@denizokcu/haze 0.9.0 → 0.11.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 (241) hide show
  1. package/CHANGELOG.md +133 -17
  2. package/README.md +164 -68
  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 +17 -1
  9. package/dist/cli/chat/chatMetrics.js +22 -5
  10. package/dist/cli/chat/contextReport.d.ts +11 -0
  11. package/dist/cli/chat/contextReport.js +46 -0
  12. package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
  13. package/dist/cli/chat/fileMentionSuggestions.js +92 -0
  14. package/dist/cli/chat/inputSuggestions.d.ts +5 -0
  15. package/dist/cli/chat/inputSuggestions.js +17 -3
  16. package/dist/cli/chat/liveRegion.d.ts +25 -0
  17. package/dist/cli/chat/liveRegion.js +48 -0
  18. package/dist/cli/chat/messages.d.ts +33 -2
  19. package/dist/cli/chat/messages.js +216 -33
  20. package/dist/cli/chat/sessionLifecycle.d.ts +67 -0
  21. package/dist/cli/chat/sessionLifecycle.js +205 -0
  22. package/dist/cli/chat/sessionRecorder.js +80 -14
  23. package/dist/cli/chat/startupInfo.js +11 -4
  24. package/dist/cli/chat/tips.d.ts +21 -0
  25. package/dist/cli/chat/tips.js +43 -0
  26. package/dist/cli/chat/wizardDispatch.d.ts +64 -0
  27. package/dist/cli/chat/wizardDispatch.js +744 -0
  28. package/dist/cli/commands/chat.d.ts +6 -0
  29. package/dist/cli/commands/chat.js +373 -790
  30. package/dist/cli/commands/chatModes.d.ts +1 -1
  31. package/dist/cli/commands/chatModes.js +7 -2
  32. package/dist/cli/commands/commandHelp.js +5 -3
  33. package/dist/cli/commands/commands.d.ts +5 -2
  34. package/dist/cli/commands/commands.js +22 -18
  35. package/dist/cli/commands/doctor.d.ts +19 -0
  36. package/dist/cli/commands/doctor.js +76 -0
  37. package/dist/cli/commands/fleetCommand.d.ts +14 -0
  38. package/dist/cli/commands/fleetCommand.js +46 -0
  39. package/dist/cli/commands/formatters.d.ts +5 -0
  40. package/dist/cli/commands/formatters.js +35 -6
  41. package/dist/cli/commands/logsCommand.js +1 -7
  42. package/dist/cli/commands/modelCommand.js +1 -1
  43. package/dist/cli/commands/ndjsonSink.d.ts +23 -0
  44. package/dist/cli/commands/ndjsonSink.js +38 -0
  45. package/dist/cli/commands/providerWizard.d.ts +10 -2
  46. package/dist/cli/commands/providerWizard.js +50 -4
  47. package/dist/cli/commands/runCommand.d.ts +4 -0
  48. package/dist/cli/commands/runCommand.js +142 -16
  49. package/dist/cli/commands/sessionPicker.d.ts +9 -0
  50. package/dist/cli/commands/sessionPicker.js +29 -0
  51. package/dist/cli/commands/settingsSummary.js +6 -4
  52. package/dist/cli/commands/skillConfirmRemove.js +4 -3
  53. package/dist/cli/commands/skillWizard.d.ts +2 -0
  54. package/dist/cli/commands/skillWizard.js +16 -6
  55. package/dist/cli/commands/streaming/abortCause.d.ts +24 -0
  56. package/dist/cli/commands/streaming/abortCause.js +16 -0
  57. package/dist/cli/commands/streaming/assistantText.js +9 -2
  58. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
  59. package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
  60. package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
  61. package/dist/cli/commands/streaming/goalSupervisor.js +127 -0
  62. package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
  63. package/dist/cli/commands/streaming/idleTimer.js +24 -0
  64. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +2 -0
  65. package/dist/cli/commands/streaming/toolCallRecovery.js +24 -0
  66. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -0
  67. package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -2
  68. package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
  69. package/dist/cli/commands/streaming/toolResultState.js +29 -7
  70. package/dist/cli/commands/streaming/turnOutcome.d.ts +17 -0
  71. package/dist/cli/commands/streaming/turnOutcome.js +27 -11
  72. package/dist/cli/commands/streaming/turnRuntime.js +6 -4
  73. package/dist/cli/commands/streaming.d.ts +82 -3
  74. package/dist/cli/commands/streaming.js +528 -91
  75. package/dist/cli/commands/wizardActions.d.ts +7 -0
  76. package/dist/cli/commands/wizardActions.js +7 -0
  77. package/dist/cli/commands/wizardPrompts.js +7 -1
  78. package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
  79. package/dist/cli/commands/wizardSuggestions.js +64 -14
  80. package/dist/cli/commands/wizardTransition.d.ts +4 -0
  81. package/dist/cli/commands/wizardTransition.js +1 -2
  82. package/dist/cli/index.js +82 -22
  83. package/dist/cli/terminalTitle.d.ts +6 -0
  84. package/dist/cli/terminalTitle.js +36 -0
  85. package/dist/config/inputHistory.d.ts +3 -3
  86. package/dist/config/inputHistory.js +12 -18
  87. package/dist/config/modelDiscovery.d.ts +71 -0
  88. package/dist/config/modelDiscovery.js +214 -0
  89. package/dist/config/privateStorage.js +28 -2
  90. package/dist/config/providerAuth.d.ts +14 -0
  91. package/dist/config/providerAuth.js +49 -0
  92. package/dist/config/providerPresets.d.ts +49 -5
  93. package/dist/config/providerPresets.js +573 -73
  94. package/dist/config/providers.d.ts +2 -0
  95. package/dist/config/providers.js +9 -0
  96. package/dist/config/settings.d.ts +58 -0
  97. package/dist/config/settings.js +38 -1
  98. package/dist/config/skillSettings.d.ts +6 -13
  99. package/dist/config/skillSettings.js +20 -19
  100. package/dist/core/agent/budgets.d.ts +36 -0
  101. package/dist/core/agent/budgets.js +44 -0
  102. package/dist/core/agent/compaction.d.ts +38 -0
  103. package/dist/core/agent/compaction.js +108 -19
  104. package/dist/core/agent/completionController.d.ts +230 -0
  105. package/dist/core/agent/completionController.js +287 -0
  106. package/dist/core/agent/contextBudget.d.ts +46 -0
  107. package/dist/core/agent/contextBudget.js +89 -7
  108. package/dist/core/agent/errors.js +6 -2
  109. package/dist/core/agent/events.d.ts +86 -0
  110. package/dist/core/agent/reasoningPolicy.d.ts +31 -0
  111. package/dist/core/agent/reasoningPolicy.js +27 -0
  112. package/dist/core/agent/toolCapabilities.d.ts +27 -0
  113. package/dist/core/agent/toolCapabilities.js +58 -0
  114. package/dist/core/agent/toolExecutionBudget.d.ts +35 -0
  115. package/dist/core/agent/toolExecutionBudget.js +49 -0
  116. package/dist/core/agent/toolOutputStore.d.ts +13 -0
  117. package/dist/core/agent/toolOutputStore.js +27 -10
  118. package/dist/core/agent/toolResults.d.ts +12 -0
  119. package/dist/core/agent/toolResults.js +38 -0
  120. package/dist/core/agent/turnBudget.d.ts +35 -0
  121. package/dist/core/agent/turnBudget.js +27 -0
  122. package/dist/core/agent/turnPolicy.d.ts +11 -0
  123. package/dist/core/agent/turnPolicy.js +19 -0
  124. package/dist/core/agent/workState.d.ts +76 -1
  125. package/dist/core/agent/workState.js +120 -13
  126. package/dist/core/attachments/imageAttachments.d.ts +90 -0
  127. package/dist/core/attachments/imageAttachments.js +245 -0
  128. package/dist/core/attachments/readBlessings.d.ts +37 -0
  129. package/dist/core/attachments/readBlessings.js +79 -0
  130. package/dist/core/deadline.d.ts +33 -0
  131. package/dist/core/deadline.js +74 -0
  132. package/dist/core/goal/completionPolicy.d.ts +27 -0
  133. package/dist/core/goal/completionPolicy.js +37 -1
  134. package/dist/core/goal/requestClassifier.d.ts +0 -3
  135. package/dist/core/goal/requestClassifier.js +0 -13
  136. package/dist/core/io/boundedRead.js +76 -29
  137. package/dist/core/limits/byteBudgets.d.ts +7 -0
  138. package/dist/core/limits/byteBudgets.js +7 -0
  139. package/dist/core/limits/textBudgets.d.ts +25 -0
  140. package/dist/core/limits/textBudgets.js +25 -0
  141. package/dist/core/log/llmLog.js +7 -0
  142. package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
  143. package/dist/core/persistence/orderedFileWriter.js +16 -2
  144. package/dist/core/process/backgroundRegistry.d.ts +35 -0
  145. package/dist/core/process/backgroundRegistry.js +195 -0
  146. package/dist/core/process/runBoundedProcess.d.ts +9 -0
  147. package/dist/core/process/runBoundedProcess.js +74 -29
  148. package/dist/core/safety/missingExecutable.d.ts +42 -0
  149. package/dist/core/safety/missingExecutable.js +77 -0
  150. package/dist/core/safety/urlGuard.d.ts +2 -1
  151. package/dist/core/safety/urlGuard.js +3 -2
  152. package/dist/core/session/sessionSlimming.js +47 -4
  153. package/dist/core/session/sessionStore.d.ts +74 -0
  154. package/dist/core/session/sessionStore.js +268 -18
  155. package/dist/core/subagent/contracts.d.ts +120 -0
  156. package/dist/core/subagent/contracts.js +55 -0
  157. package/dist/core/subagent/executionProfiles.d.ts +28 -0
  158. package/dist/core/subagent/executionProfiles.js +45 -0
  159. package/dist/core/subagent/subagentCoordinator.d.ts +78 -0
  160. package/dist/core/subagent/subagentCoordinator.js +164 -0
  161. package/dist/core/subagent/subagentRunner.d.ts +211 -145
  162. package/dist/core/subagent/subagentRunner.js +208 -98
  163. package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
  164. package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
  165. package/dist/core/tasks/taskStorage.js +12 -1
  166. package/dist/llm/client.d.ts +36 -29
  167. package/dist/llm/client.js +102 -33
  168. package/dist/llm/hazeTools.d.ts +2559 -150
  169. package/dist/llm/hazeTools.js +119 -31
  170. package/dist/llm/lsp.d.ts +26 -4
  171. package/dist/llm/lsp.js +90 -14
  172. package/dist/llm/lspTools.d.ts +2366 -0
  173. package/dist/llm/lspTools.js +87 -79
  174. package/dist/llm/openaiCodex.d.ts +3 -0
  175. package/dist/llm/openaiCodex.js +47 -0
  176. package/dist/llm/openaiCodexOAuth.d.ts +54 -0
  177. package/dist/llm/openaiCodexOAuth.js +214 -0
  178. package/dist/llm/requestContext.d.ts +25 -1
  179. package/dist/llm/requestContext.js +51 -8
  180. package/dist/llm/systemPrompt.d.ts +15 -1
  181. package/dist/llm/systemPrompt.js +24 -8
  182. package/dist/llm/toolResultTypes.d.ts +8 -1
  183. package/dist/llm/tools/bashTool.d.ts +906 -32
  184. package/dist/llm/tools/bashTool.js +30 -4
  185. package/dist/llm/tools/editMatch.d.ts +14 -0
  186. package/dist/llm/tools/editMatch.js +72 -0
  187. package/dist/llm/tools/failures.d.ts +2 -0
  188. package/dist/llm/tools/failures.js +1 -0
  189. package/dist/llm/tools/fetchTool.d.ts +42 -26
  190. package/dist/llm/tools/fetchTool.js +1 -1
  191. package/dist/llm/tools/fileToolShared.d.ts +6 -4
  192. package/dist/llm/tools/fileToolShared.js +18 -23
  193. package/dist/llm/tools/gitIgnore.d.ts +49 -0
  194. package/dist/llm/tools/gitIgnore.js +129 -0
  195. package/dist/llm/tools/grepRunner.d.ts +5 -0
  196. package/dist/llm/tools/grepRunner.js +52 -71
  197. package/dist/llm/tools/outputCap.d.ts +2 -6
  198. package/dist/llm/tools/outputCap.js +2 -6
  199. package/dist/llm/tools/processTool.d.ts +1077 -0
  200. package/dist/llm/tools/processTool.js +41 -0
  201. package/dist/llm/tools/readRecovery.d.ts +10 -0
  202. package/dist/llm/tools/readRecovery.js +135 -0
  203. package/dist/llm/tools/toolContext.d.ts +9 -1
  204. package/dist/llm/tools/toolContext.js +83 -43
  205. package/dist/llm/tools/workspaceFile.d.ts +9 -1
  206. package/dist/llm/tools/workspaceFile.js +33 -4
  207. package/dist/llm/webFetch.d.ts +17 -0
  208. package/dist/llm/webFetch.js +66 -86
  209. package/dist/llm/workerContext.d.ts +18 -0
  210. package/dist/llm/workerContext.js +55 -0
  211. package/dist/skills/SkillLoader.d.ts +2 -2
  212. package/dist/skills/SkillRegistry.d.ts +3 -2
  213. package/dist/skills/SkillRegistry.js +43 -13
  214. package/dist/skills/builder/SkillBuilder.d.ts +3 -0
  215. package/dist/skills/builder/SkillBuilder.js +23 -5
  216. package/dist/skills/skillTools.js +11 -4
  217. package/dist/skills/types.d.ts +6 -1
  218. package/dist/ui/codeHighlight.d.ts +4 -0
  219. package/dist/ui/codeHighlight.js +31 -0
  220. package/dist/ui/components/Header.d.ts +1 -1
  221. package/dist/ui/components/MarkdownText.d.ts +16 -2
  222. package/dist/ui/components/MarkdownText.js +244 -34
  223. package/dist/ui/components/TextInput.d.ts +12 -2
  224. package/dist/ui/components/TextInput.js +80 -8
  225. package/dist/ui/theme.d.ts +4 -3
  226. package/dist/ui/theme.js +5 -4
  227. package/dist/utils/buildInfo.d.ts +104 -0
  228. package/dist/utils/buildInfo.js +253 -0
  229. package/dist/utils/format.d.ts +2 -0
  230. package/dist/utils/format.js +8 -0
  231. package/dist/utils/fs.d.ts +9 -1
  232. package/dist/utils/fs.js +87 -29
  233. package/dist/utils/openPath.d.ts +2 -0
  234. package/dist/utils/openPath.js +22 -0
  235. package/dist/utils/path.d.ts +2 -0
  236. package/dist/utils/path.js +5 -1
  237. package/dist/utils/utf8.d.ts +22 -0
  238. package/dist/utils/utf8.js +54 -0
  239. package/dist/utils/version.d.ts +9 -3
  240. package/dist/utils/version.js +28 -2
  241. package/package.json +24 -19
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { Task } from '../../core/tasks/taskStorage.js';
3
3
  export declare const MAX_VISIBLE_TASKS = 5;
