@loviusc/sa-spec 0.1.0 → 0.1.3
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/package.json +5 -1
- package/readme.md +57 -29
- package/src/cli.js +131 -2
- package/templates/AGENTS.md +15 -14
- package/templates/project/req/handoff.md +1 -1
- package/templates/project/req/{uml.puml → uml/main.puml} +1 -1
- package/templates/readme.md +57 -29
- package/templates/rules/file-style.md +4 -6
- package/templates/rules/uml-style.md +4 -1
- package/templates/skills/system-analysis/SKILL.md +19 -16
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loviusc/sa-spec",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Personal system analysis documentation workspace CLI",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org/"
|
|
8
|
+
},
|
|
5
9
|
"bin": {
|
|
6
10
|
"sa-spec": "bin/sa-spec.js"
|
|
7
11
|
},
|
package/readme.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
`sa-spec` 是一個輕量的系統分析文件工作台,用固定流程把需求想法整理成可確認、可歸檔、可檢查的文件。
|
|
4
4
|
|
|
5
|
-
AI
|
|
5
|
+
AI 工作流只使用四個指令,並支援簡寫別名(兩者等價):
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
spec:
|
|
10
|
-
spec:
|
|
11
|
-
spec:
|
|
12
|
-
|
|
7
|
+
| 標準指令 | 簡寫 | 說明 |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `spec:init` | `sci` | 初始化專案與規則 |
|
|
10
|
+
| `spec:propose` | `scp` | 提出需求並整理摘要 |
|
|
11
|
+
| `spec:analyze` | `sca` | 衝突檢查與規格起草 |
|
|
12
|
+
| `spec:commit` | `scc` | 確認歸檔並建立 Git commit |
|
|
13
13
|
|
|
14
14
|
每個需求歸檔後固定包含:
|
|
15
15
|
|
|
@@ -17,7 +17,8 @@ spec:commit
|
|
|
17
17
|
project/
|
|
18
18
|
REQ-001-login/
|
|
19
19
|
srs.md
|
|
20
|
-
uml
|
|
20
|
+
uml/
|
|
21
|
+
main.puml
|
|
21
22
|
openapi.yaml
|
|
22
23
|
db-schema.md
|
|
23
24
|
handoff.md
|
|
@@ -240,6 +241,7 @@ sa-spec init --full
|
|
|
240
241
|
| `sa-spec check` | 檢查基本文件是否存在。 |
|
|
241
242
|
| `sa-spec status` | 顯示系統規格與需求索引狀態。 |
|
|
242
243
|
| `sa-spec doctor` | 檢查必要檔案是否存在。 |
|
|
244
|
+
| `sa-spec upgrade [--dry-run]` | 將既有專案升級為最新版本:同步最新 AGENTS 與規則文件,並將既有需求中的 `uml.puml` 自動遷移為 `uml/main.puml`。 |
|
|
243
245
|
|
|
244
246
|
`sa-spec new` 是快速建空白模板的輔助工具。正式需求流程仍建議使用 `spec:init`、`spec:propose`、`spec:analyze`、`spec:commit`。
|
|
245
247
|
|
|
@@ -259,7 +261,7 @@ sa-spec init --full
|
|
|
259
261
|
| AI 對話 | Claude Code 類型的 VS Code AI 套件或 CLI 整合 | 擇一 | 用 Claude 讀取工作區規則並協作產出需求文件。 |
|
|
260
262
|
| AI 對話 | Gemini 類型的 VS Code AI 套件或 CLI 整合 | 擇一 | 用 Gemini 讀取工作區規則並協作產出需求文件。 |
|
|
261
263
|
| Markdown | Markdown 預覽或 Markdown All in One 類型套件 | 選用 | 預覽 `srs.md`、`history.md`、`system-spec.md`。 |
|
|
262
|
-
| UML | PlantUML 類型套件 | 選用 |
|
|
264
|
+
| UML | PlantUML 類型套件 | 選用 | 預覽需求內的 `uml/*.puml`。 |
|
|
263
265
|
| YAML | YAML 類型套件 | 選用 | 編輯與檢查 `openapi.yaml`。 |
|
|
264
266
|
| Git | GitLens 類型套件 | 選用 | 查看需求文件修改歷程。 |
|
|
265
267
|
|
|
@@ -280,10 +282,10 @@ Markdown、PlantUML、YAML、GitLens 這類套件可以提升閱讀與檢查體
|
|
|
280
282
|
| CLI | `sa-spec init --full` | 終端機或 VS Code Terminal | 建立文件骨架與規則檔。 |
|
|
281
283
|
| CLI | `sa-spec check` | 終端機或 VS Code Terminal | 檢查必要文件是否存在。 |
|
|
282
284
|
| CLI | `sa-spec status` | 終端機或 VS Code Terminal | 查看系統規格與需求索引狀態。 |
|
|
283
|
-
| AI 工作流程 | `spec:init` | VS Code AI 對話側邊欄 | 載入規則並確認工作區狀態。 |
|
|
284
|
-
| AI 工作流程 | `spec:propose` | VS Code AI 對話側邊欄 | 整理使用者提出的需求。 |
|
|
285
|
-
| AI 工作流程 | `spec:analyze` | VS Code AI 對話側邊欄 | 檢查衝突並產出待確認草稿。 |
|
|
286
|
-
| AI 工作流程 | `spec:commit` | VS Code AI 對話側邊欄 | 歸檔已確認版本並建立本機 Git commit。 |
|
|
285
|
+
| AI 工作流程 | `spec:init` / `sci` | VS Code AI 對話側邊欄 | 載入規則並確認工作區狀態。 |
|
|
286
|
+
| AI 工作流程 | `spec:propose` / `scp` | VS Code AI 對話側邊欄 | 整理使用者提出的需求。 |
|
|
287
|
+
| AI 工作流程 | `spec:analyze` / `sca` | VS Code AI 對話側邊欄 | 檢查衝突並產出待確認草稿。 |
|
|
288
|
+
| AI 工作流程 | `spec:commit` / `scc` | VS Code AI 對話側邊欄 | 歸檔已確認版本並建立本機 Git commit。 |
|
|
287
289
|
|
|
288
290
|
建議操作順序:
|
|
289
291
|
|
|
@@ -297,32 +299,32 @@ code .
|
|
|
297
299
|
接著在 VS Code 的 AI 對話側邊欄輸入:
|
|
298
300
|
|
|
299
301
|
```text
|
|
300
|
-
spec:init
|
|
301
|
-
spec:propose
|
|
302
|
-
spec:analyze
|
|
303
|
-
spec:commit
|
|
302
|
+
spec:init # 或簡寫 sci
|
|
303
|
+
spec:propose # 或簡寫 scp
|
|
304
|
+
spec:analyze # 或簡寫 sca
|
|
305
|
+
spec:commit # 或簡寫 scc
|
|
304
306
|
```
|
|
305
307
|
|
|
306
308
|
如果你有安裝 prompts 或 slash commands,可以用對應的快捷指令;沒有安裝也可以直接手動輸入上面的文字指令。
|
|
307
309
|
|
|
308
310
|
## AI 工作流程
|
|
309
311
|
|
|
310
|
-
| 指令 | 用途 |
|
|
311
|
-
|
|
312
|
-
| `spec:init` | 初始化並載入 `AGENTS.md`、`skills/system-analysis/SKILL.md` 與必要規則。 |
|
|
313
|
-
| `spec:propose` | 使用者提出需求後,整理需求摘要、目標、初步流程與待確認事項。 |
|
|
314
|
-
| `spec:analyze` | 檢查是否與既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿。 |
|
|
315
|
-
| `spec:commit` | 使用者確認無衝突版本後,將版本歸檔到 `project/`,並建立本機 Git commit。 |
|
|
312
|
+
| 指令 | 簡寫 | 用途 |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| `spec:init` | `sci` | 初始化並載入 `AGENTS.md`、`skills/system-analysis/SKILL.md` 與必要規則。 |
|
|
315
|
+
| `spec:propose` | `scp` | 使用者提出需求後,整理需求摘要、目標、初步流程與待確認事項。 |
|
|
316
|
+
| `spec:analyze` | `sca` | 檢查是否與既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿。 |
|
|
317
|
+
| `spec:commit` | `scc` | 使用者確認無衝突版本後,將版本歸檔到 `project/`,並建立本機 Git commit。 |
|
|
316
318
|
|
|
317
319
|
狀態機:
|
|
318
320
|
|
|
319
321
|
```text
|
|
320
|
-
init -> propose -> analyze
|
|
322
|
+
init (sci) -> propose (scp) -> analyze (sca)
|
|
321
323
|
|
|
322
|
-
analyze 無衝突 -> 產出待確認版本 -> commit
|
|
323
|
-
analyze 有衝突 -> 釐清問題 -> analyze
|
|
324
|
+
analyze 無衝突 -> 產出待確認版本 -> commit (scc)
|
|
325
|
+
analyze 有衝突 -> 釐清問題 -> analyze (sca)
|
|
324
326
|
|
|
325
|
-
commit -> 歸檔 -> 本機 Git commit
|
|
327
|
+
commit (scc) -> 歸檔 -> 本機 Git commit
|
|
326
328
|
```
|
|
327
329
|
|
|
328
330
|
`spec:analyze` 若發現衝突,只會列出衝突與待釐清問題,不會修改任何需求文件,也不會產出最終文件。釐清後應再次執行 `spec:analyze`,重新檢查並產出草稿。
|
|
@@ -334,7 +336,7 @@ commit -> 歸檔 -> 本機 Git commit
|
|
|
334
336
|
```text
|
|
335
337
|
請先閱讀 project/REQ-001-pomodoro-timer/handoff.md。
|
|
336
338
|
以 handoff.md 作為本次開發入口與限制摘要。
|
|
337
|
-
如需完整需求細節,再查閱同資料夾內的 srs.md、uml
|
|
339
|
+
如需完整需求細節,再查閱同資料夾內的 srs.md、uml/、openapi.yaml、db-schema.md 與 history.md。
|
|
338
340
|
不得自行新增 handoff.md 未確認的角色、權限、流程、狀態、API 或 DB 欄位。
|
|
339
341
|
若發現 handoff.md 與既有程式或規格衝突,請停止開發並回報。
|
|
340
342
|
```
|
|
@@ -520,7 +522,8 @@ project/
|
|
|
520
522
|
system-spec.md
|
|
521
523
|
REQ-001-pomodoro-timer/
|
|
522
524
|
srs.md
|
|
523
|
-
uml
|
|
525
|
+
uml/
|
|
526
|
+
state.puml
|
|
524
527
|
openapi.yaml
|
|
525
528
|
db-schema.md
|
|
526
529
|
handoff.md
|
|
@@ -591,3 +594,28 @@ git push origin master
|
|
|
591
594
|
- `project/system-spec.md` 只能在 `spec:commit` 依使用者確認內容更新。
|
|
592
595
|
- `spec:commit` 會自動建立本機 Git commit;remote push 需使用者明確要求或啟用 auto-push。
|
|
593
596
|
- 一次最多問 3 個待確認問題,優先詢問會影響範圍、資料、權限、API、DB 或驗收的問題。
|
|
597
|
+
|
|
598
|
+
## 更新紀錄
|
|
599
|
+
|
|
600
|
+
### v0.1.3
|
|
601
|
+
- **支援指令簡寫別名(同時保留完整指令)**:
|
|
602
|
+
- `sci` = `spec:init`
|
|
603
|
+
- `scp` = `spec:propose`
|
|
604
|
+
- `sca` = `spec:analyze`
|
|
605
|
+
- `scc` = `spec:commit`
|
|
606
|
+
- 兩者完全等價,使用者可依輸入習慣自由選擇長指令或 3 字母縮寫。
|
|
607
|
+
|
|
608
|
+
### v0.1.2
|
|
609
|
+
- **新增 `sa-spec upgrade` 版本升級指令**:
|
|
610
|
+
- **工作區規則同步**:自動檢查並更新專案中的 `AGENTS.md`、`skills/system-analysis/SKILL.md` 以及 `rules/` 目錄下的規則文件至最新版本(自動保留既有的 memory context)。
|
|
611
|
+
- **既有需求自動遷移**:掃描 `project/REQ-*` 目錄,將舊版 `uml.puml` 自動重構移動為 `uml/main.puml`,並自動修復 `handoff.md` 中的來源引用路徑。
|
|
612
|
+
- **提供 `--dry-run` 模擬模式**:可加上 `--dry-run` 參數先行預覽哪些檔案會被更新或遷移,而不實際寫入檔案。
|
|
613
|
+
|
|
614
|
+
### v0.1.1
|
|
615
|
+
- **PlantUML 檔案架構重構(解決多圖渲染與預覽開不起來問題)**:
|
|
616
|
+
- **目錄化結構**:每個需求目錄下由原本單一檔案 `uml.puml` 改為 `uml/` 資料夾(預設提供 `uml/main.puml` 骨架)。
|
|
617
|
+
- **單檔單圖原則**:嚴格規範每個 `.puml` 檔案僅包含單一組 `@startuml` 與 `@enduml`,禁止在單一檔案內混放多張圖。
|
|
618
|
+
- **支援多面向拆分**:需求若涉及多個面向(如業務流程、循序互動、狀態轉換),必須拆分為獨立 `.puml` 檔案(例如 `uml/main.puml`、`uml/sequence.puml`、`uml/state.puml`),確保 PlantUML 預覽外掛能順暢開啟與渲染。
|
|
619
|
+
- **CLI 自動化**:`sa-spec new` 與 `sa-spec template req` 自動建立 `uml/` 資料夾並產出預設的 `uml/main.puml`。
|
|
620
|
+
- **全專案規範同步**:同步更新 `AGENTS.md`、`system-analysis` skill、`rules/uml-style.md`、`rules/file-style.md` 與 `handoff.md`。
|
|
621
|
+
|
package/src/cli.js
CHANGED
|
@@ -20,6 +20,9 @@ function main() {
|
|
|
20
20
|
case "check":
|
|
21
21
|
runCheck();
|
|
22
22
|
return;
|
|
23
|
+
case "upgrade":
|
|
24
|
+
upgradeProject(args.slice(1));
|
|
25
|
+
return;
|
|
23
26
|
case "doctor":
|
|
24
27
|
runDoctor();
|
|
25
28
|
return;
|
|
@@ -219,11 +222,13 @@ function createReqTemplate(args, label = "new") {
|
|
|
219
222
|
|
|
220
223
|
const slug = slugify(name);
|
|
221
224
|
const reqDir = path.join("project", `${id}-${slug}`);
|
|
225
|
+
const umlDir = path.join(reqDir, "uml");
|
|
222
226
|
const replacements = { REQ_ID: id, REQ_NAME: name };
|
|
223
227
|
const results = [
|
|
224
228
|
ensureDir(reqDir),
|
|
229
|
+
ensureDir(umlDir),
|
|
225
230
|
ensureFileFromTemplate(path.join("project", "req", "srs.md"), path.join(reqDir, "srs.md"), replacements),
|
|
226
|
-
ensureFileFromTemplate(path.join("project", "req", "uml.puml"), path.join(
|
|
231
|
+
ensureFileFromTemplate(path.join("project", "req", "uml", "main.puml"), path.join(umlDir, "main.puml"), replacements),
|
|
227
232
|
ensureFileFromTemplate(path.join("project", "req", "openapi.yaml"), path.join(reqDir, "openapi.yaml"), replacements),
|
|
228
233
|
ensureFileFromTemplate(path.join("project", "req", "db-schema.md"), path.join(reqDir, "db-schema.md"), replacements),
|
|
229
234
|
ensureFileFromTemplate(path.join("project", "req", "handoff.md"), path.join(reqDir, "handoff.md"), replacements),
|
|
@@ -336,10 +341,133 @@ function slugify(value) {
|
|
|
336
341
|
.replace(/^-+|-+$/g, "");
|
|
337
342
|
}
|
|
338
343
|
|
|
344
|
+
function upgradeProject(args = []) {
|
|
345
|
+
const dryRun = args.includes("--dry-run");
|
|
346
|
+
const results = [];
|
|
347
|
+
|
|
348
|
+
results.push(ensureDir("skills"));
|
|
349
|
+
results.push(ensureDir(path.join("skills", "system-analysis")));
|
|
350
|
+
|
|
351
|
+
results.push(updateFileFromTemplate("AGENTS.md", "AGENTS.md", dryRun));
|
|
352
|
+
results.push(
|
|
353
|
+
updateFileFromTemplate(
|
|
354
|
+
path.join("skills", "system-analysis", "SKILL.md"),
|
|
355
|
+
path.join("skills", "system-analysis", "SKILL.md"),
|
|
356
|
+
dryRun
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const rulesTargetDir = path.join(cwd, "rules");
|
|
361
|
+
if (fs.existsSync(rulesTargetDir)) {
|
|
362
|
+
const templateRulesDir = path.join(templatesDir, "rules");
|
|
363
|
+
for (const file of listFilesRecursive(templateRulesDir)) {
|
|
364
|
+
const relativePath = path.relative(templatesDir, file);
|
|
365
|
+
results.push(updateFileFromTemplate(relativePath, relativePath, dryRun));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const projectDir = path.join(cwd, "project");
|
|
370
|
+
if (fs.existsSync(projectDir)) {
|
|
371
|
+
const entries = fs.readdirSync(projectDir, { withFileTypes: true });
|
|
372
|
+
for (const entry of entries) {
|
|
373
|
+
if (entry.isDirectory() && entry.name.startsWith("REQ-")) {
|
|
374
|
+
const reqRelDir = path.join("project", entry.name);
|
|
375
|
+
const oldUmlRelPath = path.join(reqRelDir, "uml.puml");
|
|
376
|
+
const oldUmlAbsPath = path.join(cwd, oldUmlRelPath);
|
|
377
|
+
const newUmlRelDir = path.join(reqRelDir, "uml");
|
|
378
|
+
const newUmlAbsDir = path.join(cwd, newUmlRelDir);
|
|
379
|
+
const newMainUmlRelPath = path.join(newUmlRelDir, "main.puml");
|
|
380
|
+
const newMainUmlAbsPath = path.join(cwd, newMainUmlRelPath);
|
|
381
|
+
|
|
382
|
+
if (fs.existsSync(oldUmlAbsPath)) {
|
|
383
|
+
if (!fs.existsSync(newMainUmlAbsPath)) {
|
|
384
|
+
if (!dryRun) {
|
|
385
|
+
if (!fs.existsSync(newUmlAbsDir)) {
|
|
386
|
+
fs.mkdirSync(newUmlAbsDir, { recursive: true });
|
|
387
|
+
}
|
|
388
|
+
fs.renameSync(oldUmlAbsPath, newMainUmlAbsPath);
|
|
389
|
+
}
|
|
390
|
+
results.push({
|
|
391
|
+
action: "migrate",
|
|
392
|
+
target: `${oldUmlRelPath} -> ${newMainUmlRelPath}`
|
|
393
|
+
});
|
|
394
|
+
} else {
|
|
395
|
+
results.push({
|
|
396
|
+
action: "warn",
|
|
397
|
+
target: oldUmlRelPath,
|
|
398
|
+
message: `目標 ${newMainUmlRelPath} 已存在,請確認是否可手動移除舊檔。`
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const handoffRelPath = path.join(reqRelDir, "handoff.md");
|
|
404
|
+
const handoffAbsPath = path.join(cwd, handoffRelPath);
|
|
405
|
+
if (fs.existsSync(handoffAbsPath)) {
|
|
406
|
+
const content = fs.readFileSync(handoffAbsPath, "utf8");
|
|
407
|
+
if (content.includes("uml.puml")) {
|
|
408
|
+
if (!dryRun) {
|
|
409
|
+
fs.writeFileSync(handoffAbsPath, content.replace(/uml\.puml/g, "uml/"), "utf8");
|
|
410
|
+
}
|
|
411
|
+
results.push({
|
|
412
|
+
action: "update",
|
|
413
|
+
target: handoffRelPath,
|
|
414
|
+
message: "更新來源參照 uml.puml -> uml/"
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
printResultList(dryRun ? "upgrade (dry-run)" : "upgrade", results);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function updateFileFromTemplate(templateRelativePath, targetRelativePath, dryRun = false) {
|
|
426
|
+
const targetAbsolutePath = path.join(cwd, targetRelativePath);
|
|
427
|
+
const templateAbsolutePath = path.join(templatesDir, templateRelativePath);
|
|
428
|
+
if (!fs.existsSync(templateAbsolutePath)) {
|
|
429
|
+
return { action: "skip", target: targetRelativePath };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
let templateContent = readTemplate(templateRelativePath);
|
|
433
|
+
if (!fs.existsSync(targetAbsolutePath)) {
|
|
434
|
+
if (!dryRun) {
|
|
435
|
+
writeFileIfMissing(targetAbsolutePath, templateContent);
|
|
436
|
+
}
|
|
437
|
+
return { action: "create", target: targetRelativePath };
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const currentContent = fs.readFileSync(targetAbsolutePath, "utf8");
|
|
441
|
+
if (currentContent.includes("<claude-mem-context>")) {
|
|
442
|
+
const memMatch = currentContent.match(/(<claude-mem-context>[\s\S]*?<\/claude-mem-context>)/);
|
|
443
|
+
if (memMatch && !templateContent.includes("<claude-mem-context>")) {
|
|
444
|
+
templateContent = `${templateContent.trimEnd()}\n\n\n${memMatch[1]}\n`;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (currentContent.trim() === templateContent.trim()) {
|
|
449
|
+
return { action: "skip", target: targetRelativePath };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (!dryRun) {
|
|
453
|
+
fs.writeFileSync(targetAbsolutePath, templateContent, "utf8");
|
|
454
|
+
}
|
|
455
|
+
return { action: "update", target: targetRelativePath };
|
|
456
|
+
}
|
|
457
|
+
|
|
339
458
|
function printResultList(label, results) {
|
|
340
459
|
console.log(`sa-spec ${label}`);
|
|
341
460
|
for (const result of results) {
|
|
342
|
-
const action =
|
|
461
|
+
const action =
|
|
462
|
+
result.action === "create"
|
|
463
|
+
? "CREATED"
|
|
464
|
+
: result.action === "update"
|
|
465
|
+
? "UPDATED"
|
|
466
|
+
: result.action === "migrate"
|
|
467
|
+
? "MIGRATED"
|
|
468
|
+
: result.action === "warn"
|
|
469
|
+
? "WARNING"
|
|
470
|
+
: "SKIPPED";
|
|
343
471
|
console.log(`${action} ${result.target}${result.message ? ` - ${result.message}` : ""}`);
|
|
344
472
|
}
|
|
345
473
|
}
|
|
@@ -351,6 +479,7 @@ Usage:
|
|
|
351
479
|
sa-spec init [--full]
|
|
352
480
|
sa-spec new --id REQ-001 --name login
|
|
353
481
|
sa-spec check
|
|
482
|
+
sa-spec upgrade [--dry-run]
|
|
354
483
|
`);
|
|
355
484
|
}
|
|
356
485
|
|
package/templates/AGENTS.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
每個需求歸檔時固定包含:
|
|
8
8
|
|
|
9
9
|
- `srs.md`:需求規格。
|
|
10
|
-
- `uml.puml
|
|
10
|
+
- `uml/`:UML 圖目錄(依面向拆分為獨立 `.puml` 檔,如 `main.puml`、`sequence.puml` 等,禁止單檔混放多圖)。
|
|
11
11
|
- `openapi.yaml`:OpenAPI 草稿。
|
|
12
12
|
- `db-schema.md`:DB Schema 草稿。
|
|
13
13
|
- `handoff.md`:給 OpenSpec 或其他 AI 開發工具的開發交接摘要。
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
# 指令流程
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
使用四個指令,並支援簡寫別名(兩者等價):
|
|
19
19
|
|
|
20
|
-
| 指令 | 用途 | 規則 |
|
|
21
|
-
|
|
22
|
-
| `spec:init` | 初始化 | 載入並遵守 `AGENTS.md`、`skills/system-analysis/SKILL.md` 與必要規則,確認 `project/` 結構是否存在。 |
|
|
23
|
-
| `spec:propose` | 提出需求 | 使用者提出需求後,先整理需求摘要、目標、初步流程與待確認事項,不歸檔、不修改既有需求。 |
|
|
24
|
-
| `spec:analyze` | 分析與起草 | 先檢查新需求是否與 `project/` 內所有既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿;有衝突則只列出衝突與待釐清問題,待使用者釐清後再次執行 `spec:analyze
|
|
25
|
-
| `spec:commit` | 確認歸檔 | 只把使用者已確認的版本歸檔到該需求資料夾,更新 `project/index.md`、`project/system-spec.md` 與 `history.md`,並建立本機 Git commit。 |
|
|
20
|
+
| 指令 | 簡寫 | 用途 | 規則 |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| `spec:init` | `sci` | 初始化 | 載入並遵守 `AGENTS.md`、`skills/system-analysis/SKILL.md` 與必要規則,確認 `project/` 結構是否存在。 |
|
|
23
|
+
| `spec:propose` | `scp` | 提出需求 | 使用者提出需求後,先整理需求摘要、目標、初步流程與待確認事項,不歸檔、不修改既有需求。 |
|
|
24
|
+
| `spec:analyze` | `sca` | 分析與起草 | 先檢查新需求是否與 `project/` 內所有既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿;有衝突則只列出衝突與待釐清問題,待使用者釐清後再次執行 `spec:analyze`(或 `sca`)。 |
|
|
25
|
+
| `spec:commit` | `scc` | 確認歸檔 | 只把使用者已確認的版本歸檔到該需求資料夾,更新 `project/index.md`、`project/system-spec.md` 與 `history.md`,並建立本機 Git commit。 |
|
|
26
26
|
|
|
27
27
|
# 重要限制
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
- `spec:commit` 完成文件歸檔後,必須自動建立本機 Git commit;commit message 以需求編號與需求名稱為主,並加上簡短需求說明,格式為 `docs(REQ-001): 需求名稱 - 簡短需求說明`。
|
|
41
41
|
- `spec:commit` 只有在使用者明確要求推送 remote,或專案設定啟用 auto-push 時,才可執行 `git push`;push 失敗時只回報認證或網路問題,不得回滾已完成的文件歸檔與本機 commit。
|
|
42
42
|
- 文件未經使用者確認,不得標示為 `已審核`。
|
|
43
|
-
- `uml
|
|
43
|
+
- `uml/` 內的 UML 圖不限單一 UML 圖型;`spec:analyze` 必須依需求選擇最能說明流程、互動、狀態或資料關係的 UML 圖,例如活動圖、循序圖、使用案例圖、狀態圖或類別圖,不可為了固定格式硬產生活動圖。**嚴禁將多張圖混在同一個檔案中**,必須在需求資料夾下的 `uml/` 目錄拆分成獨立的 `.puml` 檔案(例如 `uml/main.puml`、`uml/sequence.puml`、`uml/state.puml`),且每個檔案只能包含一組 `@startuml` 與 `@enduml`,以避免 PlantUML 渲染或預覽失敗。
|
|
44
44
|
- 一次最多問 3 個待確認問題,優先詢問會影響範圍、資料、權限、API、DB 或驗收的問題。
|
|
45
45
|
|
|
46
46
|
# 衝突檢查重點
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
# 狀態機
|
|
68
68
|
|
|
69
69
|
```text
|
|
70
|
-
init -> propose -> analyze
|
|
70
|
+
init (sci) -> propose (scp) -> analyze (sca)
|
|
71
71
|
|
|
72
|
-
analyze 無衝突 -> 產出待確認版本 -> commit
|
|
73
|
-
analyze 有衝突 -> 釐清問題 -> analyze
|
|
72
|
+
analyze 無衝突 -> 產出待確認版本 -> commit (scc)
|
|
73
|
+
analyze 有衝突 -> 釐清問題 -> analyze (sca)
|
|
74
74
|
|
|
75
|
-
commit -> 歸檔 -> 本機 Git commit
|
|
75
|
+
commit (scc) -> 歸檔 -> 本機 Git commit
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
# 歸檔結構
|
|
@@ -82,7 +82,8 @@ project/
|
|
|
82
82
|
index.md
|
|
83
83
|
REQ-001-name/
|
|
84
84
|
srs.md
|
|
85
|
-
uml
|
|
85
|
+
uml/
|
|
86
|
+
main.puml
|
|
86
87
|
openapi.yaml
|
|
87
88
|
db-schema.md
|
|
88
89
|
handoff.md
|
package/templates/readme.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
`sa-spec` 是一個輕量的系統分析文件工作台,用固定流程把需求想法整理成可確認、可歸檔、可檢查的文件。
|
|
4
4
|
|
|
5
|
-
AI
|
|
5
|
+
AI 工作流只使用四個指令,並支援簡寫別名(兩者等價):
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
spec:
|
|
10
|
-
spec:
|
|
11
|
-
spec:
|
|
12
|
-
|
|
7
|
+
| 標準指令 | 簡寫 | 說明 |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `spec:init` | `sci` | 初始化專案與規則 |
|
|
10
|
+
| `spec:propose` | `scp` | 提出需求並整理摘要 |
|
|
11
|
+
| `spec:analyze` | `sca` | 衝突檢查與規格起草 |
|
|
12
|
+
| `spec:commit` | `scc` | 確認歸檔並建立 Git commit |
|
|
13
13
|
|
|
14
14
|
每個需求歸檔後固定包含:
|
|
15
15
|
|
|
@@ -17,7 +17,8 @@ spec:commit
|
|
|
17
17
|
project/
|
|
18
18
|
REQ-001-login/
|
|
19
19
|
srs.md
|
|
20
|
-
uml
|
|
20
|
+
uml/
|
|
21
|
+
main.puml
|
|
21
22
|
openapi.yaml
|
|
22
23
|
db-schema.md
|
|
23
24
|
handoff.md
|
|
@@ -240,6 +241,7 @@ sa-spec init --full
|
|
|
240
241
|
| `sa-spec check` | 檢查基本文件是否存在。 |
|
|
241
242
|
| `sa-spec status` | 顯示系統規格與需求索引狀態。 |
|
|
242
243
|
| `sa-spec doctor` | 檢查必要檔案是否存在。 |
|
|
244
|
+
| `sa-spec upgrade [--dry-run]` | 將既有專案升級為最新版本:同步最新 AGENTS 與規則文件,並將既有需求中的 `uml.puml` 自動遷移為 `uml/main.puml`。 |
|
|
243
245
|
|
|
244
246
|
`sa-spec new` 是快速建空白模板的輔助工具。正式需求流程仍建議使用 `spec:init`、`spec:propose`、`spec:analyze`、`spec:commit`。
|
|
245
247
|
|
|
@@ -259,7 +261,7 @@ sa-spec init --full
|
|
|
259
261
|
| AI 對話 | Claude Code 類型的 VS Code AI 套件或 CLI 整合 | 擇一 | 用 Claude 讀取工作區規則並協作產出需求文件。 |
|
|
260
262
|
| AI 對話 | Gemini 類型的 VS Code AI 套件或 CLI 整合 | 擇一 | 用 Gemini 讀取工作區規則並協作產出需求文件。 |
|
|
261
263
|
| Markdown | Markdown 預覽或 Markdown All in One 類型套件 | 選用 | 預覽 `srs.md`、`history.md`、`system-spec.md`。 |
|
|
262
|
-
| UML | PlantUML 類型套件 | 選用 |
|
|
264
|
+
| UML | PlantUML 類型套件 | 選用 | 預覽需求內的 `uml/*.puml`。 |
|
|
263
265
|
| YAML | YAML 類型套件 | 選用 | 編輯與檢查 `openapi.yaml`。 |
|
|
264
266
|
| Git | GitLens 類型套件 | 選用 | 查看需求文件修改歷程。 |
|
|
265
267
|
|
|
@@ -280,10 +282,10 @@ Markdown、PlantUML、YAML、GitLens 這類套件可以提升閱讀與檢查體
|
|
|
280
282
|
| CLI | `sa-spec init --full` | 終端機或 VS Code Terminal | 建立文件骨架與規則檔。 |
|
|
281
283
|
| CLI | `sa-spec check` | 終端機或 VS Code Terminal | 檢查必要文件是否存在。 |
|
|
282
284
|
| CLI | `sa-spec status` | 終端機或 VS Code Terminal | 查看系統規格與需求索引狀態。 |
|
|
283
|
-
| AI 工作流程 | `spec:init` | VS Code AI 對話側邊欄 | 載入規則並確認工作區狀態。 |
|
|
284
|
-
| AI 工作流程 | `spec:propose` | VS Code AI 對話側邊欄 | 整理使用者提出的需求。 |
|
|
285
|
-
| AI 工作流程 | `spec:analyze` | VS Code AI 對話側邊欄 | 檢查衝突並產出待確認草稿。 |
|
|
286
|
-
| AI 工作流程 | `spec:commit` | VS Code AI 對話側邊欄 | 歸檔已確認版本並建立本機 Git commit。 |
|
|
285
|
+
| AI 工作流程 | `spec:init` / `sci` | VS Code AI 對話側邊欄 | 載入規則並確認工作區狀態。 |
|
|
286
|
+
| AI 工作流程 | `spec:propose` / `scp` | VS Code AI 對話側邊欄 | 整理使用者提出的需求。 |
|
|
287
|
+
| AI 工作流程 | `spec:analyze` / `sca` | VS Code AI 對話側邊欄 | 檢查衝突並產出待確認草稿。 |
|
|
288
|
+
| AI 工作流程 | `spec:commit` / `scc` | VS Code AI 對話側邊欄 | 歸檔已確認版本並建立本機 Git commit。 |
|
|
287
289
|
|
|
288
290
|
建議操作順序:
|
|
289
291
|
|
|
@@ -297,32 +299,32 @@ code .
|
|
|
297
299
|
接著在 VS Code 的 AI 對話側邊欄輸入:
|
|
298
300
|
|
|
299
301
|
```text
|
|
300
|
-
spec:init
|
|
301
|
-
spec:propose
|
|
302
|
-
spec:analyze
|
|
303
|
-
spec:commit
|
|
302
|
+
spec:init # 或簡寫 sci
|
|
303
|
+
spec:propose # 或簡寫 scp
|
|
304
|
+
spec:analyze # 或簡寫 sca
|
|
305
|
+
spec:commit # 或簡寫 scc
|
|
304
306
|
```
|
|
305
307
|
|
|
306
308
|
如果你有安裝 prompts 或 slash commands,可以用對應的快捷指令;沒有安裝也可以直接手動輸入上面的文字指令。
|
|
307
309
|
|
|
308
310
|
## AI 工作流程
|
|
309
311
|
|
|
310
|
-
| 指令 | 用途 |
|
|
311
|
-
|
|
312
|
-
| `spec:init` | 初始化並載入 `AGENTS.md`、`skills/system-analysis/SKILL.md` 與必要規則。 |
|
|
313
|
-
| `spec:propose` | 使用者提出需求後,整理需求摘要、目標、初步流程與待確認事項。 |
|
|
314
|
-
| `spec:analyze` | 檢查是否與既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿。 |
|
|
315
|
-
| `spec:commit` | 使用者確認無衝突版本後,將版本歸檔到 `project/`,並建立本機 Git commit。 |
|
|
312
|
+
| 指令 | 簡寫 | 用途 |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| `spec:init` | `sci` | 初始化並載入 `AGENTS.md`、`skills/system-analysis/SKILL.md` 與必要規則。 |
|
|
315
|
+
| `spec:propose` | `scp` | 使用者提出需求後,整理需求摘要、目標、初步流程與待確認事項。 |
|
|
316
|
+
| `spec:analyze` | `sca` | 檢查是否與既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿。 |
|
|
317
|
+
| `spec:commit` | `scc` | 使用者確認無衝突版本後,將版本歸檔到 `project/`,並建立本機 Git commit。 |
|
|
316
318
|
|
|
317
319
|
狀態機:
|
|
318
320
|
|
|
319
321
|
```text
|
|
320
|
-
init -> propose -> analyze
|
|
322
|
+
init (sci) -> propose (scp) -> analyze (sca)
|
|
321
323
|
|
|
322
|
-
analyze 無衝突 -> 產出待確認版本 -> commit
|
|
323
|
-
analyze 有衝突 -> 釐清問題 -> analyze
|
|
324
|
+
analyze 無衝突 -> 產出待確認版本 -> commit (scc)
|
|
325
|
+
analyze 有衝突 -> 釐清問題 -> analyze (sca)
|
|
324
326
|
|
|
325
|
-
commit -> 歸檔 -> 本機 Git commit
|
|
327
|
+
commit (scc) -> 歸檔 -> 本機 Git commit
|
|
326
328
|
```
|
|
327
329
|
|
|
328
330
|
`spec:analyze` 若發現衝突,只會列出衝突與待釐清問題,不會修改任何需求文件,也不會產出最終文件。釐清後應再次執行 `spec:analyze`,重新檢查並產出草稿。
|
|
@@ -334,7 +336,7 @@ commit -> 歸檔 -> 本機 Git commit
|
|
|
334
336
|
```text
|
|
335
337
|
請先閱讀 project/REQ-001-pomodoro-timer/handoff.md。
|
|
336
338
|
以 handoff.md 作為本次開發入口與限制摘要。
|
|
337
|
-
如需完整需求細節,再查閱同資料夾內的 srs.md、uml
|
|
339
|
+
如需完整需求細節,再查閱同資料夾內的 srs.md、uml/、openapi.yaml、db-schema.md 與 history.md。
|
|
338
340
|
不得自行新增 handoff.md 未確認的角色、權限、流程、狀態、API 或 DB 欄位。
|
|
339
341
|
若發現 handoff.md 與既有程式或規格衝突,請停止開發並回報。
|
|
340
342
|
```
|
|
@@ -520,7 +522,8 @@ project/
|
|
|
520
522
|
system-spec.md
|
|
521
523
|
REQ-001-pomodoro-timer/
|
|
522
524
|
srs.md
|
|
523
|
-
uml
|
|
525
|
+
uml/
|
|
526
|
+
state.puml
|
|
524
527
|
openapi.yaml
|
|
525
528
|
db-schema.md
|
|
526
529
|
handoff.md
|
|
@@ -591,3 +594,28 @@ git push origin master
|
|
|
591
594
|
- `project/system-spec.md` 只能在 `spec:commit` 依使用者確認內容更新。
|
|
592
595
|
- `spec:commit` 會自動建立本機 Git commit;remote push 需使用者明確要求或啟用 auto-push。
|
|
593
596
|
- 一次最多問 3 個待確認問題,優先詢問會影響範圍、資料、權限、API、DB 或驗收的問題。
|
|
597
|
+
|
|
598
|
+
## 更新紀錄
|
|
599
|
+
|
|
600
|
+
### v0.1.3
|
|
601
|
+
- **支援指令簡寫別名(同時保留完整指令)**:
|
|
602
|
+
- `sci` = `spec:init`
|
|
603
|
+
- `scp` = `spec:propose`
|
|
604
|
+
- `sca` = `spec:analyze`
|
|
605
|
+
- `scc` = `spec:commit`
|
|
606
|
+
- 兩者完全等價,使用者可依輸入習慣自由選擇長指令或 3 字母縮寫。
|
|
607
|
+
|
|
608
|
+
### v0.1.2
|
|
609
|
+
- **新增 `sa-spec upgrade` 版本升級指令**:
|
|
610
|
+
- **工作區規則同步**:自動檢查並更新專案中的 `AGENTS.md`、`skills/system-analysis/SKILL.md` 以及 `rules/` 目錄下的規則文件至最新版本(自動保留既有的 memory context)。
|
|
611
|
+
- **既有需求自動遷移**:掃描 `project/REQ-*` 目錄,將舊版 `uml.puml` 自動重構移動為 `uml/main.puml`,並自動修復 `handoff.md` 中的來源引用路徑。
|
|
612
|
+
- **提供 `--dry-run` 模擬模式**:可加上 `--dry-run` 參數先行預覽哪些檔案會被更新或遷移,而不實際寫入檔案。
|
|
613
|
+
|
|
614
|
+
### v0.1.1
|
|
615
|
+
- **PlantUML 檔案架構重構(解決多圖渲染與預覽開不起來問題)**:
|
|
616
|
+
- **目錄化結構**:每個需求目錄下由原本單一檔案 `uml.puml` 改為 `uml/` 資料夾(預設提供 `uml/main.puml` 骨架)。
|
|
617
|
+
- **單檔單圖原則**:嚴格規範每個 `.puml` 檔案僅包含單一組 `@startuml` 與 `@enduml`,禁止在單一檔案內混放多張圖。
|
|
618
|
+
- **支援多面向拆分**:需求若涉及多個面向(如業務流程、循序互動、狀態轉換),必須拆分為獨立 `.puml` 檔案(例如 `uml/main.puml`、`uml/sequence.puml`、`uml/state.puml`),確保 PlantUML 預覽外掛能順暢開啟與渲染。
|
|
619
|
+
- **CLI 自動化**:`sa-spec new` 與 `sa-spec template req` 自動建立 `uml/` 資料夾並產出預設的 `uml/main.puml`。
|
|
620
|
+
- **全專案規範同步**:同步更新 `AGENTS.md`、`system-analysis` skill、`rules/uml-style.md`、`rules/file-style.md` 與 `handoff.md`。
|
|
621
|
+
|
|
@@ -20,12 +20,11 @@
|
|
|
20
20
|
- 每個需求資料夾至少包含:
|
|
21
21
|
- `srs.md`:需求規格。
|
|
22
22
|
- `history.md`:需求歷程。
|
|
23
|
-
- `uml.puml
|
|
23
|
+
- `uml/`:UML 圖目錄,依面向拆分為獨立 `.puml` 檔(如 `main.puml`、`sequence.puml` 等,單檔單圖,禁止單檔混放多圖)。
|
|
24
24
|
- `openapi.yaml`:OpenAPI 草稿。
|
|
25
25
|
- `db-schema.md`:DB Schema 草稿。
|
|
26
26
|
- `handoff.md`:給 OpenSpec 或其他 AI 開發工具的開發交接摘要。
|
|
27
27
|
- 若需求涉及畫面,使用 `wireframe.md`。
|
|
28
|
-
- 若需求需要 UML,放入 `uml/` 資料夾。
|
|
29
28
|
- 若需求需要 API 或資料模型,使用 `api.md` 或獨立資料模型文件。
|
|
30
29
|
- 若需求需要 DB Table 設計,使用 `db-table.md`。
|
|
31
30
|
|
|
@@ -37,13 +36,12 @@ project/
|
|
|
37
36
|
srs.md
|
|
38
37
|
wireframe.md
|
|
39
38
|
history.md
|
|
40
|
-
uml
|
|
39
|
+
uml/
|
|
40
|
+
main.puml
|
|
41
|
+
sequence.puml
|
|
41
42
|
openapi.yaml
|
|
42
43
|
db-schema.md
|
|
43
44
|
handoff.md
|
|
44
|
-
uml/
|
|
45
|
-
use-case.puml
|
|
46
|
-
sequence.puml
|
|
47
45
|
api.md
|
|
48
46
|
db-table.md
|
|
49
47
|
```
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## 格式
|
|
4
4
|
- UML 圖一律使用 PlantUML。
|
|
5
|
-
- PlantUML 檔案副檔名使用 `.puml
|
|
5
|
+
- PlantUML 檔案副檔名使用 `.puml`,放置於需求的 `uml/` 資料夾中(例如 `uml/main.puml`、`uml/sequence.puml`)。
|
|
6
|
+
- **嚴禁將多張圖混在同一個檔案中**:每個 `.puml` 檔案僅能包含單一組 `@startuml` 與 `@enduml`,避免 PlantUML 預覽或渲染工具解析失敗或無法開啟。
|
|
7
|
+
- 若需求涉及多個面向(例如業務流程、循序互動、狀態轉換),必須依圖型或面向拆分成獨立的 `.puml` 檔案。
|
|
6
8
|
- 圖表內容以繁體中文描述,並採用台灣常用語。
|
|
7
9
|
|
|
8
10
|
## 限制
|
|
@@ -10,6 +12,7 @@
|
|
|
10
12
|
- 不明確的部分必須標示為「待確認」,並回到人工審核。
|
|
11
13
|
- UML 必須能追溯到對應需求編號。
|
|
12
14
|
- UML 內容不得超出已確認或已標示假設的需求範圍。
|
|
15
|
+
- 單張圖應保持精簡清晰,避免過度龐大或單一圖節點過多導致渲染失敗。
|
|
13
16
|
|
|
14
17
|
## 圖表類型
|
|
15
18
|
- Use Case Diagram:用於描述使用者、外部系統與系統功能邊界。
|
|
@@ -8,7 +8,7 @@ description: 用 init、propose、analyze、commit 四段流程整理需求,
|
|
|
8
8
|
## 核心交付物
|
|
9
9
|
|
|
10
10
|
- `srs.md`:需求規格。
|
|
11
|
-
- `uml.puml
|
|
11
|
+
- `uml/`:UML 圖目錄(依面向拆分為獨立 `.puml` 檔,如 `main.puml`、`sequence.puml` 等,禁止單檔混放多圖)。
|
|
12
12
|
- `openapi.yaml`:OpenAPI 草稿。
|
|
13
13
|
- `db-schema.md`:DB Schema 草稿。
|
|
14
14
|
- `handoff.md`:給 OpenSpec 或其他 AI 開發工具的開發交接摘要。
|
|
@@ -16,12 +16,14 @@ description: 用 init、propose、analyze、commit 四段流程整理需求,
|
|
|
16
16
|
|
|
17
17
|
## 指令流程
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
23
|
-
| `spec:
|
|
24
|
-
| `spec:
|
|
19
|
+
使用四個核心指令,並支援簡寫別名(兩者等價):
|
|
20
|
+
|
|
21
|
+
| 指令 | 簡寫 | 用途 | 執行規則 |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| `spec:init` | `sci` | 初始化 | 載入並遵守 `AGENTS.md`、本 skill 與必要規則,確認 `project/` 結構是否存在。 |
|
|
24
|
+
| `spec:propose` | `scp` | 提出需求 | 整理使用者需求為摘要、目標、初步流程與待確認事項;不歸檔、不修改既有需求。 |
|
|
25
|
+
| `spec:analyze` | `sca` | 分析與起草 | 先檢查新需求是否與 `project/` 內所有既有需求衝突;無衝突才產出 SRS、UML、OpenAPI、DB Schema 草稿;有衝突則只列出衝突與待釐清問題,待使用者釐清後再次執行 `spec:analyze`(或 `sca`)。 |
|
|
26
|
+
| `spec:commit` | `scc` | 確認歸檔 | 只把使用者已確認的版本歸檔到該需求資料夾,更新 `project/index.md`、`project/system-spec.md` 與 `history.md`,並建立本機 Git commit。 |
|
|
25
27
|
|
|
26
28
|
## 硬性限制
|
|
27
29
|
|
|
@@ -42,7 +44,7 @@ description: 用 init、propose、analyze、commit 四段流程整理需求,
|
|
|
42
44
|
- `spec:commit` 完成文件歸檔後,必須自動建立本機 Git commit;commit message 以需求編號與需求名稱為主,並加上簡短需求說明,格式為 `docs(REQ-001): 需求名稱 - 簡短需求說明`。
|
|
43
45
|
- `spec:commit` 只有在使用者明確要求推送 remote,或專案設定啟用 auto-push 時,才可執行 `git push`;push 失敗時只回報認證或網路問題,不得回滾已完成的文件歸檔與本機 commit。
|
|
44
46
|
- 文件未經使用者確認,不得標示為 `已審核`。
|
|
45
|
-
- `uml
|
|
47
|
+
- `uml/` 內的 UML 圖不限單一 UML 圖型;`spec:analyze` 必須依需求選擇最能說明流程、互動、狀態或資料關係的 UML 圖,例如活動圖、循序圖、使用案例圖、狀態圖或類別圖,不可為了固定格式硬產生活動圖。**嚴禁將多張圖混在同一個檔案中**,必須在需求資料夾下的 `uml/` 目錄拆分成獨立的 `.puml` 檔案(例如 `uml/main.puml`、`uml/sequence.puml`、`uml/state.puml`),且每個檔案只能包含一組 `@startuml` 與 `@enduml`,以避免 PlantUML 渲染或預覽失敗。
|
|
46
48
|
- 一次最多問 3 個待確認問題,優先詢問會影響範圍、資料、權限、API、DB 或驗收的問題。
|
|
47
49
|
|
|
48
50
|
## analyze 衝突檢查
|
|
@@ -55,7 +57,7 @@ description: 用 init、propose、analyze、commit 四段流程整理需求,
|
|
|
55
57
|
- 所有 `project/REQ-*/openapi.yaml`
|
|
56
58
|
- 所有 `project/REQ-*/db-schema.md`
|
|
57
59
|
- 所有 `project/REQ-*/handoff.md`
|
|
58
|
-
- 必要時讀取 `project/REQ-*/uml
|
|
60
|
+
- 必要時讀取 `project/REQ-*/uml/*.puml`
|
|
59
61
|
|
|
60
62
|
至少檢查:
|
|
61
63
|
|
|
@@ -81,7 +83,7 @@ description: 用 init、propose、analyze、commit 四段流程整理需求,
|
|
|
81
83
|
無衝突時,輸出一個待確認版本,包含:
|
|
82
84
|
|
|
83
85
|
- SRS 草稿。
|
|
84
|
-
- UML PlantUML
|
|
86
|
+
- UML PlantUML 草稿(放置於 `uml/` 資料夾中,每張圖獨立檔案)。
|
|
85
87
|
- OpenAPI YAML 草稿。
|
|
86
88
|
- DB Schema 草稿。
|
|
87
89
|
- Handoff 交接摘要草稿。
|
|
@@ -97,7 +99,8 @@ description: 用 init、propose、analyze、commit 四段流程整理需求,
|
|
|
97
99
|
project/
|
|
98
100
|
REQ-001-name/
|
|
99
101
|
srs.md
|
|
100
|
-
uml
|
|
102
|
+
uml/
|
|
103
|
+
main.puml
|
|
101
104
|
openapi.yaml
|
|
102
105
|
db-schema.md
|
|
103
106
|
handoff.md
|
|
@@ -119,7 +122,7 @@ project/
|
|
|
119
122
|
|
|
120
123
|
若需求不需要 API 或 DB,必須明確標示「無 API 需求」或「無 DB 需求」。不得在 `handoff.md` 中新增未經使用者確認的角色、權限、資料、流程、狀態、API 或 DB 欄位。
|
|
121
124
|
|
|
122
|
-
交給 OpenSpec 或其他 AI 開發工具時,應要求它先閱讀 `handoff.md`,並以 `handoff.md` 作為本次開發入口與限制摘要。若需要完整細節,再查閱同需求資料夾內的 `srs.md`、`uml
|
|
125
|
+
交給 OpenSpec 或其他 AI 開發工具時,應要求它先閱讀 `handoff.md`,並以 `handoff.md` 作為本次開發入口與限制摘要。若需要完整細節,再查閱同需求資料夾內的 `srs.md`、`uml/`、`openapi.yaml`、`db-schema.md` 與 `history.md`。
|
|
123
126
|
|
|
124
127
|
歸檔完成後,必須只 stage 本次歸檔相關檔案,並建立本機 Git commit。commit message 格式:
|
|
125
128
|
|
|
@@ -132,10 +135,10 @@ docs(REQ-001): 需求名稱 - 簡短需求說明
|
|
|
132
135
|
## 狀態機
|
|
133
136
|
|
|
134
137
|
```text
|
|
135
|
-
init -> propose -> analyze
|
|
138
|
+
init (sci) -> propose (scp) -> analyze (sca)
|
|
136
139
|
|
|
137
|
-
analyze 無衝突 -> 產出待確認版本 -> commit
|
|
138
|
-
analyze 有衝突 -> 釐清問題 -> analyze
|
|
140
|
+
analyze 無衝突 -> 產出待確認版本 -> commit (scc)
|
|
141
|
+
analyze 有衝突 -> 釐清問題 -> analyze (sca)
|
|
139
142
|
|
|
140
|
-
commit -> 歸檔 -> 本機 Git commit
|
|
143
|
+
commit (scc) -> 歸檔 -> 本機 Git commit
|
|
141
144
|
```
|