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
test: verify packed CLI natively on Apple Silicon
David Zhangf4544193a7c2
diff --git a/scripts/RELEASING.md b/scripts/RELEASING.mdindex dfd0979..fce37e7 100644--- a/scripts/RELEASING.md+++ b/scripts/RELEASING.md@@ -30,3 +30,19 @@ asset checks. [The build](build-cli.ts) copies the authored MIT license and[Retained license sources](licenses/README.md) document upstream distribution gaps.The archive excludes test fixtures, evaluation evidence, node_modules directories, source maps,and repository source. Runtime parser dependencies install from exact npm pins.++On an Apple Silicon Mac, run `node scripts/test-native.mjs` after the normal+`bun install --frozen-lockfile` setup. This builds and packs the candidate, installs+it with npm outside the checkout, and runs the credential-free commands and+synthetic Python search against a loopback Gateway fixture. To verify an existing+archive without Bun, use `node scripts/test-native.mjs --prebuilt /path/package.tgz`.+The command prints the archive hash and actual Node/macOS runtime for retained+evidence. It requires Node 22 or newer; a result proves the printed version only.++Native installation uses temporary npm configuration, HOME, and XDG directories.+The installed process receives a PATH containing only Node, so host Python, Bun,+and compiler installations cannot satisfy runtime dependencies. All fixture+credentials are synthetic, and local commands must make no Gateway requests.+This bounded smoke complements the Docker suites; filesystem-policy tests still+run only in their isolated Docker environment. npm installation needs network+access to resolve the exact runtime dependencies; search uses only loopback HTTP.diff --git a/scripts/test-native.mjs b/scripts/test-native.mjsnew file mode 100644index 0000000..9323333--- /dev/null+++ b/scripts/test-native.mjs@@ -0,0 +1,155 @@+#!/usr/bin/env node+import assert from "node:assert/strict";+import { execFile, spawnSync } from "node:child_process";+import { createHash } from "node:crypto";+import { cp, mkdir, mkdtemp, readFile, realpath, rm, symlink, writeFile } from "node:fs/promises";+import { release, tmpdir } from "node:os";+import { dirname, join, resolve } from "node:path";+import { fileURLToPath } from "node:url";+import { promisify } from "node:util";+const execute = promisify(execFile);+const root = fileURLToPath(new URL("../", import.meta.url));+let scratch;+try {+ assert.equal(+ process.platform,+ "darwin",+ "Native smoke requires macOS; use test-installed.sh for Linux",+ );+ assert.equal(process.arch, "arm64", "This native gate covers macOS Apple Silicon");+ assert.ok(Number(process.versions.node.split(".")[0]) >= 22, "Node >=22 is required");+ const args = process.argv.slice(2);+ assert.ok(+ args.length === 0 || (args.length === 2 && args[0] === "--prebuilt"),+ "Usage: node scripts/test-native.mjs [--prebuilt package.tgz]",+ );+ scratch = await mkdtemp(join(tmpdir(), "jg-native-"));+ const home = join(scratch, "home"),+ config = join(scratch, "config"),+ cache = join(scratch, "cache"),+ runtimeBin = join(scratch, "runtime-bin");+ await Promise.all([home, config, cache, runtimeBin].map((path) => mkdir(path)));+ const npmrc = join(scratch, "npmrc");+ await writeFile(npmrc, "");+ // Development tooling may build/pack; none of its environment reaches the installed app.+ const setupEnv = {+ PATH: `${dirname(process.execPath)}:/usr/bin:/bin`,+ HOME: home,+ XDG_CONFIG_HOME: config,+ XDG_CACHE_HOME: cache,+ TMPDIR: scratch,+ npm_config_cache: join(scratch, "npm-cache"),+ npm_config_userconfig: npmrc,+ npm_config_registry: "https://registry.npmjs.org",+ NODE_AUTH_TOKEN: "",+ };+ let tarball;+ if (args.length) {+ tarball = join(scratch, "candidate.tgz");+ await cp(resolve(args[1]), tarball);+ } else {+ await execute("bun", ["run", "--cwd", "apps/cli", "build"], {+ cwd: root,+ env: { ...setupEnv, PATH: process.env.PATH },+ timeout: 120_000,+ maxBuffer: 8_000_000,+ });+ const packed = await execute(+ "npm",+ ["pack", "./apps/cli", "--json", "--ignore-scripts", "--pack-destination", scratch],+ {+ cwd: root,+ env: setupEnv,+ timeout: 120_000,+ maxBuffer: 8_000_000,+ },+ );+ const packages = JSON.parse(packed.stdout);+ assert.equal(packages.length, 1);+ tarball = join(scratch, packages[0].filename);+ }+ const integrity = createHash("sha256")+ .update(await readFile(tarball))+ .digest("hex");+ const prefix = join(scratch, "prefix");+ await execute(+ "npm",+ [+ "install",+ "--global",+ "--prefix",+ prefix,+ "--ignore-scripts",+ "--omit=dev",+ "--no-audit",+ "--no-fund",+ tarball,+ ],+ {+ cwd: scratch,+ env: setupEnv,+ timeout: 180_000,+ maxBuffer: 8_000_000,+ },+ );+ const binary = join(prefix, "bin/jg");+ const packageDirectory = await realpath(join(prefix, "lib/node_modules/@dzhng/jevgrep"));+ assert.ok(+ (await realpath(binary)).startsWith(`${packageDirectory}/`),+ "Executable must belong to the fresh npm install",+ );+ const skill = join(scratch, "canonical-skill.md");+ await cp(process.env.JEVGREP_CANONICAL_SKILL || join(root, "skills/jevgrep/SKILL.md"), skill);+ await symlink(process.execPath, join(runtimeBin, "node"));+ const runtimeEnv = {+ PATH: runtimeBin,+ HOME: home,+ XDG_CONFIG_HOME: config,+ XDG_CACHE_HOME: cache,+ TMPDIR: scratch,+ AI_GATEWAY_API_KEY: "",+ AI_GATEWAY_BASE_URL: "http://127.0.0.1:1/unused",+ JEVGREP_INSTALLED_BINARY: binary,+ JEVGREP_INSTALLED_PACKAGE: packageDirectory,+ JEVGREP_EXPECTED_SKILL: skill,+ JEVGREP_TEST_PATH: runtimeBin,+ };+ for (const command of ["python3", "bun", "cc", "gcc", "clang", "make"])+ assert.equal(+ spawnSync(command, ["--version"], { env: runtimeEnv }).error?.code,+ "ENOENT",+ `${command} must not resolve in the installed runtime PATH`,+ );+ console.log(+ `Native proof: ${process.platform}/${process.arch} ${release()}; Node ${process.version}; tarball SHA-256 ${integrity}`,+ );+ const tested = await execute(+ process.execPath,+ [+ "--test",+ "--test-reporter=tap",+ "--test-concurrency=1",+ "--test-name-pattern",+ "^(installed local commands match the package without credentials|actual installed search parses Python and returns every relevant hierarchy branch)$",+ join(root, "test/installed.test.mjs"),+ ],+ { cwd: scratch, env: runtimeEnv, timeout: 120_000, maxBuffer: 8_000_000 },+ );+ assert.equal(tested.stderr, "");+ assert.match(+ tested.stdout,+ /^# pass 2$/m,+ "Both native smoke journeys must execute; renamed selectors cannot silently pass",+ );+ console.log(tested.stdout.trimEnd());+ console.log(+ "Native installed smoke passed; all fixtures, credentials, cache and installation were temporary.",+ );+} catch (error) {+ if (error.stdout) console.log(String(error.stdout).trimEnd());+ if (error.stderr) console.log(String(error.stderr).trimEnd());+ console.log(`Native installed smoke failed: ${error.message}`);+ process.exitCode = 1;+} finally {+ if (scratch) await rm(scratch, { recursive: true, force: true });+}diff --git a/test/installed.test.mjs b/test/installed.test.mjsindex 4d83b55..bd83489 100644--- a/test/installed.test.mjs+++ b/test/installed.test.mjs@@ -202,7 +202,7 @@ async function context(t, mode = "healthy") {server.listen(0, "127.0.0.1", resolve);});const env = {- PATH: "/opt/jevgrep/bin:/usr/local/bin:/usr/bin:/bin",+ PATH: process.env.JEVGREP_TEST_PATH ?? "/opt/jevgrep/bin:/usr/local/bin:/usr/bin:/bin",HOME: home,XDG_CONFIG_HOME: config,XDG_CACHE_HOME: cache,@@ -298,13 +298,16 @@ function complete(result) {}}-test("installed runtime has no checkout or Python/Bun/compiler prerequisites", async (t) => {+test("installed runtime has no checkout or Python/Bun/compiler prerequisites", async () => {for (const executable of ["python3", "bun", "cc", "gcc", "clang", "make"]) {const result = spawnSync(executable, ["--version"], { encoding: "utf8" });assert.equal(result.error?.code, "ENOENT", `${executable} must be absent from final runtime`);}await assert.rejects(access("/checkout"), { code: "ENOENT" });assert.ok((await realpath(binary)).startsWith(`${packageDirectory}/`));+});++test("installed local commands match the package without credentials", async (t) => {const fixture = await context(t);const metadata = JSON.parse(await readFile(join(packageDirectory, "package.json"), "utf8"));assert.equal(metadata.name, "@dzhng/jevgrep");