🐛 fix(playbook): use relative paths in CLAUDE.md when not at project root
When CLAUDE.md lives in a subdirectory (e.g. .claude/CLAUDE.md), the @AGENTS.md import must use ../AGENTS.md since Claude Code resolves @path relative to the file's directory. Calculate depth automatically. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6518f0f554
commit
c8d6bf21a6
|
|
@ -746,11 +746,20 @@ def sync_claude_md(project_root: Path, config: dict) -> None:
|
|||
if claude_md is None:
|
||||
claude_md = project_root / "CLAUDE.md"
|
||||
|
||||
rel_prefix = ""
|
||||
try:
|
||||
rel = claude_md.parent.resolve().relative_to(project_root.resolve())
|
||||
if rel != Path("."):
|
||||
depth = len(rel.parts)
|
||||
rel_prefix = "../" * depth
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
block_lines = [
|
||||
_CLAUDE_BLOCK_START,
|
||||
"",
|
||||
"@AGENTS.md",
|
||||
"@AGENT_RULES.md",
|
||||
f"@{rel_prefix}AGENTS.md",
|
||||
f"@{rel_prefix}AGENT_RULES.md",
|
||||
"",
|
||||
_CLAUDE_BLOCK_END,
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in New Issue