diff --git a/packages/vscode/src/fragmentcommands.ts b/packages/vscode/src/fragmentcommands.ts index fb000ea1c0..3147614274 100644 --- a/packages/vscode/src/fragmentcommands.ts +++ b/packages/vscode/src/fragmentcommands.ts @@ -3,19 +3,12 @@ import { ExtensionState } from "./state" import { checkDirectoryExists, checkFileExists } from "./fs" import { registerCommand } from "./commands" import { templateGroup } from "../../core/src/ast" -import { - GENAI_ANY_REGEX, - TOOL_ID, - TOOL_NAME, - VSCODE_CONFIG_CLI_PATH, - VSCODE_CONFIG_CLI_VERSION, -} from "../../core/src/constants" +import { GENAI_ANY_REGEX, TOOL_ID, TOOL_NAME } from "../../core/src/constants" import { NotSupportedError } from "../../core/src/error" import { promptParameterTypeToJSONSchema } from "../../core/src/parameters" import { Fragment } from "../../core/src/generation" import { assert, dotGenaiscriptPath, groupBy } from "../../core/src/util" -import { CORE_VERSION } from "../../core/src/version" -import { semverParse, semverSatisfies } from "../../core/src/semver" +import { resolveCli } from "./config" type TemplateQuickPickItem = { template?: PromptScript @@ -188,8 +181,7 @@ export function activateFragmentCommands(state: ExtensionState) { files = [file] } - const config = vscode.workspace.getConfiguration(TOOL_ID) - const program = config.get(VSCODE_CONFIG_CLI_PATH) as string + const { cliPath, cliVersion } = await resolveCli() const args = [ "run", vscode.workspace.asRelativePath(template.filename), @@ -197,19 +189,10 @@ export function activateFragmentCommands(state: ExtensionState) { vscode.workspace.asRelativePath(file.fsPath) ), ] - const cliVersion = - (config.get(VSCODE_CONFIG_CLI_VERSION) as string) || CORE_VERSION - const gv = semverParse(CORE_VERSION) - if (!semverSatisfies(cliVersion, ">=" + gv.major + "." + gv.minor)) - vscode.window.showWarningMessage( - TOOL_ID + - ` - genaiscript cli version (${cliVersion}) outdated, please update to ${CORE_VERSION}` - ) - - const configuration = program + const configuration = cliPath ? { name: TOOL_NAME, - program, + cliPath, request: "launch", skipFiles: ["/**", dotGenaiscriptPath("**")], type: "node", diff --git a/packages/vscode/src/servermanager.ts b/packages/vscode/src/servermanager.ts index ee5a27898b..356fd9c1a8 100644 --- a/packages/vscode/src/servermanager.ts +++ b/packages/vscode/src/servermanager.ts @@ -6,10 +6,7 @@ import { OPEN, TOOL_NAME, ICON_LOGO_NAME, - CLIENT_RECONNECT_MAX_ATTEMPTS, TOOL_ID, - VSCODE_CONFIG_CLI_VERSION, - VSCODE_CONFIG_CLI_PATH, } from "../../core/src/constants" import { ServerManager, host } from "../../core/src/host" import { logError, logVerbose } from "../../core/src/util" @@ -17,6 +14,7 @@ import { WebSocketClient } from "../../core/src/server/client" import { CORE_VERSION } from "../../core/src/version" import { createChatModelRunner } from "./lmaccess" import { semverParse, semverSatisfies } from "../../core/src/semver" +import { resolveCli } from "./config" export class TerminalServerManager implements ServerManager { private _terminal: vscode.Terminal @@ -86,15 +84,9 @@ export class TerminalServerManager implements ServerManager { isTransient: true, iconPath: new vscode.ThemeIcon(ICON_LOGO_NAME), }) - const config = vscode.workspace.getConfiguration(TOOL_ID) - const cliPath = config.get(VSCODE_CONFIG_CLI_PATH) as string + const { cliPath, cliVersion } = await resolveCli() if (cliPath) this._terminal.sendText(`node "${cliPath}" serve`) - else { - const cliVersion = - (config.get(VSCODE_CONFIG_CLI_VERSION) as string) || - CORE_VERSION - this._terminal.sendText(`npx --yes ${TOOL_ID}@${cliVersion} serve`) - } + else this._terminal.sendText(`npx --yes ${TOOL_ID}@${cliVersion} serve`) this._terminal.show() }