@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
@@ -1,33 +1,37 @@
1
1
  import { tool } from 'ai';
2
2
  import { z } from 'zod';
3
- import { classifyBashCommand, isValidationClassification } from '../../core/safety/bashClassifier.js';
3
+ import { classifyShellCommand, isValidationClassification } from '../../core/safety/shellClassifier.js';
4
4
  import { detectMissingExecutable, missingExecutableFields } from '../../core/safety/missingExecutable.js';
5
5
  import { parseValidationOutput } from '../../core/validation/outputParser.js';
6
- import { filterBashOutput } from '../../core/bashOutput/registry.js';
6
+ import { filterShellOutput } from '../../core/shellOutput/registry.js';
7
7
  import { storeToolOutput } from '../../core/agent/toolOutputStore.js';
8
8
  import { workspaceRoot } from '../../utils/path.js';
9
9
  import { compactStoredOutput, COMPACT_COMMAND_CHARS } from './outputCap.js';
10
10
  import { hazeContext, hazeToolContextSchema, runDedupedTool } from './toolContext.js';
11
11
  import { runBoundedProcess } from '../../core/process/runBoundedProcess.js';
12
- import { BASH_STREAM_BYTES } from '../../core/limits/byteBudgets.js';
13
- import { SHORT_VALIDATION_CHARS } from '../../core/limits/textBudgets.js';
12
+ import { SHELL_STREAM_BYTES, SHORT_VALIDATION_CHARS } from '../../core/limits.js';
14
13
  import { startBackgroundProcess } from '../../core/process/backgroundRegistry.js';
14
+ import { resolveUserShell, shellInvocation, shellSyntaxGuidance } from '../../core/process/userShell.js';
15
15
  /** Byte-stat metadata only — the raw stream text must never reach the model context (see code-review CR-001). */
16
16
  function streamByteStats(stream) {
17
17
  return { totalBytes: stream.totalBytes, retainedBytes: stream.retainedBytes, omittedBytes: stream.omittedBytes };
18
18
  }
19
- export const bashTool = tool({
20
- description: 'Run workspace tests, builds, validation, or inspection. Risk classification is informational; use file tools for edits.',
19
+ const userShell = resolveUserShell();
20
+ export const shellTool = tool({
21
+ description: 'Run workspace inspection or validation. Set purpose=validation for custom checks that should count as completion evidence; risk classification is informational.',
21
22
  contextSchema: hazeToolContextSchema,
22
23
  inputSchema: z.object({
23
- command: z.string().min(1).describe('Command to execute with bash -lc'),
24
+ command: z.string().min(1).describe(`Command to execute with ${userShell} ${shellInvocation('', userShell).args.join(' ')}. ${shellSyntaxGuidance(userShell)}`.trim()),
25
+ purpose: z.enum(['auto', 'validation']).default('auto').describe('Use validation for an intentional test/check command, including custom assertion scripts; pass/fail still comes from the real process result.'),
24
26
  timeoutSeconds: z.number().int().positive().max(600).optional().describe('Timeout in seconds; defaults to 60'),
25
- allowMutation: z.boolean().default(false).describe('Deprecated compatibility flag. Commands run without confirmation; retained for compatibility.'),
26
27
  background: z.boolean().default(false).describe('Start a registered long-running process and return immediately. Use process to list, inspect output, or kill it.'),
27
28
  }),
28
- execute: async ({ command, timeoutSeconds, background }, context) => runDedupedTool('bash', { command, timeoutSeconds, background }, context, async () => {
29
+ execute: async ({ command, purpose, timeoutSeconds, background }, context) => runDedupedTool('shell', { command, purpose, timeoutSeconds, background }, context, async () => {
29
30
  const cwd = workspaceRoot();
30
- const classification = classifyBashCommand(command);
31
+ const classification = classifyShellCommand(command);
32
+ // Note: secret-file protection is NOT hard-enforced here by decision — it
33
+ // lives in the file tools (workspaceFile.ts / grep globs). For shell, the
34
+ // behavior is instructed via the system prompt (SECRET_FILE_RULE).
31
35
  if (background) {
32
36
  if (hazeContext(context)?.isSubagent) {
33
37
  return { ok: false, command, reasonCode: 'background_not_allowed', recoverable: false, error: 'Background processes are available only to the main haze turn, not fleet workers.', suggestedNextStep: 'Run the server from the main conversation.' };
@@ -45,21 +49,21 @@ export const bashTool = tool({
45
49
  }
46
50
  const timeoutMs = (timeoutSeconds ?? 60) * 1000;
47
51
  const startedAt = Date.now();
48
- const processResult = await runBoundedProcess({ command: 'bash', args: ['-lc', command], cwd, timeoutMs, signal: context.abortSignal, maxStdoutBytes: BASH_STREAM_BYTES, maxStderrBytes: BASH_STREAM_BYTES });
52
+ const processResult = await runBoundedProcess({ ...shellInvocation(command), cwd, timeoutMs, signal: context.abortSignal, maxStdoutBytes: SHELL_STREAM_BYTES, maxStderrBytes: SHELL_STREAM_BYTES });
49
53
  const { code, timedOut } = processResult;
50
54
  const stdout = processResult.stdout.text;
51
55
  const stderr = processResult.stderr.text;
52
- const validationSummary = isValidationClassification(classification)
56
+ const validationSummary = purpose === 'validation' || isValidationClassification(classification)
53
57
  ? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: processResult.stdout.omittedBytes > 0, stderrTruncated: processResult.stderr.omittedBytes > 0, classification })
54
58
  : undefined;
55
59
  const validationPassed = validationSummary?.status === 'passed';
56
- const output = filterBashOutput({ command, code, stdout, stderr, timedOut, classification, validationSummary, storeRawOutput: storeToolOutput, fallbackCompact: compactStoredOutput, compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS });
60
+ const output = filterShellOutput({ command, code, stdout, stderr, timedOut, classification, validationSummary, storeRawOutput: storeToolOutput, fallbackCompact: compactStoredOutput, compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS });
57
61
  // Generic, dependency-agnostic diagnostic for a missing executable. Only the
58
62
  // executable name and a generic next step are exposed (never raw stderr).
59
63
  const missing = code !== 0 && !processResult.aborted ? detectMissingExecutable({ command, code, stderr }) : undefined;
60
64
  return {
61
65
  ok: code === 0 && !timedOut && !processResult.aborted && !processResult.error,
62
- code, command, cwd, classification, durationMs: Date.now() - startedAt, timedOut,
66
+ code, command, purpose, cwd, classification, durationMs: Date.now() - startedAt, timedOut,
63
67
  aborted: processResult.aborted, signal: processResult.signal, forcedTermination: processResult.forced,
64
68
  stdout: output.stdout, stderr: output.stderr, validationSummary,
65
69
  stdoutBytes: streamByteStats(processResult.stdout), stderrBytes: streamByteStats(processResult.stderr),
@@ -55,7 +55,7 @@ export function hazeContext(context) {
55
55
  return isHazeToolContext(value) ? value : undefined;
56
56
  }
57
57
  export function toolsContextFor(tools, context) {
58
- const hazeToolNames = new Set(['listFiles', 'readFile', 'grep', 'replaceLines', 'writeFile', 'editFile', 'bash', 'process', 'fetch']);
58
+ const hazeToolNames = new Set(['listFiles', 'readFile', 'grep', 'replaceLines', 'writeFile', 'editFile', 'shell', 'process', 'fetch']);
59
59
  return Object.fromEntries(Object.keys(tools).filter(name => hazeToolNames.has(name)).map(name => [name, context]));
60
60
  }
61
61
  /**
@@ -114,15 +114,15 @@ export function scopedContextMutationStop(toolName, filePath, files) {
114
114
  };
115
115
  }
116
116
  function isMutatingTool(toolName) {
117
- // Bash is conservatively workspace-mutation-capable. Classification remains
117
+ // Shell execution is conservatively workspace-mutation-capable. Classification remains
118
118
  // informational and is not a sandbox boundary.
119
- return ['editFile', 'replaceLines', 'writeFile', 'bash'].includes(toolName);
119
+ return ['editFile', 'replaceLines', 'writeFile', 'shell'].includes(toolName);
120
120
  }
121
121
  function isReadOnlyFileTool(toolName) {
122
122
  return ['listFiles', 'readFile', 'grep'].includes(toolName);
123
123
  }
124
124
  // Read-only tools that participate in completed-call deduplication within a
125
- // turn (no side effects). Bash is deliberately excluded: commands can observe
125
+ // turn (no side effects). Shell is deliberately excluded: commands can observe
126
126
  // external state changes between identical calls (CR-007).
127
127
  function isDeduplicableReadOnlyTool(toolName) {
128
128
  return isReadOnlyFileTool(toolName) || toolName === 'fetch';
@@ -188,7 +188,7 @@ export async function runDedupedTool(toolName, input, context, execute) {
188
188
  if (isMutatingTool(toolName) && ctx.mutationPolicy) {
189
189
  // A worker supplies its whole-run owner so nested tool calls are
190
190
  // reentrant. Main-turn calls intentionally receive a fresh owner per
191
- // mutation, serializing concurrent edit/bash calls.
191
+ // mutation, serializing concurrent edit/shell calls.
192
192
  const owner = ctx.mutationOwner ?? ctx.mutationPolicy.createOwner();
193
193
  releaseMutation = await ctx.mutationPolicy.acquire(owner, context.abortSignal);
194
194
  }
@@ -1,12 +1,12 @@
1
1
  import { type ToolExecutionContext } from './toolContext.js';
2
- export declare function prepareWorkspaceExisting(filePath: string): Promise<string>;
3
2
  /**
4
3
  * Resolve a read path and confine it to the workspace — unless the user
5
4
  * explicitly mentioned it (or a parent directory) in the prompt this turn.
6
5
  * Blessed paths skip both `.gitignore` enforcement and the workspace boundary
7
- * so the model can read host files the user pointed at. Mutating tools use
8
- * `prepareWorkspaceMutation` / `prepareWorkspaceWritePath` instead, which
9
- * never consult the bless set.
6
+ * so the model can read host files the user pointed at. Secret-file
7
+ * protection is checked before the bless set and is never bypassed.
8
+ * Mutating tools use `prepareWorkspaceMutation` / `prepareWorkspaceWritePath`
9
+ * instead, which never consult the bless set.
10
10
  */
11
11
  export declare function prepareWorkspaceRead(filePath: string, allowIgnored: boolean | undefined, context?: ToolExecutionContext): Promise<string>;
12
12
  export declare function prepareWorkspaceMutation(toolName: string, filePath: string, allowIgnored: boolean | undefined, context: ToolExecutionContext): Promise<{
@@ -1,34 +1,44 @@
1
1
  import fs from 'node:fs/promises';
2
+ import os from 'node:os';
2
3
  import path from 'node:path';
3
4
  import { assertRealPathInsideWorkspace, assertWritablePathInsideWorkspace, resolveWorkspacePath, workspaceRoot } from '../../utils/path.js';
4
5
  import { isPathBlessed } from '../../core/attachments/readBlessings.js';
6
+ import { isProtectedSecretPath } from '../../core/safety/secretPaths.js';
5
7
  import { assertNotIgnored } from './fileToolShared.js';
8
+ import { HazeToolError } from './failures.js';
6
9
  import { discoverScopedContext, hazeContext, scopedContextMutationStop } from './toolContext.js';
7
- export async function prepareWorkspaceExisting(filePath) {
8
- const absolutePath = resolveWorkspacePath(filePath);
9
- await assertRealPathInsideWorkspace(absolutePath, filePath);
10
- return absolutePath;
10
+ /**
11
+ * Secret files are hands-off for every tool: this check wins over the read
12
+ * bless set, `allowIgnored`, and gitignore logic. Both the lexical path and
13
+ * the real path are checked so symlinks cannot rename a secret into reach
14
+ * (`link -> .env`) or a secret name onto other content (`.env -> target`).
15
+ */
16
+ async function assertNotSecretPath(absolutePath, realPath, inputPath, operation) {
17
+ const homeDir = os.homedir();
18
+ if (!isProtectedSecretPath(absolutePath, homeDir) && !isProtectedSecretPath(realPath, homeDir))
19
+ return;
20
+ throw new HazeToolError(`Refusing to ${operation} protected secret file: ${inputPath}. Secret files (SSH keys, shell histories, .env files, credentials) are never accessible to agent tools.`, 'secret_file_protected', { recoverable: false, suggestedNextStep: 'Protected secret file: do not retry with other tools, paths, or shell. Ask the user to provide the needed value in the conversation instead.' });
11
21
  }
12
22
  /**
13
23
  * Resolve a read path and confine it to the workspace — unless the user
14
24
  * explicitly mentioned it (or a parent directory) in the prompt this turn.
15
25
  * Blessed paths skip both `.gitignore` enforcement and the workspace boundary
16
- * so the model can read host files the user pointed at. Mutating tools use
17
- * `prepareWorkspaceMutation` / `prepareWorkspaceWritePath` instead, which
18
- * never consult the bless set.
26
+ * so the model can read host files the user pointed at. Secret-file
27
+ * protection is checked before the bless set and is never bypassed.
28
+ * Mutating tools use `prepareWorkspaceMutation` / `prepareWorkspaceWritePath`
29
+ * instead, which never consult the bless set.
19
30
  */
20
31
  export async function prepareWorkspaceRead(filePath, allowIgnored, context) {
32
+ const absolutePath = path.resolve(workspaceRoot(), filePath);
33
+ const realRequested = await requestedRealPath(absolutePath);
34
+ await assertNotSecretPath(absolutePath, realRequested, filePath, 'read');
21
35
  const blessed = context ? hazeContext(context)?.blessedPaths : undefined;
22
- if (blessed && blessed.length > 0) {
23
- const absolutePath = path.resolve(workspaceRoot(), filePath);
24
- const realRequested = await requestedRealPath(absolutePath);
25
- if (isPathBlessed(realRequested, blessed))
26
- return absolutePath;
27
- }
28
- const absolutePath = resolveWorkspacePath(filePath);
29
- await assertNotIgnored(absolutePath, filePath, allowIgnored);
30
- await assertRealPathInsideWorkspace(absolutePath, filePath);
31
- return absolutePath;
36
+ if (blessed && blessed.length > 0 && isPathBlessed(realRequested, blessed))
37
+ return absolutePath;
38
+ const confinedPath = resolveWorkspacePath(filePath);
39
+ await assertNotIgnored(confinedPath, filePath, allowIgnored, { operation: 'read' });
40
+ await assertRealPathInsideWorkspace(confinedPath, filePath);
41
+ return confinedPath;
32
42
  }
33
43
  /** Best-effort realpath for bless comparison; falls back to the verbatim path if the file is gone. */
34
44
  async function requestedRealPath(absolutePath) {
@@ -41,6 +51,7 @@ async function requestedRealPath(absolutePath) {
41
51
  }
42
52
  export async function prepareWorkspaceMutation(toolName, filePath, allowIgnored, context) {
43
53
  const absolutePath = resolveWorkspacePath(filePath);
54
+ await assertNotSecretPath(absolutePath, await requestedRealPath(absolutePath), filePath, 'mutation');
44
55
  await assertNotIgnored(absolutePath, filePath, allowIgnored);
45
56
  await assertRealPathInsideWorkspace(absolutePath, filePath);
46
57
  const scopedContext = await discoverScopedContext(filePath, context);
@@ -49,6 +60,7 @@ export async function prepareWorkspaceMutation(toolName, filePath, allowIgnored,
49
60
  }
50
61
  export async function prepareWorkspaceWritePath(toolName, filePath, allowIgnored, context) {
51
62
  const absolutePath = resolveWorkspacePath(filePath);
63
+ await assertNotSecretPath(absolutePath, await requestedRealPath(absolutePath), filePath, 'mutation');
52
64
  await assertNotIgnored(absolutePath, filePath, allowIgnored);
53
65
  const scopedContext = await discoverScopedContext(filePath, context);
54
66
  const scopedStop = scopedContextMutationStop(toolName, filePath, scopedContext);
@@ -30,7 +30,7 @@ export interface FetchOptions {
30
30
  * caller). When `pinnedIp` is undefined (literal-IP URL), the transport falls
31
31
  * back to the global fetch — no DNS-rebinding surface exists for a literal IP.
32
32
  */
33
- export type PinnedFetcher = (url: URL, pinnedIp: string | undefined, init: RequestInit) => Promise<Response>;
33
+ type PinnedFetcher = (url: URL, pinnedIp: string | undefined, init: RequestInit) => Promise<Response>;
34
34
  export interface FetchResult {
35
35
  url: string;
36
36
  status: number;
@@ -1,12 +1,2 @@
1
- import type { LoadedSkill, SkillFrontmatter, SkillSource } from './types.js';
2
- declare function parseSkillMarkdown(content: string): {
3
- frontmatter: SkillFrontmatter;
4
- body: string;
5
- };
6
- declare function referencedPaths(body: string): string[];
1
+ import type { LoadedSkill, SkillSource } from './types.js';
7
2
  export declare function loadSkill(dir: string, source?: SkillSource): Promise<LoadedSkill | null>;
8
- export declare const internals: {
9
- parseSkillMarkdown: typeof parseSkillMarkdown;
10
- referencedPaths: typeof referencedPaths;
11
- };
12
- export {};
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
2
2
  import path from 'node:path';
3
3
  import YAML from 'yaml';
4
4
  import { assertRealPathInsideRoot } from '../utils/path.js';
5
- import { SKILL_MARKDOWN_BYTES } from '../core/limits/byteBudgets.js';
5
+ import { SKILL_MARKDOWN_BYTES } from '../core/limits.js';
6
6
  import { readUtf8Prefix } from '../core/io/boundedRead.js';
7
7
  const MAX_REFERENCE_BYTES = 50_000;
8
8
  const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
@@ -77,4 +77,3 @@ export async function loadSkill(dir, source = 'global') {
77
77
  const references = await Promise.all(referencedPaths(body).map(ref => loadReference(dir, ref)));
78
78
  return { dir, path: realSkillPath, name: frontmatter.name, description: frontmatter.description, body, references, source };
79
79
  }
80
- export const internals = { parseSkillMarkdown, referencedPaths };
@@ -17,7 +17,7 @@ export interface LoadedSkill {
17
17
  references: LoadedSkillReference[];
18
18
  source: SkillSource;
19
19
  }
20
- export interface SkillRegistryError {
20
+ interface SkillRegistryError {
21
21
  directory: string;
22
22
  message: string;
23
23
  source?: SkillSource;
@@ -29,3 +29,4 @@ export interface SkillRegistry {
29
29
  candidates?: LoadedSkill[];
30
30
  errors: SkillRegistryError[];
31
31
  }
32
+ export {};
@@ -2,5 +2,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from 'ink';
3
3
  import { theme } from '../theme.js';
4
4
  export function Header({ subtitle, version }) {
5
- return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: theme.purple, bold: true, children: "haze" }), version ? _jsxs(Text, { color: theme.muted, children: [" v", version] }) : null] }), _jsx(Text, { children: " " }), _jsx(Text, { color: theme.muted, children: subtitle ?? 'A tiny terminal fog machine for building software.' })] });
5
+ return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: theme.accent, bold: true, children: "haze" }), version ? _jsxs(Text, { color: theme.muted, children: [" v", version] }) : null] }), _jsx(Text, { children: " " }), _jsx(Text, { color: theme.muted, children: subtitle ?? 'A tiny terminal fog machine for building software.' })] });
6
6
  }
@@ -102,7 +102,7 @@ function MarkdownBlock({ token, width, source, textOverride, compactAfter }) {
102
102
  case 'space':
103
103
  return _jsx(Text, { children: " " });
104
104
  case 'hr':
105
- return _jsx(Text, { color: theme.deepPurple, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" });
105
+ return _jsx(Text, { color: theme.accentDim, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" });
106
106
  case 'blockquote': {
107
107
  const quote = token;
108
108
  return _jsx(Box, { flexDirection: "column", marginY: 1, children: quote.text.split('\n').map((line, index) => _jsx(Text, { backgroundColor: theme.surfaceBg, children: padAnsi(line || ' ', width) }, index)) });
@@ -130,7 +130,7 @@ function ListItemView({ item, ordered, index, width }) {
130
130
  const markerWidth = visibleLength(marker);
131
131
  const blocks = (item.tokens ?? []).filter(child => child.type !== 'space');
132
132
  if (blocks.length === 0) {
133
- return _jsx(Box, { children: _jsx(Text, { color: theme.purple, children: marker }) });
133
+ return _jsx(Box, { children: _jsx(Text, { color: theme.accent, children: marker }) });
134
134
  }
135
135
  return _jsx(Box, { flexDirection: "column", children: blocks.map((block, blockIndex) => (_jsx(ListItemBlock, { token: block, marker: blockIndex === 0 ? marker : null, markerWidth: markerWidth, width: width }, blockIndex))) });
136
136
  }
@@ -145,26 +145,26 @@ function ListItemBlock({ token, marker, markerWidth, width }) {
145
145
  const contentWidth = Math.max(1, width - markerWidth);
146
146
  const lines = wrapInlineAtoms(splitInlineIntoAtoms(tokenizeInline(text)), contentWidth);
147
147
  const prefix = (lineIndex) => lineIndex === 0 ? (marker ?? ' '.repeat(markerWidth)) : ' '.repeat(markerWidth);
148
- return _jsx(Box, { flexDirection: "column", children: lines.map((line, lineIndex) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: theme.purple, children: prefix(lineIndex) }) }), _jsx(Text, { children: line.map((atom, atomIndex) => atom.type === 'space' ? _jsx(Text, { children: ' ' }, atomIndex) : renderInlinePart(atom, atomIndex)) })] }, lineIndex))) });
148
+ return _jsx(Box, { flexDirection: "column", children: lines.map((line, lineIndex) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: theme.accent, children: prefix(lineIndex) }) }), _jsx(Text, { children: line.map((atom, atomIndex) => atom.type === 'space' ? _jsx(Text, { children: ' ' }, atomIndex) : renderInlinePart(atom, atomIndex)) })] }, lineIndex))) });
149
149
  }
