@hmharness/cli 0.21.3 → 0.22.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.
@@ -1 +1,8 @@
1
- export declare function runTaskAblation(write: (s: string) => void, home: () => string, runs: number, difficulty?: 'easy' | 'mid'): Promise<void>;
1
+ export declare function runTaskAblation(write: (s: string) => void, home: () => string, runs: number, difficulty?: 'easy' | 'mid' | 'hard'): Promise<void>;
2
+ /**
3
+ * Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
4
+ * claims a band is measurable, run each candidate task bare and measure its
5
+ * actual failure rate. Admission to the measurable band is 20-80% bare
6
+ * failure — the author's intuition about difficulty is not the instrument.
7
+ */
8
+ export declare function runBareCalibration(write: (s: string) => void, difficulty: 'easy' | 'mid' | 'hard', probes: number): Promise<void>;
@@ -26,10 +26,18 @@ const TASKS = [
26
26
  { text: '用 list_dir 列出 G:/hmharness/packages 下名为 kernel 的目录是否存在,只回复 是 或 否。', expect: '是', label: 'exists-check' },
27
27
  ];
28
28
  /**
29
- * MID-difficulty band (§26's measurable zone): multi-step extraction where
30
- * bare-prompt runs sometimes slip — counting, sorted enumeration, version
31
- * arithmetic. Expected values verified against the repo at authoring time.
29
+ * HARD band: cross-file aggregation and format transforms — models slip
30
+ * here more often. Expected values verified against the repo at authoring.
32
31
  */
32
+ const HARD_TASKS = [
33
+ { text: '分别读取 G:/hmharness/packages/kernel/src/index.ts 和 G:/hmharness/packages/agent/src/index.ts 两个文件,统计两个文件中包含 export 的行数总和,只回复该数字。', expect: '29', label: 'cross-file-count' },
34
+ { text: '读取 G:/hmharness/packages/web/package.json,只回复 dependencies 中 qrcode 这一项的精确版本约束字符串(含符号),不要其他文字。', expect: '^1.5.4', label: 'dep-constraint' },
35
+ { text: '统计 G:/hmharness/packages/cognitive/src/__tests__ 和 G:/hmharness/packages/environments/src/__tests__ 两个目录中 .test.ts 结尾文件的总个数,只回复数字。', expect: '9', label: 'cross-dir-count' },
36
+ { text: '读取 G:/hmharness/package.json 的 version 字段,把其中的点全部换成短横线后回复结果,不要其他文字。', expect: '0-21-3', label: 'version-dashes' },
37
+ ];
38
+ function poolOf(difficulty) {
39
+ return difficulty === 'hard' ? HARD_TASKS : difficulty === 'mid' ? MID_TASKS : TASKS;
40
+ }
33
41
  const MID_TASKS = [
34
42
  { text: '用 read_file 读取 G:/hmharness/packages/kernel/src/index.ts,统计包含 export 的行数,只回复该数字。', expect: '16', label: 'count-export' },
35
43
  { text: '读取 G:/hmharness/packages/cli/package.json,按字母序只列出全部 @hmharness 开头的依赖名,逗号分隔不要空格。', expect: '@hmharness/agent,@hmharness/cognitive,@hmharness/domain-harmony,@hmharness/domain-ops,@hmharness/environments,@hmharness/evaluation,@hmharness/evolution,@hmharness/kernel,@hmharness/observability,@hmharness/sandbox,@hmharness/web', label: 'sorted-deps' },
@@ -55,7 +63,7 @@ function runOnce(task, bare, timeoutMs) {
55
63
  }
56
64
  export async function runTaskAblation(write, home, runs, difficulty = 'easy') {
57
65
  const homeDir = home();
58
- const pool = difficulty === 'mid' ? MID_TASKS : TASKS;
66
+ const pool = poolOf(difficulty);
59
67
  write(`Terminal 域消融 · ${difficulty} 难度 · ${pool.length} 个可验证任务 × ${runs} 轮 × 双臂(§26 工作域测量)\n`);
60
68
  let withOk = 0;
61
69
  let bareOk = 0;
@@ -89,3 +97,25 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy') {
89
97
  write(`结论 · 认知层 ${withOk}/${total} vs 裸 ${bareOk}/${total} → harness 结果层净贡献 ${(record.harnessDelta * 100).toFixed(1)}%\n`);
90
98
  write(DIM('(ARC 域测上限=诚实零;本域测工作范围=模型胜任区的结果增益)\n'));
91
99
  }
100
+ /**
101
+ * Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
102
+ * claims a band is measurable, run each candidate task bare and measure its
103
+ * actual failure rate. Admission to the measurable band is 20-80% bare
104
+ * failure — the author's intuition about difficulty is not the instrument.
105
+ */
106
+ export async function runBareCalibration(write, difficulty, probes) {
107
+ const pool = poolOf(difficulty);
108
+ write(`裸臂定标 · ${difficulty} 难度 · ${pool.length} 任务 × ${probes} 次裸跑(准入带=失败率 20%-80%)\n`);
109
+ for (const t of pool) {
110
+ let fails = 0;
111
+ for (let i = 0; i < probes; i++) {
112
+ const r = await runOnce(t.text, true, 240_000);
113
+ if (!r.output.includes(t.expect))
114
+ fails += 1;
115
+ }
116
+ const rate = Number((fails / probes).toFixed(2));
117
+ const band = rate === 0 ? '地板(剔除)' : rate >= 1 ? '天花板(剔除)' : rate >= 0.2 && rate <= 0.8 ? '可测带 ✓' : '边缘';
118
+ write(` ${t.label.padEnd(18)} 裸失败率 ${Math.round(rate * 100)}% → ${band}\n`);
119
+ }
120
+ write(DIM(' 定标纪律:只有可测带任务进消融池;地板/天花板任务测不出处理效应\n'));
121
+ }
package/dist/main.js CHANGED
@@ -1221,17 +1221,23 @@ flags:
1221
1221
  if (rest.includes('--task')) {
1222
1222
  // §26 in the WORKING domain: verifiable terminal mini-tasks, same
1223
1223
  // model, digest on vs HMH_NO_COGNITIVE=1 — result-level harness delta.
1224
- // --difficulty=mid is the measurable band (bare runs sometimes slip).
1224
+ // --difficulty selects the band; --calibrate bare-runs first (admission
1225
+ // to the measurable band = 20-80% bare failure, not author intuition).
1225
1226
  const rounds = Number(rest.find((a) => a.startsWith('--runs='))?.slice(7) ?? 1);
1226
- const difficulty = rest.includes('--difficulty=mid') ? 'mid' : 'easy';
1227
- const { runTaskAblation } = await import("./ablate-task.js");
1227
+ const difficulty = rest.includes('--difficulty=hard') ? 'hard' : rest.includes('--difficulty=mid') ? 'mid' : 'easy';
1228
+ const { runTaskAblation, runBareCalibration } = await import("./ablate-task.js");
1228
1229
  const { homeDir: hd } = await import('@hmharness/kernel');
1230
+ if (rest.includes('--calibrate')) {
1231
+ const probes = Number(rest.find((a) => a.startsWith('--probes='))?.slice(9) ?? 2);
1232
+ await runBareCalibration((s) => stdout.write(s), difficulty, Number.isFinite(probes) ? Math.min(Math.max(probes, 1), 4) : 2);
1233
+ return;
1234
+ }
1229
1235
  await runTaskAblation((s) => stdout.write(s), hd, Number.isFinite(rounds) ? Math.min(Math.max(rounds, 1), 5) : 1, difficulty);
1230
1236
  return;
1231
1237
  }
1232
1238
  if (!rest.includes('--env=arc3')) {
1233
- stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=easy|mid] | --stats\n');
1234
- stdout.write(DIM(' --env=arc3: ARC 域(上限); --task: terminal 域; --difficulty=mid: 中等难度区(结果层可测带); 结果落 cognitive/ablation.jsonl\n'));
1239
+ stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=easy|mid|hard] [--calibrate [--probes=N]] | --stats\n');
1240
+ stdout.write(DIM(' --calibrate: 裸臂定标(准入带=裸失败率20-80%); --difficulty=hard: 跨文件聚合带; 结果落 cognitive/ablation.jsonl\n'));
1235
1241
  return;
