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
5 changes: 5 additions & 0 deletions .changeset/fix-cli-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@promptc/cli": patch
---

Report the CLI package version from package.json instead of a stale hard-coded value.
10 changes: 8 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
// 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";
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";
Expand Down Expand Up @@ -732,4 +739,3 @@ See docs/PASSES.md for per-pass preconditions, postconditions, and
behavior-preservation arguments.
`);
}

Loading