diff --git a/docs/src/content/docs/getting-started/installation.mdx b/docs/src/content/docs/getting-started/installation.mdx index 3e68248581..0a0a308a8f 100644 --- a/docs/src/content/docs/getting-started/installation.mdx +++ b/docs/src/content/docs/getting-started/installation.mdx @@ -80,7 +80,6 @@ to bug fixes earlier than the marketplace release. - ... - .genaiscript/ folder created by the extension to store supporting files - - genaiscript.cjs command line - cache/ various cache files - retreival/ retreival database caches - ... supporting files diff --git a/packages/core/src/clihelp.ts b/packages/core/src/clihelp.ts index ea87c186c3..e9f9a6a583 100644 --- a/packages/core/src/clihelp.ts +++ b/packages/core/src/clihelp.ts @@ -1,6 +1,6 @@ import { CORE_VERSION, RunTemplateOptions } from "." import { Fragment } from "./ast" -import { GENAISCRIPT_CLI_JS, NPM_CLI_PACKAGE } from "./constants" +import { NPM_CLI_PACKAGE } from "./constants" import { MarkdownTrace } from "./trace" export function generateCliArguments( @@ -52,9 +52,8 @@ ${generateCliArguments(template, fragment, options, "batch")} - You will need to install [Node.js](https://nodejs.org/en/). -- The \`${GENAISCRIPT_CLI_JS}\` is written by the Visual Studio Code extension automatically. - The CLI uses the same secrets in the \`.env\` file. -- Run \`node .genaiscript/genaiscript help run\` for the full list of options. +- Run \`npx genaiscript help run\` for the full list of options. ` ) } diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index 36b9f88349..3da81a1b3d 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -6,7 +6,6 @@ export const AZURE_OPENAI_API_VERSION = "2023-09-01-preview" export const TOOL_ID = "genaiscript" export const GENAISCRIPT_FOLDER = "." + TOOL_ID export const CLI_JS = TOOL_ID + ".cjs" -export const GENAISCRIPT_CLI_JS = GENAISCRIPT_FOLDER + "/" + CLI_JS export const GENAI_SRC = "genaisrc" export const GENAI_EXT = ".genai.js" export const TOOL_NAME = "GenAIScript" diff --git a/packages/vscode/src/fragmentcommands.ts b/packages/vscode/src/fragmentcommands.ts index 939a713306..2e69030ee1 100644 --- a/packages/vscode/src/fragmentcommands.ts +++ b/packages/vscode/src/fragmentcommands.ts @@ -1,7 +1,6 @@ import * as vscode from "vscode" import { Fragment, - GENAISCRIPT_CLI_JS, PromptTemplate, dotGenaiscriptPath, groupBy, @@ -11,7 +10,6 @@ import { ExtensionState } from "./state" import { checkDirectoryExists, checkFileExists, - saveAllTextDocuments, } from "./fs" type TemplateQuickPickItem = { @@ -83,10 +81,10 @@ export function activateFragmentCommands(state: ExtensionState) { const fragmentPrompt = async ( options: | { - fragment?: Fragment | string | vscode.Uri - template?: PromptTemplate - debug?: boolean - } + fragment?: Fragment | string | vscode.Uri + template?: PromptTemplate + debug?: boolean + } | vscode.Uri ) => { if (typeof options === "object" && options instanceof vscode.Uri) @@ -128,7 +126,7 @@ export function activateFragmentCommands(state: ExtensionState) { vscode.workspace.workspaceFolders[0], { name: "GenAIScript", - program: GENAISCRIPT_CLI_JS, + program: state.cliJsPath, request: "launch", skipFiles: ["/**", dotGenaiscriptPath("**")], type: "node", @@ -198,9 +196,8 @@ export function templatesToQuickPickItems( template.filename )) ?? template.id, - description: `${template.id} ${ - template.description || "" - }`, + description: `${template.id} ${template.description || "" + }`, template, } ) diff --git a/packages/vscode/src/retreivalcommands.ts b/packages/vscode/src/retreivalcommands.ts index b80570514b..6edaa38d12 100644 --- a/packages/vscode/src/retreivalcommands.ts +++ b/packages/vscode/src/retreivalcommands.ts @@ -5,11 +5,8 @@ import { GENAISCRIPT_FOLDER, TOOL_NAME, clearIndex, - initToken, isIndexable, - upsert, search as retreivalSearch, - CLI_JS, ICON_LOGO_NAME, RETRIEVAL_DEFAULT_INDEX, } from "genaiscript-core" @@ -105,7 +102,7 @@ export function activateRetreivalCommands(state: ExtensionState) { iconPath: new vscode.ThemeIcon(ICON_LOGO_NAME), }) terminal.sendText( - `node ${host.path.join(GENAISCRIPT_FOLDER, CLI_JS)} retreival index "${host.path.join(vscode.workspace.asRelativePath(uri.fsPath), "**")}" --name ${indexName}` + `node "${state.cliJsPath}" retreival index "${host.path.join(vscode.workspace.asRelativePath(uri.fsPath), "**")}" --name ${indexName}` ) terminal.show() } diff --git a/packages/vscode/src/servermanager.ts b/packages/vscode/src/servermanager.ts index d9a1f58b0a..467aa4ca28 100644 --- a/packages/vscode/src/servermanager.ts +++ b/packages/vscode/src/servermanager.ts @@ -1,6 +1,4 @@ import { - CLI_JS, - GENAISCRIPT_FOLDER, HighlightService, ICON_LOGO_NAME, RetreivalService, @@ -45,7 +43,7 @@ export class TerminalServerManager implements ServerManager { iconPath: new vscode.ThemeIcon(ICON_LOGO_NAME), }) this._terminal.sendText( - `node ${host.path.join(GENAISCRIPT_FOLDER, CLI_JS)} serve` + `node "${this.state.cliJsPath}" serve` ) this._terminal.show() } diff --git a/packages/vscode/src/state.ts b/packages/vscode/src/state.ts index 7ea7d76e29..05aaea6a8a 100644 --- a/packages/vscode/src/state.ts +++ b/packages/vscode/src/state.ts @@ -179,11 +179,6 @@ export class ExtensionState extends EventTarget { const dir = vscode.Uri.file(dotGenaiscriptPath(".")) await vscode.workspace.fs.createDirectory(dir) - const p = Utils.joinPath(this.context.extensionUri, CLI_JS) - const cli = vscode.Uri.file(dotGenaiscriptPath(CLI_JS)) - - // genaiscript.cjs - await vscode.workspace.fs.copy(p, cli, { overwrite: true }) // add .gitignore await writeFile( dir, @@ -206,6 +201,11 @@ retrieval/ ) } + get cliJsPath() { + const res = Utils.joinPath(this.context.extensionUri, CLI_JS).fsPath + return res + } + aiRequestCache() { return this._aiRequestCache } @@ -529,9 +529,9 @@ ${e.message}` const spec = `# Specification ${files - .map((uri) => this.host.path.relative(fspath, uri.fsPath)) - .map((fn) => `- [${fn}](./${fn})`) - .join("\n")} + .map((uri) => this.host.path.relative(fspath, uri.fsPath)) + .map((fn) => `- [${fn}](./${fn})`) + .join("\n")} ` this.host.clearVirtualFiles() this.host.setVirtualFile(specn, spec) @@ -610,9 +610,9 @@ ${files r.source = TOOL_NAME r.code = target ? { - value, - target, - } + value, + target, + } : undefined return r })