popeye-cli 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 (209) hide show
  1. package/.env.example +25 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +320 -0
  4. package/dist/adapters/claude.d.ts +82 -0
  5. package/dist/adapters/claude.d.ts.map +1 -0
  6. package/dist/adapters/claude.js +230 -0
  7. package/dist/adapters/claude.js.map +1 -0
  8. package/dist/adapters/openai.d.ts +48 -0
  9. package/dist/adapters/openai.d.ts.map +1 -0
  10. package/dist/adapters/openai.js +257 -0
  11. package/dist/adapters/openai.js.map +1 -0
  12. package/dist/auth/claude.d.ts +44 -0
  13. package/dist/auth/claude.d.ts.map +1 -0
  14. package/dist/auth/claude.js +139 -0
  15. package/dist/auth/claude.js.map +1 -0
  16. package/dist/auth/index.d.ts +61 -0
  17. package/dist/auth/index.d.ts.map +1 -0
  18. package/dist/auth/index.js +141 -0
  19. package/dist/auth/index.js.map +1 -0
  20. package/dist/auth/keychain.d.ts +66 -0
  21. package/dist/auth/keychain.d.ts.map +1 -0
  22. package/dist/auth/keychain.js +125 -0
  23. package/dist/auth/keychain.js.map +1 -0
  24. package/dist/auth/openai-entry.d.ts +9 -0
  25. package/dist/auth/openai-entry.d.ts.map +1 -0
  26. package/dist/auth/openai-entry.js +410 -0
  27. package/dist/auth/openai-entry.js.map +1 -0
  28. package/dist/auth/openai.d.ts +71 -0
  29. package/dist/auth/openai.d.ts.map +1 -0
  30. package/dist/auth/openai.js +212 -0
  31. package/dist/auth/openai.js.map +1 -0
  32. package/dist/auth/server.d.ts +32 -0
  33. package/dist/auth/server.d.ts.map +1 -0
  34. package/dist/auth/server.js +213 -0
  35. package/dist/auth/server.js.map +1 -0
  36. package/dist/cli/commands/auth.d.ts +10 -0
  37. package/dist/cli/commands/auth.d.ts.map +1 -0
  38. package/dist/cli/commands/auth.js +162 -0
  39. package/dist/cli/commands/auth.js.map +1 -0
  40. package/dist/cli/commands/config.d.ts +10 -0
  41. package/dist/cli/commands/config.d.ts.map +1 -0
  42. package/dist/cli/commands/config.js +215 -0
  43. package/dist/cli/commands/config.js.map +1 -0
  44. package/dist/cli/commands/create.d.ts +10 -0
  45. package/dist/cli/commands/create.d.ts.map +1 -0
  46. package/dist/cli/commands/create.js +240 -0
  47. package/dist/cli/commands/create.js.map +1 -0
  48. package/dist/cli/commands/index.d.ts +10 -0
  49. package/dist/cli/commands/index.d.ts.map +1 -0
  50. package/dist/cli/commands/index.js +10 -0
  51. package/dist/cli/commands/index.js.map +1 -0
  52. package/dist/cli/commands/resume.d.ts +18 -0
  53. package/dist/cli/commands/resume.d.ts.map +1 -0
  54. package/dist/cli/commands/resume.js +241 -0
  55. package/dist/cli/commands/resume.js.map +1 -0
  56. package/dist/cli/commands/status.d.ts +18 -0
  57. package/dist/cli/commands/status.d.ts.map +1 -0
  58. package/dist/cli/commands/status.js +154 -0
  59. package/dist/cli/commands/status.js.map +1 -0
  60. package/dist/cli/index.d.ts +17 -0
  61. package/dist/cli/index.d.ts.map +1 -0
  62. package/dist/cli/index.js +71 -0
  63. package/dist/cli/index.js.map +1 -0
  64. package/dist/cli/interactive.d.ts +9 -0
  65. package/dist/cli/interactive.d.ts.map +1 -0
  66. package/dist/cli/interactive.js +330 -0
  67. package/dist/cli/interactive.js.map +1 -0
  68. package/dist/cli/output.d.ts +182 -0
  69. package/dist/cli/output.d.ts.map +1 -0
  70. package/dist/cli/output.js +355 -0
  71. package/dist/cli/output.js.map +1 -0
  72. package/dist/config/defaults.d.ts +57 -0
  73. package/dist/config/defaults.d.ts.map +1 -0
  74. package/dist/config/defaults.js +103 -0
  75. package/dist/config/defaults.js.map +1 -0
  76. package/dist/config/index.d.ts +138 -0
  77. package/dist/config/index.d.ts.map +1 -0
  78. package/dist/config/index.js +244 -0
  79. package/dist/config/index.js.map +1 -0
  80. package/dist/config/schema.d.ts +220 -0
  81. package/dist/config/schema.d.ts.map +1 -0
  82. package/dist/config/schema.js +141 -0
  83. package/dist/config/schema.js.map +1 -0
  84. package/dist/generators/index.d.ts +101 -0
  85. package/dist/generators/index.d.ts.map +1 -0
  86. package/dist/generators/index.js +200 -0
  87. package/dist/generators/index.js.map +1 -0
  88. package/dist/generators/python.d.ts +48 -0
  89. package/dist/generators/python.d.ts.map +1 -0
  90. package/dist/generators/python.js +262 -0
  91. package/dist/generators/python.js.map +1 -0
  92. package/dist/generators/templates/index.d.ts +6 -0
  93. package/dist/generators/templates/index.d.ts.map +1 -0
  94. package/dist/generators/templates/index.js +6 -0
  95. package/dist/generators/templates/index.js.map +1 -0
  96. package/dist/generators/templates/python.d.ts +53 -0
  97. package/dist/generators/templates/python.d.ts.map +1 -0
  98. package/dist/generators/templates/python.js +454 -0
  99. package/dist/generators/templates/python.js.map +1 -0
  100. package/dist/generators/templates/typescript.d.ts +53 -0
  101. package/dist/generators/templates/typescript.d.ts.map +1 -0
  102. package/dist/generators/templates/typescript.js +394 -0
  103. package/dist/generators/templates/typescript.js.map +1 -0
  104. package/dist/generators/typescript.d.ts +64 -0
  105. package/dist/generators/typescript.d.ts.map +1 -0
  106. package/dist/generators/typescript.js +271 -0
  107. package/dist/generators/typescript.js.map +1 -0
  108. package/dist/index.d.ts +7 -0
  109. package/dist/index.d.ts.map +1 -0
  110. package/dist/index.js +12 -0
  111. package/dist/index.js.map +1 -0
  112. package/dist/state/index.d.ts +168 -0
  113. package/dist/state/index.d.ts.map +1 -0
  114. package/dist/state/index.js +338 -0
  115. package/dist/state/index.js.map +1 -0
  116. package/dist/state/persistence.d.ts +91 -0
  117. package/dist/state/persistence.d.ts.map +1 -0
  118. package/dist/state/persistence.js +201 -0
  119. package/dist/state/persistence.js.map +1 -0
  120. package/dist/types/cli.d.ts +132 -0
  121. package/dist/types/cli.d.ts.map +1 -0
  122. package/dist/types/cli.js +17 -0
  123. package/dist/types/cli.js.map +1 -0
  124. package/dist/types/consensus.d.ts +111 -0
  125. package/dist/types/consensus.d.ts.map +1 -0
  126. package/dist/types/consensus.js +29 -0
  127. package/dist/types/consensus.js.map +1 -0
  128. package/dist/types/index.d.ts +9 -0
  129. package/dist/types/index.d.ts.map +1 -0
  130. package/dist/types/index.js +13 -0
  131. package/dist/types/index.js.map +1 -0
  132. package/dist/types/project.d.ts +73 -0
  133. package/dist/types/project.d.ts.map +1 -0
  134. package/dist/types/project.js +55 -0
  135. package/dist/types/project.js.map +1 -0
  136. package/dist/types/workflow.d.ts +236 -0
  137. package/dist/types/workflow.d.ts.map +1 -0
  138. package/dist/types/workflow.js +74 -0
  139. package/dist/types/workflow.js.map +1 -0
  140. package/dist/workflow/consensus.d.ts +89 -0
  141. package/dist/workflow/consensus.d.ts.map +1 -0
  142. package/dist/workflow/consensus.js +220 -0
  143. package/dist/workflow/consensus.js.map +1 -0
  144. package/dist/workflow/execution-mode.d.ts +82 -0
  145. package/dist/workflow/execution-mode.d.ts.map +1 -0
  146. package/dist/workflow/execution-mode.js +346 -0
  147. package/dist/workflow/execution-mode.js.map +1 -0
  148. package/dist/workflow/index.d.ts +110 -0
  149. package/dist/workflow/index.d.ts.map +1 -0
  150. package/dist/workflow/index.js +283 -0
  151. package/dist/workflow/index.js.map +1 -0
  152. package/dist/workflow/plan-mode.d.ts +83 -0
  153. package/dist/workflow/plan-mode.d.ts.map +1 -0
  154. package/dist/workflow/plan-mode.js +241 -0
  155. package/dist/workflow/plan-mode.js.map +1 -0
  156. package/dist/workflow/test-runner.d.ts +87 -0
  157. package/dist/workflow/test-runner.d.ts.map +1 -0
  158. package/dist/workflow/test-runner.js +273 -0
  159. package/dist/workflow/test-runner.js.map +1 -0
  160. package/eslint.config.js +25 -0
  161. package/package.json +66 -0
  162. package/src/adapters/claude.ts +298 -0
  163. package/src/adapters/openai.ts +300 -0
  164. package/src/auth/claude.ts +166 -0
  165. package/src/auth/index.ts +171 -0
  166. package/src/auth/keychain.ts +138 -0
  167. package/src/auth/openai-entry.ts +410 -0
  168. package/src/auth/openai.ts +260 -0
  169. package/src/auth/server.ts +252 -0
  170. package/src/cli/commands/auth.ts +194 -0
  171. package/src/cli/commands/config.ts +241 -0
  172. package/src/cli/commands/create.ts +308 -0
  173. package/src/cli/commands/index.ts +10 -0
  174. package/src/cli/commands/resume.ts +304 -0
  175. package/src/cli/commands/status.ts +189 -0
  176. package/src/cli/index.ts +90 -0
  177. package/src/cli/interactive.ts +418 -0
  178. package/src/cli/output.ts +410 -0
  179. package/src/config/defaults.ts +114 -0
  180. package/src/config/index.ts +315 -0
  181. package/src/config/schema.ts +164 -0
  182. package/src/generators/index.ts +251 -0
  183. package/src/generators/python.ts +318 -0
  184. package/src/generators/templates/index.ts +6 -0
  185. package/src/generators/templates/python.ts +465 -0
  186. package/src/generators/templates/typescript.ts +417 -0
  187. package/src/generators/typescript.ts +340 -0
  188. package/src/index.ts +13 -0
  189. package/src/state/index.ts +454 -0
  190. package/src/state/persistence.ts +230 -0
  191. package/src/types/cli.ts +146 -0
  192. package/src/types/consensus.ts +116 -0
  193. package/src/types/index.ts +64 -0
  194. package/src/types/project.ts +85 -0
  195. package/src/types/workflow.ts +149 -0
  196. package/src/workflow/consensus.ts +299 -0
  197. package/src/workflow/execution-mode.ts +517 -0
  198. package/src/workflow/index.ts +396 -0
  199. package/src/workflow/plan-mode.ts +356 -0
  200. package/src/workflow/test-runner.ts +345 -0
  201. package/tests/adapters/openai.test.ts +145 -0
  202. package/tests/config/config.test.ts +208 -0
  203. package/tests/generators/generators.test.ts +185 -0
  204. package/tests/types/consensus.test.ts +152 -0
  205. package/tests/types/project.test.ts +134 -0
  206. package/tests/workflow/consensus.test.ts +221 -0
  207. package/tests/workflow/test-runner.test.ts +214 -0
  208. package/tsconfig.json +25 -0
  209. package/vitest.config.ts +22 -0
