popeye-cli 1.7.0 → 1.9.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 (174) hide show
  1. package/README.md +148 -7
  2. package/cheatsheet.md +440 -0
  3. package/dist/cli/commands/db.d.ts +10 -0
  4. package/dist/cli/commands/db.d.ts.map +1 -0
  5. package/dist/cli/commands/db.js +240 -0
  6. package/dist/cli/commands/db.js.map +1 -0
  7. package/dist/cli/commands/doctor.d.ts +18 -0
  8. package/dist/cli/commands/doctor.d.ts.map +1 -0
  9. package/dist/cli/commands/doctor.js +255 -0
  10. package/dist/cli/commands/doctor.js.map +1 -0
  11. package/dist/cli/commands/index.d.ts +3 -0
  12. package/dist/cli/commands/index.d.ts.map +1 -1
  13. package/dist/cli/commands/index.js +3 -0
  14. package/dist/cli/commands/index.js.map +1 -1
  15. package/dist/cli/commands/review.d.ts +31 -0
  16. package/dist/cli/commands/review.d.ts.map +1 -0
  17. package/dist/cli/commands/review.js +156 -0
  18. package/dist/cli/commands/review.js.map +1 -0
  19. package/dist/cli/index.d.ts.map +1 -1
  20. package/dist/cli/index.js +4 -1
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/cli/interactive.d.ts.map +1 -1
  23. package/dist/cli/interactive.js +218 -61
  24. package/dist/cli/interactive.js.map +1 -1
  25. package/dist/generators/admin-wizard.d.ts +25 -0
  26. package/dist/generators/admin-wizard.d.ts.map +1 -0
  27. package/dist/generators/admin-wizard.js +123 -0
  28. package/dist/generators/admin-wizard.js.map +1 -0
  29. package/dist/generators/all.d.ts.map +1 -1
  30. package/dist/generators/all.js +10 -3
  31. package/dist/generators/all.js.map +1 -1
  32. package/dist/generators/database.d.ts +58 -0
  33. package/dist/generators/database.d.ts.map +1 -0
  34. package/dist/generators/database.js +229 -0
  35. package/dist/generators/database.js.map +1 -0
  36. package/dist/generators/fullstack.d.ts.map +1 -1
  37. package/dist/generators/fullstack.js +23 -7
  38. package/dist/generators/fullstack.js.map +1 -1
  39. package/dist/generators/index.d.ts +2 -0
  40. package/dist/generators/index.d.ts.map +1 -1
  41. package/dist/generators/index.js +2 -0
  42. package/dist/generators/index.js.map +1 -1
  43. package/dist/generators/templates/admin-wizard-python.d.ts +32 -0
  44. package/dist/generators/templates/admin-wizard-python.d.ts.map +1 -0
  45. package/dist/generators/templates/admin-wizard-python.js +425 -0
  46. package/dist/generators/templates/admin-wizard-python.js.map +1 -0
  47. package/dist/generators/templates/admin-wizard-react.d.ts +48 -0
  48. package/dist/generators/templates/admin-wizard-react.d.ts.map +1 -0
  49. package/dist/generators/templates/admin-wizard-react.js +554 -0
  50. package/dist/generators/templates/admin-wizard-react.js.map +1 -0
  51. package/dist/generators/templates/database-docker.d.ts +23 -0
  52. package/dist/generators/templates/database-docker.d.ts.map +1 -0
  53. package/dist/generators/templates/database-docker.js +221 -0
  54. package/dist/generators/templates/database-docker.js.map +1 -0
  55. package/dist/generators/templates/database-python.d.ts +54 -0
  56. package/dist/generators/templates/database-python.d.ts.map +1 -0
  57. package/dist/generators/templates/database-python.js +723 -0
  58. package/dist/generators/templates/database-python.js.map +1 -0
  59. package/dist/generators/templates/database-typescript.d.ts +34 -0
  60. package/dist/generators/templates/database-typescript.d.ts.map +1 -0
  61. package/dist/generators/templates/database-typescript.js +232 -0
  62. package/dist/generators/templates/database-typescript.js.map +1 -0
  63. package/dist/generators/templates/fullstack.d.ts.map +1 -1
  64. package/dist/generators/templates/fullstack.js +29 -0
  65. package/dist/generators/templates/fullstack.js.map +1 -1
  66. package/dist/generators/templates/index.d.ts +5 -0
  67. package/dist/generators/templates/index.d.ts.map +1 -1
  68. package/dist/generators/templates/index.js +5 -0
  69. package/dist/generators/templates/index.js.map +1 -1
  70. package/dist/state/index.d.ts +10 -0
  71. package/dist/state/index.d.ts.map +1 -1
  72. package/dist/state/index.js +21 -0
  73. package/dist/state/index.js.map +1 -1
  74. package/dist/types/audit.d.ts +623 -0
  75. package/dist/types/audit.d.ts.map +1 -0
  76. package/dist/types/audit.js +240 -0
  77. package/dist/types/audit.js.map +1 -0
  78. package/dist/types/database-runtime.d.ts +86 -0
  79. package/dist/types/database-runtime.d.ts.map +1 -0
  80. package/dist/types/database-runtime.js +61 -0
  81. package/dist/types/database-runtime.js.map +1 -0
  82. package/dist/types/database.d.ts +85 -0
  83. package/dist/types/database.d.ts.map +1 -0
  84. package/dist/types/database.js +71 -0
  85. package/dist/types/database.js.map +1 -0
  86. package/dist/types/index.d.ts +2 -0
  87. package/dist/types/index.d.ts.map +1 -1
  88. package/dist/types/index.js +4 -0
  89. package/dist/types/index.js.map +1 -1
  90. package/dist/types/workflow.d.ts +36 -0
  91. package/dist/types/workflow.d.ts.map +1 -1
  92. package/dist/types/workflow.js +7 -0
  93. package/dist/types/workflow.js.map +1 -1
  94. package/dist/workflow/audit-analyzer.d.ts +58 -0
  95. package/dist/workflow/audit-analyzer.d.ts.map +1 -0
  96. package/dist/workflow/audit-analyzer.js +420 -0
  97. package/dist/workflow/audit-analyzer.js.map +1 -0
  98. package/dist/workflow/audit-mode.d.ts +28 -0
  99. package/dist/workflow/audit-mode.d.ts.map +1 -0
  100. package/dist/workflow/audit-mode.js +169 -0
  101. package/dist/workflow/audit-mode.js.map +1 -0
  102. package/dist/workflow/audit-recovery.d.ts +61 -0
  103. package/dist/workflow/audit-recovery.d.ts.map +1 -0
  104. package/dist/workflow/audit-recovery.js +242 -0
  105. package/dist/workflow/audit-recovery.js.map +1 -0
  106. package/dist/workflow/audit-reporter.d.ts +65 -0
  107. package/dist/workflow/audit-reporter.d.ts.map +1 -0
  108. package/dist/workflow/audit-reporter.js +301 -0
  109. package/dist/workflow/audit-reporter.js.map +1 -0
  110. package/dist/workflow/audit-scanner.d.ts +87 -0
  111. package/dist/workflow/audit-scanner.d.ts.map +1 -0
  112. package/dist/workflow/audit-scanner.js +768 -0
  113. package/dist/workflow/audit-scanner.js.map +1 -0
  114. package/dist/workflow/db-setup-runner.d.ts +63 -0
  115. package/dist/workflow/db-setup-runner.d.ts.map +1 -0
  116. package/dist/workflow/db-setup-runner.js +336 -0
  117. package/dist/workflow/db-setup-runner.js.map +1 -0
  118. package/dist/workflow/db-state-machine.d.ts +30 -0
  119. package/dist/workflow/db-state-machine.d.ts.map +1 -0
  120. package/dist/workflow/db-state-machine.js +51 -0
  121. package/dist/workflow/db-state-machine.js.map +1 -0
  122. package/dist/workflow/index.d.ts +7 -0
  123. package/dist/workflow/index.d.ts.map +1 -1
  124. package/dist/workflow/index.js +7 -0
  125. package/dist/workflow/index.js.map +1 -1
  126. package/package.json +1 -1
  127. package/src/cli/commands/db.ts +281 -0
  128. package/src/cli/commands/doctor.ts +273 -0
  129. package/src/cli/commands/index.ts +3 -0
  130. package/src/cli/commands/review.ts +187 -0
  131. package/src/cli/index.ts +6 -0
  132. package/src/cli/interactive.ts +174 -4
  133. package/src/generators/admin-wizard.ts +146 -0
  134. package/src/generators/all.ts +10 -3
  135. package/src/generators/database.ts +286 -0
  136. package/src/generators/fullstack.ts +26 -9
  137. package/src/generators/index.ts +12 -0
  138. package/src/generators/templates/admin-wizard-python.ts +431 -0
  139. package/src/generators/templates/admin-wizard-react.ts +560 -0
  140. package/src/generators/templates/database-docker.ts +227 -0
  141. package/src/generators/templates/database-python.ts +734 -0
  142. package/src/generators/templates/database-typescript.ts +238 -0
  143. package/src/generators/templates/fullstack.ts +29 -0
  144. package/src/generators/templates/index.ts +5 -0
  145. package/src/state/index.ts +28 -0
  146. package/src/types/audit.ts +294 -0
  147. package/src/types/database-runtime.ts +69 -0
  148. package/src/types/database.ts +84 -0
  149. package/src/types/index.ts +29 -0
  150. package/src/types/workflow.ts +20 -0
  151. package/src/workflow/audit-analyzer.ts +491 -0
  152. package/src/workflow/audit-mode.ts +240 -0
  153. package/src/workflow/audit-recovery.ts +284 -0
  154. package/src/workflow/audit-reporter.ts +370 -0
  155. package/src/workflow/audit-scanner.ts +873 -0
  156. package/src/workflow/db-setup-runner.ts +391 -0
  157. package/src/workflow/db-state-machine.ts +58 -0
  158. package/src/workflow/index.ts +7 -0
  159. package/tests/cli/commands/review.test.ts +52 -0
  160. package/tests/generators/admin-wizard-orchestrator.test.ts +64 -0
  161. package/tests/generators/admin-wizard-templates.test.ts +366 -0
  162. package/tests/generators/cross-phase-integration.test.ts +383 -0
  163. package/tests/generators/database.test.ts +456 -0
  164. package/tests/generators/fe-be-db-integration.test.ts +613 -0
  165. package/tests/types/audit.test.ts +250 -0
  166. package/tests/types/database-runtime.test.ts +158 -0
  167. package/tests/types/database.test.ts +187 -0
  168. package/tests/workflow/audit-analyzer.test.ts +281 -0
  169. package/tests/workflow/audit-mode.test.ts +114 -0
  170. package/tests/workflow/audit-recovery.test.ts +237 -0
  171. package/tests/workflow/audit-reporter.test.ts +254 -0
  172. package/tests/workflow/audit-scanner.test.ts +270 -0
  173. package/tests/workflow/db-setup-runner.test.ts +211 -0
  174. package/tests/workflow/db-state-machine.test.ts +117 -0
