@denizokcu/haze 0.1.1 → 0.3.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.3.0 - 2026-06-10
6
+
7
+ - Redesigned docs site with cleaner layout, improved typography, better mobile responsiveness, scroll-reveal animations, skip-link accessibility, and refreshed content structure.
8
+ - Moved the task bar above the activity spinner so in-progress and pending tasks are visible during active agent turns.
9
+ - Tasks are now automatically cleared when starting or exiting a session, preventing stale task state across sessions.
10
+ - Renamed internal `TaskBar` component to `TaskBarContent` for clarity.
11
+
12
+ ## 0.2.0 - 2026-06-07
13
+
14
+ - Improved coding-loop reliability with stronger continuation behavior after failed edits, failed validation, missing validation, tool-budget interruptions, and incomplete assistant responses.
15
+ - Added structured bash command classification for read-only, mutating, destructive, network, validation, and unknown commands, with cwd, duration, timeout, and classification metadata in bash results.
16
+ - Added validation-output parsing for common test, typecheck, lint, and build commands, including failed files, failed tests, diagnostics, summaries, and suggested next steps.
17
+ - Added shared structured tool result types and more specific file-edit failure reason codes so edit recovery can reread the affected file and retry with better guidance.
18
+ - Reworked the system prompt, subagent prompt, compaction prompt, and generated-skill guidance around autonomous expert developer workflows with concise final status reporting.
19
+ - Removed hard-coded `temperature: 0` from model calls so providers/models that reject temperature options can run without warning workarounds.
20
+ - Removed bash confirmation gates, including for destructive classifications; Haze now assumes expert users know what they asked for and relies on transparent tool output rather than permission prompts.
21
+ - Improved chat input editing with wrapped multi-line display, vertical cursor movement across wrapped lines, and better cursor mapping for compacted paste blocks.
22
+ - Added and updated tests for bash classification, bash execution behavior, validation parsing, edit recovery, system-prompt guidance, and skill generation.
23
+
5
24
  ## 0.1.1 - 2026-06-07
6
25
 
7
26
  - Bundled ripgrep with `@vscode/ripgrep` and updated the `grep` tool to use the package-provided binary path, removing the requirement for users to install `rg` separately or expose it on `PATH`.
package/README.md CHANGED
@@ -2,16 +2,21 @@
2
2
 
3
3
  A minimal LLM harness for your terminal.
4
4
 
5
- ## What's new in 0.1.0
5
+ ## What's new in 0.3.0
6
6
 
7
- Haze 0.1.0 is the foundation release: the agent can now *find*, *delegate*, and *show its work* without turning your terminal into soup.
7
+ Haze 0.3.0 polishes the experience around sessions and the docs site.
8
8
 
9
- - `grep` gives the model fast, targeted codebase search with regex, globs, context lines, and `.gitignore` awareness — no more brute-force file spelunking.
10
- - Subagents let Haze fan out independent investigations into fresh contexts, then fold the result back into the main turn as a concise summary.
11
- - File edits now render compact, colorized inline diffs with one context line around the change; big diffs stay summarized so signal beats scrollback.
12
- - Long-turn handling is calmer: truncated model output and tool-heavy loops recover more gracefully.
9
+ - The docs site has been redesigned with a cleaner layout, improved typography, better mobile responsiveness, scroll-reveal animations, and accessibility improvements.
10
+ - The task bar now appears above the activity spinner so in-progress and pending tasks are always visible during active agent turns.
11
+ - Tasks are automatically cleared when starting or exiting a session, preventing stale task state from leaking across conversations.
13
12
 
14
- The result is a more capable agent loop while keeping the core small and inspectable. Haze gives an AI model transparent local tools — read, search, edit, write, list, and run commands — plus focused delegation when work can split safely. Tiny spell, sharper goblin.
13
+ Previous releases:
14
+
15
+ - **0.2.0** — Reliability release: stronger continuation after failed edits and validation, structured bash classification, parsed validation summaries, multi-line chat input with vertical cursor movement.
16
+ - **0.1.0** — Bundled ripgrep, subagent delegation, inline diff display.
17
+ - **0.0.3** — Durable sessions, context compaction, provider management.
18
+ - **0.0.2** — Markdown skills, autocomplete, listFiles pagination.
19
+ - **0.0.1** — Initial release.
15
20
 
16
21
  Haze works with OpenAI-compatible providers, including OpenRouter and local endpoints. Use `/provider` to choose or add one, then `/model` to select a model.
17
22
 
@@ -24,7 +29,7 @@ Haze works with OpenAI-compatible providers, including OpenRouter and local endp
24
29
  |_| |_|\__,_/___\___|
25
30
  ```
26
31
 
27
- Haze keeps guardrails light. The LLM can work from the terminal with freedoms close to yours, while trying to stay scoped to the current project. Watch the tool calls. Keep your hands near the wheel. Progress.
32
+ Haze keeps guardrails light. The LLM can work from the terminal with freedoms close to yours, while trying to stay scoped to the current project. It is aimed at developers who want an expert-oriented tool, not a permission dialog factory. Watch the tool calls. Keep your hands near the wheel. Progress.
28
33
 
29
34
  ## Getting started
30
35
 
@@ -77,7 +82,7 @@ Open a project and ask for work:
77
82
  create a calculator in calc-app in ruby with add subtract multiply divide
78
83
  ```
79
84
 
