Skip to content
Merged
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
11 changes: 9 additions & 2 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ jobs:
# other targets are cross-compiled — we trust bun's compile output
# for them and verify post-release.
if: matrix.target == 'bun-linux-x64-modern'
run: ./${{ matrix.asset }} --version || true
run: |
EXPECTED="$(node -p "require('./package.json').version")"
ACTUAL="$(./${{ matrix.asset }} --version)"
test "${ACTUAL}" = "${EXPECTED}"

- name: Upload to GitHub release
env:
Expand Down Expand Up @@ -149,5 +152,9 @@ jobs:
# needing real credentials.
shell: pwsh
run: |
./codebase.exe --version
$expected = node -p "require('./package.json').version"
$actual = ./codebase.exe --version
if ($actual.Trim() -ne $expected.Trim()) {
throw "Version mismatch: expected $expected, got $actual"
}
./codebase.exe --help
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codebase-cli",
"version": "2.0.0-pre.84",
"version": "2.0.0-pre.85",
"description": "Codebase CLI — a TypeScript coding agent on the pi-mono runtime. OAuth-aware, any LLM provider, single install.",
"keywords": [
"ai",
Expand Down
27 changes: 5 additions & 22 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import packageMetadata from "../package.json";

/**
* Resolves the running CLI's version at runtime by reading the bundled
* package.json. This is the single source of truth for "what am I
* running" — surfaced in the welcome banner, the status bar, and the
* `--version` flag so the user can never wonder again whether their
* shell is launching the build they just compiled.
*
* Fallback to "?.?.?" if the lookup fails for any reason; a missing
* version string shouldn't crash the agent.
* Keep package.json as the single source of truth, but import it so native
* Bun builds embed the version instead of trying to read a neighboring file
* that does not exist beside a standalone binary.
*/
export const VERSION: string = (() => {
try {
// dist/version.js → dist/ → package.json
// src/version.ts (via tsx) → src/ → package.json
const here = dirname(fileURLToPath(import.meta.url));
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8")) as { version?: string };
return pkg.version ?? "?.?.?";
} catch {
return "?.?.?";
}
})();
export const VERSION = packageMetadata.version;
Loading