@evomap/evolver-cli 2.0.0-beta.0 → 2.0.0-beta.10
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/antiGeneBenchmark.js +12 -0
- package/dist/antiGeneEvidence.d.ts +15 -0
- package/dist/antiGeneEvidence.js +49 -0
- package/dist/antiGeneRollout.d.ts +3 -1
- package/dist/antiGeneRollout.js +16 -2
- package/dist/assetHealth.d.ts +6 -0
- package/dist/assetHealth.js +105 -0
- package/dist/assetSidecarRecovery.d.ts +14 -0
- package/dist/assetSidecarRecovery.js +171 -0
- package/dist/assetTrust.d.ts +24 -0
- package/dist/assetTrust.js +218 -0
- package/dist/atp.js +4 -2
- package/dist/autoDistillLlm.d.ts +6 -0
- package/dist/autoDistillLlm.js +44 -7
- package/dist/autoexec.d.ts +14 -12
- package/dist/autoexec.js +84 -34
- package/dist/autoexecConfig.d.ts +10 -0
- package/dist/autoexecConfig.js +68 -0
- package/dist/cli.js +12 -5
- package/dist/cliContracts.js +30 -3
- package/dist/cliLifecycle.d.ts +7 -0
- package/dist/cliLifecycle.js +9 -0
- package/dist/cycleConsumer.d.ts +61 -1
- package/dist/cycleConsumer.js +551 -16
- package/dist/dashboard.d.ts +33 -0
- package/dist/dashboard.js +352 -0
- package/dist/dispatch.d.ts +10 -1
- package/dist/dispatch.js +40 -2
- package/dist/distillAdmission.d.ts +13 -0
- package/dist/distillAdmission.js +35 -0
- package/dist/distillObserver.js +6 -8
- package/dist/distillPrimitives.d.ts +9 -7
- package/dist/distillPrimitives.js +65 -12
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.js +49 -3
- package/dist/index.d.ts +8 -2
- package/dist/index.js +350 -42
- package/dist/issueReport.d.ts +7 -0
- package/dist/issueReport.js +291 -0
- package/dist/lifecycle.d.ts +19 -1
- package/dist/lifecycle.js +226 -29
- package/dist/localMemoryGraph.d.ts +97 -0
- package/dist/localMemoryGraph.js +889 -0
- package/dist/login.d.ts +20 -4
- package/dist/login.js +58 -8
- package/dist/materialPackage.d.ts +52 -0
- package/dist/materialPackage.js +401 -0
- package/dist/materialSnapshot.d.ts +54 -0
- package/dist/materialSnapshot.js +370 -0
- package/dist/memoryEventMirror.d.ts +23 -0
- package/dist/memoryEventMirror.js +140 -0
- package/dist/migrate/fieldMap.js +25 -0
- package/dist/migrate/v1Import.d.ts +7 -1
- package/dist/migrate/v1Import.js +132 -11
- package/dist/nonGitWorkspaceNotice.d.ts +24 -0
- package/dist/nonGitWorkspaceNotice.js +122 -0
- package/dist/proxyToken.d.ts +10 -0
- package/dist/proxyToken.js +80 -0
- package/dist/recipe.d.ts +12 -2
- package/dist/recipe.js +381 -8
- package/dist/reuse.d.ts +5 -3
- package/dist/reuse.js +74 -6
- package/dist/reuseReport.js +16 -16
- package/dist/runtimeCapabilities.d.ts +18 -0
- package/dist/runtimeCapabilities.js +81 -0
- package/dist/runtimeSessionSource.d.ts +10 -0
- package/dist/runtimeSessionSource.js +32 -5
- package/dist/setupHooks.d.ts +11 -1
- package/dist/setupHooks.js +235 -16
- package/dist/skill2gep.d.ts +38 -9
- package/dist/skill2gep.js +147 -14
- package/dist/skillDistill.d.ts +1 -0
- package/dist/skillDistill.js +4 -4
- package/dist/skillFetch.d.ts +18 -0
- package/dist/skillFetch.js +391 -0
- package/dist/solo/mode.js +5 -0
- package/dist/sync.d.ts +38 -0
- package/dist/sync.js +1981 -0
- package/dist/trajectoryExport.js +23 -12
- package/dist/v1Compat.d.ts +24 -0
- package/dist/v1Compat.js +249 -0
- package/dist/version.js +2 -0
- package/dist/workflow.d.ts +39 -0
- package/dist/workflow.js +386 -0
- package/dist/workflowRuntime.d.ts +66 -0
- package/dist/workflowRuntime.js +631 -0
- package/package.json +12 -6
package/dist/reuseReport.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// `--anti-gene` is the read-only operator view for #326: it surfaces local AntiGene assets, review state, shadow
|
|
17
17
|
// observations, and whether approved warnings have actually appeared in selection decisions.
|
|
18
18
|
import { events, ops, assetstore, algo } from '@evomap/evolver-core';
|
|
19
|
+
import { formatAntiGeneEvidenceAction, formatAntiGeneEvidenceSummary, summarizeAntiGeneEvidence } from './antiGeneEvidence.js';
|
|
19
20
|
function parseFlags(argv) {
|
|
20
21
|
let quarantine = false, promote = false, antiGene = false, minNegative = 3, minUnsafe = 1;
|
|
21
22
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -70,7 +71,7 @@ async function reportProbation(deps, log) {
|
|
|
70
71
|
return 0;
|
|
71
72
|
}
|
|
72
73
|
function reviewState(review, assetId) {
|
|
73
|
-
return reviewRecord(review, assetId)?.state ?? '
|
|
74
|
+
return reviewRecord(review, assetId)?.state ?? 'unreviewed';
|
|
74
75
|
}
|
|
75
76
|
function reviewRecord(review, assetId) {
|
|
76
77
|
return review?.get?.(assetId) ?? null;
|
|
@@ -81,12 +82,6 @@ function stringArray(value) {
|
|
|
81
82
|
function optionalString(value) {
|
|
82
83
|
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
83
84
|
}
|
|
84
|
-
function countLabel(value) {
|
|
85
|
-
return Array.isArray(value) ? String(value.length) : '0';
|
|
86
|
-
}
|
|
87
|
-
function numberLabel(value) {
|
|
88
|
-
return typeof value === 'number' && Number.isFinite(value) ? String(value) : '-';
|
|
89
|
-
}
|
|
90
85
|
function reviewAuditLabel(record) {
|
|
91
86
|
if (!record)
|
|
92
87
|
return '';
|
|
@@ -146,26 +141,31 @@ async function reportAntiGenes(deps, log) {
|
|
|
146
141
|
log('anti-gene: no AntiGene assets or shadow observations recorded yet.');
|
|
147
142
|
return 0;
|
|
148
143
|
}
|
|
149
|
-
const counts = { approved: 0, quarantined: 0, rejected: 0 };
|
|
144
|
+
const counts = { approved: 0, quarantined: 0, rejected: 0, unreviewed: 0 };
|
|
150
145
|
for (const asset of assets)
|
|
151
146
|
counts[reviewState(review, String(asset.asset_id))] += 1;
|
|
152
|
-
log(`anti-gene: ${assets.length} stored asset(s); review approved=${counts.approved} quarantined=${counts.quarantined} rejected=${counts.rejected}; shadow candidate=${shadowCandidates.length} declined=${shadowDeclines.length}`);
|
|
147
|
+
log(`anti-gene: ${assets.length} stored asset(s); review approved=${counts.approved} quarantined=${counts.quarantined} rejected=${counts.rejected} unreviewed=${counts.unreviewed}; shadow candidate=${shadowCandidates.length} declined=${shadowDeclines.length}`);
|
|
153
148
|
for (const asset of assets) {
|
|
154
149
|
const assetId = String(asset.asset_id);
|
|
155
150
|
const id = typeof asset['id'] === 'string' ? String(asset['id']) : assetId;
|
|
156
151
|
const record = reviewRecord(review, assetId);
|
|
157
|
-
const state = record?.state ?? '
|
|
152
|
+
const state = record?.state ?? 'unreviewed';
|
|
158
153
|
const severity = optionalString(asset['severity']) ?? '-';
|
|
159
154
|
const trigger = stringArray(asset['trigger']).slice(0, 6).join(',');
|
|
160
155
|
const avoid = stringArray(asset['avoid']).slice(0, 2).join(' | ');
|
|
161
|
-
const evidence = `failures=${numberLabel(asset['failure_count'])} clusters=${countLabel(asset['source_clusters'])} evidence=${countLabel(asset['evidence_capsules'])}`;
|
|
162
156
|
const audit = reviewAuditLabel(record);
|
|
163
157
|
const injected = (injectedCounts.get(id) ?? 0) + (id === assetId ? 0 : injectedCounts.get(assetId) ?? 0);
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
158
|
+
const evidenceSummary = summarizeAntiGeneEvidence(asset, injected);
|
|
159
|
+
const evidence = `${formatAntiGeneEvidenceSummary(evidenceSummary)} ${formatAntiGeneEvidenceAction(evidenceSummary, state)}`;
|
|
160
|
+
const next = state === 'unreviewed' && injected > 0
|
|
161
|
+
? `observed historically in ${injected} decision(s); explicit approval required`
|
|
162
|
+
: state === 'quarantined' || state === 'unreviewed'
|
|
163
|
+
? evidenceSummary.strength === 'weak'
|
|
164
|
+
? `reject/defer, or approve with evolver review --approve ${id} --allow-weak-evidence before warning injection`
|
|
165
|
+
: 'approve with evolver review --approve before warning injection'
|
|
166
|
+
: state === 'approved'
|
|
167
|
+
? (injected > 0 ? `observed in ${injected} decision(s)` : 'approved; waiting for matching selection')
|
|
168
|
+
: 'rejected; withheld from warning injection';
|
|
169
169
|
log(` ${id} {${state}} severity=${severity} trigger=${trigger || '-'} avoid=${avoid || '-'} ${evidence}${audit ? ` ${audit}` : ''} ${next}`);
|
|
170
170
|
}
|
|
171
171
|
if (shadowCandidates.length > 0 || shadowDeclines.length > 0) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type RuntimeCapabilityStatus = 'supported' | 'experimental' | 'unsupported';
|
|
2
|
+
type RuntimeCapabilityId = 'claude-code' | 'codex' | 'cursor' | 'gemini' | 'antigravity' | 'kimi' | 'kiro' | 'opencode' | 'generic-chat';
|
|
3
|
+
interface RuntimeCapability {
|
|
4
|
+
status: RuntimeCapabilityStatus;
|
|
5
|
+
evidence: string;
|
|
6
|
+
}
|
|
7
|
+
interface RuntimeCapabilityEntry {
|
|
8
|
+
runtime: RuntimeCapabilityId;
|
|
9
|
+
ingest: RuntimeCapability;
|
|
10
|
+
inject: RuntimeCapability;
|
|
11
|
+
execute: RuntimeCapability;
|
|
12
|
+
verify: RuntimeCapability;
|
|
13
|
+
resume: RuntimeCapability;
|
|
14
|
+
}
|
|
15
|
+
/** Product-level runtime matrix. A transcript parser never implies execution, verification, or resumability. */
|
|
16
|
+
export declare const RUNTIME_CAPABILITY_MATRIX: Readonly<Record<RuntimeCapabilityId, RuntimeCapabilityEntry>>;
|
|
17
|
+
export declare function runtimeCapabilities(): RuntimeCapabilityEntry[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const supported = (evidence) => ({ status: 'supported', evidence });
|
|
2
|
+
const experimental = (evidence) => ({ status: 'experimental', evidence });
|
|
3
|
+
const unsupported = (evidence) => ({ status: 'unsupported', evidence });
|
|
4
|
+
/** Product-level runtime matrix. A transcript parser never implies execution, verification, or resumability. */
|
|
5
|
+
export const RUNTIME_CAPABILITY_MATRIX = {
|
|
6
|
+
'claude-code': {
|
|
7
|
+
runtime: 'claude-code',
|
|
8
|
+
ingest: supported('normalized Claude Code JSONL adapter'),
|
|
9
|
+
inject: supported('MCP registration plus SessionStart hook'),
|
|
10
|
+
execute: supported('run-verified claude -p runner'),
|
|
11
|
+
verify: supported('git diff proof plus external validation hook'),
|
|
12
|
+
resume: unsupported('cycle runner does not bind ingested session ids to claude resume'),
|
|
13
|
+
},
|
|
14
|
+
codex: {
|
|
15
|
+
runtime: 'codex',
|
|
16
|
+
ingest: supported('normalized Codex rollout adapter'),
|
|
17
|
+
inject: supported('project MCP config plus SessionStart hook'),
|
|
18
|
+
execute: supported('run-verified codex exec runner'),
|
|
19
|
+
verify: supported('git diff proof plus external validation hook'),
|
|
20
|
+
resume: unsupported('cycle runner starts a new codex exec session'),
|
|
21
|
+
},
|
|
22
|
+
cursor: {
|
|
23
|
+
runtime: 'cursor',
|
|
24
|
+
ingest: supported('Cursor transcript and state.vscdb adapters'),
|
|
25
|
+
inject: supported('always-on project rules injection'),
|
|
26
|
+
execute: experimental('CLI flags are contract-tested but the repository still treats the runner as a scaffold'),
|
|
27
|
+
verify: supported('git diff proof plus external validation hook'),
|
|
28
|
+
resume: unsupported('no verified headless session resume mapping'),
|
|
29
|
+
},
|
|
30
|
+
gemini: {
|
|
31
|
+
runtime: 'gemini',
|
|
32
|
+
ingest: supported('normalized Gemini CLI session adapter'),
|
|
33
|
+
inject: unsupported('no Evolver Gemini injection installer'),
|
|
34
|
+
execute: experimental('hermetic Gemini CLI 0.46.0 headless JSON contract exists, but provider-backed live E2E smoke is not complete'),
|
|
35
|
+
verify: experimental('hermetic structured-result and git-diff proof contract exists, but provider-backed live E2E verification is not complete'),
|
|
36
|
+
resume: unsupported('Gemini resume accepts latest/index; ingested UUIDs cannot be mapped reliably'),
|
|
37
|
+
},
|
|
38
|
+
antigravity: {
|
|
39
|
+
runtime: 'antigravity',
|
|
40
|
+
ingest: supported('strict Antigravity transcript adapter'),
|
|
41
|
+
inject: supported('user-level MCP tool discovery only; no SessionStart hook'),
|
|
42
|
+
execute: unsupported('agy is not installed or live-verified in the implementation environment'),
|
|
43
|
+
verify: unsupported('no Antigravity runner result is wired to state proof'),
|
|
44
|
+
resume: unsupported('no verified transcript-id to agy resume contract'),
|
|
45
|
+
},
|
|
46
|
+
kimi: {
|
|
47
|
+
runtime: 'kimi',
|
|
48
|
+
ingest: supported('normalized Kimi session adapter'),
|
|
49
|
+
inject: unsupported('no Evolver Kimi injection installer'),
|
|
50
|
+
execute: unsupported('no verified Kimi runner contract'),
|
|
51
|
+
verify: unsupported('no Kimi execution runner exists'),
|
|
52
|
+
resume: unsupported('no verified Kimi resume contract'),
|
|
53
|
+
},
|
|
54
|
+
kiro: {
|
|
55
|
+
runtime: 'kiro',
|
|
56
|
+
ingest: supported('normalized Kiro session adapter'),
|
|
57
|
+
inject: unsupported('automatic Kiro setup is not available on the current main branch'),
|
|
58
|
+
execute: unsupported('no verified Kiro runner contract'),
|
|
59
|
+
verify: unsupported('no Kiro execution runner exists'),
|
|
60
|
+
resume: unsupported('no verified Kiro resume contract'),
|
|
61
|
+
},
|
|
62
|
+
opencode: {
|
|
63
|
+
runtime: 'opencode',
|
|
64
|
+
ingest: supported('normalized OpenCode session adapter'),
|
|
65
|
+
inject: unsupported('automatic OpenCode setup is not available on the current main branch'),
|
|
66
|
+
execute: unsupported('no verified OpenCode runner contract'),
|
|
67
|
+
verify: unsupported('no OpenCode execution runner exists'),
|
|
68
|
+
resume: unsupported('no verified OpenCode resume contract'),
|
|
69
|
+
},
|
|
70
|
+
'generic-chat': {
|
|
71
|
+
runtime: 'generic-chat',
|
|
72
|
+
ingest: supported('normalized standard OpenAI and Anthropic message JSON/JSONL adapter'),
|
|
73
|
+
inject: unsupported('generic transcript interchange has no Evolver injection installer'),
|
|
74
|
+
execute: unsupported('generic chat transcripts do not identify a runnable provider or CLI contract'),
|
|
75
|
+
verify: unsupported('no provider-backed execution runner exists for generic chat transcripts'),
|
|
76
|
+
resume: unsupported('no provider or session identity contract exists for generic chat transcripts'),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export function runtimeCapabilities() {
|
|
80
|
+
return Object.values(RUNTIME_CAPABILITY_MATRIX);
|
|
81
|
+
}
|
|
@@ -5,5 +5,15 @@ export interface RuntimeSessionSource {
|
|
|
5
5
|
sessionId?: string;
|
|
6
6
|
turns: NormalizedTurn[];
|
|
7
7
|
}
|
|
8
|
+
export interface RuntimeSessionParseDiagnostics {
|
|
9
|
+
rowsScanned: number;
|
|
10
|
+
rowsRead: number;
|
|
11
|
+
invalidJson: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RuntimeSessionParseResult {
|
|
14
|
+
sources: RuntimeSessionSource[];
|
|
15
|
+
diagnostics: RuntimeSessionParseDiagnostics;
|
|
16
|
+
}
|
|
8
17
|
export declare function isRuntimeSessionSourcePath(path: string): boolean;
|
|
18
|
+
export declare function parseRuntimeSessionSourcesWithDiagnostics(path: string, readSource?: (path: string) => string): RuntimeSessionParseResult;
|
|
9
19
|
export declare function parseRuntimeSessionSources(path: string, readSource?: (path: string) => string): RuntimeSessionSource[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { adapterForPath, isCursorStateVscdbPath, parseCursorStateVscdb, } from '@evomap/evolver-runtime-adapters';
|
|
3
|
+
import { adapterForPath, isCursorStateVscdbPath, parseJsonlLinesWithStats, parseCursorStateVscdb, stripUtf8Bom, } from '@evomap/evolver-runtime-adapters';
|
|
4
|
+
const EMPTY_DIAGNOSTICS = { rowsScanned: 0, rowsRead: 0, invalidJson: 0 };
|
|
4
5
|
export function isRuntimeSessionSourcePath(path) {
|
|
5
6
|
return isCursorStateVscdbPath(path) || adapterForPath(path) !== undefined;
|
|
6
7
|
}
|
|
@@ -15,15 +16,41 @@ function cursorSourceFromSession(session, index) {
|
|
|
15
16
|
turns: session.turns,
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
function diagnosticsForRuntimeSource(raw) {
|
|
20
|
+
const trimmed = stripUtf8Bom(raw).trim();
|
|
21
|
+
if (!trimmed)
|
|
22
|
+
return { ...EMPTY_DIAGNOSTICS };
|
|
23
|
+
try {
|
|
24
|
+
JSON.parse(trimmed);
|
|
25
|
+
return { rowsScanned: 1, rowsRead: 1, invalidJson: 0 };
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return parseJsonlLinesWithStats(raw).stats;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource = (p) => readFileSync(p, 'utf8')) {
|
|
19
32
|
const absPath = resolve(path);
|
|
20
33
|
if (isCursorStateVscdbPath(absPath)) {
|
|
21
|
-
|
|
34
|
+
const sources = parseCursorStateVscdb(absPath)
|
|
22
35
|
.map(cursorSourceFromSession)
|
|
23
36
|
.filter((source) => source !== null);
|
|
37
|
+
return { sources, diagnostics: { ...EMPTY_DIAGNOSTICS } };
|
|
24
38
|
}
|
|
25
39
|
const adapter = adapterForPath(absPath);
|
|
26
40
|
if (!adapter)
|
|
27
|
-
return [];
|
|
28
|
-
|
|
41
|
+
return { sources: [], diagnostics: { ...EMPTY_DIAGNOSTICS } };
|
|
42
|
+
const raw = readSource(absPath);
|
|
43
|
+
const sessionId = adapter.sessionIdFromPath?.(absPath)?.trim();
|
|
44
|
+
return {
|
|
45
|
+
sources: [{
|
|
46
|
+
agent: adapter.agent,
|
|
47
|
+
label: sessionId ? `${adapter.agent}:${sessionId}` : adapter.agent,
|
|
48
|
+
...(sessionId ? { sessionId } : {}),
|
|
49
|
+
turns: adapter.parse(raw),
|
|
50
|
+
}],
|
|
51
|
+
diagnostics: diagnosticsForRuntimeSource(raw),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function parseRuntimeSessionSources(path, readSource = (p) => readFileSync(p, 'utf8')) {
|
|
55
|
+
return parseRuntimeSessionSourcesWithDiagnostics(path, readSource).sources;
|
|
29
56
|
}
|
package/dist/setupHooks.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
import { type InstallScope } from '@evomap/evolver-mcp';
|
|
1
2
|
import { assetstore } from '@evomap/evolver-core';
|
|
2
|
-
|
|
3
|
+
import { maybeEmitNonGitWorkspaceNotice } from './nonGitWorkspaceNotice.js';
|
|
4
|
+
interface SetupHooksDeps {
|
|
5
|
+
emitNonGitWorkspaceNotice?: typeof maybeEmitNonGitWorkspaceNotice;
|
|
6
|
+
runtimeAvailable?: (runtime: 'opencode' | 'kiro', configRoot: string, scope: InstallScope) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function commandNamesForPath(command: string, platform: NodeJS.Platform, pathExt: string | undefined): string[];
|
|
9
|
+
export declare function safeSetupOperationError(error: unknown): string;
|
|
10
|
+
export declare function safeSetupResultError(error: unknown): string;
|
|
11
|
+
export declare function runSetupHooks(argv: readonly string[], store?: assetstore.AssetStoreProvider, review?: assetstore.ReviewLedger, deps?: SetupHooksDeps): Promise<number>;
|
|
12
|
+
export {};
|
package/dist/setupHooks.js
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
// (the real device-wide scope); `--scope=project` (default) writes the project's own .mcp.json. Deny-nothing:
|
|
5
5
|
// it only writes the runtime's own config, is idempotent, refuses symlinked adapter paths, and `--uninstall`
|
|
6
6
|
// cleanly removes only evolver's entries.
|
|
7
|
-
import { planInjection, installInjection, uninstallInjection, runtimeSupport, renderManualWiring, renderServiceGuidance, SETUP_RUNTIMES, SERVICE_TARGETS } from '@evomap/evolver-mcp';
|
|
7
|
+
import { planInjection, installInjection, uninstallInjection, runtimeSupport, renderManualWiring, renderServiceGuidance, SETUP_RUNTIMES, SERVICE_TARGETS, kiroConfigRoot, resolveOpenCodeConfig, McpConfigConflictError, McpConfigOwnershipError, McpConfigVerificationError, McpServerValidationError } from '@evomap/evolver-mcp';
|
|
8
8
|
import { assetstore, events } from '@evomap/evolver-core';
|
|
9
|
-
import { readFileSync } from 'node:fs';
|
|
9
|
+
import { accessSync, constants, existsSync, readFileSync, statSync } from 'node:fs';
|
|
10
10
|
import { createRequire } from 'node:module';
|
|
11
|
+
import { homedir } from 'node:os';
|
|
12
|
+
import { delimiter, dirname, isAbsolute, join, relative, sep } from 'node:path';
|
|
11
13
|
import { fileURLToPath } from 'node:url';
|
|
12
14
|
import { currentTopCursorGenes } from './cursorRewrite.js';
|
|
13
15
|
import { resolveProxyBinPath, resolveStableNodePath } from './lifecycle.js';
|
|
14
16
|
import { reviewLedgerForStore } from './reviewFilter.js';
|
|
17
|
+
import { maybeEmitNonGitWorkspaceNotice } from './nonGitWorkspaceNotice.js';
|
|
15
18
|
const requireFromHere = createRequire(import.meta.url);
|
|
16
19
|
function parseFlags(argv) {
|
|
17
20
|
const out = {};
|
|
@@ -33,7 +36,133 @@ function parseFlags(argv) {
|
|
|
33
36
|
}
|
|
34
37
|
return out;
|
|
35
38
|
}
|
|
36
|
-
const USAGE = `usage: evolver setup-hooks [--runtime=${SETUP_RUNTIMES.join('|')}] [--scope=user|project|global] [--root=<dir>] [--env-file=<path>] [--profile-descriptor=<json>] [--service=${SERVICE_TARGETS.join('|')}] [--uninstall] [--force] [--json] [--hook-command="evolver inject session-start"] [--server-command=<cmd>] [--server-args=a,b] [--service-command=<cmd>] [--service-args=a,b]\n`;
|
|
39
|
+
const USAGE = `usage: evolver setup-hooks [--runtime=${SETUP_RUNTIMES.join('|')}] [--scope=user|project|global] [--root=<dir>] [--env-file=<path>] [--profile-descriptor=<json>] [--service=${SERVICE_TARGETS.join('|')}] [--uninstall] [--dry-run] [--force] [--json] [--hook-command="evolver inject session-start"] [--server-command=<cmd>] [--server-args=a,b] [--service-command=<cmd>] [--service-args=a,b]\n`;
|
|
40
|
+
export function commandNamesForPath(command, platform, pathExt) {
|
|
41
|
+
if (platform !== 'win32' || /\.[^\\/]+$/.test(command))
|
|
42
|
+
return [command];
|
|
43
|
+
const extensions = (pathExt?.trim() || '.COM;.EXE;.BAT;.CMD')
|
|
44
|
+
.split(';')
|
|
45
|
+
.map((extension) => extension.trim())
|
|
46
|
+
.filter((extension) => /^\.?[A-Za-z\d]+$/.test(extension))
|
|
47
|
+
.map((extension) => extension.startsWith('.') ? extension : `.${extension}`);
|
|
48
|
+
return [command, ...extensions.map((extension) => `${command}${extension}`)];
|
|
49
|
+
}
|
|
50
|
+
function commandOnPath(command) {
|
|
51
|
+
const names = commandNamesForPath(command, process.platform, process.env['PATHEXT']);
|
|
52
|
+
for (const directory of (process.env['PATH'] ?? '').split(delimiter).filter(Boolean)) {
|
|
53
|
+
for (const name of names) {
|
|
54
|
+
try {
|
|
55
|
+
const candidate = join(directory, name);
|
|
56
|
+
if (!statSync(candidate).isFile())
|
|
57
|
+
continue;
|
|
58
|
+
accessSync(candidate, constants.X_OK);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Continue searching PATH.
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
function defaultRuntimeAvailable(runtime, configRoot, scope) {
|
|
69
|
+
if (runtime === 'opencode') {
|
|
70
|
+
const resolution = resolveOpenCodeConfig({
|
|
71
|
+
configRoot,
|
|
72
|
+
scope,
|
|
73
|
+
homeDir: homedir(),
|
|
74
|
+
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
75
|
+
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
|
76
|
+
opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
|
|
77
|
+
});
|
|
78
|
+
return commandOnPath('opencode') || (resolution.evidencePaths ?? [resolution.configPath]).some(existsSync);
|
|
79
|
+
}
|
|
80
|
+
const pathOptions = {
|
|
81
|
+
configRoot,
|
|
82
|
+
homeDir: homedir(),
|
|
83
|
+
kiroHome: process.env['KIRO_HOME'],
|
|
84
|
+
};
|
|
85
|
+
const evidenceRoots = scope === 'project'
|
|
86
|
+
? [
|
|
87
|
+
kiroConfigRoot({ ...pathOptions, scope: 'project' }),
|
|
88
|
+
kiroConfigRoot({ ...pathOptions, scope: 'user' }),
|
|
89
|
+
]
|
|
90
|
+
: [kiroConfigRoot({ ...pathOptions, scope: 'user' })];
|
|
91
|
+
return commandOnPath('kiro') || commandOnPath('kiro-cli') || evidenceRoots.some(existsSync);
|
|
92
|
+
}
|
|
93
|
+
function displaySetupPath(path, configRoot, scope) {
|
|
94
|
+
if (scope === 'user') {
|
|
95
|
+
const home = homedir();
|
|
96
|
+
const homePath = safeRelativePath(home, path);
|
|
97
|
+
if (homePath === '')
|
|
98
|
+
return '~';
|
|
99
|
+
if (homePath !== undefined)
|
|
100
|
+
return `~/${homePath.replaceAll('\\', '/')}`;
|
|
101
|
+
}
|
|
102
|
+
const projectPath = safeProjectRelativePath(configRoot, path);
|
|
103
|
+
if (projectPath === '')
|
|
104
|
+
return '.';
|
|
105
|
+
return projectPath !== undefined ? projectPath.replaceAll('\\', '/') : '<config-path>';
|
|
106
|
+
}
|
|
107
|
+
function safeRelativePath(root, path) {
|
|
108
|
+
const candidate = relative(root, path);
|
|
109
|
+
if (isAbsolute(candidate) || candidate === '..' || candidate.startsWith(`..${sep}`))
|
|
110
|
+
return undefined;
|
|
111
|
+
return candidate;
|
|
112
|
+
}
|
|
113
|
+
function safeProjectRelativePath(root, path) {
|
|
114
|
+
const descendant = safeRelativePath(root, path);
|
|
115
|
+
if (descendant !== undefined)
|
|
116
|
+
return descendant;
|
|
117
|
+
return safeRelativePath(dirname(path), root) === undefined ? undefined : relative(root, path);
|
|
118
|
+
}
|
|
119
|
+
function displayResultPaths(paths, configRoot, scope) {
|
|
120
|
+
return paths?.map((path) => displaySetupPath(path, configRoot, scope));
|
|
121
|
+
}
|
|
122
|
+
export function safeSetupOperationError(error) {
|
|
123
|
+
if (error instanceof McpConfigConflictError)
|
|
124
|
+
return error.message;
|
|
125
|
+
if (error instanceof McpConfigOwnershipError)
|
|
126
|
+
return error.message;
|
|
127
|
+
if (error instanceof McpConfigVerificationError) {
|
|
128
|
+
return error.restored
|
|
129
|
+
? '[setup-hooks] runtime configuration verification failed; the previous configuration was restored.'
|
|
130
|
+
: '[setup-hooks] runtime configuration verification failed; rollback could not be confirmed. Inspect the runtime config before retrying.';
|
|
131
|
+
}
|
|
132
|
+
if (error instanceof McpServerValidationError)
|
|
133
|
+
return error.message;
|
|
134
|
+
const name = error instanceof Error ? error.name : '';
|
|
135
|
+
switch (name) {
|
|
136
|
+
case 'McpConfigConflictError': return '[setup-hooks] existing Evolver configuration conflicts; use --force to replace only the Evolver entry.';
|
|
137
|
+
case 'McpConfigOwnershipError': return '[setup-hooks] Evolver ownership metadata is ambiguous or no longer matches the runtime configuration; inspect it before retrying.';
|
|
138
|
+
case 'McpConfigShapeError': return '[setup-hooks] runtime configuration has an invalid JSON shape.';
|
|
139
|
+
case 'McpConfigVerificationError': return error.restored === true
|
|
140
|
+
? '[setup-hooks] runtime configuration verification failed; the previous configuration was restored.'
|
|
141
|
+
: '[setup-hooks] runtime configuration verification failed; rollback could not be confirmed. Inspect the runtime config before retrying.';
|
|
142
|
+
case 'McpConfigChangedError': return '[setup-hooks] runtime configuration changed during the operation; retry after the runtime finishes writing it.';
|
|
143
|
+
case 'EmptySharedConfigError': return '[setup-hooks] runtime configuration is empty; repair or remove it before retrying.';
|
|
144
|
+
case 'UnparseableConfigError': return '[setup-hooks] runtime configuration is not valid JSON; repair it before retrying.';
|
|
145
|
+
case 'SymlinkRefusedError': return '[setup-hooks] refused an unsafe symbolic-link configuration path.';
|
|
146
|
+
default: return '[setup-hooks] runtime configuration operation failed.';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export function safeSetupResultError(error) {
|
|
150
|
+
if (typeof error !== 'string')
|
|
151
|
+
return safeSetupOperationError(error);
|
|
152
|
+
const reason = error.replace(/\s+/g, ' ').trim();
|
|
153
|
+
const passive = reason.match(/^passive runtime ([a-z0-9][a-z0-9-]{0,63}): no tool injection$/);
|
|
154
|
+
const unimplementedInstall = reason.match(/^installer not yet implemented for ([a-z0-9][a-z0-9-]{0,63}) \(supported: [a-z0-9, -]+\)$/);
|
|
155
|
+
const unimplementedUninstall = reason.match(/^uninstall not implemented for ([a-z0-9][a-z0-9-]{0,63})$/);
|
|
156
|
+
const runtime = passive?.[1] ?? unimplementedInstall?.[1] ?? unimplementedUninstall?.[1];
|
|
157
|
+
if (!runtime || !SETUP_RUNTIMES.includes(runtime)) {
|
|
158
|
+
return safeSetupOperationError(error);
|
|
159
|
+
}
|
|
160
|
+
if (passive)
|
|
161
|
+
return `[setup-hooks] passive runtime ${runtime}: no tool injection`;
|
|
162
|
+
if (unimplementedInstall)
|
|
163
|
+
return `[setup-hooks] installer not yet implemented for ${runtime}`;
|
|
164
|
+
return `[setup-hooks] uninstall not implemented for ${runtime}`;
|
|
165
|
+
}
|
|
37
166
|
const PROFILE_DESCRIPTOR_FLAG = 'profile-descriptor';
|
|
38
167
|
const SECRET_ASSIGNMENT_RE = /\b(?:A2A_NODE_SECRET|EVOMAP_ENTERPRISE_TOKEN|EVOMAP_PRIVATE_HUB_TOKEN|EVOMAP_NODE_SECRET|EVOLVER_IPC_TOKEN|EVOLVER_LLM_TOKEN|PHUB_ENTERPRISE_TOKEN|PRIVATE_HUB_ENTERPRISE_TOKEN)\b\s*[:=]\s*["']?[^"'\s<]+/;
|
|
39
168
|
const INLINE_BEARER_RE = /\bBearer\s+(?!<|\$|%|REDACTED\b|TOKEN\b|token\b|env:)[A-Za-z0-9._~+/=-]{12,}/i;
|
|
@@ -273,7 +402,7 @@ function appendAdapterNotes(text, hints) {
|
|
|
273
402
|
? `${text}\n\nAdapter notes:\n${hints.map((hint) => ` - ${hint}`).join('\n')}`
|
|
274
403
|
: text;
|
|
275
404
|
}
|
|
276
|
-
export async function runSetupHooks(argv, store, review) {
|
|
405
|
+
export async function runSetupHooks(argv, store, review, deps = {}) {
|
|
277
406
|
const f = parseFlags(argv);
|
|
278
407
|
const runtimeRaw = typeof f['runtime'] === 'string'
|
|
279
408
|
? f['runtime']
|
|
@@ -300,24 +429,62 @@ export async function runSetupHooks(argv, store, review) {
|
|
|
300
429
|
process.stderr.write(`${support.reason}\n${USAGE}`);
|
|
301
430
|
return 1;
|
|
302
431
|
}
|
|
303
|
-
//
|
|
432
|
+
// Installed runtimes have a real config writer + uninstaller (including Antigravity MCP config).
|
|
304
433
|
const runtime = runtimeRaw;
|
|
305
434
|
const configRoot = typeof f['root'] === 'string' ? f['root'] : process.cwd();
|
|
306
435
|
// claude-code: user scope targets ~/.claude.json regardless of --root; project scope uses configRoot.
|
|
307
436
|
const scope = scopeResult.scope;
|
|
437
|
+
if (f['dry-run'] === true && runtime !== 'opencode' && runtime !== 'kiro') {
|
|
438
|
+
const error = `--dry-run is currently supported for opencode and kiro setup only; no config was written.`;
|
|
439
|
+
if (json)
|
|
440
|
+
emit({ runtime, outcome: 'error', files: [], error });
|
|
441
|
+
else
|
|
442
|
+
process.stderr.write(`${error}\n`);
|
|
443
|
+
return 1;
|
|
444
|
+
}
|
|
308
445
|
if (support.outcome === 'installed' && f['uninstall']) {
|
|
309
|
-
|
|
446
|
+
let r;
|
|
447
|
+
try {
|
|
448
|
+
r = uninstallInjection(runtime, {
|
|
449
|
+
configRoot,
|
|
450
|
+
scope,
|
|
451
|
+
homeDir: homedir(),
|
|
452
|
+
kiroHome: process.env['KIRO_HOME'],
|
|
453
|
+
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
454
|
+
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
|
455
|
+
opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
|
|
456
|
+
dryRun: f['dry-run'] === true,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
const message = safeSetupOperationError(error);
|
|
461
|
+
if (json)
|
|
462
|
+
emit({ runtime, action: 'uninstall', files: [], error: message });
|
|
463
|
+
else
|
|
464
|
+
process.stderr.write(`${message}\n`);
|
|
465
|
+
return 1;
|
|
466
|
+
}
|
|
467
|
+
const files = displayResultPaths(r.files, configRoot, scope) ?? [];
|
|
468
|
+
const backups = displayResultPaths(r.backups, configRoot, scope);
|
|
310
469
|
if (!r.ok) {
|
|
470
|
+
const message = safeSetupResultError(r.error);
|
|
311
471
|
if (json)
|
|
312
|
-
emit({ runtime, action: 'uninstall', files: [], error:
|
|
472
|
+
emit({ runtime, action: 'uninstall', files: [], error: message });
|
|
313
473
|
else
|
|
314
|
-
process.stderr.write(`${
|
|
474
|
+
process.stderr.write(`${message}\n`);
|
|
315
475
|
return 1;
|
|
316
476
|
}
|
|
477
|
+
if (r.dryRun) {
|
|
478
|
+
if (json)
|
|
479
|
+
emit({ runtime, action: 'uninstall', files, backups, dryRun: true });
|
|
480
|
+
else
|
|
481
|
+
process.stdout.write(files.length ? `dry-run: would remove evolver from: ${files.join(', ')}\n` : 'dry-run: nothing to remove\n');
|
|
482
|
+
return 0;
|
|
483
|
+
}
|
|
317
484
|
if (json)
|
|
318
|
-
emit({ runtime, action: 'uninstall', files
|
|
485
|
+
emit({ runtime, action: 'uninstall', files, backups });
|
|
319
486
|
else
|
|
320
|
-
process.stdout.write(
|
|
487
|
+
process.stdout.write(files.length ? `removed evolver from: ${files.join(', ')}\n` : 'nothing to remove\n');
|
|
321
488
|
return 0;
|
|
322
489
|
}
|
|
323
490
|
const profileDescriptor = profileDescriptorFromFlag(f);
|
|
@@ -359,6 +526,30 @@ export async function runSetupHooks(argv, store, review) {
|
|
|
359
526
|
return 0;
|
|
360
527
|
}
|
|
361
528
|
const server = buildServer(f, descriptor);
|
|
529
|
+
if ((runtime === 'opencode' || runtime === 'kiro') && f['dry-run'] !== true) {
|
|
530
|
+
let runtimeDetected;
|
|
531
|
+
try {
|
|
532
|
+
runtimeDetected = (deps.runtimeAvailable ?? defaultRuntimeAvailable)(runtime, configRoot, scope);
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
const message = safeSetupOperationError(error);
|
|
536
|
+
if (json)
|
|
537
|
+
emit({ runtime, outcome: 'error', files: [], error: message });
|
|
538
|
+
else
|
|
539
|
+
process.stderr.write(`${message}\n`);
|
|
540
|
+
return 1;
|
|
541
|
+
}
|
|
542
|
+
if (!runtimeDetected) {
|
|
543
|
+
const error = `${runtime} runtime was not detected; install or launch ${runtime === 'opencode' ? 'OpenCode' : 'Kiro'} first, then rerun. No config was written.`;
|
|
544
|
+
if (json)
|
|
545
|
+
emit({ runtime, outcome: 'error', files: [], error });
|
|
546
|
+
else
|
|
547
|
+
process.stderr.write(`${error}\n`);
|
|
548
|
+
return 1;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
if (runtime === 'cursor')
|
|
552
|
+
(deps.emitNonGitWorkspaceNotice ?? maybeEmitNonGitWorkspaceNotice)({ cwd: configRoot });
|
|
362
553
|
// cursor seeds .cursor/rules/evolver.mdc with the CURRENT top REVIEW-APPROVED genes so the file is useful
|
|
363
554
|
// immediately (before the first daemon rewrite) without seeding an unapproved draft (A2a). The renderer thus
|
|
364
555
|
// has a real production caller even without the daemon running.
|
|
@@ -373,6 +564,12 @@ export async function runSetupHooks(argv, store, review) {
|
|
|
373
564
|
...(typeof f['hook-command'] === 'string' ? { hookCommand: f['hook-command'] } : {}),
|
|
374
565
|
...(cursorGenes ? { genes: cursorGenes } : {}),
|
|
375
566
|
force: f['force'] === true,
|
|
567
|
+
dryRun: f['dry-run'] === true,
|
|
568
|
+
homeDir: homedir(),
|
|
569
|
+
kiroHome: process.env['KIRO_HOME'],
|
|
570
|
+
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
571
|
+
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
|
572
|
+
opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
|
|
376
573
|
});
|
|
377
574
|
}
|
|
378
575
|
catch (e) {
|
|
@@ -380,7 +577,7 @@ export async function runSetupHooks(argv, store, review) {
|
|
|
380
577
|
// `unsupported` runtime. Reporting `unsupported` here would tell a bootstrapper the runtime isn't supported and
|
|
381
578
|
// make it stop trying, when the real cause is operational. `error` is a CLI result status (the attempt failed),
|
|
382
579
|
// distinct from the support-matrix `unsupported` (an unrecognized runtime id) (Bugbot #264).
|
|
383
|
-
const msg =
|
|
580
|
+
const msg = safeSetupOperationError(e);
|
|
384
581
|
if (json)
|
|
385
582
|
emit({ runtime, outcome: 'error', files: [], error: msg });
|
|
386
583
|
else
|
|
@@ -389,22 +586,44 @@ export async function runSetupHooks(argv, store, review) {
|
|
|
389
586
|
}
|
|
390
587
|
if (!r.ok) {
|
|
391
588
|
// Same reasoning for an ok:false install result: a failed install of a supported runtime is `error`, not `unsupported`.
|
|
589
|
+
const message = safeSetupResultError(r.error);
|
|
392
590
|
if (json)
|
|
393
|
-
emit({ runtime, outcome: 'error', files: [], error:
|
|
591
|
+
emit({ runtime, outcome: 'error', files: [], error: message });
|
|
394
592
|
else
|
|
395
|
-
process.stderr.write(`${
|
|
593
|
+
process.stderr.write(`${message}\n`);
|
|
396
594
|
return 1;
|
|
397
595
|
}
|
|
596
|
+
const files = displayResultPaths(r.files, configRoot, scope) ?? [];
|
|
597
|
+
const backups = displayResultPaths(r.backups, configRoot, scope);
|
|
598
|
+
if (r.dryRun) {
|
|
599
|
+
if (json) {
|
|
600
|
+
emit({
|
|
601
|
+
runtime,
|
|
602
|
+
outcome: 'installed',
|
|
603
|
+
files,
|
|
604
|
+
backups,
|
|
605
|
+
dryRun: true,
|
|
606
|
+
...(r.alreadyInstalled ? { alreadyInstalled: true } : {}),
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
else if (r.alreadyInstalled) {
|
|
610
|
+
process.stdout.write('dry-run: evolver already installed (no changes)\n');
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
process.stdout.write(`dry-run: would install evolver (${r.mode}) → ${files.join(', ')}\n`);
|
|
614
|
+
}
|
|
615
|
+
return 0;
|
|
616
|
+
}
|
|
398
617
|
if (r.alreadyInstalled) {
|
|
399
618
|
if (json)
|
|
400
|
-
emit({ runtime, outcome: 'installed', files
|
|
619
|
+
emit({ runtime, outcome: 'installed', files, alreadyInstalled: true });
|
|
401
620
|
else
|
|
402
621
|
process.stdout.write('evolver already installed (use --force to reinstall)\n');
|
|
403
622
|
return 0;
|
|
404
623
|
}
|
|
405
624
|
if (json)
|
|
406
|
-
emit({ runtime, outcome: 'installed', files: r.
|
|
625
|
+
emit({ runtime, outcome: 'installed', files, backups, mode: r.mode, verified: r.verified });
|
|
407
626
|
else
|
|
408
|
-
process.stdout.write(`installed evolver (${r.mode}) → ${
|
|
627
|
+
process.stdout.write(`installed evolver (${r.mode}) → ${files.join(', ')}\n`);
|
|
409
628
|
return 0;
|
|
410
629
|
}
|