@phren/agent 0.1.15 → 0.3.5

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 (110) hide show
  1. package/README.md +86 -0
  2. package/dist/agent-loop/index.js +239 -65
  3. package/dist/agent-loop/stream.js +212 -29
  4. package/dist/agent-loop/types.js +15 -2
  5. package/dist/checkpoint.js +103 -22
  6. package/dist/commands/info.js +30 -15
  7. package/dist/commands/model.js +6 -2
  8. package/dist/commands/review.js +183 -0
  9. package/dist/commands/session.js +70 -7
  10. package/dist/commands.js +168 -12
  11. package/dist/config.js +87 -10
  12. package/dist/context/compactor.js +239 -0
  13. package/dist/context/pruner.js +39 -13
  14. package/dist/context/token-counter.js +33 -1
  15. package/dist/custom-commands.js +69 -0
  16. package/dist/guards/repeat-tool-reminder.js +75 -0
  17. package/dist/headless.js +115 -0
  18. package/dist/herdr-hooks.js +71 -0
  19. package/dist/index.js +351 -48
  20. package/dist/mcp-client.js +434 -73
  21. package/dist/mcp-oauth.js +121 -0
  22. package/dist/memory/anti-patterns.js +7 -3
  23. package/dist/memory/auto-capture.js +7 -3
  24. package/dist/memory/context.js +92 -73
  25. package/dist/memory/project-context.js +24 -5
  26. package/dist/memory/provenance.js +15 -0
  27. package/dist/memory/review-triage.js +166 -0
  28. package/dist/memory/session.js +36 -1
  29. package/dist/models.js +152 -19
  30. package/dist/multi/child-entry.js +65 -10
  31. package/dist/multi/diff-renderer.js +3 -3
  32. package/dist/multi/markdown.js +125 -27
  33. package/dist/multi/provider-manager.js +8 -0
  34. package/dist/multi/publish.js +72 -0
  35. package/dist/multi/spawner.js +45 -4
  36. package/dist/multi/syntax-highlight.js +25 -4
  37. package/dist/multi/types.js +1 -1
  38. package/dist/permissions/allowlist.js +86 -13
  39. package/dist/permissions/checker.js +42 -7
  40. package/dist/permissions/kernel-sandbox.js +197 -0
  41. package/dist/permissions/prompt.js +10 -1
  42. package/dist/permissions/sandbox.js +40 -17
  43. package/dist/providers/anthropic.js +154 -7
  44. package/dist/providers/codex-auth.js +28 -0
  45. package/dist/providers/codex.js +134 -23
  46. package/dist/providers/history.js +35 -0
  47. package/dist/providers/ollama.js +37 -6
  48. package/dist/providers/openai-compat.js +171 -74
  49. package/dist/providers/openrouter.js +47 -17
  50. package/dist/providers/replay.js +62 -0
  51. package/dist/providers/resolve.js +41 -7
  52. package/dist/providers/retry.js +38 -5
  53. package/dist/providers/types.js +9 -1
  54. package/dist/repl.js +47 -5
  55. package/dist/session/log.js +217 -0
  56. package/dist/session/persist.js +190 -0
  57. package/dist/settings.js +42 -26
  58. package/dist/system-prompt.js +18 -2
  59. package/dist/tools/apply-patch.js +355 -0
  60. package/dist/tools/edit-engine.js +287 -0
  61. package/dist/tools/edit-file.js +86 -27
  62. package/dist/tools/grep.js +25 -10
  63. package/dist/tools/lint-test.js +0 -22
  64. package/dist/tools/mcp-resources.js +51 -6
  65. package/dist/tools/phren-finding.js +12 -4
  66. package/dist/tools/phren-search.js +7 -2
  67. package/dist/tools/read-file.js +37 -9
  68. package/dist/tools/read-image.js +76 -0
  69. package/dist/tools/registry.js +27 -5
  70. package/dist/tools/shell.js +134 -71
  71. package/dist/tools/skill.js +20 -20
  72. package/dist/tools/spawn-agent.js +77 -13
  73. package/dist/tools/update-plan.js +48 -0
  74. package/dist/tools/web-fetch.js +110 -12
  75. package/dist/tools/web-search.js +4 -4
  76. package/dist/tui/components/App.js +98 -26
  77. package/dist/tui/components/ApprovalPanel.js +8 -0
  78. package/dist/tui/components/InputArea.js +5 -5
  79. package/dist/tui/components/ModelPicker.js +43 -0
  80. package/dist/tui/components/PhrenInput.js +10 -5
  81. package/dist/tui/components/PlanReview.js +7 -0
  82. package/dist/tui/components/ShortcutHelp.js +5 -0
  83. package/dist/tui/components/StatusBar.js +46 -20
  84. package/dist/tui/components/SteerQueue.js +1 -1
  85. package/dist/tui/components/ThinkingIndicator.js +6 -4
  86. package/dist/tui/components/ToolCall.js +10 -4
  87. package/dist/tui/components/ToolDetail.js +21 -0
  88. package/dist/tui/help.js +6 -0
  89. package/dist/tui/hooks/useKeyboardShortcuts.js +15 -1
  90. package/dist/tui/index.js +0 -1
  91. package/dist/tui/ink-entry.js +317 -33
  92. package/dist/tui/tool-render.js +1 -1
  93. package/dist/user-hooks.js +171 -0
  94. package/package.json +14 -8
  95. package/dist/multi/multi-commands.js +0 -170
  96. package/dist/multi/multi-events.js +0 -98
  97. package/dist/multi/multi-render.js +0 -147
  98. package/dist/multi/pane.js +0 -28
  99. package/dist/multi/tui-multi.js +0 -200
  100. package/dist/permissions/privacy.js +0 -248
  101. package/dist/tui/components/AgentMessage.js +0 -5
  102. package/dist/tui/components/ChatMessage.js +0 -23
  103. package/dist/tui/components/CodeBlock.js +0 -8
  104. package/dist/tui/components/Separator.js +0 -7
  105. package/dist/tui/components/StreamingText.js +0 -5
  106. package/dist/tui/components/UserMessage.js +0 -5
  107. package/dist/tui/menu-mode.js +0 -86
  108. package/dist/tui/mouse.js +0 -71
  109. package/dist/tui/terminal-control.js +0 -62
  110. package/dist/tui.js +0 -781
