spec-lite 1.3.1 → 1.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-lite",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
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. **Bắt buộc không có option skip; FRD migration không hoàn tất nếu thiếu User Flows.** | 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,67 @@ 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. Bắt buộc — không có option skip.** Propose-then-approve giống V6 nhưng loop cho tới khi user approve: model derive draft, user duyệt (yes) hoặc trả phản hồi (edit) → model regenerate. FRD migration chỉ hoàn tất khi `## User Flows` đã insert.
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)
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") → regenerate draft, loop lại
311
+
312
+ User Flows là **bắt buộc** — không có option skip. Nếu user muốn dừng toàn bộ migration cho feature này, dùng "skip-feature" ở Bước 4 hoặc abort skill (Ctrl-C) trước khi V8 chạy.
313
+ ```
314
+
315
+ #### 6.4 Insert
316
+ - Insert section `## User Flows` ngay sau `## Overview` (theo thứ tự template).
317
+ - Copy intro + **Flow numbering stable** note (V2 convention) từ template, sau đó list các Mermaid blocks theo flow numbering.
318
+
319
+ ---
320
+
321
+ ### Bước 7: Validate
248
322
 
249
323
  Sau khi apply hết vectors cho một FRD, chạy check:
250
324
 
@@ -253,28 +327,29 @@ Sau khi apply hết vectors cho một FRD, chạy check:
253
327
  - [ ] Story AC vẫn dùng `AC-F{NNN}-` (không bị remap nhầm)
254
328
  - [ ] Mermaid blocks không còn pattern `[{...}]`
255
329
  - [ ] Có heading `## Verification Rules` (nếu V6 applied)
330
+ - [ ] Có heading `## User Flows` với ít nhất 1 Mermaid flowchart (bắt buộc — nếu V8 detected mà section vẫn vắng thì migration chưa hoàn tất)
256
331
  - [ ] VR Rule column không chứa keyword UI copy: "error message", "vui lòng", "hint", "tooltip"
257
332
  - [ ] Frontmatter `referenced_by` trỏ tới `3.3 Feature level` (không phải `3.2`)
258
333
 
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).
334
+ 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
335
 
261
336
  ---
262
337
 
263
- ### Bước 7: Report + changelog
338
+ ### Bước 8: Report + changelog
264
339
 
265
340
  Cho mỗi FRD đã migrate:
266
341
 
267
342
  ```
268
343
  ✓ F-001 — auth
269
- Vectors applied: V1, V3, V4 (3 IDs remapped), V5, V6 (8 VRs added)
344
+ Vectors applied: V1, V3, V4 (3 IDs remapped), V5, V6 (8 VRs added), V8 (2 flows added)
270
345
  Cascade: fdd.md (3 refs), tsd.md (5 refs), integrations/003 (3 refs)
271
- Backup: frd.md.bak.20260519-1430
272
346
 
273
347
  ✓ F-002 — checkout
274
348
  Vectors applied: V5, V6 (5 VRs added)
275
- Backup: frd.md.bak.20260519-1430
276
349
  ```
277
350
 
351
+ 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.
352
+
278
353
  Append vào [changelogs.md](../../changelogs.md) `## [Unreleased]`:
279
354
 
280
355
  ```
@@ -290,21 +365,24 @@ Append vào [changelogs.md](../../changelogs.md) `## [Unreleased]`:
290
365
  | "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
366
  | "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
367
  | "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). |
368
+ | "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
369
 
295
370
  ## Red Flags
296
371
 
297
372
  - Apply V4 không có dry-run preview → user không kịp catch cascade reference sai.
298
373
  - 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.
374
+ - 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.
375
+ - 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.
376
+ - Để FRD không có `## User Flows` sau migration vì "draft chưa ổn" → sai. V8 bắt buộc; nếu draft chưa ổn, dùng `edit` loop cho tới khi approve. FRD không có User Flows = migration chưa hoàn tất.
377
+ - V8 Mermaid block dùng syntax `[{...}]` thay vì `["..."]` — vi phạm V1 convention.
300
378
  - Validate fail nhưng skip rollback → file ở trạng thái nửa migrate, khó debug sau.
301
379
  - Load conventions.md hoặc source code "for safety" → contamination, tốn context, không cải thiện output.
302
380
 
303
381
  ## Verification
304
382
 
305
383
  Trước khi mark feature done:
306
- - [ ] Tất cả vectors detected đã apply (hoặc skip có log lý do)
384
+ - [ ] Tất cả vectors detected đã apply (hoặc skip có log lý do — riêng V8 KHÔNG được skip)
307
385
  - [ ] Validate Bước 6 pass
308
- - [ ] Backup `.bak.{timestamp}` còn nguyên
386
+ - [ ] Working tree clean trước khi skill chạy (git status verified) — rollback dùng git, không có file backup
309
387
  - [ ] Cascade ID đã re-grep và confirm 0 false-positive
310
388
  - [ ] 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