- assigned_to: thomijasir
#25 [Feature]: Add resource-aware CLI completion
Originally created by: thomijasir
Originally owned by: thomijasir
Feature description
Extend shell completion with project names, environment references, secret keys, and token IDs from the active Dopbase server.
Current behavior
The planned completion command can generate command and flag names, but those scripts do not know which resources exist on the active server.
Why we need this
Long environment references and generated IDs are slow to type and easy to mistype. Resource completion makes interactive use faster without changing command syntax.
Proposed CLI interface
Complete project arguments from accessible project names and IDs.Complete environment arguments as project/environment plus immutable environment IDs.Complete secret keys for secret get and secret delete.Complete token IDs for token revoke.
Expected behavior
- Add a hidden completion entry point used by generated shell scripts.
- Run completion in strict non-interactive mode and never open login or confirmation prompts.
- Use the active server, saved session, and directory-scoped environment context.
- Apply a short completion deadline. Return no candidates and exit successfully when the server is slow, unavailable, or unauthenticated.
- Filter candidates by the shell-provided prefix and return one candidate per line.
- Treat descriptions as optional metadata and keep output stable for shell parsing.
- Do not print normal warnings, update notices, progress, or debug output during completion.
Security and compatibility
- Fetch secret metadata only. Never request or return secret values.
- Do not expose credentials, cache content, or full API errors to the shell.
- Quote or escape candidates according to the selected shell to prevent command substitution or argument splitting.
Out of scope
- Completing values for secret creation.
- Prompting the user to authenticate.
- Persisting resource lists in the repository.
Acceptance criteria
- [ ] Supported resource arguments receive matching candidates.
- [ ] Prefix filtering works with names and IDs.
- [ ] Completion returns quickly and silently when offline or logged out.
- [ ] No completion path fetches plaintext secrets.
- [ ] Candidates with shell-sensitive characters are escaped correctly.
- [ ] Static completion continues to work when resource lookup fails.
Test scenarios
- Add hidden-command parser tests and fake-server integration tests under
app/tests/cli/. - Cover every resource type, prefixes, empty results, timeout, unavailable server, expired session, shell escaping, stderr silence, and proof that no reveal or runtime endpoint is called.
Documentation
Document that resource completion uses the active server and degrades to static completion when resources cannot be loaded.
Dependencies
Depends on shell completion generation in [#16] and existing metadata list endpoints.