chore: 同步 DSH 上游笔记格式,导入后自动封印归档

This commit is contained in:
czm
2026-09-18 07:53:10 +08:00
parent 2aef219faf
commit a6073d3933
3 changed files with 22 additions and 9 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ AI 每天都能帮你交十几个 PR,但每个新会话都是一张白纸,
npx skills add czm15053/write-notes-like-deepseek
```
📺 先看效果:[在线演示看板](https://czm15053.github.io/write-notes-like-deepseek-demo/)(内置 974 篇来自 DeepSeek Harness 的真实决策笔记,可脱机浏览)
📺 先看效果:[在线演示看板](https://czm15053.github.io/write-notes-like-deepseek-demo/)(内置 1,106 篇来自 DeepSeek Harness 的真实决策笔记,可脱机浏览)
---
@@ -267,7 +267,7 @@ npx tsx scripts/build-board.ts --init board.html "项目决策看板" # 本
npx tsx scripts/build-board.ts --bundle .agents/notes demo.html "项目决策看板" # 打包分发
```
真实界面(来自内嵌 DeepSeek Harness 974 篇真实笔记的[在线演示](https://czm15053.github.io/write-notes-like-deepseek-demo/)):
真实界面(来自内嵌 DeepSeek Harness 1,106 篇真实笔记的[在线演示](https://czm15053.github.io/write-notes-like-deepseek-demo/)):
<p align="center">
<img src="assets/board-baseline.png" alt="看板真实界面:四组 KPI 总览与「系统承重墙」——按交叉引用权重萃取的最关键决策" width="100%" />
@@ -288,7 +288,7 @@ npx tsx scripts/build-board.ts --bundle .agents/notes demo.html "项目决策看
按月份与分类切片,回看全部笔记铺开的演进轨迹:
<p align="center">
<img src="assets/board-timeline.png" alt="演进时间线:月份与分类双维切片,2026-06 至 2026-09 共 974 条记录" width="100%" />
<img src="assets/board-timeline.png" alt="演进时间线:月份与分类双维切片,2026-06 至 2026-09 共 1,106 条记录" width="100%" />
</p>
---
+6
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env node
import { execSync } from 'node:child_process';
import { readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { join, resolve, relative, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -77,4 +78,9 @@ for (const topDoc of ['README.zh.md', 'README.md', 'AGENTS.md']) {
}
}
// 自动更新归档 Note 密封清单
try {
execSync('npx tsx scripts/verify-archived-agent-notes.ts --write', { stdio: 'ignore' });
} catch {}
console.log(`✅ 成功将 ${copied} 篇中文 Note 标准化写入到: ${targetNotesDir}`);
+13 -6
View File
@@ -9,9 +9,9 @@ import { resolve } from "node:path";
import { agentNoteRoot, walkAgentNoteTree } from "./agent-note-tree.ts";
const STATUS: Record<string, RegExp> = {
proposed: /^Status: proposed$/,
implemented: /^Status: implemented$/,
rejected: /^Status: rejected — .+$/,
proposed: /^Status: proposed$|^状态[::] ?已提议$/,
implemented: /^Status: implemented$|^状态[::] ?已实现$/,
rejected: /^Status: rejected — .+$|^状态[::] ?已否决 — .+$/,
};
const PROBLEM_FIRST = ["## Problem", "## 问题"];
@@ -24,7 +24,7 @@ const REQUIRED: Record<string, string[][]> = {
],
implemented: [
["## Decision", "## 决定", "## 决策"],
["## Consequences", "## 后果", "## 影响", "## 结果"],
["## Consequences", "## 后果", "## 影响", "## 结果", "## 结果与代价"],
],
rejected: [
["## Proposal", "## 提议", "## 方案", "## 提案"],
@@ -39,6 +39,8 @@ const BANNED_IMPLEMENTED = new Set([
]);
const ALTERNATIVES_RE = /^## (?:Alternatives considered|.{0,8}?(?:替代方案|备选方案))$/;
const FORMAT_ADOPTED = "2026-07-05";
const GRANDFATHER = "<!-- agent-note-format: alternatives-not-recorded (pre-format Agent Note) -->";
/** Strip trailing parenthetical: `## Decision(说明)` → `## Decision`. */
function headingBase(h: string): string {
@@ -117,7 +119,7 @@ for (const note of notes) {
// not be miscounted as a duplicate status header.
const looksLikeStatusLine = (l: string) => {
const t = l.trim();
return t === "Status: proposed" || t === "Status: implemented" || /^Status: rejected — .+$/.test(t);
return Object.values(STATUS).some((re) => re.test(t));
};
const statusCount = prose.filter(looksLikeStatusLine).length;
if (statusCount !== 1) fail("Status: line must appear exactly once");
@@ -138,9 +140,14 @@ for (const note of notes) {
}
}
if (!bases.some((h: string) => ALTERNATIVES_RE.test(h))) {
const hasSection = bases.some((h: string) => ALTERNATIVES_RE.test(h));
const rawText = readFileSync(resolve(agentNoteRoot, note.rel), "utf8");
const hasGrandfather = rawText.includes(GRANDFATHER);
if (hasSection && hasGrandfather) fail("carries both ## Alternatives considered and grandfather comment — drop the comment");
if (!hasSection && !hasGrandfather) {
fail("missing ## Alternatives considered / ## 备选方案");
}
if (hasGrandfather && note.date >= FORMAT_ADOPTED) fail(`grandfather comment only valid before ${FORMAT_ADOPTED}`);
}
if (errors.length) {