4
- export declare function TaskBar({ tasks, width, expanded, padding }: {
4
+ export declare function TaskBar({ tasks, width, expanded, padding, maxRows }: {
5
5
  tasks: Task[];
6
6
  width: number;
7
7
  expanded: boolean;
8
8
  padding: number;
9
+ maxRows?: number;
9
10
  }): React.JSX.Element;
@@ -14,12 +14,15 @@ function taskStatusColor(status) {
14
14
  }
15
15
  }
16
16
  export const MAX_VISIBLE_TASKS = 5;
17
- export function TaskBar({ tasks, width, expanded, padding }) {
17
+ export function TaskBar({ tasks, width, expanded, padding, maxRows }) {
18
18
  const maxTitleWidth = Math.max(10, width - 6);
19
19
  const inProgress = tasks.filter(t => t.status === 'in_progress');
20
20
  const pending = tasks.filter(t => t.status === 'pending');
21
21
  const completed = tasks.filter(t => t.status === 'completed');
22
- const limit = expanded ? tasks.length : MAX_VISIBLE_TASKS;
22
+ // Live-region budget (see chat/liveRegion.ts): expanded mode is capped too,
23
+ // otherwise a long task list alone can push the dynamic frame past one
24
+ // viewport and trigger Ink's scrollback-wiping overflow fallback.
25
+ const limit = expanded ? Math.min(tasks.length, maxRows ?? tasks.length) : MAX_VISIBLE_TASKS;
23
26
  const ordered = [];
24
27
  for (const t of inProgress) {
25
28
  if (ordered.length < limit)
@@ -35,6 +38,6 @@ export function TaskBar({ tasks, width, expanded, padding }) {
35
38
  const counts = `${inProgress.length > 0 ? `${inProgress.length} active` : ''}${pending.length > 0 ? `${inProgress.length > 0 ? ', ' : ''}${pending.length} pending` : ''}${completed.length > 0 ? `${inProgress.length + pending.length > 0 ? ', ' : ''}${completed.length} done` : ''}`;
36
39
  return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [padding > 0 && Array.from({ length: padding }, (_, i) => _jsx(Text, { children: ' ' }, `pad-${i}`)), _jsxs(Text, { children: [_jsx(Text, { color: theme.purple, bold: true, children: "Tasks" }), counts ? _jsxs(Text, { color: theme.muted, children: [" (", counts, ")"] }) : null, tasks.length > MAX_VISIBLE_TASKS ? _jsxs(Text, { color: theme.muted, dimColor: true, children: [" \u00B7 ctrl+o ", expanded ? 'collapse' : 'expand'] }) : null] }), ordered.map(task => {
37
40
  const title = task.title.length > maxTitleWidth ? task.title.slice(0, maxTitleWidth - 1) + '\u2026' : task.title;
38
- return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: taskStatusColor(task.status), children: [TASK_STATUS_ICON[task.status], " "] }), _jsx(Text, { color: task.status === 'completed' ? theme.muted : 'white', children: title })] }, task.id));
39
- })] }));
41
+ return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: taskStatusColor(task.status), children: [TASK_STATUS_ICON[task.status], " "] }), _jsx(Text, { color: task.status === 'completed' ? theme.muted : theme.foreground, children: title })] }, task.id));
42
+ }), expanded && ordered.length < tasks.length ? _jsxs(Text, { color: theme.muted, children: [" +", tasks.length - ordered.length, " more (ctrl+o)"] }) : null] }));
40
43
  }
