@hmharness/cli 0.21.0 → 0.21.1

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.
@@ -32,4 +32,5 @@ export declare function runArc3Play(write: (s: string) => void, opts: {
32
32
  levelsCompleted: number;
33
33
  levelCount: number;
34
34
  actions: number;
35
+ distinctActions: number;
35
36
  } | null>;
package/dist/arc3-play.js CHANGED
@@ -45,13 +45,15 @@ export async function runArc3Ablation(write, opts, deps) {
45
45
  at: new Date().toISOString(),
46
46
  game: gameId,
47
47
  steps: opts.steps,
48
- withCognitive: { levels: withCognitive.levelsCompleted, actions: withCognitive.actions, trajectoryId: withCognitive.trajectoryId },
49
- bare: { levels: bare.levelsCompleted, actions: bare.actions, trajectoryId: bare.trajectoryId },
48
+ withCognitive: { levels: withCognitive.levelsCompleted, actions: withCognitive.actions, distinctActions: withCognitive.distinctActions, trajectoryId: withCognitive.trajectoryId },
49
+ bare: { levels: bare.levelsCompleted, actions: bare.actions, distinctActions: bare.distinctActions, trajectoryId: bare.trajectoryId },
50
50
  harnessDeltaLevels: withCognitive.levelsCompleted - bare.levelsCompleted,
51
+ harnessDeltaDiversity: withCognitive.distinctActions - bare.distinctActions,
51
52
  };
52
53
  await mkdir(join(home, 'cognitive'), { recursive: true }).catch(() => undefined);
53
54
  await appendFile(join(home, 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
54
55
  write(`\n结论 · 认知层 ${withCognitive.levelsCompleted} 关 vs 裸提示词 ${bare.levelsCompleted} 关 → harness 净贡献 ${record.harnessDeltaLevels >= 0 ? '+' : ''}${record.harnessDeltaLevels} 关\n`);
56
+ write(` 动作多样性 认知层 ${withCognitive.distinctActions} 种 vs 裸 ${bare.distinctActions} 种(关卡持平时行为差异信号)\n`);
55
57
  write(`(样本=${opts.steps} 步/臂,单次实验;多次运行后 cognitive/ablation.jsonl 聚合更可靠)\n`);
56
58
  }
57
59
  export async function runArc3Play(write, opts, deps) {
@@ -153,6 +155,7 @@ export async function runArc3Play(write, opts, deps) {
153
155
  const score = await env.evaluate();
154
156
  const traj = rec.finish(Number(score.metrics.levelsCompleted ?? 0) > state0.levelsCompleted);
155
157
  await new TrajectoryStore(home).append(traj);
158
+ const distinctActions = new Set(traj.steps.map((s) => s.action.type)).size;
156
159
  const mem = new CognitiveMemory(home);
157
160
  await mem.load();
158
161
  await mem.write({
@@ -176,5 +179,6 @@ export async function runArc3Play(write, opts, deps) {
176
179
  levelsCompleted: Number(score.metrics.levelsCompleted ?? 0),
177
180
  levelCount: Number(score.metrics.levelCount ?? 0),
178
181
  actions: Number(score.metrics.actions ?? opts.steps),
182
+ distinctActions,
179
183
  };
180
184
  }
package/dist/main.js CHANGED
@@ -1192,8 +1192,34 @@ flags:
1192
1192
  if (sub === 'ablate') {
1193
1193
  // blueprint §26 final question, measured: same model, same game —
1194
1194
  // how much does the cognitive layer contribute vs a bare prompt?
1195
+ const { readFile } = await import('node:fs/promises');
1196
+ const { join: j } = await import('node:path');
1197
+ if (rest.includes('--stats')) {
1198
+ try {
1199
+ const text = await readFile(j(homeDir(), 'cognitive', 'ablation.jsonl'), 'utf8');
1200
+ const rows = text.split('\n').filter((l) => l.trim()).map((l) => JSON.parse(l));
1201
+ if (rows.length === 0) {
1202
+ stdout.write('(暂无消融记录——先跑 hmh cognitive ablate --env=arc3)\n');
1203
+ return;
1204
+ }
1205
+ const avg = (pick) => {
1206
+ const vals = rows.map(pick).filter((v) => Number.isFinite(v));
1207
+ return vals.length ? Number((vals.reduce((s, v) => s + v, 0) / vals.length).toFixed(2)) : Number.NaN;
1208
+ };
1209
+ stdout.write(`消融聚合 · ${rows.length} 次实验 · 平均 ${avg((r) => r.steps)} 步/臂\n`);
1210
+ stdout.write(` 关卡净贡献均值 ${avg((r) => r.harnessDeltaLevels)} · 动作多样性净贡献均值 ${avg((r) => r.harnessDeltaDiversity ?? Number.NaN)}\n`);
1211
+ const pos = rows.filter((r) => r.harnessDeltaLevels > 0).length;
1212
+ const neg = rows.filter((r) => r.harnessDeltaLevels < 0).length;
1213
+ stdout.write(` 关卡贡献分布: 正 ${pos} / 持平 ${rows.length - pos - neg} / 负 ${neg}\n`);
1214
+ stdout.write(DIM(' 关卡持平是常态(ARC 难度);多样性与后续关卡增益随样本累积显现\n'));
1215
+ }
1216
+ catch {
1217
+ stdout.write('(暂无消融记录——先跑 hmh cognitive ablate --env=arc3)\n');
1218
+ }
1219
+ return;
1220
+ }
1195
1221
  if (!rest.includes('--env=arc3')) {
1196
- stdout.write('用法: hmh cognitive ablate --env=arc3 [--game=<id前缀>] [--steps=N]\n');
1222
+ stdout.write('用法: hmh cognitive ablate --env=arc3 [--game=<id前缀>] [--steps=N] | --stats\n');
1197
1223
  stdout.write(DIM(' 双臂对照: 认知层(世界模型信念+经验教训) vs 裸提示词; 结果落 cognitive/ablation.jsonl\n'));
1198
1224
  return;
1199
1225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.21.0",
3
+ "version": "0.21.1",
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.0",
47
- "@hmharness/cognitive": "0.21.0",
48
- "@hmharness/domain-harmony": "0.21.0",
49
- "@hmharness/domain-ops": "0.21.0",
50
- "@hmharness/environments": "0.21.0",
51
- "@hmharness/evaluation": "0.21.0",
52
- "@hmharness/evolution": "0.21.0",
53
- "@hmharness/kernel": "0.21.0",
54
- "@hmharness/observability": "0.21.0",
55
- "@hmharness/sandbox": "0.21.0",
56
- "@hmharness/web": "0.21.0",
46
+ "@hmharness/agent": "0.21.1",
47
+ "@hmharness/cognitive": "0.21.1",
48
+ "@hmharness/domain-harmony": "0.21.1",
49
+ "@hmharness/domain-ops": "0.21.1",
50
+ "@hmharness/environments": "0.21.1",
51
+ "@hmharness/evaluation": "0.21.1",
52
+ "@hmharness/evolution": "0.21.1",
53
+ "@hmharness/kernel": "0.21.1",
54
+ "@hmharness/observability": "0.21.1",
55
+ "@hmharness/sandbox": "0.21.1",
56
+ "@hmharness/web": "0.21.1",
57
57
  "qrcode": "^1.5.4"
58
58
  }
59
59
  }