@kawacode/mcp 5.0.4 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md.example +101 -36
- package/README.md +54 -62
- package/build/index.js +24 -5
- package/build/index.js.map +1 -1
- package/build/prompts/intent-first-workflow.js +7 -8
- package/build/prompts/intent-first-workflow.js.map +1 -1
- package/build/resources/active-intent.js +2 -2
- package/build/resources/active-intent.js.map +1 -1
- package/build/services/muninn-ipc.d.ts +3 -1
- package/build/services/muninn-ipc.js +35 -5
- package/build/services/muninn-ipc.js.map +1 -1
- package/build/tools/activate-intent.d.ts +40 -0
- package/build/tools/activate-intent.js +52 -0
- package/build/tools/activate-intent.js.map +1 -0
- package/build/tools/check-active-intent.d.ts +0 -1
- package/build/tools/check-active-intent.js +3 -4
- package/build/tools/check-active-intent.js.map +1 -1
- package/build/tools/complete-intent.d.ts +18 -6
- package/build/tools/complete-intent.js +31 -2
- package/build/tools/complete-intent.js.map +1 -1
- package/build/tools/create-intent.d.ts +23 -1
- package/build/tools/create-intent.js +58 -5
- package/build/tools/create-intent.js.map +1 -1
- package/build/tools/detect-intent-conflicts.d.ts +22 -322
- package/build/tools/detect-intent-conflicts.js +35 -60
- package/build/tools/detect-intent-conflicts.js.map +1 -1
- package/build/tools/edit-session-decision.d.ts +4 -4
- package/build/tools/evolve-decisions.d.ts +0 -6
- package/build/tools/evolve-decisions.js +1 -3
- package/build/tools/evolve-decisions.js.map +1 -1
- package/build/tools/get-intents-for-file.js +1 -1
- package/build/tools/get-intents-for-file.js.map +1 -1
- package/build/tools/get-intents-for-lines.js +1 -1
- package/build/tools/get-intents-for-lines.js.map +1 -1
- package/build/tools/get-project-decisions.d.ts +1 -0
- package/build/tools/get-project-decisions.js +3 -2
- package/build/tools/get-project-decisions.js.map +1 -1
- package/build/tools/get-relevant-context.d.ts +1 -0
- package/build/tools/get-relevant-context.js +2 -1
- package/build/tools/get-relevant-context.js.map +1 -1
- package/build/tools/get-session-decisions.d.ts +2 -0
- package/build/tools/get-session-decisions.js +1 -0
- package/build/tools/get-session-decisions.js.map +1 -1
- package/build/tools/index.d.ts +54 -204
- package/build/tools/index.js +3 -3
- package/build/tools/index.js.map +1 -1
- package/build/tools/infer-history.d.ts +13 -16
- package/build/tools/infer-history.js +62 -29
- package/build/tools/infer-history.js.map +1 -1
- package/build/tools/list-team-intents.d.ts +30 -0
- package/build/tools/list-team-intents.js +39 -16
- package/build/tools/list-team-intents.js.map +1 -1
- package/build/tools/log-work.js +1 -1
- package/build/tools/log-work.js.map +1 -1
- package/build/tools/record-decision.d.ts +6 -0
- package/build/tools/record-decision.js +2 -0
- package/build/tools/record-decision.js.map +1 -1
- package/build/tools/resolve-origin.js +1 -0
- package/build/tools/resolve-origin.js.map +1 -1
- package/build/tools/update-intent.d.ts +95 -0
- package/build/tools/update-intent.js +94 -0
- package/build/tools/update-intent.js.map +1 -0
- package/package.json +1 -1
- package/build/services/active-intent-store.d.ts +0 -36
- package/build/services/active-intent-store.js +0 -45
- package/build/services/active-intent-store.js.map +0 -1
- package/build/services/kawa-api.d.ts +0 -131
- package/build/services/kawa-api.js +0 -239
- package/build/services/kawa-api.js.map +0 -1
- package/build/services/repo-encryption.d.ts +0 -46
- package/build/services/repo-encryption.js +0 -92
- package/build/services/repo-encryption.js.map +0 -1
- package/build/services/storage-decryption.d.ts +0 -52
- package/build/services/storage-decryption.js +0 -162
- package/build/services/storage-decryption.js.map +0 -1
- package/build/tools/assign-blocks.d.ts +0 -87
- package/build/tools/assign-blocks.js +0 -49
- package/build/tools/assign-blocks.js.map +0 -1
- package/build/tools/get-project-context.d.ts +0 -82
- package/build/tools/get-project-context.js +0 -73
- package/build/tools/get-project-context.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { request } from '../services/muninn-ipc.js';
|
|
3
|
+
import { resolveOrigin } from './resolve-origin.js';
|
|
4
|
+
export const updateIntentSchema = z.object({
|
|
5
|
+
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
|
+
intentId: z.string().optional().describe('ID of the intent to update. If omitted, updates the currently active intent.'),
|
|
8
|
+
title: z.string().max(200).optional().describe('Updated title for the intent'),
|
|
9
|
+
description: z.string().max(2000).optional().describe('Updated description for the intent'),
|
|
10
|
+
constraints: z.array(z.string()).optional().describe('Updated constraints for this work'),
|
|
11
|
+
scope: z.object({
|
|
12
|
+
type: z.enum(['repo', 'folder', 'files']),
|
|
13
|
+
paths: z.array(z.string())
|
|
14
|
+
}).optional().describe('Updated scope for the intent'),
|
|
15
|
+
});
|
|
16
|
+
export async function updateIntent(input) {
|
|
17
|
+
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
18
|
+
// Resolve the intent ID: use provided intentId, or look up the active intent
|
|
19
|
+
let intentId = input.intentId;
|
|
20
|
+
if (!intentId) {
|
|
21
|
+
const activeRes = await request('intent', 'get-active', { repoOrigin: actualOrigin });
|
|
22
|
+
intentId = activeRes.intentId || activeRes.intent?.id || '';
|
|
23
|
+
if (!intentId) {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
intentId: '',
|
|
27
|
+
message: 'No active intent found and no intentId provided. Create an intent first or provide an intentId.',
|
|
28
|
+
updatedFields: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Build the updates object from provided fields
|
|
33
|
+
const updates = {};
|
|
34
|
+
const updatedFields = [];
|
|
35
|
+
if (input.title !== undefined) {
|
|
36
|
+
updates.title = input.title;
|
|
37
|
+
updatedFields.push('title');
|
|
38
|
+
}
|
|
39
|
+
if (input.description !== undefined) {
|
|
40
|
+
updates.description = input.description;
|
|
41
|
+
updatedFields.push('description');
|
|
42
|
+
}
|
|
43
|
+
if (input.constraints !== undefined) {
|
|
44
|
+
updates.constraints = input.constraints;
|
|
45
|
+
updatedFields.push('constraints');
|
|
46
|
+
}
|
|
47
|
+
if (input.scope !== undefined) {
|
|
48
|
+
updates.scope = input.scope;
|
|
49
|
+
updatedFields.push('scope');
|
|
50
|
+
}
|
|
51
|
+
if (updatedFields.length === 0) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
intentId,
|
|
55
|
+
message: 'No fields to update. Provide at least one of: title, description, constraints, scope.',
|
|
56
|
+
updatedFields: [],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const res = await request('intent', 'update', {
|
|
60
|
+
id: intentId,
|
|
61
|
+
updates,
|
|
62
|
+
});
|
|
63
|
+
if (res.success === false) {
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
intentId,
|
|
67
|
+
message: res.error || 'Intent update failed',
|
|
68
|
+
updatedFields: [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
intentId,
|
|
74
|
+
message: `Intent updated: ${updatedFields.join(', ')}`,
|
|
75
|
+
updatedFields,
|
|
76
|
+
warning: res.warning,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export const updateIntentTool = {
|
|
80
|
+
name: 'update_intent',
|
|
81
|
+
description: `Update an active intent's title, description, scope, or constraints.
|
|
82
|
+
|
|
83
|
+
Use this to reformulate an intent as understanding evolves during work. Intents are
|
|
84
|
+
living documents — they should be updated to reflect what the work actually became,
|
|
85
|
+
not left as the initial guess. Common triggers for reformulation:
|
|
86
|
+
- The real problem turned out to be different from the initial hypothesis
|
|
87
|
+
- Scope expanded or narrowed during investigation
|
|
88
|
+
- The approach changed after discovering constraints
|
|
89
|
+
|
|
90
|
+
If no intentId is provided, the currently active intent is updated.`,
|
|
91
|
+
inputSchema: updateIntentSchema,
|
|
92
|
+
handler: updateIntent
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=update-intent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC3B,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC7B,CAAC;IAED,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,QAAQ;YACR,OAAO,EAAE,uFAAuF;YAChG,aAAa,EAAE,EAAE;SAClB,CAAA;IACH,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE;QAC5C,EAAE,EAAE,QAAQ;QACZ,OAAO;KACR,CAAC,CAAA;IAEF,IAAI,GAAG,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,QAAQ;YACR,OAAO,EAAE,GAAG,CAAC,KAAK,IAAI,sBAAsB;YAC5C,aAAa,EAAE,EAAE;SAClB,CAAA;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,OAAO,EAAE,mBAAmB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACtD,aAAa;QACb,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE;;;;;;;;;oEASqD;IAClE,WAAW,EAAE,kBAAkB;IAC/B,OAAO,EAAE,YAAY;CACtB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory active intent tracking.
|
|
3
|
-
*
|
|
4
|
-
* Simple Map keyed by normalized origin. Replaces Muninn's per-repo
|
|
5
|
-
* active intent tracking. State lives only for the MCP server lifetime.
|
|
6
|
-
*/
|
|
7
|
-
import type { Intent } from './kawa-api.js';
|
|
8
|
-
export interface ActiveIntent {
|
|
9
|
-
id: string;
|
|
10
|
-
title: string;
|
|
11
|
-
description: string;
|
|
12
|
-
templateType: string;
|
|
13
|
-
status: string;
|
|
14
|
-
constraints: string[];
|
|
15
|
-
blocks: Array<{
|
|
16
|
-
filePath: string;
|
|
17
|
-
startLine: number;
|
|
18
|
-
endLine: number;
|
|
19
|
-
contentSnippet?: string;
|
|
20
|
-
}>;
|
|
21
|
-
branch?: string;
|
|
22
|
-
forkedFrom?: string;
|
|
23
|
-
createdAt?: string;
|
|
24
|
-
}
|
|
25
|
-
declare class ActiveIntentStore {
|
|
26
|
-
private store;
|
|
27
|
-
get(origin: string): ActiveIntent | null;
|
|
28
|
-
set(origin: string, intent: ActiveIntent): void;
|
|
29
|
-
clear(origin: string): void;
|
|
30
|
-
/** Return all active intents as [origin, intent] pairs */
|
|
31
|
-
getAll(): Array<[string, ActiveIntent]>;
|
|
32
|
-
/** Convert an API Intent to the ActiveIntent shape and store it */
|
|
33
|
-
setFromApiIntent(origin: string, apiIntent: Intent, cloudId: string): void;
|
|
34
|
-
}
|
|
35
|
-
export declare const activeIntentStore: ActiveIntentStore;
|
|
36
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory active intent tracking.
|
|
3
|
-
*
|
|
4
|
-
* Simple Map keyed by normalized origin. Replaces Muninn's per-repo
|
|
5
|
-
* active intent tracking. State lives only for the MCP server lifetime.
|
|
6
|
-
*/
|
|
7
|
-
class ActiveIntentStore {
|
|
8
|
-
store = new Map();
|
|
9
|
-
get(origin) {
|
|
10
|
-
return this.store.get(origin) || null;
|
|
11
|
-
}
|
|
12
|
-
set(origin, intent) {
|
|
13
|
-
this.store.set(origin, intent);
|
|
14
|
-
}
|
|
15
|
-
clear(origin) {
|
|
16
|
-
this.store.delete(origin);
|
|
17
|
-
}
|
|
18
|
-
/** Return all active intents as [origin, intent] pairs */
|
|
19
|
-
getAll() {
|
|
20
|
-
return [...this.store.entries()];
|
|
21
|
-
}
|
|
22
|
-
/** Convert an API Intent to the ActiveIntent shape and store it */
|
|
23
|
-
setFromApiIntent(origin, apiIntent, cloudId) {
|
|
24
|
-
this.store.set(origin, {
|
|
25
|
-
id: cloudId || apiIntent._id || apiIntent.id || '',
|
|
26
|
-
title: apiIntent.title || '',
|
|
27
|
-
description: apiIntent.description || '',
|
|
28
|
-
templateType: apiIntent.templateType || 'feature',
|
|
29
|
-
status: apiIntent.status || 'active',
|
|
30
|
-
constraints: apiIntent.constraints || [],
|
|
31
|
-
blocks: (apiIntent.blocks || []).map(b => ({
|
|
32
|
-
filePath: b.filePath,
|
|
33
|
-
startLine: b.startLine,
|
|
34
|
-
endLine: b.endLine,
|
|
35
|
-
contentSnippet: b.contentSnippet,
|
|
36
|
-
})),
|
|
37
|
-
branch: apiIntent.branch,
|
|
38
|
-
forkedFrom: apiIntent.forkedFrom,
|
|
39
|
-
createdAt: apiIntent.createdAt,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// Singleton
|
|
44
|
-
export const activeIntentStore = new ActiveIntentStore();
|
|
45
|
-
//# sourceMappingURL=active-intent-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"active-intent-store.js","sourceRoot":"","sources":["../../src/services/active-intent-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH,MAAM,iBAAiB;IACb,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAA;IAE/C,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAA;IACvC,CAAC;IAED,GAAG,CAAC,MAAc,EAAE,MAAoB;QACtC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,MAAc;QAClB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,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Uses Node 18+ built-in fetch (no new dependencies).
|
|
6
|
-
*
|
|
7
|
-
* Config:
|
|
8
|
-
* KAWA_API_URL — defaults to https://api.codeawareness.com (set to http://localhost:3008 for local dev)
|
|
9
|
-
* KAWA_AUTH_TOKEN — JWT bearer token (optional - auto-loaded from storage if not set)
|
|
10
|
-
*
|
|
11
|
-
* Auth token resolution order:
|
|
12
|
-
* 1. KAWA_AUTH_TOKEN environment variable
|
|
13
|
-
* 2. ~/.kawa-code/.storage.caw (decrypted using username+hostname)
|
|
14
|
-
*/
|
|
15
|
-
export interface Intent {
|
|
16
|
-
_id?: string;
|
|
17
|
-
id?: string;
|
|
18
|
-
title: string;
|
|
19
|
-
description: string;
|
|
20
|
-
templateType: string;
|
|
21
|
-
status?: string;
|
|
22
|
-
scope?: {
|
|
23
|
-
type: string;
|
|
24
|
-
paths: string[];
|
|
25
|
-
};
|
|
26
|
-
blocks?: IntentBlock[];
|
|
27
|
-
constraints?: string[];
|
|
28
|
-
branch?: string;
|
|
29
|
-
forkedFrom?: string;
|
|
30
|
-
encrypted?: boolean;
|
|
31
|
-
authorId?: string;
|
|
32
|
-
authorName?: string;
|
|
33
|
-
createdAt?: string;
|
|
34
|
-
updatedAt?: string;
|
|
35
|
-
}
|
|
36
|
-
export interface IntentBlock {
|
|
37
|
-
filePath: string;
|
|
38
|
-
startLine: number;
|
|
39
|
-
endLine: number;
|
|
40
|
-
contentHash?: string;
|
|
41
|
-
contentSnippet?: string;
|
|
42
|
-
codeContent?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface IntentTranslation {
|
|
45
|
-
intentId: string;
|
|
46
|
-
lang: string;
|
|
47
|
-
title: string;
|
|
48
|
-
description: string;
|
|
49
|
-
}
|
|
50
|
-
export interface Decision {
|
|
51
|
-
decisionId: string;
|
|
52
|
-
intentId?: string;
|
|
53
|
-
authorId?: string;
|
|
54
|
-
timestamp?: string;
|
|
55
|
-
decisionType: string;
|
|
56
|
-
summary: string;
|
|
57
|
-
context?: string;
|
|
58
|
-
alternatives?: string[];
|
|
59
|
-
rationale: string;
|
|
60
|
-
consequences?: string;
|
|
61
|
-
relatedFiles?: string[];
|
|
62
|
-
supersedes?: string[];
|
|
63
|
-
constraintsChecked?: string[];
|
|
64
|
-
constraintViolations?: Array<{
|
|
65
|
-
alternative: string;
|
|
66
|
-
constraint: string;
|
|
67
|
-
reason: string;
|
|
68
|
-
}>;
|
|
69
|
-
createdAt?: string;
|
|
70
|
-
updatedAt?: string;
|
|
71
|
-
}
|
|
72
|
-
export interface CreateIntentParams {
|
|
73
|
-
origin: string;
|
|
74
|
-
lang?: string;
|
|
75
|
-
title: string;
|
|
76
|
-
description: string;
|
|
77
|
-
templateType?: string;
|
|
78
|
-
constraints?: string[];
|
|
79
|
-
scope?: {
|
|
80
|
-
type: string;
|
|
81
|
-
paths: string[];
|
|
82
|
-
};
|
|
83
|
-
blocks?: IntentBlock[];
|
|
84
|
-
branch?: string;
|
|
85
|
-
forkedFrom?: string;
|
|
86
|
-
}
|
|
87
|
-
export declare class KawaApi {
|
|
88
|
-
private baseUrl;
|
|
89
|
-
private authToken;
|
|
90
|
-
constructor(baseUrl?: string, authToken?: string);
|
|
91
|
-
/**
|
|
92
|
-
* Refresh the auth token from storage
|
|
93
|
-
*
|
|
94
|
-
* Call this periodically to pick up token refreshes from Muninn.
|
|
95
|
-
* Returns true if a new token was loaded.
|
|
96
|
-
*/
|
|
97
|
-
refreshTokenFromStorage(): boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Check if the client has an auth token
|
|
100
|
-
*/
|
|
101
|
-
hasAuthToken(): boolean;
|
|
102
|
-
listIntents(origin: string, lang?: string, since?: string): Promise<Intent[]>;
|
|
103
|
-
createIntent(params: CreateIntentParams): Promise<{
|
|
104
|
-
intent: Intent;
|
|
105
|
-
cloudId: string;
|
|
106
|
-
}>;
|
|
107
|
-
getIntent(intentId: string, origin: string, lang?: string): Promise<Intent>;
|
|
108
|
-
updateIntent(intentId: string, origin: string, updates: Partial<Intent>): Promise<Intent>;
|
|
109
|
-
deleteIntent(intentId: string, origin: string): Promise<void>;
|
|
110
|
-
getIntentsByFile(origin: string, filePath: string): Promise<Intent[]>;
|
|
111
|
-
getIntentsByLines(origin: string, filePath: string, startLine: number, endLine: number): Promise<Intent[]>;
|
|
112
|
-
batchSaveIntents(origin: string, lang: string, intents: CreateIntentParams[]): Promise<any>;
|
|
113
|
-
saveIntentTranslation(intentId: string, origin: string, lang: string, title: string, description: string): Promise<any>;
|
|
114
|
-
getIntentTranslation(intentId: string, origin: string, lang: string): Promise<IntentTranslation | null>;
|
|
115
|
-
getTeamDecisions(origin: string, since?: string): Promise<Decision[]>;
|
|
116
|
-
getIntentDecisions(intentId: string, origin: string): Promise<Decision[]>;
|
|
117
|
-
syncDecisions(origin: string, intentId: string, decisions: Decision[]): Promise<any>;
|
|
118
|
-
deleteDecision(decisionId: string, origin: string): Promise<void>;
|
|
119
|
-
searchRelevantContext(origin: string, query: string, activeFiles?: string[], options?: {
|
|
120
|
-
maxIntents?: number;
|
|
121
|
-
maxDecisions?: number;
|
|
122
|
-
minScore?: number;
|
|
123
|
-
}): Promise<any>;
|
|
124
|
-
private get;
|
|
125
|
-
private post;
|
|
126
|
-
private patch;
|
|
127
|
-
private del;
|
|
128
|
-
getBaseUrl(): string;
|
|
129
|
-
private request;
|
|
130
|
-
}
|
|
131
|
-
export declare function getApi(): KawaApi;
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP client for the Kawa API.
|
|
3
|
-
*
|
|
4
|
-
* Replaces Muninn IPC — all data operations go directly to the REST API.
|
|
5
|
-
* Uses Node 18+ built-in fetch (no new dependencies).
|
|
6
|
-
*
|
|
7
|
-
* Config:
|
|
8
|
-
* KAWA_API_URL — defaults to https://api.codeawareness.com (set to http://localhost:3008 for local dev)
|
|
9
|
-
* KAWA_AUTH_TOKEN — JWT bearer token (optional - auto-loaded from storage if not set)
|
|
10
|
-
*
|
|
11
|
-
* Auth token resolution order:
|
|
12
|
-
* 1. KAWA_AUTH_TOKEN environment variable
|
|
13
|
-
* 2. ~/.kawa-code/.storage.caw (decrypted using username+hostname)
|
|
14
|
-
*/
|
|
15
|
-
import { getAuthTokenFromStorage } from './storage-decryption.js';
|
|
16
|
-
// ============================================================================
|
|
17
|
-
// API Client
|
|
18
|
-
// ============================================================================
|
|
19
|
-
export class KawaApi {
|
|
20
|
-
baseUrl;
|
|
21
|
-
authToken;
|
|
22
|
-
constructor(baseUrl, authToken) {
|
|
23
|
-
this.baseUrl = (baseUrl || process.env.KAWA_API_URL || 'https://api.codeawareness.com').replace(/\/$/, '');
|
|
24
|
-
// Auth token resolution order:
|
|
25
|
-
// 1. Explicit parameter
|
|
26
|
-
// 2. Environment variable
|
|
27
|
-
// 3. Storage file (auto-decrypted)
|
|
28
|
-
this.authToken = authToken || process.env.KAWA_AUTH_TOKEN || '';
|
|
29
|
-
if (!this.authToken) {
|
|
30
|
-
// Try to load from Muninn storage
|
|
31
|
-
const tokenFromStorage = getAuthTokenFromStorage();
|
|
32
|
-
if (tokenFromStorage) {
|
|
33
|
-
this.authToken = tokenFromStorage;
|
|
34
|
-
console.error('Loaded auth token from Muninn storage (~/.kawa-code/.storage.caw)');
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
console.error('Warning: No auth token available. Tried:');
|
|
38
|
-
console.error(' 1. KAWA_AUTH_TOKEN environment variable (not set)');
|
|
39
|
-
console.error(' 2. ~/.kawa-code/.storage.caw (not found or not decryptable)');
|
|
40
|
-
console.error(' → API calls will fail until you log in to Muninn');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// --------------------------------------------------------------------------
|
|
45
|
-
// Auth Token Management
|
|
46
|
-
// --------------------------------------------------------------------------
|
|
47
|
-
/**
|
|
48
|
-
* Refresh the auth token from storage
|
|
49
|
-
*
|
|
50
|
-
* Call this periodically to pick up token refreshes from Muninn.
|
|
51
|
-
* Returns true if a new token was loaded.
|
|
52
|
-
*/
|
|
53
|
-
refreshTokenFromStorage() {
|
|
54
|
-
const tokenFromStorage = getAuthTokenFromStorage();
|
|
55
|
-
if (tokenFromStorage && tokenFromStorage !== this.authToken) {
|
|
56
|
-
this.authToken = tokenFromStorage;
|
|
57
|
-
console.error('Refreshed auth token from Muninn storage');
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Check if the client has an auth token
|
|
64
|
-
*/
|
|
65
|
-
hasAuthToken() {
|
|
66
|
-
return this.authToken.length > 0;
|
|
67
|
-
}
|
|
68
|
-
// --------------------------------------------------------------------------
|
|
69
|
-
// Intents
|
|
70
|
-
// --------------------------------------------------------------------------
|
|
71
|
-
async listIntents(origin, lang = 'en', since) {
|
|
72
|
-
const params = { origin, lang };
|
|
73
|
-
if (since)
|
|
74
|
-
params.since = since;
|
|
75
|
-
const data = await this.get('/v1/intents', params);
|
|
76
|
-
return data.intents || [];
|
|
77
|
-
}
|
|
78
|
-
async createIntent(params) {
|
|
79
|
-
const body = {
|
|
80
|
-
origin: params.origin,
|
|
81
|
-
lang: params.lang || 'en',
|
|
82
|
-
title: params.title,
|
|
83
|
-
description: params.description,
|
|
84
|
-
templateType: params.templateType || 'feature',
|
|
85
|
-
constraints: params.constraints || [],
|
|
86
|
-
scope: params.scope || { type: 'repo', paths: [] },
|
|
87
|
-
blocks: params.blocks || [],
|
|
88
|
-
branch: params.branch,
|
|
89
|
-
forkedFrom: params.forkedFrom,
|
|
90
|
-
};
|
|
91
|
-
const data = await this.post('/v1/intents', body);
|
|
92
|
-
return {
|
|
93
|
-
intent: data.intent || data,
|
|
94
|
-
cloudId: data.intent?._id || data._id || ''
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
async getIntent(intentId, origin, lang = 'en') {
|
|
98
|
-
const data = await this.get(`/v1/intents/${intentId}`, { origin, lang });
|
|
99
|
-
return data.intent || data;
|
|
100
|
-
}
|
|
101
|
-
async updateIntent(intentId, origin, updates) {
|
|
102
|
-
const body = { origin, ...updates };
|
|
103
|
-
const data = await this.patch(`/v1/intents/${intentId}`, body);
|
|
104
|
-
return data.intent || data;
|
|
105
|
-
}
|
|
106
|
-
async deleteIntent(intentId, origin) {
|
|
107
|
-
await this.del(`/v1/intents/${intentId}`, { origin });
|
|
108
|
-
}
|
|
109
|
-
async getIntentsByFile(origin, filePath) {
|
|
110
|
-
const data = await this.get('/v1/intents/by-file', { origin, path: filePath });
|
|
111
|
-
return data.intents || [];
|
|
112
|
-
}
|
|
113
|
-
async getIntentsByLines(origin, filePath, startLine, endLine) {
|
|
114
|
-
const data = await this.get('/v1/intents/by-lines', {
|
|
115
|
-
origin,
|
|
116
|
-
path: filePath,
|
|
117
|
-
startLine: String(startLine),
|
|
118
|
-
endLine: String(endLine)
|
|
119
|
-
});
|
|
120
|
-
return data.intents || [];
|
|
121
|
-
}
|
|
122
|
-
async batchSaveIntents(origin, lang, intents) {
|
|
123
|
-
return this.post('/v1/intents/batch', { origin, lang, intents });
|
|
124
|
-
}
|
|
125
|
-
// Translations
|
|
126
|
-
async saveIntentTranslation(intentId, origin, lang, title, description) {
|
|
127
|
-
return this.post(`/v1/intents/${intentId}/translations`, {
|
|
128
|
-
origin, lang, title, description
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
async getIntentTranslation(intentId, origin, lang) {
|
|
132
|
-
try {
|
|
133
|
-
return await this.get(`/v1/intents/${intentId}/translations/${lang}`, { origin });
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// --------------------------------------------------------------------------
|
|
140
|
-
// Decisions
|
|
141
|
-
// --------------------------------------------------------------------------
|
|
142
|
-
async getTeamDecisions(origin, since) {
|
|
143
|
-
const params = { origin };
|
|
144
|
-
if (since)
|
|
145
|
-
params.since = since;
|
|
146
|
-
const data = await this.get('/v1/decisions/team', params);
|
|
147
|
-
return data.decisions || [];
|
|
148
|
-
}
|
|
149
|
-
async getIntentDecisions(intentId, origin) {
|
|
150
|
-
const data = await this.get(`/v1/decisions/intent/${intentId}`, { origin });
|
|
151
|
-
return data.decisions || [];
|
|
152
|
-
}
|
|
153
|
-
async syncDecisions(origin, intentId, decisions) {
|
|
154
|
-
return this.post('/v1/decisions/sync', { origin, intentId, decisions });
|
|
155
|
-
}
|
|
156
|
-
async deleteDecision(decisionId, origin) {
|
|
157
|
-
await this.del(`/v1/decisions/${decisionId}`, { origin });
|
|
158
|
-
}
|
|
159
|
-
// --------------------------------------------------------------------------
|
|
160
|
-
// Search
|
|
161
|
-
// --------------------------------------------------------------------------
|
|
162
|
-
async searchRelevantContext(origin, query, activeFiles, options) {
|
|
163
|
-
return this.post('/v1/search', { origin, query, activeFiles, ...options });
|
|
164
|
-
}
|
|
165
|
-
// --------------------------------------------------------------------------
|
|
166
|
-
// HTTP helpers
|
|
167
|
-
// --------------------------------------------------------------------------
|
|
168
|
-
async get(path, params) {
|
|
169
|
-
const url = new URL(this.baseUrl + path);
|
|
170
|
-
if (params) {
|
|
171
|
-
for (const [k, v] of Object.entries(params)) {
|
|
172
|
-
if (v !== undefined)
|
|
173
|
-
url.searchParams.set(k, v);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return this.request(url.toString(), { method: 'GET' });
|
|
177
|
-
}
|
|
178
|
-
async post(path, body) {
|
|
179
|
-
return this.request(this.baseUrl + path, {
|
|
180
|
-
method: 'POST',
|
|
181
|
-
headers: { 'Content-Type': 'application/json' },
|
|
182
|
-
body: JSON.stringify(body)
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
async patch(path, body) {
|
|
186
|
-
return this.request(this.baseUrl + path, {
|
|
187
|
-
method: 'PATCH',
|
|
188
|
-
headers: { 'Content-Type': 'application/json' },
|
|
189
|
-
body: JSON.stringify(body)
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
async del(path, params) {
|
|
193
|
-
const url = new URL(this.baseUrl + path);
|
|
194
|
-
if (params) {
|
|
195
|
-
for (const [k, v] of Object.entries(params)) {
|
|
196
|
-
if (v !== undefined)
|
|
197
|
-
url.searchParams.set(k, v);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return this.request(url.toString(), { method: 'DELETE' });
|
|
201
|
-
}
|
|
202
|
-
getBaseUrl() {
|
|
203
|
-
return this.baseUrl;
|
|
204
|
-
}
|
|
205
|
-
async request(url, init) {
|
|
206
|
-
const headers = {
|
|
207
|
-
...(init.headers || {}),
|
|
208
|
-
'Authorization': `Bearer ${this.authToken}`
|
|
209
|
-
};
|
|
210
|
-
let response;
|
|
211
|
-
try {
|
|
212
|
-
response = await fetch(url, { ...init, headers });
|
|
213
|
-
}
|
|
214
|
-
catch (err) {
|
|
215
|
-
const cause = err instanceof Error ? err.message : String(err);
|
|
216
|
-
throw new Error(`Cannot reach Kawa API at ${this.baseUrl} — ${init.method} ${url}: ${cause}`);
|
|
217
|
-
}
|
|
218
|
-
if (!response.ok) {
|
|
219
|
-
const text = await response.text().catch(() => '');
|
|
220
|
-
throw new Error(`API ${init.method} ${url} failed (${response.status}): ${text}`);
|
|
221
|
-
}
|
|
222
|
-
const contentType = response.headers.get('content-type') || '';
|
|
223
|
-
if (contentType.includes('application/json')) {
|
|
224
|
-
return response.json();
|
|
225
|
-
}
|
|
226
|
-
return {};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
// ============================================================================
|
|
230
|
-
// Singleton
|
|
231
|
-
// ============================================================================
|
|
232
|
-
let instance = null;
|
|
233
|
-
export function getApi() {
|
|
234
|
-
if (!instance) {
|
|
235
|
-
instance = new KawaApi();
|
|
236
|
-
}
|
|
237
|
-
return instance;
|
|
238
|
-
}
|
|
239
|
-
//# sourceMappingURL=kawa-api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kawa-api.js","sourceRoot":"","sources":["../../src/services/kawa-api.ts"],"names":[],"mappings":"AAAA;;;;;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C;CACF;AAED,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,IAAI,QAAQ,GAAmB,IAAI,CAAA;AAEnC,MAAM,UAAU,MAAM;IACpB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAA;IAC1B,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository content encryption for zero-knowledge block assignment.
|
|
3
|
-
*
|
|
4
|
-
* Replicates Muninn Gardener's encryption.rs for intent block content:
|
|
5
|
-
* - Key derivation: PBKDF2-HMAC-SHA256, 600,000 iterations
|
|
6
|
-
* - Key material: "{initialCommitSHA}-{origin}"
|
|
7
|
-
* - Salt: "kawa-code-zero-knowledge-v1"
|
|
8
|
-
* - Cipher: AES-256-GCM with random 12-byte IV
|
|
9
|
-
* - Output: JSON string {"encryptedContent", "iv", "authTag"}
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Derive a 32-byte AES key from the repo's initial commit SHA and origin.
|
|
13
|
-
*
|
|
14
|
-
* Matches Muninn's derive_repository_key():
|
|
15
|
-
* - key material = "{initialCommit}-{origin}"
|
|
16
|
-
* - salt = "kawa-code-zero-knowledge-v1"
|
|
17
|
-
* - 600,000 PBKDF2-HMAC-SHA256 iterations
|
|
18
|
-
*/
|
|
19
|
-
export declare function deriveRepoKey(initialCommit: string, origin: string): Buffer;
|
|
20
|
-
/**
|
|
21
|
-
* Get the initial (root) commit SHA for a repository.
|
|
22
|
-
*/
|
|
23
|
-
export declare function getInitialCommitSHA(repoPath: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Encrypt content using AES-256-GCM.
|
|
26
|
-
*
|
|
27
|
-
* Returns a JSON string matching Muninn's EncryptedContent format:
|
|
28
|
-
* { "encryptedContent": hex, "iv": hex, "authTag": hex }
|
|
29
|
-
*
|
|
30
|
-
* The encryptedContent hex includes the 16-byte auth tag appended
|
|
31
|
-
* (AES-GCM ciphertext + tag), matching Gardener's Rust implementation.
|
|
32
|
-
*/
|
|
33
|
-
export declare function encryptContent(plaintext: string, key: Buffer): string;
|
|
34
|
-
/**
|
|
35
|
-
* Extract content from a file at the given line range and compute hash + snippet.
|
|
36
|
-
*
|
|
37
|
-
* Matches Gardener's IntentBlockService::extract_content_and_hash():
|
|
38
|
-
* - Lines are 1-based
|
|
39
|
-
* - snippet = first 150 characters
|
|
40
|
-
* - contentHash = SHA-256 of the whitespace-normalized plaintext (hex)
|
|
41
|
-
*/
|
|
42
|
-
export declare function extractContentAndHash(fileContent: string, startLine: number, endLine: number): {
|
|
43
|
-
content: string;
|
|
44
|
-
contentHash: string;
|
|
45
|
-
contentSnippet: string;
|
|
46
|
-
};
|