@hmharness/cli 0.6.8 → 0.7.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.
Files changed (2) hide show
  1. package/dist/main.js +41 -0
  2. package/package.json +8 -7
package/dist/main.js CHANGED
@@ -31,6 +31,7 @@ const DIM = (s) => `\x1b[2m${s}\x1b[0m`;
31
31
  const CYAN = (s) => `\x1b[36m${s}\x1b[0m`;
32
32
  const YELLOW = (s) => `\x1b[33m${s}\x1b[0m`;
33
33
  const GREEN = (s) => `\x1b[32m${s}\x1b[0m`;
34
+ const RED = (s) => `\x1b[31m${s}\x1b[0m`;
34
35
  async function uiStrings() {
35
36
  const cfg = await loadConfig();
36
37
  return strings((cfg.locale ?? 'zh'));
@@ -639,6 +640,46 @@ flags:
639
640
  : DIM(' no backups yet - run "hmh state backup"\n'));
640
641
  return;
641
642
  }
643
+ if (cmd === 'replay') {
644
+ // V2 M1: typed trajectory replay. Bare `hmh replay` lists recent runs;
645
+ // `hmh replay <run-id>` renders the event timeline; --json dumps raw.
646
+ await initHome();
647
+ const { jsonlTrajectoryStore } = await import('@hmharness/observability');
648
+ const store = jsonlTrajectoryStore(homeDir());
649
+ const id = rest.find((a) => !a.startsWith('-'));
650
+ if (!id) {
651
+ const runs = await store.listRuns(20);
652
+ stdout.write(runs.length
653
+ ? runs.map((r) => {
654
+ const okc = r.outcome ? (r.outcome.success ? GREEN('✓') : RED('✗')) : YELLOW('…');
655
+ const m = r.metrics ? ` · ${r.metrics.turns ?? '?'}t/${r.metrics.toolUses ?? '?'}x` : '';
656
+ return ` ${okc} ${r.runId} ${DIM(r.task.slice(0, 52))}${m}`;
657
+ }).join('\n') + '\n'
658
+ : DIM(' no runs yet - every task now records a trajectory automatically\n'));
659
+ return;
660
+ }
661
+ if (rest.includes('--json')) {
662
+ stdout.write(await store.exportRun(id, 'json'));
663
+ return;
664
+ }
665
+ const t = await store.getRun(id);
666
+ if (t.events.length === 0) {
667
+ stdout.write(DIM(`no trajectory found for ${id}\n`));
668
+ return;
669
+ }
670
+ const t0 = Date.parse(t.events[0].ts);
671
+ stdout.write(`run ${id} · ${t.model ?? '?'} · ${t.task.slice(0, 80)}\n`);
672
+ for (const e of t.events) {
673
+ const off = String(Math.max(0, Date.parse(e.ts) - t0)).padStart(7);
674
+ const icon = e.type.startsWith('tool.') ? CYAN('⚙') : e.type.startsWith('run.') ? (e.type === 'run.completed' ? GREEN('✓') : e.type === 'run.failed' ? RED('✗') : '▶') : e.type === 'error.observed' ? RED('!') : '·';
675
+ stdout.write(` +${off}ms ${icon} ${e.type.padEnd(20)} ${DIM(JSON.stringify(e.payload).slice(0, 110))}\n`);
676
+ }
677
+ if (t.outcome) {
678
+ stdout.write(` ${t.outcome.success ? GREEN('outcome: success') : RED('outcome: failed')} (${t.outcome.reason ?? '?'})`
679
+ + (t.metrics ? ` · ${t.metrics.turns ?? '?'} turns · ${t.metrics.toolUses ?? '?'} tools · ↑${t.metrics.promptTokens ?? '?'} ↓${t.metrics.completionTokens ?? '?'} tok` : '') + '\n');
680
+ }
681
+ return;
682
+ }
642
683
  if (cmd === 'tui') {
643
684
  await initHome();
644
685
  // tui(yes, noWeb): inside the TTY check the TUI auto-links the web UI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.6.8",
3
+ "version": "0.7.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,11 +43,12 @@
43
43
  "build": "tsc -p tsconfig.build.json"
44
44
  },
45
45
  "dependencies": {
46
- "@hmharness/kernel": "0.6.8",
47
- "@hmharness/evolution": "0.6.8",
48
- "@hmharness/domain-harmony": "0.6.8",
49
- "@hmharness/domain-ops": "0.6.8",
50
- "@hmharness/agent": "0.6.8",
51
- "@hmharness/web": "0.6.8"
46
+ "@hmharness/kernel": "0.7.0",
47
+ "@hmharness/observability": "0.7.0",
48
+ "@hmharness/evolution": "0.7.0",
49
+ "@hmharness/domain-harmony": "0.7.0",
50
+ "@hmharness/domain-ops": "0.7.0",
51
+ "@hmharness/agent": "0.7.0",
52
+ "@hmharness/web": "0.7.0"
52
53
  }
53
54
  }