codexia 0.2.0 → 0.3.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/CHANGELOG.md +55 -51
- package/README.md +67 -0
- package/dist/ai/config.d.ts +11 -0
- package/dist/ai/config.d.ts.map +1 -0
- package/dist/ai/config.js +51 -0
- package/dist/ai/config.js.map +1 -0
- package/dist/ai/explainer.d.ts +32 -0
- package/dist/ai/explainer.d.ts.map +1 -0
- package/dist/ai/explainer.js +118 -0
- package/dist/ai/explainer.js.map +1 -0
- package/dist/ai/index.d.ts +23 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +47 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/prompts/impact-explain.d.ts +6 -0
- package/dist/ai/prompts/impact-explain.d.ts.map +1 -0
- package/dist/ai/prompts/impact-explain.js +50 -0
- package/dist/ai/prompts/impact-explain.js.map +1 -0
- package/dist/ai/prompts/pr-describe.d.ts +13 -0
- package/dist/ai/prompts/pr-describe.d.ts.map +1 -0
- package/dist/ai/prompts/pr-describe.js +65 -0
- package/dist/ai/prompts/pr-describe.js.map +1 -0
- package/dist/ai/prompts/pr-review.d.ts +18 -0
- package/dist/ai/prompts/pr-review.d.ts.map +1 -0
- package/dist/ai/prompts/pr-review.js +61 -0
- package/dist/ai/prompts/pr-review.js.map +1 -0
- package/dist/ai/provider.d.ts +6 -0
- package/dist/ai/provider.d.ts.map +1 -0
- package/dist/ai/provider.js +19 -0
- package/dist/ai/provider.js.map +1 -0
- package/dist/ai/providers/anthropic.d.ts +14 -0
- package/dist/ai/providers/anthropic.d.ts.map +1 -0
- package/dist/ai/providers/anthropic.js +53 -0
- package/dist/ai/providers/anthropic.js.map +1 -0
- package/dist/ai/providers/ollama.d.ts +13 -0
- package/dist/ai/providers/ollama.d.ts.map +1 -0
- package/dist/ai/providers/ollama.js +64 -0
- package/dist/ai/providers/ollama.js.map +1 -0
- package/dist/ai/providers/openai.d.ts +14 -0
- package/dist/ai/providers/openai.d.ts.map +1 -0
- package/dist/ai/providers/openai.js +42 -0
- package/dist/ai/providers/openai.js.map +1 -0
- package/dist/ai/types.d.ts +29 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +5 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +3 -0
- package/dist/cli/commands/dashboard.d.ts.map +1 -0
- package/dist/cli/commands/dashboard.js +30 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/commands/graph.js +1 -1
- package/dist/cli/commands/graph.js.map +1 -1
- package/dist/cli/commands/impact.d.ts.map +1 -1
- package/dist/cli/commands/impact.js +23 -0
- package/dist/cli/commands/impact.js.map +1 -1
- package/dist/cli/commands/pr-report.d.ts.map +1 -1
- package/dist/cli/commands/pr-report.js +49 -0
- package/dist/cli/commands/pr-report.js.map +1 -1
- package/dist/cli/engine.d.ts +65 -2
- package/dist/cli/engine.d.ts.map +1 -1
- package/dist/cli/engine.js +136 -2
- package/dist/cli/engine.js.map +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/interactive.js +1 -1
- package/dist/cli/interactive.js.map +1 -1
- package/dist/core/dependency-graph.d.ts +3 -1
- package/dist/core/dependency-graph.d.ts.map +1 -1
- package/dist/core/dependency-graph.js +20 -7
- package/dist/core/dependency-graph.js.map +1 -1
- package/dist/core/language-providers/index.d.ts +9 -0
- package/dist/core/language-providers/index.d.ts.map +1 -0
- package/dist/core/language-providers/index.js +12 -0
- package/dist/core/language-providers/index.js.map +1 -0
- package/dist/core/language-providers/providers/go.d.ts +20 -0
- package/dist/core/language-providers/providers/go.d.ts.map +1 -0
- package/dist/core/language-providers/providers/go.js +256 -0
- package/dist/core/language-providers/providers/go.js.map +1 -0
- package/dist/core/language-providers/providers/java.d.ts +20 -0
- package/dist/core/language-providers/providers/java.d.ts.map +1 -0
- package/dist/core/language-providers/providers/java.js +234 -0
- package/dist/core/language-providers/providers/java.js.map +1 -0
- package/dist/core/language-providers/providers/python.d.ts +20 -0
- package/dist/core/language-providers/providers/python.d.ts.map +1 -0
- package/dist/core/language-providers/providers/python.js +267 -0
- package/dist/core/language-providers/providers/python.js.map +1 -0
- package/dist/core/language-providers/providers/ruby.d.ts +20 -0
- package/dist/core/language-providers/providers/ruby.d.ts.map +1 -0
- package/dist/core/language-providers/providers/ruby.js +281 -0
- package/dist/core/language-providers/providers/ruby.js.map +1 -0
- package/dist/core/language-providers/providers/rust.d.ts +20 -0
- package/dist/core/language-providers/providers/rust.d.ts.map +1 -0
- package/dist/core/language-providers/providers/rust.js +384 -0
- package/dist/core/language-providers/providers/rust.js.map +1 -0
- package/dist/core/language-providers/providers/typescript.d.ts +20 -0
- package/dist/core/language-providers/providers/typescript.d.ts.map +1 -0
- package/dist/core/language-providers/providers/typescript.js +300 -0
- package/dist/core/language-providers/providers/typescript.js.map +1 -0
- package/dist/core/language-providers/registry.d.ts +59 -0
- package/dist/core/language-providers/registry.d.ts.map +1 -0
- package/dist/core/language-providers/registry.js +133 -0
- package/dist/core/language-providers/registry.js.map +1 -0
- package/dist/core/language-providers/types.d.ts +55 -0
- package/dist/core/language-providers/types.d.ts.map +1 -0
- package/dist/core/language-providers/types.js +29 -0
- package/dist/core/language-providers/types.js.map +1 -0
- package/dist/core/repo-indexer.d.ts +10 -4
- package/dist/core/repo-indexer.d.ts.map +1 -1
- package/dist/core/repo-indexer.js +24 -26
- package/dist/core/repo-indexer.js.map +1 -1
- package/dist/dashboard/client/src/App.d.ts +3 -0
- package/dist/dashboard/client/src/App.d.ts.map +1 -0
- package/dist/dashboard/client/src/App.js +127 -0
- package/dist/dashboard/client/src/App.js.map +1 -0
- package/dist/dashboard/client/src/api.d.ts +9 -0
- package/dist/dashboard/client/src/api.d.ts.map +1 -0
- package/dist/dashboard/client/src/api.js +30 -0
- package/dist/dashboard/client/src/api.js.map +1 -0
- package/dist/dashboard/client/src/components/ActivityChart.d.ts +7 -0
- package/dist/dashboard/client/src/components/ActivityChart.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/ActivityChart.js +76 -0
- package/dist/dashboard/client/src/components/ActivityChart.js.map +1 -0
- package/dist/dashboard/client/src/components/Card.d.ts +21 -0
- package/dist/dashboard/client/src/components/Card.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/Card.js +35 -0
- package/dist/dashboard/client/src/components/Card.js.map +1 -0
- package/dist/dashboard/client/src/components/ComplexityHeatmap.d.ts +7 -0
- package/dist/dashboard/client/src/components/ComplexityHeatmap.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/ComplexityHeatmap.js +55 -0
- package/dist/dashboard/client/src/components/ComplexityHeatmap.js.map +1 -0
- package/dist/dashboard/client/src/components/ErrorDisplay.d.ts +7 -0
- package/dist/dashboard/client/src/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/ErrorDisplay.js +14 -0
- package/dist/dashboard/client/src/components/ErrorDisplay.js.map +1 -0
- package/dist/dashboard/client/src/components/HealthScore.d.ts +7 -0
- package/dist/dashboard/client/src/components/HealthScore.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/HealthScore.js +66 -0
- package/dist/dashboard/client/src/components/HealthScore.js.map +1 -0
- package/dist/dashboard/client/src/components/HotPathsList.d.ts +8 -0
- package/dist/dashboard/client/src/components/HotPathsList.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/HotPathsList.js +59 -0
- package/dist/dashboard/client/src/components/HotPathsList.js.map +1 -0
- package/dist/dashboard/client/src/components/LanguageBreakdown.d.ts +6 -0
- package/dist/dashboard/client/src/components/LanguageBreakdown.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/LanguageBreakdown.js +49 -0
- package/dist/dashboard/client/src/components/LanguageBreakdown.js.map +1 -0
- package/dist/dashboard/client/src/components/Loading.d.ts +4 -0
- package/dist/dashboard/client/src/components/Loading.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/Loading.js +25 -0
- package/dist/dashboard/client/src/components/Loading.js.map +1 -0
- package/dist/dashboard/client/src/components/SignalsList.d.ts +8 -0
- package/dist/dashboard/client/src/components/SignalsList.d.ts.map +1 -0
- package/dist/dashboard/client/src/components/SignalsList.js +70 -0
- package/dist/dashboard/client/src/components/SignalsList.js.map +1 -0
- package/dist/dashboard/client/src/hooks/useApi.d.ts +9 -0
- package/dist/dashboard/client/src/hooks/useApi.d.ts.map +1 -0
- package/dist/dashboard/client/src/hooks/useApi.js +19 -0
- package/dist/dashboard/client/src/hooks/useApi.js.map +1 -0
- package/dist/dashboard/client/src/main.d.ts +2 -0
- package/dist/dashboard/client/src/main.d.ts.map +1 -0
- package/dist/dashboard/client/src/main.js +8 -0
- package/dist/dashboard/client/src/main.js.map +1 -0
- package/dist/dashboard/client/src/types.d.ts +85 -0
- package/dist/dashboard/client/src/types.d.ts.map +1 -0
- package/dist/dashboard/client/src/types.js +2 -0
- package/dist/dashboard/client/src/types.js.map +1 -0
- package/dist/dashboard/client/vite.config.d.ts +3 -0
- package/dist/dashboard/client/vite.config.d.ts.map +1 -0
- package/dist/dashboard/client/vite.config.js +24 -0
- package/dist/dashboard/client/vite.config.js.map +1 -0
- package/dist/dashboard/index.d.ts +3 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/server/index.d.ts +108 -0
- package/dist/dashboard/server/index.d.ts.map +1 -0
- package/dist/dashboard/server/index.js +740 -0
- package/dist/dashboard/server/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/modules/complexity-engine.d.ts +1 -0
- package/dist/modules/complexity-engine.d.ts.map +1 -1
- package/dist/modules/complexity-engine.js +26 -18
- package/dist/modules/complexity-engine.js.map +1 -1
- package/dist/modules/graph-utils.d.ts +7 -2
- package/dist/modules/graph-utils.d.ts.map +1 -1
- package/dist/modules/graph-utils.js +17 -11
- package/dist/modules/graph-utils.js.map +1 -1
- package/package.json +9 -4
- package/src/dashboard/dist/assets/index-DwKWIJD-.css +1 -0
- package/src/dashboard/dist/assets/index-jqRzjhTn.js +226 -0
- package/src/dashboard/dist/codexia-icon.svg +10 -0
- package/src/dashboard/dist/index.html +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,70 +1,74 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
### What's Changed
|
|
6
|
-
|
|
7
|
-
- chore: release v0.1.0 (2dabe28)
|
|
8
|
-
- fix: fix version bump step with logging for better visibility (46e0351)
|
|
9
|
-
- chore: release v0.1.0 (e6456e4)
|
|
10
|
-
- feat: enhance release workflow with separate push for version bump and tag (0a1f061)
|
|
11
|
-
- chore: release v0.3.0 (3075ea2)
|
|
12
|
-
- chore: add release workflow for automated versioning and publishing (#11) (d8846d4)
|
|
13
|
-
- feat: add interactive wizard for command selection and execution (#6) (37610b2)
|
|
14
|
-
- feat: Add 12 new analysis modules and MCP server (#4) (d02f673)
|
|
15
|
-
- feat: Add new commands and features to Codexia CLI (#1) (900702f)
|
|
16
|
-
- chore: Add GitHub Actions CI workflow for testing and building (#2) (3370888)
|
|
17
|
-
- Initial commit (02b3f9a)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## [v0.1.0] - 2026-01-17
|
|
21
|
-
|
|
22
|
-
### What's Changed
|
|
23
|
-
|
|
24
|
-
- fix: fix version bump step with logging for better visibility (46e0351)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## [v0.1.0] - 2026-01-17
|
|
28
|
-
|
|
29
|
-
### What's Changed
|
|
30
|
-
|
|
31
|
-
|
|
3
|
+
All notable changes to Codexia will be documented in this file.
|
|
32
4
|
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
33
7
|
|
|
34
|
-
## [v0.3.0] - 2026-01-17
|
|
35
8
|
|
|
36
|
-
|
|
9
|
+
## [0.3.0] - 2026-01-18
|
|
37
10
|
|
|
38
|
-
|
|
39
|
-
- feat: add interactive wizard for command selection and execution (#6) (37610b2)
|
|
40
|
-
- feat: Add 12 new analysis modules and MCP server (#4) (d02f673)
|
|
41
|
-
- feat: Add new commands and features to Codexia CLI (#1) (900702f)
|
|
42
|
-
- chore: Add GitHub Actions CI workflow for testing and building (#2) (3370888)
|
|
43
|
-
- Initial commit (02b3f9a)
|
|
11
|
+
### Added
|
|
44
12
|
|
|
13
|
+
#### 📊 Web Dashboard
|
|
14
|
+
- **Real-time Dashboard** (`codexia dashboard`) — Beautiful, modern web interface for repository visualization
|
|
15
|
+
- Repository health score with interactive breakdown
|
|
16
|
+
- Complexity heatmap with clickable file details
|
|
17
|
+
- Code signals list with severity filtering
|
|
18
|
+
- Hot paths visualization
|
|
19
|
+
- Team leaderboard with contributor statistics
|
|
20
|
+
- GitHub-style commit activity heatmap
|
|
21
|
+
- Code ownership and bus factor analysis
|
|
22
|
+
- Branch overview with stale branch detection
|
|
23
|
+
- Interactive modals with detailed information for all items
|
|
24
|
+
- **Modern Dark Theme** — Vercel-inspired design with smooth animations
|
|
25
|
+
- Pure black background with subtle neutral accents
|
|
26
|
+
- Inter + JetBrains Mono typography
|
|
27
|
+
- Smooth modal open/close animations
|
|
28
|
+
- Hover effects and micro-interactions
|
|
29
|
+
|
|
30
|
+
#### 🤖 AI Integration
|
|
31
|
+
- **Multi-Provider AI Support** — Optional AI-powered features with graceful fallback
|
|
32
|
+
- OpenAI integration (GPT-4, GPT-3.5)
|
|
33
|
+
- Anthropic integration (Claude)
|
|
34
|
+
- Ollama integration (local models, free)
|
|
35
|
+
- Automatic provider detection from environment variables
|
|
36
|
+
- Graceful fallback when no API keys configured
|
|
37
|
+
|
|
38
|
+
#### 🌍 Multi-Language Support
|
|
39
|
+
- **Python** — Full symbol extraction, import analysis, complexity metrics
|
|
40
|
+
- **Ruby** — Class, method, and module detection with gem dependencies
|
|
41
|
+
- **Java** — Package imports, class hierarchy, and annotation support
|
|
42
|
+
- **Go** — Package analysis, struct/interface extraction, import detection
|
|
43
|
+
- **Rust** — Mod/use statements, struct/enum/trait/impl detection
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
### Changed
|
|
46
|
+
- Dashboard REST API now includes git statistics endpoints
|
|
47
|
+
- Improved error handling across all API endpoints
|
|
48
|
+
- Enhanced type definitions for multi-language support
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
### Technical
|
|
51
|
+
- Added `src/ai/` module with provider abstraction
|
|
52
|
+
- Added `src/languages/` with 6 language providers
|
|
53
|
+
- Added `src/dashboard/` with React + Vite + Tailwind client
|
|
54
|
+
- Native Node.js HTTP server (no Express dependency)
|
|
55
|
+
- Comprehensive TypeScript types for all features
|
|
50
56
|
|
|
51
|
-
## [
|
|
57
|
+
## [v0.2.0] - 2026-01-17
|
|
52
58
|
|
|
53
59
|
### Added
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
- Guided prompts for paths, options, and output formats
|
|
58
|
-
- Built with `@inquirer/prompts` for a modern CLI experience
|
|
60
|
+
- Interactive wizard mode with guided prompts
|
|
61
|
+
- 12 new analysis modules
|
|
62
|
+
- MCP server for AI assistant integration
|
|
59
63
|
|
|
60
64
|
### Fixed
|
|
65
|
+
- Graph command data transformation
|
|
66
|
+
- Changelog auto-detection for repos without tags
|
|
67
|
+
- Hot paths graceful error handling
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
- **Changelog command** — Auto-detects repository root commit when no tags exist; fixed formatter to handle actual engine output structure
|
|
64
|
-
- **Hot paths command** — Gracefully handles missing entry points and paths data
|
|
65
|
-
- **History command** — Fixed undefined values in summary output with proper fallbacks
|
|
69
|
+
---
|
|
66
70
|
|
|
67
|
-
## [
|
|
71
|
+
## [v0.2.0] - 2026-01-13
|
|
68
72
|
|
|
69
73
|
### Added
|
|
70
74
|
|
package/README.md
CHANGED
|
@@ -185,6 +185,72 @@ codexia mcp-server # Start stdio server (for Claude)
|
|
|
185
185
|
codexia mcp-server --port 3000 # Start HTTP server
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
+
### 📊 **Web Dashboard**
|
|
189
|
+
|
|
190
|
+
Beautiful, real-time visualization of your repository health.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
codexia dashboard # Start dashboard server
|
|
194
|
+
codexia dashboard --port 3200 # Custom port
|
|
195
|
+
codexia dashboard --open # Auto-open in browser
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The dashboard provides:
|
|
199
|
+
- **Repository Health Score** — Overall health with breakdown
|
|
200
|
+
- **Complexity Heatmap** — Visual file complexity overview
|
|
201
|
+
- **Code Signals** — Issues ranked by severity
|
|
202
|
+
- **Hot Paths** — Critical areas needing attention
|
|
203
|
+
- **Team Leaderboard** — Contributor stats and activity
|
|
204
|
+
- **Commit Activity** — GitHub-style contribution heatmap
|
|
205
|
+
- **Code Ownership** — Bus factor and knowledge silo risks
|
|
206
|
+
- **Branch Overview** — Active and stale branches
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## AI Integration
|
|
211
|
+
|
|
212
|
+
Codexia includes optional AI-powered features for enhanced analysis:
|
|
213
|
+
|
|
214
|
+
### Configuration
|
|
215
|
+
|
|
216
|
+
Set your preferred AI provider via environment variables:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# OpenAI
|
|
220
|
+
export OPENAI_API_KEY=sk-...
|
|
221
|
+
|
|
222
|
+
# Anthropic
|
|
223
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
224
|
+
|
|
225
|
+
# Ollama (local, free)
|
|
226
|
+
export OLLAMA_HOST=http://localhost:11434
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Features
|
|
230
|
+
|
|
231
|
+
AI integration enables:
|
|
232
|
+
- **Smart commit message generation**
|
|
233
|
+
- **Enhanced code explanations**
|
|
234
|
+
- **Intelligent refactoring suggestions**
|
|
235
|
+
- **Natural language queries** about your codebase
|
|
236
|
+
|
|
237
|
+
The system gracefully falls back if no API keys are configured—all core analysis features work without AI.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Multi-Language Support
|
|
242
|
+
|
|
243
|
+
Codexia supports analysis across multiple programming languages:
|
|
244
|
+
|
|
245
|
+
| Language | Symbols | Dependencies | Complexity |
|
|
246
|
+
|----------|---------|--------------|------------|
|
|
247
|
+
| TypeScript/JavaScript | ✅ | ✅ | ✅ |
|
|
248
|
+
| Python | ✅ | ✅ | ✅ |
|
|
249
|
+
| Ruby | ✅ | ✅ | ✅ |
|
|
250
|
+
| Java | ✅ | ✅ | ✅ |
|
|
251
|
+
| Go | ✅ | ✅ | ✅ |
|
|
252
|
+
| Rust | ✅ | ✅ | ✅ |
|
|
253
|
+
|
|
188
254
|
---
|
|
189
255
|
|
|
190
256
|
## Installation
|
|
@@ -337,6 +403,7 @@ Commands:
|
|
|
337
403
|
changelog Generate semantic changelog
|
|
338
404
|
monorepo Analyze monorepo structure
|
|
339
405
|
mcp-server Start MCP server for AI tools
|
|
406
|
+
dashboard Start web dashboard
|
|
340
407
|
|
|
341
408
|
Options:
|
|
342
409
|
--json Output as JSON
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AIConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load AI configuration from environment variables.
|
|
4
|
+
* Returns null if AI is not configured - this signals graceful fallback.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getAIConfig(): AIConfig | null;
|
|
7
|
+
/**
|
|
8
|
+
* Check if AI is enabled (has valid configuration)
|
|
9
|
+
*/
|
|
10
|
+
export declare function isAIEnabled(): boolean;
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/ai/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,IAAI,CA+B7C;AAeD;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load AI configuration from environment variables.
|
|
3
|
+
* Returns null if AI is not configured - this signals graceful fallback.
|
|
4
|
+
*/
|
|
5
|
+
export function getAIConfig() {
|
|
6
|
+
const provider = process.env.CODEXIA_AI_PROVIDER;
|
|
7
|
+
const apiKey = process.env.CODEXIA_AI_API_KEY;
|
|
8
|
+
const baseUrl = process.env.CODEXIA_AI_BASE_URL;
|
|
9
|
+
const model = process.env.CODEXIA_AI_MODEL;
|
|
10
|
+
// For OpenAI/Anthropic, require API key
|
|
11
|
+
// For Ollama, just require provider to be set (local, no key needed)
|
|
12
|
+
if (!provider) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (provider === 'ollama') {
|
|
16
|
+
return {
|
|
17
|
+
provider,
|
|
18
|
+
baseUrl: baseUrl || 'http://localhost:11434',
|
|
19
|
+
model: model || 'llama3',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// OpenAI and Anthropic require API key
|
|
23
|
+
if (!apiKey) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
provider,
|
|
28
|
+
apiKey,
|
|
29
|
+
baseUrl,
|
|
30
|
+
model: model || getDefaultModel(provider),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function getDefaultModel(provider) {
|
|
34
|
+
switch (provider) {
|
|
35
|
+
case 'openai':
|
|
36
|
+
return 'gpt-4o';
|
|
37
|
+
case 'anthropic':
|
|
38
|
+
return 'claude-3-5-sonnet-20241022';
|
|
39
|
+
case 'ollama':
|
|
40
|
+
return 'llama3';
|
|
41
|
+
default:
|
|
42
|
+
return 'gpt-4o';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if AI is enabled (has valid configuration)
|
|
47
|
+
*/
|
|
48
|
+
export function isAIEnabled() {
|
|
49
|
+
return getAIConfig() !== null;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/ai/config.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAuD,CAAC;IACrF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAE3C,wCAAwC;IACxC,qEAAqE;IACrE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO;YACL,QAAQ;YACR,OAAO,EAAE,OAAO,IAAI,wBAAwB;YAC5C,KAAK,EAAE,KAAK,IAAI,QAAQ;SACzB,CAAC;IACJ,CAAC;IAED,uCAAuC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,QAAQ;QACR,MAAM;QACN,OAAO;QACP,KAAK,EAAE,KAAK,IAAI,eAAe,CAAC,QAAQ,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,QAA8B;IACrD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,WAAW;YACd,OAAO,4BAA4B,CAAC;QACtC,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,WAAW,EAAE,KAAK,IAAI,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AIProvider, AIExplanation } from './types.js';
|
|
2
|
+
import type { ImpactResult } from '../core/types.js';
|
|
3
|
+
import { type PrReportData } from './prompts/pr-review.js';
|
|
4
|
+
import { type PrDescribeData } from './prompts/pr-describe.js';
|
|
5
|
+
/**
|
|
6
|
+
* AI Explainer - generates natural language explanations for analysis results
|
|
7
|
+
*/
|
|
8
|
+
export declare class AIExplainer {
|
|
9
|
+
private provider;
|
|
10
|
+
constructor(provider: AIProvider);
|
|
11
|
+
/**
|
|
12
|
+
* Explain impact analysis results in natural language
|
|
13
|
+
*/
|
|
14
|
+
explainImpact(impact: ImpactResult): Promise<AIExplanation>;
|
|
15
|
+
/**
|
|
16
|
+
* Generate AI-powered PR review summary
|
|
17
|
+
*/
|
|
18
|
+
reviewPr(data: PrReportData): Promise<AIExplanation>;
|
|
19
|
+
/**
|
|
20
|
+
* Generate a PR description from commits and impact analysis
|
|
21
|
+
*/
|
|
22
|
+
describePr(data: PrDescribeData): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Answer a question about the codebase
|
|
25
|
+
*/
|
|
26
|
+
askQuestion(question: string, context: {
|
|
27
|
+
architecture?: string;
|
|
28
|
+
fileContext?: string;
|
|
29
|
+
dependencies?: string;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=explainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explainer.d.ts","sourceRoot":"","sources":["../../src/ai/explainer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzF;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,UAAU;IAExC;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBjE;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAoB1D;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BvD;;OAEG;IACG,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GACA,OAAO,CAAC,MAAM,CAAC;CAiCnB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { buildImpactExplanationPrompt } from './prompts/impact-explain.js';
|
|
2
|
+
import { buildPrReviewPrompt } from './prompts/pr-review.js';
|
|
3
|
+
import { buildPrDescriptionPrompt } from './prompts/pr-describe.js';
|
|
4
|
+
/**
|
|
5
|
+
* AI Explainer - generates natural language explanations for analysis results
|
|
6
|
+
*/
|
|
7
|
+
export class AIExplainer {
|
|
8
|
+
provider;
|
|
9
|
+
constructor(provider) {
|
|
10
|
+
this.provider = provider;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Explain impact analysis results in natural language
|
|
14
|
+
*/
|
|
15
|
+
async explainImpact(impact) {
|
|
16
|
+
const prompt = buildImpactExplanationPrompt(impact);
|
|
17
|
+
try {
|
|
18
|
+
const summary = await this.provider.complete(prompt, {
|
|
19
|
+
maxTokens: 500,
|
|
20
|
+
temperature: 0.3,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
summary: summary.trim(),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
// Graceful fallback - return empty explanation on error
|
|
28
|
+
return {
|
|
29
|
+
summary: '',
|
|
30
|
+
details: `AI explanation unavailable: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate AI-powered PR review summary
|
|
36
|
+
*/
|
|
37
|
+
async reviewPr(data) {
|
|
38
|
+
const prompt = buildPrReviewPrompt(data);
|
|
39
|
+
try {
|
|
40
|
+
const summary = await this.provider.complete(prompt, {
|
|
41
|
+
maxTokens: 800,
|
|
42
|
+
temperature: 0.4,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
summary: summary.trim(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
summary: '',
|
|
51
|
+
details: `AI review unavailable: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Generate a PR description from commits and impact analysis
|
|
57
|
+
*/
|
|
58
|
+
async describePr(data) {
|
|
59
|
+
const prompt = buildPrDescriptionPrompt(data);
|
|
60
|
+
try {
|
|
61
|
+
const description = await this.provider.complete(prompt, {
|
|
62
|
+
maxTokens: 1500,
|
|
63
|
+
temperature: 0.5,
|
|
64
|
+
});
|
|
65
|
+
return description.trim();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
// Return a template on error
|
|
69
|
+
return `## What
|
|
70
|
+
<!-- Describe what this PR does -->
|
|
71
|
+
|
|
72
|
+
## Why
|
|
73
|
+
<!-- Explain the motivation -->
|
|
74
|
+
|
|
75
|
+
## How
|
|
76
|
+
<!-- Technical implementation details -->
|
|
77
|
+
|
|
78
|
+
## Testing
|
|
79
|
+
<!-- How was this tested -->
|
|
80
|
+
|
|
81
|
+
_AI description generation failed: ${error instanceof Error ? error.message : 'Unknown error'}_`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Answer a question about the codebase
|
|
86
|
+
*/
|
|
87
|
+
async askQuestion(question, context) {
|
|
88
|
+
const contextParts = [];
|
|
89
|
+
if (context.architecture) {
|
|
90
|
+
contextParts.push(`## Project Architecture\n${context.architecture}`);
|
|
91
|
+
}
|
|
92
|
+
if (context.fileContext) {
|
|
93
|
+
contextParts.push(`## Relevant Code\n${context.fileContext}`);
|
|
94
|
+
}
|
|
95
|
+
if (context.dependencies) {
|
|
96
|
+
contextParts.push(`## Dependencies\n${context.dependencies}`);
|
|
97
|
+
}
|
|
98
|
+
const prompt = `You are an expert software engineer helping answer questions about a codebase.
|
|
99
|
+
|
|
100
|
+
${contextParts.join('\n\n')}
|
|
101
|
+
|
|
102
|
+
## Question
|
|
103
|
+
${question}
|
|
104
|
+
|
|
105
|
+
Provide a clear, helpful answer based on the context provided. If you don't have enough information to answer accurately, say so.`;
|
|
106
|
+
try {
|
|
107
|
+
const answer = await this.provider.complete(prompt, {
|
|
108
|
+
maxTokens: 1000,
|
|
109
|
+
temperature: 0.4,
|
|
110
|
+
});
|
|
111
|
+
return answer.trim();
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return `Unable to answer: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=explainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explainer.js","sourceRoot":"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;;EAEjB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;;;EAGzB,QAAQ;;kIAEwH,CAAC;QAE/H,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAClD,SAAS,EAAE,IAAI;gBACf,WAAW,EAAE,GAAG;aACjB,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,qBAAqB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;QACzF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export * from './provider.js';
|
|
4
|
+
export * from './explainer.js';
|
|
5
|
+
import { isAIEnabled } from './config.js';
|
|
6
|
+
import { AIExplainer } from './explainer.js';
|
|
7
|
+
import type { AIProvider } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Get the AI provider (singleton, lazy-initialized)
|
|
10
|
+
* Returns null if AI is not configured
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAIProvider(): AIProvider | null;
|
|
13
|
+
/**
|
|
14
|
+
* Get the AI explainer (singleton, lazy-initialized)
|
|
15
|
+
* Returns null if AI is not configured
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAIExplainer(): AIExplainer | null;
|
|
18
|
+
/**
|
|
19
|
+
* Reset cached provider/explainer (useful for testing)
|
|
20
|
+
*/
|
|
21
|
+
export declare function resetAI(): void;
|
|
22
|
+
export { isAIEnabled };
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAQjD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,GAAG,IAAI,CAQnD;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAG9B;AAGD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// AI Module - Graceful AI integration for Codexia
|
|
2
|
+
// If AI is not configured, all functions silently return without errors
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export * from './config.js';
|
|
5
|
+
export * from './provider.js';
|
|
6
|
+
export * from './explainer.js';
|
|
7
|
+
import { getAIConfig, isAIEnabled } from './config.js';
|
|
8
|
+
import { createProvider } from './provider.js';
|
|
9
|
+
import { AIExplainer } from './explainer.js';
|
|
10
|
+
let cachedProvider = null;
|
|
11
|
+
let cachedExplainer = null;
|
|
12
|
+
/**
|
|
13
|
+
* Get the AI provider (singleton, lazy-initialized)
|
|
14
|
+
* Returns null if AI is not configured
|
|
15
|
+
*/
|
|
16
|
+
export function getAIProvider() {
|
|
17
|
+
if (cachedProvider)
|
|
18
|
+
return cachedProvider;
|
|
19
|
+
const config = getAIConfig();
|
|
20
|
+
if (!config)
|
|
21
|
+
return null;
|
|
22
|
+
cachedProvider = createProvider(config);
|
|
23
|
+
return cachedProvider;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the AI explainer (singleton, lazy-initialized)
|
|
27
|
+
* Returns null if AI is not configured
|
|
28
|
+
*/
|
|
29
|
+
export function getAIExplainer() {
|
|
30
|
+
if (cachedExplainer)
|
|
31
|
+
return cachedExplainer;
|
|
32
|
+
const provider = getAIProvider();
|
|
33
|
+
if (!provider)
|
|
34
|
+
return null;
|
|
35
|
+
cachedExplainer = new AIExplainer(provider);
|
|
36
|
+
return cachedExplainer;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reset cached provider/explainer (useful for testing)
|
|
40
|
+
*/
|
|
41
|
+
export function resetAI() {
|
|
42
|
+
cachedProvider = null;
|
|
43
|
+
cachedExplainer = null;
|
|
44
|
+
}
|
|
45
|
+
// Re-export for convenience
|
|
46
|
+
export { isAIEnabled };
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,wEAAwE;AAExE,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,IAAI,cAAc,GAAsB,IAAI,CAAC;AAC7C,IAAI,eAAe,GAAuB,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC;IAE1C,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,eAAe;QAAE,OAAO,eAAe,CAAC;IAE5C,MAAM,QAAQ,GAAG,aAAa,EAAE,CAAC;IACjC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,eAAe,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC5C,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO;IACrB,cAAc,GAAG,IAAI,CAAC;IACtB,eAAe,GAAG,IAAI,CAAC;AACzB,CAAC;AAED,4BAA4B;AAC5B,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impact-explain.d.ts","sourceRoot":"","sources":["../../../src/ai/prompts/impact-explain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAiDzE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a prompt for explaining impact analysis results
|
|
3
|
+
*/
|
|
4
|
+
export function buildImpactExplanationPrompt(impact) {
|
|
5
|
+
const changedSymbols = impact.directlyChanged
|
|
6
|
+
.slice(0, 15)
|
|
7
|
+
.map(c => `- ${c.changeType.toUpperCase()}: ${c.symbol.kind} \`${c.symbol.name}\` in ${c.symbol.filePath}`)
|
|
8
|
+
.join('\n');
|
|
9
|
+
const affectedModules = impact.affectedModules
|
|
10
|
+
.slice(0, 10)
|
|
11
|
+
.map(m => `- ${m.path} (${m.reason}, distance: ${m.distance})`)
|
|
12
|
+
.join('\n');
|
|
13
|
+
const breakingChanges = impact.publicApiChanges
|
|
14
|
+
.filter(c => c.changeType === 'breaking')
|
|
15
|
+
.slice(0, 5)
|
|
16
|
+
.map(c => `- ${c.symbol}: ${c.description}`)
|
|
17
|
+
.join('\n');
|
|
18
|
+
const riskFactors = impact.riskScore.factors
|
|
19
|
+
.slice(0, 5)
|
|
20
|
+
.map(f => `- ${f.name} (+${f.weight}): ${f.reason}`)
|
|
21
|
+
.join('\n');
|
|
22
|
+
return `You are a senior software engineer helping explain code change impact to a development team.
|
|
23
|
+
|
|
24
|
+
## Analysis Results
|
|
25
|
+
|
|
26
|
+
**Risk Score:** ${impact.riskScore.overall}/100
|
|
27
|
+
|
|
28
|
+
### Changed Symbols
|
|
29
|
+
${changedSymbols || 'None detected'}
|
|
30
|
+
|
|
31
|
+
### Affected Modules (Transitive Impact)
|
|
32
|
+
${affectedModules || 'None - changes are isolated'}
|
|
33
|
+
|
|
34
|
+
### Breaking API Changes
|
|
35
|
+
${breakingChanges || 'None'}
|
|
36
|
+
|
|
37
|
+
### Risk Factors
|
|
38
|
+
${riskFactors || 'Low risk change'}
|
|
39
|
+
|
|
40
|
+
## Your Task
|
|
41
|
+
|
|
42
|
+
Write a clear, concise explanation (3-5 sentences) that:
|
|
43
|
+
1. Summarizes what was changed and its scope
|
|
44
|
+
2. Highlights the most significant downstream impacts
|
|
45
|
+
3. Notes any breaking changes or high-risk areas
|
|
46
|
+
4. Provides one actionable recommendation
|
|
47
|
+
|
|
48
|
+
Use plain language that both senior and junior developers can understand. Be specific about file names and module boundaries.`;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=impact-explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impact-explain.js","sourceRoot":"","sources":["../../../src/ai/prompts/impact-explain.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAoB;IAC/D,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe;SAC1C,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;SACZ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC,MAAM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commits: CommitInfo[];
|
|
4
|
+
impact: ImpactResult;
|
|
5
|
+
filesChanged: number;
|
|
6
|
+
additions: number;
|
|
7
|
+
deletions: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Build a prompt for generating a PR description
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildPrDescriptionPrompt(data: PrDescribeData): string;
|
|
13
|
+
//# sourceMappingURL=pr-describe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-describe.d.ts","sourceRoot":"","sources":["../../../src/ai/prompts/pr-describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEpE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAgErE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a prompt for generating a PR description
|
|
3
|
+
*/
|
|
4
|
+
export function buildPrDescriptionPrompt(data) {
|
|
5
|
+
const commitMessages = data.commits
|
|
6
|
+
.slice(0, 20)
|
|
7
|
+
.map(c => `- ${c.message}`)
|
|
8
|
+
.join('\n');
|
|
9
|
+
const changedSymbols = data.impact.directlyChanged
|
|
10
|
+
.slice(0, 15)
|
|
11
|
+
.map(c => `- ${c.changeType} ${c.symbol.kind} \`${c.symbol.name}\` in ${c.symbol.filePath}`)
|
|
12
|
+
.join('\n');
|
|
13
|
+
const affectedModules = data.impact.affectedModules
|
|
14
|
+
.slice(0, 10)
|
|
15
|
+
.map(m => `- ${m.path}: ${m.reason}`)
|
|
16
|
+
.join('\n');
|
|
17
|
+
const breakingChanges = data.impact.publicApiChanges
|
|
18
|
+
.filter(c => c.changeType === 'breaking')
|
|
19
|
+
.map(c => `- ${c.symbol}: ${c.description}`)
|
|
20
|
+
.join('\n');
|
|
21
|
+
return `You are helping a developer write a professional pull request description.
|
|
22
|
+
|
|
23
|
+
## Commits in this PR
|
|
24
|
+
${commitMessages || 'No commits yet'}
|
|
25
|
+
|
|
26
|
+
## Code Statistics
|
|
27
|
+
- **Files Changed:** ${data.filesChanged}
|
|
28
|
+
- **Lines:** +${data.additions} / -${data.deletions}
|
|
29
|
+
|
|
30
|
+
## Symbols Changed
|
|
31
|
+
${changedSymbols || 'No significant symbol changes'}
|
|
32
|
+
|
|
33
|
+
## Affected Modules
|
|
34
|
+
${affectedModules || 'Changes are self-contained'}
|
|
35
|
+
|
|
36
|
+
## Breaking Changes
|
|
37
|
+
${breakingChanges || 'None'}
|
|
38
|
+
|
|
39
|
+
## Your Task
|
|
40
|
+
|
|
41
|
+
Generate a well-structured PR description in Markdown with these sections:
|
|
42
|
+
|
|
43
|
+
## What
|
|
44
|
+
A brief 1-2 sentence summary of what this PR does.
|
|
45
|
+
|
|
46
|
+
## Why
|
|
47
|
+
The motivation and context for these changes (infer from commit messages and code changes).
|
|
48
|
+
|
|
49
|
+
## How
|
|
50
|
+
A technical explanation of the implementation approach.
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
What testing was done or should be done (infer from file patterns).
|
|
54
|
+
|
|
55
|
+
## Breaking Changes
|
|
56
|
+
List any breaking changes, or state "None" if there are none.
|
|
57
|
+
|
|
58
|
+
## Checklist
|
|
59
|
+
- [ ] Tests added/updated
|
|
60
|
+
- [ ] Documentation updated
|
|
61
|
+
- [ ] No breaking changes (or documented above)
|
|
62
|
+
|
|
63
|
+
Be specific and technical. Use bullet points where appropriate.`;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=pr-describe.js.map
|