diff --git a/src/cli.ts b/src/cli.ts index 16d6258..435743d 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -39,11 +39,22 @@ import { type SetupInput, type SetupPathRuleInput } from "./types.js"; -import { applyUpdate, maybePrintUpdateNotice, planUpdate, type UpdatePlan } from "./update.js"; +import { + applyUpdate, + maybePrintUpdateNotice, + planUpdate, + readCurrentVersion, + type UpdatePlan +} from "./update.js"; async function main(argv: string[]) { const [area, command, ...rest] = argv; + if (area === "version" || area === "--version" || area === "-V") { + console.log(await readCurrentVersion()); + return; + } + if (area === "init") { await initOpenBrain(); console.log("OpenBrain initialized."); @@ -628,6 +639,9 @@ function printDreamResult(result: Awaited>) { function usage() { console.log(`Usage: + openbrain version + openbrain --version + openbrain -V openbrain init openbrain update [--yes] openbrain setup [--brain-scope default|paths] [--path-rule ] [--codex yes|no] [--claude yes|no] [--disable-claude-auto-memory yes|no] diff --git a/tests/install-script.test.ts b/tests/install-script.test.ts index 5b185ab..30a22af 100644 --- a/tests/install-script.test.ts +++ b/tests/install-script.test.ts @@ -84,6 +84,12 @@ describe("install script", () => { }); expect(stdout).toContain("openbrain init"); expect(stdout).toContain("openbrain setup"); + + const packageJson = JSON.parse(await readFile(path.join(installDir, "package.json"), "utf8")); + for (const argument of ["version", "--version", "-V"]) { + const result = await execFileAsync(path.join(binDir, "openbrain"), [argument]); + expect(result.stdout.trim()).toBe(packageJson.version); + } }, 90_000); test("can preserve an existing executable wrapper during an update", async () => {