mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #37] Add dynamic shell completion to the aenv CLI #17
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LSX-s-Software on GitHub (Jul 28, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/37
Summary
Add first-class shell completion support to the native
aenvCLI for Bash, Zsh, and Fish.In addition to completing commands and flags, the CLI should dynamically complete AgentENV resources such as sandbox IDs and template/snapshot names.
Motivation
The CLI contains nested commands, aliases, and resource identifiers that are difficult to enter manually:
Sandbox IDs are UUIDs, while templates and snapshots may be referenced by either names or IDs. As the number of resources grows, users currently need to run a list command, copy a value, and paste it into the next command.
Shell completion would make interactive CLI use faster and reduce invalid commands caused by stale or mistyped identifiers.
Proposed interface
Add a command that emits completion registration code:
The generated registration should call back into the current
aenvbinary when completion is requested, allowing it to provide both static and dynamic candidates.Static completion should cover:
ls,rm,cn, andsnap;--output table|json;aenv build.Dynamic resource completion
Sandboxes
Commands accepting a sandbox ID should query the sandbox list and filter candidates by the states accepted by the command:
pause,exec,timeout, andsnapshot create: running sandboxes;resume: paused sandboxes;connect,delete, andsnapshot list --sandbox-id: running and paused sandboxes.The inserted value should be the sandbox ID. When supported by the shell, the candidate description should include the sandbox's template and state.
Templates and snapshots
Commands accepting a template or snapshot should complete human-readable names or aliases first, with IDs available as fallback candidates:
aenv start <target>;aenv template watch <template>;aenv template delete <template>.aenv start --coldshould not query template or snapshot candidates because its target is an OCI image reference.Candidate descriptions should distinguish templates from snapshots and include the underlying ID and build status where available.
Failure and performance behavior
Dynamic completion is an interactive, best-effort feature and must not make the shell feel blocked.
Installation
The existing installation paths should install lightweight completion loaders for Bash, Zsh, and Fish:
make install-aenv;scripts/install-cli.sh;The loaders should generate registration code from the installed
aenvbinary when a shell starts, so CLI upgrades do not leave incompatible cached completion scripts behind.Installers should use standard completion directories and must not modify
.bashrc,.zshrc, or Fish configuration files automatically. If additional shell configuration is required, the installer should print an actionable message.make uninstall-aenvshould remove the installed completion loaders.Documentation
Document automatic installation and manual activation:
Acceptance criteria
aenvcommands, aliases, flags, and enum values.aenv start --colddoes not return template or snapshot candidates.Non-goals
@rbalachandar commented on GitHub (Jul 30, 2026):
Step 1 (static completion scaffolding — commands, aliases, flags, the
--outputenum, and path arguments) is up in #89. This note is about step 2: dynamic resource completion (sandbox IDs filtered by command-applicable state, template/snapshot names, and thestart --coldOCI-ref exception).One mechanism decision before starting it: clap_complete's dynamic completion is gated behind its
unstable-dynamicfeature (and requiresclap/unstable-ext) as of 4.6.x, so it's explicitly unstable. The realistic options are:aenv __completecallback that the generated scripts invoke — a bit more code, but stable and self-contained.I'd lean toward the hand-rolled callback to avoid pinning the CLI to an unstable clap feature, but happy to go either way.
@NickNYU commented on GitHub (Aug 4, 2026):
Hi
I’d like to contribute to this issue.
After reviewing the current aenv command tree, I’m interested in taking the
sandbox-ID dynamic completion subtask for:
The scope would be querying the configured AgentENV API for available
sandboxes, completing sandbox IDs (optionally with state/alias descriptions),
handling API/auth errors gracefully, and adding focused tests.
Is this part still unclaimed, and does it fit the completion design currently
being implemented?
@LSX-s-Software commented on GitHub (Aug 6, 2026):
@NickNYU Thanks for your interest in working on this!
You’re welcome to take a stab at it and open a PR. It would be great if you could briefly outline your approach here before implementing, just to make sure we’re aligned on the direction.
Let us know if you run into any questions along the way.
@NickNYU commented on GitHub (Aug 11, 2026):
@LSX-s-Software Thanks for the clarification. I reviewed the current CLI implementation, PR #89, and a few related industry approaches such as Docker and K8S(kubectl) completion.
My understanding is (please correct me if I'm wrong) that PR #89 already provides the static completion foundation for commands by leveraging the clap framework.
Meaningful
The remaining useful part of this issue is dynamic completion of runtime resources.
I would like to propose taking the following first slice:
Dynamic sandbox-ID completion
Commands and arguments:
aenv connect <sandbox-id>aenv exec <sandbox-id> ...aenv upload <sandbox-id> ...aenv download <sandbox-id> ...aenv pause <sandbox-id>aenv resume <sandbox-id>aenv delete <sandbox-id>aenv timeout <sandbox-id> ...aenv snapshot create <sandbox-id>aenv snapshot list --sandbox-id <sandbox-id>The proposed implementation would:
/v2/sandboxesAPI. (No new API is introduced)Possible implementation approaches
Option A: Use Clap's dynamic completion support
Use
clap_complete'sunstable-dynamicAPIs, such asCompleteEnv,ArgValueCandidates, orArgValueCompleter.Pros:
clap_completedesign.Cons:
unstable-dynamic.Option B: Add an AgentENV-owned internal completion hook
Add an internal command or protocol such as:
The generated Bash/Zsh/Fish scripts would invoke it only at supported sandbox-ID argument positions.
Pros:
Cons:
Summary
Both options should reuse the existing CLI client and /v2/sandboxes endpoint. No new server-side completion API should be needed.
I would intentionally leave the following for later follow-up work:
The first implementation would include focused tests for command/argument recognition, state filtering, prefix filtering, stable ordering, successful API lookup, and silent failure behavior.
Would maintainers and other contributors be willing to weigh in on Option A vs. Option B, and whether this sandbox-ID-only scope is appropriate for the first slice?
Thanks
@NickNYU commented on GitHub (Aug 12, 2026):
I implemented the two proposed approaches as separate experimental PRs so we can compare them without conflating the designs:
PR #163 — clap_complete unstable-dynamic
CompleteEnvandArgValueCandidates.PR #164 — AgentENV-owned
aenv __completeaenv __complete --index ... -- <words...>.These PRs are intentionally alternatives, not additions to merge together. Please review the API/maintenance trade-off and let me know which direction is preferable for #37. The existing static
aenv completion <shell>behavior is preserved in both branches.@LSX-s-Software commented on GitHub (Aug 22, 2026):
This issue is not yet completed. We should at least add back the document removed by
c890d29or implement auto installation.@NickNYU commented on GitHub (Sep 3, 2026):
Hi
As the issue has been opened for several days, I try to summarize things and see if it fits the fact:
Where things stand
c890d29— restored in #231 (merged 2026-08-30). docs/src/getting-started/aenv-cli.md again covers aenv completion , the per-shell install locations, and source <(aenv completion bash)-style manual activation.What might be the Next
as @LSX-s-Software has mentioned previously in 08-22's note: "at least the document back, or auto installation", it might be good to do
make install-aenv,scripts/install-cli.sh,scripts/install.sh, plus removal frommake uninstall-aenv). None of these touch completion today. #115 covered exactly this, but it was closed on 08-28 without review — Hi @rbalachandar, are you still planning to merge it, so that we don't need to duplicate the workaenv start <target>,aenv template watch,aenv template delete, including thestart --coldOCI-reference exception.Proposal
I'd like to pick up (1) if no one is trying to do it
Waiting for your news, thanks!
@rbalachandar commented on GitHub (Sep 3, 2026):
Thought different approach was taken. I can reopen the PR if the approach sounds good.
@NickNYU commented on GitHub (Sep 4, 2026):
Hi @rbalachandar, thanks for the reply! Yes, #115's approach (auto-install loaders, no shell-rc edits, only touch managed files) still matches what this issue needs — what merged later (#163, dynamic completion via the
COMPLETE=callback) is on a different layer and shouldn't conflict. Please go ahead and reopen #115, and I'm happy to review it against current main.Then I'll take the remaining slice: template/snapshot name completion for
aenv start <target>,aenv template watch,aenv template delete, with thestart --coldOCI-reference exception.@LSX-s-Software does this split sound good?
@NickNYU commented on GitHub (Sep 6, 2026):
Hi, an update on the remaining dynamic-completion part.
I've implemented (2) — template / snapshot name completion — and opened #250. What's in it:
aenv start <TAB>completes template and snapshot names, then IDs as a fallback.aenv template watch/aenv template deletecomplete template names, then IDs.aenv start --cold <TAB>offers nothing, since the target is an OCI image reference. It returns before any credential or network access, so a cold start costs no API call./v2/templatesand/snapshots; no new server API, and the same short timeouts and silent-failure behavior as #163.Two small things I ran into and fixed along the way:
snapshot list --sandbox-idhad no sandbox completion, although it's listed in this issue under the sandbox states table.@rbalachandar — for (1), please go ahead and reopen #115 whenever you like, it doesn't conflict with this PR. I'm happy to review it.
That would leave this issue fully covered: static scaffolding (#89), dynamic sandbox IDs (#163), docs (#231), template/snapshot names (#250), auto installation (#115).