@gotza02/sequential-thinking 2026.1.17 → 2026.1.18

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
@@ -127,6 +127,13 @@ npm run build
127
127
  npm test
128
128
  ```
129
129
 
130
+ ## Recent Updates (v2026.1.18)
131
+
132
+ - **Bug Fixes**:
133
+ - Fixed an issue where commented-out imports were incorrectly parsed by the graph analyzer.
134
+ - Resolved a branching logic issue where branch IDs could collide.
135
+ - Fixed version mismatch between package.json and server instance.
136
+
130
137
  ## License
131
138
 
132
139
  This MCP server is licensed under the MIT License.
package/dist/graph.js CHANGED
@@ -45,7 +45,12 @@ export class ProjectKnowledgeGraph {
45
45
  }
46
46
  async parseFile(filePath) {
47
47
  try {
48
- const content = await fs.readFile(filePath, 'utf-8');
48
+ let content = await fs.readFile(filePath, 'utf-8');
49
+ // Remove comments before parsing imports
50
+ // 1. Remove block comments /* ... */
51
+ content = content.replace(/\/\*[\s\S]*?\*\//g, '');
52
+ // 2. Remove line comments // ...
53
+ content = content.replace(/\/\/.*$/gm, '');
49
54
  const importRegex = /import\s+(?:[\w\s{},*]+from\s+)?['"]([^'"]+)['"]/g;
50
55
  const dynamicImportRegex = /import\(['"]([^'"]+)['"]\)/g;
51
56
  const requireRegex = /require\(['"]([^'"]+)['"]\)/g;
@@ -0,0 +1,46 @@
1
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
2
+ import { ProjectKnowledgeGraph } from './graph.js';
3
+ import * as fs from 'fs/promises';
4
+ vi.mock('fs/promises');
5
+ describe('ProjectKnowledgeGraph', () => {
6
+ let graph;
7
+ beforeEach(() => {
8
+ graph = new ProjectKnowledgeGraph();
9
+ vi.resetAllMocks();
10
+ });
11
+ it('should ignore imports in comments', async () => {
12
+ const mockFiles = ['/app/index.ts', '/app/utils.ts', '/app/oldUtils.ts'];
13
+ const mockContentIndex = `
14
+ import { something } from './utils';
15
+ // import { oldThing } from './oldUtils';
16
+ /* import { other } from './other' */
17
+ `;
18
+ const mockContentUtils = 'export const something = 1;';
19
+ fs.readdir.mockResolvedValue([
20
+ { name: 'index.ts', isDirectory: () => false },
21
+ { name: 'utils.ts', isDirectory: () => false },
22
+ { name: 'oldUtils.ts', isDirectory: () => false }
23
+ ]);
24
+ fs.readFile.mockImplementation(async (path) => {
25
+ if (path.includes('index.ts'))
26
+ return mockContentIndex;
27
+ return '';
28
+ });
29
+ // Mock resolvePath behavior indirectly by mocking existing files check in graph.build logic
30
+ // But since graph.ts uses fs.readdir recursively, we need to mock that structure.
31
+ // For simplicity in this unit test, we'll mock 'getAllFiles' if it were public,
32
+ // but since it's private, we have to mock fs structure carefully or rely on the implementation.
33
+ // Let's rely on the fact that build calls getAllFiles which calls readdir.
34
+ // We need to ensure 'utils.ts' and 'oldUtils.ts' resolution is tested.
35
+ // Actually, since we mock readFile, the file existence check in resolvePath uses "this.nodes.has".
36
+ // "this.nodes" is populated by getAllFiles.
37
+ // So we need getAllFiles to return both index.ts and utils.ts.
38
+ // And NOT oldUtils.ts so we can see if it tries to resolve it?
39
+ // Actually, if it tries to resolve 'oldUtils', it might fail if not in nodes.
40
+ // But the bug is that it SHOULD NOT even try to resolve 'oldUtils' because it's commented out.
41
+ await graph.build('/app');
42
+ const relationships = graph.getRelationships('/app/index.ts');
43
+ expect(relationships?.imports).toContain('utils.ts');
44
+ expect(relationships?.imports).not.toContain('oldUtils.ts');
45
+ });
46
+ });
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { ProjectKnowledgeGraph } from './graph.js';
10
10
  const execAsync = promisify(exec);
11
11
  const server = new McpServer({
12
12
  name: "sequential-thinking-server",
13
- version: "0.2.0",
13
+ version: "2026.1.18",
14
14
  });
15
15
  const thinkingServer = new SequentialThinkingServer();
16
16
  const knowledgeGraph = new ProjectKnowledgeGraph();
package/dist/lib.js CHANGED
@@ -59,10 +59,11 @@ export class SequentialThinkingServer {
59
59
  }
60
60
  this.thoughtHistory.push(input);
61
61
  if (input.branchFromThought && input.branchId) {
62
- if (!this.branches[input.branchId]) {
63
- this.branches[input.branchId] = [];
62
+ const branchKey = `${input.branchFromThought}-${input.branchId}`;
63
+ if (!this.branches[branchKey]) {
64
+ this.branches[branchKey] = [];
64
65
  }
65
- this.branches[input.branchId].push(input);
66
+ this.branches[branchKey].push(input);
66
67
  }
67
68
  if (!this.disableThoughtLogging) {
68
69
  const formattedThought = this.formatThought(input);
@@ -39,7 +39,7 @@ describe('SequentialThinkingServer', () => {
39
39
  };
40
40
  const result1 = server.processThought(branch1Input);
41
41
  const content1 = JSON.parse(result1.content[0].text);
42
- expect(content1.branches).toContain("branch-A");
42
+ expect(content1.branches).toContain("1-branch-A");
43
43
  // Branch 2
44
44
  const branch2Input = {
45
45
  thought: "Alternative B",
@@ -52,7 +52,7 @@ describe('SequentialThinkingServer', () => {
52
52
  };
53
53
  const result2 = server.processThought(branch2Input);
54
54
  const content2 = JSON.parse(result2.content[0].text);
55
- expect(content2.branches).toContain("branch-B");
55
+ expect(content2.branches).toContain("1-branch-B");
56
56
  expect(content2.branches.length).toBe(2);
57
57
  });
58
58
  it('should handle evaluation with scores', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotza02/sequential-thinking",
3
- "version": "2026.1.17",
3
+ "version": "2026.1.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },