@denizokcu/haze 0.11.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +28 -14
  3. package/SECURITY.md +5 -3
  4. package/dist/buildInfo.json +3 -3
  5. package/dist/cli/chat/TaskBar.js +1 -1
  6. package/dist/cli/chat/chatMetrics.d.ts +2 -2
  7. package/dist/cli/chat/chatMetrics.js +1 -1
  8. package/dist/cli/chat/fileMentionSuggestions.js +1 -1
  9. package/dist/cli/chat/inputSuggestions.d.ts +8 -16
  10. package/dist/cli/chat/inputSuggestions.js +10 -41
  11. package/dist/cli/chat/messages.d.ts +0 -2
  12. package/dist/cli/chat/messages.js +5 -5
  13. package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
  14. package/dist/cli/chat/turnState.d.ts +1 -1
  15. package/dist/cli/chat/wizardDispatch.d.ts +90 -28
  16. package/dist/cli/chat/wizardDispatch.js +257 -130
  17. package/dist/cli/commands/chat.js +61 -77
  18. package/dist/cli/commands/chatModes.d.ts +8 -1
  19. package/dist/cli/commands/chatModes.js +9 -44
  20. package/dist/cli/commands/commandHelp.js +2 -0
  21. package/dist/cli/commands/commands.js +2 -0
  22. package/dist/cli/commands/doctor.js +1 -1
  23. package/dist/cli/commands/formatters.d.ts +3 -3
  24. package/dist/cli/commands/formatters.js +12 -25
  25. package/dist/cli/commands/providerWizard.js +2 -3
  26. package/dist/cli/commands/runCommand.js +1 -1
  27. package/dist/cli/commands/serverWizard.d.ts +34 -0
  28. package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
  29. package/dist/cli/commands/settingsSummary.js +2 -0
  30. package/dist/cli/commands/skillsWizard.d.ts +41 -0
  31. package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
  32. package/dist/cli/commands/streaming/abortCause.d.ts +2 -1
  33. package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
  34. package/dist/cli/commands/streaming/agentAttempt.js +79 -0
  35. package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
  36. package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
  37. package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
  38. package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
  39. package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
  40. package/dist/cli/commands/streaming/attemptSetup.js +167 -0
  41. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
  42. package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
  43. package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
  44. package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
  45. package/dist/cli/commands/streaming/stallRecovery.js +105 -0
  46. package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
  47. package/dist/cli/commands/streaming/streamLoop.js +448 -0
  48. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +14 -0
  49. package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
  50. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
  51. package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
  52. package/dist/cli/commands/streaming/turnRuntime.js +6 -0
  53. package/dist/cli/commands/streaming.d.ts +14 -25
  54. package/dist/cli/commands/streaming.js +43 -754
  55. package/dist/cli/commands/themesCommand.d.ts +17 -0
  56. package/dist/cli/commands/themesCommand.js +24 -0
  57. package/dist/cli/commands/wizardFlow.d.ts +341 -0
  58. package/dist/cli/commands/wizardFlow.js +397 -0
  59. package/dist/cli/contextReport.js +3 -0
  60. package/dist/cli/index.js +1 -1
  61. package/dist/config/contextFiles.js +9 -3
  62. package/dist/config/inputHistory.d.ts +0 -1
  63. package/dist/config/inputHistory.js +1 -1
  64. package/dist/config/modelDiscovery.d.ts +0 -15
  65. package/dist/config/modelDiscovery.js +1 -1
  66. package/dist/config/settings.d.ts +9 -0
  67. package/dist/config/settings.js +4 -0
  68. package/dist/config/skillSettings.js +4 -4
  69. package/dist/config/updateCheck.d.ts +0 -1
  70. package/dist/config/updateCheck.js +1 -1
  71. package/dist/core/agent/budgets.d.ts +63 -1
  72. package/dist/core/agent/budgets.js +84 -1
  73. package/dist/core/agent/compaction.js +1 -1
  74. package/dist/core/agent/completionController.d.ts +7 -13
  75. package/dist/core/agent/completionController.js +17 -8
  76. package/dist/core/agent/contextBudget.d.ts +0 -4
  77. package/dist/core/agent/contextBudget.js +3 -3
  78. package/dist/core/agent/errors.d.ts +0 -1
  79. package/dist/core/agent/errors.js +1 -1
  80. package/dist/core/agent/events.d.ts +5 -1
  81. package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
  82. package/dist/core/agent/goalPolicy.js +106 -0
  83. package/dist/core/agent/requestAssembly.d.ts +2 -2
  84. package/dist/core/agent/requestAssembly.js +16 -4
  85. package/dist/core/agent/toolCapabilities.d.ts +2 -2
  86. package/dist/core/agent/toolCapabilities.js +5 -5
  87. package/dist/core/agent/toolOutputStore.js +1 -1
  88. package/dist/core/agent/toolResults.js +1 -1
  89. package/dist/core/agent/workState.d.ts +6 -3
  90. package/dist/core/agent/workState.js +62 -7
  91. package/dist/core/attachments/imageAttachments.js +90 -42
  92. package/dist/core/deadline.d.ts +0 -6
  93. package/dist/core/deadline.js +1 -1
  94. package/dist/core/io/boundedRead.js +1 -1
  95. package/dist/core/limits.d.ts +51 -0
  96. package/dist/core/limits.js +51 -0
  97. package/dist/core/log/llmLog.js +1 -1
  98. package/dist/core/process/backgroundRegistry.d.ts +2 -3
  99. package/dist/core/process/backgroundRegistry.js +10 -6
  100. package/dist/core/process/userShell.d.ts +16 -0
  101. package/dist/core/process/userShell.js +59 -0
  102. package/dist/core/safety/secretPaths.d.ts +18 -0
  103. package/dist/core/safety/secretPaths.js +115 -0
  104. package/dist/core/safety/shellClassifier.d.ts +11 -0
  105. package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
  106. package/dist/core/safety/urlGuard.d.ts +1 -1
  107. package/dist/core/session/sessionSlimming.d.ts +0 -3
  108. package/dist/core/session/sessionSlimming.js +2 -3
  109. package/dist/core/session/sessionStore.d.ts +1 -0
  110. package/dist/core/session/sessionStore.js +39 -20
  111. package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
  112. package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
  113. package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
  114. package/dist/core/shellOutput/registry.d.ts +2 -0
  115. package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
  116. package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
  117. package/dist/core/subagent/contracts.d.ts +2 -14
  118. package/dist/core/subagent/contracts.js +3 -3
  119. package/dist/core/subagent/executionProfiles.js +2 -2
  120. package/dist/core/subagent/subagentRunner.js +3 -4
  121. package/dist/core/toolOutput/reduction.d.ts +0 -12
  122. package/dist/core/toolOutput/reduction.js +1 -1
  123. package/dist/core/validation/outputParser.d.ts +2 -2
  124. package/dist/llm/client.js +5 -1
  125. package/dist/llm/hazeTools.d.ts +139 -124
  126. package/dist/llm/hazeTools.js +20 -11
  127. package/dist/llm/initPrompt.js +1 -1
  128. package/dist/llm/lsp/client.d.ts +45 -0
  129. package/dist/llm/lsp/client.js +195 -0
  130. package/dist/llm/lsp/pool.d.ts +23 -0
  131. package/dist/llm/lsp/pool.js +86 -0
  132. package/dist/llm/lsp/protocol.d.ts +64 -0
  133. package/dist/llm/lsp/protocol.js +128 -0
  134. package/dist/llm/lsp/requests.d.ts +94 -0
  135. package/dist/llm/lsp/requests.js +119 -0
  136. package/dist/llm/lspTools.d.ts +3824 -570
  137. package/dist/llm/lspTools.js +65 -1
  138. package/dist/llm/openaiCodex.d.ts +0 -2
  139. package/dist/llm/openaiCodex.js +0 -4
  140. package/dist/llm/openaiCodexOAuth.d.ts +0 -3
  141. package/dist/llm/openaiCodexOAuth.js +6 -3
  142. package/dist/llm/requestContext.d.ts +5 -1
  143. package/dist/llm/requestContext.js +25 -2
  144. package/dist/llm/systemPrompt.d.ts +1 -0
  145. package/dist/llm/systemPrompt.js +16 -7
  146. package/dist/llm/toolResultTypes.d.ts +1 -15
  147. package/dist/llm/toolResultTypes.js +1 -4
  148. package/dist/llm/tools/editMatch.d.ts +0 -9
  149. package/dist/llm/tools/editMatch.js +1 -1
  150. package/dist/llm/tools/failures.d.ts +6 -0
  151. package/dist/llm/tools/failures.js +8 -2
  152. package/dist/llm/tools/fetchTool.js +1 -1
  153. package/dist/llm/tools/fileToolShared.d.ts +4 -2
  154. package/dist/llm/tools/fileToolShared.js +9 -5
  155. package/dist/llm/tools/gitIgnore.d.ts +25 -32
  156. package/dist/llm/tools/gitIgnore.js +216 -98
  157. package/dist/llm/tools/grepParse.d.ts +2 -1
  158. package/dist/llm/tools/grepRunner.d.ts +1 -1
  159. package/dist/llm/tools/grepRunner.js +2 -2
  160. package/dist/llm/tools/outputCap.d.ts +2 -7
  161. package/dist/llm/tools/outputCap.js +3 -3
  162. package/dist/llm/tools/processTool.d.ts +16 -16
  163. package/dist/llm/tools/processTool.js +1 -1
  164. package/dist/llm/tools/readRecovery.d.ts +0 -2
  165. package/dist/llm/tools/readRecovery.js +4 -2
  166. package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
  167. package/dist/llm/tools/{bashTool.js → shellTool.js} +18 -14
  168. package/dist/llm/tools/toolContext.js +5 -5
  169. package/dist/llm/tools/workspaceFile.d.ts +4 -4
  170. package/dist/llm/tools/workspaceFile.js +29 -17
  171. package/dist/llm/webFetch.d.ts +1 -1
  172. package/dist/skills/SkillLoader.d.ts +1 -11
  173. package/dist/skills/SkillLoader.js +1 -2
  174. package/dist/skills/types.d.ts +2 -1
  175. package/dist/ui/components/Header.js +1 -1
  176. package/dist/ui/components/MarkdownText.js +10 -10
  177. package/dist/ui/components/TextInput.d.ts +1 -1
  178. package/dist/ui/components/TextInput.js +2 -2
  179. package/dist/ui/terminalColors.d.ts +29 -0
  180. package/dist/ui/terminalColors.js +47 -0
  181. package/dist/ui/theme.d.ts +105 -10
  182. package/dist/ui/theme.js +126 -15
  183. package/dist/ui/themes/af-magic.d.ts +7 -0
  184. package/dist/ui/themes/af-magic.js +25 -0
  185. package/dist/ui/themes/agnoster.d.ts +10 -0
  186. package/dist/ui/themes/agnoster.js +40 -0
  187. package/dist/ui/themes/bira.d.ts +10 -0
  188. package/dist/ui/themes/bira.js +28 -0
  189. package/dist/ui/themes/bureau.d.ts +10 -0
  190. package/dist/ui/themes/bureau.js +28 -0
  191. package/dist/ui/themes/clean.d.ts +9 -0
  192. package/dist/ui/themes/clean.js +27 -0
  193. package/dist/ui/themes/cloud.d.ts +6 -0
  194. package/dist/ui/themes/cloud.js +24 -0
  195. package/dist/ui/themes/dst.d.ts +10 -0
  196. package/dist/ui/themes/dst.js +28 -0
  197. package/dist/ui/themes/fishy.d.ts +7 -0
  198. package/dist/ui/themes/fishy.js +25 -0
  199. package/dist/ui/themes/index.d.ts +8 -0
  200. package/dist/ui/themes/index.js +36 -0
  201. package/dist/ui/themes/light.d.ts +3 -0
  202. package/dist/ui/themes/light.js +21 -0
  203. package/dist/ui/themes/purple.d.ts +7 -0
  204. package/dist/ui/themes/purple.js +26 -0
  205. package/dist/ui/themes/robbyrussell.d.ts +8 -0
  206. package/dist/ui/themes/robbyrussell.js +26 -0
  207. package/dist/ui/themes/solarized-dark.d.ts +16 -0
  208. package/dist/ui/themes/solarized-dark.js +44 -0
  209. package/dist/ui/themes/solarized-light.d.ts +12 -0
  210. package/dist/ui/themes/solarized-light.js +40 -0
  211. package/dist/ui/themes/steeef.d.ts +11 -0
  212. package/dist/ui/themes/steeef.js +29 -0
  213. package/dist/utils/buildInfo.d.ts +6 -13
  214. package/dist/utils/buildInfo.js +6 -15
  215. package/dist/utils/fs.d.ts +7 -5
  216. package/dist/utils/fs.js +5 -2
  217. package/dist/utils/path.d.ts +0 -1
  218. package/dist/utils/path.js +1 -1
  219. package/package.json +6 -4
  220. package/dist/cli/commands/lspWizard.d.ts +0 -14
  221. package/dist/cli/commands/lspWizard.js +0 -44
  222. package/dist/cli/commands/mcpWizard.d.ts +0 -15
  223. package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
  224. package/dist/cli/commands/skillConfirmRemove.js +0 -20
  225. package/dist/cli/commands/skillCreation.d.ts +0 -12
  226. package/dist/cli/commands/skillCreation.js +0 -14
  227. package/dist/cli/commands/skillWizard.d.ts +0 -17
  228. package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
  229. package/dist/cli/commands/streaming/idleTimer.js +0 -24
  230. package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -27
  231. package/dist/cli/commands/streaming/turnOutcome.js +0 -29
  232. package/dist/cli/commands/wizardActions.d.ts +0 -47
  233. package/dist/cli/commands/wizardActions.js +0 -47
  234. package/dist/cli/commands/wizardInput.d.ts +0 -4
  235. package/dist/cli/commands/wizardInput.js +0 -19
  236. package/dist/cli/commands/wizardPrompts.d.ts +0 -22
  237. package/dist/cli/commands/wizardPrompts.js +0 -58
  238. package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
  239. package/dist/cli/commands/wizardSuggestions.js +0 -190
  240. package/dist/cli/commands/wizardTransition.d.ts +0 -37
  241. package/dist/cli/commands/wizardTransition.js +0 -43
  242. package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
  243. package/dist/core/agent/toolExecutionBudget.js +0 -49
  244. package/dist/core/agent/turnBudget.d.ts +0 -35
  245. package/dist/core/agent/turnBudget.js +0 -27
  246. package/dist/core/bashOutput/ansi.d.ts +0 -1
  247. package/dist/core/bashOutput/ansi.js +0 -7
  248. package/dist/core/bashOutput/registry.d.ts +0 -4
  249. package/dist/core/goal/completionPolicy.js +0 -43
  250. package/dist/core/goal/requestClassifier.d.ts +0 -3
  251. package/dist/core/goal/requestClassifier.js +0 -18
  252. package/dist/core/goal/sessionGoal.d.ts +0 -8
  253. package/dist/core/goal/sessionGoal.js +0 -30
  254. package/dist/core/limits/byteBudgets.d.ts +0 -20
  255. package/dist/core/limits/byteBudgets.js +0 -20
  256. package/dist/core/limits/textBudgets.d.ts +0 -25
  257. package/dist/core/limits/textBudgets.js +0 -25
  258. package/dist/core/safety/bashClassifier.d.ts +0 -10
  259. package/dist/llm/lsp.d.ts +0 -149
  260. package/dist/llm/lsp.js +0 -368
  261. package/dist/ui/components/ErrorView.d.ts +0 -4
  262. package/dist/ui/components/ErrorView.js +0 -7
  263. package/dist/utils/yaml.d.ts +0 -2
  264. package/dist/utils/yaml.js +0 -8
  265. package/examples/skills/files/SKILL.md +0 -16
  266. package/examples/skills/files/examples/file-editing.md +0 -3
  267. /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
  268. /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
  269. /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
  270. /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
  271. /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
  272. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
  273. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
  274. /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
  275. /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
  276. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
  277. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
  278. /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from 'react';
