@hmharness/cli 0.19.2 → 0.19.4
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/main.js +64 -1
- package/package.json +12 -12
package/dist/main.js
CHANGED
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
import readline from 'node:readline/promises';
|
|
25
25
|
import { stdin, stdout } from 'node:process';
|
|
26
26
|
import { readFile } from 'node:fs/promises';
|
|
27
|
+
import { mkdir, rm } from 'node:fs/promises';
|
|
27
28
|
import { join } from 'node:path';
|
|
29
|
+
import { tmpdir } from 'node:os';
|
|
28
30
|
import { stopWebDaemon, startWebDaemon, hmhWebUp, readWebPid } from "./web-daemon.js";
|
|
29
31
|
import { chat, homeDir, resolveProvider, initHome, latestSession, listProviders, listSessions, loadConfig, loadTranscript, mcpServerTools, Registry, runLoop, setChatRoute, setLocale, } from '@hmharness/kernel';
|
|
30
32
|
import { listSkills, listDrafts, promoteSkill, runBench, runEvolution, rollbackSkill, unpromoteSkill, } from '@hmharness/evolution';
|
|
@@ -955,8 +957,69 @@ flags:
|
|
|
955
957
|
stdout.write(` 规划门: 可信[${wm.plannerGate.trusted.join(',')}] 存疑[${wm.plannerGate.untrusted.join(',')}] 未知[${wm.plannerGate.unknown.join(',')}]\n`);
|
|
956
958
|
return;
|
|
957
959
|
}
|
|
960
|
+
if (sub === 'drift') {
|
|
961
|
+
// GOAL-005 on live data: did recorded runs actually serve their goals?
|
|
962
|
+
const { analyzeGoalDrift } = await import('@hmharness/cognitive');
|
|
963
|
+
const views = await analyzeGoalDrift(homeDir());
|
|
964
|
+
if (views.length === 0) {
|
|
965
|
+
stdout.write('(尚无带目标的轨迹——设置会话目标后再跑任务)\n');
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
for (const v of views.slice(0, 10)) {
|
|
969
|
+
stdout.write(` ${v.driftScore.toFixed(2).padEnd(5)} ${v.recommendation.padEnd(22)} ${v.goalDescription.slice(0, 60)}\n`);
|
|
970
|
+
for (const s of v.signals.slice(0, 2))
|
|
971
|
+
stdout.write(DIM(` ${s}\n`));
|
|
972
|
+
}
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
if (sub === 'skills') {
|
|
976
|
+
// SK-002 on live data: repeated successful action runs as candidates
|
|
977
|
+
const { skillCandidatesFromHistory } = await import('@hmharness/cognitive');
|
|
978
|
+
const candidates = await skillCandidatesFromHistory(homeDir());
|
|
979
|
+
if (candidates.length === 0) {
|
|
980
|
+
stdout.write('(暂无技能候选——需要≥2 条含≥2 步成功动作序列的轨迹)\n');
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
for (const c of candidates) {
|
|
984
|
+
stdout.write(` [${c.status}] ${c.name}\n`);
|
|
985
|
+
stdout.write(` 流程: ${c.procedure.join(' → ')} · 证据 ${c.evidenceTrajectories} 条轨迹(晋升仍需过基准门禁)\n`);
|
|
986
|
+
}
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
if (sub === 'explore') {
|
|
990
|
+
// blueprint M4: run the exploration engine against a real environment.
|
|
991
|
+
// Unknown affordances get probed under budget; the outcome lands in
|
|
992
|
+
// the trajectory store + episodic index like any task run.
|
|
993
|
+
const actions = Number(rest.find((a) => a.startsWith('--actions='))?.slice(10) ?? 6);
|
|
994
|
+
const home = homeDir();
|
|
995
|
+
const scratch = join(tmpdir(), `hmh-explore-${Date.now().toString(36)}`);
|
|
996
|
+
await mkdir(scratch, { recursive: true });
|
|
997
|
+
try {
|
|
998
|
+
const { runExploration } = await import('@hmharness/cognitive');
|
|
999
|
+
const { TerminalEnvironment } = await import('@hmharness/environments');
|
|
1000
|
+
const summary = await runExploration(home, {
|
|
1001
|
+
environmentId: 'terminal',
|
|
1002
|
+
maxActions: Number.isFinite(actions) ? Math.min(Math.max(actions, 1), 20) : 6,
|
|
1003
|
+
maxCost: 40,
|
|
1004
|
+
env: new TerminalEnvironment({ workspaceDir: scratch, timeoutMs: 15_000 }),
|
|
1005
|
+
});
|
|
1006
|
+
stdout.write(`探索完成 · ${summary.result.actionsTaken} 动作 / ${summary.result.costSpent} 成本单位${summary.result.aborted ? `(${summary.result.aborted === 'budget' ? '预算到限' : summary.result.aborted === 'risk' ? '风险熔断' : '无候选动作'})` : ''}\n`);
|
|
1007
|
+
stdout.write(` 轨迹 ${summary.trajectoryId} 已落盘 · 假设裁决 ${summary.result.hypothesesResolved} 条\n`);
|
|
1008
|
+
for (const h of summary.hypotheses)
|
|
1009
|
+
stdout.write(DIM(` [${h.status}] ${h.claim}\n`));
|
|
1010
|
+
if (summary.worldModelBeliefs.length) {
|
|
1011
|
+
stdout.write(' 信念更新:\n');
|
|
1012
|
+
for (const b of summary.worldModelBeliefs.slice(0, 6))
|
|
1013
|
+
stdout.write(` ${b.actionType.padEnd(22)} 置信 ${b.confidence.toFixed(2)} × ${b.evidenceCount}\n`);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
finally {
|
|
1017
|
+
await rm(scratch, { recursive: true, force: true }).catch(() => undefined);
|
|
1018
|
+
}
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
958
1021
|
if (sub !== 'status') {
|
|
959
|
-
stdout.write('用法: hmh cognitive status|world-model|diagnose|bench —
|
|
1022
|
+
stdout.write('用法: hmh cognitive status|world-model|diagnose|bench|drift|skills|explore — 认知子系统与世界模型\n');
|
|
960
1023
|
return;
|
|
961
1024
|
}
|
|
962
1025
|
const { cognitiveStatus, formatCognitiveStatus } = await import('@hmharness/cognitive');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
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.19.
|
|
47
|
-
"@hmharness/cognitive": "0.19.
|
|
48
|
-
"@hmharness/domain-harmony": "0.19.
|
|
49
|
-
"@hmharness/domain-ops": "0.19.
|
|
50
|
-
"@hmharness/environments": "0.19.
|
|
51
|
-
"@hmharness/evaluation": "0.19.
|
|
52
|
-
"@hmharness/evolution": "0.19.
|
|
53
|
-
"@hmharness/kernel": "0.19.
|
|
54
|
-
"@hmharness/observability": "0.19.
|
|
55
|
-
"@hmharness/sandbox": "0.19.
|
|
56
|
-
"@hmharness/web": "0.19.
|
|
46
|
+
"@hmharness/agent": "0.19.4",
|
|
47
|
+
"@hmharness/cognitive": "0.19.4",
|
|
48
|
+
"@hmharness/domain-harmony": "0.19.4",
|
|
49
|
+
"@hmharness/domain-ops": "0.19.4",
|
|
50
|
+
"@hmharness/environments": "0.19.4",
|
|
51
|
+
"@hmharness/evaluation": "0.19.4",
|
|
52
|
+
"@hmharness/evolution": "0.19.4",
|
|
53
|
+
"@hmharness/kernel": "0.19.4",
|
|
54
|
+
"@hmharness/observability": "0.19.4",
|
|
55
|
+
"@hmharness/sandbox": "0.19.4",
|
|
56
|
+
"@hmharness/web": "0.19.4",
|
|
57
57
|
"qrcode": "^1.5.4"
|
|
58
58
|
}
|
|
59
59
|
}
|