MCPcopy Create free account
hub / github.com/SethGammon/Citadel / main

Function main

hooks_src/worktree-setup.js:25–141  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

23async function main(input) {
24 const worktreePath = input.path;
25 if (!worktreePath) return;
26
27 const pathCheck = health.validatePath(worktreePath);
28 if (!pathCheck.safe) {
29 health.securityWarning('worktree-setup', `Possible injection in worktree path — ${pathCheck.violation}. Skipping setup.`);
30 return;
31 }
32
33 // Readiness only. Tracked manifests and ignored env files are not consent
34 // to execute lifecycle scripts or distribute secrets to another checkout.
35
36 try {
37 const report = await checkWorktreeReadiness({
38 projectRoot: MAIN_ROOT,
39 worktreePath,
40 branch: input.branch || null,
41 write: true,
42 });
43 health.logTiming('worktree-readiness', 0, {
44 event: 'worktree-readiness',
45 status: report.status,
46 branch: input.branch || null,
47 worktree: path.basename(worktreePath),
48 });
49 health.writeAuditLog('worktree-readiness', {
50 status: report.status,
51 blockFleet: report.blockFleet,
52 branch: input.branch || null,
53 worktree: path.basename(worktreePath),
54 report: report.file,
55 });
56 } catch (err) {
57 process.stderr.write(`[worktree-setup] Readiness check failed in ${worktreePath}: ${err.message}\n`);
58 }
59}
60
61let data = '';
62process.stdin.setEncoding('utf8');
63process.stdin.on('data', chunk => { data += chunk; });
64process.stdin.on('end', async () => {
65 try { await main(JSON.parse(data)); } catch { /* silent */ }
66 process.stdout.write('ok\n');
67});

Callers 1

worktree-setup.jsFile · 0.70

Calls 1

checkWorktreeReadinessFunction · 0.85

Tested by

no test coverage detected