2
+ import { useEffect, useReducer, useRef, useState } from 'react';
3
3
  import { execFile as execFileCallback } from 'node:child_process';
4
4
  import { promisify } from 'node:util';
5
5
  import { Box, render, Static, Text, useApp, useWindowSize } from 'ink';
@@ -13,7 +13,8 @@ import { activeModel, activeProvider } from '../../config/providers.js';
13
13
  import { isSkillEnabled } from '../../config/skillSettings.js';
14
14
  import { Header } from '../../ui/components/Header.js';
15
15
  import { TextInput } from '../../ui/components/TextInput.js';
16
- import { theme } from '../../ui/theme.js';
16
+ import { setActiveTheme, resolveTheme, theme, DEFAULT_THEME_NAME } from '../../ui/theme.js';
17
+ import { applyTerminalColors, resetTerminalColors } from '../../ui/terminalColors.js';
17
18
  import { handleSlashCommand } from './commands.js';
18
19
  import { runAgentGoal } from './streaming/goalSupervisor.js';
19
20
  import { formatElapsedTimeWhole, imageAttachmentLine } from './formatters.js';
@@ -26,7 +27,7 @@ import { MAX_VISIBLE_TASKS, TaskBar } from '../chat/TaskBar.js';
26
27
  import { AssistantMarkdownChunkView, MessageView, partitionDisplayMessages } from '../chat/messages.js';
