Agents group commands, and CLI help/auth#135
Closed
liranfarage89 wants to merge 17 commits intofeat/node-20-upgradefrom
Closed
Agents group commands, and CLI help/auth#135liranfarage89 wants to merge 17 commits intofeat/node-20-upgradefrom
liranfarage89 wants to merge 17 commits intofeat/node-20-upgradefrom
Conversation
chpl
reviewed
Dec 3, 2025
…lient-integrations into feat/cli-agents-settings-list-agents
Author
Thanks for the review and the notes.
|
chpl
reviewed
Dec 9, 2025
Comment on lines
+16
to
+39
| const DEPRECATED_CREDENTIAL_FLAGS = ['-k', '--apiKey', '-s', '--apiSecret']; | ||
|
|
||
| const warnOnDeprecatedCredentialFlags = (command, argv) => { | ||
| if (command === 'configure') return; | ||
|
|
||
| const hasDeprecatedFlag = argv.some(arg => { | ||
| if (DEPRECATED_CREDENTIAL_FLAGS.includes(arg)) return true; | ||
| return ( | ||
| arg.startsWith('--apiKey=') || | ||
| arg.startsWith('-k=') || | ||
| arg.startsWith('--apiSecret=') || | ||
| arg.startsWith('-s=') | ||
| ); | ||
| }); | ||
|
|
||
| if (hasDeprecatedFlag) { | ||
| const YELLOW = '\u001b[33m'; | ||
| const RESET = '\u001b[0m'; | ||
| logger.info( | ||
| `${YELLOW}Warning: -k/--apiKey and -s/--apiSecret are deprecated for this command and may be removed in a future version. Prefer using "env0 configure" or ENV0_API_KEY/ENV0_API_SECRET instead.${RESET}` | ||
| ); | ||
| } | ||
| }; | ||
|
|
Author
There was a problem hiding this comment.
it's bad practice to pass sensitive variables like that, isn't it?
chpl
approved these changes
Dec 9, 2025
Remove command prefix grouping logic from getCommandOptions and return parsed options directly. Export getCommandOptions for testing. Update test mocks to match new flat structure without command key nesting.
…g file Update config merge order in config-manager to prioritize environment variables over CLI parameters. Add tests to verify env vars take precedence in both scenarios with and without config file. Add test coverage for agents-settings-list-agents command.
Author
|
closing this for now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR extends the
@env0/cliwith a new agents command, modernizes how commands and arguments are wired, and refreshes the help output and README to better reflect current behavior.Key themes:
agentscommand group withagents list.-k/-son runtime commands now deprecated rather than removed.--helpoutput.Changes
1. New
agents listcommand (Agents Settings API)Added
agents listCLI command to list organization agents, backed by the/agentsAPI endpoint.Usage:
Implementation:
Handler:
src/commands/agents-settings-list-agents.jsEnv0ApiClientto callGET /agentswithorganizationIdas a query param.Command config in
src/config/commands.js:organizationIdis grouped underagentsinsrc/config/arguments.jsso it appears correctly in help output.2. Centralized command wiring & required options
Before:
run-command.jshard‑coded per‑command handlers and required options.After:
src/config/commands.jsis the single source of truth:Each command now has:
handler– function implementing the command.requiredOptions– which options must be present.useDeployUtils– whether to initializeDeployUtils.options– CLI option schema forcommand-line-args.help– description and example(s) used for--help.src/commands/run-command.jsis now generic:commands[command]and uses the command’srequiredOptions/useDeployUtils/optionsinstead of hard-coding.DeployUtilsonly whenuseDeployUtilsis true.commandConfig.handler(options, variables).This makes adding new commands (including future
agents <subcommand>s) primarily a matter of adding an entry inconfig/commands.jsplus a handler module.3. Auth flow: non-breaking, with deprecation warning
Goal: Improve auth UX by encouraging
env0 configureand env vars, without breaking existing flows that rely on-k/-s.Changes:
In
src/config/arguments.js:apiKey/apiSecret(API_KEY,API_SECRET) remain defined withsecret: trueand are still available to runtime commands via shared base arguments.organizationIdis also grouped underagentsso it is exposed foragents list.In
src/config/commands.js:deploy,destroy,approve,cancel) once again use base argument sets that includeapiKey/apiSecret, so-k/-swork as before.agents listuses onlyorganizationIdas its explicit option, with credentials coming from configure/env/flags.configurecontinues to expose-k/--apiKeyand-s/--apiSecretfor initial setup.In
src/main.js:warnOnDeprecatedCredentialFlagshelper detects use of-k/--apiKeyand-s/--apiSecret(and their=valueforms) on non-configurecommands.commandLineArgsandconfigManager.readas before.In
src/commands/help.js:secret: true, soapiKey/apiSecretdon’t show up under runtime commands, while remaining valid flags.config-managerbehavior remains the same:tests/lib/config-manager.spec.js) already assert:README updates:
apiKey/apiSecretflags for backwards compatibility, but these are now deprecated.env0 configureand/orENV0_API_KEY/ENV0_API_SECRETgoing forward.4. Grouped
agentscommands and routingsrc/main.jsnow supports grouped commands for agents:After handling internal commands (help/version/configure), any
agents <subcommand>invocation is mapped:This currently supports:
env0 agents list -o <organizationId>And will work for future subcommands like
agents delete,agents update, etc., as long as they are defined inconfig/commands.js.env0 agents --helpis treated as an internal help call before remapping, so it shows a dedicated agents help page (see below) instead of trying to run a subcommand.5. Help output improvements
File:
src/commands/help.jsTop‑level help (
env0 --help):Now a more conventional layout:
Usage–env0 <command> [options].Commands– only top‑level commands (deploy,destroy,approve,cancel,configure,version,help,agents).agentsis summarized as:Per-command
... optionssections are rendered only for top-level commands (no spaces in name).Examples– driven by each command’shelparray fromconfig/commands.js.Footer with project URL.
Agents‑specific help (
env0 agents --help):Uses a separate layout built from
commandsentries that start withagents:Usage–env0 agents <command> [options].Commands– currently:agents list options– shows onlyorganizationId.Examples– only agents examples.src/main.jspasses the command intohelp(command)so:env0 --help→ top-level help.env0 agents --help→ agents‑specific help.6. Tests
Existing tests for
run-command,deploy,destroy,config-manager, etc., continue to validate behavior around required options and config/env precedence.Given this PR is focused on behavior and compatibility rather than new core flows, the primary safeguards are the existing suite plus manual verification of:
env0 --helptop-level layout.env0 agents --helpgrouped agents help.env0 agents list -o <org>with credentials coming fromconfigure/ env vars /-k/-s.7. README refresh
File:
node/README.mdModernized and aligned with current behavior:
Documents:
configure→deploy→--help/agents --help).apiKey/apiSecretflags for backwards compatibility, but these flags are now deprecated andenv0 configure/ env vars are preferred.deploy,destroy,approve,cancel, groupedagentscommands (currentlyagents list),configure,version,help.ENV0_API_URL).Notes for reviewers
Backward compatibility:
env0 configure.ENV0_API_KEY/ENV0_API_SECRETenv vars.-k/-sflags on runtime commands, now accompanied by a deprecation warning instead of a behavior change.--helpis more concise; detailed per‑subcommand help is available viaenv0 agents --help.Extensibility:
agents) can be added by:src/config/commands.js(withhandler,requiredOptions,useDeployUtils,options,help).src/commands/….main.jsorrun-command.jsfor additionalagents <subcommand>entries.