Files
clean-architecture-frontend…/tests/unit/template-contract-documents.test.ts
T
DongHyeonka 5757742ed0 docs(work): 하네스 문서를 새 문서 위치와 검사 범위에 맞춘다
문제: 하네스 PR #13이 더한 작업 매뉴얼·규칙은 이 브랜치가 바꾼 문서
체계의 옛 모습을 적는다.
- 옛 경로: `docs/architecture/decisions/`, `docs/superpowers/`, 루트
  `SPEC.md`, 목표 설계였던 `docs/testing/frontend-platform-testing-strategy.md`
- 옛 검사 범위: 「docs/README.md 1절이 링크한 문서, 폴더 링크는 바로 아래
  .md만」. 지금 verify:documentation은 살아 있는 문서 전부를 보고 언어·
  문체·숫자·머리 블록도 본다
- 옛 docs/README.md 절(1절 묶음 / 2절 목표 설계 / 3절 작업 이력)과 README
  절 이름(「Support scope」, 「Updating a copied project」)
- #13의 template-contract-documents 시험은 README 지워도 되는 표를
  `docs/superpowers/` 행으로 찾는데, 그 행은 이제 없다

고른 방법: 그 줄만 새 위치·새 절 이름·새 범위로 고친다(.claude/rules/docs.md,
docs/work의 docs-writing·operate·research-design·reference 다섯,
docs/problem-statement.md). 시험은 `docs/history/` 행으로 표를 찾는다.
docs/work/evidence.md는 백엔드처럼 매뉴얼 규칙의 근거 기록이라 고치지 않고
`HISTORY_HOLDERS`에 넣어 참조·숫자 검사에서 뺀다.

위험: 하네스 문서의 다른 문장은 건드리지 않았다. 하네스 세션이 쓴 뜻을
바꾸지 않으려는 것이다.

검증: 문서 검사 여섯이 0건, `git grep -n -E 'docs/superpowers|architecture/decisions'`가
기록·CHANGELOG·출처 표시 밖에서 0건.
2026-11-11 20:55:32 +09:00

50 lines
2.4 KiB
TypeScript

import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
/**
* Owner decision 2026-11-07 (docs/work/reference/decisions.md): the root
* AGENTS.md and CLAUDE.md, `.claude/` and `docs/work/` are the template's
* contract, which a copy keeps. So the README table of files a copy may delete
* must not list them, and docs/README.md section 1 links the rule book and the
* work manual, which makes verify:documentation check the paths, scripts and
* gate IDs they name.
*/
const CONTRACT = Object.freeze(["AGENTS.md", "CLAUDE.md", ".claude", "docs/work"]);
// Built from pieces: deletable-history-documents.test.ts fails on code that
// names a folder a copy may delete.
const PAST_PLANS = ["docs", "history"].join("/");
/** A row only the deletable-files table has; found by content so a translated heading still finds it. */
const DELETABLE_ROW = `| \`${PAST_PLANS}/\` |`;
/** The paths in the first cells of the README table that holds DELETABLE_ROW. */
function deletablePaths(readme: string): string[] {
const lines = readme.split("\n");
const row = lines.findIndex((line) => line.startsWith(DELETABLE_ROW));
if (row === -1) throw new Error(`README.md has no table row starting with ${DELETABLE_ROW}`);
let start = row;
while (start > 0 && lines[start - 1]?.startsWith("|")) start -= 1;
let end = row;
while (lines[end + 1]?.startsWith("|")) end += 1;
return lines
.slice(start + 2, end + 1)
.flatMap((line) => [...(line.split("|")[1] ?? "").matchAll(/`([^`]+)`/gu)].map(([, entry = ""]) => entry))
.map((entry) => entry.replace(/\/$/u, ""));
}
describe("template contract documents", () => {
it("are not in the README table of files a copy may delete", async () => {
const listed = deletablePaths(await readFile("README.md", "utf8"));
expect(listed).toContain(PAST_PLANS);
expect(listed.filter((entry) => CONTRACT.some((kept) => entry === kept || entry.startsWith(`${kept}/`))))
.toEqual([]);
});
it("are linked from the current-contract section of docs/README.md", async () => {
const index = await readFile("docs/README.md", "utf8");
const section = /^## 1\.[\s\S]*?(?=^## )/mu.exec(index)?.[0] ?? "";
const links = [...section.matchAll(/\]\(([^)#\s]+)\)/gu)].map(([, target = ""]) => target);
expect(links).toEqual(expect.arrayContaining(["../AGENTS.md", "work/", "work/reference/"]));
});
});