@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.
- package/CLAUDE.md.example +11 -3
- package/README.md +54 -198
- package/build/index.js +10 -1
- package/build/index.js.map +1 -1
- package/build/kawacode-on-pre-edit.d.ts +27 -0
- package/build/kawacode-on-pre-edit.js +201 -0
- package/build/kawacode-on-pre-edit.js.map +1 -0
- package/build/kawacode-on-stop.d.ts +33 -0
- package/build/kawacode-on-stop.js +88 -0
- package/build/kawacode-on-stop.js.map +1 -0
- package/build/pre-edit/path-resolve.d.ts +32 -0
- package/build/pre-edit/path-resolve.js +52 -0
- package/build/pre-edit/path-resolve.js.map +1 -0
- package/build/pre-edit/path-resolve.test.d.ts +1 -0
- package/build/pre-edit/path-resolve.test.js +105 -0
- package/build/pre-edit/path-resolve.test.js.map +1 -0
- package/build/prompts/intent-first-workflow.js +2 -2
- package/build/services/muninn-ipc.js +11 -3
- package/build/services/muninn-ipc.js.map +1 -1
- package/build/tools/_fork-fields.d.ts +84 -0
- package/build/tools/_fork-fields.js +65 -0
- package/build/tools/_fork-fields.js.map +1 -0
- package/build/tools/activate-intent.d.ts +66 -0
- package/build/tools/activate-intent.js +59 -3
- package/build/tools/activate-intent.js.map +1 -1
- package/build/tools/check-active-intent.d.ts +64 -0
- package/build/tools/check-active-intent.js +16 -2
- package/build/tools/check-active-intent.js.map +1 -1
- package/build/tools/complete-intent.d.ts +115 -4
- package/build/tools/complete-intent.js +138 -12
- package/build/tools/complete-intent.js.map +1 -1
- package/build/tools/create-intent.d.ts +73 -1
- package/build/tools/create-intent.js +105 -7
- package/build/tools/create-intent.js.map +1 -1
- package/build/tools/detect-intent-conflicts.d.ts +52 -0
- package/build/tools/detect-intent-conflicts.js +14 -10
- package/build/tools/detect-intent-conflicts.js.map +1 -1
- package/build/tools/edit-session-decision.d.ts +76 -12
- package/build/tools/edit-session-decision.js +11 -2
- package/build/tools/edit-session-decision.js.map +1 -1
- package/build/tools/evolve-decisions.d.ts +52 -0
- package/build/tools/evolve-decisions.js +14 -15
- package/build/tools/evolve-decisions.js.map +1 -1
- package/build/tools/get-intent-changes.d.ts +52 -0
- package/build/tools/get-intent-changes.js +4 -1
- package/build/tools/get-intent-changes.js.map +1 -1
- package/build/tools/get-intents-for-file.d.ts +52 -0
- package/build/tools/get-intents-for-file.js +4 -1
- package/build/tools/get-intents-for-file.js.map +1 -1
- package/build/tools/get-intents-for-lines.d.ts +52 -0
- package/build/tools/get-intents-for-lines.js +4 -1
- package/build/tools/get-intents-for-lines.js.map +1 -1
- package/build/tools/get-project-decisions.d.ts +52 -0
- package/build/tools/get-project-decisions.js +4 -1
- package/build/tools/get-project-decisions.js.map +1 -1
- package/build/tools/get-relevant-context.d.ts +54 -0
- package/build/tools/get-relevant-context.js +19 -24
- package/build/tools/get-relevant-context.js.map +1 -1
- package/build/tools/get-session-decisions.d.ts +53 -0
- package/build/tools/get-session-decisions.js +6 -2
- package/build/tools/get-session-decisions.js.map +1 -1
- package/build/tools/index.d.ts +628 -18
- package/build/tools/index.js +12 -3
- package/build/tools/index.js.map +1 -1
- package/build/tools/infer-history.d.ts +6 -0
- package/build/tools/infer-history.js +28 -15
- package/build/tools/infer-history.js.map +1 -1
- package/build/tools/list-team-intents.d.ts +58 -6
- package/build/tools/list-team-intents.js +5 -2
- package/build/tools/list-team-intents.js.map +1 -1
- package/build/tools/log-work.d.ts +52 -0
- package/build/tools/log-work.js +4 -1
- package/build/tools/log-work.js.map +1 -1
- package/build/tools/pre-edit-acknowledge.d.ts +92 -0
- package/build/tools/pre-edit-acknowledge.js +48 -0
- package/build/tools/pre-edit-acknowledge.js.map +1 -0
- package/build/tools/pre-edit-decision-check.d.ts +141 -0
- package/build/tools/pre-edit-decision-check.js +77 -0
- package/build/tools/pre-edit-decision-check.js.map +1 -0
- package/build/tools/record-decision.d.ts +94 -12
- package/build/tools/record-decision.js +18 -1
- package/build/tools/record-decision.js.map +1 -1
- package/build/tools/update-intent.d.ts +60 -8
- package/build/tools/update-intent.js +6 -1
- package/build/tools/update-intent.js.map +1 -1
- package/package.json +6 -3
|
@@ -1,6 +1,7 @@
|
|
|
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 completeIntentSchema = 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'),
|
|
@@ -8,7 +9,8 @@ export const completeIntentSchema = z.object({
|
|
|
8
9
|
commitSha: z.string().optional().describe('The git commit SHA to associate with this intent (if already committed)'),
|
|
9
10
|
status: z.enum(['committed', 'pushed', 'done', 'abandoned', 'superseded']).default('committed')
|
|
10
11
|
.describe('The new status for the intent. Use "committed" after git commit, "done" when work is complete, "abandoned" to discard, "superseded" when another intent replaces this one.'),
|
|
11
|
-
supersededBy: z.string().optional().describe('Intent ID that supersedes this one. Required when status is "superseded".')
|
|
12
|
+
supersededBy: z.string().optional().describe('Intent ID that supersedes this one. Required when status is "superseded".'),
|
|
13
|
+
...forkFieldsExtensions,
|
|
12
14
|
});
|
|
13
15
|
export async function completeIntent(input) {
|
|
14
16
|
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
@@ -38,28 +40,114 @@ export async function completeIntent(input) {
|
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
}
|
|
43
|
+
// Muninn's v2 distillation pipeline (Sonnet distill + per-pair Haiku conflict
|
|
44
|
+
// judge + recall embeddings) can run well past the 30s default — measured
|
|
45
|
+
// 51s for superseded on an M3 (see kawa.muninn intent.rs). Override the
|
|
46
|
+
// per-call timeout so conflict / transient-failure responses actually come
|
|
47
|
+
// back instead of the client hanging up first. Mirrors inference:estimate's
|
|
48
|
+
// ESTIMATE_TIMEOUT_MS (decision 092172fb: per-call override, not a raised global).
|
|
49
|
+
const COMPLETE_TIMEOUT_MS = 180_000;
|
|
41
50
|
const res = await request('intent', 'complete', {
|
|
42
51
|
repoOrigin: actualOrigin,
|
|
43
52
|
status: input.status,
|
|
44
53
|
commitSha: input.commitSha,
|
|
45
54
|
supersededBy: input.supersededBy,
|
|
46
|
-
|
|
55
|
+
...extractForkFields(input),
|
|
56
|
+
}, COMPLETE_TIMEOUT_MS);
|
|
47
57
|
const intentId = res.intentId || '';
|
|
48
58
|
const intentTitle = res.intentTitle || 'Intent';
|
|
49
59
|
const previousStatus = res.previousStatus || 'active';
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
const success = res.success !== false;
|
|
61
|
+
const conflicts = Array.isArray(res.conflicts) ? res.conflicts : [];
|
|
62
|
+
const committedDecisionCount = typeof res.committedDecisionCount === 'number' ? res.committedDecisionCount : undefined;
|
|
63
|
+
const reason = res.reason === 'conflicts' || res.reason === 'transient-failure' ? res.reason : undefined;
|
|
64
|
+
const apiSyncDeferred = res.apiSyncDeferred === true;
|
|
65
|
+
// Branch on the four §7.2 / §7.3 outcome shapes — pick the message that
|
|
66
|
+
// tells the agent exactly what to surface to the user.
|
|
67
|
+
let newStatus;
|
|
68
|
+
let message;
|
|
69
|
+
if (!success && reason === 'conflicts') {
|
|
70
|
+
// PRD §5.2 step 5b — distilled decisions contradicted standards. No write,
|
|
71
|
+
// no transition, bucket preserved. The agent's job is to surface each
|
|
72
|
+
// conflict to the user and ask how to resolve.
|
|
73
|
+
newStatus = res.status || 'active';
|
|
74
|
+
const lines = [
|
|
75
|
+
`Cannot complete: ${conflicts.length} conflict(s) between proposed decisions and existing standards.`,
|
|
76
|
+
'',
|
|
77
|
+
'For each conflict below, surface BOTH sides side-by-side to the user and ask how to resolve.',
|
|
78
|
+
'Common resolution paths:',
|
|
79
|
+
' (A) Record a superseding decision: record_decision(type="fork", supersedes=["<existing-decision-id>"], rationale=...). Then retry complete_intent.',
|
|
80
|
+
' (B) Abandon the intent: complete_intent(status="abandoned"). Decisions are soft-deleted but recoverable via activate_intent.',
|
|
81
|
+
' (C) Keep the intent active and continue working.',
|
|
82
|
+
'',
|
|
83
|
+
'DO NOT silently retry — every retry runs the distiller again and produces the same conflicts.',
|
|
84
|
+
'',
|
|
85
|
+
];
|
|
86
|
+
conflicts.forEach((c, i) => {
|
|
87
|
+
lines.push(`[${i + 1}] Proposed: ${c.proposedDecisionSummary}`);
|
|
88
|
+
const cw = c.conflictsWith || {};
|
|
89
|
+
const author = cw.author ? ` by ${cw.author}` : '';
|
|
90
|
+
const intentPart = cw.intentTitle ? ` (intent: "${cw.intentTitle}")` : '';
|
|
91
|
+
lines.push(` Conflicts with: ${cw.summary || cw.decisionId || '(unknown)'}${intentPart}${author}`);
|
|
92
|
+
if (c.description)
|
|
93
|
+
lines.push(` ${c.description}`);
|
|
94
|
+
lines.push('');
|
|
95
|
+
});
|
|
96
|
+
message = lines.join('\n');
|
|
97
|
+
}
|
|
98
|
+
else if (!success && reason === 'transient-failure') {
|
|
99
|
+
// Distiller LLM error or /check-conflicts API error. Bucket re-populated,
|
|
100
|
+
// intent stays active. User decides whether to wait + retry or abandon.
|
|
101
|
+
newStatus = res.status || 'active';
|
|
102
|
+
const stage = res.failedStage ? ` (${res.failedStage})` : '';
|
|
103
|
+
const errPart = res.error ? `: ${res.error}` : '';
|
|
104
|
+
message =
|
|
105
|
+
`Could not complete intent "${intentTitle}" — transient failure${stage}${errPart}. ` +
|
|
106
|
+
`The ephemerals were preserved. Wait for the underlying issue to clear, then retry complete_intent. ` +
|
|
107
|
+
`If retrying repeatedly fails, the user can abandon the intent (complete_intent(status="abandoned")).`;
|
|
108
|
+
}
|
|
109
|
+
else if (!success) {
|
|
110
|
+
// Catch-all for legacy / unexpected error shapes.
|
|
111
|
+
newStatus = res.newStatus || res.status || input.status;
|
|
112
|
+
message = `Failed to complete intent "${intentTitle}".`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Clean completion. Note: Phase 3.5 may have queued writes for later
|
|
116
|
+
// replay — the response is success=true but apiSyncDeferred=true.
|
|
117
|
+
newStatus = res.newStatus || input.status;
|
|
118
|
+
const statusMessages = {
|
|
119
|
+
committed: `Intent "${intentTitle}" marked as committed`,
|
|
120
|
+
pushed: `Intent "${intentTitle}" marked as pushed`,
|
|
121
|
+
done: `Intent "${intentTitle}" marked as done`,
|
|
122
|
+
abandoned: `Intent "${intentTitle}" abandoned`,
|
|
123
|
+
superseded: `Intent "${intentTitle}" marked as superseded`,
|
|
124
|
+
};
|
|
125
|
+
const statusMsg = statusMessages[input.status] || `Intent "${intentTitle}" updated`;
|
|
126
|
+
const shaPart = input.commitSha ? ` (commit: ${input.commitSha.substring(0, 7)})` : '';
|
|
127
|
+
const distilledPart = committedDecisionCount && committedDecisionCount > 0
|
|
128
|
+
? ` — ${committedDecisionCount} distilled decision(s) recorded`
|
|
129
|
+
: '';
|
|
130
|
+
const deferredPart = apiSyncDeferred
|
|
131
|
+
? ` — API sync deferred (${(res.deferredStages || []).join(', ')}); will retry on the next sync tick`
|
|
132
|
+
: '';
|
|
133
|
+
message = statusMsg + shaPart + distilledPart + deferredPart;
|
|
134
|
+
}
|
|
56
135
|
return {
|
|
57
|
-
success
|
|
136
|
+
success,
|
|
58
137
|
intentId,
|
|
59
138
|
previousStatus,
|
|
60
|
-
newStatus
|
|
139
|
+
newStatus,
|
|
61
140
|
commitSha: input.commitSha,
|
|
62
|
-
message
|
|
141
|
+
message,
|
|
142
|
+
committedDecisionCount,
|
|
143
|
+
conflicts: conflicts.length > 0 ? conflicts : undefined,
|
|
144
|
+
reason,
|
|
145
|
+
failedStage: res.failedStage,
|
|
146
|
+
error: res.error,
|
|
147
|
+
apiSyncDeferred: apiSyncDeferred ? true : undefined,
|
|
148
|
+
deferredStages: Array.isArray(res.deferredStages) ? res.deferredStages : undefined,
|
|
149
|
+
deferredDecisionCount: typeof res.deferredDecisionCount === 'number' ? res.deferredDecisionCount : undefined,
|
|
150
|
+
deferredError: res.deferredError,
|
|
63
151
|
};
|
|
64
152
|
}
|
|
65
153
|
export const completeIntentTool = {
|
|
@@ -75,7 +163,45 @@ Status values:
|
|
|
75
163
|
- "committed": Code is committed locally (default)
|
|
76
164
|
- "pushed": Code has been pushed to remote
|
|
77
165
|
- "done": Work is fully complete
|
|
78
|
-
- "abandoned": Work was discarded without committing
|
|
166
|
+
- "abandoned": Work was discarded without committing
|
|
167
|
+
|
|
168
|
+
REQUIRED: Inspect the response after calling this tool. Four outcomes:
|
|
169
|
+
|
|
170
|
+
1. response.success === true:
|
|
171
|
+
The task is complete. Briefly acknowledge the commit and — if
|
|
172
|
+
response.committedDecisionCount > 0 — mention that N distilled architectural
|
|
173
|
+
decisions were recorded for the intent. Do NOT enumerate the decisions
|
|
174
|
+
inline; they're visible via the orchestration panel and via
|
|
175
|
+
get_intent_decisions / get_relevant_context if the user wants details.
|
|
176
|
+
If response.apiSyncDeferred === true, also mention that the API sync was
|
|
177
|
+
deferred; the queued writes will replay on the next sync tick.
|
|
178
|
+
|
|
179
|
+
2. response.success === false AND response.conflicts is non-empty:
|
|
180
|
+
The distillation produced decisions that contradict existing standards in
|
|
181
|
+
this repo. Status stays "active" and NO decisions were written.
|
|
182
|
+
Surface EACH conflict to the user with the proposed decision and the
|
|
183
|
+
conflicting standard decision side-by-side. Then ask the user how to
|
|
184
|
+
resolve. Common options to suggest:
|
|
185
|
+
(A) Record a superseding decision via record_decision(type="fork",
|
|
186
|
+
supersedes=["<existing-decision-id>"], rationale=...). Then retry
|
|
187
|
+
complete_intent — the distiller may now find the new superseding
|
|
188
|
+
decision in recall and the conflict resolves.
|
|
189
|
+
(B) Abandon the intent: complete_intent(status="abandoned"). Decisions
|
|
190
|
+
are soft-deleted but recoverable via activate_intent if the user
|
|
191
|
+
changes their mind.
|
|
192
|
+
(C) Keep the intent active and continue working.
|
|
193
|
+
DO NOT silently retry — every retry runs the distiller (and the per-pair
|
|
194
|
+
judge) again. Wait for the user's decision.
|
|
195
|
+
|
|
196
|
+
3. response.success === false AND response.reason === "transient-failure":
|
|
197
|
+
The distiller LLM call or the conflict-check API call errored. The
|
|
198
|
+
ephemerals are preserved (the bucket is intact), and the intent stays
|
|
199
|
+
"active". Tell the user the failure stage (response.failedStage) and the
|
|
200
|
+
underlying error, then suggest retrying once the issue clears, or
|
|
201
|
+
abandoning if the failure persists.
|
|
202
|
+
|
|
203
|
+
4. In a non-interactive (autonomous) session: log the conflicts at WARN level
|
|
204
|
+
and leave the intent active. A human review path exists via the panel.`,
|
|
79
205
|
inputSchema: completeIntentSchema,
|
|
80
206
|
handler: completeIntent
|
|
81
207
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete-intent.js","sourceRoot":"","sources":["../../src/tools/complete-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;
|
|
1
|
+
{"version":3,"file":"complete-intent.js","sourceRoot":"","sources":["../../src/tools/complete-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;AACnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE3E,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,C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KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACnD,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;QAClF,qBAAqB,EAAE,OAAO,GAAG,CAAC,qBAAqB,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS;QAC5G,aAAa,EAAE,GAAG,CAAC,aAAa;KACjC,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0EAiD2D;IACxE,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,cAAc;CACxB,CAAA"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const createAndActivateIntentSchema: 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
|
title: z.ZodString;
|
|
@@ -14,12 +28,24 @@ export declare const createAndActivateIntentSchema: z.ZodObject<{
|
|
|
14
28
|
templateType: "feature" | "refactor" | "exploration";
|
|
15
29
|
force: boolean;
|
|
16
30
|
repoOrigin?: string | undefined;
|
|
31
|
+
forkAuthor?: {
|
|
32
|
+
platform: "github" | "gitlab";
|
|
33
|
+
user: string;
|
|
34
|
+
forkOrigin: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
workspaceId?: string | undefined;
|
|
17
37
|
constraints?: string[] | undefined;
|
|
18
38
|
}, {
|
|
19
39
|
repoPath: string;
|
|
20
40
|
title: string;
|
|
21
41
|
description: string;
|
|
22
42
|
repoOrigin?: string | undefined;
|
|
43
|
+
forkAuthor?: {
|
|
44
|
+
platform: "github" | "gitlab";
|
|
45
|
+
user: string;
|
|
46
|
+
forkOrigin: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
workspaceId?: string | undefined;
|
|
23
49
|
templateType?: "feature" | "refactor" | "exploration" | undefined;
|
|
24
50
|
constraints?: string[] | undefined;
|
|
25
51
|
force?: boolean | undefined;
|
|
@@ -39,18 +65,52 @@ interface ConflictInfo {
|
|
|
39
65
|
oppositionDetected: boolean;
|
|
40
66
|
oppositionDetail: string | null;
|
|
41
67
|
}
|
|
68
|
+
export interface ActiveIntentLockConflict {
|
|
69
|
+
existingIntentId: string;
|
|
70
|
+
title?: string;
|
|
71
|
+
createdBy?: string;
|
|
72
|
+
author?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Soft-lock surfaced when a `pending` intent blocks creating a new one on
|
|
76
|
+
* the same repo. PRD_AGENT_COORDINATION_LAYER_02 §6.3 — the agent must prompt
|
|
77
|
+
* the user to abandon-or-finalize the pending one before proceeding.
|
|
78
|
+
*/
|
|
79
|
+
export interface PendingIntentBlocking {
|
|
80
|
+
intentId: string;
|
|
81
|
+
title?: string;
|
|
82
|
+
pendingReason?: string;
|
|
83
|
+
lastActivityAt?: string;
|
|
84
|
+
distilledDecisionCount?: number;
|
|
85
|
+
}
|
|
42
86
|
export interface CreateIntentResponse {
|
|
43
87
|
success: boolean;
|
|
44
88
|
intentId: string;
|
|
45
|
-
action: 'created' | 'reactivated' | 'conflict';
|
|
89
|
+
action: 'created' | 'reactivated' | 'conflict' | 'lock_conflict' | 'pending_blocked';
|
|
46
90
|
message: string;
|
|
47
91
|
conflicts?: ConflictInfo[];
|
|
92
|
+
lockConflict?: ActiveIntentLockConflict;
|
|
93
|
+
pendingIntent?: PendingIntentBlocking;
|
|
48
94
|
}
|
|
49
95
|
export declare function createAndActivateIntent(input: CreateIntentInput): Promise<CreateIntentResponse>;
|
|
50
96
|
export declare const createAndActivateIntentTool: {
|
|
51
97
|
name: string;
|
|
52
98
|
description: string;
|
|
53
99
|
inputSchema: z.ZodObject<{
|
|
100
|
+
forkAuthor: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
platform: z.ZodEnum<["github", "gitlab"]>;
|
|
102
|
+
user: z.ZodString;
|
|
103
|
+
forkOrigin: z.ZodString;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
platform: "github" | "gitlab";
|
|
106
|
+
user: string;
|
|
107
|
+
forkOrigin: string;
|
|
108
|
+
}, {
|
|
109
|
+
platform: "github" | "gitlab";
|
|
110
|
+
user: string;
|
|
111
|
+
forkOrigin: string;
|
|
112
|
+
}>>;
|
|
113
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
54
114
|
repoOrigin: z.ZodOptional<z.ZodString>;
|
|
55
115
|
repoPath: z.ZodString;
|
|
56
116
|
title: z.ZodString;
|
|
@@ -65,12 +125,24 @@ export declare const createAndActivateIntentTool: {
|
|
|
65
125
|
templateType: "feature" | "refactor" | "exploration";
|
|
66
126
|
force: boolean;
|
|
67
127
|
repoOrigin?: string | undefined;
|
|
128
|
+
forkAuthor?: {
|
|
129
|
+
platform: "github" | "gitlab";
|
|
130
|
+
user: string;
|
|
131
|
+
forkOrigin: string;
|
|
132
|
+
} | undefined;
|
|
133
|
+
workspaceId?: string | undefined;
|
|
68
134
|
constraints?: string[] | undefined;
|
|
69
135
|
}, {
|
|
70
136
|
repoPath: string;
|
|
71
137
|
title: string;
|
|
72
138
|
description: string;
|
|
73
139
|
repoOrigin?: string | undefined;
|
|
140
|
+
forkAuthor?: {
|
|
141
|
+
platform: "github" | "gitlab";
|
|
142
|
+
user: string;
|
|
143
|
+
forkOrigin: string;
|
|
144
|
+
} | undefined;
|
|
145
|
+
workspaceId?: string | undefined;
|
|
74
146
|
templateType?: "feature" | "refactor" | "exploration" | undefined;
|
|
75
147
|
constraints?: string[] | undefined;
|
|
76
148
|
force?: boolean | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
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 createAndActivateIntentSchema = 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'),
|
|
@@ -9,13 +10,12 @@ export const createAndActivateIntentSchema = z.object({
|
|
|
9
10
|
templateType: z.enum(['feature', 'refactor', 'exploration']).default('feature').describe('Type of work'),
|
|
10
11
|
constraints: z.array(z.string()).optional().describe('Requirements or constraints for this work'),
|
|
11
12
|
force: z.boolean().optional().default(false).describe('Bypass conflict detection. Set to true after the user has reviewed detected conflicts and chosen to proceed anyway.'),
|
|
13
|
+
...forkFieldsExtensions,
|
|
12
14
|
});
|
|
13
15
|
export async function createAndActivateIntent(input) {
|
|
14
16
|
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
15
|
-
// Step 1: Create
|
|
16
|
-
//
|
|
17
|
-
// dedups by embedding similarity (≥ 0.85) and runs automatic conflict
|
|
18
|
-
// detection against all other intents for the repo.
|
|
17
|
+
// Step 1: Create the intent. If a sufficiently similar one already exists, the
|
|
18
|
+
// server may reactivate it instead of creating a duplicate.
|
|
19
19
|
const createRes = await request('intent', 'create', {
|
|
20
20
|
repoOrigin: actualOrigin,
|
|
21
21
|
title: input.title,
|
|
@@ -24,7 +24,14 @@ export async function createAndActivateIntent(input) {
|
|
|
24
24
|
constraints: input.constraints || [],
|
|
25
25
|
scope: { type: 'repo', paths: [] },
|
|
26
26
|
force: input.force || false,
|
|
27
|
+
...extractForkFields(input),
|
|
27
28
|
});
|
|
29
|
+
// Pending-intent soft lock — surfaced before any API write per PRD §6.3.
|
|
30
|
+
// The agent's job is to ask the user to dispose of the pending one before
|
|
31
|
+
// proceeding. force=true bypasses this for autonomous runs.
|
|
32
|
+
if (createRes.pendingIntentBlocking) {
|
|
33
|
+
return buildPendingBlockedResponse(createRes.pendingIntentBlocking);
|
|
34
|
+
}
|
|
28
35
|
// Handle conflict detection — API returned 409 with conflict data.
|
|
29
36
|
// Return the conflicts to the caller (Claude Code) so it can present
|
|
30
37
|
// them to the user and optionally retry with force=true.
|
|
@@ -67,11 +74,38 @@ export async function createAndActivateIntent(input) {
|
|
|
67
74
|
throw new Error('Intent creation succeeded but no intent ID was returned');
|
|
68
75
|
}
|
|
69
76
|
const action = createRes.action === 'reactivated' ? 'reactivated' : 'created';
|
|
70
|
-
// Step 2: Set it as active
|
|
71
|
-
|
|
77
|
+
// Step 2: Set it as active.
|
|
78
|
+
// The per-repo lock may reject this step even though the intent itself was created —
|
|
79
|
+
// forward force to Muninn and surface the lock conflict separately from the
|
|
80
|
+
// content-similarity conflict that createRes handles above.
|
|
81
|
+
const setRes = await request('intent', 'set-active', {
|
|
72
82
|
repoOrigin: actualOrigin,
|
|
73
83
|
intentId,
|
|
84
|
+
force: input.force || false,
|
|
85
|
+
...extractForkFields(input),
|
|
74
86
|
});
|
|
87
|
+
// The set-active step has its own pending-intent soft-lock check (the lock
|
|
88
|
+
// holder may have transitioned to pending between steps 1 and 2, or the
|
|
89
|
+
// pre-check on create may have been skipped because the active intent was
|
|
90
|
+
// not the lock holder). Surface the same shaped response.
|
|
91
|
+
if (setRes.pendingIntentBlocking) {
|
|
92
|
+
return buildPendingBlockedResponse(setRes.pendingIntentBlocking, intentId);
|
|
93
|
+
}
|
|
94
|
+
if (setRes.conflict === true && setRes.conflictType === 'active_intent_lock') {
|
|
95
|
+
const lockConflict = await buildLockConflictDetails(actualOrigin, setRes.existingIntentId);
|
|
96
|
+
const idShort = setRes.existingIntentId.substring(0, 8);
|
|
97
|
+
const who = lockConflict.author ? ` by ${lockConflict.author}` : '';
|
|
98
|
+
const titlePart = lockConflict.title ? ` "${lockConflict.title}"` : '';
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
intentId,
|
|
102
|
+
action: 'lock_conflict',
|
|
103
|
+
lockConflict,
|
|
104
|
+
message: `Intent "${input.title}" was ${action} (id: ${intentId.substring(0, 8)}), but could not be activated: ` +
|
|
105
|
+
`repo already owns intent ${idShort}${titlePart}${who}. ` +
|
|
106
|
+
`Retry with force=true to take over, complete_intent on ${idShort} first, or abandon this new intent.`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
75
109
|
const message = action === 'reactivated'
|
|
76
110
|
? `Reactivated existing similar intent: "${input.title}" — resuming previous work instead of creating a duplicate.`
|
|
77
111
|
: `Created and activated intent: "${input.title}"`;
|
|
@@ -82,6 +116,49 @@ export async function createAndActivateIntent(input) {
|
|
|
82
116
|
message,
|
|
83
117
|
};
|
|
84
118
|
}
|
|
119
|
+
function buildPendingBlockedResponse(blocker, intentId = '') {
|
|
120
|
+
const pendingIntent = {
|
|
121
|
+
intentId: blocker.intentId || '',
|
|
122
|
+
title: blocker.title || undefined,
|
|
123
|
+
pendingReason: blocker.pendingReason || undefined,
|
|
124
|
+
lastActivityAt: blocker.lastActivityAt || undefined,
|
|
125
|
+
distilledDecisionCount: typeof blocker.distilledDecisionCount === 'number'
|
|
126
|
+
? blocker.distilledDecisionCount
|
|
127
|
+
: undefined,
|
|
128
|
+
};
|
|
129
|
+
const idShort = pendingIntent.intentId ? pendingIntent.intentId.substring(0, 8) : 'pending';
|
|
130
|
+
const titlePart = pendingIntent.title ? ` "${pendingIntent.title}"` : '';
|
|
131
|
+
const reasonPart = pendingIntent.pendingReason ? ` (reason: ${pendingIntent.pendingReason})` : '';
|
|
132
|
+
return {
|
|
133
|
+
success: false,
|
|
134
|
+
intentId,
|
|
135
|
+
action: 'pending_blocked',
|
|
136
|
+
pendingIntent,
|
|
137
|
+
message: `Pending intent ${idShort}${titlePart}${reasonPart} exists on this repo. ` +
|
|
138
|
+
`Ask the user how to proceed: ` +
|
|
139
|
+
`(A) abandon it via complete_intent(intentId="${pendingIntent.intentId}", status="abandoned"), ` +
|
|
140
|
+
`(C) complete and finalize it via complete_intent(intentId="${pendingIntent.intentId}", status="committed"), ` +
|
|
141
|
+
`then retry. To proceed without prompting, retry with force=true.`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function buildLockConflictDetails(repoOrigin, existingIntentId) {
|
|
145
|
+
try {
|
|
146
|
+
const res = await request('intent', 'get-active', { repoOrigin });
|
|
147
|
+
const intent = res.intent;
|
|
148
|
+
if (intent && intent.id === existingIntentId) {
|
|
149
|
+
return {
|
|
150
|
+
existingIntentId,
|
|
151
|
+
title: intent.title,
|
|
152
|
+
createdBy: intent.createdBy,
|
|
153
|
+
author: intent.authorInfo?.name || intent.author,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Fall through to ID-only response
|
|
159
|
+
}
|
|
160
|
+
return { existingIntentId };
|
|
161
|
+
}
|
|
85
162
|
export const createAndActivateIntentTool = {
|
|
86
163
|
name: 'create_and_activate_intent',
|
|
87
164
|
description: `Create a new intent from the user's request and mark it as active.
|
|
@@ -95,7 +172,28 @@ This ensures all AI-generated code gets properly tracked and attributed.
|
|
|
95
172
|
|
|
96
173
|
If the tool returns conflicts (action="conflict"), present the conflict
|
|
97
174
|
details to the user and ask whether to proceed. If yes, retry with
|
|
98
|
-
force=true to bypass conflict detection
|
|
175
|
+
force=true to bypass conflict detection.
|
|
176
|
+
|
|
177
|
+
Three distinct block types exist:
|
|
178
|
+
|
|
179
|
+
- action="conflict": content-similarity conflict from intent creation (another
|
|
180
|
+
team member's intent overlaps semantically or in files). Bypassed by
|
|
181
|
+
force=true after the user reviews and chooses to proceed.
|
|
182
|
+
|
|
183
|
+
- action="lock_conflict": per-repo active-intent lock — another session on this
|
|
184
|
+
repo already owns the active intent slot. The new intent was still created
|
|
185
|
+
and can be activated later; or call complete_intent on the existing one first.
|
|
186
|
+
Bypassed by force=true (takes over the active slot).
|
|
187
|
+
|
|
188
|
+
- action="pending_blocked": a "pending" intent exists on this repo (auto-finalized
|
|
189
|
+
by the orphan-recovery sweeper, or blocked by conflicts at completion). Surface
|
|
190
|
+
the pendingIntent details to the user and ask how to dispose of it before
|
|
191
|
+
starting new work:
|
|
192
|
+
(A) Abandon it: call complete_intent(intentId=..., status="abandoned").
|
|
193
|
+
(C) Complete and finalize: call complete_intent(intentId=..., status="committed").
|
|
194
|
+
After the user decides and the pending intent is disposed, retry create_and_activate_intent.
|
|
195
|
+
In autonomous (non-interactive) sessions, retry with force=true to proceed
|
|
196
|
+
without prompting — the pending intent stays pending.`,
|
|
99
197
|
inputSchema: createAndActivateIntentSchema,
|
|
100
198
|
handler: createAndActivateIntent
|
|
101
199
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-intent.js","sourceRoot":"","sources":["../../src/tools/create-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;
|
|
1
|
+
{"version":3,"file":"create-intent.js","sourceRoot":"","sources":["../../src/tools/create-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,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
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const detectIntentConflictsSchema: 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;
|
|
@@ -8,11 +22,23 @@ export declare const detectIntentConflictsSchema: z.ZodObject<{
|
|
|
8
22
|
repoPath: string;
|
|
9
23
|
intentId: string;
|
|
10
24
|
repoOrigin?: string | undefined;
|
|
25
|
+
forkAuthor?: {
|
|
26
|
+
platform: "github" | "gitlab";
|
|
27
|
+
user: string;
|
|
28
|
+
forkOrigin: string;
|
|
29
|
+
} | undefined;
|
|
30
|
+
workspaceId?: string | undefined;
|
|
11
31
|
minScore?: number | undefined;
|
|
12
32
|
}, {
|
|
13
33
|
repoPath: string;
|
|
14
34
|
intentId: string;
|
|
15
35
|
repoOrigin?: string | undefined;
|
|
36
|
+
forkAuthor?: {
|
|
37
|
+
platform: "github" | "gitlab";
|
|
38
|
+
user: string;
|
|
39
|
+
forkOrigin: string;
|
|
40
|
+
} | undefined;
|
|
41
|
+
workspaceId?: string | undefined;
|
|
16
42
|
minScore?: number | undefined;
|
|
17
43
|
}>;
|
|
18
44
|
export type DetectIntentConflictsInput = z.infer<typeof detectIntentConflictsSchema>;
|
|
@@ -42,6 +68,20 @@ export declare const detectIntentConflictsTool: {
|
|
|
42
68
|
name: string;
|
|
43
69
|
description: string;
|
|
44
70
|
inputSchema: z.ZodObject<{
|
|
71
|
+
forkAuthor: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
platform: z.ZodEnum<["github", "gitlab"]>;
|
|
73
|
+
user: z.ZodString;
|
|
74
|
+
forkOrigin: z.ZodString;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
platform: "github" | "gitlab";
|
|
77
|
+
user: string;
|
|
78
|
+
forkOrigin: string;
|
|
79
|
+
}, {
|
|
80
|
+
platform: "github" | "gitlab";
|
|
81
|
+
user: string;
|
|
82
|
+
forkOrigin: string;
|
|
83
|
+
}>>;
|
|
84
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
45
85
|
repoOrigin: z.ZodOptional<z.ZodString>;
|
|
46
86
|
repoPath: z.ZodString;
|
|
47
87
|
intentId: z.ZodString;
|
|
@@ -50,11 +90,23 @@ export declare const detectIntentConflictsTool: {
|
|
|
50
90
|
repoPath: string;
|
|
51
91
|
intentId: string;
|
|
52
92
|
repoOrigin?: string | undefined;
|
|
93
|
+
forkAuthor?: {
|
|
94
|
+
platform: "github" | "gitlab";
|
|
95
|
+
user: string;
|
|
96
|
+
forkOrigin: string;
|
|
97
|
+
} | undefined;
|
|
98
|
+
workspaceId?: string | undefined;
|
|
53
99
|
minScore?: number | undefined;
|
|
54
100
|
}, {
|
|
55
101
|
repoPath: string;
|
|
56
102
|
intentId: string;
|
|
57
103
|
repoOrigin?: string | undefined;
|
|
104
|
+
forkAuthor?: {
|
|
105
|
+
platform: "github" | "gitlab";
|
|
106
|
+
user: string;
|
|
107
|
+
forkOrigin: string;
|
|
108
|
+
} | undefined;
|
|
109
|
+
workspaceId?: string | undefined;
|
|
58
110
|
minScore?: number | undefined;
|
|
59
111
|
}>;
|
|
60
112
|
handler: typeof detectIntentConflicts;
|