@hmharness/cli 0.19.4 → 0.19.5
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 +58 -5
- package/package.json +12 -12
package/dist/main.js
CHANGED
|
@@ -991,19 +991,28 @@ flags:
|
|
|
991
991
|
// Unknown affordances get probed under budget; the outcome lands in
|
|
992
992
|
// the trajectory store + episodic index like any task run.
|
|
993
993
|
const actions = Number(rest.find((a) => a.startsWith('--actions='))?.slice(10) ?? 6);
|
|
994
|
+
const envId = rest.find((a) => a.startsWith('--env='))?.slice(6) ?? 'terminal';
|
|
994
995
|
const home = homeDir();
|
|
995
996
|
const scratch = join(tmpdir(), `hmh-explore-${Date.now().toString(36)}`);
|
|
996
997
|
await mkdir(scratch, { recursive: true });
|
|
997
998
|
try {
|
|
998
999
|
const { runExploration } = await import('@hmharness/cognitive');
|
|
999
|
-
const { TerminalEnvironment } = await import('@hmharness/environments');
|
|
1000
|
+
const { TerminalEnvironment, HarmonyOsEnvironment } = await import('@hmharness/environments');
|
|
1001
|
+
const env = envId === 'harmonyos'
|
|
1002
|
+
? new HarmonyOsEnvironment({ timeoutMs: 20_000 })
|
|
1003
|
+
: envId === 'terminal' ? new TerminalEnvironment({ workspaceDir: scratch, timeoutMs: 15_000 })
|
|
1004
|
+
: undefined;
|
|
1005
|
+
if (!env) {
|
|
1006
|
+
stdout.write(`环境 '${envId}' 暂不支持 headless 探索(terminal | harmonyos)\n`);
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1000
1009
|
const summary = await runExploration(home, {
|
|
1001
|
-
environmentId:
|
|
1010
|
+
environmentId: envId,
|
|
1002
1011
|
maxActions: Number.isFinite(actions) ? Math.min(Math.max(actions, 1), 20) : 6,
|
|
1003
1012
|
maxCost: 40,
|
|
1004
|
-
env
|
|
1013
|
+
env,
|
|
1005
1014
|
});
|
|
1006
|
-
stdout.write(`探索完成 · ${summary.result.actionsTaken} 动作 / ${summary.result.costSpent} 成本单位${summary.result.aborted ? `(${summary.result.aborted === 'budget' ? '预算到限' : summary.result.aborted === 'risk' ? '风险熔断' : '无候选动作'})` : ''}\n`);
|
|
1015
|
+
stdout.write(`探索完成 · ${envId} · ${summary.result.actionsTaken} 动作 / ${summary.result.costSpent} 成本单位${summary.result.aborted ? `(${summary.result.aborted === 'budget' ? '预算到限' : summary.result.aborted === 'risk' ? '风险熔断' : '无候选动作'})` : ''}\n`);
|
|
1007
1016
|
stdout.write(` 轨迹 ${summary.trajectoryId} 已落盘 · 假设裁决 ${summary.result.hypothesesResolved} 条\n`);
|
|
1008
1017
|
for (const h of summary.hypotheses)
|
|
1009
1018
|
stdout.write(DIM(` [${h.status}] ${h.claim}\n`));
|
|
@@ -1018,8 +1027,52 @@ flags:
|
|
|
1018
1027
|
}
|
|
1019
1028
|
return;
|
|
1020
1029
|
}
|
|
1030
|
+
if (sub === 'transfer') {
|
|
1031
|
+
// blueprint §17: controlled transfer experiment — the with-arm explores
|
|
1032
|
+
// the target with SOURCE-env beliefs seeded, the without-arm starts
|
|
1033
|
+
// empty. Same budgets, same environments; only knowledge differs.
|
|
1034
|
+
if (!rest.includes('--run')) {
|
|
1035
|
+
stdout.write('用法: hmh cognitive transfer --run [--source=terminal] [--target=harmonyos] [--runs=3]\n');
|
|
1036
|
+
stdout.write(DIM(' 需要目标环境可达(harmonyos 需要 hdc 设备在线);每臂各 runs 次探索,动作级成功率对照\n'));
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const source = rest.find((a) => a.startsWith('--source='))?.slice(9) ?? 'terminal';
|
|
1040
|
+
const target = rest.find((a) => a.startsWith('--target='))?.slice(9) ?? 'harmonyos';
|
|
1041
|
+
const runs = Number(rest.find((a) => a.startsWith('--runs='))?.slice(7) ?? 3);
|
|
1042
|
+
const home = homeDir();
|
|
1043
|
+
const scratch = join(tmpdir(), `hmh-transfer-${Date.now().toString(36)}`);
|
|
1044
|
+
await mkdir(scratch, { recursive: true });
|
|
1045
|
+
try {
|
|
1046
|
+
const { runTransferExperiment } = await import('@hmharness/cognitive');
|
|
1047
|
+
const { TerminalEnvironment, HarmonyOsEnvironment } = await import('@hmharness/environments');
|
|
1048
|
+
const makeEnv = target === 'harmonyos'
|
|
1049
|
+
? () => new HarmonyOsEnvironment({ timeoutMs: 20_000 })
|
|
1050
|
+
: target === 'terminal' ? () => new TerminalEnvironment({ workspaceDir: join(scratch, `t-${Date.now().toString(36)}`), timeoutMs: 15_000 })
|
|
1051
|
+
: null;
|
|
1052
|
+
if (!makeEnv) {
|
|
1053
|
+
stdout.write(`目标环境 '${target}' 暂不支持(terminal | harmonyos)\n`);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
const report = await runTransferExperiment(home, {
|
|
1057
|
+
sourceEnv: source,
|
|
1058
|
+
targetEnv: target,
|
|
1059
|
+
makeTargetEnv: makeEnv,
|
|
1060
|
+
runsPerArm: Number.isFinite(runs) ? Math.min(Math.max(runs, 1), 10) : 3,
|
|
1061
|
+
maxActions: 4,
|
|
1062
|
+
});
|
|
1063
|
+
stdout.write(`迁移实验 ${source} → ${target}(每臂 ${report.runsPerArm} 次探索)\n`);
|
|
1064
|
+
stdout.write(` 动作重叠: ${report.actionOverlap.length ? report.actionOverlap.join(', ') : '(无——两环境无共享动作类型,本实验不构成迁移检验)'}\n`);
|
|
1065
|
+
stdout.write(` 带迁移成功率 ${report.withTransfer} vs 空白对照 ${report.fromScratch} → 迁移分 ${report.score} [${report.verdict}]\n`);
|
|
1066
|
+
if (report.verdict === 'negative')
|
|
1067
|
+
stdout.write(YELLOW(' ⚠ 负迁移:源环境信念在目标环境有害——世界模型需要修订\n'));
|
|
1068
|
+
}
|
|
1069
|
+
finally {
|
|
1070
|
+
await rm(scratch, { recursive: true, force: true }).catch(() => undefined);
|
|
1071
|
+
}
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1021
1074
|
if (sub !== 'status') {
|
|
1022
|
-
stdout.write('用法: hmh cognitive status|world-model|diagnose|bench|drift|skills|explore — 认知子系统与世界模型\n');
|
|
1075
|
+
stdout.write('用法: hmh cognitive status|world-model|diagnose|bench|drift|skills|explore|transfer — 认知子系统与世界模型\n');
|
|
1023
1076
|
return;
|
|
1024
1077
|
}
|
|
1025
1078
|
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.5",
|
|
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.5",
|
|
47
|
+
"@hmharness/cognitive": "0.19.5",
|
|
48
|
+
"@hmharness/domain-harmony": "0.19.5",
|
|
49
|
+
"@hmharness/domain-ops": "0.19.5",
|
|
50
|
+
"@hmharness/environments": "0.19.5",
|
|
51
|
+
"@hmharness/evaluation": "0.19.5",
|
|
52
|
+
"@hmharness/evolution": "0.19.5",
|
|
53
|
+
"@hmharness/kernel": "0.19.5",
|
|
54
|
+
"@hmharness/observability": "0.19.5",
|
|
55
|
+
"@hmharness/sandbox": "0.19.5",
|
|
56
|
+
"@hmharness/web": "0.19.5",
|
|
57
57
|
"qrcode": "^1.5.4"
|
|
58
58
|
}
|
|
59
59
|
}
|