@neurcode-ai/cli 0.19.8 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-client.d.ts +4 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js.map +1 -1
- package/dist/commands/activate.d.ts +6 -0
- package/dist/commands/activate.d.ts.map +1 -1
- package/dist/commands/activate.js +24 -0
- package/dist/commands/activate.js.map +1 -1
- package/dist/commands/brain.d.ts.map +1 -1
- package/dist/commands/brain.js +114 -17
- package/dist/commands/brain.js.map +1 -1
- package/dist/commands/runtime-doctor.d.ts.map +1 -1
- package/dist/commands/runtime-doctor.js +41 -2
- package/dist/commands/runtime-doctor.js.map +1 -1
- package/dist/commands/runtime-identity.d.ts.map +1 -1
- package/dist/commands/runtime-identity.js +46 -1
- package/dist/commands/runtime-identity.js.map +1 -1
- package/dist/commands/runtime-sync.d.ts.map +1 -1
- package/dist/commands/runtime-sync.js +55 -0
- package/dist/commands/runtime-sync.js.map +1 -1
- package/dist/commands/session-hook.d.ts +16 -1
- package/dist/commands/session-hook.d.ts.map +1 -1
- package/dist/commands/session-hook.js +165 -10
- package/dist/commands/session-hook.js.map +1 -1
- package/dist/commands/session.d.ts +4 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +39 -17
- package/dist/commands/session.js.map +1 -1
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-build.json +5 -5
- package/dist/utils/RelevanceScorer.d.ts.map +1 -1
- package/dist/utils/RelevanceScorer.js +16 -9
- package/dist/utils/RelevanceScorer.js.map +1 -1
- package/dist/utils/agent-session-launcher.d.ts.map +1 -1
- package/dist/utils/agent-session-launcher.js +142 -97
- package/dist/utils/agent-session-launcher.js.map +1 -1
- package/dist/utils/brain-lifecycle.d.ts +62 -0
- package/dist/utils/brain-lifecycle.d.ts.map +1 -0
- package/dist/utils/brain-lifecycle.js +482 -0
- package/dist/utils/brain-lifecycle.js.map +1 -0
- package/dist/utils/cli-startup.d.ts.map +1 -1
- package/dist/utils/cli-startup.js +20 -0
- package/dist/utils/cli-startup.js.map +1 -1
- package/dist/utils/command-budget.d.ts +10 -0
- package/dist/utils/command-budget.d.ts.map +1 -0
- package/dist/utils/command-budget.js +203 -0
- package/dist/utils/command-budget.js.map +1 -0
- package/dist/utils/mcp-server-pin.d.ts +1 -1
- package/dist/utils/mcp-server-pin.js +2 -2
- package/dist/utils/runtime-authority.d.ts +27 -0
- package/dist/utils/runtime-authority.d.ts.map +1 -0
- package/dist/utils/runtime-authority.js +162 -0
- package/dist/utils/runtime-authority.js.map +1 -0
- package/dist/utils/runtime-companion.d.ts +32 -0
- package/dist/utils/runtime-companion.d.ts.map +1 -1
- package/dist/utils/runtime-companion.js +57 -2
- package/dist/utils/runtime-companion.js.map +1 -1
- package/dist/utils/runtime-live.d.ts.map +1 -1
- package/dist/utils/runtime-live.js +14 -6
- package/dist/utils/runtime-live.js.map +1 -1
- package/dist/utils/runtime-outbox.d.ts.map +1 -1
- package/dist/utils/runtime-outbox.js +133 -1
- package/dist/utils/runtime-outbox.js.map +1 -1
- package/dist/utils/runtime-privacy.d.ts.map +1 -1
- package/dist/utils/runtime-privacy.js +52 -0
- package/dist/utils/runtime-privacy.js.map +1 -1
- package/dist/utils/runtime-state.d.ts +7 -35
- package/dist/utils/runtime-state.d.ts.map +1 -1
- package/dist/utils/runtime-state.js +203 -134
- package/dist/utils/runtime-state.js.map +1 -1
- package/dist/utils/session-start-transaction.d.ts +31 -0
- package/dist/utils/session-start-transaction.d.ts.map +1 -0
- package/dist/utils/session-start-transaction.js +207 -0
- package/dist/utils/session-start-transaction.js.map +1 -0
- package/dist/utils/v0-governance.d.ts +2 -1
- package/dist/utils/v0-governance.d.ts.map +1 -1
- package/dist/utils/v0-governance.js +271 -11
- package/dist/utils/v0-governance.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SESSION_START_TRANSACTION_SCHEMA_VERSION = void 0;
|
|
4
|
+
exports.beginSessionStartTransaction = beginSessionStartTransaction;
|
|
5
|
+
exports.updateSessionStartTransaction = updateSessionStartTransaction;
|
|
6
|
+
exports.clearSessionStartTransaction = clearSessionStartTransaction;
|
|
7
|
+
exports.inspectSessionStartTransaction = inspectSessionStartTransaction;
|
|
8
|
+
exports.recoverTimedOutSessionStart = recoverTimedOutSessionStart;
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
const brain_1 = require("@neurcode-ai/brain");
|
|
13
|
+
const governance_runtime_1 = require("@neurcode-ai/governance-runtime");
|
|
14
|
+
exports.SESSION_START_TRANSACTION_SCHEMA_VERSION = 'neurcode.session-start-transaction.v1';
|
|
15
|
+
function transactionPath(repoRoot) {
|
|
16
|
+
return (0, node_path_1.join)(repoRoot, '.neurcode', 'session-starting.json');
|
|
17
|
+
}
|
|
18
|
+
function syncParentDirectory(path) {
|
|
19
|
+
try {
|
|
20
|
+
const descriptor = (0, node_fs_1.openSync)((0, node_path_1.dirname)(path), 'r');
|
|
21
|
+
try {
|
|
22
|
+
(0, node_fs_1.fsyncSync)(descriptor);
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
(0, node_fs_1.closeSync)(descriptor);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Directory fsync is unavailable on some platforms.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function atomicWrite(path, value) {
|
|
33
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
34
|
+
const temporary = `${path}.tmp.${process.pid}.${(0, node_crypto_1.randomUUID)()}`;
|
|
35
|
+
let descriptor = null;
|
|
36
|
+
try {
|
|
37
|
+
descriptor = (0, node_fs_1.openSync)(temporary, 'w', 0o600);
|
|
38
|
+
(0, node_fs_1.writeFileSync)(descriptor, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
|
39
|
+
(0, node_fs_1.fsyncSync)(descriptor);
|
|
40
|
+
(0, node_fs_1.closeSync)(descriptor);
|
|
41
|
+
descriptor = null;
|
|
42
|
+
(0, node_fs_1.renameSync)(temporary, path);
|
|
43
|
+
syncParentDirectory(path);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (descriptor !== null) {
|
|
47
|
+
try {
|
|
48
|
+
(0, node_fs_1.closeSync)(descriptor);
|
|
49
|
+
}
|
|
50
|
+
catch { /* best effort */ }
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
(0, node_fs_1.rmSync)(temporary, { force: true });
|
|
54
|
+
}
|
|
55
|
+
catch { /* best effort */ }
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function atomicCreate(path, value) {
|
|
60
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
61
|
+
const temporary = `${path}.candidate.${process.pid}.${(0, node_crypto_1.randomUUID)()}`;
|
|
62
|
+
let descriptor = null;
|
|
63
|
+
try {
|
|
64
|
+
descriptor = (0, node_fs_1.openSync)(temporary, 'wx', 0o600);
|
|
65
|
+
(0, node_fs_1.writeFileSync)(descriptor, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
|
66
|
+
(0, node_fs_1.fsyncSync)(descriptor);
|
|
67
|
+
(0, node_fs_1.closeSync)(descriptor);
|
|
68
|
+
descriptor = null;
|
|
69
|
+
// Publishing a fully-written candidate with a hard link gives concurrent
|
|
70
|
+
// starters an atomic create-if-absent boundary without a partial JSON window.
|
|
71
|
+
(0, node_fs_1.linkSync)(temporary, path);
|
|
72
|
+
syncParentDirectory(path);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
if (descriptor !== null) {
|
|
76
|
+
try {
|
|
77
|
+
(0, node_fs_1.closeSync)(descriptor);
|
|
78
|
+
}
|
|
79
|
+
catch { /* best effort */ }
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
(0, node_fs_1.rmSync)(temporary, { force: true });
|
|
83
|
+
}
|
|
84
|
+
catch { /* best effort */ }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function readTransaction(repoRoot) {
|
|
88
|
+
const path = transactionPath(repoRoot);
|
|
89
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
90
|
+
return null;
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
|
|
93
|
+
if (parsed.schemaVersion !== exports.SESSION_START_TRANSACTION_SCHEMA_VERSION
|
|
94
|
+
|| !Number.isSafeInteger(parsed.pid)
|
|
95
|
+
|| typeof parsed.commandKey !== 'string'
|
|
96
|
+
|| typeof parsed.phase !== 'string') {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
...parsed,
|
|
101
|
+
jobId: typeof parsed.jobId === 'string' && parsed.jobId
|
|
102
|
+
? parsed.jobId
|
|
103
|
+
: `legacy-${parsed.pid}`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function beginSessionStartTransaction(repoRoot, commandKey) {
|
|
111
|
+
const path = transactionPath(repoRoot);
|
|
112
|
+
const existing = readTransaction(repoRoot);
|
|
113
|
+
if ((0, node_fs_1.existsSync)(path)) {
|
|
114
|
+
const ownerState = existing
|
|
115
|
+
? (0, brain_1.inspectOwnedProcess)(existing.pid, existing.processStartFingerprint)
|
|
116
|
+
: 'unknown';
|
|
117
|
+
if (!existing || ownerState === 'alive_same' || ownerState === 'unknown') {
|
|
118
|
+
throw new Error('session_start_already_running_or_unverifiable');
|
|
119
|
+
}
|
|
120
|
+
// Reclaim only a positively abandoned transaction, and only if its owner
|
|
121
|
+
// identity still matches the value we inspected.
|
|
122
|
+
const verified = readTransaction(repoRoot);
|
|
123
|
+
if (!verified
|
|
124
|
+
|| verified.jobId !== existing.jobId
|
|
125
|
+
|| verified.pid !== existing.pid
|
|
126
|
+
|| verified.processStartFingerprint !== existing.processStartFingerprint) {
|
|
127
|
+
throw new Error('session_start_transaction_changed_during_recovery');
|
|
128
|
+
}
|
|
129
|
+
if (verified.sessionId)
|
|
130
|
+
(0, governance_runtime_1.removeSession)(repoRoot, verified.sessionId);
|
|
131
|
+
(0, node_fs_1.rmSync)(path, { force: true });
|
|
132
|
+
}
|
|
133
|
+
const now = new Date().toISOString();
|
|
134
|
+
const transaction = {
|
|
135
|
+
schemaVersion: exports.SESSION_START_TRANSACTION_SCHEMA_VERSION,
|
|
136
|
+
commandKey,
|
|
137
|
+
jobId: (0, node_crypto_1.randomUUID)(),
|
|
138
|
+
pid: process.pid,
|
|
139
|
+
processStartFingerprint: (0, brain_1.processStartFingerprint)(process.pid),
|
|
140
|
+
startedAt: now,
|
|
141
|
+
updatedAt: now,
|
|
142
|
+
phase: 'initializing_runtime',
|
|
143
|
+
sessionId: null,
|
|
144
|
+
};
|
|
145
|
+
try {
|
|
146
|
+
atomicCreate(path, transaction);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const code = error && typeof error === 'object' && 'code' in error
|
|
150
|
+
? String(error.code)
|
|
151
|
+
: '';
|
|
152
|
+
if (code === 'EEXIST')
|
|
153
|
+
throw new Error('session_start_already_running');
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
return transaction;
|
|
157
|
+
}
|
|
158
|
+
function updateSessionStartTransaction(repoRoot, update) {
|
|
159
|
+
const current = readTransaction(repoRoot);
|
|
160
|
+
if (!current || current.pid !== process.pid)
|
|
161
|
+
return current;
|
|
162
|
+
const next = {
|
|
163
|
+
...current,
|
|
164
|
+
updatedAt: new Date().toISOString(),
|
|
165
|
+
phase: update.phase,
|
|
166
|
+
sessionId: update.sessionId === undefined ? current.sessionId : update.sessionId,
|
|
167
|
+
};
|
|
168
|
+
atomicWrite(transactionPath(repoRoot), next);
|
|
169
|
+
return next;
|
|
170
|
+
}
|
|
171
|
+
function clearSessionStartTransaction(repoRoot) {
|
|
172
|
+
const current = readTransaction(repoRoot);
|
|
173
|
+
if (!current
|
|
174
|
+
|| current.pid !== process.pid
|
|
175
|
+
|| current.processStartFingerprint !== (0, brain_1.processStartFingerprint)(process.pid))
|
|
176
|
+
return;
|
|
177
|
+
try {
|
|
178
|
+
(0, node_fs_1.rmSync)(transactionPath(repoRoot), { force: true });
|
|
179
|
+
}
|
|
180
|
+
catch { /* best effort */ }
|
|
181
|
+
}
|
|
182
|
+
function inspectSessionStartTransaction(repoRoot) {
|
|
183
|
+
const current = readTransaction(repoRoot);
|
|
184
|
+
return current ? {
|
|
185
|
+
phase: current.phase,
|
|
186
|
+
sessionId: current.sessionId,
|
|
187
|
+
ownerState: (0, brain_1.inspectOwnedProcess)(current.pid, current.processStartFingerprint),
|
|
188
|
+
} : null;
|
|
189
|
+
}
|
|
190
|
+
function recoverTimedOutSessionStart(repoRoot, childPid) {
|
|
191
|
+
const current = readTransaction(repoRoot);
|
|
192
|
+
if (!current || current.pid !== childPid)
|
|
193
|
+
return { recovered: false, phase: current?.phase ?? null };
|
|
194
|
+
const identity = (0, brain_1.inspectOwnedProcess)(current.pid, current.processStartFingerprint);
|
|
195
|
+
if (identity === 'alive_same' || identity === 'unknown') {
|
|
196
|
+
return { recovered: false, phase: current.phase };
|
|
197
|
+
}
|
|
198
|
+
if (current.sessionId) {
|
|
199
|
+
(0, governance_runtime_1.removeSession)(repoRoot, current.sessionId);
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
(0, node_fs_1.rmSync)(transactionPath(repoRoot), { force: true });
|
|
203
|
+
}
|
|
204
|
+
catch { /* best effort */ }
|
|
205
|
+
return { recovered: true, phase: current.phase };
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=session-start-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-start-transaction.js","sourceRoot":"","sources":["../../src/utils/session-start-transaction.ts"],"names":[],"mappings":";;;AAuHA,oEAiDC;AAED,sEAcC;AAED,oEAQC;AAED,wEAWC;AAED,kEAeC;AAhOD,6CAAyC;AACzC,qCAWiB;AACjB,yCAA0C;AAC1C,8CAAkF;AAClF,wEAAgE;AAEnD,QAAA,wCAAwC,GAAG,uCAAgD,CAAC;AAsBzG,SAAS,eAAe,CAAC,QAAgB;IACvC,OAAO,IAAA,gBAAI,EAAC,QAAQ,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAA,kBAAQ,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC;YAAC,IAAA,mBAAS,EAAC,UAAU,CAAC,CAAC;QAAC,CAAC;gBAAS,CAAC;YAAC,IAAA,mBAAS,EAAC,UAAU,CAAC,CAAC;QAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,oDAAoD;IACtD,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,KAA8B;IAC/D,IAAA,mBAAS,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,GAAG,IAAI,QAAQ,OAAO,CAAC,GAAG,IAAI,IAAA,wBAAU,GAAE,EAAE,CAAC;IAC/D,IAAI,UAAU,GAAkB,IAAI,CAAC;IACrC,IAAI,CAAC;QACH,UAAU,GAAG,IAAA,kBAAQ,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7C,IAAA,uBAAa,EAAC,UAAU,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AAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACnF,IAAI,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACxD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;IACpD,CAAC;IACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,IAAA,kCAAa,EAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC;QAAC,IAAA,gBAAM,EAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACvF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ModuleImportRecord, type RepoGovernanceProfile, type RuntimeGovernanceConfig } from '@neurcode-ai/governance-runtime';
|
|
1
|
+
import { type GeneratedProvenanceEvidence, type ModuleImportRecord, type RepositoryManifestEvidence, type RepoGovernanceProfile, type RuntimeGovernanceConfig } from '@neurcode-ai/governance-runtime';
|
|
2
2
|
export declare const CODEOWNERS_CANDIDATES: string[];
|
|
3
3
|
export declare const MANIFEST_CANDIDATES: string[];
|
|
4
4
|
declare const COPILOT_HOOK_EVENTS: readonly ["UserPromptSubmit", "PreToolUse", "Stop"];
|
|
@@ -159,6 +159,7 @@ export interface GovernanceConfigReadResult {
|
|
|
159
159
|
}
|
|
160
160
|
export declare function resolveRepoRoot(cwd?: string): string;
|
|
161
161
|
export declare function gitLsFiles(cwd: string): string[];
|
|
162
|
+
export declare function readGeneratedProvenanceEvidence(repoRoot: string, paths: string[], manifests: RepositoryManifestEvidence[]): GeneratedProvenanceEvidence[];
|
|
162
163
|
export declare function governanceConfigPath(repoRoot: string): string;
|
|
163
164
|
export declare function readRuntimeGovernanceConfig(repoRoot: string): GovernanceConfigReadResult;
|
|
164
165
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v0-governance.d.ts","sourceRoot":"","sources":["../../src/utils/v0-governance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v0-governance.d.ts","sourceRoot":"","sources":["../../src/utils/v0-governance.ts"],"names":[],"mappings":"AAiBA,OAAO,EAIL,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAE7B,MAAM,iCAAiC,CAAC;AAIzC,eAAO,MAAM,qBAAqB,UAA0D,CAAC;AAC7F,eAAO,MAAM,mBAAmB,UAmB/B,CAAC;AAQF,QAAA,MAAM,mBAAmB,qDAAsD,CAAC;AAChF,KAAK,gBAAgB,GAAG,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE3D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;CAgC1B,CAAC;AAOX,KAAK,eAAe,GAAG,MAAM,OAAO,uBAAuB,CAAC;AAmH5D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,YAAY,CAAC;AAE5E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC5C,cAAc,EAAE,qBAAqB,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,yEAAyE;IACzE,eAAe,CAA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,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,0BAA0B,CAsF5B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,2BAA2B,CAqDtF"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PROFILE_STALENESS_CACHE_TTL_MS = exports.CLAUDE_GOVERNANCE_HOOKS = exports.MANIFEST_CANDIDATES = exports.CODEOWNERS_CANDIDATES = void 0;
|
|
4
4
|
exports.resolveRepoRoot = resolveRepoRoot;
|
|
5
5
|
exports.gitLsFiles = gitLsFiles;
|
|
6
|
+
exports.readGeneratedProvenanceEvidence = readGeneratedProvenanceEvidence;
|
|
6
7
|
exports.governanceConfigPath = governanceConfigPath;
|
|
7
8
|
exports.readRuntimeGovernanceConfig = readRuntimeGovernanceConfig;
|
|
8
9
|
exports.readModuleImports = readModuleImports;
|
|
@@ -30,11 +31,32 @@ const fs_1 = require("fs");
|
|
|
30
31
|
const os_1 = require("os");
|
|
31
32
|
const path_1 = require("path");
|
|
32
33
|
const governance_runtime_1 = require("@neurcode-ai/governance-runtime");
|
|
34
|
+
const brain_1 = require("@neurcode-ai/brain");
|
|
35
|
+
const glob_match_1 = require("../governance/intent/glob-match");
|
|
33
36
|
exports.CODEOWNERS_CANDIDATES = ['CODEOWNERS', '.github/CODEOWNERS', 'docs/CODEOWNERS'];
|
|
34
|
-
exports.MANIFEST_CANDIDATES = [
|
|
37
|
+
exports.MANIFEST_CANDIDATES = [
|
|
38
|
+
'package.json',
|
|
39
|
+
'pnpm-workspace.yaml',
|
|
40
|
+
'lerna.json',
|
|
41
|
+
'nx.json',
|
|
42
|
+
'turbo.json',
|
|
43
|
+
'rush.json',
|
|
44
|
+
'workspace.json',
|
|
45
|
+
'pyproject.toml',
|
|
46
|
+
'setup.py',
|
|
47
|
+
'setup.cfg',
|
|
48
|
+
'go.mod',
|
|
49
|
+
'Cargo.toml',
|
|
50
|
+
'pom.xml',
|
|
51
|
+
'build.gradle',
|
|
52
|
+
'build.gradle.kts',
|
|
53
|
+
'Gemfile',
|
|
54
|
+
'composer.json',
|
|
55
|
+
'Package.swift',
|
|
56
|
+
];
|
|
35
57
|
const CLAUDE_MCP_ENTRY = Object.freeze({
|
|
36
58
|
command: 'npx',
|
|
37
|
-
args: ['-y', '@neurcode-ai/mcp-server@0.
|
|
59
|
+
args: ['-y', '@neurcode-ai/mcp-server@0.3.1'],
|
|
38
60
|
});
|
|
39
61
|
const CLAUDE_PRE_TOOL_MATCHER = 'Bash|Edit|Write|MultiEdit';
|
|
40
62
|
const COPILOT_HOOK_EVENTS = ['UserPromptSubmit', 'PreToolUse', 'Stop'];
|
|
@@ -207,6 +229,169 @@ function readFirstExisting(cwd, candidates) {
|
|
|
207
229
|
}
|
|
208
230
|
return { path: null, content: null };
|
|
209
231
|
}
|
|
232
|
+
function readManifestBundle(cwd, paths) {
|
|
233
|
+
const manifestNames = new Set(exports.MANIFEST_CANDIDATES);
|
|
234
|
+
return paths
|
|
235
|
+
.filter((pathValue) => manifestNames.has((0, path_1.basename)(pathValue)))
|
|
236
|
+
.sort()
|
|
237
|
+
.map((pathValue) => {
|
|
238
|
+
try {
|
|
239
|
+
return { path: pathValue, content: (0, fs_1.readFileSync)((0, path_1.join)(cwd, pathValue), 'utf8') };
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return { path: pathValue, content: null };
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
const GENERATED_HEADER_RE = /(?:@generated\b|\b(?:generated (?:file|code)|do not edit|automatically generated)\b)/i;
|
|
247
|
+
const GENERATOR_CONFIG_RE = /(?:^|\/)(?:openapi-generator[^/]*|buf\.gen|orval\.config|graphql-codegen)[^/]*\.(?:json|ya?ml|[cm]?[jt]s)$/i;
|
|
248
|
+
function normalizeGeneratedPath(value) {
|
|
249
|
+
return value.trim().replace(/^['"]|['"],?$/g, '').replace(/\\/g, '/').replace(/^\.\//, '');
|
|
250
|
+
}
|
|
251
|
+
function nearestGenerationCommand(outputPath, manifests) {
|
|
252
|
+
const candidates = manifests
|
|
253
|
+
.filter((manifest) => (0, path_1.basename)(manifest.path) === 'package.json' && manifest.content)
|
|
254
|
+
.map((manifest) => {
|
|
255
|
+
try {
|
|
256
|
+
const parsed = JSON.parse(manifest.content);
|
|
257
|
+
const script = Object.keys(parsed.scripts ?? {})
|
|
258
|
+
.filter((name) => /(?:^|:)(?:generate|codegen|gen)(?::|$)/i.test(name))
|
|
259
|
+
.sort()[0];
|
|
260
|
+
const root = (0, path_1.dirname)(manifest.path) === '.' ? '' : (0, path_1.dirname)(manifest.path).replace(/\\/g, '/');
|
|
261
|
+
return script && (!root || outputPath === root || outputPath.startsWith(`${root}/`))
|
|
262
|
+
? { root, command: `pnpm${root ? ` --dir ${root}` : ''} run ${script}` }
|
|
263
|
+
: null;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
.filter((candidate) => Boolean(candidate))
|
|
270
|
+
.sort((left, right) => right.root.length - left.root.length);
|
|
271
|
+
return candidates[0]?.command ?? null;
|
|
272
|
+
}
|
|
273
|
+
function resolveGeneratedSource(outputPath, candidate, tracked) {
|
|
274
|
+
if (!candidate)
|
|
275
|
+
return null;
|
|
276
|
+
const normalized = normalizeGeneratedPath(candidate);
|
|
277
|
+
if (tracked.has(normalized))
|
|
278
|
+
return normalized;
|
|
279
|
+
const relativeCandidate = normalizeGeneratedPath((0, path_1.join)((0, path_1.dirname)(outputPath), normalized));
|
|
280
|
+
return tracked.has(relativeCandidate) ? relativeCandidate : null;
|
|
281
|
+
}
|
|
282
|
+
function readGeneratedProvenanceEvidence(repoRoot, paths, manifests) {
|
|
283
|
+
const tracked = new Set(paths);
|
|
284
|
+
const evidence = new Map();
|
|
285
|
+
const record = (item) => {
|
|
286
|
+
const outputPath = normalizeGeneratedPath(item.outputPath);
|
|
287
|
+
if (!tracked.has(outputPath))
|
|
288
|
+
return;
|
|
289
|
+
const command = item.command ?? nearestGenerationCommand(outputPath, manifests);
|
|
290
|
+
evidence.set(`${outputPath}:${item.evidenceType}:${item.sourcePath ?? ''}`, {
|
|
291
|
+
...item,
|
|
292
|
+
outputPath,
|
|
293
|
+
command,
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
const attributesPath = (0, path_1.join)(repoRoot, '.gitattributes');
|
|
297
|
+
if (tracked.has('.gitattributes') && (0, fs_1.existsSync)(attributesPath)) {
|
|
298
|
+
try {
|
|
299
|
+
for (const rawLine of (0, fs_1.readFileSync)(attributesPath, 'utf8').split('\n')) {
|
|
300
|
+
const line = rawLine.trim();
|
|
301
|
+
if (!line || line.startsWith('#') || !/\blinguist-generated(?:=true)?\b/i.test(line))
|
|
302
|
+
continue;
|
|
303
|
+
const pattern = normalizeGeneratedPath(line.split(/\s+/)[0] ?? '');
|
|
304
|
+
for (const pathValue of paths) {
|
|
305
|
+
if (pathValue !== '.gitattributes' && (0, glob_match_1.matchesGlob)(pattern, pathValue)) {
|
|
306
|
+
record({ outputPath: pathValue, evidenceType: 'gitattributes' });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
// Unreadable attributes are non-authoritative; other provenance still applies.
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
for (const outputPath of paths.slice(0, MAX_GRAPH_FILES)) {
|
|
316
|
+
if (outputPath.endsWith('.sha256')) {
|
|
317
|
+
const target = outputPath.slice(0, -'.sha256'.length);
|
|
318
|
+
if (tracked.has(target))
|
|
319
|
+
record({ outputPath: target, evidenceType: 'checksum' });
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
const absolute = (0, path_1.join)(repoRoot, outputPath);
|
|
323
|
+
let head = '';
|
|
324
|
+
try {
|
|
325
|
+
if (!(0, fs_1.existsSync)(absolute))
|
|
326
|
+
continue;
|
|
327
|
+
head = (0, fs_1.readFileSync)(absolute, 'utf8').slice(0, 12_000);
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (GENERATED_HEADER_RE.test(head)) {
|
|
333
|
+
const sourceMatch = head.match(/(?:generated from|source(?: of truth)?)[\s:=]+['"]?([A-Za-z0-9_./-]+\.[A-Za-z0-9_-]+)/i);
|
|
334
|
+
record({
|
|
335
|
+
outputPath,
|
|
336
|
+
sourcePath: resolveGeneratedSource(outputPath, sourceMatch?.[1], tracked),
|
|
337
|
+
evidenceType: 'generated-header',
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (GENERATOR_CONFIG_RE.test(outputPath)) {
|
|
341
|
+
const outputMatch = head.match(/(?:output|outDir|outputDir|outputDirectory)[\s:="'{]+([A-Za-z0-9_./-]+)/i);
|
|
342
|
+
if (!outputMatch?.[1])
|
|
343
|
+
continue;
|
|
344
|
+
const outputRoot = normalizeGeneratedPath((0, path_1.join)((0, path_1.dirname)(outputPath), outputMatch[1]));
|
|
345
|
+
const sourceMatch = head.match(/(?:inputSpec|schema|source)[\s:="'{]+([A-Za-z0-9_./-]+\.[A-Za-z0-9_-]+)/i);
|
|
346
|
+
for (const candidate of paths.filter((pathValue) => pathValue === outputRoot || pathValue.startsWith(`${outputRoot}/`))) {
|
|
347
|
+
record({
|
|
348
|
+
outputPath: candidate,
|
|
349
|
+
sourcePath: resolveGeneratedSource(outputPath, sourceMatch?.[1], tracked),
|
|
350
|
+
evidenceType: 'generator-config',
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return Array.from(evidence.values()).sort((left, right) => left.outputPath.localeCompare(right.outputPath) || left.evidenceType.localeCompare(right.evidenceType));
|
|
356
|
+
}
|
|
357
|
+
function readTopologyBrainFacts(repoRoot) {
|
|
358
|
+
const graph = (0, brain_1.readRepositoryGraph)(repoRoot);
|
|
359
|
+
if (!graph)
|
|
360
|
+
return null;
|
|
361
|
+
const facts = [];
|
|
362
|
+
const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
363
|
+
for (const node of graph.nodes) {
|
|
364
|
+
if (!node.path)
|
|
365
|
+
continue;
|
|
366
|
+
if (node.kind === 'symbol' || node.kind === 'package' || node.kind === 'test') {
|
|
367
|
+
facts.push({
|
|
368
|
+
kind: node.kind,
|
|
369
|
+
path: node.path,
|
|
370
|
+
name: node.name,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
for (const edge of graph.edges) {
|
|
375
|
+
const from = nodesById.get(edge.fromId);
|
|
376
|
+
const to = nodesById.get(edge.toId);
|
|
377
|
+
if (!from?.path || !to?.path)
|
|
378
|
+
continue;
|
|
379
|
+
const kind = edge.type === 'imports'
|
|
380
|
+
? 'import'
|
|
381
|
+
: edge.type === 'tests'
|
|
382
|
+
? 'test'
|
|
383
|
+
: 'reference';
|
|
384
|
+
facts.push({
|
|
385
|
+
kind,
|
|
386
|
+
path: from.path,
|
|
387
|
+
relatedPath: to.path,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
freshness: graph.freshness.state,
|
|
392
|
+
facts: facts.slice(0, 20_000),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
210
395
|
function prefixCodeownersContent(content, baseDir) {
|
|
211
396
|
const prefix = baseDir.replace(/\\/g, '/').replace(/\/$/, '');
|
|
212
397
|
if (!prefix || prefix === '.')
|
|
@@ -443,16 +628,22 @@ function buildCurrentGovernanceProfile(repoRoot, options = {}) {
|
|
|
443
628
|
const paths = gitLsFiles(root);
|
|
444
629
|
const codeowners = readCodeownersBundle(root, paths);
|
|
445
630
|
const manifest = readFirstExisting(root, exports.MANIFEST_CANDIDATES);
|
|
631
|
+
const manifests = readManifestBundle(root, paths);
|
|
446
632
|
const governance = readRuntimeGovernanceConfig(root);
|
|
447
633
|
const imports = readModuleImports(root, paths);
|
|
634
|
+
const brain = readTopologyBrainFacts(root);
|
|
635
|
+
const generatedEvidence = readGeneratedProvenanceEvidence(root, paths, manifests);
|
|
448
636
|
const profile = (0, governance_runtime_1.buildRepoGovernanceProfile)({
|
|
449
637
|
paths,
|
|
450
638
|
codeownersContent: codeowners.content,
|
|
451
639
|
manifestContent: manifest.content,
|
|
640
|
+
manifests,
|
|
452
641
|
repoName: (0, path_1.basename)(root),
|
|
453
642
|
source: 'local',
|
|
454
643
|
runtimeConfig: governance.config,
|
|
455
644
|
imports,
|
|
645
|
+
brain,
|
|
646
|
+
generatedEvidence,
|
|
456
647
|
});
|
|
457
648
|
if (options.bypassCache !== true && process.env.NEURCODE_PROFILE_CACHE !== '0') {
|
|
458
649
|
writeProfileBuildFileCache(root, profile, stateFingerprint);
|
|
@@ -468,10 +659,14 @@ function readProfileBuildFileCache(repoRoot, stateFingerprint) {
|
|
|
468
659
|
return null;
|
|
469
660
|
try {
|
|
470
661
|
const parsed = JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
471
|
-
if (!parsed.profile ||
|
|
472
|
-
return null;
|
|
473
|
-
if (Date.now() > Date.parse(parsed.expiresAt))
|
|
662
|
+
if (!parsed.profile || stateFingerprint === null || parsed.stateFingerprint === null)
|
|
474
663
|
return null;
|
|
664
|
+
// The repository-state fingerprint, not wall-clock age, is the cache's
|
|
665
|
+
// correctness boundary. Expiring an unchanged cache forced large repos to
|
|
666
|
+
// reload their complete repository graph every five minutes, which made
|
|
667
|
+
// otherwise read-only status commands exceed their budgets. Keep writing
|
|
668
|
+
// expiresAt for backward compatibility with older readers, but reuse the
|
|
669
|
+
// persisted profile for as long as the source-free fingerprint matches.
|
|
475
670
|
if (parsed.stateFingerprint !== stateFingerprint)
|
|
476
671
|
return null;
|
|
477
672
|
return parsed.profile;
|
|
@@ -570,6 +765,35 @@ function profileFreshnessActionForSession(result, sessionProfileHash) {
|
|
|
570
765
|
}
|
|
571
766
|
const profileStalenessCache = new Map();
|
|
572
767
|
let lastProfileCacheHit = false;
|
|
768
|
+
function changedPathContentFingerprint(root, path) {
|
|
769
|
+
const absolutePath = (0, path_1.join)(root, path);
|
|
770
|
+
try {
|
|
771
|
+
const stat = (0, fs_1.lstatSync)(absolutePath);
|
|
772
|
+
if (stat.isSymbolicLink()) {
|
|
773
|
+
return `${path}\0symlink\0${(0, fs_1.readlinkSync)(absolutePath)}`;
|
|
774
|
+
}
|
|
775
|
+
if (!stat.isFile())
|
|
776
|
+
return `${path}\0${stat.mode}\0${stat.size}`;
|
|
777
|
+
const hash = (0, crypto_1.createHash)('sha256');
|
|
778
|
+
const descriptor = (0, fs_1.openSync)(absolutePath, 'r');
|
|
779
|
+
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
780
|
+
try {
|
|
781
|
+
let bytesRead = 0;
|
|
782
|
+
do {
|
|
783
|
+
bytesRead = (0, fs_1.readSync)(descriptor, buffer, 0, buffer.length, null);
|
|
784
|
+
if (bytesRead > 0)
|
|
785
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
786
|
+
} while (bytesRead > 0);
|
|
787
|
+
}
|
|
788
|
+
finally {
|
|
789
|
+
(0, fs_1.closeSync)(descriptor);
|
|
790
|
+
}
|
|
791
|
+
return `${path}\0file\0${stat.mode}\0${stat.size}\0${hash.digest('hex')}`;
|
|
792
|
+
}
|
|
793
|
+
catch {
|
|
794
|
+
return `${path}\0missing`;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
573
797
|
function profileCacheStateFingerprint(root) {
|
|
574
798
|
try {
|
|
575
799
|
let head = 'unborn';
|
|
@@ -578,32 +802,68 @@ function profileCacheStateFingerprint(root) {
|
|
|
578
802
|
cwd: root,
|
|
579
803
|
encoding: 'utf8',
|
|
580
804
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
805
|
+
timeout: 3_000,
|
|
581
806
|
}).trim();
|
|
582
807
|
}
|
|
583
808
|
catch {
|
|
584
809
|
// `git status` remains authoritative before the first commit. Keep an
|
|
585
810
|
// explicit sentinel so staged topology changes still invalidate caches.
|
|
586
811
|
}
|
|
587
|
-
const
|
|
812
|
+
const internalPathExclusions = [
|
|
813
|
+
'--',
|
|
814
|
+
'.',
|
|
815
|
+
':(exclude).neurcode/**',
|
|
816
|
+
':(exclude).neurcode-admission/**',
|
|
817
|
+
':(exclude).cursor/rules/neurcode-*',
|
|
818
|
+
];
|
|
819
|
+
const status = (0, child_process_1.execFileSync)('git', [
|
|
820
|
+
'status', '--porcelain=v2', '-z', '--untracked-files=all',
|
|
821
|
+
...internalPathExclusions,
|
|
822
|
+
], {
|
|
823
|
+
cwd: root,
|
|
824
|
+
encoding: 'utf8',
|
|
825
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
826
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
827
|
+
timeout: 5_000,
|
|
828
|
+
});
|
|
829
|
+
const stagedSummary = (0, child_process_1.execFileSync)('git', [
|
|
830
|
+
'diff', '--cached', '--no-ext-diff', '--numstat', '-z',
|
|
831
|
+
...internalPathExclusions,
|
|
832
|
+
], {
|
|
588
833
|
cwd: root,
|
|
589
834
|
encoding: 'utf8',
|
|
590
835
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
591
836
|
maxBuffer: 4 * 1024 * 1024,
|
|
837
|
+
timeout: 5_000,
|
|
592
838
|
});
|
|
593
|
-
const
|
|
839
|
+
const worktreeSummary = (0, child_process_1.execFileSync)('git', [
|
|
840
|
+
'diff', '--no-ext-diff', '--numstat', '-z',
|
|
841
|
+
...internalPathExclusions,
|
|
842
|
+
], {
|
|
594
843
|
cwd: root,
|
|
595
844
|
encoding: 'utf8',
|
|
596
845
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
597
|
-
maxBuffer:
|
|
846
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
847
|
+
timeout: 5_000,
|
|
598
848
|
});
|
|
599
|
-
const
|
|
849
|
+
const changedPaths = (0, child_process_1.execFileSync)('git', [
|
|
850
|
+
'ls-files', '-m', '-o', '--exclude-standard', '-z',
|
|
851
|
+
...internalPathExclusions,
|
|
852
|
+
], {
|
|
600
853
|
cwd: root,
|
|
601
854
|
encoding: 'utf8',
|
|
602
855
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
603
856
|
maxBuffer: 8 * 1024 * 1024,
|
|
604
|
-
|
|
857
|
+
timeout: 5_000,
|
|
858
|
+
}).split('\0').filter(Boolean).sort();
|
|
859
|
+
// Only dirty/untracked paths are content-hashed. This preserves exact
|
|
860
|
+
// invalidation (including same-size edits with restored mtimes) without
|
|
861
|
+
// rescanning every tracked file or following repository symlinks.
|
|
862
|
+
const workingContent = changedPaths
|
|
863
|
+
.map((path) => changedPathContentFingerprint(root, path))
|
|
864
|
+
.join('\n');
|
|
605
865
|
return (0, crypto_1.createHash)('sha256')
|
|
606
|
-
.update(`${head}\n${status}\n${
|
|
866
|
+
.update(`${head}\n${status}\n${stagedSummary}\n${worktreeSummary}\n${workingContent}`)
|
|
607
867
|
.digest('hex')
|
|
608
868
|
.slice(0, 24);
|
|
609
869
|
}
|