@denizokcu/haze 1.7.11 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +142 -102
  3. package/SECURITY.md +1 -1
  4. package/assets/graph-grammars/NOTICE.md +21 -0
  5. package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
  6. package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
  7. package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
  8. package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
  9. package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
  10. package/assets/graph-grammars/web-tree-sitter.js +4056 -0
  11. package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
  12. package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
  13. package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
  14. package/bin/haze.js +47 -19
  15. package/dist/buildInfo.json +3 -3
  16. package/dist/cli/chat/BusyBar.d.ts +1 -2
  17. package/dist/cli/chat/ChatHeader.d.ts +6 -0
  18. package/dist/cli/chat/ChatHeader.js +11 -0
  19. package/dist/cli/chat/ChatScreen.d.ts +16 -0
  20. package/dist/cli/chat/ChatScreen.js +399 -0
  21. package/dist/cli/chat/ChatScreenView.d.ts +68 -0
  22. package/dist/cli/chat/ChatScreenView.js +47 -0
  23. package/dist/cli/chat/LiveTail.d.ts +11 -0
  24. package/dist/cli/chat/LiveTail.js +26 -0
  25. package/dist/cli/chat/TaskBar.d.ts +3 -2
  26. package/dist/cli/chat/TaskBar.js +4 -0
  27. package/dist/cli/chat/agentTurnRunner.d.ts +12 -0
  28. package/dist/cli/chat/agentTurnRunner.js +177 -0
  29. package/dist/cli/chat/busyIndicator.js +9 -5
  30. package/dist/cli/chat/chatMetrics.d.ts +7 -0
  31. package/dist/cli/chat/chatMetrics.js +15 -1
  32. package/dist/cli/chat/chatViewModel.d.ts +85 -0
  33. package/dist/cli/chat/chatViewModel.js +66 -0
  34. package/dist/cli/chat/fileMentionSuggestions.d.ts +0 -14
  35. package/dist/cli/chat/fileMentionSuggestions.js +4 -21
  36. package/dist/cli/chat/inputSuggestions.js +1 -0
  37. package/dist/cli/chat/liveTheme.d.ts +11 -0
  38. package/dist/cli/chat/liveTheme.js +26 -0
  39. package/dist/cli/chat/messageFinalize.d.ts +4 -0
  40. package/dist/cli/chat/messageFinalize.js +8 -0
  41. package/dist/cli/chat/messages.js +1 -1
  42. package/dist/cli/chat/pickerOpeners.d.ts +23 -0
  43. package/dist/cli/chat/pickerOpeners.js +36 -0
  44. package/dist/cli/chat/promptSessionState.d.ts +11 -0
  45. package/dist/cli/chat/promptSessionState.js +39 -0
  46. package/dist/cli/chat/renderMetrics.d.ts +8 -0
  47. package/dist/cli/chat/renderMetrics.js +14 -0
  48. package/dist/cli/chat/resizeGuard.d.ts +11 -0
  49. package/dist/cli/chat/resizeGuard.js +25 -0
  50. package/dist/cli/chat/screenDeps.d.ts +116 -0
  51. package/dist/cli/chat/screenDeps.js +1 -0
  52. package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
  53. package/dist/cli/chat/sessionLifecycle.js +6 -2
  54. package/dist/cli/chat/sessionRecorder.js +4 -1
  55. package/dist/cli/chat/settingsSelection.d.ts +33 -0
  56. package/dist/cli/chat/settingsSelection.js +46 -0
  57. package/dist/cli/chat/skillNotices.d.ts +18 -0
  58. package/dist/cli/chat/skillNotices.js +26 -0
  59. package/dist/cli/chat/startupInfo.js +1 -1
  60. package/dist/cli/chat/startupSequence.d.ts +2 -0
  61. package/dist/cli/chat/startupSequence.js +6 -0
  62. package/dist/cli/chat/submitPipeline.d.ts +8 -0
  63. package/dist/cli/chat/submitPipeline.js +141 -0
  64. package/dist/cli/chat/terminalControl.js +1 -1
  65. package/dist/cli/chat/toolSummaries.d.ts +29 -0
  66. package/dist/cli/chat/toolSummaries.js +268 -0
  67. package/dist/cli/chat/turnState.d.ts +8 -0
  68. package/dist/cli/chat/turnState.js +1 -0
  69. package/dist/cli/chat/userCommandFlow.d.ts +21 -0
  70. package/dist/cli/chat/userCommandFlow.js +66 -0
  71. package/dist/cli/chat/userCommandRunner.d.ts +14 -0
  72. package/dist/cli/chat/userCommandRunner.js +56 -0
  73. package/dist/cli/chat/wizard/providerHandlers.js +19 -2
  74. package/dist/cli/chat/wizardTrail.d.ts +22 -0
  75. package/dist/cli/chat/wizardTrail.js +55 -0
  76. package/dist/cli/commands/chat.d.ts +1 -13
  77. package/dist/cli/commands/chat.js +10 -795
  78. package/dist/cli/commands/commandHelp.js +11 -6
  79. package/dist/cli/commands/commandSuggest.d.ts +2 -0
  80. package/dist/cli/commands/commandSuggest.js +35 -0
  81. package/dist/cli/commands/commands.js +12 -3
  82. package/dist/cli/commands/formatters.d.ts +1 -23
  83. package/dist/cli/commands/formatters.js +3 -224
  84. package/dist/cli/commands/graphCommand.d.ts +2 -0
  85. package/dist/cli/commands/graphCommand.js +60 -0
  86. package/dist/cli/commands/initCommand.js +14 -0
  87. package/dist/cli/commands/modelCommand.js +11 -7
  88. package/dist/cli/commands/reasoningCommand.js +3 -3
  89. package/dist/cli/commands/runCommand.js +6 -2
  90. package/dist/cli/commands/streaming/agentAttempt.js +11 -1
  91. package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
  92. package/dist/cli/commands/streaming/attemptOutcome.js +8 -3
  93. package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
  94. package/dist/cli/commands/streaming/attemptSetup.js +34 -5
  95. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
  96. package/dist/cli/commands/streaming/goalSupervisor.js +5 -3
  97. package/dist/cli/commands/streaming/prepareStep.js +1 -0
  98. package/dist/cli/commands/streaming/stepProjection.d.ts +59 -0
  99. package/dist/cli/commands/streaming/stepProjection.js +54 -0
  100. package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
  101. package/dist/cli/commands/streaming/streamLoop.js +34 -23
  102. package/dist/cli/commands/streaming/toolGroupRenderer.js +1 -1
  103. package/dist/cli/commands/streaming/toolPartHandlers.js +8 -2
  104. package/dist/cli/commands/streaming.d.ts +3 -1
  105. package/dist/cli/commands/streaming.js +5 -0
  106. package/dist/cli/commands/wizardFlow.d.ts +2 -0
  107. package/dist/cli/commands/wizardFlow.js +3 -0
  108. package/dist/cli/index.js +8 -4
  109. package/dist/cli/terminalTitle.js +9 -3
  110. package/dist/config/contextFiles.d.ts +2 -5
  111. package/dist/config/contextFiles.js +1 -1
  112. package/dist/config/inputHistory.js +2 -2
  113. package/dist/config/providerAuth.js +2 -2
  114. package/dist/config/providerModelFacts.js +5 -0
  115. package/dist/config/providerPresets.js +1 -1
  116. package/dist/config/settings.d.ts +7 -0
  117. package/dist/config/settings.js +9 -2
  118. package/dist/config/updateCheck.js +2 -2
  119. package/dist/core/agent/compaction.d.ts +1 -0
  120. package/dist/core/agent/compaction.js +3 -0
  121. package/dist/core/agent/completionController.d.ts +1 -1
  122. package/dist/core/agent/contextBudget.d.ts +1 -1
  123. package/dist/core/agent/goalPolicy.js +8 -2
  124. package/dist/core/agent/overflow.js +5 -0
  125. package/dist/core/agent/toolCapabilities.js +14 -0
  126. package/dist/core/agent/userCommands.d.ts +53 -0
  127. package/dist/core/agent/userCommands.js +116 -0
  128. package/dist/core/agent/workState.d.ts +3 -1
  129. package/dist/core/agent/workState.js +57 -26
  130. package/dist/core/contextFileTypes.d.ts +12 -0
  131. package/dist/core/contextFileTypes.js +1 -0
  132. package/dist/core/graph/analyze.d.ts +61 -0
  133. package/dist/core/graph/analyze.js +274 -0
  134. package/dist/core/graph/buildGraph.d.ts +44 -0
  135. package/dist/core/graph/buildGraph.js +290 -0
  136. package/dist/core/graph/digest.d.ts +2 -0
  137. package/dist/core/graph/digest.js +40 -0
  138. package/dist/core/graph/extract.d.ts +58 -0
  139. package/dist/core/graph/extract.js +394 -0
  140. package/dist/core/graph/model.d.ts +63 -0
  141. package/dist/core/graph/model.js +96 -0
  142. package/dist/core/graph/query.d.ts +69 -0
  143. package/dist/core/graph/query.js +391 -0
  144. package/dist/core/graph/store.d.ts +64 -0
  145. package/dist/core/graph/store.js +171 -0
  146. package/dist/core/limits.d.ts +2 -0
  147. package/dist/core/limits.js +2 -0
  148. package/dist/core/log/llmLog.js +2 -2
  149. package/dist/{config → core/persistence}/privateStorage.js +1 -1
  150. package/dist/core/process/runBoundedProcess.d.ts +7 -4
  151. package/dist/core/process/runBoundedProcess.js +22 -11
  152. package/dist/core/safety/redaction.d.ts +2 -0
  153. package/dist/core/safety/redaction.js +26 -5
  154. package/dist/core/safety/secretPaths.js +12 -3
  155. package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
  156. package/dist/core/safety/untrustedEnvelopes.js +17 -2
  157. package/dist/core/safety/urlGuard.js +2 -0
  158. package/dist/core/session/sessionStore.d.ts +8 -1
  159. package/dist/core/session/sessionStore.js +15 -4
  160. package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
  161. package/dist/core/shellOutput/types.d.ts +1 -1
  162. package/dist/core/subagent/executionProfiles.js +4 -4
  163. package/dist/core/tasks/taskStorage.js +11 -1
  164. package/dist/{llm → core}/toolResultTypes.d.ts +1 -1
  165. package/dist/core/validation/outputParser.d.ts +1 -1
  166. package/dist/core/validation/outputParser.js +16 -8
  167. package/dist/llm/hazeTools.d.ts +2 -12426
  168. package/dist/llm/hazeTools.js +4 -0
  169. package/dist/llm/lsp/pool.js +1 -1
  170. package/dist/llm/lsp/workspaceEdit.d.ts +1 -1
  171. package/dist/llm/lspTools.d.ts +3 -12622
  172. package/dist/llm/requestContext.d.ts +6 -0
  173. package/dist/llm/requestContext.js +28 -7
  174. package/dist/llm/subagentRunner.d.ts +2 -308
  175. package/dist/llm/systemPrompt.js +17 -7
  176. package/dist/llm/toolGroups.d.ts +534 -0
  177. package/dist/llm/toolGroups.js +57 -0
  178. package/dist/llm/tools/editMatch.d.ts +1 -1
  179. package/dist/llm/tools/failures.d.ts +1 -1
  180. package/dist/llm/tools/fetchTool.d.ts +2 -1221
  181. package/dist/llm/tools/fileToolShared.d.ts +1 -1
  182. package/dist/llm/tools/fileToolShared.js +1 -1
  183. package/dist/llm/tools/fileTools.d.ts +2 -7768
  184. package/dist/llm/tools/fileTools.js +1 -1
  185. package/dist/llm/tools/gitTools.d.ts +12 -0
  186. package/dist/llm/tools/gitTools.js +527 -0
  187. package/dist/llm/tools/graphAdvisory.d.ts +22 -0
  188. package/dist/llm/tools/graphAdvisory.js +68 -0
  189. package/dist/llm/tools/graphTools.d.ts +13 -0
  190. package/dist/llm/tools/graphTools.js +195 -0
  191. package/dist/llm/tools/processTool.d.ts +2 -1081
  192. package/dist/llm/tools/readRecovery.d.ts +1 -1
  193. package/dist/llm/tools/replaceInFiles.d.ts +1 -1
  194. package/dist/llm/tools/replaceInFiles.js +1 -1
  195. package/dist/llm/tools/shellTool.d.ts +2 -1513
  196. package/dist/llm/tools/storedOutputTool.d.ts +2 -355
  197. package/dist/llm/tools/taskTool.d.ts +2 -489
  198. package/dist/llm/tools/taskTool.js +4 -1
  199. package/dist/llm/tools/toolContext.js +29 -11
  200. package/dist/llm/tools/toolContextState.d.ts +4 -1
  201. package/dist/llm/tools/toolContextState.js +2 -1
  202. package/dist/llm/tools/workspaceFile.d.ts +2 -2
  203. package/dist/llm/tools/workspaceFile.js +10 -5
  204. package/dist/skills/SkillRegistry.js +1 -1
  205. package/dist/skills/builder/SkillBuilder.js +1 -1
  206. package/dist/skills/plugins/installer.js +1 -1
  207. package/dist/skills/plugins/runtime.js +1 -1
  208. package/dist/skills/skillTools.js +4 -1
  209. package/dist/ui/components/MarkdownText.d.ts +14 -0
  210. package/dist/ui/components/MarkdownText.js +77 -12
  211. package/dist/ui/components/NativeIndicators.js +5 -1
  212. package/dist/ui/components/StreamingMarkdownText.d.ts +3 -1
  213. package/dist/ui/components/StreamingMarkdownText.js +39 -11
  214. package/dist/ui/components/TextInput.d.ts +1 -2
  215. package/dist/ui/components/TextInput.js +79 -9
  216. package/dist/ui/components/WizardChoices.d.ts +1 -2
  217. package/dist/ui/components/useInputSuggestions.d.ts +1 -1
  218. package/dist/ui/components/useInputSuggestions.js +1 -1
  219. package/dist/ui/mentionDetection.d.ts +20 -0
  220. package/dist/ui/mentionDetection.js +24 -0
  221. package/dist/ui/terminalColors.d.ts +4 -4
  222. package/dist/ui/terminalColors.js +23 -6
  223. package/dist/ui/terminalSanitize.js +8 -3
  224. package/dist/ui/textGeometry.d.ts +2 -0
  225. package/dist/ui/textGeometry.js +6 -0
  226. package/dist/ui/themes/registry.js +33 -33
  227. package/dist/utils/openPath.js +7 -0
  228. package/package.json +22 -19
  229. /package/dist/{llm/tools → core/ignore}/gitIgnore.d.ts +0 -0
  230. /package/dist/{llm/tools → core/ignore}/gitIgnore.js +0 -0
  231. /package/dist/{config → core}/paths.d.ts +0 -0
  232. /package/dist/{config → core}/paths.js +0 -0
  233. /package/dist/{config → core/persistence}/privateStorage.d.ts +0 -0
  234. /package/dist/{llm → core}/toolResultTypes.js +0 -0