@@ -1,17 +1,28 @@
1
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState, useCallback, useEffect } from "react";
3
- import { Static, Box, Text, useApp, useInput } from "ink";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as fs from "node:fs";
3
+ import { Box, Static, Text, useApp, useInput, useStdin } from "ink";
4
+ import { useCallback, useEffect, useState } from "react";
5
+ import { COMMAND_NAMES } from "../../commands.js";
6
+ import { renderMarkdown } from "../../multi/markdown.js";
7
+ import { getPlan } from "../../tools/update-plan.js";
8
+ import { isHelpKey } from "../help.js";
9
+ import { useKeyboardShortcuts } from "../hooks/useKeyboardShortcuts.js";
10
+ import { highlightMatches, useSearch } from "../hooks/useSearch.js";
11
+ import { ApprovalPanel } from "./ApprovalPanel.js";
4
12
  import { Banner } from "./Banner.js";
13
+ import { InputArea, PermissionsLine } from "./InputArea.js";
14
+ import { ModelPicker } from "./ModelPicker.js";
15
+ import { PlanReview } from "./PlanReview.js";
16
+ import { ShortcutHelp } from "./ShortcutHelp.js";
17
+ import { StatusBar } from "./StatusBar.js";
18
+ import { SteerQueue } from "./SteerQueue.js";
19
+ import { ThinkingIndicator } from "./ThinkingIndicator.js";
5
20
  import { ToolCall } from "./ToolCall.js";
21
+ import { ToolDetail } from "./ToolDetail.js";
6
22
  import { ToolSpinner } from "./ToolSpinner.js";
7
- import { ThinkingIndicator } from "./ThinkingIndicator.js";
8
- import { SteerQueue } from "./SteerQueue.js";
9
- import { InputArea, PermissionsLine } from "./InputArea.js";
10
- import { useKeyboardShortcuts } from "../hooks/useKeyboardShortcuts.js";
11
- import { renderMarkdown } from "../../multi/markdown.js";
12
- import { useSearch, highlightMatches } from "../hooks/useSearch.js";
13
- export function App({ state, completedMessages, streamingText, completedToolCalls, activeTool, thinking, thinkStartTime, thinkElapsed, steerQueue, running, showBanner, inputHistory, verbose, theme, onSubmit, onPermissionCycle, onCancelTurn, onExit, onExpandTool, agents, selectedAgentId, onSelectAgent, onCancelAgent, }) {
23
+ export function App({ state, completedMessages, streamingText, reasoningText, completedToolCalls, activeTool, thinking, thinkStartTime, thinkElapsed, steerQueue, running, showBanner, inputHistory, verbose, theme, onSubmit, onPermissionCycle, onCancelTurn, onExit, onExpandTool, agents, selectedAgentId, onSelectAgent, onCancelAgent, approval, modelPicker, onModelPickerMove, onModelPickerReasoning, onModelPickerSelect, onModelPickerCancel, onInspectTool, toolDetail, onToolDetailMove, onToolDetailClose, planReview, }) {
14
24
  const { exit } = useApp();
25
+ const { stdin } = useStdin();
15
26
  const [inputValue, setInputValue] = useState("");
16
27
  const [bashMode, setBashMode] = useState(false);
17
28
  const [historyIndex, setHistoryIndex] = useState(-1);
@@ -24,8 +35,31 @@ export function App({ state, completedMessages, streamingText, completedToolCall
24
35
  const [historySearchQuery, setHistorySearchQuery] = useState("");
25
36
  const [historySearchIndex, setHistorySearchIndex] = useState(0);
26
37
  const [expandedTools, setExpandedTools] = useState(new Set());
38
+ const [completionIndex, setCompletionIndex] = useState(0);
39
+ const [showHelp, setShowHelp] = useState(false);
27
40
  // ── Ctrl+F content search ────────────────────────────────────────────────
28
41
  const search = useSearch();
42
+ // Slash-command and @file completion candidates for the current input.
43
+ const completions = (() => {
44
+ if (inputValue.startsWith("/") && !/\s/.test(inputValue)) {
45
+ return COMMAND_NAMES.filter((name) => name.startsWith(inputValue) && name !== inputValue).slice(0, 8);
46
+ }
47
+ const match = inputValue.match(/(?:^|\s)@([^\s@]*)$/);
48
+ if (!match)
49
+ return [];
50
+ const partial = match[1];
51
+ const tokenStart = inputValue.length - partial.length - 1;
52
+ try {
53
+ return fs.readdirSync(process.cwd())
54
+ .filter((entry) => entry.startsWith(partial))
55
+ .slice(0, 8)
56
+ .map((entry) => `${inputValue.slice(0, tokenStart)}@${entry}`);
57
+ }
58
+ catch {
59
+ return [];
60
+ }
61
+ })();
62
+ useEffect(() => { setCompletionIndex(0); }, [inputValue]);
29
63
  // When the query changes, recompute total match count across all completed messages
30
64
  useEffect(() => {
31
65
  if (!search.state.active || !search.state.query) {
@@ -142,6 +176,27 @@ export function App({ state, completedMessages, streamingText, completedToolCall
142
176
  setBashMode(false);
143
177
  }, [bashMode, onSubmit]);
144
178
  const isAnyModeActive = search.state.active || historySearchMode;
179
+ const helpEnabled = !isAnyModeActive && !modelPicker && !toolDetail && !approval;
180
+ useEffect(() => {
181
+ if (!helpEnabled)
182
+ return;
183
+ const onData = (data) => {
184
+ const input = data.toString();
185
+ if (input !== "?" && isHelpKey(input, inputValue))
186
+ setShowHelp(value => !value);
187
+ };
188
+ stdin.on("data", onData);
189
+ return () => { stdin.off("data", onData); };
190
+ }, [stdin, helpEnabled, inputValue]);
191
+ useInput((input, key) => {
192
+ if (showHelp) {
193
+ if (key.escape || input === "?" || isHelpKey(input, inputValue))
194
+ setShowHelp(false);
195
+ }
196
+ else if (isHelpKey(input, inputValue)) {
197
+ setShowHelp(true);
198
+ }
199
+ }, { isActive: helpEnabled });
145
200
  useKeyboardShortcuts({
146
201
  isRunning: running,
147
202
  inputValue,
@@ -166,20 +221,22 @@ export function App({ state, completedMessages, streamingText, completedToolCall
166
221
  search.activate();
167
222
  },
168
223
  onExpandTool: () => {
169
- const lastIndex = completedToolCalls.length - 1;
170
- if (lastIndex < 0)
224
+ if (completedToolCalls.length > 0) {
225
+ const lastIndex = completedToolCalls.length - 1;
226
+ setExpandedTools((prev) => {
227
+ const next = new Set(prev);
228
+ if (next.has(lastIndex)) {
229
+ next.delete(lastIndex);
230
+ }
231
+ else {
232
+ next.add(lastIndex);
233
+ }
234
+ return next;
235
+ });
236
+ onExpandTool?.();
171
237
  return;
172
- setExpandedTools((prev) => {
173
- const next = new Set(prev);
174
- if (next.has(lastIndex)) {
175
- next.delete(lastIndex);
176
- }
177
- else {
178
- next.add(lastIndex);
179
- }
180
- return next;
181
- });
182
- onExpandTool?.();
238
+ }
239
+ onInspectTool?.();
183
240
  },
184
241
  onOpenEditor: () => {
185
242
  // Write input to temp file, open $EDITOR, read back
@@ -217,6 +274,16 @@ export function App({ state, completedMessages, streamingText, completedToolCall
217
274
  onSelectAgent?.(nextId === "__main__" ? null : nextId);
218
275
  } : undefined,
219
276
  onToggleTaskList: () => setShowTaskList(v => !v),
277
+ enabled: !isAnyModeActive && !showHelp && !modelPicker && !toolDetail,
278
+ completionOpen: completions.length > 0,
279
+ completionCount: completions.length,
280
+ onCompletionMove: (delta) => setCompletionIndex((i) => (i + delta + completions.length) % completions.length),
281
+ onCompletionAccept: () => {
282
+ if (completions.length === 0)
283
+ return;
284
+ setInputValue(completions[completionIndex % completions.length]);
285
+ setCompletionIndex(0);
286
+ },
220
287
  });
221
288
  // Helper: apply search highlighting to a text string (ANSI only works in
222
289
  // non-Ink raw text mode). Since Ink's <Text> will escape ANSI we pass raw
@@ -235,13 +302,18 @@ export function App({ state, completedMessages, streamingText, completedToolCall
235
302
  const renderedText = aMsg.text
236
303
  ? applySearch(renderMarkdown(aMsg.text, theme.markdown))
237
304
  : "";
238
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [aMsg.toolCalls?.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme }, i))), renderedText ? (_jsxs(Box, { children: [_jsxs(Text, { color: theme.agent.color, wrap: "truncate", children: [theme.agent.label, " "] }), _jsx(Text, { wrap: "wrap", children: renderedText })] })) : null] }, item.id));
305
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [aMsg.toolCalls?.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme }, i))), renderedText ? (_jsxs(Box, { children: [_jsx(Box, { flexShrink: 0, children: _jsxs(Text, { color: theme.agent.color, children: [theme.agent.label, " "] }) }), _jsx(Box, { flexGrow: 1, flexShrink: 1, minWidth: 0, children: _jsx(Text, { wrap: "wrap", children: renderedText }) })] })) : null] }, item.id));
239
306
  }
