@denizokcu/haze 1.0.0 → 1.1.1

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 (116) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +17 -8
  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/busyIndicator.d.ts +11 -0
  7. package/dist/cli/chat/busyIndicator.js +34 -0
  8. package/dist/cli/chat/chatMetrics.d.ts +0 -1
  9. package/dist/cli/chat/chatMetrics.js +1 -7
  10. package/dist/cli/chat/followUpQueue.d.ts +11 -0
  11. package/dist/cli/chat/followUpQueue.js +38 -0
  12. package/dist/cli/chat/inputSuggestions.js +1 -0
  13. package/dist/cli/chat/messages.d.ts +0 -22
  14. package/dist/cli/chat/messages.js +42 -87
  15. package/dist/cli/chat/sessionLifecycle.d.ts +3 -1
  16. package/dist/cli/chat/sessionLifecycle.js +6 -1
  17. package/dist/cli/chat/sessionRecorder.d.ts +2 -0
  18. package/dist/cli/chat/sessionRecorder.js +6 -0
  19. package/dist/cli/chat/startupSequence.d.ts +29 -0
  20. package/dist/cli/chat/startupSequence.js +59 -0
  21. package/dist/cli/chat/transcriptPartition.d.ts +23 -0
  22. package/dist/cli/chat/transcriptPartition.js +78 -0
  23. package/dist/cli/chat/wizard/fieldTransitions.d.ts +38 -0
  24. package/dist/cli/chat/wizard/fieldTransitions.js +43 -0
  25. package/dist/cli/chat/wizard/lspHandlers.d.ts +4 -0
  26. package/dist/cli/chat/wizard/lspHandlers.js +85 -0
  27. package/dist/cli/chat/wizard/mcpHandlers.d.ts +8 -0
  28. package/dist/cli/chat/wizard/mcpHandlers.js +82 -0
  29. package/dist/cli/chat/wizard/providerHandlers.d.ts +12 -0
  30. package/dist/cli/chat/wizard/providerHandlers.js +420 -0
  31. package/dist/cli/chat/wizard/sessionThemeHandlers.d.ts +4 -0
  32. package/dist/cli/chat/wizard/sessionThemeHandlers.js +48 -0
  33. package/dist/cli/chat/wizard/skillsHandlers.d.ts +4 -0
  34. package/dist/cli/chat/wizard/skillsHandlers.js +125 -0
  35. package/dist/cli/chat/wizard/types.d.ts +63 -0
  36. package/dist/cli/chat/wizard/types.js +24 -0
  37. package/dist/cli/chat/wizard/uiState.d.ts +56 -0
  38. package/dist/cli/chat/wizard/uiState.js +15 -0
  39. package/dist/cli/chat/wizardDispatch.d.ts +11 -113
  40. package/dist/cli/chat/wizardDispatch.js +41 -805
  41. package/dist/cli/commands/chat.js +89 -110
  42. package/dist/cli/commands/commandHelp.js +2 -0
  43. package/dist/cli/commands/commands.js +2 -0
  44. package/dist/cli/commands/formatters.d.ts +0 -3
  45. package/dist/cli/commands/formatters.js +6 -29
  46. package/dist/cli/commands/runCommand.d.ts +2 -0
  47. package/dist/cli/commands/runCommand.js +67 -4
  48. package/dist/cli/commands/settingsSummary.js +2 -0
  49. package/dist/cli/commands/streaming/assistantSegments.d.ts +19 -0
  50. package/dist/cli/commands/streaming/assistantSegments.js +48 -0
  51. package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -2
  52. package/dist/cli/commands/streaming/attemptOutcome.js +17 -7
  53. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +69 -8
  54. package/dist/cli/commands/streaming/goalCheckpoint.js +36 -1
  55. package/dist/cli/commands/streaming/goalSupervisor.d.ts +17 -2
  56. package/dist/cli/commands/streaming/goalSupervisor.js +62 -12
  57. package/dist/cli/commands/streaming/prepareStep.d.ts +35 -0
  58. package/dist/cli/commands/streaming/prepareStep.js +100 -0
  59. package/dist/cli/commands/streaming/recoverySlices.d.ts +15 -0
  60. package/dist/cli/commands/streaming/recoverySlices.js +29 -0
  61. package/dist/cli/commands/streaming/stallRecovery.d.ts +0 -1
  62. package/dist/cli/commands/streaming/stallRecovery.js +0 -4
  63. package/dist/cli/commands/streaming/streamLoop.js +9 -230
  64. package/dist/cli/commands/streaming/toolGroupRenderer.js +2 -1
  65. package/dist/cli/commands/streaming/toolPartHandlers.d.ts +19 -0
  66. package/dist/cli/commands/streaming/toolPartHandlers.js +95 -0
  67. package/dist/cli/commands/streaming.d.ts +4 -1
  68. package/dist/cli/commands/streaming.js +6 -21
  69. package/dist/cli/commands/themesCommand.d.ts +17 -0
  70. package/dist/cli/commands/themesCommand.js +24 -0
  71. package/dist/cli/commands/wizardFlow.d.ts +7 -0
  72. package/dist/cli/commands/wizardFlow.js +20 -0
  73. package/dist/cli/index.js +3 -1
  74. package/dist/config/providerPresets.d.ts +7 -0
  75. package/dist/config/providerPresets.js +195 -391
  76. package/dist/config/settings.d.ts +2 -0
  77. package/dist/config/settings.js +1 -0
  78. package/dist/core/agent/completionController.d.ts +14 -7
  79. package/dist/core/agent/completionController.js +12 -6
  80. package/dist/core/agent/events.d.ts +12 -0
  81. package/dist/core/agent/goalPolicy.d.ts +4 -3
  82. package/dist/core/agent/goalPolicy.js +9 -4
  83. package/dist/core/agent/workState.d.ts +25 -15
  84. package/dist/core/agent/workState.js +71 -43
  85. package/dist/core/safety/secretPaths.d.ts +18 -0
  86. package/dist/core/safety/secretPaths.js +115 -0
  87. package/dist/core/session/sessionSlimming.js +8 -0
  88. package/dist/core/session/sessionStore.d.ts +61 -1
  89. package/dist/core/session/sessionStore.js +115 -6
  90. package/dist/llm/hazeTools.d.ts +64 -208
  91. package/dist/llm/hazeTools.js +6 -0
  92. package/dist/llm/systemPrompt.js +3 -1
  93. package/dist/llm/toolResultTypes.d.ts +1 -1
  94. package/dist/llm/tools/failures.d.ts +6 -0
  95. package/dist/llm/tools/failures.js +8 -2
  96. package/dist/llm/tools/readRecovery.js +2 -0
  97. package/dist/llm/tools/shellTool.js +3 -0
  98. package/dist/llm/tools/taskTool.d.ts +64 -208
  99. package/dist/llm/tools/taskTool.js +22 -10
  100. package/dist/llm/tools/workspaceFile.d.ts +4 -3
  101. package/dist/llm/tools/workspaceFile.js +30 -13
  102. package/dist/ui/components/Header.js +1 -1
  103. package/dist/ui/components/MarkdownText.js +10 -10
  104. package/dist/ui/components/TextInput.d.ts +1 -1
  105. package/dist/ui/components/TextInput.js +8 -69
  106. package/dist/ui/components/useInputSuggestions.d.ts +27 -0
  107. package/dist/ui/components/useInputSuggestions.js +98 -0
  108. package/dist/ui/terminalColors.d.ts +29 -0
  109. package/dist/ui/terminalColors.js +47 -0
  110. package/dist/ui/theme.d.ts +105 -10
  111. package/dist/ui/theme.js +125 -15
  112. package/dist/ui/themes/registry.d.ts +5 -0
  113. package/dist/ui/themes/registry.js +436 -0
  114. package/dist/utils/format.d.ts +10 -0
  115. package/dist/utils/format.js +45 -0
  116. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1 - 2026-08-26
