@evomap/evolver-cli 2.0.0-beta.0
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.d.ts +9 -0
- package/dist/antiGeneBenchmark.js +173 -0
- package/dist/antiGeneRollout.d.ts +14 -0
- package/dist/antiGeneRollout.js +276 -0
- package/dist/atp.d.ts +122 -0
- package/dist/atp.js +413 -0
- package/dist/atpAutoDeliver.d.ts +53 -0
- package/dist/atpAutoDeliver.js +197 -0
- package/dist/atpAutobuyPrompt.d.ts +48 -0
- package/dist/atpAutobuyPrompt.js +109 -0
- package/dist/autoDistillAntiGene.d.ts +63 -0
- package/dist/autoDistillAntiGene.js +396 -0
- package/dist/autoDistillLlm.d.ts +94 -0
- package/dist/autoDistillLlm.js +510 -0
- package/dist/autoDistillTranscript.d.ts +87 -0
- package/dist/autoDistillTranscript.js +364 -0
- package/dist/autoRecall.d.ts +25 -0
- package/dist/autoRecall.js +80 -0
- package/dist/autoexec.d.ts +237 -0
- package/dist/autoexec.js +1041 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +7 -0
- package/dist/cliContracts.d.ts +72 -0
- package/dist/cliContracts.js +815 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.js +10 -0
- package/dist/cursorRewrite.d.ts +42 -0
- package/dist/cursorRewrite.js +65 -0
- package/dist/cycleConsumer.d.ts +42 -0
- package/dist/cycleConsumer.js +519 -0
- package/dist/daemonLoop.d.ts +33 -0
- package/dist/daemonLoop.js +72 -0
- package/dist/dispatch.d.ts +10 -0
- package/dist/dispatch.js +75 -0
- package/dist/distillObserver.d.ts +33 -0
- package/dist/distillObserver.js +146 -0
- package/dist/distillPrimitives.d.ts +48 -0
- package/dist/distillPrimitives.js +142 -0
- package/dist/doctor.d.ts +54 -0
- package/dist/doctor.js +931 -0
- package/dist/geneValue.d.ts +37 -0
- package/dist/geneValue.js +97 -0
- package/dist/index.d.ts +193 -0
- package/dist/index.js +1135 -0
- package/dist/lifecycle.d.ts +75 -0
- package/dist/lifecycle.js +859 -0
- package/dist/login.d.ts +10 -0
- package/dist/login.js +38 -0
- package/dist/migrate/divergenceAudit.d.ts +29 -0
- package/dist/migrate/divergenceAudit.js +37 -0
- package/dist/migrate/fieldMap.d.ts +18 -0
- package/dist/migrate/fieldMap.js +68 -0
- package/dist/migrate/v1Import.d.ts +16 -0
- package/dist/migrate/v1Import.js +118 -0
- package/dist/phub.d.ts +18 -0
- package/dist/phub.js +284 -0
- package/dist/recall.d.ts +26 -0
- package/dist/recall.js +162 -0
- package/dist/recipe.d.ts +61 -0
- package/dist/recipe.js +564 -0
- package/dist/reflectionObserver.d.ts +8 -0
- package/dist/reflectionObserver.js +6 -0
- package/dist/reuse.d.ts +48 -0
- package/dist/reuse.js +300 -0
- package/dist/reuseReport.d.ts +20 -0
- package/dist/reuseReport.js +255 -0
- package/dist/reviewFilter.d.ts +4 -0
- package/dist/reviewFilter.js +6 -0
- package/dist/runtimeSessionSource.d.ts +9 -0
- package/dist/runtimeSessionSource.js +29 -0
- package/dist/setupHooks.d.ts +2 -0
- package/dist/setupHooks.js +410 -0
- package/dist/skill2gep.d.ts +144 -0
- package/dist/skill2gep.js +321 -0
- package/dist/skillDistill.d.ts +75 -0
- package/dist/skillDistill.js +342 -0
- package/dist/solo/breaker.d.ts +14 -0
- package/dist/solo/breaker.js +21 -0
- package/dist/solo/gitGuard.d.ts +17 -0
- package/dist/solo/gitGuard.js +62 -0
- package/dist/solo/mode.d.ts +12 -0
- package/dist/solo/mode.js +55 -0
- package/dist/thesis.d.ts +43 -0
- package/dist/thesis.js +179 -0
- package/dist/trajectoryExport.d.ts +1 -0
- package/dist/trajectoryExport.js +895 -0
- package/dist/valueDigest.d.ts +33 -0
- package/dist/valueDigest.js +94 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +14 -0
- package/package.json +38 -0
package/dist/thesis.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// `evolver thesis` (value-measurement slice 2) — the CONTROLLED A/B for the product thesis: does reusing a learned
|
|
2
|
+
// gene make the agent measurably better? Runs the same task suite twice through the REAL cycle engine — once with
|
|
3
|
+
// the learned-gene pool (evolver arm), once against an empty store (baseline arm) — and reports the objective
|
|
4
|
+
// pass-rate delta + verdict. `passed` comes from an external verifier (the suite's validation commands run in the
|
|
5
|
+
// throwaway worktree), never self-report. The agent work is `makeSafeExecute` (6 safety controls, deny-by-default),
|
|
6
|
+
// so a live run only touches the repo the operator explicitly allowlists via `--repo`. Distinct from `gene-value`
|
|
7
|
+
// (slice 1), which only OBSERVES production history; this is a controlled experiment.
|
|
8
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { join, resolve } from 'node:path';
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import { events, assetstore, algo, exec, benchmark } from '@evomap/evolver-core';
|
|
13
|
+
const NOW_FALLBACK = () => Date.now();
|
|
14
|
+
/** Build a minimal ProblemPattern from a task's signals (the cycle needs a problem to evolve against). */
|
|
15
|
+
function buildProblem(id, signals, now) {
|
|
16
|
+
return {
|
|
17
|
+
id, signature: `thesis:${id}`, signatureV: 1,
|
|
18
|
+
firstSeenAt: new Date(now - 1000).toISOString(), lastSeenAt: new Date(now).toISOString(),
|
|
19
|
+
occurrences: 3, linkedSignals: [...signals], resolvedBy: null, status: 'open',
|
|
20
|
+
value: { severity: 1, reach: 1, strategicFit: 1, novelty: 0, costEst: 0 },
|
|
21
|
+
consecutiveFailures: 0, cooldownUntil: null, extensions: {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const sh = (cmd, args, cwd) => new Promise((res) => { const c = spawn(cmd, [...args], { cwd, shell: false }); c.on('close', (code) => res(code ?? -1)); c.on('error', () => res(-1)); });
|
|
25
|
+
const parseFlags = (argv) => {
|
|
26
|
+
const out = {};
|
|
27
|
+
for (let i = 0; i < argv.length; i++) {
|
|
28
|
+
const a = argv[i];
|
|
29
|
+
if (a?.startsWith('--')) {
|
|
30
|
+
const next = argv[i + 1];
|
|
31
|
+
if (next !== undefined && !next.startsWith('--')) {
|
|
32
|
+
out[a.slice(2)] = next;
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
out[a.slice(2)] = '';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
};
|
|
41
|
+
const pct = (r) => `${(r * 100).toFixed(0)}%`;
|
|
42
|
+
/**
|
|
43
|
+
* `evolver thesis --suite <file> [--repo <allowlisted>] [--min-samples N] [--min-delta D] [--interleave] [--json]`.
|
|
44
|
+
* Runs the controlled A/B and prints baseline-vs-evolver pass rates + the verdict. A LIVE run needs `--repo` (the
|
|
45
|
+
* single allowlisted root the agent may touch); tests inject `deps.execute` instead.
|
|
46
|
+
*/
|
|
47
|
+
export async function runThesisCommand(argv, deps = {}) {
|
|
48
|
+
const flags = parseFlags(argv);
|
|
49
|
+
if (!flags['suite']) {
|
|
50
|
+
process.stderr.write('用法: evolver thesis --suite <file> [--repo <allowlisted>] [--min-samples N] [--min-delta D] [--alpha A] [--target-power P] [--interleave] [--json]\n');
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
let suite;
|
|
54
|
+
try {
|
|
55
|
+
const parsed = JSON.parse(readFileSync(resolve(flags['suite']), 'utf8'));
|
|
56
|
+
if (!parsed || typeof parsed !== 'object' || !Array.isArray(parsed.tasks))
|
|
57
|
+
throw new Error('suite must be an object with a tasks[] array');
|
|
58
|
+
suite = parsed;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
process.stderr.write(`thesis: cannot read --suite (${e instanceof Error ? e.message : String(e)})\n`);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
if (suite.tasks.length === 0) {
|
|
65
|
+
process.stderr.write('thesis: suite has no tasks\n');
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
const now = deps.now ?? NOW_FALLBACK;
|
|
69
|
+
// Live run needs an external verifier — empty suite.validation would let the agent's own success solidify a
|
|
70
|
+
// Capsule (contrary to the pass/fail contract). Refuse early (Bugbot #168). Injected execute (tests) is exempt.
|
|
71
|
+
if (!deps.execute && !flags['repo']) {
|
|
72
|
+
process.stderr.write('thesis: a live A/B needs --repo <allowlisted> (the only repo the agent may touch). Refusing to run without it.\n');
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
if (!deps.execute && (!Array.isArray(suite.validation) || suite.validation.length === 0)) {
|
|
76
|
+
process.stderr.write('thesis: a controlled A/B needs an external verifier — add a non-empty "validation" array to the suite. Refusing (passed must not come from agent self-report).\n');
|
|
77
|
+
return 1;
|
|
78
|
+
}
|
|
79
|
+
// HERMETIC experiment (Bugbot #168): the evolver arm READS genes from the pool but its cycle WRITES (capsules,
|
|
80
|
+
// evolution events) must NOT land in production — that would pollute real selection + bans. So seed a THROWAWAY
|
|
81
|
+
// evolver store with a copy of the pool's genes; both arms write only into temp stores that are discarded after.
|
|
82
|
+
const readPool = deps.pool ?? new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
83
|
+
const expDir = mkdtempSync(join(tmpdir(), 'thesis-exp-'));
|
|
84
|
+
const evolverStore = new assetstore.LocalJsonlProvider(join(expDir, 'evolver'));
|
|
85
|
+
const baseline = new assetstore.LocalJsonlProvider(join(expDir, 'baseline'));
|
|
86
|
+
for (const g of await readPool.list('Gene', 100_000))
|
|
87
|
+
await evolverStore.put(g); // read prod genes, write experiment capsules to temp
|
|
88
|
+
// The agent: injected fake (tests) OR makeSafeExecute over the operator-allowlisted repo (live). The resolver
|
|
89
|
+
// store is the temp evolverStore (baseline selects no gene, so it embeds none — no cross-arm contamination).
|
|
90
|
+
let execute = deps.execute;
|
|
91
|
+
if (!execute) {
|
|
92
|
+
const repo = resolve(flags['repo']);
|
|
93
|
+
const validate = async (_m, _d, cwd) => {
|
|
94
|
+
for (const cmd of suite.validation) {
|
|
95
|
+
const [c, ...a] = cmd.split(' ');
|
|
96
|
+
if (await sh(c, a, cwd) !== 0)
|
|
97
|
+
return { passed: false, score: 0.2 };
|
|
98
|
+
}
|
|
99
|
+
return { passed: true, score: 0.95 };
|
|
100
|
+
};
|
|
101
|
+
execute = exec.makeSafeExecute(repo, evolverStore, { allowedRoots: [repo] }, { validate });
|
|
102
|
+
}
|
|
103
|
+
const agent = execute;
|
|
104
|
+
const solver = benchmark.makeEvolutionThesisSolver({
|
|
105
|
+
pool: evolverStore, baseline, now, execute: agent,
|
|
106
|
+
toCycleOpts: (t) => ({
|
|
107
|
+
problem: buildProblem(t.id, t.input.signals, now()),
|
|
108
|
+
signals: t.input.signals,
|
|
109
|
+
category: t.input.category ?? 'repair',
|
|
110
|
+
target: t.input.target ?? 't.ts',
|
|
111
|
+
expectedEffect: t.input.expectedEffect ?? 'fix',
|
|
112
|
+
summary: t.input.summary ?? `thesis ${t.id}`,
|
|
113
|
+
confidence: t.input.confidence ?? 0.9,
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
const tasks = suite.tasks.map((s) => ({
|
|
117
|
+
id: s.id,
|
|
118
|
+
input: {
|
|
119
|
+
signals: s.signals,
|
|
120
|
+
...(s.category ? { category: s.category } : {}),
|
|
121
|
+
...(s.target ? { target: s.target } : {}),
|
|
122
|
+
...(s.expectedEffect ? { expectedEffect: s.expectedEffect } : {}),
|
|
123
|
+
...(s.summary ? { summary: s.summary } : {}),
|
|
124
|
+
...(s.confidence != null ? { confidence: s.confidence } : {}),
|
|
125
|
+
},
|
|
126
|
+
}));
|
|
127
|
+
const opts = { interleave: 'interleave' in flags };
|
|
128
|
+
if (flags['min-samples'])
|
|
129
|
+
opts.minSamples = Number(flags['min-samples']);
|
|
130
|
+
if (flags['min-delta'])
|
|
131
|
+
opts.minPassRateDelta = Number(flags['min-delta']);
|
|
132
|
+
if (flags['alpha'])
|
|
133
|
+
opts.alpha = Number(flags['alpha']);
|
|
134
|
+
if (flags['target-power'])
|
|
135
|
+
opts.targetPower = Number(flags['target-power']);
|
|
136
|
+
let report;
|
|
137
|
+
try {
|
|
138
|
+
report = await benchmark.runThesis({ name: suite.name || 'thesis', tasks }, solver, opts);
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
rmSync(expDir, { recursive: true, force: true });
|
|
142
|
+
}
|
|
143
|
+
if ('json' in flags) {
|
|
144
|
+
// requiredN is Infinity when minPassRateDelta is 0; plain JSON.stringify would turn it into null, which a
|
|
145
|
+
// consumer can't tell apart from a missing/invalid value. Serialize non-finite numbers as explicit strings.
|
|
146
|
+
const replacer = (_k, v) => typeof v === 'number' && !Number.isFinite(v) ? (v > 0 ? 'Infinity' : v < 0 ? '-Infinity' : 'NaN') : v;
|
|
147
|
+
process.stdout.write(JSON.stringify(report, replacer) + '\n');
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
const a = report.evolver;
|
|
151
|
+
const b = report.baseline;
|
|
152
|
+
process.stdout.write(`thesis [${report.suite}] controlled A/B (verdict = practical delta AND statistical significance):\n`);
|
|
153
|
+
process.stdout.write(` baseline n=${b.n} pass=${pct(b.passRate)} avgCost=${b.avgCost.toFixed(2)} reuse=${pct(b.reuseRate)}\n`);
|
|
154
|
+
process.stdout.write(` evolver n=${a.n} pass=${pct(a.passRate)} avgCost=${a.avgCost.toFixed(2)} reuse=${pct(a.reuseRate)}\n`);
|
|
155
|
+
process.stdout.write(` Δpass=${(report.passRateDelta * 100).toFixed(1)}pt Δcost=${report.costDelta.toFixed(2)} → ${report.verdict}\n`);
|
|
156
|
+
process.stdout.write(` significance: p=${report.pValue.toFixed(3)} (z=${report.z.toFixed(2)}), 95% CI Δpass=[${(report.ciLow * 100).toFixed(1)}, ${(report.ciHigh * 100).toFixed(1)}]pt → ${report.significant ? 'significant' : 'not significant'}\n`);
|
|
157
|
+
const minDelta = opts.minPassRateDelta ?? 0.05;
|
|
158
|
+
const targetPower = opts.targetPower ?? 0.8;
|
|
159
|
+
const finiteReq = Number.isFinite(report.requiredN);
|
|
160
|
+
const reqN = finiteReq ? `${report.requiredN}` : '∞';
|
|
161
|
+
const ptStr = (minDelta * 100).toFixed(0);
|
|
162
|
+
process.stdout.write(` power: ${pct(report.power)} to detect a ${ptStr}pt effect; need ~${reqN}/arm for ${pct(targetPower)} power\n`);
|
|
163
|
+
if (report.verdict === 'insufficient_samples') {
|
|
164
|
+
process.stdout.write(` (need ≥${opts.minSamples ?? 30} samples per arm for a verdict — add tasks or lower --min-samples)\n`);
|
|
165
|
+
}
|
|
166
|
+
else if (!report.significant && !finiteReq) {
|
|
167
|
+
// requiredN is Infinity: no achievable effect to power for (minDelta is 0, or the baseline is already at the
|
|
168
|
+
// ceiling so a lift has no headroom). MORE SAMPLES WON'T HELP — don't mislabel it underpowered (Bugbot #286).
|
|
169
|
+
process.stdout.write(` (power undefined: no achievable ${ptStr}pt effect — set --min-delta > 0 and check the baseline isn't already at the ceiling; more samples won't help)\n`);
|
|
170
|
+
}
|
|
171
|
+
else if (!report.significant && Math.abs(report.passRateDelta) >= minDelta) {
|
|
172
|
+
process.stdout.write(` (delta clears the practical bar but is not statistically significant — more samples needed to confirm)\n`);
|
|
173
|
+
}
|
|
174
|
+
else if (report.verdict === 'no_significant_diff' && report.power < targetPower) {
|
|
175
|
+
// A null behind low power is UNDERPOWERED, not "no effect" — and here requiredN is finite, so more tasks fix it.
|
|
176
|
+
process.stdout.write(` (underpowered: this n could not reliably detect a ${ptStr}pt effect — 'no difference' is unconfirmed, not proven; run ~${reqN}/arm)\n`);
|
|
177
|
+
}
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runTrajectoryExport(argv: readonly string[]): Promise<number>;
|