80
- Haze will inspect, search, write files, run commands, and show compact tool activity inline. Small file edits include a colorized line diff with one context line before and after the change; large diffs stay summarized so the transcript does not become a wall of noise. Sessions are saved by default so you can resume the latest workspace conversation with `haze --continue` or `/resume`.
85
+ Haze will inspect, search, write files, run commands, and show compact tool activity inline. Small file edits include a colorized line diff with one context line before and after the change; large diffs stay summarized so the transcript does not become a wall of noise. Bash validation output is summarized when possible so failures point at the relevant files, tests, or diagnostics. Sessions are saved by default so you can resume the latest workspace conversation with `haze --continue` or `/resume`.
81
86
 
82
87
  Use `/` to discover commands and skills. `Tab` completes the top suggestion.
83
88
 
@@ -194,10 +199,10 @@ Haze exposes a deliberately small toolset:
194
199
  - `editFile` — unique text replacements, with line-number-prefix tolerance for common model mistakes.
195
200
  - `replaceLines` — line-range edits when exact replacements are awkward; slightly-too-large EOF ranges are clamped.
196
201
  - `writeFile` — create files and parent directories.
197
- - `bash` — run tests, builds, git commands, and inspections.
202
+ - `bash` — run tests, builds, git commands, inspections, scripts, installs, and other shell workflows with command classification metadata.
198
203
  - `skill_*` — load Markdown skill instructions on demand.
199
204
 
200
- Tool calls are grouped in the transcript so you can see what happened without reading a novella. Successful targeted file edits show a compact diff with colored additions/removals and one context line around the change when the diff is small; larger diffs are summarized with a pointer to `git diff`. File-tool failures return structured recovery hints instead of mystery stack traces.
205
+ Tool calls are grouped in the transcript so you can see what happened without reading a novella. Successful targeted file edits show a compact diff with colored additions/removals and one context line around the change when the diff is small; larger diffs are summarized with a pointer to `git diff`. File-tool failures return structured reason codes and recovery hints instead of mystery stack traces. Bash validation commands can return parsed summaries with failed files, failed tests, diagnostics, and suggested next steps.
201
206
 
202
207
  ## Subagents
203
208
 
@@ -223,8 +228,8 @@ Use `AGENTS.md` for project conventions, commands, architecture notes, and thing
223
228
  - File tools are restricted to the current workspace.
224
229
  - File tools follow `.gitignore` by default.
225
230
  - Ignored files require an explicit override.
226
- - Bash mutations are discouraged by the tool contract.
227
- - Destructive actions should require explicit user confirmation.
231
+ - Bash commands are classified and shown with working-directory metadata, but Haze does not use command confirmation gates.
232
+ - Mutating and destructive commands can run when they are relevant to the user's request; this is intentional for expert users.
228
233
  - Haze is powerful enough to help and dumb enough to deserve supervision. Ideal software, basically.
229
234
 
230
235
  ## Local development
@@ -1,4 +1,4 @@
1
- export type Mode = 'chat' | 'provider' | 'providerAction' | 'model' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels';
1
+ export type Mode = 'chat' | 'provider' | 'providerAction' | 'model' | 'providerAddPreset' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels' | 'providerSetKey' | 'providerRemoveModels' | 'providerConfirmRemove';
2
2
  interface ChatOptions {
3
3
  debug?: boolean;
4
4
  version?: string;
@@ -6,6 +6,7 @@ import { Box, render, Static, Text, useApp, useStdout } from 'ink';
6
6
  import Spinner from 'ink-spinner';
7
7
  import { readContextFiles } from '../../config/contextFiles.js';
8
8
  import { addInputHistoryItem, readInputHistory } from '../../config/inputHistory.js';
9
+ import { loadTasks as loadTasksFromStore, clearTasks as clearTasksFromStore } from '../../core/tasks/taskStorage.js';
9
10
  import { readSettings, updateSettings } from '../../config/settings.js';
10
11
  import { activeModel, configuredProviders, DEFAULT_PROVIDER_NAME, findProvider, modelSelector, providerHasKey, resolveModelSelector, upsertProvider } from '../../config/providers.js';
11
12
  import { Header } from '../../ui/components/Header.js';
@@ -14,7 +15,9 @@ import { MarkdownText } from '../../ui/components/MarkdownText.js';
14
15
  import { theme } from '../../ui/theme.js';
15
16
  import { handleSlashCommand } from './commands.js';
16
17
  import { runAgentTurn } from './streaming.js';
18
+ import { formatElapsedTime, formatElapsedTimeWhole } from './formatters.js';
17
19
  import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
20
+ import { PROVIDER_PRESETS, findPreset } from '../../config/providerPresets.js';
18
21
  import { appendSessionEntry, createSession, formatSession, latestSession, restoreConversation } from '../../core/session/sessionStore.js';
19
22
  import { compactModelMessages, modelMessageText } from '../../core/agent/compaction.js';
20
23
  import { createSessionGoal, formatGoalStatus } from '../../core/goal/sessionGoal.js';
@@ -49,11 +52,6 @@ function formatTokenCount(tokens) {
49
52
  return `${(tokens / 1_000).toFixed(tokens >= 10_000 ? 0 : 1).replace(/\.0$/, '')}k`;
50
53
  return String(tokens);
51
54
  }
52
- function truncateWithEllipsis(text, maxLength) {
53
- if (text.length <= maxLength)
54
- return text;
55
- return `${text.slice(0, maxLength).trimEnd()}…`;
56
- }
57
55
  function displayMessagesFromConversation(conversation) {
58
56
  return conversation.flatMap(message => {
59
57
  if (message.role !== 'user' && message.role !== 'assistant')
@@ -100,18 +98,27 @@ function ToolMessageText({ text, streaming }) {
100
98
  }
101
99
  const row = /^(\s*)([✓✗…])\s+(\S+)(.*)$/.exec(line);
102
100
  if (!row) {
103
- return _jsxs(Text, { color: theme.muted, children: [index === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null, line] }, `${index}-${line}`);
101
+ const timer = /(.*) (\([0-9]+(?:h [0-9]+m [0-9]+(?:\.[0-9])?s|m [0-9]+(?:\.[0-9])?s|(?:\.[0-9])?s)\))$/.exec(line);
102
+ return _jsxs(Text, { color: theme.muted, children: [index === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null, timer ? timer[1] : line, timer ? _jsxs(Text, { color: theme.muted, bold: false, children: [" ", timer[2]] }) : null] }, `${index}-${line}`);
104
103
  }
105
104
  const [, indent, icon, toolName, rest] = row;
106
105
  const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
107
- return _jsxs(Text, { color: theme.muted, children: [indent, _jsx(Text, { color: iconColor, children: icon }), " ", _jsx(Text, { color: theme.purple, children: toolName }), rest] }, `${index}-${line}`);
106
+ const timer = /(.*) (\([0-9]+(?:h [0-9]+m [0-9]+(?:\.[0-9])?s|m [0-9]+(?:\.[0-9])?s|(?:\.[0-9])?s)\))$/.exec(rest);
107
+ return _jsxs(Text, { color: theme.muted, children: [indent, _jsx(Text, { color: iconColor, children: icon }), " ", _jsx(Text, { color: theme.purple, children: toolName }), timer ? timer[1] : rest, timer ? _jsxs(Text, { color: theme.muted, bold: false, children: [" ", timer[2]] }) : null] }, `${index}-${line}`);
108
108
  }) });