27
28
  import { createSessionRecorder } from '../chat/sessionRecorder.js';
28
29
  import { createSessionLifecycle } from '../chat/sessionLifecycle.js';
29
- import { createWizardDispatch } from '../chat/wizardDispatch.js';
30
+ import { createWizardDispatch, initialWizardUiState, wizardUiReducer } from '../chat/wizardDispatch.js';
30
31
  import { buildContextReport } from '../chat/contextReport.js';
31
32
  import { startupContextInfo, startupProviderInfo } from '../chat/startupInfo.js';
32
33
  import { TIPS, randomTipIndex, tipsEnabled } from '../chat/tips.js';
@@ -37,8 +38,7 @@ import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES, placeholderForMode } fr
37
38
  import { inputSuggestionsForState } from '../chat/inputSuggestions.js';
38
39
  import { modelThinkingLabel } from '../../utils/modelName.js';
39
40
  import { detectCheckoutMismatch, formatMismatchWarning, runtimeCapabilities } from '../../utils/buildInfo.js';
40
- import { transitionMcpField, transitionProviderField } from './wizardTransition.js';
41
- import { commandParts } from './wizardInput.js';
41
+ import { commandParts } from './wizardFlow.js';
42
42
  import { backgroundProcessCount, subscribeBackgroundProcesses, teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
43
43
  import { MAX_SESSION_PICKER_RESULTS } from './sessionPicker.js';
44
44
  const execFile = promisify(execFileCallback);
@@ -121,7 +121,6 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
121
121
  const [contextFiles, setContextFiles] = useState([]);
122
122
  const [mode, setMode] = useState('chat');
123
123
  const [sessions, setSessions] = useState([]);
124
- const [selectedSessionId, setSelectedSessionId] = useState();
125
124
  const [busy, setBusy] = useState(false);
126
125
  const [backgroundCount, setBackgroundCount] = useState(backgroundProcessCount);
127
126
  const [busyLabel, setBusyLabel] = useState(() => thinkingLabelForSettings(settings));
@@ -142,17 +141,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
142
141
  const [pausedResume, setPausedResume] = useState(undefined);
143
142
  const [skills, setSkills] = useState([]);
144
143
  const [branchName, setBranchName] = useState();
145
- const [modelProviderFilter, setModelProviderFilter] = useState();
146
- const [discoveredModels, setDiscoveredModels] = useState([]);
147
- const [suggestedModels, setSuggestedModels] = useState([]);
148
- const [selectedProviderName, setSelectedProviderName] = useState();
149
- const [providerDraft, setProviderDraft] = useState({});
150
- const [skillDraft, setSkillDraft] = useState({});
151
- const [selectedSkillName, setSelectedSkillName] = useState();
152
- const [selectedLspName, setSelectedLspName] = useState();
153
- const [lspDraft, setLspDraft] = useState({});
154
- const [selectedMcpName, setSelectedMcpName] = useState();
155
- const [mcpDraft, setMcpDraft] = useState({});
144
+ // Wizard flow state (selection, drafts, model discovery) in one reducer;
145
+ // this replaced twelve individual useState hooks.
146
+ const [wizardState, updateWizard] = useReducer(wizardUiReducer, undefined, initialWizardUiState);
147
+ const { modelProviderFilter, discoveredModels, suggestedModels, selectedProviderName, providerDraft, selectedSkillName, selectedLspName, selectedMcpName } = wizardState;
156
148
  // Wrap setBusy so the busy indicator knows when the turn started, and tick a
157
149
  // heartbeat every second while busy so elapsed time keeps rolling. This keeps
158
150
  // the UI visibly alive during long model thinking / blocked tool runs where
@@ -190,6 +182,26 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
190
182
  return;
191
183
  currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
192
184
  }, [busy]);
