@dzhechkov/p-replicator 1.0.1 → 1.1.0

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 (19) hide show
  1. package/README.md +25 -3
  2. package/package.json +6 -3
  3. package/src/commands/doctor.js +2 -2
  4. package/src/commands/list.js +1 -1
  5. package/templates/.claude/rules/replicate-pipeline.md +13 -1
  6. package/templates/.claude/rules/skill-interface-protocol.md +148 -0
  7. package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +116 -63
  8. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/01-detect-parse.md +329 -0
  9. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/02-analyze-map.md +449 -0
  10. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/03-generate-p0.md +630 -0
  11. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/04-generate-p1.md +537 -0
  12. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/05-generate-p2p3.md +512 -0
  13. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/06-package-deliver.md +710 -0
  14. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/07-harvest-feedback.md +286 -0
  15. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/08-skill-composition.md +378 -0
  16. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/09-cross-project-learning.md +461 -0
  17. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/README.md +83 -0
  18. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/maturity-integration.md +198 -0
  19. package/templates/.claude/skills/pipeline-forge/references/self-extracted-patterns.md +260 -0
@@ -0,0 +1,449 @@
1
+ # Module: Analyze & Map
2
+
3
+ Phase 2 of the CC-Toolkit-Generator Enhanced pipeline.
4
+ Takes the Internal Project Model (IPM) from Module 01, maps documents to toolkit
5
+ instruments using pipeline-specific rules and a scoring engine, and produces a
6
+ prioritized Instrument Map.
7
+
8
+ ---
9
+
10
+ ## Input
11
+
12
+ | Parameter | Type | Source |
13
+ |-----------|------|--------|
14
+ | `ipm` | IPM object | Output of Module 01 (Detect & Parse) |
15
+
16
+ The IPM must contain at minimum:
17
+ - `pipeline_type` -- determines which mapping table to apply
18
+ - `detected_docs` -- documents to map to instruments
19
+ - `project_characteristics` -- flags for conditional instruments
20
+
21
+ ---
22
+
23
+ ## Process
24
+
25
+ ### Step 1: Select Mapping Table
26
+
27
+ Based on `ipm.pipeline_type`, load the appropriate mapping rules.
28
+
29
+ ```
30
+ IF pipeline_type IN ["SPARC", "SPARC_MINIMAL"]:
31
+ USE sparc_mapping (defined below)
32
+ ELIF pipeline_type IN ["IDEA2PRD_FULL", "IDEA2PRD_PARTIAL"]:
33
+ USE idea2prd_mapping
34
+ view() references/extended-mapping.md # Complete DDD/ADR/Gherkin/Fitness mappings
35
+ ELIF pipeline_type == "MINIMAL":
36
+ USE sparc_mapping with reduced scope
37
+ ```
38
+
39
+ ### Step 2: Apply SPARC Mapping
40
+
41
+ When pipeline is SPARC or SPARC_MINIMAL, map documents to instruments using
42
+ the primary SPARC mapping table:
43
+
44
+ ```
45
+ SPARC DOCUMENT MAPPING:
46
+
47
+ PRD.md:
48
+ - Executive Summary → CLAUDE.md Overview (P0)
49
+ - Problem Statement → CLAUDE.md Problem Context (P0), architect.md (P1)
50
+ - Functional Reqs → /plan features (P1), /start Phase 2 scope
51
+ - NFRs → security.md (P0), testing.md (P1)
52
+ - User Stories → /test templates (P1), testing-patterns/ (P1)
53
+
54
+ Solution_Strategy.md:
55
+ - Root Cause/Framework → project-context/ (P1), architect.md (P1), CLAUDE.md
56
+
57
+ Specification.md:
58
+ - Data Model/API/Security → /start Phase 2 (P0), security.md (P0), coding-standards/ (P1)
59
+
60
+ Pseudocode.md:
61
+ - Algorithms/Error Handling → planner.md (P1), code-reviewer.md (P1), /start refs
62
+
63
+ Architecture.md:
64
+ - Structure/Stack/Docker/APIs → CLAUDE.md (P0), /start (P0), .mcp.json (P3), coding-style.md (P0)
65
+
66
+ Refinement.md:
67
+ - Edge Cases/Testing/Security → code-reviewer.md (P1), testing.md (P1), /test (P1), tdd-guide.md (P2)
68
+
69
+ Completion.md:
70
+ - CI/CD/Docker/Monitoring → /deploy (P1), /start Phase 3, hooks (P2)
71
+
72
+ Research_Findings.md:
73
+ - Tech Decisions/Best Practices → architect.md (P1), coding-standards/ (P1), CLAUDE.md
74
+
75
+ Final_Summary.md:
76
+ - Quick Reference → CLAUDE.md (P0), DEVELOPMENT_GUIDE.md (P0)
77
+ ```
78
+
79
+ Extraction patterns for SPARC documents:
80
+
81
+ ```
82
+ EXTRACT PRD.md:
83
+ name → title
84
+ problem → context
85
+ requirements → features
86
+ NFRs → rules
87
+
88
+ EXTRACT Architecture.md:
89
+ structure → /start P1
90
+ packages → /start P2
91
+ docker → /start P3
92
+ stack → CLAUDE.md
93
+ APIs → security-patterns
94
+ DB → migration
95
+
96
+ EXTRACT Pseudocode.md:
97
+ functions → planner templates
98
+ algorithms → /start P2 refs
99
+ errors → code-reviewer
100
+ ```
101
+
102
+ ### Step 3: Apply idea2prd Mapping
103
+
104
+ When pipeline is IDEA2PRD_FULL or IDEA2PRD_PARTIAL, apply the extended mapping.
105
+ Read `view() references/extended-mapping.md` for the complete mapping matrix.
106
+
107
+ Key idea2prd-specific mappings:
108
+
109
+ ```
110
+ DDD STRATEGIC:
111
+ bounded-contexts.md:
112
+ - Context definitions → domain-expert.md agent (P1)
113
+ - Context responsibilities → Agent scope definitions
114
+ - Ubiquitous Language → domain-glossary rule, project-context/ (P1)
115
+ context-map.md:
116
+ - Relationships → Integration hooks
117
+ - Anti-Corruption Layer → Validation hooks, security.md
118
+
119
+ DDD TACTICAL:
120
+ aggregates/*.md:
121
+ - Aggregate Root → ddd-validator.md agent (P1)
122
+ - Invariants → PreToolUse validation hooks (P2)
123
+ - Business Rules → coding-style.md (P0), validation hooks
124
+ entities/*.md:
125
+ - Entity definitions → Type checking hooks
126
+ events/*.md:
127
+ - Domain Events → event-handlers/ skill (P1)
128
+ - Event handlers → PostToolUse hooks (P2)
129
+
130
+ ADR DOCUMENTS:
131
+ FOR EACH adr/*.md:
132
+ CLASSIFY by keywords:
133
+ "security", "auth", "encryption" → security.md rule
134
+ "performance", "scale", "cache" → performance rules
135
+ "test", "coverage", "TDD" → testing.md rule
136
+ "API", "REST", "GraphQL" → api-patterns/ skill
137
+ "database", "storage" → data rules
138
+ technology names → coding-standards/ skill
139
+
140
+ C4 DIAGRAMS:
141
+ context.mermaid → CLAUDE.md overview, architect.md context
142
+ container.mermaid → CLAUDE.md structure, Agent boundaries
143
+ component.mermaid → Skill boundaries, coding-standards/
144
+
145
+ PSEUDOCODE:
146
+ {Aggregate}.pseudo:
147
+ FUNCTION signature → planner.md templates (P1)
148
+ VALIDATE statements → PreToolUse hooks (P2)
149
+ EMIT statements → event-handlers/ skill (P1)
150
+ Error handling → code-reviewer knowledge (P1)
151
+
152
+ GHERKIN TESTS:
153
+ *.feature:
154
+ Feature name → /test command scope (P1)
155
+ Scenario → Test templates
156
+ Given/When/Then → Setup/Action/Assertion patterns
157
+ Scenario Outline → Parameterized tests
158
+
159
+ FITNESS FUNCTIONS:
160
+ fitness-functions.md:
161
+ Architecture fitness → ddd-validator agent (P1)
162
+ Code quality fitness → PostToolUse hook (P2)
163
+ Security fitness → PreToolUse hook (P2)
164
+
165
+ .AI-CONTEXT (8 files):
166
+ README.md → CLAUDE.md Overview (P0)
167
+ architecture-summary → CLAUDE.md Architecture (P0)
168
+ key-decisions → CLAUDE.md Decisions (P0)
169
+ domain-glossary → project-context/ skill (P1)
170
+ bounded-contexts → domain-model.md rule (P0)
171
+ coding-standards → coding-style.md rule (P0)
172
+ fitness-rules → fitness-functions.md rule (P1)
173
+ pseudocode-index → planner.md agent (P1)
174
+ ```
175
+
176
+ ### Step 4: Score Each Instrument
177
+
178
+ Apply the scoring engine to every candidate instrument. Read
179
+ `view() references/enhanced-recommendations.md` for detailed scoring rules.
180
+
181
+ #### 4a. Base Scores by Document Type
182
+
183
+ | Document Type | Base Score | Max Boost |
184
+ |---------------|------------|-----------|
185
+ | .ai-context/* | +15 | +5 |
186
+ | PRD.md | +10 | +5 |
187
+ | DDD Strategic | +12 | +8 |
188
+ | DDD Tactical | +10 | +10 |
189
+ | ADR (>10 files) | +10 | +5 |
190
+ | Pseudocode | +10 | +5 |
191
+ | Gherkin | +10 | +5 |
192
+ | Fitness | +8 | +5 |
193
+ | C4 | +5 | +3 |
194
+ | Completion | +5 | +3 |
195
+
196
+ #### 4b. Smart Recommendation Boosts
197
+
198
+ Apply these boosts based on document content and count:
199
+
200
+ ```
201
+ # SPARC Core Boosts
202
+ Architecture.md present → architect.md (+10), /start (+10)
203
+ Pseudocode.md present → planner.md (+10), BOOST /start P2
204
+ Refinement.md present → testing.md (+8), code-reviewer.md (+8), /test (+8)
205
+ Solution_Strategy present → project-context/ (+8), BOOST architect (+3)
206
+ Completion.md present → /deploy (+8), BOOST /start P3
207
+
208
+ # Detection-based Boosts
209
+ has_external_apis = true → security-patterns/ (+10), secrets-management.md (+10)
210
+ has_database = true → BOOST /start P3 with migration
211
+ "Coolify" found → coolify MCP (+8)
212
+ "Docker" found → docker MCP (+5)
213
+
214
+ # DDD-Specific Boosts
215
+ docs/ddd/strategic/ exists → domain-expert.md (+10)
216
+ aggregates/ has >3 files → ddd-validator.md (+8), +5 if >7 files
217
+ aggregates/ has >5 files → aggregate-patterns/ (+5)
218
+ events/ has >3 files → event-handlers/ (+5)
219
+ events/ has >0 files → event-handlers/ (+10)
220
+ docs/adr/ has >10 files → architect.md (+10)
221
+ docs/adr/ has >15 files → architect.md (+5 additional)
222
+ docs/tests/*.feature exists → testing-patterns/ (+10), tdd-guide.md (+8)
223
+ tests/ has >10 scenarios → testing-patterns/ (+5)
224
+ docs/fitness/ exists → fitness-functions.md (+10)
225
+ fitness has >5 functions → validation hooks (+5)
226
+ .ai-context/ exists → INTEGRATE into CLAUDE.md, project-context/ (+10)
227
+ .ai-context/ has >4 files → project-context/ RECOMMEND
228
+
229
+ # ADR Security Boost
230
+ FOR EACH adr/*.md containing "security": security.md += 2
231
+ FOR EACH adr/*.md containing "authentication": security.md += 1
232
+ FOR EACH adr/*.md containing "encryption": security.md += 1
233
+ ```
234
+
235
+ #### 4c. Assign Priority Tiers
236
+
237
+ ```python
238
+ def assign_tier(score: int, document_source: str) -> str:
239
+ # Source-specific boosts
240
+ ddd_boost = 2 if document_source in ["DDD_STRATEGIC", "DDD_TACTICAL"] else 0
241
+ gherkin_boost = 2 if document_source == "GHERKIN" else 0
242
+ ai_context_boost = 3 if document_source == "AI_CONTEXT" else 0
243
+
244
+ adjusted_score = score + ddd_boost + gherkin_boost + ai_context_boost
245
+
246
+ if adjusted_score >= 18:
247
+ return "P1" # Highly recommended, default ON
248
+ elif adjusted_score >= 12:
249
+ return "P1" # Recommended, default ON
250
+ elif adjusted_score >= 8:
251
+ return "P2" # Optional, default OFF
252
+ else:
253
+ return "P3" # External/advanced, default OFF
254
+ ```
255
+
256
+ Note: P0 items are **not scored** -- they are always mandatory regardless of
257
+ score. P0 assignment is hardcoded in Module 03.
258
+
259
+ ### Step 5: Build Instrument Map
260
+
261
+ Assemble all scored instruments into the Instrument Map, sorted by tier then
262
+ by score descending:
263
+
264
+ ```
265
+ instrument_map = {
266
+ p0_mandatory: [
267
+ # Always generated -- not scored, hardcoded list
268
+ # See Module 03 for the definitive P0 list
269
+ ],
270
+
271
+ p0_conditional: [
272
+ # Generated IF characteristic flags are set
273
+ { name: "secrets-management.md", type: "rule",
274
+ condition: "has_external_apis", source_docs: [...] },
275
+ { name: "security-patterns/", type: "skill",
276
+ condition: "has_external_apis", source_docs: [...] },
277
+ { name: "domain-model.md", type: "rule",
278
+ condition: "has_ddd_strategic", source_docs: [...] }
279
+ ],
280
+
281
+ p1_recommended: [
282
+ # Scored instruments with tier P1 (score >= 12)
283
+ { name: "planner.md", type: "agent", score: 21,
284
+ source_docs: ["Pseudocode.md"], pipeline: "SPARC" },
285
+ { name: "code-reviewer.md", type: "agent", score: 19,
286
+ source_docs: ["Refinement.md", "Specification.md"], pipeline: "SPARC" },
287
+ { name: "architect.md", type: "agent", score: 18,
288
+ source_docs: ["Architecture.md", "Solution_Strategy.md"], pipeline: "SPARC" },
289
+ # ... more P1 instruments sorted by score
290
+ ],
291
+
292
+ p2_optional: [
293
+ # Scored instruments with tier P2 (score 8-11)
294
+ { name: "tdd-guide.md", type: "agent", score: 10,
295
+ source_docs: [...], pipeline: "SPARC" },
296
+ # ... more P2 instruments
297
+ ],
298
+
299
+ p3_external: [
300
+ # Scored instruments with tier P3 (score < 8)
301
+ { name: ".mcp.json", type: "config", score: 5,
302
+ source_docs: [...] }
303
+ ],
304
+
305
+ enterprise_lifecycle: {
306
+ # Included IF DDD detected -- see references/templates/feature-lifecycle-ent.md
307
+ enabled: bool,
308
+ items: [
309
+ { name: "/feature-ent", type: "command" },
310
+ { name: "feature-lifecycle-ent.md", type: "rule" },
311
+ { name: "idea2prd-manual/", type: "skill", action: "copy+rewrite" },
312
+ { name: "goap-research-ed25519/", type: "skill", action: "copy+rewrite" }
313
+ ]
314
+ },
315
+
316
+ feature_suggestions: {
317
+ # Always included at P1 -- see references/templates/feature-suggestions.md
318
+ items: [
319
+ { name: "/next", type: "command" },
320
+ { name: "feature-navigator/", type: "skill" },
321
+ { name: "feature-roadmap.json", type: "config" },
322
+ { name: "feature-context.py", type: "hook" }
323
+ ]
324
+ },
325
+
326
+ automation: {
327
+ # Always included at P1 -- see references/templates/automation-commands.md
328
+ items: [
329
+ { name: "/go", type: "command" },
330
+ { name: "/run", type: "command" },
331
+ { name: "/docs", type: "command" }
332
+ ]
333
+ }
334
+ }
335
+ ```
336
+
337
+ ### Step 6: MANUAL/HYBRID Mode Checkpoint (conditional)
338
+
339
+ In HYBRID mode, present a summary checkpoint (Checkpoint 1 in HYBRID,
340
+ Checkpoint 2 in MANUAL):
341
+
342
+ ```
343
+ ================================================================
344
+ CHECKPOINT: Smart Selection
345
+ ================================================================
346
+
347
+ Pipeline Detected: [pipeline_type]
348
+ Documents Found: [total] files across [categories] categories
349
+
350
+ P0 Generated (mandatory):
351
+ - CLAUDE.md [size estimate]
352
+ - security.md [size estimate]
353
+ - coding-style.md [size estimate]
354
+ [IF has_ddd_strategic:]
355
+ - domain-model.md (from DDD Strategic) [size estimate]
356
+ [IF has_external_apis:]
357
+ - secrets-management.md [size estimate]
358
+ - security-patterns/ [size estimate]
359
+
360
+ P1 Recommended (score >= 12):
361
+ | # | Instrument | Type | Score | Source |
362
+ |---|------------------|---------|-------|---------------------|
363
+ | 1 | [name] | [type] | [N] | [source docs] |
364
+ | 2 | ... | ... | ... | ... |
365
+
366
+ P2 Optional (score 8-11):
367
+ | # | Instrument | Type | Score | Source |
368
+ ...
369
+
370
+ P3 External:
371
+ | # | Instrument | Type | Score | Source |
372
+ ...
373
+
374
+ Quick Actions:
375
+ "ok" -- generate all P1 ([N] instruments)
376
+ "minimum" -- P0 only
377
+ "maximum" -- all P1 + P2 + P3 ([N] instruments)
378
+ "+ddd" -- add all DDD-specific
379
+ "+gherkin" -- add all Gherkin-specific
380
+ "+N" / "-N" -- toggle specific instrument by number
381
+
382
+ ================================================================
383
+ ```
384
+
385
+ Wait for user selection before passing Instrument Map to Module 03.
386
+
387
+ ---
388
+
389
+ ## Output
390
+
391
+ | Field | Type | Description |
392
+ |-------|------|-------------|
393
+ | `instrument_map` | InstrumentMap object | Scored, tiered list of all toolkit instruments as defined in Step 5 |
394
+
395
+ The Instrument Map is consumed by:
396
+ - **Module 03 (Generate P0)** -- uses `p0_mandatory` and `p0_conditional` lists
397
+ - **Module 04 (Generate P1)** -- uses `p1_recommended`, `enterprise_lifecycle`, `feature_suggestions`, `automation`
398
+ - **Module 05 (Generate P2-P3)** -- uses `p2_optional` and `p3_external`
399
+ - **Module 06 (Package)** -- uses the full map for validation checklist
400
+
401
+ ---
402
+
403
+ ## Quality Gate
404
+
405
+ | Check | Condition | Action on Failure |
406
+ |-------|-----------|-------------------|
407
+ | All P0 items have sources | Every P0 mandatory item has at least one `source_doc` mapped from the IPM | Review IPM; if doc genuinely missing, generate P0 item from available context with degraded quality warning. |
408
+ | No orphan docs | Every document in `ipm.detected_docs` maps to at least one instrument | Log warning for unmapped docs. Not blocking but indicates potential content loss. |
409
+ | Score consistency | No P1 item has score < 12; no P2 item has score >= 12 | Re-run tier assignment on failing items. |
410
+ | Conditional P0 flags match | `p0_conditional` items match `project_characteristics` flags | Remove conditional items whose flags are false. |
411
+ | Instrument Map non-empty | At least P0 mandatory items are present | Always true by construction (P0 is hardcoded). |
412
+
413
+ ---
414
+
415
+ ## Dependencies
416
+
417
+ This module reads the following reference files during execution:
418
+
419
+ | Reference | Purpose | When Read |
420
+ |-----------|---------|-----------|
421
+ | `view() references/enhanced-recommendations.md` | Detailed scoring rules for DDD, ADR, Gherkin, Fitness, Pseudocode, .ai-context documents | Step 4 (scoring engine) |
422
+ | `view() references/extended-mapping.md` | Complete document-to-instrument mapping for idea2prd pipeline | Step 3 (idea2prd mapping) |
423
+
424
+ These files are part of the cc-toolkit-generator-enhanced skill and are read
425
+ at the paths:
426
+ - `.claude/skills/cc-toolkit-generator-enhanced/references/enhanced-recommendations.md`
427
+ - `.claude/skills/cc-toolkit-generator-enhanced/references/extended-mapping.md`
428
+
429
+ ---
430
+
431
+ ## Reusability
432
+
433
+ The scoring engine (Steps 4a-4c) is a general-purpose component that can be
434
+ reused for **any document-to-artifact mapping problem**:
435
+
436
+ 1. **Define a mapping table** (document section -> output artifact)
437
+ 2. **Define base scores** per document type
438
+ 3. **Define boost rules** based on content analysis
439
+ 4. **Apply tier assignment** using the threshold function
440
+
441
+ This three-layer scoring model (base score + content boosts + tier thresholds)
442
+ is domain-agnostic. To adapt for a different domain:
443
+ - Replace the SPARC/idea2prd mapping tables with domain-specific mappings
444
+ - Adjust base scores to reflect domain priorities
445
+ - Define domain-specific boost conditions
446
+ - Keep the tier assignment function unchanged (or adjust thresholds)
447
+
448
+ The Instrument Map output format is also reusable as a generic "prioritized
449
+ artifact manifest" for any toolkit or scaffold generator.