spec-lite 1.3.1 → 1.3.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-lite",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Spec-driven development kit for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,12 +52,32 @@ Skill detect từng frd hiện tại thuộc "era" nào và apply vectors tươn
52
52
  | **V5 US/AC stability notes** | Section User Stories thiếu chuỗi "ID stable" | Insert 2 dòng note | None |
53
53
  | **V6 VR section** | Không có heading `## Verification Rules` | Propose VR table từ User Stories → user approve → insert | Medium |
54
54
  | **V7 Components Used location** | Section `## Components Consumed` đứng riêng (era pre-84d7303) | Move xuống `## Dependencies` thành subsection `### Components Used` | Low |
55
- | **V8 User Flows missing** | Không có heading `## User Flows` (era pre-84d7303) | Insert section placeholder với `<!-- TODO: BA fill in flows -->`. **KHÔNG tự sinh flow.** | None |
55
+ | **V8 User Flows missing** | Không có heading `## User Flows` (era pre-84d7303) | Derive Mermaid flows từ User Stories propose user approve insert. 1 flow / nhóm US liên quan theo journey logic. | Medium |
56
56
 
57
57
  ---
58
58
 
59
59
  ## Process
60
60
 
61
+ ### Bước 0: Pre-flight — working tree clean
62
+
63
+ Chạy `git status --porcelain`. Nếu output không rỗng (có file modified / untracked / staged):
64
+
65
+ ```
66
+ ⛔ Working tree không clean. Skill không tạo file backup `.bak` — rollback dựa vào git.
67
+ Hãy commit hoặc stash thay đổi hiện tại trước khi chạy `/spec-frd-update`, rồi chạy lại.
68
+
69
+ Files dirty:
70
+ M specs/main/feature/F-001-auth/frd.md
71
+ ?? notes.md
72
+ ```
73
+
74
+ Dừng hoàn toàn. Skill chỉ proceed khi `git status` clean — đảm bảo mọi change sau đó đều thuộc migration, dễ revert bằng `git checkout -- {path}` hoặc `git restore`.
75
+
76
+ Nếu repo không phải git repo → cảnh báo và yêu cầu confirm:
77
+ > ⚠ Thư mục này không phải git repo. Skill không tạo file backup. Nếu apply sai, không thể rollback. Tiếp tục? (yes / no — default no)
78
+
79
+ ---
80
+
61
81
  ### Bước 1: Discover & classify
62
82
 
63
83
  Quét `specs/main/feature/*/frd.md`. Với mỗi file:
