pilot-shell icon indicating copy to clipboard operation
pilot-shell copied to clipboard

Rule-reference check in sync-agent-assets.mjs mis-resolves a ~/.claude/rules/... (home-relative) reference as a project-local path

Open ianrios opened this issue 2 months ago • 1 comments

auditRuleRouting/extractRuleReferences in skills/setup-rules/scripts/sync-agent-assets.mjs extract any .claude/rules/...md-shaped substring from AGENTS.md with no check for what precedes it. A legitimate ~/.claude/rules/development-practices.md reference (a global, home-relative rule that genuinely exists at that path) gets captured with the ~/ silently dropped, then resolved as path.resolve(repo, '.claude', 'rules', 'development-practices.md') — a project-local path that correctly doesn't exist — and reported as AGENTS.md references missing rule file: ..., blocking session Stop.

Verified the repo itself was fine: node sync-agent-assets.mjs --check --repo <repo> after working around the phrasing reports "Agent assets are synchronized." The only way to avoid the false block today is rewording any AGENTS.md line so it never writes the literal ~/.claude/rules/....md path in one unbroken run — describing the file by name/section instead of giving its path.

Requested fix: the extraction regexes need to exclude a match preceded by ~ (or more generally, require a word/line boundary immediately before .claude/rules/ rather than matching the substring anywhere).

Distinct from #187 — that one is isTrivialClaude's CLAUDE.md/AGENTS.md content check; this is the separate reference-extraction path in the same file.

ianrios avatar Sep 08 '26 20:09 ianrios

Thanks @ianrios for the precise report and for separating this from the generated-file issue.

Resolved in Pilot Shell v11.0.2.

The rule-reference extractor now accepts only genuinely repository-relative .claude/rules/... references. Tokens embedded under ~/, $HOME/, absolute paths, parent-relative paths, or longer path prefixes are excluded, while valid Markdown and bare project-local references continue to work.

Regression coverage includes the home-relative case and the other non-project path prefixes. Thanks again for the clear reproduction.

maxritter avatar Sep 09 '26 13:09 maxritter