@kawacode/mcp 5.0.4 → 5.2.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 (81) hide show
  1. package/CLAUDE.md.example +101 -36
  2. package/README.md +54 -62
  3. package/build/index.js +24 -5
  4. package/build/index.js.map +1 -1
  5. package/build/prompts/intent-first-workflow.js +7 -8
  6. package/build/prompts/intent-first-workflow.js.map +1 -1
  7. package/build/resources/active-intent.js +2 -2
  8. package/build/resources/active-intent.js.map +1 -1
  9. package/build/services/muninn-ipc.d.ts +3 -1
  10. package/build/services/muninn-ipc.js +35 -5
  11. package/build/services/muninn-ipc.js.map +1 -1
  12. package/build/tools/activate-intent.d.ts +40 -0
  13. package/build/tools/activate-intent.js +52 -0
  14. package/build/tools/activate-intent.js.map +1 -0
  15. package/build/tools/check-active-intent.d.ts +0 -1
  16. package/build/tools/check-active-intent.js +3 -4
  17. package/build/tools/check-active-intent.js.map +1 -1
  18. package/build/tools/complete-intent.d.ts +18 -6
  19. package/build/tools/complete-intent.js +31 -2
  20. package/build/tools/complete-intent.js.map +1 -1
  21. package/build/tools/create-intent.d.ts +23 -1
  22. package/build/tools/create-intent.js +58 -5
  23. package/build/tools/create-intent.js.map +1 -1
  24. package/build/tools/detect-intent-conflicts.d.ts +22 -322
  25. package/build/tools/detect-intent-conflicts.js +35 -60
  26. package/build/tools/detect-intent-conflicts.js.map +1 -1
  27. package/build/tools/edit-session-decision.d.ts +4 -4
  28. package/build/tools/evolve-decisions.d.ts +0 -6
  29. package/build/tools/evolve-decisions.js +1 -3
  30. package/build/tools/evolve-decisions.js.map +1 -1
  31. package/build/tools/get-intents-for-file.js +1 -1
  32. package/build/tools/get-intents-for-file.js.map +1 -1
  33. package/build/tools/get-intents-for-lines.js +1 -1
  34. package/build/tools/get-intents-for-lines.js.map +1 -1
  35. package/build/tools/get-project-decisions.d.ts +1 -0
  36. package/build/tools/get-project-decisions.js +3 -2
  37. package/build/tools/get-project-decisions.js.map +1 -1
  38. package/build/tools/get-relevant-context.d.ts +1 -0
  39. package/build/tools/get-relevant-context.js +2 -1
  40. package/build/tools/get-relevant-context.js.map +1 -1
  41. package/build/tools/get-session-decisions.d.ts +2 -0
  42. package/build/tools/get-session-decisions.js +1 -0
  43. package/build/tools/get-session-decisions.js.map +1 -1
  44. package/build/tools/index.d.ts +54 -204
  45. package/build/tools/index.js +3 -3
  46. package/build/tools/index.js.map +1 -1
  47. package/build/tools/infer-history.d.ts +13 -16
  48. package/build/tools/infer-history.js +62 -29
  49. package/build/tools/infer-history.js.map +1 -1
  50. package/build/tools/list-team-intents.d.ts +30 -0
  51. package/build/tools/list-team-intents.js +39 -16
  52. package/build/tools/list-team-intents.js.map +1 -1
  53. package/build/tools/log-work.js +1 -1
  54. package/build/tools/log-work.js.map +1 -1
  55. package/build/tools/record-decision.d.ts +6 -0
  56. package/build/tools/record-decision.js +2 -0
  57. package/build/tools/record-decision.js.map +1 -1
  58. package/build/tools/resolve-origin.js +1 -0
  59. package/build/tools/resolve-origin.js.map +1 -1
  60. package/build/tools/update-intent.d.ts +95 -0
  61. package/build/tools/update-intent.js +94 -0
  62. package/build/tools/update-intent.js.map +1 -0
  63. package/package.json +1 -1
  64. package/build/services/active-intent-store.d.ts +0 -36
  65. package/build/services/active-intent-store.js +0 -45
  66. package/build/services/active-intent-store.js.map +0 -1
  67. package/build/services/kawa-api.d.ts +0 -131
  68. package/build/services/kawa-api.js +0 -239
  69. package/build/services/kawa-api.js.map +0 -1
  70. package/build/services/repo-encryption.d.ts +0 -46
  71. package/build/services/repo-encryption.js +0 -92
  72. package/build/services/repo-encryption.js.map +0 -1
  73. package/build/services/storage-decryption.d.ts +0 -52
  74. package/build/services/storage-decryption.js +0 -162
  75. package/build/services/storage-decryption.js.map +0 -1
  76. package/build/tools/assign-blocks.d.ts +0 -87
  77. package/build/tools/assign-blocks.js +0 -49
  78. package/build/tools/assign-blocks.js.map +0 -1
  79. package/build/tools/get-project-context.d.ts +0 -82
  80. package/build/tools/get-project-context.js +0 -73
  81. package/build/tools/get-project-context.js.map +0 -1
