Skip to content

armgit / cogit

Public Imported from GitHub
0

Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.

build(release): take the npm and plugin versions from VERSION

Erena309ad216fee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c88863e..82bc269 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `codelineage session write --consume`: deletes the `--file` input once the record is saved and keeps it when the write fails. `gitPolicy=commit` now also ignores `.codelineage/inbox/`.
### Changed
+- The npm package and the plugin manifest now take their version from `VERSION` (the one `./release` bumps): `npm run build` and `npm pack` copy it through `scripts/sync-version.mjs`, and a test fails while they differ. Both move from 0.1.0 to 0.4.0, so the first release continues at 0.5.0.
- Map: inside a session the nodes now read top to bottom, as an indented outline (phases in order along a left spine, their steps, decisions and questions indented below), so the map grows downwards instead of sideways.
- Map: the graph now spans the full window width and nearly its full height (the header and status card stay at a readable width), and a "Full screen" button expands it over the whole window, entering browser full screen when allowed; Esc or the button closes it.
- `commander`, `zod` and `@inquirer/prompts` moved to `devDependencies`: they are bundled into `dist/cli.js`, so installing the package pulls in no runtime dependencies.
diff --git a/packages/cli/.claude-plugin/plugin.json b/packages/cli/.claude-plugin/plugin.json
index c22c22c..3a8677a 100644
--- a/packages/cli/.claude-plugin/plugin.json
+++ b/packages/cli/.claude-plugin/plugin.json
@@ -1,9 +1,11 @@
{
"name": "codelineage",
"displayName": "codelineage",
- "version": "0.1.0",
+ "version": "0.4.0",
"description": "The lineage of your AI coding sessions: records what each session decided and why, and renders it as a static map.",
- "author": { "name": "Eren Sertkaya" },
+ "author": {
+ "name": "Eren Sertkaya"
+ },
"license": "MIT",
"keywords": ["lineage", "sessions", "history", "decisions"]
}
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 92c733c..8326623 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "codelineage",
- "version": "0.1.0",
+ "version": "0.4.0",
"description": "The lineage of your AI coding sessions.",
"license": "MIT",
"type": "module",
@@ -17,7 +17,9 @@
"node": ">=22.13.0"
},
"scripts": {
- "build": "tsup"
+ "prebuild": "node ../../scripts/sync-version.mjs",
+ "build": "tsup",
+ "prepack": "node ../../scripts/sync-version.mjs"
},
"devDependencies": {
"@inquirer/prompts": "^8.7.4",
diff --git a/packages/cli/test/plugin-manifest.test.ts b/packages/cli/test/plugin-manifest.test.ts
index 205effe..f3ed725 100644
--- a/packages/cli/test/plugin-manifest.test.ts
+++ b/packages/cli/test/plugin-manifest.test.ts
@@ -10,6 +10,9 @@ describe("plugin packaging", () => {
const plugin = await read("../.claude-plugin/plugin.json");
// An npm-sourced plugin without a version resolves to "unknown" and never updates.
expect(plugin.version).toBe(pkg.version);
+ // VERSION is the source; `npm run build` copies it (scripts/sync-version.mjs).
+ const version = (await readFile(new URL("../../../VERSION", import.meta.url), "utf8")).trim();
+ expect(pkg.version, "run npm run build to sync VERSION").toBe(version);
expect(plugin.name).toBe(pkg.name);
expect(pkg.files).toEqual(
expect.arrayContaining(["dist", ".claude-plugin", "skills", "hooks"]),
diff --git a/packages/cli/test/sync-version.test.ts b/packages/cli/test/sync-version.test.ts
new file mode 100644
index 0000000..e2af8eb
--- /dev/null
+++ b/packages/cli/test/sync-version.test.ts
@@ -0,0 +1,29 @@
+import { mkdir, readFile, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+// @ts-expect-error plain ESM script without types
+import { run, syncVersion, TARGETS } from "../../../scripts/sync-version.mjs";
+import { tempDir } from "./helpers.js";
+
+describe("sync-version", () => {
+ it("copies VERSION into the npm and plugin manifests, keeping other keys", async () => {
+ const root = await tempDir();
+ await writeFile(join(root, "VERSION"), "1.2.3\n");
+ for (const rel of TARGETS as string[]) {
+ await mkdir(join(root, rel, ".."), { recursive: true });
+ await writeFile(join(root, rel), JSON.stringify({ name: "x", version: "0.1.0" }));
+ }
+ expect(syncVersion(root)).toEqual({ version: "1.2.3", changed: TARGETS });
+ for (const rel of TARGETS as string[]) {
+ expect(JSON.parse(await readFile(join(root, rel), "utf8"))).toEqual({
+ name: "x",
+ version: "1.2.3",
+ });
+ }
+ expect(syncVersion(root).changed).toEqual([]);
+ });
+
+ it("leaves this repository unchanged when it is already in sync", () => {
+ expect(run(() => {})).toEqual([]);
+ });
+});
diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs
new file mode 100644
index 0000000..5d55c66
--- /dev/null
+++ b/scripts/sync-version.mjs
@@ -0,0 +1,31 @@
+#!/usr/bin/env node
+// VERSION is the single source (./release bumps it); npm and the plugin manifest copy it.
+import { readFileSync, writeFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+export const TARGETS = ["packages/cli/package.json", "packages/cli/.claude-plugin/plugin.json"];
+
+/** Copies VERSION into every target; returns the files it changed. */
+export function syncVersion(root) {
+ const version = readFileSync(join(root, "VERSION"), "utf8").trim();
+ const changed = [];
+ for (const rel of TARGETS) {
+ const file = join(root, rel);
+ const json = JSON.parse(readFileSync(file, "utf8"));
+ if (json.version === version) continue;
+ json.version = version;
+ writeFileSync(file, `${JSON.stringify(json, null, 2)}\n`);
+ changed.push(rel);
+ }
+ return { version, changed };
+}
+
+/** Syncs this repository and prints each changed file. */
+export function run(log = console.log) {
+ const { version, changed } = syncVersion(join(dirname(fileURLToPath(import.meta.url)), ".."));
+ for (const rel of changed) log(`${rel}: version ${version}`);
+ return changed;
+}
+
+if (process.argv[1] === fileURLToPath(import.meta.url)) run();
diff --git a/vitest.config.ts b/vitest.config.ts
index aedad4d..3d6fbea 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -23,7 +23,7 @@ export default defineConfig({
globalSetup: ["./packages/cli/test/global-setup.ts"],
coverage: {
provider: "v8",
- include: ["packages/*/src/**"],
+ include: ["packages/*/src/**", "scripts/**"],
exclude: ["packages/cli/src/cli.ts"],
reporter: ["text-summary", "lcov"],
},