greprag 5.40.0 → 5.40.1

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 (43) hide show
  1. package/dist/commands/checkpoint-helpers.js +3 -3
  2. package/dist/commands/checkpoint-helpers.js.map +1 -1
  3. package/dist/commands/claude-md-patch.d.ts +56 -0
  4. package/dist/commands/claude-md-patch.js +124 -0
  5. package/dist/commands/claude-md-patch.js.map +1 -0
  6. package/dist/commands/codex-app-server.js +2 -2
  7. package/dist/commands/codex-app-server.js.map +1 -1
  8. package/dist/commands/codex-doctor.js +2 -2
  9. package/dist/commands/codex-doctor.js.map +1 -1
  10. package/dist/commands/codex-supervisor.js +2 -2
  11. package/dist/commands/codex-supervisor.js.map +1 -1
  12. package/dist/commands/codex.js +2 -2
  13. package/dist/commands/codex.js.map +1 -1
  14. package/dist/commands/desk-line.js +3 -2
  15. package/dist/commands/desk-line.js.map +1 -1
  16. package/dist/commands/inbox-watch-supervisor.d.ts +9 -0
  17. package/dist/commands/inbox-watch-supervisor.js +162 -4
  18. package/dist/commands/inbox-watch-supervisor.js.map +1 -1
  19. package/dist/commands/init.d.ts +11 -7
  20. package/dist/commands/init.js +69 -33
  21. package/dist/commands/init.js.map +1 -1
  22. package/dist/commands/watcher-registry.d.ts +8 -1
  23. package/dist/commands/watcher-registry.js +51 -9
  24. package/dist/commands/watcher-registry.js.map +1 -1
  25. package/dist/guard.js +5 -5
  26. package/dist/guard.js.map +1 -1
  27. package/dist/hook.js +6 -6
  28. package/dist/hook.js.map +1 -1
  29. package/dist/index.js +12 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/opencode-plugin-helpers.js +2 -2
  32. package/dist/opencode-plugin-helpers.js.map +1 -1
  33. package/dist/opencode-plugin.js +5 -5
  34. package/dist/opencode-plugin.js.map +1 -1
  35. package/dist/proc.d.ts +35 -0
  36. package/dist/proc.js +45 -0
  37. package/dist/proc.js.map +1 -0
  38. package/dist/project-anchor.js +2 -2
  39. package/dist/project-anchor.js.map +1 -1
  40. package/dist/session-id.js +12 -1
  41. package/dist/session-id.js.map +1 -1
  42. package/package.json +1 -1
  43. package/skill/templates/workshop-chip.md +5 -2
@@ -26,11 +26,46 @@
26
26
  * module-eval time), so it is safe.
27
27
  *
28
28
  * adr: adr/monitor-resilience.md */
29
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ var desc = Object.getOwnPropertyDescriptor(m, k);
32
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
33
+ desc = { enumerable: true, get: function() { return m[k]; } };
34
+ }
35
+ Object.defineProperty(o, k2, desc);
36
+ }) : (function(o, m, k, k2) {
37
+ if (k2 === undefined) k2 = k;
38
+ o[k2] = m[k];
39
+ }));
40
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
41
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
42
+ }) : function(o, v) {
43
+ o["default"] = v;
44
+ });
45
+ var __importStar = (this && this.__importStar) || (function () {
46
+ var ownKeys = function(o) {
47
+ ownKeys = Object.getOwnPropertyNames || function (o) {
48
+ var ar = [];
49
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
50
+ return ar;
51
+ };
52
+ return ownKeys(o);
53
+ };
54
+ return function (mod) {
55
+ if (mod && mod.__esModule) return mod;
56
+ var result = {};
57
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
58
+ __setModuleDefault(result, mod);
59
+ return result;
60
+ };
61
+ })();
29
62
  Object.defineProperty(exports, "__esModule", { value: true });
30
63
  exports.FATAL_EXIT_CODE = exports.SUPERVISE_ENV = void 0;
