@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.
- package/CHANGELOG.md +100 -1
- package/README.md +77 -27
- package/SECURITY.md +22 -0
- package/bin/haze.js +102 -1
- package/dist/buildInfo.json +7 -0
- package/dist/cli/chat/TaskBar.d.ts +2 -1
- package/dist/cli/chat/TaskBar.js +7 -4
- package/dist/cli/chat/chatMetrics.d.ts +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/contextReport.js +2 -0
- package/dist/cli/chat/fileMentionSuggestions.js +3 -2
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +9 -41
- package/dist/cli/chat/liveRegion.d.ts +25 -0
- package/dist/cli/chat/liveRegion.js +48 -0
- package/dist/cli/chat/messages.d.ts +33 -4
- package/dist/cli/chat/messages.js +218 -35
- package/dist/cli/chat/sessionLifecycle.d.ts +11 -1
- package/dist/cli/chat/sessionLifecycle.js +64 -14
- package/dist/cli/chat/sessionRecorder.js +75 -7
- package/dist/cli/chat/startupInfo.d.ts +0 -1
- package/dist/cli/chat/startupInfo.js +11 -15
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +349 -133
- package/dist/cli/commands/chat.d.ts +5 -0
- package/dist/cli/commands/chat.js +216 -172
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/commands.d.ts +2 -0
- package/dist/cli/commands/commands.js +10 -5
- package/dist/cli/commands/doctor.d.ts +19 -0
- package/dist/cli/commands/doctor.js +76 -0
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +8 -25
- package/dist/cli/commands/ndjsonSink.d.ts +23 -0
- package/dist/cli/commands/ndjsonSink.js +38 -0
- package/dist/cli/commands/providerWizard.d.ts +9 -2
- package/dist/cli/commands/providerWizard.js +39 -7
- package/dist/cli/commands/runCommand.d.ts +3 -0
- package/dist/cli/commands/runCommand.js +117 -11
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/skillsWizard.d.ts +41 -0
- package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
- package/dist/cli/commands/streaming/abortCause.d.ts +25 -0
- package/dist/cli/commands/streaming/abortCause.js +16 -0
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- package/dist/cli/commands/streaming/assistantText.js +9 -2
- package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
- package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
- package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
- package/dist/cli/commands/streaming/attemptSetup.js +167 -0
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
- package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
- package/dist/cli/commands/streaming/goalSupervisor.js +130 -0
- package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
- package/dist/cli/commands/streaming/stallRecovery.js +105 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
- package/dist/cli/commands/streaming/streamLoop.js +448 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +16 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +80 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -1
- package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -4
- package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
- package/dist/cli/commands/streaming/toolResultState.js +29 -7
- package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -0
- package/dist/cli/commands/streaming.d.ts +65 -9
- package/dist/cli/commands/streaming.js +133 -430
- package/dist/cli/commands/wizardFlow.d.ts +334 -0
- package/dist/cli/commands/wizardFlow.js +377 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.js +68 -22
- package/dist/cli/terminalTitle.js +1 -1
- package/dist/config/contextFiles.js +9 -3
- package/dist/config/inputHistory.d.ts +0 -1
- package/dist/config/inputHistory.js +1 -1
- package/dist/config/modelDiscovery.d.ts +36 -0
- package/dist/config/modelDiscovery.js +164 -1
- package/dist/config/privateStorage.js +28 -2
- package/dist/config/providerAuth.d.ts +14 -0
- package/dist/config/providerAuth.js +49 -0
- package/dist/config/providerPresets.d.ts +39 -7
- package/dist/config/providerPresets.js +371 -100
- package/dist/config/providers.js +2 -0
- package/dist/config/settings.d.ts +43 -0
- package/dist/config/settings.js +12 -0
- package/dist/config/skillSettings.js +4 -4
- package/dist/config/updateCheck.d.ts +0 -1
- package/dist/config/updateCheck.js +1 -1
- package/dist/core/agent/budgets.d.ts +73 -1
- package/dist/core/agent/budgets.js +94 -1
- package/dist/core/agent/compaction.d.ts +38 -0
- package/dist/core/agent/compaction.js +92 -17
- package/dist/core/agent/completionController.d.ts +224 -0
- package/dist/core/agent/completionController.js +296 -0
- package/dist/core/agent/contextBudget.d.ts +36 -2
- package/dist/core/agent/contextBudget.js +62 -9
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +78 -0
- package/dist/core/agent/goalPolicy.d.ts +47 -0
- package/dist/core/agent/goalPolicy.js +106 -0
- package/dist/core/agent/reasoningPolicy.d.ts +31 -0
- package/dist/core/agent/reasoningPolicy.js +27 -0
- package/dist/core/agent/requestAssembly.d.ts +2 -2
- package/dist/core/agent/requestAssembly.js +16 -4
- package/dist/core/agent/toolCapabilities.d.ts +27 -0
- package/dist/core/agent/toolCapabilities.js +58 -0
- package/dist/core/agent/toolOutputStore.d.ts +8 -0
- package/dist/core/agent/toolOutputStore.js +11 -11
- package/dist/core/agent/toolResults.d.ts +12 -0
- package/dist/core/agent/toolResults.js +38 -0
- package/dist/core/agent/turnPolicy.d.ts +11 -0
- package/dist/core/agent/turnPolicy.js +19 -0
- package/dist/core/agent/workState.d.ts +81 -3
- package/dist/core/agent/workState.js +176 -10
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +27 -0
- package/dist/core/deadline.js +74 -0
- package/dist/core/io/boundedRead.js +1 -1
- package/dist/core/limits.d.ts +51 -0
- package/dist/core/limits.js +51 -0
- package/dist/core/log/llmLog.js +8 -1
- package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
- package/dist/core/persistence/orderedFileWriter.js +16 -2
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +15 -10
- package/dist/core/process/runBoundedProcess.d.ts +8 -2
- package/dist/core/process/runBoundedProcess.js +15 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/missingExecutable.d.ts +42 -0
- package/dist/core/safety/missingExecutable.js +77 -0
- package/dist/core/safety/shellClassifier.d.ts +11 -0
- package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
- package/dist/core/safety/urlGuard.d.ts +1 -1
- package/dist/core/session/sessionSlimming.d.ts +0 -3
- package/dist/core/session/sessionSlimming.js +2 -3
- package/dist/core/session/sessionStore.d.ts +38 -0
- package/dist/core/session/sessionStore.js +242 -59
- package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
- package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
- package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
- package/dist/core/shellOutput/registry.d.ts +2 -0
- package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
- package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
- package/dist/core/subagent/contracts.d.ts +6 -14
- package/dist/core/subagent/contracts.js +4 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentCoordinator.d.ts +4 -0
- package/dist/core/subagent/subagentCoordinator.js +32 -2
- package/dist/core/subagent/subagentRunner.js +19 -40
- package/dist/core/toolOutput/reduction.d.ts +0 -12
- package/dist/core/toolOutput/reduction.js +1 -1
- package/dist/core/validation/outputParser.d.ts +2 -2
- package/dist/llm/client.d.ts +17 -1
- package/dist/llm/client.js +86 -14
- package/dist/llm/hazeTools.d.ts +693 -204
- package/dist/llm/hazeTools.js +110 -28
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp/client.d.ts +45 -0
- package/dist/llm/lsp/client.js +195 -0
- package/dist/llm/lsp/pool.d.ts +23 -0
- package/dist/llm/lsp/pool.js +86 -0
- package/dist/llm/lsp/protocol.d.ts +64 -0
- package/dist/llm/lsp/protocol.js +128 -0
- package/dist/llm/lsp/requests.d.ts +94 -0
- package/dist/llm/lsp/requests.js +119 -0
- package/dist/llm/lspTools.d.ts +5653 -33
- package/dist/llm/lspTools.js +152 -80
- package/dist/llm/openaiCodex.d.ts +1 -0
- package/dist/llm/openaiCodex.js +43 -0
- package/dist/llm/openaiCodexOAuth.d.ts +51 -0
- package/dist/llm/openaiCodexOAuth.js +217 -0
- package/dist/llm/requestContext.d.ts +7 -0
- package/dist/llm/requestContext.js +30 -4
- package/dist/llm/systemPrompt.d.ts +12 -0
- package/dist/llm/systemPrompt.js +24 -11
- package/dist/llm/toolResultTypes.d.ts +7 -14
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +14 -9
- package/dist/llm/tools/editMatch.js +73 -1
- package/dist/llm/tools/failures.d.ts +2 -0
- package/dist/llm/tools/failures.js +1 -0
- package/dist/llm/tools/fetchTool.d.ts +16 -0
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +8 -5
- package/dist/llm/tools/fileToolShared.js +22 -23
- package/dist/llm/tools/gitIgnore.d.ts +42 -0
- package/dist/llm/tools/gitIgnore.js +247 -0
- package/dist/llm/tools/grepParse.d.ts +2 -1
- package/dist/llm/tools/grepRunner.d.ts +1 -1
- package/dist/llm/tools/grepRunner.js +2 -2
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -3
- package/dist/llm/tools/processTool.d.ts +16 -16
- package/dist/llm/tools/processTool.js +1 -1
- package/dist/llm/tools/readRecovery.d.ts +8 -0
- package/dist/llm/tools/readRecovery.js +135 -0
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +171 -123
- package/dist/llm/tools/{bashTool.js → shellTool.js} +20 -14
- package/dist/llm/tools/toolContext.d.ts +1 -1
- package/dist/llm/tools/toolContext.js +66 -37
- package/dist/llm/tools/workspaceFile.d.ts +0 -1
- package/dist/llm/tools/workspaceFile.js +1 -6
- package/dist/llm/webFetch.d.ts +18 -1
- package/dist/llm/webFetch.js +64 -97
- package/dist/skills/SkillLoader.d.ts +1 -11
- package/dist/skills/SkillLoader.js +1 -2
- package/dist/skills/types.d.ts +2 -1
- package/dist/ui/codeHighlight.d.ts +4 -0
- package/dist/ui/codeHighlight.js +31 -0
- package/dist/ui/components/Header.d.ts +1 -1
- package/dist/ui/components/MarkdownText.d.ts +16 -2
- package/dist/ui/components/MarkdownText.js +244 -34
- package/dist/ui/components/TextInput.d.ts +8 -1
- package/dist/ui/components/TextInput.js +6 -2
- package/dist/ui/theme.d.ts +4 -3
- package/dist/ui/theme.js +5 -4
- package/dist/utils/buildInfo.d.ts +97 -0
- package/dist/utils/buildInfo.js +244 -0
- package/dist/utils/fs.d.ts +11 -0
- package/dist/utils/fs.js +91 -26
- package/dist/utils/openPath.d.ts +2 -2
- package/dist/utils/openPath.js +19 -6
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +6 -2
- package/dist/utils/utf8.d.ts +22 -0
- package/dist/utils/utf8.js +54 -0
- package/dist/utils/version.d.ts +9 -3
- package/dist/utils/version.js +28 -2
- package/package.json +28 -21
- package/dist/cli/commands/lspWizard.d.ts +0 -14
- package/dist/cli/commands/lspWizard.js +0 -44
- package/dist/cli/commands/mcpWizard.d.ts +0 -15
- package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
- package/dist/cli/commands/skillConfirmRemove.js +0 -20
- package/dist/cli/commands/skillCreation.d.ts +0 -12
- package/dist/cli/commands/skillCreation.js +0 -14
- package/dist/cli/commands/skillWizard.d.ts +0 -17
- package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
- package/dist/cli/commands/streaming/idleTimer.js +0 -24
- package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -10
- package/dist/cli/commands/streaming/turnOutcome.js +0 -13
- package/dist/cli/commands/wizardActions.d.ts +0 -46
- package/dist/cli/commands/wizardActions.js +0 -46
- package/dist/cli/commands/wizardInput.d.ts +0 -4
- package/dist/cli/commands/wizardInput.js +0 -19
- package/dist/cli/commands/wizardPrompts.d.ts +0 -22
- package/dist/cli/commands/wizardPrompts.js +0 -52
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -188
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/bashOutput/ansi.d.ts +0 -1
- package/dist/core/bashOutput/ansi.js +0 -7
- package/dist/core/bashOutput/registry.d.ts +0 -4
- package/dist/core/goal/completionPolicy.d.ts +0 -2
- package/dist/core/goal/completionPolicy.js +0 -7
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -18
- package/dist/core/goal/sessionGoal.d.ts +0 -8
- package/dist/core/goal/sessionGoal.js +0 -30
- package/dist/core/limits/byteBudgets.d.ts +0 -18
- package/dist/core/limits/byteBudgets.js +0 -18
- package/dist/core/limits/textBudgets.d.ts +0 -23
- package/dist/core/limits/textBudgets.js +0 -23
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -129
- package/dist/llm/lsp.js +0 -307
- package/dist/ui/components/ErrorView.d.ts +0 -4
- package/dist/ui/components/ErrorView.js +0 -7
- package/dist/utils/yaml.d.ts +0 -2
- package/dist/utils/yaml.js +0 -8
- package/examples/skills/files/SKILL.md +0 -16
- package/examples/skills/files/examples/file-editing.md +0 -3
- /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
interface ChatOptions {
|
|
2
2
|
debug?: boolean;
|
|
3
3
|
version?: string;
|
|
4
|
+
/** Safe build provenance (commit, build time) recorded into session headers. */
|
|
5
|
+
build?: {
|
|
6
|
+
commit?: string;
|
|
7
|
+
builtAt?: string;
|
|
8
|
+
};
|
|
4
9
|
continueSession?: boolean;
|
|
5
10
|
resumeSessionId?: string;
|
|
6
11
|
noSession?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useEffect, useReducer, useRef, useState } from 'react';
|
|
3
3
|
import { execFile as execFileCallback } from 'node:child_process';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
|
-
import { Box, render, Static, Text, useApp,
|
|
5
|
+
import { Box, render, Static, Text, useApp, useWindowSize } from 'ink';
|
|
6
6
|
import Spinner from 'ink-spinner';
|
|
7
7
|
import { readContextFiles } from '../../config/contextFiles.js';
|
|
8
8
|
import { checkForUpdate } from '../../config/updateCheck.js';
|
|
@@ -15,7 +15,7 @@ import { Header } from '../../ui/components/Header.js';
|
|
|
15
15
|
import { TextInput } from '../../ui/components/TextInput.js';
|
|
16
16
|
import { theme } from '../../ui/theme.js';
|
|
17
17
|
import { handleSlashCommand } from './commands.js';
|
|
18
|
-
import {
|
|
18
|
+
import { runAgentGoal } from './streaming/goalSupervisor.js';
|
|
19
19
|
import { formatElapsedTimeWhole, imageAttachmentLine } from './formatters.js';
|
|
20
20
|
import { imageCapabilityError, IMAGE_ONLY_PROMPT_TEXT, resolveImageAttachments } from '../../core/attachments/imageAttachments.js';
|
|
21
21
|
import { resolveReadBlessings } from '../../core/attachments/readBlessings.js';
|
|
@@ -23,12 +23,12 @@ import { endLog as endLlmLog } from '../../core/log/llmLog.js';
|
|
|
23
23
|
import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
|
|
24
24
|
import { formatSession, listSessions } from '../../core/session/sessionStore.js';
|
|
25
25
|
import { MAX_VISIBLE_TASKS, TaskBar } from '../chat/TaskBar.js';
|
|
26
|
-
import {
|
|
26
|
+
import { AssistantMarkdownChunkView, MessageView, partitionDisplayMessages } from '../chat/messages.js';
|
|
27
27
|
import { createSessionRecorder } from '../chat/sessionRecorder.js';
|
|
28
28
|
import { createSessionLifecycle } from '../chat/sessionLifecycle.js';
|
|
29
|
-
import { createWizardDispatch } from '../chat/wizardDispatch.js';
|
|
29
|
+
import { createWizardDispatch, initialWizardUiState, wizardUiReducer } from '../chat/wizardDispatch.js';
|
|
30
30
|
import { buildContextReport } from '../chat/contextReport.js';
|
|
31
|
-
import { startupContextInfo,
|
|
31
|
+
import { startupContextInfo, startupProviderInfo } from '../chat/startupInfo.js';
|
|
32
32
|
import { TIPS, randomTipIndex, tipsEnabled } from '../chat/tips.js';
|
|
33
33
|
import { fileMentionSuggestions } from '../chat/fileMentionSuggestions.js';
|
|
34
34
|
import { compactHomePath, formatTokenCount, statusBarMetrics } from '../chat/chatMetrics.js';
|
|
@@ -36,8 +36,8 @@ import { accumulateTokenUsage, EMPTY_TOKEN_USAGE, shouldClearCompletedTasks } fr
|
|
|
36
36
|
import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES, placeholderForMode } from './chatModes.js';
|
|
37
37
|
import { inputSuggestionsForState } from '../chat/inputSuggestions.js';
|
|
38
38
|
import { modelThinkingLabel } from '../../utils/modelName.js';
|
|
39
|
-
import {
|
|
40
|
-
import { commandParts } from './
|
|
39
|
+
import { detectCheckoutMismatch, formatMismatchWarning, runtimeCapabilities } from '../../utils/buildInfo.js';
|
|
40
|
+
import { commandParts } from './wizardFlow.js';
|
|
41
41
|
import { backgroundProcessCount, subscribeBackgroundProcesses, teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
|
|
42
42
|
import { MAX_SESSION_PICKER_RESULTS } from './sessionPicker.js';
|
|
43
43
|
const execFile = promisify(execFileCallback);
|
|
@@ -60,10 +60,19 @@ function busyElapsedLabel(startedAt) {
|
|
|
60
60
|
function thinkingLabelForSettings(settings) {
|
|
61
61
|
return modelThinkingLabel(activeModel(settings)?.model);
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Busy indicator isolated in its own component. The Spinner animates on its own
|
|
65
|
+
* internal state (~10 fps) which triggers re-renders inside this subtree; keeping
|
|
66
|
+
* the spinner out of ChatScreen's render scope means those ticks don't propagate
|
|
67
|
+
* to the transcript tree above (where React.memo on MessageView already prevents
|
|
68
|
+
* deep re-renders, but avoiding the reconciliation walk entirely is still cheaper).
|
|
69
|
+
*/
|
|
70
|
+
function BusyBar({ label, elapsed, tip }) {
|
|
71
|
+
return _jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(Box, { children: _jsxs(Text, { children: [_jsxs(Text, { color: theme.command, bold: true, children: [_jsx(Spinner, { type: "dots" }), " ", label, elapsed ? _jsxs(Text, { color: theme.muted, children: [" \u00B7 ", elapsed] }) : null] }), _jsx(Text, { color: theme.muted, children: " \u00B7 type to queue follow-up \u00B7 esc to interrupt" })] }) }), tip && (_jsx(Box, { children: _jsxs(Text, { color: theme.muted, children: [_jsx(Text, { bold: true, children: "Tip:" }), " ", tip] }) }))] });
|
|
72
|
+
}
|
|
73
|
+
function ChatScreen({ debug = false, version, build, continueSession = false, resumeSessionId, noSession = false }) {
|
|
64
74
|
const { exit } = useApp();
|
|
65
|
-
const {
|
|
66
|
-
const width = stdout.columns ?? process.stdout.columns ?? 80;
|
|
75
|
+
const { columns: width, rows: terminalRows } = useWindowSize();
|
|
67
76
|
const nextDisplayOrderRef = useRef(1);
|
|
68
77
|
const withDisplayOrder = (message) => {
|
|
69
78
|
if (message.displayOrder != null)
|
|
@@ -71,9 +80,7 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
71
80
|
return { ...message, displayOrder: nextDisplayOrderRef.current++ };
|
|
72
81
|
};
|
|
73
82
|
const withDisplayOrders = (next) => next.map(withDisplayOrder);
|
|
74
|
-
const [messages, setMessagesRaw] = useState([
|
|
75
|
-
{ role: 'system', text: 'Welcome to haze. Use /help for commands.', displayOrder: 0 }
|
|
76
|
-
]);
|
|
83
|
+
const [messages, setMessagesRaw] = useState([]);
|
|
77
84
|
const setMessages = (updater) => {
|
|
78
85
|
setMessagesRaw(previous => withDisplayOrders(typeof updater === 'function' ? updater(previous) : updater));
|
|
79
86
|
};
|
|
@@ -96,6 +103,11 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
96
103
|
if (!sessionRecorderRef.current)
|
|
97
104
|
sessionRecorderRef.current = createSessionRecorder(() => sessionRef.current);
|
|
98
105
|
const sessionStartRef = useRef(new Date());
|
|
106
|
+
// Stable PromptSession object across turns so per-session flags (the
|
|
107
|
+
// context-fallback warning key) persist; rebuilt when a new session starts,
|
|
108
|
+
// detected by sessionStartRef identity (the lifecycle controller replaces
|
|
109
|
+
// the Date on new/resume/continue).
|
|
110
|
+
const promptSessionRef = useRef({ identity: undefined, value: { cwd: process.cwd() } });
|
|
99
111
|
const workStateRef = useRef(undefined);
|
|
100
112
|
const llmLogRef = useRef(undefined);
|
|
101
113
|
const persistenceWarningShownRef = useRef(false);
|
|
@@ -108,7 +120,6 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
108
120
|
const [contextFiles, setContextFiles] = useState([]);
|
|
109
121
|
const [mode, setMode] = useState('chat');
|
|
110
122
|
const [sessions, setSessions] = useState([]);
|
|
111
|
-
const [selectedSessionId, setSelectedSessionId] = useState();
|
|
112
123
|
const [busy, setBusy] = useState(false);
|
|
113
124
|
const [backgroundCount, setBackgroundCount] = useState(backgroundProcessCount);
|
|
114
125
|
const [busyLabel, setBusyLabel] = useState(() => thinkingLabelForSettings(settings));
|
|
@@ -122,19 +133,17 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
122
133
|
const [taskBarPadding, setTaskBarPadding] = useState(0);
|
|
123
134
|
const [tokenUsage, setTokenUsage] = useState({ ...EMPTY_TOKEN_USAGE });
|
|
124
135
|
const [queuedFollowUps, setQueuedFollowUps] = useState([]);
|
|
136
|
+
// A genuinely paused goal (no measurable progress, deadline, or a stalled
|
|
137
|
+
// model stream) — automatic continuation has already been attempted by the
|
|
138
|
+
// goal supervisor. Carries what a one-key resume needs; any new submission
|
|
139
|
+
// clears it.
|
|
140
|
+
const [pausedResume, setPausedResume] = useState(undefined);
|
|
125
141
|
const [skills, setSkills] = useState([]);
|
|
126
142
|
const [branchName, setBranchName] = useState();
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const [
|
|
130
|
-
const
|
|
131
|
-
const [providerDraft, setProviderDraft] = useState({});
|
|
132
|
-
const [skillDraft, setSkillDraft] = useState({});
|
|
133
|
-
const [selectedSkillName, setSelectedSkillName] = useState();
|
|
134
|
-
const [selectedLspName, setSelectedLspName] = useState();
|
|
135
|
-
const [lspDraft, setLspDraft] = useState({});
|
|
136
|
-
const [selectedMcpName, setSelectedMcpName] = useState();
|
|
137
|
-
const [mcpDraft, setMcpDraft] = useState({});
|
|
143
|
+
// Wizard flow state (selection, drafts, model discovery) in one reducer;
|
|
144
|
+
// this replaced twelve individual useState hooks.
|
|
145
|
+
const [wizardState, updateWizard] = useReducer(wizardUiReducer, undefined, initialWizardUiState);
|
|
146
|
+
const { modelProviderFilter, discoveredModels, suggestedModels, selectedProviderName, providerDraft, selectedSkillName, selectedLspName, selectedMcpName } = wizardState;
|
|
138
147
|
// Wrap setBusy so the busy indicator knows when the turn started, and tick a
|
|
139
148
|
// heartbeat every second while busy so elapsed time keeps rolling. This keeps
|
|
140
149
|
// the UI visibly alive during long model thinking / blocked tool runs where
|
|
@@ -173,11 +182,12 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
173
182
|
currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
|
|
174
183
|
}, [busy]);
|
|
175
184
|
useEffect(() => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
void (async () => {
|
|
186
|
+
const [settingsResult, branch, files] = await Promise.all([
|
|
187
|
+
readSettings().then(value => ({ value, error: undefined })).catch(error => ({ value: {}, error: error instanceof Error ? error.message : String(error) })),
|
|
188
|
+
currentBranchName().catch(() => undefined),
|
|
189
|
+
readContextFiles().catch(() => []),
|
|
190
|
+
]);
|
|
181
191
|
const next = settingsResult.value;
|
|
182
192
|
setSettings(next);
|
|
183
193
|
setSettingsError(settingsResult.error);
|
|
@@ -185,23 +195,29 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
185
195
|
setContextFiles(files);
|
|
186
196
|
contextFileSignaturesRef.current = new Map(files.flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
187
197
|
setMessages(m => [...m, { role: 'system', text: settingsResult.error ? settingsResult.error : `${startupProviderInfo(next)}\n\n${startupContextInfo(files)}` }]);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
|
|
196
|
-
if (version) {
|
|
197
|
-
checkForUpdate({ currentVersion: version, packageName: '@denizokcu/haze' })
|
|
198
|
-
.then(result => {
|
|
198
|
+
await sessionLifecycle.initializeSession().catch(error => {
|
|
199
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
200
|
+
setMessages(m => [...m, { role: 'system', text: `Session disabled: ${text}` }]);
|
|
201
|
+
});
|
|
202
|
+
await refreshSkills().catch(() => undefined);
|
|
203
|
+
if (version) {
|
|
204
|
+
const result = await checkForUpdate({ currentVersion: version, packageName: '@denizokcu/haze' }).catch(() => undefined);
|
|
199
205
|
if (result?.isOutdated) {
|
|
200
206
|
setMessages(m => [...m, { role: 'system', text: `A new version of haze is available: ${result.latestVersion} (you have ${version}). Update with: npm i -g @denizokcu/haze` }]);
|
|
201
207
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
}
|
|
209
|
+
// Runtime/installation diagnostics: never switch runtimes silently, but
|
|
210
|
+
// make a stale binary serving a workspace with a newer checkout unmistakable.
|
|
211
|
+
const mismatch = detectCheckoutMismatch();
|
|
212
|
+
if (mismatch) {
|
|
213
|
+
setMessages(m => [...m, { role: 'system', text: formatMismatchWarning(mismatch) }]);
|
|
214
|
+
}
|
|
215
|
+
else if (!runtimeCapabilities().goalSupervisorAvailable) {
|
|
216
|
+
setMessages(m => [...m, { role: 'system', text: 'Warning: this haze build lacks the goal supervisor module; exhausting a turn step/tool budget may pause the goal instead of continuing automatically. Reinstall or relink haze (npm run dev:link in the checkout).' }]);
|
|
217
|
+
}
|
|
218
|
+
})().catch(() => undefined);
|
|
219
|
+
readInputHistory().then(setInputHistory).catch(() => undefined);
|
|
220
|
+
loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
|
|
205
221
|
const branchTimer = setInterval(() => {
|
|
206
222
|
currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
|
|
207
223
|
}, 15_000);
|
|
@@ -254,6 +270,7 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
254
270
|
// dedicated controller so this component stays orchestration glue (CR-006).
|
|
255
271
|
const sessionLifecycle = createSessionLifecycle({
|
|
256
272
|
version,
|
|
273
|
+
build,
|
|
257
274
|
continueSession,
|
|
258
275
|
resumeSessionId,
|
|
259
276
|
noSession,
|
|
@@ -270,15 +287,16 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
270
287
|
setMessages,
|
|
271
288
|
setLiveMessagesState,
|
|
272
289
|
setTokenUsage,
|
|
290
|
+
manualCompaction: () => settings.manualCompaction ?? 'llm-summary',
|
|
273
291
|
debugLog,
|
|
274
292
|
showPersistenceWarning,
|
|
275
293
|
});
|
|
276
|
-
const { clearConversation, compactConversation } = sessionLifecycle;
|
|
294
|
+
const { clearConversation, compactConversation, compactConversationWithModel } = sessionLifecycle;
|
|
277
295
|
async function openSessionPicker() {
|
|
278
296
|
await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
|
|
279
297
|
const next = await listSessions();
|
|
280
298
|
setSessions(next);
|
|
281
|
-
|
|
299
|
+
updateWizard({ type: 'set', key: 'selectedSessionId', value: undefined });
|
|
282
300
|
if (next.length === 0) {
|
|
283
301
|
setMessages(m => [...m, { role: 'system', text: 'No saved sessions found for this workspace.' }]);
|
|
284
302
|
setMode('chat');
|
|
@@ -311,18 +329,7 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
311
329
|
if (mode !== 'chat') {
|
|
312
330
|
setMode('chat');
|
|
313
331
|
setSessions([]);
|
|
314
|
-
|
|
315
|
-
setModelProviderFilter(undefined);
|
|
316
|
-
setDiscoveredModels([]);
|
|
317
|
-
setSuggestedModels([]);
|
|
318
|
-
setSelectedProviderName(undefined);
|
|
319
|
-
setProviderDraft({});
|
|
320
|
-
setSkillDraft({});
|
|
321
|
-
setSelectedSkillName(undefined);
|
|
322
|
-
setSelectedLspName(undefined);
|
|
323
|
-
setLspDraft({});
|
|
324
|
-
setSelectedMcpName(undefined);
|
|
325
|
-
setMcpDraft({});
|
|
332
|
+
updateWizard({ type: 'reset' });
|
|
326
333
|
}
|
|
327
334
|
}
|
|
328
335
|
function showWizardMessage(message) {
|
|
@@ -333,15 +340,12 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
333
340
|
// shared settings-patch applier (CR-006). Rebuilt every render so handlers
|
|
334
341
|
// see current state without new React state.
|
|
335
342
|
const wizard = createWizardDispatch({
|
|
336
|
-
settings, skills,
|
|
337
|
-
|
|
338
|
-
providerDraft, lspDraft, mcpDraft, skillDraft,
|
|
343
|
+
settings, skills, sessions,
|
|
344
|
+
wizard: wizardState, updateWizard,
|
|
339
345
|
setMode, setSettings,
|
|
340
|
-
|
|
346
|
+
showMessage: showWizardMessage, refreshSkills,
|
|
341
347
|
resumeSessionById: sessionLifecycle.resumeSessionById,
|
|
342
348
|
forkSessionById: sessionLifecycle.forkSessionById,
|
|
343
|
-
setModelProviderFilter, setProviderDraft, setSkillDraft, setLspDraft, setMcpDraft, setDiscoveredModels, setSuggestedModels,
|
|
344
|
-
showMessage: showWizardMessage, refreshSkills,
|
|
345
349
|
setBusyLabel, setBusy: setBusyWithHeartbeat,
|
|
346
350
|
idleBusyLabel: thinkingLabelForSettings(settings),
|
|
347
351
|
});
|
|
@@ -366,41 +370,9 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
366
370
|
queueFollowUp(value);
|
|
367
371
|
return;
|
|
368
372
|
}
|
|
369
|
-
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
if (effect.type === 'message')
|
|
373
|
-
showWizardMessage(effect.text);
|
|
374
|
-
else if (effect.type === 'mode')
|
|
375
|
-
setMode(effect.mode);
|
|
376
|
-
else if (effect.type === 'provider-draft') {
|
|
377
|
-
if (effect.replace)
|
|
378
|
-
setProviderDraft(effect.patch);
|
|
379
|
-
else
|
|
380
|
-
setProviderDraft(draft => ({ ...draft, ...effect.patch }));
|
|
381
|
-
}
|
|
382
|
-
else if (effect.type === 'discover-provider-models') {
|
|
383
|
-
// The draft patch above is still pending React state, so discovery
|
|
384
|
-
// receives the merged draft explicitly (same pattern as MCP stdio).
|
|
385
|
-
await wizard.discoverProviderModelsForDraft(effect.draft);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
const mcpEffects = transitionMcpField({ mode, value, settings, draft: mcpDraft });
|
|
391
|
-
if (mcpEffects) {
|
|
392
|
-
for (const effect of mcpEffects) {
|
|
393
|
-
if (effect.type === 'message')
|
|
394
|
-
showWizardMessage(effect.text);
|
|
395
|
-
else if (effect.type === 'mode')
|
|
396
|
-
setMode(effect.mode);
|
|
397
|
-
else if (effect.type === 'mcp-draft')
|
|
398
|
-
setMcpDraft(draft => ({ ...draft, ...effect.patch }));
|
|
399
|
-
else if (effect.type === 'finish-mcp-stdio')
|
|
400
|
-
await wizard.finishMcpCustom(undefined, effect.draft);
|
|
401
|
-
}
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
373
|
+
// Any new submission supersedes a paused-task resume affordance.
|
|
374
|
+
if (pausedResume)
|
|
375
|
+
setPausedResume(undefined);
|
|
404
376
|
if (await wizard.dispatch(mode, value))
|
|
405
377
|
return;
|
|
406
378
|
const invokedSkill = skillInvocation(value);
|
|
@@ -413,7 +385,7 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
413
385
|
settings,
|
|
414
386
|
contextFiles,
|
|
415
387
|
setMode,
|
|
416
|
-
setModelProviderFilter,
|
|
388
|
+
setModelProviderFilter: (filter) => updateWizard({ type: 'set', key: 'modelProviderFilter', value: filter }),
|
|
417
389
|
addSystemMessage: text => setMessages(m => [...m, { role: 'system', text }]),
|
|
418
390
|
clearConversation,
|
|
419
391
|
newSession: async () => {
|
|
@@ -421,7 +393,7 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
421
393
|
lastAssistantTextRef.current = '';
|
|
422
394
|
setLiveMessagesState(() => []);
|
|
423
395
|
setMessages([{ role: 'system', text: 'Started fresh. The fog parts.' }]);
|
|
424
|
-
await sessionLifecycle.startNewSession('
|
|
396
|
+
await sessionLifecycle.startNewSession('New session started.');
|
|
425
397
|
},
|
|
426
398
|
resumeSession: noSession ? undefined : async (id) => {
|
|
427
399
|
if (id)
|
|
@@ -431,6 +403,7 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
431
403
|
},
|
|
432
404
|
sessionInfo: () => sessionRef.current ? formatSession(sessionRef.current) : 'Session persistence is off.',
|
|
433
405
|
compactConversation,
|
|
406
|
+
compactConversationLlm: compactConversationWithModel,
|
|
434
407
|
runAgentTurn: (prompt, displayValue, options) => doAgentTurn(prompt, displayValue, options),
|
|
435
408
|
refreshContextFiles: async () => {
|
|
436
409
|
const files = await readContextFiles().catch(() => contextFiles);
|
|
@@ -526,7 +499,42 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
526
499
|
await runSingleAgentTurn(preparedFollowUp.value, preparedFollowUp.displayValue, preparedFollowUp.options);
|
|
527
500
|
}
|
|
528
501
|
}
|
|
529
|
-
|
|
502
|
+
/**
|
|
503
|
+
* Resume a paused turn against the preserved conversation (no re-added user
|
|
504
|
+
* message). An idle-stall resume continues the same logical turn's bounded
|
|
505
|
+
* retry pool; an incomplete-goal resume starts a fresh logical turn (its
|
|
506
|
+
* budget was exhausted) nudged to pick up the remaining concrete work.
|
|
507
|
+
*/
|
|
508
|
+
/**
|
|
509
|
+
* Explicitly resume a genuinely paused goal (automatic continuation already
|
|
510
|
+
* ran): an idle-stall resume continues the bounded retry pool; an
|
|
511
|
+
* incomplete-goal resume restarts the supervisor from the stored checkpoint.
|
|
512
|
+
* Both ride the preserved conversation — no completed mutations are replayed.
|
|
513
|
+
*/
|
|
514
|
+
async function resumePausedTask() {
|
|
515
|
+
const resume = pausedResume;
|
|
516
|
+
if (!resume || busy)
|
|
517
|
+
return;
|
|
518
|
+
setPausedResume(undefined);
|
|
519
|
+
setMessages(m => [...m, { role: 'system', text: 'Resuming the unfinished goal; completed work is preserved in the conversation.' }]);
|
|
520
|
+
const resumeFrom = resume.kind === 'incomplete-goal' && resume.checkpoint
|
|
521
|
+
? { kind: 'incomplete-goal', checkpoint: resume.checkpoint }
|
|
522
|
+
: { kind: 'model-stream-idle', retryAttempt: resume.retryAttempt };
|
|
523
|
+
await runSingleAgentTurn(resume.request, undefined, {}, resumeFrom);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* The PromptSession shared by every turn of the active session. Returning a
|
|
527
|
+
* stable object (not a fresh literal per turn) is what makes once-per-session
|
|
528
|
+
* affordances actually once-per-session; a new session identity yields a
|
|
529
|
+
* fresh object so they fire again at its start.
|
|
530
|
+
*/
|
|
531
|
+
function currentPromptSession() {
|
|
532
|
+
if (promptSessionRef.current.identity !== sessionStartRef.current) {
|
|
533
|
+
promptSessionRef.current = { identity: sessionStartRef.current, value: { start: sessionStartRef.current, cwd: process.cwd() } };
|
|
534
|
+
}
|
|
535
|
+
return promptSessionRef.current.value;
|
|
536
|
+
}
|
|
537
|
+
async function runSingleAgentTurn(value, displayValue, turnOptions = {}, resumeExisting) {
|
|
530
538
|
const sessionRecorder = sessionRecorderRef.current;
|
|
531
539
|
const finalizeMessage = (msg) => {
|
|
532
540
|
if (msg.hidden)
|
|
@@ -535,91 +543,124 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
535
543
|
setMessages(m => [...m, ordered]);
|
|
536
544
|
sessionRecorder.recordUiMessage(ordered);
|
|
537
545
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
setLiveMessagesState(m => m.filter(msg => msg.id !== id));
|
|
553
|
-
finalizeMessage(updated);
|
|
546
|
+
// The logical-goal supervisor owns this submission: recoverable-incomplete
|
|
547
|
+
// physical turns (including step/tool budget boundaries) continue
|
|
548
|
+
// automatically; per-turn limits stay safety boundaries. An explicit
|
|
549
|
+
// resumeFrom restarts a genuinely paused goal from its checkpoint/pool.
|
|
550
|
+
const goalResult = await runAgentGoal({
|
|
551
|
+
request: value,
|
|
552
|
+
displayValue,
|
|
553
|
+
contextFiles,
|
|
554
|
+
session: currentPromptSession(),
|
|
555
|
+
callbacks: {
|
|
556
|
+
addMessage: msg => {
|
|
557
|
+
const ordered = withDisplayOrder(msg);
|
|
558
|
+
if (ordered.streaming) {
|
|
559
|
+
setLiveMessagesState(m => [...m, ordered]);
|
|
554
560
|
return;
|
|
555
561
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
562
|
+
finalizeMessage(ordered);
|
|
563
|
+
},
|
|
564
|
+
updateMessage: (id, update) => {
|
|
565
|
+
const liveMessage = liveMessagesRef.current.find(msg => msg.id === id);
|
|
566
|
+
if (liveMessage) {
|
|
567
|
+
const updated = { ...liveMessage, ...update };
|
|
568
|
+
if (updated.streaming === false) {
|
|
569
|
+
setLiveMessagesState(m => m.filter(msg => msg.id !== id));
|
|
570
|
+
finalizeMessage(updated);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
setLiveMessagesState(m => m.map(msg => msg.id === id ? { ...msg, ...update } : msg));
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
setMessages(m => m.map(msg => msg.id === id ? { ...msg, ...update } : msg));
|
|
577
|
+
},
|
|
578
|
+
setConversation: msgs => {
|
|
579
|
+
conversationRef.current = msgs;
|
|
580
|
+
sessionRecorder.recordConversation(msgs);
|
|
581
|
+
},
|
|
582
|
+
setBusy: setBusyWithHeartbeat,
|
|
583
|
+
setBusyLabel,
|
|
584
|
+
debugLog,
|
|
585
|
+
getConversation: () => conversationRef.current,
|
|
586
|
+
getLastAssistantText: () => lastAssistantTextRef.current,
|
|
587
|
+
setLastAssistantText: text => { lastAssistantTextRef.current = text; },
|
|
588
|
+
setAbortController: controller => { abortControllerRef.current = controller; },
|
|
589
|
+
setWorkState: state => {
|
|
590
|
+
workStateRef.current = state;
|
|
591
|
+
sessionRecorder.recordWorkState(state);
|
|
592
|
+
},
|
|
593
|
+
compactConversation,
|
|
594
|
+
recordTokenUsage: usage => {
|
|
595
|
+
setTokenUsage(current => accumulateTokenUsage(current, usage));
|
|
596
|
+
},
|
|
597
|
+
onEvent: event => {
|
|
598
|
+
sessionRecorder.recordEvent(event);
|
|
599
|
+
},
|
|
600
|
+
onTasksChanged: () => { loadTasksFromStore().then(t => { setVisibleTasks(t); setTaskBarPadding(0); }).catch(() => undefined); },
|
|
601
|
+
contextFileSignatures: contextFileSignaturesRef.current,
|
|
602
|
+
log: llmLogRef.current,
|
|
582
603
|
},
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}, 0, false, false, { start: sessionStartRef.current, cwd: process.cwd() }, undefined, turnOptions);
|
|
604
|
+
...(resumeExisting ? { resumeFrom: resumeExisting } : {}),
|
|
605
|
+
...(turnOptions.attachments || turnOptions.blessedPaths || turnOptions.ephemeralControl || turnOptions.subagentOverrides ? { turnOptions } : {})
|
|
606
|
+
});
|
|
587
607
|
await sessionRecorder.flush().catch(showPersistenceWarning);
|
|
588
608
|
await llmLogRef.current?.writer?.flush().catch(showPersistenceWarning);
|
|
609
|
+
// Only a genuinely paused goal (supervisor already attempted automatic
|
|
610
|
+
// continuation) exposes the one-key resume affordance; it stays until the
|
|
611
|
+
// user submits something else.
|
|
612
|
+
if (goalResult.resume?.kind === 'model-stream-idle')
|
|
613
|
+
setPausedResume({ kind: 'model-stream-idle', request: goalResult.resume.request, retryAttempt: goalResult.resume.retryAttempt });
|
|
614
|
+
else if (goalResult.resume?.kind === 'incomplete-goal')
|
|
615
|
+
setPausedResume({ kind: 'incomplete-goal', request: goalResult.resume.checkpoint.request, retryAttempt: 0, checkpoint: goalResult.resume.checkpoint });
|
|
616
|
+
else
|
|
617
|
+
setPausedResume(undefined);
|
|
618
|
+
return goalResult;
|
|
589
619
|
}
|
|
590
620
|
const visible = messages.filter(message => !message.hidden);
|
|
591
621
|
const activeLiveMessages = liveMessages.filter(message => !message.hidden);
|
|
592
|
-
const
|
|
593
|
-
const transcriptItems = orderedVisibleMessages.filter(message => !message.streaming).map((message, index) => ({ key: messageKey(message, index), message }));
|
|
594
|
-
const streamingItems = orderedVisibleMessages.filter(message => message.streaming);
|
|
622
|
+
const { staticItems: staticTranscriptItems, streamingItems } = partitionDisplayMessages([...visible, ...activeLiveMessages]);
|
|
595
623
|
const activeSelection = activeModel(settings);
|
|
596
624
|
const placeholder = placeholderForMode(mode, busy);
|
|
597
625
|
const activeModelName = activeSelection ? `${activeSelection.provider.name}:${activeSelection.model}` : 'unconfigured';
|
|
598
|
-
const headerSubtitle = [
|
|
599
|
-
'A minimal LLM harness for growing your own workflows while you work.',
|
|
600
|
-
'',
|
|
601
|
-
'Start with simple chat, then teach haze your habits with skills:',
|
|
602
|
-
'/skills — add, enable/disable, validate, or remove Markdown skills.',
|
|
603
|
-
'',
|
|
604
|
-
startupInputTips(),
|
|
605
|
-
'',
|
|
606
|
-
'The most adaptive workflow is the one you shape as you go.',
|
|
607
|
-
'',
|
|
608
|
-
'Guardrails are light: haze lets the LLM work from the terminal almost like you,',
|
|
609
|
-
'while trying to stay scoped to this project.',
|
|
610
|
-
].join('\n');
|
|
626
|
+
const headerSubtitle = (_jsxs(Text, { children: ['A minimal coding agent for your terminal.\n\nStart with chat. Turn repeated work into Markdown skills:\n', _jsx(Text, { color: theme.command, children: "/skills" }), ' — create, enable, disable, validate, or remove skills.\n\nType ', _jsx(Text, { color: theme.command, children: "@" }), ' to browse workspace files. To grant read-only access to a file or directory outside the workspace for this turn, mention a path containing ', _jsx(Text, { color: theme.command, children: "/" }), ' (for example, ', _jsx(Text, { color: theme.command, children: "@../shared/file.ts" }), ' or ', _jsx(Text, { color: theme.command, children: "/tmp/reference.md" }), ').\n\nImage mentions require a vision-capable model. File edits and writes stay inside the workspace.\n\nhaze runs tool calls without confirmation gates. Supervise consequential work as you would any shell session.\n\nShape haze around your workflow as you go.\n\nUse ', _jsx(Text, { color: theme.command, children: "/help" }), ' for commands.'] }));
|
|
611
627
|
const workspaceLabel = `${compactHomePath(process.cwd())}${branchName ? ` (${branchName})` : ''}`;
|
|
612
628
|
const enabledSkillCount = new Set(skills.filter(skill => isSkillEnabled(settings, skill.name, skill.source)).map(skill => skill.name)).size;
|
|
613
629
|
const metrics = statusBarMetrics({ messages: [...messages, ...liveMessages], tokenUsage, enabledSkillCount, backgroundProcessCount: backgroundCount });
|
|
614
630
|
const inputSuggestions = inputSuggestionsForState({ mode, settings, skills, sessions, selectedProviderName, modelProviderFilter, providerDraftName: providerDraft.name, discoveredModels, suggestedModels, selectedSkillName, selectedLspName, selectedMcpName });
|
|
615
631
|
const staticItems = [
|
|
616
|
-
{ kind: 'header', key:
|
|
617
|
-
...
|
|
632
|
+
{ kind: 'header', key: 'header', subtitle: headerSubtitle },
|
|
633
|
+
...staticTranscriptItems,
|
|
618
634
|
];
|
|
619
635
|
const busyElapsed = busyElapsedLabel(turnStartedAtRef.current);
|
|
620
|
-
|
|
636
|
+
const contentWidth = Math.max(1, width - 2);
|
|
637
|
+
// Live-region budget: once the dynamic frame exceeds the viewport, Ink falls
|
|
638
|
+
// back to clearTerminal + full transcript replay, which wipes scrollback and
|
|
639
|
+
// jumps to the top on every render. Every dynamic section is therefore
|
|
640
|
+
// clamped so the frame stays under one screen (see chat/liveRegion.ts).
|
|
641
|
+
const busyRows = busy ? (showingTip ? 2 : 1) : 0;
|
|
642
|
+
const queuedRows = queuedFollowUps.length > 0 ? 2 + queuedFollowUps.length : 0;
|
|
643
|
+
const collapsedTaskRows = Math.min(visibleTasks.length, MAX_VISIBLE_TASKS);
|
|
644
|
+
const expandedTaskCap = Math.max(MAX_VISIBLE_TASKS, terminalRows - 18);
|
|
645
|
+
const expandedTaskRows = Math.min(visibleTasks.length, expandedTaskCap) + (visibleTasks.length > expandedTaskCap ? 1 : 0);
|
|
646
|
+
const taskRows = visibleTasks.length > 0 ? 2 + taskBarPadding + (tasksExpanded ? expandedTaskRows : collapsedTaskRows) : 0;
|
|
647
|
+
// Debug-only panels are counted conservatively so debug mode cannot overflow either.
|
|
648
|
+
const debugPanelRows = debug && debugLogs.length > 0 ? 4 + debugLogs.length : 0;
|
|
649
|
+
const tokenPanelRows = debug && metrics.hasTokenBreakdown ? 5 : 0;
|
|
650
|
+
// The input box is border (2) + one row; a user-pasted multiline draft can
|
|
651
|
+
// exceed this estimate (accepted: it is transient, user-driven editing state).
|
|
652
|
+
const fixedLiveRows = busyRows + queuedRows + taskRows + debugPanelRows + tokenPanelRows + 3 /* input */ + 2 /* status */ + 2 /* safety */;
|
|
653
|
+
const streamingRowsBudget = Math.max(1, terminalRows - fixedLiveRows);
|
|
654
|
+
const perStreamingItemRows = streamingItems.length > 0 ? Math.max(2, Math.floor(streamingRowsBudget / streamingItems.length)) : 0;
|
|
655
|
+
return _jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Static, { items: staticItems, children: item => item.kind === 'header'
|
|
621
656
|
? _jsx(Header, { subtitle: item.subtitle, version: version }, item.key)
|
|
622
|
-
:
|
|
657
|
+
: item.kind === 'assistant-markdown'
|
|
658
|
+
? _jsx(AssistantMarkdownChunkView, { message: item.message, content: item.content, width: contentWidth, first: item.first, final: item.final }, item.key)
|
|
659
|
+
: _jsx(MessageView, { message: item.message, width: contentWidth }, item.key) }), streamingItems.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, children: streamingItems.map(item => {
|
|
660
|
+
// One row for the optional header plus one for the item's bottom margin.
|
|
661
|
+
const chrome = (item.showHeader === false ? 0 : 1) + 1;
|
|
662
|
+
return _jsx(MessageView, { message: item.message, width: contentWidth, showHeader: item.showHeader, maxVisibleLines: Math.max(1, perStreamingItemRows - chrome) }, item.key);
|
|
663
|
+
}) }), debug && debugLogs.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { color: theme.muted, bold: true, children: "Debug" }), debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, children: ["\u2022 ", line] }, index))] }), queuedFollowUps.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: [_jsx(Text, { color: theme.muted, children: "Queued follow-ups:" }), queuedFollowUps.map((item, index) => _jsxs(Text, { color: theme.muted, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), pausedResume && !busy && _jsxs(Box, { flexShrink: 0, marginBottom: 1, children: [_jsxs(Text, { color: theme.muted, children: [pausedResume.kind === 'incomplete-goal' ? 'Unfinished goal paused (no measurable progress)' : 'Unfinished goal paused (model stream stalled)', " \u00B7 "] }), _jsxs(Text, { color: theme.command, bold: true, children: ["Press R to ", pausedResume.kind === 'incomplete-goal' ? 'resume' : 'retry'] }), _jsx(Text, { color: theme.muted, children: " or type a follow-up" })] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: expandedTaskCap }) }), busy && _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, tip: showingTip ? TIPS[tipIndex] : undefined }), _jsx(Box, { borderStyle: "round", borderColor: theme.deepPurple, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _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: Math.max(20, contentWidth - 4), getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
|
|
623
664
|
if (!tasksExpanded) {
|
|
624
665
|
setTaskBarPadding(0);
|
|
625
666
|
setTasksExpanded(true);
|
|
@@ -630,19 +671,22 @@ function ChatScreen({ debug = false, version, continueSession = false, resumeSes
|
|
|
630
671
|
setTaskBarPadding(Math.max(0, expandedRows - collapsedRows));
|
|
631
672
|
setTasksExpanded(false);
|
|
632
673
|
}
|
|
633
|
-
}, onCancel: cancelThinking, onEscape: () => {
|
|
674
|
+
}, onCancel: cancelThinking, onResumeKey: pausedResume != null && !busy ? resumePausedTask : undefined, onEscape: () => {
|
|
634
675
|
if (busy)
|
|
635
676
|
cancelThinking();
|
|
636
677
|
else
|
|
637
678
|
closeInputList();
|
|
638
|
-
}, onSubmit: submit }) }) }), debug && metrics.hasTokenBreakdown && _jsxs(Box, { flexShrink: 0, flexDirection: "column", paddingX: 1, children: [_jsxs(Text, { color: theme.muted, bold: true, children: ["Token usage ", metrics.inputEstimated || metrics.outputEstimated ? '(estimated)' : '(precise)'] }), _jsxs(Text, { color: theme.muted, children: [" in=", formatTokenCount(metrics.effectiveInput), " out=", formatTokenCount(metrics.effectiveOutput), tokenUsage.cacheReadTokens > 0 ? ` cached=${formatTokenCount(tokenUsage.cacheReadTokens)}` : '', tokenUsage.noCacheTokens > 0 ? ` uncached=${formatTokenCount(tokenUsage.noCacheTokens)}` : '', tokenUsage.cacheWriteTokens > 0 ? ` cache_write=${formatTokenCount(tokenUsage.cacheWriteTokens)}` : '', tokenUsage.reasoningTokens > 0 ? ` reasoning=${formatTokenCount(tokenUsage.reasoningTokens)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" logical=", formatTokenCount(tokenUsage.logicalInputEstimate), tokenUsage.effectiveNonCachedInput != null ? ` effective_non_cached=${formatTokenCount(tokenUsage.effectiveNonCachedInput)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" system=", formatTokenCount(tokenUsage.systemPrompt), " messages=", formatTokenCount(tokenUsage.messages), " tools=", formatTokenCount(tokenUsage.toolSchemas), " output=", formatTokenCount(tokenUsage.outputEstimate)] })] }), _jsxs(Box, { flexShrink: 0, justifyContent: "space-between", children: [_jsxs(Box, { flexDirection: "column", flexShrink: 1, minWidth: 0, children: [_jsx(Text, { color: theme.muted,
|
|
679
|
+
}, onSubmit: submit }) }) }), debug && metrics.hasTokenBreakdown && _jsxs(Box, { flexShrink: 0, flexDirection: "column", paddingX: 1, children: [_jsxs(Text, { color: theme.muted, bold: true, children: ["Token usage ", metrics.inputEstimated || metrics.outputEstimated ? '(estimated)' : '(precise)'] }), _jsxs(Text, { color: theme.muted, children: [" in=", formatTokenCount(metrics.effectiveInput), " out=", formatTokenCount(metrics.effectiveOutput), tokenUsage.cacheReadTokens > 0 ? ` cached=${formatTokenCount(tokenUsage.cacheReadTokens)}` : '', tokenUsage.noCacheTokens > 0 ? ` uncached=${formatTokenCount(tokenUsage.noCacheTokens)}` : '', tokenUsage.cacheWriteTokens > 0 ? ` cache_write=${formatTokenCount(tokenUsage.cacheWriteTokens)}` : '', tokenUsage.reasoningTokens > 0 ? ` reasoning=${formatTokenCount(tokenUsage.reasoningTokens)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" logical=", formatTokenCount(tokenUsage.logicalInputEstimate), tokenUsage.effectiveNonCachedInput != null ? ` effective_non_cached=${formatTokenCount(tokenUsage.effectiveNonCachedInput)}` : ''] }), _jsxs(Text, { color: theme.muted, children: [" system=", formatTokenCount(tokenUsage.systemPrompt), " messages=", formatTokenCount(tokenUsage.messages), " tools=", formatTokenCount(tokenUsage.toolSchemas), " output=", formatTokenCount(tokenUsage.outputEstimate)] })] }), _jsxs(Box, { flexShrink: 0, justifyContent: "space-between", children: [_jsxs(Box, { flexDirection: "column", flexShrink: 1, minWidth: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel })] }), _jsx(Box, { flexShrink: 0, marginLeft: 2, children: _jsx(Text, { color: theme.muted, wrap: "truncate-start", children: activeModelName }) })] })] });
|
|
639
680
|
}
|
|
640
681
|
export async function chatCommand(options = {}) {
|
|
641
682
|
if (process.stdout.isTTY) {
|
|
642
683
|
process.stdout.write('\u001B[2J\u001B[3J\u001B[H');
|
|
643
684
|
}
|
|
644
685
|
await clearTasksFromStore().catch(() => undefined);
|
|
645
|
-
|
|
686
|
+
// Incremental rendering rewrites only changed lines of the live frame, removing
|
|
687
|
+
// the full-frame erase/rewrite flicker while streaming. The fps cap aligns with
|
|
688
|
+
// the ~80ms spinner cadence; faster renders would only repaint unchanged lines.
|
|
689
|
+
const app = render(_jsx(ChatScreen, { debug: options.debug, version: options.version, build: options.build, continueSession: options.continueSession, resumeSessionId: options.resumeSessionId, noSession: options.noSession }), { incrementalRendering: true, maxFps: 15 });
|
|
646
690
|
await app.waitUntilExit();
|
|
647
691
|
await teardownBackgroundProcesses().catch(() => undefined);
|
|
648
692
|
await clearTasksFromStore().catch(() => undefined);
|