109
109
  }
110
+ function messageElapsedLabel(message) {
111
+ if (message.startedAt == null)
112
+ return '';
113
+ const end = message.finishedAt ?? (message.streaming ? Date.now() : message.startedAt);
114
+ const elapsed = end - message.startedAt;
115
+ return message.streaming ? formatElapsedTimeWhole(elapsed) : formatElapsedTime(elapsed);
116
+ }
110
117
  function MessageView({ message, width }) {
111
118
  if (message.role === 'user') {
112
119
  return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { backgroundColor: theme.quoteBg, children: fullWidthBlankLine(width) }), _jsx(Text, { color: theme.success, bold: true, backgroundColor: theme.quoteBg, children: ' You asked'.padEnd(width) }), fullWidthLines(message.text, width, 2).map((line, lineIndex) => _jsx(Text, { color: "white", backgroundColor: theme.quoteBg, children: line }, lineIndex)), _jsx(Text, { backgroundColor: theme.quoteBg, children: fullWidthBlankLine(width) })] });
113
120
  }
114
- return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: message.role === 'assistant' ? theme.purple : message.role === 'tool' ? theme.blue : theme.muted, bold: true, children: message.role === 'assistant' ? 'haze' : message.role === 'tool' ? 'Tool' : 'Info' }), message.role === 'tool'
121
+ return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: message.role === 'assistant' ? theme.purple : message.role === 'tool' ? theme.blue : theme.muted, bold: true, children: message.role === 'assistant' ? 'haze' : message.role === 'tool' ? 'Tool' : 'Info' }), messageElapsedLabel(message) ? _jsxs(Text, { color: theme.muted, bold: false, children: [" \u00B7 ", messageElapsedLabel(message)] }) : null] }), message.role === 'tool'
115
122
  ? _jsx(ToolMessageText, { text: message.text, streaming: message.streaming })
116
123
  : message.role === 'assistant' && !message.streaming
117
124
  ? _jsx(MarkdownText, { content: message.text })
@@ -137,6 +144,43 @@ function startupProviderInfo(settings) {
137
144
  `- Configured providers: ${configuredProviders(settings).length}`,
138
145
  ].join('\n');
139
146
  }
