@aaac/runtime 0.1.44 → 0.1.49
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/dist/adapters/adk-sdk.js +3 -3
- package/dist/{chunk-IGSKPSU3.js → chunk-C6XCN33A.js} +5 -5
- package/dist/chunk-VMJPJ7B7.js +316 -0
- package/dist/chunk-VMJPJ7B7.js.map +1 -0
- package/dist/{chunk-735UA5HV.js → chunk-YZQRSVDZ.js} +41 -4
- package/dist/chunk-YZQRSVDZ.js.map +1 -0
- package/dist/claude-bundles/full.js +1154 -0
- package/dist/claude-bundles/lean.js +6 -0
- package/dist/generator/index.d.ts +13 -0
- package/dist/generator/index.js +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +741 -19
- package/dist/index.js.map +1 -1
- package/dist/lib/claude-native/hooks-lite.d.ts +314 -0
- package/dist/lib/claude-native/hooks-lite.js +44 -0
- package/dist/lib/claude-native/hooks-lite.js.map +1 -0
- package/dist/lib/claude-native/index.d.ts +51 -207
- package/dist/lib/claude-native/index.js +71 -229
- package/dist/lib/claude-native/index.js.map +1 -1
- package/package.json +8 -3
- package/dist/chunk-735UA5HV.js.map +0 -1
- /package/dist/{chunk-IGSKPSU3.js.map → chunk-C6XCN33A.js.map} +0 -0
|
@@ -1,206 +1,49 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildNavigationContext,
|
|
3
3
|
renderNavigationIndexPrompt
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import {
|
|
6
|
-
createGuardrailHooksFromRules,
|
|
7
|
-
matchGlob
|
|
8
|
-
} from "../../chunk-EH5VFZYJ.js";
|
|
9
|
-
import "../../chunk-KXGUWBGK.js";
|
|
4
|
+
} from "../../chunk-C6XCN33A.js";
|
|
10
5
|
import "../../chunk-ET6TGQRT.js";
|
|
6
|
+
import "../../chunk-KXGUWBGK.js";
|
|
7
|
+
import {
|
|
8
|
+
TimeoutError,
|
|
9
|
+
buildAllowResponse,
|
|
10
|
+
buildContextResponse,
|
|
11
|
+
buildDenyResponse,
|
|
12
|
+
computeSourceHash,
|
|
13
|
+
createCacheStore,
|
|
14
|
+
createExclusiveLock,
|
|
15
|
+
createPreToolUseHandler,
|
|
16
|
+
createWorkspacePreToolUseHandler,
|
|
17
|
+
emitHookOutput,
|
|
18
|
+
isProtectedArtifact,
|
|
19
|
+
listArtifacts,
|
|
20
|
+
parseHookInput,
|
|
21
|
+
readHookInput,
|
|
22
|
+
resolvePathToArtifacts,
|
|
23
|
+
routePathToMember,
|
|
24
|
+
stripMemberPrefix,
|
|
25
|
+
withDegrade,
|
|
26
|
+
withTimeout
|
|
27
|
+
} from "../../chunk-VMJPJ7B7.js";
|
|
28
|
+
import "../../chunk-EH5VFZYJ.js";
|
|
11
29
|
|
|
12
|
-
// src/lib/claude-native/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
const raw = Buffer.concat(chunks).toString("utf-8").trim();
|
|
23
|
-
if (!raw) {
|
|
24
|
-
throw new Error("Empty stdin \u2014 no hook input received");
|
|
25
|
-
}
|
|
26
|
-
return parseHookInput(raw);
|
|
27
|
-
}
|
|
28
|
-
function emitHookOutput(output) {
|
|
29
|
-
process.stdout.write(JSON.stringify(output) + "\n");
|
|
30
|
-
}
|
|
31
|
-
function buildContextResponse(eventName, additionalContext) {
|
|
32
|
-
return {
|
|
33
|
-
hookSpecificOutput: {
|
|
34
|
-
hookEventName: eventName,
|
|
35
|
-
additionalContext
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function buildDenyResponse(reason) {
|
|
40
|
-
return {
|
|
41
|
-
hookSpecificOutput: {
|
|
42
|
-
hookEventName: "PreToolUse",
|
|
43
|
-
permissionDecision: "deny",
|
|
44
|
-
permissionDecisionReason: reason
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function buildAllowResponse() {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/lib/claude-native/cache-store.ts
|
|
53
|
-
import { readFile, writeFile, rename, stat, mkdir } from "fs/promises";
|
|
54
|
-
import { join } from "path";
|
|
55
|
-
import { randomBytes } from "crypto";
|
|
56
|
-
function createCacheStore(options) {
|
|
57
|
-
const { cacheDir } = options;
|
|
58
|
-
function cacheFilePath(key) {
|
|
59
|
-
return join(cacheDir, `${key}.json`);
|
|
60
|
-
}
|
|
61
|
-
async function ensureDir() {
|
|
62
|
-
await mkdir(cacheDir, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
const store = {
|
|
65
|
-
async read(key) {
|
|
66
|
-
try {
|
|
67
|
-
const raw = await readFile(cacheFilePath(key), "utf-8");
|
|
68
|
-
return JSON.parse(raw);
|
|
69
|
-
} catch {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
async write(key, data, sourceHash) {
|
|
74
|
-
await ensureDir();
|
|
75
|
-
const entry = {
|
|
76
|
-
data,
|
|
77
|
-
writtenAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
78
|
-
sourceHash
|
|
79
|
-
};
|
|
80
|
-
const content = JSON.stringify(entry, null, 2);
|
|
81
|
-
const target = cacheFilePath(key);
|
|
82
|
-
const tmpPath = `${target}.${randomBytes(4).toString("hex")}.tmp`;
|
|
83
|
-
await writeFile(tmpPath, content, "utf-8");
|
|
84
|
-
try {
|
|
85
|
-
await rename(tmpPath, target);
|
|
86
|
-
} catch {
|
|
87
|
-
await writeFile(target, content, "utf-8");
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
async readIfFresh(key, currentHash) {
|
|
91
|
-
const entry = await store.read(key);
|
|
92
|
-
if (!entry) return null;
|
|
93
|
-
if (entry.sourceHash !== currentHash) return null;
|
|
94
|
-
return entry.data;
|
|
95
|
-
},
|
|
96
|
-
async getFileMtime(filePath) {
|
|
97
|
-
try {
|
|
98
|
-
const s = await stat(filePath);
|
|
99
|
-
return s.mtimeMs;
|
|
100
|
-
} catch {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return store;
|
|
106
|
-
}
|
|
107
|
-
function computeSourceHash(inputs) {
|
|
108
|
-
return inputs.map(String).join(":");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// src/lib/claude-native/latency.ts
|
|
112
|
-
var TimeoutError = class extends Error {
|
|
113
|
-
constructor(ms) {
|
|
114
|
-
super(`Operation timed out after ${ms}ms`);
|
|
115
|
-
this.name = "TimeoutError";
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
async function withTimeout(promise, timeoutMs) {
|
|
119
|
-
if (timeoutMs <= 0) return promise;
|
|
120
|
-
let timer;
|
|
121
|
-
const timeout = new Promise((_resolve, reject) => {
|
|
122
|
-
timer = setTimeout(() => reject(new TimeoutError(timeoutMs)), timeoutMs);
|
|
123
|
-
});
|
|
124
|
-
try {
|
|
125
|
-
return await Promise.race([promise, timeout]);
|
|
126
|
-
} finally {
|
|
127
|
-
clearTimeout(timer);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function createExclusiveLock() {
|
|
131
|
-
let pending = null;
|
|
132
|
-
return {
|
|
133
|
-
async run(fn) {
|
|
134
|
-
if (pending) return pending;
|
|
135
|
-
pending = fn().finally(() => {
|
|
136
|
-
pending = null;
|
|
137
|
-
});
|
|
138
|
-
return pending;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
async function withDegrade(operation, fallback, timeoutMs) {
|
|
143
|
-
try {
|
|
144
|
-
const value = await withTimeout(operation(), timeoutMs);
|
|
145
|
-
return { value, degraded: false };
|
|
146
|
-
} catch (err) {
|
|
147
|
-
const reason = err instanceof TimeoutError ? err.message : err instanceof Error ? err.message : String(err);
|
|
148
|
-
return { value: fallback, degraded: true, reason };
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// src/lib/claude-native/artifact-resolver.ts
|
|
153
|
-
function resolvePathToArtifacts(filePath, navigationIndex) {
|
|
154
|
-
const artifacts = navigationIndex.artifacts ?? {};
|
|
155
|
-
const matches = [];
|
|
156
|
-
for (const [id, artifact] of Object.entries(artifacts)) {
|
|
157
|
-
const patterns = artifact?.files?.path_patterns;
|
|
158
|
-
if (!Array.isArray(patterns)) continue;
|
|
159
|
-
for (const pattern of patterns) {
|
|
160
|
-
if (typeof pattern !== "string") continue;
|
|
161
|
-
if (matchGlob(pattern, filePath)) {
|
|
162
|
-
matches.push({ artifactId: id, artifact, matchedPattern: pattern });
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return matches;
|
|
168
|
-
}
|
|
169
|
-
function isProtectedArtifact(match) {
|
|
170
|
-
const props = match.artifact.properties ?? {};
|
|
171
|
-
if (props.authority === "generated") {
|
|
172
|
-
const regen = match.artifact.routes?.regenerate;
|
|
173
|
-
const hint = regen ? ` Run '${regen}' to regenerate.` : " Edit the source artifact and regenerate instead.";
|
|
174
|
-
return {
|
|
175
|
-
protected: true,
|
|
176
|
-
reason: `File belongs to generated artifact '${match.artifactId}'. Direct editing is not allowed.${hint}`
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
if (props.manual_edit === "forbidden") {
|
|
180
|
-
return {
|
|
181
|
-
protected: true,
|
|
182
|
-
reason: `File belongs to artifact '${match.artifactId}' which has manual_edit: forbidden. This artifact must not be edited directly.`
|
|
183
|
-
};
|
|
30
|
+
// src/lib/claude-native/ensure-navigation-index.ts
|
|
31
|
+
import { stat } from "fs/promises";
|
|
32
|
+
var DEFAULT_CACHE_KEY = "navigation-index";
|
|
33
|
+
var buildLocks = /* @__PURE__ */ new Map();
|
|
34
|
+
function getBuildLock(key) {
|
|
35
|
+
let lock = buildLocks.get(key);
|
|
36
|
+
if (!lock) {
|
|
37
|
+
lock = createExclusiveLock();
|
|
38
|
+
buildLocks.set(key, lock);
|
|
184
39
|
}
|
|
185
|
-
return
|
|
186
|
-
}
|
|
187
|
-
function listArtifacts(navigationIndex) {
|
|
188
|
-
const artifacts = navigationIndex.artifacts ?? {};
|
|
189
|
-
return Object.entries(artifacts).map(([id, artifact]) => ({
|
|
190
|
-
id,
|
|
191
|
-
artifact
|
|
192
|
-
}));
|
|
40
|
+
return lock;
|
|
193
41
|
}
|
|
194
|
-
|
|
195
|
-
// src/lib/claude-native/ensure-navigation-index.ts
|
|
196
|
-
import { stat as stat2 } from "fs/promises";
|
|
197
|
-
var CACHE_KEY = "navigation-index";
|
|
198
|
-
var buildLock = createExclusiveLock();
|
|
199
42
|
async function computeCurrentHash(sourceFiles) {
|
|
200
43
|
const mtimes = [];
|
|
201
44
|
for (const file of sourceFiles) {
|
|
202
45
|
try {
|
|
203
|
-
const s = await
|
|
46
|
+
const s = await stat(file);
|
|
204
47
|
mtimes.push(s.mtimeMs);
|
|
205
48
|
} catch {
|
|
206
49
|
mtimes.push(`missing:${file}`);
|
|
@@ -209,11 +52,12 @@ async function computeCurrentHash(sourceFiles) {
|
|
|
209
52
|
return computeSourceHash(mtimes);
|
|
210
53
|
}
|
|
211
54
|
async function ensureNavigationIndex(options) {
|
|
212
|
-
|
|
55
|
+
const cacheKey = options.cacheKey ?? DEFAULT_CACHE_KEY;
|
|
56
|
+
return getBuildLock(cacheKey).run(async () => {
|
|
213
57
|
const store = createCacheStore({ cacheDir: options.cacheDir });
|
|
214
58
|
const currentHash = await computeCurrentHash(options.sourceFiles);
|
|
215
59
|
const cached = await store.readIfFresh(
|
|
216
|
-
|
|
60
|
+
cacheKey,
|
|
217
61
|
currentHash
|
|
218
62
|
);
|
|
219
63
|
if (cached) {
|
|
@@ -222,7 +66,7 @@ async function ensureNavigationIndex(options) {
|
|
|
222
66
|
const context = await buildNavigationContext(options.navigationOptions);
|
|
223
67
|
const navigationIndex = context.navigationIndex;
|
|
224
68
|
try {
|
|
225
|
-
await store.write(
|
|
69
|
+
await store.write(cacheKey, navigationIndex, currentHash);
|
|
226
70
|
} catch {
|
|
227
71
|
}
|
|
228
72
|
return { navigationIndex, fromCache: false };
|
|
@@ -379,41 +223,35 @@ function extractCandidateArtifacts(prompt, navigationIndex) {
|
|
|
379
223
|
return matches;
|
|
380
224
|
}
|
|
381
225
|
|
|
382
|
-
// src/lib/claude-native/
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
if (BASH_TOOLS.has(toolName) && guardrailHooks) {
|
|
406
|
-
const command = toolInput.command ?? "";
|
|
407
|
-
if (command) {
|
|
408
|
-
const hookResult = guardrailHooks.beforeShellExecution({ command });
|
|
409
|
-
if (hookResult.permission === "deny") {
|
|
410
|
-
return buildDenyResponse(
|
|
411
|
-
hookResult.user_message ?? "Command blocked by guardrail"
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
226
|
+
// src/lib/claude-native/workspace-session-start.ts
|
|
227
|
+
function createWorkspaceSessionStartHandler(config) {
|
|
228
|
+
return async function handleWorkspaceSessionStart(_input) {
|
|
229
|
+
const results = await Promise.all(
|
|
230
|
+
config.members.map(async (member) => {
|
|
231
|
+
const result = await ensureNavigationIndex({
|
|
232
|
+
cacheDir: config.cacheDir,
|
|
233
|
+
sourceFiles: member.sourceFiles,
|
|
234
|
+
navigationOptions: member.navigationOptions,
|
|
235
|
+
cacheKey: member.cacheKey
|
|
236
|
+
});
|
|
237
|
+
return { member, result };
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
const sections = [];
|
|
241
|
+
for (const { member, result } of results) {
|
|
242
|
+
const summary = renderNavigationIndexPrompt(result.navigationIndex);
|
|
243
|
+
const cacheNote = result.fromCache ? "(loaded from cache)" : "(freshly built)";
|
|
244
|
+
sections.push(
|
|
245
|
+
`### Member: ${member.name} ${cacheNote}
|
|
246
|
+
${summary}`
|
|
247
|
+
);
|
|
415
248
|
}
|
|
416
|
-
|
|
249
|
+
const additionalContext = [
|
|
250
|
+
sections.join("\n\n"),
|
|
251
|
+
"",
|
|
252
|
+
"Workspace navigation indices ready. Use analyzer MCP tools for deep investigation."
|
|
253
|
+
].join("\n");
|
|
254
|
+
return buildContextResponse("SessionStart", additionalContext);
|
|
417
255
|
};
|
|
418
256
|
}
|
|
419
257
|
export {
|
|
@@ -427,6 +265,8 @@ export {
|
|
|
427
265
|
createPreToolUseHandler,
|
|
428
266
|
createSessionStartHandler,
|
|
429
267
|
createUserPromptSubmitHandler,
|
|
268
|
+
createWorkspacePreToolUseHandler,
|
|
269
|
+
createWorkspaceSessionStartHandler,
|
|
430
270
|
emitHookOutput,
|
|
431
271
|
ensureNavigationIndex,
|
|
432
272
|
formatNdjson,
|
|
@@ -437,6 +277,8 @@ export {
|
|
|
437
277
|
parseHookInput,
|
|
438
278
|
readHookInput,
|
|
439
279
|
resolvePathToArtifacts,
|
|
280
|
+
routePathToMember,
|
|
281
|
+
stripMemberPrefix,
|
|
440
282
|
withDegrade,
|
|
441
283
|
withTimeout
|
|
442
284
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/claude-native/hook-protocol.ts","../../../src/lib/claude-native/cache-store.ts","../../../src/lib/claude-native/latency.ts","../../../src/lib/claude-native/artifact-resolver.ts","../../../src/lib/claude-native/ensure-navigation-index.ts","../../../src/lib/claude-native/file-suggestion.ts","../../../src/lib/claude-native/session-start.ts","../../../src/lib/claude-native/user-prompt-submit.ts","../../../src/lib/claude-native/pre-tool-use.ts"],"sourcesContent":["/**\n * Claude Code Hook Protocol — parse stdin JSON input and emit hook response JSON.\n *\n * Implements the protocol defined at https://code.claude.com/docs/en/hooks\n * for SessionStart, UserPromptSubmit, and PreToolUse hook events.\n */\n\n// ---------------------------------------------------------------------------\n// Hook Event Types\n// ---------------------------------------------------------------------------\n\nexport type HookEventName = \"SessionStart\" | \"UserPromptSubmit\" | \"PreToolUse\";\n\nexport interface SessionStartInput {\n hookEventName: \"SessionStart\";\n session_id?: string;\n type?: \"new\" | \"resume\" | \"clear\" | \"compact\";\n}\n\nexport interface UserPromptSubmitInput {\n hookEventName: \"UserPromptSubmit\";\n session_id?: string;\n prompt?: string;\n}\n\nexport interface PreToolUseInput {\n hookEventName: \"PreToolUse\";\n session_id?: string;\n tool_name?: string;\n tool_input?: {\n file_path?: string;\n path?: string;\n command?: string;\n content?: string;\n [key: string]: unknown;\n };\n}\n\nexport type HookInput = SessionStartInput | UserPromptSubmitInput | PreToolUseInput;\n\n// ---------------------------------------------------------------------------\n// Hook Response Types\n// ---------------------------------------------------------------------------\n\nexport type PermissionDecision = \"allow\" | \"deny\" | \"ask\";\n\nexport interface HookOutput {\n /** Hook-specific output envelope. */\n hookSpecificOutput?: {\n hookEventName: HookEventName;\n /** Additional context injected into the session. */\n additionalContext?: string;\n /** Permission decision for PreToolUse hooks. */\n permissionDecision?: PermissionDecision;\n /** Reason for the permission decision. */\n permissionDecisionReason?: string;\n };\n}\n\n// ---------------------------------------------------------------------------\n// Parse / Emit\n// ---------------------------------------------------------------------------\n\n/**\n * Parse hook input from a raw JSON string (typically from stdin).\n * Throws on invalid JSON but not on missing fields — callers handle defaults.\n */\nexport function parseHookInput(raw: string): HookInput {\n const parsed = JSON.parse(raw) as HookInput;\n return parsed;\n}\n\n/**\n * Read all of stdin and parse as hook input JSON.\n */\nexport async function readHookInput(): Promise<HookInput> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk as string));\n }\n const raw = Buffer.concat(chunks).toString(\"utf-8\").trim();\n if (!raw) {\n throw new Error(\"Empty stdin — no hook input received\");\n }\n return parseHookInput(raw);\n}\n\n/**\n * Emit a hook response as JSON to stdout.\n */\nexport function emitHookOutput(output: HookOutput): void {\n process.stdout.write(JSON.stringify(output) + \"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Response Builders\n// ---------------------------------------------------------------------------\n\n/**\n * Build a response that injects additional context into the session.\n */\nexport function buildContextResponse(\n eventName: HookEventName,\n additionalContext: string,\n): HookOutput {\n return {\n hookSpecificOutput: {\n hookEventName: eventName,\n additionalContext,\n },\n };\n}\n\n/**\n * Build a deny response for PreToolUse hooks.\n */\nexport function buildDenyResponse(reason: string): HookOutput {\n return {\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: reason,\n },\n };\n}\n\n/**\n * Build an allow response (empty output = allow by default).\n */\nexport function buildAllowResponse(): HookOutput {\n return {};\n}\n","/**\n * Cache Store — read/write `.claude/cache/` directory.\n *\n * Stores navigation-index.json and metadata for graph cache invalidation.\n * Uses atomic write (write-to-temp + rename) for concurrent-access safety.\n */\n\nimport { readFile, writeFile, rename, stat, mkdir } from \"node:fs/promises\";\nimport { join, dirname } from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface CacheEntry<T = unknown> {\n data: T;\n /** ISO timestamp of when the cache was written. */\n writtenAt: string;\n /** Hash of source inputs used for invalidation. */\n sourceHash: string;\n}\n\nexport interface CacheStoreOptions {\n /** Absolute path to the `.claude/cache/` directory. */\n cacheDir: string;\n}\n\n// ---------------------------------------------------------------------------\n// Cache Store\n// ---------------------------------------------------------------------------\n\nexport interface CacheStore {\n read<T = unknown>(key: string): Promise<CacheEntry<T> | null>;\n write<T = unknown>(key: string, data: T, sourceHash: string): Promise<void>;\n /**\n * Check if a cache entry is fresh by comparing its sourceHash.\n * Returns the cached data if fresh, null if stale or missing.\n */\n readIfFresh<T = unknown>(key: string, currentHash: string): Promise<T | null>;\n /** Get the mtime of a file (for invalidation checks). */\n getFileMtime(filePath: string): Promise<number | null>;\n}\n\nexport function createCacheStore(options: CacheStoreOptions): CacheStore {\n const { cacheDir } = options;\n\n function cacheFilePath(key: string): string {\n return join(cacheDir, `${key}.json`);\n }\n\n async function ensureDir(): Promise<void> {\n await mkdir(cacheDir, { recursive: true });\n }\n\n const store: CacheStore = {\n async read<T = unknown>(key: string): Promise<CacheEntry<T> | null> {\n try {\n const raw = await readFile(cacheFilePath(key), \"utf-8\");\n return JSON.parse(raw) as CacheEntry<T>;\n } catch {\n return null;\n }\n },\n\n async write<T = unknown>(key: string, data: T, sourceHash: string): Promise<void> {\n await ensureDir();\n const entry: CacheEntry<T> = {\n data,\n writtenAt: new Date().toISOString(),\n sourceHash,\n };\n const content = JSON.stringify(entry, null, 2);\n const target = cacheFilePath(key);\n const tmpPath = `${target}.${randomBytes(4).toString(\"hex\")}.tmp`;\n\n // Atomic write: write to temp file then rename\n await writeFile(tmpPath, content, \"utf-8\");\n try {\n await rename(tmpPath, target);\n } catch {\n // Fallback: direct write if rename fails (cross-device)\n await writeFile(target, content, \"utf-8\");\n }\n },\n\n async readIfFresh<T = unknown>(key: string, currentHash: string): Promise<T | null> {\n const entry = await store.read<T>(key);\n if (!entry) return null;\n if (entry.sourceHash !== currentHash) return null;\n return entry.data;\n },\n\n async getFileMtime(filePath: string): Promise<number | null> {\n try {\n const s = await stat(filePath);\n return s.mtimeMs;\n } catch {\n return null;\n }\n },\n };\n\n return store;\n}\n\n/**\n * Compute a simple hash string from an array of file mtimes and content strings.\n * Not cryptographic — used only for cache invalidation.\n */\nexport function computeSourceHash(inputs: Array<string | number>): string {\n return inputs.map(String).join(\":\");\n}\n","/**\n * Latency utilities — timeout wrapper, graph build exclusion, degrade policy.\n *\n * Mirrors the Promise-sharing pattern from analyzer-bridge.ts for concurrent\n * graph build exclusion.\n */\n\n// ---------------------------------------------------------------------------\n// Timeout wrapper\n// ---------------------------------------------------------------------------\n\nexport class TimeoutError extends Error {\n constructor(ms: number) {\n super(`Operation timed out after ${ms}ms`);\n this.name = \"TimeoutError\";\n }\n}\n\n/**\n * Race a promise against a timeout. Resolves with the promise result or\n * rejects with TimeoutError.\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n): Promise<T> {\n if (timeoutMs <= 0) return promise;\n\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new TimeoutError(timeoutMs)), timeoutMs);\n });\n\n try {\n return await Promise.race([promise, timeout]);\n } finally {\n clearTimeout(timer!);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Exclusive lock (Promise sharing)\n// ---------------------------------------------------------------------------\n\n/**\n * Creates an exclusive async lock that ensures only one invocation runs at a\n * time. Subsequent callers await the same Promise (analyzer-bridge pattern).\n */\nexport function createExclusiveLock<T>(): {\n run: (fn: () => Promise<T>) => Promise<T>;\n} {\n let pending: Promise<T> | null = null;\n\n return {\n async run(fn: () => Promise<T>): Promise<T> {\n if (pending) return pending;\n pending = fn().finally(() => {\n pending = null;\n });\n return pending;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Degrade policy\n// ---------------------------------------------------------------------------\n\nexport interface DegradeResult<T> {\n value: T;\n degraded: boolean;\n reason?: string;\n}\n\n/**\n * Attempt an operation with timeout; if it fails or times out, return the\n * fallback value with `degraded: true`.\n */\nexport async function withDegrade<T>(\n operation: () => Promise<T>,\n fallback: T,\n timeoutMs: number,\n): Promise<DegradeResult<T>> {\n try {\n const value = await withTimeout(operation(), timeoutMs);\n return { value, degraded: false };\n } catch (err) {\n const reason =\n err instanceof TimeoutError\n ? err.message\n : err instanceof Error\n ? err.message\n : String(err);\n return { value: fallback, degraded: true, reason };\n }\n}\n","/**\n * Artifact Resolver — reverse-lookup path to artifact_id using navigation-index.\n *\n * Uses glob matching from guardrail-hooks.ts to match file paths against\n * artifact path_patterns defined in the navigation index.\n */\n\nimport { matchGlob } from \"../guardrail-hooks.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Minimal shape of a navigation-index artifact node. */\nexport interface NavigationArtifact {\n properties?: {\n type?: string;\n authority?: string;\n manual_edit?: string;\n [key: string]: unknown;\n };\n files?: {\n path_patterns?: string[];\n [key: string]: unknown;\n };\n agents?: {\n owners?: string[];\n editors?: string[];\n [key: string]: unknown;\n };\n routes?: {\n regenerate?: string;\n [key: string]: unknown;\n };\n relations?: {\n derived_artifacts?: string[];\n [key: string]: unknown;\n };\n}\n\nexport interface ArtifactMatch {\n artifactId: string;\n artifact: NavigationArtifact;\n /** The glob pattern that matched. */\n matchedPattern: string;\n}\n\n// ---------------------------------------------------------------------------\n// Resolver\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a file path to its artifact(s) in the navigation index.\n * Returns all matching artifacts (a file may belong to multiple artifacts).\n */\nexport function resolvePathToArtifacts(\n filePath: string,\n navigationIndex: Record<string, unknown>,\n): ArtifactMatch[] {\n const artifacts =\n (navigationIndex.artifacts as Record<string, NavigationArtifact>) ?? {};\n const matches: ArtifactMatch[] = [];\n\n for (const [id, artifact] of Object.entries(artifacts)) {\n const patterns = artifact?.files?.path_patterns;\n if (!Array.isArray(patterns)) continue;\n\n for (const pattern of patterns) {\n if (typeof pattern !== \"string\") continue;\n if (matchGlob(pattern, filePath)) {\n matches.push({ artifactId: id, artifact, matchedPattern: pattern });\n break; // One match per artifact is sufficient\n }\n }\n }\n\n return matches;\n}\n\n/**\n * Check if a file path targets a protected artifact (generated or manual_edit: forbidden).\n */\nexport function isProtectedArtifact(match: ArtifactMatch): {\n protected: boolean;\n reason: string;\n} {\n const props = match.artifact.properties ?? {};\n\n if (props.authority === \"generated\") {\n const regen = match.artifact.routes?.regenerate;\n const hint = regen\n ? ` Run '${regen}' to regenerate.`\n : \" Edit the source artifact and regenerate instead.\";\n return {\n protected: true,\n reason:\n `File belongs to generated artifact '${match.artifactId}'.` +\n ` Direct editing is not allowed.${hint}`,\n };\n }\n\n if (props.manual_edit === \"forbidden\") {\n return {\n protected: true,\n reason:\n `File belongs to artifact '${match.artifactId}' which has manual_edit: forbidden.` +\n ` This artifact must not be edited directly.`,\n };\n }\n\n return { protected: false, reason: \"\" };\n}\n\n/**\n * Get all artifact entries from a navigation index as a flat list.\n */\nexport function listArtifacts(\n navigationIndex: Record<string, unknown>,\n): Array<{ id: string; artifact: NavigationArtifact }> {\n const artifacts =\n (navigationIndex.artifacts as Record<string, NavigationArtifact>) ?? {};\n return Object.entries(artifacts).map(([id, artifact]) => ({\n id,\n artifact,\n }));\n}\n","/**\n * Ensure Navigation Index — cache warm / invalidation.\n *\n * Checks cache freshness via source file mtime comparison. If stale,\n * calls buildNavigationContext() and writes to .claude/cache/.\n * If fresh, returns cached data immediately.\n *\n * This is the performance-critical path for SessionStart hooks.\n */\n\nimport { stat } from \"node:fs/promises\";\nimport { buildNavigationContext, type NavigationContextOptions } from \"../navigation-context.js\";\nimport {\n createCacheStore,\n computeSourceHash,\n type CacheStore,\n} from \"./cache-store.js\";\nimport { createExclusiveLock } from \"./latency.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface EnsureNavigationIndexOptions {\n /** Absolute path to .claude/cache/ directory. */\n cacheDir: string;\n /** Paths to source files whose mtime drives cache invalidation. */\n sourceFiles: string[];\n /** Options for buildNavigationContext() when cache is stale. */\n navigationOptions: NavigationContextOptions;\n}\n\nexport interface NavigationIndexResult {\n navigationIndex: Record<string, unknown>;\n /** Whether the result was loaded from cache (true) or freshly built (false). */\n fromCache: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nconst CACHE_KEY = \"navigation-index\";\n\n/** Shared lock to prevent concurrent navigation-index builds. */\nconst buildLock = createExclusiveLock<NavigationIndexResult>();\n\n/**\n * Collect mtimes for source files and produce a cache hash.\n */\nasync function computeCurrentHash(sourceFiles: string[]): Promise<string> {\n const mtimes: Array<string | number> = [];\n for (const file of sourceFiles) {\n try {\n const s = await stat(file);\n mtimes.push(s.mtimeMs);\n } catch {\n // File not found — include a sentinel so hash changes if file appears\n mtimes.push(`missing:${file}`);\n }\n }\n return computeSourceHash(mtimes);\n}\n\n/**\n * Ensure the navigation index is available and fresh. Returns the index\n * data, building + caching if necessary.\n */\nexport async function ensureNavigationIndex(\n options: EnsureNavigationIndexOptions,\n): Promise<NavigationIndexResult> {\n return buildLock.run(async () => {\n const store: CacheStore = createCacheStore({ cacheDir: options.cacheDir });\n const currentHash = await computeCurrentHash(options.sourceFiles);\n\n // Try cache first\n const cached = await store.readIfFresh<Record<string, unknown>>(\n CACHE_KEY,\n currentHash,\n );\n if (cached) {\n return { navigationIndex: cached, fromCache: true };\n }\n\n // Cache miss or stale — rebuild\n const context = await buildNavigationContext(options.navigationOptions);\n const navigationIndex = context.navigationIndex;\n\n // Write to cache (non-blocking error handling)\n try {\n await store.write(CACHE_KEY, navigationIndex, currentHash);\n } catch {\n // Cache write failure is non-fatal\n }\n\n return { navigationIndex, fromCache: false };\n });\n}\n","/**\n * File Suggestion Handler — artifact-aware @ completion for Claude Code.\n *\n * Reads stdin prefix, filters navigation-index artifacts, and emits NDJSON\n * candidates sorted by relevance score.\n */\n\nimport { listArtifacts, type NavigationArtifact } from \"./artifact-resolver.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface FileSuggestionCandidate {\n label: string;\n path: string;\n kind: \"artifact\" | \"file\";\n /** Artifact ID this file/pattern belongs to. */\n artifact?: string;\n /** Authority of the artifact (canonical, generated, etc.). */\n authority?: string;\n /** Manual edit policy for the artifact. */\n manual_edit?: string;\n /** Relevance score (higher = more relevant). */\n score: number;\n}\n\nexport interface FileSuggestionOptions {\n /** The navigation index to search. */\n navigationIndex: Record<string, unknown>;\n /** Maximum number of candidates to return. */\n maxCandidates?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_MAX_CANDIDATES = 100;\n\n/**\n * Generate file suggestion candidates from the navigation index.\n * Filters by prefix if provided, then returns NDJSON-formatted candidates.\n */\nexport function generateCandidates(\n prefix: string,\n options: FileSuggestionOptions,\n): FileSuggestionCandidate[] {\n const { navigationIndex, maxCandidates = DEFAULT_MAX_CANDIDATES } = options;\n const artifacts = listArtifacts(navigationIndex);\n const candidates: FileSuggestionCandidate[] = [];\n const lowerPrefix = prefix.toLowerCase();\n\n for (const { id, artifact } of artifacts) {\n const props = artifact.properties ?? {};\n const patterns = artifact.files?.path_patterns ?? [];\n\n // Artifact-level candidate\n if (!prefix || id.toLowerCase().includes(lowerPrefix)) {\n candidates.push({\n label: id,\n path: patterns.length > 0 ? String(patterns[0]) : id,\n kind: \"artifact\",\n authority: props.authority as string | undefined,\n manual_edit: props.manual_edit as string | undefined,\n score: computeArtifactScore(id, artifact, prefix),\n });\n }\n\n // File-level candidates from path patterns\n for (const pattern of patterns) {\n if (typeof pattern !== \"string\") continue;\n // Skip pure glob patterns for file-level suggestions (they're covered by artifact-level)\n if (pattern.includes(\"*\") || pattern.includes(\"?\")) continue;\n\n if (!prefix || pattern.toLowerCase().includes(lowerPrefix)) {\n candidates.push({\n label: pattern,\n path: pattern,\n kind: \"file\",\n artifact: id,\n authority: props.authority as string | undefined,\n manual_edit: props.manual_edit as string | undefined,\n score: computeFileScore(pattern, prefix),\n });\n }\n }\n }\n\n // Sort by score descending, then by label\n candidates.sort((a, b) => {\n if (b.score !== a.score) return b.score - a.score;\n return a.label.localeCompare(b.label);\n });\n\n return candidates.slice(0, maxCandidates);\n}\n\n/**\n * Format candidates as NDJSON (one JSON object per line).\n */\nexport function formatNdjson(candidates: FileSuggestionCandidate[]): string {\n return candidates.map((c) => JSON.stringify(c)).join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Scoring helpers\n// ---------------------------------------------------------------------------\n\nfunction computeArtifactScore(\n id: string,\n artifact: NavigationArtifact,\n prefix: string,\n): number {\n let score = 50;\n const props = artifact.properties ?? {};\n\n // Boost canonical, editable artifacts\n if (props.authority === \"canonical\") score += 20;\n if (props.manual_edit === \"allowed\") score += 10;\n\n // Boost source artifacts\n if (props.type === \"source\") score += 15;\n\n // Penalize generated artifacts\n if (props.authority === \"generated\") score -= 20;\n if (props.manual_edit === \"forbidden\") score -= 10;\n\n // Boost exact prefix match\n if (prefix && id.toLowerCase().startsWith(prefix.toLowerCase())) {\n score += 20;\n }\n\n return score;\n}\n\nfunction computeFileScore(path: string, prefix: string): number {\n let score = 40;\n\n // Boost exact prefix match\n if (prefix && path.toLowerCase().startsWith(prefix.toLowerCase())) {\n score += 30;\n }\n\n // Boost shorter paths (more specific)\n score += Math.max(0, 20 - path.split(\"/\").length * 2);\n\n return score;\n}\n\n/**\n * Main handler for file-suggestion bin script.\n * Reads prefix from stdin, returns NDJSON candidates to stdout.\n */\nexport async function handleFileSuggestion(\n navigationIndex: Record<string, unknown>,\n stdinData: string,\n): Promise<string> {\n const prefix = stdinData.trim();\n const candidates = generateCandidates(prefix, { navigationIndex });\n return formatNdjson(candidates);\n}\n","/**\n * SessionStart Hook Handler — cache warm + navigation-index summary injection.\n *\n * Executed on session new/resume/clear/compact events. Warms the navigation-index\n * cache and returns a rendered summary as additionalContext.\n *\n * Latency constraint: NO AST analysis or ContextPack generation.\n */\n\nimport { renderNavigationIndexPrompt } from \"../task-runner.js\";\nimport {\n ensureNavigationIndex,\n type EnsureNavigationIndexOptions,\n} from \"./ensure-navigation-index.js\";\nimport {\n buildContextResponse,\n type HookOutput,\n type SessionStartInput,\n} from \"./hook-protocol.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface SessionStartHandlerConfig {\n /** Absolute path to .claude/cache/ directory. */\n cacheDir: string;\n /** Source files for cache invalidation (component.yaml, agent-contracts.yaml, etc.). */\n sourceFiles: string[];\n /** Options for buildNavigationContext(). */\n navigationOptions: EnsureNavigationIndexOptions[\"navigationOptions\"];\n}\n\n// ---------------------------------------------------------------------------\n// Handler\n// ---------------------------------------------------------------------------\n\n/**\n * Create a SessionStart hook handler.\n */\nexport function createSessionStartHandler(config: SessionStartHandlerConfig) {\n return async function handleSessionStart(\n _input: SessionStartInput,\n ): Promise<HookOutput> {\n const result = await ensureNavigationIndex({\n cacheDir: config.cacheDir,\n sourceFiles: config.sourceFiles,\n navigationOptions: config.navigationOptions,\n });\n\n const summary = renderNavigationIndexPrompt(result.navigationIndex);\n const cacheNote = result.fromCache\n ? \"(loaded from cache)\"\n : \"(freshly built)\";\n\n const additionalContext = [\n summary,\n \"\",\n `Navigation index ${cacheNote}. Use analyzer MCP tools for deep investigation.`,\n ].join(\"\\n\");\n\n return buildContextResponse(\"SessionStart\", additionalContext);\n };\n}\n","/**\n * UserPromptSubmit Hook Handler — navigation-index summary injection.\n *\n * Executed after prompt submission, before Claude processes it. Provides a\n * compact navigation-index summary so the LLM can pick candidates and delegate\n * deep exploration to `analyzer.getContextMap` (Level 2).\n *\n * ContextPack is NOT pre-injected by default (#206 Phase D).\n */\n\nimport { renderNavigationIndexPrompt } from \"../task-runner.js\";\nimport {\n ensureNavigationIndex,\n type EnsureNavigationIndexOptions,\n} from \"./ensure-navigation-index.js\";\nimport {\n listArtifacts,\n} from \"./artifact-resolver.js\";\nimport {\n buildContextResponse,\n type HookOutput,\n type UserPromptSubmitInput,\n} from \"./hook-protocol.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface UserPromptSubmitHandlerConfig {\n /** Absolute path to the project root. */\n projectRoot: string;\n /** Absolute path to .claude/cache/ directory. */\n cacheDir: string;\n /** Source files for cache invalidation. */\n sourceFiles: string[];\n /** Options for buildNavigationContext(). */\n navigationOptions: EnsureNavigationIndexOptions[\"navigationOptions\"];\n}\n\n// ---------------------------------------------------------------------------\n// Handler\n// ---------------------------------------------------------------------------\n\n/**\n * Create a UserPromptSubmit hook handler.\n */\nexport function createUserPromptSubmitHandler(\n config: UserPromptSubmitHandlerConfig,\n) {\n return async function handleUserPromptSubmit(\n input: UserPromptSubmitInput,\n ): Promise<HookOutput> {\n const prompt = input.prompt ?? \"\";\n\n const navResult = await ensureNavigationIndex({\n cacheDir: config.cacheDir,\n sourceFiles: config.sourceFiles,\n navigationOptions: config.navigationOptions,\n });\n const navigationIndex = navResult.navigationIndex;\n const navigationSummary = renderNavigationIndexPrompt(navigationIndex);\n\n const sections: string[] = [\n \"## Project Navigation Index\",\n navigationSummary,\n \"\",\n \"> Use `analyzer.getContextMap` with candidate paths/artifacts from the index\",\n \"> when you need structured dependency and read-target guidance.\",\n ];\n\n const candidates = extractCandidateArtifacts(prompt, navigationIndex);\n if (candidates.length > 0) {\n const candidateLines = candidates.map((c) => {\n const props = c.artifact.properties ?? {};\n const tags = [props.type, props.authority, props.manual_edit ? `edit:${props.manual_edit}` : \"\"]\n .filter(Boolean)\n .join(\", \");\n return `- ${c.artifactId} [${tags}]`;\n });\n sections.push(\n \"## Candidate Artifacts (from prompt keywords)\\n\" + candidateLines.join(\"\\n\"),\n );\n }\n\n const additionalContext = sections.join(\"\\n\");\n return buildContextResponse(\"UserPromptSubmit\", additionalContext);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ninterface CandidateArtifact {\n artifactId: string;\n artifact: ReturnType<typeof listArtifacts>[number][\"artifact\"];\n}\n\nfunction extractCandidateArtifacts(\n prompt: string,\n navigationIndex: Record<string, unknown>,\n): CandidateArtifact[] {\n if (!prompt.trim()) return [];\n\n const artifacts = listArtifacts(navigationIndex);\n const lowerPrompt = prompt.toLowerCase();\n const matches: CandidateArtifact[] = [];\n const seen = new Set<string>();\n\n for (const { id, artifact } of artifacts) {\n if (lowerPrompt.includes(id.toLowerCase()) && !seen.has(id)) {\n seen.add(id);\n matches.push({ artifactId: id, artifact });\n continue;\n }\n\n const patterns = artifact.files?.path_patterns ?? [];\n for (const pattern of patterns) {\n if (typeof pattern !== \"string\") continue;\n const literal = pattern.replace(/[*?]/g, \"\").replace(/\\{.*\\}/g, \"\");\n if (literal.length > 3 && lowerPrompt.includes(literal.toLowerCase()) && !seen.has(id)) {\n seen.add(id);\n matches.push({ artifactId: id, artifact });\n break;\n }\n }\n }\n\n return matches;\n}\n","/**\n * PreToolUse Hook Handler — artifact guardrail + DSL guardrail enforcement.\n *\n * Executed before tool use (Edit, Write, Bash, etc.). Checks:\n * 1. Edit/Write tools: file path → artifact reverse lookup → deny if protected\n * 2. Bash tool: apply DSL guardrail rules via GuardrailHooks\n */\n\nimport {\n createGuardrailHooksFromRules,\n getBlockingViolations,\n type GuardrailRuleData,\n} from \"../guardrail-hooks.js\";\nimport {\n resolvePathToArtifacts,\n isProtectedArtifact,\n} from \"./artifact-resolver.js\";\nimport {\n buildDenyResponse,\n buildAllowResponse,\n type HookOutput,\n type PreToolUseInput,\n} from \"./hook-protocol.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface PreToolUseHandlerConfig {\n /** Navigation index for artifact resolution. */\n navigationIndex: Record<string, unknown>;\n /** DSL guardrail rules for Bash command evaluation. */\n guardrailRules?: GuardrailRuleData;\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/** Tool names that perform file edits. */\nconst EDIT_TOOLS = new Set([\"Edit\", \"Write\", \"MultiEdit\", \"edit\", \"write\"]);\n\n/** Tool names that execute shell commands. */\nconst BASH_TOOLS = new Set([\"Bash\", \"bash\", \"Terminal\", \"terminal\"]);\n\n// ---------------------------------------------------------------------------\n// Handler\n// ---------------------------------------------------------------------------\n\n/**\n * Create a PreToolUse hook handler.\n */\nexport function createPreToolUseHandler(config: PreToolUseHandlerConfig) {\n // Pre-compile guardrail hooks if rules provided\n const guardrailHooks = config.guardrailRules\n ? createGuardrailHooksFromRules(config.guardrailRules)\n : null;\n\n return async function handlePreToolUse(\n input: PreToolUseInput,\n ): Promise<HookOutput> {\n const toolName = input.tool_name ?? \"\";\n const toolInput = input.tool_input ?? {};\n\n // --- Edit/Write tool: artifact protection ---\n if (EDIT_TOOLS.has(toolName)) {\n const filePath = toolInput.file_path ?? toolInput.path ?? \"\";\n if (filePath) {\n const matches = resolvePathToArtifacts(\n filePath,\n config.navigationIndex,\n );\n\n for (const match of matches) {\n const check = isProtectedArtifact(match);\n if (check.protected) {\n return buildDenyResponse(check.reason);\n }\n }\n }\n }\n\n // --- Bash tool: DSL guardrail enforcement ---\n if (BASH_TOOLS.has(toolName) && guardrailHooks) {\n const command = toolInput.command ?? \"\";\n if (command) {\n const hookResult = guardrailHooks.beforeShellExecution({ command });\n if (hookResult.permission === \"deny\") {\n return buildDenyResponse(\n hookResult.user_message ?? \"Command blocked by guardrail\",\n );\n }\n }\n }\n\n // --- Default: allow ---\n return buildAllowResponse();\n };\n}\n"],"mappings":";;;;;;;;;;;;AAmEO,SAAS,eAAe,KAAwB;AACrD,QAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,SAAO;AACT;AAKA,eAAsB,gBAAoC;AACxD,QAAM,SAAmB,CAAC;AAC1B,mBAAiB,SAAS,QAAQ,OAAO;AACvC,WAAO,KAAK,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK,KAAe,CAAC;AAAA,EAC3E;AACA,QAAM,MAAM,OAAO,OAAO,MAAM,EAAE,SAAS,OAAO,EAAE,KAAK;AACzD,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,2CAAsC;AAAA,EACxD;AACA,SAAO,eAAe,GAAG;AAC3B;AAKO,SAAS,eAAe,QAA0B;AACvD,UAAQ,OAAO,MAAM,KAAK,UAAU,MAAM,IAAI,IAAI;AACpD;AASO,SAAS,qBACd,WACA,mBACY;AACZ,SAAO;AAAA,IACL,oBAAoB;AAAA,MAClB,eAAe;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAKO,SAAS,kBAAkB,QAA4B;AAC5D,SAAO;AA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Y,IAAI,SAAS,CAAC;AACzC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;;;ACzFA,IAAM,aAAa,oBAAI,IAAI,CAAC,QAAQ,SAAS,aAAa,QAAQ,OAAO,CAAC;AAG1E,IAAM,aAAa,oBAAI,IAAI,CAAC,QAAQ,QAAQ,YAAY,UAAU,CAAC;AAS5D,SAAS,wBAAwB,QAAiC;AAEvE,QAAM,iBAAiB,OAAO,iBAC1B,8BAA8B,OAAO,cAAc,IACnD;AAEJ,SAAO,eAAe,iBACpB,OACqB;AACrB,UAAM,WAAW,MAAM,aAAa;AACpC,UAAM,YAAY,MAAM,cAAc,CAAC;AAGvC,QAAI,WAAW,IAAI,QAAQ,GAAG;AAC5B,YAAM,WAAW,UAAU,aAAa,UAAU,QAAQ;AAC1D,UAAI,UAAU;AACZ,cAAM,UAAU;AAAA,UACd;AAAA,UACA,OAAO;AAAA,QACT;AAEA,mBAAW,SAAS,SAAS;AAC3B,gBAAM,QAAQ,oBAAoB,KAAK;AACvC,cAAI,MAAM,WAAW;AACnB,mBAAO,kBAAkB,MAAM,MAAM;AAAA,UACvC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAGA,QAAI,WAAW,IAAI,QAAQ,KAAK,gBAAgB;AAC9C,YAAM,UAAU,UAAU,WAAW;AACrC,UAAI,SAAS;AACX,cAAM,aAAa,eAAe,qBAAqB,EAAE,QAAQ,CAAC;AAClE,YAAI,WAAW,eAAe,QAAQ;AACpC,iBAAO;AAAA,YACL,WAAW,gBAAgB;AAAA,UAC7B;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAGA,WAAO,mBAAmB;AAAA,EAC5B;AACF;","names":["stat","stat"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/claude-native/ensure-navigation-index.ts","../../../src/lib/claude-native/file-suggestion.ts","../../../src/lib/claude-native/session-start.ts","../../../src/lib/claude-native/user-prompt-submit.ts","../../../src/lib/claude-native/workspace-session-start.ts"],"sourcesContent":["/**\n * Ensure Navigation Index — cache warm / invalidation.\n *\n * Checks cache freshness via source file mtime comparison. If stale,\n * calls buildNavigationContext() and writes to .claude/cache/.\n * If fresh, returns cached data immediately.\n *\n * This is the performance-critical path for SessionStart hooks.\n */\n\nimport { stat } from \"node:fs/promises\";\nimport { buildNavigationContext, type NavigationContextOptions } from \"../navigation-context.js\";\nimport {\n createCacheStore,\n computeSourceHash,\n type CacheStore,\n} from \"./cache-store.js\";\nimport { createExclusiveLock } from \"./latency.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface EnsureNavigationIndexOptions {\n /** Absolute path to .claude/cache/ directory. */\n cacheDir: string;\n /** Paths to source files whose mtime drives cache invalidation. */\n sourceFiles: string[];\n /** Options for buildNavigationContext() when cache is stale. */\n navigationOptions: NavigationContextOptions;\n /**\n * Cache key for the stored JSON file (default: `\"navigation-index\"`).\n *\n * In workspace mode each member uses its own key, e.g.\n * `\"navigation-index.aaac\"`, so their caches remain isolated.\n * Single-component callers omit this field and the default preserves\n * byte-identical behaviour with previous versions.\n */\n cacheKey?: string;\n}\n\nexport interface NavigationIndexResult {\n navigationIndex: Record<string, unknown>;\n /** Whether the result was loaded from cache (true) or freshly built (false). */\n fromCache: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_CACHE_KEY = \"navigation-index\";\n\n/**\n * Per-key exclusive locks so concurrent session-start calls for distinct\n * workspace members can build their indices in parallel, while duplicate calls\n * for the same key are deduplicated (share the in-flight promise).\n */\nconst buildLocks = new Map<string, ReturnType<typeof createExclusiveLock<NavigationIndexResult>>>();\n\nfunction getBuildLock(key: string): ReturnType<typeof createExclusiveLock<NavigationIndexResult>> {\n let lock = buildLocks.get(key);\n if (!lock) {\n lock = createExclusiveLock<NavigationIndexResult>();\n buildLocks.set(key, lock);\n }\n return lock;\n}\n\n/**\n * Collect mtimes for source files and produce a cache hash.\n */\nasync function computeCurrentHash(sourceFiles: string[]): Promise<string> {\n const mtimes: Array<string | number> = [];\n for (const file of sourceFiles) {\n try {\n const s = await stat(file);\n mtimes.push(s.mtimeMs);\n } catch {\n // File not found — include a sentinel so hash changes if file appears\n mtimes.push(`missing:${file}`);\n }\n }\n return computeSourceHash(mtimes);\n}\n\n/**\n * Ensure the navigation index is available and fresh. Returns the index\n * data, building + caching if necessary.\n *\n * In workspace mode, pass a unique `cacheKey` per member (e.g.\n * `\"navigation-index.aaac\"`) so each member's index is stored and\n * invalidated independently.\n */\nexport async function ensureNavigationIndex(\n options: EnsureNavigationIndexOptions,\n): Promise<NavigationIndexResult> {\n const cacheKey = options.cacheKey ?? DEFAULT_CACHE_KEY;\n\n return getBuildLock(cacheKey).run(async () => {\n const store: CacheStore = createCacheStore({ cacheDir: options.cacheDir });\n const currentHash = await computeCurrentHash(options.sourceFiles);\n\n // Try cache first\n const cached = await store.readIfFresh<Record<string, unknown>>(\n cacheKey,\n currentHash,\n );\n if (cached) {\n return { navigationIndex: cached, fromCache: true };\n }\n\n // Cache miss or stale — rebuild\n const context = await buildNavigationContext(options.navigationOptions);\n const navigationIndex = context.navigationIndex;\n\n // Write to cache (non-blocking error handling)\n try {\n await store.write(cacheKey, navigationIndex, currentHash);\n } catch {\n // Cache write failure is non-fatal\n }\n\n return { navigationIndex, fromCache: false };\n });\n}\n","/**\n * File Suggestion Handler — artifact-aware @ completion for Claude Code.\n *\n * Reads stdin prefix, filters navigation-index artifacts, and emits NDJSON\n * candidates sorted by relevance score.\n */\n\nimport { listArtifacts, type NavigationArtifact } from \"./artifact-resolver.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface FileSuggestionCandidate {\n label: string;\n path: string;\n kind: \"artifact\" | \"file\";\n /** Artifact ID this file/pattern belongs to. */\n artifact?: string;\n /** Authority of the artifact (canonical, generated, etc.). */\n authority?: string;\n /** Manual edit policy for the artifact. */\n manual_edit?: string;\n /** Relevance score (higher = more relevant). */\n score: number;\n}\n\nexport interface FileSuggestionOptions {\n /** The navigation index to search. */\n navigationIndex: Record<string, unknown>;\n /** Maximum number of candidates to return. */\n maxCandidates?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_MAX_CANDIDATES = 100;\n\n/**\n * Generate file suggestion candidates from the navigation index.\n * Filters by prefix if provided, then returns NDJSON-formatted candidates.\n */\nexport function generateCandidates(\n prefix: string,\n options: FileSuggestionOptions,\n): FileSuggestionCandidate[] {\n const { navigationIndex, maxCandidates = DEFAULT_MAX_CANDIDATES } = options;\n const artifacts = listArtifacts(navigationIndex);\n const candidates: FileSuggestionCandidate[] = [];\n const lowerPrefix = prefix.toLowerCase();\n\n for (const { id, artifact } of artifacts) {\n const props = artifact.properties ?? {};\n const patterns = artifact.files?.path_patterns ?? [];\n\n // Artifact-level candidate\n if (!prefix || id.toLowerCase().includes(lowerPrefix)) {\n candidates.push({\n label: id,\n path: patterns.length > 0 ? String(patterns[0]) : id,\n kind: \"artifact\",\n authority: props.authority as string | undefined,\n manual_edit: props.manual_edit as string | undefined,\n score: computeArtifactScore(id, artifact, prefix),\n });\n }\n\n // File-level candidates from path patterns\n for (const pattern of patterns) {\n if (typeof pattern !== \"string\") continue;\n // Skip pure glob patterns for file-level suggestions (they're covered by artifact-level)\n if (pattern.includes(\"*\") || pattern.includes(\"?\")) continue;\n\n if (!prefix || pattern.toLowerCase().includes(lowerPrefix)) {\n candidates.push({\n label: pattern,\n path: pattern,\n kind: \"file\",\n artifact: id,\n authority: props.authority as string | undefined,\n manual_edit: props.manual_edit as string | undefined,\n score: computeFileScore(pattern, prefix),\n });\n }\n }\n }\n\n // Sort by score descending, then by label\n candidates.sort((a, b) => {\n if (b.score !== a.score) return b.score - a.score;\n return a.label.localeCompare(b.label);\n });\n\n return candidates.slice(0, maxCandidates);\n}\n\n/**\n * Format candidates as NDJSON (one JSON object per line).\n */\nexport function formatNdjson(candidates: FileSuggestionCandidate[]): string {\n return candidates.map((c) => JSON.stringify(c)).join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Scoring helpers\n// ---------------------------------------------------------------------------\n\nfunction computeArtifactScore(\n id: string,\n artifact: NavigationArtifact,\n prefix: string,\n): number {\n let score = 50;\n const props = artifact.properties ?? {};\n\n // Boost canonical, editable artifacts\n if (props.authority === \"canonical\") score += 20;\n if (props.manual_edit === \"allowed\") score += 10;\n\n // Boost source artifacts\n if (props.type === \"source\") score += 15;\n\n // Penalize generated artifacts\n if (props.authority === \"generated\") score -= 20;\n if (props.manual_edit === \"forbidden\") score -= 10;\n\n // Boost exact prefix match\n if (prefix && id.toLowerCase().startsWith(prefix.toLowerCase())) {\n score += 20;\n }\n\n return score;\n}\n\nfunction computeFileScore(path: string, prefix: string): number {\n let score = 40;\n\n // Boost exact prefix match\n if (prefix && path.toLowerCase().startsWith(prefix.toLowerCase())) {\n score += 30;\n }\n\n // Boost shorter paths (more specific)\n score += Math.max(0, 20 - path.split(\"/\").length * 2);\n\n return score;\n}\n\n/**\n * Main handler for file-suggestion bin script.\n * Reads prefix from stdin, returns NDJSON candidates to stdout.\n */\nexport async function handleFileSuggestion(\n navigationIndex: Record<string, unknown>,\n stdinData: string,\n): Promise<string> {\n const prefix = stdinData.trim();\n const candidates = generateCandidates(prefix, { navigationIndex });\n return formatNdjson(candidates);\n}\n","/**\n * SessionStart Hook Handler — cache warm + navigation-index summary injection.\n *\n * Executed on session new/resume/clear/compact events. Warms the navigation-index\n * cache and returns a rendered summary as additionalContext.\n *\n * Latency constraint: NO AST analysis or ContextPack generation.\n */\n\nimport { renderNavigationIndexPrompt } from \"../task-runner.js\";\nimport {\n ensureNavigationIndex,\n type EnsureNavigationIndexOptions,\n} from \"./ensure-navigation-index.js\";\nimport {\n buildContextResponse,\n type HookOutput,\n type SessionStartInput,\n} from \"./hook-protocol.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface SessionStartHandlerConfig {\n /** Absolute path to .claude/cache/ directory. */\n cacheDir: string;\n /** Source files for cache invalidation (component.yaml, agent-contracts.yaml, etc.). */\n sourceFiles: string[];\n /** Options for buildNavigationContext(). */\n navigationOptions: EnsureNavigationIndexOptions[\"navigationOptions\"];\n}\n\n// ---------------------------------------------------------------------------\n// Handler\n// ---------------------------------------------------------------------------\n\n/**\n * Create a SessionStart hook handler.\n */\nexport function createSessionStartHandler(config: SessionStartHandlerConfig) {\n return async function handleSessionStart(\n _input: SessionStartInput,\n ): Promise<HookOutput> {\n const result = await ensureNavigationIndex({\n cacheDir: config.cacheDir,\n sourceFiles: config.sourceFiles,\n navigationOptions: config.navigationOptions,\n });\n\n const summary = renderNavigationIndexPrompt(result.navigationIndex);\n const cacheNote = result.fromCache\n ? \"(loaded from cache)\"\n : \"(freshly built)\";\n\n const additionalContext = [\n summary,\n \"\",\n `Navigation index ${cacheNote}. Use analyzer MCP tools for deep investigation.`,\n ].join(\"\\n\");\n\n return buildContextResponse(\"SessionStart\", additionalContext);\n };\n}\n","/**\n * UserPromptSubmit Hook Handler — navigation-index summary injection.\n *\n * Executed after prompt submission, before Claude processes it. Provides a\n * compact navigation-index summary so the LLM can pick candidates and delegate\n * deep exploration to `analyzer.getContextMap` (Level 2).\n *\n * ContextPack is NOT pre-injected by default (#206 Phase D).\n */\n\nimport { renderNavigationIndexPrompt } from \"../task-runner.js\";\nimport {\n ensureNavigationIndex,\n type EnsureNavigationIndexOptions,\n} from \"./ensure-navigation-index.js\";\nimport {\n listArtifacts,\n} from \"./artifact-resolver.js\";\nimport {\n buildContextResponse,\n type HookOutput,\n type UserPromptSubmitInput,\n} from \"./hook-protocol.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface UserPromptSubmitHandlerConfig {\n /** Absolute path to the project root. */\n projectRoot: string;\n /** Absolute path to .claude/cache/ directory. */\n cacheDir: string;\n /** Source files for cache invalidation. */\n sourceFiles: string[];\n /** Options for buildNavigationContext(). */\n navigationOptions: EnsureNavigationIndexOptions[\"navigationOptions\"];\n}\n\n// ---------------------------------------------------------------------------\n// Handler\n// ---------------------------------------------------------------------------\n\n/**\n * Create a UserPromptSubmit hook handler.\n */\nexport function createUserPromptSubmitHandler(\n config: UserPromptSubmitHandlerConfig,\n) {\n return async function handleUserPromptSubmit(\n input: UserPromptSubmitInput,\n ): Promise<HookOutput> {\n const prompt = input.prompt ?? \"\";\n\n const navResult = await ensureNavigationIndex({\n cacheDir: config.cacheDir,\n sourceFiles: config.sourceFiles,\n navigationOptions: config.navigationOptions,\n });\n const navigationIndex = navResult.navigationIndex;\n const navigationSummary = renderNavigationIndexPrompt(navigationIndex);\n\n const sections: string[] = [\n \"## Project Navigation Index\",\n navigationSummary,\n \"\",\n \"> Use `analyzer.getContextMap` with candidate paths/artifacts from the index\",\n \"> when you need structured dependency and read-target guidance.\",\n ];\n\n const candidates = extractCandidateArtifacts(prompt, navigationIndex);\n if (candidates.length > 0) {\n const candidateLines = candidates.map((c) => {\n const props = c.artifact.properties ?? {};\n const tags = [props.type, props.authority, props.manual_edit ? `edit:${props.manual_edit}` : \"\"]\n .filter(Boolean)\n .join(\", \");\n return `- ${c.artifactId} [${tags}]`;\n });\n sections.push(\n \"## Candidate Artifacts (from prompt keywords)\\n\" + candidateLines.join(\"\\n\"),\n );\n }\n\n const additionalContext = sections.join(\"\\n\");\n return buildContextResponse(\"UserPromptSubmit\", additionalContext);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ninterface CandidateArtifact {\n artifactId: string;\n artifact: ReturnType<typeof listArtifacts>[number][\"artifact\"];\n}\n\nfunction extractCandidateArtifacts(\n prompt: string,\n navigationIndex: Record<string, unknown>,\n): CandidateArtifact[] {\n if (!prompt.trim()) return [];\n\n const artifacts = listArtifacts(navigationIndex);\n const lowerPrompt = prompt.toLowerCase();\n const matches: CandidateArtifact[] = [];\n const seen = new Set<string>();\n\n for (const { id, artifact } of artifacts) {\n if (lowerPrompt.includes(id.toLowerCase()) && !seen.has(id)) {\n seen.add(id);\n matches.push({ artifactId: id, artifact });\n continue;\n }\n\n const patterns = artifact.files?.path_patterns ?? [];\n for (const pattern of patterns) {\n if (typeof pattern !== \"string\") continue;\n const literal = pattern.replace(/[*?]/g, \"\").replace(/\\{.*\\}/g, \"\");\n if (literal.length > 3 && lowerPrompt.includes(literal.toLowerCase()) && !seen.has(id)) {\n seen.add(id);\n matches.push({ artifactId: id, artifact });\n break;\n }\n }\n }\n\n return matches;\n}\n","/**\n * Workspace SessionStart Hook Handler — per-member navigation-index warm-up.\n *\n * Builds (or validates) a cached navigation-index for each declared workspace\n * member in parallel, then returns a combined summary as `additionalContext`.\n *\n * This module is in the **heavy** path (imports ensureNavigationIndex →\n * navigation-context → agent-contracts) and is therefore NOT included in the\n * lean hooks-lite entry point. SessionStart fires only once per session, so\n * the higher import cost is acceptable.\n */\n\nimport { renderNavigationIndexPrompt } from \"../task-runner.js\";\nimport {\n ensureNavigationIndex,\n type EnsureNavigationIndexOptions,\n} from \"./ensure-navigation-index.js\";\nimport {\n buildContextResponse,\n type HookOutput,\n type SessionStartInput,\n} from \"./hook-protocol.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface WorkspaceMemberSessionConfig {\n /** Human-readable member name (e.g. `\"aaac\"`). */\n name: string;\n /** Absolute path to member root directory. */\n root: string;\n /**\n * Unique cache key for this member's navigation-index JSON.\n * Format: `navigation-index.<name>`.\n */\n cacheKey: string;\n /** Source files for mtime-based cache invalidation. */\n sourceFiles: string[];\n /** Options passed to `buildNavigationContext()` on cache miss. */\n navigationOptions: EnsureNavigationIndexOptions[\"navigationOptions\"];\n}\n\nexport interface WorkspaceSessionStartConfig {\n /** Absolute path to the shared `.claude/cache/` directory. */\n cacheDir: string;\n /** Workspace members to build/validate indices for. */\n members: WorkspaceMemberSessionConfig[];\n}\n\n// ---------------------------------------------------------------------------\n// Handler\n// ---------------------------------------------------------------------------\n\n/**\n * Create a workspace-aware SessionStart hook handler.\n *\n * All member navigation-indices are built in **parallel** (each key has its\n * own exclusive lock so concurrent calls for the same member deduplicate\n * rather than queue behind other members).\n */\nexport function createWorkspaceSessionStartHandler(\n config: WorkspaceSessionStartConfig,\n) {\n return async function handleWorkspaceSessionStart(\n _input: SessionStartInput,\n ): Promise<HookOutput> {\n // Build all member indices concurrently\n const results = await Promise.all(\n config.members.map(async (member) => {\n const result = await ensureNavigationIndex({\n cacheDir: config.cacheDir,\n sourceFiles: member.sourceFiles,\n navigationOptions: member.navigationOptions,\n cacheKey: member.cacheKey,\n });\n return { member, result };\n }),\n );\n\n // Aggregate summaries\n const sections: string[] = [];\n for (const { member, result } of results) {\n const summary = renderNavigationIndexPrompt(result.navigationIndex);\n const cacheNote = result.fromCache ? \"(loaded from cache)\" : \"(freshly built)\";\n sections.push(\n `### Member: ${member.name} ${cacheNote}\\n${summary}`,\n );\n }\n\n const additionalContext = [\n sections.join(\"\\n\\n\"),\n \"\",\n \"Workspace navigation indices ready. Use analyzer MCP tools for deep investigation.\",\n ].join(\"\\n\");\n\n return buildContextResponse(\"SessionStart\", additionalContext);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAS,YAAY;AAyCrB,IAAM,oBAAoB;AAO1B,IAAM,aAAa,oBAAI,IAA2E;AAElG,SAAS,aAAa,KAA4E;AAChG,MAAI,OAAO,WAAW,IAAI,GAAG;AAC7B,MAAI,CAAC,MAAM;AACT,WAAO,oBAA2C;AAClD,eAAW,IAAI,KAAK,IAAI;AAAA,EAC1B;AACA,SAAO;AACT;AAKA,eAAe,mBAAmB,aAAwC;AACxE,QAAM,SAAiC,CAAC;AACxC,aAAW,QAAQ,aAAa;AAC9B,QAAI;AACF,YAAM,IAAI,MAAM,KAAK,IAAI;AACzB,aAAO,KAAK,EAAE,OAAO;AAAA,IACvB,QAAQ;AAEN,aAAO,KAAK,WAAW,IAAI,EA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AAAA,MAC5B,OAAO,QAAQ,IAAI,OAAO,WAAW;AACnC,cAAM,SAAS,MAAM,sBAAsB;AAAA,UACzC,UAAU,OAAO;AAAA,UACjB,aAAa,OAAO;AAAA,UACpB,mBAAmB,OAAO;AAAA,UAC1B,UAAU,OAAO;AAAA,QACnB,CAAC;AACD,eAAO,EAAE,QAAQ,OAAO;AAAA,MAC1B,CAAC;AAAA,IACH;AAGA,UAAM,WAAqB,CAAC;AAC5B,eAAW,EAAE,QAAQ,OAAO,KAAK,SAAS;AACxC,YAAM,UAAU,4BAA4B,OAAO,eAAe;AAClE,YAAM,YAAY,OAAO,YAAY,wBAAwB;AAC7D,eAAS;AAAA,QACP,eAAe,OAAO,IAAI,IAAI,SAAS;AAAA,EAAK,OAAO;AAAA,MACrD;AAAA,IACF;AAEA,UAAM,oBAAoB;AAAA,MACxB,SAAS,KAAK,MAAM;AAAA,MACpB;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAEX,WAAO,qBAAqB,gBAAgB,iBAAiB;AAAA,EAC/D;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aaac/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"description": "Runtime SDK for the AaaC toolchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"./claude-native": {
|
|
34
34
|
"types": "./dist/lib/claude-native/index.d.ts",
|
|
35
35
|
"import": "./dist/lib/claude-native/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./claude-native/hooks-lite": {
|
|
38
|
+
"types": "./dist/lib/claude-native/hooks-lite.d.ts",
|
|
39
|
+
"import": "./dist/lib/claude-native/hooks-lite.js"
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
42
|
"files": [
|
|
@@ -41,7 +45,7 @@
|
|
|
41
45
|
"LICENSE"
|
|
42
46
|
],
|
|
43
47
|
"scripts": {
|
|
44
|
-
"build": "tsup",
|
|
48
|
+
"build": "tsup && node scripts/build-claude-bundles.mjs",
|
|
45
49
|
"clean": "rm -rf dist",
|
|
46
50
|
"test": "vitest run",
|
|
47
51
|
"prepublishOnly": "npm run clean && npm run build"
|
|
@@ -90,6 +94,7 @@
|
|
|
90
94
|
}
|
|
91
95
|
},
|
|
92
96
|
"devDependencies": {
|
|
93
|
-
"artifact-contracts-analyzer": "file:../../../artifact-contracts-analyzer"
|
|
97
|
+
"artifact-contracts-analyzer": "file:../../../artifact-contracts-analyzer",
|
|
98
|
+
"esbuild": "^0.28.0"
|
|
94
99
|
}
|
|
95
100
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generator/context.ts","../src/generator/config.ts"],"sourcesContent":["/**\n * Build the guardrail context from resolved DSL + binding data.\n *\n * (The DSL→TypeScript codegen context builder, `buildContractContext`, was\n * removed alongside the runtime `generate()` codegen path.)\n */\n\nexport interface GuardrailCheckEntry {\n guardrail_id: string;\n description: string;\n severity: string;\n action: string;\n matcher_type: string;\n pattern: string;\n message: string;\n file_glob?: string;\n exclude_glob?: string;\n}\n\nexport interface GuardrailContext {\n commandChecks: GuardrailCheckEntry[];\n fileChecks: GuardrailCheckEntry[];\n contentChecks: GuardrailCheckEntry[];\n allChecks: GuardrailCheckEntry[];\n hasGuardrails: boolean;\n}\n\n/**\n * Build guardrail context from DSL guardrails, binding guardrail_impl, and active policy.\n * Mirrors the agent-contracts resolveChecks pattern.\n */\nexport function buildGuardrailContext(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n dsl: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n binding: any,\n policyName?: string,\n): GuardrailContext {\n const empty: GuardrailContext = {\n commandChecks: [],\n fileChecks: [],\n contentChecks: [],\n allChecks: [],\n hasGuardrails: false,\n };\n\n if (!binding?.guardrail_impl) return empty;\n\n const guardrails = dsl.guardrails ?? {};\n const policies = dsl.guardrail_policies ?? {};\n const policy = policyName ? policies[policyName] : undefined;\n\n const allChecks: GuardrailCheckEntry[] = [];\n\n for (const [guardrailId, impl] of Object.entries(\n binding.guardrail_impl as Record<string, { checks: Array<Record<string, unknown>> }>,\n )) {\n const guardrail = guardrails[guardrailId] as Record<string, unknown> | undefined;\n const description = (guardrail?.description as string) ?? guardrailId;\n\n const policyRule = policy?.rules?.find(\n (r: Record<string, unknown>) => r.guardrail === guardrailId,\n );\n const severity = (policyRule?.severity as string) ?? \"warning\";\n const action = (policyRule?.action as string) ?? \"warn\";\n\n for (const check of impl.checks) {\n const matcher = check.matcher as Record<string, unknown> | undefined;\n if (!matcher) continue;\n\n allChecks.push({\n guardrail_id: guardrailId,\n description,\n severity,\n action,\n matcher_type: matcher.type as string,\n pattern: matcher.pattern as string,\n message: (check.message as string) ?? description,\n file_glob: matcher.file_glob as string | undefined,\n exclude_glob: matcher.exclude_glob as string | undefined,\n });\n }\n }\n\n return {\n commandChecks: allChecks.filter((c) => c.matcher_type === \"command_regex\"),\n fileChecks: allChecks.filter((c) => c.matcher_type === \"file_glob\"),\n contentChecks: allChecks.filter((c) => c.matcher_type === \"content_regex\"),\n allChecks,\n hasGuardrails: allChecks.length > 0,\n };\n}\n","/**\n * Generator configuration — loads and validates agents.conf.yaml\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport YAML from \"yaml\";\n\nexport const DEFAULT_CONFIG_PATH = \"./agents.conf.yaml\";\n\nconst RecoverySchema = z.object({\n max_follow_ups: z.number().int().min(0).default(2),\n max_retries: z.number().int().min(0).default(0),\n}).default(() => ({ max_follow_ups: 2, max_retries: 0 }));\n\nconst ModelClassEntrySchema = z.object({\n adapter: z.string(),\n model: z.string().optional(),\n});\n\nconst ModelMappingSchema = z.object({\n fast: ModelClassEntrySchema.optional(),\n standard: ModelClassEntrySchema.optional(),\n thinking: ModelClassEntrySchema.optional(),\n}).default({});\n\nconst ProgressLogSchema = z.object({\n destination: z.enum([\"stderr\", \"file\", \"both\", \"none\"]).default(\"stderr\"),\n file: z.string().optional(),\n naming: z.enum([\"single\", \"per-invocation\", \"daily\"]).default(\"single\"),\n}).default(() => ({ destination: \"stderr\" as const, naming: \"single\" as const }))\n .refine(\n (val) => {\n if ((val.destination === \"file\" || val.destination === \"both\") && !val.file) return false;\n return true;\n },\n { message: \"logging.progress_log.file is required when destination is 'file' or 'both'\" },\n );\n\nconst LoggingSchema = z.object({\n progress_log: ProgressLogSchema,\n}).default(() => ({ progress_log: { destination: \"stderr\" as const, naming: \"single\" as const } }));\n\nexport const RuntimeConfigSchema = z.object({\n dsl: z.string().default(\"./agent-contracts.yaml\"),\n generated_dir: z.string().default(\"./agent/generated\"),\n bindings: z.array(z.string()).default([]),\n active_guardrail_policy: z.string().optional(),\n templates_dir: z.string().optional(),\n plugins: z.array(z.string()).default([]),\n recovery: RecoverySchema,\n model_mapping: ModelMappingSchema,\n logging: LoggingSchema,\n});\n\nexport type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;\n\n/**\n * Unified project bindings object.\n * - guardrail: guardrail_impl matcher files → machine enforcement (BoundResolver)\n * - hooks: git hook bindings → governance materialize (#68; declarative for now)\n * - observability: event-mapping file + external recorder CLI\n */\nconst BindingsSchema = z.object({\n guardrail: z.array(z.string()).optional(),\n hooks: z.array(z.string()).optional(),\n observability: z.object({\n event_mapping: z.string().optional(),\n recorder: z.string().optional(),\n /** Toggle in-process agent-axis recording. Defaults to ON when this binding exists. */\n enabled: z.boolean().optional(),\n /** Override the SQLite DB path for in-process recording (default: DEFAULT_DB_PATH). */\n db_path: z.string().optional(),\n /**\n * OTel Collector endpoint for emitting spans to an OTLP-compatible backend.\n * When set, @aaac/observability's OtelEmitter is configured with this endpoint.\n * Falls back to process.env.OTEL_EXPORTER_OTLP_ENDPOINT when absent.\n * Omitting this field keeps the OtelEmitter in no-op mode (fail-open).\n */\n otel: z.object({\n endpoint: z.string(),\n }).optional(),\n }).optional(),\n}).optional();\n\nconst CliSectionSchema = z.object({\n agents: z.string().optional(),\n dsl: z.string().optional(),\n generated_dir: z.string().optional(),\n plugins: z.array(z.string()).optional(),\n bindings: BindingsSchema,\n}).strict();\n\nexport const ComponentOverrideSchema = z.object({\n agents: z.string().optional(),\n dsl: z.string().optional(),\n component_contract: z.string().optional(),\n generated_dir: z.string().optional(),\n bindings: BindingsSchema,\n plugins: z.array(z.string()).optional(),\n model_mapping: ModelMappingSchema.optional(),\n recovery: RecoverySchema.optional(),\n templates_dir: z.string().optional(),\n}).strict();\n\nexport type ComponentOverride = z.infer<typeof ComponentOverrideSchema>;\n\nconst EnvironmentsSchema = z.object({\n git: z.object({\n hooks: z.array(z.string()).optional(),\n }).optional(),\n cursor: z.object({\n hooks_json: z.string().optional(),\n }).optional(),\n ci: z.object({\n provider: z.string().optional(),\n }).optional(),\n}).optional();\n\nexport const ProjectConfigSchema = z.object({\n schema: z.string().optional(),\n agents: z.string().optional(),\n dsl: z.string().optional(),\n generated_dir: z.string().optional(),\n bindings: BindingsSchema,\n active_guardrail_policy: z.string().optional(),\n templates_dir: z.string().optional(),\n plugins: z.array(z.string()).optional(),\n recovery: RecoverySchema,\n model_mapping: ModelMappingSchema,\n logging: LoggingSchema,\n artifacts: z.string().optional(),\n toolchains: z.string().optional(),\n components: z.record(z.string(), ComponentOverrideSchema).optional(),\n environments: EnvironmentsSchema,\n cli: z.record(z.string(), CliSectionSchema).optional(),\n});\n\nexport type ProjectConfig = z.infer<typeof ProjectConfigSchema>;\n\nexport interface ResolvedProgressLog {\n destination: \"stderr\" | \"file\" | \"both\" | \"none\";\n file: string | undefined;\n naming: \"single\" | \"per-invocation\" | \"daily\";\n}\n\nexport interface ResolvedEnvironments {\n git?: { hooks: string[] };\n cursor?: { hooks_json: string };\n ci?: { provider: string };\n}\n\nexport interface ResolvedObservability {\n eventMappingPath?: string;\n recorder?: string;\n /** Whether in-process agent-axis recording is enabled (default true when binding present). */\n enabled?: boolean;\n /** Resolved override for the SQLite DB path (undefined → DEFAULT_DB_PATH). */\n dbPath?: string;\n /**\n * OTel Collector endpoint configuration.\n * When present, OtelEmitter is configured with this endpoint at pipeline creation.\n * Falls back to OTEL_EXPORTER_OTLP_ENDPOINT env var when absent.\n */\n otel?: { endpoint: string };\n}\n\nexport interface ResolvedConfig extends RuntimeConfig {\n configDir: string;\n dslPath: string;\n generatedDir: string;\n /** Resolved guardrail_impl matcher files (machine enforcement). */\n bindingPaths: string[];\n /** Resolved git-hook binding files (governance materialize, #68). */\n hookBindingPaths: string[];\n /** Observability event mapping + recorder, if configured. */\n observability?: ResolvedObservability;\n templatesDir: string | undefined;\n pluginPaths: string[];\n resolvedLogging: { progressLog: ResolvedProgressLog };\n artifactsPath?: string;\n toolchainsPath?: string;\n environments?: ResolvedEnvironments;\n componentOverrides?: Record<string, ComponentOverride>;\n}\n\ninterface GovernanceFields {\n artifacts?: string;\n toolchains?: string;\n environments?: z.infer<typeof EnvironmentsSchema>;\n componentOverrides?: Record<string, ComponentOverride>;\n hookBindings?: string[];\n observability?: {\n event_mapping?: string;\n recorder?: string;\n enabled?: boolean;\n db_path?: string;\n otel?: { endpoint: string };\n };\n}\n\n/** Internal runtime base assembled from a project manifest before RuntimeConfigSchema validation. */\ninterface RuntimeConfigInput {\n dsl?: string;\n generated_dir?: string;\n bindings: string[];\n active_guardrail_policy?: string;\n templates_dir?: string;\n plugins?: string[];\n recovery: z.infer<typeof RecoverySchema>;\n model_mapping: z.infer<typeof ModelMappingSchema>;\n logging: z.infer<typeof LoggingSchema>;\n}\n\ntype ConfigOverride = ComponentOverride | z.infer<typeof CliSectionSchema>;\n\nfunction resolveConfigFilePath(configPath: string): string {\n return resolve(configPath);\n}\n\nfunction mergeBindingsUnion(root: string[] | undefined, override: string[] | undefined): string[] {\n const base = root ?? [];\n const extra = override ?? [];\n const seen = new Set(base);\n const result = [...base];\n for (const binding of extra) {\n if (!seen.has(binding)) {\n result.push(binding);\n seen.add(binding);\n }\n }\n return result;\n}\n\nfunction mergeConfigWithOverride(\n base: RuntimeConfigInput,\n override: ConfigOverride,\n): RuntimeConfigInput {\n const merged: RuntimeConfigInput = { ...base };\n\n const overrideDsl = override.agents ?? override.dsl;\n if (overrideDsl !== undefined) merged.dsl = overrideDsl;\n if (override.generated_dir !== undefined) merged.generated_dir = override.generated_dir;\n if (override.bindings?.guardrail !== undefined) {\n merged.bindings = mergeBindingsUnion(base.bindings, override.bindings.guardrail);\n }\n if (override.plugins !== undefined) merged.plugins = override.plugins;\n\n if (\"templates_dir\" in override && override.templates_dir !== undefined) {\n merged.templates_dir = override.templates_dir;\n }\n\n if (\"model_mapping\" in override && override.model_mapping) {\n merged.model_mapping = {\n ...base.model_mapping,\n ...(override.model_mapping.fast ? { fast: override.model_mapping.fast } : {}),\n ...(override.model_mapping.standard ? { standard: override.model_mapping.standard } : {}),\n ...(override.model_mapping.thinking ? { thinking: override.model_mapping.thinking } : {}),\n };\n }\n\n if (\"recovery\" in override && override.recovery) {\n merged.recovery = {\n ...base.recovery,\n ...override.recovery,\n };\n }\n\n return merged;\n}\n\nfunction resolveEnvironments(\n environments: z.infer<typeof EnvironmentsSchema>,\n configDir: string,\n): ResolvedEnvironments | undefined {\n if (!environments) return undefined;\n\n const resolved: ResolvedEnvironments = {};\n\n if (environments.git?.hooks) {\n resolved.git = { hooks: environments.git.hooks };\n }\n\n if (environments.cursor?.hooks_json) {\n resolved.cursor = {\n hooks_json: resolve(configDir, environments.cursor.hooks_json),\n };\n }\n\n if (environments.ci?.provider) {\n resolved.ci = { provider: environments.ci.provider };\n }\n\n return Object.keys(resolved).length > 0 ? resolved : undefined;\n}\n\nfunction buildResolvedConfig(\n config: RuntimeConfig,\n configDir: string,\n governance?: GovernanceFields,\n): ResolvedConfig {\n const pl = config.logging.progress_log;\n\n return {\n ...config,\n configDir,\n dslPath: resolve(configDir, config.dsl),\n generatedDir: resolve(configDir, config.generated_dir),\n bindingPaths: config.bindings.map((b) => resolve(configDir, b)),\n hookBindingPaths: (governance?.hookBindings ?? []).map((b) => resolve(configDir, b)),\n observability: governance?.observability\n ? {\n eventMappingPath: governance.observability.event_mapping\n ? resolve(configDir, governance.observability.event_mapping)\n : undefined,\n recorder: governance.observability.recorder,\n enabled: governance.observability.enabled,\n dbPath: governance.observability.db_path\n ? resolve(configDir, governance.observability.db_path)\n : undefined,\n otel: governance.observability.otel,\n }\n : undefined,\n templatesDir: config.templates_dir\n ? resolve(configDir, config.templates_dir)\n : undefined,\n pluginPaths: config.plugins,\n resolvedLogging: {\n progressLog: {\n destination: pl.destination,\n file: pl.file ? resolve(configDir, pl.file) : undefined,\n naming: pl.naming,\n },\n },\n artifactsPath: governance?.artifacts\n ? resolve(configDir, governance.artifacts)\n : undefined,\n toolchainsPath: governance?.toolchains\n ? resolve(configDir, governance.toolchains)\n : undefined,\n environments: resolveEnvironments(governance?.environments, configDir),\n componentOverrides: governance?.componentOverrides,\n };\n}\n\n/** Assemble the internal runtime base from a parsed project manifest (agents wins over dsl alias). */\nfunction projectToRuntimeBase(projectConfig: ProjectConfig): RuntimeConfigInput {\n return {\n dsl: projectConfig.agents ?? projectConfig.dsl,\n generated_dir: projectConfig.generated_dir,\n bindings: projectConfig.bindings?.guardrail ?? [],\n active_guardrail_policy: projectConfig.active_guardrail_policy,\n templates_dir: projectConfig.templates_dir,\n plugins: projectConfig.plugins,\n recovery: projectConfig.recovery,\n model_mapping: projectConfig.model_mapping,\n logging: projectConfig.logging,\n };\n}\n\nfunction resolveOverride(\n projectConfig: ProjectConfig,\n target?: string,\n): ConfigOverride | undefined {\n if (!target) return undefined;\n\n if (projectConfig.components?.[target]) {\n return projectConfig.components[target];\n }\n\n if (projectConfig.cli?.[target]) {\n return projectConfig.cli[target];\n }\n\n return undefined;\n}\n\nexport async function loadProjectConfig(\n configPath: string,\n target?: string,\n): Promise<ResolvedConfig> {\n const absPath = resolveConfigFilePath(configPath);\n const raw = await readFile(absPath, \"utf8\");\n const parsed = YAML.parse(raw);\n const projectConfig = ProjectConfigSchema.parse(parsed);\n\n let base = projectToRuntimeBase(projectConfig);\n const override = resolveOverride(projectConfig, target);\n\n if (override) {\n base = mergeConfigWithOverride(base, override);\n }\n\n const config = RuntimeConfigSchema.parse(base);\n const configDir = dirname(absPath);\n\n return buildResolvedConfig(config, configDir, {\n artifacts: projectConfig.artifacts,\n toolchains: projectConfig.toolchains,\n environments: projectConfig.environments,\n componentOverrides: projectConfig.components,\n hookBindings: projectConfig.bindings?.hooks,\n observability: projectConfig.bindings?.observability,\n });\n}\n"],"mappings":";AA+BO,SAAS,sBAEd,KAEA,SACA,YACkB;AAClB,QAAM,QAA0B;AAAA,IAC9B,eAAe,CAAC;AAAA,IAChB,YAAY,CAAC;AAAA,IACb,eAAe,CAAC;AAAA,IAChB,WAAW,CAAC;AAAA,IACZ,eAAe;AAAA,EACjB;AAEA,MAAI,CAAC,SAAS,eAAgB,QAAO;AAErC,QAAM,aAAa,IAAI,cAAc,CAAC;AACtC,QAAM,WAAW,IAAI,sBAAsB,CAAC;AAC5C,QAAM,SAAS,aAAa,SAAS,UAAU,IAAI;AAEnD,QAAM,YAAmC,CAAC;AAE1C,aAAW,CAAC,aAAa,IAAI,KAAK,OAAO;AAAA,IACvC,QAAQ;AAAA,EACV,GAAG;AACD,UAAM,YAAY,WAAW,WAAW;AACxC,UAAM,cAAe,WAAW,eAA0B;AAE1D,UAAM,aAAa,QAAQ,OAAO;AAAA,MAChC,CAAC,MAA+B,EAAE,cAAc;AAAA,IAClD;AACA,UAAM,WAAY,YAAY,YAAuB;AACrD,UAAM,SAAU,YAAY,UAAqB;AAEjD,eAAW,SAAS,KAAK,QAAQ;AAC/B,YAAM,UAAU,MAAM;AACtB,UAAI,CAAC,QAAS;AAEd,gBAAU,KAAK;AAAA,QACb,cAAc;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,QAAQ;AAAA,QACtB,SAAS,QAAQ;AAAA,QACjB,SAAU,MAAM,W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