@eldrforge/ai-service 0.1.13 → 0.1.14
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 +1112 -226
- package/dist/index.js +84 -55
- package/dist/index.js.map +1 -1
- package/examples/01-simple-commit.ts +80 -0
- package/examples/02-release-notes.ts +124 -0
- package/examples/03-interactive-commit.ts +150 -0
- package/examples/04-custom-storage.ts +162 -0
- package/examples/05-custom-tools.ts +243 -0
- package/examples/README.md +320 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1136,7 +1136,7 @@ function createGetFileHistoryTool$1() {
|
|
|
1136
1136
|
function createGetFileContentTool$1() {
|
|
1137
1137
|
return {
|
|
1138
1138
|
name: "get_file_content",
|
|
1139
|
-
description: "Get the complete current content of a file to understand context around changes",
|
|
1139
|
+
description: "Get the complete current content of a file to understand context around changes. Returns a message if the file does not exist (e.g., if it was deleted).",
|
|
1140
1140
|
parameters: {
|
|
1141
1141
|
type: "object",
|
|
1142
1142
|
properties: {
|
|
@@ -1166,6 +1166,11 @@ function createGetFileContentTool$1() {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
return content;
|
|
1168
1168
|
} catch (error) {
|
|
1169
|
+
if (error.code === "ENOENT" || error.message?.includes("ENOENT")) {
|
|
1170
|
+
return `File not found: ${filePath}
|
|
1171
|
+
|
|
1172
|
+
This file may have been deleted in this release or does not exist in the current working tree. Check the diff to see if this file was removed.`;
|
|
1173
|
+
}
|
|
1169
1174
|
throw new Error(`Failed to read file: ${error.message}`);
|
|
1170
1175
|
}
|
|
1171
1176
|
}
|
|
@@ -1207,7 +1212,7 @@ function createSearchCodebaseTool$1() {
|
|
|
1207
1212
|
const output = await run(command, { cwd: workingDir });
|
|
1208
1213
|
return output.stdout || "No matches found";
|
|
1209
1214
|
} catch (error) {
|
|
1210
|
-
if (error.message.includes("exit code 1")) {
|
|
1215
|
+
if (error.message.includes("exit code 1") || error.stderr?.includes("did not match any file")) {
|
|
1211
1216
|
return "No matches found";
|
|
1212
1217
|
}
|
|
1213
1218
|
throw new Error(`Search failed: ${error.message}`);
|
|
@@ -1494,29 +1499,42 @@ async function runAgenticCommit(config) {
|
|
|
1494
1499
|
function buildSystemPrompt$1() {
|
|
1495
1500
|
return `You are an expert software engineer tasked with generating meaningful commit messages.
|
|
1496
1501
|
|
|
1497
|
-
You have access to tools
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
-
|
|
1503
|
-
- analyze_diff_section:
|
|
1504
|
-
-
|
|
1505
|
-
|
|
1502
|
+
You have access to tools to understand changes deeply. Use them strategically based on what you see:
|
|
1503
|
+
|
|
1504
|
+
## When to Use Each Tool
|
|
1505
|
+
|
|
1506
|
+
**Understanding What Changed:**
|
|
1507
|
+
- get_file_content: Use when you need full context. Good for: seeing entire class/function being modified, checking imports, understanding overall structure
|
|
1508
|
+
- analyze_diff_section: Use when diff is confusing. Good for: expanding context around small changes, seeing how code integrates
|
|
1509
|
+
- get_file_dependencies: Use for import/refactor changes. Good for: understanding what's being moved/reorganized, checking dependency impact
|
|
1510
|
+
|
|
1511
|
+
**Understanding Why:**
|
|
1512
|
+
- get_file_history: Use to see evolution. Good for: understanding if this continues previous work, checking for patterns
|
|
1513
|
+
- get_recent_commits: Use to check recent context. Good for: avoiding duplicate messages, understanding if this is part of a series
|
|
1514
|
+
- search_codebase: Use to understand usage. Good for: seeing if changes affect multiple places, finding patterns
|
|
1515
|
+
|
|
1516
|
+
**Organizing Changes:**
|
|
1517
|
+
- group_files_by_concern: Use when multiple files changed. Good for: identifying logical groupings, determining if split is needed
|
|
1518
|
+
- get_related_tests: Use for logic changes. Good for: understanding intent from test changes, verifying behavior changes
|
|
1519
|
+
|
|
1520
|
+
## Investigation Strategy
|
|
1521
|
+
|
|
1522
|
+
For simple changes (1-3 files, obvious purpose):
|
|
1523
|
+
- Use 1-2 tools: get_recent_commits to avoid duplicates, get_related_tests if logic changed
|
|
1524
|
+
|
|
1525
|
+
For moderate changes (4-10 files, clear theme):
|
|
1526
|
+
- Use 2-4 tools: group_files_by_concern, get_file_content for key files, get_recent_commits, get_related_tests
|
|
1506
1527
|
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
2. Use tools to investigate specific changes that need more context
|
|
1510
|
-
3. Identify if changes represent one cohesive commit or multiple logical commits
|
|
1511
|
-
4. Generate a commit message (or multiple if splits suggested) that accurately describes changes
|
|
1528
|
+
For complex changes (10+ files, or unclear purpose):
|
|
1529
|
+
- Use 4-6 tools: group_files_by_concern, get_file_history, get_file_content for key files, get_file_dependencies, get_related_tests, search_codebase
|
|
1512
1530
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
-
|
|
1531
|
+
Always use tools to understand context - don't rely only on the diff.
|
|
1532
|
+
|
|
1533
|
+
## Guidelines
|
|
1534
|
+
- Follow conventional commit format when appropriate (feat:, fix:, refactor:, docs:, test:, chore:)
|
|
1517
1535
|
- Consider suggesting split commits for unrelated changes
|
|
1518
|
-
-
|
|
1519
|
-
-
|
|
1536
|
+
- Output only the commit message and/or splits - no conversational remarks
|
|
1537
|
+
- NEVER include phrases like "If you want" or "Let me know" or offer follow-up actions
|
|
1520
1538
|
|
|
1521
1539
|
Output format:
|
|
1522
1540
|
When you're ready to provide the final commit message, format it as:
|
|
@@ -1645,7 +1663,7 @@ function createGetFileHistoryTool() {
|
|
|
1645
1663
|
function createGetFileContentTool() {
|
|
1646
1664
|
return {
|
|
1647
1665
|
name: "get_file_content",
|
|
1648
|
-
description: "Get the complete current content of a file to understand context around changes",
|
|
1666
|
+
description: "Get the complete current content of a file to understand context around changes. Returns a message if the file does not exist (e.g., if it was deleted).",
|
|
1649
1667
|
parameters: {
|
|
1650
1668
|
type: "object",
|
|
1651
1669
|
properties: {
|
|
@@ -1675,6 +1693,11 @@ function createGetFileContentTool() {
|
|
|
1675
1693
|
}
|
|
1676
1694
|
return content;
|
|
1677
1695
|
} catch (error) {
|
|
1696
|
+
if (error.code === "ENOENT" || error.message?.includes("ENOENT")) {
|
|
1697
|
+
return `File not found: ${filePath}
|
|
1698
|
+
|
|
1699
|
+
This file may have been deleted in this release or does not exist in the current working tree. Check the diff to see if this file was removed.`;
|
|
1700
|
+
}
|
|
1678
1701
|
throw new Error(`Failed to read file: ${error.message}`);
|
|
1679
1702
|
}
|
|
1680
1703
|
}
|
|
@@ -1716,7 +1739,7 @@ function createSearchCodebaseTool() {
|
|
|
1716
1739
|
const output = await run(command, { cwd: workingDir });
|
|
1717
1740
|
return output.stdout || "No matches found";
|
|
1718
1741
|
} catch (error) {
|
|
1719
|
-
if (error.message.includes("exit code 1")) {
|
|
1742
|
+
if (error.message.includes("exit code 1") || error.stderr?.includes("did not match any file")) {
|
|
1720
1743
|
return "No matches found";
|
|
1721
1744
|
}
|
|
1722
1745
|
throw new Error(`Search failed: ${error.message}`);
|
|
@@ -2292,38 +2315,40 @@ async function runAgenticRelease(config) {
|
|
|
2292
2315
|
function buildSystemPrompt() {
|
|
2293
2316
|
return `You are an expert software engineer and technical writer tasked with generating comprehensive, thoughtful release notes.
|
|
2294
2317
|
|
|
2295
|
-
You have access to tools
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
-
|
|
2301
|
-
-
|
|
2302
|
-
-
|
|
2303
|
-
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
-
|
|
2307
|
-
-
|
|
2308
|
-
-
|
|
2318
|
+
You have access to tools to investigate the release in depth. Use them strategically:
|
|
2319
|
+
|
|
2320
|
+
## Investigation Tools
|
|
2321
|
+
|
|
2322
|
+
**Understanding Context & History:**
|
|
2323
|
+
- get_file_history: Use when you need to understand how a file evolved. Good for: seeing if a refactor is part of a larger pattern, understanding why certain decisions were made
|
|
2324
|
+
- get_recent_commits: Use to see what happened to files recently. Good for: detecting related work, understanding if this is part of an ongoing effort
|
|
2325
|
+
- compare_previous_release: Use to contextualize scope. Good for: comparing size/impact of this release vs previous ones, identifying if this is major/minor
|
|
2326
|
+
- get_tag_history: Use early to understand release cadence. Good for: establishing context about project versioning patterns
|
|
2327
|
+
|
|
2328
|
+
**Analyzing Current Changes:**
|
|
2329
|
+
- get_file_content: Use when diff alone isn't enough. Good for: understanding APIs, seeing full class/function context, checking imports
|
|
2330
|
+
- analyze_diff_section: Use to expand context around cryptic changes. Good for: seeing surrounding code, understanding integration points
|
|
2331
|
+
- get_file_dependencies: Use for refactors/moves. Good for: assessing impact scope, identifying what depends on changed code
|
|
2332
|
+
- search_codebase: Use to find usage patterns. Good for: checking if APIs are widely used, finding similar patterns elsewhere
|
|
2333
|
+
|
|
2334
|
+
**Pattern Recognition:**
|
|
2335
|
+
- group_files_by_concern: Use when many files changed. Good for: organizing changes into logical themes, identifying what actually happened
|
|
2336
|
+
- analyze_commit_patterns: Use for many commits. Good for: detecting themes across commits, identifying if work is focused or scattered
|
|
2337
|
+
- get_release_stats: Use to quantify scope. Good for: getting concrete metrics on scale of changes
|
|
2338
|
+
|
|
2339
|
+
**Risk Assessment:**
|
|
2340
|
+
- get_breaking_changes: Always use. Good for: identifying API changes, finding removals/signature changes that could break users
|
|
2341
|
+
- get_related_tests: Use for significant logic changes. Good for: understanding what behavior changed, verifying test coverage exists
|
|
2342
|
+
|
|
2343
|
+
## Your Investigation Strategy
|
|
2309
2344
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
5. Check for breaking changes and significant architectural shifts
|
|
2316
|
-
6. Understand the "why" behind changes by examining commit messages, issues, and code
|
|
2317
|
-
7. Synthesize findings into comprehensive, thoughtful release notes
|
|
2345
|
+
1. **Start broad** (2-3 tools): get_tag_history, get_release_stats, analyze_commit_patterns
|
|
2346
|
+
2. **Identify themes** (1-2 tools): group_files_by_concern if many files, compare_previous_release for context
|
|
2347
|
+
3. **Deep dive** (3-5 tools): get_file_content for key changes, get_file_dependencies for refactors, analyze_diff_section for unclear changes
|
|
2348
|
+
4. **Verify understanding** (2-3 tools): get_related_tests for logic changes, search_codebase for impact
|
|
2349
|
+
5. **Check risks** (1 tool): get_breaking_changes always
|
|
2318
2350
|
|
|
2319
|
-
|
|
2320
|
-
- Use tools strategically - focus on understanding significant changes
|
|
2321
|
-
- Look at test changes to understand intent and functionality
|
|
2322
|
-
- Check previous releases to provide context and compare scope
|
|
2323
|
-
- Identify patterns and themes across multiple commits
|
|
2324
|
-
- Consider the audience and what context they need
|
|
2325
|
-
- Be thorough and analytical, especially for large releases
|
|
2326
|
-
- Follow the release notes format and best practices provided
|
|
2351
|
+
Use at least 6-8 tools per release to ensure comprehensive analysis. Each tool provides a different lens on the changes.
|
|
2327
2352
|
|
|
2328
2353
|
Output format:
|
|
2329
2354
|
When you're ready to provide the final release notes, format them as JSON:
|
|
@@ -2340,7 +2365,11 @@ The release notes should:
|
|
|
2340
2365
|
- Connect related changes to reveal patterns
|
|
2341
2366
|
- Be substantial and analytical, not formulaic
|
|
2342
2367
|
- Sound like they were written by a human who studied the changes
|
|
2343
|
-
- Be grounded in actual commits and issues (no hallucinations)
|
|
2368
|
+
- Be grounded in actual commits and issues (no hallucinations)
|
|
2369
|
+
- Be standalone documentation that can be published as-is
|
|
2370
|
+
- NEVER include conversational elements like "If you want, I can also..." or "Let me know if..."
|
|
2371
|
+
- NEVER offer follow-up actions, questions, or suggestions for additional work
|
|
2372
|
+
- End with substantive content, not conversational closing remarks`;
|
|
2344
2373
|
}
|
|
2345
2374
|
function buildUserMessage(params) {
|
|
2346
2375
|
const { fromRef, toRef, logContent, diffContent, milestoneIssues, releaseFocus, userContext } = params;
|