@denizokcu/haze 1.0.0 → 1.1.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +12 -7
  3. package/SECURITY.md +3 -1
  4. package/dist/buildInfo.json +3 -3
  5. package/dist/cli/chat/TaskBar.js +1 -1
  6. package/dist/cli/chat/inputSuggestions.js +1 -0
  7. package/dist/cli/chat/messages.js +3 -3
  8. package/dist/cli/chat/wizardDispatch.js +10 -0
  9. package/dist/cli/commands/chat.js +47 -5
  10. package/dist/cli/commands/commandHelp.js +2 -0
  11. package/dist/cli/commands/commands.js +2 -0
  12. package/dist/cli/commands/formatters.js +6 -0
  13. package/dist/cli/commands/settingsSummary.js +2 -0
  14. package/dist/cli/commands/themesCommand.d.ts +17 -0
  15. package/dist/cli/commands/themesCommand.js +24 -0
  16. package/dist/cli/commands/wizardFlow.d.ts +7 -0
  17. package/dist/cli/commands/wizardFlow.js +20 -0
  18. package/dist/config/settings.d.ts +2 -0
  19. package/dist/config/settings.js +1 -0
  20. package/dist/core/safety/secretPaths.d.ts +18 -0
  21. package/dist/core/safety/secretPaths.js +115 -0
  22. package/dist/llm/hazeTools.js +6 -0
  23. package/dist/llm/systemPrompt.js +3 -1
  24. package/dist/llm/toolResultTypes.d.ts +1 -1
  25. package/dist/llm/tools/failures.d.ts +6 -0
  26. package/dist/llm/tools/failures.js +8 -2
  27. package/dist/llm/tools/readRecovery.js +2 -0
  28. package/dist/llm/tools/shellTool.js +3 -0
  29. package/dist/llm/tools/workspaceFile.d.ts +4 -3
  30. package/dist/llm/tools/workspaceFile.js +30 -13
  31. package/dist/ui/components/Header.js +1 -1
  32. package/dist/ui/components/MarkdownText.js +10 -10
  33. package/dist/ui/components/TextInput.d.ts +1 -1
  34. package/dist/ui/components/TextInput.js +2 -2
  35. package/dist/ui/terminalColors.d.ts +29 -0
  36. package/dist/ui/terminalColors.js +47 -0
  37. package/dist/ui/theme.d.ts +105 -10
  38. package/dist/ui/theme.js +126 -15
  39. package/dist/ui/themes/af-magic.d.ts +7 -0
  40. package/dist/ui/themes/af-magic.js +25 -0
  41. package/dist/ui/themes/agnoster.d.ts +10 -0
  42. package/dist/ui/themes/agnoster.js +40 -0
  43. package/dist/ui/themes/bira.d.ts +10 -0
  44. package/dist/ui/themes/bira.js +28 -0
  45. package/dist/ui/themes/bureau.d.ts +10 -0
  46. package/dist/ui/themes/bureau.js +28 -0
  47. package/dist/ui/themes/clean.d.ts +9 -0
  48. package/dist/ui/themes/clean.js +27 -0
  49. package/dist/ui/themes/cloud.d.ts +6 -0
  50. package/dist/ui/themes/cloud.js +24 -0
  51. package/dist/ui/themes/dst.d.ts +10 -0
  52. package/dist/ui/themes/dst.js +28 -0
  53. package/dist/ui/themes/fishy.d.ts +7 -0
  54. package/dist/ui/themes/fishy.js +25 -0
  55. package/dist/ui/themes/index.d.ts +8 -0
  56. package/dist/ui/themes/index.js +36 -0
  57. package/dist/ui/themes/light.d.ts +3 -0
  58. package/dist/ui/themes/light.js +21 -0
  59. package/dist/ui/themes/purple.d.ts +7 -0
  60. package/dist/ui/themes/purple.js +26 -0
  61. package/dist/ui/themes/robbyrussell.d.ts +8 -0
  62. package/dist/ui/themes/robbyrussell.js +26 -0
  63. package/dist/ui/themes/solarized-dark.d.ts +16 -0
  64. package/dist/ui/themes/solarized-dark.js +44 -0
  65. package/dist/ui/themes/solarized-light.d.ts +12 -0
  66. package/dist/ui/themes/solarized-light.js +40 -0
  67. package/dist/ui/themes/steeef.d.ts +11 -0
  68. package/dist/ui/themes/steeef.js +29 -0
  69. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 - 2026-08-19
4
+
5
+ Theming and secrets. Two user-facing layers landed in this release: a full terminal theme system (14 built-in palettes, live switching, terminal-default adoption) and hard secret-file protection across every file tool.
6
+
7
+ ### Added
8
+
9
+ - Terminal theming: `src/ui/theme.ts` is the shared palette singleton (semantic roles — accent, command, muted, success/danger pairs, surface backgrounds — resolved through the oh-my-zsh/zsh color vocabulary of zsh names, xterm-256 indices, or `#rrggbb` hex), and `src/ui/themes/` is a one-file-per-theme registry keyed by settings name, seeded with the default `purple` and `light` palettes plus oh-my-zsh ports (`robbyrussell`, `af-magic`, `agnoster`, `bira`, `bureau`, `clean`, `cloud`, `dst`, `fishy`, `solarized-dark`, `solarized-light`, `steeef`). Themes own both terminal defaults: haze adopts the theme's foreground and background via OSC 10/11 at startup and restores them (OSC 110/111) on exit, so light palettes never paint a light canvas under dark-default text. A `theme` key in `~/.haze/settings.json` selects the palette (validated loudly at startup with the valid names listed), and the new `/themes` command switches it: the picker labels each theme light/dark and marks the active one, `/themes <name>` sets one directly, and switching applies live without a restart — already-printed transcript text keeps its old colors (Ink `<Static>` stays as-rendered), which is accepted behavior. `docs/theming-plan.md` documents the research, the role table, and the conversion guides for porting oh-my-zsh, VS Code, and Sublime themes.
10
+
11
+ - Hard secret-file protection in every file tool: SSH keys (`~/.ssh/**`, `id_*` private keys), shell history files, `.env`/`.envrc` files (excluding `.example`/`.sample`/`.template` documentation variants), `*.pem`/`*.key`, `secrets.{json,yaml,yml,toml}`, and common home credential stores (`~/.aws`, `~/.gnupg`, `~/.netrc`, `~/.git-credentials`, and others; see `src/core/safety/secretPaths.ts`) are refused for reads *and* mutations before any filesystem access. The check covers lexical and real paths (symlink-proof in both directions), wins over user-typed `@path` read blessings and `allowIgnored`, and grep traversal excludes the protected names with negated-only globs appended after any model-supplied glob (a later ripgrep glob takes precedence, so an explicit glob cannot re-include secrets; positive re-include globs would whitelist the search, which is why documentation variants are excluded from traversal but stay readable via targeted `readFile`). Refusals are terminal structured results (`secret_file_protected`, `recoverable: false`, ask-the-user next step, no content echoed) so models do not burn steps retrying, and the transcript shows them as `blocked: protected secret file (path)`, distinct from ordinary failures. The `shell` tool is deliberately not command-filtered: secret avoidance in shell is instructed through the system prompt (`SECRET_FILE_RULE`), aligned with the file-tool refusal wording.
12
+
3
13
  ## 1.0.0 - 2026-08-16
