@evomap/evolver-cli 2.0.0-beta.2 → 2.0.0-beta.22
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 +2 -0
- package/dist/antiGeneRollout.js +9 -3
- package/dist/assetHealth.d.ts +6 -0
- package/dist/assetHealth.js +107 -0
- package/dist/assetRepair.d.ts +24 -0
- package/dist/assetRepair.js +172 -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 +231 -0
- package/dist/atp.d.ts +10 -5
- package/dist/atp.js +119 -26
- package/dist/atpAutoBuyer.d.ts +120 -0
- package/dist/atpAutoBuyer.js +814 -0
- package/dist/atpAutoDeliver.js +2 -2
- package/dist/autoDistillAntiGene.js +7 -5
- package/dist/autoDistillLlm.d.ts +26 -0
- package/dist/autoDistillLlm.js +119 -22
- package/dist/autoDistillTranscript.js +3 -2
- package/dist/autoexec.d.ts +111 -24
- package/dist/autoexec.js +887 -120
- package/dist/autoexecConfig.d.ts +10 -0
- package/dist/autoexecConfig.js +69 -0
- package/dist/cli.js +13 -0
- package/dist/cliContracts.d.ts +33 -2
- package/dist/cliContracts.js +818 -78
- package/dist/commandCatalog.d.ts +72 -0
- package/dist/commandCatalog.js +120 -0
- package/dist/commands.d.ts +1 -0
- package/dist/commands.js +1 -0
- package/dist/curriculumCapabilityGaps.d.ts +6 -0
- package/dist/curriculumCapabilityGaps.js +24 -0
- package/dist/cycleConsumer.d.ts +17 -2
- package/dist/cycleConsumer.js +374 -50
- package/dist/dashboard.d.ts +13 -1
- package/dist/dashboard.js +235 -18
- package/dist/dispatch.d.ts +9 -2
- package/dist/dispatch.js +29 -6
- package/dist/distillAdmission.d.ts +13 -0
- package/dist/distillAdmission.js +35 -0
- package/dist/distillObserver.js +27 -12
- package/dist/distillPrimitives.d.ts +11 -8
- package/dist/distillPrimitives.js +116 -22
- package/dist/doctor.d.ts +13 -0
- package/dist/doctor.js +177 -10
- package/dist/identityHome.d.ts +9 -0
- package/dist/identityHome.js +47 -0
- package/dist/index.d.ts +73 -40
- package/dist/index.js +745 -207
- package/dist/issueReport.d.ts +7 -0
- package/dist/issueReport.js +291 -0
- package/dist/learningTrace.d.ts +15 -0
- package/dist/learningTrace.js +73 -0
- package/dist/lifecycle.d.ts +199 -2
- package/dist/lifecycle.js +4999 -152
- package/dist/lifecycleBootstrapTransaction.d.ts +235 -0
- package/dist/lifecycleBootstrapTransaction.js +2182 -0
- package/dist/localMemoryGraph.d.ts +184 -0
- package/dist/localMemoryGraph.js +2689 -0
- package/dist/login.d.ts +1 -1
- package/dist/login.js +3 -3
- package/dist/materialPackage.js +3 -6
- package/dist/materialSnapshot.d.ts +35 -1
- package/dist/materialSnapshot.js +265 -18
- package/dist/memoryGraphOps.d.ts +8 -0
- package/dist/memoryGraphOps.js +140 -0
- package/dist/migrate/assetFormatMap.d.ts +61 -0
- package/dist/migrate/assetFormatMap.js +53 -0
- package/dist/migrate/envTranslate.d.ts +26 -0
- package/dist/migrate/envTranslate.js +147 -0
- package/dist/migrate/fieldMap.d.ts +7 -5
- package/dist/migrate/fieldMap.js +20 -14
- package/dist/migrate/oauthImport.d.ts +66 -0
- package/dist/migrate/oauthImport.js +667 -0
- package/dist/migrate/v1Import.d.ts +98 -1
- package/dist/migrate/v1Import.js +1532 -71
- package/dist/modelCompatibility.d.ts +10 -0
- package/dist/modelCompatibility.js +296 -0
- package/dist/promptRecallHook.d.ts +24 -0
- package/dist/promptRecallHook.js +425 -0
- package/dist/recallVerifyReport.d.ts +37 -0
- package/dist/recallVerifyReport.js +244 -0
- package/dist/recipe.d.ts +14 -2
- package/dist/recipe.js +543 -65
- package/dist/repairedAssetStore.d.ts +2 -0
- package/dist/repairedAssetStore.js +12 -0
- package/dist/requiredSandboxValidation.d.ts +5 -0
- package/dist/requiredSandboxValidation.js +4 -0
- package/dist/reuse.d.ts +18 -4
- package/dist/reuse.js +375 -107
- package/dist/reviewFilter.d.ts +3 -1
- package/dist/reviewFilter.js +3 -1
- package/dist/runtimeCapabilities.d.ts +18 -0
- package/dist/runtimeCapabilities.js +81 -0
- package/dist/runtimeSessionSource.d.ts +8 -2
- package/dist/runtimeSessionSource.js +63 -11
- package/dist/selectionPolicyConfig.d.ts +8 -0
- package/dist/selectionPolicyConfig.js +18 -0
- package/dist/semanticIdfConfig.d.ts +2 -0
- package/dist/semanticIdfConfig.js +4 -0
- package/dist/sessionIngest.d.ts +43 -0
- package/dist/sessionIngest.js +180 -0
- package/dist/setupHooks.d.ts +5 -0
- package/dist/setupHooks.js +330 -14
- package/dist/skill2gep.d.ts +13 -9
- package/dist/skill2gep.js +99 -36
- package/dist/skillDistill.d.ts +8 -4
- package/dist/skillDistill.js +39 -9
- package/dist/solo/mode.js +1 -0
- package/dist/sync.d.ts +13 -1
- package/dist/sync.js +1947 -265
- package/dist/thesis.d.ts +1 -1
- package/dist/thesis.js +20 -3
- package/dist/trajectoryExport.js +21 -3
- package/dist/v1Compat.d.ts +1 -0
- package/dist/v1Compat.js +9 -0
- package/dist/valueDigest.js +8 -1
- package/dist/windowsLegacyTaskCleanup.d.ts +228 -0
- package/dist/windowsLegacyTaskCleanup.js +1475 -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 +638 -0
- package/package.json +14 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** V1→V2 asset path / schema mapping — Refs #684 (R4 Asset-format, 5 sub-items). */
|
|
2
|
+
export declare const CURRENT_WIRE_SCHEMA_VERSION: "1.13.0";
|
|
3
|
+
export declare const V1_EVENT_SCHEMA_VERSION_EXAMPLE: "1.6.0";
|
|
4
|
+
/** Machine-readable mapping for the five issue rows. */
|
|
5
|
+
export declare const ASSET_FORMAT_MAP: readonly [{
|
|
6
|
+
readonly id: 1;
|
|
7
|
+
readonly severity: "major";
|
|
8
|
+
readonly v1: "events.jsonl in the selected current store, or repository legacy assets/gep (EvolutionEvent plus ValidationReport rows; stored schema often 1.6.0)";
|
|
9
|
+
readonly v2: "content-addressed EvolutionEvent JSONL; existing schema_version is preserved";
|
|
10
|
+
readonly migrate: "import-v1 injects 1.13.0 only when schema_version is missing; frozen hash mismatches remain untrusted; ValidationReport rows are validated, counted, and preserved in the V1 source";
|
|
11
|
+
}, {
|
|
12
|
+
readonly id: 2;
|
|
13
|
+
readonly severity: "cosmetic";
|
|
14
|
+
readonly v1: "capsules.json(.l) in the selected current store, then repository legacy fallback";
|
|
15
|
+
readonly v2: "LocalJsonlProvider Capsule stream + migration/v1_extensions.jsonl for non-schema fields";
|
|
16
|
+
readonly migrate: "import-v1 combines the capsules envelope and JSONL overlay by id; JSONL wins";
|
|
17
|
+
}, {
|
|
18
|
+
readonly id: 3;
|
|
19
|
+
readonly severity: "cosmetic";
|
|
20
|
+
readonly v1: "candidates.jsonl in the selected current store, then repository legacy fallback";
|
|
21
|
+
readonly v2: "material/candidates (selection input — not wire assets)";
|
|
22
|
+
readonly migrate: "import-v1 skips candidates (report.candidatesSkipped=true); operators keep pool outside wire store";
|
|
23
|
+
}, {
|
|
24
|
+
readonly id: 4;
|
|
25
|
+
readonly severity: "cosmetic";
|
|
26
|
+
readonly v1: "failed_capsules.json";
|
|
27
|
+
readonly v2: "no automatic wire mapping";
|
|
28
|
+
readonly migrate: "not imported; preserve the V1 source for explicit operator recovery";
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: 5;
|
|
31
|
+
readonly severity: "cosmetic";
|
|
32
|
+
readonly v1: "genes.json(.l) in the selected current store, then repository legacy fallback";
|
|
33
|
+
readonly v2: "LocalJsonlProvider Gene JSONL (content-addressed)";
|
|
34
|
+
readonly migrate: "import-v1 combines the genes envelope and JSONL overlay by id; JSONL wins";
|
|
35
|
+
}];
|
|
36
|
+
/** V1 path components used to select one current workspace plus the repository legacy fallback. */
|
|
37
|
+
export declare const V1_GEP_SOURCE_LAYOUT: {
|
|
38
|
+
readonly workspaceCurrent: readonly ["workspace", ".evolver", "gep"];
|
|
39
|
+
readonly rootCurrent: readonly [".evolver", "gep"];
|
|
40
|
+
readonly legacy: readonly ["assets", "gep"];
|
|
41
|
+
};
|
|
42
|
+
export declare const V1_GEP_WIRE_SOURCES: {
|
|
43
|
+
readonly Gene: {
|
|
44
|
+
readonly envelope: {
|
|
45
|
+
readonly basename: "genes.json";
|
|
46
|
+
readonly key: "genes";
|
|
47
|
+
};
|
|
48
|
+
readonly jsonl: "genes.jsonl";
|
|
49
|
+
};
|
|
50
|
+
readonly Capsule: {
|
|
51
|
+
readonly envelope: {
|
|
52
|
+
readonly basename: "capsules.json";
|
|
53
|
+
readonly key: "capsules";
|
|
54
|
+
};
|
|
55
|
+
readonly jsonl: "capsules.jsonl";
|
|
56
|
+
};
|
|
57
|
+
readonly EvolutionEvent: {
|
|
58
|
+
readonly jsonl: "events.jsonl";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type AssetFormatMapEntry = (typeof ASSET_FORMAT_MAP)[number];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { wire } from '@evomap/evolver-core';
|
|
2
|
+
/** V1→V2 asset path / schema mapping — Refs #684 (R4 Asset-format, 5 sub-items). */
|
|
3
|
+
export const CURRENT_WIRE_SCHEMA_VERSION = wire.SCHEMA_VERSION;
|
|
4
|
+
export const V1_EVENT_SCHEMA_VERSION_EXAMPLE = '1.6.0';
|
|
5
|
+
/** Machine-readable mapping for the five issue rows. */
|
|
6
|
+
export const ASSET_FORMAT_MAP = [
|
|
7
|
+
{
|
|
8
|
+
id: 1,
|
|
9
|
+
severity: 'major',
|
|
10
|
+
v1: 'events.jsonl in the selected current store, or repository legacy assets/gep (EvolutionEvent plus ValidationReport rows; stored schema often 1.6.0)',
|
|
11
|
+
v2: 'content-addressed EvolutionEvent JSONL; existing schema_version is preserved',
|
|
12
|
+
migrate: `import-v1 injects ${CURRENT_WIRE_SCHEMA_VERSION} only when schema_version is missing; frozen hash mismatches remain untrusted; ValidationReport rows are validated, counted, and preserved in the V1 source`,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 2,
|
|
16
|
+
severity: 'cosmetic',
|
|
17
|
+
v1: 'capsules.json(.l) in the selected current store, then repository legacy fallback',
|
|
18
|
+
v2: 'LocalJsonlProvider Capsule stream + migration/v1_extensions.jsonl for non-schema fields',
|
|
19
|
+
migrate: 'import-v1 combines the capsules envelope and JSONL overlay by id; JSONL wins',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 3,
|
|
23
|
+
severity: 'cosmetic',
|
|
24
|
+
v1: 'candidates.jsonl in the selected current store, then repository legacy fallback',
|
|
25
|
+
v2: 'material/candidates (selection input — not wire assets)',
|
|
26
|
+
migrate: 'import-v1 skips candidates (report.candidatesSkipped=true); operators keep pool outside wire store',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 4,
|
|
30
|
+
severity: 'cosmetic',
|
|
31
|
+
v1: 'failed_capsules.json',
|
|
32
|
+
v2: 'no automatic wire mapping',
|
|
33
|
+
migrate: 'not imported; preserve the V1 source for explicit operator recovery',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 5,
|
|
37
|
+
severity: 'cosmetic',
|
|
38
|
+
v1: 'genes.json(.l) in the selected current store, then repository legacy fallback',
|
|
39
|
+
v2: 'LocalJsonlProvider Gene JSONL (content-addressed)',
|
|
40
|
+
migrate: 'import-v1 combines the genes envelope and JSONL overlay by id; JSONL wins',
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
/** V1 path components used to select one current workspace plus the repository legacy fallback. */
|
|
44
|
+
export const V1_GEP_SOURCE_LAYOUT = {
|
|
45
|
+
workspaceCurrent: ['workspace', '.evolver', 'gep'],
|
|
46
|
+
rootCurrent: ['.evolver', 'gep'],
|
|
47
|
+
legacy: ['assets', 'gep'],
|
|
48
|
+
};
|
|
49
|
+
export const V1_GEP_WIRE_SOURCES = {
|
|
50
|
+
Gene: { envelope: { basename: 'genes.json', key: 'genes' }, jsonl: 'genes.jsonl' },
|
|
51
|
+
Capsule: { envelope: { basename: 'capsules.json', key: 'capsules' }, jsonl: 'capsules.jsonl' },
|
|
52
|
+
EvolutionEvent: { jsonl: 'events.jsonl' },
|
|
53
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { bootstrap } from '@evomap/evolver-core';
|
|
2
|
+
export interface MigrateEnvOptions {
|
|
3
|
+
/** Path to a dotenv file to scan. When omitted, scans process env only. */
|
|
4
|
+
file?: string;
|
|
5
|
+
/** Also scan process.env (default true when file set). File values win, matching the runtime loader. */
|
|
6
|
+
includeProcessEnv?: boolean;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
/** Optional path to write a suggested dotenv fragment (non-secret mapped keys only). */
|
|
9
|
+
writeSuggestions?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MigrateEnvResult {
|
|
12
|
+
report: bootstrap.V1EnvTranslationReport;
|
|
13
|
+
scannedKeys: string[];
|
|
14
|
+
source: 'process' | 'file' | 'file+process';
|
|
15
|
+
}
|
|
16
|
+
export declare function runMigrateEnvScan(opts: MigrateEnvOptions, processEnv?: Record<string, string | undefined>): MigrateEnvResult;
|
|
17
|
+
/** Build a dotenv fragment for mappable keys only (never writes secret values for keep/GITHUB). */
|
|
18
|
+
export declare function formatMappedDotenvFragment(report: bootstrap.V1EnvTranslationReport): string;
|
|
19
|
+
export declare function parseMigrateEnvArgs(argv: readonly string[]): MigrateEnvOptions | {
|
|
20
|
+
error: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function runMigrateEnvCommand(argv: readonly string[], io?: {
|
|
23
|
+
stdout?: (line: string) => void;
|
|
24
|
+
stderr?: (line: string) => void;
|
|
25
|
+
env?: Record<string, string | undefined>;
|
|
26
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Offline V1→V2 env translation for `evolver migrate env` (Refs #698).
|
|
2
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { bootstrap } from '@evomap/evolver-core';
|
|
5
|
+
import { expandHomePath, parseEnvFile } from '@evomap/evolver-mcp';
|
|
6
|
+
function loadFileEnv(path) {
|
|
7
|
+
const resolved = resolve(expandHomePath(path));
|
|
8
|
+
return parseEnvFile(readFileSync(resolved, 'utf8'));
|
|
9
|
+
}
|
|
10
|
+
export function runMigrateEnvScan(opts, processEnv = process.env) {
|
|
11
|
+
let env = {};
|
|
12
|
+
let source = 'process';
|
|
13
|
+
if (opts.file) {
|
|
14
|
+
const fromFile = loadFileEnv(opts.file);
|
|
15
|
+
env = { ...fromFile };
|
|
16
|
+
source = 'file';
|
|
17
|
+
if (opts.includeProcessEnv !== false) {
|
|
18
|
+
env = { ...processEnv, ...fromFile };
|
|
19
|
+
source = 'file+process';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
env = { ...processEnv };
|
|
24
|
+
}
|
|
25
|
+
const report = bootstrap.translateV1Env(env);
|
|
26
|
+
return { report, scannedKeys: Object.keys(env).sort(), source };
|
|
27
|
+
}
|
|
28
|
+
/** Build a dotenv fragment for mappable keys only (never writes secret values for keep/GITHUB). */
|
|
29
|
+
export function formatMappedDotenvFragment(report) {
|
|
30
|
+
const lines = [
|
|
31
|
+
'# Generated by: evolver migrate env --write-suggestions',
|
|
32
|
+
'# Only MAP suggestions (V1 → V2 rename). Review before applying.',
|
|
33
|
+
'# Manual and removed V1 keys are comments; resolve manual items before deleting them.',
|
|
34
|
+
...(report.caveats ?? []).map((caveat) => `# CAVEAT ${caveat}`),
|
|
35
|
+
'',
|
|
36
|
+
];
|
|
37
|
+
for (const s of report.suggestions) {
|
|
38
|
+
if (s.action === 'map' && s.v2Name && s.v2Value !== undefined) {
|
|
39
|
+
lines.push(`# was ${s.v1Name}`);
|
|
40
|
+
lines.push(`${s.v2Name}=${JSON.stringify(s.v2Value)}`);
|
|
41
|
+
lines.push('');
|
|
42
|
+
}
|
|
43
|
+
else if (s.action === 'manual') {
|
|
44
|
+
lines.push(`# REVIEW ${s.v1Name} — ${s.guidance}`);
|
|
45
|
+
lines.push('');
|
|
46
|
+
}
|
|
47
|
+
else if (s.action === 'remove') {
|
|
48
|
+
lines.push(`# REMOVE ${s.v1Name} — ${s.guidance}`);
|
|
49
|
+
lines.push('');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return lines.join('\n');
|
|
53
|
+
}
|
|
54
|
+
export function parseMigrateEnvArgs(argv) {
|
|
55
|
+
const opts = {};
|
|
56
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
57
|
+
const a = argv[i] ?? '';
|
|
58
|
+
if (a === '--json')
|
|
59
|
+
opts.json = true;
|
|
60
|
+
else if (a === '--file' || a === '--env-file') {
|
|
61
|
+
const v = argv[++i];
|
|
62
|
+
if (!v || v.startsWith('--'))
|
|
63
|
+
return { error: 'migrate env --file requires a path' };
|
|
64
|
+
opts.file = v;
|
|
65
|
+
}
|
|
66
|
+
else if (a.startsWith('--file='))
|
|
67
|
+
opts.file = a.slice('--file='.length);
|
|
68
|
+
else if (a.startsWith('--env-file='))
|
|
69
|
+
opts.file = a.slice('--env-file='.length);
|
|
70
|
+
else if (a === '--write-suggestions') {
|
|
71
|
+
const v = argv[++i];
|
|
72
|
+
if (!v || v.startsWith('--'))
|
|
73
|
+
return { error: 'migrate env --write-suggestions requires a path' };
|
|
74
|
+
opts.writeSuggestions = v;
|
|
75
|
+
}
|
|
76
|
+
else if (a.startsWith('--write-suggestions='))
|
|
77
|
+
opts.writeSuggestions = a.slice('--write-suggestions='.length);
|
|
78
|
+
else if (a === '--no-process-env')
|
|
79
|
+
opts.includeProcessEnv = false;
|
|
80
|
+
else if (a === '--help' || a === '-h')
|
|
81
|
+
return { error: 'help' };
|
|
82
|
+
else
|
|
83
|
+
return { error: `unknown argument: ${a}` };
|
|
84
|
+
}
|
|
85
|
+
return opts;
|
|
86
|
+
}
|
|
87
|
+
export async function runMigrateEnvCommand(argv, io = {}) {
|
|
88
|
+
const stdout = io.stdout ?? ((line) => { process.stdout.write(line); });
|
|
89
|
+
const stderr = io.stderr ?? ((line) => { process.stderr.write(line); });
|
|
90
|
+
const usage = [
|
|
91
|
+
'Usage: evolver migrate env [--file <dotenv>] [--json] [--write-suggestions <path>] [--no-process-env]',
|
|
92
|
+
'',
|
|
93
|
+
'Offline V1→V2 env translation for knobs removed or renamed after upgrade (Refs #698).',
|
|
94
|
+
'Does not load secrets into resolvers; prints key names and actions only in text mode.',
|
|
95
|
+
'',
|
|
96
|
+
].join('\n');
|
|
97
|
+
const parsed = parseMigrateEnvArgs(argv);
|
|
98
|
+
if ('error' in parsed) {
|
|
99
|
+
if (parsed.error === 'help') {
|
|
100
|
+
stdout(usage);
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
stderr(`${parsed.error}\n${usage}`);
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const result = runMigrateEnvScan(parsed, io.env ?? process.env);
|
|
108
|
+
if (parsed.writeSuggestions) {
|
|
109
|
+
const fragment = formatMappedDotenvFragment(result.report);
|
|
110
|
+
writeFileSync(resolve(expandHomePath(parsed.writeSuggestions)), fragment, {
|
|
111
|
+
encoding: 'utf8',
|
|
112
|
+
flag: 'wx',
|
|
113
|
+
mode: 0o600,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (parsed.json) {
|
|
117
|
+
// JSON mode deliberately emits metadata only; raw source and mapped values stay in memory.
|
|
118
|
+
const safe = {
|
|
119
|
+
source: result.source,
|
|
120
|
+
detectedCount: result.report.detectedCount,
|
|
121
|
+
mappableCount: result.report.mappableCount,
|
|
122
|
+
manualCount: result.report.manualCount,
|
|
123
|
+
removableCount: result.report.removableCount,
|
|
124
|
+
githubTokenPresent: result.report.githubTokenPresent,
|
|
125
|
+
caveats: result.report.caveats ?? [],
|
|
126
|
+
suggestions: result.report.suggestions.map((s) => ({
|
|
127
|
+
v1Name: s.v1Name,
|
|
128
|
+
action: s.action,
|
|
129
|
+
v2Name: s.v2Name,
|
|
130
|
+
guidance: s.guidance,
|
|
131
|
+
})),
|
|
132
|
+
};
|
|
133
|
+
stdout(`${JSON.stringify(safe, null, 2)}\n`);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
stdout(bootstrap.formatV1EnvTranslationReport(result.report));
|
|
137
|
+
if (parsed.writeSuggestions) {
|
|
138
|
+
stdout(`wrote suggestions: ${parsed.writeSuggestions}\n`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
stderr(`migrate env: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -7,12 +7,14 @@ export interface MappedAsset {
|
|
|
7
7
|
/**
|
|
8
8
|
* v1 资产 → v2 wire(M8-2). 规则:
|
|
9
9
|
* - 只留 gep-sdk schema 允许字段, 其余(avoid 等)落 dropped→sidecar(不参与 canonicalize, 不动 asset_id).
|
|
10
|
-
* -
|
|
10
|
+
* - 缺 schema_version → 注入 wire.SCHEMA_VERSION 作为新记录 authoring default;已有版本原样保留。
|
|
11
|
+
* SDK package version 不是最低可接受 wire version。
|
|
11
12
|
* - source_type 非标枚举 → generated; mutation_id null → ''.
|
|
12
|
-
* - asset_id: 有则**冻结**(原样);
|
|
13
|
+
* - asset_id: 有则**冻结**(原样); 缺失时新算(recomputed=true). 若映射改变正文,importer 会用
|
|
14
|
+
* content-bound provenance 隔离 frozen mismatch,而不是把它默认为可信资产(Refs #677).
|
|
13
15
|
* - v2 新增 optional(resolution_status/proof_of_work/...) v1 无 → 自然省略(不合成).
|
|
14
|
-
* - Gene 的 routing_hint/tool_policy
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* - Gene 的 routing_hint/tool_policy/generation_meta 需要先 normalize,不能走 raw-copy;这里维护迁移本地
|
|
17
|
+
* 的阻断集,避免 future schema promotion 让 `allowed.has(k)` 把原始脏值直接塞进 record。
|
|
18
|
+
* v1 的 null/缺省干净省略;存在但归一化失败的脏值落 dropped 便于审计。
|
|
17
19
|
*/
|
|
18
20
|
export declare function mapV1Asset(kind: V1Kind, v1: Record<string, unknown>): MappedAsset;
|
package/dist/migrate/fieldMap.js
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
import { wire } from '@evomap/evolver-core';
|
|
2
2
|
// v1→v2 source_type 枚举转换(skill2gep_distillation 等非标 → generated).
|
|
3
3
|
const SOURCE_TYPE_MAP = { skill2gep_distillation: 'generated' };
|
|
4
|
-
const KNOWN_SOURCE = new Set(['generated', 'reused', 'reference']);
|
|
4
|
+
const KNOWN_SOURCE = new Set(['generated', 'reused', 'reference', 'user_authored']);
|
|
5
|
+
const GENE_RAW_NORMALIZED_FIELDS = new Set(['routing_hint', 'tool_policy', 'generation_meta']);
|
|
5
6
|
/**
|
|
6
7
|
* v1 资产 → v2 wire(M8-2). 规则:
|
|
7
8
|
* - 只留 gep-sdk schema 允许字段, 其余(avoid 等)落 dropped→sidecar(不参与 canonicalize, 不动 asset_id).
|
|
8
|
-
* -
|
|
9
|
+
* - 缺 schema_version → 注入 wire.SCHEMA_VERSION 作为新记录 authoring default;已有版本原样保留。
|
|
10
|
+
* SDK package version 不是最低可接受 wire version。
|
|
9
11
|
* - source_type 非标枚举 → generated; mutation_id null → ''.
|
|
10
|
-
* - asset_id: 有则**冻结**(原样);
|
|
12
|
+
* - asset_id: 有则**冻结**(原样); 缺失时新算(recomputed=true). 若映射改变正文,importer 会用
|
|
13
|
+
* content-bound provenance 隔离 frozen mismatch,而不是把它默认为可信资产(Refs #677).
|
|
11
14
|
* - v2 新增 optional(resolution_status/proof_of_work/...) v1 无 → 自然省略(不合成).
|
|
12
|
-
* - Gene 的 routing_hint/tool_policy
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* - Gene 的 routing_hint/tool_policy/generation_meta 需要先 normalize,不能走 raw-copy;这里维护迁移本地
|
|
16
|
+
* 的阻断集,避免 future schema promotion 让 `allowed.has(k)` 把原始脏值直接塞进 record。
|
|
17
|
+
* v1 的 null/缺省干净省略;存在但归一化失败的脏值落 dropped 便于审计。
|
|
15
18
|
*/
|
|
16
19
|
export function mapV1Asset(kind, v1) {
|
|
17
20
|
const allowed = new Set(wire.schemaProperties(kind));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
21
|
+
// V1 rows are untrusted. Null prototypes keep keys such as `__proto__` auditable instead of invoking
|
|
22
|
+
// Object.prototype setters and silently losing extension data.
|
|
23
|
+
const record = Object.create(null);
|
|
24
|
+
const dropped = Object.create(null);
|
|
25
|
+
// Gene normalization is migration-local. wire.GENE_HINT_FIELDS is only the runtime strip list for local-only
|
|
26
|
+
// annotations; do not reuse it here or a future schema promotion can re-enable raw-copy leakage.
|
|
27
|
+
const geneNormalizedFields = kind === 'Gene' ? GENE_RAW_NORMALIZED_FIELDS : null;
|
|
22
28
|
for (const [k, val] of Object.entries(v1)) {
|
|
23
|
-
//
|
|
29
|
+
// Normalized Gene fields are owned EXCLUSIVELY by the block below — never copied raw. This must hold even
|
|
24
30
|
// after a future gep-sdk bump adds them to schemaProperties (allowed): otherwise `allowed.has(k)` would
|
|
25
|
-
// copy the RAW v1
|
|
31
|
+
// copy the RAW v1 field into record, and the normalize-overwrite below only fires when normalize returns
|
|
26
32
|
// truthy — so a malformed hint (normalizes to null) would leak through un-normalized.
|
|
27
|
-
if (
|
|
33
|
+
if (geneNormalizedFields?.has(k))
|
|
28
34
|
continue;
|
|
29
35
|
if (allowed.has(k))
|
|
30
36
|
record[k] = val;
|
|
@@ -50,7 +56,7 @@ export function mapV1Asset(kind, v1) {
|
|
|
50
56
|
// (forward-compat for a repo that carried the #302 branch). A `_source` whose generation_source normalizes away
|
|
51
57
|
// (unknown enum) is NOT silently dropped — the raw `_source` stays in `dropped` for audit (it already landed there
|
|
52
58
|
// above as a non-schema field). `generation_meta` itself (if a v1 gene already carried the v2 field name) is a
|
|
53
|
-
//
|
|
59
|
+
// normalized field and is handled here by normalize, same as the hints.
|
|
54
60
|
if (v1['_source'] !== undefined && v1['_source'] !== null) {
|
|
55
61
|
const src = v1['_source'];
|
|
56
62
|
if (src && typeof src === 'object') {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { hub } from '@evomap/evolver-core';
|
|
2
|
+
import { type PublicAuthPathOptions } from '../login.js';
|
|
3
|
+
type OAuthMigrateStatus = 'migrated' | 'dry_run' | 'skipped_existing' | 'source_missing' | 'invalid_source' | 'refused';
|
|
4
|
+
export interface OAuthMigrateReport {
|
|
5
|
+
status: OAuthMigrateStatus;
|
|
6
|
+
fromPath: string;
|
|
7
|
+
toPath: string;
|
|
8
|
+
/** Field presence only — never raw secrets. */
|
|
9
|
+
sourceFields: {
|
|
10
|
+
hasAccessToken: boolean;
|
|
11
|
+
hasRefreshToken: boolean;
|
|
12
|
+
hasExpires: boolean;
|
|
13
|
+
hasDevice: boolean;
|
|
14
|
+
shape: 'v2-credential' | 'oauth2-snake' | 'nested' | 'unknown';
|
|
15
|
+
};
|
|
16
|
+
/** True when access token is past expiresAt (refresh may still work). */
|
|
17
|
+
accessExpired?: boolean;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OAuthMigrateOptions {
|
|
21
|
+
fromPath?: string;
|
|
22
|
+
toPath?: string;
|
|
23
|
+
force?: boolean;
|
|
24
|
+
dryRun?: boolean;
|
|
25
|
+
json?: boolean;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
env?: NodeJS.ProcessEnv;
|
|
28
|
+
homeDir?: string;
|
|
29
|
+
/** Test seam for deterministic source replacement races. */
|
|
30
|
+
sourceReadTestHook?: (stage: 'before-open' | 'after-open' | 'after-read', path: string) => void;
|
|
31
|
+
/** Test seam for security metadata changes between snapshot and trust inspection. */
|
|
32
|
+
beforeSourceTrustTestHook?: (path: string) => void;
|
|
33
|
+
/** Test seam for a destination created immediately before no-clobber publish. */
|
|
34
|
+
beforeSaveTestHook?: (path: string) => void;
|
|
35
|
+
/** Test seam that avoids creating a real soft machine id. */
|
|
36
|
+
deviceFingerprint?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Normalize expires fields: ms epoch preferred; accept seconds epoch or expires_in relative. */
|
|
39
|
+
export declare function normalizeExpiresAt(raw: Record<string, unknown>, nowMs: number): number | undefined;
|
|
40
|
+
export interface ParsedV1OAuth {
|
|
41
|
+
cred: hub.Credential & {
|
|
42
|
+
token: string;
|
|
43
|
+
};
|
|
44
|
+
shape: OAuthMigrateReport['sourceFields']['shape'];
|
|
45
|
+
hasAccessToken: boolean;
|
|
46
|
+
hasRefreshToken: boolean;
|
|
47
|
+
hasExpires: boolean;
|
|
48
|
+
hasDevice: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse a V1 (or already-V2) OAuth JSON object into a V2 hub.Credential.
|
|
52
|
+
* Accepts snake_case OAuth2, nested token objects, and V2 credential shape.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseV1OAuthJson(raw: unknown, nowMs?: number): ParsedV1OAuth;
|
|
55
|
+
export declare function defaultV1OAuthPath(opts?: PublicAuthPathOptions): string;
|
|
56
|
+
/**
|
|
57
|
+
* Convert V1 ~/.evomap/oauth_token.json into V2 token.json via CredentialStore.
|
|
58
|
+
* Never prints secret values. Fail-closed on unsafe paths / missing tokens.
|
|
59
|
+
*/
|
|
60
|
+
export declare function migrateV1OAuth(options?: OAuthMigrateOptions): OAuthMigrateReport;
|
|
61
|
+
export declare function runMigrateOAuthCommand(argv: readonly string[], io?: {
|
|
62
|
+
stdout?: (s: string) => void;
|
|
63
|
+
stderr?: (s: string) => void;
|
|
64
|
+
env?: NodeJS.ProcessEnv;
|
|
65
|
+
}): Promise<number>;
|
|
66
|
+
export {};
|