From c1f04770e86ef84f4918103f6db0288ea2f45f7f Mon Sep 17 00:00:00 2001 From: Faraazuddin Mohammed Date: Tue, 19 May 2026 10:41:11 -0400 Subject: [PATCH] fix: report promptc CLI package version --- .changeset/fix-cli-version.md | 5 +++++ packages/cli/src/index.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-cli-version.md diff --git a/.changeset/fix-cli-version.md b/.changeset/fix-cli-version.md new file mode 100644 index 0000000..97be2e7 --- /dev/null +++ b/.changeset/fix-cli-version.md @@ -0,0 +1,5 @@ +--- +"@promptc/cli": patch +--- + +Report the CLI package version from package.json instead of a stale hard-coded value. diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 3c4ac09..2614494 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -23,6 +23,7 @@ // 3 pass precondition failure (an explicitly-requested pass refused to run) import { parseArgs } from "node:util"; +import { readFileSync } from "node:fs"; import { validateIR, type SourceFormat } from "@promptc/ir"; import { codegen } from "@promptc/codegen"; @@ -30,7 +31,13 @@ import { runPipeline, type PassRecord, listAllPasses } from "./pipeline.js"; import { parseSource } from "./parse.js"; import { tokenCount } from "./tokens.js"; -const VERSION = "0.0.1"; +const VERSION = readPackageVersion(); + +function readPackageVersion(): string { + const packageJsonUrl = new URL("../package.json", import.meta.url); + const packageJson = JSON.parse(readFileSync(packageJsonUrl, "utf8")) as { version?: string }; + return packageJson.version ?? "0.0.0"; +} interface OptimizeFlags { target: "cost" | "tokens" | "none"; @@ -732,4 +739,3 @@ See docs/PASSES.md for per-pass preconditions, postconditions, and behavior-preservation arguments. `); } -