@denizokcu/haze 1.1.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.
- package/CHANGELOG.md +24 -1
- package/README.md +9 -5
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/busyIndicator.d.ts +11 -0
- package/dist/cli/chat/busyIndicator.js +34 -0
- package/dist/cli/chat/chatMetrics.d.ts +0 -1
- package/dist/cli/chat/chatMetrics.js +1 -7
- package/dist/cli/chat/followUpQueue.d.ts +11 -0
- package/dist/cli/chat/followUpQueue.js +38 -0
- package/dist/cli/chat/messages.d.ts +0 -22
- package/dist/cli/chat/messages.js +40 -85
- package/dist/cli/chat/sessionLifecycle.d.ts +3 -1
- package/dist/cli/chat/sessionLifecycle.js +6 -1
- package/dist/cli/chat/sessionRecorder.d.ts +2 -0
- package/dist/cli/chat/sessionRecorder.js +6 -0
- package/dist/cli/chat/startupSequence.d.ts +29 -0
- package/dist/cli/chat/startupSequence.js +59 -0
- package/dist/cli/chat/transcriptPartition.d.ts +23 -0
- package/dist/cli/chat/transcriptPartition.js +78 -0
- package/dist/cli/chat/wizard/fieldTransitions.d.ts +38 -0
- package/dist/cli/chat/wizard/fieldTransitions.js +43 -0
- package/dist/cli/chat/wizard/lspHandlers.d.ts +4 -0
- package/dist/cli/chat/wizard/lspHandlers.js +85 -0
- package/dist/cli/chat/wizard/mcpHandlers.d.ts +8 -0
- package/dist/cli/chat/wizard/mcpHandlers.js +82 -0
- package/dist/cli/chat/wizard/providerHandlers.d.ts +12 -0
- package/dist/cli/chat/wizard/providerHandlers.js +420 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.d.ts +4 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +48 -0
- package/dist/cli/chat/wizard/skillsHandlers.d.ts +4 -0
- package/dist/cli/chat/wizard/skillsHandlers.js +125 -0
- package/dist/cli/chat/wizard/types.d.ts +63 -0
- package/dist/cli/chat/wizard/types.js +24 -0
- package/dist/cli/chat/wizard/uiState.d.ts +56 -0
- package/dist/cli/chat/wizard/uiState.js +15 -0
- package/dist/cli/chat/wizardDispatch.d.ts +11 -113
- package/dist/cli/chat/wizardDispatch.js +41 -815
- package/dist/cli/commands/chat.js +45 -108
- package/dist/cli/commands/formatters.d.ts +0 -3
- package/dist/cli/commands/formatters.js +0 -29
- package/dist/cli/commands/runCommand.d.ts +2 -0
- package/dist/cli/commands/runCommand.js +67 -4
- package/dist/cli/commands/streaming/assistantSegments.d.ts +19 -0
- package/dist/cli/commands/streaming/assistantSegments.js +48 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -2
- package/dist/cli/commands/streaming/attemptOutcome.js +17 -7
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +69 -8
- package/dist/cli/commands/streaming/goalCheckpoint.js +36 -1
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +17 -2
- package/dist/cli/commands/streaming/goalSupervisor.js +62 -12
- package/dist/cli/commands/streaming/prepareStep.d.ts +35 -0
- package/dist/cli/commands/streaming/prepareStep.js +100 -0
- package/dist/cli/commands/streaming/recoverySlices.d.ts +15 -0
- package/dist/cli/commands/streaming/recoverySlices.js +29 -0
- package/dist/cli/commands/streaming/stallRecovery.d.ts +0 -1
- package/dist/cli/commands/streaming/stallRecovery.js +0 -4
- package/dist/cli/commands/streaming/streamLoop.js +9 -230
- package/dist/cli/commands/streaming/toolGroupRenderer.js +2 -1
- package/dist/cli/commands/streaming/toolPartHandlers.d.ts +19 -0
- package/dist/cli/commands/streaming/toolPartHandlers.js +95 -0
- package/dist/cli/commands/streaming.d.ts +4 -1
- package/dist/cli/commands/streaming.js +6 -21
- package/dist/cli/index.js +3 -1
- package/dist/config/providerPresets.d.ts +7 -0
- package/dist/config/providerPresets.js +195 -391
- package/dist/core/agent/completionController.d.ts +14 -7
- package/dist/core/agent/completionController.js +12 -6
- package/dist/core/agent/events.d.ts +12 -0
- package/dist/core/agent/goalPolicy.d.ts +4 -3
- package/dist/core/agent/goalPolicy.js +9 -4
- package/dist/core/agent/workState.d.ts +25 -15
- package/dist/core/agent/workState.js +71 -43
- package/dist/core/session/sessionSlimming.js +8 -0
- package/dist/core/session/sessionStore.d.ts +61 -1
- package/dist/core/session/sessionStore.js +115 -6
- package/dist/llm/hazeTools.d.ts +64 -208
- package/dist/llm/tools/taskTool.d.ts +64 -208
- package/dist/llm/tools/taskTool.js +22 -10
- package/dist/ui/components/TextInput.js +6 -67
- package/dist/ui/components/useInputSuggestions.d.ts +27 -0
- package/dist/ui/components/useInputSuggestions.js +98 -0
- package/dist/ui/theme.d.ts +8 -8
- package/dist/ui/theme.js +11 -12
- package/dist/ui/themes/registry.d.ts +5 -0
- package/dist/ui/themes/registry.js +436 -0
- package/dist/utils/format.d.ts +10 -0
- package/dist/utils/format.js +45 -0
- package/package.json +1 -1
- package/dist/ui/themes/af-magic.d.ts +0 -7
- package/dist/ui/themes/af-magic.js +0 -25
- package/dist/ui/themes/agnoster.d.ts +0 -10
- package/dist/ui/themes/agnoster.js +0 -40
- package/dist/ui/themes/bira.d.ts +0 -10
- package/dist/ui/themes/bira.js +0 -28
- package/dist/ui/themes/bureau.d.ts +0 -10
- package/dist/ui/themes/bureau.js +0 -28
- package/dist/ui/themes/clean.d.ts +0 -9
- package/dist/ui/themes/clean.js +0 -27
- package/dist/ui/themes/cloud.d.ts +0 -6
- package/dist/ui/themes/cloud.js +0 -24
- package/dist/ui/themes/dst.d.ts +0 -10
- package/dist/ui/themes/dst.js +0 -28
- package/dist/ui/themes/fishy.d.ts +0 -7
- package/dist/ui/themes/fishy.js +0 -25
- package/dist/ui/themes/index.d.ts +0 -8
- package/dist/ui/themes/index.js +0 -36
- package/dist/ui/themes/light.d.ts +0 -3
- package/dist/ui/themes/light.js +0 -21
- package/dist/ui/themes/purple.d.ts +0 -7
- package/dist/ui/themes/purple.js +0 -26
- package/dist/ui/themes/robbyrussell.d.ts +0 -8
- package/dist/ui/themes/robbyrussell.js +0 -26
- package/dist/ui/themes/solarized-dark.d.ts +0 -16
- package/dist/ui/themes/solarized-dark.js +0 -44
- package/dist/ui/themes/solarized-light.d.ts +0 -12
- package/dist/ui/themes/solarized-light.js +0 -40
- package/dist/ui/themes/steeef.d.ts +0 -11
- package/dist/ui/themes/steeef.js +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
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
|
+
|
|
3
26
|
## 1.1.0 - 2026-08-19
|
|
4
27
|
|
|
5
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.
|
|
6
29
|
|
|
7
30
|
### Added
|
|
8
31
|
|
|
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.
|
|
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`.
|
|
10
33
|
|
|
11
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.
|
|
12
35
|
|
package/README.md
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
A minimal LLM harness for your terminal.
|
|
4
4
|
|
|
5
|
-
## What's new in 1.1.
|
|
5
|
+
## What's new in 1.1.1
|
|
6
6
|
|
|
7
|
-
haze 1.1.
|
|
7
|
+
haze 1.1.1 makes long-running goals resumable while keeping the autonomy core small and evidence-based.
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
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.
|
|
11
13
|
|
|
12
14
|
Previous releases:
|
|
13
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.
|
|
14
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).
|
|
15
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.
|
|
16
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.
|
|
@@ -243,6 +246,7 @@ haze -p "summarize this repo" --model openai:gpt-4o-mini
|
|
|
243
246
|
haze --resume <id> -p "continue the investigation"
|
|
244
247
|
haze -p "list the top 3 bugs in src/api.ts" --output json
|
|
245
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
|
|
246
250
|
echo "what does this project do?" | haze
|
|
247
251
|
```
|
|
248
252
|
|
|
@@ -269,7 +273,7 @@ If you pipe stdin without `-p`, haze reads the prompt from stdin. Piped prompts
|
|
|
269
273
|
}
|
|
270
274
|
```
|
|
271
275
|
|
|
272
|
-
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
|
|
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`.
|
|
273
277
|
|
|
274
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:
|
|
275
279
|
|
package/dist/buildInfo.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denizokcu/haze",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"commit": "
|
|
5
|
-
"builtAt": "2026-08-
|
|
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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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 '
|
|
6
|
-
import { MarkdownText
|
|
7
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return _jsxs(Text, { color: theme.muted, children: [index === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null,
|
|
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
|
|
162
|
+
const [, indent, icon, toolName] = match;
|
|
145
163
|
const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
|
|
146
|
-
const
|
|
147
|
-
return
|
|
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) {
|
|
@@ -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
|
},
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ContextFile } from '../../config/contextFiles.js';
|
|
2
|
+
import { type HazeSettings } from '../../config/settings.js';
|
|
3
|
+
/** Current git branch name for the workspace header, or undefined outside a repo/branch. */
|
|
4
|
+
export declare function currentBranchName(): Promise<string | undefined>;
|
|
5
|
+
/** What the startup sequence loaded from disk, handed to the screen before the slower steps run. */
|
|
6
|
+
export interface StartupLoadedState {
|
|
7
|
+
settings: HazeSettings;
|
|
8
|
+
settingsError?: string;
|
|
9
|
+
branchName?: string;
|
|
10
|
+
contextFiles: ContextFile[];
|
|
11
|
+
}
|
|
12
|
+
export interface StartupSequenceOptions {
|
|
13
|
+
/** CLI version; when set, an update check runs and outdated builds are reported. */
|
|
14
|
+
version?: string;
|
|
15
|
+
/** Receives the loaded settings/branch/context files as soon as they are read. */
|
|
16
|
+
onLoaded: (loaded: StartupLoadedState) => void;
|
|
17
|
+
/** Session init/continue/resume controller from the screen. */
|
|
18
|
+
initializeSession: () => Promise<void>;
|
|
19
|
+
/** Reloads the skill registry (also reports project-skill and error signatures). */
|
|
20
|
+
refreshSkills: () => Promise<unknown>;
|
|
21
|
+
addSystemMessage: (text: string) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The chat screen's startup sequence, extracted so ChatScreen stays rendering
|
|
25
|
+
* glue: load settings/branch/context files, show the startup banner, initialize
|
|
26
|
+
* the session, load skills, check for updates, and surface runtime diagnostics.
|
|
27
|
+
* Every step degrades to a system message instead of blocking startup.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runStartupSequence(options: StartupSequenceOptions): Promise<void>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { execFile as execFileCallback } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { readContextFiles } from '../../config/contextFiles.js';
|
|
4
|
+
import { readSettings } from '../../config/settings.js';
|
|
5
|
+
import { checkForUpdate } from '../../config/updateCheck.js';
|
|
6
|
+
import { detectCheckoutMismatch, formatMismatchWarning, runtimeCapabilities } from '../../utils/buildInfo.js';
|
|
7
|
+
import { startupContextInfo, startupProviderInfo } from './startupInfo.js';
|
|
8
|
+
const execFile = promisify(execFileCallback);
|
|
9
|
+
/** Current git branch name for the workspace header, or undefined outside a repo/branch. */
|
|
10
|
+
export async function currentBranchName() {
|
|
11
|
+
try {
|
|
12
|
+
const { stdout } = await execFile('git', ['branch', '--show-current'], { cwd: process.cwd() });
|
|
13
|
+
return stdout.trim() || undefined;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The chat screen's startup sequence, extracted so ChatScreen stays rendering
|
|
21
|
+
* glue: load settings/branch/context files, show the startup banner, initialize
|
|
22
|
+
* the session, load skills, check for updates, and surface runtime diagnostics.
|
|
23
|
+
* Every step degrades to a system message instead of blocking startup.
|
|
24
|
+
*/
|
|
25
|
+
export async function runStartupSequence(options) {
|
|
26
|
+
const [settingsResult, branch, files] = await Promise.all([
|
|
27
|
+
readSettings().then(value => ({ value, error: undefined })).catch(error => ({ value: {}, error: error instanceof Error ? error.message : String(error) })),
|
|
28
|
+
currentBranchName().catch(() => undefined),
|
|
29
|
+
readContextFiles().catch(() => []),
|
|
30
|
+
]);
|
|
31
|
+
options.onLoaded({
|
|
32
|
+
settings: settingsResult.value,
|
|
33
|
+
settingsError: settingsResult.error,
|
|
34
|
+
branchName: branch,
|
|
35
|
+
contextFiles: files,
|
|
36
|
+
});
|
|
37
|
+
const next = settingsResult.value;
|
|
38
|
+
options.addSystemMessage(settingsResult.error ? settingsResult.error : `${startupProviderInfo(next)}\n\n${startupContextInfo(files)}`);
|
|
39
|
+
await options.initializeSession().catch(error => {
|
|
40
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
41
|
+
options.addSystemMessage(`Session disabled: ${text}`);
|
|
42
|
+
});
|
|
43
|
+
await options.refreshSkills().catch(() => undefined);
|
|
44
|
+
if (options.version) {
|
|
45
|
+
const result = await checkForUpdate({ currentVersion: options.version, packageName: '@denizokcu/haze' }).catch(() => undefined);
|
|
46
|
+
if (result?.isOutdated) {
|
|
47
|
+
options.addSystemMessage(`A new version of haze is available: ${result.latestVersion} (you have ${options.version}). Update with: npm i -g @denizokcu/haze`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Runtime/installation diagnostics: never switch runtimes silently, but
|
|
51
|
+
// make a stale binary serving a workspace with a newer checkout unmistakable.
|
|
52
|
+
const mismatch = detectCheckoutMismatch();
|
|
53
|
+
if (mismatch) {
|
|
54
|
+
options.addSystemMessage(formatMismatchWarning(mismatch));
|
|
55
|
+
}
|
|
56
|
+
else if (!runtimeCapabilities().goalSupervisorAvailable) {
|
|
57
|
+
options.addSystemMessage('Warning: this haze build lacks the goal supervisor module; exhausting a turn step/tool budget may pause the goal instead of continuing automatically. Reinstall or relink haze (npm run dev:link in the checkout).');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Message } from '../commands/streaming.js';
|
|
2
|
+
export type TranscriptStaticItem = {
|
|
3
|
+
kind: 'message';
|
|
4
|
+
key: string;
|
|
5
|
+
message: Message;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'assistant-markdown';
|
|
8
|
+
key: string;
|
|
9
|
+
message: Message;
|
|
10
|
+
content: string;
|
|
11
|
+
first: boolean;
|
|
12
|
+
final: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type TranscriptStreamingItem = {
|
|
15
|
+
key: string;
|
|
16
|
+
message: Message;
|
|
17
|
+
showHeader?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Partition display messages into append-only static Markdown roots and the active streaming tail. */
|
|
20
|
+
export declare function partitionDisplayMessages(messages: Message[]): {
|
|
21
|
+
staticItems: TranscriptStaticItem[];
|
|
22
|
+
streamingItems: TranscriptStreamingItem[];
|
|
23
|
+
};
|