agent-ecosystem/src/main/services/team/UnifiedLineCounter.ts
iliya 99a8bff8d2 feat: integrate terminal service and enhance CLI authentication handling
- Added PtyTerminalService to manage PTY terminal processes, enabling terminal functionalities within the application.
- Updated CLI installer to include authentication status checks, providing feedback on user login state.
- Enhanced the dashboard with a warning banner for CLI installation status, prompting users to log in if not authenticated.
- Introduced IPC channels for terminal operations, allowing communication between main and renderer processes for terminal management.
- Improved TaskCommentsSection and other components to support new features and enhance user experience during task management.
2026-02-26 20:17:32 +02:00

25 lines
805 B
TypeScript

import { diffLines } from 'diff';
/**
* Unified line counting utility using semantic diff.
* Ensures consistent +/- line counts across all services
* (MemberStatsComputer, ChangeExtractorService, FileContentResolver).
*
* Uses `diffLines()` from npm `diff` package — the same algorithm
* already used correctly in ChangeExtractorService.countLines()
* and FileContentResolver.getFileContent().
*/
export function countLineChanges(
oldStr: string,
newStr: string
): { added: number; removed: number } {
if (!oldStr && !newStr) return { added: 0, removed: 0 };
const changes = diffLines(oldStr, newStr);
let added = 0;
let removed = 0;
for (const c of changes) {
if (c.added) added += c.count ?? 0;
if (c.removed) removed += c.count ?? 0;
}
return { added, removed };
}