@gotza02/sequential-thinking 2026.2.14 → 2026.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -140,6 +140,12 @@ export class SequentialThinkingServer {
140
140
  summaryInsertedAt: startIndex
141
141
  };
142
142
  }
143
+ async searchHistory(query) {
144
+ const lowerQuery = query.toLowerCase();
145
+ return this.thoughtHistory.filter(t => t.thought.toLowerCase().includes(lowerQuery) ||
146
+ (t.thoughtType && t.thoughtType.toLowerCase().includes(lowerQuery)) ||
147
+ (t.branchId && t.branchId.toLowerCase().includes(lowerQuery)));
148
+ }
143
149
  addToMemory(input) {
144
150
  if (input.thoughtNumber > input.totalThoughts) {
145
151
  input.totalThoughts = input.thoughtNumber;
@@ -204,12 +210,30 @@ export class SequentialThinkingServer {
204
210
  if (this.delayMs > 0) {
205
211
  await new Promise(resolve => setTimeout(resolve, this.delayMs));
206
212
  }
213
+ // --- 🧠 Logic Upgrade: Intelligence & Feedback ---
214
+ const warnings = [];
215
+ // 1. Loop Detection (ตรวจการคิดวน)
216
+ const recentThoughts = this.thoughtHistory.slice(-3);
217
+ if (recentThoughts.length >= 3 && recentThoughts.every(t => t.thoughtType === input.thoughtType)) {
218
+ warnings.push(`⚠️ WARNING: You have used '${input.thoughtType}' for 4 consecutive steps. Consider 'reflexion' or 'generation' to progress.`);
219
+ }
220
+ // 2. Completion Guard (เตือนถ้าลืมเทส)
221
+ if (input.nextThoughtNeeded === false) {
222
+ const hasVerification = this.thoughtHistory.some(t => t.thought.toLowerCase().includes('test') ||
223
+ t.thought.toLowerCase().includes('verify') ||
224
+ t.thought.toLowerCase().includes('check'));
225
+ if (!hasVerification) {
226
+ warnings.push(`🚨 CRITICAL: You are ending the task without explicit verification/testing steps. It is recommended to verify changes first.`);
227
+ }
228
+ }
207
229
  this.addToMemory(input);
208
230
  await this.saveHistory();
209
231
  if (!this.disableThoughtLogging) {
210
232
  const formattedThought = this.formatThought(input);
211
233
  console.error(formattedThought);
212
234
  }
235
+ // 3. Visualization (Mermaid Diagram)
236
+ const mermaid = this.generateMermaid();
213
237
  return {
214
238
  content: [{
215
239
  type: "text",
@@ -218,7 +242,9 @@ export class SequentialThinkingServer {
218
242
  totalThoughts: input.totalThoughts,
219
243
  nextThoughtNeeded: input.nextThoughtNeeded,
220
244
  branches: Object.keys(this.branches),
221
- thoughtHistoryLength: this.thoughtHistory.length
245
+ thoughtHistoryLength: this.thoughtHistory.length,
246
+ feedback: warnings.length > 0 ? warnings : "Analysis healthy",
247
+ visualization: mermaid
222
248
  }, null, 2)
223
249
  }]
224
250
  };
@@ -236,4 +262,22 @@ export class SequentialThinkingServer {
236
262
  };
237
263
  }
238
264
  }
265
+ generateMermaid() {
266
+ let diagram = 'graph TD\n';
267
+ this.thoughtHistory.forEach((t, i) => {
268
+ const id = `T${t.thoughtNumber}`;
269
+ const label = `${t.thoughtNumber}[${t.thoughtType || 'thought'}]`;
270
+ diagram += ` ${id}("${label}")\n`;
271
+ if (i > 0) {
272
+ const prevId = `T${this.thoughtHistory[i - 1].thoughtNumber}`;
273
+ if (t.branchFromThought) {
274
+ diagram += ` T${t.branchFromThought} -->|branch: ${t.branchId}| ${id}\n`;
275
+ }
276
+ else {
277
+ diagram += ` ${prevId} --> ${id}\n`;
278
+ }
279
+ }
280
+ });
281
+ return diagram;
282
+ }
239
283
  }
@@ -99,4 +99,26 @@ You MUST:
99
99
  };
100
100
  }
101
101
  });
102
+ // 13. search_thoughts
103
+ server.tool("search_thoughts", "Search through the thinking history to recall specific details or past decisions.", {
104
+ query: z.string().describe("The search term or keyword to look for")
105
+ }, async ({ query }) => {
106
+ try {
107
+ const results = await thinkingServer.searchHistory(query);
108
+ return {
109
+ content: [{
110
+ type: "text",
111
+ text: results.length > 0
112
+ ? `Found ${results.length} matches:\n${JSON.stringify(results, null, 2)}`
113
+ : `No matches found for "${query}"`
114
+ }]
115
+ };
116
+ }
117
+ catch (error) {
118
+ return {
119
+ content: [{ type: "text", text: `Search Error: ${error instanceof Error ? error.message : String(error)}` }],
120
+ isError: true
121
+ };
122
+ }
123
+ });
102
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotza02/sequential-thinking",
3
- "version": "2026.2.14",
3
+ "version": "2026.2.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },