@compilr-dev/agents-coding-go 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 +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/parser/go-parser.d.ts +104 -0
- package/dist/parser/go-parser.d.ts.map +1 -0
- package/dist/parser/go-parser.js +492 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +5 -0
- package/dist/parser/node-types.d.ts +130 -0
- package/dist/parser/node-types.d.ts.map +1 -0
- package/dist/parser/node-types.js +4 -0
- package/dist/skills/go-best-practices.d.ts +7 -0
- package/dist/skills/go-best-practices.d.ts.map +1 -0
- package/dist/skills/go-best-practices.js +78 -0
- package/dist/skills/go-code-health.d.ts +7 -0
- package/dist/skills/go-code-health.d.ts.map +1 -0
- package/dist/skills/go-code-health.js +209 -0
- package/dist/skills/go-code-structure.d.ts +7 -0
- package/dist/skills/go-code-structure.d.ts.map +1 -0
- package/dist/skills/go-code-structure.js +155 -0
- package/dist/skills/go-dependency-audit.d.ts +7 -0
- package/dist/skills/go-dependency-audit.d.ts.map +1 -0
- package/dist/skills/go-dependency-audit.js +246 -0
- package/dist/skills/go-refactor-impact.d.ts +7 -0
- package/dist/skills/go-refactor-impact.d.ts.map +1 -0
- package/dist/skills/go-refactor-impact.js +232 -0
- package/dist/skills/index.d.ts +26 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +36 -0
- package/dist/tools/extract-docstrings.d.ts +51 -0
- package/dist/tools/extract-docstrings.d.ts.map +1 -0
- package/dist/tools/extract-docstrings.js +292 -0
- package/dist/tools/find-dead-code.d.ts +62 -0
- package/dist/tools/find-dead-code.d.ts.map +1 -0
- package/dist/tools/find-dead-code.js +422 -0
- package/dist/tools/find-duplicates.d.ts +65 -0
- package/dist/tools/find-duplicates.d.ts.map +1 -0
- package/dist/tools/find-duplicates.js +289 -0
- package/dist/tools/find-implementations.d.ts +71 -0
- package/dist/tools/find-implementations.d.ts.map +1 -0
- package/dist/tools/find-implementations.js +342 -0
- package/dist/tools/find-patterns.d.ts +71 -0
- package/dist/tools/find-patterns.d.ts.map +1 -0
- package/dist/tools/find-patterns.js +477 -0
- package/dist/tools/find-references.d.ts +66 -0
- package/dist/tools/find-references.d.ts.map +1 -0
- package/dist/tools/find-references.js +306 -0
- package/dist/tools/find-symbol.d.ts +86 -0
- package/dist/tools/find-symbol.d.ts.map +1 -0
- package/dist/tools/find-symbol.js +380 -0
- package/dist/tools/get-call-graph.d.ts +89 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +431 -0
- package/dist/tools/get-class-hierarchy.d.ts +34 -0
- package/dist/tools/get-class-hierarchy.d.ts.map +1 -0
- package/dist/tools/get-class-hierarchy.js +250 -0
- package/dist/tools/get-complexity.d.ts +53 -0
- package/dist/tools/get-complexity.d.ts.map +1 -0
- package/dist/tools/get-complexity.js +357 -0
- package/dist/tools/get-dependency-graph.d.ts +85 -0
- package/dist/tools/get-dependency-graph.d.ts.map +1 -0
- package/dist/tools/get-dependency-graph.js +389 -0
- package/dist/tools/get-exports.d.ts +78 -0
- package/dist/tools/get-exports.d.ts.map +1 -0
- package/dist/tools/get-exports.js +437 -0
- package/dist/tools/get-file-structure.d.ts +28 -0
- package/dist/tools/get-file-structure.d.ts.map +1 -0
- package/dist/tools/get-file-structure.js +172 -0
- package/dist/tools/get-imports.d.ts +30 -0
- package/dist/tools/get-imports.d.ts.map +1 -0
- package/dist/tools/get-imports.js +420 -0
- package/dist/tools/get-signature.d.ts +100 -0
- package/dist/tools/get-signature.d.ts.map +1 -0
- package/dist/tools/get-signature.js +800 -0
- package/dist/tools/index.d.ts +55 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +75 -0
- package/dist/tools/types.d.ts +408 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +4 -0
- package/package.json +86 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Best Practices Skill
|
|
3
|
+
*
|
|
4
|
+
* Provides guidance for Go-specific coding patterns and analysis.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from "@compilr-dev/agents";
|
|
7
|
+
export const goBestPracticesSkill = defineSkill({
|
|
8
|
+
name: "go-best-practices",
|
|
9
|
+
description: "Go-specific coding guidance and analysis workflow",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
tags: ["python", "best-practices", "analysis"],
|
|
12
|
+
prompt: `You are in Go analysis mode. Use these tools for comprehensive code understanding:
|
|
13
|
+
|
|
14
|
+
## Code Structure Analysis
|
|
15
|
+
- **getFileStructure**: Get overview of classes, functions, imports, variables
|
|
16
|
+
- Use to understand file organization
|
|
17
|
+
- Identify public API surface
|
|
18
|
+
- See class hierarchies and method signatures
|
|
19
|
+
|
|
20
|
+
## Go-Specific Guidance
|
|
21
|
+
|
|
22
|
+
### Naming Conventions (PEP 8)
|
|
23
|
+
- \`snake_case\` for functions, variables, modules
|
|
24
|
+
- \`PascalCase\` for classes
|
|
25
|
+
- \`UPPER_CASE\` for constants
|
|
26
|
+
- \`_private\` for internal use
|
|
27
|
+
- \`__dunder__\` for special methods
|
|
28
|
+
|
|
29
|
+
### Type Hints (PEP 484, 585)
|
|
30
|
+
- Always add type hints to function signatures
|
|
31
|
+
- Use \`Optional[T]\` for nullable values
|
|
32
|
+
- Use \`Union[A, B]\` for multiple types
|
|
33
|
+
- Prefer \`list[T]\` over \`List[T]\` (Go 3.9+)
|
|
34
|
+
|
|
35
|
+
### Docstrings (PEP 257)
|
|
36
|
+
- Use triple quotes for all docstrings
|
|
37
|
+
- First line is a summary
|
|
38
|
+
- Blank line before detailed description
|
|
39
|
+
- Document parameters, returns, raises
|
|
40
|
+
|
|
41
|
+
### Best Practices
|
|
42
|
+
- Use dataclasses or attrs for data containers
|
|
43
|
+
- Prefer pathlib over os.path
|
|
44
|
+
- Use f-strings over .format()
|
|
45
|
+
- Use context managers for resources
|
|
46
|
+
- Avoid mutable default arguments: \`def foo(x=None)\` not \`def foo(x=[])\`
|
|
47
|
+
- Use \`__all__\` to define public API
|
|
48
|
+
|
|
49
|
+
### Anti-Patterns to Avoid
|
|
50
|
+
- Bare \`except:\` clauses (catch specific exceptions)
|
|
51
|
+
- \`from module import *\` (explicit imports only)
|
|
52
|
+
- Global variables
|
|
53
|
+
- Deeply nested code (refactor to smaller functions)
|
|
54
|
+
- Magic numbers (use named constants)
|
|
55
|
+
|
|
56
|
+
## Analysis Workflow
|
|
57
|
+
|
|
58
|
+
1. **Understand Structure**
|
|
59
|
+
\`\`\`
|
|
60
|
+
getFileStructure for overview
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
2. **Review Complexity**
|
|
64
|
+
- Look for functions with many parameters
|
|
65
|
+
- Check for deeply nested code
|
|
66
|
+
- Identify god classes
|
|
67
|
+
|
|
68
|
+
3. **Check Code Quality**
|
|
69
|
+
- Look for missing type hints
|
|
70
|
+
- Check docstring coverage
|
|
71
|
+
- Find TODO/FIXME comments
|
|
72
|
+
|
|
73
|
+
4. **Suggest Improvements**
|
|
74
|
+
- Recommend refactoring for complex code
|
|
75
|
+
- Suggest type hints where missing
|
|
76
|
+
- Propose better naming when unclear
|
|
77
|
+
`,
|
|
78
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Code Health Skill
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates code quality analysis using complexity, dead code, duplicates, patterns, and other tools.
|
|
5
|
+
*/
|
|
6
|
+
export declare const goCodeHealthSkill: import("@compilr-dev/agents").Skill;
|
|
7
|
+
//# sourceMappingURL=go-code-health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-code-health.d.ts","sourceRoot":"","sources":["../../src/skills/go-code-health.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,iBAAiB,qCA0M5B,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Code Health Skill
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates code quality analysis using complexity, dead code, duplicates, patterns, and other tools.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from "@compilr-dev/agents";
|
|
7
|
+
export const goCodeHealthSkill = defineSkill({
|
|
8
|
+
name: "go-code-health",
|
|
9
|
+
description: "Comprehensive Go code quality and health analysis",
|
|
10
|
+
version: "1.1.0",
|
|
11
|
+
tags: ["python", "code-health", "quality", "analysis"],
|
|
12
|
+
prompt: `You are in Go code health analysis mode. Use these tools systematically:
|
|
13
|
+
|
|
14
|
+
## Health Check Workflow
|
|
15
|
+
|
|
16
|
+
### Step 1: Complexity Analysis
|
|
17
|
+
Use **get_complexity_go** to find complex code:
|
|
18
|
+
- Cyclomatic complexity > 10 indicates complex logic
|
|
19
|
+
- Cognitive complexity > 15 indicates hard-to-understand code
|
|
20
|
+
- High nesting depth suggests refactoring needed
|
|
21
|
+
- Functions with many parameters need restructuring
|
|
22
|
+
|
|
23
|
+
### Step 2: Dead Code Detection
|
|
24
|
+
Use **find_dead_code_go** to find unused code:
|
|
25
|
+
- Unused functions (defined but never called)
|
|
26
|
+
- Unused classes (defined but never instantiated)
|
|
27
|
+
- Unused variables (declared but never used)
|
|
28
|
+
- Confidence levels (high/medium/low)
|
|
29
|
+
|
|
30
|
+
### Step 3: Code Duplication
|
|
31
|
+
Use **find_duplicates_go** to detect duplicated code:
|
|
32
|
+
- Content-based hashing for exact matches
|
|
33
|
+
- Normalized comparison (ignores formatting)
|
|
34
|
+
- Identifies refactoring opportunities
|
|
35
|
+
- Shows duplication percentage
|
|
36
|
+
|
|
37
|
+
### Step 4: Anti-Patterns and Code Smells
|
|
38
|
+
Use **find_patterns_go** to find issues:
|
|
39
|
+
- Security issues (eval, exec, pickle with untrusted data)
|
|
40
|
+
- Performance issues (star imports, bare except)
|
|
41
|
+
- Maintainability issues (mutable default args, magic numbers)
|
|
42
|
+
- Custom pattern support
|
|
43
|
+
|
|
44
|
+
### Step 5: Documentation Coverage
|
|
45
|
+
Use **extract_docstrings_go** to check documentation:
|
|
46
|
+
- Functions without docstrings need documentation
|
|
47
|
+
- Missing parameter descriptions
|
|
48
|
+
- Missing return type documentation
|
|
49
|
+
- Missing exception documentation
|
|
50
|
+
|
|
51
|
+
### Step 6: Import Analysis
|
|
52
|
+
Use **get_imports_go** to review dependencies:
|
|
53
|
+
- High third-party dependency count increases risk
|
|
54
|
+
- Unused imports add clutter
|
|
55
|
+
- Circular import patterns cause issues
|
|
56
|
+
- Prefer stdlib over third-party when possible
|
|
57
|
+
|
|
58
|
+
### Step 7: Code Structure
|
|
59
|
+
Use **get_file_structure_go** to understand organization:
|
|
60
|
+
- God classes with too many methods
|
|
61
|
+
- Files with too many classes/functions
|
|
62
|
+
- Deep class hierarchies
|
|
63
|
+
- Missing __all__ for public API
|
|
64
|
+
|
|
65
|
+
## Health Metrics
|
|
66
|
+
|
|
67
|
+
### Code Complexity
|
|
68
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
69
|
+
|--------|------|------------|------------|
|
|
70
|
+
| Cyclomatic | < 5 | 5-10 | > 10 |
|
|
71
|
+
| Cognitive | < 8 | 8-15 | > 15 |
|
|
72
|
+
| Nesting | < 3 | 3-4 | > 4 |
|
|
73
|
+
| Parameters | < 4 | 4-6 | > 6 |
|
|
74
|
+
|
|
75
|
+
### Dead Code
|
|
76
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
77
|
+
|--------|------|------------|------------|
|
|
78
|
+
| Unused functions | 0 | 1-3 | > 3 |
|
|
79
|
+
| Unused classes | 0 | 1-2 | > 2 |
|
|
80
|
+
| Confidence HIGH items | 0 | 0 | > 0 |
|
|
81
|
+
|
|
82
|
+
### Code Duplication
|
|
83
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
84
|
+
|--------|------|------------|------------|
|
|
85
|
+
| Duplication % | < 3% | 3-7% | > 7% |
|
|
86
|
+
| Duplicate blocks | < 3 | 3-5 | > 5 |
|
|
87
|
+
|
|
88
|
+
### Pattern Issues
|
|
89
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
90
|
+
|--------|------|------------|------------|
|
|
91
|
+
| Security issues | 0 | 0 | > 0 |
|
|
92
|
+
| Performance issues | < 3 | 3-5 | > 5 |
|
|
93
|
+
| Maintainability | < 5 | 5-10 | > 10 |
|
|
94
|
+
|
|
95
|
+
### Documentation
|
|
96
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
97
|
+
|--------|------|------------|------------|
|
|
98
|
+
| Public funcs documented | 100% | > 80% | < 80% |
|
|
99
|
+
| Params documented | 100% | > 70% | < 70% |
|
|
100
|
+
| Classes with docstrings | 100% | > 90% | < 90% |
|
|
101
|
+
|
|
102
|
+
### Dependencies
|
|
103
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
104
|
+
|--------|------|------------|------------|
|
|
105
|
+
| Third-party imports | < 10 | 10-20 | > 20 |
|
|
106
|
+
| Local circular deps | 0 | 1-2 | > 2 |
|
|
107
|
+
|
|
108
|
+
## Quick Health Check (use for rapid assessment)
|
|
109
|
+
|
|
110
|
+
\`\`\`
|
|
111
|
+
// Step 1: Check complexity hotspots
|
|
112
|
+
get_complexity_go({
|
|
113
|
+
path: "/path/to/project",
|
|
114
|
+
recursive: true,
|
|
115
|
+
threshold: 10,
|
|
116
|
+
onlyAboveThreshold: true
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
// Step 2: Find critical patterns
|
|
120
|
+
find_patterns_go({
|
|
121
|
+
path: "/path/to/project",
|
|
122
|
+
categories: ["security", "performance"]
|
|
123
|
+
})
|
|
124
|
+
\`\`\`
|
|
125
|
+
|
|
126
|
+
## Full Health Audit
|
|
127
|
+
|
|
128
|
+
\`\`\`
|
|
129
|
+
// Step 1: Complexity analysis
|
|
130
|
+
get_complexity_go({ path: "/path/to/project", recursive: true })
|
|
131
|
+
|
|
132
|
+
// Step 2: Dead code detection
|
|
133
|
+
find_dead_code_go({ path: "/path/to/project" })
|
|
134
|
+
|
|
135
|
+
// Step 3: Duplication analysis
|
|
136
|
+
find_duplicates_go({ path: "/path/to/project", minLines: 6 })
|
|
137
|
+
|
|
138
|
+
// Step 4: Pattern analysis
|
|
139
|
+
find_patterns_go({ path: "/path/to/project", categories: ["all"] })
|
|
140
|
+
|
|
141
|
+
// Step 5: Documentation coverage
|
|
142
|
+
extract_docstrings_go({ path: "/path/to/project" })
|
|
143
|
+
\`\`\`
|
|
144
|
+
|
|
145
|
+
## Analysis Report Template
|
|
146
|
+
|
|
147
|
+
\`\`\`markdown
|
|
148
|
+
# Code Health Report
|
|
149
|
+
|
|
150
|
+
## Summary
|
|
151
|
+
| Metric | Value | Status |
|
|
152
|
+
|--------|-------|--------|
|
|
153
|
+
| Files analyzed | N | - |
|
|
154
|
+
| Avg complexity | X | Good/Warning/Critical |
|
|
155
|
+
| Max complexity | Y | Good/Warning/Critical |
|
|
156
|
+
| Dead code items | N | Good/Warning/Critical |
|
|
157
|
+
| Duplicate blocks | M | Good/Warning/Critical |
|
|
158
|
+
| Duplication % | X% | Good/Warning/Critical |
|
|
159
|
+
| Security issues | S | Good/Warning/Critical |
|
|
160
|
+
| Performance issues | P | Good/Warning/Critical |
|
|
161
|
+
|
|
162
|
+
## Complexity Hotspots (top 5)
|
|
163
|
+
| Function | File | Cyclomatic | Cognitive | Action |
|
|
164
|
+
|----------|------|------------|-----------|--------|
|
|
165
|
+
| process_order | orders.go:45 | 25 | 32 | Refactor immediately |
|
|
166
|
+
| validate_input | utils.go:120 | 15 | 18 | Consider splitting |
|
|
167
|
+
|
|
168
|
+
## Dead Code
|
|
169
|
+
| Name | File | Type | Confidence |
|
|
170
|
+
|------|------|------|------------|
|
|
171
|
+
| old_helper | utils.go:89 | function | HIGH |
|
|
172
|
+
| LegacyClass | models.go:12 | class | MEDIUM |
|
|
173
|
+
|
|
174
|
+
## Code Duplication
|
|
175
|
+
| ID | Lines | Files | Sample |
|
|
176
|
+
|----|-------|-------|--------|
|
|
177
|
+
| DUP-1 | 15 | 3 | \`def validate...\` |
|
|
178
|
+
|
|
179
|
+
## Pattern Issues
|
|
180
|
+
| Pattern | Severity | Count | Files |
|
|
181
|
+
|---------|----------|-------|-------|
|
|
182
|
+
| eval-usage | ERROR | 2 | api.go, utils.go |
|
|
183
|
+
| bare-except | WARNING | 5 | various |
|
|
184
|
+
| mutable-default | WARNING | 3 | models.go |
|
|
185
|
+
|
|
186
|
+
## Recommendations (prioritized)
|
|
187
|
+
|
|
188
|
+
### Critical (fix immediately)
|
|
189
|
+
1. **Security**: Remove eval() usage in api.go:45
|
|
190
|
+
2. **Complexity**: Refactor process_order() - split into smaller functions
|
|
191
|
+
|
|
192
|
+
### Important (fix soon)
|
|
193
|
+
1. **Dead code**: Remove unused LegacyClass
|
|
194
|
+
2. **Duplication**: Extract common validation logic (DUP-1)
|
|
195
|
+
|
|
196
|
+
### Suggestions (improve when touching these files)
|
|
197
|
+
1. Add docstrings to undocumented public functions
|
|
198
|
+
2. Fix bare except clauses - catch specific exceptions
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
## When to Use This Skill
|
|
202
|
+
|
|
203
|
+
- Before code review
|
|
204
|
+
- After major refactoring
|
|
205
|
+
- During tech debt assessment
|
|
206
|
+
- For new team member onboarding
|
|
207
|
+
- Regular health checks (weekly/monthly)
|
|
208
|
+
`,
|
|
209
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-code-structure.d.ts","sourceRoot":"","sources":["../../src/skills/go-code-structure.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,oBAAoB,qCAoJ/B,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Code Structure Skill
|
|
3
|
+
*
|
|
4
|
+
* Analyzes Go codebase structure, organization, and architecture patterns.
|
|
5
|
+
*/
|
|
6
|
+
import { defineSkill } from "@compilr-dev/agents";
|
|
7
|
+
export const goCodeStructureSkill = defineSkill({
|
|
8
|
+
name: "go-code-structure",
|
|
9
|
+
description: "Analyze Go codebase structure and organization",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
tags: ["python", "structure", "architecture", "analysis"],
|
|
12
|
+
prompt: `You are in Go code structure analysis mode. Use these tools systematically:
|
|
13
|
+
|
|
14
|
+
## Structure Analysis Workflow
|
|
15
|
+
|
|
16
|
+
### Step 1: File-Level Overview
|
|
17
|
+
Use **get_file_structure_go** to understand each file:
|
|
18
|
+
- Classes and their methods
|
|
19
|
+
- Standalone functions
|
|
20
|
+
- Module-level constants
|
|
21
|
+
- Import organization
|
|
22
|
+
|
|
23
|
+
### Step 2: Class Hierarchy
|
|
24
|
+
Use **get_class_hierarchy_go** to understand inheritance:
|
|
25
|
+
- Find parent classes (ancestors)
|
|
26
|
+
- Find child classes (descendants)
|
|
27
|
+
- Understand Method Resolution Order (MRO)
|
|
28
|
+
- Identify mixin patterns
|
|
29
|
+
|
|
30
|
+
### Step 3: Symbol Navigation
|
|
31
|
+
Use **find_symbol_go** to locate definitions:
|
|
32
|
+
- Find where functions are defined
|
|
33
|
+
- Locate class definitions
|
|
34
|
+
- Find constant declarations
|
|
35
|
+
|
|
36
|
+
### Step 4: Usage Analysis
|
|
37
|
+
Use **find_references_go** to understand usage:
|
|
38
|
+
- How classes/functions are used
|
|
39
|
+
- Import patterns across the codebase
|
|
40
|
+
- Call sites and data flow
|
|
41
|
+
|
|
42
|
+
## Go Package Structure
|
|
43
|
+
|
|
44
|
+
### Standard Package Layout
|
|
45
|
+
\`\`\`
|
|
46
|
+
my_package/
|
|
47
|
+
├── __init__.go # Package exports (__all__)
|
|
48
|
+
├── __main__.go # Entry point for python -m
|
|
49
|
+
├── core/
|
|
50
|
+
│ ├── __init__.go
|
|
51
|
+
│ └── models.go
|
|
52
|
+
├── utils/
|
|
53
|
+
│ ├── __init__.go
|
|
54
|
+
│ └── helpers.go
|
|
55
|
+
├── cli.go # CLI entry point
|
|
56
|
+
└── py.typed # PEP 561 marker
|
|
57
|
+
\`\`\`
|
|
58
|
+
|
|
59
|
+
### Test Structure
|
|
60
|
+
\`\`\`
|
|
61
|
+
tests/
|
|
62
|
+
├── __init__.go
|
|
63
|
+
├── conftest.go # pytest fixtures
|
|
64
|
+
├── test_core/
|
|
65
|
+
│ └── test_models.go
|
|
66
|
+
└── test_utils/
|
|
67
|
+
└── test_helpers.go
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
## Patterns to Look For
|
|
71
|
+
|
|
72
|
+
### Good Patterns
|
|
73
|
+
- **Layered Architecture**: Clear separation of concerns
|
|
74
|
+
- **Dependency Injection**: Loose coupling via constructor params
|
|
75
|
+
- **Interface Segregation**: Small, focused abstract base classes
|
|
76
|
+
- **Composition over Inheritance**: Prefer has-a over is-a
|
|
77
|
+
|
|
78
|
+
### Anti-Patterns
|
|
79
|
+
- **God Class**: Class with too many responsibilities (>10 methods, >500 lines)
|
|
80
|
+
- **Circular Dependencies**: Module A imports B, B imports A
|
|
81
|
+
- **Deep Inheritance**: More than 3 levels of inheritance
|
|
82
|
+
- **Spaghetti Code**: No clear structure or organization
|
|
83
|
+
- **Feature Envy**: Methods that use other class's data more than their own
|
|
84
|
+
|
|
85
|
+
## Structure Metrics
|
|
86
|
+
|
|
87
|
+
### File Level
|
|
88
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
89
|
+
|--------|------|------------|------------|
|
|
90
|
+
| Lines per file | < 300 | 300-500 | > 500 |
|
|
91
|
+
| Classes per file | 1-3 | 4-5 | > 5 |
|
|
92
|
+
| Functions per file | < 15 | 15-25 | > 25 |
|
|
93
|
+
| Imports | < 15 | 15-25 | > 25 |
|
|
94
|
+
|
|
95
|
+
### Class Level
|
|
96
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
97
|
+
|--------|------|------------|------------|
|
|
98
|
+
| Methods per class | < 10 | 10-15 | > 15 |
|
|
99
|
+
| Lines per class | < 200 | 200-400 | > 400 |
|
|
100
|
+
| Inheritance depth | 1-2 | 3 | > 3 |
|
|
101
|
+
| Public methods | < 8 | 8-12 | > 12 |
|
|
102
|
+
|
|
103
|
+
### Function Level
|
|
104
|
+
| Metric | Good | Acceptable | Needs Work |
|
|
105
|
+
|--------|------|------------|------------|
|
|
106
|
+
| Lines per function | < 20 | 20-40 | > 40 |
|
|
107
|
+
| Parameters | < 4 | 4-6 | > 6 |
|
|
108
|
+
| Return paths | < 3 | 3-5 | > 5 |
|
|
109
|
+
|
|
110
|
+
## Common Refactoring Suggestions
|
|
111
|
+
|
|
112
|
+
1. **Extract Class**: Split large class into smaller focused ones
|
|
113
|
+
2. **Extract Function**: Break long functions into smaller ones
|
|
114
|
+
3. **Move Method**: Move method to class where data lives
|
|
115
|
+
4. **Introduce Abstract Base Class**: Create interface for polymorphism
|
|
116
|
+
5. **Replace Inheritance with Composition**: Use delegation instead
|
|
117
|
+
|
|
118
|
+
## Structure Report Template
|
|
119
|
+
|
|
120
|
+
\`\`\`markdown
|
|
121
|
+
# Code Structure Report
|
|
122
|
+
|
|
123
|
+
## Overview
|
|
124
|
+
- Total files: N
|
|
125
|
+
- Total classes: N
|
|
126
|
+
- Total functions: N
|
|
127
|
+
|
|
128
|
+
## Package Organization
|
|
129
|
+
- Root: my_package/
|
|
130
|
+
- Key modules: core, utils, api
|
|
131
|
+
|
|
132
|
+
## Class Hierarchy
|
|
133
|
+
1. BaseClass
|
|
134
|
+
├── ChildA
|
|
135
|
+
└── ChildB
|
|
136
|
+
└── GrandChild
|
|
137
|
+
|
|
138
|
+
## Hotspots
|
|
139
|
+
1. large_module.go - 600 lines, 8 classes
|
|
140
|
+
2. god_class.go::MegaClass - 25 methods
|
|
141
|
+
|
|
142
|
+
## Recommendations
|
|
143
|
+
1. Split large_module.go into smaller modules
|
|
144
|
+
2. Extract responsibilities from MegaClass
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
## When to Use This Skill
|
|
148
|
+
|
|
149
|
+
- Onboarding to a new codebase
|
|
150
|
+
- Before major refactoring
|
|
151
|
+
- Architecture review
|
|
152
|
+
- Documentation generation
|
|
153
|
+
- Understanding legacy code
|
|
154
|
+
`,
|
|
155
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-dependency-audit.d.ts","sourceRoot":"","sources":["../../src/skills/go-dependency-audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,sBAAsB,qCA+OjC,CAAC"}
|