package/CLAUDE.md.example CHANGED
@@ -1,40 +1,100 @@
1
1
  # CLAUDE.md
2
2
 
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
3
+ Guidance for Claude Code when working in this repository.
6
4
 
7
5
  <!-- Replace with a 1-2 sentence description of your project -->
8
6
  [Your project name] is a [brief description of what it does].
9
7
 
10
- ## AI Code Implementation Workflow
8
+ ---
9
+
10
+ ## Workflow — run on every non-trivial turn
11
+
12
+ 1. **Check active intent** — `check_active_intent` (kawa-intents MCP). Resume if one exists.
13
+ 2. **Get relevant context** — `get_relevant_context` with a task description. Past decisions and related intents inform the approach.
14
+ 3. **Now** explore code, read files, plan.
15
+ 4. **Create an intent** when the conversation transitions to actual code changes (see "When to create an intent" below).
16
+ 5. **Before commit** — `record_decision` for significant decisions (see "Recording decisions" below).
17
+ 6. **After commit** — `complete_intent` with the commit SHA and `status: "committed"`. This also triggers auto-capture of code blocks from the diff.
18
+
19
+ Skip the entire workflow for trivial one-liners (typos, obvious bugs) — just make the change.
20
+
21
+ ---
22
+
23
+ ## When to create an intent — vs skip
24
+
25
+ **Create** an intent for:
26
+ - Explicit change requests ("fix this bug", "add feature X", "refactor Y")
27
+ - User-approved proposals you're about to implement
28
+ - Any turn where you will modify files
29
+
30
+ **Skip** the intent workflow for:
31
+ - Questions ("how does X work?", "why was this done this way?")
32
+ - Investigation ("look at the auth flow", "find where X is called")
33
+ - Architecture / design discussion with no concrete action item
34
+ - Trivial pass-through changes (e.g., just forwarding a new field through a helper)
35
+
36
+ For exploration turns, still call `get_relevant_context` to enrich your answer — just don't create an intent.
37
+
38
+ ---
39
+
40
+ ## Intent conflicts
41
+
42
+ `create_and_activate_intent` auto-detects conflicts. When the tool returns `action: "conflict"`:
43
+
44
+ 1. Present each conflict to the user — severity, the conflicting intent's title/author, nature of the overlap.
45
+ 2. Ask: "These conflicts were detected. Should I proceed anyway?"
46
+ 3. On approval, retry `create_and_activate_intent` with `force: true`. Bypassed conflict IDs are recorded for audit.
47
+
48
+ ---
11
49
 
12
- **BEFORE exploring code or reading files** for any non-trivial task, follow these steps in order:
50
+ ## Intent reformulation
13
51
 
14
- 1. **Check active intent**: Call `check_active_intent` (kawa-intents MCP) to see if work is already tracked
15
- 2. **Get relevant context**: Call `get_relevant_context` with a description of the task to find past decisions and related intents that may inform your approach
16
- 3. **Then explore code**: Now read files, search the codebase, and analyze the problem
52
+ Intents are living documents, not upfront contracts. When the work reveals that the original title, description, or scope has drifted, call `update_intent` to fix it. **Do not ask the user for permission** — reformulation is expected. An intent may be updated many times before commit.
17
53
 
18
- For trivial one-line fixes (typos, obvious bugs), skip the above and use `log_work` after completing the change. For everything else — especially bug fixes from issues, multi-file changes, or unfamiliar code — always start with steps 1-2.
54
+ ---
19
55
 
20
- **Recording decisions before commit**: When the user asks to finalize/commit, review the work done in the session and call `record_decision` for each significant decision or lesson *before* creating the commit. Apply a **high bar**: a decision is worth recording only if a future developer (or Claude in a future session) would genuinely benefit from knowing it — i.e., it would change how they approach the same area of code.
56
+ ## Recording decisions — apply a high bar
21
57
 
22
- Record when you:
23
- - Chose between meaningful alternatives (type: `fork`) — e.g., serde alias vs fixing all reconstruction sites
24
- - Discovered non-obvious behavior that will recur or affect future work (type: `discovery`) — e.g., UI progress tracking requires completion events per phase
25
- - Identified a hard constraint that future work must respect (type: `constraint`) — e.g., checkpoint cleanup must wait for persistence
26
- - Made an explicit trade-off with lasting impact (type: `tradeoff`) — e.g., precision vs simplicity in rate limiting
27
- - Tried and rejected an approach that looked reasonable (type: `abandoned`)
28
- - Selected a library or dependency after comparing alternatives (type: `dependency`) — e.g., chose `reqwest` over `hyper` for HTTP
58
+ A decision is worth recording **only if** a future developer (or Claude in a future session) would genuinely benefit — i.e., it would change how they approach the same area of code.
29
59
 
