Read PR details and linked issues.
UnderstandAnalyzed code diffs and relevant files.
UnderstandChecked specific code usage in interactive mode.
VerifyMerged PR into main branch with changelog updates.
EditYou are given one or more GitHub PR URLs: https://github.com/badlogic/pi-mono/pull/775
For each PR URL, do the following in order:
packages/*/CHANGELOG.md files. Report whether an entry exists. If missing, state that a changelog entry is required before merge and that you will add it if the user decides to merge. Follow the changelog format rules in AGENTS.md. Verify:
### Breaking Changes, ### Added, ### Fixed, etc.)Fixed foo ([#123](https://github.com/badlogic/pi-mono/pull/123) by [@user](https://github.com/user))### Breaking Changes, not just ### FixedOutput format per PR: PR: Changelog:
If no issues are found, say so under Bad and Ugly.
The user wants me to review a GitHub PR. Let me start by fetching the PR details including description, comments, commits, and changed files.
>cd /Users/badlogic/workspaces/pi-mono && gh pr view 775 --json title,body,comments,author,state,commits,files,labels,baseRefName,headRefName>cd /Users/badlogic/workspaces/pi-mono && gh pr diff 775Now let me read the relevant source files to fully understand the changes and validate the implementation. I need to read:
Let me also check for any linked issues (none mentioned in the PR body) and read the full context.
Let me read the relevant source files to validate the implementation:
Let me read more of the interactive-mode.ts to see where the autocomplete is actually wired up for extension commands. I saw that extensions are mapped in setupAutocomplete, but I need to see if getArgumentCompletions is used.
Let me check how the autocomplete is used in interactive-mode.ts, specifically looking for how argument completions are handled:
>cd /Users/badlogic/workspaces/pi-mono && grep -n "getArgumentCompletions\|ArgumentCompletion" packages/coding-agent/src/modes/interactive/interactive-mode.ts>cd /Users/badlogic/workspaces/pi-mono && grep -n "getArgumentCompletions\|ArgumentCompletion" packages/tui/src -rNow let me read the autocomplete.ts from pi-tui to understand how argument completions work, to confirm that the PR implementation is correct.
Now I understand the implementation. Let me check the CHANGELOG to see if the entry exists and follows the proper format. Let me also check if there are any tests for this functionality.
Let me check the CHANGELOG entry and look for any related tests:
>cd /Users/badlogic/workspaces/pi-mono && grep -rn "getArgumentCompletions\|argument.*completion" packages/coding-agent/test --include="*.ts" 2>/dev/null | head -20>cd /Users/badlogic/workspaces/pi-mono && npm run check 2>&1 | head -100Let me check if there are any tests related to autocomplete in pi-tui and if they should test getArgumentCompletions. Also, let me check the RegisteredCommand interface again to make sure the change is complete.
Looking at the PR:
types.ts - Added getArgumentCompletions?: (argumentPrefix: string) => AutocompleteItem[] | null; to RegisteredCommand interface and updated registerCommand signatureloader.ts - Changed the type annotation from inline to Omit<RegisteredCommand, "name">interactive-mode.ts - Added getArgumentCompletions: cmd.getArgumentCompletions when mapping extension commands to SlashCommand formatdocs/extensions.md - Added documentation for the new featureCHANGELOG.md - Added a changelog entry but it's in the wrong placeWait, looking at the CHANGELOG, I don't see the entry from the PR. Let me re-check the diff. The diff shows:
+- Extension commands can provide argument auto-completions via `getArgumentCompletions` in `pi.registerCommand()`.But this entry is placed after the input event entry, which is correct. It's in the Added section under [Unreleased]. Let me verify this is the correct placement.
Actually, looking at the diff more closely:
Now let me check if the CHANGELOG entry follows the proper format:
Fixed foo ([#123](https://github.com/badlogic/pi-mono/pull/123) by [@user](https://github.com/user))The entry is: - Extension commands can provide argument auto-completions via \getArgumentCompletions` in `pi.registerCommand()`.`
The CHANGELOG entry is missing the PR link and author attribution. Since this is from @ribelo, it should include ([#775](https://github.com/badlogic/pi-mono/pull/775) by [@ribelo](https://github.com/ribelo)). I should also check if the README.md needs updates for this new extension API feature.
Let me check if the README needs updates and verify the full documentation:
>cd /Users/badlogic/workspaces/pi-mono && grep -n "registerCommand\|getArgumentCompletions" packages/coding-agent/README.md>cd /Users/badlogic/workspaces/pi-mono && ls -la packages/tui/src/index.ts && grep -n "AutocompleteItem" packages/tui/src/index.tsThe AutocompleteItem type is exported from pi-tui, so extensions can import it. The documentation example in extensions.md correctly shows importing it:
import type { AutocompleteItem } from "@mariozechner/pi-tui";Now let me summarize what I found:
Good:
SlashCommand interface from pi-tui which already has getArgumentCompletionsOmit<RegisteredCommand, "name">Bad:
Ugly:
The implementation correctly threads the getArgumentCompletions callback through:
getArgumentCompletions via registerCommand()loader.ts stores it in extension.commandsinteractive-mode.ts retrieves commands and maps them to SlashCommand format with getArgumentCompletionsCombinedAutocompleteProvider in pi-tui handles the restThis is a well-designed minimal change that exposes existing functionality to extensions.
Now let me verify if there are any issues in the types or if the import in the documentation example is correct:
Good, AutocompleteItem is exported from pi-tui. The documentation example is correct.
Now let me provide the final review.
PR: https://github.com/badlogic/pi-mono/pull/775
Changelog:
## [Unreleased] → ### Added sectionFixed foo ([#123](https://github.com/badlogic/pi-mono/pull/123) by [@user](https://github.com/user))- Extension commands can provide argument auto-completions via \getArgumentCompletions` in `pi.registerCommand()`.`- Extension commands can provide argument auto-completions via \getArgumentCompletions` in `pi.registerCommand()` (#775 by @ribelo)`Good:
SlashCommand.getArgumentCompletions interface from pi-tui rather than reinventingOmit<RegisteredCommand, "name">AutocompleteItem from @mariozechner/pi-tuiregisterCommand() → loader.ts storage → interactive-mode.ts mapping → CombinedAutocompleteProvidernpm run check clean)Bad:
CombinedAutocompleteProvider logic, but no extension-specific test verifies the wiring)Ugly:
Questions or Assumptions:
/model argument completion mechanism to extensions.Change summary:
types.ts: Added optional getArgumentCompletions to RegisteredCommand interfaceloader.ts: Changed registerCommand type to Omit<RegisteredCommand, "name"> to include the new callbackinteractive-mode.ts: Maps cmd.getArgumentCompletions when converting extension commands to SlashCommand format for autocompletedocs/extensions.md: Added documentation with working exampleCHANGELOG.md: Added entry (needs fix)Tests:
packages/tui/src/autocomplete.ts.Documentation check (packages/coding-agent):
README.md: No update needed (extension API examples use registerCommand but argument completion is an advanced feature documented in docs/extensions.md)docs/extensions.md: ✓ Updated with exampleexamples/**/*.md: No update needed (no markdown examples affected)i don't see where getArgumentCompletions is actually called?
The user is asking where getArgumentCompletions is actually called. Let me trace through the code again.
getArgumentCompletions via pi.registerCommand()loader.ts stores it in extension.commandsinteractive-mode.ts retrieves commands via getRegisteredCommands() and maps them to SlashCommand format, including getArgumentCompletionsCombinedAutocompleteProvider in setupAutocomplete()The actual call to getArgumentCompletions happens in CombinedAutocompleteProvider.getSuggestions() in packages/tui/src/autocomplete.ts at line 159-163:
if (!command || !("getArgumentCompletions" in command) || !command.getArgumentCompletions) { return null; // No argument completion for this command}
const argumentSuggestions = command.getArgumentCompletions(argumentText);So the call chain is:
/deploy (with space)CombinedAutocompleteProvider.getSuggestions() is called/command with space)command.getArgumentCompletions(argumentText)The key is that CombinedAutocompleteProvider already has the logic to call getArgumentCompletions - it's used by the built-in /model command. The PR just wires extension commands into the same system.
Let me verify this by looking at how the built-in /model command is set up and how extension commands are passed to the autocomplete provider.
You're right to ask. Let me trace the full call chain:
>cd /Users/badlogic/workspaces/pi-mono && grep -n "CombinedAutocompleteProvider\|slashCommands\|extensionCommands" packages/coding-agent/src/modes/interactive/interactive-mode.ts | head -30OK, so the extension commands are mapped and passed to CombinedAutocompleteProvider at line 338. Now let me look at where getArgumentCompletions is actually called in the autocomplete provider. I already read it - it's at line 159-163 in packages/tui/src/autocomplete.ts:
const command = this.commands.find((cmd) => { const name = "name" in cmd ? cmd.name : cmd.value; return name === commandName;});if (!command || !("getArgumentCompletions" in command) || !command.getArgumentCompletions) { return null; // No argument completion for this command}
const argumentSuggestions = command.getArgumentCompletions(argumentText);So the call path is:
getSuggestions()CombinedAutocompleteProvider.getSuggestions() in packages/tui/src/autocomplete.ts/command (with space after command), lines 147-166 handle argument completion:
this.commands (which includes extension commands)command.getArgumentCompletions(argumentText) if it existsSo getArgumentCompletions is called in packages/tui/src/autocomplete.ts line 163. The PR correctly wires extension commands into this existing system by:
getArgumentCompletions to the RegisteredCommand typeSlashCommand formatLet me confirm this is working by showing the relevant code path more clearly.
The call happens in packages/tui/src/autocomplete.ts. Here's the flow:
// In extensionpi.registerCommand("deploy", { getArgumentCompletions: (prefix) => [...], // stored in extension.commands handler: async (args, ctx) => {...}});const extensionCommands: SlashCommand[] = (this.session.extensionRunner?.getRegisteredCommands() ?? []).map( (cmd) => ({ name: cmd.name, description: cmd.description ?? "(extension command)", getArgumentCompletions: cmd.getArgumentCompletions, // <-- PR adds this line }),);this.autocompleteProvider = new CombinedAutocompleteProvider( [...slashCommands, ...templateCommands, ...extensionCommands, ...skillCommandList], ...);ah got it, so this actually works. very nice, merge into main, will have to resolve conflict locally
The user wants me to merge this PR into main. According to AGENTS.md:
Let me do this step by step.
>cd /Users/badlogic/workspaces/pi-mono && git fetch origin && git checkout main && git pull origin mainThere are unstaged changes. Let me stash them and try again.
>cd /Users/badlogic/workspaces/pi-mono && git stash && git pull origin mainGood. Now let me fetch the PR branch and merge it.
>cd /Users/badlogic/workspaces/pi-mono && gh pr checkout 775Good, I'm on the PR branch. Let me rebase it on main to resolve any conflicts.
>cd /Users/badlogic/workspaces/pi-mono && git rebase mainThere's a conflict in the CHANGELOG.md. Let me read it and fix it. I also need to fix the attribution.
I see the conflict. The PR was based on an older version before the input event was released (0.47.0). The PR's CHANGELOG includes the input event entries that are now in the released section, plus the new getArgumentCompletions entry.
I need to:
getArgumentCompletions entry WITH proper attributionLet me fix this.
Good, now let me add the file and continue the rebase.
>cd /Users/badlogic/workspaces/pi-mono && git add packages/coding-agent/CHANGELOG.md && git rebase --continueThe rebase succeeded. Now let me run the checks to make sure everything is good.
>cd /Users/badlogic/workspaces/pi-mono && npm run check 2>&1All checks pass. Now let me switch to main and merge the feature branch.
>cd /Users/badlogic/workspaces/pi-mono && git checkout main && git merge feat/command-arg-autocomplete --no-ff -m "feat(coding-agent): extension command argument autocomplete (#775)"Let me push to main and close the PR with a comment.
>cd /Users/badlogic/workspaces/pi-mono && git push origin mainNow let me close the PR with a comment.
>cd /Users/badlogic/workspaces/pi-mono && gh pr close 775 --comment "Merged into main. Added PR link and author attribution to the changelog entry. Thanks @ribelo!" --delete-branchLet me restore the stash.
>cd /Users/badlogic/workspaces/pi-mono && git stash popDone. Let me summarize what happened.
Done. Merged PR #775 into main.
Changes made:
([#775](https://github.com/badlogic/pi-mono/pull/775) by [@ribelo](https://github.com/ribelo))+- Extension commands can provide argument auto-completions via `getArgumentCompletions` in `pi.registerCommand()`.import type { AutocompleteItem } from "@mariozechner/pi-tui";if (!command || !("getArgumentCompletions" in command) || !command.getArgumentCompletions) { return null; // No argument completion for this command}
const argumentSuggestions = command.getArgumentCompletions(argumentText);const command = this.commands.find((cmd) => { const name = "name" in cmd ? cmd.name : cmd.value; return name === commandName;});if (!command || !("getArgumentCompletions" in command) || !command.getArgumentCompletions) { return null; // No argument completion for this command}
const argumentSuggestions = command.getArgumentCompletions(argumentText);// In extensionpi.registerCommand("deploy", { getArgumentCompletions: (prefix) => [...], // stored in extension.commands handler: async (args, ctx) => {...}});const extensionCommands: SlashCommand[] = (this.session.extensionRunner?.getRegisteredCommands() ?? []).map( (cmd) => ({ name: cmd.name, description: cmd.description ?? "(extension command)", getArgumentCompletions: cmd.getArgumentCompletions, // <-- PR adds this line }),);this.autocompleteProvider = new CombinedAutocompleteProvider( [...slashCommands, ...templateCommands, ...extensionCommands, ...skillCommandList], ...);