@denizokcu/haze 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.md +57 -17
  2. package/README.md +119 -64
  3. package/dist/cli/chat/chatMetrics.d.ts +17 -1
  4. package/dist/cli/chat/chatMetrics.js +22 -5
  5. package/dist/cli/chat/contextReport.d.ts +11 -0
  6. package/dist/cli/chat/contextReport.js +44 -0
  7. package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
  8. package/dist/cli/chat/fileMentionSuggestions.js +91 -0
  9. package/dist/cli/chat/inputSuggestions.d.ts +5 -0
  10. package/dist/cli/chat/inputSuggestions.js +17 -3
  11. package/dist/cli/chat/sessionLifecycle.d.ts +58 -0
  12. package/dist/cli/chat/sessionLifecycle.js +155 -0
  13. package/dist/cli/chat/sessionRecorder.js +7 -9
  14. package/dist/cli/chat/startupInfo.d.ts +1 -0
  15. package/dist/cli/chat/startupInfo.js +11 -0
  16. package/dist/cli/chat/tips.d.ts +21 -0
  17. package/dist/cli/chat/tips.js +43 -0
  18. package/dist/cli/chat/wizardDispatch.d.ts +64 -0
  19. package/dist/cli/chat/wizardDispatch.js +645 -0
  20. package/dist/cli/commands/chat.d.ts +1 -0
  21. package/dist/cli/commands/chat.js +181 -700
  22. package/dist/cli/commands/chatModes.d.ts +1 -1
  23. package/dist/cli/commands/chatModes.js +7 -2
  24. package/dist/cli/commands/commandHelp.js +5 -3
  25. package/dist/cli/commands/commands.d.ts +3 -2
  26. package/dist/cli/commands/commands.js +12 -13
  27. package/dist/cli/commands/fleetCommand.d.ts +14 -0
  28. package/dist/cli/commands/fleetCommand.js +46 -0
  29. package/dist/cli/commands/formatters.d.ts +5 -0
  30. package/dist/cli/commands/formatters.js +33 -6
  31. package/dist/cli/commands/logsCommand.js +1 -7
  32. package/dist/cli/commands/modelCommand.js +1 -1
  33. package/dist/cli/commands/providerWizard.d.ts +1 -0
  34. package/dist/cli/commands/providerWizard.js +13 -0
  35. package/dist/cli/commands/runCommand.d.ts +1 -0
  36. package/dist/cli/commands/runCommand.js +25 -5
  37. package/dist/cli/commands/sessionPicker.d.ts +9 -0
  38. package/dist/cli/commands/sessionPicker.js +29 -0
  39. package/dist/cli/commands/settingsSummary.js +6 -4
  40. package/dist/cli/commands/skillConfirmRemove.js +4 -3
  41. package/dist/cli/commands/skillWizard.d.ts +2 -0
  42. package/dist/cli/commands/skillWizard.js +16 -6
  43. package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
  44. package/dist/cli/commands/streaming/idleTimer.js +24 -0
  45. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -0
  46. package/dist/cli/commands/streaming/toolGroupRenderer.js +4 -2
  47. package/dist/cli/commands/streaming/turnRuntime.js +6 -4
  48. package/dist/cli/commands/streaming.d.ts +13 -1
  49. package/dist/cli/commands/streaming.js +42 -19
  50. package/dist/cli/commands/wizardActions.d.ts +6 -0
  51. package/dist/cli/commands/wizardActions.js +6 -0
  52. package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
  53. package/dist/cli/commands/wizardSuggestions.js +60 -12
  54. package/dist/cli/commands/wizardTransition.d.ts +4 -0
  55. package/dist/cli/commands/wizardTransition.js +1 -2
  56. package/dist/cli/index.js +17 -3
  57. package/dist/cli/terminalTitle.d.ts +6 -0
  58. package/dist/cli/terminalTitle.js +36 -0
  59. package/dist/config/inputHistory.d.ts +3 -3
  60. package/dist/config/inputHistory.js +12 -18
  61. package/dist/config/modelDiscovery.d.ts +20 -0
  62. package/dist/config/modelDiscovery.js +51 -0
  63. package/dist/config/providerPresets.d.ts +16 -4
  64. package/dist/config/providerPresets.js +263 -34
  65. package/dist/config/providers.d.ts +2 -0
  66. package/dist/config/providers.js +7 -0
  67. package/dist/config/settings.d.ts +22 -0
  68. package/dist/config/settings.js +29 -1
  69. package/dist/config/skillSettings.d.ts +6 -13
  70. package/dist/config/skillSettings.js +20 -19
  71. package/dist/core/agent/budgets.d.ts +26 -0
  72. package/dist/core/agent/budgets.js +34 -0
  73. package/dist/core/agent/compaction.js +17 -3
  74. package/dist/core/agent/contextBudget.d.ts +8 -0
  75. package/dist/core/agent/contextBudget.js +29 -0
  76. package/dist/core/agent/errors.js +6 -2
  77. package/dist/core/agent/events.d.ts +12 -0
  78. package/dist/core/agent/toolOutputStore.d.ts +5 -0
  79. package/dist/core/agent/toolOutputStore.js +18 -1
  80. package/dist/core/agent/workState.d.ts +1 -1
  81. package/dist/core/agent/workState.js +0 -4
  82. package/dist/core/attachments/imageAttachments.d.ts +90 -0
  83. package/dist/core/attachments/imageAttachments.js +245 -0
  84. package/dist/core/attachments/readBlessings.d.ts +37 -0
  85. package/dist/core/attachments/readBlessings.js +79 -0
  86. package/dist/core/goal/requestClassifier.d.ts +0 -3
  87. package/dist/core/goal/requestClassifier.js +0 -13
  88. package/dist/core/io/boundedRead.js +76 -29
  89. package/dist/core/limits/byteBudgets.d.ts +5 -0
  90. package/dist/core/limits/byteBudgets.js +5 -0
  91. package/dist/core/limits/textBudgets.d.ts +23 -0
  92. package/dist/core/limits/textBudgets.js +23 -0
  93. package/dist/core/process/backgroundRegistry.d.ts +35 -0
  94. package/dist/core/process/backgroundRegistry.js +194 -0
  95. package/dist/core/process/runBoundedProcess.d.ts +3 -0
  96. package/dist/core/process/runBoundedProcess.js +65 -29
  97. package/dist/core/safety/urlGuard.d.ts +2 -1
  98. package/dist/core/safety/urlGuard.js +3 -2
  99. package/dist/core/session/sessionSlimming.js +47 -4
  100. package/dist/core/session/sessionStore.d.ts +37 -0
  101. package/dist/core/session/sessionStore.js +95 -9
  102. package/dist/core/subagent/contracts.d.ts +116 -0
  103. package/dist/core/subagent/contracts.js +54 -0
  104. package/dist/core/subagent/executionProfiles.d.ts +28 -0
  105. package/dist/core/subagent/executionProfiles.js +45 -0
  106. package/dist/core/subagent/subagentCoordinator.d.ts +74 -0
  107. package/dist/core/subagent/subagentCoordinator.js +134 -0
  108. package/dist/core/subagent/subagentRunner.d.ts +211 -145
  109. package/dist/core/subagent/subagentRunner.js +228 -98
  110. package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
  111. package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
  112. package/dist/core/tasks/taskStorage.js +12 -1
  113. package/dist/llm/client.d.ts +20 -29
  114. package/dist/llm/client.js +29 -28
  115. package/dist/llm/hazeTools.d.ts +2013 -78
  116. package/dist/llm/hazeTools.js +16 -7
  117. package/dist/llm/lsp.d.ts +2 -0
  118. package/dist/llm/lsp.js +18 -3
  119. package/dist/llm/requestContext.d.ts +22 -1
  120. package/dist/llm/requestContext.js +45 -5
  121. package/dist/llm/systemPrompt.d.ts +4 -1
  122. package/dist/llm/systemPrompt.js +14 -4
  123. package/dist/llm/toolResultTypes.d.ts +1 -1
  124. package/dist/llm/tools/bashTool.d.ts +874 -32
  125. package/dist/llm/tools/bashTool.js +25 -4
  126. package/dist/llm/tools/fetchTool.d.ts +26 -26
  127. package/dist/llm/tools/fetchTool.js +1 -1
  128. package/dist/llm/tools/fileToolShared.d.ts +2 -1
  129. package/dist/llm/tools/fileToolShared.js +5 -5
  130. package/dist/llm/tools/grepRunner.d.ts +5 -0
  131. package/dist/llm/tools/grepRunner.js +52 -71
  132. package/dist/llm/tools/outputCap.d.ts +2 -6
  133. package/dist/llm/tools/outputCap.js +2 -6
  134. package/dist/llm/tools/processTool.d.ts +1077 -0
  135. package/dist/llm/tools/processTool.js +41 -0
  136. package/dist/llm/tools/toolContext.d.ts +8 -0
  137. package/dist/llm/tools/toolContext.js +22 -11
  138. package/dist/llm/tools/workspaceFile.d.ts +9 -1
  139. package/dist/llm/tools/workspaceFile.js +33 -4
  140. package/dist/llm/webFetch.js +24 -11
  141. package/dist/llm/workerContext.d.ts +18 -0
  142. package/dist/llm/workerContext.js +55 -0
  143. package/dist/skills/SkillLoader.d.ts +2 -2
  144. package/dist/skills/SkillRegistry.d.ts +3 -2
  145. package/dist/skills/SkillRegistry.js +43 -13
  146. package/dist/skills/builder/SkillBuilder.d.ts +3 -0
  147. package/dist/skills/builder/SkillBuilder.js +23 -5
  148. package/dist/skills/skillTools.js +11 -4
  149. package/dist/skills/types.d.ts +6 -1
  150. package/dist/ui/components/TextInput.d.ts +5 -2
  151. package/dist/ui/components/TextInput.js +76 -8
  152. package/dist/utils/format.d.ts +2 -0
  153. package/dist/utils/format.js +8 -0
  154. package/dist/utils/fs.d.ts +0 -1
  155. package/dist/utils/fs.js +0 -4
  156. package/dist/utils/openPath.d.ts +2 -0
  157. package/dist/utils/openPath.js +9 -0
  158. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- export type Mode = 'chat' | 'provider' | 'providerAction' | 'model' | 'providerAddPreset' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels' | 'providerSetKey' | 'providerRemoveModels' | 'providerConfirmRemove' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsAddDescription' | 'skillsConfirmRemove' | 'lsp' | 'lspAction' | 'lspAddPreset' | 'lspAddName' | 'lspAddCommand' | 'lspConfirmRemove' | 'mcp' | 'mcpAction' | 'mcpAddPreset' | 'mcpAddName' | 'mcpAddTransport' | 'mcpAddUrl' | 'mcpAddCommand' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
