@kawacode/mcp 5.2.2 → 6.1.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 (86) hide show
  1. package/CLAUDE.md.example +11 -3
  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 +201 -0
  7. package/build/kawacode-on-pre-edit.js.map +1 -0
  8. package/build/kawacode-on-stop.d.ts +33 -0
  9. package/build/kawacode-on-stop.js +88 -0
  10. package/build/kawacode-on-stop.js.map +1 -0
  11. package/build/pre-edit/path-resolve.d.ts +32 -0
  12. package/build/pre-edit/path-resolve.js +52 -0
  13. package/build/pre-edit/path-resolve.js.map +1 -0
  14. package/build/pre-edit/path-resolve.test.d.ts +1 -0
  15. package/build/pre-edit/path-resolve.test.js +105 -0
  16. package/build/pre-edit/path-resolve.test.js.map +1 -0
  17. package/build/prompts/intent-first-workflow.js +2 -2
  18. package/build/services/muninn-ipc.js +11 -3
  19. package/build/services/muninn-ipc.js.map +1 -1
  20. package/build/tools/_fork-fields.d.ts +84 -0
  21. package/build/tools/_fork-fields.js +65 -0
  22. package/build/tools/_fork-fields.js.map +1 -0
  23. package/build/tools/activate-intent.d.ts +66 -0
  24. package/build/tools/activate-intent.js +59 -3
  25. package/build/tools/activate-intent.js.map +1 -1
  26. package/build/tools/check-active-intent.d.ts +64 -0
  27. package/build/tools/check-active-intent.js +16 -2
  28. package/build/tools/check-active-intent.js.map +1 -1
  29. package/build/tools/complete-intent.d.ts +115 -4
  30. package/build/tools/complete-intent.js +138 -12
  31. package/build/tools/complete-intent.js.map +1 -1
  32. package/build/tools/create-intent.d.ts +73 -1
  33. package/build/tools/create-intent.js +105 -7
  34. package/build/tools/create-intent.js.map +1 -1
  35. package/build/tools/detect-intent-conflicts.d.ts +52 -0
  36. package/build/tools/detect-intent-conflicts.js +14 -10
  37. package/build/tools/detect-intent-conflicts.js.map +1 -1
  38. package/build/tools/edit-session-decision.d.ts +76 -12
  39. package/build/tools/edit-session-decision.js +11 -2
  40. package/build/tools/edit-session-decision.js.map +1 -1
  41. package/build/tools/evolve-decisions.d.ts +52 -0
  42. package/build/tools/evolve-decisions.js +14 -15
  43. package/build/tools/evolve-decisions.js.map +1 -1
  44. package/build/tools/get-intent-changes.d.ts +52 -0
  45. package/build/tools/get-intent-changes.js +4 -1
  46. package/build/tools/get-intent-changes.js.map +1 -1
  47. package/build/tools/get-intents-for-file.d.ts +52 -0
  48. package/build/tools/get-intents-for-file.js +4 -1
  49. package/build/tools/get-intents-for-file.js.map +1 -1
  50. package/build/tools/get-intents-for-lines.d.ts +52 -0
  51. package/build/tools/get-intents-for-lines.js +4 -1
  52. package/build/tools/get-intents-for-lines.js.map +1 -1
  53. package/build/tools/get-project-decisions.d.ts +52 -0
  54. package/build/tools/get-project-decisions.js +4 -1
  55. package/build/tools/get-project-decisions.js.map +1 -1
  56. package/build/tools/get-relevant-context.d.ts +54 -0
  57. package/build/tools/get-relevant-context.js +19 -24
  58. package/build/tools/get-relevant-context.js.map +1 -1
  59. package/build/tools/get-session-decisions.d.ts +53 -0
  60. package/build/tools/get-session-decisions.js +6 -2
  61. package/build/tools/get-session-decisions.js.map +1 -1
  62. package/build/tools/index.d.ts +628 -18
  63. package/build/tools/index.js +12 -3
  64. package/build/tools/index.js.map +1 -1
  65. package/build/tools/infer-history.d.ts +6 -0
  66. package/build/tools/infer-history.js +28 -15
  67. package/build/tools/infer-history.js.map +1 -1
  68. package/build/tools/list-team-intents.d.ts +58 -6
  69. package/build/tools/list-team-intents.js +5 -2
  70. package/build/tools/list-team-intents.js.map +1 -1
  71. package/build/tools/log-work.d.ts +52 -0
  72. package/build/tools/log-work.js +4 -1
  73. package/build/tools/log-work.js.map +1 -1
  74. package/build/tools/pre-edit-acknowledge.d.ts +92 -0
  75. package/build/tools/pre-edit-acknowledge.js +48 -0
  76. package/build/tools/pre-edit-acknowledge.js.map +1 -0
  77. package/build/tools/pre-edit-decision-check.d.ts +141 -0
  78. package/build/tools/pre-edit-decision-check.js +77 -0
  79. package/build/tools/pre-edit-decision-check.js.map +1 -0
  80. package/build/tools/record-decision.d.ts +94 -12
  81. package/build/tools/record-decision.js +18 -1
  82. package/build/tools/record-decision.js.map +1 -1
  83. package/build/tools/update-intent.d.ts +60 -8
  84. package/build/tools/update-intent.js +6 -1
  85. package/build/tools/update-intent.js.map +1 -1
  86. package/package.json +6 -3
