From ced56f8d9d4c3fccc4393a80cce53e2f4ad2a264 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 5 May 2026 01:01:34 -0400 Subject: [PATCH 1/2] fix(vite): bundle cli for npx runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed the build to target Node SSR instead of Vite’s default client/lib pipeline, and stopped externalizing the TUI stack. The relevant change is in `vite.config.mts:6: build.ssr = 'src/cli.ts'`, a fixed `cli.js` entry name, and removal of `react`/`ink`/`@inkjs/ui` from external. That removes the emitted Rolldown fallback that was throwing `Calling require for "react"` when the binary was launched via `npx`. The new build no longer contains that runtime stub, and `node dist/cli.js --help` now runs successfully. --- vite.config.mts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vite.config.mts b/vite.config.mts index 15ecd0e9..47505985 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -5,23 +5,19 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ build: { target: 'node24', - lib: { - entry: 'src/cli.ts', - formats: ['es'], - fileName: 'cli', - }, + ssr: 'src/cli.ts', rolldownOptions: { + output: { + entryFileNames: 'cli.js', + }, external: [ - '@inkjs/ui', 'cac', - 'ink', 'node:child_process', 'node:fs', 'node:os', 'node:path', 'node:util', 'ollama', - 'react', ], }, }, From 672331ffabb70de3dfe0f99630e18e2aa388dc5a Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 5 May 2026 01:07:42 -0400 Subject: [PATCH 2/2] ci(github): verify packaged cli via npm exec in test.yml --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee727abf..f499d5c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,6 +49,16 @@ jobs: - name: Build package run: npm run build + - name: Verify CLI via npm exec + run: | + package_archive=$(npm pack | tail -n 1) + temp_dir=$(mktemp -d) + cd "$temp_dir" + output=$(npm exec --yes --package "${GITHUB_WORKSPACE}/${package_archive}" code-ollama -- --help) + printf '%s\n' "$output" + grep -F "code-ollama" <<< "$output" + grep -F "run " <<< "$output" + - name: Setup Ollama uses: ai-action/setup-ollama@v2