diff --git a/docs/cli/plan-mode.md b/docs/cli/plan-mode.md index 6c855157558..751794996b2 100644 --- a/docs/cli/plan-mode.md +++ b/docs/cli/plan-mode.md @@ -68,7 +68,7 @@ You can enter Plan Mode in three ways: ### The Planning Workflow -1. **Requirements:** The agent clarifies goals using `ask_user`. +1. **Requirements:** The agent clarifies goals using [`ask_user`]. 2. **Exploration:** The agent uses read-only tools (like [`read_file`]) to map the codebase and validate assumptions. 3. **Design:** The agent proposes alternative approaches with a recommended @@ -95,7 +95,7 @@ These are the only allowed tools: - **FileSystem (Read):** [`read_file`], [`list_directory`], [`glob`] - **Search:** [`grep_search`], [`google_web_search`] -- **Interaction:** `ask_user` +- **Interaction:** [`ask_user`] - **MCP Tools (Read):** Read-only [MCP tools] (e.g., `github_read_issue`, `postgres_read_schema`) are allowed. - **Planning (Write):** [`write_file`] and [`replace`] ONLY allowed for `.md` @@ -183,3 +183,4 @@ Guide]. [Policy Engine Guide]: /docs/core/policy-engine.md [`enter_plan_mode`]: /docs/tools/planning.md#1-enter_plan_mode-enterplanmode [`exit_plan_mode`]: /docs/tools/planning.md#2-exit_plan_mode-exitplanmode +[`ask_user`]: /docs/tools/ask-user.md diff --git a/docs/tools/ask-user.md b/docs/tools/ask-user.md new file mode 100644 index 00000000000..ad6c3b5a063 --- /dev/null +++ b/docs/tools/ask-user.md @@ -0,0 +1,95 @@ +# Ask User Tool + +The `ask_user` tool allows the agent to ask you one or more questions to gather +preferences, clarify requirements, or make decisions. It supports multiple +question types including multiple-choice, free-form text, and Yes/No +confirmation. + +## `ask_user` (Ask User) + +- **Tool name:** `ask_user` +- **Display name:** Ask User +- **File:** `ask-user.ts` +- **Parameters:** + - `questions` (array of objects, required): A list of 1 to 4 questions to ask. + Each question object has the following properties: + - `question` (string, required): The complete question text. + - `header` (string, required): A short label (max 16 chars) displayed as a + chip/tag (e.g., "Auth", "Database"). + - `type` (string, optional): The type of question. Defaults to `'choice'`. + - `'choice'`: Multiple-choice with options (supports multi-select). + - `'text'`: Free-form text input. + - `'yesno'`: Yes/No confirmation. + - `options` (array of objects, optional): Required for `'choice'` type. 2-4 + selectable options. + - `label` (string, required): Display text (1-5 words). + - `description` (string, required): Brief explanation. + - `multiSelect` (boolean, optional): For `'choice'` type, allows selecting + multiple options. + - `placeholder` (string, optional): Hint text for input fields. + +- **Behavior:** + - Presents an interactive dialog to the user with the specified questions. + - Pauses execution until the user provides answers or dismisses the dialog. + - Returns the user's answers to the model. + +- **Output (`llmContent`):** A JSON string containing the user's answers, + indexed by question position (e.g., + `{"answers":{"0": "Option A", "1": "Some text"}}`). + +- **Confirmation:** Yes. The tool inherently involves user interaction. + +## Usage Examples + +### Multiple Choice Question + +```json +{ + "questions": [ + { + "header": "Database", + "question": "Which database would you like to use?", + "type": "choice", + "options": [ + { + "label": "PostgreSQL", + "description": "Powerful, open source object-relational database system." + }, + { + "label": "SQLite", + "description": "C-library that implements a SQL database engine." + } + ] + } + ] +} +``` + +### Text Input Question + +```json +{ + "questions": [ + { + "header": "Project Name", + "question": "What is the name of your new project?", + "type": "text", + "placeholder": "e.g., my-awesome-app" + } + ] +} +``` + +### Yes/No Question + +```json +{ + "questions": [ + { + "header": "Deploy", + "question": "Do you want to deploy the application now?", + "type": "yesno" + } + ] +} +``` diff --git a/docs/tools/index.md b/docs/tools/index.md index ff594056ace..c7b2c1fc725 100644 --- a/docs/tools/index.md +++ b/docs/tools/index.md @@ -87,6 +87,8 @@ Gemini CLI's built-in tools can be broadly categorized as follows: - **[Todo Tool](./todos.md) (`write_todos`):** For managing subtasks of complex requests. - **[Planning Tools](./planning.md):** For entering and exiting Plan Mode. +- **[Ask User Tool](./ask-user.md) (`ask_user`):** For gathering user input and + making decisions. Additionally, these tools incorporate: