fix(cli): meta init --refresh-docs must not re-scaffold or regress stack in a monorepo (#163)#164
Merged
Merged
Conversation
…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
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.
Fixes #163.
Two coupled bugs
1.
--forcecancelled the refresh-only short-circuit → full project re-scaffold.The early return in
init()was gated on!opts.force, someta init --refresh-docs --forcefell through to the full scaffold path and re-createdmetaobjects/,metaobjects.config.ts,codegen/generators/,.metaobjects/config.json, andpackage.meta.json(and scaffolded into sibling packages). Refresh now short-circuits whenever the project exists, regardless of--force.--forceon this path instead means "overwrite hand-edited docs in place rather than writing the.newsidecar."2. Refresh re-detected the stack from a root-only probe, discarding the correct persisted stack.
writeAgentContextre-detected frompackage.jsondeps + 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 tojava 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 newstackForAgentContexthelper 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 exposeagent-docs, which redirects to the Node CLI (Python literally printsnpx 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 --forcerefreshes docs only — does not re-scaffold the project.--refresh-docs --forceoverwrites a hand-edited doc in place (no.new).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-onlypaths too (documented in the helper).🤖 Generated with Claude Code