@@ -1,5 +1,5 @@
1
1
  import type { ModelMessage } from 'ai';
2
- import type { Message } from '../commands/streaming.js';
2
+ import type { Message, TokenUsage } from '../commands/streaming.js';
3
3
  export declare function toolCallCount(messages: Message[]): number;
4
4
  export declare function estimateTokens(text: string): number;
5
5
  export declare function compactHomePath(filePath: string, home?: string): string;
@@ -9,3 +9,19 @@ export declare function estimateConversationTokens(messages: Message[]): {
9
9
  input: number;
10
10
  output: number;
11
11
  };
12
+ /** Status-bar numbers for the transcript, extracted so render stays declarative (CR-006). */
13
+ export declare function statusBarMetrics(input: {
14
+ messages: Message[];
15
+ tokenUsage: TokenUsage;
16
+ enabledSkillCount: number;
17
+ backgroundProcessCount?: number;
18
+ }): {
19
+ hazeMessages: number;
20
+ toolsUsed: number;
21
+ effectiveInput: number;
22
+ effectiveOutput: number;
23
+ inputEstimated: boolean;
24
+ outputEstimated: boolean;
25
+ statusDetailLabel: string;
26
+ hasTokenBreakdown: boolean;
27
+ };
@@ -4,11 +4,11 @@ export function toolCallCount(messages) {
4
4
  return messages.reduce((total, message) => {
5
5
  if (message.role !== 'tool')
6
6
  return total;
7
- const headerCount = /Tools: (\d+) calls?/.exec(message.text)?.[1];
8
- if (headerCount)
9
- return total + Number(headerCount);
10
- const rows = message.text.split('\n').filter(line => /^\s+[✓✗…]\s/.test(line));
11
- return total + rows.reduce((rowTotal, row) => rowTotal + Number(/×(\d+)/.exec(row)?.[1] ?? 1), 0);
7
+ // Live tool groups carry a structured count; only restored historical
8
+ // transcripts fall back to counting rendered per-call rows (CR-015).
9
+ if (typeof message.toolCount === 'number')
10
+ return total + message.toolCount;
11
+ return total + message.text.split('\n').filter(line => /^\s+[✓✗…]\s/.test(line)).length;
12
12
  }, 0);
13
13
  }
14
14
  export function estimateTokens(text) {
@@ -48,3 +48,20 @@ export function estimateConversationTokens(messages) {
48
48
  output: estimateTokens(outputText),
49
49
  };
50
50
  }
51
+ /** Status-bar numbers for the transcript, extracted so render stays declarative (CR-006). */
52
+ export function statusBarMetrics(input) {
53
+ const { messages, tokenUsage, enabledSkillCount } = input;
54
+ const hazeMessages = messages.filter(message => message.role === 'assistant' && !message.hidden).length;
55
+ const toolsUsed = toolCallCount(messages);
56
+ const fallbackTokens = estimateConversationTokens(messages);
57
+ const estimatedLogicalInput = tokenUsage.logicalInputEstimate || fallbackTokens.input || 0;
58
+ const providerInput = tokenUsage.inputTokens;
59
+ const effectiveInput = providerInput == null ? estimatedLogicalInput : Math.max(providerInput, estimatedLogicalInput);
60
+ const effectiveOutput = tokenUsage.outputTokens ?? (fallbackTokens.output || 0);
61
+ const inputEstimated = providerInput == null || effectiveInput !== providerInput;
62
+ const outputEstimated = tokenUsage.outputTokens == null;
63
+ const backgroundLabel = input.backgroundProcessCount ? ` / ⏵ ${input.backgroundProcessCount} bg` : '';
64
+ const statusDetailLabel = `${hazeMessages} haze message${hazeMessages === 1 ? '' : 's'} / ${toolsUsed} tool call${toolsUsed === 1 ? '' : 's'} / LLM ${inputEstimated ? '~' : ''}↑${formatTokenCount(effectiveInput)} ${outputEstimated ? '~' : ''}↓${formatTokenCount(effectiveOutput)} / ${enabledSkillCount} skill${enabledSkillCount === 1 ? '' : 's'}${backgroundLabel}`;
65
+ const hasTokenBreakdown = tokenUsage.systemPrompt > 0 || tokenUsage.messages > 0 || tokenUsage.toolSchemas > 0 || effectiveInput > 0 || effectiveOutput > 0;
66
+ return { hazeMessages, toolsUsed, effectiveInput, effectiveOutput, inputEstimated, outputEstimated, statusDetailLabel, hasTokenBreakdown };
67
+ }
@@ -0,0 +1,11 @@
1
+ import type { ModelMessage } from 'ai';
2
+ import type { ContextFile } from '../../config/contextFiles.js';
3
+ /**
4
+ * Build the `/context` token report. Extracted from `chat.tsx` (CR-006); takes
5
+ * its inputs explicitly so the component only orchestrates.
6
+ */
7
+ export declare function buildContextReport(input: {
8
+ sessionStart: Date;
9
+ contextFiles: ContextFile[];
10
+ conversation: ModelMessage[];
11
+ }): Promise<string>;
@@ -0,0 +1,46 @@
1
+ import { contextBreakdown } from '../../core/agent/contextBudget.js';
2
+ import { stripSyntheticControls } from '../../core/agent/requestAssembly.js';
3
+ import { modelWithConfig } from '../../llm/client.js';
4
+ import { assembleRequestContext } from '../../llm/requestContext.js';
5
+ import { closeMcpClients } from '../../llm/mcp.js';
6
+ import { formatContextReport } from '../commands/formatters.js';
7
+ /**
8
+ * Build the `/context` token report. Extracted from `chat.tsx` (CR-006); takes
9
+ * its inputs explicitly so the component only orchestrates.
10
+ */
11
+ export async function buildContextReport(input) {
12
+ const runtime = await modelWithConfig({ cwd: process.cwd() });
13
+ if (!runtime?.model) {
14
+ return 'No model provider configured. Run /provider to choose or add a provider before /context can estimate tokens.';
15
+ }
16
+ const session = { start: input.sessionStart, cwd: process.cwd() };
17
+ const assembled = await assembleRequestContext({ contextFiles: input.contextFiles, session, model: runtime.model });
18
+ try {
19
+ const messages = stripSyntheticControls(input.conversation);
20
+ const breakdown = contextBreakdown({ system: assembled.systemPrompt, contextFiles: input.contextFiles, messages, tools: assembled.availableTools });
21
+ const tools = breakdown.toolSchemas.map(tool => ({
22
+ name: tool.name,
23
+ tokens: tool.tokens,
24
+ category: assembled.toolCategories.get(tool.name) ?? 'builtin',
25
+ }));
26
+ return formatContextReport({
27
+ modelLabel: `${runtime.config.providerName}:${runtime.config.modelName}`,
28
+ systemTokens: breakdown.system,
29
+ projectContext: breakdown.projectContext,
30
+ tools,
31
+ messagesByRole: breakdown.messagesByRole,
32
+ toolResults: breakdown.toolResults,
33
+ toolInputs: breakdown.toolInputs,
34
+ syntheticControl: breakdown.syntheticControl,
35
+ logicalInputEstimate: breakdown.logicalInputEstimate,
36
+ messageCount: messages.length,
37
+ mcpErrors: assembled.loadedMcp?.errors ?? [],
38
+ });
39
+ }
40
+ finally {
41
+ if (assembled.loadedMcp?.clients.length)
42
+ await closeMcpClients(assembled.loadedMcp.clients);
43
+ if (assembled.lspPool)
44
+ await assembled.lspPool.close();
45
+ }
46
+ }
@@ -0,0 +1,29 @@
1
+ import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
2
+ export interface MentionContext {
3
+ /** Full token including the leading `@`. */
4
+ token: string;
5
+ /** Index in the source string where the `@` sits. */
6
+ start: number;
7
+ /** Index one past the last char of the token. */
8
+ end: number;
9
+ }
10
+ /**
11
+ * Find the `@token` (if any) at the given cursor position. The cursor may
12
+ * sit anywhere inside the token or directly after its last char — both
13
+ * count as "inside" so the user can keep typing or completing.
14
+ */
15
+ export declare function detectMentionAtCursor(value: string, cursor: number): MentionContext | undefined;
16
+ export interface FileMentionSuggestionsOptions {
17
+ /** Override the workspace root for tests. Defaults to `process.cwd()`. */
18
+ workspaceRoot?: string;
19
+ }
20
+ /**
21
+ * List workspace paths matching the `@token` for tab completion. The token is
22
+ * treated as `@<parent>/<prefix>`; the parent directory is listed (one level,
23
+ * non-recursive) and children are filtered by the prefix. `.gitignored` paths
24
+ * are excluded; `.git` and `node_modules` are skipped by `walkDir` itself.
25
+ *
26
+ * Suggestion values include the leading `@` so the caller can replace the
27
+ * `@token` range verbatim with the chosen suggestion.
28
+ */
29
+ export declare function fileMentionSuggestions(token: string, options?: FileMentionSuggestionsOptions): Promise<TextInputSuggestion[]>;
@@ -0,0 +1,92 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { walkDir } from '../../utils/fs.js';
4
+ import { createIgnoreClassifier } from '../../llm/tools/gitIgnore.js';
5
+ import { workspaceRoot } from '../../utils/path.js';
6
+ /**
7
+ * Tab-completion support for `@`-mention paths (F04 AC1).
8
+ *
9
+ * Mention completion is cursor-aware partial replacement — unlike slash
10
+ * commands, the suggestion replaces only the `@token` at the cursor, not the
11
+ * whole input. Detection runs in the TextInput layer; this module owns the
12
+ * filesystem listing (bounded, `.gitignore`-aware) and stays UI-agnostic.
13
+ */
14
+ /** Cap so completion stays responsive in large repos (F04 AC5). */
15
+ const MAX_MENTION_SUGGESTIONS = 20;
16
+ /** Characters allowed inside a `@token` while it is being typed. */
17
+ const MENTION_TOKEN_PATTERN = /@[\w./~-]*/g;
18
+ /**
19
+ * Find the `@token` (if any) at the given cursor position. The cursor may
20
+ * sit anywhere inside the token or directly after its last char — both
21
+ * count as "inside" so the user can keep typing or completing.
22
+ */
23
+ export function detectMentionAtCursor(value, cursor) {
24
+ for (const match of value.matchAll(MENTION_TOKEN_PATTERN)) {
25
+ if (match.index === undefined)
26
+ continue;
27
+ const start = match.index;
28
+ const end = start + match[0].length;
29
+ if (cursor >= start && cursor <= end)
30
+ return { token: match[0], start, end };
31
+ }
32
+ return undefined;
33
+ }
34
+ /**
35
+ * Strip the leading `@` and split the query into parent directory + prefix.
36
+ * `@src/f` → `{parentDir: 'src', prefix: 'f'}`; `@` → `{parentDir: '.', prefix: ''}`.
37
+ */
38
+ function splitQuery(token) {
39
+ const query = token.replace(/^@/, '');
40
+ const lastSlash = query.lastIndexOf('/');
41
+ if (lastSlash < 0)
42
+ return { parentDir: '.', prefix: query };
43
+ return { parentDir: query.slice(0, lastSlash), prefix: query.slice(lastSlash + 1) };
44
+ }
45
+ /**
46
+ * List workspace paths matching the `@token` for tab completion. The token is
47
+ * treated as `@<parent>/<prefix>`; the parent directory is listed (one level,
48
+ * non-recursive) and children are filtered by the prefix. `.gitignored` paths
49
+ * are excluded; `.git` and `node_modules` are skipped by `walkDir` itself.
50
+ *
51
+ * Suggestion values include the leading `@` so the caller can replace the
52
+ * `@token` range verbatim with the chosen suggestion.
53
+ */
54
+ export async function fileMentionSuggestions(token, options = {}) {
55
+ const root = options.workspaceRoot ?? workspaceRoot();
56
+ const { parentDir, prefix } = splitQuery(token);
57
+ const absoluteParent = path.resolve(root, parentDir);
58
+ // Keep completion inside the workspace — outside paths get the read-blessing
59
+ // surface but not tab completion (the spec confines completion to workspace).
60
+ const relative = path.relative(root, absoluteParent);
61
+ if (relative.startsWith('..') || path.isAbsolute(relative))
62
+ return [];
63
+ // Reject non-directory parents (e.g. `@file.txt/`) before walkDir would
64
+ // throw ENOTDIR on readdir.
65
+ let parentStats;
66
+ try {
67
+ parentStats = await fs.stat(absoluteParent);
68
+ }
69
+ catch {
70
+ return [];
71
+ }
72
+ if (!parentStats.isDirectory())
73
+ return [];
74
+ const classifier = createIgnoreClassifier(root);
75
+ const entries = await walkDir(absoluteParent, {
76
+ recursive: false,
77
+ maxEntries: MAX_MENTION_SUGGESTIONS * 4,
78
+ ignoreBatch: relativePaths => classifier.classify(relativePaths),
79
+ });
80
+ const matches = entries
81
+ .filter(entry => entry.name.startsWith(prefix))
82
+ .slice(0, MAX_MENTION_SUGGESTIONS);
83
+ return matches.map(entry => {
84
+ const childPath = parentDir === '.' ? entry.name : `${parentDir}/${entry.name}`;
85
+ const completed = entry.isDirectory ? `${childPath}/` : childPath;
86
+ return {
87
+ value: `@${completed}`,
88
+ description: entry.isDirectory ? 'directory' : 'file',
89
+ kind: 'file',
90
+ };
91
+ });
92
+ }
@@ -1,5 +1,6 @@
1
1
  import type { HazeSettings } from '../../config/settings.js';
