@phren/agent 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,11 @@ export async function runTurn(userInput, session, config, hooks) {
25
25
  session.messages.push({ role: "user", content: userInput });
26
26
  let turnToolCalls = 0;
27
27
  const turnStart = session.turns;
28
+ const signal = hooks?.signal;
28
29
  while (session.turns - turnStart < maxTurns) {
30
+ // Abort check
31
+ if (signal?.aborted)
32
+ break;
29
33
  // Budget check
30
34
  if (costTracker?.isOverBudget()) {
31
35
  status(`\x1b[33m[budget exceeded: ${costTracker.formatCost()}]\x1b[0m\n`);
@@ -61,7 +65,7 @@ export async function runTurn(userInput, session, config, hooks) {
61
65
  if (useStream) {
62
66
  // Streaming path — retry the initial connection (before consuming deltas)
63
67
  const stream = await withRetry(async () => provider.chatStream(systemPrompt, session.messages, turnTools), undefined, verbose);
64
- const result = await consumeStream(stream, costTracker, hooks?.onTextDelta);
68
+ const result = await consumeStream(stream, costTracker, hooks?.onTextDelta, signal);
65
69
  assistantContent = result.content;
66
70
  stopReason = result.stop_reason;
67
71
  }
@@ -92,6 +96,9 @@ export async function runTurn(userInput, session, config, hooks) {
92
96
  }
93
97
  session.messages.push({ role: "assistant", content: assistantContent });
94
98
  session.turns++;
99
+ // Abort check after LLM response
100
+ if (signal?.aborted)
101
+ break;
95
102
  // Show turn cost
96
103
  if (verbose && costTracker) {
97
104
  status(`\x1b[2m cost: ${costTracker.formatCost()}\x1b[0m\n`);
@@ -30,13 +30,15 @@ export async function runToolsConcurrently(blocks, registry) {
30
30
  return results;
31
31
  }
32
32
  /** Consume a chatStream into ContentBlock[] + stop_reason, streaming text via callback. */
33
- export async function consumeStream(stream, costTracker, onTextDelta) {
33
+ export async function consumeStream(stream, costTracker, onTextDelta, signal) {
34
34
  const content = [];
35
35
  let stop_reason = "end_turn";
36
36
  let currentText = "";
37
37
  // Map block index -> tool state for Anthropic-style index-based IDs
38
38
  const toolsByIndex = new Map();
39
39
  for await (const delta of stream) {
40
+ if (signal?.aborted)
41
+ break;
40
42
  if (delta.type === "text_delta") {
41
43
  (onTextDelta ?? process.stdout.write.bind(process.stdout))(delta.text);
42
44
  currentText += delta.text;
@@ -0,0 +1,13 @@
1
+ const DIM = "\x1b[2m";
2
+ const BOLD = "\x1b[1m";
3
+ const RESET = "\x1b[0m";
4
+ export function configCommand(parts, ctx) {
5
+ void parts; // no sub-commands yet — display-only
6
+ process.stderr.write(`\n${BOLD}Configuration${RESET}\n`);
7
+ process.stderr.write(`${DIM} Provider: ${ctx.providerName ?? "unknown"}${RESET}\n`);
8
+ process.stderr.write(`${DIM} Model: ${ctx.currentModel ?? "default"}${RESET}\n`);
9
+ process.stderr.write(`${DIM} Reasoning: ${ctx.currentReasoning ?? "default"}${RESET}\n`);
10
+ process.stderr.write(`${DIM} Project: ${ctx.phrenCtx?.project ?? "none"}${RESET}\n`);
11
+ process.stderr.write(`\n`);
12
+ return true;
13
+ }
package/dist/commands.js CHANGED
@@ -3,6 +3,7 @@ import { helpCommand, turnsCommand, clearCommand, cwdCommand, filesCommand, cost
3
3
  import { sessionCommand, historyCommand, compactCommand, diffCommand, gitCommand, resumeCommand } from "./commands/session.js";
4
4
  import { memCommand, askCommand } from "./commands/memory.js";
5
5
  import { modelCommand, providerCommand, presetCommand } from "./commands/model.js";
6
+ import { configCommand } from "./commands/config.js";
6
7
  import { loadInputMode, saveInputMode, savePermissionMode } from "./settings.js";
7
8
  const DIM = "\x1b[2m";
8
9
  const RESET = "\x1b[0m";
@@ -20,7 +21,7 @@ export function createCommandContext(session, contextLimit) {
20
21
  export const COMMAND_NAMES = [
21
22
  "/help", "/turns", "/clear", "/cwd", "/files", "/cost", "/plan", "/undo",
22
23
  "/context", "/model", "/provider", "/preset", "/session", "/history",
23
- "/compact", "/diff", "/git", "/mem", "/ask", "/resume", "/spawn", "/agents",
24
+ "/compact", "/diff", "/git", "/mem", "/ask", "/resume", "/config", "/spawn", "/agents",
24
25
  "/mode", "/permissions", "/verbose", "/theme", "/agent",
25
26
  "/exit", "/quit", "/q",
26
27
  ];
@@ -52,6 +53,7 @@ export function handleCommand(input, ctx) {
52
53
  case "/mem": return memCommand(parts, ctx);
53
54
  case "/ask": return askCommand(parts, ctx);
54
55
  case "/resume": return resumeCommand(parts, ctx);
56
+ case "/config": return configCommand(parts, ctx);
55
57
  case "/mode": {
56
58
  const current = loadInputMode();
57
59
  const newMode = current === "steering" ? "queue" : "steering";
package/dist/tui/ansi.js CHANGED
@@ -25,9 +25,14 @@ export function stripAnsi(t) {
25
25
  // ── Permission mode helpers ─────────────────────────────────────────────────
26
26
  // Cycle: ask → auto edits → plan → autopilot (matches Claude Code pattern)
27
27
  export const PERMISSION_MODES = ["suggest", "auto-confirm", "plan", "full-auto"];
28
- export function nextPermissionMode(current) {
29
- const idx = PERMISSION_MODES.indexOf(current);
30
- return PERMISSION_MODES[(idx + 1) % PERMISSION_MODES.length];
28
+ /** Cycle to next permission mode. Skips full-auto unless yolo is true. */
29
+ export function nextPermissionMode(current, yolo = false) {
30
+ const modes = yolo ? PERMISSION_MODES : PERMISSION_MODES.filter(m => m !== "full-auto");
31
+ const idx = modes.indexOf(current);
32
+ // If current mode is full-auto but yolo is false, jump to suggest
33
+ if (idx === -1)
34
+ return modes[0];
35
+ return modes[(idx + 1) % modes.length];
31
36
  }
32
37
  export const PERMISSION_LABELS = {
33
38
  "suggest": "",
@@ -43,9 +48,9 @@ export const PERMISSION_ICONS = {
43
48
  };
44
49
  export const PERMISSION_COLORS = {
45
50
  "suggest": (t) => t, // invisible / no color
46
- "auto-confirm": s.yellow, // orange-ish (ANSI yellow)
51
+ "auto-confirm": s.blue, // blue
47
52
  "plan": s.magenta, // purple
48
- "full-auto": s.green, // green
53
+ "full-auto": s.green, // green (requires --yolo to enable)
49
54
  };
50
55
  export function permTag(mode) {
51
56
  return PERMISSION_COLORS[mode](`${PERMISSION_ICONS[mode]} ${PERMISSION_LABELS[mode]}`);
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState, useCallback, useEffect } from "react";
3
3
  import { Static, Box, Text, useApp, useInput } from "ink";
4
4
  import { Banner } from "./Banner.js";
@@ -10,7 +10,7 @@ import { InputArea, PermissionsLine } from "./InputArea.js";
10
10
  import { useKeyboardShortcuts } from "../hooks/useKeyboardShortcuts.js";
11
11
  import { renderMarkdown } from "../../multi/markdown.js";
12
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, agents, selectedAgentId, onSelectAgent, onCancelAgent, }) {
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, }) {
14
14
  const { exit } = useApp();
15
15
  const [inputValue, setInputValue] = useState("");
16
16
  const [bashMode, setBashMode] = useState(false);
@@ -18,10 +18,12 @@ export function App({ state, completedMessages, streamingText, completedToolCall
18
18
  const [ctrlCCount, setCtrlCCount] = useState(0);
19
19
  const [tabFocused, setTabFocused] = useState(false);
20
20
  const [highlightedTabIndex, setHighlightedTabIndex] = useState(0);
21
+ const [showTaskList, setShowTaskList] = useState(false);
21
22
  const [stashedInput, setStashedInput] = useState("");
22
23
  const [historySearchMode, setHistorySearchMode] = useState(false);
23
24
  const [historySearchQuery, setHistorySearchQuery] = useState("");
24
25
  const [historySearchIndex, setHistorySearchIndex] = useState(0);
26
+ const [expandedTools, setExpandedTools] = useState(new Set());
25
27
  // ── Ctrl+F content search ────────────────────────────────────────────────
26
28
  const search = useSearch();
27
29
  // When the query changes, recompute total match count across all completed messages
@@ -163,6 +165,22 @@ export function App({ state, completedMessages, streamingText, completedToolCall
163
165
  onContentSearch: () => {
164
166
  search.activate();
165
167
  },
168
+ onExpandTool: () => {
169
+ const lastIndex = completedToolCalls.length - 1;
170
+ if (lastIndex < 0)
171
+ 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?.();
183
+ },
166
184
  onOpenEditor: () => {
167
185
  // Write input to temp file, open $EDITOR, read back
168
186
  const tmpFile = `/tmp/phren-input-${Date.now()}.md`;
@@ -192,6 +210,13 @@ export function App({ state, completedMessages, streamingText, completedToolCall
192
210
  onSelectAgent?.(id === "__main__" ? null : id);
193
211
  }
194
212
  },
213
+ onCycleAgent: agents && agents.length > 0 ? () => {
214
+ const currentIdx = agents.findIndex(a => a.id === selectedAgentId || (selectedAgentId === null && a.id === "__main__"));
215
+ const nextIdx = (currentIdx + 1) % agents.length;
216
+ const nextId = agents[nextIdx].id;
217
+ onSelectAgent?.(nextId === "__main__" ? null : nextId);
218
+ } : undefined,
219
+ onToggleTaskList: () => setShowTaskList(v => !v),
195
220
  });
196
221
  // Helper: apply search highlighting to a text string (ANSI only works in
197
222
  // non-Ink raw text mode). Since Ink's <Text> will escape ANSI we pass raw
@@ -201,18 +226,7 @@ export function App({ state, completedMessages, streamingText, completedToolCall
201
226
  return text;
202
227
  return highlightMatches(text, search.state.query).highlighted;
203
228
  }, [search.state.active, search.state.query]);
204
- // Build Static items — banner first, then completed messages
205
- const staticItems = [];
206
- if (showBanner) {
207
- staticItems.push({ id: "banner", kind: "banner" });
208
- }
209
- for (const msg of completedMessages) {
210
- staticItems.push(msg);
211
- }
212
- return (_jsxs(_Fragment, { children: [_jsx(Static, { items: staticItems, children: (item) => {
213
- if (item.kind === "banner") {
214
- return (_jsx(Box, { flexDirection: "column", children: _jsx(Banner, { version: state.version, theme: theme }) }, "banner"));
215
- }
229
+ return (_jsxs(_Fragment, { children: [_jsx(Static, { items: completedMessages, children: (item) => {
216
230
  if (item.kind === "user") {
217
231
  return (_jsx(Box, { flexDirection: "column", children: _jsxs(Text, { bold: theme.user.bold ?? true, color: theme.user.color, children: [theme.user.label, " ", applySearch(item.text)] }) }, item.id));
218
232
  }
@@ -227,7 +241,7 @@ export function App({ state, completedMessages, streamingText, completedToolCall
227
241
  return _jsx(Text, { color: theme.system.color, dimColor: true, children: applySearch(item.text) }, item.id);
228
242
  }
229
243
  return null;
230
- } }), _jsxs(Box, { flexDirection: "column", children: [completedToolCalls.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme }, `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: streamingText })] })), thinking && _jsx(Box, { marginTop: 1, children: _jsx(ThinkingIndicator, { startTime: thinkStartTime, theme: theme }) }), thinkElapsed !== null && (_jsxs(Text, { color: theme.dim, dimColor: true, children: [" ", "\u25c6", " thought for ", thinkElapsed, "s"] })), ctrlCCount > 0 && !running && (_jsxs(Text, { dimColor: true, children: [" ", "Press Ctrl+C again to exit."] })), _jsx(SteerQueue, { items: steerQueue, theme: theme }), 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
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
231
245
  ? _jsxs(Text, { dimColor: true, color: theme.search?.match ?? undefined, children: [" (", search.state.currentMatch + 1, " of ", search.state.matchCount, ")"] })
232
246
  : search.state.query.length > 0
233
247
  ? _jsx(Text, { dimColor: true, color: theme.search?.noMatch ?? "red", children: " (no matches)" })
@@ -235,5 +249,5 @@ export function App({ state, completedMessages, streamingText, completedToolCall
235
249
  ? _jsxs(Text, { dimColor: true, color: theme.search?.match ?? undefined, children: [" (match ", (historySearchIndex % historyMatches.length) + 1, " of ", historyMatches.length, ")"] })
236
250
  : historySearchQuery.length > 0
237
251
  ? _jsx(Text, { dimColor: true, color: theme.search?.noMatch ?? "red", children: " (no matches)" })
238
- : _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, agents: agents, selectedAgentId: selectedAgentId, highlightedTabId: agents?.[highlightedTabIndex]?.id ?? null, tabFocused: tabFocused })] })] }));
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 })] })] }));
239
253
  }
@@ -1,47 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import * as os from "os";
4
- import { createRequire } from "module";
5
- const _require = createRequire(import.meta.url);
6
- let cachedArt = null;
7
- let artLoaded = false;
8
- function getArtLines() {
9
- if (artLoaded)
10
- return cachedArt ?? [];
11
- artLoaded = true;
12
- try {
13
- const mod = _require("@phren/cli/phren-art");
14
- cachedArt = mod.PHREN_ART.filter((l) => l.trim());
15
- return cachedArt;
16
- }
17
- catch {
18
- return [];
19
- }
4
+ function formatContextWindow(n) {
5
+ if (n >= 1_000_000)
6
+ return `${Math.round(n / 1_000_000)}M ctx`;
7
+ if (n >= 1_000)
8
+ return `${Math.round(n / 1_000)}k ctx`;
9
+ return `${n} ctx`;
20
10
  }
21
- function stripAnsi(t) {
22
- return t.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "");
23
- }
24
- export function Banner({ version, theme }) {
11
+ export function Banner({ state, theme }) {
25
12
  const cwd = process.cwd().replace(os.homedir(), "~");
26
- const artLines = getArtLines();
27
- const maxArtWidth = 26;
28
13
  const logoColor = theme?.banner.logo ?? "magenta";
29
14
  const versionColor = theme?.banner.version ?? "gray";
30
15
  const cwdColor = theme?.banner.cwd ?? "cyan";
31
- const infoLines = [
32
- { key: "title", node: _jsx(Text, { bold: true, color: logoColor, children: "◆ phren" }) },
33
- { key: "version", node: _jsx(Text, { color: versionColor, dimColor: true, children: " v" + version }) },
34
- { key: "cwd", node: _jsx(Text, { color: cwdColor, dimColor: true, children: cwd }) },
35
- ];
36
- if (artLines.length > 0) {
37
- const rowCount = Math.max(artLines.length, infoLines.length);
38
- return (_jsxs(Box, { flexDirection: "column", children: [Array.from({ length: rowCount }, (_, i) => {
39
- const artLine = i < artLines.length ? artLines[i] : "";
40
- const artVisible = stripAnsi(artLine).length;
41
- const padding = Math.max(0, maxArtWidth - artVisible);
42
- const info = i < infoLines.length ? infoLines[i] : null;
43
- return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { children: artLine + " ".repeat(padding) }), info ? info.node : _jsx(Text, { children: "" })] }, i));
44
- }), _jsx(Text, { children: "" })] }));
45
- }
46
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Box, { children: [infoLines[0].node, infoLines[1].node] }), infoLines[2].node, _jsx(Text, { children: "" })] }));
16
+ const modelParts = [];
17
+ if (state.model)
18
+ modelParts.push(state.model);
19
+ if (state.contextWindow)
20
+ modelParts.push(formatContextWindow(state.contextWindow));
21
+ if (state.reasoningEffort)
22
+ modelParts.push(state.reasoningEffort);
23
+ const modelLine = modelParts.join(" · ");
24
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { bold: true, color: logoColor, children: "◆ phren" }), _jsx(Text, { color: versionColor, dimColor: true, children: " v" + state.version })] }), modelLine ? (_jsx(Text, { color: versionColor, dimColor: true, children: modelLine })) : null, _jsx(Text, { color: cwdColor, dimColor: true, children: cwd }), _jsx(Text, { children: "" })] }));
47
25
  }
@@ -9,9 +9,9 @@ export function InputArea({ value, onChange, onSubmit, bashMode, focus, separato
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
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: sepColor, dimColor: true, children: sep }), _jsxs(Box, { children: [bashMode
13
- ? _jsx(Text, { color: bashPromptColor, children: "! " })
14
- : _jsxs(Text, { color: promptColor, dimColor: true, children: ["\u25b8", " "] }), _jsx(PhrenInput, { value: value, onChange: onChange, onSubmit: onSubmit, focus: focus })] }), _jsx(Text, { color: sepColor, dimColor: true, children: sep })] }));
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
+ ? _jsx(Text, { color: bashPromptColor, children: "! " })
14
+ : _jsxs(Text, { color: promptColor, dimColor: true, children: ["\u276f", " "] }), _jsx(PhrenInput, { value: value, onChange: onChange, onSubmit: onSubmit, focus: focus })] }));
15
15
  }
16
16
  const STATUS_ICON = {
17
17
  running: "\u25cf", // ●
@@ -21,14 +21,14 @@ const STATUS_ICON = {
21
21
  starting: "\u25cc", // ◌
22
22
  cancelled: "\u2500", // ─
23
23
  };
24
- export function PermissionsLine({ mode, theme, agents, selectedAgentId, highlightedTabId, tabFocused }) {
24
+ export function PermissionsLine({ mode, theme, running, agents, selectedAgentId, highlightedTabId, tabFocused }) {
25
25
  const icon = PERMISSION_ICONS[mode];
26
26
  const label = PERMISSION_LABELS[mode];
27
27
  const permColors = theme?.permission;
28
28
  const color = mode === "suggest"
29
29
  ? (permColors?.suggest ?? "")
30
30
  : mode === "auto-confirm"
31
- ? (permColors?.auto ?? "yellow")
31
+ ? (permColors?.auto ?? "blue")
32
32
  : mode === "plan"
33
33
  ? (permColors?.plan ?? "magenta")
34
34
  : (permColors?.fullAuto ?? "green");
@@ -49,7 +49,7 @@ export function PermissionsLine({ mode, theme, agents, selectedAgentId, highligh
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] })] })) : (_jsx(Text, { children: " " })), 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)", 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) => {
53
53
  const isActive = agent.id === selectedAgentId;
54
54
  const isHighlighted = tabFocused && agent.id === highlightedTabId;
55
55
  const statusIcon = STATUS_ICON[agent.status];
@@ -98,10 +98,10 @@ export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = tru
98
98
  }
99
99
  return;
100
100
  }
101
- // Left arrow / Ctrl+B — move cursor left
101
+ // Left arrow — move cursor left (with word jump modifiers)
102
102
  if (key.leftArrow || (key.ctrl && input === "b")) {
103
- if (key.meta) {
104
- // Alt+Left / Alt+B — word jump left
103
+ if (key.meta || key.ctrl) {
104
+ // Alt+Left / Ctrl+Left / Alt+B / Ctrl+B — word jump left
105
105
  setCursor((c) => wordBoundaryLeft(value, c));
106
106
  }
107
107
  else {
@@ -109,10 +109,10 @@ export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = tru
109
109
  }
110
110
  return;
111
111
  }
112
- // Right arrow / Ctrl+F — move cursor right
112
+ // Right arrow — move cursor right (with word jump modifiers)
113
113
  if (key.rightArrow || (key.ctrl && input === "f")) {
114
- if (key.meta) {
115
- // Alt+Right / Alt+F — word jump right
114
+ if (key.meta || key.ctrl) {
115
+ // Alt+Right / Ctrl+Right / Alt+F / Ctrl+F — word jump right
116
116
  setCursor((c) => wordBoundaryRight(value, c));
117
117
  }
118
118
  else {
@@ -120,7 +120,7 @@ export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = tru
120
120
  }
121
121
  return;
122
122
  }
123
- // Alt+B — word jump left (standalone, not combined with arrow)
123
+ // Alt+B — word jump left (standalone)
124
124
  if (key.meta && input === "b") {
125
125
  setCursor((c) => wordBoundaryLeft(value, c));
126
126
  return;
@@ -142,6 +142,20 @@ export function PhrenInput({ value, onChange, onSubmit, placeholder, focus = tru
142
142
  setCursor(posToOffset(lines, line, lines[line].length));
143
143
  return;
144
144
  }
145
+ // Alt+Backspace / Alt+Delete — delete word before cursor
146
+ if ((key.backspace || key.delete) && key.meta) {
147
+ const boundary = wordBoundaryLeft(value, cursor);
148
+ onChange(value.slice(0, boundary) + value.slice(cursor));
149
+ setCursor(boundary);
150
+ return;
151
+ }
152
+ // Ctrl+Backspace / Ctrl+Delete — delete word before cursor
153
+ if ((key.backspace || key.delete) && key.ctrl) {
154
+ const boundary = wordBoundaryLeft(value, cursor);
155
+ onChange(value.slice(0, boundary) + value.slice(cursor));
156
+ setCursor(boundary);
157
+ return;
158
+ }
145
159
  // Backspace — delete character before cursor
146
160
  if (key.backspace || key.delete) {
147
161
  if (cursor > 0) {
@@ -1,28 +1,27 @@
1
1
  import { jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useMemo } from "react";
3
3
  import { Text } from "ink";
4
- // Phren's own thinking verbs — memory-oriented, not generic
4
+ // Phren's own thinking verbs — memory-oriented
5
5
  const THINKING_VERBS = [
6
- "thinking", "reasoning", "recalling", "connecting", "processing",
6
+ "recalling", "connecting", "reasoning", "threading", "mapping", "synthesizing",
7
7
  ];
8
- export function ThinkingIndicator({ startTime, theme }) {
8
+ export function ThinkingIndicator({ startTime: _startTime, theme }) {
9
9
  const [frame, setFrame] = useState(0);
10
10
  // Pick a random verb once per mount
11
11
  const verb = useMemo(() => THINKING_VERBS[Math.floor(Math.random() * THINKING_VERBS.length)], []);
12
12
  useEffect(() => {
13
13
  const timer = setInterval(() => {
14
14
  setFrame((f) => f + 1);
15
- }, 50);
15
+ }, 500);
16
16
  return () => clearInterval(timer);
17
17
  }, []);
18
- const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
19
18
  // Gentle sine-wave interpolation between theme thinking colors
20
- const t = (Math.sin(frame * 0.08) + 1) / 2;
19
+ const t = (Math.sin(frame * 0.4) + 1) / 2;
21
20
  const [pr, pg, pb] = theme.thinking.primary;
22
21
  const [sr, sg, sb] = theme.thinking.secondary;
23
22
  const r = Math.round(pr * (1 - t) + sr * t);
24
23
  const g = Math.round(pg * (1 - t) + sg * t);
25
24
  const b = Math.round(pb * (1 - t) + sb * t);
26
25
  const hex = `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
27
- return (_jsxs(Text, { children: [" ", _jsxs(Text, { color: hex, children: ["\u25c6", " ", verb] }), " ", _jsxs(Text, { dimColor: true, children: [elapsed, "s"] })] }));
26
+ return (_jsxs(Text, { children: [" ", _jsxs(Text, { color: hex, children: ["\u25c6", " ", verb, "\u2026"] })] }));
28
27
  }
@@ -1,8 +1,8 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { formatToolInput, formatDuration, fileLink, isFileToolPreview } from "../tool-render.js";
4
- const VERBOSE_LINES = 5;
5
- export function ToolCall({ name, input, output, isError, durationMs, diffRendered, verbose, theme }) {
4
+ const FOLD_LINES = 3;
5
+ export function ToolCall({ name, input, output, isError, durationMs, diffRendered, verbose, theme, expanded }) {
6
6
  const rawPreview = formatToolInput(name, input);
7
7
  const preview = isFileToolPreview(name) && rawPreview ? fileLink(rawPreview) : rawPreview;
8
8
  const dur = formatDuration(durationMs);
@@ -11,11 +11,13 @@ export function ToolCall({ name, input, output, isError, durationMs, diffRendere
11
11
  const previewColor = theme?.tool.preview ?? theme?.separator ?? "gray";
12
12
  const durationColor = theme?.tool.duration ?? undefined;
13
13
  const outputColor = theme?.tool.output ?? undefined;
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] })] }));
14
16
  if (!verbose) {
15
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Box, { children: [_jsxs(Text, { color: statusColor, children: [isError ? "\u2717" : "\u2192", " "] }), _jsx(Text, { bold: true, color: nameColor, children: name }), _jsxs(Text, { color: previewColor, children: [" ", preview] }), _jsxs(Text, { color: durationColor, dimColor: true, children: [" ", dur] })] }), diffRendered && (_jsx(Text, { children: diffRendered }))] }));
17
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [header, diffRendered && (_jsxs(Text, { children: [" \u23bf ", diffRendered] }))] }));
16
18
  }
17
19
  const allLines = output.split("\n").filter(Boolean);
18
- const shown = allLines.slice(0, VERBOSE_LINES);
19
- const overflow = allLines.length - VERBOSE_LINES;
20
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Box, { children: [_jsxs(Text, { color: statusColor, children: [isError ? "\u2717" : "\u2192", " "] }), _jsx(Text, { bold: true, color: nameColor, children: name }), _jsxs(Text, { color: previewColor, children: [" ", preview] }), _jsxs(Text, { color: durationColor, dimColor: true, children: [" ", dur] })] }), diffRendered ? (_jsx(Text, { children: diffRendered })) : (_jsxs(_Fragment, { children: [shown.map((line, i) => (_jsx(Text, { color: outputColor, dimColor: true, children: " " + line.slice(0, 120) }, i))), overflow > 0 && (_jsx(Text, { color: outputColor, dimColor: true, children: " ... +" + overflow + " lines" }))] }))] }));
20
+ const shown = expanded ? allLines : allLines.slice(0, FOLD_LINES);
21
+ 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)"] }))] }))] }));
21
23
  }
@@ -32,6 +32,11 @@ export function useKeyboardShortcuts(opts) {
32
32
  // Any other key: exit tab bar and fall through
33
33
  opts.onExitTabBar?.();
34
34
  }
35
+ // Shift+Down → cycle through agent tabs
36
+ if (key.downArrow && key.shift && opts.onCycleAgent) {
37
+ opts.onCycleAgent();
38
+ return;
39
+ }
35
40
  // Down arrow (empty input) → enter tab bar
36
41
  if (key.downArrow && opts.inputValue === "" && opts.onEnterTabBar && !opts.tabFocused) {
37
42
  opts.onEnterTabBar();
@@ -65,6 +70,16 @@ export function useKeyboardShortcuts(opts) {
65
70
  opts.onContentSearch?.();
66
71
  return;
67
72
  }
73
+ // Ctrl+O -- expand/collapse last tool call output
74
+ if (key.ctrl && input === "o") {
75
+ opts.onExpandTool?.();
76
+ return;
77
+ }
78
+ // Ctrl+T -- toggle task list display
79
+ if (key.ctrl && input === "t") {
80
+ opts.onToggleTaskList?.();
81
+ return;
82
+ }
68
83
  // Ctrl+D -- exit cleanly
69
84
  if (key.ctrl && input === "d") {
70
85
  opts.onExit();
@@ -98,8 +113,12 @@ export function useKeyboardShortcuts(opts) {
98
113
  opts.onSetCtrlCCount(opts.ctrlCCount + 1);
99
114
  return;
100
115
  }
101
- // Escape -- cancel agent work, exit bash mode, or clear input
116
+ // Escape -- cancel running turn, exit bash mode, clear input, or cancel agent
102
117
  if (key.escape) {
118
+ if (opts.isRunning) {
119
+ opts.onCancelTurn();
120
+ return;
121
+ }
103
122
  if (opts.bashMode) {
104
123
  opts.onSetBashMode(false);
105
124
  opts.onSetInput("");
@@ -108,7 +127,6 @@ export function useKeyboardShortcuts(opts) {
108
127
  opts.onSetInput("");
109
128
  }
110
129
  else if (opts.onEscCancelAgent) {
111
- // No input, not in bash mode — cancel the selected agent's work
112
130
  opts.onEscCancelAgent();
113
131
  }
114
132
  return;
@@ -12,8 +12,6 @@ import { nextPermissionMode } from "./ansi.js";
12
12
  import { App } from "./components/App.js";
13
13
  import { createRequire } from "node:module";
14
14
  import { getTheme, THEME_NAMES } from "./themes.js";
15
- import { TerminalControl } from "./terminal-control.js";
16
- import { enableMouse, disableMouse, parseMouseEvent } from "./mouse.js";
17
15
  const _require = createRequire(import.meta.url);
18
16
  const AGENT_VERSION = _require("../../package.json").version;
19
17
  export async function startInkTui(config, spawner) {
@@ -28,13 +26,10 @@ export async function startInkTui(config, spawner) {
28
26
  let verbose = false;
29
27
  let theme = getTheme();
30
28
  let msgCounter = 0;
31
- const terminalControl = new TerminalControl();
32
- // Mouse handler ref — assigned after agentTabs/handleSelectAgent are defined.
33
- // Stored here so handleExit (defined before the handler) can call .off on it.
34
- let mouseHandler = () => { };
35
- // Permission prompt state — when set, input field captures y/n/a/s
36
- let permissionResolve = null;
37
- // Ink-compatible askUser: shows prompt in chat, waits for y/n in input
29
+ // Autopilot (full-auto) requires --yolo flag to be cycleable via Shift+Tab
30
+ const yoloEnabled = config.registry.permissionConfig.mode === "full-auto";
31
+ const permissionQueue = [];
32
+ // Ink-compatible askUser: shows prompt in chat, queues for y/n in input
38
33
  config.registry.askUser = async (toolName, input, reason) => {
39
34
  const { addAllow } = await import("../permissions/allowlist.js");
40
35
  const summary = Object.keys(input).length > 0
@@ -43,18 +38,11 @@ export async function startInkTui(config, spawner) {
43
38
  completedMessages.push({
44
39
  id: nextId(),
45
40
  kind: "status",
46
- text: `\x1b[1m\x1b[33m[PERMISSION]\x1b[0m ${toolName}\n ${reason}\n ${summary}\n \x1b[2m[y]es [n]o [a]llow-tool [s]ession-allow\x1b[0m`,
41
+ text: `\x1b[1m\x1b[33m◇ Allow ${toolName}?\x1b[0m ${summary}\n \x1b[2m[y]es [n]o [a]llow [s]ession or type feedback to deny & redirect\x1b[0m`,
47
42
  });
48
43
  update();
49
44
  return new Promise((resolve) => {
50
- permissionResolve = (allowed) => {
51
- permissionResolve = null;
52
- resolve(allowed);
53
- };
54
- // Store the addAllow function for a/s responses
55
- permissionResolve.toolName = toolName;
56
- permissionResolve.input = input;
57
- permissionResolve.addAllow = addAllow;
45
+ permissionQueue.push({ resolve, toolName, input, addAllow });
58
46
  });
59
47
  };
60
48
  // Mutable render state — updated then pushed to React via rerender()
@@ -77,19 +65,11 @@ export async function startInkTui(config, spawner) {
77
65
  permMode: config.registry.permissionConfig.mode,
78
66
  agentCount: spawner?.listAgents().length ?? 0,
79
67
  version: AGENT_VERSION,
68
+ model: config.provider.model,
69
+ contextWindow: config.provider.contextWindow,
70
+ reasoningEffort: config.provider.reasoningEffort,
80
71
  };
81
72
  }
82
- function renderFixedStatus() {
83
- if (!terminalControl.isEnabled)
84
- return;
85
- const s = getAppState();
86
- const cols = process.stdout.columns || 80;
87
- const left = ` \u25c6 phren \u00b7 ${s.provider}${s.project ? ` \u00b7 ${s.project}` : ""}`;
88
- const right = `${s.permMode} T:${s.turns}${s.agentCount > 0 ? ` A:${s.agentCount}` : ""} `;
89
- const pad = Math.max(0, cols - left.length - right.length);
90
- const line = `\x1b[7m${left}${" ".repeat(pad)}${right}\x1b[0m`;
91
- terminalControl.renderStatusBar(process.stdout, line);
92
- }
93
73
  // Re-render the Ink app with current state
94
74
  let rerender = null;
95
75
  // Ink app instance — set after render(), used by closures for clear()
@@ -110,37 +90,34 @@ export async function startInkTui(config, spawner) {
110
90
  return;
111
91
  // Determine what to display based on selected view
112
92
  const agentConvo = selectedAgentId ? agentConvos.get(selectedAgentId) : null;
113
- // When viewing an agent: show their messages with fresh IDs (so Static re-renders after screen clear)
93
+ // Prefix IDs so <Static> re-renders after agent tab switch
114
94
  const prefix = `v${viewSwitchCounter}-`;
115
- const displayMessages = agentConvo
116
- ? agentConvo.messages.map((m) => ({ ...m, id: prefix + m.id }))
117
- : completedMessages.map((m) => ({ ...m, id: prefix + m.id }));
95
+ const rawMessages = agentConvo ? agentConvo.messages : completedMessages;
96
+ const displayMessages = rawMessages.map((m) => ({ ...m, id: prefix + m.id }));
118
97
  const displayStreaming = agentConvo ? agentConvo.streamingText : streamingText;
119
98
  const displayToolCalls = agentConvo ? [...agentConvo.toolCalls] : [...currentToolCalls];
120
99
  const displayActiveTool = agentConvo ? agentConvo.activeTool : activeTool;
121
100
  const displayThinking = agentConvo ? false : thinking;
122
101
  const displayRunning = agentConvo ? (spawner?.getAgent(selectedAgentId)?.status === "running" || false) : running;
123
102
  rerender(_jsx(App, { state: getAppState(), completedMessages: displayMessages, streamingText: displayStreaming, completedToolCalls: displayToolCalls, activeTool: displayActiveTool, thinking: displayThinking, thinkStartTime: thinkStartTime, thinkElapsed: agentConvo ? null : thinkElapsed, steerQueue: agentConvo ? [] : [...steerQueueBuf], running: displayRunning, showBanner: !selectedAgentId, inputHistory: [...inputHistory], verbose: verbose, theme: theme, onSubmit: handleSubmit, onPermissionCycle: handlePermissionCycle, onCancelTurn: handleCancelTurn, onExit: handleExit, agents: agentTabs.length > 0 ? [{ id: "__main__", name: "phren", status: running ? "running" : "idle", color: "magentaBright" }, ...agentTabs] : undefined, selectedAgentId: selectedAgentId ?? (agentTabs.length > 0 ? "__main__" : undefined), onCancelAgent: handleCancelAgent, onSelectAgent: (id) => handleSelectAgent(id === "__main__" ? null : id) }));
124
- renderFixedStatus();
125
103
  }
126
104
  function handlePermissionCycle() {
127
- const next = nextPermissionMode(config.registry.permissionConfig.mode);
105
+ const next = nextPermissionMode(config.registry.permissionConfig.mode, yoloEnabled);
128
106
  config.registry.setPermissions({ ...config.registry.permissionConfig, mode: next });
129
107
  savePermissionMode(next);
130
108
  update();
131
109
  }
132
110
  let resolveSession = null;
133
111
  function handleExit() {
134
- disableMouse(process.stdout);
135
- if (process.stdin.isTTY) {
136
- process.stdin.off("data", mouseHandler);
137
- }
138
- terminalControl.disable(process.stdout);
139
112
  if (resolveSession)
140
113
  resolveSession(session);
141
114
  }
115
+ let turnAbort = null;
142
116
  function handleCancelTurn() {
143
- // Signal cancellation — the running turn will see this via steering
117
+ if (turnAbort) {
118
+ turnAbort.abort();
119
+ turnAbort = null;
120
+ }
144
121
  pendingInput = null;
145
122
  steerQueueBuf.length = 0;
146
123
  update();
@@ -181,27 +158,35 @@ export async function startInkTui(config, spawner) {
181
158
  const line = input.trim();
182
159
  if (!line)
183
160
  return;
184
- // Permission prompt active — intercept y/n/a/s
185
- if (permissionResolve) {
161
+ // Permission prompt active — intercept y/n/a/s (process next in queue)
162
+ if (permissionQueue.length > 0) {
163
+ const entry = permissionQueue.shift();
186
164
  const key = line.toLowerCase();
187
- const meta = permissionResolve;
188
165
  if (key === "y" || key === "yes") {
189
- completedMessages.push({ id: nextId(), kind: "status", text: "\x1b[32m✓ Allowed\x1b[0m" });
190
- permissionResolve(true);
166
+ completedMessages.push({ id: nextId(), kind: "status", text: `\x1b[32m\u2713 ${entry.toolName}\x1b[0m` });
167
+ entry.resolve(true);
191
168
  }
192
169
  else if (key === "a") {
193
- completedMessages.push({ id: nextId(), kind: "status", text: "\x1b[32m✓ Allowed (tool for session)\x1b[0m" });
194
- meta.addAllow(meta.toolName, meta.input, "tool");
195
- permissionResolve(true);
170
+ completedMessages.push({ id: nextId(), kind: "status", text: `\x1b[32m\u2713 ${entry.toolName} (always)\x1b[0m` });
171
+ entry.addAllow(entry.toolName, entry.input, "tool");
172
+ entry.resolve(true);
196
173
  }
197
174
  else if (key === "s") {
198
- completedMessages.push({ id: nextId(), kind: "status", text: "\x1b[32m✓ Allowed (session)\x1b[0m" });
199
- meta.addAllow(meta.toolName, meta.input, "session");
200
- permissionResolve(true);
175
+ completedMessages.push({ id: nextId(), kind: "status", text: `\x1b[32m\u2713 ${entry.toolName} (session)\x1b[0m` });
176
+ entry.addAllow(entry.toolName, entry.input, "session");
177
+ entry.resolve(true);
201
178
  }
202
179
  else {
203
- completedMessages.push({ id: nextId(), kind: "status", text: "\x1b[31m✗ Denied\x1b[0m" });
204
- permissionResolve(false);
180
+ // Deny with feedback: if the input is more than a single n/no, treat it as a redirect message
181
+ const isSilentDeny = key === "n" || key === "no";
182
+ if (!isSilentDeny && line.length > 1) {
183
+ completedMessages.push({ id: nextId(), kind: "status", text: `\x1b[31m\u2717 ${entry.toolName} \x1b[2m\u2014 redirecting: "${line}"\x1b[0m` });
184
+ steerQueueBuf.push(line);
185
+ }
186
+ else {
187
+ completedMessages.push({ id: nextId(), kind: "status", text: `\x1b[31m\u2717 ${entry.toolName}\x1b[0m` });
188
+ }
189
+ entry.resolve(false);
205
190
  }
206
191
  update();
207
192
  return;
@@ -339,10 +324,13 @@ export async function startInkTui(config, spawner) {
339
324
  update();
340
325
  return;
341
326
  }
342
- // Normal user message — add to completed history and run main agent turn
343
- completedMessages.push({ id: nextId(), kind: "user", text: line });
344
- update();
345
- runAgentTurn(line);
327
+ // Normal user message — defer static push to next tick so dynamic area is clean
328
+ update(); // flush clean state first (empty input)
329
+ setImmediate(() => {
330
+ completedMessages.push({ id: nextId(), kind: "user", text: line });
331
+ update();
332
+ runAgentTurn(line);
333
+ });
346
334
  }
347
335
  // TurnHooks bridge — updates mutable state, calls update()
348
336
  const tuiHooks = {
@@ -387,17 +375,21 @@ export async function startInkTui(config, spawner) {
387
375
  return result;
388
376
  },
389
377
  };
378
+ // Phren's past-tense verbs for turn summaries
379
+ const PAST_VERBS = ["Recalled", "Reasoned", "Connected", "Synthesized", "Reflected", "Distilled", "Threaded", "Mapped"];
390
380
  async function runAgentTurn(userInput) {
391
381
  running = true;
392
382
  thinking = true;
383
+ turnAbort = new AbortController();
393
384
  thinkStartTime = Date.now();
394
385
  thinkElapsed = null;
395
386
  streamingText = "";
396
387
  currentToolCalls = [];
397
388
  activeTool = null;
389
+ const pastVerb = PAST_VERBS[Math.floor(Math.random() * PAST_VERBS.length)];
398
390
  update();
399
391
  try {
400
- await runTurn(userInput, session, config, tuiHooks);
392
+ await runTurn(userInput, session, config, { ...tuiHooks, signal: turnAbort?.signal });
401
393
  }
402
394
  catch (err) {
403
395
  const msg = err instanceof Error ? err.message : String(err);
@@ -419,7 +411,7 @@ export async function startInkTui(config, spawner) {
419
411
  currentToolCalls = [];
420
412
  activeTool = null;
421
413
  running = false;
422
- thinkElapsed = elapsed;
414
+ thinkElapsed = `${pastVerb} for ${elapsed}s`;
423
415
  process.stdout.write("\x07"); // terminal bell on completion
424
416
  update();
425
417
  // Clear elapsed indicator after a brief display
@@ -469,14 +461,13 @@ export async function startInkTui(config, spawner) {
469
461
  color: TAB_COLORS[i % TAB_COLORS.length],
470
462
  }));
471
463
  }
472
- // Switch views: clear screen, swap which messages are displayed
464
+ // Switch views: clear screen so <Static> re-renders with fresh IDs
473
465
  let viewSwitchCounter = 0;
474
466
  function handleSelectAgent(agentId) {
475
467
  if (agentId === selectedAgentId)
476
468
  return;
477
469
  selectedAgentId = agentId;
478
470
  viewSwitchCounter++;
479
- // Clear screen so Ink's <Static> re-renders with fresh items
480
471
  if (appInstance)
481
472
  appInstance.clear();
482
473
  else
@@ -594,52 +585,11 @@ export async function startInkTui(config, spawner) {
594
585
  process.title = "phren";
595
586
  process.stdout.write(`\x1b]0;phren \xb7 ${projectName}\x07`); // set terminal window title
596
587
  // Initial render
597
- const app = render(_jsx(App, { state: getAppState(), completedMessages: [], streamingText: "", completedToolCalls: [], activeTool: null, thinking: false, thinkStartTime: 0, thinkElapsed: null, steerQueue: [], running: false, showBanner: true, inputHistory: [], verbose: verbose, theme: theme, onSubmit: handleSubmit, onPermissionCycle: handlePermissionCycle, onCancelTurn: handleCancelTurn, onExit: handleExit, agents: undefined, selectedAgentId: undefined, onCancelAgent: handleCancelAgent, onSelectAgent: handleSelectAgent }), { exitOnCtrlC: false, incrementalRendering: true, maxFps: 30 });
588
+ const app = render(_jsx(App, { state: getAppState(), completedMessages: [], streamingText: "", completedToolCalls: [], activeTool: null, thinking: false, thinkStartTime: 0, thinkElapsed: null, steerQueue: [], running: false, showBanner: true, inputHistory: [], verbose: verbose, theme: theme, onSubmit: handleSubmit, onPermissionCycle: handlePermissionCycle, onCancelTurn: handleCancelTurn, onExit: handleExit, agents: undefined, selectedAgentId: undefined, onCancelAgent: handleCancelAgent, onSelectAgent: handleSelectAgent }), { exitOnCtrlC: false });
598
589
  rerender = app.rerender;
599
590
  appInstance = app;
600
- terminalControl.enable(process.stdout);
601
- enableMouse(process.stdout);
602
- // Mouse event handling — raw stdin listener catches SGR mouse events that
603
- // Ink doesn't parse, enabling click-to-focus on agent tabs.
604
- mouseHandler = (data) => {
605
- const str = data.toString();
606
- const evt = parseMouseEvent(str);
607
- if (!evt || evt.type !== "press" || evt.button !== "left")
608
- return;
609
- // Check if click is in the agent tab row (row above the fixed status bar)
610
- const rows = process.stdout.rows || 24;
611
- const tabRow = rows - 1;
612
- if (evt.y === tabRow && agentTabs.length > 0) {
613
- // Determine which tab was clicked based on x position.
614
- // Tab layout mirrors what InputArea renders: "phren● name● ..."
615
- let xPos = 2; // initial padding offset
616
- // First slot is always the "phren" (main) tab
617
- const mainTabWidth = "phren●".length + 2;
618
- if (evt.x >= xPos && evt.x < xPos + mainTabWidth) {
619
- handleSelectAgent(null);
620
- return;
621
- }
622
- xPos += mainTabWidth;
623
- for (const tab of agentTabs) {
624
- const tabWidth = tab.name.length + 3; // "name● "
625
- if (evt.x >= xPos && evt.x < xPos + tabWidth) {
626
- handleSelectAgent(tab.id);
627
- return;
628
- }
629
- xPos += tabWidth;
630
- }
631
- }
632
- };
633
- if (process.stdin.isTTY) {
634
- process.stdin.on("data", mouseHandler);
635
- }
636
591
  const done = new Promise((r) => { resolveSession = r; });
637
592
  app.waitUntilExit().then(() => {
638
- disableMouse(process.stdout);
639
- if (process.stdin.isTTY) {
640
- process.stdin.off("data", mouseHandler);
641
- }
642
- terminalControl.disable(process.stdout);
643
593
  if (resolveSession)
644
594
  resolveSession(session);
645
595
  });
@@ -41,9 +41,9 @@ export const DARK_THEME = {
41
41
  },
42
42
  permission: {
43
43
  suggest: "cyan",
44
- auto: "green",
44
+ auto: "blue",
45
45
  plan: "magenta",
46
- fullAuto: "yellow",
46
+ fullAuto: "green",
47
47
  },
48
48
  markdown: {
49
49
  heading: `${ESC}1m${ESC}36m`, // bold cyan
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/agent",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Coding agent with persistent memory — powered by phren",
5
5
  "type": "module",
6
6
  "bin": {