@denizokcu/haze 0.10.0 → 1.0.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 (294) hide show
  1. package/CHANGELOG.md +100 -1
  2. package/README.md +77 -27
  3. package/SECURITY.md +22 -0
  4. package/bin/haze.js +102 -1
  5. package/dist/buildInfo.json +7 -0
  6. package/dist/cli/chat/TaskBar.d.ts +2 -1
  7. package/dist/cli/chat/TaskBar.js +7 -4
  8. package/dist/cli/chat/chatMetrics.d.ts +2 -2
  9. package/dist/cli/chat/chatMetrics.js +1 -1
  10. package/dist/cli/chat/contextReport.js +2 -0
  11. package/dist/cli/chat/fileMentionSuggestions.js +3 -2
  12. package/dist/cli/chat/inputSuggestions.d.ts +8 -16
  13. package/dist/cli/chat/inputSuggestions.js +9 -41
  14. package/dist/cli/chat/liveRegion.d.ts +25 -0
  15. package/dist/cli/chat/liveRegion.js +48 -0
  16. package/dist/cli/chat/messages.d.ts +33 -4
  17. package/dist/cli/chat/messages.js +218 -35
  18. package/dist/cli/chat/sessionLifecycle.d.ts +11 -1
  19. package/dist/cli/chat/sessionLifecycle.js +64 -14
  20. package/dist/cli/chat/sessionRecorder.js +75 -7
  21. package/dist/cli/chat/startupInfo.d.ts +0 -1
  22. package/dist/cli/chat/startupInfo.js +11 -15
  23. package/dist/cli/chat/turnState.d.ts +1 -1
  24. package/dist/cli/chat/wizardDispatch.d.ts +90 -28
  25. package/dist/cli/chat/wizardDispatch.js +349 -133
  26. package/dist/cli/commands/chat.d.ts +5 -0
  27. package/dist/cli/commands/chat.js +216 -172
  28. package/dist/cli/commands/chatModes.d.ts +8 -1
  29. package/dist/cli/commands/chatModes.js +9 -44
  30. package/dist/cli/commands/commands.d.ts +2 -0
  31. package/dist/cli/commands/commands.js +10 -5
  32. package/dist/cli/commands/doctor.d.ts +19 -0
  33. package/dist/cli/commands/doctor.js +76 -0
  34. package/dist/cli/commands/formatters.d.ts +3 -3
  35. package/dist/cli/commands/formatters.js +8 -25
  36. package/dist/cli/commands/ndjsonSink.d.ts +23 -0
  37. package/dist/cli/commands/ndjsonSink.js +38 -0
  38. package/dist/cli/commands/providerWizard.d.ts +9 -2
  39. package/dist/cli/commands/providerWizard.js +39 -7
  40. package/dist/cli/commands/runCommand.d.ts +3 -0
  41. package/dist/cli/commands/runCommand.js +117 -11
  42. package/dist/cli/commands/serverWizard.d.ts +34 -0
  43. package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
  44. package/dist/cli/commands/skillsWizard.d.ts +41 -0
  45. package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
  46. package/dist/cli/commands/streaming/abortCause.d.ts +25 -0
  47. package/dist/cli/commands/streaming/abortCause.js +16 -0
  48. package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
  49. package/dist/cli/commands/streaming/agentAttempt.js +79 -0
  50. package/dist/cli/commands/streaming/assistantText.js +9 -2
  51. package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
  52. package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
  53. package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
  54. package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
  55. package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
  56. package/dist/cli/commands/streaming/attemptSetup.js +167 -0
  57. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
  58. package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
  59. package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
  60. package/dist/cli/commands/streaming/goalSupervisor.js +130 -0
  61. package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
  62. package/dist/cli/commands/streaming/stallRecovery.js +105 -0
  63. package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
  64. package/dist/cli/commands/streaming/streamLoop.js +448 -0
  65. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +16 -0
  66. package/dist/cli/commands/streaming/toolCallRecovery.js +80 -0
  67. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -1
  68. package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -4
  69. package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
  70. package/dist/cli/commands/streaming/toolResultState.js +29 -7
  71. package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
  72. package/dist/cli/commands/streaming/turnRuntime.js +6 -0
  73. package/dist/cli/commands/streaming.d.ts +65 -9
  74. package/dist/cli/commands/streaming.js +133 -430
  75. package/dist/cli/commands/wizardFlow.d.ts +334 -0
  76. package/dist/cli/commands/wizardFlow.js +377 -0
  77. package/dist/cli/contextReport.js +3 -0
  78. package/dist/cli/index.js +68 -22
  79. package/dist/cli/terminalTitle.js +1 -1
  80. package/dist/config/contextFiles.js +9 -3
  81. package/dist/config/inputHistory.d.ts +0 -1
  82. package/dist/config/inputHistory.js +1 -1
  83. package/dist/config/modelDiscovery.d.ts +36 -0
  84. package/dist/config/modelDiscovery.js +164 -1
  85. package/dist/config/privateStorage.js +28 -2
  86. package/dist/config/providerAuth.d.ts +14 -0
  87. package/dist/config/providerAuth.js +49 -0
  88. package/dist/config/providerPresets.d.ts +39 -7
  89. package/dist/config/providerPresets.js +371 -100
  90. package/dist/config/providers.js +2 -0
  91. package/dist/config/settings.d.ts +43 -0
  92. package/dist/config/settings.js +12 -0
  93. package/dist/config/skillSettings.js +4 -4
  94. package/dist/config/updateCheck.d.ts +0 -1
  95. package/dist/config/updateCheck.js +1 -1
  96. package/dist/core/agent/budgets.d.ts +73 -1
  97. package/dist/core/agent/budgets.js +94 -1
  98. package/dist/core/agent/compaction.d.ts +38 -0
  99. package/dist/core/agent/compaction.js +92 -17
  100. package/dist/core/agent/completionController.d.ts +224 -0
  101. package/dist/core/agent/completionController.js +296 -0
  102. package/dist/core/agent/contextBudget.d.ts +36 -2
  103. package/dist/core/agent/contextBudget.js +62 -9
  104. package/dist/core/agent/errors.d.ts +0 -1
  105. package/dist/core/agent/errors.js +1 -1
  106. package/dist/core/agent/events.d.ts +78 -0
  107. package/dist/core/agent/goalPolicy.d.ts +47 -0
  108. package/dist/core/agent/goalPolicy.js +106 -0
  109. package/dist/core/agent/reasoningPolicy.d.ts +31 -0
  110. package/dist/core/agent/reasoningPolicy.js +27 -0
  111. package/dist/core/agent/requestAssembly.d.ts +2 -2
  112. package/dist/core/agent/requestAssembly.js +16 -4
  113. package/dist/core/agent/toolCapabilities.d.ts +27 -0
  114. package/dist/core/agent/toolCapabilities.js +58 -0
  115. package/dist/core/agent/toolOutputStore.d.ts +8 -0
  116. package/dist/core/agent/toolOutputStore.js +11 -11
  117. package/dist/core/agent/toolResults.d.ts +12 -0
  118. package/dist/core/agent/toolResults.js +38 -0
  119. package/dist/core/agent/turnPolicy.d.ts +11 -0
  120. package/dist/core/agent/turnPolicy.js +19 -0
  121. package/dist/core/agent/workState.d.ts +81 -3
  122. package/dist/core/agent/workState.js +176 -10
  123. package/dist/core/attachments/imageAttachments.js +90 -42
  124. package/dist/core/deadline.d.ts +27 -0
  125. package/dist/core/deadline.js +74 -0
  126. package/dist/core/io/boundedRead.js +1 -1
  127. package/dist/core/limits.d.ts +51 -0
  128. package/dist/core/limits.js +51 -0
  129. package/dist/core/log/llmLog.js +8 -1
  130. package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
  131. package/dist/core/persistence/orderedFileWriter.js +16 -2
  132. package/dist/core/process/backgroundRegistry.d.ts +2 -3
  133. package/dist/core/process/backgroundRegistry.js +15 -10
  134. package/dist/core/process/runBoundedProcess.d.ts +8 -2
  135. package/dist/core/process/runBoundedProcess.js +15 -6
  136. package/dist/core/process/userShell.d.ts +16 -0
  137. package/dist/core/process/userShell.js +59 -0
  138. package/dist/core/safety/missingExecutable.d.ts +42 -0
  139. package/dist/core/safety/missingExecutable.js +77 -0
  140. package/dist/core/safety/shellClassifier.d.ts +11 -0
  141. package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
  142. package/dist/core/safety/urlGuard.d.ts +1 -1
  143. package/dist/core/session/sessionSlimming.d.ts +0 -3
  144. package/dist/core/session/sessionSlimming.js +2 -3
  145. package/dist/core/session/sessionStore.d.ts +38 -0
  146. package/dist/core/session/sessionStore.js +242 -59
  147. package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
  148. package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
  149. package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
  150. package/dist/core/shellOutput/registry.d.ts +2 -0
  151. package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
  152. package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
  153. package/dist/core/subagent/contracts.d.ts +6 -14
  154. package/dist/core/subagent/contracts.js +4 -3
  155. package/dist/core/subagent/executionProfiles.js +2 -2
  156. package/dist/core/subagent/subagentCoordinator.d.ts +4 -0
  157. package/dist/core/subagent/subagentCoordinator.js +32 -2
  158. package/dist/core/subagent/subagentRunner.js +19 -40
  159. package/dist/core/toolOutput/reduction.d.ts +0 -12
  160. package/dist/core/toolOutput/reduction.js +1 -1
  161. package/dist/core/validation/outputParser.d.ts +2 -2
  162. package/dist/llm/client.d.ts +17 -1
  163. package/dist/llm/client.js +86 -14
  164. package/dist/llm/hazeTools.d.ts +693 -204
  165. package/dist/llm/hazeTools.js +110 -28
  166. package/dist/llm/initPrompt.js +1 -1
  167. package/dist/llm/lsp/client.d.ts +45 -0
  168. package/dist/llm/lsp/client.js +195 -0
  169. package/dist/llm/lsp/pool.d.ts +23 -0
  170. package/dist/llm/lsp/pool.js +86 -0
  171. package/dist/llm/lsp/protocol.d.ts +64 -0
  172. package/dist/llm/lsp/protocol.js +128 -0
  173. package/dist/llm/lsp/requests.d.ts +94 -0
  174. package/dist/llm/lsp/requests.js +119 -0
  175. package/dist/llm/lspTools.d.ts +5653 -33
  176. package/dist/llm/lspTools.js +152 -80
  177. package/dist/llm/openaiCodex.d.ts +1 -0
  178. package/dist/llm/openaiCodex.js +43 -0
  179. package/dist/llm/openaiCodexOAuth.d.ts +51 -0
  180. package/dist/llm/openaiCodexOAuth.js +217 -0
  181. package/dist/llm/requestContext.d.ts +7 -0
  182. package/dist/llm/requestContext.js +30 -4
  183. package/dist/llm/systemPrompt.d.ts +12 -0
  184. package/dist/llm/systemPrompt.js +24 -11
  185. package/dist/llm/toolResultTypes.d.ts +7 -14
  186. package/dist/llm/toolResultTypes.js +1 -4
  187. package/dist/llm/tools/editMatch.d.ts +14 -9
  188. package/dist/llm/tools/editMatch.js +73 -1
  189. package/dist/llm/tools/failures.d.ts +2 -0
  190. package/dist/llm/tools/failures.js +1 -0
  191. package/dist/llm/tools/fetchTool.d.ts +16 -0
  192. package/dist/llm/tools/fetchTool.js +1 -1
  193. package/dist/llm/tools/fileToolShared.d.ts +8 -5
  194. package/dist/llm/tools/fileToolShared.js +22 -23
  195. package/dist/llm/tools/gitIgnore.d.ts +42 -0
  196. package/dist/llm/tools/gitIgnore.js +247 -0
  197. package/dist/llm/tools/grepParse.d.ts +2 -1
  198. package/dist/llm/tools/grepRunner.d.ts +1 -1
  199. package/dist/llm/tools/grepRunner.js +2 -2
  200. package/dist/llm/tools/outputCap.d.ts +2 -7
  201. package/dist/llm/tools/outputCap.js +3 -3
  202. package/dist/llm/tools/processTool.d.ts +16 -16
  203. package/dist/llm/tools/processTool.js +1 -1
  204. package/dist/llm/tools/readRecovery.d.ts +8 -0
  205. package/dist/llm/tools/readRecovery.js +135 -0
  206. package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +171 -123
  207. package/dist/llm/tools/{bashTool.js → shellTool.js} +20 -14
  208. package/dist/llm/tools/toolContext.d.ts +1 -1
  209. package/dist/llm/tools/toolContext.js +66 -37
  210. package/dist/llm/tools/workspaceFile.d.ts +0 -1
  211. package/dist/llm/tools/workspaceFile.js +1 -6
  212. package/dist/llm/webFetch.d.ts +18 -1
  213. package/dist/llm/webFetch.js +64 -97
  214. package/dist/skills/SkillLoader.d.ts +1 -11
  215. package/dist/skills/SkillLoader.js +1 -2
  216. package/dist/skills/types.d.ts +2 -1
  217. package/dist/ui/codeHighlight.d.ts +4 -0
  218. package/dist/ui/codeHighlight.js +31 -0
  219. package/dist/ui/components/Header.d.ts +1 -1
  220. package/dist/ui/components/MarkdownText.d.ts +16 -2
  221. package/dist/ui/components/MarkdownText.js +244 -34
  222. package/dist/ui/components/TextInput.d.ts +8 -1
  223. package/dist/ui/components/TextInput.js +6 -2
  224. package/dist/ui/theme.d.ts +4 -3
  225. package/dist/ui/theme.js +5 -4
  226. package/dist/utils/buildInfo.d.ts +97 -0
  227. package/dist/utils/buildInfo.js +244 -0
  228. package/dist/utils/fs.d.ts +11 -0
  229. package/dist/utils/fs.js +91 -26
  230. package/dist/utils/openPath.d.ts +2 -2
  231. package/dist/utils/openPath.js +19 -6
  232. package/dist/utils/path.d.ts +2 -1
  233. package/dist/utils/path.js +6 -2
  234. package/dist/utils/utf8.d.ts +22 -0
  235. package/dist/utils/utf8.js +54 -0
  236. package/dist/utils/version.d.ts +9 -3
  237. package/dist/utils/version.js +28 -2
  238. package/package.json +28 -21
  239. package/dist/cli/commands/lspWizard.d.ts +0 -14
  240. package/dist/cli/commands/lspWizard.js +0 -44
  241. package/dist/cli/commands/mcpWizard.d.ts +0 -15
  242. package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
  243. package/dist/cli/commands/skillConfirmRemove.js +0 -20
  244. package/dist/cli/commands/skillCreation.d.ts +0 -12
  245. package/dist/cli/commands/skillCreation.js +0 -14
  246. package/dist/cli/commands/skillWizard.d.ts +0 -17
  247. package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
  248. package/dist/cli/commands/streaming/idleTimer.js +0 -24
  249. package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -10
  250. package/dist/cli/commands/streaming/turnOutcome.js +0 -13
  251. package/dist/cli/commands/wizardActions.d.ts +0 -46
  252. package/dist/cli/commands/wizardActions.js +0 -46
  253. package/dist/cli/commands/wizardInput.d.ts +0 -4
  254. package/dist/cli/commands/wizardInput.js +0 -19
  255. package/dist/cli/commands/wizardPrompts.d.ts +0 -22
  256. package/dist/cli/commands/wizardPrompts.js +0 -52
  257. package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
  258. package/dist/cli/commands/wizardSuggestions.js +0 -188
  259. package/dist/cli/commands/wizardTransition.d.ts +0 -37
  260. package/dist/cli/commands/wizardTransition.js +0 -43
  261. package/dist/core/bashOutput/ansi.d.ts +0 -1
  262. package/dist/core/bashOutput/ansi.js +0 -7
  263. package/dist/core/bashOutput/registry.d.ts +0 -4
  264. package/dist/core/goal/completionPolicy.d.ts +0 -2
  265. package/dist/core/goal/completionPolicy.js +0 -7
  266. package/dist/core/goal/requestClassifier.d.ts +0 -3
  267. package/dist/core/goal/requestClassifier.js +0 -18
  268. package/dist/core/goal/sessionGoal.d.ts +0 -8
  269. package/dist/core/goal/sessionGoal.js +0 -30
  270. package/dist/core/limits/byteBudgets.d.ts +0 -18
  271. package/dist/core/limits/byteBudgets.js +0 -18
  272. package/dist/core/limits/textBudgets.d.ts +0 -23
  273. package/dist/core/limits/textBudgets.js +0 -23
  274. package/dist/core/safety/bashClassifier.d.ts +0 -10
  275. package/dist/llm/lsp.d.ts +0 -129
  276. package/dist/llm/lsp.js +0 -307
  277. package/dist/ui/components/ErrorView.d.ts +0 -4
  278. package/dist/ui/components/ErrorView.js +0 -7
  279. package/dist/utils/yaml.d.ts +0 -2
  280. package/dist/utils/yaml.js +0 -8
  281. package/examples/skills/files/SKILL.md +0 -16
  282. package/examples/skills/files/examples/file-editing.md +0 -3
  283. /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
  284. /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
  285. /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
  286. /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
  287. /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
  288. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
  289. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
  290. /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
  291. /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
  292. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
  293. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
  294. /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
