Repository navigation
fix(bootstrap): gitignore telemetry and drop absolute path from .mcp.json - #304
Conversation
…json Two files that `charter bootstrap` generates were not safe to commit. 1. `.charter/telemetry/events.ndjson` is per-machine usage data that grows with every command and conflicts on every cross-machine merge, but the generated `.charter/.gitignore` covered only `.cache/` and `context.md`, so a normal `git add -A` staged it. Add `telemetry/` to GITIGNORE_CONTENT. The pattern is relative to the config dir, matching the path telemetry.ts builds as `<configPath>/telemetry/events.ndjson`. 2. `.mcp.json` is a committed, shared file, but bootstrap wrote `path.resolve(aiDir)` into the `--ai-dir` arg, baking the author's absolute path into it. That breaks the MCP server for every other clone and for CI, and leaks the local directory layout. Write the relative `aiDir` instead. `charter serve` already resolves `--ai-dir` against its own cwd (serve.ts), which MCP clients set to the repo root, and `.ai` is its default. `charter hook print --mcp-config` already emitted a relative path, so bootstrap was the outlier. Also drop the "Generated .mcp.json uses an absolute --ai-dir path" warning, which is now false. The caller already guards on `mcpConfig.warning`. Because `writeIfChanged` rewrites on content diff, an already-bootstrapped repo picks up the new `.charter/.gitignore` on its next `charter bootstrap` or `charter init`. Tests: updated the existing `.mcp.json` assertion, which encoded the old absolute-path behaviour, and added regression tests for both parts. The `.mcp.json` test asserts on the raw generated text (no temp dir, no absolute arg), not just that the file parses. Both new tests were confirmed to fail with the bugs reintroduced. Resolves-Request: #298 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
stackbilt-admin
left a comment
There was a problem hiding this comment.
CHANGES_REQUESTED
Both one-liners are correct and both new tests are genuine regression tests — I verified that independently rather than taking the PR body's word for it. The block is not on the code; it is that the user-facing documentation for this exact file still instructs the behavior the PR just removed, plus two upgrade-path gaps.
Requested changes
1. docs/cli-reference.md and README.md still tell users to do what this PR fixes.
docs/cli-reference.md:422— "Use an absolute path for--ai-dir. A relative path like.airesolves against the MCP host's working directory at spawn time, which may not be the project root."docs/cli-reference.md:416andREADME.md:234— the copy-paste.mcp.jsonwiring example is"--ai-dir", "/absolute/path/to/.ai".docs/cli-reference.md:406— "When wiring in.mcp.json, use an absolute path ... relative paths are resolved against the working directory at spawn time, which may differ from the project root in multi-repo setups."
The PR body says of the deleted warning "No test asserted that string." True — but the same guidance lives in the docs, which are the spec users actually copy from. After this merges, charter bootstrap writes .ai while the reference manual says that is wrong. Update all four sites to show the relative form, and keep one sentence of the old warning's substance as the escape hatch: if the MCP client spawns the server outside the repo root, pass an absolute --ai-dir (or set the client's cwd). That preserves the real caveat instead of deleting it.
2. telemetry/ does not untrack telemetry that is already committed (init.ts:264).
Verified against real git: with events.ndjson already tracked, adding telemetry/ to .charter/.gitignore changes nothing — the file stays in the index and every appended event line is still staged by git add -A:
--- staged after upgrade + new telemetry write ---
.charter/.gitignore
.charter/telemetry/events.ndjson
So for the users who actually hit #298 — the ones whose telemetry is committed and conflicting on every cross-machine merge — this fix does not stop the churn. It only prevents new repos from starting it. That needs a one-line upgrade note (git rm -r --cached .charter/telemetry) in the release notes or the bootstrap output. Not asking for a CHANGELOG entry specifically, since #300 did not touch it either.
3. Do not recommend charter bootstrap --force as the .mcp.json migration.
The PR body's reviewer note says existing repos carrying the old absolute path should "run charter bootstrap --force or hand-edit." The same --force flag also drives writeAdfScaffolds(aiDir, force, preset) at bootstrap.ts:878, which overwrites the user's customized .ai/*.adf modules (backed up to .ai/.backup at bootstrap.ts:845, but still clobbered — that is what the existing test keeps custom ADF files when run with --yes but without --force guards). Re-scaffolding every ADF module to fix one JSON string is disproportionate.
Either recommend the hand-edit only, or make the existing warning at bootstrap.ts:~750 actually actionable: when existingCharter's --ai-dir arg is absolute, say so and name the one-line edit, instead of the generic "already defines mcpServers.charter (use --force to replace it)." As written, a user hitting this warning is not told that their .mcp.json is the stale-absolute-path case or what the safe fix is. A follow-up issue is acceptable if you would rather not grow this PR.
Verification performed
A. Is a relative --ai-dir safe at runtime? Yes, and it is strictly better than what it replaces. The absolute form was unconditionally broken for every clone except the author's machine, so this is not a close call.
The discriminating fact — which the PR body does not make — is that the failure mode is loud, not silent. serve.ts:76-84: if the resolved .ai does not exist, charter serve writes a structured JSON-RPC error to stdout naming the resolved path and throws CLIError. Same for a missing manifest.adf at serve.ts:85-92. That behavior is tested (serve-context.test.ts:111, "names the resolved --ai-dir path when the directory is missing"). So a client that spawns with an unexpected cwd produces a diagnosable startup error, not a server silently reading the wrong .ai. Silently reading a different project's context would require the spawn cwd to be another repo that itself has a valid .ai/manifest.adf.
The rest of the author's reasoning checks out against source: serve.ts:75 is path.resolve(getFlag(args, '--ai-dir') ?? '.ai'), .ai is already the default, and hook.ts:129 already emits a relative --ai-dir (omitting the flag entirely at default) — so bootstrap was the outlier, and hook.ts:129 is shipped and tested (hook.test.ts:156). doctor.ts:45 only checks parsed?.mcpServers?.charter !== undefined and never inspects the args shape, as claimed.
What I did not verify, and will not assert: the actual cwd each MCP client uses at spawn. I have no primary-source evidence for Cursor's or Codex's behavior, and the repo's own docs/cli-reference.md:406 warns about precisely this in "multi-repo setups." That is why item 1 asks for the escape hatch to survive in the docs rather than for the code to change. With that sentence in the docs, I am confident in the relative form.
B. The changed assertion is a genuine correction, not a weakening. creates .mcp.json with charter MCP server wiring previously asserted path.resolve('.ai'), which encoded the bug. The new test beside it is strictly stronger — it asserts on the raw generated text (not.toContain(tempDir), not.toContain(path.resolve('.ai'))) plus args.some(path.isAbsolute) === false, so it cannot pass merely because the file parses. No other test lost coverage: the only other suites touching MCP wiring are hook.test.ts:110-156 (untouched, and independently confirms the relative precedent) and score.test.ts:214, which tests --ai-dir consumption of absolute paths and is unaffected by what bootstrap writes.
C. Deleted warning. No test, no caller, no config references the string; the caller guards on if (mcpConfig.warning) at bootstrap.ts:671, so returning no warning is fine. The one exception is the docs — see item 1.
D. Gitignore pattern is correct. writeIfChanged(path.join(configDir, '.gitignore'), GITIGNORE_CONTENT) at init.ts:426 writes into the config dir; telemetry.ts:88-90 (and 148, 179) write path.join(configPath, 'telemetry', 'events.ndjson') into the same dir. A trailing-slash pattern with no interior slash matches at any depth below the .gitignore. Confirmed against real git rather than by reading:
$ git check-ignore -v .charter/telemetry/events.ndjson
.charter/.gitignore:4:telemetry/ .charter/telemetry/events.ndjson
$ git add -A && git diff --cached --name-only
.charter/.gitignore
E. Both new tests genuinely catch the bug. I reintroduced both one-liners in an isolated git worktree (the shared checkout was never modified) and got exactly 3 failures, matching the PR body:
FAIL > creates .mcp.json with charter MCP server wiring
FAIL > writes a repo-relative --ai-dir into .mcp.json, never an absolute path
AssertionError: expected '{ "mcpServers": ...' not to contain '/tmp/charter-bootstrap-test-53ZBeu'
FAIL > ignores the telemetry directory in the generated .charter/.gitignore
AssertionError: expected [ '# Charter local state', ...(3) ] to include 'telemetry/'
Tests 3 failed | 14 passed (17)
The gitignore test is line-based on trimmed lines, so a comment mentioning telemetry would not satisfy it. Minor nit, non-blocking: expect(raw).not.toContain(tempDir) could be brittle on platforms where os.tmpdir() differs from its realpath after chdir; the adjacent not.toContain(path.resolve('.ai')) and the isAbsolute check already cover that case, so nothing needs to change.
F. Upgrade path — see items 2 and 3. The gitignore half does reach already-bootstrapped repos via writeIfChanged as claimed, but only for telemetry that is not yet tracked. The .mcp.json half does not self-heal, and the warning users hit does not tell them what to do.
G. Swept for other generators writing absolute paths into committed files — clean. .mcp.json was the only one. The remaining path.resolve calls in bootstrap.ts (417, 418, 427, 447, 448, 915, 975, 1113-1115) are all filesystem operations or existence checks, never interpolated into generated content. hook.ts:280,289 likewise resolve the hooks dir for fs use. No template in packages/cli/src interpolates path.resolve(...) or process.cwd() into written content, and CLAUDE_SESSION_HOOK_CONFIG (hook.ts:107) emits the bare charter context-refresh --once command with no path.
Baseline
pnpm test 884/884 across 62 files and pnpm run typecheck clean, both reproduced locally on auto/bugfix/issue-298 — matching the PR's claim against the 882 baseline.
Round 1 review follow-up. The code fix was correct but what surrounded it was not: the manual still instructed the behaviour the fix removed, and neither upgrade path was stated anywhere a user would find it. 1. Docs contradicted the generator. docs/cli-reference.md told users to "Use an absolute path for --ai-dir" and shipped a copy-paste .mcp.json example with an absolute path, in three places; README.md carried the same example. All four now show the repo-relative `.ai`. The real caveat survives as the escape hatch: if the MCP client spawns the server outside the project root, set the client's cwd or pass an absolute --ai-dir and keep it untracked. Noted that a wrong cwd fails loudly -- serve.ts emits a startup error naming the resolved path -- so the relative form is diagnosable, not silently wrong. 2. Gitignoring telemetry does not untrack telemetry. A gitignore entry never removes a path already in the index, so for the repos that hit this -- the ones whose events.ndjson is committed and conflicting -- the generator fix alone changes nothing. Added an upgrade section under `charter init` with the one-time `git rm -r --cached .charter/telemetry`, and documented which parts of .charter/ are local-only. 3. Stopped recommending `bootstrap --force` as the .mcp.json migration. The same flag drives writeAdfScaffolds, so it re-scaffolds .ai/*.adf and overwrites hand-authored modules -- disproportionate for fixing one JSON string, and a data-loss risk. ensureProjectMcpConfig now detects the stale-absolute-path case specifically and names the one-line hand-edit at the moment the user hits the warning, explicitly steering off --force. The generic branch notes the ADF re-scaffold side effect too. Tests: added a regression test asserting the warning names the offending path, names the replacement, and says not to use --force. Verified it fails when the detection is disabled. 885/885, typecheck clean. Resolves-Request: #298 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The setup phase collected warnings but never printed them. Phase 3 loops `adfResult.step.warnings` and prints each as " Warning: ...", phase 2 had no such loop, so setup warnings only ever reached the user as a number in the closing "Bootstrap complete. N warning(s)." tally. That made the previous commit's stale-absolute-path message unreachable in practice: a user running plain `charter bootstrap` saw "1 warning" and no way to learn which file, what was wrong with it, or how to fix it. The message was only visible with --format json. The same gap hid the older generic "already defines mcpServers.charter" warning, which is likely why nobody noticed it was recommending a destructive --force. Mirrors the phase 3 loop exactly. Retargeted the regression test from the JSON result to the printed log lines, so it asserts what a default run actually shows rather than a field the user never sees. Verified the test fails when the loop is removed. 885/885, typecheck clean. Resolves-Request: #298 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
stackbilt-admin
left a comment
There was a problem hiding this comment.
APPROVED
Round 2 against c8d76e9. All three round-1 items are genuinely addressed, and the scope addition is correct. I re-verified each one rather than reading the diff and agreeing — including the part the author self-reported as initially broken.
Round-1 items — closed
1. Docs. All four sites now show the repo-relative .ai (docs/cli-reference.md:421, :431-439; README.md:234-240). The escape hatch survived rather than being deleted, which was the actual ask: cli-reference.md:439 tells clients spawning outside the repo root to set cwd or pass an absolute --ai-dir, and correctly folds in the loud-failure property with a pointer to the Startup errors section. :421 also fixes the subtler half — it now says "resolved to an absolute path at startup, relative to the working directory the server was spawned in," where the old text asserted absolute resolution without saying against what. The remaining absolute example at :418 is a bare CLI invocation, not .mcp.json wiring, so it is correctly left alone.
2. Telemetry upgrade note (cli-reference.md:124-138) states the thing that actually matters and that I had to demonstrate empirically last round — "Adding the ignore rule does not untrack a file that is already in the index" — gives the exact git rm -r --cached .charter/telemetry, and notes the file stays on disk so charter telemetry report keeps working. That last detail matters and I would not have thought to ask for it. Agreed on not building a doctor check here.
3. Fixed in code rather than retracted from the PR body, which is the better outcome. absoluteAiDirArg (bootstrap.ts:707-719) is defensively written — non-object, array, missing or non-array args, missing flag, and non-string value all return undefined before path.isAbsolute is reached. The generic fallback at bootstrap.ts:794 was also improved to lead with the hand-edit and disclose that --force re-scaffolds .ai/*.adf.
Verification performed
Stale-path detection fires end-to-end, and the message is actionable. I ran a real bootstrap in text mode against a .mcp.json carrying the exact WSL path shape from #298. Printed output:
[2/7] Setting up governance...
Created .charter/config.json
...
Warning: Skipped MCP config update: .mcp.json pins an absolute --ai-dir
(/mnt/c/users/someone/wargames/.ai), which breaks the MCP server for every
other clone and for CI. Edit .mcp.json and replace that path with ".ai".
Do not use --force for this: it also re-scaffolds .ai/*.adf and would
overwrite customized modules.
It names the offending path, the exact replacement, and the reason not to reach for --force. .mcp.json was left byte-identical — no surprise rewrite. That is a hand-edit a user can act on without further instruction. (One documented case where the advice is wrong for the reader — see follow-up 3.)
The phase-2 loop is correct and consistent with phase 3, and does not double-print. bootstrap.ts:159-161 mirrors :184-186 exactly — same options.format === 'text' guard, same Warning: ${w} shape, same position after the created/updated listings and before the trailing blank line.
I checked the double-printing risk specifically, because bootstrap.ts:540 does warnings.push(...detection.warnings) and detection warnings are already printed in phase 1. That push is inside runDetectPhase, so those land on the detect step, not setup — no leakage, and a per-step dump confirms each warning appears exactly once.
Nothing newly surfaced that should have stayed silent. runSetupPhase (bootstrap.ts:612-907) pushes warnings from exactly two places: :677 (mcpConfig.warning) and :690 (Setup failed: ${msg}). The first is the five ensureProjectMcpConfig variants — malformed JSON, non-object root, non-object mcpServers, already-defined, stale-absolute — all actionable and all previously invisible in text mode. The second mirrors phase 3's ADF init failed: at :986, which has always been printed by the phase-3 loop. So the failure-path behavior is not a new duplication pattern; it matches the existing precedent.
The new test genuinely asserts on printed output. I did not take this on the comment. I deleted only the print loop at bootstrap.ts:159-161, leaving the warning intact in the JSON result, and the test failed on exactly the right assertion:
FAIL > warns specifically about a stale absolute --ai-dir and does not recommend --force
AssertionError: expected undefined to be defined
Had it been reading the JSON result it would still have passed. It also asserts the path, the ".ai" replacement, and Do not use --force, so it pins the steer-away rather than merely the presence of some warning.
Suite and typecheck: 885/885 across 62 files, typecheck clean, reproduced locally at c8d76e9. Matches your figure.
Answers to your specific questions
Is the scope addition in scope? Keep it. I find the author's argument persuasive for the same reason you do, and would add: shipping item 3 without it would have been a silent no-op for every text-mode user, which is the same class of defect as the original bug — a correct value written somewhere nobody reads. It is five lines copied from the adjacent phase, it has a test that fails without it, and splitting it would leave the PR claiming a fix users cannot see. Right call.
Is the author's inference about the old --force advice over-reading? Partly — state it narrowly. Invisibility does explain why that specific warning's destructive advice went unchallenged; it was unreachable in the default text path. But it does not generalize, and the author's own correction is the counter-evidence: bootstrap.ts:967 and :969 advise --force as a routine remedy and are printed, since phase 3 has always looped its warnings. So --force-as-remedy has been visible to users all along in the pointer-file path and still went unchallenged. The honest claim is the narrow one: invisibility explains this instance, not the pattern. Agreed those two are out of scope here.
Non-blocking follow-ups
None affects this approval.
-
The count-but-don't-print gap still exists in phases 6 and 7.
populate(accumulated atbootstrap.ts:303, print block:305-315) anddoctor(:322) still add to the warning tally with no print loop. This is user-visible: my probe's trailer readBootstrap complete. 3 warnings.while only 2Warning:lines were printed, the third being a populate-phase warning text mode swallowed. (The specific warning I hit was an artifact of running from source, but the swallowing is real and would hide a genuine populate failure the same way.) Worth folding into whichever follow-up you file for:967/:969. -
absoluteAiDirArgis platform-asymmetric.path.isAbsoluteis platform-dependent:path.posix.isAbsolute('C:\\Users\\x')isfalse(verified), so a.mcp.jsongenerated on Windows and then cloned onto Linux or macOS falls through to the generic warning instead of the specific one. The reverse works —path.win32.isAbsolute('/mnt/c/x')istrue— so the common WSL-authored case is covered and the fallback is now decent. A drive-letter check would close it if the Windows-author case is worth it. -
The documented escape hatch now trips the new warning, and its remedy is not literally actionable. This one is created by round 2, from the new warning and the new docs paragraph interacting, so it is worth recording even though it should not hold the PR.
cli-reference.md:439andREADME.md:240tell a user whose client spawns outside the repo root to "pass an absolute--ai-dirand keep that entry out of version control." A user who follows that advice then gets the new warning on everybootstraprun, asserting their config "breaks the MCP server for every other clone and for CI" and instructing them to replace it with.ai— advice that is wrong for them, since the whole premise of their setup is that the relative path does not resolve. The warning's claim is only true when.mcp.jsonis committed, which the detection does not check.Two small precision issues: the warning text could scope its claim (".. breaks the MCP server for every other clone if
.mcp.jsonis committed"), or the docs could note the warning is expected in that configuration. And "keep that entry out of version control" cannot be done as written — you cannot untrack one key of a JSON file. The realistic move is gitignoring.mcp.jsonwholesale, which is exactly what this repo does for itself (.gitignore:9, confirmed bygit check-ignore -v .mcp.json). Saying that explicitly would make the escape hatch followable.
Round 2 review follow-up. The previous commits left the tool contradicting its own manual: the docs offer an absolute --ai-dir as the escape hatch for clients that spawn outside the repo root, while the new warning fired on exactly that, telling anyone who followed the documented advice that their config was broken on every run. The harm in #298 is a machine-specific path inside a committed, shared file. An absolute path in an untracked or gitignored .mcp.json harms nobody and is the supported escape hatch. So the warning is now gated on whether git actually tracks .mcp.json. isTrackedByGit fails closed, via the existing runGit helper: outside a git repo, before `git init`, or with git unavailable it reports false and bootstrap stays quiet rather than warning on a guess. Silence is the safe outcome here -- the cost of missing a warning is one stale path, the cost of a false one is telling correct users they are wrong. Also replaced the remedy text, which was not literally actionable: "keep that entry out of version control" cannot be done per-JSON-key. It now names gitignoring .mcp.json wholesale plus `git rm --cached`, the move that actually works. Docs escape hatch in cli-reference.md and README.md aligned with the same instruction, and the docs now state the warning is gated on tracked-ness so a deliberately machine-local config stays quiet. Tests: tracked .mcp.json warns; untracked stays silent; outside a git repo stays silent. All three use a real git index rather than a mock, since the distinction under test is exactly what git reports. Verified the two silence tests fail when the gate is removed. 887/887, typecheck clean. Resolves-Request: #298 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ix (#316) A gitignore entry never untracks an already-tracked file, so a repo bootstrapped before #304 keeps staging .charter/telemetry/events.ndjson on every `git add -A` -- silently, and precisely for the users who hit the original bug. doctor exists to catch exactly this: repo state that drifted from what the current generator would produce. The diagnostic is INFO, not WARN, and deliberately so. doctor fails CI on any WARN, and this is state Charter's own bootstrap created rather than anything the user opted into, so warning would break an existing repo's CI purely on upgrade -- breaking the promise in docs/cli-reference.md that the advisory nudge "never fails an existing repo's CI on upgrade", and failing the bare `charter doctor --ci` invocation that same document prescribes. Same ruling as the source LOC budget nudge (#186). The remedy lists the ignore entry BEFORE `git rm -r --cached`: after rm --cached the file is untracked but still on disk, so the reflexive `git add -A` that caused the problem would re-stage it before the user finished reading. A test pins that ordering so it cannot be silently reversed. Detection reads only the git index via `git ls-files`, never fs.existsSync, so the case-insensitive /mnt/c host cannot let a test pass while the logic is wrong on a case-sensitive checkout. The path is derived from options.configPath rather than hardcoded, so a custom --config dir is detected and printed correctly, quoted so a path containing a space stays copy-pasteable. A git failure omits the check rather than reporting a PASS it did not earn. Closes #306
Review follow-up on #307. The hoist already makes omission impossible -- one steps.push, all seven phases through it. This closes the other half of the contract, which nothing type-checks: completePhase de-duplicates by exact string match against the array `render` returns, so a render that claims a warning it never printed swallows it. Phase 5 returned installResult.step.warnings wholesale while drawing only the `Failed:`, `Hint:` and `Retry` shapes. That is accurate today -- runInstallPhase records exactly those three and details.error is the same msg -- but a fourth warning added to that phase later would have been silently swallowed with no test failing. It now accumulates the strings it actually printed and claims only those, matching what phase 4 already does. The JSDoc drops the #304/#307 history paragraph, which restated the CHANGELOG, and the "Returns the number of warnings" line, which restated the signature. It keeps the render contract and now states the trust relationship the de-dup turns on, since no type enforces it. completePhase is exported so the contract can be tested directly; the repo already exports internals this way (filePathToKeywords, buildSuggestReport). Six unit tests pin it: an unclaimed warning prints, a claimed one does not reprint, a partial claim leaves the rest to the helper (the phase 5 trap), a phase with no section still surfaces warnings, a silent one prints nothing, and --format json records the step while drawing nothing. Added one end-to-end guard on the real phase 5: every warning it records must be readable somewhere in its section. Verified by construction rather than by reasoning -- with phase 5 reverted to the wholesale claim it still passes, because today that claim is accurate, and with the section additionally stopped from drawing Hint/Retry it fails with "install warning is invisible in text output: Retry manually: npm install". It is a guard against a future over-claim, not a detector of current code. The reviewer suggested vi.mock for the phase 6 require. Probed both spellings -- vi.mock('../commands/adf-populate') and vi.mock('./adf-populate') -- and neither intercepts it: runPopulatePhase reaches the module through a bare Node require, which resolves outside vitest's module graph, so the recorded warning is still the resolver error rather than the mock's. The phase 6 end-to-end test therefore keeps its explicit precondition, now documenting the quirk and telling a future maintainer to delete the test if it ever trips, since the contract tests cover that path deliberately. Tests 950/950, typecheck clean. Built-CLI output byte-identical to the previously reviewed build across the same fixture.
…ute --ai-dir (#317) Two independent fixes. 1. Phases 6 (populate) and 7 (doctor) tallied step.warnings.length but never printed the text under text format, so those warnings reached a plain `charter bootstrap` user only as a number in "Bootstrap complete. N warnings." That is not cosmetic: #304 found invisible warning text advising a destructive `bootstrap --force` (#305), unnoticed precisely because it never printed. Rather than copying the print loop into two more places, this hoists it into completePhase(). It is now the only site that appends to result.steps, and it prints every warning the phase's own renderer did not report drawing -- so a phase cannot reach the JSON payload without its warnings reaching the screen, and a future phase 8 that forgets to print is structurally impossible rather than merely absent from today's code. Phase 5 returns only the lines it actually drew instead of its whole warning array. The wholesale claim was accurate today, but a fourth install warning added later would have been silently swallowed with nothing failing. Output is byte-identical to before for every phase that already printed -- verified by diffing real CLI output across text, --mode lean and --format json fixtures; the sole delta is the previously-invisible warning line. 2. absoluteAiDirArg gated on path.isAbsolute(), which on POSIX is false for a Windows drive-letter or UNC path -- so a .mcp.json authored on native Windows and read on Linux, CI or a container escaped the stale-path warning that #298 added it for. It now also consults path.win32.isAbsolute(), documented Node behavior rather than hand-rolled regexes with escaping to get wrong. A rooted driveless path is covered too: it cannot be a legitimate committed value, being a backslash-bearing relative name on POSIX and current-drive-dependent on Windows. Drive-relative C:project\.ai stays correctly undetected. Closes #307
Closes #298
Two files
charter bootstrapgenerates were not safe to commit, and nothing marked them local-only. Both parts are independent and both are fixed here.1. Telemetry was not gitignored
packages/cli/src/commands/init.ts—GITIGNORE_CONTENTcovered only.cache/andcontext.md, so.charter/telemetry/events.ndjsonwas staged by a normalgit add -A. It is per-machine usage data carrying timestamps and command history, it grows with every command, and it conflicts on every cross-machine merge.Added
telemetry/to the constant. The file is written into the config dir, so the pattern is relative to it and covers the<configPath>/telemetry/events.ndjsonpath built inpackages/cli/src/commands/telemetry.ts:52.Already-bootstrapped repos do get this.
writeIfChanged(init.ts:445) rewrites when content differs, so the nextcharter bootstrap/charter initupgrades an existing.charter/.gitignore. (It also clobbers hand-edits to that file — pre-existing behaviour, not changed here.)2.
.mcp.jsonhardcoded an absolute pathpackages/cli/src/commands/bootstrap.ts:704wrotepath.resolve(aiDir)into the--ai-dirarg..mcp.jsonis committed and shared, so this broke the MCP server for every other clone and for CI, and leaked the author's directory layout.Now writes the relative
aiDir. Confirmed safe at runtime:serve.ts:75doespath.resolve(getFlag(args, '--ai-dir') ?? '.ai')— it resolves relative paths against its own cwd, which MCP clients set to the repo root, and.aiis already its default. Corroborating evidence:charter hook print --mcp-config(hook.ts:129) already emitted a relative--ai-dirand omitted the flag entirely at default, so bootstrap was the outlier.doctor.tsonly checks for the presence ofmcpServers.charterand never inspects the args shape.Also removed the now-false warning
"Generated .mcp.json uses an absolute --ai-dir path". The caller already guards onmcpConfig.warning, so returning no warning is fine. No test asserted that string.Tests
pnpm test884/884 (882 baseline + 2 new),pnpm run typecheckclean, both from the repo root.One existing assertion changed:
creates .mcp.json with charter MCP server wiringexpectedpath.resolve('.ai'). That test encoded the bug, so it was corrected to expect.ai— not weakened; the new dedicated test around it is strictly stronger.Both new tests were verified to actually catch the bug: with the two one-liners reverted, all three fail (
expected [...] not to contain '/tmp/charter-bootstrap-test-iZPEe9', andexpected [...] to include 'telemetry/'). The.mcp.jsontest asserts on the raw generated text — no temp dir, no absolute arg anywhere inargs— so it would not pass merely because the file parses.Reviewer notes
.mcp.jsonand no.charter/.gitignoreon disk, its root.gitignorealready ignores.charter/telemetry/and.mcp.json, andgit ls-files .charter/shows nothing undertelemetry/. So no untracking was needed anywhere — the fix is purely to the generator for downstream repos.sameServer(bootstrap.ts:~743) mismatches, and without--forcethe existing"already defines mcpServers.charter"warning fires. Users runcharter bootstrap --forceor hand-edit. That path is pre-existing logic and deliberately untouched here.bootstrap.tsaround lines 704 and 756, not 376/908, and does not touchadf.ts,hook.tsor.githooks/pre-commit.🤖 Generated with Claude Code
Round 1 review follow-up (commits
1767ba4,c8d76e9)All three required changes are in.
pnpm test885/885,pnpm run typecheckclean.1. Docs no longer contradict the generator. The reviewer was right that "no test asserted that string" was true but incomplete — the instruction survived in the manual people copy from. Updated all four sites to the repo-relative
.ai:docs/cli-reference.md(the--ai-dirbullet, the wiring example, and the "Use an absolute path" sentence) and theREADME.mdexample. The genuine caveat is kept as an escape hatch rather than deleted: if the MCP client spawns the server outside the project root, set the client'scwdor pass an absolute--ai-dirand keep it untracked. I also folded in the reviewer's stronger argument — a wrong cwd fails loudly, sincecharter serveemits a startup error naming the resolved path, so the relative form is diagnosable rather than silently wrong.2. Telemetry upgrade note added to the docs. Confirmed the reviewer's point: a gitignore entry never untracks a path already in the index, so the generator fix alone does nothing for the repos that actually hit #298. Added an "Upgrading: untracking already-committed telemetry" section under
charter initwith the one-timegit rm -r --cached .charter/telemetry, plus a line stating which parts of.charter/are local-only vs committed. It notes the file stays on disk, socharter telemetry reportkeeps working.3.
bootstrap --forceis no longer the recommended.mcp.jsonmigration. This was the sharpest finding and it is fixed in code, not just retracted from the PR body.ensureProjectMcpConfignow detects the stale-absolute-path case specifically via a newabsoluteAiDirArghelper and warns:The user gets the exact fix at the moment they hit the warning, and is steered off the destructive flag. The generic branch now also notes the ADF re-scaffold side effect. New regression test asserts the warning names the offending path, names the replacement, and contains "Do not use --force"; verified it fails when the detection is disabled.
Reported, not fixed (per the lead's ask):
bootstrap --forceis not recommended as a routine remedy anywhere else. Every other--forcein docs and command output is scoped to its own command (adf init,adf populate,adf compile,hook install), anddocs/cli-reference.md:641documents bootstrap's neutrally. The latent issue worth its own ticket is that bootstrap's single--forcefans out to hook overwrite + ADF re-scaffold + config overwrite at once, with no way to opt into just one — unlike every other command, whose--forceis narrow.The warning was invisible — fixed in
c8d76e9Item 3 was not actually delivered by the code change alone, and this is worth calling out rather than burying.
The setup phase collected warnings but never printed them. Phase 3 loops
adfResult.step.warningsand prints each asWarning: ...; phase 2 had no such loop, so setup warnings only ever reached the user as a number in the closingBootstrap complete. N warning(s).tally. A user with a stale absolute path running plaincharter bootstrapwould have seen1 warningand nothing else — the new actionable message was only reachable via--format json.That is a pre-existing gap, not one this PR introduced, and it is very likely why nobody noticed the old generic warning was recommending a destructive
--force: no one could read it.Phase 2 now mirrors phase 3's loop. The regression test was retargeted from the JSON result to the printed log lines, so it asserts what a default run actually shows; verified it fails when the loop is removed. All other log-inspecting tests (security-sensitive, lean-mode) still pass with the extra lines.
Correction to my earlier
--forcesurveyMy first sweep was truncated by a
head -20and cut off before the end ofbootstrap.ts. Re-running it unfiltered found two morebootstrap --forcerecommendations I had missed, both in ADF-pointer warnings:bootstrap.ts:962—${pf.name} has custom content; skipping pointer (run 'charter adf migrate' first or use --force to overwrite)bootstrap.ts:964—${pf.name} already exists; skipping (use --force to overwrite)These are the same blunt
bootstrap --forcebeing advised as a routine remedy, in exactly the pattern the review flagged — and, per the fix above, they were unreachable in text mode until this PR. I have not changed them; they are reported for the lead to file separately.Round 2 review follow-up (commit
8cff7a1)pnpm test887/887,pnpm run typecheckclean.The PR contradicted itself, and that is now fixed. Round 1 added a docs escape hatch saying you may pin an absolute
--ai-dirif your client spawns outside the repo root — and a warning that fired on exactly that. Anyone following the documented advice would have been told every run that their config was broken. That is the same failure mode this backlog is about, so it was worth a round rather than a footnote.The gate. The harm in #298 is a machine-specific path inside a committed, shared file. An absolute path in an untracked or gitignored
.mcp.jsonharms nobody and is the supported escape hatch. The warning is now gated onisTrackedByGit('.mcp.json'):.mcp.jsonand it pins an absolute--ai-dir→ warngit init, or git unavailable → silentDetection reliability, since the lead asked for this explicitly rather than something flaky:
isTrackedByGitgoes through the existingrunGithelper (git ls-files --error-unmatch -- .mcp.json, no shell) and fails closed — every failure path returnsfalseand stays quiet. It cannot crash bootstrap. Silence is the correct bias: a missed warning costs one stale path, a false warning tells correct users they are wrong.The remedy text was also not literally actionable, as the reviewer noted — "keep that entry out of version control" cannot be done per-JSON-key. It now names the move that actually works, gitignoring the file wholesale:
The docs escape hatch in
cli-reference.mdandREADME.mdnow gives that same instruction, and the reference states the warning is gated on tracked-ness so a deliberately machine-local config stays quiet. This repo already gitignores.mcp.jsonat.gitignore:9, so the recommendation matches existing practice.Tests — three cases, using a real git index rather than a mock, since the distinction under test is precisely what git reports: tracked warns, untracked stays silent, no-git-repo stays silent. Verified both silence tests fail when the gate is removed (
expected ' Warning: Skipped MCP config update:…' to be undefined).Left alone per the lead: phases 6/7 count-but-don't-print, and
absoluteAiDirArgnot matching Windows paths on POSIX. Both are being filed separately.