@kawacode/mcp 6.1.5 → 6.8.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.
- package/CLAUDE.md.example +13 -0
- package/build/index.js +13 -1
- package/build/index.js.map +1 -1
- package/build/kawacode-on-pre-edit.d.ts +5 -0
- package/build/kawacode-on-pre-edit.js +73 -9
- package/build/kawacode-on-pre-edit.js.map +1 -1
- package/build/kawacode-on-stop.d.ts +49 -23
- package/build/kawacode-on-stop.js +288 -38
- package/build/kawacode-on-stop.js.map +1 -1
- package/build/services/muninn-ipc.d.ts +19 -1
- package/build/services/muninn-ipc.js +20 -2
- package/build/services/muninn-ipc.js.map +1 -1
- package/build/stop/uncompleted-commit.d.ts +63 -0
- package/build/stop/uncompleted-commit.js +188 -0
- package/build/stop/uncompleted-commit.js.map +1 -0
- package/build/stop/uncompleted-commit.test.d.ts +1 -0
- package/build/stop/uncompleted-commit.test.js +135 -0
- package/build/stop/uncompleted-commit.test.js.map +1 -0
- package/build/telemetry.d.ts +54 -0
- package/build/telemetry.js +84 -0
- package/build/telemetry.js.map +1 -0
- package/build/tools/activate-intent.d.ts +1 -14
- package/build/tools/activate-intent.js +17 -56
- package/build/tools/activate-intent.js.map +1 -1
- package/build/tools/arbiter-apply.d.ts +132 -0
- package/build/tools/arbiter-apply.js +59 -0
- package/build/tools/arbiter-apply.js.map +1 -0
- package/build/tools/arbiter-resolve.d.ts +132 -0
- package/build/tools/arbiter-resolve.js +58 -0
- package/build/tools/arbiter-resolve.js.map +1 -0
- package/build/tools/check-active-intent.d.ts +21 -12
- package/build/tools/check-active-intent.js +54 -27
- package/build/tools/check-active-intent.js.map +1 -1
- package/build/tools/complete-intent.d.ts +43 -10
- package/build/tools/complete-intent.js +51 -84
- package/build/tools/complete-intent.js.map +1 -1
- package/build/tools/create-intent.d.ts +1 -21
- package/build/tools/create-intent.js +18 -106
- package/build/tools/create-intent.js.map +1 -1
- package/build/tools/get-decision-detail.d.ts +109 -0
- package/build/tools/get-decision-detail.js +57 -0
- package/build/tools/get-decision-detail.js.map +1 -0
- package/build/tools/get-project-decisions.d.ts +0 -4
- package/build/tools/get-project-decisions.js +4 -6
- package/build/tools/get-project-decisions.js.map +1 -1
- package/build/tools/get-relevant-context.d.ts +0 -1
- package/build/tools/get-relevant-context.js +18 -3
- package/build/tools/get-relevant-context.js.map +1 -1
- package/build/tools/get-resolution-context.d.ts +154 -0
- package/build/tools/get-resolution-context.js +78 -0
- package/build/tools/get-resolution-context.js.map +1 -0
- package/build/tools/get-session-decisions.d.ts +0 -5
- package/build/tools/get-session-decisions.js +5 -5
- package/build/tools/get-session-decisions.js.map +1 -1
- package/build/tools/index.d.ts +216 -7
- package/build/tools/index.js +13 -3
- package/build/tools/index.js.map +1 -1
- package/build/tools/list-team-intents.d.ts +6 -6
- package/build/tools/list-team-intents.js +2 -2
- package/build/tools/list-team-intents.js.map +1 -1
- package/build/tools/pre-edit-acknowledge.d.ts +12 -0
- package/build/tools/pre-edit-acknowledge.js +21 -0
- package/build/tools/pre-edit-acknowledge.js.map +1 -1
- package/build/tools/pre-edit-decision-check.js +2 -0
- package/build/tools/pre-edit-decision-check.js.map +1 -1
- package/build/tools/record-decision.d.ts +76 -0
- package/build/tools/record-decision.js +10 -0
- package/build/tools/record-decision.js.map +1 -1
- package/package.json +2 -2
|
@@ -14,8 +14,10 @@ export const createAndActivateIntentSchema = z.object({
|
|
|
14
14
|
});
|
|
15
15
|
export async function createAndActivateIntent(input) {
|
|
16
16
|
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
17
|
-
// Step 1: Create the intent. If a sufficiently similar one
|
|
18
|
-
// server may reactivate it instead of creating a
|
|
17
|
+
// Step 1: Create the intent. If a sufficiently similar one created by THIS
|
|
18
|
+
// session already exists, the server may reactivate it instead of creating a
|
|
19
|
+
// duplicate (dedup is scoped per-session — IMPLEMENTATION_PLAN_MULTI_ACTIVE_INTENTS.md
|
|
20
|
+
// §10.4 — so two sessions' near-duplicates are surfaced as conflicts, not merged).
|
|
19
21
|
const createRes = await request('intent', 'create', {
|
|
20
22
|
repoOrigin: actualOrigin,
|
|
21
23
|
title: input.title,
|
|
@@ -26,19 +28,11 @@ export async function createAndActivateIntent(input) {
|
|
|
26
28
|
force: input.force || false,
|
|
27
29
|
...extractForkFields(input),
|
|
28
30
|
});
|
|
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
|
-
}
|
|
35
31
|
// Handle conflict detection — API returned 409 with conflict data.
|
|
36
32
|
// Return the conflicts to the caller (Claude Code) so it can present
|
|
37
33
|
// them to the user and optionally retry with force=true.
|
|
38
34
|
if (createRes.conflict === true && createRes.conflicts) {
|
|
39
35
|
const conflicts = createRes.conflicts;
|
|
40
|
-
const highCount = conflicts.filter((c) => c.severity === 'high').length;
|
|
41
|
-
const mediumCount = conflicts.filter((c) => c.severity === 'medium').length;
|
|
42
36
|
const lines = [
|
|
43
37
|
`Found ${conflicts.length} potential conflict(s) with existing intents:`,
|
|
44
38
|
'',
|
|
@@ -74,38 +68,14 @@ export async function createAndActivateIntent(input) {
|
|
|
74
68
|
throw new Error('Intent creation succeeded but no intent ID was returned');
|
|
75
69
|
}
|
|
76
70
|
const action = createRes.action === 'reactivated' ? 'reactivated' : 'created';
|
|
77
|
-
// Step 2: Set it as active
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
const setRes = await request('intent', 'set-active', {
|
|
71
|
+
// Step 2: Set it as THIS session's current intent. Under the multi-active
|
|
72
|
+
// model (no lock) set-active never conflicts — many intents can be active per
|
|
73
|
+
// repo at once, and this only moves this session's `current` focus pointer.
|
|
74
|
+
await request('intent', 'set-active', {
|
|
82
75
|
repoOrigin: actualOrigin,
|
|
83
76
|
intentId,
|
|
84
|
-
force: input.force || false,
|
|
85
77
|
...extractForkFields(input),
|
|
86
78
|
});
|
|
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
|
-
}
|
|
109
79
|
const message = action === 'reactivated'
|
|
110
80
|
? `Reactivated existing similar intent: "${input.title}" — resuming previous work instead of creating a duplicate.`
|
|
111
81
|
: `Created and activated intent: "${input.title}"`;
|
|
@@ -116,84 +86,26 @@ export async function createAndActivateIntent(input) {
|
|
|
116
86
|
message,
|
|
117
87
|
};
|
|
118
88
|
}
|
|
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
|
-
}
|
|
162
89
|
export const createAndActivateIntentTool = {
|
|
163
90
|
name: 'create_and_activate_intent',
|
|
164
|
-
description: `Create a new intent from the user's request and mark it as active.
|
|
91
|
+
description: `Create a new intent from the user's request and mark it as active for THIS session.
|
|
165
92
|
|
|
166
|
-
Call this when check_active_intent returns no active intent. Before calling:
|
|
93
|
+
Call this when check_active_intent returns no active intent for your session. Before calling:
|
|
167
94
|
1. Summarize what the user is asking for
|
|
168
95
|
2. Ask the user to confirm the intent details (title, description, type)
|
|
169
96
|
3. Then call this tool with the confirmed details
|
|
170
97
|
|
|
171
98
|
This ensures all AI-generated code gets properly tracked and attributed.
|
|
172
99
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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).
|
|
100
|
+
Multi-active model: many intents can be active on a repo at once (one per
|
|
101
|
+
session/teammate). Creating + activating one only sets YOUR session's current
|
|
102
|
+
focus — it never blocks or displaces another session's active intent, so there
|
|
103
|
+
is no lock conflict to resolve.
|
|
187
104
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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.`,
|
|
105
|
+
If the tool returns conflicts (action="conflict"), it found an existing
|
|
106
|
+
team-member intent that overlaps semantically or in files. Present the conflict
|
|
107
|
+
details to the user and ask whether to proceed. If yes, retry with force=true to
|
|
108
|
+
bypass conflict detection.`,
|
|
197
109
|
inputSchema: createAndActivateIntentSchema,
|
|
198
110
|
handler: createAndActivateIntent
|
|
199
111
|
};
|
|
@@ -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;AACnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE3E,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,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,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IAC9E,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC3E,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC;IACxG,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACjG,KA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yDAAyD,CAAC,CAAA;IAC5E,CAAC;IACD,MAAM,MAAM,GAA8B,SAAS,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAA;IAExG,0EAA0E;IAC1E,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE;QACpC,UAAU,EAAE,YAAY;QACxB,QAAQ;QACR,GAAG,iBAAiB,CAAC,KAAK,CAAC;KAC5B,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,MAAM,KAAK,aAAa;QACtC,CAAC,CAAC,yCAAyC,KAAK,CAAC,KAAK,6DAA6D;QACnH,CAAC,CAAC,kCAAkC,KAAK,CAAC,KAAK,GAAG,CAAA;IAEpD,OAAO;QACL,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE;;;;;;;;;;;;;;;;;2BAiBY;IACzB,WAAW,EAAE,6BAA6B;IAC1C,OAAO,EAAE,uBAAuB;CACjC,CAAA"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getDecisionDetailSchema: 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>;
|
|
17
|
+
repoOrigin: z.ZodOptional<z.ZodString>;
|
|
18
|
+
repoPath: z.ZodString;
|
|
19
|
+
decisionId: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
repoPath: string;
|
|
22
|
+
decisionId: string;
|
|
23
|
+
repoOrigin?: string | undefined;
|
|
24
|
+
forkAuthor?: {
|
|
25
|
+
platform: "github" | "gitlab";
|
|
26
|
+
user: string;
|
|
27
|
+
forkOrigin: string;
|
|
28
|
+
} | undefined;
|
|
29
|
+
workspaceId?: string | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
repoPath: string;
|
|
32
|
+
decisionId: string;
|
|
33
|
+
repoOrigin?: string | undefined;
|
|
34
|
+
forkAuthor?: {
|
|
35
|
+
platform: "github" | "gitlab";
|
|
36
|
+
user: string;
|
|
37
|
+
forkOrigin: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
workspaceId?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export type GetDecisionDetailInput = z.infer<typeof getDecisionDetailSchema>;
|
|
42
|
+
export interface DecisionDetail {
|
|
43
|
+
decisionId: string;
|
|
44
|
+
intentId: string;
|
|
45
|
+
intentIds: string[];
|
|
46
|
+
type: string;
|
|
47
|
+
summary: string;
|
|
48
|
+
rationale: string;
|
|
49
|
+
context?: string;
|
|
50
|
+
alternatives: string[];
|
|
51
|
+
consequences?: string;
|
|
52
|
+
symptom?: string;
|
|
53
|
+
appliesWhen?: string | null;
|
|
54
|
+
relatedFiles: string[];
|
|
55
|
+
supersedes: string[];
|
|
56
|
+
constraintsChecked: string[];
|
|
57
|
+
constraintViolations: any[];
|
|
58
|
+
timestamp?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface GetDecisionDetailResponse {
|
|
61
|
+
found: boolean;
|
|
62
|
+
decision?: DecisionDetail;
|
|
63
|
+
error?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare function getDecisionDetail(input: GetDecisionDetailInput): Promise<GetDecisionDetailResponse>;
|
|
66
|
+
export declare const getDecisionDetailTool: {
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
inputSchema: z.ZodObject<{
|
|
70
|
+
forkAuthor: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
platform: z.ZodEnum<["github", "gitlab"]>;
|
|
72
|
+
user: z.ZodString;
|
|
73
|
+
forkOrigin: z.ZodString;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
platform: "github" | "gitlab";
|
|
76
|
+
user: string;
|
|
77
|
+
forkOrigin: string;
|
|
78
|
+
}, {
|
|
79
|
+
platform: "github" | "gitlab";
|
|
80
|
+
user: string;
|
|
81
|
+
forkOrigin: string;
|
|
82
|
+
}>>;
|
|
83
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
84
|
+
repoOrigin: z.ZodOptional<z.ZodString>;
|
|
85
|
+
repoPath: z.ZodString;
|
|
86
|
+
decisionId: z.ZodString;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
repoPath: string;
|
|
89
|
+
decisionId: string;
|
|
90
|
+
repoOrigin?: string | undefined;
|
|
91
|
+
forkAuthor?: {
|
|
92
|
+
platform: "github" | "gitlab";
|
|
93
|
+
user: string;
|
|
94
|
+
forkOrigin: string;
|
|
95
|
+
} | undefined;
|
|
96
|
+
workspaceId?: string | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
repoPath: string;
|
|
99
|
+
decisionId: string;
|
|
100
|
+
repoOrigin?: string | undefined;
|
|
101
|
+
forkAuthor?: {
|
|
102
|
+
platform: "github" | "gitlab";
|
|
103
|
+
user: string;
|
|
104
|
+
forkOrigin: string;
|
|
105
|
+
} | undefined;
|
|
106
|
+
workspaceId?: string | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
handler: typeof getDecisionDetail;
|
|
109
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { request } from '../services/muninn-ipc.js';
|
|
3
|
+
import { resolveOrigin } from './resolve-origin.js';
|
|
4
|
+
import { forkFieldsExtensions, extractForkFields } from './_fork-fields.js';
|
|
5
|
+
export const getDecisionDetailSchema = z.object({
|
|
6
|
+
repoOrigin: z.string().optional().describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
|
|
7
|
+
repoPath: z.string().describe('Local path to the repository root'),
|
|
8
|
+
decisionId: z.string().describe('The decision ID to expand (from a recall result, e.g. get_relevant_context)'),
|
|
9
|
+
...forkFieldsExtensions,
|
|
10
|
+
});
|
|
11
|
+
export async function getDecisionDetail(input) {
|
|
12
|
+
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
13
|
+
const res = await request('decision', 'detail', {
|
|
14
|
+
repoOrigin: actualOrigin,
|
|
15
|
+
decisionId: input.decisionId,
|
|
16
|
+
...extractForkFields(input),
|
|
17
|
+
});
|
|
18
|
+
const d = res?.decision;
|
|
19
|
+
if (!d) {
|
|
20
|
+
return { found: false, error: res?.error || 'Decision not found' };
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
found: true,
|
|
24
|
+
decision: {
|
|
25
|
+
decisionId: d.decisionId || d.decision_id || d._id || d.id || '',
|
|
26
|
+
intentId: d.intentId || d.intent_id || d.intentIds?.[0] || d.intent_ids?.[0] || '',
|
|
27
|
+
intentIds: d.intentIds || d.intent_ids || (d.intentId || d.intent_id ? [d.intentId || d.intent_id] : []),
|
|
28
|
+
type: d.decisionType || d.decision_type || d.type || '',
|
|
29
|
+
summary: d.summary || '',
|
|
30
|
+
rationale: d.rationale || '',
|
|
31
|
+
context: d.context,
|
|
32
|
+
alternatives: d.alternatives || [],
|
|
33
|
+
consequences: d.consequences,
|
|
34
|
+
symptom: d.symptom,
|
|
35
|
+
appliesWhen: d.appliesWhen ?? d.applies_when ?? d.aw ?? null,
|
|
36
|
+
relatedFiles: d.relatedFiles || d.related_files || [],
|
|
37
|
+
supersedes: d.supersedes || [],
|
|
38
|
+
constraintsChecked: d.constraintsChecked || d.constraints_checked || [],
|
|
39
|
+
constraintViolations: d.constraintViolations || d.constraint_violations || [],
|
|
40
|
+
timestamp: d.timestamp || d.createdAt || d.created_at,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export const getDecisionDetailTool = {
|
|
45
|
+
name: 'get_decision_detail',
|
|
46
|
+
description: `Expand one decision to its full detail.
|
|
47
|
+
|
|
48
|
+
Recall surfaces (get_relevant_context, get_project_decisions, get_session_decisions) return decisions summary-only to keep context lean. Use this to pull the full reasoning for a single decision you want to open — pay for detail only where you ask for it.
|
|
49
|
+
|
|
50
|
+
Inputs:
|
|
51
|
+
- \`decisionId\`: the decision to expand (the \`id\` / \`decisionId\` from a recall result).
|
|
52
|
+
|
|
53
|
+
Returns the decision's \`rationale\`, \`context\`, \`consequences\`, \`alternatives\`, \`symptom\`, \`appliesWhen\`, and related metadata. \`found: false\` when the id is unknown in this repo.`,
|
|
54
|
+
inputSchema: getDecisionDetailSchema,
|
|
55
|
+
handler: getDecisionDetail
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=get-decision-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-decision-detail.js","sourceRoot":"","sources":["../../src/tools/get-decision-detail.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,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,CAA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,CAAC,EAAE,CAAC;YACxG,IAAI,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE;YACvD,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;YACxB,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,EAAE;YAC5B,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,EAAE;YAClC,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,IAAI,IAAI;YAC5D,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,aAAa,IAAI,EAAE;YACrD,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,EAAE;YAC9B,kBAAkB,EAAE,CAAC,CAAC,kBAAkB,IAAI,CAAC,CAAC,mBAAmB,IAAI,EAAE;YACvE,oBAAoB,EAAE,CAAC,CAAC,oBAAoB,IAAI,CAAC,CAAC,qBAAqB,IAAI,EAAE;YAC7E,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,UAAU;SACtD;KACF,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE;;;;;;;iMAOkL;IAC/L,WAAW,EAAE,uBAAuB;IACpC,OAAO,EAAE,iBAAiB;CAC3B,CAAA"}
|
|
@@ -48,10 +48,6 @@ export interface ProjectDecision {
|
|
|
48
48
|
timestamp: string;
|
|
49
49
|
type: 'fork' | 'abandoned' | 'discovery' | 'constraint' | 'tradeoff' | 'dependency';
|
|
50
50
|
summary: string;
|
|
51
|
-
rationale: string;
|
|
52
|
-
context?: string;
|
|
53
|
-
alternatives: string[];
|
|
54
|
-
consequences?: string;
|
|
55
51
|
relatedFiles: string[];
|
|
56
52
|
constraintsChecked: string[];
|
|
57
53
|
constraintViolations: ConstraintViolation[];
|
|
@@ -20,10 +20,9 @@ export async function getProjectDecisions(input) {
|
|
|
20
20
|
timestamp: d.timestamp || d.created_at || d.createdAt || '',
|
|
21
21
|
type: d.decision_type || d.decisionType || d.type,
|
|
22
22
|
summary: d.summary || '',
|
|
23
|
-
|
|
24
|
-
context
|
|
25
|
-
|
|
26
|
-
consequences: d.consequences,
|
|
23
|
+
// Lean payload (INTENT_INTELLIGENCE.md §5.8): the unbounded free-text fields
|
|
24
|
+
// (rationale/context/consequences/alternatives) are dropped from this recall
|
|
25
|
+
// surface. Fetch them on demand via get_decision_detail(decisionId).
|
|
27
26
|
relatedFiles: d.related_files || d.relatedFiles || [],
|
|
28
27
|
constraintsChecked: d.constraints_checked || d.constraintsChecked || [],
|
|
29
28
|
constraintViolations: d.constraint_violations || d.constraintViolations || []
|
|
@@ -47,11 +46,10 @@ Returns:
|
|
|
47
46
|
- decisions: Array of decisions with their intent context
|
|
48
47
|
- count: Total number of decisions
|
|
49
48
|
|
|
50
|
-
Each decision includes:
|
|
49
|
+
Each decision includes (summary-only, to keep context lean — call get_decision_detail(decisionId) for full rationale/context/consequences/alternatives):
|
|
51
50
|
- intentIds: The intents this decision belongs to (array — a decision can span multiple intents)
|
|
52
51
|
- type: fork, abandoned, discovery, constraint, tradeoff, or dependency
|
|
53
52
|
- summary: Brief description of the decision
|
|
54
|
-
- rationale: Why this decision was made
|
|
55
53
|
- relatedFiles: Files affected by this decision
|
|
56
54
|
- constraintViolations: Options that were rejected due to constraints`,
|
|
57
55
|
inputSchema: getProjectDecisionsSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-project-decisions.js","sourceRoot":"","sources":["../../src/tools/get-project-decisions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;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AC,CAAC,CAAA;IAEH,OAAO;QACL,SAAS;QACT,KAAK,EAAE,SAAS,CAAC,MAAM;KACxB,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE;;;;;;;;;;;;;;;;;sEAiBuD;IACpE,WAAW,EAAE,yBAAyB;IACtC,OAAO,EAAE,mBAAmB;CAC7B,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { request } from '../services/muninn-ipc.js';
|
|
3
3
|
import { resolveOrigin } from './resolve-origin.js';
|
|
4
4
|
import { forkFieldsExtensions, extractForkFields } from './_fork-fields.js';
|
|
5
|
+
import { emitInjection, estimateTokens } from '../telemetry.js';
|
|
5
6
|
export const getRelevantContextSchema = z.object({
|
|
6
7
|
repoOrigin: z.string().optional().describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
|
|
7
8
|
repoPath: z.string().describe('Local path to the repository root'),
|
|
@@ -42,7 +43,7 @@ export async function getRelevantContext(input) {
|
|
|
42
43
|
const msg = err?.message || String(err);
|
|
43
44
|
return { ...EMPTY_RESPONSE(actualOrigin, input.repoPath), error: `Muninn unavailable: ${msg}` };
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
const response = {
|
|
46
47
|
projectOrigin: actualOrigin,
|
|
47
48
|
projectPath: input.repoPath,
|
|
48
49
|
relevantIntents: (res.intents || []).map((i) => ({
|
|
@@ -59,7 +60,9 @@ export async function getRelevantContext(input) {
|
|
|
59
60
|
intentIds: d.intentIds || d.intent_ids || (d.intentId || d.intent_id ? [d.intentId || d.intent_id] : []),
|
|
60
61
|
type: d.decisionType || d.decision_type || d.type || '',
|
|
61
62
|
summary: d.summary || '',
|
|
62
|
-
|
|
63
|
+
// Lean payload (INTENT_INTELLIGENCE.md §5.8): rationale is dropped from the
|
|
64
|
+
// recall surface — it dominated context accumulation (re-sent every turn).
|
|
65
|
+
// Fetch full rationale on demand via get_decision_detail(decisionId).
|
|
63
66
|
relatedFiles: d.relatedFiles || d.related_files || [],
|
|
64
67
|
hasViolations: (d.constraintViolations || d.constraint_violations || []).length > 0,
|
|
65
68
|
score: d.score || 0,
|
|
@@ -72,6 +75,18 @@ export async function getRelevantContext(input) {
|
|
|
72
75
|
decisionsReturned: (res.decisions || []).length,
|
|
73
76
|
}
|
|
74
77
|
};
|
|
78
|
+
// Track-B injection telemetry (VALUE_METRICS Phase 2): size the serialized
|
|
79
|
+
// recall payload (≈ chars/4), itemCount = intents + decisions, and carry the
|
|
80
|
+
// surfaced decision ids for the read-side recall→supersedes "acted on" join.
|
|
81
|
+
// Fire-and-forget — never blocks the tool result.
|
|
82
|
+
void emitInjection({
|
|
83
|
+
type: 'recall',
|
|
84
|
+
tokensEst: estimateTokens(JSON.stringify(response)),
|
|
85
|
+
itemCount: response.relevantIntents.length + response.relevantDecisions.length,
|
|
86
|
+
repoOrigin: actualOrigin,
|
|
87
|
+
decisionIds: response.relevantDecisions.map(d => d.id).filter(Boolean),
|
|
88
|
+
});
|
|
89
|
+
return response;
|
|
75
90
|
}
|
|
76
91
|
export const getRelevantContextTool = {
|
|
77
92
|
name: 'get_relevant_context',
|
|
@@ -88,7 +103,7 @@ Inputs of note:
|
|
|
88
103
|
|
|
89
104
|
Returns:
|
|
90
105
|
- \`relevantIntents\`: past work units (intents) related to the task, scored by relevance.
|
|
91
|
-
- \`relevantDecisions\`: prior decisions related to the task — both intent-scoped and repo-scoped.
|
|
106
|
+
- \`relevantDecisions\`: prior decisions related to the task — both intent-scoped and repo-scoped. Summary-only (no inline rationale, to keep context lean); call \`get_decision_detail(decisionId)\` for the full rationale/context/consequences of any decision you want to open.
|
|
92
107
|
|
|
93
108
|
Recommended sequence:
|
|
94
109
|
1. \`check_active_intent\` at session start to resume any existing work.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-relevant-context.js","sourceRoot":"","sources":["../../src/tools/get-relevant-context.ts"],"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