popeye-cli 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 (166) hide show
  1. package/README.md +521 -125
  2. package/dist/adapters/claude.d.ts +16 -4
  3. package/dist/adapters/claude.d.ts.map +1 -1
  4. package/dist/adapters/claude.js +679 -33
  5. package/dist/adapters/claude.js.map +1 -1
  6. package/dist/adapters/gemini.d.ts +55 -0
  7. package/dist/adapters/gemini.d.ts.map +1 -0
  8. package/dist/adapters/gemini.js +318 -0
  9. package/dist/adapters/gemini.js.map +1 -0
  10. package/dist/adapters/openai.d.ts.map +1 -1
  11. package/dist/adapters/openai.js +41 -7
  12. package/dist/adapters/openai.js.map +1 -1
  13. package/dist/auth/claude.d.ts +11 -9
  14. package/dist/auth/claude.d.ts.map +1 -1
  15. package/dist/auth/claude.js +107 -71
  16. package/dist/auth/claude.js.map +1 -1
  17. package/dist/auth/gemini.d.ts +58 -0
  18. package/dist/auth/gemini.d.ts.map +1 -0
  19. package/dist/auth/gemini.js +172 -0
  20. package/dist/auth/gemini.js.map +1 -0
  21. package/dist/auth/index.d.ts +11 -7
  22. package/dist/auth/index.d.ts.map +1 -1
  23. package/dist/auth/index.js +23 -5
  24. package/dist/auth/index.js.map +1 -1
  25. package/dist/auth/keychain.d.ts +20 -7
  26. package/dist/auth/keychain.d.ts.map +1 -1
  27. package/dist/auth/keychain.js +85 -29
  28. package/dist/auth/keychain.js.map +1 -1
  29. package/dist/auth/openai.d.ts +2 -2
  30. package/dist/auth/openai.d.ts.map +1 -1
  31. package/dist/auth/openai.js +30 -32
  32. package/dist/auth/openai.js.map +1 -1
  33. package/dist/cli/interactive.d.ts.map +1 -1
  34. package/dist/cli/interactive.js +1151 -110
  35. package/dist/cli/interactive.js.map +1 -1
  36. package/dist/config/defaults.d.ts +6 -1
  37. package/dist/config/defaults.d.ts.map +1 -1
  38. package/dist/config/defaults.js +10 -2
  39. package/dist/config/defaults.js.map +1 -1
  40. package/dist/config/index.d.ts +10 -0
  41. package/dist/config/index.d.ts.map +1 -1
  42. package/dist/config/index.js +19 -0
  43. package/dist/config/index.js.map +1 -1
  44. package/dist/config/schema.d.ts +20 -0
  45. package/dist/config/schema.d.ts.map +1 -1
  46. package/dist/config/schema.js +7 -0
  47. package/dist/config/schema.js.map +1 -1
  48. package/dist/generators/python.d.ts.map +1 -1
  49. package/dist/generators/python.js +1 -0
  50. package/dist/generators/python.js.map +1 -1
  51. package/dist/generators/typescript.d.ts.map +1 -1
  52. package/dist/generators/typescript.js +1 -0
  53. package/dist/generators/typescript.js.map +1 -1
  54. package/dist/state/index.d.ts +108 -0
  55. package/dist/state/index.d.ts.map +1 -1
  56. package/dist/state/index.js +551 -4
  57. package/dist/state/index.js.map +1 -1
  58. package/dist/state/registry.d.ts +52 -0
  59. package/dist/state/registry.d.ts.map +1 -0
  60. package/dist/state/registry.js +215 -0
  61. package/dist/state/registry.js.map +1 -0
  62. package/dist/types/cli.d.ts +4 -0
  63. package/dist/types/cli.d.ts.map +1 -1
  64. package/dist/types/cli.js.map +1 -1
  65. package/dist/types/consensus.d.ts +69 -4
  66. package/dist/types/consensus.d.ts.map +1 -1
  67. package/dist/types/consensus.js +24 -3
  68. package/dist/types/consensus.js.map +1 -1
  69. package/dist/types/workflow.d.ts +55 -0
  70. package/dist/types/workflow.d.ts.map +1 -1
  71. package/dist/types/workflow.js +16 -0
  72. package/dist/types/workflow.js.map +1 -1
  73. package/dist/workflow/auto-fix.d.ts +45 -0
  74. package/dist/workflow/auto-fix.d.ts.map +1 -0
  75. package/dist/workflow/auto-fix.js +274 -0
  76. package/dist/workflow/auto-fix.js.map +1 -0
  77. package/dist/workflow/consensus.d.ts +44 -2
  78. package/dist/workflow/consensus.d.ts.map +1 -1
  79. package/dist/workflow/consensus.js +565 -17
  80. package/dist/workflow/consensus.js.map +1 -1
  81. package/dist/workflow/execution-mode.d.ts +10 -4
  82. package/dist/workflow/execution-mode.d.ts.map +1 -1
  83. package/dist/workflow/execution-mode.js +547 -58
  84. package/dist/workflow/execution-mode.js.map +1 -1
  85. package/dist/workflow/index.d.ts +14 -2
  86. package/dist/workflow/index.d.ts.map +1 -1
  87. package/dist/workflow/index.js +69 -6
  88. package/dist/workflow/index.js.map +1 -1
  89. package/dist/workflow/milestone-workflow.d.ts +34 -0
  90. package/dist/workflow/milestone-workflow.d.ts.map +1 -0
  91. package/dist/workflow/milestone-workflow.js +414 -0
  92. package/dist/workflow/milestone-workflow.js.map +1 -0
  93. package/dist/workflow/plan-mode.d.ts +14 -1
  94. package/dist/workflow/plan-mode.d.ts.map +1 -1
  95. package/dist/workflow/plan-mode.js +589 -47
  96. package/dist/workflow/plan-mode.js.map +1 -1
  97. package/dist/workflow/plan-storage.d.ts +142 -0
  98. package/dist/workflow/plan-storage.d.ts.map +1 -0
  99. package/dist/workflow/plan-storage.js +331 -0
  100. package/dist/workflow/plan-storage.js.map +1 -0
  101. package/dist/workflow/project-verification.d.ts +37 -0
  102. package/dist/workflow/project-verification.d.ts.map +1 -0
  103. package/dist/workflow/project-verification.js +381 -0
  104. package/dist/workflow/project-verification.js.map +1 -0
  105. package/dist/workflow/task-workflow.d.ts +37 -0
  106. package/dist/workflow/task-workflow.d.ts.map +1 -0
  107. package/dist/workflow/task-workflow.js +383 -0
  108. package/dist/workflow/task-workflow.js.map +1 -0
  109. package/dist/workflow/test-runner.d.ts +1 -0
  110. package/dist/workflow/test-runner.d.ts.map +1 -1
  111. package/dist/workflow/test-runner.js +9 -5
  112. package/dist/workflow/test-runner.js.map +1 -1
  113. package/dist/workflow/ui-designer.d.ts +82 -0
  114. package/dist/workflow/ui-designer.d.ts.map +1 -0
  115. package/dist/workflow/ui-designer.js +234 -0
  116. package/dist/workflow/ui-designer.js.map +1 -0
  117. package/dist/workflow/ui-setup.d.ts +58 -0
  118. package/dist/workflow/ui-setup.d.ts.map +1 -0
  119. package/dist/workflow/ui-setup.js +685 -0
  120. package/dist/workflow/ui-setup.js.map +1 -0
  121. package/dist/workflow/ui-verification.d.ts +114 -0
  122. package/dist/workflow/ui-verification.d.ts.map +1 -0
  123. package/dist/workflow/ui-verification.js +258 -0
  124. package/dist/workflow/ui-verification.js.map +1 -0
  125. package/dist/workflow/workflow-logger.d.ts +110 -0
  126. package/dist/workflow/workflow-logger.d.ts.map +1 -0
  127. package/dist/workflow/workflow-logger.js +267 -0
  128. package/dist/workflow/workflow-logger.js.map +1 -0
  129. package/package.json +2 -2
  130. package/src/adapters/claude.ts +815 -34
  131. package/src/adapters/gemini.ts +373 -0
  132. package/src/adapters/openai.ts +40 -7
  133. package/src/auth/claude.ts +120 -78
  134. package/src/auth/gemini.ts +207 -0
  135. package/src/auth/index.ts +28 -8
  136. package/src/auth/keychain.ts +95 -28
  137. package/src/auth/openai.ts +29 -36
  138. package/src/cli/interactive.ts +1357 -115
  139. package/src/config/defaults.ts +10 -2
  140. package/src/config/index.ts +21 -0
  141. package/src/config/schema.ts +7 -0
  142. package/src/generators/python.ts +1 -0
  143. package/src/generators/typescript.ts +1 -0
  144. package/src/state/index.ts +713 -4
  145. package/src/state/registry.ts +278 -0
  146. package/src/types/cli.ts +4 -0
  147. package/src/types/consensus.ts +65 -6
  148. package/src/types/workflow.ts +35 -0
  149. package/src/workflow/auto-fix.ts +340 -0
  150. package/src/workflow/consensus.ts +750 -16
  151. package/src/workflow/execution-mode.ts +673 -74
  152. package/src/workflow/index.ts +95 -6
  153. package/src/workflow/milestone-workflow.ts +576 -0
  154. package/src/workflow/plan-mode.ts +696 -50
  155. package/src/workflow/plan-storage.ts +482 -0
  156. package/src/workflow/project-verification.ts +471 -0
  157. package/src/workflow/task-workflow.ts +525 -0
  158. package/src/workflow/test-runner.ts +10 -5
  159. package/src/workflow/ui-designer.ts +337 -0
  160. package/src/workflow/ui-setup.ts +797 -0
  161. package/src/workflow/ui-verification.ts +357 -0
  162. package/src/workflow/workflow-logger.ts +353 -0
  163. package/tests/config/config.test.ts +1 -1
  164. package/tests/types/consensus.test.ts +3 -3
  165. package/tests/workflow/plan-mode.test.ts +213 -0
  166. package/tests/workflow/test-runner.test.ts +5 -3
