greprag 5.82.1 → 5.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/claude-lifecycle-cutover.js +5 -16
  2. package/dist/commands/codex.js +4 -0
  3. package/dist/commands/corpus/client.js +16 -0
  4. package/dist/commands/corpus/index.js +5 -2
  5. package/dist/commands/corpus/section.js +3 -3
  6. package/dist/commands/corpus/walk.js +3 -3
  7. package/dist/commands/delivery.js +64 -0
  8. package/dist/commands/docptr.js +10 -24
  9. package/dist/commands/init.js +4 -5
  10. package/dist/commands/load-primer-reminder.js +2 -2
  11. package/dist/commands/load.js +45 -12
  12. package/dist/commands/merge-guard.js +94 -9
  13. package/dist/commands/parity.js +0 -2
  14. package/dist/commands/pipe-wrap.js +4 -2
  15. package/dist/commands/skill-mirror-reminder.js +24 -6
  16. package/dist/commands/skill.js +24 -8
  17. package/dist/commands/skillgain.js +5 -1
  18. package/dist/commands/state-trigger.js +67 -31
  19. package/dist/delivery-config.js +69 -0
  20. package/dist/deploy-locks.js +18 -3
  21. package/dist/doc-mirror-client.js +39 -11
  22. package/dist/hook.js +35 -39
  23. package/dist/index.js +62 -27
  24. package/dist/native-adapter-refresh.js +114 -0
  25. package/dist/native-skill-adoption.js +20 -53
  26. package/dist/native-skill-mirror.js +130 -52
  27. package/dist/native-skill-pending.js +5 -2
  28. package/dist/opencode-plugin.bundle.js +1079 -159
  29. package/dist/opencode-plugin.js +6 -0
  30. package/dist/skill-activation-manifest.js +98 -22
  31. package/dist/skill-landing.js +6 -0
  32. package/dist/skill-mirror-files.js +59 -0
  33. package/package.json +1 -1
  34. package/scripts/postinstall.js +4 -19
  35. package/skill/greprag/docs/corpus.md +2 -2
  36. package/skill/greprag/docs/setup.md +1 -1
  37. package/skill/mechanic/SKILL.md +14 -39
  38. package/skill/mechanic/docs/skill-fix-conventions.md +2 -2
  39. package/skill/templates/chip-spawn.md +36 -20
@@ -2,9 +2,9 @@
2
2
 
3
3
  **Grok Build?** Stop. Run `greprag load grok-chip-spawn`. This entry is Claude `spawn_task`.
4
4
 
5
- The `pre-spawn-check` PreToolUse hook **validates** chip prompts at the spawn boundary, but **cannot inject content** — `modifiedInput` is silently dropped by the CCD harness for MCP `spawn_task` calls (see `adr/spawn-task-hook-mode.md` 2026-05-27 entry). The agent writes Block 1 into the prompt itself. Validator rejects with `permissionDecision: deny` and a remediation reason if the `Chip: ` title prefix or the Block 1 worktree marker is missing.
5
+ The `pre-spawn-check` PreToolUse hook **validates** chip prompts at the spawn boundary, but **cannot inject content** — `modifiedInput` is silently dropped by the CCD harness for MCP `spawn_task` calls (see `adr/spawn-task-hook-mode.md` 2026-05-27 entry). The agent writes Block 1 into the prompt itself. Validator rejects with `permissionDecision: deny` and a remediation reason if the `Chip: ` title prefix or the current Block 1 (its `git branch -m` reuse step and its `git worktree add` local-start step) is missing.
6
6
 
7
- **Chips talk over native `SendMessage`, not greprag.** Claude Code addresses live sessions by name on this machine — `ListAgents` to discover, `SendMessage to: "<name>"` to send, delivered at the recipient's next tool boundary. The parent gets native start and completion notifications for every chip it spawns. So there is no IN-FLIGHT ping, no `greprag send` report-back, and **no watcher to arm**. greprag's role in the chip loop is now content only (the `fix list` pre-pull below, and `fix spawn` as mission generator).
7
+ **Chips talk over native `SendMessage`, not greprag.** Claude Code addresses live sessions by name on this machine — `ListAgents` to discover, `SendMessage to: "<name>"` to send, delivered at the recipient's next tool boundary — unless the recipient runs in a different permission mode, which holds the message for the operator's approval and may let it expire. The parent gets native start and completion notifications for every chip it spawns. So there is no IN-FLIGHT ping, no `greprag send` report-back, and **no watcher to arm**. greprag's role in the chip loop is now content only (the `fix list` pre-pull below, and `fix spawn` as mission generator).
8
8
 
9
9
  > **Part of a multi-chip mission?** If this chip is one of ≥2 aimed at a single objective, you should already be inside a chip-leader plan — your **base branch** and **merge target** (the integration branch, *never* master) come from it. If you're not, stop and run `greprag load chip-leader` first. A lone chip targeting its own objective proceeds here directly.
10
10
 
@@ -18,6 +18,9 @@ Add `mode: interactive` as the first line of the task body to pause the chip for
18
18
 
19
19
  ## Block 1 — Setup (verbatim, substitute `<slug>`)
20
20
 
21
+ <!-- adr: adr/prespawn-augmentation.md -->
22
+ The desktop app starts each spawned chip in a fresh worktree of its own. Block 1 keeps that worktree and renames its branch to `chip/<slug>`; it makes `.claude/worktrees/<slug>` only on a local start.
23
+
21
24
  `<slug>` = title slugified (e.g. `Chip: Fix synthesis loop` → `fix-synthesis-loop`). `<parent-name>` = YOUR native session name, the one `ListAgents` prints as "This session is `<name>`" — that is the chip's reply address, not a greprag 8-hex.
22
25
 
23
26
  ````
@@ -25,20 +28,32 @@ Add `mode: interactive` as the first line of the task body to pause the chip for
25
28
 
26
29
  ```bash
27
30
  main_root=$(git rev-parse --git-common-dir | xargs dirname)
28
- cd "$main_root"
29
-
30
- if [ -d ".claude/worktrees/<slug>" ]; then
31
- cd ".claude/worktrees/<slug>"
32
- current_branch=$(git branch --show-current)
33
- if [ "$current_branch" = "chip/<slug>" ]; then
34
- echo "Worktree already exists on correct branch — reusing"
31
+ branch=$(git branch --show-current)
32
+
33
+ if [ "$branch" = "chip/<slug>" ]; then
34
+ echo "Already on chip/<slug> — reusing this worktree"
35
+ elif [ "$(git rev-parse --path-format=absolute --git-dir)" != "$(git rev-parse --path-format=absolute --git-common-dir)" ] \
36
+ && [ -n "$branch" ] && [ -z "$(git status --porcelain)" ] \
37
+ && [ -z "$(git for-each-ref --format='%(upstream)' "refs/heads/$branch")" ] \
38
+ && git merge-base --is-ancestor HEAD "$(git -C "$main_root" rev-parse HEAD)"; then
39
+ # The app already gave this chip a fresh worktree (clean, local branch, no commits of its own): use it.
40
+ git branch -m "chip/<slug>" || exit 1
41
+ else
42
+ # Started locally, so there is no fresh worktree here: make the chip's own.
43
+ cd "$main_root"
44
+ if [ -d ".claude/worktrees/<slug>" ]; then
45
+ cd ".claude/worktrees/<slug>"
46
+ current_branch=$(git branch --show-current)
47
+ if [ "$current_branch" = "chip/<slug>" ]; then
48
+ echo "Worktree already exists on correct branch — reusing"
49
+ else
50
+ echo "ERROR: Worktree dir exists but is on branch '$current_branch', not 'chip/<slug>'. Remove it and retry." >&2
51
+ exit 1
52
+ fi
35
53
  else
36
- echo "ERROR: Worktree dir exists but is on branch '$current_branch', not 'chip/<slug>'. Remove it and retry." >&2
37
- exit 1
54
+ git worktree add ".claude/worktrees/<slug>" -b chip/<slug>
55
+ cd ".claude/worktrees/<slug>"
38
56
  fi
39
- else
40
- git worktree add ".claude/worktrees/<slug>" -b chip/<slug>
41
- cd ".claude/worktrees/<slug>"
42
57
  fi
43
58
 
44
59
  # Pristine worktrees check out source only — if the repo ships a worktree
@@ -57,7 +72,7 @@ Your parent session is named `<parent-name>`. When you finish, report to it with
57
72
 
58
73
  **Worktree launch failed? START THE CHIP LOCALLY instead.** The harness creates the worktree before your Block 1 ever runs, and when that fails the spawning session sees nothing — no error, no exit code, only the operator reporting it is stuck. A local start is safe and self-correcting: Block 1 creates the worktree itself as its first action, so nothing is lost and nothing is done twice. If the same slug fails again, change the slug — you cannot see harness-side worktree errors, so elimination is the only tool you have.
59
74
 
60
- **Multi-chip mission (`greprag load chip-leader`)?** The spawn title alone does NOT reach FleetView's watcher registry — that title is auto-generated by gpt-5.4-nano from your opening turn. So the leader will have you **stamp your registry title in Block 1**, right after the `cd` into the worktree:
75
+ **Multi-chip mission (`greprag load chip-leader`)?** The spawn title alone does NOT reach FleetView's watcher registry — that title is auto-generated by gpt-5.4-nano from your opening turn. So the leader will have you **stamp your registry title in Block 1**, right after the worktree setup:
61
76
 
62
77
  ```bash
63
78
  greprag session retitle <your-own-8hex> "Chip <Label> — <workstream>"
@@ -72,21 +87,22 @@ Close the task body with this (substitute `<slug>` + `<parent-name>`):
72
87
  ````
73
88
  ---
74
89
 
