Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:777genius Agent teams ai ChangeExtractorService getTaskChanges

From Leeroopedia
Knowledge Sources
Domains Code_Review, Version_Control
Last Updated 2026-10-22 00:00 GMT

Overview

Concrete tool for extracting structured file changes and diff hunks from agent team worktrees with caching and in-flight deduplication, provided by the Agent Teams application.

Description

The ChangeExtractorService.getTaskChanges() method computes the file changes made by a specific task within a team's worktree. It reads task metadata (owner, status, intervals, since) to scope the diff, delegates heavy computation to a worker process via `TaskChangeWorkerClient`, and caches results with in-flight deduplication.

Key behaviors:

  • Per-task scoping: Uses task metadata (owner, status, intervals) to determine which commits/changes belong to the task.
  • In-flight deduplication: For summary-only requests (not force-fresh, not retry-backfill), maintains an in-flight map keyed by team+task+options to prevent duplicate extractions.
  • Summary vs. full mode: `summaryOnly: true` returns just file-level metadata without hunk content; `summaryOnly: false` (default) returns full diff hunks.
  • Force fresh: `forceFresh: true` bypasses the cache entirely.
  • Retry backfill: `retryBackfill: true` retries extraction for tasks with partial previous results.
  • State bucket awareness: Uses task review state, history events, and kanban column to select the correct change state bucket.

Usage

  • Change review UI: Call with `summaryOnly: true` for the initial file list, then call with `summaryOnly: false` for a specific file's hunk content.
  • Force refresh: Pass `forceFresh: true` when the worktree has changed and cached results are stale.
  • Partial recovery: Pass `retryBackfill: true` when a previous extraction produced partial results.

Code Reference

Source Location

  • Repository: agent-teams
  • File: src/main/services/team/ChangeExtractorService.ts

Signature

export interface TaskChangeRequestOptions {
  summaryOnly?: boolean;
  forceFresh?: boolean;
  retryBackfill?: boolean;
  owner?: string;
  status?: string;
  intervals?: unknown;
  since?: string;
}

export class ChangeExtractorService {
  async getTaskChanges(
    teamName: string,
    taskId: string,
    options?: TaskChangeRequestOptions
  ): Promise<TaskChangeSetV2>;
}

Import

import { ChangeExtractorService } from '@main/services/team/ChangeExtractorService';

I/O Contract

Inputs

Name Type Required Description
teamName string Yes Team identifier
taskId string Yes Task to extract changes for
options.summaryOnly boolean No If true, return file-level metadata only (no hunk content)
options.forceFresh boolean No Bypass cache and recompute from worktree
options.retryBackfill boolean No Retry extraction for partial previous results
options.owner string No Override task owner for scoping
options.status string No Override task status for scoping
options.since string No Time boundary for change scoping

Outputs

Name Type Description
return Promise<TaskChangeSetV2> Structured change set
TaskChangeSetV2.files FileChange[] Array of changed files with paths and diff snippets
TaskChangeSetV2.warnings string[] Extraction warnings
TaskChangeSetV2.confidence string Confidence level of the extraction

Usage Examples

Extracting Summary Changes for UI

import { ChangeExtractorService } from '@main/services/team/ChangeExtractorService';

const service = new ChangeExtractorService();

// Get file-level summary (fast, no hunk content)
const summary = await service.getTaskChanges('my-team', 'task-123', {
  summaryOnly: true,
});

console.log(`Changed files: ${summary.files.length}`);
for (const file of summary.files) {
  console.log(`  ${file.filePath} (+${file.addedLines} -${file.removedLines})`);
}

Extracting Full Diff for a File

// Get full hunk content for detailed review
const fullChanges = await service.getTaskChanges('my-team', 'task-123', {
  summaryOnly: false,
});

const targetFile = fullChanges.files.find(
  (f) => f.filePath === 'src/auth/login.ts'
);
// targetFile.snippets contains before/after hunk content

Force Fresh Extraction

// After the agent has made new edits, force a fresh extraction
const fresh = await service.getTaskChanges('my-team', 'task-123', {
  forceFresh: true,
});

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment