@denizokcu/haze 0.11.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +28 -14
  3. package/SECURITY.md +5 -3
  4. package/dist/buildInfo.json +3 -3
  5. package/dist/cli/chat/TaskBar.js +1 -1
  6. package/dist/cli/chat/chatMetrics.d.ts +2 -2
  7. package/dist/cli/chat/chatMetrics.js +1 -1
  8. package/dist/cli/chat/fileMentionSuggestions.js +1 -1
  9. package/dist/cli/chat/inputSuggestions.d.ts +8 -16
  10. package/dist/cli/chat/inputSuggestions.js +10 -41
  11. package/dist/cli/chat/messages.d.ts +0 -2
  12. package/dist/cli/chat/messages.js +5 -5
  13. package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
  14. package/dist/cli/chat/turnState.d.ts +1 -1
  15. package/dist/cli/chat/wizardDispatch.d.ts +90 -28
  16. package/dist/cli/chat/wizardDispatch.js +257 -130
  17. package/dist/cli/commands/chat.js +61 -77
  18. package/dist/cli/commands/chatModes.d.ts +8 -1
  19. package/dist/cli/commands/chatModes.js +9 -44
  20. package/dist/cli/commands/commandHelp.js +2 -0
  21. package/dist/cli/commands/commands.js +2 -0
  22. package/dist/cli/commands/doctor.js +1 -1
  23. package/dist/cli/commands/formatters.d.ts +3 -3
  24. package/dist/cli/commands/formatters.js +12 -25
  25. package/dist/cli/commands/providerWizard.js +2 -3
  26. package/dist/cli/commands/runCommand.js +1 -1
  27. package/dist/cli/commands/serverWizard.d.ts +34 -0
  28. package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
  29. package/dist/cli/commands/settingsSummary.js +2 -0
  30. package/dist/cli/commands/skillsWizard.d.ts +41 -0
  31. package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
  32. package/dist/cli/commands/streaming/abortCause.d.ts +2 -1
  33. package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
  34. package/dist/cli/commands/streaming/agentAttempt.js +79 -0
  35. package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
  36. package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
  37. package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
  38. package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
  39. package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
  40. package/dist/cli/commands/streaming/attemptSetup.js +167 -0
  41. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
  42. package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
  43. package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
  44. package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
  45. package/dist/cli/commands/streaming/stallRecovery.js +105 -0
  46. package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
  47. package/dist/cli/commands/streaming/streamLoop.js +448 -0
  48. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +14 -0
  49. package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
  50. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
  51. package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
  52. package/dist/cli/commands/streaming/turnRuntime.js +6 -0
  53. package/dist/cli/commands/streaming.d.ts +14 -25
  54. package/dist/cli/commands/streaming.js +43 -754
  55. package/dist/cli/commands/themesCommand.d.ts +17 -0
  56. package/dist/cli/commands/themesCommand.js +24 -0
  57. package/dist/cli/commands/wizardFlow.d.ts +341 -0
  58. package/dist/cli/commands/wizardFlow.js +397 -0
  59. package/dist/cli/contextReport.js +3 -0
  60. package/dist/cli/index.js +1 -1
  61. package/dist/config/contextFiles.js +9 -3
  62. package/dist/config/inputHistory.d.ts +0 -1
  63. package/dist/config/inputHistory.js +1 -1
  64. package/dist/config/modelDiscovery.d.ts +0 -15
  65. package/dist/config/modelDiscovery.js +1 -1
  66. package/dist/config/settings.d.ts +9 -0
  67. package/dist/config/settings.js +4 -0
  68. package/dist/config/skillSettings.js +4 -4
  69. package/dist/config/updateCheck.d.ts +0 -1
  70. package/dist/config/updateCheck.js +1 -1
  71. package/dist/core/agent/budgets.d.ts +63 -1
  72. package/dist/core/agent/budgets.js +84 -1
  73. package/dist/core/agent/compaction.js +1 -1
  74. package/dist/core/agent/completionController.d.ts +7 -13
  75. package/dist/core/agent/completionController.js +17 -8
  76. package/dist/core/agent/contextBudget.d.ts +0 -4
  77. package/dist/core/agent/contextBudget.js +3 -3
  78. package/dist/core/agent/errors.d.ts +0 -1
  79. package/dist/core/agent/errors.js +1 -1
  80. package/dist/core/agent/events.d.ts +5 -1
  81. package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
  82. package/dist/core/agent/goalPolicy.js +106 -0
  83. package/dist/core/agent/requestAssembly.d.ts +2 -2
  84. package/dist/core/agent/requestAssembly.js +16 -4
  85. package/dist/core/agent/toolCapabilities.d.ts +2 -2
  86. package/dist/core/agent/toolCapabilities.js +5 -5
  87. package/dist/core/agent/toolOutputStore.js +1 -1
  88. package/dist/core/agent/toolResults.js +1 -1
  89. package/dist/core/agent/workState.d.ts +6 -3
  90. package/dist/core/agent/workState.js +62 -7
  91. package/dist/core/attachments/imageAttachments.js +90 -42
  92. package/dist/core/deadline.d.ts +0 -6
  93. package/dist/core/deadline.js +1 -1
  94. package/dist/core/io/boundedRead.js +1 -1
  95. package/dist/core/limits.d.ts +51 -0
  96. package/dist/core/limits.js +51 -0
  97. package/dist/core/log/llmLog.js +1 -1
  98. package/dist/core/process/backgroundRegistry.d.ts +2 -3
  99. package/dist/core/process/backgroundRegistry.js +10 -6
  100. package/dist/core/process/userShell.d.ts +16 -0
  101. package/dist/core/process/userShell.js +59 -0
  102. package/dist/core/safety/secretPaths.d.ts +18 -0
  103. package/dist/core/safety/secretPaths.js +115 -0
  104. package/dist/core/safety/shellClassifier.d.ts +11 -0
  105. package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
  106. package/dist/core/safety/urlGuard.d.ts +1 -1
  107. package/dist/core/session/sessionSlimming.d.ts +0 -3
  108. package/dist/core/session/sessionSlimming.js +2 -3
  109. package/dist/core/session/sessionStore.d.ts +1 -0
  110. package/dist/core/session/sessionStore.js +39 -20
  111. package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
  112. package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
  113. package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
  114. package/dist/core/shellOutput/registry.d.ts +2 -0
  115. package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
  116. package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
  117. package/dist/core/subagent/contracts.d.ts +2 -14
  118. package/dist/core/subagent/contracts.js +3 -3
  119. package/dist/core/subagent/executionProfiles.js +2 -2
  120. package/dist/core/subagent/subagentRunner.js +3 -4
  121. package/dist/core/toolOutput/reduction.d.ts +0 -12
  122. package/dist/core/toolOutput/reduction.js +1 -1
  123. package/dist/core/validation/outputParser.d.ts +2 -2
  124. package/dist/llm/client.js +5 -1
  125. package/dist/llm/hazeTools.d.ts +139 -124
  126. package/dist/llm/hazeTools.js +20 -11
  127. package/dist/llm/initPrompt.js +1 -1
  128. package/dist/llm/lsp/client.d.ts +45 -0
  129. package/dist/llm/lsp/client.js +195 -0
  130. package/dist/llm/lsp/pool.d.ts +23 -0
  131. package/dist/llm/lsp/pool.js +86 -0
  132. package/dist/llm/lsp/protocol.d.ts +64 -0
  133. package/dist/llm/lsp/protocol.js +128 -0
  134. package/dist/llm/lsp/requests.d.ts +94 -0
  135. package/dist/llm/lsp/requests.js +119 -0
  136. package/dist/llm/lspTools.d.ts +3824 -570
  137. package/dist/llm/lspTools.js +65 -1
  138. package/dist/llm/openaiCodex.d.ts +0 -2
  139. package/dist/llm/openaiCodex.js +0 -4
  140. package/dist/llm/openaiCodexOAuth.d.ts +0 -3
  141. package/dist/llm/openaiCodexOAuth.js +6 -3
  142. package/dist/llm/requestContext.d.ts +5 -1
  143. package/dist/llm/requestContext.js +25 -2
  144. package/dist/llm/systemPrompt.d.ts +1 -0
  145. package/dist/llm/systemPrompt.js +16 -7
  146. package/dist/llm/toolResultTypes.d.ts +1 -15
  147. package/dist/llm/toolResultTypes.js +1 -4
  148. package/dist/llm/tools/editMatch.d.ts +0 -9
  149. package/dist/llm/tools/editMatch.js +1 -1
  150. package/dist/llm/tools/failures.d.ts +6 -0
  151. package/dist/llm/tools/failures.js +8 -2
  152. package/dist/llm/tools/fetchTool.js +1 -1
  153. package/dist/llm/tools/fileToolShared.d.ts +4 -2
  154. package/dist/llm/tools/fileToolShared.js +9 -5
  155. package/dist/llm/tools/gitIgnore.d.ts +25 -32
  156. package/dist/llm/tools/gitIgnore.js +216 -98
  157. package/dist/llm/tools/grepParse.d.ts +2 -1
  158. package/dist/llm/tools/grepRunner.d.ts +1 -1
  159. package/dist/llm/tools/grepRunner.js +2 -2
  160. package/dist/llm/tools/outputCap.d.ts +2 -7
  161. package/dist/llm/tools/outputCap.js +3 -3
  162. package/dist/llm/tools/processTool.d.ts +16 -16
  163. package/dist/llm/tools/processTool.js +1 -1
  164. package/dist/llm/tools/readRecovery.d.ts +0 -2
  165. package/dist/llm/tools/readRecovery.js +4 -2
  166. package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
  167. package/dist/llm/tools/{bashTool.js → shellTool.js} +18 -14
  168. package/dist/llm/tools/toolContext.js +5 -5
  169. package/dist/llm/tools/workspaceFile.d.ts +4 -4
  170. package/dist/llm/tools/workspaceFile.js +29 -17
  171. package/dist/llm/webFetch.d.ts +1 -1
  172. package/dist/skills/SkillLoader.d.ts +1 -11
  173. package/dist/skills/SkillLoader.js +1 -2
  174. package/dist/skills/types.d.ts +2 -1
  175. package/dist/ui/components/Header.js +1 -1
  176. package/dist/ui/components/MarkdownText.js +10 -10
  177. package/dist/ui/components/TextInput.d.ts +1 -1
  178. package/dist/ui/components/TextInput.js +2 -2
  179. package/dist/ui/terminalColors.d.ts +29 -0
  180. package/dist/ui/terminalColors.js +47 -0
  181. package/dist/ui/theme.d.ts +105 -10
  182. package/dist/ui/theme.js +126 -15
  183. package/dist/ui/themes/af-magic.d.ts +7 -0
  184. package/dist/ui/themes/af-magic.js +25 -0
  185. package/dist/ui/themes/agnoster.d.ts +10 -0
  186. package/dist/ui/themes/agnoster.js +40 -0
  187. package/dist/ui/themes/bira.d.ts +10 -0
  188. package/dist/ui/themes/bira.js +28 -0
  189. package/dist/ui/themes/bureau.d.ts +10 -0
  190. package/dist/ui/themes/bureau.js +28 -0
  191. package/dist/ui/themes/clean.d.ts +9 -0
  192. package/dist/ui/themes/clean.js +27 -0
  193. package/dist/ui/themes/cloud.d.ts +6 -0
  194. package/dist/ui/themes/cloud.js +24 -0
  195. package/dist/ui/themes/dst.d.ts +10 -0
  196. package/dist/ui/themes/dst.js +28 -0
  197. package/dist/ui/themes/fishy.d.ts +7 -0
  198. package/dist/ui/themes/fishy.js +25 -0
  199. package/dist/ui/themes/index.d.ts +8 -0
  200. package/dist/ui/themes/index.js +36 -0
  201. package/dist/ui/themes/light.d.ts +3 -0
  202. package/dist/ui/themes/light.js +21 -0
  203. package/dist/ui/themes/purple.d.ts +7 -0
  204. package/dist/ui/themes/purple.js +26 -0
  205. package/dist/ui/themes/robbyrussell.d.ts +8 -0
  206. package/dist/ui/themes/robbyrussell.js +26 -0
  207. package/dist/ui/themes/solarized-dark.d.ts +16 -0
  208. package/dist/ui/themes/solarized-dark.js +44 -0
  209. package/dist/ui/themes/solarized-light.d.ts +12 -0
  210. package/dist/ui/themes/solarized-light.js +40 -0
  211. package/dist/ui/themes/steeef.d.ts +11 -0
  212. package/dist/ui/themes/steeef.js +29 -0
  213. package/dist/utils/buildInfo.d.ts +6 -13
  214. package/dist/utils/buildInfo.js +6 -15
  215. package/dist/utils/fs.d.ts +7 -5
  216. package/dist/utils/fs.js +5 -2
  217. package/dist/utils/path.d.ts +0 -1
  218. package/dist/utils/path.js +1 -1
  219. package/package.json +6 -4
  220. package/dist/cli/commands/lspWizard.d.ts +0 -14
  221. package/dist/cli/commands/lspWizard.js +0 -44
  222. package/dist/cli/commands/mcpWizard.d.ts +0 -15
  223. package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
  224. package/dist/cli/commands/skillConfirmRemove.js +0 -20
  225. package/dist/cli/commands/skillCreation.d.ts +0 -12
  226. package/dist/cli/commands/skillCreation.js +0 -14
  227. package/dist/cli/commands/skillWizard.d.ts +0 -17
  228. package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
  229. package/dist/cli/commands/streaming/idleTimer.js +0 -24
  230. package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -27
  231. package/dist/cli/commands/streaming/turnOutcome.js +0 -29
  232. package/dist/cli/commands/wizardActions.d.ts +0 -47
  233. package/dist/cli/commands/wizardActions.js +0 -47
  234. package/dist/cli/commands/wizardInput.d.ts +0 -4
  235. package/dist/cli/commands/wizardInput.js +0 -19
  236. package/dist/cli/commands/wizardPrompts.d.ts +0 -22
  237. package/dist/cli/commands/wizardPrompts.js +0 -58
  238. package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
  239. package/dist/cli/commands/wizardSuggestions.js +0 -190
  240. package/dist/cli/commands/wizardTransition.d.ts +0 -37
  241. package/dist/cli/commands/wizardTransition.js +0 -43
  242. package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
  243. package/dist/core/agent/toolExecutionBudget.js +0 -49
  244. package/dist/core/agent/turnBudget.d.ts +0 -35
  245. package/dist/core/agent/turnBudget.js +0 -27
  246. package/dist/core/bashOutput/ansi.d.ts +0 -1
  247. package/dist/core/bashOutput/ansi.js +0 -7
  248. package/dist/core/bashOutput/registry.d.ts +0 -4
  249. package/dist/core/goal/completionPolicy.js +0 -43
  250. package/dist/core/goal/requestClassifier.d.ts +0 -3
  251. package/dist/core/goal/requestClassifier.js +0 -18
  252. package/dist/core/goal/sessionGoal.d.ts +0 -8
  253. package/dist/core/goal/sessionGoal.js +0 -30
  254. package/dist/core/limits/byteBudgets.d.ts +0 -20
  255. package/dist/core/limits/byteBudgets.js +0 -20
  256. package/dist/core/limits/textBudgets.d.ts +0 -25
  257. package/dist/core/limits/textBudgets.js +0 -25
  258. package/dist/core/safety/bashClassifier.d.ts +0 -10
  259. package/dist/llm/lsp.d.ts +0 -149
  260. package/dist/llm/lsp.js +0 -368
  261. package/dist/ui/components/ErrorView.d.ts +0 -4
  262. package/dist/ui/components/ErrorView.js +0 -7
  263. package/dist/utils/yaml.d.ts +0 -2
  264. package/dist/utils/yaml.js +0 -8
  265. package/examples/skills/files/SKILL.md +0 -16
  266. package/examples/skills/files/examples/file-editing.md +0 -3
  267. /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
  268. /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
  269. /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
  270. /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
  271. /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
  272. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
  273. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
  274. /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
  275. /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
  276. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
  277. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
  278. /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
