forked from bchanot/claude
fix(project-rules): physical parent check, emit write guard, extract keeps both copies
_rules_out_path_ok resolves the first existing ancestor with cd -P and refuses an out that escapes the project; emit goes through it and checks mkdir and the write; an extract rewrite failure keeps tmp and out and names both. Callers (onboarder, scaffolder) stop on any rc 2 but exists.
This commit is contained in:
1 parent
4e71b1af64
commit
9d5530af89
4 files changed
+83
-24
No files matched your search
+4
-2
@@ -141,7 +141,8 @@ bash ~/.claude/lib/project-rules.sh -C <PROJECT_ROOT> emit ~/.claude/templates/p
|
||||
`build_cmd`, `testing` layout from `test_cmd`); never duplicate the
|
||||
always-on Build/Test sections.
|
||||
- rc 1 → no match, nothing written, skip silently.
|
||||
- rc 2 → the file exists: keep it, never overwrite.
|
||||
- rc 2 whose stderr line ends with ` exists` → keep the file, never
|
||||
overwrite; any other rc 2 → STOP, relay the lib's line.
|
||||
Then `bash ~/.claude/lib/project-rules.sh -C <PROJECT_ROOT> check` must print
|
||||
`N rule(s) ok`. The `!.claude/rules/` negation comes from the gitflow socle
|
||||
at /onboard STEP 2.6 (`gitflow init` reconciles it); PHASE 4 stays as is.
|
||||
@@ -252,7 +253,8 @@ rc ≠ 0 (should not happen after S0) → ROLLBACK: `git -C <PROJECT_ROOT>
|
||||
reset -q`, `git -C <PROJECT_ROOT> checkout -- CLAUDE.md` (plus
|
||||
`.gitignore` when S0 appended to it), delete every
|
||||
`.claude/rules/<name>.md` this run wrote (literal paths, one `rm` per
|
||||
row), then STOP with the row and the lib's message.
|
||||
row; a row that failed at the rewrite step also leaves a tmp file named
|
||||
on stderr: delete it too), then STOP with the row and the lib's message.
|
||||
|
||||
S2 — POINTER. If CLAUDE.md has no `## Path-scoped rules` section, append:
|
||||
```markdown
|
||||
|
||||
Reference in new issue
Block a user