Lines 211-251javascript
212 * Install `agentdb` + `better-sqlite3` as LOCAL project deps so the session-hook writer can
213 * `import('agentdb')` and get a native SQLite store (better-sqlite3 ships prebuilt binaries — no
214 * build tools — and gives true cross-process WAL concurrency so the hook and the MCP server share
215 * one live store). Best-effort: returns false (caller degrades to jsonl) if install fails.
217function installAgentdbLocally(projectRoot) {
218 if (isAgentdbInstalledLocally(projectRoot))
221 // Anchor npm to THIS project: without a package.json here, npm's prefix walk-up would
222 // install into (and mutate the lockfile of) the nearest ANCESTOR project (audit code#2).
223 const pkgJsonPath = join(projectRoot, 'package.json');
224 if (!existsSync(pkgJsonPath)) {
225 writeFileSync(pkgJsonPath, JSON.stringify({ name: 'dz-harness-project', private: true, version: '0.0.0' }, null, 2) + '\n');
227 // NB: use the ESM-imported execSync — `require()` is undefined in this ESM module (the
228 // original agentdb hooks failed silently for exactly this reason). stdio:'ignore' (not
229 // 'pipe') avoids execSync's 1 MB maxBuffer aborting the child on npm's verbose output.
230 // --save-exact: agentdb is alpha; a semver range would let a later `npm update` drift the
231 // local copy away from the version the MCP registration pins (audit gap G7).
232 execSync('npm install agentdb better-sqlite3 --save-exact --no-audit --no-fund --loglevel=error', {
233 cwd: projectRoot,
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
dist/setup.jsView on unpkg · L231 237 return isAgentdbInstalledLocally(projectRoot);
243/** Run full environment setup. */
244/** Marker that brackets the dz-harness section in a shared CLAUDE.md/AGENTS.md. */
245const DRIVER_MARKER_START = '<!-- dz-harness-driver:start -->';
246const DRIVER_MARKER_END = '<!-- dz-harness-driver:end -->';
248 * Operating instructions for a coding agent that should *drive* the dz CLI
249 * correctly. Inspired by Visa VVAH `--install-agents`: the toolkit ships its own
250 * "how to operate me" doc so agents use the CLI as intended rather than guessing.