@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
|
@@ -1,92 +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
|
-
import * as crypto from 'crypto';
|
|
12
|
-
import { execSync } from 'child_process';
|
|
13
|
-
// Cache derived keys by "initialCommit:origin" to avoid repeated 600K-iteration PBKDF2
|
|
14
|
-
const keyCache = new Map();
|
|
15
|
-
/**
|
|
16
|
-
* Derive a 32-byte AES key from the repo's initial commit SHA and origin.
|
|
17
|
-
*
|
|
18
|
-
* Matches Muninn's derive_repository_key():
|
|
19
|
-
* - key material = "{initialCommit}-{origin}"
|
|
20
|
-
* - salt = "kawa-code-zero-knowledge-v1"
|
|
21
|
-
* - 600,000 PBKDF2-HMAC-SHA256 iterations
|
|
22
|
-
*/
|
|
23
|
-
export function deriveRepoKey(initialCommit, origin) {
|
|
24
|
-
const cacheKey = `${initialCommit.trim()}:${origin}`;
|
|
25
|
-
const cached = keyCache.get(cacheKey);
|
|
26
|
-
if (cached)
|
|
27
|
-
return cached;
|
|
28
|
-
const keyMaterial = `${initialCommit.trim()}-${origin}`;
|
|
29
|
-
const salt = 'kawa-code-zero-knowledge-v1';
|
|
30
|
-
const key = crypto.pbkdf2Sync(keyMaterial, salt, 600_000, 32, 'sha256');
|
|
31
|
-
keyCache.set(cacheKey, key);
|
|
32
|
-
return key;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get the initial (root) commit SHA for a repository.
|
|
36
|
-
*/
|
|
37
|
-
export function getInitialCommitSHA(repoPath) {
|
|
38
|
-
return execSync('git rev-list --max-parents=0 HEAD', {
|
|
39
|
-
cwd: repoPath,
|
|
40
|
-
encoding: 'utf-8',
|
|
41
|
-
timeout: 10000,
|
|
42
|
-
}).trim().split('\n')[0]; // Take first if multiple roots
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Encrypt content using AES-256-GCM.
|
|
46
|
-
*
|
|
47
|
-
* Returns a JSON string matching Muninn's EncryptedContent format:
|
|
48
|
-
* { "encryptedContent": hex, "iv": hex, "authTag": hex }
|
|
49
|
-
*
|
|
50
|
-
* The encryptedContent hex includes the 16-byte auth tag appended
|
|
51
|
-
* (AES-GCM ciphertext + tag), matching Gardener's Rust implementation.
|
|
52
|
-
*/
|
|
53
|
-
export function encryptContent(plaintext, key) {
|
|
54
|
-
const iv = crypto.randomBytes(12);
|
|
55
|
-
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
|
|
56
|
-
const encrypted = Buffer.concat([
|
|
57
|
-
cipher.update(plaintext, 'utf8'),
|
|
58
|
-
cipher.final(),
|
|
59
|
-
]);
|
|
60
|
-
const authTag = cipher.getAuthTag(); // 16 bytes
|
|
61
|
-
// Gardener appends authTag to ciphertext in encryptedContent
|
|
62
|
-
const ciphertextWithTag = Buffer.concat([encrypted, authTag]);
|
|
63
|
-
return JSON.stringify({
|
|
64
|
-
encryptedContent: ciphertextWithTag.toString('hex'),
|
|
65
|
-
iv: iv.toString('hex'),
|
|
66
|
-
authTag: authTag.toString('hex'),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Extract content from a file at the given line range and compute hash + snippet.
|
|
71
|
-
*
|
|
72
|
-
* Matches Gardener's IntentBlockService::extract_content_and_hash():
|
|
73
|
-
* - Lines are 1-based
|
|
74
|
-
* - snippet = first 150 characters
|
|
75
|
-
* - contentHash = SHA-256 of the whitespace-normalized plaintext (hex)
|
|
76
|
-
*/
|
|
77
|
-
export function extractContentAndHash(fileContent, startLine, endLine) {
|
|
78
|
-
const lines = fileContent.split('\n');
|
|
79
|
-
const startIdx = startLine - 1;
|
|
80
|
-
const endIdx = Math.min(endLine, lines.length);
|
|
81
|
-
if (startIdx >= lines.length) {
|
|
82
|
-
return { content: '', contentHash: '', contentSnippet: '' };
|
|
83
|
-
}
|
|
84
|
-
const content = lines.slice(startIdx, endIdx).join('\n');
|
|
85
|
-
const contentSnippet = content.slice(0, 150);
|
|
86
|
-
const contentHash = crypto
|
|
87
|
-
.createHash('sha256')
|
|
88
|
-
.update(content.trim())
|
|
89
|
-
.digest('hex');
|
|
90
|
-
return { content, contentHash, contentSnippet };
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=repo-encryption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-encryption.js","sourceRoot":"","sources":["../../src/services/repo-encryption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,uFAAuF;AACvF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,aAAqB,EAAE,MAAc;IACjE,MAAM,QAAQ,GAAG,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAA;IACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACrC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IAEzB,MAAM,WAAW,GAAG,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAA;IACvD,MAAM,IAAI,GAAG,6BAA6B,CAAA;IAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;IAEvE,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAC3B,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IACl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IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAE9C,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,CAAA;IAC7D,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxD,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5C,MAAM,WAAW,GAAG,MAAM;SACvB,UAAU,CAAC,QAAQ,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SACtB,MAAM,CAAC,KAAK,CAAC,CAAA;IAEhB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,CAAA;AACjD,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage decryption service for reading auth tokens from Muninn's encrypted storage.
|
|
3
|
-
*
|
|
4
|
-
* This module replicates Muninn's storage encryption scheme to read the auth token
|
|
5
|
-
* from ~/.kawa-code/.storage.caw without requiring manual env var configuration.
|
|
6
|
-
*
|
|
7
|
-
* Encryption details (must match Muninn's encryption.rs):
|
|
8
|
-
* - Key derivation: username:hostname with salt "kawa-storage-encryption-v1"
|
|
9
|
-
* - Algorithm: PBKDF2-HMAC-SHA256, 100,000 iterations
|
|
10
|
-
* - Cipher: AES-256-GCM
|
|
11
|
-
* - Format: hex(iv):hex(ciphertext):hex(auth_tag)
|
|
12
|
-
*/
|
|
13
|
-
export interface TokenObject {
|
|
14
|
-
_id: string;
|
|
15
|
-
token: string;
|
|
16
|
-
kind: string;
|
|
17
|
-
expires: string;
|
|
18
|
-
user: string;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
denied: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface AuthTokens {
|
|
23
|
-
access: TokenObject;
|
|
24
|
-
refresh?: TokenObject;
|
|
25
|
-
}
|
|
26
|
-
export interface StorageData {
|
|
27
|
-
auth?: {
|
|
28
|
-
user?: any;
|
|
29
|
-
tokens?: AuthTokens;
|
|
30
|
-
};
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Read and decrypt the storage file
|
|
35
|
-
*
|
|
36
|
-
* Returns the parsed storage data or null if unavailable/corrupted.
|
|
37
|
-
* Handles both encrypted and legacy unencrypted formats.
|
|
38
|
-
*/
|
|
39
|
-
export declare function readStorage(): StorageData | null;
|
|
40
|
-
/**
|
|
41
|
-
* Extract auth token from storage
|
|
42
|
-
*
|
|
43
|
-
* Returns the access token if available, otherwise null.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getAuthTokenFromStorage(): string | null;
|
|
46
|
-
/**
|
|
47
|
-
* Get full auth data from storage (user + tokens)
|
|
48
|
-
*/
|
|
49
|
-
export declare function getAuthFromStorage(): {
|
|
50
|
-
user: any;
|
|
51
|
-
tokens: AuthTokens;
|
|
52
|
-
} | null;
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage decryption service for reading auth tokens from Muninn's encrypted storage.
|
|
3
|
-
*
|
|
4
|
-
* This module replicates Muninn's storage encryption scheme to read the auth token
|
|
5
|
-
* from ~/.kawa-code/.storage.caw without requiring manual env var configuration.
|
|
6
|
-
*
|
|
7
|
-
* Encryption details (must match Muninn's encryption.rs):
|
|
8
|
-
* - Key derivation: username:hostname with salt "kawa-storage-encryption-v1"
|
|
9
|
-
* - Algorithm: PBKDF2-HMAC-SHA256, 100,000 iterations
|
|
10
|
-
* - Cipher: AES-256-GCM
|
|
11
|
-
* - Format: hex(iv):hex(ciphertext):hex(auth_tag)
|
|
12
|
-
*/
|
|
13
|
-
import * as crypto from 'crypto';
|
|
14
|
-
import * as fs from 'fs';
|
|
15
|
-
import * as os from 'os';
|
|
16
|
-
import * as path from 'path';
|
|
17
|
-
/**
|
|
18
|
-
* Derive storage encryption key from username and hostname
|
|
19
|
-
*
|
|
20
|
-
* Matches Muninn's derive_storage_key() implementation:
|
|
21
|
-
* - Key material: "username:hostname"
|
|
22
|
-
* - Salt: "kawa-storage-encryption-v1"
|
|
23
|
-
* - Algorithm: PBKDF2-HMAC-SHA256
|
|
24
|
-
* - Iterations: 100,000
|
|
25
|
-
* - Key length: 32 bytes
|
|
26
|
-
*/
|
|
27
|
-
function deriveStorageKey() {
|
|
28
|
-
const username = process.env.USER || process.env.USERNAME || 'unknown';
|
|
29
|
-
const hostname = os.hostname() || 'unknown';
|
|
30
|
-
const keyMaterial = `${username}:${hostname}`;
|
|
31
|
-
const salt = 'kawa-storage-encryption-v1';
|
|
32
|
-
// PBKDF2-HMAC-SHA256, 100,000 iterations, 32-byte output
|
|
33
|
-
return crypto.pbkdf2Sync(keyMaterial, salt, 100_000, 32, 'sha256');
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Decrypt storage file content
|
|
37
|
-
*
|
|
38
|
-
* Format: hex(iv):hex(ciphertext_with_auth_tag):hex(auth_tag)
|
|
39
|
-
* The ciphertext includes the auth tag at the end (last 16 bytes).
|
|
40
|
-
* AES-GCM verifies the auth tag automatically during decryption.
|
|
41
|
-
*/
|
|
42
|
-
function decryptStorage(encryptedData) {
|
|
43
|
-
const key = deriveStorageKey();
|
|
44
|
-
// Parse format: hex(iv):hex(ciphertext):hex(auth_tag)
|
|
45
|
-
const parts = encryptedData.split(':');
|
|
46
|
-
if (parts.length !== 3) {
|
|
47
|
-
throw new Error('Invalid encrypted storage format (expected 3 parts)');
|
|
48
|
-
}
|
|
49
|
-
const iv = Buffer.from(parts[0], 'hex');
|
|
50
|
-
const ciphertextWithTag = Buffer.from(parts[1], 'hex');
|
|
51
|
-
const authTag = Buffer.from(parts[2], 'hex');
|
|
52
|
-
// Verify IV length
|
|
53
|
-
if (iv.length !== 12) {
|
|
54
|
-
throw new Error(`Invalid IV length (expected 12, got ${iv.length})`);
|
|
55
|
-
}
|
|
56
|
-
// Verify auth tag length
|
|
57
|
-
if (authTag.length !== 16) {
|
|
58
|
-
throw new Error(`Invalid auth tag length (expected 16, got ${authTag.length})`);
|
|
59
|
-
}
|
|
60
|
-
// Create decipher for AES-256-GCM
|
|
61
|
-
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
|
|
62
|
-
decipher.setAuthTag(authTag);
|
|
63
|
-
// Decrypt (note: ciphertextWithTag includes the auth tag at the end, but we
|
|
64
|
-
// extract just the ciphertext portion for decryption since we set the auth tag separately)
|
|
65
|
-
const ciphertext = ciphertextWithTag.subarray(0, ciphertextWithTag.length - 16);
|
|
66
|
-
let plaintext = decipher.update(ciphertext, undefined, 'utf8');
|
|
67
|
-
plaintext += decipher.final('utf8');
|
|
68
|
-
return plaintext;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Check if content is in encrypted storage format
|
|
72
|
-
*
|
|
73
|
-
* Encrypted format: hex(iv):hex(ciphertext):hex(auth_tag)
|
|
74
|
-
* All three parts should be valid hex strings
|
|
75
|
-
*/
|
|
76
|
-
function isEncryptedStorage(content) {
|
|
77
|
-
const parts = content.split(':');
|
|
78
|
-
if (parts.length !== 3) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
// All parts should be valid hex (even length, only hex chars)
|
|
82
|
-
return parts.every(part => {
|
|
83
|
-
return part.length > 0 &&
|
|
84
|
-
part.length % 2 === 0 &&
|
|
85
|
-
/^[0-9a-fA-F]+$/.test(part);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get the storage file path
|
|
90
|
-
*
|
|
91
|
-
* Returns ~/.kawa-code/.storage.caw
|
|
92
|
-
*/
|
|
93
|
-
function getStoragePath() {
|
|
94
|
-
const homeDir = os.homedir();
|
|
95
|
-
return path.join(homeDir, '.kawa-code', '.storage.caw');
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Read and decrypt the storage file
|
|
99
|
-
*
|
|
100
|
-
* Returns the parsed storage data or null if unavailable/corrupted.
|
|
101
|
-
* Handles both encrypted and legacy unencrypted formats.
|
|
102
|
-
*/
|
|
103
|
-
export function readStorage() {
|
|
104
|
-
try {
|
|
105
|
-
const storagePath = getStoragePath();
|
|
106
|
-
if (!fs.existsSync(storagePath)) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const content = fs.readFileSync(storagePath, 'utf8').trim();
|
|
110
|
-
if (!content) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
// Decrypt if encrypted, otherwise treat as legacy plaintext JSON
|
|
114
|
-
let plaintext;
|
|
115
|
-
if (isEncryptedStorage(content)) {
|
|
116
|
-
try {
|
|
117
|
-
plaintext = decryptStorage(content);
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
console.error('Failed to decrypt storage (hostname/username may have changed):', err);
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// Legacy unencrypted format
|
|
126
|
-
plaintext = content;
|
|
127
|
-
}
|
|
128
|
-
// Parse JSON
|
|
129
|
-
const data = JSON.parse(plaintext);
|
|
130
|
-
return data;
|
|
131
|
-
}
|
|
132
|
-
catch (err) {
|
|
133
|
-
console.error('Failed to read storage file:', err);
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Extract auth token from storage
|
|
139
|
-
*
|
|
140
|
-
* Returns the access token if available, otherwise null.
|
|
141
|
-
*/
|
|
142
|
-
export function getAuthTokenFromStorage() {
|
|
143
|
-
const storage = readStorage();
|
|
144
|
-
if (!storage?.auth?.tokens?.access?.token) {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
return storage.auth.tokens.access.token;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get full auth data from storage (user + tokens)
|
|
151
|
-
*/
|
|
152
|
-
export function getAuthFromStorage() {
|
|
153
|
-
const storage = readStorage();
|
|
154
|
-
if (!storage?.auth?.user || !storage?.auth?.tokens) {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
user: storage.auth.user,
|
|
159
|
-
tokens: storage.auth.tokens
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=storage-decryption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage-decryption.js","sourceRoot":"","sources":["../../src/services/storage-decryption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAyB5B;;;;;;;;;GASG;AACH,SAAS,gBAAgB;IACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,SAAS,CAAA;IACtE,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAA;IAC3C,MAAM,WAAW,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;IAC7C,MAAM,IAAI,GAAG,4BAA4B,CAAA;IAEzC,yDAAyD;IACzD,OAAO,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;AACpE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,aAAqB;IAC3C,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAA;IAE9B,sDAAsD;IACtD,MAAM,KAAK,GA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CAAC,iEAAiE,EAAE,GAAG,CAAC,CAAA;gBACrF,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;aAAM,CAAC;YACN,4BAA4B;YAC5B,SAAS,GAAG,OAAO,CAAA;QACrB,CAAC;QAED,aAAa;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAgB,CAAA;QACjD,OAAO,IAAI,CAAA;IAEb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;QAClD,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAA;IAE7B,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAA;IAE7B,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACnD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;QACvB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;KAC5B,CAAA;AACH,CAAC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const assignBlocksSchema: z.ZodObject<{
|
|
3
|
-
repoOrigin: z.ZodOptional<z.ZodString>;
|
|
4
|
-
repoPath: z.ZodString;
|
|
5
|
-
intentId: z.ZodString;
|
|
6
|
-
blocks: z.ZodArray<z.ZodObject<{
|
|
7
|
-
filePath: z.ZodString;
|
|
8
|
-
startLine: z.ZodNumber;
|
|
9
|
-
endLine: z.ZodNumber;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
filePath: string;
|
|
12
|
-
startLine: number;
|
|
13
|
-
endLine: number;
|
|
14
|
-
}, {
|
|
15
|
-
filePath: string;
|
|
16
|
-
startLine: number;
|
|
17
|
-
endLine: number;
|
|
18
|
-
}>, "many">;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
repoPath: string;
|
|
21
|
-
intentId: string;
|
|
22
|
-
blocks: {
|
|
23
|
-
filePath: string;
|
|
24
|
-
startLine: number;
|
|
25
|
-
endLine: number;
|
|
26
|
-
}[];
|
|
27
|
-
repoOrigin?: string | undefined;
|
|
28
|
-
}, {
|
|
29
|
-
repoPath: string;
|
|
30
|
-
intentId: string;
|
|
31
|
-
blocks: {
|
|
32
|
-
filePath: string;
|
|
33
|
-
startLine: number;
|
|
34
|
-
endLine: number;
|
|
35
|
-
}[];
|
|
36
|
-
repoOrigin?: string | undefined;
|
|
37
|
-
}>;
|
|
38
|
-
export type AssignBlocksInput = z.infer<typeof assignBlocksSchema>;
|
|
39
|
-
export interface AssignBlocksResponse {
|
|
40
|
-
success: boolean;
|
|
41
|
-
assignedBlocks: number;
|
|
42
|
-
intentId: string;
|
|
43
|
-
intentTitle: string;
|
|
44
|
-
message: string;
|
|
45
|
-
}
|
|
46
|
-
export declare function assignBlocksToIntent(input: AssignBlocksInput): Promise<AssignBlocksResponse>;
|
|
47
|
-
export declare const assignBlocksToIntentTool: {
|
|
48
|
-
name: string;
|
|
49
|
-
description: string;
|
|
50
|
-
inputSchema: z.ZodObject<{
|
|
51
|
-
repoOrigin: z.ZodOptional<z.ZodString>;
|
|
52
|
-
repoPath: z.ZodString;
|
|
53
|
-
intentId: z.ZodString;
|
|
54
|
-
blocks: z.ZodArray<z.ZodObject<{
|
|
55
|
-
filePath: z.ZodString;
|
|
56
|
-
startLine: z.ZodNumber;
|
|
57
|
-
endLine: z.ZodNumber;
|
|
58
|
-
}, "strip", z.ZodTypeAny, {
|
|
59
|
-
filePath: string;
|
|
60
|
-
startLine: number;
|
|
61
|
-
endLine: number;
|
|
62
|
-
}, {
|
|
63
|
-
filePath: string;
|
|
64
|
-
startLine: number;
|
|
65
|
-
endLine: number;
|
|
66
|
-
}>, "many">;
|
|
67
|
-
}, "strip", z.ZodTypeAny, {
|
|
68
|
-
repoPath: string;
|
|
69
|
-
intentId: string;
|
|
70
|
-
blocks: {
|
|
71
|
-
filePath: string;
|
|
72
|
-
startLine: number;
|
|
73
|
-
endLine: number;
|
|
74
|
-
}[];
|
|
75
|
-
repoOrigin?: string | undefined;
|
|
76
|
-
}, {
|
|
77
|
-
repoPath: string;
|
|
78
|
-
intentId: string;
|
|
79
|
-
blocks: {
|
|
80
|
-
filePath: string;
|
|
81
|
-
startLine: number;
|
|
82
|
-
endLine: number;
|
|
83
|
-
}[];
|
|
84
|
-
repoOrigin?: string | undefined;
|
|
85
|
-
}>;
|
|
86
|
-
handler: typeof assignBlocksToIntent;
|
|
87
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { request } from '../services/muninn-ipc.js';
|
|
3
|
-
import { resolveOrigin } from './resolve-origin.js';
|
|
4
|
-
export const assignBlocksSchema = 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().describe('The intent ID to assign blocks to'),
|
|
8
|
-
blocks: z.array(z.object({
|
|
9
|
-
filePath: z.string().describe('Path to the file (relative to repo root)'),
|
|
10
|
-
startLine: z.number().min(1).describe('Start line number (1-based)'),
|
|
11
|
-
endLine: z.number().min(1).describe('End line number (1-based, inclusive)')
|
|
12
|
-
})).describe('Code blocks to assign to the active intent')
|
|
13
|
-
});
|
|
14
|
-
export async function assignBlocksToIntent(input) {
|
|
15
|
-
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
16
|
-
// Delegate all file I/O, encryption, and API sync to Muninn
|
|
17
|
-
const res = await request('intent-block', 'batch-assign', {
|
|
18
|
-
repoOrigin: actualOrigin,
|
|
19
|
-
repoPath: input.repoPath,
|
|
20
|
-
intentId: input.intentId,
|
|
21
|
-
blocks: input.blocks.map(b => ({
|
|
22
|
-
filePath: b.filePath,
|
|
23
|
-
startLine: b.startLine,
|
|
24
|
-
endLine: b.endLine,
|
|
25
|
-
})),
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
success: res.success !== false,
|
|
29
|
-
assignedBlocks: res.count || res.assignedCount || input.blocks.length,
|
|
30
|
-
intentId: res.intentId || '',
|
|
31
|
-
intentTitle: res.intentTitle || 'Active Intent',
|
|
32
|
-
message: `Assigned ${res.count || input.blocks.length} code block(s) to active intent`
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export const assignBlocksToIntentTool = {
|
|
36
|
-
name: 'assign_blocks_to_intent',
|
|
37
|
-
description: `Assign code blocks to the currently active intent.
|
|
38
|
-
|
|
39
|
-
Call this AFTER writing code to track which lines were modified:
|
|
40
|
-
1. For each file you modified, provide the line range
|
|
41
|
-
2. Blocks get assigned to the active intent
|
|
42
|
-
3. This enables tracking, conflict detection, and team visibility
|
|
43
|
-
|
|
44
|
-
Example: After adding a function at lines 50-75 in auth.ts, call with:
|
|
45
|
-
{ blocks: [{ filePath: "src/auth.ts", startLine: 50, endLine: 75 }] }`,
|
|
46
|
-
inputSchema: assignBlocksSchema,
|
|
47
|
-
handler: assignBlocksToIntent
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=assign-blocks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assign-blocks.js","sourceRoot":"","sources":["../../src/tools/assign-blocks.ts"],"names":[],"mapp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EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC7B,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;KACJ,CAAC,CAAA;IAEF,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,KAAK;QAC9B,cAAc,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,aAAa,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM;QACrE,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE;QAC5B,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,eAAe;QAC/C,OAAO,EAAE,YAAY,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,iCAAiC;KACvF,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE;;;;;;;;sEAQuD;IACpE,WAAW,EAAE,kBAAkB;IAC/B,OAAO,EAAE,oBAAoB;CAC9B,CAAA"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const getProjectContextSchema: z.ZodObject<{
|
|
3
|
-
repoOrigin: z.ZodString;
|
|
4
|
-
repoPath: z.ZodString;
|
|
5
|
-
maxDecisions: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
6
|
-
maxTeamIntents: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
-
includeTeamIntents: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
repoOrigin: string;
|
|
10
|
-
repoPath: string;
|
|
11
|
-
maxDecisions: number;
|
|
12
|
-
maxTeamIntents: number;
|
|
13
|
-
includeTeamIntents: boolean;
|
|
14
|
-
}, {
|
|
15
|
-
repoOrigin: string;
|
|
16
|
-
repoPath: string;
|
|
17
|
-
maxDecisions?: number | undefined;
|
|
18
|
-
maxTeamIntents?: number | undefined;
|
|
19
|
-
includeTeamIntents?: boolean | undefined;
|
|
20
|
-
}>;
|
|
21
|
-
export type GetProjectContextInput = z.infer<typeof getProjectContextSchema>;
|
|
22
|
-
export interface ActiveIntent {
|
|
23
|
-
id: string;
|
|
24
|
-
title: string;
|
|
25
|
-
description: string;
|
|
26
|
-
templateType: string;
|
|
27
|
-
status: string;
|
|
28
|
-
branch: string;
|
|
29
|
-
}
|
|
30
|
-
export interface TeamIntent {
|
|
31
|
-
id: string;
|
|
32
|
-
title: string;
|
|
33
|
-
author: string;
|
|
34
|
-
status: string;
|
|
35
|
-
templateType: string;
|
|
36
|
-
}
|
|
37
|
-
export interface RecentDecision {
|
|
38
|
-
intentId: string;
|
|
39
|
-
type: string;
|
|
40
|
-
summary: string;
|
|
41
|
-
}
|
|
42
|
-
export interface GetProjectContextResponse {
|
|
43
|
-
projectOrigin: string;
|
|
44
|
-
projectPath: string;
|
|
45
|
-
activeIntent: ActiveIntent | null;
|
|
46
|
-
teamIntents: TeamIntent[];
|
|
47
|
-
teamIntentCount: number;
|
|
48
|
-
recentDecisions: RecentDecision[];
|
|
49
|
-
summary: {
|
|
50
|
-
hasActiveIntent: boolean;
|
|
51
|
-
activeIntentTitle: string | null;
|
|
52
|
-
teamMembersWorking: number;
|
|
53
|
-
teamIntentsShown: number;
|
|
54
|
-
teamIntentsTotal: number;
|
|
55
|
-
recentDecisionCount: number;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export declare function getProjectContext(input: GetProjectContextInput): Promise<GetProjectContextResponse>;
|
|
59
|
-
export declare const getProjectContextTool: {
|
|
60
|
-
name: string;
|
|
61
|
-
description: string;
|
|
62
|
-
inputSchema: z.ZodObject<{
|
|
63
|
-
repoOrigin: z.ZodString;
|
|
64
|
-
repoPath: z.ZodString;
|
|
65
|
-
maxDecisions: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
66
|
-
maxTeamIntents: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
67
|
-
includeTeamIntents: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
68
|
-
}, "strip", z.ZodTypeAny, {
|
|
69
|
-
repoOrigin: string;
|
|
70
|
-
repoPath: string;
|
|
71
|
-
maxDecisions: number;
|
|
72
|
-
maxTeamIntents: number;
|
|
73
|
-
includeTeamIntents: boolean;
|
|
74
|
-
}, {
|
|
75
|
-
repoOrigin: string;
|
|
76
|
-
repoPath: string;
|
|
77
|
-
maxDecisions?: number | undefined;
|
|
78
|
-
maxTeamIntents?: number | undefined;
|
|
79
|
-
includeTeamIntents?: boolean | undefined;
|
|
80
|
-
}>;
|
|
81
|
-
handler: typeof getProjectContext;
|
|
82
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { request } from '../services/muninn-ipc.js';
|
|
3
|
-
import { resolveOrigin } from './resolve-origin.js';
|
|
4
|
-
export const getProjectContextSchema = z.object({
|
|
5
|
-
repoOrigin: z.string().describe('Git remote origin URL (e.g., git@github.com:user/repo.git)'),
|
|
6
|
-
repoPath: z.string().describe('Local path to the repository root'),
|
|
7
|
-
maxDecisions: z.number().optional().default(3).describe('Maximum number of recent decisions to return'),
|
|
8
|
-
maxTeamIntents: z.number().optional().default(5).describe('Maximum number of team intents to return'),
|
|
9
|
-
includeTeamIntents: z.boolean().optional().default(true).describe('Whether to include team intents')
|
|
10
|
-
});
|
|
11
|
-
export async function getProjectContext(input) {
|
|
12
|
-
const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
|
|
13
|
-
const res = await request('claude-code', 'project-context', {
|
|
14
|
-
repoOrigin: actualOrigin,
|
|
15
|
-
maxDecisions: input.maxDecisions,
|
|
16
|
-
maxTeamIntents: input.maxTeamIntents,
|
|
17
|
-
includeTeamIntents: input.includeTeamIntents,
|
|
18
|
-
});
|
|
19
|
-
// Transform Muninn response to MCP response format
|
|
20
|
-
const activeIntent = res.activeIntent
|
|
21
|
-
? {
|
|
22
|
-
id: res.activeIntent.id || '',
|
|
23
|
-
title: res.activeIntent.title || '',
|
|
24
|
-
description: res.activeIntent.description || '',
|
|
25
|
-
templateType: res.activeIntent.templateType || 'feature',
|
|
26
|
-
status: res.activeIntent.status || 'active',
|
|
27
|
-
branch: res.activeIntent.branch || ''
|
|
28
|
-
}
|
|
29
|
-
: null;
|
|
30
|
-
const teamIntents = (res.teamIntents || []).map((i) => ({
|
|
31
|
-
id: i.id || '',
|
|
32
|
-
title: i.title || '',
|
|
33
|
-
author: i.author || i.authorName || 'Unknown',
|
|
34
|
-
status: i.status || 'active',
|
|
35
|
-
templateType: i.templateType || 'feature',
|
|
36
|
-
}));
|
|
37
|
-
const recentDecisions = (res.recentDecisions || []).map((d) => ({
|
|
38
|
-
intentId: d.intentId || '',
|
|
39
|
-
type: d.decisionType || d.type || '',
|
|
40
|
-
summary: d.summary || '',
|
|
41
|
-
}));
|
|
42
|
-
const uniqueAuthors = new Set(teamIntents.map(i => i.author));
|
|
43
|
-
return {
|
|
44
|
-
projectOrigin: actualOrigin,
|
|
45
|
-
projectPath: input.repoPath,
|
|
46
|
-
activeIntent,
|
|
47
|
-
teamIntents,
|
|
48
|
-
teamIntentCount: teamIntents.length,
|
|
49
|
-
recentDecisions,
|
|
50
|
-
summary: {
|
|
51
|
-
hasActiveIntent: activeIntent !== null,
|
|
52
|
-
activeIntentTitle: activeIntent?.title || null,
|
|
53
|
-
teamMembersWorking: uniqueAuthors.size,
|
|
54
|
-
teamIntentsShown: teamIntents.length,
|
|
55
|
-
teamIntentsTotal: res.teamIntentsTotal || teamIntents.length,
|
|
56
|
-
recentDecisionCount: recentDecisions.length
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export const getProjectContextTool = {
|
|
61
|
-
name: 'get_project_context',
|
|
62
|
-
description: `Get project status overview before starting work. CALL THIS AT THE START OF EVERY CODING SESSION.
|
|
63
|
-
|
|
64
|
-
Returns a lightweight status check:
|
|
65
|
-
- **Active intent**: What you're currently working on (id, title, status)
|
|
66
|
-
- **Team intents**: What teammates are working on (titles only, see summary for total count)
|
|
67
|
-
- **Recent decisions**: Summary-only (type + one-liner) — use get_relevant_context for full rationale
|
|
68
|
-
|
|
69
|
-
This is a **status check**, not a knowledge dump. For task-specific context (full decision rationale, file-level conflicts), call get_relevant_context after exploring the user's request.`,
|
|
70
|
-
inputSchema: getProjectContextSchema,
|
|
71
|
-
handler: getProjectContext
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=get-project-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-project-context.js","sourceRoot":"","sources":["../../src/tools/get-project-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4DAA4D,CAAC;IAC7F,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAClE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IACvG,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACrG,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE,CA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