@denizokcu/haze 1.7.11 → 1.8.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.
- package/CHANGELOG.md +56 -0
- package/README.md +142 -102
- package/SECURITY.md +1 -1
- package/assets/graph-grammars/NOTICE.md +21 -0
- package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
- package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.js +4056 -0
- package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
- package/bin/haze.js +47 -19
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +1 -2
- package/dist/cli/chat/ChatHeader.d.ts +6 -0
- package/dist/cli/chat/ChatHeader.js +11 -0
- package/dist/cli/chat/ChatScreen.d.ts +16 -0
- package/dist/cli/chat/ChatScreen.js +399 -0
- package/dist/cli/chat/ChatScreenView.d.ts +68 -0
- package/dist/cli/chat/ChatScreenView.js +47 -0
- package/dist/cli/chat/LiveTail.d.ts +11 -0
- package/dist/cli/chat/LiveTail.js +26 -0
- package/dist/cli/chat/TaskBar.d.ts +3 -2
- package/dist/cli/chat/TaskBar.js +4 -0
- package/dist/cli/chat/agentTurnRunner.d.ts +12 -0
- package/dist/cli/chat/agentTurnRunner.js +177 -0
- package/dist/cli/chat/busyIndicator.js +9 -5
- package/dist/cli/chat/chatMetrics.d.ts +7 -0
- package/dist/cli/chat/chatMetrics.js +15 -1
- package/dist/cli/chat/chatViewModel.d.ts +85 -0
- package/dist/cli/chat/chatViewModel.js +66 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +0 -14
- package/dist/cli/chat/fileMentionSuggestions.js +4 -21
- package/dist/cli/chat/inputSuggestions.js +1 -0
- package/dist/cli/chat/liveTheme.d.ts +11 -0
- package/dist/cli/chat/liveTheme.js +26 -0
- package/dist/cli/chat/messageFinalize.d.ts +4 -0
- package/dist/cli/chat/messageFinalize.js +8 -0
- package/dist/cli/chat/messages.js +1 -1
- package/dist/cli/chat/pickerOpeners.d.ts +23 -0
- package/dist/cli/chat/pickerOpeners.js +36 -0
- package/dist/cli/chat/promptSessionState.d.ts +11 -0
- package/dist/cli/chat/promptSessionState.js +39 -0
- package/dist/cli/chat/renderMetrics.d.ts +8 -0
- package/dist/cli/chat/renderMetrics.js +14 -0
- package/dist/cli/chat/resizeGuard.d.ts +11 -0
- package/dist/cli/chat/resizeGuard.js +25 -0
- package/dist/cli/chat/screenDeps.d.ts +116 -0
- package/dist/cli/chat/screenDeps.js +1 -0
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
- package/dist/cli/chat/sessionLifecycle.js +6 -2
- package/dist/cli/chat/sessionRecorder.js +4 -1
- package/dist/cli/chat/settingsSelection.d.ts +33 -0
- package/dist/cli/chat/settingsSelection.js +46 -0
- package/dist/cli/chat/skillNotices.d.ts +18 -0
- package/dist/cli/chat/skillNotices.js +26 -0
- package/dist/cli/chat/startupInfo.js +1 -1
- package/dist/cli/chat/startupSequence.d.ts +2 -0
- package/dist/cli/chat/startupSequence.js +6 -0
- package/dist/cli/chat/submitPipeline.d.ts +8 -0
- package/dist/cli/chat/submitPipeline.js +141 -0
- package/dist/cli/chat/terminalControl.js +1 -1
- package/dist/cli/chat/toolSummaries.d.ts +29 -0
- package/dist/cli/chat/toolSummaries.js +268 -0
- package/dist/cli/chat/turnState.d.ts +8 -0
- package/dist/cli/chat/turnState.js +1 -0
- package/dist/cli/chat/userCommandFlow.d.ts +21 -0
- package/dist/cli/chat/userCommandFlow.js +66 -0
- package/dist/cli/chat/userCommandRunner.d.ts +14 -0
- package/dist/cli/chat/userCommandRunner.js +56 -0
- package/dist/cli/chat/wizard/providerHandlers.js +19 -2
- package/dist/cli/chat/wizardTrail.d.ts +22 -0
- package/dist/cli/chat/wizardTrail.js +55 -0
- package/dist/cli/commands/chat.d.ts +1 -13
- package/dist/cli/commands/chat.js +10 -795
- package/dist/cli/commands/commandHelp.js +11 -6
- package/dist/cli/commands/commandSuggest.d.ts +2 -0
- package/dist/cli/commands/commandSuggest.js +35 -0
- package/dist/cli/commands/commands.js +12 -3
- package/dist/cli/commands/formatters.d.ts +1 -23
- package/dist/cli/commands/formatters.js +3 -224
- package/dist/cli/commands/graphCommand.d.ts +2 -0
- package/dist/cli/commands/graphCommand.js +60 -0
- package/dist/cli/commands/initCommand.js +14 -0
- package/dist/cli/commands/modelCommand.js +11 -7
- package/dist/cli/commands/reasoningCommand.js +3 -3
- package/dist/cli/commands/runCommand.js +6 -2
- package/dist/cli/commands/streaming/agentAttempt.js +11 -1
- package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +8 -3
- package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
- package/dist/cli/commands/streaming/attemptSetup.js +34 -5
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/goalSupervisor.js +5 -3
- package/dist/cli/commands/streaming/prepareStep.js +1 -0
- package/dist/cli/commands/streaming/stepProjection.d.ts +59 -0
- package/dist/cli/commands/streaming/stepProjection.js +54 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
- package/dist/cli/commands/streaming/streamLoop.js +34 -23
- package/dist/cli/commands/streaming/toolGroupRenderer.js +1 -1
- package/dist/cli/commands/streaming/toolPartHandlers.js +8 -2
- package/dist/cli/commands/streaming.d.ts +3 -1
- package/dist/cli/commands/streaming.js +5 -0
- package/dist/cli/commands/wizardFlow.d.ts +2 -0
- package/dist/cli/commands/wizardFlow.js +3 -0
- package/dist/cli/index.js +8 -4
- package/dist/cli/terminalTitle.js +9 -3
- package/dist/config/contextFiles.d.ts +2 -5
- package/dist/config/contextFiles.js +1 -1
- package/dist/config/inputHistory.js +2 -2
- package/dist/config/providerAuth.js +2 -2
- package/dist/config/providerModelFacts.js +5 -0
- package/dist/config/providerPresets.js +1 -1
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.js +9 -2
- package/dist/config/updateCheck.js +2 -2
- package/dist/core/agent/compaction.d.ts +1 -0
- package/dist/core/agent/compaction.js +3 -0
- package/dist/core/agent/completionController.d.ts +1 -1
- package/dist/core/agent/contextBudget.d.ts +1 -1
- package/dist/core/agent/goalPolicy.js +8 -2
- package/dist/core/agent/overflow.js +5 -0
- package/dist/core/agent/toolCapabilities.js +14 -0
- package/dist/core/agent/userCommands.d.ts +53 -0
- package/dist/core/agent/userCommands.js +116 -0
- package/dist/core/agent/workState.d.ts +3 -1
- package/dist/core/agent/workState.js +57 -26
- package/dist/core/contextFileTypes.d.ts +12 -0
- package/dist/core/contextFileTypes.js +1 -0
- package/dist/core/graph/analyze.d.ts +61 -0
- package/dist/core/graph/analyze.js +274 -0
- package/dist/core/graph/buildGraph.d.ts +44 -0
- package/dist/core/graph/buildGraph.js +290 -0
- package/dist/core/graph/digest.d.ts +2 -0
- package/dist/core/graph/digest.js +40 -0
- package/dist/core/graph/extract.d.ts +58 -0
- package/dist/core/graph/extract.js +394 -0
- package/dist/core/graph/model.d.ts +63 -0
- package/dist/core/graph/model.js +96 -0
- package/dist/core/graph/query.d.ts +69 -0
- package/dist/core/graph/query.js +391 -0
- package/dist/core/graph/store.d.ts +64 -0
- package/dist/core/graph/store.js +171 -0
- package/dist/core/limits.d.ts +2 -0
- package/dist/core/limits.js +2 -0
- package/dist/core/log/llmLog.js +2 -2
- package/dist/{config → core/persistence}/privateStorage.js +1 -1
- package/dist/core/process/runBoundedProcess.d.ts +7 -4
- package/dist/core/process/runBoundedProcess.js +22 -11
- package/dist/core/safety/redaction.d.ts +2 -0
- package/dist/core/safety/redaction.js +26 -5
- package/dist/core/safety/secretPaths.js +12 -3
- package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
- package/dist/core/safety/untrustedEnvelopes.js +17 -2
- package/dist/core/safety/urlGuard.js +2 -0
- package/dist/core/session/sessionStore.d.ts +8 -1
- package/dist/core/session/sessionStore.js +15 -4
- package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
- package/dist/core/shellOutput/types.d.ts +1 -1
- package/dist/core/subagent/executionProfiles.js +4 -4
- package/dist/core/tasks/taskStorage.js +11 -1
- package/dist/{llm → core}/toolResultTypes.d.ts +1 -1
- package/dist/core/validation/outputParser.d.ts +1 -1
- package/dist/core/validation/outputParser.js +16 -8
- package/dist/llm/hazeTools.d.ts +2 -12426
- package/dist/llm/hazeTools.js +4 -0
- package/dist/llm/lsp/pool.js +1 -1
- package/dist/llm/lsp/workspaceEdit.d.ts +1 -1
- package/dist/llm/lspTools.d.ts +3 -12622
- package/dist/llm/requestContext.d.ts +6 -0
- package/dist/llm/requestContext.js +28 -7
- package/dist/llm/subagentRunner.d.ts +2 -308
- package/dist/llm/systemPrompt.js +17 -7
- package/dist/llm/toolGroups.d.ts +534 -0
- package/dist/llm/toolGroups.js +57 -0
- package/dist/llm/tools/editMatch.d.ts +1 -1
- package/dist/llm/tools/failures.d.ts +1 -1
- package/dist/llm/tools/fetchTool.d.ts +2 -1221
- package/dist/llm/tools/fileToolShared.d.ts +1 -1
- package/dist/llm/tools/fileToolShared.js +1 -1
- package/dist/llm/tools/fileTools.d.ts +2 -7768
- package/dist/llm/tools/fileTools.js +1 -1
- package/dist/llm/tools/gitTools.d.ts +12 -0
- package/dist/llm/tools/gitTools.js +527 -0
- package/dist/llm/tools/graphAdvisory.d.ts +22 -0
- package/dist/llm/tools/graphAdvisory.js +68 -0
- package/dist/llm/tools/graphTools.d.ts +13 -0
- package/dist/llm/tools/graphTools.js +195 -0
- package/dist/llm/tools/processTool.d.ts +2 -1081
- package/dist/llm/tools/readRecovery.d.ts +1 -1
- package/dist/llm/tools/replaceInFiles.d.ts +1 -1
- package/dist/llm/tools/replaceInFiles.js +1 -1
- package/dist/llm/tools/shellTool.d.ts +2 -1513
- package/dist/llm/tools/storedOutputTool.d.ts +2 -355
- package/dist/llm/tools/taskTool.d.ts +2 -489
- package/dist/llm/tools/taskTool.js +4 -1
- package/dist/llm/tools/toolContext.js +29 -11
- package/dist/llm/tools/toolContextState.d.ts +4 -1
- package/dist/llm/tools/toolContextState.js +2 -1
- package/dist/llm/tools/workspaceFile.d.ts +2 -2
- package/dist/llm/tools/workspaceFile.js +10 -5
- package/dist/skills/SkillRegistry.js +1 -1
- package/dist/skills/builder/SkillBuilder.js +1 -1
- package/dist/skills/plugins/installer.js +1 -1
- package/dist/skills/plugins/runtime.js +1 -1
- package/dist/skills/skillTools.js +4 -1
- package/dist/ui/components/MarkdownText.d.ts +14 -0
- package/dist/ui/components/MarkdownText.js +77 -12
- package/dist/ui/components/NativeIndicators.js +5 -1
- package/dist/ui/components/StreamingMarkdownText.d.ts +3 -1
- package/dist/ui/components/StreamingMarkdownText.js +39 -11
- package/dist/ui/components/TextInput.d.ts +1 -2
- package/dist/ui/components/TextInput.js +79 -9
- package/dist/ui/components/WizardChoices.d.ts +1 -2
- package/dist/ui/components/useInputSuggestions.d.ts +1 -1
- package/dist/ui/components/useInputSuggestions.js +1 -1
- package/dist/ui/mentionDetection.d.ts +20 -0
- package/dist/ui/mentionDetection.js +24 -0
- package/dist/ui/terminalColors.d.ts +4 -4
- package/dist/ui/terminalColors.js +23 -6
- package/dist/ui/terminalSanitize.js +8 -3
- package/dist/ui/textGeometry.d.ts +2 -0
- package/dist/ui/textGeometry.js +6 -0
- package/dist/ui/themes/registry.js +33 -33
- package/dist/utils/openPath.js +7 -0
- package/package.json +22 -19
- /package/dist/{llm/tools → core/ignore}/gitIgnore.d.ts +0 -0
- /package/dist/{llm/tools → core/ignore}/gitIgnore.js +0 -0
- /package/dist/{config → core}/paths.d.ts +0 -0
- /package/dist/{config → core}/paths.js +0 -0
- /package/dist/{config → core/persistence}/privateStorage.d.ts +0 -0
- /package/dist/{llm → core}/toolResultTypes.js +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Static, Text } from 'ink';
|
|
3
|
+
import { ActivitySpinner, StatusNotice } from '../../ui/components/NativeIndicators.js';
|
|
4
|
+
import { Header } from '../../ui/components/Header.js';
|
|
5
|
+
import { TextInput } from '../../ui/components/TextInput.js';
|
|
6
|
+
import { theme } from '../../ui/theme.js';
|
|
7
|
+
import { TaskBar } from './TaskBar.js';
|
|
8
|
+
import { BusyBar } from './BusyBar.js';
|
|
9
|
+
import { DynamicFrame } from './DynamicFrame.js';
|
|
10
|
+
import { AssistantMarkdownChunkView, MessageView } from './messages.js';
|
|
11
|
+
import { LiveTail } from './LiveTail.js';
|
|
12
|
+
import { contextLeftLabel } from './chatMetrics.js';
|
|
13
|
+
import { fileMentionSuggestions } from './fileMentionSuggestions.js';
|
|
14
|
+
import { TIPS } from './tips.js';
|
|
15
|
+
import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES } from '../commands/chatModes.js';
|
|
16
|
+
import { formatTokenCount } from '../../utils/format.js';
|
|
17
|
+
/**
|
|
18
|
+
* The pure render of the chat screen: static transcript plus the dynamic
|
|
19
|
+
* frame. Extracted from `commands/chat.tsx` so the component file stays
|
|
20
|
+
* orchestration glue; every value arrives as an explicit prop.
|
|
21
|
+
*/
|
|
22
|
+
export function ChatScreenView(props) {
|
|
23
|
+
const { version, debug, terminalRows, horizontalPadding, contentWidth, replay, staticItems, streamingItems, debugLogs, metrics, renderMetricsReader, tokenUsage, contextUsage, followUps, visibleTasks, tasksExpanded, taskBarPadding, busy, busyLabel, busyElapsed, busyDetail, showingTip, tipIndex, graphBuilding, pausedResume, workspaceLabel, activeModelName, reasoningSuffix, placeholder, mode, inputHistory, inputSuggestions, onSubmit, onCancel, onResumeKey, onInterrupt, onEscape, onHistoryAdd, onToggleTasks, } = props;
|
|
24
|
+
const contextLabel = contextLeftLabel(contextUsage, metrics.effectiveInput);
|
|
25
|
+
return _jsxs(Box, { flexDirection: "column", paddingX: horizontalPadding, children: [_jsx(Static, { items: staticItems, children: item => item.kind === 'header'
|
|
26
|
+
? _jsx(Header, { subtitle: item.subtitle, version: version }, item.key)
|
|
27
|
+
: item.kind === 'assistant-markdown'
|
|
28
|
+
? _jsx(AssistantMarkdownChunkView, { message: item.message, content: item.content, width: replay.contentWidth, first: item.first, final: item.final }, item.key)
|
|
29
|
+
: _jsx(MessageView, { message: item.message, width: replay.contentWidth }, item.key) }, replay.key), _jsx(DynamicFrame, { rows: terminalRows, columns: contentWidth, sections: {
|
|
30
|
+
live: streamingItems.length > 0 ? rows => _jsx(LiveTail, { items: streamingItems, width: contentWidth, rows: rows }) : undefined,
|
|
31
|
+
debug: debug ? _jsxs(_Fragment, { children: [debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["\u2022 ", line] }, index)), metrics.hasTokenBreakdown && _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Tokens: in=", formatTokenCount(metrics.effectiveInput), " out=", formatTokenCount(metrics.effectiveOutput), " logical=", formatTokenCount(tokenUsage.logicalInputEstimate)] }), renderMetricsReader && (() => {
|
|
32
|
+
const renderMetrics = renderMetricsReader();
|
|
33
|
+
if (!renderMetrics)
|
|
34
|
+
return null;
|
|
35
|
+
const age = Date.now() - renderMetrics.at;
|
|
36
|
+
// Skip the reading once it is clearly stale; it refreshes on the
|
|
37
|
+
// next frame while anything animated keeps the debug panel alive.
|
|
38
|
+
return age < 5_000 ? _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Ink render: ", renderMetrics.renderTime.toFixed(1), "ms"] }) : null;
|
|
39
|
+
})()] }) : undefined,
|
|
40
|
+
queue: followUps.queued.length > 0 ? _jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Queued follow-ups: ", followUps.queued.length] }), followUps.queued.map((item, index) => _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: [index + 1, ". ", item] }, `${index}-${item}`))] }) : undefined,
|
|
41
|
+
tasks: visibleTasks.length > 0 ? _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: Math.max(1, terminalRows - 8) }) : undefined,
|
|
42
|
+
activity: busy ? _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, detail: busyDetail, tip: showingTip ? TIPS[tipIndex] : undefined })
|
|
43
|
+
: graphBuilding ? _jsxs(Box, { overflow: "hidden", children: [_jsx(ActivitySpinner, {}), _jsx(Box, { flexShrink: 0, width: 1 }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: "Building code graph in the background\u2026" })] })
|
|
44
|
+
: pausedResume ? _jsxs(StatusNotice, { variant: "warning", children: ["Press R to resume \u00B7 unfinished goal paused", pausedResume.pauseReason ? ` (${pausedResume.pauseReason})` : ''] }) : undefined,
|
|
45
|
+
status: _jsxs(_Fragment, { children: [_jsxs(Box, { width: "100%", flexDirection: "row", justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsxs(Text, { color: theme.muted, wrap: "truncate-start", children: [activeModelName, reasoningSuffix] })] }), _jsxs(Box, { width: "100%", flexDirection: "row", justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel }), contextLabel && _jsx(Text, { color: theme.muted, wrap: "truncate-start", children: contextLabel })] })] }),
|
|
46
|
+
}, input: ({ width: inputWidth, inputRows, suggestionRows, onRowsChange }) => _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: inputWidth, inputRows: inputRows, suggestionRows: suggestionRows, onRowsChange: onRowsChange, getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: onHistoryAdd, onToggleTasks: onToggleTasks, onCancel: onCancel, onResumeKey: onResumeKey, onInterrupt: onInterrupt, onEscape: onEscape, onSubmit: onSubmit }) })] });
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TranscriptStreamingItem } from './transcriptPartition.js';
|
|
2
|
+
/**
|
|
3
|
+
* The dynamic tail's streaming items, clamped to the live-region row budget.
|
|
4
|
+
* Items beyond the budget are not dropped silently: one indicator row counts
|
|
5
|
+
* them, so parallel work that is temporarily out of view stays visible (FE-06).
|
|
6
|
+
*/
|
|
7
|
+
export declare function LiveTail({ items, width, rows }: {
|
|
8
|
+
items: TranscriptStreamingItem[];
|
|
9
|
+
width: number;
|
|
10
|
+
rows: number;
|
|
11
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { MessageView } from './messages.js';
|
|
4
|
+
import { theme } from '../../ui/theme.js';
|
|
5
|
+
/**
|
|
6
|
+
* The dynamic tail's streaming items, clamped to the live-region row budget.
|
|
7
|
+
* Items beyond the budget are not dropped silently: one indicator row counts
|
|
8
|
+
* them, so parallel work that is temporarily out of view stays visible (FE-06).
|
|
9
|
+
*/
|
|
10
|
+
export function LiveTail({ items, width, rows }) {
|
|
11
|
+
if (rows <= 0 || items.length === 0)
|
|
12
|
+
return null;
|
|
13
|
+
// Allocate the sum, not a positive minimum for every pending item.
|
|
14
|
+
let count = Math.min(items.length, Math.floor(rows / 2));
|
|
15
|
+
const hidden = items.length - count;
|
|
16
|
+
if (hidden > 0) {
|
|
17
|
+
// The indicator takes one row; give up an item rather than squeeze the
|
|
18
|
+
// remaining ones below a readable two rows (header or content plus one row).
|
|
19
|
+
const available = rows - 1;
|
|
20
|
+
while (count > 0 && Math.floor(available / count) < 2)
|
|
21
|
+
count -= 1;
|
|
22
|
+
}
|
|
23
|
+
const itemRows = count > 0 ? Math.floor((rows - (hidden > 0 ? 1 : 0)) / count) : 0;
|
|
24
|
+
// Keep the newest items: the last one is the active message being streamed.
|
|
25
|
+
return _jsxs(Box, { flexDirection: "column", children: [hidden > 0 ? _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: `+${items.length - count} more` }) : null, items.slice(items.length - count).map(item => _jsx(Box, { maxHeight: itemRows, flexShrink: 0, overflow: "hidden", children: _jsx(MessageView, { message: item.message, width: width, showHeader: item.showHeader, maxVisibleLines: itemRows - 1 }) }, item.key))] });
|
|
26
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { Task } from '../../core/tasks/taskStorage.js';
|
|
3
2
|
export declare const MAX_VISIBLE_TASKS = 5;
|
|
3
|
+
/** Rows the transcript gains when an expanded task bar collapses back to `MAX_VISIBLE_TASKS` rows. */
|
|
4
|
+
export declare function taskBarCollapsePadding(visibleTasks: number): number;
|
|
4
5
|
export declare function TaskBar({ tasks, width, expanded, padding, maxRows }: {
|
|
5
6
|
tasks: Task[];
|
|
6
7
|
width: number;
|
|
7
8
|
expanded: boolean;
|
|
8
9
|
padding: number;
|
|
9
10
|
maxRows?: number;
|
|
10
|
-
}):
|
|
11
|
+
}): import("react").JSX.Element;
|
package/dist/cli/chat/TaskBar.js
CHANGED
|
@@ -14,6 +14,10 @@ function taskStatusColor(status) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
export const MAX_VISIBLE_TASKS = 5;
|
|
17
|
+
/** Rows the transcript gains when an expanded task bar collapses back to `MAX_VISIBLE_TASKS` rows. */
|
|
18
|
+
export function taskBarCollapsePadding(visibleTasks) {
|
|
19
|
+
return Math.max(0, visibleTasks + 1 - (Math.min(visibleTasks, MAX_VISIBLE_TASKS) + 1));
|
|
20
|
+
}
|
|
17
21
|
export function TaskBar({ tasks, width, expanded, padding, maxRows }) {
|
|
18
22
|
const maxTitleWidth = Math.max(10, width - 6);
|
|
19
23
|
const inProgress = tasks.filter(t => t.status === 'in_progress');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TurnExecutionOptions } from '../commands/streaming.js';
|
|
2
|
+
import type { ChatScreenDeps } from './screenDeps.js';
|
|
3
|
+
/** A user submission: one turn, then every follow-up queued while it ran (ARCH-05). */
|
|
4
|
+
export declare function runAgentTurnWithFollowUps(deps: ChatScreenDeps, value: string, displayValue?: string, turnOptions?: TurnExecutionOptions): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Explicitly resume a genuinely paused goal (automatic continuation already
|
|
7
|
+
* ran): an idle-stall resume continues the bounded retry pool; an
|
|
8
|
+
* incomplete-goal resume restarts the supervisor from the stored checkpoint
|
|
9
|
+
* (kind selection in chat/userInput.ts). Both ride the preserved
|
|
10
|
+
* conversation — no completed mutations are replayed.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resumePausedGoal(deps: ChatScreenDeps): Promise<void>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { runAgentGoal } from '../commands/streaming/goalSupervisor.js';
|
|
2
|
+
import { createQuarantinableCallbacks } from '../commands/streaming/attemptLifecycle.js';
|
|
3
|
+
import { resolveModelSelector } from '../../config/providers.js';
|
|
4
|
+
import { providerEndpointFingerprint } from '../../config/providers.js';
|
|
5
|
+
import { loadTasks as loadTasksFromStore } from '../../core/tasks/taskStorage.js';
|
|
6
|
+
import { accumulateTokenUsage } from './turnState.js';
|
|
7
|
+
import { nextFleetStatus } from './chatMetrics.js';
|
|
8
|
+
import { clearTasks as clearTasksFromStore } from '../../core/tasks/taskStorage.js';
|
|
9
|
+
import { shouldClearCompletedTasks } from './turnState.js';
|
|
10
|
+
import { resumeKindFor } from './userInput.js';
|
|
11
|
+
import { routeQueuedLine } from './userCommandFlow.js';
|
|
12
|
+
/** A user submission: one turn, then every follow-up queued while it ran (ARCH-05). */
|
|
13
|
+
export async function runAgentTurnWithFollowUps(deps, value, displayValue, turnOptions = {}) {
|
|
14
|
+
if (deps.stoppingRef.current)
|
|
15
|
+
return;
|
|
16
|
+
deps.setDebugLogs([]);
|
|
17
|
+
// When every task is already completed, start the new turn with a clean
|
|
18
|
+
// slate: the task bar clears (nothing shown for simple questions) and the
|
|
19
|
+
// model may create fresh todos via writeTasks if the new question warrants.
|
|
20
|
+
if (shouldClearCompletedTasks(deps.visibleTasks)) {
|
|
21
|
+
deps.setVisibleTasks([]);
|
|
22
|
+
deps.setTasksExpanded(false);
|
|
23
|
+
deps.setTaskBarPadding(0);
|
|
24
|
+
await clearTasksFromStore().catch(() => undefined);
|
|
25
|
+
}
|
|
26
|
+
await runSingleAgentTurn(deps, value, displayValue, turnOptions);
|
|
27
|
+
for (let next = deps.followUps.takeNext(); !deps.stoppingRef.current && next !== undefined; next = deps.followUps.takeNext()) {
|
|
28
|
+
// A queued `!` line is a user command, not a prompt.
|
|
29
|
+
const routed = await routeQueuedLine(deps, next);
|
|
30
|
+
if (routed.handled)
|
|
31
|
+
continue;
|
|
32
|
+
const preparedFollowUp = await deps.prepareUserInput(routed.value);
|
|
33
|
+
if (!preparedFollowUp)
|
|
34
|
+
continue;
|
|
35
|
+
await runSingleAgentTurn(deps, preparedFollowUp.value, preparedFollowUp.displayValue, preparedFollowUp.options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Explicitly resume a genuinely paused goal (automatic continuation already
|
|
40
|
+
* ran): an idle-stall resume continues the bounded retry pool; an
|
|
41
|
+
* incomplete-goal resume restarts the supervisor from the stored checkpoint
|
|
42
|
+
* (kind selection in chat/userInput.ts). Both ride the preserved
|
|
43
|
+
* conversation — no completed mutations are replayed.
|
|
44
|
+
*/
|
|
45
|
+
export async function resumePausedGoal(deps) {
|
|
46
|
+
const resume = deps.pausedResume;
|
|
47
|
+
if (!resume || deps.busy)
|
|
48
|
+
return;
|
|
49
|
+
deps.setPausedResume(undefined);
|
|
50
|
+
deps.setMessages(m => [...m, { role: 'system', text: 'Resuming the unfinished goal; completed work is preserved in the conversation.' }]);
|
|
51
|
+
await runSingleAgentTurn(deps, resume.request, undefined, {}, resumeKindFor(resume));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Run one physical agent turn under the logical-goal supervisor. Extracted
|
|
55
|
+
* from `chat.tsx` (CR-006 pattern): recoverable-incomplete turns continue
|
|
56
|
+
* automatically; an explicit `resumeExisting` restarts a genuinely paused
|
|
57
|
+
* goal from its checkpoint/retry pool. Behavior is unchanged — pure code
|
|
58
|
+
* motion over the explicit deps bundle.
|
|
59
|
+
*/
|
|
60
|
+
async function runSingleAgentTurn(deps, value, displayValue, turnOptions = {}, resumeExisting) {
|
|
61
|
+
const { stoppingRef, sealedRef, quarantineRef, activeGoalRef, conversationRef, settingsRef, sessionRecorderRef, contextFiles, settings, withDisplayOrder, addStreaming, patchLiveMessage, drainLiveMessages, finalizeMessage, setMessages, setBusy, setBusyLabel, debugLog, lastAssistantTextRef, abortControllerRef, workStateRef, setTokenUsage, setContextUsage, setFleet, setVisibleTasks, setTaskBarPadding, contextFileSignaturesRef, llmLogRef, showPersistenceWarning, setPausedResume, currentModelSelection, currentPromptSession, } = deps;
|
|
62
|
+
if (stoppingRef.current)
|
|
63
|
+
return;
|
|
64
|
+
const sessionRecorder = sessionRecorderRef.current;
|
|
65
|
+
const selection = currentModelSelection();
|
|
66
|
+
if (!selection) {
|
|
67
|
+
setMessages(m => [...m, { role: 'system', text: 'No model selected for this session. Run /model to choose one.' }]);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
sessionRecorder.recordModelSelection(selection);
|
|
71
|
+
// The logical-goal supervisor owns this submission: recoverable-incomplete
|
|
72
|
+
// physical turns (including step/tool budget boundaries) continue
|
|
73
|
+
// automatically; per-turn limits stay safety boundaries. An explicit
|
|
74
|
+
// resumeFrom restarts a genuinely paused goal from its checkpoint/pool.
|
|
75
|
+
const goalOptions = {
|
|
76
|
+
request: value,
|
|
77
|
+
displayValue,
|
|
78
|
+
contextFiles,
|
|
79
|
+
session: currentPromptSession(),
|
|
80
|
+
modelOverride: `${selection.provider}:${selection.model}`,
|
|
81
|
+
escalationModel: settings.escalationModel,
|
|
82
|
+
callbacks: {
|
|
83
|
+
addMessage: (msg) => {
|
|
84
|
+
const ordered = withDisplayOrder(msg);
|
|
85
|
+
if (ordered.streaming) {
|
|
86
|
+
addStreaming(ordered);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
finalizeMessage(ordered);
|
|
90
|
+
},
|
|
91
|
+
updateMessage: (id, update) => {
|
|
92
|
+
if (patchLiveMessage(id, update))
|
|
93
|
+
return;
|
|
94
|
+
setMessages(m => m.map(msg => msg.id === id ? { ...msg, ...update } : msg));
|
|
95
|
+
},
|
|
96
|
+
setConversation: (msgs) => {
|
|
97
|
+
conversationRef.current = msgs;
|
|
98
|
+
sessionRecorder.recordConversation(msgs);
|
|
99
|
+
},
|
|
100
|
+
onModelTransition: (selector, msgs) => {
|
|
101
|
+
const resolved = resolveModelSelector(settingsRef.current, selector);
|
|
102
|
+
if (resolved.status === 'found')
|
|
103
|
+
sessionRecorder.recordModelTransition(msgs, { provider: resolved.provider.name, model: resolved.model, endpointFingerprint: providerEndpointFingerprint(resolved.provider) });
|
|
104
|
+
},
|
|
105
|
+
setBusy,
|
|
106
|
+
setBusyLabel,
|
|
107
|
+
debugLog,
|
|
108
|
+
getConversation: () => conversationRef.current,
|
|
109
|
+
getLastAssistantText: () => lastAssistantTextRef.current,
|
|
110
|
+
setLastAssistantText: (text) => { lastAssistantTextRef.current = text; },
|
|
111
|
+
setAbortController: (controller) => {
|
|
112
|
+
abortControllerRef.current = controller;
|
|
113
|
+
if (stoppingRef.current)
|
|
114
|
+
controller?.abort('Chat is exiting.');
|
|
115
|
+
},
|
|
116
|
+
setWorkState: (state) => {
|
|
117
|
+
workStateRef.current = state;
|
|
118
|
+
sessionRecorder.recordWorkState(state);
|
|
119
|
+
},
|
|
120
|
+
compactConversation: deps.sessionLifecycle.compactConversation,
|
|
121
|
+
recordCompaction: (entry) => sessionRecorder.recordCompactEntry(entry),
|
|
122
|
+
recordTokenUsage: (usage) => {
|
|
123
|
+
setTokenUsage(current => accumulateTokenUsage(current, usage));
|
|
124
|
+
},
|
|
125
|
+
recordContextUsage: (tokens) => setContextUsage?.(current => ({ windowTokens: current.windowTokens, usedTokens: tokens, estimated: false })),
|
|
126
|
+
onEvent: (event) => {
|
|
127
|
+
sessionRecorder.recordEvent(event);
|
|
128
|
+
if (event.type === 'context_budget')
|
|
129
|
+
setContextUsage?.(current => ({ ...current, windowTokens: event.contextWindowTokens }));
|
|
130
|
+
else if (event.type === 'subagent_state')
|
|
131
|
+
setFleet(current => nextFleetStatus(current, event));
|
|
132
|
+
else if (event.type === 'goal_end')
|
|
133
|
+
setFleet(undefined);
|
|
134
|
+
},
|
|
135
|
+
onTasksChanged: () => {
|
|
136
|
+
loadTasksFromStore().then(t => {
|
|
137
|
+
if (stoppingRef.current)
|
|
138
|
+
return;
|
|
139
|
+
setVisibleTasks(t);
|
|
140
|
+
setTaskBarPadding(0);
|
|
141
|
+
}).catch(() => undefined);
|
|
142
|
+
},
|
|
143
|
+
contextFileSignatures: contextFileSignaturesRef.current,
|
|
144
|
+
log: llmLogRef.current,
|
|
145
|
+
},
|
|
146
|
+
...(resumeExisting ? { resumeFrom: resumeExisting } : {}),
|
|
147
|
+
// Durable goal ledger (P1): every supervisor boundary appends to the
|
|
148
|
+
// session JSONL so a crash or restart leaves a resumable frontier.
|
|
149
|
+
goalLedger: { append: (entry) => { if (!sealedRef.current)
|
|
150
|
+
sessionRecorder.recordGoalEntry(entry); } },
|
|
151
|
+
...(turnOptions.attachments || turnOptions.blessedPaths || turnOptions.ephemeralControl || turnOptions.subagentOverrides ? { turnOptions } : {})
|
|
152
|
+
};
|
|
153
|
+
const guarded = createQuarantinableCallbacks(goalOptions.callbacks);
|
|
154
|
+
quarantineRef.current = guarded.quarantine;
|
|
155
|
+
const goalPromise = runAgentGoal({ ...goalOptions, callbacks: guarded.callbacks });
|
|
156
|
+
activeGoalRef.current = goalPromise;
|
|
157
|
+
const goalResult = await goalPromise;
|
|
158
|
+
activeGoalRef.current = undefined;
|
|
159
|
+
if (stoppingRef.current)
|
|
160
|
+
return goalResult;
|
|
161
|
+
await sessionRecorder.flush().catch(showPersistenceWarning);
|
|
162
|
+
await llmLogRef.current?.writer?.flush().catch(showPersistenceWarning);
|
|
163
|
+
// Turn boundary: an aborted or forcibly-settled attempt is quarantined
|
|
164
|
+
// before it can emit the finalizing update, so settle anything still in
|
|
165
|
+
// the live tail now; the streamed text is preserved verbatim in <Static>.
|
|
166
|
+
drainLiveMessages();
|
|
167
|
+
// Only a genuinely paused goal (supervisor already attempted automatic
|
|
168
|
+
// continuation) exposes the one-key resume affordance; it stays until the
|
|
169
|
+
// user submits something else.
|
|
170
|
+
if (goalResult.resume?.kind === 'model-stream-idle')
|
|
171
|
+
setPausedResume({ kind: 'model-stream-idle', request: goalResult.resume.request, retryAttempt: goalResult.resume.retryAttempt });
|
|
172
|
+
else if (goalResult.resume?.kind === 'incomplete-goal')
|
|
173
|
+
setPausedResume({ kind: 'incomplete-goal', request: goalResult.resume.checkpoint.request, retryAttempt: 0, checkpoint: goalResult.resume.checkpoint, pauseReason: goalResult.stopReason === 'context-exhausted' || goalResult.stopReason === 'goal-deadline' || goalResult.stopReason === 'no-progress' ? goalResult.stopReason : undefined });
|
|
174
|
+
else
|
|
175
|
+
setPausedResume(undefined);
|
|
176
|
+
return goalResult;
|
|
177
|
+
}
|
|
@@ -26,11 +26,15 @@ export function useBusyIndicator() {
|
|
|
26
26
|
// re-renders this component, refreshing the elapsed label below.
|
|
27
27
|
useAnimation({ interval: 1000, isActive: busy && !screenReader });
|
|
28
28
|
function setBusy(nextBusy) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
// Functional update so two setBusy calls inside one React batch both see
|
|
30
|
+
// the current flag and the timer starts once (FE-10).
|
|
31
|
+
setBusyState(current => {
|
|
32
|
+
if (nextBusy && !current)
|
|
33
|
+
turnStartedAtRef.current = Date.now();
|
|
34
|
+
if (!nextBusy)
|
|
35
|
+
turnStartedAtRef.current = undefined;
|
|
36
|
+
return nextBusy;
|
|
37
|
+
});
|
|
34
38
|
}
|
|
35
39
|
return { busy, setBusy, elapsed: busyElapsedLabel(turnStartedAtRef.current) };
|
|
36
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
2
|
import type { Message } from '../commands/streaming.js';
|
|
3
3
|
import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
|
|
4
|
+
import type { ContextUsage } from './turnState.js';
|
|
4
5
|
export declare function toolCallCount(messages: Message[]): number;
|
|
5
6
|
export declare function compactHomePath(filePath: string, home?: string): string;
|
|
6
7
|
export declare function displayMessagesFromConversation(conversation: ModelMessage[]): Message[];
|
|
@@ -24,6 +25,12 @@ export declare function statusBarMetrics(input: {
|
|
|
24
25
|
statusDetailLabel: string;
|
|
25
26
|
hasTokenBreakdown: boolean;
|
|
26
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* `NN% context left` for the status bar. Uses the provider-measured request size
|
|
30
|
+
* once a step has reported; before that falls back to the transcript estimate
|
|
31
|
+
* (`fallbackUsedTokens`), marked `~` when it is a nonzero guess.
|
|
32
|
+
*/
|
|
33
|
+
export declare function contextLeftLabel(usage: ContextUsage, fallbackUsedTokens: number): string | undefined;
|
|
27
34
|
export interface FleetStatus {
|
|
28
35
|
running: number;
|
|
29
36
|
queued: number;
|
|
@@ -60,6 +60,20 @@ export function statusBarMetrics(input) {
|
|
|
60
60
|
const hasTokenBreakdown = tokenUsage.systemPrompt > 0 || tokenUsage.messages > 0 || tokenUsage.toolSchemas > 0 || effectiveInput > 0 || effectiveOutput > 0;
|
|
61
61
|
return { assistantMessages, toolsUsed, effectiveInput, effectiveOutput, inputEstimated, outputEstimated, statusDetailLabel, hasTokenBreakdown };
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* `NN% context left` for the status bar. Uses the provider-measured request size
|
|
65
|
+
* once a step has reported; before that falls back to the transcript estimate
|
|
66
|
+
* (`fallbackUsedTokens`), marked `~` when it is a nonzero guess.
|
|
67
|
+
*/
|
|
68
|
+
export function contextLeftLabel(usage, fallbackUsedTokens) {
|
|
69
|
+
const windowTokens = usage.windowTokens;
|
|
70
|
+
if (!windowTokens || windowTokens <= 0)
|
|
71
|
+
return undefined;
|
|
72
|
+
const measured = usage.usedTokens != null;
|
|
73
|
+
const usedTokens = Math.max(0, Math.min(windowTokens, usage.usedTokens ?? fallbackUsedTokens));
|
|
74
|
+
const left = Math.round((1 - usedTokens / windowTokens) * 100);
|
|
75
|
+
return `${!measured && usedTokens > 0 ? '~' : ''}${left}% context left`;
|
|
76
|
+
}
|
|
63
77
|
/**
|
|
64
78
|
* Rolling fleet depth for the busy row, folded from coordinator events.
|
|
65
79
|
* `queued` events report the queue length after enqueue; each later `started`
|
|
@@ -91,7 +105,7 @@ export function busyDetailLabel(input) {
|
|
|
91
105
|
}
|
|
92
106
|
const fleet = input.fleet;
|
|
93
107
|
if (fleet && (fleet.running > 0 || fleet.queued > 0)) {
|
|
94
|
-
parts.push(`
|
|
108
|
+
parts.push(`subagents ${fleet.running} running${fleet.queued > 0 ? `, ${fleet.queued} queued` : ''}`); // UX-21: one noun — "subagent" — for the fleet's parallel agents
|
|
95
109
|
}
|
|
96
110
|
return parts.length > 0 ? parts.join(' · ') : undefined;
|
|
97
111
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
import type { SessionSummary } from '../../core/session/sessionStore.js';
|
|
3
|
+
import type { LoadedSkill } from '../../skills/types.js';
|
|
4
|
+
import type { PromptSession } from '../../llm/systemPrompt.js';
|
|
5
|
+
import type { Message } from '../commands/streaming.js';
|
|
6
|
+
import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
|
|
7
|
+
import { type Mode } from '../commands/chatModes.js';
|
|
8
|
+
import { type FleetStatus } from './chatMetrics.js';
|
|
9
|
+
import type { WizardUiState } from './wizard/uiState.js';
|
|
10
|
+
/** The session's pinned `provider:model` selection, when one is recorded. */
|
|
11
|
+
export type ModelSelection = {
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
endpointFingerprint?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Status-bar model name and reasoning suffix for the current screen state.
|
|
18
|
+
* Pure: the name marks a selection that no longer resolves, and the suffix
|
|
19
|
+
* shows the level that will actually be requested (`(no reasoning parameter)`
|
|
20
|
+
* for `unset`, `(provider default)` when the protocol cannot carry a level).
|
|
21
|
+
*/
|
|
22
|
+
export declare function modelStatusFor(input: {
|
|
23
|
+
settings: HazeSettings;
|
|
24
|
+
selectedModel: ModelSelection | undefined;
|
|
25
|
+
sessionReasoning: PromptSession['reasoningByModel'];
|
|
26
|
+
}): {
|
|
27
|
+
activeModelName: string;
|
|
28
|
+
reasoningSuffix: string;
|
|
29
|
+
};
|
|
30
|
+
/** Horizontal chrome for the live frame (`width`) and the settled Static replay (`replayWidth`). */
|
|
31
|
+
export declare function chatLayoutFor(width: number, replayWidth: number): {
|
|
32
|
+
horizontalPadding: number;
|
|
33
|
+
contentWidth: number;
|
|
34
|
+
replayContentWidth: number;
|
|
35
|
+
};
|
|
36
|
+
export interface ChatViewModelInput {
|
|
37
|
+
messages: Message[];
|
|
38
|
+
liveMessages: Message[];
|
|
39
|
+
busy: boolean;
|
|
40
|
+
fleet: FleetStatus | undefined;
|
|
41
|
+
settings: HazeSettings;
|
|
42
|
+
mode: Mode;
|
|
43
|
+
tokenUsage: TokenUsage;
|
|
44
|
+
backgroundCount: number;
|
|
45
|
+
skills: LoadedSkill[];
|
|
46
|
+
branchName: string | undefined;
|
|
47
|
+
sessions: SessionSummary[];
|
|
48
|
+
wizard: WizardUiState;
|
|
49
|
+
selectedModel: ModelSelection | undefined;
|
|
50
|
+
/** `reasoningByModel` of the current session; a new object identity re-derives the suffix and the picker suggestions. */
|
|
51
|
+
sessionReasoning: PromptSession['reasoningByModel'];
|
|
52
|
+
/** Bumped by `/reasoning`; it only forces the re-render that re-reads `sessionReasoning`. */
|
|
53
|
+
reasoningOverrideCounter: number;
|
|
54
|
+
width: number;
|
|
55
|
+
replayWidth: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Everything `ChatScreen` derives for one render. The heavy work is memoised on
|
|
59
|
+
* the identity of its inputs (FE-03): the 1 Hz busy heartbeat and every stream
|
|
60
|
+
* delta re-render the screen, but only changed messages may re-run Markdown
|
|
61
|
+
* root chunking.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useChatViewModel(input: ChatViewModelInput): {
|
|
64
|
+
horizontalPadding: number;
|
|
65
|
+
contentWidth: number;
|
|
66
|
+
replayContentWidth: number;
|
|
67
|
+
busyDetail: string | undefined;
|
|
68
|
+
staticTranscriptItems: import("./transcriptPartition.js").TranscriptStaticItem[];
|
|
69
|
+
streamingItems: import("./transcriptPartition.js").TranscriptStreamingItem[];
|
|
70
|
+
placeholder: string;
|
|
71
|
+
activeModelName: string;
|
|
72
|
+
reasoningSuffix: string;
|
|
73
|
+
workspaceLabel: string;
|
|
74
|
+
metrics: {
|
|
75
|
+
assistantMessages: number;
|
|
76
|
+
toolsUsed: number;
|
|
77
|
+
effectiveInput: number;
|
|
78
|
+
effectiveOutput: number;
|
|
79
|
+
inputEstimated: boolean;
|
|
80
|
+
outputEstimated: boolean;
|
|
81
|
+
statusDetailLabel: string;
|
|
82
|
+
hasTokenBreakdown: boolean;
|
|
83
|
+
};
|
|
84
|
+
inputSuggestions: import("../../ui/components/TextInput.js").TextInputSuggestion[];
|
|
85
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { activeModel } from '../../config/providers.js';
|
|
3
|
+
import { resolveProviderReasoning } from '../../config/providerReasoning.js';
|
|
4
|
+
import { isSkillEnabled } from '../../config/skillSettings.js';
|
|
5
|
+
import { isStoredReasoning, resolveReasoningChoice } from '../../core/agent/reasoningPolicy.js';
|
|
6
|
+
import { placeholderForMode } from '../commands/chatModes.js';
|
|
7
|
+
import { busyDetailLabel, compactHomePath, statusBarMetrics } from './chatMetrics.js';
|
|
8
|
+
import { inputSuggestionsForState } from './inputSuggestions.js';
|
|
9
|
+
import { partitionDisplayMessages } from './transcriptPartition.js';
|
|
10
|
+
/**
|
|
11
|
+
* Status-bar model name and reasoning suffix for the current screen state.
|
|
12
|
+
* Pure: the name marks a selection that no longer resolves, and the suffix
|
|
13
|
+
* shows the level that will actually be requested (`(no reasoning parameter)`
|
|
14
|
+
* for `unset`, `(provider default)` when the protocol cannot carry a level).
|
|
15
|
+
*/
|
|
16
|
+
export function modelStatusFor(input) {
|
|
17
|
+
const { settings, selectedModel } = input;
|
|
18
|
+
const activeSelection = activeModel(settings);
|
|
19
|
+
const activeModelName = selectedModel ? `${selectedModel.provider}:${selectedModel.model}${activeSelection ? '' : ' (unavailable)'}` : 'unconfigured';
|
|
20
|
+
const activeSelector = activeSelection ? `${activeSelection.provider.name}:${activeSelection.model}` : undefined;
|
|
21
|
+
const effectiveReasoning = activeSelector
|
|
22
|
+
? resolveReasoningChoice(input.sessionReasoning?.[activeSelector], isStoredReasoning(settings.reasoning) ? settings.reasoning : undefined)
|
|
23
|
+
: undefined;
|
|
24
|
+
const reasoningSuffix = effectiveReasoning
|
|
25
|
+
? effectiveReasoning.level === undefined
|
|
26
|
+
? ' (no reasoning parameter)'
|
|
27
|
+
: activeSelection && resolveProviderReasoning(activeSelection.provider, activeSelection.model, effectiveReasoning.level).effective === 'disabled'
|
|
28
|
+
? ' (provider default)'
|
|
29
|
+
: ` (${effectiveReasoning.level})`
|
|
30
|
+
: '';
|
|
31
|
+
return { activeModelName, reasoningSuffix };
|
|
32
|
+
}
|
|
33
|
+
/** Horizontal chrome for the live frame (`width`) and the settled Static replay (`replayWidth`). */
|
|
34
|
+
export function chatLayoutFor(width, replayWidth) {
|
|
35
|
+
const horizontalPadding = width >= 12 ? 1 : 0;
|
|
36
|
+
return {
|
|
37
|
+
horizontalPadding,
|
|
38
|
+
contentWidth: Math.max(1, width - horizontalPadding * 2),
|
|
39
|
+
replayContentWidth: Math.max(1, replayWidth - (replayWidth >= 12 ? 1 : 0) * 2),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Everything `ChatScreen` derives for one render. The heavy work is memoised on
|
|
44
|
+
* the identity of its inputs (FE-03): the 1 Hz busy heartbeat and every stream
|
|
45
|
+
* delta re-render the screen, but only changed messages may re-run Markdown
|
|
46
|
+
* root chunking.
|
|
47
|
+
*/
|
|
48
|
+
export function useChatViewModel(input) {
|
|
49
|
+
const { messages, liveMessages, busy, fleet, settings, mode, tokenUsage, backgroundCount, skills, branchName, sessions, wizard, selectedModel, sessionReasoning, reasoningOverrideCounter, width, replayWidth } = input;
|
|
50
|
+
void reasoningOverrideCounter;
|
|
51
|
+
const activeLiveMessages = useMemo(() => liveMessages.filter(message => !message.hidden), [liveMessages]);
|
|
52
|
+
// Recomputed each busy heartbeat (1 Hz) alongside the elapsed label; the
|
|
53
|
+
// streaming-rate estimate rides the already-live message text, so no extra
|
|
54
|
+
// timer or token bookkeeping is introduced.
|
|
55
|
+
const busyDetail = busy ? busyDetailLabel({ messages: activeLiveMessages, fleet }) : undefined;
|
|
56
|
+
const { staticItems: staticTranscriptItems, streamingItems } = useMemo(() => partitionDisplayMessages([...messages, ...liveMessages].filter(message => !message.hidden)), [messages, liveMessages]);
|
|
57
|
+
const placeholder = placeholderForMode(mode, busy);
|
|
58
|
+
const { activeModelName, reasoningSuffix } = modelStatusFor({ settings, selectedModel, sessionReasoning });
|
|
59
|
+
const workspaceLabel = `${compactHomePath(process.cwd())}${branchName ? ` (${branchName})` : ''}`;
|
|
60
|
+
const enabledSkillCount = useMemo(() => new Set(skills.filter(skill => isSkillEnabled(settings, skill.name, skill.source)).map(skill => skill.name)).size, [skills, settings]);
|
|
61
|
+
const metrics = useMemo(() => statusBarMetrics({ messages: [...messages, ...liveMessages], tokenUsage, enabledSkillCount, backgroundProcessCount: backgroundCount }), [messages, liveMessages, tokenUsage, enabledSkillCount, backgroundCount]);
|
|
62
|
+
const { modelProviderFilter, discoveredModels, suggestedModels, selectedProviderName, providerDraft, selectedSkillName, selectedLspName, selectedMcpName, plugins, selectedPluginName, pluginCollectionEntries } = wizard;
|
|
63
|
+
const inputSuggestions = useMemo(() => inputSuggestionsForState({ mode, settings, skills, sessions, selectedProviderName, modelProviderFilter, providerDraftName: providerDraft.name, discoveredModels, suggestedModels, selectedSkillName, selectedLspName, selectedMcpName, plugins, selectedPluginName, pluginCollectionEntries, sessionReasoning }), [mode, settings, skills, sessions, selectedProviderName, modelProviderFilter, providerDraft.name, discoveredModels, suggestedModels, selectedSkillName, selectedLspName, selectedMcpName, plugins, selectedPluginName, pluginCollectionEntries, sessionReasoning]);
|
|
64
|
+
const layout = chatLayoutFor(width, replayWidth);
|
|
65
|
+
return { busyDetail, staticTranscriptItems, streamingItems, placeholder, activeModelName, reasoningSuffix, workspaceLabel, metrics, inputSuggestions, ...layout };
|
|
66
|
+
}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
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
2
|
export interface FileMentionSuggestionsOptions {
|
|
17
3
|
/** Override the workspace root for tests. Defaults to `process.cwd()`. */
|
|
18
4
|
workspaceRoot?: string;
|
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { walkDir } from '../../utils/fs.js';
|
|
4
|
-
import { createIgnoreClassifier } from '../../
|
|
4
|
+
import { createIgnoreClassifier } from '../../core/ignore/gitIgnore.js';
|
|
5
5
|
import { workspaceRoot } from '../../utils/path.js';
|
|
6
6
|
/**
|
|
7
7
|
* Tab-completion support for `@`-mention paths (F04 AC1).
|
|
8
8
|
*
|
|
9
9
|
* Mention completion is cursor-aware partial replacement — unlike slash
|
|
10
10
|
* commands, the suggestion replaces only the `@token` at the cursor, not the
|
|
11
|
-
* whole input. Detection runs in the TextInput layer;
|
|
12
|
-
* filesystem listing (bounded, `.gitignore`-aware) and
|
|
11
|
+
* whole input. Detection runs in the TextInput layer (`ui/mentionDetection.ts`);
|
|
12
|
+
* this module owns the filesystem listing (bounded, `.gitignore`-aware) and
|
|
13
|
+
* stays UI-agnostic.
|
|
13
14
|
*/
|
|
14
15
|
/** Cap so completion stays responsive in large repos (F04 AC5). */
|
|
15
16
|
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
17
|
/**
|
|
35
18
|
* Strip the leading `@` and split the query into parent directory + prefix.
|
|
36
19
|
* `@src/f` → `{parentDir: 'src', prefix: 'f'}`; `@` → `{parentDir: '.', prefix: ''}`.
|
|
@@ -20,6 +20,7 @@ const CHAT_COMMAND_SUGGESTIONS = [
|
|
|
20
20
|
{ value: '/session', description: 'Show current session path', kind: 'command' },
|
|
21
21
|
{ value: '/resume', description: 'Browse saved sessions for this workspace', kind: 'command' },
|
|
22
22
|
{ value: '/new', description: 'Start a new session', kind: 'command' },
|
|
23
|
+
{ value: '/graph', description: 'Build or refresh the workspace code graph (deterministic, incremental) and show an orientation report', kind: 'command' },
|
|
23
24
|
{ value: '/logs', description: 'List recent LLM logs, or summarize one by id (--debug runs only)', kind: 'command' },
|
|
24
25
|
{ value: '/compact ', description: 'Summarize older context and keep recent messages', kind: 'command' },
|
|
25
26
|
{ value: '/clear', description: 'Clear conversation history', kind: 'command' },
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
/**
|
|
3
|
+
* Live theme switching, extracted from `ChatScreen` (ARCH-05): whenever the
|
|
4
|
+
* settings' theme name changes (/themes), re-resolve and adopt it so the whole
|
|
5
|
+
* UI repaints without a restart. Ink <Static> history stays as-rendered, so
|
|
6
|
+
* already-printed text keeps its old colors; the terminal defaults (OSC 10/11)
|
|
7
|
+
* follow the new theme. Skipped until `settingsThemeLoadedRef` is set —
|
|
8
|
+
* `chatCommand()` already resolved the theme before the first render, and the
|
|
9
|
+
* pre-load {} state would briefly flash the default theme.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useLiveTheme(settings: HazeSettings, stoppingRef: React.MutableRefObject<boolean>, settingsThemeLoadedRef: React.MutableRefObject<boolean>): void;
|