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

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 (187) hide show
  1. package/highlights-eq9cgrbb.scm +604 -0
  2. package/highlights-ghv9g403.scm +205 -0
  3. package/highlights-hk7bwhj4.scm +284 -0
  4. package/highlights-r812a2qc.scm +150 -0
  5. package/highlights-x6tmsnaa.scm +115 -0
  6. package/index.js +10375 -0
  7. package/injections-73j83es3.scm +27 -0
  8. package/package.json +14 -64
  9. package/parser.worker.js +8 -0
  10. package/tree-sitter-3jzf13jk.wasm +0 -0
  11. package/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  12. package/tree-sitter-markdown-411r6y9b.wasm +0 -0
  13. package/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  14. package/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  15. package/tree-sitter-zig-e78zbjpm.wasm +0 -0
  16. package/scripts/postinstall.ts +0 -29
  17. package/src/app/gateway.tsx +0 -83
  18. package/src/app/gatewayEvents.ts +0 -203
  19. package/src/app/launch.ts +0 -41
  20. package/src/app/skin.tsx +0 -31
  21. package/src/app/spawnHistory.ts +0 -75
  22. package/src/app/tabs.ts +0 -23
  23. package/src/app/turnReducer.ts +0 -390
  24. package/src/app/useAppKeys.ts +0 -268
  25. package/src/app/useAtRefPopover.ts +0 -99
  26. package/src/app/useInputHistory.ts +0 -66
  27. package/src/app/useSession.ts +0 -102
  28. package/src/app/useSlashCommands.ts +0 -70
  29. package/src/app/useSlashPopover.ts +0 -48
  30. package/src/app.tsx +0 -917
  31. package/src/commands/slash.ts +0 -151
  32. package/src/components/avatar/AnimatedAvatar.tsx +0 -66
  33. package/src/components/avatar/eikon.ts +0 -144
  34. package/src/components/avatar/states/error.ts +0 -1155
  35. package/src/components/avatar/states/idle.ts +0 -1155
  36. package/src/components/avatar/states/index.ts +0 -30
  37. package/src/components/avatar/states/listening.ts +0 -1155
  38. package/src/components/avatar/states/speaking.ts +0 -1155
  39. package/src/components/avatar/states/thinking.ts +0 -1155
  40. package/src/components/avatar/states/working.ts +0 -1155
  41. package/src/components/chat/AtRefPopover.tsx +0 -54
  42. package/src/components/chat/CodeBlock.tsx +0 -67
  43. package/src/components/chat/Composer.tsx +0 -347
  44. package/src/components/chat/DiffBlock.tsx +0 -116
  45. package/src/components/chat/ErrorBlock.tsx +0 -70
  46. package/src/components/chat/MediaChip.tsx +0 -114
  47. package/src/components/chat/MessageItem.tsx +0 -282
  48. package/src/components/chat/MessageList.tsx +0 -114
  49. package/src/components/chat/PromptCard.tsx +0 -359
  50. package/src/components/chat/SlashPopover.tsx +0 -158
  51. package/src/components/chat/ThoughtCloud.tsx +0 -185
  52. package/src/components/chat/TypingIndicator.tsx +0 -25
  53. package/src/components/chat/tool/Subagent.tsx +0 -75
  54. package/src/components/chat/tool/frame.tsx +0 -69
  55. package/src/components/chat/tool/index.tsx +0 -65
  56. package/src/components/chat/tool/preview.ts +0 -57
  57. package/src/components/sidebar/ContextGauge.tsx +0 -102
  58. package/src/components/sidebar/Sidebar.tsx +0 -143
  59. package/src/components/tabs/TabBar.tsx +0 -50
  60. package/src/components/ui/FileLink.tsx +0 -52
  61. package/src/config/index.ts +0 -156
  62. package/src/config/lane.ts +0 -161
  63. package/src/config/models.ts +0 -95
  64. package/src/config/rules.ts +0 -80
  65. package/src/config/schema.ts +0 -308
  66. package/src/dialogs/alert.tsx +0 -52
  67. package/src/dialogs/chafa.tsx +0 -72
  68. package/src/dialogs/confirm.tsx +0 -58
  69. package/src/dialogs/curator.tsx +0 -153
  70. package/src/dialogs/eikon-picker.tsx +0 -95
  71. package/src/dialogs/help.tsx +0 -80
  72. package/src/dialogs/history.tsx +0 -92
  73. package/src/dialogs/info.tsx +0 -115
  74. package/src/dialogs/keys.tsx +0 -170
  75. package/src/dialogs/logs.tsx +0 -42
  76. package/src/dialogs/message.tsx +0 -38
  77. package/src/dialogs/model-picker.tsx +0 -123
  78. package/src/dialogs/new-profile.tsx +0 -69
  79. package/src/dialogs/new-task.tsx +0 -103
  80. package/src/dialogs/profile.tsx +0 -55
  81. package/src/dialogs/rollback.tsx +0 -190
  82. package/src/dialogs/spawn-history.tsx +0 -80
  83. package/src/dialogs/text-prompt.tsx +0 -68
  84. package/src/dialogs/theme-picker.tsx +0 -50
  85. package/src/home/index.ts +0 -23
  86. package/src/home/store.ts +0 -267
  87. package/src/index.tsx +0 -113
  88. package/src/keys/catalog.ts +0 -115
  89. package/src/keys/chord.ts +0 -125
  90. package/src/keys/conflicts.ts +0 -48
  91. package/src/keys/context.tsx +0 -112
  92. package/src/keys/index.ts +0 -5
  93. package/src/keys/list.ts +0 -94
  94. package/src/keys/oc-compat.ts +0 -87
  95. package/src/tabs/Agents.tsx +0 -607
  96. package/src/tabs/Analytics.tsx +0 -154
  97. package/src/tabs/Chat.tsx +0 -50
  98. package/src/tabs/Config.tsx +0 -605
  99. package/src/tabs/Context.tsx +0 -599
  100. package/src/tabs/Cron.tsx +0 -294
  101. package/src/tabs/Env.tsx +0 -227
  102. package/src/tabs/Kanban.tsx +0 -367
  103. package/src/tabs/Memory.tsx +0 -294
  104. package/src/tabs/Sessions.tsx +0 -786
  105. package/src/tabs/Skills.tsx +0 -507
  106. package/src/tabs/Toolsets.tsx +0 -266
  107. package/src/theme/builtin.ts +0 -78
  108. package/src/theme/context.tsx +0 -106
  109. package/src/theme/index.ts +0 -4
  110. package/src/theme/resolve.ts +0 -134
  111. package/src/theme/syntax.ts +0 -31
  112. package/src/theme/themes/aura.json +0 -69
  113. package/src/theme/themes/ayu.json +0 -80
  114. package/src/theme/themes/carbonfox.json +0 -248
  115. package/src/theme/themes/catppuccin-frappe.json +0 -233
  116. package/src/theme/themes/catppuccin-macchiato.json +0 -233
  117. package/src/theme/themes/catppuccin.json +0 -112
  118. package/src/theme/themes/cobalt2.json +0 -228
  119. package/src/theme/themes/cursor.json +0 -249
  120. package/src/theme/themes/dracula.json +0 -219
  121. package/src/theme/themes/everforest.json +0 -241
  122. package/src/theme/themes/flexoki.json +0 -237
  123. package/src/theme/themes/github.json +0 -233
  124. package/src/theme/themes/gruvbox.json +0 -242
  125. package/src/theme/themes/kanagawa.json +0 -77
  126. package/src/theme/themes/lucent-orng.json +0 -237
  127. package/src/theme/themes/material.json +0 -235
  128. package/src/theme/themes/matrix.json +0 -77
  129. package/src/theme/themes/mercury.json +0 -252
  130. package/src/theme/themes/monokai.json +0 -221
  131. package/src/theme/themes/nightowl.json +0 -221
  132. package/src/theme/themes/nord.json +0 -223
  133. package/src/theme/themes/one-dark.json +0 -84
  134. package/src/theme/themes/opencode.json +0 -245
  135. package/src/theme/themes/orng.json +0 -249
  136. package/src/theme/themes/osaka-jade.json +0 -93
  137. package/src/theme/themes/palenight.json +0 -222
  138. package/src/theme/themes/rosepine.json +0 -234
  139. package/src/theme/themes/solarized.json +0 -223
  140. package/src/theme/themes/synthwave84.json +0 -226
  141. package/src/theme/themes/tokyonight.json +0 -243
  142. package/src/theme/themes/vercel.json +0 -245
  143. package/src/theme/themes/vesper.json +0 -218
  144. package/src/theme/themes/zenburn.json +0 -223
  145. package/src/theme/types.ts +0 -119
  146. package/src/types/message.ts +0 -97
  147. package/src/ui/ChafaImage.tsx +0 -64
  148. package/src/ui/Splash.tsx +0 -118
  149. package/src/ui/borders.ts +0 -28
  150. package/src/ui/command.tsx +0 -104
  151. package/src/ui/dialog-select.tsx +0 -164
  152. package/src/ui/dialog.tsx +0 -102
  153. package/src/ui/fmt.ts +0 -82
  154. package/src/ui/kv.tsx +0 -28
  155. package/src/ui/shell.tsx +0 -45
  156. package/src/ui/spinner.tsx +0 -59
  157. package/src/ui/splash-art.ts +0 -123
  158. package/src/ui/table.tsx +0 -117
  159. package/src/ui/ticker.tsx +0 -90
  160. package/src/ui/toast.tsx +0 -130
  161. package/src/utils/categorical.ts +0 -77
  162. package/src/utils/chafa.ts +0 -173
  163. package/src/utils/clipboard.ts +0 -67
  164. package/src/utils/context-segments.ts +0 -317
  165. package/src/utils/control.ts +0 -495
  166. package/src/utils/drop.ts +0 -25
  167. package/src/utils/editor.ts +0 -33
  168. package/src/utils/fuzzy.ts +0 -45
  169. package/src/utils/gateway-client.ts +0 -253
  170. package/src/utils/gateway-types.ts +0 -282
  171. package/src/utils/git.ts +0 -57
  172. package/src/utils/hermes-analytics.ts +0 -134
  173. package/src/utils/hermes-home.ts +0 -821
  174. package/src/utils/hermes-kanban.ts +0 -154
  175. package/src/utils/hermes-profiles.ts +0 -217
  176. package/src/utils/interpolate.ts +0 -31
  177. package/src/utils/math-unicode.ts +0 -818
  178. package/src/utils/memory-activity.ts +0 -140
  179. package/src/utils/open-file.ts +0 -13
  180. package/src/utils/paths.ts +0 -52
  181. package/src/utils/perf.ts +0 -235
  182. package/src/utils/preferences.ts +0 -150
  183. package/src/utils/sessions-db.ts +0 -396
  184. package/src/utils/subagent-tree.ts +0 -146
  185. package/src/utils/terminal-reset.ts +0 -129
  186. package/src/utils/tips.ts +0 -67
  187. package/src/utils/tokens.ts +0 -87
