predev-api 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Pre.dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include README.md
2
+ include LICENSE
3
+ exclude *.pyc
4
+ exclude __pycache__
5
+ exclude .pytest_cache
6
+ exclude .coverage
7
+ exclude coverage.xml
8
+ exclude .git
9
+ exclude .gitignore
10
+ exclude venv
11
+ exclude node_modules
12
+ exclude tests/*
13
+ exclude examples/*
@@ -0,0 +1,471 @@
1
+ Metadata-Version: 2.4
2
+ Name: predev-api
3
+ Version: 0.1.0
4
+ Summary: Python client for the Pre.dev Architect API - Generate comprehensive software specifications
5
+ Home-page: https://github.com/predev/predev-api-python
6
+ Author: Pre.dev
7
+ Author-email: support@pre.dev
8
+ License: MIT
9
+ Project-URL: Documentation, https://docs.pre.dev/api-reference/introduction
10
+ Project-URL: Bug Reports, https://github.com/predev/predev-api-python/issues
11
+ Project-URL: Source, https://github.com/predev/predev-api-python
12
+ Keywords: predev api specification architect ai
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.25.0
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license
35
+ Dynamic: license-file
36
+ Dynamic: project-url
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
40
+
41
+ # pre.dev Architect API - Python Client
42
+
43
+ A Python client library for the [Pre.dev Architect API](https://docs.pre.dev). Generate comprehensive software specifications using AI-powered analysis.
44
+
45
+ ## Features
46
+
47
+ - 🚀 **Fast Spec**: Generate comprehensive specifications quickly - perfect for MVPs and prototypes
48
+ - 🔍 **Deep Spec**: Generate ultra-detailed specifications for complex systems with enterprise-grade depth
49
+ - 📊 **Status Tracking**: Check the status of async specification generation requests
50
+ - 🔒 **Enterprise Support**: Both solo and enterprise authentication methods
51
+ - ✨ **Type Hints**: Full type annotations for better IDE support
52
+ - 🛡️ **Error Handling**: Custom exceptions for different error scenarios
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install predev-api
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ```python
63
+ from predev_api import PredevAPI
64
+
65
+ # Initialize the client with your API key
66
+ client = PredevAPI(api_key="your_api_key_here")
67
+
68
+ # Generate a fast specification
69
+ result = client.fast_spec(
70
+ input_text="Build a task management app with team collaboration",
71
+ output_format="url"
72
+ )
73
+
74
+ print(result)
75
+ ```
76
+
77
+ ## Authentication
78
+
79
+ The Pre.dev API uses API key authentication. Get your API key from the [pre.dev dashboard](https://pre.dev) under Settings → API Keys:
80
+
81
+ ```python
82
+ client = PredevAPI(api_key="your_api_key")
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ ### Fast Spec Generation
88
+
89
+ Generate comprehensive specifications quickly, ideal for MVPs and prototypes:
90
+
91
+ ```python
92
+ from predev_api import PredevAPI
93
+
94
+ client = PredevAPI(api_key="your_api_key")
95
+
96
+ result = client.fast_spec(
97
+ input_text="Build a task management app with team collaboration features",
98
+ output_format="url" # or "json"
99
+ )
100
+
101
+ print(result)
102
+ ```
103
+
104
+ ### Deep Spec Generation
105
+
106
+ Generate ultra-detailed specifications for complex systems with enterprise-grade depth:
107
+
108
+ ```python
109
+ from predev_api import PredevAPI
110
+
111
+ client = PredevAPI(api_key="your_api_key")
112
+
113
+ result = client.deep_spec(
114
+ input_text="Build an enterprise resource planning system with inventory, finance, and HR modules",
115
+ output_format="url" # or "json"
116
+ )
117
+
118
+ print(result)
119
+ ```
120
+
121
+ ### Check Specification Status
122
+
123
+ For async requests, check the status of your specification generation:
124
+
125
+ ```python
126
+ from predev_api import PredevAPI
127
+
128
+ client = PredevAPI(api_key="your_api_key")
129
+
130
+ status = client.get_spec_status(spec_id="your_spec_id")
131
+ print(status)
132
+ ```
133
+
134
+ ## Examples
135
+
136
+ Check out the [examples directory](./examples) for more detailed usage examples:
137
+
138
+ - `fast_spec_example.py` - Generate fast specifications
139
+ - `deep_spec_example.py` - Generate deep specifications
140
+ - `get_status_example.py` - Check specification status
141
+
142
+ To run the examples:
143
+
144
+ ```bash
145
+ # Set your API key
146
+ export PREDEV_API_KEY="your_api_key_here"
147
+
148
+ # Run an example
149
+ python examples/fast_spec_example.py
150
+ ```
151
+
152
+ ## API Reference
153
+
154
+ ### `PredevAPI`
155
+
156
+ Main client class for interacting with the Pre.dev API.
157
+
158
+ #### Constructor
159
+
160
+ ```python
161
+ PredevAPI(api_key: str, enterprise: bool = False, base_url: str = "https://api.pre.dev")
162
+ ```
163
+
164
+ **Parameters:**
165
+ - `api_key` (str): Your API key from pre.dev settings
166
+ - `enterprise` (bool): Whether to use enterprise authentication (default: False)
167
+ - `base_url` (str): Base URL for the API (default: "https://api.pre.dev")
168
+
169
+ #### Methods
170
+
171
+ ##### `fast_spec(input_text: str, output_format: Literal["url", "markdown"] = "url", current_context: Optional[str] = None, doc_urls: Optional[List[str]] = None) -> Dict[str, Any]`
172
+
173
+ Generate a fast specification (30-40 seconds, 10 credits).
174
+
175
+ **Parameters:**
176
+ - `input_text` (str, **required**): Description of what you want to build
177
+ - `output_format` (str, optional): Output format
178
+ - `"url"` (default): Returns hosted URL to view the spec
179
+ - `"markdown"`: Returns raw markdown content in response
180
+ - `current_context` (str, optional): Existing project/codebase context
181
+ - **When omitted**: Generates full new project spec with setup, deployment, docs, maintenance (`isNewBuild: true`)
182
+ - **When provided**: Generates feature addition spec for existing project (`isNewBuild: false`)
183
+ - `doc_urls` (List[str], optional): Array of documentation URLs that Architect will reference when generating specifications (e.g., API docs, design systems)
184
+
185
+ **Returns:** Dictionary containing:
186
+ ```python
187
+ {
188
+ "output": "https://pre.dev/s/abc123", # URL or markdown content
189
+ "outputFormat": "url", # Echo of format requested
190
+ "isNewBuild": True, # True for new projects, False for features
191
+ "fileUrl": "https://pre.dev/s/abc123" # Direct link to spec
192
+ }
193
+ ```
194
+
195
+ **Cost:** 10 credits per request
196
+
197
+ **Use Cases:** MVPs, prototypes, rapid iteration
198
+
199
+ **What's Generated:**
200
+ - ✅ Executive summary
201
+ - ✅ Feature breakdown by category
202
+ - ✅ Technical architecture recommendations
203
+ - ✅ Implementation milestones with effort estimates
204
+ - ✅ User stories and acceptance criteria
205
+ - ✅ Task checklist with progress tracking (`[ ]` → `[→]` → `[✓]` → `[⊘]`)
206
+ - ✅ Risk analysis and considerations
207
+
208
+ **Example - New Project:**
209
+ ```python
210
+ result = client.fast_spec(
211
+ input_text="Build a SaaS project management tool with team collaboration",
212
+ output_format="url"
213
+ )
214
+ # Returns: isNewBuild=True, includes setup and deployment
215
+ ```
216
+
217
+ **Example - Feature Addition:**
218
+ ```python
219
+ result = client.fast_spec(
220
+ input_text="Add calendar view and Gantt chart visualization",
221
+ current_context="Existing task management system with list/board views, auth, team features",
222
+ output_format="url"
223
+ )
224
+ # Returns: isNewBuild=False, focuses only on new features
225
+ ```
226
+
227
+ **Example - With Documentation URLs:**
228
+ ```python
229
+ result = client.fast_spec(
230
+ input_text="Build a customer support ticketing system",
231
+ doc_urls=["https://docs.pre.dev", "https://docs.stripe.com"],
232
+ output_format="markdown"
233
+ )
234
+ ```
235
+
236
+ **Raises:**
237
+ - `AuthenticationError`: If authentication fails
238
+ - `RateLimitError`: If rate limit is exceeded
239
+ - `PredevAPIError`: For other API errors
240
+
241
+ ##### `deep_spec(input_text: str, output_format: Literal["url", "markdown"] = "url", current_context: Optional[str] = None, doc_urls: Optional[List[str]] = None) -> Dict[str, Any]`
242
+
243
+ Generate a deep specification (2-3 minutes, 25 credits) with enterprise-grade depth.
244
+
245
+ **Parameters:**
246
+ - `input_text` (str, **required**): Description of what you want to build
247
+ - `output_format` (str, optional): Output format - `"url"` (default) or `"markdown"`
248
+ - `current_context` (str, optional): Existing project/codebase context
249
+ - **When omitted**: Full new project spec (`isNewBuild: true`)
250
+ - **When provided**: Feature addition spec (`isNewBuild: false`)
251
+ - `doc_urls` (List[str], optional): Documentation URLs for reference
252
+
253
+ **Returns:** Dictionary with same structure as `fast_spec()`
254
+
255
+ **Cost:** 50 credits per request
256
+
257
+ **Use Cases:** Complex systems, enterprise applications, comprehensive planning
258
+
259
+ **What's Generated:** Same as fast_spec but with:
260
+ - 📊 More detailed architecture diagrams and explanations
261
+ - 🔍 Deeper technical analysis
262
+ - 📈 More comprehensive risk assessment
263
+ - 🎯 More granular implementation steps
264
+ - 🏗️ Advanced infrastructure recommendations
265
+
266
+ **Example:**
267
+ ```python
268
+ result = client.deep_spec(
269
+ input_text="Build an enterprise resource planning (ERP) system",
270
+ doc_urls=["https://company-docs.com/architecture"],
271
+ output_format="url"
272
+ )
273
+ ```
274
+
275
+ **Raises:**
276
+ - `AuthenticationError`: If authentication fails
277
+ - `RateLimitError`: If rate limit is exceeded
278
+ - `PredevAPIError`: For other API errors
279
+
280
+ ##### `get_spec_status(spec_id: str) -> Dict[str, Any]`
281
+
282
+ Get the status of a specification generation request (for async requests).
283
+
284
+ **Parameters:**
285
+ - `spec_id` (str): The ID of the specification request
286
+
287
+ **Returns:** Dictionary with status information
288
+ ```python
289
+ {
290
+ "requestId": "abc123",
291
+ "status": "completed", # pending | processing | completed | failed
292
+ "progress": "Finalizing documentation...",
293
+ "output": "https://pre.dev/s/abc123",
294
+ "outputFormat": "url",
295
+ "fileUrl": "https://pre.dev/s/abc123",
296
+ "executionTimeMs": 35000
297
+ }
298
+ ```
299
+
300
+ **Raises:**
301
+ - `AuthenticationError`: If authentication fails
302
+ - `PredevAPIError`: For other API errors
303
+
304
+ ### Output Formats
305
+
306
+ #### URL Format (`output_format="url"`)
307
+ Returns a hosted URL where you can view the specification in a formatted interface:
308
+ ```python
309
+ {
310
+ "output": "https://pre.dev/s/abc123",
311
+ "outputFormat": "url",
312
+ "isNewBuild": true,
313
+ "fileUrl": "https://pre.dev/s/abc123"
314
+ }
315
+ ```
316
+
317
+ #### Markdown Format (`output_format="markdown"`)
318
+ Returns the raw markdown content directly in the response:
319
+ ```python
320
+ {
321
+ "markdown": "# Project Specification\n\n## Executive Summary...",
322
+ "outputFormat": "markdown",
323
+ "isNewBuild": true,
324
+ "fileUrl": "https://pre.dev/s/abc123"
325
+ }
326
+ ```
327
+
328
+ **Fast Spec Markdown Example:**
329
+ ```markdown
330
+ ### - [ ] **Milestone 1**: User authentication and profile management
331
+
332
+ - [ ] **User Registration** - (M): As a: new user, I want to: register an account with email and password, So that: I can access the platform
333
+ - **Acceptance Criteria:**
334
+ - [ ] User can register with valid email and password
335
+ - [ ] Email verification sent upon registration
336
+ - [ ] Duplicate emails handled gracefully
337
+ - [ ] Password strength requirements enforced
338
+
339
+ - [ ] **User Login** - (S): As a: registered user, I want to: log in securely, So that: I can access my account
340
+ - **Acceptance Criteria:**
341
+ - [ ] User can log in with correct credentials
342
+ - [ ] Invalid credentials rejected with clear message
343
+ - [ ] Session persists across browser tabs
344
+ - [ ] Password reset option available
345
+
346
+ - [ ] **User Profile** - (M): As a: registered user, I want to: manage my profile, So that: I can update my information
347
+ - **Acceptance Criteria:**
348
+ - [ ] User can view and edit profile details
349
+ - [ ] Shipping addresses can be saved
350
+ - [ ] Password can be changed with re-authentication
351
+ - [ ] Account can be deactivated
352
+ ```
353
+
354
+ **Deep Spec Markdown Example (includes subtasks):**
355
+ ```markdown
356
+ ### - [ ] **Milestone 2**: User authentication and profile management
357
+
358
+ - [ ] **User Registration** - (M): As a: new user, I want to: register an account with email and password, So that: I can access the platform
359
+ - **Acceptance Criteria:**
360
+ - [ ] User can register with valid email and password
361
+ - [ ] Email verification sent upon registration
362
+ - [ ] Duplicate emails handled gracefully
363
+ - [ ] Password strength requirements enforced
364
+ - [ ] DB: Create/verify table_users migration - (M)
365
+ - [ ] Infra: Configure Clerk (external_clerk) & auth settings - (M)
366
+ - [ ] FE: Implement /RegisterPage UI comp_registerPage_mainForm - (M)
367
+ - [ ] FE: Add client-side validation & reCAPTCHA on register form - (M)
368
+ - [ ] API: Implement registerWithEmail mutation in router_route_registerPage - (M)
369
+ - [ ] Backend: Create user record in table_users and auth_methods - (M)
370
+ - [ ] Integration: Connect API to Clerk for email confirmation/session - (M)
371
+ - [ ] QA: Write unit and integration tests for registration flow - (M)
372
+ - [ ] Docs: Document registration API and front-end behavior - (M)
373
+
374
+ - [ ] **Password Reset** - (M): As a: registered user, I want to: reset my password securely, So that: I can regain access
375
+ - **Acceptance Criteria:**
376
+ - [ ] User can request password reset link via valid email
377
+ - [ ] Reset link expires after a defined period
378
+ - [ ] New password must meet strength requirements
379
+ - [ ] System invalidates existing sessions after password change
380
+ - [ ] DB: Create password_resets table migration - (M)
381
+ - [ ] API: Implement requestPasswordReset mutation (validate, create token) - (M)
382
+ - [ ] API: Implement verifyResetToken and finalizeReset mutation - (M)
383
+ - [ ] Frontend: Add Password Reset Request page (/auth/password-reset) - (M)
384
+ - [ ] Frontend: Add Password Reset Form page (/auth/reset?token=) - (M)
385
+ - [ ] Auth Integration: Wire Clerk for account lookup and session invalidation - (M)
386
+ - [ ] Infra: Email service integration and template for reset link - (M)
387
+ - [ ] Security: Add reCAPTCHA and rate limiting to request endpoint - (M)
388
+ - [ ] Testing: End-to-end tests for reset flow - (M)
389
+ - [ ] Docs: Document API, pages, and operational runbook - (M)
390
+ ```
391
+
392
+ **Key Differences:**
393
+ - **Fast Spec**: Milestones → User Stories with Acceptance Criteria
394
+ - **Deep Spec**: Milestones → User Stories → Granular Subtasks (DB, API, FE, QA, Docs)
395
+ - Complexity estimates: (XS, S, M, L, XL)
396
+
397
+ ### Task Status Legend
398
+
399
+ Task status legend: `[ ]` → `[→]` → `[✓]` → `[⊘]`
400
+
401
+ Update as your agent completes work to keep both you and AI aligned on progress.
402
+
403
+ ## Error Handling
404
+
405
+ The library provides custom exceptions for different error scenarios:
406
+
407
+ ```python
408
+ from predev_api import PredevAPI, PredevAPIError, AuthenticationError, RateLimitError
409
+
410
+ client = PredevAPI(api_key="your_api_key")
411
+
412
+ try:
413
+ result = client.fast_spec("Build a mobile app")
414
+ except AuthenticationError as e:
415
+ print(f"Authentication failed: {e}")
416
+ except RateLimitError as e:
417
+ print(f"Rate limit exceeded: {e}")
418
+ except PredevAPIError as e:
419
+ print(f"API error: {e}")
420
+ ```
421
+
422
+ ## Requirements
423
+
424
+ - Python 3.8 or higher
425
+ - requests >= 2.25.0
426
+
427
+ ## Development & Testing
428
+
429
+ ### Running Tests
430
+
431
+ The package includes a comprehensive test suite using pytest. To run the tests:
432
+
433
+ ```bash
434
+ # Install dependencies (including test dependencies)
435
+ pip install -r requirements.txt
436
+
437
+ # Run all tests
438
+ python -m pytest
439
+
440
+ # Run tests with coverage report
441
+ python -m pytest --cov=predev_api --cov-report=term-missing
442
+
443
+ # Run tests in verbose mode
444
+ python -m pytest -v
445
+ ```
446
+
447
+ ### Test Coverage
448
+
449
+ The test suite covers:
450
+ - Client initialization with solo and enterprise authentication
451
+ - Fast spec generation
452
+ - Deep spec generation
453
+ - Spec status checking
454
+ - Error handling (authentication errors, rate limits, API errors)
455
+ - Custom exceptions
456
+
457
+ Current test coverage: **94%**
458
+
459
+ ## Documentation
460
+
461
+ For more information about the Pre.dev Architect API, visit:
462
+ - [API Documentation](https://docs.pre.dev)
463
+ - [Pre.dev Website](https://pre.dev)
464
+
465
+ ## License
466
+
467
+ MIT License - see LICENSE file for details
468
+
469
+ ## Support
470
+
471
+ For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/predev/predev-api-python).