240
307
  if (item.kind === "status") {
241
308
  return _jsx(Text, { color: theme.system.color, dimColor: true, children: applySearch(item.text) }, item.id);
242
309
  }
243
310
  return null;
244
- } }), _jsxs(Box, { flexDirection: "column", children: [showBanner && completedMessages.length === 0 && _jsx(Banner, { state: state, theme: theme }), completedToolCalls.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme, expanded: expandedTools.has(i) }, `tc-${i}`))), activeTool && (_jsxs(Box, { paddingLeft: 2, children: [_jsx(ToolSpinner, { theme: theme }), _jsx(Text, { bold: true, color: theme.tool.name, children: activeTool.name }), activeTool.preview ? _jsxs(Text, { color: theme.tool.preview ?? theme.separator, children: [" ", activeTool.preview] }) : null] })), streamingText !== "" && (_jsxs(Box, { marginTop: 1, children: [_jsxs(Text, { color: theme.agent.color, wrap: "truncate", children: [theme.agent.label, " "] }), _jsx(Text, { wrap: "wrap", children: renderMarkdown(streamingText, theme.markdown) })] })), thinking && _jsx(Box, { marginTop: 1, children: _jsx(ThinkingIndicator, { startTime: thinkStartTime, theme: theme }) }), thinkElapsed !== null && (_jsxs(Text, { color: theme.dim, dimColor: true, children: [" ", "\u25c8", " ", thinkElapsed] })), ctrlCCount > 0 && !running && (_jsxs(Text, { dimColor: true, children: [" ", "Press Ctrl+C again to exit."] })), _jsx(SteerQueue, { items: steerQueue, theme: theme }), showTaskList && (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { dimColor: true, children: [" ", "Tasks: (ctrl+t to hide)"] }), _jsxs(Text, { dimColor: true, children: [" ", "No shared task list in this session."] })] })), search.state.active && (_jsxs(Box, { children: [_jsxs(Text, { color: theme.search?.prompt ?? "cyan", children: [" ", "find: ", search.state.query, _jsx(Text, { inverse: true, children: " " })] }), search.state.matchCount > 0
311
+ } }), _jsxs(Box, { flexDirection: "column", children: [showBanner && completedMessages.length === 0 && _jsx(Banner, { state: state, theme: theme }), completedToolCalls.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme, expanded: expandedTools.has(i) }, `tc-${i}`))), activeTool && (_jsxs(Box, { paddingLeft: 2, children: [_jsx(ToolSpinner, { theme: theme }), _jsx(Text, { bold: true, color: theme.tool.name, children: activeTool.name }), activeTool.preview ? _jsxs(Text, { color: theme.tool.preview ?? theme.separator, children: [" ", activeTool.preview] }) : null] })), reasoningText ? (_jsx(Box, { marginTop: 1, paddingLeft: 2, children: _jsxs(Text, { dimColor: true, italic: true, wrap: "wrap", children: ["✴ ", reasoningText.length > 400 ? `…${reasoningText.slice(-400)}` : reasoningText] }) })) : null, streamingText !== "" && (_jsxs(Box, { marginTop: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsxs(Text, { color: theme.agent.color, children: [theme.agent.label, " "] }) }), _jsx(Box, { flexGrow: 1, flexShrink: 1, minWidth: 0, children: _jsx(Text, { wrap: "wrap", children: renderMarkdown(streamingText, theme.markdown) }) })] })), thinking && _jsx(Box, { marginTop: 1, children: _jsx(ThinkingIndicator, { startTime: thinkStartTime, theme: theme }) }), thinkElapsed !== null && (_jsxs(Text, { color: theme.dim, dimColor: true, children: [" ", "\u25c8", " ", thinkElapsed] })), ctrlCCount > 0 && !running && (_jsxs(Text, { dimColor: true, children: [" ", "Press Ctrl+C again to exit."] })), _jsx(SteerQueue, { items: steerQueue, theme: theme }), showTaskList && (() => {
312
+ const plan = getPlan();
313
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { dimColor: true, children: [" ", "Plan (ctrl+t to hide)"] }), plan.length === 0
314
+ ? _jsxs(Text, { dimColor: true, children: [" ", "No plan yet."] })
315
+ : plan.map((item, i) => (_jsxs(Text, { color: item.status === "completed" ? "green" : item.status === "in_progress" ? "yellow" : undefined, dimColor: item.status === "completed", children: [" ", item.status === "completed" ? "\u2713" : item.status === "in_progress" ? "\u25cf" : "\u25cb", " ", item.content] }, i)))] }));
316
+ })(), search.state.active && (_jsxs(Box, { children: [_jsxs(Text, { color: theme.search?.prompt ?? "cyan", children: [" ", "find: ", search.state.query, _jsx(Text, { inverse: true, children: " " })] }), search.state.matchCount > 0
245
317
  ? _jsxs(Text, { dimColor: true, color: theme.search?.match ?? undefined, children: [" (", search.state.currentMatch + 1, " of ", search.state.matchCount, ")"] })
246
318
  : search.state.query.length > 0
247
319
  ? _jsx(Text, { dimColor: true, color: theme.search?.noMatch ?? "red", children: " (no matches)" })
@@ -249,5 +321,5 @@ export function App({ state, completedMessages, streamingText, completedToolCall
249
321
  ? _jsxs(Text, { dimColor: true, color: theme.search?.match ?? undefined, children: [" (match ", (historySearchIndex % historyMatches.length) + 1, " of ", historyMatches.length, ")"] })
250
322
  : historySearchQuery.length > 0
251
323
  ? _jsx(Text, { dimColor: true, color: theme.search?.noMatch ?? "red", children: " (no matches)" })
252
- : _jsx(Text, { dimColor: true, children: " (type to search history)" })] })), historySearchMode && currentMatch && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" ", "\u25b8", " ", currentMatch] }) })), _jsx(InputArea, { value: inputValue, onChange: setInputValue, onSubmit: handleSubmit, bashMode: bashMode, focus: !isAnyModeActive, separatorColor: theme.separator, theme: theme }), _jsx(PermissionsLine, { mode: state.permMode, theme: theme, running: running, agents: agents, selectedAgentId: selectedAgentId, highlightedTabId: agents?.[highlightedTabIndex]?.id ?? null, tabFocused: tabFocused })] })] }));
324
+ : _jsx(Text, { dimColor: true, children: " (type to search history)" })] })), historySearchMode && currentMatch && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" ", "\u25b8", " ", currentMatch] }) })), showHelp ? _jsx(ShortcutHelp, { theme: theme }) : null, planReview !== null && planReview !== undefined ? _jsx(PlanReview, { text: planReview, theme: theme }) : null, toolDetail ? (_jsx(ToolDetail, { detail: toolDetail, theme: theme, onMove: onToolDetailMove ?? (() => { }), onClose: onToolDetailClose ?? (() => { }) })) : null, modelPicker ? (_jsx(ModelPicker, { state: modelPicker, theme: theme, onMove: onModelPickerMove ?? (() => { }), onReasoning: onModelPickerReasoning ?? (() => { }), onSelect: onModelPickerSelect ?? (() => { }), onCancel: onModelPickerCancel ?? (() => { }) })) : null, completions.length > 0 && (_jsx(Box, { flexDirection: "column", paddingLeft: 2, children: completions.map((candidate, i) => (_jsxs(Text, { color: i === completionIndex ? theme.statusBar.accent : undefined, dimColor: i !== completionIndex, children: [i === completionIndex ? "\u25b8 " : " ", candidate] }, candidate))) })), approval ? _jsx(ApprovalPanel, { info: approval, theme: theme }) : null, _jsx(StatusBar, { provider: state.provider, model: state.model, project: state.project, turns: state.turns, cost: state.cost, contextTokens: state.contextTokens, contextLimit: state.contextWindow, reasoningEffort: state.reasoningEffort, theme: theme }), _jsx(InputArea, { value: inputValue, onChange: setInputValue, onSubmit: handleSubmit, bashMode: bashMode, focus: !isAnyModeActive && !showHelp && !modelPicker && !toolDetail, completionOpen: completions.length > 0, separatorColor: theme.separator, theme: theme }), _jsx(PermissionsLine, { mode: state.permMode, theme: theme, running: running, agents: agents, selectedAgentId: selectedAgentId, highlightedTabId: agents?.[highlightedTabIndex]?.id ?? null, tabFocused: tabFocused })] })] }));
253
325
  }
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ const RISK_LABEL = { read: "READ", write: "WRITE", dangerous: "SHELL" };
4
+ const RISK_COLOR = { read: "green", write: "yellow", dangerous: "red" };
5
+ export function ApprovalPanel({ info, theme }) {
6
+ const color = RISK_COLOR[info.risk];
7
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: color, paddingX: 1, marginTop: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { bold: true, color: color, children: [RISK_LABEL[info.risk], " "] }), _jsx(Text, { bold: true, children: info.toolName }), info.queueDepth > 0 ? _jsxs(Text, { dimColor: true, children: [" (+", info.queueDepth, " waiting)"] }) : null] }), _jsx(Text, { dimColor: true, children: info.reason }), _jsx(Text, { color: theme?.tool.preview ?? theme?.separator ?? "cyan", children: info.summary }), info.detail ? _jsx(Text, { dimColor: true, children: info.detail }) : null, info.diff ? _jsx(Text, { children: info.diff }) : null, _jsx(Text, { dimColor: true, children: "[y]es [n]o [a]llow-tool [s]ession or type feedback to deny & redirect" })] }));
8
+ }
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text, useStdout } from "ink";
3
+ import { PERMISSION_ICONS, PERMISSION_LABELS } from "../ansi.js";
3
4
  import { PhrenInput } from "./PhrenInput.js";
