Skip to content

Add opt-in monorepo initializer#165

Merged
chailandau merged 4 commits into
mainfrom
chai/monorepo-initializer
Jun 22, 2026
Merged

Add opt-in monorepo initializer#165
chailandau merged 4 commits into
mainfrom
chai/monorepo-initializer

Conversation

@chailandau

Copy link
Copy Markdown
Collaborator

Category: new-feature
User Impact: Monorepo users can safely bootstrap root and child Ghost packages without manually discovering every workspace path.
Problem: Ghost already supports root-to-child fingerprint stacks, but initialization required users to know each child path and run ghost init --scope ... by hand.
Solution: Add an opt-in ghost init --monorepo mode that creates or preserves the root package, detects workspace child package roots from deterministic metadata, and prints scoped init commands by default. Add --apply for explicit child package creation, keeping plain ghost init unchanged.

Validation:

  • pnpm test: passed, 390 tests
  • pnpm check: passed
  • pnpm build: passed in pre-push hook

Changeset: added minor changeset for the new public CLI flag/capability.

Ghost Review:

  • node packages/ghost/dist/bin.js check --base origin/main --format json: passed
  • node packages/ghost/dist/bin.js review --base origin/main --include-memory --format json: ran successfully
File changes

.changeset/green-monorepos-init.md
Adds the minor release note for the new monorepo initializer.

README.md
Documents the safe ghost init --monorepo plan mode and explicit --apply mode.

apps/docs/src/content/docs/cli-reference.mdx
Adds the monorepo initialization commands and behavior to the CLI reference.

apps/docs/src/generated/cli-manifest.json
Regenerates CLI metadata so docs expose --monorepo and --apply.

docs/fingerprint-format.md
Documents the monorepo initializer alongside nested package stack behavior.

docs/superpowers/plans/2026-06-22-monorepo-initializer.md
Captures the implementation plan and execution checklist used for the change.

docs/superpowers/specs/2026-06-22-monorepo-initializer-design.md
Captures the approved design and risk decision for plan-by-default behavior.

packages/ghost/src/fingerprint-commands.ts
Extracts init registration into a focused command module and keeps the broader fingerprint command registry under the file-size guard.

packages/ghost/src/init-command.ts
Registers ghost init, including existing root/scope behavior plus the new monorepo options and validation.

packages/ghost/src/monorepo-init-command.ts
Implements plan/apply output, root creation or preservation, child skip/create handling, and scoped command formatting.

packages/ghost/src/scan/index.ts
Exports the monorepo candidate detector for CLI use.

packages/ghost/src/scan/monorepo-init.ts
Adds deterministic workspace metadata detection for package.json workspaces and pnpm workspaces.

packages/ghost/test/cli.test.ts
Adds coverage for plan mode, apply mode, skipped existing packages, custom --memory-dir, GHOST_MEMORY_DIR, pnpm workspaces, and invalid option combinations.

Screenshots/Demos: N/A

@chailandau chailandau marked this pull request as ready for review June 22, 2026 19:15
@chailandau chailandau requested a review from nahiyankhan as a code owner June 22, 2026 19:15
nahiyankhan
nahiyankhan previously approved these changes Jun 22, 2026
@chailandau chailandau merged commit 7329ccb into main Jun 22, 2026
6 checks passed
@chailandau chailandau deleted the chai/monorepo-initializer branch June 22, 2026 19:36
@github-actions github-actions Bot mentioned this pull request Jun 22, 2026
nahiyankhan pushed a commit that referenced this pull request Jun 23, 2026
nahiyankhan pushed a commit that referenced this pull request Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants