add quiz tool
This commit is contained in:
parent
98c99d3a63
commit
489aa49663
3 changed files with 69 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
65
extensions/cli/src/tools/askQuestion.ts
Normal file
65
extensions/cli/src/tools/askQuestion.ts
Normal file
|
|
@ -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<string> => {
|
||||
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}"`;
|
||||
},
|
||||
};
|
||||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue