Skip to content

Commit b1545e8

Browse files
committed
docs(plans): 0-C1 表生成器补两处防御
- row() 增加单元格净化:半角 | 换成全角(用 \\| 转义会在下次读取时二次转义,破坏 --write 幂等性) - 超硬限行的拆分计划默认值改为「必须拆」(原「若再增长」对已越 600 的文件是错的) 两处都在编码前修,避免实施者照抄出格式缺陷。
1 parent 75c566f commit b1545e8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎docs/superpowers/plans/2026-09-11-frontend-redesign-batch0c1-line-limit-governance.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,13 @@ function writeTable() {
410410
const reasons = parseReasons();
411411
const over = [...measured.entries()].filter(([, n]) => n > HARD_LIMIT).sort((a, b) => b[1] - a[1]);
412412
const band = [...measured.entries()].filter(([, n]) => n > SOFT_LIMIT && n <= HARD_LIMIT).sort((a, b) => b[1] - a[1]);
413-
const row = (p, n, why, split) => `| ${p} | ${n} | ${why || '(待补理由)'} | ${split || '若再增长:按职责拆分'} |`;
413+
// 单元格净化:文本里的半角 `|` 会撑破 Markdown 表格,并让下次 `parseReasons` 误切列。
414+
// 换**全角** `|` 而不是 `\|` —— 转义写法在下次读取时会被再次转义,破坏 `--write` 的幂等性。
415+
const cell = (t, fallback) => {
416+
const s = (t ?? '').replace(/\|/g, '|').replace(/\s*\n\s*/g, ' ').trim();
417+
return s || fallback;
418+
};
419+
const row = (p, n, why, split) => `| ${p} | ${n} | ${cell(why, '(待补理由)')} | ${cell(split, '若再增长:按职责拆分')} |`;
414420

415421
const lines = [
416422
'# 单文件行数豁免登记(AGENTS.md §3:单文件 ≤300 行;301–600 行须登记本清单)',
@@ -432,7 +438,7 @@ function writeTable() {
432438
// 按路径保留人工维护的两列,改成 3 列会让这些拆分计划在**下一次重生成时静默丢失**。
433439
'| 文件 | 行数 | 说明 | 拆分计划 |',
434440
'|---|---|---|---|',
435-
...over.map(([p, n]) => row(p, n, `超硬限(>${HARD_LIMIT} 行),不允许豁免`, reasons.get(p)?.split)),
441+
...over.map(([p, n]) => row(p, n, `超硬限(>${HARD_LIMIT} 行),不允许豁免`, reasons.get(p)?.split || `**超硬限必须拆**:拆到各文件 ≤${SOFT_LIMIT} 行`)),
436442
'',
437443
`## ${SOFT_LIMIT + 1}–${HARD_LIMIT} 档(须登记)`,
438444
'',

0 commit comments

Comments
 (0)