@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.
- package/CHANGELOG.md +33 -0
- package/README.md +28 -14
- package/SECURITY.md +5 -3
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/TaskBar.js +1 -1
- package/dist/cli/chat/chatMetrics.d.ts +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/fileMentionSuggestions.js +1 -1
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +10 -41
- package/dist/cli/chat/messages.d.ts +0 -2
- package/dist/cli/chat/messages.js +5 -5
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +257 -130
- package/dist/cli/commands/chat.js +61 -77
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/commandHelp.js +2 -0
- package/dist/cli/commands/commands.js +2 -0
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +12 -25
- package/dist/cli/commands/providerWizard.js +2 -3
- package/dist/cli/commands/runCommand.js +1 -1
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/settingsSummary.js +2 -0
- package/dist/cli/commands/skillsWizard.d.ts +41 -0
- package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
- package/dist/cli/commands/streaming/abortCause.d.ts +2 -1
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
- package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
- package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
- package/dist/cli/commands/streaming/attemptSetup.js +167 -0
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
- package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
- package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
- package/dist/cli/commands/streaming/stallRecovery.js +105 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
- package/dist/cli/commands/streaming/streamLoop.js +448 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +14 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
- package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -0
- package/dist/cli/commands/streaming.d.ts +14 -25
- package/dist/cli/commands/streaming.js +43 -754
- package/dist/cli/commands/themesCommand.d.ts +17 -0
- package/dist/cli/commands/themesCommand.js +24 -0
- package/dist/cli/commands/wizardFlow.d.ts +341 -0
- package/dist/cli/commands/wizardFlow.js +397 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.js +1 -1
- package/dist/config/contextFiles.js +9 -3
- package/dist/config/inputHistory.d.ts +0 -1
- package/dist/config/inputHistory.js +1 -1
- package/dist/config/modelDiscovery.d.ts +0 -15
- package/dist/config/modelDiscovery.js +1 -1
- package/dist/config/settings.d.ts +9 -0
- package/dist/config/settings.js +4 -0
- package/dist/config/skillSettings.js +4 -4
- package/dist/config/updateCheck.d.ts +0 -1
- package/dist/config/updateCheck.js +1 -1
- package/dist/core/agent/budgets.d.ts +63 -1
- package/dist/core/agent/budgets.js +84 -1
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/completionController.d.ts +7 -13
- package/dist/core/agent/completionController.js +17 -8
- package/dist/core/agent/contextBudget.d.ts +0 -4
- package/dist/core/agent/contextBudget.js +3 -3
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +5 -1
- package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
- package/dist/core/agent/goalPolicy.js +106 -0
- package/dist/core/agent/requestAssembly.d.ts +2 -2
- package/dist/core/agent/requestAssembly.js +16 -4
- package/dist/core/agent/toolCapabilities.d.ts +2 -2
- package/dist/core/agent/toolCapabilities.js +5 -5
- package/dist/core/agent/toolOutputStore.js +1 -1
- package/dist/core/agent/toolResults.js +1 -1
- package/dist/core/agent/workState.d.ts +6 -3
- package/dist/core/agent/workState.js +62 -7
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +0 -6
- package/dist/core/deadline.js +1 -1
- package/dist/core/io/boundedRead.js +1 -1
- package/dist/core/limits.d.ts +51 -0
- package/dist/core/limits.js +51 -0
- package/dist/core/log/llmLog.js +1 -1
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +10 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/secretPaths.d.ts +18 -0
- package/dist/core/safety/secretPaths.js +115 -0
- package/dist/core/safety/shellClassifier.d.ts +11 -0
- package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
- package/dist/core/safety/urlGuard.d.ts +1 -1
- package/dist/core/session/sessionSlimming.d.ts +0 -3
- package/dist/core/session/sessionSlimming.js +2 -3
- package/dist/core/session/sessionStore.d.ts +1 -0
- package/dist/core/session/sessionStore.js +39 -20
- package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
- package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
- package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
- package/dist/core/shellOutput/registry.d.ts +2 -0
- package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
- package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
- package/dist/core/subagent/contracts.d.ts +2 -14
- package/dist/core/subagent/contracts.js +3 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentRunner.js +3 -4
- package/dist/core/toolOutput/reduction.d.ts +0 -12
- package/dist/core/toolOutput/reduction.js +1 -1
- package/dist/core/validation/outputParser.d.ts +2 -2
- package/dist/llm/client.js +5 -1
- package/dist/llm/hazeTools.d.ts +139 -124
- package/dist/llm/hazeTools.js +20 -11
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp/client.d.ts +45 -0
- package/dist/llm/lsp/client.js +195 -0
- package/dist/llm/lsp/pool.d.ts +23 -0
- package/dist/llm/lsp/pool.js +86 -0
- package/dist/llm/lsp/protocol.d.ts +64 -0
- package/dist/llm/lsp/protocol.js +128 -0
- package/dist/llm/lsp/requests.d.ts +94 -0
- package/dist/llm/lsp/requests.js +119 -0
- package/dist/llm/lspTools.d.ts +3824 -570
- package/dist/llm/lspTools.js +65 -1
- package/dist/llm/openaiCodex.d.ts +0 -2
- package/dist/llm/openaiCodex.js +0 -4
- package/dist/llm/openaiCodexOAuth.d.ts +0 -3
- package/dist/llm/openaiCodexOAuth.js +6 -3
- package/dist/llm/requestContext.d.ts +5 -1
- package/dist/llm/requestContext.js +25 -2
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +16 -7
- package/dist/llm/toolResultTypes.d.ts +1 -15
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +0 -9
- package/dist/llm/tools/editMatch.js +1 -1
- package/dist/llm/tools/failures.d.ts +6 -0
- package/dist/llm/tools/failures.js +8 -2
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +4 -2
- package/dist/llm/tools/fileToolShared.js +9 -5
- package/dist/llm/tools/gitIgnore.d.ts +25 -32
- package/dist/llm/tools/gitIgnore.js +216 -98
- package/dist/llm/tools/grepParse.d.ts +2 -1
- package/dist/llm/tools/grepRunner.d.ts +1 -1
- package/dist/llm/tools/grepRunner.js +2 -2
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -3
- package/dist/llm/tools/processTool.d.ts +16 -16
- package/dist/llm/tools/processTool.js +1 -1
- package/dist/llm/tools/readRecovery.d.ts +0 -2
- package/dist/llm/tools/readRecovery.js +4 -2
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
- package/dist/llm/tools/{bashTool.js → shellTool.js} +18 -14
- package/dist/llm/tools/toolContext.js +5 -5
- package/dist/llm/tools/workspaceFile.d.ts +4 -4
- package/dist/llm/tools/workspaceFile.js +29 -17
- package/dist/llm/webFetch.d.ts +1 -1
- package/dist/skills/SkillLoader.d.ts +1 -11
- package/dist/skills/SkillLoader.js +1 -2
- package/dist/skills/types.d.ts +2 -1
- package/dist/ui/components/Header.js +1 -1
- package/dist/ui/components/MarkdownText.js +10 -10
- package/dist/ui/components/TextInput.d.ts +1 -1
- package/dist/ui/components/TextInput.js +2 -2
- package/dist/ui/terminalColors.d.ts +29 -0
- package/dist/ui/terminalColors.js +47 -0
- package/dist/ui/theme.d.ts +105 -10
- package/dist/ui/theme.js +126 -15
- package/dist/ui/themes/af-magic.d.ts +7 -0
- package/dist/ui/themes/af-magic.js +25 -0
- package/dist/ui/themes/agnoster.d.ts +10 -0
- package/dist/ui/themes/agnoster.js +40 -0
- package/dist/ui/themes/bira.d.ts +10 -0
- package/dist/ui/themes/bira.js +28 -0
- package/dist/ui/themes/bureau.d.ts +10 -0
- package/dist/ui/themes/bureau.js +28 -0
- package/dist/ui/themes/clean.d.ts +9 -0
- package/dist/ui/themes/clean.js +27 -0
- package/dist/ui/themes/cloud.d.ts +6 -0
- package/dist/ui/themes/cloud.js +24 -0
- package/dist/ui/themes/dst.d.ts +10 -0
- package/dist/ui/themes/dst.js +28 -0
- package/dist/ui/themes/fishy.d.ts +7 -0
- package/dist/ui/themes/fishy.js +25 -0
- package/dist/ui/themes/index.d.ts +8 -0
- package/dist/ui/themes/index.js +36 -0
- package/dist/ui/themes/light.d.ts +3 -0
- package/dist/ui/themes/light.js +21 -0
- package/dist/ui/themes/purple.d.ts +7 -0
- package/dist/ui/themes/purple.js +26 -0
- package/dist/ui/themes/robbyrussell.d.ts +8 -0
- package/dist/ui/themes/robbyrussell.js +26 -0
- package/dist/ui/themes/solarized-dark.d.ts +16 -0
- package/dist/ui/themes/solarized-dark.js +44 -0
- package/dist/ui/themes/solarized-light.d.ts +12 -0
- package/dist/ui/themes/solarized-light.js +40 -0
- package/dist/ui/themes/steeef.d.ts +11 -0
- package/dist/ui/themes/steeef.js +29 -0
- package/dist/utils/buildInfo.d.ts +6 -13
- package/dist/utils/buildInfo.js +6 -15
- package/dist/utils/fs.d.ts +7 -5
- package/dist/utils/fs.js +5 -2
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +1 -1
- package/package.json +6 -4
- package/dist/cli/commands/lspWizard.d.ts +0 -14
- package/dist/cli/commands/lspWizard.js +0 -44
- package/dist/cli/commands/mcpWizard.d.ts +0 -15
- package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
- package/dist/cli/commands/skillConfirmRemove.js +0 -20
- package/dist/cli/commands/skillCreation.d.ts +0 -12
- package/dist/cli/commands/skillCreation.js +0 -14
- package/dist/cli/commands/skillWizard.d.ts +0 -17
- package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
- package/dist/cli/commands/streaming/idleTimer.js +0 -24
- package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -27
- package/dist/cli/commands/streaming/turnOutcome.js +0 -29
- package/dist/cli/commands/wizardActions.d.ts +0 -47
- package/dist/cli/commands/wizardActions.js +0 -47
- package/dist/cli/commands/wizardInput.d.ts +0 -4
- package/dist/cli/commands/wizardInput.js +0 -19
- package/dist/cli/commands/wizardPrompts.d.ts +0 -22
- package/dist/cli/commands/wizardPrompts.js +0 -58
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -190
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
- package/dist/core/agent/toolExecutionBudget.js +0 -49
- package/dist/core/agent/turnBudget.d.ts +0 -35
- package/dist/core/agent/turnBudget.js +0 -27
- package/dist/core/bashOutput/ansi.d.ts +0 -1
- package/dist/core/bashOutput/ansi.js +0 -7
- package/dist/core/bashOutput/registry.d.ts +0 -4
- package/dist/core/goal/completionPolicy.js +0 -43
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -18
- package/dist/core/goal/sessionGoal.d.ts +0 -8
- package/dist/core/goal/sessionGoal.js +0 -30
- package/dist/core/limits/byteBudgets.d.ts +0 -20
- package/dist/core/limits/byteBudgets.js +0 -20
- package/dist/core/limits/textBudgets.d.ts +0 -25
- package/dist/core/limits/textBudgets.js +0 -25
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -149
- package/dist/llm/lsp.js +0 -368
- package/dist/ui/components/ErrorView.d.ts +0 -4
- package/dist/ui/components/ErrorView.js +0 -7
- package/dist/utils/yaml.d.ts +0 -2
- package/dist/utils/yaml.js +0 -8
- package/examples/skills/files/SKILL.md +0 -16
- package/examples/skills/files/examples/file-editing.md +0 -3
- /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
- /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 {
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
const [
|
|
148
|
-
const
|
|
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().
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
364
|
-
|
|
365
|
-
providerDraft, lspDraft, mcpDraft, skillDraft,
|
|
365
|
+
settings, skills, sessions,
|
|
366
|
+
wizard: wizardState, updateWizard,
|
|
366
367
|
setMode, setSettings,
|
|
367
|
-
|
|
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.
|
|
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
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
23
|
-
|
|
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 === '
|
|
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 `
|
|
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 (
|
|
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 '
|
|
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 './
|
|
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.
|
|
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.
|
|
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'}`,
|