31
64
  exports.installLastResortHandlers = installLastResortHandlers;
65
+ exports.waitForStableMtime = waitForStableMtime;
32
66
  exports.runSupervisor = runSupervisor;
33
- const child_process_1 = require("child_process");
67
+ const fs = __importStar(require("fs"));
68
+ const proc_1 = require("../proc");
34
69
  const inbox_watch_1 = require("./inbox-watch");
35
70
  const watcher_registry_1 = require("./watcher-registry");
36
71
  const LOG_PREFIX = '[greprag inbox watch]';
@@ -67,6 +102,30 @@ const SUPERVISOR_BACKOFF_FACTOR = 2;
67
102
  // 60s of uninterrupted child life resets the backoff so a long-lived
68
103
  // child that finally dies retries fast, not slowly.
69
104
  const SUPERVISOR_HEALTHY_RESET_MS = 60_000;
105
+ // ---- Monitor-task liveness probe (2026-06-10) ----------------------------
106
+ // The pipe binding (bindToConsumer) catches the harness CLOSING the pipe
107
+ // (session end/reload) and --owner-pid catches claude.exe dying — but a
108
+ // TaskStop (and the host restart on a model switch) kills only the Monitor
109
+ // task's bash layers: claude.exe survives, the harness keeps the pipe's read
110
+ // end open, and the sh→supervisor→child stack orphans (reproduced live
111
+ // 2026-06-10: TaskStop killed bash 7604/17948; sh 14148 + node 11556/12776
112
+ // survived and needed a manual taskkill — the reaper read them `ok→keep
113
+ // via=owner=…:live-claude`). The arm command stamps the Monitor bash's
114
+ // Windows PID (`--monitor-pid`, from /proc/$$/winpid); this probe tests it
115
+ // with ONE pidAlive() syscall per tick — never a process-table snapshot (the
116
+ // 2026-06-05b lesson) — and on death stops the whole watcher through the
117
+ // normal terminal teardown (goodbye + pidfile removal, no respawn).
118
+ // Env-overridable for tests. adr: adr/monitor-resilience.md (2026-06-10)
119
+ const MONITOR_PROBE_MS = Number(process.env.GREPRAG_WATCH_MONITOR_PROBE_MS) || 15_000;
120
+ // Rebuild settle (2026-06-10): `npm run build` swaps dist/ under every running
121
+ // watcher; the child crashes (a lazy `require` loads a half-written module) and
122
+ // an immediate respawn loads a partially-emitted entry file → a crash-loop wave
123
+ // per rebuild, fleet-wide. When the entry script's mtime has changed since the
124
+ // child was spawned, wait for the build to go quiet before respawning, and
125
+ // reset the backoff — a rebuild is a restart condition, not a crash storm.
126
+ const REBUILD_SETTLE_POLL_MS = 500;
127
+ const REBUILD_SETTLE_QUIET_MS = 1_500;
128
+ const REBUILD_SETTLE_MAX_WAIT_MS = 30_000;
70
129
  // Exit code the child uses for "fatal, do not respawn" conditions —
71
130
  // 4xx HTTP responses, missing API key, missing anchor. Anything else
72
131
  // (signal, code 1, code 2, exception) is a crash and gets respawned.
@@ -116,6 +175,51 @@ function ownerPidFromArgv(argv) {
116
175
  }
117
176
  return undefined;
118
177
  }
