herm-tui 1.0.0-dev.1 → 1.0.0-dev.11

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 (192) hide show
  1. package/README.md +8 -4
  2. package/assets/eikons/ares.eikon +367 -0
  3. package/assets/eikons/default.eikon +398 -0
  4. package/assets/eikons/mono.eikon +395 -0
  5. package/db.worker.js +81 -0
  6. package/highlights-eq9cgrbb.scm +604 -0
  7. package/highlights-ghv9g403.scm +205 -0
  8. package/highlights-hk7bwhj4.scm +284 -0
  9. package/highlights-r812a2qc.scm +150 -0
  10. package/highlights-x6tmsnaa.scm +115 -0
  11. package/index.js +4151 -0
  12. package/injections-73j83es3.scm +27 -0
  13. package/package.json +14 -64
  14. package/parser.worker.js +8 -0
  15. package/tree-sitter-3jzf13jk.wasm +0 -0
  16. package/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  17. package/tree-sitter-markdown-411r6y9b.wasm +0 -0
  18. package/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  19. package/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  20. package/tree-sitter-zig-e78zbjpm.wasm +0 -0
  21. package/scripts/postinstall.ts +0 -29
  22. package/src/app/gateway.tsx +0 -83
  23. package/src/app/gatewayEvents.ts +0 -203
  24. package/src/app/launch.ts +0 -41
  25. package/src/app/skin.tsx +0 -31
  26. package/src/app/spawnHistory.ts +0 -75
  27. package/src/app/tabs.ts +0 -23
  28. package/src/app/turnReducer.ts +0 -390
  29. package/src/app/useAppKeys.ts +0 -268
  30. package/src/app/useAtRefPopover.ts +0 -99
  31. package/src/app/useInputHistory.ts +0 -66
  32. package/src/app/useSession.ts +0 -102
  33. package/src/app/useSlashCommands.ts +0 -70
  34. package/src/app/useSlashPopover.ts +0 -48
  35. package/src/app.tsx +0 -917
  36. package/src/commands/slash.ts +0 -151
  37. package/src/components/avatar/AnimatedAvatar.tsx +0 -66
  38. package/src/components/avatar/eikon.ts +0 -144
  39. package/src/components/avatar/states/error.ts +0 -1155
  40. package/src/components/avatar/states/idle.ts +0 -1155
  41. package/src/components/avatar/states/index.ts +0 -30
  42. package/src/components/avatar/states/listening.ts +0 -1155
  43. package/src/components/avatar/states/speaking.ts +0 -1155
  44. package/src/components/avatar/states/thinking.ts +0 -1155
  45. package/src/components/avatar/states/working.ts +0 -1155
  46. package/src/components/chat/AtRefPopover.tsx +0 -54
  47. package/src/components/chat/CodeBlock.tsx +0 -67
  48. package/src/components/chat/Composer.tsx +0 -347
  49. package/src/components/chat/DiffBlock.tsx +0 -116
  50. package/src/components/chat/ErrorBlock.tsx +0 -70
  51. package/src/components/chat/MediaChip.tsx +0 -114
  52. package/src/components/chat/MessageItem.tsx +0 -282
  53. package/src/components/chat/MessageList.tsx +0 -114
  54. package/src/components/chat/PromptCard.tsx +0 -359
  55. package/src/components/chat/SlashPopover.tsx +0 -158
  56. package/src/components/chat/ThoughtCloud.tsx +0 -185
  57. package/src/components/chat/TypingIndicator.tsx +0 -25
  58. package/src/components/chat/tool/Subagent.tsx +0 -75
  59. package/src/components/chat/tool/frame.tsx +0 -69
  60. package/src/components/chat/tool/index.tsx +0 -65
  61. package/src/components/chat/tool/preview.ts +0 -57
  62. package/src/components/sidebar/ContextGauge.tsx +0 -102
  63. package/src/components/sidebar/Sidebar.tsx +0 -143
  64. package/src/components/tabs/TabBar.tsx +0 -50
  65. package/src/components/ui/FileLink.tsx +0 -52
  66. package/src/config/index.ts +0 -156
  67. package/src/config/lane.ts +0 -161
  68. package/src/config/models.ts +0 -95
  69. package/src/config/rules.ts +0 -80
  70. package/src/config/schema.ts +0 -308
  71. package/src/dialogs/alert.tsx +0 -52
  72. package/src/dialogs/chafa.tsx +0 -72
  73. package/src/dialogs/confirm.tsx +0 -58
  74. package/src/dialogs/curator.tsx +0 -153
  75. package/src/dialogs/eikon-picker.tsx +0 -95
  76. package/src/dialogs/help.tsx +0 -80
  77. package/src/dialogs/history.tsx +0 -92
  78. package/src/dialogs/info.tsx +0 -115
  79. package/src/dialogs/keys.tsx +0 -170
  80. package/src/dialogs/logs.tsx +0 -42
  81. package/src/dialogs/message.tsx +0 -38
  82. package/src/dialogs/model-picker.tsx +0 -123
  83. package/src/dialogs/new-profile.tsx +0 -69
  84. package/src/dialogs/new-task.tsx +0 -103
  85. package/src/dialogs/profile.tsx +0 -55
  86. package/src/dialogs/rollback.tsx +0 -190
  87. package/src/dialogs/spawn-history.tsx +0 -80
  88. package/src/dialogs/text-prompt.tsx +0 -68
  89. package/src/dialogs/theme-picker.tsx +0 -50
  90. package/src/home/index.ts +0 -23
  91. package/src/home/store.ts +0 -267
  92. package/src/index.tsx +0 -113
  93. package/src/keys/catalog.ts +0 -115
  94. package/src/keys/chord.ts +0 -125
  95. package/src/keys/conflicts.ts +0 -48
  96. package/src/keys/context.tsx +0 -112
  97. package/src/keys/index.ts +0 -5
  98. package/src/keys/list.ts +0 -94
  99. package/src/keys/oc-compat.ts +0 -87
  100. package/src/tabs/Agents.tsx +0 -607
  101. package/src/tabs/Analytics.tsx +0 -154
  102. package/src/tabs/Chat.tsx +0 -50
  103. package/src/tabs/Config.tsx +0 -605
  104. package/src/tabs/Context.tsx +0 -599
  105. package/src/tabs/Cron.tsx +0 -294
  106. package/src/tabs/Env.tsx +0 -227
  107. package/src/tabs/Kanban.tsx +0 -367
  108. package/src/tabs/Memory.tsx +0 -294
  109. package/src/tabs/Sessions.tsx +0 -786
  110. package/src/tabs/Skills.tsx +0 -507
  111. package/src/tabs/Toolsets.tsx +0 -266
  112. package/src/theme/builtin.ts +0 -78
  113. package/src/theme/context.tsx +0 -106
  114. package/src/theme/index.ts +0 -4
  115. package/src/theme/resolve.ts +0 -134
  116. package/src/theme/syntax.ts +0 -31
  117. package/src/theme/themes/aura.json +0 -69
  118. package/src/theme/themes/ayu.json +0 -80
  119. package/src/theme/themes/carbonfox.json +0 -248
  120. package/src/theme/themes/catppuccin-frappe.json +0 -233
  121. package/src/theme/themes/catppuccin-macchiato.json +0 -233
  122. package/src/theme/themes/catppuccin.json +0 -112
  123. package/src/theme/themes/cobalt2.json +0 -228
  124. package/src/theme/themes/cursor.json +0 -249
  125. package/src/theme/themes/dracula.json +0 -219
  126. package/src/theme/themes/everforest.json +0 -241
  127. package/src/theme/themes/flexoki.json +0 -237
  128. package/src/theme/themes/github.json +0 -233
  129. package/src/theme/themes/gruvbox.json +0 -242
  130. package/src/theme/themes/kanagawa.json +0 -77
  131. package/src/theme/themes/lucent-orng.json +0 -237
  132. package/src/theme/themes/material.json +0 -235
  133. package/src/theme/themes/matrix.json +0 -77
  134. package/src/theme/themes/mercury.json +0 -252
  135. package/src/theme/themes/monokai.json +0 -221
  136. package/src/theme/themes/nightowl.json +0 -221
  137. package/src/theme/themes/nord.json +0 -223
  138. package/src/theme/themes/one-dark.json +0 -84
  139. package/src/theme/themes/opencode.json +0 -245
  140. package/src/theme/themes/orng.json +0 -249
  141. package/src/theme/themes/osaka-jade.json +0 -93
  142. package/src/theme/themes/palenight.json +0 -222
  143. package/src/theme/themes/rosepine.json +0 -234
  144. package/src/theme/themes/solarized.json +0 -223
  145. package/src/theme/themes/synthwave84.json +0 -226
  146. package/src/theme/themes/tokyonight.json +0 -243
  147. package/src/theme/themes/vercel.json +0 -245
  148. package/src/theme/themes/vesper.json +0 -218
  149. package/src/theme/themes/zenburn.json +0 -223
  150. package/src/theme/types.ts +0 -119
  151. package/src/types/message.ts +0 -97
  152. package/src/ui/ChafaImage.tsx +0 -64
  153. package/src/ui/Splash.tsx +0 -118
  154. package/src/ui/borders.ts +0 -28
  155. package/src/ui/command.tsx +0 -104
  156. package/src/ui/dialog-select.tsx +0 -164
  157. package/src/ui/dialog.tsx +0 -102
  158. package/src/ui/fmt.ts +0 -82
  159. package/src/ui/kv.tsx +0 -28
  160. package/src/ui/shell.tsx +0 -45
  161. package/src/ui/spinner.tsx +0 -59
  162. package/src/ui/splash-art.ts +0 -123
  163. package/src/ui/table.tsx +0 -117
  164. package/src/ui/ticker.tsx +0 -90
  165. package/src/ui/toast.tsx +0 -130
  166. package/src/utils/categorical.ts +0 -77
  167. package/src/utils/chafa.ts +0 -173
  168. package/src/utils/clipboard.ts +0 -67
  169. package/src/utils/context-segments.ts +0 -317
  170. package/src/utils/control.ts +0 -495
  171. package/src/utils/drop.ts +0 -25
  172. package/src/utils/editor.ts +0 -33
  173. package/src/utils/fuzzy.ts +0 -45
  174. package/src/utils/gateway-client.ts +0 -253
  175. package/src/utils/gateway-types.ts +0 -282
  176. package/src/utils/git.ts +0 -57
  177. package/src/utils/hermes-analytics.ts +0 -134
  178. package/src/utils/hermes-home.ts +0 -821
  179. package/src/utils/hermes-kanban.ts +0 -154
  180. package/src/utils/hermes-profiles.ts +0 -217
  181. package/src/utils/interpolate.ts +0 -31
  182. package/src/utils/math-unicode.ts +0 -818
  183. package/src/utils/memory-activity.ts +0 -140
  184. package/src/utils/open-file.ts +0 -13
  185. package/src/utils/paths.ts +0 -52
  186. package/src/utils/perf.ts +0 -235
  187. package/src/utils/preferences.ts +0 -150
  188. package/src/utils/sessions-db.ts +0 -396
  189. package/src/utils/subagent-tree.ts +0 -146
  190. package/src/utils/terminal-reset.ts +0 -129
  191. package/src/utils/tips.ts +0 -67
  192. package/src/utils/tokens.ts +0 -87
