@kawacode/mcp 5.2.2 → 6.0.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 (78) hide show
  1. package/CLAUDE.md.example +1 -1
  2. package/README.md +54 -198
  3. package/build/index.js +10 -1
  4. package/build/index.js.map +1 -1
  5. package/build/kawacode-on-pre-edit.d.ts +27 -0
  6. package/build/kawacode-on-pre-edit.js +205 -0
  7. package/build/kawacode-on-pre-edit.js.map +1 -0
  8. package/build/kawacode-on-stop.d.ts +29 -0
  9. package/build/kawacode-on-stop.js +84 -0
  10. package/build/kawacode-on-stop.js.map +1 -0
  11. package/build/prompts/intent-first-workflow.js +2 -2
  12. package/build/tools/_fork-fields.d.ts +84 -0
  13. package/build/tools/_fork-fields.js +65 -0
  14. package/build/tools/_fork-fields.js.map +1 -0
  15. package/build/tools/activate-intent.d.ts +66 -0
  16. package/build/tools/activate-intent.js +59 -3
  17. package/build/tools/activate-intent.js.map +1 -1
  18. package/build/tools/check-active-intent.d.ts +64 -0
  19. package/build/tools/check-active-intent.js +16 -2
  20. package/build/tools/check-active-intent.js.map +1 -1
  21. package/build/tools/complete-intent.d.ts +115 -4
  22. package/build/tools/complete-intent.js +130 -11
  23. package/build/tools/complete-intent.js.map +1 -1
  24. package/build/tools/create-intent.d.ts +73 -1
  25. package/build/tools/create-intent.js +105 -7
  26. package/build/tools/create-intent.js.map +1 -1
  27. package/build/tools/detect-intent-conflicts.d.ts +52 -0
  28. package/build/tools/detect-intent-conflicts.js +14 -10
  29. package/build/tools/detect-intent-conflicts.js.map +1 -1
  30. package/build/tools/edit-session-decision.d.ts +64 -12
  31. package/build/tools/edit-session-decision.js +4 -1
  32. package/build/tools/edit-session-decision.js.map +1 -1
  33. package/build/tools/evolve-decisions.d.ts +52 -0
  34. package/build/tools/evolve-decisions.js +14 -15
  35. package/build/tools/evolve-decisions.js.map +1 -1
  36. package/build/tools/get-intent-changes.d.ts +52 -0
  37. package/build/tools/get-intent-changes.js +4 -1
  38. package/build/tools/get-intent-changes.js.map +1 -1
  39. package/build/tools/get-intents-for-file.d.ts +52 -0
  40. package/build/tools/get-intents-for-file.js +4 -1
  41. package/build/tools/get-intents-for-file.js.map +1 -1
  42. package/build/tools/get-intents-for-lines.d.ts +52 -0
  43. package/build/tools/get-intents-for-lines.js +4 -1
  44. package/build/tools/get-intents-for-lines.js.map +1 -1
  45. package/build/tools/get-project-decisions.d.ts +52 -0
  46. package/build/tools/get-project-decisions.js +4 -1
  47. package/build/tools/get-project-decisions.js.map +1 -1
  48. package/build/tools/get-relevant-context.d.ts +52 -0
  49. package/build/tools/get-relevant-context.js +18 -24
  50. package/build/tools/get-relevant-context.js.map +1 -1
  51. package/build/tools/get-session-decisions.d.ts +52 -0
  52. package/build/tools/get-session-decisions.js +4 -1
  53. package/build/tools/get-session-decisions.js.map +1 -1
  54. package/build/tools/index.d.ts +620 -18
  55. package/build/tools/index.js +12 -3
  56. package/build/tools/index.js.map +1 -1
  57. package/build/tools/infer-history.d.ts +6 -0
  58. package/build/tools/infer-history.js +28 -15
  59. package/build/tools/infer-history.js.map +1 -1
  60. package/build/tools/list-team-intents.d.ts +58 -6
  61. package/build/tools/list-team-intents.js +5 -2
  62. package/build/tools/list-team-intents.js.map +1 -1
  63. package/build/tools/log-work.d.ts +52 -0
  64. package/build/tools/log-work.js +4 -1
  65. package/build/tools/log-work.js.map +1 -1
  66. package/build/tools/pre-edit-acknowledge.d.ts +92 -0
  67. package/build/tools/pre-edit-acknowledge.js +48 -0
  68. package/build/tools/pre-edit-acknowledge.js.map +1 -0
  69. package/build/tools/pre-edit-decision-check.d.ts +141 -0
  70. package/build/tools/pre-edit-decision-check.js +77 -0
  71. package/build/tools/pre-edit-decision-check.js.map +1 -0
  72. package/build/tools/record-decision.d.ts +88 -12
  73. package/build/tools/record-decision.js +15 -1
  74. package/build/tools/record-decision.js.map +1 -1
  75. package/build/tools/update-intent.d.ts +60 -8
  76. package/build/tools/update-intent.js +6 -1
  77. package/build/tools/update-intent.js.map +1 -1
  78. package/package.json +6 -3
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * kawacode-on-stop — Claude Code Stop hook dispatcher.
4
+ *
5
+ * Reads the Stop hook payload from stdin (session_id, transcript_path, cwd)
6
+ * and sends two short IPCs to Muninn:
7
+ *
8
+ * 1. capture-thoughts:capture { sessionId, transcriptPath, cwd }
9
+ * → Muninn reads the transcript, filters thinking blocks, appends
10
+ * JSONL to ~/.kawa-code/thoughts/active/session-{id}.jsonl
11
+ * 2. extractor:trigger { session_id, cwd }
12
+ * → Muninn wakes the (debounced) extractor service which reads the
13
+ * fresh JSONL and emits ephemeral decisions.
14
+ *
15
+ * Replaces the legacy kawacode-capture-thoughts (Node CLI that did the file
16
+ * I/O itself, never merged to main) AND kawacode-extract-trigger (separate
17
+ * Node CLI that did the second IPC). The whole capture pipeline now lives
18
+ * in Muninn — this dispatcher's only job is to fire the two pings.
19
+ *
20
+ * Failure discipline: every error path exits 0. Claude Code's Stop hook
21
+ * must never block the turn loop on capture failure. This is the ONLY
22
+ * place fail-soft is allowed under the no-Muninn-independence rule —
23
+ * because the hook script is the boundary between the harness (which
24
+ * can't recover) and Muninn (which can re-derive missing captures from
25
+ * the transcript on the next Stop).
26
+ *
27
+ * Opt out with KAWA_THOUGHT_CAPTURE=off.
28
+ */
29
+ export {};
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * kawacode-on-stop — Claude Code Stop hook dispatcher.
4
+ *
5
+ * Reads the Stop hook payload from stdin (session_id, transcript_path, cwd)
6
+ * and sends two short IPCs to Muninn:
7
+ *
8
+ * 1. capture-thoughts:capture { sessionId, transcriptPath, cwd }
9
+ * → Muninn reads the transcript, filters thinking blocks, appends
10
+ * JSONL to ~/.kawa-code/thoughts/active/session-{id}.jsonl
11
+ * 2. extractor:trigger { session_id, cwd }
12
+ * → Muninn wakes the (debounced) extractor service which reads the
13
+ * fresh JSONL and emits ephemeral decisions.
14
+ *
15
+ * Replaces the legacy kawacode-capture-thoughts (Node CLI that did the file
16
+ * I/O itself, never merged to main) AND kawacode-extract-trigger (separate
17
+ * Node CLI that did the second IPC). The whole capture pipeline now lives
18
+ * in Muninn — this dispatcher's only job is to fire the two pings.
19
+ *
20
+ * Failure discipline: every error path exits 0. Claude Code's Stop hook
21
+ * must never block the turn loop on capture failure. This is the ONLY
22
+ * place fail-soft is allowed under the no-Muninn-independence rule —
23
+ * because the hook script is the boundary between the harness (which
24
+ * can't recover) and Muninn (which can re-derive missing captures from
25
+ * the transcript on the next Stop).
26
+ *
27
+ * Opt out with KAWA_THOUGHT_CAPTURE=off.
28
+ */
29
+ import { readFileSync } from 'node:fs';
30
+ import { connectToMuninn, request, disconnect } from './services/muninn-ipc.js';
31
+ function readStdin() {
32
+ try {
33
+ return readFileSync(0, 'utf8');
34
+ }
35
+ catch {
36
+ return '';
37
+ }
38
+ }
39
+ async function main() {
40
+ if (process.env.KAWA_THOUGHT_CAPTURE === 'off') {
41
+ process.exit(0);
42
+ }
43
+ const raw = readStdin();
44
+ if (!raw)
45
+ process.exit(0);
46
+ let payload;
47
+ try {
48
+ payload = JSON.parse(raw);
49
+ }
50
+ catch {
51
+ process.exit(0);
52
+ }
53
+ const sessionId = payload.session_id;
54
+ const transcriptPath = payload.transcript_path;
55
+ const cwd = payload.cwd;
56
+ if (!sessionId || !transcriptPath)
57
+ process.exit(0);
58
+ try {
59
+ await connectToMuninn();
60
+ }
61
+ catch {
62
+ // Muninn down. Capture happens whenever Muninn is next up — the
63
+ // extractor's checkpoint advances on the next successful capture.
64
+ process.exit(0);
65
+ }
66
+ // Fire both IPCs in parallel; each is independent and tolerant of the
67
+ // other's failure. allSettled because we never want one to short-circuit
68
+ // the other on transient failure.
69
+ await Promise.allSettled([
70
+ request('capture-thoughts', 'capture', {
71
+ sessionId,
72
+ transcriptPath,
73
+ cwd: cwd ?? null,
74
+ }),
75
+ request('extractor', 'trigger', {
76
+ session_id: sessionId,
77
+ cwd: cwd ?? '',
78
+ }),
79
+ ]);
80
+ disconnect();
81
+ process.exit(0);
82
+ }
83
+ main().catch(() => process.exit(0));
84
+ //# sourceMappingURL=kawacode-on-stop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kawacode-on-stop.js","sourceRoot":"","sources":["../src/kawacode-on-stop.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAS/E,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,KAAK,UAAU,IAAI;IACjB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,KAAK,EAAE,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;IACvB,IAAI,CAAC,GAAG;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAEzB,IAAI,OAAoB,CAAA;IACxB,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAA;IACpC,MAAM,cAAc,GAAG,OAAO,CAAC,eAAe,CAAA;IAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACvB,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAElD,IAAI,CAAC;QACH,MAAM,eAAe,EAAE,CAAA;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,gEAAgE;QAChE,kEAAkE;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,sEAAsE;IACtE,yEAAyE;IACzE,kCAAkC;IAClC,MAAM,OAAO,CAAC,UAAU,CAAC;QACvB,OAAO,CAAC,kBAAkB,EAAE,SAAS,EAAE;YACrC,SAAS;YACT,cAAc;YACd,GAAG,EAAE,GAAG,IAAI,IAAI;SACjB,CAAC;QACF,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE;YAC9B,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,GAAG,IAAI,EAAE;SACf,CAAC;KACH,CAAC,CAAA;IAEF,UAAU,EAAE,CAAA;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA"}
@@ -37,7 +37,7 @@ Before using MCP tools, assess the task complexity. Match your workflow to the t
37
37
  | **Before coding** | Check/create intent | \`check_active_intent\`, \`create_and_activate_intent\` |
38
38
  | **On "done"/"commit"/"worked"/etc.** | Verify diff → Git commit → Complete | \`get_intent_changes\`, \`complete_intent\` |
39
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
+ > **Note**: Code blocks are attached to the intent automatically when you call \`complete_intent\` with a commit SHA. There is no manual "assign blocks" step.
41
41
 
42
42
  **Trigger phrases for commit flow**: "this worked", "let's commit", "done", "close this", "ship it", "looks good"
43
43
 
@@ -124,7 +124,7 @@ 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
- 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.
127
+ 6. **Complete intent**: Call \`complete_intent\` with the commit SHA and status='committed'. The modified code blocks are auto-captured and attached to the intent as part of the same call.
128
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
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Shared Zod schema fragment for the forkAuthor + workspaceId attribution
3
+ * fields added in REPO_FORKS_IMPLEMENTATION_PLAN_PHASE_1.md §5.
4
+ *
5
+ * Every MCP tool that accepts `repoOrigin` spreads `forkFieldsExtensions`
6
+ * into its Zod input schema and forwards `extractForkFields(input)` to the
7
+ * IPC payload. Both fields are OPTIONAL — Muninn resolves them
8
+ * automatically from `repoPath` (fork detection + workspace registry, §4.2 +
9
+ * §4.3). Callers only need to pass them in advanced override / testing
10
+ * scenarios where the desktop app's auto-resolution should be bypassed.
11
+ *
12
+ * Keep the field shape in lockstep with:
13
+ * - kawa.api/src/models/intents.model.ts / decisions.model.ts
14
+ * - kawa.muninn/src-tauri/src/gardener/handlers/intent.rs (OutboundIdentity)
15
+ *
16
+ * Drift across repos will cause silent rejection (Yup validators strip
17
+ * unknown fields on the API side) or runtime errors on the Muninn side.
18
+ */
19
+ import { z } from 'zod';
20
+ /**
21
+ * Fork attribution payload. Optional in its entirety; when present, all
22
+ * three subfields are required (so the API can persist a coherent record).
23
+ */
24
+ export declare const forkAuthorSchema: z.ZodObject<{
25
+ platform: z.ZodEnum<["github", "gitlab"]>;
26
+ user: z.ZodString;
27
+ forkOrigin: z.ZodString;
28
+ }, "strip", z.ZodTypeAny, {
29
+ platform: "github" | "gitlab";
30
+ user: string;
31
+ forkOrigin: string;
32
+ }, {
33
+ platform: "github" | "gitlab";
34
+ user: string;
35
+ forkOrigin: string;
36
+ }>;
37
+ export type ForkAuthor = z.infer<typeof forkAuthorSchema>;
38
+ /**
39
+ * Spread into each tool's Zod input schema. The two fields are independent —
40
+ * a tool can accept `workspaceId` alone (override for the override target)
41
+ * without `forkAuthor` (canonical clone) and vice versa.
42
+ */
43
+ export declare const forkFieldsExtensions: {
44
+ forkAuthor: z.ZodOptional<z.ZodObject<{
45
+ platform: z.ZodEnum<["github", "gitlab"]>;
46
+ user: z.ZodString;
47
+ forkOrigin: z.ZodString;
48
+ }, "strip", z.ZodTypeAny, {
49
+ platform: "github" | "gitlab";
50
+ user: string;
51
+ forkOrigin: string;
52
+ }, {
53
+ platform: "github" | "gitlab";
54
+ user: string;
55
+ forkOrigin: string;
56
+ }>>;
57
+ workspaceId: z.ZodOptional<z.ZodString>;
58
+ };
59
+ /**
60
+ * Subset of a tool input shape carrying just the §5 fields.
61
+ *
62
+ * Tools have many other fields; this is the narrow type the
63
+ * `extractForkFields` helper accepts so it stays usable across all 20 tools
64
+ * without each one importing a full input type.
65
+ */
66
+ export interface ForkFieldsInput {
67
+ forkAuthor?: ForkAuthor;
68
+ workspaceId?: string;
69
+ }
70
+ /**
71
+ * Pluck the §5 fields off a tool input for IPC payload forwarding.
72
+ *
73
+ * Returns an object suitable for spreading into the `request(...)` call:
74
+ *
75
+ * await request('intent', 'create', {
76
+ * repoOrigin: actualOrigin,
77
+ * ...extractForkFields(input),
78
+ * ...
79
+ * })
80
+ *
81
+ * Fields are only included when defined, so canonical-clone callers don't
82
+ * spam Muninn with explicit nulls.
83
+ */
84
+ export declare function extractForkFields(input: ForkFieldsInput): ForkFieldsInput;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Shared Zod schema fragment for the forkAuthor + workspaceId attribution
3
+ * fields added in REPO_FORKS_IMPLEMENTATION_PLAN_PHASE_1.md §5.
4
+ *
5
+ * Every MCP tool that accepts `repoOrigin` spreads `forkFieldsExtensions`
6
+ * into its Zod input schema and forwards `extractForkFields(input)` to the
7
+ * IPC payload. Both fields are OPTIONAL — Muninn resolves them
8
+ * automatically from `repoPath` (fork detection + workspace registry, §4.2 +
9
+ * §4.3). Callers only need to pass them in advanced override / testing
10
+ * scenarios where the desktop app's auto-resolution should be bypassed.
11
+ *
12
+ * Keep the field shape in lockstep with:
13
+ * - kawa.api/src/models/intents.model.ts / decisions.model.ts
14
+ * - kawa.muninn/src-tauri/src/gardener/handlers/intent.rs (OutboundIdentity)
15
+ *
16
+ * Drift across repos will cause silent rejection (Yup validators strip
17
+ * unknown fields on the API side) or runtime errors on the Muninn side.
18
+ */
19
+ import { z } from 'zod';
20
+ /**
21
+ * Fork attribution payload. Optional in its entirety; when present, all
22
+ * three subfields are required (so the API can persist a coherent record).
23
+ */
24
+ export const forkAuthorSchema = z
25
+ .object({
26
+ platform: z.enum(['github', 'gitlab']),
27
+ user: z.string(),
28
+ forkOrigin: z.string(),
29
+ })
30
+ .describe('Fork attribution; usually resolved by Muninn automatically — pass only for override / testing.');
31
+ /**
32
+ * Spread into each tool's Zod input schema. The two fields are independent —
33
+ * a tool can accept `workspaceId` alone (override for the override target)
34
+ * without `forkAuthor` (canonical clone) and vice versa.
35
+ */
36
+ export const forkFieldsExtensions = {
37
+ forkAuthor: forkAuthorSchema.optional(),
38
+ workspaceId: z
39
+ .string()
40
+ .optional()
41
+ .describe('Workspace identifier; usually resolved by Muninn automatically — pass only for override / testing.'),
42
+ };
43
+ /**
44
+ * Pluck the §5 fields off a tool input for IPC payload forwarding.
45
+ *
46
+ * Returns an object suitable for spreading into the `request(...)` call:
47
+ *
48
+ * await request('intent', 'create', {
49
+ * repoOrigin: actualOrigin,
50
+ * ...extractForkFields(input),
51
+ * ...
52
+ * })
53
+ *
54
+ * Fields are only included when defined, so canonical-clone callers don't
55
+ * spam Muninn with explicit nulls.
56
+ */
57
+ export function extractForkFields(input) {
58
+ const out = {};
59
+ if (input.forkAuthor !== undefined)
60
+ out.forkAuthor = input.forkAuthor;
61
+ if (input.workspaceId !== undefined)
62
+ out.workspaceId = input.workspaceId;
63
+ return out;
64
+ }
65
+ //# sourceMappingURL=_fork-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_fork-fields.js","sourceRoot":"","sources":["../../src/tools/_fork-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC;KACD,QAAQ,CACP,gGAAgG,CACjG,CAAA;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACvC,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,oGAAoG,CACrG;CACJ,CAAA;AAcD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAsB;IACtD,MAAM,GAAG,GAAoB,EAAE,CAAA;IAC/B,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAAE,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAA;IACrE,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS;QAAE,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAA;IACxE,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1,40 +1,106 @@
1
1
  import { z } from 'zod';
2
2
  export declare const activateIntentSchema: z.ZodObject<{
3
+ forkAuthor: z.ZodOptional<z.ZodObject<{
4
+ platform: z.ZodEnum<["github", "gitlab"]>;
5
+ user: z.ZodString;
6
+ forkOrigin: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ platform: "github" | "gitlab";
9
+ user: string;
10
+ forkOrigin: string;
11
+ }, {
12
+ platform: "github" | "gitlab";
13
+ user: string;
14
+ forkOrigin: string;
15
+ }>>;
16
+ workspaceId: z.ZodOptional<z.ZodString>;
3
17
  repoOrigin: z.ZodOptional<z.ZodString>;
4
18
  repoPath: z.ZodString;
5
19
  intentId: z.ZodString;
20
+ force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
6
21
  }, "strip", z.ZodTypeAny, {
7
22
  repoPath: string;
23
+ force: boolean;
8
24
  intentId: string;
9
25
  repoOrigin?: string | undefined;
26
+ forkAuthor?: {
27
+ platform: "github" | "gitlab";
28
+ user: string;
29
+ forkOrigin: string;
30
+ } | undefined;
31
+ workspaceId?: string | undefined;
10
32
  }, {
11
33
  repoPath: string;
12
34
  intentId: string;
13
35
  repoOrigin?: string | undefined;
36
+ forkAuthor?: {
37
+ platform: "github" | "gitlab";
38
+ user: string;
39
+ forkOrigin: string;
40
+ } | undefined;
41
+ workspaceId?: string | undefined;
42
+ force?: boolean | undefined;
14
43
  }>;
15
44
  export type ActivateIntentInput = z.infer<typeof activateIntentSchema>;
45
+ export interface ActiveIntentLockConflict {
46
+ existingIntentId: string;
47
+ title?: string;
48
+ createdBy?: string;
49
+ author?: string;
50
+ }
16
51
  export interface ActivateIntentResponse {
17
52
  success: boolean;
18
53
  intentId: string;
54
+ action?: 'activated' | 'already_active' | 'conflict';
19
55
  previousActiveId?: string;
20
56
  message: string;
57
+ lockConflict?: ActiveIntentLockConflict;
21
58
  }
22
59
  export declare function activateIntent(input: ActivateIntentInput): Promise<ActivateIntentResponse>;
23
60
  export declare const activateIntentTool: {
24
61
  name: string;
25
62
  description: string;
26
63
  inputSchema: z.ZodObject<{
64
+ forkAuthor: z.ZodOptional<z.ZodObject<{
65
+ platform: z.ZodEnum<["github", "gitlab"]>;
66
+ user: z.ZodString;
67
+ forkOrigin: z.ZodString;
68
+ }, "strip", z.ZodTypeAny, {
69
+ platform: "github" | "gitlab";
70
+ user: string;
71
+ forkOrigin: string;
72
+ }, {
73
+ platform: "github" | "gitlab";
74
+ user: string;
75
+ forkOrigin: string;
76
+ }>>;
77
+ workspaceId: z.ZodOptional<z.ZodString>;
27
78
  repoOrigin: z.ZodOptional<z.ZodString>;
28
79
  repoPath: z.ZodString;
29
80
  intentId: z.ZodString;
81
+ force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
30
82
  }, "strip", z.ZodTypeAny, {
31
83
  repoPath: string;
84
+ force: boolean;
32
85
  intentId: string;
33
86
  repoOrigin?: string | undefined;
87
+ forkAuthor?: {
88
+ platform: "github" | "gitlab";
89
+ user: string;
90
+ forkOrigin: string;
91
+ } | undefined;
92
+ workspaceId?: string | undefined;
34
93
  }, {
35
94
  repoPath: string;
36
95
  intentId: string;
37
96
  repoOrigin?: string | undefined;
97
+ forkAuthor?: {
98
+ platform: "github" | "gitlab";
99
+ user: string;
100
+ forkOrigin: string;
101
+ } | undefined;
102
+ workspaceId?: string | undefined;
103
+ force?: boolean | undefined;
38
104
  }>;
39
105
  handler: typeof activateIntent;
40
106
  };
@@ -1,10 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { request } from '../services/muninn-ipc.js';
3
3
  import { resolveOrigin } from './resolve-origin.js';
4
+ import { forkFieldsExtensions, extractForkFields } from './_fork-fields.js';
4
5
  export const activateIntentSchema = z.object({
5
6
  repoOrigin: z.string().optional().describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
6
7
  repoPath: z.string().describe('Local path to the repository root'),
7
8
  intentId: z.string().describe('The cloud ID (preferred) or local UUID of the existing intent to activate.'),
9
+ force: z.boolean().optional().default(false).describe('Bypass the per-repo active-intent lock. Set to true after the user has reviewed the lock conflict and chosen to take over.'),
10
+ ...forkFieldsExtensions,
8
11
  });
9
12
  export async function activateIntent(input) {
10
13
  const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
@@ -15,24 +18,61 @@ export async function activateIntent(input) {
15
18
  return {
16
19
  success: true,
17
20
  intentId: input.intentId,
21
+ action: 'already_active',
18
22
  previousActiveId,
19
23
  message: `Intent ${input.intentId.substring(0, 8)} is already active`,
20
24
  };
21
25
  }
22
26
  // Set the intent as active
23
- await request('intent', 'set-active', {
27
+ const setRes = await request('intent', 'set-active', {
24
28
  repoOrigin: actualOrigin,
25
29
  intentId: input.intentId,
30
+ force: input.force || false,
31
+ ...extractForkFields(input),
26
32
  });
33
+ if (setRes.conflict === true && setRes.conflictType === 'active_intent_lock') {
34
+ const lockConflict = await buildLockConflictDetails(actualOrigin, setRes.existingIntentId);
35
+ const idShort = setRes.existingIntentId.substring(0, 8);
36
+ const who = lockConflict.author ? ` by ${lockConflict.author}` : '';
37
+ const titlePart = lockConflict.title ? ` "${lockConflict.title}"` : '';
38
+ return {
39
+ success: false,
40
+ intentId: input.intentId,
41
+ action: 'conflict',
42
+ lockConflict,
43
+ message: `Active-intent lock: repo already owns intent ${idShort}${titlePart}${who}. ` +
44
+ `Call activate_intent again with force=true to take over, complete_intent on ${idShort} first, ` +
45
+ `or choose a different intent.`,
46
+ };
47
+ }
27
48
  return {
28
49
  success: true,
29
50
  intentId: input.intentId,
51
+ action: 'activated',
30
52
  previousActiveId: previousActiveId || undefined,
31
53
  message: previousActiveId
32
54
  ? `Activated intent ${input.intentId.substring(0, 8)} (was: ${previousActiveId.substring(0, 8)})`
33
55
  : `Activated intent ${input.intentId.substring(0, 8)}`,
34
56
  };
35
57
  }
58
+ async function buildLockConflictDetails(repoOrigin, existingIntentId) {
59
+ try {
60
+ const res = await request('intent', 'get-active', { repoOrigin });
61
+ const intent = res.intent;
62
+ if (intent && intent.id === existingIntentId) {
63
+ return {
64
+ existingIntentId,
65
+ title: intent.title,
66
+ createdBy: intent.createdBy,
67
+ author: intent.authorInfo?.name || intent.author,
68
+ };
69
+ }
70
+ }
71
+ catch {
72
+ // Fall through to ID-only response
73
+ }
74
+ return { existingIntentId };
75
+ }
36
76
  export const activateIntentTool = {
37
77
  name: 'activate_intent',
38
78
  description: `Activate an existing intent by ID without creating a new one.
