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
16 changes: 15 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -628,6 +639,9 @@ function printDreamResult(result: Awaited<ReturnType<typeof dreamMaybe>>) {

function usage() {
console.log(`Usage:
openbrain version
openbrain --version
openbrain -V
openbrain init
openbrain update [--yes]
openbrain setup [--brain-scope default|paths] [--path-rule <brain=/path>] [--codex yes|no] [--claude yes|no] [--disable-claude-auto-memory yes|no]
Expand Down
6 changes: 6 additions & 0 deletions tests/install-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading