Skip to content

fix(cli): meta init --refresh-docs must not re-scaffold or regress stack in a monorepo (#163)#164

Merged
dmealing merged 1 commit into
mainfrom
fix/163-refresh-docs-monorepo
Jul 4, 2026
Merged

fix(cli): meta init --refresh-docs must not re-scaffold or regress stack in a monorepo (#163)#164
dmealing merged 1 commit into
mainfrom
fix/163-refresh-docs-monorepo

Conversation

@dmealing

@dmealing dmealing commented Jul 4, 2026

Copy link
Copy Markdown
Member

Fixes #163.

Two coupled bugs

1. --force cancelled the refresh-only short-circuit → full project re-scaffold.
The early return in init() was gated on !opts.force, so meta init --refresh-docs --force fell through to the full scaffold path and re-created metaobjects/, metaobjects.config.ts, codegen/generators/, .metaobjects/config.json, and package.meta.json (and scaffolded into sibling packages). Refresh now short-circuits whenever the project exists, regardless of --force. --force on this path instead means "overwrite hand-edited docs in place rather than writing the .new sidecar."

2. Refresh re-detected the stack from a root-only probe, discarding the correct persisted stack.
writeAgentContext re-detected from package.json deps + filenames at the repo root only. On a monorepo the client (React/TanStack) deps live in a sibling package, and a Maven-built Kotlin server has no gradle file — so detection collapses to java server, no client, and the refreshed docs regress (and shrink, since a narrower stack assembles fewer skill reference fragments). The correct stack is already persisted in .metaobjects/.agent-context.json; a new stackForAgentContext helper reuses it, with precedence explicit --server/--client > persisted manifest > detection.

Scope: TS-CLI-only — no cross-port change, no conformance fixture

meta init / --refresh-docs / stack-detection are the Node TS CLI's. The other ports only expose agent-docs, which redirects to the Node CLI (Python literally prints npx meta agent-docs). This is CLI scaffolding, not metamodel behavior — so there's nothing to fan out and no conformance corpus involved.

Tests

Adds regression coverage in init-refresh-docs.test.ts (each fails against pre-fix code):

  • --refresh-docs --force refreshes docs only — does not re-scaffold the project.
  • --refresh-docs --force overwrites a hand-edited doc in place (no .new).
  • refresh preserves a persisted multi-package stack instead of re-detecting.

Full CLI suite green (361 pass), typecheck clean. Reviewed for correctness + simplified (single-ternary stack helper); the persisted-stack preference intentionally governs the shared --force/--docs-only paths too (documented in the helper).

🤖 Generated with Claude Code

…ack in a monorepo (#163)

Two coupled bugs made `meta init --refresh-docs` unusable on a multi-module
monorepo:

1. `--force` cancelled the refresh-only short-circuit. The early return was
   gated on `!opts.force`, so `--refresh-docs --force` fell through to the FULL
   project scaffold — re-creating metaobjects/, metaobjects.config.ts,
   codegen/generators/, config.json, package.meta.json (and scaffolding into
   sibling packages). Refresh now short-circuits whenever the project exists,
   regardless of --force; --force on this path instead means "overwrite
   hand-edited docs in place rather than writing the .new sidecar".

2. Refresh re-detected the stack from a root-only probe, discarding the correct
   persisted stack. On a monorepo the client deps live in a sibling package and
   a Maven-built Kotlin server has no gradle file, so root detection yields
   "java server, no client" and the refreshed docs regress (and shrink, since a
   narrower stack assembles fewer reference fragments). The correct stack is
   already persisted in .metaobjects/.agent-context.json; refresh now reuses it
   (precedence: explicit --server/--client > persisted manifest > detection).

TS-CLI-only: meta init / refresh / stack-detection are the Node CLI's; the other
ports only expose agent-docs (which redirects to the Node CLI). No cross-port
change and no conformance fixture — this is CLI scaffolding, not metamodel
behavior. Adds regression tests: --refresh-docs --force writes docs only (no
re-scaffold) and preserves a persisted multi-package stack.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ew1XfYSbEAezxjs9opynAe
@dmealing
dmealing merged commit a0fa3a5 into main Jul 4, 2026
1 check passed
@dmealing
dmealing deleted the fix/163-refresh-docs-monorepo branch July 4, 2026 15:35
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.

meta init --refresh-docs mis-detects stack + re-scaffolds root in a multi-module monorepo

1 participant