@gotza02/sequential-thinking 10000.1.7 → 10000.1.8
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/analyzers/ComplexityCalculator.d.ts +15 -0
- package/dist/analyzers/ComplexityCalculator.js +59 -0
- package/dist/analyzers/QualityAnalyzer.d.ts +25 -0
- package/dist/analyzers/QualityAnalyzer.js +89 -0
- package/dist/analyzers/RefactoringEngine.d.ts +20 -0
- package/dist/analyzers/RefactoringEngine.js +107 -0
- package/dist/analyzers/SymbolAnalyzer.d.ts +30 -0
- package/dist/analyzers/SymbolAnalyzer.js +123 -0
- package/dist/analyzers/index.d.ts +8 -0
- package/dist/analyzers/index.js +4 -0
- package/dist/coding.test.js +4 -0
- package/dist/dashboard/index.html +95 -0
- package/dist/dashboard/server.js +1 -1
- package/dist/graph.d.ts +0 -6
- package/dist/graph.js +9 -265
- package/dist/intelligent-code.d.ts +2 -68
- package/dist/intelligent-code.js +10 -364
- package/dist/lib.d.ts +42 -0
- package/dist/lib.js +308 -237
- package/dist/parsers/GenericParser.d.ts +6 -0
- package/dist/parsers/GenericParser.js +52 -0
- package/dist/parsers/GoParser.d.ts +6 -0
- package/dist/parsers/GoParser.js +36 -0
- package/dist/parsers/JavaParser.d.ts +6 -0
- package/dist/parsers/JavaParser.js +32 -0
- package/dist/parsers/PythonParser.d.ts +6 -0
- package/dist/parsers/PythonParser.js +50 -0
- package/dist/parsers/RustParser.d.ts +6 -0
- package/dist/parsers/RustParser.js +33 -0
- package/dist/parsers/TypeScriptParser.d.ts +9 -0
- package/dist/parsers/TypeScriptParser.js +85 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/parsers/index.js +6 -0
- package/dist/tools/sports/tools/match.js +2 -2
- package/dist/tools/web.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
export class GoParser {
|
|
3
|
+
async parse(filePath) {
|
|
4
|
+
try {
|
|
5
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
6
|
+
const imports = [];
|
|
7
|
+
const symbols = [];
|
|
8
|
+
// Single line: import "fmt"
|
|
9
|
+
const singleImportMatches = content.matchAll(/import\s+"([^"]+)"/g);
|
|
10
|
+
for (const match of singleImportMatches)
|
|
11
|
+
imports.push(match[1]);
|
|
12
|
+
// Block: import ( "fmt"; "os" )
|
|
13
|
+
const blockImportMatches = content.matchAll(/import\s+\(([\s\S]*?)\)/g);
|
|
14
|
+
for (const match of blockImportMatches) {
|
|
15
|
+
const block = match[1];
|
|
16
|
+
const innerMatches = block.matchAll(/"([^"]+)"/g);
|
|
17
|
+
for (const im of innerMatches)
|
|
18
|
+
imports.push(im[1]);
|
|
19
|
+
}
|
|
20
|
+
// Go symbols
|
|
21
|
+
const funcMatches = content.matchAll(/^func\s+(?:\([^\)]*\)\s+)?([a-zA-Z_][a-zA-Z0-9_]*)/gm);
|
|
22
|
+
for (const match of funcMatches)
|
|
23
|
+
symbols.push(`func:${match[1]}`);
|
|
24
|
+
const typeMatches = content.matchAll(/^type\s+([A-Z][a-zA-Z0-9_]*)\s+(?:struct|interface)/gm);
|
|
25
|
+
for (const match of typeMatches)
|
|
26
|
+
symbols.push(`type:${match[1]}`);
|
|
27
|
+
return { imports, symbols };
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(`Error parsing Go file ${filePath}:`, error);
|
|
31
|
+
return { imports: [], symbols: [] };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const goParser = new GoParser();
|
|
36
|
+
export default goParser;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
export class JavaParser {
|
|
3
|
+
async parse(filePath) {
|
|
4
|
+
try {
|
|
5
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
6
|
+
const imports = [];
|
|
7
|
+
const symbols = [];
|
|
8
|
+
// import package.Class;
|
|
9
|
+
const importMatches = content.matchAll(/^import\s+([^;]+);/gm);
|
|
10
|
+
for (const match of importMatches)
|
|
11
|
+
imports.push(match[1].trim());
|
|
12
|
+
// package declaration
|
|
13
|
+
const pkgMatch = content.match(/^package\s+([^;]+);/m);
|
|
14
|
+
if (pkgMatch)
|
|
15
|
+
symbols.push(`package:${pkgMatch[1]}`);
|
|
16
|
+
// public class/interface/enum
|
|
17
|
+
const classMatches = content.matchAll(/^public\s+(?:static\s+)?(?:final\s+)?(?:abstract\s+)?(class|interface|enum|record)\s+([A-Z][A-Za-z0-9_]*)/gm);
|
|
18
|
+
for (const match of classMatches)
|
|
19
|
+
symbols.push(`${match[1]}:${match[2]}`);
|
|
20
|
+
// public methods
|
|
21
|
+
const methodMatches = content.matchAll(/^public\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:\w+(?:<[^>]+>)?)\s+([a-z][a-zA-Z0-9_]*)\s*\(/gm);
|
|
22
|
+
for (const match of methodMatches)
|
|
23
|
+
symbols.push(`method:${match[1]}`);
|
|
24
|
+
return { imports, symbols };
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return { imports: [], symbols: [] };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const javaParser = new JavaParser();
|
|
32
|
+
export default javaParser;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
export class PythonParser {
|
|
3
|
+
async parse(filePath) {
|
|
4
|
+
try {
|
|
5
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
6
|
+
const imports = [];
|
|
7
|
+
const symbols = [];
|
|
8
|
+
// Python imports with better regex
|
|
9
|
+
const simpleImportMatches = content.matchAll(/^\s*import\s+([^#\n]+)/gm);
|
|
10
|
+
for (const match of simpleImportMatches) {
|
|
11
|
+
match[1].split(',').forEach(s => {
|
|
12
|
+
const clean = s.trim().split(/\s+/)[0];
|
|
13
|
+
if (clean && !clean.startsWith('.'))
|
|
14
|
+
imports.push(clean);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
// from . import x, from ..package import y
|
|
18
|
+
const fromImportMatches = content.matchAll(/^\s*from\s+([.\w]+)\s+import/gm);
|
|
19
|
+
for (const match of fromImportMatches) {
|
|
20
|
+
let imp = match[1];
|
|
21
|
+
if (imp.startsWith('.')) {
|
|
22
|
+
const matchDots = imp.match(/^(\.+)(.*)/);
|
|
23
|
+
if (matchDots) {
|
|
24
|
+
const dots = matchDots[1].length;
|
|
25
|
+
const name = matchDots[2];
|
|
26
|
+
if (dots === 1)
|
|
27
|
+
imp = `./${name}`;
|
|
28
|
+
else
|
|
29
|
+
imp = `${'../'.repeat(dots - 1)}${name}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
imports.push(imp);
|
|
33
|
+
}
|
|
34
|
+
// Python symbols (skip underscored/private)
|
|
35
|
+
const funcMatches = content.matchAll(/^def\s+([a-zA-Z_][a-zA-Z0-9_]*)/gm);
|
|
36
|
+
for (const match of funcMatches)
|
|
37
|
+
symbols.push(`def:${match[1]}`);
|
|
38
|
+
const classMatches = content.matchAll(/^class\s+([a-zA-Z_][a-zA-Z0-9_]*)/gm);
|
|
39
|
+
for (const match of classMatches)
|
|
40
|
+
symbols.push(`class:${match[1]}`);
|
|
41
|
+
return { imports, symbols };
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error(`Error parsing Python file ${filePath}:`, error);
|
|
45
|
+
return { imports: [], symbols: [] };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const pythonParser = new PythonParser();
|
|
50
|
+
export default pythonParser;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
export class RustParser {
|
|
3
|
+
async parse(filePath) {
|
|
4
|
+
try {
|
|
5
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
6
|
+
const imports = [];
|
|
7
|
+
const symbols = [];
|
|
8
|
+
// use crate::module::item;
|
|
9
|
+
const useMatches = content.matchAll(/^use\s+([^;]+);/gm);
|
|
10
|
+
for (const match of useMatches) {
|
|
11
|
+
imports.push(match[1].trim());
|
|
12
|
+
}
|
|
13
|
+
// mod statement
|
|
14
|
+
const modMatches = content.matchAll(/^mod\s+([a-z][a-z0-9_]*)/gm);
|
|
15
|
+
for (const match of modMatches)
|
|
16
|
+
symbols.push(`mod:${match[1]}`);
|
|
17
|
+
// pub fn / pub struct / pub enum / pub trait
|
|
18
|
+
const pubMatches = content.matchAll(/^pub\s+(fn|struct|enum|trait)\s+([A-Za-z][A-Za-z0-9_]*)/gm);
|
|
19
|
+
for (const match of pubMatches)
|
|
20
|
+
symbols.push(`${match[1]}:${match[2]}`);
|
|
21
|
+
// impl blocks
|
|
22
|
+
const implMatches = content.matchAll(/^impl\s+([A-Z][A-Za-z0-9_]*)/gm);
|
|
23
|
+
for (const match of implMatches)
|
|
24
|
+
symbols.push(`impl:${match[1]}`);
|
|
25
|
+
return { imports, symbols };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return { imports: [], symbols: [] };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const rustParser = new RustParser();
|
|
33
|
+
export default rustParser;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ParseResult {
|
|
2
|
+
imports: string[];
|
|
3
|
+
symbols: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare class TypeScriptParser {
|
|
6
|
+
parse(filePath: string): Promise<ParseResult>;
|
|
7
|
+
}
|
|
8
|
+
export declare const typeScriptParser: TypeScriptParser;
|
|
9
|
+
export default typeScriptParser;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
export class TypeScriptParser {
|
|
4
|
+
async parse(filePath) {
|
|
5
|
+
try {
|
|
6
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
7
|
+
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
8
|
+
const imports = [];
|
|
9
|
+
const symbols = [];
|
|
10
|
+
const visit = (node) => {
|
|
11
|
+
// --- Symbols (Exports) ---
|
|
12
|
+
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
13
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
14
|
+
if (isExported)
|
|
15
|
+
symbols.push(`function:${node.name.text}`);
|
|
16
|
+
}
|
|
17
|
+
else if (ts.isClassDeclaration(node) && node.name) {
|
|
18
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
19
|
+
if (isExported)
|
|
20
|
+
symbols.push(`class:${node.name.text}`);
|
|
21
|
+
}
|
|
22
|
+
else if (ts.isInterfaceDeclaration(node) && node.name) {
|
|
23
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
24
|
+
if (isExported)
|
|
25
|
+
symbols.push(`interface:${node.name.text}`);
|
|
26
|
+
}
|
|
27
|
+
else if (ts.isTypeAliasDeclaration(node) && node.name) {
|
|
28
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
29
|
+
if (isExported)
|
|
30
|
+
symbols.push(`type:${node.name.text}`);
|
|
31
|
+
}
|
|
32
|
+
else if (ts.isEnumDeclaration(node) && node.name) {
|
|
33
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
34
|
+
if (isExported)
|
|
35
|
+
symbols.push(`enum:${node.name.text}`);
|
|
36
|
+
}
|
|
37
|
+
else if (ts.isVariableStatement(node)) {
|
|
38
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
39
|
+
if (isExported) {
|
|
40
|
+
node.declarationList.declarations.forEach(d => {
|
|
41
|
+
if (ts.isIdentifier(d.name))
|
|
42
|
+
symbols.push(`var:${d.name.text}`);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// --- Imports ---
|
|
47
|
+
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
48
|
+
if (node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
49
|
+
imports.push(node.moduleSpecifier.text);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (ts.isCallExpression(node)) {
|
|
53
|
+
if (node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments.length > 0) {
|
|
54
|
+
const arg = node.arguments[0];
|
|
55
|
+
if (ts.isStringLiteral(arg)) {
|
|
56
|
+
imports.push(arg.text);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (ts.isIdentifier(node.expression) && node.expression.text === 'require' && node.arguments.length > 0) {
|
|
60
|
+
const arg = node.arguments[0];
|
|
61
|
+
if (ts.isStringLiteral(arg)) {
|
|
62
|
+
imports.push(arg.text);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (ts.isImportEqualsDeclaration(node)) {
|
|
67
|
+
if (ts.isExternalModuleReference(node.moduleReference)) {
|
|
68
|
+
if (ts.isStringLiteral(node.moduleReference.expression)) {
|
|
69
|
+
imports.push(node.moduleReference.expression.text);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
ts.forEachChild(node, visit);
|
|
74
|
+
};
|
|
75
|
+
visit(sourceFile);
|
|
76
|
+
return { imports, symbols };
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error(`Error parsing TypeScript file ${filePath}:`, error);
|
|
80
|
+
return { imports: [], symbols: [] };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export const typeScriptParser = new TypeScriptParser();
|
|
85
|
+
export default typeScriptParser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { TypeScriptParser, typeScriptParser } from './TypeScriptParser.js';
|
|
2
|
+
export { PythonParser, pythonParser } from './PythonParser.js';
|
|
3
|
+
export { GoParser, goParser } from './GoParser.js';
|
|
4
|
+
export { RustParser, rustParser } from './RustParser.js';
|
|
5
|
+
export { JavaParser, javaParser } from './JavaParser.js';
|
|
6
|
+
export { GenericParser, genericParser } from './GenericParser.js';
|
|
7
|
+
export type { ParseResult } from './TypeScriptParser.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TypeScriptParser, typeScriptParser } from './TypeScriptParser.js';
|
|
2
|
+
export { PythonParser, pythonParser } from './PythonParser.js';
|
|
3
|
+
export { GoParser, goParser } from './GoParser.js';
|
|
4
|
+
export { RustParser, rustParser } from './RustParser.js';
|
|
5
|
+
export { JavaParser, javaParser } from './JavaParser.js';
|
|
6
|
+
export { GenericParser, genericParser } from './GenericParser.js';
|
|
@@ -337,12 +337,12 @@ async function scrapeContentWithErrorHandling(url, type) {
|
|
|
337
337
|
return scrapedContent.data || '';
|
|
338
338
|
}
|
|
339
339
|
else {
|
|
340
|
-
return
|
|
340
|
+
return `${type.charAt(0).toUpperCase() + type.slice(1)} scrape failed: ${scrapedContent.error}`;
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
catch (scrapeError) {
|
|
344
344
|
const errorMsg = scrapeError instanceof Error ? scrapeError.message : String(scrapeError);
|
|
345
|
-
return
|
|
345
|
+
return `${type.charAt(0).toUpperCase() + type.slice(1)} scrape failed: ${errorMsg}`;
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
/**
|
package/dist/tools/web.js
CHANGED
|
@@ -96,13 +96,16 @@ export function registerWebTools(server) {
|
|
|
96
96
|
}, async ({ query, provider }) => {
|
|
97
97
|
const errors = [];
|
|
98
98
|
// 1. Identify available providers
|
|
99
|
-
|
|
99
|
+
// Priority: API providers first, then HTML scraping fallback
|
|
100
|
+
const availableProviders = [];
|
|
100
101
|
if (process.env.BRAVE_API_KEY)
|
|
101
102
|
availableProviders.push('brave');
|
|
102
103
|
if (process.env.EXA_API_KEY)
|
|
103
104
|
availableProviders.push('exa');
|
|
104
105
|
if (process.env.GOOGLE_SEARCH_API_KEY && process.env.GOOGLE_SEARCH_CX)
|
|
105
106
|
availableProviders.push('google');
|
|
107
|
+
// Always add duckduckgo as last resort (HTML scraping)
|
|
108
|
+
availableProviders.push('duckduckgo');
|
|
106
109
|
if (availableProviders.length === 0) {
|
|
107
110
|
return {
|
|
108
111
|
content: [{ type: "text", text: "Error: No search provider configured. Please set BRAVE_API_KEY, EXA_API_KEY, or GOOGLE_SEARCH_API_KEY." }],
|