@vyuhlabs/dxkit 2.12.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +246 -287
- package/dist/allowlist/hint.d.ts +1 -1
- package/dist/allowlist/hint.d.ts.map +1 -1
- package/dist/allowlist/hint.js +6 -3
- package/dist/allowlist/hint.js.map +1 -1
- package/dist/baseline/check.d.ts +7 -0
- package/dist/baseline/check.d.ts.map +1 -1
- package/dist/baseline/check.js +3 -1
- package/dist/baseline/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +101 -14
- package/dist/cli.js.map +1 -1
- package/dist/dashboard/graph-tab.d.ts.map +1 -1
- package/dist/dashboard/graph-tab.js +6 -3
- package/dist/dashboard/graph-tab.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +13 -12
- package/dist/doctor.js.map +1 -1
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +8 -2
- package/dist/generator.js.map +1 -1
- package/dist/issue-cli.d.ts +1 -1
- package/dist/issue-cli.js +1 -1
- package/dist/loop/demo.d.ts +12 -0
- package/dist/loop/demo.d.ts.map +1 -0
- package/dist/loop/demo.js +331 -0
- package/dist/loop/demo.js.map +1 -0
- package/dist/loop/doctor.d.ts +37 -0
- package/dist/loop/doctor.d.ts.map +1 -0
- package/dist/loop/doctor.js +320 -0
- package/dist/loop/doctor.js.map +1 -0
- package/dist/loop/ledger-cli.d.ts +7 -0
- package/dist/loop/ledger-cli.d.ts.map +1 -0
- package/dist/loop/ledger-cli.js +95 -0
- package/dist/loop/ledger-cli.js.map +1 -0
- package/dist/loop/ledger.d.ts +95 -0
- package/dist/loop/ledger.d.ts.map +1 -0
- package/dist/loop/ledger.js +201 -0
- package/dist/loop/ledger.js.map +1 -0
- package/dist/loop/policy.d.ts +35 -0
- package/dist/loop/policy.d.ts.map +1 -0
- package/dist/loop/policy.js +151 -0
- package/dist/loop/policy.js.map +1 -0
- package/dist/loop/scaffold.d.ts +28 -0
- package/dist/loop/scaffold.d.ts.map +1 -0
- package/dist/loop/scaffold.js +224 -0
- package/dist/loop/scaffold.js.map +1 -0
- package/dist/loop/stop-gate.d.ts +71 -0
- package/dist/loop/stop-gate.d.ts.map +1 -0
- package/dist/loop/stop-gate.js +295 -0
- package/dist/loop/stop-gate.js.map +1 -0
- package/dist/self-invocation.d.ts +77 -0
- package/dist/self-invocation.d.ts.map +1 -0
- package/dist/self-invocation.js +157 -0
- package/dist/self-invocation.js.map +1 -0
- package/dist/ship-installers.d.ts.map +1 -1
- package/dist/ship-installers.js +8 -0
- package/dist/ship-installers.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +22 -5
- package/dist/update.js.map +1 -1
- package/dist/upgrade.d.ts +3 -3
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +5 -4
- package/dist/upgrade.js.map +1 -1
- package/package.json +6 -4
- package/templates/.claude/skills/dxkit-config/SKILL.md +17 -0
- package/templates/.claude/skills/dxkit-init/SKILL.md +1 -0
- package/templates/.claude/skills/dxkit-learn/SKILL.md +17 -0
- package/templates/.claude/skills/dxkit-loop/SKILL.md +114 -0
- package/templates/.claude/skills/dxkit-onboard/SKILL.md +2 -0
- package/templates/.claude/skills/dxkit-update/SKILL.md +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/loop/scaffold.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,sDAYC;AA+ID,8CAMC;AA5OD;;;;;;;;;;;;;;;GAeG;AACH,uCAAyB;AACzB,2CAA6B;AAE7B,qCAAgE;AAChE,wDAA8C;AAE9C;;;4EAG4E;AAC/D,QAAA,iBAAiB,GAAG,IAAA,0BAAQ,EAAC,gBAAg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EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC1F,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3B,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC/B,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vyuh-dxkit hook stop-gate` — the Claude Code **Stop hook** body.
|
|
3
|
+
*
|
|
4
|
+
* Purpose: stop an autonomous loop from declaring "done" while the
|
|
5
|
+
* deterministic guardrail still reports net-new findings. When the gate
|
|
6
|
+
* blocks, it feeds the exact net-new findings back to the model so the
|
|
7
|
+
* loop can repair them and try to stop again.
|
|
8
|
+
*
|
|
9
|
+
* Claude Code Stop-hook contract used here:
|
|
10
|
+
* - The hook receives a JSON payload on stdin (session_id, cwd,
|
|
11
|
+
* stop_hook_active, optional agent fields).
|
|
12
|
+
* - To BLOCK the stop AND have the model read an actionable message,
|
|
13
|
+
* the hook prints `{"decision":"block","reason":"..."}` on stdout and
|
|
14
|
+
* exits 0. (Exit code 2 also blocks, but its stderr reaches only the
|
|
15
|
+
* operator, not the model — wrong for a repair loop, so it's reserved
|
|
16
|
+
* here for operator-facing config failures.)
|
|
17
|
+
* - `stop_hook_active` is true when the model is already continuing
|
|
18
|
+
* because a prior Stop-gate blocked this turn. Claude Code caps
|
|
19
|
+
* consecutive blocks, so an un-fixable failure can't loop forever;
|
|
20
|
+
* we still keep blocking on net-new findings (the safety guarantee)
|
|
21
|
+
* and rely on that cap as the backstop.
|
|
22
|
+
*
|
|
23
|
+
* Posture:
|
|
24
|
+
* - Net-new findings → block every time (the model CAN fix these).
|
|
25
|
+
* - Guardrail could not run (no baseline, dxkit error) → an operator/
|
|
26
|
+
* preflight problem the model can't fix. Fail closed by surfacing it
|
|
27
|
+
* once (exit 2, operator-visible) then allow on the next attempt to
|
|
28
|
+
* avoid thrashing to the block cap. `DXKIT_LOOP_FAIL_OPEN=1` allows
|
|
29
|
+
* immediately with a loud warning instead. Never a silent skip.
|
|
30
|
+
*/
|
|
31
|
+
import type { GuardrailJsonPayload } from '../baseline/check-renderers';
|
|
32
|
+
import { type LedgerEvent } from './ledger';
|
|
33
|
+
/** Subset of the Claude Code Stop-hook stdin payload we consume. */
|
|
34
|
+
interface StopHookPayload {
|
|
35
|
+
readonly session_id?: string;
|
|
36
|
+
readonly cwd?: string;
|
|
37
|
+
readonly stop_hook_active?: boolean;
|
|
38
|
+
readonly agent_id?: string;
|
|
39
|
+
readonly agent_type?: string;
|
|
40
|
+
}
|
|
41
|
+
/** What the gate decided, before any process I/O. */
|
|
42
|
+
export interface StopGateDecision {
|
|
43
|
+
/** 'allow' → exit 0 silent; 'block-model' → exit 0 + decision JSON;
|
|
44
|
+
* 'block-operator' → exit 2 + stderr. */
|
|
45
|
+
readonly outcome: 'allow' | 'block-model' | 'block-operator';
|
|
46
|
+
/** Message fed to the model (block-model) or operator (block-operator). */
|
|
47
|
+
readonly message: string;
|
|
48
|
+
/** Ledger event recorded for this decision. */
|
|
49
|
+
readonly event: LedgerEvent;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build the repair-friendly message the model reads when blocked. Lists
|
|
53
|
+
* each net-new finding with the location it must fix, and is explicit
|
|
54
|
+
* about the two anti-patterns (refresh baseline / fix grandfathered debt)
|
|
55
|
+
* so the loop stays scoped to what IT introduced.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildRepairMessage(json: GuardrailJsonPayload): string;
|
|
58
|
+
/**
|
|
59
|
+
* Run the gate. Pure of stdout/exit — returns a decision the CLI wrapper
|
|
60
|
+
* turns into process output + exit code. `runCheck` is injected so tests
|
|
61
|
+
* can drive the gate without a real repo + baseline.
|
|
62
|
+
*/
|
|
63
|
+
export declare function computeStopGate(cwd: string, payload: StopHookPayload, runCheck: (repoDir: string) => Promise<GuardrailJsonPayload>): Promise<StopGateDecision>;
|
|
64
|
+
/**
|
|
65
|
+
* CLI entry for `vyuh-dxkit hook stop-gate`. Reads the hook payload from
|
|
66
|
+
* stdin, runs the guardrail in-process, writes the ledger + last-guardrail
|
|
67
|
+
* snapshot, then emits the Stop-hook decision and exits.
|
|
68
|
+
*/
|
|
69
|
+
export declare function runStopGate(cwd: string): Promise<void>;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=stop-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop-gate.d.ts","sourceRoot":"","sources":["../../src/loop/stop-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,UAAU,CAAC;AAKlB,oEAAoE;AACpE,UAAU,eAAe;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B;8CAC0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,gBAAgB,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAuBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CA2BrE;AAqBD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,GAC3D,OAAO,CAAC,gBAAgB,CAAC,CAiI3B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmD5D"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildRepairMessage = buildRepairMessage;
|
|
37
|
+
exports.computeStopGate = computeStopGate;
|
|
38
|
+
exports.runStopGate = runStopGate;
|
|
39
|
+
const ledger_1 = require("./ledger");
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
/** Read and parse the stdin hook payload; {} on any problem. */
|
|
44
|
+
function readStdinPayload() {
|
|
45
|
+
let raw = '';
|
|
46
|
+
try {
|
|
47
|
+
raw = fs.readFileSync(0, 'utf8');
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
if (!raw.trim())
|
|
53
|
+
return {};
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(raw);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Blocking pairs (classifier blocks AND not waived by an allowlist). */
|
|
62
|
+
function blockingPairs(json) {
|
|
63
|
+
return json.pairs.filter((p) => p.blocks && p.suppressedByAllowlist === undefined);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build the repair-friendly message the model reads when blocked. Lists
|
|
67
|
+
* each net-new finding with the location it must fix, and is explicit
|
|
68
|
+
* about the two anti-patterns (refresh baseline / fix grandfathered debt)
|
|
69
|
+
* so the loop stays scoped to what IT introduced.
|
|
70
|
+
*/
|
|
71
|
+
function buildRepairMessage(json) {
|
|
72
|
+
const blocking = blockingPairs(json);
|
|
73
|
+
const n = blocking.length;
|
|
74
|
+
const lines = [];
|
|
75
|
+
lines.push(`dxkit blocked completion because this branch introduces ${n} net-new ` +
|
|
76
|
+
`finding${n === 1 ? '' : 's'}.`);
|
|
77
|
+
lines.push('');
|
|
78
|
+
lines.push('Do not refresh the baseline.');
|
|
79
|
+
lines.push('Do not fix unrelated grandfathered debt.');
|
|
80
|
+
lines.push('Fix only the net-new findings below, then try to stop again.');
|
|
81
|
+
lines.push('');
|
|
82
|
+
blocking.forEach((p, i) => {
|
|
83
|
+
const loc = p.file ? `${p.file}${p.line !== undefined ? `:${p.line}` : ''}` : '(no location)';
|
|
84
|
+
const sev = p.severity ? ` [${p.severity}]` : '';
|
|
85
|
+
lines.push(`${i + 1}. ${p.kind}${sev}`);
|
|
86
|
+
lines.push(` location: ${loc}`);
|
|
87
|
+
const detail = p.reasons.find((r) => r.detail)?.detail;
|
|
88
|
+
if (detail)
|
|
89
|
+
lines.push(` reason: ${detail}`);
|
|
90
|
+
});
|
|
91
|
+
lines.push('');
|
|
92
|
+
lines.push(`Full machine-readable detail: ${path.join(ledger_1.LEDGER_DIR, 'last-guardrail.json')} ` +
|
|
93
|
+
`(read it and fix only these net-new findings).`);
|
|
94
|
+
return lines.join('\n');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Optional configured test command (DXKIT_LOOP_TEST_COMMAND). Runs only
|
|
98
|
+
* after the guardrail passes. Returns the status plus a short failure
|
|
99
|
+
* tail to surface in the block message. `not_configured` when unset.
|
|
100
|
+
*/
|
|
101
|
+
function runConfiguredTests(repoDir) {
|
|
102
|
+
const cmd = process.env.DXKIT_LOOP_TEST_COMMAND;
|
|
103
|
+
if (!cmd || !cmd.trim())
|
|
104
|
+
return { status: 'not_configured', tail: '' };
|
|
105
|
+
try {
|
|
106
|
+
(0, child_process_1.execSync)(cmd, { cwd: repoDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
107
|
+
return { status: 'pass', tail: '' };
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
const e = err;
|
|
111
|
+
const out = `${e.stdout ?? ''}${e.stderr ?? ''}`.trim();
|
|
112
|
+
const tail = out.split('\n').slice(-15).join('\n');
|
|
113
|
+
return { status: 'fail', tail };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Run the gate. Pure of stdout/exit — returns a decision the CLI wrapper
|
|
118
|
+
* turns into process output + exit code. `runCheck` is injected so tests
|
|
119
|
+
* can drive the gate without a real repo + baseline.
|
|
120
|
+
*/
|
|
121
|
+
async function computeStopGate(cwd, payload, runCheck) {
|
|
122
|
+
const start = Date.now();
|
|
123
|
+
const repoDir = payload.cwd || cwd;
|
|
124
|
+
const stopActive = !!payload.stop_hook_active;
|
|
125
|
+
const failOpen = process.env.DXKIT_LOOP_FAIL_OPEN === '1';
|
|
126
|
+
const session = payload.session_id || '';
|
|
127
|
+
const agentFields = {
|
|
128
|
+
...(payload.agent_id ? { agent_id: payload.agent_id } : {}),
|
|
129
|
+
...(payload.agent_type ? { agent_type: payload.agent_type } : {}),
|
|
130
|
+
};
|
|
131
|
+
let json;
|
|
132
|
+
try {
|
|
133
|
+
json = await runCheck(repoDir);
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
// Guardrail could not run — a preflight/config problem (no baseline,
|
|
137
|
+
// dxkit error) the model cannot repair.
|
|
138
|
+
const msg = err.message || String(err);
|
|
139
|
+
const allow = failOpen || stopActive;
|
|
140
|
+
const event = (0, ledger_1.buildLedgerEvent)(repoDir, {
|
|
141
|
+
session_id: session,
|
|
142
|
+
...agentFields,
|
|
143
|
+
cwd: repoDir,
|
|
144
|
+
guardrail_status: 'error',
|
|
145
|
+
net_new_findings: 0,
|
|
146
|
+
baseline_findings: 0,
|
|
147
|
+
files_changed: 0,
|
|
148
|
+
allowed: allow,
|
|
149
|
+
stop_hook_active: stopActive,
|
|
150
|
+
tests_status: 'skipped',
|
|
151
|
+
lint_status: 'not_configured',
|
|
152
|
+
typecheck_status: 'not_configured',
|
|
153
|
+
duration_ms: Date.now() - start,
|
|
154
|
+
});
|
|
155
|
+
if (allow) {
|
|
156
|
+
return {
|
|
157
|
+
outcome: 'allow',
|
|
158
|
+
event,
|
|
159
|
+
message: `dxkit Stop-gate could not run the guardrail (${msg}). Allowing stop. ` +
|
|
160
|
+
`Fix the loop preflight (run \`vyuh-dxkit baseline create\` / ` +
|
|
161
|
+
`\`vyuh-dxkit loop doctor\`) before trusting unattended runs.`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
outcome: 'block-operator',
|
|
166
|
+
event,
|
|
167
|
+
message: `dxkit Stop-gate could not run the guardrail: ${msg}\n` +
|
|
168
|
+
`This is a loop preflight problem, not something the agent can fix. ` +
|
|
169
|
+
`Run \`vyuh-dxkit loop doctor\` / \`vyuh-dxkit baseline create\`, or set ` +
|
|
170
|
+
`DXKIT_LOOP_FAIL_OPEN=1 to allow stops when the gate can't run.`,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const blocking = blockingPairs(json);
|
|
174
|
+
const guardrailBlocks = blocking.length > 0;
|
|
175
|
+
// Guardrail decides first. If it blocks, don't bother running tests —
|
|
176
|
+
// the model must fix the findings regardless.
|
|
177
|
+
if (guardrailBlocks) {
|
|
178
|
+
const event = (0, ledger_1.buildLedgerEvent)(repoDir, {
|
|
179
|
+
session_id: session,
|
|
180
|
+
...agentFields,
|
|
181
|
+
cwd: repoDir,
|
|
182
|
+
branch: json.current.branch,
|
|
183
|
+
commit: json.current.commitSha,
|
|
184
|
+
guardrail_status: 'fail',
|
|
185
|
+
net_new_findings: blocking.length,
|
|
186
|
+
baseline_findings: json.baseline.findingsCount,
|
|
187
|
+
files_changed: 0,
|
|
188
|
+
allowed: false,
|
|
189
|
+
stop_hook_active: stopActive,
|
|
190
|
+
tests_status: 'skipped',
|
|
191
|
+
lint_status: 'not_configured',
|
|
192
|
+
typecheck_status: 'not_configured',
|
|
193
|
+
duration_ms: Date.now() - start,
|
|
194
|
+
});
|
|
195
|
+
return { outcome: 'block-model', event, message: buildRepairMessage(json) };
|
|
196
|
+
}
|
|
197
|
+
// Guardrail passed — run the optional configured test command.
|
|
198
|
+
const tests = runConfiguredTests(repoDir);
|
|
199
|
+
if (tests.status === 'fail') {
|
|
200
|
+
const event = (0, ledger_1.buildLedgerEvent)(repoDir, {
|
|
201
|
+
session_id: session,
|
|
202
|
+
...agentFields,
|
|
203
|
+
cwd: repoDir,
|
|
204
|
+
branch: json.current.branch,
|
|
205
|
+
commit: json.current.commitSha,
|
|
206
|
+
guardrail_status: 'pass',
|
|
207
|
+
net_new_findings: 0,
|
|
208
|
+
baseline_findings: json.baseline.findingsCount,
|
|
209
|
+
files_changed: 0,
|
|
210
|
+
allowed: false,
|
|
211
|
+
stop_hook_active: stopActive,
|
|
212
|
+
tests_status: 'fail',
|
|
213
|
+
lint_status: 'not_configured',
|
|
214
|
+
typecheck_status: 'not_configured',
|
|
215
|
+
duration_ms: Date.now() - start,
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
outcome: 'block-model',
|
|
219
|
+
event,
|
|
220
|
+
message: `dxkit allowed the guardrail but the configured test command failed.\n` +
|
|
221
|
+
`Fix the failure below, then try to stop again.\n\n${tests.tail}`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
// Clean stop.
|
|
225
|
+
const event = (0, ledger_1.buildLedgerEvent)(repoDir, {
|
|
226
|
+
session_id: session,
|
|
227
|
+
...agentFields,
|
|
228
|
+
cwd: repoDir,
|
|
229
|
+
branch: json.current.branch,
|
|
230
|
+
commit: json.current.commitSha,
|
|
231
|
+
guardrail_status: 'pass',
|
|
232
|
+
net_new_findings: 0,
|
|
233
|
+
baseline_findings: json.baseline.findingsCount,
|
|
234
|
+
files_changed: 0,
|
|
235
|
+
allowed: true,
|
|
236
|
+
stop_hook_active: stopActive,
|
|
237
|
+
tests_status: tests.status,
|
|
238
|
+
lint_status: 'not_configured',
|
|
239
|
+
typecheck_status: 'not_configured',
|
|
240
|
+
duration_ms: Date.now() - start,
|
|
241
|
+
});
|
|
242
|
+
return { outcome: 'allow', event, message: '' };
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* CLI entry for `vyuh-dxkit hook stop-gate`. Reads the hook payload from
|
|
246
|
+
* stdin, runs the guardrail in-process, writes the ledger + last-guardrail
|
|
247
|
+
* snapshot, then emits the Stop-hook decision and exits.
|
|
248
|
+
*/
|
|
249
|
+
async function runStopGate(cwd) {
|
|
250
|
+
const payload = readStdinPayload();
|
|
251
|
+
const repoDir = payload.cwd || cwd;
|
|
252
|
+
// Resolve the loop-scoped posture ONCE (preset → policy). This is the
|
|
253
|
+
// only place the loop preset is read; the CI guardrail never sees it.
|
|
254
|
+
const { resolveLoopPolicy } = await Promise.resolve().then(() => __importStar(require('./policy')));
|
|
255
|
+
const { policy, preset } = resolveLoopPolicy(repoDir);
|
|
256
|
+
const runCheck = async (dir) => {
|
|
257
|
+
const { runGuardrailCheck } = await Promise.resolve().then(() => __importStar(require('../baseline/check')));
|
|
258
|
+
const { renderJson } = await Promise.resolve().then(() => __importStar(require('../baseline/check-renderers')));
|
|
259
|
+
const result = await runGuardrailCheck({ cwd: dir, policy });
|
|
260
|
+
const json = renderJson(result);
|
|
261
|
+
// Persist the full machine-readable verdict so the model (and a human)
|
|
262
|
+
// can read the exact net-new findings the block message points to.
|
|
263
|
+
try {
|
|
264
|
+
const dir2 = path.join(dir, ledger_1.LEDGER_DIR);
|
|
265
|
+
fs.mkdirSync(dir2, { recursive: true });
|
|
266
|
+
fs.writeFileSync(path.join(dir2, 'last-guardrail.json'), JSON.stringify(json, null, 2) + '\n', 'utf8');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
/* best-effort snapshot */
|
|
270
|
+
}
|
|
271
|
+
return json;
|
|
272
|
+
};
|
|
273
|
+
const decision = await computeStopGate(cwd, payload, runCheck);
|
|
274
|
+
// Stamp the active preset onto the ledger line so the audit trail shows
|
|
275
|
+
// which posture was in force when the gate allowed/blocked.
|
|
276
|
+
(0, ledger_1.appendLedgerEvent)(repoDir, { ...decision.event, preset });
|
|
277
|
+
if (decision.outcome === 'block-model') {
|
|
278
|
+
// Exit 0 + decision JSON on stdout → blocks the stop and feeds the
|
|
279
|
+
// reason to the model so it repairs.
|
|
280
|
+
process.stdout.write(JSON.stringify({ decision: 'block', reason: decision.message }) + '\n');
|
|
281
|
+
process.exit(0);
|
|
282
|
+
}
|
|
283
|
+
if (decision.outcome === 'block-operator') {
|
|
284
|
+
// Exit 2 → blocks the stop; stderr reaches the operator (the model
|
|
285
|
+
// can't fix a preflight problem).
|
|
286
|
+
process.stderr.write(decision.message + '\n');
|
|
287
|
+
process.exit(2);
|
|
288
|
+
}
|
|
289
|
+
// allow: exit 0 lets the stop proceed. Surface any warning (config
|
|
290
|
+
// fail-open) on stderr so it isn't a silent skip.
|
|
291
|
+
if (decision.message)
|
|
292
|
+
process.stderr.write(decision.message + '\n');
|
|
293
|
+
process.exit(0);
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=stop-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop-gate.js","sourceRoot":"","sources":["../../src/loop/stop-gate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,gDA2BC;AA0BD,0CAqIC;AAOD,kCAmDC;AA9SD,qCAMkB;AAClB,iDAAyC;AACzC,uCAAyB;AACzB,2CAA6B;AAsB7B,gEAAgE;AAChE,SAAS,gBAAgB;IACvB,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAC3B,IAAI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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,KAAK,gBAAgB,EAAE,CAAC;QAC1C,mEAAmE;QACnE,kCAAkC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,mEAAmE;IACnE,kDAAkD;IAClD,IAAI,QAAQ,CAAC,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical way a generated artifact invokes the dxkit CLI. Resolves
|
|
3
|
+
* to a project-local `./node_modules/.bin/vyuh-dxkit` (when dxkit is a
|
|
4
|
+
* devDependency) or a global install; both are what `requiresResolvableCli`
|
|
5
|
+
* + the install flow guarantee for any active self-invocation surface.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DXKIT_CLI = "npx vyuh-dxkit";
|
|
8
|
+
/** Build a CLI invocation string. `dxkitCli('hook stop-gate')` →
|
|
9
|
+
* `'npx vyuh-dxkit hook stop-gate'`; `dxkitCli()` → `'npx vyuh-dxkit'`. */
|
|
10
|
+
export declare function dxkitCli(subcommand?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The install-time decisions that determine which self-invocation surfaces
|
|
13
|
+
* a given `init`/`update` run actually writes. Each surface maps itself to
|
|
14
|
+
* one of these via `installedWhen`.
|
|
15
|
+
*/
|
|
16
|
+
export interface SurfaceFlags {
|
|
17
|
+
/** `.claude/settings.json` is written (carries the PreToolUse
|
|
18
|
+
* `context-hook`) — true on every `init` that scaffolds `.claude`. */
|
|
19
|
+
readonly claudeSettings?: boolean;
|
|
20
|
+
/** The loop pack (Stop hook) is installed (`init --claude-loop`). */
|
|
21
|
+
readonly claudeLoop?: boolean;
|
|
22
|
+
/** The git pre-push guardrail hook is installed (`--with-hooks`). */
|
|
23
|
+
readonly gitHooks?: boolean;
|
|
24
|
+
/** The CI guardrail workflow is installed (`--with-ci`). */
|
|
25
|
+
readonly ciGuardrails?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** One artifact that auto-executes the dxkit CLI after install. */
|
|
28
|
+
export interface SelfInvocationSurface {
|
|
29
|
+
/** Stable id (used in tests + audit output). */
|
|
30
|
+
readonly id: string;
|
|
31
|
+
/** Human-readable description of the artifact. */
|
|
32
|
+
readonly description: string;
|
|
33
|
+
/** The CLI subcommand it invokes (for audit; the body itself is built
|
|
34
|
+
* with `dxkitCli` at the surface's own site). */
|
|
35
|
+
readonly invokes: string;
|
|
36
|
+
/** True when this surface is installed for the given flags. */
|
|
37
|
+
installedWhen(flags: SurfaceFlags): boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Every dxkit-installed artifact that shells out to the dxkit CLI at
|
|
41
|
+
* runtime. The single source of truth for the devDependency decision and
|
|
42
|
+
* the doctor resolvability checks. Add new auto-running surfaces here.
|
|
43
|
+
*/
|
|
44
|
+
export declare const SELF_INVOCATION_SURFACES: readonly SelfInvocationSurface[];
|
|
45
|
+
/**
|
|
46
|
+
* The surfaces active for a given install decision. `registry` is injectable
|
|
47
|
+
* (defaults to the canonical list) so the playbook test can prove a newly
|
|
48
|
+
* registered surface flows through `requiresResolvableCli` without the
|
|
49
|
+
* function having to hardcode the set — the same registry-as-argument seam
|
|
50
|
+
* `runProducers` uses.
|
|
51
|
+
*/
|
|
52
|
+
export declare function activeSelfInvocationSurfaces(flags: SurfaceFlags, registry?: readonly SelfInvocationSurface[]): SelfInvocationSurface[];
|
|
53
|
+
/**
|
|
54
|
+
* Does this install need a project-local (or global) dxkit so its
|
|
55
|
+
* generated artifacts can run? True when ANY self-invocation surface is
|
|
56
|
+
* active. Replaces the hand-maintained `wantHooks || wantCi` conditional in
|
|
57
|
+
* both `cli.ts` (init) and `update.ts`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function requiresResolvableCli(flags: SurfaceFlags, registry?: readonly SelfInvocationSurface[]): boolean;
|
|
60
|
+
/** Where a runtime `vyuh-dxkit` invocation resolves from, if anywhere. */
|
|
61
|
+
export type CliResolution = {
|
|
62
|
+
readonly ok: true;
|
|
63
|
+
readonly how: 'local' | 'global';
|
|
64
|
+
} | {
|
|
65
|
+
readonly ok: false;
|
|
66
|
+
readonly how: 'none';
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Does `vyuh-dxkit` actually resolve in `cwd` right now? Mirrors how the
|
|
70
|
+
* generated artifacts resolve it: a project-local `./node_modules/.bin`
|
|
71
|
+
* binary first, then a global one on PATH. This is the runtime truth the
|
|
72
|
+
* doctor checks — a surface can be registered (settings.json written) yet
|
|
73
|
+
* still 404 at fire time if the devDependency was declared but never
|
|
74
|
+
* `npm install`-ed, or the repo is non-Node with no global install.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveDxkitCli(cwd: string): CliResolution;
|
|
77
|
+
//# sourceMappingURL=self-invocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-invocation.d.ts","sourceRoot":"","sources":["../src/self-invocation.ts"],"names":[],"mappings":"AAgCA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C;4EAC4E;AAC5E,wBAAgB,QAAQ,CAAC,UAAU,SAAK,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;2EACuE;IACvE,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,mEAAmE;AACnE,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;sDACkD;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;CAC7C;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAyBpE,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,YAAY,EACnB,QAAQ,GAAE,SAAS,qBAAqB,EAA6B,GACpE,qBAAqB,EAAE,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,QAAQ,GAAE,SAAS,qBAAqB,EAA6B,GACpE,OAAO,CAET;AAED,0EAA0E;AAC1E,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAY1D"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SELF_INVOCATION_SURFACES = exports.DXKIT_CLI = void 0;
|
|
37
|
+
exports.dxkitCli = dxkitCli;
|
|
38
|
+
exports.activeSelfInvocationSurfaces = activeSelfInvocationSurfaces;
|
|
39
|
+
exports.requiresResolvableCli = requiresResolvableCli;
|
|
40
|
+
exports.resolveDxkitCli = resolveDxkitCli;
|
|
41
|
+
/**
|
|
42
|
+
* Self-invocation — the ONE place that knows how dxkit's own generated
|
|
43
|
+
* artifacts call the dxkit CLI, and which of those artifacts auto-execute
|
|
44
|
+
* it at runtime.
|
|
45
|
+
*
|
|
46
|
+
* Several things dxkit installs shell out to the dxkit CLI after install:
|
|
47
|
+
* the loop Stop hook, the `.claude` PreToolUse `context-hook`, the git
|
|
48
|
+
* pre-push guardrail hook, and the CI guardrail workflow. Every one of
|
|
49
|
+
* them only works if `vyuh-dxkit` actually resolves in the user's
|
|
50
|
+
* environment (a project-local devDependency or a global install). When it
|
|
51
|
+
* does not, the invocation `npx vyuh-dxkit …` 404s — `vyuh-dxkit` is a
|
|
52
|
+
* binary name, not a package — and the surface fails on every fire.
|
|
53
|
+
*
|
|
54
|
+
* Two facts used to live as scattered string literals and hand-maintained
|
|
55
|
+
* `wantHooks || wantCi` conditionals, so a new surface (the loop Stop
|
|
56
|
+
* hook) was added without being taught to either — it shipped 404-ing on
|
|
57
|
+
* pure-npx installs. This module makes both facts derive from ONE list:
|
|
58
|
+
*
|
|
59
|
+
* 1. The canonical invocation string (`DXKIT_CLI` / `dxkitCli`).
|
|
60
|
+
* 2. The registry of self-invoking surfaces (`SELF_INVOCATION_SURFACES`),
|
|
61
|
+
* from which `requiresResolvableCli` (the install/update devDependency
|
|
62
|
+
* decision) and the doctor resolvability checks are derived.
|
|
63
|
+
*
|
|
64
|
+
* Adding a surface is a one-line registry entry; it cannot silently forget
|
|
65
|
+
* the devDependency wire-up or the doctor check. Enforced by
|
|
66
|
+
* `scripts/check-architecture.sh` (no raw `npx vyuh-dxkit` literal in
|
|
67
|
+
* `src/` outside this file) and `test/self-invocation-playbook.test.ts`.
|
|
68
|
+
*/
|
|
69
|
+
const fs = __importStar(require("fs"));
|
|
70
|
+
const path = __importStar(require("path"));
|
|
71
|
+
const child_process_1 = require("child_process");
|
|
72
|
+
/**
|
|
73
|
+
* The canonical way a generated artifact invokes the dxkit CLI. Resolves
|
|
74
|
+
* to a project-local `./node_modules/.bin/vyuh-dxkit` (when dxkit is a
|
|
75
|
+
* devDependency) or a global install; both are what `requiresResolvableCli`
|
|
76
|
+
* + the install flow guarantee for any active self-invocation surface.
|
|
77
|
+
*/
|
|
78
|
+
exports.DXKIT_CLI = 'npx vyuh-dxkit'; // self-invocation-ok
|
|
79
|
+
/** Build a CLI invocation string. `dxkitCli('hook stop-gate')` →
|
|
80
|
+
* `'npx vyuh-dxkit hook stop-gate'`; `dxkitCli()` → `'npx vyuh-dxkit'`. */
|
|
81
|
+
function dxkitCli(subcommand = '') {
|
|
82
|
+
return subcommand ? `${exports.DXKIT_CLI} ${subcommand}` : exports.DXKIT_CLI;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Every dxkit-installed artifact that shells out to the dxkit CLI at
|
|
86
|
+
* runtime. The single source of truth for the devDependency decision and
|
|
87
|
+
* the doctor resolvability checks. Add new auto-running surfaces here.
|
|
88
|
+
*/
|
|
89
|
+
exports.SELF_INVOCATION_SURFACES = [
|
|
90
|
+
{
|
|
91
|
+
id: 'context-hook',
|
|
92
|
+
description: '.claude/settings.json PreToolUse hook (passive graph context)',
|
|
93
|
+
invokes: 'context-hook',
|
|
94
|
+
installedWhen: (f) => !!f.claudeSettings,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'loop-stop-gate-hook',
|
|
98
|
+
description: '.claude/settings.json Stop hook (loop pack guardrail gate)',
|
|
99
|
+
invokes: 'hook stop-gate',
|
|
100
|
+
installedWhen: (f) => !!f.claudeLoop,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'pre-push-guardrail-hook',
|
|
104
|
+
description: '.githooks/pre-push guardrail check',
|
|
105
|
+
invokes: 'guardrail check',
|
|
106
|
+
installedWhen: (f) => !!f.gitHooks,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'ci-guardrail-workflow',
|
|
110
|
+
description: '.github/workflows/dxkit-guardrails.yml guardrail check',
|
|
111
|
+
invokes: 'guardrail check',
|
|
112
|
+
installedWhen: (f) => !!f.ciGuardrails,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
/**
|
|
116
|
+
* The surfaces active for a given install decision. `registry` is injectable
|
|
117
|
+
* (defaults to the canonical list) so the playbook test can prove a newly
|
|
118
|
+
* registered surface flows through `requiresResolvableCli` without the
|
|
119
|
+
* function having to hardcode the set — the same registry-as-argument seam
|
|
120
|
+
* `runProducers` uses.
|
|
121
|
+
*/
|
|
122
|
+
function activeSelfInvocationSurfaces(flags, registry = exports.SELF_INVOCATION_SURFACES) {
|
|
123
|
+
return registry.filter((s) => s.installedWhen(flags));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Does this install need a project-local (or global) dxkit so its
|
|
127
|
+
* generated artifacts can run? True when ANY self-invocation surface is
|
|
128
|
+
* active. Replaces the hand-maintained `wantHooks || wantCi` conditional in
|
|
129
|
+
* both `cli.ts` (init) and `update.ts`.
|
|
130
|
+
*/
|
|
131
|
+
function requiresResolvableCli(flags, registry = exports.SELF_INVOCATION_SURFACES) {
|
|
132
|
+
return activeSelfInvocationSurfaces(flags, registry).length > 0;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Does `vyuh-dxkit` actually resolve in `cwd` right now? Mirrors how the
|
|
136
|
+
* generated artifacts resolve it: a project-local `./node_modules/.bin`
|
|
137
|
+
* binary first, then a global one on PATH. This is the runtime truth the
|
|
138
|
+
* doctor checks — a surface can be registered (settings.json written) yet
|
|
139
|
+
* still 404 at fire time if the devDependency was declared but never
|
|
140
|
+
* `npm install`-ed, or the repo is non-Node with no global install.
|
|
141
|
+
*/
|
|
142
|
+
function resolveDxkitCli(cwd) {
|
|
143
|
+
const isWin = process.platform === 'win32';
|
|
144
|
+
const localBin = path.join(cwd, 'node_modules', '.bin', isWin ? 'vyuh-dxkit.cmd' : 'vyuh-dxkit');
|
|
145
|
+
if (fs.existsSync(localBin))
|
|
146
|
+
return { ok: true, how: 'local' };
|
|
147
|
+
try {
|
|
148
|
+
(0, child_process_1.execFileSync)(isWin ? 'where' : 'which', ['vyuh-dxkit'], {
|
|
149
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
150
|
+
});
|
|
151
|
+
return { ok: true, how: 'global' };
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return { ok: false, how: 'none' };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=self-invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-invocation.js","sourceRoot":"","sources":["../src/self-invocation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,4BAEC;AAuED,oEAKC;AAQD,sDAKC;AAeD,0CAYC;AAhKD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,iDAA6C;AAE7C;;;;;GAKG;AACU,QAAA,SAAS,GAAG,gBAAgB,CAAC,CAAC,qBAAqB;AAEhE;4EAC4E;AAC5E,SAAgB,QAAQ,CAAC,UAAU,GAAG,EAAE;IACtC,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,iBAAS,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,iBAAS,CAAC;AAC/D,CAAC;AAgCD;;;;GAIG;AACU,QAAA,wBAAwB,GAAqC;IACxE;QACE,EAAE,EAAE,cAAc;QAClB,WAAW,EAAE,+DAA+D;QAC5E,OAAO,EAAE,cAAc;QACvB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;KACzC;IACD;QACE,EAAE,EAAE,qBAAqB;QACzB,WAAW,EAAE,4DAA4D;QACzE,OAAO,EAAE,gBAAgB;QACzB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU;KACrC;IACD;QACE,EAAE,EAAE,yBAAyB;QAC7B,WAAW,EAAE,oCAAoC;QACjD,OAAO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