ai-spec-dev 0.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.
@@ -0,0 +1,151 @@
1
+ import OpenAI from 'openai';
2
+
3
+ interface ProjectContext {
4
+ techStack: string[];
5
+ fileStructure: string[];
6
+ dependencies: string[];
7
+ apiStructure: string[];
8
+ schema?: string;
9
+ routeSummary?: string;
10
+ /** Contents of .ai-spec-constitution.md if present */
11
+ constitution?: string;
12
+ /** Extracted error handling patterns from source */
13
+ errorPatterns?: string;
14
+ }
15
+ declare class ContextLoader {
16
+ private projectRoot;
17
+ constructor(projectRoot: string);
18
+ loadProjectContext(): Promise<ProjectContext>;
19
+ private loadPackageJson;
20
+ private loadPrismaSchema;
21
+ private loadFileStructure;
22
+ private loadConstitution;
23
+ private loadErrorPatterns;
24
+ private loadApiStructure;
25
+ }
26
+
27
+ interface AIProvider {
28
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
29
+ readonly providerName: string;
30
+ readonly modelName: string;
31
+ }
32
+ interface ProviderMeta {
33
+ /** Human-readable display name */
34
+ displayName: string;
35
+ /** Short description shown in model picker */
36
+ description: string;
37
+ /** Available models (first is the default) */
38
+ models: string[];
39
+ /** Environment variable name for the API key */
40
+ envKey: string;
41
+ /**
42
+ * Base URL for OpenAI-compatible providers.
43
+ * Undefined means the provider has its own SDK (Gemini / Claude).
44
+ */
45
+ baseURL?: string;
46
+ }
47
+ declare const PROVIDER_CATALOG: Record<string, ProviderMeta>;
48
+ declare const SUPPORTED_PROVIDERS: string[];
49
+ declare const DEFAULT_MODELS: Record<string, string>;
50
+ declare const ENV_KEY_MAP: Record<string, string>;
51
+ declare class GeminiProvider implements AIProvider {
52
+ private genAI;
53
+ readonly providerName = "gemini";
54
+ readonly modelName: string;
55
+ constructor(apiKey: string, modelName?: string);
56
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
57
+ }
58
+ declare class ClaudeProvider implements AIProvider {
59
+ private client;
60
+ readonly providerName = "claude";
61
+ readonly modelName: string;
62
+ constructor(apiKey: string, modelName?: string);
63
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
64
+ }
65
+ declare class OpenAICompatibleProvider implements AIProvider {
66
+ protected client: OpenAI;
67
+ readonly providerName: string;
68
+ readonly modelName: string;
69
+ constructor(providerName: string, apiKey: string, modelName: string, baseURL?: string);
70
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
71
+ }
72
+ declare function createProvider(providerName: string, apiKey: string, modelName?: string): AIProvider;
73
+ declare class SpecGenerator {
74
+ private provider;
75
+ constructor(provider: AIProvider);
76
+ generateSpec(idea: string, context?: ProjectContext): Promise<string>;
77
+ }
78
+
79
+ declare class SpecRefiner {
80
+ private provider;
81
+ constructor(provider: AIProvider);
82
+ refineLoop(initialSpec: string): Promise<string>;
83
+ }
84
+
85
+ type CodeGenMode = "claude-code" | "api" | "plan";
86
+ interface CodeGenOptions {
87
+ /** Run claude non-interactively via -p flag (saves tokens, good for automation) */
88
+ auto?: boolean;
89
+ }
90
+ declare class CodeGenerator {
91
+ private provider;
92
+ private mode;
93
+ constructor(provider: AIProvider, mode?: CodeGenMode);
94
+ generateCode(specFilePath: string, workingDir: string, context?: ProjectContext, options?: CodeGenOptions): Promise<void>;
95
+ private isClaudeCLIAvailable;
96
+ private runClaudeCode;
97
+ private runApiMode;
98
+ private runApiModeWithTasks;
99
+ private generateFiles;
100
+ private runPlanMode;
101
+ }
102
+
103
+ declare class CodeReviewer {
104
+ private provider;
105
+ constructor(provider: AIProvider);
106
+ private getGitDiff;
107
+ private getDiffStats;
108
+ reviewCode(specContent: string): Promise<string>;
109
+ }
110
+
111
+ declare const CONSTITUTION_FILE = ".ai-spec-constitution.md";
112
+ declare class ConstitutionGenerator {
113
+ private provider;
114
+ constructor(provider: AIProvider);
115
+ generate(projectRoot: string): Promise<string>;
116
+ saveConstitution(projectRoot: string, content: string): Promise<string>;
117
+ }
118
+ declare function loadConstitution(projectRoot: string): Promise<string | undefined>;
119
+ declare function printConstitutionHint(exists: boolean): void;
120
+
121
+ type TaskLayer = "data" | "infra" | "service" | "api" | "test";
122
+ type TaskPriority = "high" | "medium" | "low";
123
+ interface SpecTask {
124
+ id: string;
125
+ title: string;
126
+ description: string;
127
+ layer: TaskLayer;
128
+ filesToTouch: string[];
129
+ acceptanceCriteria: string[];
130
+ dependencies: string[];
131
+ priority: TaskPriority;
132
+ }
133
+ declare class TaskGenerator {
134
+ private provider;
135
+ constructor(provider: AIProvider);
136
+ generateTasks(spec: string, context?: ProjectContext): Promise<SpecTask[]>;
137
+ saveTasks(tasks: SpecTask[], specFilePath: string): Promise<string>;
138
+ sortByLayer(tasks: SpecTask[]): SpecTask[];
139
+ }
140
+ declare function printTasks(tasks: SpecTask[]): void;
141
+ declare function loadTasksForSpec(specFilePath: string): Promise<SpecTask[] | null>;
142
+
143
+ declare class GitWorktreeManager {
144
+ private baseDir;
145
+ constructor(baseDir: string);
146
+ private isGitRepo;
147
+ private sanitizeFeatureName;
148
+ createWorktree(idea: string): Promise<string | null>;
149
+ }
150
+
151
+ export { type AIProvider, CONSTITUTION_FILE, ClaudeProvider, type CodeGenMode, type CodeGenOptions, CodeGenerator, CodeReviewer, ConstitutionGenerator, ContextLoader, DEFAULT_MODELS, ENV_KEY_MAP, GeminiProvider, GitWorktreeManager, OpenAICompatibleProvider, PROVIDER_CATALOG, type ProjectContext, type ProviderMeta, SUPPORTED_PROVIDERS, SpecGenerator, SpecRefiner, type SpecTask, TaskGenerator, type TaskLayer, type TaskPriority, createProvider, loadConstitution, loadTasksForSpec, printConstitutionHint, printTasks };
@@ -0,0 +1,151 @@
1
+ import OpenAI from 'openai';
2
+
3
+ interface ProjectContext {
4
+ techStack: string[];
5
+ fileStructure: string[];
6
+ dependencies: string[];
7
+ apiStructure: string[];
8
+ schema?: string;
9
+ routeSummary?: string;
10
+ /** Contents of .ai-spec-constitution.md if present */
11
+ constitution?: string;
12
+ /** Extracted error handling patterns from source */
13
+ errorPatterns?: string;
14
+ }
15
+ declare class ContextLoader {
16
+ private projectRoot;
17
+ constructor(projectRoot: string);
18
+ loadProjectContext(): Promise<ProjectContext>;
19
+ private loadPackageJson;
20
+ private loadPrismaSchema;
21
+ private loadFileStructure;
22
+ private loadConstitution;
23
+ private loadErrorPatterns;
24
+ private loadApiStructure;
25
+ }
26
+
27
+ interface AIProvider {
28
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
29
+ readonly providerName: string;
30
+ readonly modelName: string;
31
+ }
32
+ interface ProviderMeta {
33
+ /** Human-readable display name */
34
+ displayName: string;
35
+ /** Short description shown in model picker */
36
+ description: string;
37
+ /** Available models (first is the default) */
38
+ models: string[];
39
+ /** Environment variable name for the API key */
40
+ envKey: string;
41
+ /**
42
+ * Base URL for OpenAI-compatible providers.
43
+ * Undefined means the provider has its own SDK (Gemini / Claude).
44
+ */
45
+ baseURL?: string;
46
+ }
47
+ declare const PROVIDER_CATALOG: Record<string, ProviderMeta>;
48
+ declare const SUPPORTED_PROVIDERS: string[];
49
+ declare const DEFAULT_MODELS: Record<string, string>;
50
+ declare const ENV_KEY_MAP: Record<string, string>;
51
+ declare class GeminiProvider implements AIProvider {
52
+ private genAI;
53
+ readonly providerName = "gemini";
54
+ readonly modelName: string;
55
+ constructor(apiKey: string, modelName?: string);
56
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
57
+ }
58
+ declare class ClaudeProvider implements AIProvider {
59
+ private client;
60
+ readonly providerName = "claude";
61
+ readonly modelName: string;
62
+ constructor(apiKey: string, modelName?: string);
63
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
64
+ }
65
+ declare class OpenAICompatibleProvider implements AIProvider {
66
+ protected client: OpenAI;
67
+ readonly providerName: string;
68
+ readonly modelName: string;
69
+ constructor(providerName: string, apiKey: string, modelName: string, baseURL?: string);
70
+ generate(prompt: string, systemInstruction?: string): Promise<string>;
71
+ }
72
+ declare function createProvider(providerName: string, apiKey: string, modelName?: string): AIProvider;
73
+ declare class SpecGenerator {
74
+ private provider;
75
+ constructor(provider: AIProvider);
76
+ generateSpec(idea: string, context?: ProjectContext): Promise<string>;
77
+ }
78
+
79
+ declare class SpecRefiner {
80
+ private provider;
81
+ constructor(provider: AIProvider);
82
+ refineLoop(initialSpec: string): Promise<string>;
83
+ }
84
+
85
+ type CodeGenMode = "claude-code" | "api" | "plan";
86
+ interface CodeGenOptions {
87
+ /** Run claude non-interactively via -p flag (saves tokens, good for automation) */
88
+ auto?: boolean;
89
+ }
90
+ declare class CodeGenerator {
91
+ private provider;
92
+ private mode;
93
+ constructor(provider: AIProvider, mode?: CodeGenMode);
94
+ generateCode(specFilePath: string, workingDir: string, context?: ProjectContext, options?: CodeGenOptions): Promise<void>;
95
+ private isClaudeCLIAvailable;
96
+ private runClaudeCode;
97
+ private runApiMode;
98
+ private runApiModeWithTasks;
99
+ private generateFiles;
100
+ private runPlanMode;
101
+ }
102
+
103
+ declare class CodeReviewer {
104
+ private provider;
105
+ constructor(provider: AIProvider);
106
+ private getGitDiff;
107
+ private getDiffStats;
108
+ reviewCode(specContent: string): Promise<string>;
109
+ }
110
+
111
+ declare const CONSTITUTION_FILE = ".ai-spec-constitution.md";
112
+ declare class ConstitutionGenerator {
113
+ private provider;
114
+ constructor(provider: AIProvider);
115
+ generate(projectRoot: string): Promise<string>;
116
+ saveConstitution(projectRoot: string, content: string): Promise<string>;
117
+ }
118
+ declare function loadConstitution(projectRoot: string): Promise<string | undefined>;
119
+ declare function printConstitutionHint(exists: boolean): void;
120
+
121
+ type TaskLayer = "data" | "infra" | "service" | "api" | "test";
122
+ type TaskPriority = "high" | "medium" | "low";
123
+ interface SpecTask {
124
+ id: string;
125
+ title: string;
126
+ description: string;
127
+ layer: TaskLayer;
128
+ filesToTouch: string[];
129
+ acceptanceCriteria: string[];
130
+ dependencies: string[];
131
+ priority: TaskPriority;
132
+ }
133
+ declare class TaskGenerator {
134
+ private provider;
135
+ constructor(provider: AIProvider);
136
+ generateTasks(spec: string, context?: ProjectContext): Promise<SpecTask[]>;
137
+ saveTasks(tasks: SpecTask[], specFilePath: string): Promise<string>;
138
+ sortByLayer(tasks: SpecTask[]): SpecTask[];
139
+ }
140
+ declare function printTasks(tasks: SpecTask[]): void;
141
+ declare function loadTasksForSpec(specFilePath: string): Promise<SpecTask[] | null>;
142
+
143
+ declare class GitWorktreeManager {
144
+ private baseDir;
145
+ constructor(baseDir: string);
146
+ private isGitRepo;
147
+ private sanitizeFeatureName;
148
+ createWorktree(idea: string): Promise<string | null>;
149
+ }
150
+
151
+ export { type AIProvider, CONSTITUTION_FILE, ClaudeProvider, type CodeGenMode, type CodeGenOptions, CodeGenerator, CodeReviewer, ConstitutionGenerator, ContextLoader, DEFAULT_MODELS, ENV_KEY_MAP, GeminiProvider, GitWorktreeManager, OpenAICompatibleProvider, PROVIDER_CATALOG, type ProjectContext, type ProviderMeta, SUPPORTED_PROVIDERS, SpecGenerator, SpecRefiner, type SpecTask, TaskGenerator, type TaskLayer, type TaskPriority, createProvider, loadConstitution, loadTasksForSpec, printConstitutionHint, printTasks };