@google/gemini-cli 0.1.19 → 0.1.21
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 +1 -1
- package/dist/package.json +4 -4
- package/dist/src/config/config.d.ts +2 -2
- package/dist/src/config/config.js +62 -19
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/keyBindings.js +4 -0
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +0 -9
- package/dist/src/config/settingsSchema.js +0 -9
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/trustedFolders.d.ts +36 -0
- package/dist/src/config/trustedFolders.js +112 -0
- package/dist/src/config/trustedFolders.js.map +1 -0
- package/dist/src/gemini.js +7 -4
- 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/nonInteractiveCli.js +2 -3
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +2 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/ui/App.js +18 -8
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/IdeIntegrationNudge.d.ts +7 -3
- package/dist/src/ui/IdeIntegrationNudge.js +31 -10
- package/dist/src/ui/IdeIntegrationNudge.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +2 -4
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/ideCommand.js +3 -3
- package/dist/src/ui/commands/ideCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +4 -0
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/terminalSetupCommand.d.ts +13 -0
- package/dist/src/ui/commands/terminalSetupCommand.js +41 -0
- package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +1 -0
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/AuthDialog.js +5 -4
- package/dist/src/ui/components/AuthDialog.js.map +1 -1
- package/dist/src/ui/components/AuthInProgress.js +5 -4
- package/dist/src/ui/components/AuthInProgress.js.map +1 -1
- package/dist/src/ui/components/DebugProfiler.js +5 -4
- package/dist/src/ui/components/DebugProfiler.js.map +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js +6 -5
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.js +5 -4
- package/dist/src/ui/components/FolderTrustDialog.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +7 -1
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.js +12 -10
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js +5 -4
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.js +6 -5
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +7 -6
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.js +10 -8
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.js +32 -10
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.js +2 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +67 -46
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +5 -5
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.d.ts +4 -0
- package/dist/src/ui/hooks/useFocus.js +4 -4
- package/dist/src/ui/hooks/useFocus.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.d.ts +3 -2
- package/dist/src/ui/hooks/useFolderTrust.js +24 -9
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +5 -6
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.d.ts +9 -1
- package/dist/src/ui/hooks/useKeypress.js +197 -8
- package/dist/src/ui/hooks/useKeypress.js.map +1 -1
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +15 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +20 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +1 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +5 -4
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +5 -4
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -1
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js +5 -4
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -1
- package/dist/src/ui/utils/kittyProtocolDetector.d.ts +13 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js +88 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -0
- package/dist/src/ui/utils/platformConstants.d.ts +38 -0
- package/dist/src/ui/utils/platformConstants.js +39 -0
- package/dist/src/ui/utils/platformConstants.js.map +1 -0
- package/dist/src/ui/utils/terminalSetup.d.ts +30 -0
- package/dist/src/ui/utils/terminalSetup.js +281 -0
- package/dist/src/ui/utils/terminalSetup.js.map +1 -0
- package/dist/src/utils/checks.d.ts +19 -0
- package/dist/src/utils/checks.js +24 -0
- package/dist/src/utils/checks.js.map +1 -0
- package/dist/src/zed-integration/acp.d.ts +63 -0
- package/dist/src/{acp → zed-integration}/acp.js +76 -44
- package/dist/src/zed-integration/acp.js.map +1 -0
- package/dist/src/zed-integration/schema.d.ts +11679 -0
- package/dist/src/zed-integration/schema.js +305 -0
- package/dist/src/zed-integration/schema.js.map +1 -0
- package/dist/src/zed-integration/zedIntegration.d.ts +10 -0
- package/dist/src/{acp/acpPeer.js → zed-integration/zedIntegration.js} +333 -187
- package/dist/src/zed-integration/zedIntegration.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/google-gemini-cli-0.1.18.tgz +0 -0
- package/dist/src/acp/acp.d.ts +0 -208
- package/dist/src/acp/acp.js.map +0 -1
- package/dist/src/acp/acpPeer.d.ts +0 -8
- package/dist/src/acp/acpPeer.js.map +0 -1
- package/dist/src/ui/utils/errorParsing.d.ts +0 -7
- package/dist/src/ui/utils/errorParsing.js +0 -90
- package/dist/src/ui/utils/errorParsing.js.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
let detectionComplete = false;
|
|
7
|
+
let protocolSupported = false;
|
|
8
|
+
let protocolEnabled = false;
|
|
9
|
+
/**
|
|
10
|
+
* Detects Kitty keyboard protocol support.
|
|
11
|
+
* Definitive document about this protocol lives at https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
|
12
|
+
* This function should be called once at app startup.
|
|
13
|
+
*/
|
|
14
|
+
export async function detectAndEnableKittyProtocol() {
|
|
15
|
+
if (detectionComplete) {
|
|
16
|
+
return protocolSupported;
|
|
17
|
+
}
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
20
|
+
detectionComplete = true;
|
|
21
|
+
resolve(false);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const originalRawMode = process.stdin.isRaw;
|
|
25
|
+
if (!originalRawMode) {
|
|
26
|
+
process.stdin.setRawMode(true);
|
|
27
|
+
}
|
|
28
|
+
let responseBuffer = '';
|
|
29
|
+
let progressiveEnhancementReceived = false;
|
|
30
|
+
let checkFinished = false;
|
|
31
|
+
const handleData = (data) => {
|
|
32
|
+
responseBuffer += data.toString();
|
|
33
|
+
// Check for progressive enhancement response (CSI ? <flags> u)
|
|
34
|
+
if (responseBuffer.includes('\x1b[?') && responseBuffer.includes('u')) {
|
|
35
|
+
progressiveEnhancementReceived = true;
|
|
36
|
+
}
|
|
37
|
+
// Check for device attributes response (CSI ? <attrs> c)
|
|
38
|
+
if (responseBuffer.includes('\x1b[?') && responseBuffer.includes('c')) {
|
|
39
|
+
if (!checkFinished) {
|
|
40
|
+
checkFinished = true;
|
|
41
|
+
process.stdin.removeListener('data', handleData);
|
|
42
|
+
if (!originalRawMode) {
|
|
43
|
+
process.stdin.setRawMode(false);
|
|
44
|
+
}
|
|
45
|
+
if (progressiveEnhancementReceived) {
|
|
46
|
+
// Enable the protocol
|
|
47
|
+
process.stdout.write('\x1b[>1u');
|
|
48
|
+
protocolSupported = true;
|
|
49
|
+
protocolEnabled = true;
|
|
50
|
+
// Set up cleanup on exit
|
|
51
|
+
process.on('exit', disableProtocol);
|
|
52
|
+
process.on('SIGTERM', disableProtocol);
|
|
53
|
+
}
|
|
54
|
+
detectionComplete = true;
|
|
55
|
+
resolve(protocolSupported);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
process.stdin.on('data', handleData);
|
|
60
|
+
// Send queries
|
|
61
|
+
process.stdout.write('\x1b[?u'); // Query progressive enhancement
|
|
62
|
+
process.stdout.write('\x1b[c'); // Query device attributes
|
|
63
|
+
// Timeout after 50ms
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
if (!checkFinished) {
|
|
66
|
+
process.stdin.removeListener('data', handleData);
|
|
67
|
+
if (!originalRawMode) {
|
|
68
|
+
process.stdin.setRawMode(false);
|
|
69
|
+
}
|
|
70
|
+
detectionComplete = true;
|
|
71
|
+
resolve(false);
|
|
72
|
+
}
|
|
73
|
+
}, 50);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function disableProtocol() {
|
|
77
|
+
if (protocolEnabled) {
|
|
78
|
+
process.stdout.write('\x1b[<u');
|
|
79
|
+
protocolEnabled = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function isKittyProtocolEnabled() {
|
|
83
|
+
return protocolEnabled;
|
|
84
|
+
}
|
|
85
|
+
export function isKittyProtocolSupported() {
|
|
86
|
+
return protocolSupported;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=kittyProtocolDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kittyProtocolDetector.js","sourceRoot":"","sources":["../../../../src/ui/utils/kittyProtocolDetector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAC9B,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAC9B,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClD,iBAAiB,GAAG,IAAI,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO;QACT,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC5C,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,cAAc,GAAG,EAAE,CAAC;QACx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eAAe;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,gCAAgC;QACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,0BAA0B;QAE1D,qBAAqB;QACrB,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;gBACjD,IAAI,CAAC,eAAe,EAAE,CAAC;oBACrB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBAClC,CAAC;gBACD,iBAAiB,GAAG,IAAI,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;QACH,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe;IACtB,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChC,eAAe,GAAG,KAAK,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Terminal Platform Constants
|
|
8
|
+
*
|
|
9
|
+
* This file contains terminal-related constants used throughout the application,
|
|
10
|
+
* specifically for handling keyboard inputs and terminal protocols.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Kitty keyboard protocol sequences for enhanced keyboard input.
|
|
14
|
+
* @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
|
15
|
+
*/
|
|
16
|
+
export declare const KITTY_CTRL_C = "[99;5u";
|
|
17
|
+
/**
|
|
18
|
+
* Timing constants for terminal interactions
|
|
19
|
+
*/
|
|
20
|
+
export declare const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
|
|
21
|
+
/**
|
|
22
|
+
* VS Code terminal integration constants
|
|
23
|
+
*/
|
|
24
|
+
export declare const VSCODE_SHIFT_ENTER_SEQUENCE = "\\\r\n";
|
|
25
|
+
/**
|
|
26
|
+
* Backslash + Enter detection window in milliseconds.
|
|
27
|
+
* Used to detect Shift+Enter pattern where backslash
|
|
28
|
+
* is followed by Enter within this timeframe.
|
|
29
|
+
*/
|
|
30
|
+
export declare const BACKSLASH_ENTER_DETECTION_WINDOW_MS = 5;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum expected length of a Kitty keyboard protocol sequence.
|
|
33
|
+
* Format: ESC [ <keycode> ; <modifiers> u/~
|
|
34
|
+
* Example: \x1b[13;2u (Shift+Enter) = 8 chars
|
|
35
|
+
* Longest reasonable: \x1b[127;15~ = 11 chars (Del with all modifiers)
|
|
36
|
+
* We use 12 to provide a small buffer.
|
|
37
|
+
*/
|
|
38
|
+
export declare const MAX_KITTY_SEQUENCE_LENGTH = 12;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Terminal Platform Constants
|
|
8
|
+
*
|
|
9
|
+
* This file contains terminal-related constants used throughout the application,
|
|
10
|
+
* specifically for handling keyboard inputs and terminal protocols.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Kitty keyboard protocol sequences for enhanced keyboard input.
|
|
14
|
+
* @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
|
15
|
+
*/
|
|
16
|
+
export const KITTY_CTRL_C = '[99;5u';
|
|
17
|
+
/**
|
|
18
|
+
* Timing constants for terminal interactions
|
|
19
|
+
*/
|
|
20
|
+
export const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
|
|
21
|
+
/**
|
|
22
|
+
* VS Code terminal integration constants
|
|
23
|
+
*/
|
|
24
|
+
export const VSCODE_SHIFT_ENTER_SEQUENCE = '\\\r\n';
|
|
25
|
+
/**
|
|
26
|
+
* Backslash + Enter detection window in milliseconds.
|
|
27
|
+
* Used to detect Shift+Enter pattern where backslash
|
|
28
|
+
* is followed by Enter within this timeframe.
|
|
29
|
+
*/
|
|
30
|
+
export const BACKSLASH_ENTER_DETECTION_WINDOW_MS = 5;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum expected length of a Kitty keyboard protocol sequence.
|
|
33
|
+
* Format: ESC [ <keycode> ; <modifiers> u/~
|
|
34
|
+
* Example: \x1b[13;2u (Shift+Enter) = 8 chars
|
|
35
|
+
* Longest reasonable: \x1b[127;15~ = 11 chars (Del with all modifiers)
|
|
36
|
+
* We use 12 to provide a small buffer.
|
|
37
|
+
*/
|
|
38
|
+
export const MAX_KITTY_SEQUENCE_LENGTH = 12;
|
|
39
|
+
//# sourceMappingURL=platformConstants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformConstants.js","sourceRoot":"","sources":["../../../../src/ui/utils/platformConstants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,QAAQ,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export interface TerminalSetupResult {
|
|
7
|
+
success: boolean;
|
|
8
|
+
message: string;
|
|
9
|
+
requiresRestart?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Main terminal setup function that detects and configures the current terminal.
|
|
13
|
+
*
|
|
14
|
+
* This function:
|
|
15
|
+
* 1. Detects the current terminal emulator
|
|
16
|
+
* 2. Applies appropriate configuration for Shift+Enter and Ctrl+Enter support
|
|
17
|
+
* 3. Creates backups of configuration files before modifying them
|
|
18
|
+
*
|
|
19
|
+
* @returns Promise<TerminalSetupResult> Result object with success status and message
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = await terminalSetup();
|
|
23
|
+
* if (result.success) {
|
|
24
|
+
* console.log(result.message);
|
|
25
|
+
* if (result.requiresRestart) {
|
|
26
|
+
* console.log('Please restart your terminal');
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
export declare function terminalSetup(): Promise<TerminalSetupResult>;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Terminal setup utility for configuring Shift+Enter and Ctrl+Enter support.
|
|
8
|
+
*
|
|
9
|
+
* This module provides automatic detection and configuration of various terminal
|
|
10
|
+
* emulators to support multiline input through modified Enter keys.
|
|
11
|
+
*
|
|
12
|
+
* Supported terminals:
|
|
13
|
+
* - VS Code: Configures keybindings.json to send \\\r\n
|
|
14
|
+
* - Cursor: Configures keybindings.json to send \\\r\n (VS Code fork)
|
|
15
|
+
* - Windsurf: Configures keybindings.json to send \\\r\n (VS Code fork)
|
|
16
|
+
*
|
|
17
|
+
* For VS Code and its forks:
|
|
18
|
+
* - Shift+Enter: Sends \\\r\n (backslash followed by CRLF)
|
|
19
|
+
* - Ctrl+Enter: Sends \\\r\n (backslash followed by CRLF)
|
|
20
|
+
*
|
|
21
|
+
* The module will not modify existing shift+enter or ctrl+enter keybindings
|
|
22
|
+
* to avoid conflicts with user customizations.
|
|
23
|
+
*/
|
|
24
|
+
import { promises as fs } from 'fs';
|
|
25
|
+
import * as os from 'os';
|
|
26
|
+
import * as path from 'path';
|
|
27
|
+
import { exec } from 'child_process';
|
|
28
|
+
import { promisify } from 'util';
|
|
29
|
+
import { isKittyProtocolEnabled } from './kittyProtocolDetector.js';
|
|
30
|
+
import { VSCODE_SHIFT_ENTER_SEQUENCE } from './platformConstants.js';
|
|
31
|
+
const execAsync = promisify(exec);
|
|
32
|
+
/**
|
|
33
|
+
* Removes single-line JSON comments (// ...) from a string to allow parsing
|
|
34
|
+
* VS Code style JSON files that may contain comments.
|
|
35
|
+
*/
|
|
36
|
+
function stripJsonComments(content) {
|
|
37
|
+
// Remove single-line comments (// ...)
|
|
38
|
+
return content.replace(/^\s*\/\/.*$/gm, '');
|
|
39
|
+
}
|
|
40
|
+
// Terminal detection
|
|
41
|
+
async function detectTerminal() {
|
|
42
|
+
const termProgram = process.env.TERM_PROGRAM;
|
|
43
|
+
// Check VS Code and its forks - check forks first to avoid false positives
|
|
44
|
+
// Check for Cursor-specific indicators
|
|
45
|
+
if (process.env.CURSOR_TRACE_ID ||
|
|
46
|
+
process.env.VSCODE_GIT_ASKPASS_MAIN?.toLowerCase().includes('cursor')) {
|
|
47
|
+
return 'cursor';
|
|
48
|
+
}
|
|
49
|
+
// Check for Windsurf-specific indicators
|
|
50
|
+
if (process.env.VSCODE_GIT_ASKPASS_MAIN?.toLowerCase().includes('windsurf')) {
|
|
51
|
+
return 'windsurf';
|
|
52
|
+
}
|
|
53
|
+
// Check VS Code last since forks may also set VSCODE env vars
|
|
54
|
+
if (termProgram === 'vscode' || process.env.VSCODE_GIT_IPC_HANDLE) {
|
|
55
|
+
return 'vscode';
|
|
56
|
+
}
|
|
57
|
+
// Check parent process name
|
|
58
|
+
if (os.platform() !== 'win32') {
|
|
59
|
+
try {
|
|
60
|
+
const { stdout } = await execAsync('ps -o comm= -p $PPID');
|
|
61
|
+
const parentName = stdout.trim();
|
|
62
|
+
// Check forks before VS Code to avoid false positives
|
|
63
|
+
if (parentName.includes('windsurf') || parentName.includes('Windsurf'))
|
|
64
|
+
return 'windsurf';
|
|
65
|
+
if (parentName.includes('cursor') || parentName.includes('Cursor'))
|
|
66
|
+
return 'cursor';
|
|
67
|
+
if (parentName.includes('code') || parentName.includes('Code'))
|
|
68
|
+
return 'vscode';
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// Continue detection even if process check fails
|
|
72
|
+
console.debug('Parent process detection failed:', error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
// Backup file helper
|
|
78
|
+
async function backupFile(filePath) {
|
|
79
|
+
try {
|
|
80
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
81
|
+
const backupPath = `${filePath}.backup.${timestamp}`;
|
|
82
|
+
await fs.copyFile(filePath, backupPath);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
// Log backup errors but continue with operation
|
|
86
|
+
console.warn(`Failed to create backup of ${filePath}:`, error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Helper function to get VS Code-style config directory
|
|
90
|
+
function getVSCodeStyleConfigDir(appName) {
|
|
91
|
+
const platform = os.platform();
|
|
92
|
+
if (platform === 'darwin') {
|
|
93
|
+
return path.join(os.homedir(), 'Library', 'Application Support', appName, 'User');
|
|
94
|
+
}
|
|
95
|
+
else if (platform === 'win32') {
|
|
96
|
+
if (!process.env.APPDATA) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return path.join(process.env.APPDATA, appName, 'User');
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return path.join(os.homedir(), '.config', appName, 'User');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Generic VS Code-style terminal configuration
|
|
106
|
+
async function configureVSCodeStyle(terminalName, appName) {
|
|
107
|
+
const configDir = getVSCodeStyleConfigDir(appName);
|
|
108
|
+
if (!configDir) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
message: `Could not determine ${terminalName} config path on Windows: APPDATA environment variable is not set.`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const keybindingsFile = path.join(configDir, 'keybindings.json');
|
|
115
|
+
try {
|
|
116
|
+
await fs.mkdir(configDir, { recursive: true });
|
|
117
|
+
let keybindings = [];
|
|
118
|
+
try {
|
|
119
|
+
const content = await fs.readFile(keybindingsFile, 'utf8');
|
|
120
|
+
await backupFile(keybindingsFile);
|
|
121
|
+
try {
|
|
122
|
+
const cleanContent = stripJsonComments(content);
|
|
123
|
+
const parsedContent = JSON.parse(cleanContent);
|
|
124
|
+
if (!Array.isArray(parsedContent)) {
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
message: `${terminalName} keybindings.json exists but is not a valid JSON array. ` +
|
|
128
|
+
`Please fix the file manually or delete it to allow automatic configuration.\n` +
|
|
129
|
+
`File: ${keybindingsFile}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
keybindings = parsedContent;
|
|
133
|
+
}
|
|
134
|
+
catch (parseError) {
|
|
135
|
+
return {
|
|
136
|
+
success: false,
|
|
137
|
+
message: `Failed to parse ${terminalName} keybindings.json. The file contains invalid JSON.\n` +
|
|
138
|
+
`Please fix the file manually or delete it to allow automatic configuration.\n` +
|
|
139
|
+
`File: ${keybindingsFile}\n` +
|
|
140
|
+
`Error: ${parseError}`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// File doesn't exist, will create new one
|
|
146
|
+
}
|
|
147
|
+
const shiftEnterBinding = {
|
|
148
|
+
key: 'shift+enter',
|
|
149
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
150
|
+
when: 'terminalFocus',
|
|
151
|
+
args: { text: VSCODE_SHIFT_ENTER_SEQUENCE },
|
|
152
|
+
};
|
|
153
|
+
const ctrlEnterBinding = {
|
|
154
|
+
key: 'ctrl+enter',
|
|
155
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
156
|
+
when: 'terminalFocus',
|
|
157
|
+
args: { text: VSCODE_SHIFT_ENTER_SEQUENCE },
|
|
158
|
+
};
|
|
159
|
+
// Check if ANY shift+enter or ctrl+enter bindings already exist
|
|
160
|
+
const existingShiftEnter = keybindings.find((kb) => {
|
|
161
|
+
const binding = kb;
|
|
162
|
+
return binding.key === 'shift+enter';
|
|
163
|
+
});
|
|
164
|
+
const existingCtrlEnter = keybindings.find((kb) => {
|
|
165
|
+
const binding = kb;
|
|
166
|
+
return binding.key === 'ctrl+enter';
|
|
167
|
+
});
|
|
168
|
+
if (existingShiftEnter || existingCtrlEnter) {
|
|
169
|
+
const messages = [];
|
|
170
|
+
if (existingShiftEnter) {
|
|
171
|
+
messages.push(`- Shift+Enter binding already exists`);
|
|
172
|
+
}
|
|
173
|
+
if (existingCtrlEnter) {
|
|
174
|
+
messages.push(`- Ctrl+Enter binding already exists`);
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
success: false,
|
|
178
|
+
message: `Existing keybindings detected. Will not modify to avoid conflicts.\n` +
|
|
179
|
+
messages.join('\n') +
|
|
180
|
+
'\n' +
|
|
181
|
+
`Please check and modify manually if needed: ${keybindingsFile}`,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
// Check if our specific bindings already exist
|
|
185
|
+
const hasOurShiftEnter = keybindings.some((kb) => {
|
|
186
|
+
const binding = kb;
|
|
187
|
+
return (binding.key === 'shift+enter' &&
|
|
188
|
+
binding.command === 'workbench.action.terminal.sendSequence' &&
|
|
189
|
+
binding.args?.text === '\\\r\n');
|
|
190
|
+
});
|
|
191
|
+
const hasOurCtrlEnter = keybindings.some((kb) => {
|
|
192
|
+
const binding = kb;
|
|
193
|
+
return (binding.key === 'ctrl+enter' &&
|
|
194
|
+
binding.command === 'workbench.action.terminal.sendSequence' &&
|
|
195
|
+
binding.args?.text === '\\\r\n');
|
|
196
|
+
});
|
|
197
|
+
if (!hasOurShiftEnter || !hasOurCtrlEnter) {
|
|
198
|
+
if (!hasOurShiftEnter)
|
|
199
|
+
keybindings.unshift(shiftEnterBinding);
|
|
200
|
+
if (!hasOurCtrlEnter)
|
|
201
|
+
keybindings.unshift(ctrlEnterBinding);
|
|
202
|
+
await fs.writeFile(keybindingsFile, JSON.stringify(keybindings, null, 4));
|
|
203
|
+
return {
|
|
204
|
+
success: true,
|
|
205
|
+
message: `Added Shift+Enter and Ctrl+Enter keybindings to ${terminalName}.\nModified: ${keybindingsFile}`,
|
|
206
|
+
requiresRestart: true,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
return {
|
|
211
|
+
success: true,
|
|
212
|
+
message: `${terminalName} keybindings already configured.`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
return {
|
|
218
|
+
success: false,
|
|
219
|
+
message: `Failed to configure ${terminalName}.\nFile: ${keybindingsFile}\nError: ${error}`,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Terminal-specific configuration functions
|
|
224
|
+
async function configureVSCode() {
|
|
225
|
+
return configureVSCodeStyle('VS Code', 'Code');
|
|
226
|
+
}
|
|
227
|
+
async function configureCursor() {
|
|
228
|
+
return configureVSCodeStyle('Cursor', 'Cursor');
|
|
229
|
+
}
|
|
230
|
+
async function configureWindsurf() {
|
|
231
|
+
return configureVSCodeStyle('Windsurf', 'Windsurf');
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Main terminal setup function that detects and configures the current terminal.
|
|
235
|
+
*
|
|
236
|
+
* This function:
|
|
237
|
+
* 1. Detects the current terminal emulator
|
|
238
|
+
* 2. Applies appropriate configuration for Shift+Enter and Ctrl+Enter support
|
|
239
|
+
* 3. Creates backups of configuration files before modifying them
|
|
240
|
+
*
|
|
241
|
+
* @returns Promise<TerminalSetupResult> Result object with success status and message
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* const result = await terminalSetup();
|
|
245
|
+
* if (result.success) {
|
|
246
|
+
* console.log(result.message);
|
|
247
|
+
* if (result.requiresRestart) {
|
|
248
|
+
* console.log('Please restart your terminal');
|
|
249
|
+
* }
|
|
250
|
+
* }
|
|
251
|
+
*/
|
|
252
|
+
export async function terminalSetup() {
|
|
253
|
+
// Check if terminal already has optimal keyboard support
|
|
254
|
+
if (isKittyProtocolEnabled()) {
|
|
255
|
+
return {
|
|
256
|
+
success: true,
|
|
257
|
+
message: 'Your terminal is already configured for an optimal experience with multiline input (Shift+Enter and Ctrl+Enter).',
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const terminal = await detectTerminal();
|
|
261
|
+
if (!terminal) {
|
|
262
|
+
return {
|
|
263
|
+
success: false,
|
|
264
|
+
message: 'Could not detect terminal type. Supported terminals: VS Code, Cursor, and Windsurf.',
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
switch (terminal) {
|
|
268
|
+
case 'vscode':
|
|
269
|
+
return configureVSCode();
|
|
270
|
+
case 'cursor':
|
|
271
|
+
return configureCursor();
|
|
272
|
+
case 'windsurf':
|
|
273
|
+
return configureWindsurf();
|
|
274
|
+
default:
|
|
275
|
+
return {
|
|
276
|
+
success: false,
|
|
277
|
+
message: `Terminal "${terminal}" is not supported yet.`,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=terminalSetup.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,IAAI,sBAAsB,EAAE,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EACL,kHAAkH;SACrH,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,cAAc,EAAE,CAAC;IAExC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EACL,qFAAqF;SACxF,CAAC;IACJ,CAAC;IAED,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,eAAe,EAAE,CAAC;QAC3B,KAAK,QAAQ;YACX,OAAO,eAAe,EAAE,CAAC;QAC3B,KAAK,UAAU;YACb,OAAO,iBAAiB,EAAE,CAAC;QAC7B;YACE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,aAAa,QAAQ,yBAAyB;aACxD,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare function assumeExhaustive(_value: never): void;
|
|
7
|
+
/**
|
|
8
|
+
* Throws an exception on unexpected values.
|
|
9
|
+
*
|
|
10
|
+
* A common use case is switch statements:
|
|
11
|
+
* switch(enumValue) {
|
|
12
|
+
* case Enum.A:
|
|
13
|
+
* case Enum.B:
|
|
14
|
+
* break;
|
|
15
|
+
* default:
|
|
16
|
+
* checkExhaustive(enumValue);
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkExhaustive(value: never, msg?: string): never;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/* Fail to compile on unexpected values. */
|
|
7
|
+
export function assumeExhaustive(_value) { }
|
|
8
|
+
/**
|
|
9
|
+
* Throws an exception on unexpected values.
|
|
10
|
+
*
|
|
11
|
+
* A common use case is switch statements:
|
|
12
|
+
* switch(enumValue) {
|
|
13
|
+
* case Enum.A:
|
|
14
|
+
* case Enum.B:
|
|
15
|
+
* break;
|
|
16
|
+
* default:
|
|
17
|
+
* checkExhaustive(enumValue);
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
export function checkExhaustive(value, msg = `unexpected value ${value}!`) {
|
|
21
|
+
assumeExhaustive(value);
|
|
22
|
+
throw new Error(msg);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../src/utils/checks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2CAA2C;AAC3C,MAAM,UAAU,gBAAgB,CAAC,MAAa,IAAS,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAY,EACZ,GAAG,GAAG,oBAAoB,KAAK,GAAG;IAElC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACxB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import * as schema from './schema.js';
|
|
7
|
+
export * from './schema.js';
|
|
8
|
+
import { WritableStream, ReadableStream } from 'node:stream/web';
|
|
9
|
+
export declare class AgentSideConnection implements Client {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(toAgent: (conn: Client) => Agent, input: WritableStream<Uint8Array>, output: ReadableStream<Uint8Array>);
|
|
12
|
+
/**
|
|
13
|
+
* Streams new content to the client including text, tool calls, etc.
|
|
14
|
+
*/
|
|
15
|
+
sessionUpdate(params: schema.SessionNotification): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Request permission before running a tool
|
|
18
|
+
*
|
|
19
|
+
* The agent specifies a series of permission options with different granularity,
|
|
20
|
+
* and the client returns the chosen one.
|
|
21
|
+
*/
|
|
22
|
+
requestPermission(params: schema.RequestPermissionRequest): Promise<schema.RequestPermissionResponse>;
|
|
23
|
+
readTextFile(params: schema.ReadTextFileRequest): Promise<schema.ReadTextFileResponse>;
|
|
24
|
+
writeTextFile(params: schema.WriteTextFileRequest): Promise<schema.WriteTextFileResponse>;
|
|
25
|
+
}
|
|
26
|
+
type Result<T> = {
|
|
27
|
+
result: T;
|
|
28
|
+
} | {
|
|
29
|
+
error: ErrorResponse;
|
|
30
|
+
};
|
|
31
|
+
type ErrorResponse = {
|
|
32
|
+
code: number;
|
|
33
|
+
message: string;
|
|
34
|
+
data?: unknown;
|
|
35
|
+
};
|
|
36
|
+
export declare class RequestError extends Error {
|
|
37
|
+
code: number;
|
|
38
|
+
data?: {
|
|
39
|
+
details?: string;
|
|
40
|
+
};
|
|
41
|
+
constructor(code: number, message: string, details?: string);
|
|
42
|
+
static parseError(details?: string): RequestError;
|
|
43
|
+
static invalidRequest(details?: string): RequestError;
|
|
44
|
+
static methodNotFound(details?: string): RequestError;
|
|
45
|
+
static invalidParams(details?: string): RequestError;
|
|
46
|
+
static internalError(details?: string): RequestError;
|
|
47
|
+
static authRequired(details?: string): RequestError;
|
|
48
|
+
toResult<T>(): Result<T>;
|
|
49
|
+
}
|
|
50
|
+
export interface Client {
|
|
51
|
+
requestPermission(params: schema.RequestPermissionRequest): Promise<schema.RequestPermissionResponse>;
|
|
52
|
+
sessionUpdate(params: schema.SessionNotification): Promise<void>;
|
|
53
|
+
writeTextFile(params: schema.WriteTextFileRequest): Promise<schema.WriteTextFileResponse>;
|
|
54
|
+
readTextFile(params: schema.ReadTextFileRequest): Promise<schema.ReadTextFileResponse>;
|
|
55
|
+
}
|
|
56
|
+
export interface Agent {
|
|
57
|
+
initialize(params: schema.InitializeRequest): Promise<schema.InitializeResponse>;
|
|
58
|
+
newSession(params: schema.NewSessionRequest): Promise<schema.NewSessionResponse>;
|
|
59
|
+
loadSession?(params: schema.LoadSessionRequest): Promise<schema.LoadSessionResponse>;
|
|
60
|
+
authenticate(params: schema.AuthenticateRequest): Promise<void>;
|
|
61
|
+
prompt(params: schema.PromptRequest): Promise<schema.PromptResponse>;
|
|
62
|
+
cancel(params: schema.CancelNotification): Promise<void>;
|
|
63
|
+
}
|