pack-Agent

August 16, 2026 · View on GitHub

简体中文 | English

Package any AI agent into a portable dsh mode (preset) repository.

The result is a GitHub repository that is itself a dsh preset: clone it to ~/.dsh/.agent-presets/<id> and pick it in the dsh mode selector.

What is this

pack_agent.py packages an AI agent — from Claude Code, Codex, opencode, aider, Cursor, an installed dsh preset, or any custom agent described by a JSON/YAML manifest — into a portable dsh preset repo containing:

PathContent
agent.cordis.ymldsh composition file (base preset + MCP + tools + skills wiring)
preset.ymlmode name / description shown in the dsh picker
AGENTS.mdmerged agent instructions + memory
skills/collected skills (one directory per skill)
tools/bundled custom tool plugins
assets/extra files you asked to include
.env.exampleMCP token placeholders (never real secrets)
install.shone-command installer for dsh
pack_agent.pythe packer itself, so the packaged agent can be re-packed later

Highlights

  • Multi-source: dsh preset (--from-dsh), Claude Code (~/.claude.json, skills, CLAUDE.md, project .mcp.json), Codex (~/.codex/config.toml, memory, skills), opencode / aider / Cursor (--source opencode|aider|cursor), or a generic manifest
  • Secret-safe MCP: tokens/secrets are replaced with process.env.AGENT_MCP_* placeholders and listed in .env.example — nothing sensitive is committed
  • Memory redaction: --memory safe strips assignment-style secrets and inline credential-looking tokens (URLs and normal prose are left alone)
  • MCP filtering: --mcp-include, --mcp-exclude, --exclude-local-mcp (drop machine-local servers)
  • --dry-run previews exactly what would be packaged, writing nothing; --verbose shows detailed discovery
  • --push initializes git and publishes to GitHub (via gh when available)

Requirements

  • Python 3.9+
  • pip install pyyaml (TOML sources additionally need tomli on Python < 3.11)

Quick start

# Auto-detect dsh / Claude Code / Codex / opencode / aider / Cursor on this machine and merge everything
python3 pack_agent.py --id my-agent --name "My Agent" --description "..." --out dist/my-agent

# Package one installed dsh preset
python3 pack_agent.py --from-dsh standard --id my-agent --out dist/my-agent

# Package any agent described by a manifest
python3 pack_agent.py --manifest agent.manifest.json --out dist/my-agent

# Preview without writing anything
python3 pack_agent.py --manifest agent.manifest.json --out dist/my-agent --dry-run

# Only keep the github MCP, drop machine-local servers
python3 pack_agent.py --id my-agent --mcp-include github --exclude-local-mcp --out dist/my-agent

# Package and push to GitHub
python3 pack_agent.py --id my-agent --push --repo my-agent --public

CLI reference

OptionDescription
--idmode id (kebab-case directory name). Default: derived from --out or my-agent
--name, --descriptiondisplay name / description in the dsh mode picker
--outoutput directory. Default: ./dist/<id>
--sourceauto (default, merges all detected), dsh, claude, codex, opencode, aider, cursor, generic
--from-dsh <id>use an installed dsh preset as the base (implies --source dsh)
--manifest <path>JSON/YAML manifest describing a generic agent
--skills [names...]skill names/paths to include; no values = include none. Default: all discovered
--mcp-config <path>extra JSON/YAML/TOML file with MCP servers (repeatable)
--mcp-include <name>only include these MCP servers (repeatable / comma-separated)
--mcp-exclude <name>exclude these MCP servers (repeatable / comma-separated)
--exclude-local-mcpdrop machine-local MCP servers (home/local paths, localhost URLs)
--agent-md <path>agent instructions file to include (repeatable)
--memoryauto (default) / full / safe / none
--memory-files <path>extra memory files (repeatable)
--extra-file <src:dst>copy an extra file/dir into assets/<dst> (repeatable)
--tool <path>bundle a custom tool plugin into tools/ (repeatable)
--base-preset <id>dsh preset used as the base when the source is not dsh. Default: standard
--dry-runprint the plan, write nothing
--verbosedetailed discovery / redaction output
--push, --repo, --public, --privategit init + push to GitHub
--yesskip prompts

Manifest format

{
  "id": "my-agent",
  "name": "My Agent",
  "description": "A packaged agent",
  "skills": ["/path/to/skill-dir", "skill-name-from-common-roots"],
  "mcp": {
    "github": {
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "ghp_xxx" }
    }
  },
  "agent_md": ["/path/to/AGENTS.md"],
  "memory": {
    "mode": "safe",
    "files": ["/path/to/memory.md"]
  },
  "tools": [
    "/path/to/tool.mjs",
    {"path": "/path/to/tool-dir", "id": "my-tool", "name": "./tools/tool-dir/index.mjs", "config": {}}
  ],
  "extra_files": [
    {"src": "/path/to/file", "dst": "notes/guide.md"}
  ]
}

Installing a packaged agent

On the target machine:

git clone --depth 1 https://github.com/you/my-agent ~/.dsh/.agent-presets/my-agent

or inside the repo:

./install.sh https://github.com/you/my-agent my-agent

Then restart dsh and pick the mode. Set the environment variables listed in .env.example.

Security notes

  • MCP tokens/secrets never enter the repository — only process.env.AGENT_MCP_* placeholders plus a .env.example.
  • Memory defaults to safe mode, which also strips inline credential-looking tokens; use --memory full only when you really need everything verbatim.
  • Before publishing, review AGENTS.md, skills/ and assets/ for anything sensitive.

License

MIT © aoye516