Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export const PLACEHOLDER_API_KEY = "<your token>"
export const VSCODE_CONFIG_CLI_VERSION = "cli.version"
export const VSCODE_CONFIG_CLI_PATH = "cli.path"
export const VSCODE_CONFIG_CLI_PACKAGE_MANAGER = "cli.packageManager"
export const VSCODE_CONFIG_CLI_NO_COLORS = "cli.noColors"

export const CONSOLE_COLOR_INFO = 32
export const CONSOLE_COLOR_DEBUG = 90
Expand Down
5 changes: 5 additions & 0 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@
"genaiscript.cli.path": {
"type": "string",
"description": "Path to GenAIScript CLI. Default uses npx."
},
"genaiscript.cli.noColors": {
"type": "boolean",
"default": false,
"description": "Disable color output in the CLI. Default is false (colors enabled)."
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
VSCODE_CONFIG_CLI_PACKAGE_MANAGER,
VSCODE_CONFIG_CLI_PATH,
VSCODE_CONFIG_CLI_VERSION,
VSCODE_CONFIG_CLI_NO_COLORS,
} from "../../core/src/constants"
import { CORE_VERSION, VSCODE_CLI_VERSION } from "../../core/src/version"
import { semverParse, semverSatisfies } from "../../core/src/semver"
Expand All @@ -21,11 +22,12 @@ export async function resolveCli(state: ExtensionState) {
| "npm"
| "yarn"
| "pnpm" // TODO: add support for bun
const noColors = config.get(VSCODE_CONFIG_CLI_NO_COLORS) as boolean
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}`
)
return { cliPath, cliVersion, packageManager }
return { cliPath, cliVersion, packageManager, noColors }
}
5 changes: 4 additions & 1 deletion packages/vscode/src/fragmentcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,17 @@ export function activateFragmentCommands(state: ExtensionState) {
)
if (parameters === undefined) return

const { cliPath, cliVersion } = await resolveCli(state)
const { cliPath, cliVersion, noColors } = await resolveCli(state)
const args = [
"run",
vscode.workspace.asRelativePath(script.filename),
...files.map((file) =>
vscode.workspace.asRelativePath(file.fsPath)
),
]
if (noColors) {
args.push("--no-colors")
}
for (const [name, value] of Object.entries(parameters)) {
args.push(`--vars`, `${name}=${value}`)
}
Expand Down
36 changes: 21 additions & 15 deletions packages/vscode/src/servermanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class TerminalServerManager
logVerbose(
`starting server on port ${this._port} at ${cwd} (DEBUG=${debug || ""})`
)
const { cliPath, cliVersion, packageManager } = await resolveCli(
const { cliPath, cliVersion, packageManager, noColors } = await resolveCli(
this.state
)
const githubCopilotChatClient = isLanguageModelsAvailable()
Expand All @@ -208,23 +208,29 @@ export class TerminalServerManager
}),
hideFromUser,
})
if (cliPath)
this._terminal.sendText(
`node "${cliPath}" serve --port ${this._port} --dispatch-progress --cors "*" ${githubCopilotChatClient}`
)
if (cliPath) {
const cmd = `node "${cliPath}" serve --port ${this._port} --dispatch-progress --cors "*" ${githubCopilotChatClient}${noColors ? " --no-colors" : ""}`.trim()
this._terminal.sendText(cmd)
}
else {
const args = [
`${TOOL_ID}@${cliVersion}`,
`serve`,
`--port`,
`${this._port}`,
`--dispatch-progress`,
`--cors`,
`"*"`
]
if (githubCopilotChatClient) {
args.push(githubCopilotChatClient)
}
if (noColors) {
args.push("--no-colors")
}
const pkg = await packageResolveExecute(
cwd,
[
`${TOOL_ID}@${cliVersion}`,
`serve`,
`--port`,
`${this._port}`,
`--dispatch-progress`,
`--cors`,
`"*"`,
githubCopilotChatClient,
],
args,
{ agent: packageManager }
)
const cmd = [shellQuote([pkg.command]), ...pkg.args].join(" ")
Expand Down
5 changes: 4 additions & 1 deletion packages/vscode/src/taskprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function activeTaskProvider(state: ExtensionState) {
try {
if (!state.project) return []

const { cliPath, cliVersion } = await resolveCli(state)
const { cliPath, cliVersion, noColors } = await resolveCli(state)
const exec = shellQuote([cliPath || `npx`])
const exeArgs = cliPath
? []
Expand All @@ -27,6 +27,9 @@ export async function activeTaskProvider(state: ExtensionState) {
script.filename
)
const args = [...exeArgs, "run", scriptName]
if (noColors) {
args.push("--no-colors")
}
if (vscode.window.activeTextEditor)
args.push("${relativeFile}")
const task = new vscode.Task(
Expand Down
Loading