147
+ const TASK_STATUS_ICON = {
148
+ pending: '\u25CB',
149
+ in_progress: '\u25D0',
150
+ completed: '\u2713',
151
+ };
152
+ function taskStatusColor(status) {
153
+ switch (status) {
154
+ case 'completed': return theme.success;
155
+ case 'in_progress': return theme.warning;
156
+ default: return theme.muted;
157
+ }
158
+ }
159
+ const MAX_VISIBLE_TASKS = 5;
160
+ function TaskBarContent({ tasks, width, expanded, padding }) {
161
+ const maxTitleWidth = Math.max(10, width - 6);
162
+ const inProgress = tasks.filter(t => t.status === 'in_progress');
163
+ const pending = tasks.filter(t => t.status === 'pending');
164
+ const completed = tasks.filter(t => t.status === 'completed');
165
+ const limit = expanded ? tasks.length : MAX_VISIBLE_TASKS;
166
+ const ordered = [];
167
+ for (const t of inProgress) {
168
+ if (ordered.length < limit)
169
+ ordered.push(t);
170
+ }
171
+ for (const t of pending) {
172
+ if (ordered.length < limit)
173
+ ordered.push(t);
174
+ }
175
+ for (let i = completed.length - 1; i >= 0 && ordered.length < limit; i--) {
176
+ ordered.push(completed[i]);
177
+ }
178
+ const counts = `${inProgress.length > 0 ? `${inProgress.length} active` : ''}${pending.length > 0 ? `${inProgress.length > 0 ? ', ' : ''}${pending.length} pending` : ''}${completed.length > 0 ? `${inProgress.length + pending.length > 0 ? ', ' : ''}${completed.length} done` : ''}`;
179
+ return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [padding > 0 && Array.from({ length: padding }, (_, i) => _jsx(Text, { children: ' ' }, `pad-${i}`)), _jsxs(Text, { children: [_jsx(Text, { color: theme.purple, bold: true, children: "Tasks" }), counts ? _jsxs(Text, { color: theme.muted, children: [" (", counts, ")"] }) : null, tasks.length > MAX_VISIBLE_TASKS ? _jsxs(Text, { color: theme.muted, dimColor: true, children: [" \u00B7 ctrl+o ", expanded ? 'collapse' : 'expand'] }) : null] }), ordered.map(task => {
180
+ const title = task.title.length > maxTitleWidth ? task.title.slice(0, maxTitleWidth - 1) + '\u2026' : task.title;
181
+ return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: taskStatusColor(task.status), children: [TASK_STATUS_ICON[task.status], " "] }), _jsx(Text, { color: task.status === 'completed' ? theme.muted : 'white', children: title })] }, task.id));
182
+ })] }));
183
+ }
140
184
  function ChatScreen({ debug = false, version, continueSession = false, noSession = false }) {
141
185
  const { exit } = useApp();
142
186
  const { stdout } = useStdout();
@@ -166,13 +210,22 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
166
210
  const [busy, setBusy] = useState(false);
167
211
  const [busyLabel, setBusyLabel] = useState('Haze is thinking');
168
212
  const [activeGoalStatus, setActiveGoalStatus] = useState();
169
- const [sessionLabel, setSessionLabel] = useState();
213
+ const [visibleTasks, setVisibleTasks] = useState([]);
214
+ const [tasksExpanded, setTasksExpanded] = useState(false);
215
+ const [taskBarPadding, setTaskBarPadding] = useState(0);
216
+ const [, setSessionLabel] = useState();
217
+ const [llmTokenEstimate, setLlmTokenEstimate] = useState({ input: 0, output: 0 });
218
+ const [, setTimerTick] = useState(0);
170
219
  const [queuedFollowUps, setQueuedFollowUps] = useState([]);
171
220
  const [skills, setSkills] = useState([]);
172
221
  const [branchName, setBranchName] = useState();
173
222
  const [modelProviderFilter, setModelProviderFilter] = useState();
174
223
  const [selectedProviderName, setSelectedProviderName] = useState();
175
224
  const [providerDraft, setProviderDraft] = useState({});
225
+ useEffect(() => {
226
+ const timer = setInterval(() => setTimerTick(tick => tick + 1), 1000);
227
+ return () => clearInterval(timer);
228
+ }, []);
176
229
  useEffect(() => {
177
230
  Promise.all([readSettings(), currentBranchName()]).then(([next, branch]) => {
178
231
  setSettings(next);
@@ -193,6 +246,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
193
246
  readInputHistory().then(setInputHistory).catch(() => undefined);
194
247
  readContextFiles().then(setContextFiles).catch(() => undefined);
195
248
  refreshSkills().catch(() => undefined);
249
+ loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
196
250
  const branchTimer = setInterval(() => {
197
251
  currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
198
252
  }, 3000);
@@ -229,6 +283,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
229
283
  }
230
284
  const session = await createSession({ hazeVersion: version });
231
285
  sessionRef.current = session;
286
+ setLlmTokenEstimate({ input: 0, output: 0 });
232
287
  setSessionLabel(session.id);
233
288
  setMessages(m => [...m, { role: 'system', text: `${message}\nSession saved: ${session.file}` }]);
234
289
  }
@@ -245,7 +300,9 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
245
300
  conversationRef.current = conversation;
246
301
  setSessionLabel(session.id);
247
302
  setLiveMessagesState(() => []);
248
- setMessages(m => [...m, { role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...displayMessagesFromConversation(conversation)]);
303
+ const restoredMessages = displayMessagesFromConversation(conversation);
304
+ setLlmTokenEstimate(estimateConversationTokens(restoredMessages));
305
+ setMessages(m => [...m, { role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...restoredMessages]);
249
306
  return;
250
307
  }
251
308
  }
@@ -254,6 +311,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
254
311
  function clearConversation() {
255
312
  conversationRef.current = [];
256
313
  lastAssistantTextRef.current = '';
314
+ setLlmTokenEstimate({ input: 0, output: 0 });
257
315
  setLiveMessagesState(() => []);
258
316
  setMessages([{ role: 'system', text: 'Cleared. The void is productive.' }]);
259
317
  const session = sessionRef.current;
@@ -308,10 +366,11 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
308
366
  setMessages(m => [...m, { role: 'system', text: `Queued follow-up (${followUpQueueRef.current.length}): ${trimmed}` }]);
309
367
  }
310
368
  function closeInputList() {
311
- if (mode === 'provider' || mode === 'providerAction' || mode === 'model') {
369
+ if (mode !== 'chat') {
312
370
  setMode('chat');
313
371
  setModelProviderFilter(undefined);
314
372
  setSelectedProviderName(undefined);
373
+ setProviderDraft({});
315
374
  }
316
375
  }
317
376
  function providerSuggestions() {
@@ -321,13 +380,34 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
321
380
  description: `${provider.url} · ${provider.models.length} model${provider.models.length === 1 ? '' : 's'}`,
322
381
  kind: 'provider',
323
382
  })),
324
- { value: 'add provider', description: 'Add a new OpenAI-compatible provider', kind: 'provider' },
383
+ { value: 'add provider', description: 'Add a new provider (presets available)', kind: 'provider' },
325
384
  ];
326
385
  }