@@ -0,0 +1,26 @@
1
+ import { useEffect } from 'react';
2
+ import { setActiveTheme, resolveTheme, theme, DEFAULT_THEME_NAME } from '../../ui/theme.js';
3
+ import { applyTerminalColors } from '../../ui/terminalColors.js';
4
+ /**
5
+ * Live theme switching, extracted from `ChatScreen` (ARCH-05): whenever the
6
+ * settings' theme name changes (/themes), re-resolve and adopt it so the whole
7
+ * UI repaints without a restart. Ink <Static> history stays as-rendered, so
8
+ * already-printed text keeps its old colors; the terminal defaults (OSC 10/11)
9
+ * follow the new theme. Skipped until `settingsThemeLoadedRef` is set —
10
+ * `chatCommand()` already resolved the theme before the first render, and the
11
+ * pre-load {} state would briefly flash the default theme.
12
+ */
13
+ export function useLiveTheme(settings, stoppingRef, settingsThemeLoadedRef) {
14
+ const activeThemeName = settings.theme ?? DEFAULT_THEME_NAME;
15
+ useEffect(() => {
16
+ if (!settingsThemeLoadedRef.current || stoppingRef.current)
17
+ return;
18
+ try {
19
+ setActiveTheme(resolveTheme(activeThemeName));
20
+ applyTerminalColors(theme.foreground, theme.background);
21
+ }
22
+ catch {
23
+ // Malformed theme names were reported at startup; keep the resolved default.
24
+ }
25
+ }, [activeThemeName, stoppingRef, settingsThemeLoadedRef]);
26
+ }
@@ -0,0 +1,4 @@
1
+ import type { Message } from '../commands/streaming.js';
2
+ import type { ChatScreenDeps } from './screenDeps.js';
3
+ /** Finalize a formerly-live message into the append-only transcript and session record. */
4
+ export declare function finalizeMessage(deps: ChatScreenDeps, message: Message): void;
@@ -0,0 +1,8 @@
1
+ /** Finalize a formerly-live message into the append-only transcript and session record. */
2
+ export function finalizeMessage(deps, message) {
3
+ if (message.hidden || deps.sealedRef.current)
4
+ return;
5
+ const ordered = deps.withDisplayOrder(message);
6
+ deps.setMessages(m => [...m, ordered]);
7
+ deps.sessionRecorderRef.current?.recordUiMessage(ordered);
8
+ }
@@ -205,7 +205,7 @@ function StreamingClampedText({ text, width, maxVisibleLines }) {
205
205
  export const MessageView = React.memo(function MessageView({ message, width, showHeader = true, maxVisibleLines }) {
206
206
  if (maxVisibleLines != null && message.role !== 'tool') {
207
207
  return _jsxs(Box, { flexDirection: "column", flexShrink: 0, maxHeight: maxVisibleLines + (showHeader ? 1 : 0), overflow: "hidden", children: [showHeader && _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: message.role === 'assistant' ? 'haze' : message.role === 'user' ? 'You asked' : 'Info' }), message.role === 'assistant'
208
- ? _jsx(StreamingMarkdownText, { content: message.text, width: width, maxVisibleLines: maxVisibleLines })
208
+ ? _jsx(StreamingMarkdownText, { content: message.text, width: width, maxVisibleLines: maxVisibleLines, streaming: message.streaming })
209
209
  : _jsx(StreamingClampedText, { text: message.text, width: width, maxVisibleLines: maxVisibleLines })] });
210
210
  }
211
211
  if (message.role === 'user') {
@@ -0,0 +1,23 @@
1
+ import type React from 'react';
2
+ import { type SessionSummary } from '../../core/session/sessionStore.js';
3
+ import type { Mode } from '../commands/chatModes.js';
4
+ import type { Message } from '../commands/streaming.js';
5
+ import type { WizardUiAction } from './wizardDispatch.js';
6
+ export type PickerOpenerDeps = {
7
+ /** Flushes the active session before listing so it is visible to the picker. */
8
+ flush: () => Promise<unknown>;
9
+ onFlushError: (error: unknown) => void;
10
+ setSessions: (sessions: SessionSummary[]) => void;
11
+ updateWizard: (action: WizardUiAction) => void;
12
+ setMode: (mode: Mode) => void;
13
+ setMessages: (updater: React.SetStateAction<Message[]>) => void;
14
+ };
15
+ /**
16
+ * Openers for the session and plugin pickers, extracted from `ChatScreen`
17
+ * (ARCH-05). They only load data and route to the matching mode; the picker
18
+ * submit handling stays in `wizardDispatch.ts`.
19
+ */
20
+ export declare function createPickerOpeners(deps: PickerOpenerDeps): {
21
+ openSessionPicker: () => Promise<void>;
22
+ openPluginPicker: () => Promise<void>;
23
+ };
@@ -0,0 +1,36 @@
1
+ import { listSessions } from '../../core/session/sessionStore.js';
2
+ import { MAX_SESSION_PICKER_RESULTS } from '../commands/sessionPicker.js';
3
+ import { listInstalledPlugins } from '../commands/pluginCommand.js';
4
+ /**
5
+ * Openers for the session and plugin pickers, extracted from `ChatScreen`
6
+ * (ARCH-05). They only load data and route to the matching mode; the picker
7
+ * submit handling stays in `wizardDispatch.ts`.
8
+ */
9
+ export function createPickerOpeners(deps) {
10
+ async function openSessionPicker() {
11
+ await deps.flush().catch(deps.onFlushError);
12
+ const next = await listSessions();
13
+ deps.setSessions(next);
14
+ deps.updateWizard({ type: 'set', key: 'selectedSessionId', value: undefined });
15
+ if (next.length === 0) {
16
+ deps.setMessages(m => [...m, { role: 'system', text: 'No saved sessions found for this workspace.' }]);
17
+ deps.setMode('chat');
18
+ return;
19
+ }
20
+ deps.setMode('sessions');
21
+ const hidden = Math.max(0, next.length - MAX_SESSION_PICKER_RESULTS);
22
+ deps.setMessages(m => [...m, { role: 'system', text: `Choose a saved session (newest first)${hidden ? `. Showing ${MAX_SESSION_PICKER_RESULTS} of ${next.length}; ${hidden} older sessions are hidden.` : '.'}` }]);
23
+ }
24
+ async function openPluginPicker() {
25
+ try {
26
+ deps.updateWizard({ type: 'plugins', value: await listInstalledPlugins() });
27
+ }
28
+ catch (error) {
29
+ deps.setMessages(m => [...m, { role: 'system', text: `Could not list installed plugins: ${error instanceof Error ? error.message : String(error)}` }]);
30
+ return;
31
+ }
32
+ deps.setMode('plugins');
33
+ deps.setMessages(m => [...m, { role: 'system', text: 'Choose install plugin, inspect plugin, or an installed plugin to manage. Only skills activate; no scripts, hooks, or MCP servers run.' }]);
34
+ }
35
+ return { openSessionPicker, openPluginPicker };
36
+ }
@@ -0,0 +1,11 @@
1
+ import type { PromptSession } from '../../llm/systemPrompt.js';
2
+ import type { StoredReasoningSetting } from '../../core/agent/reasoningPolicy.js';
3
+ /**
4
+ * The stable per-session PromptSession plus the per-model reasoning overrides
5
+ * stored on it, extracted from `ChatScreen` (ARCH-05).
6
+ */
7
+ export declare function usePromptSession(sessionStartRef: React.MutableRefObject<Date>): {
8
+ currentPromptSession: () => PromptSession;
9
+ setSessionReasoningOverride: (modelSelector: string, setting: StoredReasoningSetting | undefined) => void;
10
+ reasoningOverrideCounter: number;
11
+ };
@@ -0,0 +1,39 @@
1
+ import { useRef, useState } from 'react';
2
+ /**
3
+ * The stable per-session PromptSession plus the per-model reasoning overrides
4
+ * stored on it, extracted from `ChatScreen` (ARCH-05).
5
+ */
6
+ export function usePromptSession(sessionStartRef) {
7
+ // Stable PromptSession object across turns so per-session flags (the
8
+ // context-fallback warning key) persist; rebuilt when a new session starts,
9
+ // detected by sessionStartRef identity (the lifecycle controller replaces
10
+ // the Date on new/resume/continue).
11
+ const promptSessionRef = useRef({ identity: undefined, value: { cwd: process.cwd() } });
12
+ // Session per-model reasoning overrides live on the stable PromptSession
13
+ // object; this counter only forces a re-render so the status bar updates.
14
+ const [reasoningOverrideCounter, setReasoningOverrideCounter] = useState(0);
15
+ /**
16
+ * The PromptSession shared by every turn of the active session. Returning a
17
+ * stable object (not a fresh literal per turn) is what makes once-per-session
18
+ * affordances actually once-per-session; a new session identity yields a
19
+ * fresh object so they fire again at its start.
20
+ */
21
+ function currentPromptSession() {
22
+ if (promptSessionRef.current.identity !== sessionStartRef.current) {
23
+ promptSessionRef.current = { identity: sessionStartRef.current, value: { start: sessionStartRef.current, cwd: process.cwd() } };
24
+ }
25
+ return promptSessionRef.current.value;
26
+ }
27
+ function setSessionReasoningOverride(modelSelector, setting) {
28
+ const session = currentPromptSession();
29
+ if (setting === undefined) {
30
+ if (session.reasoningByModel)
31
+ delete session.reasoningByModel[modelSelector];
32
+ }
33
+ else {
34
+ session.reasoningByModel = { ...session.reasoningByModel, [modelSelector]: setting };
35
+ }
36
+ setReasoningOverrideCounter(count => count + 1);
37
+ }
38
+ return { currentPromptSession, setSessionReasoningOverride, reasoningOverrideCounter };
39
+ }
@@ -0,0 +1,8 @@
1
+ export type RenderMetrics = {
2
+ at: number;
3
+ renderTime: number;
4
+ };
5
+ export type RenderMetricsReader = () => RenderMetrics | undefined;
6
+ export declare function setRenderMetricsReader(reader: RenderMetricsReader): void;
7
+ export declare function clearRenderMetricsReader(): void;
8
+ export declare function readRenderMetrics(): RenderMetrics | undefined;
@@ -0,0 +1,14 @@
1
+ // Module-level on purpose: the Ink render options live outside React, and the
2
+ // debug panel reads the latest value through a getter so it never enters state
3
+ // (no extra re-renders). `commands/chat.tsx` installs the reader and clears it
4
+ // when the terminal session restores; `ChatScreen` consumes it.
5
+ let renderMetricsReader;
6
+ export function setRenderMetricsReader(reader) {
7
+ renderMetricsReader = reader;
8
+ }
9
+ export function clearRenderMetricsReader() {
10
+ renderMetricsReader = undefined;
11
+ }
12
+ export function readRenderMetrics() {
13
+ return renderMetricsReader?.();
14
+ }
@@ -18,3 +18,14 @@ export interface ResizeGuardStream {
18
18
  * of the transcript there.
19
19
  */
20
20
  export declare function installViewportResizeGuard(stream?: ResizeGuardStream): () => void;
21
+ /** Width replays wait this long for a drag-resize to settle (FE-04). */
22
+ export declare const RESIZE_SETTLE_MS = 120;
23
+ /**
24
+ * Coalesce a burst of width changes into one `<Static>` replay. The viewport
25
+ * still clears on every change (the guard above); only the replay, which
26
+ * re-parses the whole settled transcript, waits for the resize to settle.
27
+ */
28
+ export declare function createResizeSettler(apply: (columns: number) => void, delayMs?: number): {
29
+ next: (columns: number) => void;
30
+ cancel: () => void;
31
+ };
@@ -23,3 +23,28 @@ export function installViewportResizeGuard(stream = process.stdout) {
23
23
  stream.on('resize', onResize);
24
24
  return () => { stream.off('resize', onResize); };
25
25
  }
26
+ /** Width replays wait this long for a drag-resize to settle (FE-04). */
27
+ export const RESIZE_SETTLE_MS = 120;
28
+ /**
29
+ * Coalesce a burst of width changes into one `<Static>` replay. The viewport
30
+ * still clears on every change (the guard above); only the replay, which
31
+ * re-parses the whole settled transcript, waits for the resize to settle.
32
+ */
33
+ export function createResizeSettler(apply, delayMs = RESIZE_SETTLE_MS) {
34
+ let timer;
35
+ const cancel = () => {
36
+ if (timer !== undefined)
37
+ clearTimeout(timer);
38
+ timer = undefined;
39
+ };
40
+ return {
41
+ next(columns) {
42
+ cancel();
43
+ timer = setTimeout(() => {
44
+ timer = undefined;
45
+ apply(columns);
46
+ }, delayMs);
47
+ },
48
+ cancel,
49
+ };
50
+ }
@@ -0,0 +1,116 @@
1
+ import type React from 'react';
2
+ import type { ModelMessage } from 'ai';
3
+ import type { ContextFile } from '../../config/contextFiles.js';
4
+ import type { HazeSettings } from '../../config/settings.js';
5
+ import type { HazeSession } from '../../core/session/sessionStore.js';
6
+ import type { WorkState } from '../../core/agent/workState.js';
7
+ import type { LlmLog } from '../../core/log/llmLog.js';
8
+ import type { Task } from '../../core/tasks/taskStorage.js';
9
+ import type { PromptSession } from '../../llm/systemPrompt.js';
10
+ import type { Message, TurnExecutionOptions } from '../commands/streaming.js';
11
+ import type { GoalCheckpoint } from '../commands/streaming/goalCheckpoint.js';
12
+ import type { Mode } from '../commands/chatModes.js';
13
+ import type { SessionRecorder } from './sessionRecorder.js';
14
+ import type { useFollowUpQueue } from './followUpQueue.js';
15
+ import type { useBusyIndicator } from './busyIndicator.js';
16
+ import type { createWizardDispatch } from './wizardDispatch.js';
17
+ import type { createSessionLifecycle } from './sessionLifecycle.js';
18
+ import type { useTerminalControl } from './terminalControl.js';
19
+ /** A genuinely paused goal and what a one-key R resume needs (SU-04). */
20
+ export type PausedResume = {
21
+ kind: 'model-stream-idle' | 'incomplete-goal';
22
+ request: string;
23
+ retryAttempt: number;
24
+ checkpoint?: GoalCheckpoint;
25
+ pauseReason?: 'no-progress' | 'goal-deadline' | 'context-exhausted';
26
+ };
27
+ /** Explicit resume of a paused goal passed into a single agent turn. */
28
+ export type ResumeExisting = {
29
+ kind: 'model-stream-idle';
30
+ retryAttempt: number;
31
+ } | {
32
+ kind: 'incomplete-goal';
33
+ checkpoint: GoalCheckpoint;
34
+ };
35
+ /**
36
+ * The explicit dependency bundle the extracted ChatScreen function bodies
37
+ * (`submitPipeline`, `agentTurnRunner`, `messageFinalize`) receive instead of
38
+ * closing over component scope. Assembled once per render in `chat/ChatScreen.tsx`;
39
+ * refs are shared objects, so call-time reads always see fresh values.
40
+ */
41
+ export interface ChatScreenDeps {
42
+ stoppingRef: React.RefObject<boolean>;
43
+ sealedRef: React.RefObject<boolean>;
44
+ quarantineRef: React.RefObject<(() => void) | undefined>;
45
+ activeGoalRef: React.RefObject<Promise<unknown> | undefined>;
46
+ conversationRef: React.RefObject<ModelMessage[]>;
47
+ settingsRef: React.RefObject<HazeSettings>;
48
+ sessionRef: React.RefObject<HazeSession | undefined>;
49
+ sessionRecorderRef: React.RefObject<SessionRecorder | undefined>;
50
+ sessionStartRef: React.RefObject<Date>;
51
+ workStateRef: React.RefObject<WorkState | undefined>;
52
+ lastAssistantTextRef: React.RefObject<string>;
53
+ abortControllerRef: React.RefObject<AbortController | null>;
54
+ llmLogRef: React.RefObject<LlmLog | undefined>;
55
+ contextFileSignaturesRef: React.RefObject<Map<string, string>>;
56
+ settings: HazeSettings;
57
+ settingsError: string | undefined;
58
+ contextFiles: ContextFile[];
59
+ mode: Mode;
60
+ busy: boolean;
61
+ pausedResume: PausedResume | undefined;
62
+ visibleTasks: Task[];
63
+ setMessages: (updater: React.SetStateAction<Message[]>) => void;
64
+ setSettings: (next: HazeSettings, patch?: HazeSettings) => void;
65
+ setSettingsError: React.Dispatch<React.SetStateAction<string | undefined>>;
66
+ setMode: React.Dispatch<React.SetStateAction<Mode>>;
67
+ setContextFiles: React.Dispatch<React.SetStateAction<ContextFile[]>>;
68
+ setBusy: ReturnType<typeof useBusyIndicator>['setBusy'];
69
+ setBusyLabel: React.Dispatch<React.SetStateAction<string>>;
70
+ setTokenUsage: React.Dispatch<React.SetStateAction<import('../commands/streaming/turnRuntime.js').TokenUsage>>;
71
+ /** Optional so lifecycle-only harnesses need not wire it; the screen always provides it. */
72
+ setContextUsage?: React.Dispatch<React.SetStateAction<import('./turnState.js').ContextUsage>>;
73
+ setFleet: React.Dispatch<React.SetStateAction<import('./chatMetrics.js').FleetStatus | undefined>>;
74
+ setVisibleTasks: React.Dispatch<React.SetStateAction<Task[]>>;
75
+ setTaskBarPadding: React.Dispatch<React.SetStateAction<number>>;
76
+ setTasksExpanded: React.Dispatch<React.SetStateAction<boolean>>;
77
+ setPausedResume: React.Dispatch<React.SetStateAction<PausedResume | undefined>>;
78
+ setDebugLogs: React.Dispatch<React.SetStateAction<string[]>>;
79
+ updateWizard: Parameters<typeof createWizardDispatch>[0]['updateWizard'];
80
+ currentModelSelection: () => {
81
+ provider: string;
82
+ model: string;
83
+ endpointFingerprint?: string;
84
+ } | undefined;
85
+ currentPromptSession: () => PromptSession;
86
+ withDisplayOrder: (message: Message) => Message;
87
+ finalizeMessage: (message: Message) => void;
88
+ addStreaming: (message: Message) => void;
89
+ patchLiveMessage: (id: string, update: Partial<Message>) => Message | undefined;
90
+ drainLiveMessages: () => void;
91
+ clearLiveMessages: () => void;
92
+ debugLog: (line: string) => void;
93
+ showPersistenceWarning: (error: unknown) => void;
94
+ skillInvocation: (value: string) => {
95
+ skill: import('../../skills/types.js').LoadedSkill;
96
+ args: string;
97
+ } | undefined;
98
+ prepareUserInput: (value: string) => Promise<{
99
+ value: string;
100
+ displayValue?: string;
101
+ options: TurnExecutionOptions;
102
+ } | undefined>;
103
+ doAgentTurn: (value: string, displayValue?: string, turnOptions?: TurnExecutionOptions) => Promise<void>;
104
+ /** Run one user command (`! <command>`) and hand its output to the model. */
105
+ runUserCommand: (command: string) => Promise<void>;
106
+ openSessionPicker: () => Promise<void>;
107
+ openPluginPicker: () => Promise<void>;
108
+ refreshSkills: () => Promise<import('../../skills/types.js').LoadedSkill[]>;
109
+ setSessionReasoningOverride: (modelSelector: string, setting: import('../../core/agent/reasoningPolicy.js').StoredReasoningSetting | undefined) => void;
110
+ shutdown: () => Promise<void>;
111
+ followUps: ReturnType<typeof useFollowUpQueue>;
112
+ wizard: ReturnType<typeof createWizardDispatch>;
113
+ sessionLifecycle: ReturnType<typeof createSessionLifecycle>;
114
+ terminalControl: ReturnType<typeof useTerminalControl>;
115
+ noSession: boolean;
116
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -7,6 +7,7 @@ import { type LlmLog } from '../../core/log/llmLog.js';
7
7
  import type { Message } from '../commands/streaming.js';
8
8
  import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
9
9
  import type { SessionRecorder } from './sessionRecorder.js';
10
+ import { type ContextUsage } from './turnState.js';
10
11
  /**
11
12
  * Session lifecycle controller extracted from `chat.tsx` (CR-006): session
12
13
  * init/continue/resume/new/clear/compact live here; the component keeps refs,
@@ -54,6 +55,7 @@ export interface SessionLifecycleDeps {
54
55
  /** Drop the live tail (clear/new-session). */
55
56
  clearLiveMessages: () => void;
56
57
  setTokenUsage: (usage: TokenUsage) => void;
58
+ setContextUsage?: (usage: ContextUsage) => void;
57
59
  /** Manual /compact mode: model-written summary (default) or heuristic excerpt. */
58
60
  manualCompaction?: () => 'llm-summary' | 'heuristic';
59
61
  /** Opt-in session-write secret redaction (HZ-9 `redactSessionSecrets` setting). */
@@ -1,6 +1,7 @@
1
1
  import { streamText } from 'ai';
2
2
  import { transitionProviderConversation } from '../../core/agent/providerTransition.js';
3
3
  import { buildLlmCompactionPrompt, compactModelMessages, compactModelMessagesWithSummary, splitForCompaction } from '../../core/agent/compaction.js';
4
+ import { buildCodeGraphDigest } from '../../core/graph/digest.js';
4
5
  import { FALLBACK_CONTEXT_WINDOW_TOKENS } from '../../core/agent/contextBudget.js';
5
6
  import { COMPACTION_LLM_MAX_OUTPUT_TOKENS } from '../../core/agent/budgets.js';
6
7
  import { clearToolOutputs } from '../../core/agent/toolOutputStore.js';
@@ -9,7 +10,7 @@ import { auxiliaryRequestOptions } from '../../core/providerContracts.js';
9
10
  import { createSession, findSession, forkSession, formatSession, latestSession, restoreSessionState } from '../../core/session/sessionStore.js';
10
11
  import { createLog as createLlmLog, endLog as endLlmLog } from '../../core/log/llmLog.js';
11
12
  import { displayMessagesFromConversation, estimateConversationTokens } from './chatMetrics.js';
12
- import { EMPTY_TOKEN_USAGE } from './turnState.js';
13
+ import { EMPTY_CONTEXT_USAGE, EMPTY_TOKEN_USAGE } from './turnState.js';
13
14
  /** Bounded wall-clock budget for one manual LLM compaction summary (SU-03). */
14
15
  const COMPACT_SUMMARY_TIMEOUT_MS = 120_000;
15
16
  import { teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
@@ -43,6 +44,7 @@ export function createSessionLifecycle(deps) {
43
44
  if (selection)
44
45
  deps.sessionRecorder()?.recordModelSelection(selection);
45
46
  deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE });
47
+ deps.setContextUsage?.({ ...EMPTY_CONTEXT_USAGE });
46
48
  await startNewLog();
47
49
  const status = `${message}\nSession: ${session.file}`;
48
50
  deps.setMessages(messages => {
@@ -72,6 +74,7 @@ export function createSessionLifecycle(deps) {
72
74
  deps.clearLiveMessages();
73
75
  const restoredMessages = displayMessagesFromConversation(restoredConversation);
74
76
  deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE, messages: estimateConversationTokens(restoredMessages).input, outputEstimate: estimateConversationTokens(restoredMessages).output });
77
+ deps.setContextUsage?.({ ...EMPTY_CONTEXT_USAGE, usedTokens: estimateConversationTokens(restoredMessages).input, estimated: true });
75
78
  deps.workStateRef.current = workState;
76
79
  for (const error of parseErrors) {
77
80
  deps.debugLog(`Session parse error: ${error}`);
@@ -190,6 +193,7 @@ export function createSessionLifecycle(deps) {
190
193
  deps.conversationRef.current = [];
191
194
  deps.lastAssistantTextRef.current = '';
192
195
  deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE });
196
+ deps.setContextUsage?.({ ...EMPTY_CONTEXT_USAGE });
193
197
  deps.workStateRef.current = undefined;
194
198
  deps.clearLiveMessages();
195
199
  deps.setMessages(() => [{ role: 'system', text: 'Cleared. The void is productive.' }]);
@@ -231,7 +235,7 @@ export function createSessionLifecycle(deps) {
231
235
  const summarization = streamText({
232
236
  model: runtime.model,
233
237
  ...providerSettings,
234
- prompt: buildLlmCompactionPrompt({ older: split.older, instructions }),
238
+ prompt: buildLlmCompactionPrompt({ older: split.older, instructions, codeGraphDigest: await buildCodeGraphDigest() }),
235
239
  abortSignal: AbortSignal.timeout(COMPACT_SUMMARY_TIMEOUT_MS),
236
240
  });
237
241
  const summaryText = (await summarization.text).trim();
@@ -8,7 +8,10 @@ export function createSessionRecorder(getSession) {
8
8
  const session = getSession();
9
9
  if (!session)
10
10
  return;
11
- void writer.append({ session, entry });
11
+ // Per-call rejections are captured as the writer's sticky first error and
12
+ // surfaced once by flush()/error(); an unhandled rejection here would kill
13
+ // the process on Node >=22 (the sibling paths below do the same).
14
+ void writer.append({ session, entry }).catch(() => undefined);
12
15
  };
13
16
  // Full-history snapshot coalescing (RH-008). conversation_snapshot and
14
17
  // work_state_snapshot entries are large and only the latest of each is ever
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import type { ModelMessage } from 'ai';
3
+ import type { HazeSettings } from '../../config/settings.js';
4
+ import type { SessionRecorder } from './sessionRecorder.js';
5
+ import type { Message } from '../commands/streaming.js';
6
+ export type SettingsSelection = {
7
+ provider: string;
8
+ model: string;
9
+ endpointFingerprint?: string;
10
+ };
11
+ export type SettingsSelectionDeps = {
12
+ conversationRef: React.MutableRefObject<ModelMessage[]>;
13
+ sessionRecorderRef: React.MutableRefObject<SessionRecorder | undefined>;
14
+ setMessages: (updater: React.SetStateAction<Message[]>) => void;
15
+ };
16
+ /**
17
+ * Settings state plus the session-pinned model selection, extracted from
18
+ * `ChatScreen` (ARCH-05). `setSettings` records the global default before a
19
+ * patch merge so unrelated settings writes never replace a resumed session's
20
+ * model (merge policy in chat/userInput.ts), converts the conversation when the
21
+ * selected model or provider endpoint changes, and records `model_selection`.
22
+ */
23
+ export declare function useSettingsSelection({ conversationRef, sessionRecorderRef, setMessages }: SettingsSelectionDeps): {
24
+ settings: HazeSettings;
25
+ settingsRef: React.RefObject<HazeSettings>;
26
+ defaultSelectionRef: React.RefObject<{
27
+ provider?: string;
28
+ model?: string;
29
+ }>;
30
+ setSettings: (next: HazeSettings, patch?: HazeSettings) => void;
31
+ setSettingsRaw: React.Dispatch<React.SetStateAction<HazeSettings>>;
32
+ currentModelSelection: () => SettingsSelection | undefined;
33
+ };
@@ -0,0 +1,46 @@
1
+ import { useRef, useState } from 'react';
2
+ import { activeModel, providerEndpointFingerprint } from '../../config/providers.js';
3
+ import { transitionProviderConversation } from '../../core/agent/providerTransition.js';
4
+ import { mergeSettingsSelection } from './userInput.js';
5
+ /**
6
+ * Settings state plus the session-pinned model selection, extracted from
7
+ * `ChatScreen` (ARCH-05). `setSettings` records the global default before a
8
+ * patch merge so unrelated settings writes never replace a resumed session's
9
+ * model (merge policy in chat/userInput.ts), converts the conversation when the
10
+ * selected model or provider endpoint changes, and records `model_selection`.
11
+ */
12
+ export function useSettingsSelection({ conversationRef, sessionRecorderRef, setMessages }) {
13
+ const [settings, setSettingsRaw] = useState({});
14
+ const settingsRef = useRef({});
15
+ const defaultSelectionRef = useRef({});
16
+ function currentModelSelection() {
17
+ const { provider, model } = settingsRef.current;
18
+ const selected = activeModel(settingsRef.current);
19
+ return provider && model ? { provider, model, ...(selected ? { endpointFingerprint: providerEndpointFingerprint(selected.provider) } : {}) } : undefined;
20
+ }
21
+ function setSettings(next, patch) {
22
+ const previousSelection = currentModelSelection();
23
+ const previousProvider = activeModel(settingsRef.current)?.provider;
24
+ // The ref records the global default from `next` (what updateSettings
25
+ // returned) before the patch merge; unrelated settings writes must not
26
+ // replace a resumed session's model (merge policy in chat/userInput.ts).
27
+ defaultSelectionRef.current = { provider: next.provider, model: next.model };
28
+ settingsRef.current = patch ? mergeSettingsSelection(next, settingsRef.current, patch) : next;
29
+ const selected = currentModelSelection();
30
+ const selectedProvider = activeModel(settingsRef.current)?.provider;
31
+ const changedEndpoint = selectedProvider && (!previousProvider || previousProvider.url !== selectedProvider.url || previousProvider.kind !== selectedProvider.kind);
32
+ if (patch && previousSelection && selected && (previousSelection.provider !== selected.provider || previousSelection.model !== selected.model || changedEndpoint) && conversationRef.current.length) {
33
+ conversationRef.current = transitionProviderConversation(conversationRef.current);
34
+ sessionRecorderRef.current?.recordModelTransition(conversationRef.current, selected);
35
+ setMessages(messages => [...messages, { role: 'system', text: 'Model changed: previous tool history was converted to text and provider reasoning state was cleared.' }]);
36
+ }
37
+ setSettingsRaw(settingsRef.current);
38
+ if (patch && ('provider' in patch || 'model' in patch)) {
39
+ if (selected)
40
+ sessionRecorderRef.current?.recordModelSelection(selected);
41
+ }
42
+ }
43
+ // Direct state sync for the resume/continue/fork selection restore: no
44
+ // provider transition, the conversation is replaced by the lifecycle anyway.
45
+ return { settings, settingsRef, defaultSelectionRef, setSettings, setSettingsRaw, currentModelSelection };
46
+ }
@@ -0,0 +1,18 @@
1
+ import type { LoadedSkill } from '../../skills/types.js';
2
+ /** Signatures of the skill notices already announced in this session. */
3
+ export type SkillNoticeState = {
4
+ project: string;
5
+ errors: string;
6
+ notices: string;
7
+ };
8
+ export declare const initialSkillNoticeState: () => SkillNoticeState;
9
+ /**
10
+ * Pure diffing half of `refreshSkills`: loads the registry and returns the
11
+ * candidate list, the next notice state, and the system messages that changed
12
+ * since the previous state (each notice is announced once per signature).
13
+ */
14
+ export declare function loadSkillsWithNotices(previous: SkillNoticeState): Promise<{
15
+ skills: LoadedSkill[];
16
+ state: SkillNoticeState;
17
+ messages: string[];
18
+ }>;
@@ -0,0 +1,26 @@
1
+ import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
2
+ export const initialSkillNoticeState = () => ({ project: '', errors: '', notices: '' });
3
+ /**
4
+ * Pure diffing half of `refreshSkills`: loads the registry and returns the
5
+ * candidate list, the next notice state, and the system messages that changed
6
+ * since the previous state (each notice is announced once per signature).
7
+ */
8
+ export async function loadSkillsWithNotices(previous) {
9
+ const registry = await loadSkillRegistry();
10
+ const skills = registry.candidates ?? [...registry.skills.values()];
11
+ const projectSkills = skills.filter(skill => skill.source === 'project');
12
+ const project = projectSkills.map(skill => `${skill.name}:${skill.path}`).join('\n');
13
+ const errors = registry.errors.map(error => `${error.source ? `${error.source}/` : ''}${error.directory}: ${error.message}`).join('\n');
14
+ // Visible load-time shadow notices (HZA-6): a project skill silently
15
+ // overriding a same-named user skill is something the user should see.
16
+ const notices = (registry.notices ?? []).join('\n');
17
+ const messages = [];
18
+ if (project && project !== previous.project) {
19
+ messages.push(`Project skills discovered (repository-provided, untrusted content): ${projectSkills.map(skill => skill.name).join(', ')}`);
20
+ }
21
+ if (errors && errors !== previous.errors)
22
+ messages.push(`Invalid skills were isolated:\n${errors}`);
23
+ if (notices && notices !== previous.notices)
24
+ messages.push(notices);
25
+ return { skills, state: { project, errors, notices }, messages };
26
+ }
@@ -34,7 +34,7 @@ export function startupProviderInfo(settings) {
34
34
  lspLine,
35
35
  mcpLine,
36
36
  '',
37
- 'Run /provider to choose or add a provider, then select a model.',
37
+ 'Run /provider to choose or add a provider, then select a model (choose "later" to skip for now). Esc goes back one step; Esc at the first step exits.',
38
38
  ].join('\n');
39
39
  }
40
40
  const model = selection.model;
@@ -19,6 +19,8 @@ export interface StartupSequenceOptions {
19
19
  /** Reloads the skill registry (also reports project-skill and error signatures). */
20
20
  refreshSkills: () => Promise<unknown>;
21
21
  addSystemMessage: (text: string) => void;
22
+ /** Notified only when the background graph build actually starts/finishes. */
23
+ onGraphActivity?: (building: boolean) => void;
22
24
  }
23
25
  /**
24
26
  * The chat screen's startup sequence, extracted so ChatScreen stays rendering
@@ -4,6 +4,7 @@ import { readContextFiles } from '../../config/contextFiles.js';
4
4
  import { readSettings } from '../../config/settings.js';
5
5
  import { checkForUpdate } from '../../config/updateCheck.js';
6
6
  import { detectCheckoutMismatch, formatMismatchWarning, runtimeCapabilities } from '../../utils/buildInfo.js';
7
+ import { ensureGraphInBackground } from '../../core/graph/buildGraph.js';
7
8
  import { startupContextInfo, startupProviderInfo } from './startupInfo.js';
8
9
  const execFile = promisify(execFileCallback);
9
10
  /** Current git branch name for the workspace header, or undefined outside a repo/branch. */
@@ -56,4 +57,9 @@ export async function runStartupSequence(options) {
56
57
  else if (!runtimeCapabilities().goalSupervisorAvailable) {
57
58
  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
  }
60
+ // Keep the workspace code graph warm without blocking startup: a single
61
+ // background build on every startup — creating the graph when none exists
62
+ // yet, incrementally refreshing it afterwards. Failures are silent here;
63
+ // the graph tools surface `graph_not_built` with a hint.
64
+ void ensureGraphInBackground({ onActivity: options.onGraphActivity });
59
65
  }
@@ -0,0 +1,8 @@
1
+ import type { ChatScreenDeps } from './screenDeps.js';
2
+ /**
3
+ * The chat input submit pipeline: exit shortcut, settings repair, busy
4
+ * queueing, wizard dispatch, skill invocation, slash commands, then the
5
+ * agent turn. Extracted from `chat.tsx` (CR-006 pattern) — pure code motion
6
+ * over the explicit deps bundle.
7
+ */
8
+ export declare function submit(deps: ChatScreenDeps, value: string): Promise<void>;