@@ -41,11 +81,27 @@ Use this to:
41
81
  - Switch to a different intent found via list_team_intents or get_relevant_context
42
82
  - Re-activate an intent that was deactivated (e.g., to complete it)
43
83
  - Resume work on a previously created intent
84
+ - Resume an "abandoned" or "pending" intent (see below)
44
85
 
45
86
  Accepts both cloud IDs (from get_relevant_context / API) and local UUIDs (from list_team_intents).
46
87
 
47
- If another intent is currently active, it will be replaced (not completed).
48
- To complete the previous intent first, call complete_intent before this tool.`,
88
+ Resuming abandoned / pending intents:
89
+ - Abandoned intents have their decisions soft-deleted (invisible to recall and
90
+ get_relevant_context). Activating one transparently restores them — single-intent
91
+ decisions for this intent get their soft-delete cleared so the prior reasoning
92
+ becomes visible again. Multi-intent decisions stay visible throughout (they were
93
+ never soft-deleted).
94
+ - Pending intents are intents auto-finalized by the orphan-recovery sweeper (24h
95
+ inactivity) — possibly with conflicts blocking the finalization. Their decisions
96
+ were never soft-deleted, so activating one is a clean resume; new ephemerals
97
+ accumulate in a fresh bucket and the next complete_intent distills only the new work.
98
+
99
+ Per-repo active-intent lock: if another session already has a different intent active on
100
+ this repo, the tool returns action="conflict" with lockConflict details. Present the
101
+ conflict to the user and choose one of:
102
+ - Take over: retry with force=true (displaces the other session's active intent).
103
+ - Complete first: call complete_intent on the existing intent, then retry.
104
+ - Cancel: choose a different intent or stop.`,
49
105
  inputSchema: activateIntentSchema,