@@ -1,185 +0,0 @@
1
- // Eikon thought cloud — shows the non-output parts of a turn
2
- // (reasoning, tool trail, status). Sits in flow above the chat scroll.
3
- // Auto-opens while the assistant is reasoning or running tools, closes
4
- // once text is streaming; pinning a past message holds it open. The
5
- // tail bubbles live on the Sidebar avatar.
6
-
7
- import { memo, useEffect, useRef, useState } from "react"
8
- import type { BorderCharacters, MouseEvent } from "@opentui/core"
9
- import type { Message, Part, ThinkingPart, ToolPart } from "../../types/message"
10
- import { Tool } from "./tool"
11
- import { usePref } from "../../utils/preferences"
12
- import { useTheme } from "../../theme"
13
-
14
- export const CLOUD_MIN = 12
15
- const CLOUD_MAX = 24
16
-
17
- // Heavy triple-dash — reads as thick + noncontinuous. Corners stay
18
- // heavy-solid so the box parses as a bubble, not a grid.
19
- const CLOUD: BorderCharacters = {
20
- topLeft: "┏", topRight: "┓", bottomLeft: "┗", bottomRight: "┛",
21
- horizontal: "┅", vertical: "┇",
22
- topT: "┅", bottomT: "┅", leftT: "┇", rightT: "┇", cross: "╋",
23
- }
24
-
25
- // Stepped bubbles bridging the cloud to the avatar's upper-left. Three
26
- // slots, big→small top→bottom. When animating, one slot is lit per
27
- // frame and travels bottom→top (away from the head, into the cloud);
28
- // the trailing empty frame reads as the bubble entering the cloud.
29
- const SLOTS = [
30
- ["┏┅┅┓ ", "┗┅┅┛ "],
31
- [" ┏┓ ", " ┗┛ "],
32
- [" ╸ ", " "],
33
- ]
34
- const BLANK = " "
35
- const ORDER = [2, 1, 0, -1]
36
-
37
- export const Tail = memo((props: { run: boolean }) => {
38
- const theme = useTheme().theme
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- const refs = useRef<any[]>([]) // TextNodeRenderable[6]
41
- // Paint a full frame (all slots when idle; one lit slot when running).
42
- // Mutates span .children directly — one requestRender() per touched
43
- // node, zero React reconciles per 160ms tick.
44
- const paint = (lit: number | null) => {
45
- SLOTS.forEach((slot, i) => slot.forEach((l, j) => {
46
- const node = refs.current[i * 2 + j]
47
- if (node) node.children = [lit === null || lit === i ? l : BLANK]
48
- }))
49
- }
50
- useEffect(() => {
51
- if (!props.run) { paint(null); return }
52
- let f = 0
53
- paint(ORDER[0])
54
- const t = setInterval(() => { f = (f + 1) % ORDER.length; paint(ORDER[f]) }, 160)
55
- return () => { clearInterval(t); paint(null) }
56
- }, [props.run])
57
- return (
58
- <box flexDirection="column">
59
- {SLOTS.flatMap((slot, i) =>
60
- slot.map((l, j) => (
61
- <text key={`${i}-${j}`} fg={theme.hermAvatar}>
62
- <span ref={el => { refs.current[i * 2 + j] = el }}>{l}</span>
63
- </text>
64
- )),
65
- )}
66
- </box>
67
- )
68
- })
69
-
70
- function parts(m: Message | undefined): Part[] {
71
- // ThoughtCloud shows the agent's process (reasoning + tool calls).
72
- // Prompts render inline in the transcript body, not here.
73
- return m?.parts.filter(p => p.type === "thinking" || p.type === "tool") ?? []
74
- }
75
-
76
- type Pane = "all" | "reasoning" | "tools"
77
-
78
- function latest(messages: Message[]): Message | undefined {
79
- for (let i = messages.length - 1; i >= 0; i--)
80
- if (messages[i].role === "assistant") return messages[i]
81
- return undefined
82
- }
83
-
84
- // Rough row cost — enough for auto-grow between MIN and MAX.
85
- function rows(list: Part[]): number {
86
- return list.reduce((n, p) =>
87
- n + (p.type === "thinking" ? Math.ceil(p.content.length / 80) || 1
88
- : p.type === "tool" && p.diff ? 6
89
- : 1), 0)
90
- }
91
-
92
- export const ThoughtCloud = memo((props: {
93
- height: number
94
- messages: Message[]
95
- pick?: Message
96
- onResize: (h: number) => void
97
- onClose?: () => void
98
- }) => {
99
- const theme = useTheme().theme
100
- const detail = usePref("toolDetails") ?? "expanded"
101
- const src = props.pick ?? latest(props.messages)
102
- const all = parts(src)
103
- const think = all.filter((p): p is ThinkingPart => p.type === "thinking")
104
- const tools = all.filter((p): p is ToolPart => p.type === "tool")
105
- const [pane, setPane] = useState<Pane>("all")
106
- const body = pane === "reasoning" ? think : pane === "tools" ? tools : all
107
-
108
- // Auto-grow: track content until the user drags; then their size
109
- // sticks. `want` is the dep so growth follows streamed thinking text,
110
- // not just part count.
111
- const manual = useRef(false)
112
- const want = Math.min(CLOUD_MAX, Math.max(CLOUD_MIN, rows(body) + 3))
113
- const resize = props.onResize
114
- useEffect(() => {
115
- if (!manual.current) resize(want)
116
- }, [want, resize])
117
-
118
- // Drag-resize via the bottom edge. MouseEvent.y is absolute terminal
119
- // row; delta from the drag origin maps 1:1 to height rows.
120
- const drag = useRef<{ y: number; h: number } | null>(null)
121
- const grab = (e: MouseEvent) => {
122
- drag.current = { y: e.y, h: props.height }
123
- manual.current = true
124
- e.stopPropagation()
125
- }
126
- const move = (e: MouseEvent) => {
127
- const d = drag.current
128
- if (!d) return
129
- resize(Math.min(CLOUD_MAX, Math.max(CLOUD_MIN, d.h + (e.y - d.y))))
130
- }
131
- const drop = () => { drag.current = null }
132
-
133
- const pill = (id: Pane, label: string, n: number) => {
134
- const on = pane === id
135
- return (
136
- <box height={1} marginRight={2}
137
- onMouseDown={(e: MouseEvent) => { e.stopPropagation(); setPane(id) }}>
138
- <text>
139
- <span fg={on ? theme.accent : theme.textMuted}>
140
- {on ? <strong>{label}</strong> : label}
141
- </span>
142
- {n > 0 ? <span fg={theme.textMuted}>{` ${n}`}</span> : null}
143
- </text>
144
- </box>
145
- )
146
- }
147
-
148
- return (
149
- <box
150
- height={props.height} flexDirection="column" position="relative"
151
- border borderColor={theme.hermAvatar} customBorderChars={CLOUD}
152
- backgroundColor={theme.backgroundPanel} paddingX={1}
153
- >
154
- <box height={1} flexShrink={0} flexDirection="row">
155
- {pill("all", "all", all.length)}
156
- {pill("reasoning", "reasoning", think.length)}
157
- {pill("tools", "tools", tools.length)}
158
- <box flexGrow={1} />
159
- {detail !== "expanded" ? (
160
- <box marginRight={1}><text fg={theme.textMuted}>⟨{detail}⟩</text></box>
161
- ) : null}
162
- {props.onClose ? (
163
- <box width={1} onMouseDown={props.onClose}>
164
- <text fg={theme.textMuted}>×</text>
165
- </box>
166
- ) : null}
167
- </box>
168
- <scrollbox scrollY stickyScroll stickyStart="bottom" flexGrow={1}>
169
- <box flexDirection="column" width="100%">
170
- {body.map((p, i) =>
171
- p.type === "thinking"
172
- ? <box key={(p as ThinkingPart).key ?? `th-${i}`} minHeight={1} width="100%" flexShrink={0}>
173
- <text fg={theme.textMuted} wrapMode="word">{(p as ThinkingPart).content}</text>
174
- </box>
175
- : <box key={(p as ToolPart).id || `t-${i}`} width="100%" flexShrink={0}>
176
- <Tool tool={p as ToolPart} detail={detail === "hidden" ? "hidden" : "collapsed"} />
177
- </box>,
178
- )}
179
- </box>
180
- </scrollbox>
181
- <box position="absolute" left={0} right={0} bottom={0} height={1}
182
- onMouseDown={grab} onMouseDrag={move} onMouseUp={drop} onMouseDragEnd={drop} />
183
- </box>
184
- )
185
- })
@@ -1,25 +0,0 @@
1
- import { memo, useState, useEffect } from "react"
2
- import { useTheme } from "../../theme"
3
- import { Spinner } from "../../ui/spinner"
4
-
5
- // Shown in the brief window between message.start and the first
6
- // assistant part. The gateway's thinking.delta verb text shows in
7
- // the Composer status bar; this is the in-transcript placeholder.
8
- // Rotates a small local verb list so it doesn't read as frozen.
9
-
10
- const VERBS = ["Thinking…", "Considering…", "Working…", "Pondering…"]
11
-
12
- export const TypingIndicator = memo((props: { label?: string }) => {
13
- const theme = useTheme().theme
14
- const [i, setI] = useState(0)
15
- useEffect(() => {
16
- if (props.label) return
17
- const id = setInterval(() => setI(n => (n + 1) % VERBS.length), 2200)
18
- return () => clearInterval(id)
19
- }, [props.label])
20
- return (
21
- <box height={1} paddingLeft={1}>
22
- <Spinner color={theme.info} label={props.label ?? VERBS[i]} />
23
- </box>
24
- )
25
- })
@@ -1,75 +0,0 @@
1
- // delegate_task / subagent renderer — oc's `Task` match.
2
- //
3
- // Collapsed: InlineTool row with goal + a sub-line:
4
- // running: ↳ {last tool} {preview} (or ↳ N toolcalls)
5
- // done: └ N toolcalls · duration
6
- // Click → expand to the full child trail, each as its own inline row
7
- // using the same spec() glyphs as top-level tools.
8
-
9
- import { memo, useState } from "react"
10
- import type { ToolPart as Part } from "../../../types/message"
11
- import { useTheme } from "../../../theme"
12
- import { useSpinnerGlyph } from "../../../ui/spinner"
13
- import { spec } from "./preview"
14
-
15
- function dur(d?: number): string {
16
- if (d == null) return ""
17
- const s = d / 1000
18
- return s < 60 ? `${s.toFixed(1)}s` : `${Math.floor(s / 60)}m${Math.round(s % 60)}s`
19
- }
20
-
21
- export const Subagent = memo(({ tool }: { tool: Part }) => {
22
- const theme = useTheme().theme
23
- const [open, setOpen] = useState(false)
24
- const running = tool.status === "running"
25
- const failed = tool.status === "error"
26
- const spin = useSpinnerGlyph(running)
27
- const trail = tool.trail ?? []
28
- const last = trail[trail.length - 1]
29
-
30
- const fg = failed ? theme.error : running ? theme.text : theme.textMuted
31
- const goal = (tool.goal ?? tool.preview ?? "").replace(/\s+/g, " ").trim()
32
-
33
- const sub = running
34
- ? last
35
- ? `↳ ${spec(last.name).verb || last.name} ${last.preview ?? ""}`
36
- : trail.length ? `↳ ${trail.length} toolcalls` : ""
37
- : `└ ${trail.length} toolcall${trail.length === 1 ? "" : "s"}${tool.duration ? ` · ${dur(tool.duration)}` : ""}`
38
-
39
- return (
40
- <box flexDirection="column" paddingLeft={3 + (tool.depth ?? 0) * 2}
41
- onMouseDown={trail.length ? () => setOpen(o => !o) : undefined}>
42
- <box height={1}>
43
- <text>
44
- <span fg={running ? theme.warning : fg}>{running ? spin : "⊙"} </span>
45
- <span fg={fg}>Task — {goal || "delegating…"}</span>
46
- </text>
47
- </box>
48
- {open ? (
49
- <box flexDirection="column">
50
- {trail.map((c, i) => {
51
- const s = spec(c.name)
52
- const lbl = s.verb ? `${s.verb} ${c.preview ?? ""}` : c.preview ?? c.name
53
- return (
54
- <box key={i} height={1}>
55
- <text>
56
- <span fg={theme.textMuted}>{i < trail.length - 1 ? "├─ " : "└─ "}</span>
57
- <span fg={theme.textMuted}>{s.icon} {lbl}</span>
58
- </text>
59
- </box>
60
- )
61
- })}
62
- {tool.result ? (
63
- <box minHeight={1} marginTop={1}>
64
- <text fg={theme.textMuted} wrapMode="word">{tool.result}</text>
65
- </box>
66
- ) : null}
67
- </box>
68
- ) : sub ? (
69
- <box height={1}>
70
- <text fg={theme.textMuted}>{sub}</text>
71
- </box>
72
- ) : null}
73
- </box>
74
- )
75
- })
@@ -1,69 +0,0 @@
1
- // InlineTool — the single shape every tool renders into in the
2
- // ThoughtCloud. Diffs that warrant a body render as InlineDiff chips
3
- // in the assistant message body (MessageItem), not here.
4
-
5
- import { memo, useState, type ReactNode } from "react"
6
- import type { RGBA } from "@opentui/core"
7
- import type { ToolPart } from "../../../types/message"
8
- import { useTheme } from "../../../theme"
9
- import { useSpinnerGlyph } from "../../../ui/spinner"
10
- import { spec } from "./preview"
11
-
12
- function ms(d?: number): string {
13
- if (d == null) return ""
14
- if (d < 1000) return `${Math.round(d)}ms`
15
- if (d < 60000) return `${(d / 1000).toFixed(1)}s`
16
- return `${Math.floor(d / 60000)}m${Math.round((d % 60000) / 1000)}s`
17
- }
18
-
19
- type InlineProps = {
20
- part: ToolPart
21
- /** Content for the collapsed row; usually preview text. */
22
- children: ReactNode
23
- /** True once enough input exists to show `children` instead of pending. */
24
- complete?: boolean
25
- iconColor?: RGBA
26
- onClick?: () => void
27
- }
28
-
29
- export const InlineTool = memo((p: InlineProps) => {
30
- const theme = useTheme().theme
31
- const [hover, setHover] = useState(false)
32
- const s = spec(p.part.name)
33
- const running = p.part.status === "running"
34
- const failed = p.part.status === "error"
35
- const spin = useSpinnerGlyph(running)
36
-
37
- const fg = failed ? theme.error
38
- : hover && p.onClick ? theme.text
39
- : running ? theme.text
40
- : theme.textMuted
41
-
42
- return (
43
- <box
44
- flexDirection="column"
45
- paddingLeft={3}
46
- onMouseOver={p.onClick ? () => setHover(true) : undefined}
47
- onMouseOut={p.onClick ? () => setHover(false) : undefined}
48
- onMouseDown={p.onClick}
49
- >
50
- <box height={1}>
51
- <text>
52
- <span fg={running ? theme.warning : p.iconColor ?? fg}>{running ? spin : s.icon} </span>
53
- {p.complete ?? true
54
- ? <span fg={fg}>{p.children}</span>
55
- : <span fg={fg}>~ {s.pending}</span>}
56
- {p.part.duration != null
57
- ? <span fg={theme.textMuted}> {ms(p.part.duration)}</span>
58
- : null}
59
- </text>
60
- </box>
61
- {failed && p.part.result ? (
62
- <box minHeight={1} paddingLeft={2}>
63
- <text fg={theme.error} wrapMode="word">{p.part.result}</text>
64
- </box>
65
- ) : null}
66
- </box>
67
- )
68
- })
69
-
@@ -1,65 +0,0 @@
1
- // Per-tool dispatch — oc's `<Switch>` over part.tool. Each hermes
2
- // tool name maps to either an InlineTool row or a BlockTool card.
3
- //
4
- // Data constraint: the stock tui_gateway emits only
5
- // tool.start {name, context: build_tool_preview() string ≤80ch}
6
- // tool.complete {summary, inline_diff?, error?, duration_s}
7
- // — NOT the raw args JSON or the tool result body. So per-tool
8
- // *bodies* (bash stdout, todo checklist, grep matches) are blocked
9
- // on the wire carrying more (→ docs/UPSTREAM.md). The dispatch and
10
- // frame grammar here are ready for them.
11
-
12
- import { memo } from "react"
13
- import type { ToolPart as Part } from "../../../types/message"
14
- import type { DetailMode } from "../../../utils/preferences"
15
- import { InlineTool } from "./frame"
16
- import { isDiff } from "../DiffBlock"
17
- import { Subagent } from "./Subagent"
18
- import { spec } from "./preview"
19
- import { useTheme } from "../../../theme"
20
-
21
- const FILE = new Set(["write_file", "patch"])
22
-
23
- function short(s: string | undefined, n = 120): string {
24
- if (!s) return ""
25
- const one = s.replace(/\s+/g, " ").trim()
26
- return one.length > n ? one.slice(0, n - 1) + "…" : one
27
- }
28
-
29
- function base(path: string): string {
30
- const clean = path.replace(/\/+$/, "")
31
- const slash = clean.lastIndexOf("/")
32
- return slash >= 0 ? clean.slice(slash + 1) : clean
33
- }
34
-
35
- const Inline = memo(({ tool }: { tool: Part }) => {
36
- const s = spec(tool.name)
37
- const body = tool.preview ? short(tool.preview) : ""
38
- return (
39
- <InlineTool part={tool} complete={!!body || tool.status !== "running"}>
40
- {s.verb ? `${s.verb} ${body}` : body || tool.name}
41
- </InlineTool>
42
- )
43
- })
44
-
45
- /** Accent-filled pill: `changed <basename>`. The actual diff renders
46
- * as an InlineDiff chip in the assistant message body (d39945f), so
47
- * the ThoughtCloud row only needs to say *that* a file changed. */
48
- const FileEdit = memo(({ tool }: { tool: Part }) => {
49
- const theme = useTheme().theme
50
- // While running (no result yet) or when preview is absent (some
51
- // providers omit the path), fall through to the generic inline row.
52
- if (tool.status === "running" || !tool.preview) return <Inline tool={tool} />
53
- return (
54
- <InlineTool part={tool}>
55
- <span bg={theme.accent} fg={theme.background}> changed {short(base(tool.preview), 48)} </span>
56
- </InlineTool>
57
- )
58
- })
59
-
60
- export const Tool = memo(({ tool, detail = "expanded" }: { tool: Part; detail?: DetailMode }) => {
61
- if (detail === "hidden" && tool.status !== "running") return null
62
- if (tool.trail || tool.name === "delegate_task") return <Subagent tool={tool} />
63
- if (FILE.has(tool.name) || tool.diff || isDiff(tool.result)) return <FileEdit tool={tool} />
64
- return <Inline tool={tool} />
65
- })
@@ -1,57 +0,0 @@
1
- // Hermes tool name → one-line presentation. Data only — rendering
2
- // lives in the dispatch switch. Covers the tool vocabulary the
3
- // gateway emits (see hermes-agent model_tools + agent/display.py
4
- // primary_args for the WHAT); icon glyphs follow oc's single-char
5
- // convention (no emoji).
6
-
7
- export type Spec = {
8
- icon: string
9
- /** Verb shown before the preview string on the collapsed row. */
10
- verb: string
11
- /** Gerund shown while status == running and no preview yet. */
12
- pending: string
13
- }
14
-
15
- const SPEC: Record<string, Spec> = {
16
- terminal: { icon: "$", verb: "", pending: "Writing command…" },
17
- process: { icon: "⊚", verb: "Process", pending: "Managing process…" },
18
- execute_code: { icon: "»", verb: "Exec", pending: "Writing script…" },
19
-
20
- read_file: { icon: "→", verb: "Read", pending: "Reading file…" },
21
- write_file: { icon: "←", verb: "Write", pending: "Preparing write…" },
22
- patch: { icon: "←", verb: "Edit", pending: "Preparing edit…" },
23
-
24
- search_files: { icon: "✱", verb: "Search", pending: "Searching…" },
25
- web_search: { icon: "◈", verb: "Web", pending: "Searching web…" },
26
- web_extract: { icon: "%", verb: "Fetch", pending: "Fetching page…" },
27
- session_search: { icon: "↺", verb: "Recall", pending: "Searching memory…" },
28
-
29
- browser_navigate: { icon: "%", verb: "Navigate", pending: "Navigating…" },
30
- browser_click: { icon: "·", verb: "Click", pending: "Clicking…" },
31
- browser_type: { icon: "⌨", verb: "Type", pending: "Typing…" },
32
- browser_snapshot: { icon: "⎙", verb: "Snapshot", pending: "Capturing…" },
33
- browser_vision: { icon: "◉", verb: "Vision", pending: "Looking…" },
34
- vision_analyze: { icon: "◉", verb: "Vision", pending: "Analyzing image…" },
35
-
36
- todo: { icon: "☰", verb: "Todo", pending: "Updating todos…" },
37
- memory: { icon: "⚑", verb: "Memory", pending: "Updating memory…" },
38
- clarify: { icon: "?", verb: "Ask", pending: "Asking…" },
39
-
40
- skill_view: { icon: "◆", verb: "Skill", pending: "Loading skill…" },
41
- skills_list: { icon: "◆", verb: "Skills", pending: "Listing skills…" },
42
- skill_manage: { icon: "◆", verb: "Skill", pending: "Managing skill…" },
43
-
44
- delegate_task: { icon: "⊙", verb: "Delegate", pending: "Spawning agent…" },
45
- cronjob: { icon: "◷", verb: "Cron", pending: "Managing cron…" },
46
- text_to_speech: { icon: "♪", verb: "TTS", pending: "Synthesizing…" },
47
- image_generate: { icon: "✦", verb: "Image", pending: "Generating image…" },
48
- }
49
-
50
- const GENERIC: Spec = { icon: "⚙", verb: "", pending: "Running…" }
51
-
52
- export function spec(name: string): Spec {
53
- if (name.startsWith("subagent")) return { icon: "⊙", verb: "Subagent", pending: "Running…" }
54
- if (name.startsWith("mcp__") || name.startsWith("mcp:")) return { icon: "◇", verb: "MCP", pending: "Calling…" }
55
- return SPEC[name] ?? GENERIC
56
- }
57
-
@@ -1,102 +0,0 @@
1
- import { memo } from "react"
2
- import { useTheme } from "../../theme"
3
- import type { SessionInfo } from "../../utils/gateway-types"
4
- import type { Usage } from "../../types/message"
5
- import { formatTokens } from "../../utils/tokens"
6
-
7
- // Context-compaction gauge for the sidebar. Three-line block:
8
- // 258K / 1M (used / limit, centered)
9
- // [████████████░░░░░░░░░░░░░░░░░░░] (bar spans ~full width minus [])
10
- // 26% (percent, centered)
11
- //
12
- // Color ramps with ratio:
13
- // <0.50 → textMuted (plenty of room)
14
- // <0.75 → primary (normal working range)
15
- // <0.90 → warning (approaching compression)
16
- // ≥0.90 → error (hot)
17
- //
18
- // Hidden entirely when live usage is unavailable — never renders a
19
- // stale or fabricated value.
20
-
21
- const FILL = "█"
22
- const EMPTY = "░"
23
-
24
- type Ramp = "muted" | "primary" | "warning" | "error"
25
-
26
- const ramp = (ratio: number): Ramp => {
27
- if (ratio >= 0.90) return "error"
28
- if (ratio >= 0.75) return "warning"
29
- if (ratio >= 0.50) return "primary"
30
- return "muted"
31
- }
32
-
33
- const centered = (s: string, width: number): string => {
34
- const pad = Math.max(0, width - s.length)
35
- // Bias the extra space to the right when pad is odd. Terminal glyphs
36
- // are visually slightly left-weighted, so ceil-left / floor-right
37
- // reads as more optically centered than the naive floor/ceil split.
38
- const left = Math.ceil(pad / 2)
39
- const right = pad - left
40
- return " ".repeat(left) + s + " ".repeat(right)
41
- }
42
-
43
- const formatPct = (ratio: number): string => {
44
- const pct = ratio * 100
45
- if (pct < 10) return `${pct.toFixed(1)}%`
46
- return `${Math.round(pct)}%`
47
- }
48
-
49
- export const ContextGauge = memo((props: {
50
- info?: SessionInfo | null
51
- usage?: Usage
52
- width: number
53
- }) => {
54
- const theme = useTheme().theme
55
- const info = props.info
56
-
57
- // Live usage from message.complete events takes priority over the
58
- // session.info snapshot (which is captured at session create and
59
- // stale after any turn). Fall back to info.usage for the first
60
- // render after resume, before any new wire event has arrived.
61
- const used = props.usage?.context_used ?? info?.usage?.context_used ?? info?.context_used
62
- const max = props.usage?.context_max ?? info?.usage?.context_max ?? info?.context_max
63
-
64
- // No live data → hide. Stale gauges are worse than no gauge.
65
- // Note: used=0 is valid (fresh session, no turn yet). Guard on the
66
- // max (non-positive → no compression wired up → hide).
67
- if (typeof max !== "number" || max <= 0) return null
68
- if (typeof used !== "number") return null
69
-
70
- const ratio = Math.max(0, Math.min(1, used / max))
71
- // Bar fills the row minus the two bracket chars; min 8 cells for
72
- // safety at very narrow widths.
73
- const cells = Math.max(8, props.width - 2)
74
- const filled = Math.round(ratio * cells)
75
- const bar = FILL.repeat(filled) + EMPTY.repeat(cells - filled)
76
-
77
- const color = (() => {
78
- switch (ramp(ratio)) {
79
- case "error": return theme.error
80
- case "warning": return theme.warning
81
- case "primary": return theme.primary
82
- default: return theme.hermBodyTextMuted
83
- }
84
- })()
85
-
86
- const top = `${formatTokens(used)} / ${formatTokens(max)}`
87
- const pct = formatPct(ratio)
88
-
89
- return (
90
- <box flexDirection="column" marginTop={1}>
91
- <box height={1}>
92
- <text><span fg={theme.hermBodyTextMuted}>{centered(top, props.width)}</span></text>
93
- </box>
94
- <box height={1}>
95
- <text><span fg={color}>{centered(`[${bar}]`, props.width)}</span></text>
96
- </box>
97
- <box height={1}>
98
- <text><span fg={theme.hermBodyTextMuted}>{centered(pct, props.width)}</span></text>
99
- </box>
100
- </box>
101
- )
102
- })