4
- import { PERMISSION_LABELS, PERMISSION_ICONS } from "../ansi.js";
5
- export function InputArea({ value, onChange, onSubmit, bashMode, focus, separatorColor, theme }) {
5
+ export function InputArea({ value, onChange, onSubmit, bashMode, focus, separatorColor, theme, completionOpen }) {
6
6
  const { stdout } = useStdout();
7
7
  const columns = stdout?.columns || 80;
8
- const sep = "\u2500".repeat(columns);
8
+ const _sep = "\u2500".repeat(columns);
9
9
  const sepColor = theme?.input.separator ?? separatorColor ?? "gray";
10
10
  const promptColor = theme?.input.prompt ?? undefined;
11
11
  const bashPromptColor = theme?.input.bashPrompt ?? "yellow";
12
12
  return (_jsxs(Box, { flexDirection: "row", borderStyle: "round", borderColor: sepColor, borderLeft: false, borderRight: false, borderTop: true, borderBottom: true, width: columns, marginTop: 1, children: [bashMode
13
13
  ? _jsx(Text, { color: bashPromptColor, children: "! " })
14
- : _jsxs(Text, { color: promptColor, dimColor: true, children: ["\u276f", " "] }), _jsx(PhrenInput, { value: value, onChange: onChange, onSubmit: onSubmit, focus: focus })] }));
14
+ : _jsxs(Text, { color: promptColor, dimColor: true, children: ["\u276f", " "] }), _jsx(PhrenInput, { value: value, onChange: onChange, onSubmit: onSubmit, focus: focus, completionOpen: completionOpen })] }));
15
15
  }