150
150
  // Block-level content (code, nested list, blockquote, table). The marker
151
151
  // sits on its own line when this is the first block; the block then renders
152
152
  // indented to align with the marker.
153
- return _jsxs(Box, { flexDirection: "column", children: [marker ? _jsx(Text, { color: theme.purple, children: marker }) : null, _jsx(Box, { flexDirection: "column", marginLeft: markerWidth, children: _jsx(MarkdownBlock, { token: token, width: Math.max(20, width - markerWidth) }) })] });
153
+ return _jsxs(Box, { flexDirection: "column", children: [marker ? _jsx(Text, { color: theme.accent, children: marker }) : null, _jsx(Box, { flexDirection: "column", marginLeft: markerWidth, children: _jsx(MarkdownBlock, { token: token, width: Math.max(20, width - markerWidth) }) })] });
154
154
  }
155
155
  function HeadingBlock({ heading, width }) {
156
156
  const title = stripInline(heading.text).trim();
157
157
  if (heading.depth === 1)
158
- return _jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, children: [_jsx(Text, { color: theme.purple, bold: true, children: title.toUpperCase() }), _jsx(Text, { color: theme.deepPurple, children: '─'.repeat(Math.min(width, Math.max(12, visibleLength(title)))) })] });
158
+ return _jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, children: [_jsx(Text, { color: theme.accent, bold: true, children: title.toUpperCase() }), _jsx(Text, { color: theme.accentDim, children: '─'.repeat(Math.min(width, Math.max(12, visibleLength(title)))) })] });
159
159
  if (heading.depth === 2)