4
+
5
+ Durable goal resume and a smaller autonomy core. This patch keeps the concrete headless/recovery gains developed after 1.1.0 while removing unproven completion ceremony before publication.
6
+
7
+ ### Added
8
+
9
+ - Durable goal ledger and crash-resume frontier: every logical-goal boundary can append bounded state to the session JSONL, including the exact request and its hash, cycle, mutation/validation outcome, task counts, and unresolved pre-edit failure evidence. Session restore finds the newest unfinished frontier without making goal-only files resumable, tolerates a truncated final line, and keeps the frontier through bounded ledger vacuuming.
10
+ - Headless `--until-done`: print mode can relaunch the preserved logical goal after transient provider failures with exponential backoff, `goal_resume` stream events, the existing absolute goal timeout, and a three-strike no-progress poison guard. Relaunches reuse the conversation and frontier without duplicating the original request or granting additional authority.
11
+ - Headless goal observability: `goal_notice` events and a bounded `notices` array expose continuation/pause decisions to stream and single-envelope consumers; `goal_continue` carries readable text.
12
+
13
+ ### Changed
14
+
15
+ - Completion remains structural but proportional: pending model-declared tasks and missing/stale/failed post-mutation validation reject a final. Red→green evidence is opportunistic — fixes do not need a pre-edit failing repro, but a recognized validation that fails before the first mutation must be rerun successfully after the edit. The completing check is sequence-bound so a pre-edit pass cannot satisfy the rule.
16
+ - `writeTasks` is task-only again. The experimental ask gate/refinement/amendment flow, independent verifier, goal shapes, multi-lane hints, final sweep, mandatory repro/depth prompt, waiver, and successor-command protocol were evaluated and removed before release. A three-attempt Harbor `csv-query` A/B found no success gain from the added ceremony and materially higher token/time cost; the final trimmed arms remained correct, but efficiency varied enough that this release makes no benchmark-speed claim.
17
+ - Large orchestration modules were split into focused helpers: chat startup/transcript/follow-up handling, wizard fields and per-domain handlers, input suggestions, and streaming preparation/tool dispatch/assistant segments/recovery slices. Public CLI behavior is unchanged.
18
+ - Theme definitions are consolidated into one typed registry, and provider presets use compact model tuples while preserving the resolved palette and preset data.
19
+ - All built-in tool rows align wrapped output beneath the tool name, and shared formatting helpers replace duplicate elapsed-time/path logic.
20
+
21
+ ### Fixed
22
+
23
+ - Overlong `writeTasks` titles are truncated in `execute` instead of causing a whole-call `AI_TypeValidationError` retry loop.
24
+ - Unresolved same-check red evidence survives physical-turn and crash-resume boundaries, while a satisfied pair is dropped from carried state so later turns do not inherit obsolete completion debt.
25
+
26
+ ## 1.1.0 - 2026-08-19
27
+
28
+ 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.
29
+
30
+ ### Added
31
+
32
+ - 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. The conversion guides for porting oh-my-zsh, VS Code, and Sublime themes live in `src/ui/themes/AGENTS.md`.
33
+
34
+ - 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.
35
+
3
36
  ## 1.0.0 - 2026-08-16
