chore(infra): 更新 Nginx 部署配置与项目上下文文档
- 更新 CI/CD 子域名反向代理配置 - 调整 Nginx 静态文件服务器配置 - 更新 CONTEXT.md 领域共享语言文档 - 添加 CLAUDE.md 代理工作指南 - 更新 Playwright E2E 测试配置
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Impeccable design hook — PostToolUse entry point.
|
||||
*
|
||||
* Reads the Claude Code / Codex / Cursor hook event from stdin, runs the design
|
||||
* detector against the touched file, and emits a system reminder via
|
||||
* `hookSpecificOutput.additionalContext` when findings exist.
|
||||
*
|
||||
* Contract: never break a turn. Always exit 0. Clean files emit a small ack
|
||||
* unless quiet mode is enabled.
|
||||
*
|
||||
* Most logic lives in `hook-lib.mjs` so it is unit-testable without a
|
||||
* subprocess. This file is the thin stdin/stdout adapter.
|
||||
*/
|
||||
|
||||
import { runHook, writeAuditLog } from './hook-lib.mjs';
|
||||
|
||||
async function readStdin() {
|
||||
if (process.stdin.isTTY) return '';
|
||||
const chunks = [];
|
||||
for await (const chunk of process.stdin) chunks.push(chunk);
|
||||
return Buffer.concat(chunks).toString('utf-8');
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Snapshot the inherited env FIRST so the re-entrancy guard checks the
|
||||
// parent's value, not the value we are about to export for any child
|
||||
// processes the hook might ever spawn.
|
||||
const inheritedEnv = { ...process.env };
|
||||
process.env.IMPECCABLE_HOOK_DEPTH = process.env.IMPECCABLE_HOOK_DEPTH || '1';
|
||||
|
||||
let stdinJson = '';
|
||||
try { stdinJson = await readStdin(); } catch { /* fall through */ }
|
||||
|
||||
const result = await runHook({
|
||||
stdinJson,
|
||||
env: inheritedEnv,
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
|
||||
writeAuditLog(process.env, result.audit, process.cwd());
|
||||
|
||||
if (result.stdout) process.stdout.write(result.stdout);
|
||||
process.exit(result.exitCode || 0);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
// Last-ditch: never break the agent's turn even if something we did not
|
||||
// anticipate goes wrong. Audit-log the failure if logging is enabled.
|
||||
try {
|
||||
writeAuditLog(process.env, {
|
||||
ts: new Date().toISOString(),
|
||||
event: 'PostToolUse',
|
||||
error: String(err && err.message ? err.message : err),
|
||||
});
|
||||
} catch { /* swallow */ }
|
||||
if (process.env.IMPECCABLE_HOOK_DEBUG) {
|
||||
process.stderr.write(`[impeccable-hook] ${err}\n`);
|
||||
}
|
||||
process.exit(0);
|
||||
});
|
||||
Reference in New Issue
Block a user