package/README.md CHANGED
@@ -26,7 +26,8 @@ Popeye is an autonomous software development agent that takes a simple project i
26
26
  9. **Scans** generated website files for placeholder fingerprints (TODO comments, lorem ipsum, default tiers) and reports quality warnings
27
27
  10. **Styles** the application with a professional design system and component library
28
28
  11. **Tests** the implementation and fixes issues automatically with Tester-driven fix plans
29
- 12. **Delivers** a complete, working project with polished UI
29
+ 12. **Reviews** the completed project with a post-build audit that scores code quality, detects wiring issues, and generates recovery tasks
30
+ 13. **Delivers** a complete, working project with polished UI
30
31
 
31
32
  ## How It Works
32
33
 
@@ -435,6 +436,7 @@ Popeye provides real-time feedback:
435
436
  - How to run (development, tests, production)
436
437
  - Project structure overview
437
438
  - **Project Type Upgrade**: Upgrade projects in-place (e.g., python to fullstack, fullstack to all) with automatic file restructuring, scaffolding, and planning integration
439
+ - **Post-Build Audit/Review**: Run `popeye review` to scan your completed project, score it across 8 categories, detect FE-BE wiring issues, and auto-generate recovery milestones for critical findings
438
440
  - **Flexible Model Switching**: Use any AI model name for OpenAI, Gemini, or Grok providers -- not limited to a predefined list
