@neurcode-ai/cli 0.20.0 → 0.20.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/LICENSE +201 -0
- package/dist/commands/brain.d.ts.map +1 -1
- package/dist/commands/brain.js +63 -26
- package/dist/commands/brain.js.map +1 -1
- package/dist/commands/runtime-doctor.d.ts.map +1 -1
- package/dist/commands/runtime-doctor.js +17 -0
- package/dist/commands/runtime-doctor.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 +146 -10
- package/dist/commands/session-hook.js.map +1 -1
- package/dist/commands/session.d.ts +4 -2
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +22 -4
- package/dist/commands/session.js.map +1 -1
- package/dist/index.js +60 -9
- package/dist/index.js.map +1 -1
- package/dist/runtime-build.json +5 -5
- 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 +25 -6
- package/dist/utils/brain-lifecycle.d.ts.map +1 -1
- package/dist/utils/brain-lifecycle.js +305 -60
- package/dist/utils/brain-lifecycle.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/enterprise-eval-report.d.ts +2 -0
- package/dist/utils/enterprise-eval-report.d.ts.map +1 -1
- package/dist/utils/enterprise-eval-report.js.map +1 -1
- package/dist/utils/eval-demo.d.ts.map +1 -1
- package/dist/utils/eval-demo.js +16 -3
- package/dist/utils/eval-demo.js.map +1 -1
- package/dist/utils/guided-eval.d.ts +14 -0
- package/dist/utils/guided-eval.d.ts.map +1 -1
- package/dist/utils/guided-eval.js +84 -1
- package/dist/utils/guided-eval.js.map +1 -1
- package/dist/utils/operator-identity.d.ts +16 -0
- package/dist/utils/operator-identity.d.ts.map +1 -0
- package/dist/utils/operator-identity.js +37 -0
- package/dist/utils/operator-identity.js.map +1 -0
- package/dist/utils/runtime-companion.d.ts +2 -0
- package/dist/utils/runtime-companion.d.ts.map +1 -1
- package/dist/utils/runtime-companion.js +8 -1
- 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 +17 -7
- 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 +40 -0
- package/dist/utils/runtime-outbox.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.map +1 -1
- package/dist/utils/v0-governance.js +81 -11
- package/dist/utils/v0-governance.js.map +1 -1
- package/package.json +10 -9
|
@@ -1,151 +1,220 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime state guardrails.
|
|
4
|
-
*
|
|
5
|
-
* Detects the operational state of a project root and produces structured
|
|
6
|
-
* "what's next" guidance when a command would otherwise fail with a raw
|
|
7
|
-
* runtime / git / filesystem error.
|
|
8
|
-
*
|
|
9
|
-
* Pure, deterministic, no network. Read-only. No mutations to .neurcode/
|
|
10
|
-
* or any other on-disk state.
|
|
11
|
-
*
|
|
12
|
-
* Aesthetic discipline: subtle sophistication, no terminal theatrics.
|
|
13
|
-
* Aligned with the operational-experience refabrication phase
|
|
14
|
-
* (docs/ux/final-operational-experience-report.md).
|
|
15
|
-
*/
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.classifyRuntimeState = classifyRuntimeState;
|
|
20
4
|
exports.detectRuntimeState = detectRuntimeState;
|
|
21
5
|
exports.renderRuntimeStateGuidance = renderRuntimeStateGuidance;
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
6
|
+
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const governance_runtime_1 = require("@neurcode-ai/governance-runtime");
|
|
10
|
+
const cli_runtime_1 = require("@neurcode-ai/cli-runtime");
|
|
11
|
+
const v0_governance_1 = require("./v0-governance");
|
|
12
|
+
const session_start_transaction_1 = require("./session-start-transaction");
|
|
13
|
+
function activePointer(repoRoot) {
|
|
14
|
+
const path = (0, node_path_1.join)(repoRoot, '.neurcode', 'active-session.json');
|
|
15
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
16
|
+
return { present: false, sessionId: null, readable: true };
|
|
28
17
|
try {
|
|
29
|
-
|
|
18
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
|
|
19
|
+
return {
|
|
20
|
+
present: true,
|
|
21
|
+
sessionId: typeof parsed.sessionId === 'string' && parsed.sessionId ? parsed.sessionId : null,
|
|
22
|
+
readable: parsed.sessionId === null || typeof parsed.sessionId === 'string',
|
|
23
|
+
};
|
|
30
24
|
}
|
|
31
25
|
catch {
|
|
32
|
-
return null;
|
|
26
|
+
return { present: true, sessionId: null, readable: false };
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
function hooksOrAdapterInstalled(repoRoot) {
|
|
30
|
+
return [
|
|
31
|
+
'.claude/settings.json',
|
|
32
|
+
'.claude/settings.local.json',
|
|
33
|
+
'.github/hooks/neurcode.json',
|
|
34
|
+
'.cursor/mcp.json',
|
|
35
|
+
'.vscode/settings.json',
|
|
36
|
+
].some((path) => (0, node_fs_1.existsSync)((0, node_path_1.join)(repoRoot, path)));
|
|
37
|
+
}
|
|
38
|
+
function hasSessionRecords(repoRoot) {
|
|
39
|
+
try {
|
|
40
|
+
const directory = (0, governance_runtime_1.sessionsDir)(repoRoot);
|
|
41
|
+
return (0, node_fs_1.existsSync)(directory) && (0, node_fs_1.readdirSync)(directory).some((entry) => entry.endsWith('.json'));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function sensitiveCounts(profile) {
|
|
48
|
+
const counts = {};
|
|
49
|
+
for (const boundary of profile?.sensitiveBoundaries ?? []) {
|
|
50
|
+
counts[boundary.tag] = (counts[boundary.tag] ?? 0) + 1;
|
|
51
|
+
}
|
|
52
|
+
return counts;
|
|
53
|
+
}
|
|
54
|
+
function recoveryCommand(state) {
|
|
55
|
+
if (state === 'not_installed')
|
|
56
|
+
return 'neurcode activate claude';
|
|
57
|
+
if (state === 'installed_not_activated')
|
|
58
|
+
return 'neurcode run claude --goal "Governed goal: describe the intended change"';
|
|
59
|
+
if (state === 'active_compatible_session')
|
|
60
|
+
return 'neurcode session status --local --json';
|
|
61
|
+
if (state === 'session_starting')
|
|
62
|
+
return 'neurcode session status --local --json';
|
|
63
|
+
if (state === 'session_start_failed')
|
|
64
|
+
return 'neurcode doctor --runtime --json';
|
|
65
|
+
if (state === 'stale_or_incompatible_session')
|
|
66
|
+
return 'neurcode session reset-stale --force --json';
|
|
67
|
+
if (state === 'enforcement_paused')
|
|
68
|
+
return 'neurcode cursor mode advisory --json';
|
|
69
|
+
return 'neurcode runtime repair';
|
|
70
|
+
}
|
|
71
|
+
function classifyRuntimeState(repoRootInput) {
|
|
72
|
+
const repoRoot = (0, v0_governance_1.resolveRepoRoot)(repoRootInput);
|
|
73
|
+
const pointer = activePointer(repoRoot);
|
|
74
|
+
const profileRead = (0, v0_governance_1.readGovernanceProfile)(repoRoot);
|
|
75
|
+
const profile = profileRead.profile;
|
|
76
|
+
const profilePresent = (0, node_fs_1.existsSync)((0, v0_governance_1.profilePath)(repoRoot));
|
|
77
|
+
const manifestPresent = (0, node_fs_1.existsSync)((0, cli_runtime_1.runtimeManifestPath)(repoRoot));
|
|
78
|
+
const manifest = (0, cli_runtime_1.readActivatedRuntimeManifest)(repoRoot);
|
|
79
|
+
const hooksInstalled = hooksOrAdapterInstalled(repoRoot);
|
|
80
|
+
const sessionRecordsPresent = hasSessionRecords(repoRoot);
|
|
81
|
+
const governanceExpected = profilePresent || manifestPresent || pointer.present || sessionRecordsPresent;
|
|
82
|
+
const starting = (0, session_start_transaction_1.inspectSessionStartTransaction)(repoRoot);
|
|
83
|
+
const activeSession = pointer.sessionId ? (0, governance_runtime_1.loadSession)(repoRoot, pointer.sessionId) : null;
|
|
84
|
+
const compatible = activeSession && profile
|
|
85
|
+
? activeSession.profileHash === profile.profileHash
|
|
86
|
+
: activeSession ? null : null;
|
|
87
|
+
let state;
|
|
88
|
+
const reasons = [];
|
|
89
|
+
if (profile?.runtimeConfig.localMode === 'paused') {
|
|
90
|
+
state = 'enforcement_paused';
|
|
91
|
+
reasons.push('intentional_local_pause');
|
|
92
|
+
}
|
|
93
|
+
else if (starting?.ownerState === 'alive_same') {
|
|
94
|
+
state = 'session_starting';
|
|
95
|
+
reasons.push(`session_start_phase:${starting.phase}`);
|
|
96
|
+
}
|
|
97
|
+
else if (starting) {
|
|
98
|
+
state = 'session_start_failed';
|
|
99
|
+
reasons.push(`session_start_owner:${starting.ownerState}`);
|
|
100
|
+
reasons.push(`session_start_phase:${starting.phase}`);
|
|
101
|
+
}
|
|
102
|
+
else if ((profilePresent && !profile) || (manifestPresent && !manifest) || !pointer.readable) {
|
|
103
|
+
state = 'runtime_unavailable';
|
|
104
|
+
if (profilePresent && !profile)
|
|
105
|
+
reasons.push('profile_unreadable');
|
|
106
|
+
if (manifestPresent && !manifest)
|
|
107
|
+
reasons.push('runtime_manifest_unreadable_or_incompatible');
|
|
108
|
+
if (!pointer.readable)
|
|
109
|
+
reasons.push('active_pointer_unreadable');
|
|
110
|
+
}
|
|
111
|
+
else if (pointer.sessionId && (!activeSession || compatible === false)) {
|
|
112
|
+
state = 'stale_or_incompatible_session';
|
|
113
|
+
reasons.push(!activeSession ? 'active_session_record_missing' : 'session_profile_incompatible');
|
|
114
|
+
}
|
|
115
|
+
else if (activeSession && compatible === true && activeSession.status === 'active') {
|
|
116
|
+
state = 'active_compatible_session';
|
|
117
|
+
reasons.push('active_session_profile_compatible');
|
|
118
|
+
}
|
|
119
|
+
else if (!governanceExpected && !hooksInstalled) {
|
|
120
|
+
state = 'not_installed';
|
|
121
|
+
reasons.push('runtime_artifacts_absent');
|
|
122
|
+
}
|
|
123
|
+
else if (!governanceExpected && hooksInstalled) {
|
|
124
|
+
state = 'installed_not_activated';
|
|
125
|
+
reasons.push('adapter_installed_without_governance_state');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
state = 'session_start_failed';
|
|
129
|
+
reasons.push('governance_expected_without_active_session');
|
|
130
|
+
}
|
|
131
|
+
const configuredBoundaryCount = profile
|
|
132
|
+
? profile.runtimeConfig.approvalRequiredGlobs.length
|
|
133
|
+
+ profile.runtimeConfig.sensitiveGlobs.length
|
|
134
|
+
+ profile.runtimeConfig.safeSupportGlobs.length
|
|
135
|
+
: 0;
|
|
136
|
+
return {
|
|
137
|
+
schemaVersion: governance_runtime_1.RUNTIME_STATE_SCHEMA_VERSION,
|
|
138
|
+
state,
|
|
139
|
+
governanceExpected,
|
|
140
|
+
protectedPathsFailClosed: governanceExpected
|
|
141
|
+
&& state !== 'enforcement_paused'
|
|
142
|
+
&& state !== 'active_compatible_session',
|
|
143
|
+
recoveryCommand: recoveryCommand(state),
|
|
144
|
+
evidence: {
|
|
145
|
+
metadataOnly: true,
|
|
146
|
+
hooksOrAdapterInstalled: hooksInstalled,
|
|
147
|
+
runtimeManifestPresent: manifestPresent,
|
|
148
|
+
profilePresent,
|
|
149
|
+
profileReadable: !profilePresent || Boolean(profile),
|
|
150
|
+
activePointerPresent: pointer.present,
|
|
151
|
+
activeSessionPresent: Boolean(activeSession),
|
|
152
|
+
sessionProfileCompatible: compatible,
|
|
153
|
+
trackedFileCount: profile?.topology.trackedFileCount ?? null,
|
|
154
|
+
ownershipBoundaryCount: profile?.ownershipBoundaries.length ?? 0,
|
|
155
|
+
approvalBoundaryCount: profile?.approvalRequiredPaths.length ?? 0,
|
|
156
|
+
sensitiveBoundaryCounts: sensitiveCounts(profile),
|
|
157
|
+
configuredBoundaryCount,
|
|
158
|
+
reasonCodes: reasons,
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function detectRuntimeState(repoRootInput) {
|
|
163
|
+
const repoRoot = (0, v0_governance_1.resolveRepoRoot)(repoRootInput);
|
|
164
|
+
const gitProbe = (0, node_child_process_1.spawnSync)('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
165
|
+
cwd: repoRoot,
|
|
166
|
+
encoding: 'utf8',
|
|
167
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
168
|
+
timeout: 2_000,
|
|
169
|
+
});
|
|
170
|
+
const isGitRepo = gitProbe.status === 0 && String(gitProbe.stdout).trim() === 'true';
|
|
171
|
+
const headProbe = isGitRepo
|
|
172
|
+
? (0, node_child_process_1.spawnSync)('git', ['rev-parse', '--verify', 'HEAD'], {
|
|
173
|
+
cwd: repoRoot,
|
|
174
|
+
encoding: 'utf8',
|
|
175
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
176
|
+
timeout: 2_000,
|
|
177
|
+
})
|
|
178
|
+
: null;
|
|
44
179
|
return {
|
|
45
|
-
projectRoot: root,
|
|
46
180
|
isGitRepo,
|
|
47
|
-
hasHeadCommit,
|
|
48
|
-
hasNeurcodeDir,
|
|
49
|
-
hasIntentPack,
|
|
50
|
-
|
|
181
|
+
hasHeadCommit: headProbe?.status === 0,
|
|
182
|
+
hasNeurcodeDir: (0, node_fs_1.existsSync)((0, node_path_1.join)(repoRoot, '.neurcode')),
|
|
183
|
+
hasIntentPack: (0, node_fs_1.existsSync)((0, node_path_1.join)(repoRoot, '.neurcode', 'intent-pack.json'))
|
|
184
|
+
|| (0, node_fs_1.existsSync)((0, node_path_1.join)(repoRoot, '.neurcode', 'intent.json')),
|
|
185
|
+
hasLastVerifyOutput: (0, node_fs_1.existsSync)((0, node_path_1.join)(repoRoot, '.neurcode', 'last-verify-output.json')),
|
|
186
|
+
enforcement: classifyRuntimeState(repoRoot),
|
|
51
187
|
};
|
|
52
188
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Render an operational-guidance panel when a command cannot run because
|
|
55
|
-
* a prerequisite is not met. Same aesthetic as the welcome banner + the
|
|
56
|
-
* `neurcode home` panels: subtle, structured, no theatrics.
|
|
57
|
-
*
|
|
58
|
-
* The panel writes to stderr (so JSON-mode callers piping stdout get clean
|
|
59
|
-
* JSON or no output) and returns the exit code the caller should propagate.
|
|
60
|
-
*/
|
|
61
189
|
function renderRuntimeStateGuidance(issue, state, options = {}) {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
print(` ${chalk_1.default.bold('Recommended next step')}`);
|
|
91
|
-
print(chalk_1.default.cyan(' git add . && git commit -m "chore: baseline"'));
|
|
92
|
-
print(chalk_1.default.dim(' Then re-run verify; the working-tree diff will resolve cleanly.'));
|
|
93
|
-
print('');
|
|
94
|
-
break;
|
|
95
|
-
case 'no-neurcode-dir':
|
|
96
|
-
print(` ${chalk_1.default.bold('Issue')} no .neurcode/ directory in the project root`);
|
|
97
|
-
print(` ${chalk_1.default.bold('Path')} ${chalk_1.default.dim(state.projectRoot)}`);
|
|
98
|
-
print('');
|
|
99
|
-
print(` ${chalk_1.default.bold('Why this matters')}`);
|
|
100
|
-
print(chalk_1.default.dim(' Neurcode reads its governance state from .neurcode/ — the intent'));
|
|
101
|
-
print(chalk_1.default.dim(' contract, evidence artefacts, control-plane snapshots, and replay'));
|
|
102
|
-
print(chalk_1.default.dim(' state all live there. Without it, verify has no contract to enforce.'));
|
|
103
|
-
print('');
|
|
104
|
-
print(` ${chalk_1.default.bold('Recommended next step')}`);
|
|
105
|
-
print(chalk_1.default.cyan(' neurcode start') + chalk_1.default.dim(' "what you intend to change"'));
|
|
106
|
-
print(chalk_1.default.dim(' This declares the intent contract and initialises .neurcode/.'));
|
|
107
|
-
print('');
|
|
108
|
-
break;
|
|
109
|
-
case 'no-intent-pack':
|
|
110
|
-
print(` ${chalk_1.default.bold('Issue')} no intent contract on disk`);
|
|
111
|
-
print(` ${chalk_1.default.bold('Path')} ${chalk_1.default.dim(state.projectRoot)}/.neurcode/intent-pack.json`);
|
|
112
|
-
print('');
|
|
113
|
-
print(` ${chalk_1.default.bold('Why this matters')}`);
|
|
114
|
-
print(chalk_1.default.dim(' Neurcode is intent-first. Verify needs a declared intent contract'));
|
|
115
|
-
print(chalk_1.default.dim(' to know what scope to govern. Without it, runtime falls back to'));
|
|
116
|
-
print(chalk_1.default.dim(' structural rules only — the dominant value of the runtime (scope'));
|
|
117
|
-
print(chalk_1.default.dim(' guard, forbidden-boundary enforcement, import-edge governance) is'));
|
|
118
|
-
print(chalk_1.default.dim(' inactive.'));
|
|
119
|
-
print('');
|
|
120
|
-
print(` ${chalk_1.default.bold('Recommended next step')}`);
|
|
121
|
-
print(chalk_1.default.cyan(' neurcode start') + chalk_1.default.dim(' "what you intend to change"'));
|
|
122
|
-
print('');
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
print(chalk_1.default.dim(' See: ') + chalk_1.default.cyan('neurcode home') + chalk_1.default.dim(' for the current runtime state.'));
|
|
126
|
-
print('');
|
|
190
|
+
const commandLabel = options.commandLabel || 'this command';
|
|
191
|
+
const guidance = {
|
|
192
|
+
'not-a-git-repo': {
|
|
193
|
+
message: `${commandLabel} requires a Git repository.`,
|
|
194
|
+
recovery: 'git init',
|
|
195
|
+
},
|
|
196
|
+
'no-head-commit': {
|
|
197
|
+
message: `${commandLabel} requires an initial Git commit before HEAD-based analysis.`,
|
|
198
|
+
recovery: 'git add -A && git commit -m "Initial commit"',
|
|
199
|
+
},
|
|
200
|
+
'no-neurcode-dir': {
|
|
201
|
+
message: `${commandLabel} requires initialized Neurcode state.`,
|
|
202
|
+
recovery: state.enforcement.recoveryCommand,
|
|
203
|
+
},
|
|
204
|
+
'no-intent-pack': {
|
|
205
|
+
message: `${commandLabel} requires a captured intent/plan artifact.`,
|
|
206
|
+
recovery: 'neurcode plan --help',
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
const selected = guidance[issue];
|
|
210
|
+
process.stderr.write([
|
|
211
|
+
'',
|
|
212
|
+
'Neurcode needs attention',
|
|
213
|
+
selected.message,
|
|
214
|
+
`Runtime state: ${state.enforcement.state}`,
|
|
215
|
+
`Run exactly: ${selected.recovery}`,
|
|
216
|
+
'',
|
|
217
|
+
].join('\n'));
|
|
127
218
|
return 2;
|
|
128
219
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Convenience: detect state + render guidance + return the exit code for
|
|
131
|
-
* the FIRST unsatisfied prerequisite (in lifecycle order). Returns null if
|
|
132
|
-
* all required prerequisites are satisfied.
|
|
133
|
-
*/
|
|
134
|
-
function guardRequired(projectRoot, required, options = {}) {
|
|
135
|
-
const state = detectRuntimeState(projectRoot);
|
|
136
|
-
const checks = [
|
|
137
|
-
['not-a-git-repo', !state.isGitRepo],
|
|
138
|
-
['no-head-commit', state.isGitRepo && !state.hasHeadCommit],
|
|
139
|
-
['no-neurcode-dir', !state.hasNeurcodeDir],
|
|
140
|
-
['no-intent-pack', !state.hasIntentPack],
|
|
141
|
-
];
|
|
142
|
-
for (const [issue, failed] of checks) {
|
|
143
|
-
if (!required.includes(issue))
|
|
144
|
-
continue;
|
|
145
|
-
if (!failed)
|
|
146
|
-
continue;
|
|
147
|
-
return renderRuntimeStateGuidance(issue, state, options);
|
|
148
|
-
}
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
220
|
//# sourceMappingURL=runtime-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-state.js","sourceRoot":"","sources":["../../src/utils/runtime-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-state.js","sourceRoot":"","sources":["../../src/utils/runtime-state.ts"],"names":[],"mappings":";;AA2EA,oDAkFC;AAiBD,gDA2BC;AAED,gEAoCC;AA/OD,2DAA+C;AAC/C,qCAAgE;AAChE,yCAAiC;AACjC,wEAOyC;AACzC,0DAGkC;AAClC,mDAIyB;AACzB,2EAA6E;AAE7E,SAAS,aAAa,CAAC,QAAgB;IACrC,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,QAAQ,EAAE,WAAW,EAAE,qBAAqB,CAAC,CAAC;IAChE,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAClF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,IAAI,EAAE,MAA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AAE;YAChB,OAAO,EAAE,GAAG,YAAY,6BAA6B;YACrD,QAAQ,EAAE,UAAU;SACrB;QACD,gBAAgB,EAAE;YAChB,OAAO,EAAE,GAAG,YAAY,6DAA6D;YACrF,QAAQ,EAAE,8CAA8C;SACzD;QACD,iBAAiB,EAAE;YACjB,OAAO,EAAE,GAAG,YAAY,uCAAuC;YAC/D,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,eAAe;SAC5C;QACD,gBAAgB,EAAE;YAChB,OAAO,EAAE,GAAG,YAAY,4CAA4C;YACpE,QAAQ,EAAE,sBAAsB;SACjC;KACF,CAAC;IACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB;QACE,EAAE;QACF,0BAA0B;QAC1B,QAAQ,CAAC,OAAO;QAChB,kBAAkB,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;QAC3C,gBAAgB,QAAQ,CAAC,QAAQ,EAAE;QACnC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { inspectOwnedProcess } from '@neurcode-ai/brain';
|
|
2
|
+
export declare const SESSION_START_TRANSACTION_SCHEMA_VERSION: "neurcode.session-start-transaction.v1";
|
|
3
|
+
export type SessionStartPhase = 'initializing_runtime' | 'fingerprinting_profile' | 'persisting_deferred_session' | 'shaping_session' | 'activating_session' | 'reconciling_cloud';
|
|
4
|
+
interface SessionStartTransaction {
|
|
5
|
+
schemaVersion: typeof SESSION_START_TRANSACTION_SCHEMA_VERSION;
|
|
6
|
+
commandKey: string;
|
|
7
|
+
jobId: string;
|
|
8
|
+
pid: number;
|
|
9
|
+
processStartFingerprint: string | null;
|
|
10
|
+
startedAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
phase: SessionStartPhase;
|
|
13
|
+
sessionId: string | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function beginSessionStartTransaction(repoRoot: string, commandKey: string): SessionStartTransaction;
|
|
16
|
+
export declare function updateSessionStartTransaction(repoRoot: string, update: {
|
|
17
|
+
phase: SessionStartPhase;
|
|
18
|
+
sessionId?: string | null;
|
|
19
|
+
}): SessionStartTransaction | null;
|
|
20
|
+
export declare function clearSessionStartTransaction(repoRoot: string): void;
|
|
21
|
+
export declare function inspectSessionStartTransaction(repoRoot: string): {
|
|
22
|
+
phase: SessionStartPhase;
|
|
23
|
+
sessionId: string | null;
|
|
24
|
+
ownerState: ReturnType<typeof inspectOwnedProcess>;
|
|
25
|
+
} | null;
|
|
26
|
+
export declare function recoverTimedOutSessionStart(repoRoot: string, childPid: number): {
|
|
27
|
+
recovered: boolean;
|
|
28
|
+
phase: SessionStartPhase | null;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=session-start-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-start-transaction.d.ts","sourceRoot":"","sources":["../../src/utils/session-start-transaction.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,oBAAoB,CAAC;AAGlF,eAAO,MAAM,wCAAwC,EAAG,uCAAgD,CAAC;AAEzG,MAAM,MAAM,iBAAiB,GACzB,sBAAsB,GACtB,wBAAwB,GACxB,6BAA6B,GAC7B,iBAAiB,GACjB,oBAAoB,GACpB,mBAAmB,CAAC;AAExB,UAAU,uBAAuB;IAC/B,aAAa,EAAE,OAAO,wCAAwC,CAAC;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAA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