2
2
  import type { LoadedSkill } from '../../skills/types.js';
3
+ import type { SessionSummary } from '../../core/session/sessionStore.js';
3
4
  import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
4
5
  import type { Mode } from '../commands/chatModes.js';
5
6
  interface InputSuggestionState {
@@ -8,9 +9,13 @@ interface InputSuggestionState {
8
9
  skills: LoadedSkill[];
9
10
  selectedProviderName?: string;
10
11
  modelProviderFilter?: string;
12
+ providerDraftName?: string;
13
+ discoveredModels?: string[];
14
+ suggestedModels?: string[];
11
15
  selectedSkillName?: string;
12
16
  selectedLspName?: string;
13
17
  selectedMcpName?: string;
18
+ sessions?: SessionSummary[];
14
19
  }
15
20
  export declare function inputSuggestionsForState(state: InputSuggestionState): TextInputSuggestion[];
16
21
  export {};
@@ -1,5 +1,6 @@
1
1
  import { isSkillEnabled } from '../../config/skillSettings.js';
2
- import { providerSuggestions, providerActionSuggestions, presetSuggestions, modelSuggestions, lspSuggestions, lspActionSuggestions, lspPresetSuggestions, mcpSuggestions, mcpActionSuggestions, mcpPresetSuggestions, mcpTransportSuggestions, skillsSuggestions, skillsActionSuggestions } from '../commands/wizardSuggestions.js';
2
+ import { providerSuggestions, providerActionSuggestions, presetSuggestions, modelSuggestions, modelAddProviderSuggestions, modelPickSuggestions, lspSuggestions, lspActionSuggestions, lspPresetSuggestions, mcpSuggestions, mcpActionSuggestions, mcpPresetSuggestions, mcpTransportSuggestions, skillsSuggestions, skillsActionSuggestions, skillScopeSuggestions } from '../commands/wizardSuggestions.js';
3
+ import { sessionActionSuggestions, sessionSuggestions } from '../commands/sessionPicker.js';
3
4
  const CHAT_COMMAND_SUGGESTIONS = [
4
5
  { value: '/help', description: 'Show commands', kind: 'command' },
5
6
  { value: '/provider', description: 'Choose a provider', kind: 'command' },
@@ -9,9 +10,10 @@ const CHAT_COMMAND_SUGGESTIONS = [
9
10
  { value: '/settings', description: 'Show provider, model, API key, and context status', kind: 'command' },
10
11
  { value: '/context', description: 'Show token breakdown of system, tools, MCP, and messages', kind: 'command' },
11
12
  { value: '/skills', description: 'Manage Markdown skills (add, enable/disable, validate, remove)', kind: 'command' },
13
+ { value: '/fleet ', description: 'Parallelize independent work in disposable contexts (flags: --review/--profile/--workers/--concurrency)', kind: 'command' },
12
14
  { value: '/init', description: 'Create or update AGENTS.md project instructions', kind: 'command' },
13
15
  { value: '/session', description: 'Show current session path', kind: 'command' },
14
- { value: '/resume', description: 'Resume latest session for this workspace', kind: 'command' },
16
+ { value: '/resume', description: 'Browse saved sessions for this workspace', kind: 'command' },
15
17
  { value: '/new', description: 'Start a new session', kind: 'command' },
16
18
  { value: '/compact ', description: 'Summarize older context and keep recent messages', kind: 'command' },
17
19
  { value: '/clear', description: 'Clear conversation history', kind: 'command' },
@@ -20,6 +22,10 @@ const CHAT_COMMAND_SUGGESTIONS = [
20
22
  ];
21
23
  export function inputSuggestionsForState(state) {
22
24
  const { mode, settings, skills } = state;
25
+ if (mode === 'sessions')
26
+ return sessionSuggestions(state.sessions ?? []);
27
+ if (mode === 'sessionAction')
28
+ return sessionActionSuggestions();
23
29
  if (mode === 'provider')
24
30
  return providerSuggestions(settings);
25
31
  if (mode === 'providerAction')
@@ -28,10 +34,16 @@ export function inputSuggestionsForState(state) {
28
34
  return presetSuggestions();
29
35
  if (mode === 'model')
30
36
  return modelSuggestions(settings, state.modelProviderFilter);
37
+ if (mode === 'modelAddProvider')
38
+ return modelAddProviderSuggestions(settings);
39
+ if (mode === 'modelPick')
40
+ return modelPickSuggestions(settings, state.selectedProviderName ?? state.providerDraftName, state.discoveredModels ?? [], state.suggestedModels ?? []);
31
41
  if (mode === 'skills')
32
42
  return skillsSuggestions(settings, skills);
33
43
  if (mode === 'skillsAction')
34
44
  return skillsActionSuggestions(settings, skills, state.selectedSkillName);
45
+ if (mode === 'skillsAddScope')
46
+ return skillScopeSuggestions();
35
47
  if (mode === 'lsp')
36
48
  return lspSuggestions(settings);
37
49
  if (mode === 'lspAction')
@@ -48,8 +60,10 @@ export function inputSuggestionsForState(state) {
48
60
  return mcpTransportSuggestions();
49
61
  if (mode !== 'chat')
50
62
  return [];
63
+ const activeSkills = skills.filter((skill, index) => isSkillEnabled(settings, skill.name, skill.source)
64
+ && !skills.slice(0, index).some(candidate => candidate.name === skill.name && isSkillEnabled(settings, candidate.name, candidate.source)));
51
65
  return [
52
66
  ...CHAT_COMMAND_SUGGESTIONS,
53
- ...skills.filter(skill => isSkillEnabled(settings, skill.name)).map(skill => ({ value: `/${skill.name}`, description: skill.description, kind: 'skill' })),
67
+ ...activeSkills.map(skill => ({ value: `/${skill.name}`, description: `${skill.description} · ${skill.source}`, kind: 'skill' })),
54
68
  ];
55
69
  }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Live-region row budgeting.
3
+ *
4
+ * Ink reclaims the terminal with `clearTerminal` (which erases scrollback)
5
+ * whenever the *dynamic* frame grows taller than the viewport, so every dynamic
6
+ * section must be clamped to keep the frame under one screen. These helpers
7
+ * mirror Ink's own line wrapping (`wrapAnsi` with `trim: false, hard: true`) so
8
+ * our row estimates match what Ink actually renders.
9
+ */
10
+ /** Wrap one logical line exactly like an Ink `<Text>` with default wrap mode. */
11
+ export declare function wrapLine(line: string, width: number): string[];
12
+ /** Wrapped row count of a logical line at the given width. */
13
+ export declare function lineRows(line: string, width: number): number;
14
+ export interface TailClamp {
15
+ text: string;
16
+ /** Wrapped rows hidden above the visible tail (0 when nothing was clamped). */
17
+ hiddenLineCount: number;
18
+ }
19
+ /**
20
+ * Keep the last `maxLines` wrapped rows of `text`, dropping whole logical lines
21
+ * from the top (a wrapped group is never split). When clamping occurs, one row
22
+ * is reserved for the caller's `⋯ +N lines` indicator. Nothing is lost: the
23
+ * full text is committed verbatim to the static transcript once it settles.
24
+ */
25
+ export declare function clampTextTail(text: string, width: number, maxLines: number): TailClamp;
@@ -0,0 +1,48 @@
1
+ import wrapAnsi from 'wrap-ansi';
2
+ /**
3
+ * Live-region row budgeting.
4
+ *
5
+ * Ink reclaims the terminal with `clearTerminal` (which erases scrollback)
6
+ * whenever the *dynamic* frame grows taller than the viewport, so every dynamic
7
+ * section must be clamped to keep the frame under one screen. These helpers
8
+ * mirror Ink's own line wrapping (`wrapAnsi` with `trim: false, hard: true`) so
9
+ * our row estimates match what Ink actually renders.
10
+ */
11
+ /** Wrap one logical line exactly like an Ink `<Text>` with default wrap mode. */
12
+ export function wrapLine(line, width) {
13
+ const safeWidth = Math.max(1, width);
14
+ if (line.length === 0)
15
+ return [''];
16
+ return wrapAnsi(line, safeWidth, { trim: false, hard: true }).split('\n');
17
+ }
18
+ /** Wrapped row count of a logical line at the given width. */
19
+ export function lineRows(line, width) {
20
+ return wrapLine(line, width).length;
21
+ }
22
+ /**
23
+ * Keep the last `maxLines` wrapped rows of `text`, dropping whole logical lines
24
+ * from the top (a wrapped group is never split). When clamping occurs, one row
25
+ * is reserved for the caller's `⋯ +N lines` indicator. Nothing is lost: the
26
+ * full text is committed verbatim to the static transcript once it settles.
27
+ */
28
+ export function clampTextTail(text, width, maxLines) {
29
+ if (maxLines < 1)
30
+ return { text: '', hiddenLineCount: 0 };
31
+ const logical = text.replace(/\r\n|\r/g, '\n').split('\n');
32
+ const rows = logical.map(line => lineRows(line, width));
33
+ const total = rows.reduce((sum, count) => sum + count, 0);
34
+ if (total <= maxLines)
35
+ return { text, hiddenLineCount: 0 };
36
+ const visibleBudget = Math.max(1, maxLines - 1); // reserve the indicator row
37
+ let used = 0;
38
+ let start = logical.length;
39
+ while (start > 0) {
40
+ const next = rows[start - 1] ?? 0;
41
+ if (used + next > visibleBudget)
42
+ break;
43
+ used += next;
44
+ start -= 1;
45
+ }
46
+ const hiddenLineCount = rows.slice(0, start).reduce((sum, count) => sum + count, 0);
47
+ return { text: logical.slice(start).join('\n'), hiddenLineCount };
48
+ }
@@ -1,9 +1,40 @@
1
1
  import React from 'react';
2
2
  import type { Message } from '../commands/streaming.js';
3
3
  export declare function messageElapsedLabel(message: Message): string;
4
- export declare function MessageView({ message, width }: {
4
+ export declare const AssistantMarkdownChunkView: React.MemoExoticComponent<({ message, content, width, first, final }: {
5
5
  message: Message;
6
+ content: string;
6
7
  width: number;
7
- }): React.JSX.Element;
8
+ first: boolean;
9
+ final: boolean;
10
+ }) => React.JSX.Element>;
11
+ export declare const MessageView: React.MemoExoticComponent<({ message, width, showHeader, maxVisibleLines }: {
12
+ message: Message;
13
+ width: number;
14
+ showHeader?: boolean;
15
+ maxVisibleLines?: number;
16
+ }) => React.JSX.Element>;
8
17
  export declare function messageKey(message: Message, index: number): string;
18
+ export type TranscriptStaticItem = {
19
+ kind: 'message';
20
+ key: string;
21
+ message: Message;
22
+ } | {
23
+ kind: 'assistant-markdown';
24
+ key: string;
25
+ message: Message;
26
+ content: string;
27
+ first: boolean;
28
+ final: boolean;
29
+ };
30
+ export type TranscriptStreamingItem = {
31
+ key: string;
32
+ message: Message;
33
+ showHeader?: boolean;
34
+ };
35
+ /** Partition display messages into append-only static Markdown roots and the active streaming tail. */
36
+ export declare function partitionDisplayMessages(messages: Message[]): {
37
+ staticItems: TranscriptStaticItem[];
38
+ streamingItems: TranscriptStreamingItem[];
39
+ };
9
40
  export declare function orderedDisplayMessages(messages: Message[]): Message[];