specpro-cli 0.1.0__py3-none-any.whl

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.
Files changed (76) hide show
  1. specpro_cli/__init__.py +16 -0
  2. specpro_cli/assets/commands/specpro.analyze.md +1102 -0
  3. specpro_cli/assets/commands/specpro.checklist.md +335 -0
  4. specpro_cli/assets/commands/specpro.clarify.md +581 -0
  5. specpro_cli/assets/commands/specpro.constitution.md +488 -0
  6. specpro_cli/assets/commands/specpro.feature.md +115 -0
  7. specpro_cli/assets/commands/specpro.implement.md +1881 -0
  8. specpro_cli/assets/commands/specpro.manual-test.md +206 -0
  9. specpro_cli/assets/commands/specpro.plan.md +3284 -0
  10. specpro_cli/assets/commands/specpro.qc.md +1489 -0
  11. specpro_cli/assets/commands/specpro.scenarios.md +154 -0
  12. specpro_cli/assets/commands/specpro.specify.md +1449 -0
  13. specpro_cli/assets/commands/specpro.status.md +863 -0
  14. specpro_cli/assets/commands/specpro.tasks.md +1207 -0
  15. specpro_cli/assets/commands/specpro.test-implement.md +462 -0
  16. specpro_cli/assets/commands/specpro.test-plan.md +383 -0
  17. specpro_cli/assets/commands/specpro.user-manual.md +178 -0
  18. specpro_cli/assets/scripts/bash/check-anti-coupling.sh +293 -0
  19. specpro_cli/assets/scripts/bash/check-prerequisites.sh +176 -0
  20. specpro_cli/assets/scripts/bash/common.sh +88 -0
  21. specpro_cli/assets/scripts/bash/create-new-feature.sh +336 -0
  22. specpro_cli/assets/scripts/bash/qc-auto-fix.sh +121 -0
  23. specpro_cli/assets/scripts/bash/setup-plan.sh +60 -0
  24. specpro_cli/assets/scripts/bash/verify-cumulative-records.sh +203 -0
  25. specpro_cli/assets/scripts/bash/verify-deliverables-tracked.sh +147 -0
  26. specpro_cli/assets/scripts/bash/verify-deployment.sh +239 -0
  27. specpro_cli/assets/scripts/bash/verify-frontmatter-yaml.sh +63 -0
  28. specpro_cli/assets/scripts/bash/verify-ledger.sh +376 -0
  29. specpro_cli/assets/scripts/bash/verify-shapes.sh +1082 -0
  30. specpro_cli/assets/scripts/git-hooks/pre-commit +243 -0
  31. specpro_cli/assets/scripts/install-git-hooks.sh +67 -0
  32. specpro_cli/assets/scripts/powershell/check-anti-coupling.ps1 +249 -0
  33. specpro_cli/assets/scripts/powershell/check-prerequisites.ps1 +148 -0
  34. specpro_cli/assets/scripts/powershell/common.ps1 +95 -0
  35. specpro_cli/assets/scripts/powershell/create-new-feature.ps1 +229 -0
  36. specpro_cli/assets/scripts/powershell/qc-auto-fix.ps1 +110 -0
  37. specpro_cli/assets/scripts/powershell/setup-plan.ps1 +61 -0
  38. specpro_cli/assets/scripts/powershell/verify-cumulative-records.ps1 +133 -0
  39. specpro_cli/assets/scripts/powershell/verify-deliverables-tracked.ps1 +112 -0
  40. specpro_cli/assets/scripts/powershell/verify-deployment.ps1 +278 -0
  41. specpro_cli/assets/scripts/powershell/verify-frontmatter-yaml.ps1 +56 -0
  42. specpro_cli/assets/scripts/powershell/verify-ledger.ps1 +383 -0
  43. specpro_cli/assets/scripts/powershell/verify-shapes.ps1 +978 -0
  44. specpro_cli/assets/templates/agent-context-template.md +49 -0
  45. specpro_cli/assets/templates/assumptions-template.md +248 -0
  46. specpro_cli/assets/templates/checklist-template.md +40 -0
  47. specpro_cli/assets/templates/clarifications-template.md +155 -0
  48. specpro_cli/assets/templates/constitution-template.md +50 -0
  49. specpro_cli/assets/templates/feature-spec-template.md +66 -0
  50. specpro_cli/assets/templates/plan-overview-template.md +150 -0
  51. specpro_cli/assets/templates/plan-template.md +387 -0
  52. specpro_cli/assets/templates/protocol-golden-bytes-guide.md +195 -0
  53. specpro_cli/assets/templates/requirements-template.md +356 -0
  54. specpro_cli/assets/templates/spec-template.md +267 -0
  55. specpro_cli/assets/templates/tasks-template.md +252 -0
  56. specpro_cli/assets/templates/test-tasks-template.md +174 -0
  57. specpro_cli/cli/__init__.py +5 -0
  58. specpro_cli/cli/cmd_init.py +416 -0
  59. specpro_cli/cli/cmd_remove.py +122 -0
  60. specpro_cli/cli/entry.py +181 -0
  61. specpro_cli/integrations/__init__.py +36 -0
  62. specpro_cli/integrations/base.py +601 -0
  63. specpro_cli/integrations/claude/__init__.py +101 -0
  64. specpro_cli/integrations/copilot/__init__.py +153 -0
  65. specpro_cli/integrations/cursor_agent/__init__.py +51 -0
  66. specpro_cli/integrations/gemini/__init__.py +44 -0
  67. specpro_cli/integrations/opencode/__init__.py +48 -0
  68. specpro_cli/integrations/qodercli/__init__.py +54 -0
  69. specpro_cli/integrations/registry.py +88 -0
  70. specpro_cli/packaged/__init__.py +5 -0
  71. specpro_cli/packaged/sync.py +106 -0
  72. specpro_cli-0.1.0.dist-info/METADATA +117 -0
  73. specpro_cli-0.1.0.dist-info/RECORD +76 -0
  74. specpro_cli-0.1.0.dist-info/WHEEL +4 -0
  75. specpro_cli-0.1.0.dist-info/entry_points.txt +2 -0
  76. specpro_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,383 @@
