fix: simplify agentrun cli entrypoints

This commit is contained in:
Codex
2026-06-11 00:41:20 +00:00
parent 4068d64555
commit 23e2a6e3e2
22 changed files with 342 additions and 199 deletions
+10 -10
View File
@@ -1,6 +1,6 @@
---
name: unidesk-cicd
description: UniDesk CI/CD 控制面 — `hwlab g14``agentrun v01` 子命令,覆盖 PR 监控自动合并、Tekton/Argo 控制面、git-mirror、Secret、observability、CI tools image、PipelineRun 清理和 AgentRun v0.1 部署。用户提到 CI/CD、deploy、rollout、PipelineRun、trigger、git-mirror、control-plane、k3s 部署、agentrun 部署、hwlab g14、monitor-prs、trigger-current 时使用。任何需要把代码变更推送部署到 G14 k3s 的操作都必须走本 skill。
description: UniDesk CI/CD 控制面 — `hwlab g14``agentrun` 子命令,覆盖 PR 监控自动合并、Tekton/Argo 控制面、git-mirror、Secret、observability、CI tools image、PipelineRun 清理和 AgentRun v0.1 部署。用户提到 CI/CD、deploy、rollout、PipelineRun、trigger、git-mirror、control-plane、k3s 部署、agentrun 部署、hwlab g14、monitor-prs、trigger-current 时使用。任何需要把代码变更推送部署到 G14 k3s 的操作都必须走本 skill。
---
# UniDesk HWLAB G14 CI/CD CLI
@@ -191,15 +191,15 @@ bun scripts/cli.ts hwlab g14 record-rollout --pr <number> --source-commit <sha>
## AgentRun v0.1 控制面
```bash
bun scripts/cli.ts agentrun v01 control-plane status \
bun scripts/cli.ts agentrun control-plane status \
[--dry-run|--confirm]
bun scripts/cli.ts agentrun v01 control-plane trigger-current \
bun scripts/cli.ts agentrun control-plane trigger-current \
[--dry-run|--confirm]
bun scripts/cli.ts agentrun v01 control-plane refresh \
bun scripts/cli.ts agentrun control-plane refresh \
[--dry-run|--confirm]
bun scripts/cli.ts agentrun v01 control-plane cleanup-runs \
bun scripts/cli.ts agentrun control-plane cleanup-runs \
[--min-age-minutes N] [--limit N] [--dry-run|--confirm]
bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs \
bun scripts/cli.ts agentrun control-plane cleanup-released-pvs \
[--limit N] [--dry-run|--confirm]
```
@@ -209,14 +209,14 @@ bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs \
- `cleanup-runs`: 只清理 `agentrun-ci` 中已完成 PipelineRun + 临时 PVC;不清理 `agentrun-v01` runtime runner Job/Pod/Secret
- `cleanup-released-pvs`: 回收 Released PV
AgentRun `control-plane status` 的 compact JSON 关键字段在 `.data.sourceCommit``.data.expectedPipelineRun``.data.runtimeAlignment``.data.gitMirror.summary` 等位置,不要假设存在 `.data.status`。触发部署后如果 GitOps 已 promotion 但 git mirror `pendingFlush=true`,先执行 `bun scripts/cli.ts agentrun v01 git-mirror flush --confirm --wait`,再 `control-plane refresh --confirm`,最后用 `control-plane status --full` 证明 `runtimeAlignment.localHeadMatchesOrigin=true``syncedToGitopsLatest=true``managerSourceMatchesExpected=true`
AgentRun `control-plane status` 的 compact JSON 关键字段在 `.data.sourceCommit``.data.expectedPipelineRun``.data.runtimeAlignment``.data.gitMirror.summary` 等位置,不要假设存在 `.data.status`。触发部署后如果 GitOps 已 promotion 但 git mirror `pendingFlush=true`,先执行 `bun scripts/cli.ts agentrun git-mirror flush --confirm --wait`,再 `control-plane refresh --confirm`,最后用 `control-plane status --full` 证明 `runtimeAlignment.localHeadMatchesOrigin=true``syncedToGitopsLatest=true``managerSourceMatchesExpected=true`
## AgentRun v0.1 Git Mirror
```bash
bun scripts/cli.ts agentrun v01 git-mirror status [--full|--raw]
bun scripts/cli.ts agentrun v01 git-mirror sync [--dry-run|--confirm] [--wait]
bun scripts/cli.ts agentrun v01 git-mirror flush [--dry-run|--confirm] [--wait]
bun scripts/cli.ts agentrun git-mirror status [--full|--raw]
bun scripts/cli.ts agentrun git-mirror sync [--dry-run|--confirm] [--wait]
bun scripts/cli.ts agentrun git-mirror flush [--dry-run|--confirm] [--wait]
```
- `status`: 返回 `localV01`/`githubV01`/`localGitops`/`githubGitops`/`pendingFlush`/`githubInSync`
+43 -18
View File
@@ -1,13 +1,13 @@
---
name: unidesk-code-queue
description: UniDesk AgentRun-backed Code Queue CLI — legacy `codex` 子命令只保留历史只读/残留停止/prompt-lint;新任务提交、Aipod/Artificer 派单、steer、resume、queue mutation、session trace/output/read/cancel 和 HWLAB Code Agent/CaseRun follow-up 必须使用 `agentrun v01 queue|sessions|aipod-specs`。用户提到 codex、Code Queue、submit、steer、resume、tasks、unread、code-queue、aipod、Artificer、HWLAB Code Agent 时使用。
description: UniDesk AgentRun-backed Code Queue CLI — Skill(cli-spec)。legacy `codex` 子命令只保留历史只读/残留停止/prompt-lint;新任务提交、Aipod/Artificer 派单、steer、resume、queue mutation、session trace/output/read/cancel、run/command/runner 状态 drill-down 和 HWLAB Code Agent/CaseRun follow-up 必须使用 `agentrun queue|runs|commands|runner|sessions|aipod-specs`。用户提到 codex、Code Queue、submit、steer、resume、tasks、unread、code-queue、aipod、Artificer、HWLAB Code Agent 时使用。
---
# UniDesk Code Queue / AgentRun CLI
旧 Code Queue 已冻结新任务和写入口。`bun scripts/cli.ts codex ...` 现在只作为历史归档、只读排障、残留任务停止和 prompt-lint 入口;新的指挥官派单、Aipod/Artificer 执行、trace/output、read/cancel、steer/reuse 必须走 AgentRun Queue/Sessions/AipodSpec。
旧 Code Queue 已冻结新任务和写入口。`bun scripts/cli.ts codex ...` 现在只作为历史归档、只读排障、残留任务停止和 prompt-lint 入口;新的指挥官派单、Aipod/Artificer 执行、trace/output、read/cancel、steer/reuse 必须走 AgentRun Queue/Runs/Commands/Runner/Sessions/AipodSpec,并按 cli-spec 渐进披露
**固定入口前缀**: `cd /root/unidesk && bun scripts/cli.ts codex ...`
**固定入口前缀**: `cd /root/unidesk && bun scripts/cli.ts agentrun ...`
---
@@ -15,15 +15,27 @@ description: UniDesk AgentRun-backed Code Queue CLI — legacy `codex` 子命令
```bash
# 查看 AgentRun 指挥官队列
bun scripts/cli.ts agentrun v01 queue commander --reader-id <id>
bun scripts/cli.ts agentrun queue commander --reader-id <id>
bun scripts/cli.ts agentrun queue commander --reader-id <id> --full
# 按已有 CLI 组合查看一个 Aipod/Queue run 生命周期;不要新增 queue lifecycle 命令
bun scripts/cli.ts agentrun queue show <taskId>
bun scripts/cli.ts agentrun queue show <taskId> --full
bun scripts/cli.ts agentrun runs show <runId>
bun scripts/cli.ts agentrun runs result <runId> --command-id <commandId>
bun scripts/cli.ts agentrun runs events <runId> --after-seq <lastSeq> --limit 100 --tail-summary
bun scripts/cli.ts agentrun commands show <commandId> --run-id <runId>
bun scripts/cli.ts agentrun commands result <commandId> --run-id <runId>
bun scripts/cli.ts agentrun runner jobs --run-id <runId> --command-id <commandId>
bun scripts/cli.ts agentrun runner job-status <runnerJobId> --run-id <runId>
# 查看 / 渲染 AipodSpecArtificer 是默认分布式开发 agent
bun scripts/cli.ts agentrun v01 aipod-specs list
bun scripts/cli.ts agentrun v01 aipod-specs show Artificer
bun scripts/cli.ts agentrun v01 aipod-specs render Artificer --prompt-stdin
bun scripts/cli.ts agentrun aipod-specs list
bun scripts/cli.ts agentrun aipod-specs show Artificer
bun scripts/cli.ts agentrun aipod-specs render Artificer --prompt-stdin
# 提交 AgentRun Queue payload
bun scripts/cli.ts agentrun v01 queue submit --json-stdin <<'JSON'
bun scripts/cli.ts agentrun queue submit --json-stdin <<'JSON'
{
"tenantId": "unidesk",
"projectId": "example",
@@ -36,24 +48,37 @@ bun scripts/cli.ts agentrun v01 queue submit --json-stdin <<'JSON'
JSON
# 用 AipodSpec 提交,优先用于新任务和 Artificer
bun scripts/cli.ts agentrun v01 queue submit --aipod Artificer \
bun scripts/cli.ts agentrun queue submit --aipod Artificer \
--prompt-stdin --idempotency-key <key>
# 查看/控制 AgentRun session
bun scripts/cli.ts agentrun v01 sessions trace <sessionId>
bun scripts/cli.ts agentrun v01 sessions output <sessionId>
bun scripts/cli.ts agentrun v01 sessions read <sessionId>
bun scripts/cli.ts agentrun v01 sessions turn <sessionId> --aipod Artificer --prompt-stdin
bun scripts/cli.ts agentrun v01 sessions steer <sessionId> --prompt-stdin
bun scripts/cli.ts agentrun v01 sessions cancel <sessionId>
bun scripts/cli.ts agentrun sessions trace <sessionId>
bun scripts/cli.ts agentrun sessions output <sessionId>
bun scripts/cli.ts agentrun sessions read <sessionId>
bun scripts/cli.ts agentrun sessions turn <sessionId> --aipod Artificer --prompt-stdin
bun scripts/cli.ts agentrun sessions steer <sessionId> --prompt-stdin
bun scripts/cli.ts agentrun sessions cancel <sessionId>
```
日常一次性 JSON、prompt 和 runner JSON 输入优先使用 quoted heredoc/stdin`--json-stdin``--prompt-stdin``--runner-json-stdin``--*-file -`。UniDesk bridge 会把 stdin 直通 G14 `/root/agentrun-v01` 官方 `./scripts/agentrun --manager-url auto` CLI,不先落 dump 文件;`--json-file``--prompt-file``--runner-json-file` 只用于已审阅且可复用的受控文件。它不是旧 Code Queue adapter,不双写,也不迁移旧历史。
`AipodSpec` 是 AgentRun v0.1 的声明式 agent 装配:模型 profile、gitbundle、skills/tools、SecretRef 和 tool credential 都从 YAML 规格渲染。`Artificer` 默认用于 UniDesk 分布式开发任务,使用 `sub2api` provider、`gpt-5.5``reasoningEffort=xhigh`,并通过 SecretRef 注入 GitHub PR token、GitHub SSH 和 UniDesk SSH 透传能力。更新规格时使用 `agentrun v01 aipod-specs apply --yaml-stdin --dry-run` 先看计划,确认后再去掉 `--dry-run`;不得把 API key、SSH key 或 token 写入 prompt、payload、YAML 或 issue。
`AipodSpec` 是 AgentRun v0.1 的声明式 agent 装配:模型 profile、gitbundle、skills/tools、SecretRef 和 tool credential 都从 YAML 规格渲染。`Artificer` 默认用于 UniDesk 分布式开发任务,使用 `sub2api` provider、`gpt-5.5``reasoningEffort=xhigh`,并通过 SecretRef 注入 GitHub PR token、GitHub SSH 和 UniDesk SSH 透传能力。更新规格时使用 `agentrun aipod-specs apply --yaml-stdin --dry-run` 先看计划,确认后再去掉 `--dry-run`;不得把 API key、SSH key 或 token 写入 prompt、payload、YAML 或 issue。
AgentRun Queue payload 需要 runner 内使用 UniDesk SSH 透传时,只通过 `executionPolicy.secretScope.toolCredentials[].tool=unidesk-ssh` 请求 `agentrun-v01-tool-unidesk-ssh/UNIDESK_SSH_CLIENT_TOKEN` SecretRef;不要把 token 写入 prompt、payload 或 `transientEnv`。非敏感 endpoint 使用 `UNIDESK_MAIN_SERVER_IP``UNIDESK_MAIN_SERVER_HOST``UNIDESK_FRONTEND_URL`,可由 runner-job `transientEnv` 显式提供;G14 `agentrun-v01` manager 也会在缺省时按受控默认值自动补齐,并在 trace 中只显示 env name/count/hash 与 `valuesPrinted=false`
## Queue 渐进披露
AgentRun queue 生命周期不是一个单独的 `queue lifecycle` 命令,而是一组现有 CLI 的渐进披露组合:
1. 默认总览用 `queue commander --reader-id <id>`,只看 active/unread/terminal 摘要和少量任务行。
2. 单任务用 `queue show <taskId>`,读取 `latestAttempt.runId``commandId``runnerJobId``sessionId/sessionPath`、Aipod metadata 和 `pollCommands`
3. Run 级状态用 `runs show <runId>``runs result <runId> --command-id <commandId>`,判断 claimed、lease、stale、terminalClassification、failureKind、provider interruption、timeoutBudget 和 recoveryActions。
4. Command 级状态用 `commands show <commandId> --run-id <runId>``commands result <commandId> --run-id <runId>`,确认 command state、ack、terminal status 和结果摘要。
5. Runner job 只读状态用 `runner jobs --run-id <runId> --command-id <commandId>``runner job-status <runnerJobId> --run-id <runId>`,确认 env image reuse、jobName、namespace、phase、exitCode、retention 和 `valuesPrinted=false`。不要为了这些字段手动调用 `trans G14:k3s kubectl ...`
6. Session trace/output 只在 `queue show` 或 result 里有实际 `sessionId` 时使用 `sessions trace|output|read|steer|cancel``sessionRef=null` 时不要猜 session 命令。
默认视图必须低噪声,`--full` 展开结构化详情,`--raw` 才保留原始响应;命令返回里的 drill-down 应优先是 `bun scripts/cli.ts agentrun ...`,不得把人工 k8s 查询作为日常下一步。
## HWLAB Code Agent 入口整合
HWLAB Code Agent / CaseRun follow-up 的日常派单也归入 AgentRun Queue/Sessions:新任务用 `queue submit --aipod Artificer` 或包含 HWLAB gitbundle 的 `queue submit --json-stdin`;运行中纠偏用 `sessions steer``sessions turn --aipod Artificer`。需要验证 HWLAB Web/Cloud API 原入口时,仍按 `$hwlab-code-agent` 使用 G14 `/root/hwlab-v02``hwlab-cli client agent ...` 拉取同一 trace/result/inspect;不要回到旧 `codex submit/resume/steer`
@@ -86,7 +111,7 @@ bun scripts/cli.ts codex move <taskId> --queue <queueId>
bun scripts/cli.ts codex tasks --view commander [--limit N]
```
返回旧 Code Queue 历史/残留任务的有界 action mapactive runners 计数、少量 active item、queued/retry_wait 计数、terminal-unread 总数、关键风险计数、分类计数和 drill-down 命令。新任务队列状态用 `agentrun v01 queue commander`
返回旧 Code Queue 历史/残留任务的有界 action mapactive runners 计数、少量 active item、queued/retry_wait 计数、terminal-unread 总数、关键风险计数、分类计数和 drill-down 命令。新任务队列状态用 `agentrun queue commander`
### Supervisor(分区视图)
@@ -164,7 +189,7 @@ bun scripts/cli.ts codex interrupt <taskId>
bun scripts/cli.ts codex cancel <taskId>
```
仅用于停止旧 Code Queue 残留任务;新 AgentRun session 使用 `bun scripts/cli.ts agentrun v01 sessions cancel <sessionId>`
仅用于停止旧 Code Queue 残留任务;新 AgentRun session 使用 `bun scripts/cli.ts agentrun sessions cancel <sessionId>`
---