178
+ /** The Monitor task's bash PID forwarded by the arm command
179
+ * (`--monitor-pid N`, Windows pid space via /proc/$$/winpid). 0 = the arm-time
180
+ * "no stamp" fallback → undefined. */
181
+ function monitorPidFromArgv(argv) {
182
+ const i = argv.indexOf('--monitor-pid');
183
+ if (i >= 0 && i + 1 < argv.length) {
184
+ const n = Number(argv[i + 1]);
185
+ if (Number.isFinite(n) && n > 0)
186
+ return n;
187
+ }
188
+ return undefined;
189
+ }
190
+ /** Entry-script mtime, or null when unstatable (deleted mid-rebuild, exotic
191
+ * launcher). Null disables the rebuild-settle branch — fail-open. */
192
+ function entryMtimeMs(entry) {
193
+ try {
194
+ return fs.statSync(entry).mtimeMs;
195
+ }
196
+ catch {
197
+ return null;
198
+ }
199
+ }
200
+ /** Resolve once `file`'s mtime has been UNCHANGED for `quietMs` (the build is
201
+ * done writing), or after `maxWaitMs` regardless (never wedge the supervisor
202
+ * on a watch loop). A stat failure (file mid-rename) counts as "still
203
+ * changing". Exported for tests. */
204
+ async function waitForStableMtime(file, opts) {
205
+ const pollMs = opts?.pollMs ?? REBUILD_SETTLE_POLL_MS;
206
+ const quietMs = opts?.quietMs ?? REBUILD_SETTLE_QUIET_MS;
207
+ const maxWaitMs = opts?.maxWaitMs ?? REBUILD_SETTLE_MAX_WAIT_MS;
208
+ const deadline = Date.now() + maxWaitMs;
209
+ let last = null;
210
+ let stableSince = Date.now();
211
+ while (Date.now() < deadline) {
212
+ const m = entryMtimeMs(file);
213
+ if (m === null || m !== last) {
214
+ last = m;
215
+ stableSince = Date.now();
216
+ }
217
+ else if (Date.now() - stableSince >= quietMs) {
218
+ return;
219
+ }
220
+ await new Promise((r) => setTimeout(r, pollMs));
221
+ }
222
+ }
119
223
  /** Fire one short, best-effort liveness request. Never throws; never blocks
120
224
  * longer than `timeoutMs` (so a dead network can't hang the heartbeat or stall
121
225
  * exit). adr: docs/registry-freshness-design.md */