439
441
 
440
442
  ### Automatic UI/UX Design
@@ -709,6 +711,70 @@ The `qaEnabled` field in `ProjectState` controls whether the 7-phase workflow is
709
711
  | `consensus.threshold` | 95 | Code plan consensus threshold |
710
712
  | `consensus.testPlanThreshold` | 90 | Test plan consensus threshold (lower to avoid over-engineering test plans) |
711
713
 
714
+ ### Deferred Database Integration
715
+
716
+ Fullstack and ALL projects include a 3-phase deferred database integration system. Instead of requiring a running database at project creation time, Popeye generates all the necessary database scaffolding and provides tools to configure and apply it later.
717
+
718
+ #### Phase 1: Types and Templates
719
+
720
+ The database layer generates production-ready templates for:
721
+
722
+ | Template Set | Contents |
723
+ |-------------|----------|
724
+ | **SQLAlchemy** | Connection module, startup hook, health route, conftest, Alembic config, initial migration |
725
+ | **Alembic** | `alembic.ini`, `env.py`, initial migration script |
726
+ | **pgvector** | Vector extension setup for AI/ML workloads |
727
+ | **Docker** | `docker-compose.yml` with PostgreSQL service, health checks, volumes |
728
+ | **Environment** | `.env.example` with `DATABASE_URL`, `ADMIN_SETUP_TOKEN` |
729
+
730
+ Database configuration is tracked in `ProjectState.dbConfig` with the following status lifecycle:
731
+
732
+ ```
733
+ none -> configured -> migrating -> ready
734
+ \-> error
735
+ ```
736
+
737
+ #### Phase 2: State Machine and CLI Commands
738
+
739
+ The database lifecycle is managed by a state machine (`db-state-machine.ts`) that enforces valid transitions between statuses. Two CLI commands provide management:
740
+
741
+ **`/db [action]`** -- Database management:
742
+ - `/db status` -- Show current database configuration and status
743
+ - `/db configure` -- Interactively set DATABASE_URL and write to `.env`
744
+ - `/db apply` -- Run the setup pipeline (create tables, run migrations)
745
+
746
+ **`/doctor`** -- Readiness checks (8 checks):
747
+ - `.env` file exists with `DATABASE_URL`
748
+ - Backend directory structure is valid
749
+ - `requirements.txt` includes database dependencies
750
+ - Alembic configuration is present
751
+ - Docker Compose includes postgres service
752
+ - Database connection is reachable
753
+ - Migrations are up to date
754
+ - Health endpoint returns OK
755
+
756
+ #### Phase 3: Admin Wizard UI
757
+
758
+ The admin wizard generates a complete database setup experience with both backend and frontend components:
759
+
760
+ **Backend (FastAPI):**
761
+ - `admin_auth.py` middleware -- Validates `X-Admin-Token` header against `ADMIN_SETUP_TOKEN` env var
762
+ - `admin_db.py` routes -- RESTful endpoints under `/api/admin/db`:
763
+ - `GET /status` -- Current DB status, migration count, connection info
764
+ - `POST /configure` -- Save database URL to `.env`
765
+ - `POST /test` -- Test database connectivity
766
+ - `POST /apply` -- Run Alembic migrations
767
+ - `POST /rollback` -- Roll back the last migration
768
+
769
+ **Frontend (React):**
770
+ - `useAdminApi` hook -- Authenticated API calls with `X-Admin-Token` header
771
+ - `DbStatusBanner` -- Displays current database status with color-coded indicators
772
+ - `ConnectionForm` -- Database URL input with connection test button
773
+ - `MigrationProgress` -- Real-time migration progress display
774
+ - `DbSetupStepper` -- Step-by-step wizard guiding the full setup flow
775
+
776
+ Both the `fullstack.ts` and `all.ts` generators wire the admin wizard layer automatically. The admin wizard files are included in `getFullstackProjectFiles()` and `getAllProjectFiles()` for validation.
777
+
712
778
  ### Observability Features
713
779
 
714
780
  - **Workflow Logging**: Detailed logs written to `docs/WORKFLOW_LOG.md`
@@ -831,6 +897,40 @@ popeye config set consensus.threshold 90
831
897
  popeye config reset
