Find code by asking what it does. A CLI for coding agents that uses Jev to discover relevant files and source context.
TypeScript ai-sdkclaude-codeclicode-searchcodexcoding-agentscontext-retrievaldeveloper-toolsjevsemantic-searchtypescriptvercel-ai-gateway
fix skill installer path handling
David Zhang46b1a5e75f32
diff --git a/apps/cli/src/skill.ts b/apps/cli/src/skill.tsindex c9f35f0..d3122bd 100644--- a/apps/cli/src/skill.ts+++ b/apps/cli/src/skill.ts@@ -5,6 +5,29 @@ import { CliError } from "./errors";declare const JEVGREP_BUNDLED: boolean;+const windowsCommandMetaCharacters = /([()[\]{}%!^"`<>&|;, *?])/g;++function escapeWindowsCommand(command: string): string {+ return command.replace(windowsCommandMetaCharacters, "^$1");+}++function escapeWindowsArgument(argument: string): string {+ let escaped = argument;+ // Preserve literal quotes and trailing backslashes when cmd.exe parses the+ // quoted argument. This follows the Windows command-line quoting rules.+ escaped = escaped.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');+ escaped = escaped.replace(/(?=(\\+?)?)\1$/g, "$1$1");+ return `"${escaped}"`.replace(windowsCommandMetaCharacters, "^$1");+}++function windowsInstallerCommand(args: string[]): string[] {+ const command = [+ escapeWindowsCommand("npx"),+ ...args.map((argument) => escapeWindowsArgument(argument)),+ ].join(" ");+ return ["/d", "/s", "/c", `"${command}"`];+}+export async function installSkill(command: Extract<Command, { kind: "skill" }>,signal: AbortSignal,@@ -24,12 +47,19 @@ export async function installSkill(if (command.yes) args.push("--yes");signal.throwIfAborted();return new Promise((resolve, reject) => {- const child = spawn("npx", args, {- // Preserve installer prompts while keeping all CLI output on stdout.- stdio: ["inherit", process.stdout, process.stdout],- signal,- killSignal: "SIGINT",- });+ const windows = process.platform === "win32";+ const child = spawn(+ windows ? (process.env.ComSpec ?? process.env.comspec ?? "cmd.exe") : "npx",+ windows ? windowsInstallerCommand(args) : args,+ {+ // Preserve installer prompts while keeping all CLI output on stdout.+ stdio: ["inherit", process.stdout, process.stdout],+ shell: false,+ windowsVerbatimArguments: windows,+ signal,+ killSignal: "SIGINT",+ },+ );child.once("error", (error: NodeJS.ErrnoException) =>reject(error.code === "ENOENT"diff --git a/scripts/test-suite.sh b/scripts/test-suite.shindex 65267a0..64cd1e7 100644--- a/scripts/test-suite.sh+++ b/scripts/test-suite.sh@@ -2,6 +2,7 @@set -euo pipefailbun test --timeout 30000 ./apps/cli/test ./packages/core/test ./test/discovery.test.ts ./test/evaluator.test.ts ./test/retrieval.test.ts ./test/retrieval-freshness.test.tsnode --test packages/core/test-node/provider-protocol.mjs+node --test test/skill.test.mjsnode --experimental-strip-types --test test/parser/*.test.tsnode --test test/release.test.mjspython3 -B -m unittest discover -s evals/implementation/swebench -p test_installed.pydiff --git a/test/skill.test.mjs b/test/skill.test.mjsnew file mode 100644index 0000000..8048180--- /dev/null+++ b/test/skill.test.mjs@@ -0,0 +1,82 @@+import assert from "node:assert/strict";+import { execFile } from "node:child_process";+import { cp, mkdir, mkdtemp, readFile, realpath, rm, symlink, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { delimiter, dirname, join } from "node:path";+import { test } from "node:test";+import { fileURLToPath } from "node:url";+import { promisify } from "node:util";++test("skill installer preserves local source arguments through the platform launcher", async (t) => {+ const home = await mkdtemp(join(tmpdir(), "jevgrep-skill-"));+ t.after(() => rm(home, { recursive: true, force: true }));+ const checkoutRoot = fileURLToPath(new URL("../", import.meta.url));+ const checkoutScratch = await mkdtemp(join(tmpdir(), ".tmp-skill-"));+ t.after(() => rm(checkoutScratch, { recursive: true, force: true }));+ await symlink(+ join(checkoutRoot, "node_modules"),+ join(checkoutScratch, "node_modules"),+ "junction",+ );+ const bin = join(home, "installer with spaces");+ await mkdir(bin);+ const fixture = fileURLToPath(new URL("./fixtures/skill-installer.mjs", import.meta.url));+ const windows = process.platform === "win32";+ await writeFile(+ join(bin, windows ? "npx.cmd" : "npx"),+ windows+ ? `@echo off\r\n"${process.execPath}" "${fixture}" %*\r\n`+ : `#!/bin/sh\nexec "${process.execPath}" "${fixture}" "$@"\n`,+ { mode: 0o755 },+ );++ let cli = process.env.JEVGREP_TEST_CLI;+ let packageDist;+ if (cli) {+ packageDist = dirname(dirname(cli));+ } else {+ packageDist = join(checkoutScratch, "cli bundle & with spaces", "dist");+ await cp(fileURLToPath(new URL("../apps/cli/dist", import.meta.url)), packageDist, {+ recursive: true,+ });+ cli = join(packageDist, "bin", "index.js");+ }+ const source = await realpath(join(packageDist, "skills", "jevgrep"));+ const result = await promisify(execFile)(+ process.execPath,+ [cli, "skill", "--agent", "claude-code", "--agent", "codex", "--global", "--yes"],+ {+ cwd: home,+ env: {+ ...process.env,+ HOME: home,+ XDG_CONFIG_HOME: home,+ XDG_CACHE_HOME: join(home, "cache"),+ PATH: [bin, dirname(process.execPath), process.env.PATH].join(delimiter),+ JEVGREP_INSTALLER_EXIT: "7",+ },+ timeout: 10000,+ },+ ).then(+ () => assert.fail("The installer exit status must reach the CLI"),+ (error) => error,+ );+ assert.equal(result.code, 7);+ assert.equal(result.stdout, "Installer completed.\n");+ assert.equal(result.stderr, "");+ assert.deepEqual(JSON.parse(await readFile(join(home, "installed-skill.json"), "utf8")), [+ "--yes",+ "--ignore-scripts",+ "[email protected]",+ "add",+ source,+ "--skill",+ "jevgrep",+ "--agent",+ "claude-code",+ "--agent",+ "codex",+ "--global",+ "--yes",+ ]);+});