如何用 Multica CLI 脚本化管理 workspace、issue 与 agent(含 profile 与 JSON 输出)
发布时间:2026/9/11 4:40:27 作者:尧图编辑部 阅读量:1,286
)
如何用 Multica CLI 脚本化管理 workspace、issue 与 agent含 profile 与 JSON 输出【免费下载链接】multicaMake humans and AI agents work as one team — open-source and self-hostable.项目地址: https://gitcode.com/GitHub_Trending/mu/multica如果你的工作流里有一批重复动作——批量列出某个 workspace 的 issue、按状态筛选、创建 issue 并指派给 agent、为 staging 和 production 各连一个 Multica 实例——那么 Multica CLImultica提供的命令行接口就是为这种脚本化场景准备的。本文基于项目文档 Using the CLI 和 CLI and Agent Daemon Guide给出一条可执行的脚本化路径安装 CLI、连接服务器、用--output json拿到机器可读数据、用 workspace 解析规则控制命令作用域、用--profile隔离多环境。完成本文后你可以把 workspace、issue、agent 的日常管理写进 shell 脚本或 CI而不是每次都打开网页。准备条件安装 CLI 并连接 Multica 实例脚本化的前提是机器上有一个能认证通过的multica。macOS / Linux 下文档给出的安装方式任选其一brew install multica-ai/tap/multica # 或 curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bashWindows PowerShell 下irm https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.ps1 | iex安装后验证multica version能打印版本号即安装成功。然后连接服务器连 Multica Cloud 用multica setup连自托管实例用multica setup self-host \ --server-url https://api.example.com \ --app-url https://app.example.comsetup会保存服务器地址、打开浏览器完成登录并启动 daemon。无浏览器的机器先在建 PATWeb 端Settings → API Token再用交互式粘贴方式登录避免 token 进 shell historymultica login --token用multica auth status确认当前服务器、用户和 token 有效期。PAT 以mul_开头、有效期 90 天剩余不足 7 天时会自动续期一旦过期或被吊销需要重新multica login见 Authentication and tokens。先弄清 JSON 输出的默认行为再写脚本写脚本前先记住文档给出的两条默认规则它们决定你在哪些命令上必须显式加--output jsonlist类命令默认输出面向终端的 tableget和create类命令大多默认输出 JSON。显式指定时统一写成multica issue list --output json multica agent list --output json文档明确建议脚本应使用 JSON 输出而不是去解析 table 文本。各命令支持的输出格式与分页参数以multica command --help为准。另外两个脚本化相关的 ID 规则issue 用MUL-123这类 key 或完整 UUID短 UUID 前缀不被接受其他资源的list命令默认打印可复制的短 ID加--full-id输出完整 UUID。短 ID 有歧义时 CLI 会要求你补字符或给完整 UUID。脚本化 workspace 管理先列出你能访问的 workspace拿到 slug 或 IDmultica workspace list multica workspace list --full-id multica workspace list --output jsontable 输出中当前默认 workspace 带*标记。切换默认值用multica workspace switch slug multica workspace switch workspace-idswitch会先校验你对该 workspace 有访问权再写入当前 profile 的默认 workspace。multica workspace get不带参数时解析到当前默认 workspace可以直接当作我现在在哪个 workspace的检查命令。写脚本时最关键是 workspace 的解析顺序优先级从高到低命令上的--workspace-id id环境变量MULTICA_WORKSPACE_ID当前 profile 存储的默认 workspace由workspace switch或login写入。CI 或无头环境下不想依赖任何已存储状态时推荐显式传--workspace-id或设MULTICA_WORKSPACE_ID例如MULTICA_WORKSPACE_IDworkspace-id multica issue list --output json脚本化 issue 管理以下是文档给出的 issue 常用操作路径全部可以放进脚本# 查看与搜索 multica issue list multica issue get MUL-123 multica issue search login failure # 创建与更新 multica issue create --title Fix login failure multica issue status MUL-123 in_progress multica issue assign MUL-123 --to Backend Agent # 评论与执行记录 multica issue comment list MUL-123 multica issue comment add MUL-123 --content Check the regression tests first multica issue runs MUL-123脚本里几个值得专门处理的点JSON 输出裁剪字段。--fields只在 JSON 输出下生效用逗号分隔的白名单控制返回哪些顶层字段字段名是真实 API key例如 assignee 拆成assignee_type/assignee_idmultica issue list --output json --fieldsid,title,status,priority长文本从 stdin 读。描述和评论里有换行和引号时用 stdin 而不是拼命令行multica issue create --title Upgrade notes --description-stdin notes.md multica issue comment add MUL-123 --content-stdin review.md按 metadata 和自定义属性过滤。--metadata可重复、多条件之间是 AND值会做类型嗅探true/false变 bool数字变 number其余为 string需要强制字符串时包一层引号如42multica issue list --metadata pr_number482 --metadata is_blockedtrue multica issue list --property ImpactHigh --property ImpactMedium multica issue list --property Impact__none__ --status in_review按 ID 指派避免重名。--to做成员/agent/squad 的模糊名匹配名字重叠时用--to-id uuidUUID 可以从multica workspace member list --output json/multica agent list --output json的返回里取multica issue assign MUL-123 --to-id 5fb87ac7-23b5-4a7a-81fa-ed295a54545d multica issue create --title Fix login bug --assignee-id 5fb87ac7-23b5-4a7a-81fa-ed295a54545d状态命令的合法取值是backlog、todo、in_progress、in_review、done、blocked、cancelled。轮询运行进度。拿到 run 的 task ID 后issue runs默认打印短前缀--full-id出完整 UUID短 task 前缀需要配--issue指定所属 issue用--since做增量拉取multica issue run-messages task-id --output json multica issue run-messages task-id --since 42 --output json脚本化 agent 管理multica agent list multica agent list --output json multica agent get agent-id新建 agent 时--name和--runtime-id是必填项runtime 决定 agent 在哪台机器上用哪个 AI coding tool 执行multica agent create \ --name Frontend Reviewer \ --runtime-id runtime-id \ --description Reviews frontend pull requests \ --instructions Read the diff and tests first; post review conclusions only as issue comments.runtime-id从multica runtime list的输出里取。可选参数还有--model、--thinking-level、--mcp-config、--permission-mode、--max-concurrent-tasks等。注意命令参数里的明文会留在 shell history敏感内容如自定义环境变量应走 stdin 或权限受限的文件。配置相似的 agent 不必重建直接复制原文档示例中的agent-id替换为你agent list拿到的 IDmultica agent copy agent-id副本默认留在同一 runtime跨 runtime 复制要同时给--runtime-id和--model。环境变量、MCP 配置和runtime_config永远不会被复制需要在副本上用create时相同的 flag 重新提供。已有 agent 的自定义环境变量仅 owner/admin 可读写multica agent env get agent-id multica agent env set agent-id用 profile 隔离多环境同一台机器要同时连 production 和 staging或 Cloud 和自托管时用命名 profile 隔离一套独立的服务器地址、token、默认 workspace 和 daemon 状态multica setup self-host --profile staging \ --server-url https://api.staging.example.com \ --app-url https://staging.example.com multica issue list --profile staging配置文件位置默认 profile 在~/.multica/config.json命名 profile 在~/.multica/profiles/name/config.json。查看当前值multica config show multica config show --profile staging对应的 daemon 也按 profile 启动和查看multica daemon start --profile staging multica daemon status --profile staging --output json multica daemon logs --profile staging每个 profile 有独立的日志、PID 和健康端口。daemon logs会先打印它解析到的日志绝对路径——多 profile 并存时不要凭猜测打开~/.multica/daemon.log。配置解析的优先级链是命令行 flag 环境变量 config.json 内置默认值config set传空字符串可清除已持久化的值例如multica config set poll_interval 。验证与限制跑完脚本后用这几条命令做端到端确认multica auth status multica daemon status --output json multica config showauth status显示服务器、用户与 token 状态daemon status --output json给出 PID、运行时长、检测到的 agent 和被监听的 workspace。如果连接层有问题Troubleshooting 给出的第一组排查命令就是这四条multica version、multica auth status、multica daemon status --output json、multica daemon logs --lines 100。最后三条必须写进脚本约定里的限制配置文件含 token。CLI 配置里存的是能代表你访问 Multica 的 PAT不要提交到仓库、上传日志或分享给他人。不要在宿主机 shell / Compose 服务 / 容器 entrypoint 里设置MULTICA_DAEMON_PORT。宿主 daemon 会自己从--profile推导健康端口并向 agent 任务注入该变量旧版本0.4.22、0.4.23在宿主机设了它会拒绝登录新版本也会让普通 API 和 profile 解析命令保持 fail-closed 直到移除该变量。agent 任务内的 CLI 是另一套上下文。当 CLI 运行在 daemon 托管的 agent 任务中时它不读写人类的 profile 文件改用 daemon 注入的任务级临时凭证mat_前缀认证login、logout、setup、workspace switch、daemon start/stop/restart等人类命令在该上下文不可用。你的脚本如果运行在 agent 任务里不要假设能--profile切换或改配置。后续可以沿 Command reference 里的完整命令表扩展project、autopilot、label、skill等对象每个命令支持哪些分页与输出参数以multica command --help为准。【免费下载链接】multicaMake humans and AI agents work as one team — open-source and self-hostable.项目地址: https://gitcode.com/GitHub_Trending/mu/multica创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考