specthread 0.1.3 → 0.1.5
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 +2 -0
- package/dist/bin/cli.js +2 -1
- package/dist/checks/links.js +4 -3
- package/dist/commands/init.js +34 -22
- package/dist/gen/references.js +10 -5
- package/dist/utils/scan.d.ts +6 -2
- package/dist/utils/scan.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ CLAUDE.md ← Claude Code용 (@AGENTS.md)
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
npx specthread init [--tools claude,cursor] # 프로젝트 초기화
|
|
37
|
+
npx specthread init --force # scaffold 파일을 최신으로 덮어쓰기
|
|
37
38
|
npx specthread check # 문서 정합성 검사
|
|
38
39
|
npx specthread gen # 참조 절·목차·요약 표 미리보기
|
|
39
40
|
npx specthread gen --write # 실제 적용
|
|
@@ -64,6 +65,7 @@ specthread/config.local.jsonc (개인)
|
|
|
64
65
|
| 키 | 역할 |
|
|
65
66
|
| ----------- | ----------------------------------------------- |
|
|
66
67
|
| `path` | 스캔 대상 경로 (자유 KV) |
|
|
68
|
+
| `fileKinds` | 확장자 → 종류 매핑 (`doc` / `source`) |
|
|
67
69
|
| `features` | 기능 플래그 (`markers`, `emDash`, `references`) |
|
|
68
70
|
| `markers` | 마커 종류·시점 라벨 |
|
|
69
71
|
| `docTypes` | 경로별 템플릿·프론트매터 스키마 |
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const [command, ...rest] = process.argv.slice(2);
|
|
3
|
-
const usage = `specthread
|
|
3
|
+
const usage = `specthread - Spec-Driven Development (SDD) 도구
|
|
4
4
|
|
|
5
5
|
사용법: specthread <command> [options]
|
|
6
6
|
|
|
7
7
|
commands:
|
|
8
8
|
init [--tools claude,cursor] 프로젝트에 SDD 체계 초기화
|
|
9
|
+
init --force scaffold 파일을 최신으로 덮어쓰기
|
|
9
10
|
check 문서 정합성 검사 (28개 규칙)
|
|
10
11
|
gen [--write] 참조 절·목차·미확정 사항 요약 생성
|
|
11
12
|
help 이 도움말 표시
|
package/dist/checks/links.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RULE } from '../constants/rules.js';
|
|
2
2
|
/** 링크 유효성 - 대상 파일이 있는가, 앵커가 실제 헤딩을 가리키는가. */
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
|
-
import { join, dirname, normalize } from 'node:path';
|
|
5
|
-
import { REPO_ROOT } from '../utils/scan.js';
|
|
4
|
+
import { join, dirname, extname, normalize } from 'node:path';
|
|
5
|
+
import { REPO_ROOT, docExtSet } from '../utils/scan.js';
|
|
6
6
|
import { inChangeLog, inRefSection, isTargetDoc } from '../utils/scope.js';
|
|
7
7
|
/** 외부 링크는 파일 시스템에 없으니 확인하지 않는다 */
|
|
8
8
|
const isExternal = (target) => /^(https?:|mailto:)/.test(target);
|
|
@@ -14,6 +14,7 @@ const isExternal = (target) => /^(https?:|mailto:)/.test(target);
|
|
|
14
14
|
*/
|
|
15
15
|
export const checkLinks = (index) => {
|
|
16
16
|
const findings = [];
|
|
17
|
+
const docExts = docExtSet(index.config.fileKinds);
|
|
17
18
|
for (const file of index.files.values()) {
|
|
18
19
|
if (!isTargetDoc(file, index.config))
|
|
19
20
|
continue;
|
|
@@ -47,7 +48,7 @@ export const checkLinks = (index) => {
|
|
|
47
48
|
});
|
|
48
49
|
continue;
|
|
49
50
|
}
|
|
50
|
-
if (!link.anchor || !rel.
|
|
51
|
+
if (!link.anchor || !docExts.has(extname(rel).toLowerCase()))
|
|
51
52
|
continue;
|
|
52
53
|
const target = index.files.get(rel);
|
|
53
54
|
// 색인 범위 밖 문서 (archive 등) 는 앵커를 확인하지 않는다
|
package/dist/commands/init.js
CHANGED
|
@@ -15,14 +15,15 @@ const scaffoldDir = () => {
|
|
|
15
15
|
}
|
|
16
16
|
throw new Error("scaffold 디렉터리를 찾을 수 없다");
|
|
17
17
|
};
|
|
18
|
-
const
|
|
19
|
-
if (existsSync(dest))
|
|
20
|
-
return
|
|
18
|
+
const copyFile = (src, dest, force) => {
|
|
19
|
+
if (existsSync(dest) && !force)
|
|
20
|
+
return "skipped";
|
|
21
|
+
const existed = existsSync(dest);
|
|
21
22
|
const dir = dirname(dest);
|
|
22
23
|
if (!existsSync(dir))
|
|
23
24
|
mkdirSync(dir, { recursive: true });
|
|
24
25
|
writeFileSync(dest, readFileSync(src, "utf8"), "utf8");
|
|
25
|
-
return
|
|
26
|
+
return existed ? "overwritten" : "created";
|
|
26
27
|
};
|
|
27
28
|
const ensureAgentsMd = (cwd, scaffold) => {
|
|
28
29
|
const dest = join(cwd, "AGENTS.md");
|
|
@@ -66,11 +67,20 @@ const parseTools = (args) => {
|
|
|
66
67
|
return new Set(["claude"]);
|
|
67
68
|
return new Set(args[idx + 1].split(",").map((t) => t.trim().toLowerCase()));
|
|
68
69
|
};
|
|
70
|
+
const STATUS_LABEL = {
|
|
71
|
+
created: "생성",
|
|
72
|
+
overwritten: "덮어씀",
|
|
73
|
+
skipped: "이미 존재. 건너뜀",
|
|
74
|
+
};
|
|
69
75
|
export const init = (args) => {
|
|
70
76
|
const cwd = process.cwd();
|
|
71
77
|
const scaffold = scaffoldDir();
|
|
72
78
|
const tools = parseTools(args);
|
|
73
|
-
|
|
79
|
+
const force = args.includes("--force");
|
|
80
|
+
if (force)
|
|
81
|
+
console.log("specthread init --force\n");
|
|
82
|
+
else
|
|
83
|
+
console.log("specthread init\n");
|
|
74
84
|
const stDir = join(cwd, "specthread");
|
|
75
85
|
if (existsSync(stDir)) {
|
|
76
86
|
console.log(" specthread/ 이미 존재 - 기존 설정 유지");
|
|
@@ -79,22 +89,21 @@ export const init = (args) => {
|
|
|
79
89
|
mkdirSync(stDir, { recursive: true });
|
|
80
90
|
console.log(" specthread/ 생성");
|
|
81
91
|
}
|
|
82
|
-
const specthreadFiles = [
|
|
92
|
+
const specthreadFiles = [
|
|
93
|
+
"config.jsonc",
|
|
94
|
+
"rules.md",
|
|
95
|
+
"project.md",
|
|
96
|
+
"pending.md",
|
|
97
|
+
];
|
|
83
98
|
for (const file of specthreadFiles) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
console.log(` specthread/${file} 생성`);
|
|
87
|
-
else
|
|
88
|
-
console.log(` specthread/${file} 이미 존재 - 건너뜀`);
|
|
99
|
+
const status = copyFile(join(scaffold, file), join(stDir, file), force);
|
|
100
|
+
console.log(` specthread/${file} ${STATUS_LABEL[status]}`);
|
|
89
101
|
}
|
|
90
102
|
const templateFiles = ["spec.md", "plan.md"];
|
|
91
103
|
const templatesDir = join(stDir, "templates");
|
|
92
104
|
for (const file of templateFiles) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
console.log(` specthread/templates/${file} 생성`);
|
|
96
|
-
else
|
|
97
|
-
console.log(` specthread/templates/${file} 이미 존재 - 건너뜀`);
|
|
105
|
+
const status = copyFile(join(scaffold, "templates", file), join(templatesDir, file), force);
|
|
106
|
+
console.log(` specthread/templates/${file} ${STATUS_LABEL[status]}`);
|
|
98
107
|
}
|
|
99
108
|
ensureAgentsMd(cwd, scaffold);
|
|
100
109
|
if (tools.has("claude")) {
|
|
@@ -102,13 +111,16 @@ export const init = (args) => {
|
|
|
102
111
|
const skillsDir = join(cwd, ".claude", "skills");
|
|
103
112
|
if (!existsSync(skillsDir))
|
|
104
113
|
mkdirSync(skillsDir, { recursive: true });
|
|
105
|
-
const skillFiles = [
|
|
114
|
+
const skillFiles = [
|
|
115
|
+
"check.md",
|
|
116
|
+
"gen.md",
|
|
117
|
+
"plan-open.md",
|
|
118
|
+
"plan-run.md",
|
|
119
|
+
"plan-close.md",
|
|
120
|
+
];
|
|
106
121
|
for (const file of skillFiles) {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
console.log(` .claude/skills/${file} 생성`);
|
|
110
|
-
else
|
|
111
|
-
console.log(` .claude/skills/${file} 이미 존재 - 건너뜀`);
|
|
122
|
+
const status = copyFile(join(scaffold, "claude", "skills", file), join(skillsDir, file), force);
|
|
123
|
+
console.log(` .claude/skills/${file} ${STATUS_LABEL[status]}`);
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
126
|
console.log("\n완료. npx specthread check 로 문서 정합성을 확인할 수 있다.");
|
package/dist/gen/references.js
CHANGED
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
* 불러 지금 내용과 비교한다. 검사기가 생성기를 부르는 것이 거꾸로 보이지만,
|
|
14
14
|
* _무엇이 옳은 내용인가_ 를 한곳에서만 정의하려면 이 방향이 맞다.
|
|
15
15
|
*/
|
|
16
|
-
import { basename, dirname, join, normalize } from "node:path";
|
|
16
|
+
import { basename, dirname, extname, join, normalize } from "node:path";
|
|
17
|
+
import { docExtSet } from "../utils/scan.js";
|
|
17
18
|
import { wantsRefSection } from "../utils/scope.js";
|
|
18
|
-
/** 코드·데이터 대상인지.
|
|
19
|
-
const isCode = (path) =>
|
|
19
|
+
/** 코드·데이터 대상인지. doc 확장자가 아니고 디렉터리도 아니면 코드로 본다 */
|
|
20
|
+
const isCode = (path, docExts) => {
|
|
21
|
+
const ext = extname(path).toLowerCase();
|
|
22
|
+
return ext !== "" && !docExts.has(ext);
|
|
23
|
+
};
|
|
20
24
|
/**
|
|
21
25
|
* 링크 대상의 리포 루트 기준 위치. 같은 파일 이름이 겹칠 때 라벨로 쓴다.
|
|
22
26
|
*
|
|
@@ -96,8 +100,9 @@ export const referenceBlock = (file, config) => {
|
|
|
96
100
|
return [];
|
|
97
101
|
const label = labels(file.path, targets);
|
|
98
102
|
const render = (list) => list.map((t) => line(t, label.get(t.path) ?? t.path));
|
|
99
|
-
const
|
|
100
|
-
const
|
|
103
|
+
const exts = docExtSet(config.fileKinds);
|
|
104
|
+
const docs = targets.filter((t) => !isCode(t.path, exts));
|
|
105
|
+
const code = targets.filter((t) => isCode(t.path, exts));
|
|
101
106
|
const out = [""];
|
|
102
107
|
// 비는 갈래는 제목도 내지 않는다. 빈 제목만 남으면 아직 안 채운 것처럼 읽힌다
|
|
103
108
|
if (docs.length > 0)
|
package/dist/utils/scan.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { DocIndex } from "../types.ts";
|
|
2
|
-
import type { SpecthreadConfig } from "../config.schema.ts";
|
|
1
|
+
import type { DocIndex, FileKind } from "../types.ts";
|
|
2
|
+
import type { FileKindsConfig, SpecthreadConfig } from "../config.schema.ts";
|
|
3
3
|
/** 프로젝트 루트 절대 경로. 색인 경로를 여기 기준 상대 경로로 통일하는 데 쓴다 */
|
|
4
4
|
export declare const REPO_ROOT: string;
|
|
5
|
+
/** config.fileKinds 에서 확장자 → kind 역매핑을 만든다 */
|
|
6
|
+
export declare const buildExtMap: (kinds: FileKindsConfig) => Map<string, FileKind>;
|
|
7
|
+
/** doc 확장자 Set. 링크 대상이 문서인지 판정할 때 쓴다 */
|
|
8
|
+
export declare const docExtSet: (kinds: FileKindsConfig) => Set<string>;
|
|
5
9
|
/**
|
|
6
10
|
* 색인을 만든다. 검사기와 생성기의 유일한 입력이다.
|
|
7
11
|
*
|
package/dist/utils/scan.js
CHANGED
|
@@ -11,7 +11,7 @@ import { makeRefContext, parseSectionRefs } from "./resolve.js";
|
|
|
11
11
|
/** 프로젝트 루트 절대 경로. 색인 경로를 여기 기준 상대 경로로 통일하는 데 쓴다 */
|
|
12
12
|
export const REPO_ROOT = normalize(process.cwd());
|
|
13
13
|
/** config.fileKinds 에서 확장자 → kind 역매핑을 만든다 */
|
|
14
|
-
const buildExtMap = (kinds) => {
|
|
14
|
+
export const buildExtMap = (kinds) => {
|
|
15
15
|
const map = new Map();
|
|
16
16
|
for (const ext of kinds.doc)
|
|
17
17
|
map.set(ext.toLowerCase(), "doc");
|
|
@@ -19,6 +19,8 @@ const buildExtMap = (kinds) => {
|
|
|
19
19
|
map.set(ext.toLowerCase(), "source");
|
|
20
20
|
return map;
|
|
21
21
|
};
|
|
22
|
+
/** doc 확장자 Set. 링크 대상이 문서인지 판정할 때 쓴다 */
|
|
23
|
+
export const docExtSet = (kinds) => new Set(kinds.doc.map((e) => e.toLowerCase()));
|
|
22
24
|
/** 확장자로 파일 종류를 결정한다. config.fileKinds 기반 */
|
|
23
25
|
const kindFromPath = (file, extMap) => {
|
|
24
26
|
const dot = file.lastIndexOf(".");
|