Repository navigation
fix(cli): init writes agent docs every agent reads, at the project root, never in the home folder - #7497
Conversation
… never in the home folder The default writes the agent-docs block to AGENTS.md and a managed one-line import of it to GEMINI.md. In a project with a CLAUDE.md or .claude/CLAUDE.md, it also writes the block to .claude/CLAUDE.md, never root CLAUDE.md: Claude Code skips AGENTS.md there and does not follow an import from a subfolder session without asking, and Copilot CLI reads root CLAUDE.md beside AGENTS.md. Each tested agent then reads the block once, from the root or a subfolder. Init run from a subfolder writes at the nearest folder with a package.json, within its repository and never the home folder. No mode writes agent docs into the home folder; init reports install-failed there and exits 0.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
…codes - The Claude Code copy goes in the Claude file the project already has: root CLAUDE.md, else .claude/CLAUDE.md. Many projects ignore .claude/ in git, so a new .claude/CLAUDE.md left a fresh clone with no copy. When both exist, root CLAUDE.md holds it. Init creates no Claude file. - GEMINI.md gets no import when it already imports AGENTS.md, inline included, or when the project's Gemini settings read AGENTS.md. - A GEMINI.md that resolves outside the project is skipped and reported; the rest is written and init exits 0, as before. - The project root is the nearest package.json that declares an Astryx package, else the nearest package.json, else the folder init runs in, as before. The home folder and the settings folders in it are refused. - --agent claude and --agent all never leave a block in both Claude files, and --agent all keeps the GEMINI.md import. - doctor looks for the docs where init writes them. It fails, and the setup check reads not set up, when only the GEMINI.md import of an AGENTS.md without a block is left.
init refused every folder below a settings folder in the home folder, so a project in an agent worktree (~/.codex/worktrees/<id>/<repo>, ~/.cursor/worktrees/<repo>/<id>) got no agent docs, and upgrade could not refresh a block there. Now only the home folder itself, and a folder in a settings folder that belongs to no project there, are refused. A folder below the settings folder with a package.json at or above it is a project. The top of a settings folder stays refused even with a package.json, because agents read the files there in every project.
There was a problem hiding this comment.
This is a careful, well-tested change, but approval waits on a maintainer decision. No current spec covers the new default agent-docs layout for astryx init: always writing AGENTS.md, the Claude copy and .claude/CLAUDE.md removal, the created GEMINI.md import, writing at the resolved project root, and refusing the home folder and dot-folders in it. A maintainer needs to provide or identify the governing spec for it and settle whether it ships as a [fix] patch. Separately, please fix these:
- The per-command setup nudge still checks only the working folder, so after
initin a nested package such asfunctions/it keeps asking forinit, and re-running it there cannot clear it. - The
--agenthelp and the working-with-ai guide still sayallcovers every existing agent doc, and do not mention thatclaudeandallnow remove the block from.claude/CLAUDE.md. - When root
CLAUDE.mdimportsAGENTS.mdand.claude/CLAUDE.mdexists, the copy goes to.claude/CLAUDE.md, so Claude Code reads the block twice.
[Automated review]
| // The docs belong at the project root, not in the subfolder init ran in; | ||
| // with no project above, they go where init ran, as before. Explicit | ||
| // --agent-docs-path entries stay relative to where init ran. | ||
| const root = resolveAgentDocsRoot(cwd) ?? cwd; |
There was a problem hiding this comment.
Init now writes at this resolved root, but the per-command setup nudge in clients/cli/index.mjs (lines 548–551) still calls isAstryxInitialized(cwd) only. In a nested package such as functions/ (its own package.json, no Astryx), every text command keeps printing "Next step: run … init", and re-running init there cannot clear it. Checking resolveAgentDocsRoot(cwd) ?? cwd there as well, as doctor now does, would keep the two in step.
| const existing = discoverAgentDocs(targetDir); | ||
| // Inject into all existing files, create defaults for each tool. GEMINI.md | ||
| // is left out: the default keeps a one-line import of AGENTS.md there. | ||
| const existing = discoverAgentDocs(targetDir).filter(p => p !== GEMINI_MD); |
There was a problem hiding this comment.
--agent all now leaves GEMINI.md out here. With --agent claude or all, the block is also removed from .claude/CLAUDE.md when CLAUDE.md gets it. The --agent option text in clients/cli/commands/init.doc.mjs still says "all (every existing agent doc, …)", and the guide's Manual options in assets/docs/working-with-ai.doc.mjs say "every agent file present", so neither help nor the guide describes these changes.
| // already holds the block. | ||
| const claudeCopy = aliases.has(CLAUDE_MD) | ||
| ? null | ||
| : ([CLAUDE_MD, CLAUDE_DIR_MD].find(p => present.has(p) && !wrappers.has(p)) ?? null); |
There was a problem hiding this comment.
When root CLAUDE.md imports AGENTS.md and .claude/CLAUDE.md exists, this gives the copy to .claude/CLAUDE.md. Claude then reads the block through CLAUDE.md → AGENTS.md and again from .claude/CLAUDE.md, which the installAgentDocs comment and the changeset say should not happen. Treating a root wrapper or alias of AGENTS.md as already holding the copy, so .claude/CLAUDE.md is stripped, would fix it.
init skipped GEMINI.md when the project's .gemini/settings.json pointed Gemini CLI at AGENTS.md. Gemini loads project settings only when it starts at the project root, so a session started in a subfolder read no copy of the block. Write the import whatever the settings say, and skip it only when GEMINI.md already imports AGENTS.md. Started at the root with such settings, Gemini reads two copies: a duplicate beats none.
… follow init - The Claude Code file the project has, root CLAUDE.md else .claude/CLAUDE.md, holds the copy even when it imports AGENTS.md: Claude Code does not follow that import in a session started in a subfolder, so without the copy it read none there. A refresh keeps and updates that copy instead of removing it. - The reminder to run init that commands print looks at the project root too, so it stops once init has run in a nested package. - The --agent help and the working-with-AI guide say that all skips GEMINI.md, and that claude and all remove the block from .claude/CLAUDE.md when CLAUDE.md gets it.
There was a problem hiding this comment.
Approval waits on a maintainer decision: no current spec covers the new default agent-docs layout for astryx init (always writing AGENTS.md, the Claude copy and the .claude/CLAUDE.md removal, the GEMINI.md import, writing at the resolved project root, and refusing the home folder and dot-folders in it). A maintainer needs to provide or identify the governing spec for it, for example by approving the rules drafted in #7539, and settle whether it ships as a [fix] patch and whether AST-040's consumer-file protections apply to the new GEMINI.md and .claude/CLAUDE.md edits. Separately, please:
- make
init --remove-agentsrun from a subfolder remove whatinitwrote at the project root, or say in its help which folder it acts on; - state in the
inithelp and the working-with-AI guide that the default removes a block from.claude/CLAUDE.mdwhen rootCLAUDE.mdexists, and that the project-root search stops at a repository root; - rebase onto
main, where #7262 and #6216 now conflict with this branch.
[Automated review]
| // The docs belong at the project root, not in the subfolder init ran in; | ||
| // with no project above, they go where init ran, as before. Explicit | ||
| // --agent-docs-path entries stay relative to where init ran. | ||
| const root = resolveAgentDocsRoot(cwd) ?? cwd; |
There was a problem hiding this comment.
Init now writes at this resolved root, but init --remove-agents still calls removeAgentDocs(cwd) in api/init/remove/remove.mjs. After init in src/app writes ../../AGENTS.md and ../../GEMINI.md, init --remove-agents in src/app prints "Nothing to remove: no Astryx agent-docs block was found." and leaves both files, where main removed what init wrote. Resolving the same root in remove, or naming the folder it acts on in the option text and message, would keep the pair in step.
| 'getting-started steps); the theme feature also writes an annotated theme template.', | ||
| 'agents, and CI). By default it writes the agent-docs block, including guidance ' + | ||
| 'from configured integrations, to AGENTS.md and to the Claude Code file the project ' + | ||
| 'has (CLAUDE.md, else .claude/CLAUDE.md), and a one-line import of AGENTS.md to ' + |
There was a problem hiding this comment.
The default also removes a managed block from .claude/CLAUDE.md whenever root CLAUDE.md exists, but this description and the working-with-AI guide only say where the copy goes; the guide states the removal for --agent claude and all alone. The project-root sentence below also leaves out that the search stops at a repository root. Both are automatic behavior that help and the manifest should state.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the earlier help and Changeset gap for a root CLAUDE.md is fixed, but that rewrite dropped one case from astryx init --help. When root CLAUDE.md is git-ignored and .claude links outside the project with a CLAUDE.md that only imports AGENTS.md, init skips it with a note and exits 0 (as the path-safety tests pin), yet the exit-0 entry in init.doc.mjs no longer lists that among its five soft cases. Please restore "or a block-less import of an existing AGENTS.md" in the ignored-root clause, or widen the Claude Code file case to cover .claude/CLAUDE.md beside a root one, ideally with a help assertion so it stays listed.
[Automated review]
| { | ||
| code: 0, | ||
| when: 'success, including agent docs that could not be written for a reason other than a path escape (reported as docsError)', | ||
| when: "success, including agent docs left unwritten in five soft cases, each reported as docsError with one note: running in the home folder, or in a settings folder in it outside a project; a GEMINI.md that resolves outside the project; when init runs below the project root, a project-root agent file that resolves outside the project; the project's Claude Code file (root CLAUDE.md, or .claude/CLAUDE.md when there is no root one) when it resolves outside the project and is a block-less import of an existing AGENTS.md, which 0.7.1 left alone; and a .claude/CLAUDE.md that resolves outside the project and that 0.7.1 did not write: beside a CLAUDE.md the project ignores, the one --agent claude adds; with --agent claude beside a CLAUDE.md, one whose block it would remove", |
There was a problem hiding this comment.
This list now misses one skip the head makes. While root CLAUDE.md is git-ignored, a committed .claude/CLAUDE.md gets a copy too; when .claude links outside the project and its CLAUDE.md only imports an existing AGENTS.md, init skips it with a docsError note and exits 0 (pinned in agent-docs.path-safety.test.mjs, "skips a linked-outside block-less import of an existing AGENTS.md"). The fourth case covers .claude/CLAUDE.md only when there is no root CLAUDE.md, and the fifth now names only the copy --agent claude adds, so this shape is in neither; the previous wording ("the one --agent claude adds or a block-less import of an existing AGENTS.md") covered it. Restoring that clause, or widening the fourth case to any Claude Code file that holds a copy, fixes it.
…elp; pin every soft exit-0 case Round 11 dropped "or a block-less import of an existing AGENTS.md" from the ignored-root clause of init's exit-0 help: with root CLAUDE.md ignored and .claude linked outside, a .claude/CLAUDE.md that only imports an existing AGENTS.md is skipped with a note and exit 0. Restored. A new test checks that the help names every soft exit-0 case the path-safety tests pin.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the earlier gap in astryx init --help is fixed and now pinned by a test. One exit-code regression remains: astryx init --remove-agents run below the project root now exits 1 with ERR_PATH_TRAVERSAL and removes nothing when a project-root agent doc that holds a block links outside the project (for example a monorepo package whose CLAUDE.md links to the repository's), where 0.7.x exits 0, although the Changeset says exit codes are unchanged. Please skip that root file with a note when run below the root, as init already does when installing, and pin the case in remove.test.mjs.
[Automated review]
| export function removeProjectAgentDocs(cwd) { | ||
| const root = agentDocsTargetDir(cwd); | ||
| const dirs = realDir(root) === realDir(cwd) ? [cwd] : [root, cwd]; | ||
| for (const dir of dirs) assertRemovableWithin(dir); |
There was a problem hiding this comment.
Run below the project root, this refuses the whole removal when a project-root agent doc that holds a block links outside the project (for example apps/web/CLAUDE.md linked to ../../CLAUDE.md): the head exits 1 with ERR_PATH_TRAVERSAL and leaves the working folder's block, where 0.7.x removed it and exited 0. Install skips the same file below the root (refuseEscapes: sameFolder(targetDir, cwd) in run.mjs); skipping it here with a note, and keeping exit 0, would keep 0.7.x's exit code for this input.
| - The managed block is Astryx-owned (`architecture:cli-surface` INV31): init and `astryx upgrade` write, refresh, and remove only the block, whatever ignore rules or generated markers say, as 0.7.1 did, and never change the text around it. Every write stays inside the project (INV10): run in the folder 0.7.1 wrote, an agent file 0.7.1 wrote there whose path leaves the project still refuses the run with exit 1. The project's Claude Code file (root `CLAUDE.md`, or `.claude/CLAUDE.md` when there is no root one) that resolves outside the project and is a block-less import of an existing `AGENTS.md`, which 0.7.1 left alone, is skipped and reported in `docsError` with one note, and init exits 0. Run from a folder below the project root, where 0.7.1 wrote in that folder instead, a project-root file whose path leaves the project is skipped and reported in `docsError` with one note, the rest is written, and init exits 0. | ||
| - While root `CLAUDE.md` is one the project ignores, by its own ignore files or by those from the repository root down (a monorepo's root `.gitignore`), a `.claude/CLAUDE.md` the project commits gets the copy too, on the first run as on later ones, and `--agent claude` and `--agent all` write it there, so a fresh clone still gives Claude Code a copy. Such a copy that resolves outside the project refuses the run with exit 1 where 0.7.1 wrote it too; one 0.7.1 did not write (the one `--agent claude` adds, or a block-less import of an existing `AGENTS.md`) is skipped and reported in `docsError` with one note, and init exits 0. So is a `.claude/CLAUDE.md` whose block `--agent claude` would remove beside a `CLAUDE.md`, since 0.7.1's `claude` preset wrote only `CLAUDE.md` there. Beside a committed root `CLAUDE.md`, with `.claude` linked outside the project, three cases that 0.7.1 refused now exit 0 with nothing written: the default with a `.claude/CLAUDE.md` of plain text, and `--agent all` with one of plain text or a block-less import of `AGENTS.md`. 0.7.1 wrote that `.claude/CLAUDE.md`; now root `CLAUDE.md` holds the copy and the linked file gets none, so no write leaves the project and none needs refusing. In a project that keeps its own layout, a `GEMINI.md` that imports no agent file now gets a copy, as the other agent files do. | ||
| - The copy in `.claude/CLAUDE.md` is removed only once root `CLAUDE.md` holds the same block, and only the managed block between its markers: the rest of the file stays, and the file is deleted only when nothing but whitespace is left. `astryx init --remove-agents` deletes a file it created only when nothing but whitespace or init's own heading is left; 0.7.0 also deleted a file whose remaining text had a heading and any line with the word "guidance". | ||
| - `astryx init --remove-agents` removes the block at the project root, where `init` writes it, and in the folder it runs in. Run from a subfolder, it removes what `init` wrote at the root, and a block an earlier version left in that subfolder. Exit codes and the JSON shape are unchanged. |
There was a problem hiding this comment.
Not true for one input yet: run in a subfolder while a project-root agent doc that holds a block links outside the project, --remove-agents now exits 1 where 0.7.x exits 0. Either keep exit 0 there (see the comment on removeProjectAgentDocs) or name it here as a newly refused input with its migration.
…e linked outside the project, with a note Below the project root, a project-root agent file holding a block that resolves outside the project (apps/web/CLAUDE.md -> ../../CLAUDE.md) refused the whole removal with ERR_PATH_TRAVERSAL, leaving the working folder's block; 0.7.x touched only that folder and exited 0. It is now left as it is with a Note and the rest is removed, exit 0, as install does below the root. At the root, and for a file in the working folder, an escape still refuses the run. The --remove-agents help and the changeset say so. Tests: the workspace-member case below the root; the same link at the root still refuses.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the previous astryx init --remove-agents exit-code regression is fixed and pinned by a test. Two small fixes remain:
- In a project rooted directly in a home dot-folder (for example
~/.dotfiles),astryx upgrade --applynow leaves the agent-docs block stale, reportsagentDocs.action: "error"and advises runninginit, which refuses there too; please name this refusal in the Changeset (the input, how it fails and the migration, as INV10a asks), have upgrade print the real reason, and pin it inupgrade.test.mjs. packages/cli/api/init/init.doc.mjsstill listsERR_PATH_TRAVERSALfor a project-root file thatremoveAgentsnow leaves as it is, with a note, when run below the root; please update that entry.
[Automated review]
| - Claude Code skips `AGENTS.md` in a folder that has a `CLAUDE.md` or `.claude/CLAUDE.md`, so the Claude Code file the project already has keeps a full copy: root `CLAUDE.md`, else `.claude/CLAUDE.md`. It keeps the copy even when it imports `AGENTS.md`, because Claude Code does not follow that import in a session started in a subfolder; started at the root, Claude Code then reads two. When both exist, the copy goes in root `CLAUDE.md`, which projects commit even when they ignore `.claude/`, and a block in `.claude/CLAUDE.md` is removed. Init creates no Claude file. `astryx upgrade` refreshes every copy. | ||
| - Gemini CLI reads only `GEMINI.md`: init adds a one-line import, `@./AGENTS.md`, creating `GEMINI.md` when it is missing. It adds none when `GEMINI.md` already imports `AGENTS.md`, inline or on its own line. It adds the import even when the project's `.gemini/settings.json` has Gemini read `AGENTS.md` through `context.fileName`: Gemini loads those settings only when it starts at the project root, so a session started in a subfolder would otherwise get no copy. Started at the root, Gemini then reads two. | ||
| - The project root is the nearest folder at or above where init runs whose `package.json` declares an `@astryxdesign` package, else the nearest with any `package.json`. The search stops at a repository root and never counts the home folder. With no `package.json` found, init writes where it runs, as before. `docsWritten` still lists each file relative to where init ran, for example `../../AGENTS.md`. | ||
| - In the home folder, or in a settings folder in it such as `~/.gemini` or `~/.claude` outside a project, init writes no agent docs, reports `docsError` as `install-failed` with the reason, and still exits 0. This is a compatible fix under `architecture:cli-surface` INV31 (where init writes, and that no mode writes agent docs into the home folder or a settings folder in it) and INV10a (a refusal of a write outside its confined root, made before anything is written). The refused inputs: the home folder itself, and the top of a folder of the home folder whose name starts with a dot (every such folder is a settings folder), even when it holds a `package.json`; a folder below it with its own `package.json` is a project. How it fails: no agent docs are written, `docsError` is `install-failed` with the reason, and the exit status stays 0, as before. Migration: run `astryx init` from the project's own folder, or add the block to the file by hand. A project inside a settings folder, such as an agent worktree in `~/.codex/worktrees/` or `~/.cursor/worktrees/`, is set up normally, and `astryx upgrade` refreshes it. Agents read the files in those folders in every project. Run `astryx init --remove-agents` in the home folder to remove a block an earlier version wrote into `~/.claude/CLAUDE.md`. |
There was a problem hiding this comment.
This names only init's refusal, but the same guard (assertAgentDocsTarget at the top of installAgentDocs) now also stops astryx upgrade --apply from refreshing a block in the home folder or a home dot-folder outside a project. In a project rooted at ~/.dotfiles, 0.7.x refreshed AGENTS.md; this head leaves it stale with agentDocs.action: "error", and line 10 still says "astryx upgrade refreshes every copy". INV10a asks the Changeset to name each newly refused input, how it fails, and the migration.
| const written = installAgentDocs(cwd, { | ||
| onlyReplace: true, | ||
| renderedBlock, | ||
| // A GEMINI.md that resolves outside the project is left as it is. |
There was a problem hiding this comment.
installAgentDocs can now throw AgentDocsHomeError here, which the catch below turns into "Could not refresh agent docs. Run … init --features agents to update them manually." That init writes nothing in the same folder, so the advice loops. Printing the AgentDocsHomeError message (and pinning the case in upgrade.test.mjs) would tell the person why the block stays as it is.
| { | ||
| code: 'ERR_PATH_TRAVERSAL', | ||
| when: 'the template output path resolves outside cwd (for example through a symlinked src directory), or, with removeAgents, a managed agent-docs file resolves outside cwd through a symlink', | ||
| when: 'the template output path resolves outside cwd (for example through a symlinked src directory), or, with removeAgents, a managed agent-docs file at the project root or in cwd resolves outside that folder through a symlink', |
There was a problem hiding this comment.
Since this revision, run below the project root, a project-root agent file that resolves outside the project is left as it is with a note and init({removeAgents: true}) resolves with removed: true; only a file in cwd, or at the root when run there, rejects. Suggest: "with removeAgents, a managed agent-docs file in cwd, or at the project root when run there, resolves outside that folder through a symlink (run below the root, a project-root file is left as it is with a note)".
…instead of pointing at init; init's ERR_PATH_TRAVERSAL entry matches removal below the root - In a project at the top of a home settings folder (~/.dotfiles with a package.json), upgrade --apply cannot refresh the block (INV31), and its warning said to run init --features agents, which refuses the same folder. It now names the folder and why, and says to move the project or update the block by hand. agentDocs.action stays error. The changeset names the refusal in INV10a form (input, failure, migration), and its "upgrade refreshes every copy" names the exception. - api/init/init.doc.mjs: ERR_PATH_TRAVERSAL with removeAgents is for a file in cwd, or at the project root when run there; below the root such a file is left with a note. Test: upgrade --apply in ~/.dotfiles leaves the block and prints the reason, without init.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the previous round's upgrade message and API-doc fixes are in. Two small fixes remain:
astryx init --agent-docs-path notes/AI.mdrun from the home folder now writes nothing, although the file lands in an ordinary subfolder and the Changeset says explicit paths work as before; please apply the home-folder check to each file's folder rather than to the working folder, with a test.astryx upgradewithout--apply, in a project rooted at the home folder or a home dot-folder, still reportswould-refreshand says to re-run with--apply, which then refuses; please have the dry run report the same refusal, with a test.
[Automated review]
| // --agent-docs-path entries stay relative to where init ran. | ||
| const root = agentDocsTargetDir(cwd); | ||
| const targetDir = paths ? cwd : root; | ||
| assertAgentDocsTarget(targetDir); |
There was a problem hiding this comment.
With --agent-docs-path, targetDir is the working folder, so this refuses every explicit path given from the home folder: cd ~ && astryx init --agent-docs-path notes/AI.md now writes nothing (the base wrote ~/notes/AI.md), while the same file is written when init runs in ~/notes. INV31 refuses only writes into the home folder or a settings folder in it, and the Changeset says --agent-docs-path writes where init runs, as before. Checking each resolved file's folder instead (refusing AI.md or .claude/CLAUDE.md given from ~, keeping notes/AI.md), with a test beside "refuses an explicit path", would fix it.
| logger.warn( | ||
| `Could not refresh agent docs. Run \`${formatCliCommand('astryx init --features agents')}\` to update them manually.`, | ||
| ); | ||
| if (err instanceof AgentDocsHomeError) { |
There was a problem hiding this comment.
This now explains the refusal on --apply, but the dry run never reaches it: prepareAgentDocsRefresh (line 344) still reports would-refresh and prints "Re-run with --apply to refresh (AGENTS.md)" in the same project. Checking assertAgentDocsTarget(cwd) there and reporting error with this reason would keep the preview and the apply step in agreement.
…pgrade's dry run reports the home-folder refusal - init --agent-docs-path from the home folder refused every path, because the home check ran on the working folder: cd ~ && init --agent-docs-path notes/AI.md wrote nothing, where 0.7.x wrote ~/notes/AI.md. Each path's own folder is checked now, before anything is written: notes/AI.md is written; AI.md or .claude/CLAUDE.md from the home folder is refused with the note, as before. - upgrade without --apply, in a project at the home folder or the top of a settings folder, reported would-refresh and "Re-run with --apply", which then refused. It now reports agentDocs.action error with the same reason --apply prints. - The --agent-docs-path help and the changeset say so. Tests: an explicit path into a plain folder of the home folder is written, directly and through init; one in the home folder, at the top of a settings folder, or among several paths is refused with nothing written; the dry run in ~/.dotfiles reports the refusal.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the previous round's explicit-path and dry-run fixes are in. Three fixes remain:
- A
.claude/CLAUDE.mdthat git tracks loses its copy, or never gets one, when an unanchoredCLAUDE.mdline in.gitignorealso matches it, so a fresh clone gives Claude Code no copy; please count tracked files as committed inclaudeDirKeepsCopy, with a test. - In the home folder (with a stray
package.json) or a project at the top of a home dot-folder such as~/.dotfiles, the setup nudge, upgrade's "No Astryx agent-docs block found" line anddoctor's agent-docs fix still say to runinit, which writes nothing there; please skip the nudge there and give the refusal and its migration instead, with tests. - The new
--agent-docs-pathhelp says only a path directly in the home folder or at the top of a settings folder is refused, but any folder in a settings folder outside a project is (for examplehooks/AI.mdrun in~/.claude); please reword it to match.
[Automated review]
| */ | ||
| function claudeDirKeepsCopy(targetDir) { | ||
| if (!rootClaudeIgnored(targetDir)) return false; | ||
| return !ignoredHere(targetDir, CLAUDE_DIR_MD, false); |
There was a problem hiding this comment.
This treats any .claude/CLAUDE.md an ignore pattern matches as uncommitted, but Git and Mercurial apply ignore rules only to untracked files. With CLAUDE.md in .gitignore and a tracked .claude/CLAUDE.md, init strips its block (or adds none on a first run), so a fresh clone, which lacks the ignored root CLAUDE.md, gives Claude Code no copy (INV31: "every agent CLI reads at least one copy … from files the project commits"). Counting a tracked file as committed, or keeping the copy whenever tracking can't be read, would fix it.
| // repository the walk above already reaches it (the root never lies | ||
| // above the repository root), so this changes nothing there; outside a | ||
| // repository the walk checks only cwd, and this finds the root. | ||
| if (isAstryxInitialized(agentDocsTargetDir(cwd))) return; |
There was a problem hiding this comment.
In the home folder (with a stray package.json) or at the top of a home dot-folder such as ~/.dotfiles, this nudge still says to run init, which now writes nothing there, so it prints again on every command. Skipping it when assertAgentDocsTarget(agentDocsTargetDir(cwd)) throws would stop the loop; upgrade's missing-docs line (api/upgrade/_adapter.mjs:330-335) and doctor's agent-docs fix (api/doctor/doctor.mjs:623) need the same check.
| description: | ||
| 'Explicit file path(s) for agent docs, inside the project; takes precedence over --agent. ' + | ||
| 'If any path is outside the project, no agent docs are written and the command exits 1. ' + | ||
| 'A path directly in the home folder, or at the top of a settings folder in it such as ~/.claude, is refused with a note (exit 0), and nothing is written. ' + |
There was a problem hiding this comment.
The code refuses every folder in a home settings folder that no package.json makes a project, not only its top: --agent-docs-path hooks/AI.md run in ~/.claude, and .claude/agents/AI.md run in the home folder, are refused too. Suggest: "A path in the home folder itself, or in a settings folder in it outside a project (such as ~/.claude or ~/.claude/hooks), is refused with a note (exit 0), and nothing is written."
…it' advice where init writes nothing - git and Mercurial ignore only untracked files, so a .claude/CLAUDE.md the repository tracks is committed even when an ignore rule matches it (an unanchored CLAUDE.md in .gitignore). The ignored-root and kept-copy checks ask the repository (git ls-files --error-unmatch, sl/hg files) whether an ignored agent file is tracked; when that cannot be read, the copy is kept. doc-loads lists the new spawn. - In the home folder or at the top of a settings folder in it, where init writes no agent docs: the setup reminder after each command stays quiet; upgrade with no block reports agentDocs.action error with the reason and what to do (move the project, or add the block by hand), not init; doctor's agent-docs fix says the same. - The --agent-docs-path help uses the reviewer's wording; the changeset names the tracked-file rule and the three surfaces. Tests: a tracked .claude/CLAUDE.md under an unanchored rule keeps its copy (default and --agent claude), an untracked one is stripped, an unreadable repository keeps it; the reminder in ~ and ~/.dotfiles; upgrade with no block in ~/.dotfiles; doctor's fix there.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the previous round's three fixes are in. One fix remains: when git ignores an untracked root CLAUDE.md only through .git/info/exclude or a global excludes file, init still strips the block from a committed .claude/CLAUDE.md, so a fresh clone gives Claude Code no copy where 0.7.1 kept one. Since the code already asks git whether the file is tracked, please also ask it whether the file is ignored (git check-ignore), widen the INV31 ignored-root sentence to match for maintainer approval, and pin the case in agent-docs.path-safety.test.mjs.
[Automated review]
| * @returns {boolean} | ||
| */ | ||
| function uncommittedHere(targetDir, rel, unreadable) { | ||
| if (!ignoredHere(targetDir, rel, unreadable)) return false; |
There was a problem hiding this comment.
This asks only the in-tree ignore reader, which never reads .git/info/exclude or core.excludesFile. With root CLAUDE.md untracked and ignored through either (git check-ignore CLAUDE.md exits 0), this returns false before trackedHere runs, so root CLAUDE.md counts as committed and the default strips the block from a tracked .claude/CLAUDE.md (or never adds one); a fresh clone then gives Claude Code no copy, where 0.7.1 kept it. Since trackedHere already runs git, asking git check-ignore -q -- <rel> for an untracked file here (with the sl/hg equivalents, or keeping the copy when they cannot answer) would close it, with a .git/info/exclude case in agent-docs.path-safety.test.mjs.
Conflicts, both sides kept: api/doctor/doctor.mjs, api/init/init.doc.mjs and init.type.mjs, assets/docs/working-with-ai.doc.mjs, clients/cli/commands/init.doc.mjs and setup-nudge.test.mjs, clients/cli/index.mjs, foundation/doc-compiler/doc-loads.test.mjs.
Global mode (main) treats a folder whose package.json declares no Astryx package as outside a project: init prints no getting-started steps there and the setup reminder stays quiet. Two #7497 fixtures moved to os.tmpdir() or declare nothing, so they now declare @astryxdesign/core; --json output now carries meta.answeredBy, which the remove-agents JSON check expects; and main's outside-project init test now sees the GEMINI.md import #7497 always writes.
…l excludes included The ignored-root check read only the in-tree ignore files, never .git/info/exclude or core.excludesFile, so with root CLAUDE.md untracked and ignored through either, the default stripped (or never added) the block in a tracked .claude/CLAUDE.md. Inside a repository, init now asks the repository whether an agent file is untracked and ignored: `git check-ignore -q` (which never reports a tracked file, and reads every ignore source), or `sl`/`hg status -i -n`. When it cannot answer, the copy is kept. Outside a repository the folder's ignore files answer, as before. This replaces the separate tracked-file query and the ignoreFrom reader, which the repository's answer covers, so file-protection.mjs is back to main's. The INV31 ignored-root sentence and the changeset say so (the record line stays with the others pending approval). Tests: an untracked root CLAUDE.md ignored through .git/info/exclude, and through core.excludesFile, beside a tracked .claude/CLAUDE.md keeps its copy; the monorepo case runs in a real git repository.
There was a problem hiding this comment.
Changes requested: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the previous round's .git/info/exclude fix is in, but CI's test-node now fails one of this pull request's own tests. "keeps the copy when the repository .hgignore cannot be parsed (fails closed)" in agent-docs.path-safety.test.mjs still expects the in-tree .hgignore reader this revision removes: Mercurial opens the bare .hg folder the test creates and answers that root CLAUDE.md is not ignored, so init strips the copy. Please build real Mercurial repositories in the three Mercurial cases (skipped when hg is missing or is Sapling, as the git cases skip without git) and make the fail-closed case a repository hg cannot open, such as a .hg/requires naming an unknown requirement.
[Automated review]
| }); | ||
| } | ||
|
|
||
| it('keeps the copy when the repository .hgignore cannot be parsed (fails closed)', () => { |
There was a problem hiding this comment.
This case fails in CI's test-node on this head. The ignored-root check now asks hg status -i -n, and Mercurial opens the bare .hg folder created here, skips the invalid syntax: bogus line and answers that CLAUDE.md is not ignored, so init strips the block; the case passes only where hg cannot open the folder (Sapling's hg, or none installed). Suggest building real repositories with hg init for the three Mercurial cases, skipped when hg is missing or is Sapling as the git cases skip without git, and making this one a repository hg cannot open, such as a .hg/requires naming an unknown requirement.
…hg is installed CI went red on GitHub's runners: their real Mercurial reads an .hgignore with an unknown syntax line by skipping it, answers that root CLAUDE.md is not ignored, and the copy moves, as the repository says. The test assumed the box's hg would fail on that file. The code already treats a tool that is missing, cannot start, times out, or exits with an undocumented code as "cannot answer" and keeps the copy; its comment now says so. The test now sets the search path itself: no hg, an hg that fails (255), and one with an undocumented exit (2) keep the copy; an hg that answers with nothing ignored moves it. The glob and regexp cases keep the same outcome whether hg is installed or not.
There was a problem hiding this comment.
Recommending approval: the agent-docs layout, the project-root search and the home-folder refusal match architecture:cli-surface INV31, and the Mercurial fail-closed test that failed CI on the previous revision now stubs hg and passes in test-node. Two things remain before merge: an engineering owner approves the INV31 and spec:AST-040 FR8 amendments on this head, and merging main clears the pr-a11y failure, which comes from a Token test that exists only on main.
[Automated review]
|
/approve-spec 4a022fc |
User impact
astryx initwrites the Astryx block that teaches coding agents how to use the CLI. With this change:initruns in a subfolder.~/.claudeor~/.gemini. A project inside such a folder, such as an agent worktree, still works.doctorfails when theGEMINI.mdimport points at anAGENTS.mdthat lost its block.On
maintoday:GEMINI.md, whichinitnever writes.AGENTS.md,initwrites the block only into the Claude file. Codex CLI misses it, and so does Copilot CLI when that file is.claude/CLAUDE.md.initwrites into that subfolder.initwrites the block into the user's own~/.claude/CLAUDE.md, or into a new~/.codex/AGENTS.md. Every project on the machine then gets one Astryx version's rules.Problem and solution fit
initignores that. It writes a full block into whatever agent files exist, or createsAGENTS.md, in the folder it runs in.CLAUDE.mdand.claude/CLAUDE.md, and readsAGENTS.mdonly when neither exists.AGENTS.md.GEMINI.md, unless its settings name other files.AGENTS.md,CLAUDE.mdandGEMINI.mdtogether.The fix follows one rule: no agent gets zero copies; an extra copy is the accepted cost.
Expected behavior and authority
initdocuments that it installs the agent docs for "your project". The consumer guide says the generated file gives the agent "everything your AI needs". An agent that never gets the block falls outside that promise.@pathimport wrappers alone, and removes a block an older run expanded into one.architecture:cli-surfaceINV10 (every write is confined) and INV13 (agent docs have one rendered source of truth) still hold. Every write stays inside the project root, and every copy of the block is the same bytes, rendered once per run.Smallest restoration
The layout
This applies when no
--agentor--agent-docs-pathis given.AGENTS.mdholds the block, and is created when missing. Codex CLI reads nothing else. Claude Code reads it in a project without a Claude file.CLAUDE.md, or.claude/CLAUDE.mdwhen there is no root one.AGENTS.mdbeside a Claude file, so the copy is needed.AGENTS.mditself. Started in a subfolder, Claude Code reads only the copy; started at the root, it reads two.CLAUDE.md, which projects commit even when they ignore.claude/in git. A block in.claude/CLAUDE.mdis removed.initcreates no Claude file.AGENTS.mdunder another name (a symlink) gets no copy.GEMINI.mdgets a one-line managed import,@./AGENTS.md, and is created when missing.GEMINI.mdalready importsAGENTS.md, on its own line or inline.initreads imports the way Gemini CLI does: an@pathat the start of the text or after whitespace, and not inside backticks..gemini/settings.jsonhas Gemini readAGENTS.mdthroughcontext.fileName. Gemini loads project settings only when it starts at the project root, so without the import, a session started in a subfolder reads no copy. A session started at the root then reads two..cursorrules,.hermes.mdandHERMES.mdfiles keep a full block, as before.AGENTS.md, or two agent files that are one file under two names.Where the docs go
package.jsondeclares an@astryxdesignpackage.package.jsondeclares one, the root is the nearest folder with anypackage.json. If there is none at all, it is the working folder, as before.docsWrittenstill lists each file relative to the working folder, for example../../AGENTS.md.initwrites no agent docs. It reportsdocsError: {kind: 'install-failed', message}and exits 0.--remove-agentsstill works there, to clean up a block an earlier version wrote.package.json. Examples are the worktrees Codex keeps in~/.codex/worktrees/and Cursor in~/.cursor/worktrees/.initandupgradework there.package.jsonthere (for example one for hook scripts in~/.claude). Agents read~/.claude/CLAUDE.md,~/.codex/AGENTS.mdand~/.gemini/GEMINI.mdin every project.Links outside the project
GEMINI.md, is skipped when it resolves outside the project. An example is a link to a shared file in a monorepo.initreports the skip indocsError, writes the rest, and exits 0.path-safetyand exit 1, as before.Presets and checks
--agent claudeand--agent allnever leave a block in bothCLAUDE.mdand.claude/CLAUDE.md: whenCLAUDE.mdgets the block, a block in.claude/CLAUDE.mdis removed.--agent allleaves theGEMINI.mdimport as it is. The--agenthelp and the working-with-AI guide say both.--agent-docs-pathis unchanged.doctorlooks for the agent docs whereinitwrites them. It fails when theGEMINI.mdimport points at anAGENTS.mdwith no block. The setup check in the CLI and in Core no longer counts that import as setup, and it looks atGEMINI.md.initthat commands print looks at the project root too, so it stops onceinithas run in a nested package such asfunctions/.agentDocsTargetDirrule init uses), which quiets a nested package such asfunctions/whose project root already holds init's docs; inside a repository this adds nothing, and tests pin that.init --remove-agentsremoves the block whereinitwrites it, at the project root, and in the folder it runs in, so a block an earlier version left in that folder goes too.upgraderefreshes each block where it is, the Claude file's copy included. A project moves to the new layout the next time it runsinit.inithelp and the working-with-AI guide state each rule above, including the.claude/CLAUDE.mdremoval and where the project-root search stops.Evidence
Copies of the block each agent reads
Four agent CLIs ran headless with fresh homes, against a local stub server that records the request each one sends: Claude Code 2.1.296, Codex CLI 0.162.1, Gemini CLI 0.63.0 and Copilot CLI 1.0.97.
initran at the root, and each agent then started at the root or insrc/app.initfrommain; "this branch" is this change.src/appsrc/appCLAUDE.mdAGENTS.mdandCLAUDE.md.claude/CLAUDE.mdCLAUDE.mdlinked toAGENTS.mdGEMINI.mdAGENTS.md*CLAUDE.mdthat importsAGENTS.md**AGENTS.md, and aCLAUDE.mdthat imports it**.claude/CLAUDE.mdthat importsAGENTS.md*** Gemini CLI 0.64.0 for this row, with
context.fileNameset to"AGENTS.md"or["AGENTS.md", "GEMINI.md"].** Claude Code 2.1.300, Codex CLI 0.162.1, Gemini CLI 0.64.0 and Copilot CLI 1.0.97 for these rows.
The counts above 1 are the accepted extra copies:
AGENTS.mdand rootCLAUDE.mdtogether, as onmain. When thatCLAUDE.mdimportsAGENTS.md, Copilot CLI follows the import too and reads three.AGENTS.mdagain through that file's import. Started in a subfolder, it does not follow the import, so the copy is the one it reads. Without the copy it read none there: 0 insrc/app.AGENTS.mdthrough its settings, and again through the import.All 32 mixes of
AGENTS.md,CLAUDE.md,.claude/CLAUDE.md,GEMINI.mdand.cursorrules: every agent read the block in all 64 cells (each mix, from the root and fromsrc/app).CLAUDE.mdgave 1/1/1/1, and the 16 with one gave 1/1/1/2.initkept the project's own text in every file, exited 0 and reported no error.Agents follow the block
Each agent did a small task in a project whose block carried three unusual instructions:
The test setup:
AGENTS.mdonly;CLAUDE.md;.claude/ignored in git, in a fresh clone;AGENTS.md.src/app. A cell passed when the agent followed all three instructions in its reply and its files.Result: 39 of 40 cells passed. The one miss was Gemini CLI started in
src/appin the project whose Gemini settings readAGENTS.md:initskippedGEMINI.mdthere, and Gemini doesn't load project settings from a subfolder. This change writes the import in that case too, which gives Gemini CLI one copy insrc/appand two at the root (the last row of the table above).Edge cases
.claude/ignored in git, project hasCLAUDE.md; agents run in a fresh cloneCLAUDE.mdthat importsAGENTS.md, plus.claude/CLAUDE.md**src/appsrc/app1/1/1/3CLAUDE.mdwith an inlineSee @AGENTS.md**src/appsrc/app1/1/1/3AGENTS.mdandGEMINI.mdGEMINI.mdalready saysFollow @./AGENTS.md always.GEMINI.mduntouchedGEMINI.mdlinks to a file outside the projectdocsError.claudelinks to a folder outside the project, project hasCLAUDE.md--agent allafter the default, project hasAGENTS.mdandCLAUDE.md--agent claudeafter the default, same projectinitrun infunctions/src, wherefunctions/has its ownpackage.jsonwithout Astryxfunctions/src/AGENTS.md; agents there read 1/1/0/1functions/srcread 1/1/1/1initrun in~/.gemini~/.gemini/AGENTS.md~/.codex/worktrees/<id>/web), init at its rootsrc/appsrc/app~/.cursor/worktrees/web/<id>)src/appsrc/appAGENTS.mddeleted after init, thendoctorinit, theninit --remove-agents, both run insrc/appinitwrote insrc/appinitwrote at the project root, and a block an earlier version left insrc/appUnchanged paths
--agent-docs-pathwrites where it did.package.jsonabove it still gets the docs whereinitruns.Regression tests
They fail on
main; see Testing.Compatibility
I classified this under the release compatibility spec against 0.7.0 as a compatible fix:
[fix], with patch bumps for@astryxdesign/cliand@astryxdesign/core.mainstill reads it, and the agents that miss it onmainread it. A few setups still leave an agent with none, as onmain, such as aGEMINI.mdthat links outside the project;initreports that skip.init.runJSON shape is unchanged.docsErrorkeeps its documented kinds;install-failedalready allows amessage.docsWrittenstill lists files relative to the working folder..claude/CLAUDE.mdthat links outside the project and holds no block, beside a rootCLAUDE.md, is no longer written.initexits 0 there, where 0.7.0 exited 1.GEMINI.mdthat links outside the project exits 0, as on 0.7.0, which ignored the file. This branch reports the skip indocsError, where 0.7.0 left it null.initwrites nothing and says why, with exit 0 and the same JSON shape. A block written there reaches every project on the machine, which is the defect this fixes. A project inside a settings folder is written as on 0.7.0, now at its root.--agent claudewrites the full block into the Claude file, and--agent-docs-pathwrites where it did.init --remove-agentskeeps its exit codes and theinit.removeJSON shape. Run in a subfolder, it also removes the block at the project root, whereinitnow writes it; on 0.7.0 it acted on that folder alone. Each folder is checked before anything is written, and a file that links outside its folder refuses the run, as before.CLAUDE.mdexists, as onmain, and three when thatCLAUDE.mdimportsAGENTS.md.AGENTS.md.AGENTS.md.[fix]and not a new default:initdocuments that it installs the agent docs for the project, and onmainagents miss them in common setups. Placing the block where each agent reads it restores that promise without offering anything new: no flag, option, JSON field or exit code changes, and no caller opts in or migrates. The rules are recorded in the CLI surface architecture by spec(cli-surface): agent docs reach every agent from the project's own files #7539.Follow-ups (not in this pull request)
package.jsonat or above the working folder,initwrites no agent docs and says why. Today it writes in the working folder, which this pull request keeps, because the refusal narrows an input 0.7.0 accepts.initandupgradeneither refresh nor remove a block an earlier version left in a subfolder (for examplesrc/app/AGENTS.md, from runninginitthere), so agents started in that subfolder read it beside the root block.init --remove-agentsrun in that subfolder removes it.Scope
Why one pull request
The home-folder and settings-folder refusal, the project-root resolution, and the per-agent layout are one rule: where
initwrites agent docs (architecture:cli-surfaceINV31). The refusal is the edge of that rule (no mode writes outside a project), the project root is where it writes inside one, and the layout is what it writes there. Any one of them alone leaves main writing agent docs by a rule INV31 does not state: resolving the project root without the refusal would walk a run in~/.claudeup to the home folder; the layout without the root would write a fullAGENTS.mdcopy into every subfolderinitruns in; the refusal alone would refuse runs the old rule wrote to. The tests exercise them together. Of about 2,585 changed lines inpackages/and the changeset, 1,373 are tests (agent-docs layout and path safety, init behavior, remove, doctor, setup nudge, upgrade); the code and docs are 1,212.Answers to the maintainer questions
architecture:cli-surfaceINV31 states whereinitwrites and that no mode writes agent docs into the home folder or a settings folder in it, outside a project. INV10a classifies refusing a write outside its confined root, before anything is written, as a compatible[fix], patch-eligible underspec:AST-017(AST-017 FR54 points to cli-surface for this class). The changeset names each refused input (the home folder itself, and the top of a dot-folder directly in it, even with apackage.json), how it fails (no agent docs,docsErrorinstall-failed, exit 0 as before), and the migration (runinitfrom the project's own folder, or add the block by hand).GEMINI.mdand.claude/CLAUDE.mdwrites follow the protections upgrade uses? No: the managed block is Astryx-owned, sospec:AST-040's protections do not apply to it (see the maintainer decision below);architecture:cli-surfaceINV10 still confines every write to the project.Maintainer decision: release tier
This ships as a
[fix]on the patch plan.docsErrorkeeps its existingkindvalues, and no field is removed or renamed.architecture:cli-surfaceINV31 states: a block inAGENTS.mdat the project root, a full copy in the project's Claude Code file, and a one-line import inGEMINI.md. Init writes to that layout so that every agent reads the block.~/.claude), even when that folder has apackage.json.architecture:cli-surfaceINV10a classifies refusing a write outside the confined root, before anything is written, as a compatible fix. The changeset names the refused inputs, says how the refusal fails (no agent docs,docsErrorinstall-failed, exit 0 as before), and gives the migration (run init from the project's own folder, or add the block by hand)..claude/CLAUDE.mdchange removes only the Astryx-managed block between its markers, and only when rootCLAUDE.mdholds the same block. It never touches the rest of the file, and it deletes the file only when nothing but whitespace is left.--remove-agentsremoves only managed blocks init writes. It now also covers the project root, where init writes, as well as the folder it runs in. It removes only the managed blocks, with the same rules for what is deleted.Maintainer decision: the managed agent-docs block
The block between the Astryx markers is Astryx-owned content. This replaces the earlier decisions on exit codes for protected skips and on upgrade and protected agent docs.
architecture:cli-surfaceINV10 still refuses any path outside the project. An agent file 0.7.1 wrote whose path leaves the project (for example aCLAUDE.mdlinked to a shared file) still fails init with exit 1. AGEMINI.mdthat resolves outside the project is a file only this PR writes, so it is left as it is, reported indocsErrorwith one note, and init exits 0. That applies in the default layout and in a project's own layout.architecture:cli-surfaceINV31 now says: "The managed block is Astryx-owned:spec:AST-040's protections cover consumer-owned content, not the block; INV10 still confines every write."spec:AST-040FR8 points to INV31 for the block. AST-040's protections keep covering codemods and every other edit to consumer-owned content.CLAUDE.mdis one the project ignores, a committed.claude/CLAUDE.mdcopy is refreshed, not removed, so a fresh clone still gives Claude Code a copy. An extra copy is accepted (DEC-2).apps/sandboxrunsastryx init --features agentson every install. A test pins that a fresh install, a second install, and a machine with an old.claude/CLAUDE.mdall print nothing on stderr.Writing rubric results
Scope: the record lines this pull request changes. These are the
architecture:cli-surfaceINV31 header clause, the ignored-root exception in INV31's Claude Code bullet, the INV31 "managed block is Astryx-owned" bullet, and thespec:AST-040FR8 pointer sentence.R1 narration: none. Each sentence states what init and upgrade do, or which record governs the block. None says what changed, what was proposed, or what used to happen.
R2 research: none in the records. The reasoning for the ignored-root exception (a fresh clone lacks an ignored root
CLAUDE.md) is one clause inside the rule it supports.R3 evidence: no evidence or verification cell changed. INV31's existing verification row covers the new behavior through the agent-docs, init, and upgrade tests it already names.
R4 rejected alternatives: none recorded. The exception states only the chosen behavior.
R5 change references: none. Searching the changed lines for
#followed by digits,/pull/, and/issues/finds nothing. The only references are to records (spec:AST-040,architecture:cli-surfaceINV31, INV10,spec:AST-017FR16).R6 open questions: none. The changed sections hold no open questions.
Testing
agent-docs.test.mjs,agent-docs.path-safety.test.mjs,init.behavior.test.mjs,init.test.mjs,remove.test.mjs,doctor.test.mjs,upgrade.test.mjsandsetup-nudge.test.mjs. They cover each layout rule, Claude files that importAGENTS.md, every form of Gemini settings, links outside the project, the home and settings folders, Codex- and Cursor-shaped worktree paths, the presets,doctor,--remove-agentsfrom a subfolder and the reminder to runinit. Run againstmain's code, with the new exports stubbed so the test files load, 68 of them fail.pnpm check:repo, the copyright, README and exports checks, Core's postinstall test, and the build.Overlapping pull requests
packages/cli/clients/cli/index.mjs,packages/cli/clients/cli/commands/setup-nudge.test.mjs,packages/cli/api/doctor/doctor.mjs,packages/cli/foundation/agent-docs/agent-docs.mjsand both copies of the setup contract:packages/cli/foundation/agent-docs/agent-doc-state.mjsand Core's generated copy,packages/core/scripts/agent-doc-state.mjs. The two conflict inpackages/cli/clients/cli/index.mjs: both change the setup reminder's "already set up" check, this one to also look at the project root, fix(cli): the setup reminder, the swizzle StyleX note, and a doctor line say only what is true #7262 to look for the block up to the repository root. Core's copy of the setup contract stays in sync. Agreed resolution in clients/cli/index.mjs: keep fix(cli): the setup reminder, the swizzle StyleX note, and a doctor line say only what is true #7262'sinOwnSourceCheckout(cwd)plusisAstryxPromptInReach(cwd)check and drop this pull request's|| isAstryxInitialized(resolveAgentDocsRoot(cwd) ?? cwd)clause. The reach check finds the project-root block from any subfolder inside a repository and never counts a GEMINI.md import as set up. Whichever lands second runspnpm check:setup-contract.buildto the block's command list) and agent-docs: single-source setup gotchas as data #6731 (setup gotchas as data, draft) both editgenerateCompressedIndexinpackages/cli/foundation/agent-docs/agent-docs.mjs. fix(cli): add build to agent-docs CLI reference #6951 and agent-docs: single-source setup gotchas as data #6731 change what the block says; this changes only where init writes it, so they compose. The hunks do not overlap.packages/cli/api/doctor/doctor.mjs,packages/cli/foundation/agent-docs/agent-docs.mjsand its tests. feat(Theme): one-prop compact density for dense tools #6817 (compact density, draft) editsagent-docs.mjsand its tests.packages/cli/api/doctor/doctor.mjs.astryx mcp, draft) and feat(cli): addintegration initcommand #6961 (theintegration initcommand) editpackages/cli/clients/cli/index.mjs.packages/cli/assets/docs/working-with-ai.doc.mjs.Whichever lands second is updated onto the other.