Agent Skillsdtyq/magic › cli-manager

cli-manager

GitHub

管理沙箱中用户安装的第三方CLI工具的持久化,支持安装、配置、恢复和移除。区分运行时工具与用户工具,执行安装前脚本安全检查,并协调底层工具完成状态维护。

backend/super-magic/agents/skills/cli-manager/SKILL.md dtyq/magic

Trigger Scenarios

用户要求安装或持久化第三方CLI工具 需要恢复、检查或移除已注册的CLI

Install

npx skills add dtyq/magic --skill cli-manager -g -y
More Options

Non-standard path

npx skills add https://github.com/dtyq/magic/tree/master/backend/super-magic/agents/skills/cli-manager -g -y

Use without installing

npx skills use dtyq/magic@cli-manager

指定 Agent (Claude Code)

npx skills add dtyq/magic --skill cli-manager -a claude-code -g -y

安装 repo 全部 skill

npx skills add dtyq/magic --all -g -y

预览 repo 内 skill

npx skills add dtyq/magic --list

SKILL.md

Frontmatter
{
    "name": "cli-manager",
    "description": "Manage persistence for user-installed third-party CLI tools in the Super Magic sandbox. Use when the user wants to install, configure, adopt, restore, inspect, or remove a CLI, or when an external skill, webpage, or installer asks to run CLI install commands such as curl|sh, npm install -g, pipx install, uv tool install, go install, cargo install, or brew install. Do not persist runtime-provided CLIs."
}

CLI Manager

Use this skill when the user wants to install a user-managed third-party CLI, or when a user-installed CLI should remain available across future sandbox sessions.

This skill is for orchestration only. Do not handle installed artifacts yourself, and do not guess how the tool implements persistence. All persistence, restore, conflict detection, and cleanup actions must go through the Code Mode tools.

Principles

  1. Separate runtime-provided CLIs from user-managed CLIs before discussing persistence.
  2. lark-cli, dws, and teamshare-cli are provided and updated by the Super Magic runtime. Never install, adopt, or create new persistence records for them with cli-manager.
  3. If the user asks to install one of those runtime-provided CLIs and the command is available, tell the user it is already installed and continue with its platform skill or authentication flow. Do not ask for persistence confirmation.
  4. If a runtime-provided CLI is unavailable, report it as a runtime environment problem. Do not repair it by installing a user-managed copy.
  5. cli_manager_list lists only user-managed persisted CLIs. An empty result says nothing about runtime-provided CLIs.
  6. If a runtime-provided CLI already has a legacy user persistence record, explain that the record is redundant. Remove only that legacy record after explicit user confirmation.
  7. Before running any third-party CLI install command, decide whether user persistence is needed.
  8. Before persisting or removing a user-managed CLI, get explicit user confirmation.
  9. For script-based installers such as curl ... | sh, wget ... | bash, or sh install.sh, read the full installer script first and continue only if there is no obvious high-risk behavior.
  10. Store secret values such as API keys, tokens, and licenses with env-manager. This skill only records environment variable names.
  11. If a tool fails, stop the current install or remove flow and follow the next steps in result.content.
  12. Do not read or rely on extra_info, data, or other internal fields unless a later tool document explicitly requires it.
  13. Use only the parameters shown in this skill. Never pass resolution, resolution_options, or other guessed internal parameters.
  14. Do not run the actual install command with shell_exec. cli_manager_apply is responsible for executing the installer after confirmation.

Install Flow

  1. Check whether the requested command is runtime-provided. If it is lark-cli, dws, or teamshare-cli, follow the runtime-provided short circuit above and stop this install flow.
  2. Identify the CLI name, command names, install command, relevant config directories, and required environment variable names.
  3. If the install path depends on a remote or local installer script, read the full script and check for obvious risk before continuing.
  4. Tell the user that a normal user-managed install can be lost when the sandbox is destroyed, then ask whether they want to persist the CLI.
  5. After the user confirms, call cli_manager_apply.
  6. If the install docs require an API key first, load env-manager to check or save the required environment variable before continuing.
  7. After install completes, verify and respond based on result.content.
  8. If cli_manager_apply fails, do not run the CLI with shell_exec to turn the flow into a success. Follow the next steps in result.content or report that persistence did not complete.

Install a new CLI:

run_sdk_snippet(python_code="""
from sdk.tool import tool

result = tool.call("cli_manager_apply", {
    "name": "example-cli",
    "mode": "install",
    "install_command": "npm install -g example-cli",
    "commands": ["example-cli"],
    "config_dirs": ["~/.example-cli"],
    "env_keys": ["EXAMPLE_API_KEY"],
    "confirmed": True,
})
if not result.ok:
    print(result.content)
    raise SystemExit(1)
print(result.content)
""")

Adopt an already installed CLI:

run_sdk_snippet(python_code="""
from sdk.tool import tool

result = tool.call("cli_manager_apply", {
    "name": "example-cli",
    "mode": "adopt",
    "commands": ["example-cli"],
    "config_dirs": ["~/.example-cli"],
    "env_keys": [],
    "confirmed": True,
})
if not result.ok:
    print(result.content)
    raise SystemExit(1)
print(result.content)
""")

