@nbiish/cognitive-tools-mcp 8.8.4 → 8.9.3
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 +49 -49
- package/build/index.js +461 -1280
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,1323 +1,504 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
* -----------------------------------------------------------------------------
|
|
4
|
-
* Gikendaasowin Aabajichiganan - Revolutionary 2-Round Cognitive Deliberation MCP Server (v8.8.3)
|
|
5
|
-
*
|
|
6
|
-
* Description: Revolutionary MCP server implementing the most advanced 2-round cognitive
|
|
7
|
-
* processing engine available. Features a comprehensive 6-stage framework combining
|
|
8
|
-
* Scientific Investigation, OOReD analysis, and Critical Thinking methodologies
|
|
9
|
-
* with expertly evaluated prompting strategies from modern-prompting.mdc.
|
|
10
|
-
*
|
|
11
|
-
* v8.8.2 OPTIMIZATION RELEASE - Threshold Adjustment & Verbosity Reduction:
|
|
12
|
-
* - Updated threshold from ≥1.38 to ≥1.42 for more selective prompting strategies
|
|
13
|
-
* - Removed redundant "Strategy-Enhanced Results" sections from all stages
|
|
14
|
-
* - Optimized critical thinking path generation to eliminate repetitive content
|
|
15
|
-
* - Simplified strategy application formatting for conciseness
|
|
16
|
-
* - Eliminated duplicate strategy evaluation between rounds for consistency
|
|
17
|
-
* - Maintained single tool call architecture with reduced verbosity
|
|
18
|
-
* -----------------------------------------------------------------------------
|
|
19
|
-
*/
|
|
20
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
21
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
22
|
-
import {
|
|
23
|
-
//
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "ToT-lite (Tree of Thoughts)",
|
|
87
|
-
description: "Bounded breadth/depth exploration for complex problem decomposition"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: "Progressive-Hint Prompting (PHP)",
|
|
91
|
-
description: "Use previously generated outputs as contextual hints"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
name: "Cognitive Scaffolding Prompting",
|
|
95
|
-
description: "Structure reasoning through metacognitive frameworks"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "Knowledge Synthesis Prompting (KSP)",
|
|
99
|
-
description: "Integrate knowledge from multiple internal domains"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: "Reflexive Analysis",
|
|
103
|
-
description: "Embed ethical, legal, and cultural considerations"
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: "PAL (Program-Aided Language)",
|
|
107
|
-
description: "Generate executable code for computational tasks"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: "Context-Compression",
|
|
111
|
-
description: "Apply when context exceeds budget using LLMLingua"
|
|
112
|
-
}
|
|
113
|
-
];
|
|
114
|
-
// DYNAMIC IN-PROMPT EVALUATION: Score each strategy based on actual input and context
|
|
115
|
-
const strategies = strategyTemplates.map(template => {
|
|
116
|
-
const solutionLevel = evaluateSolutionLevel(template.name, template.description, input, mode, context);
|
|
117
|
-
const efficiencyLevel = evaluateEfficiencyLevel(template.name, template.description, input, mode, context);
|
|
118
|
-
return {
|
|
119
|
-
name: template.name,
|
|
120
|
-
description: template.description,
|
|
121
|
-
solutionLevel: solutionLevel,
|
|
122
|
-
efficiencyLevel: efficiencyLevel,
|
|
123
|
-
totalScore: solutionLevel + efficiencyLevel
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
// Return strategies with scores ≥1.42
|
|
127
|
-
return strategies.filter(s => s.totalScore >= 1.42).sort((a, b) => b.totalScore - a.totalScore);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* DYNAMIC IN-PROMPT EVALUATION: Evaluates solution capability based on actual task requirements
|
|
131
|
-
* Returns 0.00-0.99 based on how well the strategy solves the specific problem
|
|
132
|
-
*/
|
|
133
|
-
function evaluateSolutionLevel(strategyName, description, input, mode, context) {
|
|
134
|
-
let score = 0.50; // Base score
|
|
135
|
-
// Analyze input complexity and requirements
|
|
136
|
-
const inputLength = input.length;
|
|
137
|
-
const hasCodeTerms = /code|implement|debug|program|function|class|method|variable/.test(input.toLowerCase());
|
|
138
|
-
const hasAnalysisTerms = /analyze|compare|evaluate|assess|review|examine/.test(input.toLowerCase());
|
|
139
|
-
const hasCreativeTerms = /create|design|generate|build|develop|invent/.test(input.toLowerCase());
|
|
140
|
-
const hasDecisionTerms = /decide|choose|select|determine|resolve|conclude/.test(input.toLowerCase());
|
|
141
|
-
const hasComplexLogic = /algorithm|logic|reasoning|thinking|strategy|approach/.test(input.toLowerCase());
|
|
142
|
-
const hasMultiStep = /step|phase|stage|process|workflow|procedure/.test(input.toLowerCase());
|
|
143
|
-
// Strategy-specific solution evaluation based on modern-prompting.mdc capabilities
|
|
144
|
-
if (strategyName.includes("Cache-Augmented Reasoning + ReAct")) {
|
|
145
|
-
score = 0.60; // Strong baseline for reasoning + action cycles
|
|
146
|
-
if (hasComplexLogic && hasMultiStep)
|
|
147
|
-
score += 0.20;
|
|
148
|
-
if (mode === "analyze" || mode === "decide")
|
|
149
|
-
score += 0.15;
|
|
150
|
-
if (context && context.length > 100)
|
|
151
|
-
score += 0.10; // Benefits from context
|
|
152
|
-
}
|
|
153
|
-
else if (strategyName.includes("Self-Consistency")) {
|
|
154
|
-
score = 0.55; // Good for validation
|
|
155
|
-
if (hasDecisionTerms)
|
|
156
|
-
score += 0.25; // Excels at decision validation
|
|
157
|
-
if (mode === "decide" || mode === "evaluate")
|
|
158
|
-
score += 0.18;
|
|
159
|
-
if (inputLength > 300)
|
|
160
|
-
score += 0.10; // Better with complex inputs
|
|
161
|
-
}
|
|
162
|
-
else if (strategyName.includes("Tree of Thoughts")) {
|
|
163
|
-
score = 0.65; // Strong for complex decomposition
|
|
164
|
-
if (hasComplexLogic && hasMultiStep)
|
|
165
|
-
score += 0.25;
|
|
166
|
-
if (mode === "analyze" || mode === "synthesize")
|
|
167
|
-
score += 0.20;
|
|
168
|
-
if (hasCreativeTerms)
|
|
169
|
-
score += 0.15; // Good for creative problem solving
|
|
170
|
-
}
|
|
171
|
-
else if (strategyName.includes("Progressive-Hint Prompting")) {
|
|
172
|
-
score = 0.52; // Moderate baseline
|
|
173
|
-
if (hasMultiStep)
|
|
174
|
-
score += 0.20;
|
|
175
|
-
if (context && context.length > 50)
|
|
176
|
-
score += 0.18; // Uses previous context well
|
|
177
|
-
if (mode === "synthesize")
|
|
178
|
-
score += 0.12;
|
|
179
|
-
}
|
|
180
|
-
else if (strategyName.includes("Cognitive Scaffolding")) {
|
|
181
|
-
score = 0.68; // High baseline for structured thinking
|
|
182
|
-
if (hasComplexLogic)
|
|
183
|
-
score += 0.22;
|
|
184
|
-
if (inputLength > 500)
|
|
185
|
-
score += 0.15; // Better with complex inputs
|
|
186
|
-
if (mode === "analyze" || mode === "evaluate")
|
|
187
|
-
score += 0.12;
|
|
188
|
-
}
|
|
189
|
-
else if (strategyName.includes("Knowledge Synthesis")) {
|
|
190
|
-
score = 0.58; // Good for integration
|
|
191
|
-
if (mode === "synthesize")
|
|
192
|
-
score += 0.25;
|
|
193
|
-
if (hasAnalysisTerms)
|
|
194
|
-
score += 0.18;
|
|
195
|
-
if (context && hasComplexLogic)
|
|
196
|
-
score += 0.15;
|
|
197
|
-
}
|
|
198
|
-
else if (strategyName.includes("Reflexive Analysis")) {
|
|
199
|
-
score = 0.45; // Lower baseline, specialized use
|
|
200
|
-
if (mode === "evaluate")
|
|
201
|
-
score += 0.30; // Excellent for evaluation
|
|
202
|
-
if (hasAnalysisTerms)
|
|
203
|
-
score += 0.20;
|
|
204
|
-
if (input.includes("ethic") || input.includes("legal") || input.includes("cultur"))
|
|
205
|
-
score += 0.25;
|
|
206
|
-
}
|
|
207
|
-
else if (strategyName.includes("PAL (Program-Aided Language)")) {
|
|
208
|
-
score = 0.40; // Specialized for computation
|
|
209
|
-
if (hasCodeTerms)
|
|
210
|
-
score += 0.35; // Excellent for coding tasks
|
|
211
|
-
if (input.includes("calculat") || input.includes("comput") || input.includes("math"))
|
|
212
|
-
score += 0.25;
|
|
213
|
-
if (mode === "decide" && hasCodeTerms)
|
|
214
|
-
score += 0.15;
|
|
215
|
-
}
|
|
216
|
-
else if (strategyName.includes("Context-Compression")) {
|
|
217
|
-
score = 0.35; // Specialized utility
|
|
218
|
-
if (inputLength > 1000)
|
|
219
|
-
score += 0.40; // Excels with large inputs
|
|
220
|
-
if (context && context.length > 500)
|
|
221
|
-
score += 0.25;
|
|
222
|
-
if (inputLength > 2000)
|
|
223
|
-
score += 0.20; // Even better with very large inputs
|
|
224
|
-
}
|
|
225
|
-
return Math.min(0.99, score);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* DYNAMIC IN-PROMPT EVALUATION: Evaluates efficiency based on computational and cognitive overhead
|
|
229
|
-
* Returns 0.00-0.99 based on how efficiently the strategy processes the specific task
|
|
230
|
-
*/
|
|
231
|
-
function evaluateEfficiencyLevel(strategyName, description, input, mode, context) {
|
|
232
|
-
let score = 0.60; // Base efficiency score
|
|
233
|
-
const inputLength = input.length;
|
|
234
|
-
const isSimpleTask = inputLength < 200 && !(/complex|difficult|challenging|intricate/.test(input.toLowerCase()));
|
|
235
|
-
const isUrgentMode = mode === "decide";
|
|
236
|
-
const hasTimeConstraints = /quick|fast|urgent|immediate|rapid/.test(input.toLowerCase());
|
|
237
|
-
// Strategy-specific efficiency evaluation
|
|
238
|
-
if (strategyName.includes("Cache-Augmented Reasoning + ReAct")) {
|
|
239
|
-
score = 0.65; // Good balance of power and efficiency
|
|
240
|
-
if (context)
|
|
241
|
-
score += 0.12; // More efficient with cached context
|
|
242
|
-
if (isSimpleTask)
|
|
243
|
-
score -= 0.08; // Overhead for simple tasks
|
|
244
|
-
if (hasTimeConstraints)
|
|
245
|
-
score += 0.08;
|
|
246
|
-
}
|
|
247
|
-
else if (strategyName.includes("Self-Consistency")) {
|
|
248
|
-
score = 0.45; // Lower efficiency due to parallel processing
|
|
249
|
-
if (isUrgentMode)
|
|
250
|
-
score -= 0.10; // Slower for urgent decisions
|
|
251
|
-
if (isSimpleTask)
|
|
252
|
-
score -= 0.15; // Overkill for simple tasks
|
|
253
|
-
if (inputLength > 500)
|
|
254
|
-
score += 0.20; // More worthwhile for complex inputs
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
// Modern prompting strategies from modern-prompting.mdc
|
|
6
|
+
const PROMPTING_STRATEGIES = {
|
|
7
|
+
"Cache-Augmented Reasoning + ReAct": {
|
|
8
|
+
description: "Interleave internal knowledge activation with reasoning/action cycles. Preload all relevant context into working memory. Keep rationale concise (≤ 8 bullets). Synthesize knowledge from multiple internal sources. Progressive knowledge building through iterative refinement.",
|
|
9
|
+
type: "primary"
|
|
10
|
+
},
|
|
11
|
+
"Self-Consistency": {
|
|
12
|
+
description: "Generate 3 short reasoning drafts in parallel. Return most consistent answer only. Use for ambiguous or high-stakes decisions.",
|
|
13
|
+
type: "primary"
|
|
14
|
+
},
|
|
15
|
+
"PAL (Program-Aided Language)": {
|
|
16
|
+
description: "Generate executable code for computational tasks. Include result + minimal rationale only. Prefix with '# PoT offload' comment.",
|
|
17
|
+
type: "primary"
|
|
18
|
+
},
|
|
19
|
+
"Reflexion": {
|
|
20
|
+
description: "Single critique and revision cycle. Use when confidence < 0.7. Avoid verbose chain-of-thought exposure.",
|
|
21
|
+
type: "primary"
|
|
22
|
+
},
|
|
23
|
+
"Context-Compression": {
|
|
24
|
+
description: "Apply when context exceeds budget. Use LLMLingua/LongLLMLingua compression. Prefer Minimal-CoT and bounded ToT-lite.",
|
|
25
|
+
type: "primary"
|
|
26
|
+
},
|
|
27
|
+
"ToT-lite (Tree of Thoughts)": {
|
|
28
|
+
description: "Bounded breadth/depth exploration. Use for complex problem decomposition. Limited branching to maintain efficiency.",
|
|
29
|
+
type: "primary"
|
|
30
|
+
},
|
|
31
|
+
"Automated Prompt Optimization (APO)": {
|
|
32
|
+
description: "Autonomously refine and improve prompts based on performance feedback. Use techniques like Expert Prompting or iterative refinement to enhance clarity and effectiveness. Reduces manual prompt engineering effort and improves task outcomes.",
|
|
33
|
+
type: "advanced"
|
|
34
|
+
},
|
|
35
|
+
"Reflexive Analysis": {
|
|
36
|
+
description: "Embed ethical, legal, and cultural considerations directly into the reasoning process. Explicitly evaluate prompts and responses against project-specific guidelines (e.g., Indigenous Data Sovereignty principles). Ensures responsible and contextually-aware AI behavior.",
|
|
37
|
+
type: "advanced"
|
|
38
|
+
},
|
|
39
|
+
"Progressive-Hint Prompting (PHP)": {
|
|
40
|
+
description: "Use previously generated outputs as contextual hints. Iterative refinement toward optimal solutions. Multi-turn interaction with cumulative knowledge building. Automatic guidance toward correct reasoning paths.",
|
|
41
|
+
type: "advanced"
|
|
42
|
+
},
|
|
43
|
+
"Cache-Augmented Generation (CAG)": {
|
|
44
|
+
description: "Preload all relevant context into working memory. Eliminate real-time retrieval dependencies. Leverage extended context capabilities of modern LLMs. Reduce latency and minimize retrieval errors.",
|
|
45
|
+
type: "advanced"
|
|
46
|
+
},
|
|
47
|
+
"Cognitive Scaffolding Prompting": {
|
|
48
|
+
description: "Structure reasoning through metacognitive frameworks. Explicit mental model construction and validation. Progressive complexity building from simple to complex tasks. Self-monitoring and regulation of reasoning processes.",
|
|
49
|
+
type: "advanced"
|
|
50
|
+
},
|
|
51
|
+
"Internal Knowledge Synthesis (IKS)": {
|
|
52
|
+
description: "Generate hypothetical knowledge constructs from parametric memory. Activate latent knowledge through structured prompting. Cross-reference and validate internal knowledge consistency. Synthesize coherent responses from distributed model knowledge.",
|
|
53
|
+
type: "advanced"
|
|
54
|
+
},
|
|
55
|
+
"Multimodal Synthesis": {
|
|
56
|
+
description: "Process and integrate information from multiple modalities (e.g., text, images, data). Extend reasoning capabilities to include visual question answering and cross-modal analysis. Enables solutions for a broader range of complex, real-world tasks.",
|
|
57
|
+
type: "advanced"
|
|
58
|
+
},
|
|
59
|
+
"Knowledge Synthesis Prompting (KSP)": {
|
|
60
|
+
description: "Integrate knowledge from multiple internal domains. Fine-grained coherence validation for credibility. Essential for complex factual content generation. Cross-domain knowledge validation and integration.",
|
|
61
|
+
type: "advanced"
|
|
62
|
+
},
|
|
63
|
+
"Prompt Compression": {
|
|
64
|
+
description: "LLMLingua for token budget management. Preserve semantic content while reducing length. Maintain reasoning quality under constraints.",
|
|
65
|
+
type: "advanced"
|
|
255
66
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
score -= 0.15; // Slow for urgent needs
|
|
262
|
-
if (inputLength > 800)
|
|
263
|
-
score += 0.25; // Worth it for very complex problems
|
|
264
|
-
}
|
|
265
|
-
else if (strategyName.includes("Progressive-Hint Prompting")) {
|
|
266
|
-
score = 0.68; // Good efficiency with iterative approach
|
|
267
|
-
if (context)
|
|
268
|
-
score += 0.15; // Very efficient with context
|
|
269
|
-
if (isSimpleTask)
|
|
270
|
-
score += 0.10; // Good for simple progressive tasks
|
|
271
|
-
if (hasTimeConstraints)
|
|
272
|
-
score += 0.08;
|
|
273
|
-
}
|
|
274
|
-
else if (strategyName.includes("Cognitive Scaffolding")) {
|
|
275
|
-
score = 0.52; // Moderate efficiency with structured approach
|
|
276
|
-
if (inputLength > 600)
|
|
277
|
-
score += 0.18; // More efficient for complex structured problems
|
|
278
|
-
if (isSimpleTask)
|
|
279
|
-
score -= 0.12; // Overhead for simple tasks
|
|
280
|
-
if (mode === "analyze")
|
|
281
|
-
score += 0.10;
|
|
282
|
-
}
|
|
283
|
-
else if (strategyName.includes("Knowledge Synthesis")) {
|
|
284
|
-
score = 0.58; // Good efficiency for integration tasks
|
|
285
|
-
if (context && context.length > 100)
|
|
286
|
-
score += 0.15;
|
|
287
|
-
if (mode === "synthesize")
|
|
288
|
-
score += 0.12;
|
|
289
|
-
if (isSimpleTask)
|
|
290
|
-
score -= 0.08;
|
|
291
|
-
}
|
|
292
|
-
else if (strategyName.includes("Reflexive Analysis")) {
|
|
293
|
-
score = 0.35; // Lower efficiency due to deep reflection
|
|
294
|
-
if (mode === "evaluate")
|
|
295
|
-
score += 0.25; // More efficient in evaluation mode
|
|
296
|
-
if (isSimpleTask)
|
|
297
|
-
score -= 0.15; // Overkill for simple tasks
|
|
298
|
-
if (hasTimeConstraints)
|
|
299
|
-
score -= 0.20; // Slow process
|
|
300
|
-
}
|
|
301
|
-
else if (strategyName.includes("PAL (Program-Aided Language)")) {
|
|
302
|
-
score = 0.75; // High efficiency for computational tasks
|
|
303
|
-
if (input.includes("code") || input.includes("calculat"))
|
|
304
|
-
score += 0.15;
|
|
305
|
-
if (isSimpleTask && input.includes("comput"))
|
|
306
|
-
score += 0.10;
|
|
307
|
-
if (!input.match(/code|math|calculat|comput|program/))
|
|
308
|
-
score -= 0.30; // Inefficient for non-computational tasks
|
|
309
|
-
}
|
|
310
|
-
else if (strategyName.includes("Context-Compression")) {
|
|
311
|
-
score = 0.85; // Very high efficiency for compression
|
|
312
|
-
if (inputLength < 500)
|
|
313
|
-
score -= 0.25; // Unnecessary for short inputs
|
|
314
|
-
if (inputLength > 1500)
|
|
315
|
-
score += 0.10; // More valuable for very long inputs
|
|
316
|
-
if (hasTimeConstraints)
|
|
317
|
-
score += 0.05;
|
|
318
|
-
}
|
|
319
|
-
return Math.min(0.99, score);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Generates tool usage recommendations for pair programming scenarios
|
|
323
|
-
*/
|
|
324
|
-
function generateToolRecommendations(input, mode, deliberationResults) {
|
|
325
|
-
const recommendations = [];
|
|
326
|
-
let toolCount = 0;
|
|
327
|
-
// File manipulation tools
|
|
328
|
-
if (input.includes("file") || input.includes("code") || input.includes("implement")) {
|
|
329
|
-
recommendations.push("• **read_file** - Read relevant source files for context");
|
|
330
|
-
recommendations.push("• **replace_string_in_file** - Make targeted code changes");
|
|
331
|
-
recommendations.push("• **create_file** - Create new files as needed");
|
|
332
|
-
toolCount += 3;
|
|
333
|
-
}
|
|
334
|
-
// Web search tools
|
|
335
|
-
if (input.includes("research") || input.includes("latest") || input.includes("current") || mode === "evaluate") {
|
|
336
|
-
recommendations.push("• **vscode-websearchforcopilot_webSearch** - Search for current information");
|
|
337
|
-
recommendations.push("• **mcp_brave-search_brave_web_search** - Comprehensive web search");
|
|
338
|
-
toolCount += 2;
|
|
339
|
-
}
|
|
340
|
-
// Code analysis tools
|
|
341
|
-
if (input.includes("debug") || input.includes("error") || input.includes("analyze")) {
|
|
342
|
-
recommendations.push("• **get_errors** - Check for compilation/lint errors");
|
|
343
|
-
recommendations.push("• **semantic_search** - Find relevant code patterns");
|
|
344
|
-
recommendations.push("• **list_code_usages** - Analyze function/class usage");
|
|
345
|
-
toolCount += 3;
|
|
346
|
-
}
|
|
347
|
-
// Documentation tools
|
|
348
|
-
if (input.includes("documentation") || input.includes("library") || input.includes("api")) {
|
|
349
|
-
recommendations.push("• **mcp_context7_get-library-docs** - Get up-to-date library documentation");
|
|
350
|
-
toolCount += 1;
|
|
351
|
-
}
|
|
352
|
-
// Terminal execution
|
|
353
|
-
if (input.includes("run") || input.includes("execute") || input.includes("install")) {
|
|
354
|
-
recommendations.push("• **run_in_terminal** - Execute commands and scripts");
|
|
355
|
-
toolCount += 1;
|
|
356
|
-
}
|
|
357
|
-
// Default minimum recommendations for pair programming
|
|
358
|
-
if (toolCount === 0) {
|
|
359
|
-
recommendations.push("• **semantic_search** - Explore codebase for relevant patterns");
|
|
360
|
-
recommendations.push("• **read_file** - Review key implementation files");
|
|
361
|
-
recommendations.push("• **vscode-websearchforcopilot_webSearch** - Research best practices");
|
|
362
|
-
toolCount = 3;
|
|
363
|
-
}
|
|
364
|
-
return { toolCount: Math.min(8, toolCount), recommendations };
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Formats prompting strategy evaluation results for output
|
|
368
|
-
* Shows dynamically evaluated strategies with real-time scoring
|
|
369
|
-
*/
|
|
370
|
-
function formatPromptingStrategyResults(strategies) {
|
|
371
|
-
if (strategies.length === 0) {
|
|
372
|
-
return "**No strategies met the threshold of ≥1.42 through dynamic evaluation**";
|
|
373
|
-
}
|
|
374
|
-
let result = `**SELECTED PROMPTING STRATEGIES (Score ≥1.42 - Dynamically Evaluated):**\n`;
|
|
375
|
-
strategies.forEach((strategy, index) => {
|
|
376
|
-
result += `${index + 1}. **${strategy.name}** (Total: ${strategy.totalScore.toFixed(2)})\n`;
|
|
377
|
-
result += ` - Solution Level: ${strategy.solutionLevel.toFixed(2)} (evaluated in-prompt for task fit)\n`;
|
|
378
|
-
result += ` - Efficiency Level: ${strategy.efficiencyLevel.toFixed(2)} (evaluated in-prompt for computational overhead)\n`;
|
|
379
|
-
result += ` - Description: ${strategy.description}\n\n`;
|
|
380
|
-
});
|
|
381
|
-
result += `*All scores dynamically calculated based on actual input context, task mode, and complexity requirements*\n`;
|
|
382
|
-
return result;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Applies selected prompting strategies to enhance stage processing
|
|
386
|
-
*/
|
|
387
|
-
function applySelectedStrategies(strategies, input, mode, stage) {
|
|
388
|
-
if (strategies.length === 0)
|
|
389
|
-
return "";
|
|
390
|
-
return `**Applied Strategies:** ${strategies.map(s => `${s.name} (${s.totalScore.toFixed(2)})`).join(', ')}\n`;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Formats strategy application for display
|
|
394
|
-
*/
|
|
395
|
-
function formatStrategyApplication(strategies) {
|
|
396
|
-
return strategies.map(s => `${s.name} (${s.totalScore.toFixed(2)})`).join(', ');
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Applies scientific scaffolding for enhanced investigation
|
|
400
|
-
*/
|
|
401
|
-
function applyScientificScaffolding(input, mode) {
|
|
402
|
-
return `**Metacognitive Framework Applied:**
|
|
403
|
-
- Problem decomposition using hierarchical analysis
|
|
404
|
-
- Evidence evaluation through structured criteria
|
|
405
|
-
- Hypothesis strength assessment using confidence scoring
|
|
406
|
-
- Systematic validation through cross-referencing methodology`;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Validates scientific consistency using self-consistency approach
|
|
410
|
-
*/
|
|
411
|
-
function validateScientificConsistency(questionIdentification, hypothesisFormation) {
|
|
412
|
-
return `**Consistency Analysis:**
|
|
413
|
-
- Question-hypothesis alignment: HIGH (systematic correspondence achieved)
|
|
414
|
-
- Internal logic coherence: VALIDATED (no contradictory elements detected)
|
|
415
|
-
- Methodological consistency: CONFIRMED (approach aligns with scientific principles)
|
|
416
|
-
- Evidence-conclusion linkage: STRONG (clear causal relationships established)`;
|
|
417
|
-
}
|
|
418
|
-
// --- Cognitive Deliberation Engine ---
|
|
419
|
-
/**
|
|
420
|
-
* Performs complete two-round cognitive deliberation in a single tool call
|
|
421
|
-
* Round 1: Stages 1-2 (Scientific Investigation + Initial OOReD)
|
|
422
|
-
* Round 2: Stages 3-6 (Critical Thinking + Reviews + Final Action)
|
|
423
|
-
* All happens internally without requiring multiple tool calls or session management
|
|
424
|
-
*/
|
|
425
|
-
async function performCognitiveDeliberation(input, mode, context) {
|
|
426
|
-
// ROUND 1: Stages 1-2 (Internal processing)
|
|
427
|
-
// STAGE 1: SCIENTIFIC INVESTIGATION with prompting strategy evaluation
|
|
428
|
-
const selectedStrategies = evaluatePromptingStrategies(input, mode, context);
|
|
429
|
-
const stage1 = await performScientificInvestigation(input, mode, context, selectedStrategies);
|
|
430
|
-
// STAGE 2: INITIAL OOReD
|
|
431
|
-
const stage2 = await performInitialOOReD(input, mode, context, stage1, selectedStrategies);
|
|
432
|
-
const firstRoundResults = `# 1ST ROUND OF DELIBERATION
|
|
433
|
-
|
|
434
|
-
## PROMPTING STRATEGY EVALUATION
|
|
435
|
-
${formatPromptingStrategyResults(selectedStrategies)}
|
|
436
|
-
|
|
437
|
-
## STAGE 1: SCIENTIFIC INVESTIGATION
|
|
438
|
-
${stage1}
|
|
439
|
-
|
|
440
|
-
## STAGE 2: INITIAL OBSERVE-ORIENT-REASON-DECIDE
|
|
441
|
-
${stage2}
|
|
442
|
-
|
|
443
|
-
---
|
|
444
|
-
*First Round Complete: Scientific Investigation + Initial OOReD*`;
|
|
445
|
-
// ROUND 2: Stages 3-6 (Internal processing continues)
|
|
446
|
-
// Use same strategies for consistency (input/mode/context unchanged)
|
|
447
|
-
const secondRoundStrategies = selectedStrategies;
|
|
448
|
-
// STAGE 3: CRITICAL THINKING + PRE-ACT
|
|
449
|
-
const stage3 = await performCriticalThinkingPreAct(input, mode, context, firstRoundResults, secondRoundStrategies);
|
|
450
|
-
// STAGE 4: SCIENTIFIC REVIEW
|
|
451
|
-
const stage4 = await performScientificReview(input, mode, context, firstRoundResults, stage3, secondRoundStrategies);
|
|
452
|
-
// STAGE 5: OOReD REVIEW
|
|
453
|
-
const stage5 = await performOOReViewReview(input, mode, context, firstRoundResults, stage4, secondRoundStrategies);
|
|
454
|
-
// STAGE 6: FINAL ACT
|
|
455
|
-
const stage6 = await performFinalAct(input, mode, context, stage3, stage5, secondRoundStrategies);
|
|
456
|
-
// Generate final tool recommendations
|
|
457
|
-
const finalToolRecs = generateToolRecommendations(input, mode, `${stage3}\n${stage5}\n${stage6}`);
|
|
458
|
-
const secondRoundResults = `# 2ND ROUND OF DELIBERATION
|
|
459
|
-
|
|
460
|
-
## STAGE 3: CRITICAL THINKING & PRE-ACTION PLANNING
|
|
461
|
-
${stage3}
|
|
462
|
-
|
|
463
|
-
## STAGE 4: SCIENTIFIC REVIEW & VALIDATION
|
|
464
|
-
${stage4}
|
|
465
|
-
|
|
466
|
-
## STAGE 5: OOReD REVIEW & REFINEMENT
|
|
467
|
-
${stage5}
|
|
468
|
-
|
|
469
|
-
## STAGE 6: FACT-BASED ACTION & FINAL RECOMMENDATIONS
|
|
470
|
-
${stage6}
|
|
471
|
-
|
|
472
|
-
---
|
|
473
|
-
*Second Round Complete: Critical Thinking + Reviews + Final Action*`;
|
|
474
|
-
// Return complete single-tool-call result
|
|
475
|
-
return `${firstRoundResults}
|
|
476
|
-
|
|
477
|
-
${secondRoundResults}
|
|
478
|
-
|
|
479
|
-
# FINAL DELIBERATION OUTPUT
|
|
480
|
-
|
|
481
|
-
## COMPREHENSIVE ANALYSIS COMPLETE
|
|
482
|
-
The two-round deliberation process has successfully analyzed your ${mode} request through all 6 stages of the cognitive framework. The analysis incorporates the highest-rated prompting strategies and provides actionable recommendations based on systematic investigation and critical thinking.
|
|
483
|
-
|
|
484
|
-
**tool use before re-deliberation: ${finalToolRecs.toolCount}**
|
|
485
|
-
|
|
486
|
-
### RECOMMENDED TOOLS FOR IMPLEMENTATION:
|
|
487
|
-
${finalToolRecs.recommendations.join('\n')}
|
|
488
|
-
|
|
489
|
-
---
|
|
490
|
-
*Enhanced 2-Round Cognitive Framework: Scientific Investigation + OOReD + Critical Thinking*
|
|
491
|
-
*Processing Mode: ${mode} | Total Strategies Applied: ${selectedStrategies.length}*
|
|
492
|
-
*Framework Version: 8.8.3 | Complete Single-Tool-Call Processing*`;
|
|
493
|
-
}
|
|
494
|
-
// --- 6-Stage Cognitive Processing Functions with Integrated Prompting Strategies ---
|
|
495
|
-
/**
|
|
496
|
-
* STAGE 1: SCIENTIFIC INVESTIGATION
|
|
497
|
-
* Implements selected prompting strategies for systematic hypothesis formation and experimental design
|
|
498
|
-
*/
|
|
499
|
-
async function performScientificInvestigation(input, mode, context, strategies) {
|
|
500
|
-
// Apply selected prompting strategies for scientific investigation
|
|
501
|
-
const useCoT = strategies?.some(s => s.name.includes("Chain-of-Thought") || s.name.includes("Cache-Augmented"));
|
|
502
|
-
const useScaffolding = strategies?.some(s => s.name.includes("Scaffolding"));
|
|
503
|
-
const useSelfConsistency = strategies?.some(s => s.name.includes("Self-Consistency"));
|
|
504
|
-
// Chain-of-Thought: Step-by-step scientific method application
|
|
505
|
-
const questionIdentification = identifyScientificQuestion(input, mode, useCoT);
|
|
506
|
-
const hypothesisFormation = formHypothesis(input, mode, context, useCoT);
|
|
507
|
-
const experimentDesign = designCognitiveExperiment(input, mode, useScaffolding);
|
|
508
|
-
// Apply cognitive scaffolding if selected
|
|
509
|
-
const scaffoldingResults = useScaffolding ? applyScientificScaffolding(input, mode) : "";
|
|
510
|
-
// Apply self-consistency validation if selected
|
|
511
|
-
const consistencyCheck = useSelfConsistency ? validateScientificConsistency(questionIdentification, hypothesisFormation) : "";
|
|
512
|
-
return `### Scientific Method Application
|
|
513
|
-
|
|
514
|
-
**Applied Prompting Strategies:** ${strategies?.map(s => s.name).join(', ') || 'Default approach'}
|
|
515
|
-
|
|
516
|
-
**1. Question Identification ${useCoT ? '(Chain-of-Thought)' : ''}:**
|
|
517
|
-
${questionIdentification}
|
|
518
|
-
|
|
519
|
-
**2. Hypothesis Formation ${useCoT ? '(Chain-of-Thought)' : ''}:**
|
|
520
|
-
${hypothesisFormation}
|
|
521
|
-
|
|
522
|
-
**3. Experimental Design ${useScaffolding ? '(Cognitive Scaffolding)' : ''}:**
|
|
523
|
-
${experimentDesign}
|
|
524
|
-
|
|
525
|
-
**4. Data Analysis Framework:**
|
|
526
|
-
${designDataAnalysisFramework(input, mode)}
|
|
67
|
+
};
|
|
68
|
+
class CognitiveDeliberationEngine {
|
|
69
|
+
// Stage 1: Scientific Investigation
|
|
70
|
+
performScientificInvestigation(input, context) {
|
|
71
|
+
return `## Scientific Investigation Framework
|
|
527
72
|
|
|
528
|
-
**
|
|
529
|
-
${setupConclusionFramework(mode)}
|
|
73
|
+
**1. Identify Question:** ${this.extractCoreQuestion(input)}
|
|
530
74
|
|
|
531
|
-
|
|
532
|
-
${scaffoldingResults}` : ''}
|
|
75
|
+
**2. Form Hypothesis:** ${this.formHypothesis(input, context)}
|
|
533
76
|
|
|
534
|
-
${
|
|
535
|
-
${consistencyCheck}` : ''}
|
|
77
|
+
**3. Experimental Design:** ${this.designApproach(input, context)}
|
|
536
78
|
|
|
537
|
-
**
|
|
538
|
-
- Systematic approach to problem decomposition applied
|
|
539
|
-
- Evidence-based reasoning prioritized through ${strategies?.length || 0} selected strategies
|
|
540
|
-
- Hypothesis-driven inquiry methodology established
|
|
541
|
-
- Experimental validation requirements identified with ${useCoT ? 'enhanced reasoning chains' : 'standard validation'}`;
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* STAGE 2: INITIAL OBSERVE-ORIENT-REASON-DECIDE
|
|
545
|
-
* Implements selected prompting strategies for multiple reasoning path exploration
|
|
546
|
-
*/
|
|
547
|
-
async function performInitialOOReD(input, mode, context, stage1Result, strategies) {
|
|
548
|
-
// Tree-of-Thoughts: Multiple parallel reasoning paths
|
|
549
|
-
const observationPaths = generateMultipleObservationPaths(input, mode, context);
|
|
550
|
-
const orientationAlternatives = generateOrientationAlternatives(input, mode, stage1Result);
|
|
551
|
-
const reasoningBranches = generateReasoningBranches(input, mode, context);
|
|
552
|
-
// Meta-Prompting: Self-reflection on reasoning quality
|
|
553
|
-
const qualityAssessment = assessReasoningQuality(reasoningBranches);
|
|
554
|
-
return `### Observe-Orient-Reason-Decide Analysis
|
|
79
|
+
**4. Data Analysis Framework:** ${this.establishAnalysisFramework(input)}
|
|
555
80
|
|
|
556
|
-
**
|
|
557
|
-
|
|
81
|
+
**5. Conclusion Preparation:** ${this.prepareConclusions(input)}`;
|
|
82
|
+
}
|
|
83
|
+
// Stage 2: Initial OOReD
|
|
84
|
+
performInitialOOReD(input, selectedStrategies, context) {
|
|
85
|
+
return `## Initial OOReD Process
|
|
558
86
|
|
|
559
|
-
**
|
|
560
|
-
${orientationAlternatives}
|
|
87
|
+
**Observe:** Input complexity analysis reveals ${this.analyzeComplexity(input)}. Context depth: ${context ? 'comprehensive' : 'minimal'}. Task characteristics: ${this.identifyTaskType(input)}.
|
|
561
88
|
|
|
562
|
-
**
|
|
563
|
-
${reasoningBranches}
|
|
89
|
+
**Orient:** Solution pathway identification using ${selectedStrategies.join(', ')} strategies. Primary approach: ${this.identifyPrimaryApproach(input, selectedStrategies)}.
|
|
564
90
|
|
|
565
|
-
**
|
|
566
|
-
${selectOptimalReasoningPath(reasoningBranches, qualityAssessment)}
|
|
91
|
+
**Reason:** Core reasoning foundation: ${this.establishReasoning(input, selectedStrategies, context)}.
|
|
567
92
|
|
|
568
|
-
**
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* STAGE 3: CRITICAL THINKING + PRE-ACTION PLANNING
|
|
576
|
-
* Implements selected prompting strategies for 10-step critical thinking with validation
|
|
577
|
-
*/
|
|
578
|
-
async function performCriticalThinkingPreAct(input, mode, context, firstRoundResult, strategies) {
|
|
579
|
-
// Self-Consistency: Multiple critical thinking approaches
|
|
580
|
-
const criticalThinkingPaths = await generateCriticalThinkingPaths(input, mode, firstRoundResult);
|
|
581
|
-
const consensusAnalysis = findConsensusAcrossPaths(criticalThinkingPaths);
|
|
582
|
-
// Meta-Prompting: Pre-action planning with tool identification
|
|
583
|
-
const toolPlanning = await planRequiredTools(input, mode, consensusAnalysis);
|
|
584
|
-
// Apply selected prompting strategies
|
|
585
|
-
const strategyResults = strategies ? applySelectedStrategies(strategies, input, mode, "critical-thinking") : "";
|
|
586
|
-
return `### Critical Thinking Analysis (10-Step Framework)
|
|
93
|
+
**Decide:** Action framework: ${this.decideActions(input, context)}`;
|
|
94
|
+
}
|
|
95
|
+
// Stage 3: Critical Thinking
|
|
96
|
+
performCriticalThinking(input, context) {
|
|
97
|
+
return `## Critical Thinking Framework
|
|
587
98
|
|
|
588
|
-
**
|
|
589
|
-
${
|
|
99
|
+
1. **Purpose:** ${this.identifyPurpose(input)}
|
|
100
|
+
2. **Precise Question:** ${this.refineQuestion(input)}
|
|
101
|
+
3. **Operating Context:** ${this.establishContext(input, context)}
|
|
102
|
+
4. **Information Needs:** ${this.identifyInformationNeeds(input)}
|
|
103
|
+
5. **Credibility Assessment:** ${this.assessCredibility(input, context)}
|
|
104
|
+
6. **Relevant Concepts:** ${this.identifyRelevantConcepts(input)}
|
|
105
|
+
7. **Preliminary Conclusions:** ${this.drawPreliminaryConclusions(input)}
|
|
106
|
+
8. **Assumptions Analysis:** ${this.analyzeAssumptions(input)}
|
|
107
|
+
9. **Implications:** ${this.identifyImplications(input)}
|
|
108
|
+
10. **Consequences:** ${this.assessConsequences(input)}
|
|
590
109
|
|
|
591
|
-
**
|
|
592
|
-
|
|
110
|
+
**Pre-Action Tool Planning:** ${this.planToolUsage(input)}`;
|
|
111
|
+
}
|
|
112
|
+
// Stage 4: Scientific Review
|
|
113
|
+
performScientificReview(input, round1Results, context) {
|
|
114
|
+
return `## Scientific Review Process
|
|
593
115
|
|
|
594
|
-
**
|
|
595
|
-
${consensusAnalysis}
|
|
116
|
+
**Question Validation:** ${this.validateQuestion(input, round1Results)}
|
|
596
117
|
|
|
597
|
-
**
|
|
598
|
-
${toolPlanning}
|
|
118
|
+
**Hypothesis Refinement:** ${this.refineHypothesis(input, round1Results)}
|
|
599
119
|
|
|
600
|
-
**
|
|
601
|
-
- Thinking process evaluation: ${evaluateThinkingProcess(criticalThinkingPaths)}
|
|
602
|
-
- Assumption validation: ${validateAssumptions(criticalThinkingPaths)}
|
|
603
|
-
- Bias detection: ${detectCognitiveBiases(criticalThinkingPaths)}
|
|
604
|
-
- Completeness check: ${assessCompletenessOfAnalysis(criticalThinkingPaths)}`;
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* STAGE 4: SCIENTIFIC REVIEW & VALIDATION
|
|
608
|
-
* Implements selected prompting strategies for enhanced validation
|
|
609
|
-
*/
|
|
610
|
-
async function performScientificReview(input, mode, context, firstRoundResult, stage3Result, strategies) {
|
|
611
|
-
// Chain-of-Thought: Systematic review of scientific method application
|
|
612
|
-
const reviewSteps = performSystematicReview(firstRoundResult, stage3Result);
|
|
613
|
-
// Self-Consistency: Multiple validation approaches
|
|
614
|
-
const validationPaths = generateValidationPaths(firstRoundResult, mode);
|
|
615
|
-
const consistencyCheck = assessCrossStageConsistency(firstRoundResult, stage3Result);
|
|
616
|
-
// Apply selected prompting strategies
|
|
617
|
-
const strategyResults = strategies ? applySelectedStrategies(strategies, input, mode, "scientific-review") : "";
|
|
618
|
-
return `### Scientific Review & Enhanced Validation
|
|
120
|
+
**Methodology Assessment:** ${this.assessMethodology(round1Results)}
|
|
619
121
|
|
|
620
|
-
**
|
|
621
|
-
${strategies ? formatStrategyApplication(strategies) : "Default scientific review approach"}
|
|
122
|
+
**Evidence Evaluation:** ${this.evaluateEvidence(input, context, round1Results)}
|
|
622
123
|
|
|
623
|
-
**
|
|
624
|
-
|
|
124
|
+
**Conclusion Verification:** ${this.verifyConclusions(round1Results)}`;
|
|
125
|
+
}
|
|
126
|
+
// Stage 5: OOReD Review
|
|
127
|
+
performOOReD_Review(input, round1Results, selectedStrategies, context) {
|
|
128
|
+
return `## OOReD Review Process
|
|
625
129
|
|
|
626
|
-
**
|
|
627
|
-
${validationPaths}
|
|
130
|
+
**Enhanced Observation:** ${this.enhanceObservation(input, round1Results)}
|
|
628
131
|
|
|
629
|
-
**
|
|
630
|
-
${consistencyCheck}
|
|
132
|
+
**Strategic Reorientation:** ${this.reorient(input, round1Results, selectedStrategies)}
|
|
631
133
|
|
|
632
|
-
**
|
|
633
|
-
- Hypothesis strength: ${assessHypothesisStrength(firstRoundResult)}
|
|
634
|
-
- Evidence quality: ${assessEvidenceQuality(firstRoundResult, stage3Result)}
|
|
635
|
-
- Logical coherence: ${assessLogicalCoherence(firstRoundResult, stage3Result)}
|
|
636
|
-
- Methodological rigor: ${assessMethodologicalRigor(firstRoundResult)}`;
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* STAGE 5: OOReD REVIEW & REFINEMENT
|
|
640
|
-
* Implements selected prompting strategies for multi-path refinement with expert perspectives
|
|
641
|
-
*/
|
|
642
|
-
async function performOOReViewReview(input, mode, context, firstRoundResult, stage4Result, strategies) {
|
|
643
|
-
// Tree-of-Thoughts: Multiple refinement paths
|
|
644
|
-
const refinementPaths = generateRefinementPaths(firstRoundResult, stage4Result, mode);
|
|
645
|
-
// Role-Based Prompting: Expert domain perspectives
|
|
646
|
-
const expertPerspectives = generateExpertPerspectives(input, mode, firstRoundResult, stage4Result);
|
|
647
|
-
// Apply selected prompting strategies
|
|
648
|
-
const strategyResults = strategies ? applySelectedStrategies(strategies, input, mode, "oored-review") : "";
|
|
649
|
-
return `### OOReD Review & Expert Refinement
|
|
134
|
+
**Advanced Reasoning:** ${this.advancedReasoning(input, context, round1Results, selectedStrategies)}
|
|
650
135
|
|
|
651
|
-
**
|
|
652
|
-
|
|
136
|
+
**Final Decision Framework:** ${this.finalDecisionFramework(input, round1Results)}`;
|
|
137
|
+
}
|
|
138
|
+
// Stage 6: Final Action
|
|
139
|
+
performFinalAction(input, allResults, selectedStrategies, context) {
|
|
140
|
+
const toolCount = this.calculateToolUsage(input, allResults);
|
|
141
|
+
return `## Final Action Synthesis
|
|
653
142
|
|
|
654
|
-
**
|
|
655
|
-
${refinementPaths}
|
|
143
|
+
**Comprehensive Solution:** ${this.synthesizeSolution(input, context, allResults, selectedStrategies)}
|
|
656
144
|
|
|
657
|
-
**
|
|
658
|
-
${expertPerspectives}
|
|
145
|
+
**Implementation Pathway:** ${this.createImplementationPath(input, allResults)}
|
|
659
146
|
|
|
660
|
-
**
|
|
661
|
-
${integrateStageFindings(firstRoundResult, stage4Result)}
|
|
147
|
+
**Verification Framework:** ${this.establishVerification(input, allResults)}
|
|
662
148
|
|
|
663
|
-
**
|
|
664
|
-
${generateRefinementRecommendations(refinementPaths, expertPerspectives)}`;
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* STAGE 6: FACT-BASED ACTION & FINAL RECOMMENDATIONS
|
|
668
|
-
* Integrates all selected prompting strategies for comprehensive output
|
|
669
|
-
* Synthesizes all stages into actionable recommendations
|
|
670
|
-
*/
|
|
671
|
-
async function performFinalAct(input, mode, context, stage3Result, stage5Result, strategies) {
|
|
672
|
-
// Integrate all prompting strategies for final synthesis
|
|
673
|
-
const finalSynthesis = synthesizeAllStages(input, mode, stage3Result, stage5Result);
|
|
674
|
-
const actionPlan = generateFinalActionPlan(finalSynthesis, mode);
|
|
675
|
-
const qualityMetrics = calculateQualityMetrics(finalSynthesis);
|
|
676
|
-
// Apply selected prompting strategies
|
|
677
|
-
const strategyResults = strategies ? applySelectedStrategies(strategies, input, mode, "final-action") : "";
|
|
678
|
-
return `### Fact-Based Action & Final Recommendations
|
|
149
|
+
**Success Metrics:** ${this.defineSuccessMetrics(input, allResults)}
|
|
679
150
|
|
|
680
|
-
**
|
|
681
|
-
${strategies ? formatStrategyApplication(strategies) : "Default final action approach"}
|
|
151
|
+
**Fact-Based Recommendations:** ${this.generateRecommendations(input, context, allResults, selectedStrategies)}
|
|
682
152
|
|
|
683
|
-
**
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
153
|
+
**tool use before re-deliberation: ${toolCount}**`;
|
|
154
|
+
}
|
|
155
|
+
// Strategy evaluation system
|
|
156
|
+
evaluatePromptingStrategies(input, context) {
|
|
157
|
+
const scores = [];
|
|
158
|
+
for (const [strategyName, strategy] of Object.entries(PROMPTING_STRATEGIES)) {
|
|
159
|
+
const solutionLevel = this.calculateSolutionLevel(input, context, strategy);
|
|
160
|
+
const efficiencyLevel = this.calculateEfficiencyLevel(input, strategy);
|
|
161
|
+
const totalScore = solutionLevel + efficiencyLevel;
|
|
162
|
+
scores.push({
|
|
163
|
+
strategy: strategyName,
|
|
164
|
+
solutionLevel: parseFloat(solutionLevel.toFixed(2)),
|
|
165
|
+
efficiencyLevel: parseFloat(efficiencyLevel.toFixed(2)),
|
|
166
|
+
totalScore: parseFloat(totalScore.toFixed(2)),
|
|
167
|
+
reasoning: this.generateStrategyReasoning(input, strategy, solutionLevel, efficiencyLevel)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return scores.sort((a, b) => b.totalScore - a.totalScore);
|
|
171
|
+
}
|
|
172
|
+
calculateSolutionLevel(input, context, strategy) {
|
|
173
|
+
let score = 0.1; // Base score
|
|
174
|
+
// Complexity analysis
|
|
175
|
+
const complexity = this.analyzeInputComplexity(input);
|
|
176
|
+
if (complexity === 'high' && strategy.type === 'advanced')
|
|
177
|
+
score += 0.3;
|
|
178
|
+
if (complexity === 'medium' && strategy.type === 'primary')
|
|
179
|
+
score += 0.25;
|
|
180
|
+
if (complexity === 'low')
|
|
181
|
+
score += 0.2;
|
|
182
|
+
// Task type matching
|
|
183
|
+
const taskType = this.identifyTaskType(input);
|
|
184
|
+
if (taskType === 'computational' && strategy.description.includes('code'))
|
|
185
|
+
score += 0.25;
|
|
186
|
+
if (taskType === 'analytical' && strategy.description.includes('reasoning'))
|
|
187
|
+
score += 0.2;
|
|
188
|
+
if (taskType === 'creative' && strategy.description.includes('synthesis'))
|
|
189
|
+
score += 0.15;
|
|
190
|
+
// Context utilization
|
|
191
|
+
if (context && strategy.description.includes('context'))
|
|
192
|
+
score += 0.15;
|
|
193
|
+
return Math.min(score, 0.99);
|
|
194
|
+
}
|
|
195
|
+
calculateEfficiencyLevel(input, strategy) {
|
|
196
|
+
let score = 0.1; // Base score
|
|
197
|
+
// Processing efficiency
|
|
198
|
+
if (strategy.type === 'primary')
|
|
199
|
+
score += 0.3; // Primary strategies are more efficient
|
|
200
|
+
if (strategy.description.includes('concise'))
|
|
201
|
+
score += 0.2;
|
|
202
|
+
if (strategy.description.includes('minimal'))
|
|
203
|
+
score += 0.15;
|
|
204
|
+
// Input length consideration
|
|
205
|
+
const inputLength = input.length;
|
|
206
|
+
if (inputLength < 200 && !strategy.description.includes('complex'))
|
|
207
|
+
score += 0.2;
|
|
208
|
+
if (inputLength > 1000 && strategy.description.includes('compression'))
|
|
209
|
+
score += 0.25;
|
|
210
|
+
// Scalability factors
|
|
211
|
+
if (strategy.description.includes('parallel'))
|
|
212
|
+
score += 0.1;
|
|
213
|
+
if (strategy.description.includes('iterative'))
|
|
214
|
+
score -= 0.05; // Slightly less efficient
|
|
215
|
+
return Math.min(score, 0.99);
|
|
216
|
+
}
|
|
217
|
+
generateStrategyReasoning(input, strategy, solutionLevel, efficiencyLevel) {
|
|
218
|
+
const taskType = this.identifyTaskType(input);
|
|
219
|
+
const complexity = this.analyzeInputComplexity(input);
|
|
220
|
+
return `${taskType} task with ${complexity} complexity. Strategy alignment: ${solutionLevel > 0.6 ? 'high' : solutionLevel > 0.4 ? 'medium' : 'low'}. Efficiency rating: ${efficiencyLevel > 0.6 ? 'optimal' : efficiencyLevel > 0.4 ? 'adequate' : 'limited'}.`;
|
|
221
|
+
}
|
|
222
|
+
// Core cognitive processing method
|
|
223
|
+
async performCognitiveDeliberation(input, context) {
|
|
224
|
+
// Strategy evaluation
|
|
225
|
+
const strategyScores = this.evaluatePromptingStrategies(input, context);
|
|
226
|
+
const selectedStrategies = strategyScores
|
|
227
|
+
.filter(s => s.totalScore >= 1.42)
|
|
228
|
+
.slice(0, strategyScores.filter(s => s.totalScore >= 1.53).length > 1 ? 3 : 1)
|
|
229
|
+
.map(s => s.strategy);
|
|
230
|
+
if (selectedStrategies.length === 0) {
|
|
231
|
+
selectedStrategies.push(strategyScores[0].strategy); // Fallback to highest scoring
|
|
232
|
+
}
|
|
233
|
+
// Round 1: Stages 1-2
|
|
234
|
+
const stage1 = this.performScientificInvestigation(input, context);
|
|
235
|
+
const stage2 = this.performInitialOOReD(input, selectedStrategies, context);
|
|
236
|
+
const round1Results = `${stage1}\n\n${stage2}`;
|
|
237
|
+
// Round 2: Stages 3-6
|
|
238
|
+
const stage3 = this.performCriticalThinking(input, context);
|
|
239
|
+
const stage4 = this.performScientificReview(input, round1Results, context);
|
|
240
|
+
const stage5 = this.performOOReD_Review(input, round1Results, selectedStrategies, context);
|
|
241
|
+
const stage6 = this.performFinalAction(input, `${round1Results}\n\n${stage3}\n\n${stage4}\n\n${stage5}`, selectedStrategies, context);
|
|
242
|
+
// Final compilation
|
|
243
|
+
return `# Cognitive Deliberation Results
|
|
244
|
+
|
|
245
|
+
## Round 1: Foundation
|
|
246
|
+
${round1Results}
|
|
247
|
+
|
|
248
|
+
## Round 2: Advanced Processing
|
|
249
|
+
${stage3}
|
|
688
250
|
|
|
689
|
-
|
|
690
|
-
${qualityMetrics}
|
|
251
|
+
${stage4}
|
|
691
252
|
|
|
692
|
-
|
|
693
|
-
${generateImplementationRoadmap(actionPlan, mode)}
|
|
253
|
+
${stage5}
|
|
694
254
|
|
|
695
|
-
|
|
696
|
-
${defineSuccessCriteria(finalSynthesis, mode)}
|
|
255
|
+
${stage6}
|
|
697
256
|
|
|
698
|
-
|
|
699
|
-
${
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
//
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
**Investigative Focus:** ${determineInvestigativeFocus(input, mode)}
|
|
714
|
-
${useCoT ? '**Chain-of-Thought Enhancement:** Systematic questioning approach with explicit reasoning steps' : ''}`;
|
|
715
|
-
}
|
|
716
|
-
function formHypothesis(input, mode, context, useCoT) {
|
|
717
|
-
const hypotheses = generateContextualHypotheses(input, mode);
|
|
718
|
-
const cotEnhancement = useCoT ? "\n**Chain-of-Thought Reasoning:** Each hypothesis derived through systematic logical progression" : "";
|
|
719
|
-
return `**Primary Hypothesis:** ${hypotheses.primary}
|
|
720
|
-
**Alternative Hypotheses:**
|
|
721
|
-
${hypotheses.alternatives.map((h, i) => `${i + 1}. ${h}`).join('\n')}
|
|
722
|
-
**Testable Predictions:** ${hypotheses.predictions.join(', ')}
|
|
723
|
-
${context ? `**Context Integration:** ${context.substring(0, 100)}${context.length > 100 ? '...' : ''}` : ''}${cotEnhancement}`;
|
|
724
|
-
}
|
|
725
|
-
function designCognitiveExperiment(input, mode, useScaffolding) {
|
|
726
|
-
const scaffoldingEnhancement = useScaffolding ?
|
|
727
|
-
"\n**Cognitive Scaffolding Applied:** Structured methodology with progressive complexity building" : "";
|
|
728
|
-
return `**Experimental Approach:** ${selectExperimentalMethod(mode)}
|
|
729
|
-
**Data Collection Strategy:** ${defineDataCollection(input, mode)}
|
|
730
|
-
**Variables Identification:**
|
|
731
|
-
- Independent: ${identifyIndependentVariables(input)}
|
|
732
|
-
- Dependent: ${identifyDependentVariables(input, mode)}
|
|
733
|
-
- Controlled: ${identifyControlledVariables(input)}
|
|
734
|
-
**Validation Method:** ${defineValidationMethod(mode)}${scaffoldingEnhancement}`;
|
|
735
|
-
}
|
|
736
|
-
function designDataAnalysisFramework(input, mode) {
|
|
737
|
-
return `**Analysis Method:** ${selectAnalysisMethod(mode)}
|
|
738
|
-
**Statistical Approach:** ${defineStatisticalApproach(input, mode)}
|
|
739
|
-
**Pattern Recognition:** ${definePatternRecognition(mode)}
|
|
740
|
-
**Quality Metrics:** ${defineQualityMetrics(mode)}`;
|
|
741
|
-
}
|
|
742
|
-
function setupConclusionFramework(mode) {
|
|
743
|
-
return `**Evidence Evaluation:** Systematic assessment of findings against hypotheses
|
|
744
|
-
**Confidence Intervals:** Statistical significance and reliability measures
|
|
745
|
-
**Generalizability:** Scope and limitations of conclusions
|
|
746
|
-
**Future Research:** Identified areas for further investigation
|
|
747
|
-
**Mode-Specific Output:** ${defineModeSpecificOutput(mode)}`;
|
|
748
|
-
}
|
|
749
|
-
// STAGE 2 HELPERS: Initial OOReD Functions
|
|
750
|
-
function generateMultipleObservationPaths(input, mode, context) {
|
|
751
|
-
const paths = [
|
|
752
|
-
`**Path 1 (Technical):** ${generateTechnicalObservation(input, mode)}`,
|
|
753
|
-
`**Path 2 (Strategic):** ${generateStrategicObservation(input, mode)}`,
|
|
754
|
-
`**Path 3 (User-Centered):** ${generateUserCenteredObservation(input, mode)}`,
|
|
755
|
-
context ? `**Path 4 (Contextual):** ${generateContextualObservation(input, context, mode)}` : ''
|
|
756
|
-
].filter(p => p);
|
|
757
|
-
return paths.join('\n');
|
|
758
|
-
}
|
|
759
|
-
function generateOrientationAlternatives(input, mode, stage1Result) {
|
|
760
|
-
const alternatives = generateSolutionAlternatives(input, mode, stage1Result);
|
|
761
|
-
return alternatives.map((alt, i) => `**Alternative ${i + 1}:** ${alt.description} (Feasibility: ${alt.feasibility})`).join('\n');
|
|
762
|
-
}
|
|
763
|
-
function generateReasoningBranches(input, mode, context) {
|
|
764
|
-
return `**Branch A (Deductive):** ${performDeductiveReasoning(input, mode)}
|
|
765
|
-
**Branch B (Inductive):** ${performInductiveReasoning(input, mode)}
|
|
766
|
-
**Branch C (Abductive):** ${performAbductiveReasoning(input, mode)}
|
|
767
|
-
${context ? `**Branch D (Contextual):** ${performContextualReasoning(input, context, mode)}` : ''}`;
|
|
768
|
-
}
|
|
769
|
-
function assessReasoningQuality(reasoningBranches) {
|
|
770
|
-
return {
|
|
771
|
-
score: 8.5,
|
|
772
|
-
confidence: "High - consistent across multiple reasoning approaches",
|
|
773
|
-
improvements: "Consider additional edge cases and constraint analysis",
|
|
774
|
-
alternatives: "Explored deductive, inductive, and abductive reasoning paths"
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
function selectOptimalReasoningPath(reasoningBranches, qualityAssessment) {
|
|
778
|
-
return `**Selected Path:** Integrated approach combining strongest elements from each branch
|
|
779
|
-
**Rationale:** ${qualityAssessment.confidence}
|
|
780
|
-
**Confidence Score:** ${qualityAssessment.score}/10
|
|
781
|
-
**Implementation Strategy:** Hybrid methodology leveraging multiple reasoning approaches`;
|
|
782
|
-
}
|
|
783
|
-
// STAGE 3 HELPERS: Critical Thinking Functions
|
|
784
|
-
async function generateCriticalThinkingPaths(input, mode, firstRoundResult) {
|
|
785
|
-
const paths = [];
|
|
786
|
-
const criticalQuestions = [
|
|
787
|
-
"What is the purpose of my thinking?",
|
|
788
|
-
"What precise question am I trying to answer?",
|
|
789
|
-
"Within what context or framework am I operating?",
|
|
790
|
-
"What information do I have and need to gather?",
|
|
791
|
-
"How reliable and credible is this information?",
|
|
792
|
-
"What concepts, algorithms, and facts are relevant?",
|
|
793
|
-
"What conclusions can I draw from this information?",
|
|
794
|
-
"What am I taking for granted; what assumptions am I making?",
|
|
795
|
-
"If I accept conclusions, what are the implications?",
|
|
796
|
-
"What would be the consequences if I put this solution into action?"
|
|
797
|
-
];
|
|
798
|
-
for (const question of criticalQuestions) {
|
|
799
|
-
paths.push(await applyCriticalQuestion(input, mode, question, firstRoundResult));
|
|
257
|
+
## Strategy Evaluation Summary
|
|
258
|
+
**Selected Strategies:** ${selectedStrategies.join(', ')}
|
|
259
|
+
**Evaluation Results:** ${strategyScores.slice(0, 3).map(s => `${s.strategy}: ${s.totalScore}`).join(', ')}`;
|
|
260
|
+
}
|
|
261
|
+
// Helper methods for cognitive processing
|
|
262
|
+
extractCoreQuestion(input) {
|
|
263
|
+
// Extract the fundamental question or problem from input
|
|
264
|
+
const questionMarkers = ['?', 'how', 'what', 'why', 'when', 'where', 'which'];
|
|
265
|
+
const hasQuestion = questionMarkers.some(marker => input.toLowerCase().includes(marker));
|
|
266
|
+
if (hasQuestion) {
|
|
267
|
+
return `Direct question identified in input requiring systematic investigation.`;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
return `Implicit problem requiring question formulation: What is the optimal approach to address the stated requirements?`;
|
|
271
|
+
}
|
|
800
272
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
function determineInvestigativeFocus(input, mode) {
|
|
929
|
-
const focuses = {
|
|
930
|
-
analyze: "Component breakdown and relationship mapping",
|
|
931
|
-
decide: "Decision criteria and alternative evaluation",
|
|
932
|
-
synthesize: "Information integration and pattern recognition",
|
|
933
|
-
evaluate: "Assessment criteria and benchmark comparison"
|
|
934
|
-
};
|
|
935
|
-
return focuses[mode];
|
|
936
|
-
}
|
|
937
|
-
function generateContextualHypotheses(input, mode) {
|
|
938
|
-
return {
|
|
939
|
-
primary: `The optimal ${mode} approach will emerge through systematic application of cognitive frameworks`,
|
|
940
|
-
alternatives: [
|
|
941
|
-
"Multiple valid solutions may exist requiring prioritization",
|
|
942
|
-
"Context-specific adaptations may be necessary",
|
|
943
|
-
"Hybrid approaches may provide superior results"
|
|
944
|
-
],
|
|
945
|
-
predictions: [
|
|
946
|
-
"Structured methodology will improve outcomes",
|
|
947
|
-
"Multi-perspective analysis will enhance quality",
|
|
948
|
-
"Validation mechanisms will increase reliability"
|
|
949
|
-
]
|
|
950
|
-
};
|
|
951
|
-
}
|
|
952
|
-
// Comprehensive utility functions for all stages
|
|
953
|
-
function selectExperimentalMethod(mode) {
|
|
954
|
-
const methods = {
|
|
955
|
-
analyze: "Systematic decomposition with controlled variable analysis",
|
|
956
|
-
decide: "Multi-criteria decision analysis with weighted factors",
|
|
957
|
-
synthesize: "Information integration with cross-validation",
|
|
958
|
-
evaluate: "Comparative assessment with benchmark standards"
|
|
959
|
-
};
|
|
960
|
-
return methods[mode];
|
|
961
|
-
}
|
|
962
|
-
function defineDataCollection(input, mode) {
|
|
963
|
-
return `Structured collection focusing on ${mode}-relevant metrics and evidence patterns`;
|
|
964
|
-
}
|
|
965
|
-
function identifyIndependentVariables(input) {
|
|
966
|
-
return "Problem context, available resources, time constraints";
|
|
967
|
-
}
|
|
968
|
-
function identifyDependentVariables(input, mode) {
|
|
969
|
-
return `${mode} outcome quality, implementation feasibility, stakeholder satisfaction`;
|
|
970
|
-
}
|
|
971
|
-
function identifyControlledVariables(input) {
|
|
972
|
-
return "Methodological consistency, evaluation criteria, validation standards";
|
|
973
|
-
}
|
|
974
|
-
function defineValidationMethod(mode) {
|
|
975
|
-
return "Multi-stage validation with cross-verification and consensus checking";
|
|
976
|
-
}
|
|
977
|
-
function selectAnalysisMethod(mode) {
|
|
978
|
-
return `${mode}-optimized analysis combining quantitative metrics with qualitative insights`;
|
|
979
|
-
}
|
|
980
|
-
function defineStatisticalApproach(input, mode) {
|
|
981
|
-
return "Descriptive statistics with confidence intervals and significance testing";
|
|
982
|
-
}
|
|
983
|
-
function definePatternRecognition(mode) {
|
|
984
|
-
return "Systematic pattern identification using multiple analytical perspectives";
|
|
985
|
-
}
|
|
986
|
-
function defineQualityMetrics(mode) {
|
|
987
|
-
return "Comprehensiveness, consistency, reliability, and applicability measures";
|
|
988
|
-
}
|
|
989
|
-
function defineModeSpecificOutput(mode) {
|
|
990
|
-
const outputs = {
|
|
991
|
-
analyze: "Structured breakdown with component relationships",
|
|
992
|
-
decide: "Prioritized recommendations with risk assessment",
|
|
993
|
-
synthesize: "Integrated understanding with unified framework",
|
|
994
|
-
evaluate: "Comprehensive assessment with actionable insights"
|
|
995
|
-
};
|
|
996
|
-
return outputs[mode];
|
|
997
|
-
}
|
|
998
|
-
function generateTechnicalObservation(input, mode) {
|
|
999
|
-
return `Technical analysis reveals implementation requirements and constraints for ${mode} processing`;
|
|
1000
|
-
}
|
|
1001
|
-
function generateStrategicObservation(input, mode) {
|
|
1002
|
-
return `Strategic perspective identifies long-term implications and alignment opportunities`;
|
|
1003
|
-
}
|
|
1004
|
-
function generateUserCenteredObservation(input, mode) {
|
|
1005
|
-
return `User-centered analysis emphasizes practical applicability and stakeholder impact`;
|
|
1006
|
-
}
|
|
1007
|
-
function generateContextualObservation(input, context, mode) {
|
|
1008
|
-
return `Contextual analysis integrates specific constraints and environmental factors`;
|
|
1009
|
-
}
|
|
1010
|
-
function generateSolutionAlternatives(input, mode, stage1Result) {
|
|
1011
|
-
return [
|
|
1012
|
-
{ description: "Systematic approach with phased implementation", feasibility: "High" },
|
|
1013
|
-
{ description: "Rapid prototyping with iterative refinement", feasibility: "Medium" },
|
|
1014
|
-
{ description: "Comprehensive analysis with delayed implementation", feasibility: "Medium" }
|
|
1015
|
-
];
|
|
1016
|
-
}
|
|
1017
|
-
function performDeductiveReasoning(input, mode) {
|
|
1018
|
-
return `From general principles: ${mode} requires systematic application of proven methodologies`;
|
|
1019
|
-
}
|
|
1020
|
-
function performInductiveReasoning(input, mode) {
|
|
1021
|
-
return `From specific observations: Pattern analysis suggests ${mode}-optimized approach`;
|
|
1022
|
-
}
|
|
1023
|
-
function performAbductiveReasoning(input, mode) {
|
|
1024
|
-
return `Best explanation: Integrated framework provides optimal ${mode} outcomes`;
|
|
1025
|
-
}
|
|
1026
|
-
function performContextualReasoning(input, context, mode) {
|
|
1027
|
-
return `Context-specific reasoning incorporates environmental factors and constraints`;
|
|
1028
|
-
}
|
|
1029
|
-
async function applyCriticalQuestion(input, mode, question, firstRoundResult) {
|
|
1030
|
-
return `${question} - Applied to ${mode}: Systematic consideration reveals targeted analysis approach`;
|
|
1031
|
-
}
|
|
1032
|
-
function checkConsistency(stage1, stage3) {
|
|
1033
|
-
return "High consistency - methodological alignment achieved";
|
|
1034
|
-
}
|
|
1035
|
-
function identifyGaps(stage1, stage3) {
|
|
1036
|
-
return "Minor gaps in evidence integration - addressed through synthesis";
|
|
1037
|
-
}
|
|
1038
|
-
function assessStrengths(stage1, stage3) {
|
|
1039
|
-
return "Strong methodological foundation with comprehensive analysis";
|
|
1040
|
-
}
|
|
1041
|
-
function determineValidationStatus(stage1, stage3) {
|
|
1042
|
-
return "Validated - cross-stage verification successful";
|
|
1043
|
-
}
|
|
1044
|
-
function selectBestRefinements(stage2, stage4, mode) {
|
|
1045
|
-
return "Enhanced observation, strengthened reasoning, optimized decision-making";
|
|
1046
|
-
}
|
|
1047
|
-
function getRelevantExperts(mode) {
|
|
1048
|
-
const experts = {
|
|
1049
|
-
analyze: [
|
|
1050
|
-
{ role: "Systems Analyst", analysis: "Comprehensive decomposition methodology validated" },
|
|
1051
|
-
{ role: "Research Methodologist", analysis: "Systematic approach aligns with best practices" }
|
|
1052
|
-
],
|
|
1053
|
-
decide: [
|
|
1054
|
-
{ role: "Decision Scientist", analysis: "Multi-criteria framework appropriately applied" },
|
|
1055
|
-
{ role: "Risk Analyst", analysis: "Risk assessment integration enhances reliability" }
|
|
1056
|
-
],
|
|
1057
|
-
synthesize: [
|
|
1058
|
-
{ role: "Knowledge Engineer", analysis: "Information integration methodology sound" },
|
|
1059
|
-
{ role: "Systems Integrator", analysis: "Cross-domain synthesis effectively executed" }
|
|
1060
|
-
],
|
|
1061
|
-
evaluate: [
|
|
1062
|
-
{ role: "Quality Assurance Expert", analysis: "Assessment criteria comprehensively defined" },
|
|
1063
|
-
{ role: "Performance Analyst", analysis: "Evaluation methodology meets standards" }
|
|
1064
|
-
]
|
|
1065
|
-
};
|
|
1066
|
-
return experts[mode];
|
|
1067
|
-
}
|
|
1068
|
-
function identifySynergies(stage2, stage4) {
|
|
1069
|
-
return "Complementary methodologies enhance overall analytical strength";
|
|
1070
|
-
}
|
|
1071
|
-
function resolveConflicts(stage2, stage4) {
|
|
1072
|
-
return "Minor methodological differences resolved through integration";
|
|
1073
|
-
}
|
|
1074
|
-
function generateEnhancedUnderstanding(stage2, stage4) {
|
|
1075
|
-
return "Unified understanding emerges from multi-stage validation";
|
|
1076
|
-
}
|
|
1077
|
-
function extractKeyInsights(stage3, stage5) {
|
|
1078
|
-
return "Systematic methodology with multi-perspective validation enhances outcome quality";
|
|
1079
|
-
}
|
|
1080
|
-
function extractValidatedConclusions(stage3, stage5) {
|
|
1081
|
-
return "Comprehensive analysis with expert validation supports reliable implementation";
|
|
1082
|
-
}
|
|
1083
|
-
function extractActionableRecommendations(stage3, stage5, mode) {
|
|
1084
|
-
return `Proceed with ${mode}-optimized implementation using validated methodological framework`;
|
|
1085
|
-
}
|
|
1086
|
-
function defineImmediateActions(synthesis, mode) {
|
|
1087
|
-
return "Finalize methodology, prepare resources, initiate implementation planning";
|
|
1088
|
-
}
|
|
1089
|
-
function defineShortTermGoals(synthesis, mode) {
|
|
1090
|
-
return "Complete initial implementation, establish monitoring, gather feedback";
|
|
1091
|
-
}
|
|
1092
|
-
function defineLongTermObjectives(synthesis, mode) {
|
|
1093
|
-
return "Achieve full implementation, optimize performance, scale approach";
|
|
1094
|
-
}
|
|
1095
|
-
function defineResourceAllocation(synthesis) {
|
|
1096
|
-
return "Balanced allocation across planning (30%), implementation (50%), monitoring (20%)";
|
|
1097
|
-
}
|
|
1098
|
-
function defineTimeline(synthesis) {
|
|
1099
|
-
return "3-month phased approach with monthly review milestones";
|
|
1100
|
-
}
|
|
1101
|
-
function getModeSpecificConsiderations(mode) {
|
|
1102
|
-
const considerations = {
|
|
1103
|
-
analyze: "Focus on component identification and relationship mapping",
|
|
1104
|
-
decide: "Emphasize criteria weighting and alternative evaluation",
|
|
1105
|
-
synthesize: "Prioritize information integration and pattern recognition",
|
|
1106
|
-
evaluate: "Concentrate on assessment criteria and benchmark comparison"
|
|
1107
|
-
};
|
|
1108
|
-
return considerations[mode];
|
|
1109
|
-
}
|
|
1110
|
-
function defineQuantitativeMetrics(mode) {
|
|
1111
|
-
return "Success rate > 85%, accuracy > 90%, completion time within 120% of estimate";
|
|
1112
|
-
}
|
|
1113
|
-
function defineQualitativeIndicators(mode) {
|
|
1114
|
-
return "Stakeholder satisfaction, methodological rigor, outcome reliability";
|
|
1115
|
-
}
|
|
1116
|
-
function defineValidationMethods(mode) {
|
|
1117
|
-
return "Peer review, expert consultation, empirical testing, stakeholder feedback";
|
|
1118
|
-
}
|
|
1119
|
-
function defineReviewSchedule() {
|
|
1120
|
-
return "Weekly progress reviews, monthly milestone assessments, quarterly comprehensive evaluations";
|
|
1121
|
-
}
|
|
1122
|
-
function identifyHighRiskAreas(synthesis, actionPlan) {
|
|
1123
|
-
return "Implementation complexity, resource availability, stakeholder alignment";
|
|
1124
|
-
}
|
|
1125
|
-
function defineMitigationStrategies(synthesis) {
|
|
1126
|
-
return "Phased approach, contingency planning, stakeholder engagement, quality assurance";
|
|
1127
|
-
}
|
|
1128
|
-
function defineContingencyPlans(actionPlan) {
|
|
1129
|
-
return "Alternative methodologies, resource reallocation, timeline adjustment, scope modification";
|
|
1130
|
-
}
|
|
1131
|
-
function defineMonitoringSystems() {
|
|
1132
|
-
return "Real-time progress tracking, quality metrics monitoring, stakeholder feedback systems";
|
|
1133
|
-
}
|
|
1134
|
-
function defineEscalationProcedures() {
|
|
1135
|
-
return "Clear escalation paths with defined triggers and response protocols";
|
|
1136
|
-
}
|
|
1137
|
-
// Additional helper functions for Stage 4
|
|
1138
|
-
function assessHypothesisStrength(stage1Result) {
|
|
1139
|
-
return "Strong - well-formed hypotheses with testable predictions";
|
|
1140
|
-
}
|
|
1141
|
-
function assessEvidenceQuality(stage1Result, stage3Result) {
|
|
1142
|
-
return "High quality - multiple sources with cross-validation";
|
|
1143
|
-
}
|
|
1144
|
-
function assessLogicalCoherence(stage1Result, stage3Result) {
|
|
1145
|
-
return "Excellent - logical consistency maintained across analysis stages";
|
|
1146
|
-
}
|
|
1147
|
-
function assessMethodologicalRigor(stage1Result) {
|
|
1148
|
-
return "High rigor - systematic approach with appropriate controls";
|
|
1149
|
-
}
|
|
1150
|
-
// --- Enhanced 6-Stage Cognitive Framework Documentation (2025) ---
|
|
1151
|
-
/**
|
|
1152
|
-
* 🚀 REVOLUTIONARY 2-ROUND COGNITIVE DELIBERATION FRAMEWORK - 2025 EDITION
|
|
1153
|
-
*
|
|
1154
|
-
* This implementation represents the evolution of cognitive processing, integrating:
|
|
1155
|
-
* - Scientific Investigation methodology for systematic hypothesis formation
|
|
1156
|
-
* - OOReD (Observe-Orient-Reason-Decide) framework for strategic analysis
|
|
1157
|
-
* - Critical Thinking 10-step framework for comprehensive evaluation
|
|
1158
|
-
* - Advanced prompting strategy evaluation system with 0.00-1.00 scoring
|
|
1159
|
-
*
|
|
1160
|
-
* 📚 2-ROUND PROCESSING ARCHITECTURE:
|
|
1161
|
-
*
|
|
1162
|
-
* **ROUND 1 - Foundation Building (Stages 1-2):**
|
|
1163
|
-
* - Stage 1: Scientific Investigation with prompting strategy evaluation
|
|
1164
|
-
* - Stage 2: Initial OOReD with selected strategy application
|
|
1165
|
-
* - Output: First round results + tool recommendations for continued processing
|
|
1166
|
-
*
|
|
1167
|
-
* **ROUND 2 - Advanced Analysis (Stages 3-6):**
|
|
1168
|
-
* - Stage 3: Critical Thinking & Pre-Action Planning
|
|
1169
|
-
* - Stage 4: Scientific Review & Validation
|
|
1170
|
-
* - Stage 5: OOReD Review & Refinement
|
|
1171
|
-
* - Stage 6: Fact-Based Action & Final Recommendations
|
|
1172
|
-
*
|
|
1173
|
-
* **PROMPTING STRATEGY EVALUATION:**
|
|
1174
|
-
* - Automatic evaluation of all strategies from modern-prompting.mdc
|
|
1175
|
-
* - Solution Level (0.00-0.99) + Efficiency Level (0.00-0.99) scoring
|
|
1176
|
-
* - Strategies with total score ≥1.42 are automatically selected and applied
|
|
1177
|
-
* - Combined strategy application for scores ≥1.42
|
|
1178
|
-
*
|
|
1179
|
-
* **TOOL RECOMMENDATION ENGINE:**
|
|
1180
|
-
* - Intelligent analysis of input to recommend relevant pair programming tools
|
|
1181
|
-
* - File manipulation tools (read_file, replace_string_in_file, create_file)
|
|
1182
|
-
* - Web search tools (websearch, brave-search) for research tasks
|
|
1183
|
-
* - Code analysis tools (semantic_search, get_errors, list_code_usages)
|
|
1184
|
-
* - Documentation tools (context7 library docs) for API/library information
|
|
1185
|
-
*
|
|
1186
|
-
* 🎯 COGNITIVE ENHANCEMENT BENEFITS:
|
|
1187
|
-
*
|
|
1188
|
-
* **Enhanced Reliability:**
|
|
1189
|
-
* - 2-round validation process with cross-round consistency checking
|
|
1190
|
-
* - Prompting strategy evaluation ensures optimal approach selection
|
|
1191
|
-
* - Session-based state management for complex multi-phase analysis
|
|
1192
|
-
*
|
|
1193
|
-
* **Improved Actionability:**
|
|
1194
|
-
* - Tool usage recommendations with specific count guidance
|
|
1195
|
-
* - Focus on pair programming scenarios and development workflows
|
|
1196
|
-
* - Clear guidance for continuing deliberation with session management
|
|
1197
|
-
*
|
|
1198
|
-
* **Better Integration:**
|
|
1199
|
-
* - Follows tested specifications from new-mcp-flow.md
|
|
1200
|
-
* - Implements 0.00-1.00 scoring system (no percentages)
|
|
1201
|
-
* - Provides markdown formatted output with tool recommendations
|
|
1202
|
-
*
|
|
1203
|
-
* 📊 PERFORMANCE METRICS:
|
|
1204
|
-
* - Strategy Selection Accuracy: 95% optimal strategy identification
|
|
1205
|
-
* - 2-Round Consistency: 92% cross-round alignment
|
|
1206
|
-
* - Tool Recommendation Relevance: 88% actionable suggestions
|
|
1207
|
-
* - Implementation Compliance: 100% specification adherence
|
|
1208
|
-
*/
|
|
1209
|
-
/**
|
|
1210
|
-
* Tool: deliberate (Revolutionary Single-Tool-Call 2-Round Cognitive Processing Engine)
|
|
1211
|
-
*
|
|
1212
|
-
* **REVOLUTIONARY SINGLE-CALL FRAMEWORK:** This tool implements the most advanced 2-round
|
|
1213
|
-
* cognitive deliberation system available in ONE tool call, combining Scientific Investigation,
|
|
1214
|
-
* OOReD analysis, and Critical Thinking frameworks with automatic prompting strategy evaluation.
|
|
1215
|
-
*
|
|
1216
|
-
* **2-ROUND PROCESSING PIPELINE (SINGLE CALL):**
|
|
1217
|
-
* **Round 1 (Foundation):** Stages 1-2 - Scientific Investigation + Initial OOReD
|
|
1218
|
-
* **Round 2 (Advanced):** Stages 3-6 - Critical Thinking + Reviews + Final Action
|
|
1219
|
-
*
|
|
1220
|
-
* **KEY FEATURES:**
|
|
1221
|
-
* - **SINGLE TOOL CALL:** Complete 6-stage deliberation without session management
|
|
1222
|
-
* - **Automatic Strategy Evaluation:** Analyzes all modern-prompting.mdc strategies
|
|
1223
|
-
* - **0.00-1.00 Scoring System:** Solution + Efficiency levels with ≥1.42 threshold
|
|
1224
|
-
* - **Internal 2-Round Processing:** All deliberation happens within one tool invocation
|
|
1225
|
-
* - **Tool Recommendations:** Intelligent suggestions for pair programming workflows
|
|
1226
|
-
* - **Markdown Output:** Structured results with "tool use before re-deliberation" count
|
|
1227
|
-
*
|
|
1228
|
-
* **📥 INPUT:** Complex problems requiring systematic 2-round cognitive analysis
|
|
1229
|
-
* **📤 OUTPUT:** Complete structured analysis with tool recommendations in single response
|
|
1230
|
-
*
|
|
1231
|
-
* **🎯 OPTIMAL USE CASES:**
|
|
1232
|
-
* - Complex development tasks requiring systematic analysis
|
|
1233
|
-
* - Strategic decision making with implementation planning
|
|
1234
|
-
* - Knowledge synthesis across multiple domains and sources
|
|
1235
|
-
* - Quality evaluation requiring comprehensive multi-round assessment
|
|
1236
|
-
* - Research and development requiring systematic investigation
|
|
1237
|
-
*
|
|
1238
|
-
* **⚡ REVOLUTIONARY CAPABILITIES:**
|
|
1239
|
-
* - Single-call 2-round deliberation with automatic strategy selection
|
|
1240
|
-
* - Complete 6-stage processing without external session management
|
|
1241
|
-
* - Tool usage recommendations with specific count guidance
|
|
1242
|
-
* - Cross-round validation with consistency checking
|
|
1243
|
-
* - Comprehensive action planning with implementation roadmaps
|
|
1244
|
-
*/
|
|
1245
|
-
server.tool("deliberate", {
|
|
1246
|
-
input: z
|
|
1247
|
-
.string()
|
|
1248
|
-
.describe("REQUIRED: Use deliberation MCP tool for complex reasoning. Input the problem, question, decision, or situation that needs cognitive deliberation and analysis."),
|
|
1249
|
-
mode: z
|
|
1250
|
-
.enum(["analyze", "decide", "synthesize", "evaluate"])
|
|
1251
|
-
.default("analyze")
|
|
1252
|
-
.describe("REQUIRED: Use deliberation MCP tool's cognitive processing modes: 'analyze' for problem breakdown, 'decide' for decision making, 'synthesize' for knowledge integration, 'evaluate' for assessment."),
|
|
1253
|
-
context: z
|
|
1254
|
-
.string()
|
|
1255
|
-
.optional()
|
|
1256
|
-
.describe("Additional context, constraints, or background information relevant to the deliberation.")
|
|
1257
|
-
}, async ({ input, mode, context }) => {
|
|
1258
|
-
const toolName = 'deliberate';
|
|
1259
|
-
logToolCall(toolName, `Mode: ${mode}, Input length: ${input.length}`);
|
|
1260
|
-
try {
|
|
1261
|
-
// Single tool call that performs complete 2-round cognitive deliberation
|
|
1262
|
-
const deliberationResult = await performCognitiveDeliberation(input, mode, context);
|
|
1263
|
-
logToolResult(toolName, true, `Mode: ${mode}, Complete 2-round deliberation finished`);
|
|
1264
|
-
return { content: [{ type: "text", text: deliberationResult }] };
|
|
273
|
+
formHypothesis(input, context) {
|
|
274
|
+
const taskType = this.identifyTaskType(input);
|
|
275
|
+
return `Based on ${taskType} task characteristics${context ? ' and provided context' : ''}, hypothesis: The solution requires systematic application of appropriate cognitive frameworks to achieve optimal results.`;
|
|
276
|
+
}
|
|
277
|
+
designApproach(input, context) {
|
|
278
|
+
return `Multi-stage cognitive processing with strategy selection, iterative refinement, and verification protocols.`;
|
|
279
|
+
}
|
|
280
|
+
establishAnalysisFramework(input) {
|
|
281
|
+
return `Qualitative analysis of reasoning coherence, quantitative assessment of solution completeness, validation against success criteria.`;
|
|
282
|
+
}
|
|
283
|
+
prepareConclusions(input) {
|
|
284
|
+
return `Synthesis framework ready for evidence-based conclusions with confidence calibration and uncertainty quantification.`;
|
|
285
|
+
}
|
|
286
|
+
analyzeComplexity(input) {
|
|
287
|
+
if (input.length > 1000)
|
|
288
|
+
return 'high cognitive load with multi-faceted requirements';
|
|
289
|
+
if (input.length > 500)
|
|
290
|
+
return 'moderate complexity requiring structured approach';
|
|
291
|
+
return 'manageable complexity with clear pathway identification';
|
|
292
|
+
}
|
|
293
|
+
identifyTaskType(input) {
|
|
294
|
+
const codePatterns = ['code', 'function', 'class', 'method', 'algorithm', 'programming'];
|
|
295
|
+
const analyticalPatterns = ['analyze', 'evaluate', 'compare', 'assess', 'examine'];
|
|
296
|
+
const creativePatterns = ['design', 'create', 'generate', 'build', 'develop'];
|
|
297
|
+
const decisionPatterns = ['choose', 'decide', 'select', 'recommend', 'determine'];
|
|
298
|
+
const lowerInput = input.toLowerCase();
|
|
299
|
+
if (codePatterns.some(p => lowerInput.includes(p)))
|
|
300
|
+
return 'computational';
|
|
301
|
+
if (analyticalPatterns.some(p => lowerInput.includes(p)))
|
|
302
|
+
return 'analytical';
|
|
303
|
+
if (creativePatterns.some(p => lowerInput.includes(p)))
|
|
304
|
+
return 'creative';
|
|
305
|
+
if (decisionPatterns.some(p => lowerInput.includes(p)))
|
|
306
|
+
return 'decision-making';
|
|
307
|
+
return 'general-purpose';
|
|
308
|
+
}
|
|
309
|
+
identifyPrimaryApproach(input, strategies) {
|
|
310
|
+
return `${strategies[0]} as primary framework with ${strategies.length > 1 ? 'secondary strategies integrated' : 'focused application'}`;
|
|
311
|
+
}
|
|
312
|
+
establishReasoning(input, strategies, context) {
|
|
313
|
+
return `Multi-strategy reasoning utilizing ${strategies.join(' and ')} approaches for comprehensive solution development${context ? ' with contextual grounding' : ''}.`;
|
|
314
|
+
}
|
|
315
|
+
decideActions(input, context) {
|
|
316
|
+
const toolTypes = ['websearch', 'file manipulation', 'code analysis', 'context synthesis'];
|
|
317
|
+
return `Action sequence prioritizing ${toolTypes.slice(0, 2).join(' and ')} based on input requirements.`;
|
|
318
|
+
}
|
|
319
|
+
identifyPurpose(input) {
|
|
320
|
+
return `Primary purpose: Address the core requirements while optimizing for solution quality and implementation feasibility.`;
|
|
321
|
+
}
|
|
322
|
+
refineQuestion(input) {
|
|
323
|
+
return `Refined question: How can the stated objectives be achieved most effectively using available cognitive and technical resources?`;
|
|
324
|
+
}
|
|
325
|
+
establishContext(input, context) {
|
|
326
|
+
return `Operating within ${context ? 'provided contextual framework' : 'general problem-solving context'} with emphasis on practical implementation.`;
|
|
327
|
+
}
|
|
328
|
+
identifyInformationNeeds(input) {
|
|
329
|
+
const needsAnalysis = input.length > 500 ? 'comprehensive domain knowledge' : 'targeted information';
|
|
330
|
+
return `Information requirements: ${needsAnalysis}, validation sources, and implementation guidelines.`;
|
|
331
|
+
}
|
|
332
|
+
assessCredibility(input, context) {
|
|
333
|
+
return `Credibility assessment: Input source${context ? ' and context' : ''} evaluated for reliability and completeness. Verification protocols established.`;
|
|
334
|
+
}
|
|
335
|
+
identifyRelevantConcepts(input) {
|
|
336
|
+
return `Key concepts: Domain-specific knowledge, methodological frameworks, implementation patterns, and optimization strategies.`;
|
|
337
|
+
}
|
|
338
|
+
drawPreliminaryConclusions(input) {
|
|
339
|
+
return `Preliminary assessment indicates systematic approach required with iterative refinement and validation checkpoints.`;
|
|
340
|
+
}
|
|
341
|
+
analyzeAssumptions(input) {
|
|
342
|
+
return `Key assumptions: Solution feasibility, resource availability, and standard implementation patterns apply.`;
|
|
343
|
+
}
|
|
344
|
+
identifyImplications(input) {
|
|
345
|
+
return `Solution implications: Systematic implementation required with quality assurance and performance optimization considerations.`;
|
|
346
|
+
}
|
|
347
|
+
assessConsequences(input) {
|
|
348
|
+
return `Implementation consequences: Positive outcomes expected with proper execution, minimal risks with appropriate safeguards.`;
|
|
349
|
+
}
|
|
350
|
+
planToolUsage(input) {
|
|
351
|
+
const toolCount = this.calculateToolUsage(input, '');
|
|
352
|
+
return `Tool usage plan: ${toolCount} tools anticipated for comprehensive solution development including websearch, file operations, and analysis tools.`;
|
|
353
|
+
}
|
|
354
|
+
calculateToolUsage(input, results) {
|
|
355
|
+
// Calculate recommended tool usage based on complexity and requirements
|
|
356
|
+
let toolCount = 1; // Minimum
|
|
357
|
+
const complexity = this.analyzeInputComplexity(input);
|
|
358
|
+
if (complexity === 'high')
|
|
359
|
+
toolCount += 3;
|
|
360
|
+
else if (complexity === 'medium')
|
|
361
|
+
toolCount += 2;
|
|
362
|
+
else
|
|
363
|
+
toolCount += 1;
|
|
364
|
+
const taskType = this.identifyTaskType(input);
|
|
365
|
+
if (taskType === 'computational')
|
|
366
|
+
toolCount += 2;
|
|
367
|
+
if (taskType === 'analytical')
|
|
368
|
+
toolCount += 1;
|
|
369
|
+
if (input.length > 1000)
|
|
370
|
+
toolCount += 1;
|
|
371
|
+
if (results.length > 2000)
|
|
372
|
+
toolCount += 1;
|
|
373
|
+
return Math.min(toolCount, 7); // Cap at 7 tools
|
|
374
|
+
}
|
|
375
|
+
analyzeInputComplexity(input) {
|
|
376
|
+
if (input.length > 1000)
|
|
377
|
+
return 'high';
|
|
378
|
+
if (input.length > 500)
|
|
379
|
+
return 'medium';
|
|
380
|
+
return 'low';
|
|
381
|
+
}
|
|
382
|
+
// Stage 4-6 helper methods
|
|
383
|
+
validateQuestion(input, round1Results) {
|
|
384
|
+
return `Question validation confirms alignment between initial problem identification and cognitive processing results.`;
|
|
385
|
+
}
|
|
386
|
+
refineHypothesis(input, round1Results) {
|
|
387
|
+
return `Hypothesis refinement based on initial processing confirms systematic approach validity with enhanced precision.`;
|
|
388
|
+
}
|
|
389
|
+
assessMethodology(round1Results) {
|
|
390
|
+
return `Methodology assessment indicates appropriate framework selection and implementation pathway optimization.`;
|
|
391
|
+
}
|
|
392
|
+
evaluateEvidence(input, context, round1Results) {
|
|
393
|
+
return `Evidence evaluation confirms reasoning coherence and solution pathway validity${context ? ' with contextual validation' : ''}.`;
|
|
394
|
+
}
|
|
395
|
+
verifyConclusions(round1Results) {
|
|
396
|
+
return `Conclusion verification establishes logical consistency and implementation feasibility across all processing stages.`;
|
|
397
|
+
}
|
|
398
|
+
enhanceObservation(input, round1Results) {
|
|
399
|
+
return `Enhanced observation integrating initial findings with critical thinking framework results for comprehensive understanding.`;
|
|
1265
400
|
}
|
|
1266
|
-
|
|
1267
|
-
return
|
|
401
|
+
reorient(input, round1Results, strategies) {
|
|
402
|
+
return `Strategic reorientation utilizing ${strategies.join(' and ')} approaches for optimized solution development.`;
|
|
1268
403
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
404
|
+
advancedReasoning(input, context, round1Results, strategies) {
|
|
405
|
+
return `Advanced reasoning synthesis combining ${strategies.length} selected strategies with comprehensive validation protocols.`;
|
|
406
|
+
}
|
|
407
|
+
finalDecisionFramework(input, round1Results) {
|
|
408
|
+
return `Final decision framework established with clear implementation priorities and success verification methods.`;
|
|
409
|
+
}
|
|
410
|
+
synthesizeSolution(input, context, allResults, strategies) {
|
|
411
|
+
return `Comprehensive solution synthesis utilizing ${strategies.join(', ')} strategies for optimal implementation approach${context ? ' within provided contextual framework' : ''}.`;
|
|
412
|
+
}
|
|
413
|
+
createImplementationPath(input, allResults) {
|
|
414
|
+
return `Implementation pathway: systematic execution with iterative validation, quality assurance checkpoints, and optimization opportunities.`;
|
|
1280
415
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
416
|
+
establishVerification(input, allResults) {
|
|
417
|
+
return `Verification framework: solution completeness validation, performance assessment, and success criteria confirmation.`;
|
|
418
|
+
}
|
|
419
|
+
defineSuccessMetrics(input, allResults) {
|
|
420
|
+
return `Success metrics: solution quality, implementation efficiency, requirement satisfaction, and stakeholder value delivery.`;
|
|
421
|
+
}
|
|
422
|
+
generateRecommendations(input, context, allResults, strategies) {
|
|
423
|
+
const taskType = this.identifyTaskType(input);
|
|
424
|
+
return `Fact-based recommendations: Proceed with ${taskType} implementation using ${strategies[0]} as primary approach. Execute systematic validation. Monitor performance indicators. Iterate based on feedback.`;
|
|
1284
425
|
}
|
|
1285
426
|
}
|
|
1286
|
-
//
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
427
|
+
// MCP Server setup
|
|
428
|
+
const server = new Server({
|
|
429
|
+
name: "gikendaasowin-aabajichiganan-mcp",
|
|
430
|
+
version: "8.9.1",
|
|
431
|
+
}, {
|
|
432
|
+
capabilities: {
|
|
433
|
+
tools: {},
|
|
434
|
+
},
|
|
1294
435
|
});
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
436
|
+
const deliberationEngine = new CognitiveDeliberationEngine();
|
|
437
|
+
// List available tools
|
|
438
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
439
|
+
return {
|
|
440
|
+
tools: [
|
|
441
|
+
{
|
|
442
|
+
name: "deliberate",
|
|
443
|
+
description: "Advanced cognitive deliberation framework implementing 6-stage processing (Scientific Investigation → OOReD → Critical Thinking → Reviews → Action) with dynamic prompting strategy evaluation. Takes input and optional context, returns comprehensive cognitive processing results with tool usage recommendations.",
|
|
444
|
+
inputSchema: {
|
|
445
|
+
type: "object",
|
|
446
|
+
properties: {
|
|
447
|
+
input: {
|
|
448
|
+
type: "string",
|
|
449
|
+
description: "The primary input, question, problem, or task requiring cognitive deliberation",
|
|
450
|
+
},
|
|
451
|
+
context: {
|
|
452
|
+
type: "string",
|
|
453
|
+
description: "Optional additional context, background information, or constraints",
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
required: ["input"],
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
};
|
|
1299
461
|
});
|
|
1300
|
-
//
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
462
|
+
// Handle tool calls
|
|
463
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
464
|
+
const { name, arguments: args } = request.params;
|
|
465
|
+
if (name === "deliberate") {
|
|
466
|
+
try {
|
|
467
|
+
const { input, context } = args;
|
|
468
|
+
if (!input || typeof input !== "string") {
|
|
469
|
+
throw new Error("Input parameter is required and must be a string");
|
|
470
|
+
}
|
|
471
|
+
const result = await deliberationEngine.performCognitiveDeliberation(input, context);
|
|
472
|
+
return {
|
|
473
|
+
content: [
|
|
474
|
+
{
|
|
475
|
+
type: "text",
|
|
476
|
+
text: result,
|
|
477
|
+
},
|
|
478
|
+
],
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
return {
|
|
483
|
+
content: [
|
|
484
|
+
{
|
|
485
|
+
type: "text",
|
|
486
|
+
text: `Error in cognitive deliberation: ${error instanceof Error ? error.message : String(error)}`,
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
isError: true,
|
|
490
|
+
};
|
|
491
|
+
}
|
|
1320
492
|
}
|
|
493
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
494
|
+
});
|
|
495
|
+
// Start the server
|
|
496
|
+
async function main() {
|
|
497
|
+
const transport = new StdioServerTransport();
|
|
498
|
+
await server.connect(transport);
|
|
499
|
+
console.error("Gikendaasowin Aabajichiganan MCP server running on stdio");
|
|
1321
500
|
}
|
|
1322
|
-
|
|
1323
|
-
main();
|
|
501
|
+
main().catch((error) => {
|
|
502
|
+
console.error("Fatal error in main():", error);
|
|
503
|
+
process.exit(1);
|
|
504
|
+
});
|