@hmharness/cli 0.23.19 → 0.23.20

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.
@@ -1,3 +1,24 @@
1
+ /**
2
+ * One agent run IN-PROCESS, capturing the FINAL reply text — the exact same
3
+ * extraction the bench gate uses. (The earlier subprocess version captured
4
+ * raw stdout: thinking blocks + session lines + ANSI noise broke expect-exact
5
+ * assertions — a measurement artifact that misread "model fails" when the
6
+ * harness output was merely verbose. Same instrument, same reading.)
7
+ */
8
+ /**
9
+ * P2 research ladder (04 doc: Model-only vs Model+Harness vs Model+Cognitive OS).
10
+ * Three arms over the SAME tasks, one runner:
11
+ * model-only — both flags set (no cognitive digest, no experience layer;
12
+ * the agent keeps its tools — a toolless model cannot do
13
+ * these tasks at all, so this is the honest floor)
14
+ * model+harness — experience layer ON, cognitive digest OFF
15
+ * (HMH_NO_COGNITIVE only)
16
+ * model+cogOS — everything on (the shipped default)
17
+ * Records to cognitive/ablation.jsonl as type:'ladder3' with per-arm pass
18
+ * rates and the two ladder deltas (harness-vs-only, cogOS-vs-harness).
19
+ */
20
+ export type LadderArm = 'model-only' | 'model+harness' | 'model+cogOS';
21
+ export declare function runLadder3(write: (s: string) => void, home: () => string, runs?: number, difficulty?: 'easy' | 'mid' | 'hard'): Promise<void>;
1
22
  /** A run's outcome, signal-separated: a crash (timeout/rate-limit/provider)
2
23
  * is INFRASTRUCTURE noise, not the model answering wrong — mixing them
3
24
  * poisons the effect estimate (the -8.3% artifact). Crash = the run did
@@ -72,13 +72,93 @@ async function poolOf(difficulty, home, filter) {
72
72
  return MID_TASKS;
73
73
  return TASKS;
74
74
  }
75
- /**
76
- * One agent run IN-PROCESS, capturing the FINAL reply text — the exact same
77
- * extraction the bench gate uses. (The earlier subprocess version captured
78
- * raw stdout: thinking blocks + session lines + ANSI noise broke expect-exact
79
- * assertions — a measurement artifact that misread "model fails" when the
80
- * harness output was merely verbose. Same instrument, same reading.)
81
- */
75
+ export async function runLadder3(write, home, runs = 1, difficulty = 'easy') {
76
+ const { appendFile } = await import('node:fs/promises');
77
+ const { join } = await import('node:path');
78
+ const pool = difficulty === 'hard' ? HARD_TASKS : difficulty === 'mid' ? MID_TASKS : TASKS;
79
+ const armFlags = {
80
+ 'model-only': { cog: '1', ctx: '1' },
81
+ 'model+harness': { cog: '1' },
82
+ 'model+cogOS': {},
83
+ };
84
+ const tally = {
85
+ 'model-only': { ok: 0, n: 0, crash: 0 },
86
+ 'model+harness': { ok: 0, n: 0, crash: 0 },
87
+ 'model+cogOS': { ok: 0, n: 0, crash: 0 },
88
+ };
89
+ write(`三臂阶梯(P2: Model-only vs Model+Harness vs Model+Cognitive OS)· ${difficulty} 带 · ${pool.length} 任务 × ${runs} 轮 × 3 臂\n`);
90
+ for (let r = 1; r <= runs; r++) {
91
+ for (const task of pool) {
92
+ for (const arm of ['model-only', 'model+harness', 'model+cogOS']) {
93
+ const prevCog = process.env.HMH_NO_COGNITIVE;
94
+ const prevCtx = process.env.HMH_NO_CONTEXT;
95
+ const flags = armFlags[arm];
96
+ if (flags.cog)
97
+ process.env.HMH_NO_COGNITIVE = flags.cog;
98
+ else
99
+ delete process.env.HMH_NO_COGNITIVE;
100
+ if (flags.ctx)
101
+ process.env.HMH_NO_CONTEXT = flags.ctx;
102
+ else
103
+ delete process.env.HMH_NO_CONTEXT;
104
+ let out = '';
105
+ let crashed = false;
106
+ try {
107
+ const { runAgentTask, buildRegistry } = await import('@hmharness/agent');
108
+ const { loadConfig } = await import('@hmharness/kernel');
109
+ const { reg } = await buildRegistry({ mcp: false });
110
+ await Promise.race([
111
+ runAgentTask({
112
+ task: task.text,
113
+ registry: reg,
114
+ cfg: await loadConfig(),
115
+ yes: true,
116
+ events: { onFinal: (res) => { out = res.text; } },
117
+ }),
118
+ new Promise((_, reject) => setTimeout(() => reject(new Error('ladder run timeout')), 240_000)),
119
+ ]).catch((err) => { if (!out)
120
+ throw err; return undefined; });
121
+ }
122
+ catch {
123
+ crashed = true;
124
+ }
125
+ // restore flags exactly
126
+ if (prevCog === undefined)
127
+ delete process.env.HMH_NO_COGNITIVE;
128
+ else
129
+ process.env.HMH_NO_COGNITIVE = prevCog;
130
+ if (prevCtx === undefined)
131
+ delete process.env.HMH_NO_CONTEXT;
132
+ else
133
+ process.env.HMH_NO_CONTEXT = prevCtx;
134
+ const pass = !crashed && task.check(out);
135
+ tally[arm].n += 1;
136
+ if (crashed)
137
+ tally[arm].crash += 1;
138
+ if (pass)
139
+ tally[arm].ok += 1;
140
+ write(` r${r} ${task.label.padEnd(20)} ${arm.padEnd(13)} ${pass ? '✓' : crashed ? '⚡crash' : '✗'}\n`);
141
+ }
142
+ }
143
+ }
144
+ const rate = (a) => (tally[a].n ? Number((tally[a].ok / tally[a].n).toFixed(3)) : undefined);
145
+ const deltaHarness = rate('model+harness') !== undefined && rate('model-only') !== undefined ? Number((rate('model+harness') - rate('model-only')).toFixed(3)) : undefined;
146
+ const deltaCognitive = rate('model+cogOS') !== undefined && rate('model+harness') !== undefined ? Number((rate('model+cogOS') - rate('model+harness')).toFixed(3)) : undefined;
147
+ write(`\n 通过率: model-only ${rate('model-only')} · model+harness ${rate('model+harness')} · model+cogOS ${rate('model+cogOS')}\n`);
148
+ write(` 阶梯差: harness−only ${deltaHarness} · cogOS−harness ${deltaCognitive}\n`);
149
+ const record = {
150
+ at: new Date().toISOString(),
151
+ type: 'ladder3',
152
+ difficulty,
153
+ runs,
154
+ tasks: pool.length,
155
+ tally,
156
+ rates: { 'model-only': rate('model-only'), 'model+harness': rate('model+harness'), 'model+cogOS': rate('model+cogOS') },
157
+ deltaHarness,
158
+ deltaCognitive,
159
+ };
160
+ await appendFile(join(home(), 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
161
+ }
82
162
  async function runOnce(task, bare, timeoutMs) {
83
163
  const prevCog = process.env.HMH_NO_COGNITIVE;
84
164
  const prevCtx = process.env.HMH_NO_CONTEXT;
package/dist/main.js CHANGED
@@ -1377,8 +1377,14 @@ flags:
1377
1377
  const rounds = Number(rest.find((a) => a.startsWith('--runs='))?.slice(7) ?? 1);
1378
1378
  const difficulty = rest.includes('--difficulty=bench') ? 'bench' : rest.includes('--difficulty=hard') ? 'hard' : rest.includes('--difficulty=mid') ? 'mid' : 'easy';
1379
1379
  const filter = rest.find((a) => a.startsWith('--filter='))?.slice(9);
1380
- const { runTaskAblation, runBareCalibration, runCompoundExperiment } = await import("./ablate-task.js");
1380
+ const { runTaskAblation, runBareCalibration, runCompoundExperiment, runLadder3 } = await import("./ablate-task.js");
1381
1381
  const { homeDir: hd } = await import('@hmharness/kernel');
1382
+ if (rest.includes('--ladder3')) {
1383
+ // P2 research ladder: Model-only vs Model+Harness vs Model+Cognitive
1384
+ // OS over the SAME tasks (04 doc 研究增强). Recorded as type:'ladder3'.
1385
+ await runLadder3((s) => stdout.write(s), hd, Number.isFinite(rounds) ? Math.min(Math.max(rounds, 1), 3) : 1, difficulty === 'bench' ? 'mid' : difficulty);
1386
+ return;
1387
+ }
1382
1388
  if (rest.includes('--compound')) {
1383
1389
  // cross-task compounding (the v0.22.4 pivot): arms differ in
1384
1390
  // TRAINING HISTORY inside an isolated home, not in prompt content.
@@ -1403,7 +1409,7 @@ flags:
1403
1409
  return;
1404
1410
  }
1405
1411
  if (!rest.includes('--env=arc3')) {
1406
- stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=..] [--filter=前缀] [--calibrate] | --compound [--target=cjk --trainer=train --train=4] | --stats\n');
1412
+ stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=..] [--filter=前缀] [--calibrate] | --compound [...] | --ladder3 [--runs=N] | --stats\n');
1407
1413
  stdout.write(DIM(' --compound: 跨任务复利(隔离家,训练前后同目标任务对照); --difficulty=bench: evolution 真实语料\n'));
1408
1414
  return;
1409
1415
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.23.19",
3
+ "version": "0.23.20",
4
4
  "description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -44,17 +44,17 @@
44
44
  "build": "tsc -p tsconfig.build.json"
45
45
  },
46
46
  "dependencies": {
47
- "@hmharness/agent": "0.23.19",
48
- "@hmharness/cognitive": "0.23.19",
49
- "@hmharness/domain-harmony": "0.23.19",
50
- "@hmharness/domain-ops": "0.23.19",
51
- "@hmharness/environments": "0.23.19",
52
- "@hmharness/evaluation": "0.23.19",
53
- "@hmharness/evolution": "0.23.19",
54
- "@hmharness/kernel": "0.23.19",
55
- "@hmharness/observability": "0.23.19",
56
- "@hmharness/sandbox": "0.23.19",
57
- "@hmharness/web": "0.23.19",
47
+ "@hmharness/agent": "0.23.20",
48
+ "@hmharness/cognitive": "0.23.20",
49
+ "@hmharness/domain-harmony": "0.23.20",
50
+ "@hmharness/domain-ops": "0.23.20",
51
+ "@hmharness/environments": "0.23.20",
52
+ "@hmharness/evaluation": "0.23.20",
53
+ "@hmharness/evolution": "0.23.20",
54
+ "@hmharness/kernel": "0.23.20",
55
+ "@hmharness/observability": "0.23.20",
56
+ "@hmharness/sandbox": "0.23.20",
57
+ "@hmharness/web": "0.23.20",
58
58
  "qrcode": "^1.5.4"
59
59
  }
60
60
  }