1
+ ---
2
+ description: Generate a coverage matrix and high-level test tasks (integration / component E2E / app E2E) in specs/test-tasks.md
3
+ handoffs:
4
+ - label: Execute Test Tasks
5
+ agent: specpro-test-implement
6
+ prompt: Execute the generated high-level test tasks
7
+ send: false
8
+ - label: Analyze For Consistency
9
+ agent: specpro-analyze
10
+ prompt: Run a project analysis for consistency including test matrix gaps
11
+ send: false
12
+ writes:
13
+ # This command's write surface: only what it produces AS THE PRODUCER of that
14
+ # (artifact, unit) pair. A write this command makes on a non-producer path is a
15
+ # boundary violation by definition (FR-051) and MUST NOT be declared here.
16
+ # The full ownership map is the UNION of every command's writes: block.
17
+ - artifact: specs/test-tasks.md
18
+ unit: "whole file - the run log, coverage matrix, change log, peer-diversity registry and the INF/IT/CE/AE task sections; **except** the executed task's checkbox and the coverage-matrix Status column, which are /specpro-test-implement's"
19
+ - artifact: specs/implement_issues.md
20
+ unit: "the [test-plan] section only -> its own issues marked [x] with a resolution note; appended ISS-NNN entries in any section — registration is routing; only [x]-marking is section-scoped"
21
+ ---
22
+
23
+ ## User Input
24
+
25
+ ```text
26
+ $ARGUMENTS
27
+ ```
28
+
29
+ You **MUST** consider the user input before proceeding (if not empty).
30
+
31
+ **Rerun safety — detect the artifact, default to incremental** ⚠️ [settled 2026-09-13]:
32
+
33
+ **Before writing `specs/test-tasks.md`, detect whether it already exists.** Use the SAME check in every command:
34
+
35
+ ```bash
36
+ [ -s specs/test-tasks.md ] && echo EXISTS || echo NEW # -s: exists AND non-empty (an empty placeholder counts as NEW)
37
+ ```
38
+
39
+ | Detection | Mode |
40
+ |-----------|------|
41
+ | **NEW** (absent or empty) | **Initial** — generate from scratch |
42
+ | **EXISTS** | **Incremental** — evolve it; **never silently regenerate from scratch** |
43
+
44
+ **Overwriting an existing artifact requires explicit, confirmed intent:**
45
+ 1. Only when the user *explicitly* asks (in their own words) does the initial path run on an existing artifact.
46
+ 2. **Even then, confirm once more before writing** — name the artifact that will be replaced and what will be lost; wait for the answer.
47
+ 3. **Silence is not consent.** An unspecified run on an existing artifact is ALWAYS incremental.
48
+
49
+ > **Why a shared rule rather than per-command courtesy**: nine of the twelve non-implementation commands already had some protection, but each wrote it its own way (`EXISTING_SPEC` check · "creates a NEW file" · `NEVER overwrite` · "incremental regeneration" · `AUTO_MODE=false`), and **three had none at all** — not by decision, but because the discipline had no shared carrier. Overwriting an artifact the user has been evolving is not recoverable within the session; the cost of asking is one prompt.
50
+
51
+ **Supported arguments**:
52
+ - `--review-issues`: **skip the question and process the pending `[test-plan]` entries** directly. It is *not* what enables the mode: the mode is detected on every run (see below). The flag only means "I already know — don't ask".
53
+
54
+ **Ledger handling is detected, not opted into** ⚠️ [settled 2026-09-13]:
55
+
56
+ **On every run, before any normal work, check the `[test-plan]` section of `specs/implement_issues.md` for open `[ ]` entries.**
57
+
58
+ | Situation | Behaviour |
59
+ |-----------|-----------|
60
+ | No file, or no open `[ ]` entry in `[test-plan]` | Proceed with the normal incremental run. **No prompt.** |
61
+ | Open entries exist | **Ask the user** — "N open `[test-plan]` issues. Process them first (their verdicts land in Step 7), or run normally?" |
62
+ | `--review-issues` passed | **Skip the question and process them directly.** |
63
+
64
+ > **Why the flag is not the switch** (the failure this replaces): the old semantics — flag = on, no flag = off — pushed the risk onto the user. *Not* passing it risked silently leaving findings unprocessed; passing it risked overriding the incremental work they actually wanted. Neither was safe, and the pending set was invisible until the command ran. **Detect-then-ask makes it an explicit choice; the flag is left doing only "don't ask me again".**
65
+ >
66
+ > ⚠️ **Naming (settled 2026-09-13, TOOL-008)**: earlier drafts of this command carried a `--fix-issues` flag here. It was **removed** — processing the `[test-plan]` section *is* upstream-artifact work, which is exactly what `--review-issues` means everywhere else; a second name for the same action only made the parameter set ambiguous. `/specpro-implement` keeps a separate `--fix-defects` flag, because its other queue fixes **product code** — a genuinely different thing. **Rule of thumb: `review` = upstream artifacts (spec / plan / tasks / test-tasks); `defects` = product code.**
67
+
68
+
69
+ ### Scope Resolution 🆕 (FR-063 / T050 · v0.23)
70
+
71
+ 1. **作用域判定**: 当前工作目录位于 `specs/fNNN-简称/` 内 ⇒ **feature 作用域**(读写范围 = 本 feature 目录,由 `check-prerequisites.sh` 的作用域感知解析);位于仓库根或 `specs/` 根 ⇒ **母作用域**(读写母规格链)。feature 作用域内 MUST NOT 写母产物——唯一例外:**发现登记**(台账路由,`[specify]`/`[plan]` 分区)。
72
+ 2. **新会话首次执行**: 若 `specs/features.md` 存在且含 `active` 行、而用户未指明作用域 ⇒ **询问用户**在母作用域还是某个 feature 内工作,MUST NOT 自行挑选。
73
+ 3. 本命令的产物路径随之解析:feature 作用域下落 `<feature 目录>/`,母作用域下落 `specs/`。
74
+
75
+ ## Key Concept: Four-Layer Test Ownership 🧪 [CRITICAL]
76
+
77
+ **Design Principle**: The project has FOUR test layers with DISTINCT owners. This command owns THREE of them.
78
+
79
+ | Layer | Owner | Artifact | Notes |
80
+ |-------|-------|----------|-------|
81
+ | Unit Tests | `/specpro-plan` → `/specpro-tasks` | tasks.md (in-dev tasks, `[Quality]` tasks) + `core/src` embedded tests | NOT in this command's scope |
82
+ | **Integration Tests** | **`/specpro-test-plan` (this command)** | **specs/test-tasks.md (IT-xxx)** | Mock-based, byte-sequence/scripted peers, <30s, CI-friendly |
83
+ | **Component E2E Tests** | **`/specpro-test-plan` (this command)** | **specs/test-tasks.md (CE-xxx)** | Real peers (quirks/timing/perf/concurrency), environment-guarded |
84
+ | **Application E2E Tests** | **`/specpro-test-plan` (this command)** | **specs/test-tasks.md (AE-xxx)** | App assembly, UI rendering chain, input-to-display |
85
+ | Manual Acceptance | `/specpro-manual-test` | manual-test-tasks.md | Subjective/exploratory scenarios, human judgment |
86
+
87
+ **Core artifact**: `specs/test-tasks.md` — led by a **Coverage Matrix** (FR × layer × task ID × status × rationale) built BEFORE task generation, guaranteeing reverse traceability (every FR is accounted for; every task maps back to FRs).
88
+
89
+ **Grounding principle**: test-plan MUST scan the ACTUAL codebase. Existing test assets are registered in the matrix as already-covered (never duplicated). Infrastructure gaps (e.g., no in-process mock server) become INF-xxx tasks.
90
+
91
+ ## Layer Assignment Rules 📏 [AUTHORITATIVE]
92
+
93
+ Apply these rules per FR when building the matrix. The constitution states only high-level principles; THESE rules are the operative detail.
94
+
95
+ | Layer | Assign when... | Typical module (convention, not a hard rule) | Examples |
96
+ |-------|---------------|----------------------------------------------|----------|
97
+ | **Integration (IT)** | Peer behavior can be **deterministically simulated** with byte sequences / scripted responses. Contract-conformance verification against `specs/contracts/` (mock-based) belongs HERE | `tests/integration-test/`; contract verification may live in `tests/contract-test/` | Handshake version branches, security-type negotiation, message parsing round-trips, encoder↔decoder against scripted peer, contract tests (e.g. `tests/contract-test/` protocol compatibility) |
98
+ | **Component E2E (CE)** | Behavior depends on **real peer quirks / timing / performance / concurrency scale** | `tests/e2e-test/` (real-peer packages) | Real peer auth + full encoding flow, resolution change mid-connection, throughput under real network |
99
+ | **Application E2E (AE)** | Involves **app assembly, UI rendering chain, input-to-display** | `tests/e2e-test/` (app package) | Startup→connect→render, remote-control input latency, grid view with N connections |
100
+ | **Unit (→ tasks.md)** | Single function/class in isolation | tasks.md-specified unit source sets / `tests/core-test/` / plugin `jvmTest` | Register existing tasks.md unit tasks or `core/src` embedded tests in the matrix; do NOT create new unit tasks |
101
+ | **Manual (→ specpro.manual-test)** | **Subjective/exploratory** judgment required — **PREREQUISITE (FR-065): automation MUST be ruled out first** (evaluate against the mechanical carriers; mechanical parts → IT rows; the manual row carries only the subjective remnant, named concretely) | — (human execution, no automated module) | Visual aesthetics, intuitive navigation, exploratory discovery |
102
+
103
+ **Module–layer mapping is a CONVENTION, not a hard rule**: one module may host multiple layers (e.g. `tests/e2e-test/` hosts CE real-peer packages and the AE app package), and one layer may span modules (IT in `tests/integration-test/` and `tests/contract-test/`). Any deviation is governed by the Location grounding rule (Step 5.e): a task's Location must reference a REAL module from the scan (or an INF task that creates it).
104
+
105
+ **Special cases**:
106
+ - **FR with no corresponding implementation component yet** → matrix row marked `pending-impl` in all layers; **do NOT generate tasks** (never test things that don't exist)
107
+ - **FR sufficiently covered by existing unit assets** (no high-level test adds value) → matrix row status `not-applicable` with rationale; register the asset in the Unit cell; do NOT generate tasks
108
+ - **FR deleted from spec** (incremental) → matrix row status `deprecated`; associated tasks marked `[DELETED]`; never re-tasked
109
+ - **FR covered by existing assets** → register the asset (test file path / tasks.md task ID) in the matrix cell with rationale; do NOT generate a duplicate task
110
+ - **Pure UI-logic FRs** → typically AE-only; integration/CE cells get rationale "pure UI, app-level" (or project-language equivalent)
111
+ - **In-process UI-component tests (ComposeTestRule-style tools) are component/unit-layer coverage, NOT AE** — AE means the REAL app process launched end-to-end (assembly + rendering chain); framework-less structural "UI tests" (string/structure assertions with no UI framework) count as NO UI coverage — never register them as UI-covered in any matrix cell
112
+ - **Performance NFRs** → attach as `Performance:` field on the CE/AE task that exercises the metric (only when a corresponding NFR exists)
113
+ - **Cross-platform / global-constraint FRs** (claim text covers all platforms or enumerates platforms) → coverage MUST be anchored per platform tier: per-platform cells/scenarios, or a scenario set covering every claimed `full`-tier platform. Anchoring such an FR to a single-platform scenario alone is an assignment error — analyze Pass J flags it (HIGH); on `restricted`-tier platforms, only the FRs inside the spec boundary clause get coverage, the rest of the row follows `pending-impl`/`not-applicable` semantics
114
+
115
+ ## Outline
116
+
117
+ **Artifact Language Rule** 🌐 [CRITICAL — applies to ALL generated content]:
118
+ - **Prose content** (descriptions, rationale, scenario text, guidance) follows the project's **Artifact Language** setting — from `specs/constitution.md` → **Artifact Language** field; default `en` when absent
119
+ - **Structural anchors are ALWAYS English**, regardless of the artifact language: section headings from the template, task ID prefixes (INF/IT/CE/AE), FR/US IDs, the matrix status enum, and table column names — exactly as written in the template
120
+ - **Entry field labels are structural anchors too** (`source:`, `Evidence:`, `Fix Direction:`) — never translated, even when the surrounding prose is not English. They exist to be **searched**: an entry's fields must be greppable across artifacts and projects, and a translated label silently drops out of every consumer's scan.
121
+ - Rationale: fixed anchors keep artifacts machine-parseable across specpro commands and keep instructions ↔ artifacts aligned for review
122
+
123
+ 1. **Setup**: Run `.specpro/scripts/bash/check-prerequisites.sh --json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
124
+
125
+ **Pre-flight checks**:
126
+ - **spec.md REQUIRED** — if missing: ❌ ERROR "Run /specpro-specify first", EXIT 1
127
+ - **tasks.md RECOMMENDED** — if missing: ⚠️ WARNING "FR→task mapping and module paths unavailable; matrix unit-coverage column will be incomplete. Continue? (y/n)". If 'n': EXIT 0
128
+ - **plan.md RECOMMENDED** — if missing: ⚠️ WARNING "Risk classification and Quality Targets unavailable; layer assignment will fall back to default rules. Continue? (y/n)". If 'n': EXIT 0
129
+
130
+ 2. **Incremental mode detection** 🔄 (change-log-driven; mirrors spec.md/tasks.md iteration patterns):
131
+ - If `$FEATURE_DIR/test-tasks.md` **already exists** → enter **incremental mode**:
132
+ * Read the file-header **Test-plan Runs** log and the **Matrix Change Log** table FIRST — they record what previous runs processed
133
+ * **Change-log-driven processing scope** = union of:
134
+ - FRs registered in the Matrix Change Log since the last run (previous incremental entries)
135
+ - FRs with **SpecStatus changed in spec.md** since the last Test-plan Runs entry (create/update)
136
+ - FRs **not present in the matrix** / with uncovered cells
137
+ - Grounding-scan deltas (Step 5): new existing assets → register in matrix cells; new infrastructure gaps → new INF tasks
138
+ - **Open `[test-plan]` issues in `specs/implement_issues.md`** — planning errors in this artifact reported by `/specpro-test-implement` (its Step 11). Read that section FIRST in every incremental run and resolve it in Step 7; a run that ignores it leaves the reporter's findings uncollected. In **full mode** the section may not exist yet — skip it
139
+ * All OTHER matrix rows are carried over **verbatim** (rationales, task IDs, statuses) — never re-derived, never re-scanned
140
+ * For each re-processed FR: re-run layer assignment for its row only; update its matrix cells; if task content must change, **rewrite the task in place (same ID)** or mark superseded tasks `[DELETED]` (same convention as tasks.md: mark now, physically remove on a later pass); **ID numbering never resets**
141
+ * FRs with SpecStatus = "delete" → mark matrix row `deprecated`, mark associated tasks `[DELETED]`
142
+ * **Write the logs**: append one row per re-processed FR to Matrix Change Log, and one `[test-plan:incremental <date>]` entry to Test-plan Runs
143
+ - If not exists → **full mode**: build the matrix from scratch; seed Matrix Change Log with a `create` row; write the first `[test-plan:create <date>]` entry
144
+
145
+ **Why no per-row Lifecycle markers**: unlike spec.md (whose FR entries have no other record of which commands processed them), matrix execution progress is **derivable from task checkboxes** — the status column is a human-readable summary of that derived state. Planning-era metadata (which run processed what) lives in the two logs, keeping 156+ rows maintenance-light.
146
+
147
+ 3. **Load requirements side** 📋: From spec.md extract:
148
+ - **FR full set** (all functional requirements with IDs and Lifecycle status)
149
+ - **Acceptance Scenarios** (per user story, Given-When-Then; these are the PRIMARY source for test task scenario grouping)
150
+ - **NFR performance metrics** (e.g., latency, FPS, memory targets) — later attached to CE/AE tasks as `Performance:` fields
151
+ - **Independent Test** sections (per user story) — inform layer assignment
152
+
153
+ 4. **Load planning side** 🏗️:
154
+ - From **tasks.md**: FR→task mapping (which tasks implement which FRs — identifies "no implementation component yet" FRs), module/file paths (test Location grounding)
155
+ - From **plan.md**: architecture boundaries (which modules exist, platform layers), **Quality Targets → Risk Classification** (HIGH/MEDIUM/LOW-RISK FR classification), **Quality Targets** (coverage targets; informs how aggressive layer assignment should be for HIGH-RISK modules)
156
+
157
+ 5. **Codebase grounding scan** 🔍 [CRITICAL — THIS IS WHAT MAKES test-plan REAL]:
158
+ **Purpose**: Inventory ACTUAL test assets so the matrix reflects reality, not assumptions. This prevents the three-way decoupling (mirrors that don't exist / paths that don't match / silently degraded durations) that high-level planning without grounding produces.
159
+
160
+ a. **Scan test modules**: inventory all files under `tests/*` (every test module directory), recording per file: test class name, what it actually tests (from test method names/annotations), whether it RUNS (module has build config + registered in settings) or is an empty/skeleton module
161
+
162
+ b. **Scan embedded tests**: inventory test files inside main source trees (e.g., `core/src/**/*Test.kt`, `src/test/**`) — these count as unit coverage
163
+
164
+ c. **Scan test infrastructure**: `docker-compose*.yml` (which containers/ports are defined), root-level test scripts, CI workflow files, test fixtures directories — plus **app-side infrastructure for AE**: app module build config (grounded build command + launch entry point), UI-driver toolchain (UI-test frameworks / screenshot / accessibility drivers), display environment for headless runs
165
+
166
+ d. **Produce two lists** (report them verbatim in Step 8):
167
+ - **Existing test asset inventory**: e.g., `XxxDecoderTest → registered as FR-xxx unit-covered`; each asset gets a matrix cell with rationale "existing asset: <path>"
168
+ - **Infrastructure gaps**: e.g., `tests/integration-test module is EMPTY (no build config or test sources)`, `no in-process mock server exists`, `docker-compose has no server service for CE tests`, `no app-launch harness or UI-driver toolchain exists for AE tasks`. Each gap → candidate INF-xxx task
169
+
170
+ e. **Grounding validation for every planned task Location**: a task's Location must reference a REAL module path from the scan (or an INF task that creates it). Never emit a Location under a module that the scan shows doesn't exist without an accompanying INF task.
171
+
172
+ 6. **Layer assignment** 📏: For EACH FR (full set in full mode; changed set in incremental mode):
173
+ - Apply the **Layer Assignment Rules** (above) per layer cell; record rationale in every non-covered cell
174
+ - Use plan.md risk classification: HIGH-RISK modules (protocol/crypto/network) should typically get IT + CE coverage; AE where UI chain is involved
175
+ - FRs with no implementation component (no tasks.md task, no code found in grounding scan) → mark row `pending-impl`, generate NO tasks
176
+ - Subjective/exploratory aspects → mark cell `manual (/specpro-manual-test)` with reason
177
+ - Build the coverage matrix COMPLETELY before generating any task (matrix-first, tasks-second)
178
+
179
+ 7. **Generate `specs/test-tasks.md`** 📋: Use `.specpro/templates/test-tasks-template.md` as structure. Section order and sources:
180
+ - **Test-plan Runs log** (file header) — REQUIRED; append one entry per run (`[test-plan:create <date>]` full mode / `[test-plan:incremental <date>]` incremental mode, summarizing what was processed); never rewrite or delete previous entries
181
+ - **Coverage Matrix** — from Step 6 (every FR × 4 layers, rationale everywhere, status column); incremental mode: carry over untouched rows verbatim, rewrite only re-processed FRs
182
+ - **Matrix Change Log** (inside/after matrix section) — REQUIRED; one row per re-processed FR (full mode: single `create` row covering all FRs); this table is the processing record for the next incremental run
183
+ - **Peer Diversity Registry** — REQUIRED for protocol / wire-format modules, omit otherwise; the closed set of *measured* peer behaviours. Carry existing rows over verbatim; register rows for behaviours measured since the last run (including differences reported by `test-implement`). A row is the only licence for a test to assert "peer X behaves as Y"; absence means unmeasured, and `analyze` Pass L5 audits expectations against it
184
+ - **Test Infrastructure Tasks (INF-xxx)** — from the grounding scan gap list; ordered FIRST (all test tasks depend on infra); no FR annotation
185
+ - **Integration Test Tasks (IT-xxx)** — grouped by scenario/domain (e.g., `[handshake]`, `[encoding-negotiation]`); deduplicated against existing assets found in Step 5
186
+ - **Component E2E Tasks (CE-xxx)** — grouped by scenario/domain; each with Environment + environment-guard requirement
187
+ - **Application E2E Tasks (AE-xxx)** — grouped by scenario/domain
188
+ - **Progress Statistics** — per-layer totals + matrix coverage counts (keep updated)
189
+
190
+ **Log ownership boundary**: BOTH logs, the coverage matrix, and the Peer Diversity Registry are written ONLY by `/specpro-test-plan`. `/specpro-test-implement` reads them (from the logs it determines nothing — it works from task checkboxes) but never writes them; peer-behaviour differences it discovers are report-only and get registered here on the next incremental run. Superseded tasks are marked `[DELETED]` (kept for audit), physically removed on a later pass — same convention as tasks.md.
191
+
192
+ **`[test-plan]` issue resolution** 🔄 [CLOSES THE FEEDBACK LOOP]:
193
+ - **Governing rule**: *a planning error is fixed by the planner, an implementation error by the implementer.* This artifact (`specs/test-tasks.md`) is planned here, so **planning errors in it are fixed here** — that is the whole meaning of the `[test-plan]` section
194
+ - **Shared section, split by action**: `/specpro-test-implement` **appends** new issues (`- [ ] ISS-XXX: ...`) and never marks them `[x]`; `/specpro-test-plan` **resolves** them — this command is the only party that marks `[test-plan]` issues `[x]`
195
+ - **For each open `[test-plan]` issue**, decide and record the verdict in the issue block (mirroring the `**Resolved <date>**` convention used by the other sections):
196
+ * **Accept** → fix `specs/test-tasks.md` (matrix row/cell, task content, Location, annotation) → mark `[x]` + append `**Resolved <date>**(/specpro-test-plan): <what changed>`
197
+ * **Reject** → mark `[x]` + append `**Rejected <date>**: <reason>` — an issue may be closed as unfounded, but never silently dropped
198
+ * **Re-route** → if on inspection the defect is actually a *product* bug or an *upstream* planning error, do NOT fix it here: mark `[x]` with a `**Re-routed <date>**` note naming the correct channel (`fix-tasks.md` FT / `[specify]` / `[plan]` / `[tasks]`), and say so in the report so the human can carry it there
199
+ - **Issues about infrastructure planned elsewhere are not yours**: test-infrastructure work dispatched to `tasks.md` as `[Quality]` tasks (e.g. codec test-matrix / golden-fixture / test-host tasks, on a `/specpro-plan` design section) is planned by `/specpro-tasks`, not here. If such an issue appears in `[test-plan]`, re-route it per the bullet above — do not treat that infrastructure as this command's planning surface
200
+ - **Report the outcome** in Step 8 (count opened / accepted / rejected / re-routed)
201
+ - **Verify mechanically after writing** ⚠️: run `.specpro/scripts/bash/verify-ledger.sh`. Marking issues `[x]` changes the section's counts, so the statistics table must be updated in the same pass — the script reports any mismatch by name, along with any entry that sits outside a section and a missing trailing newline. A pre-commit hook enforces the same check.
202
+ - **Edit order and idempotency check** ⚠️ [a silent false-skip, observed 2026-09-13]: write the **entry body first** (its `[x]` + resolution note, in its own section), then the derived summaries (statistics table + `Last Updated`) — never the reverse. A derived summary written first introduces the ID into the file's text before the entry is resolved, so an idempotency guard that greps the file for that ID falsely concludes "already done" and **skips the resolution**, while the summaries still claim it happened. For the same reason the guard MUST match the entry body's **line-start pattern**, never a full-text keyword search:
203
+ ```bash
204
+ grep -qE '^- \[x\] ISS-<N>:' specs/implement_issues.md # correct — matches the ENTRY's state, not a mention
205
+ # grep -q 'ISS-<N>' … # wrong — also matches the statistics Pending-Items column, the Last Updated line, cross-references
206
+ ```
207
+ - **General rule: every grep/awk example shown in an instruction or template must itself obey the line-start pattern** (TOOL-009) — the executing side copies examples verbatim, so an example that uses a whole-file match propagates the same misjudgment to everyone who copies it. This file has already corrected its own sentinel self-check command under this rule.
208
+
209
+ **Documentation convention**: test development process documentation produced while executing test tasks (mock-server format specs, flaky-test root causes, E2E environment debug guides) lives under `docs/test/` — written and maintained by `/specpro-test-implement` (see its Test Development Process Documentation step). test-plan itself does NOT write these documents; the two logs above are planning records, not documentation. Development-side docs (tasks.md work, including unit tests and their run guides) stay under `docs/implement/` — location follows the ownership of the work, not the document's topic.
210
+
211
+ **Task format** (concise; minimal per-layer differentiation):
212
+ ```markdown
213
+ - [ ] IT-001 [handshake] protocol version-branch handshake (FR-xxx)
214
+ Location: tests/integration-test/src/<target>/.../<Name>IT.kt
215
+ Source: mock server returns 003.003/003.007/003.008; assert the client uses the matching security handshake format
216
+ Mock: in-process ServerSocket mock server
217
+ ```
218
+ ```markdown
219
+ - [ ] CE-001 [connection-matrix] Real-server auth + full encoding flow (FR-xxx, FR-yyy)
220
+ Location: tests/e2e-test/src/test/.../XxxE2ETest.kt
221
+ Environment: Docker + container manifest
222
+ Validates: observable results
223
+ ```
224
+ - Every IT/CE/AE task MUST end with `(FR-XXX)` annotation (multi-FR allowed: `(FR-xxx, FR-yyy)`)
225
+ - Every task MUST have a grounded `Location` (see Step 5.e)
226
+ - Optional extension fields allowed AFTER the required fields (see Templates below)
227
+
228
+ 8. **Report** ✨:
229
+ ```markdown
230
+ ## ✅ Test Plan Complete
231
+
232
+ **Upstream status reconciliation** ⚠️ [MANDATORY before any "ready to continue" — Constraint 6 / FR-045]
233
+
234
+ **"Ready to continue" is a claim about the whole chain, not about the stage speaking.** So
235
+ before this report states any "can continue / ready" conclusion, it MUST **read** each upstream
236
+ stage's pending status on the entries that stage produced, and **state** what it found. The
237
+ over-declaration this replaces: `/specpro-tasks` closed with "✅ Ready to continue
238
+ implementation" while the design side had not taken a single step (`specs/plan.md` → Constraint 6).
239
+
240
+ **Two things, neither optional**:
241
+
242
+ 1. **Say it when the status is clean too.** "Nothing was mentioned" and "nothing is pending"
243
+ are different statements, and the first cannot be told apart from "forgot to look".
244
+ 2. **Skipped and processed counts are listed separately** — never merged into one "handled" number.
245
+
246
+ **Report shape** — every upstream gets a line, **including when it has nothing pending**
247
+ (indented, not fenced: several of these blocks sit inside an enclosing fence, and a nested
248
+ fence would close the outer one early):
249
+
250
+ Upstream reconciliation (Constraint 6)
251
+ <upstream>: N pending · M processed
252
+ Verdict: <clear to continue | upstream debts listed above>
253
+
254
+ ⚠️ **Report — do not block.** The mechanism self-heals: an upstream that completes marks its
255
+ downstream `update`. Blocking would need a judgement of "what counts as a debt", and that
256
+ judgement *is* the downstream reading its upstreams — reporting is its only legitimate form.
257
+
258
+ ⚠️ **Copied verbatim across `specpro.{specify,plan,tasks,test-plan,test-implement}.md`** (five
259
+ sites; do not exist as one because each command document is deployed and read on its own).
260
+ Only the "This stage's upstreams" line below differs per file — **change all five together**.
261
+
262
+ **This stage's upstreams**: `specify` · `plan` · `tasks` — pending means a source entry changed
263
+ after the last `Test-plan Runs` entry, or its matrix row still reads `pending-impl`.
264
+
265
+ **Test Tasks File**: specs/test-tasks.md
266
+
267
+ **Coverage Matrix**:
268
+ - FRs total: N | fully/planned covered: X | pending-impl (no component yet): Y | manual: Z
269
+ - Layer coverage: IT tasks: a | CE tasks: b | AE tasks: c
270
+ - [Full mode only] Layer coverage RATE: (covered cells / applicable cells)%
271
+
272
+ **Existing Assets Registered** (from grounding scan):
273
+ - [asset path] → [matrix cell]
274
+
275
+ **Infrastructure Gaps → INF Tasks** (from grounding scan):
276
+ - [gap description] → INF-0xx: [task title]
277
+
278
+ **Boundary confirmation with tasks.md**:
279
+ - Unit-test ownership confirmed: [N FRs] registered as tasks.md-unit-covered / core/src-embedded-covered; NO unit tasks created here
280
+
281
+ **`[test-plan]` issues** (incremental mode only): [N open on entry] → accepted: a | rejected: b | re-routed: c
282
+ ```
283
+
284
+ 9. **Do NOT update spec.md** ⚠️ [CRITICAL BOUNDARY]:
285
+ - test-plan does NOT modify Lifecycle fields (spec/plan/tasks statuses untouched)
286
+ - Test coverage state is tracked by the **matrix status column inside test-tasks.md itself**, updated by `/specpro-test-implement`
287
+ - **The one file outside test-tasks.md this command may write**: `specs/implement_issues.md`.
288
+ ⚠️ **Two acts, and only one of them is section-scoped** (the same split this file's `writes:`
289
+ unit states): **appending** a finding is **routing** — it goes to whichever section owns
290
+ the **fix**, not to a section this command owns; **marking `[x]`** is scoped — this command
291
+ marks **only `[test-plan]` entries** `[x]` with a resolution note (Step 7).
292
+ ⚠️ **A sentence reading "and only the `[test-plan]` section" collapses the two** and abolishes
293
+ the routing act. (Truth: `specs/contracts/ledger.md` → `## Write boundary` — pointed at, not
294
+ restated.)
295
+ ⇒ **Concretely, the three facts, so that no later edit can re-merge them**:
296
+ · it **MAY append** a finding to **any** section — that is routing, and a finding is routed
297
+ to whichever section owns its **fix**, not to a section this command owns;
298
+ · it marks `[x]` **only** in `[test-plan]` — that, and only that, is section-scoped;
299
+ · it touches **neither** `specs/spec.md`, `specs/plan.md`, `specs/tasks.md` **nor** any
300
+ other command's section, beyond the append above.
301
+ ⚠️ **⚠️ This paragraph was once spliced into the middle of its own first sentence** — the tail
302
+ `s` (of "entries") was left stranded and the boundary could not be recovered from the text
303
+ (`T234` / `ISS-207`). If a future edit reflows this bullet, **keep the three facts whole**: a
304
+ boundary sentence cut in half is worse than no sentence, because it still reads as a rule.
305
+
306
+ Context for test planning: $ARGUMENTS
307
+
308
+ ---
309
+
310
+ ## Task Templates 🧪 (migrated & simplified from legacy tasks.md Phase 6 testing standards)
311
+
312
+ **Field philosophy**: Environment/Observability fields are what prevented real incidents (e.g., an E2E task once ran against a nonexistent service because Environment was skippable). Keep those REQUIRED; trim ceremony fields to optional extensions.
313
+
314
+ ### Integration Test Template (IT-xxx)
315
+
316
+ **Required fields (4)**: `Location`, `Source`, `Mock`, `Validates`
317
+
318
+ ```markdown
319
+ - [ ] IT-XXX [domain] one-line title (FR-XXX[, FR-YYY])
320
+ Location: tests/integration-test/src/<target>/.../<Name>IT.kt
321
+ Source: [peer-behavior simulation description, e.g. "mock server returns 003.003/003.007/003.008; assert the client uses the matching security handshake format"]
322
+ Mock: [simulation approach, e.g. "in-process ServerSocket mock server"]
323
+ Validates: [observable results, e.g. "all three version branches complete handshake and the timeout path returns the correct error code"]
324
+ <!-- Optional extensions: Test Cases (Given-When-Then) / Risk Level / Execution Time(<30s) / CI/CD -->
325
+ ```
326
+
327
+ **Validation checklist** (minimal):
328
+ - [ ] Uses deterministic simulation (byte sequences/scripted peer), NOT a real server
329
+ - [ ] Location under a REAL module (grounded; or INF task creates the module)
330
+ - [ ] FR annotation present
331
+ - [ ] At least one error-path case (timeout / invalid response) unless task is trivially happy-path
332
+ - [ ] Test class named per convention: `*IT` suffix for IT test classes (e.g., `ConnectionMatrixIT`), distinguishing them from unit tests (`*Test`) and E2E tests (`*E2ETest`); fixture smoke tests may use `*Test` (e.g., `MockPeerSmokeTest`)
333
+
334
+ ### Component E2E Template (CE-xxx)
335
+
336
+ **Required fields (5)**: `Location`, `Environment`, `Setup`, `Validates`, `Teardown` (+ `Performance` required only when a corresponding NFR exists)
337
+
338
+ ```markdown
339
+ - [ ] CE-XXX [domain] one-line title (FR-XXX[, FR-YYY])
340
+ Location: tests/e2e-test/src/test/.../<Name>E2ETest.kt
341
+ Environment: [real system + container manifest, e.g. "Docker: <peer-service-image> (docker-compose.test.yml)"]
342
+ Setup: 1. [preparation step] 2. [@BeforeAll port-probe assumeTrue guard — skip when environment unavailable]
343
+ Validates: [observable results]
344
+ Teardown: 1. [cleanup step]
345
+ Performance: [REQUIRED only when a corresponding NFR exists, e.g. "first frame <2s"]
346
+ <!-- Optional extensions: Test Cases / Dependencies / CI/CD -->
347
+ ```
348
+
349
+ **Validation checklist** (minimal):
350
+ - [ ] Uses REAL external systems (a mock here means it should be an IT task)
351
+ - [ ] Environment-guard specified (skip, not fail, when environment unavailable)
352
+ - [ ] Setup/Teardown present (environment reproducibility + cleanup)
353
+ - [ ] FR annotation present
354
+ - [ ] Test class named per convention: `*E2ETest` suffix for CE/AE test classes (e.g., `RealPeerCompatibilityE2ETest`), distinguishing them from IT (`*IT`) and unit (`*Test`) classes
355
+
356
+ ### Application E2E Template (AE-xxx)
357
+
358
+ Same required fields as CE-xxx. Additionally:
359
+ - [ ] Exercises the app assembly / UI rendering chain / input-to-display path (not just a protocol flow — that's CE territory)
360
+ - [ ] **App-side grounding in Environment**: the app build command (from the app module's build config), the launch/driver mechanism (or an INF task creates the app-launch harness), and the display environment (virtual display for headless/CI)
361
+ - [ ] Visual-rendering Validates phrased as machine-checkable assertions (screenshot + pixel check / UI-tree check) — never "it looks right"
362
+
363
+ ### Anti-Patterns
364
+
365
+ - ❌ Location under a module that does not exist in the grounding scan (without an INF task creating it)
366
+ - ❌ Matrix cell left empty without a rationale
367
+ - ❌ Task generated for an FR marked `pending-impl`
368
+ - ❌ Integration task connecting to a real server (should be CE) / E2E task using mocks (should be IT)
369
+ - ❌ Unit test tasks created in this file (unit tests belong to tasks.md)
370
+ - ❌ AE task that never launches the real app process (an in-process UI-component test is component layer, not AE) / a matrix cell registering framework-less structural "UI tests" as UI coverage
371
+ - ❌ Duplicating a test that the grounding scan already registered as an existing asset
372
+
373
+ ---
374
+
375
+ ## Protocol Codec Module Rules 🌐 [CONDITIONAL — wire-format / protocol modules only]
376
+
377
+ **Activation**: decided by the **Activation Gate** (`.specpro/templates/protocol-golden-bytes-guide.md` §6) — triggers T3/T5 (the component under test is a wire-format codec or protocol message parser, or tests assert on raw bytes). Consume the verdict recorded upstream (§6.4); do not re-judge it. When activated, the coverage-matrix dimensions and the verification-method semantics MUST satisfy the following.
378
+
379
+ - **Mandatory matrix dimensions**: message/tile type × full-frame vs incremental context × parameters — combined systematically. A static full-frame test's tile distribution naturally skips low-frequency paths, which is exactly how a branch-level defect stays latent. Every protocol point with no coverage — and every inventory row carried as a GAP (§6.3) — is a matrix finding, not an omission to be tidied away: keep the row, mark the cell.
380
+ - **Test host is a coverage dimension**: an in-memory, network-free host is the default for codec matrices; a case that can only be expressed end-to-end carries timing coupling unrelated to the protocol and MUST be justified as a conformance spot-check rather than counted as protocol coverage (guide §3, *Layering*).
381
+ - **Verification-method semantic review**: the verification technique MUST match the semantics of the stream under test — a continuous stream is verified by feeding segments into a persistent decoder. `incomplete` reported by a one-shot full-buffer decode is a normal artefact of a continuous stream, NOT evidence that the peer truncated its data; a method-semantics mismatch produces false defect conclusions.
382
+ - **Peer-diversity coverage**: known differences between peer implementations are registered in the **Peer Diversity Registry** (see the test-task file's registry section) and drive the environment annotations — guessing unmeasured peer behaviour is forbidden.
383
+
@@ -0,0 +1,178 @@
1
+ ---
2
+ description: Generate the end-user manual (docs/user_manual/user-guide.md) from implemented features - audience is the non-technical end user; chapters trace to US/FR via HTML annotations, implemented-only gating against tasks.md, prose and headings follow Artifact Language
3
+ writes:
4
+ # This command's write surface: only what it produces AS THE PRODUCER of that
5
+ # (artifact, unit) pair. A write this command makes on a non-producer path is a
6
+ # boundary violation by definition (FR-051) and MUST NOT be declared here.
7
+ # The full ownership map is the UNION of every command's writes: block.
8
+ - artifact: docs/user_manual/user-guide.md
9
+ unit: "whole file, always rebuilt in full; screenshot REFERENCES are carried over but the image files are never touched"
10
+ ---
11
+
12
+ ## User Input
13
+
14
+ ```text
15
+ $ARGUMENTS
16
+ ```
17
+
18
+ You **MUST** consider the user input before proceeding (if not empty).
19
+
20
+ **Rerun safety — fully derived except HUMAN blocks; rebuilt in full on every run** ⚠️ [settled 2026-09-16]:
21
+
22
+ `docs/user_manual/user-guide.md` is a generated artifact: every chapter is derived from `spec.md` / `tasks.md`, and the file says so in its own header (*"Do not edit generated chapters by hand — wrap manual additions in HUMAN blocks"*). Rebuilding it wholesale therefore destroys no work of the user's — **provided** the two protected carriers below are carried over:
23
+
24
+ - **`<!-- HUMAN: … -->` … `<!-- /HUMAN -->` blocks** — re-inserted byte-identical at the chapter position they occupied before.
25
+ - **Screenshot files** — real images referenced from the manual are never deleted or repositioned.
26
+
27
+ This is why this command does **not** take the shared incremental rule (*detect the artifact; absent → initial, present → incremental; overwriting requires explicit AND re-confirmed intent*). That rule exists to protect edits a detection check cannot see — and here the edits that must survive are **explicitly marked**, not discovered. Protecting them costs a copy (Step 4), not a diff.
28
+
29
+
30
+ ### Scope Resolution 🆕 (FR-063 / T050 · v0.23)
31
+
32
+ 1. **作用域判定**: 当前工作目录位于 `specs/fNNN-简称/` 内 ⇒ **feature 作用域**(读写范围 = 本 feature 目录,由 `check-prerequisites.sh` 的作用域感知解析);位于仓库根或 `specs/` 根 ⇒ **母作用域**(读写母规格链)。feature 作用域内 MUST NOT 写母产物——唯一例外:**发现登记**(台账路由,`[specify]`/`[plan]` 分区)。
33
+ 2. **新会话首次执行**: 若 `specs/features.md` 存在且含 `active` 行、而用户未指明作用域 ⇒ **询问用户**在母作用域还是某个 feature 内工作,MUST NOT 自行挑选。
34
+ 3. 本命令的产物路径随之解析:feature 作用域下落 `<feature 目录>/`,母作用域下落 `specs/`。
35
+
36
+ ## Key Concept: End-User Manual 📖 [CRITICAL]
37
+
38
+ This command generates the **user manual** — the terminal artifact of the SDD chain, written for the non-technical end user (e.g., a teacher operating the classroom-management app). It is a **deliverable, not a process artifact**: no downstream command consumes it, and it never feeds back into the test/acceptance chain.
39
+
40
+ **Traceability contract** [CRITICAL]: every chapter must trace to spec.md content — feature chapters to User Stories / Acceptance Scenarios, troubleshooting rows to Error/Edge scenario outcomes, performance expectations to quantified FRs. Source annotations use HTML comments (invisible when rendered):
41
+
42
+ ```markdown
43
+ <!-- Source: US2, FR-xxx~FR-yyy -->
44
+ ```
45
+
46
+ **Quality red lines** [CRITICAL]:
47
+ - **No implementation leakage**: programming languages, build tools, protocol names, frameworks, plugin IDs, file paths, issue IDs (ISS-xxx), command names, progress percentages MUST NOT appear in user-visible prose.
48
+ - **Every step has an observable result**: each numbered step derived from an Acceptance Scenario carries that scenario's **Then** clause (rephrased in user language) as the expected outcome.
49
+ - **Implemented-only**: the manual MUST NOT describe behavior the app does not have. Scope is gated against tasks.md completion state (see Generation Steps, step 2).
50
+
51
+ **Language Rule** 🌐: the manual is a terminal artifact with no downstream grep consumers — prose **and** structural anchors (chapter headings) follow the project's **Artifact Language** (from `specs/constitution.md`). This deliberately differs from spec-class artifacts, whose anchors stay English.
52
+
53
+ **When it runs** ⚠️: this command has **no automatic trigger** — no other command invokes it, and it has no first-generation hook of its own (unlike `scenarios.md`, which `/specpro-plan` creates once on its initial run). Run it when a manual is wanted; re-run it when the implemented feature set has moved on.
54
+
55
+ ## Material Sourcing Map
56
+
57
+ ### Feature scope (FR-064, v0.23) ⚠️
58
+
59
+ **扫描面 = 母规格 + 每一个非 `deprecated` feature**(`specs/features.md` 登记文件,`status` ∈ `active`/`delivered`):各 feature 的 `spec.md`(+ 其 `tasks.md` 完成态)与母规格**一并**纳入 implemented-only 门控——feature 交付的功能若不入扫描面,手册对用户就是假的完整。每章的 HTML 来源标注写明出处(母规格 或 某 `fNNN-简称`);feature 缺 `tasks.md`(无法判完成态)⇒ 该 feature 的章节列入 "Planned Features" 附录并标注 `spec-only`。
60
+
61
+ | Manual section | Source | Transform |
62
+ |----------------|--------|-----------|
63
+ | Product introduction | spec.md Overview | one-line positioning + capability list in user language |
64
+ | System requirements | hardware/platform FRs, plan.md Target Platform | teacher-device / student-device table |
65
+ | Quick start | the Happy Path scenario of the primary User Story | shortest path to first success (numbered steps) |
66
+ | Feature guide (body) | one section per implemented User Story + its Acceptance Scenarios | Given-When-Then → numbered steps, each with expected outcome |
67
+ | Troubleshooting | Error/Edge Acceptance Scenarios across all USs | symptom (When) → expected message (Then) → what to do |
68
+ | FAQ | recurring Error scenarios + Independent Test friction points | question → short answer |
69
+ | Security & privacy notes | auth/crypto FRs, user-perceivable surface ONLY | password / encryption / credential notes |
70
+ | Performance reference | quantified FRs | translate to user terms (`<500ms` → "refreshes within about half a second") |
71
+
72
+ **Do NOT source from**: plan.md implementation phases, tasks.md task text, contracts/, research.md — these encode design/implementation concerns by definition.
73
+
74
+ ## Phase Detection
75
+
76
+ The manual is **always rebuilt in full** — there is no incremental mode. The two things that must survive a rebuild are **marked explicitly**, not discovered by a diff (see Rerun safety above).
77
+
78
+ | Condition | What happens |
79
+ |-----------|--------------|
80
+ | `docs/user_manual/user-guide.md` does NOT exist | full build |
81
+ | exists | full rebuild, with HUMAN blocks and screenshot references carried over |
82
+
83
+ ## Generation Steps
84
+
85
+ 1. **Setup**: Run `.specpro/scripts/bash/check-prerequisites.sh --json` from repo root.
86
+ - **spec.md REQUIRED** — missing: ❌ ERROR "Run /specpro-specify first", EXIT 1
87
+ - **tasks.md REQUIRED** — missing: ❌ ERROR "Run /specpro-tasks first (implemented-only gating needs task status)", EXIT 1
88
+ - **spec.md's User Scenarios section is the ONLY scenario source** — read the Independent Test and Acceptance Scenarios directly from it. (`scenarios.md` is a human's checking view, not an input here: it may lag the spec, and it holds nothing the spec does not.)
89
+ - **existing user-guide.md** — if present, read it for its HUMAN blocks and screenshot references (Step 4); **nothing else from it is kept**
90
+
91
+ 2. **Build the implemented-feature inventory** 📋 [CRITICAL gating]: from tasks.md, determine each User Story's implementation state — ⚠️ **per FR-064: enumerate the MOTHER spec's USs first, then each non-`deprecated` feature's USs from `specs/features.md` × `<fNNN-简称>/tasks.md`** —. A US is **implemented** only when ALL of its implementation tasks are `[x]`.'s implementation state. A US is **implemented** only when ALL of its implementation tasks are `[x]`. Unimplemented USs are excluded from the manual body and appear ONLY as single lines (title + one-sentence description, no how-to) in the "Planned Features" appendix section.
92
+
93
+ 3. **Extract per-US material**: for each implemented US collect — title, Acceptance Scenarios (Happy Path → step source; Error/Edge → troubleshooting pool), its FR group annotation, and its quantified FRs (for the performance reference and step outcomes).
94
+
95
+ 4. **Carry over the protected carriers** (only when the manual already exists) 🔒:
96
+ - every `<!-- HUMAN: <reason> -->` … `<!-- /HUMAN -->` block, **byte-identical**, re-inserted at the chapter position it occupied before
97
+ - every screenshot reference — the image files themselves are never touched, deleted, or repositioned
98
+ - a HUMAN block whose chapter no longer exists (its US was removed from the spec) moves to an **"Appendix — retained notes"** section; it is never dropped
99
+
100
+ 5. **Generate `docs/user_manual/user-guide.md`** 📖 per the Chapter Template (below):
101
+ - prose and headings in Artifact Language
102
+ - HTML source annotation at every chapter/section head
103
+ - screenshot placeholders `[Screenshot: <description>]` — real images are added by humans later; never invent image files
104
+ - header metadata: spec version, generation date, generation command
105
+
106
+ 6. **Quality self-check** (run BEFORE writing the file; fix and re-check until clean):
107
+ - **Leakage scan**: grep the draft for the project's tech vocabulary (build from plan.md Primary Dependencies + protocol/framework names + `T\d+`/`ISS-\d+`/`FR-\d+` in user-visible text — FR ids are allowed ONLY inside HTML comments)
108
+ - every numbered step has an expected result
109
+ - every chapter has a Source annotation
110
+ - implemented-only gate: no body chapter for an unimplemented US
111
+ - **protected carriers intact**: every HUMAN block counted in Step 4 is present in the new draft
112
+
113
+ 7. **Report** ✨: implemented US count covered, planned-US list, troubleshooting row count, screenshot placeholder count, **HUMAN blocks carried over**, leakage-scan result, and next-step hint: "Add real screenshots, then run /specpro-manual-test to verify the documented flows against the running app."
114
+
115
+ ## Chapter Template
116
+
117
+ > Headings below are STRUCTURE NAMES — render them in the Artifact Language. Section order is fixed; omit a section only when no source material exists for it (record the omission in the Report).
118
+
119
+ ```markdown
120
+ # <User Manual: product name>
121
+
122
+ **Applicable version**: <version>
123
+ **Last Updated**: <date>
124
+ <!-- Generated by /specpro-user-manual from spec.md v<version> on <date>.
125
+ Do not edit generated chapters by hand — wrap manual additions in HUMAN blocks. -->
126
+
127
+ ## About This Manual
128
+ (who should read it, convention symbols used)
129
+
130
+ ## Product Introduction
131
+ <!-- Source: spec.md Overview -->
132
+
133
+ ## System Requirements
134
+ <!-- Source: <hardware FRs>, plan.md Target Platform -->
135
+ (teacher-device / student-device table)
136
+
137
+ ## Installation & First Launch
138
+ (numbered steps with expected results)
139
+
140
+ ## Quick Start
141
+ <!-- Source: <primary US> Happy Path -->
142
+ (the shortest path to first success — 10 minutes or less)
143
+
144
+ ## Feature Guide
145
+ <!-- one subsection per implemented User Story -->
146
+ ### <Feature name>
147
+ <!-- Source: US<n>, FR-xxx~FR-yyy -->
148
+ **What it does**: ...
149
+ **When to use**: ...
150
+ **How to**: numbered steps, each with an expected observable result
151
+ **If something goes wrong**: link to the Troubleshooting rows derived from this US
152
+
153
+ ## Troubleshooting
154
+ <!-- Source: Error/Edge Acceptance Scenarios -->
155
+ | Symptom | Likely cause | What to do |
156
+ |---------|-------------|------------|
157
+
158
+ ## FAQ
159
+
160
+ ## Security & Privacy Notes
161
+ <!-- Source: <auth FRs>, user-perceivable surface only -->
162
+
163
+ ## Performance Reference
164
+ <!-- Source: quantified FRs, translated to user terms -->
165
+
166
+ ## Appendix
167
+ (glossary, keyboard shortcuts — only what the UI actually offers)
168
+
169
+ ## Planned Features
170
+ (single-line list of unimplemented USs — title + one sentence, no how-to)
171
+ ```
172
+
173
+ ## Output Metadata
174
+
175
+ End every run by appending to the Report:
176
+ - **Coverage**: X/Y implemented USs documented, Z FRs traced, N troubleshooting rows, M screenshot placeholders
177
+ - **Excluded (unimplemented)**: US list with blocking task ids
178
+ - **Self-check**: leakage scan PASS/FAIL, steps-with-outcome PASS/FAIL, source-annotation PASS/FAIL