@denizokcu/haze 0.9.0 → 0.10.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 +57 -17
- package/README.md +119 -64
- package/dist/cli/chat/chatMetrics.d.ts +17 -1
- package/dist/cli/chat/chatMetrics.js +22 -5
- package/dist/cli/chat/contextReport.d.ts +11 -0
- package/dist/cli/chat/contextReport.js +44 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
- package/dist/cli/chat/fileMentionSuggestions.js +91 -0
- package/dist/cli/chat/inputSuggestions.d.ts +5 -0
- package/dist/cli/chat/inputSuggestions.js +17 -3
- package/dist/cli/chat/sessionLifecycle.d.ts +58 -0
- package/dist/cli/chat/sessionLifecycle.js +155 -0
- package/dist/cli/chat/sessionRecorder.js +7 -9
- package/dist/cli/chat/startupInfo.d.ts +1 -0
- package/dist/cli/chat/startupInfo.js +11 -0
- package/dist/cli/chat/tips.d.ts +21 -0
- package/dist/cli/chat/tips.js +43 -0
- package/dist/cli/chat/wizardDispatch.d.ts +64 -0
- package/dist/cli/chat/wizardDispatch.js +645 -0
- package/dist/cli/commands/chat.d.ts +1 -0
- package/dist/cli/commands/chat.js +181 -700
- package/dist/cli/commands/chatModes.d.ts +1 -1
- package/dist/cli/commands/chatModes.js +7 -2
- package/dist/cli/commands/commandHelp.js +5 -3
- package/dist/cli/commands/commands.d.ts +3 -2
- package/dist/cli/commands/commands.js +12 -13
- package/dist/cli/commands/fleetCommand.d.ts +14 -0
- package/dist/cli/commands/fleetCommand.js +46 -0
- package/dist/cli/commands/formatters.d.ts +5 -0
- package/dist/cli/commands/formatters.js +33 -6
- package/dist/cli/commands/logsCommand.js +1 -7
- package/dist/cli/commands/modelCommand.js +1 -1
- package/dist/cli/commands/providerWizard.d.ts +1 -0
- package/dist/cli/commands/providerWizard.js +13 -0
- package/dist/cli/commands/runCommand.d.ts +1 -0
- package/dist/cli/commands/runCommand.js +25 -5
- package/dist/cli/commands/sessionPicker.d.ts +9 -0
- package/dist/cli/commands/sessionPicker.js +29 -0
- package/dist/cli/commands/settingsSummary.js +6 -4
- package/dist/cli/commands/skillConfirmRemove.js +4 -3
- package/dist/cli/commands/skillWizard.d.ts +2 -0
- package/dist/cli/commands/skillWizard.js +16 -6
- package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
- package/dist/cli/commands/streaming/idleTimer.js +24 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +4 -2
- package/dist/cli/commands/streaming/turnRuntime.js +6 -4
- package/dist/cli/commands/streaming.d.ts +13 -1
- package/dist/cli/commands/streaming.js +42 -19
- package/dist/cli/commands/wizardActions.d.ts +6 -0
- package/dist/cli/commands/wizardActions.js +6 -0
- package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
- package/dist/cli/commands/wizardSuggestions.js +60 -12
- package/dist/cli/commands/wizardTransition.d.ts +4 -0
- package/dist/cli/commands/wizardTransition.js +1 -2
- package/dist/cli/index.js +17 -3
- package/dist/cli/terminalTitle.d.ts +6 -0
- package/dist/cli/terminalTitle.js +36 -0
- package/dist/config/inputHistory.d.ts +3 -3
- package/dist/config/inputHistory.js +12 -18
- package/dist/config/modelDiscovery.d.ts +20 -0
- package/dist/config/modelDiscovery.js +51 -0
- package/dist/config/providerPresets.d.ts +16 -4
- package/dist/config/providerPresets.js +263 -34
- package/dist/config/providers.d.ts +2 -0
- package/dist/config/providers.js +7 -0
- package/dist/config/settings.d.ts +22 -0
- package/dist/config/settings.js +29 -1
- package/dist/config/skillSettings.d.ts +6 -13
- package/dist/config/skillSettings.js +20 -19
- package/dist/core/agent/budgets.d.ts +26 -0
- package/dist/core/agent/budgets.js +34 -0
- package/dist/core/agent/compaction.js +17 -3
- package/dist/core/agent/contextBudget.d.ts +8 -0
- package/dist/core/agent/contextBudget.js +29 -0
- package/dist/core/agent/errors.js +6 -2
- package/dist/core/agent/events.d.ts +12 -0
- package/dist/core/agent/toolOutputStore.d.ts +5 -0
- package/dist/core/agent/toolOutputStore.js +18 -1
- package/dist/core/agent/workState.d.ts +1 -1
- package/dist/core/agent/workState.js +0 -4
- package/dist/core/attachments/imageAttachments.d.ts +90 -0
- package/dist/core/attachments/imageAttachments.js +245 -0
- package/dist/core/attachments/readBlessings.d.ts +37 -0
- package/dist/core/attachments/readBlessings.js +79 -0
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -13
- package/dist/core/io/boundedRead.js +76 -29
- package/dist/core/limits/byteBudgets.d.ts +5 -0
- package/dist/core/limits/byteBudgets.js +5 -0
- package/dist/core/limits/textBudgets.d.ts +23 -0
- package/dist/core/limits/textBudgets.js +23 -0
- package/dist/core/process/backgroundRegistry.d.ts +35 -0
- package/dist/core/process/backgroundRegistry.js +194 -0
- package/dist/core/process/runBoundedProcess.d.ts +3 -0
- package/dist/core/process/runBoundedProcess.js +65 -29
- package/dist/core/safety/urlGuard.d.ts +2 -1
- package/dist/core/safety/urlGuard.js +3 -2
- package/dist/core/session/sessionSlimming.js +47 -4
- package/dist/core/session/sessionStore.d.ts +37 -0
- package/dist/core/session/sessionStore.js +95 -9
- package/dist/core/subagent/contracts.d.ts +116 -0
- package/dist/core/subagent/contracts.js +54 -0
- package/dist/core/subagent/executionProfiles.d.ts +28 -0
- package/dist/core/subagent/executionProfiles.js +45 -0
- package/dist/core/subagent/subagentCoordinator.d.ts +74 -0
- package/dist/core/subagent/subagentCoordinator.js +134 -0
- package/dist/core/subagent/subagentRunner.d.ts +211 -145
- package/dist/core/subagent/subagentRunner.js +228 -98
- package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
- package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
- package/dist/core/tasks/taskStorage.js +12 -1
- package/dist/llm/client.d.ts +20 -29
- package/dist/llm/client.js +29 -28
- package/dist/llm/hazeTools.d.ts +2013 -78
- package/dist/llm/hazeTools.js +16 -7
- package/dist/llm/lsp.d.ts +2 -0
- package/dist/llm/lsp.js +18 -3
- package/dist/llm/requestContext.d.ts +22 -1
- package/dist/llm/requestContext.js +45 -5
- package/dist/llm/systemPrompt.d.ts +4 -1
- package/dist/llm/systemPrompt.js +14 -4
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +874 -32
- package/dist/llm/tools/bashTool.js +25 -4
- package/dist/llm/tools/fetchTool.d.ts +26 -26
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +2 -1
- package/dist/llm/tools/fileToolShared.js +5 -5
- package/dist/llm/tools/grepRunner.d.ts +5 -0
- package/dist/llm/tools/grepRunner.js +52 -71
- package/dist/llm/tools/outputCap.d.ts +2 -6
- package/dist/llm/tools/outputCap.js +2 -6
- package/dist/llm/tools/processTool.d.ts +1077 -0
- package/dist/llm/tools/processTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +8 -0
- package/dist/llm/tools/toolContext.js +22 -11
- package/dist/llm/tools/workspaceFile.d.ts +9 -1
- package/dist/llm/tools/workspaceFile.js +33 -4
- package/dist/llm/webFetch.js +24 -11
- package/dist/llm/workerContext.d.ts +18 -0
- package/dist/llm/workerContext.js +55 -0
- package/dist/skills/SkillLoader.d.ts +2 -2
- package/dist/skills/SkillRegistry.d.ts +3 -2
- package/dist/skills/SkillRegistry.js +43 -13
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +23 -5
- package/dist/skills/skillTools.js +11 -4
- package/dist/skills/types.d.ts +6 -1
- package/dist/ui/components/TextInput.d.ts +5 -2
- package/dist/ui/components/TextInput.js +76 -8
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +8 -0
- package/dist/utils/fs.d.ts +0 -1
- package/dist/utils/fs.js +0 -4
- package/dist/utils/openPath.d.ts +2 -0
- package/dist/utils/openPath.js +9 -0
- package/package.json +1 -1
|
@@ -4,11 +4,11 @@ export function toolCallCount(messages) {
|
|
|
4
4
|
return messages.reduce((total, message) => {
|
|
5
5
|
if (message.role !== 'tool')
|
|
6
6
|
return total;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return total +
|
|
7
|
+
// Live tool groups carry a structured count; only restored historical
|
|
8
|
+
// transcripts fall back to counting rendered per-call rows (CR-015).
|
|
9
|
+
if (typeof message.toolCount === 'number')
|
|
10
|
+
return total + message.toolCount;
|
|
11
|
+
return total + message.text.split('\n').filter(line => /^\s+[✓✗…]\s/.test(line)).length;
|
|
12
12
|
}, 0);
|
|
13
13
|
}
|
|
14
14
|
export function estimateTokens(text) {
|
|
@@ -48,3 +48,20 @@ export function estimateConversationTokens(messages) {
|
|
|
48
48
|
output: estimateTokens(outputText),
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
/** Status-bar numbers for the transcript, extracted so render stays declarative (CR-006). */
|
|
52
|
+
export function statusBarMetrics(input) {
|
|
53
|
+
const { messages, tokenUsage, enabledSkillCount } = input;
|
|
54
|
+
const hazeMessages = messages.filter(message => message.role === 'assistant' && !message.hidden).length;
|
|
55
|
+
const toolsUsed = toolCallCount(messages);
|
|
56
|
+
const fallbackTokens = estimateConversationTokens(messages);
|
|
57
|
+
const estimatedLogicalInput = tokenUsage.logicalInputEstimate || fallbackTokens.input || 0;
|
|
58
|
+
const providerInput = tokenUsage.inputTokens;
|
|
59
|
+
const effectiveInput = providerInput == null ? estimatedLogicalInput : Math.max(providerInput, estimatedLogicalInput);
|
|
60
|
+
const effectiveOutput = tokenUsage.outputTokens ?? (fallbackTokens.output || 0);
|
|
61
|
+
const inputEstimated = providerInput == null || effectiveInput !== providerInput;
|
|
62
|
+
const outputEstimated = tokenUsage.outputTokens == null;
|
|
63
|
+
const backgroundLabel = input.backgroundProcessCount ? ` / ⏵ ${input.backgroundProcessCount} bg` : '';
|
|
64
|
+
const statusDetailLabel = `${hazeMessages} haze message${hazeMessages === 1 ? '' : 's'} / ${toolsUsed} tool call${toolsUsed === 1 ? '' : 's'} / LLM ${inputEstimated ? '~' : ''}↑${formatTokenCount(effectiveInput)} ${outputEstimated ? '~' : ''}↓${formatTokenCount(effectiveOutput)} / ${enabledSkillCount} skill${enabledSkillCount === 1 ? '' : 's'}${backgroundLabel}`;
|
|
65
|
+
const hasTokenBreakdown = tokenUsage.systemPrompt > 0 || tokenUsage.messages > 0 || tokenUsage.toolSchemas > 0 || effectiveInput > 0 || effectiveOutput > 0;
|
|
66
|
+
return { hazeMessages, toolsUsed, effectiveInput, effectiveOutput, inputEstimated, outputEstimated, statusDetailLabel, hasTokenBreakdown };
|
|
67
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModelMessage } from 'ai';
|
|
2
|
+
import type { ContextFile } from '../../config/contextFiles.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build the `/context` token report. Extracted from `chat.tsx` (CR-006); takes
|
|
5
|
+
* its inputs explicitly so the component only orchestrates.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildContextReport(input: {
|
|
8
|
+
sessionStart: Date;
|
|
9
|
+
contextFiles: ContextFile[];
|
|
10
|
+
conversation: ModelMessage[];
|
|
11
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { contextBreakdown } from '../../core/agent/contextBudget.js';
|
|
2
|
+
import { stripSyntheticControls } from '../../core/agent/requestAssembly.js';
|
|
3
|
+
import { modelWithConfig } from '../../llm/client.js';
|
|
4
|
+
import { assembleRequestContext } from '../../llm/requestContext.js';
|
|
5
|
+
import { closeMcpClients } from '../../llm/mcp.js';
|
|
6
|
+
import { formatContextReport } from '../commands/formatters.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build the `/context` token report. Extracted from `chat.tsx` (CR-006); takes
|
|
9
|
+
* its inputs explicitly so the component only orchestrates.
|
|
10
|
+
*/
|
|
11
|
+
export async function buildContextReport(input) {
|
|
12
|
+
const runtime = await modelWithConfig({ cwd: process.cwd() });
|
|
13
|
+
if (!runtime?.model) {
|
|
14
|
+
return 'No model provider configured. Run /provider to choose or add a provider before /context can estimate tokens.';
|
|
15
|
+
}
|
|
16
|
+
const session = { start: input.sessionStart, cwd: process.cwd() };
|
|
17
|
+
const assembled = await assembleRequestContext({ contextFiles: input.contextFiles, session, model: runtime.model });
|
|
18
|
+
try {
|
|
19
|
+
const messages = stripSyntheticControls(input.conversation);
|
|
20
|
+
const breakdown = contextBreakdown({ system: assembled.systemPrompt, contextFiles: input.contextFiles, messages, tools: assembled.availableTools });
|
|
21
|
+
const tools = breakdown.toolSchemas.map(tool => ({
|
|
22
|
+
name: tool.name,
|
|
23
|
+
tokens: tool.tokens,
|
|
24
|
+
category: assembled.toolCategories.get(tool.name) ?? 'builtin',
|
|
25
|
+
}));
|
|
26
|
+
return formatContextReport({
|
|
27
|
+
modelLabel: `${runtime.config.providerName}:${runtime.config.modelName}`,
|
|
28
|
+
systemTokens: breakdown.system,
|
|
29
|
+
projectContext: breakdown.projectContext,
|
|
30
|
+
tools,
|
|
31
|
+
messagesByRole: breakdown.messagesByRole,
|
|
32
|
+
toolResults: breakdown.toolResults,
|
|
33
|
+
toolInputs: breakdown.toolInputs,
|
|
34
|
+
syntheticControl: breakdown.syntheticControl,
|
|
35
|
+
logicalInputEstimate: breakdown.logicalInputEstimate,
|
|
36
|
+
messageCount: messages.length,
|
|
37
|
+
mcpErrors: assembled.loadedMcp?.errors ?? [],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
if (assembled.loadedMcp?.clients.length)
|
|
42
|
+
await closeMcpClients(assembled.loadedMcp.clients);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
|
|
2
|
+
export interface MentionContext {
|
|
3
|
+
/** Full token including the leading `@`. */
|
|
4
|
+
token: string;
|
|
5
|
+
/** Index in the source string where the `@` sits. */
|
|
6
|
+
start: number;
|
|
7
|
+
/** Index one past the last char of the token. */
|
|
8
|
+
end: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Find the `@token` (if any) at the given cursor position. The cursor may
|
|
12
|
+
* sit anywhere inside the token or directly after its last char — both
|
|
13
|
+
* count as "inside" so the user can keep typing or completing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectMentionAtCursor(value: string, cursor: number): MentionContext | undefined;
|
|
16
|
+
export interface FileMentionSuggestionsOptions {
|
|
17
|
+
/** Override the workspace root for tests. Defaults to `process.cwd()`. */
|
|
18
|
+
workspaceRoot?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* List workspace paths matching the `@token` for tab completion. The token is
|
|
22
|
+
* treated as `@<parent>/<prefix>`; the parent directory is listed (one level,
|
|
23
|
+
* non-recursive) and children are filtered by the prefix. `.gitignored` paths
|
|
24
|
+
* are excluded; `.git` and `node_modules` are skipped by `walkDir` itself.
|
|
25
|
+
*
|
|
26
|
+
* Suggestion values include the leading `@` so the caller can replace the
|
|
27
|
+
* `@token` range verbatim with the chosen suggestion.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fileMentionSuggestions(token: string, options?: FileMentionSuggestionsOptions): Promise<TextInputSuggestion[]>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { walkDir } from '../../utils/fs.js';
|
|
4
|
+
import { isGitIgnored } from '../../llm/tools/fileToolShared.js';
|
|
5
|
+
import { workspaceRoot } from '../../utils/path.js';
|
|
6
|
+
/**
|
|
7
|
+
* Tab-completion support for `@`-mention paths (F04 AC1).
|
|
8
|
+
*
|
|
9
|
+
* Mention completion is cursor-aware partial replacement — unlike slash
|
|
10
|
+
* commands, the suggestion replaces only the `@token` at the cursor, not the
|
|
11
|
+
* whole input. Detection runs in the TextInput layer; this module owns the
|
|
12
|
+
* filesystem listing (bounded, `.gitignore`-aware) and stays UI-agnostic.
|
|
13
|
+
*/
|
|
14
|
+
/** Cap so completion stays responsive in large repos (F04 AC5). */
|
|
15
|
+
const MAX_MENTION_SUGGESTIONS = 20;
|
|
16
|
+
/** Characters allowed inside a `@token` while it is being typed. */
|
|
17
|
+
const MENTION_TOKEN_PATTERN = /@[\w./~-]*/g;
|
|
18
|
+
/**
|
|
19
|
+
* Find the `@token` (if any) at the given cursor position. The cursor may
|
|
20
|
+
* sit anywhere inside the token or directly after its last char — both
|
|
21
|
+
* count as "inside" so the user can keep typing or completing.
|
|
22
|
+
*/
|
|
23
|
+
export function detectMentionAtCursor(value, cursor) {
|
|
24
|
+
for (const match of value.matchAll(MENTION_TOKEN_PATTERN)) {
|
|
25
|
+
if (match.index === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
const start = match.index;
|
|
28
|
+
const end = start + match[0].length;
|
|
29
|
+
if (cursor >= start && cursor <= end)
|
|
30
|
+
return { token: match[0], start, end };
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Strip the leading `@` and split the query into parent directory + prefix.
|
|
36
|
+
* `@src/f` → `{parentDir: 'src', prefix: 'f'}`; `@` → `{parentDir: '.', prefix: ''}`.
|
|
37
|
+
*/
|
|
38
|
+
function splitQuery(token) {
|
|
39
|
+
const query = token.replace(/^@/, '');
|
|
40
|
+
const lastSlash = query.lastIndexOf('/');
|
|
41
|
+
if (lastSlash < 0)
|
|
42
|
+
return { parentDir: '.', prefix: query };
|
|
43
|
+
return { parentDir: query.slice(0, lastSlash), prefix: query.slice(lastSlash + 1) };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* List workspace paths matching the `@token` for tab completion. The token is
|
|
47
|
+
* treated as `@<parent>/<prefix>`; the parent directory is listed (one level,
|
|
48
|
+
* non-recursive) and children are filtered by the prefix. `.gitignored` paths
|
|
49
|
+
* are excluded; `.git` and `node_modules` are skipped by `walkDir` itself.
|
|
50
|
+
*
|
|
51
|
+
* Suggestion values include the leading `@` so the caller can replace the
|
|
52
|
+
* `@token` range verbatim with the chosen suggestion.
|
|
53
|
+
*/
|
|
54
|
+
export async function fileMentionSuggestions(token, options = {}) {
|
|
55
|
+
const root = options.workspaceRoot ?? workspaceRoot();
|
|
56
|
+
const { parentDir, prefix } = splitQuery(token);
|
|
57
|
+
const absoluteParent = path.resolve(root, parentDir);
|
|
58
|
+
// Keep completion inside the workspace — outside paths get the read-blessing
|
|
59
|
+
// surface but not tab completion (the spec confines completion to workspace).
|
|
60
|
+
const relative = path.relative(root, absoluteParent);
|
|
61
|
+
if (relative.startsWith('..') || path.isAbsolute(relative))
|
|
62
|
+
return [];
|
|
63
|
+
// Reject non-directory parents (e.g. `@file.txt/`) before walkDir would
|
|
64
|
+
// throw ENOTDIR on readdir.
|
|
65
|
+
let parentStats;
|
|
66
|
+
try {
|
|
67
|
+
parentStats = await fs.stat(absoluteParent);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
if (!parentStats.isDirectory())
|
|
73
|
+
return [];
|
|
74
|
+
const entries = await walkDir(absoluteParent, {
|
|
75
|
+
recursive: false,
|
|
76
|
+
maxEntries: MAX_MENTION_SUGGESTIONS * 4,
|
|
77
|
+
filter: async (entry) => !await isGitIgnored(entry.absolutePath),
|
|
78
|
+
});
|
|
79
|
+
const matches = entries
|
|
80
|
+
.filter(entry => entry.name.startsWith(prefix))
|
|
81
|
+
.slice(0, MAX_MENTION_SUGGESTIONS);
|
|
82
|
+
return matches.map(entry => {
|
|
83
|
+
const childPath = parentDir === '.' ? entry.name : `${parentDir}/${entry.name}`;
|
|
84
|
+
const completed = entry.isDirectory ? `${childPath}/` : childPath;
|
|
85
|
+
return {
|
|
86
|
+
value: `@${completed}`,
|
|
87
|
+
description: entry.isDirectory ? 'directory' : 'file',
|
|
88
|
+
kind: 'file',
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HazeSettings } from '../../config/settings.js';
|
|
2
2
|
import type { LoadedSkill } from '../../skills/types.js';
|
|
3
|
+
import type { SessionSummary } from '../../core/session/sessionStore.js';
|
|
3
4
|
import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
|
|
4
5
|
import type { Mode } from '../commands/chatModes.js';
|
|
5
6
|
interface InputSuggestionState {
|
|
@@ -8,9 +9,13 @@ interface InputSuggestionState {
|
|
|
8
9
|
skills: LoadedSkill[];
|
|
9
10
|
selectedProviderName?: string;
|
|
10
11
|
modelProviderFilter?: string;
|
|
12
|
+
providerDraftName?: string;
|
|
13
|
+
discoveredModels?: string[];
|
|
14
|
+
suggestedModels?: string[];
|
|
11
15
|
selectedSkillName?: string;
|
|
12
16
|
selectedLspName?: string;
|
|
13
17
|
selectedMcpName?: string;
|
|
18
|
+
sessions?: SessionSummary[];
|
|
14
19
|
}
|
|
15
20
|
export declare function inputSuggestionsForState(state: InputSuggestionState): TextInputSuggestion[];
|
|
16
21
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isSkillEnabled } from '../../config/skillSettings.js';
|
|
2
|
-
import { providerSuggestions, providerActionSuggestions, presetSuggestions, modelSuggestions, lspSuggestions, lspActionSuggestions, lspPresetSuggestions, mcpSuggestions, mcpActionSuggestions, mcpPresetSuggestions, mcpTransportSuggestions, skillsSuggestions, skillsActionSuggestions } from '../commands/wizardSuggestions.js';
|
|
2
|
+
import { providerSuggestions, providerActionSuggestions, presetSuggestions, modelSuggestions, modelAddProviderSuggestions, modelPickSuggestions, lspSuggestions, lspActionSuggestions, lspPresetSuggestions, mcpSuggestions, mcpActionSuggestions, mcpPresetSuggestions, mcpTransportSuggestions, skillsSuggestions, skillsActionSuggestions, skillScopeSuggestions } from '../commands/wizardSuggestions.js';
|
|
3
|
+
import { sessionActionSuggestions, sessionSuggestions } from '../commands/sessionPicker.js';
|
|
3
4
|
const CHAT_COMMAND_SUGGESTIONS = [
|
|
4
5
|
{ value: '/help', description: 'Show commands', kind: 'command' },
|
|
5
6
|
{ value: '/provider', description: 'Choose a provider', kind: 'command' },
|
|
@@ -9,9 +10,10 @@ const CHAT_COMMAND_SUGGESTIONS = [
|
|
|
9
10
|
{ value: '/settings', description: 'Show provider, model, API key, and context status', kind: 'command' },
|
|
10
11
|
{ value: '/context', description: 'Show token breakdown of system, tools, MCP, and messages', kind: 'command' },
|
|
11
12
|
{ value: '/skills', description: 'Manage Markdown skills (add, enable/disable, validate, remove)', kind: 'command' },
|
|
13
|
+
{ value: '/fleet ', description: 'Parallelize independent work in disposable contexts (flags: --review/--profile/--workers/--concurrency)', kind: 'command' },
|
|
12
14
|
{ value: '/init', description: 'Create or update AGENTS.md project instructions', kind: 'command' },
|
|
13
15
|
{ value: '/session', description: 'Show current session path', kind: 'command' },
|
|
14
|
-
{ value: '/resume', description: '
|
|
16
|
+
{ value: '/resume', description: 'Browse saved sessions for this workspace', kind: 'command' },
|
|
15
17
|
{ value: '/new', description: 'Start a new session', kind: 'command' },
|
|
16
18
|
{ value: '/compact ', description: 'Summarize older context and keep recent messages', kind: 'command' },
|
|
17
19
|
{ value: '/clear', description: 'Clear conversation history', kind: 'command' },
|
|
@@ -20,6 +22,10 @@ const CHAT_COMMAND_SUGGESTIONS = [
|
|
|
20
22
|
];
|
|
21
23
|
export function inputSuggestionsForState(state) {
|
|
22
24
|
const { mode, settings, skills } = state;
|
|
25
|
+
if (mode === 'sessions')
|
|
26
|
+
return sessionSuggestions(state.sessions ?? []);
|
|
27
|
+
if (mode === 'sessionAction')
|
|
28
|
+
return sessionActionSuggestions();
|
|
23
29
|
if (mode === 'provider')
|
|
24
30
|
return providerSuggestions(settings);
|
|
25
31
|
if (mode === 'providerAction')
|
|
@@ -28,10 +34,16 @@ export function inputSuggestionsForState(state) {
|
|
|
28
34
|
return presetSuggestions();
|
|
29
35
|
if (mode === 'model')
|
|
30
36
|
return modelSuggestions(settings, state.modelProviderFilter);
|
|
37
|
+
if (mode === 'modelAddProvider')
|
|
38
|
+
return modelAddProviderSuggestions(settings);
|
|
39
|
+
if (mode === 'modelPick')
|
|
40
|
+
return modelPickSuggestions(settings, state.selectedProviderName ?? state.providerDraftName, state.discoveredModels ?? [], state.suggestedModels ?? []);
|
|
31
41
|
if (mode === 'skills')
|
|
32
42
|
return skillsSuggestions(settings, skills);
|
|
33
43
|
if (mode === 'skillsAction')
|
|
34
44
|
return skillsActionSuggestions(settings, skills, state.selectedSkillName);
|
|
45
|
+
if (mode === 'skillsAddScope')
|
|
46
|
+
return skillScopeSuggestions();
|
|
35
47
|
if (mode === 'lsp')
|
|
36
48
|
return lspSuggestions(settings);
|
|
37
49
|
if (mode === 'lspAction')
|
|
@@ -48,8 +60,10 @@ export function inputSuggestionsForState(state) {
|
|
|
48
60
|
return mcpTransportSuggestions();
|
|
49
61
|
if (mode !== 'chat')
|
|
50
62
|
return [];
|
|
63
|
+
const activeSkills = skills.filter((skill, index) => isSkillEnabled(settings, skill.name, skill.source)
|
|
64
|
+
&& !skills.slice(0, index).some(candidate => candidate.name === skill.name && isSkillEnabled(settings, candidate.name, candidate.source)));
|
|
51
65
|
return [
|
|
52
66
|
...CHAT_COMMAND_SUGGESTIONS,
|
|
53
|
-
...
|
|
67
|
+
...activeSkills.map(skill => ({ value: `/${skill.name}`, description: `${skill.description} · ${skill.source}`, kind: 'skill' })),
|
|
54
68
|
];
|
|
55
69
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ModelMessage } from 'ai';
|
|
2
|
+
import type { ContextFile } from '../../config/contextFiles.js';
|
|
3
|
+
import type { WorkState } from '../../core/agent/workState.js';
|
|
4
|
+
import { type HazeSession } from '../../core/session/sessionStore.js';
|
|
5
|
+
import { type LlmLog } from '../../core/log/llmLog.js';
|
|
6
|
+
import type { Message, TokenUsage } from '../commands/streaming.js';
|
|
7
|
+
import type { SessionRecorder } from './sessionRecorder.js';
|
|
8
|
+
/**
|
|
9
|
+
* Session lifecycle controller extracted from `chat.tsx` (CR-006): session
|
|
10
|
+
* init/continue/resume/new/clear/compact live here; the component keeps refs,
|
|
11
|
+
* state setters, and render work. Uses plain `{current}` holders so it works
|
|
12
|
+
* with React refs without importing React.
|
|
13
|
+
*/
|
|
14
|
+
export interface SessionLifecycleDeps {
|
|
15
|
+
version?: string;
|
|
16
|
+
continueSession: boolean;
|
|
17
|
+
resumeSessionId?: string;
|
|
18
|
+
noSession: boolean;
|
|
19
|
+
debug: boolean;
|
|
20
|
+
contextFiles: () => ContextFile[];
|
|
21
|
+
sessionRef: {
|
|
22
|
+
current: HazeSession | undefined;
|
|
23
|
+
};
|
|
24
|
+
sessionRecorder: () => SessionRecorder | undefined;
|
|
25
|
+
sessionStartRef: {
|
|
26
|
+
current: Date;
|
|
27
|
+
};
|
|
28
|
+
conversationRef: {
|
|
29
|
+
current: ModelMessage[];
|
|
30
|
+
};
|
|
31
|
+
workStateRef: {
|
|
32
|
+
current: WorkState | undefined;
|
|
33
|
+
};
|
|
34
|
+
lastAssistantTextRef: {
|
|
35
|
+
current: string;
|
|
36
|
+
};
|
|
37
|
+
llmLogRef: {
|
|
38
|
+
current: LlmLog | undefined;
|
|
39
|
+
};
|
|
40
|
+
contextFileSignaturesRef: {
|
|
41
|
+
current: Map<string, string>;
|
|
42
|
+
};
|
|
43
|
+
setMessages: (updater: (messages: Message[]) => Message[]) => void;
|
|
44
|
+
setLiveMessagesState: (updater: (messages: Message[]) => Message[]) => void;
|
|
45
|
+
setTokenUsage: (usage: TokenUsage) => void;
|
|
46
|
+
debugLog: (line: string) => void;
|
|
47
|
+
showPersistenceWarning: (error: unknown) => void;
|
|
48
|
+
}
|
|
49
|
+
export interface SessionLifecycle {
|
|
50
|
+
initializeSession: () => Promise<void>;
|
|
51
|
+
startNewSession: (message?: string) => Promise<void>;
|
|
52
|
+
resumeLatestSession: () => Promise<void>;
|
|
53
|
+
resumeSessionById: (id: string) => Promise<boolean>;
|
|
54
|
+
forkSessionById: (id: string) => Promise<boolean>;
|
|
55
|
+
clearConversation: () => Promise<void>;
|
|
56
|
+
compactConversation: (instructions?: string) => boolean;
|
|
57
|
+
}
|
|
58
|
+
export declare function createSessionLifecycle(deps: SessionLifecycleDeps): SessionLifecycle;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { compactModelMessages } from '../../core/agent/compaction.js';
|
|
2
|
+
import { clearToolOutputs } from '../../core/agent/toolOutputStore.js';
|
|
3
|
+
import { createSession, findSession, forkSession, formatSession, latestSession, restoreSessionState } from '../../core/session/sessionStore.js';
|
|
4
|
+
import { createLog as createLlmLog, endLog as endLlmLog } from '../../core/log/llmLog.js';
|
|
5
|
+
import { displayMessagesFromConversation, estimateConversationTokens } from './chatMetrics.js';
|
|
6
|
+
import { EMPTY_TOKEN_USAGE } from './turnState.js';
|
|
7
|
+
import { teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
|
|
8
|
+
export function createSessionLifecycle(deps) {
|
|
9
|
+
async function startNewLog() {
|
|
10
|
+
if (!deps.debug)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (deps.llmLogRef.current) {
|
|
13
|
+
await endLlmLog(deps.llmLogRef.current).catch(deps.showPersistenceWarning);
|
|
14
|
+
}
|
|
15
|
+
const log = await createLlmLog();
|
|
16
|
+
deps.llmLogRef.current = log;
|
|
17
|
+
return log;
|
|
18
|
+
}
|
|
19
|
+
async function startNewSession(message = 'Started a new session.') {
|
|
20
|
+
await teardownBackgroundProcesses().catch(deps.showPersistenceWarning);
|
|
21
|
+
await deps.sessionRecorder()?.flush().catch(deps.showPersistenceWarning);
|
|
22
|
+
clearToolOutputs();
|
|
23
|
+
deps.contextFileSignaturesRef.current = new Map(deps.contextFiles().flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
24
|
+
deps.workStateRef.current = undefined;
|
|
25
|
+
deps.sessionStartRef.current = new Date();
|
|
26
|
+
if (deps.noSession) {
|
|
27
|
+
deps.sessionRef.current = undefined;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const session = await createSession({ hazeVersion: deps.version });
|
|
31
|
+
deps.sessionRef.current = session;
|
|
32
|
+
deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE });
|
|
33
|
+
await startNewLog();
|
|
34
|
+
deps.setMessages(m => [...m, { role: 'system', text: `${message}\nSession saved: ${session.file}` }]);
|
|
35
|
+
}
|
|
36
|
+
async function resumeSession(session, replaceTranscript) {
|
|
37
|
+
const { messages: conversation, workState, parseErrors } = await restoreSessionState(session);
|
|
38
|
+
deps.sessionRef.current = session;
|
|
39
|
+
deps.conversationRef.current = conversation;
|
|
40
|
+
deps.setLiveMessagesState(() => []);
|
|
41
|
+
const restoredMessages = displayMessagesFromConversation(conversation);
|
|
42
|
+
deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE, messages: estimateConversationTokens(restoredMessages).input, outputEstimate: estimateConversationTokens(restoredMessages).output });
|
|
43
|
+
deps.workStateRef.current = workState;
|
|
44
|
+
for (const error of parseErrors) {
|
|
45
|
+
deps.debugLog(`Session parse error: ${error}`);
|
|
46
|
+
}
|
|
47
|
+
deps.setMessages(messages => {
|
|
48
|
+
const restored = [{ role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...restoredMessages];
|
|
49
|
+
return replaceTranscript ? restored : [...messages, ...restored];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
async initializeSession() {
|
|
54
|
+
if (deps.noSession)
|
|
55
|
+
return;
|
|
56
|
+
if (deps.resumeSessionId) {
|
|
57
|
+
const session = await findSession(deps.resumeSessionId);
|
|
58
|
+
if (!session)
|
|
59
|
+
throw new Error(`No session named ${deps.resumeSessionId} exists for this workspace.`);
|
|
60
|
+
await resumeSession(session, false);
|
|
61
|
+
deps.sessionStartRef.current = new Date();
|
|
62
|
+
await startNewLog();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (deps.continueSession) {
|
|
66
|
+
const session = await latestSession();
|
|
67
|
+
if (session) {
|
|
68
|
+
await resumeSession(session, false);
|
|
69
|
+
deps.sessionStartRef.current = new Date();
|
|
70
|
+
await startNewLog();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
await startNewSession(deps.continueSession ? 'No previous session found. Started a new session.' : 'Started a new session.');
|
|
75
|
+
},
|
|
76
|
+
startNewSession,
|
|
77
|
+
async resumeLatestSession() {
|
|
78
|
+
await deps.sessionRecorder()?.flush().catch(deps.showPersistenceWarning);
|
|
79
|
+
const session = await latestSession();
|
|
80
|
+
if (!session) {
|
|
81
|
+
deps.setMessages(m => [...m, { role: 'system', text: 'No previous session found for this workspace.' }]);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await teardownBackgroundProcesses().catch(deps.showPersistenceWarning);
|
|
85
|
+
clearToolOutputs();
|
|
86
|
+
await resumeSession(session, true);
|
|
87
|
+
deps.sessionStartRef.current = new Date();
|
|
88
|
+
await startNewLog();
|
|
89
|
+
},
|
|
90
|
+
async resumeSessionById(id) {
|
|
91
|
+
await deps.sessionRecorder()?.flush().catch(deps.showPersistenceWarning);
|
|
92
|
+
const session = await findSession(id);
|
|
93
|
+
if (!session) {
|
|
94
|
+
deps.setMessages(m => [...m, { role: 'system', text: `No session named ${id} exists for this workspace.` }]);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
await teardownBackgroundProcesses().catch(deps.showPersistenceWarning);
|
|
98
|
+
clearToolOutputs();
|
|
99
|
+
await resumeSession(session, true);
|
|
100
|
+
deps.sessionStartRef.current = new Date();
|
|
101
|
+
await startNewLog();
|
|
102
|
+
return true;
|
|
103
|
+
},
|
|
104
|
+
async forkSessionById(id) {
|
|
105
|
+
await deps.sessionRecorder()?.flush().catch(deps.showPersistenceWarning);
|
|
106
|
+
const source = await findSession(id);
|
|
107
|
+
if (!source) {
|
|
108
|
+
deps.setMessages(m => [...m, { role: 'system', text: `No session named ${id} exists for this workspace.` }]);
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
let forked;
|
|
112
|
+
try {
|
|
113
|
+
forked = await forkSession(source, { hazeVersion: deps.version });
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
deps.setMessages(m => [...m, { role: 'system', text: error instanceof Error ? error.message : String(error) }]);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const { session, parseErrors } = forked;
|
|
120
|
+
for (const error of parseErrors)
|
|
121
|
+
deps.debugLog(`Session parse error: ${error}`);
|
|
122
|
+
await teardownBackgroundProcesses().catch(deps.showPersistenceWarning);
|
|
123
|
+
clearToolOutputs();
|
|
124
|
+
await resumeSession(session, true);
|
|
125
|
+
deps.sessionStartRef.current = new Date();
|
|
126
|
+
await startNewLog();
|
|
127
|
+
deps.setMessages(m => [...m, { role: 'system', text: `Forked from session ${id}. The original was left unchanged.` }]);
|
|
128
|
+
return true;
|
|
129
|
+
},
|
|
130
|
+
async clearConversation() {
|
|
131
|
+
clearToolOutputs();
|
|
132
|
+
deps.conversationRef.current = [];
|
|
133
|
+
deps.lastAssistantTextRef.current = '';
|
|
134
|
+
deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE });
|
|
135
|
+
deps.workStateRef.current = undefined;
|
|
136
|
+
deps.setLiveMessagesState(() => []);
|
|
137
|
+
deps.setMessages(() => [{ role: 'system', text: 'Cleared. The void is productive.' }]);
|
|
138
|
+
deps.sessionRecorder()?.recordNamedEvent('clear', 'Conversation cleared');
|
|
139
|
+
await deps.sessionRecorder()?.flush().catch(deps.showPersistenceWarning);
|
|
140
|
+
await startNewLog().catch(deps.showPersistenceWarning);
|
|
141
|
+
},
|
|
142
|
+
compactConversation(instructions) {
|
|
143
|
+
const result = compactModelMessages(deps.conversationRef.current, { instructions, tokenBudget: 40_000, workState: deps.workStateRef.current });
|
|
144
|
+
if (!result.compacted) {
|
|
145
|
+
deps.setMessages(m => [...m, { role: 'system', text: `Compaction skipped: only ${result.keptCount} model messages in context.` }]);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
deps.conversationRef.current = result.messages;
|
|
149
|
+
deps.sessionRecorder()?.recordNamedEvent('compact', `Compacted ${result.olderCount} messages; kept ${result.keptCount}.`);
|
|
150
|
+
deps.sessionRecorder()?.recordConversation(result.messages);
|
|
151
|
+
deps.setMessages(m => [...m, { role: 'system', text: `Compacted context: condensed ${result.olderCount} older model messages into a bounded excerpt and kept the last ${result.keptCount}.` }]);
|
|
152
|
+
return true;
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { appendSessionEntry } from '../../core/session/sessionStore.js';
|
|
2
|
+
import { OrderedFileWriter } from '../../core/persistence/orderedFileWriter.js';
|
|
2
3
|
export function createSessionRecorder(getSession) {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
// Ordered appends and first-error capture come from the shared writer
|
|
5
|
+
// primitive; entries recorded before a session exists are dropped (CR-005).
|
|
6
|
+
const writer = new OrderedFileWriter(({ session, entry }) => appendSessionEntry(session, entry));
|
|
5
7
|
const append = (entry) => {
|
|
6
8
|
const session = getSession();
|
|
7
9
|
if (!session)
|
|
8
10
|
return;
|
|
9
|
-
|
|
10
|
-
firstError ??= error instanceof Error ? error : new Error(String(error));
|
|
11
|
-
});
|
|
11
|
+
void writer.append({ session, entry });
|
|
12
12
|
};
|
|
13
13
|
return {
|
|
14
14
|
recordUiMessage(message) {
|
|
@@ -27,10 +27,8 @@ export function createSessionRecorder(getSession) {
|
|
|
27
27
|
append({ type: 'event', at: new Date().toISOString(), name, text });
|
|
28
28
|
},
|
|
29
29
|
async flush() {
|
|
30
|
-
await
|
|
31
|
-
if (firstError)
|
|
32
|
-
throw firstError;
|
|
30
|
+
await writer.flush();
|
|
33
31
|
},
|
|
34
|
-
error() { return
|
|
32
|
+
error() { return writer.error(); },
|
|
35
33
|
};
|
|
36
34
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HazeSettings } from '../../config/settings.js';
|
|
2
2
|
import type { ContextFile } from '../../config/contextFiles.js';
|
|
3
3
|
export declare function startupContextInfo(contextFiles: ContextFile[]): string;
|
|
4
|
+
export declare function startupInputTips(): string;
|
|
4
5
|
export declare function startupProviderInfo(settings: HazeSettings): string;
|
|
@@ -8,6 +8,17 @@ export function startupContextInfo(contextFiles) {
|
|
|
8
8
|
...(lines.length > 0 ? lines : ['- none']),
|
|
9
9
|
].join('\n');
|
|
10
10
|
}
|
|
11
|
+
export function startupInputTips() {
|
|
12
|
+
return [
|
|
13
|
+
'Type @path/to/image.png (or any path with a /) to send images to models with vision capabilities.',
|
|
14
|
+
'',
|
|
15
|
+
'Tab through files in your working directory after typing @',
|
|
16
|
+
'',
|
|
17
|
+
'Mentioning a file or directory with @path, or any /-containing path, lets the model read it, even outside the working directory.',
|
|
18
|
+
'',
|
|
19
|
+
'Edits and writes stay inside the workspace.',
|
|
20
|
+
].join('\n');
|
|
21
|
+
}
|
|
11
22
|
export function startupProviderInfo(settings) {
|
|
12
23
|
const selection = activeModel(settings);
|
|
13
24
|
const configuredCount = configuredProviders(settings).length;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rotating tips shown under the busy label while the model is thinking.
|
|
3
|
+
*
|
|
4
|
+
* The registry is data, not code, so rewording or pruning is trivial. Tips
|
|
5
|
+
* must describe things the user can do from their keyboard (slash commands,
|
|
6
|
+
* `@`-mentions, key presses, flags) — never internal model-tool mechanics
|
|
7
|
+
* like how `readFile` pages or `grep` caps results. Keep one idea per entry,
|
|
8
|
+
* lead with the action, and stay terminal-width-friendly.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TIPS: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Pick a random tip index, avoiding the previous one when possible so the
|
|
13
|
+
* rotation never shows the same tip twice in a row.
|
|
14
|
+
*/
|
|
15
|
+
export declare function randomTipIndex(exclude?: number): number;
|
|
16
|
+
/** Whether the tips rotation is enabled in user settings (default true). */
|
|
17
|
+
export declare function tipsEnabled(settings: {
|
|
18
|
+
tips?: {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rotating tips shown under the busy label while the model is thinking.
|
|
3
|
+
*
|
|
4
|
+
* The registry is data, not code, so rewording or pruning is trivial. Tips
|
|
5
|
+
* must describe things the user can do from their keyboard (slash commands,
|
|
6
|
+
* `@`-mentions, key presses, flags) — never internal model-tool mechanics
|
|
7
|
+
* like how `readFile` pages or `grep` caps results. Keep one idea per entry,
|
|
8
|
+
* lead with the action, and stay terminal-width-friendly.
|
|
9
|
+
*/
|
|
10
|
+
export const TIPS = [
|
|
11
|
+
'Attach an image with @path/to/img.png — or any path with / — png/jpg/jpeg/gif/webp.',
|
|
12
|
+
'Type @ to browse workspace files; Tab completes the path.',
|
|
13
|
+
'Mention any file or directory by @path (or paste a /-containing path) to let the model read it this turn, even outside the workspace.',
|
|
14
|
+
'Backslash-escape spaces in paths: @screen\\ 2026.png works for macOS screenshots.',
|
|
15
|
+
'Mark a provider image-capable in /provider so attached images actually get sent.',
|
|
16
|
+
'/mcp add context7 loads external tools for up-to-date library docs.',
|
|
17
|
+
'/lsp presets then /lsp add typescript enables jump-to-definition, references, and rename.',
|
|
18
|
+
'/skills browses packaged workflows — skills inject instructions, never code.',
|
|
19
|
+
'/init scaffolds an AGENTS.md so future sessions start with project context.',
|
|
20
|
+
'Conversations persist under ~/.haze/sessions; resume the latest with /resume.',
|
|
21
|
+
'Long threads compact automatically; /compact does it on demand.',
|
|
22
|
+
'/fleet runs genuinely independent tasks through disposable contexts in parallel.',
|
|
23
|
+
'Press esc to interrupt a running turn and reclaim control.',
|
|
24
|
+
'/context shows a token breakdown — system, project context, tools, and messages.',
|
|
25
|
+
'/model <name> sets a model directly (e.g. /model sonnet); selecting one also sets its provider.',
|
|
26
|
+
'/tips toggles this hint line off if you find it distracting.',
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Pick a random tip index, avoiding the previous one when possible so the
|
|
30
|
+
* rotation never shows the same tip twice in a row.
|
|
31
|
+
*/
|
|
32
|
+
export function randomTipIndex(exclude) {
|
|
33
|
+
if (TIPS.length <= 1)
|
|
34
|
+
return 0;
|
|
35
|
+
let next = Math.floor(Math.random() * TIPS.length);
|
|
36
|
+
while (next === exclude)
|
|
37
|
+
next = Math.floor(Math.random() * TIPS.length);
|
|
38
|
+
return next;
|
|
39
|
+
}
|
|
40
|
+
/** Whether the tips rotation is enabled in user settings (default true). */
|
|
41
|
+
export function tipsEnabled(settings) {
|
|
42
|
+
return settings.tips?.enabled !== false;
|
|
43
|
+
}
|