refactor: restructure into Bun workspaces monorepo#18
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create packages/{types,templates,host-core,cli}/ with package.json and
tsconfig.json files. Add workspaces field to root package.json. Extract
shared compiler options into tsconfig.base.json.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move pure types, schemas, constants, and functions into packages/types/: - types.ts (all interfaces) - schemas/ (zod validation schemas) - constants.ts (UBUNTU_IMAGE_URL, PROJECT_MOUNT_POINT, GATEWAY_PORT) - bin-name.ts, providers.ts (pure constants and functions) - config.ts pure functions (validateConfig, configToVMConfig, sanitizeConfig) - secrets.ts pure functions (findSecretRefs, hasOpRefs, resolveEnvRefs) Original src/ files now re-export from @clawctl/types. I/O functions (loadConfig, resolveOpRefs) remain in src/lib/ for now. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move all template generators into packages/templates/src/: - lima-yaml, helpers, provision scripts - installers/ (apt, nodejs, tailscale, homebrew, op-cli, etc.) - skills/ (secret-management, op-wrapper) - completions/ (bash, zsh) - exec-approvals, bootstrap-prompt Template imports updated to use @clawctl/types. Original src/templates/ barrel files now re-export from @clawctl/templates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move all host-side VM management code into packages/host-core/src/: - drivers/ (VMDriver interface, LimaDriver implementation) - exec, provision, bootstrap, verify, prereqs, credentials - secrets-sync, infra-secrets, registry, instance-context - require-instance, git, homebrew, tailscale, parse, shell-quote, redact - config (loadConfig I/O), secrets (resolveOpRefs I/O) - headless orchestration - VM integration tests Imports updated to use @clawctl/types and @clawctl/templates. Original src/ files now re-export from @clawctl/host-core. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move CLI code into packages/cli/: - bin/ (cli.tsx entry point, clawctl-dev wrapper) - src/commands/ (all command handlers) - src/steps/ (wizard step React components) - src/components/ (reusable UI components) - src/hooks/ (React hooks) - src/app.tsx (wizard app) Remove old src/, bin/, tests/ directories (all code now in packages/). Update CLAUDE.md key directories and command paths. Update task status to Resolved. Verified: 280 tests pass, lint clean, bun build --compile works, clawctl-dev wrapper works, release build works. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Symlink bin/clawctl-dev → packages/cli/bin/clawctl-dev so the dev entry point stays at the repo root. Users don't need to know about the monorepo layout to set up their PATH. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move CLI-only types (PrereqStatus, CredentialConfig, WizardStep, ProvisioningStep) to @clawctl/cli, BIN_NAME to @clawctl/host-core, and business logic functions (configToVMConfig, sanitizeConfig, buildOnboardCommand) to @clawctl/host-core. Keep formatZodError and expandTilde as internal helpers in types (used by validateConfig). @clawctl/types now exports only: types/interfaces, schemas, constants, provider registry data, validateConfig, and secrets utilities. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the Ubuntu image URL out of @clawctl/types and into the only file that uses it (lima-yaml.ts), following the project convention of colocating constants in the template that uses them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@clawctl/types— shared types, schemas, constants, pure functions (zero I/O)@clawctl/templates— pure script/config generators (string in → string out)@clawctl/host-core— host-side VM management library (drivers, exec, provision, registry)@clawctl/cli— CLI shell (commands, Ink wizard UI, entry points)types←templates←host-core←cli; no cyclesconfig.tsandsecrets.tssplit: pure functions → types, I/O → host-corebin/clawctl-devsymlink preserved for ergonomic PATH setupMotivation
The host CLI (macOS, limactl, execa) and future VM CLI (Ubuntu, local OpenClaw, systemd) share types and schemas but almost no runtime code. Horizontal slicing now prevents the VM CLI from pulling in host-specific dependencies.
Test plan
bun test— 280 tests pass, 0 failbun run lint— cleanbun build --compile— produces working binarybun run build:release— release build worksbin/clawctl-dev --version— dev wrapper works via symlinkclawctl create --config <path>on a fresh run🤖 Generated with Claude Code