50
106
  handler: activateIntent,
51
107
  };
@@ -1 +1 @@
1
- {"version":3,"file":"activate-intent.js","sourceRoot":"","sources":["../../src/tools/activate-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,CAAC,MAAM,oBAA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AAM,CAAC,UAAU,EAAE,IAAI,IAAI,MAAM,CAAC,MAAM;aACjD,CAAA;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,mCAAmC;IACrC,CAAC;IACD,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;6CA0B8B;IAC3C,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,cAAc;CACxB,CAAA"}
@@ -1,13 +1,39 @@
1
1
  import { z } from 'zod';
2
2
  export declare const checkActiveIntentSchema: z.ZodObject<{
3
+ forkAuthor: z.ZodOptional<z.ZodObject<{
4
+ platform: z.ZodEnum<["github", "gitlab"]>;
5
+ user: z.ZodString;
6
+ forkOrigin: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ platform: "github" | "gitlab";
9
+ user: string;
10
+ forkOrigin: string;
11
+ }, {
12
+ platform: "github" | "gitlab";
13
+ user: string;
14
+ forkOrigin: string;
15
+ }>>;
16
+ workspaceId: z.ZodOptional<z.ZodString>;
3
17
  repoOrigin: z.ZodOptional<z.ZodString>;
4
18
  repoPath: z.ZodString;
5
19
  }, "strip", z.ZodTypeAny, {
6
20
  repoPath: string;
7
21
  repoOrigin?: string | undefined;
22
+ forkAuthor?: {
23
+ platform: "github" | "gitlab";
24
+ user: string;
25
+ forkOrigin: string;
26
+ } | undefined;
27
+ workspaceId?: string | undefined;
8
28
  }, {
9
29
  repoPath: string;
10
30
  repoOrigin?: string | undefined;
31
+ forkAuthor?: {
32
+ platform: "github" | "gitlab";
33
+ user: string;
34
+ forkOrigin: string;
35
+ } | undefined;
36
+ workspaceId?: string | undefined;
11
37
  }>;
12
38
  export type CheckActiveIntentInput = z.infer<typeof checkActiveIntentSchema>;
13
39
  export interface IntentBlock {
@@ -25,7 +51,19 @@ export interface ActiveIntentResponse {
25
51
  description: string;
26
52
  templateType: 'feature' | 'refactor' | 'exploration';
27
53
  constraints: string[];
54
+ /**
55
+ * `active` — currently being worked on (default).
56
+ * `pending` — auto-finalized by the sweeper or blocked at completion by
57
+ * conflicts; reportable as "live context" so the agent can prompt the
58
+ * user to resume via activate_intent or finalize via complete_intent.
59
+ */
28
60
  status: string;
61
+ /**
62
+ * Set when status === 'pending'. One of `sweeper-auto-finalize` (24h
63
+ * inactivity, no conflicts) or `sweeper-blocked-conflicts` (24h
64
+ * inactivity, distilled decisions contradicted standards).
65
+ */
66
+ pendingReason?: string;
29
67
  branch: string;
30
68
  forkedFrom?: string;
31
69
  blocks: IntentBlock[];
@@ -36,14 +74,40 @@ export declare const checkActiveIntentTool: {
36
74
  name: string;
37
75
  description: string;
38
76
  inputSchema: z.ZodObject<{
77
+ forkAuthor: z.ZodOptional<z.ZodObject<{
78
+ platform: z.ZodEnum<["github", "gitlab"]>;
79
+ user: z.ZodString;
80
+ forkOrigin: z.ZodString;
81
+ }, "strip", z.ZodTypeAny, {
82
+ platform: "github" | "gitlab";
83
+ user: string;
84
+ forkOrigin: string;
85
+ }, {
86
+ platform: "github" | "gitlab";
87
+ user: string;
88
+ forkOrigin: string;
89
+ }>>;
90
+ workspaceId: z.ZodOptional<z.ZodString>;
39
91
  repoOrigin: z.ZodOptional<z.ZodString>;
40
92
  repoPath: z.ZodString;
41
93
  }, "strip", z.ZodTypeAny, {
42
94
  repoPath: string;
43
95
  repoOrigin?: string | undefined;
96
+ forkAuthor?: {
97
+ platform: "github" | "gitlab";
98
+ user: string;
99
+ forkOrigin: string;
100
+ } | undefined;
101
+ workspaceId?: string | undefined;
44
102
  }, {
45
103
  repoPath: string;
46
104
  repoOrigin?: string | undefined;
105
+ forkAuthor?: {
106
+ platform: "github" | "gitlab";
107
+ user: string;
108
+ forkOrigin: string;
109
+ } | undefined;
110
+ workspaceId?: string | undefined;
47
111
  }>;
48
112
  handler: typeof checkActiveIntent;
49
113
  };
@@ -1,14 +1,17 @@
1
1
  import { z } from 'zod';
2
2
  import { request } from '../services/muninn-ipc.js';
3
3
  import { resolveOrigin } from './resolve-origin.js';
4
+ import { forkFieldsExtensions, extractForkFields } from './_fork-fields.js';
4
5
  export const checkActiveIntentSchema = z.object({
5
6
  repoOrigin: z.string().optional().describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
6
- repoPath: z.string().describe('Local path to the repository root')
7
+ repoPath: z.string().describe('Local path to the repository root'),
8
+ ...forkFieldsExtensions,
7
9
  });
8
10
  export async function checkActiveIntent(input) {
9
11
  const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
10
12
  const res = await request('intent', 'get-active', {
11
13
  repoOrigin: actualOrigin,
14
+ ...extractForkFields(input),
12
15
  });
13
16
  // Muninn returns { hasActiveIntent, intentId, intent }
14
17
  const intent = res.intent;
@@ -24,6 +27,7 @@ export async function checkActiveIntent(input) {
24
27
  templateType: (intent.templateType || 'feature'),
25
28
  constraints: intent.constraints || [],
26
29
  status: intent.status || 'active',
30
+ pendingReason: intent.pendingReason,
27
31
  branch: intent.branch || '',
28
32
  forkedFrom: intent.forkedFrom,
29
33
  blocks: [] // Blocks are tracked separately by intent-block service
@@ -40,7 +44,17 @@ you should ask the user to confirm intent details and then call create_and_activ
40
44
  An active intent tracks what the user is working on, enabling:
41
45
  - Better code context for AI-generated changes
42
46
  - Conflict detection with team members
43
- - Automatic assignment of code blocks to the intent`,
47
+ - Automatic assignment of code blocks to the intent
48
+
49
+ Status semantics:
50
+ - "active" — normal, in-progress.
51
+ - "pending" — auto-finalized by the orphan-recovery sweeper or blocked at
52
+ completion by conflicts. Pending is treated as live context for the repo:
53
+ prompt the user to resume the work (activate_intent) or finalize it
54
+ (complete_intent) before starting new unrelated work. Inspect "pendingReason"
55
+ to tell the user WHY the intent went pending — "sweeper-auto-finalize"
56
+ (24h idle) or "sweeper-blocked-conflicts" (decisions contradicted standards
57
+ on the auto-finalize attempt).`,
44
58
  inputSchema: checkActiveIntentSchema,
45
59
  handler: checkActiveIntent
46
60
  };