@hmharness/cli 0.8.2 → 0.9.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.
- package/dist/main.js +254 -0
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -28,6 +28,7 @@ import { listSkills, listDrafts, promoteSkill, runBench, runEvolution, rollbackS
|
|
|
28
28
|
import { harmonyTools } from '@hmharness/domain-harmony';
|
|
29
29
|
import { baseTools, buildRegistry, buildSystemPrompt, runAgentTask, strings } from '@hmharness/agent';
|
|
30
30
|
const DIM = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
31
|
+
const BOLD = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
31
32
|
const CYAN = (s) => `\x1b[36m${s}\x1b[0m`;
|
|
32
33
|
const YELLOW = (s) => `\x1b[33m${s}\x1b[0m`;
|
|
33
34
|
const GREEN = (s) => `\x1b[32m${s}\x1b[0m`;
|
|
@@ -337,6 +338,17 @@ usage:
|
|
|
337
338
|
hmh interactive REPL (conversation memory kept, /help for commands)
|
|
338
339
|
hmh resume [id-prefix|--last] continue a past session (bare = full-screen picker,
|
|
339
340
|
--last = newest session in this directory)
|
|
341
|
+
hmh project [status|checkpoint <label>|restore <id>|pause|resume|complete|
|
|
342
|
+
archive|release <ver>] project runtime: git-plumbing
|
|
343
|
+
checkpoints (your tree untouched), sandbox
|
|
344
|
+
materialization, run continuation (V2 M8)
|
|
345
|
+
hmh experiment [list|show <id>|run <id> [--cases=N]|promote <id> [--human]|
|
|
346
|
+
rollback <target>] evolution candidates: control/treatment
|
|
347
|
+
bench arms + statistical promotion gate (V2 M9)
|
|
348
|
+
hmh dataset [list|build [ver]|show <ver> [--train|--eval]]
|
|
349
|
+
trajectory -> versioned, redacted, split dataset (V2 M10)
|
|
350
|
+
hmh route shadow-router stats: agreement rate + outcome split (V2 M10)
|
|
351
|
+
hmh readiness the RL gate: six conditions measured from real evidence (V2 M11)
|
|
340
352
|
hmh web start|stop|status web UI as a silent background daemon (no window,
|
|
341
353
|
survives closing everything; log ~/.hmharness/web.log)
|
|
342
354
|
hmh web [--port=7788] web UI in the foreground (debugging)
|
|
@@ -756,6 +768,248 @@ flags:
|
|
|
756
768
|
await startServer({ port: Number.isFinite(port) ? port : 7788, host: '127.0.0.1' });
|
|
757
769
|
return; // startServer keeps the process alive
|
|
758
770
|
}
|
|
771
|
+
if (cmd === 'dataset') {
|
|
772
|
+
// V2 M10: trajectory -> versioned dataset (filter/dedupe/reward/split)
|
|
773
|
+
await initHome();
|
|
774
|
+
const home = homeDir();
|
|
775
|
+
const E = await import('@hmharness/evolution');
|
|
776
|
+
const sub = rest[0] ?? 'list';
|
|
777
|
+
if (sub === 'build') {
|
|
778
|
+
const version = rest[1] && !rest[1].startsWith('--') ? rest[1] : undefined;
|
|
779
|
+
stdout.write(DIM('building dataset from runs/ …\n'));
|
|
780
|
+
const r = await E.buildDataset(home, { version });
|
|
781
|
+
const c = r.manifest.counts;
|
|
782
|
+
stdout.write(GREEN('✓') + ` ${r.manifest.version}: scanned ${c.scanned} → kept ${c.kept} (dropped ${c.dropped}, dupes ${c.duplicates})\n`);
|
|
783
|
+
stdout.write(` train ${c.train} / eval ${c.eval} (seed ${r.manifest.splitSeed}) · filter ${r.manifest.filterFingerprint}\n`);
|
|
784
|
+
stdout.write(` dir: ${r.dir}\n`);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
if (sub === 'list') {
|
|
788
|
+
const all = await E.listDatasets(home);
|
|
789
|
+
if (all.length === 0) {
|
|
790
|
+
stdout.write('no dataset versions (hmh dataset build)\n');
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
for (const m of all)
|
|
794
|
+
stdout.write(`${CYAN(m.version)} ${DIM(m.createdAt)} · kept ${m.counts.kept} (train ${m.counts.train}/eval ${m.counts.eval}) · filter ${m.filterFingerprint}\n`);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
if (sub === 'show') {
|
|
798
|
+
const version = rest[1] ?? '';
|
|
799
|
+
const split = rest.includes('--eval') ? 'eval' : rest.includes('--train') ? 'train' : undefined;
|
|
800
|
+
const samples = await E.loadDataset(home, version, split);
|
|
801
|
+
if (samples.length === 0) {
|
|
802
|
+
stdout.write('no such dataset version or empty split\n');
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
for (const s of samples.slice(0, 30)) {
|
|
806
|
+
stdout.write(`${s.reward.toFixed(1)} ${s.outcome.padEnd(12)} ${YELLOW(`t${s.turns}`)} ${DIM(s.runId.slice(0, 22))} ${s.task.slice(0, 56).replace(/\s+/g, ' ')}\n`);
|
|
807
|
+
}
|
|
808
|
+
if (samples.length > 30)
|
|
809
|
+
stdout.write(DIM(`… ${samples.length - 30} more\n`));
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
stdout.write('usage: hmh dataset [list|build [version]|show <version> [--train|--eval]]\n');
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (cmd === 'route') {
|
|
816
|
+
// V2 M10 shadow router stats: how often the adaptive suggestion disagrees
|
|
817
|
+
// with the live route, and whether disagreement correlates with outcomes
|
|
818
|
+
await initHome();
|
|
819
|
+
const home = homeDir();
|
|
820
|
+
const { routingStats } = await import('@hmharness/kernel');
|
|
821
|
+
const s = await routingStats(home);
|
|
822
|
+
stdout.write(`routing outcomes: ${s.total} · shadow agreed ${s.agreed} (disagreement ${(s.disagreementRate * 100).toFixed(0)}%)\n`);
|
|
823
|
+
for (const [reason, n] of Object.entries(s.byReason))
|
|
824
|
+
stdout.write(` ${DIM(reason)}: ${n}\n`);
|
|
825
|
+
if (s.successAgree !== null)
|
|
826
|
+
stdout.write(`success when agreed: ${(s.successAgree * 100).toFixed(0)}%${s.successDisagree !== null ? ` · when disagreed: ${(s.successDisagree * 100).toFixed(0)}%` : ''}\n`);
|
|
827
|
+
else
|
|
828
|
+
stdout.write(DIM('agreement/success split needs >=8 labeled rows per side\n'));
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
if (cmd === 'readiness') {
|
|
832
|
+
// V2 M11: the RL gate. All six conditions measured from real evidence;
|
|
833
|
+
// closed gate names the optimization to do instead. No bypass exists.
|
|
834
|
+
await initHome();
|
|
835
|
+
const home = homeDir();
|
|
836
|
+
const { rlReadiness } = await import('@hmharness/evolution');
|
|
837
|
+
const r = await rlReadiness(home);
|
|
838
|
+
stdout.write(BOLD(r.verdict === 'rl-eligible' ? GREEN('RL-ELIGIBLE') : YELLOW('OPTIMIZE-FIRST')) + '\n');
|
|
839
|
+
for (const c of r.conditions) {
|
|
840
|
+
const mark = c.met ? GREEN('✓') : RED('✗');
|
|
841
|
+
stdout.write(` ${mark} ${c.id.padEnd(28)} ${String(c.current).slice(0, 40)} (need: ${String(c.threshold).slice(0, 44)})\n`);
|
|
842
|
+
}
|
|
843
|
+
if (r.recommendedLever)
|
|
844
|
+
stdout.write(DIM(`\nrecommended lever: ${r.recommendedLever} (skill/prompt/router optimization first - blueprint M11)\n`));
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (cmd === 'project') {
|
|
848
|
+
// V2 M8 project runtime (ADR-0002): checkpoints are plumbing snapshots -
|
|
849
|
+
// the user's index/refs/worktree are never touched; restore materializes
|
|
850
|
+
// a sandbox copy. `hmh project` alone = status of the current workspace.
|
|
851
|
+
await initHome();
|
|
852
|
+
const home = homeDir();
|
|
853
|
+
const A = await import('@hmharness/agent');
|
|
854
|
+
const sub = rest[0] ?? 'status';
|
|
855
|
+
if (sub === 'status') {
|
|
856
|
+
const rec = await A.findProject(home, process.cwd());
|
|
857
|
+
if (!rec) {
|
|
858
|
+
stdout.write(`no project bound to ${process.cwd()}\n(hmh project checkpoint "<label>" starts one and snapshots it)\n`);
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
stdout.write(CYAN(`project ${rec.projectId}`) + DIM(` · ${rec.state} · ${rec.workspace}\n`));
|
|
862
|
+
stdout.write(` checkpoints: ${rec.checkpoints.length}${rec.checkpoints.length ? ' (latest ' + rec.checkpoints[rec.checkpoints.length - 1].id + ')' : ''}\n`);
|
|
863
|
+
stdout.write(` runs: ${rec.runs.length} · decisions: ${rec.decisions.length} · releases: ${rec.releases.length}\n`);
|
|
864
|
+
for (const r of rec.releases)
|
|
865
|
+
stdout.write(` release ${GREEN(r.version)}${r.checkpointId ? DIM(' @' + r.checkpointId) : ''}\n`);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (sub === 'checkpoint') {
|
|
869
|
+
const label = rest.slice(1).join(' ').trim() || undefined;
|
|
870
|
+
const rec = await A.projectFor(home, process.cwd());
|
|
871
|
+
const cp = await A.checkpointProject(home, rec, label);
|
|
872
|
+
stdout.write(GREEN('✓') + ` checkpoint ${cp.id} · ${cp.files} files${label ? ` · ${label}` : ''} (git objects only - your tree is untouched)\n`);
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
if (sub === 'restore') {
|
|
876
|
+
const id = rest[1] ?? '';
|
|
877
|
+
const rec = await A.findProject(home, process.cwd());
|
|
878
|
+
if (!rec || !id) {
|
|
879
|
+
stdout.write('usage: hmh project restore <checkpoint-id>\n');
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
try {
|
|
883
|
+
const session = await A.restoreCheckpoint(home, rec, id);
|
|
884
|
+
stdout.write(GREEN('✓') + ` checkpoint ${id} materialized to sandbox copy:\n ${session.dir}\n(inspect or run there - your workspace is untouched)\n`);
|
|
885
|
+
}
|
|
886
|
+
catch (err) {
|
|
887
|
+
stdout.write(RED(String(err)) + '\n');
|
|
888
|
+
}
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (sub === 'pause' || sub === 'resume' || sub === 'complete' || sub === 'archive') {
|
|
892
|
+
const rec = await A.findProject(home, process.cwd());
|
|
893
|
+
if (!rec) {
|
|
894
|
+
stdout.write('no project bound to this directory\n');
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const next = sub === 'pause' ? 'paused' : sub === 'resume' ? 'active' : sub === 'complete' ? 'completed' : 'archived';
|
|
898
|
+
try {
|
|
899
|
+
const out = await A.transitionProject(home, rec, next);
|
|
900
|
+
stdout.write(GREEN('✓') + ` ${out.projectId} → ${out.state}\n`);
|
|
901
|
+
}
|
|
902
|
+
catch (err) {
|
|
903
|
+
stdout.write(RED(String(err)) + '\n');
|
|
904
|
+
}
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
if (sub === 'release') {
|
|
908
|
+
const version = rest[1] ?? '';
|
|
909
|
+
if (!version) {
|
|
910
|
+
stdout.write('usage: hmh project release <version> [notes]\n');
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
const rec = await A.findProject(home, process.cwd());
|
|
914
|
+
if (!rec) {
|
|
915
|
+
stdout.write('no project bound to this directory\n');
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
await A.releaseProject(home, rec, version, rest.slice(2).join(' ') || undefined);
|
|
919
|
+
stdout.write(GREEN('✓') + ` release ${version} pinned to latest checkpoint\n`);
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
stdout.write('usage: hmh project [status|checkpoint <label>|restore <id>|pause|resume|complete|archive|release <ver>]\n');
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (cmd === 'experiment') {
|
|
926
|
+
// V2 M9 candidate experiments (ADR-0003): Control/Treatment bench arms +
|
|
927
|
+
// two-proportion gate + promoted/rollback state. Agents never shortcut
|
|
928
|
+
// the gate - promoteCandidate enforces the report.
|
|
929
|
+
await initHome();
|
|
930
|
+
const home = homeDir();
|
|
931
|
+
const E = await import('@hmharness/evolution');
|
|
932
|
+
const sub = rest[0] ?? 'list';
|
|
933
|
+
if (sub === 'list') {
|
|
934
|
+
const list = await E.listCandidates(home);
|
|
935
|
+
const act = await E.activeVersions(home);
|
|
936
|
+
if (list.length === 0) {
|
|
937
|
+
stdout.write('no candidates registered\n');
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
for (const c of list) {
|
|
941
|
+
const rep = await E.latestExperiment(home, c.id);
|
|
942
|
+
stdout.write(`${YELLOW(c.target.padEnd(12))} ${c.id} ${DIM(c.baseVersion + ' → ' + c.candidateVersion)}`
|
|
943
|
+
+ (rep ? ` · ${rep.verdict === 'promote-eligible' ? GREEN(rep.verdict) : rep.verdict === 'reject' ? RED(rep.verdict) : DIM(rep.verdict)}` : DIM(' · untested'))
|
|
944
|
+
+ (act[c.target] ? DIM(` · active: ${act[c.target].version}`) : '') + '\n');
|
|
945
|
+
}
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (sub === 'show') {
|
|
949
|
+
const c = await E.getCandidate(home, rest[1] ?? '');
|
|
950
|
+
if (!c) {
|
|
951
|
+
stdout.write('no such candidate\n');
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
stdout.write(CYAN(`${c.target} ${c.id}`) + DIM(` ${c.baseVersion} → ${c.candidateVersion}\n`));
|
|
955
|
+
stdout.write(` hypothesis: ${c.hypothesis}\n metric: ${c.expectedMetric} · origin: ${c.origin ?? '-'}\n`);
|
|
956
|
+
const rep = await E.latestExperiment(home, c.id);
|
|
957
|
+
if (rep) {
|
|
958
|
+
stdout.write(` latest: control ${rep.control.pass}/${rep.control.n} vs treatment ${rep.treatment.pass}/${rep.treatment.n}`
|
|
959
|
+
+ ` · diff ${(rep.diff * 100).toFixed(1)}% · p=${rep.p.toFixed(4)}\n`
|
|
960
|
+
+ ` verdict: ${rep.verdict} (${rep.reason})\n`);
|
|
961
|
+
}
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
if (sub === 'run') {
|
|
965
|
+
const id = rest[1] ?? '';
|
|
966
|
+
const cand = await E.getCandidate(home, id);
|
|
967
|
+
if (!cand) {
|
|
968
|
+
stdout.write('no such candidate\n');
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
const maxCases = Number((rest.find((a) => a.startsWith('--cases=')) ?? '').slice(9)) || 12;
|
|
972
|
+
const cases = (await E.listCases(home)).filter((c) => !c.holdout);
|
|
973
|
+
if (cases.length === 0) {
|
|
974
|
+
stdout.write('no bench cases - run scripts/bench-cases-v2.cjs or seed first\n');
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
stdout.write(DIM(`running ${Math.min(maxCases, cases.length)} gate cases x2 arms (bench route)…\n`));
|
|
978
|
+
const armRun = async (c, arm) => {
|
|
979
|
+
const runner = makeCaseRunner();
|
|
980
|
+
const out = await runner(c, arm === 'treatment' ? (cand.payload ?? '') : '');
|
|
981
|
+
return { pass: E.matchCase(out, c).pass, tokens: E.estTokens(c.prompt + out) };
|
|
982
|
+
};
|
|
983
|
+
const rep = await E.runCandidateExperiment(home, cand.id, { runCase: armRun, cases, maxCases });
|
|
984
|
+
stdout.write(`control ${rep.control.pass}/${rep.control.n} · treatment ${rep.treatment.pass}/${rep.treatment.n}`
|
|
985
|
+
+ ` · diff ${(rep.diff * 100).toFixed(1)}% · p=${rep.p.toFixed(4)} · tokens ${rep.control.tokens}→${rep.treatment.tokens}\n`);
|
|
986
|
+
stdout.write(rep.verdict === 'promote-eligible' ? GREEN(`verdict: ${rep.verdict} (${rep.reason})`) : rep.verdict === 'reject' ? RED(`verdict: ${rep.verdict} (${rep.reason})`) : DIM(`verdict: ${rep.verdict} (${rep.reason})`) + '\n');
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
if (sub === 'promote') {
|
|
990
|
+
const id = rest[1] ?? '';
|
|
991
|
+
const human = rest.includes('--human');
|
|
992
|
+
const r = await E.promoteCandidate(home, id, { approvedByHuman: human });
|
|
993
|
+
if (!r.ok) {
|
|
994
|
+
stdout.write(RED('✗ ') + (r.error ?? '') + '\n');
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
stdout.write(GREEN('✓') + ` ${r.active.target} active → ${r.active.version} (previous pointer saved; hmh experiment rollback <target>)\n`);
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
if (sub === 'rollback') {
|
|
1001
|
+
const target = rest[1] ?? '';
|
|
1002
|
+
const r = await E.rollbackCandidate(home, target);
|
|
1003
|
+
if (!r.ok) {
|
|
1004
|
+
stdout.write(RED('✗ ') + (r.error ?? '') + '\n');
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
stdout.write(GREEN('✓') + ` ${target} rolled back to previous active version\n`);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
stdout.write('usage: hmh experiment [list|show <id>|run <id> [--cases=N]|promote <id> [--human]|rollback <target>]\n');
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
759
1013
|
if (cmd === 'resume') {
|
|
760
1014
|
await initHome();
|
|
761
1015
|
const home = homeDir();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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,12 +43,12 @@
|
|
|
43
43
|
"build": "tsc -p tsconfig.build.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@hmharness/kernel": "0.
|
|
46
|
+
"@hmharness/kernel": "0.9.0",
|
|
47
47
|
"@hmharness/observability": "0.7.0",
|
|
48
|
-
"@hmharness/evolution": "0.
|
|
48
|
+
"@hmharness/evolution": "0.9.0",
|
|
49
49
|
"@hmharness/domain-harmony": "0.8.0",
|
|
50
50
|
"@hmharness/domain-ops": "0.8.0",
|
|
51
|
-
"@hmharness/agent": "0.
|
|
51
|
+
"@hmharness/agent": "0.9.0",
|
|
52
52
|
"@hmharness/evaluation": "0.8.0",
|
|
53
53
|
"@hmharness/web": "0.8.2"
|
|
54
54
|
}
|