@eldrforge/ai-service 0.1.10 → 0.1.11
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/README.md +312 -7
- package/dist/index.js +866 -22
- package/dist/index.js.map +1 -1
- package/dist/src/agentic/release.d.ts +35 -0
- package/dist/src/agentic/release.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/tools/release-tools.d.ts +6 -0
- package/dist/src/tools/release-tools.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @eldrforge/ai-service
|
|
2
2
|
|
|
3
|
-
AI-powered content generation for automation tools.
|
|
3
|
+
AI-powered content generation for automation tools with agentic capabilities.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This package provides OpenAI integration with structured prompts for generating:
|
|
8
|
-
- Commit messages
|
|
9
|
-
- Release notes
|
|
10
|
-
- Code review analyses
|
|
7
|
+
This package provides OpenAI integration with structured prompts and agentic workflows for generating:
|
|
8
|
+
- **Commit messages** (traditional and agentic with tool-calling)
|
|
9
|
+
- **Release notes** (traditional and agentic with tool-calling)
|
|
10
|
+
- **Code review analyses**
|
|
11
11
|
|
|
12
|
-
Extracted from the kodrdriv project for reusability.
|
|
12
|
+
Extracted from the kodrdriv project for reusability and broader ecosystem use.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -23,9 +23,314 @@ npm install @eldrforge/ai-service
|
|
|
23
23
|
- `@riotprompt/riotprompt` - Structured prompt builder
|
|
24
24
|
- `@eldrforge/git-tools` - Utility functions
|
|
25
25
|
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
### Traditional Content Generation
|
|
29
|
+
- Structured prompt generation for commits, releases, and reviews
|
|
30
|
+
- OpenAI API integration with retry logic
|
|
31
|
+
- Interactive user feedback and editing
|
|
32
|
+
- Audio transcription support
|
|
33
|
+
|
|
34
|
+
### Agentic Mode (NEW)
|
|
35
|
+
- **Tool-calling capabilities** for AI-powered investigation
|
|
36
|
+
- **13 specialized tools** for release analysis
|
|
37
|
+
- **8 tools** for commit analysis
|
|
38
|
+
- **Self-reflection** reports with tool effectiveness metrics
|
|
39
|
+
- **Iterative refinement** with configurable limits
|
|
40
|
+
|
|
26
41
|
## Usage
|
|
27
42
|
|
|
28
|
-
|
|
43
|
+
### Release Notes Generation
|
|
44
|
+
|
|
45
|
+
#### Traditional Mode
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { createReleasePrompt, createCompletionWithRetry } from '@eldrforge/ai-service';
|
|
49
|
+
|
|
50
|
+
// Create prompt
|
|
51
|
+
const { prompt, maxTokens, isLargeRelease } = await createReleasePrompt(
|
|
52
|
+
{ overridePaths: [], overrides: true },
|
|
53
|
+
{
|
|
54
|
+
logContent: 'git log output',
|
|
55
|
+
diffContent: 'git diff output',
|
|
56
|
+
releaseFocus: 'Performance improvements',
|
|
57
|
+
milestoneIssues: 'Issue #1: Bug fix',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
context: 'Major release',
|
|
61
|
+
directories: ['src'],
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// Generate release notes
|
|
66
|
+
const result = await createCompletionWithRetry(
|
|
67
|
+
prompt.messages,
|
|
68
|
+
{
|
|
69
|
+
model: 'gpt-4o',
|
|
70
|
+
maxTokens,
|
|
71
|
+
responseFormat: { type: 'json_object' },
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Agentic Mode (NEW)
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { runAgenticRelease } from '@eldrforge/ai-service';
|
|
80
|
+
|
|
81
|
+
const result = await runAgenticRelease({
|
|
82
|
+
fromRef: 'v1.0.0',
|
|
83
|
+
toRef: 'HEAD',
|
|
84
|
+
logContent: 'git log output',
|
|
85
|
+
diffContent: 'git diff output',
|
|
86
|
+
milestoneIssues: 'Issue #1: Bug fix',
|
|
87
|
+
releaseFocus: 'Performance improvements',
|
|
88
|
+
userContext: 'Major release',
|
|
89
|
+
model: 'gpt-4o',
|
|
90
|
+
maxIterations: 30, // Default for releases
|
|
91
|
+
storage: storageAdapter,
|
|
92
|
+
logger: loggerAdapter,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// result.releaseNotes = { title: string, body: string }
|
|
96
|
+
// result.iterations = number of iterations used
|
|
97
|
+
// result.toolCallsExecuted = number of tool calls made
|
|
98
|
+
// result.toolMetrics = detailed metrics for each tool call
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Commit Message Generation
|
|
102
|
+
|
|
103
|
+
#### Traditional Mode
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { createCommitPrompt, createCompletionWithRetry } from '@eldrforge/ai-service';
|
|
107
|
+
|
|
108
|
+
const { prompt } = await createCommitPrompt(
|
|
109
|
+
{ overridePaths: [], overrides: true },
|
|
110
|
+
{
|
|
111
|
+
diffContent: 'git diff --staged',
|
|
112
|
+
logContext: 'Recent commits',
|
|
113
|
+
userDirection: 'Focus on API changes',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
context: 'Refactoring',
|
|
117
|
+
directories: ['src/api'],
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const commitMessage = await createCompletionWithRetry(
|
|
122
|
+
prompt.messages,
|
|
123
|
+
{ model: 'gpt-4o' }
|
|
124
|
+
);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Agentic Mode
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { runAgenticCommit } from '@eldrforge/ai-service';
|
|
131
|
+
|
|
132
|
+
const result = await runAgenticCommit({
|
|
133
|
+
changedFiles: ['src/api/users.ts', 'src/api/auth.ts'],
|
|
134
|
+
diffContent: 'git diff --staged',
|
|
135
|
+
userDirection: 'Focus on API changes',
|
|
136
|
+
logContext: 'Recent commits',
|
|
137
|
+
model: 'gpt-4o',
|
|
138
|
+
maxIterations: 10, // Default for commits
|
|
139
|
+
storage: storageAdapter,
|
|
140
|
+
logger: loggerAdapter,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// result.commitMessage = string
|
|
144
|
+
// result.suggestedSplits = array of split suggestions
|
|
145
|
+
// result.toolMetrics = detailed metrics
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Agentic Mode
|
|
149
|
+
|
|
150
|
+
### Release-Specific Tools (13 total)
|
|
151
|
+
|
|
152
|
+
**Investigation Tools** (inherited from commit generation):
|
|
153
|
+
1. `get_file_history` - View commit history for files
|
|
154
|
+
2. `get_file_content` - Read full file contents
|
|
155
|
+
3. `search_codebase` - Search for patterns
|
|
156
|
+
4. `get_related_tests` - Find related test files
|
|
157
|
+
5. `get_file_dependencies` - Analyze dependencies
|
|
158
|
+
6. `analyze_diff_section` - Get expanded context
|
|
159
|
+
7. `get_recent_commits` - See recent changes
|
|
160
|
+
8. `group_files_by_concern` - Identify logical groupings
|
|
161
|
+
|
|
162
|
+
**Release-Specific Tools** (unique to release generation):
|
|
163
|
+
9. `get_tag_history` - View previous release tags
|
|
164
|
+
10. `compare_previous_release` - Compare with previous versions
|
|
165
|
+
11. `get_release_stats` - Get comprehensive statistics
|
|
166
|
+
12. `get_breaking_changes` - Identify breaking changes
|
|
167
|
+
13. `analyze_commit_patterns` - Find themes and patterns
|
|
168
|
+
|
|
169
|
+
### Commit-Specific Tools (8 total)
|
|
170
|
+
|
|
171
|
+
Tools 1-8 from above (investigation tools only).
|
|
172
|
+
|
|
173
|
+
### Tool Registry
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { createToolRegistry, createReleaseTools, createCommitTools } from '@eldrforge/ai-service';
|
|
177
|
+
|
|
178
|
+
// For release notes
|
|
179
|
+
const registry = createToolRegistry({
|
|
180
|
+
workingDirectory: process.cwd(),
|
|
181
|
+
storage: storageAdapter,
|
|
182
|
+
logger: loggerAdapter,
|
|
183
|
+
});
|
|
184
|
+
const tools = createReleaseTools();
|
|
185
|
+
registry.registerAll(tools);
|
|
186
|
+
|
|
187
|
+
// For commits
|
|
188
|
+
const commitTools = createCommitTools();
|
|
189
|
+
registry.registerAll(commitTools);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Interactive Features
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import {
|
|
196
|
+
getUserChoice,
|
|
197
|
+
editContentInEditor,
|
|
198
|
+
getLLMFeedbackInEditor,
|
|
199
|
+
requireTTY,
|
|
200
|
+
STANDARD_CHOICES,
|
|
201
|
+
} from '@eldrforge/ai-service';
|
|
202
|
+
|
|
203
|
+
// Get user choice
|
|
204
|
+
const choice = await getUserChoice(
|
|
205
|
+
'What would you like to do?',
|
|
206
|
+
[STANDARD_CHOICES.CONFIRM, STANDARD_CHOICES.EDIT],
|
|
207
|
+
{ nonTtyErrorSuggestions: ['Use --dry-run'] }
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
// Edit in editor
|
|
211
|
+
const result = await editContentInEditor(
|
|
212
|
+
'Initial content',
|
|
213
|
+
['# Instructions', '# Edit below'],
|
|
214
|
+
'.md'
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
// Get LLM feedback
|
|
218
|
+
const feedback = await getLLMFeedbackInEditor(
|
|
219
|
+
'release notes',
|
|
220
|
+
'Current content'
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// Require TTY
|
|
224
|
+
requireTTY('This feature requires a terminal');
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## API Reference
|
|
228
|
+
|
|
229
|
+
### Types
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
// Release Types
|
|
233
|
+
interface AgenticReleaseConfig {
|
|
234
|
+
fromRef: string;
|
|
235
|
+
toRef: string;
|
|
236
|
+
logContent: string;
|
|
237
|
+
diffContent: string;
|
|
238
|
+
milestoneIssues?: string;
|
|
239
|
+
releaseFocus?: string;
|
|
240
|
+
userContext?: string;
|
|
241
|
+
model?: string;
|
|
242
|
+
maxIterations?: number; // Default: 30
|
|
243
|
+
debug?: boolean;
|
|
244
|
+
storage?: StorageAdapter;
|
|
245
|
+
logger?: Logger;
|
|
246
|
+
openaiReasoning?: 'low' | 'medium' | 'high';
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface AgenticReleaseResult {
|
|
250
|
+
releaseNotes: { title: string; body: string };
|
|
251
|
+
iterations: number;
|
|
252
|
+
toolCallsExecuted: number;
|
|
253
|
+
conversationHistory: ChatCompletionMessageParam[];
|
|
254
|
+
toolMetrics: ToolExecutionMetric[];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Commit Types
|
|
258
|
+
interface AgenticCommitConfig {
|
|
259
|
+
changedFiles: string[];
|
|
260
|
+
diffContent: string;
|
|
261
|
+
userDirection?: string;
|
|
262
|
+
logContext?: string;
|
|
263
|
+
model?: string;
|
|
264
|
+
maxIterations?: number; // Default: 10
|
|
265
|
+
debug?: boolean;
|
|
266
|
+
storage?: StorageAdapter;
|
|
267
|
+
logger?: Logger;
|
|
268
|
+
openaiReasoning?: 'low' | 'medium' | 'high';
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface AgenticCommitResult {
|
|
272
|
+
commitMessage: string;
|
|
273
|
+
iterations: number;
|
|
274
|
+
toolCallsExecuted: number;
|
|
275
|
+
suggestedSplits: Array<{
|
|
276
|
+
files: string[];
|
|
277
|
+
message: string;
|
|
278
|
+
rationale: string;
|
|
279
|
+
}>;
|
|
280
|
+
conversationHistory: ChatCompletionMessageParam[];
|
|
281
|
+
toolMetrics: ToolExecutionMetric[];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Tool Metrics
|
|
285
|
+
interface ToolExecutionMetric {
|
|
286
|
+
name: string;
|
|
287
|
+
success: boolean;
|
|
288
|
+
duration: number;
|
|
289
|
+
error?: string;
|
|
290
|
+
iteration: number;
|
|
291
|
+
timestamp: string;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Exports
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
// Prompt generation
|
|
299
|
+
export { createCommitPrompt } from './prompts/commit';
|
|
300
|
+
export { createReleasePrompt } from './prompts/release';
|
|
301
|
+
export { createReviewPrompt } from './prompts/review';
|
|
302
|
+
|
|
303
|
+
// Agentic execution
|
|
304
|
+
export { runAgenticCommit } from './agentic/commit';
|
|
305
|
+
export { runAgenticRelease } from './agentic/release';
|
|
306
|
+
export { runAgentic } from './agentic/executor';
|
|
307
|
+
|
|
308
|
+
// Tools
|
|
309
|
+
export { createToolRegistry } from './tools/registry';
|
|
310
|
+
export { createCommitTools } from './tools/commit-tools';
|
|
311
|
+
export { createReleaseTools } from './tools/release-tools';
|
|
312
|
+
|
|
313
|
+
// OpenAI integration
|
|
314
|
+
export {
|
|
315
|
+
createCompletion,
|
|
316
|
+
createCompletionWithRetry,
|
|
317
|
+
transcribeAudio,
|
|
318
|
+
} from './ai';
|
|
319
|
+
|
|
320
|
+
// Interactive features
|
|
321
|
+
export {
|
|
322
|
+
getUserChoice,
|
|
323
|
+
getUserText,
|
|
324
|
+
editContentInEditor,
|
|
325
|
+
getLLMFeedbackInEditor,
|
|
326
|
+
requireTTY,
|
|
327
|
+
STANDARD_CHOICES,
|
|
328
|
+
} from './interactive';
|
|
329
|
+
|
|
330
|
+
// Types
|
|
331
|
+
export type { StorageAdapter, Logger } from './types';
|
|
332
|
+
export type { Tool, ToolContext } from './tools/types';
|
|
333
|
+
```
|
|
29
334
|
|
|
30
335
|
## Development
|
|
31
336
|
|