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,488 @@
1
+ ---
2
+ description: Guide project constitution creation through AI auto-determination of project nature, clause extraction from embedded library, and automatic quality standards generation with multi-language template support.
3
+ handoffs:
4
+ - label: Build Specification
5
+ agent: specpro-specify
6
+ prompt: Implement the feature specification based on the generated constitution. I want to build...
7
+ writes:
8
+ # This command's write surface: only what it produces AS THE PRODUCER of that
9
+ # (artifact, unit) pair. A write this command makes on a non-producer path is a
10
+ # boundary violation by definition (FR-051) and MUST NOT be declared here.
11
+ # The full ownership map is the UNION of every command's writes: block.
12
+ - artifact: specs/constitution.md
13
+ unit: "whole file - the constitution it produces, including the Amendment Record"
14
+ - artifact: specs/implement_issues.md
15
+ unit: "the [constitution] section's entries marked [x]; the statistics table (**its own row only** — seven commands declare this artifact); appended ISS-NNN entries in any section — registration is routing; only [x]-marking is section-scoped"
16
+ ---
17
+
18
+ ## User Input
19
+
20
+ ```text
21
+ $ARGUMENTS
22
+ ```
23
+
24
+ You **MUST** consider the user input before proceeding. User input may include a project description (in the user's language) or be empty.
25
+
26
+ **Rerun safety — detect the artifact, default to incremental** ⚠️ [settled 2026-09-13]:
27
+
28
+ **Before writing `specs/constitution.md`, detect whether it already exists.** Use the SAME check in every command:
29
+
30
+ ```bash
31
+ [ -s specs/constitution.md ] && echo EXISTS || echo NEW # -s: exists AND non-empty (an empty placeholder counts as NEW)
32
+ ```
33
+
34
+ | Detection | Mode |
35
+ |-----------|------|
36
+ | **NEW** (absent or empty) | **Initial** — generate from scratch |
37
+ | **EXISTS** | **Incremental** — evolve it; **never silently regenerate from scratch** |
38
+
39
+ ⚠️ **This command carries the heaviest consequence of any in the set**: the constitution is the project's foundation — every downstream command reads it, and principles derived from it are baked into plan / tasks / test-plan. Regenerating it from scratch **silently invalidates all of that**.
40
+
41
+ **Overwriting an existing constitution requires explicit, confirmed intent:**
42
+ 1. Only when the user *explicitly* asks (in their own words) does the initial path run on an existing constitution.
43
+ 2. **Even then, confirm once more before writing** — name what will be replaced and what downstream artifacts (plan · tasks · test-plan · test-tasks) will be left resting on the old text; wait for the answer.
44
+ 3. **Silence is not consent.** An unspecified run on an existing constitution is ALWAYS incremental.
45
+
46
+ > **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 — this one among them**. Overwriting an artifact the user has been evolving is not recoverable within the session; the cost of asking is one prompt.
47
+
48
+
49
+ ### Scope Resolution 🆕 (FR-063 / T050 · v0.23)
50
+
51
+ 1. **作用域判定**: 当前工作目录位于 `specs/fNNN-简称/` 内 ⇒ **feature 作用域**(读写范围 = 本 feature 目录,由 `check-prerequisites.sh` 的作用域感知解析);位于仓库根或 `specs/` 根 ⇒ **母作用域**(读写母规格链)。feature 作用域内 MUST NOT 写母产物——唯一例外:**发现登记**(台账路由,`[specify]`/`[plan]` 分区)。
52
+ 2. **新会话首次执行**: 若 `specs/features.md` 存在且含 `active` 行、而用户未指明作用域 ⇒ **询问用户**在母作用域还是某个 feature 内工作,MUST NOT 自行挑选。
53
+ 3. 本命令的产物路径随之解析:feature 作用域下落 `<feature 目录>/`,母作用域下落 `specs/`。
54
+
55
+ ## Outline
56
+
57
+ This command uses a **guided AI-determination approach** with embedded clause library and **multi-language template support**. The process follows:
58
+
59
+ 1. **Language Configuration**: Set artifact language FIRST (before loading template)
60
+ 2. **Project Nature Assessment**: AI determines project type and calculates quality standards
61
+ 3. **Clauses Extraction**: Auto-extract appropriate clauses from embedded library
62
+ 4. **Technical Traits Selection**: User confirms technical characteristics
63
+ 5. **Template Loading**: Load language-specific template based on user choice
64
+ 6. **Constitution Generation**: Generate appropriate constitution in target language
65
+ 7. **Final Output**: Write constitution file
66
+
67
+ Follow this execution flow:
68
+
69
+ **CRITICAL: Language Configuration MUST happen BEFORE template loading to prevent AI language confusion**
70
+
71
+ **Branch: `--review-issues`** ⚠️ [when passed, this **replaces steps 0–8 below** — it is not an extra step in the flow]
72
+
73
+ This is the **only** consumer of the `[constitution]` section in `specs/implement_issues.md`. The
74
+ constitution is the project's foundation, so an amendment arriving by this route is a **targeted
75
+ edit of specific clauses**, never a regeneration — steps 0–8 generate a constitution from scratch
76
+ and MUST NOT run on this branch.
77
+
78
+ a. **Detect, then ask** (when `--review-issues` was not passed):
79
+ - Read the `[constitution]` section of `specs/implement_issues.md`; filter open `[ ]` entries.
80
+ - **None** → continue with the normal flow (steps 0–8). **No prompt.**
81
+ - **Some** → **ask**: "N open `[constitution]` issues. Process them first, or run normally?"
82
+ *Process first* → continue below. *Run normally* → continue with steps 0–8.
83
+ - **Rationale**: the flag used to be the whole switch — not passing it left pending issues
84
+ **silently unprocessed**, and **which issues were pending was invisible until the command
85
+ ran**. Detect-then-ask makes it an explicit choice; the flag only means *"don't ask me"*.
86
+
87
+ b. **If there is nothing to process** (no file, or no open `[ ]` entry in `[constitution]`):
88
+ display `✓ No pending [constitution] issues to process` and exit. Do not run steps 0–8.
89
+
90
+ c. **Process each open entry, in file order**:
91
+ - Read the entry's Problem / Recommendation / Evidence.
92
+ - Apply it as a **targeted edit to `specs/constitution.md`** — the specific clause it names.
93
+ ⚠️ **A carve-out or exception MUST be written as a CATEGORY, never as an instance**: a
94
+ clause reading "`<one named file>` is exempt" is a rule that governs exactly one file, and
95
+ the next member of its class falls through it untouched.
96
+ - ⚠️ **Write the enforcement point** (Core Principle I): **which step triggers it, what
97
+ condition fails, who stops.** A clause with no enforcement point is a statement, and the
98
+ Governance section's own rule is that such a clause **should be deleted rather than kept as
99
+ decoration** — so an amendment that cannot name one must be reported back, not written in.
100
+ - Mark **that entry** `[x]` in `specs/implement_issues.md`, and update that section's row in
101
+ the statistics table. ⚠️ **Marking is section-scoped: never mark another section's entries
102
+ `[x]`.**
103
+ ⚠️ **Appending is NOT section-scoped** — **登记即路由**: a command registers a finding in
104
+ whichever section owns its **fix**, not in its own. That is the ledger's **only** routing
105
+ act, and a rule reading "each commands owns only its own section" **abolishes it** while
106
+ looking like a tidiness rule. ⚠️ **The two acts must not be derived from one another.**
107
+ (Truth: `specs/contracts/ledger.md` → `## Write boundary` — **pointed at, not restated**.)
108
+
109
+ d. **Same round, no exceptions** ⚠️ [the half-recorded amendment is the failure this prevents]:
110
+ - Update `**Version**` and `**Last Amended**` in `specs/constitution.md`.
111
+ - Append the `Amendment Record` row — including the **受影响既有产物** column: name the
112
+ artifacts that depended on the clause as it was. An amendment that silently invalidates a
113
+ downstream derivation leaves it reading as if nothing changed.
114
+ - Run `.specpro/scripts/bash/verify-ledger.sh` and fix any violation before continuing.
115
+ ⚠️ Marking entries `[x]` changes the counts, so this applies here too.
116
+
117
+ e. **Then report** what was amended, and which artifacts the Amendment Record now lists as affected.
118
+
119
+ 0. **Language Configuration** 🌐 [FIRST STEP - BEFORE TEMPLATE LOADING]:
120
+
121
+ **a. Detect interaction language**: `INTERACTION_LANGUAGE = "zh" if Chinese detected, "en" otherwise`
122
+
123
+ **b. Display language selection**:
124
+ ```markdown
125
+ 🌐 Artifact Language
126
+
127
+ Select the language for the generated constitution:
128
+
129
+ 1️⃣ **English** (en) - Generate constitution in English
130
+ 2️⃣ **Chinese** (zh) - Generate constitution in Chinese
131
+ 3️⃣ **Japanese** (ja) - Generate constitution in Japanese
132
+ 4️⃣ **Korean** (ko) - Generate constitution in Korean
133
+
134
+ Your choice (1-4):
135
+ ```
136
+
137
+ **c. Set artifact language**: `ARTIFACT_LANGUAGE = selected code ("en", "zh", "ja", "ko")`
138
+
139
+ **d. Store for template selection**: `TEMPLATE_PATH = .specpro/templates/constitution-template.md` (single skeleton, shared by all artifact languages)
140
+
141
+ 1. **Load classification and clause frameworks**:
142
+ - The classification framework and clause library are embedded below (no external dependencies)
143
+ - Template will be loaded in step 5 AFTER language is determined
144
+
145
+ **PROJECT CLASSIFICATION FRAMEWORK** 📊 (Embedded reference)
146
+
147
+ **6 Project Types** (For AI auto-determination):
148
+ - **Type 1 - Prototype/MVP**: Concept validation, proof of concept, demo, no long-term maintenance
149
+ - **Type 2 - Personal/Team Tool**: Productivity scripts, internal utilities, helper tools, very small user base
150
+ - **Type 3 - Enterprise Internal App**: Internal OA systems, admin panels, department tools, no external exposure
151
+ - **Type 4 - General Business App**: External-facing business systems for regular users, customer-facing
152
+ - **Type 5 - Platform/Middleware**: Critical infrastructure, shared dependencies, component libraries, APIs
153
+ - **Type 6 - High-Risk/Compliant**: Financial, medical, government, security, life-safety related
154
+
155
+ **Quality Assurance Matrix** (Auto-calculated based on PROJECT_TYPE):
156
+ | PROJECT_TYPE | HIGH-RISK Coverage | MEDIUM-RISK Coverage | LOW-RISK Coverage |
157
+ |--------------|-------------------|---------------------|------------------|
158
+ | Type 1 (Prototype/MVP) | 70% | 50% | 0% |
159
+ | Type 2 (Personal/Team Tool) | 80% | 60% | 0% |
160
+ | Type 3 (Enterprise Internal App) | 85% | 70% | 30% |
161
+ | Type 4 (General Business App) | 90% | 75% | 40% |
162
+ | Type 5 (Platform/Middleware) | 95% | 85% | 50% |
163
+ | Type 6 (High-Risk/Compliant) | 98% | 90% | 70% |
164
+
165
+ **Risk Assessment Criteria** (For downstream workflows to classify individual modules):
166
+ - **HIGH Risk Indicators**: Financial transactions, payment processing, medical data, government services, authentication systems
167
+ - **MEDIUM Risk Indicators**: User data processing, business logic, API endpoints, database operations, session management
168
+ - **LOW Risk Indicators**: UI components, helper functions, development tools, diagnostic features, configuration management
169
+
170
+ **CLAUSES LIBRARY** 📚 (Embedded reference for clause extraction)
171
+
172
+ **Universal Clauses** (Required for ALL projects):
173
+ - **1.1 Version Control**: Git-based tracking, meaningful commits, branch protection, PR reviews
174
+ - **1.2 Documentation Requirements**: API docs, architecture diagrams, README, CHANGELOG
175
+ - **1.3 Code Quality**: Linting, complexity limits, no hardcoded credentials, meaningful naming
176
+
177
+ **Type-Specific Clauses** (Based on PROJECT_TYPE):
178
+ - **2.1 Prototype/MVP**: Rapid Iteration - Speed over perfection, technical debt acceptable, minimal docs
179
+ - **2.2 Personal/Team Tool**: Simplified Process - Core functionality tested, UI optional, basic error handling
180
+ - **2.3 Enterprise Internal App**: Internal Stability - Business logic tested, data integrity critical, internal auth
181
+ - **2.4 General Business App**: User Experience - User-facing features tested, performance optimized, user-friendly errors
182
+ - **2.5 Platform/Middleware**: Reliability - Near-zero downtime, backwards compatibility, performance SLAs
183
+ - **2.6 High-Risk/Compliant**: Compliance - Regulatory compliance, security audits, data protection, incident response
184
+
185
+ **Risk-Specific Clauses** (Based on project characteristics):
186
+ - **3.1 HIGH Risk**: Security First - Security reviews, penetration testing, encryption, strict access controls
187
+ - **3.2 MEDIUM Risk**: Quality Assurance - Code reviews, integration testing, performance testing, logging standards
188
+ - **3.3 LOW Risk**: Basic Quality - Core functionality testing, simplified reviews, basic error handling
189
+
190
+ **Technical Clauses** (User-confirmed characteristics):
191
+ - **4.1 Multiplatform Architecture**: Shared code platform-independent, platform-specific code isolated, consistent behavior
192
+ - **4.2 Protocol-Oriented Design**: Protocols documented, independently testable, version compatibility requirements
193
+ - **4.3 Performance Critical**: Performance requirements defined, performance testing mandatory, resource limits
194
+
195
+ 2. **Project Nature Assessment** 🤖 [AI AUTO-DETERMINATION]:
196
+
197
+ **a. Extract project description from user input**:
198
+ - If `$ARGUMENTS` contains project description: Extract keywords and context
199
+ - If `$ARGUMENTS` is empty: Ask user to describe their project briefly
200
+ - Example inputs to handle:
201
+ * "I want to build a personal accounting tool"
202
+ * "Enterprise internal OA system"
203
+ * "Financial trading platform"
204
+ * Empty → Prompt: "Please briefly describe your project:"
205
+
206
+ **b. AI determines project type** (NO user selection):
207
+ - Analyze project description against the 6 project types in PROJECT CLASSIFICATION FRAMEWORK
208
+ - **Keywords analysis**: Identify project characteristics from description
209
+ - **Auto-select project type** based on analysis:
210
+ * **Type 1 (Prototype/MVP)**: Keywords like "demo", "proof of concept", "test", "MVP", "prototype"
211
+ * **Type 2 (Personal/Team Tool)**: Keywords like "personal tool", "utility", "helper", "small team", "script"
212
+ * **Type 3 (Enterprise Internal App)**: Keywords like "internal", "OA", "admin", "CMS", "HR system"
213
+ * **Type 4 (General Business App)**: Keywords like "e-commerce", "SaaS", "platform", "user-facing", "business"
214
+ * **Type 5 (Platform/Middleware)**: Keywords like "library", "component", "infrastructure", "API", "framework"
215
+ * **Type 6 (High-Risk/Compliant)**: Keywords like "financial", "trading", "medical", "payment", "government"
216
+ - **Store result**: `PROJECT_TYPE = [1-6]`
217
+
218
+ **c. AI determines quality assurance standards** (based on PROJECT_TYPE):
219
+ - Use the Quality Assurance Matrix from PROJECT CLASSIFICATION FRAMEWORK
220
+ - **Auto-calculate coverage targets**:
221
+ * Type 1: `HIGH_RISK_COVERAGE = "70%"`, `MEDIUM_RISK_COVERAGE = "50%"`, `LOW_RISK_COVERAGE = "0%"`
222
+ * Type 2: `HIGH_RISK_COVERAGE = "80%"`, `MEDIUM_RISK_COVERAGE = "60%"`, `LOW_RISK_COVERAGE = "0%"`
223
+ * Type 3: `HIGH_RISK_COVERAGE = "85%"`, `MEDIUM_RISK_COVERAGE = "70%"`, `LOW_RISK_COVERAGE = "30%"`
224
+ * Type 4: `HIGH_RISK_COVERAGE = "90%"`, `MEDIUM_RISK_COVERAGE = "75%"`, `LOW_RISK_COVERAGE = "40%"`
225
+ * Type 5: `HIGH_RISK_COVERAGE = "95%"`, `MEDIUM_RISK_COVERAGE = "85%"`, `LOW_RISK_COVERAGE = "50%"`
226
+ * Type 6: `HIGH_RISK_COVERAGE = "98%"`, `MEDIUM_RISK_COVERAGE = "90%"`, `LOW_RISK_COVERAGE = "70%`
227
+ - **Store results**: `HIGH_RISK_COVERAGE`, `MEDIUM_RISK_COVERAGE`, `LOW_RISK_COVERAGE`
228
+
229
+ 3. **Clauses Extraction** 📚 [AUTO-EXTRACTION FROM EMBEDDED LIBRARY]:
230
+
231
+ **a. Extract mandatory clauses** (P0 - Universal + Type-Specific):
232
+ - **Universal Clauses** (ALL projects):
233
+ * 1.1 Version Control: Git-based tracking, meaningful commits, branch protection, PR reviews
234
+ * 1.2 Documentation Requirements: API docs, architecture diagrams, README, CHANGELOG
235
+ * 1.3 Code Quality: Linting, complexity limits, no hardcoded credentials
236
+ - **Type-Specific Clause** (Based on PROJECT_TYPE):
237
+ * Type 1: Rapid Iteration Clause
238
+ * Type 2: Simplified Process Clause
239
+ * Type 3: Internal Stability Clause
240
+ * Type 4: User Experience Clause
241
+ * Type 5: Reliability Clause
242
+ * Type 6: Compliance Clause
243
+ - **Store**: `EXTRACTED_CLAUSES_P0 = [Universal_3_Clauses + Type_1_Clause]`
244
+
245
+ **b. Extract risk-specific clauses** (P1):
246
+ - **Risk-Specific Clause** (Based on project characteristics):
247
+ * HIGH Risk characteristics detected: Security First Clause
248
+ * MEDIUM Risk characteristics detected: Quality Assurance Clause
249
+ * LOW Risk characteristics detected: Basic Quality Clause
250
+ - **Quality Assurance Clauses** (From matrix):
251
+ * 5.1 Test Coverage Requirements: HIGH-RISK >[XX]%, MEDIUM-RISK >[YY]%, LOW-RISK >[ZZ]%
252
+ * 5.2 Code Review Requirements: Based on PROJECT_TYPE strictness level
253
+ - **Store**: `EXTRACTED_CLAUSES_P1 = [Risk_Clause + QA_2_Clauses]`
254
+
255
+ **c. Extract technical trait clauses** (P2 - User-confirmed characteristics):
256
+
257
+ **AI auto-detection** (based on project description keywords):
258
+ - **Architecture Traits**:
259
+ * Multiplatform: keywords like "multiplatform", "cross-platform", "iOS & Android", "desktop & mobile"
260
+ * Microservices: keywords like "microservice", "distributed", "service mesh"
261
+ * Event-Driven: keywords like "event-driven", "async", "message queue", "kafka"
262
+ * Layered Architecture: keywords like "layered", "MVC", "tiered architecture"
263
+ - **Interface Traits**:
264
+ * RESTful API: keywords like "REST", "RESTful", "HTTP API", "REST API"
265
+ * GraphQL: keywords like "GraphQL", "GQL", "graph"
266
+ * gRPC: keywords like "gRPC", "rpc", "protobuf"
267
+ * WebSocket: keywords like "WebSocket", "realtime", "socket", "ws://"
268
+ * Webhook: keywords like "webhook", "callback", "notification"
269
+ - **Data Traits**:
270
+ * Data-Intensive: keywords like "big data", "analytics", "data warehouse", "reporting"
271
+ * Realtime Data: keywords like "realtime", "streaming", "low latency", "live"
272
+ * High Concurrency: keywords like "high concurrency", "scale", "concurrent", "thousands of users"
273
+ * Data Consistency: keywords like "transactional", "ACID", "financial", "payment", "inventory"
274
+
275
+ **Display technical traits selection menu**:
276
+ ```markdown
277
+ 🔧 Technical Traits Confirmation
278
+
279
+ Based on your project description, AI detected the following technical traits:
280
+ [AI-detected traits list]
281
+
282
+ Please confirm or modify your technical traits:
283
+
284
+ **Architecture Traits**:
285
+ ☐ 1.1 Multiplatform Architecture
286
+ ☐ 1.2 Microservices Architecture
287
+ ☐ 1.3 Event-Driven Architecture
288
+ ☐ 1.4 Layered Architecture
289
+
290
+ **Interface Traits**:
291
+ ☐ 2.1 RESTful API
292
+ ☐ 2.2 GraphQL API
293
+ ☐ 2.3 gRPC API
294
+ ☐ 2.4 WebSocket
295
+ ☐ 2.5 Webhook
296
+
297
+ **Data Traits**:
298
+ ☐ 3.1 Data-Intensive
299
+ ☐ 3.2 Realtime Data
300
+ ☐ 3.3 High Concurrency
301
+ ☐ 3.4 Data Consistency Critical
302
+
303
+ **Performance Traits**:
304
+ ☐ 4.1 Low Latency Requirements
305
+ ☐ 4.2 High Throughput Requirements
306
+ ☐ 4.3 Resource Constrained
307
+
308
+ **Security Traits**:
309
+ ☐ 5.1 Authentication/Authorization
310
+ ☐ 5.2 Data Encryption
311
+ ☐ 5.3 Audit Logging
312
+ ☐ 5.4 Data Masking
313
+
314
+ **Protocol Traits**:
315
+ ☐ 6.1 Protocol-Oriented Design
316
+ ☐ 6.2 Streaming Protocol
317
+ ☐ 6.3 Message Queue
318
+
319
+ **Deployment Traits**:
320
+ ☐ 7.1 Containerization
321
+ ☐ 7.2 Serverless
322
+ ☐ 7.3 Edge Computing
323
+
324
+ **Monitoring Traits**:
325
+ ☐ 8.1 Observability
326
+ ☐ 8.2 Debuggability
327
+
328
+ **Testing Traits**:
329
+ ☐ 9.1 Test-Driven Development
330
+ ☐ 9.2 Behavior-Driven Development
331
+
332
+ **Extensibility Traits**:
333
+ ☐ 10.1 Plugin Architecture
334
+ ☐ 10.2 Scalability
335
+
336
+ **Selection Guide**:
337
+ - Use ☑️ to select applicable traits
338
+ - AI will pre-select based on project description
339
+ - Not all traits apply to every project
340
+ - Select traits that impact your development approach
341
+
342
+ Enter selections (e.g., "1.1 2.1 3.4" or "confirmed" to accept AI suggestions):
343
+ ```
344
+
345
+ **Handle user input**:
346
+ - If "confirmed": Use AI-detected traits
347
+ - If specific trait IDs (e.g., "1.1 2.1 3.4"): Parse and use selected traits
348
+ - If empty: Ask for at least one selection
349
+
350
+ **Extract corresponding technical clauses**:
351
+ For each selected trait, include the corresponding technical clause:
352
+ - Architecture trait → Clause defines architecture requirements
353
+ - Interface trait → Clause defines interface and communication requirements
354
+ - Data trait → Clause defines data handling and consistency requirements
355
+ - Performance trait → Clause defines performance and resource requirements
356
+ - Security trait → Clause defines security and compliance requirements
357
+ - Protocol trait → Clause defines protocol and communication requirements
358
+ - Deployment trait → Clause defines deployment and infrastructure requirements
359
+ - Monitoring trait → Clause defines observability and debuggability requirements
360
+ - Testing trait → Clause defines testing methodology requirements
361
+ - Extensibility trait → Clause defines extension and scalability requirements
362
+
363
+ - **Store**: `EXTRACTED_CLAUSES_P2 = [Technical_Clauses for all selected traits]`
364
+
365
+ **d. Display extracted technical clauses for confirmation**:
366
+ ```markdown
367
+ 🔧 Technical Clauses Selected
368
+
369
+ [List of selected technical traits with their corresponding clauses]
370
+
371
+ Total technical clauses extracted: [N]
372
+
373
+ Confirm these technical clauses? (yes/modify)
374
+ ```
375
+
376
+ **e. Handle user confirmation**:
377
+ - If "yes": Proceed with extracted technical clauses
378
+ - If "modify": Allow user to add/remove specific traits, re-extract
379
+ - **Finalize**: `EXTRACTED_CLAUSES_P2 = [All confirmed technical clauses]`
380
+
381
+ 4. **Load Template** 📄 [AFTER LANGUAGE CONFIGURATION]:
382
+
383
+ **CRITICAL**: Template loading happens AFTER language selection to prevent AI confusion
384
+
385
+ **a. Single skeleton template (language-independent)**:
386
+ - `TEMPLATE_PATH = .specpro/templates/constitution-template.md`
387
+ - This is the ONLY constitution template, used for ALL artifact languages
388
+ - Fixed structural anchors in the skeleton (section headings such as `Core Principles`, `Governance`; the `Version` / `Ratified` / `Last Amended` labels) are ALWAYS English, regardless of [ARTIFACT_LANGUAGE]
389
+ - Placeholder VALUES (`[PRINCIPLE_N_NAME]`, `[SECTION_N_CONTENT]`, etc.) are generated content, NOT anchors: replace them in [ARTIFACT_LANGUAGE]
390
+
391
+ **b. Read template content**: Load the template file content
392
+
393
+ 5. **Draft the constitution content** 📝 [IN TARGET LANGUAGE]:
394
+
395
+ **a. CRITICAL LANGUAGE INSTRUCTION (two-layer language rule)**:
396
+ ```markdown
397
+ **LANGUAGE REQUIREMENT**:
398
+ - ALL constitution PROSE content MUST be generated in: [ARTIFACT_LANGUAGE]
399
+ - Ignore the language of examples in the template
400
+ - Structural anchors are ALWAYS English, regardless of [ARTIFACT_LANGUAGE]:
401
+ * Section headings: `Core Principles`, `Governance`, `Project Clauses`
402
+ * Field labels: `Version`, `Ratified`, `Last Amended`, `Artifact Language`
403
+ - Generated content (principle names/descriptions, section content, governance rules) MUST be in [ARTIFACT_LANGUAGE]
404
+ - Technical terms may remain in English (API, REST, JSON, etc.)
405
+ ```
406
+
407
+ **b. Replace placeholders**:
408
+ - `[PROJECT_NAME]` → Derived from input (in target language)
409
+ - `[CONSTITUTION_VERSION]` → "1.0.0" or increment
410
+ - `[RATIFICATION_DATE]` → Today (YYYY-MM-DD)
411
+ - `[LAST_AMENDED_DATE]` → Today (YYYY-MM-DD)
412
+ - `[PRINCIPLE_N_NAME]` → Principle name in target language
413
+ - `[PRINCIPLE_N_DESCRIPTION]` → Principle description in target language
414
+ - `[SECTION_N_NAME]` → Section name in target language
415
+ - `[SECTION_N_CONTENT]` → Section content in target language
416
+ - `[GOVERNANCE_RULES]` → Governance rules in target language
417
+
418
+ **c. Add Project Clauses section** (content in [ARTIFACT_LANGUAGE]):
419
+ ```markdown
420
+ ## Project Clauses
421
+
422
+ **Universal Clauses**:
423
+ - 1.1 Version Control: [details in ARTIFACT_LANGUAGE]
424
+ - 1.2 Documentation: [details in ARTIFACT_LANGUAGE]
425
+ - 1.3 Code Quality: [details in ARTIFACT_LANGUAGE]
426
+
427
+ **Type-Specific Clause** ([Type_N]): [content in ARTIFACT_LANGUAGE]
428
+
429
+ **Risk-Specific Clause** ([Risk_Level]): [content in ARTIFACT_LANGUAGE]
430
+
431
+ **Quality Assurance Clauses**:
432
+ - Test Coverage: HIGH >[XX]%, MEDIUM >[YY]%, LOW >[ZZ]%
433
+ - Code Review: [requirements in ARTIFACT_LANGUAGE]
434
+
435
+ [Technical Clauses if applicable, in ARTIFACT_LANGUAGE]
436
+ ```
437
+
438
+ **d. Add Artifact Language section**:
439
+ ```markdown
440
+ **Artifact Language**: [ARTIFACT_LANGUAGE]
441
+ **Purpose**: Define language for generated specs and artifacts
442
+ ```
443
+
444
+ **e. Include/exclude principles**:
445
+ - Based on project type and user-confirmed technical characteristics
446
+ - Remove unused principle sections entirely
447
+
448
+ 6. **Quality validation** ✅:
449
+
450
+ **a. Language consistency check**:
451
+ - Verify ALL prose content is in [ARTIFACT_LANGUAGE]
452
+ - Check for language mixing (except technical terms and the fixed English structural anchors listed in Step 5a)
453
+
454
+ **b. Check placeholders**: No `[ALL_CAPS_IDENTIFIER]` tokens remain
455
+
456
+ **c. Validate consistency**: Principles declarative, testable, no vague language
457
+
458
+ **d. Validate formatting**: Markdown hierarchy, consistent spacing, no trailing whitespace
459
+
460
+ 7. **Write final constitution** 💾:
461
+
462
+ Write to `specs/constitution.md`, verify successful write
463
+
464
+ 8. **Output summary** 📊:
465
+
466
+ ```markdown
467
+ ✅ Constitution Generated Successfully
468
+
469
+ 📋 Project: [Type N - Name]
470
+ 🌐 Languages: Artifact=[ARTIFACT_LANGUAGE], Interaction=[INTERACTION_LANGUAGE]
471
+ 📊 Quality: HIGH>[XX]%, MEDIUM>[YY]%, LOW>[ZZ]%
472
+ 📋 Clauses: [N] total extracted
473
+
474
+ 📄 Location: specs/constitution.md
475
+ 🎯 Next: /specpro-specify
476
+ ```
477
+
478
+ ## Important Notes
479
+
480
+ **Language Priority**: Language configuration happens FIRST to prevent AI confusion from English template
481
+
482
+ **Template Fallback**: If language-specific template doesn't exist, use English template but generate content in target language
483
+
484
+ **Clauses Library**: Fully embedded, auto-extracted based on project type, user can modify
485
+
486
+ **Risk Levels**: Constitution defines QA standards, downstream workflows classify individual modules
487
+
488
+ **Formatting**: Consistent headings, <100 char lines, single blank lines between sections
@@ -0,0 +1,115 @@
1
+ ---
2
+ description: Initialize a new feature (independent second-level spec) — dedup check, name confirmation, fNNN directory + registry row, then hand off to /specpro-specify
3
+ writes:
4
+ # This command's write surface: only what it produces AS THE PRODUCER of that
5
+ # (artifact, unit) pair (FR-051). ⚠️ specs/spec.md is deliberately NOT here:
6
+ # the feature mechanism writes ZERO bytes to the mother spec (FR-013 v0.23 /
7
+ # FR-015 — the whole point of the standalone registry file).
8
+ - artifact: specs/features.md
9
+ unit: "the registry file — skeleton on first creation (field legend + empty table); exactly ONE meta row appended per created feature; status transitions (active/delivered/deprecated). Never any US/FR/design content"
10
+ - artifact: specs/fNNN-简称/
11
+ unit: "the empty feature directory created at init (the spec inside it is produced by /specpro-specify, not by this command)"
12
+ handoffs:
13
+ - label: Write the feature spec
14
+ agent: specpro-specify
15
+ prompt: Work in feature scope — the target directory is specs/fNNN-简称/ (created and registered by /specpro-feature). Generate the feature's spec.md there from templates/feature-spec-template.md. The mother spec (specs/spec.md) is NOT the target and MUST stay byte-identical.
16
+ send: true
17
+ ---
18
+
19
+ ## User Input
20
+
21
+ ```text
22
+ $ARGUMENTS
23
+ ```
24
+
25
+ You **MUST** consider the user input before proceeding (if not empty).
26
+
27
+ **Rerun safety — init is idempotent per feature, never a regenerate** ⚠️:
28
+
29
+ This command **initializes**: dedup-check → confirm the name → allocate the next `fNNN` → create the directory → append ONE registry row. If the requested feature **already exists** (name or id in `specs/features.md`), report it and stop — this command never re-initializes, never renumbers, and never touches an existing feature directory. Spec content inside the directory belongs to `/specpro-specify`, not here.
30
+
31
+ ---
32
+
33
+
34
+ ### Scope Resolution 🆕 (FR-063 / T050 · v0.23)
35
+
36
+ 1. **作用域判定**: 当前工作目录位于 `specs/fNNN-简称/` 内 ⇒ **feature 作用域**(读写范围 = 本 feature 目录,由 `check-prerequisites.sh` 的作用域感知解析);位于仓库根或 `specs/` 根 ⇒ **母作用域**(读写母规格链)。feature 作用域内 MUST NOT 写母产物——唯一例外:**发现登记**(台账路由,`[specify]`/`[plan]` 分区)。
37
+ 2. **新会话首次执行**: 若 `specs/features.md` 存在且含 `active` 行、而用户未指明作用域 ⇒ **询问用户**在母作用域还是某个 feature 内工作,MUST NOT 自行挑选。
38
+ 3. 本命令的产物路径随之解析:feature 作用域下落 `<feature 目录>/`,母作用域下落 `specs/`。
39
+
40
+ ## Purpose
41
+
42
+ Anchor the executor to the target directory for a **new, independent feature** — a complete functional unit, NOT an augmentation of existing functionality (FR-009 v0.23). Everything after initialization is **specify's job, unchanged**: generation, clarification, and quality checks all run in feature scope exactly as they do for the mother spec. This command does **not** generate any spec content, does **not** run clarify/qc, and does **not** touch the mother spec — zero bytes (FR-013/FR-015).
43
+
44
+ Contract: `specs/contracts/feature-spec-command.md` (v1.1) — the authoritative version of everything below.
45
+
46
+ ---
47
+
48
+ ## Execution Steps
49
+
50
+ ### Step 1 — Precondition: the mother spec exists
51
+
52
+ ```bash
53
+ [ -s specs/spec.md ] || { echo "❌ no mother spec (specs/spec.md) — a feature inherits from it; run /specpro-constitution + /specpro-specify first"; exit 1; }
54
+ ```
55
+
56
+ ### Step 2 — Scope check: no nesting (FR-012)
57
+
58
+ If the current working directory is inside `specs/fNNN-简称/`:
59
+
60
+ > ℹ️ **You are inside feature `fNNN-简称`. feature commands do not nest. The new feature will be created in the MOTHER scope** (repo root, next to `specs/spec.md`), as `f(NNN+1)`.
61
+
62
+ State this explicitly and continue in mother scope (do not silently pick — the user must see where the new feature lands).
63
+
64
+ ### Step 3 — Dedup check (FR-012 ①)
65
+
66
+ The new feature is an **independent new function** — it must not overlap the mother spec's existing requirements:
67
+
68
+ - Read `specs/spec.md`'s US/FR titles and the user's description.
69
+ - **Overlap found** (the description substantially restates an existing mother FR/US) → present BOTH readings to the user: "this looks like an augmentation of `<FR-id>` rather than a new feature — extend the mother spec, or proceed as an independent feature?" Proceed only on the user's explicit choice.
70
+ - No overlap → continue.
71
+
72
+ ### Step 4 — Name confirmation + id allocation (FR-012 ②③ / FR-010 / FR-011)
73
+
74
+ 1. From the user's input, propose a 简称 (kebab-case, 2-4 words).
75
+ 2. **Show it to the user for confirmation** — never silently pick.
76
+ 3. Validate against `specs/features.md` (create the file from the skeleton below if absent):
77
+ - 简称 already used → refuse, propose alternatives (FR-011)
78
+ - Format must be `fNNN-简称` (three-digit zero-padded, monotonic from `001`); **never reuse** a deprecated feature's number (FR-010/FR-011)
79
+
80
+ ### Step 5 — Create + register (FR-012 ③)
81
+
82
+ ```bash
83
+ mkdir -p "specs/fNNN-简称"
84
+ ```
85
+
86
+ Append EXACTLY ONE row to `specs/features.md`:
87
+
88
+ ```markdown
89
+ | fNNN | 简称 | active | specs/fNNN-简称/ |
90
+ ```
91
+
92
+ **Never** write anything else to the registry, and **never** write ANY byte to `specs/spec.md` — verify before finishing:
93
+
94
+ ```bash
95
+ git diff --stat -- specs/spec.md # must be EMPTY
96
+ ```
97
+
98
+ ### Step 6 — Hand off to /specpro-specify
99
+
100
+ The frontmatter `handoffs` (send: true) carries the target directory: `/specpro-specify` generates `specs/fNNN-简称/spec.md` from `templates/feature-spec-template.md`, then clarify → qc → "review your spec or plan" — **identical to the main flow**. When it finishes, report the feature as created and point the user at the new spec.
101
+
102
+ ---
103
+
104
+ ## Registry skeleton (`specs/features.md`, first creation only)
105
+
106
+ ```markdown
107
+ # Feature Registry
108
+
109
+ 每一个 feature(独立第二级规格,`specs/fNNN-简称/`)在此登记。本文件**只记元信息**——feature 的需求内容住各自目录,MUST NOT 记入母规格(FR-013)。维护者:`/specpro-feature`(创建时只增一行;状态转换见下)。
110
+
111
+ `status` 取值:`active`(推进中)· `delivered`(已完成交付)· `deprecated`(废弃,编号保留不复用)。
112
+
113
+ | id | name | status | path |
114
+ |----|------|--------|------|
115
+ ```