4
37
 
5
38
  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,19 @@
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.1
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.1 makes long-running goals resumable while keeping the autonomy core small and evidence-based.
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
+ - Durable goal progress: logical-goal boundaries are appended to the session JSONL with an exact-request hash and bounded task/validation state, so interrupted work can resume from a crash-safe frontier instead of replaying completed work.
10
+ - Headless persistence: `--until-done` relaunches a goal after transient provider failures with exponential backoff, `goal_resume` events, the existing absolute timeout, and a three-strike no-progress guard. JSON output includes bounded goal notices so scripts can see why work continued or paused.
11
+ - Simpler completion: declared tasks and fresh post-edit validation remain authoritative. Fixes do not require a pre-edit reproduction, but when a recognized check does fail before the first edit, that same command must pass afterward. Experimental ask gates, verifier/sweep calls, lane hints, and goal shapes were evaluated and removed before release because they added cost without improving the measured task.
12
+ - Smaller internals: theme data now lives in one typed registry, provider presets use compact model tuples, and the large chat, wizard, input-suggestion, and streaming paths are split into focused modules without changing their public behavior.
13
13
 
14
14
  Previous releases:
15
15
 
16
+ - `1.1.0`: terminal theming with 14 built-in palettes and live `/themes` switching; hard secret-file protection across every file tool, including symlink, read-blessing, ignore-override, and grep-traversal defenses.
17
+ - `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
18
  - `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
19
  - `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
20
 
@@ -94,6 +96,8 @@ API keys for HTTP/SSE servers are entered in a masked prompt and sent as `Author
94
96
 
95
97
  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
98
 
99
+ 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.
100
+
97
101
  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
102
 
99
103
  ## Start using haze
@@ -204,6 +208,8 @@ When you catch yourself repeating the same instructions, put them in a skill. Th
204
208
  /model list
205
209
  /settings
206
210
  /settings open
211
+ /themes
212
+ /themes <name>
207
213
  /logs [id]
208
214
  /lsp
209
215
  /mcp
@@ -240,6 +246,7 @@ haze -p "summarize this repo" --model openai:gpt-4o-mini
240
246
  haze --resume <id> -p "continue the investigation"
241
247
  haze -p "list the top 3 bugs in src/api.ts" --output json
242
248
  haze -p "audit src/auth.ts" --output stream-json # live NDJSON events, then the result envelope
249
+ haze -p "migrate the config loader" --until-done --timeout 2h # relaunch through transient provider failures
243
250
  echo "what does this project do?" | haze
244
251
  ```
245
252
 
@@ -266,7 +273,7 @@ If you pipe stdin without `-p`, haze reads the prompt from stdin. Piped prompts
266
273
  }
267
274
  ```
268
275
 
