@ai-coders/context 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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +658 -0
  3. package/dist/generators/agentGenerator.d.ts +23 -0
  4. package/dist/generators/agentGenerator.d.ts.map +1 -0
  5. package/dist/generators/agentGenerator.js +357 -0
  6. package/dist/generators/agentGenerator.js.map +1 -0
  7. package/dist/generators/documentationGenerator.d.ts +40 -0
  8. package/dist/generators/documentationGenerator.d.ts.map +1 -0
  9. package/dist/generators/documentationGenerator.js +786 -0
  10. package/dist/generators/documentationGenerator.js.map +1 -0
  11. package/dist/generators/incrementalDocumentationGenerator.d.ts +33 -0
  12. package/dist/generators/incrementalDocumentationGenerator.d.ts.map +1 -0
  13. package/dist/generators/incrementalDocumentationGenerator.js +400 -0
  14. package/dist/generators/incrementalDocumentationGenerator.js.map +1 -0
  15. package/dist/index.d.ts +6 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +559 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/services/anthropicClient.d.ts +12 -0
  20. package/dist/services/anthropicClient.d.ts.map +1 -0
  21. package/dist/services/anthropicClient.js +98 -0
  22. package/dist/services/anthropicClient.js.map +1 -0
  23. package/dist/services/baseLLMClient.d.ts +12 -0
  24. package/dist/services/baseLLMClient.d.ts.map +1 -0
  25. package/dist/services/baseLLMClient.js +41 -0
  26. package/dist/services/baseLLMClient.js.map +1 -0
  27. package/dist/services/changeAnalyzer.d.ts +44 -0
  28. package/dist/services/changeAnalyzer.d.ts.map +1 -0
  29. package/dist/services/changeAnalyzer.js +344 -0
  30. package/dist/services/changeAnalyzer.js.map +1 -0
  31. package/dist/services/geminiClient.d.ts +12 -0
  32. package/dist/services/geminiClient.d.ts.map +1 -0
  33. package/dist/services/geminiClient.js +96 -0
  34. package/dist/services/geminiClient.js.map +1 -0
  35. package/dist/services/grokClient.d.ts +12 -0
  36. package/dist/services/grokClient.d.ts.map +1 -0
  37. package/dist/services/grokClient.js +101 -0
  38. package/dist/services/grokClient.js.map +1 -0
  39. package/dist/services/llmClientFactory.d.ts +14 -0
  40. package/dist/services/llmClientFactory.d.ts.map +1 -0
  41. package/dist/services/llmClientFactory.js +109 -0
  42. package/dist/services/llmClientFactory.js.map +1 -0
  43. package/dist/services/openRouterClient.d.ts +12 -0
  44. package/dist/services/openRouterClient.d.ts.map +1 -0
  45. package/dist/services/openRouterClient.js +96 -0
  46. package/dist/services/openRouterClient.js.map +1 -0
  47. package/dist/services/openaiClient.d.ts +12 -0
  48. package/dist/services/openaiClient.d.ts.map +1 -0
  49. package/dist/services/openaiClient.js +98 -0
  50. package/dist/services/openaiClient.js.map +1 -0
  51. package/dist/types.d.ts +60 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +3 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/utils/cliUI.d.ts +25 -0
  56. package/dist/utils/cliUI.d.ts.map +1 -0
  57. package/dist/utils/cliUI.js +236 -0
  58. package/dist/utils/cliUI.js.map +1 -0
  59. package/dist/utils/fileMapper.d.ts +11 -0
  60. package/dist/utils/fileMapper.d.ts.map +1 -0
  61. package/dist/utils/fileMapper.js +125 -0
  62. package/dist/utils/fileMapper.js.map +1 -0
  63. package/dist/utils/gitService.d.ts +50 -0
  64. package/dist/utils/gitService.d.ts.map +1 -0
  65. package/dist/utils/gitService.js +470 -0
  66. package/dist/utils/gitService.js.map +1 -0
  67. package/dist/utils/interactiveMode.d.ts +16 -0
  68. package/dist/utils/interactiveMode.d.ts.map +1 -0
  69. package/dist/utils/interactiveMode.js +432 -0
  70. package/dist/utils/interactiveMode.js.map +1 -0
  71. package/dist/utils/pricing.d.ts +14 -0
  72. package/dist/utils/pricing.d.ts.map +1 -0
  73. package/dist/utils/pricing.js +115 -0
  74. package/dist/utils/pricing.js.map +1 -0
  75. package/dist/utils/tokenEstimator.d.ts +27 -0
  76. package/dist/utils/tokenEstimator.d.ts.map +1 -0
  77. package/dist/utils/tokenEstimator.js +198 -0
  78. package/dist/utils/tokenEstimator.js.map +1 -0
  79. package/package.json +73 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 AI Coders
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,658 @@
1
+ # @ai-coders/context
2
+
3
+ [![npm version](https://badge.fury.io/js/@ai-coders%2Fcontext.svg)](https://www.npmjs.com/package/@ai-coders/context)
4
+ [![CI](https://github.com/vinilana/ai-coders-context/actions/workflows/ci.yml/badge.svg)](https://github.com/vinilana/ai-coders-context/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ > โš ๏ธ **Beta Release**: This tool is in early development (v0.x). APIs and features may change.
8
+
9
+ A powerful CLI tool that analyzes your codebase and generates comprehensive documentation and AI agent prompts using LLM APIs. Features intelligent incremental updates, cost estimation, and support for multiple LLM providers.
10
+
11
+ ## โœจ Features
12
+
13
+ - ๐Ÿ” **Repository Analysis**: Maps and analyzes your entire codebase structure with token estimation
14
+ - ๐Ÿ“š **Documentation Generation**: Creates comprehensive, module-based documentation
15
+ - ๐Ÿ”„ **Incremental Updates**: Smart git-based updates that only process changed files
16
+ - ๐Ÿ‘€ **Preview Mode**: See what would change before running expensive operations
17
+ - ๐Ÿค– **AI Agent Prompts**: Generates specialized prompts for different development tasks
18
+ - ๐ŸŒ **Multi-Provider Support**: Works with OpenRouter, OpenAI, Anthropic, Google AI, and Grok
19
+ - ๐Ÿ’ฐ **Cost Tracking**: Real-time token usage and precise cost estimation across models
20
+ - ๐ŸŽฏ **Smart Filtering**: Intelligent file filtering and module organization
21
+ - ๐Ÿš€ **CI/CD Ready**: Perfect for automated documentation workflows and pre-commit hooks
22
+
23
+ ## ๐Ÿ“ฆ Installation
24
+
25
+ ### Using npx (Recommended)
26
+
27
+ ```bash
28
+ # Run directly without installation
29
+ npx @ai-coders/context analyze /path/to/your/repo
30
+ ```
31
+
32
+ ### Global Installation
33
+
34
+ ```bash
35
+ npm install -g @ai-coders/context
36
+ ```
37
+
38
+ ### Local Development
39
+
40
+ ```bash
41
+ git clone https://github.com/vinilana/ai-coders-context.git
42
+ cd ai-coders-context
43
+ npm install
44
+ npm run build
45
+ npm link
46
+ ```
47
+
48
+ ## ๐Ÿš€ Quick Start
49
+
50
+ ### 1. Set Up API Key
51
+
52
+ Choose your preferred LLM provider and set the API key:
53
+
54
+ ```bash
55
+ # OpenRouter (Recommended - access to 100+ models)
56
+ export OPENROUTER_API_KEY=your_key_here
57
+
58
+ # Or use other providers
59
+ export OPENAI_API_KEY=your_key_here
60
+ export ANTHROPIC_API_KEY=your_key_here
61
+ export GOOGLE_AI_API_KEY=your_key_here
62
+ export GROK_API_KEY=your_key_here
63
+ ```
64
+
65
+ ### 2. Analyze Your Repository
66
+
67
+ ```bash
68
+ # Get cost estimates and repository analysis
69
+ npx @ai-coders/context analyze /path/to/your/repo
70
+ ```
71
+
72
+ ### 3. Generate Initial Documentation
73
+
74
+ ```bash
75
+ # Create comprehensive documentation and agent prompts
76
+ npx @ai-coders/context generate /path/to/your/repo
77
+ ```
78
+
79
+ ### 4. Update Documentation (Incremental)
80
+
81
+ ```bash
82
+ # Update only changed files since last run
83
+ npx @ai-coders/context update /path/to/your/repo
84
+
85
+ # Preview changes before updating
86
+ npx @ai-coders/context preview /path/to/your/repo
87
+ ```
88
+
89
+ ## ๐Ÿ“‹ Commands
90
+
91
+ ### `analyze` - Repository Analysis & Cost Estimation
92
+
93
+ Analyzes your repository structure and provides detailed cost estimates for documentation generation.
94
+
95
+ ```bash
96
+ npx @ai-coders/context analyze /path/to/repo [options]
97
+
98
+ Options:
99
+ --exclude <patterns...> Patterns to exclude from analysis
100
+ --include <patterns...> Patterns to include in analysis
101
+ -v, --verbose Show detailed file breakdown
102
+ ```
103
+
104
+ **Example Output:**
105
+ ```
106
+ ๐Ÿ“Š Token Usage Estimate for Full Documentation Generation:
107
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
108
+
109
+ ๐Ÿ“ Files to Process: 247
110
+ ๐Ÿ”ค Estimated Input Tokens: 156,500
111
+ ๐Ÿ“ Estimated Output Tokens: 62,600
112
+ ๐ŸŽฏ Total Estimated Tokens: 219,100
113
+
114
+ ๐Ÿ’ฐ Cost Estimates by Model:
115
+ Llama 3.1 8B (OpenRouter) | Input: $0.01 | Output: $0.01 | Total: $0.02
116
+ Gemini 1.5 Flash (Google AI) | Input: $0.01 | Output: $0.02 | Total: $0.03
117
+ GPT-4o Mini (OpenRouter) | Input: $0.02 | Output: $0.04 | Total: $0.06
118
+ Claude 3 Haiku (OpenRouter) | Input: $0.04 | Output: $0.08 | Total: $0.12
119
+ ```
120
+
121
+ ### `generate` - Initial Documentation Generation
122
+
123
+ Creates comprehensive documentation and AI agent prompts for your entire repository.
124
+
125
+ ```bash
126
+ npx @ai-coders/context generate /path/to/repo [options]
127
+
128
+ Options:
129
+ -o, --output <dir> Output directory (default: "./.context")
130
+ -k, --api-key <key> API key for the LLM provider
131
+ -m, --model <model> LLM model to use (default: "google/gemini-2.5-flash-preview-05-20")
132
+ -p, --provider <provider> LLM provider (openrouter, openai, anthropic, gemini, grok)
133
+ --exclude <patterns...> Patterns to exclude from analysis
134
+ --include <patterns...> Patterns to include in analysis
135
+ --docs-only Generate only documentation (skip agent prompts)
136
+ --agents-only Generate only agent prompts (skip documentation)
137
+ -v, --verbose Verbose output with detailed progress
138
+ ```
139
+
140
+ ### `update` - Incremental Documentation Updates
141
+
142
+ Updates documentation only for files that have changed since the last documented commit.
143
+
144
+ ```bash
145
+ npx @ai-coders/context update /path/to/repo [options]
146
+
147
+ Options:
148
+ -o, --output <dir> Output directory (default: "./.context")
149
+ -k, --api-key <key> API key for the LLM provider
150
+ -m, --model <model> LLM model to use
151
+ -p, --provider <provider> LLM provider
152
+ --since <commit> Compare against specific commit/branch
153
+ --staged Only process staged files (for pre-commit hooks)
154
+ --force Force regeneration even if no changes detected
155
+ --exclude <patterns...> Patterns to exclude from analysis
156
+ --include <patterns...> Patterns to include in analysis
157
+ -v, --verbose Verbose output with commit tracking info
158
+ ```
159
+
160
+ ### `preview` - Preview Changes
161
+
162
+ Shows what documentation updates would be made without actually making changes. Includes cost estimates for the affected files.
163
+
164
+ ```bash
165
+ npx @ai-coders/context preview /path/to/repo [options]
166
+
167
+ Options:
168
+ --since <commit> Compare against specific commit/branch
169
+ --staged Only analyze staged files
170
+ --exclude <patterns...> Patterns to exclude from analysis
171
+ --include <patterns...> Patterns to include in analysis
172
+ -v, --verbose Show detailed file change lists and debug info
173
+ ```
174
+
175
+ ## ๐ŸŽฏ Workflow Examples
176
+
177
+ ### Initial Setup Workflow
178
+
179
+ ```bash
180
+ # 1. Analyze repository and get cost estimates
181
+ npx @ai-coders/context analyze ./my-project
182
+
183
+ # 2. Generate initial documentation
184
+ npx @ai-coders/context generate ./my-project
185
+
186
+ # 3. Check what the output looks like
187
+ ls .context/
188
+ ```
189
+
190
+ ### Daily Development Workflow
191
+
192
+ ```bash
193
+ # Preview what would be updated
194
+ npx @ai-coders/context preview ./my-project
195
+
196
+ # Update documentation for changed files
197
+ npx @ai-coders/context update ./my-project -v
198
+
199
+ # Or update since a specific commit
200
+ npx @ai-coders/context update ./my-project --since HEAD~3
201
+ ```
202
+
203
+ ### Pre-commit Hook Integration
204
+
205
+ ```bash
206
+ # Update only staged files (perfect for pre-commit hooks)
207
+ npx @ai-coders/context update ./my-project --staged
208
+
209
+ # Preview staged changes
210
+ npx @ai-coders/context preview ./my-project --staged
211
+ ```
212
+
213
+ ### CI/CD Integration
214
+
215
+ ```bash
216
+ # Update documentation in CI for main branch changes
217
+ npx @ai-coders/context update . \
218
+ --provider openrouter \
219
+ --model google/gemini-2.5-flash-preview-05-20 \
220
+ --verbose
221
+ ```
222
+
223
+ ## ๐Ÿ—๏ธ Output Structure
224
+
225
+ The tool generates documentation in the `.context` directory:
226
+
227
+ ```
228
+ .context/
229
+ โ”œโ”€โ”€ docs/ # Generated documentation
230
+ โ”‚ โ”œโ”€โ”€ README.md # Project overview
231
+ โ”‚ โ”œโ”€โ”€ STRUCTURE.md # Repository structure
232
+ โ”‚ โ”œโ”€โ”€ DEVELOPMENT.md # Development guide
233
+ โ”‚ โ”œโ”€โ”€ API.md # API documentation
234
+ โ”‚ โ”œโ”€โ”€ DEPLOYMENT.md # Deployment guide
235
+ โ”‚ โ”œโ”€โ”€ TROUBLESHOOTING.md # Troubleshooting guide
236
+ โ”‚ โ””โ”€โ”€ modules/ # Module-specific documentation
237
+ โ”‚ โ”œโ”€โ”€ auth/ # Auth module docs
238
+ โ”‚ โ”œโ”€โ”€ api/ # API module docs
239
+ โ”‚ โ””โ”€โ”€ utils/ # Utils module docs
240
+ โ””โ”€โ”€ agents/ # AI agent prompts
241
+ โ”œโ”€โ”€ README.md # Agent index
242
+ โ”œโ”€โ”€ code-reviewer.md # Code review specialist
243
+ โ”œโ”€โ”€ bug-fixer.md # Bug fixing specialist
244
+ โ”œโ”€โ”€ feature-developer.md # Feature development specialist
245
+ โ”œโ”€โ”€ refactoring-specialist.md
246
+ โ”œโ”€โ”€ test-writer.md
247
+ โ”œโ”€โ”€ documentation-writer.md
248
+ โ”œโ”€โ”€ performance-optimizer.md
249
+ โ””โ”€โ”€ security-auditor.md
250
+
251
+ # State tracking
252
+ context-log.json # Tracks last processed commit
253
+ ```
254
+
255
+ ## ๐Ÿ”ง LLM Provider Configuration
256
+
257
+ ### OpenRouter (Recommended)
258
+
259
+ Access to 100+ models from different providers with competitive pricing:
260
+
261
+ ```bash
262
+ export OPENROUTER_API_KEY=your_api_key_here
263
+
264
+ # Use specific models
265
+ npx @ai-coders/context generate . -m google/gemini-2.5-flash-preview-05-20 # Fast & cheap
266
+ npx @ai-coders/context generate . -m anthropic/claude-3-sonnet # Balanced
267
+ npx @ai-coders/context generate . -m openai/gpt-4 # High quality
268
+ ```
269
+
270
+ ### Direct Provider Access
271
+
272
+ ```bash
273
+ # OpenAI
274
+ export OPENAI_API_KEY=your_key
275
+ npx @ai-coders/context generate . -p openai -m gpt-4o
276
+
277
+ # Anthropic
278
+ export ANTHROPIC_API_KEY=your_key
279
+ npx @ai-coders/context generate . -p anthropic -m claude-3-sonnet-20240229
280
+
281
+ # Google AI
282
+ export GOOGLE_AI_API_KEY=your_key
283
+ npx @ai-coders/context generate . -p gemini -m gemini-1.5-pro
284
+
285
+ # Grok
286
+ export GROK_API_KEY=your_key
287
+ npx @ai-coders/context generate . -p grok -m grok-beta
288
+ ```
289
+
290
+ ## ๐Ÿ’ฐ Cost Management
291
+
292
+ ### Model Selection by Cost
293
+
294
+ **Ultra Low Cost:**
295
+ - Llama 3.1 8B (OpenRouter): ~$0.05 per 1M tokens
296
+ - Gemini 1.5 Flash: ~$0.075 per 1M tokens
297
+
298
+ **Low Cost:**
299
+ - GPT-4o Mini: ~$0.15 per 1M tokens
300
+ - Claude 3 Haiku: ~$0.25 per 1M tokens
301
+
302
+ **Balanced:**
303
+ - Gemini 1.5 Pro: ~$1.25 per 1M tokens
304
+ - GPT-4o: ~$2.50 per 1M tokens
305
+ - Claude 3.5 Sonnet: ~$3.00 per 1M tokens
306
+
307
+ **High Quality:**
308
+ - GPT-4 Turbo: ~$10.00 per 1M tokens
309
+ - Grok Beta: ~$5.00 per 1M tokens
310
+
311
+ ### Cost Estimation Features
312
+
313
+ - **Pre-generation estimates**: Always run `analyze` first to see costs
314
+ - **Preview mode**: See exactly what files will be processed
315
+ - **Incremental updates**: Only pay for changed files
316
+ - **Provider comparison**: Compare costs across all supported models
317
+
318
+ ## ๐ŸŽ›๏ธ Advanced Configuration
319
+
320
+ ### Filtering Options
321
+
322
+ ```bash
323
+ # Exclude specific file types and directories
324
+ npx @ai-coders/context generate . \
325
+ --exclude "**/*.test.*" "node_modules/**" "dist/**" "*.log"
326
+
327
+ # Include only source code
328
+ npx @ai-coders/context generate . \
329
+ --include "src/**" "lib/**" "packages/**"
330
+
331
+ # Complex filtering
332
+ npx @ai-coders/context generate . \
333
+ --include "src/**" \
334
+ --exclude "src/**/*.test.*" "src/legacy/**"
335
+ ```
336
+
337
+ ### Environment Configuration
338
+
339
+ Create a `.env` file in your project:
340
+
341
+ ```bash
342
+ # .env
343
+ OPENROUTER_API_KEY=your_key_here
344
+ DEFAULT_MODEL=google/gemini-2.5-flash-preview-05-20
345
+ OUTPUT_DIR=./.context
346
+ ```
347
+
348
+ ### Model-Specific Options
349
+
350
+ ```bash
351
+ # Use high-quality model for important documentation
352
+ npx @ai-coders/context generate . \
353
+ --model anthropic/claude-3-opus \
354
+ --docs-only
355
+
356
+ # Use fast model for regular updates
357
+ npx @ai-coders/context update . \
358
+ --model google/gemini-2.5-flash-preview-05-20
359
+ ```
360
+
361
+ ## ๐Ÿ”„ Git Integration & State Tracking
362
+
363
+ ### How It Works
364
+
365
+ The tool uses Git to track which commits have been documented:
366
+
367
+ 1. **State File**: `context-log.json` tracks the last processed commit
368
+ 2. **Change Detection**: Compares current HEAD with last processed commit
369
+ 3. **Smart Updates**: Only processes files affected by changes
370
+ 4. **Commit Validation**: Handles rebases and history changes gracefully
371
+
372
+ ### Commit Tracking Features
373
+
374
+ ```bash
375
+ # See commit tracking info in verbose mode
376
+ npx @ai-coders/context update . -v
377
+
378
+ # Output includes:
379
+ # ๐Ÿ” Commit Tracking Information:
380
+ # Last documented: abc1234 - feat: add user authentication
381
+ # Current commit: def5678 - fix: handle edge case in validation
382
+ # Commits to process: 3
383
+ ```
384
+
385
+ ### Handling Different Scenarios
386
+
387
+ ```bash
388
+ # Update from specific commit
389
+ npx @ai-coders/context update . --since abc1234
390
+
391
+ # Force full regeneration
392
+ npx @ai-coders/context update . --force
393
+
394
+ # Work with staged files (pre-commit)
395
+ npx @ai-coders/context update . --staged
396
+ ```
397
+
398
+ ## ๐Ÿš€ Pre-commit Hook Setup
399
+
400
+ Automatically update documentation when committing code changes:
401
+
402
+ ### 1. Create Pre-commit Hook
403
+
404
+ ```bash
405
+ # Create the hook file
406
+ cat > .git/hooks/pre-commit << 'EOF'
407
+ #!/bin/bash
408
+ set -e
409
+
410
+ echo "๐Ÿ” AI Coders Context: Checking for documentation updates..."
411
+
412
+ # Check if there are staged files that need documentation updates
413
+ STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|js|py|java|cpp|c|h|css|scss|html|xml|json|yaml|yml|md|txt|sql|sh|bat|ps1|php|rb|go|rs|swift|kt|scala|r|m|pl|lua|vim)$' || true)
414
+
415
+ if [ -z "$STAGED_FILES" ]; then
416
+ echo "โœ… No relevant files staged for commit"
417
+ exit 0
418
+ fi
419
+
420
+ echo "๐Ÿ“ Found staged files that may need documentation updates:"
421
+ echo "$STAGED_FILES" | sed 's/^/ - /'
422
+
423
+ # Update documentation for staged files only
424
+ echo "๐Ÿ“š Updating documentation for staged files..."
425
+ npx @ai-coders/context update . \
426
+ --staged \
427
+ --model google/gemini-2.5-flash-preview-05-20 \
428
+ --verbose || {
429
+ echo "โŒ Documentation update failed. Commit aborted."
430
+ exit 1
431
+ }
432
+
433
+ # Check if documentation was updated
434
+ if git diff --quiet .context/docs/; then
435
+ echo "โœ… Documentation is up to date"
436
+ else
437
+ echo "๐Ÿ“ Documentation updated. Adding to commit..."
438
+ git add .context/docs/
439
+ echo "โœ… Documentation changes added to commit"
440
+ fi
441
+
442
+ echo "๐ŸŽ‰ Pre-commit documentation check complete!"
443
+ exit 0
444
+ EOF
445
+
446
+ # Make it executable
447
+ chmod +x .git/hooks/pre-commit
448
+ ```
449
+
450
+ ### 2. Test the Hook
451
+
452
+ ```bash
453
+ # Stage some files and commit
454
+ git add src/my-changes.ts
455
+ git commit -m "feat: add new feature"
456
+
457
+ # The hook will automatically:
458
+ # 1. Detect staged files
459
+ # 2. Update relevant documentation
460
+ # 3. Add updated docs to the commit
461
+ ```
462
+
463
+ ## ๐Ÿข CI/CD Integration
464
+
465
+ ### GitHub Actions Example
466
+
467
+ ```yaml
468
+ # .github/workflows/docs-update.yml
469
+ name: Update Documentation
470
+
471
+ on:
472
+ push:
473
+ branches: [ main, develop ]
474
+ paths:
475
+ - 'src/**'
476
+ - 'lib/**'
477
+ - '*.md'
478
+ - '*.json'
479
+ - '*.ts'
480
+ - '*.js'
481
+
482
+ jobs:
483
+ update-docs:
484
+ runs-on: ubuntu-latest
485
+
486
+ steps:
487
+ - uses: actions/checkout@v4
488
+ with:
489
+ fetch-depth: 0 # Need full history for git diff
490
+
491
+ - name: Use Node.js
492
+ uses: actions/setup-node@v4
493
+ with:
494
+ node-version: '20.x'
495
+ cache: 'npm'
496
+
497
+ - name: Update Documentation
498
+ run: |
499
+ npx @ai-coders/context update . \
500
+ --provider openrouter \
501
+ --model google/gemini-2.5-flash-preview-05-20 \
502
+ --verbose
503
+ env:
504
+ OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
505
+
506
+ - name: Commit documentation updates
507
+ run: |
508
+ git config user.name "docs-bot"
509
+ git config user.email "docs-bot@github.com"
510
+
511
+ if ! git diff --quiet .context/docs/; then
512
+ git add .context/docs/
513
+ git commit -m "docs: update documentation for changed files
514
+
515
+ Auto-generated by AI Coders Context"
516
+ git push
517
+ fi
518
+ ```
519
+
520
+ ## ๐Ÿ› ๏ธ Troubleshooting
521
+
522
+ ### Common Issues
523
+
524
+ **"No documentation context found"**
525
+ ```bash
526
+ # Run these commands in order:
527
+ npx @ai-coders/context analyze .
528
+ npx @ai-coders/context generate .
529
+ npx @ai-coders/context preview . # Now this will work
530
+ ```
531
+
532
+ **"API key not found"**
533
+ ```bash
534
+ # Set your API key
535
+ export OPENROUTER_API_KEY=your_key_here
536
+
537
+ # Or pass it directly
538
+ npx @ai-coders/context generate . --api-key your_key_here
539
+ ```
540
+
541
+ **"No changes detected"**
542
+ ```bash
543
+ # Force regeneration
544
+ npx @ai-coders/context update . --force
545
+
546
+ # Or check what's being tracked
547
+ npx @ai-coders/context update . -v
548
+ ```
549
+
550
+ **High costs**
551
+ ```bash
552
+ # Use cost-effective models
553
+ npx @ai-coders/context generate . --model google/gemini-2.5-flash-preview-05-20
554
+
555
+ # Preview costs first
556
+ npx @ai-coders/context analyze .
557
+
558
+ # Use incremental updates
559
+ npx @ai-coders/context update . # Only processes changed files
560
+ ```
561
+
562
+ ### Debug Mode
563
+
564
+ ```bash
565
+ # Enable verbose output for detailed debugging
566
+ npx @ai-coders/context update . -v
567
+
568
+ # This shows:
569
+ # - Commit tracking information
570
+ # - File change analysis
571
+ # - Token estimation details
572
+ # - Processing progress
573
+ ```
574
+
575
+ ## ๐Ÿ“š Available Agent Types
576
+
577
+ The tool generates specialized AI agent prompts for different development tasks:
578
+
579
+ - **๐Ÿ” Code Reviewer**: Reviews code for quality, best practices, and potential issues
580
+ - **๐Ÿ› Bug Fixer**: Analyzes and fixes bugs with step-by-step debugging
581
+ - **โšก Feature Developer**: Implements new features following project patterns
582
+ - **๐Ÿ”ง Refactoring Specialist**: Improves code structure and maintainability
583
+ - **๐Ÿงช Test Writer**: Creates comprehensive test suites
584
+ - **๐Ÿ“ Documentation Writer**: Maintains and improves documentation
585
+ - **๐Ÿš€ Performance Optimizer**: Identifies and fixes performance bottlenecks
586
+ - **๐Ÿ”’ Security Auditor**: Identifies security vulnerabilities and fixes
587
+
588
+ ## ๐Ÿ“Š Supported File Types
589
+
590
+ The tool automatically detects and processes these file types:
591
+
592
+ **Programming Languages:**
593
+ - JavaScript/TypeScript (`.js`, `.ts`, `.jsx`, `.tsx`)
594
+ - Python (`.py`)
595
+ - Java (`.java`)
596
+ - C/C++ (`.c`, `.cpp`, `.h`)
597
+ - Go (`.go`)
598
+ - Rust (`.rs`)
599
+ - Swift (`.swift`)
600
+ - Kotlin (`.kt`)
601
+ - Scala (`.scala`)
602
+ - PHP (`.php`)
603
+ - Ruby (`.rb`)
604
+
605
+ **Configuration & Data:**
606
+ - JSON (`.json`)
607
+ - YAML (`.yaml`, `.yml`)
608
+ - XML (`.xml`)
609
+ - SQL (`.sql`)
610
+
611
+ **Web Technologies:**
612
+ - HTML (`.html`)
613
+ - CSS/SCSS (`.css`, `.scss`, `.sass`)
614
+
615
+ **Documentation:**
616
+ - Markdown (`.md`)
617
+ - Text files (`.txt`)
618
+
619
+ **Scripts:**
620
+ - Shell scripts (`.sh`)
621
+ - Batch files (`.bat`)
622
+ - PowerShell (`.ps1`)
623
+
624
+ ## ๐Ÿค Contributing
625
+
626
+ 1. Fork the repository
627
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
628
+ 3. Make your changes
629
+ 4. Add tests if applicable
630
+ 5. Commit your changes: `git commit -m 'feat: add amazing feature'`
631
+ 6. Push to the branch: `git push origin feature/amazing-feature`
632
+ 7. Submit a pull request
633
+
634
+ ### Development Setup
635
+
636
+ ```bash
637
+ git clone https://github.com/vinilana/ai-coders-context.git
638
+ cd ai-coders-context
639
+ npm install
640
+ npm run dev # Development mode with auto-reload
641
+ npm run build # Build for production
642
+ npm test # Run tests
643
+ ```
644
+
645
+ ## ๐Ÿ“„ License
646
+
647
+ MIT License - see [LICENSE](LICENSE) file for details.
648
+
649
+ ## ๐Ÿ†˜ Support
650
+
651
+ - ๐Ÿ› [Report bugs](https://github.com/vinilana/ai-coders-context/issues)
652
+ - ๐Ÿ’ก [Request features](https://github.com/vinilana/ai-coders-context/issues)
653
+ - ๐Ÿ“– [Documentation](https://github.com/vinilana/ai-coders-context/wiki)
654
+ - ๐Ÿ’ฌ [Discussions](https://github.com/vinilana/ai-coders-context/discussions)
655
+
656
+ ---
657
+
658
+ Made with โค๏ธ by the AI Coders Academy - https://aicoders.academy
@@ -0,0 +1,23 @@
1
+ import { RepoStructure } from '../types';
2
+ import { FileMapper } from '../utils/fileMapper';
3
+ import { BaseLLMClient } from '../services/baseLLMClient';
4
+ export declare class AgentGenerator {
5
+ private fileMapper;
6
+ private llmClient;
7
+ private agentTypes;
8
+ constructor(fileMapper: FileMapper, llmClient: BaseLLMClient);
9
+ generateAgentPrompts(repoStructure: RepoStructure, outputDir: string, verbose?: boolean): Promise<void>;
10
+ private generateAgentPrompt;
11
+ private formatAgentPrompt;
12
+ private getAgentResponsibilities;
13
+ private getAgentBestPractices;
14
+ private getAgentCommands;
15
+ private createRepoContext;
16
+ private createFileContext;
17
+ private createStructureOverview;
18
+ private getFileTypeDistribution;
19
+ private isImportantFile;
20
+ private generateAgentIndex;
21
+ private formatBytes;
22
+ }
23
+ //# sourceMappingURL=agentGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentGenerator.d.ts","sourceRoot":"","sources":["../../src/generators/agentGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,qBAAa,cAAc;IAavB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IAbnB,OAAO,CAAC,UAAU,CAShB;gBAGQ,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,aAAa;IAG5B,oBAAoB,CACxB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC,IAAI,CAAC;YA0CF,mBAAmB;IAiBjC,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,wBAAwB;IAwDhC,OAAO,CAAC,qBAAqB;IAgD7B,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,iBAAiB;YAyBX,iBAAiB;IAoB/B,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,eAAe;YAaT,kBAAkB;IA6ChC,OAAO,CAAC,WAAW;CAOpB"}