@kawacode/mcp 6.1.2 → 6.6.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 (69) hide show
  1. package/CLAUDE.md.example +2 -0
  2. package/build/index.js +16 -1
  3. package/build/index.js.map +1 -1
  4. package/build/kawacode-on-pre-edit.d.ts +5 -0
  5. package/build/kawacode-on-pre-edit.js +45 -6
  6. package/build/kawacode-on-pre-edit.js.map +1 -1
  7. package/build/kawacode-on-stop.d.ts +49 -23
  8. package/build/kawacode-on-stop.js +233 -38
  9. package/build/kawacode-on-stop.js.map +1 -1
  10. package/build/services/muninn-ipc.d.ts +19 -1
  11. package/build/services/muninn-ipc.js +20 -2
  12. package/build/services/muninn-ipc.js.map +1 -1
  13. package/build/stop/uncompleted-commit.d.ts +45 -0
  14. package/build/stop/uncompleted-commit.js +117 -0
  15. package/build/stop/uncompleted-commit.js.map +1 -0
  16. package/build/stop/uncompleted-commit.test.d.ts +1 -0
  17. package/build/stop/uncompleted-commit.test.js +105 -0
  18. package/build/stop/uncompleted-commit.test.js.map +1 -0
  19. package/build/tools/activate-intent.d.ts +1 -14
  20. package/build/tools/activate-intent.js +17 -56
  21. package/build/tools/activate-intent.js.map +1 -1
  22. package/build/tools/arbiter-apply.d.ts +132 -0
  23. package/build/tools/arbiter-apply.js +59 -0
  24. package/build/tools/arbiter-apply.js.map +1 -0
  25. package/build/tools/arbiter-resolve.d.ts +132 -0
  26. package/build/tools/arbiter-resolve.js +58 -0
  27. package/build/tools/arbiter-resolve.js.map +1 -0
  28. package/build/tools/check-active-intent.d.ts +21 -12
  29. package/build/tools/check-active-intent.js +26 -13
  30. package/build/tools/check-active-intent.js.map +1 -1
  31. package/build/tools/complete-intent.d.ts +29 -0
  32. package/build/tools/complete-intent.js +26 -28
  33. package/build/tools/complete-intent.js.map +1 -1
  34. package/build/tools/create-intent.d.ts +1 -21
  35. package/build/tools/create-intent.js +18 -106
  36. package/build/tools/create-intent.js.map +1 -1
  37. package/build/tools/get-decision-detail.d.ts +109 -0
  38. package/build/tools/get-decision-detail.js +57 -0
  39. package/build/tools/get-decision-detail.js.map +1 -0
  40. package/build/tools/get-project-decisions.d.ts +0 -4
  41. package/build/tools/get-project-decisions.js +4 -6
  42. package/build/tools/get-project-decisions.js.map +1 -1
  43. package/build/tools/get-relevant-context.d.ts +0 -1
  44. package/build/tools/get-relevant-context.js +4 -2
  45. package/build/tools/get-relevant-context.js.map +1 -1
  46. package/build/tools/get-resolution-context.d.ts +154 -0
  47. package/build/tools/get-resolution-context.js +78 -0
  48. package/build/tools/get-resolution-context.js.map +1 -0
  49. package/build/tools/get-session-decisions.d.ts +0 -5
  50. package/build/tools/get-session-decisions.js +5 -5
  51. package/build/tools/get-session-decisions.js.map +1 -1
  52. package/build/tools/index.d.ts +225 -7
  53. package/build/tools/index.js +18 -3
  54. package/build/tools/index.js.map +1 -1
  55. package/build/tools/infer-history.d.ts +16 -0
  56. package/build/tools/infer-history.js +27 -0
  57. package/build/tools/infer-history.js.map +1 -1
  58. package/build/tools/list-team-intents.d.ts +6 -6
  59. package/build/tools/list-team-intents.js +21 -32
  60. package/build/tools/list-team-intents.js.map +1 -1
  61. package/build/tools/pre-edit-decision-check.js +2 -0
  62. package/build/tools/pre-edit-decision-check.js.map +1 -1
  63. package/build/tools/record-decision.d.ts +76 -0
  64. package/build/tools/record-decision.js +10 -0
  65. package/build/tools/record-decision.js.map +1 -1
  66. package/build/tools/update-features.d.ts +31 -0
  67. package/build/tools/update-features.js +51 -0
  68. package/build/tools/update-features.js.map +1 -0
  69. package/package.json +2 -2
