chore(codex): add commit checklist hook

This commit is contained in:
lanrtop 2026-09-21 12:55:34 +09:00
parent 9f2bda28a0
commit 4f070b7356
2 changed files with 47 additions and 0 deletions

15
.codex/hooks.json Normal file
View File

@ -0,0 +1,15 @@
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "node -e \"let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const i=JSON.parse(d);const cmd=(i.tool_input||{}).command||'';if(cmd.includes('git commit')){process.stderr.write('\\n📋 提交前检查清单:\\n complexity S → /code-review\\n complexity M → /Dev-edge-case → /code-review\\n\\n');}}catch(e){}});\""
}
]
}
]
}
}

View File

@ -0,0 +1,32 @@
#!/usr/bin/env node
// 由炼境托管:重跑接入包会用最新模板覆盖本文件,请勿在此做项目定制。
// 蓝图门控:pre-commit 检查未关闭的 🔵 任务卡,warn only(exit 0,不阻断提交)。
const fs = require('fs');
const path = require('path');
const modulesDir = path.join(process.cwd(), '.blueprint', 'modules');
if (!fs.existsSync(modulesDir)) {
process.exit(0);
}
const unclosed = [];
for (const file of fs.readdirSync(modulesDir).filter(f => f.endsWith('.md'))) {
const content = fs.readFileSync(path.join(modulesDir, file), 'utf8');
for (const line of content.split('\n')) {
if (line.startsWith('### 🔵')) {
unclosed.push({ file, title: line.replace(/^###\s*🔵\s*/, '').trim() });
}
}
}
if (unclosed.length > 0) {
process.stderr.write('\n⚠️ 蓝图门控:发现未关闭任务卡\n');
for (const { file, title } of unclosed) {
process.stderr.write(` 🔵 ${title}(${file})\n`);
}
process.stderr.write('\n 已完成 → 改为 ✅;仍进行中 → 属预期,可忽略本提示。\n\n');
}
process.exit(0);