@hmharness/cli 0.8.2 → 0.8.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 +173 -0
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -337,6 +337,13 @@ usage:
|
|
|
337
337
|
hmh interactive REPL (conversation memory kept, /help for commands)
|
|
338
338
|
hmh resume [id-prefix|--last] continue a past session (bare = full-screen picker,
|
|
339
339
|
--last = newest session in this directory)
|
|
340
|
+
hmh project [status|checkpoint <label>|restore <id>|pause|resume|complete|
|
|
341
|
+
archive|release <ver>] project runtime: git-plumbing
|
|
342
|
+
checkpoints (your tree untouched), sandbox
|
|
343
|
+
materialization, run continuation (V2 M8)
|
|
344
|
+
hmh experiment [list|show <id>|run <id> [--cases=N]|promote <id> [--human]|
|
|
345
|
+
rollback <target>] evolution candidates: control/treatment
|
|
346
|
+
bench arms + statistical promotion gate (V2 M9)
|
|
340
347
|
hmh web start|stop|status web UI as a silent background daemon (no window,
|
|
341
348
|
survives closing everything; log ~/.hmharness/web.log)
|
|
342
349
|
hmh web [--port=7788] web UI in the foreground (debugging)
|
|
@@ -756,6 +763,172 @@ flags:
|
|
|
756
763
|
await startServer({ port: Number.isFinite(port) ? port : 7788, host: '127.0.0.1' });
|
|
757
764
|
return; // startServer keeps the process alive
|
|
758
765
|
}
|
|
766
|
+
if (cmd === 'project') {
|
|
767
|
+
// V2 M8 project runtime (ADR-0002): checkpoints are plumbing snapshots -
|
|
768
|
+
// the user's index/refs/worktree are never touched; restore materializes
|
|
769
|
+
// a sandbox copy. `hmh project` alone = status of the current workspace.
|
|
770
|
+
await initHome();
|
|
771
|
+
const home = homeDir();
|
|
772
|
+
const A = await import('@hmharness/agent');
|
|
773
|
+
const sub = rest[0] ?? 'status';
|
|
774
|
+
if (sub === 'status') {
|
|
775
|
+
const rec = await A.findProject(home, process.cwd());
|
|
776
|
+
if (!rec) {
|
|
777
|
+
stdout.write(`no project bound to ${process.cwd()}\n(hmh project checkpoint "<label>" starts one and snapshots it)\n`);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
stdout.write(CYAN(`project ${rec.projectId}`) + DIM(` · ${rec.state} · ${rec.workspace}\n`));
|
|
781
|
+
stdout.write(` checkpoints: ${rec.checkpoints.length}${rec.checkpoints.length ? ' (latest ' + rec.checkpoints[rec.checkpoints.length - 1].id + ')' : ''}\n`);
|
|
782
|
+
stdout.write(` runs: ${rec.runs.length} · decisions: ${rec.decisions.length} · releases: ${rec.releases.length}\n`);
|
|
783
|
+
for (const r of rec.releases)
|
|
784
|
+
stdout.write(` release ${GREEN(r.version)}${r.checkpointId ? DIM(' @' + r.checkpointId) : ''}\n`);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
if (sub === 'checkpoint') {
|
|
788
|
+
const label = rest.slice(1).join(' ').trim() || undefined;
|
|
789
|
+
const rec = await A.projectFor(home, process.cwd());
|
|
790
|
+
const cp = await A.checkpointProject(home, rec, label);
|
|
791
|
+
stdout.write(GREEN('✓') + ` checkpoint ${cp.id} · ${cp.files} files${label ? ` · ${label}` : ''} (git objects only - your tree is untouched)\n`);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (sub === 'restore') {
|
|
795
|
+
const id = rest[1] ?? '';
|
|
796
|
+
const rec = await A.findProject(home, process.cwd());
|
|
797
|
+
if (!rec || !id) {
|
|
798
|
+
stdout.write('usage: hmh project restore <checkpoint-id>\n');
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
try {
|
|
802
|
+
const session = await A.restoreCheckpoint(home, rec, id);
|
|
803
|
+
stdout.write(GREEN('✓') + ` checkpoint ${id} materialized to sandbox copy:\n ${session.dir}\n(inspect or run there - your workspace is untouched)\n`);
|
|
804
|
+
}
|
|
805
|
+
catch (err) {
|
|
806
|
+
stdout.write(RED(String(err)) + '\n');
|
|
807
|
+
}
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
if (sub === 'pause' || sub === 'resume' || sub === 'complete' || sub === 'archive') {
|
|
811
|
+
const rec = await A.findProject(home, process.cwd());
|
|
812
|
+
if (!rec) {
|
|
813
|
+
stdout.write('no project bound to this directory\n');
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
const next = sub === 'pause' ? 'paused' : sub === 'resume' ? 'active' : sub === 'complete' ? 'completed' : 'archived';
|
|
817
|
+
try {
|
|
818
|
+
const out = await A.transitionProject(home, rec, next);
|
|
819
|
+
stdout.write(GREEN('✓') + ` ${out.projectId} → ${out.state}\n`);
|
|
820
|
+
}
|
|
821
|
+
catch (err) {
|
|
822
|
+
stdout.write(RED(String(err)) + '\n');
|
|
823
|
+
}
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (sub === 'release') {
|
|
827
|
+
const version = rest[1] ?? '';
|
|
828
|
+
if (!version) {
|
|
829
|
+
stdout.write('usage: hmh project release <version> [notes]\n');
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
const rec = await A.findProject(home, process.cwd());
|
|
833
|
+
if (!rec) {
|
|
834
|
+
stdout.write('no project bound to this directory\n');
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
await A.releaseProject(home, rec, version, rest.slice(2).join(' ') || undefined);
|
|
838
|
+
stdout.write(GREEN('✓') + ` release ${version} pinned to latest checkpoint\n`);
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
stdout.write('usage: hmh project [status|checkpoint <label>|restore <id>|pause|resume|complete|archive|release <ver>]\n');
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
if (cmd === 'experiment') {
|
|
845
|
+
// V2 M9 candidate experiments (ADR-0003): Control/Treatment bench arms +
|
|
846
|
+
// two-proportion gate + promoted/rollback state. Agents never shortcut
|
|
847
|
+
// the gate - promoteCandidate enforces the report.
|
|
848
|
+
await initHome();
|
|
849
|
+
const home = homeDir();
|
|
850
|
+
const E = await import('@hmharness/evolution');
|
|
851
|
+
const sub = rest[0] ?? 'list';
|
|
852
|
+
if (sub === 'list') {
|
|
853
|
+
const list = await E.listCandidates(home);
|
|
854
|
+
const act = await E.activeVersions(home);
|
|
855
|
+
if (list.length === 0) {
|
|
856
|
+
stdout.write('no candidates registered\n');
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
for (const c of list) {
|
|
860
|
+
const rep = await E.latestExperiment(home, c.id);
|
|
861
|
+
stdout.write(`${YELLOW(c.target.padEnd(12))} ${c.id} ${DIM(c.baseVersion + ' → ' + c.candidateVersion)}`
|
|
862
|
+
+ (rep ? ` · ${rep.verdict === 'promote-eligible' ? GREEN(rep.verdict) : rep.verdict === 'reject' ? RED(rep.verdict) : DIM(rep.verdict)}` : DIM(' · untested'))
|
|
863
|
+
+ (act[c.target] ? DIM(` · active: ${act[c.target].version}`) : '') + '\n');
|
|
864
|
+
}
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (sub === 'show') {
|
|
868
|
+
const c = await E.getCandidate(home, rest[1] ?? '');
|
|
869
|
+
if (!c) {
|
|
870
|
+
stdout.write('no such candidate\n');
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
stdout.write(CYAN(`${c.target} ${c.id}`) + DIM(` ${c.baseVersion} → ${c.candidateVersion}\n`));
|
|
874
|
+
stdout.write(` hypothesis: ${c.hypothesis}\n metric: ${c.expectedMetric} · origin: ${c.origin ?? '-'}\n`);
|
|
875
|
+
const rep = await E.latestExperiment(home, c.id);
|
|
876
|
+
if (rep) {
|
|
877
|
+
stdout.write(` latest: control ${rep.control.pass}/${rep.control.n} vs treatment ${rep.treatment.pass}/${rep.treatment.n}`
|
|
878
|
+
+ ` · diff ${(rep.diff * 100).toFixed(1)}% · p=${rep.p.toFixed(4)}\n`
|
|
879
|
+
+ ` verdict: ${rep.verdict} (${rep.reason})\n`);
|
|
880
|
+
}
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
if (sub === 'run') {
|
|
884
|
+
const id = rest[1] ?? '';
|
|
885
|
+
const cand = await E.getCandidate(home, id);
|
|
886
|
+
if (!cand) {
|
|
887
|
+
stdout.write('no such candidate\n');
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
const maxCases = Number((rest.find((a) => a.startsWith('--cases=')) ?? '').slice(9)) || 12;
|
|
891
|
+
const cases = (await E.listCases(home)).filter((c) => !c.holdout);
|
|
892
|
+
if (cases.length === 0) {
|
|
893
|
+
stdout.write('no bench cases - run scripts/bench-cases-v2.cjs or seed first\n');
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
stdout.write(DIM(`running ${Math.min(maxCases, cases.length)} gate cases x2 arms (bench route)…\n`));
|
|
897
|
+
const armRun = async (c, arm) => {
|
|
898
|
+
const runner = makeCaseRunner();
|
|
899
|
+
const out = await runner(c, arm === 'treatment' ? (cand.payload ?? '') : '');
|
|
900
|
+
return { pass: E.matchCase(out, c).pass, tokens: E.estTokens(c.prompt + out) };
|
|
901
|
+
};
|
|
902
|
+
const rep = await E.runCandidateExperiment(home, cand.id, { runCase: armRun, cases, maxCases });
|
|
903
|
+
stdout.write(`control ${rep.control.pass}/${rep.control.n} · treatment ${rep.treatment.pass}/${rep.treatment.n}`
|
|
904
|
+
+ ` · diff ${(rep.diff * 100).toFixed(1)}% · p=${rep.p.toFixed(4)} · tokens ${rep.control.tokens}→${rep.treatment.tokens}\n`);
|
|
905
|
+
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');
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
if (sub === 'promote') {
|
|
909
|
+
const id = rest[1] ?? '';
|
|
910
|
+
const human = rest.includes('--human');
|
|
911
|
+
const r = await E.promoteCandidate(home, id, { approvedByHuman: human });
|
|
912
|
+
if (!r.ok) {
|
|
913
|
+
stdout.write(RED('✗ ') + (r.error ?? '') + '\n');
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
stdout.write(GREEN('✓') + ` ${r.active.target} active → ${r.active.version} (previous pointer saved; hmh experiment rollback <target>)\n`);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
if (sub === 'rollback') {
|
|
920
|
+
const target = rest[1] ?? '';
|
|
921
|
+
const r = await E.rollbackCandidate(home, target);
|
|
922
|
+
if (!r.ok) {
|
|
923
|
+
stdout.write(RED('✗ ') + (r.error ?? '') + '\n');
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
stdout.write(GREEN('✓') + ` ${target} rolled back to previous active version\n`);
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
stdout.write('usage: hmh experiment [list|show <id>|run <id> [--cases=N]|promote <id> [--human]|rollback <target>]\n');
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
759
932
|
if (cmd === 'resume') {
|
|
760
933
|
await initHome();
|
|
761
934
|
const home = homeDir();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@hmharness/kernel": "0.8.2",
|
|
47
47
|
"@hmharness/observability": "0.7.0",
|
|
48
|
-
"@hmharness/evolution": "0.8.
|
|
48
|
+
"@hmharness/evolution": "0.8.4",
|
|
49
49
|
"@hmharness/domain-harmony": "0.8.0",
|
|
50
50
|
"@hmharness/domain-ops": "0.8.0",
|
|
51
|
-
"@hmharness/agent": "0.8.
|
|
51
|
+
"@hmharness/agent": "0.8.4",
|
|
52
52
|
"@hmharness/evaluation": "0.8.0",
|
|
53
53
|
"@hmharness/web": "0.8.2"
|
|
54
54
|
}
|