185
+ // Live theme switching (docs/theming-plan.md §3.6): whenever the settings'
186
+ // theme name changes (/themes), re-resolve and adopt it so the whole UI
187
+ // repaints without a restart. Ink <Static> history stays as-rendered, so
188
+ // already-printed text keeps its old colors; the terminal defaults (OSC
189
+ // 10/11) follow the new theme. Skipped until settings have loaded once —
190
+ // chatCommand() already resolved the theme before the first render, and the
191
+ // pre-load {} state would briefly flash the default theme.
192
+ const settingsThemeLoadedRef = useRef(false);
193
+ const activeThemeName = settings.theme ?? DEFAULT_THEME_NAME;
194
+ useEffect(() => {
195
+ if (!settingsThemeLoadedRef.current)
196
+ return;
197
+ try {
198
+ setActiveTheme(resolveTheme(activeThemeName));
199
+ applyTerminalColors(theme.foreground, theme.background);
200
+ }
201
+ catch {
202
+ // Malformed theme names were reported at startup; keep the resolved default.
203
+ }
204
+ }, [activeThemeName]);
193
205
  useEffect(() => {
194
206
  void (async () => {
195
207
  const [settingsResult, branch, files] = await Promise.all([
@@ -199,6 +211,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
199
211
  ]);
200
212
  const next = settingsResult.value;
201
213
  setSettings(next);
214
+ settingsThemeLoadedRef.current = true;
202
215
  setSettingsError(settingsResult.error);
203
216
  setBranchName(branch);
204
217
  setContextFiles(files);
@@ -221,7 +234,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
221
234
  if (mismatch) {
222
235
  setMessages(m => [...m, { role: 'system', text: formatMismatchWarning(mismatch) }]);
223
236
  }
224
- else if (!runtimeCapabilities().logicalGoalSupervisor) {
237
+ else if (!runtimeCapabilities().goalSupervisorAvailable) {
225
238
  setMessages(m => [...m, { role: 'system', text: '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).' }]);
226
239
  }
227
240
  })().catch(() => undefined);
@@ -305,7 +318,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
305
318
  await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
306
319
  const next = await listSessions();
307
320
  setSessions(next);
308
- setSelectedSessionId(undefined);
321
+ updateWizard({ type: 'set', key: 'selectedSessionId', value: undefined });
309
322
  if (next.length === 0) {
310
323
  setMessages(m => [...m, { role: 'system', text: 'No saved sessions found for this workspace.' }]);
311
324
  setMode('chat');
@@ -338,18 +351,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
338
351
  if (mode !== 'chat') {
339
352
  setMode('chat');
340
353
  setSessions([]);
341
- setSelectedSessionId(undefined);
342
- setModelProviderFilter(undefined);
343
- setDiscoveredModels([]);
344
- setSuggestedModels([]);
345
- setSelectedProviderName(undefined);
346
- setProviderDraft({});
347
- setSkillDraft({});
348
- setSelectedSkillName(undefined);
349
- setSelectedLspName(undefined);
350
- setLspDraft({});
351
- setSelectedMcpName(undefined);
352
- setMcpDraft({});
354
+ updateWizard({ type: 'reset' });
353
355
  }
354
356
  }
355
357
  function showWizardMessage(message) {
@@ -360,15 +362,12 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
360
362
  // shared settings-patch applier (CR-006). Rebuilt every render so handlers
361
363
  // see current state without new React state.
362
364
  const wizard = createWizardDispatch({
363
- settings, skills, modelProviderFilter, selectedProviderName, selectedSkillName, selectedLspName, selectedMcpName,
364
- sessions, selectedSessionId,
365
- providerDraft, lspDraft, mcpDraft, skillDraft,
365
+ settings, skills, sessions,
366
+ wizard: wizardState, updateWizard,
366
367
  setMode, setSettings,
367
- setSelectedProviderName, setSelectedSkillName, setSelectedLspName, setSelectedMcpName, setSelectedSessionId,
368
+ showMessage: showWizardMessage, refreshSkills,
368
369
  resumeSessionById: sessionLifecycle.resumeSessionById,
369
370
  forkSessionById: sessionLifecycle.forkSessionById,
370
- setModelProviderFilter, setProviderDraft, setSkillDraft, setLspDraft, setMcpDraft, setDiscoveredModels, setSuggestedModels,
371
- showMessage: showWizardMessage, refreshSkills,
372
371
  setBusyLabel, setBusy: setBusyWithHeartbeat,
373
372
  idleBusyLabel: thinkingLabelForSettings(settings),
374
373
  });
@@ -396,41 +395,6 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
396
395
  // Any new submission supersedes a paused-task resume affordance.
397
396
  if (pausedResume)
398
397
  setPausedResume(undefined);
399
- const providerEffects = transitionProviderField({ mode, value, settings, draft: providerDraft });
400
- if (providerEffects) {
401
- for (const effect of providerEffects) {
402
- if (effect.type === 'message')
403
- showWizardMessage(effect.text);
404
- else if (effect.type === 'mode')
405
- setMode(effect.mode);
406
- else if (effect.type === 'provider-draft') {
407
- if (effect.replace)
408
- setProviderDraft(effect.patch);
409
- else
410
- setProviderDraft(draft => ({ ...draft, ...effect.patch }));
411
- }
412
- else if (effect.type === 'discover-provider-models') {
413
- // The draft patch above is still pending React state, so discovery
414
- // receives the merged draft explicitly (same pattern as MCP stdio).
415
- await wizard.discoverProviderModelsForDraft(effect.draft);
416
- }
417
- }
418
- return;
419
- }
420
- const mcpEffects = transitionMcpField({ mode, value, settings, draft: mcpDraft });
421
- if (mcpEffects) {
422
- for (const effect of mcpEffects) {
423
- if (effect.type === 'message')
424
- showWizardMessage(effect.text);
425
- else if (effect.type === 'mode')
426
- setMode(effect.mode);
427
- else if (effect.type === 'mcp-draft')
428
- setMcpDraft(draft => ({ ...draft, ...effect.patch }));
429
- else if (effect.type === 'finish-mcp-stdio')
430
- await wizard.finishMcpCustom(undefined, effect.draft);
431
- }
432
- return;
433
- }
434
398
  if (await wizard.dispatch(mode, value))
435
399
  return;
436
400
  const invokedSkill = skillInvocation(value);
@@ -443,7 +407,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
443
407
  settings,
444
408
  contextFiles,
445
409
  setMode,
446
- setModelProviderFilter,
410
+ setModelProviderFilter: (filter) => updateWizard({ type: 'set', key: 'modelProviderFilter', value: filter }),
447
411
  addSystemMessage: text => setMessages(m => [...m, { role: 'system', text }]),
448
412
  clearConversation,
449
413
  newSession: async () => {
@@ -718,7 +682,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
718
682
  // One row for the optional header plus one for the item's bottom margin.
719
683
  const chrome = (item.showHeader === false ? 0 : 1) + 1;
720
684
  return _jsx(MessageView, { message: item.message, width: contentWidth, showHeader: item.showHeader, maxVisibleLines: Math.max(1, perStreamingItemRows - chrome) }, item.key);
721
- }) }), debug && debugLogs.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { color: theme.muted, bold: true, children: "Debug" }), debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, children: ["\u2022 ", line] }, index))] }), queuedFollowUps.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: [_jsx(Text, { color: theme.muted, children: "Queued follow-ups:" }), queuedFollowUps.map((item, index) => _jsxs(Text, { color: theme.muted, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), pausedResume && !busy && _jsxs(Box, { flexShrink: 0, marginBottom: 1, children: [_jsxs(Text, { color: theme.muted, children: [pausedResume.kind === 'incomplete-goal' ? 'Unfinished goal paused (no measurable progress)' : 'Unfinished goal paused (model stream stalled)', " \u00B7 "] }), _jsxs(Text, { color: theme.command, bold: true, children: ["Press R to ", pausedResume.kind === 'incomplete-goal' ? 'resume' : 'retry'] }), _jsx(Text, { color: theme.muted, children: " or type a follow-up" })] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: expandedTaskCap }) }), busy && _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, tip: showingTip ? TIPS[tipIndex] : undefined }), _jsx(Box, { borderStyle: "round", borderColor: theme.deepPurple, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: Math.max(20, contentWidth - 4), getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
685
+ }) }), debug && debugLogs.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { color: theme.muted, bold: true, children: "Debug" }), debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, children: ["\u2022 ", line] }, index))] }), queuedFollowUps.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: [_jsx(Text, { color: theme.muted, children: "Queued follow-ups:" }), queuedFollowUps.map((item, index) => _jsxs(Text, { color: theme.muted, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), pausedResume && !busy && _jsxs(Box, { flexShrink: 0, marginBottom: 1, children: [_jsxs(Text, { color: theme.muted, children: [pausedResume.kind === 'incomplete-goal' ? 'Unfinished goal paused (no measurable progress)' : 'Unfinished goal paused (model stream stalled)', " \u00B7 "] }), _jsxs(Text, { color: theme.command, bold: true, children: ["Press R to ", pausedResume.kind === 'incomplete-goal' ? 'resume' : 'retry'] }), _jsx(Text, { color: theme.muted, children: " or type a follow-up" })] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: expandedTaskCap }) }), busy && _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, tip: showingTip ? TIPS[tipIndex] : undefined }), _jsx(Box, { borderStyle: "round", borderColor: theme.border, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: Math.max(20, contentWidth - 4), getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
722
686
  if (!tasksExpanded) {
723
687
  setTaskBarPadding(0);
724
688
  setTasksExpanded(true);
@@ -737,15 +701,35 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
737
701
  }, onSubmit: submit }) }) }), debug && metrics.hasTokenBreakdown && _jsxs(Box, { flexShrink: 0, flexDirection: "column", paddingX: 1, children: [_jsxs(Text, { color: theme.muted, bold: true, children: ["Token usage ", metrics.inputEstimated || metrics.outputEstimated ? '(estimated)' : '(precise)'] }), _jsxs(Text, { color: theme.muted, children: [" in=", formatTokenCount(metrics.effectiveInput), " out=", formatTokenCount(metrics.effectiveOutput), tokenUsage.cacheReadTokens > 0 ? ` cached=${formatTokenCount(tokenUsage.cacheReadTokens)}` : '', tokenUsage.noCacheTokens > 0 ? ` uncached=${formatTokenCount(tokenUsage.noCacheTokens)}` : '', tokenUsage.cacheWriteTokens > 0 ? ` cache_write=${formatTokenCount(tokenUsage.cacheWriteTokens)}` : '', tokenUsage.reasoningTokens > 0 ? ` reasoning=${formatTokenCount(tokenUsage.reasoningTokens)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" logical=", formatTokenCount(tokenUsage.logicalInputEstimate), tokenUsage.effectiveNonCachedInput != null ? ` effective_non_cached=${formatTokenCount(tokenUsage.effectiveNonCachedInput)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" system=", formatTokenCount(tokenUsage.systemPrompt), " messages=", formatTokenCount(tokenUsage.messages), " tools=", formatTokenCount(tokenUsage.toolSchemas), " output=", formatTokenCount(tokenUsage.outputEstimate)] })] }), _jsxs(Box, { flexShrink: 0, justifyContent: "space-between", children: [_jsxs(Box, { flexDirection: "column", flexShrink: 1, minWidth: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel })] }), _jsx(Box, { flexShrink: 0, marginLeft: 2, children: _jsx(Text, { color: theme.muted, wrap: "truncate-start", children: activeModelName }) })] })] });