30
- Do NOT record:
31
- - Routine refactors, obvious bug fixes, version bumps, formatting changes
32
- - Session-only debugging artifacts (e.g., a stray `test.only` or `console.log` that was removed)
33
- - Anything where the "lesson" is obvious in hindsight or already clear from the code/diff
34
- - Gotchas with no future recurrence risk (one-off typos, copy-paste errors, trivial config mistakes)
60
+ **Record when**:
61
+ - `fork` — chose between meaningful alternatives (e.g., serde alias vs. fixing all reconstruction sites)
62
+ - `discovery` — non-obvious behavior that will recur (e.g., UI progress tracking requires per-phase completion events)
63
+ - `constraint` — hard requirement future work must respect (e.g., checkpoint cleanup must wait for persistence)
64
+ - `tradeoff` — explicit trade-off with lasting impact (e.g., precision vs. simplicity in rate limiting)
65
+ - `abandoned` — tried and rejected an approach that looked reasonable
66
+ - `dependency` — selected a library after comparing alternatives (e.g., `reqwest` over `hyper` for HTTP)
67
+
68
+ **Do NOT record**:
69
+ - Routine refactors, obvious bug fixes, version bumps, formatting
70
+ - Session-only debugging artifacts (stray `test.only`, `console.log` removals)
71
+ - Lessons that are obvious in hindsight or clear from the diff
72
+ - One-off typos, copy-paste errors, trivial config mistakes
35
73
  - Decisions with no meaningful alternatives considered
36
74
 
37
- **Committing pre-existing changes**: When uncommitted changes exist that weren't made under an active intent, infer intents retroactively: read the diffs, group changes by semantic purpose, call `list_team_intents` to find existing intents that accurately match each group, then commit each group under its matched intent (create a new intent if no accurate match found). Present the grouping plan to the user before committing. Use `log_work` for trivial standalone changes.
75
+ ---
76
+
77
+ ## Committing pre-existing changes
78
+
79
+ When uncommitted changes exist that weren't made under an active intent:
80
+
81
+ 1. Read the diffs.
82
+ 2. Group changes by semantic purpose.
83
+ 3. Call `get_relevant_context` to find existing intents that accurately match each group.
84
+ 4. Commit each group under its matched intent (create a new intent only if no accurate match exists).
85
+ 5. Present the grouping plan to the user before committing.
86
+
87
+ Trivial standalone changes (typos, formatting) can be committed without an intent.
88
+
89
+ ---
90
+
91
+ ## Code blocks are auto-captured on commit
92
+
93
+ When `complete_intent` runs with a `commitSha`, the diff is read, line ranges are extracted per modified file, an AST-based semantic anchor is computed per range (for robust re-anchoring after rebases), and the blocks are sent to the API in the same PATCH that updates the intent status. **There is no manual "assign blocks" step.**
94
+
95
+ Implication: an intent completed without a `commitSha` will have an empty `blocks` array. For `abandoned` intents that's fine. For `committed` / `pushed` / `done`, **always pass the commit SHA** so auto-capture runs.
96
+
97
+ ---
38
98
 
39
99
  ## Repository Origin and Path
40
100
 
@@ -46,11 +106,11 @@ Use these values for ALL MCP tool calls:
46
106
 
47
107
  **Important**: `repoPath` must point to the directory containing the `.git` folder.
48
108
 
49
- <!-- ============================================================
109
+ <!-- =========================================================
50
110
  EVERYTHING BELOW IS OPTIONAL — add what's useful for your project
51
- ============================================================ -->
111
+ ========================================================= -->
52
112
 
53
- <!-- OPTIONAL: For monorepos or multi-project workspaces, replace the
113
+ <!-- OPTIONAL: monorepo / multi-project workspaces. Replace the
54
114
  single repoOrigin/repoPath above with a table:
55
115
 
56
116
  ### Repository Origins and Paths
@@ -61,20 +121,25 @@ Each sub-project has its own `.git` directory. When calling MCP tools, use the *
61
121
  |-------------|-----------------------------------------|----------------------------------|
62
122
  | my-api | `git@github.com:my-org/my-api.git` | `/path/to/workspace/my-api` |
63
123
  | my-frontend | `git@github.com:my-org/my-frontend.git` | `/path/to/workspace/my-frontend` |
