@evomap/evolver-cli 2.0.0-beta.14 → 2.0.0-beta.16

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/reuse.d.ts CHANGED
@@ -17,6 +17,12 @@ type AssetByIdFetcher = {
17
17
  fetchAssetById(assetId: string): Promise<assetstore.AssetRecord | null>;
18
18
  hello?(opts: PublicHelloOptions): Promise<unknown>;
19
19
  };
20
+ type PrivateReuseProxy = {
21
+ fetchAsset(args: {
22
+ assetId: string;
23
+ expectedHubMode: 'private';
24
+ }): Promise<unknown>;
25
+ };
20
26
  export interface ReuseCliDeps {
21
27
  store?: assetstore.AssetStoreProvider;
22
28
  assetsDir?: string;
@@ -31,6 +37,8 @@ export interface ReuseCliDeps {
31
37
  hub: PublicHubCapability;
32
38
  auth: hubNs.AuthProvider;
33
39
  };
40
+ /** Test seam for private-mode proxy discovery. */
41
+ resolveProxyClient?: (env: NodeJS.ProcessEnv) => PrivateReuseProxy | undefined;
34
42
  }
35
43
  interface ReuseOptions {
36
44
  id: string;
package/dist/reuse.js CHANGED
@@ -12,7 +12,7 @@
12
12
  // 2. NEVER let a token/secret reach any stream — error text is mapped to fixed messages / redacted.
13
13
  import { assetstore, events, hub as hubNs, wire } from '@evomap/evolver-core';
14
14
  import { AuthError, HubClientError, HubUnreachableError, connectPublicHub, isHubDryRunEnabled } from '@evomap/evolver-adapter-public';
15
- import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
15
+ import { loadEnvFileFromEnv, proxyClientFromEnv } from '@evomap/evolver-mcp';
16
16
  import { createRecipeHubFromEnv } from './recipe.js';
17
17
  import { getCliVersion } from './version.js';
18
18
  const REUSE_CONTRACT = 'reuse.v1';
@@ -75,8 +75,10 @@ export async function runReuseCommand(argv, deps = {}) {
75
75
  const env = deps.env ?? process.env;
76
76
  // Keep the native reuse path aligned with publish/contract transport: env-file values must be present before
77
77
  // dry-run checks and Hub construction. The loader mutates `env` and does not expose secret values.
78
- loadEnvFileFromEnv(env);
79
- const store = deps.store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
78
+ const envFile = loadEnvFileFromEnv(env);
79
+ if (envFile.error)
80
+ throw new Error('failed to load EVOLVER_ENV_FILE');
81
+ const store = deps.store ?? new assetstore.LocalJsonlProvider(deps.assetsDir ?? events.assetsDir(env));
80
82
  // 1) Already in the local recall library → reuse is idempotent: log + ok, no hub round-trip.
81
83
  const local = await resolveLocalReuseAsset(store, opts.id);
82
84
  if (local) {
@@ -88,7 +90,7 @@ export async function runReuseCommand(argv, deps = {}) {
88
90
  return emit({ ok: true, status: 'dry_run', message: `would fetch ${opts.id} and write it to the local recall library` }, ctx);
89
91
  }
90
92
  // 3) Pull the global asset by id, write it into the local recall library (put dedups → idempotent on repeat).
91
- const hub = deps.hub ?? createRecipeHubFromEnv(env, deps.connectHub ?? connectPublicHub);
93
+ const hub = deps.hub ?? createReuseFetcherFromEnv(env, deps);
92
94
  // One-shot CLIs never heartbeat, so the hub may hold no env fingerprint for this node and its anti-abuse
93
95
  // layer then 403s /a2a/fetch (`bulk_fetch_blocked: IP antibody`, #555). A fingerprinted hello
94
96
  // (rotate:false + preserveCredentials:true) neither requests nor applies credential mutation while establishing
@@ -117,6 +119,34 @@ export async function runReuseCommand(argv, deps = {}) {
117
119
  return emit(mapError(e), ctx);
118
120
  }
119
121
  }
122
+ function createReuseFetcherFromEnv(env, deps) {
123
+ const hubMode = configuredHubMode(env);
124
+ if (hubMode === 'public') {
125
+ return createRecipeHubFromEnv(env, deps.connectHub ?? connectPublicHub);
126
+ }
127
+ const proxy = (deps.resolveProxyClient ?? proxyClientFromEnv)(env);
128
+ if (!proxy)
129
+ throw new Error('private Hub proxy is not configured');
130
+ return {
131
+ fetchAssetById: async (assetId) => {
132
+ const body = await proxy.fetchAsset({ assetId, expectedHubMode: 'private' });
133
+ const root = recordValue(body);
134
+ const payload = recordValue(root['payload']);
135
+ const assets = Array.isArray(root['assets']) ? root['assets'] : Array.isArray(payload['assets']) ? payload['assets'] : [];
136
+ const asset = assets.find((candidate) => {
137
+ const record = recordValue(candidate);
138
+ return record['asset_id'] === assetId || record['id'] === assetId;
139
+ });
140
+ return asset && typeof asset === 'object' && !Array.isArray(asset) ? asset : null;
141
+ },
142
+ };
143
+ }
144
+ function configuredHubMode(env) {
145
+ const value = String(env['EVOMAP_HUB_MODE'] ?? 'public').trim().toLowerCase();
146
+ if (value === 'public' || value === 'private')
147
+ return value;
148
+ throw new Error('EVOMAP_HUB_MODE must be public or private');
149
+ }
120
150
  /** Flags this CLI understands. parseReuseArgs walks argv and rejects anything outside this set with reason
121
151
  * `unsupported` so a typoed flag never silently falls through to a Hub round-trip — review blocker on V1 #283
122
152
  * (the previous tightening lived only in cliContracts.ts; dispatch.ts routes `reuse` here, so this is the path
@@ -288,7 +318,9 @@ function stripHubMetadata(asset) {
288
318
  return out;
289
319
  }
290
320
  function storeBaseDir(store, deps) {
291
- return store instanceof assetstore.LocalJsonlProvider ? store.baseDir : deps.assetsDir ?? events.assetsDir();
321
+ return store instanceof assetstore.LocalJsonlProvider
322
+ ? store.baseDir
323
+ : deps.assetsDir ?? events.assetsDir(deps.env ?? process.env);
292
324
  }
293
325
  function stringField(record, key) {
294
326
  const value = record[key];
@@ -299,7 +331,7 @@ function isContentAssetId(value) {
299
331
  }
300
332
  function logReuse(deps, opts, asset, source) {
301
333
  // AssetCallLog.append is best-effort (never throws) — a logging failure must not break the reuse write.
302
- const callLog = deps.callLog ?? new hubNs.AssetCallLog(events.assetCallLogPath());
334
+ const callLog = deps.callLog ?? new hubNs.AssetCallLog(events.assetCallLogPath(deps.env ?? process.env));
303
335
  callLog.append({
304
336
  action: 'asset_reuse',
305
337
  asset_id: asset.asset_id,
@@ -330,6 +362,9 @@ function hubErrorField(body) {
330
362
  const err = body['error'];
331
363
  return typeof err === 'string' ? err : undefined;
332
364
  }
365
+ function recordValue(value) {
366
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
367
+ }
333
368
  function mapError(e) {
334
369
  if (e instanceof ReuseIntegrityError) {
335
370
  return { ok: false, status: 'integrity_failed', message: e.message };
@@ -361,6 +396,15 @@ function mapError(e) {
361
396
  // a bad URL is a configuration gap, NOT an auth failure — conflating them would tell the operator/desktop adapter
362
397
  // to "log in" when the real fix is to correct the Hub URL.
363
398
  const msg = e instanceof Error ? e.message : String(e);
399
+ if (/failed to load EVOLVER_ENV_FILE/i.test(msg)) {
400
+ return { ok: false, status: 'unavailable', message: 'failed to load EVOLVER_ENV_FILE' };
401
+ }
402
+ if (/EVOMAP_HUB_MODE must be public or private/i.test(msg)) {
403
+ return { ok: false, status: 'unavailable', message: 'EVOMAP_HUB_MODE must be public or private' };
404
+ }
405
+ if (/private Hub proxy is not configured/i.test(msg)) {
406
+ return { ok: false, status: 'unavailable', message: 'private Hub proxy is not configured' };
407
+ }
364
408
  if (/Hub URL|EVOMAP_HUB_URL|A2A_HUB_URL/i.test(msg)) {
365
409
  return { ok: false, status: 'unavailable', message: redact(msg) };
366
410
  }
@@ -31,8 +31,8 @@ export const RUNTIME_CAPABILITY_MATRIX = {
31
31
  runtime: 'gemini',
32
32
  ingest: supported('normalized Gemini CLI session adapter'),
33
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'),
34
+ execute: experimental('Gemini CLI 0.46.0 deterministic real-runtime cycle smoke passed; provider-backed live E2E smoke is not complete'),
35
+ verify: experimental('real CLI edit, independent validation, Git patch proof, and cleanup passed with deterministic responses; provider-backed live E2E verification is not complete'),
36
36
  resume: unsupported('Gemini resume accepts latest/index; ingested UUIDs cannot be mapped reliably'),
37
37
  },
38
38
  antigravity: {
@@ -14,12 +14,16 @@ export interface ParsedSkill {
14
14
  validation: string[];
15
15
  preconditions: string[];
16
16
  }
17
+ export interface ParseSkillMdOptions {
18
+ /** Preserve validation commands from every matching section for fail-closed callers. */
19
+ completeValidationPlan?: boolean;
20
+ }
17
21
  /**
18
22
  * Parse a SKILL.md into a structured intermediate — faithful port of v1 `parseSkillMd`. Pure. Section keywords are
19
23
  * matched against lower-cased headings and include CJK synonyms (skills authored in Chinese), though the signal
20
24
  * tokenizer keeps ASCII `[a-z0-9_]` only, so a CJK skill's signals come from its (English) frontmatter description.
21
25
  */
22
- export declare function parseSkillMd(skillMd: string): ParsedSkill;
26
+ export declare function parseSkillMd(skillMd: string, opts?: ParseSkillMdOptions): ParsedSkill;
23
27
  /** Whether a validation command is safe to run as a Gene.validation entry (faithful port of v1
24
28
  * policyCheck.isValidationCommandAllowed): a `node …` command with no command substitution, no shell
25
29
  * metacharacters (outside quoted strings), and no node eval flags (-e/--eval/--print/-p). */
@@ -32,6 +36,7 @@ export interface SynthesizeOptions {
32
36
  skillName?: string;
33
37
  maxFiles?: number;
34
38
  }
39
+ export type SkillEvidenceMode = 'workflow_execution' | 'validation_only';
35
40
  export interface SynthesizeResult {
36
41
  gene: algo.GeneCandidate | null;
37
42
  errors: string[];
@@ -103,7 +108,7 @@ export interface SkillExecution {
103
108
  * hallucinating a successful run to pad the registry. Non-success executions are honest, so not checked. Returns
104
109
  * the rejection reason, or null when clean.
105
110
  */
106
- export declare function detectForgery(execution: SkillExecution): string | null;
111
+ export declare function detectForgery(execution: SkillExecution, evidenceMode?: SkillEvidenceMode): string | null;
107
112
  /** A synthesized Capsule (faithful to v1's shape; schema-conform / persistence is B3's concern). */
108
113
  export interface SkillCapsule {
109
114
  type: 'Capsule';
@@ -149,6 +154,7 @@ export type AssembleResult = {
149
154
  */
150
155
  export declare function assembleCapsule(gene: algo.GeneCandidate, execution: SkillExecution, opts?: {
151
156
  scenario?: string;
157
+ evidenceMode?: SkillEvidenceMode;
152
158
  }): AssembleResult;
153
159
  export interface ReverseDistillResult {
154
160
  gene: algo.GeneCandidate | null;
@@ -169,5 +175,6 @@ export interface ReverseDistillResult {
169
175
  */
170
176
  export declare function reverseDistill(parsed: ParsedSkill, execution?: SkillExecution, opts?: SynthesizeOptions & {
171
177
  scenario?: string;
178
+ evidenceMode?: SkillEvidenceMode;
172
179
  }): ReverseDistillResult;
173
180
  export {};
package/dist/skill2gep.js CHANGED
@@ -13,12 +13,21 @@ const SKILL2GEP_ID_PREFIX = 'gene_s2g_';
13
13
  const SKILL_MAX_FILES = 12;
14
14
  /** Validation-command allowlist prefixes (v1 policyCheck): only `node …` is a runnable Gene.validation entry. */
15
15
  const VALIDATION_ALLOWED_PREFIXES = ['node '];
16
+ function sectionHeadingMatches(heading, keyword) {
17
+ if (/^[a-z0-9 ]+$/i.test(keyword)) {
18
+ const forms = keyword === 'verify'
19
+ ? ['verify', 'verification', 'verifications']
20
+ : [keyword, `${keyword}s`];
21
+ return forms.some((form) => new RegExp('(^|[^a-z0-9])' + form + '($|[^a-z0-9])', 'i').test(heading));
22
+ }
23
+ return heading.includes(keyword);
24
+ }
16
25
  /**
17
26
  * Parse a SKILL.md into a structured intermediate — faithful port of v1 `parseSkillMd`. Pure. Section keywords are
18
27
  * matched against lower-cased headings and include CJK synonyms (skills authored in Chinese), though the signal
19
28
  * tokenizer keeps ASCII `[a-z0-9_]` only, so a CJK skill's signals come from its (English) frontmatter description.
20
29
  */
21
- export function parseSkillMd(skillMd) {
30
+ export function parseSkillMd(skillMd, opts = {}) {
22
31
  const text = String(skillMd || '');
23
32
  // --- frontmatter (--- … --- block of key: value lines, keys lower-cased) ---
24
33
  const frontmatter = {};
@@ -35,15 +44,20 @@ export function parseSkillMd(skillMd) {
35
44
  // --- sections: split by `##+ heading`; content before the first heading is `_preamble`. A repeated heading
36
45
  // resets its block (last occurrence wins), matching v1. ---
37
46
  const lines = { _preamble: [] };
47
+ const sectionOccurrences = [{ key: '_preamble', lines: [] }];
38
48
  let currentKey = '_preamble';
49
+ let currentOccurrence = sectionOccurrences[0];
39
50
  body.split(/\n/).forEach((line) => {
40
51
  const hdr = line.match(/^##+\s+(.+?)\s*$/);
41
52
  if (hdr) {
42
53
  currentKey = hdr[1].toLowerCase().trim();
43
54
  lines[currentKey] = [];
55
+ currentOccurrence = { key: currentKey, lines: [] };
56
+ sectionOccurrences.push(currentOccurrence);
44
57
  }
45
58
  else {
46
59
  (lines[currentKey] ??= []).push(line);
60
+ currentOccurrence.lines.push(line);
47
61
  }
48
62
  });
49
63
  const sections = {};
@@ -70,6 +84,11 @@ export function parseSkillMd(skillMd) {
70
84
  }
71
85
  return out.join('\n');
72
86
  };
87
+ /** Every matching section occurrence, including repeated headings, in document order. */
88
+ const pickSectionOccurrencesAll = (keywords) => sectionOccurrences
89
+ .filter(({ key }) => keywords.some((kw) => sectionHeadingMatches(key, kw)))
90
+ .map(({ lines: occurrenceLines }) => occurrenceLines.join('\n').trim())
91
+ .join('\n');
73
92
  /** Every markdown list item → one step, in document order, length-bounded (default 5..300). */
74
93
  const extractSteps = (block, opts) => {
75
94
  const minLen = opts && typeof opts.minLen === 'number' ? opts.minLen : 5;
@@ -109,7 +128,10 @@ export function parseSkillMd(skillMd) {
109
128
  ]));
110
129
  // --- validation: the bash/sh fenced commands in the validation/test section (non-comment, ≤300) ---
111
130
  const validation = [];
112
- const valBlock = pickSection(['validation', 'test', 'verify', 'check', '校验', '验证', '测试', '检查']);
131
+ const validationKeywords = ['validation', 'test', 'verify', 'check', '校验', '验证', '测试', '检查'];
132
+ const valBlock = opts.completeValidationPlan
133
+ ? pickSectionOccurrencesAll(validationKeywords)
134
+ : pickSection(validationKeywords);
113
135
  const fenceRe = /```(?:bash|sh|shell)?\s*\n([\s\S]*?)\n```/g;
114
136
  let fence;
115
137
  while ((fence = fenceRe.exec(valBlock)) !== null) {
@@ -129,7 +151,7 @@ export function parseSkillMd(skillMd) {
129
151
  signals_match: signals.slice(0, 8),
130
152
  strategy: strategy.slice(0, MAX_STRATEGY_STEPS),
131
153
  avoid: avoid.slice(0, 5),
132
- validation: validation.slice(0, 5),
154
+ validation: opts.completeValidationPlan ? validation : validation.slice(0, 5),
133
155
  preconditions: preconditions.slice(0, 4),
134
156
  };
135
157
  }
@@ -351,7 +373,7 @@ const shortHash = (s) => createHash('sha256').update(String(s ?? '')).digest('he
351
373
  * hallucinating a successful run to pad the registry. Non-success executions are honest, so not checked. Returns
352
374
  * the rejection reason, or null when clean.
353
375
  */
354
- export function detectForgery(execution) {
376
+ export function detectForgery(execution, evidenceMode = 'workflow_execution') {
355
377
  const trace = Array.isArray(execution?.trace) ? execution.trace : [];
356
378
  const files = Number(execution?.blast_radius?.files ?? 0);
357
379
  const lines = Number(execution?.blast_radius?.lines ?? 0);
@@ -359,7 +381,7 @@ export function detectForgery(execution) {
359
381
  return null;
360
382
  if (trace.length === 0)
361
383
  return 'empty_execution_trace';
362
- if (files === 0 && lines === 0)
384
+ if (evidenceMode === 'workflow_execution' && files === 0 && lines === 0)
363
385
  return 'zero_blast_radius_with_success';
364
386
  if (!trace.some((t) => Number.isInteger(t?.exit)))
365
387
  return 'no_exit_code_in_trace';
@@ -410,9 +432,13 @@ export function assembleCapsule(gene, execution, opts = {}) {
410
432
  confidence: Math.max(0, Math.min(1, score)),
411
433
  blast_radius: { files, lines },
412
434
  outcome: { status, score },
413
- success_reason: status === 'success' ? (execution?.success_reason || 'Skill workflow completed and all declared validations passed.') : null,
435
+ success_reason: status === 'success'
436
+ ? (execution?.success_reason || (opts.evidenceMode === 'validation_only'
437
+ ? 'All declared validation commands passed in the local verifier.'
438
+ : 'Skill workflow completed and all declared validations passed.'))
439
+ : null,
414
440
  env_fingerprint: bootstrap.captureEnvFingerprint(),
415
- source_type: 'skill2gep_hook',
441
+ source_type: opts.evidenceMode === 'validation_only' ? 'skill2gep_validation' : 'skill2gep_hook',
416
442
  strategy: Array.isArray(gene.strategy) ? [...gene.strategy] : [],
417
443
  content: execution?.content_summary || buildContentSummary(trace, execution?.blast_radius),
418
444
  execution_trace: trace.map((t, i) => ({
@@ -438,12 +464,15 @@ export function reverseDistill(parsed, execution = {}, opts = {}) {
438
464
  let capsule = null;
439
465
  let capsuleDiagnostic = null;
440
466
  if (execution?.status) {
441
- const forgery = detectForgery(execution);
467
+ const forgery = detectForgery(execution, opts.evidenceMode);
442
468
  if (forgery) {
443
469
  capsuleDiagnostic = { reason: 'capsule_rejected_forgery', detail: forgery };
444
470
  }
445
471
  else {
446
- const r = assembleCapsule(gene, execution, opts.scenario ? { scenario: opts.scenario } : {});
472
+ const r = assembleCapsule(gene, execution, {
473
+ ...(opts.scenario ? { scenario: opts.scenario } : {}),
474
+ ...(opts.evidenceMode ? { evidenceMode: opts.evidenceMode } : {}),
475
+ });
447
476
  if (r.ok)
448
477
  capsule = r.capsule;
449
478
  else
@@ -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?: SynthesizeOptions & {
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
  *
@@ -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 existing = (await deps.store.list('Gene', 1000)).map((g) => ({
60
- id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
61
- signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
62
- }));
63
- const r = algo.intakeGene(gene, existing);
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)`, severity: 'info' },
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 = { ...capsule, gene: geneId };
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.0-beta.14",
3
+ "version": "2.0.0-beta.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "evolver CLI (status/watch/cycles/rebuild-views/...)",
@@ -20,12 +20,12 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@evomap/evolver-core": "2.0.0-beta.14",
24
- "@evomap/evolver-adapter-public": "2.0.0-beta.14",
25
- "@evomap/evolver-mcp": "2.0.0-beta.14",
26
- "@evomap/evolver-proxy": "2.0.0-beta.14",
27
- "@evomap/evolver-runtime-adapters": "2.0.0-beta.14",
28
- "@evomap/evolver-webui": "2.0.0-beta.14"
23
+ "@evomap/evolver-core": "2.0.0-beta.16",
24
+ "@evomap/evolver-adapter-public": "2.0.0-beta.16",
25
+ "@evomap/evolver-mcp": "2.0.0-beta.16",
26
+ "@evomap/evolver-proxy": "2.0.0-beta.16",
27
+ "@evomap/evolver-runtime-adapters": "2.0.0-beta.16",
28
+ "@evomap/evolver-webui": "2.0.0-beta.16"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",