aws-runtime-bridge 1.7.7 → 1.7.8

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.
@@ -5,4 +5,11 @@
5
5
  */
6
6
  export declare const gitRouter: import("express-serve-static-core").Router;
7
7
  export declare function assertGitWorkspacePathAccessible(workspacePath: string): Promise<void>;
8
+ type GitDiffFileStatus = 'modified' | 'added' | 'deleted' | 'renamed';
9
+ /**
10
+ * 判断 Git diff 汇总行是否应该展示在差异树中。
11
+ * 普通 modified 且文本增删均为 0 通常是 filemode/元数据噪声,避免显示为“无差异内容”。
12
+ */
13
+ export declare function shouldIncludeGitDiffSummaryFile(status: GitDiffFileStatus, additions: number, deletions: number, isBinaryDiff: boolean): boolean;
14
+ export {};
8
15
  //# sourceMappingURL=git.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/routes/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,eAAO,MAAM,SAAS,4CAAW,CAAC;AAWlC,wBAAsB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe3F"}
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/routes/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,eAAO,MAAM,SAAS,4CAAW,CAAC;AAWlC,wBAAsB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe3F;AASD,KAAK,iBAAiB,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,OAAO,GACpB,OAAO,CAMT"}
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { Router } from 'express';
7
7
  import { spawn } from 'node:child_process';
8
- import path from 'node:path';
9
8
  import { promises as fs } from 'node:fs';
9
+ import path from 'node:path';
10
10
  import { validateToken } from '../middleware/auth.js';
11
11
  export const gitRouter = Router();
12
12
  export async function assertGitWorkspacePathAccessible(workspacePath) {
@@ -25,6 +25,16 @@ export async function assertGitWorkspacePathAccessible(workspacePath) {
25
25
  throw new Error(`workspace path is not a directory: ${workspacePath}`);
26
26
  }
27
27
  }
28
+ /**
29
+ * 判断 Git diff 汇总行是否应该展示在差异树中。
30
+ * 普通 modified 且文本增删均为 0 通常是 filemode/元数据噪声,避免显示为“无差异内容”。
31
+ */
32
+ export function shouldIncludeGitDiffSummaryFile(status, additions, deletions, isBinaryDiff) {
33
+ if (status === 'added' || status === 'deleted' || status === 'renamed') {
34
+ return true;
35
+ }
36
+ return isBinaryDiff || additions > 0 || deletions > 0;
37
+ }
28
38
  /**
29
39
  * 执行 git 命令并返回输出
30
40
  */
@@ -418,10 +428,14 @@ gitRouter.post('/git/diff', validateToken, async (req, res) => {
418
428
  const parts = line.split('\t');
419
429
  if (parts.length < 3)
420
430
  continue;
431
+ const isBinaryDiff = parts[0] === '-' || parts[1] === '-';
421
432
  const additions = parts[0] === '-' ? 0 : parseInt(parts[0], 10) || 0;
422
433
  const deletions = parts[1] === '-' ? 0 : parseInt(parts[1], 10) || 0;
423
434
  const filePath = parseRenameDisplayPath(parts.slice(2).join('\t').trim());
424
435
  const status = statusMap.get(filePath) || 'modified';
436
+ if (!filePath || !shouldIncludeGitDiffSummaryFile(status, additions, deletions, isBinaryDiff)) {
437
+ continue;
438
+ }
425
439
  files.push({ path: filePath, status, additions, deletions });
426
440
  }
427
441
  res.json({
@@ -4,8 +4,8 @@
4
4
  import { mkdtemp, rm, writeFile } from 'node:fs/promises';
5
5
  import { tmpdir } from 'node:os';
6
6
  import path from 'node:path';
7
- import { describe, it, expect } from 'vitest';
8
- import { assertGitWorkspacePathAccessible } from './git.js';
7
+ import { describe, expect, it } from 'vitest';
8
+ import { assertGitWorkspacePathAccessible, shouldIncludeGitDiffSummaryFile } from './git.js';
9
9
  describe('git stash operations', () => {
10
10
  function parseStashList(output) {
11
11
  const stashes = [];
@@ -98,6 +98,21 @@ describe('git workspace path validation', () => {
98
98
  }
99
99
  });
100
100
  });
101
+ describe('git diff summary visibility', () => {
102
+ it('filters ordinary modified files without textual changes', () => {
103
+ expect(shouldIncludeGitDiffSummaryFile('modified', 0, 0, false)).toBe(false);
104
+ });
105
+ it('keeps modified files with text or binary changes', () => {
106
+ expect(shouldIncludeGitDiffSummaryFile('modified', 1, 0, false)).toBe(true);
107
+ expect(shouldIncludeGitDiffSummaryFile('modified', 0, 1, false)).toBe(true);
108
+ expect(shouldIncludeGitDiffSummaryFile('modified', 0, 0, true)).toBe(true);
109
+ });
110
+ it('keeps structural status changes even when line counts are zero', () => {
111
+ expect(shouldIncludeGitDiffSummaryFile('added', 0, 0, false)).toBe(true);
112
+ expect(shouldIncludeGitDiffSummaryFile('deleted', 0, 0, false)).toBe(true);
113
+ expect(shouldIncludeGitDiffSummaryFile('renamed', 0, 0, false)).toBe(true);
114
+ });
115
+ });
101
116
  describe('error handling', () => {
102
117
  it('detects "no local changes" error', () => {
103
118
  const isNoChangesError = (stderr) => stderr.includes('No local changes to save');
@@ -111,7 +126,7 @@ describe('error handling', () => {
111
126
  });
112
127
  it('detects invalid stash reference', () => {
113
128
  const isInvalidRef = (stderr) => stderr.includes('is not a valid reference');
114
- expect(isInvalidRef("stash@{99} is not a valid reference")).toBe(true);
129
+ expect(isInvalidRef('stash@{99} is not a valid reference')).toBe(true);
115
130
  expect(isInvalidRef('other error')).toBe(false);
116
131
  });
117
132
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-runtime-bridge",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "AgentsWorkStudio runtime bridge service for machine-level agent runtime integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",