1
+ export type Mode = 'chat' | 'sessions' | 'sessionAction' | 'provider' | 'providerAction' | 'model' | 'modelAddProvider' | 'modelPick' | 'providerAddPreset' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels' | 'providerSetKey' | 'providerRemoveModels' | 'providerConfirmRemove' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsAddScope' | 'skillsAddDescription' | 'skillsConfirmRemove' | 'lsp' | 'lspAction' | 'lspAddPreset' | 'lspAddName' | 'lspAddCommand' | 'lspConfirmRemove' | 'mcp' | 'mcpAction' | 'mcpAddPreset' | 'mcpAddName' | 'mcpAddTransport' | 'mcpAddUrl' | 'mcpAddCommand' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
2
2
  /** Modes that show an always-on suggestion picker (server/preset lists). */
3
3
  export declare const PICKER_MODES: ReadonlySet<Mode>;
4
4
  /** Modes that mask input (secrets/API keys). */
@@ -1,14 +1,18 @@
1
1
  /** Modes that show an always-on suggestion picker (server/preset lists). */
2
- export const PICKER_MODES = new Set(['provider', 'providerAction', 'providerAddPreset', 'model', 'skills', 'skillsAction', 'lsp', 'lspAction', 'lspAddPreset', 'mcp', 'mcpAction', 'mcpAddPreset', 'mcpAddTransport']);
2
+ export const PICKER_MODES = new Set(['sessions', 'sessionAction', 'provider', 'providerAction', 'providerAddPreset', 'model', 'modelAddProvider', 'modelPick', 'skills', 'skillsAction', 'skillsAddScope', 'lsp', 'lspAction', 'lspAddPreset', 'mcp', 'mcpAction', 'mcpAddPreset', 'mcpAddTransport']);
3
3
  /** Modes that mask input (secrets/API keys). */
4
4
  export const MASKED_MODES = new Set(['providerAddKey', 'providerSetKey', 'mcpAddKey', 'mcpSetKey']);
5
5
  /** Modes where submitting an empty value is valid (optional steps). */
6
6
  export const SUBMIT_EMPTY_MODES = new Set(['providerAddKey', 'mcpAddKey']);
