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

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,367 +0,0 @@
1
- import { useState, useEffect, useCallback, useMemo, useRef, memo } from "react"
2
- import { useKeyboard, useTerminalDimensions } from "@opentui/react"
3
- import type { ScrollBoxRenderable } from "@opentui/core"
4
- import {
5
- board, detail, assignees, tailLog, q, STATUSES,
6
- type Task, type Status, type Detail,
7
- } from "../utils/hermes-kanban"
8
- import { useKeys } from "../keys"
9
- import { useTheme } from "../theme"
10
- import { useGateway } from "../app/gateway"
11
- import { useDialog } from "../ui/dialog"
12
- import { useToast } from "../ui/toast"
13
- import { DialogSelect } from "../ui/dialog-select"
14
- import { openConfirm } from "../dialogs/confirm"
15
- import { openTextPrompt } from "../dialogs/text-prompt"
16
- import { openCreateTask } from "../dialogs/new-task"
17
- import { TabShell } from "../ui/shell"
18
- import { KVBlock } from "../ui/kv"
19
- import { ago, trunc } from "../ui/fmt"
20
-
21
- // Operator board for ~/.hermes/kanban.db.
22
- //
23
- // Reads are sidecar SQLite. Every write routes through
24
- // `shell.exec → hermes kanban <verb>` so kanban_db.py owns the state
25
- // machine (recompute_ready, link-cycle guard, task_events, notify
26
- // subs) and herm can't drift from the CLI/dashboard.
27
- //
28
- // Verbs exposed here cover the human-operator loop from the
29
- // kanban-orchestrator/worker skills:
30
- //
31
- // n create c comment a assign
32
- // N create-child u unblock (+answer) d archive
33
- // D dispatch r reload l worker log
34
- // Enter detail ←→↑↓ nav Esc close pane
35
-
36
- type Sh = { stdout: string; stderr: string; code: number }
37
-
38
- const HEAD: Record<Status, string> = {
39
- triage: "triage", todo: "todo", ready: "ready",
40
- running: "running", blocked: "blocked", done: "done",
41
- }
42
-
43
- const Card = memo((p: { id: string; t: Task; on: boolean; colOn: boolean; onPick: () => void }) => {
44
- const theme = useTheme().theme
45
- const fg = p.on ? theme.accent : p.colOn ? theme.text : theme.textMuted
46
- return (
47
- <box id={p.id} height={2} flexDirection="column"
48
- backgroundColor={p.on ? theme.backgroundElement : undefined}
49
- onMouseDown={p.onPick}>
50
- <box height={1} overflow="hidden">
51
- <text>
52
- <span fg={p.on ? theme.primary : theme.textMuted}>{p.on ? "▸ " : " "}</span>
53
- <span fg={fg}>{trunc(p.t.title, 60)}</span>
54
- </text>
55
- </box>
56
- <box height={1} overflow="hidden">
57
- <text fg={theme.textMuted}>
58
- {` ${p.t.id.slice(0, 8)} ${p.t.assignee ?? "—"}${p.t.priority ? ` P${p.t.priority}` : ""}${p.t.pid ? ` pid ${p.t.pid}` : ""}`}
59
- </text>
60
- </box>
61
- </box>
62
- )
63
- })
64
-
65
- const Column = memo((p: {
66
- status: Status; tasks: Task[]; on: boolean; sel: number
67
- onPick: (i: number) => void
68
- }) => {
69
- const theme = useTheme().theme
70
- const box = useRef<ScrollBoxRenderable | null>(null)
71
- const id = (i: number) => `kb-${p.status}-${i}`
72
- // Keep the selected card in view. Fires on ↑↓ and on ←→ (p.on flips
73
- // true) so entering a column that was previously scrolled away snaps
74
- // to row 0. No-op while this column isn't active.
75
- useEffect(() => {
76
- if (p.on && p.tasks.length > 0) box.current?.scrollChildIntoView(id(p.sel))
77
- }, [p.on, p.sel, p.tasks.length])
78
- const tint = p.status === "blocked" ? theme.warning
79
- : p.status === "running" ? theme.success
80
- : p.status === "done" ? theme.textMuted : theme.primary
81
- return (
82
- <box flexDirection="column" flexGrow={1} flexBasis={0} minWidth={20}
83
- border borderColor={p.on ? theme.primary : theme.border} paddingLeft={1} paddingRight={1}>
84
- <box height={1}>
85
- <text>
86
- <span fg={tint}><strong>{HEAD[p.status]}</strong></span>
87
- <span fg={theme.textMuted}>{` ${p.tasks.length}`}</span>
88
- </text>
89
- </box>
90
- <scrollbox ref={box} scrollY flexGrow={1}>
91
- <box flexDirection="column" width="100%">
92
- {p.tasks.map((t, i) => (
93
- <Card key={t.id} id={id(i)} t={t} on={p.on && i === p.sel} colOn={p.on}
94
- onPick={() => p.onPick(i)} />
95
- ))}
96
- </box>
97
- </scrollbox>
98
- </box>
99
- )
100
- })
101
-
102
- type Pane = { kind: "detail"; d: Detail } | { kind: "log"; id: string; text: string }
103
-
104
- const SidePane = memo((p: { pane: Pane }) => {
105
- const { theme, syntaxStyle } = useTheme()
106
- if (p.pane.kind === "log") return (
107
- <box flexDirection="column" padding={1} border borderColor={theme.border}
108
- backgroundColor={theme.backgroundPanel} width="50%">
109
- <box height={1}><text>
110
- <span fg={theme.primary}><strong>{p.pane.id}</strong></span>
111
- <span fg={theme.textMuted}>{" · worker log (tail)"}</span>
112
- </text></box>
113
- <box height={1} />
114
- <scrollbox scrollY flexGrow={1}>
115
- <text wrapMode="word" fg={theme.textMuted}>{p.pane.text || "(empty)"}</text>
116
- </scrollbox>
117
- </box>
118
- )
119
- const d = p.pane.d
120
- return (
121
- <box flexDirection="column" padding={1} border borderColor={theme.border}
122
- backgroundColor={theme.backgroundPanel} width="50%">
123
- <box height={1}>
124
- <text>
125
- <span fg={theme.primary}><strong>{d.id}</strong></span>
126
- <span fg={theme.textMuted}>{` · ${d.status} · ${ago(d.updated_at)}`}</span>
127
- </text>
128
- </box>
129
- <box height={1}><text fg={theme.accent}><strong>{d.title}</strong></text></box>
130
- <box height={1} />
131
- <KVBlock rows={[
132
- ["Assignee", d.assignee ?? "—"],
133
- ["Priority", d.priority ? `P${d.priority}` : "—"],
134
- ["Tenant", d.tenant ?? undefined],
135
- ["Parents", d.parents.length ? d.parents.join(", ") : undefined],
136
- ["Children", d.children.length ? d.children.join(", ") : undefined],
137
- ["PID", d.pid ? String(d.pid) : undefined],
138
- ["Error", d.error ?? undefined, theme.error],
139
- ]} />
140
- <box height={1} />
141
- <scrollbox scrollY flexGrow={1}>
142
- <box flexDirection="column" width="100%">
143
- {d.body ? <markdown content={d.body} fg={theme.markdownText} syntaxStyle={syntaxStyle} /> : null}
144
- {d.result ? <>
145
- <box height={1} />
146
- <box height={1}><text fg={theme.textMuted}>Result</text></box>
147
- <markdown content={d.result} fg={theme.markdownText} syntaxStyle={syntaxStyle} />
148
- </> : null}
149
- {d.comments.length > 0 ? <>
150
- <box height={1} />
151
- <box height={1}><text fg={theme.textMuted}>{`Comments (${d.comments.length})`}</text></box>
152
- {d.comments.map((c, i) => (
153
- <box key={i} flexDirection="column" marginTop={1}>
154
- <box height={1}><text fg={theme.textMuted}>{`${c.author} · ${ago(c.at)}`}</text></box>
155
- <text wrapMode="word">{c.body}</text>
156
- </box>
157
- ))}
158
- </> : null}
159
- </box>
160
- </scrollbox>
161
- <box height={1}><text fg={theme.textMuted}>a assign c comment u unblock d archive l log N child</text></box>
162
- </box>
163
- )
164
- })
165
-
166
- export const Kanban = memo((props: { focused?: boolean }) => {
167
- const theme = useTheme().theme
168
- const gw = useGateway()
169
- const dialog = useDialog()
170
- const toast = useToast()
171
- const dims = useTerminalDimensions()
172
- const keys = useKeys()
173
-
174
- const [data, setData] = useState(() => board())
175
- const [col, setCol] = useState(0)
176
- const [row, setRow] = useState(0)
177
- const [pane, setPane] = useState<Pane | null>(null)
178
-
179
- const load = useCallback(() => {
180
- setData(board())
181
- setPane(p => p?.kind === "detail" ? (d => d ? { kind: "detail", d } : null)(detail(p.d.id)) : p)
182
- }, [])
183
- useEffect(load, [load])
184
-
185
- // Cheap live-ish refresh while focused AND something is running.
186
- // `running` changing length recreates the interval; back off to
187
- // manual `r` when idle — no dispatcher → no row churn.
188
- const running = data.get("running")?.length ?? 0
189
- useEffect(() => {
190
- if (!props.focused || running === 0) return
191
- const t = setInterval(load, 3000)
192
- return () => clearInterval(t)
193
- }, [props.focused, running, load])
194
-
195
- const total = [...data.values()].reduce((a, v) => a + v.length, 0)
196
-
197
- // Drop empty columns at narrow widths but never collapse the one
198
- // the selection is on. An entirely empty board keeps full chrome so
199
- // the layout reads as a kanban, not a blank slate.
200
- const cols = useMemo(() => {
201
- const all = STATUSES.map(s => ({ status: s, tasks: data.get(s) ?? [] }))
202
- if (dims.width >= 160 || total === 0) return all
203
- return all.filter((c, i) => c.tasks.length > 0 || i === col)
204
- }, [data, dims.width, col, total])
205
-
206
- const cur = cols[Math.min(col, cols.length - 1)]
207
- const task = cur?.tasks[Math.min(row, (cur?.tasks.length ?? 1) - 1)]
208
-
209
- // `shell.exec → hermes kanban <verb>`. Non-zero → toast the CLI's
210
- // own stderr (cycle detected, unknown id, etc). reload on success.
211
- const sh = useCallback((argv: string, ok?: string) =>
212
- gw.request<Sh>("shell.exec", { command: `hermes kanban ${argv}` }).then(r => {
213
- if (r.code !== 0) throw new Error((r.stderr || r.stdout || `exit ${r.code}`).trim())
214
- if (ok) toast.show({ variant: "success", message: ok })
215
- load()
216
- return r.stdout
217
- }).catch((e: Error) => void toast.show({ variant: "error", message: trunc(e.message, 120) })),
218
- [gw, toast, load])
219
-
220
- // ── Actions ────────────────────────────────────────────────────────
221
-
222
- const live = useRef({ task })
223
- live.current = { task }
224
-
225
- const create = useCallback((parent?: Task) =>
226
- openCreateTask(dialog, {
227
- assignees: assignees(),
228
- parent: parent ? { id: parent.id, title: parent.title } : undefined,
229
- }).then(d => {
230
- if (!d) return
231
- const flags = [
232
- d.assignee ? `--assignee ${q(d.assignee)}` : "",
233
- d.body ? `--body ${q(d.body)}` : "",
234
- d.priority ? `--priority ${d.priority}` : "",
235
- d.parent ? `--parent ${q(d.parent)}` : "",
236
- ].filter(Boolean).join(" ")
237
- return sh(`create ${q(d.title)} ${flags}`.trim(),
238
- `Created${d.assignee ? ` → ${d.assignee}` : ""}`)
239
- }), [dialog, sh])
240
-
241
- const assign = useCallback((t: Task) => {
242
- const opts = [{ title: "(unassigned)", value: "none" },
243
- ...assignees().map(n => ({ title: n, value: n }))]
244
- dialog.replace(
245
- <DialogSelect title={`Assign ${t.id}`} options={opts} current={t.assignee ?? "none"}
246
- placeholder="Search profiles…"
247
- onSelect={o => {
248
- dialog.clear()
249
- void sh(`assign ${q(t.id)} ${q(o.value)}`,
250
- o.value === "none" ? `Unassigned ${t.id}` : `${t.id} → ${o.value}`)
251
- }} />,
252
- )
253
- }, [dialog, sh])
254
-
255
- const comment = useCallback((t: Task) =>
256
- openTextPrompt(dialog, { title: `Comment on ${t.id}`, label: t.title })
257
- .then(v => v && sh(`comment ${q(t.id)} ${q(v)} --author user`, "Comment added")),
258
- [dialog, sh])
259
-
260
- const unblock = useCallback((t: Task) => {
261
- if (t.status !== "blocked")
262
- return void toast.show({ variant: "info", message: `${t.id} is ${t.status}, not blocked` })
263
- return openTextPrompt(dialog, {
264
- title: `Unblock ${t.id}`, label: "Answer (posted as comment, then task → ready)",
265
- }).then(async v => {
266
- // Comment first so the respawned worker sees the answer in its
267
- // context (build_worker_context reads the thread). Empty answer
268
- // still unblocks — operator just wants a retry.
269
- if (v) await sh(`comment ${q(t.id)} ${q(v)} --author user`)
270
- return sh(`unblock ${q(t.id)}`, `Unblocked ${t.id}`)
271
- })
272
- }, [dialog, sh, toast])
273
-
274
- const archive = useCallback((t: Task) =>
275
- openConfirm(dialog, {
276
- title: "Archive task?", danger: true, yes: "archive",
277
- body: `${t.id} · ${trunc(t.title, 60)}\n\nMoves to 'archived' and ends any open run. Children stay; their dependency on this task is treated as satisfied.`,
278
- }).then(ok => { if (ok) void sh(`archive ${q(t.id)}`, `Archived ${t.id}`) }),
279
- [dialog, sh])
280
-
281
- const dispatch = useCallback(() => {
282
- const ready = data.get("ready")?.length ?? 0
283
- if (ready === 0)
284
- return void toast.show({ variant: "info", message: "No tasks in 'ready'" })
285
- return openConfirm(dialog, {
286
- title: "Dispatch ready tasks?",
287
- body: `${ready} task${ready === 1 ? "" : "s"} in 'ready'. Spawns one worker per task (one pass).`,
288
- yes: "dispatch",
289
- }).then(ok => { if (ok) void sh("dispatch --json", `Dispatched (${ready} ready)`) })
290
- }, [dialog, sh, toast, data])
291
-
292
- const showLog = useCallback((t: Task) => {
293
- const text = tailLog(t.id)
294
- if (text == null)
295
- return void toast.show({ variant: "info", message: `No worker log for ${t.id}` })
296
- setPane({ kind: "log", id: t.id, text })
297
- }, [toast])
298
-
299
- // Data-driven verb table. `when` gates availability; anything that
300
- // needs a selected task reads through `live.current`.
301
- type Act = { key: string; title: string; when: (t?: Task) => boolean; run: (t?: Task) => void }
302
- const ACTS = useMemo<Act[]>(() => [
303
- { key: "n", title: "New task", when: () => true, run: () => void create() },
304
- { key: "N", title: "New child", when: t => !!t, run: t => void create(t) },
305
- { key: "a", title: "Assign", when: t => !!t, run: t => assign(t!) },
306
- { key: "c", title: "Comment", when: t => !!t, run: t => void comment(t!) },
307
- { key: "u", title: "Unblock", when: t => t?.status === "blocked", run: t => void unblock(t!) },
308
- { key: "d", title: "Archive", when: t => !!t, run: t => void archive(t!) },
309
- { key: "l", title: "Worker log", when: t => !!t, run: t => showLog(t!) },
310
- { key: "D", title: "Dispatch", when: () => true, run: () => void dispatch() },
311
- ], [create, assign, comment, unblock, archive, showLog, dispatch])
312
-
313
- useKeyboard((key) => {
314
- if (!props.focused || dialog.stack.length > 0) return
315
- if (key.name === "escape" && pane) return setPane(null)
316
- if (keys.match("list.refresh", key)) return load()
317
- if (key.name === "left")
318
- return setCol(c => { const n = Math.max(0, c - 1); setRow(0); return n })
319
- if (key.name === "right")
320
- return setCol(c => { const n = Math.min(cols.length - 1, c + 1); setRow(0); return n })
321
- if (key.name === "up")
322
- return setRow(r => Math.max(0, r - 1))
323
- if (key.name === "down")
324
- return setRow(r => Math.min((cur?.tasks.length ?? 1) - 1, r + 1))
325
- if (key.name === "return" && task)
326
- return setPane(p => p?.kind === "detail" && p.d.id === task.id
327
- ? null : (d => d ? { kind: "detail", d } : null)(detail(task.id)))
328
- const t = live.current.task
329
- const hit = ACTS.find(a => a.key === key.raw && a.when(t))
330
- if (hit) return hit.run(t)
331
- })
332
-
333
- const hint = useMemo(() => {
334
- const t = task
335
- return ["←→↑↓ nav", "Enter detail",
336
- ...ACTS.filter(a => a.when(t)).map(a => `${a.key} ${a.title.toLowerCase()}`),
337
- "r reload"].join(" ")
338
- }, [ACTS, task])
339
-
340
- return (
341
- <box flexDirection="row" flexGrow={1}>
342
- <TabShell
343
- title={`Kanban · ${total} task${total === 1 ? "" : "s"}${running ? ` · ${running} running` : ""}`}
344
- hint={hint}
345
- >
346
- <box flexDirection="row" flexGrow={1} gap={1}>
347
- {cols.map((c, i) => (
348
- <Column key={c.status} status={c.status} tasks={c.tasks}
349
- on={i === Math.min(col, cols.length - 1)} sel={row}
350
- onPick={r => {
351
- setCol(i); setRow(r)
352
- const d = detail(c.tasks[r].id)
353
- if (d) setPane({ kind: "detail", d })
354
- }} />
355
- ))}
356
- </box>
357
- {total === 0 && (
358
- <box flexDirection="column" marginTop={1}>
359
- <text fg={theme.textMuted}>no tasks — board at ~/.hermes/kanban.db</text>
360
- <text fg={theme.textMuted}>press <span fg={theme.accent}>n</span> to create one</text>
361
- </box>
362
- )}
363
- </TabShell>
364
- {pane ? <SidePane pane={pane} /> : null}
365
- </box>
366
- )
367
- })
@@ -1,294 +0,0 @@
1
- import { useState, memo } from "react"
2
- import type { MemoryProviderInfo, MemoryFileInfo } from "../utils/hermes-home"
3
- import type { MemoryActivity } from "../utils/memory-activity"
4
- import { useHome, home } from "../home"
5
- import { ago } from "../ui/fmt"
6
- import { useTheme, type Theme } from "../theme"
7
- import { useListKeys } from "../keys"
8
- import { useDialog } from "../ui/dialog"
9
- import { useToast } from "../ui/toast"
10
- import { useGateway } from "../app/gateway"
11
- import { openConfirm } from "../dialogs/confirm"
12
- import { TabShell } from "../ui/shell"
13
- import { KVBlock } from "../ui/kv"
14
-
15
- // ─── Helpers ──────────────────────────────────────────────────────────
16
-
17
- function usageColor(pct: number, theme: Theme): string {
18
- if (pct >= 95) return theme.error.toString()
19
- if (pct >= 80) return theme.warning.toString()
20
- return theme.success.toString()
21
- }
22
-
23
- function bar(pct: number, w: number): string {
24
- const filled = Math.round((pct / 100) * w)
25
- return "█".repeat(filled) + "░".repeat(w - filled)
26
- }
27
-
28
- const DESC: Record<string, string> = {
29
- builtin: "File-based §-delimited entries (MEMORY.md + USER.md). Always active.",
30
- mem0: "Server-side LLM fact extraction with semantic search and reranking.",
31
- honcho: "AI-native cross-session user modeling with dialectic Q&A.",
32
- hindsight: "Knowledge graph with entity resolution and multi-strategy retrieval.",
33
- holographic: "Local SQLite fact store with FTS5, trust scoring, HRR retrieval.",
34
- openviking: "Session-managed memory with tiered retrieval.",
35
- retaindb: "Cloud memory API with hybrid search and 7 memory types.",
36
- byterover: "Persistent knowledge tree via brv CLI.",
37
- supermemory: "Semantic long-term memory with profile recall and session ingest.",
38
- }
39
-
40
- // ─── Component ────────────────────────────────────────────────────────
41
-
42
- export const Memory = memo((props: { focused?: boolean }) => {
43
- const theme = useTheme().theme
44
- const dialog = useDialog()
45
- const toast = useToast()
46
- const gw = useGateway()
47
- const [sel, setSel] = useState(0)
48
-
49
- const config = useHome("config")
50
- const memory = useHome("memory")
51
- const userProfile = useHome("userProfile")
52
- const providers = useHome("memoryProviders") ?? []
53
- const activity = useHome("memoryActivity") ?? []
54
-
55
- const cfg = config?.memory
56
- const active = cfg?.provider || ""
57
-
58
- const cur = providers[sel]
59
- const on = !!cur && (cur.name === "builtin" || cur.name === active)
60
-
61
- // Activate/deactivate writes memory.provider to disk via cli.exec
62
- // (the gateway's config.set whitelist doesn't include it, so the RPC
63
- // path 4002s). Applies on the next session — the running agent keeps
64
- // the provider it was constructed with.
65
- const toggle = async () => {
66
- if (!cur || cur.name === "builtin") return
67
- const isOn = cur.name === active
68
- const ok = await openConfirm(dialog, {
69
- title: isOn ? "Deactivate memory provider?" : "Activate memory provider?",
70
- body: isOn
71
- ? `Clear '${cur.name}' as the active provider (revert to built-in only).`
72
- : `Set '${cur.name}' as the active provider. Ensure required env vars are set (Env tab).`,
73
- yes: isOn ? "deactivate" : "activate",
74
- })
75
- if (!ok) return
76
- const { writeConfig } = await import("../config/lane")
77
- const r = await writeConfig(gw, [{ key: "memory.provider", to: isOn ? "" : cur.name }])
78
- if (r.failed.length) return toast.show({ variant: "error", message: r.failed[0].err })
79
- home.invalidate("config")
80
- home.invalidate("memoryProviders")
81
- toast.show({ variant: "success", message: isOn ? "Deactivated" : `Activated ${cur.name} — new sessions pick this up` })
82
- }
83
-
84
- const keys = useListKeys({
85
- active: !!props.focused && dialog.stack.length === 0,
86
- count: providers.length, setSel,
87
- onToggle: toggle,
88
- onRefresh: () => {
89
- home.invalidate("memoryProviders")
90
- home.invalidate("memoryActivity")
91
- toast.show({ variant: "info", message: "Reloaded", duration: 1000 })
92
- },
93
- })
94
-
95
- const feed = !cur ? []
96
- : cur.name === "builtin" ? activity
97
- : activity.filter(a => a.provider === cur.name)
98
-
99
- return (
100
- <box flexDirection="row" flexGrow={1}>
101
- <TabShell title="Memory Providers" grow={1}
102
- hint={`${keys.print("list.up")}${keys.print("list.down")} select ${keys.print("list.toggle")} activate`}>
103
- <scrollbox scrollY flexGrow={1}>
104
- {providers.map((p, i) => {
105
- const pOn = p.name === "builtin" || p.name === active
106
- const has = Object.keys(p.config).length > 0
107
- const dot = pOn ? "●" : has ? "◐" : "○"
108
- const fg = pOn ? theme.success : has ? theme.warning : theme.textMuted
109
- const tag = pOn ? "active" : has ? "configured" : ""
110
- return (
111
- <box
112
- key={p.name}
113
- flexDirection="column"
114
- marginBottom={1}
115
- backgroundColor={i === sel ? theme.backgroundElement : undefined}
116
- onMouseDown={() => setSel(i)}
117
- onMouseMove={() => setSel(i)}
118
- >
119
- <box height={1}>
120
- <text>
121
- <span fg={fg}>{dot} </span>
122
- <span fg={i === sel ? theme.accent : theme.text}>{p.name}</span>
123
- {tag ? <span fg={fg}> ({tag})</span> : null}
124
- </text>
125
- </box>
126
- <box height={1} overflow="hidden" paddingLeft={2}>
127
- <text fg={theme.textMuted}>{DESC[p.name] || "—"}</text>
128
- </box>
129
- </box>
130
- )
131
- })}
132
- </scrollbox>
133
- </TabShell>
134
-
135
- <TabShell
136
- title={cur?.name ?? "Provider"}
137
- hint={on ? "● active" : "○ inactive"}
138
- grow={2}
139
- >
140
- {cur ? (
141
- <ProviderDetail provider={cur} active={active} cfg={cfg}
142
- memory={memory} userProfile={userProfile} feed={feed} />
143
- ) : (
144
- <text fg={theme.textMuted}>Select a provider</text>
145
- )}
146
- </TabShell>
147
- </box>
148
- )
149
- })
150
-
151
- // ─── Provider Detail ──────────────────────────────────────────────────
152
-
153
- type MemoryCfg = {
154
- memory_enabled: boolean
155
- user_profile_enabled: boolean
156
- memory_char_limit: number
157
- user_char_limit: number
158
- provider: string
159
- nudge_interval: number
160
- flush_min_turns: number
161
- }
162
-
163
- const ProviderDetail = memo((props: {
164
- provider: MemoryProviderInfo
165
- active: string
166
- cfg: MemoryCfg | undefined
167
- memory: MemoryFileInfo | null | undefined
168
- userProfile: MemoryFileInfo | null | undefined
169
- feed: MemoryActivity[]
170
- }) => {
171
- const theme = useTheme().theme
172
- const p = props.provider
173
- const on = p.name === "builtin" || p.name === props.active
174
-
175
- return (
176
- <scrollbox scrollY flexGrow={1}>
177
- <box flexDirection="column">
178
- <box minHeight={1}>
179
- <text wrapMode="word" fg={theme.textMuted}>{DESC[p.name] || "Memory provider"}</text>
180
- </box>
181
- <box height={1} />
182
-
183
- {p.name === "builtin" ? (
184
- <box flexDirection="column">
185
- {props.cfg ? (
186
- <>
187
- <KVBlock rows={[
188
- ["Notes", props.cfg.memory_enabled ? "enabled" : "disabled",
189
- props.cfg.memory_enabled ? theme.success : theme.error],
190
- ["Profile", props.cfg.user_profile_enabled ? "enabled" : "disabled",
191
- props.cfg.user_profile_enabled ? theme.success : theme.error],
192
- ]} />
193
- <box height={1} />
194
- </>
195
- ) : null}
196
- <CapacityBar title="Notes (MEMORY.md)" info={props.memory ?? null} />
197
- <box height={1} />
198
- <CapacityBar title="Profile (USER.md)" info={props.userProfile ?? null} />
199
- </box>
200
- ) : null}
201
-
202
- {p.name !== "builtin" && on && props.cfg ? (
203
- <>
204
- <box height={1}><text fg={theme.accent}><strong>Agent Settings</strong></text></box>
205
- <KVBlock rows={[
206
- ["Nudge", `every ${props.cfg.nudge_interval} turns`],
207
- ["Flush", `after ${props.cfg.flush_min_turns} turns`],
208
- ]} />
209
- <box height={1} />
210
- </>
211
- ) : null}
212
-
213
- {Object.keys(p.config).length > 0 ? (
214
- <>
215
- <box height={1}><text fg={theme.accent}><strong>Local Configuration</strong></text></box>
216
- <KVBlock rows={Object.entries(p.config).map(([k, v]) => [k, String(v)] as [string, string])} />
217
- </>
218
- ) : p.name !== "builtin" ? (
219
- <box height={1} marginTop={1}>
220
- <text fg={theme.textMuted}>No local config found. Run `hermes memory setup` to configure.</text>
221
- </box>
222
- ) : null}
223
-
224
- <ActivityFeed items={props.feed} own={p.name} />
225
- </box>
226
- </scrollbox>
227
- )
228
- })
229
-
230
- // ─── Activity Feed ────────────────────────────────────────────────────
231
-
232
- const OP_GLYPH = { write: "+", read: "?" } as const
233
-
234
- const ActivityFeed = memo((props: { items: MemoryActivity[]; own: string }) => {
235
- const theme = useTheme().theme
236
- const all = props.own === "builtin"
237
- const nW = props.items.filter(a => a.op === "write").length
238
- return (
239
- <box flexDirection="column" marginTop={1}>
240
- <box height={1}>
241
- <text>
242
- <span fg={theme.accent}><strong>Recent Activity</strong></span>
243
- {props.items.length
244
- ? <span fg={theme.textMuted}> · {nW} writes, {props.items.length - nW} reads</span>
245
- : null}
246
- </text>
247
- </box>
248
- {props.items.length === 0 ? (
249
- <box height={1}>
250
- <text fg={theme.textMuted}>No memory-tool calls in the last ~2000 messages</text>
251
- </box>
252
- ) : null}
253
- {props.items.map((a, i) => (
254
- <box key={i} height={1} flexDirection="row" overflow="hidden">
255
- <text>
256
- <span fg={a.op === "write" ? theme.success : theme.textMuted}>{OP_GLYPH[a.op]} </span>
257
- <span fg={theme.textMuted}>{ago(a.ts).padEnd(8)}</span>
258
- {all && a.provider !== "builtin"
259
- ? <span fg={theme.primary}>{a.provider}·</span>
260
- : null}
261
- <span fg={theme.text}>{a.verb}</span>
262
- <span fg={theme.textMuted}> {a.summary}</span>
263
- </text>
264
- </box>
265
- ))}
266
- </box>
267
- )
268
- })
269
-
270
- // ─── Capacity Bar ─────────────────────────────────────────────────────
271
-
272
- const CapacityBar = memo((props: { title: string; info: MemoryFileInfo | null }) => {
273
- const theme = useTheme().theme
274
- if (!props.info) {
275
- return <box height={1}><text fg={theme.textMuted}>{props.title}: unavailable</text></box>
276
- }
277
- const color = usageColor(props.info.usagePercent, theme)
278
- return (
279
- <box flexDirection="column">
280
- <box height={1}>
281
- <text>
282
- <span fg={theme.text}>{props.title}</span>
283
- <span fg={theme.textMuted}> · {props.info.entryCount} entries</span>
284
- </text>
285
- </box>
286
- <box height={1}>
287
- <text>
288
- <span fg={color}>{bar(props.info.usagePercent, 20)}</span>
289
- <span fg={theme.textMuted}> {props.info.charCount}/{props.info.charLimit} ({props.info.usagePercent}%)</span>
290
- </text>
291
- </box>
292
- </box>
293
- )
294
- })