@@ -0,0 +1,31 @@
1
+ import { highlight, supportsLanguage } from 'cli-highlight';
2
+ import stripAnsi from 'strip-ansi';
3
+ /** Map a source path to a cli-highlight language when its extension is known. */
4
+ export function languageForPath(filePath) {
5
+ const extension = /\.([^./]+)$/.exec(filePath)?.[1]?.toLowerCase();
6
+ if (!extension)
7
+ return undefined;
8
+ const aliases = {
9
+ cjs: 'javascript', cts: 'typescript', htm: 'html', js: 'javascript', md: 'markdown', mjs: 'javascript',
10
+ mts: 'typescript', py: 'python', rb: 'ruby', sh: 'bash', ts: 'typescript', yml: 'yaml',
11
+ };
12
+ const language = aliases[extension] ?? extension;
13
+ return supportsLanguage(language) ? language : undefined;
14
+ }
15
+ /** Highlight, clip, and pad one source line to an exact terminal width. */
16
+ export function highlightedCodeLine(code, width, language) {
17
+ const safeWidth = Math.max(1, width);
18
+ const singleLine = code.replace(/\t/g, ' ');
19
+ const fitted = singleLine.length > safeWidth
20
+ ? `${singleLine.slice(0, Math.max(0, safeWidth - 1))}…`
21
+ : singleLine;
22
+ let rendered = fitted;
23
+ try {
24
+ rendered = highlight(fitted, { language: language || undefined, ignoreIllegals: true });
25
+ }
26
+ catch {
27
+ // Unknown or malformed source still renders as plain text.
28
+ }
29
+ const padding = Math.max(0, safeWidth - stripAnsi(rendered).length);
30
+ return `${rendered}${' '.repeat(padding)}`;
31
+ }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  export declare function Header({ subtitle, version }: {
3
- subtitle?: string;
3
+ subtitle?: React.ReactNode;
4
4
  version?: string;
5
5
  }): React.JSX.Element;