16
16
  const STATUS_ICON = {
17
17
  running: "\u25cf", // ●
@@ -49,7 +49,7 @@ export function PermissionsLine({ mode, theme, running, agents, selectedAgentId,
49
49
  }
50
50
  return agent.color;
51
51
  }
52
- return (_jsxs(Box, { children: [showPerm ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: color, children: [icon, " ", label] }), _jsxs(Text, { dimColor: true, children: [" (shift+tab to cycle)", running ? " \u00b7 esc to interrupt" : ""] })] })) : (_jsxs(Text, { children: [" ", running ? _jsx(Text, { dimColor: true, children: "esc to interrupt" }) : null] })), hasAgents ? (_jsxs(Text, { children: [" ", agents.map((agent, i) => {
52
+ return (_jsxs(Box, { children: [showPerm ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: color, children: [icon, " ", label] }), _jsxs(Text, { dimColor: true, children: [" (shift+tab to cycle) \u00B7 ?/F1 help", running ? " \u00b7 esc to interrupt" : ""] })] })) : (_jsxs(Text, { children: [" ", _jsxs(Text, { dimColor: true, children: ["?/F1 help \u00B7 shift+tab permissions \u00B7 ctrl+o tools \u00B7 ctrl+f find \u00B7 ctrl+t plan", running ? " · esc to interrupt" : ""] })] })), hasAgents ? (_jsxs(Text, { children: [" ", agents.map((agent, i) => {
53
53
  const isActive = agent.id === selectedAgentId;
54
54
  const isHighlighted = tabFocused && agent.id === highlightedTabId;
55
55
  const statusIcon = STATUS_ICON[agent.status];
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text, useInput } from "ink";
3
+ import { REASONING_LEVELS } from "../../models.js";
4
+ function meter(level, theme) {
5
+ if (!level)
6
+ return "\u2500\u2500\u2500\u2500\u2500";
7
+ const index = REASONING_LEVELS.indexOf(level);
8
+ const filled = index < 0 ? 0 : Math.min(index + 1, 5);
9
+ return "\u25cf".repeat(filled) + "\u25cb".repeat(5 - filled);
10
+ }
11
+ export function ModelPicker({ state, theme, onMove, onReasoning, onSelect, onCancel }) {
12
+ useInput((input, key) => {
13
+ if (key.escape) {
14
+ onCancel();
15
+ return;
16
+ }
17
+ if (key.return) {
18
+ onSelect();
19
+ return;
20
+ }
21
+ if (key.upArrow) {
22
+ onMove(-1);
23
+ return;
24
+ }
25
+ if (key.downArrow) {
26
+ onMove(1);
27
+ return;
28
+ }
29
+ if (key.leftArrow) {
30
+ onReasoning(-1);
31
+ return;
32
+ }
33
+ if (key.rightArrow) {
34
+ onReasoning(1);
35
+ return;
36
+ }
37
+ });
38
+ const accent = theme?.statusBar.accent ?? "cyan";
39
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: accent, paddingX: 1, marginTop: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, children: "Select model " }), _jsx(Text, { dimColor: true, children: "\u2191\u2193 navigate \u00b7 \u2190\u2192 reasoning \u00b7 enter select \u00b7 esc cancel" })] }), state.models.map((model, i) => {
40
+ const selected = i === state.cursor;
41
+ return (_jsxs(Text, { color: selected ? accent : undefined, dimColor: !selected, children: [selected ? "\u25b8 " : " ", model.label, _jsxs(Text, { dimColor: true, children: [" ", meter(state.reasoning[i], theme), state.reasoning[i] ? ` ${state.reasoning[i]}` : ""] }), _jsxs(Text, { dimColor: true, children: [" ", Math.round(model.contextWindow / 1000), "k"] })] }, model.id));
42
+ })] }));
43
+ }
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { Box, Text, useInput } from "ink";
4
2
  import * as fs from "fs";