269
- The `status` field is authoritative (driven by the agent's terminal state, not by parsing `result`), and the exit code mirrors it: `0` only for `complete`. A run that ends without a substantive final answer, after an unresolved final tool failure, with declared tasks or required validation still unfinished (even if the model wrote a final message) is `failed` even if the provider returned normally; the evidence envelope carries the task counts and validation outcome that gated it. Per-turn step/tool budgets are safety boundaries, not completion: haze automatically continues the logical goal in fresh turns while measurable progress remains, so a budget boundary alone never fails a run. `--timeout` bounds the entire logical goal (not each internal turn). The result envelope additionally carries a `goal` object (physical turns used, stop reason, total mutations, final validation outcome and task counts) when goal-level continuation was involved.
276
+ The `status` field is authoritative (driven by the agent's terminal state, not by parsing `result`), and the exit code mirrors it: `0` only for `complete`. A run that ends without a substantive final answer, after an unresolved final tool failure, or with declared tasks or required validation still unfinished is `failed` even if the provider returned normally; the evidence envelope carries the task counts and validation outcome that gated it. For fixes, red→green evidence is opportunistic: haze does not require a pre-edit failing repro, but if a recognized validation fails before the first mutation, that same command must pass after the fix. Per-turn step/tool budgets are safety boundaries, not completion: haze automatically continues the logical goal in fresh turns while measurable progress remains, so a budget boundary alone never fails a run. `--timeout` bounds the entire logical goal (not each internal turn), and `--until-done` additionally relaunches the goal after transient provider failures (exponential backoff, `goal_resume` events, a three-strike no-progress guard) until it structurally completes or the deadline hits — without granting any extra authority. The result envelope additionally carries a `goal` object (physical turns used, stop reason, total mutations, final validation outcome and task counts) when goal-level continuation was involved, and a bounded `notices` array with the gate decisions the run made (such as pause reasons) so scripts can see why a goal continued or stopped — the same decisions stream live as `goal_notice` events in `--output stream-json`.
270
277
 
271
278
  `--output stream-json` writes progress as the run happens. Each public event is one newline-delimited JSON object on stdout. The last line uses the same `{ type: "result", status, result, usage }` envelope as `--output json`, so consumers can display progress and parse the final result in the same way:
272
279
 
@@ -304,7 +311,7 @@ haze has a small built-in toolset:
304
311
  - `skill` loads an installed Markdown workflow or one of its references.
305
312
  - `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
313
 
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.
314
+ 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
315
 
309
316
  ### Optional LSP navigation
310
317
 
@@ -382,6 +389,7 @@ Most haze behaviour needs no configuration; a few optional keys in `~/.haze/sett
382
389
  - `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
390
  - `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
391
  - `manualCompaction` (`"llm-summary"` default, or `"heuristic"`): whether manual `/compact` asks the active model for a continuity summary or keeps the model-free bounded excerpt.
392
+ - `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
393
 
386
394
  ## Safety model
387
395
 
@@ -392,6 +400,7 @@ Ordinary file and tool output is data, not instructions. The system prompt says
392
400
  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
401
 
394
402
  - Model-selected file tools are restricted to the current workspace and follow `.gitignore` by default.
403
+ - 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
404
  - 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
405
  - 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
406
  - 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.1",
4
+ "commit": "26906fadb2553848b273fc254f2e0f57ba27cd0c",
5
+ "builtAt": "2026-08-26T17:12:54.837Z",
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] }));
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Busy state with a one-second heartbeat. The tick re-renders the elapsed-time
3
+ * label so the developer always sees rolling activity even when the model is
4
+ * thinking with no streamed output and no tool is running (the "looks stuck"
5
+ * problem). Extracted from ChatScreen alongside BusyBar.
6
+ */
7
+ export declare function useBusyIndicator(): {
8
+ busy: boolean;
9
+ setBusy: (nextBusy: boolean) => void;
10
+ elapsed: string;
11
+ };
@@ -0,0 +1,34 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { formatElapsedTimeWhole } from '../../utils/format.js';
3
+ /** Elapsed-time label for the busy indicator heartbeat, or '' when no turn is active. */
4
+ function busyElapsedLabel(startedAt) {
5
+ if (startedAt == null)
6
+ return '';
7
+ const elapsed = Date.now() - startedAt;
8
+ return elapsed > 0 ? formatElapsedTimeWhole(elapsed) : '';
9
+ }
10
+ /**
11
+ * Busy state with a one-second heartbeat. The tick re-renders the elapsed-time
12
+ * label so the developer always sees rolling activity even when the model is
13
+ * thinking with no streamed output and no tool is running (the "looks stuck"
14
+ * problem). Extracted from ChatScreen alongside BusyBar.
15
+ */
16
+ export function useBusyIndicator() {
17
+ const [busy, setBusyState] = useState(false);
18
+ const turnStartedAtRef = useRef(undefined);
19
+ const [, setBusyTick] = useState(0);
20
+ useEffect(() => {
21
+ if (!busy)
22
+ return;
23
+ const heartbeat = setInterval(() => setBusyTick(tick => tick + 1), 1000);
24
+ return () => clearInterval(heartbeat);
25
+ }, [busy]);
26
+ function setBusy(nextBusy) {
27
+ if (nextBusy && !busy)
28
+ turnStartedAtRef.current = Date.now();
29
+ if (!nextBusy)
30
+ turnStartedAtRef.current = undefined;
31
+ setBusyState(nextBusy);
32
+ }
33
+ return { busy, setBusy, elapsed: busyElapsedLabel(turnStartedAtRef.current) };
34
+ }
@@ -3,7 +3,6 @@ import type { Message } from '../commands/streaming.js';
3
3
  import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
4
4
  export declare function toolCallCount(messages: Message[]): number;
5
5
  export declare function compactHomePath(filePath: string, home?: string): string;
6
- export declare function formatTokenCount(tokens: number): string;
7
6
  export declare function displayMessagesFromConversation(conversation: ModelMessage[]): Message[];
8
7
  export declare function estimateConversationTokens(messages: Message[]): {
9
8
  input: number;
@@ -1,5 +1,6 @@
1
1
  import os from 'node:os';
2
2
  import { modelMessageText } from '../../core/agent/compaction.js';
3
+ import { formatTokenCount } from '../../utils/format.js';
3
4
  export function toolCallCount(messages) {
4
5
  return messages.reduce((total, message) => {
5
6
  if (message.role !== 'tool')
@@ -19,13 +20,6 @@ export function compactHomePath(filePath, home = os.homedir()) {
19
20
  return '~';
20
21
  return filePath.startsWith(`${home}/`) ? `~/${filePath.slice(home.length + 1)}` : filePath;
21
22
  }
22
- export function formatTokenCount(tokens) {
23
- if (tokens >= 1_000_000)
24
- return `${(tokens / 1_000_000).toFixed(tokens >= 10_000_000 ? 0 : 1).replace(/\.0$/, '')}m`;
25
- if (tokens >= 1_000)
26
- return `${(tokens / 1_000).toFixed(tokens >= 10_000 ? 0 : 1).replace(/\.0$/, '')}k`;
27
- return String(tokens);
28
- }
29
23
  export function displayMessagesFromConversation(conversation) {
30
24
  return conversation.flatMap(message => {
31
25
  if (message.role !== 'user' && message.role !== 'assistant')
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The follow-up queue for messages submitted while a turn is running (typed
3
+ * input is queued, Esc clears). Extracted from ChatScreen so queue mechanics
4
+ * (ref + mirrored state + transcript notices) live in one place.
5
+ */
6
+ export declare function useFollowUpQueue(addSystemMessage: (text: string) => void): {
7
+ queued: string[];
8
+ queue: (value: string) => void;
9
+ takeNext: () => string | undefined;
10
+ clear: () => void;
11
+ };
@@ -0,0 +1,38 @@
1
+ import { useRef, useState } from 'react';
2
+ /**
3
+ * The follow-up queue for messages submitted while a turn is running (typed
4
+ * input is queued, Esc clears). Extracted from ChatScreen so queue mechanics
5
+ * (ref + mirrored state + transcript notices) live in one place.
6
+ */
7
+ export function useFollowUpQueue(addSystemMessage) {
8
+ const queueRef = useRef([]);
9
+ const [queued, setQueued] = useState([]);
10
+ /** Queue a submitted value; empty values are ignored. */
11
+ function queue(value) {
12
+ const trimmed = value.trim();
13
+ if (!trimmed)
14
+ return;
15
+ queueRef.current = [...queueRef.current, trimmed];
16
+ setQueued(queueRef.current);
17
+ addSystemMessage(`Queued follow-up (${queueRef.current.length}): ${trimmed}`);
18
+ }
19
+ /** Dequeue the next follow-up (announcing it), or undefined when empty. */
20
+ function takeNext() {
21
+ const next = queueRef.current[0];
22
+ if (next === undefined)
23
+ return undefined;
24
+ queueRef.current = queueRef.current.slice(1);
25
+ setQueued(queueRef.current);
26
+ addSystemMessage(`Running queued follow-up: ${next}`);
27
+ return next;
28
+ }
29
+ /** Drop every queued follow-up (user interrupt); reports the clear when anything was dropped. */
30
+ function clear() {
31
+ if (queueRef.current.length === 0)
32
+ return;
33
+ queueRef.current = [];
34
+ setQueued([]);
35
+ addSystemMessage('Cleared queued follow-ups after interrupt.');
36
+ }
37
+ return { queued, queue, takeNext, clear };
38
+ }
@@ -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' },
@@ -14,25 +14,3 @@ export declare const MessageView: React.MemoExoticComponent<({ message, width, s
14
14
  showHeader?: boolean;
15
15
  maxVisibleLines?: number;
16
16
  }) => React.JSX.Element>;
17
- export type TranscriptStaticItem = {
18
- kind: 'message';
19
- key: string;
20
- message: Message;
21
- } | {
22
- kind: 'assistant-markdown';
23
- key: string;
24
- message: Message;
25
- content: string;
26
- first: boolean;
27
- final: boolean;
28
- };
29
- export type TranscriptStreamingItem = {
30
- key: string;
31
- message: Message;
32
- showHeader?: boolean;
33
- };
34
- /** Partition display messages into append-only static Markdown roots and the active streaming tail. */
35
- export declare function partitionDisplayMessages(messages: Message[]): {
36
- staticItems: TranscriptStaticItem[];
37
- streamingItems: TranscriptStreamingItem[];
38
- };
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import React from 'react';
3
3
  import { Box, Text } from 'ink';
4
4
  import Spinner from 'ink-spinner';
5
- import { formatElapsedTime, formatElapsedTimeWhole } from '../commands/formatters.js';
6
- import { MarkdownText, markdownRootChunks } from '../../ui/components/MarkdownText.js';
7
- import { lineRows, clampTextTail } from './liveRegion.js';
5
+ import { formatElapsedTime, formatElapsedTimeWhole } from '../../utils/format.js';
6
+ import { MarkdownText } from '../../ui/components/MarkdownText.js';
7
+ import { clampTextTail, wrapLine } from './liveRegion.js';
8
8
  import { isSubstantiveAssistantText } from '../commands/streaming/assistantText.js';
9
9
  import { theme } from '../../ui/theme.js';
10
10
  import { highlightedCodeLine, languageForPath } from '../../ui/codeHighlight.js';
@@ -88,6 +88,22 @@ function ToolDiffView({ diff, width }) {
88
88
  function toolDiffRows(diff) {
89
89
  return 1 + diff.lines.length + (diff.handle ? 1 : 0) + (diff.complete === false ? 1 : 0) + 1;
90
90
  }
91
+ const TOOL_ROW_PATTERN = /^(\s*)([✓✗…])\s+(\S+)(.*)$/;
92
+ /**
93
+ * Wrapped display rows for one tool-group line. Ink's wrapping has no hanging
94
+ * indent, so icon rows are pre-wrapped here (mirroring Ink's own wrap-ansi
95
+ * settings, see liveRegion.ts) and continuation rows are padded to align
96
+ * under the tool name instead of dropping back to the left edge.
97
+ */
98
+ function toolGroupLineRows(line, width) {
99
+ const match = TOOL_ROW_PATTERN.exec(line);
100
+ if (!match)
101
+ return wrapLine(line, width);
102
+ const [, indent, icon, toolName, rest] = match;
103
+ const hang = indent.length + 2; // icon + separating space
104
+ const rows = wrapLine(`${toolName}${rest}`, Math.max(1, width - hang));
105
+ return rows.map((row, index) => (index === 0 ? `${indent}${icon} ${row}` : `${' '.repeat(hang)}${row}`));
106
+ }
91
107
  /**
92
108
  * Live-region clamp for the streaming tool group (see liveRegion.ts): keep only
93
109
  * the rows that fit the viewport budget, dropping whole logical lines from the
@@ -99,7 +115,9 @@ function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines }) {
99
115
  const allDiffs = toolDiffs ?? [];
100
116
  if (maxVisibleLines == null)
101
117
  return { lines: allLines, hiddenTextRowCount: 0, visibleDiffs: allDiffs, hiddenDiffCount: 0 };
102
- const rows = allLines.map(line => lineRows(line, width));
118
+ // Row counts must mirror toolGroupLineRows so the budget matches what is
119
+ // actually rendered (icon rows consume one extra hang indent column).
120
+ const rows = allLines.map(line => toolGroupLineRows(line, width).length);
103
121
  const total = rows.reduce((sum, count) => sum + count, 0);
104
122
  let lines = allLines;
105
123
  let hiddenTextRowCount = 0;
@@ -134,17 +152,26 @@ function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines }) {
134
152
  }
135
153
  function ToolMessageText({ text, streaming, width, toolDiffs, maxVisibleLines }) {
136
154
  const clamped = clampToolDisplay({ text, width, toolDiffs, maxVisibleLines });
137
- const lines = clamped.lines;
138
- return _jsxs(Box, { flexDirection: "column", children: [clamped.hiddenTextRowCount > 0 ? _jsx(Text, { color: theme.muted, children: `⋯ +${clamped.hiddenTextRowCount} line${clamped.hiddenTextRowCount === 1 ? '' : 's'} above` }) : null, lines.map((line, index) => {
139
- const row = /^(\s*)([✓✗…])\s+(\S+)(.*)$/.exec(line);
140
- if (!row) {
141
- const timer = /(.*) (\([0-9]+(?:h [0-9]+m [0-9]+(?:\.[0-9])?s|m [0-9]+(?:\.[0-9])?s|(?:\.[0-9])?s)\))$/.exec(line);
142
- 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}`);
155
+ return _jsxs(Box, { flexDirection: "column", children: [clamped.hiddenTextRowCount > 0 ? _jsx(Text, { color: theme.muted, children: `⋯ +${clamped.hiddenTextRowCount} line${clamped.hiddenTextRowCount === 1 ? '' : 's'} above` }) : null, clamped.lines.flatMap((line, index) => {
156
+ const match = TOOL_ROW_PATTERN.exec(line);
157
+ if (!match) {
158
+ // Summary header / caption rows: plain muted rows (spinner on the
159
+ // first row while streaming).
160
+ return toolGroupLineRows(line, width).map((row, rowIndex) => _jsxs(Text, { color: theme.muted, children: [index === 0 && rowIndex === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null, row] }, `${index}-${rowIndex}`));
143
161
  }
144
- const [, indent, icon, toolName, rest] = row;
162
+ const [, indent, icon, toolName] = match;
145
163
  const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
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}`);
164
+ const hang = indent.length + 2; // icon + separating space
165
+ return toolGroupLineRows(line, width).map((row, rowIndex) => {
166
+ // Rows already carry their prefix; slice the content off to re-apply
167
+ // icon/tool-name colors on the first row.
168
+ const content = row.slice(hang);
169
+ return rowIndex === 0
170
+ ? _jsxs(Text, { color: theme.muted, children: [indent, _jsx(Text, { color: iconColor, children: icon }), " ", _jsx(Text, { color: theme.accent, children: content.slice(0, toolName.length) }), content.slice(toolName.length)] }, `${index}-${rowIndex}`)
171
+ // Continuation rows keep the hanging indent so wrapped tool lines
172
+ // stay aligned under the tool name.
173
+ : _jsx(Text, { color: theme.muted, children: row }, `${index}-${rowIndex}`);
174
+ });
148
175
  }), 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
176
  }
150
177
  export function messageElapsedLabel(message) {
@@ -161,7 +188,7 @@ export function messageElapsedLabel(message) {
161
188
  }
162
189
  export const AssistantMarkdownChunkView = React.memo(function AssistantMarkdownChunkView({ message, content, width, first, final }) {
163
190
  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] });
191
+ 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
192
  });
166
193
  /** Streaming assistant tail clamped to the live-region budget; the full text enters the static transcript once the root settles. */
167
194
  function StreamingClampedText({ text, width, maxVisibleLines }) {
@@ -172,7 +199,7 @@ export const MessageView = React.memo(function MessageView({ message, width, sho
172
199
  if (message.role === 'user') {
173
200
  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
201
  }
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'
202
+ 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
203
  ? _jsx(ToolMessageText, { text: message.text, streaming: message.streaming, width: width, toolDiffs: message.toolDiffs, maxVisibleLines: message.streaming ? maxVisibleLines : undefined })
177
204
  : message.role === 'assistant' && !message.streaming
178
205
  // Only settled assistant messages get Markdown rendering. Streaming
@@ -185,75 +212,3 @@ export const MessageView = React.memo(function MessageView({ message, width, sho
185
212
  ? _jsx(StreamingClampedText, { text: message.text, width: width, maxVisibleLines: maxVisibleLines })
186
213
  : _jsx(Text, { children: message.text })] });
187
214
  });
188
- function messageKey(message, index) {
189
- return message.id ?? `${index}-${message.role}-${message.text}`;
190
- }
191
- /** Partition display messages into append-only static Markdown roots and the active streaming tail. */
192
- export function partitionDisplayMessages(messages) {
193
- const staticItems = [];
194
- const streamingItems = [];
195
- let reachedDynamicTail = false;
196
- orderedDisplayMessages(messages).forEach((message, index) => {
197
- const key = messageKey(message, index);
198
- // Static output must remain an ordered prefix. A settled notification that
199
- // follows live text stays in the dynamic frame until that text is complete.
200
- if (reachedDynamicTail) {
201
- streamingItems.push({ key, message });
202
- return;
203
- }
204
- if (message.role !== 'assistant') {
205
- if (message.streaming) {
206
- reachedDynamicTail = true;
207
- streamingItems.push({ key, message });
208
- }
209
- else {
210
- staticItems.push({ kind: 'message', key, message });
211
- }
212
- return;
213
- }
214
- const chunks = markdownRootChunks(message.text);
215
- if (chunks.length === 0) {
216
- if (message.streaming) {
217
- reachedDynamicTail = true;
218
- streamingItems.push({ key, message });
219
- }
220
- else {
221
- staticItems.push({ kind: 'message', key, message });
222
- }
223
- return;
224
- }
225
- // Marked may still reclassify the final root while the stream grows. Keep
226
- // only that root dynamic; every preceding root is now safe to append once.
227
- const staticChunkCount = message.streaming ? Math.max(0, chunks.length - 1) : chunks.length;
228
- for (let chunkIndex = 0; chunkIndex < staticChunkCount; chunkIndex++) {
229
- staticItems.push({
230
- kind: 'assistant-markdown',
231
- key: `${key}-markdown-${chunkIndex}`,
232
- message,
233
- content: chunks[chunkIndex] ?? '',
234
- first: chunkIndex === 0,
235
- final: !message.streaming && chunkIndex === chunks.length - 1,
236
- });
237
- }
238
- if (message.streaming) {
239
- reachedDynamicTail = true;
240
- streamingItems.push({
241
- key,
242
- message: { ...message, text: chunks.at(-1) ?? message.text },
243
- showHeader: staticChunkCount === 0,
244
- });
245
- }
246
- });
247
- return { staticItems, streamingItems };
248
- }
249
- function orderedDisplayMessages(messages) {
250
- return messages
251
- .map((message, index) => ({ message, index }))
252
- .sort((a, b) => {
253
- if (a.message.displayOrder != null && b.message.displayOrder != null && a.message.displayOrder !== b.message.displayOrder) {
254
- return a.message.displayOrder - b.message.displayOrder;
255
- }
256
- return a.index - b.index;
257
- })
258
- .map(item => item.message);
259
- }
@@ -1,7 +1,7 @@
1
1
  import type { ModelMessage } from 'ai';
2
2
  import type { ContextFile } from '../../config/contextFiles.js';
3
3
  import type { WorkState } from '../../core/agent/workState.js';
4
- import { type HazeSession } from '../../core/session/sessionStore.js';
4
+ import { type GoalLedgerFrontier, type HazeSession } from '../../core/session/sessionStore.js';
5
5
  import { type LlmLog } from '../../core/log/llmLog.js';
6
6
  import type { Message } from '../commands/streaming.js';
7
7
  import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
@@ -51,6 +51,8 @@ export interface SessionLifecycleDeps {
51
51
  setTokenUsage: (usage: TokenUsage) => void;
52
52
  /** Manual /compact mode: model-written summary (default) or heuristic excerpt. */
53
53
  manualCompaction?: () => 'llm-summary' | 'heuristic';
54
+ /** Called when a resumed session carries an unterminated goal frontier (P1): the UI offers the one-key continue. */
55
+ onGoalFrontier?: (frontier: GoalLedgerFrontier) => void;
54
56
  debugLog: (line: string) => void;
55
57
  showPersistenceWarning: (error: unknown) => void;
56
58
  }
@@ -44,7 +44,7 @@ export function createSessionLifecycle(deps) {
44
44
  });
45
45
  }
46
46
  async function resumeSession(session, replaceTranscript) {
47
- const { messages: conversation, workState, parseErrors } = await restoreSessionState(session);
47
+ const { messages: conversation, workState, parseErrors, goalFrontier } = await restoreSessionState(session);
48
48
  deps.sessionRef.current = session;
49
49
  deps.conversationRef.current = conversation;
50
50
  deps.setLiveMessagesState(() => []);
@@ -58,6 +58,11 @@ export function createSessionLifecycle(deps) {
58
58
  const restored = [{ role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...restoredMessages];
59
59
  return replaceTranscript ? restored : [...messages, ...restored];
60
60
  });
61
+ // P1 resume path: a durable, unterminated goal frontier surfaces in the
62
+ // resume flow (system note + one-key continue, mirroring the R-resume UX)
63
+ // instead of silently starting fresh.
64
+ if (goalFrontier)
65
+ deps.onGoalFrontier?.(goalFrontier);
61
66
  }
62
67
  /** Heuristic-excerpt compaction shared by the sync path and the LLM fallback (F-09). */
63
68
  function compactConversationSync(instructions) {
@@ -1,5 +1,6 @@
1
1
  import type { ModelMessage } from 'ai';
2
2
  import { type HazeSession } from '../../core/session/sessionStore.js';
3
+ import type { GoalLedgerAppend } from '../commands/streaming/goalCheckpoint.js';
3
4
  import type { AgentEvent } from '../../core/agent/events.js';
4
5
  import type { WorkState } from '../../core/agent/workState.js';
5
6
  import type { Message } from '../commands/streaming.js';
@@ -8,6 +9,7 @@ export declare function createSessionRecorder(getSession: () => HazeSession | un
8
9
  recordConversation(messages: ModelMessage[]): void;
9
10
  recordWorkState(state: WorkState): void;
10
11
  recordEvent(event: AgentEvent): void;
12
+ recordGoalEntry(entry: GoalLedgerAppend): void;
11
13
  recordNamedEvent(name: string, text: string): void;
12
14
  flush(): Promise<void>;
13
15
  error(): Error | undefined;
@@ -80,6 +80,12 @@ export function createSessionRecorder(getSession) {
80
80
  return;
81
81
  appendEntry({ type: 'event', at: event.at, name: event.type, text: JSON.stringify(event) });
82
82
  },
83
+ // Durable goal-ledger append (P1): the supervisor calls this once per
84
+ // boundary (start/continue/end); the append-only frontier is the last
85
+ // non-terminal entry, and a truncated tail line parses as absent.
86
+ recordGoalEntry(entry) {
87
+ appendEntry({ type: 'goal', at: new Date().toISOString(), ...entry });
88
+ },
83
89
  recordNamedEvent(name, text) {
84
90
  appendEntry({ type: 'event', at: new Date().toISOString(), name, text });
85
91
  },