@gotza02/sequential-thinking 2026.1.18 → 2026.1.19
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/graph.js +18 -1
- package/dist/graph.test.js +33 -0
- package/package.json +2 -2
package/dist/graph.js
CHANGED
|
@@ -78,14 +78,31 @@ export class ProjectKnowledgeGraph {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
async resolvePath(dir, relativePath) {
|
|
81
|
-
const extensions = ['', '.ts', '.js', '.tsx', '.jsx', '.json', '/index.ts', '/index.js'];
|
|
82
81
|
const absolutePath = path.resolve(dir, relativePath);
|
|
82
|
+
// 1. Try exact match
|
|
83
|
+
if (this.nodes.has(absolutePath)) {
|
|
84
|
+
return absolutePath;
|
|
85
|
+
}
|
|
86
|
+
// 2. Try appending extensions
|
|
87
|
+
const extensions = ['.ts', '.js', '.tsx', '.jsx', '.json', '/index.ts', '/index.js'];
|
|
83
88
|
for (const ext of extensions) {
|
|
84
89
|
const p = absolutePath + ext;
|
|
85
90
|
if (this.nodes.has(p)) {
|
|
86
91
|
return p;
|
|
87
92
|
}
|
|
88
93
|
}
|
|
94
|
+
// 3. Try handling .js -> .ts mapping (ESM style imports)
|
|
95
|
+
if (absolutePath.endsWith('.js')) {
|
|
96
|
+
const tsPath = absolutePath.replace(/\.js$/, '.ts');
|
|
97
|
+
if (this.nodes.has(tsPath))
|
|
98
|
+
return tsPath;
|
|
99
|
+
const tsxPath = absolutePath.replace(/\.js$/, '.tsx');
|
|
100
|
+
if (this.nodes.has(tsxPath))
|
|
101
|
+
return tsxPath;
|
|
102
|
+
const jsxPath = absolutePath.replace(/\.js$/, '.jsx');
|
|
103
|
+
if (this.nodes.has(jsxPath))
|
|
104
|
+
return jsxPath;
|
|
105
|
+
}
|
|
89
106
|
return null;
|
|
90
107
|
}
|
|
91
108
|
getRelationships(filePath) {
|
package/dist/graph.test.js
CHANGED
|
@@ -43,4 +43,37 @@ describe('ProjectKnowledgeGraph', () => {
|
|
|
43
43
|
expect(relationships?.imports).toContain('utils.ts');
|
|
44
44
|
expect(relationships?.imports).not.toContain('oldUtils.ts');
|
|
45
45
|
});
|
|
46
|
+
it('should resolve .js imports to .ts files', async () => {
|
|
47
|
+
const mockContentIndex = `import { something } from './lib.js';`;
|
|
48
|
+
fs.readdir.mockResolvedValue([
|
|
49
|
+
{ name: 'index.ts', isDirectory: () => false },
|
|
50
|
+
{ name: 'lib.ts', isDirectory: () => false }
|
|
51
|
+
]);
|
|
52
|
+
fs.readFile.mockImplementation(async (filePath) => {
|
|
53
|
+
if (filePath.endsWith('index.ts'))
|
|
54
|
+
return mockContentIndex;
|
|
55
|
+
return '';
|
|
56
|
+
});
|
|
57
|
+
await graph.build('/app');
|
|
58
|
+
const relationships = graph.getRelationships('/app/index.ts');
|
|
59
|
+
// The output of getRelationships.imports is relative paths.
|
|
60
|
+
// If imports ./lib.js, and we have lib.ts, it should resolve to /app/lib.ts
|
|
61
|
+
// And path.relative('/app', '/app/lib.ts') is 'lib.ts'
|
|
62
|
+
expect(relationships?.imports).toContain('lib.ts');
|
|
63
|
+
});
|
|
64
|
+
it('should resolve .js imports to .jsx files', async () => {
|
|
65
|
+
const mockContentIndex = `import { Button } from './Button.js';`;
|
|
66
|
+
fs.readdir.mockResolvedValue([
|
|
67
|
+
{ name: 'index.js', isDirectory: () => false },
|
|
68
|
+
{ name: 'Button.jsx', isDirectory: () => false }
|
|
69
|
+
]);
|
|
70
|
+
fs.readFile.mockImplementation(async (filePath) => {
|
|
71
|
+
if (filePath.endsWith('index.js'))
|
|
72
|
+
return mockContentIndex;
|
|
73
|
+
return '';
|
|
74
|
+
});
|
|
75
|
+
await graph.build('/app');
|
|
76
|
+
const relationships = graph.getRelationships('/app/index.js');
|
|
77
|
+
expect(relationships?.imports).toContain('Button.jsx');
|
|
78
|
+
});
|
|
46
79
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gotza02/sequential-thinking",
|
|
3
|
-
"version": "2026.1.
|
|
3
|
+
"version": "2026.1.19",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"bugs": "https://github.com/modelcontextprotocol/servers/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/modelcontextprotocol/servers.git"
|
|
15
|
+
"url": "git+https://github.com/modelcontextprotocol/servers.git"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"bin": {
|