5
- import * as nodePath from "path";
3
+ import { Box, Text, useInput } from "ink";
6
4
  import * as os from "os";
5
+ import * as nodePath from "path";
6
+ import { useEffect, useState } from "react";
7
+ import { isHelpKey } from "../help.js";
7
8
  /** Map a flat cursor offset to { line, col } within a multi-line string. */
8
9
  function offsetToPos(text, offset) {
9
10
  let line = 0;
@@ -33,7 +34,7 @@ function posToOffset(lines, line, col) {
33
34
  * Replaces ink-text-input to enable cursor positioning, word jump,
34
35
  * kill-line, Shift+Enter multi-line, and other readline-style keybindings.
35
36
  */
36
- export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = true }) {
37
+ export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = true, completionOpen = false }) {
37
38
  const [cursor, setCursor] = useState(value.length);
38
39
  // Keep cursor within bounds when value changes externally
39
40
  useEffect(() => {
@@ -42,6 +43,10 @@ export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = tru
42
43
  const lines = value.split("\n");
43
44
  const isMultiLine = lines.length > 1;
44
45
  useInput((input, key) => {
46
+ if (isHelpKey(input, value))
47
+ return;
48
+ if (completionOpen && (key.upArrow || key.downArrow || (key.tab && !key.shift)))
49
+ return;
45
50
  // Bracketed paste: strip \x1b[200~ (start) and \x1b[201~ (end) markers.
46
51
  // If markers are present, insert the cleaned text at cursor as a single paste.
47
52
  const PASTE_START = "\x1b[200~";
@@ -289,7 +294,7 @@ function completeFilePath(value, cursor) {
289
294
  if (!tokenMatch)
290
295
  return null;
291
296
  const token = tokenMatch[1];
292
- const tokenStart = cursor - token.length;
297
+ const _tokenStart = cursor - token.length;
293
298
  // Only complete tokens that look like paths
294
299
  if (!/[/.~]/.test(token))
295
300
  return null;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ import { renderMarkdown } from "../../multi/markdown.js";
4
+ export function PlanReview({ text, theme }) {
5
+ const accent = theme?.statusBar.accent ?? "magenta";
6
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: accent, paddingX: 1, marginTop: 1, children: [_jsx(Text, { bold: true, color: accent, children: "Plan ready for review" }), _jsx(Text, { wrap: "wrap", children: text ? renderMarkdown(text, theme?.markdown) : "(empty plan)" }), _jsx(Text, { dimColor: true, children: "[y]es approve [n]o abort or type feedback to revise" })] }));
7
+ }
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ export function ShortcutHelp({ theme }) {
4
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.separator, paddingX: 1, children: [_jsx(Text, { bold: true, children: "Keyboard shortcuts" }), _jsx(Text, { children: "Enter send \u00B7 Shift+Enter newline \u00B7 Tab complete" }), _jsx(Text, { children: "Shift+Tab permissions \u00B7 Esc interrupt / clear draft" }), _jsx(Text, { children: "Ctrl+R history \u00B7 Ctrl+F find \u00B7 Ctrl+O tool details" }), _jsx(Text, { children: "Ctrl+T plan \u00B7 Ctrl+G editor \u00B7 Ctrl+S stash / restore draft" }), _jsx(Text, { children: "\u2191\u2193 history \u00B7 Shift+\u2193 next agent \u00B7 \u2193 on empty draft: agent tabs" }), _jsx(Text, { children: "Ctrl+L clear screen \u00B7 Ctrl+D quit \u00B7 Ctrl+C cancel / clear / quit" }), _jsx(Text, { dimColor: true, children: "Esc, ? or F1 close \u00B7 F1 opens help with a draft" })] }));
5
+ }
@@ -1,27 +1,53 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Text, useStdout } from "ink";
3
- import { PERMISSION_LABELS } from "../ansi.js";
4
- export function StatusBar({ provider, project, turns, cost, permMode, agentCount, theme }) {
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text, useStdout } from "ink";
3
+ function displayWidth(text) {
4
+ let width = 0;
5
+ for (const ch of text) {
6
+ const code = ch.codePointAt(0) ?? 0;
7
+ const wide = (code >= 0x1100 && code <= 0x115f) || (code >= 0x2e80 && code <= 0xa4cf)
8
+ || (code >= 0xac00 && code <= 0xd7a3) || (code >= 0xf900 && code <= 0xfaff)
9
+ || (code >= 0xfe30 && code <= 0xfe6f) || (code >= 0xff00 && code <= 0xff60)
10
+ || (code >= 0xffe0 && code <= 0xffe6) || (code >= 0x1f300 && code <= 0x1faff);
11
+ width += wide ? 2 : 1;
12
+ }
13
+ return width;
14
+ }
15
+ function truncate(text, max) {
16
+ if (max <= 0)
17
+ return "";
18
+ if (displayWidth(text) <= max)
19
+ return text;
20
+ let out = "";
21
+ for (const ch of text) {
22
+ if (displayWidth(out + ch) > max - 1)
23
+ break;
24
+ out += ch;
25
+ }
26
+ return out + "\u2026";
27
+ }
28
+ export function StatusBar({ provider, model, project, turns, cost, contextTokens, contextLimit, reasoningEffort, theme }) {
5
29
  const { stdout } = useStdout();
6
30
  const width = stdout?.columns || 80;
7
- const modeLabel = permMode ? PERMISSION_LABELS[permMode] : "";
8
- const agentTag = agentCount && agentCount > 0 ? `A${agentCount}` : "";
9
- const leftParts = [" \u25c6 phren", provider];
31
+ const leftParts = ["\u25c6 phren", provider];
32
+ if (model)
33
+ leftParts.push(model);
10
34
  if (project)
11
35
  leftParts.push(project);
12
36
  const left = leftParts.join(" \u00b7 ");
13
- const rightParts = [];
14
- if (modeLabel)
15
- rightParts.push(modeLabel);
16
- if (agentTag)
17
- rightParts.push(agentTag);
37
+ const pct = contextTokens !== undefined && contextLimit && contextLimit > 0
38
+ ? Math.round((contextTokens / contextLimit) * 100)
39
+ : undefined;
40
+ const ctxText = pct !== undefined ? `ctx ${pct}%` : "";
41
+ const restParts = [];
42
+ if (reasoningEffort)
43
+ restParts.push(reasoningEffort);
18
44
  if (cost)
19
- rightParts.push(cost);
20
- rightParts.push(`T${turns}`);
21
- const right = rightParts.join(" ") + " ";
22
- const pad = Math.max(0, width - left.length - right.length);
23
- const fullLine = left + " ".repeat(pad) + right;
24
- // theme.statusBar.accent is available for future use (e.g. highlighted segments)
25
- const _accent = theme?.statusBar.accent;
26
- return _jsx(Text, { inverse: true, children: fullLine });
45
+ restParts.push(cost);
46
+ restParts.push(`T${turns}`);
47
+ const rest = restParts.join(" \u00b7 ");
48
+ const rightWidth = displayWidth(ctxText) + (ctxText && rest ? 3 : 0) + displayWidth(rest);
49
+ const leftText = truncate(left, Math.max(0, width - rightWidth - 2));
50
+ const pad = Math.max(1, width - displayWidth(leftText) - rightWidth - 1);
51
+ const hot = pct !== undefined && pct >= 80;
52
+ return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, color: theme?.statusBar.accent, children: leftText + " ".repeat(pad) }), ctxText ? _jsx(Text, { color: hot ? "yellow" : undefined, dimColor: !hot, children: ctxText }) : null, ctxText && rest ? _jsx(Text, { dimColor: true, children: " \u00b7 " }) : null, rest ? _jsx(Text, { dimColor: true, children: rest }) : null] }));
27
53
  }
