@@ -15,6 +15,8 @@ const EVENT_NAME = process.env.GITHUB_EVENT_NAME || '';
1515const GITHUB_TOKEN = process . env . GITHUB_TOKEN || '' ;
1616const ANTHROPIC_API_KEY = process . env . ANTHROPIC_API_KEY || '' ;
1717const 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
1921export 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> {
126152export 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