124
+
125
+ Cross-repo workflow:
126
+ 1. Create an intent in each affected repo at the start — not retroactively
127
+ 2. Record decisions in the repo they affect
128
+ 3. Skip the intent workflow for repos with trivial pass-through changes
129
+ 4. Check `check_active_intent` per repo before modifying it
64
130
  -->
65
131
 
66
- <!-- OPTIONAL: Add project-specific sections as needed.
67
- Examples of what to include:
132
+ <!-- OPTIONAL: Project-specific sections.
68
133
 
69
- ## Development Commands
70
- - How to run tests, lint, build, etc.
134
+ ## Global constraints
135
+ Rules that apply to every change (e.g., DB name, no fallback code paths, required approval patterns).
71
136
 
72
- ## Code Style
73
- - Project conventions Claude should follow
137
+ ## Development Commands
138
+ How to run tests, lint, build.
74
139
 
75
- ## Architecture
76
- - Key architectural decisions or patterns
140
+ ## Gotchas
141
+ Non-obvious pitfalls Claude will hit.
77
142
 
78
- ## Important Files
79
- - Files Claude should know about
143
+ ## Reference
144
+ Link to a sibling ARCHITECTURE.md for IPC schemas, data models, etc. Keep this file behavior-focused.
80
145
  -->
package/README.md CHANGED
@@ -24,28 +24,12 @@ This MCP server enables AI coding assistants to understand what you're working o
24
24
  - **Decision recording**: Track architectural decisions and trade-offs with constraint validation
25
25
  - **Code block assignment**: Associate code changes with intents for better commit history
26
26
 
27
- ## Usage
28
-
29
- The MCP server works together with Kawa Code, AI code generators such as Cursor, Claude Code,
30
- and the Kawa Code extensions.
31
-
32
- ## Key Features
33
-
34
- - **Context Persistence**: Never lose track of what you were working on across AI sessions
35
- - **Smart Context Retrieval**: Relevance-based context loading - only fetch what's needed for the current task
36
- - **Zero-Knowledge Encryption**: Code blocks encrypted client-side before cloud sync, API cannot decrypt
37
- - **Team Conflict Detection**: Know when teammates are working on the same files/lines
38
- - **Decision Tracking**: Record architectural decisions with constraint validation and conflict detection
39
- - **Commit Integration**: Link all code changes to intent context for better git history
40
- - **Cross-Platform**: Works with Claude Code and Cursor AI via MCP protocol
41
-
42
27
  ## Prerequisites
43
28
 
44
29
  ### Required
45
30
 
46
31
  - **Node.js >= 18.0.0** — runtime for the MCP server
