@compilr-dev/agents-coding-ts 0.1.0
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 +21 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +66 -0
- package/dist/parser/index.d.ts +7 -0
- package/dist/parser/index.js +6 -0
- package/dist/parser/typescript-parser.d.ts +22 -0
- package/dist/parser/typescript-parser.js +423 -0
- package/dist/skills/code-health.d.ts +9 -0
- package/dist/skills/code-health.js +167 -0
- package/dist/skills/code-structure.d.ts +9 -0
- package/dist/skills/code-structure.js +97 -0
- package/dist/skills/dependency-audit.d.ts +9 -0
- package/dist/skills/dependency-audit.js +110 -0
- package/dist/skills/index.d.ts +16 -0
- package/dist/skills/index.js +27 -0
- package/dist/skills/refactor-impact.d.ts +9 -0
- package/dist/skills/refactor-impact.js +135 -0
- package/dist/skills/type-analysis.d.ts +9 -0
- package/dist/skills/type-analysis.js +150 -0
- package/dist/tools/find-dead-code.d.ts +20 -0
- package/dist/tools/find-dead-code.js +375 -0
- package/dist/tools/find-duplicates.d.ts +21 -0
- package/dist/tools/find-duplicates.js +274 -0
- package/dist/tools/find-implementations.d.ts +21 -0
- package/dist/tools/find-implementations.js +436 -0
- package/dist/tools/find-patterns.d.ts +21 -0
- package/dist/tools/find-patterns.js +457 -0
- package/dist/tools/find-references.d.ts +23 -0
- package/dist/tools/find-references.js +488 -0
- package/dist/tools/find-symbol.d.ts +21 -0
- package/dist/tools/find-symbol.js +458 -0
- package/dist/tools/get-call-graph.d.ts +23 -0
- package/dist/tools/get-call-graph.js +469 -0
- package/dist/tools/get-complexity.d.ts +21 -0
- package/dist/tools/get-complexity.js +394 -0
- package/dist/tools/get-dependency-graph.d.ts +23 -0
- package/dist/tools/get-dependency-graph.js +482 -0
- package/dist/tools/get-documentation.d.ts +21 -0
- package/dist/tools/get-documentation.js +613 -0
- package/dist/tools/get-exports.d.ts +21 -0
- package/dist/tools/get-exports.js +427 -0
- package/dist/tools/get-file-structure.d.ts +27 -0
- package/dist/tools/get-file-structure.js +120 -0
- package/dist/tools/get-imports.d.ts +23 -0
- package/dist/tools/get-imports.js +350 -0
- package/dist/tools/get-signature.d.ts +20 -0
- package/dist/tools/get-signature.js +758 -0
- package/dist/tools/get-type-hierarchy.d.ts +22 -0
- package/dist/tools/get-type-hierarchy.js +485 -0
- package/dist/tools/index.d.ts +23 -0
- package/dist/tools/index.js +25 -0
- package/dist/tools/types.d.ts +1302 -0
- package/dist/tools/types.js +7 -0
- package/package.json +84 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Health Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyze codebase health: complexity, dead code, duplicates, and anti-patterns.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from '@compilr-dev/agents';
|
|
7
|
+
/**
|
|
8
|
+
* Code health skill - Analyze codebase health using Tier 3 tools
|
|
9
|
+
*/
|
|
10
|
+
export const codeHealthSkill = defineSkill({
|
|
11
|
+
name: 'code-health',
|
|
12
|
+
description: 'Analyze codebase health: complexity, dead code, duplicates, and anti-patterns',
|
|
13
|
+
prompt: `You are in CODE HEALTH ANALYSIS mode. Analyze the codebase for quality issues.
|
|
14
|
+
|
|
15
|
+
## TOOLS TO USE
|
|
16
|
+
|
|
17
|
+
1. **get_complexity**: Analyze code complexity
|
|
18
|
+
- Cyclomatic complexity (decision points)
|
|
19
|
+
- Cognitive complexity (readability)
|
|
20
|
+
- Nesting depth
|
|
21
|
+
- Function length
|
|
22
|
+
- Parameter count
|
|
23
|
+
- Identify complexity hotspots
|
|
24
|
+
|
|
25
|
+
2. **find_dead_code**: Find unused code
|
|
26
|
+
- Unused exports (exported but never imported)
|
|
27
|
+
- Unused functions (defined but never called)
|
|
28
|
+
- Unused variables (declared but never used)
|
|
29
|
+
- Confidence levels (high/medium/low)
|
|
30
|
+
|
|
31
|
+
3. **find_duplicates**: Detect code duplication
|
|
32
|
+
- Content-based hashing
|
|
33
|
+
- Normalized comparison (ignores formatting)
|
|
34
|
+
- Identifies refactoring opportunities
|
|
35
|
+
- Shows duplication percentage
|
|
36
|
+
|
|
37
|
+
4. **find_patterns**: Find anti-patterns and code smells
|
|
38
|
+
- Security issues (eval, innerHTML, hardcoded secrets)
|
|
39
|
+
- Performance issues (console.log, sync fs ops, nested loops)
|
|
40
|
+
- Maintainability issues (magic numbers, TODO/FIXME, any type)
|
|
41
|
+
- Custom pattern support
|
|
42
|
+
|
|
43
|
+
## ANALYSIS WORKFLOW
|
|
44
|
+
|
|
45
|
+
### Quick Health Check
|
|
46
|
+
\`\`\`
|
|
47
|
+
// Step 1: Check complexity hotspots
|
|
48
|
+
get_complexity({
|
|
49
|
+
path: "/path/to/project",
|
|
50
|
+
recursive: true,
|
|
51
|
+
threshold: 10,
|
|
52
|
+
onlyAboveThreshold: true
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Step 2: Find critical patterns
|
|
56
|
+
find_patterns({
|
|
57
|
+
path: "/path/to/project",
|
|
58
|
+
categories: ["security", "performance"]
|
|
59
|
+
})
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
### Full Health Audit
|
|
63
|
+
\`\`\`
|
|
64
|
+
// Step 1: Complexity analysis
|
|
65
|
+
get_complexity({
|
|
66
|
+
path: "/path/to/project",
|
|
67
|
+
recursive: true,
|
|
68
|
+
threshold: 10
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Step 2: Dead code detection
|
|
72
|
+
find_dead_code({
|
|
73
|
+
path: "/path/to/project",
|
|
74
|
+
checkExports: true,
|
|
75
|
+
checkFunctions: true
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Step 3: Duplication analysis
|
|
79
|
+
find_duplicates({
|
|
80
|
+
path: "/path/to/project",
|
|
81
|
+
minLines: 6,
|
|
82
|
+
minTokens: 50
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// Step 4: Pattern analysis
|
|
86
|
+
find_patterns({
|
|
87
|
+
path: "/path/to/project",
|
|
88
|
+
categories: ["all"]
|
|
89
|
+
})
|
|
90
|
+
\`\`\`
|
|
91
|
+
|
|
92
|
+
## OUTPUT FORMAT
|
|
93
|
+
|
|
94
|
+
### Health Summary
|
|
95
|
+
| Metric | Value | Status |
|
|
96
|
+
|--------|-------|--------|
|
|
97
|
+
| Files analyzed | N | - |
|
|
98
|
+
| Avg complexity | X | 🟢/🟡/🔴 |
|
|
99
|
+
| Max complexity | Y | 🟢/🟡/🔴 |
|
|
100
|
+
| Complexity hotspots | Z | 🟢/🟡/🔴 |
|
|
101
|
+
| Dead code items | N | 🟢/🟡/🔴 |
|
|
102
|
+
| Duplicate blocks | M | 🟢/🟡/🔴 |
|
|
103
|
+
| Duplication % | X% | 🟢/🟡/🔴 |
|
|
104
|
+
| Security issues | S | 🟢/🟡/🔴 |
|
|
105
|
+
| Performance issues | P | 🟢/🟡/🔴 |
|
|
106
|
+
|
|
107
|
+
### Complexity Hotspots (top 5)
|
|
108
|
+
| Function | File | Cyclomatic | Cognitive | Action |
|
|
109
|
+
|----------|------|------------|-----------|--------|
|
|
110
|
+
| processOrder | orders.ts:45 | 25 | 32 | 🔴 Refactor immediately |
|
|
111
|
+
| validateInput | utils.ts:120 | 15 | 18 | 🟡 Consider splitting |
|
|
112
|
+
|
|
113
|
+
### Dead Code
|
|
114
|
+
| Name | File | Type | Confidence |
|
|
115
|
+
|------|------|------|------------|
|
|
116
|
+
| oldHelper | utils.ts:89 | function | HIGH |
|
|
117
|
+
| legacyExport | index.ts:12 | export | MEDIUM |
|
|
118
|
+
|
|
119
|
+
### Code Duplication
|
|
120
|
+
| ID | Lines | Tokens | Files | Sample |
|
|
121
|
+
|----|-------|--------|-------|--------|
|
|
122
|
+
| DUP-1 | 15 | 120 | 3 | \`function validate...\` |
|
|
123
|
+
|
|
124
|
+
### Pattern Issues
|
|
125
|
+
| Pattern | Severity | Count | Files |
|
|
126
|
+
|---------|----------|-------|-------|
|
|
127
|
+
| eval-usage | 🔴 ERROR | 2 | api.ts, utils.ts |
|
|
128
|
+
| console-log | ℹ️ INFO | 15 | various |
|
|
129
|
+
| any-type | ⚠️ WARN | 8 | types.ts |
|
|
130
|
+
|
|
131
|
+
### Recommendations (prioritized)
|
|
132
|
+
|
|
133
|
+
#### 🔴 Critical (fix immediately)
|
|
134
|
+
1. **Security**: Remove eval() usage in api.ts:45
|
|
135
|
+
2. **Complexity**: Refactor processOrder() - split into smaller functions
|
|
136
|
+
|
|
137
|
+
#### 🟡 Important (fix soon)
|
|
138
|
+
1. **Dead code**: Remove unused legacyExport
|
|
139
|
+
2. **Duplication**: Extract common validation logic (DUP-1)
|
|
140
|
+
|
|
141
|
+
#### ℹ️ Suggestions (improve when touching these files)
|
|
142
|
+
1. Remove console.log statements before production
|
|
143
|
+
2. Replace any types with specific types
|
|
144
|
+
|
|
145
|
+
## THRESHOLDS
|
|
146
|
+
|
|
147
|
+
| Metric | 🟢 Good | 🟡 Warning | 🔴 Critical |
|
|
148
|
+
|--------|---------|------------|-------------|
|
|
149
|
+
| Cyclomatic complexity | <10 | 10-20 | >20 |
|
|
150
|
+
| Cognitive complexity | <15 | 15-25 | >25 |
|
|
151
|
+
| Function length | <50 lines | 50-100 | >100 |
|
|
152
|
+
| Parameters | <5 | 5-7 | >7 |
|
|
153
|
+
| Duplication % | <5% | 5-10% | >10% |
|
|
154
|
+
| Security issues | 0 | 1-2 | >2 |
|
|
155
|
+
|
|
156
|
+
## RULES
|
|
157
|
+
|
|
158
|
+
- Start with quick check, go deep on request
|
|
159
|
+
- Prioritize security issues first
|
|
160
|
+
- Focus on actionable recommendations
|
|
161
|
+
- Don't overwhelm - show top issues first
|
|
162
|
+
- Consider project context (prototype vs production)
|
|
163
|
+
- Dead code detection has false positives - verify before removing
|
|
164
|
+
- Duplication is sometimes intentional - use judgment`,
|
|
165
|
+
tags: ['analysis', 'quality', 'complexity', 'health', 'audit'],
|
|
166
|
+
version: '1.0.0',
|
|
167
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Structure Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyze and understand codebase structure using analysis tools.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Code structure skill - Understand codebase structure using analysis tools
|
|
8
|
+
*/
|
|
9
|
+
export declare const codeStructureSkill: import("@compilr-dev/agents").Skill;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Structure Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyze and understand codebase structure using analysis tools.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from '@compilr-dev/agents';
|
|
7
|
+
/**
|
|
8
|
+
* Code structure skill - Understand codebase structure using analysis tools
|
|
9
|
+
*/
|
|
10
|
+
export const codeStructureSkill = defineSkill({
|
|
11
|
+
name: 'code-structure',
|
|
12
|
+
description: 'Analyze and understand codebase structure quickly',
|
|
13
|
+
prompt: `You are in CODE STRUCTURE ANALYSIS mode. Analyze the specified path to understand its structure.
|
|
14
|
+
|
|
15
|
+
## TOOLS TO USE
|
|
16
|
+
|
|
17
|
+
1. **get_file_structure**: Analyze a file's internal structure
|
|
18
|
+
- Classes, functions, methods, properties
|
|
19
|
+
- Imports and exports
|
|
20
|
+
- Type definitions
|
|
21
|
+
|
|
22
|
+
2. **get_imports**: Understand dependencies
|
|
23
|
+
- External packages vs internal modules
|
|
24
|
+
- Type-only imports
|
|
25
|
+
- Transitive imports (when needed)
|
|
26
|
+
|
|
27
|
+
3. **get_exports**: Understand what a module exposes
|
|
28
|
+
- Default and named exports
|
|
29
|
+
- Re-exports from other modules
|
|
30
|
+
- Type exports
|
|
31
|
+
|
|
32
|
+
## ANALYSIS WORKFLOW
|
|
33
|
+
|
|
34
|
+
### For a Single File
|
|
35
|
+
1. Use get_file_structure to see:
|
|
36
|
+
- What classes and functions are defined
|
|
37
|
+
- What interfaces/types are declared
|
|
38
|
+
- File statistics (line count, complexity)
|
|
39
|
+
|
|
40
|
+
2. Use get_imports to understand:
|
|
41
|
+
- External dependencies
|
|
42
|
+
- Internal module dependencies
|
|
43
|
+
- How the file relates to others
|
|
44
|
+
|
|
45
|
+
3. Use get_exports to see:
|
|
46
|
+
- What the file provides to others
|
|
47
|
+
- Public API surface
|
|
48
|
+
|
|
49
|
+
### For a Directory
|
|
50
|
+
1. Start with the index file (if exists)
|
|
51
|
+
2. Analyze re-exports to understand module structure
|
|
52
|
+
3. Look at key files identified by imports
|
|
53
|
+
|
|
54
|
+
## OUTPUT FORMAT
|
|
55
|
+
|
|
56
|
+
Provide a structured analysis:
|
|
57
|
+
|
|
58
|
+
### Overview
|
|
59
|
+
Brief description of what this code does.
|
|
60
|
+
|
|
61
|
+
### Main Components
|
|
62
|
+
| Name | Type | Purpose |
|
|
63
|
+
|------|------|---------|
|
|
64
|
+
| ... | class/function/type | ... |
|
|
65
|
+
|
|
66
|
+
### Dependencies
|
|
67
|
+
- **External**: List of npm packages used
|
|
68
|
+
- **Internal**: List of local modules imported
|
|
69
|
+
|
|
70
|
+
### Exports (Public API)
|
|
71
|
+
- Default export: description
|
|
72
|
+
- Named exports: list with purposes
|
|
73
|
+
|
|
74
|
+
### Entry Points
|
|
75
|
+
Suggested starting points for understanding this code:
|
|
76
|
+
1. Start with file X because...
|
|
77
|
+
2. Then look at Y to understand...
|
|
78
|
+
|
|
79
|
+
### Architecture Notes
|
|
80
|
+
Any patterns, conventions, or notable design decisions.
|
|
81
|
+
|
|
82
|
+
## WHEN TO GO DEEPER
|
|
83
|
+
|
|
84
|
+
- If a class looks important, use get_file_structure on related files
|
|
85
|
+
- If imports are unclear, use get_imports with transitive: true
|
|
86
|
+
- If you need to trace re-exports, use get_exports with resolveReExports: true
|
|
87
|
+
|
|
88
|
+
## RULES
|
|
89
|
+
|
|
90
|
+
- Start broad, then go deep on request
|
|
91
|
+
- Focus on understanding, not judging
|
|
92
|
+
- Highlight patterns and conventions
|
|
93
|
+
- Note any red flags (circular deps, mixed concerns) but don't dwell
|
|
94
|
+
- Keep output concise - expand only when asked`,
|
|
95
|
+
tags: ['analysis', 'structure', 'understanding', 'navigation'],
|
|
96
|
+
version: '1.0.0',
|
|
97
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Audit Skill
|
|
3
|
+
*
|
|
4
|
+
* Audit module dependencies and identify potential issues.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from '@compilr-dev/agents';
|
|
7
|
+
/**
|
|
8
|
+
* Dependency audit skill - Analyze module dependencies for issues
|
|
9
|
+
*/
|
|
10
|
+
export const dependencyAuditSkill = defineSkill({
|
|
11
|
+
name: 'dependency-audit',
|
|
12
|
+
description: 'Audit module dependencies and identify potential issues',
|
|
13
|
+
prompt: `You are in DEPENDENCY AUDIT mode. Analyze the project's module dependencies.
|
|
14
|
+
|
|
15
|
+
## TOOLS TO USE
|
|
16
|
+
|
|
17
|
+
1. **get_dependency_graph**: Build a complete module dependency graph
|
|
18
|
+
- Detect circular dependencies
|
|
19
|
+
- Identify external vs internal dependencies
|
|
20
|
+
- Find modules with excessive dependencies
|
|
21
|
+
- Find highly-depended-upon modules
|
|
22
|
+
|
|
23
|
+
2. **get_imports**: Analyze specific file imports
|
|
24
|
+
- List external packages used
|
|
25
|
+
- Check for type-only imports
|
|
26
|
+
- Identify unused imports
|
|
27
|
+
- Find transitive dependencies
|
|
28
|
+
|
|
29
|
+
## AUDIT WORKFLOW
|
|
30
|
+
|
|
31
|
+
### Step 1: Build Dependency Graph
|
|
32
|
+
\`\`\`
|
|
33
|
+
get_dependency_graph({
|
|
34
|
+
path: "/path/to/project",
|
|
35
|
+
includeExternal: true,
|
|
36
|
+
includeTypeOnly: true
|
|
37
|
+
})
|
|
38
|
+
\`\`\`
|
|
39
|
+
|
|
40
|
+
### Step 2: Check for Issues
|
|
41
|
+
|
|
42
|
+
#### Circular Dependencies
|
|
43
|
+
- Look at circularDependencies array
|
|
44
|
+
- Each cycle shows: [A → B → C → A]
|
|
45
|
+
- Report severity: 2-node cycles are worse than long chains
|
|
46
|
+
|
|
47
|
+
#### Dependency Hot Spots
|
|
48
|
+
- Check stats.mostDependencies: Module that imports the most
|
|
49
|
+
- Check stats.mostDependents: Module that is imported the most
|
|
50
|
+
- High numbers may indicate:
|
|
51
|
+
- God modules (do too much)
|
|
52
|
+
- Tight coupling
|
|
53
|
+
- Missing abstractions
|
|
54
|
+
|
|
55
|
+
#### External Package Analysis
|
|
56
|
+
- List external packages from stats.externalPackageList
|
|
57
|
+
- Check for:
|
|
58
|
+
- Duplicate packages (e.g., lodash AND underscore)
|
|
59
|
+
- Heavy packages that could be replaced
|
|
60
|
+
- Type-only packages (should be in devDependencies)
|
|
61
|
+
|
|
62
|
+
### Step 3: Deep Dive with get_imports
|
|
63
|
+
For suspicious files, use get_imports to see:
|
|
64
|
+
- What exactly is imported from each source
|
|
65
|
+
- Which imports are type-only
|
|
66
|
+
- Whether default, named, or namespace imports are used
|
|
67
|
+
|
|
68
|
+
## OUTPUT FORMAT
|
|
69
|
+
|
|
70
|
+
### Dependency Graph Summary
|
|
71
|
+
| Metric | Value |
|
|
72
|
+
|--------|-------|
|
|
73
|
+
| Total modules | X |
|
|
74
|
+
| Internal modules | Y |
|
|
75
|
+
| External packages | Z |
|
|
76
|
+
| Total edges | N |
|
|
77
|
+
| Circular dependencies | M |
|
|
78
|
+
|
|
79
|
+
### Circular Dependencies (if any)
|
|
80
|
+
1. \`module-a.ts\` → \`module-b.ts\` → \`module-a.ts\`
|
|
81
|
+
- Severity: HIGH (2-node cycle)
|
|
82
|
+
- Suggested fix: Extract shared code to new module
|
|
83
|
+
|
|
84
|
+
### Hot Spots
|
|
85
|
+
| Module | Incoming | Outgoing | Risk |
|
|
86
|
+
|--------|----------|----------|------|
|
|
87
|
+
| utils/index.ts | 15 | 3 | HIGH - God module |
|
|
88
|
+
| services/api.ts | 2 | 12 | MEDIUM - Many deps |
|
|
89
|
+
|
|
90
|
+
### External Packages (N total)
|
|
91
|
+
- **Core**: react, express, lodash
|
|
92
|
+
- **Dev**: typescript, eslint, vitest
|
|
93
|
+
- **Potential issues**:
|
|
94
|
+
- lodash + underscore (duplicate functionality)
|
|
95
|
+
|
|
96
|
+
### Recommendations
|
|
97
|
+
1. Break up utils/index.ts into focused modules
|
|
98
|
+
2. Resolve circular dependency between A and B
|
|
99
|
+
3. Consider replacing moment with date-fns (smaller bundle)
|
|
100
|
+
|
|
101
|
+
## RULES
|
|
102
|
+
|
|
103
|
+
- Focus on structural issues, not code quality
|
|
104
|
+
- Prioritize circular dependencies (they cause real problems)
|
|
105
|
+
- Don't flag normal patterns as issues
|
|
106
|
+
- Provide actionable recommendations
|
|
107
|
+
- Be concise - expand only on request`,
|
|
108
|
+
tags: ['analysis', 'dependencies', 'audit', 'architecture'],
|
|
109
|
+
version: '1.0.0',
|
|
110
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript Analysis Skills
|
|
3
|
+
*
|
|
4
|
+
* Specialized skills for code analysis workflows using AST-based tools.
|
|
5
|
+
*/
|
|
6
|
+
import type { Skill } from '@compilr-dev/agents';
|
|
7
|
+
export { defineSkill, type Skill } from '@compilr-dev/agents';
|
|
8
|
+
export { codeStructureSkill } from './code-structure.js';
|
|
9
|
+
export { dependencyAuditSkill } from './dependency-audit.js';
|
|
10
|
+
export { refactorImpactSkill } from './refactor-impact.js';
|
|
11
|
+
export { typeAnalysisSkill } from './type-analysis.js';
|
|
12
|
+
export { codeHealthSkill } from './code-health.js';
|
|
13
|
+
/**
|
|
14
|
+
* All TypeScript/JavaScript analysis skills
|
|
15
|
+
*/
|
|
16
|
+
export declare const tsSkills: Skill[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript Analysis Skills
|
|
3
|
+
*
|
|
4
|
+
* Specialized skills for code analysis workflows using AST-based tools.
|
|
5
|
+
*/
|
|
6
|
+
export { defineSkill } from '@compilr-dev/agents';
|
|
7
|
+
export { codeStructureSkill } from './code-structure.js';
|
|
8
|
+
export { dependencyAuditSkill } from './dependency-audit.js';
|
|
9
|
+
export { refactorImpactSkill } from './refactor-impact.js';
|
|
10
|
+
export { typeAnalysisSkill } from './type-analysis.js';
|
|
11
|
+
export { codeHealthSkill } from './code-health.js';
|
|
12
|
+
// Import for collection
|
|
13
|
+
import { codeStructureSkill } from './code-structure.js';
|
|
14
|
+
import { dependencyAuditSkill } from './dependency-audit.js';
|
|
15
|
+
import { refactorImpactSkill } from './refactor-impact.js';
|
|
16
|
+
import { typeAnalysisSkill } from './type-analysis.js';
|
|
17
|
+
import { codeHealthSkill } from './code-health.js';
|
|
18
|
+
/**
|
|
19
|
+
* All TypeScript/JavaScript analysis skills
|
|
20
|
+
*/
|
|
21
|
+
export const tsSkills = [
|
|
22
|
+
codeStructureSkill,
|
|
23
|
+
dependencyAuditSkill,
|
|
24
|
+
refactorImpactSkill,
|
|
25
|
+
typeAnalysisSkill,
|
|
26
|
+
codeHealthSkill,
|
|
27
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refactor Impact Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyze the impact of refactoring a symbol across the codebase.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Refactor impact skill - Analyze impact of refactoring a symbol
|
|
8
|
+
*/
|
|
9
|
+
export declare const refactorImpactSkill: import("@compilr-dev/agents").Skill;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refactor Impact Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyze the impact of refactoring a symbol across the codebase.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from '@compilr-dev/agents';
|
|
7
|
+
/**
|
|
8
|
+
* Refactor impact skill - Analyze impact of refactoring a symbol
|
|
9
|
+
*/
|
|
10
|
+
export const refactorImpactSkill = defineSkill({
|
|
11
|
+
name: 'refactor-impact',
|
|
12
|
+
description: 'Analyze the impact of refactoring a symbol across the codebase',
|
|
13
|
+
prompt: `You are in REFACTOR IMPACT ANALYSIS mode. Analyze what would be affected by refactoring a symbol.
|
|
14
|
+
|
|
15
|
+
## TOOLS TO USE
|
|
16
|
+
|
|
17
|
+
1. **find_symbol**: Locate the symbol definition
|
|
18
|
+
- Find where the symbol is defined
|
|
19
|
+
- Get its type (function, class, interface, etc.)
|
|
20
|
+
- Check if it's exported
|
|
21
|
+
|
|
22
|
+
2. **find_references**: Find all usages of the symbol
|
|
23
|
+
- Direct usages in code
|
|
24
|
+
- Import statements
|
|
25
|
+
- Type references
|
|
26
|
+
- Inheritance (extends/implements)
|
|
27
|
+
|
|
28
|
+
3. **get_call_graph**: Understand call relationships
|
|
29
|
+
- What functions call this symbol?
|
|
30
|
+
- What does this symbol call?
|
|
31
|
+
- Trace the impact chain
|
|
32
|
+
|
|
33
|
+
4. **get_type_hierarchy**: For classes/interfaces
|
|
34
|
+
- What extends or implements this?
|
|
35
|
+
- What does this extend or implement?
|
|
36
|
+
- Interface implementations affected
|
|
37
|
+
|
|
38
|
+
## ANALYSIS WORKFLOW
|
|
39
|
+
|
|
40
|
+
### Step 1: Locate the Symbol
|
|
41
|
+
\`\`\`
|
|
42
|
+
find_symbol({
|
|
43
|
+
symbol: "SymbolName",
|
|
44
|
+
scope: "/path/to/project",
|
|
45
|
+
kind: "any" // or specific: function, class, interface
|
|
46
|
+
})
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
### Step 2: Find All References
|
|
50
|
+
\`\`\`
|
|
51
|
+
find_references({
|
|
52
|
+
symbol: "SymbolName",
|
|
53
|
+
scope: "/path/to/project",
|
|
54
|
+
groupByFile: true
|
|
55
|
+
})
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
### Step 3: Analyze Call Graph (for functions/methods)
|
|
59
|
+
\`\`\`
|
|
60
|
+
get_call_graph({
|
|
61
|
+
path: "/path/to/file.ts",
|
|
62
|
+
functionName: "functionName",
|
|
63
|
+
direction: "both",
|
|
64
|
+
maxDepth: 2
|
|
65
|
+
})
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
### Step 4: Check Type Hierarchy (for classes/interfaces)
|
|
69
|
+
\`\`\`
|
|
70
|
+
get_type_hierarchy({
|
|
71
|
+
path: "/path/to/file.ts",
|
|
72
|
+
typeName: "TypeName",
|
|
73
|
+
direction: "both"
|
|
74
|
+
})
|
|
75
|
+
\`\`\`
|
|
76
|
+
|
|
77
|
+
## OUTPUT FORMAT
|
|
78
|
+
|
|
79
|
+
### Symbol Overview
|
|
80
|
+
| Property | Value |
|
|
81
|
+
|----------|-------|
|
|
82
|
+
| Name | \`SymbolName\` |
|
|
83
|
+
| Type | function / class / interface |
|
|
84
|
+
| Defined in | path/to/file.ts:42 |
|
|
85
|
+
| Exported | Yes / No |
|
|
86
|
+
|
|
87
|
+
### Direct Impact (files that directly use this symbol)
|
|
88
|
+
| File | Usages | Types |
|
|
89
|
+
|------|--------|-------|
|
|
90
|
+
| src/index.ts | 3 | import, call, call |
|
|
91
|
+
| src/service.ts | 1 | import |
|
|
92
|
+
|
|
93
|
+
### Indirect Impact (files affected through call chain)
|
|
94
|
+
| File | Distance | Path |
|
|
95
|
+
|------|----------|------|
|
|
96
|
+
| src/api.ts | 2 | api.ts → service.ts → Symbol |
|
|
97
|
+
|
|
98
|
+
### Type Hierarchy Impact (if applicable)
|
|
99
|
+
- **Extends**: ParentClass (changes may break parent contract)
|
|
100
|
+
- **Extended by**: ChildClass1, ChildClass2 (children may need updates)
|
|
101
|
+
- **Implements**: IInterface (interface changes affect all implementors)
|
|
102
|
+
- **Implemented by**: ClassA, ClassB (N implementations to update)
|
|
103
|
+
|
|
104
|
+
### Risk Assessment
|
|
105
|
+
| Risk Level | Reason |
|
|
106
|
+
|------------|--------|
|
|
107
|
+
| 🔴 HIGH | 15+ files affected, exported from public API |
|
|
108
|
+
| 🟡 MEDIUM | 5-15 files affected |
|
|
109
|
+
| 🟢 LOW | <5 files affected, internal only |
|
|
110
|
+
|
|
111
|
+
### Refactoring Checklist
|
|
112
|
+
- [ ] Update definition in source file
|
|
113
|
+
- [ ] Update N import statements
|
|
114
|
+
- [ ] Update N call sites
|
|
115
|
+
- [ ] Update N type references
|
|
116
|
+
- [ ] Update N child classes (if applicable)
|
|
117
|
+
- [ ] Run tests to verify
|
|
118
|
+
|
|
119
|
+
### Suggested Approach
|
|
120
|
+
1. Start with X because...
|
|
121
|
+
2. Then update Y...
|
|
122
|
+
3. Finally, verify with tests
|
|
123
|
+
|
|
124
|
+
## RULES
|
|
125
|
+
|
|
126
|
+
- Always start with find_symbol to understand what you're dealing with
|
|
127
|
+
- Use find_references to get complete picture
|
|
128
|
+
- Only use get_call_graph for functions/methods
|
|
129
|
+
- Only use get_type_hierarchy for classes/interfaces
|
|
130
|
+
- Quantify the impact (number of files, usages)
|
|
131
|
+
- Provide actionable checklist
|
|
132
|
+
- Highlight breaking changes for exported/public symbols`,
|
|
133
|
+
tags: ['refactoring', 'analysis', 'impact', 'planning'],
|
|
134
|
+
version: '1.0.0',
|
|
135
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Analysis Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyze type hierarchies, interfaces, and their implementations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Type analysis skill - Analyze type hierarchies and implementations
|
|
8
|
+
*/
|
|
9
|
+
export declare const typeAnalysisSkill: import("@compilr-dev/agents").Skill;
|