@@ -116,7 +136,7 @@ Với mỗi FRD đã chọn, load các file sau (chỉ những gì cần thiết
116
136
 
117
137
  ---
118
138
 
119
- ### Bước 3: Apply mechanical vectors (V1, V2, V3, V5, V7, V8)
139
+ ### Bước 3: Apply mechanical vectors (V1, V2, V3, V5, V7)
120
140
 
121
141
  Đây là các vector **không cần model reasoning** — pure text manipulation. Apply tuần tự, không hỏi user.
122
142
 
@@ -143,12 +163,6 @@ Với mỗi FRD đã chọn, load các file sau (chỉ những gì cần thiết
143
163
  - Cắt nội dung bảng, xóa heading.
144
164
  - Trong `## Dependencies`, ensure có 2 subsections: `### Feature Dependencies` (giữ bảng cũ nếu có) và `### Components Used` (chèn bảng vừa cắt).
145
165
 
146
- #### V8 — User Flows placeholder
147
- - Sau `## Overview`, insert:
148
- > ## User Flows
149
- >
150
- > <!-- TODO: BA fill in flows. KHÔNG tự sinh — flow là decision của product, không derive được từ AC. -->
151
-
152
166
  ---
153
167
 
154
168
  ### Bước 4: V4 — AC → FAC renumber với cascade
@@ -244,7 +258,66 @@ Apply? (yes / edit / skip-vr)
244
258
 
245
259
  ---
246
260
 
247
- ### Bước 6: Validate
261
+ ### Bước 6: V8 — Derive User Flows section
262
+
263
+ **Run nếu V8 detected.** Propose-then-approve giống V6 — model derive draft, user duyệt trước khi ghi.
264
+
265
+ #### 6.1 Load minimal context
266
+ - Section `## Overview` của FRD (framing scope + actors).
267
+ - Section `## User Stories` (đã chứa AC — source của journey steps).
268
+
269
+ **KHÔNG load:** code, fdd.md, tech.md, sequence diagrams hiện có. Mục đích: flow ở frd là **user-facing journey** (WHAT), không phải implementation sequence (HOW thuộc fdd).
270
+
271
+ #### 6.2 Derive flows
272
+ Nhóm User Stories theo journey logic, mỗi journey → 1 Mermaid flowchart:
273
+
274
+ - **Grouping rule:** US chia sẻ chung trigger / actor / postcondition → cùng 1 flow. Vd `US-001 Đăng ký` + `US-002 Xác thực email` → 1 flow "Onboarding"; còn `US-003 Reset password` là journey riêng.
275
+ - **Mermaid structure:**
276
+ - Start node = trigger (user action mở đầu, từ Given của AC đầu tiên).
277
+ - Decision nodes = branch từ AC (happy / error paths).
278
+ - End node = postcondition (từ Then của AC cuối).
279
+ - Edge label = user action hoặc system response (từ When / Then).
280
+ - **Naming:** `Flow {N}: {tên ngắn}` — N đánh số từ 1 theo thứ tự xuất hiện trong frd.
281
+ - **Mermaid syntax:** dùng `["..."]` chứ KHÔNG `[{...}]` (V1 convention).
282
+
283
+ #### 6.3 Propose & approve
284
+
285
+ Hiển thị draft full mermaid blocks (chưa ghi file):
286
+
287
+ ```
288
+ Proposed User Flows for F-001:
289
+
290
+ Flow 1: Onboarding (đăng ký + xác thực email)
291
+ Spans: US-F001-001, US-F001-002
292
+ ```mermaid
293
+ flowchart TD
294
+ A["User mở trang Sign up"] --> B["Nhập email + password"]
295
+ B --> C{"Validation pass?"}
296
+ C -->|yes| D["Gửi email xác thực"]
297
+ C -->|no| E["Hiển thị lỗi"]
298
+ D --> F["User click link trong email"]
299
+ F --> G["Account active"]
300
+ ```
301
+
302
+ Flow 2: Login
303
+ Spans: US-F001-003
304
+ ```mermaid
305
+ ...
306
+ ```
307
+
308
+ Apply? (yes / edit / skip-flows)
309
+ yes → insert vào frd.md
310
+ edit → user góp ý flow nào cần sửa (vd: "Flow 1 thiếu nhánh email đã tồn tại")
311
+ skip-flows → giữ FRD không có User Flows section
312
+ ```
313
+
314
+ #### 6.4 Insert
315
+ - Insert section `## User Flows` ngay sau `## Overview` (theo thứ tự template).
316
+ - Copy intro + **Flow numbering stable** note (V2 convention) từ template, sau đó list các Mermaid blocks theo flow numbering.
317
+
318
+ ---
319
+
320
+ ### Bước 7: Validate
248
321
 
249
322
  Sau khi apply hết vectors cho một FRD, chạy check:
250
323
 
@@ -256,25 +329,25 @@ Sau khi apply hết vectors cho một FRD, chạy check:
256
329
  - [ ] VR Rule column không chứa keyword UI copy: "error message", "vui lòng", "hint", "tooltip"
257
330
  - [ ] Frontmatter `referenced_by` trỏ tới `3.3 Feature level` (không phải `3.2`)
258
331
 
259
- Nếu check fail → rollback bằng cách restore từ backup `.bak.{timestamp}` (skill tạo backup trước khi modify mỗi file).
332
+ Nếu check fail → rollback bằng `git checkout -- {file}` (skill không tạo backup vật lý vì git history đã đảm nhận vai trò này). Yêu cầu working tree clean trước khi chạy skill — nếu dirty, skill báo lỗi và dừng để tránh trộn lẫn change của user với change của migration.
260
333
 
261
334
  ---
262
335
 
263
- ### Bước 7: Report + changelog
336
+ ### Bước 8: Report + changelog
264
337
 
265
338
  Cho mỗi FRD đã migrate:
266
339
 
267
340
  ```
268
341
  ✓ F-001 — auth
269
- Vectors applied: V1, V3, V4 (3 IDs remapped), V5, V6 (8 VRs added)
342
+ Vectors applied: V1, V3, V4 (3 IDs remapped), V5, V6 (8 VRs added), V8 (2 flows added)
270
343
  Cascade: fdd.md (3 refs), tsd.md (5 refs), integrations/003 (3 refs)
271
- Backup: frd.md.bak.20260519-1430
272
344
 
273
345
  ✓ F-002 — checkout
274
346
  Vectors applied: V5, V6 (5 VRs added)
275
- Backup: frd.md.bak.20260519-1430
276
347
  ```
277
348
 
349
+ Rollback (nếu user phát hiện sai sau khi skill xong): `git checkout -- specs/main/feature/{F-XXX}-{slug}/` để revert toàn bộ feature dir, hoặc `git restore -p` để revert per-hunk.
350
+
278
351
  Append vào [changelogs.md](../../changelogs.md) `## [Unreleased]`:
279
352
 
280
353
  ```
@@ -290,13 +363,15 @@ Append vào [changelogs.md](../../changelogs.md) `## [Unreleased]`:
290
363
  | "Format mới optional, frd cũ vẫn dùng được" | Đúng cho đọc thủ công. Nhưng `/spec-test` và `/spec-tsd` derive TC theo IDs FAC/VR — frd thiếu sẽ break derivation, fallback bằng placeholder không trace được. |
291
364
  | "Tự sinh VR an toàn, model giỏi infer constraint" | Model dễ bịa rule không có trong AC ("password tối thiểu 12 ký tự" khi AC chỉ nói "password hợp lệ"). Luôn propose-then-approve, không auto-apply. |
292
365
  | "Skip cascade, chỉ rename trong frd thôi" | Sẽ break tsd.md Traceability Matrix và test.md Coverage. Hoặc cascade full, hoặc skip V4 toàn bộ. |
293
- | "Migrate batch tất cả cùng lúc cho nhanh" | V4 cascade dễ break — user cần xem diff per-feature. Batch mode chỉ áp dụng cho V1-V3, V5, V7, V8 (mechanical, low risk). |
366
+ | "Migrate batch tất cả cùng lúc cho nhanh" | V4 cascade dễ break — user cần xem diff per-feature. Batch mode chỉ áp dụng cho V1, V2, V3, V5, V7 (mechanical, low risk). V6 và V8 phải propose-then-approve. |
294
367
 
295
368
  ## Red Flags
296
369
 
297
370
  - Apply V4 không có dry-run preview → user không kịp catch cascade reference sai.
298
371
  - VR Rule column chứa regex `^[a-z]+$` hoặc tech type `varchar(255)` — đó là HOW, sai vị trí.
299
- - V8 placeholder bị fill nội dung tự sinh (model bịa flow) flow decision của product.
372
+ - V8 flows auto-apply không qua propose-then-approve model có thể bịa glue step / sai journey grouping mà BA không kịp catch.
373
+ - V8 flow chứa step không trace được lên US nào (model bịa) → BA reject draft và yêu cầu regenerate.
374
+ - V8 Mermaid block dùng syntax `[{...}]` thay vì `["..."]` — vi phạm V1 convention.
300
375
  - Validate fail nhưng skip rollback → file ở trạng thái nửa migrate, khó debug sau.
301
376
  - Load conventions.md hoặc source code "for safety" → contamination, tốn context, không cải thiện output.
302
377
 
@@ -305,6 +380,6 @@ Append vào [changelogs.md](../../changelogs.md) `## [Unreleased]`:
305
380
  Trước khi mark feature done:
306
381
  - [ ] Tất cả vectors detected đã apply (hoặc skip có log lý do)
307
382
  - [ ] Validate Bước 6 pass
308
- - [ ] Backup `.bak.{timestamp}` còn nguyên
383
+ - [ ] Working tree clean trước khi skill chạy (git status verified) — rollback dùng git, không có file backup
309
384
  - [ ] Cascade ID đã re-grep và confirm 0 false-positive
310
385
  - [ ] User confirm VR proposal nếu V6 applied
@@ -208,14 +208,15 @@ Migrate frd.md hiện có lên format mới nhất của `templates/main/feature
208
208
  | V5 | Insert US/AC stability notes | None |
209
209
  | V6 | Propose Verification Rules từ User Stories → user approve → insert | Medium |
210
210
  | V7 | Move `Components Consumed` → `Dependencies > Components Used` | Low |
211
- | V8 | Insert `User Flows` placeholder (KHÔNG tự sinh flow) | None |
211
+ | V8 | Derive Mermaid flows từ User Stories propose user approve → insert | Medium |
212
212
 
213
- **Workflow:** Discover & classify → per-FRD context load → apply mechanical vectors (V1/V2/V3/V5/V7/V8) → V4 dry-run preview với cascade impact → confirm → V6 propose VR → confirm → validate → report.
213
+ **Workflow:** Pre-flight git clean check → discover & classify → per-FRD context load → apply mechanical vectors (V1/V2/V3/V5/V7) → V4 dry-run preview với cascade impact → confirm → V6 propose VR → confirm → V8 propose Flows → confirm → validate → report.
214
214
 
215
215
  **Cảnh báo:**
216
216
  - V4 mặc định dry-run, in remap table + cascade diff trước khi ghi.
217
217
  - V6 luôn propose-then-approve, không auto-apply (model dễ bịa rule).
218
- - V8 chỉ chèn placeholder TODO, không tự sinh flow (flow decision của product).
218
+ - V8 luôn propose-then-approve model derive flow từ US journey grouping, BA phải review để catch glue step bịa hoặc grouping sai.
219
+ - KHÔNG tạo file `.bak` — rollback dùng `git checkout -- {file}`. Pre-flight yêu cầu working tree clean.
219
220
 
220
221
  **No-op safe:** nếu mọi FRD đã clean, skill báo và dừng — không ghi gì.
221
222