xonecas.io
64875
Mc

mini-coder / commit 2832b6d

embed version at build time to fix missing version in global binary

Replace runtime package.json lookup with a compile-time define so the
version is baked into dist/mc.js. Previously, resolving
../../package.json relative to import.meta.url failed when the binary
was globally installed (no package.json alongside it), causing the
banner to display 'vunknown'.

- Add scripts/build.ts using Bun.build() with --define __PACKAGE_VERSION__
- Update package.json build script to run scripts/build.ts
- Remove readFileSync lookup in output.ts; use the injected constant

Sean2026-02-23 2832b6d8bf444a2c5dc6f41fffedd0ae106b3bc2 parent f19a753

4 files changed

TODO.md+12−2
@@ -2,9 +2,19 @@
22
33 ---
44
5-## Review agent is missing subagent output features.
5+# Missing version on globally installed binary
66
7-As the title says, there is no visibility to actions of the /review subagent
7+Investigate why when I use the global installed binary, the version appears as:
8+
9+```sh
10+❯ mc
11+
12+ mc mini-coder · vunknown
13+ zen/claude-sonnet-4-6 · /Users/seancaetanomartin/src/mini-coder
14+ /help for commands · ctrl+d to exit
15+
16+· MCP: connected exa
17+```
818
919 ---
1020
package.json+1−1
@@ -8,7 +8,7 @@
88 "mc": "./dist/mc.js"
99 },
1010 "scripts": {
11- "build": "bun build src/index.ts --target=bun --outfile=dist/mc.js --packages=external",
11+ "build": "bun run scripts/build.ts",
1212 "dev": "bun run src/index.ts",
1313 "typecheck": "tsc --noEmit",
1414 "lint": "biome check src",
scripts/build.ts+19−0
@@ -0,0 +1,19 @@
1+import pkg from "../package.json";
2+
3+const result = await Bun.build({
4+ entrypoints: ["src/index.ts"],
5+ target: "bun",
6+ outdir: "dist",
7+ naming: "mc.js",
8+ packages: "external",
9+ define: {
10+ __PACKAGE_VERSION__: JSON.stringify(pkg.version),
11+ },
12+});
13+
14+if (!result.success) {
15+ for (const log of result.logs) {
16+ console.error(log);
17+ }
18+ process.exit(1);
19+}
src/cli/output.ts+3−13
@@ -1,4 +1,3 @@
1-import { readFileSync } from "node:fs";
21 import { homedir } from "node:os";
32
43 import * as c from "yoctocolors";
@@ -6,18 +5,9 @@ import type { TurnEvent } from "../llm-api/types.ts";
65 import { renderChunk } from "./markdown.ts";
76
87 const HOME = homedir();
9-const PACKAGE_VERSION = (() => {
10- try {
11- const raw = readFileSync(
12- new URL("../../package.json", import.meta.url),
13- "utf8",
14- );
15- const data = JSON.parse(raw) as { version?: string };
16- return data.version ?? "unknown";
17- } catch {
18- return "unknown";
19- }
20-})();
8+declare const __PACKAGE_VERSION__: string;
9+const PACKAGE_VERSION =
10+ typeof __PACKAGE_VERSION__ !== "undefined" ? __PACKAGE_VERSION__ : "unknown";
2111
2212 // ─── Terminal restore ─────────────────────────────────────────────────────────