@@ -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,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6EAA6E,CAAC;IACzH,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAClE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4EAA4E,CAAC;CAC5G,CAAC,CAAA;AAWF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B;IAC7D,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEpE,4CAA4C;IAC5C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAA;IACrF,MAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAA;IAEzE,IAAI,gBAAgB,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC;QACxC,OAAO;YACL,OAAO,EAAE,I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AAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;KACzD,CAAA;AACH,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,UAAkB,EAAE,gBAAwB;IAClF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;QACjE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;QACzB,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE,KAAK,gBAAgB,EAAE,CAAC;YAC7C,OAAO;gBACL,gBAAgB;gBAChB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,MAAM,EAAE,MAAM,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
  };
@@ -1 +1 @@
1
- {"version":3,"file":"check-active-intent.js","sourceRoot":"","sources":["../../src/tools/check-active-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,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6EAA6E,CAAC;IACzH,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;CACnE,CAAC,CAAA;AA2BF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAA6B;IACnE,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEpE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE;QAChD,UAAU,EAAE,YAAY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H,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE;;;;;;;;;;;;;;;;;;iCAkBkB;IAC/B,WAAW,EAAE,uBAAuB;IACpC,OAAO,EAAE,iBAAiB;CAC3B,CAAA"}
@@ -1,5 +1,19 @@
1
1
  import { z } from 'zod';
2
2
  export declare const completeIntentSchema: 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.ZodOptional<z.ZodString>;
@@ -7,34 +21,119 @@ export declare const completeIntentSchema: z.ZodObject<{
7
21
  status: z.ZodDefault<z.ZodEnum<["committed", "pushed", "done", "abandoned", "superseded"]>>;
8
22
  supersededBy: z.ZodOptional<z.ZodString>;
9
23
  }, "strip", z.ZodTypeAny, {
10
- repoPath: string;
11
24
  status: "committed" | "pushed" | "done" | "abandoned" | "superseded";
25
+ repoPath: string;
12
26
  repoOrigin?: string | undefined;
27
+ forkAuthor?: {
28
+ platform: "github" | "gitlab";
29
+ user: string;
30
+ forkOrigin: string;
31
+ } | undefined;
32
+ workspaceId?: string | undefined;
13
33
  intentId?: string | undefined;
14
34
  commitSha?: string | undefined;
15
35
  supersededBy?: string | undefined;
16
36
  }, {
17
37
  repoPath: string;
18
- repoOrigin?: string | undefined;
19
38
  status?: "committed" | "pushed" | "done" | "abandoned" | "superseded" | undefined;
39
+ repoOrigin?: string | undefined;
40
+ forkAuthor?: {
41
+ platform: "github" | "gitlab";
42
+ user: string;
43
+ forkOrigin: string;
44
+ } | undefined;
45
+ workspaceId?: string | undefined;
20
46
  intentId?: string | undefined;
21
47
  commitSha?: string | undefined;
22
48
  supersededBy?: string | undefined;
23
49
  }>;
24
50
  export type CompleteIntentInput = z.infer<typeof completeIntentSchema>;
51
+ /**
52
+ * One contradiction between a distilled proposed decision and an existing
53
+ * standard decision in the repo. Surfaced when distillation produces decisions
54
+ * that conflict with previously-recorded ones (PRD §5.2 step 5b / §7.2).
55
+ */
56
+ export interface ConflictMatch {
57
+ proposedDecisionSummary: string;
58
+ proposedDecisionRationale: string;
59
+ conflictsWith: {
60
+ decisionId: string;
61
+ summary: string;
62
+ intentTitle?: string;
63
+ author?: string;
64
+ };
65
+ sharedConcern?: string;
66
+ description?: string;
67
+ }
25
68
  export interface CompleteIntentResponse {
26
69
  success: boolean;
27
70
  intentId: string;
28
71
  previousStatus: string;
72
+ /**
73
+ * The status after this call. Stays "active" when distillation surfaces
74
+ * conflicts (PRD §5.2 step 5b — no decisions written, no transition).
75
+ */
29
76
  newStatus: string;
30
77
  commitSha?: string;
31
78
  message: string;
79
+ /**
80
+ * Number of distilled standard decisions written to the API on a clean
81
+ * completion. Omitted when there were no ephemerals, when the v2 pipeline
82
+ * is disabled, or when conflicts blocked the write.
83
+ *
84
+ * Decision *content* is intentionally not surfaced here — it's already
85
+ * visible via the orchestration panel and via get_intent_decisions /
86
+ * get_relevant_context. Inlining the full list would just duplicate that
87
+ * channel and add noise to the agent's reply.
88
+ */
89
+ committedDecisionCount?: number;
90
+ /**
91
+ * Non-empty when the proposed-decision distillation contradicted existing
92
+ * standard decisions. Each entry pairs the proposed decision with the
93
+ * specific standard decision it contradicts, so the agent can surface the
94
+ * pair to the user. When conflicts is non-empty, success=false and
95
+ * newStatus stays "active" — the user resolves and retries.
96
+ */
97
+ conflicts?: ConflictMatch[];
98
+ /**
99
+ * Set when success=false to discriminate between:
100
+ * - "conflicts" → see `conflicts[]`
101
+ * - "transient-failure" → distiller LLM call or /check-conflicts API errored;
102
+ * `failedStage` and `error` carry diagnostics, the user retries.
103
+ */
104
+ reason?: 'conflicts' | 'transient-failure';
105
+ failedStage?: string;
106
+ error?: string;
107
+ /**
108
+ * Phase 3.5 — true when an API write call (decisions/sync, intents/PATCH)
109
+ * was queued for later replay because the API was unreachable. Work is
110
+ * "done" from the user's perspective; surface a heads-up. `deferredStages`
111
+ * names which write(s) were queued.
112
+ */
113
+ apiSyncDeferred?: boolean;
114
+ deferredStages?: string[];
115
+ deferredDecisionCount?: number;
116
+ deferredError?: string;
32
117
  }
33
118
  export declare function completeIntent(input: CompleteIntentInput): Promise<CompleteIntentResponse>;
34
119
  export declare const completeIntentTool: {
35
120
  name: string;
36
121
  description: string;
37
122
  inputSchema: z.ZodObject<{
123
+ forkAuthor: z.ZodOptional<z.ZodObject<{
124
+ platform: z.ZodEnum<["github", "gitlab"]>;
125
+ user: z.ZodString;
126
+ forkOrigin: z.ZodString;
127
+ }, "strip", z.ZodTypeAny, {
128
+ platform: "github" | "gitlab";
129
+ user: string;
130
+ forkOrigin: string;
131
+ }, {
132
+ platform: "github" | "gitlab";
133
+ user: string;
134
+ forkOrigin: string;
135
+ }>>;
136
+ workspaceId: z.ZodOptional<z.ZodString>;
38
137
  repoOrigin: z.ZodOptional<z.ZodString>;
39
138
  repoPath: z.ZodString;
40
139
  intentId: z.ZodOptional<z.ZodString>;
@@ -42,16 +141,28 @@ export declare const completeIntentTool: {
42
141
  status: z.ZodDefault<z.ZodEnum<["committed", "pushed", "done", "abandoned", "superseded"]>>;
43
142
  supersededBy: z.ZodOptional<z.ZodString>;
44
143
  }, "strip", z.ZodTypeAny, {
45
- repoPath: string;
46
144
  status: "committed" | "pushed" | "done" | "abandoned" | "superseded";
145
+ repoPath: string;
47
146
  repoOrigin?: string | undefined;
147
+ forkAuthor?: {
148
+ platform: "github" | "gitlab";
149
+ user: string;
150
+ forkOrigin: string;
151
+ } | undefined;
152
+ workspaceId?: string | undefined;
48
153
  intentId?: string | undefined;
49
154
  commitSha?: string | undefined;
50
155
  supersededBy?: string | undefined;
51
156
  }, {
52
157
  repoPath: string;
53
- repoOrigin?: string | undefined;
54
158
  status?: "committed" | "pushed" | "done" | "abandoned" | "superseded" | undefined;
159
+ repoOrigin?: string | undefined;
160
+ forkAuthor?: {
161
+ platform: "github" | "gitlab";
162
+ user: string;
163
+ forkOrigin: string;
164
+ } | undefined;
165
+ workspaceId?: string | undefined;
55
166
  intentId?: string | undefined;
56
167
  commitSha?: string | undefined;
57
168
  supersededBy?: string | undefined;