4
14
 
5
15
  The first stable release. The CLI flags, settings schema, `stream-json` event contract, session format, skill layout, and structured tool-result shape are now covered by the 1.x compatibility promise: breaking changes to them require a new major version.
package/README.md CHANGED
@@ -2,17 +2,16 @@
2
2
 
3
3
  A minimal LLM harness for your terminal.
4
4
 
5
- ## What's new in 1.0.0
5
+ ## What's new in 1.1.0
6
6
 
7
- haze 1.0.0 is the first stable release: the CLI flags, settings schema, `stream-json` event contract, session format, skill layout, and structured tool-result shape are now covered by the 1.x compatibility promise. It also lands a configurable model-retry pool and the four benchmark-driven reliability fixes below.
7
+ haze 1.1.0 adds a terminal theme system and hard secret-file protection.
8
8
 
9
- - Configurable model-retry pool: the `modelRetries` setting (integer 0–10, default 2) sizes the shared bounded pool that retries transient model errors and idle-stream stalls. Raise it for providers that terminate long streams aggressively; `0` disables automatic retries (stalls pause with the goal preserved for a one-key resume). The effective pool size is visible in `timeout`/`retry` stream events (`maxRetries`) and stall diagnostics.
10
- - Benchmark-hardened completion evidence (found by the csv-query differential benchmark — same model across four harnesses isolates the harness): `writeFile` chunking guidance can no longer be shadowed by schema validation, reads fail open in Git-less workspaces while mutations still fail closed, the shell validation classifier recognizes Python/Go/Rust/Make/Maven/Gradle/Ruby/.NET/Deno/Bun test commands plus direct runs of files changed this goal, and `shell` accepts `purpose=validation` so ad hoc assertion scripts become structured completion evidence.
11
- - Validated with a differential Harbor benchmark on glm-5.3 (claude-code, nanocoder, pi, haze): haze passed 17/17 verifier tests with the fewest input tokens of the reporting harnesses, a clean goal envelope (1 cycle, structured passing validation), and zero stalls. Full report under [`benchmarks/harbor/results`](https://github.com/DenizOkcu/haze/tree/main/benchmarks/harbor/results).
12
- - Carried from 0.11.0: autonomous goal continuation across physical turns, runtime provenance and stale-install protection, model-aware context budgeting, headless `--timeout`, per-tool deadlines, incremental streaming, and model-written `/compact` summaries.
9
+ - Terminal theming: 14 built-in palettes — the default `purple`, a `light` pair, and oh-my-zsh ports like `robbyrussell`, `af-magic`, `agnoster`, and `solarized-dark`/`solarized-light`. `/themes` opens a picker (each theme labeled light/dark, the active one marked); `/themes <name>` sets one directly. Switching applies live without a restart, and the selection persists as `theme` in `~/.haze/settings.json`. A theme owns both terminal defaults — haze adopts its foreground/background (OSC 10/11) on start and restores yours on exit — so already-printed transcript text keeps its old colors, which is accepted behavior. `docs/theming-plan.md` documents the role vocabulary and the conversion guides for porting more themes.
10
+ - Hard secret-file protection in every file tool: SSH keys, shell history files, `.env`/`.envrc` (documentation variants excepted), `*.pem`/`*.key`, and common home credential stores are refused for reads and mutations before any filesystem access — terminal `secret_file_protected` results, symlink-proof in both directions, immune to user-granted read exceptions and ignore overrides, with grep traversal skipping the protected names. The `shell` tool remains unfiltered by design; secret avoidance there is instructed through the system prompt and stays inside your supervision boundary.
13
11
 
14
12
  Previous releases:
15
13
 
14
+ - `1.0.0`: first stable release — the CLI flags, settings schema, `stream-json` event contract, session format, skill layout, and structured tool-result shape under the 1.x compatibility promise; a configurable model-retry pool; and four benchmark-driven reliability fixes (validated with the Harbor differential benchmark: 17/17 verifier tests, fewest input tokens of the reporting harnesses, zero stalls).
16
15
  - `0.11.0`: goal-level autonomy across physical-turn budgets (logical-goal supervisor, evidence-gated completion, `goal_*` stream events, cumulative goal envelope), runtime provenance and `haze doctor` (embedded build info, stale-build refusal, session build headers), model-aware context budgeting (per-preset limits, live discovery, 128K fallback, self-healing context overflow), headless `--timeout` with per-tool deadlines and abort-cause typing, performance work (batched ignore checks, LSP reuse, coalesced/vacuumed sessions, memoized estimates, incremental streaming, viewport-clamped live region), and model-written `/compact` summaries with a heuristic fallback.
17
16
  - `0.10.1`: OpenAI Subscription OAuth preset, SECURITY.md and the attended-use threat model, bounded completion recovery, compact colorized diffs, prompt-injection framing, hardened fetch/stdin/sessions, and a multi-page docs site.
18
17
 
@@ -94,6 +93,8 @@ API keys for HTTP/SSE servers are entered in a masked prompt and sent as `Author
94
93
 
95
94
  Saved settings live in `~/.haze/settings.json`. ChatGPT OAuth credentials live separately in `~/.haze/auth.json`; both files use private permissions. Provider keys and MCP headers require HTTPS unless the endpoint uses loopback HTTP (`localhost`, `*.localhost`, `127/8`, or `::1`). Keyless HTTP remains available, and local OpenAI-compatible providers do not need a key. If a settings or authentication file is malformed, haze shows an actionable error instead of treating it as empty. Configure everything inside haze with `/provider`, `/model`, and `/settings`; there are no environment variables to set. Provider presets carry curated per-model metadata (context window and output cap from the models.dev catalog) which the wizard writes into `modelLimits`.
96
95
 
96
+ Switch the interface palette with `/themes`. The picker lists every built-in theme — light palettes and oh-my-zsh ports like `robbyrussell`, `af-magic`, and `solarized-dark` — and applies the choice immediately; `/themes <name>` sets one directly. The selection persists as `theme` in `~/.haze/settings.json`, and text already on screen keeps its old colors.
97
+
97
98
  haze focuses on chat, local tools, context files, sessions, and Markdown skills. Use `/skills` for workflows outside that core. Its interactive picker can generate a skill from a description, then enable, disable, validate, or remove it. For reviews, release prep, deploy checks, debugging routines, or a team-specific checklist, ask haze to create a skill and edit the resulting Markdown as needed.
98
99
 
99
100
  ## Start using haze
@@ -204,6 +205,8 @@ When you catch yourself repeating the same instructions, put them in a skill. Th
204
205
  /model list
205
206
  /settings
206
207
  /settings open
208
+ /themes
209
+ /themes <name>
207
210
  /logs [id]
208
211
  /lsp
209
212
  /mcp
@@ -304,7 +307,7 @@ haze has a small built-in toolset:
304
307
  - `skill` loads an installed Markdown workflow or one of its references.
305
308
  - `lspWorkspaceSymbols`, `lspSymbols`, `lspDefinition`, and `lspReferences` provide optional read-only navigation through configured language servers. They appear only when an enabled server command is installed.
306
309
 
307
- Tool calls are grouped in the transcript so you can see what happened without reading a novella. Every successful `editFile`, `replaceLines`, and `writeFile` content change shows colored additions and removals with line numbers and context. Large diffs keep an eight-row preview—the first four and last four rows, separated by an omission marker—and expose the complete retained diff through `readToolOutput`; no-op mutations are labeled explicitly. File-tool failures include a reason code and a recovery hint. Large shell, search, and fetch results stay behind an in-memory handle. Later model calls see a compact summary tailored to validation, git, search, diffs, JSON, logs, or the head and tail of the output.
310
+ Tool calls are grouped in the transcript so you can see what happened without reading a novella. Every successful `editFile`, `replaceLines`, and `writeFile` content change shows colored additions and removals with line numbers and context. Large diffs keep an eight-row preview—the first four and last four rows, separated by an omission marker—and expose the complete retained diff through `readToolOutput`; no-op mutations are labeled explicitly. File-tool failures include a reason code and a recovery hint; protected secret files (SSH keys, shell histories, `.env` files, credentials) are refused outright with `secret_file_protected` and show as `blocked: protected secret file` in the transcript. Large shell, search, and fetch results stay behind an in-memory handle. Later model calls see a compact summary tailored to validation, git, search, diffs, JSON, logs, or the head and tail of the output.
308
311
 
309
312
  ### Optional LSP navigation
310
313
 
@@ -382,6 +385,7 @@ Most haze behaviour needs no configuration; a few optional keys in `~/.haze/sett
382
385
  - `modelRetries` (integer 0–10, default 2): size of the shared bounded retry pool for transient model errors and idle-stream stalls. Raise it for providers that terminate long streams aggressively; `0` disables automatic retries (a stalled stream pauses with the goal preserved for a one-key resume). The effective value is reported in `timeout` and `retry` stream events as `maxRetries`.
383
386
  - `contextWindowFallbackTokens` / `localContextWindowFallbackTokens` (default 128K hosted / 32K local): context-window guess for models without limits metadata. Every turn emits a `context_budget` event naming the window and its source, and the interactive warning fires once per model per session when the built-in default was used.
384
387
  - `manualCompaction` (`"llm-summary"` default, or `"heuristic"`): whether manual `/compact` asks the active model for a continuity summary or keeps the model-free bounded excerpt.
388
+ - `theme` (string, default `purple`): name of a built-in palette (`/themes` lists and sets them, with `light` and oh-my-zsh ports like `robbyrussell` included). Unknown names fail loudly at startup with the valid names listed.
385
389
 
386
390
  ## Safety model
387
391
 
@@ -392,6 +396,7 @@ Ordinary file and tool output is data, not instructions. The system prompt says
392
396
  Shell classification is informational. haze does not ask for confirmation before running commands, including commands that can mutate or delete data. This is an intentional trade-off for attended expert use, not a sandbox or permission boundary.
393
397
 
394
398
  - Model-selected file tools are restricted to the current workspace and follow `.gitignore` by default.
399
+ - Secret files are hard-blocked in every file tool, always: SSH keys (`~/.ssh/**` and `id_*` private keys), shell history files, `.env`/`.envrc` files, `*.pem`/`*.key`, and common home credential stores. Reads, edits, and writes are refused before any filesystem access with a terminal `secret_file_protected` result — no user-granted read exception, ignore override, or symlink form bypasses it — and grep traversal skips those names. Documentation variants (`.env.example`, `.env.sample`, `.env.template`, `id_*.pub`) stay readable. The transcript marks these attempts as `blocked: protected secret file`. The `shell` tool is not command-filtered; secret avoidance there is instructed through the system prompt, so shell remains inside your supervision boundary, not a sandbox.
395
400
  - A path explicitly typed by the user with `@path` or as a slash-containing bare path may grant read-only access for that turn, including outside the workspace. It never grants mutation access.
396
401
  - Ignored workspace files require an explicit override unless covered by that user-granted read exception. If Git cannot run at all, mutation tools refuse with `ignore_check_unavailable` (the safe direction for writes) — reads still proceed.
397
402
  - The `fetch` tool only reads public `http(s)` URLs. It rejects other schemes along with private, loopback, link-local, cloud-metadata, and malformed IPv6-like hosts. On every redirect, haze connects to the public IP it already validated, which closes the DNS-rebinding gap.
package/SECURITY.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  | Version | Supported |
6
6
  |---------|-----------|
7
- | Latest minor (`1.0.x`) | Yes — security fixes |
7
+ | Latest minor (`1.1.x`) | Yes — security fixes |
8
8
  | Older minors and pre-1.0 (`0.x`) | No — upgrade required |
9
9
 
10
10
  Security fixes are provided for the latest published minor release. Upgrade to the newest release before reporting an issue that may already have been fixed.
@@ -20,3 +20,5 @@ Include the affected version, operating system, reproduction steps, impact, and
20
20
  haze is intended for attended use by an experienced developer on a single-user machine. It trusts the user and their global `~/.haze` configuration. Repository contents, project instructions and skills, fetched web content, MCP and LSP servers, and model output are untrusted inputs. A local attacker who already has access as the same operating-system user is outside the supported threat model.
21
21
 
22
22
  haze does not use command confirmation gates. Shell classification is informational, and relevant commands may mutate or delete data. Workspace confinement, bounded input and output, URL validation, private local storage, prompt-injection framing, and user supervision reduce risk, but haze is not a sandbox.
23
+
24
+ The file tools carry one absolute exclusion: protected secret files (SSH keys, shell history files, `.env`/`.envrc` files, `*.pem`/`*.key`, and common home credential stores) are refused for reads and mutations before any filesystem access, including via symlinks, user-typed path exceptions, or ignore overrides. The `shell` tool has no command-level filtering for these paths; secret avoidance in shell is instructed through the system prompt and remains inside the attended-use supervision boundary. This layer is best-effort protection against casual and accidental access, not a defense against a deliberately malicious model — treat the operating-system account boundary as the real containment line.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@denizokcu/haze",
3
- "version": "1.0.0",
4
- "commit": "85e798e5d4b65f08889f2f780c3f9b0f2fe6ac07",
5
- "builtAt": "2026-08-16T22:39:49.522Z",
3
+ "version": "1.1.0",
4
+ "commit": "7bc6e5378787d1d1b8f2bc8ea803ed8b1da86a13",
5
+ "builtAt": "2026-08-19T05:45:12.356Z",
6
6
  "sourceRoot": "/Users/deniz.okcu/development/haze"
7
7
  }
