ai-spector 0.1.1

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 (63) hide show
  1. package/README.md +169 -0
  2. package/_templates/basic_design/db-design-template.md +177 -0
  3. package/_templates/basic_design/detail-api-template.md +278 -0
  4. package/_templates/basic_design/detail-screen-template.md +281 -0
  5. package/_templates/basic_design/list-api-template.md +130 -0
  6. package/_templates/basic_design/list-screen-template.md +242 -0
  7. package/_templates/detail_design/common/architecture-overview-template.md +302 -0
  8. package/_templates/detail_design/common/deployment-infrastructure-template.md +461 -0
  9. package/_templates/detail_design/common/error-handling-patterns-template.md +460 -0
  10. package/_templates/detail_design/common/integration-patterns-template.md +410 -0
  11. package/_templates/detail_design/common/performance-standards-template.md +406 -0
  12. package/_templates/detail_design/common/security-patterns-template.md +395 -0
  13. package/_templates/detail_design/feature-detail-design-template.md +773 -0
  14. package/_templates/detail_design/feature-list-template.md +39 -0
  15. package/_templates/srs/1-introduction.md +58 -0
  16. package/_templates/srs/2-overall-description.md +91 -0
  17. package/_templates/srs/3-use-case-detail-template.md +142 -0
  18. package/_templates/srs/3-use-cases.md +53 -0
  19. package/_templates/srs/4-system-feature-detail-template.md +131 -0
  20. package/_templates/srs/4-system-features-list-template.md +39 -0
  21. package/_templates/srs/5-data-requirements.md +59 -0
  22. package/_templates/srs/6-external-interfaces.md +56 -0
  23. package/_templates/srs/7-quality-attributes.md +74 -0
  24. package/_templates/srs/8-internationalization.md +36 -0
  25. package/_templates/srs/9-other-requirements.md +46 -0
  26. package/assets/cursor/commands/analyze.md +39 -0
  27. package/assets/cursor/commands/generate-detail-design.md +35 -0
  28. package/assets/cursor/commands/generate-srs.md +38 -0
  29. package/assets/cursor/skills/spec-writer/SKILL.md +33 -0
  30. package/assets/workflow/config/analyze.graphify.json +36 -0
  31. package/assets/workflow/config/completeness-rules.detail-design.json +57 -0
  32. package/assets/workflow/config/completeness-rules.srs.json +72 -0
  33. package/assets/workflow/config/dag.detail-design.json +64 -0
  34. package/assets/workflow/config/dag.srs.json +87 -0
  35. package/assets/workflow/state/state.template.json +26 -0
  36. package/assets/workflow/templates/basic_design/db-design-template.md +177 -0
  37. package/assets/workflow/templates/basic_design/detail-api-template.md +278 -0
  38. package/assets/workflow/templates/basic_design/detail-screen-template.md +281 -0
  39. package/assets/workflow/templates/basic_design/list-api-template.md +130 -0
  40. package/assets/workflow/templates/basic_design/list-screen-template.md +242 -0
  41. package/assets/workflow/templates/detail_design/common/architecture-overview-template.md +302 -0
  42. package/assets/workflow/templates/detail_design/common/deployment-infrastructure-template.md +461 -0
  43. package/assets/workflow/templates/detail_design/common/error-handling-patterns-template.md +460 -0
  44. package/assets/workflow/templates/detail_design/common/integration-patterns-template.md +410 -0
  45. package/assets/workflow/templates/detail_design/common/performance-standards-template.md +406 -0
  46. package/assets/workflow/templates/detail_design/common/security-patterns-template.md +395 -0
  47. package/assets/workflow/templates/detail_design/feature-detail-design-template.md +773 -0
  48. package/assets/workflow/templates/detail_design/feature-list-template.md +39 -0
  49. package/assets/workflow/templates/srs/1-introduction.md +58 -0
  50. package/assets/workflow/templates/srs/2-overall-description.md +91 -0
  51. package/assets/workflow/templates/srs/3-use-case-detail-template.md +142 -0
  52. package/assets/workflow/templates/srs/3-use-cases.md +53 -0
  53. package/assets/workflow/templates/srs/4-system-feature-detail-template.md +131 -0
  54. package/assets/workflow/templates/srs/4-system-features-list-template.md +39 -0
  55. package/assets/workflow/templates/srs/5-data-requirements.md +59 -0
  56. package/assets/workflow/templates/srs/6-external-interfaces.md +56 -0
  57. package/assets/workflow/templates/srs/7-quality-attributes.md +74 -0
  58. package/assets/workflow/templates/srs/8-internationalization.md +36 -0
  59. package/assets/workflow/templates/srs/9-other-requirements.md +46 -0
  60. package/bin/spec-writer.js +56 -0
  61. package/package.json +25 -0
  62. package/src/cli/helpers/fs.js +50 -0
  63. package/src/cli/init.js +178 -0
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # Spec Writer
2
+
3
+ Spec Writer is an npm-installable bootstrapper for incremental documentation workflows in Cursor.
4
+
5
+ 1. Analyze project sources with Graphify MCP.
6
+ 2. Generate SRS documents in dependency order.
7
+ 3. Generate detail design documents in dependency order.
8
+
9
+ It is designed for part-by-part generation with parallel subagents and merge/review loops.
10
+
11
+ ## What You Get
12
+
13
+ After `init`, your project has:
14
+
15
+ - Cursor commands: `/analyze`, `/generate-srs`, `/generate-detail-design`
16
+ - Workflow skill + configs + state files
17
+ - SRS/detail design templates
18
+ - Output folders for generated docs
19
+ - Graphify-backed knowledge loop for incremental generation
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # in your target project
25
+ npx ai-spector init
26
+ ```
27
+
28
+ Then in Cursor chat:
29
+
30
+ 1. `/analyze` (or `/analyze src docs`)
31
+ 2. `/generate-srs`
32
+ 3. `/generate-detail-design`
33
+
34
+ ## Init Command
35
+
36
+ ```bash
37
+ ai-spector init [--force] [--no-graphify] [--skip-index] [--yes]
38
+ ```
39
+
40
+ Options:
41
+
42
+ - `--force`: overwrite existing installed assets.
43
+ - `--no-graphify`: skip Graphify bootstrap.
44
+ - `--skip-index`: do not run initial Graphify index.
45
+ - `--yes`: non-interactive mode.
46
+
47
+ ## Command Guide
48
+
49
+ ### `/analyze [paths...]`
50
+
51
+ - No args: analyze current workspace folder.
52
+ - With args: analyze only provided files/folders.
53
+ - Produces:
54
+ - `docs/.docflow/analysis/knowledge.json`
55
+ - `docs/.docflow/analysis/gaps.json`
56
+ - `docs/.docflow/analysis/scope.json`
57
+
58
+ Examples:
59
+
60
+ ```text
61
+ /analyze
62
+ /analyze src
63
+ /analyze src services docs/requirements
64
+ ```
65
+
66
+ ### `/generate-srs [file]`
67
+
68
+ - No file: generate all pending SRS nodes by DAG wave.
69
+ - With file: generate/repair one target file.
70
+ - Uses existing outputs + completeness checks before writing.
71
+
72
+ Examples:
73
+
74
+ ```text
75
+ /generate-srs
76
+ /generate-srs 3-use-cases.md
77
+ ```
78
+
79
+ ### `/generate-detail-design [file]`
80
+
81
+ - No file: generate all pending detail design nodes by DAG wave.
82
+ - With file: generate/repair one target file.
83
+ - Uses SRS outputs + Graphify context.
84
+
85
+ Examples:
86
+
87
+ ```text
88
+ /generate-detail-design
89
+ /generate-detail-design feature-list.md
90
+ ```
91
+
92
+ ## Continue From Existing Files (Default Behavior)
93
+
94
+ Generation commands always scan existing outputs first and classify files as:
95
+
96
+ - `good`
97
+ - `missing_content`
98
+ - `missing_file`
99
+
100
+ Default behavior:
101
+
102
+ - keep `good` files unchanged
103
+ - patch `missing_content`
104
+ - create `missing_file`
105
+
106
+ After each generated or patched file, content is synced back to Graphify so later files can use updated context.
107
+
108
+ ## Dependency Waves
109
+
110
+ SRS and detail design are generated in dependency order. Independent nodes in the same wave can run in parallel, then main agent merges/reviews before moving to the next wave.
111
+
112
+ ## Publish to npm
113
+
114
+ From this package repo:
115
+
116
+ ```bash
117
+ npm login
118
+ npm whoami
119
+ chmod +x bin/spec-writer.js
120
+ npm pack --dry-run
121
+ npm publish --access public
122
+ ```
123
+
124
+ For next releases:
125
+
126
+ ```bash
127
+ npm version patch
128
+ npm publish
129
+ ```
130
+
131
+ ## Installed Project Structure
132
+
133
+ ```text
134
+ .cursor/
135
+ commands/
136
+ analyze.md
137
+ generate-srs.md
138
+ generate-detail-design.md
139
+ skills/
140
+ spec-writer/
141
+ SKILL.md
142
+
143
+ docs/
144
+ _templates/
145
+ srs/
146
+ detail_design/
147
+ basic_design/
148
+ .docflow/
149
+ graph/
150
+ graphify-index/
151
+ analysis/
152
+ knowledge.json
153
+ gaps.json
154
+ scope.json
155
+ partials/
156
+ srs/
157
+ detail-design/
158
+ logs/
159
+ config/
160
+ dag.srs.json
161
+ dag.detail-design.json
162
+ analyze.graphify.json
163
+ completeness-rules.srs.json
164
+ completeness-rules.detail-design.json
165
+ state.json
166
+ output/
167
+ srs/
168
+ detail-design/
169
+ ```
@@ -0,0 +1,177 @@
1
+ # Database Design: <Project Name>
2
+
3
+ > This document explains the database structure and purpose of each table, helping developers, QA, and DBAs understand data relationships and design rationale.
4
+
5
+ **Source Requirements:** SRS Section 5 (Data Requirements)
6
+
7
+ ---
8
+
9
+ ## 1. Overview
10
+
11
+ **Database Management System:** <PostgreSQL/MySQL/Other>
12
+
13
+ **Purpose:**
14
+ > Describe the main purpose of the database and what business flows it supports.
15
+
16
+ **Source Requirements:**
17
+ > Reference SRS sections that informed this design.
18
+ - SRS Section 4: <Functional Requirements>
19
+ - SRS Section 5: <Data Requirements>
20
+ - SRS Section 7: <Quality Attributes>
21
+
22
+ ---
23
+
24
+ ## 2. Entity-Relationship Diagram
25
+
26
+ > Provide a visual representation of tables and their relationships.
27
+
28
+ ```mermaid
29
+ erDiagram
30
+ ENTITY1 ||--o{ ENTITY2 : "relationship"
31
+ ENTITY1 {
32
+ int id PK
33
+ string name
34
+ datetime created_at
35
+ }
36
+ ENTITY2 {
37
+ int id PK
38
+ int entity1_id FK
39
+ string description
40
+ }
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 3. Table List and Roles
46
+
47
+ | Table Name | Purpose | Main Relationships |
48
+ |------------|---------|-------------------|
49
+ | `<table_name>` | <Purpose description> | <Relationship description> |
50
+ | `<table_name>` | <Purpose description> | <Relationship description> |
51
+
52
+ ---
53
+
54
+ ## 4. Detailed Table Descriptions
55
+
56
+ ### 4.1 `<table_name>`
57
+
58
+ **Purpose:**
59
+ > Describe what this table stores and its role in the system.
60
+
61
+ **Primary Key:** `<field_name>` (<data_type>)
62
+
63
+ **Key Fields:**
64
+
65
+ | Field Name | Data Type | Constraints | Description |
66
+ |------------|-----------|-------------|-------------|
67
+ | `<field_name>` | `<type>` | `<UNIQUE/NOT NULL/CHECK>` | <Description> |
68
+ | `<field_name>` | `<type>` | `<constraints>` | <Description> |
69
+
70
+ **Important Design Decisions:**
71
+ - <Decision 1 and rationale>
72
+ - <Decision 2 and rationale>
73
+
74
+ **Foreign Keys:**
75
+ - `<field_name>` → `<referenced_table>.<referenced_field>` (<relationship description>)
76
+
77
+ **Indexes:**
78
+ - `<index_name>` on `<field_name>` (<purpose>)
79
+
80
+ **Business Rules:**
81
+ - <Business rule 1>
82
+ - <Business rule 2>
83
+
84
+ ---
85
+
86
+ ### 4.2 `<table_name>`
87
+
88
+ **Purpose:**
89
+ > Describe what this table stores.
90
+
91
+ **Primary Key:** `<field_name>` (<data_type>)
92
+
93
+ **Key Fields:**
94
+
95
+ | Field Name | Data Type | Constraints | Description |
96
+ |------------|-----------|-------------|-------------|
97
+ | `<field_name>` | `<type>` | `<constraints>` | <Description> |
98
+
99
+ **Foreign Keys:**
100
+ - `<field_name>` → `<referenced_table>.<referenced_field>`
101
+
102
+ **Indexes:**
103
+ - `<index_name>` on `<field_name>`
104
+
105
+ ---
106
+
107
+ ## 5. Relationships Summary
108
+
109
+ > Document all relationships between tables.
110
+
111
+ | From Table | Relationship Type | To Table | Description |
112
+ |------------|-------------------|----------|-------------|
113
+ | `<table1>` | One-to-Many | `<table2>` | <Description> |
114
+ | `<table1>` | Many-to-Many | `<table2>` | <Description> |
115
+
116
+ ---
117
+
118
+ ## 6. Data Integrity Rules
119
+
120
+ **Constraints:**
121
+ - <Constraint 1>
122
+ - <Constraint 2>
123
+
124
+ **Validation Rules:**
125
+ - <Validation rule 1>
126
+ - <Validation rule 2>
127
+
128
+ **Referential Integrity:**
129
+ - <Cascade/restrict/set null behavior>
130
+
131
+ ---
132
+
133
+ ## 7. Performance Considerations
134
+
135
+ **Indexes:**
136
+ > List indexes for query optimization.
137
+
138
+ | Index Name | Table | Fields | Purpose |
139
+ |------------|-------|--------|---------|
140
+ | `<index_name>` | `<table>` | `<fields>` | <Purpose> |
141
+
142
+ **Query Optimization Notes:**
143
+ - <Note 1>
144
+ - <Note 2>
145
+
146
+ ---
147
+
148
+ ## 8. Security Considerations
149
+
150
+ **Access Control:**
151
+ - <Access control requirement 1>
152
+ - <Access control requirement 2>
153
+
154
+ **Data Protection:**
155
+ - <Protection measure 1>
156
+ - <Protection measure 2>
157
+
158
+ ---
159
+
160
+ ## 9. Future Extensions
161
+
162
+ > Document potential future enhancements or changes.
163
+
164
+ - <Extension 1>
165
+ - <Extension 2>
166
+
167
+ ---
168
+
169
+ ## 10. Notes
170
+
171
+ **Migration Strategy:**
172
+ > Reference migration tool or approach (e.g., Flyway, Liquibase).
173
+
174
+ **Testing Considerations:**
175
+ - <Testing note 1>
176
+ - <Testing note 2>
177
+
@@ -0,0 +1,278 @@
1
+ # API Detail: <Project Name>
2
+
3
+ > This document specifies detailed request/response schemas, path/query parameters, and error handling for each API endpoint. For the endpoint list and overview, see the API List document.
4
+
5
+ **Source Requirements:** SRS Section 4 (System Features), Section 6.2 (Software Interfaces)
6
+
7
+ ---
8
+
9
+ ## 1. Detailed Endpoint Specifications
10
+
11
+ ### 1.1 `POST /resource`
12
+
13
+ **Summary:** <Brief description>
14
+
15
+ **Operation ID:** `createResource`
16
+
17
+ **Source Requirement:** SRS Section <X.X> - <Feature Name>
18
+
19
+ **Authentication:** Required
20
+
21
+ **Request:**
22
+
23
+ **Headers:**
24
+ ```
25
+ Authorization: Bearer <token>
26
+ Content-Type: application/json
27
+ ```
28
+
29
+ **Body Schema:**
30
+ ```json
31
+ {
32
+ "field1": "<type>",
33
+ "field2": "<type>",
34
+ "field3": "<type>"
35
+ }
36
+ ```
37
+
38
+ **Field Descriptions:**
39
+
40
+ | Field | Type | Required | Validation | Description |
41
+ |-------|------|----------|------------|-------------|
42
+ | `field1` | `<type>` | Yes | <Validation rules> | <Description> |
43
+ | `field2` | `<type>` | No | <Validation rules> | <Description> |
44
+
45
+ **Example Request:**
46
+ ```json
47
+ {
48
+ "field1": "value1",
49
+ "field2": "value2"
50
+ }
51
+ ```
52
+
53
+ **Responses:**
54
+
55
+ **201 Created:**
56
+ ```json
57
+ {
58
+ "id": 123,
59
+ "status": "success",
60
+ "message": "<Message>"
61
+ }
62
+ ```
63
+
64
+ **400 Bad Request:**
65
+ ```json
66
+ {
67
+ "error": "validation_error",
68
+ "message": "<Error message>",
69
+ "details": [
70
+ {
71
+ "field": "field1",
72
+ "message": "<Field-specific error>"
73
+ }
74
+ ]
75
+ }
76
+ ```
77
+
78
+ **401 Unauthorized:**
79
+ ```json
80
+ {
81
+ "error": "unauthorized",
82
+ "message": "Authentication required"
83
+ }
84
+ ```
85
+
86
+ **500 Internal Server Error:**
87
+ ```json
88
+ {
89
+ "error": "internal_error",
90
+ "message": "<Error message>"
91
+ }
92
+ ```
93
+
94
+ ---
95
+
96
+ ### 1.2 `GET /resource/{id}`
97
+
98
+ **Summary:** <Brief description>
99
+
100
+ **Operation ID:** `getResource`
101
+
102
+ **Source Requirement:** SRS Section <X.X>
103
+
104
+ **Authentication:** Required
105
+
106
+ **Path Parameters:**
107
+
108
+ | Parameter | Type | Required | Description |
109
+ |-----------|------|----------|-------------|
110
+ | `id` | integer | Yes | Resource identifier |
111
+
112
+ **Query Parameters:**
113
+
114
+ | Parameter | Type | Required | Description |
115
+ |-----------|------|----------|-------------|
116
+ | `include` | string | No | Related resources to include |
117
+ | `fields` | string | No | Fields to return |
118
+
119
+ **Responses:**
120
+
121
+ **200 OK:**
122
+ ```json
123
+ {
124
+ "id": 123,
125
+ "field1": "value1",
126
+ "field2": "value2",
127
+ "created_at": "2025-01-01T00:00:00Z"
128
+ }
129
+ ```
130
+
131
+ **404 Not Found:**
132
+ ```json
133
+ {
134
+ "error": "not_found",
135
+ "message": "Resource not found"
136
+ }
137
+ ```
138
+
139
+ ---
140
+
141
+ ### 1.3 `PUT /resource/{id}`
142
+
143
+ **Summary:** <Brief description>
144
+
145
+ **Operation ID:** `updateResource`
146
+
147
+ **Authentication:** Required
148
+
149
+ **Path Parameters:**
150
+ - `id`: Resource identifier
151
+
152
+ **Request Body:**
153
+ > Similar structure to POST
154
+
155
+ **Responses:**
156
+ > Similar structure to GET/POST
157
+
158
+ ---
159
+
160
+ ### 1.4 `DELETE /resource/{id}`
161
+
162
+ **Summary:** <Brief description>
163
+
164
+ **Operation ID:** `deleteResource`
165
+
166
+ **Authentication:** Required
167
+
168
+ **Path Parameters:**
169
+ - `id`: Resource identifier
170
+
171
+ **Responses:**
172
+
173
+ **204 No Content:**
174
+ > Success response with no body
175
+
176
+ **404 Not Found:**
177
+ > Error response
178
+
179
+ ---
180
+
181
+ ## 2. Data Models
182
+
183
+ ### 2.1 Resource Model
184
+
185
+ **Description:** <Description of the data model>
186
+
187
+ **Schema:**
188
+ ```json
189
+ {
190
+ "id": "integer",
191
+ "field1": "string",
192
+ "field2": "integer",
193
+ "created_at": "datetime",
194
+ "updated_at": "datetime"
195
+ }
196
+ ```
197
+
198
+ **Field Details:**
199
+
200
+ | Field | Type | Description | Constraints |
201
+ |-------|------|-------------|-------------|
202
+ | `id` | integer | Unique identifier | Auto-generated |
203
+ | `field1` | string | <Description> | Max 255 chars |
204
+ | `field2` | integer | <Description> | Min 0, Max 100 |
205
+
206
+ ---
207
+
208
+ ## 3. Error Handling
209
+
210
+ **Standard Error Response Format:**
211
+ ```json
212
+ {
213
+ "error": "<error_code>",
214
+ "message": "<Human-readable message>",
215
+ "details": {
216
+ "<additional_info>": "<value>"
217
+ }
218
+ }
219
+ ```
220
+
221
+ **Error Codes:**
222
+
223
+ | Code | HTTP Status | Description |
224
+ |------|-------------|-------------|
225
+ | `validation_error` | 400 | Request validation failed |
226
+ | `unauthorized` | 401 | Authentication required |
227
+ | `forbidden` | 403 | Insufficient permissions |
228
+ | `not_found` | 404 | Resource not found |
229
+ | `conflict` | 409 | Resource conflict |
230
+ | `internal_error` | 500 | Server error |
231
+
232
+ ---
233
+
234
+ ## 4. Rate Limiting
235
+
236
+ **Limits:**
237
+ - <Limit description>
238
+
239
+ **Headers:**
240
+ ```
241
+ X-RateLimit-Limit: <number>
242
+ X-RateLimit-Remaining: <number>
243
+ X-RateLimit-Reset: <timestamp>
244
+ ```
245
+
246
+ **Response when limit exceeded:**
247
+ ```json
248
+ {
249
+ "error": "rate_limit_exceeded",
250
+ "message": "Too many requests",
251
+ "retry_after": 60
252
+ }
253
+ ```
254
+
255
+ ---
256
+
257
+ ## 5. Webhooks (if applicable)
258
+
259
+ **Events:**
260
+ - `<event_name>`: <Description>
261
+
262
+ **Payload Format:**
263
+ ```json
264
+ {
265
+ "event": "<event_name>",
266
+ "timestamp": "<ISO 8601>",
267
+ "data": {
268
+ "<resource_data>": "..."
269
+ }
270
+ }
271
+ ```
272
+
273
+ ---
274
+
275
+ ## 6. Future Enhancements
276
+
277
+ - <Enhancement 1>
278
+ - <Enhancement 2>