package/README.md CHANGED
@@ -1,56 +1,155 @@
1
1
  # Popeye CLI
2
2
 
3
- A fully autonomous TypeScript CLI tool that transforms your ideas into complete, tested, deployable code projects using AI-powered code generation and review.
3
+ A fully autonomous code generation tool that transforms your ideas into complete, tested, deployable code projects using AI-powered planning, consensus, and implementation.
4
4
 
5
- ## Overview
5
+ ## What is Popeye?
6
6
 
7
- Popeye orchestrates two AI systems to ensure high-quality code generation:
7
+ Popeye is an autonomous software development agent that takes a simple project idea and builds it into a fully functional codebase. Unlike traditional code assistants that require constant guidance, Popeye operates autonomously through a structured workflow:
8
8
 
9
- - **Claude (via Claude Agent SDK)**: Primary code execution engine that generates, implements, and tests code
10
- - **OpenAI**: Review and validation partner that ensures plans meet quality standards through consensus
9
+ 1. **Understands** your idea and expands it into a detailed specification
10
+ 2. **Designs** the UI automatically based on the project context
11
+ 3. **Plans** a complete development roadmap with milestones and tasks
12
+ 4. **Validates** the plan through AI consensus (multiple AI systems must agree)
13
+ 5. **Implements** each task autonomously, writing production-quality code
14
+ 6. **Styles** the application with a professional design system and component library
15
+ 7. **Tests** the implementation and fixes issues automatically
16
+ 8. **Delivers** a complete, working project with polished UI
11
17
 
