@compilr-dev/agents-coding-ts 0.1.3 → 0.1.5
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/LICENSE +95 -8
- package/README.md +4 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +14 -4
- package/dist/parser/index.d.ts +2 -2
- package/dist/parser/index.js +1 -1
- package/dist/parser/typescript-parser.d.ts +2 -2
- package/dist/parser/typescript-parser.js +77 -54
- package/dist/skills/code-health.js +5 -5
- package/dist/skills/code-structure.js +5 -5
- package/dist/skills/dependency-audit.js +5 -5
- package/dist/skills/index.d.ts +7 -7
- package/dist/skills/index.js +11 -11
- package/dist/skills/refactor-impact.js +5 -5
- package/dist/skills/type-analysis.js +5 -5
- package/dist/tools/find-dead-code.d.ts +2 -2
- package/dist/tools/find-dead-code.js +82 -58
- package/dist/tools/find-duplicates.d.ts +2 -2
- package/dist/tools/find-duplicates.js +41 -38
- package/dist/tools/find-implementations.d.ts +2 -2
- package/dist/tools/find-implementations.js +44 -36
- package/dist/tools/find-patterns.d.ts +2 -2
- package/dist/tools/find-patterns.js +154 -148
- package/dist/tools/find-references.d.ts +2 -2
- package/dist/tools/find-references.js +76 -72
- package/dist/tools/find-symbol.d.ts +2 -2
- package/dist/tools/find-symbol.js +106 -96
- package/dist/tools/get-call-graph.d.ts +2 -2
- package/dist/tools/get-call-graph.js +52 -47
- package/dist/tools/get-complexity.d.ts +2 -2
- package/dist/tools/get-complexity.js +94 -46
- package/dist/tools/get-dependency-graph.d.ts +2 -2
- package/dist/tools/get-dependency-graph.js +66 -52
- package/dist/tools/get-documentation.d.ts +2 -2
- package/dist/tools/get-documentation.js +154 -122
- package/dist/tools/get-exports.d.ts +2 -2
- package/dist/tools/get-exports.js +73 -61
- package/dist/tools/get-file-structure.d.ts +2 -2
- package/dist/tools/get-file-structure.js +16 -16
- package/dist/tools/get-imports.d.ts +2 -2
- package/dist/tools/get-imports.js +46 -46
- package/dist/tools/get-signature.d.ts +2 -2
- package/dist/tools/get-signature.js +168 -124
- package/dist/tools/get-type-hierarchy.d.ts +2 -2
- package/dist/tools/get-type-hierarchy.js +53 -44
- package/dist/tools/index.d.ts +18 -16
- package/dist/tools/index.js +17 -15
- package/dist/tools/read-symbol.d.ts +62 -0
- package/dist/tools/read-symbol.js +464 -0
- package/dist/tools/types.d.ts +27 -27
- package/package.json +8 -8
package/LICENSE
CHANGED
|
@@ -1,13 +1,100 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
Functional Source License, Version 1.1, MIT Future License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Abbreviation: FSL-1.1-MIT
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Notice
|
|
6
|
+
|
|
7
|
+
Copyright 2026 Carmelo Scozzola
|
|
8
|
+
|
|
9
|
+
Terms and Conditions
|
|
10
|
+
|
|
11
|
+
Licensor ("We")
|
|
12
|
+
|
|
13
|
+
The party offering the Software under these Terms and Conditions.
|
|
14
|
+
|
|
15
|
+
The Software
|
|
16
|
+
|
|
17
|
+
The "Software" is each version of the software that we make available under
|
|
18
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
19
|
+
Conditions with the Software.
|
|
20
|
+
|
|
21
|
+
License Grant
|
|
22
|
+
|
|
23
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
24
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
25
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
26
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
27
|
+
|
|
28
|
+
Permitted Purpose
|
|
29
|
+
|
|
30
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
31
|
+
means making the Software available to others in a commercial product or
|
|
32
|
+
service that:
|
|
33
|
+
|
|
34
|
+
1. substitutes for the Software;
|
|
35
|
+
|
|
36
|
+
2. substitutes for any other product or service we offer using the Software
|
|
37
|
+
that exists as of the date we make the Software available; or
|
|
38
|
+
|
|
39
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
40
|
+
|
|
41
|
+
Permitted Purposes specifically include using the Software:
|
|
42
|
+
|
|
43
|
+
1. for your internal use and access;
|
|
44
|
+
|
|
45
|
+
2. for non-commercial education;
|
|
46
|
+
|
|
47
|
+
3. for non-commercial research; and
|
|
48
|
+
|
|
49
|
+
4. in connection with professional services that you provide to a licensee
|
|
50
|
+
using the Software in accordance with these Terms and Conditions.
|
|
51
|
+
|
|
52
|
+
Patents
|
|
53
|
+
|
|
54
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
55
|
+
patents, the license grant above includes a license under our patents. If you
|
|
56
|
+
make a claim against any party that the Software infringes or contributes to
|
|
57
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
58
|
+
immediately.
|
|
59
|
+
|
|
60
|
+
Redistribution
|
|
61
|
+
|
|
62
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
63
|
+
the Software.
|
|
64
|
+
|
|
65
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
66
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
67
|
+
remove any copyright notices provided in or with the Software.
|
|
68
|
+
|
|
69
|
+
Disclaimer
|
|
70
|
+
|
|
71
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
72
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
73
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
74
|
+
|
|
75
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
76
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
77
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
78
|
+
|
|
79
|
+
Trademarks
|
|
80
|
+
|
|
81
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
82
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
83
|
+
trademarks, trade names, service marks or product names.
|
|
84
|
+
|
|
85
|
+
Grant of Future License
|
|
86
|
+
|
|
87
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
88
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
89
|
+
the Software available. On or after that date, you may use the Software under
|
|
90
|
+
the MIT license, in which case the following will apply:
|
|
91
|
+
|
|
92
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
93
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
94
|
+
the Software without restriction, including without limitation the rights to
|
|
95
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
96
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
97
|
+
so, subject to the following conditions:
|
|
11
98
|
|
|
12
99
|
The above copyright notice and this permission notice shall be included in all
|
|
13
100
|
copies or substantial portions of the Software.
|
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript/JavaScript analysis tools for AI agents - AST-based code analysis using the TypeScript Compiler API.
|
|
4
4
|
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> This package is in beta. APIs may change between minor versions.
|
|
7
|
+
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
7
10
|
```bash
|
|
@@ -46,4 +49,4 @@ agent.registerSkills(tsSkills);
|
|
|
46
49
|
|
|
47
50
|
## License
|
|
48
51
|
|
|
49
|
-
MIT
|
|
52
|
+
[FSL-1.1-MIT](https://fsl.software/) - See [LICENSE](LICENSE) for details. Converts to MIT after 2 years per version.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* TypeScript/JavaScript analysis tools for AI coding agents.
|
|
5
5
|
* Provides AST-based code analysis, complexity metrics, and type hierarchy tools.
|
|
6
6
|
*/
|
|
7
|
-
export { parseTypeScript, detectLanguage, isLanguageSupported, } from
|
|
8
|
-
export { getFileStructureTool, createGetFileStructureTool, findSymbolTool, createFindSymbolTool, findReferencesTool, createFindReferencesTool, getImportsTool, createGetImportsTool, getExportsTool, createGetExportsTool, getCallGraphTool, createGetCallGraphTool, getDependencyGraphTool, createGetDependencyGraphTool, findImplementationsTool, createFindImplementationsTool, getTypeHierarchyTool, createGetTypeHierarchyTool, getComplexityTool, createGetComplexityTool, findDeadCodeTool, createFindDeadCodeTool, findDuplicatesTool, createFindDuplicatesTool, findPatternsTool, createFindPatternsTool, getSignatureTool, createGetSignatureTool, getDocumentationTool, createGetDocumentationTool, } from
|
|
9
|
-
export type { SupportedLanguage, ParameterInfo, GetFileStructureInput, FileStructure, ImportInfo, ExportInfo, ClassInfo, FunctionInfo, MethodInfo, PropertyInfo, VariableInfo, TypeDefinitionInfo, FileStats, SymbolKind, SymbolKindFilter, FindSymbolInput, FindSymbolResult, SymbolDefinition, SearchStats, ReferenceType, FindReferencesInput, FindReferencesResult, Reference, FileReferences, GetImportsInput, GetImportsResult, DetailedImport, ImportedSymbol, TransitiveImport, ImportStats, GetExportsInput, GetExportsResult, ExportedSymbol, ExportKind, ReExport, ExportStats, CallGraphDirection, CallType, GetCallGraphInput, GetCallGraphResult, FunctionNode, CallInfo, CallGraphNode, CallGraphStats, GetDependencyGraphInput, GetDependencyGraphResult, ModuleNode, DependencyEdge, CircularDependency, DependencyGraphStats, FindImplementationsInput, FindImplementationsResult, ImplementationInfo, HierarchyDirection, GetTypeHierarchyInput, GetTypeHierarchyResult, TypeHierarchyNode, GetComplexityInput, GetComplexityResult, FileComplexity, FunctionComplexity, ComplexityContributor, ComplexityContributorType, FindDeadCodeInput, FindDeadCodeResult, DeadCodeItem, FindDuplicatesInput, FindDuplicatesResult, DuplicateGroup, CodeLocation, FindPatternsInput, FindPatternsResult, PatternMatch, CodePattern, GetSignatureInput, GetSignatureResult, ParameterDetail, TypeDetail, GenericDetail, Documentation, MemberSignature, SignatureSymbolKind, GetDocumentationInput, GetDocumentationResult, FileDocumentation, DocumentedSymbol, DocumentationSymbolKind, ExtractorOptions, } from
|
|
10
|
-
export { codeStructureSkill, dependencyAuditSkill, refactorImpactSkill, typeAnalysisSkill, codeHealthSkill, tsSkills, defineSkill, type Skill, } from
|
|
7
|
+
export { parseTypeScript, detectLanguage, isLanguageSupported, } from "./parser/index.js";
|
|
8
|
+
export { getFileStructureTool, createGetFileStructureTool, findSymbolTool, createFindSymbolTool, findReferencesTool, createFindReferencesTool, getImportsTool, createGetImportsTool, getExportsTool, createGetExportsTool, getCallGraphTool, createGetCallGraphTool, getDependencyGraphTool, createGetDependencyGraphTool, findImplementationsTool, createFindImplementationsTool, getTypeHierarchyTool, createGetTypeHierarchyTool, getComplexityTool, createGetComplexityTool, findDeadCodeTool, createFindDeadCodeTool, findDuplicatesTool, createFindDuplicatesTool, findPatternsTool, createFindPatternsTool, getSignatureTool, createGetSignatureTool, getDocumentationTool, createGetDocumentationTool, readFunctionTool, readClassTool, readTypeTool, createReadFunctionTool, createReadClassTool, createReadTypeTool, } from "./tools/index.js";
|
|
9
|
+
export type { SupportedLanguage, ParameterInfo, GetFileStructureInput, FileStructure, ImportInfo, ExportInfo, ClassInfo, FunctionInfo, MethodInfo, PropertyInfo, VariableInfo, TypeDefinitionInfo, FileStats, SymbolKind, SymbolKindFilter, FindSymbolInput, FindSymbolResult, SymbolDefinition, SearchStats, ReferenceType, FindReferencesInput, FindReferencesResult, Reference, FileReferences, GetImportsInput, GetImportsResult, DetailedImport, ImportedSymbol, TransitiveImport, ImportStats, GetExportsInput, GetExportsResult, ExportedSymbol, ExportKind, ReExport, ExportStats, CallGraphDirection, CallType, GetCallGraphInput, GetCallGraphResult, FunctionNode, CallInfo, CallGraphNode, CallGraphStats, GetDependencyGraphInput, GetDependencyGraphResult, ModuleNode, DependencyEdge, CircularDependency, DependencyGraphStats, FindImplementationsInput, FindImplementationsResult, ImplementationInfo, HierarchyDirection, GetTypeHierarchyInput, GetTypeHierarchyResult, TypeHierarchyNode, GetComplexityInput, GetComplexityResult, FileComplexity, FunctionComplexity, ComplexityContributor, ComplexityContributorType, FindDeadCodeInput, FindDeadCodeResult, DeadCodeItem, FindDuplicatesInput, FindDuplicatesResult, DuplicateGroup, CodeLocation, FindPatternsInput, FindPatternsResult, PatternMatch, CodePattern, GetSignatureInput, GetSignatureResult, ParameterDetail, TypeDetail, GenericDetail, Documentation, MemberSignature, SignatureSymbolKind, GetDocumentationInput, GetDocumentationResult, FileDocumentation, DocumentedSymbol, DocumentationSymbolKind, ExtractorOptions, ReadFunctionInput, ReadClassInput, ReadTypeInput, ReadSymbolResult, } from "./tools/index.js";
|
|
10
|
+
export { codeStructureSkill, dependencyAuditSkill, refactorImpactSkill, typeAnalysisSkill, codeHealthSkill, tsSkills, defineSkill, type Skill, } from "./skills/index.js";
|
|
11
11
|
/**
|
|
12
12
|
* All TypeScript/JavaScript analysis tools for easy registration
|
|
13
13
|
*/
|
|
@@ -27,8 +27,11 @@ export declare const tsTools: {
|
|
|
27
27
|
readonly findPatterns: import("@compilr-dev/agents").Tool<import("./tools/types.js").FindPatternsInput>;
|
|
28
28
|
readonly getSignature: import("@compilr-dev/agents").Tool<import("./tools/types.js").GetSignatureInput>;
|
|
29
29
|
readonly getDocumentation: import("@compilr-dev/agents").Tool<import("./tools/types.js").GetDocumentationInput>;
|
|
30
|
+
readonly readFunction: import("@compilr-dev/agents").Tool<import("./tools/read-symbol.js").ReadFunctionInput>;
|
|
31
|
+
readonly readClass: import("@compilr-dev/agents").Tool<import("./tools/read-symbol.js").ReadClassInput>;
|
|
32
|
+
readonly readType: import("@compilr-dev/agents").Tool<import("./tools/read-symbol.js").ReadTypeInput>;
|
|
30
33
|
};
|
|
31
34
|
/**
|
|
32
35
|
* Array of all TypeScript/JavaScript analysis tools
|
|
33
36
|
*/
|
|
34
|
-
export declare const allTsTools: readonly [import("@compilr-dev/agents").Tool<import("./tools/types.js").GetFileStructureInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindSymbolInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindReferencesInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetImportsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetExportsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetCallGraphInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetDependencyGraphInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindImplementationsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetTypeHierarchyInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetComplexityInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindDeadCodeInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindDuplicatesInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindPatternsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetSignatureInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetDocumentationInput>];
|
|
37
|
+
export declare const allTsTools: readonly [import("@compilr-dev/agents").Tool<import("./tools/types.js").GetFileStructureInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindSymbolInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindReferencesInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetImportsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetExportsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetCallGraphInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetDependencyGraphInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindImplementationsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetTypeHierarchyInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetComplexityInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindDeadCodeInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindDuplicatesInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").FindPatternsInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetSignatureInput>, import("@compilr-dev/agents").Tool<import("./tools/types.js").GetDocumentationInput>, import("@compilr-dev/agents").Tool<import("./tools/read-symbol.js").ReadFunctionInput>, import("@compilr-dev/agents").Tool<import("./tools/read-symbol.js").ReadClassInput>, import("@compilr-dev/agents").Tool<import("./tools/read-symbol.js").ReadTypeInput>];
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Provides AST-based code analysis, complexity metrics, and type hierarchy tools.
|
|
6
6
|
*/
|
|
7
7
|
// Parser exports
|
|
8
|
-
export { parseTypeScript, detectLanguage, isLanguageSupported, } from
|
|
8
|
+
export { parseTypeScript, detectLanguage, isLanguageSupported, } from "./parser/index.js";
|
|
9
9
|
// Tool exports
|
|
10
10
|
export {
|
|
11
11
|
// Tier 1 & 2 Tools
|
|
@@ -13,11 +13,13 @@ getFileStructureTool, createGetFileStructureTool, findSymbolTool, createFindSymb
|
|
|
13
13
|
// Tier 3 Tools
|
|
14
14
|
getComplexityTool, createGetComplexityTool, findDeadCodeTool, createFindDeadCodeTool, findDuplicatesTool, createFindDuplicatesTool, findPatternsTool, createFindPatternsTool,
|
|
15
15
|
// Tier 4 Utility Tools
|
|
16
|
-
getSignatureTool, createGetSignatureTool, getDocumentationTool, createGetDocumentationTool,
|
|
16
|
+
getSignatureTool, createGetSignatureTool, getDocumentationTool, createGetDocumentationTool,
|
|
17
|
+
// Smart File Reading Tools
|
|
18
|
+
readFunctionTool, readClassTool, readTypeTool, createReadFunctionTool, createReadClassTool, createReadTypeTool, } from "./tools/index.js";
|
|
17
19
|
// Skill exports
|
|
18
|
-
export { codeStructureSkill, dependencyAuditSkill, refactorImpactSkill, typeAnalysisSkill, codeHealthSkill, tsSkills, defineSkill, } from
|
|
20
|
+
export { codeStructureSkill, dependencyAuditSkill, refactorImpactSkill, typeAnalysisSkill, codeHealthSkill, tsSkills, defineSkill, } from "./skills/index.js";
|
|
19
21
|
// Tool imports for collections
|
|
20
|
-
import { getFileStructureTool, findSymbolTool, findReferencesTool, getImportsTool, getExportsTool, getCallGraphTool, getDependencyGraphTool, findImplementationsTool, getTypeHierarchyTool, getComplexityTool, findDeadCodeTool, findDuplicatesTool, findPatternsTool, getSignatureTool, getDocumentationTool, } from
|
|
22
|
+
import { getFileStructureTool, findSymbolTool, findReferencesTool, getImportsTool, getExportsTool, getCallGraphTool, getDependencyGraphTool, findImplementationsTool, getTypeHierarchyTool, getComplexityTool, findDeadCodeTool, findDuplicatesTool, findPatternsTool, getSignatureTool, getDocumentationTool, readFunctionTool, readClassTool, readTypeTool, } from "./tools/index.js";
|
|
21
23
|
/**
|
|
22
24
|
* All TypeScript/JavaScript analysis tools for easy registration
|
|
23
25
|
*/
|
|
@@ -40,6 +42,10 @@ export const tsTools = {
|
|
|
40
42
|
// Tier 4
|
|
41
43
|
getSignature: getSignatureTool,
|
|
42
44
|
getDocumentation: getDocumentationTool,
|
|
45
|
+
// Smart File Reading
|
|
46
|
+
readFunction: readFunctionTool,
|
|
47
|
+
readClass: readClassTool,
|
|
48
|
+
readType: readTypeTool,
|
|
43
49
|
};
|
|
44
50
|
/**
|
|
45
51
|
* Array of all TypeScript/JavaScript analysis tools
|
|
@@ -63,4 +69,8 @@ export const allTsTools = [
|
|
|
63
69
|
// Tier 4
|
|
64
70
|
getSignatureTool,
|
|
65
71
|
getDocumentationTool,
|
|
72
|
+
// Smart File Reading
|
|
73
|
+
readFunctionTool,
|
|
74
|
+
readClassTool,
|
|
75
|
+
readTypeTool,
|
|
66
76
|
];
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides AST parsing capabilities using the TypeScript Compiler API.
|
|
5
5
|
*/
|
|
6
|
-
export { parseTypeScript, detectLanguage, isLanguageSupported, } from
|
|
7
|
-
export type { SupportedLanguage } from
|
|
6
|
+
export { parseTypeScript, detectLanguage, isLanguageSupported, } from "./typescript-parser.js";
|
|
7
|
+
export type { SupportedLanguage } from "../tools/types.js";
|
package/dist/parser/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides AST parsing capabilities using the TypeScript Compiler API.
|
|
5
5
|
*/
|
|
6
|
-
export { parseTypeScript, detectLanguage, isLanguageSupported, } from
|
|
6
|
+
export { parseTypeScript, detectLanguage, isLanguageSupported, } from "./typescript-parser.js";
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Uses TypeScript's built-in parser for accurate AST analysis.
|
|
5
5
|
* Works for both TypeScript and JavaScript files.
|
|
6
6
|
*/
|
|
7
|
-
import type { FileStructure, ExtractorOptions, SupportedLanguage } from
|
|
7
|
+
import type { FileStructure, ExtractorOptions, SupportedLanguage } from "../tools/types.js";
|
|
8
8
|
/**
|
|
9
9
|
* Parse a TypeScript/JavaScript file and extract its structure
|
|
10
10
|
*/
|
|
11
|
-
export declare function parseTypeScript(sourceCode: string, filePath: string, options?: ExtractorOptions): Omit<FileStructure,
|
|
11
|
+
export declare function parseTypeScript(sourceCode: string, filePath: string, options?: ExtractorOptions): Omit<FileStructure, "path" | "language" | "languageConfidence">;
|
|
12
12
|
/**
|
|
13
13
|
* Detect language from file path
|
|
14
14
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Uses TypeScript's built-in parser for accurate AST analysis.
|
|
5
5
|
* Works for both TypeScript and JavaScript files.
|
|
6
6
|
*/
|
|
7
|
-
import * as ts from
|
|
7
|
+
import * as ts from "typescript";
|
|
8
8
|
// Helper to check for a specific modifier kind
|
|
9
9
|
function hasModifierKind(modifiers, kind) {
|
|
10
10
|
return modifiers?.some((m) => m.kind === kind) ?? false;
|
|
@@ -27,7 +27,7 @@ export function parseTypeScript(sourceCode, filePath, options = {}) {
|
|
|
27
27
|
const types = extractTypes(sourceFile);
|
|
28
28
|
// Calculate stats
|
|
29
29
|
const stats = {
|
|
30
|
-
lineCount: sourceCode.split(
|
|
30
|
+
lineCount: sourceCode.split("\n").length,
|
|
31
31
|
importCount: imports.length,
|
|
32
32
|
exportCount: exports.length,
|
|
33
33
|
classCount: classes.length,
|
|
@@ -48,21 +48,21 @@ export function parseTypeScript(sourceCode, filePath, options = {}) {
|
|
|
48
48
|
* Get TypeScript script kind from file extension
|
|
49
49
|
*/
|
|
50
50
|
function getScriptKind(filePath) {
|
|
51
|
-
const ext = filePath.toLowerCase().split(
|
|
51
|
+
const ext = filePath.toLowerCase().split(".").pop();
|
|
52
52
|
switch (ext) {
|
|
53
|
-
case
|
|
53
|
+
case "ts":
|
|
54
54
|
return ts.ScriptKind.TS;
|
|
55
|
-
case
|
|
55
|
+
case "tsx":
|
|
56
56
|
return ts.ScriptKind.TSX;
|
|
57
|
-
case
|
|
57
|
+
case "js":
|
|
58
58
|
return ts.ScriptKind.JS;
|
|
59
|
-
case
|
|
59
|
+
case "jsx":
|
|
60
60
|
return ts.ScriptKind.JSX;
|
|
61
|
-
case
|
|
62
|
-
case
|
|
61
|
+
case "mts":
|
|
62
|
+
case "cts":
|
|
63
63
|
return ts.ScriptKind.TS;
|
|
64
|
-
case
|
|
65
|
-
case
|
|
64
|
+
case "mjs":
|
|
65
|
+
case "cjs":
|
|
66
66
|
return ts.ScriptKind.JS;
|
|
67
67
|
default:
|
|
68
68
|
return ts.ScriptKind.TS;
|
|
@@ -80,7 +80,9 @@ function extractImports(sourceFile) {
|
|
|
80
80
|
return;
|
|
81
81
|
const source = moduleSpecifier.text;
|
|
82
82
|
// Check for type-only import using modifiers
|
|
83
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
83
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
84
|
+
? ts.getModifiers(node)
|
|
85
|
+
: undefined;
|
|
84
86
|
const hasTypeKeyword = hasModifierKind(modifiers, ts.SyntaxKind.TypeKeyword);
|
|
85
87
|
const importInfo = {
|
|
86
88
|
source,
|
|
@@ -120,7 +122,7 @@ function extractExports(sourceFile) {
|
|
|
120
122
|
// export default ...
|
|
121
123
|
if (ts.isExportAssignment(node)) {
|
|
122
124
|
exports.push({
|
|
123
|
-
name:
|
|
125
|
+
name: "default",
|
|
124
126
|
isDefault: true,
|
|
125
127
|
isTypeOnly: false,
|
|
126
128
|
});
|
|
@@ -129,7 +131,9 @@ function extractExports(sourceFile) {
|
|
|
129
131
|
// export { ... }
|
|
130
132
|
if (ts.isExportDeclaration(node)) {
|
|
131
133
|
// Check for type-only export using modifiers
|
|
132
|
-
const exportMods = ts.canHaveModifiers(node)
|
|
134
|
+
const exportMods = ts.canHaveModifiers(node)
|
|
135
|
+
? ts.getModifiers(node)
|
|
136
|
+
: undefined;
|
|
133
137
|
const isTypeOnlyExport = hasModifierKind(exportMods, ts.SyntaxKind.TypeKeyword);
|
|
134
138
|
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
135
139
|
for (const element of node.exportClause.elements) {
|
|
@@ -143,11 +147,13 @@ function extractExports(sourceFile) {
|
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
145
149
|
// Check for export modifier on declarations
|
|
146
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
150
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
151
|
+
? ts.getModifiers(node)
|
|
152
|
+
: undefined;
|
|
147
153
|
const hasExport = hasModifierKind(modifiers, ts.SyntaxKind.ExportKeyword);
|
|
148
154
|
const hasDefault = hasModifierKind(modifiers, ts.SyntaxKind.DefaultKeyword);
|
|
149
155
|
if (hasExport) {
|
|
150
|
-
let name =
|
|
156
|
+
let name = "unknown";
|
|
151
157
|
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
152
158
|
name = node.name.text;
|
|
153
159
|
}
|
|
@@ -175,9 +181,9 @@ function extractExports(sourceFile) {
|
|
|
175
181
|
else if (ts.isEnumDeclaration(node)) {
|
|
176
182
|
name = node.name.text;
|
|
177
183
|
}
|
|
178
|
-
if (name !==
|
|
184
|
+
if (name !== "unknown" || hasDefault) {
|
|
179
185
|
exports.push({
|
|
180
|
-
name: hasDefault ?
|
|
186
|
+
name: hasDefault ? "default" : name,
|
|
181
187
|
isDefault: hasDefault,
|
|
182
188
|
isTypeOnly: ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node),
|
|
183
189
|
});
|
|
@@ -205,24 +211,28 @@ function extractClasses(sourceFile, includePrivate, maxDepth) {
|
|
|
205
211
|
* Extract information from a class declaration
|
|
206
212
|
*/
|
|
207
213
|
function extractClassInfo(node, includePrivate, _maxDepth) {
|
|
208
|
-
const name = node.name?.text ??
|
|
209
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
214
|
+
const name = node.name?.text ?? "anonymous";
|
|
215
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
216
|
+
? ts.getModifiers(node)
|
|
217
|
+
: undefined;
|
|
210
218
|
const isExported = hasModifierKind(modifiers, ts.SyntaxKind.ExportKeyword);
|
|
211
219
|
const isAbstract = hasModifierKind(modifiers, ts.SyntaxKind.AbstractKeyword);
|
|
212
220
|
const methods = [];
|
|
213
221
|
const properties = [];
|
|
214
222
|
for (const member of node.members) {
|
|
215
|
-
const memberModifiers = ts.canHaveModifiers(member)
|
|
223
|
+
const memberModifiers = ts.canHaveModifiers(member)
|
|
224
|
+
? ts.getModifiers(member)
|
|
225
|
+
: undefined;
|
|
216
226
|
const visibility = getVisibility(memberModifiers);
|
|
217
227
|
// Skip private members if not included
|
|
218
|
-
if (!includePrivate && visibility ===
|
|
228
|
+
if (!includePrivate && visibility === "private") {
|
|
219
229
|
continue;
|
|
220
230
|
}
|
|
221
231
|
if (ts.isConstructorDeclaration(member)) {
|
|
222
232
|
const isAsync = hasModifierKind(memberModifiers, ts.SyntaxKind.AsyncKeyword);
|
|
223
233
|
const isStatic = hasModifierKind(memberModifiers, ts.SyntaxKind.StaticKeyword);
|
|
224
234
|
methods.push({
|
|
225
|
-
name:
|
|
235
|
+
name: "constructor",
|
|
226
236
|
visibility,
|
|
227
237
|
async: isAsync,
|
|
228
238
|
static: isStatic,
|
|
@@ -231,7 +241,9 @@ function extractClassInfo(node, includePrivate, _maxDepth) {
|
|
|
231
241
|
});
|
|
232
242
|
}
|
|
233
243
|
else if (ts.isMethodDeclaration(member)) {
|
|
234
|
-
const methodName = ts.isIdentifier(member.name)
|
|
244
|
+
const methodName = ts.isIdentifier(member.name)
|
|
245
|
+
? member.name.text
|
|
246
|
+
: "computed";
|
|
235
247
|
const isAsync = hasModifierKind(memberModifiers, ts.SyntaxKind.AsyncKeyword);
|
|
236
248
|
const isStatic = hasModifierKind(memberModifiers, ts.SyntaxKind.StaticKeyword);
|
|
237
249
|
methods.push({
|
|
@@ -244,8 +256,7 @@ function extractClassInfo(node, includePrivate, _maxDepth) {
|
|
|
244
256
|
});
|
|
245
257
|
}
|
|
246
258
|
else if (ts.isPropertyDeclaration(member)) {
|
|
247
|
-
|
|
248
|
-
const propName = member.name && ts.isIdentifier(member.name) ? member.name.text : null;
|
|
259
|
+
const propName = ts.isIdentifier(member.name) ? member.name.text : null;
|
|
249
260
|
if (propName) {
|
|
250
261
|
const isStatic = hasModifierKind(memberModifiers, ts.SyntaxKind.StaticKeyword);
|
|
251
262
|
const isReadonly = hasModifierKind(memberModifiers, ts.SyntaxKind.ReadonlyKeyword);
|
|
@@ -272,21 +283,21 @@ function extractClassInfo(node, includePrivate, _maxDepth) {
|
|
|
272
283
|
*/
|
|
273
284
|
function getVisibility(modifiers) {
|
|
274
285
|
if (!modifiers)
|
|
275
|
-
return
|
|
286
|
+
return "public";
|
|
276
287
|
for (const mod of modifiers) {
|
|
277
288
|
if (mod.kind === ts.SyntaxKind.PrivateKeyword)
|
|
278
|
-
return
|
|
289
|
+
return "private";
|
|
279
290
|
if (mod.kind === ts.SyntaxKind.ProtectedKeyword)
|
|
280
|
-
return
|
|
291
|
+
return "protected";
|
|
281
292
|
}
|
|
282
|
-
return
|
|
293
|
+
return "public";
|
|
283
294
|
}
|
|
284
295
|
/**
|
|
285
296
|
* Extract parameter information
|
|
286
297
|
*/
|
|
287
298
|
function extractParameters(params) {
|
|
288
299
|
return params.map((param) => ({
|
|
289
|
-
name: ts.isIdentifier(param.name) ? param.name.text :
|
|
300
|
+
name: ts.isIdentifier(param.name) ? param.name.text : "param",
|
|
290
301
|
type: param.type ? param.type.getText() : undefined,
|
|
291
302
|
}));
|
|
292
303
|
}
|
|
@@ -298,7 +309,9 @@ function extractFunctions(sourceFile) {
|
|
|
298
309
|
ts.forEachChild(sourceFile, (node) => {
|
|
299
310
|
// Function declarations
|
|
300
311
|
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
301
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
312
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
313
|
+
? ts.getModifiers(node)
|
|
314
|
+
: undefined;
|
|
302
315
|
const isExported = hasModifierKind(modifiers, ts.SyntaxKind.ExportKeyword);
|
|
303
316
|
const isAsync = hasModifierKind(modifiers, ts.SyntaxKind.AsyncKeyword);
|
|
304
317
|
functions.push({
|
|
@@ -311,11 +324,14 @@ function extractFunctions(sourceFile) {
|
|
|
311
324
|
}
|
|
312
325
|
// Variable declarations that are arrow functions
|
|
313
326
|
if (ts.isVariableStatement(node)) {
|
|
314
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
327
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
328
|
+
? ts.getModifiers(node)
|
|
329
|
+
: undefined;
|
|
315
330
|
const isExported = hasModifierKind(modifiers, ts.SyntaxKind.ExportKeyword);
|
|
316
331
|
for (const decl of node.declarationList.declarations) {
|
|
317
332
|
if (ts.isIdentifier(decl.name) && decl.initializer) {
|
|
318
|
-
if (ts.isArrowFunction(decl.initializer) ||
|
|
333
|
+
if (ts.isArrowFunction(decl.initializer) ||
|
|
334
|
+
ts.isFunctionExpression(decl.initializer)) {
|
|
319
335
|
const funcModifiers = decl.initializer.modifiers;
|
|
320
336
|
const isAsync = funcModifiers
|
|
321
337
|
? funcModifiers.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)
|
|
@@ -325,7 +341,9 @@ function extractFunctions(sourceFile) {
|
|
|
325
341
|
exported: isExported,
|
|
326
342
|
async: isAsync,
|
|
327
343
|
parameters: extractParameters(decl.initializer.parameters),
|
|
328
|
-
returnType: decl.initializer.type
|
|
344
|
+
returnType: decl.initializer.type
|
|
345
|
+
? decl.initializer.type.getText()
|
|
346
|
+
: undefined,
|
|
329
347
|
});
|
|
330
348
|
}
|
|
331
349
|
}
|
|
@@ -341,14 +359,17 @@ function extractVariables(sourceFile) {
|
|
|
341
359
|
const variables = [];
|
|
342
360
|
ts.forEachChild(sourceFile, (node) => {
|
|
343
361
|
if (ts.isVariableStatement(node)) {
|
|
344
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
362
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
363
|
+
? ts.getModifiers(node)
|
|
364
|
+
: undefined;
|
|
345
365
|
const isExported = hasModifierKind(modifiers, ts.SyntaxKind.ExportKeyword);
|
|
346
|
-
const kind = node.declarationList.flags & ts.NodeFlags.Const ?
|
|
366
|
+
const kind = node.declarationList.flags & ts.NodeFlags.Const ? "const" : "let";
|
|
347
367
|
for (const decl of node.declarationList.declarations) {
|
|
348
368
|
if (ts.isIdentifier(decl.name)) {
|
|
349
369
|
// Skip if this is a function (arrow function or function expression)
|
|
350
370
|
if (decl.initializer &&
|
|
351
|
-
(ts.isArrowFunction(decl.initializer) ||
|
|
371
|
+
(ts.isArrowFunction(decl.initializer) ||
|
|
372
|
+
ts.isFunctionExpression(decl.initializer))) {
|
|
352
373
|
continue;
|
|
353
374
|
}
|
|
354
375
|
variables.push({
|
|
@@ -369,26 +390,28 @@ function extractVariables(sourceFile) {
|
|
|
369
390
|
function extractTypes(sourceFile) {
|
|
370
391
|
const types = [];
|
|
371
392
|
ts.forEachChild(sourceFile, (node) => {
|
|
372
|
-
const modifiers = ts.canHaveModifiers(node)
|
|
393
|
+
const modifiers = ts.canHaveModifiers(node)
|
|
394
|
+
? ts.getModifiers(node)
|
|
395
|
+
: undefined;
|
|
373
396
|
const isExported = hasModifierKind(modifiers, ts.SyntaxKind.ExportKeyword);
|
|
374
397
|
if (ts.isInterfaceDeclaration(node)) {
|
|
375
398
|
types.push({
|
|
376
399
|
name: node.name.text,
|
|
377
|
-
kind:
|
|
400
|
+
kind: "interface",
|
|
378
401
|
exported: isExported,
|
|
379
402
|
});
|
|
380
403
|
}
|
|
381
404
|
else if (ts.isTypeAliasDeclaration(node)) {
|
|
382
405
|
types.push({
|
|
383
406
|
name: node.name.text,
|
|
384
|
-
kind:
|
|
407
|
+
kind: "type",
|
|
385
408
|
exported: isExported,
|
|
386
409
|
});
|
|
387
410
|
}
|
|
388
411
|
else if (ts.isEnumDeclaration(node)) {
|
|
389
412
|
types.push({
|
|
390
413
|
name: node.name.text,
|
|
391
|
-
kind:
|
|
414
|
+
kind: "enum",
|
|
392
415
|
exported: isExported,
|
|
393
416
|
});
|
|
394
417
|
}
|
|
@@ -399,18 +422,18 @@ function extractTypes(sourceFile) {
|
|
|
399
422
|
* Detect language from file path
|
|
400
423
|
*/
|
|
401
424
|
export function detectLanguage(filePath) {
|
|
402
|
-
const ext = filePath.toLowerCase().split(
|
|
425
|
+
const ext = filePath.toLowerCase().split(".").pop();
|
|
403
426
|
switch (ext) {
|
|
404
|
-
case
|
|
405
|
-
case
|
|
406
|
-
case
|
|
407
|
-
case
|
|
408
|
-
return { language:
|
|
409
|
-
case
|
|
410
|
-
case
|
|
411
|
-
case
|
|
412
|
-
case
|
|
413
|
-
return { language:
|
|
427
|
+
case "ts":
|
|
428
|
+
case "tsx":
|
|
429
|
+
case "mts":
|
|
430
|
+
case "cts":
|
|
431
|
+
return { language: "typescript", confidence: 1.0 };
|
|
432
|
+
case "js":
|
|
433
|
+
case "jsx":
|
|
434
|
+
case "mjs":
|
|
435
|
+
case "cjs":
|
|
436
|
+
return { language: "javascript", confidence: 1.0 };
|
|
414
437
|
default:
|
|
415
438
|
return { language: null, confidence: 0 };
|
|
416
439
|
}
|
|
@@ -419,5 +442,5 @@ export function detectLanguage(filePath) {
|
|
|
419
442
|
* Check if a language is supported by this parser
|
|
420
443
|
*/
|
|
421
444
|
export function isLanguageSupported(language) {
|
|
422
|
-
return language ===
|
|
445
|
+
return language === "typescript" || language === "javascript";
|
|
423
446
|
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Analyze codebase health: complexity, dead code, duplicates, and anti-patterns.
|
|
5
5
|
*/
|
|
6
|
-
import { defineSkill } from
|
|
6
|
+
import { defineSkill } from "@compilr-dev/agents";
|
|
7
7
|
/**
|
|
8
8
|
* Code health skill - Analyze codebase health using Tier 3 tools
|
|
9
9
|
*/
|
|
10
10
|
export const codeHealthSkill = defineSkill({
|
|
11
|
-
name:
|
|
12
|
-
description:
|
|
11
|
+
name: "code-health",
|
|
12
|
+
description: "Analyze codebase health: complexity, dead code, duplicates, and anti-patterns",
|
|
13
13
|
prompt: `You are in CODE HEALTH ANALYSIS mode. Analyze the codebase for quality issues.
|
|
14
14
|
|
|
15
15
|
## When to Use
|
|
@@ -175,6 +175,6 @@ find_patterns({
|
|
|
175
175
|
- Consider project context (prototype vs production)
|
|
176
176
|
- Dead code detection has false positives - verify before removing
|
|
177
177
|
- Duplication is sometimes intentional - use judgment`,
|
|
178
|
-
tags: [
|
|
179
|
-
version:
|
|
178
|
+
tags: ["analysis", "quality", "complexity", "health", "audit"],
|
|
179
|
+
version: "1.0.0",
|
|
180
180
|
});
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Analyze and understand codebase structure using analysis tools.
|
|
5
5
|
*/
|
|
6
|
-
import { defineSkill } from
|
|
6
|
+
import { defineSkill } from "@compilr-dev/agents";
|
|
7
7
|
/**
|
|
8
8
|
* Code structure skill - Understand codebase structure using analysis tools
|
|
9
9
|
*/
|
|
10
10
|
export const codeStructureSkill = defineSkill({
|
|
11
|
-
name:
|
|
12
|
-
description:
|
|
11
|
+
name: "code-structure",
|
|
12
|
+
description: "Analyze and understand codebase structure quickly",
|
|
13
13
|
prompt: `You are in CODE STRUCTURE ANALYSIS mode. Analyze the specified path to understand its structure.
|
|
14
14
|
|
|
15
15
|
## When to Use
|
|
@@ -102,6 +102,6 @@ Any patterns, conventions, or notable design decisions.
|
|
|
102
102
|
- Highlight patterns and conventions
|
|
103
103
|
- Note any red flags (circular deps, mixed concerns) but don't dwell
|
|
104
104
|
- Keep output concise - expand only when asked`,
|
|
105
|
-
tags: [
|
|
106
|
-
version:
|
|
105
|
+
tags: ["analysis", "structure", "understanding", "navigation"],
|
|
106
|
+
version: "1.0.0",
|
|
107
107
|
});
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Audit module dependencies and identify potential issues.
|
|
5
5
|
*/
|
|
6
|
-
import { defineSkill } from
|
|
6
|
+
import { defineSkill } from "@compilr-dev/agents";
|
|
7
7
|
/**
|
|
8
8
|
* Dependency audit skill - Analyze module dependencies for issues
|
|
9
9
|
*/
|
|
10
10
|
export const dependencyAuditSkill = defineSkill({
|
|
11
|
-
name:
|
|
12
|
-
description:
|
|
11
|
+
name: "dependency-audit",
|
|
12
|
+
description: "Audit module dependencies and identify potential issues",
|
|
13
13
|
prompt: `You are in DEPENDENCY AUDIT mode. Analyze the project's module dependencies.
|
|
14
14
|
|
|
15
15
|
## When to Use
|
|
@@ -116,6 +116,6 @@ For suspicious files, use get_imports to see:
|
|
|
116
116
|
- Don't flag normal patterns as issues
|
|
117
117
|
- Provide actionable recommendations
|
|
118
118
|
- Be concise - expand only on request`,
|
|
119
|
-
tags: [
|
|
120
|
-
version:
|
|
119
|
+
tags: ["analysis", "dependencies", "audit", "architecture"],
|
|
120
|
+
version: "1.0.0",
|
|
121
121
|
});
|