@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
|
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { Box, Text, useInput } from 'ink';
|
|
4
4
|
import { theme } from '../theme.js';
|
|
5
5
|
import { compactPasteBlocksForDisplay, cursorPosition, displayCursorForValueCursor, lineCount, normalizeLineEndings, updatePasteBlocksForReplacement, valueCursorForDisplayCursor, wrapDisplayValue, } from '../inputBuffer.js';
|
|
6
|
+
import { detectMentionAtCursor } from '../../cli/chat/fileMentionSuggestions.js';
|
|
6
7
|
const COMPACT_PASTE_MIN_LINES = 4;
|
|
7
8
|
const CTRL_ENTER_ESCAPE_INPUTS = new Set(['\u001B[13;5u', '\u001B[13;5~']);
|
|
8
9
|
export function shouldInsertNewline(input, key) {
|
|
@@ -10,11 +11,14 @@ export function shouldInsertNewline(input, key) {
|
|
|
10
11
|
|| input === '\n'
|
|
11
12
|
|| CTRL_ENTER_ESCAPE_INPUTS.has(input);
|
|
12
13
|
}
|
|
13
|
-
export function TextInput({ placeholder, disabled, mask, historyItems = [], recordHistory = true, suggestions = [], suggestionMode = 'slash', submitOnEmpty = false, width = 80, onHistoryAdd, onCancel, onEscape, onToggleTasks, onSubmit }) {
|
|
14
|
+
export function TextInput({ placeholder, disabled, mask, historyItems = [], recordHistory = true, suggestions = [], suggestionMode = 'slash', submitOnEmpty = false, width = 80, getMentionSuggestions, onHistoryAdd, onCancel, onEscape, onToggleTasks, onSubmit }) {
|
|
14
15
|
const [value, setValue] = useState('');
|
|
15
16
|
const [cursor, setCursor] = useState(0);
|
|
16
17
|
const [pasteBlocks, setPasteBlocks] = useState([]);
|
|
17
18
|
const [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(0);
|
|
19
|
+
const [mentionContext, setMentionContext] = useState();
|
|
20
|
+
const [mentionSuggestions, setMentionSuggestions] = useState([]);
|
|
21
|
+
const [mentionSelectedIndex, setMentionSelectedIndex] = useState(0);
|
|
18
22
|
const history = useRef(historyItems);
|
|
19
23
|
const historyIndex = useRef(null);
|
|
20
24
|
const draft = useRef('');
|
|
@@ -40,6 +44,7 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
40
44
|
setCursor(Math.max(0, Math.min(nextCursor, next.length)));
|
|
41
45
|
setPasteBlocks(nextPasteBlocks);
|
|
42
46
|
setSelectedSuggestionIndex(0);
|
|
47
|
+
setMentionSelectedIndex(0);
|
|
43
48
|
}
|
|
44
49
|
function replaceInput(start, end, inserted) {
|
|
45
50
|
const normalizedInserted = normalizeLineEndings(inserted);
|
|
@@ -65,8 +70,36 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
65
70
|
return suggestionValue.toLowerCase().includes(suggestionQuery) || suggestion.description?.toLowerCase().includes(suggestionQuery);
|
|
66
71
|
})
|
|
67
72
|
.slice(0, 20);
|
|
73
|
+
// `@token` mention detection — only in chat mode (slash) so wizard pickers
|
|
74
|
+
// never grab `@`-prefixed tokens. Detection is sync; suggestion fetch is
|
|
75
|
+
// async with cancellation so fast typing does not race stale results.
|
|
76
|
+
const detectedMention = !mask && suggestionMode === 'slash' && !value.startsWith('/') && getMentionSuggestions
|
|
77
|
+
? detectMentionAtCursor(value, cursor)
|
|
78
|
+
: undefined;
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
setMentionContext(detectedMention);
|
|
81
|
+
}, [detectedMention?.token, detectedMention?.start, detectedMention?.end]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!mentionContext || !getMentionSuggestions) {
|
|
84
|
+
if (mentionSuggestions.length > 0)
|
|
85
|
+
setMentionSuggestions([]);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let cancelled = false;
|
|
89
|
+
Promise.resolve(getMentionSuggestions(mentionContext.token))
|
|
90
|
+
.then(results => { if (!cancelled) {
|
|
91
|
+
setMentionSuggestions(results);
|
|
92
|
+
setMentionSelectedIndex(0);
|
|
93
|
+
} })
|
|
94
|
+
.catch(() => { if (!cancelled)
|
|
95
|
+
setMentionSuggestions([]); });
|
|
96
|
+
return () => { cancelled = true; };
|
|
97
|
+
}, [mentionContext?.token, mentionContext?.start, mentionContext?.end]);
|
|
98
|
+
const inMentionMode = !!detectedMention;
|
|
99
|
+
const mentionList = inMentionMode ? mentionSuggestions : [];
|
|
100
|
+
const activeMentionIndex = Math.min(mentionSelectedIndex, Math.max(0, mentionList.length - 1));
|
|
68
101
|
const activeSuggestionIndex = Math.min(selectedSuggestionIndex, Math.max(0, filteredSuggestions.length - 1));
|
|
69
|
-
const activeSuggestion = filteredSuggestions[activeSuggestionIndex];
|
|
102
|
+
const activeSuggestion = inMentionMode ? mentionList[activeMentionIndex] : filteredSuggestions[activeSuggestionIndex];
|
|
70
103
|
const displayValue = mask ? '•'.repeat(value.length) : compactPasteBlocksForDisplay(value, pasteBlocks);
|
|
71
104
|
const displayCursor = mask ? cursor : displayCursorForValueCursor(pasteBlocks, cursor);
|
|
72
105
|
const inputWidth = Math.max(1, width - 2);
|
|
@@ -108,6 +141,13 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
108
141
|
return;
|
|
109
142
|
}
|
|
110
143
|
if (key.tab && activeSuggestion) {
|
|
144
|
+
if (inMentionMode && detectedMention) {
|
|
145
|
+
// Partial replacement of the `@token` range, not the whole input —
|
|
146
|
+
// mention completion fires mid-prompt.
|
|
147
|
+
replaceInput(detectedMention.start, detectedMention.end, activeSuggestion.value);
|
|
148
|
+
historyIndex.current = null;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
111
151
|
setInput(activeSuggestion.value);
|
|
112
152
|
historyIndex.current = null;
|
|
113
153
|
return;
|
|
@@ -117,9 +157,21 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
117
157
|
return;
|
|
118
158
|
}
|
|
119
159
|
if (key.return) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
160
|
+
// Mention mode: complete the `@token` range before submitting, so
|
|
161
|
+
// pressing Enter on `read @packa` with `@package.json` highlighted
|
|
162
|
+
// submits `read @package.json` (matches slash-command behavior).
|
|
163
|
+
let submittedValue;
|
|
164
|
+
let submittedSuggestion;
|
|
165
|
+
if (inMentionMode && detectedMention && activeSuggestion && activeSuggestion.value !== detectedMention.token) {
|
|
166
|
+
submittedValue = value.slice(0, detectedMention.start) + activeSuggestion.value + value.slice(detectedMention.end);
|
|
167
|
+
submittedSuggestion = activeSuggestion;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const shouldUseSuggestion = !!activeSuggestion && activeSuggestion.value !== value.trim() && (suggestionMode === 'always' || value.startsWith('/'));
|
|
171
|
+
submittedValue = shouldUseSuggestion && activeSuggestion ? activeSuggestion.value : value;
|
|
172
|
+
submittedSuggestion = shouldUseSuggestion ? activeSuggestion : undefined;
|
|
173
|
+
}
|
|
174
|
+
const submitted = submittedValue.trim();
|
|
123
175
|
const historyValue = submittedSuggestion && submittedSuggestion.kind !== 'command' ? '' : submitted;
|
|
124
176
|
setInput('');
|
|
125
177
|
historyIndex.current = null;
|
|
@@ -140,12 +192,19 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
140
192
|
return;
|
|
141
193
|
}
|
|
142
194
|
if (key.upArrow) {
|
|
195
|
+
if (inMentionMode && mentionList.length > 0) {
|
|
196
|
+
if (activeMentionIndex > 0)
|
|
197
|
+
setMentionSelectedIndex(current => Math.max(0, current - 1));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
143
200
|
if (filteredSuggestions.length > 0 && activeSuggestionIndex > 0) {
|
|
144
201
|
setSelectedSuggestionIndex(current => Math.max(0, current - 1));
|
|
145
202
|
return;
|
|
146
203
|
}
|
|
147
|
-
if (filteredSuggestions.length === 0 && moveCursorVertically(-1))
|
|
204
|
+
if (filteredSuggestions.length === 0 && !inMentionMode && moveCursorVertically(-1))
|
|
148
205
|
return;
|
|
206
|
+
if (inMentionMode)
|
|
207
|
+
return; // no history navigation while completing
|
|
149
208
|
preferredColumn.current = null;
|
|
150
209
|
if (history.current.length === 0)
|
|
151
210
|
return;
|
|
@@ -159,11 +218,18 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
159
218
|
return;
|
|
160
219
|
}
|
|
161
220
|
if (key.downArrow) {
|
|
221
|
+
if (inMentionMode && mentionList.length > 0) {
|
|
222
|
+
if (activeMentionIndex < mentionList.length - 1)
|
|
223
|
+
setMentionSelectedIndex(current => Math.min(mentionList.length - 1, current + 1));
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
162
226
|
if (filteredSuggestions.length > 0 && activeSuggestionIndex < filteredSuggestions.length - 1) {
|
|
163
227
|
setSelectedSuggestionIndex(current => Math.min(filteredSuggestions.length - 1, current + 1));
|
|
164
228
|
return;
|
|
165
229
|
}
|
|
166
|
-
if (filteredSuggestions.length === 0 && moveCursorVertically(1))
|
|
230
|
+
if (filteredSuggestions.length === 0 && !inMentionMode && moveCursorVertically(1))
|
|
231
|
+
return;
|
|
232
|
+
if (inMentionMode)
|
|
167
233
|
return;
|
|
168
234
|
preferredColumn.current = null;
|
|
169
235
|
if (historyIndex.current === null)
|
|
@@ -212,7 +278,9 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
212
278
|
const maxVisibleLines = 4;
|
|
213
279
|
const firstVisibleLine = Math.max(0, Math.min(currentCursorPosition.lineIndex - maxVisibleLines + 1, wrappedLines.length - maxVisibleLines));
|
|
214
280
|
const visibleLines = wrappedLines.slice(firstVisibleLine, firstVisibleLine + maxVisibleLines);
|
|
215
|
-
|
|
281
|
+
const displayList = inMentionMode ? mentionList : filteredSuggestions;
|
|
282
|
+
const displayActiveIndex = inMentionMode ? activeMentionIndex : activeSuggestionIndex;
|
|
283
|
+
return _jsxs(Box, { flexDirection: "column", width: "100%", children: [displayList.length > 0 && _jsx(Box, { flexDirection: "column", marginBottom: 1, children: displayList.map((suggestion, index) => _jsxs(Text, { color: index === displayActiveIndex ? theme.success : theme.muted, wrap: "truncate-end", children: [index === displayActiveIndex ? '› ' : ' ', suggestion.value, _jsxs(Text, { color: theme.muted, children: [" ", suggestion.kind ?? 'command', suggestion.description ? ` — ${suggestion.description}` : ''] })] }, suggestion.value)) }), value.length === 0 ? _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: theme.purple, children: "\u203A " }), _jsx(Text, { inverse: true, children: " " }), _jsxs(Text, { color: theme.muted, dimColor: true, children: [" ", placeholder ?? 'Type a message...'] })] }) : visibleLines.map((line, index) => {
|
|
216
284
|
const absoluteLineIndex = firstVisibleLine + index;
|
|
217
285
|
const isCursorLine = absoluteLineIndex === currentCursorPosition.lineIndex;
|
|
218
286
|
const lineCursor = isCursorLine ? Math.max(0, Math.min(displayCursor - line.start, line.text.length)) : -1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Human-readable byte sizes for display text (CLI rows, session placeholders). */
|
|
2
|
+
export function formatBytes(bytes) {
|
|
3
|
+
if (bytes < 1024)
|
|
4
|
+
return `${bytes} B`;
|
|
5
|
+
if (bytes < 1024 * 1024)
|
|
6
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
7
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
8
|
+
}
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -12,4 +12,3 @@ export interface WalkOptions {
|
|
|
12
12
|
filter?: (entry: WalkEntry) => boolean | Promise<boolean>;
|
|
13
13
|
}
|
|
14
14
|
export declare function walkDir(root: string, options?: WalkOptions): Promise<WalkEntry[]>;
|
|
15
|
-
export declare function listFilesRecursive(root: string): Promise<string[]>;
|
package/dist/utils/fs.js
CHANGED
|
@@ -34,7 +34,3 @@ export async function walkDir(root, options = {}) {
|
|
|
34
34
|
await walk(root);
|
|
35
35
|
return result;
|
|
36
36
|
}
|
|
37
|
-
export async function listFilesRecursive(root) {
|
|
38
|
-
const entries = await walkDir(root, { recursive: true });
|
|
39
|
-
return entries.filter(e => e.isFile).map(e => e.path).sort();
|
|
40
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
/** Open a file with the platform default handler. Tests mock this module. */
|
|
3
|
+
export function openPath(filePath) {
|
|
4
|
+
const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
5
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', filePath] : [filePath];
|
|
6
|
+
const child = spawn(command, args, { stdio: 'ignore', detached: true });
|
|
7
|
+
child.on('error', () => undefined);
|
|
8
|
+
child.unref();
|
|
9
|
+
}
|