@elyracode/git-intel 0.9.55 → 0.9.57

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 (2) hide show
  1. package/extensions/index.ts +46 -22
  2. package/package.json +1 -1
@@ -1,9 +1,21 @@
1
1
  import { execSync } from "node:child_process";
2
- import type { ExtensionAPI } from "@elyracode/coding-agent";
2
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
3
3
  import { Type } from "typebox";
4
4
 
5
- export default function (elyra: ExtensionAPI): void {
5
+ /** Details reported by git_briefing. */
6
+ interface BriefingDetails {
7
+ commits?: number;
8
+ files?: number;
9
+ }
10
+
11
+ /** Details reported by generate_pr_description. */
12
+ interface PrDescriptionDetails {
13
+ branch?: string;
14
+ base?: string;
15
+ commitCount?: number;
16
+ }
6
17
 
18
+ export default function (elyra: ExtensionAPI): void {
7
19
  // ── Tool: git_briefing ──
8
20
  elyra.registerTool({
9
21
  name: "git_briefing",
@@ -14,10 +26,12 @@ export default function (elyra: ExtensionAPI): void {
14
26
  "Use this at the start of a session to understand what changed.",
15
27
  parameters: Type.Object({
16
28
  since: Type.Optional(
17
- Type.String({ description: "Time period (e.g., '24 hours ago', 'yesterday', '3 days ago'). Default: '24 hours ago'" }),
29
+ Type.String({
30
+ description: "Time period (e.g., '24 hours ago', 'yesterday', '3 days ago'). Default: '24 hours ago'",
31
+ }),
18
32
  ),
19
33
  }),
20
- execute: async (_toolCallId, params) => {
34
+ execute: async (_toolCallId, params): Promise<AgentToolResult<BriefingDetails>> => {
21
35
  try {
22
36
  const cwd = process.cwd();
23
37
  const since = params.since ?? "24 hours ago";
@@ -52,7 +66,10 @@ export default function (elyra: ExtensionAPI): void {
52
66
  }
53
67
 
54
68
  // Changed files
55
- const changedFiles = git(cwd, `diff --name-only HEAD~${Math.min(commitLines.length, 50)}..HEAD 2>/dev/null || echo ""`);
69
+ const changedFiles = git(
70
+ cwd,
71
+ `diff --name-only HEAD~${Math.min(commitLines.length, 50)}..HEAD 2>/dev/null || echo ""`,
72
+ );
56
73
  const fileList = changedFiles.split("\n").filter((l) => l.trim());
57
74
  if (fileList.length > 0) {
58
75
  lines.push(`## Changed Files (${fileList.length})`);
@@ -78,8 +95,14 @@ export default function (elyra: ExtensionAPI): void {
78
95
  }
79
96
 
80
97
  // Branches with recent activity
81
- const branches = git(cwd, "branch -a --sort=-committerdate --format='%(refname:short) %(committerdate:relative)'");
82
- const branchLines = branches.split("\n").filter((l) => l.trim()).slice(0, 10);
98
+ const branches = git(
99
+ cwd,
100
+ "branch -a --sort=-committerdate --format='%(refname:short) %(committerdate:relative)'",
101
+ );
102
+ const branchLines = branches
103
+ .split("\n")
104
+ .filter((l) => l.trim())
105
+ .slice(0, 10);
83
106
  if (branchLines.length > 1) {
84
107
  lines.push("## Active Branches");
85
108
  for (const b of branchLines) {
@@ -131,18 +154,19 @@ export default function (elyra: ExtensionAPI): void {
131
154
  };
132
155
  }
133
156
  return {
134
- content: [{
135
- type: "text",
136
- text: `No staged changes. Stage files first with \`git add\`.\n\nUnstaged changes:\n${diff}`,
137
- }],
157
+ content: [
158
+ {
159
+ type: "text",
160
+ text: `No staged changes. Stage files first with \`git add\`.\n\nUnstaged changes:\n${diff}`,
161
+ },
162
+ ],
138
163
  details: {},
139
164
  };
140
165
  }
141
166
 
142
167
  const diffContent = git(cwd, "diff --cached");
143
- const truncatedDiff = diffContent.length > 30000
144
- ? `${diffContent.slice(0, 30000)}\n\n... (truncated)`
145
- : diffContent;
168
+ const truncatedDiff =
169
+ diffContent.length > 30000 ? `${diffContent.slice(0, 30000)}\n\n... (truncated)` : diffContent;
146
170
 
147
171
  const lines: string[] = [
148
172
  "# Staged Changes",
@@ -160,9 +184,7 @@ export default function (elyra: ExtensionAPI): void {
160
184
  "",
161
185
  "Types: feat, fix, chore, docs, refactor, test, style, perf",
162
186
  "Scope: the package or area affected",
163
- params.include_body
164
- ? "Include a body explaining what and why (not how)."
165
- : "Keep it to a single line.",
187
+ params.include_body ? "Include a body explaining what and why (not how)." : "Keep it to a single line.",
166
188
  ];
167
189
 
168
190
  return {
@@ -192,7 +214,7 @@ export default function (elyra: ExtensionAPI): void {
192
214
  Type.String({ description: "Base branch to compare against (default: auto-detect main or master)" }),
193
215
  ),
194
216
  }),
195
- execute: async (_toolCallId, params) => {
217
+ execute: async (_toolCallId, params): Promise<AgentToolResult<PrDescriptionDetails>> => {
196
218
  try {
197
219
  const cwd = process.cwd();
198
220
 
@@ -212,9 +234,7 @@ export default function (elyra: ExtensionAPI): void {
212
234
  const diffStat = git(cwd, `diff --stat ${base}..HEAD`);
213
235
  const diff = git(cwd, `diff ${base}..HEAD`);
214
236
 
215
- const truncatedDiff = diff.length > 50000
216
- ? `${diff.slice(0, 50000)}\n\n... (truncated)`
217
- : diff;
237
+ const truncatedDiff = diff.length > 50000 ? `${diff.slice(0, 50000)}\n\n... (truncated)` : diff;
218
238
 
219
239
  const lines: string[] = [
220
240
  `# PR: ${currentBranch} -> ${base}`,
@@ -239,7 +259,11 @@ export default function (elyra: ExtensionAPI): void {
239
259
 
240
260
  return {
241
261
  content: [{ type: "text", text: lines.join("\n") }],
242
- details: { branch: currentBranch, base, commitCount: commits.split("\n").filter((l) => l.trim()).length },
262
+ details: {
263
+ branch: currentBranch,
264
+ base,
265
+ commitCount: commits.split("\n").filter((l) => l.trim()).length,
266
+ },
243
267
  };
244
268
  } catch (error) {
245
269
  const msg = error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/git-intel",
3
- "version": "0.9.55",
3
+ "version": "0.9.57",
4
4
  "description": "Elyra extension for Git intelligence -- session briefings, commit message generation, PR descriptions",
5
5
  "type": "module",
6
6
  "keywords": [