@@ -1,6 +1,20 @@
1
1
  import React from 'react';
2
2
  import { type Tokens } from 'marked';
3
- export declare function MarkdownText({ content }: {
3
+ export declare const MarkdownText: React.MemoExoticComponent<({ content, width }: {
4
4
  content: string;
5
- }): React.JSX.Element;
5
+ width: number;
6
+ }) => React.JSX.Element>;
7
+ /** Test-only: clear the chunk cache to assert lexer call counts deterministically. */
8
+ export declare function clearMarkdownRootChunksCacheForTests(): void;
9
+ /**
10
+ * Split Markdown into stable root-level chunks. The final chunk is deliberately
11
+ * considered active: Marked may still reclassify it as more text arrives (for
12
+ * example, a paragraph can become a setext heading or a GFM table). Once a
13
+ * following root block exists, the preceding chunk is safe to render once in
14
+ * Ink's <Static> transcript.
15
+ *
16
+ * A source-path lead and its following fenced code block stay in one chunk so
17
+ * MarkdownText can preserve their shared filename and starting line metadata.
18
+ */
19
+ export declare function markdownRootChunks(content: string): string[];
6
20
  export declare function renderMarkdownTable(table: Tokens.Table, maxWidth?: number): string[];
@@ -1,16 +1,91 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box, Text, useStdout } from 'ink';
2
+ import React from 'react';
3
+ import { Box, Text } from 'ink';
3
4
  import { marked } from 'marked';