832
898
  ```
833
899
 
900
+ ### `popeye review` (alias: `audit`)
901
+
902
+ Run a post-build audit/review of the project. Scans the codebase, produces a structured report with findings and scores, and optionally generates recovery milestones.
903
+
904
+ ```bash
905
+ # Standard audit
906
+ popeye review ./my-project
907
+
908
+ # Deep audit with strict mode
909
+ popeye review ./my-project --depth 3 --strict
910
+
911
+ # JSON only, no auto-recovery
912
+ popeye review ./my-project --format json --no-recover
913
+
914
+ # Audit only the frontend component
915
+ popeye review ./my-project --target frontend
916
+ ```
917
+
918
+ **Options:**
919
+ | Option | Description | Default |
920
+ |--------|-------------|---------|
921
+ | `-d, --depth <level>` | Audit depth: `1`=shallow, `2`=standard, `3`=deep | `2` |
922
+ | `-s, --strict` | Enable strict mode (higher standards) | `false` |
923
+ | `-f, --format <type>` | Output format: `json`, `md`, `both` | `both` |
924
+ | `--no-recover` | Skip auto-injection of recovery milestones | Recovery on |
925
+ | `-t, --target <kind>` | Audit target: `all`, `frontend`, `backend`, `website` | `all` |
926
+
927
+ The audit runs three stages:
928
+ 1. **Scan** -- Deterministic filesystem scan (files, LOC, dependencies, FE-BE wiring matrix)
929
+ 2. **Analyze** -- AI-powered analysis producing scored findings across 8 categories
930
+ 3. **Recovery** -- Evidence-based recovery plan generation when critical/major findings exist
931
+
932
+ Reports are written to `.popeye/popeye.audit.md`, `.popeye/popeye.audit.json`, and optionally `.popeye/popeye.recovery.md`/`.json`. Recovery milestones are injected into the project state and can be executed with `popeye resume`.
933
+
834
934
  ### Interactive Mode
835
935
 
836
936
  Launch an interactive REPL session:
@@ -855,6 +955,10 @@ popeye
855
955
  /model [provider] [model] Show/set AI model (openai/gemini/grok)
856
956
  /model <provider> list Show known models for a provider
857
957
  /upgrade [target] Upgrade project type (e.g., fullstack -> all)
958
+ /overview [fix] Project review with analysis; fix to auto-discover docs
959
+ /db [action] Database management (status/configure/apply)
960
+ /doctor Run database and project readiness checks
961
+ /review Run post-build audit with findings and recovery
858
962
  /info Show system info (Claude CLI status, API keys, etc.)
859
963
  /clear Clear screen
860
964
  /exit Exit interactive mode
@@ -1150,6 +1254,13 @@ my-project/
1150
1254
  │ │ ├── src/
1151
1255
  │ │ │ ├── components/
1152
1256
  │ │ │ │ └── ui/ # shadcn/ui components
1257
+ │ │ │ ├── admin/ # Admin wizard components
1258
+ │ │ │ │ ├── useAdminApi.ts # Authenticated API hook
1259
+ │ │ │ │ ├── DbStatusBanner.tsx # DB status indicator
1260
+ │ │ │ │ ├── ConnectionForm.tsx # DB URL input + test
1261
+ │ │ │ │ ├── MigrationProgress.tsx # Migration progress
1262
+ │ │ │ │ ├── DbSetupStepper.tsx # Setup wizard stepper
1263
+ │ │ │ │ └── index.ts # Admin component exports
1153
1264
  │ │ │ ├── pages/
1154
1265
  │ │ │ ├── hooks/
1155
1266
  │ │ │ ├── lib/
@@ -1165,11 +1276,22 @@ my-project/
1165
1276
  │ │
1166
1277
  │ └── backend/ # FastAPI backend
1167
1278
  │ ├── src/
1168
- │ │ ├── api/
1169
- │ │ │ └── routes/
1279
+ │ │ ├── {package}/
1280
+ │ │ │ ├── routes/
1281
+ │ │ │ │ ├── health_db.py # DB health endpoint
1282
+ │ │ │ │ └── admin_db.py # Admin wizard routes
1283
+ │ │ │ ├── middleware/
1284
+ │ │ │ │ ├── __init__.py
1285
+ │ │ │ │ └── admin_auth.py # X-Admin-Token validation
1286
+ │ │ │ ├── db.py # SQLAlchemy connection module
1287
+ │ │ │ └── main.py
1170
1288
  │ │ ├── models/
1171
1289
  │ │ ├── services/
1172
1290
  │ │ └── main.py
1291
+ │ ├── alembic/ # Database migrations
1292
+ │ │ ├── env.py
1293
+ │ │ └── versions/
1294
+ │ ├── alembic.ini
1173
1295
  │ ├── tests/
1174
1296
  │ │ └── conftest.py
1175
1297
  │ ├── pyproject.toml
@@ -1215,7 +1337,7 @@ my-project/
1215
1337
  ├── README.md
1216
1338
  ├── .gitignore
1217
1339
  ├── .env.example
1218
- ├── docker-compose.yml # Full stack orchestration
1340
+ ├── docker-compose.yml # Full stack orchestration (includes PostgreSQL service)
1219
1341
  ├── popeye.md # Project configuration
1220
1342
  └── .popeye/
1221
1343
  ├── state.json
@@ -1434,8 +1556,11 @@ src/
1434
1556
  ├── cli/ # CLI interface
1435
1557
  │ ├── index.ts # Command setup
1436
1558
  │ ├── output.ts # Output formatting
1437
- │ ├── interactive.ts # REPL mode (with /model, /upgrade, /overview commands)
1559
+ │ ├── interactive.ts # REPL mode (with /model, /upgrade, /overview, /db, /doctor commands)
1438
1560
  │ └── commands/ # Individual commands
1561
+ │ ├── db.ts # Database management CLI (status/configure/apply)
1562
+ │ ├── doctor.ts # Readiness checks (8 checks for DB and project health)
1563
+ │ └── review.ts # Post-build audit/review CLI command
1439
1564
  ├── adapters/ # AI service adapters
1440
1565
  │ ├── claude.ts # Claude Agent SDK (with rate limiting)
1441
1566
  │ ├── openai.ts # OpenAI API (default reviewer, marketing persona for websites)
@@ -1456,6 +1581,8 @@ src/
1456
1581
  │ ├── website-context.ts # Doc discovery, brand assets, content context, dual-mode validation
1457
1582
  │ ├── website-content-scanner.ts # Post-generation placeholder fingerprint scanner
1458
1583
  │ ├── doc-parser.ts # Product doc parsing (name, tagline, features, pricing, color)
1584
+ │ ├── database.ts # DB layer orchestration (generatePythonDatabaseLayer, getDatabaseFiles)
1585
+ │ ├── admin-wizard.ts # Admin wizard orchestration (generateAdminWizardLayer, getAdminWizardFiles)
1459
1586
  │ ├── all.ts # ALL project scaffolding (exports 5 generator functions)
1460
1587
  │ └── templates/ # File templates
1461
1588
  │ ├── python.ts
@@ -1466,6 +1593,10 @@ src/
1466
1593
  │ ├── website-components.ts # Header, Footer, Navigation components
1467
1594
  │ ├── website-seo.ts # JSON-LD, sitemap, robots, 404, 500, manifest, meta
1468
1595
  │ ├── website-conversion.ts # Lead capture route, contact form, env examples
1596
+ │ ├── database-python.ts # SQLAlchemy + Alembic + pgvector templates (12 functions)
1597
+ │ ├── database-docker.ts # Docker Compose + postgres service templates
1598
+ │ ├── admin-wizard-python.ts # FastAPI admin auth middleware + admin DB routes
1599
+ │ ├── admin-wizard-react.ts # React admin wizard components (status, forms, stepper)
1469
1600
  │ └── index.ts # Template module exports
1470
1601
  ├── state/ # State management
1471
1602
  │ ├── persistence.ts # File operations
@@ -1482,6 +1613,8 @@ src/
1482
1613
  │ ├── milestone-workflow.ts
1483
1614
  │ ├── task-workflow.ts # 7-phase task workflow with QA gate
1484
1615
  │ ├── tester.ts # QA skill: test planning, review, fix plans (provider-agnostic)
1616
+ │ ├── db-state-machine.ts # DB lifecycle state transitions (canTransition, transitionDbStatus)
1617
+ │ ├── db-setup-runner.ts # DB setup pipeline runner (env parsing, migration prereqs)
1485
1618
  │ ├── test-runner.ts # Test execution
1486
1619
  │ ├── workflow-logger.ts # Persistent logging (test-planning, test-review stages)
1487
1620
  │ ├── plan-storage.ts # Consensus docs storage (per-app feedback)
@@ -1495,12 +1628,20 @@ src/
1495
1628
  │ ├── project-verification.ts # Project quality checks
1496
1629
  │ ├── project-structure.ts # Project directory scanner
1497
1630
  │ ├── remediation.ts # Consensus-driven failure recovery
1498
- └── auto-fix.ts # Automatic error fixing (enhanced ENOENT tracking)
1631
+ ├── auto-fix.ts # Automatic error fixing (enhanced ENOENT tracking)
1632
+ │ ├── audit-scanner.ts # Deterministic project scanning (components, wiring, docs)
1633
+ │ ├── audit-analyzer.ts # AI-powered analysis with Serena-first search
1634
+ │ ├── audit-reporter.ts # Markdown + JSON report generation
1635
+ │ ├── audit-recovery.ts # Evidence-based recovery plan generation
1636
+ │ └── audit-mode.ts # Audit orchestrator (scan -> analyze -> recover)
1499
1637
  └── types/ # TypeScript types
1500
1638
  ├── project.ts # OutputLanguage, isWorkspace(), flexible OpenAIModelSchema
1501
- ├── workflow.ts # ProjectStateSchema (qaEnabled, qa* task fields)
1639
+ ├── workflow.ts # ProjectStateSchema (qaEnabled, dbConfig, qa* task fields)
1502
1640
  ├── consensus.ts # GeminiModelSchema, GrokModelSchema, reviewerPersona, testPlanThreshold
1503
1641
  ├── tester.ts # TestVerdict, TestPlanOutput, TestRunReview, TestFixPlan
1642
+ ├── audit.ts # Audit system schemas (findings, recovery, wiring, scores)
1643
+ ├── database.ts # DbStatus, DbMode, DbConfig, DbSetupStep Zod schemas
1644
+ ├── database-runtime.ts # SetupStepResult, ReadinessCheck runtime schemas
1504
1645
  └── website-strategy.ts # WebsiteStrategyDocument, BrandAssetsContract, DesignTokens
1505
1646
  ```
