* feat(terminal): add shared terminal types and interfaces Add shared terminal module with types and interfaces that enable terminal management across VSCode, CLI, and JetBrains environments. - Define ITerminal, ITerminalManager, and TerminalInfo interfaces - Add TerminalProcessResultPromise for async command execution - Include StandaloneTerminalOptions for non-VSCode environments - Prepare module structure for standalone implementations * feat(terminal): export standalone terminal implementations Enable exports for standalone terminal classes that were previously commented out as placeholders: - StandaloneTerminal - StandaloneTerminalManager - StandaloneTerminalProcess - StandaloneTerminalRegistry These implementations are now ready for use outside the terminal module. * fix: resolve TerminalInfo type incompatibility in settings update - Remove unused TerminalInfo import from both updateSettings files - Use `as any` cast to handle type mismatch between VSCode and standalone TerminalInfo - Replace busyTerminals array with busyTerminalsCount to avoid type issues - Add null-safe access when getting busy terminals length * feat: import StandaloneTerminalManager from bundled cline-core Replace standalone enhanced-terminal.js with import from the bundled TypeScript version in cline-core.js. This consolidates terminal management code and removes the need to separately include the runtime file in the VS Code extension package. - Re-export StandaloneTerminalManager from cline-core.ts - Update vscode-impls.js to import from cline-core.js - Remove .vscodeignore exception for enhanced-terminal.js * feat: simplify standalone terminal manager initialization Replace global injection pattern with environment variable detection for determining terminal execution mode. The Task class now directly instantiates StandaloneTerminalManager when IS_STANDALONE=true instead of relying on a globally injected instance. - Remove StandaloneTerminalManager re-export from cline-core.ts - Simplify vscode-impls.js createTerminal to return stub object - Use IS_STANDALONE env var for terminal manager selection in Task - Remove global.standaloneTerminalManager injection pattern * Fix Standalone build * Fix Standalone build * fix: use subagentTerminalOutputLineLimit in StandaloneTerminalManager.processOutput Match the VSCode TerminalManager logic to properly use subagentTerminalOutputLineLimit (2000) for subagent commands instead of always falling back to terminalOutputLineLimit (500). * feat: add TerminalManager to HostProvider for dependency injection - Add TerminalManagerCreator type and createTerminalManager to HostProvider - Extract ITerminalManager interface to shared/terminal/types for abstraction - Refactor TerminalManager to implement ITerminalManager interface - Create StandaloneTerminalManager for non-VSCode environments - Update TerminalRegistry to use ITerminalManager via HostProvider - Enable terminal management to work across different host environments * feat: refactor terminal manager to use ITerminalManager interface - Replace concrete TerminalManager/StandaloneTerminalManager types with ITerminalManager interface - Use HostProvider.createTerminalManager() for host-agnostic terminal creation - Simplify terminal execution mode logic in Task constructor - Add dynamic imports for StandaloneTerminalManager when backgroundExec mode is used - Improve logging for terminal manager selection
159 lines
4.7 KiB
JavaScript
159 lines
4.7 KiB
JavaScript
console.log("Loading stub impls...")
|
|
|
|
const { createStub } = require("./stub-utils")
|
|
|
|
// Import the base vscode object from stubs
|
|
const vscode = require("./vscode-stubs.js")
|
|
|
|
// Extend the existing window object from stubs rather than overwriting it
|
|
vscode.window = {
|
|
...vscode.window, // Keep existing properties from stubs
|
|
showInformationMessage: (...args) => {
|
|
console.log("Stubbed showInformationMessage:", ...args)
|
|
return Promise.resolve(undefined)
|
|
},
|
|
showWarningMessage: (...args) => {
|
|
console.log("Stubbed showWarningMessage:", ...args)
|
|
return Promise.resolve(undefined)
|
|
},
|
|
showErrorMessage: (...args) => {
|
|
console.log("Stubbed showErrorMessage:", ...args)
|
|
return Promise.resolve(undefined)
|
|
},
|
|
showInputBox: async (options) => {
|
|
console.log("Stubbed showInputBox:", options)
|
|
return ""
|
|
},
|
|
showOpenDialog: async (options) => {
|
|
console.log("Stubbed showOpenDialog:", options)
|
|
return []
|
|
},
|
|
showSaveDialog: async (options) => {
|
|
console.log("Stubbed showSaveDialog:", options)
|
|
return undefined
|
|
},
|
|
showTextDocument: async (...args) => {
|
|
console.log("Stubbed showTextDocument:", ...args)
|
|
return {}
|
|
},
|
|
createTerminal: (...args) => {
|
|
// In standalone mode, terminals are managed directly by Task.terminalManager (StandaloneTerminalManager)
|
|
// This stub is provided for compatibility but should not be called directly
|
|
console.log("Stubbed createTerminal:", ...args)
|
|
|
|
// Return a minimal stub terminal object
|
|
const stubTerminal = {
|
|
name: args[0]?.name || args[0] || "Terminal",
|
|
processId: Promise.resolve(undefined),
|
|
creationOptions: {},
|
|
exitStatus: undefined,
|
|
state: { isInteractedWith: false },
|
|
sendText: (text) => console.log("Stubbed terminal.sendText:", text),
|
|
show: () => console.log("Stubbed terminal.show"),
|
|
hide: () => console.log("Stubbed terminal.hide"),
|
|
dispose: () => console.log("Stubbed terminal.dispose"),
|
|
}
|
|
|
|
vscode.window.terminals.push(stubTerminal)
|
|
return stubTerminal
|
|
},
|
|
activeTextEditor: undefined,
|
|
visibleTextEditors: [],
|
|
tabGroups: {
|
|
all: [],
|
|
close: async () => {},
|
|
onDidChangeTabs: createStub("vscode.env.tabGroups.onDidChangeTabs"),
|
|
activeTabGroup: { tabs: [] },
|
|
},
|
|
withProgress: async (_options, task) => {
|
|
console.log("Stubbed withProgress")
|
|
return task({ report: () => {} })
|
|
},
|
|
registerUriHandler: () => ({ dispose: () => {} }),
|
|
registerWebviewViewProvider: () => ({ dispose: () => {} }),
|
|
onDidChangeActiveTextEditor: () => ({ dispose: () => {} }),
|
|
createTextEditorDecorationType: () => ({ dispose: () => {} }),
|
|
createWebviewPanel: (..._args) => {
|
|
throw new Error("WebviewPanel is not supported in standalone app.")
|
|
},
|
|
}
|
|
|
|
vscode.env = {
|
|
uriScheme: "vscode",
|
|
appName: "Visual Studio Code",
|
|
appRoot: "/tmp/vscode/appRoot",
|
|
language: "en",
|
|
machineId: "stub-machine-id",
|
|
remoteName: undefined,
|
|
sessionId: "stub-session-id",
|
|
shell: "/bin/bash",
|
|
|
|
clipboard: createStub("vscode.env.clipboard"),
|
|
openExternal: createStub("vscode.env.openExternal"),
|
|
getQueryParameter: createStub("vscode.env.getQueryParameter"),
|
|
onDidChangeTelemetryEnabled: createStub("vscode.env.onDidChangeTelemetryEnabled"),
|
|
isTelemetryEnabled: createStub("vscode.env.isTelemetryEnabled"),
|
|
telemetryConfiguration: createStub("vscode.env.telemetryConfiguration"),
|
|
onDidChangeTelemetryConfiguration: createStub("vscode.env.onDidChangeTelemetryConfiguration"),
|
|
createTelemetryLogger: createStub("vscode.env.createTelemetryLogger"),
|
|
}
|
|
|
|
vscode.Uri = {
|
|
parse: (uriString) => {
|
|
const url = new URL(uriString)
|
|
return {
|
|
scheme: url.protocol.replace(":", ""),
|
|
authority: url.hostname,
|
|
path: url.pathname,
|
|
query: url.search.slice(1),
|
|
fragment: url.hash.slice(1),
|
|
fsPath: `/tmp${url.pathname}`,
|
|
toString: () => uriString,
|
|
toJSON: () => uriString,
|
|
with: (change) => {
|
|
const newUrl = new URL(uriString)
|
|
if (change.scheme) {
|
|
newUrl.protocol = change.scheme + ":"
|
|
}
|
|
if (change.authority) {
|
|
newUrl.hostname = change.authority
|
|
}
|
|
if (change.path) {
|
|
newUrl.pathname = change.path
|
|
}
|
|
if (change.query) {
|
|
newUrl.search = "?" + change.query
|
|
}
|
|
if (change.fragment) {
|
|
newUrl.hash = "#" + change.fragment
|
|
}
|
|
return vscode.Uri.parse(newUrl.toString())
|
|
},
|
|
}
|
|
},
|
|
|
|
file: (path) => {
|
|
return {
|
|
scheme: "file",
|
|
authority: "",
|
|
path,
|
|
fsPath: path,
|
|
query: "",
|
|
fragment: "",
|
|
toString: () => `file://${path}`,
|
|
toJSON: () => `file://${path}`,
|
|
with: (change) => {
|
|
const modified = Object.assign({}, vscode.Uri.file(path), change)
|
|
return modified
|
|
},
|
|
}
|
|
},
|
|
|
|
joinPath: (...segments) => {
|
|
const joined = segments.map((s) => (typeof s === "string" ? s : s.path)).join("/")
|
|
return vscode.Uri.file("/" + joined.replace(/\/+/g, "/"))
|
|
},
|
|
}
|
|
|
|
console.log("Finished loading stub impls...")
|