@@ -1,72 +0,0 @@
1
- // Throwaway demo dialog — `/chafa <path>` renders an image inline via
2
- // chafa's symbol mode + our SGR parser (src/utils/chafa.ts). Proof that
3
- // 24-bit colored image rendering in OpenTUI works end-to-end. Will be
4
- // superseded by inline rendering in MessageItem (herm-mzb.7).
5
-
6
- import { useMemo, useState } from "react"
7
- import { spawnSync } from "child_process"
8
- import { existsSync } from "fs"
9
- import { useTheme } from "../theme"
10
- import type { DialogContext } from "../ui/dialog"
11
- import { parseChafa, hex, type Cell } from "../utils/chafa"
12
-
13
- const CHAFA = ["/usr/sbin/chafa", "/usr/bin/chafa", "/usr/local/bin/chafa", "/opt/homebrew/bin/chafa"]
14
-
15
- function whichChafa(): string | null {
16
- for (const p of CHAFA) if (existsSync(p)) return p
17
- return null
18
- }
19
-
20
- function render(path: string, w: number, h: number): { rows?: Cell[][]; err?: string } {
21
- const bin = whichChafa()
22
- if (!bin) return { err: "chafa not installed (brew/apt install chafa)" }
23
- const full = path.startsWith("~") ? path.replace(/^~/, process.env.HOME ?? "") : path
24
- if (!existsSync(full)) return { err: `file not found: ${full}` }
25
- const r = spawnSync(bin, [
26
- `--size=${w}x${h}`,
27
- "--format=symbols",
28
- "--symbols=block",
29
- "--colors=full",
30
- full,
31
- ], { encoding: "utf8" })
32
- if (r.status !== 0) return { err: r.stderr || `chafa exit ${r.status}` }
33
- return { rows: parseChafa(r.stdout) }
34
- }
35
-
36
- const ChafaDialog = ({ path }: { path: string }) => {
37
- const theme = useTheme().theme
38
- const [w] = useState(80)
39
- const [h] = useState(28)
40
- const result = useMemo(() => render(path, w, h), [path, w, h])
41
-
42
- return (
43
- <box flexDirection="column" minWidth={w + 4} gap={1}>
44
- <box height={1}>
45
- <text fg={theme.primary}><strong>chafa demo · {path}</strong></text>
46
- </box>
47
- {result.err
48
- ? <box height={1}><text fg={theme.error}>{result.err}</text></box>
49
- : (
50
- <box flexDirection="column">
51
- {result.rows!.map((row, i) => (
52
- <text key={i}>
53
- {row.map((c, j) => (
54
- <span key={j} fg={hex(c.fg)} bg={hex(c.bg)}>{c.ch}</span>
55
- ))}
56
- </text>
57
- ))}
58
- </box>
59
- )}
60
- <box height={1}>
61
- <text fg={theme.borderSubtle}>
62
- {result.rows ? `${result.rows.length} rows · ${result.rows.reduce((a, r) => a + r.length, 0)} cells · ` : ""}
63
- Esc to close
64
- </text>
65
- </box>
66
- </box>
67
- )
68
- }
69
-
70
- export function openChafa(dialog: DialogContext, path: string) {
71
- dialog.replace(<ChafaDialog path={path} />)
72
- }
@@ -1,58 +0,0 @@
1
- // Generic y/n confirm dialog. `openConfirm(dialog, {...})` resolves to
2
- // true on [y], false on [n]/Esc.
3
-
4
- import { useKeyboard } from "@opentui/react"
5
- import { useKeys } from "../keys"
6
- import { useTheme } from "../theme"
7
- import type { DialogContext } from "../ui/dialog"
8
-
9
- type Props = {
10
- title: string
11
- body: string
12
- yes?: string
13
- no?: string
14
- danger?: boolean
15
- onConfirm: () => void
16
- onCancel: () => void
17
- }
18
-
19
- const Confirm = (props: Props) => {
20
- const theme = useTheme().theme
21
- const keys = useKeys()
22
- useKeyboard((key) => {
23
- if (keys.match("dialog.confirm", key) || keys.match("dialog.accept", key)) return props.onConfirm()
24
- if (keys.match("dialog.deny", key) || keys.match("dialog.cancel", key)) return props.onCancel()
25
- })
26
- return (
27
- <box flexDirection="column" width={54}>
28
- <box height={1}>
29
- <text fg={props.danger ? theme.warning : theme.primary}>
30
- <strong>{props.title}</strong>
31
- </text>
32
- </box>
33
- <box height={1} />
34
- <box minHeight={1}><text wrapMode="word">{props.body}</text></box>
35
- <box height={1} />
36
- <box height={1}>
37
- <text fg={theme.textMuted}>
38
- {`[${keys.print("dialog.confirm")}/${keys.print("dialog.accept")}] ${props.yes ?? "confirm"} [${keys.print("dialog.deny")}] ${props.no ?? "cancel"}`}
39
- </text>
40
- </box>
41
- </box>
42
- )
43
- }
44
-
45
- export function openConfirm(
46
- dialog: DialogContext,
47
- opts: Omit<Props, "onConfirm" | "onCancel">,
48
- ): Promise<boolean> {
49
- return new Promise((resolve) => {
50
- dialog.replace(
51
- <Confirm
52
- {...opts}
53
- onConfirm={() => { dialog.clear(); resolve(true) }}
54
- onCancel={() => { dialog.clear(); resolve(false) }}
55
- />,
56
- )
57
- })
58
- }
@@ -1,153 +0,0 @@
1
- // Curator control panel. Reads .curator_state + config.curator.*; the
2
- // report pane shows the newest logs/curator/*/REPORT.md. Writes route
3
- // through `shell.exec → hermes curator <verb>` so the CLI owns the
4
- // state machine (see Agents.tsx / Kanban.tsx for the precedent).
5
-
6
- import { useEffect, useState, useCallback } from "react"
7
- import { useKeyboard } from "@opentui/react"
8
- import { useTheme } from "../theme"
9
- import type { DialogContext } from "../ui/dialog"
10
- import { useGateway } from "../app/gateway"
11
- import { useHome, home } from "../home"
12
- import { useToast } from "../ui/toast"
13
- import { readLatestCuratorReport, type CuratorReportInfo } from "../utils/hermes-home"
14
- import { KVLink } from "../components/ui/FileLink"
15
- import { KVBlock } from "../ui/kv"
16
- import { Spinner } from "../ui/spinner"
17
- import { ago, until, dur, trunc } from "../ui/fmt"
18
-
19
- const iso = (s: string | null | undefined): number | null => {
20
- if (!s) return null
21
- const t = Date.parse(s)
22
- return Number.isFinite(t) ? Math.floor(t / 1000) : null
23
- }
24
-
25
- type Sh = { stdout: string; stderr: string; code: number }
26
-
27
- const CuratorDialog = () => {
28
- const { theme, syntaxStyle } = useTheme()
29
- const gw = useGateway()
30
- const toast = useToast()
31
- const state = useHome("curatorState")
32
- const cfg = useHome("config")?.curator
33
- const [report, setReport] = useState<CuratorReportInfo | null>(null)
34
- const [loaded, setLoaded] = useState(false)
35
- const [busy, setBusy] = useState<"run" | "pause" | "resume" | null>(null)
36
-
37
- useEffect(() => {
38
- readLatestCuratorReport()
39
- .then(r => { setReport(r); setLoaded(true) })
40
- .catch(() => setLoaded(true))
41
- }, [])
42
-
43
- const sh = useCallback((verb: "run" | "pause" | "resume", ok: string) => {
44
- if (busy) return
45
- setBusy(verb)
46
- gw.request<Sh>("shell.exec", { command: `hermes curator ${verb}` })
47
- .then(r => {
48
- if (r.code !== 0) throw new Error((r.stderr || r.stdout || `exit ${r.code}`).trim())
49
- toast.show({ variant: "success", message: ok })
50
- home.invalidate("curatorState")
51
- })
52
- .catch((e: Error) => toast.show({ variant: "error", message: trunc(e.message, 120) }))
53
- .finally(() => setBusy(null))
54
- }, [gw, toast, busy])
55
-
56
- useKeyboard((key) => {
57
- if (key.raw === "r") return sh("run", "Curator run started (background)")
58
- if (key.raw === "p") return state?.paused
59
- ? sh("resume", "Curator resumed")
60
- : sh("pause", "Curator paused")
61
- })
62
-
63
- const last = iso(state?.last_run_at ?? null)
64
- // Next-due is last_run_at + interval_hours. CLI additionally gates on
65
- // min_idle_hours, so this is "eligible from", not "will fire at".
66
- const due = last && cfg ? last + cfg.interval_hours * 3600 : null
67
- const status = cfg?.enabled === false ? "disabled"
68
- : state?.paused ? "paused"
69
- : "enabled"
70
- const tint = status === "enabled" ? theme.success
71
- : status === "paused" ? theme.warning : theme.textMuted
72
-
73
- return (
74
- <box flexDirection="column" width={120} height={34}>
75
- <box height={1} flexDirection="row">
76
- <text>
77
- <span fg={theme.primary}><strong>Skill Curator</strong></span>
78
- <span fg={tint}>{` · ${status}`}</span>
79
- </text>
80
- {busy ? <box marginLeft={2}><Spinner color={theme.textMuted} label={busy} /></box> : null}
81
- </box>
82
- <box height={1}>
83
- <text fg={theme.textMuted}>
84
- {state
85
- ? `${state.run_count} run${state.run_count === 1 ? "" : "s"}${last ? " · last " + ago(last) : " · never"} · Esc to close`
86
- : "No curator state yet · Esc to close"}
87
- </text>
88
- </box>
89
- <box height={1} />
90
-
91
- <box flexDirection="row" flexGrow={1} gap={2}>
92
- <box flexDirection="column" width={40} height="100%" flexShrink={0}>
93
- <KVBlock rows={[
94
- ["Next run", status !== "enabled" ? `— (${status})`
95
- : due ? until(due) : "when idle"],
96
- ["Last run", last ? ago(last) : "never"],
97
- ["Duration", state?.last_run_duration_seconds
98
- ? dur(state.last_run_duration_seconds) : undefined],
99
- ]} />
100
- <box height={1} />
101
- <box height={1}><text fg={theme.textMuted}>Config · edit in Config tab</text></box>
102
- <KVBlock rows={[
103
- ["Interval", cfg ? `${cfg.interval_hours}h` : "—"],
104
- ["Stale after", cfg ? `${cfg.stale_after_days}d` : "—"],
105
- ["Archive after", cfg ? `${cfg.archive_after_days}d` : "—"],
106
- ]} />
107
- <box height={1} />
108
- <box flexDirection="column">
109
- <box height={1}><text>
110
- <span fg={theme.accent}>r </span>
111
- <span fg={theme.text}>run now</span>
112
- <span fg={theme.textMuted}> (background)</span>
113
- </text></box>
114
- <box height={1}><text>
115
- <span fg={theme.accent}>p </span>
116
- <span fg={theme.text}>{state?.paused ? "resume" : "pause"}</span>
117
- </text></box>
118
- </box>
119
- {state?.last_run_summary ? <>
120
- <box height={1} />
121
- <box height={1}><text fg={theme.textMuted}>Last run</text></box>
122
- <scrollbox scrollY flexGrow={1}>
123
- <markdown content={state.last_run_summary}
124
- fg={theme.markdownText} syntaxStyle={syntaxStyle} />
125
- </scrollbox>
126
- </> : null}
127
- </box>
128
-
129
- {!loaded ? (
130
- <box height={1}><text fg={theme.textMuted}>loading report…</text></box>
131
- ) : report ? (
132
- <box flexDirection="column" flexGrow={1} height="100%" minWidth={0}>
133
- <box height={1}><text fg={theme.info}><strong>{`▾ Report · ${report.runId}`}</strong></text></box>
134
- <KVLink label="File" source={report.source} text={report.source.relative} />
135
- <box height={1} />
136
- <scrollbox scrollY flexGrow={1} border borderColor={theme.border}
137
- paddingLeft={1} paddingRight={1}>
138
- <box flexDirection="column" width="100%">
139
- <markdown content={report.content || "(empty)"}
140
- fg={theme.markdownText} syntaxStyle={syntaxStyle} />
141
- </box>
142
- </scrollbox>
143
- </box>
144
- ) : (
145
- <box height={1}><text fg={theme.textMuted}>No runs yet — curator has not completed a cycle.</text></box>
146
- )}
147
- </box>
148
- </box>
149
- )
150
- }
151
-
152
- export const openCurator = (dialog: DialogContext) =>
153
- dialog.replace(<CuratorDialog />)
@@ -1,95 +0,0 @@
1
- // Browse available .eikon avatars from known directories with a live
2
- // preview. ↑/↓ to navigate, Enter to select, Esc closes (via DialogProvider).
3
-
4
- import { useMemo, useState } from "react"
5
- import { readFileSync } from "fs"
6
- import { homedir } from "os"
7
- import { join } from "path"
8
- import { useListKeys } from "../keys"
9
- import { useTheme } from "../theme"
10
- import { useDialog } from "../ui/dialog"
11
- import { AnimatedAvatar } from "../components/avatar/AnimatedAvatar"
12
- import { listEikons, parseEikon, type ParsedEikon } from "../components/avatar/eikon"
13
-
14
- const trunc = (s: string, n: number) => s.length <= n ? s : s.slice(0, n - 1) + "…"
15
-
16
- // Default search path for .eikon avatars: $HERMES_HOME/eikons.
17
- // If nothing is found the picker shows an empty state — see README
18
- // "Avatars (.eikon)" for where to drop files.
19
- const defaultDirs = (): string[] => {
20
- const hermesHome = process.env.HERMES_HOME || join(homedir(), ".hermes")
21
- return [join(hermesHome, "eikons")]
22
- }
23
-
24
- export const EikonPickerDialog = (props: {
25
- dirs?: string[]
26
- onSelect: (path: string) => void
27
- }) => {
28
- const theme = useTheme().theme
29
- const dialog = useDialog()
30
- const dirs = props.dirs ?? defaultDirs()
31
-
32
- const found = useMemo(() => listEikons(dirs), [dirs])
33
- const [cursor, setCursor] = useState(0)
34
-
35
- const cur = found[cursor]
36
- const parsed = useMemo<ParsedEikon | undefined>(() => {
37
- if (!cur) return undefined
38
- try { return parseEikon(readFileSync(cur.path, "utf8")) }
39
- catch { return undefined }
40
- }, [cur])
41
-
42
- useListKeys({
43
- active: true,
44
- count: found.length, setSel: setCursor,
45
- onActivate: () => { if (cur) { props.onSelect(cur.path); dialog.clear() } },
46
- })
47
-
48
- const w = (parsed?.meta.width ?? 48) + 2
49
- const h = Math.max(parsed?.meta.height ?? 24, 12)
50
-
51
- return (
52
- <box flexDirection="column" width={40 + w} height={h + 4}>
53
- <box height={1}><text fg={theme.primary}><strong>Pick Avatar</strong></text></box>
54
- <box height={1}><text fg={theme.textMuted}>{`${found.length} found · ↑↓ nav · Enter select · Esc close`}</text></box>
55
- <box height={1} />
56
- <box flexDirection="row" flexGrow={1}>
57
- {/* list */}
58
- <box width={38} marginRight={2}>
59
- <scrollbox scrollY flexGrow={1}>
60
- <box flexDirection="column" width="100%">
61
- {found.length === 0 ? (
62
- <box key="empty" height={1}><text fg={theme.textMuted}>No .eikon files found.</text></box>
63
- ) : found.map((e, i) => {
64
- const on = i === cursor
65
- return (
66
- <box key={e.path} flexDirection="column" paddingLeft={1} paddingRight={1}
67
- backgroundColor={on ? theme.backgroundElement : undefined}
68
- onMouseDown={() => setCursor(i)}>
69
- <box height={1}>
70
- <text fg={on ? theme.text : theme.textMuted}><strong>{trunc(e.meta.name, 34)}</strong></text>
71
- </box>
72
- <box height={1}>
73
- <text fg={theme.textMuted}>
74
- {`${e.meta.author ?? "—"} · ${e.meta.states.length} states · ${e.meta.width}×${e.meta.height}`}
75
- </text>
76
- </box>
77
- </box>
78
- )
79
- })}
80
- </box>
81
- </scrollbox>
82
- </box>
83
- {/* preview */}
84
- <box flexGrow={1} flexDirection="column" overflow="hidden">
85
- {parsed
86
- ? <AnimatedAvatar key={cur?.path ?? "none"} state="idle" eikon={parsed} />
87
- : <box key="blank" height={1}><text fg={theme.textMuted}>No preview.</text></box>}
88
- </box>
89
- </box>
90
- </box>
91
- )
92
- }
93
-
94
- export const openEikonPicker = (dialog: ReturnType<typeof useDialog>, onSelect: (path: string) => void) =>
95
- dialog.replace(<EikonPickerDialog onSelect={onSelect} />)
@@ -1,80 +0,0 @@
1
- // Help dialog — keyboard shortcut reference, generated from the
2
- // action catalog so it stays correct under user rebinds.
3
-
4
- import { useMemo } from "react"
5
- import { useTheme } from "../theme"
6
- import { useKeys, type Scope } from "../keys"
7
-
8
- type Group = { title: string; scope: Scope }
9
-
10
- const GROUPS: ReadonlyArray<Group> = [
11
- { title: "Global", scope: "global" },
12
- { title: "Composer", scope: "composer" },
13
- { title: "Lists", scope: "list" },
14
- { title: "Dialogs", scope: "dialog" },
15
- { title: "Sessions", scope: "sessions" },
16
- { title: "Agents", scope: "agents" },
17
- { title: "Config", scope: "config" },
18
- ]
19
-
20
- const COLS = 2
21
-
22
- export const HelpDialog = () => {
23
- const theme = useTheme().theme
24
- const keys = useKeys()
25
-
26
- const sections = useMemo(() =>
27
- GROUPS.map(g => ({
28
- title: g.title,
29
- rows: keys.all(g.scope)
30
- .filter(e => e.id !== "leader" && e.chord.length > 0)
31
- .map(e => [keys.print(e.id), e.desc] as const),
32
- })).filter(s => s.rows.length > 0),
33
- [keys])
34
-
35
- const total = sections.reduce((n, s) => n + s.rows.length + 2, 0)
36
- const split = Math.ceil(total / COLS)
37
-
38
- // Flow sections into two roughly-equal columns. A section goes to
39
- // column 1 once placing it in column 0 would overshoot the split.
40
- const cols: typeof sections[] = [[], []]
41
- let acc = 0
42
- for (const s of sections) {
43
- const h = s.rows.length + 2
44
- const i = acc + h <= split || cols[0].length === 0 ? 0 : 1
45
- cols[i].push(s)
46
- if (i === 0) acc += h
47
- }
48
-
49
- return (
50
- <box flexDirection="column" width={104}>
51
- <box height={1} flexDirection="row">
52
- <box flexGrow={1}>
53
- <text fg={theme.text}><strong>Keyboard Shortcuts</strong></text>
54
- </box>
55
- <text fg={theme.textMuted}>{`leader = ${keys.print("leader")}`}</text>
56
- </box>
57
- <box height={1} />
58
- <box flexDirection="row" gap={3}>
59
- {cols.map((col, ci) => (
60
- <box key={ci} flexDirection="column" flexGrow={1} flexBasis={0}>
61
- {col.map(s => (
62
- <box key={s.title} flexDirection="column" marginBottom={1}>
63
- <text fg={theme.primary}><strong>{s.title}</strong></text>
64
- {s.rows.map(([chord, desc]) => (
65
- <box key={chord + desc} flexDirection="row" height={1} paddingLeft={1}>
66
- <box width={14}><text fg={theme.accent}>{chord}</text></box>
67
- <box flexGrow={1} minWidth={0} height={1} overflow="hidden">
68
- <text fg={theme.textMuted}>{desc}</text>
69
- </box>
70
- </box>
71
- ))}
72
- </box>
73
- ))}
74
- </box>
75
- ))}
76
- </box>
77
- <text fg={theme.textMuted}>esc to close</text>
78
- </box>
79
- )
80
- }
@@ -1,92 +0,0 @@
1
- // Read-only transcript viewer for the *live* session (authoritative
2
- // gateway history, not herm's render state). Useful after resuming a
3
- // session (shows server messages herm hasn't rendered) and for sanity
4
- // checking what session.undo / rewind actually removed.
5
- //
6
- // Row shape comes from tui_gateway `_history_to_messages`:
7
- // user/assistant/system → {role, text}
8
- // tool → {role, name, context} (args summary, no result)
9
-
10
- import { useEffect, useState } from "react"
11
- import { useTheme, type Theme } from "../theme"
12
- import type { DialogContext } from "../ui/dialog"
13
- import type { Gateway } from "../app/gateway"
14
- import type { TranscriptMessage } from "../utils/gateway-types"
15
- import { trunc } from "../ui/fmt"
16
-
17
- type Res = { count: number; messages: TranscriptMessage[] }
18
-
19
- const tag = (m: TranscriptMessage, theme: Theme) =>
20
- m.role === "user" ? { label: "▸ You", fg: theme.info }
21
- : m.role === "assistant" ? { label: "◂ Agent", fg: theme.success }
22
- : m.role === "tool" ? { label: `⚙ ${m.name ?? "tool"}`, fg: theme.warning }
23
- : { label: "· system", fg: theme.textMuted }
24
-
25
- // Flatten native-mode parts-lists to the first text fragment so the
26
- // history preview renders something meaningful instead of [object Object].
27
- const flatten = (t: TranscriptMessage["text"]): string => {
28
- if (typeof t === "string") return t
29
- if (!Array.isArray(t)) return ""
30
- for (const p of t)
31
- if (p && typeof p === "object" && "type" in p && p.type === "text"
32
- && "text" in p && typeof p.text === "string") return p.text
33
- return ""
34
- }
35
-
36
- const body = (m: TranscriptMessage) =>
37
- m.role === "tool" ? (m.context ?? "") : flatten(m.text)
38
-
39
- const HistoryDialog = (props: { gw: Gateway }) => {
40
- const theme = useTheme().theme
41
- const [rows, setRows] = useState<TranscriptMessage[] | null>(null)
42
- const [err, setErr] = useState("")
43
-
44
- useEffect(() => {
45
- props.gw.request<Res>("session.history")
46
- .then(r => setRows(r.messages ?? []))
47
- .catch((e: Error) => { setErr(e.message); setRows([]) })
48
- }, [props.gw])
49
-
50
- const n = rows?.length ?? 0
51
- const h = Math.min(34, Math.max(8, n + 5))
52
-
53
- return (
54
- <box flexDirection="column" width={110} height={h}>
55
- <box height={1}><text fg={theme.primary}><strong>Session History</strong></text></box>
56
- <box height={1}>
57
- <text fg={err ? theme.error : theme.textMuted}>
58
- {err ? `⚠ ${err}` : `${n} messages · server-authoritative · Esc to close`}
59
- </text>
60
- </box>
61
- <box height={1} />
62
- {rows === null ? (
63
- <box height={1}><text fg={theme.textMuted}>loading…</text></box>
64
- ) : n === 0 ? (
65
- <box height={1}><text fg={theme.textMuted}>Empty — no turns yet.</text></box>
66
- ) : (
67
- <scrollbox scrollY flexGrow={1}>
68
- <box flexDirection="column">
69
- {rows.map((m, i) => {
70
- const t = tag(m, theme)
71
- return (
72
- <box key={i} height={1} flexDirection="row">
73
- <box width={14} flexShrink={0}>
74
- <text fg={t.fg}>{trunc(t.label, 13)}</text>
75
- </box>
76
- <box flexGrow={1} minWidth={0} height={1} overflow="hidden">
77
- <text fg={m.role === "tool" || m.role === "system" ? theme.textMuted : theme.text}>
78
- {body(m).replace(/\n/g, " ")}
79
- </text>
80
- </box>
81
- </box>
82
- )
83
- })}
84
- </box>
85
- </scrollbox>
86
- )}
87
- </box>
88
- )
89
- }
90
-
91
- export const openHistory = (dialog: DialogContext, gw: Gateway) =>
92
- dialog.replace(<HistoryDialog gw={gw} />)
@@ -1,115 +0,0 @@
1
- // Small read-only KV dialogs for /status, /usage, /profile.
2
- // /platforms has no structured RPC — it falls through to slash.exec
3
- // and renders as a system line (see UPSTREAM.md).
4
-
5
- import { useEffect, useState } from "react"
6
- import type { RGBA } from "@opentui/core"
7
- import { useTheme } from "../theme"
8
- import { KVBlock } from "../ui/kv"
9
- import { fmt, cost } from "../ui/fmt"
10
- import type { DialogContext } from "../ui/dialog"
11
- import type { Gateway } from "../app/gateway"
12
- import type { SessionInfo, SessionUsageResponse } from "../utils/gateway-types"
13
- import { listProfiles, activeProfileName } from "../utils/hermes-profiles"
14
- import { hermesPath } from "../utils/hermes-home"
15
-
16
- type Row = [string, string | undefined, RGBA?]
17
-
18
- const InfoDialog = (props: { title: string; rows: Row[]; note?: string }) => {
19
- const theme = useTheme().theme
20
- const body = props.rows.filter(r => r[1] !== undefined)
21
- return (
22
- <box flexDirection="column" minWidth={52} gap={1}>
23
- <box height={1}><text fg={theme.primary}><strong>{props.title}</strong></text></box>
24
- <box flexDirection="column"><KVBlock rows={body} /></box>
25
- {props.note
26
- ? <box height={1}><text fg={theme.textMuted}>{props.note}</text></box>
27
- : null}
28
- <box height={1}><text fg={theme.borderSubtle}>Esc to close</text></box>
29
- </box>
30
- )
31
- }
32
-
33
- // ── /status ──────────────────────────────────────────────────────────
34
-
35
- export function openStatus(dialog: DialogContext, info: SessionInfo | null, sid: string) {
36
- const toolsets = Object.keys(info?.tools ?? {})
37
- const nTools = Object.values(info?.tools ?? {}).reduce((n, v) => n + v.length, 0)
38
- const mcp = info?.mcp_servers ?? []
39
- const up = mcp.filter(s => s.connected).length
40
- dialog.replace(
41
- <InfoDialog title="Status" rows={[
42
- ["Version", info?.version || "—"],
43
- ["Model", info?.model || "—"],
44
- ["Profile", activeProfileName()],
45
- ["Home", hermesPath("")],
46
- ["CWD", info?.cwd || process.cwd()],
47
- ["Session", sid || "—"],
48
- ["Tools", `${nTools} in ${toolsets.length} toolset${toolsets.length === 1 ? "" : "s"}`],
49
- ["Skills", String(Object.values(info?.skills ?? {}).reduce((n, v) => n + v.length, 0))],
50
- ["MCP", mcp.length ? `${up}/${mcp.length} connected` : undefined],
51
- ]} />,
52
- )
53
- }
54
-
55
- // ── /usage ───────────────────────────────────────────────────────────
56
-
57
- const UsageDialog = ({ gw }: { gw: Gateway }) => {
58
- const theme = useTheme().theme
59
- const [u, setU] = useState<SessionUsageResponse | null>(null)
60
- const [err, setErr] = useState("")
61
- useEffect(() => {
62
- gw.request<SessionUsageResponse>("session.usage")
63
- .then(setU).catch(e => setErr(e instanceof Error ? e.message : String(e)))
64
- }, [gw])
65
-
66
- if (err) return <InfoDialog title="Usage" rows={[["Error", err, theme.error]]} />
67
- if (!u) return <InfoDialog title="Usage" rows={[["", "…"]]} />
68
-
69
- const ctx = u.context_max
70
- ? `${fmt(u.context_used ?? 0)} / ${fmt(u.context_max)} (${Math.round(u.context_percent ?? 0)}%)`
71
- : undefined
72
- return (
73
- <InfoDialog title="Usage" note={u.cost_status === "estimated" ? "cost is estimated" : undefined} rows={[
74
- ["Model", u.model || "—"],
75
- ["API calls", String(u.calls ?? 0)],
76
- ["Input", fmt(u.input ?? 0)],
77
- ["Output", fmt(u.output ?? 0)],
78
- ["Cache r/w", (u.cache_read || u.cache_write) ? `${fmt(u.cache_read ?? 0)} / ${fmt(u.cache_write ?? 0)}` : undefined],
79
- ["Total", fmt(u.total ?? 0)],
80
- ["Context", ctx],
81
- ["Cost", u.cost_usd != null ? cost(u.cost_usd) : undefined, theme.accent],
82
- ]} />
83
- )
84
- }
85
-
86
- export const openUsage = (dialog: DialogContext, gw: Gateway) =>
87
- dialog.replace(<UsageDialog gw={gw} />)
88
-
89
- // ── /profile ─────────────────────────────────────────────────────────
90
-
91
- const ProfileDialog = () => {
92
- const [p, setP] = useState<import("../utils/hermes-profiles").ProfileInfo | null | undefined>(undefined)
93
- const active = activeProfileName()
94
- useEffect(() => {
95
- listProfiles().then(ps => setP(ps.find(x => x.name === active) ?? null))
96
- .catch(() => setP(null))
97
- }, [])
98
- if (p === undefined) return <InfoDialog title="Profile" rows={[["", "…"]]} />
99
- return (
100
- <InfoDialog title="Profile" note={p ? undefined : "profile directory not found"} rows={[
101
- ["Active", active],
102
- ["Home", p?.path ?? hermesPath("")],
103
- ["Model", p?.model ?? "—"],
104
- ["Provider", p?.provider ?? "—"],
105
- ["Skills", p ? String(p.skill_count) : undefined],
106
- ["Gateway", p?.gateway_running ? "running" : "stopped"],
107
- ["Sticky", p?.is_sticky ? "yes" : undefined],
108
- ["Alias", p?.is_default ? undefined : p?.has_alias ? `~/.local/bin/${active}` : "—"],
109
- [".env", p?.has_env ? "present" : "—"],
110
- ]} />
111
- )
112
- }
113
-
114
- export const openProfile = (dialog: DialogContext) =>
115
- dialog.replace(<ProfileDialog />)