1236
1242
  }
1237
1243
  const steps = Number(rest.find((a) => a.startsWith('--steps='))?.slice(8) ?? 5);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.21.3",
3
+ "version": "0.22.0",
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",
@@ -43,17 +43,17 @@
43
43
  "build": "tsc -p tsconfig.build.json"
44
44
  },
45
45
  "dependencies": {
46
- "@hmharness/agent": "0.21.3",
47
- "@hmharness/cognitive": "0.21.3",
48
- "@hmharness/domain-harmony": "0.21.3",
49
- "@hmharness/domain-ops": "0.21.3",
50
- "@hmharness/environments": "0.21.3",
51
- "@hmharness/evaluation": "0.21.3",
52
- "@hmharness/evolution": "0.21.3",
53
- "@hmharness/kernel": "0.21.3",
54
- "@hmharness/observability": "0.21.3",
55
- "@hmharness/sandbox": "0.21.3",
56
- "@hmharness/web": "0.21.3",
46
+ "@hmharness/agent": "0.22.0",
47
+ "@hmharness/cognitive": "0.22.0",
48
+ "@hmharness/domain-harmony": "0.22.0",
49
+ "@hmharness/domain-ops": "0.22.0",
50
+ "@hmharness/environments": "0.22.0",
51
+ "@hmharness/evaluation": "0.22.0",
52
+ "@hmharness/evolution": "0.22.0",
53
+ "@hmharness/kernel": "0.22.0",
54
+ "@hmharness/observability": "0.22.0",
55
+ "@hmharness/sandbox": "0.22.0",
56
+ "@hmharness/web": "0.22.0",
57
57
  "qrcode": "^1.5.4"
58
58
  }
59
59
  }