12
- The workflow ensures 95%+ consensus between both AI systems before code execution begins, resulting in well-planned, thoroughly vetted implementations.
18
+ ## How It Works
13
19
 
14
- ## Features
20
+ ```
21
+ ┌─────────────────────────────────────────────────────────────────────┐
22
+ │ POPEYE WORKFLOW │
23
+ ├─────────────────────────────────────────────────────────────────────┤
24
+ │ │
25
+ │ [Your Idea] ──► [Specification] ──► [UI Design] ──► [Dev Plan] │
26
+ │ ▲ │ │ │
27
+ │ │ │ ▼ │
28
+ │ OpenAI expands Auto-design Claude creates │
29
+ │ theme/style │
30
+ │ │ │
31
+ │ ▼ │
32
+ │ ┌─────────────────────────────────────┐ │
33
+ │ │ CONSENSUS LOOP (95%+) │ │
34
+ │ │ ┌─────────┐ ┌─────────┐ │ │
35
+ │ │ │ OpenAI │◄───►│ Claude │ │ │
36
+ │ │ │ Reviews │ │ Revises │ │ │
37
+ │ │ └─────────┘ └─────────┘ │ │
38
+ │ └─────────────────────────────────────┘ │
39
+ │ │ │
40
+ │ ▼ │
41
+ │ ┌─────────────────────────────────────┐ │
42
+ │ │ EXECUTION MODE │ │
43
+ │ │ For each task: │ │
44
+ │ │ 1. Claude implements │ │
45
+ │ │ 2. Tests run automatically │ │
46
+ │ │ 3. Fix issues (up to 3 retries) │ │
47
+ │ │ 4. Mark complete │ │
48
+ │ └─────────────────────────────────────┘ │
49
+ │ │ │
50
+ │ ▼ │
51
+ │ ┌─────────────────────────────────────┐ │
52
+ │ │ UI SETUP & STYLING │ │
53
+ │ │ - Install Tailwind CSS │ │
54
+ │ │ - Configure shadcn/ui components │ │
55
+ │ │ - Apply selected theme │ │
56
+ │ └─────────────────────────────────────┘ │
57
+ │ │ │
58
+ │ ▼ │
59
+ │ [Complete Project with Polished UI] │
60
+ │ │
61
+ └─────────────────────────────────────────────────────────────────────┘
62
+ ```
15
63
 
16
- - **Dual-AI Consensus System**: Plans are iteratively refined until both Claude and OpenAI agree on the approach
17
- - **Multi-Language Support**: Generate projects in Python or TypeScript
18
- - **Secure Authentication**: Browser-based OAuth for Claude, secure API key storage for OpenAI
19
- - **Interactive Mode**: REPL-style interface with slash commands for ongoing work
20
- - **One-Shot Creation**: `popeye create` command for quick project generation
21
- - **Progress Tracking**: Visual feedback with spinners and progress bars
22
- - **Automatic Testing**: Generated code includes tests that are run and verified
64
+ ### Multi-AI Consensus System
65
+
66
+ Popeye uses multiple AI systems that must agree before implementation begins:
67
+
68
+ - **Claude (via Claude Agent SDK)**: Primary code execution engine that generates plans, implements code, and runs tests
69
+ - **OpenAI GPT-4** (default reviewer): Evaluates plans for completeness, feasibility, and quality
70
+ - **Google Gemini** (optional): Can be configured as reviewer or arbitrator when consensus gets stuck
71
+
72
+ Plans are iteratively refined until systems reach **95%+ consensus**, ensuring well-thought-out implementations. When consensus cannot be reached, an arbitrator (Gemini by default) makes the final decision.
73
+
74
+ ## Prerequisites
75
+
76
+ Before installing Popeye, ensure you have:
77
+
78
+ ### Required
79
+
80
+ | Requirement | Version | Purpose |
81
+ |-------------|---------|---------|
82
+ | **Node.js** | 18.0+ | Runtime environment |
83
+ | **npm** | 8.0+ | Package manager |
84
+ | **Claude Code CLI** | Latest | Code generation engine |
85
+
86
+ ### Claude Code CLI Installation
87
+
88
+ Popeye requires the Claude Code CLI to be installed and authenticated:
89
+
90
+ ```bash
91
+ # Install Claude Code CLI (if not already installed)
92
+ npm install -g @anthropic-ai/claude-code
93
+
94
+ # Authenticate with Claude (opens browser for OAuth)
95
+ claude auth login
96
+ ```
97
+
98
+ Verify Claude Code is working:
99
+
100
+ ```bash
101
+ claude --version
102
+ ```
103
+
104
+ ### API Keys Required
105
+
106
+ | Service | Required | Purpose |
107
+ |---------|----------|---------|
108
+ | **OpenAI API Key** | Yes | Plan review and consensus (default reviewer) |
109
+ | **Claude Auth** | Yes | Code generation (via Claude Code CLI) |
110
+ | **Gemini API Key** | Optional | Alternative reviewer or arbitrator |
23
111
 
24
112
  ## Installation
25
113
 
114
+ ### Global Installation (Recommended)
115
+
26
116
  ```bash
27
117
  npm install -g popeye-cli
28
118
  ```
29
119
 
30
- Or use directly with npx:
120
+ ### Using npx (No Installation)
31
121
 
32
122
  ```bash
33
- npx popeye-cli create "my project idea"
123
+ npx popeye-cli create "your project idea"
124
+ ```
125
+
126
+ ### From Source
127
+
128
+ ```bash
129
+ git clone https://github.com/your-org/popeye-cli.git
130
+ cd popeye-cli
131
+ npm install
132
+ npm run build
133
+ npm link
34
134
  ```
35
135
 
36
136
  ## Quick Start
37
137
 
38
138
  ### 1. Authenticate
39
139
 
40
- First, set up authentication with both AI services:
41
-
42
140
  ```bash
43
141
  # Authenticate with Claude (browser-based OAuth)
44
142
  popeye auth claude
45
143
 
46
- # Authenticate with OpenAI (API key)
144
+ # Set up OpenAI API key (required - default reviewer)
47
145
  popeye auth openai
146
+
147
+ # Set up Gemini API key (optional - for arbitration or alternative reviewer)
148
+ popeye auth gemini
48
149
  ```
49
150
 
50
151
  ### 2. Create a Project
51
152
 
52
- Generate a complete project from an idea:
53
-
54
153
  ```bash
55
154
  # Create a Python project
56
155
  popeye create "A REST API for managing todo items with SQLite storage" --language python
@@ -59,24 +158,113 @@ popeye create "A REST API for managing todo items with SQLite storage" --languag
59
158
  popeye create "A React component library for data visualization" --language typescript
60
159
  ```
61
160
 
62
- ### 3. Interactive Mode
161
+ ### 3. Monitor Progress
63
162
 
64
- For ongoing work and experimentation:
163
+ Popeye provides real-time feedback:
65
164
 
66
- ```bash
67
- popeye
165
+ ```
166
+ [Plan] Creating development plan...
167
+ [UI Design] Analyzing project idea for UI intent...
168
+ [UI Design] UI Intent: modern style for consumer audience
169
+ [UI Design] Selected theme: Modern Blue
170
+ [UI Design] UI design complete: Modern Blue theme with 12 components
171
+ [Consensus] Review round 1: 78% agreement
172
+ [Consensus] Addressing concerns...
173
+ [Consensus] Review round 2: 92% agreement
174
+ [Consensus] Review round 3: 97% agreement - APPROVED
175
+ [Execute] Milestone 1: Project Setup
176
+ [Execute] Task 1.1: Initialize project structure... DONE
177
+ [Execute] Task 1.2: Configure dependencies... DONE
178
+ [Execute] Milestone 2: Core Implementation
179
+ ...
180
+ [UI Setup] Installing Tailwind CSS and dependencies...
181
+ [UI Setup] Installing UI component dependencies...
182
+ [UI Setup] Setting up theme and styles...
183
+ [UI Setup] UI setup complete: 5 components installed
184
+ [Complete] Project built successfully!
68
185
  ```
69
186
 
70
- In interactive mode, use slash commands:
187
+ ## Features
71
188
 
72
- ```
73
- /help Show available commands
74
- /create <idea> Start a new project
75
- /status Check current project status
76
- /auth Manage authentication
77
- /config View/edit configuration
78
- /exit Exit interactive mode
79
- ```
189
+ ### Core Features
190
+
191
+ - **Fully Autonomous**: Runs from idea to complete project without manual intervention
192
+ - **Dual-AI Consensus**: Plans validated by multiple AI systems before execution
193
+ - **Multi-Language Support**: Generate projects in Python or TypeScript
194
+ - **Automatic Testing**: Tests are generated and run for each implementation
195
+ - **Error Recovery**: Failed tests trigger automatic fix attempts (up to 3 retries)
196
+ - **Auto-Generated README**: At project completion, generates a comprehensive README with:
197
+ - Project description and features
198
+ - Prerequisites and installation instructions
199
+ - Environment setup guide
200
+ - How to run (development, tests, production)
201
+ - Project structure overview
202
+
203
+ ### Automatic UI/UX Design
204
+
205
+ Popeye automatically handles all UI/UX decisions, eliminating the need for manual design work:
206
+
207
+ - **AI-Powered UI Design**: Analyzes your project idea to determine the optimal UI style, color scheme, and component needs
208
+ - **Theme Selection**: Automatically selects from professional themes based on project context:
209
+ - **Modern Blue**: Clean, professional look for general applications
210
+ - **Elegant Dark**: Sophisticated style with purple accents
211
+ - **Minimal Clean**: Streamlined design for business tools
212
+ - **Vibrant Gradient**: Bold, colorful design for consumer apps
213
+ - **Component Library Setup**: Installs and configures shadcn/ui with Tailwind CSS
214
+ - **Project-Aware Components**: Selects appropriate UI components based on project type:
215
+ - Dashboard projects: tables, charts, cards, tabs
216
+ - Kanban boards: drag-and-drop, context menus, popovers
217
+ - E-commerce: carousels, accordions, sliders
218
+ - Blogs: navigation menus, avatars, text areas
219
+ - **Accessibility Built-in**: Targets WCAG AA compliance by default
220
+ - **Dark Mode Support**: Automatic dark mode configuration
221
+ - **Mobile-First Design**: Responsive layouts out of the box
222
+
223
+ The UI design specification is saved to `.popeye/ui-spec.json` and is used to guide all code generation, ensuring consistent styling throughout the project.
224
+
225
+ ### Reliability Features
226
+
227
+ - **Rate Limit Handling**: Automatically waits and retries when API rate limits are hit
228
+ - Improved detection using specific regex patterns to avoid false positives
229
+ - Distinguishes actual rate limit errors from plan content mentioning "rate limits"
230
+ - Parses reset times from error messages (e.g., "resets 3pm")
231
+ - Extracts clean error messages without including extraneous plan content
232
+ - Configurable wait times (default: 5 min base, 2 hour max)
233
+ - Up to 5 retry attempts before failing
234
+ - Progress updates during wait periods
235
+
236
+ - **Resume Capability**: Resume interrupted projects from where they left off
237
+ - State persisted in `.popeye/state.json`
238
+ - Tracks completed milestones and tasks
239
+ - Survives crashes, rate limits, and manual interruptions
240
+
241
+ - **Plan File Extraction**: Handles various Claude response formats
242
+ - Detects when Claude saves plans to `~/.claude/plans/`
243
+ - Automatically extracts plan content from saved files
244
+ - Validates plan structure before proceeding
245
+
246
+ - **Consensus Stuck Detection**: Prevents infinite loops in consensus phase
247
+ - Detects stagnation (scores not improving)
248
+ - Detects oscillation patterns (scores bouncing up and down)
249
+ - 15-minute timeout with automatic arbitration
250
+ - Per-iteration timing logs for debugging
251
+
252
+ ### Observability Features
253
+
254
+ - **Workflow Logging**: Detailed logs written to `docs/WORKFLOW_LOG.md`
255
+ - Tracks all phases: planning, consensus, execution
256
+ - Timestamps and log levels (info, warn, error, success)
257
+ - Useful for debugging and auditing
258
+
259
+ - **Code Quality Verification**: Validates actual code implementation
260
+ - Checks source file count and lines of code
261
+ - Verifies main entry points exist
262
+ - Detects substantive code vs. empty scaffolding
263
+
264
+ - **UI Verification**: Validates UI setup and styling
265
+ - Verifies Tailwind CSS installation
266
+ - Checks component library setup
267
+ - Validates theme configuration
80
268
 
81
269
  ## Commands
82
270
 
@@ -84,99 +272,137 @@ In interactive mode, use slash commands:
84
272
 
85
273
  Create a new project from an idea.
86
274
 
87
- **Options:**
88
- - `-n, --name <name>`: Project name (default: derived from idea)
89
- - `-l, --language <lang>`: Output language: `python` or `typescript` (default: python)
90
- - `-d, --directory <dir>`: Output directory (default: current directory)
91
- - `-m, --model <model>`: OpenAI model for consensus (default: gpt-4o)
92
-
93
- **Example:**
94
275
  ```bash
