Introduce AGENTS.md (root, primary agent instruction file) documenting six hard-won fixes with explicit DO NOT / WHY, plus executable enforcement so a future AI cannot delete or reintroduce them: 1. package-lock.json must be generated with npm 10 (Docker's npm 10.9.8). npm 11 drops the top-level @emnapi/core + @emnapi/runtime entries npm 10 needs, breaking the tag-triggered Docker build at `npm ci` (happened on v1.0.14). Add scripts/verify-lockfile-npm10.mjs + .npmrc + a Dockerfile fail-fast check + a CI step + tests/unit/lockfile-npm10-guard.test.js. Also re-fix the lockfile itself (regenerated with npm 10.9.8). 2. Tests must never write to the real ~/.9router DB (isolateDataDir). 3. Hidden providers must not leak into Usage (usageProviders !p.hidden). 4. codebuddy-intl connection test + OAuth identity. 5. Fork-only features that must survive upstream syncs. 6. Upstream sync procedure. Each marker cross-references AGENTS.md and the covering test. CLAUDE.md now points to AGENTS.md at the top. Verified: build ok, guard script passes, full suite leaves the real DB count unchanged (38), 0 new regressions.
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// Global test isolation: never let the unit/translator suite write to the user's
|
|
// real database (~/.9router). Some tests (e.g. zed-live-models, zed-native-auth)
|
|
// exercise real route handlers that call createProviderConnection — without this
|
|
// they append test rows ("zed-live-*@example.com", "guard-*@example.com",
|
|
// "Account N") straight into the live DB.
|
|
//
|
|
// GUARD — DO NOT DELETE this file or remove it from vitest.config.js setupFiles.
|
|
// See AGENTS.md §2. Covered by tests/unit/test-data-dir-isolation.test.js.
|
|
//
|
|
// DATA_DIR must be set before src/lib/dataDir.js is imported (it reads the env
|
|
// at module-eval time), which is exactly what a vitest setupFile guarantees.
|
|
//
|
|
// Escape hatches:
|
|
// - RUN_REAL=1 → keep the real DATA_DIR so *.real.test.js can read it.
|
|
// - DATA_DIR=<path> → respect an explicit override (CI / manual isolation).
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const RUN_REAL = process.env.RUN_REAL === "1";
|
|
const explicit = process.env.DATA_DIR;
|
|
|
|
if (!RUN_REAL && !explicit) {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "9router-test-"));
|
|
process.env.DATA_DIR = dir;
|
|
process.on("exit", () => {
|
|
try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
});
|
|
}
|