get_changed_files
List files changed since a specified git base to understand the scope of recent modifications.
Instructions
List files changed since a base ref (default: HEAD~1). Useful to understand scope of recent changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| base | No |
Implementation Reference
- src/access/GitAccess.ts:57-87 (handler)The core implementation: runs `git diff --name-status <base> HEAD` and parses output into ChangedFile objects with path and status (added, modified, deleted, renamed). Defaults base to 'HEAD~1'.
async function getChangedFiles(repoDir: string, base?: string): Promise<ChangedFile[]> { const ref = base ?? 'HEAD~1'; const { stdout } = await execFileAsync('git', [ '-C', repoDir, 'diff', '--name-status', ref, 'HEAD', ]); return stdout .trim() .split('\n') .filter(Boolean) .map((line) => { const [rawStatus, ...parts] = line.split('\t'); const path = parts[parts.length - 1] ?? ''; const statusChar = (rawStatus ?? '')[0] ?? 'M'; const statusMap: Record<string, ChangedFile['status']> = { A: 'added', M: 'modified', D: 'deleted', R: 'renamed', }; return { path, status: statusMap[statusChar] ?? 'modified', }; }); } - src/managers/BranchManager.ts:20-26 (handler)Manager layer that combines git.getBranchContext and git.getChangedFiles in parallel, returning both context and changed files.
async function getChangedFiles(base?: string): Promise<BranchManagerResult> { const [context, changedFiles] = await Promise.all([ git.getBranchContext(repoDir), git.getChangedFiles(repoDir, base), ]); return { context, changedFiles }; } - src/tools/branch.tool.ts:19-24 (handler)MCP tool handler that registers 'get_changed_files' via server.tool, calls manager.getChangedFiles(args.base), and returns JSON-stringified result.
server.tool('get_changed_files', 'List files changed since a base ref (default: HEAD~1). Useful to understand scope of recent changes.', GetChangedFilesSchema.shape, async (args) => { const result = await manager.getChangedFiles(args.base); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; }); - src/tools/branch.tool.ts:7-9 (schema)Zod schema defining optional 'base' string parameter (defaults to HEAD~1).
export const GetChangedFilesSchema = z.object({ base: z.string().optional(), }); - src/access/GitAccess.ts:13-16 (helper)ChangedFile interface with path and status type (added/modified/deleted/renamed).
export interface ChangedFile { path: string; status: 'added' | 'modified' | 'deleted' | 'renamed'; }