-
Notifications
You must be signed in to change notification settings - Fork 68
feat: natural language parsing and multi-instance for /consult #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,56 +1,79 @@ | ||||||||||
| <!-- AUTO-GENERATED by scripts/gen-adapters.js - DO NOT EDIT --> | ||||||||||
| --- | ||||||||||
| name: consult | ||||||||||
| description: "Use when user asks to \"consult gemini\", \"ask codex\", \"get second opinion\", \"cross-check with claude\", \"consult another AI\", \"ask opencode\", \"copilot opinion\". Queries another AI CLI tool and returns the response." | ||||||||||
| description: "Use when user asks to \"consult gemini\", \"ask codex\", \"get second opinion\", \"cross-check with claude\", \"consult another AI\", \"ask opencode\", \"copilot opinion\", \"ask 3 codex\", \"multi-consult\". Queries another AI CLI tool and returns the response." | ||||||||||
| --- | ||||||||||
|
|
||||||||||
| # /consult - Cross-Tool AI Consultation | ||||||||||
|
|
||||||||||
| You are executing the /consult command. Your job is to consult another AI CLI tool, get its response, and present the results to the user. | ||||||||||
| You are executing the /consult command. Your job is to parse the user's request (natural language or flags), resolve missing parameters interactively, and execute the consultation. | ||||||||||
|
|
||||||||||
| ## Constraints | ||||||||||
|
|
||||||||||
| - NEVER expose API keys in commands or output | ||||||||||
| - NEVER run with permission-bypassing flags (`--dangerously-skip-permissions`, `bypassPermissions`) | ||||||||||
| - MUST use safe-mode defaults (`-a suggest` for Codex, `--allowedTools "Read,Glob,Grep"` for Claude) | ||||||||||
| - MUST enforce 120s timeout on all tool executions | ||||||||||
| - MUST validate `--tool` against allow-list: gemini, codex, claude, opencode, copilot (reject all others) | ||||||||||
| - MUST validate tool names against allow-list: gemini, codex, claude, opencode, copilot (reject all others) | ||||||||||
| - MUST validate `--context=file=PATH` is within the project directory (reject absolute paths outside cwd) | ||||||||||
| - MUST quote all user-provided values in shell commands to prevent injection | ||||||||||
| - NEVER execute tools the user has not explicitly requested | ||||||||||
|
|
||||||||||
| ## Arguments | ||||||||||
| ## Execution | ||||||||||
|
|
||||||||||
| Parse from $ARGUMENTS: | ||||||||||
| ### Phase 1: Parse Input (Flags + Natural Language) | ||||||||||
|
|
||||||||||
| - **question**: What to ask the consulted tool (required unless --continue) | ||||||||||
| - **--tool**: Target tool: `gemini`, `codex`, `claude`, `opencode`, `copilot` (interactive picker if omitted) | ||||||||||
| - **--effort**: Thinking effort: `low`, `medium`, `high`, `max` (interactive picker if omitted) | ||||||||||
| - **--model**: Specific model name (interactive picker if omitted). Free text. | ||||||||||
| - **--context**: Auto-include context: `diff` (git diff), `file=PATH` (attach specific file), `none` (default) | ||||||||||
| - **--continue**: Continue last consultation session, or `--continue=SESSION_ID` for specific session | ||||||||||
| Parse `$ARGUMENTS` using both explicit flags and natural language extraction. Flags always take priority over NLP when both provide the same parameter. | ||||||||||
|
|
||||||||||
| ## Execution | ||||||||||
| #### Step 1a: Extract explicit flags | ||||||||||
|
|
||||||||||
| Look for and remove these flags from `$ARGUMENTS`: | ||||||||||
|
|
||||||||||
| 1. `--tool=VALUE` or `--tool VALUE` where VALUE is one of: gemini, codex, claude, opencode, copilot | ||||||||||
| 2. `--effort=VALUE` or `--effort VALUE` where VALUE is one of: low, medium, high, max | ||||||||||
| 3. `--model=VALUE` or `--model VALUE` (any string, including quoted) | ||||||||||
| 4. `--context=VALUE` where VALUE is: diff, file=PATH, or none | ||||||||||
| 5. `--continue` (optionally `--continue=SESSION_ID`) | ||||||||||
| 6. `--count=N` where N is 1-5 | ||||||||||
|
|
||||||||||
| Remove all matched flags and their values from `$ARGUMENTS`. | ||||||||||
|
|
||||||||||
| #### Step 1b: Natural language extraction (on remaining text) | ||||||||||
|
|
||||||||||
| ### Phase 1: Parse Arguments | ||||||||||
| After removing flags, parse the remaining text for these patterns: | ||||||||||
|
|
||||||||||
| Extract these values from `$ARGUMENTS`: | ||||||||||
| **Tool extraction** (case-insensitive): | ||||||||||
| - "with {tool}" (e.g., "with codex") -> tool | ||||||||||
| - "ask {tool}" (e.g., "ask gemini") -> tool | ||||||||||
| - "consult {tool}" -> tool | ||||||||||
| - "{tool} about" (e.g., "codex about") -> tool | ||||||||||
| - Tool names: claude, gemini, codex, opencode, copilot | ||||||||||
|
|
||||||||||
| 1. Look for `--tool=VALUE` or `--tool VALUE` where VALUE MUST be one of: gemini, codex, claude, opencode, copilot (reject others) | ||||||||||
| 2. Look for `--effort=VALUE` or `--effort VALUE` where VALUE MUST be one of: low, medium, high, max | ||||||||||
| 3. Look for `--model=VALUE` or `--model VALUE` (any string, including quoted strings like `"my model"`) | ||||||||||
| 4. Look for `--context=VALUE` where VALUE is: diff, file=PATH, or none | ||||||||||
| 5. Look for `--continue` (optionally `--continue=SESSION_ID`) | ||||||||||
| 6. Remove all matched flags (including their values) from `$ARGUMENTS`. Handle quoted flag values (e.g., `--model "gpt 4"`) by removing the entire quoted string. Everything remaining is the **question**. | ||||||||||
| **Count extraction**: | ||||||||||
| - "ask {N} {tool}" (e.g., "ask 3 codex") -> count=N, tool | ||||||||||
| - "{N} {tool}" (e.g., "3 codex") -> count=N, tool | ||||||||||
| - "{N} instances" -> count=N | ||||||||||
| - "few instances" / "multiple" / "several" -> count=ambiguous (ask user in Phase 2) | ||||||||||
|
||||||||||
| - "few instances" / "multiple" / "several" -> count=ambiguous (ask user in Phase 2) | |
| - "few instances" / "multiple" / "several" -> count=ambiguous (ask user in Phase 2) | |
| - After extracting any numeric `{N}` above, immediately validate that `N` is an integer between 1 and 5 (inclusive). | |
| - If `N < 1` or `N > 5`, do **not** treat it as a valid count: clear the count value, keep any other extracted parameters (like tool and question), and in Phase 2 ask the user to choose a count between 1 and 5 (or apply a safe default like 3 if the user declines to choose). |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Instances picker only offers options 1, 2, and 3, but the specification allows counts from 1-5. Users who want 4 or 5 parallel consultations would have no way to select these values through the interactive picker. Either add options for "4 (Extensive)" and "5 (Maximum)" to the picker, or add an "Other" option that allows custom input (with validation).
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Codex adapter requires unique id fields for each question in request_user_input (as noted in the comment on line 107), but the example doesn't actually show the id fields. For Codex compatibility, each question block should include an explicit id field like id: "tool_select", id: "effort_select", and id: "instances_select". Without these, the Codex platform may reject or mishandle the user input request.
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Codex adapter documentation notes that "Each question MUST include a unique id field (e.g., id: \"q1\")," but the example questions below don't include any id fields. Add id fields to each question in the request_user_input examples (e.g., "id: "tool"", "id: "effort"", "id: "instances"") to match the stated requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The count parameter validation is mentioned in Step 1a but there's no actual validation logic in the parsing phase. The command should validate that N is between 1-5 when extracting the --count flag or parsing NLP count patterns, and immediately reject out-of-range values with the error message from the error table. Currently, the validation would only happen later when the error is displayed, but it's unclear where the actual check occurs.