4
- import { highlight } from 'cli-highlight';
5
5
  import stripAnsi from 'strip-ansi';
6
6
  import { theme } from '../theme.js';
7
- export function MarkdownText({ content }) {
8
- const tokens = marked.lexer(content, { gfm: true, breaks: true });
9
- const { stdout } = useStdout();
10
- const width = Math.max(20, (stdout.columns ?? process.stdout.columns ?? 100) - 2);
11
- return _jsx(Box, { flexDirection: "column", children: tokens.map((token, index) => _jsx(MarkdownBlock, { token: token, width: width }, index)) });
7
+ import { highlightedCodeLine } from '../codeHighlight.js';
8
+ const MARKED_OPTIONS = { gfm: true, breaks: true };
9
+ export const MarkdownText = React.memo(function MarkdownText({ content, width }) {
10
+ const tokens = marked.lexer(content, MARKED_OPTIONS);
11
+ const contentWidth = Math.max(20, width - 2);
12
+ return _jsx(Box, { flexDirection: "column", children: tokens.map((token, index) => {
13
+ const codeLead = token.type === 'paragraph' || token.type === 'text' ? codeLeadForFollowingFence(tokens, index) : undefined;
14
+ if (token.type === 'space' && bridgesCodeLeadToFence(tokens, index))
15
+ return null;
16
+ return _jsx(MarkdownBlock, { token: token, width: contentWidth, source: token.type === 'code' ? precedingCodeSource(tokens, index) : undefined, textOverride: codeLead?.text, compactAfter: codeLead != null }, index);
17
+ }) });
18
+ });
19
+ /**
20
+ * Bounded LRU cache for Markdown root chunking (RH-007). Settled assistant
21
+ * messages never change, but `partitionDisplayMessages` runs on every render
22
+ * and would otherwise re-lex the entire historical transcript each time. The
23
+ * chunking is a pure function of the source text, so identical content reuses a
24
+ * cached result; the LRU bound keeps memory predictable for long sessions.
25
+ */
26
+ const ROOT_CHUNKS_CACHE_MAX = 500;
27
+ const rootChunksCache = new Map();
28
+ /** Test-only: clear the chunk cache to assert lexer call counts deterministically. */
29
+ export function clearMarkdownRootChunksCacheForTests() {
30
+ rootChunksCache.clear();
31
+ }
32
+ function computeMarkdownRootChunks(content) {
33
+ const tokens = marked.lexer(content, MARKED_OPTIONS);
34
+ if (tokens.length === 0)
35
+ return content ? [content] : [];
36
+ const chunks = [];
37
+ let chunkStart = 0;
38
+ for (let index = 0; index < tokens.length; index++) {
39
+ const token = tokens[index];
40
+ if (!token || token.type === 'space')
41
+ continue;
42
+ let nextIndex = index + 1;
43
+ while (tokens[nextIndex]?.type === 'space')
44
+ nextIndex++;
45
+ if (nextIndex >= tokens.length)
46
+ continue;
47
+ const linkedCodeBlock = (token.type === 'paragraph' || token.type === 'text')
48
+ && tokens[nextIndex]?.type === 'code'
49
+ && codeLeadForFollowingFence(tokens, index) != null;
50
+ if (linkedCodeBlock)
51
+ continue;
52
+ const chunk = tokens.slice(chunkStart, nextIndex).map(item => item.raw).join('');
53
+ if (chunk)
54
+ chunks.push(chunk);
55
+ chunkStart = nextIndex;
56
+ }
57
+ const activeChunk = tokens.slice(chunkStart).map(token => token.raw).join('');
58
+ if (activeChunk)
59
+ chunks.push(activeChunk);
60
+ return chunks;
61
+ }
62
+ /**
63
+ * Split Markdown into stable root-level chunks. The final chunk is deliberately
64
+ * considered active: Marked may still reclassify it as more text arrives (for
65
+ * example, a paragraph can become a setext heading or a GFM table). Once a
66
+ * following root block exists, the preceding chunk is safe to render once in
67
+ * Ink's <Static> transcript.
68
+ *
69
+ * A source-path lead and its following fenced code block stay in one chunk so
70
+ * MarkdownText can preserve their shared filename and starting line metadata.
71
+ */
72
+ export function markdownRootChunks(content) {
73
+ const cached = rootChunksCache.get(content);
74
+ if (cached) {
75
+ rootChunksCache.delete(content);
76
+ rootChunksCache.set(content, cached);
77
+ return cached;
78
+ }
79
+ const chunks = computeMarkdownRootChunks(content);
80
+ if (rootChunksCache.size >= ROOT_CHUNKS_CACHE_MAX) {
81
+ const oldest = rootChunksCache.keys().next().value;
82
+ if (oldest !== undefined)
83
+ rootChunksCache.delete(oldest);
84
+ }
85
+ rootChunksCache.set(content, chunks);
86
+ return chunks;
12
87
  }
13
- function MarkdownBlock({ token, width }) {
88
+ function MarkdownBlock({ token, width, source, textOverride, compactAfter }) {
14
89
  switch (token.type) {
15
90
  case 'heading': {
16
91
  const heading = token;
@@ -18,11 +93,11 @@ function MarkdownBlock({ token, width }) {
18
93
  }
19
94
  case 'paragraph': {
20
95
  const paragraph = token;
21
- return _jsx(Box, { marginBottom: 1, children: _jsx(InlineMarkdown, { text: paragraph.text }) });
96
+ return _jsx(Box, { marginBottom: compactAfter ? 0 : 1, children: _jsx(InlineMarkdown, { text: textOverride ?? paragraph.text }) });
22
97
  }
23
98
  case 'text': {
24
99
  const text = token;
25
- return _jsx(InlineMarkdown, { text: text.text });
100
+ return _jsx(InlineMarkdown, { text: textOverride ?? text.text });
26
101
  }
27
102
  case 'space':
28
103
  return _jsx(Text, { children: " " });
@@ -30,15 +105,16 @@ function MarkdownBlock({ token, width }) {
30
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" });
31
106
  case 'blockquote': {
32
107
  const quote = token;
33
- return _jsx(Box, { flexDirection: "column", marginY: 1, children: quote.text.split('\n').map((line, index) => _jsx(Text, { backgroundColor: theme.quoteBg, children: padAnsi(line || ' ', width) }, index)) });
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)) });
34
109
  }
35
110
  case 'list': {
36
111
  const list = token;
37
- return _jsx(Box, { flexDirection: "column", marginBottom: 1, children: list.items.map((item, index) => _jsxs(Box, { children: [_jsx(Text, { color: theme.purple, children: list.ordered ? `${index + 1}. ` : '• ' }), _jsx(InlineMarkdown, { text: item.text.replace(/\n/g, ' ') })] }, index)) });
112
+ return _jsx(Box, { flexDirection: "column", marginBottom: 1, children: list.items.map((item, index) => (_jsx(ListItemView, { item: item, ordered: list.ordered, index: index, width: width }, index))) });
38
113
  }
39
114
  case 'code': {
40
115
  const code = token;
41
- return _jsx(CodeBlock, { code: code.text, language: code.lang, width: width });
116
+ const fence = parseCodeFenceInfo(code.lang);
117
+ return _jsx(CodeBlock, { code: code.text, language: fence.language, source: fence.source ?? source, width: width });
42
118
  }
43
119
  case 'table': {
44
120
  const table = token;
@@ -49,13 +125,40 @@ function MarkdownBlock({ token, width }) {
49
125
  return _jsx(Text, { children: 'raw' in token ? String(token.raw) : '' });
50
126
  }
51
127
  }
128
+ function ListItemView({ item, ordered, index, width }) {
129
+ const marker = ordered ? `${index + 1}. ` : '• ';
130
+ const markerWidth = visibleLength(marker);
131
+ const blocks = (item.tokens ?? []).filter(child => child.type !== 'space');
132
+ if (blocks.length === 0) {
133
+ return _jsx(Box, { children: _jsx(Text, { color: theme.purple, children: marker }) });
134
+ }
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
+ }
137
+ function ListItemBlock({ token, marker, markerWidth, width }) {
138
+ if (token.type === 'paragraph' || token.type === 'text') {
139
+ const text = token.text;
140
+ // Pre-wrap manually. Ink's auto-wrap algorithm injects a stray leading
141
+ // space on wrapped lines at certain widths (the wrap-point whitespace gets
142
+ // preserved on top of the marker indent), so we hand-pack atoms into lines
143
+ // and render each line as its own row. Whitespace is preserved as separate
144
+ // "space" atoms so the original spacing (e.g. "code, code") survives.
145
+ const contentWidth = Math.max(1, width - markerWidth);
146
+ const lines = wrapInlineAtoms(splitInlineIntoAtoms(tokenizeInline(text)), contentWidth);
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))) });
149
+ }
150
+ // Block-level content (code, nested list, blockquote, table). The marker
151
+ // sits on its own line when this is the first block; the block then renders
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) }) })] });
154
+ }
52
155
  function HeadingBlock({ heading, width }) {
53
156
  const title = stripInline(heading.text).trim();
54
157
  if (heading.depth === 1)
55
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)))) })] });
56
159
  if (heading.depth === 2)