7
7
  const PLACEHOLDERS = {
8
+ sessions: 'Choose a saved session',
9
+ sessionAction: 'Resume or fork this session',
8
10
  provider: 'Choose provider',
9
11
  providerAction: 'Choose provider action',
10
12
  providerAddPreset: 'Choose a provider preset or custom',
11
- model: 'Choose model',
13
+ model: 'Choose model, or add model',
14
+ modelAddProvider: 'Choose a provider to add models to',
15
+ modelPick: 'Choose a model to add',
12
16
  providerAddName: 'Provider name',
13
17
  providerAddUrl: 'https://example.com/v1',
14
18
  providerAddKey: 'API key, or blank for local',
@@ -20,6 +24,7 @@ const PLACEHOLDERS = {
20
24
  skills: 'Choose a skill or add skill',
21
25
  skillsAction: 'show info, enable, disable, validate, or remove',
22
26
  skillsAddName: 'Skill name (kebab-case, e.g. security-review)',
27
+ skillsAddScope: 'Choose this project or global',
23
28
  skillsAddDescription: 'Describe what the skill should do',
24
29
  skillsConfirmRemove: 'Type "yes" to confirm',
25
30
  lsp: 'Choose LSP server or add server',
@@ -1,15 +1,17 @@
1
1
  export const COMMAND_HELP_ENTRIES = [
2
2
  { usage: '/help', description: 'Show all available slash commands and what they do.' },
3
- { usage: '/provider', description: 'Choose a provider, then use it, add/remove models, set API key, or remove it.' },
4
- { usage: '/model', description: 'Choose a model from all configured providers.' },
3
+ { usage: '/provider', description: 'Choose a provider, then use it, add/remove models, set API key, toggle image input, or remove it.' },
4
+ { usage: '/model', description: 'Choose a model, or add models from a provider\'s models endpoint.' },
5
5
  { usage: '/model <name-or-provider:name>', description: 'Set a model directly. Selecting a model also sets its provider.' },
6
6
  { usage: '/settings', description: 'Show the configured provider, model, API key status, LSP/MCP servers, skills, and loaded context files.' },
7
7
  { usage: '/settings open', description: 'Open ~/.haze/settings.json with the OS default app.' },
8
8
  { usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
9
+ { usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
10
+ { usage: '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>', description: 'Run genuinely independent tasks through disposable contexts. Runtime enforces profile concurrency, deadlines, and mutation serialization; control guidance is not persisted. Declines non-parallel work.' },
9
11
  { usage: '/init', description: 'Inspect the current workspace and create or update AGENTS.md project instructions.' },
10
12
  { usage: '/context', description: 'Show a token breakdown of the current request: system prompt, project context, tools (incl. MCP), and chat messages.' },
11
13
  { usage: '/session', description: 'Show the current durable session file.' },
12
- { usage: '/resume', description: 'Resume the latest saved session for this workspace.' },
14
+ { usage: '/resume [id]', description: 'Browse this workspace’s saved sessions, or resume an exact session id.' },
13
15
  { usage: '/new', description: 'Start a fresh durable session.' },
14
16
  { usage: '/logs', description: 'List recent log files with sizes and dates.' },
15
17
  { usage: '/lsp', description: 'Configure Language Server Protocol navigation tools (interactive picker).' },
@@ -1,6 +1,7 @@
1
1
  import type { ContextFile } from '../../config/contextFiles.js';
2
2
  import { type HazeSettings } from '../../config/settings.js';
3
3
  import type { Mode } from './chatModes.js';
4
+ import type { TurnExecutionOptions } from './streaming.js';
4
5
  export type CommandContext = {
5
6
  settings: HazeSettings;
6
7
  contextFiles: ContextFile[];
@@ -9,10 +10,10 @@ export type CommandContext = {
9
10
  addSystemMessage: (text: string) => void;
10
11
  clearConversation: () => void | Promise<void>;
11
12
  newSession?: () => Promise<void>;
12
- resumeSession?: () => Promise<void>;
13
+ resumeSession?: (id?: string) => Promise<void>;
13
14
  sessionInfo?: () => string;
14
15
  compactConversation?: (instructions?: string) => boolean;
15
- runAgentTurn: (prompt: string, displayValue?: string) => Promise<void>;
16
+ runAgentTurn: (prompt: string, displayValue?: string, options?: TurnExecutionOptions) => Promise<void>;
16
17
  refreshContextFiles: () => Promise<ContextFile[]>;
17
18
  updateSettings: (patch: Partial<HazeSettings>) => Promise<HazeSettings>;
18
19
  getContextReport?: () => Promise<string>;
@@ -1,8 +1,9 @@
1
- import { spawn } from 'node:child_process';
2
1
  import fs from 'fs-extra';
3
2
  import { SETTINGS_FILE, writeSettings } from '../../config/settings.js';
3
+ import { openPath } from '../../utils/openPath.js';
4
4
  import { clearTasks } from '../../core/tasks/taskStorage.js';
5
5
  import { COMMAND_HELP_ENTRIES, formatCommandHelp } from './commandHelp.js';
6
+ import { handleFleetCommand } from './fleetCommand.js';
6
7
  import { handleInitCommand } from './initCommand.js';
7
8
  import { handleLogsCommand } from './logsCommand.js';
8
9
  import { handleModelCommand } from './modelCommand.js';
@@ -12,15 +13,6 @@ async function ensureSettingsFile(settings) {
12
13
  await writeSettings(settings);
13
14
  return SETTINGS_FILE;
14
15
  }
15
- function openPath(filePath) {
16
- if (process.env.VITEST || process.env.NODE_ENV === 'test')
17
- return;
18
- const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
19
- const args = process.platform === 'win32' ? ['/c', 'start', '', filePath] : [filePath];
20
- const child = spawn(command, args, { stdio: 'ignore', detached: true });
21
- child.on('error', () => undefined);
22
- child.unref();
23
- }
24
16
  const HANDLED = 'handled';
25
17
  function exact(command) {
26
18
  return value => value === command ? { args: '' } : false;
@@ -33,8 +25,8 @@ const SLASH_COMMANDS = [
33
25
  { match: exact('/help'), run: (_args, ctx) => { ctx.addSystemMessage(formatCommandHelp(COMMAND_HELP_ENTRIES)); return HANDLED; } },
34
26
  { match: exact('/context'), run: async (_args, ctx) => { ctx.addSystemMessage(ctx.getContextReport ? await ctx.getContextReport() : 'Context overview is unavailable.'); return HANDLED; } },
35
27
  { match: exact('/session'), run: (_args, ctx) => { ctx.addSystemMessage(ctx.sessionInfo?.() ?? 'Session persistence is unavailable.'); return HANDLED; } },
36
- { match: exact('/resume'), run: async (_args, ctx) => { if (ctx.resumeSession)
37
- await ctx.resumeSession();
28
+ { match: exactOrArgs('/resume'), run: async (args, ctx) => { if (ctx.resumeSession)
29
+ await ctx.resumeSession(args || undefined);
38
30
  else
39
31
  ctx.addSystemMessage('Session persistence is unavailable.'); return HANDLED; } },
40
32
  { match: exact('/new'), run: async (_args, ctx) => { if (ctx.newSession)
@@ -45,7 +37,7 @@ const SLASH_COMMANDS = [
45
37
  ctx.compactConversation(args || undefined);
46
38
  else
47
39
  ctx.addSystemMessage('Compaction is unavailable.'); return HANDLED; } },
48
- { match: exact('/clear'), run: async (_args, ctx) => { await ctx.clearConversation(); await clearTasks(); ctx.addSystemMessage('Cleared. The void is productive.'); return HANDLED; } },
40
+ { match: exact('/clear'), run: async (_args, ctx) => { await ctx.clearConversation(); await clearTasks(); return HANDLED; } },
49
41
  { match: exactOrArgs('/logs'), run: async (args, ctx) => await handleLogsCommand(args, ctx) },
50
42
  { match: exactOrArgs('/lsp'), run: (_args, ctx) => { ctx.setMode('lsp'); ctx.addSystemMessage('Choose an LSP server to enable, disable, or remove it. Choose "add server" to add one from presets (e.g. typescript) or enter a custom command.'); return HANDLED; } },
51
43
  { match: exactOrArgs('/mcp'), run: (_args, ctx) => { ctx.setMode('mcp'); ctx.addSystemMessage('Choose an MCP server to enable, disable, remove, or set a key for it. Choose "add server" to add one from presets (e.g. context7) or enter custom details.'); return HANDLED; } },
@@ -54,6 +46,13 @@ const SLASH_COMMANDS = [
54
46
  { match: exact('/provider'), run: (_args, ctx) => { ctx.setModelProviderFilter?.(undefined); ctx.setMode('provider'); ctx.addSystemMessage('Choose a provider. Selecting one opens provider actions. Choose "add provider" to pick from presets or enter custom details.'); return HANDLED; } },
55
47
  { match: exact('/init'), run: async (_args, ctx) => await handleInitCommand(ctx) },
56
48
  { match: exact('/skills'), run: (_args, ctx) => { ctx.setMode('skills'); ctx.addSystemMessage('Choose a skill to show info, enable/disable, or remove it. Choose "add skill" to generate a new one from a description.'); return HANDLED; } },
49
+ { match: exact('/tips'), run: async (_args, ctx) => {
50
+ const currentlyEnabled = ctx.settings.tips?.enabled !== false;
51
+ await ctx.updateSettings({ tips: { enabled: !currentlyEnabled } });
52
+ ctx.addSystemMessage(`Tips rotation ${currentlyEnabled ? 'disabled' : 'enabled'}.`);
53
+ return HANDLED;
54
+ } },
55
+ { match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
57
56
  ];
58
57
  export async function handleSlashCommand(value, ctx) {
59
58
  for (const command of SLASH_COMMANDS) {
@@ -0,0 +1,14 @@
1
+ import type { TurnExecutionOptions } from './streaming.js';
2
+ import type { CommandContext, CommandResult } from './commands.js';
3
+ export interface ParsedFleetCommand {
4
+ prompt: string;
5
+ options: TurnExecutionOptions;
6
+ }
7
+ export declare function parseFleetArgs(args: string): {
8
+ ok: true;
9
+ value: ParsedFleetCommand;
10
+ } | {
11
+ ok: false;
12
+ error: string;
13
+ };
14
+ export declare function handleFleetCommand(args: string, ctx: CommandContext): Promise<CommandResult>;
@@ -0,0 +1,46 @@
1
+ import { SUBAGENT_MAX_CONCURRENCY } from '../../core/agent/budgets.js';
2
+ const FLEET_CONTROL = `This is an ephemeral /fleet parallel-only control. Decompose the durable request into genuinely independent, self-contained subagent capsules; decline if fewer than two exist and never invent tasks. For a repository-wide request, first do one bounded structure lookup, then give workers focused directory/file scope hints instead of all of src. Every call requires objective, deliverable, and mode; keep objective under 1000 characters, prefer at most 12 scope paths, and put output formatting in deliverable/acceptanceCriteria. Mode is inspect, research, implement, or validate. Never call subagent with {}. Runtime owns queueing, concurrency, deadlines, provider policy, and mutation serialization. Submit independent read-only calls together; submit mutation conservatively and validate after it settles. Aggregate every capsule truthfully by termination, usability, truncation, changed paths, validation, and coverage gaps. Retry a failed/limited worker at most once, only with materially narrower scope; otherwise report the gap. Never request private worker transcripts.`;
3
+ export function parseFleetArgs(args) {
4
+ const tokens = args.trim().split(/\s+/).filter(Boolean);
5
+ const overrides = {};
6
+ let index = 0;
7
+ while (index < tokens.length && tokens[index].startsWith('-')) {
8
+ const flag = tokens[index++];
9
+ if (flag === '--')
10
+ break;
11
+ if (flag === '--review') {
12
+ overrides.forceMode = 'inspect';
13
+ continue;
14
+ }
15
+ if (!['--profile', '--workers', '--concurrency'].includes(flag))
16
+ return { ok: false, error: `Unknown /fleet flag: ${flag}` };
17
+ const value = tokens[index++];
18
+ if (!value || value.startsWith('--'))
19
+ return { ok: false, error: `${flag} requires a value.` };
20
+ if (flag === '--profile')
21
+ overrides.profile = value;
22
+ if (flag === '--workers')
23
+ overrides.workerModel = value;
24
+ if (flag === '--concurrency') {
25
+ const concurrency = Number(value);
26
+ if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > SUBAGENT_MAX_CONCURRENCY)
27
+ return { ok: false, error: `--concurrency must be an integer from 1 to ${SUBAGENT_MAX_CONCURRENCY}.` };
28
+ overrides.maxConcurrency = concurrency;
29
+ }
30
+ }
31
+ const prompt = tokens.slice(index).join(' ').trim();
32
+ if (!prompt)
33
+ return { ok: false, error: '/fleet needs a prompt describing parallel work.' };
34
+ return { ok: true, value: { prompt, options: { ephemeralControl: FLEET_CONTROL, subagentOverrides: overrides } } };
35
+ }
36
+ const USAGE = '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>';
37
+ export async function handleFleetCommand(args, ctx) {
38
+ const parsed = parseFleetArgs(args);
39
+ if (!parsed.ok) {
40
+ ctx.addSystemMessage(`${parsed.error} Usage: ${USAGE}`);
41
+ return 'handled';
42
+ }
43
+ const durable = `/fleet ${args.trim()}`;
44
+ await ctx.runAgentTurn(durable, durable, parsed.value.options);
45
+ return 'handled';
46
+ }
@@ -12,6 +12,11 @@ export declare function toolResultSummary(event: {
12
12
  */
13
13
  export declare function busyToolLabel(toolName: string, input: unknown): string;
14
14
  export declare function formatSeconds(milliseconds: number): string;
15
+ /** Compact transcript row for a user-attached image (F03); never dumps bytes. */
16
+ export declare function imageAttachmentLine(attachment: {
17
+ fileName: string;
18
+ bytes: number;
19
+ }): string;
15
20
  export declare function formatElapsedTime(milliseconds: number): string;
16
21
  export declare function formatElapsedTimeWhole(milliseconds: number): string;
17
22
  export declare function toolOutputDetails(value: unknown): string;
@@ -1,3 +1,4 @@
1
+ import { formatBytes } from '../../utils/format.js';
1
2
  export function compact(value, maxLength = 180) {
2
3
  let text;
3
4
  if (value instanceof Error) {
@@ -18,9 +19,11 @@ export function compact(value, maxLength = 180) {
18
19
  export function toolCallSummary(toolName, input) {
19
20
  const data = input;
20
21
  if (toolName === 'bash' && typeof data?.command === 'string') {
21
- const timeout = typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
22
- return `bash $ ${data.command}${timeout}`;
22
+ const mode = data.background === true ? ' (background)' : typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
23
+ return `bash $ ${data.command}${mode}`;
23
24
  }
25
+ if (toolName === 'process' && typeof data?.action === 'string')
26
+ return `process ${data.action}${typeof data.backgroundId === 'string' ? ` ${data.backgroundId}` : ''}`;
24
27
  if (toolName === 'grep' && typeof data?.pattern === 'string') {
25
28
  const path = typeof data.path === 'string' && data.path !== '.' ? ` in ${data.path}` : '';
26
29
  const glob = typeof data.glob === 'string' ? ` (${data.glob})` : '';
@@ -42,9 +45,12 @@ export function toolCallSummary(toolName, input) {
42
45
  return `replaceLines ${data.path}:${data.startLine}-${data.endLine}`;
43
46
  if ((toolName === 'editFile' || toolName === 'replaceLines') && (data == null || (typeof data === 'object' && Object.keys(data).length === 0)))
44
47
  return toolName;
45
- if (toolName === 'subagent' && typeof data?.task === 'string') {
46
- const taskPreview = data.task.length > 60 ? `${data.task.slice(0, 60).trimEnd()}…` : data.task;
47
- return `subagent "${taskPreview}"`;
48
+ if (toolName === 'subagent') {
49
+ const task = typeof data?.objective === 'string' ? data.objective : typeof data?.task === 'string' ? data.task : undefined;
50
+ if (task) {
51
+ const taskPreview = task.length > 60 ? `${task.slice(0, 60).trimEnd()}…` : task;
52
+ return `subagent "${taskPreview}"`;
53
+ }
48
54
  }
49
55
  if (toolName === 'writeTasks') {
50
56
  const tasks = Array.isArray(data?.tasks) ? data.tasks : [];
@@ -64,6 +70,9 @@ export function toolResultSummary(event) {
64
70
  return `failed: ${compact(event.error ?? output?.error ?? event.output)}`;
65
71
  if (output?.duplicateSkipped === true)
66
72
  return 'skipped duplicate';
73
+ if (output?.background === true && typeof output.backgroundId === 'string') {
74
+ return `⏵ ${output.backgroundId} ${compact(output.command, 80)}${typeof output.pid === 'number' ? ` (pid ${output.pid})` : ''}`;
75
+ }
67
76
  if (typeof output?.totalMatches === 'number') {
68
77
  const count = output.totalMatches;
69
78
  return count === 0 ? 'no matches' : `${output.matchCountIsLowerBound === true ? 'at least ' : ''}${count} match${count === 1 ? '' : 'es'}`;
@@ -79,6 +88,18 @@ export function toolResultSummary(event) {
79
88
  : '';
80
89
  return `exited with code ${output.code}${risk}`;
81
90
  }
91
+ const resultOutput = output ?? {};
92
+ const capsule = typeof resultOutput.capsule === 'object' && resultOutput.capsule != null ? resultOutput.capsule : undefined;
93
+ if (capsule && typeof capsule.termination === 'string' && typeof capsule.deliverable === 'string') {
94
+ const summary = capsule.deliverable.split('\n')[0] ?? '';
95
+ const preview = summary.length > 120 ? `${summary.slice(0, 120).trimEnd()}…` : summary;
96
+ const telemetry = typeof resultOutput.telemetry === 'object' && resultOutput.telemetry != null ? resultOutput.telemetry : undefined;
97
+ const calls = typeof telemetry?.toolCallCount === 'number' ? telemetry.toolCallCount : typeof resultOutput.toolCallCount === 'number' ? resultOutput.toolCallCount : 0;
98
+ const durationMs = typeof telemetry?.durationMs === 'number' ? telemetry.durationMs : resultOutput.durationMs;
99
+ const duration = typeof durationMs === 'number' ? ` in ${(durationMs / 1000).toFixed(1)}s` : '';
100
+ const meta = calls > 0 ? ` (${calls} call${calls === 1 ? '' : 's'}${duration})` : '';
101
+ return `${capsule.termination}${capsule.usable === false ? ' · unusable' : ''}${capsule.truncated === true ? ' · truncated' : ''}${meta}: ${preview}`;
102
+ }
82
103
  if (typeof output?.status === 'string' && typeof output?.summary === 'string') {
83
104
  const summary = output.summary.split('\n')[0] ?? '';
84
105
  const preview = summary.length > 120 ? `${summary.slice(0, 120).trimEnd()}…` : summary;
@@ -123,7 +144,9 @@ export function busyToolLabel(toolName, input) {
123
144
  const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
124
145
  switch (toolName) {
125
146
  case 'bash':
126
- return 'Running command';
147
+ return data?.background === true ? 'Starting background process' : 'Running command';
148
+ case 'process':
149
+ return 'Managing background process';
127
150
  case 'grep':
128
151
  return 'Searching';
129
152
  case 'listFiles':
@@ -154,6 +177,10 @@ export function busyToolLabel(toolName, input) {
154
177
  export function formatSeconds(milliseconds) {
155
178
  return `${(milliseconds / 1000).toFixed(1)}s`;
156
179
  }
180
+ /** Compact transcript row for a user-attached image (F03); never dumps bytes. */
181
+ export function imageAttachmentLine(attachment) {
182
+ return `🖼 ${attachment.fileName} (${formatBytes(attachment.bytes)})`;
183
+ }
157
184
  export function formatElapsedTime(milliseconds) {
158
185
  const totalSeconds = Math.max(0, milliseconds / 1000);
159
186
  const wholeSeconds = Math.floor(totalSeconds);
@@ -1,11 +1,5 @@
1
1
  import { listLogs, summarizeLog } from '../../core/log/llmLog.js';
2
- function formatBytes(bytes) {
3
- if (bytes < 1024)
4
- return `${bytes} B`;
5
- if (bytes < 1024 * 1024)
6
- return `${(bytes / 1024).toFixed(1)} KB`;
7
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
8
- }
2
+ import { formatBytes } from '../../utils/format.js';
9
3
  export async function handleLogsCommand(args, ctx) {
10
4
  const id = args.trim();
11
5
  if (!id) {
@@ -3,7 +3,7 @@ export async function handleModelCommand(value, ctx) {
3
3
  if (value === '/model') {
4
4
  ctx.setModelProviderFilter?.(undefined);
5
5
  ctx.setMode('model');
6
- ctx.addSystemMessage('Choose a model. Selecting a model also sets its provider.');
6
+ ctx.addSystemMessage('Choose a model, or select "add models" to fetch a provider\'s model list and pick from it. Selecting a model also sets its provider.');
7
7
  return 'handled';
8
8
  }
9
9
  if (value === '/model list') {
@@ -18,6 +18,7 @@ export declare function providerRemoveModels(settings: HazeSettings, providerNam
18
18
  export declare function providerRemove(settings: HazeSettings, providerName: string | undefined): WizardPatch & {
19
19
  wasActiveProvider?: boolean;
20
20
  };
21
+ export declare function providerSetImageCapable(settings: HazeSettings, providerName: string | undefined, enabled: boolean): WizardPatch;
21
22
  export declare function providerSetKey(settings: HazeSettings, providerName: string | undefined, value: string): WizardPatch & {
22
23
  key?: string;
23
24
  };
@@ -90,6 +90,19 @@ export function providerRemove(settings, providerName) {
90
90
  message: `Removed provider ${provider.name}.${wasActiveProvider ? ' Active provider and model selection cleared.' : ''}`,
91
91
  };
92
92
  }
93
+ export function providerSetImageCapable(settings, providerName, enabled) {
94
+ const provider = providerName ? findProvider(settings, providerName) : undefined;
95
+ if (!provider)
96
+ return { message: 'No provider selected.' };
97
+ const capabilities = { ...(provider.capabilities ?? {}), images: enabled };
98
+ return {
99
+ provider,
100
+ settingsPatch: { providers: upsertProvider(settings, { ...provider, capabilities }) },
101
+ message: enabled
102
+ ? `Provider ${provider.name} marked image-capable. Attached images will be sent to it.`
103
+ : `Provider ${provider.name} is no longer image-capable.`,
104
+ };
105
+ }
93
106
  export function providerSetKey(settings, providerName, value) {
94
107
  const provider = providerName ? findProvider(settings, providerName) : undefined;
95
108
  if (!provider)
@@ -2,6 +2,7 @@ export type HeadlessOutput = 'text' | 'json' | 'stream-json';
2
2
  export interface HeadlessOptions {
3
3
  prompt: string;
4
4
  modelOverride?: string;
5
+ resumeSessionId?: string;
5
6
  output: HeadlessOutput;
6
7
  debug?: boolean;
7
8
  }
@@ -4,10 +4,8 @@ import { EMPTY_TOKEN_USAGE, accumulateTokenUsage } from '../chat/turnState.js';
4
4
  import { readSettings } from '../../config/settings.js';
5
5
  import { activeModel, modelSelector, resolveModelSelector } from '../../config/providers.js';
6
6
  import { createLog, endLog } from '../../core/log/llmLog.js';
7
- function debug(line) {
8
- if (process.env.HAZE_DEBUG)
9
- process.stderr.write(`[haze] ${line}\n`);
10
- }
7
+ import { findSession, restoreSessionState } from '../../core/session/sessionStore.js';
8
+ import { teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
11
9
  function pinnedUsage(usage) {
12
10
  // Normalize every field to a number: TokenUsage seeds most fields to 0 but
13
11
  // inputTokens/outputTokens may be undefined until the first report. A uniform ?? 0
@@ -73,14 +71,30 @@ async function resolveModelOrError(modelOverride) {
73
71
  return undefined;
74
72
  }
75
73
  export async function runHeadless(options) {
74
+ const resumed = options.resumeSessionId ? await findSession(options.resumeSessionId) : undefined;
75
+ if (options.resumeSessionId && !resumed) {
76
+ process.stderr.write(`No session named ${options.resumeSessionId} exists for this workspace.\n`);
77
+ return 1;
78
+ }
76
79
  const modelError = await resolveModelOrError(options.modelOverride);
77
80
  if (modelError) {
78
81
  process.stderr.write(`${modelError}\n`);
79
82
  return 1;
80
83
  }
84
+ // stderr keeps stdout clean for --output json/stream-json consumers.
85
+ const debugLog = (line) => {
86
+ if (options.debug)
87
+ process.stderr.write(`[haze] ${line}\n`);
88
+ };
81
89
  const contextFiles = await readContextFiles(process.cwd());
82
90
  const session = { start: new Date(), cwd: process.cwd() };
83
91
  let conversation = [];
92
+ if (resumed) {
93
+ const restored = await restoreSessionState(resumed);
94
+ conversation = restored.messages;
95
+ for (const error of restored.parseErrors)
96
+ process.stderr.write(`Session parse error: ${error}\n`);
97
+ }
84
98
  // Assistant text is delivered in two stages by runAgentTurn: an initial streaming
85
99
  // `addMessage`, then a finalizing `updateMessage` with the complete text. We key
86
100
  // segments by id and patch them on update so finalized (and multi-segment) text is captured.
@@ -116,7 +130,7 @@ export async function runHeadless(options) {
116
130
  },
117
131
  setBusy: () => undefined,
118
132
  setBusyLabel: () => undefined,
119
- debugLog: debug,
133
+ debugLog,
120
134
  getConversation: () => conversation,
121
135
  getLastAssistantText: () => lastAssistantText,
122
136
  setLastAssistantText: (text) => {
@@ -131,6 +145,7 @@ export async function runHeadless(options) {
131
145
  let status;
132
146
  let result;
133
147
  let persistenceError;
148
+ let backgroundTeardownError;
134
149
  try {
135
150
  ({ status } = await runAgentTurn(options.prompt, options.prompt, contextFiles, callbacks, 0, false, false, session, options.modelOverride));
136
151
  result = segments.filter((s) => !s.hidden && s.text).map((s) => s.text).join('\n');
@@ -140,11 +155,16 @@ export async function runHeadless(options) {
140
155
  result = error instanceof Error ? error.message : String(error);
141
156
  }
142
157
  finally {
158
+ await teardownBackgroundProcesses().catch(error => {
159
+ backgroundTeardownError = error instanceof Error ? error.message : String(error);
160
+ });
143
161
  if (log)
144
162
  await endLog(log).catch(error => {
145
163
  persistenceError = error instanceof Error ? error.message : String(error);
146
164
  });
147
165
  }
166
+ if (backgroundTeardownError)
167
+ process.stderr.write(`haze background teardown warning: ${backgroundTeardownError}\n`);
148
168
  if (persistenceError)
149
169
  process.stderr.write(`haze persistence warning: ${persistenceError}\n`);
150
170
  if (options.output === 'json' || options.output === 'stream-json') {
@@ -0,0 +1,9 @@
1
+ import type { SessionSummary } from '../../core/session/sessionStore.js';
2
+ import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
3
+ export declare const MAX_SESSION_PICKER_RESULTS = 20;
4
+ export declare const SESSION_ACTIONS: {
5
+ readonly resume: "resume";
6
+ readonly fork: "fork";
7
+ };
8
+ export declare function sessionSuggestions(sessions: SessionSummary[]): TextInputSuggestion[];
9
+ export declare function sessionActionSuggestions(): TextInputSuggestion[];
@@ -0,0 +1,29 @@
1
+ export const MAX_SESSION_PICKER_RESULTS = 20;
2
+ export const SESSION_ACTIONS = { resume: 'resume', fork: 'fork' };
3
+ function formatDate(value) {
4
+ const date = new Date(value);
5
+ if (Number.isNaN(date.getTime()))
6
+ return value;
7
+ const pad = (part) => String(part).padStart(2, '0');
8
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
9
+ }
10
+ function formatBytes(bytes) {
11
+ if (bytes < 1024)
12
+ return `${bytes} B`;
13
+ if (bytes < 1024 * 1024)
14
+ return `${Math.ceil(bytes / 1024)} KB`;
15
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
16
+ }
17
+ export function sessionSuggestions(sessions) {
18
+ return sessions.slice(0, MAX_SESSION_PICKER_RESULTS).map(session => ({
19
+ value: session.id,
20
+ description: `${formatDate(session.lastActivityAt)} · ${session.messageCount} msg${session.messageCount === 1 ? '' : 's'} · ${formatBytes(session.sizeBytes)}${session.lastStatus ? ` · ${session.lastStatus}` : ''}${session.parseErrors.length ? ' · ⚠ malformed lines' : ''}${session.firstUserPreview ? ` · “${session.firstUserPreview}”` : ''}`,
21
+ kind: 'session',
22
+ }));
23
+ }
24
+ export function sessionActionSuggestions() {
25
+ return [
26
+ { value: SESSION_ACTIONS.resume, description: 'Resume this session', kind: 'session' },
27
+ { value: SESSION_ACTIONS.fork, description: 'Start a new session from its latest snapshot', kind: 'session' },
28
+ ];
29
+ }
@@ -1,7 +1,7 @@
1
1
  import { contextFileDiagnostics, summarizeContextDiagnostics } from '../../config/contextFiles.js';
2
2
  import { configuredLspServers } from '../../config/lspSettings.js';
3
3
  import { configuredMcpServers } from '../../config/mcpSettings.js';
4
- import { activeProvider as resolveActiveProvider, configuredProviders, providerHasKey } from '../../config/providers.js';
4
+ import { activeProvider as resolveActiveProvider, configuredProviders, providerHasKey, providerImageCapable } from '../../config/providers.js';
5
5
  import { isSkillEnabled } from '../../config/skillSettings.js';
6
6
  import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
7
7
  export async function formatSettingsSummary(settings, contextFiles) {
@@ -22,19 +22,21 @@ export async function formatSettingsSummary(settings, contextFiles) {
22
22
  }
23
23
  const lspServers = configuredLspServers(settings);
24
24
  const skillRegistry = await loadSkillRegistry();
25
- const installedSkills = [...skillRegistry.skills.values()];
26
- const skillNames = installedSkills.map(skill => `${skill.name}${isSkillEnabled(settings, skill.name) ? '' : ' (disabled)'}`).join(', ');
25
+ const installedSkills = skillRegistry.candidates ?? [...skillRegistry.skills.values()];
26
+ const skillNames = installedSkills.map(skill => `${skill.name}${isSkillEnabled(settings, skill.name, skill.source) ? '' : ' (disabled)'} · ${skill.source}`).join(', ');
27
+ const projectSkillNames = installedSkills.filter(skill => skill.source === 'project').map(skill => skill.name).join(', ');
27
28
  const lines = [
28
29
  `Provider: ${activeProvider?.name ?? 'not configured'}`,
29
30
  `Model: ${settings.model ?? 'not set'}`,
30
31
  `Base URL: ${activeProvider?.url ?? settings.baseURL ?? 'not configured'}`,
31
32
  `API key: ${activeProvider && providerHasKey(settings, activeProvider) ? 'saved' : 'missing'}`,
32
- `Configured providers: ${providers.map(provider => provider.name).join(', ') || 'none'}`,
33
+ `Configured providers: ${providers.map(provider => `${provider.name}${providerImageCapable(provider) ? ' (images)' : ''}`).join(', ') || 'none'}`,
33
34
  `LSP servers: ${lspServers.map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
34
35
  `MCP servers: ${configuredMcpServers(settings).map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
35
36
  `Skills: ${skillNames || 'none'}`,
36
37
  ...(skillRegistry.errors.length ? [`Skill load errors: ${skillRegistry.errors.map(error => `${error.directory}: ${error.message}`).join('; ')}`] : []),
37
38
  `Context files: ${contextFiles.length ? `${contextFiles.map(file => file.path).join(', ')} (~${contextTokens} tokens)` : 'none'}`,
39
+ `Project skills (repo context): ${projectSkillNames || 'none'}`,
38
40
  ];
39
41
  if (notes.length > 0)
40
42
  lines.push(`Context note: ${notes.join('; ')}`);
@@ -1,11 +1,12 @@
1
1
  import { removeSkillSetting } from '../../config/skillSettings.js';
2
2
  import { isYesConfirmation } from './wizardInput.js';
3
+ import { findSelectedSkill } from './skillWizard.js';
3
4
  export function skillConfirmRemoveResult(settings, skills, selectedName, value) {
4
5
  if (!selectedName)
5
6
  return { mode: 'chat' };
6
7
  if (!isYesConfirmation(value))
7
8
  return { mode: 'chat', selectedName: undefined, message: 'Cancelled. Skill not removed.' };
8
- const skill = skills.find(candidate => candidate.name === selectedName);
9
+ const skill = findSelectedSkill(skills, selectedName);
9
10
  if (!skill)
10
11
  return { mode: 'chat', selectedName: undefined, message: `Skill ${selectedName} not found.` };
11
12
  return {
@@ -13,7 +14,7 @@ export function skillConfirmRemoveResult(settings, skills, selectedName, value)
13
14
  selectedName: undefined,
14
15
  skill,
15
16
  removedDir: skill.dir,
16
- settingsPatch: { skills: removeSkillSetting(settings, selectedName) },
17
- message: `Removed skill ${selectedName}.`,
17
+ settingsPatch: { skills: removeSkillSetting(settings, skill.name, skill.source) },
18
+ message: skill.source === 'global' ? `Removed skill ${skill.name}.` : `Removed project skill ${skill.name}.`,
18
19
  };
19
20
  }
@@ -7,6 +7,8 @@ export type SkillWizardResult = {
7
7
  settingsPatch?: Partial<HazeSettings>;
8
8
  clearDraft?: boolean;
9
9
  };
10
+ export declare function skillPickerValue(skill: LoadedSkill): string;
11
+ export declare function findSelectedSkill(skills: LoadedSkill[], selection: string | undefined): LoadedSkill | undefined;
10
12
  export declare function selectSkillResult(skills: LoadedSkill[], name: string): SkillWizardResult;
11
13
  export declare function skillInfoMessage(settings: HazeSettings, skill: LoadedSkill): string;
12
14
  export declare function selectSkillActionResult(settings: HazeSettings, skills: LoadedSkill[], selectedName: string | undefined, action: string): SkillWizardResult & {
@@ -1,38 +1,48 @@
1
1
  import { isSkillEnabled, setSkillEnabled } from '../../config/skillSettings.js';
2
2
  import { COMMON_ACTIONS, SKILL_ACTIONS, SKILL_CHOICES } from './wizardActions.js';
3
+ export function skillPickerValue(skill) {
4
+ return `${skill.name} · ${skill.source}`;
5
+ }
6
+ export function findSelectedSkill(skills, selection) {
7
+ if (!selection)
8
+ return undefined;
9
+ return skills.find(skill => skillPickerValue(skill) === selection)
10
+ ?? skills.find(skill => skill.name === selection);
11
+ }
3
12
  export function selectSkillResult(skills, name) {
4
13
  if (name === SKILL_CHOICES.addSkill)
5
14
  return { mode: 'skillsAddName', clearDraft: true, message: 'Name the skill (kebab-case, e.g. security-review). ESC cancels.' };
6
- const skill = skills.find(candidate => candidate.name === name);
15
+ const skill = findSelectedSkill(skills, name);
7
16
  if (!skill)
8
17
  return { mode: 'chat', message: `No skill named ${name}. Use /skills and choose add skill.` };
9
- return { mode: 'skillsAction', selectedName: skill.name, message: `${skill.name}: choose an action.` };
18
+ return { mode: 'skillsAction', selectedName: name === skill.name ? skill.name : skillPickerValue(skill), message: `${skill.name} · ${skill.source}: choose an action.` };
10
19
  }
11
20
  export function skillInfoMessage(settings, skill) {
12
21
  return [
13
22
  `${skill.name}`,
14
23
  skill.description,
15
24
  '',
25
+ `Source: ${skill.source}`,
16
26
  `References: ${skill.references.length}`,
17
27
  `Path: ${skill.dir}`,
18
- `State: ${isSkillEnabled(settings, skill.name) ? 'enabled' : 'disabled'}`,
28
+ `State: ${isSkillEnabled(settings, skill.name, skill.source) ? 'enabled' : 'disabled'}`,
19
29
  ].join('\n');
20
30
  }
21
31
  export function selectSkillActionResult(settings, skills, selectedName, action) {
22
32
  if (!selectedName)
23
33
  return { mode: 'skills' };
24
- const skill = skills.find(candidate => candidate.name === selectedName);
34
+ const skill = findSelectedSkill(skills, selectedName);
25
35
  if (!skill)
26
36
  return { mode: 'chat', selectedName: undefined, message: `Skill ${selectedName} not found.` };
27
37
  if (action === COMMON_ACTIONS.enable || action === COMMON_ACTIONS.disable) {
28
38
  const enabled = action === COMMON_ACTIONS.enable;
29
- return { mode: 'chat', selectedName: undefined, settingsPatch: { skills: setSkillEnabled(settings, selectedName, enabled) }, message: `Skill ${selectedName} ${enabled ? 'enabled' : 'disabled'}.`, skill };
39
+ return { mode: 'chat', selectedName: undefined, settingsPatch: { skills: setSkillEnabled(settings, skill.name, enabled, skill.source) }, message: `Skill ${skill.name} (${skill.source}) ${enabled ? 'enabled' : 'disabled'}.`, skill };
30
40
  }
31
41
  if (action === SKILL_ACTIONS.showInfo)
32
42
  return { message: skillInfoMessage(settings, skill), skill };
33
43
  if (action === SKILL_ACTIONS.validate)
34
44
  return { validate: true, skill };
35
45
  if (action === SKILL_ACTIONS.removeSkill)
36
- return { mode: 'skillsConfirmRemove', message: `Remove skill ${selectedName}? This deletes ~/.haze/skills/${selectedName}. Type "yes" to confirm. Esc to cancel.`, skill };
46
+ return { mode: 'skillsConfirmRemove', message: `Remove ${skill.source} skill ${skill.name}? This deletes ${skill.dir}. Type "yes" to confirm. Esc to cancel.`, skill };
37
47
  return { message: `Unknown skill action: ${action}`, skill };
38
48
  }