@denizokcu/haze 0.11.0 → 1.0.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 +23 -0
- package/README.md +23 -14
- package/SECURITY.md +3 -3
- package/dist/buildInfo.json +3 -3
- 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 +9 -41
- package/dist/cli/chat/messages.d.ts +0 -2
- package/dist/cli/chat/messages.js +2 -2
- 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 +250 -133
- package/dist/cli/commands/chat.js +14 -72
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +6 -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/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/wizardFlow.d.ts +334 -0
- package/dist/cli/commands/wizardFlow.js +377 -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 +7 -0
- package/dist/config/settings.js +3 -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/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 +14 -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 +13 -6
- package/dist/llm/toolResultTypes.d.ts +0 -14
- 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/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 +2 -2
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
- package/dist/llm/tools/{bashTool.js → shellTool.js} +15 -14
- package/dist/llm/tools/toolContext.js +5 -5
- package/dist/llm/tools/workspaceFile.d.ts +0 -1
- package/dist/llm/tools/workspaceFile.js +1 -6
- 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/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
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { configuredProviders, findProvider, modelSelector, providerImageCapable } from '../../config/providers.js';
|
|
2
|
+
import { configuredLspServers, LSP_PRESETS } from '../../config/lspSettings.js';
|
|
3
|
+
import { configuredMcpServers, findMcpServer, findMcpPreset, presetIds } from '../../config/mcpSettings.js';
|
|
4
|
+
import { isSkillEnabled } from '../../config/skillSettings.js';
|
|
5
|
+
import { PROVIDER_PRESETS } from '../../config/providerPresets.js';
|
|
6
|
+
import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
|
|
7
|
+
import { sessionActionSuggestions, sessionSuggestions } from './sessionPicker.js';
|
|
8
|
+
/**
|
|
9
|
+
* Wizard flow table (CR-006 successor): the single source of truth for every
|
|
10
|
+
* picker/wizard step. A step's kind, placeholder, suggestion list, and (for
|
|
11
|
+
* field-capture steps) its pure capture function all live in one entry, so
|
|
12
|
+
* adding a wizard step touches one table row — `chatModes.ts` derives the
|
|
13
|
+
* `Mode` union and the picker/masked/empty-submit classification from this
|
|
14
|
+
* table, and `chat/wizardDispatch.ts` drives the submits.
|
|
15
|
+
*
|
|
16
|
+
* Keep this module a leaf: it must not import the per-domain `*Wizard.ts`
|
|
17
|
+
* result modules or `chatModes.ts`, so the dependency graph stays acyclic
|
|
18
|
+
* (domain modules import the shared constants/helpers from here).
|
|
19
|
+
*/
|
|
20
|
+
// ── Shared action/choice vocabulary ─────────────────────────────────────────
|
|
21
|
+
export const PROVIDER_CHOICES = {
|
|
22
|
+
addProvider: 'add provider',
|
|
23
|
+
custom: 'custom',
|
|
24
|
+
};
|
|
25
|
+
export const PROVIDER_ACTIONS = {
|
|
26
|
+
useProvider: 'use provider',
|
|
27
|
+
addModels: 'add models',
|
|
28
|
+
manageAccess: 'set API key',
|
|
29
|
+
signInChatGpt: 'sign in with ChatGPT',
|
|
30
|
+
markImageCapable: 'mark image-capable',
|
|
31
|
+
clearImageCapable: 'clear image-capable',
|
|
32
|
+
removeModels: 'remove models',
|
|
33
|
+
removeProvider: 'remove provider',
|
|
34
|
+
};
|
|
35
|
+
export const MODEL_CHOICES = {
|
|
36
|
+
addModels: 'add models',
|
|
37
|
+
enterModelNames: 'enter model names',
|
|
38
|
+
};
|
|
39
|
+
export const SERVER_CHOICES = {
|
|
40
|
+
addServer: 'add server',
|
|
41
|
+
custom: 'custom',
|
|
42
|
+
};
|
|
43
|
+
export const COMMON_ACTIONS = {
|
|
44
|
+
enable: 'enable',
|
|
45
|
+
disable: 'disable',
|
|
46
|
+
};
|
|
47
|
+
export const LSP_ACTIONS = {
|
|
48
|
+
removeServer: 'remove server',
|
|
49
|
+
};
|
|
50
|
+
export const MCP_ACTIONS = {
|
|
51
|
+
manageAccess: 'set API key',
|
|
52
|
+
removeServer: 'remove server',
|
|
53
|
+
};
|
|
54
|
+
export const MCP_TRANSPORTS = {
|
|
55
|
+
http: 'http',
|
|
56
|
+
sse: 'sse',
|
|
57
|
+
stdio: 'stdio',
|
|
58
|
+
};
|
|
59
|
+
export const SKILL_CHOICES = {
|
|
60
|
+
addSkill: 'add skill',
|
|
61
|
+
};
|
|
62
|
+
export const SKILL_ACTIONS = {
|
|
63
|
+
showInfo: 'show info',
|
|
64
|
+
validate: 'validate',
|
|
65
|
+
removeSkill: 'remove skill',
|
|
66
|
+
};
|
|
67
|
+
const YES_CONFIRMATION = 'yes';
|
|
68
|
+
// ── Input parsing helpers ───────────────────────────────────────────────────
|
|
69
|
+
export function commaList(value) {
|
|
70
|
+
return value.split(',').map(item => item.trim()).filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
export function commandParts(value) {
|
|
73
|
+
return value.trim().split(/\s+/).filter(Boolean);
|
|
74
|
+
}
|
|
75
|
+
export function isYesConfirmation(value) {
|
|
76
|
+
return value.trim().toLowerCase() === YES_CONFIRMATION;
|
|
77
|
+
}
|
|
78
|
+
export function isValidUrl(value) {
|
|
79
|
+
try {
|
|
80
|
+
new URL(value);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// ── Skill selection lookup (shared by suggestions and the skills wizard) ────
|
|
88
|
+
export function skillPickerValue(skill) {
|
|
89
|
+
return `${skill.name} · ${skill.source}`;
|
|
90
|
+
}
|
|
91
|
+
export function findSelectedSkill(skills, selection) {
|
|
92
|
+
if (!selection)
|
|
93
|
+
return undefined;
|
|
94
|
+
return skills.find(skill => skillPickerValue(skill) === selection)
|
|
95
|
+
?? skills.find(skill => skill.name === selection);
|
|
96
|
+
}
|
|
97
|
+
export function captureProviderName(settings, value) {
|
|
98
|
+
const name = value.trim();
|
|
99
|
+
if (!name)
|
|
100
|
+
return { message: 'Provider name is required.' };
|
|
101
|
+
if (settings.providers?.some(provider => provider.name === name))
|
|
102
|
+
return { message: `Provider ${name} already exists. Choose a unique name.` };
|
|
103
|
+
return { nextMode: 'providerAddUrl', draft: { name }, systemMessage: 'OpenAI-compatible base URL? Example: https://openrouter.ai/api/v1 or http://localhost:1234/v1' };
|
|
104
|
+
}
|
|
105
|
+
export function captureLspName(settings, value) {
|
|
106
|
+
const name = value.trim();
|
|
107
|
+
if (!name)
|
|
108
|
+
return { message: 'LSP server name is required.' };
|
|
109
|
+
if (configuredLspServers(settings).some(server => server.name === name))
|
|
110
|
+
return { message: `LSP server ${name} already exists. Choose a unique name.` };
|
|
111
|
+
return { nextMode: 'lspAddCommand', draft: { name }, systemMessage: 'Command to run? Example: typescript-language-server --stdio' };
|
|
112
|
+
}
|
|
113
|
+
export function captureMcpName(settings, value) {
|
|
114
|
+
const name = value.trim();
|
|
115
|
+
if (!name)
|
|
116
|
+
return { message: 'MCP server name is required.' };
|
|
117
|
+
if (findMcpServer(settings, name))
|
|
118
|
+
return { message: `MCP server ${name} already exists. Choose a unique name.` };
|
|
119
|
+
return { nextMode: 'mcpAddTransport', draft: { name }, systemMessage: 'Transport type? http (Streamable HTTP), sse (Server-Sent Events), or stdio (local process).' };
|
|
120
|
+
}
|
|
121
|
+
export function captureProviderUrl(value) {
|
|
122
|
+
if (!isValidUrl(value))
|
|
123
|
+
return { message: 'Enter a valid URL, for example http://localhost:1234/v1.' };
|
|
124
|
+
// The Codex endpoint only accepts ChatGPT sign-in, never API keys; point
|
|
125
|
+
// users at the preset instead of a custom provider that cannot work (F-14).
|
|
126
|
+
const codexHint = value.trim() === CHATGPT_CODEX_BASE_URL
|
|
127
|
+
? `\nNote: ${CHATGPT_CODEX_BASE_URL} serves ChatGPT sign-in only. To use it, add the OpenAI Subscription preset via /provider instead of a custom API-key provider.`
|
|
128
|
+
: '';
|
|
129
|
+
return { draft: { url: value.trim() }, nextMode: 'providerAddKey', systemMessage: `API key? Leave blank for local/keyless providers.${codexHint}` };
|
|
130
|
+
}
|
|
131
|
+
export function captureMcpUrl(value) {
|
|
132
|
+
if (!isValidUrl(value))
|
|
133
|
+
return { message: 'Enter a valid URL, for example https://mcp.context7.com/mcp.' };
|
|
134
|
+
return { draft: { url: value.trim() }, nextMode: 'mcpAddKey', systemMessage: 'Optional API key or auth header value? (Leave blank to skip — Enter works.) Sent as Authorization: Bearer <value>.' };
|
|
135
|
+
}
|
|
136
|
+
export function captureMcpTransport(value) {
|
|
137
|
+
const transport = value.trim().toLowerCase();
|
|
138
|
+
if (transport !== MCP_TRANSPORTS.http && transport !== MCP_TRANSPORTS.sse && transport !== MCP_TRANSPORTS.stdio)
|
|
139
|
+
return { message: 'Enter http, sse, or stdio.' };
|
|
140
|
+
if (transport === MCP_TRANSPORTS.stdio)
|
|
141
|
+
return { draft: { transport }, nextMode: 'mcpAddCommand', systemMessage: 'Command to run? Example: npx -y @modelcontextprotocol/server-filesystem .' };
|
|
142
|
+
return { draft: { transport }, nextMode: 'mcpAddUrl', systemMessage: `MCP server URL? Example: https://mcp.context7.com/mcp for ${transport}.` };
|
|
143
|
+
}
|
|
144
|
+
export function captureMcpCommand(value) {
|
|
145
|
+
const parts = commandParts(value);
|
|
146
|
+
if (parts.length === 0)
|
|
147
|
+
return { message: 'Command is required.' };
|
|
148
|
+
return { draft: { command: parts[0], args: parts.slice(1) }, nextMode: 'chat', systemMessage: 'Stdio MCP authentication must be handled by the command or wrapper; HTTP headers do not apply.' };
|
|
149
|
+
}
|
|
150
|
+
// ── Suggestion builders (pure; bound to steps in the table below) ───────────
|
|
151
|
+
export function providerSuggestions(settings) {
|
|
152
|
+
return [
|
|
153
|
+
...configuredProviders(settings).map(provider => ({
|
|
154
|
+
value: provider.name,
|
|
155
|
+
description: `${provider.url} · ${provider.models.length} model${provider.models.length === 1 ? '' : 's'}`,
|
|
156
|
+
kind: 'provider',
|
|
157
|
+
})),
|
|
158
|
+
{ value: PROVIDER_CHOICES.addProvider, description: 'Add a new provider (presets available)', kind: 'provider' },
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
export function providerActionSuggestions(settings, selectedProviderName) {
|
|
162
|
+
const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
|
|
163
|
+
return [
|
|
164
|
+
{ value: PROVIDER_ACTIONS.useProvider, description: 'Set this provider and choose a model', kind: 'provider' },
|
|
165
|
+
{ value: PROVIDER_ACTIONS.addModels, description: provider?.kind === 'chatgpt-codex' ? 'Add a supported Codex model name' : 'Fetch the provider model list and add models', kind: 'provider' },
|
|
166
|
+
...(provider?.kind === 'chatgpt-codex'
|
|
167
|
+
? [{ value: PROVIDER_ACTIONS.signInChatGpt, description: 'Sign in again or switch ChatGPT account', kind: 'provider' }]
|
|
168
|
+
: [{ value: PROVIDER_ACTIONS.manageAccess, description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' }]),
|
|
169
|
+
provider
|
|
170
|
+
? (providerImageCapable(provider)
|
|
171
|
+
? { value: PROVIDER_ACTIONS.clearImageCapable, description: 'Stop sending attached images to this provider', kind: 'provider' }
|
|
172
|
+
: { value: PROVIDER_ACTIONS.markImageCapable, description: 'Allow attached images to be sent to this provider', kind: 'provider' })
|
|
173
|
+
: { value: PROVIDER_ACTIONS.markImageCapable, description: 'Allow attached images to be sent to this provider', kind: 'provider' },
|
|
174
|
+
...(provider?.models?.length ? [{ value: PROVIDER_ACTIONS.removeModels, description: 'Remove models from this provider', kind: 'provider' }] : []),
|
|
175
|
+
{ value: PROVIDER_ACTIONS.removeProvider, description: 'Delete this provider from settings', kind: 'provider' },
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
export function presetSuggestions() {
|
|
179
|
+
const cloudPresets = PROVIDER_PRESETS.filter(p => p.category === 'cloud');
|
|
180
|
+
const localPresets = PROVIDER_PRESETS.filter(p => p.category === 'local');
|
|
181
|
+
return [
|
|
182
|
+
...cloudPresets.map(preset => ({
|
|
183
|
+
value: preset.id,
|
|
184
|
+
description: `${preset.baseUrl}${preset.auth === 'chatgpt-oauth' ? ' · browser sign-in' : ''}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
|
|
185
|
+
kind: 'provider',
|
|
186
|
+
})),
|
|
187
|
+
...localPresets.map(preset => ({
|
|
188
|
+
value: preset.id,
|
|
189
|
+
description: `${preset.baseUrl} · local, no API key needed`,
|
|
190
|
+
kind: 'provider',
|
|
191
|
+
})),
|
|
192
|
+
{ value: PROVIDER_CHOICES.custom, description: 'Enter provider name, URL, and API key manually', kind: 'provider' },
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
export function modelSuggestions(settings, modelProviderFilter) {
|
|
196
|
+
const providers = configuredProviders(settings).filter(provider => !modelProviderFilter || provider.name === modelProviderFilter);
|
|
197
|
+
return [
|
|
198
|
+
...providers.flatMap(provider => provider.models.map(model => ({
|
|
199
|
+
value: modelProviderFilter ? model : modelSelector(provider, model),
|
|
200
|
+
description: provider.name,
|
|
201
|
+
kind: 'model',
|
|
202
|
+
}))),
|
|
203
|
+
{ value: MODEL_CHOICES.addModels, description: modelProviderFilter ? `Add models to ${modelProviderFilter} (fetched from its models endpoint)` : 'Add models to a provider (fetched from its models endpoint)', kind: 'model' },
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
export function modelAddProviderSuggestions(settings) {
|
|
207
|
+
return configuredProviders(settings).map(provider => ({
|
|
208
|
+
value: provider.name,
|
|
209
|
+
description: `${provider.models.length} model${provider.models.length === 1 ? '' : 's'} configured`,
|
|
210
|
+
kind: 'provider',
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Model picker fed by live /models discovery. Curated `suggestedModels`
|
|
215
|
+
* (from provider presets) are pinned atop the discovered list when the
|
|
216
|
+
* endpoint actually serves them — stale curation entries simply don't pin.
|
|
217
|
+
*/
|
|
218
|
+
export function modelPickSuggestions(settings, providerName, discoveredModels, suggestedModels = []) {
|
|
219
|
+
const provider = providerName ? findProvider(settings, providerName) : undefined;
|
|
220
|
+
const configured = new Set(provider?.models ?? []);
|
|
221
|
+
const available = discoveredModels.filter(model => !configured.has(model));
|
|
222
|
+
const availableSet = new Set(available);
|
|
223
|
+
const pinned = suggestedModels.filter(model => availableSet.has(model));
|
|
224
|
+
const pinnedSet = new Set(pinned);
|
|
225
|
+
return [
|
|
226
|
+
...pinned.map(model => ({
|
|
227
|
+
value: model,
|
|
228
|
+
description: 'suggested',
|
|
229
|
+
kind: 'model',
|
|
230
|
+
})),
|
|
231
|
+
...available.filter(model => !pinnedSet.has(model)).map(model => ({
|
|
232
|
+
value: model,
|
|
233
|
+
description: providerName,
|
|
234
|
+
kind: 'model',
|
|
235
|
+
})),
|
|
236
|
+
{ value: MODEL_CHOICES.enterModelNames, description: 'Type comma-separated model names instead', kind: 'model' },
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
export function lspSuggestions(settings) {
|
|
240
|
+
const servers = configuredLspServers(settings);
|
|
241
|
+
return [{ value: SERVER_CHOICES.addServer, description: 'add an LSP server (presets available)', kind: 'lsp' },
|
|
242
|
+
...servers.map(server => ({
|
|
243
|
+
value: server.name,
|
|
244
|
+
description: `${server.command}${(server.args ?? []).length ? ` ${(server.args ?? []).join(' ')}` : ''} · ${server.enabled === false ? 'disabled' : 'enabled'}`,
|
|
245
|
+
kind: 'lsp',
|
|
246
|
+
}))];
|
|
247
|
+
}
|
|
248
|
+
export function lspActionSuggestions(settings, selectedLspName) {
|
|
249
|
+
const server = selectedLspName ? configuredLspServers(settings).find(s => s.name === selectedLspName) : undefined;
|
|
250
|
+
const result = [];
|
|
251
|
+
if (server)
|
|
252
|
+
result.push({ value: server.enabled === false ? COMMON_ACTIONS.enable : COMMON_ACTIONS.disable, description: `${server.enabled === false ? COMMON_ACTIONS.enable : COMMON_ACTIONS.disable} this server`, kind: 'lsp' });
|
|
253
|
+
result.push({ value: LSP_ACTIONS.removeServer, description: 'remove this server', kind: 'lsp' });
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
function lspPresetSuggestions() {
|
|
257
|
+
return [
|
|
258
|
+
...Object.values(LSP_PRESETS).map(preset => ({
|
|
259
|
+
value: preset.name,
|
|
260
|
+
description: `${preset.command} ${(preset.args ?? []).join(' ')} [${(preset.extensions ?? []).join(', ')}]`,
|
|
261
|
+
kind: 'lsp',
|
|
262
|
+
})),
|
|
263
|
+
{ value: SERVER_CHOICES.custom, description: 'enter a name and command manually', kind: 'lsp' },
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
export function mcpSuggestions(settings) {
|
|
267
|
+
const servers = configuredMcpServers(settings);
|
|
268
|
+
return [{ value: SERVER_CHOICES.addServer, description: 'add an MCP server (presets available)', kind: 'mcp' },
|
|
269
|
+
...servers.map(server => {
|
|
270
|
+
const location = server.url ?? (server.command ? `${server.command} ${(server.args ?? []).join(' ')}`.trim() : '');
|
|
271
|
+
return { value: server.name, description: `${server.transport}${location ? ` ${location}` : ''} · ${server.enabled === false ? 'disabled' : 'enabled'}`, kind: 'mcp' };
|
|
272
|
+
})];
|
|
273
|
+
}
|
|
274
|
+
export function mcpActionSuggestions(settings, selectedMcpName) {
|
|
275
|
+
const server = selectedMcpName ? findMcpServer(settings, selectedMcpName) : undefined;
|
|
276
|
+
const result = [];
|
|
277
|
+
if (server) {
|
|
278
|
+
result.push({ value: server.enabled === false ? COMMON_ACTIONS.enable : COMMON_ACTIONS.disable, description: `${server.enabled === false ? COMMON_ACTIONS.enable : COMMON_ACTIONS.disable} this server`, kind: 'mcp' });
|
|
279
|
+
if (server.transport !== 'stdio')
|
|
280
|
+
result.push({ value: MCP_ACTIONS.manageAccess, description: server.headers?.length ? 'update the saved API key' : 'add an API key', kind: 'mcp' });
|
|
281
|
+
}
|
|
282
|
+
result.push({ value: MCP_ACTIONS.removeServer, description: 'remove this server', kind: 'mcp' });
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
function mcpPresetSuggestions() {
|
|
286
|
+
return [
|
|
287
|
+
...presetIds().map(presetId => {
|
|
288
|
+
const preset = findMcpPreset(presetId);
|
|
289
|
+
return { value: presetId, description: preset.description ?? `${preset.transport} server`, kind: 'mcp' };
|
|
290
|
+
}),
|
|
291
|
+
{ value: SERVER_CHOICES.custom, description: 'enter name, transport, and URL or command manually', kind: 'mcp' },
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
export function mcpTransportSuggestions() {
|
|
295
|
+
return [
|
|
296
|
+
{ value: MCP_TRANSPORTS.http, description: 'Streamable HTTP (remote)', kind: 'mcp' },
|
|
297
|
+
{ value: MCP_TRANSPORTS.sse, description: 'Server-Sent Events (remote)', kind: 'mcp' },
|
|
298
|
+
{ value: MCP_TRANSPORTS.stdio, description: 'local process', kind: 'mcp' },
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
export function skillsSuggestions(settings, skills) {
|
|
302
|
+
return [{ value: SKILL_CHOICES.addSkill, description: 'describe a new skill for haze to generate', kind: 'skill' },
|
|
303
|
+
...skills.map(skill => ({
|
|
304
|
+
value: skills.some(candidate => candidate !== skill && candidate.name === skill.name) ? skillPickerValue(skill) : skill.name,
|
|
305
|
+
description: `${skill.description} · ${skill.source}${isSkillEnabled(settings, skill.name, skill.source) ? '' : ' · disabled'}`,
|
|
306
|
+
kind: 'skill',
|
|
307
|
+
}))];
|
|
308
|
+
}
|
|
309
|
+
export function skillScopeSuggestions() {
|
|
310
|
+
return [
|
|
311
|
+
{ value: 'this project', description: 'create .haze/skills/<name>/SKILL.md for this repository', kind: 'skill' },
|
|
312
|
+
{ value: 'global', description: 'create ~/.haze/skills/<name>/SKILL.md for your user', kind: 'skill' },
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
export function skillsActionSuggestions(settings, skills, selectedSkillName) {
|
|
316
|
+
const skill = findSelectedSkill(skills, selectedSkillName);
|
|
317
|
+
const result = [];
|
|
318
|
+
if (skill) {
|
|
319
|
+
const enabled = isSkillEnabled(settings, skill.name, skill.source);
|
|
320
|
+
result.push({ value: enabled ? COMMON_ACTIONS.disable : COMMON_ACTIONS.enable, description: `${enabled ? COMMON_ACTIONS.disable : COMMON_ACTIONS.enable} this skill`, kind: 'skill' });
|
|
321
|
+
result.push({ value: SKILL_ACTIONS.showInfo, description: 'show description, references, and path', kind: 'skill' });
|
|
322
|
+
result.push({ value: SKILL_ACTIONS.validate, description: 're-load and validate SKILL.md', kind: 'skill' });
|
|
323
|
+
}
|
|
324
|
+
result.push({ value: SKILL_ACTIONS.removeSkill, description: 'delete this skill directory', kind: 'skill' });
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
export const WIZARD_STEPS = [
|
|
328
|
+
// Sessions
|
|
329
|
+
{ id: 'sessions', kind: 'pick', placeholder: 'Choose a saved session', suggestions: (s) => sessionSuggestions(s.sessions ?? []) },
|
|
330
|
+
{ id: 'sessionAction', kind: 'pick', placeholder: 'Resume or fork this session', suggestions: () => sessionActionSuggestions() },
|
|
331
|
+
// Provider + model flows
|
|
332
|
+
{ id: 'provider', kind: 'pick', placeholder: 'Choose provider', suggestions: (s) => providerSuggestions(s.settings) },
|
|
333
|
+
{ id: 'providerAction', kind: 'pick', placeholder: 'Choose provider action', suggestions: (s) => providerActionSuggestions(s.settings, s.selectedProviderName) },
|
|
334
|
+
{ id: 'providerAddPreset', kind: 'pick', placeholder: 'Choose a provider preset or custom', suggestions: () => presetSuggestions() },
|
|
335
|
+
{ id: 'providerAddName', kind: 'input', placeholder: 'Provider name', suggestions: () => [] },
|
|
336
|
+
{ id: 'providerAddUrl', kind: 'input', placeholder: 'https://example.com/v1', suggestions: () => [] },
|
|
337
|
+
{ id: 'providerAddKey', kind: 'masked-input', placeholder: 'API key, or blank for local', optional: true, suggestions: () => [] },
|
|
338
|
+
{ id: 'providerAddModels', kind: 'input', placeholder: 'model-a, model-b', suggestions: () => [] },
|
|
339
|
+
{ id: 'providerAppendModels', kind: 'input', placeholder: 'model-a, model-b', suggestions: () => [] },
|
|
340
|
+
{ id: 'providerSetKey', kind: 'masked-input', placeholder: 'API key', suggestions: () => [] },
|
|
341
|
+
{ id: 'providerRemoveModels', kind: 'input', placeholder: 'model-a, model-b', suggestions: () => [] },
|
|
342
|
+
{ id: 'providerConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
|
|
343
|
+
{ id: 'model', kind: 'pick', placeholder: 'Choose model, or add model', suggestions: (s) => modelSuggestions(s.settings, s.modelProviderFilter) },
|
|
344
|
+
{ id: 'modelAddProvider', kind: 'pick', placeholder: 'Choose a provider to add models to', suggestions: (s) => modelAddProviderSuggestions(s.settings) },
|
|
345
|
+
{ id: 'modelPick', kind: 'pick', placeholder: 'Choose a model to add', suggestions: (s) => modelPickSuggestions(s.settings, s.selectedProviderName ?? s.providerDraftName, s.discoveredModels ?? [], s.suggestedModels ?? []) },
|
|
346
|
+
// Skills
|
|
347
|
+
{ id: 'skills', kind: 'pick', placeholder: 'Choose a skill or add skill', suggestions: (s) => skillsSuggestions(s.settings, s.skills) },
|
|
348
|
+
{ id: 'skillsAction', kind: 'pick', placeholder: 'show info, enable, disable, validate, or remove', suggestions: (s) => skillsActionSuggestions(s.settings, s.skills, s.selectedSkillName) },
|
|
349
|
+
{ id: 'skillsAddName', kind: 'input', placeholder: 'Skill name (kebab-case, e.g. security-review)', suggestions: () => [] },
|
|
350
|
+
{ id: 'skillsAddScope', kind: 'pick', placeholder: 'Choose this project or global', suggestions: () => skillScopeSuggestions() },
|
|
351
|
+
{ id: 'skillsAddDescription', kind: 'input', placeholder: 'Describe what the skill should do', suggestions: () => [] },
|
|
352
|
+
{ id: 'skillsConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
|
|
353
|
+
// LSP servers
|
|
354
|
+
{ id: 'lsp', kind: 'pick', placeholder: 'Choose LSP server or add server', suggestions: (s) => lspSuggestions(s.settings) },
|
|
355
|
+
{ id: 'lspAction', kind: 'pick', placeholder: 'enable, disable, or remove server', suggestions: (s) => lspActionSuggestions(s.settings, s.selectedLspName) },
|
|
356
|
+
{ id: 'lspAddPreset', kind: 'pick', placeholder: 'Choose an LSP preset or custom', suggestions: () => lspPresetSuggestions() },
|
|
357
|
+
{ id: 'lspAddName', kind: 'input', placeholder: 'LSP server name (e.g. typescript)', suggestions: () => [] },
|
|
358
|
+
{ id: 'lspAddCommand', kind: 'input', placeholder: 'Command (e.g. typescript-language-server --stdio)', suggestions: () => [] },
|
|
359
|
+
{ id: 'lspConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
|
|
360
|
+
// MCP servers
|
|
361
|
+
{ id: 'mcp', kind: 'pick', placeholder: 'Choose MCP server or add server', suggestions: (s) => mcpSuggestions(s.settings) },
|
|
362
|
+
{ id: 'mcpAction', kind: 'pick', placeholder: 'enable, disable, remove, or set key', suggestions: (s) => mcpActionSuggestions(s.settings, s.selectedMcpName) },
|
|
363
|
+
{ id: 'mcpAddPreset', kind: 'pick', placeholder: 'Choose an MCP preset or custom', suggestions: () => mcpPresetSuggestions() },
|
|
364
|
+
{ id: 'mcpAddName', kind: 'input', placeholder: 'MCP server name (e.g. context7)', suggestions: () => [] },
|
|
365
|
+
{ id: 'mcpAddTransport', kind: 'pick', placeholder: 'http, sse, or stdio', suggestions: () => mcpTransportSuggestions() },
|
|
366
|
+
{ id: 'mcpAddUrl', kind: 'input', placeholder: 'https://mcp.example.com/mcp', suggestions: () => [] },
|
|
367
|
+
{ id: 'mcpAddCommand', kind: 'input', placeholder: 'Command (e.g. npx -y @pkg/server)', suggestions: () => [] },
|
|
368
|
+
{ id: 'mcpAddKey', kind: 'masked-input', placeholder: 'API key, or blank to skip', optional: true, suggestions: () => [] },
|
|
369
|
+
{ id: 'mcpSetKey', kind: 'masked-input', placeholder: 'API key', suggestions: () => [] },
|
|
370
|
+
{ id: 'mcpConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
|
|
371
|
+
];
|
|
372
|
+
const WIZARD_STEP_BY_ID = Object.fromEntries(WIZARD_STEPS.map(step => [step.id, step]));
|
|
373
|
+
/** Suggestions for a wizard mode, or undefined when the mode is not a wizard step ('chat'). */
|
|
374
|
+
export function wizardSuggestionsFor(mode, state) {
|
|
375
|
+
const step = WIZARD_STEP_BY_ID[mode];
|
|
376
|
+
return step ? step.suggestions(state) : undefined;
|
|
377
|
+
}
|
|
@@ -8,6 +8,8 @@ import { compactModelMessages } from '../core/agent/compaction.js';
|
|
|
8
8
|
import { summarizeContextDiagnostics } from '../config/contextFiles.js';
|
|
9
9
|
const reportSession = { start: new Date(0), cwd: process.cwd() };
|
|
10
10
|
async function loadFiles(paths) {
|
|
11
|
+
// This developer-only report command intentionally accepts explicit host paths:
|
|
12
|
+
// it analyzes files selected by the local CLI user and never writes them.
|
|
11
13
|
const candidates = paths.length > 0 ? paths : ['AGENTS.md', 'CLAUDE.md'];
|
|
12
14
|
const files = [];
|
|
13
15
|
for (const candidate of candidates) {
|
|
@@ -21,6 +23,7 @@ async function loadFiles(paths) {
|
|
|
21
23
|
const args = process.argv.slice(2);
|
|
22
24
|
const traceIndex = args.indexOf('--trace');
|
|
23
25
|
if (traceIndex >= 0) {
|
|
26
|
+
// Trace fixtures are likewise explicit local-user input, not model-controlled paths.
|
|
24
27
|
const tracePath = args[traceIndex + 1];
|
|
25
28
|
if (!tracePath)
|
|
26
29
|
throw new Error('--trace requires a JSON fixture path');
|
package/dist/cli/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { runHeadless } from './commands/runCommand.js';
|
|
|
5
5
|
import { installTerminalTitle, terminalTitleLabel } from './terminalTitle.js';
|
|
6
6
|
import { findSession } from '../core/session/sessionStore.js';
|
|
7
7
|
import { installBackgroundProcessSignalHandlers, teardownBackgroundProcesses } from '../core/process/backgroundRegistry.js';
|
|
8
|
-
import { STDIN_PROMPT_BYTES } from '../core/limits
|
|
8
|
+
import { STDIN_PROMPT_BYTES } from '../core/limits.js';
|
|
9
9
|
import { readPackageVersion } from '../utils/version.js';
|
|
10
10
|
import { formatVersionVerbose, readBuildInfo } from '../utils/buildInfo.js';
|
|
11
11
|
import { runDoctor } from './commands/doctor.js';
|
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
5
|
import { HAZE_DIR } from './paths.js';
|
|
6
6
|
import { readUtf8Prefix } from '../core/io/boundedRead.js';
|
|
7
|
+
import { assertRealPathInsideRoot } from '../utils/path.js';
|
|
7
8
|
const DEFAULT_BUDGET_THRESHOLD = 0.15;
|
|
8
9
|
function resolveBudgetThreshold(explicit) {
|
|
9
10
|
if (typeof explicit === 'number' && Number.isFinite(explicit))
|
|
@@ -37,7 +38,7 @@ function displayPath(filePath) {
|
|
|
37
38
|
return `~/${path.relative(home, filePath)}`;
|
|
38
39
|
return filePath;
|
|
39
40
|
}
|
|
40
|
-
async function readContextCandidates(candidates, seen = new Set(), options = {}) {
|
|
41
|
+
async function readContextCandidates(candidates, seen = new Set(), options = {}, allowedRoot) {
|
|
41
42
|
const contextFiles = [];
|
|
42
43
|
for (const candidate of candidates) {
|
|
43
44
|
const absolute = path.resolve(candidate);
|
|
@@ -49,13 +50,18 @@ async function readContextCandidates(candidates, seen = new Set(), options = {})
|
|
|
49
50
|
const stat = await fs.stat(absolute).catch(() => null);
|
|
50
51
|
if (!stat?.isFile())
|
|
51
52
|
continue;
|
|
53
|
+
const readablePath = allowedRoot
|
|
54
|
+
? await assertRealPathInsideRoot(allowedRoot, absolute, absolute, 'workspace').catch(() => undefined)
|
|
55
|
+
: absolute;
|
|
56
|
+
if (!readablePath)
|
|
57
|
+
continue;
|
|
52
58
|
const displayedPath = displayPath(absolute);
|
|
53
59
|
const signature = contextFileSignature(stat);
|
|
54
60
|
const loadedSignature = options.alreadyLoadedSignatures?.get(displayedPath) ?? options.alreadyLoadedSignatures?.get(absolute);
|
|
55
61
|
if (loadedSignature === signature)
|
|
56
62
|
continue;
|
|
57
63
|
options.onContextFileRead?.(displayedPath);
|
|
58
|
-
const prefix = await readUtf8Prefix(
|
|
64
|
+
const prefix = await readUtf8Prefix(readablePath, MAX_CONTEXT_FILE_CHARS * 4);
|
|
59
65
|
const content = prefix.content.slice(0, MAX_CONTEXT_FILE_CHARS);
|
|
60
66
|
const truncated = prefix.truncated || prefix.content.length > MAX_CONTEXT_FILE_CHARS;
|
|
61
67
|
const file = {
|
|
@@ -112,7 +118,7 @@ export async function readScopedContextFilesForPath(targetPath, options = {}) {
|
|
|
112
118
|
alreadySeen.add(path.resolve(cwd, loadedPath));
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
|
-
return await readContextCandidates(candidates, alreadySeen, options);
|
|
121
|
+
return await readContextCandidates(candidates, alreadySeen, options, cwd);
|
|
116
122
|
}
|
|
117
123
|
export function contextFileDiagnostics(files) {
|
|
118
124
|
return files.map(file => ({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const INPUT_HISTORY_FILE: string;
|
|
2
1
|
export declare function readInputHistory(file?: string): Promise<string[]>;
|
|
3
2
|
export declare function writeInputHistory(history: string[], file?: string): Promise<void>;
|
|
4
3
|
export declare function addInputHistoryItem(item: string, file?: string): Promise<string[]>;
|
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { HAZE_DIR } from './paths.js';
|
|
4
4
|
import { tightenPrivateFile, writePrivateJsonAtomic } from './privateStorage.js';
|
|
5
5
|
const HISTORY_DIR = path.join(HAZE_DIR, 'history');
|
|
6
|
-
|
|
6
|
+
const INPUT_HISTORY_FILE = path.join(HISTORY_DIR, 'input-history.json');
|
|
7
7
|
const MAX_HISTORY_ITEMS = 500;
|
|
8
8
|
function normalizeHistory(value) {
|
|
9
9
|
if (!Array.isArray(value))
|
|
@@ -20,21 +20,6 @@ export type ModelDiscoveryResult = {
|
|
|
20
20
|
};
|
|
21
21
|
export declare function modelsEndpointUrl(baseUrl: string): string;
|
|
22
22
|
export declare function parseModelsBody(body: unknown): string[];
|
|
23
|
-
/**
|
|
24
|
-
* Ollama native enrichment. Ollama's OpenAI-compatible /v1/models returns no
|
|
25
|
-
* context fields (verified against ollama 0.32), but its native API does, with
|
|
26
|
-
* different fidelity levels — resolved best-first per model:
|
|
27
|
-
* 1. GET /api/ps — the ACTUAL runtime context of a currently-loaded model
|
|
28
|
-
* (reflects OLLAMA_CONTEXT_LENGTH and Ollama's vram-based auto-sizing);
|
|
29
|
-
* only available while the model stays loaded (keep_alive window).
|
|
30
|
-
* 2. POST /api/show parameters `num_ctx N` — the user's explicit per-model
|
|
31
|
-
* setting (Modelfile), capped by the model's trained maximum.
|
|
32
|
-
* 3. POST /api/show model_info `<arch>.context_length` — the model's
|
|
33
|
-
* theoretical maximum. The effective runtime window may be smaller
|
|
34
|
-
* (auto-sized to VRAM), so it is capped at the conservative local
|
|
35
|
-
* fallback rather than trusted outright (silent truncation guard).
|
|
36
|
-
*/
|
|
37
|
-
export declare const OLLAMA_PROBE_TIMEOUT_MS = 4000;
|
|
38
23
|
interface OllamaShowFacts {
|
|
39
24
|
max?: number;
|
|
40
25
|
numCtx?: number;
|
|
@@ -44,7 +44,7 @@ function firstHarvested(...values) {
|
|
|
44
44
|
* (auto-sized to VRAM), so it is capped at the conservative local
|
|
45
45
|
* fallback rather than trusted outright (silent truncation guard).
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
const OLLAMA_PROBE_TIMEOUT_MS = 4_000;
|
|
48
48
|
/** Bound the per-save /api/show probe loop so bulk pastes stay cheap. */
|
|
49
49
|
const OLLAMA_PROBE_MAX_MODELS = 8;
|
|
50
50
|
function loopbackRoot(baseUrl) {
|
|
@@ -87,6 +87,13 @@ export interface HazeSettings {
|
|
|
87
87
|
*/
|
|
88
88
|
contextWindowFallbackTokens?: number;
|
|
89
89
|
localContextWindowFallbackTokens?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Size of the shared bounded model-retry pool for transient model errors and
|
|
92
|
+
* idle-stream stalls, per turn. Unset means the built-in default of 2. Raise
|
|
93
|
+
* it for providers that terminate long streams aggressively (e.g. some
|
|
94
|
+
* OpenAI-compatible gateways); 0 disables automatic retries.
|
|
95
|
+
*/
|
|
96
|
+
modelRetries?: number;
|
|
90
97
|
/**
|
|
91
98
|
* Manual `/compact` mode (F-09): `llm-summary` (default) asks the active
|
|
92
99
|
* model to summarize the older history; `heuristic` keeps the bounded
|
package/dist/config/settings.js
CHANGED
|
@@ -44,6 +44,8 @@ const subagentSettingsSchema = z.object({
|
|
|
44
44
|
}).passthrough();
|
|
45
45
|
/** Fallback windows must be plausible positive token counts (not fractions/junk). */
|
|
46
46
|
const contextWindowFallbackSchema = z.number().int().min(1_000).max(10_000_000);
|
|
47
|
+
/** Retry-pool size must be a small non-negative count (0 disables retries). */
|
|
48
|
+
const modelRetriesSchema = z.number().int().min(0).max(10);
|
|
47
49
|
const settingsSchema = z.object({
|
|
48
50
|
provider: z.string().optional(),
|
|
49
51
|
model: z.string().optional(),
|
|
@@ -55,6 +57,7 @@ const settingsSchema = z.object({
|
|
|
55
57
|
reasoning: reasoningLevelSchema.optional(),
|
|
56
58
|
contextWindowFallbackTokens: contextWindowFallbackSchema.optional(),
|
|
57
59
|
localContextWindowFallbackTokens: contextWindowFallbackSchema.optional(),
|
|
60
|
+
modelRetries: modelRetriesSchema.optional(),
|
|
58
61
|
manualCompaction: z.enum(['llm-summary', 'heuristic']).optional(),
|
|
59
62
|
tips: z.object({ enabled: z.boolean().optional() }).optional(),
|
|
60
63
|
apiKey: z.string().optional(),
|
|
@@ -16,18 +16,18 @@ export function configuredSkillSettings(settings) {
|
|
|
16
16
|
function settingScope(entry) {
|
|
17
17
|
return entry.scope ?? 'global';
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function isSameSkillSetting(entry, name, scope) {
|
|
20
20
|
return entry.name === name && settingScope(entry) === scope;
|
|
21
21
|
}
|
|
22
22
|
/** A skill is enabled unless an explicit scope-aware override disables it. */
|
|
23
23
|
export function isSkillEnabled(settings, name, scope = 'global') {
|
|
24
|
-
const entry = configuredSkillSettings(settings).find(candidate =>
|
|
24
|
+
const entry = configuredSkillSettings(settings).find(candidate => isSameSkillSetting(candidate, name, scope));
|
|
25
25
|
return entry ? entry.enabled !== false : true;
|
|
26
26
|
}
|
|
27
27
|
export function setSkillEnabled(settings, name, enabled, scope = 'global') {
|
|
28
|
-
const others = configuredSkillSettings(settings).filter(entry => !
|
|
28
|
+
const others = configuredSkillSettings(settings).filter(entry => !isSameSkillSetting(entry, name, scope));
|
|
29
29
|
return enabled ? others : [...others, { name, ...(scope === 'project' ? { scope } : {}), enabled: false }];
|
|
30
30
|
}
|
|
31
31
|
export function removeSkillSetting(settings, name, scope = 'global') {
|
|
32
|
-
return configuredSkillSettings(settings).filter(entry => !
|
|
32
|
+
return configuredSkillSettings(settings).filter(entry => !isSameSkillSetting(entry, name, scope));
|
|
33
33
|
}
|
|
@@ -6,7 +6,7 @@ import { HAZE_DIR } from './paths.js';
|
|
|
6
6
|
import { isNewer } from '../utils/version.js';
|
|
7
7
|
import { tightenPrivateFile, writePrivateJsonAtomic } from './privateStorage.js';
|
|
8
8
|
const execFile = promisify(execFileCallback);
|
|
9
|
-
|
|
9
|
+
const UPDATE_CHECK_FILE = path.join(HAZE_DIR, 'updateCheck.json');
|
|
10
10
|
const DEFAULT_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24h
|
|
11
11
|
const DEFAULT_TIMEOUT_MS = 5000;
|
|
12
12
|
async function defaultExecVersion(packageName, options) {
|