1506
1647
 
package/cheatsheet.md ADDED
@@ -0,0 +1,440 @@
1
+ # Popeye CLI Cheatsheet
2
+
3
+ Quick reference for all Popeye CLI commands, interactive mode slash commands, and configuration options.
4
+
5
+ ---
6
+
7
+ ## CLI Commands
8
+
9
+ ### `popeye-cli create <idea>`
10
+
11
+ Create a new project from a natural language description.
12
+
13
+ | Option | Description | Default |
14
+ |--------|-------------|---------|
15
+ | `-n, --name <name>` | Project name | Auto-generated |
16
+ | `-l, --language <lang>` | Output language (`python`, `typescript`, `fullstack`, `website`, `all`) | `python` |
17
+ | `-m, --model <model>` | OpenAI model for consensus | `gpt-4o` |
18
+ | `-o, --output <dir>` | Output directory | Current directory |
19
+ | `--threshold <percent>` | Consensus threshold percentage | `95` |
20
+ | `--max-iterations <n>` | Maximum consensus iterations | `5` |
21
+ | `--skip-scaffold` | Skip initial project scaffolding | `false` |
22
+
23
+ ```bash
24
+ popeye-cli create "todo app with user authentication" -l fullstack -n my-todo
25
+ ```
26
+
27
+ ---
28
+
29
+ ### `popeye-cli interactive` (alias: `i`)
30
+
31
+ Start interactive mode for guided project creation and management. This is the default when running `popeye-cli` with no arguments.
32
+
33
+ ```bash
34
+ popeye-cli interactive
35
+ popeye-cli i
36
+ ```
37
+
38
+ ---
39
+
40
+ ### `popeye-cli status [directory]`
41
+
42
+ Show current project status and progress.
43
+
44
+ | Option | Description |
45
+ |--------|-------------|
46
+ | `-v, --verbose` | Show detailed status |
47
+ | `--json` | Output as JSON |
48
+
49
+ ```bash
50
+ popeye-cli status ./my-project --verbose
51
+ ```
52
+
53
+ ---
54
+
55
+ ### `popeye-cli validate [directory]`
56
+
57
+ Validate that a project structure is complete and ready for execution.
58
+
59
+ ```bash
60
+ popeye-cli validate ./my-project
61
+ ```
62
+
63
+ ---
64
+
65
+ ### `popeye-cli summary [directory]`
66
+
67
+ Show a detailed project summary including plan, milestones, and current progress.
68
+
69
+ ```bash
70
+ popeye-cli summary ./my-project
71
+ ```
72
+
73
+ ---
74
+
75
+ ### `popeye-cli resume [directory]`
76
+
77
+ Resume an interrupted workflow from where it left off.
78
+
79
+ | Option | Description | Default |
80
+ |--------|-------------|---------|
81
+ | `--threshold <percent>` | Consensus threshold | `95` |
82
+ | `--max-iterations <n>` | Max consensus iterations | `5` |
83
+ | `--max-retries <n>` | Max task retries | `3` |
84
+
85
+ ```bash
86
+ popeye-cli resume ./my-project
87
+ ```
88
+
89
+ ---
90
+
91
+ ### `popeye-cli reset [directory]`
92
+
93
+ Reset a project to a specific phase, discarding progress beyond that point.
94
+
95
+ | Option | Description | Default |
96
+ |--------|-------------|---------|
97
+ | `-p, --phase <phase>` | Phase to reset to (`plan`, `execution`) | `plan` |
98
+ | `-f, --force` | Skip confirmation prompt | `false` |
99
+
100
+ ```bash
101
+ popeye-cli reset ./my-project --phase plan --force
102
+ ```
103
+
104
+ ---
105
+
106
+ ### `popeye-cli cancel [directory]`
107
+
108
+ Cancel and delete a project entirely.
109
+
110
+ | Option | Description |
111
+ |--------|-------------|
112
+ | `-f, --force` | Skip confirmation prompt |
113
+
114
+ ```bash
115
+ popeye-cli cancel ./my-project --force
116
+ ```
117
+
118
+ ---
119
+
120
+ ### `popeye-cli auth <subcommand>`
121
+
122
+ Manage authentication for AI provider services.
123
+
124
+ | Subcommand | Description |
125
+ |------------|-------------|
126
+ | `status` | Show authentication status for all services |
127
+ | `login [service]` | Authenticate with a service (`claude`, `openai`, `gemini`, `grok`, `all`) |
128
+ | `logout [service]` | Remove stored credentials for a service |
129
+ | `claude` | Authenticate with Claude CLI |
130
+ | `openai` | Authenticate with OpenAI API |
131
+ | `gemini` | Authenticate with Gemini API |
132
+ | `grok` | Authenticate with xAI Grok API |
133
+
134
+ The `login`, `openai`, `gemini`, and `grok` subcommands accept `--api-key <key>` to provide a key directly.
135
+
136
+ ```bash
137
+ popeye-cli auth status
138
+ popeye-cli auth login openai --api-key sk-...
139
+ popeye-cli auth logout all
140
+ ```
141
+
142
+ ---
143
+
144
+ ### `popeye-cli config <subcommand>`
145
+
146
+ Manage CLI configuration settings.
147
+
148
+ | Subcommand | Description |
149
+ |------------|-------------|
150
+ | `show` | Show current configuration (`--json` for JSON output) |
151
+ | `defaults` | Show default configuration values (`--json` for JSON output) |
152
+ | `get <key>` | Get a specific config value (e.g., `consensus.threshold`) |
153
+ | `path` | Show the configuration file path |
154
+ | `init` | Create a configuration file (`-f, --format <json\|yaml>`) |
155
+
156
+ ```bash
157
+ popeye-cli config show --json
158
+ popeye-cli config get consensus.threshold
159
+ popeye-cli config init --format yaml
160
+ ```
161
+
162
+ ---
163
+
164
+ ### `popeye-cli db <subcommand>`
165
+
166
+ Manage database configuration and setup for fullstack/all projects.
167
+
168
+ | Subcommand | Description |
169
+ |------------|-------------|
170
+ | `status [directory]` | Show database configuration and lifecycle status |
171
+ | `configure [directory]` | Configure database mode (local Docker or managed) and connection URL |
172
+ | `apply [directory]` | Run the full setup pipeline: connectivity check, extensions, migrations, seed, readiness |
173
+
174
+ The `apply` subcommand accepts `--skip-seed` to skip the seed step.
175
+
176
+ ```bash
177
+ popeye-cli db status ./my-project
178
+ popeye-cli db configure ./my-project
179
+ popeye-cli db apply ./my-project --skip-seed
180
+ ```
181
+
182
+ **Database lifecycle**: `unconfigured` -> `configured` -> `applying` -> `ready` (or `error`)
183
+
184
+ ---
185
+
186
+ ### `popeye-cli doctor [directory]`
187
+
188
+ Run comprehensive project and database readiness checks.
189
+
190
+ Checks performed:
191
+ 1. **Project State** -- Verifies `.popeye/` state directory exists
192
+ 2. **DB Layer** -- Confirms database layer was generated
193
+ 3. **Docker Compose** -- Checks PostgreSQL service is defined
194
+ 4. **DATABASE_URL** -- Validates the env var is configured
195
+ 5. **DB Reachability** -- Tests actual database connectivity
196
+ 6. **pgvector Extension** -- Checks if the vector extension is available
197
+ 7. **Migrations Applied** -- Queries `alembic_version` for migration status
198
+ 8. **Health Endpoint** -- Pings the backend `/health/db` endpoint
199
+
200
+ ```bash
201
+ popeye-cli doctor ./my-project
202
+ ```
203
+
204
+ ---
205
+
206
+ ### `popeye-cli review [directory]` (alias: `audit`)
207
+
208
+ Run a post-build audit/review of the project. Scans the codebase, produces a structured report with findings, and optionally generates recovery milestones.
209
+
210
+ | Option | Description | Default |
211
+ |--------|-------------|---------|
212
+ | `-d, --depth <level>` | Audit depth: `1`=shallow, `2`=standard, `3`=deep | `2` |
213
+ | `-s, --strict` | Enable strict mode (higher standards, stricter recovery triggers) | `false` |
214
+ | `-f, --format <type>` | Output format: `json`, `md`, `both` | `both` |
215
+ | `--no-recover` | Skip auto-injection of recovery milestones | Recovery enabled by default |
216
+ | `-t, --target <kind>` | Audit target: `all`, `frontend`, `backend`, `website` | `all` |
217
+
218
+ The audit runs three stages:
219
+ 1. **Scan** -- Deterministic filesystem scan (files, LOC, deps, wiring matrix)
220
+ 2. **Analyze** -- AI-powered analysis producing scored findings
221
+ 3. **Recovery** -- Evidence-based recovery plan generation (if critical/major findings exist)
222
+
223
+ Reports are written to `.popeye/popeye.audit.md`, `.popeye/popeye.audit.json`, and optionally `.popeye/popeye.recovery.md`/`.json`.
224
+
225
+ ```bash
226
+ popeye-cli review ./my-project
227
+ popeye-cli review ./my-project --depth 3 --strict
228
+ popeye-cli review ./my-project --format json --no-recover
229
+ popeye-cli audit ./my-project --target frontend
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Interactive Mode Slash Commands
235
+
236
+ Enter these commands during an interactive session (started via `popeye-cli interactive`).
237
+
238
+ ### Help and Info
239
+
240
+ | Command | Description |
241
+ |---------|-------------|
242
+ | `/help`, `/h`, `/?` | Show all available commands |
243
+ | `/info`, `/check` | Show system info: Claude CLI status, API auth status, environment |
244
+
245
+ ### Project Creation and Management
246
+
247
+ | Command | Description |
248
+ |---------|-------------|
249
+ | `/new <idea>` | Start a new project (skips existing project check) |
250
+ | `/resume` | Resume an interrupted project with project discovery |
251
+ | `/status` | Show current project status and progress |
252
+ | `/overview [fix]` | Show full project plan and milestone review. Add `fix` to re-discover docs and auto-fix issues |
253
+
254
+ ```
255
+ /new todo app with drag and drop
256
+ /resume
257
+ /overview fix
258
+ ```
259
+
260
+ ### Authentication
261
+
262
+ | Command | Description |
263
+ |---------|-------------|
264
+ | `/auth` | Re-run the authentication flow for all AI services |
265
+
266
+ ### Configuration
267
+
268
+ | Command | Description |
269
+ |---------|-------------|
270
+ | `/config` | Show full configuration summary |
271
+ | `/config reviewer <provider>` | Set reviewer model (`openai`, `gemini`, `grok`) |
272
+ | `/config arbitrator <provider\|off>` | Set arbitrator model or disable it |
273
+ | `/config language <lang>` | Set project output language |
274
+ | `/config model <provider> [model]` | Show or set AI model for a provider |
275
+
276
+ ### Language and Model Selection
277
+
278
+ | Command | Description |
279
+ |---------|-------------|
280
+ | `/language <lang>`, `/lang`, `/l` | Set output language: `be`, `fe`, `fs`, `web`, `all` |
281
+ | `/model` | Show current models for all providers |
282
+ | `/model <provider>` | Show available models for a provider |
283
+ | `/model <provider> <model>` | Set a specific model for a provider |
284
+
285
+ ```
286
+ /lang fullstack
287
+ /model openai gpt-4o-mini
288
+ /model gemini gemini-2.0-flash
289
+ /model grok grok-3
290
+ ```
291
+
292
+ ### Project Upgrade
293
+
294
+ | Command | Description |
295
+ |---------|-------------|
296
+ | `/upgrade` | Show interactive upgrade menu |
297
+ | `/upgrade <target>` | Upgrade project to a different type (`fullstack`, `website`, `all`, etc.) |
298
+
299
+ Available upgrade paths depend on the current project type:
300
+ - `python` -> `fullstack`, `all`
301
+ - `typescript` -> `fullstack`, `all`
302
+ - `fullstack` -> `all`
303
+ - `website` -> `all`
304
+
305
+ ```
306
+ /upgrade fullstack
307
+ /upgrade all
308
+ ```
309
+
310
+ ### Database and Health
311
+
312
+ | Command | Description |
313
+ |---------|-------------|
314
+ | `/db status` | Show database lifecycle status |
315
+ | `/db configure` | Configure database (redirects to CLI) |
316
+ | `/db apply` | Apply database setup (redirects to CLI) |
317
+ | `/doctor` | Run all readiness checks inline |
318
+ | `/review`, `/audit` | Run a post-build audit with findings and optional recovery |
319
+
320
+ ### Session Control
321
+
322
+ | Command | Description |
323
+ |---------|-------------|
324
+ | `/clear`, `/cls` | Clear screen and redraw the UI |
325
+ | `/exit`, `/quit`, `/q` | Exit Popeye CLI |
326
+
327
+ ### Default Behavior
328
+
329
+ Typing anything without a `/` prefix treats the input as a project idea for creation or refinement.
330
+
331
+ ---
332
+
333
+ ## Language Aliases
334
+
335
+ | Language | Aliases | What it generates |
336
+ |----------|---------|-------------------|
337
+ | `python` | `be`, `backend`, `py` | FastAPI backend API |
338
+ | `typescript` | `fe`, `frontend`, `ts` | React + Vite frontend |
339
+ | `fullstack` | `fs` | Monorepo: React frontend + FastAPI backend + PostgreSQL |
340
+ | `website` | `web` | Next.js marketing/landing website |
341
+ | `all` | -- | Complete stack: frontend + backend + website + shared packages |
342
+
343
+ ---
344
+
345
+ ## Available AI Models
346
+
347
+ ### OpenAI
348
+
349
+ `gpt-4o`, `gpt-4o-mini`, `gpt-4-turbo`, `o1-preview`, `o1-mini` (custom models also accepted)
350
+
351
+ ### Gemini
352
+
353
+ `gemini-2.0-flash`, `gemini-2.0-pro`, `gemini-1.5-flash`, `gemini-1.5-pro` (custom models also accepted)
354
+
355
+ ### Grok (xAI)
356
+
357
+ `grok-3`, `grok-3-mini`, `grok-2` (custom models also accepted)
358
+
359
+ ---
360
+
361
+ ## Configuration Files
362
+
363
+ Popeye looks for configuration in these files (in order):
364
+
365
+ - `.popeyerc`
366
+ - `.popeyerc.json`
367
+ - `.popeyerc.yaml`
368
+ - `popeye.config.js`
369
+
370
+ ### Config Sections
371
+
372
+ | Section | Keys | Description |
373
+ |---------|------|-------------|
374
+ | `consensus` | `threshold`, `maxIterations`, `temperature`, `maxTokens` | Consensus engine settings |
375
+ | `apis` | `openai.model`, `openai.timeout` | API provider settings |
376
+ | `project` | `defaultLanguage`, `defaultName` | Project defaults |
377
+ | `directories` | `output`, `state` | Directory paths |
378
+ | `output` | `verbose`, `colors`, `progress` | Display settings |
379
+
380
+ ---
381
+
382
+ ## Database Lifecycle States
383
+
384
+ ```
385
+ unconfigured ──> configured ──> applying ──> ready
386
+ ^ │
387
+ │ error <──────┘
388
+ │ │
389
+ └──────────────┘
390
+ ```
391
+
392
+ | State | Meaning |
393
+ |-------|---------|
394
+ | `unconfigured` | No `DATABASE_URL` set, DB layer not configured |
395
+ | `configured` | URL set and DB reachable, migrations not yet applied |
396
+ | `applying` | Setup pipeline is running (migrations, extensions, seed) |
397
+ | `ready` | All checks passed, database is operational |
398
+ | `error` | Setup failed, can retry from `configured` |
399
+
400
+ ---
401
+
402
+ ## Setup Pipeline Steps
403
+
404
+ When you run `popeye-cli db apply`, the pipeline executes these steps in order:
405
+
406
+ 1. **check_connection** -- Verify database is reachable
407
+ 2. **ensure_extensions** -- Create required PostgreSQL extensions (pgvector)
408
+ 3. **apply_migrations** -- Run `alembic upgrade head`
409
+ 4. **seed_minimal** -- Execute seed script if present
410
+ 5. **readiness_tests** -- Verify database is fully operational
411
+ 6. **mark_ready** -- Transition status to `ready`
412
+
413
+ ---
414
+
415
+ ## Quick Examples
416
+
417
+ ```bash
418
+ # Create a fullstack project
419
+ popeye-cli create "task management app" -l fullstack -n taskmaster
420
+
421
+ # Start interactive mode
422
+ popeye-cli
423
+
424
+ # Check project health
425
+ popeye-cli doctor ./taskmaster
426
+
427
+ # Set up the database
428
+ popeye-cli db configure ./taskmaster
429
+ popeye-cli db apply ./taskmaster
430
+
431
+ # Resume after interruption
432
+ popeye-cli resume ./taskmaster
433
+
434
+ # Audit the project after build
435
+ popeye-cli review ./taskmaster
436
+ popeye-cli review ./taskmaster --depth 3 --strict
437
+
438
+ # Reset and re-plan
439
+ popeye-cli reset ./taskmaster --phase plan
440
+ ```
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Database CLI command
3
+ * Provides subcommands: status, configure, apply
4
+ */
5
+ import { Command } from 'commander';
6
+ /**
7
+ * Create the db command with subcommands
8
+ */
9
+ export declare function createDbCommand(): Command;
10
+ //# sourceMappingURL=db.d.ts.map