@aiready/context-analyzer 0.9.11 → 0.9.13
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/.turbo/turbo-build.log +6 -6
- package/.turbo/turbo-test.log +17 -17
- package/CONTRIBUTING.md +81 -33
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/context-analyzer@0.9.
|
|
3
|
+
> @aiready/context-analyzer@0.9.13 build /Users/pengcao/projects/aiready/packages/context-analyzer
|
|
4
4
|
> tsup src/index.ts src/cli.ts --format cjs,esm --dts
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[32mESM[39m [1mdist/cli.mjs [22m[32m18.53 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/python-context-UOPTQH44.mjs [22m[32m5.64 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/chunk-Y6FXYEAI.mjs [22m[32m390.00 B[39m
|
|
13
15
|
[32mESM[39m [1mdist/index.mjs [22m[32m585.00 B[39m
|
|
14
16
|
[32mESM[39m [1mdist/chunk-BD4NWUVG.mjs [22m[32m42.75 KB[39m
|
|
15
|
-
[32mESM[39m
|
|
16
|
-
[32mESM[39m [1mdist/python-context-UOPTQH44.mjs [22m[32m5.64 KB[39m
|
|
17
|
-
[32mESM[39m ⚡️ Build success in 84ms
|
|
17
|
+
[32mESM[39m ⚡️ Build success in 35ms
|
|
18
18
|
[32mCJS[39m [1mdist/cli.js [22m[32m62.78 KB[39m
|
|
19
19
|
[32mCJS[39m [1mdist/index.js [22m[32m51.03 KB[39m
|
|
20
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mCJS[39m ⚡️ Build success in 36ms
|
|
21
21
|
DTS Build start
|
|
22
|
-
DTS ⚡️ Build success in
|
|
22
|
+
DTS ⚡️ Build success in 1748ms
|
|
23
23
|
DTS dist/cli.d.ts 20.00 B
|
|
24
24
|
DTS dist/index.d.ts 6.03 KB
|
|
25
25
|
DTS dist/cli.d.mts 20.00 B
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/context-analyzer@0.9.
|
|
3
|
+
> @aiready/context-analyzer@0.9.13 test /Users/pengcao/projects/aiready/packages/context-analyzer
|
|
4
4
|
> vitest run
|
|
5
5
|
|
|
6
6
|
[?25l
|
|
7
7
|
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/Users/pengcao/projects/aiready/packages/context-analyzer[39m
|
|
8
8
|
|
|
9
|
-
[32m✓[39m src/__tests__/scoring.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m
|
|
10
|
-
[32m✓[39m dist/__tests__/scoring.test.js [2m([22m[2m7 tests[22m[2m)[22m[32m
|
|
11
|
-
[32m✓[39m
|
|
12
|
-
[32m✓[39m
|
|
13
|
-
[32m✓[39m
|
|
14
|
-
[32m✓[39m
|
|
15
|
-
[32m✓[39m
|
|
16
|
-
[32m✓[39m dist/__tests__/
|
|
17
|
-
[32m✓[39m
|
|
18
|
-
[32m✓[39m
|
|
19
|
-
[32m✓[39m src/__tests__/
|
|
20
|
-
[32m✓[39m src/__tests__/enhanced-cohesion.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/__tests__/scoring.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
10
|
+
[32m✓[39m dist/__tests__/scoring.test.js [2m([22m[2m7 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
11
|
+
[32m✓[39m src/__tests__/fragmentation-log.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 1[2mms[22m[39m
|
|
12
|
+
[32m✓[39m dist/__tests__/structural-cohesion.test.js [2m([22m[2m4 tests[22m[2m)[22m[32m 1[2mms[22m[39m
|
|
13
|
+
[32m✓[39m dist/__tests__/analyzer.test.js [2m([22m[2m14 tests[22m[2m)[22m[32m 19[2mms[22m[39m
|
|
14
|
+
[32m✓[39m dist/__tests__/fragmentation-advanced.test.js [2m([22m[2m3 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
15
|
+
[32m✓[39m src/__tests__/analyzer.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
16
|
+
[32m✓[39m dist/__tests__/auto-detection.test.js [2m([22m[2m8 tests[22m[2m)[22m[32m 24[2mms[22m[39m
|
|
17
|
+
[32m✓[39m src/__tests__/fragmentation-coupling.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
18
|
+
[32m✓[39m dist/__tests__/fragmentation-coupling.test.js [2m([22m[2m2 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
19
|
+
[32m✓[39m src/__tests__/auto-detection.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 87[2mms[22m[39m
|
|
21
20
|
[32m✓[39m dist/__tests__/fragmentation-log.test.js [2m([22m[2m3 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
22
|
-
[32m✓[39m
|
|
23
|
-
[32m✓[39m src/__tests__/structural-cohesion.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
21
|
+
[32m✓[39m src/__tests__/structural-cohesion.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
24
22
|
[32m✓[39m dist/__tests__/enhanced-cohesion.test.js [2m([22m[2m6 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
23
|
+
[32m✓[39m src/__tests__/enhanced-cohesion.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
24
|
+
[32m✓[39m src/__tests__/fragmentation-advanced.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
25
25
|
|
|
26
26
|
[2m Test Files [22m [1m[32m16 passed[39m[22m[90m (16)[39m
|
|
27
27
|
[2m Tests [22m [1m[32m94 passed[39m[22m[90m (94)[39m
|
|
28
|
-
[2m Start at [22m
|
|
29
|
-
[2m Duration [22m
|
|
28
|
+
[2m Start at [22m 22:54:42
|
|
29
|
+
[2m Duration [22m 2.38s[2m (transform 5.69s, setup 0ms, import 14.77s, tests 208ms, environment 1ms)[22m
|
|
30
30
|
|
|
31
31
|
[?25h
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
# Contributing to @aiready/
|
|
1
|
+
# Contributing to @aiready/context-analyzer
|
|
2
2
|
|
|
3
|
-
Thank you for your interest in contributing to AIReady
|
|
3
|
+
Thank you for your interest in contributing to AIReady Context Analyzer! We welcome bug reports, feature requests, and code contributions.
|
|
4
|
+
|
|
5
|
+
## 🎯 What is Context Analyzer?
|
|
6
|
+
|
|
7
|
+
The Context Analyzer measures and optimizes **context window usage** - how much of your codebase an AI model must understand to work with any given file. It helps identify:
|
|
8
|
+
|
|
9
|
+
- **High context cost files**: Files that require loading many dependencies
|
|
10
|
+
- **Deep import chains**: Complex dependency graphs that waste tokens
|
|
11
|
+
- **Low cohesion modules**: Files that import too many unrelated concerns
|
|
12
|
+
- **Context fragmentation**: Places where important code is scattered
|
|
4
13
|
|
|
5
14
|
## 🐛 Reporting Issues
|
|
6
15
|
|
|
7
|
-
Found a bug or have a feature request? [Open an issue](https://github.com/caopengau/aiready-
|
|
16
|
+
Found a bug or have a feature request? [Open an issue](https://github.com/caopengau/aiready-context-analyzer/issues) with:
|
|
8
17
|
- Clear description of the problem or feature
|
|
9
18
|
- Sample code that demonstrates the issue
|
|
10
19
|
- Expected vs actual behavior
|
|
@@ -14,8 +23,8 @@ Found a bug or have a feature request? [Open an issue](https://github.com/caopen
|
|
|
14
23
|
|
|
15
24
|
```bash
|
|
16
25
|
# Clone your fork
|
|
17
|
-
git clone https://github.com/YOUR_USERNAME/aiready-
|
|
18
|
-
cd aiready-
|
|
26
|
+
git clone https://github.com/YOUR_USERNAME/aiready-context-analyzer
|
|
27
|
+
cd aiready-context-analyzer
|
|
19
28
|
|
|
20
29
|
# Install dependencies
|
|
21
30
|
pnpm install
|
|
@@ -34,16 +43,16 @@ pnpm test
|
|
|
34
43
|
|
|
35
44
|
1. **Fork the repository** and create a new branch:
|
|
36
45
|
```bash
|
|
37
|
-
git checkout -b fix/
|
|
46
|
+
git checkout -b fix/import-depth-calculation
|
|
38
47
|
# or
|
|
39
|
-
git checkout -b feat/new-
|
|
48
|
+
git checkout -b feat/new-metric
|
|
40
49
|
```
|
|
41
50
|
|
|
42
51
|
2. **Make your changes** following our code style:
|
|
43
52
|
- Use TypeScript strict mode
|
|
44
|
-
- Add tests for new
|
|
53
|
+
- Add tests for new metrics
|
|
45
54
|
- Update README with new features
|
|
46
|
-
- Keep
|
|
55
|
+
- Keep analysis logic modular and focused
|
|
47
56
|
|
|
48
57
|
3. **Test your changes**:
|
|
49
58
|
```bash
|
|
@@ -56,21 +65,21 @@ pnpm test
|
|
|
56
65
|
|
|
57
66
|
4. **Commit using conventional commits**:
|
|
58
67
|
```bash
|
|
59
|
-
git commit -m "fix:
|
|
60
|
-
git commit -m "feat: add
|
|
68
|
+
git commit -m "fix: accurate import depth calculation"
|
|
69
|
+
git commit -m "feat: add cohesion metric"
|
|
61
70
|
```
|
|
62
71
|
|
|
63
72
|
5. **Push and open a PR**:
|
|
64
73
|
```bash
|
|
65
|
-
git push origin feat/new-
|
|
74
|
+
git push origin feat/new-metric
|
|
66
75
|
```
|
|
67
76
|
|
|
68
77
|
## 📋 Commit Convention
|
|
69
78
|
|
|
70
79
|
We use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
71
80
|
|
|
72
|
-
- `feat:` - New feature (new
|
|
73
|
-
- `fix:` - Bug fix (
|
|
81
|
+
- `feat:` - New feature (new metric, output format)
|
|
82
|
+
- `fix:` - Bug fix (calculation accuracy, false positives)
|
|
74
83
|
- `docs:` - Documentation updates
|
|
75
84
|
- `perf:` - Performance improvements
|
|
76
85
|
- `refactor:` - Code restructuring
|
|
@@ -78,28 +87,67 @@ We use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
|
78
87
|
|
|
79
88
|
## 🧪 Testing Guidelines
|
|
80
89
|
|
|
81
|
-
- Add test cases in `src/__tests__
|
|
82
|
-
- Include real-world
|
|
83
|
-
- Test edge cases (empty files,
|
|
84
|
-
- Verify output formats (console, JSON
|
|
90
|
+
- Add test cases in `src/__tests__/`
|
|
91
|
+
- Include real-world code examples
|
|
92
|
+
- Test edge cases (empty files, circular imports)
|
|
93
|
+
- Verify output formats (console, JSON)
|
|
85
94
|
|
|
86
95
|
Example test:
|
|
87
96
|
```typescript
|
|
88
|
-
test('
|
|
89
|
-
const
|
|
90
|
-
expect(
|
|
91
|
-
expect(
|
|
97
|
+
test('calculates import depth correctly', () => {
|
|
98
|
+
const result = analyzeFile('src/utils/helper.ts', [...files]);
|
|
99
|
+
expect(result.contextCost).toBe(1500);
|
|
100
|
+
expect(result.importDepth).toBe(3);
|
|
92
101
|
});
|
|
93
102
|
```
|
|
94
103
|
|
|
104
|
+
## 🏗️ Architecture
|
|
105
|
+
|
|
106
|
+
### Directory Structure
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
src/
|
|
110
|
+
├── analyzer.ts # Main orchestrator
|
|
111
|
+
├── metrics/
|
|
112
|
+
│ ├── contextCost.ts # Token cost estimation
|
|
113
|
+
│ ├── importDepth.ts # Dependency depth analysis
|
|
114
|
+
│ ├── cohesion.ts # Module cohesion scoring
|
|
115
|
+
│ └── fragmentation.ts # Context fragmentation detection
|
|
116
|
+
├── types.ts # Type definitions
|
|
117
|
+
├── cli.ts # CLI interface
|
|
118
|
+
└── index.ts # Public API exports
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Adding a New Metric
|
|
122
|
+
|
|
123
|
+
1. Create `src/metrics/your-metric.ts`:
|
|
124
|
+
```typescript
|
|
125
|
+
import type { FileAnalysis } from '../types';
|
|
126
|
+
|
|
127
|
+
export function calculateYourMetric(file: FileAnalysis): number {
|
|
128
|
+
// Your calculation logic
|
|
129
|
+
return metricValue;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
2. Update `src/types.ts` with new result types
|
|
134
|
+
|
|
135
|
+
3. Integrate in `src/analyzer.ts`
|
|
136
|
+
|
|
137
|
+
4. Add CLI options in `src/cli.ts`
|
|
138
|
+
|
|
139
|
+
5. Export from `src/index.ts`
|
|
140
|
+
|
|
141
|
+
6. Add tests in `src/__tests__/`
|
|
142
|
+
|
|
95
143
|
## 🎯 Areas for Contribution
|
|
96
144
|
|
|
97
145
|
Great places to start:
|
|
98
|
-
- **New
|
|
99
|
-
- **Better
|
|
100
|
-
- **
|
|
146
|
+
- **New metrics**: Add new context quality measurements
|
|
147
|
+
- **Better calculations**: Improve token estimation accuracy
|
|
148
|
+
- **Language support**: Add analysis for more file types
|
|
101
149
|
- **Performance**: Optimize for large codebases
|
|
102
|
-
- **
|
|
150
|
+
- **Visualization**: Add output formats or reports
|
|
103
151
|
- **Documentation**: Usage examples, best practices
|
|
104
152
|
|
|
105
153
|
## 🔍 Code Review
|
|
@@ -112,18 +160,18 @@ Great places to start:
|
|
|
112
160
|
## 📚 Documentation
|
|
113
161
|
|
|
114
162
|
- Update README.md for new features
|
|
115
|
-
- Add examples for new
|
|
163
|
+
- Add examples for new metrics
|
|
116
164
|
- Document CLI options
|
|
117
165
|
- Include real-world use cases
|
|
118
166
|
|
|
119
167
|
## 💡 Feature Ideas
|
|
120
168
|
|
|
121
169
|
Looking for inspiration? Consider:
|
|
122
|
-
- Language-specific
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
170
|
+
- Language-specific context costs (TypeScript vs Python)
|
|
171
|
+
- Framework-aware analysis (React hooks, Vue composables)
|
|
172
|
+
- Bundle size estimation
|
|
173
|
+
- Hot path analysis
|
|
174
|
+
- IDE integration
|
|
127
175
|
|
|
128
176
|
## ❓ Questions?
|
|
129
177
|
|
|
@@ -131,4 +179,4 @@ Open an issue or reach out to the maintainers. We're here to help!
|
|
|
131
179
|
|
|
132
180
|
---
|
|
133
181
|
|
|
134
|
-
**Thank you for helping
|
|
182
|
+
**Thank you for helping optimize AI context usage!** 💙
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.13",
|
|
4
4
|
"description": "AI context window cost analysis - detect fragmented code, deep import chains, and expensive context budgets",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"commander": "^14.0.0",
|
|
50
50
|
"chalk": "^5.3.0",
|
|
51
51
|
"prompts": "^2.4.2",
|
|
52
|
-
"@aiready/core": "0.9.
|
|
52
|
+
"@aiready/core": "0.9.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^24.0.0",
|