@neurcode-ai/cli 0.19.0 → 0.19.2
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/commands/brain.d.ts.map +1 -1
- package/dist/commands/brain.js +87 -7
- package/dist/commands/brain.js.map +1 -1
- package/dist/commands/ops.d.ts +5 -0
- package/dist/commands/ops.d.ts.map +1 -1
- package/dist/commands/ops.js +32 -2
- package/dist/commands/ops.js.map +1 -1
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +50 -0
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/quickstart.d.ts.map +1 -1
- package/dist/commands/quickstart.js +11 -6
- package/dist/commands/quickstart.js.map +1 -1
- package/dist/commands/session.d.ts +5 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +328 -53
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/verify-output.d.ts +2 -0
- package/dist/commands/verify-output.d.ts.map +1 -1
- package/dist/commands/verify-output.js +4 -0
- package/dist/commands/verify-output.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +108 -24
- package/dist/commands/verify.js.map +1 -1
- package/dist/governance/structural-on-diff.d.ts +11 -0
- package/dist/governance/structural-on-diff.d.ts.map +1 -1
- package/dist/governance/structural-on-diff.js +38 -5
- package/dist/governance/structural-on-diff.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime-build.json +5 -5
- package/dist/utils/brain-context.d.ts.map +1 -1
- package/dist/utils/brain-context.js +11 -2
- package/dist/utils/brain-context.js.map +1 -1
- package/dist/utils/local-repo-brain.d.ts.map +1 -1
- package/dist/utils/local-repo-brain.js +4 -0
- package/dist/utils/local-repo-brain.js.map +1 -1
- package/dist/utils/proposed-change-analysis.d.ts.map +1 -1
- package/dist/utils/proposed-change-analysis.js +7 -5
- package/dist/utils/proposed-change-analysis.js.map +1 -1
- package/dist/utils/repo-intelligence-v2.d.ts.map +1 -1
- package/dist/utils/repo-intelligence-v2.js +41 -0
- package/dist/utils/repo-intelligence-v2.js.map +1 -1
- package/dist/utils/structural-understanding.d.ts +2 -2
- package/dist/utils/structural-understanding.d.ts.map +1 -1
- package/dist/utils/structural-understanding.js +1 -1
- package/dist/utils/structural-understanding.js.map +1 -1
- package/dist/utils/team-memory-path-hygiene.d.ts +4 -0
- package/dist/utils/team-memory-path-hygiene.d.ts.map +1 -0
- package/dist/utils/team-memory-path-hygiene.js +50 -0
- package/dist/utils/team-memory-path-hygiene.js.map +1 -0
- package/dist/utils/v0-governance.d.ts +7 -0
- package/dist/utils/v0-governance.d.ts.map +1 -1
- package/dist/utils/v0-governance.js +47 -0
- package/dist/utils/v0-governance.js.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../src/commands/quickstart.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAyEH,
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../src/commands/quickstart.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAyEH,8CAsHC;AA7LD,2BAA0D;AAC1D,+BAA4B;AAC5B,kDAA0B;AAC1B,wDAA4E;AAC5E,mEAAuE;AAOvE,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCtB,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;IACtE,QAAQ,EAAE,2EAA2E;IACrF,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,WAAW;IACX,aAAa,EAAE,IAAI;IACnB,sBAAsB,EAAE,IAAI;IAC5B,YAAY,EAAE,qBAAqB;CACpC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAEZ,SAAS,WAAW,CAAC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+9,7 @@
|
|
|
9
9
|
* - neurcode session status - Show status of current session
|
|
10
10
|
*/
|
|
11
11
|
import { type AgentPlan, type AgentPlanAmendmentProposal, type AIChangeRecord, type AgentInvocationSummary, type AgentGuardPostureSummary, type ArchitectureObligation, type GovernanceSession, type SessionEvent } from '@neurcode-ai/governance-runtime';
|
|
12
|
+
import { type DiffFile } from '@neurcode-ai/diff-parser';
|
|
12
13
|
import { type RuntimeConnection } from '../utils/runtime-connection';
|
|
13
14
|
import { type ImpactSummary } from '../utils/repo-brain-impact';
|
|
14
15
|
import { type AgentGuardSupervisorInspection } from '../utils/agent-guard-supervisor';
|
|
@@ -101,6 +102,10 @@ interface PresentLocalGovernanceStatus {
|
|
|
101
102
|
connection: RuntimeConnection | null;
|
|
102
103
|
}
|
|
103
104
|
type LocalGovernanceStatus = MissingLocalGovernanceStatus | PresentLocalGovernanceStatus;
|
|
105
|
+
type UnderstandingDiffFile = DiffFile & {
|
|
106
|
+
provenance?: 'git-diff' | 'git-untracked';
|
|
107
|
+
};
|
|
108
|
+
export declare function resolveUnderstandingDiffFiles(repoRoot: string, options?: Pick<SessionCommandOptions, 'staged' | 'base' | 'head'>): UnderstandingDiffFile[];
|
|
104
109
|
export declare function buildLocalGovernanceStatus(options?: SessionCommandOptions): LocalGovernanceStatus;
|
|
105
110
|
export declare function localGovernanceStatusCommand(options?: SessionCommandOptions): void;
|
|
106
111
|
export declare function resetStaleGovernanceSessionCommand(options?: SessionCommandOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAmBL,KAAK,SAAS,EACd,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,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M,GAAG,IAAI,CAAC;QACrB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAkB/E;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,aAAa,GAAG,IAAI,CAQ7G;AAED,wBAAsB,0BAA0B,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAiF1H;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;EA2B7E;AAuND,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,qBAA0B,QAkEjF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,iBAyFvE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,iBAuLrE;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,iBA+ExE;AAED,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,qBAA0B,QAmC3E;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,qBAA0B,QAyC7E;AAED,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,qBAA0B,QA6C5E;AAED,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,qBAA0B,QAwC9E"}
|
package/dist/commands/session.js
CHANGED
|
@@ -43,6 +43,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
43
43
|
};
|
|
44
44
|
})();
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.resolveUnderstandingDiffFiles = resolveUnderstandingDiffFiles;
|
|
46
47
|
exports.buildLocalGovernanceStatus = buildLocalGovernanceStatus;
|
|
47
48
|
exports.localGovernanceStatusCommand = localGovernanceStatusCommand;
|
|
48
49
|
exports.resetStaleGovernanceSessionCommand = resetStaleGovernanceSessionCommand;
|
|
@@ -84,6 +85,7 @@ const runtime_outbox_1 = require("../utils/runtime-outbox");
|
|
|
84
85
|
const repo_brain_impact_1 = require("../utils/repo-brain-impact");
|
|
85
86
|
const structural_understanding_1 = require("../utils/structural-understanding");
|
|
86
87
|
const agent_guard_supervisor_1 = require("../utils/agent-guard-supervisor");
|
|
88
|
+
const hook_heartbeat_1 = require("../utils/hook-heartbeat");
|
|
87
89
|
const node_child_process_1 = require("node:child_process");
|
|
88
90
|
const node_fs_1 = require("node:fs");
|
|
89
91
|
const node_path_1 = require("node:path");
|
|
@@ -173,7 +175,79 @@ function approvalContextFrom(event) {
|
|
|
173
175
|
: event?.filePath,
|
|
174
176
|
};
|
|
175
177
|
}
|
|
176
|
-
|
|
178
|
+
const UNTRACKED_UNDERSTANDING_EXCLUDED_DIRS = new Set([
|
|
179
|
+
'.git',
|
|
180
|
+
'.neurcode',
|
|
181
|
+
'.neurcode-admission',
|
|
182
|
+
'.neurcode-ai-record',
|
|
183
|
+
'.cache',
|
|
184
|
+
'.next',
|
|
185
|
+
'build',
|
|
186
|
+
'cache',
|
|
187
|
+
'coverage',
|
|
188
|
+
'dist',
|
|
189
|
+
'evidence',
|
|
190
|
+
'generated',
|
|
191
|
+
'node_modules',
|
|
192
|
+
'out',
|
|
193
|
+
'vendor',
|
|
194
|
+
]);
|
|
195
|
+
const UNTRACKED_UNDERSTANDING_SOURCE = /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/i;
|
|
196
|
+
const UNTRACKED_UNDERSTANDING_GENERATED_FILE = /(?:\.d\.ts|\.map|\.min\.js|\.bundle\.js|\.generated\.[cm]?[jt]sx?)$/i;
|
|
197
|
+
function normalizeUnderstandingPath(value) {
|
|
198
|
+
return value.replace(/\\/g, '/').replace(/^\.\//, '').trim();
|
|
199
|
+
}
|
|
200
|
+
function eligibleUntrackedUnderstandingPath(repoRoot, value) {
|
|
201
|
+
const normalized = normalizeUnderstandingPath(value);
|
|
202
|
+
if (!normalized || normalized.startsWith('/') || normalized === '..' || normalized.startsWith('../'))
|
|
203
|
+
return null;
|
|
204
|
+
const segments = normalized.split('/');
|
|
205
|
+
if (segments.includes('..') || segments.some((segment) => UNTRACKED_UNDERSTANDING_EXCLUDED_DIRS.has(segment.toLowerCase()))) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
if (UNTRACKED_UNDERSTANDING_GENERATED_FILE.test(normalized))
|
|
209
|
+
return null;
|
|
210
|
+
const absolutePath = (0, node_path_1.join)(repoRoot, normalized);
|
|
211
|
+
try {
|
|
212
|
+
const stat = (0, node_fs_1.lstatSync)(absolutePath);
|
|
213
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return normalized;
|
|
220
|
+
}
|
|
221
|
+
function untrackedDiffFile(repoRoot, path) {
|
|
222
|
+
let lines = [];
|
|
223
|
+
if (UNTRACKED_UNDERSTANDING_SOURCE.test(path)) {
|
|
224
|
+
const text = (0, node_fs_1.readFileSync)((0, node_path_1.join)(repoRoot, path), 'utf8').replace(/\r\n/g, '\n');
|
|
225
|
+
lines = text ? text.split('\n') : [];
|
|
226
|
+
if (lines.at(-1) === '')
|
|
227
|
+
lines.pop();
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
path,
|
|
231
|
+
changeType: 'add',
|
|
232
|
+
addedLines: lines.length,
|
|
233
|
+
removedLines: 0,
|
|
234
|
+
hunks: lines.length > 0
|
|
235
|
+
? [{
|
|
236
|
+
oldStart: 0,
|
|
237
|
+
oldLines: 0,
|
|
238
|
+
newStart: 1,
|
|
239
|
+
newLines: lines.length,
|
|
240
|
+
lines: lines.map((content, index) => ({
|
|
241
|
+
type: 'added',
|
|
242
|
+
content,
|
|
243
|
+
lineNumber: index + 1,
|
|
244
|
+
})),
|
|
245
|
+
}]
|
|
246
|
+
: [],
|
|
247
|
+
provenance: 'git-untracked',
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function resolveUnderstandingDiffFiles(repoRoot, options = {}) {
|
|
177
251
|
const args = ['diff'];
|
|
178
252
|
if (options.staged) {
|
|
179
253
|
args.push('--cached');
|
|
@@ -184,11 +258,27 @@ function resolveUnderstandingDiff(repoRoot, options) {
|
|
|
184
258
|
else {
|
|
185
259
|
args.push('HEAD');
|
|
186
260
|
}
|
|
187
|
-
|
|
261
|
+
const diffText = (0, node_child_process_1.execFileSync)('git', args, {
|
|
188
262
|
cwd: repoRoot,
|
|
189
263
|
encoding: 'utf8',
|
|
190
264
|
maxBuffer: 64 * 1024 * 1024,
|
|
191
265
|
});
|
|
266
|
+
const selected = (0, diff_parser_1.parseDiff)(diffText);
|
|
267
|
+
if (options.staged)
|
|
268
|
+
return selected;
|
|
269
|
+
const untrackedOutput = (0, node_child_process_1.execFileSync)('git', ['ls-files', '--others', '--exclude-standard', '-z'], {
|
|
270
|
+
cwd: repoRoot,
|
|
271
|
+
encoding: 'utf8',
|
|
272
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
273
|
+
});
|
|
274
|
+
const byPath = new Map(selected.map((file) => [normalizeUnderstandingPath(file.path), file]));
|
|
275
|
+
for (const rawPath of untrackedOutput.split('\0')) {
|
|
276
|
+
const path = eligibleUntrackedUnderstandingPath(repoRoot, rawPath);
|
|
277
|
+
if (!path || byPath.has(path))
|
|
278
|
+
continue;
|
|
279
|
+
byPath.set(path, untrackedDiffFile(repoRoot, path));
|
|
280
|
+
}
|
|
281
|
+
return [...byPath.values()].sort((a, b) => normalizeUnderstandingPath(a.path).localeCompare(normalizeUnderstandingPath(b.path)));
|
|
192
282
|
}
|
|
193
283
|
function loadLocalGovernanceSession(repoRoot, sessionId) {
|
|
194
284
|
return sessionId ? (0, governance_runtime_1.loadSession)(repoRoot, sessionId) : (0, governance_runtime_1.loadActiveSession)(repoRoot);
|
|
@@ -251,6 +341,108 @@ function pendingApprovalBlock(session, now = new Date()) {
|
|
|
251
341
|
}
|
|
252
342
|
return null;
|
|
253
343
|
}
|
|
344
|
+
function activePointerInspection(repoRoot) {
|
|
345
|
+
const path = (0, node_path_1.join)(repoRoot, '.neurcode', 'active-session.json');
|
|
346
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
347
|
+
return { state: 'missing', sessionId: null, session: null };
|
|
348
|
+
try {
|
|
349
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
|
|
350
|
+
if (parsed.sessionId === null)
|
|
351
|
+
return { state: 'cleared', sessionId: null, session: null };
|
|
352
|
+
if (typeof parsed.sessionId !== 'string' || !parsed.sessionId.trim()) {
|
|
353
|
+
return { state: 'malformed', sessionId: null, session: null };
|
|
354
|
+
}
|
|
355
|
+
const session = (0, governance_runtime_1.loadSession)(repoRoot, parsed.sessionId);
|
|
356
|
+
if (!session || session.status !== 'active') {
|
|
357
|
+
return { state: 'stale', sessionId: parsed.sessionId, session };
|
|
358
|
+
}
|
|
359
|
+
return { state: 'valid', sessionId: parsed.sessionId, session };
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return { state: 'malformed', sessionId: null, session: null };
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function validGovernanceSessionRecord(value) {
|
|
366
|
+
if (!value || typeof value !== 'object')
|
|
367
|
+
return false;
|
|
368
|
+
const record = value;
|
|
369
|
+
return (typeof record.sessionId === 'string' &&
|
|
370
|
+
typeof record.profileHash === 'string' &&
|
|
371
|
+
(record.status === 'active' || record.status === 'finished') &&
|
|
372
|
+
Array.isArray(record.events) &&
|
|
373
|
+
Boolean(record.contract && typeof record.contract === 'object'));
|
|
374
|
+
}
|
|
375
|
+
function scanSessionRecords(repoRoot) {
|
|
376
|
+
const directory = (0, governance_runtime_1.sessionsDir)(repoRoot);
|
|
377
|
+
if (!(0, node_fs_1.existsSync)(directory))
|
|
378
|
+
return { active: [], malformed: [] };
|
|
379
|
+
const active = [];
|
|
380
|
+
const malformed = [];
|
|
381
|
+
for (const entry of (0, node_fs_1.readdirSync)(directory, { withFileTypes: true })
|
|
382
|
+
.filter((item) => item.isFile() && item.name.endsWith('.json') && !item.name.endsWith('.change-record.json'))
|
|
383
|
+
.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
384
|
+
const relativePath = `.neurcode/sessions/${entry.name}`;
|
|
385
|
+
try {
|
|
386
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(directory, entry.name), 'utf8'));
|
|
387
|
+
if (!validGovernanceSessionRecord(parsed)) {
|
|
388
|
+
malformed.push({ file: relativePath, reasonCode: 'invalid_session_record' });
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (entry.name !== `${parsed.sessionId}.json`) {
|
|
392
|
+
malformed.push({ file: relativePath, reasonCode: 'session_id_filename_mismatch' });
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (parsed.status === 'active')
|
|
396
|
+
active.push(parsed);
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
malformed.push({ file: relativePath, reasonCode: 'malformed_json' });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
active: active.sort((a, b) => a.sessionId.localeCompare(b.sessionId)),
|
|
404
|
+
malformed,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function recoveryReasonCode(pointer, sessionId) {
|
|
408
|
+
if (pointer.state === 'valid') {
|
|
409
|
+
return pointer.sessionId === sessionId
|
|
410
|
+
? 'stale_referenced_active_session'
|
|
411
|
+
: 'orphan_unreferenced_active_record';
|
|
412
|
+
}
|
|
413
|
+
if (pointer.state === 'missing')
|
|
414
|
+
return 'orphan_missing_active_pointer';
|
|
415
|
+
if (pointer.state === 'cleared')
|
|
416
|
+
return 'orphan_cleared_active_pointer';
|
|
417
|
+
if (pointer.state === 'malformed')
|
|
418
|
+
return 'orphan_malformed_active_pointer';
|
|
419
|
+
return 'orphan_stale_active_pointer';
|
|
420
|
+
}
|
|
421
|
+
function activeSessionLiveness(repoRoot, sessionId, now) {
|
|
422
|
+
const reasons = [];
|
|
423
|
+
const supervisor = (0, agent_guard_supervisor_1.inspectAgentGuardSupervisor)(repoRoot, sessionId);
|
|
424
|
+
if (supervisor.state?.sessionId === sessionId &&
|
|
425
|
+
supervisor.alive &&
|
|
426
|
+
['running', 'starting', 'stopping'].includes(supervisor.effectiveStatus)) {
|
|
427
|
+
reasons.push('live_supervisor_process');
|
|
428
|
+
}
|
|
429
|
+
const heartbeat = (0, hook_heartbeat_1.readHookHeartbeat)(repoRoot);
|
|
430
|
+
const heartbeatAt = Date.parse(heartbeat?.lastEvent.ts ?? '');
|
|
431
|
+
if (heartbeat?.lastEvent.sessionId === sessionId &&
|
|
432
|
+
Number.isFinite(heartbeatAt) &&
|
|
433
|
+
now.getTime() - heartbeatAt >= 0 &&
|
|
434
|
+
now.getTime() - heartbeatAt <= 5 * 60_000) {
|
|
435
|
+
reasons.push('fresh_hook_heartbeat');
|
|
436
|
+
}
|
|
437
|
+
return reasons;
|
|
438
|
+
}
|
|
439
|
+
function clearInvalidActivePointer(repoRoot, pointer) {
|
|
440
|
+
if (pointer.state === 'valid')
|
|
441
|
+
return;
|
|
442
|
+
const directory = (0, node_path_1.join)(repoRoot, '.neurcode');
|
|
443
|
+
(0, node_fs_1.mkdirSync)(directory, { recursive: true });
|
|
444
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(directory, 'active-session.json'), JSON.stringify({ sessionId: null }, null, 2) + '\n', 'utf8');
|
|
445
|
+
}
|
|
254
446
|
function buildLocalGovernanceStatus(options = {}) {
|
|
255
447
|
const repoRoot = (0, v0_governance_1.resolveRepoRoot)(options.dir || process.cwd());
|
|
256
448
|
const session = loadLocalGovernanceSession(repoRoot, options.sessionId);
|
|
@@ -413,7 +605,8 @@ async function resetStaleGovernanceSessionCommand(options = {}) {
|
|
|
413
605
|
const maxAgeMinutes = Number.isFinite(options.maxAgeMinutes)
|
|
414
606
|
? Math.max(0, Number(options.maxAgeMinutes))
|
|
415
607
|
: 120;
|
|
416
|
-
const
|
|
608
|
+
const pointer = activePointerInspection(repoRoot);
|
|
609
|
+
const records = scanSessionRecords(repoRoot);
|
|
417
610
|
const output = (payload, statusCode = 0) => {
|
|
418
611
|
if (options.json) {
|
|
419
612
|
console.log(JSON.stringify(payload, null, 2));
|
|
@@ -433,92 +626,175 @@ async function resetStaleGovernanceSessionCommand(options = {}) {
|
|
|
433
626
|
}
|
|
434
627
|
process.exitCode = statusCode;
|
|
435
628
|
};
|
|
436
|
-
if (
|
|
629
|
+
if (records.active.length === 0) {
|
|
437
630
|
output({
|
|
438
631
|
ok: true,
|
|
439
632
|
reset: false,
|
|
440
633
|
repoRoot,
|
|
441
634
|
reason: 'no_active_session',
|
|
635
|
+
pointerState: pointer.state,
|
|
636
|
+
malformedRecords: records.malformed,
|
|
442
637
|
message: 'No active in-flow governance session found.',
|
|
443
638
|
});
|
|
444
639
|
return;
|
|
445
640
|
}
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
const
|
|
449
|
-
|
|
641
|
+
const recovered = [];
|
|
642
|
+
const skipped = [];
|
|
643
|
+
for (const active of records.active) {
|
|
644
|
+
const ageMinutes = sessionAgeMinutes(active, now);
|
|
645
|
+
const pending = pendingApprovalBlock(active, now);
|
|
646
|
+
const stale = ageMinutes >= maxAgeMinutes;
|
|
647
|
+
const liveness = activeSessionLiveness(repoRoot, active.sessionId, now);
|
|
648
|
+
const reasonCode = recoveryReasonCode(pointer, active.sessionId);
|
|
649
|
+
if (liveness.length > 0) {
|
|
650
|
+
skipped.push({
|
|
651
|
+
sessionId: active.sessionId,
|
|
652
|
+
reason: 'session_live',
|
|
653
|
+
reasonCode,
|
|
654
|
+
liveness,
|
|
655
|
+
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
656
|
+
});
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (!stale && options.force !== true) {
|
|
660
|
+
skipped.push({
|
|
661
|
+
sessionId: active.sessionId,
|
|
662
|
+
reason: 'session_not_stale',
|
|
663
|
+
reasonCode,
|
|
664
|
+
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
665
|
+
pendingApproval: pending,
|
|
666
|
+
});
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
if (pending && options.force !== true) {
|
|
670
|
+
skipped.push({
|
|
671
|
+
sessionId: active.sessionId,
|
|
672
|
+
reason: 'pending_approval',
|
|
673
|
+
reasonCode,
|
|
674
|
+
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
675
|
+
filePath: pending.filePath,
|
|
676
|
+
owners: pending.owners,
|
|
677
|
+
suggestedApprovalPath: pending.suggestedApprovalPath,
|
|
678
|
+
});
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
const pointerReferenced = pointer.state === 'valid' && pointer.sessionId === active.sessionId;
|
|
682
|
+
(0, governance_runtime_1.appendEvent)(repoRoot, active.sessionId, {
|
|
683
|
+
type: 'user_decision',
|
|
684
|
+
ts: now.toISOString(),
|
|
685
|
+
decision: pointerReferenced ? 'reset_stale_session' : 'recover_orphaned_session',
|
|
686
|
+
detail: {
|
|
687
|
+
source: 'local_cli',
|
|
688
|
+
recovery: true,
|
|
689
|
+
reasonCode,
|
|
690
|
+
pointerState: pointer.state,
|
|
691
|
+
force: options.force === true,
|
|
692
|
+
maxAgeMinutes,
|
|
693
|
+
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
694
|
+
pendingApproval: pending,
|
|
695
|
+
livenessChecks: ['bounded_event_age', 'guard_supervisor_process', 'hook_heartbeat'],
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
const livePointerPath = (0, node_path_1.join)(repoRoot, '.neurcode', 'active-session.json');
|
|
699
|
+
const preservedLivePointer = pointer.state === 'valid' && pointer.sessionId !== active.sessionId && (0, node_fs_1.existsSync)(livePointerPath)
|
|
700
|
+
? (0, node_fs_1.readFileSync)(livePointerPath, 'utf8')
|
|
701
|
+
: null;
|
|
702
|
+
let finished = null;
|
|
703
|
+
try {
|
|
704
|
+
finished = (0, governance_runtime_1.finishSession)(repoRoot, active.sessionId, { reason: reasonCode });
|
|
705
|
+
}
|
|
706
|
+
finally {
|
|
707
|
+
if (preservedLivePointer !== null) {
|
|
708
|
+
(0, node_fs_1.writeFileSync)(livePointerPath, preservedLivePointer, 'utf8');
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (!finished) {
|
|
712
|
+
skipped.push({ sessionId: active.sessionId, reason: 'finish_failed', reasonCode });
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
const supervisor = (0, agent_guard_supervisor_1.inspectAgentGuardSupervisor)(repoRoot, finished.sessionId);
|
|
716
|
+
if (supervisor.state?.sessionId === finished.sessionId) {
|
|
717
|
+
(0, agent_guard_supervisor_1.stopSupervisorOnSessionCompletion)(repoRoot);
|
|
718
|
+
}
|
|
719
|
+
await (0, runtime_live_1.publishRuntimeLiveStatus)(repoRoot, finished);
|
|
720
|
+
const replay = (0, governance_runtime_1.replaySession)(finished);
|
|
721
|
+
recovered.push({
|
|
722
|
+
sessionId: finished.sessionId,
|
|
723
|
+
previousGoal: finished.contract.goal,
|
|
724
|
+
status: finished.status,
|
|
725
|
+
reasonCode,
|
|
726
|
+
replayHash: finished.replayHash,
|
|
727
|
+
replayVerified: replay.matchesOriginal,
|
|
728
|
+
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
729
|
+
forced: options.force === true,
|
|
730
|
+
recordPath: `.neurcode/sessions/${finished.sessionId}.json`,
|
|
731
|
+
evidencePath: (0, node_path_1.relative)(repoRoot, (0, governance_runtime_1.aiChangeRecordPath)(repoRoot, finished.sessionId)).replace(/\\/g, '/'),
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
if (recovered.length > 0) {
|
|
735
|
+
clearInvalidActivePointer(repoRoot, pointer);
|
|
736
|
+
const first = recovered[0];
|
|
450
737
|
output({
|
|
451
738
|
ok: true,
|
|
452
|
-
reset:
|
|
739
|
+
reset: true,
|
|
453
740
|
repoRoot,
|
|
454
|
-
sessionId:
|
|
455
|
-
|
|
456
|
-
|
|
741
|
+
sessionId: recovered.length === 1 ? first.sessionId : undefined,
|
|
742
|
+
status: recovered.length === 1 ? first.status : 'finished',
|
|
743
|
+
replayHash: recovered.length === 1 ? first.replayHash : undefined,
|
|
744
|
+
ageMinutes: recovered.length === 1 ? first.ageMinutes : undefined,
|
|
457
745
|
maxAgeMinutes,
|
|
458
|
-
|
|
459
|
-
|
|
746
|
+
forced: options.force === true,
|
|
747
|
+
pointerState: pointer.state,
|
|
748
|
+
recoveredCount: recovered.length,
|
|
749
|
+
recovered,
|
|
750
|
+
skipped,
|
|
751
|
+
malformedRecords: records.malformed,
|
|
752
|
+
message: `Recovered ${recovered.length} stale or orphaned active session record${recovered.length === 1 ? '' : 's'}.`,
|
|
460
753
|
});
|
|
461
754
|
return;
|
|
462
755
|
}
|
|
463
|
-
|
|
756
|
+
const primary = skipped.find((item) => item.sessionId === pointer.sessionId) ?? skipped[0];
|
|
757
|
+
if (primary?.reason === 'pending_approval') {
|
|
464
758
|
output({
|
|
465
759
|
ok: false,
|
|
466
760
|
reset: false,
|
|
467
761
|
repoRoot,
|
|
468
|
-
|
|
469
|
-
reason: 'pending_approval',
|
|
470
|
-
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
762
|
+
...primary,
|
|
471
763
|
maxAgeMinutes,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
suggestedApprovalPath: pending.suggestedApprovalPath,
|
|
764
|
+
pointerState: pointer.state,
|
|
765
|
+
malformedRecords: records.malformed,
|
|
475
766
|
message: 'Active session is waiting on an unresolved approval; refusing to reset without --force.',
|
|
476
767
|
next: [
|
|
477
|
-
`Approve exactly ${
|
|
768
|
+
`Approve exactly ${primary.suggestedApprovalPath} from the dashboard or MCP.`,
|
|
478
769
|
'Or run `neurcode session reset-stale --force` if this is abandoned rehearsal state.',
|
|
479
770
|
],
|
|
480
771
|
}, 2);
|
|
481
772
|
return;
|
|
482
773
|
}
|
|
483
|
-
(
|
|
484
|
-
type: 'user_decision',
|
|
485
|
-
ts: now.toISOString(),
|
|
486
|
-
decision: 'reset_stale_session',
|
|
487
|
-
detail: {
|
|
488
|
-
source: 'local_cli',
|
|
489
|
-
force: options.force === true,
|
|
490
|
-
maxAgeMinutes,
|
|
491
|
-
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
492
|
-
pendingApproval: pending,
|
|
493
|
-
},
|
|
494
|
-
});
|
|
495
|
-
const finished = (0, governance_runtime_1.finishSession)(repoRoot, active.sessionId);
|
|
496
|
-
if (!finished) {
|
|
774
|
+
if (primary?.reason === 'finish_failed') {
|
|
497
775
|
output({
|
|
498
776
|
ok: false,
|
|
499
777
|
reset: false,
|
|
500
778
|
repoRoot,
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
779
|
+
...primary,
|
|
780
|
+
pointerState: pointer.state,
|
|
781
|
+
malformedRecords: records.malformed,
|
|
782
|
+
message: `Could not finish active session ${primary.sessionId}.`,
|
|
504
783
|
}, 1);
|
|
505
784
|
return;
|
|
506
785
|
}
|
|
507
|
-
(0, agent_guard_supervisor_1.stopSupervisorOnSessionCompletion)(repoRoot);
|
|
508
|
-
await (0, runtime_live_1.publishRuntimeLiveStatus)(repoRoot, finished);
|
|
509
786
|
output({
|
|
510
787
|
ok: true,
|
|
511
|
-
reset:
|
|
788
|
+
reset: false,
|
|
512
789
|
repoRoot,
|
|
513
|
-
|
|
514
|
-
previousGoal: finished.contract.goal,
|
|
515
|
-
status: finished.status,
|
|
516
|
-
replayHash: finished.replayHash,
|
|
517
|
-
ageMinutes: Number(ageMinutes.toFixed(2)),
|
|
790
|
+
...primary,
|
|
518
791
|
maxAgeMinutes,
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
792
|
+
pointerState: pointer.state,
|
|
793
|
+
skipped,
|
|
794
|
+
malformedRecords: records.malformed,
|
|
795
|
+
message: primary?.reason === 'session_live'
|
|
796
|
+
? `Session ${primary.sessionId} has current process or heartbeat liveness evidence and was preserved.`
|
|
797
|
+
: `Active session ${primary?.sessionId} is not stale yet (${Number(primary?.ageMinutes ?? 0).toFixed(1)}m < ${maxAgeMinutes}m).`,
|
|
522
798
|
});
|
|
523
799
|
}
|
|
524
800
|
async function replanGovernanceSessionCommand(options = {}) {
|
|
@@ -1547,9 +1823,9 @@ function structuralUnderstandingCommand(options = {}) {
|
|
|
1547
1823
|
process.exitCode = 1;
|
|
1548
1824
|
return;
|
|
1549
1825
|
}
|
|
1550
|
-
let
|
|
1826
|
+
let diffFiles = [];
|
|
1551
1827
|
try {
|
|
1552
|
-
|
|
1828
|
+
diffFiles = resolveUnderstandingDiffFiles(repoRoot, options);
|
|
1553
1829
|
}
|
|
1554
1830
|
catch (error) {
|
|
1555
1831
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1562,7 +1838,6 @@ function structuralUnderstandingCommand(options = {}) {
|
|
|
1562
1838
|
process.exitCode = 1;
|
|
1563
1839
|
return;
|
|
1564
1840
|
}
|
|
1565
|
-
const diffFiles = diffText.trim() ? (0, diff_parser_1.parseDiff)(diffText) : [];
|
|
1566
1841
|
const profile = (0, v0_governance_1.getProfileStaleness)(repoRoot).currentProfile;
|
|
1567
1842
|
const artifact = (0, structural_understanding_1.buildStructuralUnderstanding)(repoRoot, diffFiles, {
|
|
1568
1843
|
session,
|