@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
package/dist/skill2gep.js
CHANGED
|
@@ -4,21 +4,44 @@
|
|
|
4
4
|
// faithful to v1 (golden-tested). B2 adds `synthesizeGene` + the Capsule contracts (trace-only / empty→Gene-only /
|
|
5
5
|
// validation-coverage); the human-review + real-trace red lines live there.
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
|
-
import { bootstrap } from '@evomap/evolver-core';
|
|
7
|
+
import { bootstrap, verify } from '@evomap/evolver-core';
|
|
8
|
+
const { isValidationCommandAllowed } = verify;
|
|
9
|
+
// Re-export for backward compatibility (used by tests)
|
|
10
|
+
export { isValidationCommandAllowed };
|
|
8
11
|
/** Max strategy steps kept from a skill (v1 parity: MAX_STRATEGY_STEPS). */
|
|
9
12
|
export const MAX_STRATEGY_STEPS = 28;
|
|
10
13
|
/** Gene id prefix for skill-distilled genes (v1 SKILL2GEP_ID_PREFIX). */
|
|
11
14
|
const SKILL2GEP_ID_PREFIX = 'gene_s2g_';
|
|
12
15
|
/** Default max-files constraint for a distilled gene (v1 skillDistiller.DISTILLED_MAX_FILES). */
|
|
13
16
|
const SKILL_MAX_FILES = 12;
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const WORKFLOW_SECTION_KEYWORDS = [
|
|
18
|
+
'workflow', 'strategy', 'steps', 'procedure', 'quick start', 'how to',
|
|
19
|
+
'human gate', 'output contract', 'release', 'rollback', 'promotion',
|
|
20
|
+
'process each', 'request process', 'request path',
|
|
21
|
+
'工作流', '流程', '步骤', '核心方法', '方法', '快速规则', '规则',
|
|
22
|
+
'输出门', '输出门槛', '人工确认', '人工门', '回滚', '发布', '晋级',
|
|
23
|
+
];
|
|
24
|
+
// 安全与请求章节属于策略,而不是可选说明;丢失它们会让蒸馏后的 Skill 缺少审批和信任边界契约。
|
|
25
|
+
const GOVERNANCE_SECTION_KEYWORDS = [
|
|
26
|
+
'security', 'safety', 'credential', 'approval', 'adversarial',
|
|
27
|
+
'trust boundary', 'content isolation', 'untrusted content',
|
|
28
|
+
'protect x data', 'protect data', 'data protection', 'privacy', 'legal basis', 'consent',
|
|
29
|
+
];
|
|
30
|
+
function sectionHeadingMatches(heading, keyword) {
|
|
31
|
+
if (/^[a-z0-9 ]+$/i.test(keyword)) {
|
|
32
|
+
const forms = keyword === 'verify'
|
|
33
|
+
? ['verify', 'verification', 'verifications']
|
|
34
|
+
: [keyword, `${keyword}s`];
|
|
35
|
+
return forms.some((form) => new RegExp('(^|[^a-z0-9])' + form + '($|[^a-z0-9])', 'i').test(heading));
|
|
36
|
+
}
|
|
37
|
+
return heading.includes(keyword);
|
|
38
|
+
}
|
|
16
39
|
/**
|
|
17
40
|
* Parse a SKILL.md into a structured intermediate — faithful port of v1 `parseSkillMd`. Pure. Section keywords are
|
|
18
41
|
* matched against lower-cased headings and include CJK synonyms (skills authored in Chinese), though the signal
|
|
19
42
|
* tokenizer keeps ASCII `[a-z0-9_]` only, so a CJK skill's signals come from its (English) frontmatter description.
|
|
20
43
|
*/
|
|
21
|
-
export function parseSkillMd(skillMd) {
|
|
44
|
+
export function parseSkillMd(skillMd, opts = {}) {
|
|
22
45
|
const text = String(skillMd || '');
|
|
23
46
|
// --- frontmatter (--- … --- block of key: value lines, keys lower-cased) ---
|
|
24
47
|
const frontmatter = {};
|
|
@@ -35,15 +58,20 @@ export function parseSkillMd(skillMd) {
|
|
|
35
58
|
// --- sections: split by `##+ heading`; content before the first heading is `_preamble`. A repeated heading
|
|
36
59
|
// resets its block (last occurrence wins), matching v1. ---
|
|
37
60
|
const lines = { _preamble: [] };
|
|
61
|
+
const sectionOccurrences = [{ key: '_preamble', lines: [] }];
|
|
38
62
|
let currentKey = '_preamble';
|
|
63
|
+
let currentOccurrence = sectionOccurrences[0];
|
|
39
64
|
body.split(/\n/).forEach((line) => {
|
|
40
65
|
const hdr = line.match(/^##+\s+(.+?)\s*$/);
|
|
41
66
|
if (hdr) {
|
|
42
67
|
currentKey = hdr[1].toLowerCase().trim();
|
|
43
68
|
lines[currentKey] = [];
|
|
69
|
+
currentOccurrence = { key: currentKey, lines: [] };
|
|
70
|
+
sectionOccurrences.push(currentOccurrence);
|
|
44
71
|
}
|
|
45
72
|
else {
|
|
46
73
|
(lines[currentKey] ??= []).push(line);
|
|
74
|
+
currentOccurrence.lines.push(line);
|
|
47
75
|
}
|
|
48
76
|
});
|
|
49
77
|
const sections = {};
|
|
@@ -70,6 +98,11 @@ export function parseSkillMd(skillMd) {
|
|
|
70
98
|
}
|
|
71
99
|
return out.join('\n');
|
|
72
100
|
};
|
|
101
|
+
/** Every matching section occurrence, including repeated headings, in document order. */
|
|
102
|
+
const pickSectionOccurrencesAll = (keywords) => sectionOccurrences
|
|
103
|
+
.filter(({ key }) => keywords.some((kw) => sectionHeadingMatches(key, kw)))
|
|
104
|
+
.map(({ lines: occurrenceLines }) => occurrenceLines.join('\n').trim())
|
|
105
|
+
.join('\n');
|
|
73
106
|
/** Every markdown list item → one step, in document order, length-bounded (default 5..300). */
|
|
74
107
|
const extractSteps = (block, opts) => {
|
|
75
108
|
const minLen = opts && typeof opts.minLen === 'number' ? opts.minLen : 5;
|
|
@@ -85,6 +118,49 @@ export function parseSkillMd(skillMd) {
|
|
|
85
118
|
}
|
|
86
119
|
return steps;
|
|
87
120
|
};
|
|
121
|
+
/** 将只有 prose 的安全章节中的声明式防护规则保留为有界策略语句。 */
|
|
122
|
+
const extractGovernanceStatements = (blocks) => {
|
|
123
|
+
const statements = [];
|
|
124
|
+
for (const block of blocks) {
|
|
125
|
+
let fenceMarker;
|
|
126
|
+
for (const rawLine of String(block || '').split(/\n/)) {
|
|
127
|
+
const line = rawLine.trim();
|
|
128
|
+
if (fenceMarker !== undefined) {
|
|
129
|
+
const closingFence = line.match(/^(`+|~+)$/);
|
|
130
|
+
if (closingFence !== null
|
|
131
|
+
&& closingFence[1][0] === fenceMarker.char
|
|
132
|
+
&& closingFence[1].length >= fenceMarker.length) {
|
|
133
|
+
fenceMarker = undefined;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const openingFence = line.match(/^(`{3,}|~{3,})(?:.*)?$/);
|
|
138
|
+
if (openingFence !== null) {
|
|
139
|
+
fenceMarker = { char: openingFence[1][0], length: openingFence[1].length };
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (!line || /^<\/?[A-Z0-9_-]+(?:>|\s)/.test(line))
|
|
143
|
+
continue;
|
|
144
|
+
const listItem = line.match(/^(?:\d+\.|[-*])\s+(.+?)\s*$/);
|
|
145
|
+
const statement = (listItem ? listItem[1] : line).replace(/^>\s?/, '').trim();
|
|
146
|
+
if (statement.length >= 5 && statement.length <= 300 && !statements.includes(statement)) {
|
|
147
|
+
statements.push(statement);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return statements;
|
|
152
|
+
};
|
|
153
|
+
const matchingGovernanceBlocks = sectionOccurrences
|
|
154
|
+
.filter(({ key }) => GOVERNANCE_SECTION_KEYWORDS.some((kw) => sectionHeadingMatches(key, kw)))
|
|
155
|
+
.map(({ lines: occurrenceLines }) => occurrenceLines.join('\n').trim());
|
|
156
|
+
const selectStrategySteps = (workflowSteps, governanceSteps) => {
|
|
157
|
+
const workflow = [...new Set(workflowSteps)];
|
|
158
|
+
const governance = [...new Set(governanceSteps)];
|
|
159
|
+
if (workflow.length + governance.length <= MAX_STRATEGY_STEPS)
|
|
160
|
+
return [...workflow, ...governance];
|
|
161
|
+
return [...governance.slice(0, MAX_STRATEGY_STEPS), ...workflow]
|
|
162
|
+
.slice(0, MAX_STRATEGY_STEPS);
|
|
163
|
+
};
|
|
88
164
|
// --- signals: frontmatter.description + the trigger/when section, tokenized to [a-z0-9_] (3..40, has-letter) ---
|
|
89
165
|
const signals = [];
|
|
90
166
|
const signalSource = (frontmatter['description'] || '') + '\n' + pickSection([
|
|
@@ -97,19 +173,17 @@ export function parseSkillMd(skillMd) {
|
|
|
97
173
|
signals.push(s);
|
|
98
174
|
});
|
|
99
175
|
// --- strategy: workflow + governance-tail sections; avoid: anti-pattern sections ---
|
|
100
|
-
const strategy = extractSteps(pickSectionsAll(
|
|
101
|
-
'workflow', 'strategy', 'steps', 'procedure', 'quick start', 'how to',
|
|
102
|
-
'human gate', 'output contract', 'release', 'rollback', 'promotion',
|
|
103
|
-
'工作流', '流程', '步骤', '核心方法', '方法', '快速规则', '规则',
|
|
104
|
-
'输出门', '输出门槛', '人工确认', '人工门', '回滚', '发布', '晋级',
|
|
105
|
-
]));
|
|
176
|
+
const strategy = selectStrategySteps(extractSteps(pickSectionsAll(WORKFLOW_SECTION_KEYWORDS)), extractGovernanceStatements(matchingGovernanceBlocks));
|
|
106
177
|
const avoid = extractSteps(pickSectionsAll([
|
|
107
178
|
'avoid', 'pitfall', 'anti-pattern', 'common mistake', 'do not', 'forbidden', "don't",
|
|
108
179
|
'不要做', '不要', '常见错误', '避免', '陷阱', '禁止',
|
|
109
180
|
]));
|
|
110
181
|
// --- validation: the bash/sh fenced commands in the validation/test section (non-comment, ≤300) ---
|
|
111
182
|
const validation = [];
|
|
112
|
-
const
|
|
183
|
+
const validationKeywords = ['validation', 'test', 'verify', 'check', '校验', '验证', '测试', '检查'];
|
|
184
|
+
const valBlock = opts.completeValidationPlan
|
|
185
|
+
? pickSectionOccurrencesAll(validationKeywords)
|
|
186
|
+
: pickSection(validationKeywords);
|
|
113
187
|
const fenceRe = /```(?:bash|sh|shell)?\s*\n([\s\S]*?)\n```/g;
|
|
114
188
|
let fence;
|
|
115
189
|
while ((fence = fenceRe.exec(valBlock)) !== null) {
|
|
@@ -129,28 +203,10 @@ export function parseSkillMd(skillMd) {
|
|
|
129
203
|
signals_match: signals.slice(0, 8),
|
|
130
204
|
strategy: strategy.slice(0, MAX_STRATEGY_STEPS),
|
|
131
205
|
avoid: avoid.slice(0, 5),
|
|
132
|
-
validation: validation.slice(0, 5),
|
|
206
|
+
validation: opts.completeValidationPlan ? validation : validation.slice(0, 5),
|
|
133
207
|
preconditions: preconditions.slice(0, 4),
|
|
134
208
|
};
|
|
135
209
|
}
|
|
136
|
-
/** Whether a validation command is safe to run as a Gene.validation entry (faithful port of v1
|
|
137
|
-
* policyCheck.isValidationCommandAllowed): a `node …` command with no command substitution, no shell
|
|
138
|
-
* metacharacters (outside quoted strings), and no node eval flags (-e/--eval/--print/-p). */
|
|
139
|
-
export function isValidationCommandAllowed(cmd) {
|
|
140
|
-
const c = String(cmd || '').trim();
|
|
141
|
-
if (!c)
|
|
142
|
-
return false;
|
|
143
|
-
if (!VALIDATION_ALLOWED_PREFIXES.some((p) => c.startsWith(p)))
|
|
144
|
-
return false;
|
|
145
|
-
if (/`|\$\(/.test(c))
|
|
146
|
-
return false; // no command substitution
|
|
147
|
-
const stripped = c.replace(/"[^"]*"/g, '').replace(/'[^']*'/g, ''); // ignore metachars inside quotes
|
|
148
|
-
if (/[;&|><]/.test(stripped))
|
|
149
|
-
return false; // no chaining / redirection
|
|
150
|
-
if (/^node\s+(-e|--eval|--print|-p)\b/.test(c))
|
|
151
|
-
return false; // no inline eval
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
210
|
/** Stable slug for a skill-distilled gene id (v1 slugify). */
|
|
155
211
|
function slugify(s) {
|
|
156
212
|
return String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '').slice(0, 60);
|
|
@@ -351,7 +407,7 @@ const shortHash = (s) => createHash('sha256').update(String(s ?? '')).digest('he
|
|
|
351
407
|
* hallucinating a successful run to pad the registry. Non-success executions are honest, so not checked. Returns
|
|
352
408
|
* the rejection reason, or null when clean.
|
|
353
409
|
*/
|
|
354
|
-
export function detectForgery(execution) {
|
|
410
|
+
export function detectForgery(execution, evidenceMode = 'workflow_execution') {
|
|
355
411
|
const trace = Array.isArray(execution?.trace) ? execution.trace : [];
|
|
356
412
|
const files = Number(execution?.blast_radius?.files ?? 0);
|
|
357
413
|
const lines = Number(execution?.blast_radius?.lines ?? 0);
|
|
@@ -359,7 +415,7 @@ export function detectForgery(execution) {
|
|
|
359
415
|
return null;
|
|
360
416
|
if (trace.length === 0)
|
|
361
417
|
return 'empty_execution_trace';
|
|
362
|
-
if (files === 0 && lines === 0)
|
|
418
|
+
if (evidenceMode === 'workflow_execution' && files === 0 && lines === 0)
|
|
363
419
|
return 'zero_blast_radius_with_success';
|
|
364
420
|
if (!trace.some((t) => Number.isInteger(t?.exit)))
|
|
365
421
|
return 'no_exit_code_in_trace';
|
|
@@ -410,9 +466,13 @@ export function assembleCapsule(gene, execution, opts = {}) {
|
|
|
410
466
|
confidence: Math.max(0, Math.min(1, score)),
|
|
411
467
|
blast_radius: { files, lines },
|
|
412
468
|
outcome: { status, score },
|
|
413
|
-
success_reason: status === 'success'
|
|
469
|
+
success_reason: status === 'success'
|
|
470
|
+
? (execution?.success_reason || (opts.evidenceMode === 'validation_only'
|
|
471
|
+
? 'All declared validation commands passed in the local verifier.'
|
|
472
|
+
: 'Skill workflow completed and all declared validations passed.'))
|
|
473
|
+
: null,
|
|
414
474
|
env_fingerprint: bootstrap.captureEnvFingerprint(),
|
|
415
|
-
source_type: 'skill2gep_hook',
|
|
475
|
+
source_type: opts.evidenceMode === 'validation_only' ? 'skill2gep_validation' : 'skill2gep_hook',
|
|
416
476
|
strategy: Array.isArray(gene.strategy) ? [...gene.strategy] : [],
|
|
417
477
|
content: execution?.content_summary || buildContentSummary(trace, execution?.blast_radius),
|
|
418
478
|
execution_trace: trace.map((t, i) => ({
|
|
@@ -438,12 +498,15 @@ export function reverseDistill(parsed, execution = {}, opts = {}) {
|
|
|
438
498
|
let capsule = null;
|
|
439
499
|
let capsuleDiagnostic = null;
|
|
440
500
|
if (execution?.status) {
|
|
441
|
-
const forgery = detectForgery(execution);
|
|
501
|
+
const forgery = detectForgery(execution, opts.evidenceMode);
|
|
442
502
|
if (forgery) {
|
|
443
503
|
capsuleDiagnostic = { reason: 'capsule_rejected_forgery', detail: forgery };
|
|
444
504
|
}
|
|
445
505
|
else {
|
|
446
|
-
const r = assembleCapsule(gene, execution,
|
|
506
|
+
const r = assembleCapsule(gene, execution, {
|
|
507
|
+
...(opts.scenario ? { scenario: opts.scenario } : {}),
|
|
508
|
+
...(opts.evidenceMode ? { evidenceMode: opts.evidenceMode } : {}),
|
|
509
|
+
});
|
|
447
510
|
if (r.ok)
|
|
448
511
|
capsule = r.capsule;
|
|
449
512
|
else
|
package/dist/skillDistill.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assetstore, events } from '@evomap/evolver-core';
|
|
2
|
-
import { type SkillExecution, type SynthesizeOptions } from './skill2gep.js';
|
|
2
|
+
import { type SkillEvidenceMode, type SkillExecution, type SynthesizeOptions } from './skill2gep.js';
|
|
3
3
|
export interface DiscoveredSkill {
|
|
4
4
|
/** The skill's directory name (`<dir>/skills/<name>/`) — its canonical id, used for dedup. */
|
|
5
5
|
name: string;
|
|
@@ -34,6 +34,12 @@ export interface SkillDistillResult {
|
|
|
34
34
|
capsuleDiagnostic: string | null;
|
|
35
35
|
errors: string[];
|
|
36
36
|
}
|
|
37
|
+
export interface SkillDistillationOptions extends SynthesizeOptions {
|
|
38
|
+
scenario?: string;
|
|
39
|
+
evidenceMode?: SkillEvidenceMode;
|
|
40
|
+
geneIdentity?: 'signals' | 'semantic';
|
|
41
|
+
completeValidationPlan?: boolean;
|
|
42
|
+
}
|
|
37
43
|
/**
|
|
38
44
|
* Distill a SKILL.md + its real execution into a pooled gene (+ capsule evidence) (B3a). The gene lands
|
|
39
45
|
* QUARANTINED — same human-review gate (A2a/A2b) as every auto-draft, so a skill-distilled gene never enters a
|
|
@@ -42,9 +48,7 @@ export interface SkillDistillResult {
|
|
|
42
48
|
* diagnostic. Idempotent on the gene (intake dedups by signals; quarantine is sticky). NEVER throws on a bad
|
|
43
49
|
* skill — returns errors instead, so a daemon scanning many skills is not broken by one.
|
|
44
50
|
*/
|
|
45
|
-
export declare function recordSkillDistillation(skillMd: string, execution: SkillExecution, deps: SkillDistillDeps, opts?:
|
|
46
|
-
scenario?: string;
|
|
47
|
-
}): Promise<SkillDistillResult>;
|
|
51
|
+
export declare function recordSkillDistillation(skillMd: string, execution: SkillExecution, deps: SkillDistillDeps, opts?: SkillDistillationOptions): Promise<SkillDistillResult>;
|
|
48
52
|
/**
|
|
49
53
|
* `evolver skill-distill --skill <SKILL.md|dir> [--execution <json|@file>] [--scenario <name>] [--strict]` (B3b-ii).
|
|
50
54
|
*
|
package/dist/skillDistill.js
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
// the gene.distilled audit event, and persisting the capsule evidence. The session→execution-trace extraction that
|
|
6
6
|
// turns a discovered skill into a Capsule-bearing distillation is B3b-ii (a separate slice).
|
|
7
7
|
import { readdirSync, readFileSync, statSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
8
|
+
import { createHash } from 'node:crypto';
|
|
8
9
|
import { join, resolve, dirname } from 'node:path';
|
|
9
10
|
import { assetstore, algo, events } from '@evomap/evolver-core';
|
|
10
|
-
import { parseSkillMd, reverseDistill } from './skill2gep.js';
|
|
11
|
+
import { parseSkillMd, reverseDistill, } from './skill2gep.js';
|
|
11
12
|
import { reviewLedgerForStore } from './reviewFilter.js';
|
|
12
13
|
/**
|
|
13
14
|
* Discover procedural skills under the given roots (B3b-i): each `<root>/skills/<name>/SKILL.md`. Pure enumeration
|
|
@@ -51,16 +52,20 @@ export function discoverSkills(roots) {
|
|
|
51
52
|
*/
|
|
52
53
|
export async function recordSkillDistillation(skillMd, execution, deps, opts = {}) {
|
|
53
54
|
const review = deps.review ?? reviewLedgerForStore(deps.store);
|
|
54
|
-
const parsed = parseSkillMd(skillMd);
|
|
55
|
+
const parsed = parseSkillMd(skillMd, { completeValidationPlan: opts.completeValidationPlan });
|
|
55
56
|
const { gene, capsule, capsuleDiagnostic } = reverseDistill(parsed, execution, opts);
|
|
56
57
|
const diag = capsuleDiagnostic ? (capsuleDiagnostic.detail ?? capsuleDiagnostic.reason) : null;
|
|
57
58
|
if (!gene)
|
|
58
59
|
return { geneId: null, geneAssetId: null, quarantined: false, capsuleId: null, capsuleDiagnostic: diag, errors: ['gene synthesis refused (strict mode or empty)'] };
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const semanticIdentity = opts.geneIdentity === 'semantic';
|
|
61
|
+
const existing = semanticIdentity
|
|
62
|
+
? []
|
|
63
|
+
: (await deps.store.list('Gene', 1000)).map((g) => ({
|
|
64
|
+
id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
|
|
65
|
+
signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
|
|
66
|
+
}));
|
|
67
|
+
const candidate = semanticIdentity ? { ...gene, id: semanticGeneId(gene) } : gene;
|
|
68
|
+
const r = algo.intakeGene(candidate, existing);
|
|
64
69
|
if (!r.ok || !r.gene)
|
|
65
70
|
return { geneId: null, geneAssetId: null, quarantined: false, capsuleId: null, capsuleDiagnostic: diag, errors: r.errors };
|
|
66
71
|
const assetId = String(r.gene.asset_id);
|
|
@@ -78,7 +83,7 @@ export async function recordSkillDistillation(skillMd, execution, deps, opts = {
|
|
|
78
83
|
await deps.ingestor.ingest({
|
|
79
84
|
type: 'gene.distilled',
|
|
80
85
|
payload: { geneId, assetId: r.gene.asset_id, category: r.gene.category, source: 'skill2gep', skill: parsed.name },
|
|
81
|
-
human: { title: `skill-distilled gene ${geneId} (UNPROVEN — awaiting review)
|
|
86
|
+
human: { title: `skill-distilled gene ${geneId} (UNPROVEN — awaiting review)`.slice(0, 80), severity: 'info' },
|
|
82
87
|
actor: { kind: 'machine', id: 'skill2gep' },
|
|
83
88
|
});
|
|
84
89
|
}
|
|
@@ -90,7 +95,11 @@ export async function recordSkillDistillation(skillMd, execution, deps, opts = {
|
|
|
90
95
|
// intakeGene may REWRITE the gene id (it only keeps an id already in the distilled-prefix namespace), so the
|
|
91
96
|
// capsule — built from the pre-intake candidate id — must be re-pointed to the POOLED gene id, else it
|
|
92
97
|
// references a gene that is not in the store.
|
|
93
|
-
const pooledCapsule = {
|
|
98
|
+
const pooledCapsule = {
|
|
99
|
+
...capsule,
|
|
100
|
+
...(semanticIdentity ? { id: semanticCapsuleId(geneId, capsule.id) } : {}),
|
|
101
|
+
gene: geneId,
|
|
102
|
+
};
|
|
94
103
|
await deps.store.put(pooledCapsule); // evidence; references the (gated) gene
|
|
95
104
|
capsuleId = pooledCapsule.id;
|
|
96
105
|
}
|
|
@@ -102,6 +111,26 @@ export async function recordSkillDistillation(skillMd, execution, deps, opts = {
|
|
|
102
111
|
return { geneId: null, geneAssetId: null, quarantined: false, capsuleId: null, capsuleDiagnostic: diag, errors: [e instanceof Error ? e.message : String(e)] };
|
|
103
112
|
}
|
|
104
113
|
}
|
|
114
|
+
function semanticGeneId(gene) {
|
|
115
|
+
const constraints = gene.constraints ?? {};
|
|
116
|
+
const normalized = JSON.stringify({
|
|
117
|
+
category: String(gene.category ?? ''),
|
|
118
|
+
signals: [...(gene.signals_match ?? [])].map((value) => String(value).trim().toLowerCase()).filter(Boolean).sort(),
|
|
119
|
+
strategy: [...(gene.strategy ?? [])].map((value) => String(value).trim()).filter(Boolean),
|
|
120
|
+
summary: String(gene.summary ?? ''),
|
|
121
|
+
preconditions: [...(gene.preconditions ?? [])].map((value) => String(value).trim()).filter(Boolean),
|
|
122
|
+
constraints: {
|
|
123
|
+
maxFiles: Number(constraints.max_files ?? 0),
|
|
124
|
+
forbiddenPaths: [...(constraints.forbidden_paths ?? [])].map((value) => String(value).trim()).filter(Boolean).sort(),
|
|
125
|
+
},
|
|
126
|
+
validation: [...(gene.validation ?? [])].map((value) => String(value).replace(/\s+/g, ' ').trim()).filter(Boolean),
|
|
127
|
+
});
|
|
128
|
+
return `gene_distilled_${createHash('sha256').update(normalized).digest('hex').slice(0, 24)}`;
|
|
129
|
+
}
|
|
130
|
+
function semanticCapsuleId(geneId, originalCapsuleId) {
|
|
131
|
+
const digest = createHash('sha256').update(`${geneId}|${originalCapsuleId}`).digest('hex').slice(0, 24);
|
|
132
|
+
return `cap_s2g_${digest}`;
|
|
133
|
+
}
|
|
105
134
|
/** Resolve a `--skill` argument (a SKILL.md file OR a skill directory) to the SKILL.md path. */
|
|
106
135
|
function resolveSkillMdPath(skillArg) {
|
|
107
136
|
const p = resolve(skillArg);
|
|
@@ -193,6 +222,7 @@ export async function runSkillDistill(argv, injected = {}) {
|
|
|
193
222
|
return 1;
|
|
194
223
|
}
|
|
195
224
|
process.stdout.write(`skill-distill: gene ${res.geneId} ${res.quarantined ? 'QUARANTINED (awaiting `evolver review --approve`)' : 'recorded'}\n`);
|
|
225
|
+
process.stdout.write(' preferred hub artifact is Recipe (`evolver recipe build --publish`), not Skill Store\n');
|
|
196
226
|
if (res.capsuleId)
|
|
197
227
|
process.stdout.write(` → capsule ${res.capsuleId} (real execution evidence)\n`);
|
|
198
228
|
else {
|
package/dist/solo/mode.js
CHANGED
|
@@ -34,6 +34,7 @@ export function applySoloLockdown(env = process.env) {
|
|
|
34
34
|
EVOLVER_ATP: 'off',
|
|
35
35
|
EVOLVER_ATP_AUTOBUY: 'off',
|
|
36
36
|
EVOLVER_ATP_AUTODELIVER: 'off',
|
|
37
|
+
EVOLVER_LEARNING_TRACE_UPLOAD: '0',
|
|
37
38
|
// Empty hub creds so any lower-level connector short-circuits.
|
|
38
39
|
A2A_HUB_URL: '',
|
|
39
40
|
EVOMAP_HUB_URL: '',
|
package/dist/sync.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface SyncAccountAssetLister {
|
|
|
5
5
|
listAccountAssets(opts: AccountAssetListOptions): Promise<AccountAssetListResult>;
|
|
6
6
|
}
|
|
7
7
|
export interface SyncAccountAssetHub extends SyncAccountAssetLister {
|
|
8
|
-
fetchAssetById(assetId: string): Promise<assetstore.AssetRecord | null>;
|
|
8
|
+
fetchAssetById(assetId: string, options?: hubNs.FetchAssetByIdOptions): Promise<assetstore.AssetRecord | null>;
|
|
9
9
|
}
|
|
10
10
|
export interface SyncCliDeps {
|
|
11
11
|
hub?: SyncAccountAssetLister | SyncAccountAssetHub;
|
|
@@ -21,6 +21,18 @@ export interface SyncCliDeps {
|
|
|
21
21
|
hub: PublicHubCapability;
|
|
22
22
|
auth: hubNs.AuthProvider;
|
|
23
23
|
};
|
|
24
|
+
connectPrivateHub?: (env: NodeJS.ProcessEnv) => Promise<SyncAccountAssetHub>;
|
|
25
|
+
/** Opaque identity supplied by an injected Hub adapter; it is hashed again before any checkpoint write. */
|
|
26
|
+
resumeIdentityFingerprint?: string;
|
|
24
27
|
}
|
|
25
28
|
export declare function runSyncCommand(argv: readonly string[], deps?: SyncCliDeps): Promise<number>;
|
|
29
|
+
export declare function preparePrivateSyncHub(runtime: {
|
|
30
|
+
hub: unknown;
|
|
31
|
+
hello(opts: {
|
|
32
|
+
rotate: boolean;
|
|
33
|
+
evolverVersion?: string;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
ok: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
}): Promise<SyncAccountAssetHub>;
|
|
26
38
|
export {};
|