75
- **Report back:** when the work is committed, send your result to the parent with native `SendMessage`:
90
+ **Report back:** when the work is committed, send your result to the parent with native `SendMessage`, then end your turn:
76
91
 
77
92
  - `to`: `"<parent-name>"`
78
93
  - `message`: status, commit hash, branch `chip/<slug>`, and a one-line summary.
94
+ - `notify_when_idle`: `true`
79
95
 
80
- The parent is a live session on this machine — no greprag address, no watcher. If `SendMessage` errors because the parent has ended, stop and leave the commit on the branch; the parent picks it up at merge.
96
+ The parent is a live session on this machine — no greprag address, no watcher. A successful send only means queued: a parent in a different permission mode holds the report for the operator's approval and may let it expire, and the `[Cross-session delivery notice]` saying so reaches you only after your turn ends.
81
97
 
82
- **Then close yourself:** once the report has landed, run `/close`. It takes the chip path automatically (it recognises a `chip/` branch), so it sends no question and touches nothing outside this worktree — it commits any stragglers, confirms the report, and archives the session, which removes this worktree. Your branch survives for the parent to merge. If the report failed because the parent is gone, do NOT close — leave the worktree standing.
98
+ **Then close yourself:** run `/close` only when the parent's `[Cross-session idle notice]` says it is idle and no delivery notice said the report was held, refused or not approved before expiry. `/close` takes the chip path automatically (it recognises a `chip/` branch), so it sends no question and touches nothing outside this worktree — it commits any stragglers and archives the session, which removes this worktree. Your branch survives for the parent to merge. Anything else — a held, refused or expired report, or `SendMessage` erroring because the parent has ended — means the report did not land: do NOT close, leave the commit on the branch and the worktree standing, and tell the operator where the report is (a held one waits for their approval in `<parent-name>`).
83
99
 
84
100
  **Cleanup discipline (HARD RULE):** chip prompts forbid `git clean`, `git reset --hard`, `git worktree remove`, `git checkout <other>`, raw `rm -rf` outside the worktree's tracked files.
85
101
  ````
86
102
 
87
103
  ## After spawning — do nothing
88
104
 
89
- No watcher. No arming. The harness tells you when the operator starts the chip and again when it ends, and the chip's own `SendMessage` lands at your next tool boundary. Never arm a `Monitor` on greprag's inbox for chip traffic — the inbox watcher exists for Discord, inbound email, and cold opens, not for chips.
105
+ No watcher. No arming. The harness tells you when the operator starts the chip and again when it ends. Never arm a `Monitor` on greprag's inbox for chip traffic — the inbox watcher exists for Discord, inbound email, and cold opens, not for chips.
90
106
 
91
107
  ## Before composing
92
108
 
@@ -100,6 +116,6 @@ Chips never `npm run deploy` (or Wrangler / another provider deploy) from the wo
100
116
 
101
117
  ## Parent merge discipline — prune at the merge (HARD RULE)
102
118
 
103
- When you (the parent) merge a chip branch — through the canonical commit path or a profile-declared merge — prune in the same breath: junction guard (`~/.claude/skills/commit/guard-junctions.sh <worktree>`), `git worktree remove .claude/worktrees/<slug>`, and `git branch -d chip/<slug>` once merged. A chip that closed itself has already removed its own worktree, so that path will be gone — delete the branch and move on, don't go hunting for it. Deferred cleanup = stale worktrees piling up (field state 2026-06-10: 3 leftovers). Multi-chip missions: worktree dies at the integration-branch merge; the branch lives until the configured default-branch merge (chip-leader Phase 4).
119
+ When you (the parent) merge a chip branch — through the canonical commit path or a profile-declared merge — prune in the same breath: find the worktree holding `chip/<slug>` in `git worktree list` (the app's own worktree when the chip reused it, `.claude/worktrees/<slug>` on a local start), junction guard it (`~/.claude/skills/commit/guard-junctions.sh <worktree>`), `git worktree remove <worktree>`, and `git branch -d chip/<slug>` once merged. A chip that closed itself has already removed its own worktree, so no worktree holds the branch — delete the branch and move on, don't go hunting for it. Deferred cleanup = stale worktrees piling up (field state 2026-06-10: 3 leftovers). Multi-chip missions: worktree dies at the integration-branch merge; the branch lives until the configured default-branch merge (chip-leader Phase 4).
104
120
 
105
121
  **FIX chips report to the mission owner.** A `greprag fix spawn` mission is the source of truth for FIX behavior. `fix spawn` detects usable Git history and emits `workspaceMode`: Git uses an isolated worktree; non-Git, unavailable Git, or no commit uses the project-local task with serialized writes. Dispatch honors that mode without trying a worktree first. The FIX chip identifies the exact friction, makes the smallest durable root-cause fix, verifies and commits useful work, then reports the commit/result and cleanup parameters to the parent mission owner. It creates no human landing gate. If no live parent exists and the chip carries the full-goal mission, it follows the repo profile as mission owner.