@denizokcu/haze 1.5.0 → 1.6.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 (90) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +74 -5
  3. package/SECURITY.md +1 -1
  4. package/dist/buildInfo.json +3 -3
  5. package/dist/cli/chat/DynamicFrame.d.ts +0 -13
  6. package/dist/cli/chat/DynamicFrame.js +7 -2
  7. package/dist/cli/chat/inputSuggestions.js +2 -0
  8. package/dist/cli/chat/resizeGuard.d.ts +20 -0
  9. package/dist/cli/chat/resizeGuard.js +25 -0
  10. package/dist/cli/chat/terminalControl.d.ts +4 -2
  11. package/dist/cli/chat/terminalControl.js +16 -5
  12. package/dist/cli/chat/wizard/pluginHandlers.d.ts +10 -0
  13. package/dist/cli/chat/wizard/pluginHandlers.js +156 -0
  14. package/dist/cli/chat/wizard/skillsHandlers.js +2 -2
  15. package/dist/cli/chat/wizard/types.d.ts +20 -0
  16. package/dist/cli/chat/wizard/uiState.d.ts +25 -1
  17. package/dist/cli/chat/wizard/uiState.js +3 -1
  18. package/dist/cli/chat/wizardDispatch.js +6 -0
  19. package/dist/cli/commands/chat.js +27 -5
  20. package/dist/cli/commands/commandHelp.js +7 -2
  21. package/dist/cli/commands/commands.d.ts +5 -0
  22. package/dist/cli/commands/commands.js +17 -3
  23. package/dist/cli/commands/initCommand.js +3 -2
  24. package/dist/cli/commands/pluginCommand.d.ts +16 -0
  25. package/dist/cli/commands/pluginCommand.js +127 -0
  26. package/dist/cli/commands/reasoningCommand.d.ts +0 -15
  27. package/dist/cli/commands/reasoningCommand.js +1 -3
  28. package/dist/cli/commands/skillsWizard.js +4 -0
  29. package/dist/cli/commands/streaming/agentAttempt.js +2 -1
  30. package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
  31. package/dist/cli/commands/streaming/attemptOutcome.js +4 -3
  32. package/dist/cli/commands/streaming/attemptSetup.d.ts +2 -0
  33. package/dist/cli/commands/streaming/attemptSetup.js +3 -2
  34. package/dist/cli/commands/streaming/stallRecovery.d.ts +6 -0
  35. package/dist/cli/commands/streaming/stallRecovery.js +6 -5
  36. package/dist/cli/commands/streaming/turnRuntime.js +2 -4
  37. package/dist/cli/commands/wizardFlow.d.ts +59 -0
  38. package/dist/cli/commands/wizardFlow.js +40 -0
  39. package/dist/cli/contextReportCli.js +4 -3
  40. package/dist/cli/index.js +19 -2
  41. package/dist/config/contextFiles.js +3 -2
  42. package/dist/config/inputHistory.js +3 -3
  43. package/dist/config/paths.d.ts +1 -0
  44. package/dist/config/paths.js +1 -0
  45. package/dist/config/providerAuth.js +3 -3
  46. package/dist/config/settings.d.ts +14 -2
  47. package/dist/config/settings.js +8 -4
  48. package/dist/config/updateCheck.js +3 -3
  49. package/dist/core/agent/budgets.d.ts +17 -0
  50. package/dist/core/agent/budgets.js +19 -0
  51. package/dist/core/agent/reasoningPolicy.js +1 -1
  52. package/dist/core/agent/workState.d.ts +0 -2
  53. package/dist/core/agent/workState.js +1 -1
  54. package/dist/core/log/llmLog.js +1 -1
  55. package/dist/core/providerContracts.d.ts +6 -3
  56. package/dist/core/session/sessionStore.js +4 -3
  57. package/dist/core/subagent/contracts.d.ts +1 -11
  58. package/dist/core/subagent/contracts.js +0 -22
  59. package/dist/llm/client.js +28 -7
  60. package/dist/llm/subagentRunner.d.ts +1 -6
  61. package/dist/llm/subagentRunner.js +11 -23
  62. package/dist/llm/tools/fileTools.js +2 -3
  63. package/dist/llm/tools/gitIgnore.js +1 -1
  64. package/dist/llm/tools/grepRunner.d.ts +10 -0
  65. package/dist/llm/tools/grepRunner.js +24 -0
  66. package/dist/llm/tools/toolContext.d.ts +2 -3
  67. package/dist/llm/tools/toolContext.js +2 -3
  68. package/dist/llm/tools/toolContextState.d.ts +0 -1
  69. package/dist/llm/tools/toolContextState.js +1 -4
  70. package/dist/llm/workerContext.d.ts +0 -7
  71. package/dist/llm/workerContext.js +0 -17
  72. package/dist/skills/SkillLoader.js +3 -2
  73. package/dist/skills/SkillRegistry.js +7 -4
  74. package/dist/skills/builder/SkillBuilder.js +11 -10
  75. package/dist/skills/plugins/installer.d.ts +25 -0
  76. package/dist/skills/plugins/installer.js +272 -0
  77. package/dist/skills/plugins/package.d.ts +41 -0
  78. package/dist/skills/plugins/package.js +275 -0
  79. package/dist/skills/plugins/runtime.d.ts +3 -0
  80. package/dist/skills/plugins/runtime.js +108 -0
  81. package/dist/skills/skillTools.js +10 -5
  82. package/dist/skills/types.d.ts +4 -0
  83. package/dist/ui/codeHighlight.d.ts +1 -1
  84. package/dist/ui/codeHighlight.js +112 -4
  85. package/dist/ui/components/StreamingMarkdownText.d.ts +0 -2
  86. package/dist/ui/components/StreamingMarkdownText.js +1 -1
  87. package/dist/ui/components/TextInput.d.ts +1 -1
  88. package/dist/utils/fs.d.ts +10 -0
  89. package/dist/utils/fs.js +37 -2
  90. package/package.json +17 -20
@@ -24,9 +24,16 @@ function openRouterHeaders(providerName, baseURL) {
24
24
  'X-Title': HAZE_TITLE,
25
25
  };
26
26
  }
27
- function capabilities(providerName, baseURL, providerKind) {
27
+ function capabilities(providerName, baseURL, providerKind, explicit) {
28
28
  const directOpenAI = providerKind !== 'chatgpt-codex' && (providerName === 'openai' || /api\.openai\.com/i.test(baseURL));
29
29
  const openRouter = isOpenRouter(providerName, baseURL);
30
+ // Reasoning-effort support is explicit-first: a user override wins either
31
+ // way. Otherwise loopback/local inference servers (LM Studio, Ollama,
32
+ // llama.cpp) default to `false`: their own reasoning switches coerce
33
+ // unsupported levels — even `none` — to `on` (LM Studio), inverting the
34
+ // request, and subagent workers rely on `none` meaning off. Hosted
35
+ // OpenAI-compatible endpoints keep the SDK pass-through (`true`).
36
+ const supportsReasoningEffort = explicit?.reasoningEffort ?? !isLocalProviderUrl(baseURL);
30
37
  return {
31
38
  reportsCacheUsage: directOpenAI || openRouter,
32
39
  supportsPromptCacheKey: directOpenAI,
@@ -34,11 +41,25 @@ function capabilities(providerName, baseURL, providerKind) {
34
41
  supportsStickySessionId: openRouter,
35
42
  supportsServerCompaction: false,
36
43
  supportsTextVerbosity: directOpenAI,
37
- // Pass-through marker: the SDK maps the top-level `reasoning` parameter
38
- // per provider and endpoints without native support ignore the field.
39
- supportsReasoningEffort: true,
44
+ supportsReasoningEffort,
40
45
  };
41
46
  }
47
+ /**
48
+ * Match the pinned OpenAI SDK's GPT-6+ effort restrictions before transport.
49
+ * Unsupported choices are omitted, not promoted to a different effort; the
50
+ * policy retains the request and explains why the provider default will apply.
51
+ */
52
+ function reasoningPolicyForModel(modelName, requested, caps) {
53
+ const policy = resolveReasoningPolicy({ requested, capabilities: caps });
54
+ if (policy.effective === 'disabled')
55
+ return policy;
56
+ const version = /^gpt-(\d+)(?:\.\d+)?(?:-.+)?$/.exec(modelName);
57
+ const supportsNone = modelName === 'gpt-6-sol' || modelName === 'gpt-6-luna';
58
+ if (version && Number(version[1]) >= 6 && (requested === 'minimal' || (requested === 'none' && !supportsNone))) {
59
+ return { requested, effective: 'disabled', reason: `${modelName} does not support reasoning effort ${requested}; parameter omitted (provider default). Choose low, medium, high, xhigh, or unset.` };
60
+ }
61
+ return policy;
62
+ }
42
63
  /** True for loopback/local inference servers, whose effective window is server-configured (often far below the model's). */
43
64
  export function isLocalProviderUrl(url) {
44
65
  try {
@@ -58,11 +79,11 @@ function runtimeForSelection(settings, selection, cwd, reasoningOverride, sessio
58
79
  const name = selection.model;
59
80
  const cacheSeed = cwd ?? process.cwd();
60
81
  const cacheKey = crypto.createHash('sha256').update(`${cacheSeed}\0${name}`).digest('hex').slice(0, 32);
61
- const caps = capabilities(selection.provider.name, baseURL, providerKind);
82
+ const caps = capabilities(selection.provider.name, baseURL, providerKind, selection.provider.capabilities);
62
83
  const selector = modelSelector(selection.provider, name);
63
84
  // The full precedence chain lives in one pure resolver
64
85
  // (`resolveAttemptReasoning`): run-scoped override → session per-model map →
65
- // global settings → built-in default (medium). The stored or session
86
+ // global settings → built-in default (low). The stored or session
66
87
  // `provider-default` sentinel sends no parameter at all. The capability gate
67
88
  // in resolveReasoningPolicy is unchanged — nothing forces the parameter onto
68
89
  // an unsupported protocol.
@@ -73,7 +94,7 @@ function runtimeForSelection(settings, selection, cwd, reasoningOverride, sessio
73
94
  globalSetting: isStoredReasoning(settings.reasoning) ? settings.reasoning : undefined,
74
95
  });
75
96
  const requestedReasoning = effectiveRequestedReasoning(storedReasoning);
76
- const reasoningPolicy = resolveReasoningPolicy({ requested: requestedReasoning, capabilities: caps });
97
+ const reasoningPolicy = reasoningPolicyForModel(name, requestedReasoning, caps);
77
98
  const openai = providerKind === 'chatgpt-codex'
78
99
  ? createOpenAI({ apiKey: OAUTH_SDK_SENTINEL, baseURL, fetch: createChatGptCodexFetch(selection.provider.name) })
79
100
  : createOpenAI({ apiKey, baseURL, headers: openRouterHeaders(selection.provider.name, baseURL) });
@@ -1,4 +1,3 @@
1
- import type { ContextFile } from '../config/contextFiles.js';
2
1
  import { toolOnlyStepCount } from '../core/agent/turnPolicy.js';
3
2
  import { type HazeToolContext } from './tools/toolContext.js';
4
3
  import { type WorkerContextBundle } from './workerContext.js';
@@ -18,14 +17,11 @@ declare function validationFromOutput(name: string, output: unknown): {
18
17
  ok: boolean;
19
18
  } | undefined;
20
19
  export type SubagentResult = SubagentExecutionResult;
21
- export declare function runSubagent(taskInput: string | SubagentTaskCapsule, options: {
20
+ export declare function runSubagent(task: SubagentTaskCapsule, options: {
22
21
  model?: WorkerRuntime['model'];
23
22
  runtime?: WorkerRuntime;
24
23
  profile?: SubagentExecutionProfile;
25
- contextFiles?: ContextFile[];
26
24
  contextBundle?: WorkerContextBundle;
27
- allowedTools?: readonly string[];
28
- maxSteps?: number;
29
25
  abortSignal?: AbortSignal;
30
26
  deadlineExpired?: () => boolean;
31
27
  queueMs?: number;
@@ -40,7 +36,6 @@ export declare function createSubagentTool(options: {
40
36
  mutationPolicy?: WorkspaceMutationPolicy;
41
37
  blockedReason?: string;
42
38
  forceMode?: 'inspect';
43
- contextFiles?: ContextFile[];
44
39
  session?: PromptSession;
45
40
  }): ({
46
41
  deferLoading?: boolean;
@@ -1,13 +1,13 @@
1
1
  import { isStepCount, streamText, tool } from 'ai';
2
2
  import { estimateValueTokens } from '../core/agent/contextBudget.js';
3
- import { SUBAGENT_MAX_STEPS, SUBAGENT_MIN_STEPS, SUBAGENT_SYNTHESIS_RESERVE, SUBAGENT_TOOL_ONLY_LIMIT, createToolExecutionBudget, isToolBudgetBlocked, withToolExecutionBudget, } from '../core/agent/budgets.js';
3
+ import { SUBAGENT_SYNTHESIS_RESERVE, SUBAGENT_TOOL_ONLY_LIMIT, createToolExecutionBudget, isToolBudgetBlocked, withToolExecutionBudget, } from '../core/agent/budgets.js';
4
4
  import { storeToolOutput } from '../core/agent/toolOutputStore.js';
5
5
  import { changedPathsFromTool } from '../core/agent/toolCapabilities.js';
6
6
  import { withSyntheticControl } from '../core/agent/requestAssembly.js';
7
7
  import { toolOnlyStepCount } from '../core/agent/turnPolicy.js';
8
8
  import { toolsContextFor } from './tools/toolContext.js';
9
- import { assembleWorkerContext, compatibilityBundle, workerTaskMessage } from './workerContext.js';
10
- import { fallbackWorkerRuntime, normalizeSubagentInput, subagentInputSchema, withLegacyProjection, } from '../core/subagent/contracts.js';
9
+ import { assembleWorkerContext, workerTaskMessage } from './workerContext.js';
10
+ import { fallbackWorkerRuntime, normalizeSubagentInput, subagentInputSchema, } from '../core/subagent/contracts.js';
11
11
  import { COMPATIBILITY_PROFILE } from '../core/subagent/executionProfiles.js';
12
12
  import { SubagentCoordinator } from '../core/subagent/subagentCoordinator.js';
13
13
  import { projectContextSection } from './systemPrompt.js';
@@ -54,22 +54,14 @@ function terminalResult(task, runtime, profile, termination, message, queueMs =
54
54
  const capsule = { id: task.id, termination, usable: false, deliverable: message, changedPaths: [], validation: [], coverageGaps: [message], truncated: false };
55
55
  const telemetry = telemetryBase(runtime, profile, estimateValueTokens(workerTaskMessage(task)), 0, queueMs);
56
56
  telemetry.estimates.resultCapsuleTokens = estimateValueTokens(capsule);
57
- return withLegacyProjection(capsule, telemetry, termination === 'provider_error' || termination === 'policy_blocked' ? message : undefined);
57
+ return { capsule, telemetry, ...(termination === 'provider_error' || termination === 'policy_blocked' ? { error: message } : {}) };
58
58
  }
59
- export async function runSubagent(taskInput, options) {
59
+ export async function runSubagent(task, options) {
60
60
  const profile = options.profile ?? COMPATIBILITY_PROFILE;
61
61
  const runtime = options.runtime ?? fallbackWorkerRuntime(options.model);
62
- const task = typeof taskInput === 'string'
63
- ? { id: 'worker', objective: taskInput, deliverable: 'Return a concise self-contained result.', mode: options.allowedTools ? (options.allowedTools.some(name => ['editFile', 'replaceLines', 'writeFile'].includes(name)) ? 'implement' : options.allowedTools.includes('shell') ? 'validate' : options.allowedTools.includes('fetch') ? 'research' : 'inspect') : 'implement', scope: [], acceptanceCriteria: [], legacyMaxSteps: options.maxSteps }
64
- : taskInput;
65
- const requestedSteps = task.legacyMaxSteps ?? options.maxSteps;
66
- if (requestedSteps != null && (requestedSteps < SUBAGENT_MIN_STEPS || requestedSteps > SUBAGENT_MAX_STEPS))
67
- return terminalResult(task, runtime, profile, 'policy_blocked', `maxSteps must be from ${SUBAGENT_MIN_STEPS} to ${SUBAGENT_MAX_STEPS}.`);
68
- const maxSteps = Math.min(requestedSteps ?? profile.maxSteps, profile.maxSteps);
62
+ const maxSteps = profile.maxSteps;
69
63
  const startedAt = performance.now();
70
- const bundle = options.contextBundle ?? (options.contextFiles
71
- ? await compatibilityBundle(task, profile, options.contextFiles, options.allowedTools, options.session)
72
- : await assembleWorkerContext(task, profile, options.session));
64
+ const bundle = options.contextBundle ?? await assembleWorkerContext(task, profile, options.session);
73
65
  if (bundle.policyBlock)
74
66
  return terminalResult(task, runtime, profile, 'policy_blocked', bundle.policyBlock, options.queueMs);
75
67
  const toolCallLog = [];
@@ -177,7 +169,7 @@ export async function runSubagent(taskInput, options) {
177
169
  telemetry.estimates.privateContextTokens = (usageIn ?? bundle.estimatedTokens) + (usageOut ?? 0);
178
170
  telemetry.estimates.resultCapsuleTokens = estimateValueTokens(capsule);
179
171
  telemetry.estimates.mainContextTokensAvoided = Math.max(0, telemetry.estimates.privateContextTokens - telemetry.estimates.taskCapsuleTokens - telemetry.estimates.resultCapsuleTokens);
180
- return withLegacyProjection(capsule, telemetry);
172
+ return { capsule, telemetry };
181
173
  }
182
174
  catch (error) {
183
175
  // Bounded, actionable provider-failure capsule (RT-03): a worker that dies
@@ -190,20 +182,16 @@ export async function runSubagent(taskInput, options) {
190
182
  const capsuleMessage = `${boundedMessage}. No usable worker output was produced; retry this subagent once with the same task, or do the work directly in the main conversation.`;
191
183
  const termination = options.deadlineExpired?.() ? 'deadline_exceeded' : options.abortSignal?.aborted ? 'cancelled' : 'provider_error';
192
184
  const result = terminalResult(task, runtime, profile, termination, capsuleMessage, options.queueMs);
193
- // Keep the raw provider message on the legacy `error` field so machine
194
- // consumers see exactly what the provider said (unchanged contract).
185
+ // Keep the raw provider message on `error` so machine consumers see exactly
186
+ // what the provider said (unchanged contract).
195
187
  result.error = rawMessage;
196
188
  result.capsule.changedPaths = [...changedPaths].sort();
197
189
  result.capsule.validation = [...validation];
198
190
  result.telemetry.estimates.resultCapsuleTokens = estimateValueTokens(result.capsule);
199
191
  result.telemetry.durationMs = performance.now() - startedAt;
200
- result.durationMs = result.telemetry.durationMs;
201
192
  result.telemetry.toolCalls = toolCallLog;
202
- result.toolCalls = toolCallLog;
203
193
  result.telemetry.toolCallCount = toolBudget.started;
204
- result.toolCallCount = toolBudget.started;
205
194
  result.telemetry.usage = { inputTokens: usageIn, outputTokens: usageOut };
206
- result.tokens = { in: usageIn, out: usageOut };
207
195
  return result;
208
196
  }
209
197
  finally {
@@ -226,7 +214,7 @@ export function createSubagentTool(options) {
226
214
  return terminalResult(task, runtime, profile, 'policy_blocked', options.blockedReason);
227
215
  return await coordinator.submit({
228
216
  id, mode: task.mode, signal: context.abortSignal,
229
- run: ({ signal, queueMs, deadlineExpired }) => runSubagent(task, { runtime, profile, abortSignal: signal, deadlineExpired, queueMs, session: options.session, mutationPolicy: options.mutationPolicy, ...(options.contextFiles ? { contextFiles: options.contextFiles } : {}) }),
217
+ run: ({ signal, queueMs, deadlineExpired }) => runSubagent(task, { runtime, profile, abortSignal: signal, deadlineExpired, queueMs, session: options.session, mutationPolicy: options.mutationPolicy }),
230
218
  terminal: (termination, queueMs) => terminalResult(task, runtime, profile, termination, termination === 'cancelled'
231
219
  ? 'Worker cancelled before completion.'
232
220
  : termination === 'deadline_exceeded'
@@ -1,7 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { tool } from 'ai';
4
- import { rgPath } from '@vscode/ripgrep';
5
4
  import { z } from 'zod';
6
5
  import { walkDir } from '../../utils/fs.js';
7
6
  import { workspaceRoot } from '../../utils/path.js';
@@ -15,7 +14,7 @@ import { runDedupedTool, discoverScopedContext, withScopedContext, hazeToolConte
15
14
  import { prepareWorkspaceMutation, prepareWorkspaceRead, prepareWorkspaceWritePath } from './workspaceFile.js';
16
15
  import { DEFAULT_READ_LINES, INLINE_DIFF_LINE_LIMIT, MAX_OUTPUT_CHARS, sourceOutlineEntries } from './fileToolShared.js';
17
16
  import { createIgnoreClassifier } from './gitIgnore.js';
18
- import { runRipgrepBounded } from './grepRunner.js';
17
+ import { runRipgrepBounded, resolveRipgrepExecutable } from './grepRunner.js';
19
18
  import { secretSearchExcludeGlobs } from '../../core/safety/secretPaths.js';
20
19
  import { EXACT_MUTATION_BYTES } from '../../core/limits.js';
21
20
  import { WRITE_FILE_CHUNK_BYTES } from '../../core/agent/budgets.js';
@@ -218,7 +217,7 @@ export const fileTools = {
218
217
  args.push('--iglob', secretGlob);
219
218
  args.push('--glob', '!**/.git/**', '--glob', '!**/node_modules/**');
220
219
  args.push('--', pattern, absolutePath);
221
- const result = await runRipgrepBounded({ executable: rgPath, args, cwd: workspaceRoot(), maxMatches, signal: context.abortSignal });
220
+ const result = await runRipgrepBounded({ executable: resolveRipgrepExecutable(), args, cwd: workspaceRoot(), maxMatches, signal: context.abortSignal });
222
221
  const stdout = result.stdout;
223
222
  if (result.aborted)
224
223
  throw new Error('ripgrep aborted');
@@ -1,4 +1,4 @@
1
- import fs from 'fs-extra';
1
+ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import ignoreFactory from 'ignore';
4
4
  import { workspaceRelativePath, workspaceRoot } from '../../utils/path.js';
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Prefer the bundled ripgrep binary; fall back to a system `rg` on PATH when
3
+ * the bundled download is absent (installs where dependency lifecycle scripts
4
+ * are blocked never materialize `@vscode/ripgrep/bin/rg`). Returns the bundled
5
+ * path unchanged when no system rg exists so spawn errors still name the
6
+ * expected binary. Injectable for deterministic tests.
7
+ */
8
+ export declare function resolveRipgrepExecutable(options?: {
9
+ bundledPath?: string;
10
+ }): string;
1
11
  /**
2
12
  * Line-oriented bounded ripgrep runner built on the shared bounded-process
3
13
  * primitive, so spawn/timeout/abort/process-group teardown behavior is
@@ -1,6 +1,30 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { delimiter, join } from 'node:path';
1
3
  import { StringDecoder } from 'node:string_decoder';
4
+ import { rgPath } from '@vscode/ripgrep';
2
5
  import { runBoundedProcess } from '../../core/process/runBoundedProcess.js';
3
6
  import { GREP_STREAM_BYTES, PROCESS_STDERR_BYTES, TEXT_LINE_BYTES } from '../../core/limits.js';
7
+ /**
8
+ * Prefer the bundled ripgrep binary; fall back to a system `rg` on PATH when
9
+ * the bundled download is absent (installs where dependency lifecycle scripts
10
+ * are blocked never materialize `@vscode/ripgrep/bin/rg`). Returns the bundled
11
+ * path unchanged when no system rg exists so spawn errors still name the
12
+ * expected binary. Injectable for deterministic tests.
13
+ */
14
+ export function resolveRipgrepExecutable(options) {
15
+ const bundled = options?.bundledPath ?? rgPath;
16
+ if (existsSync(bundled))
17
+ return bundled;
18
+ const name = process.platform === 'win32' ? 'rg.exe' : 'rg';
19
+ for (const dir of process.env.PATH?.split(delimiter) ?? []) {
20
+ if (!dir)
21
+ continue;
22
+ const candidate = join(dir, name);
23
+ if (existsSync(candidate))
24
+ return candidate;
25
+ }
26
+ return bundled;
27
+ }
4
28
  /**
5
29
  * Line-oriented bounded ripgrep runner built on the shared bounded-process
6
30
  * primitive, so spawn/timeout/abort/process-group teardown behavior is
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { type ContextFile } from '../../config/contextFiles.js';
3
3
  import { type HazeToolContext, type ToolExecutionContext } from './toolContextState.js';
4
4
  export type { HazeToolContext, PostMutationDiagnostics, ToolExecutionContext } from './toolContextState.js';
5
- export { hazeContext, isHazeToolContext } from './toolContextState.js';
5
+ export { hazeContext } from './toolContextState.js';
6
6
  /**
7
7
  * Turn-scoped tool-call orchestration shared by every built-in tool: in-flight
8
8
  * and completed-call deduplication, a mutation epoch that invalidates read
@@ -10,8 +10,7 @@ export { hazeContext, isHazeToolContext } from './toolContextState.js';
10
10
  * project instructions (CLAUDE.md / AGENTS.md below the cwd).
11
11
  *
12
12
  * All state lives on per-tool `context` values, which the agent turn owns and
13
- * passes to the AI SDK. Tests and older callers may still provide the legacy
14
- * `experimental_context` shape. Nothing here is persisted.
13
+ * passes to the AI SDK. Nothing here is persisted.
15
14
  */
16
15
  export declare const hazeToolContextSchema: z.ZodCustom<HazeToolContext, HazeToolContext>;
17
16
  export declare function toolsContextFor<T extends Record<string, unknown>>(tools: T, context: HazeToolContext): Partial<Record<keyof T, HazeToolContext>>;
@@ -5,7 +5,7 @@ import { workspacePathKey, workspaceRoot } from '../../utils/path.js';
5
5
  import { isFailedToolOutput, requiresReadFileRecovery, toolInputField } from '../../core/agent/toolResults.js';
6
6
  import { HazeToolError } from './failures.js';
7
7
  import { hazeContext, isHazeToolContext } from './toolContextState.js';
8
- export { hazeContext, isHazeToolContext } from './toolContextState.js';
8
+ export { hazeContext } from './toolContextState.js';
9
9
  /**
10
10
  * Turn-scoped tool-call orchestration shared by every built-in tool: in-flight
11
11
  * and completed-call deduplication, a mutation epoch that invalidates read
@@ -13,8 +13,7 @@ export { hazeContext, isHazeToolContext } from './toolContextState.js';
13
13
  * project instructions (CLAUDE.md / AGENTS.md below the cwd).
14
14
  *
15
15
  * All state lives on per-tool `context` values, which the agent turn owns and
16
- * passes to the AI SDK. Tests and older callers may still provide the legacy
17
- * `experimental_context` shape. Nothing here is persisted.
16
+ * passes to the AI SDK. Nothing here is persisted.
18
17
  */
19
18
  export const hazeToolContextSchema = z.custom(isHazeToolContext, 'Invalid haze tool context');
20
19
  export function toolsContextFor(tools, context) {
@@ -11,7 +11,6 @@ import type { WorkspaceMutationOwner, WorkspaceMutationPolicy } from '../../core
11
11
  export type ToolExecutionContext = {
12
12
  abortSignal?: AbortSignal;
13
13
  context?: unknown;
14
- experimental_context?: unknown;
15
14
  };
16
15
  export type PostMutationDiagnostics = (paths: readonly string[]) => Promise<unknown | undefined>;
17
16
  export type HazeToolContext = {
@@ -27,8 +27,5 @@ export function isHazeToolContext(value) {
27
27
  && validOptional('postMutationDiagnostics', field => typeof field === 'function');
28
28
  }
29
29
  export function hazeContext(context) {
30
- const value = typeof context.context === 'object' && context.context != null
31
- ? context.context
32
- : context.experimental_context;
33
- return isHazeToolContext(value) ? value : undefined;
30
+ return isHazeToolContext(context.context) ? context.context : undefined;
34
31
  }
@@ -16,10 +16,3 @@ export interface WorkerContextBundle {
16
16
  }
17
17
  export declare function workerTaskMessage(task: SubagentTaskCapsule): string;
18
18
  export declare function assembleWorkerContext(task: SubagentTaskCapsule, profile: SubagentExecutionProfile, session?: PromptSession): Promise<WorkerContextBundle>;
19
- /**
20
- * Legacy compatibility bundle for callers (e.g. `/fleet`) that pass explicit
21
- * context files and an optional tool allowlist instead of letting the worker
22
- * resolve its own context. Moved from `llm/subagentRunner.ts` so the
23
- * runner stays free of `llm` imports.
24
- */
25
- export declare function compatibilityBundle(task: SubagentTaskCapsule, profile: SubagentExecutionProfile, contextFiles: ContextFile[], allowedTools: readonly string[] | undefined, session: PromptSession | undefined): Promise<WorkerContextBundle>;
@@ -53,20 +53,3 @@ export async function assembleWorkerContext(task, profile, session) {
53
53
  return { instructions: [], loadedPaths: new Set(), loadedSignatures: new Map(), systemPrompt: '', tools: {}, estimatedTokens: 0, taskTokens: estimateValueTokens(workerTaskMessage(task)), validatedScope: [], policyBlock: reason };
54
54
  }
55
55
  }
56
- /**
57
- * Legacy compatibility bundle for callers (e.g. `/fleet`) that pass explicit
58
- * context files and an optional tool allowlist instead of letting the worker
59
- * resolve its own context. Moved from `llm/subagentRunner.ts` so the
60
- * runner stays free of `llm` imports.
61
- */
62
- export async function compatibilityBundle(task, profile, contextFiles, allowedTools, session) {
63
- const instructions = contextFiles;
64
- const systemPrompt = buildSubagentPrompt(instructions, session, task.mode, profile);
65
- const tools = {};
66
- for (const name of allowedTools ?? MODE_TOOL_NAMES[task.mode])
67
- if (name in hazeTools)
68
- tools[name] = hazeTools[name];
69
- const taskTokens = estimateValueTokens(workerTaskMessage(task));
70
- const estimatedTokens = estimateTextTokens(systemPrompt) + taskTokens + estimateToolSchemas(tools).reduce((sum, value) => sum + value.tokens, 0);
71
- return { instructions, systemPrompt, tools, taskTokens, estimatedTokens, validatedScope: [], loadedPaths: new Set(instructions.map(file => file.path)), loadedSignatures: new Map(instructions.flatMap(file => file.signature ? [[file.path, file.signature]] : [])), ...(estimatedTokens > profile.maxInputTokens ? { policyBlock: `Worker input estimate ${estimatedTokens} exceeds profile ${profile.name} limit ${profile.maxInputTokens}.` } : {}) };
72
- }
@@ -1,4 +1,5 @@
1
- import fs from 'fs-extra';
1
+ import fs from 'node:fs/promises';
2
+ import { pathExists } from '../utils/fs.js';
2
3
  import path from 'node:path';
3
4
  import YAML from 'yaml';
4
5
  import { confinedResolve } from './confinement.js';
@@ -74,7 +75,7 @@ async function loadReference(dir, referencePath) {
74
75
  }
75
76
  export async function loadSkill(dir, source = 'global') {
76
77
  const skillPath = path.join(dir, 'SKILL.md');
77
- if (!(await fs.pathExists(skillPath)))
78
+ if (!(await pathExists(skillPath)))
78
79
  return null;
79
80
  const realSkillPath = await confinedResolve(dir, skillPath, 'SKILL.md', 'skill directory');
80
81
  if (isProtectedSecretPath(realSkillPath))
@@ -1,10 +1,12 @@
1
- import fs from 'fs-extra';
1
+ import fs from 'node:fs/promises';
2
+ import { pathExists, ensureDir } from '../utils/fs.js';
2
3
  import path from 'node:path';
3
4
  import { GLOBAL_SKILLS_DIR } from '../config/paths.js';
4
5
  import { loadSkill } from './SkillLoader.js';
5
6
  import { confinedResolve } from './confinement.js';
7
+ import { loadPluginSkills } from './plugins/runtime.js';
6
8
  async function loadRoot(root, containmentRoot, source, errors) {
7
- if (!(await fs.pathExists(root)))
9
+ if (!(await pathExists(root)))
8
10
  return [];
9
11
  if (source === 'project') {
10
12
  try {
@@ -50,11 +52,12 @@ export function resolveSkillCandidates(candidates, enabled = () => true) {
50
52
  }
51
53
  export async function loadSkillRegistry(cwd = process.cwd()) {
52
54
  const errors = [];
53
- await fs.ensureDir(GLOBAL_SKILLS_DIR);
55
+ await ensureDir(GLOBAL_SKILLS_DIR);
54
56
  const global = await loadRoot(GLOBAL_SKILLS_DIR, GLOBAL_SKILLS_DIR, 'global', errors);
55
57
  const projectRoot = path.join(cwd, '.haze', 'skills');
56
58
  const project = await loadRoot(projectRoot, cwd, 'project', errors);
57
- const candidates = [...project, ...global];
59
+ const plugins = await loadPluginSkills(errors);
60
+ const candidates = [...project, ...plugins, ...global];
58
61
  const skills = resolveSkillCandidates(candidates);
59
62
  return { skills, candidates, errors };
60
63
  }
@@ -1,5 +1,6 @@
1
1
  import { generateObject } from 'ai';
2
- import fs from 'fs-extra';
2
+ import fs from 'node:fs/promises';
3
+ import { ensureDir, move, pathExists } from '../../utils/fs.js';
3
4
  import path from 'node:path';
4
5
  import YAML from 'yaml';
5
6
  import { GLOBAL_SKILLS_DIR } from '../../config/paths.js';
@@ -239,10 +240,10 @@ async function skillTargetRoot(input) {
239
240
  return { root: GLOBAL_SKILLS_DIR, source: 'global' };
240
241
  const cwd = path.resolve(input.cwd ?? process.cwd());
241
242
  const hazeDir = path.join(cwd, '.haze');
242
- if (await fs.pathExists(hazeDir))
243
+ if (await pathExists(hazeDir))
243
244
  await confinedResolve(cwd, hazeDir, '.haze', 'workspace');
244
245
  const root = path.join(hazeDir, 'skills');
245
- await fs.ensureDir(root);
246
+ await ensureDir(root);
246
247
  await confinedResolve(cwd, root, '.haze/skills', 'workspace');
247
248
  return { root, source: 'project' };
248
249
  }
@@ -263,19 +264,19 @@ export async function createSkill(input) {
263
264
  const skillFile = path.join(dir, 'SKILL.md');
264
265
  // Never populate a pre-existing directory: it may contain symlinks planted by
265
266
  // repository content, and creation is expected to be new and atomic in scope.
266
- if (await fs.pathExists(dir))
267
+ if (await pathExists(dir))
267
268
  throw new Error(`Skill already exists: ${finalName}`);
268
- await fs.ensureDir(dir);
269
- if (await fs.pathExists(skillFile))
269
+ await ensureDir(dir);
270
+ if (await pathExists(skillFile))
270
271
  throw new Error(`Skill already exists: ${finalName}`);
271
272
  for (const generatedFile of generated.files) {
272
273
  const safePath = assertSafeGeneratedFile(generatedFile.path);
273
274
  const absolutePath = path.join(dir, safePath);
274
- await fs.ensureDir(path.dirname(absolutePath));
275
+ await ensureDir(path.dirname(absolutePath));
275
276
  const content = safePath === 'SKILL.md' ? withSkillName(withStandardRequirements(generatedFile.content), finalName) : generatedFile.content;
276
277
  await fs.writeFile(absolutePath, content, 'utf8');
277
278
  }
278
- if (!(await fs.pathExists(skillFile))) {
279
+ if (!(await pathExists(skillFile))) {
279
280
  const fallback = fallbackSkill(normalizedInput);
280
281
  await fs.writeFile(skillFile, fallback.files[0].content, 'utf8');
281
282
  }
@@ -284,9 +285,9 @@ export async function createSkill(input) {
284
285
  throw new Error('Generated skill is missing SKILL.md');
285
286
  if (loaded.name !== finalName) {
286
287
  const nextDir = path.join(root, loaded.name);
287
- if (await fs.pathExists(nextDir))
288
+ if (await pathExists(nextDir))
288
289
  throw new Error(`Skill already exists: ${loaded.name}`);
289
- await fs.move(dir, nextDir);
290
+ await move(dir, nextDir);
290
291
  return { name: loaded.name, dir: nextDir, file: path.join(nextDir, 'SKILL.md') };
291
292
  }
292
293
  return { name: finalName, dir, file: skillFile };
@@ -0,0 +1,25 @@
1
+ export interface PluginInstallResult {
2
+ name: string;
3
+ version?: string;
4
+ alreadyInstalled: boolean;
5
+ warnings: string[];
6
+ }
7
+ export interface InstalledPlugin {
8
+ name: string;
9
+ version?: string;
10
+ }
11
+ export interface PluginEnumeration {
12
+ plugins: InstalledPlugin[];
13
+ errors: {
14
+ directory: string;
15
+ message: string;
16
+ }[];
17
+ }
18
+ export interface PluginRemoveResult {
19
+ name: string;
20
+ retained: string[];
21
+ }
22
+ export declare function installPlugin(sourceDir: string, pluginName?: string): Promise<PluginInstallResult>;
23
+ export declare function enumeratePlugins(): Promise<PluginEnumeration>;
24
+ export declare function listPlugins(): Promise<InstalledPlugin[]>;
25
+ export declare function removePlugin(name: string): Promise<PluginRemoveResult>;