mycontext-cli 4.2.5 → 4.2.7
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.
- package/README.md +531 -144
- package/dist/README.md +531 -144
- package/dist/cli.js +14 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +17 -4
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init-interactive.d.ts +127 -0
- package/dist/commands/init-interactive.d.ts.map +1 -0
- package/dist/commands/init-interactive.js +754 -0
- package/dist/commands/init-interactive.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +22 -31
- package/dist/commands/init.js.map +1 -1
- package/dist/doctor/DoctorEngine.d.ts.map +1 -1
- package/dist/doctor/DoctorEngine.js +9 -3
- package/dist/doctor/DoctorEngine.js.map +1 -1
- package/dist/doctor/rules/dead-code-rules.d.ts.map +1 -1
- package/dist/doctor/rules/dead-code-rules.js +29 -3
- package/dist/doctor/rules/dead-code-rules.js.map +1 -1
- package/dist/doctor/rules/index.d.ts +3 -1
- package/dist/doctor/rules/index.d.ts.map +1 -1
- package/dist/doctor/rules/index.js +7 -1
- package/dist/doctor/rules/index.js.map +1 -1
- package/dist/doctor/rules/instantdb-rules.d.ts +3 -0
- package/dist/doctor/rules/instantdb-rules.d.ts.map +1 -0
- package/dist/doctor/rules/instantdb-rules.js +335 -0
- package/dist/doctor/rules/instantdb-rules.js.map +1 -0
- package/dist/doctor/rules/typescript-rules.d.ts +3 -0
- package/dist/doctor/rules/typescript-rules.d.ts.map +1 -0
- package/dist/doctor/rules/typescript-rules.js +177 -0
- package/dist/doctor/rules/typescript-rules.js.map +1 -0
- package/dist/doctor/types.d.ts +1 -0
- package/dist/doctor/types.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/dist/services/InferenceEngine.d.ts +41 -0
- package/dist/services/InferenceEngine.d.ts.map +1 -0
- package/dist/services/InferenceEngine.js +307 -0
- package/dist/services/InferenceEngine.js.map +1 -0
- package/dist/services/Planner.d.ts +77 -0
- package/dist/services/Planner.d.ts.map +1 -0
- package/dist/services/Planner.js +828 -0
- package/dist/services/Planner.js.map +1 -0
- package/dist/services/ProjectScanner.d.ts.map +1 -1
- package/dist/services/ProjectScanner.js +7 -3
- package/dist/services/ProjectScanner.js.map +1 -1
- package/dist/types/asl.d.ts +387 -0
- package/dist/types/asl.d.ts.map +1 -0
- package/dist/types/asl.js +139 -0
- package/dist/types/asl.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* InferenceEngine
|
|
4
|
+
*
|
|
5
|
+
* LLM-powered inference system that auto-completes high-confidence tasks,
|
|
6
|
+
* self-critiques its own work, and learns from user corrections.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.InferenceEngine = void 0;
|
|
10
|
+
const AICore_1 = require("../core/ai/AICore");
|
|
11
|
+
class InferenceEngine {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.learningContext = {
|
|
14
|
+
corrections: [],
|
|
15
|
+
preferences: {},
|
|
16
|
+
patterns: [],
|
|
17
|
+
};
|
|
18
|
+
// Initialize AICore
|
|
19
|
+
this.aiCore = AICore_1.AICore.getInstance({
|
|
20
|
+
fallbackEnabled: true,
|
|
21
|
+
workingDirectory: process.cwd(),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run LLM-based inference for a task
|
|
26
|
+
*/
|
|
27
|
+
async infer(task, currentASL, completedTasks) {
|
|
28
|
+
const prompt = this.buildInferencePrompt(task, currentASL, completedTasks);
|
|
29
|
+
const response = await this.aiCore.generateText(prompt, {
|
|
30
|
+
temperature: 0.3, // Lower temperature for more deterministic inference
|
|
31
|
+
});
|
|
32
|
+
let parsedResult;
|
|
33
|
+
try {
|
|
34
|
+
// Strip markdown code blocks if present
|
|
35
|
+
let cleanedResponse = response.trim();
|
|
36
|
+
if (cleanedResponse.startsWith('```json')) {
|
|
37
|
+
cleanedResponse = cleanedResponse.replace(/^```json\s*/m, '').replace(/\s*```$/m, '');
|
|
38
|
+
}
|
|
39
|
+
else if (cleanedResponse.startsWith('```')) {
|
|
40
|
+
cleanedResponse = cleanedResponse.replace(/^```\s*/m, '').replace(/\s*```$/m, '');
|
|
41
|
+
}
|
|
42
|
+
parsedResult = JSON.parse(cleanedResponse);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw new Error(`Failed to parse inference result: ${response}`);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
task,
|
|
49
|
+
result: parsedResult.asl,
|
|
50
|
+
confidence: parsedResult.confidence,
|
|
51
|
+
reasoning: parsedResult.reasoning,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Self-critique: LLM validates its own inference
|
|
56
|
+
*/
|
|
57
|
+
async selfCritique(inference, currentASL) {
|
|
58
|
+
const prompt = this.buildCritiquePrompt(inference, currentASL);
|
|
59
|
+
const response = await this.aiCore.generateText(prompt, {
|
|
60
|
+
temperature: 0.2, // Even lower temperature for critique
|
|
61
|
+
});
|
|
62
|
+
let parsedCritique;
|
|
63
|
+
try {
|
|
64
|
+
// Strip markdown code blocks if present
|
|
65
|
+
let cleanedResponse = response.trim();
|
|
66
|
+
if (cleanedResponse.startsWith('```json')) {
|
|
67
|
+
cleanedResponse = cleanedResponse.replace(/^```json\s*/m, '').replace(/\s*```$/m, '');
|
|
68
|
+
}
|
|
69
|
+
else if (cleanedResponse.startsWith('```')) {
|
|
70
|
+
cleanedResponse = cleanedResponse.replace(/^```\s*/m, '').replace(/\s*```$/m, '');
|
|
71
|
+
}
|
|
72
|
+
parsedCritique = JSON.parse(cleanedResponse);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw new Error(`Failed to parse critique result: ${response}`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
isValid: parsedCritique.isValid,
|
|
79
|
+
confidence: parsedCritique.confidence,
|
|
80
|
+
issues: parsedCritique.issues || [],
|
|
81
|
+
suggestions: parsedCritique.suggestions || [],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Feed inference results to downstream tasks
|
|
86
|
+
* Updates confidence and dependencies
|
|
87
|
+
*/
|
|
88
|
+
feedToNextTasks(completedTask, pendingTasks) {
|
|
89
|
+
return pendingTasks.map((task) => {
|
|
90
|
+
// Check if this task depends on the completed task
|
|
91
|
+
if (task.dependencies.includes(completedTask.id)) {
|
|
92
|
+
// Boost confidence if dependency completed successfully
|
|
93
|
+
const confidenceBoost = completedTask.confidence >= 90 ? 10 : 5;
|
|
94
|
+
const newConfidence = Math.min(100, task.confidence + confidenceBoost);
|
|
95
|
+
return {
|
|
96
|
+
...task,
|
|
97
|
+
confidence: newConfidence,
|
|
98
|
+
autoInfer: newConfidence >= 90,
|
|
99
|
+
needsConfirmation: newConfidence >= 70 && newConfidence < 90,
|
|
100
|
+
needsUserInput: newConfidence < 70,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return task;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Learn from user correction
|
|
108
|
+
*/
|
|
109
|
+
async learnFromCorrection(taskId, inferredValue, correctedValue, reason) {
|
|
110
|
+
const correction = {
|
|
111
|
+
taskId,
|
|
112
|
+
inferredValue,
|
|
113
|
+
correctedValue,
|
|
114
|
+
reason,
|
|
115
|
+
timestamp: new Date(),
|
|
116
|
+
};
|
|
117
|
+
this.learningContext.corrections.push(correction);
|
|
118
|
+
// Detect patterns from corrections
|
|
119
|
+
await this.detectPatterns();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Detect patterns from user corrections
|
|
123
|
+
*/
|
|
124
|
+
async detectPatterns() {
|
|
125
|
+
if (this.learningContext.corrections.length < 2)
|
|
126
|
+
return;
|
|
127
|
+
const prompt = this.buildPatternDetectionPrompt();
|
|
128
|
+
const response = await this.aiCore.generateText(prompt, {
|
|
129
|
+
temperature: 0.3,
|
|
130
|
+
});
|
|
131
|
+
let parsedPatterns;
|
|
132
|
+
try {
|
|
133
|
+
// Strip markdown code blocks if present
|
|
134
|
+
let cleanedResponse = response.trim();
|
|
135
|
+
if (cleanedResponse.startsWith('```json')) {
|
|
136
|
+
cleanedResponse = cleanedResponse.replace(/^```json\s*/m, '').replace(/\s*```$/m, '');
|
|
137
|
+
}
|
|
138
|
+
else if (cleanedResponse.startsWith('```')) {
|
|
139
|
+
cleanedResponse = cleanedResponse.replace(/^```\s*/m, '').replace(/\s*```$/m, '');
|
|
140
|
+
}
|
|
141
|
+
parsedPatterns = JSON.parse(cleanedResponse);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
return; // Silently fail pattern detection
|
|
145
|
+
}
|
|
146
|
+
if (parsedPatterns.patterns && Array.isArray(parsedPatterns.patterns)) {
|
|
147
|
+
this.learningContext.patterns = parsedPatterns.patterns;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get learning context for prompt injection
|
|
152
|
+
*/
|
|
153
|
+
getLearningContext() {
|
|
154
|
+
if (this.learningContext.corrections.length === 0) {
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
const corrections = this.learningContext.corrections
|
|
158
|
+
.map((c) => `- User corrected "${c.inferredValue}" to "${c.correctedValue}"${c.reason ? ` (reason: ${c.reason})` : ""}`)
|
|
159
|
+
.join("\n");
|
|
160
|
+
const patterns = this.learningContext.patterns.length > 0
|
|
161
|
+
? "\n\nDetected patterns:\n" +
|
|
162
|
+
this.learningContext.patterns
|
|
163
|
+
.map((p) => `- ${p.description} (confidence: ${p.confidence}%)`)
|
|
164
|
+
.join("\n")
|
|
165
|
+
: "";
|
|
166
|
+
return `\n\n## Learning Context (from previous corrections):\n${corrections}${patterns}\n\nPlease apply these learnings to your inference.`;
|
|
167
|
+
}
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// PROMPT BUILDING
|
|
170
|
+
// ============================================================================
|
|
171
|
+
buildInferencePrompt(task, currentASL, completedTasks) {
|
|
172
|
+
const learningContext = this.getLearningContext();
|
|
173
|
+
return `You are an expert software architect helping to build a complete application specification (ASL - Abstract Specification Language).
|
|
174
|
+
|
|
175
|
+
## Task
|
|
176
|
+
${task.description}
|
|
177
|
+
|
|
178
|
+
## Current ASL State
|
|
179
|
+
\`\`\`json
|
|
180
|
+
${JSON.stringify(currentASL, null, 2)}
|
|
181
|
+
\`\`\`
|
|
182
|
+
|
|
183
|
+
## Completed Tasks (for context)
|
|
184
|
+
${completedTasks.map((t) => `- ${t.description} (confidence: ${t.confidence}%)`).join("\n")}
|
|
185
|
+
${learningContext}
|
|
186
|
+
|
|
187
|
+
## Your Task
|
|
188
|
+
Infer the missing ASL sections for: "${task.description}"
|
|
189
|
+
|
|
190
|
+
Consider:
|
|
191
|
+
1. What entities, fields, pages, or permissions are needed?
|
|
192
|
+
2. What are the standard conventions for this type of application?
|
|
193
|
+
3. What can be reasonably inferred from the current state and completed tasks?
|
|
194
|
+
4. What patterns exist in similar applications?
|
|
195
|
+
|
|
196
|
+
## Guidelines
|
|
197
|
+
1. **Entities**: Must have 'name' and 'fields'. Fields must have 'name' and 'type' (string, number, boolean, date, json, ref).
|
|
198
|
+
2. **Auth**: If needed, provider must be 'email', 'oauth-github', 'oauth-google', or 'magic-link'.
|
|
199
|
+
3. **Permissions**: Each permission must have 'role', 'resource' (entity name or '*'), and 'actions' (array of: 'create', 'read', 'update', 'delete', 'manage'). **DO NOT USE 'can'**.
|
|
200
|
+
4. **Pages**: Must have 'path' (e.g., '/dashboard'), 'name' (component name), 'type' ('page' or 'layout').
|
|
201
|
+
|
|
202
|
+
Return a JSON response with:
|
|
203
|
+
\`\`\`json
|
|
204
|
+
{
|
|
205
|
+
"asl": {
|
|
206
|
+
// Partial ASL object with your inferred sections
|
|
207
|
+
// Only include the sections you're inferring for this task
|
|
208
|
+
},
|
|
209
|
+
"confidence": 85, // 0-100 confidence score
|
|
210
|
+
"reasoning": "I inferred X because Y. Standard convention suggests Z."
|
|
211
|
+
}
|
|
212
|
+
\`\`\`
|
|
213
|
+
|
|
214
|
+
Be conservative with confidence:
|
|
215
|
+
- 95-100%: Extremely certain (e.g., blog → needs Post entity)
|
|
216
|
+
- 85-94%: Very confident (e.g., blog → likely needs Comment entity)
|
|
217
|
+
- 70-84%: Moderately confident (e.g., auth method could be email or OAuth)
|
|
218
|
+
- Below 70%: Too ambiguous, user input needed
|
|
219
|
+
|
|
220
|
+
Only return JSON, no other text.`;
|
|
221
|
+
}
|
|
222
|
+
buildCritiquePrompt(inference, currentASL) {
|
|
223
|
+
return `You are a critical reviewer validating an AI inference.
|
|
224
|
+
|
|
225
|
+
## Original Task
|
|
226
|
+
${inference.task.description}
|
|
227
|
+
|
|
228
|
+
## Inference Made
|
|
229
|
+
\`\`\`json
|
|
230
|
+
${JSON.stringify(inference.result, null, 2)}
|
|
231
|
+
\`\`\`
|
|
232
|
+
|
|
233
|
+
## Reasoning Provided
|
|
234
|
+
${inference.reasoning}
|
|
235
|
+
|
|
236
|
+
## Confidence Claimed
|
|
237
|
+
${inference.confidence}%
|
|
238
|
+
|
|
239
|
+
## Current ASL State
|
|
240
|
+
\`\`\`json
|
|
241
|
+
${JSON.stringify(currentASL, null, 2)}
|
|
242
|
+
\`\`\`
|
|
243
|
+
|
|
244
|
+
## Your Task
|
|
245
|
+
Critically evaluate this inference. Look for:
|
|
246
|
+
1. **Logical errors**: Does the inference make sense?
|
|
247
|
+
2. **Inconsistencies**: Does it conflict with existing ASL?
|
|
248
|
+
3. **Over-confidence**: Is the confidence score justified?
|
|
249
|
+
4. **Missing context**: Are there assumptions that might be wrong?
|
|
250
|
+
5. **Type safety**: Are the field types appropriate?
|
|
251
|
+
|
|
252
|
+
Return a JSON response:
|
|
253
|
+
\`\`\`json
|
|
254
|
+
{
|
|
255
|
+
"isValid": true, // or false
|
|
256
|
+
"confidence": 85, // Updated confidence (can be lower or higher)
|
|
257
|
+
"issues": [
|
|
258
|
+
{
|
|
259
|
+
"severity": "error", // "error" | "warning" | "info"
|
|
260
|
+
"message": "Description of the issue",
|
|
261
|
+
"field": "entities.User.fields[0]", // Optional: specific field path
|
|
262
|
+
"suggestion": "How to fix it"
|
|
263
|
+
}
|
|
264
|
+
],
|
|
265
|
+
"suggestions": [
|
|
266
|
+
"Consider adding X",
|
|
267
|
+
"Y might be better as Z"
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
\`\`\`
|
|
271
|
+
|
|
272
|
+
Be harsh but fair. Drop confidence if there's any doubt.
|
|
273
|
+
|
|
274
|
+
Only return JSON, no other text.`;
|
|
275
|
+
}
|
|
276
|
+
buildPatternDetectionPrompt() {
|
|
277
|
+
const corrections = this.learningContext.corrections
|
|
278
|
+
.map((c, idx) => `${idx + 1}. Task: ${c.taskId}\n Inferred: ${JSON.stringify(c.inferredValue)}\n Corrected: ${JSON.stringify(c.correctedValue)}${c.reason ? `\n Reason: ${c.reason}` : ""}`)
|
|
279
|
+
.join("\n\n");
|
|
280
|
+
return `Analyze these user corrections and detect patterns:
|
|
281
|
+
|
|
282
|
+
${corrections}
|
|
283
|
+
|
|
284
|
+
Look for patterns in:
|
|
285
|
+
1. **Terminology**: User prefers certain terms (e.g., "article" instead of "post")
|
|
286
|
+
2. **Structure**: User prefers certain data structures (e.g., nested vs flat)
|
|
287
|
+
3. **Preferences**: User has specific preferences (e.g., always use OAuth instead of email/password)
|
|
288
|
+
|
|
289
|
+
Return JSON:
|
|
290
|
+
\`\`\`json
|
|
291
|
+
{
|
|
292
|
+
"patterns": [
|
|
293
|
+
{
|
|
294
|
+
"type": "terminology", // "terminology" | "structure" | "preference"
|
|
295
|
+
"description": "User prefers 'article' over 'post'",
|
|
296
|
+
"examples": ["post → article", "blog post → article"],
|
|
297
|
+
"confidence": 95 // How confident are you this is a real pattern
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
\`\`\`
|
|
302
|
+
|
|
303
|
+
Only return JSON, no other text.`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
exports.InferenceEngine = InferenceEngine;
|
|
307
|
+
//# sourceMappingURL=InferenceEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InferenceEngine.js","sourceRoot":"","sources":["../../src/services/InferenceEngine.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAWH,8CAA2C;AAE3C,MAAa,eAAe;IAI1B;QACE,IAAI,CAAC,eAAe,GAAG;YACrB,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,EAAE;YACf,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,oBAAoB;QACpB,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,WAAW,CAAC;YAC/B,eAAe,EAAE,IAAI;YACrB,gBAAgB,EAAE,OAAO,CAAC,GAAG,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CACT,IAAmB,EACnB,UAAwB,EACxB,cAA+B;QAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE;YACtD,WAAW,EAAE,GAAG,EAAE,qDAAqD;SACxE,CAAC,CAAC;QAEH,IAAI,YAAiB,CAAC;QACtB,IAAI,CAAC;YACH,wCAAwC;YACxC,IAAI,eAAe,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtC,IAAI,eAAe,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,C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WAAW;;;;;;;;;;;;;;;;;;;;;iCAqBoB,CAAC;IAChC,CAAC;CACF;AApWD,0CAoWC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planner Service
|
|
3
|
+
*
|
|
4
|
+
* The "Planner Layer" in the MyContext compiler pipeline.
|
|
5
|
+
* Responsible for:
|
|
6
|
+
* 1. Validating ASL for 100% completeness
|
|
7
|
+
* 2. Generating clarifying questions for gaps
|
|
8
|
+
* 3. Creating diff previews before generation
|
|
9
|
+
* 4. Task decomposition with confidence scoring (NEW)
|
|
10
|
+
* 5. Auto-inference for high-confidence tasks (NEW)
|
|
11
|
+
*
|
|
12
|
+
* The Planner ensures NO code is generated until the specification is perfect.
|
|
13
|
+
*/
|
|
14
|
+
import type { ASL, ASLValidationResult, Question, DiffPreview, InferenceTask, PlannerState, ContextRevelation, Checkpoint } from "../types/asl";
|
|
15
|
+
export declare class Planner {
|
|
16
|
+
private state;
|
|
17
|
+
private inferenceEngine;
|
|
18
|
+
private aiCore;
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Decompose initial input into inference tasks with confidence scores
|
|
22
|
+
*/
|
|
23
|
+
decompose(initialInput: string): Promise<InferenceTask[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Select next task to execute based on dependencies and confidence
|
|
26
|
+
*/
|
|
27
|
+
selectNextTask(): InferenceTask | null;
|
|
28
|
+
/**
|
|
29
|
+
* Mark task as completed and update state
|
|
30
|
+
*/
|
|
31
|
+
markTaskComplete(taskId: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Update dependent tasks after a task completes
|
|
34
|
+
*/
|
|
35
|
+
updateDependentTasks(completedTask: InferenceTask): void;
|
|
36
|
+
/**
|
|
37
|
+
* Reveal context to user (what was inferred and why)
|
|
38
|
+
*/
|
|
39
|
+
revealContext(task: InferenceTask, inference: Partial<ASL>): ContextRevelation[];
|
|
40
|
+
/**
|
|
41
|
+
* Create checkpoint summary before proceeding
|
|
42
|
+
*/
|
|
43
|
+
createCheckpoint(autoInferredTasks: InferenceTask[]): Checkpoint;
|
|
44
|
+
/**
|
|
45
|
+
* Get current planner state
|
|
46
|
+
*/
|
|
47
|
+
getState(): PlannerState;
|
|
48
|
+
/**
|
|
49
|
+
* Update overall confidence score
|
|
50
|
+
*/
|
|
51
|
+
private updateConfidenceScore;
|
|
52
|
+
/**
|
|
53
|
+
* Build decomposition prompt
|
|
54
|
+
*/
|
|
55
|
+
private buildDecompositionPrompt;
|
|
56
|
+
/**
|
|
57
|
+
* Validate ASL for completeness and correctness
|
|
58
|
+
*/
|
|
59
|
+
validate(asl: Partial<ASL>): ASLValidationResult;
|
|
60
|
+
/**
|
|
61
|
+
* Generate clarifying questions for gaps in ASL
|
|
62
|
+
*/
|
|
63
|
+
generateQuestions(asl: Partial<ASL>): Question[];
|
|
64
|
+
/**
|
|
65
|
+
* Generate diff preview showing what will be generated
|
|
66
|
+
*/
|
|
67
|
+
generateDiff(asl: ASL): DiffPreview;
|
|
68
|
+
/**
|
|
69
|
+
* Check if ASL is complete enough for generation
|
|
70
|
+
*/
|
|
71
|
+
isComplete(asl: Partial<ASL>): boolean;
|
|
72
|
+
private generateSchemaPreview;
|
|
73
|
+
private generateTypesPreview;
|
|
74
|
+
private pageSpecToPath;
|
|
75
|
+
private estimateSize;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Planner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Planner.d.ts","sourceRoot":"","sources":["../../src/services/Planner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,GAAG,EACH,mBAAmB,EAGnB,QAAQ,EAGR,WAAW,EAMX,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,UAAU,EAEX,MAAM,cAAc,CAAC;AAatB,qBAAa,OAAO;IAClB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,eAAe,CAAkB;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