47
- - **[Kawa Code](https://codeawareness.com/product) desktop app running** — kawa.mcp is a thin MCP-to-IPC adapter; all git operations, storage, and API communication happen in Kawa Code
48
- - **Active Kawa Code account** — for cloud sync and team features
32
+ - **[Kawa Code](https://kawacode.ai) desktop app running** — kawa.mcp is a thin MCP-to-IPC adapter; all git operations, storage, and API communication happen in Kawa Code
49
33
 
50
34
  ### Optional (for history inference)
51
35
 
@@ -54,63 +38,27 @@ and the Kawa Code extensions.
54
38
 
55
39
  ## Installation
56
40
 
57
- ```bash
58
- # Clone the repository (if not already cloned)
59
- cd /path/to/kawa.mcp
60
-
61
- # Install dependencies
62
- npm install
63
-
64
- # Build the TypeScript source
65
- npm run build
66
- ```
67
-
68
- ## Quick Start
69
-
70
- 1. **Start Kawa Code**: Launch the Kawa Code desktop app and log in
71
- 2. **Configure MCP**: Add kawa.mcp to your AI assistant's MCP configuration (see Configuration section)
72
- 3. **Restart AI**: Restart Claude Code or Cursor to load the MCP server
73
- 4. **Test connection**: The server will try to connect to Kawa Code on startup
74
- 5. **Start coding**: Use `check_active_intent` to begin tracking your work
75
-
76
- ## Setting Up CLAUDE.md
77
-
78
- For Claude Code to use the MCP tools effectively, your project needs a `CLAUDE.md` file that tells Claude *when* to call the tools and provides your repository coordinates.
79
-
80
- Copy the example template into your project root and fill in the placeholders:
41
+ Add the MCP server to Claude Code (available across all your projects):
81
42
 
82
43
  ```bash
83
- cp /path/to/kawa.mcp/CLAUDE.md.example /path/to/your-project/CLAUDE.md
44
+ claude mcp add kawa-intents --scope user -- npx -y @kawacode/mcp
84
45
  ```
85
46
 
86
- Or just merge the example with your own content.
87
- See [`CLAUDE.md.example`](./CLAUDE.md.example) for the full template with optional sections for monorepos, code style, and architecture.
88
-
89
- ## Configuration
90
-
91
- ### Claude Code
92
-
93
- Create a `.mcp.json` file in your project root (recommended for teams — commit it to git):
47
+ Or for a single project, create a `.mcp.json` file in your project root (recommended for teams — commit it to git):
94
48
 
95
49
  ```json
96
50
  {
97
51
  "mcpServers": {
98
52
  "kawa-intents": {
99
53
  "type": "stdio",
100
- "command": "node",
101
- "args": ["/absolute/path/to/kawa.mcp/build/index.js"]
54
+ "command": "npx",
55
+ "args": ["-y", "@kawacode/mcp"]
102
56
  }
103
57
  }
104
58
  }
105
59
  ```
106
60
 
107
- Or add it at user level (available across all your projects):
108
-
109
- ```bash
110
- claude mcp add --transport stdio kawa-intents --scope user -- node /absolute/path/to/kawa.mcp/build/index.js
111
- ```
112
-
113
- ### Cursor AI
61
+ #### Cursor AI setup
114
62
 
115
63
  Add to your Cursor MCP configuration (`~/.cursor/mcp.json`):
116
64
 
@@ -118,14 +66,58 @@ Add to your Cursor MCP configuration (`~/.cursor/mcp.json`):
118
66
  {
119
67
  "mcpServers": {
120
68
  "kawa-intents": {
121
- "command": "node",
122
- "args": ["/absolute/path/to/kawa.mcp/build/index.js"]
69
+ "command": "npx",
70
+ "args": ["-y", "@kawacode/mcp"]
123
71
  }
124
72
  }
125
73
  }
126
74
  ```
127
75
 
128
- **Important:** Use absolute paths, not relative paths or `~` shortcuts.
76
+ ## Quick Start
77
+
78
+ 1. **Start Kawa Code**: Launch the Kawa Code desktop app and log in
79
+ 2. **Install MCP**: Run `claude mcp add kawa-intents --scope user -- npx -y @kawacode/mcp`
80
+ 3. **Restart AI**: Restart Claude Code or Cursor to load the MCP server
81
+ 4. **Test connection**: The server will try to connect to Kawa Code on startup
82
+ 5. **Start coding**: You'll start seeing `check_active_intent` at the start of your work with Claude Code
83
+
84
+ ## Setting Up CLAUDE.md
85
+
86
+ #### Quick prompt to tell Claude Code to set up everything:
87
+
88
+ ```
89
+ Read the CLAUDE.md.example file from the @kawacode/mcp package and create a CLAUDE.md in this project's root. Fill in the repoOrigin and repoPath with the actual values from this repository's git config. Fill in the Project Overview with a brief description of this project.
90
+ ```
91
+
92
+ After this, you can start working using your usual workflow. Kawa Code will automatically start improving your LLM's code generation quality.
93
+
94
+ To benefit from Kawa Code's intent-driven development immediately, tell Claude Code to infer code decisions from your git history:
95
+
96
+ ```
97
+ Please run infer_history with max 3000 commits.
98
+ ```
99
+
100
+ Tier 5 (the default) extracts the most context. Tiers are cumulative — each includes all data from lower tiers. Tiers 2 and 4 add PR/issue context from GitHub/GitLab and require the `gh` or `glab` CLI; they're automatically skipped if unavailable.
101
+
102
+ This can take a while, depending on how many commits you asked it to analyze. You'll see a progress bar in Kawa Code application.
103
+ Once this is done, you can open the project in Kawa Code (or you can use one of Kawa Code extensions for Visual Studio Code, emacs, or vim) to see the intents at every step in the code evolution.
104
+ Kawa Code will now select the relevant intents and micro-decisions made to speed up code generation, issue troubleshooting, bug fixing etc.
105
+ This relevant context will also help generating a more correct solution to your prompt request.
106
+
107
+ ## Usage
108
+
109
+ The MCP server works together with Kawa Code, AI code generators such as Cursor, Claude Code,
110
+ and the Kawa Code extensions.
111
+
112
+ ## Key Features
113
+
114
+ - **Context Persistence**: Never lose track of what you were working on across AI sessions
115
+ - **Smart Context Retrieval**: Relevance-based context loading - only fetch what's needed for the current task
116
+ - **Zero-Knowledge Encryption**: Code blocks encrypted client-side before cloud sync, API cannot decrypt
117
+ - **Team Conflict Detection**: Know when teammates are working on the same files/lines
118
+ - **Decision Tracking**: Record architectural decisions with constraint validation and conflict detection
119
+ - **Commit Integration**: Link all code changes to intent context for better git history
120
+ - **Cross-Platform**: Works with Claude Code and Cursor AI via MCP protocol
129
121
 
130
122
  ## Available Tools
131
123
 
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, getIntentsForFile, getIntentsForLines, assignBlocksToIntent, listTeamIntents, getIntentChanges, completeIntent, logWork, recordDecision, getSessionDecisions, getProjectDecisions, editSessionDecision, detectIntentConflicts, inferHistory, evolveDecisions } from './tools/index.js';
6
+ import { allTools, getRelevantContext, checkActiveIntent, createAndActivateIntent, activateIntent, getIntentsForFile, getIntentsForLines, listTeamIntents, getIntentChanges, completeIntent, logWork, recordDecision, getSessionDecisions, getProjectDecisions, editSessionDecision, detectIntentConflicts, inferHistory, evolveDecisions } 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
@@ -58,15 +58,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
58
58
  case 'create_and_activate_intent':
59
59
  result = await createAndActivateIntent(args);
60
60
  break;
61
+ case 'activate_intent':
62
+ result = await activateIntent(args);
63
+ break;
61
64
  case 'get_intents_for_file':
62
65
  result = await getIntentsForFile(args);
63
66
  break;
64
67
  case 'get_intents_for_lines':
65
68
  result = await getIntentsForLines(args);
66
69
  break;
67
- case 'assign_blocks_to_intent':
68
- result = await assignBlocksToIntent(args);
69
- break;
70
70
  case 'list_team_intents':
71
71
  result = await listTeamIntents(args);
72
72
  break;
@@ -113,8 +113,27 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
113
113
  };
114
114
  }
115
115
  catch (error) {
116
+ // Surface IPC / handler failures as structured tool output instead of an
117
+ // McpError stack trace. The AI sees the friendly error message and can
118
+ // decide how to recover (retry, fall back, ask user, etc.).
119
+ // Errors that are not IPC-related (e.g. unknown tool name) are still
120
+ // raised as McpError below.
121
+ if (error instanceof McpError)
122
+ throw error;
116
123
  const message = error instanceof Error ? error.message : 'Tool execution failed';
117
- throw new McpError(ErrorCode.InternalError, message);
124
+ return {
125
+ content: [
126
+ {
127
+ type: 'text',
128
+ text: JSON.stringify({
129
+ success: false,
130
+ error: message,
131
+ tool: name,
132
+ }, null, 2),
133
+ },
134
+ ],
135
+ isError: true,
136
+ };
118
137
  }
119
138
  });
120
139
  // Handle prompt listing
@@ -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,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,cAAc,EAAE,KAAK,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -27,7 +27,7 @@ Before using MCP tools, assess the task complexity. Match your workflow to the t
27
27
  | When | Action | Tool |
28
28
  |------|--------|------|
29
29
  | **Before coding** | Check for active intent (resume if exists) | \`check_active_intent\` |
30
- | **After edits** | Log what was done | \`log_work\` or \`assign_blocks_to_intent\` |
30
+ | **After edits** | Log what was done | \`log_work\` |
31
31
 
32
32
  **Full workflow** — Multi-file features, unfamiliar code areas, architectural decisions, cross-cutting changes, or work that may overlap with teammates. Use the complete lifecycle:
33
33
 
@@ -35,8 +35,9 @@ Before using MCP tools, assess the task complexity. Match your workflow to the t
35
35
  |------|--------|------|
36
36
  | **After exploring request** | Get relevant context (with discovered files) | \`get_relevant_context\` |
37
37
  | **Before coding** | Check/create intent | \`check_active_intent\`, \`create_and_activate_intent\` |
38
- | **After each file edit** | Assign modified line ranges | \`assign_blocks_to_intent\` |
39
- | **On "done"/"commit"/"worked"/etc.** | Verify blocks → Git commit → Complete | \`get_intent_changes\`, \`complete_intent\` |
38
+ | **On "done"/"commit"/"worked"/etc.** | Verify diff → Git commit → Complete | \`get_intent_changes\`, \`complete_intent\` |
39
+
40
+ > **Note**: Code blocks are attached to the intent automatically when you call \`complete_intent\` with a commit SHA. Muninn reads the commit diff, computes semantic anchors for each modified range, and sends the encrypted blocks to the API in the same call that updates the intent status. There is no manual "assign blocks" step.
40
41
 
41
42
  **Trigger phrases for commit flow**: "this worked", "let's commit", "done", "close this", "ship it", "looks good"
42
43
 
@@ -109,8 +110,7 @@ When the user chooses to commit (or explicitly requests it):
109
110
 
110
111
  Include these in the intent record? [Yes] [Edit] [Skip]
111
112
  \`\`\`
112
- 5. **Assign blocks**: Call \`assign_blocks_to_intent\` with all modified file ranges
113
- 6. **Git operations**:
113
+ 5. **Git operations**:
114
114
  \`\`\`bash
115
115
  git add <files>
116
116
  git commit -m "<intent title>
@@ -124,8 +124,8 @@ When the user chooses to commit (or explicitly requests it):
124
124
  Intent-ID: <intent-id>
125
125
  Co-Authored-By: Claude <noreply@anthropic.com>"
126
126
  \`\`\`
127
- 7. **Complete intent**: Call \`complete_intent\` with the commit SHA and status='committed'
128
- 8. **Report**: Tell the user the commit SHA and that the intent is complete
127
+ 6. **Complete intent**: Call \`complete_intent\` with the commit SHA and status='committed'. Muninn will auto-capture the modified code blocks from the commit diff, compute semantic anchors, and send them together with the status update in one API call.
128
+ 7. **Report**: Tell the user the commit SHA and that the intent is complete
129
129
 
130
130
  - If user had a new request that triggered the commit, proceed to create a new intent for it
131
131
  - If user explicitly said "we're done", the workflow ends
@@ -184,7 +184,6 @@ For each group:
184
184
  | \`create_and_activate_intent\` | When no active intent and user requests code changes |
185
185
  | \`get_intents_for_file\` | Before modifying files (check for team conflicts) |
186
186
  | \`get_intents_for_lines\` | Before modifying specific line ranges |
187
- | \`assign_blocks_to_intent\` | After writing code, before committing |
188
187
  | \`get_intent_changes\` | Before prompting about commit (to show change summary) |
189
188
  | \`complete_intent\` | After successful git commit, or to abandon |
190
189
  | \`list_team_intents\` | To see what teammates are working on |
@@ -1 +1 @@
1
- {"version":3,"file":"intent-first-workflow.js","sourceRoot":"","sources":["../../src/prompts/intent-first-workflow.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,4HAA4H;IACzI,SAAS,EAAE;QACT;YACE,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;SAChB;KACF;IACD,SAAS,EAAE,CAAC,IAAoC,EAAE,EAAE;QAClD,MAAM,WAAW,GAAG,IAAI,EAAE,gBAAgB;YACxC,CAAC,CAAC,yBAAyB,IAAI,CAAC,gBAAgB,EAAE;YAClD,CAAC,CAAC,EAAE,CAAA;QAEN,OAAO,qCAAqC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4FAyLiC,CAAA;IAC1F,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,yBAAyB,CAAC,CAAA"}
1
+ {"version":3,"file":"intent-first-workflow.js","sourceRoot":"","sources":["../../src/prompts/intent-first-workflow.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,4HAA4H;IACzI,SAAS,EAAE;QACT;YACE,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;SAChB;KACF;IACD,SAAS,EAAE,CAAC,IAAoC,EAAE,EAAE;QAClD,MAAM,WAAW,GAAG,IAAI,EAAE,gBAAgB;YACxC,CAAC,CAAC,yBAAyB,IAAI,CAAC,gBAAgB,EAAE;YAClD,CAAC,CAAC,EAAE,CAAA;QAEN,OAAO,qCAAqC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4FAwLiC,CAAA;IAC1F,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,yBAAyB,CAAC,CAAA"}
@@ -16,8 +16,8 @@ export async function readActiveIntentResource(repoOrigin) {
16
16
  const res = await request('intent', 'get-active', {
17
17
  repoOrigin: repoOrigin || '',
18
18
  });
19
- // Muninn returns { success, activeIntentId, activeIntent }
20
- const intent = res.activeIntent;
19
+ // Muninn returns { hasActiveIntent, intentId, intent }
20
+ const intent = res.intent;
21
21
  if (!intent) {
22
22
  return JSON.stringify({
23
23
  hasActiveIntent: false,
@@ -1 +1 @@
1
- {"version":3,"file":"active-intent.js","sourceRoot":"","sources":["../../src/resources/active-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAShE,MAAM,CAAC,MAAM,oBAAoB,GAAyB;IACxD,GAAG,EAAE,sBAAsB;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0DAA0D;IACvE,QAAQ,EAAE,kBAAkB;CAC7B,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,UAAmB;IAChE,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,eAAe,EAAE,KAAK;YACtB,IAAI,EAAE,6DAA6D;SACpE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACb,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE;YAChD,UAAU,EAAE,UAAU,IAAI,EAAE;SAC7B,CAAC,CAAA;QAEF,2DAA2D;QAC3D,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,CAAA;QAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,eAAe,EAAE,KAAK;gBACtB,UAAU,EAAE,UAAU,IAAI,SAAS;gBACnC,IAAI,EAAE,UAAU;oBACd,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,+DAA+D;aACpE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACb,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,eAAe,EAAE,IAAI;YACrB,U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
  */
12
+ /** Stable session ID for this MCP process. Identifies this agent in intent attribution. */
13
+ export declare const SESSION_ID: string;
12
14
  /**
13
15
  * Connect to Muninn's Huginn IPC socket.
14
16
  *
@@ -29,7 +31,7 @@ export declare function request(domain: string, action: string, data?: any): Pro
29
31
  * Ensure a repository path is registered with Muninn as a project.
30
32
  *
31
33
  * Sends `code:add` with the folder path so Muninn activates the project,
32
- * sets up git state, and pulls intents/decisions/lessons from the API.
34
+ * sets up git state, and pulls intents/decisions from the API.
33
35
  * Always sends the request — Muninn's AddHandler is idempotent and
34
36
  * returns the existing project if already added.
35
37
  * Errors are logged but not thrown — repo registration is best-effort.
@@ -16,6 +16,8 @@ import * as os from 'os';
16
16
  import * as crypto from 'crypto';
17
17
  const EXTENSION_ID = 'mcp';
18
18
  const EXTENSION_DOMAINS = ['intent', 'intent-block', 'decision', 'claude-code', 'code', 'inference'];
19
+ /** Stable session ID for this MCP process. Identifies this agent in intent attribution. */
20
+ export const SESSION_ID = `mcp-${crypto.randomBytes(4).toString('hex')}`;
19
21
  const REQUEST_TIMEOUT_MS = 30_000;
20
22
  const HANDSHAKE_TIMEOUT_MS = 10_000;
21
23
  /**
@@ -184,7 +186,22 @@ function connectClientPipe(pipePath, resolve, reject) {
184
186
  cleanup();
185
187
  });
186
188
  }
187
- /** Route an inbound response message to its waiting pendingRequest entry. */
189
+ /** Route an inbound response message to its waiting pendingRequest entry.
190
+ *
191
+ * Failure propagation has two layers:
192
+ * 1. Envelope-level: `msg.err` is set when the IPC dispatch itself failed
193
+ * (unknown domain, malformed message, etc.). Reject directly.
194
+ * 2. Application-level: Muninn handlers wrap their own failures INSIDE
195
+ * `msg.data` as `{ success: false, error: "..." }`. Without this check,
196
+ * tools silently received the failure object as a successful resolve and
197
+ * had to remember to inspect it themselves — which several built tools
198
+ * did not, leading to fake `success: true, intentId: ""` responses.
199
+ *
200
+ * Strict equality (`=== false`) is intentional. Async-start responses such as
201
+ * `{ started: true, message: "..." }` (inference run/evolve) and estimate
202
+ * responses (`{ estimate: {...} }`) carry no `success` field at all and must
203
+ * pass through unchanged.
204
+ */
188
205
  function routeResponse(msg) {
189
206
  const msgId = msg._msgId;
190
207
  if (msgId && pendingRequests.has(msgId)) {
@@ -193,10 +210,23 @@ function routeResponse(msg) {
193
210
  clearTimeout(pending.timer);
194
211
  if (msg.err) {
195
212
  pending.reject(new Error(msg.err));
213
+ return;
196
214
  }
197
- else {
198
- pending.resolve(msg.data || {});
215
+ const data = msg.data || {};
216
+ if (data.success === false) {
217
+ // Conflict responses carry structured `conflicts` data that the calling
218
+ // tool must present to the user — not a dispatch failure. Let them pass.
219
+ if (data.conflict === true) {
220
+ pending.resolve(data);
221
+ return;
222
+ }
223
+ const errorMsg = typeof data.error === 'string' && data.error.length > 0
224
+ ? data.error
225
+ : 'Muninn handler returned success: false with no error message';
226
+ pending.reject(new Error(errorMsg));
227
+ return;
199
228
  }
229
+ pending.resolve(data);
200
230
  }
201
231
  }
202
232
  /**
@@ -223,7 +253,7 @@ export async function request(domain, action, data = {}) {
223
253
  domain,
224
254
  action,
225
255
  caw: cawId,
226
- data,
256
+ data: { ...data, _agentId: SESSION_ID },
227
257
  _msgId: msgId,
228
258
  });
229
259
  socket.write(message + '\n');
@@ -233,7 +263,7 @@ export async function request(domain, action, data = {}) {
233
263
  * Ensure a repository path is registered with Muninn as a project.
234
264
  *
235
265
  * Sends `code:add` with the folder path so Muninn activates the project,
236
- * sets up git state, and pulls intents/decisions/lessons from the API.
266
+ * sets up git state, and pulls intents/decisions from the API.
237
267
  * Always sends the request — Muninn's AddHandler is idempotent and
238
268
  * returns the existing project if already added.
239
269
  * Errors are logged but not thrown — repo registration is best-effort.