738
702
  }
739
703
  export async function chatCommand(options = {}) {
704
+ // Resolve the theme before any Ink output so every component renders with it.
705
+ // Settings failures must not block startup (the in-app banner already reports
706
+ // them), but an unknown theme name fails loudly with the valid names listed.
707
+ try {
708
+ setActiveTheme(resolveTheme((await readSettings()).theme));
709
+ }
710
+ catch (error) {
711
+ console.error(`[haze] ${error instanceof Error ? error.message : String(error)}; using the ${DEFAULT_THEME_NAME} theme.`);
712
+ }
740
713
  if (process.stdout.isTTY) {
741
714
  process.stdout.write('\u001B[2J\u001B[3J\u001B[H');
715
+ // Adopt the theme's foreground AND background as the terminal defaults
716
+ // (OSC 10 + 11; ignored by terminals without support). Both sides must be
717
+ // themed together: unstyled text inherits the terminal fg, so a light
718
+ // background without a light-mode fg would be unreadable. Restored
719
+ // (OSC 110 + 111) on exit below.
720
+ applyTerminalColors(theme.foreground, theme.background);
742
721
  }
743
722
  await clearTasksFromStore().catch(() => undefined);
744
723
  // Incremental rendering rewrites only changed lines of the live frame, removing
745
724
  // the full-frame erase/rewrite flicker while streaming. The fps cap aligns with
746
725
  // the ~80ms spinner cadence; faster renders would only repaint unchanged lines.
747
726
  const app = render(_jsx(ChatScreen, { debug: options.debug, version: options.version, build: options.build, continueSession: options.continueSession, resumeSessionId: options.resumeSessionId, noSession: options.noSession }), { incrementalRendering: true, maxFps: 15 });
748
- await app.waitUntilExit();
749
- await teardownBackgroundProcesses().catch(() => undefined);
750
- await clearTasksFromStore().catch(() => undefined);
727
+ try {
728
+ await app.waitUntilExit();
729
+ await teardownBackgroundProcesses().catch(() => undefined);
730
+ await clearTasksFromStore().catch(() => undefined);
731
+ }
732
+ finally {
733
+ resetTerminalColors();
734
+ }
751
735
  }
@@ -1,4 +1,11 @@
1
- export type Mode = 'chat' | 'sessions' | 'sessionAction' | 'provider' | 'providerAction' | 'model' | 'modelAddProvider' | 'modelPick' | 'providerAddPreset' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels' | 'providerSetKey' | 'providerRemoveModels' | 'providerConfirmRemove' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsAddScope' | 'skillsAddDescription' | 'skillsConfirmRemove' | 'lsp' | 'lspAction' | 'lspAddPreset' | 'lspAddName' | 'lspAddCommand' | 'lspConfirmRemove' | 'mcp' | 'mcpAction' | 'mcpAddPreset' | 'mcpAddName' | 'mcpAddTransport' | 'mcpAddUrl' | 'mcpAddCommand' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
1
+ import { type WizardStepId } from './wizardFlow.js';
2
+ /**
3
+ * Input-mode classification derived from the wizard flow table
4
+ * (`wizardFlow.ts`): the `Mode` union, the picker/masked/empty-submit sets,
5
+ * and per-mode placeholders all follow from the step definitions, so adding a
6
+ * step updates every classification from its single table entry.
7
+ */
8
+ export type Mode = 'chat' | WizardStepId;
2
9
  /** Modes that show an always-on suggestion picker (server/preset lists). */
3
10
  export declare const PICKER_MODES: ReadonlySet<Mode>;
4
11
  /** Modes that mask input (secrets/API keys). */
@@ -1,49 +1,14 @@
1
+ import { WIZARD_STEPS } from './wizardFlow.js';
2
+ /** Wizard steps viewed through their definition type, for uniform property access. */
3
+ const STEPS = WIZARD_STEPS;
4
+ const stepIds = (steps) => steps.map(step => step.id);
1
5
  /** Modes that show an always-on suggestion picker (server/preset lists). */
2
- export const PICKER_MODES = new Set(['sessions', 'sessionAction', 'provider', 'providerAction', 'providerAddPreset', 'model', 'modelAddProvider', 'modelPick', 'skills', 'skillsAction', 'skillsAddScope', 'lsp', 'lspAction', 'lspAddPreset', 'mcp', 'mcpAction', 'mcpAddPreset', 'mcpAddTransport']);
6
+ export const PICKER_MODES = new Set(stepIds(STEPS.filter(step => step.kind === 'pick')));
3
7
  /** Modes that mask input (secrets/API keys). */