package/CLAUDE.md.example CHANGED
@@ -9,6 +9,8 @@ Guidance for Claude Code when working in this repository.
9
9
 
10
10
  ## Workflow — run on every non-trivial turn
11
11
 
12
+ > **Recall before you explore — every turn, including questions and investigation.** On a new request in an indexed sub-project, your *first* tool call is `get_relevant_context` (paraphrase the ask + name any files you already know) — **before** the first Read/Grep/Bash/Explore, not after. The common failure this prevents: opening a turn with search and never pulling prior decisions. `check_active_intent` is secondary (only when you may edit).
13
+
12
14
  1. **Check active intent** — `check_active_intent` (kawa-intents MCP). Resume if one exists.
13
15
  2. **Get relevant context** — `get_relevant_context` with a task description. Past decisions and related intents inform the approach.
14
16
  3. **Now** explore code, read files, plan.
package/build/index.js CHANGED
@@ -3,7 +3,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
5
5
  import { connectToMuninn, ensureRepo } from './services/muninn-ipc.js';
6
- import { allTools, getRelevantContext, checkActiveIntent, createAndActivateIntent, activateIntent, getIntentsForFile, getIntentsForLines, listTeamIntents, getIntentChanges, completeIntent, updateIntent, logWork, recordDecision, getSessionDecisions, getProjectDecisions, editSessionDecision, detectIntentConflicts, inferHistory, evolveDecisions, preEditDecisionCheck, preEditAcknowledge } from './tools/index.js';
6
+ import { allTools, getRelevantContext, checkActiveIntent, createAndActivateIntent, activateIntent, getIntentsForFile, getIntentsForLines, listTeamIntents, getIntentChanges, completeIntent, updateIntent, logWork, recordDecision, getSessionDecisions, getProjectDecisions, getDecisionDetail, editSessionDecision, detectIntentConflicts, inferHistory, evolveDecisions, updateFeatures, preEditDecisionCheck, preEditAcknowledge, getResolutionContext, arbiterResolve, arbiterApply } from './tools/index.js';
7
7
  import { prompts } from './prompts/intent-first-workflow.js';
8
8
  import { resources, readActiveIntentResource } from './resources/active-intent.js';
9
9
  // Create MCP server
@@ -91,6 +91,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
91
91
  case 'get_project_decisions':
92
92
  result = await getProjectDecisions(args);
93
93
  break;
94
+ case 'get_decision_detail':
95
+ result = await getDecisionDetail(args);
96
+ break;
94
97
  case 'edit_session_decision':
95
98
  result = await editSessionDecision(args);
96
99
  break;
@@ -103,12 +106,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
103
106
  case 'evolve_decisions':
104
107
  result = await evolveDecisions(args);
105
108
  break;
109
+ case 'update_features':
110
+ result = await updateFeatures(args);
111
+ break;
106
112
  case 'pre_edit_decision_check':
107
113
  result = await preEditDecisionCheck(args);
108
114
  break;
109
115
  case 'pre_edit_acknowledge':
110
116
  result = await preEditAcknowledge(args);
111
117
  break;
118
+ case 'get_resolution_context':
119
+ result = await getResolutionContext(args);
120
+ break;
121
+ case 'arbiter_resolve':
122
+ result = await arbiterResolve(args);
123
+ break;
124
+ case 'arbiter_apply':
125
+ result = await arbiterApply(args);
126
+ break;
112
127
  default:
113
128
  throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
114
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,SAAS,EACT,QAAQ,EACT,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAEtE,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AACzB,OAAO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@@ -18,6 +18,11 @@
18
18
  * - "review" → exit 0 + JSON on stdout (advisory)
19
19
  * - "proceed" / silent → exit 0, no output
20
20
  *
21
+ * This hook carries only the SEMANTIC (decision-tier) signal. The live-HAI
22
+ * code-collision signal was relocated off this per-edit path to a once-per-turn
23
+ * check in kawacode-on-stop (COLLISION_SURFACE_RELOCATION.md) — pre-edit no
24
+ * longer queries or surfaces collisions.
25
+ *
21
26
  * Failure discipline: every error path exits 0. Hook must not block
22
27
  * Claude Code's turn loop on infra issues. (Same fail-soft carve-out
23
28
  * as kawacode-on-stop — see that file's header for the rule.)
