@vybestack/llxprt-code 0.1.14 → 0.1.16
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/README.md +90 -2
- package/dist/package.json +4 -5
- package/dist/src/config/config.d.ts +4 -1
- package/dist/src/config/config.js +151 -54
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/extension.d.ts +1 -0
- package/dist/src/config/extension.js +4 -0
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/settings.d.ts +13 -3
- package/dist/src/config/settings.js +84 -23
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/gemini.d.ts +3 -0
- package/dist/src/gemini.js +212 -36
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/integration-tests/GITHUB_ACTIONS_README.md +41 -0
- package/dist/src/integration-tests/test-utils.d.ts +68 -0
- package/dist/src/integration-tests/test-utils.js +167 -0
- package/dist/src/integration-tests/test-utils.js.map +1 -0
- package/dist/src/nonInteractiveCli.js +24 -66
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/providers/IFileSystem.d.ts +42 -0
- package/dist/src/providers/IFileSystem.js +46 -0
- package/dist/src/providers/IFileSystem.js.map +1 -0
- package/dist/src/providers/providerConfigUtils.d.ts +0 -4
- package/dist/src/providers/providerConfigUtils.js +21 -52
- package/dist/src/providers/providerConfigUtils.js.map +1 -1
- package/dist/src/providers/providerManagerInstance.d.ts +6 -1
- package/dist/src/providers/providerManagerInstance.js +117 -82
- package/dist/src/providers/providerManagerInstance.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +13 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/CommandService.d.ts +8 -4
- package/dist/src/services/CommandService.js +24 -8
- package/dist/src/services/CommandService.js.map +1 -1
- package/dist/src/services/FileCommandLoader.d.ts +15 -3
- package/dist/src/services/FileCommandLoader.js +94 -42
- package/dist/src/services/FileCommandLoader.js.map +1 -1
- package/dist/src/services/McpPromptLoader.d.ts +25 -0
- package/dist/src/services/McpPromptLoader.js +192 -0
- package/dist/src/services/McpPromptLoader.js.map +1 -0
- package/dist/src/services/prompt-processors/shellProcessor.d.ts +32 -0
- package/dist/src/services/prompt-processors/shellProcessor.js +77 -0
- package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -0
- package/dist/src/services/prompt-processors/types.d.ts +4 -0
- package/dist/src/services/prompt-processors/types.js +4 -0
- package/dist/src/services/prompt-processors/types.js.map +1 -1
- package/dist/src/ui/App.js +325 -195
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.js +2 -5
- package/dist/src/ui/commands/aboutCommand.js.map +1 -1
- package/dist/src/ui/commands/baseurlCommand.js +54 -9
- package/dist/src/ui/commands/baseurlCommand.js.map +1 -1
- package/dist/src/ui/commands/chatCommand.js +39 -1
- package/dist/src/ui/commands/chatCommand.js.map +1 -1
- package/dist/src/ui/commands/diagnosticsCommand.d.ts +10 -0
- package/dist/src/ui/commands/diagnosticsCommand.js +122 -0
- package/dist/src/ui/commands/diagnosticsCommand.js.map +1 -0
- package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
- package/dist/src/ui/commands/directoryCommand.js +116 -0
- package/dist/src/ui/commands/directoryCommand.js.map +1 -0
- package/dist/src/ui/commands/ideCommand.js +101 -105
- package/dist/src/ui/commands/ideCommand.js.map +1 -1
- package/dist/src/ui/commands/initCommand.d.ts +7 -0
- package/dist/src/ui/commands/initCommand.js +108 -0
- package/dist/src/ui/commands/initCommand.js.map +1 -0
- package/dist/src/ui/commands/keyCommand.js +75 -11
- package/dist/src/ui/commands/keyCommand.js.map +1 -1
- package/dist/src/ui/commands/keyfileCommand.js +54 -13
- package/dist/src/ui/commands/keyfileCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +53 -8
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +2 -1
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/modelCommand.js +2 -5
- package/dist/src/ui/commands/modelCommand.js.map +1 -1
- package/dist/src/ui/commands/profileCommand.d.ts +10 -0
- package/dist/src/ui/commands/profileCommand.js +592 -0
- package/dist/src/ui/commands/profileCommand.js.map +1 -0
- package/dist/src/ui/commands/providerCommand.js +46 -3
- package/dist/src/ui/commands/providerCommand.js.map +1 -1
- package/dist/src/ui/commands/setCommand.d.ts +7 -0
- package/dist/src/ui/commands/setCommand.js +431 -0
- package/dist/src/ui/commands/setCommand.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.d.ts +7 -0
- package/dist/src/ui/commands/setupGithubCommand.js +49 -0
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +23 -4
- package/dist/src/ui/commands/types.js +1 -0
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/commands/vimCommand.js +0 -7
- package/dist/src/ui/commands/vimCommand.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.d.ts +3 -3
- package/dist/src/ui/components/ContextSummaryDisplay.js +8 -8
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
- package/dist/src/ui/components/DebugProfiler.js +26 -0
- package/dist/src/ui/components/DebugProfiler.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +2 -0
- package/dist/src/ui/components/Footer.js +5 -4
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Header.js +1 -1
- package/dist/src/ui/components/Header.js.map +1 -1
- package/dist/src/ui/components/Help.js +2 -2
- package/dist/src/ui/components/Help.js.map +1 -1
- package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +5 -4
- package/dist/src/ui/components/IDEContextDetailDisplay.js +6 -8
- package/dist/src/ui/components/IDEContextDetailDisplay.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.d.ts +2 -0
- package/dist/src/ui/components/InputPrompt.js +128 -13
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/LoadProfileDialog.d.ts +13 -0
- package/dist/src/ui/components/LoadProfileDialog.js +57 -0
- package/dist/src/ui/components/LoadProfileDialog.js.map +1 -0
- package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
- package/dist/src/ui/components/PrepareLabel.js +16 -0
- package/dist/src/ui/components/PrepareLabel.js.map +1 -0
- package/dist/src/ui/components/ProviderModelDialog.js +75 -28
- package/dist/src/ui/components/ProviderModelDialog.js.map +1 -1
- package/dist/src/ui/components/SecureKeyInput.d.ts +15 -0
- package/dist/src/ui/components/SecureKeyInput.js +58 -0
- package/dist/src/ui/components/SecureKeyInput.js.map +1 -0
- package/dist/src/ui/components/ShellConfirmationDialog.d.ts +15 -0
- package/dist/src/ui/components/ShellConfirmationDialog.js +45 -0
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.d.ts +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.js +3 -3
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
- package/dist/src/ui/components/Tips.js +1 -1
- package/dist/src/ui/components/Tips.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +15 -4
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/UserMessage.js +4 -1
- package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.d.ts +270 -2
- package/dist/src/ui/components/shared/text-buffer.js +410 -70
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +72 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.js +565 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -0
- package/dist/src/ui/containers/SessionController.js +14 -15
- package/dist/src/ui/containers/SessionController.js.map +1 -1
- package/dist/src/ui/contexts/VimModeContext.js +2 -2
- package/dist/src/ui/contexts/VimModeContext.js.map +1 -1
- package/dist/src/ui/editors/editorSettingsManager.js +2 -0
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.js +56 -48
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.d.ts +1 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js +139 -200
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +7 -3
- package/dist/src/ui/hooks/slashCommandProcessor.js +219 -130
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAuthCommand.js +9 -0
- package/dist/src/ui/hooks/useAuthCommand.js.map +1 -1
- package/dist/src/ui/hooks/useCompletion.d.ts +5 -5
- package/dist/src/ui/hooks/useCompletion.js +7 -402
- package/dist/src/ui/hooks/useCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useConsoleMessages.js +53 -37
- package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +58 -12
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.js +5 -2
- package/dist/src/ui/hooks/useKeypress.js.map +1 -1
- package/dist/src/ui/hooks/useLoadProfileDialog.d.ts +27 -0
- package/dist/src/ui/hooks/useLoadProfileDialog.js +138 -0
- package/dist/src/ui/hooks/useLoadProfileDialog.js.map +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js +0 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.js +54 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.d.ts +1 -0
- package/dist/src/ui/hooks/useShellHistory.js +30 -7
- package/dist/src/ui/hooks/useShellHistory.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.d.ts +24 -0
- package/dist/src/ui/hooks/useSlashCompletion.js +451 -0
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
- package/dist/src/ui/hooks/vim.d.ts +28 -0
- package/dist/src/ui/hooks/vim.js +630 -0
- package/dist/src/ui/hooks/vim.js.map +1 -0
- package/dist/src/ui/reducers/appReducer.d.ts +3 -2
- package/dist/src/ui/reducers/appReducer.js +1 -0
- package/dist/src/ui/reducers/appReducer.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.js +10 -1
- package/dist/src/ui/themes/theme-manager.js.map +1 -1
- package/dist/src/ui/themes/theme.d.ts +1 -0
- package/dist/src/ui/themes/theme.js +19 -4
- package/dist/src/ui/themes/theme.js.map +1 -1
- package/dist/src/ui/utils/renderLoopDetector.js +3 -3
- package/dist/src/ui/utils/renderLoopDetector.js.map +1 -1
- package/dist/src/ui/utils/secureInputHandler.d.ts +46 -0
- package/dist/src/ui/utils/secureInputHandler.js +128 -0
- package/dist/src/ui/utils/secureInputHandler.js.map +1 -0
- package/dist/src/ui/utils/textUtils.d.ts +0 -8
- package/dist/src/ui/utils/textUtils.js +0 -22
- package/dist/src/ui/utils/textUtils.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.d.ts +7 -1
- package/dist/src/ui/utils/updateCheck.js +59 -25
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/utils/events.d.ts +11 -0
- package/dist/src/utils/events.js +13 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +10 -0
- package/dist/src/utils/gitUtils.js +24 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/handleAutoUpdate.d.ts +11 -0
- package/dist/src/utils/handleAutoUpdate.js +101 -0
- package/dist/src/utils/handleAutoUpdate.js.map +1 -0
- package/dist/src/utils/installationInfo.d.ts +23 -0
- package/dist/src/utils/installationInfo.js +154 -0
- package/dist/src/utils/installationInfo.js.map +1 -0
- package/dist/src/utils/sandbox-macos-permissive-closed.sb +6 -0
- package/dist/src/utils/sandbox-macos-permissive-open.sb +6 -0
- package/dist/src/utils/sandbox-macos-permissive-proxied.sb +6 -0
- package/dist/src/utils/sandbox-macos-restrictive-closed.sb +6 -0
- package/dist/src/utils/sandbox-macos-restrictive-open.sb +6 -0
- package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +6 -0
- package/dist/src/utils/sandbox.d.ts +2 -2
- package/dist/src/utils/sandbox.js +35 -11
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/spawnWrapper.d.ts +7 -0
- package/dist/src/utils/spawnWrapper.js +8 -0
- package/dist/src/utils/spawnWrapper.js.map +1 -0
- package/dist/src/utils/updateEventEmitter.d.ts +11 -0
- package/dist/src/utils/updateEventEmitter.js +12 -0
- package/dist/src/utils/updateEventEmitter.js.map +1 -0
- package/dist/src/validateNonInterActiveAuth.d.ts +2 -1
- package/dist/src/validateNonInterActiveAuth.js +31 -5
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -5
- package/dist/src/providers/enhanceConfigWithProviders.d.ts +0 -12
- package/dist/src/providers/enhanceConfigWithProviders.js +0 -16
- package/dist/src/providers/enhanceConfigWithProviders.js.map +0 -1
@@ -3,119 +3,115 @@
|
|
3
3
|
* Copyright 2025 Google LLC
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
|
-
import {
|
7
|
-
import { IDEConnectionStatus } from '@vybestack/llxprt-code-core';
|
6
|
+
import { IDEConnectionStatus, getIdeDisplayName, getIdeInstaller, } from '@vybestack/llxprt-code-core';
|
8
7
|
import { CommandKind, } from './types.js';
|
9
|
-
import
|
10
|
-
import * as process from 'process';
|
11
|
-
import { glob } from 'glob';
|
12
|
-
import * as path from 'path';
|
13
|
-
const VSCODE_COMMAND = process.platform === 'win32' ? 'code.cmd' : 'code';
|
14
|
-
const VSCODE_COMPANION_EXTENSION_FOLDER = 'vscode-ide-companion';
|
15
|
-
function isVSCodeInstalled() {
|
16
|
-
try {
|
17
|
-
child_process.execSync(process.platform === 'win32'
|
18
|
-
? `where.exe ${VSCODE_COMMAND}`
|
19
|
-
: `command -v ${VSCODE_COMMAND}`, { stdio: 'ignore' });
|
20
|
-
return true;
|
21
|
-
}
|
22
|
-
catch {
|
23
|
-
return false;
|
24
|
-
}
|
25
|
-
}
|
8
|
+
import { SettingScope } from '../../config/settings.js';
|
26
9
|
export const ideCommand = (config) => {
|
27
|
-
if (!config?.
|
10
|
+
if (!config?.getIdeModeFeature()) {
|
28
11
|
return null;
|
29
12
|
}
|
30
|
-
|
13
|
+
const currentIDE = config.getIdeClient()?.getCurrentIde();
|
14
|
+
if (!currentIDE) {
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
const ideSlashCommand = {
|
31
18
|
name: 'ide',
|
32
19
|
description: 'manage IDE integration',
|
33
20
|
kind: CommandKind.BUILT_IN,
|
34
|
-
subCommands: [
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
return {
|
60
|
-
type: 'message',
|
61
|
-
messageType: 'error',
|
62
|
-
content,
|
63
|
-
};
|
64
|
-
}
|
65
|
-
}
|
66
|
-
},
|
67
|
-
},
|
68
|
-
{
|
69
|
-
name: 'install',
|
70
|
-
description: 'install required VS Code companion extension',
|
71
|
-
kind: CommandKind.BUILT_IN,
|
72
|
-
action: async (context) => {
|
73
|
-
if (!isVSCodeInstalled()) {
|
74
|
-
context.ui.addItem({
|
75
|
-
type: 'error',
|
76
|
-
text: `VS Code command-line tool "${VSCODE_COMMAND}" not found in your PATH.`,
|
77
|
-
}, Date.now());
|
78
|
-
return;
|
79
|
-
}
|
80
|
-
const bundleDir = path.dirname(fileURLToPath(import.meta.url));
|
81
|
-
// The VSIX file is copied to the bundle directory as part of the build.
|
82
|
-
let vsixFiles = glob.sync(path.join(bundleDir, '*.vsix'));
|
83
|
-
if (vsixFiles.length === 0) {
|
84
|
-
// If the VSIX file is not in the bundle, it might be a dev
|
85
|
-
// environment running with `npm start`. Look for it in the original
|
86
|
-
// package location, relative to the bundle dir.
|
87
|
-
const devPath = path.join(bundleDir, '..', '..', '..', '..', '..', VSCODE_COMPANION_EXTENSION_FOLDER, '*.vsix');
|
88
|
-
vsixFiles = glob.sync(devPath);
|
89
|
-
}
|
90
|
-
if (vsixFiles.length === 0) {
|
91
|
-
context.ui.addItem({
|
92
|
-
type: 'error',
|
93
|
-
text: 'Could not find the required VS Code companion extension. Please file a bug via /bug.',
|
94
|
-
}, Date.now());
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
const vsixPath = vsixFiles[0];
|
98
|
-
const command = `${VSCODE_COMMAND} --install-extension ${vsixPath} --force`;
|
99
|
-
context.ui.addItem({
|
100
|
-
type: 'info',
|
101
|
-
text: `Installing VS Code companion extension...`,
|
102
|
-
}, Date.now());
|
103
|
-
try {
|
104
|
-
child_process.execSync(command, { stdio: 'pipe' });
|
105
|
-
context.ui.addItem({
|
106
|
-
type: 'info',
|
107
|
-
text: 'VS Code companion extension installed successfully. Restart llxprt in a fresh terminal window.',
|
108
|
-
}, Date.now());
|
109
|
-
}
|
110
|
-
catch (_error) {
|
111
|
-
context.ui.addItem({
|
112
|
-
type: 'error',
|
113
|
-
text: `Failed to install VS Code companion extension.`,
|
114
|
-
}, Date.now());
|
21
|
+
subCommands: [],
|
22
|
+
};
|
23
|
+
const statusCommand = {
|
24
|
+
name: 'status',
|
25
|
+
description: 'check status of IDE integration',
|
26
|
+
kind: CommandKind.BUILT_IN,
|
27
|
+
action: (_context) => {
|
28
|
+
const connection = config.getIdeClient()?.getConnectionStatus();
|
29
|
+
switch (connection?.status) {
|
30
|
+
case IDEConnectionStatus.Connected:
|
31
|
+
return {
|
32
|
+
type: 'message',
|
33
|
+
messageType: 'info',
|
34
|
+
content: `🟢 Connected`,
|
35
|
+
};
|
36
|
+
case IDEConnectionStatus.Connecting:
|
37
|
+
return {
|
38
|
+
type: 'message',
|
39
|
+
messageType: 'info',
|
40
|
+
content: `🟡 Connecting...`,
|
41
|
+
};
|
42
|
+
default: {
|
43
|
+
let content = `🔴 Disconnected`;
|
44
|
+
if (connection?.details) {
|
45
|
+
content += `: ${connection.details}`;
|
115
46
|
}
|
116
|
-
|
117
|
-
|
118
|
-
|
47
|
+
return {
|
48
|
+
type: 'message',
|
49
|
+
messageType: 'error',
|
50
|
+
content,
|
51
|
+
};
|
52
|
+
}
|
53
|
+
}
|
54
|
+
},
|
55
|
+
};
|
56
|
+
const installCommand = {
|
57
|
+
name: 'install',
|
58
|
+
description: `install required IDE companion ${getIdeDisplayName(currentIDE)} extension `,
|
59
|
+
kind: CommandKind.BUILT_IN,
|
60
|
+
action: async (context) => {
|
61
|
+
const installer = getIdeInstaller(currentIDE);
|
62
|
+
if (!installer) {
|
63
|
+
context.ui.addItem({
|
64
|
+
type: 'error',
|
65
|
+
text: 'No installer available for your configured IDE.',
|
66
|
+
}, Date.now());
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
context.ui.addItem({
|
70
|
+
type: 'info',
|
71
|
+
text: `Installing IDE companion extension...`,
|
72
|
+
}, Date.now());
|
73
|
+
const result = await installer.install();
|
74
|
+
context.ui.addItem({
|
75
|
+
type: result.success ? 'info' : 'error',
|
76
|
+
text: result.message,
|
77
|
+
}, Date.now());
|
78
|
+
},
|
79
|
+
};
|
80
|
+
const enableCommand = {
|
81
|
+
name: 'enable',
|
82
|
+
description: 'enable IDE integration',
|
83
|
+
kind: CommandKind.BUILT_IN,
|
84
|
+
action: async (context) => {
|
85
|
+
context.services.settings.setValue(SettingScope.User, 'ideMode', true);
|
86
|
+
config.setIdeMode(true);
|
87
|
+
config.setIdeClientConnected();
|
88
|
+
},
|
119
89
|
};
|
90
|
+
const disableCommand = {
|
91
|
+
name: 'disable',
|
92
|
+
description: 'disable IDE integration',
|
93
|
+
kind: CommandKind.BUILT_IN,
|
94
|
+
action: async (context) => {
|
95
|
+
context.services.settings.setValue(SettingScope.User, 'ideMode', false);
|
96
|
+
config.setIdeMode(false);
|
97
|
+
config.setIdeClientDisconnected();
|
98
|
+
},
|
99
|
+
};
|
100
|
+
const ideModeEnabled = config.getIdeMode();
|
101
|
+
if (ideModeEnabled) {
|
102
|
+
ideSlashCommand.subCommands = [
|
103
|
+
disableCommand,
|
104
|
+
statusCommand,
|
105
|
+
installCommand,
|
106
|
+
];
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
ideSlashCommand.subCommands = [
|
110
|
+
enableCommand,
|
111
|
+
statusCommand,
|
112
|
+
installCommand,
|
113
|
+
];
|
114
|
+
}
|
115
|
+
return ideSlashCommand;
|
120
116
|
};
|
121
117
|
//# sourceMappingURL=ideCommand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ideCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/ideCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
1
|
+
{"version":3,"file":"ideCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/ideCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAIL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAAM,CAAC,MA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AC,IAAI,CAAC,CAAC;YACxB,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACjC,CAAC;KACF,CAAC;IAEF,MAAM,cAAc,GAAiB;QACnC,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE,WAAW,CAAC,QAAQ;QAC1B,MAAM,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;YACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YACxE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACzB,MAAM,CAAC,wBAAwB,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAC3C,IAAI,cAAc,EAAE,CAAC;QACnB,eAAe,CAAC,WAAW,GAAG;YAC5B,cAAc;YACd,aAAa;YACb,cAAc;SACf,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,eAAe,CAAC,WAAW,GAAG;YAC5B,aAAa;YACb,aAAa;YACb,cAAc;SACf,CAAC;IACJ,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC"}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2025 Google LLC
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
import * as fs from 'fs';
|
7
|
+
import * as path from 'path';
|
8
|
+
import * as os from 'os';
|
9
|
+
import { CommandKind, } from './types.js';
|
10
|
+
import { PromptService } from '@vybestack/llxprt-code-core';
|
11
|
+
/**
|
12
|
+
* Get the init command prompt from the prompt service
|
13
|
+
*/
|
14
|
+
async function getInitCommandPrompt() {
|
15
|
+
try {
|
16
|
+
const baseDir = process.env.LLXPRT_PROMPTS_DIR ||
|
17
|
+
path.join(os.homedir(), '.llxprt', 'prompts');
|
18
|
+
const promptService = new PromptService({
|
19
|
+
baseDir,
|
20
|
+
debugMode: process.env.DEBUG === 'true',
|
21
|
+
});
|
22
|
+
await promptService.initialize();
|
23
|
+
try {
|
24
|
+
return await promptService.loadPrompt('commands/init-command.md');
|
25
|
+
}
|
26
|
+
catch (error) {
|
27
|
+
console.warn('Failed to load init command prompt from file, using fallback:', error);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
catch (error) {
|
31
|
+
console.warn('Failed to initialize prompt service, using fallback:', error);
|
32
|
+
}
|
33
|
+
// Fallback to hardcoded prompt
|
34
|
+
return getFallbackInitCommandPrompt();
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Fallback prompt if the prompt service is not available
|
38
|
+
*/
|
39
|
+
function getFallbackInitCommandPrompt() {
|
40
|
+
return `You are an AI agent that brings the power of multiple LLM providers directly into the terminal. Your task is to analyze the current directory and generate a comprehensive LLXPRT.md file to be used as instructional context for future interactions.
|
41
|
+
|
42
|
+
**Analysis Process:**
|
43
|
+
|
44
|
+
1. **Initial Exploration:**
|
45
|
+
* Start by listing the files and directories to get a high-level overview of the structure.
|
46
|
+
* Read the README file (e.g., \`README.md\`, \`README.txt\`) if it exists. This is often the best place to start.
|
47
|
+
|
48
|
+
2. **Iterative Deep Dive (up to 10 files):**
|
49
|
+
* Based on your initial findings, select a few files that seem most important (e.g., configuration files, main source files, documentation).
|
50
|
+
* Read them. As you learn more, refine your understanding and decide which files to read next. You don't need to decide all 10 files at once. Let your discoveries guide your exploration.
|
51
|
+
|
52
|
+
3. **Identify Project Type:**
|
53
|
+
* **Code Project:** Look for clues like \`package.json\`, \`requirements.txt\`, \`pom.xml\`, \`go.mod\`, \`Cargo.toml\`, \`build.gradle\`, or a \`src\` directory. If you find them, this is likely a software project.
|
54
|
+
* **Non-Code Project:** If you don't find code-related files, this might be a directory for documentation, research papers, notes, or something else.
|
55
|
+
|
56
|
+
**LLXPRT.md Content Generation:**
|
57
|
+
|
58
|
+
**For a Code Project:**
|
59
|
+
|
60
|
+
* **Project Overview:** Write a clear and concise summary of the project's purpose, main technologies, and architecture.
|
61
|
+
* **Building and Running:** Document the key commands for building, running, and testing the project. Infer these from the files you've read (e.g., \`scripts\` in \`package.json\`, \`Makefile\`, etc.). If you can't find explicit commands, provide a placeholder with a TODO.
|
62
|
+
* **Development Conventions:** Describe any coding styles, testing practices, or contribution guidelines you can infer from the codebase.
|
63
|
+
|
64
|
+
**For a Non-Code Project:**
|
65
|
+
|
66
|
+
* **Directory Overview:** Describe the purpose and contents of the directory. What is it for? What kind of information does it hold?
|
67
|
+
* **Key Files:** List the most important files and briefly explain what they contain.
|
68
|
+
* **Usage:** Explain how the contents of this directory are intended to be used.
|
69
|
+
|
70
|
+
**Final Output:**
|
71
|
+
|
72
|
+
Write the complete content to the \`LLXPRT.md\` file. The output must be well-formatted Markdown.`;
|
73
|
+
}
|
74
|
+
export const initCommand = {
|
75
|
+
name: 'init',
|
76
|
+
description: 'Analyzes the project and creates a tailored LLXPRT.md file.',
|
77
|
+
kind: CommandKind.BUILT_IN,
|
78
|
+
action: async (context, _args) => {
|
79
|
+
if (!context.services.config) {
|
80
|
+
return {
|
81
|
+
type: 'message',
|
82
|
+
messageType: 'error',
|
83
|
+
content: 'Configuration not available.',
|
84
|
+
};
|
85
|
+
}
|
86
|
+
const targetDir = context.services.config.getTargetDir();
|
87
|
+
const llxprtMdPath = path.join(targetDir, 'LLXPRT.md');
|
88
|
+
if (fs.existsSync(llxprtMdPath)) {
|
89
|
+
return {
|
90
|
+
type: 'message',
|
91
|
+
messageType: 'info',
|
92
|
+
content: 'A LLXPRT.md file already exists in this directory. No changes were made.',
|
93
|
+
};
|
94
|
+
}
|
95
|
+
// Create an empty LLXPRT.md file
|
96
|
+
fs.writeFileSync(llxprtMdPath, '', 'utf8');
|
97
|
+
context.ui.addItem({
|
98
|
+
type: 'info',
|
99
|
+
text: 'Empty LLXPRT.md created. Now analyzing the project to populate it.',
|
100
|
+
}, Date.now());
|
101
|
+
const initPrompt = await getInitCommandPrompt();
|
102
|
+
return {
|
103
|
+
type: 'submit_prompt',
|
104
|
+
content: initPrompt,
|
105
|
+
};
|
106
|
+
},
|
107
|
+
};
|
108
|
+
//# sourceMappingURL=initCommand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"initCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/initCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAIL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;GAEG;AACH,KAAK,UAAU,oBAAoB;IACjC,IAAI,CAAC;QACH,MAAM,OAAO,GACX,OAAO,CAAC,GAAG,CAAC,kBAAkB;YAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC;YACtC,OAAO;YACP,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM;SACxC,CAAC,CAAC;QACH,MAAM,aAAa,CAAC,UAAU,EAAE,CAAC;QAEjC,IAAI,CAAC;YACH,OAAO,MAAM,aAAa,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;QACpE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CACV,+DAA+D,EAC/D,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,sDAAsD,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;IAED,+BAA+B;IAC/B,OAAO,4BAA4B,EAAE,CAAC;AACxC,CA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0
|
5
5
|
*/
|
6
6
|
import { CommandKind, } from './types.js';
|
7
|
-
import {
|
8
|
-
import { setProviderApiKey } from '../../providers/providerConfigUtils.js';
|
7
|
+
import { AuthType } from '@vybestack/llxprt-code-core';
|
9
8
|
export const keyCommand = {
|
10
9
|
name: 'key',
|
11
10
|
description: 'set or remove API key for the current provider',
|
12
11
|
kind: CommandKind.BUILT_IN,
|
13
12
|
action: async (context, args) => {
|
14
|
-
const
|
13
|
+
const config = context.services.config;
|
14
|
+
if (!config) {
|
15
|
+
return {
|
16
|
+
type: 'message',
|
17
|
+
messageType: 'error',
|
18
|
+
content: 'No configuration available',
|
19
|
+
};
|
20
|
+
}
|
21
|
+
const providerManager = config.getProviderManager();
|
22
|
+
if (!providerManager) {
|
23
|
+
return {
|
24
|
+
type: 'message',
|
25
|
+
messageType: 'error',
|
26
|
+
content: 'No provider manager available',
|
27
|
+
};
|
28
|
+
}
|
29
|
+
const activeProvider = providerManager.getActiveProvider();
|
30
|
+
const providerName = activeProvider.name;
|
15
31
|
const apiKey = args?.trim();
|
16
|
-
|
17
|
-
|
18
|
-
|
32
|
+
// If no key provided or 'none', remove the key
|
33
|
+
if (!apiKey || apiKey.toLowerCase() === 'none') {
|
34
|
+
// Clear the API key
|
35
|
+
if (activeProvider.setApiKey) {
|
36
|
+
activeProvider.setApiKey('');
|
37
|
+
config.setEphemeralSetting('auth-key', undefined);
|
38
|
+
// If this is the Gemini provider, we might need to switch auth mode
|
39
|
+
const requiresAuthRefresh = providerName === 'gemini';
|
40
|
+
if (requiresAuthRefresh) {
|
41
|
+
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
42
|
+
}
|
43
|
+
const isPaidMode = activeProvider.isPaidMode?.() ?? true;
|
44
|
+
const paymentMessage = !isPaidMode && providerName === 'gemini'
|
45
|
+
? '\n✅ You are now in FREE MODE - using OAuth authentication'
|
46
|
+
: '';
|
47
|
+
return {
|
48
|
+
type: 'message',
|
49
|
+
messageType: 'info',
|
50
|
+
content: `API key removed for provider '${providerName}'${paymentMessage}`,
|
51
|
+
};
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
return {
|
55
|
+
type: 'message',
|
56
|
+
messageType: 'error',
|
57
|
+
content: `Provider '${providerName}' does not support API key updates`,
|
58
|
+
};
|
59
|
+
}
|
60
|
+
}
|
61
|
+
// Set the API key
|
62
|
+
if (activeProvider.setApiKey) {
|
63
|
+
activeProvider.setApiKey(apiKey);
|
64
|
+
config.setEphemeralSetting('auth-key', apiKey);
|
65
|
+
// If this is the Gemini provider, we need to refresh auth to use API key mode
|
66
|
+
const requiresAuthRefresh = providerName === 'gemini';
|
67
|
+
if (requiresAuthRefresh) {
|
68
|
+
await config.refreshAuth(AuthType.USE_GEMINI);
|
69
|
+
}
|
70
|
+
// Check if we're now in paid mode
|
71
|
+
const isPaidMode = activeProvider.isPaidMode?.() ?? true;
|
72
|
+
const paymentWarning = isPaidMode
|
73
|
+
? '\n⚠️ You are now in PAID MODE - API usage will be charged to your account'
|
74
|
+
: '';
|
75
|
+
// Trigger payment mode check if available
|
19
76
|
const extendedContext = context;
|
20
77
|
if (extendedContext.checkPaymentModeChange) {
|
21
78
|
setTimeout(extendedContext.checkPaymentModeChange, 100);
|
22
79
|
}
|
80
|
+
return {
|
81
|
+
type: 'message',
|
82
|
+
messageType: 'info',
|
83
|
+
content: `API key updated for provider '${providerName}'${paymentWarning}`,
|
84
|
+
};
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
return {
|
88
|
+
type: 'message',
|
89
|
+
messageType: 'error',
|
90
|
+
content: `Provider '${providerName}' does not support API key updates`,
|
91
|
+
};
|
23
92
|
}
|
24
|
-
return {
|
25
|
-
type: 'message',
|
26
|
-
messageType: result.success ? 'info' : 'error',
|
27
|
-
content: result.message,
|
28
|
-
};
|
29
93
|
},
|
30
94
|
};
|
31
95
|
//# sourceMappingURL=keyCommand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"keyCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/keyCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"keyCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/keyCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,gDAAgD;IAC7D,IAAI,EAAE,WAAW,CAAC,QAAQ;IAC1B,MAAM,EAAE,KAAK,EACX,OAAuB,EACvB,IAAY,EACkB,EAAE;QAChC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,OAAO;gBACpB,OAAO,EAAE,4BAA4B;aACtC,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACpD,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,OAAO;gBACpB,OAAO,EAAE,+BAA+B;aACzC,CAAC;QACJ,CAAC;QAED,MAAM,cAAc,GAAG,eAAe,CAAC,iBAAiB,EAAE,CAAC;QAC3D,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC;QAE5B,+CAA+C;QAC/C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;YAC/C,oBAAoB;YACpB,IAAI,cAAc,CAAC,SAAS,EAAE,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AAM,cAAc,GAAG,UAAU;gBAC/B,CAAC,CAAC,4EAA4E;gBAC9E,CAAC,CAAC,EAAE,CAAC;YAEP,0CAA0C;YAC1C,MAAM,eAAe,GAAG,OAEvB,CAAC;YACF,IAAI,eAAe,CAAC,sBAAsB,EAAE,CAAC;gBAC3C,UAAU,CAAC,eAAe,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,MAAM;gBACnB,OAAO,EAAE,iCAAiC,YAAY,IAAI,cAAc,EAAE;aAC3E,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,OAAO;gBACpB,OAAO,EAAE,aAAa,YAAY,oCAAoC;aACvE,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
@@ -5,7 +5,6 @@
|
|
5
5
|
*/
|
6
6
|
import { CommandKind, } from './types.js';
|
7
7
|
import { getProviderManager } from '../../providers/providerManagerInstance.js';
|
8
|
-
import { setProviderApiKeyFromFile } from '../../providers/providerConfigUtils.js';
|
9
8
|
import { promises as fs } from 'fs';
|
10
9
|
import path from 'path';
|
11
10
|
import { homedir } from 'os';
|
@@ -79,20 +78,62 @@ export const keyfileCommand = {
|
|
79
78
|
};
|
80
79
|
}
|
81
80
|
}
|
82
|
-
//
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
81
|
+
// Verify keyfile exists and read the key
|
82
|
+
try {
|
83
|
+
const resolvedPath = filePath.replace(/^~/, homedir());
|
84
|
+
// Check if file exists
|
85
|
+
await fs.access(resolvedPath);
|
86
|
+
// Read the key to set it on the provider
|
87
|
+
const apiKey = (await fs.readFile(resolvedPath, 'utf-8')).trim();
|
88
|
+
if (!apiKey) {
|
89
|
+
return {
|
90
|
+
type: 'message',
|
91
|
+
messageType: 'error',
|
92
|
+
content: 'The specified file is empty',
|
93
|
+
};
|
94
|
+
}
|
95
|
+
// Set API key on provider
|
96
|
+
const activeProvider = providerManager.getActiveProvider();
|
97
|
+
const providerName = activeProvider.name;
|
98
|
+
if (activeProvider.setApiKey) {
|
99
|
+
activeProvider.setApiKey(apiKey);
|
100
|
+
// Store the keyfile PATH in ephemeral settings, not the key itself
|
101
|
+
if (context.services.config) {
|
102
|
+
context.services.config.setEphemeralSetting('auth-keyfile', filePath);
|
103
|
+
// Remove any stored auth-key since we're using keyfile
|
104
|
+
context.services.config.setEphemeralSetting('auth-key', undefined);
|
105
|
+
}
|
106
|
+
// Check if we're now in paid mode
|
107
|
+
const isPaidMode = activeProvider.isPaidMode?.() ?? true;
|
108
|
+
const paymentWarning = isPaidMode
|
109
|
+
? '\n⚠️ You are now in PAID MODE - API usage will be charged to your account'
|
110
|
+
: '';
|
111
|
+
// Trigger payment mode check if available
|
112
|
+
const extendedContext = context;
|
113
|
+
if (extendedContext.checkPaymentModeChange) {
|
114
|
+
setTimeout(extendedContext.checkPaymentModeChange, 100);
|
115
|
+
}
|
116
|
+
return {
|
117
|
+
type: 'message',
|
118
|
+
messageType: 'info',
|
119
|
+
content: `API key loaded from ${resolvedPath} for provider '${providerName}'${paymentWarning}`,
|
120
|
+
};
|
121
|
+
}
|
122
|
+
else {
|
123
|
+
return {
|
124
|
+
type: 'message',
|
125
|
+
messageType: 'error',
|
126
|
+
content: `Provider '${providerName}' does not support API key updates`,
|
127
|
+
};
|
89
128
|
}
|
90
129
|
}
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
130
|
+
catch (error) {
|
131
|
+
return {
|
132
|
+
type: 'message',
|
133
|
+
messageType: 'error',
|
134
|
+
content: `Failed to load keyfile: ${error instanceof Error ? error.message : String(error)}`,
|
135
|
+
};
|
136
|
+
}
|
96
137
|
}
|
97
138
|
catch (error) {
|
98
139
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"keyfileCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/keyfileCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"keyfileCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/keyfileCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,8CAA8C;IAC3D,IAAI,EAAE,WAAW,CAAC,QAAQ;IAC1B,MAAM,EAAE,KAAK,EACX,OAAuB,EACvB,IAAY,EACkB,EAAE;QAChC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC;QAE9B,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,eAAe,CAAC,iBAAiB,EAAE,CAAC;YAC3D,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC;YAEzC,kDAAkD;YAClD,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;gBACjC,iCAAiC;gBACjC,MAAM,YAAY,GAAG;oBACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,YAAY,MAAM,CAAC;oBAC5C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,YAAY,MAAM,CAAC;oBAC5C,IAAI,CAAC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