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

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.
@@ -139,17 +139,19 @@ export async function runPublishCommand(args, deps = {}) {
139
139
  const validationCredits = extractCredits(validation.body);
140
140
  if (!validation.ok) {
141
141
  const reason = publishReasonFromResponse(validation.status, validation.body);
142
+ const detail = hubDetailFromBody(validation.body);
142
143
  if (parsed.dryRun && reason === 'quality_gate_failed') {
143
144
  bundle.gates.quality = 'fail';
144
145
  if (!bundle.blockReasons.includes('quality_gate_failed'))
145
146
  bundle.blockReasons.push('quality_gate_failed');
146
- return write(dryRunEnvelope(bundle, validationCredits), 0);
147
+ return write(dryRunEnvelope(bundle, validationCredits, detail), 0);
147
148
  }
148
149
  return write(publishFailure(reason, publishReasonMessage(reason), {
149
150
  retryable: publishRetryable(reason),
150
151
  mode: parsed.dryRun ? 'dry_run' : 'publish',
151
152
  gates: parsed.dryRun ? bundle.gates : { ...bundle.gates, quality: 'fail' },
152
153
  assets: bundle.assets,
154
+ ...(detail ? { detail } : {}),
153
155
  ...(validationCredits ? { credits: validationCredits } : {}),
154
156
  }), 1);
155
157
  }
@@ -160,11 +162,13 @@ export async function runPublishCommand(args, deps = {}) {
160
162
  const publishCredits = extractCredits(published.body);
161
163
  if (!published.ok) {
162
164
  const reason = publishReasonFromResponse(published.status, published.body);
165
+ const detail = hubDetailFromBody(published.body);
163
166
  return write(publishFailure(reason, publishReasonMessage(reason), {
164
167
  retryable: publishRetryable(reason),
165
168
  mode: 'publish',
166
169
  gates: bundle.gates,
167
170
  assets: bundle.assets,
171
+ ...(detail ? { detail } : {}),
168
172
  ...(publishCredits ? { credits: publishCredits } : {}),
169
173
  }), 1);
170
174
  }
@@ -488,7 +492,7 @@ function stripPublishMetadata(asset) {
488
492
  function storeBaseDir(store, deps) {
489
493
  return store instanceof assetstore.LocalJsonlProvider ? store.baseDir : deps.assetsDir ?? events.assetsDir();
490
494
  }
491
- function dryRunEnvelope(bundle, credits) {
495
+ function dryRunEnvelope(bundle, credits, blockDetail) {
492
496
  const suppressPayload = bundle.blockReasons.includes('leak_detected');
493
497
  return {
494
498
  ok: true,
@@ -497,6 +501,7 @@ function dryRunEnvelope(bundle, credits) {
497
501
  reversibility: REVERSIBILITY,
498
502
  blocked: bundle.blockReasons.length > 0,
499
503
  block_reasons: bundle.blockReasons,
504
+ ...(blockDetail ? { block_details: [blockDetail] } : {}),
500
505
  assets: bundle.assets,
501
506
  ...(suppressPayload ? {} : { payload: { assets: bundle.sanitized } }),
502
507
  gates: bundle.gates,
@@ -510,6 +515,7 @@ function publishFailure(reason, message, opts) {
510
515
  ...(opts.mode ? { mode: opts.mode } : {}),
511
516
  ...(opts.gates ? { gates: opts.gates } : {}),
512
517
  ...(opts.assets ? { assets: opts.assets } : {}),
518
+ ...(opts.detail ? { detail: opts.detail } : {}),
513
519
  ...(opts.credits ? { credits: opts.credits } : {}),
514
520
  reason,
515
521
  retryable: opts.retryable,
@@ -757,6 +763,43 @@ function payloadRecord(body) {
757
763
  const root = asRecord(body) ?? {};
758
764
  return asRecord(root['payload']) ?? root;
759
765
  }
766
+ // The Hub answers a rejected publish with the SPECIFIC rule that failed
767
+ // ("gene_validation_required: ..."), which our stable ContractReason enum
768
+ // necessarily flattens to `quality_gate_failed`. Keeping only the flattened code
769
+ // leaves every caller — the desktop wizard above all — with a red gate and no
770
+ // way to act on it, so the detail rides along in a separate additive field.
771
+ // Capped and control-character-stripped: it is Hub-authored text that ends up in
772
+ // a machine-readable envelope on stdout.
773
+ const HUB_DETAIL_MAX_CHARS = 300;
774
+ function stripControlChars(value) {
775
+ let out = '';
776
+ for (const ch of value) {
777
+ const code = ch.codePointAt(0) ?? 0;
778
+ out += code < 0x20 || code === 0x7f ? ' ' : ch;
779
+ }
780
+ return out;
781
+ }
782
+ function hubDetailFromBody(body) {
783
+ const root = asRecord(body) ?? {};
784
+ const payload = payloadRecord(body);
785
+ // Take the first candidate that ISN'T already a stable contract token: those
786
+ // are what `reason` carries, so emitting one here would repeat the flattened
787
+ // code this field exists to supplement. The Hub is free to put the token in
788
+ // `reason` and the rule text in `error` (or the reverse), so order alone
789
+ // cannot pick the informative one.
790
+ const raw = [
791
+ stringField(root, 'error'),
792
+ stringField(root, 'reason'),
793
+ stringField(payload, 'error'),
794
+ stringField(payload, 'reason'),
795
+ ].find((candidate) => candidate && !isStableContractReason(candidate.trim()));
796
+ if (!raw)
797
+ return undefined;
798
+ const detail = stripControlChars(raw).replace(/\s+/g, ' ').trim();
799
+ if (!detail)
800
+ return undefined;
801
+ return detail.length > HUB_DETAIL_MAX_CHARS ? `${detail.slice(0, HUB_DETAIL_MAX_CHARS)}…` : detail;
802
+ }
760
803
  function stableContractReasonFromBody(body) {
761
804
  const payload = payloadRecord(body);
762
805
  const reason = stringField(payload, 'reason') ?? stringField(payload, 'error');
@@ -1,9 +1,10 @@
1
1
  import { algo, type signals } from '@evomap/evolver-core';
2
2
  import type { NormalizedTurn } from '@evomap/evolver-runtime-adapters';
3
- /** Short matchable signal tokens from the STRONG signals only (toolName + a known error class). Every strong
4
- * signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
3
+ /** Short matchable signal tokens from STRONG signals (error classes) and SUCCESS signals (verified capabilities).
4
+ * Every strong signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
5
5
  * `Error: connection refused`), it falls back to its kind (`structured_error`/`error_result`) so a real strong
6
6
  * signal is never silently tokenless — keeping `signals_match.length === 0` an honest "no strong signal" gate.
7
+ * Success signals (#578) also produce tokens so a purely successful session can yield a matchable gene.
7
8
  * Deduped, ≤8. */
8
9
  export declare function signalTokens(sigs: readonly signals.ExtractedSignal[]): string[];
9
10
  /** Draft strategy steps = the agent's own substantive (non-meta) turns — boundary-trimmed (never chopped
@@ -2,7 +2,7 @@
2
2
  // `evolver ingest --distill` and the live distillObserver reuse ONE copy (no forked distill logic). Zero behavior
3
3
  // change vs the inline version: same tokens, same step drafting, same candidate shape. No I/O — the caller parses
4
4
  // the session into turns + extracts signals; this turns them into a draft GeneCandidate (or null when too thin).
5
- import { algo } from '@evomap/evolver-core';
5
+ import { algo, hub } from '@evomap/evolver-core';
6
6
  // Map a strong signal's free-text to a SHORT, matchable token (so a gene's signals_match stays a few
7
7
  // keywords, not a dumped error blob). Deterministic + testable; unknown errors fall back to the tool name only.
8
8
  const SIGNAL_ERROR_CLASSES = [
@@ -14,10 +14,11 @@ const SIGNAL_ERROR_CLASSES = [
14
14
  [/permission denied/i, 'permission-denied'],
15
15
  [/timed?\s?out/i, 'timeout'],
16
16
  ];
17
- /** Short matchable signal tokens from the STRONG signals only (toolName + a known error class). Every strong
18
- * signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
17
+ /** Short matchable signal tokens from STRONG signals (error classes) and SUCCESS signals (verified capabilities).
18
+ * Every strong signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
19
19
  * `Error: connection refused`), it falls back to its kind (`structured_error`/`error_result`) so a real strong
20
20
  * signal is never silently tokenless — keeping `signals_match.length === 0` an honest "no strong signal" gate.
21
+ * Success signals (#578) also produce tokens so a purely successful session can yield a matchable gene.
21
22
  * Deduped, ≤8. */
22
23
  export function signalTokens(sigs) {
23
24
  const set = new Set();
@@ -38,6 +39,22 @@ export function signalTokens(sigs) {
38
39
  if (!matched)
39
40
  set.add(s.kind);
40
41
  }
42
+ // A later failure invalidates an earlier successful intermediate command. Conversely, fail-then-pass remains a
43
+ // valid repair history because the last deterministic outcome is the verified success.
44
+ const lastOutcome = sigs.findLast((s) => s.strength === 'strong' || s.strength === 'weak' || (s.strength === 'success' && !s.needsAnalysis));
45
+ const terminalSuccess = lastOutcome?.strength === 'success' && !lastOutcome.needsAnalysis;
46
+ // Only confirmed terminal success enters the deterministic path. Prose marked needsAnalysis is left to transcript
47
+ // LLM distillation instead of triggering a material cycle before analysis has happened.
48
+ for (const s of terminalSuccess ? sigs : []) {
49
+ if (s.strength !== 'success' || s.needsAnalysis)
50
+ continue;
51
+ if (s.toolName)
52
+ set.add(s.toolName);
53
+ if (s.kind === 'verified_success')
54
+ set.add('verified-success');
55
+ else
56
+ set.add(s.kind);
57
+ }
41
58
  return [...set].slice(0, 8);
42
59
  }
43
60
  /** Trim free text to a clean step: collapse whitespace, and when longer than `cap` keep as much as fits, cutting
@@ -83,7 +100,7 @@ export function draftStrategy(turns) {
83
100
  for (const t of turns) {
84
101
  if (t.role !== 'assistant' || t.isMeta)
85
102
  continue;
86
- const raw = (t.text ?? '').replace(/\s+/g, ' ').trim();
103
+ const raw = hub.redactString(t.text ?? '').replace(/\s+/g, ' ').trim();
87
104
  if (raw.length < 40)
88
105
  continue; // too short to be a step
89
106
  if (isNarrationOnly(raw))
@@ -96,6 +113,17 @@ export function draftStrategy(turns) {
96
113
  }
97
114
  return steps.slice(-6); // the latest substantive actions (closest to the resolution)
98
115
  }
116
+ const GENERIC_SUCCESS_TOPICS = new Set([
117
+ 'added', 'adjusted', 'assistant', 'change', 'changed', 'changes', 'command', 'commands', 'complete',
118
+ 'completed', 'coverage', 'fixed', 'handling', 'implementation', 'passed', 'passing', 'regression', 'result',
119
+ 'results', 'successful', 'successfully', 'tests', 'updated', 'validation', 'verified',
120
+ ]);
121
+ function successTopicSignals(strategy) {
122
+ const text = strategy.join(' ');
123
+ return hub.extractTopicKeywords(text, undefined, 24, { minOccurrences: 1, preserveSourceOrder: true })
124
+ .filter((topic) => !GENERIC_SUCCESS_TOPICS.has(topic))
125
+ .slice(0, 4);
126
+ }
99
127
  /**
100
128
  * Assemble an UNPROVEN draft GeneCandidate from a parsed session, or null when too thin to distill (no strong
101
129
  * signal OR no substantive step). The single source of the "what makes a draftable session" gate + candidate
@@ -105,10 +133,36 @@ export function draftStrategy(turns) {
105
133
  export function draftGeneCandidate(turns, sigs, agent) {
106
134
  const signals_match = signalTokens(sigs);
107
135
  const strategy = draftStrategy(turns);
108
- if (signals_match.length === 0 || strategy.length === 0) {
136
+ const hadVerifiedSuccess = sigs.some((s) => s.strength === 'success' && !s.needsAnalysis);
137
+ const hasTerminalVerifiedSuccess = signals_match.includes('verified-success');
138
+ // 当只有成功信号(没有错误信号)时,走 innovate 路径而非 repair (#578):
139
+ // 一次成功的问题解决过程不应被分类为 repair —— 它是一个可复用的成功能力。
140
+ const hasStrongError = sigs.some((s) => s.strength === 'strong');
141
+ if (signals_match.length === 0 || strategy.length === 0 || !hasStrongError) {
142
+ // Do not let the capability sniffer resurrect a success that a later unresolved outcome already superseded.
143
+ if (hadVerifiedSuccess && !hasTerminalVerifiedSuccess && !hasStrongError)
144
+ return null;
109
145
  const hit = algo.sniffConversationCapabilities(turns)[0];
110
- if (!hit)
146
+ if (!hit) {
147
+ // Sniffer 也未命中:如果有 success 信号和 strategy(仅当 hasStrongError 为 false 才走到这里且 signals_match 非空),
148
+ // 仍然产出 gene,但标记为 innovate —— 这是一个被验证的能力,而非错误修复。
149
+ if (signals_match.length > 0 && strategy.length > 0) {
150
+ const topics = successTopicSignals(strategy);
151
+ // Generic runner + success tokens are not a reusable capability identity. Let the optional transcript-LLM
152
+ // path handle prose that has no safe discriminating topic instead of storing one global shell-success gene.
153
+ if (topics.length === 0)
154
+ return null;
155
+ const successSignals = [...new Set([...signals_match, ...topics])].slice(0, 8);
156
+ return {
157
+ category: 'innovate',
158
+ signals_match: successSignals,
159
+ strategy,
160
+ summary: `Auto-drafted from ${agent} session (UNPROVEN — curate via review): ${topics.slice(0, 3).join(', ')}`,
161
+ generation_meta: { source: 'distilled' },
162
+ };
163
+ }
111
164
  return null;
165
+ }
112
166
  const fallbackStrategy = hit.evidence;
113
167
  if (fallbackStrategy.length === 0)
114
168
  return null;
@@ -149,6 +203,8 @@ const GENERIC_NOVELTY_SIGNALS = new Set([
149
203
  'sh',
150
204
  'cmd',
151
205
  'command',
206
+ 'verified-success',
207
+ 'verified_success',
152
208
  ]);
153
209
  function normalizeSignalSet(values) {
154
210
  return new Set((values ?? []).map((value) => String(value).trim().toLowerCase()).filter(Boolean));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.14",
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.12",
24
- "@evomap/evolver-adapter-public": "2.0.0-beta.12",
25
- "@evomap/evolver-mcp": "2.0.0-beta.12",
26
- "@evomap/evolver-proxy": "2.0.0-beta.12",
27
- "@evomap/evolver-runtime-adapters": "2.0.0-beta.12",
28
- "@evomap/evolver-webui": "2.0.0-beta.12"
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"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",