@hmharness/cli 0.23.18 → 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.
- package/dist/ablate-task.d.ts +21 -0
- package/dist/ablate-task.js +87 -7
- package/dist/main.js +58 -2
- package/package.json +12 -12
package/dist/ablate-task.d.ts
CHANGED
|
@@ -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
|
package/dist/ablate-task.js
CHANGED
|
@@ -72,13 +72,93 @@ async function poolOf(difficulty, home, filter) {
|
|
|
72
72
|
return MID_TASKS;
|
|
73
73
|
return TASKS;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
@@ -911,6 +911,56 @@ flags:
|
|
|
911
911
|
await tui(yes, rest.includes('--no-web'));
|
|
912
912
|
return;
|
|
913
913
|
}
|
|
914
|
+
if (cmd === 'lsp') {
|
|
915
|
+
// LSP management surface (Capability OS first slice: source trust)
|
|
916
|
+
await initHome();
|
|
917
|
+
const sub = rest[0] ?? 'list';
|
|
918
|
+
const { discoverServers } = await import('@hmharness/lsp');
|
|
919
|
+
const { listTrust, trustServer, untrustServer } = await import('@hmharness/lsp');
|
|
920
|
+
if (sub === 'list') {
|
|
921
|
+
const servers = discoverServers(true);
|
|
922
|
+
const trusted = new Map((await listTrust(homeDir())).map((t) => [t.id, t]));
|
|
923
|
+
if (servers.length === 0) {
|
|
924
|
+
stdout.write('(本机未发现任何 language server——PATH 与 DevEco 安装目录均无)\n');
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
for (const s of servers) {
|
|
928
|
+
const t = trusted.get(s.id);
|
|
929
|
+
const state = !t ? (s.origin.includes('DevEco-local') ? '自动信任(官方布局,首次使用钉哈希)' : '未信任(hmh lsp trust ' + s.id + ')') : `${t.autoTrusted ? '自动' : '手动'}信任@${t.trustedAt.slice(0, 10)} sha:${t.sha256.slice(0, 8)}…`;
|
|
930
|
+
stdout.write(` ${s.healthy ? '✓' : '✗'} ${s.id.padEnd(16)} ${s.origin.padEnd(18)} ${s.official ? 'official' : 'COMMUNITY'} · ${state}\n`);
|
|
931
|
+
if (!s.healthy && s.unhealthyReason)
|
|
932
|
+
stdout.write(DIM(` ${s.unhealthyReason}\n`));
|
|
933
|
+
}
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
if (sub === 'trust' || sub === 'untrust') {
|
|
937
|
+
const id = rest[1];
|
|
938
|
+
if (!id) {
|
|
939
|
+
stdout.write(`用法: hmh lsp ${sub} <server-id>(见 hmh lsp list)\n`);
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
if (sub === 'untrust') {
|
|
943
|
+
const ok = await untrustServer(homeDir(), id);
|
|
944
|
+
stdout.write(ok ? `已撤销 ${id} 的信任\n` : `${id} 本就未信任\n`);
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
const server = discoverServers().find((s) => s.id === id);
|
|
948
|
+
if (!server) {
|
|
949
|
+
stdout.write(`未发现 server '${id}'(hmh lsp list 查看可用项)\n`);
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
const r = await trustServer(homeDir(), server);
|
|
953
|
+
if (!r.ok) {
|
|
954
|
+
stdout.write(`信任失败: ${r.error}\n`);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
stdout.write(`已信任 ${id}(${server.origin})· sha256 钉住 ${r.sha256.slice(0, 16)}…\n`);
|
|
958
|
+
stdout.write(DIM(' 二进制变更后将被拒绝执行(篡改检测);撤销: hmh lsp untrust ' + id + '\n'));
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
stdout.write('用法: hmh lsp list | trust <id> | untrust <id> — 语言服务器发现与健康/信任状态\n');
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
914
964
|
if (cmd === 'cognitive') {
|
|
915
965
|
// Cognitive OS (blueprint 2026-09): read-only status one-pager. The
|
|
916
966
|
// subsystems are libraries first — they come alive when the agent loop
|
|
@@ -1327,8 +1377,14 @@ flags:
|
|
|
1327
1377
|
const rounds = Number(rest.find((a) => a.startsWith('--runs='))?.slice(7) ?? 1);
|
|
1328
1378
|
const difficulty = rest.includes('--difficulty=bench') ? 'bench' : rest.includes('--difficulty=hard') ? 'hard' : rest.includes('--difficulty=mid') ? 'mid' : 'easy';
|
|
1329
1379
|
const filter = rest.find((a) => a.startsWith('--filter='))?.slice(9);
|
|
1330
|
-
const { runTaskAblation, runBareCalibration, runCompoundExperiment } = await import("./ablate-task.js");
|
|
1380
|
+
const { runTaskAblation, runBareCalibration, runCompoundExperiment, runLadder3 } = await import("./ablate-task.js");
|
|
1331
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
|
+
}
|
|
1332
1388
|
if (rest.includes('--compound')) {
|
|
1333
1389
|
// cross-task compounding (the v0.22.4 pivot): arms differ in
|
|
1334
1390
|
// TRAINING HISTORY inside an isolated home, not in prompt content.
|
|
@@ -1353,7 +1409,7 @@ flags:
|
|
|
1353
1409
|
return;
|
|
1354
1410
|
}
|
|
1355
1411
|
if (!rest.includes('--env=arc3')) {
|
|
1356
|
-
stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=..] [--filter=前缀] [--calibrate] | --compound [
|
|
1412
|
+
stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=..] [--filter=前缀] [--calibrate] | --compound [...] | --ladder3 [--runs=N] | --stats\n');
|
|
1357
1413
|
stdout.write(DIM(' --compound: 跨任务复利(隔离家,训练前后同目标任务对照); --difficulty=bench: evolution 真实语料\n'));
|
|
1358
1414
|
return;
|
|
1359
1415
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.23.
|
|
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.
|
|
48
|
-
"@hmharness/cognitive": "0.23.
|
|
49
|
-
"@hmharness/domain-harmony": "0.23.
|
|
50
|
-
"@hmharness/domain-ops": "0.23.
|
|
51
|
-
"@hmharness/environments": "0.23.
|
|
52
|
-
"@hmharness/evaluation": "0.23.
|
|
53
|
-
"@hmharness/evolution": "0.23.
|
|
54
|
-
"@hmharness/kernel": "0.23.
|
|
55
|
-
"@hmharness/observability": "0.23.
|
|
56
|
-
"@hmharness/sandbox": "0.23.
|
|
57
|
-
"@hmharness/web": "0.23.
|
|
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
|
}
|