@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
|
@@ -11,20 +11,88 @@ import { isLocalProviderUrl } from '../../llm/client.js';
|
|
|
11
11
|
import { FALLBACK_LOCAL_CONTEXT_TOKENS } from '../../core/agent/contextBudget.js';
|
|
12
12
|
import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
|
|
13
13
|
import { createSkill, toSkillDirName } from '../../skills/builder/SkillBuilder.js';
|
|
14
|
-
import { PROVIDER_ACTIONS, PROVIDER_CHOICES, MODEL_CHOICES, SERVER_CHOICES } from '../commands/
|
|
15
|
-
import {
|
|
16
|
-
import { finishLspCustomResult, selectLspActionResult, selectLspPresetResult, selectLspServerResult } from '../commands/lspWizard.js';
|
|
17
|
-
import { finishMcpCustomResult, selectMcpActionResult, selectMcpPresetResult, selectMcpServerResult, setMcpServerKeyResult } from '../commands/mcpWizard.js';
|
|
14
|
+
import { PROVIDER_ACTIONS, PROVIDER_CHOICES, MODEL_CHOICES, SERVER_CHOICES, captureLspName, captureMcpCommand, captureMcpName, captureMcpTransport, captureMcpUrl, captureProviderName, captureProviderUrl, commaList, isYesConfirmation } from '../commands/wizardFlow.js';
|
|
15
|
+
import { finishLspCustomResult, selectLspActionResult, selectLspPresetResult, selectLspServerResult, finishMcpCustomResult, selectMcpActionResult, selectMcpPresetResult, selectMcpServerResult, setMcpServerKeyResult } from '../commands/serverWizard.js';
|
|
18
16
|
import { chatgptCodexUrlWarning, providerActionResult, providerAppendModels, providerFinishAdd, providerRemove, providerRemoveModels, providerSetImageCapable, providerSetKey } from '../commands/providerWizard.js';
|
|
19
|
-
import { selectSkillActionResult, selectSkillResult } from '../commands/
|
|
20
|
-
import {
|
|
21
|
-
import { skillConfirmRemoveResult as skillConfirmRemove } from '../commands/skillConfirmRemove.js';
|
|
22
|
-
import { commaList, isYesConfirmation } from '../commands/wizardInput.js';
|
|
17
|
+
import { selectSkillActionResult, selectSkillResult, captureSkillDescription as captureSkillDescriptionResult, skillCreationFailure, skillCreationMessage, skillConfirmRemoveResult as skillConfirmRemove } from '../commands/skillsWizard.js';
|
|
18
|
+
import { selectThemeResult } from '../commands/themesCommand.js';
|
|
23
19
|
import { startupProviderInfo } from './startupInfo.js';
|
|
24
20
|
import { SESSION_ACTIONS } from '../commands/sessionPicker.js';
|
|
25
21
|
import { openBrowser, startChatGptBrowserLogin } from '../../llm/openaiCodexOAuth.js';
|
|
22
|
+
export function transitionProviderField(input) {
|
|
23
|
+
if (input.mode === 'providerAddKey') {
|
|
24
|
+
const key = input.value.trim();
|
|
25
|
+
return [
|
|
26
|
+
{ type: 'provider-draft', patch: key ? { key } : {} },
|
|
27
|
+
{ type: 'discover-provider-models', draft: { ...input.draft, ...(key ? { key } : {}) } },
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
const result = input.mode === 'providerAddName' ? captureProviderName(input.settings, input.value)
|
|
31
|
+
: input.mode === 'providerAddUrl' ? captureProviderUrl(input.value)
|
|
32
|
+
: undefined;
|
|
33
|
+
if (!result)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (result.message)
|
|
36
|
+
return [{ type: 'message', text: result.message }];
|
|
37
|
+
const patch = result.draft ?? {};
|
|
38
|
+
return [
|
|
39
|
+
...(Object.keys(patch).length ? [{ type: 'provider-draft', patch, replace: input.mode === 'providerAddName' }] : []),
|
|
40
|
+
...(result.nextMode ? [{ type: 'mode', mode: result.nextMode }] : []),
|
|
41
|
+
{ type: 'message', text: result.systemMessage },
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
export function transitionMcpField(input) {
|
|
45
|
+
const result = input.mode === 'mcpAddName' ? captureMcpName(input.settings, input.value)
|
|
46
|
+
: input.mode === 'mcpAddTransport' ? captureMcpTransport(input.value)
|
|
47
|
+
: input.mode === 'mcpAddUrl' ? captureMcpUrl(input.value)
|
|
48
|
+
: input.mode === 'mcpAddCommand' ? captureMcpCommand(input.value)
|
|
49
|
+
: undefined;
|
|
50
|
+
if (!result)
|
|
51
|
+
return undefined;
|
|
52
|
+
if (result.message)
|
|
53
|
+
return [{ type: 'message', text: result.message }];
|
|
54
|
+
const patch = result.draft ?? {};
|
|
55
|
+
const nextDraft = { ...input.draft, ...patch };
|
|
56
|
+
if (result.nextMode === 'chat' && input.mode === 'mcpAddCommand')
|
|
57
|
+
return [{ type: 'finish-mcp-stdio', draft: nextDraft }];
|
|
58
|
+
return [
|
|
59
|
+
...(Object.keys(patch).length ? [{ type: 'mcp-draft', patch }] : []),
|
|
60
|
+
...(result.nextMode ? [{ type: 'mode', mode: result.nextMode }] : []),
|
|
61
|
+
{ type: 'message', text: result.systemMessage },
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
export function initialWizardUiState() {
|
|
65
|
+
return { discoveredModels: [], suggestedModels: [], providerDraft: {}, skillDraft: {}, lspDraft: {}, mcpDraft: {} };
|
|
66
|
+
}
|
|
67
|
+
export function wizardUiReducer(state, action) {
|
|
68
|
+
switch (action.type) {
|
|
69
|
+
case 'set': return { ...state, [action.key]: action.value };
|
|
70
|
+
case 'providerDraft': return { ...state, providerDraft: action.value };
|
|
71
|
+
case 'skillDraft': return { ...state, skillDraft: action.value };
|
|
72
|
+
case 'lspDraft': return { ...state, lspDraft: action.value };
|
|
73
|
+
case 'mcpDraft': return { ...state, mcpDraft: action.value };
|
|
74
|
+
case 'discoveredModels': return { ...state, discoveredModels: action.value };
|
|
75
|
+
case 'suggestedModels': return { ...state, suggestedModels: action.value };
|
|
76
|
+
case 'reset': return initialWizardUiState();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
26
79
|
export function createWizardDispatch(deps) {
|
|
27
80
|
const { setMode, setSettings, showMessage } = deps;
|
|
81
|
+
// Setter shims over the single wizard-state reducer, so the handler bodies
|
|
82
|
+
// keep the historical per-field setter vocabulary (minimal diff; the
|
|
83
|
+
// dispatch tests mirror React state through updateWizard).
|
|
84
|
+
const setSelectedProviderName = (value) => deps.updateWizard({ type: 'set', key: 'selectedProviderName', value });
|
|
85
|
+
const setSelectedSkillName = (value) => deps.updateWizard({ type: 'set', key: 'selectedSkillName', value });
|
|
86
|
+
const setSelectedLspName = (value) => deps.updateWizard({ type: 'set', key: 'selectedLspName', value });
|
|
87
|
+
const setSelectedMcpName = (value) => deps.updateWizard({ type: 'set', key: 'selectedMcpName', value });
|
|
88
|
+
const setSelectedSessionId = (id) => deps.updateWizard({ type: 'set', key: 'selectedSessionId', value: id });
|
|
89
|
+
const setModelProviderFilter = (value) => deps.updateWizard({ type: 'set', key: 'modelProviderFilter', value });
|
|
90
|
+
const setProviderDraft = (value) => deps.updateWizard({ type: 'providerDraft', value });
|
|
91
|
+
const setSkillDraft = (value) => deps.updateWizard({ type: 'skillDraft', value });
|
|
92
|
+
const setLspDraft = (value) => deps.updateWizard({ type: 'lspDraft', value });
|
|
93
|
+
const setMcpDraft = (value) => deps.updateWizard({ type: 'mcpDraft', value });
|
|
94
|
+
const setDiscoveredModels = (value) => deps.updateWizard({ type: 'discoveredModels', value });
|
|
95
|
+
const setSuggestedModels = (value) => deps.updateWizard({ type: 'suggestedModels', value });
|
|
28
96
|
// Limits harvested from the provider's own /models listing during the most
|
|
29
97
|
// recent discovery. Written through with the models being added (provider-
|
|
30
98
|
// specific and fresher than the static preset catalog) and cleared when a
|
|
@@ -44,12 +112,12 @@ export function createWizardDispatch(deps) {
|
|
|
44
112
|
setMode('chat');
|
|
45
113
|
return;
|
|
46
114
|
}
|
|
47
|
-
|
|
115
|
+
setSelectedSessionId(id);
|
|
48
116
|
setMode('sessionAction');
|
|
49
117
|
showMessage(`Session ${id}: press Enter to resume, or choose fork.`);
|
|
50
118
|
}
|
|
51
119
|
async function selectSessionAction(action) {
|
|
52
|
-
const id = deps.selectedSessionId;
|
|
120
|
+
const id = deps.wizard.selectedSessionId;
|
|
53
121
|
if (!id) {
|
|
54
122
|
showMessage('No session selected. Start over with /resume.');
|
|
55
123
|
setMode('chat');
|
|
@@ -63,12 +131,12 @@ export function createWizardDispatch(deps) {
|
|
|
63
131
|
showMessage(`Unknown session action: ${action}.`);
|
|
64
132
|
return;
|
|
65
133
|
}
|
|
66
|
-
|
|
134
|
+
setSelectedSessionId(undefined);
|
|
67
135
|
setMode('chat');
|
|
68
136
|
}
|
|
69
137
|
async function selectProvider(providerName) {
|
|
70
138
|
if (providerName === PROVIDER_CHOICES.addProvider) {
|
|
71
|
-
|
|
139
|
+
setProviderDraft({});
|
|
72
140
|
setMode('providerAddPreset');
|
|
73
141
|
showMessage('Choose a provider preset, or select "custom" to enter details manually.');
|
|
74
142
|
return;
|
|
@@ -79,7 +147,7 @@ export function createWizardDispatch(deps) {
|
|
|
79
147
|
setMode('chat');
|
|
80
148
|
return;
|
|
81
149
|
}
|
|
82
|
-
|
|
150
|
+
setSelectedProviderName(provider.name);
|
|
83
151
|
setMode('providerAction');
|
|
84
152
|
// Surface canonical-endpoint divergence for ChatGPT sign-in providers up
|
|
85
153
|
// front: a hand-edited URL is silently ignored by the Codex fetch (F-14).
|
|
@@ -98,23 +166,23 @@ export function createWizardDispatch(deps) {
|
|
|
98
166
|
await setProviderAuth(input.name, auth);
|
|
99
167
|
if (input.existing) {
|
|
100
168
|
showMessage(`ChatGPT sign-in updated for ${input.name}.`);
|
|
101
|
-
|
|
169
|
+
setSelectedProviderName(undefined);
|
|
102
170
|
setMode('chat');
|
|
103
171
|
return;
|
|
104
172
|
}
|
|
105
173
|
const provider = { name: input.name, url: input.url, kind: 'chatgpt-codex', models: input.models, ...presetModelLimitsForModels({ name: input.name, url: input.url }, input.models) };
|
|
106
174
|
const next = await updateSettings({ providers: upsertProvider(deps.settings, provider), provider: provider.name, model: undefined });
|
|
107
175
|
setSettings(next);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
176
|
+
setProviderDraft({});
|
|
177
|
+
setSuggestedModels([]);
|
|
178
|
+
setModelProviderFilter(provider.name);
|
|
111
179
|
setMode('model');
|
|
112
180
|
showMessage(`ChatGPT connected as ${provider.name}. Choose a model explicitly.`);
|
|
113
181
|
}
|
|
114
182
|
catch (error) {
|
|
115
183
|
await login?.close().catch(() => undefined);
|
|
116
184
|
showMessage(`ChatGPT sign-in failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
|
-
|
|
185
|
+
setProviderDraft({});
|
|
118
186
|
setMode('chat');
|
|
119
187
|
}
|
|
120
188
|
finally {
|
|
@@ -124,7 +192,7 @@ export function createWizardDispatch(deps) {
|
|
|
124
192
|
}
|
|
125
193
|
async function selectPreset(presetId) {
|
|
126
194
|
if (presetId === PROVIDER_CHOICES.custom) {
|
|
127
|
-
|
|
195
|
+
setProviderDraft({});
|
|
128
196
|
setMode('providerAddName');
|
|
129
197
|
showMessage('Provider name? Example: openrouter, local, lmstudio.');
|
|
130
198
|
return;
|
|
@@ -140,11 +208,11 @@ export function createWizardDispatch(deps) {
|
|
|
140
208
|
if (nameConflict) {
|
|
141
209
|
showMessage(`Provider ${existingName} already exists. Use /provider to manage existing providers.`);
|
|
142
210
|
setMode('chat');
|
|
143
|
-
|
|
211
|
+
setProviderDraft({});
|
|
144
212
|
return;
|
|
145
213
|
}
|
|
146
|
-
|
|
147
|
-
|
|
214
|
+
setProviderDraft({ name: existingName, url: preset.baseUrl, ...(preset.auth === 'chatgpt-oauth' ? { kind: 'chatgpt-codex' } : {}) });
|
|
215
|
+
setSuggestedModels(preset.suggestedModels ?? []);
|
|
148
216
|
if (preset.auth === 'chatgpt-oauth') {
|
|
149
217
|
await loginWithChatGpt({ name: existingName, url: preset.baseUrl, models: preset.suggestedModels ?? [] });
|
|
150
218
|
}
|
|
@@ -164,43 +232,43 @@ export function createWizardDispatch(deps) {
|
|
|
164
232
|
if (!provider) {
|
|
165
233
|
showMessage(`No provider named ${providerName}.`);
|
|
166
234
|
setMode('chat');
|
|
167
|
-
|
|
235
|
+
setSelectedProviderName(undefined);
|
|
168
236
|
return;
|
|
169
237
|
}
|
|
170
238
|
const next = await updateSettings({ provider: provider.name });
|
|
171
239
|
setSettings(next);
|
|
172
|
-
|
|
173
|
-
|
|
240
|
+
setSelectedProviderName(undefined);
|
|
241
|
+
setModelProviderFilter(provider.name);
|
|
174
242
|
setMode('model');
|
|
175
243
|
showMessage(`Provider set to ${provider.name}. Choose a model.`);
|
|
176
244
|
}
|
|
177
245
|
async function selectProviderAction(action) {
|
|
178
|
-
if (!deps.selectedProviderName) {
|
|
246
|
+
if (!deps.wizard.selectedProviderName) {
|
|
179
247
|
setMode('provider');
|
|
180
248
|
return;
|
|
181
249
|
}
|
|
182
|
-
const provider = findProvider(deps.settings, deps.selectedProviderName);
|
|
250
|
+
const provider = findProvider(deps.settings, deps.wizard.selectedProviderName);
|
|
183
251
|
if (!provider) {
|
|
184
|
-
showMessage(`Provider ${deps.selectedProviderName} not found.`);
|
|
252
|
+
showMessage(`Provider ${deps.wizard.selectedProviderName} not found.`);
|
|
185
253
|
setMode('chat');
|
|
186
|
-
|
|
254
|
+
setSelectedProviderName(undefined);
|
|
187
255
|
return;
|
|
188
256
|
}
|
|
189
257
|
if (action === PROVIDER_ACTIONS.useProvider) {
|
|
190
|
-
await useProvider(deps.selectedProviderName);
|
|
258
|
+
await useProvider(deps.wizard.selectedProviderName);
|
|
191
259
|
return;
|
|
192
260
|
}
|
|
193
261
|
if (action === PROVIDER_ACTIONS.markImageCapable || action === PROVIDER_ACTIONS.clearImageCapable) {
|
|
194
|
-
const result = providerSetImageCapable(deps.settings, deps.selectedProviderName, action === PROVIDER_ACTIONS.markImageCapable);
|
|
262
|
+
const result = providerSetImageCapable(deps.settings, deps.wizard.selectedProviderName, action === PROVIDER_ACTIONS.markImageCapable);
|
|
195
263
|
if (result.settingsPatch)
|
|
196
264
|
setSettings(await updateSettings(result.settingsPatch));
|
|
197
|
-
|
|
265
|
+
setSelectedProviderName(undefined);
|
|
198
266
|
setMode('chat');
|
|
199
267
|
showMessage(result.message);
|
|
200
268
|
return;
|
|
201
269
|
}
|
|
202
270
|
if (action === PROVIDER_ACTIONS.addModels) {
|
|
203
|
-
|
|
271
|
+
setSelectedProviderName(provider.name);
|
|
204
272
|
if (provider.kind === 'chatgpt-codex') {
|
|
205
273
|
setMode('providerAppendModels');
|
|
206
274
|
showMessage(`Comma-separated supported Codex model names to add to ${provider.name}?`);
|
|
@@ -215,7 +283,7 @@ export function createWizardDispatch(deps) {
|
|
|
215
283
|
}
|
|
216
284
|
const actionResult = providerActionResult(action, provider);
|
|
217
285
|
if ('selectedName' in actionResult)
|
|
218
|
-
|
|
286
|
+
setSelectedProviderName(actionResult.selectedName);
|
|
219
287
|
if (actionResult.mode)
|
|
220
288
|
setMode(actionResult.mode);
|
|
221
289
|
showMessage(actionResult.message);
|
|
@@ -233,7 +301,7 @@ export function createWizardDispatch(deps) {
|
|
|
233
301
|
}
|
|
234
302
|
const existing = findProvider(deps.settings, target.name);
|
|
235
303
|
if (target.kind === 'chatgpt-codex' || existing?.kind === 'chatgpt-codex') {
|
|
236
|
-
|
|
304
|
+
setSelectedProviderName(target.name);
|
|
237
305
|
setMode(existing ? 'providerAppendModels' : 'providerAddModels');
|
|
238
306
|
showMessage(fallbackPrompt);
|
|
239
307
|
return;
|
|
@@ -249,7 +317,7 @@ export function createWizardDispatch(deps) {
|
|
|
249
317
|
deps.setBusyLabel(deps.idleBusyLabel);
|
|
250
318
|
}
|
|
251
319
|
if (result.status === 'ok') {
|
|
252
|
-
|
|
320
|
+
setDiscoveredModels(result.models);
|
|
253
321
|
lastDiscoveredLimits = result.modelLimits ?? {};
|
|
254
322
|
setMode('modelPick');
|
|
255
323
|
showMessage(`Found ${result.models.length} model${result.models.length === 1 ? '' : 's'} on ${target.name}. Choose one to add, or select "${MODEL_CHOICES.enterModelNames}".`);
|
|
@@ -261,9 +329,9 @@ export function createWizardDispatch(deps) {
|
|
|
261
329
|
}
|
|
262
330
|
async function selectModel(selector) {
|
|
263
331
|
if (selector === MODEL_CHOICES.addModels) {
|
|
264
|
-
const filteredProvider = deps.modelProviderFilter ? findProvider(deps.settings, deps.modelProviderFilter) : undefined;
|
|
332
|
+
const filteredProvider = deps.wizard.modelProviderFilter ? findProvider(deps.settings, deps.wizard.modelProviderFilter) : undefined;
|
|
265
333
|
if (filteredProvider) {
|
|
266
|
-
|
|
334
|
+
setSelectedProviderName(filteredProvider.name);
|
|
267
335
|
await discoverModelsFor(filteredProvider, `Comma-separated model names to add to ${filteredProvider.name}?`);
|
|
268
336
|
return;
|
|
269
337
|
}
|
|
@@ -271,7 +339,7 @@ export function createWizardDispatch(deps) {
|
|
|
271
339
|
showMessage('Choose a provider to add models to.');
|
|
272
340
|
return;
|
|
273
341
|
}
|
|
274
|
-
const scopedSelector = deps.modelProviderFilter ? `${deps.modelProviderFilter}:${selector}` : selector;
|
|
342
|
+
const scopedSelector = deps.wizard.modelProviderFilter ? `${deps.wizard.modelProviderFilter}:${selector}` : selector;
|
|
275
343
|
const resolved = resolveModelSelector(deps.settings, scopedSelector);
|
|
276
344
|
if (resolved.status === 'ambiguous') {
|
|
277
345
|
showMessage(`Model ${resolved.model} exists on multiple providers: ${resolved.providers.map(provider => modelSelector(provider, resolved.model)).join(', ')}`);
|
|
@@ -283,7 +351,7 @@ export function createWizardDispatch(deps) {
|
|
|
283
351
|
}
|
|
284
352
|
const next = await updateSettings({ provider: resolved.provider.name, model: resolved.model });
|
|
285
353
|
setSettings(next);
|
|
286
|
-
|
|
354
|
+
setModelProviderFilter(undefined);
|
|
287
355
|
setMode('chat');
|
|
288
356
|
showMessage(`Model set to ${resolved.model} on ${resolved.provider.name}.\n\n${startupProviderInfo(next)}`);
|
|
289
357
|
}
|
|
@@ -294,14 +362,14 @@ export function createWizardDispatch(deps) {
|
|
|
294
362
|
setMode('chat');
|
|
295
363
|
return;
|
|
296
364
|
}
|
|
297
|
-
|
|
365
|
+
setSelectedProviderName(provider.name);
|
|
298
366
|
await discoverModelsFor(provider, `Comma-separated model names to add to ${provider.name}?`);
|
|
299
367
|
}
|
|
300
368
|
async function pickModelToAdd(value) {
|
|
301
|
-
const provider = deps.selectedProviderName ? findProvider(deps.settings, deps.selectedProviderName) : undefined;
|
|
369
|
+
const provider = deps.wizard.selectedProviderName ? findProvider(deps.settings, deps.wizard.selectedProviderName) : undefined;
|
|
302
370
|
if (value === MODEL_CHOICES.enterModelNames) {
|
|
303
|
-
|
|
304
|
-
|
|
371
|
+
setDiscoveredModels([]);
|
|
372
|
+
setSuggestedModels([]);
|
|
305
373
|
lastDiscoveredLimits = {};
|
|
306
374
|
if (provider) {
|
|
307
375
|
setMode('providerAppendModels');
|
|
@@ -347,16 +415,16 @@ export function createWizardDispatch(deps) {
|
|
|
347
415
|
return await ollamaModelLimits({ baseUrl: url, models, conservativeCap }).catch(() => ({}));
|
|
348
416
|
}
|
|
349
417
|
async function appendModelsToProvider(modelsValue) {
|
|
350
|
-
const provider = deps.selectedProviderName ? findProvider(deps.settings, deps.selectedProviderName) : undefined;
|
|
418
|
+
const provider = deps.wizard.selectedProviderName ? findProvider(deps.settings, deps.wizard.selectedProviderName) : undefined;
|
|
351
419
|
if (provider) {
|
|
352
420
|
const native = await localNativeLimits(provider.url, commaList(modelsValue));
|
|
353
421
|
if (Object.keys(native).length > 0)
|
|
354
422
|
lastDiscoveredLimits = { ...lastDiscoveredLimits, ...native };
|
|
355
423
|
}
|
|
356
|
-
const result = providerAppendModels(deps.settings, deps.selectedProviderName, modelsValue, lastDiscoveredLimits);
|
|
424
|
+
const result = providerAppendModels(deps.settings, deps.wizard.selectedProviderName, modelsValue, lastDiscoveredLimits);
|
|
357
425
|
if (!result.provider) {
|
|
358
|
-
|
|
359
|
-
|
|
426
|
+
setDiscoveredModels([]);
|
|
427
|
+
setSuggestedModels([]);
|
|
360
428
|
lastDiscoveredLimits = {};
|
|
361
429
|
showMessage(result.message);
|
|
362
430
|
setMode('chat');
|
|
@@ -368,40 +436,40 @@ export function createWizardDispatch(deps) {
|
|
|
368
436
|
}
|
|
369
437
|
const next = await updateSettings(result.settingsPatch);
|
|
370
438
|
setSettings(next);
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
439
|
+
setSelectedProviderName(undefined);
|
|
440
|
+
setDiscoveredModels([]);
|
|
441
|
+
setSuggestedModels([]);
|
|
374
442
|
lastDiscoveredLimits = {};
|
|
375
|
-
|
|
443
|
+
setModelProviderFilter(result.provider.name);
|
|
376
444
|
setMode('model');
|
|
377
445
|
showMessage(result.message);
|
|
378
446
|
}
|
|
379
447
|
async function finishProviderAdd(modelsValue) {
|
|
380
|
-
const native = await localNativeLimits(deps.providerDraft.url, commaList(modelsValue));
|
|
448
|
+
const native = await localNativeLimits(deps.wizard.providerDraft.url, commaList(modelsValue));
|
|
381
449
|
if (Object.keys(native).length > 0)
|
|
382
450
|
lastDiscoveredLimits = { ...lastDiscoveredLimits, ...native };
|
|
383
|
-
const result = providerFinishAdd(deps.settings, deps.providerDraft, modelsValue, lastDiscoveredLimits);
|
|
451
|
+
const result = providerFinishAdd(deps.settings, deps.wizard.providerDraft, modelsValue, lastDiscoveredLimits);
|
|
384
452
|
if (!result.provider || !result.settingsPatch) {
|
|
385
453
|
showMessage(result.message);
|
|
386
454
|
setMode('chat');
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
455
|
+
setProviderDraft({});
|
|
456
|
+
setDiscoveredModels([]);
|
|
457
|
+
setSuggestedModels([]);
|
|
390
458
|
lastDiscoveredLimits = {};
|
|
391
459
|
return;
|
|
392
460
|
}
|
|
393
461
|
const next = await updateSettings(result.settingsPatch);
|
|
394
462
|
setSettings(next);
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
463
|
+
setProviderDraft({});
|
|
464
|
+
setDiscoveredModels([]);
|
|
465
|
+
setSuggestedModels([]);
|
|
398
466
|
lastDiscoveredLimits = {};
|
|
399
|
-
|
|
467
|
+
setModelProviderFilter(result.provider.name);
|
|
400
468
|
setMode('model');
|
|
401
469
|
showMessage(result.message);
|
|
402
470
|
}
|
|
403
471
|
async function providerSetKeyMode(value) {
|
|
404
|
-
const result = providerSetKey(deps.settings, deps.selectedProviderName, value);
|
|
472
|
+
const result = providerSetKey(deps.settings, deps.wizard.selectedProviderName, value);
|
|
405
473
|
if (!result.provider) {
|
|
406
474
|
showMessage(result.message);
|
|
407
475
|
setMode('chat');
|
|
@@ -412,12 +480,12 @@ export function createWizardDispatch(deps) {
|
|
|
412
480
|
return;
|
|
413
481
|
}
|
|
414
482
|
setSettings(await updateSettings(result.settingsPatch));
|
|
415
|
-
|
|
483
|
+
setSelectedProviderName(undefined);
|
|
416
484
|
setMode('chat');
|
|
417
485
|
showMessage(result.message);
|
|
418
486
|
}
|
|
419
487
|
async function providerRemoveModelsMode(value) {
|
|
420
|
-
const result = providerRemoveModels(deps.settings, deps.selectedProviderName, value);
|
|
488
|
+
const result = providerRemoveModels(deps.settings, deps.wizard.selectedProviderName, value);
|
|
421
489
|
if (!result.provider) {
|
|
422
490
|
showMessage(result.message);
|
|
423
491
|
setMode('chat');
|
|
@@ -429,12 +497,12 @@ export function createWizardDispatch(deps) {
|
|
|
429
497
|
}
|
|
430
498
|
const next = await updateSettings(result.settingsPatch);
|
|
431
499
|
setSettings(next);
|
|
432
|
-
|
|
500
|
+
setSelectedProviderName(undefined);
|
|
433
501
|
setMode('chat');
|
|
434
502
|
showMessage(result.message);
|
|
435
503
|
}
|
|
436
504
|
async function providerConfirmRemoveMode(value) {
|
|
437
|
-
const provider = deps.selectedProviderName ? findProvider(deps.settings, deps.selectedProviderName) : undefined;
|
|
505
|
+
const provider = deps.wizard.selectedProviderName ? findProvider(deps.settings, deps.wizard.selectedProviderName) : undefined;
|
|
438
506
|
if (!provider) {
|
|
439
507
|
showMessage('No provider selected.');
|
|
440
508
|
setMode('chat');
|
|
@@ -442,34 +510,34 @@ export function createWizardDispatch(deps) {
|
|
|
442
510
|
}
|
|
443
511
|
if (!isYesConfirmation(value)) {
|
|
444
512
|
showMessage('Cancelled. Provider not removed.');
|
|
445
|
-
|
|
513
|
+
setSelectedProviderName(undefined);
|
|
446
514
|
setMode('chat');
|
|
447
515
|
return;
|
|
448
516
|
}
|
|
449
|
-
const result = providerRemove(deps.settings, deps.selectedProviderName);
|
|
517
|
+
const result = providerRemove(deps.settings, deps.wizard.selectedProviderName);
|
|
450
518
|
const next = await updateSettings(result.settingsPatch ?? {});
|
|
451
519
|
await removeProviderAuth(provider.name);
|
|
452
520
|
setSettings(next);
|
|
453
|
-
|
|
521
|
+
setSelectedProviderName(undefined);
|
|
454
522
|
setMode('chat');
|
|
455
523
|
showMessage(result.message);
|
|
456
524
|
}
|
|
457
525
|
async function selectSkill(name) {
|
|
458
526
|
const result = selectSkillResult(deps.skills, name);
|
|
459
527
|
if (result.clearDraft)
|
|
460
|
-
|
|
528
|
+
setSkillDraft({});
|
|
461
529
|
if ('selectedName' in result)
|
|
462
|
-
|
|
530
|
+
setSelectedSkillName(result.selectedName);
|
|
463
531
|
if (result.mode)
|
|
464
532
|
setMode(result.mode);
|
|
465
533
|
showMessage(result.message);
|
|
466
534
|
}
|
|
467
535
|
async function selectSkillAction(action) {
|
|
468
|
-
const result = selectSkillActionResult(deps.settings, deps.skills, deps.selectedSkillName, action);
|
|
536
|
+
const result = selectSkillActionResult(deps.settings, deps.skills, deps.wizard.selectedSkillName, action);
|
|
469
537
|
if (result.settingsPatch)
|
|
470
538
|
setSettings(await updateSettings(result.settingsPatch));
|
|
471
539
|
if ('selectedName' in result)
|
|
472
|
-
|
|
540
|
+
setSelectedSkillName(result.selectedName);
|
|
473
541
|
if (result.mode)
|
|
474
542
|
setMode(result.mode);
|
|
475
543
|
if (result.validate && result.skill) {
|
|
@@ -492,7 +560,7 @@ export function createWizardDispatch(deps) {
|
|
|
492
560
|
showMessage('Skill name must contain at least one letter or number. Try again, or press ESC to cancel.');
|
|
493
561
|
return;
|
|
494
562
|
}
|
|
495
|
-
|
|
563
|
+
setSkillDraft({ ...deps.wizard.skillDraft, name: dirName });
|
|
496
564
|
setMode('skillsAddScope');
|
|
497
565
|
showMessage(`Where should "${dirName}" be created? Choose this project or global explicitly.`);
|
|
498
566
|
}
|
|
@@ -503,9 +571,9 @@ export function createWizardDispatch(deps) {
|
|
|
503
571
|
showMessage('Choose "this project" or "global".');
|
|
504
572
|
return;
|
|
505
573
|
}
|
|
506
|
-
const name = deps.skillDraft.name;
|
|
574
|
+
const name = deps.wizard.skillDraft.name;
|
|
507
575
|
if (!name) {
|
|
508
|
-
|
|
576
|
+
setSkillDraft({});
|
|
509
577
|
setMode('chat');
|
|
510
578
|
showMessage('Skill wizard lost the name. Start over with /skills.');
|
|
511
579
|
return;
|
|
@@ -515,25 +583,25 @@ export function createWizardDispatch(deps) {
|
|
|
515
583
|
showMessage(`A ${scope} skill named "${name}" already exists. Choose another scope or press ESC to cancel.`);
|
|
516
584
|
return;
|
|
517
585
|
}
|
|
518
|
-
|
|
586
|
+
setSkillDraft({ ...deps.wizard.skillDraft, scope });
|
|
519
587
|
setMode('skillsAddDescription');
|
|
520
588
|
showMessage(`Describe what "${name}" should do. This is the work the LLM will expand into the skill body.`);
|
|
521
589
|
}
|
|
522
590
|
async function captureSkillDescription(value) {
|
|
523
|
-
const result = captureSkillDescriptionResult(value, deps.skillDraft.name);
|
|
591
|
+
const result = captureSkillDescriptionResult(value, deps.wizard.skillDraft.name);
|
|
524
592
|
if (result.message)
|
|
525
593
|
showMessage(result.message);
|
|
526
594
|
if (result.mode === 'chat')
|
|
527
595
|
setMode('chat');
|
|
528
596
|
if (result.clearDraft)
|
|
529
|
-
|
|
597
|
+
setSkillDraft({});
|
|
530
598
|
if (result.description && result.draftName) {
|
|
531
599
|
const name = result.draftName;
|
|
532
600
|
const description = result.description;
|
|
533
601
|
deps.setBusyLabel(result.busyLabel ?? 'Creating skill');
|
|
534
602
|
deps.setBusy(true);
|
|
535
603
|
try {
|
|
536
|
-
const created = await createSkill({ name, description, scope: deps.skillDraft.scope ?? 'global' });
|
|
604
|
+
const created = await createSkill({ name, description, scope: deps.wizard.skillDraft.scope ?? 'global' });
|
|
537
605
|
showMessage(skillCreationMessage(created.name, created.file));
|
|
538
606
|
await deps.refreshSkills();
|
|
539
607
|
}
|
|
@@ -547,11 +615,11 @@ export function createWizardDispatch(deps) {
|
|
|
547
615
|
}
|
|
548
616
|
}
|
|
549
617
|
async function skillsConfirmRemoveMode(value) {
|
|
550
|
-
const result = skillConfirmRemove(deps.settings, deps.skills, deps.selectedSkillName, value);
|
|
618
|
+
const result = skillConfirmRemove(deps.settings, deps.skills, deps.wizard.selectedSkillName, value);
|
|
551
619
|
if (result.message)
|
|
552
620
|
showMessage(result.message);
|
|
553
621
|
if (result.selectedName === undefined)
|
|
554
|
-
|
|
622
|
+
setSelectedSkillName(undefined);
|
|
555
623
|
if (result.mode === 'chat')
|
|
556
624
|
setMode('chat');
|
|
557
625
|
if (result.removedDir)
|
|
@@ -564,37 +632,37 @@ export function createWizardDispatch(deps) {
|
|
|
564
632
|
async function selectLspServer(serverName) {
|
|
565
633
|
const result = selectLspServerResult(deps.settings, serverName);
|
|
566
634
|
if (result.clearDraft)
|
|
567
|
-
|
|
635
|
+
setLspDraft({});
|
|
568
636
|
if (serverName === SERVER_CHOICES.addServer)
|
|
569
637
|
setMode('lspAddPreset');
|
|
570
638
|
else if (result.mode)
|
|
571
639
|
setMode(result.mode);
|
|
572
640
|
if (result.selectedName !== undefined)
|
|
573
|
-
|
|
641
|
+
setSelectedLspName(result.selectedName);
|
|
574
642
|
showMessage(result.message);
|
|
575
643
|
}
|
|
576
644
|
async function selectLspPreset(presetId) {
|
|
577
645
|
const result = selectLspPresetResult(deps.settings, presetId);
|
|
578
646
|
if (result.clearDraft)
|
|
579
|
-
|
|
647
|
+
setLspDraft({});
|
|
580
648
|
await applyResult(result);
|
|
581
649
|
}
|
|
582
650
|
async function selectLspAction(action) {
|
|
583
|
-
const result = selectLspActionResult(deps.settings, deps.selectedLspName, action);
|
|
651
|
+
const result = selectLspActionResult(deps.settings, deps.wizard.selectedLspName, action);
|
|
584
652
|
if (result.settingsPatch)
|
|
585
653
|
setSettings(await updateSettings(result.settingsPatch));
|
|
586
654
|
if ('selectedName' in result)
|
|
587
|
-
|
|
655
|
+
setSelectedLspName(result.selectedName);
|
|
588
656
|
if (result.mode)
|
|
589
657
|
setMode(result.mode);
|
|
590
658
|
showMessage(result.message);
|
|
591
659
|
}
|
|
592
660
|
async function finishLspCustom(commandLine) {
|
|
593
|
-
const result = finishLspCustomResult(deps.settings, deps.lspDraft.name, commandLine);
|
|
661
|
+
const result = finishLspCustomResult(deps.settings, deps.wizard.lspDraft.name, commandLine);
|
|
594
662
|
if (result.settingsPatch)
|
|
595
663
|
setSettings(await updateSettings(result.settingsPatch));
|
|
596
664
|
if (result.clearDraft)
|
|
597
|
-
|
|
665
|
+
setLspDraft({});
|
|
598
666
|
if (result.mode)
|
|
599
667
|
setMode(result.mode);
|
|
600
668
|
showMessage(result.message);
|
|
@@ -606,96 +674,113 @@ export function createWizardDispatch(deps) {
|
|
|
606
674
|
return;
|
|
607
675
|
}
|
|
608
676
|
if (result.draft)
|
|
609
|
-
|
|
677
|
+
setLspDraft({ name: result.draft.name });
|
|
610
678
|
if (result.nextMode)
|
|
611
679
|
setMode(result.nextMode);
|
|
612
680
|
showMessage(result.systemMessage);
|
|
613
681
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
682
|
+
/**
|
|
683
|
+
* Generic typed-"yes" confirm-remove step shared by the LSP and MCP flows.
|
|
684
|
+
* Cancel and no-selection paths are identical; `remove` applies the domain
|
|
685
|
+
* settings mutation and returns the success message.
|
|
686
|
+
*/
|
|
687
|
+
function confirmRemoveStep(input) {
|
|
688
|
+
return async (value) => {
|
|
689
|
+
const name = input.selectedName();
|
|
690
|
+
if (!name) {
|
|
691
|
+
setMode('chat');
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
if (!isYesConfirmation(value)) {
|
|
695
|
+
showMessage(input.cancelMessage);
|
|
696
|
+
input.clearSelection();
|
|
697
|
+
setMode('chat');
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
showMessage(await input.remove(name));
|
|
701
|
+
input.clearSelection();
|
|
622
702
|
setMode('chat');
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
const lspConfirmRemoveMode = confirmRemoveStep({
|
|
706
|
+
selectedName: () => deps.wizard.selectedLspName,
|
|
707
|
+
cancelMessage: 'Cancelled. LSP server not removed.',
|
|
708
|
+
clearSelection: () => setSelectedLspName(undefined),
|
|
709
|
+
remove: async (name) => {
|
|
710
|
+
const next = await updateSettings({ lspServers: removeLspServer(deps.settings, name) });
|
|
711
|
+
setSettings(next);
|
|
712
|
+
return `Removed LSP server ${name}.`;
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
const mcpConfirmRemoveMode = confirmRemoveStep({
|
|
716
|
+
selectedName: () => deps.wizard.selectedMcpName,
|
|
717
|
+
cancelMessage: 'Cancelled. MCP server not removed.',
|
|
718
|
+
clearSelection: () => setSelectedMcpName(undefined),
|
|
719
|
+
remove: async (name) => {
|
|
720
|
+
const next = await updateSettings({ mcpServers: removeMcpServer(deps.settings, name) });
|
|
721
|
+
setSettings(next);
|
|
722
|
+
return `Removed MCP server ${name}.`;
|
|
723
|
+
},
|
|
724
|
+
});
|
|
631
725
|
async function selectMcpServer(serverName) {
|
|
632
726
|
const result = selectMcpServerResult(deps.settings, serverName);
|
|
633
727
|
if (result.clearDraft)
|
|
634
|
-
|
|
728
|
+
setMcpDraft({});
|
|
635
729
|
if (serverName === SERVER_CHOICES.addServer)
|
|
636
730
|
setMode('mcpAddPreset');
|
|
637
731
|
else if (result.mode)
|
|
638
732
|
setMode(result.mode);
|
|
639
733
|
if (result.selectedName !== undefined)
|
|
640
|
-
|
|
734
|
+
setSelectedMcpName(result.selectedName);
|
|
641
735
|
showMessage(result.message);
|
|
642
736
|
}
|
|
643
737
|
async function selectMcpPreset(presetId) {
|
|
644
738
|
const result = selectMcpPresetResult(deps.settings, presetId);
|
|
645
739
|
if (result.clearDraft)
|
|
646
|
-
|
|
740
|
+
setMcpDraft({});
|
|
647
741
|
if (result.draft)
|
|
648
|
-
|
|
742
|
+
setMcpDraft(result.draft);
|
|
649
743
|
if (result.mode)
|
|
650
744
|
setMode(result.mode);
|
|
651
745
|
showMessage(result.message);
|
|
652
746
|
}
|
|
653
747
|
async function selectMcpAction(action) {
|
|
654
|
-
const result = selectMcpActionResult(deps.settings, deps.selectedMcpName, action);
|
|
748
|
+
const result = selectMcpActionResult(deps.settings, deps.wizard.selectedMcpName, action);
|
|
655
749
|
if (result.settingsPatch)
|
|
656
750
|
setSettings(await updateSettings(result.settingsPatch));
|
|
657
751
|
if ('selectedName' in result)
|
|
658
|
-
|
|
752
|
+
setSelectedMcpName(result.selectedName);
|
|
659
753
|
if (result.mode)
|
|
660
754
|
setMode(result.mode);
|
|
661
755
|
showMessage(result.message);
|
|
662
756
|
}
|
|
663
|
-
async function finishMcpCustom(keyValue, draft = deps.mcpDraft) {
|
|
757
|
+
async function finishMcpCustom(keyValue, draft = deps.wizard.mcpDraft) {
|
|
664
758
|
const result = finishMcpCustomResult(deps.settings, draft, keyValue);
|
|
665
759
|
if (result.settingsPatch)
|
|
666
760
|
setSettings(await updateSettings(result.settingsPatch));
|
|
667
761
|
if (result.clearDraft)
|
|
668
|
-
|
|
762
|
+
setMcpDraft({});
|
|
669
763
|
if (result.mode)
|
|
670
764
|
setMode(result.mode);
|
|
671
765
|
showMessage(result.message);
|
|
672
766
|
}
|
|
673
767
|
async function setMcpServerKey(keyValue) {
|
|
674
|
-
const result = setMcpServerKeyResult(deps.settings, deps.selectedMcpName, keyValue);
|
|
768
|
+
const result = setMcpServerKeyResult(deps.settings, deps.wizard.selectedMcpName, keyValue);
|
|
675
769
|
if (result.settingsPatch)
|
|
676
770
|
setSettings(await updateSettings(result.settingsPatch));
|
|
677
771
|
if ('selectedName' in result)
|
|
678
|
-
|
|
772
|
+
setSelectedMcpName(result.selectedName);
|
|
679
773
|
if (result.mode)
|
|
680
774
|
setMode(result.mode);
|
|
681
775
|
showMessage(result.message);
|
|
682
776
|
}
|
|
683
|
-
async function
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
if (!isYesConfirmation(value)) {
|
|
689
|
-
showMessage('Cancelled. MCP server not removed.');
|
|
690
|
-
deps.setSelectedMcpName(undefined);
|
|
777
|
+
async function selectTheme(name) {
|
|
778
|
+
const result = selectThemeResult(name);
|
|
779
|
+
if (result.settingsPatch) {
|
|
780
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
691
781
|
setMode('chat');
|
|
692
|
-
return;
|
|
693
782
|
}
|
|
694
|
-
|
|
695
|
-
setSettings(next);
|
|
696
|
-
showMessage(`Removed MCP server ${deps.selectedMcpName}.`);
|
|
697
|
-
deps.setSelectedMcpName(undefined);
|
|
698
|
-
setMode('chat');
|
|
783
|
+
showMessage(result.message);
|
|
699
784
|
}
|
|
700
785
|
const handlers = {
|
|
701
786
|
sessions: selectSession,
|
|
@@ -729,9 +814,51 @@ export function createWizardDispatch(deps) {
|
|
|
729
814
|
mcpAddKey: finishMcpCustom,
|
|
730
815
|
mcpSetKey: setMcpServerKey,
|
|
731
816
|
mcpConfirmRemove: mcpConfirmRemoveMode,
|
|
817
|
+
themes: selectTheme,
|
|
732
818
|
};
|
|
819
|
+
/** Apply one field-transition effect at the submit boundary (was chat.tsx inline branching). */
|
|
820
|
+
async function applyProviderEffect(effect) {
|
|
821
|
+
if (effect.type === 'message')
|
|
822
|
+
showMessage(effect.text);
|
|
823
|
+
else if (effect.type === 'mode')
|
|
824
|
+
setMode(effect.mode);
|
|
825
|
+
else if (effect.type === 'provider-draft') {
|
|
826
|
+
if (effect.replace)
|
|
827
|
+
setProviderDraft(effect.patch);
|
|
828
|
+
else
|
|
829
|
+
setProviderDraft({ ...deps.wizard.providerDraft, ...effect.patch });
|
|
830
|
+
}
|
|
831
|
+
else if (effect.type === 'discover-provider-models') {
|
|
832
|
+
// The draft patch above is still pending React state, so discovery
|
|
833
|
+
// receives the merged draft explicitly (same pattern as MCP stdio).
|
|
834
|
+
await discoverProviderModelsForDraft(effect.draft);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
async function applyMcpEffect(effect) {
|
|
838
|
+
if (effect.type === 'message')
|
|
839
|
+
showMessage(effect.text);
|
|
840
|
+
else if (effect.type === 'mode')
|
|
841
|
+
setMode(effect.mode);
|
|
842
|
+
else if (effect.type === 'mcp-draft')
|
|
843
|
+
setMcpDraft({ ...deps.wizard.mcpDraft, ...effect.patch });
|
|
844
|
+
else if (effect.type === 'finish-mcp-stdio')
|
|
845
|
+
await finishMcpCustom(undefined, effect.draft);
|
|
846
|
+
}
|
|
733
847
|
return {
|
|
734
848
|
async dispatch(mode, value) {
|
|
849
|
+
// Field-capture steps first (same order chat.tsx used), then the submit table.
|
|
850
|
+
const providerEffects = transitionProviderField({ mode, value, settings: deps.settings, draft: deps.wizard.providerDraft });
|
|
851
|
+
if (providerEffects) {
|
|
852
|
+
for (const effect of providerEffects)
|
|
853
|
+
await applyProviderEffect(effect);
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
const mcpEffects = transitionMcpField({ mode, value, settings: deps.settings, draft: deps.wizard.mcpDraft });
|
|
857
|
+
if (mcpEffects) {
|
|
858
|
+
for (const effect of mcpEffects)
|
|
859
|
+
await applyMcpEffect(effect);
|
|
860
|
+
return true;
|
|
861
|
+
}
|
|
735
862
|
const handler = handlers[mode];
|
|
736
863
|
if (!handler)
|
|
737
864
|
return false;
|