4
- export const MASKED_MODES = new Set(['providerAddKey', 'providerSetKey', 'mcpAddKey', 'mcpSetKey']);
8
+ export const MASKED_MODES = new Set(stepIds(STEPS.filter(step => step.kind === 'masked-input')));
5
9
  /** Modes where submitting an empty value is valid (optional steps). */
6
- export const SUBMIT_EMPTY_MODES = new Set(['providerAddKey', 'mcpAddKey']);
7
- const PLACEHOLDERS = {
8
- sessions: 'Choose a saved session',
9
- sessionAction: 'Resume or fork this session',
10
- provider: 'Choose provider',
11
- providerAction: 'Choose provider action',
12
- providerAddPreset: 'Choose a provider preset or custom',
13
- model: 'Choose model, or add model',
14
- modelAddProvider: 'Choose a provider to add models to',
15
- modelPick: 'Choose a model to add',
16
- providerAddName: 'Provider name',
17
- providerAddUrl: 'https://example.com/v1',
18
- providerAddKey: 'API key, or blank for local',
19
- providerSetKey: 'API key',
20
- providerAddModels: 'model-a, model-b',
21
- providerAppendModels: 'model-a, model-b',
22
- providerRemoveModels: 'model-a, model-b',
23
- providerConfirmRemove: 'Type "yes" to confirm',
24
- skills: 'Choose a skill or add skill',
25
- skillsAction: 'show info, enable, disable, validate, or remove',
26
- skillsAddName: 'Skill name (kebab-case, e.g. security-review)',
27
- skillsAddScope: 'Choose this project or global',
28
- skillsAddDescription: 'Describe what the skill should do',
29
- skillsConfirmRemove: 'Type "yes" to confirm',
30
- lsp: 'Choose LSP server or add server',
31
- lspAction: 'enable, disable, or remove server',
32
- lspAddPreset: 'Choose an LSP preset or custom',
33
- lspAddName: 'LSP server name (e.g. typescript)',
34
- lspAddCommand: 'Command (e.g. typescript-language-server --stdio)',
35
- lspConfirmRemove: 'Type "yes" to confirm',
36
- mcp: 'Choose MCP server or add server',
37
- mcpAction: 'enable, disable, remove, or set key',
38
- mcpAddPreset: 'Choose an MCP preset or custom',
39
- mcpAddName: 'MCP server name (e.g. context7)',
40
- mcpAddTransport: 'http, sse, or stdio',
41
- mcpAddUrl: 'https://mcp.example.com/mcp',
42
- mcpAddCommand: 'Command (e.g. npx -y @pkg/server)',
43
- mcpAddKey: 'API key, or blank to skip',
44
- mcpSetKey: 'API key',
45
- mcpConfirmRemove: 'Type "yes" to confirm',
46
- };
10
+ export const SUBMIT_EMPTY_MODES = new Set(stepIds(STEPS.filter(step => step.optional)));
47
11
  export function placeholderForMode(mode, busy) {
48
- return PLACEHOLDERS[mode] ?? (busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask haze to help build your app');
12
+ const step = WIZARD_STEPS.find(candidate => candidate.id === mode);
13
+ return step?.placeholder ?? (busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask haze to help build your app');
49
14
  }
@@ -5,6 +5,8 @@ export const COMMAND_HELP_ENTRIES = [
5
5
  { usage: '/model <name-or-provider:name>', description: 'Set a model directly. Selecting a model also sets its provider.' },
6
6
  { usage: '/settings', description: 'Show the configured provider, model, API key status, LSP/MCP servers, skills, and loaded context files.' },
7
7
  { usage: '/settings open', description: 'Open ~/.haze/settings.json with the OS default app.' },
8
+ { usage: '/themes', description: 'Choose a terminal theme from the built-in registry (light palettes and oh-my-zsh ports included); applies immediately.' },
9
+ { usage: '/themes <name>', description: 'Set the theme directly, e.g. /themes robbyrussell. Saved to ~/.haze/settings.json; text already on screen keeps its old colors.' },
8
10
  { usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
9
11
  { usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
10
12
  { usage: '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>', description: 'Run genuinely independent tasks through disposable contexts. Runtime enforces profile concurrency, deadlines, and mutation serialization; control guidance is not persisted. Declines non-parallel work.' },
@@ -7,6 +7,7 @@ import { handleFleetCommand } from './fleetCommand.js';
7
7
  import { handleInitCommand } from './initCommand.js';
8
8
  import { handleLogsCommand } from './logsCommand.js';
9
9
  import { handleModelCommand } from './modelCommand.js';
10
+ import { handleThemesCommand } from './themesCommand.js';
10
11
  import { formatSettingsSummary } from './settingsSummary.js';
11
12
  async function ensureSettingsFile(settings) {
12
13
  if (!await fs.pathExists(SETTINGS_FILE))
@@ -57,6 +58,7 @@ const SLASH_COMMANDS = [
57
58
  ctx.addSystemMessage(`Tips rotation ${currentlyEnabled ? 'disabled' : 'enabled'}.`);
58
59
  return HANDLED;
59
60
  } },
61
+ { match: exactOrArgs('/themes'), run: async (args, ctx) => await handleThemesCommand(args, ctx) },
60
62
  { match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
61
63
  ];
62
64
  export async function handleSlashCommand(value, ctx) {
@@ -65,7 +65,7 @@ export async function runDoctor(deps = {}) {
65
65
  write('Checkout mismatch: none');
66
66
  write();
67
67
  }
68
- if (!capabilities.logicalGoalSupervisor) {
68
+ if (!capabilities.goalSupervisorAvailable) {
69
69
  write('Warning: the goal supervisor is unavailable in this runtime; exhausting a');
70
70
  write("turn's step/tool budget may pause the goal instead of continuing automatically.");
71
71
  write();
@@ -19,9 +19,8 @@ export declare function imageAttachmentLine(attachment: {
19
19
  }): string;
20
20
  export declare function formatElapsedTime(milliseconds: number): string;
21
21
  export declare function formatElapsedTimeWhole(milliseconds: number): string;
22
- export declare function toolOutputDetails(value: unknown): string;
23
- export type ContextReportCategory = 'builtin' | 'lsp' | 'skill' | 'subagent' | 'mcp';
24
- export interface ContextReportTool {
22
+ type ContextReportCategory = 'builtin' | 'lsp' | 'skill' | 'subagent' | 'mcp';
23
+ interface ContextReportTool {
25
24
  name: string;
26
25
  tokens: number;
27
26
  category: ContextReportCategory;
@@ -47,3 +46,4 @@ export interface ContextReportData {
47
46
  }
48
47
  /** Render a detailed, /context-style token breakdown. Pure for testability. */
49
48
  export declare function formatContextReport(data: ContextReportData): string;
49
+ export {};
@@ -18,9 +18,9 @@ export function compact(value, maxLength = 180) {
18
18
  }
19
19
  export function toolCallSummary(toolName, input) {
20
20
  const data = input;
21
- if (toolName === 'bash' && typeof data?.command === 'string') {
21
+ if (toolName === 'shell' && typeof data?.command === 'string') {
22
22
  const mode = data.background === true ? ' (background)' : typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
23
- return `bash $ ${data.command}${mode}`;
23
+ return `shell $ ${data.command}${mode}`;
24
24
  }
25
25
  if (toolName === 'process' && typeof data?.action === 'string')
26
26
  return `process ${data.action}${typeof data.backgroundId === 'string' ? ` ${data.backgroundId}` : ''}`;
@@ -60,7 +60,9 @@ export function toolCallSummary(toolName, input) {
60
60
  return `lspWorkspaceSymbols "${data.query}"`;
61
61
  if (toolName === 'lspSymbols' && typeof data?.path === 'string')
62
62
  return `lspSymbols ${data.path}`;
63
- if ((toolName === 'lspDefinition' || toolName === 'lspReferences') && typeof data?.path === 'string')
63
+ if (toolName === 'lspDiagnostics' && typeof data?.path === 'string')
64
+ return `lspDiagnostics ${data.path}`;
65
+ if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
64
66
  return `${toolName} ${data.path}:${data.line}:${data.column}`;
65
67
  return `${toolName} ${compact(input)}`;
66
68
  }
@@ -131,6 +133,12 @@ export function toolResultSummary(event) {
131
133
  }
132
134
  return 'completed';
133
135
  }
136
+ if (output.reasonCode === 'secret_file_protected') {
137
+ // Protection events are visible but distinct from ordinary failures so
138
+ // the developer can audit them at a glance; never print file contents.
139
+ const protectedPath = typeof output.path === 'string' && output.path ? ` (${compact(output.path, 80)})` : '';
140
+ return `blocked: protected secret file${protectedPath}`;
141
+ }
134
142
  const reason = typeof output.reasonCode === 'string' ? ` (${output.reasonCode})` : '';
135
143
  return typeof output.error === 'string' ? `failed${reason}: ${compact(output.error)}` : `failed${reason}`;
136
144
  }
@@ -145,7 +153,7 @@ export function busyToolLabel(toolName, input) {
145
153
  const data = input;
146
154
  const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
147
155
  switch (toolName) {
148
- case 'bash':
156
+ case 'shell':
149
157
  return data?.background === true ? 'Starting background process' : 'Running command';
150
158
  case 'process':
151
159
  return 'Managing background process';
@@ -209,27 +217,6 @@ export function formatElapsedTimeWhole(milliseconds) {
209
217
  return `${minutes}m ${seconds}s`;
210
218
  return `${seconds}s`;
211
219
  }
212
- export function toolOutputDetails(value) {
213
- if (!value || typeof value !== 'object')
214
- return '';
215
- const output = value;
216
- const stdout = output.stdout?.text?.trim();
217
- const stderr = output.stderr?.text?.trim();
218
- const meta = [
219
- output.cwd ? `cwd: ${output.cwd}` : '',
220
- output.classification?.riskLevel ? `classification: ${output.classification.riskLevel}${output.classification.reason ? ` — ${output.classification.reason}` : ''}` : '',
221
- output.validationSummary?.summaryText ? `validation: ${output.validationSummary.summaryText}${output.validationSummary.suggestedNextStep ? `\nnext: ${output.validationSummary.suggestedNextStep}` : ''}` : '',
222
- ].filter(Boolean).join('\n');
223
- const parts = [
224
- meta,
225
- stdout ? `stdout:\n${compact(stdout, 1200)}` : '',
226
- stderr ? `stderr:\n${compact(stderr, 1200)}` : '',
227
- ].filter(Boolean);
228
- if (parts.length === 0)
229
- return '';
230
- const truncated = output.stdout?.truncated || output.stderr?.truncated;
231
- return `${parts.join('\n\n')}${truncated ? '\n… output truncated' : ''}`;
232
- }
233
220
  const CONTEXT_CATEGORY_LABEL = {
234
221
  builtin: 'Built-in',
235
222
  lsp: 'LSP',
@@ -1,6 +1,5 @@
1
1
  import { configuredProviders, findProvider, upsertProvider } from '../../config/providers.js';
2
- import { PROVIDER_ACTIONS } from './wizardActions.js';
3
- import { commaList } from './wizardInput.js';
2
+ import { PROVIDER_ACTIONS, commaList } from './wizardFlow.js';
4
3
  import { assertCredentialedEndpointSecure } from '../../config/endpointSecurity.js';
5
4
  import { presetModelLimitsForModels } from '../../config/providerPresets.js';
6
5
  import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
@@ -163,7 +162,7 @@ export function providerActionResult(action, provider) {
163
162
  return { message: '', selectedName: undefined, mode: 'model' };
164
163
  if (action === PROVIDER_ACTIONS.addModels)
165
164
  return { message: `Comma-separated model names to add to ${provider.name}?`, mode: 'providerAppendModels' };
166
- if (action === PROVIDER_ACTIONS.setApiKey)
165
+ if (action === PROVIDER_ACTIONS.manageAccess)
167
166
  return { message: `New API key for ${provider.name}? (current: ${provider.key ? 'saved' : 'not set'})`, mode: 'providerSetKey' };
168
167
  if (action === PROVIDER_ACTIONS.removeModels)
169
168
  return { message: `Comma-separated model names to remove from ${provider.name}?\nCurrent models: ${provider.models.join(', ')}`, mode: 'providerRemoveModels' };
@@ -59,7 +59,7 @@ function toHeadlessStreamEvent(event) {
59
59
  case 'step_start':
60
60
  return { type: 'step_start', attempt: event.attempt, step: event.step, at: event.at };
61
61
  case 'step_end':
62
- return { type: 'step_end', attempt: event.attempt, step: event.step, finishReason: event.finishReason, toolCallCount: event.toolCallCount, usage: event.usage, at: event.at };
62
+ return { type: 'step_end', attempt: event.attempt, step: event.step, finishReason: event.finishReason, toolCallCount: event.toolCallCount, usage: event.usage, ...(event.responseModel ? { responseModel: event.responseModel } : {}), at: event.at };
63
63
  case 'message_start':
64
64
  return { type: 'message_start', id: event.id, role: event.role, at: event.at };
65
65
  case 'message_update':
@@ -0,0 +1,34 @@
1
+ import { type HazeLspServer } from '../../config/lspSettings.js';
2
+ import type { HazeMcpServer, HazeSettings } from '../../config/settings.js';
3
+ /**
4
+ * Pure result functions for the LSP and MCP server wizard flows. The
5
+ * corresponding steps (placeholders, kinds, suggestions) live in
6
+ * `wizardFlow.ts`; the submit orchestration lives in
7
+ * `chat/wizardDispatch.ts`.
8
+ */
9
+ export type LspWizardResult = {
10
+ message?: string;
11
+ mode?: 'chat' | 'lsp' | 'lspAction' | 'lspAddName' | 'lspConfirmRemove';
12
+ selectedName?: string;
13
+ settingsPatch?: Partial<HazeSettings>;
14
+ server?: HazeLspServer;
15
+ clearDraft?: boolean;
16
+ };
17
+ export declare function selectLspServerResult(settings: HazeSettings, serverName: string): LspWizardResult;
18
+ export declare function selectLspPresetResult(settings: HazeSettings, presetId: string): LspWizardResult;
19
+ export declare function selectLspActionResult(settings: HazeSettings, selectedName: string | undefined, action: string): LspWizardResult;
20
+ export declare function finishLspCustomResult(settings: HazeSettings, draftName: string | undefined, commandLine: string): LspWizardResult;
21
+ export type McpWizardResult = {
22
+ message?: string;
23
+ mode?: 'chat' | 'mcp' | 'mcpAction' | 'mcpAddName' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
24
+ selectedName?: string;
25
+ draft?: Partial<HazeMcpServer>;
26
+ settingsPatch?: Partial<HazeSettings>;
27
+ server?: HazeMcpServer;
28
+ clearDraft?: boolean;
29
+ };
30
+ export declare function selectMcpServerResult(settings: HazeSettings, serverName: string): McpWizardResult;
31
+ export declare function selectMcpPresetResult(settings: HazeSettings, presetId: string): McpWizardResult;
32
+ export declare function selectMcpActionResult(settings: HazeSettings, selectedName: string | undefined, action: string): McpWizardResult;
33
+ export declare function finishMcpCustomResult(settings: HazeSettings, draft: Partial<HazeMcpServer>, keyValue?: string): McpWizardResult;
34
+ export declare function setMcpServerKeyResult(settings: HazeSettings, selectedName: string | undefined, keyValue: string): McpWizardResult;
@@ -1,6 +1,48 @@
1
+ import { configuredLspServers, lspPreset, upsertLspServer, setLspServerEnabled } from '../../config/lspSettings.js';
1
2
  import { findMcpPreset, findMcpServer, toggleMcpServer, upsertMcpServer } from '../../config/mcpSettings.js';
2
- import { COMMON_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, SERVER_CHOICES } from './wizardActions.js';
3
3
  import { assertCredentialedEndpointSecure } from '../../config/endpointSecurity.js';
4
+ import { COMMON_ACTIONS, LSP_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, SERVER_CHOICES, commandParts } from './wizardFlow.js';
5
+ export function selectLspServerResult(settings, serverName) {
6
+ if (serverName === SERVER_CHOICES.addServer)
7
+ return { mode: 'lspAddName', clearDraft: true, message: 'Choose an LSP preset, or select "custom" to enter a name and command manually.' };
8
+ const server = configuredLspServers(settings).find(candidate => candidate.name === serverName);
9
+ if (!server)
10
+ return { mode: 'chat', message: `No LSP server named ${serverName}. Use /lsp and choose add server.` };
11
+ return { mode: 'lspAction', selectedName: server.name, message: `${server.name}: choose an action.` };
12
+ }
13
+ export function selectLspPresetResult(settings, presetId) {
14
+ if (presetId === SERVER_CHOICES.custom)
15
+ return { mode: 'lspAddName', clearDraft: true, message: 'LSP server name? Example: typescript, rust, my-lsp.' };
16
+ const preset = lspPreset(presetId);
17
+ if (!preset)
18
+ return { message: `Unknown preset: ${presetId}.` };
19
+ if (configuredLspServers(settings).some(server => server.name === preset.name))
20
+ return { mode: 'chat', message: `LSP server ${preset.name} already exists. Use /lsp to manage existing servers.` };
21
+ return { mode: 'chat', server: preset, settingsPatch: { lspServers: upsertLspServer(settings, preset) }, message: `Added LSP preset ${preset.name}. Ensure ${preset.command} is installed and on PATH; tools appear once it is.` };
22
+ }
23
+ export function selectLspActionResult(settings, selectedName, action) {
24
+ if (!selectedName)
25
+ return { mode: 'lsp' };
26
+ const server = configuredLspServers(settings).find(candidate => candidate.name === selectedName);
27
+ if (!server)
28
+ return { mode: 'chat', selectedName: undefined, message: `LSP server ${selectedName} not found.` };
29
+ if (action === COMMON_ACTIONS.enable || action === COMMON_ACTIONS.disable) {
30
+ const enabled = action === COMMON_ACTIONS.enable;
31
+ return { mode: 'chat', selectedName: undefined, settingsPatch: { lspServers: setLspServerEnabled(settings, selectedName, enabled) }, message: `LSP server ${selectedName} ${enabled ? 'enabled' : 'disabled'}.` };
32
+ }
33
+ if (action === LSP_ACTIONS.removeServer)
34
+ return { mode: 'lspConfirmRemove', message: `Remove LSP server ${selectedName}? Type "yes" to confirm. Esc to cancel.` };
35
+ return { message: `Unknown LSP action: ${action}` };
36
+ }
37
+ export function finishLspCustomResult(settings, draftName, commandLine) {
38
+ const name = draftName?.trim();
39
+ const parts = commandParts(commandLine);
40
+ const command = parts[0];
41
+ if (!name || !command)
42
+ return { mode: 'chat', clearDraft: true, message: 'LSP server name and command are required.' };
43
+ const server = { name, command, args: parts.slice(1), extensions: [], rootPatterns: ['.git'], enabled: true };
44
+ return { mode: 'chat', clearDraft: true, server, settingsPatch: { lspServers: upsertLspServer(settings, server) }, message: `Added LSP server ${name} (${command}${parts.length > 1 ? ` ${parts.slice(1).join(' ')}` : ''}). Add extensions in ~/.haze/settings.json so tools can auto-select it.` };
45
+ }
4
46
  export function selectMcpServerResult(settings, serverName) {
5
47
  if (serverName === SERVER_CHOICES.addServer)
6
48
  return { mode: 'mcpAddName', clearDraft: true, message: 'Choose an MCP preset, or select "custom" to enter details manually.' };
@@ -33,7 +75,7 @@ export function selectMcpActionResult(settings, selectedName, action) {
33
75
  const enabled = action === COMMON_ACTIONS.enable;
34
76
  return { mode: 'chat', selectedName: undefined, settingsPatch: { mcpServers: toggleMcpServer(settings, selectedName, enabled) ?? [] }, message: `MCP server ${selectedName} ${enabled ? 'enabled' : 'disabled'}.` };
35
77
  }
36
- if (action === MCP_ACTIONS.setApiKey) {
78
+ if (action === MCP_ACTIONS.manageAccess) {
37
79
  if (server.transport === 'stdio')
38
80
  return { mode: 'chat', selectedName: undefined, message: 'Stdio MCP authentication must be handled by its command or wrapper; HTTP headers do not apply.' };
39
81
  return { mode: 'mcpSetKey', message: `New API key for ${selectedName}? (current: ${server.headers?.length ? 'saved' : 'not set'}) Sent as Authorization: Bearer <value>.` };
@@ -3,6 +3,7 @@ import { configuredLspServers } from '../../config/lspSettings.js';
3
3
  import { configuredMcpServers } from '../../config/mcpSettings.js';
4
4
  import { activeProvider as resolveActiveProvider, configuredProviders, providerHasKey, providerImageCapable } from '../../config/providers.js';
5
5
  import { isSkillEnabled } from '../../config/skillSettings.js';
6
+ import { DEFAULT_THEME_NAME } from '../../ui/theme.js';
6
7
  import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
7
8
  export async function formatSettingsSummary(settings, contextFiles) {
8
9
  const providers = configuredProviders(settings);
@@ -30,6 +31,7 @@ export async function formatSettingsSummary(settings, contextFiles) {
30
31
  `Model: ${settings.model ?? 'not set'}`,
31
32
  `Base URL: ${activeProvider?.url ?? settings.baseURL ?? 'not configured'}`,
32
33
  `API key: ${activeProvider && providerHasKey(settings, activeProvider) ? 'saved' : 'missing'}`,
34
+ `Theme: ${settings.theme ?? `${DEFAULT_THEME_NAME} (default)`}`,
33
35
  `Configured providers: ${providers.map(provider => `${provider.name}${providerImageCapable(provider) ? ' (images)' : ''}`).join(', ') || 'none'}`,
34
36
  `LSP servers: ${lspServers.map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
35
37
  `MCP servers: ${configuredMcpServers(settings).map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,