specthread 0.1.5 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -66
- package/dist/bin/check.js +9 -34
- package/dist/bin/cli.js +5 -4
- package/dist/bin/generate.js +32 -19
- package/dist/bin/open-project.d.ts +5 -0
- package/dist/bin/open-project.js +26 -0
- package/dist/checks/changelog.js +5 -4
- package/dist/checks/headings.d.ts +0 -1
- package/dist/checks/headings.js +15 -6
- package/dist/checks/links.js +7 -4
- package/dist/checks/markers.d.ts +3 -1
- package/dist/checks/markers.js +33 -18
- package/dist/checks/pending.js +57 -23
- package/dist/checks/references.js +2 -2
- package/dist/checks/sections.js +3 -6
- package/dist/checks/style.d.ts +0 -8
- package/dist/checks/style.js +23 -43
- package/dist/checks/timestamps.js +5 -5
- package/dist/checks/toc.js +4 -6
- package/dist/commands/config-template.d.ts +8 -0
- package/{scaffold/config.jsonc → dist/commands/config-template.js} +48 -40
- package/dist/commands/init.js +121 -47
- package/dist/commands/upgrade-prompt.d.ts +12 -0
- package/dist/commands/upgrade-prompt.js +147 -0
- package/dist/config-loader.d.ts +44 -1
- package/dist/config-loader.js +219 -36
- package/dist/config.schema.d.ts +16 -35
- package/dist/config.schema.js +1 -7
- package/dist/constants/docs.d.ts +8 -4
- package/dist/constants/docs.js +8 -5
- package/dist/constants/exit.d.ts +12 -0
- package/dist/constants/exit.js +12 -0
- package/dist/constants/paths.d.ts +25 -0
- package/dist/constants/paths.js +25 -0
- package/dist/constants/patterns.d.ts +13 -6
- package/dist/constants/patterns.js +16 -6
- package/dist/constants/rules.d.ts +7 -3
- package/dist/constants/rules.js +7 -3
- package/dist/gen/pending-section.js +20 -16
- package/dist/gen/references.js +13 -9
- package/dist/gen/summary.d.ts +1 -1
- package/dist/gen/summary.js +11 -7
- package/dist/gen/toc.js +5 -2
- package/dist/run-check.d.ts +5 -0
- package/dist/run-check.js +35 -0
- package/dist/types.d.ts +6 -4
- package/dist/utils/anchor.d.ts +1 -1
- package/dist/utils/anchor.js +1 -1
- package/dist/utils/ignore.d.ts +2 -8
- package/dist/utils/ignore.js +23 -6
- package/dist/utils/parse.d.ts +6 -6
- package/dist/utils/parse.js +18 -27
- package/dist/utils/path-match.d.ts +19 -0
- package/dist/utils/path-match.js +27 -0
- package/dist/utils/report.d.ts +1 -7
- package/dist/utils/report.js +10 -3
- package/dist/utils/resolve.d.ts +15 -5
- package/dist/utils/resolve.js +63 -25
- package/dist/utils/root.d.ts +2 -0
- package/dist/utils/root.js +19 -0
- package/dist/utils/scan.d.ts +1 -3
- package/dist/utils/scan.js +28 -26
- package/dist/utils/scope.d.ts +37 -11
- package/dist/utils/scope.js +60 -24
- package/package.json +3 -3
- package/scaffold/AGENTS.md +4 -6
- package/scaffold/claude/skills/{check.md → check/SKILL.md} +6 -3
- package/scaffold/claude/skills/{gen.md → gen/SKILL.md} +5 -3
- package/scaffold/claude/skills/{plan-close.md → plan-close/SKILL.md} +1 -0
- package/scaffold/claude/skills/{plan-open.md → plan-open/SKILL.md} +1 -0
- package/scaffold/claude/skills/{plan-run.md → plan-run/SKILL.md} +1 -0
- package/scaffold/pending.md +1 -1
- package/scaffold/project.md +1 -1
- package/scaffold/rules.md +28 -27
- package/scaffold/templates/plan.md +3 -7
package/dist/checks/markers.js
CHANGED
|
@@ -1,42 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 마커 ↔ 관리 문서 대조 (`
|
|
2
|
+
* 마커 ↔ 관리 문서 대조 (`specthread/rules.md` §4-1).
|
|
3
3
|
*
|
|
4
4
|
* 양방향으로 본다 - 코드·문서에 박힌 새 형식 마커가 관리 문서 항목을 실제로
|
|
5
5
|
* 가리키는가, 그리고 관리 문서 항목이 최소 하나의 마커에서라도 걸리는가.
|
|
6
|
+
* 종류가 `markers.types` 에 있는지도 함께 본다.
|
|
6
7
|
*/
|
|
8
|
+
import { PENDING_PATH } from "../constants/paths.js";
|
|
9
|
+
import { ITEM_HEADING } from "../constants/patterns.js";
|
|
7
10
|
import { RULE } from "../constants/rules.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
import { eachContentLine } from "../utils/parse.js";
|
|
12
|
+
import { inChangeLog } from "../utils/scope.js";
|
|
13
|
+
/** 관리 문서 항목 id → 그 헤딩 줄 번호. 변경 이력 안의 것은 과거 기록이라 뺀다 */
|
|
14
|
+
export const pendingItemLines = (pending) => {
|
|
11
15
|
const out = new Map();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
inChangeLog = true;
|
|
16
|
-
if (inChangeLog)
|
|
16
|
+
const collect = (raw, i) => {
|
|
17
|
+
const line = i + 1;
|
|
18
|
+
if (inChangeLog(pending, line))
|
|
17
19
|
return;
|
|
18
|
-
const m =
|
|
20
|
+
const m = ITEM_HEADING.exec(raw);
|
|
19
21
|
if (m)
|
|
20
|
-
out.set(m[1],
|
|
21
|
-
}
|
|
22
|
+
out.set(m[1], line);
|
|
23
|
+
};
|
|
24
|
+
eachContentLine(pending.lines, collect);
|
|
22
25
|
return out;
|
|
23
26
|
};
|
|
27
|
+
const kindOf = (id) => id.split("::")[0];
|
|
24
28
|
export const checkMarkers = (index) => {
|
|
25
|
-
const pending = index.files.get(
|
|
29
|
+
const pending = index.files.get(PENDING_PATH);
|
|
26
30
|
if (pending === undefined)
|
|
27
31
|
return [];
|
|
28
32
|
const items = pendingItemLines(pending);
|
|
33
|
+
const types = new Set(index.config.markers.types);
|
|
29
34
|
const findings = [];
|
|
30
35
|
const seen = new Set();
|
|
36
|
+
const unknownType = (file, line, id) => ({
|
|
37
|
+
file,
|
|
38
|
+
line,
|
|
39
|
+
rule: RULE.MARKER.UNKNOWN_TYPE,
|
|
40
|
+
message: `종류 ${kindOf(id)} 가 config.markers.types 에 없다 - ${id}`,
|
|
41
|
+
});
|
|
31
42
|
for (const file of index.files.values()) {
|
|
32
|
-
if (file.path ===
|
|
43
|
+
if (file.path === PENDING_PATH)
|
|
33
44
|
continue;
|
|
34
45
|
for (const marker of file.markers) {
|
|
35
46
|
if (marker.slug === "")
|
|
36
47
|
continue;
|
|
37
48
|
const id = `${marker.kind}::${marker.slug}`;
|
|
38
49
|
seen.add(id);
|
|
39
|
-
if (
|
|
50
|
+
if (!types.has(marker.kind))
|
|
51
|
+
findings.push(unknownType(file.path, marker.line, id));
|
|
52
|
+
if (items.has(id))
|
|
40
53
|
continue;
|
|
41
54
|
findings.push({
|
|
42
55
|
file: file.path,
|
|
@@ -46,14 +59,16 @@ export const checkMarkers = (index) => {
|
|
|
46
59
|
});
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
|
-
for (const [
|
|
50
|
-
if (
|
|
62
|
+
for (const [id, line] of items) {
|
|
63
|
+
if (!types.has(kindOf(id)))
|
|
64
|
+
findings.push(unknownType(pending.path, line, id));
|
|
65
|
+
if (seen.has(id))
|
|
51
66
|
continue;
|
|
52
67
|
findings.push({
|
|
53
68
|
file: pending.path,
|
|
54
69
|
line,
|
|
55
70
|
rule: RULE.MARKER.UNMARKED,
|
|
56
|
-
message: `[${
|
|
71
|
+
message: `[${id}] 를 가리키는 마커가 없다 - 억제하려면 @specthread-ignore`,
|
|
57
72
|
});
|
|
58
73
|
}
|
|
59
74
|
return findings;
|
package/dist/checks/pending.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 관리 문서 항목 형식 (`
|
|
2
|
+
* 관리 문서 항목 형식 (`specthread/rules.md` §4-2).
|
|
3
3
|
*
|
|
4
4
|
* 이 검사는 관리 문서 한 파일에만 걸린다. 항목이 한곳에 모이는 것이 그 문서의 존재
|
|
5
5
|
* 이유라서, 다른 문서에 같은 모양이 나타나면 그건 미확정 사항 절 (생성 뷰) 이고
|
|
6
6
|
* 형식이 다르다 - 뷰는 `li`, 정본은 `###` 헤딩이다.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { dirname, join, normalize } from 'node:path';
|
|
9
|
+
import { PENDING_PATH } from '../constants/paths.js';
|
|
10
|
+
import { ITEM_AS_LI, ITEM_HEADING, timepointGlobal } from '../constants/patterns.js';
|
|
9
11
|
import { RULE } from '../constants/rules.js';
|
|
10
12
|
import { summaryBlocks } from '../gen/summary.js';
|
|
11
13
|
import { invertByTarget, pendingSectionBlock } from '../gen/pending-section.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const ITEM_AS_LI = /^\s*-\s+`\[[a-z]+::[a-z0-9][a-z0-9-]*\]`/;
|
|
14
|
+
import { eachContentLine } from '../utils/parse.js';
|
|
15
|
+
import { underPath } from '../utils/path-match.js';
|
|
16
|
+
import { inChangeLog, isWorkDoc } from '../utils/scope.js';
|
|
16
17
|
/**
|
|
17
18
|
* 문장이 끝난 흔적.
|
|
18
19
|
*
|
|
@@ -49,7 +50,21 @@ const inspectHeading = (path, line, title) => {
|
|
|
49
50
|
}
|
|
50
51
|
return findings;
|
|
51
52
|
};
|
|
52
|
-
|
|
53
|
+
/** 링크 대상과 코드 스팬. 둘 다 경로가 올 수 있다 */
|
|
54
|
+
const LINK_TARGET = /\]\(([^)]+)\)/g;
|
|
55
|
+
const CODE_SPAN = /`([^`]+)`/g;
|
|
56
|
+
/**
|
|
57
|
+
* 경로가 작업 폴더를 가리키는지.
|
|
58
|
+
*
|
|
59
|
+
* 링크는 문서 기준 상대 경로, 코드 스팬은 루트 기준 표기가 흔하다. 둘 다 본다.
|
|
60
|
+
*/
|
|
61
|
+
const pointsToWork = (raw, dir, work) => {
|
|
62
|
+
const clean = raw.split('#')[0].trim();
|
|
63
|
+
if (clean === '')
|
|
64
|
+
return false;
|
|
65
|
+
return underPath(normalize(clean), work) || underPath(normalize(join(dir, clean)), work);
|
|
66
|
+
};
|
|
67
|
+
const inspectBody = (path, line, text, work) => {
|
|
53
68
|
const findings = [];
|
|
54
69
|
if (ITEM_AS_LI.test(text)) {
|
|
55
70
|
findings.push({
|
|
@@ -67,7 +82,12 @@ const inspectBody = (path, line, text) => {
|
|
|
67
82
|
message: '선택지는 `li` 로 낸다',
|
|
68
83
|
});
|
|
69
84
|
}
|
|
70
|
-
|
|
85
|
+
const dir = dirname(path);
|
|
86
|
+
const refs = [
|
|
87
|
+
...[...text.matchAll(LINK_TARGET)].map((m) => m[1]),
|
|
88
|
+
...[...text.matchAll(CODE_SPAN)].map((m) => m[1]),
|
|
89
|
+
];
|
|
90
|
+
if (refs.some((r) => pointsToWork(r, dir, work))) {
|
|
71
91
|
findings.push({
|
|
72
92
|
file: path,
|
|
73
93
|
line,
|
|
@@ -77,8 +97,9 @@ const inspectBody = (path, line, text) => {
|
|
|
77
97
|
}
|
|
78
98
|
return findings;
|
|
79
99
|
};
|
|
80
|
-
/** 항목 헤딩 다음 첫 내용 줄이
|
|
81
|
-
const inspectTimepoint = (file, at) => {
|
|
100
|
+
/** 항목 헤딩 다음 첫 내용 줄이 시점인지, 해결 예정 라벨이 정의된 것인지 */
|
|
101
|
+
const inspectTimepoint = (file, at, config) => {
|
|
102
|
+
const { timepoints } = config.markers;
|
|
82
103
|
for (let i = at; i < file.lines.length; i++) {
|
|
83
104
|
const line = file.lines[i].trim();
|
|
84
105
|
if (line === '')
|
|
@@ -104,6 +125,18 @@ const inspectTimepoint = (file, at) => {
|
|
|
104
125
|
},
|
|
105
126
|
];
|
|
106
127
|
}
|
|
128
|
+
// 목록이 비어 있으면 라벨을 자유롭게 쓰는 프로젝트다
|
|
129
|
+
const label = stamp[2]?.trim();
|
|
130
|
+
if (label !== undefined && timepoints.length > 0 && !timepoints.includes(label)) {
|
|
131
|
+
return [
|
|
132
|
+
{
|
|
133
|
+
file: file.path,
|
|
134
|
+
line: i + 1,
|
|
135
|
+
rule: RULE.PENDING.UNKNOWN_TIMEPOINT,
|
|
136
|
+
message: `해결 예정 ${label} 이 config.markers.timepoints 에 없다`,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
}
|
|
107
140
|
return [];
|
|
108
141
|
}
|
|
109
142
|
// 헤딩 뒤에 아무 줄도 없으면 시점 줄이 빠진 것이다
|
|
@@ -150,17 +183,20 @@ const inspectSummary = (file, index) => {
|
|
|
150
183
|
/**
|
|
151
184
|
* 문서 미확정 사항 절 ↔ 관리 문서 백링크 일치.
|
|
152
185
|
*
|
|
153
|
-
* 목차·참조 절과 같은 구조다.
|
|
186
|
+
* 목차·참조 절과 같은 구조다. 관리 문서를 제외한 모든 문서가 대상이다 -
|
|
154
187
|
* 절 자체가 없는 문서는 `gen/pending-section.ts` 가 건드리지 않으므로 지적도 없다.
|
|
155
188
|
*/
|
|
156
189
|
const inspectPendingSection = (index) => {
|
|
157
|
-
const pending = index.files.get(
|
|
190
|
+
const pending = index.files.get(PENDING_PATH);
|
|
158
191
|
if (pending === undefined)
|
|
159
192
|
return [];
|
|
160
193
|
const byTarget = invertByTarget(pending);
|
|
161
194
|
const findings = [];
|
|
162
195
|
for (const file of index.files.values()) {
|
|
163
|
-
if (file.path ===
|
|
196
|
+
if (file.path === PENDING_PATH || file.pendingSection === null)
|
|
197
|
+
continue;
|
|
198
|
+
// 작업 문서는 생성 대상이 아니다 (pendingSectionBlock 과 같은 조건).
|
|
199
|
+
if (isWorkDoc(file.path, index.config))
|
|
164
200
|
continue;
|
|
165
201
|
const expected = pendingSectionBlock(file, byTarget, index);
|
|
166
202
|
const actual = file.lines.slice(file.pendingSection.start - 1, file.pendingSection.end);
|
|
@@ -177,24 +213,22 @@ const inspectPendingSection = (index) => {
|
|
|
177
213
|
return findings;
|
|
178
214
|
};
|
|
179
215
|
export const checkPending = (index) => {
|
|
180
|
-
const file = index.files.get(
|
|
216
|
+
const file = index.files.get(PENDING_PATH);
|
|
181
217
|
if (file === undefined)
|
|
182
218
|
return [];
|
|
183
219
|
const findings = [];
|
|
184
|
-
|
|
185
|
-
file.lines
|
|
220
|
+
// 코드블록 안은 항목 형식을 보여주는 예시다
|
|
221
|
+
eachContentLine(file.lines, (raw, i) => {
|
|
186
222
|
const line = i + 1;
|
|
187
|
-
if (
|
|
188
|
-
inChangeLog = true;
|
|
189
|
-
if (inChangeLog)
|
|
223
|
+
if (inChangeLog(file, line))
|
|
190
224
|
return;
|
|
191
|
-
const item =
|
|
225
|
+
const item = ITEM_HEADING.exec(raw);
|
|
192
226
|
if (item) {
|
|
193
|
-
findings.push(...inspectHeading(file.path, line, item[
|
|
194
|
-
findings.push(...inspectTimepoint(file, line));
|
|
227
|
+
findings.push(...inspectHeading(file.path, line, item[2]));
|
|
228
|
+
findings.push(...inspectTimepoint(file, line, index.config));
|
|
195
229
|
return;
|
|
196
230
|
}
|
|
197
|
-
findings.push(...inspectBody(file.path, line, raw));
|
|
231
|
+
findings.push(...inspectBody(file.path, line, raw, index.config.work));
|
|
198
232
|
});
|
|
199
233
|
return [...findings, ...inspectSummary(file, index), ...inspectPendingSection(index)];
|
|
200
234
|
};
|
|
@@ -5,14 +5,14 @@ import { RULE } from '../constants/rules.js';
|
|
|
5
5
|
* 목차와 같은 구조다 - 본문에 이미 있는 정보를 문서 하단에 한 번 더 적는 자리라
|
|
6
6
|
* 손으로 관리하면 반드시 어긋난다. 생성 결과와 다르면 지적한다.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { isDoc } from "../utils/scope.js";
|
|
9
9
|
import { referenceBlock } from "../gen/references.js";
|
|
10
10
|
/** 블록 안 항목 줄 수. 지적 메시지에 규모를 실어준다 */
|
|
11
11
|
const itemCount = (lines) => lines.filter((l) => l.startsWith("- [")).length;
|
|
12
12
|
export const checkReferences = (index) => {
|
|
13
13
|
const findings = [];
|
|
14
14
|
for (const file of index.files.values()) {
|
|
15
|
-
if (!
|
|
15
|
+
if (!isDoc(file))
|
|
16
16
|
continue;
|
|
17
17
|
// 본문 링크가 없으면 참조 절을 둘 이유가 없다
|
|
18
18
|
const expected = referenceBlock(file, index.config);
|
package/dist/checks/sections.js
CHANGED
|
@@ -6,8 +6,7 @@ import { RULE } from '../constants/rules.js';
|
|
|
6
6
|
* 번호 없는 헤딩은 § 대상이 될 수 없으므로 대조 집합에 들어가지 않는다.
|
|
7
7
|
*/
|
|
8
8
|
import { basename, dirname, relative } from "node:path";
|
|
9
|
-
import { inChangeLog, inRefSection, inToc,
|
|
10
|
-
/** 미해소 사유별 메시지 */
|
|
9
|
+
import { inChangeLog, inPendingSection, inRefSection, inToc, isHeadingLine, } from "../utils/scope.js";
|
|
11
10
|
/**
|
|
12
11
|
* 해소 실패 사유마다 규칙 id 와 메시지.
|
|
13
12
|
*
|
|
@@ -118,14 +117,12 @@ export const checkSectionRefs = (index) => {
|
|
|
118
117
|
const numsByFile = sectionNumbers(index);
|
|
119
118
|
for (const file of index.files.values()) {
|
|
120
119
|
// 코드·데이터도 문서의 절을 가리키므로 `md` 로 좁히지 않는다
|
|
121
|
-
if (!isCheckTarget(file.path, index.config))
|
|
122
|
-
continue;
|
|
123
120
|
for (const ref of file.sectionRefs) {
|
|
124
|
-
if (
|
|
121
|
+
if (inChangeLog(file, ref.line))
|
|
125
122
|
continue;
|
|
126
123
|
if (isHeadingLine(file, ref.line) || inToc(file, ref.line))
|
|
127
124
|
continue;
|
|
128
|
-
if (inRefSection(file, ref.line))
|
|
125
|
+
if (inRefSection(file, ref.line) || inPendingSection(file, ref.line))
|
|
129
126
|
continue;
|
|
130
127
|
const finding = inspect(index, numsByFile, file, ref);
|
|
131
128
|
if (finding !== null) {
|
package/dist/checks/style.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import type { DocIndex, Finding } from '../types.ts';
|
|
2
|
-
export declare const checkStyle: (index: DocIndex) => Finding[];
|
|
3
|
-
/**
|
|
4
|
-
* 코드에 있는 검사 id 가 규칙 문서에 선언됐는지.
|
|
5
|
-
*
|
|
6
|
-
* 선언이 없으면 문서화되지 않은 규칙을 강제하는 것이다. 역방향 (문서에만 있고 코드에
|
|
7
|
-
* 없는 것) 은 절 단위 판정이 애매해 검사하지 않는다 - 병기가 없는 절이 곧 사람만
|
|
8
|
-
* 검사하는 규칙이다.
|
|
9
|
-
*/
|
|
10
2
|
export declare const checkRuleDeclared: (index: DocIndex) => Finding[];
|
package/dist/checks/style.js
CHANGED
|
@@ -1,59 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 규칙 선언 대조 (`specthread/rules.md` §5).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 코드에 있는 검사 id 가 규칙 문서에 선언됐는지 본다. 선언이 없으면 문서화되지 않은
|
|
5
|
+
* 규칙을 강제하는 것이다. 역방향 (문서에만 있고 코드에 없는 것) 은 절 단위 판정이 애매해
|
|
6
|
+
* 검사하지 않는다 - 병기가 없는 절이 곧 사람만 검사하는 규칙이다.
|
|
6
7
|
*/
|
|
7
|
-
import {
|
|
8
|
+
import { RULES_PATH } from '../constants/paths.js';
|
|
8
9
|
import { ALL_RULE_IDS, RULE } from '../constants/rules.js';
|
|
9
|
-
import { codeSpanMask } from '../utils/parse.js';
|
|
10
|
-
import { isCheckTarget } from '../utils/scope.js';
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* 지금 실제로 도는 검사 id 만.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* 기능을 끄면 그 검사는 돌지 않으므로 규칙 문서에 선언을 요구할 이유도 없다.
|
|
14
|
+
* 끈 기능의 문서를 지웠다고 지적이 나오면 정리를 벌하는 셈이 된다.
|
|
16
15
|
*/
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const mask = codeSpanMask(raw);
|
|
28
|
-
const at = [...raw].findIndex((c, k) => c === EM_DASH && !mask[k]);
|
|
29
|
-
if (at < 0)
|
|
30
|
-
return;
|
|
31
|
-
findings.push({
|
|
32
|
-
file: file.path,
|
|
33
|
-
line: i + 1,
|
|
34
|
-
rule: RULE.STYLE.EM_DASH,
|
|
35
|
-
message: "em dash 를 쓰지 않는다. 하이픈 '-' 으로",
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return findings;
|
|
16
|
+
const enabledRuleIds = (index) => {
|
|
17
|
+
const { features } = index.config;
|
|
18
|
+
return ALL_RULE_IDS.filter((id) => {
|
|
19
|
+
const group = id.split('/')[0];
|
|
20
|
+
if (group === 'reference')
|
|
21
|
+
return features.references;
|
|
22
|
+
if (group === 'marker' || group === 'pending')
|
|
23
|
+
return features.markers;
|
|
24
|
+
return true;
|
|
25
|
+
});
|
|
40
26
|
};
|
|
41
|
-
/**
|
|
42
|
-
* 코드에 있는 검사 id 가 규칙 문서에 선언됐는지.
|
|
43
|
-
*
|
|
44
|
-
* 선언이 없으면 문서화되지 않은 규칙을 강제하는 것이다. 역방향 (문서에만 있고 코드에
|
|
45
|
-
* 없는 것) 은 절 단위 판정이 애매해 검사하지 않는다 - 병기가 없는 절이 곧 사람만
|
|
46
|
-
* 검사하는 규칙이다.
|
|
47
|
-
*/
|
|
48
27
|
export const checkRuleDeclared = (index) => {
|
|
49
|
-
const
|
|
50
|
-
const doc = index.files.get(rulesPath);
|
|
28
|
+
const doc = index.files.get(RULES_PATH);
|
|
51
29
|
if (doc === undefined)
|
|
52
30
|
return [];
|
|
53
31
|
const text = doc.lines.join('\n');
|
|
54
32
|
const heading = doc.headings.find((h) => h.title === '개요');
|
|
55
|
-
return
|
|
56
|
-
|
|
33
|
+
return enabledRuleIds(index)
|
|
34
|
+
.filter((id) => !text.includes(id))
|
|
35
|
+
.map((id) => ({
|
|
36
|
+
file: RULES_PATH,
|
|
57
37
|
line: heading?.line ?? 1,
|
|
58
38
|
rule: RULE.STYLE.RULE_UNDECLARED,
|
|
59
39
|
message: `검사 id 가 규칙 문서에 선언되지 않았다 - ${id}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { timepointGlobal } from '../constants/patterns.js';
|
|
2
2
|
import { RULE } from '../constants/rules.js';
|
|
3
3
|
/**
|
|
4
|
-
* 본문 시점 표기 - 날짜를 본문에 남기지 않는가 (`
|
|
4
|
+
* 본문 시점 표기 - 날짜를 본문에 남기지 않는가 (`specthread/rules.md` §2-1).
|
|
5
5
|
*
|
|
6
6
|
* 문서 본문은 현재 상태와 근거만 서술하고, _누가 언제 무엇을 뒤집었는가_ 는 변경 이력이
|
|
7
7
|
* 갖는다. §2-1 이 금지하는 다섯 가지 중 **날짜만** 여기서 본다. 나머지 (시점을 함의하는
|
|
@@ -9,7 +9,7 @@ import { RULE } from '../constants/rules.js';
|
|
|
9
9
|
* 검토에 맡긴다 - `신규 5 종` 같은 콘텐츠 서술까지 걸린다.
|
|
10
10
|
*/
|
|
11
11
|
import { codeSpanMask, linkTargetSpans } from "../utils/parse.js";
|
|
12
|
-
import { inChangeLog, inToc,
|
|
12
|
+
import { inChangeLog, inPendingSection, inToc, isDoc } from "../utils/scope.js";
|
|
13
13
|
const DATE = /20\d\d-\d\d-\d\d/g;
|
|
14
14
|
/** 시점 표기가 차지한 자리 */
|
|
15
15
|
const timepointSpans = (text) => [...text.matchAll(timepointGlobal())].map((m) => ({
|
|
@@ -19,7 +19,7 @@ const timepointSpans = (text) => [...text.matchAll(timepointGlobal())].map((m) =
|
|
|
19
19
|
export const checkTimestamps = (index) => {
|
|
20
20
|
const findings = [];
|
|
21
21
|
for (const file of index.files.values()) {
|
|
22
|
-
if (!
|
|
22
|
+
if (!isDoc(file))
|
|
23
23
|
continue;
|
|
24
24
|
let fence = false;
|
|
25
25
|
file.lines.forEach((text, i) => {
|
|
@@ -28,8 +28,8 @@ export const checkTimestamps = (index) => {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const line = i + 1;
|
|
31
|
-
//
|
|
32
|
-
if (fence || inChangeLog(file, line) || inToc(file, line))
|
|
31
|
+
// 코드블록은 예시, 변경 이력은 날짜가 있어야 하는 곳, 목차·미확정 사항 절은 생성물이다
|
|
32
|
+
if (fence || inChangeLog(file, line) || inToc(file, line) || inPendingSection(file, line))
|
|
33
33
|
return;
|
|
34
34
|
const mask = codeSpanMask(text);
|
|
35
35
|
const urls = linkTargetSpans(text);
|
package/dist/checks/toc.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { RULE } from
|
|
1
|
+
import { RULE } from "../constants/rules.js";
|
|
2
2
|
/**
|
|
3
3
|
* 목차 ↔ `##` 헤딩 일치.
|
|
4
4
|
*
|
|
5
5
|
* 목차는 생성기가 채우지만 사람이 손으로 고칠 수 있고, 절을 하나 끼워 넣으면
|
|
6
|
-
* 조용히 어긋난다. 생성 결과와 다르면 지적한다 - 고치는 방법은 `
|
|
6
|
+
* 조용히 어긋난다. 생성 결과와 다르면 지적한다 - 고치는 방법은 `specthread gen --write` 다.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { isDoc, singleTitle } from "../utils/scope.js";
|
|
9
9
|
import { tocBlock } from "../gen/toc.js";
|
|
10
10
|
export const checkToc = (index) => {
|
|
11
11
|
const findings = [];
|
|
12
12
|
for (const file of index.files.values()) {
|
|
13
|
-
if (!
|
|
14
|
-
continue;
|
|
15
|
-
if (singleTitle(file) === null)
|
|
13
|
+
if (singleTitle(file) === null || !isDoc(file))
|
|
16
14
|
continue;
|
|
17
15
|
// `##` 절이 없으면 목차를 둘 이유가 없다
|
|
18
16
|
const expected = tocBlock(file.headings);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init 이 생성하는 config.jsonc 본문.
|
|
3
|
+
*
|
|
4
|
+
* 값은 DEFAULT_CONFIG 에서 보간한다. scaffold 에 사본을 두면 기본값이 두 곳이 되고,
|
|
5
|
+
* 한쪽만 고쳐도 아무 곳에서도 드러나지 않는다.
|
|
6
|
+
*/
|
|
7
|
+
import type { SpecthreadConfig } from "../config.schema.ts";
|
|
8
|
+
export declare const renderConfig: (c: SpecthreadConfig) => string;
|
|
@@ -1,80 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
/** 한 줄이 너무 길어지지 않게 확장자를 묶는다. 항목 추가 시 뒤쪽만 흐른다 */
|
|
2
|
+
const wrapList = (items, indent, width = 72) => {
|
|
3
|
+
const lines = [];
|
|
4
|
+
let line = "";
|
|
5
|
+
items.forEach((item, i) => {
|
|
6
|
+
const piece = `"${item}"${i < items.length - 1 ? "," : ""}`;
|
|
7
|
+
const next = line === "" ? piece : `${line} ${piece}`;
|
|
8
|
+
if (indent.length + next.length > width && line !== "") {
|
|
9
|
+
lines.push(indent + line);
|
|
10
|
+
line = piece;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
line = next;
|
|
14
|
+
});
|
|
15
|
+
if (line !== "")
|
|
16
|
+
lines.push(indent + line);
|
|
17
|
+
return lines.join("\n");
|
|
18
|
+
};
|
|
19
|
+
const inlineList = (items) => `[${items.map((i) => `"${i}"`).join(", ")}]`;
|
|
20
|
+
export const renderConfig = (c) => `{
|
|
2
21
|
// ── specthread 설정 ──────────────────────────────────────────────
|
|
3
22
|
// 생략한 키는 기본값이 적용된다. 개인 설정은 config.local.jsonc (gitignore 대상).
|
|
4
23
|
|
|
5
24
|
// ── 파일 종류 ────────────────────────────────────────────────────
|
|
6
|
-
// 확장자 → 종류 매핑.
|
|
25
|
+
// 확장자 → 종류 매핑. 아래는 기본값이고, 필요한 확장자를 더하거나 뺄 수 있다.
|
|
7
26
|
// doc: 기획 소스. 풀파싱 대상 (헤딩, 링크, 목차, 참조절, 마커).
|
|
8
27
|
// source: 문서 외 참조 파일. 마커 + 절참조 스캔만.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
28
|
+
"fileKinds": {
|
|
29
|
+
"doc": ${inlineList(c.fileKinds.doc)},
|
|
30
|
+
"source": [
|
|
31
|
+
${wrapList(c.fileKinds.source, " ")}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
13
34
|
|
|
14
35
|
// ── 스캔 대상 경로 ───────────────────────────────────────────────
|
|
15
36
|
// 자유 KV. 키는 용도 라벨, 값은 경로 배열.
|
|
16
37
|
// 디렉터리면 재귀 스캔, 파일이면 직접 로드.
|
|
38
|
+
// 적으면 기본값을 통째로 교체한다 (키 단위로 합치지 않는다).
|
|
39
|
+
// specthread/ 의 rules·pending·project 는 여기 없어도 항상 읽는다.
|
|
17
40
|
// 예: "source": ["client/src/"], "data": ["data/"]
|
|
18
41
|
// "meta": ["CLAUDE.md", "AGENTS.md"]
|
|
19
42
|
"path": {
|
|
20
|
-
|
|
21
|
-
"
|
|
43
|
+
${Object.entries(c.path)
|
|
44
|
+
.map(([k, v]) => ` "${k}": ${inlineList(v)}`)
|
|
45
|
+
.join(",\n")}
|
|
22
46
|
},
|
|
23
47
|
|
|
24
48
|
// ── 기능 플래그 ──────────────────────────────────────────────────
|
|
25
49
|
// 기능 단위 on/off. 개별 규칙이 아닌 기능 묶음으로 제어한다.
|
|
26
50
|
"features": {
|
|
27
51
|
// 마커 체계 전체. false → marker/*, pending/* 검사 + pending 추적 비활성화
|
|
28
|
-
"markers":
|
|
29
|
-
// em dash 검사 + 치환 훅. false → style/em-dash 검사 + hook 비활성화
|
|
30
|
-
"emDash": true,
|
|
52
|
+
"markers": ${c.features.markers},
|
|
31
53
|
// 참조 절 자동 생성. false → reference/* 검사 + gen references 스킵
|
|
32
|
-
"references":
|
|
54
|
+
"references": ${c.features.references}
|
|
33
55
|
},
|
|
34
56
|
|
|
35
57
|
// ── 마커 체계 ────────────────────────────────────────────────────
|
|
36
58
|
"markers": {
|
|
37
59
|
// 마커 종류. "system" 은 코어 예약, 나머지는 프로젝트 정의.
|
|
60
|
+
// 여기 없는 종류의 마커·항목은 marker/unknown-type 으로 지적한다.
|
|
38
61
|
// 예: ["system", "design", "balance", "deps"]
|
|
39
|
-
"types":
|
|
40
|
-
// 처리 시점 라벨. 마일스톤 등.
|
|
41
|
-
// 예: ["M1", "M2", "
|
|
42
|
-
"timepoints":
|
|
62
|
+
"types": ${inlineList(c.markers.types)},
|
|
63
|
+
// 처리 시점 라벨. 마일스톤 등. 비어 있으면 해결 예정 라벨을 검사하지 않는다.
|
|
64
|
+
// 예: ["M1", "M2", "P01-123"]
|
|
65
|
+
"timepoints": ${inlineList(c.markers.timepoints)}
|
|
43
66
|
}
|
|
44
67
|
|
|
45
|
-
// ── 문서 유형 (기본값: {}) ───────────────────────────────────────
|
|
46
|
-
// 경로 패턴별 템플릿과 프론트매터 스키마를 지정한다.
|
|
47
|
-
// "docTypes": {
|
|
48
|
-
// "spec": {
|
|
49
|
-
// "path": "docs/spec/",
|
|
50
|
-
// "template": "specthread/templates/spec.md",
|
|
51
|
-
// "frontmatter": { "required": ["title"], "optional": ["status"] }
|
|
52
|
-
// }
|
|
53
|
-
// }
|
|
54
|
-
|
|
55
68
|
// ── 문서명 해소 무시 (기본값: []) ────────────────────────────────
|
|
56
|
-
// 절
|
|
69
|
+
// 절 참조가 파일명과 잘못 매칭되는 것을 방지한다.
|
|
57
70
|
// "ignoreDocNames": ["spec"]
|
|
58
71
|
|
|
59
72
|
// ── 검사 제외 (기본값: []) ───────────────────────────────────────
|
|
60
|
-
// 경로
|
|
73
|
+
// 경로 아래의 검사·생성을 전부 건너뛰거나, 특정 군만 남긴다.
|
|
74
|
+
// specthread/templates/ 와 설정 파일은 적지 않아도 항상 제외한다.
|
|
61
75
|
// "skipCheck": [
|
|
62
76
|
// "docs/archive/",
|
|
63
77
|
// { "path": "docs/drafts/", "only": ["heading", "link"] }
|
|
64
78
|
// ]
|
|
65
79
|
|
|
66
80
|
// ── 참조 절 생성 제외 (기본값: []) ──────────────────────────────
|
|
67
|
-
// 이 경로
|
|
68
|
-
// "skipRefs": ["
|
|
69
|
-
|
|
70
|
-
// ── 로케일 (기본값: "ko") ───────────────────────────────────────
|
|
71
|
-
// 현재 한국어 고정. 검사 메시지, 꼬리 절 이름, 시점 정규식 등에 영향.
|
|
72
|
-
// "locale": "ko"
|
|
81
|
+
// 이 경로 아래의 문서에는 참조 절을 생성하지 않는다.
|
|
82
|
+
// "skipRefs": ["CLAUDE.md", "docs/drafts/"]
|
|
73
83
|
|
|
74
|
-
// ──
|
|
75
|
-
//
|
|
76
|
-
// "
|
|
77
|
-
// "pending": "specthread/pending.md",
|
|
78
|
-
// "project": "specthread/project.md",
|
|
79
|
-
// "work": "docs/work/"
|
|
84
|
+
// ── 작업 문서 폴더 (기본값: "${c.work}/") ─────────────────────────
|
|
85
|
+
// 흡수 후 지우는 계획 문서. 미확정 사항 절을 만들지 않는다.
|
|
86
|
+
// "work": "${c.work}/"
|
|
80
87
|
}
|
|
88
|
+
`;
|