ai-spec-dev 0.33.0 → 0.36.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 (64) hide show
  1. package/.claude/commands/add-lesson.md +34 -0
  2. package/.claude/commands/check-layers.md +65 -0
  3. package/.claude/commands/installed-deps.md +35 -0
  4. package/.claude/commands/recall-lessons.md +40 -0
  5. package/.claude/commands/scan-singletons.md +45 -0
  6. package/.claude/commands/verify-imports.md +48 -0
  7. package/.claude/settings.local.json +11 -1
  8. package/README.md +531 -213
  9. package/RELEASE_LOG.md +424 -0
  10. package/cli/commands/config.ts +18 -0
  11. package/cli/commands/create.ts +1248 -0
  12. package/cli/commands/dashboard.ts +62 -0
  13. package/cli/commands/init.ts +45 -8
  14. package/cli/commands/mock.ts +175 -0
  15. package/cli/commands/scan.ts +99 -0
  16. package/cli/commands/types.ts +69 -0
  17. package/cli/commands/vcr.ts +70 -0
  18. package/cli/index.ts +34 -2517
  19. package/cli/utils.ts +4 -0
  20. package/core/code-generator.ts +6 -4
  21. package/core/combined-generator.ts +13 -3
  22. package/core/dashboard-generator.ts +340 -0
  23. package/core/design-dialogue.ts +124 -0
  24. package/core/dsl-extractor.ts +9 -1
  25. package/core/dsl-feedback.ts +41 -5
  26. package/core/dsl-validator.ts +32 -0
  27. package/core/error-feedback.ts +46 -2
  28. package/core/key-store.ts +5 -4
  29. package/core/project-index.ts +301 -0
  30. package/core/provider-utils.ts +39 -4
  31. package/core/reviewer.ts +84 -6
  32. package/core/run-logger.ts +109 -3
  33. package/core/run-trend.ts +24 -4
  34. package/core/self-evaluator.ts +39 -11
  35. package/core/spec-generator.ts +14 -8
  36. package/core/task-generator.ts +17 -0
  37. package/core/types-generator.ts +219 -0
  38. package/core/vcr.ts +210 -0
  39. package/dist/cli/index.js +7407 -5643
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/cli/index.mjs +7401 -5637
  42. package/dist/cli/index.mjs.map +1 -1
  43. package/dist/index.d.mts +34 -5
  44. package/dist/index.d.ts +34 -5
  45. package/dist/index.js +497 -232
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +495 -233
  48. package/dist/index.mjs.map +1 -1
  49. package/docs-assets/purpose/architecture-overview.svg +64 -0
  50. package/docs-assets/purpose/create-pipeline.svg +113 -0
  51. package/docs-assets/purpose/task-layering.svg +74 -0
  52. package/package.json +1 -1
  53. package/prompts/codegen.prompt.ts +97 -9
  54. package/prompts/design.prompt.ts +59 -0
  55. package/prompts/spec.prompt.ts +8 -1
  56. package/prompts/tasks.prompt.ts +27 -2
  57. package/purpose.md +600 -174
  58. package/tests/code-generator.test.ts +253 -0
  59. package/tests/context-loader.test.ts +207 -0
  60. package/tests/dsl-validator.test.ts +105 -0
  61. package/tests/openapi-exporter.test.ts +310 -0
  62. package/tests/reviewer.test.ts +214 -0
  63. package/tests/spec-generator.test.ts +228 -0
  64. package/tests/spec-versioning.test.ts +205 -0
package/dist/index.d.mts CHANGED
@@ -137,7 +137,7 @@ declare function createProvider(providerName: string, apiKey: string, modelName?
137
137
  declare class SpecGenerator {
138
138
  private provider;
139
139
  constructor(provider: AIProvider);
140
- generateSpec(idea: string, context?: ProjectContext): Promise<string>;
140
+ generateSpec(idea: string, context?: ProjectContext, architectureDecision?: string): Promise<string>;
141
141
  }
142
142
 
143
143
  declare class SpecRefiner {
@@ -157,6 +157,15 @@ interface SpecTask {
157
157
  layer: TaskLayer;
158
158
  filesToTouch: string[];
159
159
  acceptanceCriteria: string[];
160
+ /**
161
+ * Concrete, runnable verification steps — each entry is a specific command
162
+ * or action with an expected observable outcome.
163
+ * Examples:
164
+ * "POST /api/orders with body {...} → HTTP 201, body contains {id, status:'pending'}"
165
+ * "npm run build exits 0 with no TypeScript errors"
166
+ * "GET /api/orders/:id returns 404 when id does not exist"
167
+ */
168
+ verificationSteps: string[];
160
169
  dependencies: string[];
161
170
  priority: TaskPriority;
162
171
  /** Runtime checkpoint — set by code generator, persisted to tasks file */
@@ -174,6 +183,21 @@ declare function loadTasksForSpec(specFilePath: string): Promise<SpecTask[] | nu
174
183
  /** Persist a single task's status to the tasks JSON file (checkpoint). */
175
184
  declare function updateTaskStatus(specFilePath: string, taskId: string, status: TaskStatus): Promise<void>;
176
185
 
186
+ /**
187
+ * Extract a behavioral contract summary from a generated file.
188
+ *
189
+ * Captures:
190
+ * - export interface / type / enum — full multi-line blocks (the actual TS contracts)
191
+ * - export function / const / class — opening signature line
192
+ * - Throw statements — error codes & validation constraints
193
+ *
194
+ * Multi-line blocks (interface, type alias with {}) are captured in full so
195
+ * downstream tasks see complete method signatures and field shapes, not just
196
+ * a single-line "export interface Foo {" that conveys nothing.
197
+ *
198
+ * Falls back to first 3000 chars for CommonJS files with no explicit exports.
199
+ */
200
+ declare function extractBehavioralContract(content: string): string;
177
201
  type CodeGenMode = "claude-code" | "api" | "plan";
178
202
  interface CodeGenOptions {
179
203
  /** Run claude non-interactively via -p flag (saves tokens, good for automation) */
@@ -206,6 +230,10 @@ declare class CodeGenerator {
206
230
  }
207
231
  declare function printTaskProgress(completed: number, total: number, task: SpecTask, mode: "run" | "skip"): void;
208
232
 
233
+ /** Extract compliance score from Pass 0 output (looks for "ComplianceScore: X/10") */
234
+ declare function extractComplianceScore(complianceText: string): number;
235
+ /** Count missing requirements from Pass 0 output */
236
+ declare function extractMissingCount(complianceText: string): number;
209
237
  declare class CodeReviewer {
210
238
  private provider;
211
239
  private projectRoot;
@@ -213,8 +241,9 @@ declare class CodeReviewer {
213
241
  private getGitDiff;
214
242
  private getDiffStats;
215
243
  /**
216
- * Three-pass review:
217
- * Pass 1architecture (spec compliance, layer separation, auth)
244
+ * Four-pass review:
245
+ * Pass 0 — spec compliance (exhaustive requirement coverage audit)
246
+ * Pass 1 — architecture (layer separation, contract design, auth posture)
218
247
  * Pass 2 — implementation details (validation, error handling, edge cases)
219
248
  * + historical issue recurrence check
220
249
  * Pass 3 — impact assessment + code complexity
@@ -247,7 +276,7 @@ declare function printConstitutionHint(exists: boolean): void;
247
276
  * from task-generator.ts (which already imports AIProvider from spec-generator).
248
277
  */
249
278
 
250
- declare function generateSpecWithTasks(provider: AIProvider, idea: string, context?: ProjectContext): Promise<{
279
+ declare function generateSpecWithTasks(provider: AIProvider, idea: string, context?: ProjectContext, architectureDecision?: string): Promise<{
251
280
  spec: string;
252
281
  tasks: SpecTask[];
253
282
  }>;
@@ -267,4 +296,4 @@ declare class GitWorktreeManager {
267
296
  createWorktree(idea: string): Promise<string | null>;
268
297
  }
269
298
 
270
- export { type AIProvider, CONSTITUTION_FILE, ClaudeProvider, type CodeGenMode, type CodeGenOptions, CodeGenerator, CodeReviewer, ConstitutionGenerator, ContextLoader, DEFAULT_MODELS, ENV_KEY_MAP, FRONTEND_FRAMEWORKS, GeminiProvider, GitWorktreeManager, MiMoProvider, OpenAICompatibleProvider, PROVIDER_CATALOG, type ProjectContext, type ProviderMeta, SUPPORTED_PROVIDERS, type SharedConfigFile, SpecGenerator, SpecRefiner, type SpecTask, TaskGenerator, type TaskLayer, type TaskPriority, type TaskStatus, buildTaskPrompt, createProvider, generateSpecWithTasks, isFrontendDeps, loadConstitution, loadTasksForSpec, printConstitutionHint, printTaskProgress, printTasks, updateTaskStatus };
299
+ export { type AIProvider, CONSTITUTION_FILE, ClaudeProvider, type CodeGenMode, type CodeGenOptions, CodeGenerator, CodeReviewer, ConstitutionGenerator, ContextLoader, DEFAULT_MODELS, ENV_KEY_MAP, FRONTEND_FRAMEWORKS, GeminiProvider, GitWorktreeManager, MiMoProvider, OpenAICompatibleProvider, PROVIDER_CATALOG, type ProjectContext, type ProviderMeta, SUPPORTED_PROVIDERS, type SharedConfigFile, SpecGenerator, SpecRefiner, type SpecTask, TaskGenerator, type TaskLayer, type TaskPriority, type TaskStatus, buildTaskPrompt, createProvider, extractBehavioralContract, extractComplianceScore, extractMissingCount, generateSpecWithTasks, isFrontendDeps, loadConstitution, loadTasksForSpec, printConstitutionHint, printTaskProgress, printTasks, updateTaskStatus };
package/dist/index.d.ts CHANGED
@@ -137,7 +137,7 @@ declare function createProvider(providerName: string, apiKey: string, modelName?
137
137
  declare class SpecGenerator {
138
138
  private provider;
139
139
  constructor(provider: AIProvider);
140
- generateSpec(idea: string, context?: ProjectContext): Promise<string>;
140
+ generateSpec(idea: string, context?: ProjectContext, architectureDecision?: string): Promise<string>;
141
141
  }
142
142
 
143
143
  declare class SpecRefiner {
@@ -157,6 +157,15 @@ interface SpecTask {
157
157
  layer: TaskLayer;
158
158
  filesToTouch: string[];
159
159
  acceptanceCriteria: string[];
160
+ /**
161
+ * Concrete, runnable verification steps — each entry is a specific command
162
+ * or action with an expected observable outcome.
163
+ * Examples:
164
+ * "POST /api/orders with body {...} → HTTP 201, body contains {id, status:'pending'}"
165
+ * "npm run build exits 0 with no TypeScript errors"
166
+ * "GET /api/orders/:id returns 404 when id does not exist"
167
+ */
168
+ verificationSteps: string[];
160
169
  dependencies: string[];
161
170
  priority: TaskPriority;
162
171
  /** Runtime checkpoint — set by code generator, persisted to tasks file */
@@ -174,6 +183,21 @@ declare function loadTasksForSpec(specFilePath: string): Promise<SpecTask[] | nu
174
183
  /** Persist a single task's status to the tasks JSON file (checkpoint). */
175
184
  declare function updateTaskStatus(specFilePath: string, taskId: string, status: TaskStatus): Promise<void>;
176
185
 
186
+ /**
187
+ * Extract a behavioral contract summary from a generated file.
188
+ *
189
+ * Captures:
190
+ * - export interface / type / enum — full multi-line blocks (the actual TS contracts)
191
+ * - export function / const / class — opening signature line
192
+ * - Throw statements — error codes & validation constraints
193
+ *
194
+ * Multi-line blocks (interface, type alias with {}) are captured in full so
195
+ * downstream tasks see complete method signatures and field shapes, not just
196
+ * a single-line "export interface Foo {" that conveys nothing.
197
+ *
198
+ * Falls back to first 3000 chars for CommonJS files with no explicit exports.
199
+ */
200
+ declare function extractBehavioralContract(content: string): string;
177
201
  type CodeGenMode = "claude-code" | "api" | "plan";
178
202
  interface CodeGenOptions {
179
203
  /** Run claude non-interactively via -p flag (saves tokens, good for automation) */
@@ -206,6 +230,10 @@ declare class CodeGenerator {
206
230
  }
207
231
  declare function printTaskProgress(completed: number, total: number, task: SpecTask, mode: "run" | "skip"): void;
208
232
 
233
+ /** Extract compliance score from Pass 0 output (looks for "ComplianceScore: X/10") */
234
+ declare function extractComplianceScore(complianceText: string): number;
235
+ /** Count missing requirements from Pass 0 output */
236
+ declare function extractMissingCount(complianceText: string): number;
209
237
  declare class CodeReviewer {
210
238
  private provider;
211
239
  private projectRoot;
@@ -213,8 +241,9 @@ declare class CodeReviewer {
213
241
  private getGitDiff;
214
242
  private getDiffStats;
215
243
  /**
216
- * Three-pass review:
217
- * Pass 1architecture (spec compliance, layer separation, auth)
244
+ * Four-pass review:
245
+ * Pass 0 — spec compliance (exhaustive requirement coverage audit)
246
+ * Pass 1 — architecture (layer separation, contract design, auth posture)
218
247
  * Pass 2 — implementation details (validation, error handling, edge cases)
219
248
  * + historical issue recurrence check
220
249
  * Pass 3 — impact assessment + code complexity
@@ -247,7 +276,7 @@ declare function printConstitutionHint(exists: boolean): void;
247
276
  * from task-generator.ts (which already imports AIProvider from spec-generator).
248
277
  */
249
278
 
250
- declare function generateSpecWithTasks(provider: AIProvider, idea: string, context?: ProjectContext): Promise<{
279
+ declare function generateSpecWithTasks(provider: AIProvider, idea: string, context?: ProjectContext, architectureDecision?: string): Promise<{
251
280
  spec: string;
252
281
  tasks: SpecTask[];
253
282
  }>;
@@ -267,4 +296,4 @@ declare class GitWorktreeManager {
267
296
  createWorktree(idea: string): Promise<string | null>;
268
297
  }
269
298
 
270
- export { type AIProvider, CONSTITUTION_FILE, ClaudeProvider, type CodeGenMode, type CodeGenOptions, CodeGenerator, CodeReviewer, ConstitutionGenerator, ContextLoader, DEFAULT_MODELS, ENV_KEY_MAP, FRONTEND_FRAMEWORKS, GeminiProvider, GitWorktreeManager, MiMoProvider, OpenAICompatibleProvider, PROVIDER_CATALOG, type ProjectContext, type ProviderMeta, SUPPORTED_PROVIDERS, type SharedConfigFile, SpecGenerator, SpecRefiner, type SpecTask, TaskGenerator, type TaskLayer, type TaskPriority, type TaskStatus, buildTaskPrompt, createProvider, generateSpecWithTasks, isFrontendDeps, loadConstitution, loadTasksForSpec, printConstitutionHint, printTaskProgress, printTasks, updateTaskStatus };
299
+ export { type AIProvider, CONSTITUTION_FILE, ClaudeProvider, type CodeGenMode, type CodeGenOptions, CodeGenerator, CodeReviewer, ConstitutionGenerator, ContextLoader, DEFAULT_MODELS, ENV_KEY_MAP, FRONTEND_FRAMEWORKS, GeminiProvider, GitWorktreeManager, MiMoProvider, OpenAICompatibleProvider, PROVIDER_CATALOG, type ProjectContext, type ProviderMeta, SUPPORTED_PROVIDERS, type SharedConfigFile, SpecGenerator, SpecRefiner, type SpecTask, TaskGenerator, type TaskLayer, type TaskPriority, type TaskStatus, buildTaskPrompt, createProvider, extractBehavioralContract, extractComplianceScore, extractMissingCount, generateSpecWithTasks, isFrontendDeps, loadConstitution, loadTasksForSpec, printConstitutionHint, printTaskProgress, printTasks, updateTaskStatus };