@dzhechkov/p-replicator 1.0.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 (92) hide show
  1. package/README.md +314 -0
  2. package/bin/cli.js +4 -0
  3. package/package.json +62 -0
  4. package/src/cli.js +160 -0
  5. package/src/commands/doctor.js +151 -0
  6. package/src/commands/init.js +155 -0
  7. package/src/commands/list.js +133 -0
  8. package/src/commands/remove.js +111 -0
  9. package/src/commands/update.js +102 -0
  10. package/src/utils.js +280 -0
  11. package/templates/.claude/agents/doc-validator.md +92 -0
  12. package/templates/.claude/agents/harvest-coordinator.md +91 -0
  13. package/templates/.claude/agents/product-discoverer.md +57 -0
  14. package/templates/.claude/agents/replicate-coordinator.md +98 -0
  15. package/templates/.claude/commands/harvest.md +106 -0
  16. package/templates/.claude/commands/replicate.md +389 -0
  17. package/templates/.claude/rules/replicate-pipeline.md +92 -0
  18. package/templates/.claude/skills/brutal-honesty-review/README.md +218 -0
  19. package/templates/.claude/skills/brutal-honesty-review/SKILL.md +225 -0
  20. package/templates/.claude/skills/brutal-honesty-review/resources/assessment-rubrics.md +295 -0
  21. package/templates/.claude/skills/brutal-honesty-review/resources/review-template.md +102 -0
  22. package/templates/.claude/skills/brutal-honesty-review/scripts/assess-code.sh +179 -0
  23. package/templates/.claude/skills/brutal-honesty-review/scripts/assess-tests.sh +223 -0
  24. package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +374 -0
  25. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/claude-md-strategy.md +178 -0
  26. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/enhanced-recommendations.md +416 -0
  27. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/extended-mapping.md +370 -0
  28. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/automation-commands.md +733 -0
  29. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-agents.md +416 -0
  30. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-hooks-commands.md +524 -0
  31. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-skills.md +350 -0
  32. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/enhanced-claude-md.md +235 -0
  33. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle-ent.md +400 -0
  34. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle.md +325 -0
  35. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-suggestions.md +423 -0
  36. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/insights-system.md +349 -0
  37. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/mcp.md +274 -0
  38. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/start-command.md +283 -0
  39. package/templates/.claude/skills/explore/SKILL.md +215 -0
  40. package/templates/.claude/skills/explore/references/questioning-techniques.md +151 -0
  41. package/templates/.claude/skills/explore/references/task-brief-templates.md +355 -0
  42. package/templates/.claude/skills/goap-research-ed25519/SKILL.md +415 -0
  43. package/templates/.claude/skills/goap-research-ed25519/references/ed25519-verification.md +658 -0
  44. package/templates/.claude/skills/goap-research-ed25519/references/research-actions.md +544 -0
  45. package/templates/.claude/skills/goap-research-ed25519/references/source-evaluation.md +560 -0
  46. package/templates/.claude/skills/goap-research-ed25519/scripts/ed25519_verifier.py +662 -0
  47. package/templates/.claude/skills/goap-research-ed25519/scripts/goap_planner.py +720 -0
  48. package/templates/.claude/skills/knowledge-extractor/SKILL.md +412 -0
  49. package/templates/.claude/skills/knowledge-extractor/examples/rate-limiting-extraction.md +259 -0
  50. package/templates/.claude/skills/knowledge-extractor/modules/01-agent-review.md +192 -0
  51. package/templates/.claude/skills/knowledge-extractor/modules/02-classify.md +122 -0
  52. package/templates/.claude/skills/knowledge-extractor/modules/03-decontextualize.md +156 -0
  53. package/templates/.claude/skills/knowledge-extractor/modules/04-integrate.md +178 -0
  54. package/templates/.claude/skills/knowledge-extractor/references/artifact-categories.md +342 -0
  55. package/templates/.claude/skills/knowledge-extractor/references/decontextualization-guide.md +247 -0
  56. package/templates/.claude/skills/knowledge-extractor/references/maturity-model.md +153 -0
  57. package/templates/.claude/skills/knowledge-extractor/templates/artifact-card.md +60 -0
  58. package/templates/.claude/skills/knowledge-extractor/templates/harvest-report.md +70 -0
  59. package/templates/.claude/skills/knowledge-extractor/templates/toolkit-harvest.md +38 -0
  60. package/templates/.claude/skills/pipeline-forge/SKILL.md +523 -0
  61. package/templates/.claude/skills/pipeline-forge/examples/replicate-analysis.md +291 -0
  62. package/templates/.claude/skills/pipeline-forge/references/patterns-catalog.md +408 -0
  63. package/templates/.claude/skills/pipeline-forge/references/quality-gates.md +268 -0
  64. package/templates/.claude/skills/pipeline-forge/references/skill-anatomy.md +292 -0
  65. package/templates/.claude/skills/pipeline-forge/templates/agent-template.md +60 -0
  66. package/templates/.claude/skills/pipeline-forge/templates/command-template.md +80 -0
  67. package/templates/.claude/skills/pipeline-forge/templates/pipeline-template.md +137 -0
  68. package/templates/.claude/skills/pipeline-forge/templates/skill-template.md +132 -0
  69. package/templates/.claude/skills/problem-solver-enhanced/SKILL.md +562 -0
  70. package/templates/.claude/skills/requirements-validator/SKILL.md +121 -0
  71. package/templates/.claude/skills/requirements-validator/assets/templates/bdd-feature-template.feature +69 -0
  72. package/templates/.claude/skills/requirements-validator/references/bdd-patterns.md +184 -0
  73. package/templates/.claude/skills/requirements-validator/references/invest-criteria.md +121 -0
  74. package/templates/.claude/skills/requirements-validator/references/scoring-system.md +134 -0
  75. package/templates/.claude/skills/requirements-validator/references/smart-criteria.md +130 -0
  76. package/templates/.claude/skills/reverse-engineering-unicorn/SKILL.md +194 -0
  77. package/templates/.claude/skills/reverse-engineering-unicorn/examples/noom-cjm-example.md +100 -0
  78. package/templates/.claude/skills/reverse-engineering-unicorn/examples/noom-module1-example.md +88 -0
  79. package/templates/.claude/skills/reverse-engineering-unicorn/modules/01-intelligence.md +328 -0
  80. package/templates/.claude/skills/reverse-engineering-unicorn/modules/02-product-customers.md +221 -0
  81. package/templates/.claude/skills/reverse-engineering-unicorn/modules/025-cjm-prototype.md +206 -0
  82. package/templates/.claude/skills/reverse-engineering-unicorn/modules/03-market-competition.md +402 -0
  83. package/templates/.claude/skills/reverse-engineering-unicorn/modules/04-business-finance.md +287 -0
  84. package/templates/.claude/skills/reverse-engineering-unicorn/modules/05-growth-engine.md +290 -0
  85. package/templates/.claude/skills/reverse-engineering-unicorn/modules/06-playbook-synthesis.md +286 -0
  86. package/templates/.claude/skills/reverse-engineering-unicorn/references/blue-ocean-canvas.md +39 -0
  87. package/templates/.claude/skills/reverse-engineering-unicorn/references/industry-benchmarks.md +67 -0
  88. package/templates/.claude/skills/reverse-engineering-unicorn/references/jtbd-canvas.md +48 -0
  89. package/templates/.claude/skills/sparc-prd-mini/SKILL.md +955 -0
  90. package/templates/.claude/skills/sparc-prd-mini/references/sparc-methodology.md +360 -0
  91. package/templates/.claude/skills/sparc-prd-mini/templates/CLAUDE.md +91 -0
  92. package/templates/.claude/skills/sparc-prd-mini/templates/prd.md +336 -0
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # @dzhechkov/p-replicator
2
+
3
+ **P-Replicator** — Claude Code toolkit for AI-assisted product development (Vibe Coding).
4
+
5
+ Transform a product idea into a fully documented, validated, toolkit-equipped project ready for development.
6
+
7
+ ## Quick Start
8
+
9
+ ```bash
10
+ # Install into any project
11
+ npx @dzhechkov/p-replicator init
12
+
13
+ # Open Claude Code
14
+ claude
15
+
16
+ # Run the pipeline
17
+ /replicate "Online marketplace for handmade crafts with AI-powered recommendations"
18
+ ```
19
+
20
+ The system walks you through 4-5 phases with interactive checkpoints. At each checkpoint you review the output and confirm before proceeding. Estimated time: 45-90 minutes for the full pipeline.
21
+
22
+ ## What Gets Installed
23
+
24
+ | Component | Count | Description |
25
+ |-----------|-------|-------------|
26
+ | **Skills** | 10 | SPARC docs, research, problem-solving, validation, review, reverse engineering, toolkit generation, pipeline forge, knowledge extraction, task exploration |
27
+ | **Commands** | 2 | `/replicate` (full pipeline), `/harvest` (knowledge extraction) |
28
+ | **Agents** | 4 | replicate-coordinator, product-discoverer, doc-validator, harvest-coordinator |
29
+ | **Rules** | 1 | replicate-pipeline (phase constraints) |
30
+
31
+ After running `/replicate`, the toolkit generates additional commands, agents, rules, and skills specific to your project (see [Post-Pipeline Commands](#post-pipeline-commands)).
32
+
33
+ ## Skills Reference
34
+
35
+ | Skill | Purpose |
36
+ |-------|---------|
37
+ | `explore` | Socratic task clarification |
38
+ | `sparc-prd-mini` | SPARC documentation generator (11 docs) |
39
+ | `goap-research-ed25519` | Verified research with Ed25519 anti-hallucination |
40
+ | `problem-solver-enhanced` | First principles + TRIZ (9 modules) |
41
+ | `requirements-validator` | INVEST/SMART validation + BDD scenarios |
42
+ | `brutal-honesty-review` | Unvarnished technical criticism |
43
+ | `cc-toolkit-generator-enhanced` | Claude Code toolkit generator |
44
+ | `reverse-engineering-unicorn` | Company reverse engineering + playbook |
45
+ | `pipeline-forge` | Meta-skill: build AI pipelines from patterns |
46
+ | `knowledge-extractor` | Extract reusable knowledge from projects |
47
+
48
+ ## CLI Commands
49
+
50
+ ```bash
51
+ npx @dzhechkov/p-replicator init # Install (default)
52
+ npx @dzhechkov/p-replicator update # Update to latest version
53
+ npx @dzhechkov/p-replicator remove # Remove from project
54
+ npx @dzhechkov/p-replicator list # List installed components
55
+ npx @dzhechkov/p-replicator doctor # Health check
56
+ ```
57
+
58
+ ### Options
59
+
60
+ ```
61
+ --force Overwrite existing files without prompting
62
+ --dry-run Show what would be done without making changes
63
+ --help Show help message
64
+ --version Show version number
65
+ ```
66
+
67
+ ## The /replicate Pipeline
68
+
69
+ After installation, run `/replicate "idea"` in Claude Code to execute:
70
+
71
+ ```
72
+ Phase 0 (optional) → Phase 1 → Phase 2 → Phase 3 → Phase 4
73
+ Product Discovery Planning Validation Toolkit Finalize
74
+ ```
75
+
76
+ ### Phase 0: Product Discovery (Optional)
77
+
78
+ Activates automatically for SaaS, startups, and new products. Skipped for internal tools and utilities.
79
+
80
+ - Reverse engineers similar companies and products
81
+ - Identifies target customer segments (Jobs-To-Be-Done)
82
+ - Analyzes competitive landscape (Blue Ocean Canvas)
83
+ - Maps unit economics and monetization
84
+ - Produces a Product Discovery Brief used by Phase 1
85
+
86
+ ### Phase 1: Planning
87
+
88
+ Generates 11 SPARC documents in `docs/`:
89
+
90
+ | Document | Content |
91
+ |----------|---------|
92
+ | `PRD.md` | Product Requirements — vision, personas, user stories |
93
+ | `Solution_Strategy.md` | Problem analysis and solution approach |
94
+ | `Specification.md` | Detailed requirements with acceptance criteria |
95
+ | `Pseudocode.md` | Algorithms and data flow |
96
+ | `Architecture.md` | System design and component diagrams |
97
+ | `Refinement.md` | Edge cases, testing strategy |
98
+ | `Completion.md` | Deployment, CI/CD, monitoring |
99
+ | `Research_Findings.md` | Market and technology research |
100
+ | `Final_Summary.md` | Executive summary |
101
+ | `C4_Diagrams.md` | System context, container, and component diagrams |
102
+ | `ADR.md` | Architecture Decision Records |
103
+
104
+ ### Phase 2: Validation
105
+
106
+ Validates documentation quality using 5 parallel agents (swarm):
107
+
108
+ | Agent | Validates |
109
+ |-------|----------|
110
+ | Stories Validator | User stories against INVEST criteria |
111
+ | AC Validator | Acceptance criteria against SMART criteria |
112
+ | Architecture Validator | Architecture consistency and completeness |
113
+ | Pseudocode Validator | Algorithm correctness and edge cases |
114
+ | Coherence Validator | Cross-document consistency |
115
+
116
+ **Scoring:** Score >= 70 passes (READY), 50-69 passes with caveats, <50 requires fixes (auto-retries up to 3 times).
117
+
118
+ **Output:** `docs/validation-report.md` and `docs/test-scenarios.md` (BDD/Gherkin).
119
+
120
+ ### Phase 3: Toolkit Generation
121
+
122
+ Creates Claude Code instruments for your project:
123
+
124
+ | Category | Generated |
125
+ |----------|-----------|
126
+ | **Commands** | `/start`, `/feature`, `/plan`, `/next`, `/deploy`, `/myinsights`, `/go`, `/run`, `/docs` |
127
+ | **Agents** | `planner`, `code-reviewer`, `architect` |
128
+ | **Rules** | `git-workflow`, `feature-lifecycle`, `security`, `coding-style`, `insights-capture` |
129
+ | **Skills** | `project-context`, `coding-standards`, `testing-patterns`, `feature-navigator` |
130
+ | **Hooks** | `SessionStart` (feature context), `Stop` (auto-commit) |
131
+ | **Project files** | `CLAUDE.md`, `DEVELOPMENT_GUIDE.md`, `README.md` |
132
+
133
+ Conditional generation (automatically detected):
134
+ - DDD patterns found → `/feature-ent`, enterprise lifecycle
135
+ - External APIs detected → security rules, secrets management
136
+ - Fitness functions defined → fitness validation rules
137
+
138
+ ### Phase 4: Finalization
139
+
140
+ Creates infrastructure scaffolding (`docker-compose.yml`, `Dockerfile`, `.gitignore`) and commits everything with structured git history.
141
+
142
+ ### Checkpoint Interaction
143
+
144
+ After each phase, you see a checkpoint prompt and can respond:
145
+
146
+ | Command | Action |
147
+ |---------|--------|
148
+ | `ok` | Proceed to next phase |
149
+ | `add [detail]` | Add information to current phase output |
150
+ | `fix [issue]` | Fix something in current output |
151
+ | `redo` | Redo the current phase |
152
+ | `skip` | Skip the current phase (not recommended for Phase 2) |
153
+
154
+ ## Post-Pipeline Commands
155
+
156
+ After `/replicate` completes, the following commands become available:
157
+
158
+ ### /start — Bootstrap the Project
159
+
160
+ Reads SPARC documentation and creates the initial project structure: source code directories, database schemas, API stubs, and configuration files.
161
+
162
+ ### /feature — Full Feature Lifecycle
163
+
164
+ ```
165
+ /feature user-authentication
166
+ ```
167
+
168
+ 4-phase lifecycle: **PLAN** (SPARC docs) → **VALIDATE** (swarm, score >= 70) → **IMPLEMENT** (parallel agents) → **REVIEW** (code review swarm).
169
+
170
+ ### /plan — Lightweight Planning
171
+
172
+ ```
173
+ /plan add-payment-gateway
174
+ ```
175
+
176
+ Creates a single plan file in `docs/plans/`. Good for smaller tasks (2-5 min vs. 15-30 min for `/feature`).
177
+
178
+ ### /go — Smart Pipeline Selector
179
+
180
+ ```
181
+ /go user-authentication
182
+ ```
183
+
184
+ Automatically analyzes task complexity and selects `/plan`, `/feature`, or `/feature-ent`.
185
+
186
+ ### /run — Autonomous Build Loop
187
+
188
+ ```
189
+ /run # Build next features (MVP scope)
190
+ /run all # Build all planned features
191
+ ```
192
+
193
+ Continuously implements features from the roadmap until complete.
194
+
195
+ ### /next — What to Do Next
196
+
197
+ Shows current sprint progress, features in progress, suggested next tasks, blockers and dependencies.
198
+
199
+ ### /deploy — Deployment
200
+
201
+ ```
202
+ /deploy staging
203
+ /deploy production
204
+ ```
205
+
206
+ Guides the deployment process to the specified environment.
207
+
208
+ ### /myinsights — Development Insights
209
+
210
+ Captures errors, workarounds, and discoveries into the knowledge base. Error-first lookup: when you hit an error, the system checks if a solution already exists.
211
+
212
+ ### /docs — Generate Documentation
213
+
214
+ ```
215
+ /docs # Both Russian and English
216
+ /docs eng # English only
217
+ /docs update # Update existing docs
218
+ ```
219
+
220
+ Generates bilingual documentation in `README/` directory.
221
+
222
+ ## Feature Development Workflows
223
+
224
+ ### Simple Task
225
+
226
+ ```
227
+ /plan task-name → Creates plan in docs/plans/
228
+ implement manually → Write code following the plan
229
+ /myinsights → Capture any learnings
230
+ ```
231
+
232
+ ### Standard Feature
233
+
234
+ ```
235
+ /feature feature-name → Runs 4-phase lifecycle
236
+ /next → Check what's next
237
+ ```
238
+
239
+ ### Smart Mode
240
+
241
+ ```
242
+ /go feature-name → Auto-selects /plan or /feature or /feature-ent
243
+ ```
244
+
245
+ ### Autonomous Build
246
+
247
+ ```
248
+ /run → Builds all "next" features from roadmap
249
+ ```
250
+
251
+ ### Feature Roadmap
252
+
253
+ The system maintains `.claude/feature-roadmap.json` with statuses: `done`, `in_progress`, `next`, `planned`, `blocked`. Use `/next` to navigate.
254
+
255
+ ## The /harvest Pipeline
256
+
257
+ Extract reusable knowledge from completed projects:
258
+
259
+ ```
260
+ /harvest quick # Fast extraction, no checkpoints (~15 min)
261
+ /harvest full # Comprehensive 4-phase pipeline with checkpoints (~45 min)
262
+ /harvest marker # Mark artifact for later extraction (~30 sec)
263
+ ```
264
+
265
+ ### How /harvest full Works
266
+
267
+ ```
268
+ Phase 1: AGENT REVIEW → 5 parallel scanners
269
+ Phase 2: CLASSIFY → Categorize into skills/commands/rules/etc.
270
+ Phase 3: DECONTEXTUALIZE → Remove project-specific names, generalize
271
+ Phase 4: INTEGRATE → Write to toolkit, update index
272
+ ```
273
+
274
+ ### Harvest Audit
275
+
276
+ ```
277
+ /harvest audit
278
+ ```
279
+
280
+ Reviews toolkit maturity distribution, recommendations for promotion, and gaps in coverage.
281
+
282
+ ## Tips & Best Practices
283
+
284
+ 1. **Write descriptive product ideas** — the more detail you provide to `/replicate`, the better the documentation quality.
285
+
286
+ 2. **Use checkpoints actively** — review output at each phase, don't just skip through. Check that user stories match your vision and architecture aligns with constraints.
287
+
288
+ 3. **Start with /plan for small tasks** — not every task needs `/feature`. For tasks touching <= 3 files, `/plan` is faster and sufficient.
289
+
290
+ 4. **Use /go for automatic selection** — let the system decide between `/plan`, `/feature`, and `/feature-ent` based on complexity.
291
+
292
+ 5. **Harvest knowledge regularly** — use `/harvest marker` during development, run `/harvest quick` at the end of each sprint.
293
+
294
+ 6. **Use /next for focus** — start each session with `/next` to understand current state, blockers, and priorities.
295
+
296
+ 7. **Check insights before debugging** — the `SessionStart` hook automatically injects relevant insights from previous sessions.
297
+
298
+ 8. **Review generated CLAUDE.md** — it's Claude Code's primary context. Ensure architecture, commands, and coding standards are accurate.
299
+
300
+ 9. **Iterate on validation** — if Phase 2 returns CAVEATS, fix documentation before proceeding. Toolkit quality depends on documentation quality.
301
+
302
+ ## Integration with @dzhechkov/keysarium
303
+
304
+ Works alongside Keysarium. If `@dzhechkov/keysarium` is detected during `init`, PU skills integrate with the existing Keysarium setup, sharing `.claude/commands`, `.claude/rules`, and `.claude/agents` directories.
305
+
306
+ ```bash
307
+ npx @dzhechkov/keysarium init # Install Keysarium
308
+ npx @dzhechkov/p-replicator init # Add PU Unicorn skills
309
+ # Both work together seamlessly
310
+ ```
311
+
312
+ ## License
313
+
314
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ require('../src/cli');
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@dzhechkov/p-replicator",
3
+ "version": "1.0.0",
4
+ "description": "P-Replicator — Claude Code toolkit for AI-assisted product development (Vibe Coding). Full /replicate pipeline, 10 skills, /harvest knowledge extraction, swarm agents, quality gates.",
5
+ "main": "src/cli.js",
6
+ "bin": {
7
+ "p-replicator": "./bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "src/",
12
+ "templates/"
13
+ ],
14
+ "scripts": {
15
+ "test": "node bin/cli.js doctor",
16
+ "prepublishOnly": "node scripts/sync-templates.js"
17
+ },
18
+ "keywords": [
19
+ "claude",
20
+ "claude-code",
21
+ "ai",
22
+ "vibe-coding",
23
+ "sparc",
24
+ "prd",
25
+ "skills",
26
+ "pipeline",
27
+ "replicate",
28
+ "harvest",
29
+ "knowledge-extraction",
30
+ "swarm-agents",
31
+ "quality-gates",
32
+ "reverse-engineering",
33
+ "problem-solving",
34
+ "triz",
35
+ "bdd",
36
+ "invest",
37
+ "smart",
38
+ "documentation",
39
+ "skill-pack"
40
+ ],
41
+ "author": "dzhechko",
42
+ "license": "MIT",
43
+ "engines": {
44
+ "node": ">=16.0.0"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/dzhechko/pu-unicorn-replicate"
49
+ },
50
+ "homepage": "https://github.com/dzhechko/pu-unicorn-replicate#readme",
51
+ "bugs": {
52
+ "url": "https://github.com/dzhechko/pu-unicorn-replicate/issues"
53
+ },
54
+ "peerDependencies": {
55
+ "@dzhechkov/keysarium-core": "^1.0.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@dzhechkov/keysarium-core": {
59
+ "optional": true
60
+ }
61
+ }
62
+ }
package/src/cli.js ADDED
@@ -0,0 +1,160 @@
1
+ 'use strict';
2
+
3
+ const { bold, cyan, dim, green, yellow, error } = require('./utils');
4
+
5
+ // ---------------------------------------------------------------------------
6
+ // Banner
7
+ // ---------------------------------------------------------------------------
8
+ function showBanner() {
9
+ console.log('');
10
+ console.log(cyan('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557'));
11
+ console.log(cyan('\u2551') + bold(' P-REPLICATOR \u2014 AI Product Replicator for Claude Code ') + cyan('\u2551'));
12
+ console.log(cyan('\u2551') + ' AI-assisted product development (Vibe Coding) ' + cyan('\u2551'));
13
+ console.log(cyan('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D'));
14
+ console.log('');
15
+ }
16
+
17
+ // ---------------------------------------------------------------------------
18
+ // Version
19
+ // ---------------------------------------------------------------------------
20
+ function getVersion() {
21
+ const pkg = require('../package.json');
22
+ return pkg.version;
23
+ }
24
+
25
+ // ---------------------------------------------------------------------------
26
+ // Help
27
+ // ---------------------------------------------------------------------------
28
+ function showHelp() {
29
+ console.log(bold('Usage:') + ' npx @dzhechkov/p-replicator ' + cyan('<command>') + dim(' [options]'));
30
+ console.log('');
31
+ console.log(bold('Commands:'));
32
+ console.log(' ' + green('init') + ' Install P-Replicator into current project ' + dim('(default)'));
33
+ console.log(' ' + green('update') + ' Update to latest version');
34
+ console.log(' ' + green('remove') + ' Remove P-Replicator from project');
35
+ console.log(' ' + green('list') + ' List installed components');
36
+ console.log(' ' + green('doctor') + ' Check installation health');
37
+ console.log('');
38
+ console.log(bold('Options:'));
39
+ console.log(' ' + yellow('--force') + ' Overwrite existing files without prompting');
40
+ console.log(' ' + yellow('--dry-run') + ' Show what would be done without making changes');
41
+ console.log(' ' + yellow('--help, -h') + ' Show this help message');
42
+ console.log(' ' + yellow('--version, -v') + ' Show version number');
43
+ console.log('');
44
+ console.log(bold('Examples:'));
45
+ console.log(dim(' $ ') + 'npx @dzhechkov/p-replicator init');
46
+ console.log(dim(' $ ') + 'npx @dzhechkov/p-replicator init --force');
47
+ console.log(dim(' $ ') + 'npx @dzhechkov/p-replicator update --dry-run');
48
+ console.log(dim(' $ ') + 'npx @dzhechkov/p-replicator doctor');
49
+ console.log('');
50
+ console.log(bold('What gets installed:'));
51
+ console.log(' 10 skills SPARC docs, research, problem-solving, validation, review,');
52
+ console.log(' reverse engineering, toolkit generation, pipeline forge,');
53
+ console.log(' knowledge extraction, task exploration');
54
+ console.log(' 2 commands /replicate (full pipeline), /harvest (knowledge extraction)');
55
+ console.log(' 4 agents replicate-coordinator, product-discoverer, doc-validator,');
56
+ console.log(' harvest-coordinator');
57
+ console.log(' 1 rule replicate-pipeline (phase constraints)');
58
+ console.log('');
59
+ console.log(bold('After installation:'));
60
+ console.log(' 1. Open ' + cyan('Claude Code') + ' in this directory');
61
+ console.log(' 2. Run ' + cyan('/replicate "Your product idea"'));
62
+ console.log(' 3. Follow the 4-5 phase pipeline with checkpoints');
63
+ console.log('');
64
+ console.log(bold('Integration:'));
65
+ console.log(' Works alongside @dzhechkov/keysarium. Install both for the full toolkit.');
66
+ console.log('');
67
+ }
68
+
69
+ // ---------------------------------------------------------------------------
70
+ // Parse arguments
71
+ // ---------------------------------------------------------------------------
72
+ function parseArgs(argv) {
73
+ const args = argv.slice(2);
74
+
75
+ const flags = {
76
+ force: false,
77
+ dryRun: false,
78
+ targetDir: process.cwd(),
79
+ };
80
+
81
+ let command = null;
82
+
83
+ for (const arg of args) {
84
+ switch (arg) {
85
+ case '--force':
86
+ flags.force = true;
87
+ break;
88
+ case '--dry-run':
89
+ flags.dryRun = true;
90
+ break;
91
+ case '--help':
92
+ case '-h':
93
+ command = 'help';
94
+ break;
95
+ case '--version':
96
+ case '-v':
97
+ command = 'version';
98
+ break;
99
+ default:
100
+ if (!arg.startsWith('-') && command === null) {
101
+ command = arg;
102
+ }
103
+ break;
104
+ }
105
+ }
106
+
107
+ return { command, flags };
108
+ }
109
+
110
+ // ---------------------------------------------------------------------------
111
+ // Main
112
+ // ---------------------------------------------------------------------------
113
+ function main() {
114
+ const { command, flags } = parseArgs(process.argv);
115
+
116
+ if (command === 'version') {
117
+ console.log(getVersion());
118
+ return;
119
+ }
120
+
121
+ showBanner();
122
+
123
+ if (command === 'help') {
124
+ showHelp();
125
+ return;
126
+ }
127
+
128
+ const resolvedCommand = command || 'init';
129
+
130
+ switch (resolvedCommand) {
131
+ case 'init':
132
+ require('./commands/init')(flags);
133
+ break;
134
+
135
+ case 'update':
136
+ require('./commands/update')(flags);
137
+ break;
138
+
139
+ case 'remove':
140
+ require('./commands/remove')(flags);
141
+ break;
142
+
143
+ case 'list':
144
+ require('./commands/list')(flags);
145
+ break;
146
+
147
+ case 'doctor':
148
+ require('./commands/doctor')(flags);
149
+ break;
150
+
151
+ default:
152
+ error(`Unknown command: "${resolvedCommand}"`);
153
+ console.log('');
154
+ showHelp();
155
+ process.exitCode = 1;
156
+ break;
157
+ }
158
+ }
159
+
160
+ main();
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const {
6
+ green, red, yellow, cyan, bold, dim,
7
+ info, success, warn, error: logError,
8
+ readManifest, fileExists,
9
+ MANIFEST_FILE,
10
+ } = require('../utils');
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Expected components
14
+ // ---------------------------------------------------------------------------
15
+
16
+ const EXPECTED_SKILLS = [
17
+ 'explore',
18
+ 'sparc-prd-mini',
19
+ 'goap-research-ed25519',
20
+ 'problem-solver-enhanced',
21
+ 'requirements-validator',
22
+ 'brutal-honesty-review',
23
+ 'cc-toolkit-generator-enhanced',
24
+ 'reverse-engineering-unicorn',
25
+ 'pipeline-forge',
26
+ 'knowledge-extractor',
27
+ ];
28
+
29
+ const EXPECTED_COMMANDS = ['replicate', 'harvest'];
30
+
31
+ const EXPECTED_AGENTS = [
32
+ 'replicate-coordinator',
33
+ 'product-discoverer',
34
+ 'doc-validator',
35
+ 'harvest-coordinator',
36
+ ];
37
+
38
+ const EXPECTED_RULES = ['replicate-pipeline'];
39
+
40
+ function run(options) {
41
+ const { targetDir } = options;
42
+
43
+ let issues = 0;
44
+ let warnings = 0;
45
+
46
+ function pass(msg) { console.log(` ${green('\u2713')} ${msg}`); }
47
+ function fail(msg) { console.log(` ${red('\u2717')} ${msg}`); issues++; }
48
+ function hint(msg) { console.log(` ${yellow('!')} ${msg}`); warnings++; }
49
+
50
+ console.log(bold('P-Replicator \u2014 Health Check'));
51
+ console.log('');
52
+
53
+ // ── 1) Manifest ─────────────────────────────────────────────────────────
54
+ console.log(bold('Manifest:'));
55
+ const manifest = readManifest(targetDir);
56
+ if (manifest) {
57
+ pass(`${MANIFEST_FILE} found (v${manifest.version}, ${manifest.installedAt})`);
58
+ } else {
59
+ fail(`${MANIFEST_FILE} not found \u2014 not installed or manifest deleted`);
60
+ }
61
+ console.log('');
62
+
63
+ // ── 2) .claude directory ────────────────────────────────────────────────
64
+ console.log(bold('.claude/ directory:'));
65
+ const claudeDir = path.join(targetDir, '.claude');
66
+ if (fileExists(claudeDir)) {
67
+ pass('.claude/ exists');
68
+ } else {
69
+ fail('.claude/ directory not found');
70
+ console.log('');
71
+ logError(`Run ${cyan('npx @dzhechkov/p-replicator init')} to install.`);
72
+ process.exit(1);
73
+ }
74
+ console.log('');
75
+
76
+ // ── 3) Skills ───────────────────────────────────────────────────────────
77
+ console.log(bold('Skills (expected 10):'));
78
+ for (const skill of EXPECTED_SKILLS) {
79
+ const skillPath = path.join(claudeDir, 'skills', skill, 'SKILL.md');
80
+ if (fileExists(skillPath)) {
81
+ pass(skill);
82
+ } else {
83
+ fail(`${skill} \u2014 SKILL.md missing`);
84
+ }
85
+ }
86
+ console.log('');
87
+
88
+ // ── 4) Commands ─────────────────────────────────────────────────────────
89
+ console.log(bold('Commands (expected 2):'));
90
+ for (const cmd of EXPECTED_COMMANDS) {
91
+ const cmdPath = path.join(claudeDir, 'commands', `${cmd}.md`);
92
+ if (fileExists(cmdPath)) {
93
+ pass(`/${cmd}`);
94
+ } else {
95
+ fail(`/${cmd} \u2014 ${cmd}.md missing`);
96
+ }
97
+ }
98
+ console.log('');
99
+
100
+ // ── 5) Agents ───────────────────────────────────────────────────────────
101
+ console.log(bold('Agents (expected 4):'));
102
+ for (const agent of EXPECTED_AGENTS) {
103
+ const agentPath = path.join(claudeDir, 'agents', `${agent}.md`);
104
+ if (fileExists(agentPath)) {
105
+ pass(agent);
106
+ } else {
107
+ fail(`${agent} \u2014 ${agent}.md missing`);
108
+ }
109
+ }
110
+ console.log('');
111
+
112
+ // ── 6) Rules ────────────────────────────────────────────────────────────
113
+ console.log(bold('Rules (expected 1):'));
114
+ for (const rule of EXPECTED_RULES) {
115
+ const rulePath = path.join(claudeDir, 'rules', `${rule}.md`);
116
+ if (fileExists(rulePath)) {
117
+ pass(rule);
118
+ } else {
119
+ fail(`${rule} \u2014 ${rule}.md missing`);
120
+ }
121
+ }
122
+ console.log('');
123
+
124
+ // ── 7) Keysarium integration ────────────────────────────────────────────
125
+ console.log(bold('Integration:'));
126
+ const keysariumManifest = path.join(targetDir, '.keysarium.json');
127
+ if (fileExists(keysariumManifest)) {
128
+ pass('@dzhechkov/keysarium detected \u2014 compatible');
129
+ } else {
130
+ hint('@dzhechkov/keysarium not installed (optional)');
131
+ }
132
+ console.log('');
133
+
134
+ // ── 8) Summary ──────────────────────────────────────────────────────────
135
+ console.log(bold('\u2500'.repeat(50)));
136
+ if (issues === 0 && warnings === 0) {
137
+ success(bold('All checks passed!'));
138
+ } else if (issues === 0) {
139
+ success(`All checks passed with ${yellow(warnings + ' warning(s)')}.`);
140
+ } else {
141
+ logError(`${red(issues + ' issue(s)')} found, ${yellow(warnings + ' warning(s)')}.`);
142
+ console.log('');
143
+ info(`Run ${cyan('npx @dzhechkov/p-replicator init --force')} to repair.`);
144
+ }
145
+ console.log('');
146
+
147
+ process.exitCode = issues > 0 ? 1 : 0;
148
+ }
149
+
150
+ module.exports = run;
151
+ module.exports.run = run;