Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(exports): expose the gbrain/version subpath (#4771)

time-attack9e84f27983b4
diff --git a/package.json b/package.json
index 3343c73dcf..c5f6e17a53 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,8 @@
"./ingestion/test-harness": "./src/core/ingestion/test-harness.ts",
"./core/guardrails": "./src/core/guardrails.ts",
"./core/skillopt": "./src/core/skillopt/index.ts",
- "./pglite-lock": "./src/core/pglite-lock.ts"
+ "./pglite-lock": "./src/core/pglite-lock.ts",
+ "./version": "./src/version.ts"
},
"scripts": {
"dev": "bun run src/cli.ts",
diff --git a/test/fixtures/export-consumer/consumer.ts b/test/fixtures/export-consumer/consumer.ts
index 0087ec9c43..5c375aa195 100644
--- a/test/fixtures/export-consumer/consumer.ts
+++ b/test/fixtures/export-consumer/consumer.ts
@@ -36,6 +36,7 @@ import { GuardrailLoadError as e24 } from 'gbrain/core/guardrails';
import { loadHeldOut as e25 } from 'gbrain/core/skillopt';
import { LiveServeLockError as e26 } from 'gbrain/pglite-lock';
import { assembleEvidenceForHits as e27 } from 'gbrain/search/evidence-delivery';
+import { VERSION as e28 } from 'gbrain/version';
import type { BrainEngine } from 'gbrain/engine';
import type { PageInput, SearchResult } from 'gbrain/types';
import { PGLiteEngine } from 'gbrain/pglite-engine';
@@ -69,6 +70,7 @@ export const RUNTIME_IMPORTS: readonly unknown[] = [
e25,
e26,
e27,
+ e28,
];
export function makeEngine(): BrainEngine {
diff --git a/test/fixtures/goldens/exports/runtime.json b/test/fixtures/goldens/exports/runtime.json
index 72f4004d0f..5e065d636e 100644
--- a/test/fixtures/goldens/exports/runtime.json
+++ b/test/fixtures/goldens/exports/runtime.json
@@ -859,6 +859,9 @@
"affectsRecall",
"assertNever",
"isCRMode"
+ ],
+ "./version": [
+ "VERSION"
]
}
},
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index a228e4045b..48079e14cd 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -8538,6 +8538,15 @@
"(value: unknown) => value is CRMode"
]
}
+ ],
+ "./version": [
+ {
+ "kind": "variable",
+ "name": "VERSION",
+ "signature": [
+ "string"
+ ]
+ }
]
},
"normalizer": "export-types-v1"
diff --git a/test/public-exports.test.ts b/test/public-exports.test.ts
index eeaccf767c..7ef0eb9c97 100644
--- a/test/public-exports.test.ts
+++ b/test/public-exports.test.ts
@@ -63,6 +63,7 @@ const EXPECTED_EXPORTS: ExpectedExport[] = [
// cat30–33 consume, replacing physical node_modules deep imports.
{ subpath: 'gbrain/core/skillopt', canary: ['runSkillOpt', 'scoreSkillOnTasks', 'loadHeldOut'] },
{ subpath: 'gbrain/pglite-lock', canary: ['peekLock'] },
+ { subpath: 'gbrain/version', canary: ['VERSION'] },
];
function readPackageExports(): Record<string, string> {
@@ -79,7 +80,8 @@ describe('public exports — package.json exports map', () => {
// Removing exports: see CLAUDE.md "Removing any of these is a
// breaking change going forward" — bump minor and update this count.
// 23→24 (2026-08 fix wave): ./core/skillopt (audit skillopt-cats-11).
- expect(count).toBe(28);
+ // 28→29: ./version (gbrain-evals reads the installed version directly).
+ expect(count).toBe(29);
});
test('EXPECTED_EXPORTS list matches the exports map exactly (no drift)', () => {
@@ -114,3 +116,17 @@ describe('public exports — every subpath resolves via package name', () => {
}
}
});
+
+describe('public exports — gbrain/version', () => {
+ test('VERSION is the package version and importing it boots nothing', async () => {
+ const repoRoot = resolve(import.meta.dir, '..');
+ const pkgVersion = (await import('../package.json')).default.version;
+ const proc = Bun.spawnSync(
+ [process.execPath, '-e', "const m = await import('gbrain/version'); process.stdout.write(JSON.stringify(Object.keys(m)) + ' ' + m.VERSION);"],
+ { cwd: repoRoot, env: { PATH: process.env.PATH ?? '/usr/bin:/bin' }, stdout: 'pipe', stderr: 'pipe' },
+ );
+ expect(proc.stderr.toString()).toBe('');
+ expect(proc.exitCode).toBe(0);
+ expect(proc.stdout.toString()).toBe(`["VERSION"] ${pkgVersion}`);
+ });
+});