8 Commits

Author SHA1 Message Date
xiaoju 9d17be8b7b release: v0.3.0 2026-06-03 23:06:00 +00:00
xiaomo 7e9bd26fec fix: suppress ExperimentalWarning in tests via NODE_NO_WARNINGS env
- Use NODE_NO_WARNINGS=1 in execFileSync env instead of --no-warnings flag
- Remove overly broad process.removeAllListeners('warning') from CLI entry
- Add engines field requiring Node >=22.5.0 (node:sqlite availability)
- Update proman to 0.4.2
2026-06-03 23:02:43 +00:00
xiaomo 3168bf55c3 chore: add changeset for node:sqlite migration 2026-06-03 22:30:15 +00:00
xiaomo 00a536631a refactor: migrate from better-sqlite3 to node:sqlite
- Replace better-sqlite3 with built-in node:sqlite (DatabaseSync)
- Add transaction() helper for manual BEGIN/COMMIT/ROLLBACK
- Suppress ExperimentalWarning in CLI tests with --no-warnings
- Remove better-sqlite3 from dependencies and onlyBuiltDependencies
- No more native addon compilation issues across Node versions
2026-06-03 22:11:44 +00:00
xiaomo f8103e20ce chore: bump @shazhou/proman to 0.4.0, remove link override 2026-06-03 16:30:24 +00:00
xiaomo 5c567dc455 Revert "Merge pull request 'chore: remove redundant vite/vitest devDeps' (#69) from chore/remove-redundant-devdeps into main"
This reverts commit 08a2bddcf0, reversing
changes made to 36ebf42f2f.
2026-06-03 15:15:38 +00:00
xiaomo 08a2bddcf0 Merge pull request 'chore: remove redundant vite/vitest devDeps' (#69) from chore/remove-redundant-devdeps into main 2026-06-03 14:28:35 +00:00
xiaomo 6fc3b9030b chore: remove redundant vite/vitest devDeps (proman bundles them) 2026-06-03 14:25:35 +00:00
33 changed files with 219 additions and 945 deletions
+9 -4
View File
@@ -2,9 +2,11 @@
"name": "@ocas/workspace",
"private": true,
"devDependencies": {
"@shazhou/proman": "0.2.2",
"@biomejs/biome": "^2.4.16",
"@shazhou/proman": "0.4.2",
"@types/node": "^25.9.1",
"tsx": "^4.22.4",
"typescript": "^6.0.3",
"ulidx": "^2.4.1",
"vite": "^8.0.16",
"vitest": "^4.1.8"
@@ -20,13 +22,16 @@
"url": "https://github.com/shazhou-ww/ocas.git"
},
"homepage": "https://github.com/shazhou-ww/ocas",
"engines": {
"node": ">=22.5.0"
},
"bugs": {
"url": "https://github.com/shazhou-ww/ocas/issues"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild",
"better-sqlite3"
]
"esbuild"
],
"overrides": {}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@ocas/cli",
"version": "0.2.2",
"version": "0.3.0",
"type": "module",
"bin": {
"ocas": "dist/index.js"
+2 -1
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env node
import { existsSync, readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { homedir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
import type { Hash, ListEntry, ListOptions, Store, TagOp } from "@ocas/core";
import {
applyListOptions,
@@ -466,5 +466,5 @@ Flags:
--epsilon <n> Cutoff threshold for render (default: 0.01)
--pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope)
Agent: If you have not installed the ocas skill for this version (0.2.2), run \`ocas prompt setup\` and follow the instructions."
Agent: If you have not installed the ocas skill for this version (0.3.0), run \`ocas prompt setup\` and follow the instructions."
`;
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
// ---- @ Alias Resolution Tests ----
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue, stripVolatile } from "./helpers";
const entrypoint = resolve(import.meta.dirname, "../dist/index.js");
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue } from "./helpers";
const entrypoint = resolve(import.meta.dirname, "../dist/index.js");
+2 -2
View File
@@ -1,11 +1,11 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Hash } from "@ocas/core";
import { bootstrap, validate } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
let testDir: string;
let storePath: string;
+5 -1
View File
@@ -1,3 +1,4 @@
import { execFileSync } from "node:child_process";
import {
mkdirSync,
mkdtempSync,
@@ -5,7 +6,6 @@ import {
rmSync,
writeFileSync,
} from "node:fs";
import { execFileSync } from "node:child_process";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import type { JSONSchema } from "@ocas/core";
@@ -47,6 +47,8 @@ export async function putSchemaFile(
return hash;
}
const quietEnv = { ...process.env, NODE_NO_WARNINGS: "1" };
/**
* Run CLI command. Accepts either a string[] or ...string[] (rest args).
* If first arg is an array, uses that as args. Otherwise treats all args as the command.
@@ -62,6 +64,7 @@ export function runCli(
const stdout = execFileSync("node", finalArgs, {
encoding: "utf-8",
timeout: 10000,
env: quietEnv,
});
return { stdout, stderr: "", exitCode: 0 };
} catch (e: unknown) {
@@ -85,6 +88,7 @@ export function runCliWithStdin(
input: stdin,
encoding: "utf-8",
timeout: 10000,
env: quietEnv,
});
return { stdout, stderr: "", exitCode: 0 };
} catch (e: unknown) {
+1 -1
View File
@@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { BOOTSTRAP_STORE } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { envValue, runCli } from "./helpers.js";
let storePath: string;
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { envValue, runCli } from "./helpers.js";
const HASH_RE = /^[0-9A-HJKMNP-TV-Z]{13}$/;
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
let testDir: string;
let storePath: string;
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue } from "./helpers";
const entrypoint = resolve(import.meta.dirname, "../dist/index.js");
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue, stripVolatile } from "./helpers";
const entrypoint = resolve(import.meta.dirname, "../dist/index.js");
+2 -2
View File
@@ -1,10 +1,10 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { bootstrap } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue, putSchemaFile, runCli, runCliWithStdin } from "./helpers";
const entrypoint = resolve(import.meta.dirname, "../dist/index.js");
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue, putSchemaFile, runCli } from "./helpers";
// ---- Issue #50: Schema Validation in put Command ----
+2 -2
View File
@@ -1,11 +1,11 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Hash } from "@ocas/core";
import { bootstrap } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
let testDir: string;
let storePath: string;
+2 -2
View File
@@ -1,11 +1,11 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Hash, Store } from "@ocas/core";
import { bootstrap } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
// ---- Test helpers ----
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
const usagePath = join(import.meta.dirname, "..", "prompts", "usage.md");
+2 -2
View File
@@ -1,11 +1,11 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Hash, Store } from "@ocas/core";
import { bootstrap } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
let testDir: string;
let storePath: string;
+2 -2
View File
@@ -1,11 +1,11 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { mkdirSync, rmSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Hash, Store } from "@ocas/core";
import { bootstrap, putSchema } from "@ocas/core";
import { openStore as openFsStore } from "@ocas/fs";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
// ---- Test helpers ----
+2 -2
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { envValue, stripVolatile } from "./helpers";
const entrypoint = resolve(import.meta.dirname, "../dist/index.js");
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@ocas/core",
"version": "0.2.2",
"version": "0.3.0",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { readdirSync, readFileSync, statSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
function* walk(dir: string): Generator<string> {
for (const name of readdirSync(dir)) {
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
import type {
CasNode,
CasStore,
+4
View File
@@ -1,5 +1,9 @@
# @ocas/fs
## 0.3.0 — 2026-06-03
- Migrate from better-sqlite3 to built-in node:sqlite — zero native addon dependencies, no more NODE_MODULE_VERSION mismatch across Node upgrades.
## 0.2.0
### Breaking Changes
+1 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ocas/fs",
"version": "0.2.2",
"version": "0.3.0",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -16,7 +16,6 @@
],
"dependencies": {
"@ocas/core": "workspace:*",
"better-sqlite3": "^12.10.0",
"cborg": "^4.2.3"
},
"repository": {
@@ -29,7 +28,6 @@
"url": "https://github.com/shazhou-ww/ocas/issues"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.13",
"@types/node": "^25.9.1"
}
}
+1 -1
View File
@@ -1,2 +1,2 @@
export { createFsStore, openStore, prepareStore } from "./store.js";
export { createSqliteVarStore } from "./sqlite-store.js";
export { createFsStore, openStore, prepareStore } from "./store.js";
+49 -41
View File
@@ -1,6 +1,6 @@
import { existsSync, mkdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import Database from "better-sqlite3";
import { DatabaseSync } from "node:sqlite";
import type {
CasStore,
Hash,
@@ -27,19 +27,31 @@ import {
varKey,
} from "@ocas/core";
function transaction<T>(db: DatabaseSync, fn: () => T): T {
db.exec("BEGIN");
try {
const r = fn();
db.exec("COMMIT");
return r;
} catch (e) {
db.exec("ROLLBACK");
throw e;
}
}
const DB_FILE = "_store.db";
const VARS_FILE = "_vars.jsonl";
const TAGS_FILE = "_tags.jsonl";
function openDb(dir: string): Database.Database {
function openDb(dir: string): DatabaseSync {
mkdirSync(dir, { recursive: true });
const db = new Database(join(dir, DB_FILE));
db.pragma("journal_mode = WAL");
db.pragma("foreign_keys = ON");
const db = new DatabaseSync(join(dir, DB_FILE));
db.exec("PRAGMA journal_mode = WAL");
db.exec("PRAGMA foreign_keys = ON");
return db;
}
function initVarTables(db: Database.Database): void {
function initVarTables(db: DatabaseSync): void {
db.exec(`
CREATE TABLE IF NOT EXISTS vars (
name TEXT NOT NULL,
@@ -67,7 +79,7 @@ function initVarTables(db: Database.Database): void {
`);
}
function initTagTables(db: Database.Database): void {
function initTagTables(db: DatabaseSync): void {
db.exec(`
CREATE TABLE IF NOT EXISTS tags (
target TEXT NOT NULL,
@@ -90,11 +102,7 @@ type StoredTag = {
created: number;
};
function migrateJsonlVars(
db: Database.Database,
dir: string,
_cas: CasStore,
): void {
function migrateJsonlVars(db: DatabaseSync, dir: string, _cas: CasStore): void {
const path = join(dir, VARS_FILE);
if (!existsSync(path)) return;
@@ -131,7 +139,7 @@ function migrateJsonlVars(
VALUES (?, ?, ?, ?, ?)
`);
const migrate = db.transaction(() => {
transaction(db, () => {
for (const rec of records.values()) {
insertVar.run(
rec.name,
@@ -147,10 +155,9 @@ function migrateJsonlVars(
}
}
});
migrate();
}
function migrateJsonlTags(db: Database.Database, dir: string): void {
function migrateJsonlTags(db: DatabaseSync, dir: string): void {
const path = join(dir, TAGS_FILE);
if (!existsSync(path)) return;
@@ -196,14 +203,13 @@ function migrateJsonlTags(db: Database.Database, dir: string): void {
VALUES (?, ?, ?, ?)
`);
const migrate = db.transaction(() => {
transaction(db, () => {
for (const tm of byTarget.values()) {
for (const tag of tm.values()) {
insertTag.run(tag.target, tag.key, tag.value, tag.created);
}
}
});
migrate();
}
// ── Row helpers ──
@@ -304,17 +310,17 @@ export function createSqliteVarStore(
// ── Transactional helpers ──
const txnSetVar = db.transaction(
(
name: string,
schema: Hash,
hash: Hash,
now: number,
tagsJson: string,
labelsJson: string,
isNew: boolean,
valueChanged: boolean,
) => {
function txnSetVar(
name: string,
schema: Hash,
hash: Hash,
now: number,
tagsJson: string,
labelsJson: string,
isNew: boolean,
valueChanged: boolean,
): void {
transaction(db, () => {
if (isNew) {
stmtInsertVar.run(name, schema, hash, now, now, tagsJson, labelsJson);
stmtInsertHistory.run(name, schema, hash, 0, now);
@@ -329,11 +335,11 @@ export function createSqliteVarStore(
} else {
stmtUpdateVar.run(hash, now, tagsJson, labelsJson, name, schema);
}
},
);
});
}
const txnTagOps = db.transaction(
(target: Hash, operations: TagOp[], now: number) => {
function txnTagOps(target: Hash, operations: TagOp[], now: number): void {
transaction(db, () => {
for (const op of operations) {
if (op.op === "set") {
// Use ON CONFLICT to preserve created time — but we need existing created
@@ -346,14 +352,16 @@ export function createSqliteVarStore(
stmtDeleteTag.run(target, op.key);
}
}
},
);
});
}
const txnUntag = db.transaction((target: Hash, keys: string[]) => {
for (const k of keys) {
stmtDeleteTag.run(target, k);
}
});
function txnUntag(target: Hash, keys: string[]): void {
transaction(db, () => {
for (const k of keys) {
stmtDeleteTag.run(target, k);
}
});
}
// ── VarStore implementation ──
const varStore: VarStore = {
@@ -516,7 +524,7 @@ export function createSqliteVarStore(
// Build dynamic query
const conditions: string[] = [];
const params: unknown[] = [];
const params: (string | number | null)[] = [];
if (options?.exactName !== undefined) {
conditions.push("name = ?");
@@ -650,7 +658,7 @@ export function createSqliteVarStore(
const limit = options?.limit;
let sql: string;
const params: unknown[] = [key];
const params: (string | number | null)[] = [key];
if (value !== undefined) {
sql = `SELECT target FROM tags WHERE key = ? AND value = ? ORDER BY ${sortCol} ${sortDir}`;
params.push(value);
+1 -1
View File
@@ -1,4 +1,3 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import {
existsSync,
mkdtempSync,
@@ -17,6 +16,7 @@ import {
computeSelfHash,
verify,
} from "@ocas/core";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { createFsStore, openStore } from "./store.js";
+1 -1
View File
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { existsSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { openStore } from "./store.js";
const T1 = "AAAAAAAAAAAAA";
+1 -1
View File
@@ -1,4 +1,3 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { existsSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -11,6 +10,7 @@ import {
TagLabelConflictError,
VariableNotFoundError,
} from "@ocas/core";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { openStore } from "./store.js";
const META_TYPE_KEY = Symbol.for("@ocas/core/bootstrap-store");
+108 -854
View File
File diff suppressed because it is too large Load Diff