327
386
  function providerActionSuggestions() {
387
+ const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
328
388
  return [
329
389
  { value: 'use provider', description: 'Set this provider and choose a model', kind: 'provider' },
330
- { value: 'add models', description: 'Append comma-separated model names to this provider', kind: 'provider' },
390
+ { value: 'add models', description: 'Append comma-separated model names', kind: 'provider' },
391
+ { value: 'set API key', description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' },
392
+ ...(provider?.models?.length ? [{ value: 'remove models', description: 'Remove models from this provider', kind: 'provider' }] : []),
393
+ { value: 'remove provider', description: 'Delete this provider from settings', kind: 'provider' },
394
+ ];
395
+ }
396
+ function presetSuggestions() {
397
+ const cloudPresets = PROVIDER_PRESETS.filter(p => p.category === 'cloud');
398
+ const localPresets = PROVIDER_PRESETS.filter(p => p.category === 'local');
399
+ return [
400
+ ...cloudPresets.map(preset => ({
401
+ value: preset.id,
402
+ description: `${preset.baseUrl}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
403
+ kind: 'provider',
404
+ })),
405
+ ...localPresets.map(preset => ({
406
+ value: preset.id,
407
+ description: `${preset.baseUrl} · local, no API key needed`,
408
+ kind: 'provider',
409
+ })),
410
+ { value: 'custom', description: 'Enter provider name, URL, and API key manually', kind: 'provider' },
331
411
  ];
332
412
  }
333
413
  function modelSuggestions() {
@@ -341,8 +421,8 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
341
421
  async function selectProvider(providerName) {
342
422
  if (providerName === 'add provider') {
343
423
  setProviderDraft({});
344
- setMode('providerAddName');
345
- setMessages(m => [...m, { role: 'system', text: 'Provider name? Example: openrouter, local, lmstudio.' }]);
424
+ setMode('providerAddPreset');
425
+ setMessages(m => [...m, { role: 'system', text: 'Choose a provider preset, or select "custom" to enter details manually.' }]);
346
426
  return;
347
427
  }
348
428
  const provider = findProvider(settings, providerName);
@@ -355,6 +435,39 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
355
435
  setMode('providerAction');
356
436
  setMessages(m => [...m, { role: 'system', text: `${provider.name}: choose an action.` }]);
357
437
  }
438
+ async function selectPreset(presetId) {
439
+ if (presetId === 'custom') {
440
+ setProviderDraft({});
441
+ setMode('providerAddName');
442
+ setMessages(m => [...m, { role: 'system', text: 'Provider name? Example: openrouter, local, lmstudio.' }]);
443
+ return;
444
+ }
445
+ const preset = findPreset(presetId);
446
+ if (!preset) {
447
+ setMessages(m => [...m, { role: 'system', text: `Unknown preset: ${presetId}.` }]);
448
+ return;
449
+ }
450
+ // Check if a provider with this name already exists
451
+ const existingName = settings.providers?.some(p => p.name === preset.name) ? preset.id : preset.name;
452
+ const nameConflict = settings.providers?.some(p => p.name === existingName);
453
+ if (nameConflict) {
454
+ setMessages(m => [...m, { role: 'system', text: `Provider ${existingName} already exists. Use /provider to manage existing providers.` }]);
455
+ setMode('chat');
456
+ setProviderDraft({});
457
+ return;
458
+ }
459
+ setProviderDraft({ name: existingName, url: preset.baseUrl });
460
+ if (preset.needsApiKey) {
461
+ setMode('providerAddKey');
462
+ setMessages(m => [...m, { role: 'system', text: `${preset.name} (${preset.baseUrl})\nAPI key${preset.apiKeyHint ? ` (${preset.apiKeyHint})` : ''}?` }]);
463
+ }
464
+ else {
465
+ // Local/keyless: skip API key, go straight to models
466
+ setMode('providerAddModels');
467
+ const hint = preset.suggestedModels?.length ? ` Example: ${preset.suggestedModels.join(', ')}` : '';
468
+ setMessages(m => [...m, { role: 'system', text: `${preset.name} (${preset.baseUrl}) — no API key needed.\nComma-separated model names?${hint}` }]);
469
+ }
470
+ }
358
471
  async function useProvider(providerName) {
359
472
  const provider = findProvider(settings, providerName);
360
473
  if (!provider) {
@@ -375,6 +488,13 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
375
488
  setMode('provider');
376
489
  return;
377
490
  }
491
+ const provider = findProvider(settings, selectedProviderName);
492
+ if (!provider) {
493
+ setMessages(m => [...m, { role: 'system', text: `Provider ${selectedProviderName} not found.` }]);
494
+ setMode('chat');
495
+ setSelectedProviderName(undefined);
496
+ return;
497
+ }
378
498
  if (action === 'use provider') {
379
499
  await useProvider(selectedProviderName);
380
500
  return;
@@ -384,6 +504,21 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
384
504
  setMessages(m => [...m, { role: 'system', text: `Comma-separated model names to add to ${selectedProviderName}?` }]);
385
505
  return;
386
506
  }
507
+ if (action === 'set API key') {
508
+ setMode('providerSetKey');
509
+ setMessages(m => [...m, { role: 'system', text: `New API key for ${selectedProviderName}? (current: ${provider.key ? 'saved' : 'not set'})` }]);
510
+ return;
511
+ }
512
+ if (action === 'remove models') {
513
+ setMode('providerRemoveModels');
514
+ setMessages(m => [...m, { role: 'system', text: `Comma-separated model names to remove from ${selectedProviderName}?\nCurrent models: ${provider.models.join(', ')}` }]);
515
+ return;
516
+ }
517
+ if (action === 'remove provider') {
518
+ setMode('providerConfirmRemove');
519
+ setMessages(m => [...m, { role: 'system', text: `Remove provider ${selectedProviderName}? Type "yes" to confirm. Esc to cancel.` }]);
520
+ return;
521
+ }
387
522
  setMessages(m => [...m, { role: 'system', text: `Unknown provider action: ${action}` }]);
388
523
  }
389
524
  async function selectModel(selector) {
@@ -458,6 +593,10 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
458
593
  await selectProviderAction(value);
459
594
  return;
460
595
  }
596
+ if (mode === 'providerAddPreset') {
597
+ await selectPreset(value);
598
+ return;
599
+ }
461
600
  if (mode === 'model') {
462
601
  await selectModel(value);
463
602
  return;
@@ -504,6 +643,87 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
504
643
  await appendModelsToProvider(value);
505
644
  return;
506
645
  }
646
+ if (mode === 'providerSetKey') {
647
+ const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
648
+ if (!provider) {
649
+ setMessages(m => [...m, { role: 'system', text: 'No provider selected.' }]);
650
+ setMode('chat');
651
+ return;
652
+ }
653
+ const key = value.trim();
654
+ if (!key) {
655
+ setMessages(m => [...m, { role: 'system', text: 'API key cannot be empty. Esc to cancel.' }]);
656
+ return;
657
+ }
658
+ const updated = { ...provider, key };
659
+ const next = await updateSettings({ providers: upsertProvider(settings, updated) });
660
+ setSettings(next);
661
+ setSelectedProviderName(undefined);
662
+ setMode('chat');
663
+ setMessages(m => [...m, { role: 'system', text: `API key updated for ${provider.name}.` }]);
664
+ return;
665
+ }
666
+ if (mode === 'providerRemoveModels') {
667
+ const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
668
+ if (!provider) {
669
+ setMessages(m => [...m, { role: 'system', text: 'No provider selected.' }]);
670
+ setMode('chat');
671
+ return;
672
+ }
673
+ const toRemove = value.split(',').map(m => m.trim()).filter(Boolean);
674
+ if (toRemove.length === 0) {
675
+ setMessages(m => [...m, { role: 'system', text: 'Enter at least one model name. Esc to cancel.' }]);
676
+ return;
677
+ }
678
+ const remaining = provider.models.filter(m => !toRemove.includes(m));
679
+ if (remaining.length === 0) {
680
+ setMessages(m => [...m, { role: 'system', text: 'A provider must have at least one model. Remove the provider instead.' }]);
681
+ return;
682
+ }
683
+ const removed = provider.models.filter(m => toRemove.includes(m));
684
+ const notFound = toRemove.filter(m => !provider.models.includes(m));
685
+ const updated = { ...provider, models: remaining };
686
+ const wasActive = settings.model && provider.models.includes(settings.model) && !remaining.includes(settings.model);
687
+ const next = await updateSettings({
688
+ providers: upsertProvider(settings, updated),
689
+ ...(wasActive ? { model: remaining[0] } : {}),
690
+ });
691
+ setSettings(next);
692
+ setSelectedProviderName(undefined);
693
+ setMode('chat');
694
+ const parts = [`Removed ${removed.join(', ')} from ${provider.name}.`];
695
+ if (notFound.length)
696
+ parts.push(`Not found: ${notFound.join(', ')}.`);
697
+ if (wasActive)
698
+ parts.push(`Active model updated to ${remaining[0]}.`);
699
+ setMessages(m => [...m, { role: 'system', text: parts.join(' ') }]);
700
+ return;
701
+ }
702
+ if (mode === 'providerConfirmRemove') {
703
+ const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
704
+ if (!provider) {
705
+ setMessages(m => [...m, { role: 'system', text: 'No provider selected.' }]);
706
+ setMode('chat');
707
+ return;
708
+ }
709
+ if (value.trim().toLowerCase() !== 'yes') {
710
+ setMessages(m => [...m, { role: 'system', text: 'Cancelled. Provider not removed.' }]);
711
+ setSelectedProviderName(undefined);
712
+ setMode('chat');
713
+ return;
714
+ }
715
+ const providers = configuredProviders(settings).filter(p => p.name !== selectedProviderName);
716
+ const wasActiveProvider = settings.provider === selectedProviderName || (!settings.provider && configuredProviders(settings)[0]?.name === selectedProviderName);
717
+ const next = await updateSettings({
718
+ providers,
719
+ ...(wasActiveProvider ? { provider: providers[0]?.name, model: providers[0]?.models[0] } : {}),
720
+ });
721
+ setSettings(next);
722
+ setSelectedProviderName(undefined);
723
+ setMode('chat');
724
+ setMessages(m => [...m, { role: 'system', text: `Removed provider ${provider.name}.${wasActiveProvider ? ` Switched to ${providers[0]?.name ?? 'no provider'}.` : ''}` }]);
725
+ return;
726
+ }
507
727
  const invokedSkill = skillInvocation(value);
508
728
  if (invokedSkill) {
509
729
  const argumentText = invokedSkill.args ? `\nUser-provided skill arguments: ${invokedSkill.args}` : '';
@@ -580,6 +800,9 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
580
800
  if (value === '/create-skill' || value.startsWith('/create-skill ') || value === '/skill create' || value.startsWith('/skill create ') || value === '/skills create' || value.startsWith('/skills create ') || value.startsWith('/remove-skill ') || value.startsWith('/skill remove ') || value.startsWith('/skills remove ')) {
581
801
  await refreshSkills().catch(() => undefined);
582
802
  }
803
+ if (value.startsWith('/tasks') || value === '/clear') {
804
+ loadTasksFromStore().then(t => { setVisibleTasks(t); setTaskBarPadding(0); }).catch(() => undefined);
805
+ }
583
806
  return;
584
807
  }
585
808
  await doAgentTurn(value);
@@ -644,11 +867,15 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
644
867
  setAbortController: controller => { abortControllerRef.current = controller; },
645
868
  setGoalStatus: setActiveGoalStatus,
646
869
  compactConversation,
870
+ recordTokenEstimate: tokens => {
871
+ setLlmTokenEstimate(current => ({ input: current.input + tokens.input, output: current.output + tokens.output }));
872
+ },
647
873
  onEvent: event => {
648
874
  const session = sessionRef.current;
649
875
  if (session)
650
876
  void appendSessionEntry(session, { type: 'event', at: event.at, name: event.type, text: JSON.stringify(event) }).catch(() => undefined);
651
877
  },
878
+ onTasksChanged: () => { loadTasksFromStore().then(t => { setVisibleTasks(t); setTaskBarPadding(0); }).catch(() => undefined); },
652
879
  });
653
880
  }
654
881
  const visible = messages.filter(message => !message.hidden);
@@ -659,17 +886,23 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
659
886
  ? 'Choose provider'
660
887
  : mode === 'providerAction'
661
888
  ? 'Choose provider action'
662
- : mode === 'model'
663
- ? 'Choose model'
664
- : mode === 'providerAddName'
665
- ? 'Provider name'
666
- : mode === 'providerAddUrl'
667
- ? 'https://example.com/v1'
668
- : mode === 'providerAddKey'
669
- ? 'API key, or blank for local'
670
- : mode === 'providerAddModels' || mode === 'providerAppendModels'
671
- ? 'model-a, model-b'
672
- : busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask Haze to help build your app';
889
+ : mode === 'providerAddPreset'
890
+ ? 'Choose a provider preset or custom'
891
+ : mode === 'model'
892
+ ? 'Choose model'
893
+ : mode === 'providerAddName'
894
+ ? 'Provider name'
895
+ : mode === 'providerAddUrl'
896
+ ? 'https://example.com/v1'
897
+ : mode === 'providerAddKey' || mode === 'providerSetKey'
898
+ ? 'API key, or blank for local'
899
+ : mode === 'providerAddModels' || mode === 'providerAppendModels'
900
+ ? 'model-a, model-b'
901
+ : mode === 'providerRemoveModels'
902
+ ? 'model-a, model-b'
903
+ : mode === 'providerConfirmRemove'
904
+ ? 'Type "yes" to confirm'
905
+ : busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask Haze to help build your app';
673
906
  const activeModelName = `${activeSelection.provider.name}:${process.env.HAZE_MODEL ?? activeSelection.model}`;
674
907
  const hasLogin = Boolean(process.env.OPENAI_API_KEY ?? settings.apiKey ?? activeSelection.provider.key) || activeSelection.provider.name !== DEFAULT_PROVIDER_NAME;
675
908
  const hasChosenModel = Boolean(process.env.HAZE_MODEL ?? settings.model ?? activeSelection.model);
@@ -689,13 +922,12 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
689
922
  const workspaceLabel = `${process.cwd()}${branchName ? ` (${branchName})` : ''}`;
690
923
  const allDisplayMessages = [...messages, ...liveMessages];
691
924
  const toolsUsed = toolCallCount(allDisplayMessages);
692
- const estimatedTokens = estimateConversationTokens(allDisplayMessages);
693
- const statusDetailLabel = `${conversationRef.current.length} messages / ${toolsUsed} tool call${toolsUsed === 1 ? '' : 's'} / ↑ ~${formatTokenCount(estimatedTokens.input)} ↓ ~${formatTokenCount(estimatedTokens.output)} / ${skills.length} skill${skills.length === 1 ? '' : 's'}${sessionLabel ? ` / ${sessionLabel}` : ''}`;
925
+ const estimatedTokens = llmTokenEstimate.input > 0 || llmTokenEstimate.output > 0 ? llmTokenEstimate : estimateConversationTokens(allDisplayMessages);
926
+ const statusDetailLabel = `${conversationRef.current.length} messages / ${toolsUsed} tool call${toolsUsed === 1 ? '' : 's'} / LLM ↑ ~${formatTokenCount(estimatedTokens.input)} ↓ ~${formatTokenCount(estimatedTokens.output)} / ${skills.length} skill${skills.length === 1 ? '' : 's'}`;
694
927
  const goalText = activeGoalStatus?.replace(/^Goal:\s*/, '');
695
- const [rawGoalRequest, ...goalStatusParts] = goalText?.split(' · ') ?? [];
696
- const goalRequest = truncateWithEllipsis(rawGoalRequest ?? '', 120);
697
- const goalStatusText = goalStatusParts.join(' · ');
698
- const inputSuggestions = mode === 'provider' ? providerSuggestions() : mode === 'providerAction' ? providerActionSuggestions() : mode === 'model' ? modelSuggestions() : mode === 'chat' ? [
928
+ // Goal tracking is internal; display removed in favor of task bar
929
+ void goalText;
930
+ const inputSuggestions = mode === 'provider' ? providerSuggestions() : mode === 'providerAction' ? providerActionSuggestions() : mode === 'providerAddPreset' ? presetSuggestions() : mode === 'model' ? modelSuggestions() : mode === 'chat' ? [
699
931
  { value: '/help', description: 'Show commands', kind: 'command' },
700
932
  { value: '/provider', description: 'Choose a provider', kind: 'command' },
701
933
  { value: '/model', description: 'Choose a model', kind: 'command' },
@@ -721,7 +953,18 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
721
953
  ];
722
954
  return _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: staticItems, children: item => item.kind === 'header'
723
955
  ? _jsx(Header, { subtitle: item.subtitle, version: version }, item.key)
724
- : _jsx(MessageView, { message: item.message, width: width }, item.key) }), activeLiveMessages.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, children: activeLiveMessages.map((message, index) => _jsx(MessageView, { message: message, width: width }, messageKey(message, index))) }), debug && debugLogs.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { color: theme.muted, bold: true, children: "Debug" }), debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, children: ["\u2022 ", line] }, index))] }), queuedFollowUps.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: [_jsx(Text, { color: theme.muted, children: "Queued follow-ups:" }), queuedFollowUps.map((item, index) => _jsxs(Text, { color: theme.muted, dimColor: true, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), busy && _jsx(Box, { flexShrink: 0, marginBottom: 1, children: _jsxs(Text, { children: [_jsxs(Text, { color: theme.orange, bold: true, children: [_jsx(Spinner, { type: "dots" }), " ", busyLabel] }), _jsx(Text, { color: theme.muted, dimColor: true, children: " \u00B7 type to queue follow-up \u00B7 esc to interrupt" })] }) }), goalText && _jsx(Box, { flexShrink: 0, children: _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: theme.blue, bold: true, children: "Goal:" }), _jsxs(Text, { color: "white", children: [" ", goalRequest] }), goalStatusText ? _jsxs(Text, { color: theme.orange, children: [" \u00B7 ", goalStatusText] }) : null] }) }), _jsx(Box, { borderStyle: "round", borderColor: theme.deepPurple, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: mode === 'providerAddKey', historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: mode === 'provider' || mode === 'providerAction' || mode === 'model' ? 'always' : 'slash', submitOnEmpty: mode === 'providerAddKey', onHistoryAdd: persistInputHistory, onCancel: cancelThinking, onEscape: () => {
956
+ : _jsx(MessageView, { message: item.message, width: width }, item.key) }), activeLiveMessages.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, children: activeLiveMessages.map((message, index) => _jsx(MessageView, { message: message, width: width }, messageKey(message, index))) }), debug && debugLogs.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { color: theme.muted, bold: true, children: "Debug" }), debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, children: ["\u2022 ", line] }, index))] }), queuedFollowUps.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: [_jsx(Text, { color: theme.muted, children: "Queued follow-ups:" }), queuedFollowUps.map((item, index) => _jsxs(Text, { color: theme.muted, dimColor: true, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBarContent, { tasks: visibleTasks, width: width, expanded: tasksExpanded, padding: taskBarPadding }) }), busy && _jsx(Box, { flexShrink: 0, children: _jsxs(Text, { children: [_jsxs(Text, { color: theme.orange, bold: true, children: [_jsx(Spinner, { type: "dots" }), " ", busyLabel] }), _jsx(Text, { color: theme.muted, dimColor: true, children: " \u00B7 type to queue follow-up \u00B7 esc to interrupt" })] }) }), _jsx(Box, { borderStyle: "round", borderColor: theme.deepPurple, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: mode === 'providerAddKey' || mode === 'providerSetKey', historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: mode === 'provider' || mode === 'providerAction' || mode === 'providerAddPreset' || mode === 'model' ? 'always' : 'slash', submitOnEmpty: mode === 'providerAddKey', width: Math.max(20, width - 4), onHistoryAdd: persistInputHistory, onToggleTasks: () => {
957
+ if (!tasksExpanded) {
958
+ setTaskBarPadding(0);
959
+ setTasksExpanded(true);
960
+ }
961
+ else {
962
+ const expandedRows = visibleTasks.length + 1;
963
+ const collapsedRows = Math.min(visibleTasks.length, MAX_VISIBLE_TASKS) + 1;
964
+ setTaskBarPadding(Math.max(0, expandedRows - collapsedRows));
965
+ setTasksExpanded(false);
966
+ }
967
+ }, onCancel: cancelThinking, onEscape: () => {
725
968
  if (busy)
726
969
  cancelThinking();
727
970
  else
@@ -732,6 +975,8 @@ export async function chatCommand(options = {}) {
732
975
  if (process.stdout.isTTY) {
733
976
  process.stdout.write('\u001B[2J\u001B[3J\u001B[H');
734
977
  }
978
+ await clearTasksFromStore().catch(() => undefined);
735
979
  const app = render(_jsx(ChatScreen, { debug: options.debug, version: options.version, continueSession: options.continueSession, noSession: options.noSession }));
736
980
  await app.waitUntilExit();
981
+ await clearTasksFromStore().catch(() => undefined);
737
982
  }