@hmharness/cli 0.18.2 → 0.18.3

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 CHANGED
@@ -1622,6 +1622,39 @@ flags:
1622
1622
  stdout.write('usage: hmh experiment [list|show <id>|run <id> [--cases=N]|promote <id> [--human]|rollback <target>]\n');
1623
1623
  return;
1624
1624
  }
1625
+ if (cmd === 'export') {
1626
+ // One-click export (2026-09-25, user request): session transcript -> a
1627
+ // single readable Markdown file. Shared builder with the web endpoint;
1628
+ // TUI exposes it as /export on the same session it is replaying.
1629
+ await initHome();
1630
+ const home = homeDir();
1631
+ let file = null;
1632
+ if (rest.includes('--last') || !arg)
1633
+ file = (await listSessions(home, { cwd: process.cwd(), limit: 1 })).items[0]?.file ?? null;
1634
+ else
1635
+ file = await latestSession(home, arg);
1636
+ if (!file) {
1637
+ stdout.write('没有可导出的会话——先使用 hmh 产生一次对话。\n');
1638
+ return;
1639
+ }
1640
+ const tr = await loadTranscript(file);
1641
+ if (!tr) {
1642
+ stdout.write('会话文件无法解析:' + file + '\n');
1643
+ return;
1644
+ }
1645
+ const { exportSessionMarkdown } = await import('@hmharness/kernel');
1646
+ const md = exportSessionMarkdown(tr);
1647
+ const dir = join(home, 'exports');
1648
+ const { mkdir } = await import('node:fs/promises');
1649
+ await mkdir(dir, { recursive: true });
1650
+ const name = (tr.id || 'session').replace(/[^a-zA-Z0-9_:.@-]/g, '') + '.md';
1651
+ const out = join(dir, name);
1652
+ const { writeFile } = await import('node:fs/promises');
1653
+ await writeFile(out, md, 'utf8');
1654
+ stdout.write(GREEN('✓') + ' 已导出 ' + tr.messages.length + ' 条消息 → ' + out + '\n');
1655
+ stdout.write(DIM('完整用户输入与回复都在文件里;工具输出超过 4000 字符自动截断。\n'));
1656
+ return;
1657
+ }
1625
1658
  if (cmd === 'resume') {
1626
1659
  await initHome();
1627
1660
  const home = homeDir();
package/dist/tui.d.ts CHANGED
@@ -243,6 +243,12 @@ export declare class TuiRuntime {
243
243
  /** The user's own input, chat-style: separated by a blank line above and
244
244
  * below, right-aligned to the terminal width so it reads as "the human
245
245
  * side" against left-aligned model output. */
246
+ /** User input renders as a right-aligned chat bubble (2026-09-25 user
247
+ * feedback: folded long inputs "were not on the right"). The wrap width
248
+ * is 70% of the terminal (floor 40) - a full-width wrap made line 2+
249
+ * start at the left margin, which read as left-aligned text. The block
250
+ * always ENDS at the right edge either way; short prompts sit clearly
251
+ * on the right against left-aligned model output. */
246
252
  addUser(text: string): void;
247
253
  startStream(kind: 'think' | 'say'): ((chunk: string) => void) & {
248
254
  drop: () => void;
package/dist/tui.js CHANGED
@@ -112,6 +112,7 @@ export const COMMANDS = [
112
112
  { name: '/new', key: 'cmdNew' },
113
113
  { name: '/fork', key: 'cmdFork' },
114
114
  { name: '/copy', key: 'cmdCopy' },
115
+ { name: '/export', key: 'cmdExport' },
115
116
  { name: '/mouse', key: 'cmdMouse' },
116
117
  { name: '/plan', key: 'cmdPlan' },
117
118
  { name: '/goal', key: 'cmdGoal' },
@@ -733,10 +734,17 @@ export class TuiRuntime {
733
734
  /** The user's own input, chat-style: separated by a blank line above and
734
735
  * below, right-aligned to the terminal width so it reads as "the human
735
736
  * side" against left-aligned model output. */
737
+ /** User input renders as a right-aligned chat bubble (2026-09-25 user
738
+ * feedback: folded long inputs "were not on the right"). The wrap width
739
+ * is 70% of the terminal (floor 40) - a full-width wrap made line 2+
740
+ * start at the left margin, which read as left-aligned text. The block
741
+ * always ENDS at the right edge either way; short prompts sit clearly
742
+ * on the right against left-aligned model output. */
736
743
  addUser(text) {
737
744
  const width = Math.max(20, (stdout.columns || 100) - 2);
745
+ const blockW = Math.max(40, Math.floor(width * 0.7));
738
746
  const lines = [''];
739
- const wrapped = wrapTo(text.replace(/\n+/g, ' '), width);
747
+ const wrapped = wrapTo(text.replace(/\n+/g, ' '), blockW);
740
748
  // long prompts fold to two lines + a count marker (UX requirement 2026-09-21:
741
749
  // a pasted prompt used to eat half the screen); the driver archives the
742
750
  // full text into the Ctrl+T replay so nothing is lost
@@ -2288,6 +2296,40 @@ export async function tui(yes, noWeb = false, opts = {}) {
2288
2296
  rt.addText('(clipboard tool unavailable — output follows)\n' + lastAiText.slice(0, 2000), 'dim');
2289
2297
  return;
2290
2298
  }
2299
+ if (line === '/export') {
2300
+ // One-click export (2026-09-25): the CURRENT session (replayed or
2301
+ // fresh) becomes one Markdown file under ~/.hmharness/exports -
2302
+ // full user inputs and replies, folded tool output. Same builder as
2303
+ // `hmh export` and the web session view's download button.
2304
+ try {
2305
+ const { homeDir, findSessionFile, loadTranscript, exportSessionMarkdown } = await import('@hmharness/kernel');
2306
+ const home = homeDir();
2307
+ const sid = currentSessionId;
2308
+ const K = await import('@hmharness/kernel');
2309
+ const file = sid ? await findSessionFile(home, sid) : await K.latestSession(home, '');
2310
+ if (!file) {
2311
+ rt.addText('还没有可导出的会话内容。', 'dim');
2312
+ return;
2313
+ }
2314
+ const tr = await loadTranscript(file);
2315
+ if (!tr) {
2316
+ rt.addText('会话文件无法解析,稍后再试。', 'dim');
2317
+ return;
2318
+ }
2319
+ const md = exportSessionMarkdown(tr);
2320
+ const { mkdir, writeFile } = await import('node:fs/promises');
2321
+ const { join } = await import('node:path');
2322
+ const dir = join(home, 'exports');
2323
+ await mkdir(dir, { recursive: true });
2324
+ const out = join(dir, ((tr.id || 'session').replace(/[^a-zA-Z0-9_:.@-]/g, '')) + '.md');
2325
+ await writeFile(out, md, 'utf8');
2326
+ rt.addText(GREEN('✓') + ' 会话已导出(' + tr.messages.length + ' 条消息)→ ' + out, 'plain');
2327
+ }
2328
+ catch (err) {
2329
+ rt.addText('导出失败:' + String(err).slice(0, 120), 'dim');
2330
+ }
2331
+ return;
2332
+ }
2291
2333
  if (line === '/mouse') {
2292
2334
  // T23: full-time capture toggle for terminals without wheel
2293
2335
  // translation (?1007 already covers the wheel on mainstream ones);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
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,14 +43,14 @@
43
43
  "build": "tsc -p tsconfig.build.json"
44
44
  },
45
45
  "dependencies": {
46
- "@hmharness/kernel": "0.9.6",
46
+ "@hmharness/kernel": "0.9.7",
47
47
  "@hmharness/observability": "0.7.4",
48
48
  "@hmharness/evolution": "0.14.25",
49
49
  "@hmharness/domain-harmony": "0.13.8",
50
50
  "@hmharness/domain-ops": "0.8.3",
51
- "@hmharness/agent": "0.14.18",
51
+ "@hmharness/agent": "0.14.19",
52
52
  "@hmharness/evaluation": "0.8.6",
53
- "@hmharness/web": "0.9.4",
53
+ "@hmharness/web": "0.9.5",
54
54
  "@hmharness/sandbox": "0.8.5"
55
55
  }
56
56
  }