anthropics / anthropics/claude-code-action

Add capability to keep generated files out of the context window

Aperta
#431 1 commento 2 reazioni 0 assegnatari Vedi su GitHub
enhancement p3
Lingua principale
TypeScript
Stelle
8.9k
Fork
2.1k
Merge medio
3g 9h
PR unite (30g)
10

Descrizione

# Problem

The AI currently receives all changed files in its context, including generated files marked with linguist-generated=true in .gitattributes. This leads to:

- Unnecessary token consumption from generated files (e.g., **/go/**/*.generated.go)
- Reduced context space for human-authored code
- AI potentially analyzing/reviewing generated code that shouldn't be modified

# Current Behavior

The formatChangedFilesWithSHA function in src/github/data/formatter.ts processes all files without filtering:

```
export function formatChangedFilesWithSHA(
changedFiles: GitHubFileWithSHA[],
): string {
return changedFiles
.map(
(file) =>
`- ${file.path} (${file.changeType}) +${file.additions}/-${file.deletions} SHA: ${file.sha}`,
)
.join("\n");
}
```

# Proposed Solution

Add filtering to exclude files marked as generated in .gitattributes before formatting. This could be implemented by:

1. Option A: Parse .gitattributes and filter files with linguist-generated=true
2. Option B: Use GitHub's Linguist API data if available
3. Option C: Add a configuration option to specify file patterns to exclude

Example .gitattributes patterns that should be filtered:

```
*.generated.go linguist-generated=true
**/dist/** linguist-generated=true
**/build/** linguist-generated=true
*.min.js linguist-generated=true
```

Expected Outcome

- Reduced token usage in AI prompts
- AI focuses on human-authored code for reviews and analysis
- More efficient use of context window
- Optional: Configuration to override this behavior when generated file analysis is needed

Implementation Areas

- src/github/data/formatter.ts - Add filtering logic
- src/github/data/fetcher.ts - Filter earlier in the pipeline
- Consider adding user configuration option for this feature

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.