Lines 1-34javascript
5 * Draht Quality Gate Hook
6 * Runs after task completion to enforce quality standards.
7 * Called by the build agent after each verify step.
9 * Usage: node gsd-quality-gate.js [--strict] [--no-tests]
10 * --no-tests skips the test-suite run (used by the Stop hook, where the
11 * post-task hook and /verify-work own test execution).
12 * Exit 0 = quality OK, Exit 1 = quality issues
15const { execSync } = require("node:child_process");
16const fs = require("node:fs");
17const path = require("node:path");
19// ── Toolchain detection — mirrors src/gsd/hook-utils.ts ──────────────────────
20function detectToolchain(cwd) {
21 if (fs.existsSync(path.join(cwd, "bun.lockb")) || fs.existsSync(path.join(cwd, "bun.lock"))) {
22 return { pm: "bun", testCmd: "bun test", coverageCmd: "bun test --coverage", lintCmd: "bunx biome check ." };
23 }
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
scripts/gsd-quality-gate.cjsView on unpkg · L14 24 if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) {
25 return { pm: "pnpm", testCmd: "pnpm test", coverageCmd: "pnpm run test:coverage", lintCmd: "pnpm run lint" };
27 if (fs.existsSync(path.join(cwd, "yarn.lock"))) {
28 return { pm: "yarn", testCmd: "yarn test", coverageCmd: "yarn run test:coverage", lintCmd: "yarn run lint" };
30 return { pm: "npm", testCmd: "npm test", coverageCmd: "npm run test:coverage", lintCmd: "npm run lint" };
33function readHookConfig(cwd) {
34 // Strict by default: failing tests/types/lint fail the gate (exit 1).