发布

  • Add CLI dev mode config toggle (#3181)

    frostbyte_neo 发布于 2026-04-14 02:12:30 +00:00

    Summary

    Turns composio dev into a real developer-mode switch backed by CLI
    user config, and hides the developer subcommand tree when the mode is
    off.

    composio dev changes

    • New --mode on|off option on the dev command
      (Options.choice('mode', ['on', 'off']), optional).
    • Visibility-gated subcommands. buildDevCommand(visibility) only
      attaches the developer subcommand tree (init, tools execute,
      triggers listen, logs, toolkits, auth-configs,
      connected-accounts, triggers, projects) when
      visibility.isDevModeEnabled is true. When off, composio dev is a
      leaf command whose only job is toggling the mode.
    • Handler behavior:
    • composio dev with no flag → interactive select prompt (Turn on /
      Turn off / Keep current). Non-TTY → prints current state and exits with
      a hint to pass --mode on|off.
    • composio dev --mode on → shows a boxed warning note about unlocking
      advanced commands, then confirm before flipping. Non-TTY refuses to
      enable and points the user at the config file path.
      • composio dev --mode off → flips immediately.
    • No-op if the requested state already matches; logs current state
      instead of rewriting config.
    • Description swaps with mode. When dev mode is on: "Developer
      workflows: init, playground execution, logs, projects, toolkits,
      accounts, and triggers."
      When off: "Developer mode controls access to
      developer-only workflows. When off, only composio dev --mode on|off is
      available."

    Config wiring

    • CliUserConfig gains a developer struct ({ enabled, destructive_actions }) replacing the flat developer_mode_enabled /
      developer_dangerous_commands_enabled keys. normalizeRawConfigJson
      migrates existing configs on read.
    • ComposioCliUserConfig service exposes isDevModeEnabled(),
      areDeveloperDangerousCommandsEnabled(), and an update() that
      persists partial changes to ~/.composio/<cli-config>.json.
    • cli-main.ts / root-help.ts / commands/index.ts consume
      visibility so the help output and command tree match the toggle.

    Collateral cleanup

    Removed deprecated destructive/info commands that were being guarded
    ad-hoc and now fall under the dev-mode gate:

    • auth-configs delete, auth-configs info
    • connected-accounts delete, connected-accounts info
    • triggers delete
    • Corresponding tests deleted; auth-configs create, projects list/switch, and triggers mutation tests updated for the new
      layer/visibility shape.

    Testing

    • ts/packages/cli/test/src/commands/dev.cmd.test.ts — new coverage for
      the toggle handler (TTY/non-TTY, on→on no-op, confirm path, persisted
      config).
    • ts/packages/cli/test/src/services/cli-user-config.test.ts — new
      coverage for the developer struct, legacy key migration, and
      update().
    • ts/packages/cli/test/src/commands/feature-visibility.test.ts
      updated to exercise visibility-gated subcommands.
    • Not run: full workspace test suite.

    Co-authored-by: Claude Opus 4.6 (1M context) noreply@anthropic.com

    下载附件