@eldrforge/kodrdriv 1.2.132 → 1.2.133

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.
@@ -0,0 +1,223 @@
1
+ # Quick Start Guide
2
+
3
+ Get kodrdriv working in 5 minutes.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js v18+ installed
8
+ - Git repository with changes
9
+ - OpenAI API key
10
+ - (Optional) GitHub token for publish features
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install -g @eldrforge/kodrdriv
16
+ ```
17
+
18
+ ## Setup
19
+
20
+ ### 1. Set Environment Variables
21
+
22
+ ```bash
23
+ export OPENAI_API_KEY="sk-your-openai-key-here"
24
+ export GITHUB_TOKEN="ghp-your-github-token-here" # Optional, for publish
25
+ ```
26
+
27
+ Add to your shell profile (~/.zshrc, ~/.bashrc) to persist.
28
+
29
+ ### 2. Initialize Configuration
30
+
31
+ ```bash
32
+ # Create config files
33
+ kodrdriv --init-config
34
+
35
+ # Verify setup
36
+ kodrdriv --check-config
37
+ ```
38
+
39
+ This creates `.kodrdriv/config.yaml` in your project.
40
+
41
+ ## First Commands
42
+
43
+ ### Generate a Commit Message
44
+
45
+ ```bash
46
+ # Make some changes
47
+ echo "test" >> README.md
48
+
49
+ # Stage changes
50
+ git add README.md
51
+
52
+ # Generate commit message
53
+ kodrdriv commit
54
+ ```
55
+
56
+ **Output**: AI-generated commit message based on your changes.
57
+
58
+ **To auto-commit**:
59
+ ```bash
60
+ kodrdriv commit --sendit
61
+ ```
62
+
63
+ ### Generate Release Notes
64
+
65
+ ```bash
66
+ # Generate notes for changes since last tag
67
+ kodrdriv release
68
+
69
+ # Preview without saving
70
+ kodrdriv release --dry-run
71
+ ```
72
+
73
+ **Output**: Comprehensive release notes in Markdown format.
74
+
75
+ ### Try Self-Reflection
76
+
77
+ ```bash
78
+ # See how the AI analyzed your changes
79
+ kodrdriv commit --self-reflection
80
+
81
+ # Check the report
82
+ cat output/agentic-reflection-commit-*.md
83
+ ```
84
+
85
+ **Output**: Detailed report showing which tools were used and how effective they were.
86
+
87
+ ## Basic Configuration
88
+
89
+ Edit `.kodrdriv/config.yaml`:
90
+
91
+ ```yaml
92
+ # Global settings
93
+ model: gpt-4o
94
+ outputDirectory: output
95
+
96
+ # Commit settings
97
+ commit:
98
+ selfReflection: true
99
+ maxAgenticIterations: 10
100
+
101
+ # Release settings
102
+ release:
103
+ selfReflection: true
104
+ maxAgenticIterations: 30
105
+ ```
106
+
107
+ ## Common Workflows
108
+
109
+ ### Daily Development
110
+
111
+ ```bash
112
+ # Work on features
113
+ # ... make changes ...
114
+
115
+ # When ready to commit
116
+ git add .
117
+ kodrdriv commit --sendit
118
+ ```
119
+
120
+ ### Before a Release
121
+
122
+ ```bash
123
+ # Generate release notes
124
+ kodrdriv release --context-files CHANGELOG.md
125
+
126
+ # Review and refine
127
+ kodrdriv release --interactive
128
+ ```
129
+
130
+ ### Automated Release
131
+
132
+ ```bash
133
+ # Complete workflow (notes, PR, merge, tag, release)
134
+ kodrdriv publish
135
+ ```
136
+
137
+ ## Verification
138
+
139
+ ### Test Your Setup
140
+
141
+ ```bash
142
+ # Dry run mode (no changes made)
143
+ kodrdriv commit --dry-run
144
+
145
+ # Verbose logging
146
+ kodrdriv commit --verbose
147
+
148
+ # Debug logging (very detailed)
149
+ kodrdriv commit --debug
150
+ ```
151
+
152
+ ### Check Configuration
153
+
154
+ ```bash
155
+ # Show merged configuration
156
+ kodrdriv --check-config
157
+
158
+ # Test with a small change
159
+ echo "test" >> test.txt
160
+ git add test.txt
161
+ kodrdriv commit --dry-run
162
+ git reset HEAD test.txt
163
+ rm test.txt
164
+ ```
165
+
166
+ ## Next Steps
167
+
168
+ You now have kodrdriv working! Learn more:
169
+
170
+ - **[Usage Guide](./usage.md)** - Common patterns and workflows
171
+ - **[Commands Reference](./commands.md)** - All available commands
172
+ - **[Configuration Guide](./configuration.md)** - Advanced configuration
173
+ - **[Integration Guide](./integration.md)** - Integrate into your project
174
+
175
+ ## Troubleshooting
176
+
177
+ ### "OpenAI API key is required"
178
+ ```bash
179
+ # Check if set
180
+ echo $OPENAI_API_KEY
181
+
182
+ # Set it
183
+ export OPENAI_API_KEY="your-key"
184
+ ```
185
+
186
+ ### "No changes to commit"
187
+ ```bash
188
+ # Make sure you've staged changes
189
+ git add .
190
+
191
+ # Or use --add to auto-stage
192
+ kodrdriv commit --add --sendit
193
+ ```
194
+
195
+ ### "Cannot find module"
196
+ ```bash
197
+ # Reinstall globally
198
+ npm install -g @eldrforge/kodrdriv
199
+
200
+ # Or link for development
201
+ cd /path/to/kodrdriv
202
+ npm link
203
+ ```
204
+
205
+ ### Command Times Out
206
+ ```bash
207
+ # Increase iteration limit
208
+ kodrdriv commit --max-agentic-iterations 15
209
+
210
+ # Or use simpler model
211
+ kodrdriv commit --model gpt-4o-mini
212
+ ```
213
+
214
+ ## Tips
215
+
216
+ 1. **Start with dry-run** to see what will happen
217
+ 2. **Use --verbose** to understand what's going on
218
+ 3. **Enable self-reflection** to improve results
219
+ 4. **Pass context files** for complex changes
220
+ 5. **Check output directory** for generated files
221
+
222
+ You're ready to use kodrdriv! 🚀
223
+
@@ -0,0 +1,460 @@
1
+ # Testing Guide
2
+
3
+ Understanding and running kodrdriv tests.
4
+
5
+ ## Test Suite Overview
6
+
7
+ ### Coverage Statistics
8
+
9
+ - **kodrdriv**: ~60% coverage, 1,344 tests
10
+ - **ai-service**: ~66% coverage, 318 tests
11
+ - **tree-core**: ~94% coverage, 25 tests
12
+ - **tree-execution**: ~78% coverage, 177 tests
13
+ - **shared**: ~86% coverage
14
+ - **git-tools**: ~86% coverage, 284 tests
15
+ - **github-tools**: ~85% coverage, 393 tests
16
+
17
+ **Total**: ~2,500 tests across ecosystem
18
+
19
+ ## Running Tests
20
+
21
+ ### Basic Commands
22
+
23
+ ```bash
24
+ # All tests
25
+ npm test
26
+
27
+ # Watch mode (recommended for development)
28
+ npm run test:watch
29
+
30
+ # Coverage report
31
+ npm run test:coverage
32
+
33
+ # Specific test file
34
+ npm test tests/commands/commit.test.ts
35
+
36
+ # Pattern matching
37
+ npm test -- commit
38
+ ```
39
+
40
+ ### Test Modes
41
+
42
+ ```bash
43
+ # Run once
44
+ npm test
45
+
46
+ # Watch for changes
47
+ npm run test:watch
48
+
49
+ # UI mode (interactive)
50
+ npm run test:ui
51
+
52
+ # Verbose output
53
+ npm test -- --reporter=verbose
54
+ ```
55
+
56
+ ## Test Structure
57
+
58
+ ### By Component
59
+
60
+ **Commands** (`tests/commands/`):
61
+ - `commit.test.ts` - Commit message generation
62
+ - `release.test.ts` - Release notes generation
63
+ - `release-agentic.test.ts` - Agentic analysis
64
+ - `publish.test.ts` - Publish workflows
65
+ - `tree.test.ts` - Tree operations
66
+ - `audio-*.test.ts` - Audio processing
67
+
68
+ **Utilities** (`tests/util/`):
69
+ - `general.test.ts` - General utilities
70
+ - `stopContext.test.ts` - Content filtering
71
+ - `validation.test.ts` - Validation functions
72
+
73
+ **Integration** (`tests/integration/`):
74
+ - End-to-end workflow tests
75
+
76
+ ### By Type
77
+
78
+ **Unit Tests**:
79
+ - Individual function testing
80
+ - Mocked dependencies
81
+ - Fast execution (<1s per file)
82
+
83
+ **Integration Tests**:
84
+ - Multi-component workflows
85
+ - Real file system operations
86
+ - Moderate speed (1-5s per file)
87
+
88
+ **End-to-End Tests**:
89
+ - Complete command execution
90
+ - External API mocking
91
+ - Slower (5-10s per file)
92
+
93
+ ## Writing Tests
94
+
95
+ ### Test Template
96
+
97
+ ```typescript
98
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
99
+ import { execute } from '../src/commands/my-command';
100
+ import type { Config } from '../src/types';
101
+
102
+ describe('MyCommand', () => {
103
+ beforeEach(() => {
104
+ // Setup
105
+ });
106
+
107
+ afterEach(() => {
108
+ vi.clearAllMocks();
109
+ });
110
+
111
+ it('should handle basic case', async () => {
112
+ const config: Partial<Config> = {
113
+ dryRun: true
114
+ };
115
+
116
+ const result = await execute(config);
117
+
118
+ expect(result).toBeDefined();
119
+ });
120
+
121
+ it('should handle error case', async () => {
122
+ // Test error handling
123
+ await expect(execute(invalidConfig)).rejects.toThrow();
124
+ });
125
+ });
126
+ ```
127
+
128
+ ### Mocking Strategies
129
+
130
+ **Mock External APIs**:
131
+ ```typescript
132
+ // Mock OpenAI
133
+ vi.mock('@eldrforge/ai-service', () => ({
134
+ runAgenticCommit: vi.fn().mockResolvedValue({
135
+ commitMessage: 'mock message'
136
+ })
137
+ }));
138
+
139
+ // Mock Git
140
+ vi.mock('@eldrforge/git-tools', () => ({
141
+ run: vi.fn().mockResolvedValue({ stdout: 'output' })
142
+ }));
143
+
144
+ // Mock GitHub
145
+ vi.mock('@eldrforge/github-tools', () => ({
146
+ createPullRequest: vi.fn().mockResolvedValue({
147
+ number: 123,
148
+ html_url: 'https://github.com/...'
149
+ })
150
+ }));
151
+ ```
152
+
153
+ **Mock File System**:
154
+ ```typescript
155
+ vi.mock('@eldrforge/shared', () => ({
156
+ createStorage: vi.fn().mockReturnValue({
157
+ readFile: vi.fn(),
158
+ writeFile: vi.fn(),
159
+ ensureDirectory: vi.fn()
160
+ })
161
+ }));
162
+ ```
163
+
164
+ ### Test Assertions
165
+
166
+ ```typescript
167
+ // Basic assertions
168
+ expect(result).toBe('expected');
169
+ expect(result).toEqual({ key: 'value' });
170
+ expect(result).toContain('substring');
171
+ expect(result).toMatch(/regex/);
172
+
173
+ // Mock call verification
174
+ expect(mockFunction).toHaveBeenCalled();
175
+ expect(mockFunction).toHaveBeenCalledWith('arg1', 'arg2');
176
+ expect(mockFunction).toHaveBeenCalledTimes(2);
177
+
178
+ // Complex objects
179
+ expect(result).toEqual(expect.objectContaining({
180
+ key: 'value'
181
+ }));
182
+ ```
183
+
184
+ ## Test Coverage
185
+
186
+ ### View Coverage
187
+
188
+ ```bash
189
+ # Generate coverage report
190
+ npm run test:coverage
191
+
192
+ # Open in browser
193
+ open coverage/index.html
194
+ ```
195
+
196
+ ### Coverage Goals
197
+
198
+ - **Utilities**: 80%+ coverage
199
+ - **Commands**: 60%+ coverage (harder to test)
200
+ - **Critical paths**: 90%+ coverage
201
+
202
+ ### Improving Coverage
203
+
204
+ ```typescript
205
+ // Test happy path
206
+ it('should work with valid input', async () => {
207
+ const result = await function(validInput);
208
+ expect(result).toBeDefined();
209
+ });
210
+
211
+ // Test error path
212
+ it('should handle invalid input', async () => {
213
+ await expect(function(invalidInput)).rejects.toThrow();
214
+ });
215
+
216
+ // Test edge cases
217
+ it('should handle empty input', async () => {
218
+ const result = await function('');
219
+ expect(result).toBe('');
220
+ });
221
+ ```
222
+
223
+ ## Testing Commands
224
+
225
+ ### commit Command Tests
226
+
227
+ Key scenarios:
228
+ - Generate commit message
229
+ - Handle interactive mode
230
+ - Process context files
231
+ - Detect file: dependencies
232
+ - Handle git errors
233
+ - Split commit suggestions
234
+
235
+ ### release Command Tests
236
+
237
+ Key scenarios:
238
+ - Generate release notes
239
+ - Handle milestone integration
240
+ - Process context files
241
+ - Compare refs correctly
242
+ - Handle large releases
243
+ - Interactive refinement
244
+
245
+ ### tree Command Tests
246
+
247
+ Key scenarios:
248
+ - Dependency graph building
249
+ - Sequential execution
250
+ - Parallel execution
251
+ - Recovery from failures
252
+ - Checkpoint management
253
+ - Package filtering
254
+
255
+ ## Continuous Integration
256
+
257
+ ### Local Precommit
258
+
259
+ ```bash
260
+ npm run precommit
261
+ ```
262
+
263
+ Runs:
264
+ 1. `npm run lint` - ESLint
265
+ 2. `npx tsc --noEmit` - Type check
266
+ 3. `npm run build` - Build
267
+ 4. `npm test` - Tests
268
+
269
+ ### GitHub Actions
270
+
271
+ Automated on push:
272
+ - Lint checking
273
+ - Type checking
274
+ - Test execution
275
+ - Build verification
276
+ - Coverage reporting
277
+
278
+ ## Test Development Workflow
279
+
280
+ ### 1. Write Failing Test
281
+
282
+ ```typescript
283
+ it('should support new feature', async () => {
284
+ const result = await newFeature();
285
+ expect(result).toBe('expected');
286
+ });
287
+ ```
288
+
289
+ ### 2. Run Test (Fails)
290
+
291
+ ```bash
292
+ npm test -- new-feature
293
+ # Test fails ✗
294
+ ```
295
+
296
+ ### 3. Implement Feature
297
+
298
+ ```typescript
299
+ export async function newFeature() {
300
+ // Implementation
301
+ return 'expected';
302
+ }
303
+ ```
304
+
305
+ ### 4. Run Test (Passes)
306
+
307
+ ```bash
308
+ npm test -- new-feature
309
+ # Test passes ✓
310
+ ```
311
+
312
+ ### 5. Check Coverage
313
+
314
+ ```bash
315
+ npm run test:coverage
316
+ # Verify new code is covered
317
+ ```
318
+
319
+ ## Debugging Tests
320
+
321
+ ### Debug Single Test
322
+
323
+ ```bash
324
+ # With node inspector
325
+ node --inspect node_modules/.bin/vitest run tests/my-test.test.ts
326
+
327
+ # With console.log
328
+ # Add console.log in test or code
329
+ npm test -- my-test.test.ts
330
+
331
+ # With debugger
332
+ # Add `debugger;` statement
333
+ node --inspect-brk node_modules/.bin/vitest run tests/my-test.test.ts
334
+ ```
335
+
336
+ ### Test-Specific Logging
337
+
338
+ ```typescript
339
+ it('should work', async () => {
340
+ // Enable logging in test
341
+ const logger = {
342
+ info: console.log,
343
+ debug: console.log,
344
+ error: console.error,
345
+ warn: console.warn
346
+ };
347
+
348
+ const result = await execute({ logger });
349
+ });
350
+ ```
351
+
352
+ ## Test Best Practices
353
+
354
+ ### 1. Test Behavior, Not Implementation
355
+
356
+ **Bad**:
357
+ ```typescript
358
+ it('should call function', () => {
359
+ expect(internalFunction).toHaveBeenCalled();
360
+ });
361
+ ```
362
+
363
+ **Good**:
364
+ ```typescript
365
+ it('should generate commit message', async () => {
366
+ const result = await commit();
367
+ expect(result).toContain('feat:');
368
+ });
369
+ ```
370
+
371
+ ### 2. Use Descriptive Names
372
+
373
+ **Bad**:
374
+ ```typescript
375
+ it('test1', () => {});
376
+ ```
377
+
378
+ **Good**:
379
+ ```typescript
380
+ it('should generate conventional commit format for new features', () => {});
381
+ ```
382
+
383
+ ### 3. One Assertion Focus
384
+
385
+ **Bad**:
386
+ ```typescript
387
+ it('should do everything', () => {
388
+ expect(a).toBe(1);
389
+ expect(b).toBe(2);
390
+ expect(c).toBe(3);
391
+ });
392
+ ```
393
+
394
+ **Good**:
395
+ ```typescript
396
+ it('should set value a', () => expect(a).toBe(1));
397
+ it('should set value b', () => expect(b).toBe(2));
398
+ it('should set value c', () => expect(c).toBe(3));
399
+ ```
400
+
401
+ ### 4. Clean Up After Tests
402
+
403
+ ```typescript
404
+ afterEach(() => {
405
+ vi.clearAllMocks();
406
+ // Clean up files
407
+ // Reset state
408
+ });
409
+ ```
410
+
411
+ ## Test Data
412
+
413
+ ### Fixtures
414
+
415
+ Located in `tests/fixtures/`:
416
+ - Sample diffs
417
+ - Sample commit logs
418
+ - Mock API responses
419
+ - Test configurations
420
+
421
+ ### Using Fixtures
422
+
423
+ ```typescript
424
+ import { readFileSync } from 'fs';
425
+ import { join } from 'path';
426
+
427
+ const sampleDiff = readFileSync(
428
+ join(__dirname, 'fixtures', 'sample-diff.txt'),
429
+ 'utf8'
430
+ );
431
+ ```
432
+
433
+ ## Performance Testing
434
+
435
+ ### Measure Test Performance
436
+
437
+ ```bash
438
+ # Run with timing
439
+ npm test -- --reporter=verbose
440
+
441
+ # Find slow tests
442
+ npm test -- --reporter=verbose | grep -E "[0-9]+ms" | sort -n
443
+ ```
444
+
445
+ ### Optimize Slow Tests
446
+
447
+ - Mock expensive operations
448
+ - Use smaller fixtures
449
+ - Parallelize where possible
450
+ - Skip slow tests in watch mode
451
+
452
+ ## Next Steps
453
+
454
+ - **[Development Guide](./development.md)** - Build and extend
455
+ - **[Debugging Guide](./debugging.md)** - Troubleshoot issues
456
+ - **[Architecture Guide](./architecture.md)** - Understand design
457
+ - **[Commands Reference](./commands.md)** - Test specific commands
458
+
459
+ Keep the tests green! 🟢
460
+