Skip to content

Commit be2fe94

Browse files
committed
feat(ci): pass context_files into assess and include in Claude prompt
- Add CONTEXT_FILES and GITHUB_WORKSPACE to assess step env - Load repo files (AGENTS.md, REFERENCE.md, etc.) and append to assessment prompt - Skip missing files; REPO_ROOT from GITHUB_WORKSPACE or cwd for local runs Made-with: Cursor
1 parent fa931ca commit be2fe94

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

.github/actions/issue-auto-implement/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ runs:
7777
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
7878
GITHUB_TOKEN: ${{ inputs.github_token }}
7979
GITHUB_REPOSITORY: ${{ github.repository }}
80+
GITHUB_WORKSPACE: ${{ github.workspace }}
8081
ASSESSMENT_REFERENCE_ISSUE: ${{ inputs.assessment_reference_issue }}
82+
CONTEXT_FILES: ${{ inputs.context_files }}
8183
run: |
8284
RESULT=$(cd .github/actions/issue-auto-implement/assess && npx tsx index.ts)
8385
echo "action=$(echo "$RESULT" | jq -r '.action')" >> $GITHUB_OUTPUT

.github/actions/issue-auto-implement/assess/index.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const EVENT_NAME = process.env.GITHUB_EVENT_NAME || '';
1515
const GITHUB_TOKEN = process.env.GITHUB_TOKEN || '';
1616
const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || '';
1717
const REPO = process.env.GITHUB_REPOSITORY || '';
18+
const CONTEXT_FILES = process.env.CONTEXT_FILES || '';
19+
const REPO_ROOT = process.env.GITHUB_WORKSPACE || resolve(process.cwd(), '../../..');
1820

1921
export type AssessmentOutput = {
2022
action: 'implement' | 'request_info' | 'redirect_to_pr';
@@ -57,7 +59,28 @@ function inferEventName(payload: unknown): string {
5759
return '';
5860
}
5961

60-
function buildAssessmentPrompt(payload: unknown, eventName: string, referenceIssue: string): string {
62+
function loadContextFiles(): string {
63+
if (!CONTEXT_FILES.trim()) return '';
64+
const paths = CONTEXT_FILES.split(',').map((s) => s.trim()).filter(Boolean);
65+
const chunks: string[] = [];
66+
for (const rel of paths) {
67+
try {
68+
const full = resolve(REPO_ROOT, rel);
69+
const content = readFileSync(full, 'utf-8');
70+
chunks.push(`--- ${rel} ---\n${content}`);
71+
} catch {
72+
// Skip missing files (e.g. REFERENCE.md may not exist in all repos)
73+
}
74+
}
75+
return chunks.length ? ['Repository context:', '', ...chunks].join('\n') : '';
76+
}
77+
78+
function buildAssessmentPrompt(
79+
payload: unknown,
80+
eventName: string,
81+
referenceIssue: string,
82+
contextBlock: string
83+
): string {
6184
const p = payload as Record<string, unknown>;
6285
const issue = p.issue as { title?: string; body?: string; number?: number } | undefined;
6386
const parts: string[] = [
@@ -73,6 +96,9 @@ function buildAssessmentPrompt(payload: unknown, eventName: string, referenceIss
7396
'',
7497
`Reference example of "enough information": GitHub issue #${referenceIssue} (use similar clarity and specificity).`,
7598
];
99+
if (contextBlock) {
100+
parts.push('', contextBlock);
101+
}
76102

77103
const comment = p.comment as { body?: string } | undefined;
78104
if (comment?.body) {
@@ -126,7 +152,13 @@ async function main(): Promise<void> {
126152
export async function assess(
127153
eventName: string,
128154
payload: unknown,
129-
opts: { repo?: string; token?: string; referenceIssue?: string; anthropicClient?: Anthropic }
155+
opts: {
156+
repo?: string;
157+
token?: string;
158+
referenceIssue?: string;
159+
anthropicClient?: Anthropic;
160+
contextFilesContent?: string;
161+
}
130162
): Promise<AssessmentOutput> {
131163
const normalized = normalizeEvent(eventName, payload);
132164
if (!normalized) throw new Error('Could not normalize event');
@@ -140,7 +172,8 @@ export async function assess(
140172
}
141173

142174
const referenceIssue = opts.referenceIssue ?? '192';
143-
const prompt = buildAssessmentPrompt(payload, eventName, referenceIssue);
175+
const contextBlock = opts.contextFilesContent ?? loadContextFiles();
176+
const prompt = buildAssessmentPrompt(payload, eventName, referenceIssue, contextBlock);
144177
const result = await callClaude(prompt, opts.anthropicClient);
145178
result.issue_number = normalized.issueNumber;
146179
return result;

0 commit comments

Comments
 (0)