@defai.digital/ax-cli 3.14.8 → 3.14.10
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 +21 -2
- package/dist/analyzers/ast/index.d.ts +2 -4
- package/dist/analyzers/ast/index.js +2 -4
- package/dist/analyzers/ast/index.js.map +1 -1
- package/dist/analyzers/ast/language-parser.d.ts +4 -3
- package/dist/analyzers/ast/language-parser.js +29 -2
- package/dist/analyzers/ast/language-parser.js.map +1 -1
- package/dist/analyzers/ast/multi-language-parser.d.ts +13 -31
- package/dist/analyzers/ast/multi-language-parser.js +25 -143
- package/dist/analyzers/ast/multi-language-parser.js.map +1 -1
- package/dist/checkpoint/manager.d.ts +1 -0
- package/dist/checkpoint/manager.js +81 -15
- package/dist/checkpoint/manager.js.map +1 -1
- package/dist/checkpoint/storage.js +22 -4
- package/dist/checkpoint/storage.js.map +1 -1
- package/dist/planner/types.d.ts +2 -2
- package/dist/schemas/tool-schemas.d.ts +12 -12
- package/package.json +2 -4
- package/dist/analyzers/ast/tree-sitter-parser.d.ts +0 -134
- package/dist/analyzers/ast/tree-sitter-parser.js +0 -730
- package/dist/analyzers/ast/tree-sitter-parser.js.map +0 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ ax-cli
|
|
|
49
49
|
- [Security](#security)
|
|
50
50
|
- [Architecture](#architecture)
|
|
51
51
|
- [Changelog](#changelog)
|
|
52
|
-
- [Recent Changes (v3.14.
|
|
52
|
+
- [Recent Changes (v3.14.10)](#recent-changes-v31410)
|
|
53
53
|
- [Documentation](#documentation)
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -404,7 +404,26 @@ Email: **security@defai.digital** (private disclosure)
|
|
|
404
404
|
|
|
405
405
|
---
|
|
406
406
|
|
|
407
|
-
## Recent Changes (v3.14.
|
|
407
|
+
## Recent Changes (v3.14.10)
|
|
408
|
+
|
|
409
|
+
### Security Fix
|
|
410
|
+
|
|
411
|
+
- **MCP SDK Update**: Updated `@modelcontextprotocol/sdk` from 1.22.0 to 1.24.0 to fix DNS rebinding protection vulnerability (GHSA-w48q-cv73-mx4w)
|
|
412
|
+
|
|
413
|
+
## Previous Changes (v3.14.9)
|
|
414
|
+
|
|
415
|
+
### AST Parser Simplification
|
|
416
|
+
|
|
417
|
+
- **Removed tree-sitter Dependency**: Simplified AST parsing to focus on TypeScript/JavaScript via ts-morph, reducing dependencies and complexity
|
|
418
|
+
- **Extended Language Detection**: Added file extension detection for Java, Ruby, PHP, Kotlin, Dart, C#, JSON, YAML, and TOML
|
|
419
|
+
|
|
420
|
+
### Checkpoint System Improvements
|
|
421
|
+
|
|
422
|
+
- **File Integrity Verification**: Added hash verification before restoring checkpoint files to detect corruption
|
|
423
|
+
- **Configuration Validation**: Improved validation for `pruneAfterDays` and `compressAfterDays` settings
|
|
424
|
+
- **Error Isolation**: Maintenance operations now continue even if individual stages fail
|
|
425
|
+
|
|
426
|
+
## Previous Changes (v3.14.8)
|
|
408
427
|
|
|
409
428
|
### CI/CD Improvements
|
|
410
429
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AST Analysis Module
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
5
|
-
* Supports
|
|
4
|
+
* Provides AST parsing and traversal utilities.
|
|
5
|
+
* Supports TypeScript and JavaScript via ts-morph.
|
|
6
6
|
*/
|
|
7
7
|
export { ASTParser } from './parser.js';
|
|
8
8
|
export { MultiLanguageParser, getMultiLanguageParser, resetMultiLanguageParser } from './multi-language-parser.js';
|
|
9
|
-
export { TreeSitterParser, createTreeSitterParser, TREE_SITTER_LANGUAGES } from './tree-sitter-parser.js';
|
|
10
|
-
export type { TreeSitterLanguage } from './tree-sitter-parser.js';
|
|
11
9
|
export { getLanguageFromPath, EXTENSION_TO_LANGUAGE, BaseLanguageParser } from './language-parser.js';
|
|
12
10
|
export type { SupportedLanguage, LanguageParser } from './language-parser.js';
|
|
13
11
|
export * from './types.js';
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AST Analysis Module
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
5
|
-
* Supports
|
|
4
|
+
* Provides AST parsing and traversal utilities.
|
|
5
|
+
* Supports TypeScript and JavaScript via ts-morph.
|
|
6
6
|
*/
|
|
7
7
|
// Core parsers
|
|
8
8
|
export { ASTParser } from './parser.js';
|
|
9
9
|
export { MultiLanguageParser, getMultiLanguageParser, resetMultiLanguageParser } from './multi-language-parser.js';
|
|
10
|
-
// Tree-sitter support
|
|
11
|
-
export { TreeSitterParser, createTreeSitterParser, TREE_SITTER_LANGUAGES } from './tree-sitter-parser.js';
|
|
12
10
|
// Language detection
|
|
13
11
|
export { getLanguageFromPath, EXTENSION_TO_LANGUAGE, BaseLanguageParser } from './language-parser.js';
|
|
14
12
|
// Types and utilities
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/analyzers/ast/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEnH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/analyzers/ast/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEnH,qBAAqB;AACrB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGtG,sBAAsB;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Language Parser Interface
|
|
3
3
|
*
|
|
4
|
-
* Defines the common interface for
|
|
5
|
-
*
|
|
4
|
+
* Defines the common interface for language parsers.
|
|
5
|
+
* Currently only TypeScript/JavaScript are fully supported via ts-morph.
|
|
6
|
+
* Other languages are detected but return empty AST info.
|
|
6
7
|
*/
|
|
7
8
|
import type { FileASTInfo } from './types.js';
|
|
8
9
|
/**
|
|
9
10
|
* Supported programming languages
|
|
10
11
|
*/
|
|
11
|
-
export type SupportedLanguage = 'typescript' | 'javascript' | 'python' | 'rust' | 'go' | 'c' | 'cpp' | 'swift' | 'html' | 'css' | 'unknown';
|
|
12
|
+
export type SupportedLanguage = 'typescript' | 'javascript' | 'python' | 'rust' | 'go' | 'c' | 'cpp' | 'swift' | 'html' | 'css' | 'java' | 'ruby' | 'php' | 'kotlin' | 'dart' | 'csharp' | 'json' | 'yaml' | 'toml' | 'unknown';
|
|
12
13
|
/**
|
|
13
14
|
* Map file extensions to languages
|
|
14
15
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Language Parser Interface
|
|
3
3
|
*
|
|
4
|
-
* Defines the common interface for
|
|
5
|
-
*
|
|
4
|
+
* Defines the common interface for language parsers.
|
|
5
|
+
* Currently only TypeScript/JavaScript are fully supported via ts-morph.
|
|
6
|
+
* Other languages are detected but return empty AST info.
|
|
6
7
|
*/
|
|
7
8
|
/**
|
|
8
9
|
* Map file extensions to languages
|
|
@@ -45,6 +46,32 @@ export const EXTENSION_TO_LANGUAGE = {
|
|
|
45
46
|
'.scss': 'css',
|
|
46
47
|
'.sass': 'css',
|
|
47
48
|
'.less': 'css',
|
|
49
|
+
// Java
|
|
50
|
+
'.java': 'java',
|
|
51
|
+
// Ruby
|
|
52
|
+
'.rb': 'ruby',
|
|
53
|
+
'.rake': 'ruby',
|
|
54
|
+
'.gemspec': 'ruby',
|
|
55
|
+
// PHP
|
|
56
|
+
'.php': 'php',
|
|
57
|
+
'.phtml': 'php',
|
|
58
|
+
'.php3': 'php',
|
|
59
|
+
'.php4': 'php',
|
|
60
|
+
'.php5': 'php',
|
|
61
|
+
'.phps': 'php',
|
|
62
|
+
// Kotlin
|
|
63
|
+
'.kt': 'kotlin',
|
|
64
|
+
'.kts': 'kotlin',
|
|
65
|
+
// Dart
|
|
66
|
+
'.dart': 'dart',
|
|
67
|
+
// C#
|
|
68
|
+
'.cs': 'csharp',
|
|
69
|
+
// Config files
|
|
70
|
+
'.json': 'json',
|
|
71
|
+
'.jsonc': 'json',
|
|
72
|
+
'.yaml': 'yaml',
|
|
73
|
+
'.yml': 'yaml',
|
|
74
|
+
'.toml': 'toml',
|
|
48
75
|
};
|
|
49
76
|
/**
|
|
50
77
|
* Get language from file path
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-parser.js","sourceRoot":"","sources":["../../../src/analyzers/ast/language-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"language-parser.js","sourceRoot":"","sources":["../../../src/analyzers/ast/language-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsC;IACtE,aAAa;IACb,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,aAAa;IACb,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,SAAS;IACT,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,OAAO;IACP,KAAK,EAAE,MAAM;IACb,KAAK;IACL,KAAK,EAAE,IAAI;IACX,IAAI;IACJ,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,MAAM;IACN,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,K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AA8C;IAChD,CAAC;IAED;;OAEG;IACO,kBAAkB,CAAC,QAAgB;QAC3C,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,QAAQ;YACR,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,UAAU,EAAE,CAAC;SACd,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-Language Parser Facade
|
|
3
3
|
*
|
|
4
|
-
* Unified interface for parsing
|
|
5
|
-
* Uses ts-morph for
|
|
6
|
-
*
|
|
4
|
+
* Unified interface for parsing TypeScript/JavaScript files.
|
|
5
|
+
* Uses ts-morph for accurate type-aware parsing.
|
|
6
|
+
*
|
|
7
|
+
* Note: Previously supported 30+ languages via tree-sitter.
|
|
8
|
+
* Simplified to focus on TypeScript/JavaScript (the primary use case).
|
|
9
|
+
* For other languages, use language-specific tools.
|
|
7
10
|
*/
|
|
8
|
-
import { TreeSitterParser } from './tree-sitter-parser.js';
|
|
9
11
|
import { type SupportedLanguage } from './language-parser.js';
|
|
10
12
|
import type { FileASTInfo } from './types.js';
|
|
11
13
|
import type { SourceFile } from 'ts-morph';
|
|
12
|
-
export { TreeSitterParser };
|
|
13
14
|
/**
|
|
14
15
|
* Multi-language parser facade
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* - Python/Rust/Go: tree-sitter (fast, universal)
|
|
17
|
+
* Currently supports TypeScript/JavaScript via ts-morph.
|
|
18
|
+
* Returns empty AST info for unsupported languages.
|
|
19
19
|
*/
|
|
20
20
|
export declare class MultiLanguageParser {
|
|
21
21
|
/**
|
|
@@ -34,36 +34,17 @@ export declare class MultiLanguageParser {
|
|
|
34
34
|
* Parse TypeScript/JavaScript content using ts-morph
|
|
35
35
|
*/
|
|
36
36
|
private parseTypeScriptContent;
|
|
37
|
-
/**
|
|
38
|
-
* Parse file using tree-sitter
|
|
39
|
-
*/
|
|
40
|
-
private parseTreeSitterFile;
|
|
41
|
-
/**
|
|
42
|
-
* Parse content using tree-sitter
|
|
43
|
-
*/
|
|
44
|
-
private parseTreeSitterContent;
|
|
45
|
-
/**
|
|
46
|
-
* Try to use tree-sitter as fallback for unknown file types
|
|
47
|
-
*/
|
|
48
|
-
private tryTreeSitterFallback;
|
|
49
37
|
/**
|
|
50
38
|
* Check if a language is supported
|
|
51
39
|
*/
|
|
52
40
|
supports(filePath: string): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Check if tree-sitter has a grammar for this file type
|
|
55
|
-
*/
|
|
56
|
-
private hasTreeSitterFallback;
|
|
57
41
|
/**
|
|
58
42
|
* Get the language for a file path
|
|
59
43
|
*/
|
|
60
44
|
getLanguage(filePath: string): SupportedLanguage;
|
|
61
45
|
/**
|
|
62
46
|
* Get ts-morph SourceFile for TypeScript/JavaScript files
|
|
63
|
-
* Returns null for other languages
|
|
64
|
-
*
|
|
65
|
-
* Note: This is useful for advanced analysis that requires semantic information
|
|
66
|
-
* like finding references, type checking, etc. For basic AST info, use parseFile.
|
|
47
|
+
* Returns null for other languages
|
|
67
48
|
*/
|
|
68
49
|
getSourceFile(filePath: string): SourceFile | null;
|
|
69
50
|
/**
|
|
@@ -71,11 +52,12 @@ export declare class MultiLanguageParser {
|
|
|
71
52
|
*/
|
|
72
53
|
supportsSemanticAnalysis(filePath: string): boolean;
|
|
73
54
|
/**
|
|
74
|
-
* Get list of
|
|
55
|
+
* Get list of supported languages
|
|
75
56
|
*/
|
|
76
57
|
getSupportedLanguages(): SupportedLanguage[];
|
|
77
58
|
/**
|
|
78
|
-
* Get list of all parseable languages
|
|
59
|
+
* Get list of all parseable languages
|
|
60
|
+
* (Same as getSupportedLanguages after tree-sitter removal)
|
|
79
61
|
*/
|
|
80
62
|
getAllParseableLanguages(): string[];
|
|
81
63
|
/**
|
|
@@ -83,7 +65,7 @@ export declare class MultiLanguageParser {
|
|
|
83
65
|
*/
|
|
84
66
|
private createEmptyASTInfo;
|
|
85
67
|
/**
|
|
86
|
-
* Clear
|
|
68
|
+
* Clear cached parser and free memory
|
|
87
69
|
*/
|
|
88
70
|
dispose(): void;
|
|
89
71
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-Language Parser Facade
|
|
3
3
|
*
|
|
4
|
-
* Unified interface for parsing
|
|
5
|
-
* Uses ts-morph for
|
|
6
|
-
*
|
|
4
|
+
* Unified interface for parsing TypeScript/JavaScript files.
|
|
5
|
+
* Uses ts-morph for accurate type-aware parsing.
|
|
6
|
+
*
|
|
7
|
+
* Note: Previously supported 30+ languages via tree-sitter.
|
|
8
|
+
* Simplified to focus on TypeScript/JavaScript (the primary use case).
|
|
9
|
+
* For other languages, use language-specific tools.
|
|
7
10
|
*/
|
|
8
11
|
import { ASTParser } from './parser.js';
|
|
9
|
-
import { TreeSitterParser, createTreeSitterParser, TREE_SITTER_LANGUAGES } from './tree-sitter-parser.js';
|
|
10
12
|
import { getLanguageFromPath } from './language-parser.js';
|
|
11
|
-
// Re-export for convenience
|
|
12
|
-
export { TreeSitterParser };
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Singleton ts-morph parser
|
|
15
15
|
*/
|
|
16
|
-
const parserCache = new Map();
|
|
17
16
|
let tsMorphParser = null;
|
|
18
17
|
/**
|
|
19
18
|
* Get or create the ts-morph parser (singleton)
|
|
@@ -24,24 +23,11 @@ function getTsMorphParser() {
|
|
|
24
23
|
}
|
|
25
24
|
return tsMorphParser;
|
|
26
25
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Get or create a tree-sitter parser for a language
|
|
29
|
-
*/
|
|
30
|
-
function getTreeSitterParser(language) {
|
|
31
|
-
const cached = parserCache.get(language);
|
|
32
|
-
if (cached && cached instanceof TreeSitterParser) {
|
|
33
|
-
return cached;
|
|
34
|
-
}
|
|
35
|
-
const parser = createTreeSitterParser(language);
|
|
36
|
-
parserCache.set(language, parser);
|
|
37
|
-
return parser;
|
|
38
|
-
}
|
|
39
26
|
/**
|
|
40
27
|
* Multi-language parser facade
|
|
41
28
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* - Python/Rust/Go: tree-sitter (fast, universal)
|
|
29
|
+
* Currently supports TypeScript/JavaScript via ts-morph.
|
|
30
|
+
* Returns empty AST info for unsupported languages.
|
|
45
31
|
*/
|
|
46
32
|
export class MultiLanguageParser {
|
|
47
33
|
/**
|
|
@@ -49,44 +35,21 @@ export class MultiLanguageParser {
|
|
|
49
35
|
*/
|
|
50
36
|
async parseFile(filePath) {
|
|
51
37
|
const language = getLanguageFromPath(filePath);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
case 'javascript':
|
|
55
|
-
return this.parseTypeScriptFile(filePath);
|
|
56
|
-
case 'python':
|
|
57
|
-
case 'rust':
|
|
58
|
-
case 'go':
|
|
59
|
-
case 'c':
|
|
60
|
-
case 'cpp':
|
|
61
|
-
case 'swift':
|
|
62
|
-
case 'html':
|
|
63
|
-
case 'css':
|
|
64
|
-
return this.parseTreeSitterFile(filePath, language);
|
|
65
|
-
default:
|
|
66
|
-
// Try tree-sitter as fallback for unknown languages
|
|
67
|
-
return this.tryTreeSitterFallback(filePath);
|
|
38
|
+
if (language === 'typescript' || language === 'javascript') {
|
|
39
|
+
return this.parseTypeScriptFile(filePath);
|
|
68
40
|
}
|
|
41
|
+
// Unsupported language - return empty AST
|
|
42
|
+
return this.createEmptyASTInfo(filePath);
|
|
69
43
|
}
|
|
70
44
|
/**
|
|
71
45
|
* Parse content directly with specified language
|
|
72
46
|
*/
|
|
73
47
|
async parseContent(content, language, filePath = 'temp') {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
case 'javascript':
|
|
77
|
-
return this.parseTypeScriptContent(content, filePath);
|
|
78
|
-
case 'python':
|
|
79
|
-
case 'rust':
|
|
80
|
-
case 'go':
|
|
81
|
-
case 'c':
|
|
82
|
-
case 'cpp':
|
|
83
|
-
case 'swift':
|
|
84
|
-
case 'html':
|
|
85
|
-
case 'css':
|
|
86
|
-
return this.parseTreeSitterContent(content, language, filePath);
|
|
87
|
-
default:
|
|
88
|
-
return this.createEmptyASTInfo(filePath);
|
|
48
|
+
if (language === 'typescript' || language === 'javascript') {
|
|
49
|
+
return this.parseTypeScriptContent(content, filePath);
|
|
89
50
|
}
|
|
51
|
+
// Unsupported language - return empty AST
|
|
52
|
+
return this.createEmptyASTInfo(filePath);
|
|
90
53
|
}
|
|
91
54
|
/**
|
|
92
55
|
* Parse TypeScript/JavaScript file using ts-morph
|
|
@@ -102,84 +65,12 @@ export class MultiLanguageParser {
|
|
|
102
65
|
const parser = getTsMorphParser();
|
|
103
66
|
return parser.parseContent(content, filePath);
|
|
104
67
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Parse file using tree-sitter
|
|
107
|
-
*/
|
|
108
|
-
async parseTreeSitterFile(filePath, language) {
|
|
109
|
-
const parser = getTreeSitterParser(language);
|
|
110
|
-
return parser.parseFile(filePath);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Parse content using tree-sitter
|
|
114
|
-
*/
|
|
115
|
-
async parseTreeSitterContent(content, language, filePath) {
|
|
116
|
-
const parser = getTreeSitterParser(language);
|
|
117
|
-
return parser.parseContent(content, filePath);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Try to use tree-sitter as fallback for unknown file types
|
|
121
|
-
*/
|
|
122
|
-
async tryTreeSitterFallback(filePath) {
|
|
123
|
-
// Extract extension and check if tree-sitter supports it
|
|
124
|
-
const ext = filePath.slice(filePath.lastIndexOf('.') + 1).toLowerCase();
|
|
125
|
-
// Map common extensions to tree-sitter language names
|
|
126
|
-
const extToTreeSitter = {
|
|
127
|
-
'html': 'html',
|
|
128
|
-
'htm': 'html',
|
|
129
|
-
'css': 'css',
|
|
130
|
-
'scss': 'scss',
|
|
131
|
-
'json': 'json',
|
|
132
|
-
'yaml': 'yaml',
|
|
133
|
-
'yml': 'yaml',
|
|
134
|
-
'toml': 'toml',
|
|
135
|
-
'md': 'markdown',
|
|
136
|
-
'c': 'c',
|
|
137
|
-
'h': 'c',
|
|
138
|
-
'cpp': 'cpp',
|
|
139
|
-
'cc': 'cpp',
|
|
140
|
-
'cxx': 'cpp',
|
|
141
|
-
'hpp': 'cpp',
|
|
142
|
-
'java': 'java',
|
|
143
|
-
'kt': 'kotlin',
|
|
144
|
-
'kts': 'kotlin',
|
|
145
|
-
'swift': 'swift',
|
|
146
|
-
'rb': 'ruby',
|
|
147
|
-
'php': 'php',
|
|
148
|
-
'lua': 'lua',
|
|
149
|
-
'sh': 'bash',
|
|
150
|
-
'bash': 'bash',
|
|
151
|
-
'zsh': 'bash',
|
|
152
|
-
'sql': 'sql',
|
|
153
|
-
'vue': 'vue',
|
|
154
|
-
'svelte': 'svelte',
|
|
155
|
-
};
|
|
156
|
-
const treeSitterLang = extToTreeSitter[ext];
|
|
157
|
-
if (treeSitterLang && TREE_SITTER_LANGUAGES.includes(treeSitterLang)) {
|
|
158
|
-
try {
|
|
159
|
-
// Create a specialized tree-sitter parser
|
|
160
|
-
const parser = new TreeSitterParser('unknown', treeSitterLang);
|
|
161
|
-
return parser.parseFile(filePath);
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
// Fallback to empty AST
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return this.createEmptyASTInfo(filePath);
|
|
168
|
-
}
|
|
169
68
|
/**
|
|
170
69
|
* Check if a language is supported
|
|
171
70
|
*/
|
|
172
71
|
supports(filePath) {
|
|
173
72
|
const language = getLanguageFromPath(filePath);
|
|
174
|
-
return language
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Check if tree-sitter has a grammar for this file type
|
|
178
|
-
*/
|
|
179
|
-
hasTreeSitterFallback(filePath) {
|
|
180
|
-
const ext = filePath.slice(filePath.lastIndexOf('.') + 1).toLowerCase();
|
|
181
|
-
const fallbackExts = ['html', 'css', 'json', 'yaml', 'yml', 'toml', 'c', 'cpp', 'java', 'kt', 'swift', 'rb', 'php', 'lua', 'sh', 'bash', 'sql', 'vue'];
|
|
182
|
-
return fallbackExts.includes(ext);
|
|
73
|
+
return language === 'typescript' || language === 'javascript';
|
|
183
74
|
}
|
|
184
75
|
/**
|
|
185
76
|
* Get the language for a file path
|
|
@@ -189,10 +80,7 @@ export class MultiLanguageParser {
|
|
|
189
80
|
}
|
|
190
81
|
/**
|
|
191
82
|
* Get ts-morph SourceFile for TypeScript/JavaScript files
|
|
192
|
-
* Returns null for other languages
|
|
193
|
-
*
|
|
194
|
-
* Note: This is useful for advanced analysis that requires semantic information
|
|
195
|
-
* like finding references, type checking, etc. For basic AST info, use parseFile.
|
|
83
|
+
* Returns null for other languages
|
|
196
84
|
*/
|
|
197
85
|
getSourceFile(filePath) {
|
|
198
86
|
const language = getLanguageFromPath(filePath);
|
|
@@ -209,19 +97,17 @@ export class MultiLanguageParser {
|
|
|
209
97
|
return language === 'typescript' || language === 'javascript';
|
|
210
98
|
}
|
|
211
99
|
/**
|
|
212
|
-
* Get list of
|
|
100
|
+
* Get list of supported languages
|
|
213
101
|
*/
|
|
214
102
|
getSupportedLanguages() {
|
|
215
|
-
return ['typescript', 'javascript'
|
|
103
|
+
return ['typescript', 'javascript'];
|
|
216
104
|
}
|
|
217
105
|
/**
|
|
218
|
-
* Get list of all parseable languages
|
|
106
|
+
* Get list of all parseable languages
|
|
107
|
+
* (Same as getSupportedLanguages after tree-sitter removal)
|
|
219
108
|
*/
|
|
220
109
|
getAllParseableLanguages() {
|
|
221
|
-
return [
|
|
222
|
-
...this.getSupportedLanguages(),
|
|
223
|
-
'json', 'yaml', 'toml', 'java', 'kotlin', 'ruby', 'php', 'lua', 'bash', 'sql', 'vue',
|
|
224
|
-
];
|
|
110
|
+
return ['typescript', 'javascript'];
|
|
225
111
|
}
|
|
226
112
|
/**
|
|
227
113
|
* Create empty AST info
|
|
@@ -237,13 +123,9 @@ export class MultiLanguageParser {
|
|
|
237
123
|
});
|
|
238
124
|
}
|
|
239
125
|
/**
|
|
240
|
-
* Clear
|
|
126
|
+
* Clear cached parser and free memory
|
|
241
127
|
*/
|
|
242
128
|
dispose() {
|
|
243
|
-
for (const parser of parserCache.values()) {
|
|
244
|
-
parser.dispose();
|
|
245
|
-
}
|
|
246
|
-
parserCache.clear();
|
|
247
129
|
if (tsMorphParser) {
|
|
248
130
|
tsMorphParser.clear();
|
|
249
131
|
tsMorphParser = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-language-parser.js","sourceRoot":"","sources":["../../../src/analyzers/ast/multi-language-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"multi-language-parser.js","sourceRoot":"","sources":["../../../src/analyzers/ast/multi-language-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,sBAAsB,CAAC;AAInF;;GAEG;AACH,IAAI,aAAa,GAAqB,IAAI,CAAC;AAE3C;;GAEG;AACH,SAAS,gBAAgB;IACvB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,QAAgB;QAC9B,MAAM,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC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AAC;QAChC,2BAA2B,CAAC,OAAO,EAAE,CAAC;QACtC,2BAA2B,GAAG,IAAI,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -79,6 +79,7 @@ export declare class CheckpointManager {
|
|
|
79
79
|
shouldCreateCheckpoint(operation: string): boolean;
|
|
80
80
|
/**
|
|
81
81
|
* Update configuration
|
|
82
|
+
* Note: storageDir changes are rejected as they require re-initialization
|
|
82
83
|
*/
|
|
83
84
|
updateConfig(config: Partial<CheckpointConfig>): void;
|
|
84
85
|
/**
|