57
160
  return _jsx(Box, { marginTop: 1, marginBottom: 1, children: _jsx(Text, { color: theme.purple, bold: true, children: title }) });
58
- return _jsx(Box, { marginTop: heading.depth <= 3 ? 1 : 0, children: _jsx(Text, { color: theme.violet, bold: true, children: title }) });
161
+ return _jsx(Box, { marginTop: heading.depth <= 3 ? 1 : 0, children: _jsx(Text, { color: theme.purple, bold: true, children: title }) });
59
162
  }
60
163
  function TableLine({ line }) {
61
164
  if (isTableBorder(line))
@@ -64,30 +167,137 @@ function TableLine({ line }) {
64
167
  ? _jsx(Text, { color: theme.deepPurple, children: char }, index)
65
168
  : _jsx(Text, { children: char }, index)) });
66
169
  }
67
- function CodeBlock({ code, language, width }) {
68
- let rendered;
69
- try {
70
- rendered = highlight(code, { language: language || undefined, ignoreIllegals: true });
71
- }
72
- catch {
73
- rendered = code;
170
+ function CodeBlock({ code, language, source, width }) {
171
+ const lines = code.replace(/\n$/, '').split('\n');
172
+ const firstLine = source?.startLine ?? 1;
173
+ const showLineNumbers = source != null || lines.length > 1;
174
+ const lineNumberWidth = String(firstLine + lines.length - 1).length;
175
+ const header = source ? `${source.path}:${source.startLine}${language ? ` · ${language}` : ''}` : language;
176
+ return _jsxs(Box, { flexDirection: "column", marginTop: source ? 0 : 1, marginBottom: 1, children: [header ? _jsx(Text, { color: source ? theme.command : theme.muted, backgroundColor: theme.codeBg, children: padAnsi(header, width) }) : null, lines.map((line, index) => {
177
+ const lineNumber = firstLine + index;
178
+ const prefix = showLineNumbers ? `${String(lineNumber).padStart(lineNumberWidth)} │ ` : '';
179
+ const rendered = highlightedCodeLine(line, Math.max(1, width - prefix.length), language);
180
+ return _jsxs(Text, { backgroundColor: theme.codeBg, children: [prefix ? _jsx(Text, { color: theme.muted, backgroundColor: theme.codeBg, children: prefix }) : null, rendered] }, index);
181
+ })] });
182
+ }
183
+ function parseCodeSource(value) {
184
+ const match = /((?:[A-Za-z]:)?[^\s`()]+?\.[A-Za-z0-9]+):([1-9]\d*)(?:-[1-9]\d*)?[).,;:]?$/.exec(stripInline(value).trim());
185
+ if (!match)
186
+ return undefined;
187
+ return { path: match[1], startLine: Number(match[2]) };
188
+ }
189
+ function precedingCodeSource(tokens, codeIndex) {
190
+ for (let index = codeIndex - 1; index >= 0; index--) {
191
+ const token = tokens[index];
192
+ if (!token || token.type === 'space')
193
+ continue;
194
+ if (token.type !== 'paragraph' && token.type !== 'text')
195
+ return undefined;
196
+ return parseCodeSource(token.text);
74
197
  }
75
- const lines = rendered.replace(/\n$/, '').split('\n');
76
- return _jsxs(Box, { flexDirection: "column", marginY: 1, children: [language ? _jsx(Text, { color: theme.muted, backgroundColor: theme.codeBg, children: padAnsi(language, width) }) : null, lines.map((line, index) => _jsx(Text, { backgroundColor: theme.codeBg, children: padAnsi(line || ' ', width) }, index))] });
198
+ return undefined;
199
+ }
200
+ function codeLeadForFollowingFence(tokens, leadIndex) {
201
+ const token = tokens[leadIndex];
202
+ if (!token || (token.type !== 'paragraph' && token.type !== 'text'))
203
+ return undefined;
204
+ const value = token.text;
205
+ const source = parseCodeSource(value);
206
+ if (!source)
207
+ return undefined;
208
+ let nextIndex = leadIndex + 1;
209
+ while (tokens[nextIndex]?.type === 'space')
210
+ nextIndex++;
211
+ if (tokens[nextIndex]?.type !== 'code')
212
+ return undefined;
213
+ const pathIndex = value.lastIndexOf(source.path);
214
+ const text = value.slice(0, pathIndex).replace(/\s*(?:—|–|-)\s*`?\s*$/, '').trimEnd();
215
+ return { source, text };
216
+ }
217
+ function bridgesCodeLeadToFence(tokens, spaceIndex) {
218
+ let previousIndex = spaceIndex - 1;
219
+ while (tokens[previousIndex]?.type === 'space')
220
+ previousIndex--;
221
+ let nextIndex = spaceIndex + 1;
222
+ while (tokens[nextIndex]?.type === 'space')
223
+ nextIndex++;
224
+ return codeLeadForFollowingFence(tokens, previousIndex) != null && tokens[nextIndex]?.type === 'code';
225
+ }
226
+ function parseCodeFenceInfo(info) {
227
+ const parts = info?.trim().split(/\s+/).filter(Boolean) ?? [];
228
+ const firstSource = parts.findIndex(part => parseCodeSource(part) != null);
229
+ if (firstSource === -1)
230
+ return { language: parts[0] };
231
+ return {
232
+ language: firstSource === 0 ? undefined : parts[0],
233
+ source: parseCodeSource(parts[firstSource]),
234
+ };
77
235
  }
78
236
  function InlineMarkdown({ text }) {
79
237
  const parts = tokenizeInline(text);
80
- return _jsx(Text, { children: parts.map((part, index) => {
81
- if (part.kind === 'code')
82
- return _jsx(Text, { color: theme.warning, children: part.text }, index);
83
- if (part.kind === 'strong')
84
- return _jsx(Text, { bold: true, children: part.text }, index);
85
- if (part.kind === 'em')
86
- return _jsx(Text, { italic: true, children: part.text }, index);
87
- if (part.kind === 'link')
88
- return _jsx(Text, { color: theme.violet, children: part.text }, index);
89
- return _jsx(Text, { children: part.text }, index);
90
- }) });
238
+ return _jsx(Text, { children: parts.map((part, index) => renderInlinePart(part, index)) });
239
+ }
240
+ function renderInlinePart(part, index) {
241
+ if (part.kind === 'code')
242
+ return _jsx(Text, { color: theme.warning, backgroundColor: theme.codeBg, children: part.text }, index);
243
+ if (part.kind === 'strong')
244
+ return _jsx(Text, { bold: true, children: part.text }, index);
245
+ if (part.kind === 'em')
246
+ return _jsx(Text, { italic: true, children: part.text }, index);
247
+ if (part.kind === 'link')
248
+ return _jsx(Text, { color: theme.purple, children: part.text }, index);
249
+ return _jsx(Text, { children: part.text }, index);
250
+ }
251
+ function splitInlineIntoAtoms(parts) {
252
+ const atoms = [];
253
+ for (const part of parts) {
254
+ for (const piece of part.text.split(/(\s+)/)) {
255
+ if (piece === '')
256
+ continue;
257
+ if (/^\s+$/.test(piece))
258
+ atoms.push({ type: 'space' });
259
+ else
260
+ atoms.push({ type: 'word', kind: part.kind, text: piece });
261
+ }
262
+ }
263
+ return atoms;
264
+ }
265
+ function wrapInlineAtoms(atoms, maxWidth) {
266
+ const lines = [];
267
+ let line = [];
268
+ let width = 0;
269
+ const flushLine = () => {
270
+ while (line.length > 0 && line[line.length - 1].type === 'space')
271
+ line.pop();
272
+ if (line.length > 0)
273
+ lines.push(line);
274
+ line = [];
275
+ width = 0;
276
+ };
277
+ for (const atom of atoms) {
278
+ if (atom.type === 'space') {
279
+ if (width > 0) {
280
+ line.push(atom);
281
+ width += 1;
282
+ }
283
+ continue;
284
+ }
285
+ const wordWidth = visibleLength(atom.text);
286
+ if (wordWidth > maxWidth && width === 0) {
287
+ // Overlong word on its own line: keep it whole so we don't pretend to
288
+ // have wrap behavior we can't actually render.
289
+ lines.push([atom]);
290
+ line = [];
291
+ width = 0;
292
+ continue;
293
+ }
294
+ if (width > 0 && width + wordWidth > maxWidth)
295
+ flushLine();
296
+ line.push(atom);
297
+ width += wordWidth;
298
+ }
299
+ flushLine();
300
+ return lines.length > 0 ? lines : [[]];
91
301
  }
92
302
  function tokenizeInline(text) {
93
303
  const out = [];
@@ -12,7 +12,7 @@ export type TextInputSuggestion = {
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[];
15
- export declare function TextInput({ placeholder, disabled, mask, historyItems, recordHistory, suggestions, suggestionMode, submitOnEmpty, width, getMentionSuggestions, onHistoryAdd, onCancel, onEscape, onToggleTasks, onSubmit }: {
15
+ export declare function TextInput({ placeholder, disabled, mask, historyItems, recordHistory, suggestions, suggestionMode, submitOnEmpty, width, getMentionSuggestions, onHistoryAdd, onCancel, onEscape, onToggleTasks, onResumeKey, onSubmit }: {
16
16
  placeholder?: string;
17
17
  disabled?: boolean;
18
18
  mask?: boolean;
@@ -27,6 +27,13 @@ export declare function TextInput({ placeholder, disabled, mask, historyItems, r
27
27
  onCancel?: () => void;
28
28
  onEscape?: () => void;
29
29
  onToggleTasks?: () => void;
30
+ /**
31
+ * One-key resume affordance: when provided and the input is empty, a bare
32
+ * R/R resumes the paused task instead of typing the character. The caller
33
+ * (chat) only provides it while a paused turn is pending and renders the
34
+ * matching hint line, so ordinary typing is unaffected.
35
+ */
36
+ onResumeKey?: () => void;
30
37
  onSubmit: (value: string) => void;
31
38
  }): React.JSX.Element;
32
39
  export {};
@@ -11,7 +11,7 @@ export function shouldInsertNewline(input, key) {
11
11
  || input === '\n'
12
12
  || CTRL_ENTER_ESCAPE_INPUTS.has(input);
13
13
  }
14
- export function TextInput({ placeholder, disabled, mask, historyItems = [], recordHistory = true, suggestions = [], suggestionMode = 'slash', submitOnEmpty = false, width = 80, getMentionSuggestions, onHistoryAdd, onCancel, onEscape, onToggleTasks, onSubmit }) {
14
+ export function TextInput({ placeholder, disabled, mask, historyItems = [], recordHistory = true, suggestions = [], suggestionMode = 'slash', submitOnEmpty = false, width = 80, getMentionSuggestions, onHistoryAdd, onCancel, onEscape, onToggleTasks, onResumeKey, onSubmit }) {
15
15
  const [value, setValue] = useState('');
16
16
  const [cursor, setCursor] = useState(0);
17
17
  const [pasteBlocks, setPasteBlocks] = useState([]);
@@ -140,6 +140,10 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
140
140
  onEscape?.();
141
141
  return;
142
142
  }
143
+ if (onResumeKey && value.length === 0 && !key.ctrl && !key.meta && (input === 'r' || input === 'R')) {
144
+ onResumeKey();
145
+ return;
146
+ }
143
147
  if (key.tab && activeSuggestion) {
144
148
  if (inMentionMode && detectedMention) {
145
149
  // Partial replacement of the `@token` range, not the whole input —
@@ -280,7 +284,7 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
280
284
  const visibleLines = wrappedLines.slice(firstVisibleLine, firstVisibleLine + maxVisibleLines);
281
285
  const displayList = inMentionMode ? mentionList : filteredSuggestions;
282
286
  const displayActiveIndex = inMentionMode ? activeMentionIndex : activeSuggestionIndex;
283
- 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, dimColor: true, 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.purple, children: "\u203A " }), _jsx(Text, { inverse: true, children: " " }), _jsxs(Text, { color: theme.muted, children: [" ", placeholder ?? 'Type a message...'] })] }) : visibleLines.map((line, index) => {
284
288
  const absoluteLineIndex = firstVisibleLine + index;
285
289
  const isCursorLine = absoluteLineIndex === currentCursorPosition.lineIndex;
286
290
  const lineCursor = isCursorLine ? Math.max(0, Math.min(displayCursor - line.start, line.text.length)) : -1;
@@ -1,7 +1,7 @@
1
1
  export declare const theme: {
2
+ foreground: string;
2
3
  purple: string;
3
4
  deepPurple: string;
4
- violet: string;
5
5
  blue: string;
6
6
  muted: string;
7
7
  danger: string;
@@ -9,7 +9,8 @@ export declare const theme: {
9
9
  success: string;
10
10
  successBg: string;
11
11
  warning: string;
12
- orange: string;
12
+ /** Slash commands, paths, and active terminal work; matches --command in docs/index.html. */
13
+ command: string;
14
+ surfaceBg: string;
13
15
  codeBg: string;
14
- quoteBg: string;
15
16
  };
package/dist/ui/theme.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const theme = {
2
+ foreground: 'white',
2
3
  purple: '#a78bfa',
3
4
  deepPurple: '#6d28d9',
4
- violet: '#8b5cf6',
5
5
  blue: '#60a5fa',
6
6
  muted: '#9ca3af',
7
7
  danger: '#fb7185',
@@ -9,7 +9,8 @@ export const theme = {
9
9
  success: '#39ff14',
10
10
  successBg: '#14331f',
11
11
  warning: '#fbbf24',
12
- orange: '#f59e0b',
13
- codeBg: '#1f1633',
14
- quoteBg: '#171127'
12
+ /** Slash commands, paths, and active terminal work; matches --command in docs/index.html. */
13
+ command: '#ffb86c',
14
+ surfaceBg: '#1f1633',
15
+ codeBg: '#202124',
15
16
  };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Build provenance embedded by `npm run build` (dist/buildInfo.json). Safe
3
+ * metadata only — never environment, credentials, or conversation content.
4
+ */
5
+ export interface BuildInfo {
6
+ name: string;
7
+ version: string;
8
+ commit?: string;
9
+ builtAt?: string;
10
+ sourceRoot?: string;
11
+ }
12
+ /**
13
+ * Runtime capability registry: observable facts about the running build, so
14
+ * behavior can be diagnosed without inferring it from semantic versions. The
15
+ * goal supervisor's compiled artifact gates logical-goal supervision, cross-turn
16
+ * checkpoints, and automatic budget continuation together, so a single flag
17
+ * describes all supervisor-derived behavior; a runtime missing the artifact
18
+ * reports it unavailable.
19
+ */
20
+ export interface RuntimeCapabilities {
21
+ goalSupervisorAvailable: boolean;
22
+ }
23
+ /** Compiled module whose presence proves the autonomous goal supervisor is in this build. */
24
+ export declare const GOAL_SUPERVISOR_ARTIFACT: string;
25
+ /** Parse a buildInfo.json payload defensively; malformed files read as absent. */
26
+ export declare function parseBuildInfo(value: unknown): BuildInfo | undefined;
27
+ /**
28
+ * Provenance of the running build, or undefined when no buildInfo.json is
29
+ * readable (source runs without a prior build). Cached per process; explicit
30
+ * candidate paths bypass the cache (tests, doctor probing another root).
31
+ */
32
+ export declare function readBuildInfo(candidates?: readonly string[]): BuildInfo | undefined;
33
+ /** Test seam: clear the default-path cache so the next `readBuildInfo()` reloads from disk. */
34
+ export declare function resetBuildInfoCache(): void;
35
+ /** Read the first parsable buildInfo.json among the candidate paths. */
36
+ export declare function loadBuildInfoFrom(candidates: readonly string[]): BuildInfo | undefined;
37
+ /** Read a package.json version from an explicit package root. */
38
+ export declare function readPackageVersionAt(root: string): string | undefined;
39
+ /**
40
+ * Nearest ancestor directory (starting at `start`, default: this module's
41
+ * location) containing a package.json — i.e. the package root of the code
42
+ * that is actually executing.
43
+ */
44
+ export declare function resolvePackageRoot(start?: string): string | undefined;
45
+ /**
46
+ * Resolve the current git HEAD commit without spawning git: reads .git/HEAD
47
+ * (detached sha or symbolic ref), then the ref file or packed-refs. Returns
48
+ * undefined whenever the commit cannot be determined without guessing.
49
+ */
50
+ export declare function gitHeadCommit(root: string): string | undefined;
51
+ /** True when the goal-supervisor compiled module exists under this package root. */
52
+ export declare function goalSupervisorArtifactPresent(root: string): boolean;
53
+ /** Capabilities of the running build, verified against its compiled artifacts. */
54
+ export declare function runtimeCapabilities(root?: string): RuntimeCapabilities;
55
+ /** One-line capability summary for logs and doctor output. */
56
+ export declare function formatCapabilities(capabilities: RuntimeCapabilities): string;
57
+ /** Structured description of the executing runtime (used by --version --verbose and doctor). */
58
+ export interface RuntimeProvenance {
59
+ version: string;
60
+ build?: BuildInfo;
61
+ /** Package root of the executing code (contains package.json). */
62
+ runtimeRoot?: string;
63
+ /** Resolved entry executable (process.argv[1]); undefined in non-CLI contexts. */
64
+ executable?: string;
65
+ capabilities: RuntimeCapabilities;
66
+ }
67
+ /** Resolved entry executable (process.argv[1]); undefined in non-CLI contexts. */
68
+ export declare function resolveExecutable(): string | undefined;
69
+ /** `haze --version --verbose` block: version, commit, runtime/executable paths, supervisor state. */
70
+ export declare function formatVersionVerbose(provenance?: RuntimeProvenance): string;
71
+ /** A nearby haze checkout whose version/commit diverges from the executing runtime. */
72
+ export interface CheckoutMismatch {
73
+ /** Package root of the executing runtime. */
74
+ executingRoot: string;
75
+ executingVersion: string;
76
+ executingCommit?: string;
77
+ /** Package root of the nearby checkout found from the working directory. */
78
+ checkoutRoot: string;
79
+ checkoutVersion: string;
80
+ checkoutCommit?: string;
81
+ /** True when the checkout's version string differs from the executing one. */
82
+ versionDiffers: boolean;
83
+ /** True when the checkout's version is strictly newer than the executing one. */
84
+ checkoutNewer: boolean;
85
+ }
86
+ /**
87
+ * Detect a haze source checkout at/above `cwd` that differs from the executing
88
+ * runtime — the classic failure where a globally installed haze (e.g. 0.10.0)
89
+ * silently serves requests while the checkout beside the workspace already
90
+ * contains the fix. Returns undefined when there is nothing to warn about.
91
+ */
92
+ export declare function detectCheckoutMismatch(input?: {
93
+ executingRoot?: string;
94
+ cwd?: string;
95
+ }): CheckoutMismatch | undefined;
96
+ /** Startup warning for a stale runtime executing next to a newer checkout. */
97
+ export declare function formatMismatchWarning(mismatch: CheckoutMismatch): string;