@@ -2,41 +2,14 @@ import type { Hooks } from "@opencode-ai/plugin"
22import { log } from "../../shared/logger"
33import { readState } from "../boulder-loop/storage"
44
5- export const HOOK_NAME = "boulder-question-auto-answer"
6-
7- interface QuestionOption {
8- label : string
9- description ?: string
10- }
11-
12- interface QuestionInput {
13- questions ?: Array < {
14- question : string
15- header ?: string
16- options ?: QuestionOption [ ]
17- multiple ?: boolean
18- } >
19- }
20-
21- function findRecommendedOrFirst ( options : QuestionOption [ ] ) : string {
22- const recommended = options . find ( opt =>
23- opt . label . toLowerCase ( ) . includes ( "(recommended)" )
24- )
25- return recommended ?. label ?? options [ 0 ] ?. label ?? "Option 1"
26- }
27-
28- function autoAnswerQuestions ( input : QuestionInput ) : string [ ] {
29- return ( input . questions ?? [ ] ) . map ( q =>
30- q . options ?. length ? findRecommendedOrFirst ( q . options ) : "Continue autonomously"
31- )
32- }
5+ export const HOOK_NAME = "boulder-question-skipper"
336
347export function createBoulderQuestionAutoAnswerHook (
358 directory : string ,
369 stateDir ?: string
3710) : Hooks {
3811 return {
39- "tool.execute.before" : async ( input , output ) => {
12+ "tool.execute.before" : async ( input ) => {
4013 const toolName = input . tool ?. toLowerCase ( )
4114 if ( toolName !== "question" && toolName !== "askuserquestion" ) {
4215 return
@@ -47,18 +20,12 @@ export function createBoulderQuestionAutoAnswerHook(
4720 return
4821 }
4922
50- const params = output ?. args as QuestionInput | undefined
51- const answers = autoAnswerQuestions ( params ?? { } )
52-
53- log ( `[${ HOOK_NAME } ] Auto-answering question in Boulder mode` , {
23+ log ( `[${ HOOK_NAME } ] Skipping question in Boulder mode` , {
5424 sessionID : input . sessionID ,
55- answers,
5625 timeRemaining : state . deadline - Date . now ( ) ,
5726 } )
5827
59- throw new Error (
60- `[BOULDER MODE] Question auto-answered: ${ answers . join ( ", " ) } `
61- )
28+ throw new Error ( "[BOULDER MODE] Question skipped. Decide autonomously." )
6229 } ,
6330 }
6431}
0 commit comments