@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  export function SteerQueue({ items, theme }) {
4
4
  if (items.length === 0)
@@ -1,20 +1,22 @@
1
- import { jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useMemo } from "react";
3
3
  import { Text } from "ink";
4
4
  // Phren's own thinking verbs — memory-oriented
5
5
  const THINKING_VERBS = [
6
6
  "recalling", "connecting", "reasoning", "threading", "mapping", "synthesizing",
7
7
  ];
8
- export function ThinkingIndicator({ startTime: _startTime, theme }) {
8
+ export function ThinkingIndicator({ startTime, theme }) {
9
9
  const [frame, setFrame] = useState(0);
10
+ const [elapsed, setElapsed] = useState(0);
10
11
  // Pick a random verb once per mount
11
12
  const verb = useMemo(() => THINKING_VERBS[Math.floor(Math.random() * THINKING_VERBS.length)], []);
12
13
  useEffect(() => {
13
14
  const timer = setInterval(() => {
14
15
  setFrame((f) => f + 1);
16
+ setElapsed(Math.max(0, Math.floor((Date.now() - (startTime || Date.now())) / 1000)));
15
17
  }, 500);
16
18
  return () => clearInterval(timer);
17
- }, []);
19
+ }, [startTime]);
18
20
  // Gentle sine-wave interpolation between theme thinking colors
19
21
  const t = (Math.sin(frame * 0.4) + 1) / 2;
20
22
  const [pr, pg, pb] = theme.thinking.primary;
@@ -23,5 +25,5 @@ export function ThinkingIndicator({ startTime: _startTime, theme }) {
23
25
  const g = Math.round(pg * (1 - t) + sg * t);
24
26
  const b = Math.round(pb * (1 - t) + sb * t);
25
27
  const hex = `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
26
- return (_jsxs(Text, { children: [" ", _jsxs(Text, { color: hex, children: ["\u25c6", " ", verb, "\u2026"] })] }));
28
+ return (_jsxs(Text, { children: [" ", _jsxs(Text, { color: hex, children: ["\u25c6", " ", verb, "\u2026"] }), elapsed > 0 ? _jsx(Text, { dimColor: true, children: ` ${elapsed}s` }) : null] }));
27
29
  }
@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { formatToolInput, formatDuration, fileLink, isFileToolPreview } from "../tool-render.js";
4
4
  const FOLD_LINES = 3;
@@ -12,12 +12,18 @@ export function ToolCall({ name, input, output, isError, durationMs, diffRendere
12
12
  const durationColor = theme?.tool.duration ?? undefined;
13
13
  const outputColor = theme?.tool.output ?? undefined;
14
14
  // Header: ◇ Name(preview) dur
15
- const header = (_jsxs(Box, { children: [_jsxs(Text, { color: statusColor, children: [isError ? "\u2717" : "\u25c7", " "] }), _jsx(Text, { bold: true, color: nameColor, children: name }), preview ? _jsxs(Text, { color: previewColor, children: ["(", preview, ")"] }) : null, _jsxs(Text, { color: durationColor, dimColor: true, children: [" ", dur] })] }));
15
+ const header = (_jsxs(Box, { children: [_jsxs(Text, { color: statusColor, children: [isError ? "\u2717" : "\u25c7", " "] }), _jsx(Text, { bold: true, color: nameColor, children: name }), preview ? _jsxs(Text, { color: previewColor, children: [" (", preview, ")"] }) : null, _jsxs(Text, { color: durationColor, dimColor: true, children: [" ", dur] })] }));
16
+ const bodyColor = isError ? "red" : outputColor;
16
17
  if (!verbose) {
17
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [header, diffRendered && (_jsxs(Text, { children: [" \u23bf ", diffRendered] }))] }));
18
+ const previewLine = output.split("\n").find((line) => line.trim())?.slice(0, 120);
19
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [header, diffRendered
20
+ ? _jsxs(Text, { children: [" \u23bf ", diffRendered] })
21
+ : previewLine
22
+ ? _jsxs(Text, { color: bodyColor, dimColor: !isError, children: [" \u23bf ", previewLine] })
23
+ : null] }));
18
24
  }
19
25
  const allLines = output.split("\n").filter(Boolean);
20
26
  const shown = expanded ? allLines : allLines.slice(0, FOLD_LINES);
21
27
  const overflow = allLines.length - FOLD_LINES;
22
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [header, diffRendered ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: [" \u23bf ", diffRendered.split("\n")[0] ?? ""] }), diffRendered.split("\n").slice(1).map((line, i) => (_jsxs(Text, { children: [" ", line] }, i)))] })) : (_jsxs(_Fragment, { children: [shown.map((line, i) => (_jsxs(Text, { color: outputColor, dimColor: true, children: [i === 0 ? " \u23bf " : " ", line.slice(0, 120)] }, i))), !expanded && overflow > 0 && (_jsxs(Text, { color: outputColor, dimColor: true, children: [" \u2026 +", overflow, " lines (ctrl+o to expand)"] }))] }))] }));
28
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [header, diffRendered ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: [" \u23bf ", diffRendered.split("\n")[0] ?? ""] }), diffRendered.split("\n").slice(1).map((line, i) => (_jsxs(Text, { children: [" ", line] }, i)))] })) : (_jsxs(_Fragment, { children: [shown.map((line, i) => (_jsxs(Text, { color: bodyColor, dimColor: !isError, children: [i === 0 ? " \u23bf " : " ", line.slice(0, 120)] }, i))), !expanded && overflow > 0 && (_jsxs(Text, { color: bodyColor, dimColor: !isError, children: [" \u2026 +", overflow, " lines (ctrl+o to expand)"] }))] }))] }));
23
29
  }
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text, useInput } from "ink";
3
+ import { formatToolInput } from "../tool-render.js";
4
+ export function ToolDetail({ detail, theme, onMove, onClose }) {
5
+ useInput((input, key) => {
6
+ if (key.escape) {
7
+ onClose();
8
+ return;
9
+ }
10
+ if (key.upArrow) {
11
+ onMove(-1);
12
+ return;
13
+ }
14
+ if (key.downArrow) {
15
+ onMove(1);
16
+ return;
17
+ }
18
+ });
19
+ const { call } = detail;
20
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: call.isError ? "red" : (theme?.tool.name ?? "gray"), paddingX: 1, marginTop: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, children: call.name }), _jsxs(Text, { dimColor: true, children: [" ", formatToolInput(call.name, call.input)] }), _jsxs(Text, { dimColor: true, children: [" (", detail.index + 1, "/", detail.total, " \u00b7 \u2191\u2193 \u00b7 esc)"] })] }), _jsx(Text, { color: call.isError ? "red" : theme?.tool.output ?? undefined, wrap: "wrap", children: call.output || "(no output)" })] }));
21
+ }
@@ -0,0 +1,6 @@
1
+ /** Recognize raw F1 sequences; Ink omits function keys from useInput. */
2
+ export function isHelpKey(input, value) {
3
+ return input === "\u001bOP" || input === "\u001b[11~" || input === "\u001b[[A" || input === "\u001b[P"
4
+ || input === "\u001b[57364u"
5
+ || (input === "?" && value === "");
6
+ }
@@ -7,6 +7,20 @@ export function useKeyboardShortcuts(opts) {
7
7
  if (opts.ctrlCCount > 0)
8
8
  opts.onSetCtrlCCount(0);
9
9
  }
10
+ if (opts.completionOpen && (opts.completionCount ?? 0) > 0) {
11
+ if (key.upArrow) {
12
+ opts.onCompletionMove?.(-1);
13
+ return;
14
+ }
15
+ if (key.downArrow) {
16
+ opts.onCompletionMove?.(1);
17
+ return;
18
+ }
19
+ if (key.tab && !key.shift) {
20
+ opts.onCompletionAccept?.();
21
+ return;
22
+ }
23
+ }
10
24
  // ── Tab bar navigation ────────────────────────────────────
11
25
  if (opts.tabFocused) {
12
26
  if (key.leftArrow) {
@@ -165,5 +179,5 @@ export function useKeyboardShortcuts(opts) {
165
179
  }
166
180
  return;
167
181
  }
168
- });
182
+ }, { isActive: opts.enabled !== false });
169
183
  }
package/dist/tui/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export { ESC, s, cols, stripAnsi } from "./ansi.js";
2
2
  export { PERMISSION_MODES, nextPermissionMode, PERMISSION_LABELS, PERMISSION_ICONS, PERMISSION_COLORS, permTag } from "./ansi.js";
3
3
  export { COMPACT_LINES, formatDuration, formatToolInput, renderToolCall } from "./tool-render.js";
4
- export { loadMenuModule, renderMenu, enterMenuMode, exitMenuMode, handleMenuKeypress } from "./menu-mode.js";
5
4
  export { startInkTui } from "./ink-entry.js";