@@ -36,7 +36,7 @@ export function TaskBar({ tasks, width, expanded, padding, maxRows }) {
36
36
  ordered.push(completed[i]);
37
37
  }
38
38
  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` : ''}`;
39
- 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 => {
39
+ 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.accent, 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 => {
40
40
  const title = task.title.length > maxTitleWidth ? task.title.slice(0, maxTitleWidth - 1) + '\u2026' : task.title;
41
41
  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 : theme.foreground, children: title })] }, task.id));
42
42
  }), expanded && ordered.length < tasks.length ? _jsxs(Text, { color: theme.muted, children: [" +", tasks.length - ordered.length, " more (ctrl+o)"] }) : null] }));
@@ -7,6 +7,7 @@ const CHAT_COMMAND_SUGGESTIONS = [
7
7
  { value: '/lsp', description: 'Manage LSP servers (semantic navigation)', kind: 'command' },
8
8
  { value: '/mcp', description: 'Manage MCP servers (Context7, etc.)', kind: 'command' },
9
9
  { value: '/settings', description: 'Show provider, model, API key, and context status', kind: 'command' },
10
+ { value: '/themes', description: 'Choose a terminal theme (light palettes and oh-my-zsh ports included)', kind: 'command' },
10
11
  { value: '/context', description: 'Show token breakdown of system, tools, MCP, and messages', kind: 'command' },
11
12
  { value: '/skills', description: 'Manage Markdown skills (add, enable/disable, validate, remove)', kind: 'command' },
12
13
  { value: '/fleet ', description: 'Parallelize independent work in disposable contexts (flags: --review/--profile/--workers/--concurrency)', kind: 'command' },
@@ -144,7 +144,7 @@ function ToolMessageText({ text, streaming, width, toolDiffs, maxVisibleLines })
144
144
  const [, indent, icon, toolName, rest] = row;
145
145
  const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
146
146
  const timer = /(.*) (\([0-9]+(?:h [0-9]+m [0-9]+(?:\.[0-9])?s|m [0-9]+(?:\.[0-9])?s|(?:\.[0-9])?s)\))$/.exec(rest);
147
- 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}`);
147
+ return _jsxs(Text, { color: theme.muted, children: [indent, _jsx(Text, { color: iconColor, children: icon }), " ", _jsx(Text, { color: theme.accent, children: toolName }), timer ? timer[1] : rest, timer ? _jsxs(Text, { color: theme.muted, bold: false, children: [" ", timer[2]] }) : null] }, `${index}-${line}`);
148
148
  }), clamped.visibleDiffs.map(diff => _jsx(ToolDiffView, { diff: diff, width: width }, diff.id)), clamped.hiddenDiffCount > 0 ? _jsx(Text, { color: theme.muted, children: `⋯ ${clamped.hiddenDiffCount} diff preview${clamped.hiddenDiffCount === 1 ? '' : 's'} hidden` }) : null] });
149
149
  }
150
150
  export function messageElapsedLabel(message) {
@@ -161,7 +161,7 @@ export function messageElapsedLabel(message) {
161
161
  }
162
162
  export const AssistantMarkdownChunkView = React.memo(function AssistantMarkdownChunkView({ message, content, width, first, final }) {
163
163
  const completion = final ? messageElapsedLabel(message) : '';
164
- return _jsxs(Box, { flexDirection: "column", marginBottom: final ? 1 : 0, children: [first ? _jsx(Text, { color: theme.purple, bold: true, children: "haze" }) : null, _jsx(MarkdownText, { content: content, width: width }), completion ? _jsx(Text, { color: theme.muted, children: completion }) : null] });
164
+ return _jsxs(Box, { flexDirection: "column", marginBottom: final ? 1 : 0, children: [first ? _jsx(Text, { color: theme.accent, bold: true, children: "haze" }) : null, _jsx(MarkdownText, { content: content, width: width }), completion ? _jsx(Text, { color: theme.muted, children: completion }) : null] });
165
165
  });
166
166
  /** Streaming assistant tail clamped to the live-region budget; the full text enters the static transcript once the root settles. */
167
167
  function StreamingClampedText({ text, width, maxVisibleLines }) {
@@ -172,7 +172,7 @@ export const MessageView = React.memo(function MessageView({ message, width, sho
172
172
  if (message.role === 'user') {
173
173
  return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { backgroundColor: theme.surfaceBg, children: fullWidthBlankLine(width) }), _jsx(Text, { color: theme.success, bold: true, backgroundColor: theme.surfaceBg, children: ' You asked'.padEnd(width) }), fullWidthLines(message.text, width, 2).map((line, lineIndex) => _jsx(Text, { color: theme.foreground, backgroundColor: theme.surfaceBg, children: line }, lineIndex)), _jsx(Text, { backgroundColor: theme.surfaceBg, children: fullWidthBlankLine(width) })] });
174
174
  }
175
- return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [showHeader ? _jsxs(Text, { children: [_jsx(Text, { color: message.role === 'assistant' ? theme.purple : message.role === 'tool' ? theme.blue : message.role === 'system' ? theme.success : 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] }) : null, message.role === 'tool'
175
+ return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [showHeader ? _jsxs(Text, { children: [_jsx(Text, { color: message.role === 'assistant' ? theme.accent : message.role === 'tool' ? theme.info : message.role === 'system' ? theme.success : 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] }) : null, message.role === 'tool'
176
176
  ? _jsx(ToolMessageText, { text: message.text, streaming: message.streaming, width: width, toolDiffs: message.toolDiffs, maxVisibleLines: message.streaming ? maxVisibleLines : undefined })
177
177
  : message.role === 'assistant' && !message.streaming
178
178
  // Only settled assistant messages get Markdown rendering. Streaming
@@ -15,6 +15,7 @@ import { PROVIDER_ACTIONS, PROVIDER_CHOICES, MODEL_CHOICES, SERVER_CHOICES, capt
15
15
  import { finishLspCustomResult, selectLspActionResult, selectLspPresetResult, selectLspServerResult, finishMcpCustomResult, selectMcpActionResult, selectMcpPresetResult, selectMcpServerResult, setMcpServerKeyResult } from '../commands/serverWizard.js';
16
16
  import { chatgptCodexUrlWarning, providerActionResult, providerAppendModels, providerFinishAdd, providerRemove, providerRemoveModels, providerSetImageCapable, providerSetKey } from '../commands/providerWizard.js';
17
17
  import { selectSkillActionResult, selectSkillResult, captureSkillDescription as captureSkillDescriptionResult, skillCreationFailure, skillCreationMessage, skillConfirmRemoveResult as skillConfirmRemove } from '../commands/skillsWizard.js';
18
+ import { selectThemeResult } from '../commands/themesCommand.js';
18
19
  import { startupProviderInfo } from './startupInfo.js';
19
20
  import { SESSION_ACTIONS } from '../commands/sessionPicker.js';
20
21
  import { openBrowser, startChatGptBrowserLogin } from '../../llm/openaiCodexOAuth.js';
@@ -773,6 +774,14 @@ export function createWizardDispatch(deps) {
773
774
  setMode(result.mode);
774
775
  showMessage(result.message);
775
776
  }
777
+ async function selectTheme(name) {
778
+ const result = selectThemeResult(name);
779
+ if (result.settingsPatch) {
780
+ setSettings(await updateSettings(result.settingsPatch));
781
+ setMode('chat');
782
+ }
783
+ showMessage(result.message);
784
+ }
776
785
  const handlers = {
777
786
  sessions: selectSession,
778
787
  sessionAction: selectSessionAction,
@@ -805,6 +814,7 @@ export function createWizardDispatch(deps) {
805
814
  mcpAddKey: finishMcpCustom,
806
815
  mcpSetKey: setMcpServerKey,
807
816
  mcpConfirmRemove: mcpConfirmRemoveMode,
817
+ themes: selectTheme,
808
818
  };
809
819
  /** Apply one field-transition effect at the submit boundary (was chat.tsx inline branching). */
810
820
  async function applyProviderEffect(effect) {
@@ -13,7 +13,8 @@ import { activeModel, activeProvider } from '../../config/providers.js';
13
13
  import { isSkillEnabled } from '../../config/skillSettings.js';
14
14
  import { Header } from '../../ui/components/Header.js';
15
15
  import { TextInput } from '../../ui/components/TextInput.js';
16
- import { theme } from '../../ui/theme.js';
16
+ import { setActiveTheme, resolveTheme, theme, DEFAULT_THEME_NAME } from '../../ui/theme.js';
17
+ import { applyTerminalColors, resetTerminalColors } from '../../ui/terminalColors.js';
17
18
  import { handleSlashCommand } from './commands.js';
18
19
  import { runAgentGoal } from './streaming/goalSupervisor.js';
19
20
  import { formatElapsedTimeWhole, imageAttachmentLine } from './formatters.js';
@@ -181,6 +182,26 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
181
182
  return;
182
183
  currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
183
184
  }, [busy]);
185
+ // Live theme switching (docs/theming-plan.md §3.6): whenever the settings'
186
+ // theme name changes (/themes), re-resolve and adopt it so the whole UI
187
+ // repaints without a restart. Ink <Static> history stays as-rendered, so
188
+ // already-printed text keeps its old colors; the terminal defaults (OSC
189
+ // 10/11) follow the new theme. Skipped until settings have loaded once —
190
+ // chatCommand() already resolved the theme before the first render, and the
191
+ // pre-load {} state would briefly flash the default theme.
192
+ const settingsThemeLoadedRef = useRef(false);
193
+ const activeThemeName = settings.theme ?? DEFAULT_THEME_NAME;
194
+ useEffect(() => {
195
+ if (!settingsThemeLoadedRef.current)
196
+ return;
197
+ try {
198
+ setActiveTheme(resolveTheme(activeThemeName));
199
+ applyTerminalColors(theme.foreground, theme.background);
200
+ }
201
+ catch {
202
+ // Malformed theme names were reported at startup; keep the resolved default.
203
+ }
204
+ }, [activeThemeName]);
184
205
  useEffect(() => {
185
206
  void (async () => {
186
207
  const [settingsResult, branch, files] = await Promise.all([
@@ -190,6 +211,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
190
211
  ]);
191
212
  const next = settingsResult.value;
192
213
  setSettings(next);
214
+ settingsThemeLoadedRef.current = true;
193
215
  setSettingsError(settingsResult.error);
194
216
  setBranchName(branch);
195
217
  setContextFiles(files);
@@ -660,7 +682,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
660
682
  // One row for the optional header plus one for the item's bottom margin.
661
683
  const chrome = (item.showHeader === false ? 0 : 1) + 1;
662
684
  return _jsx(MessageView, { message: item.message, width: contentWidth, showHeader: item.showHeader, maxVisibleLines: Math.max(1, perStreamingItemRows - chrome) }, item.key);
663
- }) }), 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, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), pausedResume && !busy && _jsxs(Box, { flexShrink: 0, marginBottom: 1, children: [_jsxs(Text, { color: theme.muted, children: [pausedResume.kind === 'incomplete-goal' ? 'Unfinished goal paused (no measurable progress)' : 'Unfinished goal paused (model stream stalled)', " \u00B7 "] }), _jsxs(Text, { color: theme.command, bold: true, children: ["Press R to ", pausedResume.kind === 'incomplete-goal' ? 'resume' : 'retry'] }), _jsx(Text, { color: theme.muted, children: " or type a follow-up" })] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: expandedTaskCap }) }), busy && _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, tip: showingTip ? TIPS[tipIndex] : undefined }), _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: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: Math.max(20, contentWidth - 4), getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
685
+ }) }), 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, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), pausedResume && !busy && _jsxs(Box, { flexShrink: 0, marginBottom: 1, children: [_jsxs(Text, { color: theme.muted, children: [pausedResume.kind === 'incomplete-goal' ? 'Unfinished goal paused (no measurable progress)' : 'Unfinished goal paused (model stream stalled)', " \u00B7 "] }), _jsxs(Text, { color: theme.command, bold: true, children: ["Press R to ", pausedResume.kind === 'incomplete-goal' ? 'resume' : 'retry'] }), _jsx(Text, { color: theme.muted, children: " or type a follow-up" })] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: expandedTaskCap }) }), busy && _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, tip: showingTip ? TIPS[tipIndex] : undefined }), _jsx(Box, { borderStyle: "round", borderColor: theme.border, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: Math.max(20, contentWidth - 4), getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
664
686
  if (!tasksExpanded) {
665
687
  setTaskBarPadding(0);
666
688
  setTasksExpanded(true);
@@ -679,15 +701,35 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
679
701
  }, onSubmit: submit }) }) }), debug && metrics.hasTokenBreakdown && _jsxs(Box, { flexShrink: 0, flexDirection: "column", paddingX: 1, children: [_jsxs(Text, { color: theme.muted, bold: true, children: ["Token usage ", metrics.inputEstimated || metrics.outputEstimated ? '(estimated)' : '(precise)'] }), _jsxs(Text, { color: theme.muted, children: [" in=", formatTokenCount(metrics.effectiveInput), " out=", formatTokenCount(metrics.effectiveOutput), tokenUsage.cacheReadTokens > 0 ? ` cached=${formatTokenCount(tokenUsage.cacheReadTokens)}` : '', tokenUsage.noCacheTokens > 0 ? ` uncached=${formatTokenCount(tokenUsage.noCacheTokens)}` : '', tokenUsage.cacheWriteTokens > 0 ? ` cache_write=${formatTokenCount(tokenUsage.cacheWriteTokens)}` : '', tokenUsage.reasoningTokens > 0 ? ` reasoning=${formatTokenCount(tokenUsage.reasoningTokens)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" logical=", formatTokenCount(tokenUsage.logicalInputEstimate), tokenUsage.effectiveNonCachedInput != null ? ` effective_non_cached=${formatTokenCount(tokenUsage.effectiveNonCachedInput)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" system=", formatTokenCount(tokenUsage.systemPrompt), " messages=", formatTokenCount(tokenUsage.messages), " tools=", formatTokenCount(tokenUsage.toolSchemas), " output=", formatTokenCount(tokenUsage.outputEstimate)] })] }), _jsxs(Box, { flexShrink: 0, justifyContent: "space-between", children: [_jsxs(Box, { flexDirection: "column", flexShrink: 1, minWidth: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel })] }), _jsx(Box, { flexShrink: 0, marginLeft: 2, children: _jsx(Text, { color: theme.muted, wrap: "truncate-start", children: activeModelName }) })] })] });
680
702
  }
681
703
  export async function chatCommand(options = {}) {
704
+ // Resolve the theme before any Ink output so every component renders with it.
705
+ // Settings failures must not block startup (the in-app banner already reports
706
+ // them), but an unknown theme name fails loudly with the valid names listed.
707
+ try {
708
+ setActiveTheme(resolveTheme((await readSettings()).theme));
709
+ }
710
+ catch (error) {
711
+ console.error(`[haze] ${error instanceof Error ? error.message : String(error)}; using the ${DEFAULT_THEME_NAME} theme.`);
712
+ }
682
713
  if (process.stdout.isTTY) {
683
714
  process.stdout.write('\u001B[2J\u001B[3J\u001B[H');
715
+ // Adopt the theme's foreground AND background as the terminal defaults
716
+ // (OSC 10 + 11; ignored by terminals without support). Both sides must be
717
+ // themed together: unstyled text inherits the terminal fg, so a light
718
+ // background without a light-mode fg would be unreadable. Restored
719
+ // (OSC 110 + 111) on exit below.
720
+ applyTerminalColors(theme.foreground, theme.background);
684
721
  }
685
722
  await clearTasksFromStore().catch(() => undefined);
686
723
  // Incremental rendering rewrites only changed lines of the live frame, removing
687
724
  // the full-frame erase/rewrite flicker while streaming. The fps cap aligns with
688
725
  // the ~80ms spinner cadence; faster renders would only repaint unchanged lines.
689
726
  const app = render(_jsx(ChatScreen, { debug: options.debug, version: options.version, build: options.build, continueSession: options.continueSession, resumeSessionId: options.resumeSessionId, noSession: options.noSession }), { incrementalRendering: true, maxFps: 15 });
690
- await app.waitUntilExit();
691
- await teardownBackgroundProcesses().catch(() => undefined);
692
- await clearTasksFromStore().catch(() => undefined);
727
+ try {
728
+ await app.waitUntilExit();
729
+ await teardownBackgroundProcesses().catch(() => undefined);
730
+ await clearTasksFromStore().catch(() => undefined);
731
+ }
732
+ finally {
733
+ resetTerminalColors();
734
+ }
693
735
  }
@@ -5,6 +5,8 @@ export const COMMAND_HELP_ENTRIES = [
5
5
  { usage: '/model <name-or-provider:name>', description: 'Set a model directly. Selecting a model also sets its provider.' },
6
6
  { usage: '/settings', description: 'Show the configured provider, model, API key status, LSP/MCP servers, skills, and loaded context files.' },
7
7
  { usage: '/settings open', description: 'Open ~/.haze/settings.json with the OS default app.' },
8
+ { usage: '/themes', description: 'Choose a terminal theme from the built-in registry (light palettes and oh-my-zsh ports included); applies immediately.' },
9
+ { usage: '/themes <name>', description: 'Set the theme directly, e.g. /themes robbyrussell. Saved to ~/.haze/settings.json; text already on screen keeps its old colors.' },
8
10
  { usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
9
11
  { usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
10
12
  { usage: '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>', description: 'Run genuinely independent tasks through disposable contexts. Runtime enforces profile concurrency, deadlines, and mutation serialization; control guidance is not persisted. Declines non-parallel work.' },
@@ -7,6 +7,7 @@ import { handleFleetCommand } from './fleetCommand.js';
7
7
  import { handleInitCommand } from './initCommand.js';
8
8
  import { handleLogsCommand } from './logsCommand.js';
9
9
  import { handleModelCommand } from './modelCommand.js';
10
+ import { handleThemesCommand } from './themesCommand.js';
10
11
  import { formatSettingsSummary } from './settingsSummary.js';
11
12
  async function ensureSettingsFile(settings) {
12
13
  if (!await fs.pathExists(SETTINGS_FILE))
@@ -57,6 +58,7 @@ const SLASH_COMMANDS = [
57
58
  ctx.addSystemMessage(`Tips rotation ${currentlyEnabled ? 'disabled' : 'enabled'}.`);
58
59
  return HANDLED;
59
60
  } },
61
+ { match: exactOrArgs('/themes'), run: async (args, ctx) => await handleThemesCommand(args, ctx) },
60
62
  { match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
61
63
  ];
62
64
  export async function handleSlashCommand(value, ctx) {
@@ -133,6 +133,12 @@ export function toolResultSummary(event) {
133
133
  }
134
134
  return 'completed';
135
135
  }
136
+ if (output.reasonCode === 'secret_file_protected') {
137
+ // Protection events are visible but distinct from ordinary failures so
138
+ // the developer can audit them at a glance; never print file contents.
139
+ const protectedPath = typeof output.path === 'string' && output.path ? ` (${compact(output.path, 80)})` : '';
140
+ return `blocked: protected secret file${protectedPath}`;
141
+ }
136
142
  const reason = typeof output.reasonCode === 'string' ? ` (${output.reasonCode})` : '';
137
143
  return typeof output.error === 'string' ? `failed${reason}: ${compact(output.error)}` : `failed${reason}`;
138
144
  }
@@ -3,6 +3,7 @@ import { configuredLspServers } from '../../config/lspSettings.js';
3
3
  import { configuredMcpServers } from '../../config/mcpSettings.js';
4
4
  import { activeProvider as resolveActiveProvider, configuredProviders, providerHasKey, providerImageCapable } from '../../config/providers.js';
5
5
  import { isSkillEnabled } from '../../config/skillSettings.js';
6
+ import { DEFAULT_THEME_NAME } from '../../ui/theme.js';
6
7
  import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
7
8
  export async function formatSettingsSummary(settings, contextFiles) {
8
9
  const providers = configuredProviders(settings);
@@ -30,6 +31,7 @@ export async function formatSettingsSummary(settings, contextFiles) {
30
31
  `Model: ${settings.model ?? 'not set'}`,
31
32
  `Base URL: ${activeProvider?.url ?? settings.baseURL ?? 'not configured'}`,
32
33
  `API key: ${activeProvider && providerHasKey(settings, activeProvider) ? 'saved' : 'missing'}`,
34
+ `Theme: ${settings.theme ?? `${DEFAULT_THEME_NAME} (default)`}`,
33
35
  `Configured providers: ${providers.map(provider => `${provider.name}${providerImageCapable(provider) ? ' (images)' : ''}`).join(', ') || 'none'}`,
34
36
  `LSP servers: ${lspServers.map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
35
37
  `MCP servers: ${configuredMcpServers(settings).map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
@@ -0,0 +1,17 @@
1
+ import type { HazeSettings } from '../../config/settings.js';
2
+ import type { CommandContext, CommandResult } from './commands.js';
3
+ /**
4
+ * `/themes` — theme picker and direct set. The picker is one step in the
5
+ * `wizardFlow.ts` table (mode `themes`); this module holds the pure selection
6
+ * result shared by the slash path and the wizard submit handler, mirroring the
7
+ * other `*Command.ts` / `*Wizard.ts` splits. Applying the resolved theme live
8
+ * is owned by ChatScreen (it re-resolves whenever `settings.theme` changes).
9
+ */
10
+ export interface ThemeSelectionResult {
11
+ /** Present when the name is valid and should be persisted; absent means the message explains the failure. */
12
+ settingsPatch?: HazeSettings;
13
+ message: string;
14
+ }
15
+ /** Validate a theme name against the built-in registry (`resolveTheme` lists the valid names on failure) and shape the persist result. */
16
+ export declare function selectThemeResult(name: string): ThemeSelectionResult;
17
+ export declare function handleThemesCommand(args: string, ctx: CommandContext): Promise<CommandResult>;
@@ -0,0 +1,24 @@
1
+ import { resolveTheme } from '../../ui/theme.js';
2
+ /** Validate a theme name against the built-in registry (`resolveTheme` lists the valid names on failure) and shape the persist result. */
3
+ export function selectThemeResult(name) {
4
+ const trimmed = name.trim();
5
+ try {
6
+ resolveTheme(trimmed);
7
+ }
8
+ catch (error) {
9
+ return { message: error instanceof Error ? error.message : String(error) };
10
+ }
11
+ return { settingsPatch: { theme: trimmed }, message: `Theme set to ${trimmed}. Saved to ~/.haze/settings.json. Text already on screen keeps its old colors.` };
12
+ }
13
+ export async function handleThemesCommand(args, ctx) {
14
+ if (!args) {
15
+ ctx.setMode('themes');
16
+ ctx.addSystemMessage('Choose a theme. Selecting one applies it immediately and saves it to ~/.haze/settings.json.');
17
+ return 'handled';
18
+ }
19
+ const result = selectThemeResult(args);
20
+ if (result.settingsPatch)
21
+ await ctx.updateSettings(result.settingsPatch);
22
+ ctx.addSystemMessage(result.message);
23
+ return 'handled';
24
+ }
@@ -106,6 +106,8 @@ export declare function mcpTransportSuggestions(): TextInputSuggestion[];
106
106
  export declare function skillsSuggestions(settings: HazeSettings, skills: LoadedSkill[]): TextInputSuggestion[];
107
107
  export declare function skillScopeSuggestions(): TextInputSuggestion[];
108
108
  export declare function skillsActionSuggestions(settings: HazeSettings, skills: LoadedSkill[], selectedSkillName: string | undefined): TextInputSuggestion[];
109
+ /** Every built-in theme with its palette brightness and the active one marked (`resolveTheme` validates names). */
110
+ export declare function themeSuggestions(settings: HazeSettings): TextInputSuggestion[];
109
111
  type WizardStepKind = 'pick' | 'input' | 'masked-input' | 'confirm';
110
112
  /** Inputs available to a step's suggestion builder (mirrors the picker state). */
111
113
  export interface WizardSuggestionState {
@@ -327,6 +329,11 @@ export declare const WIZARD_STEPS: readonly [{
327
329
  readonly kind: "confirm";
328
330
  readonly placeholder: "Type \"yes\" to confirm";
329
331
  readonly suggestions: () => never[];
332
+ }, {
333
+ readonly id: "themes";
334
+ readonly kind: "pick";
335
+ readonly placeholder: "Choose a theme";
336
+ readonly suggestions: (s: WizardSuggestionState) => TextInputSuggestion[];
330
337
  }];
331
338
  export type WizardStepId = (typeof WIZARD_STEPS)[number]['id'];
332
339
  /** Suggestions for a wizard mode, or undefined when the mode is not a wizard step ('chat'). */
@@ -4,6 +4,7 @@ import { configuredMcpServers, findMcpServer, findMcpPreset, presetIds } from '.
4
4
  import { isSkillEnabled } from '../../config/skillSettings.js';
5
5
  import { PROVIDER_PRESETS } from '../../config/providerPresets.js';
6
6
  import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
7
+ import { BUILT_IN_THEME_SPECS, DEFAULT_THEME_NAME, resolveTheme } from '../../ui/theme.js';
7
8
  import { sessionActionSuggestions, sessionSuggestions } from './sessionPicker.js';
8
9
  /**
9
10
  * Wizard flow table (CR-006 successor): the single source of truth for every
@@ -324,6 +325,23 @@ export function skillsActionSuggestions(settings, skills, selectedSkillName) {
324
325
  result.push({ value: SKILL_ACTIONS.removeSkill, description: 'delete this skill directory', kind: 'skill' });
325
326
  return result;
326
327
  }
328
+ /** Perceptual-luminance check on a `#rrggbb` background so the theme picker can label light vs dark palettes. */
329
+ function isLightBackground(hex) {
330
+ const channels = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);
331
+ if (!channels)
332
+ return false;
333
+ const [, r = '0', g = '0', b = '0'] = channels;
334
+ return (0.2126 * parseInt(r, 16) + 0.7152 * parseInt(g, 16) + 0.0722 * parseInt(b, 16)) / 255 > 0.5;
335
+ }
336
+ /** Every built-in theme with its palette brightness and the active one marked (`resolveTheme` validates names). */
337
+ export function themeSuggestions(settings) {
338
+ const active = settings.theme ?? DEFAULT_THEME_NAME;
339
+ return Object.keys(BUILT_IN_THEME_SPECS).map(name => ({
340
+ value: name,
341
+ description: `${isLightBackground(resolveTheme(name).background) ? 'light' : 'dark'} palette${name === active ? ' · active' : ''}`,
342
+ kind: 'theme',
343
+ }));
344
+ }
327
345
  export const WIZARD_STEPS = [
328
346
  // Sessions
329
347
  { id: 'sessions', kind: 'pick', placeholder: 'Choose a saved session', suggestions: (s) => sessionSuggestions(s.sessions ?? []) },
@@ -368,6 +386,8 @@ export const WIZARD_STEPS = [
368
386
  { id: 'mcpAddKey', kind: 'masked-input', placeholder: 'API key, or blank to skip', optional: true, suggestions: () => [] },
369
387
  { id: 'mcpSetKey', kind: 'masked-input', placeholder: 'API key', suggestions: () => [] },
370
388
  { id: 'mcpConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
389
+ // Themes
390
+ { id: 'themes', kind: 'pick', placeholder: 'Choose a theme', suggestions: (s) => themeSuggestions(s.settings) },
371
391
  ];
372
392
  const WIZARD_STEP_BY_ID = Object.fromEntries(WIZARD_STEPS.map(step => [step.id, step]));
373
393
  /** Suggestions for a wizard mode, or undefined when the mode is not a wizard step ('chat'). */
@@ -105,6 +105,8 @@ export interface HazeSettings {
105
105
  tips?: {
106
106
  enabled?: boolean;
107
107
  };
108
+ /** Built-in theme name; unset means `purple`. Other options: `light`, oh-my-zsh ports like `robbyrussell`, palette ports like `solarized-dark`. Validated by `resolveTheme`. */
109
+ theme?: string;
108
110
  apiKey?: string;
109
111
  baseURL?: string;
110
112
  [key: string]: unknown;
@@ -60,6 +60,7 @@ const settingsSchema = z.object({
60
60
  modelRetries: modelRetriesSchema.optional(),
61
61
  manualCompaction: z.enum(['llm-summary', 'heuristic']).optional(),
62
62
  tips: z.object({ enabled: z.boolean().optional() }).optional(),
63
+ theme: z.string().optional(),
63
64
  apiKey: z.string().optional(),
64
65
  baseURL: z.string().optional(),
65
66
  }).passthrough();
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Whether a path points at (or inside) a protected secret file or credential
3
+ * store. Checked against both lexical names and real paths by callers so
4
+ * symlinks cannot rename a secret into reach (`link -> .env`) or a secret
5
+ * name onto other content (`.env -> target`). Pure function; `homeDir` is
6
+ * injectable for tests.
7
+ */
8
+ export declare function isProtectedSecretPath(candidatePath: string, homeDir?: string): boolean;
9
+ /**
10
+ * Ripgrep exclusion globs for the `grep` tool. Later globs take precedence in
11
+ * ripgrep, so callers must append these AFTER any model-supplied glob — an
12
+ * explicit model glob must not re-include secrets. Exclusions are strictly
13
+ * negated: a positive "re-include" glob would act as a whitelist and narrow
14
+ * the search to only the re-included names. Documentation variants
15
+ * (`.env.example`, `id_*.pub`) therefore stay out of traversal search but
16
+ * remain readable through targeted `readFile` calls.
17
+ */
18
+ export declare function secretSearchExcludeGlobs(): string[];