@exaudeus/workrail 0.1.4 → 0.1.6
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/dist/application/services/enhanced-loop-validator.d.ts +21 -0
- package/dist/application/services/enhanced-loop-validator.js +137 -0
- package/dist/application/services/validation-engine.d.ts +3 -0
- package/dist/application/services/validation-engine.js +20 -2
- package/dist/cli.js +33 -6
- package/package.json +1 -1
- package/workflows/coding-task-workflow-with-loops.json +59 -10
- package/workflows/exploration-workflow.json +198 -17
- package/workflows/systemic-bug-investigation-with-loops.json +61 -15
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LoopStep } from '../../types/workflow-types';
|
|
2
|
+
export interface EnhancedValidationResult {
|
|
3
|
+
warnings: string[];
|
|
4
|
+
suggestions: string[];
|
|
5
|
+
info: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class EnhancedLoopValidator {
|
|
8
|
+
private readonly PROMPT_WARNING_THRESHOLD;
|
|
9
|
+
private readonly PROMPT_ERROR_THRESHOLD;
|
|
10
|
+
private readonly TEMPLATE_VAR_PATTERN;
|
|
11
|
+
private readonly TERNARY_PATTERN;
|
|
12
|
+
private readonly NESTED_TERNARY_PATTERN;
|
|
13
|
+
validateLoopStep(step: LoopStep): EnhancedValidationResult;
|
|
14
|
+
private getLoopBodySteps;
|
|
15
|
+
private validateConditionalLogic;
|
|
16
|
+
private validatePromptLength;
|
|
17
|
+
private validateTemplateVariables;
|
|
18
|
+
private getKnownLoopVariables;
|
|
19
|
+
private detectLoopPatterns;
|
|
20
|
+
private validateLoopStructure;
|
|
21
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnhancedLoopValidator = void 0;
|
|
4
|
+
class EnhancedLoopValidator {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.PROMPT_WARNING_THRESHOLD = 1500;
|
|
7
|
+
this.PROMPT_ERROR_THRESHOLD = 2000;
|
|
8
|
+
this.TEMPLATE_VAR_PATTERN = /\{\{([^}]+)\}\}/g;
|
|
9
|
+
this.TERNARY_PATTERN = /\{\{[^}]*\?[^}]*:[^}]*\}\}/;
|
|
10
|
+
this.NESTED_TERNARY_PATTERN = /\{\{[^}]*\?[^}]*\?[^}]*:[^}]*:[^}]*\}\}/;
|
|
11
|
+
}
|
|
12
|
+
validateLoopStep(step) {
|
|
13
|
+
const warnings = [];
|
|
14
|
+
const suggestions = [];
|
|
15
|
+
const info = [];
|
|
16
|
+
const stepsToValidate = this.getLoopBodySteps(step);
|
|
17
|
+
for (const bodyStep of stepsToValidate) {
|
|
18
|
+
this.validateConditionalLogic(bodyStep, warnings, suggestions);
|
|
19
|
+
this.validatePromptLength(bodyStep, warnings, suggestions);
|
|
20
|
+
this.validateTemplateVariables(bodyStep, step, warnings, suggestions);
|
|
21
|
+
}
|
|
22
|
+
this.detectLoopPatterns(step, info, suggestions);
|
|
23
|
+
this.validateLoopStructure(step, warnings, suggestions);
|
|
24
|
+
return { warnings, suggestions, info };
|
|
25
|
+
}
|
|
26
|
+
getLoopBodySteps(step) {
|
|
27
|
+
if (Array.isArray(step.body)) {
|
|
28
|
+
return step.body;
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
validateConditionalLogic(step, warnings, suggestions) {
|
|
33
|
+
const fieldsToCheck = ['prompt', 'title', 'agentRole'];
|
|
34
|
+
for (const field of fieldsToCheck) {
|
|
35
|
+
const value = step[field];
|
|
36
|
+
if (!value || typeof value !== 'string')
|
|
37
|
+
continue;
|
|
38
|
+
if (this.NESTED_TERNARY_PATTERN.test(value)) {
|
|
39
|
+
warnings.push(`Step '${step.id}' contains nested ternary operators in ${field}. This can be hard to read and maintain.`);
|
|
40
|
+
suggestions.push(`Consider refactoring nested conditionals into separate steps with runCondition.`);
|
|
41
|
+
}
|
|
42
|
+
else if (this.TERNARY_PATTERN.test(value)) {
|
|
43
|
+
const ternaryCount = (value.match(/\?/g) || []).length;
|
|
44
|
+
if (ternaryCount >= 2) {
|
|
45
|
+
warnings.push(`Step '${step.id}' contains complex conditional logic (${ternaryCount} conditions) in ${field}.`);
|
|
46
|
+
suggestions.push(`For loops with ${ternaryCount} or more conditional paths, consider using separate steps with runCondition instead of inline conditionals.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
validatePromptLength(step, warnings, suggestions) {
|
|
52
|
+
if (!step.prompt)
|
|
53
|
+
return;
|
|
54
|
+
const promptLength = step.prompt.length;
|
|
55
|
+
if (promptLength > this.PROMPT_ERROR_THRESHOLD) {
|
|
56
|
+
warnings.push(`Step '${step.id}' has a very long prompt (${promptLength} characters). This may cause issues.`);
|
|
57
|
+
suggestions.push(`Consider splitting this into multiple steps or moving content to the guidance section.`);
|
|
58
|
+
}
|
|
59
|
+
else if (promptLength > this.PROMPT_WARNING_THRESHOLD) {
|
|
60
|
+
warnings.push(`Step '${step.id}' has a long prompt (${promptLength} characters).`);
|
|
61
|
+
suggestions.push(`For better maintainability, consider breaking this into smaller, focused steps.`);
|
|
62
|
+
}
|
|
63
|
+
const conditionalMatches = step.prompt.match(/\{\{[^}]*\?[^}]*\}\}/g);
|
|
64
|
+
if (conditionalMatches) {
|
|
65
|
+
let totalConditionalContent = 0;
|
|
66
|
+
for (const match of conditionalMatches) {
|
|
67
|
+
const literals = match.match(/'[^']*'|"[^"]*"/g) || [];
|
|
68
|
+
for (const literal of literals) {
|
|
69
|
+
totalConditionalContent += literal.length - 2;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (totalConditionalContent > this.PROMPT_ERROR_THRESHOLD) {
|
|
73
|
+
warnings.push(`Step '${step.id}' has conditional content totaling ~${totalConditionalContent} characters when expanded.`);
|
|
74
|
+
suggestions.push(`This exceeds safe limits. Use separate steps with runCondition instead of inline conditionals.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
validateTemplateVariables(step, loopStep, warnings, suggestions) {
|
|
79
|
+
const knownVars = this.getKnownLoopVariables(loopStep);
|
|
80
|
+
const fieldsToCheck = ['prompt', 'title', 'agentRole'];
|
|
81
|
+
for (const field of fieldsToCheck) {
|
|
82
|
+
const value = step[field];
|
|
83
|
+
if (!value || typeof value !== 'string')
|
|
84
|
+
continue;
|
|
85
|
+
const matches = value.matchAll(this.TEMPLATE_VAR_PATTERN);
|
|
86
|
+
for (const match of matches) {
|
|
87
|
+
const expression = match[1].trim();
|
|
88
|
+
const varName = expression.split(/[^a-zA-Z0-9_$]/, 1)[0];
|
|
89
|
+
if (varName && !knownVars.has(varName)) {
|
|
90
|
+
warnings.push(`Step '${step.id}' references potentially undefined variable '${varName}' in ${field}.`);
|
|
91
|
+
suggestions.push(`Ensure '${varName}' is defined in the context or use a known loop variable like: ${Array.from(knownVars).join(', ')}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
getKnownLoopVariables(loopStep) {
|
|
97
|
+
const vars = new Set();
|
|
98
|
+
vars.add(loopStep.loop.iterationVar || 'iteration');
|
|
99
|
+
if (loopStep.loop.type === 'forEach') {
|
|
100
|
+
vars.add(loopStep.loop.itemVar || 'item');
|
|
101
|
+
vars.add(loopStep.loop.indexVar || 'index');
|
|
102
|
+
}
|
|
103
|
+
vars.add('context');
|
|
104
|
+
vars.add('workflowId');
|
|
105
|
+
return vars;
|
|
106
|
+
}
|
|
107
|
+
detectLoopPatterns(step, info, suggestions) {
|
|
108
|
+
const bodySteps = this.getLoopBodySteps(step);
|
|
109
|
+
if (step.loop.type === 'for' && bodySteps.length > 0) {
|
|
110
|
+
const firstStep = bodySteps[0];
|
|
111
|
+
if (firstStep.prompt?.includes('analysis') ||
|
|
112
|
+
firstStep.title?.toLowerCase().includes('analysis') ||
|
|
113
|
+
firstStep.prompt?.includes('Step 1') ||
|
|
114
|
+
firstStep.prompt?.includes('Structure')) {
|
|
115
|
+
info.push('Progressive analysis pattern detected.');
|
|
116
|
+
suggestions.push('Consider using the multi-step pattern with separate steps and runCondition for clearer structure.');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (bodySteps.some(s => s.prompt?.includes('===') && s.prompt?.includes('?'))) {
|
|
120
|
+
info.push('Multi-conditional loop pattern detected.');
|
|
121
|
+
suggestions.push('For loops with multiple conditional paths, the separate steps pattern is more maintainable than inline conditionals.');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
validateLoopStructure(step, warnings, suggestions) {
|
|
125
|
+
if (typeof step.body === 'string' && step.loop.type === 'for' &&
|
|
126
|
+
typeof step.loop.count === 'number' && step.loop.count > 3) {
|
|
127
|
+
suggestions.push(`For loops with ${step.loop.count} iterations, consider if each iteration truly needs different logic. ` +
|
|
128
|
+
`If so, use separate steps with runCondition for better clarity.`);
|
|
129
|
+
}
|
|
130
|
+
if (step.loop.maxIterations > 100) {
|
|
131
|
+
warnings.push(`Loop '${step.id}' has a very high maxIterations limit (${step.loop.maxIterations}). ` +
|
|
132
|
+
`This could cause performance issues.`);
|
|
133
|
+
suggestions.push(`Consider if you really need ${step.loop.maxIterations} iterations, or implement pagination/chunking instead.`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.EnhancedLoopValidator = EnhancedLoopValidator;
|
|
@@ -21,10 +21,13 @@ export interface ValidationResult {
|
|
|
21
21
|
valid: boolean;
|
|
22
22
|
issues: string[];
|
|
23
23
|
suggestions: string[];
|
|
24
|
+
warnings?: string[];
|
|
25
|
+
info?: string[];
|
|
24
26
|
}
|
|
25
27
|
export declare class ValidationEngine {
|
|
26
28
|
private ajv;
|
|
27
29
|
private schemaCache;
|
|
30
|
+
private enhancedLoopValidator;
|
|
28
31
|
constructor();
|
|
29
32
|
private compileSchema;
|
|
30
33
|
private evaluateCriteria;
|
|
@@ -8,10 +8,12 @@ const error_handler_1 = require("../../core/error-handler");
|
|
|
8
8
|
const condition_evaluator_1 = require("../../utils/condition-evaluator");
|
|
9
9
|
const ajv_1 = __importDefault(require("ajv"));
|
|
10
10
|
const workflow_types_1 = require("../../types/workflow-types");
|
|
11
|
+
const enhanced_loop_validator_1 = require("./enhanced-loop-validator");
|
|
11
12
|
class ValidationEngine {
|
|
12
13
|
constructor() {
|
|
13
14
|
this.schemaCache = new Map();
|
|
14
15
|
this.ajv = new ajv_1.default({ allErrors: true });
|
|
16
|
+
this.enhancedLoopValidator = new enhanced_loop_validator_1.EnhancedLoopValidator();
|
|
15
17
|
}
|
|
16
18
|
compileSchema(schema) {
|
|
17
19
|
const schemaKey = JSON.stringify(schema);
|
|
@@ -205,6 +207,7 @@ class ValidationEngine {
|
|
|
205
207
|
throw new error_handler_1.ValidationError('Invalid validationCriteria format.');
|
|
206
208
|
}
|
|
207
209
|
validateLoopStep(step, workflow) {
|
|
210
|
+
const enhancedResult = this.enhancedLoopValidator.validateLoopStep(step);
|
|
208
211
|
const issues = [];
|
|
209
212
|
const suggestions = [];
|
|
210
213
|
const validTypes = ['while', 'until', 'for', 'forEach'];
|
|
@@ -309,15 +312,22 @@ class ValidationEngine {
|
|
|
309
312
|
issues.push(`Invalid index variable name '${step.loop.indexVar}'`);
|
|
310
313
|
suggestions.push('Use a valid JavaScript variable name');
|
|
311
314
|
}
|
|
315
|
+
const allWarnings = [...(enhancedResult.warnings || [])];
|
|
316
|
+
const allSuggestions = [...suggestions, ...(enhancedResult.suggestions || [])];
|
|
317
|
+
const allInfo = [...(enhancedResult.info || [])];
|
|
312
318
|
return {
|
|
313
319
|
valid: issues.length === 0,
|
|
314
320
|
issues,
|
|
315
|
-
suggestions
|
|
321
|
+
suggestions: allSuggestions,
|
|
322
|
+
warnings: allWarnings.length > 0 ? allWarnings : undefined,
|
|
323
|
+
info: allInfo.length > 0 ? allInfo : undefined
|
|
316
324
|
};
|
|
317
325
|
}
|
|
318
326
|
validateWorkflow(workflow) {
|
|
319
327
|
const issues = [];
|
|
320
328
|
const suggestions = [];
|
|
329
|
+
const warnings = [];
|
|
330
|
+
const info = [];
|
|
321
331
|
const stepIds = new Set();
|
|
322
332
|
for (const step of workflow.steps) {
|
|
323
333
|
if (stepIds.has(step.id)) {
|
|
@@ -331,6 +341,12 @@ class ValidationEngine {
|
|
|
331
341
|
const loopResult = this.validateLoopStep(step, workflow);
|
|
332
342
|
issues.push(...loopResult.issues.map(issue => `Step '${step.id}': ${issue}`));
|
|
333
343
|
suggestions.push(...loopResult.suggestions);
|
|
344
|
+
if (loopResult.warnings) {
|
|
345
|
+
warnings.push(...loopResult.warnings.map(warning => `Step '${step.id}': ${warning}`));
|
|
346
|
+
}
|
|
347
|
+
if (loopResult.info) {
|
|
348
|
+
info.push(...loopResult.info.map(i => `Step '${step.id}': ${i}`));
|
|
349
|
+
}
|
|
334
350
|
}
|
|
335
351
|
else {
|
|
336
352
|
if (!step.id) {
|
|
@@ -368,7 +384,9 @@ class ValidationEngine {
|
|
|
368
384
|
return {
|
|
369
385
|
valid: issues.length === 0,
|
|
370
386
|
issues,
|
|
371
|
-
suggestions
|
|
387
|
+
suggestions,
|
|
388
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
389
|
+
info: info.length > 0 ? info : undefined
|
|
372
390
|
};
|
|
373
391
|
}
|
|
374
392
|
isValidVariableName(name) {
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
11
11
|
const os_1 = __importDefault(require("os"));
|
|
12
12
|
const server_1 = require("./infrastructure/rpc/server");
|
|
13
13
|
const workflow_service_1 = require("./application/services/workflow-service");
|
|
14
|
-
const
|
|
14
|
+
const validation_engine_1 = require("./application/services/validation-engine");
|
|
15
15
|
const multi_directory_workflow_storage_1 = require("./infrastructure/storage/multi-directory-workflow-storage");
|
|
16
16
|
const migrate_workflow_1 = require("./cli/migrate-workflow");
|
|
17
17
|
const program = new commander_1.Command();
|
|
@@ -177,18 +177,45 @@ async function validateWorkflowFile(filePath) {
|
|
|
177
177
|
console.error(chalk_1.default.yellow('\nPlease check the JSON syntax and try again.'));
|
|
178
178
|
process.exit(1);
|
|
179
179
|
}
|
|
180
|
-
const
|
|
181
|
-
|
|
180
|
+
const validationEngine = new validation_engine_1.ValidationEngine();
|
|
181
|
+
const result = validationEngine.validateWorkflow(workflow);
|
|
182
|
+
if (result.valid && !result.warnings?.length && !result.info?.length) {
|
|
182
183
|
console.log(chalk_1.default.green('✅ Workflow is valid:'), filePath);
|
|
183
|
-
|
|
184
|
+
}
|
|
185
|
+
else if (result.valid) {
|
|
186
|
+
console.log(chalk_1.default.green('✅ Workflow is valid with warnings:'), filePath);
|
|
187
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
188
|
+
console.log(chalk_1.default.yellow('\n⚠️ Warnings:'));
|
|
189
|
+
result.warnings.forEach(warning => {
|
|
190
|
+
console.log(chalk_1.default.yellow(' •'), warning);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (result.info && result.info.length > 0) {
|
|
194
|
+
console.log(chalk_1.default.blue('\nℹ️ Information:'));
|
|
195
|
+
result.info.forEach(info => {
|
|
196
|
+
console.log(chalk_1.default.blue(' •'), info);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (result.suggestions && result.suggestions.length > 0) {
|
|
200
|
+
console.log(chalk_1.default.gray('\n💡 Suggestions:'));
|
|
201
|
+
result.suggestions.forEach(suggestion => {
|
|
202
|
+
console.log(chalk_1.default.gray(' •'), suggestion);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
184
205
|
}
|
|
185
206
|
else {
|
|
186
207
|
console.error(chalk_1.default.red('❌ Workflow validation failed:'), filePath);
|
|
187
208
|
console.error(chalk_1.default.yellow('\nValidation errors:'));
|
|
188
|
-
result.
|
|
209
|
+
result.issues.forEach(error => {
|
|
189
210
|
console.error(chalk_1.default.red(' •'), error);
|
|
190
211
|
});
|
|
191
|
-
console.error(chalk_1.default.yellow(`\nFound ${result.
|
|
212
|
+
console.error(chalk_1.default.yellow(`\nFound ${result.issues.length} validation error${result.issues.length === 1 ? '' : 's'}.`));
|
|
213
|
+
if (result.suggestions && result.suggestions.length > 0) {
|
|
214
|
+
console.log(chalk_1.default.gray('\n💡 Suggestions:'));
|
|
215
|
+
result.suggestions.forEach(suggestion => {
|
|
216
|
+
console.log(chalk_1.default.gray(' •'), suggestion);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
192
219
|
process.exit(1);
|
|
193
220
|
}
|
|
194
221
|
}
|
package/package.json
CHANGED
|
@@ -152,23 +152,72 @@
|
|
|
152
152
|
},
|
|
153
153
|
"body": [
|
|
154
154
|
{
|
|
155
|
-
"id": "phase-1-
|
|
156
|
-
"title": "Analysis Step
|
|
157
|
-
"prompt": "
|
|
158
|
-
"agentRole": "You are conducting focused analysis step
|
|
155
|
+
"id": "phase-1-step-structure",
|
|
156
|
+
"title": "Analysis Step 1/4: Structure",
|
|
157
|
+
"prompt": "**STEP 1: STRUCTURAL MAPPING**\\n\\nBuild on phase-0c overview, dive deeper into structure:\\n\\n1. Module organization (packages/services)\\n2. Core components (controllers/services/models)\\n3. Architectural patterns from overview\\n4. File naming conventions\\n5. Code organization\\n\\n**Actions:** useTools() with list_dir, grep_search (class/interface/export), read 2-3 files\\n\\n**Output (400 words):**\\n- Structure summary\\n- User rules alignment\\n- Areas for next steps\\n\\nupdateDecisionLog() with 3-5 key files",
|
|
158
|
+
"agentRole": "You are conducting focused analysis step 1 of 4. Your expertise lies in understanding code structure and organization. Use tools extensively and never make assumptions.",
|
|
159
159
|
"guidance": [
|
|
160
|
-
"This is step
|
|
160
|
+
"This is step 1 of a 4-step analysis process",
|
|
161
|
+
"Each step builds on the previous findings",
|
|
162
|
+
"Use tools liberally - verify everything",
|
|
163
|
+
"Update the Decision Log with key discoveries",
|
|
164
|
+
"Respect word limits to prevent context bloat",
|
|
165
|
+
"Note alignment/conflicts with user rules"
|
|
166
|
+
],
|
|
167
|
+
"runCondition": {"var": "analysisStep", "equals": 1},
|
|
168
|
+
"requireConfirmation": false
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "phase-1-step-modules",
|
|
172
|
+
"title": "Analysis Step 2/4: Modules",
|
|
173
|
+
"prompt": "**STEP 2: TASK-RELEVANT MODULES**\\n\\nFocus on task-specific modules:\\n\\n1. Target areas from mapping\\n2. Core business logic\\n3. Data models (interfaces/types/schemas)\\n4. API contracts\\n5. Pattern implementation\\n\\n**Actions:** useTools() and matchPatterns() with codebase_search, read complete files (with imports), trace flows\\n\\n**Output (400 words):**\\n- Module responsibilities\\n- Patterns to match\\n- Integration points\\n\\nupdateDecisionLog() with core logic files",
|
|
174
|
+
"agentRole": "You are conducting focused analysis step 2 of 4. Your expertise lies in identifying and analyzing task-specific components. Use tools extensively and never make assumptions.",
|
|
175
|
+
"guidance": [
|
|
176
|
+
"This is step 2 of a 4-step analysis process",
|
|
177
|
+
"Each step builds on the previous findings",
|
|
178
|
+
"Use tools liberally - verify everything",
|
|
179
|
+
"Update the Decision Log with key discoveries",
|
|
180
|
+
"Respect word limits to prevent context bloat",
|
|
181
|
+
"Note alignment/conflicts with user rules"
|
|
182
|
+
],
|
|
183
|
+
"runCondition": {"var": "analysisStep", "equals": 2},
|
|
184
|
+
"requireConfirmation": false
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"id": "phase-1-step-dependencies",
|
|
188
|
+
"title": "Analysis Step 3/4: Dependencies",
|
|
189
|
+
"prompt": "**STEP 3: DEPENDENCIES & FLOWS**\\n\\nTrace dependencies and execution:\\n\\n1. Import mapping\\n2. Data flow tracing\\n3. Integration points\\n4. Side effects\\n5. Testing patterns\\n\\n**Actions:** useTools() to follow imports, find test files, trace error handling\\n\\n**Output (400 words):**\\n- Dependency map\\n- Integration challenges\\n- Testing strategies\\n- Risk indicators\\n\\nupdateDecisionLog() with dependencies and test approaches",
|
|
190
|
+
"agentRole": "You are conducting focused analysis step 3 of 4. Your expertise lies in tracing dependencies and system flows. Use tools extensively and never make assumptions.",
|
|
191
|
+
"guidance": [
|
|
192
|
+
"This is step 3 of a 4-step analysis process",
|
|
193
|
+
"Each step builds on the previous findings",
|
|
194
|
+
"Use tools liberally - verify everything",
|
|
195
|
+
"Update the Decision Log with key discoveries",
|
|
196
|
+
"Respect word limits to prevent context bloat",
|
|
197
|
+
"Note alignment/conflicts with user rules"
|
|
198
|
+
],
|
|
199
|
+
"runCondition": {"var": "analysisStep", "equals": 3},
|
|
200
|
+
"requireConfirmation": false
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "phase-1-step-patterns",
|
|
204
|
+
"title": "Analysis Step 4/4: Patterns",
|
|
205
|
+
"prompt": "**STEP 4: PATTERN DISCOVERY**\\n\\nIdentify established patterns relevant to the task type. Analyze if this is a pattern-heavy task (tests, telemetry, logging, APIs, UI components).\\n\\n**Actions:** useTools() extensively - codebase_search for concepts, grep_search for pattern markers, read_file for full examples\\n\\n**Output (400 words):**\\n- Pattern types discovered\\n- Reference implementations (with file paths)\\n- Key conventions to follow\\n- Pattern alignment recommendations\\n\\nupdateDecisionLog() with pattern templates and reference files",
|
|
206
|
+
"agentRole": "You are conducting focused analysis step 4 of 4. Your expertise lies in discovering and documenting established implementation patterns for the specific task type. Use tools extensively and never make assumptions.",
|
|
207
|
+
"guidance": [
|
|
208
|
+
"This is step 4 of a 4-step analysis process",
|
|
161
209
|
"Each step builds on the previous findings",
|
|
162
210
|
"Use tools liberally - verify everything",
|
|
163
211
|
"Update the Decision Log with key discoveries",
|
|
164
212
|
"Respect word limits to prevent context bloat",
|
|
165
213
|
"Note alignment/conflicts with user rules",
|
|
166
|
-
"
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
"
|
|
214
|
+
"TASK TYPE ANALYSIS: Determine if this is adding tests (find test utilities, mocking patterns), telemetry/analytics (find tracking implementations, event schemas), logging/monitoring (find log formats, monitoring integrations), API endpoints (find route patterns, validation, error handling), UI components (find component patterns, styling conventions), or other pattern-heavy work",
|
|
215
|
+
"PATTERN SEARCH STRATEGY: Use codebase_search with queries like 'How is [telemetry|testing|logging|API] implemented?'. Use grep_search for pattern markers (e.g., track, analytics, test, describe, log). Find 3-5 reference implementations similar to your task. Look for shared utilities, helpers, or base classes. Check for pattern documentation in README or docs",
|
|
216
|
+
"PATTERN EXTRACTION: Document file structure and naming conventions, common imports and dependencies, implementation approach (functional vs class-based), error handling patterns, configuration patterns, and testing approach for this type of feature",
|
|
217
|
+
"PATTERN VALIDATION: List discovered patterns with file references. Note any conflicting patterns or multiple approaches. Ask user: 'Found these pattern examples: [list files]. Should I follow these patterns, or are there other preferred examples?' Set establishedPatterns context variable",
|
|
218
|
+
"FOCUS ON REUSABILITY: Patterns help avoid reinventing the wheel. Look especially for utility functions, base classes, shared components, or established conventions that should be followed"
|
|
171
219
|
],
|
|
220
|
+
"runCondition": {"var": "analysisStep", "equals": 4},
|
|
172
221
|
"requireConfirmation": false
|
|
173
222
|
}
|
|
174
223
|
],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "exploration-workflow",
|
|
3
3
|
"name": "Comprehensive Adaptive Exploration Workflow",
|
|
4
|
-
"version": "0.0
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "An enterprise-grade exploration workflow featuring multi-phase research loops with saturation detection, evidence-based validation, diverse solution generation, and adversarial challenge patterns. Adapts methodology based on domain type (technical/business/creative) while ensuring depth through triangulation, confidence scoring, and systematic quality gates.",
|
|
6
6
|
"clarificationPrompts": [
|
|
7
7
|
"What specific task, problem, or question do you need to explore?",
|
|
8
8
|
"What constraints or requirements should guide the exploration? (time, budget, technical, etc.)",
|
|
@@ -13,22 +13,26 @@
|
|
|
13
13
|
],
|
|
14
14
|
"preconditions": [
|
|
15
15
|
"User has a clear task, problem, or question to explore",
|
|
16
|
-
"Agent has access to research tools (web search, codebase search, etc.)",
|
|
17
16
|
"User can provide initial context, constraints, or requirements",
|
|
18
17
|
"Agent can maintain context variables throughout the workflow"
|
|
19
18
|
],
|
|
20
19
|
"metaGuidance": [
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
20
|
+
"FUNCTION DEFINITIONS: fun trackEvidence(source, grade) = 'Add to context.evidenceLog[] with {source, grade, timestamp}. Grade: High (peer-reviewed/official), Medium (expert/established), Low (anecdotal/emerging)'",
|
|
21
|
+
"fun checkSaturation() = 'Calculate novelty score: (new_insights / total_insights). If <0.1 for last 3 iterations, set context.saturationReached=true'",
|
|
22
|
+
"fun generateSolution(index, approach) = 'Create solution in context.solutions[index] with {approach, evidence, confidence, tradeoffs, risks}'",
|
|
23
|
+
"fun calculateConfidence() = '(0.4 × evidenceStrength) + (0.3 × triangulation) + (0.2 × sourceDiversity) + (0.1 × recency). Result in context.confidenceScores[]'",
|
|
24
|
+
"fun triggerDeepDive() = 'If confidence < 0.7 OR evidenceGaps.length > 0 OR contradictions found, set context.needsDeepDive=true'",
|
|
25
|
+
"CONTEXT ARCHITECTURE: Track explorationDomain (technical/business/creative), solutions[], evidenceLog[], confidenceScores[], researchPhases[], currentPhase, saturationMetrics, contradictions[], evidenceGaps[]",
|
|
26
|
+
"EVIDENCE STANDARDS: Minimum 3 sources per key claim (from available sources: web, agent knowledge, user environment), at least 1 contrasting perspective required, formal grading using adapted RAND scale (High/Medium/Limited)",
|
|
27
|
+
"SOLUTION DIVERSITY: Generate minimum 5 solutions: Quick/Simple, Thorough/Proven, Creative/Novel, Optimal/Balanced, Contrarian/Alternative",
|
|
28
|
+
"VALIDATION GATES: Phase transitions require validation; solutions need confidence ≥0.7; evidence must pass triangulation check",
|
|
29
|
+
"This workflow follows ANALYZE -> CLARIFY -> RESEARCH (loop) -> GENERATE (divergent) -> EVALUATE (convergent) -> CHALLENGE -> RECOMMEND pattern.",
|
|
30
|
+
"Automation levels (Low/Medium/High) control confirmation requirements. High: auto-proceed if confidence >0.8",
|
|
31
|
+
"Dynamic re-triage allows complexity upgrades and safe downgrades based on research insights and saturation metrics.",
|
|
32
|
+
"TOOL ADAPTATION: Workflow adapts to available tools. Check MCPs and adjust strategy based on what's available.",
|
|
33
|
+
"Context documentation updated at phase boundaries. Include function definitions for resumption.",
|
|
34
|
+
"Failure bounds: word limits (2000), max iterations (5 per loop), total steps (>20 triggers review).",
|
|
35
|
+
"Human approval required after adversarial challenge and before final recommendations."
|
|
32
36
|
],
|
|
33
37
|
"steps": [
|
|
34
38
|
{
|
|
@@ -46,6 +50,32 @@
|
|
|
46
50
|
],
|
|
47
51
|
"requireConfirmation": true
|
|
48
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"id": "phase-0a-user-context",
|
|
55
|
+
"title": "Phase 0a: User Context & Preferences Check",
|
|
56
|
+
"prompt": "**GATHER USER CONTEXT**: Before proceeding, check for relevant user preferences, rules, and past decisions that should influence this exploration.\n\n**CHECK FOR:**\n1. **User Rules/Preferences**: Use memory tools to check for:\n - Organizational standards or guidelines\n - Preferred technologies or approaches\n - Constraints or requirements from past decisions\n - Specific methodologies or frameworks to follow/avoid\n\n2. **Environmental Context**:\n - Current tech stack (if technical)\n - Business constraints (budget, timeline, resources)\n - Regulatory or compliance requirements\n - Team capabilities and preferences\n\n3. **Historical Decisions**:\n - Similar problems solved before\n - Lessons learned from past explorations\n - Established patterns to follow\n\n**ACTIONS:**\n1. Query memory/knowledge base for relevant rules\n2. Set context.userRules[] with applicable preferences\n3. Set context.constraints[] with hard requirements\n4. Note any past decisions that create precedent\n\nIf no specific rules found, note that and proceed with general best practices.",
|
|
57
|
+
"agentRole": "You are gathering user-specific context that will influence all subsequent exploration phases. Your role is to ensure the exploration aligns with the user's established preferences and constraints.",
|
|
58
|
+
"guidance": [
|
|
59
|
+
"This context check happens for all complexity levels",
|
|
60
|
+
"Rules and preferences should influence solution generation",
|
|
61
|
+
"Document which rules apply and why",
|
|
62
|
+
"If conflicts exist between rules and task requirements, flag for clarification"
|
|
63
|
+
],
|
|
64
|
+
"requireConfirmation": false
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "phase-0b-domain-classification",
|
|
68
|
+
"title": "Phase 0b: Domain Classification & Tool Selection",
|
|
69
|
+
"prompt": "**CLASSIFY EXPLORATION DOMAIN**: Based on the task, classify the exploration into one of these domains:\n\n**Technical Domain:**\n- Code implementation, architecture design, debugging\n- Tool selection, framework comparison, performance optimization\n- Primary tools: codebase_search, grep_search (if available), technical documentation\n- Fallback: Agent's technical knowledge, architectural patterns from training\n\n**Business Domain:**\n- Strategy formulation, market analysis, process improvement\n- Cost-benefit analysis, resource allocation, risk assessment\n- Primary tools: web_search for market data (if available), case studies, industry reports\n- Fallback: Business frameworks and principles from agent knowledge\n\n**Creative Domain:**\n- Content creation, design systems, user experience\n- Innovation, brainstorming, conceptual development\n- Primary tools: web_search for inspiration (if available), trend analysis\n- Fallback: Creative methodologies and patterns from agent training\n\n**IMPLEMENT:**\n1. Analyze task characteristics\n2. Set context.explorationDomain = 'technical' | 'business' | 'creative'\n3. Set context.primaryTools[] based on domain\n4. Set context.evaluationCriteria[] appropriate for domain\n\n**DOMAIN-SPECIFIC SUCCESS METRICS:**\n- Technical: Feasibility, performance, maintainability, scalability\n- Business: ROI, time-to-value, risk mitigation, strategic alignment\n- Creative: Innovation, user satisfaction, aesthetics, differentiation",
|
|
70
|
+
"agentRole": "You are a domain classification specialist who identifies the nature of exploration tasks and configures appropriate methodologies, tools, and success criteria for each domain type.",
|
|
71
|
+
"guidance": [
|
|
72
|
+
"Some tasks may span domains - choose primary domain",
|
|
73
|
+
"This classification affects tool selection and evaluation criteria",
|
|
74
|
+
"Document reasoning for domain choice",
|
|
75
|
+
"Set domain-specific context variables for later steps"
|
|
76
|
+
],
|
|
77
|
+
"requireConfirmation": false
|
|
78
|
+
},
|
|
49
79
|
{
|
|
50
80
|
"id": "phase-1-simple-lookup",
|
|
51
81
|
"runCondition": {"var": "explorationComplexity", "equals": "Simple"},
|
|
@@ -152,6 +182,97 @@
|
|
|
152
182
|
]
|
|
153
183
|
}
|
|
154
184
|
},
|
|
185
|
+
{
|
|
186
|
+
"id": "phase-2c-iterative-research-loop",
|
|
187
|
+
"type": "loop",
|
|
188
|
+
"title": "Phase 2c: Multi-Phase Deep Research with Saturation Detection",
|
|
189
|
+
"runCondition": {"var": "explorationComplexity", "not_equals": "Simple"},
|
|
190
|
+
"loop": {
|
|
191
|
+
"type": "for",
|
|
192
|
+
"count": 5,
|
|
193
|
+
"maxIterations": 5,
|
|
194
|
+
"iterationVar": "researchPhase"
|
|
195
|
+
},
|
|
196
|
+
"body": [
|
|
197
|
+
{
|
|
198
|
+
"id": "research-phase-1-broad",
|
|
199
|
+
"title": "Research Phase 1/5: Broad Scan",
|
|
200
|
+
"runCondition": { "var": "researchPhase", "equals": 1 },
|
|
201
|
+
"prompt": "**OBJECTIVE**: Cast a wide net to map the solution landscape, identify key themes, and find conflicting viewpoints.",
|
|
202
|
+
"agentRole": "Systematic Researcher: Broad Scan Specialist",
|
|
203
|
+
"guidance": [
|
|
204
|
+
"Use multiple search strategies (e.g., 'how to [task]', 'alternatives to [tool]').",
|
|
205
|
+
"Identify 3-5 high-level solution categories.",
|
|
206
|
+
"Note sources that directly conflict with each other.",
|
|
207
|
+
"ACTIONS: Update context.evidenceLog[], context.broadScanThemes[], context.contradictions[]"
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"id": "research-phase-2-deep-dive",
|
|
212
|
+
"title": "Research Phase 2/5: Deep Dive",
|
|
213
|
+
"runCondition": { "var": "researchPhase", "equals": 2 },
|
|
214
|
+
"prompt": "**OBJECTIVE**: Focus on the most promising themes from the broad scan. Investigate technical details, find implementation examples, and assess feasibility.",
|
|
215
|
+
"agentRole": "Systematic Researcher: Deep Dive Analyst",
|
|
216
|
+
"guidance": [
|
|
217
|
+
"Focus on the themes in context.broadScanThemes[].",
|
|
218
|
+
"Find specific, real-world implementation examples or case studies.",
|
|
219
|
+
"Assess complexity, dependencies, and requirements for each.",
|
|
220
|
+
"ACTIONS: Update context.evidenceLog[], context.deepDiveFindings[]"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"id": "research-phase-3-contrarian",
|
|
225
|
+
"title": "Research Phase 3/5: Contrarian Research",
|
|
226
|
+
"runCondition": { "var": "researchPhase", "equals": 3 },
|
|
227
|
+
"prompt": "**OBJECTIVE**: Actively seek out opposing viewpoints, failure cases, and critiques of the promising solutions. The goal is to challenge assumptions.",
|
|
228
|
+
"agentRole": "Systematic Researcher: Devil's Advocate",
|
|
229
|
+
"guidance": [
|
|
230
|
+
"Search for '[solution] problems', '[approach] failures', 'why not use [tool]'.",
|
|
231
|
+
"Identify hidden assumptions in the mainstream approaches.",
|
|
232
|
+
"Look for entirely different paradigms that were missed.",
|
|
233
|
+
"ACTIONS: Update context.evidenceLog[], context.contrarianEvidence[]"
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"id": "research-phase-4-synthesis",
|
|
238
|
+
"title": "Research Phase 4/5: Evidence Synthesis",
|
|
239
|
+
"runCondition": { "var": "researchPhase", "equals": 4 },
|
|
240
|
+
"prompt": "**OBJECTIVE**: Consolidate all findings. Resolve contradictions, identify patterns, and build a coherent narrative of the solution landscape.",
|
|
241
|
+
"agentRole": "Systematic Researcher: Synthesizer",
|
|
242
|
+
"guidance": [
|
|
243
|
+
"Review evidence from all previous phases.",
|
|
244
|
+
"Where sources conflict, try to understand the reason for the disagreement.",
|
|
245
|
+
"Build a framework or matrix to compare the approaches.",
|
|
246
|
+
"ACTIONS: Update context.synthesisFramework, context.evidenceGaps[]"
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"id": "research-phase-5-gap-filling",
|
|
251
|
+
"title": "Research Phase 5/5: Gap Filling & Closure",
|
|
252
|
+
"runCondition": { "var": "researchPhase", "equals": 5 },
|
|
253
|
+
"prompt": "**OBJECTIVE**: Address the specific, critical unknowns identified during synthesis. Verify key assumptions and prepare for solution generation.",
|
|
254
|
+
"agentRole": "Systematic Researcher: Finisher",
|
|
255
|
+
"guidance": [
|
|
256
|
+
"Focus only on the critical gaps listed in context.evidenceGaps[].",
|
|
257
|
+
"Perform targeted searches to answer these specific questions.",
|
|
258
|
+
"This is the final research step. The goal is to be 'done', not perfect.",
|
|
259
|
+
"ACTIONS: Update context.evidenceLog[], set context.researchComplete = true"
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"id": "research-phase-validation",
|
|
264
|
+
"title": "Validation: Research Quality Check",
|
|
265
|
+
"prompt": "**OBJECTIVE**: After each research phase, perform a quick quality check.",
|
|
266
|
+
"agentRole": "Quality Analyst",
|
|
267
|
+
"guidance": [
|
|
268
|
+
"EVIDENCE CHECK: Have we gathered at least 3 new sources in this phase? (unless it was gap-filling).",
|
|
269
|
+
"QUALITY CHECK: Is there at least one 'High' or 'Medium' grade source?",
|
|
270
|
+
"SATURATION CHECK: Use checkSaturation() to assess if we are still gathering novel information. If not, we can consider exiting the loop early by setting context.researchComplete = true.",
|
|
271
|
+
"ACTIONS: Update context.qualityMetrics[]"
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
},
|
|
155
276
|
{
|
|
156
277
|
"id": "phase-3-context-documentation",
|
|
157
278
|
"runCondition": {"var": "explorationComplexity", "not_equals": "Simple"},
|
|
@@ -168,11 +289,71 @@
|
|
|
168
289
|
],
|
|
169
290
|
"requireConfirmation": false
|
|
170
291
|
},
|
|
292
|
+
{
|
|
293
|
+
"id": "phase-3a-prepare-solutions",
|
|
294
|
+
"title": "Phase 3a: Prepare Solution Generation",
|
|
295
|
+
"runCondition": {"var": "explorationComplexity", "not_equals": "Simple"},
|
|
296
|
+
"prompt": "**PREPARE SOLUTION GENERATION**\n\nBased on your research findings, prepare for systematic solution generation:\n\n**SETUP TASKS:**\n1. Review research synthesis from Phase 2c\n2. Identify top solution categories/approaches\n3. Create solution generation framework\n\n**CREATE SOLUTION APPROACHES ARRAY:**\nSet context.solutionApproaches with these 5 types:\n```json\n[\n {\"type\": \"Quick/Simple\", \"focus\": \"Minimal time, proven approaches, immediate value\"},\n {\"type\": \"Thorough/Proven\", \"focus\": \"Best practices, comprehensive, long-term sustainability\"},\n {\"type\": \"Creative/Novel\", \"focus\": \"Innovation, emerging tech, competitive advantage\"},\n {\"type\": \"Optimal/Balanced\", \"focus\": \"Best trade-offs, practical yet forward-thinking\"},\n {\"type\": \"Contrarian/Alternative\", \"focus\": \"Challenge assumptions, overlooked approaches\"}\n]\n```\n\n**Also set:**\n- context.solutionCriteria[] from research findings\n- context.evaluationFramework for comparing solutions\n- context.userConstraints from Phase 0a\n\n**This enables the next loop to generate each solution type systematically.**",
|
|
297
|
+
"agentRole": "You are preparing the solution generation phase by creating a structured framework based on research findings.",
|
|
298
|
+
"guidance": [
|
|
299
|
+
"This step makes the loop cleaner by preparing the array",
|
|
300
|
+
"Each solution type should address different user needs",
|
|
301
|
+
"Framework should incorporate research insights"
|
|
302
|
+
],
|
|
303
|
+
"requireConfirmation": false
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"id": "phase-3b-solution-generation-loop",
|
|
307
|
+
"type": "loop",
|
|
308
|
+
"title": "Phase 3b: Diverse Solution Portfolio Generation",
|
|
309
|
+
"runCondition": {"var": "explorationComplexity", "not_equals": "Simple"},
|
|
310
|
+
"loop": {
|
|
311
|
+
"type": "forEach",
|
|
312
|
+
"items": "solutionApproaches",
|
|
313
|
+
"itemVar": "approach",
|
|
314
|
+
"indexVar": "solutionIndex",
|
|
315
|
+
"maxIterations": 5
|
|
316
|
+
},
|
|
317
|
+
"body": [
|
|
318
|
+
{
|
|
319
|
+
"id": "generate-solution",
|
|
320
|
+
"title": "Generate {{approach.type}} Solution ({{solutionIndex + 1}}/5)",
|
|
321
|
+
"prompt": "**GENERATE SOLUTION: {{approach.type}}**\n\n**Focus for this solution type**: {{approach.focus}}\n\n**DIVERGENT THINKING MODE - NO JUDGMENT**\nYou are in pure generation mode. Do NOT evaluate, compare, or judge this solution against others. Focus solely on creating a complete solution that embodies the {{approach.type}} approach.\n\n**SOLUTION REQUIREMENTS:**\n1. Generate a solution that embodies the {{approach.type}} approach\n2. Base it on evidence from all research phases\n3. Make it genuinely different from other solutions (not just variations)\n4. DEFER ALL JUDGMENT - no scoring, ranking, or comparison\n\n**INCORPORATE USER CONTEXT:**\n- Apply all relevant rules from context.userRules[]\n- Respect constraints from context.constraints[]\n- Align with organizational standards and preferences\n- Consider environment-specific factors\n\n**SOLUTION STRUCTURE:**\n1. **Core Approach**: Clear description (what makes this {{approach.type}}?)\n2. **Implementation Path**: 3-5 key steps to execute\n3. **Evidence Base**: Which research findings support this approach?\n4. **Key Features**: What distinguishes this approach?\n5. **Resource Requirements**: What's needed to implement?\n6. **Success Indicators**: Observable outcomes when working\n\n**NO EVALUATION ELEMENTS:**\n- Do NOT include confidence scores\n- Do NOT compare to other solutions\n- Do NOT rank or judge quality\n- Simply generate and document\n\n**ACTIONS:**\n- generateSolution({{solutionIndex}}, '{{approach.type}}')\n- Store complete solution in context.solutions[{{solutionIndex}}]\n- Track which evidence supports this approach",
|
|
322
|
+
"agentRole": "You are in DIVERGENT THINKING mode, generating the {{approach.type}} solution. Focus on creation without judgment. Draw from research to build a complete solution.",
|
|
323
|
+
"guidance": [
|
|
324
|
+
"DIVERGENT PHASE: Generate without evaluating or comparing",
|
|
325
|
+
"Each solution should be genuinely different, not just variations",
|
|
326
|
+
"Ground each solution in evidence from research phases",
|
|
327
|
+
"Align with user rules and preferences from Phase 0a",
|
|
328
|
+
"Include enough detail to be actionable",
|
|
329
|
+
"Reference specific sources from evidenceLog",
|
|
330
|
+
"If a solution conflicts with user rules, note it factually without judgment",
|
|
331
|
+
"DEFER ALL EVALUATION until Phase 4"
|
|
332
|
+
],
|
|
333
|
+
"hasValidation": true,
|
|
334
|
+
"validationCriteria": {
|
|
335
|
+
"and": [
|
|
336
|
+
{
|
|
337
|
+
"type": "contains",
|
|
338
|
+
"value": "Evidence:",
|
|
339
|
+
"message": "Must include evidence section"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"type": "contains",
|
|
343
|
+
"value": "Key Features:",
|
|
344
|
+
"message": "Must describe distinguishing features"
|
|
345
|
+
}
|
|
346
|
+
]
|
|
347
|
+
},
|
|
348
|
+
"requireConfirmation": false
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
},
|
|
171
352
|
{
|
|
172
353
|
"id": "phase-4-option-evaluation",
|
|
173
354
|
"runCondition": {"var": "explorationComplexity", "not_equals": "Simple"},
|
|
174
|
-
"title": "Phase 4:
|
|
175
|
-
"prompt": "**PREP**: Define evaluation criteria based on clarified requirements, constraints, and priorities.\n\n**IMPLEMENT**: \n1. Create weighted scoring matrix with 4-6 evaluation criteria based on clarifications\n2. Score each option quantitatively (1-10 scale) with detailed rationale\n3. Calculate weighted scores and rank options\n4. Perform sensitivity analysis on key criteria weights\n5. Identify decision breakpoints and scenario dependencies\n6. Document evaluation methodology and assumptions\n\n**VERIFY**: Ensure evaluation is objective, comprehensive, and incorporates all clarified priorities.",
|
|
355
|
+
"title": "Phase 4: CONVERGENT THINKING - Option Evaluation & Ranking",
|
|
356
|
+
"prompt": "**TRANSITION TO CONVERGENT THINKING MODE**\n\nThe divergent generation phase is complete. Now shift to analytical, convergent thinking to systematically evaluate all solutions.\n\n**CONVERGENT THINKING PRINCIPLES:**\n- This is NOW the time for judgment and comparison\n- Apply critical analysis to all generated solutions\n- Use evidence-based evaluation criteria\n- Be rigorous and systematic\n\n**PREP**: Define evaluation criteria based on clarified requirements, constraints, and priorities.\n\n**IMPLEMENT**: \n1. Create weighted scoring matrix with 4-6 evaluation criteria based on clarifications\n2. Score each option quantitatively (1-10 scale) with detailed rationale\n3. Calculate weighted scores and rank options\n4. Perform sensitivity analysis on key criteria weights\n5. Identify decision breakpoints and scenario dependencies\n6. Document evaluation methodology and assumptions\n\n**VERIFY**: Ensure evaluation is objective, comprehensive, and incorporates all clarified priorities.",
|
|
176
357
|
"agentRole": "You are an objective decision analyst expert in multi-criteria evaluation and quantitative assessment. Your expertise lies in translating qualitative factors into structured, defensible evaluations.",
|
|
177
358
|
"guidance": [
|
|
178
359
|
"Use at least 4-6 evaluation criteria based on clarifications",
|
|
@@ -200,7 +381,7 @@
|
|
|
200
381
|
"id": "phase-4b-devil-advocate-review",
|
|
201
382
|
"runCondition": {"var": "explorationComplexity", "not_equals": "Simple"},
|
|
202
383
|
"title": "Phase 4b: Devil's Advocate Evaluation Review",
|
|
203
|
-
"prompt": "Perform a 'devil's advocate' review of your
|
|
384
|
+
"prompt": "Perform a rigorous 'devil's advocate' review of your solutions and evaluation. This is a mandatory adversarial self-challenge to prevent overconfidence and blind spots.\n\n**STRUCTURED ADVERSARIAL ANALYSIS:**\n\n1. **Evidence Challenge**: For each solution's top 3 claims:\n - Is the evidence truly supporting this claim?\n - Are there contradicting sources we dismissed?\n - What evidence grade did we assign vs. what it deserves?\n\n2. **Hidden Failure Modes**: For the top-ranked solution:\n - What could cause catastrophic failure?\n - What assumptions could be completely wrong?\n - What context changes would invalidate this approach?\n\n3. **Overlooked Alternatives**:\n - What hybrid approaches could combine solution strengths?\n - What completely different paradigm did we miss?\n - Are we solving the right problem?\n\n4. **Bias Detection**:\n - Did we favor familiar over novel?\n - Did recent sources overshadow established wisdom?\n - Did domain bias affect our evaluation?\n\n5. **Confidence Calibration**:\n - Where are we overconfident?\n - What unknowns are we treating as knowns?\n - calculateConfidence() with penalty for identified weaknesses\n\n**OUTPUT REQUIREMENTS:**\n- Identify at least 3 significant concerns\n- Propose specific remedies for each\n- Re-calculate confidence scores\n- Set context.confidenceScore (1-10) for overall analysis quality\n- Set context.criticalIssues[] with must-address items\n\ntriggerDeepDive() if confidence drops below 0.7",
|
|
204
385
|
"agentRole": "You are a skeptical but fair senior research analyst with 15+ years of experience in strategic decision analysis. Your role is to identify potential blind spots, biases, and overlooked factors in evaluation methodologies. You excel at constructive criticism that strengthens analysis rather than destroys it.",
|
|
205
386
|
"guidance": [
|
|
206
387
|
"This is critical thinking step to find weaknesses in your own analysis",
|
|
@@ -209,21 +209,67 @@
|
|
|
209
209
|
},
|
|
210
210
|
"body": [
|
|
211
211
|
{
|
|
212
|
-
"id": "analysis-
|
|
213
|
-
"title": "Analysis
|
|
214
|
-
"prompt": "
|
|
215
|
-
"agentRole": "You are performing systematic analysis phase
|
|
212
|
+
"id": "analysis-breadth-scan",
|
|
213
|
+
"title": "Analysis 1/4: Breadth Scan",
|
|
214
|
+
"prompt": "**BREADTH SCAN**\n\n1. **Error Mapping**: grep_search errors, trace logs, map stack traces\n2. **Component Discovery**: Find all interacting components using codebase_search\n3. **Data Flow**: Trace data through bug area, transformations, persistence\n4. **Recent Changes**: Git history last 10 commits\n\n**Output**: BreadthAnalysis.md with interaction map",
|
|
215
|
+
"agentRole": "You are performing systematic analysis phase 1 of 4. Your focus is casting a wide net to find all potentially related components.",
|
|
216
216
|
"guidance": [
|
|
217
|
-
"This is analysis phase
|
|
218
|
-
"Phase 1 = Breadth Scan
|
|
219
|
-
"
|
|
220
|
-
"
|
|
217
|
+
"This is analysis phase 1 of 4 total phases",
|
|
218
|
+
"Phase 1 = Breadth Scan - Cast wide net for all related components",
|
|
219
|
+
"Create BreadthAnalysis.md with structured findings",
|
|
220
|
+
"Use findSimilarBugs() to search for historical patterns",
|
|
221
221
|
"Use the function definitions for standardized operations",
|
|
222
|
-
"
|
|
223
|
-
"Update INVESTIGATION_CONTEXT.md after each phase: use updateInvestigationContext('Analysis Findings', phase-specific findings)",
|
|
224
|
-
"In Phase 1 (Breadth Scan): Use findSimilarBugs() to search for historical patterns",
|
|
225
|
-
"After all 4 phases complete, use trackInvestigation('Phase 1 Complete', 'Moving to Hypothesis Development')"
|
|
222
|
+
"Update INVESTIGATION_CONTEXT.md after completion"
|
|
226
223
|
],
|
|
224
|
+
"runCondition": {"var": "analysisPhase", "equals": 1},
|
|
225
|
+
"requireConfirmation": false
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"id": "analysis-deep-dive",
|
|
229
|
+
"title": "Analysis 2/4: Component Deep Dive",
|
|
230
|
+
"prompt": "**COMPONENT DEEP DIVE**\n\nUse recursiveAnalysis(component, 3) on top 5 suspicious components:\n\n1. **L1 Direct**: Read complete file, state management, error handling\n2. **L2 Dependencies**: Follow imports, contracts, version compatibility\n3. **L3 Integration**: System fit, side effects, concurrency, resources\n\n**Output**: ComponentAnalysis.md with deep insights",
|
|
231
|
+
"agentRole": "You are performing systematic analysis phase 2 of 4. Your focus is deep diving into the most suspicious components to understand their internals.",
|
|
232
|
+
"guidance": [
|
|
233
|
+
"This is analysis phase 2 of 4 total phases",
|
|
234
|
+
"Phase 2 = Deep Dive - Analyze suspicious components 3 levels deep",
|
|
235
|
+
"Build on findings from Phase 1 Breadth Scan",
|
|
236
|
+
"Create ComponentAnalysis.md with structured findings",
|
|
237
|
+
"Use recursiveAnalysis() for systematic exploration",
|
|
238
|
+
"Update INVESTIGATION_CONTEXT.md after completion"
|
|
239
|
+
],
|
|
240
|
+
"runCondition": {"var": "analysisPhase", "equals": 2},
|
|
241
|
+
"requireConfirmation": false
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"id": "analysis-dependencies",
|
|
245
|
+
"title": "Analysis 3/4: Dependencies & Flow",
|
|
246
|
+
"prompt": "**DEPENDENCY & FLOW ANALYSIS**\n\n1. **Static Graph**: Import tree, circular deps, hidden dependencies\n2. **Runtime Flow**: Execution paths, async flows, state changes\n3. **Data Pipeline**: Track transformations, validation, corruption points\n4. **Integration**: External services, DB, queues, filesystem\n\n**Output**: FlowAnalysis.md with diagrams",
|
|
247
|
+
"agentRole": "You are performing systematic analysis phase 3 of 4. Your focus is tracing how components connect and data flows between them.",
|
|
248
|
+
"guidance": [
|
|
249
|
+
"This is analysis phase 3 of 4 total phases",
|
|
250
|
+
"Phase 3 = Dependencies - Trace connections and data flows",
|
|
251
|
+
"Build on component understanding from Phase 2",
|
|
252
|
+
"Create FlowAnalysis.md with diagrams and flow charts",
|
|
253
|
+
"Focus on runtime behavior and integration points",
|
|
254
|
+
"Update INVESTIGATION_CONTEXT.md after completion"
|
|
255
|
+
],
|
|
256
|
+
"runCondition": {"var": "analysisPhase", "equals": 3},
|
|
257
|
+
"requireConfirmation": false
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"id": "analysis-test-coverage",
|
|
261
|
+
"title": "Analysis 4/4: Test Coverage",
|
|
262
|
+
"prompt": "**TEST COVERAGE ANALYSIS**\n\nUse analyzeTests(component) for each suspicious component:\n\n1. **Direct Coverage**: Find tests, analyze coverage gaps, quality\n2. **Integration Tests**: Bug area tests, assumptions, flaky tests\n3. **History**: When added/modified, correlation with bug\n4. **Debug Execution**: Run with debug flags, instrument, compare\n\n**Output**: TestAnalysis.md with coverage gaps matrix",
|
|
263
|
+
"agentRole": "You are performing systematic analysis phase 4 of 4. Your focus is leveraging existing tests to understand expected behavior and find coverage gaps.",
|
|
264
|
+
"guidance": [
|
|
265
|
+
"This is analysis phase 4 of 4 total phases",
|
|
266
|
+
"Phase 4 = Tests - Analyze test coverage and quality",
|
|
267
|
+
"Build on all previous analysis phases",
|
|
268
|
+
"Create TestAnalysis.md with coverage gap matrix",
|
|
269
|
+
"Run tests with debug flags for additional insights",
|
|
270
|
+
"After completion, use trackInvestigation('Phase 1 Complete', 'Moving to Hypothesis Development')"
|
|
271
|
+
],
|
|
272
|
+
"runCondition": {"var": "analysisPhase", "equals": 4},
|
|
227
273
|
"requireConfirmation": false
|
|
228
274
|
}
|
|
229
275
|
],
|
|
@@ -415,7 +461,7 @@
|
|
|
415
461
|
"prompt": "**DEBUGGING INSTRUMENTATION for {{currentHypothesis.id}}**\n\n**Hypothesis**: {{currentHypothesis.description}}\n\n**IMPLEMENT SMART LOGGING**:\n\n1. **Standard Format**: Use instrumentCode(location, '{{currentHypothesis.id}}')\n ```\n className.methodName [{{currentHypothesis.id}}] {timestamp}: Specific message\n ```\n\n2. **Deduplication Implementation**:\n ```javascript\n // Add to each instrumentation point\n const debugState = { lastMsg: '', count: 0 };\n function smartLog(msg) {\n if (debugState.lastMsg === msg) {\n debugState.count++;\n if (debugState.count % 10 === 0) {\n console.log(`[{{currentHypothesis.id}}] ${msg} x${debugState.count}`);\n }\n } else {\n if (debugState.count > 1) {\n console.log(`[{{currentHypothesis.id}}] Previous message x${debugState.count}`);\n }\n console.log(`[{{currentHypothesis.id}}] ${msg}`);\n debugState.lastMsg = msg;\n debugState.count = 1;\n }\n }\n ```\n\n3. **Operation Grouping**:\n ```javascript\n console.log(`=== {{currentHypothesis.id}}: Operation ${opName} Start ===`);\n const startTime = Date.now();\n // ... operation code with smartLog() calls ...\n console.log(`=== {{currentHypothesis.id}}: Operation ${opName} End (${Date.now() - startTime}ms) ===`);\n ```\n\n4. **Test Instrumentation**:\n - Add debugging to relevant test files\n - Instrument test setup/teardown\n - Log test assumptions vs actual behavior\n\n5. **High-Frequency Aggregation**:\n - For loops/iterations, log summary every 100 iterations\n - For events, create time-window summaries\n - Track unique values and their counts\n\n**OUTPUT**: Instrumented code ready to produce clean, manageable logs for {{currentHypothesis.id}}",
|
|
416
462
|
"agentRole": "You are instrumenting code specifically to validate hypothesis {{currentHypothesis.id}}. Focus on targeted evidence collection.",
|
|
417
463
|
"guidance": [
|
|
418
|
-
"This is hypothesis {{hypothesisIndex + 1}} of
|
|
464
|
+
"This is hypothesis {{hypothesisIndex + 1}} of 3",
|
|
419
465
|
"Tailor instrumentation to the specific hypothesis",
|
|
420
466
|
"Ensure non-intrusive implementation"
|
|
421
467
|
],
|
|
@@ -436,7 +482,7 @@
|
|
|
436
482
|
{
|
|
437
483
|
"id": "loop-phase-5-synthesis",
|
|
438
484
|
"title": "Phase 5: Evidence Synthesis for {{currentHypothesis.id}}",
|
|
439
|
-
"prompt": "**EVIDENCE SYNTHESIS for {{currentHypothesis.id}}**\n\n**Synthesize findings:**\n1. **Evidence Summary**: What did we learn about {{currentHypothesis.id}}?\n2. **Confidence Update**: Based on evidence, rate confidence this is the root cause (0-10)\n3. **Status Update**: Mark hypothesis as Confirmed/Refuted/Needs-More-Evidence\n\n**If {{currentHypothesis.id}} is confirmed with high confidence (>8.0):**\n- Set `rootCauseFound` = true\n- Set `rootCauseHypothesis` = {{currentHypothesis.id}}\n- Update `currentConfidence` with confidence score\n\n**If all hypotheses validated but confidence <9.0:**\n- Consider additional investigation needs\n- Document what evidence is still missing\n\n**Context Update**:\n- Use updateInvestigationContext('Evidence Log', evidence summary for {{currentHypothesis.id}})\n- Every 3 iterations: Use trackInvestigation('Validation Progress', '{{hypothesisIndex + 1}}/
|
|
485
|
+
"prompt": "**EVIDENCE SYNTHESIS for {{currentHypothesis.id}}**\n\n**Synthesize findings:**\n1. **Evidence Summary**: What did we learn about {{currentHypothesis.id}}?\n2. **Confidence Update**: Based on evidence, rate confidence this is the root cause (0-10)\n3. **Status Update**: Mark hypothesis as Confirmed/Refuted/Needs-More-Evidence\n\n**If {{currentHypothesis.id}} is confirmed with high confidence (>8.0):**\n- Set `rootCauseFound` = true\n- Set `rootCauseHypothesis` = {{currentHypothesis.id}}\n- Update `currentConfidence` with confidence score\n\n**If all hypotheses validated but confidence <9.0:**\n- Consider additional investigation needs\n- Document what evidence is still missing\n\n**Context Update**:\n- Use updateInvestigationContext('Evidence Log', evidence summary for {{currentHypothesis.id}})\n- Every 3 iterations: Use trackInvestigation('Validation Progress', '{{hypothesisIndex + 1}}/3 hypotheses validated')",
|
|
440
486
|
"agentRole": "You are synthesizing evidence to determine if {{currentHypothesis.id}} is the root cause.",
|
|
441
487
|
"guidance": [
|
|
442
488
|
"Update hypothesis status based on evidence",
|
|
@@ -461,7 +507,7 @@
|
|
|
461
507
|
"var": "currentConfidence",
|
|
462
508
|
"lt": 8.0
|
|
463
509
|
},
|
|
464
|
-
"prompt": "**CONTROLLED EXPERIMENTATION** - When observation isn't enough, experiment!\n\n**Current
|
|
510
|
+
"prompt": "**CONTROLLED EXPERIMENTATION** - When observation isn't enough, experiment!\n\n**Current Investigation Status**: Leading hypothesis (Confidence: {{currentConfidence}}/10)\n\n**EXPERIMENT TYPES** (use controlledModification()):\n\n1. **Guard Additions (Non-Breaking)**:\n ```javascript\n // Add defensive check that logs but doesn't change behavior\n if (unexpectedCondition) {\n console.error('[H1_GUARD] Unexpected state detected:', state);\n // Continue normal execution\n }\n ```\n\n2. **Assertion Injections**:\n ```javascript\n // Add assertion that would fail if hypothesis is correct\n console.assert(expectedCondition, '[H1_ASSERT] Hypothesis H1 violated!');\n ```\n\n3. **Minimal Fix Test**:\n ```javascript\n // Apply minimal fix for hypothesis, see if bug disappears\n if (process.env.DEBUG_FIX_H1 === 'true') {\n // Apply hypothesized fix\n return fixedBehavior();\n }\n ```\n\n4. **Controlled Breaking**:\n ```javascript\n // Temporarily break suspected component to verify involvement\n if (process.env.DEBUG_BREAK_H1 === 'true') {\n throw new Error('[H1_BREAK] Intentionally breaking to test hypothesis');\n }\n ```\n\n**PROTOCOL**:\n1. Choose experiment type based on confidence and risk\n2. Implement modification with clear DEBUG markers\n3. Use createInvestigationBranch() if not already on investigation branch\n4. Commit: `git commit -m \"DEBUG: {{experiment_type}} for hypothesis investigation\"`\n5. Run reproduction steps\n6. Use collectEvidence() to gather results\n7. Revert changes: `git revert HEAD`\n8. Document results in ExperimentResults/hypothesis-experiment.md\n\n**SAFETY LIMITS**:\n- Max 3 experiments per hypothesis\n- Each experiment in separate commit\n- Always revert after evidence collection\n- Document everything in INVESTIGATION_CONTEXT.md\n\n**UPDATE**:\n- Hypothesis confidence based on experimental results\n- Use updateInvestigationContext('Experiment Results', experiment details and outcomes)\n- Track failed experiments in 'Dead Ends & Lessons' section",
|
|
465
511
|
"agentRole": "You are a careful experimenter using controlled code modifications to validate hypotheses. Safety and reversibility are paramount.",
|
|
466
512
|
"guidance": [
|
|
467
513
|
"Start with non-breaking experiments (guards, logs)",
|