95
- popeye create "A CLI tool for converting markdown to PDF" --name md2pdf --language python
276
+ popeye create "A CLI tool for converting markdown to PDF" \
277
+ --name md2pdf \
278
+ --language python \
279
+ --directory ./projects
96
280
  ```
97
281
 
98
- ### `popeye auth <service>`
282
+ **Options:**
283
+ | Option | Description | Default |
284
+ |--------|-------------|---------|
285
+ | `-n, --name <name>` | Project name | Derived from idea |
286
+ | `-l, --language <lang>` | `python` or `typescript` | `python` |
287
+ | `-d, --directory <dir>` | Output directory | Current directory |
288
+ | `-m, --model <model>` | OpenAI model for consensus | `gpt-4o` |
99
289
 
100
- Authenticate with Claude or OpenAI.
290
+ ### `popeye resume`
291
+
292
+ Resume an interrupted project.
101
293
 
102
- **Services:**
103
- - `claude`: Opens browser for OAuth authentication
104
- - `openai`: Prompts for API key entry via local web interface
294
+ ```bash
295
+ popeye resume --project ./my-project
296
+ ```
105
297
 
106
298
  **Options:**
107
- - `--check`: Verify stored credentials without re-authenticating
108
- - `--logout`: Remove stored credentials
299
+ | Option | Description |
300
+ |--------|-------------|
301
+ | `-p, --project <dir>` | Project directory to resume |
109
302
 
110
303
  ### `popeye status`
111
304
 
112
- Check the status of the current project.
305
+ Check the status of a project.
113
306
 
114
- **Options:**
115
- - `-p, --project <dir>`: Project directory to check
307
+ ```bash
308
+ popeye status --project ./my-project
309
+ ```
116
310
 
117
- ### `popeye resume`
311
+ ### `popeye auth <service>`
118
312
 
119
- Resume an interrupted project from where it left off.
313
+ Manage authentication.
120
314
 
121
- **Options:**
122
- - `-p, --project <dir>`: Project directory to resume
315
+ ```bash
316
+ # Authenticate with Claude
317
+ popeye auth claude
123
318
 
124
- ### `popeye config`
319
+ # Authenticate with OpenAI (default reviewer)
320
+ popeye auth openai
125
321
 
126
- View or modify configuration.
322
+ # Authenticate with Gemini (optional - for arbitration)
323
+ popeye auth gemini
127
324
 
128
- **Subcommands:**
129
- - `config show`: Display current configuration
130
- - `config set <key> <value>`: Set a configuration value
131
- - `config reset`: Reset to default configuration
325
+ # Check credentials
326
+ popeye auth claude --check
132
327
 
