mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-02 17:40:02 +02:00
fix(sync-gbrain): define Step 4 helper args and one atomic write path
Both census read-ready attempts spent turns reading the helper source to resolve <user-args>, inspecting fixture internals kept inside the repo, and reconciling 'Read + Edit' with the tmp+mv atomic write, then hit max turns before the verdict.
This commit is contained in:
1 parent
5c900eb18c
commit
39fc663894
3 files changed
+26
-15
No files matched your search
+10
-5
@@ -672,6 +672,10 @@ Capability check (per /plan-eng-review §6):
|
||||
bun run ~/.claude/skills/gstack/bin/gstack-gbrain-read-capability.ts <user-args>
|
||||
```
|
||||
|
||||
`<user-args>` are the same flags this /sync-gbrain invocation passed to Step 2,
|
||||
unchanged (empty for a plain run). The helper needs no other input: run it once
|
||||
and use its JSON result; do not inspect its source or the gbrain CLI first.
|
||||
|
||||
The helper reports JSON `status: ready` only after the successful code sync's
|
||||
source and real worktree match `.gbrain-source`, the source registration points
|
||||
to that worktree, and a bounded, source-scoped list/get returns the same page.
|
||||
@@ -746,16 +750,17 @@ sync code walk for them requires an explicit `--allow-reclone` opt-in.
|
||||
<!-- gstack-gbrain-search-guidance:end -->
|
||||
```
|
||||
|
||||
Use the Read + Edit tools. The find-and-replace target is the entire region
|
||||
from `<!-- gstack-gbrain-search-guidance:start -->` through
|
||||
Read CLAUDE.md once and compute its new content. The replacement target is
|
||||
the entire region from `<!-- gstack-gbrain-search-guidance:start -->` through
|
||||
`<!-- gstack-gbrain-search-guidance:end -->`. If those markers are missing,
|
||||
search for `## GBrain Search Guidance (configured by /sync-gbrain)` heading
|
||||
and replace from there to the next `## ` or EOF. If no heading exists, append
|
||||
the entire block at the end of CLAUDE.md.
|
||||
|
||||
**Atomic write:** write the new CLAUDE.md content to a tmp file alongside it
|
||||
(e.g., `CLAUDE.md.sync-gbrain.tmp`) then `mv` to atomic-rename, so a crash
|
||||
mid-write never leaves the file half-modified.
|
||||
**Atomic write (the only write path; do not Edit CLAUDE.md in place):** Write
|
||||
the complete new content to `CLAUDE.md.sync-gbrain.tmp` beside it, then `mv` it
|
||||
over CLAUDE.md, so a crash mid-write never leaves the file half-modified. Verify
|
||||
the block count in the same Bash call as the `mv`, then go to Step 5.
|
||||
|
||||
**If `status=unknown`** — preserve the existing guidance block, if any, and
|
||||
report the helper's reason as WARN with advice to retry `/sync-gbrain` or the
|
||||
|
||||
@@ -323,6 +323,10 @@ Capability check (per /plan-eng-review §6):
|
||||
bun run ~/.claude/skills/gstack/bin/gstack-gbrain-read-capability.ts <user-args>
|
||||
```
|
||||
|
||||
`<user-args>` are the same flags this /sync-gbrain invocation passed to Step 2,
|
||||
unchanged (empty for a plain run). The helper needs no other input: run it once
|
||||
and use its JSON result; do not inspect its source or the gbrain CLI first.
|
||||
|
||||
The helper reports JSON `status: ready` only after the successful code sync's
|
||||
source and real worktree match `.gbrain-source`, the source registration points
|
||||
to that worktree, and a bounded, source-scoped list/get returns the same page.
|
||||
@@ -397,16 +401,17 @@ sync code walk for them requires an explicit `--allow-reclone` opt-in.
|
||||
<!-- gstack-gbrain-search-guidance:end -->
|
||||
```
|
||||
|
||||
Use the Read + Edit tools. The find-and-replace target is the entire region
|
||||
from `<!-- gstack-gbrain-search-guidance:start -->` through
|
||||
Read CLAUDE.md once and compute its new content. The replacement target is
|
||||
the entire region from `<!-- gstack-gbrain-search-guidance:start -->` through
|
||||
`<!-- gstack-gbrain-search-guidance:end -->`. If those markers are missing,
|
||||
search for `## GBrain Search Guidance (configured by /sync-gbrain)` heading
|
||||
and replace from there to the next `## ` or EOF. If no heading exists, append
|
||||
the entire block at the end of CLAUDE.md.
|
||||
|
||||
**Atomic write:** write the new CLAUDE.md content to a tmp file alongside it
|
||||
(e.g., `CLAUDE.md.sync-gbrain.tmp`) then `mv` to atomic-rename, so a crash
|
||||
mid-write never leaves the file half-modified.
|
||||
**Atomic write (the only write path; do not Edit CLAUDE.md in place):** Write
|
||||
the complete new content to `CLAUDE.md.sync-gbrain.tmp` beside it, then `mv` it
|
||||
over CLAUDE.md, so a crash mid-write never leaves the file half-modified. Verify
|
||||
the block count in the same Bash call as the `mv`, then go to Step 5.
|
||||
|
||||
**If `status=unknown`** — preserve the existing guidance block, if any, and
|
||||
report the helper's reason as WARN with advice to retry `/sync-gbrain` or the
|
||||
|
||||
Reference in new issue
Block a user