@eldrforge/kodrdriv 1.2.131 → 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.
Files changed (48) hide show
  1. package/AI-GUIDE.md +834 -0
  2. package/README.md +35 -6
  3. package/agentic-reflection-commit-2025-12-27T22-56-06-143Z.md +50 -0
  4. package/agentic-reflection-commit-2025-12-27T23-01-57-294Z.md +50 -0
  5. package/agentic-reflection-commit-2025-12-27T23-11-57-811Z.md +50 -0
  6. package/agentic-reflection-commit-2025-12-27T23-12-50-645Z.md +50 -0
  7. package/agentic-reflection-commit-2025-12-27T23-13-59-347Z.md +52 -0
  8. package/agentic-reflection-commit-2025-12-27T23-14-36-001Z.md +50 -0
  9. package/agentic-reflection-commit-2025-12-27T23-18-59-832Z.md +50 -0
  10. package/agentic-reflection-commit-2025-12-27T23-25-20-667Z.md +62 -0
  11. package/dist/application.js +3 -0
  12. package/dist/application.js.map +1 -1
  13. package/dist/arguments.js +54 -21
  14. package/dist/arguments.js.map +1 -1
  15. package/dist/commands/audio-commit.js +2 -1
  16. package/dist/commands/audio-commit.js.map +1 -1
  17. package/dist/commands/audio-review.js +4 -2
  18. package/dist/commands/audio-review.js.map +1 -1
  19. package/dist/commands/commit.js +109 -288
  20. package/dist/commands/commit.js.map +1 -1
  21. package/dist/commands/publish.js +48 -6
  22. package/dist/commands/publish.js.map +1 -1
  23. package/dist/commands/release.js +79 -292
  24. package/dist/commands/release.js.map +1 -1
  25. package/dist/commands/review.js +1 -1
  26. package/dist/commands/review.js.map +1 -1
  27. package/dist/commands/tree.js +29 -33
  28. package/dist/commands/tree.js.map +1 -1
  29. package/dist/constants.js +3 -1
  30. package/dist/constants.js.map +1 -1
  31. package/dist/util/loggerAdapter.js +17 -0
  32. package/dist/util/loggerAdapter.js.map +1 -1
  33. package/dist/util/storageAdapter.js +9 -2
  34. package/dist/util/storageAdapter.js.map +1 -1
  35. package/guide/ai-system.md +519 -0
  36. package/guide/architecture.md +346 -0
  37. package/guide/commands.md +380 -0
  38. package/guide/configuration.md +513 -0
  39. package/guide/debugging.md +584 -0
  40. package/guide/development.md +629 -0
  41. package/guide/index.md +212 -0
  42. package/guide/integration.md +507 -0
  43. package/guide/monorepo.md +530 -0
  44. package/guide/quickstart.md +223 -0
  45. package/guide/testing.md +460 -0
  46. package/guide/tree-operations.md +618 -0
  47. package/guide/usage.md +575 -0
  48. package/package.json +9 -9
@@ -0,0 +1,629 @@
1
+ # Development Guide
2
+
3
+ Building, testing, and extending kodrdriv.
4
+
5
+ ## Development Setup
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js v18+
10
+ - npm v9+
11
+ - Git
12
+ - OpenAI API key
13
+ - (Optional) GitHub token
14
+
15
+ ### Clone and Install
16
+
17
+ ```bash
18
+ # Clone repository
19
+ git clone https://github.com/yourusername/kodrdriv.git
20
+ cd kodrdriv
21
+
22
+ # Install dependencies
23
+ npm install
24
+
25
+ # Build
26
+ npm run build
27
+
28
+ # Link for development
29
+ npm link
30
+ ```
31
+
32
+ ### Verify Setup
33
+
34
+ ```bash
35
+ # Run tests
36
+ npm test
37
+
38
+ # Run linter
39
+ npm run lint
40
+
41
+ # Type check
42
+ npx tsc --noEmit
43
+
44
+ # Full precommit
45
+ npm run precommit
46
+ ```
47
+
48
+ ## Project Structure
49
+
50
+ ```
51
+ kodrdriv/
52
+ ├── src/
53
+ │ ├── main.ts # Entry point
54
+ │ ├── application.ts # App initialization
55
+ │ ├── arguments.ts # CLI parsing
56
+ │ ├── types.ts # TypeScript types
57
+ │ ├── constants.ts # Defaults
58
+ │ ├── logging.ts # Logger setup
59
+ │ │
60
+ │ ├── commands/ # Command implementations
61
+ │ │ ├── commit.ts
62
+ │ │ ├── release.ts
63
+ │ │ ├── publish.ts
64
+ │ │ ├── tree.ts
65
+ │ │ └── ...
66
+ │ │
67
+ │ ├── util/ # Utilities
68
+ │ │ ├── aiAdapter.ts # AI service adapter
69
+ │ │ ├── storageAdapter.ts
70
+ │ │ ├── loggerAdapter.ts
71
+ │ │ ├── interactive.ts
72
+ │ │ └── ...
73
+ │ │
74
+ │ ├── content/ # Content generation
75
+ │ │ ├── diff.ts
76
+ │ │ ├── log.ts
77
+ │ │ └── files.ts
78
+ │ │
79
+ │ └── utils/ # Business logic
80
+ │ ├── branchState.ts
81
+ │ ├── publishState.ts
82
+ │ └── cleanup.ts
83
+
84
+ ├── tests/ # Test suite
85
+ │ ├── commands/
86
+ │ ├── util/
87
+ │ └── integration/
88
+
89
+ ├── docs/ # Documentation
90
+ ├── guide/ # AI-friendly guides
91
+ └── output/ # Generated files
92
+ ```
93
+
94
+ ## Building
95
+
96
+ ### Build Commands
97
+
98
+ ```bash
99
+ # Full build
100
+ npm run build
101
+
102
+ # Watch mode
103
+ npm run build --watch
104
+
105
+ # Type check only
106
+ npx tsc --noEmit
107
+
108
+ # Lint only
109
+ npm run lint
110
+ ```
111
+
112
+ ### Build Output
113
+
114
+ ```
115
+ dist/
116
+ ├── main.js # CLI entry point
117
+ ├── commands/ # Compiled commands
118
+ ├── util/ # Compiled utilities
119
+ └── ... (all source compiled)
120
+ ```
121
+
122
+ ## Testing
123
+
124
+ ### Test Commands
125
+
126
+ ```bash
127
+ # All tests
128
+ npm test
129
+
130
+ # Watch mode
131
+ npm run test:watch
132
+
133
+ # Coverage
134
+ npm run test:coverage
135
+
136
+ # Specific file
137
+ npm test tests/commands/commit.test.ts
138
+
139
+ # With pattern
140
+ npm test -- commit
141
+ ```
142
+
143
+ ### Test Structure
144
+
145
+ ```
146
+ tests/
147
+ ├── commands/ # Command tests
148
+ │ ├── commit.test.ts
149
+ │ ├── release.test.ts
150
+ │ ├── release-agentic.test.ts
151
+ │ └── ...
152
+ ├── util/ # Utility tests
153
+ └── integration/ # Integration tests
154
+ ```
155
+
156
+ ### Writing Tests
157
+
158
+ ```typescript
159
+ import { describe, it, expect, vi } from 'vitest';
160
+
161
+ describe('MyCommand', () => {
162
+ it('should generate output', async () => {
163
+ const result = await execute(mockConfig);
164
+ expect(result).toContain('expected');
165
+ });
166
+ });
167
+ ```
168
+
169
+ ### Mocking External Dependencies
170
+
171
+ ```typescript
172
+ // Mock git-tools
173
+ vi.mock('@eldrforge/git-tools', () => ({
174
+ run: vi.fn(),
175
+ validateString: vi.fn(v => v)
176
+ }));
177
+
178
+ // Mock ai-service
179
+ vi.mock('@eldrforge/ai-service', () => ({
180
+ runAgenticCommit: vi.fn().mockResolvedValue({
181
+ commitMessage: 'test message',
182
+ iterations: 5
183
+ })
184
+ }));
185
+ ```
186
+
187
+ ## Adding Features
188
+
189
+ ### Adding a New Command
190
+
191
+ 1. **Create command module**:
192
+ ```typescript
193
+ // src/commands/my-command.ts
194
+ import { Config } from '../types';
195
+ import { getLogger } from '../logging';
196
+
197
+ export const execute = async (runConfig: Config): Promise<string> => {
198
+ const logger = getLogger();
199
+ const isDryRun = runConfig.dryRun || false;
200
+
201
+ // Implementation
202
+
203
+ return 'Result';
204
+ };
205
+ ```
206
+
207
+ 2. **Add types**:
208
+ ```typescript
209
+ // src/types.ts
210
+ export type MyCommandConfig = {
211
+ option1?: string;
212
+ option2?: boolean;
213
+ };
214
+
215
+ // Add to ConfigSchema
216
+ myCommand: z.object({
217
+ option1: z.string().optional(),
218
+ option2: z.boolean().optional(),
219
+ }).optional(),
220
+ ```
221
+
222
+ 3. **Add defaults**:
223
+ ```typescript
224
+ // src/constants.ts
225
+ myCommand: {
226
+ option1: 'default',
227
+ option2: false,
228
+ },
229
+ ```
230
+
231
+ 4. **Add CLI interface**:
232
+ ```typescript
233
+ // src/arguments.ts
234
+ const myCommand = program
235
+ .command('my-command')
236
+ .option('--option1 <value>', 'description')
237
+ .option('--option2', 'description')
238
+ .description('My command description');
239
+ ```
240
+
241
+ 5. **Register command**:
242
+ ```typescript
243
+ // src/main.ts
244
+ import * as MyCommand from './commands/my-command';
245
+
246
+ if (commandName === 'my-command') {
247
+ summary = await MyCommand.execute(runConfig);
248
+ }
249
+ ```
250
+
251
+ 6. **Write tests**:
252
+ ```typescript
253
+ // tests/commands/my-command.test.ts
254
+ describe('MyCommand', () => {
255
+ it('should work', async () => {
256
+ const result = await execute(mockConfig);
257
+ expect(result).toBeDefined();
258
+ });
259
+ });
260
+ ```
261
+
262
+ ### Adding AI Tools
263
+
264
+ 1. **Define tool in ai-service**:
265
+ ```typescript
266
+ // ai-service/src/tools/my-tools.ts
267
+ export function createMyTools(): Tool[] {
268
+ return [{
269
+ name: 'my_tool',
270
+ description: 'What this tool does',
271
+ parameters: {
272
+ type: 'object',
273
+ properties: {
274
+ param1: { type: 'string' }
275
+ },
276
+ required: ['param1']
277
+ },
278
+ execute: async (params, context) => {
279
+ // Implementation
280
+ return { result: 'data' };
281
+ }
282
+ }];
283
+ }
284
+ ```
285
+
286
+ 2. **Register tool**:
287
+ ```typescript
288
+ // In commit.ts or release.ts
289
+ const tools = createMyTools();
290
+ toolRegistry.registerAll(tools);
291
+ ```
292
+
293
+ 3. **Update prompts**:
294
+ ```typescript
295
+ // Reference new tool in system prompt
296
+ const toolGuidance = generateToolGuidance(tools, ...);
297
+ ```
298
+
299
+ ## Debugging Development Issues
300
+
301
+ ### Build Failures
302
+
303
+ ```bash
304
+ # Clean build
305
+ rm -rf dist
306
+ npm run build
307
+
308
+ # Check for TypeScript errors
309
+ npx tsc --noEmit
310
+
311
+ # Check for circular dependencies
312
+ npx madge --circular src
313
+ ```
314
+
315
+ ### Test Failures
316
+
317
+ ```bash
318
+ # Run specific test
319
+ npm test -- my-test.test.ts
320
+
321
+ # Run with full output
322
+ npm test -- --reporter=verbose
323
+
324
+ # Update snapshots
325
+ npm test -- -u
326
+ ```
327
+
328
+ ### Import/Module Issues
329
+
330
+ ```bash
331
+ # Clear node_modules
332
+ rm -rf node_modules package-lock.json
333
+ npm install
334
+
335
+ # Rebuild packages
336
+ npm run build
337
+
338
+ # Re-link
339
+ npm link
340
+ ```
341
+
342
+ ## Code Style
343
+
344
+ ### TypeScript
345
+
346
+ ```typescript
347
+ // Use explicit types
348
+ export const execute = async (runConfig: Config): Promise<string> => {
349
+ // ...
350
+ };
351
+
352
+ // Use type guards
353
+ if (typeof value === 'string') {
354
+ // ...
355
+ }
356
+
357
+ // Avoid any when possible
358
+ const result: Result = await operation();
359
+ ```
360
+
361
+ ### Error Handling
362
+
363
+ ```typescript
364
+ // Use custom error types
365
+ import { ValidationError, CommandError } from '@eldrforge/shared';
366
+
367
+ // Throw with context
368
+ throw new ValidationError('Invalid input', { field: 'username' });
369
+
370
+ // Catch and wrap
371
+ try {
372
+ await externalOperation();
373
+ } catch (error: any) {
374
+ throw new ExternalDependencyError('Operation failed', 'service-name', error);
375
+ }
376
+ ```
377
+
378
+ ### Logging
379
+
380
+ ```typescript
381
+ // Use structured logging
382
+ logger.info('OPERATION_START: Starting operation | Param: %s | Mode: %s', param, mode);
383
+ logger.debug('Detailed information: %o', object);
384
+ logger.error('OPERATION_FAILED: Operation failed | Error: %s', error.message);
385
+
386
+ // Follow logging guide
387
+ // See: AI-FRIENDLY-LOGGING-GUIDE.md
388
+ ```
389
+
390
+ ## Package Development
391
+
392
+ ### Working on ai-service
393
+
394
+ ```bash
395
+ cd ai-service
396
+
397
+ # Install
398
+ npm install
399
+
400
+ # Build
401
+ npm run build
402
+
403
+ # Test
404
+ npm test
405
+
406
+ # Link locally
407
+ npm link
408
+
409
+ # Use in kodrdriv
410
+ cd ../kodrdriv
411
+ npm link @eldrforge/ai-service
412
+ ```
413
+
414
+ ### Working on tree-core
415
+
416
+ ```bash
417
+ cd tree-core
418
+
419
+ # Install & build
420
+ npm install
421
+ npm run build
422
+
423
+ # Test
424
+ npm test
425
+
426
+ # Link
427
+ npm link
428
+
429
+ # Use in kodrdriv
430
+ cd ../kodrdriv
431
+ npm link @eldrforge/tree-core
432
+ ```
433
+
434
+ ### Testing Cross-Package Changes
435
+
436
+ ```bash
437
+ # Link all packages
438
+ cd ai-service && npm link
439
+ cd ../tree-core && npm link
440
+ cd ../tree-execution && npm link
441
+ cd ../shared && npm link
442
+ cd ../git-tools && npm link
443
+ cd ../github-tools && npm link
444
+
445
+ # Link in kodrdriv
446
+ cd ../kodrdriv
447
+ npm link @eldrforge/ai-service
448
+ npm link @eldrforge/tree-core
449
+ npm link @eldrforge/tree-execution
450
+ npm link @eldrforge/shared
451
+ npm link @eldrforge/git-tools
452
+ npm link @eldrforge/github-tools
453
+
454
+ # Or use kodrdriv itself
455
+ kodrdriv tree link
456
+ ```
457
+
458
+ ## Continuous Integration
459
+
460
+ ### Local Precommit
461
+
462
+ ```bash
463
+ # Run before committing
464
+ npm run precommit
465
+
466
+ # This runs:
467
+ # 1. npm run lint
468
+ # 2. npm run build
469
+ # 3. npm run test
470
+ ```
471
+
472
+ ### CI Pipeline
473
+
474
+ GitHub Actions runs:
475
+ - Linting
476
+ - Type checking
477
+ - Tests with coverage
478
+ - Build verification
479
+
480
+ ## Debugging Tools
481
+
482
+ ### VS Code Configuration
483
+
484
+ `.vscode/launch.json`:
485
+ ```json
486
+ {
487
+ "version": "0.2.0",
488
+ "configurations": [
489
+ {
490
+ "type": "node",
491
+ "request": "launch",
492
+ "name": "Debug kodrdriv",
493
+ "program": "${workspaceFolder}/dist/main.js",
494
+ "args": ["commit", "--dry-run"],
495
+ "env": {
496
+ "OPENAI_API_KEY": "your-key"
497
+ }
498
+ }
499
+ ]
500
+ }
501
+ ```
502
+
503
+ ### Node Debugging
504
+
505
+ ```bash
506
+ # Run with inspector
507
+ node --inspect dist/main.js commit --dry-run
508
+
509
+ # Debug tests
510
+ node --inspect node_modules/.bin/vitest run tests/commands/commit.test.ts
511
+ ```
512
+
513
+ ## Common Development Tasks
514
+
515
+ ### Update Dependencies
516
+
517
+ ```bash
518
+ # Check for updates
519
+ npm outdated
520
+
521
+ # Update all
522
+ npm update
523
+
524
+ # Update specific
525
+ npm install @eldrforge/ai-service@latest
526
+
527
+ # Update across all packages
528
+ kodrdriv tree --cmd "npm update"
529
+ ```
530
+
531
+ ### Add New Configuration Option
532
+
533
+ 1. Add to type: `src/types.ts`
534
+ 2. Add to schema: Zod schema in `src/types.ts`
535
+ 3. Add default: `src/constants.ts`
536
+ 4. Add CLI option: `src/arguments.ts`
537
+ 5. Add transformation: `transformCommandsToNestedStructure()`
538
+ 6. Use in command: `src/commands/*.ts`
539
+
540
+ ### Add New AI Tool
541
+
542
+ 1. Define in `ai-service/src/tools/`
543
+ 2. Register in tool set
544
+ 3. Update prompts to reference
545
+ 4. Add tests
546
+ 5. Document in guide
547
+
548
+ ## Publishing Packages
549
+
550
+ ### Version Bumping
551
+
552
+ ```bash
553
+ # In each package
554
+ npm version patch # or minor, major
555
+
556
+ # Using kodrdriv
557
+ kodrdriv tree publish --target-version patch
558
+ ```
559
+
560
+ ### Publishing to npm
561
+
562
+ ```bash
563
+ # Build and publish
564
+ npm run build
565
+ npm publish
566
+
567
+ # Or use kodrdriv
568
+ kodrdriv publish
569
+ ```
570
+
571
+ ## Best Practices
572
+
573
+ ### Code Quality
574
+
575
+ - Write tests for new features
576
+ - Update documentation
577
+ - Follow existing patterns
578
+ - Use TypeScript strictly
579
+ - Handle errors properly
580
+
581
+ ### Performance
582
+
583
+ - Avoid blocking operations
584
+ - Use streaming for large data
585
+ - Cache expensive operations
586
+ - Set reasonable timeouts
587
+
588
+ ### Maintainability
589
+
590
+ - Keep functions small and focused
591
+ - Use descriptive names
592
+ - Add comments for complex logic
593
+ - Update types when changing interfaces
594
+
595
+ ## Resources
596
+
597
+ ### Implementation Guides
598
+
599
+ Root directory contains extensive docs:
600
+ - `AI-SERVICE-INTEGRATION-COMPLETE.md`
601
+ - `TREE-TOOLKIT-COMPLETE.md`
602
+ - `RIOTPROMPT-COMPLETE-SUMMARY.md`
603
+ - `SESSION-SUMMARY-DEC-31.md`
604
+
605
+ ### Package Documentation
606
+
607
+ Each package has detailed README:
608
+ - `ai-service/README.md`
609
+ - `tree-core/README.md`
610
+ - `tree-execution/README.md`
611
+ - `shared/README.md`
612
+
613
+ ### API Documentation
614
+
615
+ TypeScript provides inline documentation:
616
+ ```bash
617
+ # Generate API docs
618
+ npx typedoc src/index.ts
619
+ ```
620
+
621
+ ## Next Steps
622
+
623
+ - **[Testing Guide](./testing.md)** - Test strategies
624
+ - **[Architecture Guide](./architecture.md)** - System design
625
+ - **[Debugging Guide](./debugging.md)** - Troubleshooting
626
+ - **[AI System Guide](./ai-system.md)** - AI internals
627
+
628
+ Start contributing to kodrdriv and make it even better!
629
+