160
- return _jsx(Box, { marginTop: 1, marginBottom: 1, children: _jsx(Text, { color: theme.purple, bold: true, children: title }) });
161
- return _jsx(Box, { marginTop: heading.depth <= 3 ? 1 : 0, children: _jsx(Text, { color: theme.purple, bold: true, children: title }) });
160
+ return _jsx(Box, { marginTop: 1, marginBottom: 1, children: _jsx(Text, { color: theme.accent, bold: true, children: title }) });
161
+ return _jsx(Box, { marginTop: heading.depth <= 3 ? 1 : 0, children: _jsx(Text, { color: theme.accent, bold: true, children: title }) });
162
162
  }
163
163
  function TableLine({ line }) {
164
164
  if (isTableBorder(line))
165
- return _jsx(Text, { color: theme.deepPurple, children: line });
165
+ return _jsx(Text, { color: theme.accentDim, children: line });
166
166
  return _jsx(Text, { children: [...line].map((char, index) => char === '│'
167
- ? _jsx(Text, { color: theme.deepPurple, children: char }, index)
167
+ ? _jsx(Text, { color: theme.accentDim, children: char }, index)
168
168
  : _jsx(Text, { children: char }, index)) });
169
169
  }
170
170
  function CodeBlock({ code, language, source, width }) {
@@ -245,7 +245,7 @@ function renderInlinePart(part, index) {
245
245
  if (part.kind === 'em')
246
246
  return _jsx(Text, { italic: true, children: part.text }, index);
247
247
  if (part.kind === 'link')
248
- return _jsx(Text, { color: theme.purple, children: part.text }, index);
248
+ return _jsx(Text, { color: theme.accent, children: part.text }, index);
249
249
  return _jsx(Text, { children: part.text }, index);
250
250
  }
251
251
  function splitInlineIntoAtoms(parts) {
@@ -8,7 +8,7 @@ export declare function shouldInsertNewline(input: string, key: TextInputKey): b
8
8
  export type TextInputSuggestion = {
9
9
  value: string;
10
10
  description?: string;
11
- kind?: 'command' | 'skill' | 'provider' | 'model' | 'lsp' | 'mcp' | 'session' | 'file';
11
+ kind?: 'command' | 'skill' | 'provider' | 'model' | 'lsp' | 'mcp' | 'session' | 'file' | 'theme';
12
12
  };
13
13
  /** Cursor-aware path completer for `@token` mentions; receives the token verbatim. */
14
14
  export type MentionSuggestionsProvider = (token: string) => Promise<TextInputSuggestion[]> | TextInputSuggestion[];
@@ -284,13 +284,13 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
284
284
  const visibleLines = wrappedLines.slice(firstVisibleLine, firstVisibleLine + maxVisibleLines);
285
285
  const displayList = inMentionMode ? mentionList : filteredSuggestions;
286
286
  const displayActiveIndex = inMentionMode ? activeMentionIndex : activeSuggestionIndex;
287
- return _jsxs(Box, { flexDirection: "column", width: "100%", children: [displayList.length > 0 && _jsx(Box, { flexDirection: "column", marginBottom: 1, children: displayList.map((suggestion, index) => _jsxs(Text, { color: index === displayActiveIndex ? theme.success : theme.muted, wrap: "truncate-end", children: [index === displayActiveIndex ? '› ' : ' ', suggestion.value, _jsxs(Text, { color: theme.muted, children: [" ", suggestion.kind ?? 'command', suggestion.description ? ` — ${suggestion.description}` : ''] })] }, suggestion.value)) }), value.length === 0 ? _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: theme.purple, children: "\u203A " }), _jsx(Text, { inverse: true, children: " " }), _jsxs(Text, { color: theme.muted, children: [" ", placeholder ?? 'Type a message...'] })] }) : visibleLines.map((line, index) => {
287
+ return _jsxs(Box, { flexDirection: "column", width: "100%", children: [displayList.length > 0 && _jsx(Box, { flexDirection: "column", marginBottom: 1, children: displayList.map((suggestion, index) => _jsxs(Text, { color: index === displayActiveIndex ? theme.success : theme.muted, wrap: "truncate-end", children: [index === displayActiveIndex ? '› ' : ' ', suggestion.value, _jsxs(Text, { color: theme.muted, children: [" ", suggestion.kind ?? 'command', suggestion.description ? ` — ${suggestion.description}` : ''] })] }, suggestion.value)) }), value.length === 0 ? _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: theme.accent, children: "\u203A " }), _jsx(Text, { inverse: true, children: " " }), _jsxs(Text, { color: theme.muted, children: [" ", placeholder ?? 'Type a message...'] })] }) : visibleLines.map((line, index) => {
288
288
  const absoluteLineIndex = firstVisibleLine + index;
289
289
  const isCursorLine = absoluteLineIndex === currentCursorPosition.lineIndex;
290
290
  const lineCursor = isCursorLine ? Math.max(0, Math.min(displayCursor - line.start, line.text.length)) : -1;
291
291
  const beforeCursor = isCursorLine ? line.text.slice(0, lineCursor) : line.text;
292
292
  const cursorChar = isCursorLine ? line.text[lineCursor] ?? ' ' : '';
293
293
  const afterCursor = isCursorLine ? line.text.slice(lineCursor + 1) : '';
294
- return _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: absoluteLineIndex === 0 ? theme.purple : theme.muted, children: absoluteLineIndex === 0 ? '› ' : ' ' }), isCursorLine ? _jsxs(_Fragment, { children: [beforeCursor, _jsx(Text, { inverse: true, children: cursorChar }), afterCursor] }) : line.text] }, `${line.start}-${absoluteLineIndex}`);
294
+ return _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: theme.accent, children: absoluteLineIndex === 0 ? '› ' : ' ' }), isCursorLine ? _jsxs(_Fragment, { children: [beforeCursor, _jsx(Text, { inverse: true, children: cursorChar }), afterCursor] }) : line.text] }, `${line.start}-${absoluteLineIndex}`);
295
295
  })] });
296
296
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Terminal default color control via OSC escape sequences.
3
+ *
4
+ * A haze theme paints both terminal defaults, not just one side:
5
+ * OSC 10 — default foreground (the theme's `foreground` role)
6
+ * OSC 11 — default background (the theme's `background` role)
7
+ * OSC 110/111 — restore the terminal's own defaults on exit
8
+ *
9
+ * This pairing matters because haze renders plenty of unstyled `<Text>` that
10
+ * inherits the terminal defaults (diff code lines, plain transcript text).
11
+ * Adopting only the background would repaint that text's canvas — e.g. to
12
+ * Solarized Light's cream — while a dark-configured terminal keeps its white
13
+ * default foreground: unreadable. Adopting both sides keeps fg/bg contrast
14
+ * owned by the theme. Supported terminals (iTerm2, kitty, alacritty, wezterm,
15
+ * xterm, gnome-terminal, foot, …) honor the sequences; others ignore them, so
16
+ * haze stays as readable as the terminal's own configuration.
17
+ *
18
+ * Helpers are write-only on purpose: querying current colors (OSC 10/11 ?)
19
+ * would race the Ink app for stdin. Malformed colors never emit anything.
20
+ */
21
+ /** Minimal writable-terminal shape so tests can pass a fake stream. */
22
+ export interface TerminalColorStream {
23
+ write(chunk: string): unknown;
24
+ isTTY?: boolean;
25
+ }
26
+ /** Adopt a theme's foreground/background as the terminal defaults (OSC 10 + 11). Malformed parts are skipped; no-op off-TTY. */
27
+ export declare function applyTerminalColors(foreground: string, background: string, stream?: TerminalColorStream): void;
28
+ /** Restore the terminal's own default colors (OSC 110 + 111). No-op off-TTY. */
29
+ export declare function resetTerminalColors(stream?: TerminalColorStream): void;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Terminal default color control via OSC escape sequences.
3
+ *
4
+ * A haze theme paints both terminal defaults, not just one side:
5
+ * OSC 10 — default foreground (the theme's `foreground` role)
6
+ * OSC 11 — default background (the theme's `background` role)
7
+ * OSC 110/111 — restore the terminal's own defaults on exit
8
+ *
9
+ * This pairing matters because haze renders plenty of unstyled `<Text>` that
10
+ * inherits the terminal defaults (diff code lines, plain transcript text).
11
+ * Adopting only the background would repaint that text's canvas — e.g. to
12
+ * Solarized Light's cream — while a dark-configured terminal keeps its white
13
+ * default foreground: unreadable. Adopting both sides keeps fg/bg contrast
14
+ * owned by the theme. Supported terminals (iTerm2, kitty, alacritty, wezterm,
15
+ * xterm, gnome-terminal, foot, …) honor the sequences; others ignore them, so
16
+ * haze stays as readable as the terminal's own configuration.
17
+ *
18
+ * Helpers are write-only on purpose: querying current colors (OSC 10/11 ?)
19
+ * would race the Ink app for stdin. Malformed colors never emit anything.
20
+ */
21
+ const HEX_COLOR = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
22
+ /** `#rrggbb` → OSC rgb payload (`rr/gg/bb`), or undefined for malformed input. */
23
+ function oscRgb(color) {
24
+ const match = HEX_COLOR.exec(color.trim());
25
+ if (!match)
26
+ return undefined;
27
+ const [, r = '', g = '', b = ''] = match;
28
+ return `${r.toLowerCase()}/${g.toLowerCase()}/${b.toLowerCase()}`;
29
+ }
30
+ /** Adopt a theme's foreground/background as the terminal defaults (OSC 10 + 11). Malformed parts are skipped; no-op off-TTY. */
31
+ export function applyTerminalColors(foreground, background, stream = process.stdout) {
32
+ if (!stream.isTTY)
33
+ return;
34
+ const fg = oscRgb(foreground);
35
+ const bg = oscRgb(background);
36
+ if (fg)
37
+ stream.write(`\u001B]10;rgb:${fg}\u0007`);
38
+ if (bg)
39
+ stream.write(`\u001B]11;rgb:${bg}\u0007`);
40
+ }
41
+ /** Restore the terminal's own default colors (OSC 110 + 111). No-op off-TTY. */
42
+ export function resetTerminalColors(stream = process.stdout) {
43
+ if (!stream.isTTY)
44
+ return;
45
+ stream.write('\u001B]110\u0007');
46
+ stream.write('\u001B]111\u0007');
47
+ }
@@ -1,16 +1,111 @@
1
- export declare const theme: {
2
- foreground: string;
3
- purple: string;
4
- deepPurple: string;
5
- blue: string;
1
+ /**
2
+ * Haze theming core, aligned with the oh-my-zsh / zsh `colors` vocabulary so
3
+ * that oh-my-zsh themes port over with minimal effort.
4
+ *
5
+ * oh-my-zsh themes never define RGB colors. They reference terminal palette
6
+ * slots using zsh's `colors` vocabulary:
7
+ *
8
+ * $fg[cyan] → the named palette slot `cyan`
9
+ * $fg_bold[green] → named slot `green` (bold is a text attribute, not a color)
10
+ * ${FG[214]} / %F{214} → an xterm-256 color index
11
+ * %F{#ff8800} → truecolor hex
12
+ *
13
+ * Haze themes mirror that split in two layers:
14
+ *
15
+ * 1. Palette — `ZSH_NAMED_COLORS`, one entry per zsh `colors` key
16
+ * (`black red green yellow blue magenta cyan white default`), approximated
17
+ * as RGB because haze cannot assume the host terminal's palette.
18
+ * A theme spec may override slots with `palette`.
19
+ * 2. Roles — semantic haze surfaces (accent, command, warning, …) whose
20
+ * values are written in the same vocabulary an oh-my-zsh theme uses:
21
+ * a zsh color name, an xterm-256 index string, or `#rrggbb` hex.
22
+ *
23
+ * The built-in themes live in `src/ui/themes/` (one file per theme, named like
24
+ * its oh-my-zsh counterpart) — including ports of famous `.zsh-theme` files
25
+ * where `robbyrussell`'s `$fg_bold[green]➜` becomes `accent: 'green'`, its
26
+ * `$fg[cyan]%c` becomes `command: 'cyan'`, etc. See `src/ui/themes/AGENTS.md`
27
+ * for the full conversion guide and `docs/theming-plan.md` §6–§7 for the
28
+ * research and the segment → role translation table.
29
+ */
30
+ import { BUILT_IN_THEME_SPECS } from './themes/index.js';
31
+ export { BUILT_IN_THEME_SPECS };
32
+ /** The theme used when settings name none; also the fallback base for roles another theme omits. */
33
+ export declare const DEFAULT_THEME_NAME = "purple";
34
+ /** zsh `colors` associative-array keys — exactly the names `$fg[...]` accepts. */
35
+ export type ZshColorName = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'default';
36
+ export declare const ZSH_COLOR_NAMES: readonly ZshColorName[];
37
+ /**
38
+ * RGB approximation of the terminal palette slots the zsh names reference,
39
+ * based on the Tango palette (GNOME Terminal's classic default) because
40
+ * oh-my-zsh themes leave the actual RGB to the terminal. `default` approximates
41
+ * the terminal's default foreground color.
42
+ */
43
+ export declare const ZSH_NAMED_COLORS: Record<ZshColorName, string>;
44
+ /**
45
+ * A theme color value, written the way oh-my-zsh writes colors:
46
+ * a zsh color name (`'cyan'` for `$fg[cyan]`), an xterm-256 index string
47
+ * (`'214'` for `${FG[214]}`), or truecolor hex (`'#ff8800'` for `%F{#ff8800}`).
48
+ */
49
+ export type ColorSpec = ZshColorName | `#${string}` | `${number}`;
50
+ /**
51
+ * Resolved theme: every role is a normalized `#rrggbb` string Ink accepts.
52
+ * Semantic surfaces haze actually renders; the oh-my-zsh segment each one
53
+ * inherits from when porting is noted per role.
54
+ */
55
+ export interface HazeTheme {
56
+ /** Terminal default background (OSC 11): the canvas behind every haze surface. omz/VS Code/Sublime: the theme's `background`. */
57
+ background: string;
58
+ /** Brand/accent: app header, tool names, markers, links. omz: prompt-symbol segment (`$fg_bold[green]➜`). */
59
+ accent: string;
60
+ /** Dim accent: rules, heading underlines, table borders. omz: separator rules (`${FG[237]}` dashes in af-magic). */
61
+ accentDim: string;
62
+ /** Chrome borders: input box, panels. omz: segment dividers. */
63
+ border: string;
64
+ /** Info/tool headers. omz: secondary segment (`${FG[075]}` git parens in af-magic, `AGNOSTER_STATUS_JOB_FG`). */
65
+ info: string;
66
+ /** Secondary text: hints, timestamps, elisions. omz: muted separators (`${FG[237]}`). */
6
67
  muted: string;
7
- danger: string;
8
- dangerBg: string;
68
+ /** Primary text: task titles, diff code lines. omz: `$fg[default]` body text. */
69
+ foreground: string;
70
+ /** Slash commands, paths, handles. omz: cwd segment (`$fg[cyan]%c` in robbyrussell). */
71
+ command: string;
72
+ /** Success text: ✓ icons, completions. omz: exit-status-ok / clean-git colors. */
9
73
  success: string;
74
+ /** Background paired with `success` (added diff lines). */
10
75
  successBg: string;
76
+ /** Danger text: ✗ icons, removed diff lines. omz: exit-status-fail / `$fg_bold[red]`. */
77
+ danger: string;
78
+ /** Background paired with `danger` (removed diff lines). */
79
+ dangerBg: string;
80
+ /** Warnings, in-progress states. omz: git dirty marker (`$fg[yellow]✗` in robbyrussell). */
11
81
  warning: string;
12
- /** Slash commands, paths, and active terminal work; matches --command in docs/index.html. */
13
- command: string;
82
+ /** Quoted/user message surfaces. */
14
83
  surfaceBg: string;
84
+ /** Code fence / inline code background. */
15
85
  codeBg: string;
16
- };
86
+ }
87
+ export type HazeThemeRole = keyof HazeTheme;
88
+ export declare const THEME_ROLES: readonly HazeThemeRole[];
89
+ /**
90
+ * A theme as authored: role values in oh-my-zsh color vocabulary, plus optional
91
+ * palette overrides for themes whose host terminal palette defines the look
92
+ * (e.g. agnoster under Solarized). Roles omitted here inherit the `purple`
93
+ * theme's values, so partial ports are safe.
94
+ */
95
+ export interface HazeThemeSpec {
96
+ /** Override terminal palette slots; values must be `#rrggbb` hex. */
97
+ palette?: Partial<Record<ZshColorName, string>>;
98
+ roles?: Partial<Record<HazeThemeRole, ColorSpec>>;
99
+ }
100
+ /** xterm-256 index → RGB hex, mirroring zsh's `%F{nnn}` / `${FG[nnn]}` resolution. Base slots 0–7 resolve through the given palette. */
101
+ export declare function xterm256Color(index: number, palette?: Record<ZshColorName, string>): string;
102
+ /**
103
+ * Resolve a color spec (`'cyan'`, `'214'`, `'#ff8800'`) to `#rrggbb` hex.
104
+ * Throws with the accepted vocabulary for unknown values (fail loudly).
105
+ */
106
+ export declare function resolveColorSpec(spec: string, palette?: Record<ZshColorName, string>): string;
107
+ /** Resolve a built-in theme name (+ optional role overrides) to a complete `HazeTheme`. Throws with valid names for unknown themes. */
108
+ export declare function resolveTheme(name?: string, overrides?: Partial<Record<HazeThemeRole, string>>): HazeTheme;
109
+ /** The active theme instance; swap with `setActiveTheme` before rendering (and on future `/theme` switches). */
110
+ export declare let theme: HazeTheme;
111
+ export declare function setActiveTheme(next: HazeTheme): void;