@@ -193,9 +297,10 @@ async function runSupervisor() {
193
297
  // see a live, locally-consumed watcher without asking the cloud registry
194
298
  // (which counts orphans as armed). Removed on terminal exit below — and, if a
195
299
  // hard kill skips that, swept by the SessionStart reaper. adr: adr/monitor-resilience.md
300
+ const monitorPid = monitorPidFromArgv(process.argv.slice(2));
196
301
  if (session)
197
- (0, watcher_registry_1.writeWatcherPidfile)(session, process.pid, ownerPidFromArgv(process.argv.slice(2)));
198
- (0, watcher_registry_1.watcherAuditLog)(`arm session=${session ?? 'tenant'} ppid=${process.ppid} (launcher shell; reaper severs this watcher if ppid exits below a claude.exe)`);
302
+ (0, watcher_registry_1.writeWatcherPidfile)(session, process.pid, ownerPidFromArgv(process.argv.slice(2)), monitorPid);
303
+ (0, watcher_registry_1.watcherAuditLog)(`arm session=${session ?? 'tenant'} ppid=${process.ppid} monitorPid=${monitorPid ?? 'none'} (launcher shell; reaper severs this watcher if ppid exits below a claude.exe)`);
199
304
  // Visibility only: the reaper kills via OS taskkill/tree-kill, which leaves NO
200
305
  // teardown log below. So "an `arm` line with no matching `exit` line" == killed
201
306
  // externally (reaper); an `exit reason=consumer-gone` line == the pipe binding
@@ -211,11 +316,44 @@ async function runSupervisor() {
211
316
  if (typeof heartbeat.unref === 'function')
212
317
  heartbeat.unref();
213
318
  }
319
+ // Monitor-task liveness probe (see MONITOR_PROBE_MS above). The stamp is
320
+ // verified at arm time: a stamp that is ALREADY dead is unusable (wrong pid
321
+ // space, pasted into a non-bash shell, or recycled before we started) — the
322
+ // probe is then disabled rather than trusted, so a bad stamp can NEVER
323
+ // false-kill a live watcher; the pipe probe + reaper still cover it. A stamp
324
+ // that was verified alive and LATER dies is the Monitor task ending: stop
325
+ // everything through the normal terminal teardown.
326
+ let monitorGone = false;
327
+ let monitorProbe = null;
328
+ if (monitorPid) {
329
+ if (!(0, watcher_registry_1.pidAlive)(monitorPid)) {
330
+ (0, watcher_registry_1.watcherAuditLog)(`monitor-pid-unverifiable session=${session ?? 'tenant'} monitorPid=${monitorPid} (dead at arm — probe disabled, falling back to pipe probe + reaper)`);
331
+ }
332
+ else {
333
+ monitorProbe = setInterval(() => {
334
+ if (monitorGone || shutdownRequested)
335
+ return;
336
+ if (!(0, watcher_registry_1.pidAlive)(monitorPid)) {
337
+ monitorGone = true;
338
+ (0, watcher_registry_1.watcherAuditLog)(`monitor-gone session=${session ?? 'tenant'} monitorPid=${monitorPid} (Monitor task died — owner may still be alive; terminal stop, no respawn)`);
339
+ console.error(`${LOG_PREFIX} Monitor task (pid ${monitorPid}) is gone — stopping watcher (no respawn).`);
340
+ forward('SIGTERM');
341
+ }
342
+ }, MONITOR_PROBE_MS);
343
+ if (typeof monitorProbe.unref === 'function')
344
+ monitorProbe.unref();
345
+ }
346
+ }
347
+ // Entry-script mtime at the moment each child is (re)spawned — the rebuild
348
+ // detector's baseline. Null when unstatable (branch disabled, fail-open).
349
+ const entryScript = process.argv[1];
350
+ let spawnedMtime = null;
214
351
  while (!shutdownRequested) {
215
352
  const startedAt = Date.now();
353
+ spawnedMtime = entryMtimeMs(entryScript);
216
354
  let spawnErr = null;
217
355
  try {
218
- currentChild = (0, child_process_1.spawn)(process.execPath, childArgs, {
356
+ currentChild = (0, proc_1.safeSpawn)(process.execPath, childArgs, {
219
357
  env: childEnv,
220
358
  stdio: 'inherit',
221
359
  // detached:false keeps the child in our process group so
@@ -280,6 +418,19 @@ async function runSupervisor() {
280
418
  terminalReason = 'consumer-gone(pipe-broke)';
281
419
  break;
282
420
  }
421
+ // Rebuild settle: if dist/ was swapped under this child (its entry mtime
422
+ // changed since spawn), this death is a rebuild casualty, not a crash. Wait
423
+ // for the build to go quiet, reset the backoff, and respawn fresh — without
424
+ // this, the respawn loads a half-written entry file and the backoff
425
+ // escalates through a wave of bogus "crashes" on every `npm run build`.
426
+ const mtimeNow = entryMtimeMs(entryScript);
427
+ if (mtimeNow !== null && spawnedMtime !== null && mtimeNow !== spawnedMtime) {
428
+ console.error(`${LOG_PREFIX} supervisor: dist updated underneath (rebuild) — waiting for the build to settle, then restarting fresh`);
429
+ (0, watcher_registry_1.watcherAuditLog)(`rebuild-settle session=${session ?? 'tenant'} (entry mtime changed under live child — respawning after quiet period)`);
430
+ await waitForStableMtime(entryScript);
431
+ backoff = SUPERVISOR_BACKOFF_INITIAL_MS;
432
+ continue;
433
+ }
283
434
  if (liveMs >= SUPERVISOR_HEALTHY_RESET_MS)
284
435
  backoff = SUPERVISOR_BACKOFF_INITIAL_MS;
285
436
  const reason = exit.err
@@ -295,7 +446,14 @@ async function runSupervisor() {
295
446
  // exit; respawns `continue`). Stop the heartbeat and fire a best-effort goodbye
296
447
  // so the ghost is pruned instantly instead of waiting out the lease TTL. The
297
448
  // DELETE both closes the live WS in the InboxDO and drops the lease row.
449
+ // A monitor-gone trip is the root cause whenever it fired, regardless of which
450
+ // break path the loop took (the probe routes through forward(), so the loop
451
+ // sees a generic shutdown) — name it in the audit trail.
452
+ if (monitorGone)
453
+ terminalReason = 'monitor-gone(task-dead)';
298
454
  (0, watcher_registry_1.watcherAuditLog)(`exit session=${session ?? 'tenant'} reason=${terminalReason}`);
455
+ if (monitorProbe)
456
+ clearInterval(monitorProbe);
299
457
  if (heartbeat)
300
458
  clearInterval(heartbeat);
301
459
  if (session)
@@ -1 +1 @@
1
- {"version":3,"file":"inbox-watch-supervisor.js","sourceRoot":"","sources":["../../src/commands/inbox-watch-supervisor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qCA0BqC;;;AA0DrC,8DAWC;AA0DD,sCAgKC;AA7RD,iDAAoD;AACpD,+CAAgF;AAChF,yDAAgH;AAEhH,MAAM,UAAU,GAAG,uBAAuB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* 2. Validate key against health endpoint
5
5
  * 3. Update the target platform's native hooks/plugin/config */
6
+ import { type ManagedSection } from './claude-md-patch';
6
7
  interface InitOptions {
7
8
  apiKey?: string;
8
9
  tenantId?: string;
@@ -34,11 +35,14 @@ interface HookEntry {
34
35
  }
35
36
  export declare function applyCodexHooks(config: ClaudeSettings): string[];
36
37
  export declare function applySettings(settings: ClaudeSettings, apiKey: string): string[];
37
- /** Pure CLAUDE.md patcher (no I/O unit-testable). Given current file content,
38
- * returns the patched content, or null if it already carries the current block.
39
- * Replaces a legacy `## Inbox` OR current `## greprag CLI` section IN PLACE,
40
- * stopping at the next heading or the adjacent `<!-- greprag-conventions -->`
41
- * block (managed separately by the /greprag skill) so neither is clobbered.
42
- * Appends the section if none exists. */
43
- export declare function patchClaudeMdContent(src: string): string | null;
38
+ /** The managed-section registry for ~/.claude/CLAUDE.md. Add a spec here to put
39
+ * another greprag-seeded section under the same never-clobber discipline (e.g.
40
+ * the `## Mechanic (resident triage)` block, if init ever templatizes it).
41
+ * adr: adr/init-claudemd-patching.md */
42
+ export declare const GREPRAG_SECTIONS: ManagedSection[];
43
+ /** Back-compat pure shim used by tests + callers: returns the patched content
44
+ * for any WRITE outcome (seed / migrate / upgrade), or null for a no-op
45
+ * (already current) OR a skip (diverged → caller must not write). Skips carry
46
+ * no content by design; use {@link patchManagedSection} for the reason. */
47
+ export declare function patchClaudeMdContent(src: string, section?: ManagedSection): string | null;
44
48
  export {};
@@ -38,6 +38,7 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  };
39
39
  })();
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.GREPRAG_SECTIONS = void 0;
41
42
  exports.runInit = runInit;
42
43
  exports.applyCodexHooks = applyCodexHooks;
43
44
  exports.applySettings = applySettings;
@@ -46,9 +47,10 @@ const fs = __importStar(require("fs"));
46
47
  const path = __importStar(require("path"));
47
48
  const os = __importStar(require("os"));
48
49
  const readline = __importStar(require("readline"));
49
- const child_process_1 = require("child_process");
50
+ const proc_1 = require("../proc");
50
51
  const project_anchor_1 = require("../project-anchor");
51
52
  const codex_1 = require("./codex");
53
+ const claude_md_patch_1 = require("./claude-md-patch");
52
54
  const API_URL = 'https://api.greprag.com';
53
55
  function hasEnvPrefix(prefix) {
54
56
  return Object.keys(process.env).some(k => k.startsWith(prefix));
@@ -1391,12 +1393,29 @@ function dedupeCodexHooks(hooks) {
1391
1393
  return removed;
1392
1394
  }
1393
1395
  // -- Global CLAUDE.md patch -------------------------------------------------
1394
- /** The canonical greprag CLI section written into ~/.claude/CLAUDE.md. Mirrors the
1395
- * hand-curated block; the command map tracks `greprag --help`. Heading is
1396
- * `## greprag CLI` (NOT the legacy `## Inbox`) patchClaudeMdContent migrates
1397
- * old installs to it. This constant is the CANONICAL copy; a user's
1398
- * ~/.claude/CLAUDE.md section is rendered from it on `greprag init`. */
1399
- const GREPRAG_CLI_SECTION = `## greprag CLI (cross-project memory + async messaging)
1396
+ /** The canonical greprag CLI section body (heading + content). Source of truth
1397
+ * for the SHIPPED default kept in sync with the hand-curated live section so
1398
+ * fresh installs seed the current command map. The command map tracks
1399
+ * `greprag --help`. NOTE: greprag no longer overwrites a hand-maintained copy
1400
+ * of this section on every init (that silently regressed operator curation —
1401
+ * adr/init-claudemd-patching.md); it seeds this on a clean install, migrates
1402
+ * the legacy `## Inbox` heading + pristine pre-markers defaults into a managed
1403
+ * block, and skips (with a warning) anything the operator edited. */
1404
+ const GREPRAG_CLI_BODY = `## greprag CLI (cross-project memory + async messaging)
1405
+ \`/greprag\` walks setup + recall. Command map — \`greprag <cmd> --help\` for flags; reach for \`--help\` before guessing a subcommand:
1406
+ - \`inbox\` — read unread (auto-marks read); \`--peek\` · \`--all\` · \`--session <8hex>\` · \`--project <name>\`. (\`inbox watchers [--json]\` = live sessions you can message, each \`project · title · 8hex\`; \`inbox watch\` = the auto-armed live SSE listener, runs under **Monitor**)
1407
+ - \`send "md" --to <handle>@greprag.com[/<8hex|project>]\` — bare handle = **cold open** (first contact when you don't know their session — lands on their front desk for a manual check, no live ping); \`/<8hex>\` = a specific session; \`/<project>\` needs \`--broadcast\`. Discord DM: \`--to discord:<snowflake>\`. **This is internal cross-session messaging, NOT email** — it never reaches a real inbox.
1408
+ - \`email send --to <real-addr> --from <handle>@greprag.com --subject "s" (--body "t" | --body-file <f|->)\` — sends a **REAL outbound SMTP email** from your greprag address to any recipient (\`--attach\`/\`--cc\`/\`--bcc\`/\`--html-file\` available). \`email pending\` · \`email pull\` = drain inbound. **Use this — not \`send\` — when the user says "email X".** The \`send\`-vs-\`email send\` collision is the trap: only \`email send\` is actual email.
1409
+ - \`memory search "q"\` · \`memory recap\` (alias \`briefing\`) — search a topic/bug · session catch-up digest; narrative-pyramid tiers \`turns\`·\`hourly\`·\`daily\`·\`weekly\`·\`ships\` (commits/PRs/deploys), each \`--last N\` · \`--from/--to ISO\` · \`--project\`
1410
+ - \`corpus upload <file|url> --raw|--enriched [--index]\` · \`corpus search "q" --all\` — ingest + search arbitrary text (books, codebases, refs); \`--raw\` lexical, \`--enriched\` adds LLM vocab bridge; \`--index\` = a multi-doc "index, no bundle" source (llms.txt/sitemap) → one library store, members refreshed cheap-signal-only (ETag→lastmod→content-length, no full-read floor)
1411
+ - \`fix log "field obs"\` · \`fix search|repair\` · \`checkpoint save "5+ word title"\` — log a friction fix for /mechanic to digest · search/repair the fix queue · bookmark a session window (\`greprag lore\` was removed in v5.39.0)
1412
+ - \`status\` · \`doctor\` — install/auth/hooks state · repair orphan project_id + identity drift
1413
+ Hard rule: AI never auto-acts on a brief — summarize + confirm.`;
1414
+ /** The previous SHIPPED default (v5.39.x and earlier, pre-markers, unmarked).
1415
+ * An on-disk unmarked section whose body equals this is a pristine greprag
1416
+ * install the operator never touched — safe to migrate into a managed block.
1417
+ * Anything else unmarked is operator-curated and must NOT be clobbered. */
1418
+ const GREPRAG_CLI_BODY_V1 = `## greprag CLI (cross-project memory + async messaging)
1400
1419
  \`/greprag\` walks setup + recall. Command map — \`greprag <cmd> --help\` for flags; reach for \`--help\` before guessing a subcommand:
1401
1420
  - \`inbox\` — read unread (auto-marks read); \`--peek\` · \`--all\` · \`--session <8hex>\` · \`--project <name>\`. (\`inbox watchers [--json]\` = live sessions you can message, each \`project · title · 8hex\`; \`inbox watch\` = the auto-armed live SSE listener, runs under **Monitor**)
1402
1421
  - \`send "md" --to <handle>@greprag.com[/<8hex>]\` — message a session (\`/<8hex>\`) or cold-open a front desk (bare handle); Discord DM: \`--to discord:<snowflake>\`
@@ -1405,35 +1424,52 @@ const GREPRAG_CLI_SECTION = `## greprag CLI (cross-project memory + async messag
1405
1424
  - \`fix log|search\` · \`checkpoint save "5+ word title"\` — log emergent friction · bookmark a session window
1406
1425
  - \`status\` · \`doctor\` — install/auth/hooks state · repair orphan project_id + identity drift
1407
1426
  Hard rule: AI never auto-acts on a brief — summarize + confirm.`;
1408
- /** Pure CLAUDE.md patcher (no I/O unit-testable). Given current file content,
1409
- * returns the patched content, or null if it already carries the current block.
1410
- * Replaces a legacy `## Inbox` OR current `## greprag CLI` section IN PLACE,
1411
- * stopping at the next heading or the adjacent `<!-- greprag-conventions -->`
1412
- * block (managed separately by the /greprag skill) so neither is clobbered.
1413
- * Appends the section if none exists. */
1414
- function patchClaudeMdContent(src) {
1415
- if (src.includes(GREPRAG_CLI_SECTION))
1416
- return null; // already current
1417
- // Match either heading; stop at the next block boundary (## / # heading or an
1418
- // HTML-comment marker) so the conventions block + following sections survive.
1419
- const sectionRe = /## (?:Inbox \(cross-project async messaging\)|greprag CLI \(cross-project memory \+ async messaging\))[\s\S]*?(?=\n+(?:## |# |<!--)|\s*$)/;
1420
- if (sectionRe.test(src))
1421
- return src.replace(sectionRe, GREPRAG_CLI_SECTION);
1422
- return src.trimEnd() + '\n\n' + GREPRAG_CLI_SECTION + '\n';
1427
+ /** The managed-section registry for ~/.claude/CLAUDE.md. Add a spec here to put
1428
+ * another greprag-seeded section under the same never-clobber discipline (e.g.
1429
+ * the `## Mechanic (resident triage)` block, if init ever templatizes it).
1430
+ * adr: adr/init-claudemd-patching.md */
1431
+ exports.GREPRAG_SECTIONS = [
1432
+ {
1433
+ id: 'greprag-cli',
1434
+ version: 2,
1435
+ body: GREPRAG_CLI_BODY,
1436
+ pristineBodies: [GREPRAG_CLI_BODY_V1],
1437
+ ownedLegacyHeadingRe: /^## Inbox \(cross-project async messaging\)/,
1438
+ currentHeadingRe: /^## greprag CLI \(cross-project memory \+ async messaging\)/,
1439
+ },
1440
+ ];
1441
+ /** Back-compat pure shim used by tests + callers: returns the patched content
1442
+ * for any WRITE outcome (seed / migrate / upgrade), or null for a no-op
1443
+ * (already current) OR a skip (diverged → caller must not write). Skips carry
1444
+ * no content by design; use {@link patchManagedSection} for the reason. */
1445
+ function patchClaudeMdContent(src, section = exports.GREPRAG_SECTIONS[0]) {
1446
+ const outcome = (0, claude_md_patch_1.patchManagedSection)(src, section);
1447
+ return 'content' in outcome ? outcome.content : null;
1423
1448
  }
1424
- /** Idempotently write the greprag CLI section into ~/.claude/CLAUDE.md (migrating
1425
- * the legacy `## Inbox` section in place). Returns true if a change was written,
1426
- * false if already current or the file is absent. */
1449
+ /** Idempotently apply every managed section to ~/.claude/CLAUDE.md. Seeds /
1450
+ * migrates / upgrades pristine greprag content; NEVER overwrites a section the
1451
+ * operator hand-edited it prints a one-line note instead. Returns true if any
1452
+ * change was written. adr: adr/init-claudemd-patching.md */
1427
1453
  function patchGlobalClaudeMd() {
1428
1454
  const claudeMdPath = path.join(os.homedir(), '.claude', 'CLAUDE.md');
1429
1455
  if (!fs.existsSync(claudeMdPath))
1430
1456
  return false;
1431
- const src = fs.readFileSync(claudeMdPath, 'utf-8');
1432
- const next = patchClaudeMdContent(src);
1433
- if (next === null)
1434
- return false;
1435
- fs.writeFileSync(claudeMdPath, next, 'utf-8');
1436
- return true;
1457
+ let src = fs.readFileSync(claudeMdPath, 'utf-8');
1458
+ let changed = false;
1459
+ for (const section of exports.GREPRAG_SECTIONS) {
1460
+ const outcome = (0, claude_md_patch_1.patchManagedSection)(src, section);
1461
+ if (outcome.action === 'skip') {
1462
+ console.log(` ${outcome.reason}`);
1463
+ continue;
1464
+ }
1465
+ if ('content' in outcome) {
1466
+ src = outcome.content;
1467
+ changed = true;
1468
+ }
1469
+ }
1470
+ if (changed)
1471
+ fs.writeFileSync(claudeMdPath, src, 'utf-8');
1472
+ return changed;
1437
1473
  }
1438
1474
  // -- Anchor trackability ----------------------------------------------------
1439
1475
  /** When a repo gitignores `.greprag/`, the anchor file we just wrote won't
@@ -1453,7 +1489,7 @@ function patchGlobalClaudeMd() {
1453
1489
  function ensureAnchorTrackable(projectRoot) {
1454
1490
  // Not in a git repo? Nothing to do — the anchor is local-only by definition.
1455
1491
  try {
1456
- (0, child_process_1.execSync)('git rev-parse --git-dir', { cwd: projectRoot, stdio: 'pipe' });
1492
+ (0, proc_1.safeExecSync)('git rev-parse --git-dir', { cwd: projectRoot, stdio: 'pipe' });
1457
1493
  }
1458
1494
  catch {
1459
1495
  return null;
@@ -1462,7 +1498,7 @@ function ensureAnchorTrackable(projectRoot) {
1462
1498
  // 1 when not ignored. Either non-zero exit means "no work to do."
1463
1499
  let checkOutput;
1464
1500
  try {
1465
- checkOutput = (0, child_process_1.execSync)('git check-ignore -v .greprag/project.json', {
1501
+ checkOutput = (0, proc_1.safeExecSync)('git check-ignore -v .greprag/project.json', {
1466
1502
  cwd: projectRoot,
1467
1503
  encoding: 'utf-8',
1468
1504
  stdio: ['pipe', 'pipe', 'pipe'],