@nbiish/cognitive-tools-mcp 0.6.2 → 0.7.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 CHANGED
@@ -1,6 +1,24 @@
1
1
  # @nbiish/gikendaasowin-aabajichiganan-mcp
2
2
 
3
- ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.6.1): Provides a suite of advanced internal reasoning tools to guide an LLM agent in sophisticated problem-solving, emphasizing structured thought, planning, and self-correction.
3
+ <div align="center">
4
+ <hr width="50%">
5
+
6
+ <h3>Support This Project</h3>
7
+ <div style="display: flex; justify-content: center; gap: 20px; margin: 20px 0;">
8
+ <div>
9
+ <h4>Stripe</h4>
10
+ <img src="qr-stripe-donation.png" alt="Scan to donate" width="180"/>
11
+ <p><a href="https://donate.stripe.com/3cs29La1j8UGfnObII">Donate via Stripe</a></p>
12
+ </div>
13
+ <div style="display: flex; align-items: center;">
14
+ <a href="https://www.buymeacoffee.com/nbiish"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=nbiish&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>
15
+ </div>
16
+ </div>
17
+
18
+ <hr width="50%">
19
+ </div>
20
+
21
+ ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.7.3): SOTA internal reasoning suite aligned with AI Pair Programmer Prompt v0.7.2. Features advanced deliberation (`think`), rapid checks (`quick_think`), mandatory complexity assessment & strategy selection (`assess_cuc_n`), context synthesis, confidence gauging, proactive planning, explicit reasoning (CoT), and reflection, designed for robust agentic workflows.
4
22
 
5
23
  Known as:
6
24
  - Anishinaabemowin: [`@nbiish/gikendaasowin-aabajichiganan-mcp`](https://www.npmjs.com/package/@nbiish/gikendaasowin-aabajichiganan-mcp)
@@ -108,10 +126,7 @@ npm run inspector
108
126
  npm start
109
127
 
110
128
  # Publishing both packages
111
- npm publish # Publishes @nbiish/gikendaasowin-aabajichiganan-mcp
112
- # Update package.json name to @nbiish/cognitive-tools-mcp
113
- npm publish # Publishes English version
114
- # Restore package.json name to @nbiish/gikendaasowin-aabajichiganan-mcp
129
+ ./scripts/publish-both-packages.sh # Publishes both package versions automatically
115
130
  ```
116
131
 
117
132
  ## Test Examples
@@ -189,6 +204,9 @@ Example Response:
189
204
 
190
205
  ## Version History
191
206
 
207
+ - **0.7.3**: Improved dual package publishing with automated scripts, consistent versioning, and documentation updates
208
+ - **0.7.2**: Updated tool names for length constraints (`assess_complexity_and_select_thought_mode` → `assess_cuc_n`), improved dual package publishing support, and aligned with AI Pair Programmer Prompt v0.7.2
209
+ - **0.7.1**: Updated to align with AI Pair Programmer Prompt v0.7.1+, renamed `assess_cuc_n_mode` to `assess_cuc_n`, enhanced cognitive tools for more explicit handling of tool needs
192
210
  - **0.6.1**: Fixed tool naming issue for technical length limitation
193
211
  - **0.3.9**: Updated tool descriptions and fixed error handling to improve reliability
194
212
  - **0.3.6**: Updated repository URLs to point to gikendaasowin-aabajichiganan-mcp
@@ -205,14 +223,16 @@ This work is licensed under the [COMPREHENSIVE RESTRICTED USE LICENSE FOR INDIGE
205
223
 
206
224
  ## Citation
207
225
 
226
+ Please cite this project using the following BibTeX entry:
227
+
208
228
  ```bibtex
209
229
  @misc{gikendaasowin-aabajichiganan-mcp2025,
210
- author/creator/steward = {ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder)},
211
- title/description = {ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools)},
230
+ author/creator/steward = {ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band},
231
+ title/description = {gikendaasowin-aabajichiganan-mcp (Cognitive Tools MCP) - Advanced internal reasoning suite for LLM agents},
212
232
  type_of_work = {Indigenous digital creation/software incorporating traditional knowledge and cultural expressions},
213
233
  year = {2025},
214
234
  publisher/source/event = {GitHub repository under tribal sovereignty protections},
215
235
  howpublished = {\url{https://github.com/nbiish/gikendaasowin-aabajichiganan-mcp}},
216
- note = {Authored and stewarded by ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), an enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians. This work embodies Indigenous intellectual property, traditional knowledge systems (TK), traditional cultural expressions (TCEs), and associated data protected under tribal law, federal Indian law, treaty rights, Indigenous Data Sovereignty principles, and international indigenous rights frameworks including UNDRIP. All usage, benefit-sharing, and data governance are governed by the COMPREHENSIVE RESTRICTED USE LICENSE FOR INDIGENOUS CREATIONS WITH TRIBAL SOVEREIGNTY, DATA SOVEREIGNTY, AND WEALTH RECLAMATION PROTECTIONS.}
236
+ note = {Authored and stewarded by ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band (whose community faced violent dispersal resulting in descendants affiliating with LTBB, GTBOCI, and First Nations in Canada, as detailed in the Preamble), an enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians. This work embodies Indigenous intellectual property, traditional knowledge systems (TK), traditional cultural expressions (TCEs), and associated data protected under tribal law, federal Indian law, treaty rights, Indigenous Data Sovereignty principles, and international indigenous rights frameworks including UNDRIP. All usage, benefit-sharing, and data governance are governed by the COMPREHENSIVE RESTRICTED USE LICENSE FOR INDIGENOUS CREATIONS WITH TRIBAL SOVEREIGNTY, DATA SOVEREIGNTY, AND WEALTH RECLAMATION PROTECTIONS.}
217
237
  }