133
- ## Workflow
328
+ # Remove credentials
329
+ popeye auth openai --logout
330
+ ```
134
331
 
135
- ### Plan Mode
332
+ ### `popeye config`
136
333
 
137
- 1. **Idea Expansion**: Your brief idea is expanded into a detailed specification by OpenAI
138
- 2. **Plan Creation**: Claude creates a structured development plan with milestones and tasks
139
- 3. **Consensus Loop**:
140
- - OpenAI reviews the plan and provides feedback
141
- - Claude revises based on concerns
142
- - Repeats until 95%+ consensus is reached
143
- 4. **Plan Documentation**: The approved plan is saved to `PLAN.md`
334
+ Manage configuration.
144
335
 
145
- ### Execution Mode
336
+ ```bash
337
+ # Show current config
338
+ popeye config show
146
339
 
147
- 1. **Task Execution**: Claude implements each task sequentially
148
- 2. **Test Creation**: Tests are generated alongside implementation
149
- 3. **Test Verification**: Tests are run after each task
150
- 4. **Error Recovery**: Failed tests trigger automatic fix attempts (up to 3 retries)
151
- 5. **Completion**: Project marked complete when all tasks pass
340
+ # Set a value
341
+ popeye config set consensus.threshold 90
152
342
 
153
- ## Configuration
343
+ # Reset to defaults
344
+ popeye config reset
345
+ ```
154
346
 
155
- Popeye looks for configuration in the following order:
347
+ ### Interactive Mode
156
348
 
157
- 1. Environment variables (highest priority)
158
- 2. Project-level `popeye.config.yaml` or `.popeyerc.yaml`
159
- 3. Global `~/.popeye/config.yaml`
160
- 4. Built-in defaults (lowest priority)
349
+ Launch an interactive REPL session:
350
+
351
+ ```bash
352
+ popeye
353
+ ```
354
+
355
+ **Available Commands:**
356
+ ```
357
+ /help Show available commands
358
+ /create <idea> Start a new project
359
+ /status Check current project status
360
+ /resume Resume interrupted project
361
+ /auth Manage authentication
362
+ /config View/edit configuration
363
+ /exit Exit interactive mode
364
+ ```
365
+
366
+ ## Configuration
161
367
 
162
368
  ### Configuration File
163
369
 
370
+ Create `popeye.config.yaml` in your project or `~/.popeye/config.yaml` globally:
371
+
164
372
  ```yaml
165
- # popeye.config.yaml
373
+ # Consensus settings
166
374
  consensus:
167
- threshold: 95
168
- max_disagreements: 5
169
- escalation_action: pause
170
-
375
+ threshold: 95 # Minimum agreement percentage
376
+ max_iterations: 10 # Max revision rounds
377
+ reviewer: openai # Primary reviewer (openai or gemini)
378
+ arbitrator: gemini # Arbitrator when stuck (openai or gemini)
379
+ enable_arbitration: true # Enable automatic arbitration
380
+ arbitration_threshold: 85 # Score threshold to trigger arbitration
381
+ stuck_iterations: 3 # Iterations without improvement before arbitration
382
+ escalation_action: pause # What to do if consensus fails
383
+
384
+ # API settings
171
385
  apis:
172
386
  openai:
173
387
  model: gpt-4o
174
388
  temperature: 0.3
175
389
  max_tokens: 4096
390
+ gemini:
391
+ model: gemini-2.0-flash
392
+ temperature: 0.3
393
+ max_tokens: 4096
394
+
395
+ # Rate limit settings (new)
396
+ rateLimit:
397
+ maxRetries: 5 # Max retry attempts
398
+ baseWaitMs: 300000 # 5 minutes base wait
399
+ maxWaitMs: 7200000 # 2 hours max wait
176
400
 
401
+ # Project defaults
177
402
  project:
178
403
  default_language: python
179
404
 
405
+ # Output settings
180
406
  output:
181
407
  verbose: false
182
408
  timestamps: true
@@ -186,14 +412,28 @@ output:
186
412
  ### Environment Variables
187
413
 
188
414
  ```bash
415
+ # Required
189
416
  POPEYE_OPENAI_KEY=sk-... # OpenAI API key
417
+
418
+ # Optional
419
+ POPEYE_GEMINI_KEY=... # Gemini API key (for arbitration)
190
420
  POPEYE_DEFAULT_LANGUAGE=python # Default output language
191
421
  POPEYE_OPENAI_MODEL=gpt-4o # OpenAI model
422
+ POPEYE_GEMINI_MODEL=gemini-2.0-flash # Gemini model
192
423
  POPEYE_CONSENSUS_THRESHOLD=95 # Consensus threshold (0-100)
193
- POPEYE_MAX_DISAGREEMENTS=5 # Max iterations before escalation
424
+ POPEYE_MAX_ITERATIONS=10 # Max iterations before escalation
425
+ POPEYE_REVIEWER=openai # Primary reviewer (openai or gemini)
426
+ POPEYE_ARBITRATOR=gemini # Arbitrator (openai or gemini)
194
427
  POPEYE_LOG_LEVEL=debug # Enable verbose logging
195
428
  ```
196
429
 
430
+ ### Configuration Priority
431
+
432
+ 1. Environment variables (highest)
433
+ 2. Project-level `popeye.config.yaml` or `.popeyerc.yaml`
434
+ 3. Global `~/.popeye/config.yaml`
435
+ 4. Built-in defaults (lowest)
436
+
197
437
  ## Generated Project Structure
198
438
 
199
439
  ### Python Projects
@@ -206,6 +446,9 @@ my-project/
206
446
  ├── tests/
207
447
  │ ├── __init__.py
208
448
  │ └── conftest.py
449
+ ├── docs/
450
+ │ ├── PLAN.md # Development plan
451
+ │ └── WORKFLOW_LOG.md # Execution log
209
452
  ├── pyproject.toml
210
453
  ├── requirements.txt
211
454
  ├── README.md
@@ -213,17 +456,37 @@ my-project/
213
456
  ├── .env.example
214
457
  ├── Dockerfile
215
458
  └── .popeye/
216
- └── state.json
459
+ └── state.json # Project state
217
460
  ```
218
461
 
219
462
  ### TypeScript Projects
220
463
 
221
464
  ```
222
465
  my-project/
466
+ ├── packages/
467
+ │ └── frontend/ # Frontend application (when applicable)
468
+ │ ├── src/
469
+ │ │ ├── components/
470
+ │ │ │ └── ui/ # shadcn/ui components
471
+ │ │ │ ├── button.tsx
472
+ │ │ │ ├── card.tsx
473
+ │ │ │ ├── input.tsx
474
+ │ │ │ ├── badge.tsx
475
+ │ │ │ └── skeleton.tsx
476
+ │ │ ├── lib/
477
+ │ │ │ └── utils.ts # Tailwind utility functions
478
+ │ │ ├── index.css # Global styles with theme
479
+ │ │ └── main.tsx
480
+ │ ├── tailwind.config.ts
481
+ │ ├── postcss.config.js
482
+ │ └── package.json
223
483
  ├── src/
224
484
  │ └── index.ts
225
485
  ├── tests/
226
486
  │ └── index.test.ts
487
+ ├── docs/
488
+ │ ├── PLAN.md
489
+ │ └── WORKFLOW_LOG.md
227
490
  ├── package.json
228
491
  ├── tsconfig.json
229
492
  ├── README.md
@@ -231,48 +494,137 @@ my-project/
231
494
  ├── .env.example
232
495
  ├── Dockerfile
233
496
  └── .popeye/
234
- └── state.json
497
+ ├── state.json # Project state
498
+ └── ui-spec.json # UI design specification
235
499
  ```
236
500
 
237
- ## State Management
501
+ ## UI Design System
502
+
503
+ Popeye automatically generates a complete UI design system for frontend projects. The design decisions are based on analyzing your project idea and are fully customizable.
504
+
505
+ ### Available Themes
506
+
507
+ | Theme | Best For | Primary Color | Border Radius | Font |
508
+ |-------|----------|---------------|---------------|------|
509
+ | **Modern Blue** | General apps, SaaS | Blue (221.2) | 0.5rem | Inter |
510
+ | **Elegant Dark** | Premium products | Purple (262.1) | 0.75rem | Plus Jakarta Sans |
511
+ | **Minimal Clean** | Business tools | Neutral gray | 0.375rem | System UI |
512
+ | **Vibrant Gradient** | Consumer apps | Pink (339) | 1rem | Poppins |
513
+
514
+ ### Project Type Detection
515
+
516
+ Popeye automatically detects your project type from keywords in your idea:
517
+
518
+ | Project Type | Keywords | Components Included |
519
+ |--------------|----------|---------------------|
520
+ | Dashboard | dashboard, analytics, admin | tables, charts, tabs, cards |
521
+ | Kanban | kanban, project manage, task | drag-drop, context menu, popover |
522
+ | E-commerce | shop, store, product | carousel, accordion, slider |
523
+ | Blog | blog, article, content | navigation menu, avatar, textarea |
524
+ | Default | other | button, card, input, dialog, badge |
525
+
526
+ ### UI Specification File
527
+
528
+ The UI specification is stored in `.popeye/ui-spec.json` and contains:
529
+
530
+ ```json
531
+ {
532
+ "intent": {
533
+ "style": "modern",
534
+ "audience": "consumer",
535
+ "colorPreference": "cool",
536
+ "features": ["cards", "forms", "navigation"],
537
+ "accessibilityLevel": "AA",
538
+ "darkMode": true,
539
+ "mobileFirst": true
540
+ },
541
+ "theme": { /* theme colors and settings */ },
542
+ "themeName": "modern",
543
+ "projectType": "dashboard",
544
+ "recommendedComponents": ["button", "card", "input", ...],
545
+ "layoutPatterns": ["flex", "grid"],
546
+ "navigationStyle": "sidebar",
547
+ "keyPages": [
548
+ { "name": "Dashboard", "route": "/", "layout": "dashboard" }
549
+ ],
550
+ "designNotes": "Use Modern Blue theme consistently..."
551
+ }
552
+ ```
238
553
 
239
- Project state is persisted in `.popeye/state.json`, allowing you to:
554
+ ### Design Context in Code Generation
240
555
 
241
- - Resume interrupted projects
242
- - Track progress across sessions
243
- - Review consensus history
244
- - Debug issues
556
+ The UI specification is automatically injected into Claude's context when generating code, ensuring consistent styling. The design system prompt includes:
245
557
 
246
- ## Requirements
558
+ - Theme colors and typography
559
+ - Recommended components to use
560
+ - Layout patterns
561
+ - Accessibility requirements
562
+ - Mobile responsiveness guidelines
563
+ - Design notes for consistency
247
564
 
248
- - Node.js 18.0 or higher
249
- - npm or yarn
250
- - Claude CLI access (for code generation)
251
- - OpenAI API key (for consensus review)
565
+ ## Troubleshooting
252
566
 
253
- ## Development
567
+ ### Rate Limit Errors
254
568
 
255
- ```bash
256
- # Clone the repository
257
- git clone https://github.com/your-org/popeye-cli.git
258
- cd popeye-cli
569
+ If you see "You've hit your limit" errors:
259
570
 
260
- # Install dependencies
261
- npm install
571
+ 1. **Automatic Handling**: Popeye automatically waits and retries (up to 5 times)
572
+ 2. **Manual Resume**: If Popeye exits, use `popeye resume` to continue
573
+ 3. **Check Limits**: Verify your API usage at:
574
+ - Claude: https://console.anthropic.com
575
+ - OpenAI: https://platform.openai.com/usage
262
576
 
263
- # Build
264
- npm run build
577
+ ### Plan Validation Failures
265
578
 
266
- # Run tests
267
- npm test
579
+ If plans fail validation:
268
580
 
269
- # Run linting
270
- npm run lint
581
+ 1. Check `~/.popeye/logs/` for detailed error logs
582
+ 2. Ensure your idea is clear and specific enough
583
+ 3. Try rephrasing your project description
271
584
 
272
- # Run in development mode
273
- npm run dev
585
+ ### Authentication Issues
586
+
587
+ ```bash
588
+ # Re-authenticate
589
+ popeye auth claude --logout
590
+ popeye auth claude
591
+
592
+ popeye auth openai --logout
593
+ popeye auth openai
594
+ ```
595
+
596
+ ### Stuck Projects
597
+
598
+ ```bash
599
+ # Check status
600
+ popeye status --project ./my-project
601
+
602
+ # Resume from last checkpoint
603
+ popeye resume --project ./my-project
274
604
  ```
275
605
 
606
+ ### UI Setup Issues
607
+
608
+ If the UI setup fails or produces unexpected results:
609
+
610
+ 1. **Frontend Directory Not Found**: UI setup requires a `packages/frontend` directory structure. Ensure your project includes a frontend component.
611
+
612
+ 2. **Missing Dependencies**: If component installation fails, try manually installing:
613
+ ```bash
614
+ cd packages/frontend
615
+ npm install tailwindcss postcss autoprefixer tailwindcss-animate
616
+ npm install class-variance-authority clsx tailwind-merge lucide-react @radix-ui/react-slot
617
+ ```
618
+
619
+ 3. **Theme Not Applied**: Check that `index.css` is imported in your main entry file (`main.tsx`).
620
+
621
+ 4. **Components Not Working**: Verify the `@/lib/utils.ts` file exists with the `cn()` utility function.
622
+
623
+ 5. **View/Edit UI Specification**: The UI design can be viewed and modified at:
624
+ ```bash
625
+ cat .popeye/ui-spec.json
626
+ ```
627
+
276
628
  ## Architecture
277
629
 
278
630
  ```
@@ -284,8 +636,9 @@ src/
284
636
  │ ├── interactive.ts # REPL mode
285
637
  │ └── commands/ # Individual commands
286
638
  ├── adapters/ # AI service adapters
287
- │ ├── claude.ts # Claude Agent SDK
288
- └── openai.ts # OpenAI API
639
+ │ ├── claude.ts # Claude Agent SDK (with rate limiting)
640
+ ├── openai.ts # OpenAI API (default reviewer)
641
+ │ └── gemini.ts # Google Gemini API (reviewer/arbitrator)
289
642
  ├── auth/ # Authentication
290
643
  │ ├── keychain.ts # Credential storage
291
644
  │ └── server.ts # OAuth callback server
@@ -299,16 +652,52 @@ src/
299
652
  │ └── templates/ # File templates
300
653
  ├── state/ # State management
301
654
  │ ├── persistence.ts # File operations
302
- │ └── index.ts # State API
655
+ │ └── index.ts # State API + verification
303
656
  ├── workflow/ # Workflow engine
304
657
  │ ├── consensus.ts # Consensus loop
305
658
  │ ├── plan-mode.ts # Planning phase
306
659
  │ ├── execution-mode.ts # Execution phase
307
- └── test-runner.ts # Test execution
660
+ ├── milestone-workflow.ts
661
+ │ ├── task-workflow.ts
662
+ │ ├── test-runner.ts # Test execution
663
+ │ ├── workflow-logger.ts # Persistent logging
664
+ │ ├── ui-designer.ts # AI-powered UI design generation
665
+ │ ├── ui-setup.ts # Tailwind/shadcn setup automation
666
+ │ ├── ui-verification.ts # UI setup verification
667
+ │ ├── project-verification.ts # Project quality checks
668
+ │ └── auto-fix.ts # Automatic error fixing
308
669
  └── types/ # TypeScript types
309
- ├── project.ts # Project types
310
- ├── workflow.ts # Workflow types
311
- └── consensus.ts # Consensus types
670
+ ├── project.ts
671
+ ├── workflow.ts
672
+ └── consensus.ts
673
+ ```
674
+
675
+ ## Development
676
+
677
+ ```bash
678
+ # Clone and install
679
+ git clone https://github.com/your-org/popeye-cli.git
680
+ cd popeye-cli
681
+ npm install
682
+
683
+ # Build
684
+ npm run build
685
+
686
+ # Run tests
687
+ npm test
688
+
689
+ # Run tests with coverage
690
+ npm run test:coverage
691
+
692
+ # Type checking
693
+ npm run typecheck
694
+
695
+ # Linting
696
+ npm run lint
697
+ npm run lint:fix
698
+
699
+ # Development mode (watch)
700
+ npm run dev
312
701
  ```
313
702
 
314
703
  ## License
@@ -317,4 +706,11 @@ MIT
317
706
 
318
707
  ## Contributing
319
708
 
320
- Contributions are welcome! Please read our contributing guidelines before submitting PRs.
709
+ Contributions are welcome! Please:
710
+
711
+ 1. Fork the repository
712
+ 2. Create a feature branch
713
+ 3. Make your changes with tests
714
+ 4. Submit a pull request
715
+
716
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.