From 489aa49663ea86ea83b66b52498ded6028e77f5b Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:40:05 +0530 Subject: [PATCH] add quiz tool --- extensions/cli/src/tools/allBuiltIns.ts | 2 + extensions/cli/src/tools/askQuestion.ts | 65 +++++++++++++++++++++++++ extensions/cli/src/tools/index.tsx | 2 + 3 files changed, 69 insertions(+) create mode 100644 extensions/cli/src/tools/askQuestion.ts diff --git a/extensions/cli/src/tools/allBuiltIns.ts b/extensions/cli/src/tools/allBuiltIns.ts index c5d054e6f..a7a501c71 100644 --- a/extensions/cli/src/tools/allBuiltIns.ts +++ b/extensions/cli/src/tools/allBuiltIns.ts @@ -1,5 +1,6 @@ import { SUBAGENT_TOOL_META } from "../subagent/index.js"; +import { askQuestionTool } from "./askQuestion.js"; import { editTool } from "./edit.js"; import { exitTool } from "./exit.js"; import { fetchTool } from "./fetch.js"; @@ -18,6 +19,7 @@ import { writeFileTool } from "./writeFile.js"; // putting in here for circular import issue export const ALL_BUILT_IN_TOOLS = [ + askQuestionTool, editTool, exitTool, fetchTool, diff --git a/extensions/cli/src/tools/askQuestion.ts b/extensions/cli/src/tools/askQuestion.ts new file mode 100644 index 000000000..0dd840665 --- /dev/null +++ b/extensions/cli/src/tools/askQuestion.ts @@ -0,0 +1,65 @@ +import { quizService } from "../quiz/index.js"; + +import { Tool } from "./types.js"; + +export const askQuestionTool: Tool = { + name: "AskQuestion", + displayName: "Ask Question", + description: + "Ask the user a clarifying question to gather requirements, preferences, or implementation details before proceeding. Use this when you need user input to make a decision.", + parameters: { + type: "object", + required: ["question"], + properties: { + question: { + type: "string", + description: "The question to ask the user", + }, + options: { + type: "array", + description: + "Optional list of choices. If provided, user selects one. If omitted, user types a free-form answer.", + items: { + type: "string", + }, + }, + allowCustomAnswer: { + type: "boolean", + description: + "If true and options are provided, user can also type a custom answer instead of selecting from options", + }, + defaultAnswer: { + type: "string", + description: + "Default answer if user presses Enter without providing input", + }, + }, + }, + readonly: true, + isBuiltIn: true, + run: async (args: { + question: string; + options?: string[]; + allowCustomAnswer?: boolean; + defaultAnswer?: string; + }): Promise => { + const { question, options, allowCustomAnswer, defaultAnswer } = args; + + const answer = await quizService.askQuestion({ + question, + options, + allowCustomAnswer, + defaultAnswer, + }); + + if (options && options.length > 0) { + const selectedIndex = options.indexOf(answer); + if (selectedIndex !== -1) { + return `User selected option ${selectedIndex + 1}: "${answer}"`; + } + return `User provided custom answer: "${answer}"`; + } + + return `User answered: "${answer}"`; + }, +}; diff --git a/extensions/cli/src/tools/index.tsx b/extensions/cli/src/tools/index.tsx index eb10d870d..fb43739f8 100644 --- a/extensions/cli/src/tools/index.tsx +++ b/extensions/cli/src/tools/index.tsx @@ -19,6 +19,7 @@ import { telemetryService } from "../telemetry/telemetryService.js"; import { logger } from "../util/logger.js"; import { ALL_BUILT_IN_TOOLS } from "./allBuiltIns.js"; +import { askQuestionTool } from "./askQuestion.js"; import { checkBackgroundJobTool } from "./checkBackgroundJob.js"; import { editTool } from "./edit.js"; import { exitTool } from "./exit.js"; @@ -70,6 +71,7 @@ const BASE_BUILTIN_TOOLS: Tool[] = [ fetchTool, writeChecklistTool, checkBackgroundJobTool, + askQuestionTool, ]; const BUILTIN_SEARCH_TOOLS: Tool[] = [searchCodeTool];