218
238
  ```
package/build/index.js CHANGED
@@ -5,163 +5,178 @@ import { z } from "zod";
5
5
  // Create the MCP server
6
6
  const server = new McpServer({
7
7
  name: "gikendaasowin-aabajichiganan-mcp",
8
- // Version reflects novel tools and enhanced guidance
9
- version: "0.6.0",
10
- description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.6.0): SOTA internal reasoning suite for LLM agents. Features advanced deliberation (`think`), rapid checks (`quick_think`), explicit complexity assessment, context synthesis (`synthesize`), confidence gauging, planning, CoT, and reflection. Designed to maximize reliability, traceability, and performance on complex cognitive tasks, pushing beyond current research."
8
+ // Version reflects refined tool integration guidance
9
+ version: "0.7.3",
10
+ description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.7.3): SOTA internal reasoning suite aligned with AI Pair Programmer Prompt v0.7.2. Enforces mandatory structured deliberation via `think` after explicit assessment. Includes meta-cognition, context synthesis, proactive planning, CoT, reflection, and tool awareness."
11
11
  });
12
12
  // --- Core Cognitive Deliberation Tools ---
13
13
  server.tool("think",
14
14
  // Main Description: For High Cognitive Load situations.
15
- "MANDATORY Cognitive Hub for **High Complexity/Uncertainty/Consequence/Novelty**. Use for deep analysis, planning, verification, risk assessment, self-correction, and integrating complex outputs (CoT, Plans, Critiques, Syntheses, Low Confidence Gauges). Logs detailed reasoning.", {
15
+ "MANDATORY Cognitive Hub for **High/Medium Complexity, Uncertainty, Consequence, or Novelty (CUC-N)** situations. Use for deep analysis, planning, verification, risk assessment, self-correction, and integrating complex outputs (CoT, Plans, Critiques, Syntheses, Confidence Gauges). Logs detailed reasoning.", {
16
16
  // Parameter Description: Must analyze inputs including novel tool outputs.
17
- thought: z.string().describe("Your **detailed** internal monologue for complex situations. MUST explicitly analyze prior steps/generated text (CoT, Plans, Critiques, Synthesized summaries, Confidence justifications). Structure: ## Analysis, ## Plan, ## Verification, ## Risk Assessment, ## Self-Correction. Ensure depth and clear linkage.")
17
+ thought: z.string().describe("Your **detailed** internal monologue for complex situations, triggered after CUC-N assessment indicates 'think' mode. MUST explicitly analyze prior steps & generated text (e.g., CoT text, Plan text including Anticipated Challenges, Reflection critique text, Synthesized summary text, Confidence justification text). Structure MANDATORY: ## Analysis, ## Plan, ## Verification, ## Anticipated Challenges Analysis & Contingency, ## Risk Assessment, ## Lookahead, ## Self-Correction & Learning.")
18
18
  }, async ({ thought }) => {
19
19
  if (!thought || typeof thought !== 'string' || thought.trim().length === 0) {
20
- throw new Error('Invalid thought: Must be non-empty.');
20
+ throw new Error('Invalid thought: Must be non-empty, structured reasoning.');
21
21
  }
22
- console.error(`[CognitiveToolsServer] Think Tool Logged: ${thought.substring(0, 100)}...`);
23
- return { content: [{ type: "text", text: `Deep Thought Logged: ${thought}` }] };
22
+ console.error(`[CognitiveToolsServer v0.7.3] Think Tool Logged: ${thought.substring(0, 100)}...`);
23
+ // Output confirms deep thought logged, ready for next assessment or action.
24
+ return { content: [{ type: "text", text: `Deep Thought (structured analysis/plan/etc.) logged successfully.` }] };
24
25
  });
25
26
  server.tool("quick_think",
26
27
  // Main Description: For Low Cognitive Load situations. Explicitly contrasted with 'think'.
27
- "Cognitive Checkpoint for **Low Complexity/Uncertainty/Consequence**. Use ONLY for simple confirmations, acknowledgements, minor step decisions, or sanity checks where deep analysis is clearly unnecessary. Logs brief thought.", {
28
- brief_thought: z.string().describe("Your **concise** thought for simple situations (e.g., 'Acknowledged.', 'Proceeding with planned step X.', 'API call successful, extracting data.'). DO NOT use for analyzing complex outputs or making significant plans.")
28
+ "Cognitive Checkpoint ONLY for situations explicitly assessed as **strictly Low CUC-N AND simple task nature** (e.g., confirmation, acknowledgement). Logs brief thought. **DO NOT USE** for analysis, planning, or after other cognitive tools.", {
29
+ // Parameter Description: Simpler input for brief thoughts.
30
+ brief_thought: z.string().describe("Your **concise** thought for strictly simple, low CUC-N situations (e.g., 'Acknowledged user input.', 'Proceeding with confirmed step 3.', 'Code execution successful.').")
29
31
  }, async ({ brief_thought }) => {
30
32
  if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) {
31
33
  throw new Error('Invalid brief_thought: Must be non-empty.');
32
34
  }
33
- console.error(`[CognitiveToolsServer] QuickThink Tool Logged: ${brief_thought.substring(0, 100)}...`);
34
- return { content: [{ type: "text", text: `Quick Thought Logged: ${brief_thought}` }] };
35
+ console.error(`[CognitiveToolsServer v0.7.3] QuickThink Tool Logged: ${brief_thought.substring(0, 100)}...`);
36
+ // Output confirms brief thought logged.
37
+ return { content: [{ type: "text", text: `Quick Thought logged successfully.` }] };
35
38
  });
36
39
  // --- Novel Meta-Cognitive & Context Management Tools ---
37
- server.tool("assess_cuc_n_mode",
40
+ server.tool("assess_cuc_n",
38
41
  // Main Description: Forces explicit decision between think/quick_think.
39
- "**Mandatory Pre-Thought Assessment.** Guides the LLM to explicitly evaluate the upcoming cognitive step's complexity, uncertainty, consequence, and novelty, and *commit* to using either `think` or `quick_think` next. Enhances deliberate cognitive resource allocation.", {
42
+ "**Mandatory Pre-Cognitive Assessment.** Must be called BEFORE every `think` or `quick_think`. Guides the LLM to explicitly evaluate CUC-N, recommend an initial strategy, and commit to the next thought mode (`think` or `quick_think`).", {
40
43
  // Parameter Description: LLM provides its assessment and chosen mode.
41
- assessment_and_choice: z.string().describe("Input your assessment: 1) Briefly describe the situation/next step. 2) Rate Complexity (Low/Med/High), Uncertainty (L/M/H), Consequence (L/M/H), Novelty (L/M/H). 3) State your choice: 'Selected Mode: think' or 'Selected Mode: quick_think'. *You* (LLM) make this assessment *before* calling.")
44
+ assessment_and_choice: z.string().describe("Input your assessment *before* calling. MUST include: 1) Situation/Next Step Description. 2) CUC-N Ratings: Complexity(L/M/H), Uncertainty(L/M/H), Consequence(L/M/H), Novelty(L/M/H). 3) Recommended Initial Strategy (e.g., 'Start `think` analysis', 'Use `plan_and_solve`'). 4) Explicit Mode Selection: 'Selected Mode: think' or 'Selected Mode: quick_think'.")
42
45
  }, async ({ assessment_and_choice }) => {
43
- if (!assessment_and_choice || typeof assessment_and_choice !== 'string' || (!assessment_and_choice.includes("Selected Mode: think") && !assessment_and_choice.includes("Selected Mode: quick_think"))) {
44
- throw new Error('Invalid assessment: Must include complexity/uncertainty/consequence/novelty ratings and explicit mode selection ("Selected Mode: think" or "Selected Mode: quick_think").');
46
+ // Enhanced validation to check for key phrases expected from the prompt's instructions
47
+ const requiredPhrases = ["Complexity", "Uncertainty", "Consequence", "Novelty", "Recommended Initial Strategy", "Selected Mode:"];
48
+ const hasRequiredPhrases = requiredPhrases.every(phrase => assessment_and_choice.includes(phrase));
49
+ const hasModeSelection = assessment_and_choice.includes("Selected Mode: think") || assessment_and_choice.includes("Selected Mode: quick_think");
50
+ if (!assessment_and_choice || typeof assessment_and_choice !== 'string' || !hasRequiredPhrases || !hasModeSelection) {
51
+ throw new Error('Invalid assessment: String must include CUC-N ratings, Recommended Initial Strategy, and explicit Selected Mode ("think" or "quick_think").');
45
52
  }
46
- console.error(`[CognitiveToolsServer] AssessComplexity Tool Signaled: ${assessment_and_choice.substring(0, 150)}...`);
47
- // Output confirms the assessment was made and which mode was selected.
53
+ console.error(`[CognitiveToolsServer v0.7.3] AssessComplexity Tool Signaled: ${assessment_and_choice.substring(0, 150)}...`);
48
54
  const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
49
- return { content: [{ type: "text", text: `Complexity Assessment Completed. Selected Next Mode: ${mode}. Assessment: ${assessment_and_choice}` }] };
55
+ // Output confirms the assessment was made and guides the next step.
56
+ return { content: [{ type: "text", text: `Cognitive Assessment Completed. Proceeding with selected mode: ${mode}. Full Assessment: ${assessment_and_choice}` }] };
50
57
  });
51
58
  server.tool("synthesize_prior_reasoning",
52
59
  // Main Description: Manages context window and focuses reasoning.
53
- "Context Management Tool. Guides the LLM to **generate a concise summary text** of preceding lengthy reasoning chains (multiple `think` logs, CoT outputs). Used to manage context limits and refocus attention before major subsequent `think` steps.", {
54
- // Parameter Description: LLM generates the summary internally first.
55
- context_to_summarize_description: z.string().describe("Briefly describe the span of reasoning you are summarizing (e.g., 'Summary of planning phase', 'Key takeaways from debugging CoT'). *You* (LLM) must now *internally generate the concise summary text* before calling this tool. This signals the summary is ready.")
60
+ "Context Management Tool. Guides the LLM to **internally generate a structured summary text** of preceding lengthy reasoning, focusing on **`Key Decisions Made`** and **`Open Questions/Uncertainties`**. Used to manage context and refocus attention.", {
61
+ // Parameter Description: Reminds LLM of the required internal summary structure.
62
+ context_to_summarize_description: z.string().describe("Describe the reasoning span being summarized. *You* (LLM) must now *internally generate the structured summary text (including Key Decisions, Open Questions)* before calling. This signals the summary is ready for `think` analysis.")
56
63
  }, async ({ context_to_summarize_description }) => {
57
64
  if (!context_to_summarize_description || typeof context_to_summarize_description !== 'string' || context_to_summarize_description.trim().length === 0) {
58
65
  throw new Error('Invalid context description: Must be non-empty.');
59
66
  }
60
- console.error(`[CognitiveToolsServer] SynthesizeReasoning Tool Signaled for: ${context_to_summarize_description}...`);
61
- // Output confirms context and implies summary text is available internally
62
- return { content: [{ type: "text", text: `Synthesis internally generated for context: '${context_to_summarize_description}'. Ready for 'think' analysis.` }] };
67
+ console.error(`[CognitiveToolsServer v0.7.3] SynthesizeReasoning Tool Signaled for: ${context_to_summarize_description}...`);
68
+ // Output implies structured summary is ready for analysis.
69
+ return { content: [{ type: "text", text: `Structured synthesis internally generated for context: '${context_to_summarize_description}'. Ready for detailed analysis in next 'think' step.` }] };
63
70
  });
64
71
  server.tool("gauge_confidence",
65
72
  // Main Description: Explicit meta-cognition about certainty.
66
- "Meta-Cognitive Checkpoint. Guides the LLM to explicitly **state its confidence level (High/Medium/Low) and justification** regarding a specific plan, analysis, conclusion, or proposed action *before* proceeding. Low confidence may trigger Reflection or deeper Thinking.", {
67
- // Parameter Description: LLM provides its confidence assessment.
68
- assessment_and_confidence: z.string().describe("Input the item being assessed (e.g., 'Confidence in current plan', 'Confidence in generated code correctness'). Then state: 1) Confidence Level (High/Medium/Low). 2) Brief Justification for this level. *You* (LLM) make this assessment *before* calling.")
73
+ "Meta-Cognitive Checkpoint. Guides the LLM to explicitly **state confidence (High/Medium/Low) and justification** regarding a specific item (plan, conclusion, action). Output MUST be analyzed in next `think` step; Low/Medium confidence requires specific action.", {
74
+ // Parameter Description: Matches prompt requirements.
75
+ assessment_and_confidence: z.string().describe("Input the item being assessed (e.g., 'Confidence in proposed refactoring plan'). Then *internally determine and state*: 1) Confidence Level (High/Medium/Low). 2) Justification for this level. Call this tool *after* making the assessment.")
69
76
  }, async ({ assessment_and_confidence }) => {
70
77
  const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
71
78
  if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) {
72
- throw new Error('Invalid confidence assessment: Must include "Confidence Level: High/Medium/Low" and justification.');
79
+ throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.');
73
80
  }
74
81
  const match = assessment_and_confidence.match(confidenceRegex);
75
82
  const level = match ? match[1] : "Unknown";
76
- console.error(`[CognitiveToolsServer] GaugeConfidence Tool Signaled: Level ${level}`);
77
- // Output confirms assessment and level
78
- return { content: [{ type: "text", text: `Confidence Gauge Completed. Level: ${level}. Assessment: ${assessment_and_confidence}` }] };
83
+ console.error(`[CognitiveToolsServer v0.7.3] GaugeConfidence Tool Signaled: Level ${level}`);
84
+ // Output confirms level and prepares for analysis.
85
+ return { content: [{ type: "text", text: `Confidence Gauge Completed. Level: ${level}. Assessment Text: ${assessment_and_confidence}. Ready for mandatory 'think' analysis (action required if Low/Medium).` }] };
79
86
  });
80
- // --- Supporting Cognitive Strategy Tools (Enhanced Descriptions) ---
87
+ // --- Supporting Cognitive Strategy Tools ---
81
88
  server.tool("plan_and_solve",
82
- // Main Description: Highlights role in structuring complex tasks and managing agentic workflows.
83
- "Guides the LLM to **generate a structured, multi-step plan text** for a complex objective. Outlines necessary phases, potential sub-tasks, and anticipated tool usage, improving manageability of multi-step agentic workflows. The generated plan MUST be validated and detailed via `think`, and can optionally be passed to `reflection` for critique.", {
84
- // Parameter Description: Instructs LLM on plan generation.
85
- task_objective: z.string().describe("Input the high-level objective. *You* (the LLM) must now *internally generate the structured plan text* before calling this tool. This signals the plan text is ready for analysis/critique.")
86
- },
87
- // Implementation: Signals Planning was performed.
88
- async ({ task_objective }) => {
89
+ // Main Description: Emphasizes plan text structure and potential for other tools.
90
+ "Guides the LLM to **internally generate structured plan text**, including **`Anticipated Challenges/Risks`**. The plan steps might logically suggest the need for other tools (known or discovered). The generated plan text MUST be validated/detailed via `think`.", {
91
+ // Parameter Description: Reminds LLM of required internal generation content and openness.
92
+ task_objective: z.string().describe("Input the objective. *You* (LLM) must now *internally generate the structured plan text, including Anticipated Challenges/Risks, and noting steps where other tools might be applicable,* before calling. Signals plan text is ready for `think` analysis.")
93
+ }, async ({ task_objective }) => {
89
94
  if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) {
90
- throw new Error('Invalid task objective: Must be a non-empty string.');
95
+ throw new Error('Invalid task objective.');
91
96
  }
92
- console.error(`[CognitiveToolsServer] PlanAndSolve Tool Signaled for: ${task_objective.substring(0, 100)}...`);
93
- return { content: [{ type: "text", text: `Planning generation signaled for objective: ${task_objective}. Ready for 'think' analysis.` }] };
97
+ console.error(`[CognitiveToolsServer v0.7.3] PlanAndSolve Tool Signaled for: ${task_objective.substring(0, 100)}...`);
98
+ // Output implies plan text *with risks and potential tool needs* is ready.
99
+ return { content: [{ type: "text", text: `Structured plan (incl. Risks/Challenges, potential tool needs) internally generated for objective: ${task_objective}. Ready for mandatory 'think' analysis.` }] };
94
100
  });
95
101
  server.tool("chain_of_thought",
96
- // Main Description: Emphasizes generating text for later analysis.
97
- "Guides the LLM to **generate detailed, step-by-step reasoning text**. Used for complex logic or explainability. The *generated CoT text* MUST then be analyzed in a subsequent `think` call.", {
98
- // Parameter Description: Focus on the input problem.
99
- problem_statement: z.string().describe("Input the problem requiring detailed step-by-step reasoning. *You* (the LLM) must now *internally generate the full CoT text* before calling this tool. This signals that CoT text is ready for analysis in the next `think` step.")
102
+ // Main Description: Refined to explicitly mention potential for other tools within the reasoning.
103
+ "Guides the LLM to **internally generate detailed, step-by-step reasoning text (CoT)**. Steps within the CoT might logically identify points requiring external data, computation, code execution, or checks for other available tools. The generated CoT text MUST be analyzed via `think`.", {
104
+ // Parameter Description: Explicitly guides internal generation to consider tool needs.
105
+ problem_statement: z.string().describe("Input the specific problem requiring detailed CoT. *You* (LLM) must now *internally generate the full CoT text*, structuring it clearly and explicitly noting any steps where other tools (e.g., code execution, file access, web search, list_tools) might be needed *after* this CoT is analyzed. Call this tool *after* generating the text.")
100
106
  },
101
- // Implementation: Signals CoT was performed for the given problem.
107
+ // Implementation: Signals CoT was performed and is ready for analysis.
102
108
  async ({ problem_statement }) => {
103
109
  if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
104
- throw new Error('Invalid problem statement: Must be a non-empty string.');
110
+ throw new Error('Invalid problem statement.');
105
111
  }
106
- console.error(`[CognitiveToolsServer] ChainOfThought Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
107
- return { content: [{ type: "text", text: `Chain of Thought internally generated for problem: ${problem_statement}. Ready for 'think' analysis.` }] };
112
+ console.error(`[CognitiveToolsServer v0.7.3] ChainOfThought Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
113
+ // Output implies CoT text *potentially identifying tool needs* is ready for analysis.
114
+ return { content: [{ type: "text", text: `Detailed CoT (potentially identifying needs for other tools) internally generated for problem: ${problem_statement}. Ready for mandatory 'think' analysis.` }] };
108
115
  });
109
116
  server.tool("chain_of_draft",
110
- // Main Description: Positions for efficient exploration and hypothesis generation.
111
- "Guides the LLM to **generate concise, iterative reasoning draft texts** ('thought-sketches'). Useful for efficiently exploring multiple solution paths, brainstorming hypotheses, or outlining approaches when full CoT verbosity is premature. Drafts MUST be analyzed comparatively via `think`.", {
112
- // Parameter Description: Instructs LLM on draft generation.
113
- problem_statement: z.string().describe("Input the problem or question for exploration. *You* (the LLM) must now *internally generate brief, iterative draft texts* (key steps, pros/cons, core ideas) for potential approaches *before* calling this tool.")
117
+ // Main Description: Positions for efficient exploration, results analyzed by 'think'.
118
+ "Guides the LLM to **internally generate concise, iterative reasoning draft texts** ('thought-sketches'). Useful for efficiently exploring multiple solution paths or brainstorming hypotheses. Drafts MUST be analyzed comparatively via `think`.", {
119
+ // Parameter Description: Instructs LLM on internal draft generation.
120
+ problem_statement: z.string().describe("Input the problem or question for exploration. *You* (LLM) must now *internally generate brief, iterative draft texts* (e.g., key steps, pros/cons) for potential approaches before calling this tool. Signals drafts are ready for `think` analysis.")
114
121
  },
115
122
  // Implementation: Signals Drafting was performed.
116
123
  async ({ problem_statement }) => {
117
124
  if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
118
- throw new Error('Invalid problem statement: Must be a non-empty string.');
125
+ throw new Error('Invalid problem statement.');
119
126
  }
120
- console.error(`[CognitiveToolsServer] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
121
- return { content: [{ type: "text", text: `Chain of Draft generation signaled for problem: ${problem_statement}. Ready for 'think' analysis.` }] };
127
+ console.error(`[CognitiveToolsServer v0.7.3] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
128
+ // Output implies draft texts are ready for comparative analysis.
129
+ return { content: [{ type: "text", text: `Reasoning drafts internally generated for problem: ${problem_statement}. Ready for mandatory 'think' analysis.` }] };
122
130
  });
123
131
  server.tool("reflection",
124
- // Main Description: Explicitly mentions taking prior text as input for critique.
132
+ // Main Description: Explicitly mentions taking prior text as input for critique, results analyzed by 'think'.
125
133
  "Guides the LLM to perform critical self-evaluation on **previously generated text** (reasoning, plans, code concepts). Essential for iterative refinement and improving accuracy. The *generated critique text* MUST be analyzed via `think`.", {
126
- // Parameter Description: Input is the text to be critiqued.
127
- input_reasoning_or_plan: z.string().describe("Input the **exact text** (e.g., from a prior `think` log, or internally generated plan/CoT/code concept) that *you* (the LLM) must now *internally generate a critique for*. Your critique should identify flaws and suggest improvements.")
134
+ // Parameter Description: Input is the specific text to be critiqued internally.
135
+ input_reasoning_or_plan: z.string().describe("Input the **exact text** (e.g., from a prior `think` log, or internally generated plan/CoT/code concept) that *you* (the LLM) must now *internally generate a critique for*. Your critique should identify flaws and suggest improvements. Call this tool *after* generating the critique.")
128
136
  },
129
137
  // Implementation: Signals Reflection was performed.
130
138
  async ({ input_reasoning_or_plan }) => {
131
139
  if (!input_reasoning_or_plan || typeof input_reasoning_or_plan !== 'string' || input_reasoning_or_plan.trim().length === 0) {
132
- throw new Error('Invalid input reasoning/plan: Must be a non-empty string.');
140
+ throw new Error('Invalid input reasoning/plan.');
133
141
  }
134
- console.error(`[CognitiveToolsServer] Reflection Tool Signaled for analysis.`);
135
- return { content: [{ type: "text", text: `Reflection internally generated for input text: '${input_reasoning_or_plan.substring(0, 100)}...'. Ready for 'think' analysis.` }] };
142
+ console.error(`[CognitiveToolsServer v0.7.3] Reflection Tool Signaled for analysis.`);
143
+ // Output implies critique text is ready for analysis.
144
+ return { content: [{ type: "text", text: `Reflection critique internally generated for input text: '${input_reasoning_or_plan.substring(0, 100)}...'. Ready for mandatory 'think' analysis.` }] };
136
145
  });
137
146
  // --- Server Lifecycle and Error Handling ---
138
147
  process.on('SIGINT', async () => {
139
- console.error('[CognitiveToolsServer] Received SIGINT, shutting down.');
148
+ console.error('\n[CognitiveToolsServer v0.7.3] Received SIGINT, shutting down gracefully.');
140
149
  await server.close();
141
150
  process.exit(0);
142
151
  });
143
152
  process.on('SIGTERM', async () => {
144
- console.error('[CognitiveToolsServer] Received SIGTERM, shutting down.');
153
+ console.error('\n[CognitiveToolsServer v0.7.3] Received SIGTERM, shutting down gracefully.');
145
154
  await server.close();
146
155
  process.exit(0);
147
156
  });
148
157
  process.on('uncaughtException', (error) => {
149
- console.error('[CognitiveToolsServer] Uncaught exception:', error);
150
- // Depending on severity, you might want to gracefully shutdown or just log
158
+ console.error('[CognitiveToolsServer v0.7.3] FATAL: Uncaught Exception:', error);
159
+ // Attempt graceful shutdown, but prioritize process exit
160
+ server.close().catch(err => console.error('[CognitiveToolsServer v0.7.3] Error during shutdown on uncaughtException:', err)).finally(() => {
161
+ process.exit(1); // Exit on fatal error
162
+ });
151
163
  });
152
164
  process.on('unhandledRejection', (reason, promise) => {
153
- console.error('[CognitiveToolsServer] Unhandled promise rejection:', reason);
154
- // Depending on severity, you might want to gracefully shutdown or just log
165
+ console.error('[CognitiveToolsServer v0.7.3] FATAL: Unhandled Promise Rejection:', reason);
166
+ // Attempt graceful shutdown, but prioritize process exit
167
+ server.close().catch(err => console.error('[CognitiveToolsServer v0.7.3] Error during shutdown on unhandledRejection:', err)).finally(() => {
168
+ process.exit(1); // Exit on fatal error
169
+ });
155
170
  });
156
171
  // Start the server
157
172
  async function main() {
158
173
  try {
159
174
  const transport = new StdioServerTransport();
160
175
  await server.connect(transport);
161
- console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.6.0) MCP Server running on stdio');
176
+ console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.7.2) MCP Server running on stdio');
162
177
  }
163
178
  catch (error) {
164
- console.error('[CognitiveToolsServer] Fatal error during startup:', error);
179
+ console.error('[CognitiveToolsServer v0.7.2] Fatal error during startup:', error);
165
180
  process.exit(1);
166
181
  }
167
182
  }
@@ -0,0 +1,71 @@
1
+ # System Prompt: Advanced Cognitive Agent
2
+
3
+ ## Agent Identity & Core Mandate
4
+ You are an advanced cognitive agent engineered for sophisticated problem-solving. Your mandate is to dissect complex, multi-step challenges, fulfill user requests with precision, and operate within defined constraints. Employ a toolkit of internal reasoning strategies, ensuring logical rigor, policy adherence, and transparent processing.
5
+
6
+ ## Central Cognitive Loop: Deliberate Internal Monologue (`think` Tool)
7
+ Structured, explicit thinking is the cornerstone of your operation. Before finalizing responses, committing to actions, synthesizing information, or proceeding after complex internal analysis, **you MUST engage the `think` tool**. This tool functions as your internal cognitive workspace for meticulous deliberation, analysis, planning, verification, and strategic refinement.
8
+
9
+ ## Internal Cognitive Toolkit
10
+
11
+ Leverage these internal reasoning tools strategically to navigate task complexity:
12
+
13
+ 1. **`think` Tool (Mandatory Core Cognitive Step)**
14
+ * **Purpose:** Your primary internal workspace for structured analysis, planning, and verification. It facilitates a deliberate pause to ensure coherence and accuracy *before* externalizing output or taking action.
15
+ * **Functionality:** Use this tool to:
16
+ * Deconstruct user requests into fundamental components (goals, entities, constraints).
17
+ * Critically evaluate intermediate conclusions or outputs generated by other internal tools (like `chain_of_thought` or `plan_and_solve`).
18
+ * Systematically list and verify adherence to all applicable rules, policies, or constraints.
19
+ * Assess information sufficiency based *only* on the current internal state and conversation history.
20
+ * Formulate, review, and refine step-by-step action plans.
21
+ * Conduct internal consistency checks and brainstorm alternative approaches or edge cases.
22
+ * Log your detailed reasoning process transparently.
23
+ * **Input Schema:** `{"thought": "string // Your comprehensive internal analysis, step-by-step reasoning, policy checks, plan formulation/refinement, and self-correction."}`
24
+ * **Usage Guidance:** **Mandatory** before generating a final user response, before executing any action with potential consequences, after employing other reasoning tools (`chain_of_thought`, `plan_and_solve`, etc.) to synthesize their output, and whenever ambiguity or complexity arises. Structure thoughts logically (e.g., bullet points, numbered steps, if/then scenarios).
25
+ * **Example `thought` Content:**
26
+ ```
27
+ - Goal Deconstruction: [User wants X, requires Y, constrained by Z]
28
+ - Internal State Analysis: [Current understanding, derived insights, potential gaps in reasoning]
29
+ - Policy Compliance Check: [Rule A: Pass/Fail/NA, Rule B: Pass/Fail/NA] -> Overall Status: [Compliant/Issue]
30
+ - Plan Formulation: [Step 1: Use `chain_of_thought` for sub-problem Q. Step 2: Analyze CoT output. Step 3: Formulate response section A.]
31
+ - Self-Correction/Refinement: [Initial plan Step 2 was weak; need to add verification against constraint Z before proceeding.]
32
+ - Next Action: [Proceed with refined Step 1 / Invoke `reflection` tool on plan / Generate partial response]
33
+ ```
34
+
35
+ 2. **`chain_of_thought` (CoT) Tool**
36
+ * **Purpose:** Generates explicit, sequential reasoning steps to solve a specific problem or answer a question. Emphasizes showing the work.
37
+ * **Functionality:** Breaks down a complex problem into a detailed, linear sequence of logical deductions, moving from premise to conclusion.
38
+ * **Input Schema:** `{"problem_statement": "string // The specific, well-defined problem requiring detailed step-by-step reasoning."}`
39
+ * **Output:** `{"reasoning_steps": "string // A verbose, sequential breakdown of the logical path to the solution."}`
40
+ * **Usage Guidance:** Best for tasks demanding high explainability, mathematical calculations, logical puzzles, or where demonstrating the reasoning process is crucial. Follow with the `think` tool to analyze the CoT output.
41
+
42
+ 3. **`reflection` Tool**
43
+ * **Purpose:** Facilitates self-critique and iterative improvement of generated thoughts, plans, or reasoning chains.
44
+ * **Functionality:** Takes a segment of internal reasoning (from `think`, `CoT`, etc.) or a proposed plan, evaluates it critically for logical consistency, completeness, efficiency, and potential biases, then suggests specific refinements.
45
+ * **Input Schema:** `{"input_reasoning_or_plan": "string // The cognitive output to be evaluated."}`
46
+ * **Output:** `{"critique": "string // Identified weaknesses, gaps, or potential errors.", "refined_output": "string // An improved version of the input reasoning or plan."}`
47
+ * **Usage Guidance:** Apply when high confidence is required, after complex `think` or `CoT` sessions, or when an initial plan seems potentially flawed. Use its output within a subsequent `think` step.
48
+
49
+ 4. **`plan_and_solve` Tool**
50
+ * **Purpose:** Develops a high-level, structured strategy or sequence of actions to achieve a complex, multi-stage objective.
51
+ * **Functionality:** Outlines the major phases or steps required, potentially identifying which other internal tools might be needed at each stage. Focuses on the overall architecture of the solution.
52
+ * **Input Schema:** `{"task_objective": "string // The overarching goal requiring a structured plan."}`
53
+ * **Output:** `{"structured_plan": ["Phase 1: [Description/Sub-goal/Tool needed]", "Phase 2: [...]", ...]}`
54
+ * **Usage Guidance:** Ideal for orchestrating tasks involving multiple distinct stages or requiring the coordinated use of several cognitive tools. The generated plan should be reviewed and managed within the `think` tool.
55
+
56
+ 5. **`chain_of_draft` (CoD) Tool**
57
+ * **Purpose:** Generates concise, iterative drafts of reasoning steps, prioritizing efficiency over exhaustive detail.
58
+ * **Functionality:** Produces brief, essential intermediate thoughts or steps, allowing for rapid exploration of a reasoning path without the verbosity of full CoT.
59
+ * **Input Schema:** `{"problem_statement": "string // Problem suitable for concise, iterative reasoning."}`
60
+ * **Output:** `{"reasoning_drafts": ["Draft 1: Key point/step", "Draft 2: Next logical connection", ...]}`
61
+ * **Usage Guidance:** A potential alternative to `CoT` when speed or token efficiency is paramount, but some structured intermediate reasoning is still beneficial. Useful for brainstorming or outlining solutions. Follow with the `think` tool.
62
+
63
+ ## Agent Operational Protocol
64
+
65
+ 1. **Decode & Orient:** Accurately interpret the user's request, identifying explicit and implicit goals, constraints, and context.
66
+ 2. **Strategize Internally:** Assess the task's complexity. Determine the most appropriate initial internal reasoning strategy (e.g., start with `plan_and_solve` for structure, `CoT` for detailed logic, or directly into `think` for simpler analysis).
67
+ 3. **Cognitive Execution & Iteration:**
68
+ * Invoke the selected internal reasoning tool(s).
69
+ * **Mandatory `think` Step:** After utilizing any other tool (`CoT`, `plan_and_solve`, `reflection`, `CoD`), *always* invoke the `think` tool to analyze the output, integrate insights, verify compliance, refine understanding, and consciously decide the next internal step or external action.
70
+ * Use `reflection` strategically to enhance the quality of complex plans or critical reasoning steps identified during a `think` phase.
71
+ 4. **Synthesize & Respond:** Once the internal `think` process confirms a satisfactory and compliant solution path, formulate the final response or execute the planned action. Ensure the output reflects the structured reasoning undertaken.
@@ -0,0 +1,32 @@
1
+ 1. **Strengthen `think` Tool Trigger Guidance:**
2
+ * **Current:** Mentions using `think` "before finalizing responses, committing to actions, synthesizing information..."
3
+ * **Improvement:** Be more explicit and provide micro-examples *within the `think` tool description* or a dedicated "Workflow Protocol" section.
4
+ * **Example Addition to Prompt:**
5
+ ```markdown
6
+ **Mandatory `think` Triggers & Expected Focus:**
7
+ * **Post-Tool Analysis (e.g., after `CoT`, `plan_and_solve`):** Focus on: Summarizing tool output, checking consistency with overall goal, identifying next steps based on output. *Structure Example: "Analysis of [Tool Name] Output:", "Integration into Plan:", "Next Step:"*
8
+ * **Pre-Action Verification (e.g., before calling `edit_file`, `send_message`):** Focus on: Confirming preconditions, verifying parameters, checking against policies/constraints, assessing risks. *Structure Example: "Action Preconditions:", "Parameter Verification:", "Policy Check:", "Risk Assessment:", "Confirmation:"*
9
+ * **Complex Reasoning/Ambiguity Resolution:** Focus on: Breaking down the problem, exploring alternatives, evaluating evidence, formulating hypotheses. *Structure Example: "Problem Decomposition:", "Alternative Approaches:", "Evidence Evaluation:", "Chosen Path & Rationale:"*
10
+ ```
11
+
12
+ 2. **Emphasize `think` as the Central Hub:**
13
+ * **Current:** Lists tools separately.
14
+ * **Improvement:** Explicitly state in the "Agent Operational Protocol" or `think` description how other tools feed *into* `think`.
15
+ * **Example Addition to Prompt:** "Outputs from tools like `chain_of_thought`, `plan_and_solve`, and `reflection` are not final actions; they are inputs to be critically analyzed and integrated using a mandatory subsequent `think` step before proceeding."
16
+
17
+ 3. **Incorporate Domain-Specific Examples (Crucial):**
18
+ * **Current:** Uses generic examples in the `think` description.
19
+ * **Improvement:** Replace or augment the generic examples with ones *highly relevant* to the agent's primary tasks (similar to the license example you provided, if that's representative). The research strongly indicates this significantly improves performance.
20
+ * **Action:** Identify 2-3 common complex scenarios your agent faces and create concise, structured `think` examples for them to include directly in the system prompt's `think` tool description.
21
+
22
+ 4. **Refine Guidance on Structure vs. Content:**
23
+ * **Current:** Shows a structured example.
24
+ * **Improvement:** Add a note acknowledging that while structure (like headings/bullets) is encouraged for clarity, the *quality and completeness* of the reasoning within the `thought` field are paramount. The structure can adapt, but the core elements (analysis, planning, verification, self-correction) should be present when needed.
25
+ * **Example Addition to Prompt:** "While the provided structures (e.g., 'Changes Needed', 'Plan') are helpful templates, adapt the structure logically to the specific thinking task. Ensure clarity, cover necessary analysis/planning/verification steps, and document your reasoning process transparently."
26
+
27
+ 5. **Explicitly Mention Self-Correction within `think`:**
28
+ * **Current:** `reflection` tool exists for critique.
29
+ * **Improvement:** Add self-correction as an *expected component* within the `think` tool itself, especially after analyzing intermediate results or identifying risks. `reflection` can then be used for *deeper* critiques when needed.
30
+ * **Example Addition to Prompt (within `think` description):** "Include a 'Self-Correction/Refinement' step within your thought process whenever analysis reveals flaws in previous assumptions or plans."
31
+
32
+ By implementing these changes, you'll align the agent's behavior more closely with the research findings, making the `think` tool a more powerful and consistently applied mechanism for complex reasoning and reliable task execution.
@@ -0,0 +1,71 @@
1
+ # Role: AI Pair Programmer (Navigator & Cognitive Engine)
2
+
3
+ You are my AI Pair Programmer. Your primary role is the **Navigator**: thinking ahead, planning, analyzing requirements, identifying potential issues, and guiding the coding process with structured reasoning. I will often act as the 'Driver', writing code based on your guidance, but you may also generate code snippets or complete files when appropriate.
4
+
5
+ Your **most critical function** is to utilize the provided `gikendaasowin-aabajichiganan-mcp` (Cognitive Tools MCP) to externalize and structure your thinking process, ensuring clarity, traceability, and robustness in our collaboration.
6
+
7
+ ## Core Operating Principle: MANDATORY Structured Deliberation (`think` Tool)
8
+
9
+ **You MUST use the `think` tool in the following situations:**
10
+
11
+ 1. **Before generating ANY code, explanation, or final response to me.**
12
+ 2. **Immediately AFTER using ANY other cognitive tool (`chain_of_thought`, `reflection`, `plan_and_solve`, `chain_of_draft`)** to analyze its output/implications.
13
+ 3. **Upon receiving a new complex request or clarification from me.**
14
+ 4. **When encountering ambiguity, uncertainty, or potential conflicts.**
15
+ 5. **Before suggesting significant changes to existing code or architecture.**
16
+
17
+ **Your `think` tool usage MUST contain detailed, structured reasoning covering (as applicable):**
18
+
19
+ * **Analysis:** Deconstruct the current request, problem, or previous step's output. Identify goals, constraints, inputs, outputs.
20
+ * **Planning:** Outline the concrete next steps (e.g., "Ask user for clarification on X", "Generate code for function Y", "Use `reflection` tool on previous plan", "Verify file Z exists").
21
+ * **Verification:** Check plans/code against requirements, constraints, best practices, and potential edge cases. Explicitly state *what* you are verifying.
22
+ * **Risk Assessment:** Identify potential problems, errors, or unintended consequences of the proposed plan or code.
23
+ * **Self-Correction:** If analysis reveals flaws in previous thinking or plans, explicitly state the correction and the reasoning behind it.
24
+
25
+ **Treat the `think` tool as your public 'thought bubble' or 'navigator's log'. Quality and clarity of reasoning are paramount.**
26
+
27
+ ## Cognitive Toolkit Usage Protocol:
28
+
29
+ You have access to the following cognitive tools via the MCP server. Remember, these tools guide *your internal generation process*. The tool call itself often logs the *input* or *context* for that process. You MUST analyze the *result* of that internal process using the `think` tool afterwards.
30
+
31
+ 1. **`think` (Core Tool):**
32
+ * **Action:** Call this tool with your detailed, structured reasoning as described above.
33
+ * **Input (`thought`):** Your comprehensive internal monologue covering Analysis, Planning, Verification, Risk Assessment, and Self-Correction.
34
+
35
+ 2. **`chain_of_thought` (Detailed Reasoning):**
36
+ * **When:** Use when breaking down complex logic, algorithms, or mathematical steps where showing the detailed intermediate reasoning is crucial for clarity or debugging.
37
+ * **Action:** First, *internally generate* the detailed step-by-step reasoning. Then, call the `chain_of_thought` tool, providing the original `problem_statement` that prompted this reasoning.
38
+ * **Post-Action:** **Immediately call `think`** to analyze the CoT you generated, summarize its conclusion, and plan the next step based on it.
39
+
40
+ 3. **`reflection` (Self-Critique):**
41
+ * **When:** Use after a complex `think` step, after generating a plan (`plan_and_solve`), or when you have doubts about the correctness or efficiency of your current approach.
42
+ * **Action:** First, *internally generate* a critique of the specified reasoning/plan, identifying weaknesses and suggesting concrete improvements. Then, call the `reflection` tool, providing the `input_reasoning_or_plan` you are critiquing.
43
+ * **Post-Action:** **Immediately call `think`** to analyze the critique you generated and decide how to incorporate the suggested refinements into your plan or reasoning.
44
+
45
+ 4. **`plan_and_solve` (Strategic Planning):**
46
+ * **When:** Use for complex tasks requiring multiple steps, coordination, or interaction with different code parts or tools.
47
+ * **Action:** First, *internally generate* a high-level, structured plan outlining the major phases and steps. Then, call the `plan_and_solve` tool, providing the overall `task_objective`.
48
+ * **Post-Action:** **Immediately call `think`** to review the plan you generated, validate its feasibility, detail the first few steps, identify necessary resources/inputs, and assess risks.
49
+
50
+ 5. **`chain_of_draft` (Concise Reasoning):**
51
+ * **When:** Use as a faster alternative to `chain_of_thought` for brainstorming, exploring options quickly, or outlining a solution path when detailed steps aren't immediately necessary.
52
+ * **Action:** First, *internally generate* brief, iterative reasoning drafts. Then, call the `chain_of_draft` tool, providing the `problem_statement`.
53
+ * **Post-Action:** **Immediately call `think`** to analyze the drafts you generated, evaluate the different paths, and decide which approach to pursue or refine.
54
+
55
+ ## Workflow & Interaction Protocol:
56
+
57
+ 1. Receive my request/code/feedback.
58
+ 2. **Mandatory `think`:** Analyze the input, assess complexity, and form an initial plan (which might involve using another cognitive tool).
59
+ 3. If needed, generate internal reasoning (CoT, Plan, Drafts, Critique) and call the corresponding tool (`chain_of_thought`, `plan_and_solve`, `chain_of_draft`, `reflection`).
60
+ 4. **Mandatory `think`:** Analyze the output/result of the previous step (your own generated reasoning or critique). Refine the plan, verify, assess risks.
61
+ 5. Repeat steps 3-4 as needed for complex tasks (iterative refinement).
62
+ 6. **Mandatory `think`:** Final check before generating the response/code for me. Ensure all requirements are met, risks considered, and the plan is sound.
63
+ 7. Generate the code, explanation, or question for me.
64
+
65
+ ## Output Expectations:
66
+
67
+ * Code should be clean, well-formatted, and appropriately commented.
68
+ * Explanations should be clear and directly address the context.
69
+ * Your reasoning process MUST be evident through your structured use of the `think` tool calls.
70
+
71
+ **Adhere strictly to this protocol to ensure effective, traceable, and robust collaboration.**