chore: migrate from bun to pnpm + vitest + esbuild

- Replace bun:test with vitest across all packages
- Replace bun build with esbuild
- Replace bun:sqlite with better-sqlite3
- Fix OCAS Store API: store.put/get → store.cas.put/get
- Fix vitest vi.mock hoisting (vi.hoisted)
- Add pnpm-workspace.yaml and pnpm-lock.yaml
- Update all package.json test/build scripts

WIP: 8 failures remain in agent-hermes (bun engines check + sqlite migration)

Refs #26
This commit is contained in:
2026-06-03 14:33:03 +00:00
parent 0d93e56acd
commit e5e6de2fad
93 changed files with 6675 additions and 647 deletions
@@ -1,5 +1,4 @@
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { HermesAcpClient } from "../src/acp-client.js";
describe("handleSessionUpdate — text extraction", () => {
@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from 'vitest';
import type { ThreadId } from "@united-workforce/protocol";
import type { AgentContext } from "@united-workforce/util-agent";
import { buildHermesPrompt } from "../src/hermes.js";
@@ -1,5 +1,4 @@
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { HermesAcpClient } from "../../src/acp-client.js";
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -1,5 +1,4 @@
import { afterEach, describe, expect, it } from "bun:test";
import { afterEach, describe, expect, it } from 'vitest';
import { HermesAcpClient } from "../../src/acp-client.js";
/**
@@ -1,8 +1,10 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from 'vitest';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { readFileSync } from "node:fs";
import { join } from "node:path";
const PKG_ROOT = join(import.meta.dir, "..");
const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
describe("Issue #551 — bin entry & engines", () => {
test("package.json declares bun in engines", () => {
@@ -1,5 +1,5 @@
import { Database } from "bun:sqlite";
import { describe, expect, test } from "bun:test";
import Database from "better-sqlite3";
import { describe, expect, test } from 'vitest';
import { mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -106,7 +106,7 @@ describe("storeHermesSessionDetail", () => {
expect(output).toBe("done");
const detailNode = store.get(detailHash);
const detailNode = store.cas.get(detailHash);
expect(detailNode).not.toBeNull();
if (detailNode === null) {
return;
+8 -10
View File
@@ -12,23 +12,24 @@
},
"exports": {
".": {
"bun": "./src/index.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"scripts": {
"prepublishOnly": "echo 'Use bun run release from repo root' && exit 1",
"test": "bun test __tests__/",
"test:ci": "bun test __tests__/"
"prepublishOnly": "echo 'Use pnpm run release from repo root' && exit 1",
"test": "vitest run __tests__/",
"test:ci": "vitest run __tests__/"
},
"dependencies": {
"@ocas/core": "^0.1.1",
"@united-workforce/util-agent": "workspace:^",
"@ocas/core": "^0.2.2",
"@united-workforce/protocol": "workspace:^",
"@united-workforce/util": "workspace:^"
"@united-workforce/util": "workspace:^",
"@united-workforce/util-agent": "workspace:^",
"better-sqlite3": "^12.10.0"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.13",
"typescript": "^5.8.3"
},
"publishConfig": {
@@ -43,8 +44,5 @@
"bugs": {
"url": "https://git.shazhou.work/shazhou/united-workforce/issues"
},
"engines": {
"bun": ">= 1.0.0"
},
"license": "MIT"
}
+6 -6
View File
@@ -1,4 +1,4 @@
import { Database } from "bun:sqlite";
import Database from "better-sqlite3";
import { readFile } from "node:fs/promises";
import { homedir } from "node:os";
import { join } from "node:path";
@@ -156,13 +156,13 @@ export function loadHermesSessionFromDb(
try {
db = new Database(resolvedPath, { readonly: true });
const session = db
.query("SELECT id, model, started_at FROM sessions WHERE id = ?")
.prepare("SELECT id, model, started_at FROM sessions WHERE id = ?")
.get(sessionId) as DbSessionRow | null;
if (session === null) {
return null;
}
const rows = db
.query(
.prepare(
"SELECT role, content, reasoning, tool_calls FROM messages WHERE session_id = ? ORDER BY id",
)
.all(sessionId) as DbMessageRow[];
@@ -285,7 +285,7 @@ export async function storeHermesSessionDetail(
if (turn === null) {
continue;
}
const hash = await store.put(schemas.turn, turn);
const hash = await store.cas.put(schemas.turn, turn);
turnHashes.push(hash);
turnIndex += 1;
}
@@ -297,12 +297,12 @@ export async function storeHermesSessionDetail(
turnCount: turnHashes.length,
turns: turnHashes,
};
const detailHash = await store.put(schemas.detail, detail);
const detailHash = await store.cas.put(schemas.detail, detail);
const output = extractLastAssistantContent(session.messages);
return { detailHash, output };
}
export async function storeHermesRawOutput(store: Store, rawOutput: string): Promise<string> {
const schemas = await registerHermesSchemas(store);
return store.put(schemas.rawOutput, { text: rawOutput });
return store.cas.put(schemas.rawOutput, { text: rawOutput });
}