@@ -18,6 +18,11 @@
18
18
  * - "review" → exit 0 + JSON on stdout (advisory)
19
19
  * - "proceed" / silent → exit 0, no output
20
20
  *
21
+ * This hook carries only the SEMANTIC (decision-tier) signal. The live-HAI
22
+ * code-collision signal was relocated off this per-edit path to a once-per-turn
23
+ * check in kawacode-on-stop (COLLISION_SURFACE_RELOCATION.md) — pre-edit no
24
+ * longer queries or surfaces collisions.
25
+ *
21
26
  * Failure discipline: every error path exits 0. Hook must not block
22
27
  * Claude Code's turn loop on infra issues. (Same fail-soft carve-out
23
28
  * as kawacode-on-stop — see that file's header for the rule.)
@@ -95,19 +100,53 @@ function resolveTarget(payload) {
95
100
  }
96
101
  return null;
97
102
  }
103
+ // Payload economy for the one inline-rationale surface (INTENT_INTELLIGENCE.md §5.8).
104
+ // This block is injected into the agent transcript and is append-only — it
105
+ // re-sends every turn until compaction — so per-fire size is first-class.
106
+ // - RATIONALE_CHARS: each rationale is truncated to this, with a never-silent
107
+ // marker that doubles as the expand pointer (amount cut + get_decision_detail).
108
+ // - MAX_BLOCK_TOKENS: a per-fire budget; once exceeded, remaining decisions are
109
+ // dropped with an explicit "N more suppressed" line (never a silent cap).
110
+ const RATIONALE_CHARS = 280;
111
+ const MAX_BLOCK_TOKENS = 600;
112
+ const CHARS_PER_TOKEN = 4; // coarse char→token approximation; deterministic, no tokenizer dep
113
+ const MAX_BLOCK_CHARS = MAX_BLOCK_TOKENS * CHARS_PER_TOKEN;
114
+ function truncateRationale(d) {
115
+ const r = d.rationale ?? '';
116
+ if (r.length <= RATIONALE_CHARS)
117
+ return r;
118
+ const head = r.slice(0, RATIONALE_CHARS).trimEnd();
119
+ const cut = r.length - head.length;
120
+ return `${head}… ⟨+${cut} chars · get_decision_detail("${d.decisionId}")⟩`;
121
+ }
98
122
  function formatBlockMessage(target, res) {
99
123
  const lines = [];
100
124
  const symbol = res.enclosingSymbol?.name ? ` (in ${res.enclosingSymbol.name})` : '';
101
125
  lines.push(`Pre-edit decision check: prior reasoning is attached to ${target.filePath}:${target.startLine}-${target.endLine}${symbol}.`);
102
- for (const d of res.decisions ?? []) {
103
- lines.push(` • [${d.type}] ${d.summary ?? ''}`);
104
- if (d.rationale)
105
- lines.push(` ${d.rationale}`);
126
+ const decisions = res.decisions ?? [];
127
+ let usedChars = 0;
128
+ let shown = 0;
129
+ for (const d of decisions) {
130
+ const entry = [` • [${d.type}] ${d.summary ?? ''}`];
131
+ const rationale = truncateRationale(d);
132
+ if (rationale)
133
+ entry.push(` ${rationale}`);
134
+ const entryChars = entry.join('\n').length;
135
+ // Always show at least one decision, even if it alone exceeds the budget.
136
+ if (shown > 0 && usedChars + entryChars > MAX_BLOCK_CHARS) {
137
+ const remaining = decisions.length - shown;
138
+ lines.push(` … ${remaining} more decision${remaining === 1 ? '' : 's'} suppressed (per-fire budget) — call get_decision_detail(decisionId) to inspect.`);
139
+ break;
140
+ }
141
+ lines.push(...entry);
142
+ usedChars += entryChars;
143
+ shown += 1;
106
144
  }
107
145
  lines.push('');
108
146
  lines.push('Override options:');
109
- lines.push(' 1) record_decision(type:"fork", supersedes:[<id>], rationale:"...") then retry the Edit.');
110
- lines.push(' 2) Add `force: true` to the Edit args as a one-off escape hatch (acks the surfaced decisions for this session).');
147
+ lines.push(' 1) record_decision(type:"fork", supersedes:[<id>], rationale:"...") then retry the Edit — persistent (records lineage across sessions).');
148
+ const ackIds = decisions.map(d => `"${d.decisionId}"`).join(', ');
149
+ lines.push(` 2) pre_edit_acknowledge({ decisionIds: [${ackIds}] }) to override for THIS session, then retry the Edit.`);
111
150
  return lines.join('\n');
112
151
  }
113
152
  async function main() {
@@ -1 +1 @@
1
- {"version":3,"file":"kawacode-on-pre-edit.js","sourceRoot":"","sources":["../src/kawacode-on-pre-edit.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAyCzD,SAAS,SAAS;IAChB,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,MAAc;IACvD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACpC,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAExB,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,SAAS,IAAI,CAAC,CAAA;IACnD,CAAC;IACD,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,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 -2,32 +2,58 @@
2
2
  /**
3
3
  * kawacode-on-stop — Claude Code Stop hook dispatcher.
4
4
  *
5
- * Reads the Stop hook payload from stdin (session_id, transcript_path, cwd)
6
- * and sends two short IPCs to Muninn:
5
+ * Fires three independent, fail-soft jobs at the end of every turn:
7
6
  *
8
- * 1. capture-thoughts:capture { sessionId, transcriptPath, cwd }
9
- * → Muninn reads the transcript, extracts the assistant's text
10
- * content blocks (the model's visible responses), and appends them
11
- * as JSONL to ~/.kawa-code/thoughts/active/session-{id}.jsonl.
12
- * Thinking blocks are deliberately ignored — Claude Code redacts
13
- * their plaintext on disk, so they carry no recoverable signal.
14
- * 2. extractor:trigger { session_id, cwd }
15
- * → Muninn wakes the (debounced) extractor service which reads the
16
- * fresh JSONL and emits ephemeral decisions verbalized in the
17
- * assistant's responses.
7
+ * 1. Thought capture (opt out: KAWA_THOUGHT_CAPTURE=off) — two IPCs to Muninn:
8
+ * a. capture-thoughts:capture { sessionId, transcriptPath, cwd }
9
+ * → Muninn reads the transcript, extracts the assistant's text
10
+ * content blocks (the model's visible responses), and appends them
11
+ * as JSONL to ~/.kawa-code/thoughts/active/session-{id}.jsonl.
12
+ * Thinking blocks are deliberately ignored — Claude Code redacts
13
+ * their plaintext on disk, so they carry no recoverable signal.
14
+ * b. extractor:trigger { session_id, cwd }
15
+ * → Muninn wakes the (debounced) extractor service which reads the
16
+ * fresh JSONL and emits ephemeral decisions verbalized in the
17
+ * assistant's responses.
18
18
  *
19
- * Replaces the legacy kawacode-capture-thoughts (Node CLI that did the file
20
- * I/O itself, never merged to main) AND kawacode-extract-trigger (separate
21
- * Node CLI that did the second IPC). The whole capture pipeline now lives
22
- * in Muninn — this dispatcher's only job is to fire the two pings.
19
+ * 2. Live-HAI collision report (opt out: KAWA_STOP_COLLISION_CHECK=off) — ONE
20
+ * IPC, stop-collision:check { repoOrigin, repoPath } (_agentId auto-stamped).
21
+ * Muninn recomputes the turn's working-tree diff and runs the transient
22
+ * /repos/collisions read once per changed file (no publish), returning the
23
+ * peers grouped by HAI plus the per-repo advisory|block mode. This is the
24
+ * once-per-turn relocation of the old per-edit Tier-2 collision check
25
+ * (COLLISION_SURFACE_RELOCATION.md). When peers overlap this turn's work:
26
+ * - advisory (default): inject the report via additionalContext (model-
27
+ * only context; the agent self-judges whether to coordinate/rework/
28
+ * surface to the user).
29
+ * - block (per-repo setting): emit { decision:"block", reason } so the
30
+ * turn stays open until the agent addresses it — but only when
31
+ * stop_hook_active is not already set, so we never loop the block.
23
32
  *
24
- * Failure discipline: every error path exits 0. Claude Code's Stop hook
25
- * must never block the turn loop on capture failure. This is the ONLY
26
- * place fail-soft is allowed under the no-Muninn-independence rule —
27
- * because the hook script is the boundary between the harness (which
28
- * can't recover) and Muninn (which can re-derive missing captures from
29
- * the transcript on the next Stop).
33
+ * 3. complete_intent hard gate (opt out: KAWA_COMPLETE_GATE=off) — blocks the
34
+ * turn when the agent ran `git commit` under an active intent but never
35
+ * finalized it with complete_intent, so distillation + code-block
36
+ * auto-capture aren't silently skipped. Detection is pure Claude Code
37
+ * transcript introspection (the hook's job, not Muninn's): scan for the
38
+ * last CONFIRMED `git commit` vs the last complete_intent tool_use. A
39
+ * commit is confirmed only when its command invokes git commit AND its
40
+ * tool_result carries git's `[<ref> <shorthash>]` success line — so a
41
+ * command that merely mentions "git commit" as data (printf/heredoc) is
42
+ * not misread as a commit. Gate only when a commit lands AFTER the most
43
+ * recent complete_intent call (or with none after it) — a failed/attempted
44
+ * complete_intent still counts as "tried", so conflict-resolution turns
45
+ * are not nagged. Then confirm via intent:get-active that THIS session
46
+ * still has an open current intent (supplies its id/title). Output mirrors
47
+ * job 2: { decision:"block", reason } guarded by !stop_hook_active; once a
48
+ * block has fired it degrades to additionalContext (block once, then
49
+ * advise — never loop). Takes precedence over the collision report on the
50
+ * turn it fires (finalizing the intent matters more; collisions re-surface
51
+ * next turn).
30
52
  *
31
- * Opt out with KAWA_THOUGHT_CAPTURE=off.
53
+ * Failure discipline: every error path exits 0. Claude Code's Stop hook must
54
+ * never block the turn loop on capture/collision failure or Muninn being down.
55
+ * This is the ONLY place fail-soft is allowed under the no-Muninn-independence
56
+ * rule — the hook is the boundary between the harness (which can't recover) and
57
+ * Muninn (which re-derives missing state on the next Stop / at complete_intent).
32
58
  */
33
59
  export {};
@@ -2,36 +2,65 @@
2
2
  /**
3
3
  * kawacode-on-stop — Claude Code Stop hook dispatcher.
4
4
  *
5
- * Reads the Stop hook payload from stdin (session_id, transcript_path, cwd)
6
- * and sends two short IPCs to Muninn:
5
+ * Fires three independent, fail-soft jobs at the end of every turn:
7
6
  *
8
- * 1. capture-thoughts:capture { sessionId, transcriptPath, cwd }
9
- * → Muninn reads the transcript, extracts the assistant's text
10
- * content blocks (the model's visible responses), and appends them
11
- * as JSONL to ~/.kawa-code/thoughts/active/session-{id}.jsonl.
12
- * Thinking blocks are deliberately ignored — Claude Code redacts
13
- * their plaintext on disk, so they carry no recoverable signal.
14
- * 2. extractor:trigger { session_id, cwd }
15
- * → Muninn wakes the (debounced) extractor service which reads the
16
- * fresh JSONL and emits ephemeral decisions verbalized in the
17
- * assistant's responses.
7
+ * 1. Thought capture (opt out: KAWA_THOUGHT_CAPTURE=off) — two IPCs to Muninn:
8
+ * a. capture-thoughts:capture { sessionId, transcriptPath, cwd }
9
+ * → Muninn reads the transcript, extracts the assistant's text
10
+ * content blocks (the model's visible responses), and appends them
11
+ * as JSONL to ~/.kawa-code/thoughts/active/session-{id}.jsonl.
12
+ * Thinking blocks are deliberately ignored — Claude Code redacts
13
+ * their plaintext on disk, so they carry no recoverable signal.
14
+ * b. extractor:trigger { session_id, cwd }
15
+ * → Muninn wakes the (debounced) extractor service which reads the
16
+ * fresh JSONL and emits ephemeral decisions verbalized in the
17
+ * assistant's responses.
18
18
  *
19
- * Replaces the legacy kawacode-capture-thoughts (Node CLI that did the file
20
- * I/O itself, never merged to main) AND kawacode-extract-trigger (separate
21
- * Node CLI that did the second IPC). The whole capture pipeline now lives
22
- * in Muninn — this dispatcher's only job is to fire the two pings.
19
+ * 2. Live-HAI collision report (opt out: KAWA_STOP_COLLISION_CHECK=off) — ONE
20
+ * IPC, stop-collision:check { repoOrigin, repoPath } (_agentId auto-stamped).
21
+ * Muninn recomputes the turn's working-tree diff and runs the transient
22
+ * /repos/collisions read once per changed file (no publish), returning the
23
+ * peers grouped by HAI plus the per-repo advisory|block mode. This is the
24
+ * once-per-turn relocation of the old per-edit Tier-2 collision check
25
+ * (COLLISION_SURFACE_RELOCATION.md). When peers overlap this turn's work:
26
+ * - advisory (default): inject the report via additionalContext (model-
27
+ * only context; the agent self-judges whether to coordinate/rework/
28
+ * surface to the user).
29
+ * - block (per-repo setting): emit { decision:"block", reason } so the
30
+ * turn stays open until the agent addresses it — but only when
31
+ * stop_hook_active is not already set, so we never loop the block.
23
32
  *
24
- * Failure discipline: every error path exits 0. Claude Code's Stop hook
25
- * must never block the turn loop on capture failure. This is the ONLY
26
- * place fail-soft is allowed under the no-Muninn-independence rule —
27
- * because the hook script is the boundary between the harness (which
28
- * can't recover) and Muninn (which can re-derive missing captures from
29
- * the transcript on the next Stop).
33
+ * 3. complete_intent hard gate (opt out: KAWA_COMPLETE_GATE=off) — blocks the
34
+ * turn when the agent ran `git commit` under an active intent but never
35
+ * finalized it with complete_intent, so distillation + code-block
36
+ * auto-capture aren't silently skipped. Detection is pure Claude Code
37
+ * transcript introspection (the hook's job, not Muninn's): scan for the
38
+ * last CONFIRMED `git commit` vs the last complete_intent tool_use. A
39
+ * commit is confirmed only when its command invokes git commit AND its
40
+ * tool_result carries git's `[<ref> <shorthash>]` success line — so a
41
+ * command that merely mentions "git commit" as data (printf/heredoc) is
42
+ * not misread as a commit. Gate only when a commit lands AFTER the most
43
+ * recent complete_intent call (or with none after it) — a failed/attempted
44
+ * complete_intent still counts as "tried", so conflict-resolution turns
45
+ * are not nagged. Then confirm via intent:get-active that THIS session
46
+ * still has an open current intent (supplies its id/title). Output mirrors
47
+ * job 2: { decision:"block", reason } guarded by !stop_hook_active; once a
48
+ * block has fired it degrades to additionalContext (block once, then
49
+ * advise — never loop). Takes precedence over the collision report on the
50
+ * turn it fires (finalizing the intent matters more; collisions re-surface
51
+ * next turn).
30
52
  *
31
- * Opt out with KAWA_THOUGHT_CAPTURE=off.
53
+ * Failure discipline: every error path exits 0. Claude Code's Stop hook must
54
+ * never block the turn loop on capture/collision failure or Muninn being down.
55
+ * This is the ONLY place fail-soft is allowed under the no-Muninn-independence
56
+ * rule — the hook is the boundary between the harness (which can't recover) and
57
+ * Muninn (which re-derives missing state on the next Stop / at complete_intent).
32
58
  */
33
59
  import { readFileSync } from 'node:fs';
60
+ import { execSync } from 'node:child_process';
34
61
  import { connectToMuninn, request, disconnect } from './services/muninn-ipc.js';
62
+ import { resolveOrigin } from './tools/resolve-origin.js';
63
+ import { detectUncompletedCommit } from './stop/uncompleted-commit.js';
35
64
  function readStdin() {
36
65
  try {
37
66
  return readFileSync(0, 'utf8');
@@ -40,10 +69,155 @@ function readStdin() {
40
69
  return '';
41
70
  }
42
71
  }
72
+ /** Render one HAI's overlapping files as `path:1-3,7` (single-line ranges
73
+ * collapse to a single number). */
74
+ function formatFiles(files) {
75
+ return files
76
+ .map(f => {
77
+ const ranges = f.ranges
78
+ .map(r => (r[0] === r[1] ? `${r[0]}` : `${r[0]}-${r[1]}`))
79
+ .join(',');
80
+ return `${f.fpath}:${ranges}`;
81
+ })
82
+ .join('; ');
83
+ }
84
+ /** Lean report (payload economy — injected into the append-only transcript):
85
+ * a header plus one bullet per overlapping HAI. The guidance tail is added by
86
+ * the caller per advisory/block mode. */
87
+ function formatCollisionReport(collisions) {
88
+ const lines = [
89
+ `Live-edit collision check: ${collisions.length} collaborator(s) have in-progress edits overlapping your changes this turn.`,
90
+ ];
91
+ for (const c of collisions) {
92
+ const tag = c.isAgent ? ' (agent)' : '';
93
+ lines.push(` • ${c.label || c.uid}${tag} — ${formatFiles(c.files)}`);
94
+ }
95
+ return lines.join('\n');
96
+ }
97
+ /** Run the once-per-turn collision check. Returns the hook-protocol JSON string
98
+ * to print (advisory additionalContext or a block-to-continue), or null when
99
+ * there's nothing to surface / on any failure (fail-soft). */
100
+ async function runCollisionCheck(payload) {
101
+ if (process.env.KAWA_STOP_COLLISION_CHECK === 'off')
102
+ return null;
103
+ const cwd = payload.cwd;
104
+ if (!cwd)
105
+ return null;
106
+ let repoOrigin;
107
+ try {
108
+ repoOrigin = resolveOrigin(undefined, cwd);
109
+ }
110
+ catch {
111
+ return null; // not a git repo / git unavailable — skip
112
+ }
113
+ let res;
114
+ try {
115
+ res = await request('stop-collision', 'check', { repoOrigin, repoPath: cwd });
116
+ }
117
+ catch {
118
+ return null; // Muninn error/timeout — fail open, no report, no block
119
+ }
120
+ const collisions = res?.collisions ?? [];
121
+ if (collisions.length === 0)
122
+ return null;
123
+ const report = formatCollisionReport(collisions);
124
+ // Block-to-continue only when the per-repo setting is on AND we're not already
125
+ // inside a prior block (else the turn can never end).
126
+ if (res?.mode === 'block' && payload.stop_hook_active !== true) {
127
+ return JSON.stringify({
128
+ decision: 'block',
129
+ reason: `${report}\n\nResolve this before ending the turn: coordinate, rework, or surface it to the user.`,
130
+ });
131
+ }
132
+ // Advisory (the default; also where block degrades when stop_hook_active).
133
+ return JSON.stringify({
134
+ hookSpecificOutput: {
135
+ hookEventName: 'Stop',
136
+ additionalContext: `${report}\n\nThis is advisory — decide whether to coordinate, rework, or surface it to the user before committing.`,
137
+ },
138
+ });
139
+ }
140
+ // ===== Job 3: complete_intent hard gate =====
141
+ /** Read the transcript file and detect an uncompleted commit (fail-soft → false). */
142
+ function scanTranscriptForUncompletedCommit(transcriptPath) {
143
+ let raw;
144
+ try {
145
+ raw = readFileSync(transcriptPath, 'utf8');
146
+ }
147
+ catch {
148
+ return false;
149
+ }
150
+ return detectUncompletedCommit(raw);
151
+ }
152
+ /** Current HEAD sha for `cwd`, or null if unavailable. */
153
+ function gitHeadSha(cwd) {
154
+ try {
155
+ return execSync('git rev-parse HEAD', { cwd, encoding: 'utf8', timeout: 5000, windowsHide: true }).trim();
156
+ }
157
+ catch {
158
+ return null;
159
+ }
160
+ }
161
+ /**
162
+ * The complete_intent hard gate. Returns the hook-protocol JSON to print
163
+ * (a block, or a degraded advisory), or null when there's nothing to gate /
164
+ * on any failure (fail-soft). Mirrors runCollisionCheck's output protocol.
165
+ */
166
+ async function runCompleteGate(payload) {
167
+ if (process.env.KAWA_COMPLETE_GATE === 'off')
168
+ return null;
169
+ const cwd = payload.cwd;
170
+ const transcriptPath = payload.transcript_path;
171
+ if (!cwd || !transcriptPath)
172
+ return null;
173
+ // Cheap, IPC-free evidence first: did the agent commit without completing?
174
+ if (!scanTranscriptForUncompletedCommit(transcriptPath))
175
+ return null;
176
+ let repoOrigin;
177
+ try {
178
+ repoOrigin = resolveOrigin(undefined, cwd);
179
+ }
180
+ catch {
181
+ return null; // not a git repo / git unavailable — skip
182
+ }
183
+ // Confirm THIS session still has an open current intent (supplies id/title).
184
+ let res;
185
+ try {
186
+ res = await request('intent', 'get-active', { repoOrigin });
187
+ }
188
+ catch {
189
+ return null; // Muninn error/timeout — fail open, no gate
190
+ }
191
+ const intent = res?.intent;
192
+ if (!intent?.id)
193
+ return null; // already finalized (completion clears current) or no intent in play
194
+ if ((intent.status || 'active') !== 'active')
195
+ return null;
196
+ const headSha = gitHeadSha(cwd);
197
+ const shaShort = headSha ? ` (${headSha.slice(0, 8)})` : '';
198
+ const title = intent.title ? `"${intent.title}"` : 'the active intent';
199
+ const call = `complete_intent(intentId="${intent.id}", status="committed"${headSha ? `, commitSha="${headSha}"` : ''})`;
200
+ const reason = `You committed${shaShort} under ${title} but didn't finalize it. Run ${call} so its ` +
201
+ `decisions distill and code blocks are captured. If this commit isn't meant to finalize the ` +
202
+ `intent, complete it with the correct status or surface it to the user.`;
203
+ // Block-to-continue, unless we already blocked once this turn (avoid a loop).
204
+ if (payload.stop_hook_active !== true) {
205
+ return JSON.stringify({ decision: 'block', reason });
206
+ }
207
+ // Degrade to advisory so the turn can end after a single block.
208
+ return JSON.stringify({
209
+ hookSpecificOutput: {
210
+ hookEventName: 'Stop',
211
+ additionalContext: `Reminder — ${reason}`,
212
+ },
213
+ });
214
+ }
43
215
  async function main() {
44
- if (process.env.KAWA_THOUGHT_CAPTURE === 'off') {
216
+ const captureOff = process.env.KAWA_THOUGHT_CAPTURE === 'off';
217
+ const collisionOff = process.env.KAWA_STOP_COLLISION_CHECK === 'off';
218
+ const gateOff = process.env.KAWA_COMPLETE_GATE === 'off';
219
+ if (captureOff && collisionOff && gateOff)
45
220
  process.exit(0);
46
- }
47
221
  const raw = readStdin();
48
222
  if (!raw)
49
223
  process.exit(0);
@@ -57,31 +231,52 @@ async function main() {
57
231
  const sessionId = payload.session_id;
58
232
  const transcriptPath = payload.transcript_path;
59
233
  const cwd = payload.cwd;
60
- if (!sessionId || !transcriptPath)
61
- process.exit(0);
62
234
  try {
63
235
  await connectToMuninn();
64
236
  }
65
237
  catch {
66
- // Muninn down. Capture happens whenever Muninn is next up — the
67
- // extractor's checkpoint advances on the next successful capture.
238
+ // Muninn down. Capture happens whenever Muninn is next up (the extractor's
239
+ // checkpoint advances on the next successful capture); collision detection
240
+ // simply yields no report this turn.
68
241
  process.exit(0);
69
242
  }
70
- // Fire both IPCs in parallel; each is independent and tolerant of the
71
- // other's failure. allSettled because we never want one to short-circuit
72
- // the other on transient failure.
73
- await Promise.allSettled([
74
- request('capture-thoughts', 'capture', {
243
+ // Thought capture (fire-and-forget; each IPC tolerant of the other's failure).
244
+ const captureTasks = [];
245
+ if (!captureOff && sessionId && transcriptPath) {
246
+ captureTasks.push(request('capture-thoughts', 'capture', {
75
247
  sessionId,
76
248
  transcriptPath,
77
249
  cwd: cwd ?? null,
78
- }),
79
- request('extractor', 'trigger', {
250
+ }), request('extractor', 'trigger', {
80
251
  session_id: sessionId,
81
252
  cwd: cwd ?? '',
82
- }),
83
- ]);
253
+ }));
254
+ }
255
+ // Hook-protocol stdout producers, in precedence order. The complete_intent
256
+ // gate wins the turn it fires (finalizing the intent matters more than a
257
+ // collision advisory; collisions re-surface next turn). Only one JSON object
258
+ // may be written, so fall through to the collision report only when the gate
259
+ // produced nothing (the common case).
260
+ let output = null;
261
+ try {
262
+ output = await runCompleteGate(payload);
263
+ }
264
+ catch {
265
+ output = null; // belt-and-suspenders fail-soft
266
+ }
267
+ if (!output) {
268
+ try {
269
+ output = await runCollisionCheck(payload);
270
+ }
271
+ catch {
272
+ output = null;
273
+ }
274
+ }
275
+ if (captureTasks.length > 0)
276
+ await Promise.allSettled(captureTasks);
84
277
  disconnect();
278
+ if (output)
279
+ process.stdout.write(output + '\n');
85
280
  process.exit(0);
86
281
  }
87
282
  main().catch(() => process.exit(0));