deslop(claude): role-router 简化 + regex 去重 + stderr 错误日志
按 critic + 3 reviewer agent 反馈:
- HIGH: bare catch {} 改 catch(e){console.error(...)} 暴露 bug
- MED: regex 去重复 (develop|develops? → develops?, fix|fixes → fixes?, requirement|requirements? → requirements?)
- MED: 4 处 {continue:true,suppressOutput:true} 抽 NOOP 常量
- MED: test JSON.stringify(.sort()) → 不可变的 sortKey helper
- skip: createHookOutput 抽 lib (违反"不改 OMC keyword-detector" 决策)
- skip: ROLES enum (3 值 over-engineering)
post-deslop 回归: 10/10 PASS
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* role-router unit tests — 6 fixture (每角色 2 条)
|
||||
* role-router unit tests — 10 tests (8 fixture + 2 subprocess integration)
|
||||
* 跑法: node role-router.test.mjs
|
||||
*/
|
||||
|
||||
@@ -27,9 +27,11 @@ const fixtures = [
|
||||
let pass = 0, fail = 0;
|
||||
const failures = [];
|
||||
|
||||
const sortKey = a => a.slice().sort().join(',');
|
||||
|
||||
for (const f of fixtures) {
|
||||
const got = detectRoles(f.prompt);
|
||||
const ok = JSON.stringify(got.sort()) === JSON.stringify(f.expect.sort());
|
||||
const ok = sortKey(got) === sortKey(f.expect);
|
||||
if (ok) {
|
||||
pass++;
|
||||
console.log(`PASS "${f.prompt}" → [${got.join(',')}]`);
|
||||
|
||||
Reference in New Issue
Block a user