@denizokcu/haze 0.6.0 → 0.7.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 +19 -0
- package/README.md +59 -12
- package/dist/cli/chat/TaskBar.d.ts +9 -0
- package/dist/cli/chat/TaskBar.js +40 -0
- package/dist/cli/chat/chatMetrics.d.ts +11 -0
- package/dist/cli/chat/chatMetrics.js +50 -0
- package/dist/cli/chat/inputSuggestions.d.ts +16 -0
- package/dist/cli/chat/inputSuggestions.js +55 -0
- package/dist/cli/chat/messages.d.ts +9 -0
- package/dist/cli/chat/messages.js +76 -0
- package/dist/cli/chat/sessionRecorder.d.ts +12 -0
- package/dist/cli/chat/sessionRecorder.js +21 -0
- package/dist/cli/chat/startupInfo.d.ts +4 -0
- package/dist/cli/chat/startupInfo.js +53 -0
- package/dist/cli/chat/turnState.d.ts +5 -0
- package/dist/cli/chat/turnState.js +20 -0
- package/dist/cli/commands/chat.d.ts +0 -1
- package/dist/cli/commands/chat.js +293 -894
- package/dist/cli/commands/chatModes.d.ts +8 -0
- package/dist/cli/commands/chatModes.js +44 -0
- package/dist/cli/commands/commandHelp.d.ts +6 -0
- package/dist/cli/commands/commandHelp.js +25 -0
- package/dist/cli/commands/commands.d.ts +1 -1
- package/dist/cli/commands/commands.js +41 -267
- package/dist/cli/commands/formatters.js +12 -4
- package/dist/cli/commands/initCommand.d.ts +2 -0
- package/dist/cli/commands/initCommand.js +19 -0
- package/dist/cli/commands/logsCommand.d.ts +2 -0
- package/dist/cli/commands/logsCommand.js +63 -0
- package/dist/cli/commands/lspWizard.d.ts +14 -0
- package/dist/cli/commands/lspWizard.js +44 -0
- package/dist/cli/commands/mcpWizard.d.ts +15 -0
- package/dist/cli/commands/mcpWizard.js +69 -0
- package/dist/cli/commands/modelCommand.d.ts +2 -0
- package/dist/cli/commands/modelCommand.js +36 -0
- package/dist/cli/commands/providerWizard.d.ts +30 -0
- package/dist/cli/commands/providerWizard.js +114 -0
- package/dist/cli/commands/runCommand.d.ts +16 -0
- package/dist/cli/commands/runCommand.js +170 -0
- package/dist/cli/commands/settingsSummary.d.ts +3 -0
- package/dist/cli/commands/settingsSummary.js +40 -0
- package/dist/cli/commands/skillConfirmRemove.d.ts +11 -0
- package/dist/cli/commands/skillConfirmRemove.js +19 -0
- package/dist/cli/commands/skillCreation.d.ts +12 -0
- package/dist/cli/commands/skillCreation.js +14 -0
- package/dist/cli/commands/skillWizard.d.ts +15 -0
- package/dist/cli/commands/skillWizard.js +38 -0
- package/dist/cli/commands/streaming/assistantText.d.ts +17 -0
- package/dist/cli/commands/streaming/assistantText.js +115 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +55 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +102 -0
- package/dist/cli/commands/streaming/toolResultState.d.ts +13 -0
- package/dist/cli/commands/streaming/toolResultState.js +25 -0
- package/dist/cli/commands/streaming/turnRuntime.d.ts +78 -0
- package/dist/cli/commands/streaming/turnRuntime.js +86 -0
- package/dist/cli/commands/streaming.d.ts +9 -25
- package/dist/cli/commands/streaming.js +82 -347
- package/dist/cli/commands/wizardActions.d.ts +40 -0
- package/dist/cli/commands/wizardActions.js +40 -0
- package/dist/cli/commands/wizardInput.d.ts +4 -0
- package/dist/cli/commands/wizardInput.js +19 -0
- package/dist/cli/commands/wizardPrompts.d.ts +22 -0
- package/dist/cli/commands/wizardPrompts.js +52 -0
- package/dist/cli/commands/wizardSuggestions.d.ts +23 -0
- package/dist/cli/commands/wizardSuggestions.js +139 -0
- package/dist/cli/index.js +62 -4
- package/dist/config/contextFiles.d.ts +8 -1
- package/dist/config/contextFiles.js +25 -12
- package/dist/config/lspSettings.js +3 -6
- package/dist/config/mcpSettings.js +5 -5
- package/dist/config/providers.js +4 -4
- package/dist/config/skillSettings.js +4 -3
- package/dist/core/agent/budgets.d.ts +6 -0
- package/dist/core/agent/budgets.js +6 -0
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/requestAssembly.d.ts +0 -7
- package/dist/core/agent/requestAssembly.js +27 -5
- package/dist/core/agent/toolOutputStore.js +5 -4
- package/dist/core/agent/toolResults.d.ts +31 -0
- package/dist/core/agent/toolResults.js +42 -0
- package/dist/core/agent/turnPolicy.d.ts +8 -0
- package/dist/core/agent/turnPolicy.js +23 -0
- package/dist/core/agent/workState.d.ts +18 -5
- package/dist/core/agent/workState.js +39 -20
- package/dist/core/bashOutput/reducers/content.d.ts +1 -0
- package/dist/core/bashOutput/reducers/content.js +1 -1
- package/dist/core/bashOutput/reducers/gh.d.ts +1 -0
- package/dist/core/bashOutput/reducers/gh.js +77 -0
- package/dist/core/bashOutput/registry.js +8 -0
- package/dist/core/goal/sessionGoal.d.ts +6 -30
- package/dist/core/goal/sessionGoal.js +3 -68
- package/dist/core/safety/bashClassifier.js +30 -0
- package/dist/core/safety/urlGuard.d.ts +1 -0
- package/dist/core/safety/urlGuard.js +6 -1
- package/dist/core/session/sessionSlimming.d.ts +5 -0
- package/dist/core/session/sessionSlimming.js +78 -0
- package/dist/core/session/sessionStore.d.ts +23 -3
- package/dist/core/session/sessionStore.js +30 -10
- package/dist/core/subagent/subagentRunner.d.ts +11 -1
- package/dist/core/subagent/subagentRunner.js +1 -0
- package/dist/llm/capabilities.d.ts +12 -0
- package/dist/llm/capabilities.js +10 -0
- package/dist/llm/client.d.ts +1 -0
- package/dist/llm/client.js +11 -2
- package/dist/llm/hazeTools.d.ts +31 -32
- package/dist/llm/hazeTools.js +40 -567
- package/dist/llm/lsp.d.ts +46 -1
- package/dist/llm/lsp.js +9 -9
- package/dist/llm/lspTools.d.ts +2 -20
- package/dist/llm/mcp.js +9 -0
- package/dist/llm/requestContext.js +7 -22
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +1 -1
- package/dist/llm/tools/bashTool.d.ts +5 -0
- package/dist/llm/tools/bashTool.js +81 -0
- package/dist/llm/tools/editMatch.d.ts +55 -0
- package/dist/llm/tools/editMatch.js +99 -0
- package/dist/llm/tools/failures.d.ts +36 -0
- package/dist/llm/tools/failures.js +38 -0
- package/dist/llm/tools/fetchTool.d.ts +65 -0
- package/dist/llm/tools/fetchTool.js +45 -0
- package/dist/llm/tools/fileToolShared.d.ts +10 -0
- package/dist/llm/tools/fileToolShared.js +43 -0
- package/dist/llm/tools/grepParse.d.ts +13 -0
- package/dist/llm/tools/grepParse.js +67 -0
- package/dist/llm/tools/outputCap.d.ts +53 -0
- package/dist/llm/tools/outputCap.js +67 -0
- package/dist/llm/tools/storedOutputTool.d.ts +10 -0
- package/dist/llm/tools/storedOutputTool.js +17 -0
- package/dist/llm/tools/taskTool.d.ts +28 -0
- package/dist/llm/tools/taskTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +69 -0
- package/dist/llm/tools/toolContext.js +187 -0
- package/dist/llm/tools/workspaceFile.d.ts +33 -0
- package/dist/llm/tools/workspaceFile.js +27 -0
- package/dist/llm/webFetch.d.ts +13 -1
- package/dist/llm/webFetch.js +91 -7
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +1 -1
- package/dist/ui/components/TextInput.js +1 -99
- package/dist/ui/inputBuffer.d.ts +28 -0
- package/dist/ui/inputBuffer.js +99 -0
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/collections.js +9 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +40 -0
- package/package.json +1 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const PROVIDER_CHOICES = {
|
|
2
|
+
addProvider: 'add provider',
|
|
3
|
+
custom: 'custom',
|
|
4
|
+
};
|
|
5
|
+
export const PROVIDER_ACTIONS = {
|
|
6
|
+
useProvider: 'use provider',
|
|
7
|
+
addModels: 'add models',
|
|
8
|
+
setApiKey: 'set API key',
|
|
9
|
+
removeModels: 'remove models',
|
|
10
|
+
removeProvider: 'remove provider',
|
|
11
|
+
};
|
|
12
|
+
export const SERVER_CHOICES = {
|
|
13
|
+
addServer: 'add server',
|
|
14
|
+
custom: 'custom',
|
|
15
|
+
};
|
|
16
|
+
export const COMMON_ACTIONS = {
|
|
17
|
+
enable: 'enable',
|
|
18
|
+
disable: 'disable',
|
|
19
|
+
};
|
|
20
|
+
export const LSP_ACTIONS = {
|
|
21
|
+
removeServer: 'remove server',
|
|
22
|
+
};
|
|
23
|
+
export const MCP_ACTIONS = {
|
|
24
|
+
setApiKey: 'set API key',
|
|
25
|
+
removeServer: 'remove server',
|
|
26
|
+
};
|
|
27
|
+
export const MCP_TRANSPORTS = {
|
|
28
|
+
http: 'http',
|
|
29
|
+
sse: 'sse',
|
|
30
|
+
stdio: 'stdio',
|
|
31
|
+
};
|
|
32
|
+
export const SKILL_CHOICES = {
|
|
33
|
+
addSkill: 'add skill',
|
|
34
|
+
};
|
|
35
|
+
export const SKILL_ACTIONS = {
|
|
36
|
+
showInfo: 'show info',
|
|
37
|
+
validate: 'validate',
|
|
38
|
+
removeSkill: 'remove skill',
|
|
39
|
+
};
|
|
40
|
+
export const YES_CONFIRMATION = 'yes';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { YES_CONFIRMATION } from './wizardActions.js';
|
|
2
|
+
export function commaList(value) {
|
|
3
|
+
return value.split(',').map(item => item.trim()).filter(Boolean);
|
|
4
|
+
}
|
|
5
|
+
export function commandParts(value) {
|
|
6
|
+
return value.trim().split(/\s+/).filter(Boolean);
|
|
7
|
+
}
|
|
8
|
+
export function isYesConfirmation(value) {
|
|
9
|
+
return value.trim().toLowerCase() === YES_CONFIRMATION;
|
|
10
|
+
}
|
|
11
|
+
export function isValidUrl(value) {
|
|
12
|
+
try {
|
|
13
|
+
new URL(value);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HazeMcpServer, HazeSettings } from '../../config/settings.js';
|
|
2
|
+
export type NameCaptureResult = {
|
|
3
|
+
nextMode?: string;
|
|
4
|
+
draft?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
};
|
|
7
|
+
message?: string;
|
|
8
|
+
systemMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function captureProviderName(settings: HazeSettings, value: string): NameCaptureResult;
|
|
11
|
+
export declare function captureLspName(settings: HazeSettings, value: string): NameCaptureResult;
|
|
12
|
+
export declare function captureMcpName(settings: HazeSettings, value: string): NameCaptureResult;
|
|
13
|
+
export type FieldCaptureResult = {
|
|
14
|
+
draft?: Partial<HazeMcpServer>;
|
|
15
|
+
message?: string;
|
|
16
|
+
nextMode?: string;
|
|
17
|
+
systemMessage?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function captureProviderUrl(value: string): FieldCaptureResult;
|
|
20
|
+
export declare function captureMcpUrl(value: string): FieldCaptureResult;
|
|
21
|
+
export declare function captureMcpTransport(value: string): FieldCaptureResult;
|
|
22
|
+
export declare function captureMcpCommand(value: string): FieldCaptureResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { configuredLspServers } from '../../config/lspSettings.js';
|
|
2
|
+
import { findMcpServer } from '../../config/mcpSettings.js';
|
|
3
|
+
import { MCP_TRANSPORTS } from './wizardActions.js';
|
|
4
|
+
import { commandParts, isValidUrl } from './wizardInput.js';
|
|
5
|
+
export function captureProviderName(settings, value) {
|
|
6
|
+
const name = value.trim();
|
|
7
|
+
if (!name)
|
|
8
|
+
return { message: 'Provider name is required.' };
|
|
9
|
+
if (settings.providers?.some(provider => provider.name === name))
|
|
10
|
+
return { message: `Provider ${name} already exists. Choose a unique name.` };
|
|
11
|
+
return { nextMode: 'providerAddUrl', draft: { name }, systemMessage: 'OpenAI-compatible base URL? Example: https://openrouter.ai/api/v1 or http://localhost:1234/v1' };
|
|
12
|
+
}
|
|
13
|
+
export function captureLspName(settings, value) {
|
|
14
|
+
const name = value.trim();
|
|
15
|
+
if (!name)
|
|
16
|
+
return { message: 'LSP server name is required.' };
|
|
17
|
+
if (configuredLspServers(settings).some(server => server.name === name))
|
|
18
|
+
return { message: `LSP server ${name} already exists. Choose a unique name.` };
|
|
19
|
+
return { nextMode: 'lspAddCommand', draft: { name }, systemMessage: 'Command to run? Example: typescript-language-server --stdio' };
|
|
20
|
+
}
|
|
21
|
+
export function captureMcpName(settings, value) {
|
|
22
|
+
const name = value.trim();
|
|
23
|
+
if (!name)
|
|
24
|
+
return { message: 'MCP server name is required.' };
|
|
25
|
+
if (findMcpServer(settings, name))
|
|
26
|
+
return { message: `MCP server ${name} already exists. Choose a unique name.` };
|
|
27
|
+
return { nextMode: 'mcpAddTransport', draft: { name }, systemMessage: 'Transport type? http (Streamable HTTP), sse (Server-Sent Events), or stdio (local process).' };
|
|
28
|
+
}
|
|
29
|
+
export function captureProviderUrl(value) {
|
|
30
|
+
if (!isValidUrl(value))
|
|
31
|
+
return { message: 'Enter a valid URL, for example http://localhost:1234/v1.' };
|
|
32
|
+
return { draft: { url: value.trim() }, nextMode: 'providerAddKey', systemMessage: 'API key? Leave blank for local/keyless providers.' };
|
|
33
|
+
}
|
|
34
|
+
export function captureMcpUrl(value) {
|
|
35
|
+
if (!isValidUrl(value))
|
|
36
|
+
return { message: 'Enter a valid URL, for example https://mcp.context7.com/mcp.' };
|
|
37
|
+
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>.' };
|
|
38
|
+
}
|
|
39
|
+
export function captureMcpTransport(value) {
|
|
40
|
+
const transport = value.trim().toLowerCase();
|
|
41
|
+
if (transport !== MCP_TRANSPORTS.http && transport !== MCP_TRANSPORTS.sse && transport !== MCP_TRANSPORTS.stdio)
|
|
42
|
+
return { message: 'Enter http, sse, or stdio.' };
|
|
43
|
+
if (transport === MCP_TRANSPORTS.stdio)
|
|
44
|
+
return { draft: { transport }, nextMode: 'mcpAddCommand', systemMessage: 'Command to run? Example: npx -y @modelcontextprotocol/server-filesystem .' };
|
|
45
|
+
return { draft: { transport }, nextMode: 'mcpAddUrl', systemMessage: `MCP server URL? Example: https://mcp.context7.com/mcp for ${transport}.` };
|
|
46
|
+
}
|
|
47
|
+
export function captureMcpCommand(value) {
|
|
48
|
+
const parts = commandParts(value);
|
|
49
|
+
if (parts.length === 0)
|
|
50
|
+
return { message: 'Command is required.' };
|
|
51
|
+
return { draft: { command: parts[0], args: parts.slice(1) }, nextMode: 'mcpAddKey', systemMessage: 'Optional API key or auth header value? (Leave blank to skip — Enter works.) Sent as Authorization: Bearer <value>.' };
|
|
52
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
import type { LoadedSkill } from '../../skills/types.js';
|
|
3
|
+
import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pure suggestion builders for the chat wizard pickers (provider / model / LSP /
|
|
6
|
+
* MCP / skills). Extracted from the React component so they are unit-testable
|
|
7
|
+
* and so `ChatScreen` only owns interactive state, not picker content. Each
|
|
8
|
+
* function takes its explicit inputs and returns the suggestion list shown for
|
|
9
|
+
* the corresponding input mode.
|
|
10
|
+
*/
|
|
11
|
+
export declare function providerSuggestions(settings: HazeSettings): TextInputSuggestion[];
|
|
12
|
+
export declare function providerActionSuggestions(settings: HazeSettings, selectedProviderName: string | undefined): TextInputSuggestion[];
|
|
13
|
+
export declare function presetSuggestions(): TextInputSuggestion[];
|
|
14
|
+
export declare function modelSuggestions(settings: HazeSettings, modelProviderFilter: string | undefined): TextInputSuggestion[];
|
|
15
|
+
export declare function lspSuggestions(settings: HazeSettings): TextInputSuggestion[];
|
|
16
|
+
export declare function lspActionSuggestions(settings: HazeSettings, selectedLspName: string | undefined): TextInputSuggestion[];
|
|
17
|
+
export declare function lspPresetSuggestions(): TextInputSuggestion[];
|
|
18
|
+
export declare function mcpSuggestions(settings: HazeSettings): TextInputSuggestion[];
|
|
19
|
+
export declare function mcpActionSuggestions(settings: HazeSettings, selectedMcpName: string | undefined): TextInputSuggestion[];
|
|
20
|
+
export declare function mcpPresetSuggestions(): TextInputSuggestion[];
|
|
21
|
+
export declare function mcpTransportSuggestions(): TextInputSuggestion[];
|
|
22
|
+
export declare function skillsSuggestions(settings: HazeSettings, skills: LoadedSkill[]): TextInputSuggestion[];
|
|
23
|
+
export declare function skillsActionSuggestions(settings: HazeSettings, skills: LoadedSkill[], selectedSkillName: string | undefined): TextInputSuggestion[];
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { configuredProviders, findProvider, modelSelector } 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 { COMMON_ACTIONS, LSP_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, PROVIDER_ACTIONS, PROVIDER_CHOICES, SERVER_CHOICES, SKILL_ACTIONS, SKILL_CHOICES } from './wizardActions.js';
|
|
7
|
+
/**
|
|
8
|
+
* Pure suggestion builders for the chat wizard pickers (provider / model / LSP /
|
|
9
|
+
* MCP / skills). Extracted from the React component so they are unit-testable
|
|
10
|
+
* and so `ChatScreen` only owns interactive state, not picker content. Each
|
|
11
|
+
* function takes its explicit inputs and returns the suggestion list shown for
|
|
12
|
+
* the corresponding input mode.
|
|
13
|
+
*/
|
|
14
|
+
export function providerSuggestions(settings) {
|
|
15
|
+
return [
|
|
16
|
+
...configuredProviders(settings).map(provider => ({
|
|
17
|
+
value: provider.name,
|
|
18
|
+
description: `${provider.url} · ${provider.models.length} model${provider.models.length === 1 ? '' : 's'}`,
|
|
19
|
+
kind: 'provider',
|
|
20
|
+
})),
|
|
21
|
+
{ value: PROVIDER_CHOICES.addProvider, description: 'Add a new provider (presets available)', kind: 'provider' },
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
export function providerActionSuggestions(settings, selectedProviderName) {
|
|
25
|
+
const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
|
|
26
|
+
return [
|
|
27
|
+
{ value: PROVIDER_ACTIONS.useProvider, description: 'Set this provider and choose a model', kind: 'provider' },
|
|
28
|
+
{ value: PROVIDER_ACTIONS.addModels, description: 'Append comma-separated model names', kind: 'provider' },
|
|
29
|
+
{ value: PROVIDER_ACTIONS.setApiKey, description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' },
|
|
30
|
+
...(provider?.models?.length ? [{ value: PROVIDER_ACTIONS.removeModels, description: 'Remove models from this provider', kind: 'provider' }] : []),
|
|
31
|
+
{ value: PROVIDER_ACTIONS.removeProvider, description: 'Delete this provider from settings', kind: 'provider' },
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
export function presetSuggestions() {
|
|
35
|
+
const cloudPresets = PROVIDER_PRESETS.filter(p => p.category === 'cloud');
|
|
36
|
+
const localPresets = PROVIDER_PRESETS.filter(p => p.category === 'local');
|
|
37
|
+
return [
|
|
38
|
+
...cloudPresets.map(preset => ({
|
|
39
|
+
value: preset.id,
|
|
40
|
+
description: `${preset.baseUrl}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
|
|
41
|
+
kind: 'provider',
|
|
42
|
+
})),
|
|
43
|
+
...localPresets.map(preset => ({
|
|
44
|
+
value: preset.id,
|
|
45
|
+
description: `${preset.baseUrl} · local, no API key needed`,
|
|
46
|
+
kind: 'provider',
|
|
47
|
+
})),
|
|
48
|
+
{ value: PROVIDER_CHOICES.custom, description: 'Enter provider name, URL, and API key manually', kind: 'provider' },
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
export function modelSuggestions(settings, modelProviderFilter) {
|
|
52
|
+
const providers = configuredProviders(settings).filter(provider => !modelProviderFilter || provider.name === modelProviderFilter);
|
|
53
|
+
return providers.flatMap(provider => provider.models.map(model => ({
|
|
54
|
+
value: modelProviderFilter ? model : modelSelector(provider, model),
|
|
55
|
+
description: provider.name,
|
|
56
|
+
kind: 'model',
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
export function lspSuggestions(settings) {
|
|
60
|
+
const servers = configuredLspServers(settings);
|
|
61
|
+
return [{ value: SERVER_CHOICES.addServer, description: 'add an LSP server (presets available)', kind: 'lsp' },
|
|
62
|
+
...servers.map(server => ({
|
|
63
|
+
value: server.name,
|
|
64
|
+
description: `${server.command}${(server.args ?? []).length ? ` ${(server.args ?? []).join(' ')}` : ''} · ${server.enabled === false ? 'disabled' : 'enabled'}`,
|
|
65
|
+
kind: 'lsp',
|
|
66
|
+
}))];
|
|
67
|
+
}
|
|
68
|
+
export function lspActionSuggestions(settings, selectedLspName) {
|
|
69
|
+
const server = selectedLspName ? configuredLspServers(settings).find(s => s.name === selectedLspName) : undefined;
|
|
70
|
+
const result = [];
|
|
71
|
+
if (server)
|
|
72
|
+
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' });
|
|
73
|
+
result.push({ value: LSP_ACTIONS.removeServer, description: 'remove this server', kind: 'lsp' });
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
export function lspPresetSuggestions() {
|
|
77
|
+
return [
|
|
78
|
+
...Object.values(LSP_PRESETS).map(preset => ({
|
|
79
|
+
value: preset.name,
|
|
80
|
+
description: `${preset.command} ${(preset.args ?? []).join(' ')} [${(preset.extensions ?? []).join(', ')}]`,
|
|
81
|
+
kind: 'lsp',
|
|
82
|
+
})),
|
|
83
|
+
{ value: SERVER_CHOICES.custom, description: 'enter a name and command manually', kind: 'lsp' },
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
export function mcpSuggestions(settings) {
|
|
87
|
+
const servers = configuredMcpServers(settings);
|
|
88
|
+
return [{ value: SERVER_CHOICES.addServer, description: 'add an MCP server (presets available)', kind: 'mcp' },
|
|
89
|
+
...servers.map(server => {
|
|
90
|
+
const location = server.url ?? (server.command ? `${server.command} ${(server.args ?? []).join(' ')}`.trim() : '');
|
|
91
|
+
return { value: server.name, description: `${server.transport}${location ? ` ${location}` : ''} · ${server.enabled === false ? 'disabled' : 'enabled'}`, kind: 'mcp' };
|
|
92
|
+
})];
|
|
93
|
+
}
|
|
94
|
+
export function mcpActionSuggestions(settings, selectedMcpName) {
|
|
95
|
+
const server = selectedMcpName ? findMcpServer(settings, selectedMcpName) : undefined;
|
|
96
|
+
const result = [];
|
|
97
|
+
if (server) {
|
|
98
|
+
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' });
|
|
99
|
+
result.push({ value: MCP_ACTIONS.setApiKey, description: server.headers?.length ? 'update the saved API key' : 'add an API key', kind: 'mcp' });
|
|
100
|
+
}
|
|
101
|
+
result.push({ value: MCP_ACTIONS.removeServer, description: 'remove this server', kind: 'mcp' });
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
export function mcpPresetSuggestions() {
|
|
105
|
+
return [
|
|
106
|
+
...presetIds().map(presetId => {
|
|
107
|
+
const preset = findMcpPreset(presetId);
|
|
108
|
+
return { value: presetId, description: preset.description ?? `${preset.transport} server`, kind: 'mcp' };
|
|
109
|
+
}),
|
|
110
|
+
{ value: SERVER_CHOICES.custom, description: 'enter name, transport, and URL or command manually', kind: 'mcp' },
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
export function mcpTransportSuggestions() {
|
|
114
|
+
return [
|
|
115
|
+
{ value: MCP_TRANSPORTS.http, description: 'Streamable HTTP (remote)', kind: 'mcp' },
|
|
116
|
+
{ value: MCP_TRANSPORTS.sse, description: 'Server-Sent Events (remote)', kind: 'mcp' },
|
|
117
|
+
{ value: MCP_TRANSPORTS.stdio, description: 'local process', kind: 'mcp' },
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
export function skillsSuggestions(settings, skills) {
|
|
121
|
+
return [{ value: SKILL_CHOICES.addSkill, description: 'describe a new skill for Haze to generate', kind: 'skill' },
|
|
122
|
+
...skills.map(skill => ({
|
|
123
|
+
value: skill.name,
|
|
124
|
+
description: `${skill.description}${isSkillEnabled(settings, skill.name) ? '' : ' · disabled'}`,
|
|
125
|
+
kind: 'skill',
|
|
126
|
+
}))];
|
|
127
|
+
}
|
|
128
|
+
export function skillsActionSuggestions(settings, skills, selectedSkillName) {
|
|
129
|
+
const skill = selectedSkillName ? skills.find(candidate => candidate.name === selectedSkillName) : undefined;
|
|
130
|
+
const result = [];
|
|
131
|
+
if (skill) {
|
|
132
|
+
const enabled = isSkillEnabled(settings, skill.name);
|
|
133
|
+
result.push({ value: enabled ? COMMON_ACTIONS.disable : COMMON_ACTIONS.enable, description: `${enabled ? COMMON_ACTIONS.disable : COMMON_ACTIONS.enable} this skill`, kind: 'skill' });
|
|
134
|
+
result.push({ value: SKILL_ACTIONS.showInfo, description: 'show description, references, and path', kind: 'skill' });
|
|
135
|
+
result.push({ value: SKILL_ACTIONS.validate, description: 're-load and validate SKILL.md', kind: 'skill' });
|
|
136
|
+
}
|
|
137
|
+
result.push({ value: SKILL_ACTIONS.removeSkill, description: 'delete this skill directory', kind: 'skill' });
|
|
138
|
+
return result;
|
|
139
|
+
}
|
package/dist/cli/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
|
-
import { Command } from 'commander';
|
|
5
|
+
import { Command, Option } from 'commander';
|
|
6
6
|
import { chatCommand } from './commands/chat.js';
|
|
7
|
+
import { runHeadless } from './commands/runCommand.js';
|
|
7
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
9
10
|
const program = new Command();
|
|
@@ -11,14 +12,71 @@ program
|
|
|
11
12
|
.name('haze')
|
|
12
13
|
.description('A pragmatic, intentionally limited agentic CLI.')
|
|
13
14
|
.version(pkg.version)
|
|
14
|
-
.option('--debug', 'show
|
|
15
|
+
.option('--debug', 'show model/tool debug logs and write a detailed JSONL log to ~/.haze/logs/')
|
|
15
16
|
.option('-c, --continue', 'resume the latest saved session for this workspace')
|
|
16
|
-
.option('--no-session', 'run without saving or resuming a durable session')
|
|
17
|
+
.option('--no-session', 'run without saving or resuming a durable session')
|
|
18
|
+
.option('-p, --prompt <text>', 'print mode: run a single non-interactive turn and print the result (falls back to piped stdin)')
|
|
19
|
+
.option('-m, --model <selector>', 'override the model for this run only — a registered model name or provider:name')
|
|
20
|
+
.addOption(new Option('--output <format>', 'print-mode output: plain text, a single JSON result envelope, or a stream-json NDJSON event stream').choices(['text', 'json', 'stream-json']).default('text'));
|
|
21
|
+
program.addHelpText('after', `
|
|
22
|
+
Examples:
|
|
23
|
+
$ haze start the interactive chat
|
|
24
|
+
$ haze -p "explain src/cli/index.ts" print mode: run one turn and print the reply
|
|
25
|
+
$ echo "what does this repo do?" | haze read the prompt from piped stdin
|
|
26
|
+
$ haze -p "list the top 3 bugs" --output json emit a JSON envelope { type, status, result, usage }
|
|
27
|
+
$ haze -p "audit src/" --output stream-json stream NDJSON events live, then the final result envelope
|
|
28
|
+
$ haze -p "summarize" --model openai:gpt-4o-mini override the model for this run only
|
|
29
|
+
$ haze -p "audit auth.ts" --debug also write a detailed JSONL log to ~/.haze/logs/
|
|
30
|
+
|
|
31
|
+
Print mode (-p):
|
|
32
|
+
Runs a single agentic turn with the full toolset and guardrails, prints the final assistant
|
|
33
|
+
text, then exits (0 = complete; non-zero = aborted/failed, so CI can gate on the exit code).
|
|
34
|
+
The prompt comes from -p, otherwise from piped stdin. With --output json the reply is wrapped
|
|
35
|
+
in a single-line { type, status, result, usage } envelope. With --output stream-json haze streams
|
|
36
|
+
one NDJSON agent event per line (turn_start, message_*, tool_*, retry, turn_end) as the run
|
|
37
|
+
progresses, then prints that same { type:'result', ... } envelope as the final line — giving
|
|
38
|
+
harnesses live progress and stagnation detection. --model overrides the model for this
|
|
39
|
+
run only (no settings change) and must already be registered under a provider (add it once via
|
|
40
|
+
the /provider picker). Print-mode runs are non-durable: --continue is ignored and no session is
|
|
41
|
+
saved, and there is no automatic context-overflow recovery.
|
|
42
|
+
`);
|
|
43
|
+
async function readStdinPrompt() {
|
|
44
|
+
// Only read stdin when it is piped (non-TTY); never hang waiting on an interactive terminal.
|
|
45
|
+
if (process.stdin.isTTY === false) {
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
let data = '';
|
|
48
|
+
process.stdin.setEncoding('utf8');
|
|
49
|
+
process.stdin.on('data', (chunk) => {
|
|
50
|
+
data += chunk;
|
|
51
|
+
});
|
|
52
|
+
process.stdin.on('end', () => resolve(data.trim() ? data : undefined));
|
|
53
|
+
process.stdin.on('error', () => resolve(undefined));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
17
58
|
program.action(async () => {
|
|
18
59
|
const opts = program.opts();
|
|
60
|
+
// -p takes precedence; otherwise fall back to piped stdin. An empty stdin yields no prompt.
|
|
61
|
+
const prompt = opts.prompt?.trim() ? opts.prompt : await readStdinPrompt();
|
|
62
|
+
if (prompt) {
|
|
63
|
+
// One-shot runs are always fresh and non-durable; --continue is ignored in this mode.
|
|
64
|
+
const code = await runHeadless({
|
|
65
|
+
prompt,
|
|
66
|
+
modelOverride: opts.model,
|
|
67
|
+
// commander validates --output against the choices above, so opts.output is one of
|
|
68
|
+
// 'text' | 'json' | 'stream-json'; default to text for piped/stdin runs without the flag.
|
|
69
|
+
output: opts.output === 'json' || opts.output === 'stream-json' ? opts.output : 'text',
|
|
70
|
+
debug: Boolean(opts.debug),
|
|
71
|
+
});
|
|
72
|
+
// Set the exit code and return instead of process.exit(code): the latter does not wait
|
|
73
|
+
// for stdout to drain and can truncate piped/redirected output (e.g. `haze -p ... | jq`).
|
|
74
|
+
process.exitCode = code;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
19
77
|
await chatCommand({ debug: Boolean(opts.debug), continueSession: Boolean(opts.continue), noSession: opts.session === false, version: pkg.version });
|
|
20
78
|
});
|
|
21
|
-
program.parseAsync().catch(error => {
|
|
79
|
+
program.parseAsync().catch((error) => {
|
|
22
80
|
console.error(error instanceof Error ? error.message : error);
|
|
23
81
|
process.exit(1);
|
|
24
82
|
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export interface ContextFile {
|
|
2
2
|
path: string;
|
|
3
3
|
content: string;
|
|
4
|
+
signature?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ReadContextFileOptions {
|
|
7
|
+
onContextFileRead?: (path: string) => void;
|
|
8
|
+
alreadyLoadedSignatures?: ReadonlyMap<string, string>;
|
|
4
9
|
}
|
|
5
10
|
export interface ContextFileDiagnostic {
|
|
6
11
|
path: string;
|
|
@@ -24,10 +29,12 @@ export interface ContextFileDiagnosticsSummary {
|
|
|
24
29
|
}
|
|
25
30
|
/** Maximum characters of a context file included in every request's system context. */
|
|
26
31
|
export declare const MAX_CONTEXT_FILE_CHARS = 20000;
|
|
27
|
-
export declare function readContextFiles(cwd?: string): Promise<ContextFile[]>;
|
|
32
|
+
export declare function readContextFiles(cwd?: string, options?: ReadContextFileOptions): Promise<ContextFile[]>;
|
|
28
33
|
export declare function readScopedContextFilesForPath(targetPath: string, options?: {
|
|
29
34
|
cwd?: string;
|
|
30
35
|
alreadyLoadedPaths?: Iterable<string>;
|
|
36
|
+
alreadyLoadedSignatures?: ReadonlyMap<string, string>;
|
|
37
|
+
onContextFileRead?: (path: string) => void;
|
|
31
38
|
}): Promise<ContextFile[]>;
|
|
32
39
|
export declare function contextFileDiagnostics(files: ContextFile[]): ContextFileDiagnostic[];
|
|
33
40
|
export declare function summarizeContextDiagnostics(files: ContextFile[], options?: {
|
|
@@ -10,6 +10,9 @@ function resolveBudgetThreshold(explicit) {
|
|
|
10
10
|
return DEFAULT_BUDGET_THRESHOLD;
|
|
11
11
|
}
|
|
12
12
|
const CONTEXT_FILE_NAMES = ['CLAUDE.md', 'AGENTS.md'];
|
|
13
|
+
function contextFileSignature(stat) {
|
|
14
|
+
return `${stat.size}:${stat.mtimeMs}`;
|
|
15
|
+
}
|
|
13
16
|
/** Maximum characters of a context file included in every request's system context. */
|
|
14
17
|
export const MAX_CONTEXT_FILE_CHARS = 20_000;
|
|
15
18
|
function uniqueExistingAncestors(fromDir) {
|
|
@@ -33,7 +36,7 @@ function displayPath(filePath) {
|
|
|
33
36
|
return `~/${path.relative(home, filePath)}`;
|
|
34
37
|
return filePath;
|
|
35
38
|
}
|
|
36
|
-
async function readContextCandidates(candidates, seen = new Set()) {
|
|
39
|
+
async function readContextCandidates(candidates, seen = new Set(), options = {}) {
|
|
37
40
|
const contextFiles = [];
|
|
38
41
|
for (const candidate of candidates) {
|
|
39
42
|
const absolute = path.resolve(candidate);
|
|
@@ -45,13 +48,21 @@ async function readContextCandidates(candidates, seen = new Set()) {
|
|
|
45
48
|
const stat = await fs.stat(absolute).catch(() => null);
|
|
46
49
|
if (!stat?.isFile())
|
|
47
50
|
continue;
|
|
51
|
+
const displayedPath = displayPath(absolute);
|
|
52
|
+
const signature = contextFileSignature(stat);
|
|
53
|
+
const loadedSignature = options.alreadyLoadedSignatures?.get(displayedPath) ?? options.alreadyLoadedSignatures?.get(absolute);
|
|
54
|
+
if (loadedSignature === signature)
|
|
55
|
+
continue;
|
|
56
|
+
options.onContextFileRead?.(displayedPath);
|
|
48
57
|
const content = await fs.readFile(absolute, 'utf8');
|
|
49
|
-
|
|
50
|
-
path:
|
|
58
|
+
const file = {
|
|
59
|
+
path: displayedPath,
|
|
51
60
|
content: content.length > MAX_CONTEXT_FILE_CHARS
|
|
52
61
|
? `${content.slice(0, MAX_CONTEXT_FILE_CHARS)}\n\n[Context file truncated: ${content.length - MAX_CONTEXT_FILE_CHARS} characters omitted]`
|
|
53
62
|
: content,
|
|
54
|
-
|
|
63
|
+
signature,
|
|
64
|
+
};
|
|
65
|
+
contextFiles.push(file);
|
|
55
66
|
}
|
|
56
67
|
return contextFiles;
|
|
57
68
|
}
|
|
@@ -70,7 +81,7 @@ async function scopedDirsForPath(targetPath, cwd) {
|
|
|
70
81
|
}
|
|
71
82
|
return dirs.reverse();
|
|
72
83
|
}
|
|
73
|
-
export async function readContextFiles(cwd = process.cwd()) {
|
|
84
|
+
export async function readContextFiles(cwd = process.cwd(), options = {}) {
|
|
74
85
|
const candidates = [
|
|
75
86
|
path.join(os.homedir(), '.claude', 'CLAUDE.md'),
|
|
76
87
|
path.join(HAZE_DIR, 'AGENTS.md'),
|
|
@@ -79,7 +90,7 @@ export async function readContextFiles(cwd = process.cwd()) {
|
|
|
79
90
|
for (const name of CONTEXT_FILE_NAMES)
|
|
80
91
|
candidates.push(path.join(dir, name));
|
|
81
92
|
}
|
|
82
|
-
return await readContextCandidates(candidates);
|
|
93
|
+
return await readContextCandidates(candidates, undefined, options);
|
|
83
94
|
}
|
|
84
95
|
export async function readScopedContextFilesForPath(targetPath, options = {}) {
|
|
85
96
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -90,13 +101,15 @@ export async function readScopedContextFilesForPath(targetPath, options = {}) {
|
|
|
90
101
|
candidates.push(path.join(dir, name));
|
|
91
102
|
}
|
|
92
103
|
const alreadySeen = new Set();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
if (!options.alreadyLoadedSignatures) {
|
|
105
|
+
for (const loadedPath of loaded) {
|
|
106
|
+
if (loadedPath.startsWith('~/'))
|
|
107
|
+
alreadySeen.add(path.resolve(os.homedir(), loadedPath.slice(2)));
|
|
108
|
+
else
|
|
109
|
+
alreadySeen.add(path.resolve(cwd, loadedPath));
|
|
110
|
+
}
|
|
98
111
|
}
|
|
99
|
-
return await readContextCandidates(candidates, alreadySeen);
|
|
112
|
+
return await readContextCandidates(candidates, alreadySeen, options);
|
|
100
113
|
}
|
|
101
114
|
export function contextFileDiagnostics(files) {
|
|
102
115
|
return files.map(file => ({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { removeByName, upsertByName } from '../utils/collections.js';
|
|
3
4
|
export const LSP_PRESETS = {
|
|
4
5
|
typescript: {
|
|
5
6
|
name: 'typescript',
|
|
@@ -57,14 +58,10 @@ export function upsertLspServer(settings, server) {
|
|
|
57
58
|
rootPatterns: server.rootPatterns ?? [],
|
|
58
59
|
enabled: server.enabled !== false,
|
|
59
60
|
};
|
|
60
|
-
|
|
61
|
-
const index = servers.findIndex(existing => existing.name === normalized.name);
|
|
62
|
-
if (index === -1)
|
|
63
|
-
return [...servers, normalized];
|
|
64
|
-
return servers.map(existing => existing.name === normalized.name ? normalized : existing);
|
|
61
|
+
return upsertByName(configuredLspServers(settings), normalized);
|
|
65
62
|
}
|
|
66
63
|
export function removeLspServer(settings, name) {
|
|
67
|
-
return configuredLspServers(settings)
|
|
64
|
+
return removeByName(configuredLspServers(settings), name);
|
|
68
65
|
}
|
|
69
66
|
export function setLspServerEnabled(settings, name, enabled) {
|
|
70
67
|
return configuredLspServers(settings).map(server => server.name === name ? { ...server, enabled } : server);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findByName, removeByName, upsertByName } from '../utils/collections.js';
|
|
1
2
|
const TRANSPORTS = ['http', 'sse', 'stdio'];
|
|
2
3
|
/**
|
|
3
4
|
* Presets for well-known MCP servers. Keys are stable preset identifiers users
|
|
@@ -82,18 +83,17 @@ export function configuredMcpServers(settings) {
|
|
|
82
83
|
.filter((server) => Boolean(server));
|
|
83
84
|
}
|
|
84
85
|
export function findMcpServer(settings, name) {
|
|
85
|
-
return configuredMcpServers(settings)
|
|
86
|
+
return findByName(configuredMcpServers(settings), name);
|
|
86
87
|
}
|
|
87
88
|
export function upsertMcpServer(settings, server) {
|
|
88
|
-
|
|
89
|
-
return [...servers, server];
|
|
89
|
+
return upsertByName(configuredMcpServers(settings), server);
|
|
90
90
|
}
|
|
91
91
|
export function removeMcpServer(settings, name) {
|
|
92
|
-
return configuredMcpServers(settings)
|
|
92
|
+
return removeByName(configuredMcpServers(settings), name);
|
|
93
93
|
}
|
|
94
94
|
export function toggleMcpServer(settings, name, enabled) {
|
|
95
95
|
const servers = configuredMcpServers(settings);
|
|
96
|
-
const target = servers
|
|
96
|
+
const target = findByName(servers, name);
|
|
97
97
|
if (!target)
|
|
98
98
|
return undefined;
|
|
99
99
|
return upsertMcpServer(settings, { ...target, enabled });
|
package/dist/config/providers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findByName, upsertByName } from '../utils/collections.js';
|
|
1
2
|
// Used only to migrate legacy single-provider OpenRouter settings (apiKey/baseURL)
|
|
2
3
|
// into the providers array. There is no default provider or model anymore: users
|
|
3
4
|
// must configure a provider themselves via /provider.
|
|
@@ -43,7 +44,7 @@ export function configuredProviders(settings) {
|
|
|
43
44
|
return providers;
|
|
44
45
|
}
|
|
45
46
|
export function findProvider(settings, name) {
|
|
46
|
-
return configuredProviders(settings)
|
|
47
|
+
return findByName(configuredProviders(settings), name);
|
|
47
48
|
}
|
|
48
49
|
export function activeProvider(settings) {
|
|
49
50
|
const providers = configuredProviders(settings);
|
|
@@ -55,7 +56,7 @@ export function activeModel(settings) {
|
|
|
55
56
|
return undefined;
|
|
56
57
|
const model = settings.model && provider.models.includes(settings.model)
|
|
57
58
|
? settings.model
|
|
58
|
-
:
|
|
59
|
+
: provider.models[0];
|
|
59
60
|
if (!model)
|
|
60
61
|
return undefined;
|
|
61
62
|
return { provider, model };
|
|
@@ -84,8 +85,7 @@ export function modelSelector(provider, model) {
|
|
|
84
85
|
return `${provider.name}:${model}`;
|
|
85
86
|
}
|
|
86
87
|
export function upsertProvider(settings, provider) {
|
|
87
|
-
|
|
88
|
-
return [...providers, provider];
|
|
88
|
+
return upsertByName(configuredProviders(settings), provider);
|
|
89
89
|
}
|
|
90
90
|
export function providerHasKey(settings, provider) {
|
|
91
91
|
return Boolean(provider.key ?? (provider.name === 'openrouter' ? settings.apiKey : undefined));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findByName, removeByName } from '../utils/collections.js';
|
|
1
2
|
/**
|
|
2
3
|
* Normalized skill metadata overrides. The list is override-only: only skills that
|
|
3
4
|
* deviate from the default (enabled) appear here, so it never desyncs from disk.
|
|
@@ -14,7 +15,7 @@ export function configuredSkillSettings(settings) {
|
|
|
14
15
|
}
|
|
15
16
|
/** A skill is enabled unless an explicit override disables it. */
|
|
16
17
|
export function isSkillEnabled(settings, name) {
|
|
17
|
-
const entry = configuredSkillSettings(settings)
|
|
18
|
+
const entry = findByName(configuredSkillSettings(settings), name);
|
|
18
19
|
return entry ? entry.enabled !== false : true;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
@@ -22,10 +23,10 @@ export function isSkillEnabled(settings, name) {
|
|
|
22
23
|
* `enabled: false`. Returns the next `skills` array for updateSettings.
|
|
23
24
|
*/
|
|
24
25
|
export function setSkillEnabled(settings, name, enabled) {
|
|
25
|
-
const others = configuredSkillSettings(settings)
|
|
26
|
+
const others = removeByName(configuredSkillSettings(settings), name);
|
|
26
27
|
return enabled ? others : [...others, { name, enabled: false }];
|
|
27
28
|
}
|
|
28
29
|
/** Drop a skill's override entry. Called when a skill directory is removed. */
|
|
29
30
|
export function removeSkillSetting(settings, name) {
|
|
30
|
-
return configuredSkillSettings(settings)
|
|
31
|
+
return removeByName(configuredSkillSettings(settings), name);
|
|
31
32
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_MAX_OUTPUT_TOKENS = 16384;
|
|
2
|
+
export declare const IDLE_TIMEOUT_MS: number;
|
|
3
|
+
export declare const MAIN_STEP_LIMIT = 64;
|
|
4
|
+
export declare const MAIN_TOOL_CALL_LIMIT = 120;
|
|
5
|
+
export declare const MAIN_TOOL_ONLY_STEP_LIMIT = 24;
|
|
6
|
+
export declare const ACTIVE_CONTEXT_TOKEN_BUDGET = 40000;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const DEFAULT_MAX_OUTPUT_TOKENS = 16384;
|
|
2
|
+
export const IDLE_TIMEOUT_MS = 5 * 60_000;
|
|
3
|
+
export const MAIN_STEP_LIMIT = 64;
|
|
4
|
+
export const MAIN_TOOL_CALL_LIMIT = 120;
|
|
5
|
+
export const MAIN_TOOL_ONLY_STEP_LIMIT = 24;
|
|
6
|
+
export const ACTIVE_CONTEXT_TOKEN_BUDGET = 40_000;
|
|
@@ -34,7 +34,7 @@ export function compactModelMessages(messages, options = {}) {
|
|
|
34
34
|
const recent = messages.slice(recentStart);
|
|
35
35
|
const oldText = older.map(message => {
|
|
36
36
|
const text = modelMessageText(message).replace(/\s+/g, ' ').trim();
|
|
37
|
-
return text ? `- ${message.role}: ${text
|
|
37
|
+
return text ? `- ${message.role}: ${text}` : '';
|
|
38
38
|
}).filter(Boolean).join('\n');
|
|
39
39
|
const summary = [
|
|
40
40
|
'Compacted prior Haze conversation. Treat this as continuity context, not a new user request.',
|