@gotza02/sequential-thinking 2026.2.16 → 2026.2.17
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/coding.test.js +23 -3
- package/dist/tools/coding.js +6 -2
- package/package.json +1 -1
package/dist/coding.test.js
CHANGED
|
@@ -28,15 +28,35 @@ describe('Deep Coding Tools', () => {
|
|
|
28
28
|
vi.restoreAllMocks();
|
|
29
29
|
});
|
|
30
30
|
describe('deep_code_analyze', () => {
|
|
31
|
-
it('should return error if file is not in graph', async () => {
|
|
31
|
+
it('should return error if file is not in graph after rebuild', async () => {
|
|
32
32
|
registerCodingTools(mockServer, mockGraph);
|
|
33
33
|
const handler = registeredTools['deep_code_analyze'];
|
|
34
34
|
mockGraph.getDeepContext.mockReturnValue(null);
|
|
35
|
+
mockGraph.build = vi.fn().mockResolvedValue({});
|
|
35
36
|
const result = await handler({ filePath: 'unknown.ts' });
|
|
37
|
+
expect(mockGraph.build).toHaveBeenCalled();
|
|
36
38
|
expect(result.isError).toBe(true);
|
|
37
|
-
expect(result.content[0].text).toContain('not found in graph');
|
|
39
|
+
expect(result.content[0].text).toContain('not found in graph even after rebuilding');
|
|
38
40
|
});
|
|
39
|
-
it('should
|
|
41
|
+
it('should rebuild graph and succeed if file is found on retry', async () => {
|
|
42
|
+
registerCodingTools(mockServer, mockGraph);
|
|
43
|
+
const handler = registeredTools['deep_code_analyze'];
|
|
44
|
+
// First call returns null, second call returns context
|
|
45
|
+
mockGraph.getDeepContext
|
|
46
|
+
.mockReturnValueOnce(null)
|
|
47
|
+
.mockReturnValueOnce({
|
|
48
|
+
targetFile: { path: 'src/target.ts', symbols: ['MyClass'] },
|
|
49
|
+
dependencies: [],
|
|
50
|
+
dependents: []
|
|
51
|
+
});
|
|
52
|
+
mockGraph.build = vi.fn().mockResolvedValue({});
|
|
53
|
+
fs.readFile.mockResolvedValue('const a = 1;');
|
|
54
|
+
const result = await handler({ filePath: 'src/target.ts' });
|
|
55
|
+
expect(mockGraph.build).toHaveBeenCalled();
|
|
56
|
+
expect(result.isError).toBeUndefined();
|
|
57
|
+
expect(result.content[0].text).toContain('CODEBASE CONTEXT DOCUMENT');
|
|
58
|
+
});
|
|
59
|
+
it('should return context document when file exists immediately', async () => {
|
|
40
60
|
registerCodingTools(mockServer, mockGraph);
|
|
41
61
|
const handler = registeredTools['deep_code_analyze'];
|
|
42
62
|
// Setup mock data
|
package/dist/tools/coding.js
CHANGED
|
@@ -11,9 +11,13 @@ export function registerCodingTools(server, graph) {
|
|
|
11
11
|
try {
|
|
12
12
|
// Ensure path is safe before checking graph
|
|
13
13
|
validatePath(filePath);
|
|
14
|
-
|
|
14
|
+
let context = graph.getDeepContext(filePath);
|
|
15
15
|
if (!context) {
|
|
16
|
-
|
|
16
|
+
await graph.build(process.cwd());
|
|
17
|
+
context = graph.getDeepContext(filePath);
|
|
18
|
+
if (!context) {
|
|
19
|
+
return { content: [{ type: "text", text: `Error: File '${filePath}' not found in graph even after rebuilding. Please check the path.` }], isError: true };
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
const fileContent = await fs.readFile(path.resolve(filePath), 'utf-8');
|
|
19
23
|
let doc = `--- CODEBASE CONTEXT DOCUMENT: ${filePath} ---\n\n`;
|