@@ -4,8 +4,8 @@
4
4
  * Capabilities describe what a tool *can do* so turn-policy code can reason
5
5
  * about a turn without hard-coding tool names in every decision site. They are
6
6
  * metadata for policy/observability, never an execution gate (mirroring the
7
- * bash-classifier contract): the actual effect of a call is still determined at
8
- * runtime (e.g. a `bash` call is only validation when its command is a
7
+ * shell-classifier contract): the actual effect of a call is still determined at
8
+ * runtime (e.g. a `shell` call is only validation when its command is a
9
9
  * classifier-confirmed validation command).
10
10
  *
11
11
  * Kept provider/UI-agnostic (no `ai`/Ink imports) so it is unit-testable in
@@ -22,10 +22,10 @@ const CAPABILITY_MAP = {
22
22
  writeFile: ['mutate'],
23
23
  editFile: ['mutate'],
24
24
  replaceLines: ['mutate'],
25
- // Process execution. A bash call becomes validation only when its command is
25
+ // Process execution. A shell call becomes validation only when its command is
26
26
  // a classifier-confirmed validation command (see work state); that runtime
27
27
  // fact is tracked separately as a validation event, not as a static trait.
28
- bash: ['process'],
28
+ shell: ['process'],
29
29
  process: ['process'],
30
30
  // Coordination / durable state.
31
31
  writeTasks: ['coordinate'],
@@ -49,7 +49,7 @@ export function isMutatingCapability(name) {
49
49
  }
50
50
  /** Tools that can act as a validation step (runtime-classifier dependent). */
51
51
  export function isValidationCapable(name) {
52
- return hasCapability(name, 'validate') || name === 'bash';
52
+ return hasCapability(name, 'validate') || name === 'shell';
53
53
  }
54
54
  /** Read/discovery-only built-in tools (no mutation side effects). */
55
55
  export function isReadOrDiscoveryCapability(name) {
@@ -1,5 +1,5 @@
1
1
  import crypto from 'node:crypto';
2
- import { TOOL_OUTPUT_ENTRY_BYTES, TOOL_OUTPUT_TOTAL_BYTES } from '../limits/byteBudgets.js';
2
+ import { TOOL_OUTPUT_ENTRY_BYTES, TOOL_OUTPUT_TOTAL_BYTES } from '../limits.js';
3
3
  import { truncateUtf8AtBytes } from '../../utils/utf8.js';
4
4
  const outputs = new Map();
5
5
  const dynamicOutputs = new Map();
@@ -52,7 +52,7 @@ export function safeToolFailureDetails(output) {
52
52
  : typeof value.signal === 'string' ? 'process_signal'
53
53
  : undefined);
54
54
  // Only the dedicated Haze failure shape guarantees that `error` is a bounded
55
- // local diagnostic. Bash stderr and third-party fields may contain secrets.
55
+ // local diagnostic. Shell stderr and third-party fields may contain secrets.
56
56
  const error = structuredHazeFailure && typeof value.error === 'string' ? boundedSingleLine(value.error) : undefined;
57
57
  return { ...(errorCode ? { errorCode } : {}), ...(error ? { error } : {}), ...(missingExecutable ? { missingExecutable } : {}) };
58
58
  }
@@ -1,9 +1,9 @@
1
- import type { RequestIntent } from '../goal/requestClassifier.js';
1
+ import type { RequestIntent } from './goalPolicy.js';
2
2
  import { type ValidationKind, type ValidationSummary } from '../../llm/toolResultTypes.js';
3
3
  export type WorkFileAction = 'read' | 'created' | 'modified';
4
4
  export type WorkValidationStatus = 'pending' | 'passed' | 'failed';
5
- export type WorkStatus = 'active' | 'needs-user' | 'blocked' | 'complete' | 'aborted';
6
- export type WorkPhase = 'starting' | 'inspecting' | 'editing' | 'validating' | 'summarizing' | 'done';
5
+ type WorkStatus = 'active' | 'needs-user' | 'blocked' | 'complete' | 'aborted';
6
+ type WorkPhase = 'starting' | 'inspecting' | 'editing' | 'validating' | 'summarizing' | 'done';
7
7
  /**
8
8
  * Derived validation outcome for a turn, used as bounded completion evidence.
9
9
  * - `passed`: a classifier-confirmed validation passed after the latest mutation.
@@ -113,6 +113,8 @@ export interface WorkToolEvent {
113
113
  output?: unknown;
114
114
  duplicateSkipped?: boolean;
115
115
  }
116
+ /** Strictly recognize direct execution of one file changed during this goal. */
117
+ export declare function executedMutatedArtifact(command: string, state: WorkState): string | undefined;
116
118
  /** Extract a classifier-confirmed validation summary from a tool output, if any. */
117
119
  export declare function validationSummaryFromOutput(output: unknown): ValidationSummary | undefined;
118
120
  export declare function createWorkState(goal: string, intent: RequestIntent, successCriteria: string[], now?: number): WorkState;
@@ -124,3 +126,4 @@ export declare function observeWorkToolEvent(state: WorkState, event: WorkToolEv
124
126
  */
125
127
  export declare function deriveValidationOutcome(state: WorkState): ValidationOutcome;
126
128
  export declare function workStatePrompt(state: WorkState): string;
129
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { isValidationSummary } from '../../llm/toolResultTypes.js';
2
2
  import { toolInputField, toolOutputOk } from './toolResults.js';
3
+ import { workspacePathKey } from '../../utils/path.js';
3
4
  /** Request intents where a missing validation is itself meaningful evidence. */
4
5
  export function intentExpectsValidation(intent) {
5
6
  return intent === 'implement' || intent === 'fix' || intent === 'test';
@@ -99,6 +100,56 @@ function upsertValidation(state, command, status, summary, kind) {
99
100
  else
100
101
  state.validationCommands.push({ command, status });
101
102
  }
103
+ const ARTIFACT_LAUNCHERS = new Set(['node', 'python', 'python3', 'ruby', 'php', 'perl', 'sh', 'bash', 'zsh', 'fish', 'csh', 'tcsh', 'tsx', 'ts-node', 'rscript', 'lua']);
104
+ function shellWords(command) {
105
+ return (command.match(/(?:[^\s"']+|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+/g) ?? [])
106
+ .map(word => ((word.startsWith('"') && word.endsWith('"')) || (word.startsWith("'") && word.endsWith("'")) ? word.slice(1, -1) : word));
107
+ }
108
+ /** Strictly recognize direct execution of one file changed during this goal. */
109
+ export function executedMutatedArtifact(command, state) {
110
+ // Chaining and pipelines can mask the artifact's exit status, so they are not evidence.
111
+ if (/&&|\|\||[;|]/.test(command))
112
+ return undefined;
113
+ const words = shellWords(command.trim());
114
+ if (words.length === 0)
115
+ return undefined;
116
+ const executable = words[0].replace(/^.*[\\/]/, '').toLowerCase();
117
+ let candidate;
118
+ if (ARTIFACT_LAUNCHERS.has(executable)) {
119
+ const args = words.slice(1);
120
+ if (args.some(word => ['-e', '--eval', '-c', '-m'].includes(word)))
121
+ return undefined;
122
+ candidate = args.find(word => !word.startsWith('-'));
123
+ }
124
+ else if (executable === 'go' && words[1] === 'run') {
125
+ candidate = words.slice(2).find(word => !word.startsWith('-'));
126
+ }
127
+ else if (executable === 'pwsh' || executable === 'powershell') {
128
+ const fileIndex = words.findIndex(word => word.toLowerCase() === '-file');
129
+ candidate = fileIndex >= 0 ? words[fileIndex + 1] : undefined;
130
+ }
131
+ else if (executable === 'deno' || executable === 'bun') {
132
+ const args = words[1] === 'run' ? words.slice(2) : words.slice(1);
133
+ candidate = args.find(word => !word.startsWith('-'));
134
+ }
135
+ else if (executable === 'java') {
136
+ const jarIndex = words.indexOf('-jar');
137
+ candidate = jarIndex >= 0 ? words[jarIndex + 1] : undefined;
138
+ }
139
+ else if (words[0].startsWith('./') || words[0].startsWith('../')) {
140
+ candidate = words[0];
141
+ }
142
+ if (!candidate)
143
+ return undefined;
144
+ const candidateKey = workspacePathKey(candidate);
145
+ return state.files.find(file => file.action !== 'read' && workspacePathKey(file.path) === candidateKey)?.path;
146
+ }
147
+ function shellExitCode(output) {
148
+ if (typeof output !== 'object' || output == null)
149
+ return undefined;
150
+ const code = output.code;
151
+ return typeof code === 'number' || code === null ? code : undefined;
152
+ }
102
153
  /** Extract a classifier-confirmed validation summary from a tool output, if any. */
103
154
  export function validationSummaryFromOutput(output) {
104
155
  if (typeof output !== 'object' || output == null)
@@ -160,15 +211,19 @@ export function observeWorkToolEvent(state, event, now = Date.now()) {
160
211
  state.nextAction = `Read ${path}, then retry the edit with current content.`;
161
212
  }
162
213
  }
163
- // Only a classifier-confirmed bash command is a validation step. An arbitrary
164
- // shell call (inspection, mkdir, echo) is process work, not validation; the
165
- // bash tool embeds a `validationSummary` exactly when the classifier says so.
166
- if (event.toolName === 'bash') {
214
+ // Classifier-confirmed test/build commands are validation. A direct execution
215
+ // of a file changed during this goal is also bounded runtime evidence, provided
216
+ // the command is not chained or piped (which could mask its exit status).
217
+ if (event.toolName === 'shell') {
167
218
  const command = toolInputField(event.input, 'command');
168
219
  const summary = validationSummaryFromOutput(event.output);
169
- if (command && summary) {
170
- const status = summary.status === 'passed' ? 'passed' : 'failed';
171
- upsertValidation(state, command, status, summary.summaryText, summary.kind);
220
+ const artifact = command && !summary ? executedMutatedArtifact(command, state) : undefined;
221
+ if (command && (summary || artifact)) {
222
+ const exitCode = shellExitCode(event.output);
223
+ const passed = summary ? summary.status === 'passed' : ok && exitCode === 0;
224
+ const status = passed ? 'passed' : 'failed';
225
+ const summaryText = summary?.summaryText ?? (passed ? `Executed changed artifact ${artifact} successfully.` : `Changed artifact ${artifact} exited unsuccessfully.`);
226
+ upsertValidation(state, command, status, summaryText, summary?.kind ?? 'generic');
172
227
  state.validationSeq = seq;
173
228
  state.phase = 'validating';
174
229
  state.lastProgressAt = now;
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
- import { IMAGE_ATTACHMENT_BYTES, IMAGE_ATTACHMENTS_PER_MESSAGE } from '../limits/byteBudgets.js';
4
+ import { IMAGE_ATTACHMENT_BYTES, IMAGE_ATTACHMENTS_PER_MESSAGE } from '../limits.js';
5
5
  import { workspaceRoot } from '../../utils/path.js';
6
6
  import { formatBytes } from '../../utils/format.js';
7
7
  /**
@@ -22,23 +22,75 @@ export const IMAGE_MEDIA_TYPES = {
22
22
  '.webp': 'image/webp',
23
23
  };
24
24
  export const IMAGE_EXTENSIONS = Object.keys(IMAGE_MEDIA_TYPES);
25
- /**
26
- * `@token` candidates. The lookbehind keeps emails/handles intact
27
- * (`user@example.com` never matches at `@example.com`). Backslash escapes
28
- * (`\ `, `\(`, …) are part of the token so paths containing spaces — the
29
- * default macOS screenshot filename is `Bildschirmfoto YYYY-MM-DD um HH.MM.SS.png` —
30
- * survive intact. The escape is removed during resolution, never silently.
31
- */
32
- const MENTION_PATTERN = /(?<![\w@])@((?:[\w./~-]|\\.)+)/g;
33
- /**
34
- * Bare path candidates (no `@`). The lookahead requires a `/` somewhere in
35
- * the token so ordinary prose ("I named it cat.png") is never scanned; the
36
- * lookbehind stops mid-word matches and skips anything right after `@`
37
- * (handled by `MENTION_PATTERN`), `.`, or `/`. Backslash escapes are part
38
- * of the token. Routing (image attachment vs read-blessing) happens during
39
- * resolution based on extension and stat result.
40
- */
41
- const BARE_PATH_PATTERN = /(?<![\w.@/])(?=[\w.~/-]*\/)((?:[\w./~-]|\\.)+)(?![\w.-])/gi;
25
+ /** ASCII path-token characters accepted by the chat mention syntax. */
26
+ function isPathTokenCharacter(character) {
27
+ if (!character)
28
+ return false;
29
+ const code = character.charCodeAt(0);
30
+ return (code >= 48 && code <= 57)
31
+ || (code >= 65 && code <= 90)
32
+ || (code >= 97 && code <= 122)
33
+ || character === '_'
34
+ || character === '.'
35
+ || character === '/'
36
+ || character === '~'
37
+ || character === '-';
38
+ }
39
+ function isWordCharacter(character) {
40
+ if (!character)
41
+ return false;
42
+ const code = character.charCodeAt(0);
43
+ return (code >= 48 && code <= 57)
44
+ || (code >= 65 && code <= 90)
45
+ || (code >= 97 && code <= 122)
46
+ || character === '_';
47
+ }
48
+ /** Scan one path token, retaining backslash escapes verbatim. */
49
+ function pathTokenEnd(text, start) {
50
+ let index = start;
51
+ while (index < text.length) {
52
+ if (isPathTokenCharacter(text[index])) {
53
+ index++;
54
+ continue;
55
+ }
56
+ if (text[index] === '\\' && index + 1 < text.length && text[index + 1] !== '\n' && text[index + 1] !== '\r') {
57
+ index += 2;
58
+ continue;
59
+ }
60
+ break;
61
+ }
62
+ return index;
63
+ }
64
+ /** Linear-time scanner for explicit `@path` mentions. */
65
+ function explicitPathMentions(text) {
66
+ const mentions = [];
67
+ for (let index = 0; index < text.length; index++) {
68
+ if (text[index] !== '@' || isWordCharacter(text[index - 1]) || text[index - 1] === '@')
69
+ continue;
70
+ const end = pathTokenEnd(text, index + 1);
71
+ const token = text.slice(index + 1, end);
72
+ if (token && (token.includes('.') || token.includes('/')))
73
+ mentions.push({ mention: text.slice(index, end), token, start: index, end });
74
+ index = Math.max(index, end - 1);
75
+ }
76
+ return mentions;
77
+ }
78
+ /** Linear-time scanner for bare path tokens containing `/`. */
79
+ function barePathMentions(text) {
80
+ const mentions = [];
81
+ for (let index = 0; index < text.length; index++) {
82
+ const previous = text[index - 1];
83
+ if (!isPathTokenCharacter(text[index]) || isWordCharacter(previous) || previous === '.' || previous === '@' || previous === '/')
84
+ continue;
85
+ const end = pathTokenEnd(text, index);
86
+ const token = text.slice(index, end);
87
+ const next = text[end];
88
+ if (token.includes('/') && !isWordCharacter(next) && next !== '.' && next !== '-')
89
+ mentions.push({ mention: token, token, start: index, end });
90
+ index = Math.max(index, end - 1);
91
+ }
92
+ return mentions;
93
+ }
42
94
  /**
43
95
  * Extract path-like attachment candidates from prompt text. Two forms are
44
96
  * recognised:
@@ -54,23 +106,11 @@ const BARE_PATH_PATTERN = /(?<![\w.@/])(?=[\w.~/-]*\/)((?:[\w./~-]|\\.)+)(?![\w.
54
106
  export function extractPathMentions(text) {
55
107
  const mentions = [];
56
108
  const seen = new Set();
57
- for (const match of text.matchAll(MENTION_PATTERN)) {
58
- const token = match[1];
59
- if (!token || (!token.includes('.') && !token.includes('/')))
60
- continue;
61
- if (seen.has(match[0]))
109
+ for (const candidate of [...explicitPathMentions(text), ...barePathMentions(text)]) {
110
+ if (seen.has(candidate.mention))
62
111
  continue;
63
- seen.add(match[0]);
64
- mentions.push({ mention: match[0], token });
65
- }
66
- for (const match of text.matchAll(BARE_PATH_PATTERN)) {
67
- const token = match[1];
68
- if (!token || !token.includes('/'))
69
- continue;
70
- if (seen.has(match[0]))
71
- continue;
72
- seen.add(match[0]);
73
- mentions.push({ mention: match[0], token });
112
+ seen.add(candidate.mention);
113
+ mentions.push({ mention: candidate.mention, token: candidate.token });
74
114
  }
75
115
  return mentions;
76
116
  }
@@ -190,14 +230,22 @@ export async function resolveImageAttachments(text) {
190
230
  }
191
231
  if (strippedTokens.size === 0)
192
232
  return { text, attachments };
193
- // Strip attached mentions (explicit `@` and bare), then tidy the double
194
- // space a mid-line removal can leave behind. The lookbehind keeps line-
195
- // leading indentation intact.
196
- const cleaned = text
197
- .replace(MENTION_PATTERN, (mention, token) => strippedTokens.has(token) ? '' : mention)
198
- .replace(BARE_PATH_PATTERN, (match, token) => strippedTokens.has(token) ? '' : match)
199
- .replace(/(?<=[^\n])[ \t]{2,}/g, ' ')
200
- .trim();
233
+ // Strip attached mentions (explicit `@` and bare) by their scanner ranges,
234
+ // then tidy the double space a mid-line removal can leave behind. Sorting is
235
+ // needed because extraction preserves explicit-before-bare compatibility.
236
+ const ranges = [...explicitPathMentions(text), ...barePathMentions(text)]
237
+ .filter(candidate => strippedTokens.has(candidate.token))
238
+ .sort((left, right) => left.start - right.start);
239
+ const chunks = [];
240
+ let cursor = 0;
241
+ for (const range of ranges) {
242
+ if (range.start < cursor)
243
+ continue;
244
+ chunks.push(text.slice(cursor, range.start));
245
+ cursor = range.end;
246
+ }
247
+ chunks.push(text.slice(cursor));
248
+ const cleaned = chunks.join('').replace(/(?<=[^\n])[ \t]{2,}/g, ' ').trim();
201
249
  return { text: cleaned, attachments };
202
250
  }
203
251
  /** Build the turn's user message: plain string without attachments, multipart with. */
@@ -1,9 +1,3 @@
1
- export declare const TOOL_DEADLINE_EXCEEDED = "__hazeToolDeadlineExceeded";
2
- export interface ToolDeadlineResult {
3
- ok: false;
4
- [TOOL_DEADLINE_EXCEEDED]: true;
5
- error: string;
6
- }
7
1
  /** True when a tool result is the structured "deadline exceeded" placeholder. */
8
2
  export declare function isToolDeadlineExceeded(output: unknown): boolean;
9
3
  /**
@@ -1,4 +1,4 @@
1
- export const TOOL_DEADLINE_EXCEEDED = '__hazeToolDeadlineExceeded';
1
+ const TOOL_DEADLINE_EXCEEDED = '__hazeToolDeadlineExceeded';
2
2
  /** True when a tool result is the structured "deadline exceeded" placeholder. */
3
3
  export function isToolDeadlineExceeded(output) {
4
4
  return typeof output === 'object' && output !== null && TOOL_DEADLINE_EXCEEDED in output;
@@ -1,7 +1,7 @@
1
1
  import { createReadStream } from 'node:fs';
2
2
  import fs from 'node:fs/promises';
3
3
  import { StringDecoder } from 'node:string_decoder';
4
- import { TEXT_LINE_BYTES } from '../limits/byteBudgets.js';
4
+ import { TEXT_LINE_BYTES } from '../limits.js';
5
5
  async function* iterateBoundedUtf8LinesFrom(file, maxLineBytes, startByte, previousLineNumber) {
6
6
  const input = createReadStream(file, startByte > 0 ? { start: startByte } : undefined);
7
7
  let lineNumber = previousLineNumber;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Centralized output/resource limits.
3
+ *
4
+ * Byte budgets below bound work performed (process output, file reads, JSONL
5
+ * lines, LSP frames/headers/buffers, stored tool-output handles, skill files,
6
+ * exact-mutation size); the model-facing character caps bound returned/persisted
7
+ * text so callers cite a named constant instead of a magic number (CR-014).
8
+ *
9
+ * Changing a value changes availability/memory behavior; mention user-visible
10
+ * changes in `CHANGELOG.md` and docs.
11
+ */
12
+ export declare const SHELL_STREAM_BYTES: number;
13
+ export declare const BACKGROUND_PROCESS_OUTPUT_BYTES: number;
14
+ export declare const GREP_STREAM_BYTES: number;
15
+ export declare const PROCESS_STDERR_BYTES: number;
16
+ export declare const TOOL_OUTPUT_ENTRY_BYTES: number;
17
+ export declare const TOOL_OUTPUT_TOTAL_BYTES: number;
18
+ export declare const LSP_DOCUMENT_BYTES: number;
19
+ export declare const LSP_HEADER_BYTES: number;
20
+ export declare const LSP_FRAME_BYTES: number;
21
+ export declare const LSP_BUFFER_BYTES: number;
22
+ export declare const SKILL_MARKDOWN_BYTES: number;
23
+ export declare const EXACT_MUTATION_BYTES: number;
24
+ export declare const JSONL_LINE_BYTES: number;
25
+ export declare const TEXT_LINE_BYTES: number;
26
+ /** Maximum byte size of a prompt read from piped stdin. */
27
+ export declare const STDIN_PROMPT_BYTES: number;
28
+ /** Maximum size of one user-attached image (checked before the read). */
29
+ export declare const IMAGE_ATTACHMENT_BYTES: number;
30
+ /** Maximum number of image attachments in a single user message. */
31
+ export declare const IMAGE_ATTACHMENTS_PER_MESSAGE = 4;
32
+ /** Per-page cap for numbered file content returned by readFile/listFiles-style tools. */
33
+ export declare const MAX_OUTPUT_CHARS = 50000;
34
+ /** Default compact cap for stored shell output shown to the model. */
35
+ export declare const COMPACT_COMMAND_CHARS = 12000;
36
+ /** Compact cap for passing-validation summaries. */
37
+ export declare const SHORT_VALIDATION_CHARS = 2000;
38
+ /** Total rendered size cap for grep match output. */
39
+ export declare const GREP_MAX_OUTPUT_CHARS = 30000;
40
+ /** Per-line cap for rendered grep matches. */
41
+ export declare const GREP_MAX_LINE_CHARS = 500;
42
+ /** Bounded excerpt of older messages kept by /compact-style compaction. */
43
+ export declare const COMPACTION_OLDER_CHARS = 8000;
44
+ /** Bounded older-transcript budget sent to the model for LLM-summarized /compact (F-09). */
45
+ export declare const COMPACTION_LLM_TRANSCRIPT_CHARS = 60000;
46
+ /** Session JSONL values up to this size stay inline; larger ones become previews. */
47
+ export declare const SESSION_INLINE_VALUE_BYTES: number;
48
+ /** Preview length for slimmed session values. */
49
+ export declare const SESSION_PREVIEW_CHARS: number;
50
+ /** Strings longer than this are truncated in session snapshots. */
51
+ export declare const SESSION_LARGE_STRING_CHARS: number;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Centralized output/resource limits.
3
+ *
4
+ * Byte budgets below bound work performed (process output, file reads, JSONL
5
+ * lines, LSP frames/headers/buffers, stored tool-output handles, skill files,
6
+ * exact-mutation size); the model-facing character caps bound returned/persisted
7
+ * text so callers cite a named constant instead of a magic number (CR-014).
8
+ *
9
+ * Changing a value changes availability/memory behavior; mention user-visible
10
+ * changes in `CHANGELOG.md` and docs.
11
+ */
12
+ export const SHELL_STREAM_BYTES = 2 * 1024 * 1024;
13
+ export const BACKGROUND_PROCESS_OUTPUT_BYTES = 256 * 1024;
14
+ export const GREP_STREAM_BYTES = 8 * 1024 * 1024;
15
+ export const PROCESS_STDERR_BYTES = 64 * 1024;
16
+ export const TOOL_OUTPUT_ENTRY_BYTES = 2 * 1024 * 1024;
17
+ export const TOOL_OUTPUT_TOTAL_BYTES = 16 * 1024 * 1024;
18
+ export const LSP_DOCUMENT_BYTES = 2 * 1024 * 1024;
19
+ export const LSP_HEADER_BYTES = 16 * 1024;
20
+ export const LSP_FRAME_BYTES = 8 * 1024 * 1024;
21
+ export const LSP_BUFFER_BYTES = LSP_FRAME_BYTES + LSP_HEADER_BYTES;
22
+ export const SKILL_MARKDOWN_BYTES = 256 * 1024;
23
+ export const EXACT_MUTATION_BYTES = 8 * 1024 * 1024;
24
+ export const JSONL_LINE_BYTES = 4 * 1024 * 1024;
25
+ export const TEXT_LINE_BYTES = 1024 * 1024;
26
+ /** Maximum byte size of a prompt read from piped stdin. */
27
+ export const STDIN_PROMPT_BYTES = 256 * 1024;
28
+ /** Maximum size of one user-attached image (checked before the read). */
29
+ export const IMAGE_ATTACHMENT_BYTES = 5 * 1024 * 1024;
30
+ /** Maximum number of image attachments in a single user message. */
31
+ export const IMAGE_ATTACHMENTS_PER_MESSAGE = 4;
32
+ /** Per-page cap for numbered file content returned by readFile/listFiles-style tools. */
33
+ export const MAX_OUTPUT_CHARS = 50_000;
34
+ /** Default compact cap for stored shell output shown to the model. */
35
+ export const COMPACT_COMMAND_CHARS = 12_000;
36
+ /** Compact cap for passing-validation summaries. */
37
+ export const SHORT_VALIDATION_CHARS = 2_000;
38
+ /** Total rendered size cap for grep match output. */
39
+ export const GREP_MAX_OUTPUT_CHARS = 30_000;
40
+ /** Per-line cap for rendered grep matches. */
41
+ export const GREP_MAX_LINE_CHARS = 500;
42
+ /** Bounded excerpt of older messages kept by /compact-style compaction. */
43
+ export const COMPACTION_OLDER_CHARS = 8_000;
44
+ /** Bounded older-transcript budget sent to the model for LLM-summarized /compact (F-09). */
45
+ export const COMPACTION_LLM_TRANSCRIPT_CHARS = 60_000;
46
+ /** Session JSONL values up to this size stay inline; larger ones become previews. */
47
+ export const SESSION_INLINE_VALUE_BYTES = 32 * 1024;
48
+ /** Preview length for slimmed session values. */
49
+ export const SESSION_PREVIEW_CHARS = 4 * 1024;
50
+ /** Strings longer than this are truncated in session snapshots. */
51
+ export const SESSION_LARGE_STRING_CHARS = 8 * 1024;
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
3
3
  import { HAZE_DIR } from '../../config/paths.js';
4
4
  import { appendPrivateFile, ensurePrivateFile, ensurePrivateDir, tightenPrivateFile } from '../../config/privateStorage.js';
5
5
  import { OrderedFileWriter } from '../persistence/orderedFileWriter.js';
6
- import { JSONL_LINE_BYTES } from '../limits/byteBudgets.js';
6
+ import { JSONL_LINE_BYTES } from '../limits.js';
7
7
  import { iterateBoundedUtf8Lines } from '../io/boundedRead.js';
8
8
  const LOGS_DIR = path.join(HAZE_DIR, 'logs');
9
9
  function logFileId(now = new Date()) {
@@ -1,4 +1,4 @@
1
- export type BackgroundProcessStatus = 'running' | 'exited' | 'failed' | 'killed';
1
+ type BackgroundProcessStatus = 'running' | 'exited' | 'failed' | 'killed';
2
2
  export interface BackgroundProcessSummary {
3
3
  backgroundId: string;
4
4
  pid?: number;
@@ -29,7 +29,6 @@ export declare function killBackgroundProcess(backgroundId: string, killGraceMs?
29
29
  export declare function teardownBackgroundProcesses(killGraceMs?: number): Promise<BackgroundProcessSummary[]>;
30
30
  /** Install CLI-level abnormal-exit teardown for SIGINT and SIGTERM. */
31
31
  export declare function installBackgroundProcessSignalHandlers(): void;
32
- /** Best-effort synchronous safety net for process.exit and otherwise unawaitable exits. */
33
- export declare function terminateBackgroundProcessesSync(): void;
34
32
  /** Test-only reset; callers should normally use teardownBackgroundProcesses. */
35
33
  export declare function resetBackgroundProcessesForTests(): Promise<void>;
34
+ export {};
@@ -2,8 +2,9 @@ import { spawn } from 'node:child_process';
2
2
  import { StringDecoder } from 'node:string_decoder';
3
3
  import { BACKGROUND_PROCESS_HISTORY_LIMIT, BACKGROUND_PROCESS_MAX_CONCURRENCY } from '../agent/budgets.js';
4
4
  import { registerDynamicToolOutput, unregisterDynamicToolOutput } from '../agent/toolOutputStore.js';
5
- import { BACKGROUND_PROCESS_OUTPUT_BYTES } from '../limits/byteBudgets.js';
5
+ import { BACKGROUND_PROCESS_OUTPUT_BYTES } from '../limits.js';
6
6
  import { signalProcessTree } from './runBoundedProcess.js';
7
+ import { shellInvocation } from './userShell.js';
7
8
  import { truncateUtf8TailBufferAtBytes } from '../../utils/utf8.js';
8
9
  class OutputRing {
9
10
  decoder = new StringDecoder('utf8');
@@ -77,7 +78,8 @@ export function startBackgroundProcess(input) {
77
78
  }
78
79
  installExitHook();
79
80
  const backgroundId = `background-${nextId++}`;
80
- const child = spawn('bash', ['-lc', input.command], {
81
+ const invocation = shellInvocation(input.command);
82
+ const child = spawn(invocation.command, invocation.args, {
81
83
  cwd: input.cwd,
82
84
  detached: process.platform !== 'win32',
83
85
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -100,10 +102,12 @@ export function startBackgroundProcess(input) {
100
102
  child.once('error', error => {
101
103
  summary.status = 'failed';
102
104
  const code = typeof error === 'object' && error != null && 'code' in error ? error.code : undefined;
103
- // bash is required on Windows (via WSL or Git Bash). Without it, spawn
104
- // fails with ENOENT; surface a clearer message than the raw syscall error.
105
+ // Without the user's shell on PATH, spawn fails with ENOENT; surface a
106
+ // clearer message than the raw syscall error. The default Windows shell is
107
+ // bash (via WSL or Git Bash), so that case keeps the install hint.
108
+ const shellName = invocation.command;
105
109
  summary.error = code === 'ENOENT' && process.platform === 'win32'
106
- ? `bash was not found on PATH. Install WSL or Git Bash, or run haze on a POSIX shell. Underlying error: ${error.message}`
110
+ ? `${shellName} was not found on PATH.${shellName === 'bash' ? ' Install WSL or Git Bash, or run haze on a POSIX shell.' : ''} Underlying error: ${error.message}`
107
111
  : error.message;
108
112
  notify();
109
113
  });
@@ -184,7 +188,7 @@ export function installBackgroundProcessSignalHandlers() {
184
188
  handle('SIGTERM', 143);
185
189
  }
186
190
  /** Best-effort synchronous safety net for process.exit and otherwise unawaitable exits. */
187
- export function terminateBackgroundProcessesSync() {
191
+ function terminateBackgroundProcessesSync() {
188
192
  for (const record of activeRecords())
189
193
  signalProcessTree(record.child, 'SIGTERM');
190
194
  }
@@ -0,0 +1,16 @@
1
+ export type ShellDialect = 'posix' | 'fish' | 'csh' | 'powershell' | 'cmd' | 'unknown';
2
+ export declare function shellDialect(shellPath?: string): ShellDialect;
3
+ /** Model-facing syntax guidance for the selected shell. */
4
+ export declare function shellSyntaxGuidance(shellPath?: string): "Use POSIX-compatible shell syntax." | "Use fish syntax; do not use POSIX variable-assignment syntax." | "Use csh/tcsh syntax; do not use POSIX variable-assignment syntax." | "Use PowerShell syntax, cmdlets, quoting, and environment-variable notation." | "Use Windows cmd.exe syntax and environment-variable notation." | "Use syntax supported by this shell; avoid shell-specific constructs when uncertain.";
5
+ /**
6
+ * The shell commands run in: an explicit HAZE_SHELL override, otherwise the
7
+ * user's login shell from the environment, with a bash fallback. On Windows the fallback stays `bash` (via WSL or Git Bash)
8
+ * because commands are written in POSIX syntax; Git Bash terminals export
9
+ * `SHELL` anyway, so the fallback only covers the no-`SHELL` case.
10
+ */
11
+ export declare function resolveUserShell(): string;
12
+ /** Spawn target for running `command` under `shellPath` (default: user's shell). */
13
+ export declare function shellInvocation(command: string, shellPath?: string): {
14
+ command: string;
15
+ args: string[];
16
+ };
@@ -0,0 +1,59 @@
1
+ // Shells that accept `-l` (login shell) alongside `-c`. Flags are passed
2
+ // separately (`-l -c`, not `-lc`) because that form is accepted by every
3
+ // login-capable shell including fish.
4
+ const LOGIN_CAPABLE = new Set(['bash', 'zsh', 'ksh', 'ksh93', 'mksh', 'yash', 'fish']);
5
+ function shellName(shellPath) {
6
+ const base = shellPath.split(/[\\/]/).pop() ?? shellPath;
7
+ return base.replace(/\.exe$/i, '').toLowerCase();
8
+ }
9
+ export function shellDialect(shellPath = resolveUserShell()) {
10
+ const name = shellName(shellPath);
11
+ if (['bash', 'zsh', 'sh', 'dash', 'ksh', 'ksh93', 'mksh', 'yash'].includes(name))
12
+ return 'posix';
13
+ if (name === 'fish')
14
+ return 'fish';
15
+ if (name === 'csh' || name === 'tcsh')
16
+ return 'csh';
17
+ if (name === 'pwsh' || name === 'powershell')
18
+ return 'powershell';
19
+ if (name === 'cmd')
20
+ return 'cmd';
21
+ return 'unknown';
22
+ }
23
+ /** Model-facing syntax guidance for the selected shell. */
24
+ export function shellSyntaxGuidance(shellPath = resolveUserShell()) {
25
+ const dialect = shellDialect(shellPath);
26
+ if (dialect === 'posix')
27
+ return 'Use POSIX-compatible shell syntax.';
28
+ if (dialect === 'fish')
29
+ return 'Use fish syntax; do not use POSIX variable-assignment syntax.';
30
+ if (dialect === 'csh')
31
+ return 'Use csh/tcsh syntax; do not use POSIX variable-assignment syntax.';
32
+ if (dialect === 'powershell')
33
+ return 'Use PowerShell syntax, cmdlets, quoting, and environment-variable notation.';
34
+ if (dialect === 'cmd')
35
+ return 'Use Windows cmd.exe syntax and environment-variable notation.';
36
+ return 'Use syntax supported by this shell; avoid shell-specific constructs when uncertain.';
37
+ }
38
+ /**
39
+ * The shell commands run in: an explicit HAZE_SHELL override, otherwise the
40
+ * user's login shell from the environment, with a bash fallback. On Windows the fallback stays `bash` (via WSL or Git Bash)
41
+ * because commands are written in POSIX syntax; Git Bash terminals export
42
+ * `SHELL` anyway, so the fallback only covers the no-`SHELL` case.
43
+ */
44
+ export function resolveUserShell() {
45
+ const fromEnv = process.env.HAZE_SHELL || process.env.SHELL;
46
+ if (fromEnv)
47
+ return fromEnv;
48
+ return process.platform === 'win32' ? 'bash' : '/bin/bash';
49
+ }
50
+ /** Spawn target for running `command` under `shellPath` (default: user's shell). */
51
+ export function shellInvocation(command, shellPath = resolveUserShell()) {
52
+ const name = shellName(shellPath);
53
+ if (name === 'pwsh' || name === 'powershell')
54
+ return { command: shellPath, args: ['-Command', command] };
55
+ if (name === 'cmd')
56
+ return { command: shellPath, args: ['/c', command] };
57
+ const login = LOGIN_CAPABLE.has(name) ? ['-l'] : [];
58
+ return { command: shellPath, args: [...login, '-c', command] };
59
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Whether a path points at (or inside) a protected secret file or credential
3
+ * store. Checked against both lexical names and real paths by callers so
4
+ * symlinks cannot rename a secret into reach (`link -> .env`) or a secret
5
+ * name onto other content (`.env -> target`). Pure function; `homeDir` is
6
+ * injectable for tests.
7
+ */
8
+ export declare function isProtectedSecretPath(candidatePath: string, homeDir?: string): boolean;
9
+ /**
10
+ * Ripgrep exclusion globs for the `grep` tool. Later globs take precedence in
11
+ * ripgrep, so callers must append these AFTER any model-supplied glob — an
12
+ * explicit model glob must not re-include secrets. Exclusions are strictly
13
+ * negated: a positive "re-include" glob would act as a whitelist and narrow
14
+ * the search to only the re-included names. Documentation variants
15
+ * (`.env.example`, `id_*.pub`) therefore stay out of traversal search but
16
+ * remain readable through targeted `readFile` calls.
17
+ */
18
+ export declare function secretSearchExcludeGlobs(): string[];