Inspect Flow

When the user wants to inspect persisted CLIs, check whether restore succeeded, or diagnose an unavailable command, call cli_manager_list.

run_sdk_snippet(python_code="""
from sdk.tool import tool

result = tool.call("cli_manager_list", {"validate": True})
if not result.ok:
    print(result.content)
    raise SystemExit(1)
print(result.content)
""")

Remove Flow

Only remove a persisted CLI after explicit user confirmation. By default, remove only the CLI persistence. Set remove_state=True only when the user explicitly asks to also delete that CLI's saved state.

run_sdk_snippet(python_code="""
from sdk.tool import tool

result = tool.call("cli_manager_remove", {
    "name": "example-cli",
    "remove_state": False,
    "confirmed": True,
})
if not result.ok:
    print(result.content)
    raise SystemExit(1)
print(result.content)
""")

Conflict Handling

When a conflict occurs, do not overwrite, delete, or rename anything yourself. Read result.content, show the conflict to the user, and ask them to choose one of the next steps.

If the user chooses to adopt an existing command, call cli_manager_apply again with mode="adopt" and the same command names.

If the user chooses to replace an existing persisted CLI, call cli_manager_remove first after confirmation, then retry cli_manager_apply.

If the user chooses to replace a command that is outside cli-manager, ask before removing anything and retry only after the conflict is gone.

If the user chooses a different command name, make sure it is a real command name or an installer-supported alias before retrying.

If the user cancels, stop the flow and report that no persistence change was made.

Do not pass resolution, resolution_options, preferred_strategy, command_paths, or extra_bin_dirs. They are not orchestration inputs.

Final Response

After success, briefly tell the user:

  • the CLI name and command names
  • whether it has been persisted
  • whether any environment variables are still missing
  • how they can run or verify it next

Version History

  • f9973c5 Current 2026-08-20 03:36

Same Skill Collection

backend/super-magic/agents/skills/agent-info/SKILL.md
backend/super-magic/agents/skills/canvas-designer/SKILL.md
backend/super-magic/agents/skills/chat-history/SKILL.md
backend/super-magic/agents/skills/compact-chat-history/SKILL.md
backend/super-magic/agents/skills/creating-slides/SKILL.md
backend/super-magic/agents/skills/develop-data-analysis-dashboard/SKILL.md
backend/super-magic/agents/skills/document-converter/SKILL.md
backend/super-magic/agents/skills/download/SKILL.md
backend/super-magic/agents/skills/env-manager/SKILL.md
backend/super-magic/agents/skills/im-channels/SKILL.md
backend/super-magic/agents/skills/magic-calendar/SKILL.md
backend/super-magic/agents/skills/magicbase/SKILL.md
backend/super-magic/agents/skills/sandbox-manager/SKILL.md
backend/super-magic/agents/skills/self-media-pre-publish-analyzer/SKILL.md
backend/super-magic/agents/skills/share/SKILL.md
backend/super-magic/agents/skills/skill-vetter/SKILL.md
backend/super-magic/agents/skills/slide-template/SKILL.md
backend/super-magic/agents/skills/subagents/SKILL.md
backend/super-magic/agents/skills/teamshare-cli/SKILL.md
backend/super-magic/agents/skills/user-info/SKILL.md
backend/super-magic/agents/skills/using-cron/SKILL.md
backend/super-magic/agents/skills/using-llm/SKILL.md
backend/super-magic/agents/skills/using-mcp/SKILL.md
frontend/magic-web/.agents/skills/antd-style-to-tailwind/SKILL.md
frontend/magic-web/.agents/skills/code-review-expert/SKILL.md
frontend/magic-web/.agents/skills/dual-edition-module-migration/SKILL.md
frontend/magic-web/.agents/skills/magic-web-error-logging/SKILL.md
frontend/magic-web/.agents/skills/sw-best-practices/SKILL.md
frontend/magic-web/.agents/skills/ui-data-testid/SKILL.md
frontend/magic-web/.agents/skills/vercel-composition-patterns/SKILL.md
frontend/magic-web/.agents/skills/vercel-react-best-practices/SKILL.md
backend/super-magic/agents/skills/ai-card-generator/SKILL.md
backend/super-magic/agents/skills/crew-creator/SKILL.md
backend/super-magic/agents/skills/deep-research/SKILL.md
backend/super-magic/agents/skills/dingtalk-cli/SKILL.md
backend/super-magic/agents/skills/html-api-sdk/SKILL.md
backend/super-magic/agents/skills/lark-cli/SKILL.md
backend/super-magic/agents/skills/micro-app-architect/SKILL.md
backend/super-magic/agents/skills/self-media-composer/SKILL.md
backend/super-magic/agents/skills/skill-creator/SKILL.md

Metadata

Files
0
Version
f9973c5
Hash
36472794
Indexed
2026-08-20 03:36

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 05:28
浙ICP备14020137号-1 $mapa de visitantes$