@@ -0,0 +1,465 @@
1
+ /**
2
+ * Python project templates
3
+ * Provides template files for Python project generation
4
+ */
5
+
6
+ /**
7
+ * Generate pyproject.toml content
8
+ */
9
+ export function generatePyprojectToml(projectName: string): string {
10
+ return `[build-system]
11
+ requires = ["setuptools>=61.0", "wheel"]
12
+ build-backend = "setuptools.build_meta"
13
+
14
+ [project]
15
+ name = "${projectName}"
16
+ version = "0.1.0"
17
+ description = "Generated by Popeye CLI"
18
+ readme = "README.md"
19
+ requires-python = ">=3.11"
20
+ license = {text = "MIT"}
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ ]
29
+ dependencies = []
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "pytest>=7.0.0",
34
+ "pytest-cov>=4.0.0",
35
+ "pytest-asyncio>=0.21.0",
36
+ "black>=23.0.0",
37
+ "ruff>=0.1.0",
38
+ "mypy>=1.0.0",
39
+ ]
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+
44
+ [tool.pytest.ini_options]
45
+ testpaths = ["tests"]
46
+ asyncio_mode = "auto"
47
+ addopts = "-v --cov=src --cov-report=term-missing"
48
+
49
+ [tool.black]
50
+ line-length = 100
51
+ target-version = ["py311"]
52
+
53
+ [tool.ruff]
54
+ line-length = 100
55
+ select = ["E", "F", "I", "N", "W", "UP"]
56
+ ignore = ["E501"]
57
+
58
+ [tool.mypy]
59
+ python_version = "3.11"
60
+ strict = true
61
+ warn_return_any = true
62
+ warn_unused_ignores = true
63
+ `;
64
+ }
65
+
66
+ /**
67
+ * Generate requirements.txt content
68
+ */
69
+ export function generateRequirementsTxt(): string {
70
+ return `# Core dependencies
71
+ # Add your dependencies here
72
+
73
+ # Development dependencies
74
+ pytest>=7.0.0
75
+ pytest-cov>=4.0.0
76
+ pytest-asyncio>=0.21.0
77
+ black>=23.0.0
78
+ ruff>=0.1.0
79
+ mypy>=1.0.0
80
+ `;
81
+ }
82
+
83
+ /**
84
+ * Generate main __init__.py content
85
+ */
86
+ export function generateMainInit(projectName: string): string {
87
+ return `"""
88
+ ${projectName}
89
+
90
+ Generated by Popeye CLI
91
+ """
92
+
93
+ __version__ = "0.1.0"
94
+ `;
95
+ }
96
+
97
+ /**
98
+ * Generate main.py content
99
+ */
100
+ export function generateMainPy(projectName: string): string {
101
+ return `"""
102
+ Main entry point for ${projectName}.
103
+
104
+ This module serves as the primary entry point for the application.
105
+ """
106
+
107
+ import logging
108
+
109
+ # Configure logging
110
+ logging.basicConfig(
111
+ level=logging.INFO,
112
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
113
+ )
114
+ logger = logging.getLogger(__name__)
115
+
116
+
117
+ def main() -> None:
118
+ """
119
+ Main function.
120
+
121
+ Entry point for the application.
122
+ """
123
+ logger.info("Starting ${projectName}")
124
+ # TODO: Implement main functionality
125
+ print("Hello from ${projectName}!")
126
+
127
+
128
+ if __name__ == "__main__":
129
+ main()
130
+ `;
131
+ }
132
+
133
+ /**
134
+ * Generate conftest.py content
135
+ */
136
+ export function generateConftest(): string {
137
+ return `"""
138
+ Pytest configuration and fixtures.
139
+
140
+ This module contains shared fixtures used across all tests.
141
+ """
142
+
143
+ import pytest
144
+
145
+
146
+ @pytest.fixture
147
+ def sample_data() -> dict:
148
+ """
149
+ Provide sample data for tests.
150
+
151
+ Returns:
152
+ dict: Sample data dictionary.
153
+ """
154
+ return {"key": "value", "number": 42}
155
+ `;
156
+ }
157
+
158
+ /**
159
+ * Generate test_main.py content
160
+ */
161
+ export function generateTestMain(projectName: string): string {
162
+ return `"""
163
+ Tests for main module.
164
+ """
165
+
166
+ import pytest
167
+
168
+ # Import the module to test
169
+ # from src.${projectName.replace(/-/g, '_')}.main import main
170
+
171
+
172
+ class TestMain:
173
+ """Test cases for main module."""
174
+
175
+ def test_placeholder(self) -> None:
176
+ """
177
+ Placeholder test.
178
+
179
+ This test should be replaced with actual tests.
180
+ """
181
+ assert True
182
+
183
+ def test_sample_with_fixture(self, sample_data: dict) -> None:
184
+ """
185
+ Test using sample_data fixture.
186
+
187
+ Args:
188
+ sample_data: Fixture providing sample data.
189
+ """
190
+ assert sample_data["key"] == "value"
191
+ assert sample_data["number"] == 42
192
+ `;
193
+ }
194
+
195
+ /**
196
+ * Generate Dockerfile content
197
+ */
198
+ export function generateDockerfile(projectName: string): string {
199
+ return `# Python base image
200
+ FROM python:3.11-slim as base
201
+
202
+ # Set environment variables
203
+ ENV PYTHONDONTWRITEBYTECODE=1 \\
204
+ PYTHONUNBUFFERED=1 \\
205
+ PIP_NO_CACHE_DIR=1 \\
206
+ PIP_DISABLE_PIP_VERSION_CHECK=1
207
+
208
+ WORKDIR /app
209
+
210
+ # Install dependencies
211
+ COPY requirements.txt .
212
+ RUN pip install --no-cache-dir -r requirements.txt
213
+
214
+ # Copy source code
215
+ COPY src/ ./src/
216
+
217
+ # Production stage
218
+ FROM base as production
219
+
220
+ # Create non-root user
221
+ RUN adduser --disabled-password --gecos '' appuser
222
+ USER appuser
223
+
224
+ # Run the application
225
+ CMD ["python", "-m", "src.${projectName.replace(/-/g, '_')}.main"]
226
+
227
+ # Development stage
228
+ FROM base as development
229
+
230
+ # Install dev dependencies
231
+ RUN pip install --no-cache-dir pytest pytest-cov black ruff mypy
232
+
233
+ # Copy tests
234
+ COPY tests/ ./tests/
235
+
236
+ CMD ["pytest", "tests/", "-v"]
237
+ `;
238
+ }
239
+
240
+ /**
241
+ * Generate docker-compose.yml content
242
+ */
243
+ export function generateDockerCompose(projectName: string): string {
244
+ return `version: "3.8"
245
+
246
+ services:
247
+ app:
248
+ build:
249
+ context: .
250
+ target: production
251
+ container_name: ${projectName}
252
+ restart: unless-stopped
253
+ env_file:
254
+ - .env
255
+ volumes:
256
+ - ./data:/app/data
257
+
258
+ dev:
259
+ build:
260
+ context: .
261
+ target: development
262
+ container_name: ${projectName}-dev
263
+ volumes:
264
+ - ./src:/app/src
265
+ - ./tests:/app/tests
266
+ command: ["python", "-m", "src.${projectName.replace(/-/g, '_')}.main"]
267
+ `;
268
+ }
269
+
270
+ /**
271
+ * Generate .gitignore content
272
+ */
273
+ export function generateGitignore(): string {
274
+ return `# Byte-compiled / optimized / DLL files
275
+ __pycache__/
276
+ *.py[cod]
277
+ *$py.class
278
+
279
+ # C extensions
280
+ *.so
281
+
282
+ # Distribution / packaging
283
+ .Python
284
+ build/
285
+ develop-eggs/
286
+ dist/
287
+ downloads/
288
+ eggs/
289
+ .eggs/
290
+ lib/
291
+ lib64/
292
+ parts/
293
+ sdist/
294
+ var/
295
+ wheels/
296
+ *.egg-info/
297
+ .installed.cfg
298
+ *.egg
299
+
300
+ # PyInstaller
301
+ *.manifest
302
+ *.spec
303
+
304
+ # Installer logs
305
+ pip-log.txt
306
+ pip-delete-this-directory.txt
307
+
308
+ # Unit test / coverage reports
309
+ htmlcov/
310
+ .tox/
311
+ .nox/
312
+ .coverage
313
+ .coverage.*
314
+ .cache
315
+ nosetests.xml
316
+ coverage.xml
317
+ *.cover
318
+ *.py,cover
319
+ .hypothesis/
320
+ .pytest_cache/
321
+
322
+ # Translations
323
+ *.mo
324
+ *.pot
325
+
326
+ # Environments
327
+ .env
328
+ .venv
329
+ env/
330
+ venv/
331
+ ENV/
332
+
333
+ # IDE
334
+ .idea/
335
+ .vscode/
336
+ *.swp
337
+ *.swo
338
+
339
+ # mypy
340
+ .mypy_cache/
341
+
342
+ # ruff
343
+ .ruff_cache/
344
+
345
+ # Project specific
346
+ .popeye/
347
+ data/
348
+ *.log
349
+ `;
350
+ }
351
+
352
+ /**
353
+ * Generate .env.example content
354
+ */
355
+ export function generateEnvExample(): string {
356
+ return `# Environment variables
357
+ # Copy this file to .env and fill in the values
358
+
359
+ # Application settings
360
+ APP_ENV=development
361
+ DEBUG=true
362
+ LOG_LEVEL=INFO
363
+
364
+ # Add your environment variables below
365
+ `;
366
+ }
367
+
368
+ /**
369
+ * Generate README.md content
370
+ */
371
+ export function generateReadme(projectName: string, description: string): string {
372
+ return `# ${projectName}
373
+
374
+ ${description || 'Generated by Popeye CLI'}
375
+
376
+ ## Installation
377
+
378
+ \`\`\`bash
379
+ # Create virtual environment
380
+ python -m venv venv
381
+ source venv/bin/activate # On Windows: venv\\Scripts\\activate
382
+
383
+ # Install dependencies
384
+ pip install -e ".[dev]"
385
+ \`\`\`
386
+
387
+ ## Usage
388
+
389
+ \`\`\`bash
390
+ python -m src.${projectName.replace(/-/g, '_')}.main
391
+ \`\`\`
392
+
393
+ ## Development
394
+
395
+ ### Running Tests
396
+
397
+ \`\`\`bash
398
+ pytest tests/ -v
399
+ \`\`\`
400
+
401
+ ### Code Formatting
402
+
403
+ \`\`\`bash
404
+ black src/ tests/
405
+ ruff check src/ tests/ --fix
406
+ \`\`\`
407
+
408
+ ### Type Checking
409
+
410
+ \`\`\`bash
411
+ mypy src/
412
+ \`\`\`
413
+
414
+ ## Docker
415
+
416
+ \`\`\`bash
417
+ # Build and run with Docker Compose
418
+ docker-compose up --build
419
+
420
+ # Run in development mode
421
+ docker-compose run dev
422
+ \`\`\`
423
+
424
+ ## License
425
+
426
+ MIT
427
+ `;
428
+ }
429
+
430
+ /**
431
+ * Generate Makefile content
432
+ */
433
+ export function generateMakefile(_projectName: string): string {
434
+ return `.PHONY: install dev test lint format typecheck clean docker-build docker-run
435
+
436
+ install:
437
+ \tpip install -e .
438
+
439
+ dev:
440
+ \tpip install -e ".[dev]"
441
+
442
+ test:
443
+ \tpytest tests/ -v --cov=src --cov-report=term-missing
444
+
445
+ lint:
446
+ \truff check src/ tests/
447
+
448
+ format:
449
+ \tblack src/ tests/
450
+ \truff check src/ tests/ --fix
451
+
452
+ typecheck:
453
+ \tmypy src/
454
+
455
+ clean:
456
+ \trm -rf build/ dist/ *.egg-info/ .pytest_cache/ .mypy_cache/ .ruff_cache/ __pycache__/
457
+ \tfind . -type d -name "__pycache__" -exec rm -rf {} +
458
+
459
+ docker-build:
460
+ \tdocker-compose build
461
+
462
+ docker-run:
463
+ \tdocker-compose up
464
+ `;
465
+ }