Skip to content

AGX CLI nits: functions:update-function hint, functions:set-secret shortcut#61

Merged
etbyrd merged 2 commits into
mainfrom
agx-cli-nits-functions-update-hint
May 11, 2026
Merged

AGX CLI nits: functions:update-function hint, functions:set-secret shortcut#61
etbyrd merged 2 commits into
mainfrom
agx-cli-nits-functions-update-hint

Conversation

@etbyrd
Copy link
Copy Markdown
Member

@etbyrd etbyrd commented May 11, 2026

Summary

Two CLI ergonomic findings from the email-summarizer AGX run, both in one PR.

1. functions:redeploy discoverability

The AGX agent reached for the auto-generated functions:update-function command for redeploys, missed functions:redeploy --file entirely, and ended up hand-rolling a JSON wrapper with the bundle as a string. Added an OPERATION_HINTS map keyed by sdkName in api-command.ts, appended to operation descriptions in createOperationCommand. Hints point users from functions:update-function, functions:create-function, functions:set-function-secret, and functions:create-function-secret to the file-input / convenience wrappers.

2. functions:set-secret with optional --redeploy

New hand-rolled command at sdk-node/src/oclif/commands/functions-set-secret.ts. Flags: --id, --key, --value, --redeploy. With --redeploy, after the secret upsert succeeds, the command calls getFunction then updateFunction with the same code to roll the binding into the running handler in one shell invocation. Pure runSetSecret(api, params) is exported for testing. Stage-tagged discriminated-union result lets the CLI frame errors as 'secret landed, deploy did not' when only the redeploy fails. Registered as functions:set-secret in src/oclif/index.ts. Topic description in package.json updated to mention it.

Test plan

  • make node-check (vitest 666 tests pass, biome lint clean, tsc --noEmit clean)
  • make node-check-generated (exit 0)
  • live --help smoke tests confirming hints render on the four generated commands and functions:set-secret --help documents the new flags

Paired

  • mono-repo PR #499: trim PUT response code, full webhook delivery body. The new getDelivery operation will want an SDK regeneration follow-up after the openapi spec catches up.

…ortcut

Two ergonomic gaps surfaced by the AGX CLI walkthrough.

First, an agent reading `functions:update-function --help` had no
way to discover `functions:redeploy --file <bundle>`. Add an
OPERATION_HINTS map keyed by manifest sdkName so generated commands
that shadow a hand-rolled shortcut surface the shortcut directly in
their --help description. Entries for createFunction, updateFunction,
createFunctionSecret, and setFunctionSecret point at functions:deploy,
functions:redeploy, and functions:set-secret respectively.

Second, writing a function secret only landed the value at rest;
making it visible to the running handler still required a manual
redeploy. Add functions:set-secret with a --redeploy flag that, after
the secret upsert succeeds, fetches the current bundle via
getFunction and re-runs the deploy in the same call. Stage-tagged
errors so the caller can tell whether the secret landed before a
failed redeploy.

Tests cover both no-redeploy and --redeploy paths against a fake API
surface, plus the description-rendering branch of createOperationCommand
for both the with-hint and no-hint cases. Update the functions topic
description in package.json to call out all three shortcuts.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 11, 2026

Greptile Summary

This PR adds two CLI ergonomic improvements to the functions command group: discoverability hints on four generated commands (via OPERATION_HINTS in api-command.ts) and a new functions:set-secret hand-rolled command that wraps the secret-upsert + optional redeploy into a single invocation.

  • OPERATION_HINTS appends a "prefer this shortcut" tip to the --help description of functions:create-function, functions:update-function, functions:create-function-secret, and functions:set-function-secret, steering agents and users toward the file-input ergonomics.
  • functions:set-secret wraps setFunctionSecret + an optional getFunction/updateFunction redeploy cycle, with a discriminated-union result type that lets the CLI distinguish "secret landed, deploy did not" at the error-message layer. The source-map caveat for --redeploy is documented in both the code comments and the flag description.
  • Test coverage is thorough: all error stages (set-secret, get-function, redeploy) and empty-data 2xx edge cases are exercised against a fake SetSecretApiSurface, and the OPERATION_HINTS contents are pinned by tests to guard against silent renames.

Confidence Score: 5/5

Safe to merge — the changes are additive, well-tested, and the new --redeploy path correctly uses the required code field from FunctionDetail.

All changed code paths are covered by unit tests. FunctionDetail.code is a required string in the generated type, so the redeploy step has no null/undefined risk. The discriminated-union result and stage-specific stderr messages handle partial-failure cases cleanly. No existing behavior is modified — the OPERATION_HINTS insertion is purely additive to --help output.

No files require special attention.

Important Files Changed

Filename Overview
sdk-node/src/oclif/commands/functions-set-secret.ts New hand-rolled command implementing the functions:set-secret shortcut with optional --redeploy; discriminated-union result type, stage-specific stderr hints, and source-map caveat are all well-handled.
sdk-node/src/oclif/api-command.ts Adds OPERATION_HINTS map and appends matching hint to the --help description in createOperationCommand; change is minimal and isolated to description rendering.
sdk-node/tests/oclif/functions-set-secret.test.ts Comprehensive unit tests cover the happy path, each error stage (set-secret, get-function, redeploy), and empty-data 2xx edge cases using a fake SetSecretApiSurface.
sdk-node/tests/oclif/api-command.test.ts Adds tests that pin OPERATION_HINTS contents to known shortcut commands and verify hint injection/omission in createOperationCommand description output.
sdk-node/src/oclif/index.ts Registers functions:set-secret in the COMMANDS map alongside the existing functions:deploy / functions:redeploy shortcuts.
sdk-node/package.json Updates the functions oclif topic description to reference the new functions:set-secret shortcut and functions:redeploy.

Reviews (2): Last reviewed commit: "Document source-map drop on functions:se..." | Re-trigger Greptile

Comment thread sdk-node/src/oclif/commands/functions-set-secret.ts
P2 from Greptile. The --redeploy shortcut pulls the function's current code via getFunction (which does not return the source map, since source maps are stored only on the runtime side) and re-uploads with no sourceMap field. The runtime treats a deploy without sourceMap as 'drop the existing one', so a user who originally deployed with --source-map-file silently loses symbolication after --redeploy. Document the limitation in both the file's header docstring and the flag description, with a pointer to functions:redeploy --file --source-map-file for callers who need symbolication preserved.
@etbyrd etbyrd merged commit 8709732 into main May 11, 2026
8 checks passed
@etbyrd etbyrd deleted the agx-cli-nits-functions-update-hint branch May 11, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant