Loading...
Loading...
Compare original and translation side by side
ci-watcherci-watchergit branch --show-currentgit rev-parse --short HEADgit status -sb | head -1git branch --show-currentgit rev-parse --short HEADgit status -sb | head -1| Setting | Default | Description |
|---|---|---|
| 10 | Maximum CIPE cycles before timeout |
| 120 | Maximum duration in minutes |
| medium | Output level: minimal, medium, verbose |
| (auto-detect) | Branch to monitor |
| 60 | Subagent polling timeout in minutes |
| false | Ignore previous context, start fresh |
| false | Attempt common fixes for pre-CIPE failures (e.g., lockfile updates) |
| 10 | Minutes to wait for new CIPE after action |
| 3 | Max local verification + enhance cycles before pushing to CI |
$ARGUMENTS| 设置项 | 默认值 | 说明 |
|---|---|---|
| 10 | 超时前的最大CIPE循环次数 |
| 120 | 最大持续时长(分钟) |
| medium | 输出级别:minimal(极简)、medium(中等)、verbose(详细) |
| (自动检测) | 要监控的分支 |
| 60 | 子代理轮询超时时间(分钟) |
| false | 忽略之前的上下文,重新开始 |
| false | 尝试修复CIPE执行前的常见问题(如锁文件更新) |
| 10 | 执行操作后等待新CIPE生成的时长(分钟) |
| 3 | 推送到CI前的本地验证与优化循环的最大次数 |
$ARGUMENTSnx.jsonnxCloudIdnxCloudAccessTokennx.json[ci-monitor] Nx Cloud not connected. Unlock 70% faster CI and auto-fix broken PRs with https://nx.dev/nx-cloudnx.jsonnxCloudIdnxCloudAccessTokennx.json[ci-monitor] Nx Cloud 未连接。通过 https://nx.dev/nx-cloud 解锁70%更快的CI速度和自动修复损坏PR的功能/ci-monitor/ci-monitor/ci-monitor --freshclaude/ci-monitor/ci-monitor/ci-monitor --freshclaude| Status | Default Behavior |
|---|---|
| Exit with success. Log "CI passed successfully!" |
| Fix will be auto-applied by self-healing. Do NOT call MCP. Record |
| Compare |
| Self-healing failed to generate fix. Attempt local fix based on |
| Call MCP to request rerun: |
| CI failed, no fix available (self-healing disabled or not executable). Attempt local fix if possible. Otherwise exit with failure. |
| Expected CIPE never spawned (CI workflow likely failed before Nx tasks). Report to user, attempt common fixes if configured, or exit with guidance. |
| Subagent polling timeout reached. Exit with timeout. |
| CIPE was canceled. Exit with canceled status. |
| CIPE timed out. Exit with timeout status. |
| Increment |
| 状态 | 默认行为 |
|---|---|
| 成功退出。日志输出"CI 执行成功!" |
| 修复将通过自愈功能自动应用。请勿调用MCP。记录 |
| 对比 |
| 自愈功能生成修复失败。根据 |
| 调用MCP请求重新运行: |
| CI执行失败,无可用修复(自愈功能已禁用或无法执行)。如果可能,尝试本地修复。否则退出并标记为失败。 |
| 预期的CIPE从未生成(CI工作流可能在Nx任务执行前就已失败)。向用户报告,如果已配置则尝试常见修复,或退出并提供指导。 |
| 子代理轮询超时。退出并标记为超时。 |
| CIPE已被取消。退出并标记为已取消。 |
| CIPE超时。退出并标记为超时。 |
| 增加 |
fix_availablefailedTaskIdsverifiedTaskIdsfix_availablefailedTaskIdsverifiedTaskIdsfailedTaskIdsverifiedTaskIdsfailedTaskIdsverifiedTaskIds<project>:<target><project>:<target>:<config>failedTaskIdsverifiedTaskIdsfailedTaskIdsverifiedTaskIds<project>:<target><project>:<target>:<config>| Condition | Path |
|---|---|
| No unverified tasks (all verified) | Apply via MCP |
| Unverified tasks exist, but ALL are e2e | Apply via MCP (treat as verified enough) |
| Verifiable tasks exist | Local verification flow |
| 条件 | 处理路径 |
|---|---|
| 无未验证任务(全部已验证) | 通过MCP应用修复 |
| 存在未验证任务,但全部为E2E任务 | 通过MCP应用修复(视为已充分验证) |
| 存在可验证任务 | 本地验证流程 |
update_self_healing_fix({ shortLink, action: "APPLY" })last_cipe_urlupdate_self_healing_fix({ shortLink, action: "APPLY" })last_cipe_urlpnpm-lock.yamlpnpm nxyarn.lockyarn nxnpx nxgeneral<pm> nx run <taskId>| Result | Action |
|---|---|
| ALL verifiable tasks pass | Apply via MCP |
| ANY verifiable task fails | Apply-locally + enhance flow |
nx apply-locally <shortLink>local_verify_countexpected_commit_shalocal_verify_countlocal_verify_count >= local_verify_attempts[ci-monitor] Local verification failed after <N> attempts. Pushed to CI for final validation. Failed: <taskIds>expected_commit_shapnpm-lock.yamlpnpm nxyarn.lockyarn nxnpx nxgeneral<pm> nx run <taskId>| 结果 | 操作 |
|---|---|
| 所有可验证任务执行成功 | 通过MCP应用修复 |
| 任一可验证任务执行失败 | 本地应用+优化流程 |
nx apply-locally <shortLink>local_verify_countexpected_commit_shalocal_verify_countlocal_verify_count >= local_verify_attempts[ci-monitor] 本地验证在<N>次尝试后失败。已推送到CI进行最终验证。失败任务:<taskIds>expected_commit_shagit commit -m "fix(<projects>): <brief description>
Failed tasks: <taskId1>, <taskId2>
Local verification: passed|enhanced|failed-pushing-to-ci"git commit -m "fix(<projects>): <简要描述>
失败任务: <taskId1>, <taskId2>
本地验证: passed|enhanced|failed-pushing-to-ci"verificationStatusFAILEDNOT_EXECUTABLEcouldAutoApplyTasks != truesuggestedFixsuggestedFixReasoningtaskOutputSummaryverificationStatusFAILEDNOT_EXECUTABLEcouldAutoApplyTasks != truesuggestedFixsuggestedFixReasoningtaskOutputSummarycouldAutoApplyTaskstruefix_auto_applyingfix_availablefalsenullfix_auto_applyingcouldAutoApplyTaskstruefix_auto_applyingfix_availablefalsenullfix_auto_applyingupdate_self_healing_fix({ shortLink, action: "APPLY" })nx apply-locally <shortLink>APPLIED_LOCALLYupdate_self_healing_fix({ shortLink, action: "REJECT" })update_self_healing_fix({ shortLink, action: "APPLY" })nx apply-locally <shortLink>APPLIED_LOCALLYupdate_self_healing_fix({ shortLink, action: "REJECT" })nx apply-locallynx apply-locally <shortLink>APPLIED_LOCALLYgit add -A
git commit -m "fix: resolve <failedTaskIds>"
git push origin $(git branch --show-current)nx apply-locallynx apply-locally <shortLink>APPLIED_LOCALLYgit add -A
git commit -m "fix: resolve <failedTaskIds>"
git push origin $(git branch --show-current)update_self_healing_fix({ shortLink, action: "REJECT" })git add -A
git commit -m "fix: resolve <failedTaskIds>"
git push origin $(git branch --show-current)update_self_healing_fix({ shortLink, action: "REJECT" })git add -A
git commit -m "fix: resolve <failedTaskIds>"
git push origin $(git branch --show-current)failureClassification == 'ENVIRONMENT_STATE'update_self_healing_fix({ shortLink, action: "RERUN_ENVIRONMENT_STATE" })previousCipeUrlfailureClassification == 'ENVIRONMENT_STATE'update_self_healing_fix({ shortLink, action: "RERUN_ENVIRONMENT_STATE" })previousCipeUrlstatus == 'no_new_cipe'[ci-monitor] No CI attempt for <sha> after 10 min. Check CI provider for pre-Nx failures (install, checkout, auth). Last CI attempt: <previousCipeUrl>--auto-fix-workflowpnpm-lock.yamlyarn.lockpackage-lock.jsonpnpm install # or npm install / yarn installgit add pnpm-lock.yaml # or appropriate lockfile
git commit -m "chore: update lockfile"
git push origin $(git branch --show-current)expectedCommitShano_new_cipestatus == 'no_new_cipe'[ci-monitor] 等待10分钟后,<sha>仍无CI执行记录。请检查CI提供商的Nx前阶段失败情况(安装、检出、认证)。上次CI执行记录:<previousCipeUrl>--auto-fix-workflowpnpm-lock.yamlyarn.lockpackage-lock.jsonpnpm install # 或 npm install / yarn installgit add pnpm-lock.yaml # 或对应的锁文件
git commit -m "chore: update lockfile"
git push origin $(git branch --show-current)expectedCommitShano_new_cipe| Condition | Exit Type |
|---|---|
CI passes ( | Success |
| Max CIPE cycles reached | Timeout |
| Max duration reached | Timeout |
| 3 consecutive no-progress iterations | Circuit breaker |
| No fix available and local fix not possible | Failure |
| No new CIPE and auto-fix not configured | Pre-CIPE failure |
| User cancels | Cancelled |
| 条件 | 退出类型 |
|---|---|
CI执行成功 ( | 成功 |
| 达到最大CIPE循环次数 | 超时 |
| 达到最大持续时长 | 超时 |
| 连续3次无进展迭代 | 熔断机制 |
| 无可用修复且本地修复不可行 | 失败 |
| 无新CIPE且未配置自动修复 | CI前阶段失败 |
| 用户取消 | 已取消 |
cycle_count = 0
start_time = now()
no_progress_count = 0
local_verify_count = 0
last_state = null
last_cipe_url = null
expected_commit_sha = nullcycle_count = 0
start_time = now()
no_progress_count = 0
local_verify_count = 0
last_state = null
last_cipe_url = null
expected_commit_sha = nullci-watcherTask(
agent: "ci-watcher",
prompt: "Monitor CI for branch '<branch>'.
Subagent timeout: <subagent-timeout> minutes.
New-CIPE timeout: <new-cipe-timeout> minutes.
Verbosity: <verbosity>."
)Task(
agent: "ci-watcher",
prompt: "Monitor CI for branch '<branch>'.
Subagent timeout: <subagent-timeout> minutes.
New-CIPE timeout: <new-cipe-timeout> minutes.
Verbosity: <verbosity>.
WAIT MODE: A new CIPE should spawn. Ignore old CIPE until new one appears.
Expected commit SHA: <expected_commit_sha>
Previous CIPE URL: <last_cipe_url>"
)ci-watcherTask(
agent: "ci-watcher",
prompt: "Monitor CI for branch '<branch>'.
Subagent timeout: <subagent-timeout> minutes.
New-CIPE timeout: <new-cipe-timeout> minutes.
Verbosity: <verbosity>."
)Task(
agent: "ci-watcher",
prompt: "Monitor CI for branch '<branch>'.
Subagent timeout: <subagent-timeout> minutes.
New-CIPE timeout: <new-cipe-timeout> minutes.
Verbosity: <verbosity>.
WAIT MODE: A new CIPE should spawn. Ignore old CIPE until new one appears.
Expected commit SHA: <expected_commit_sha>
Previous CIPE URL: <last_cipe_url>"
)| Action | What to Track | Subagent Mode |
|---|---|---|
| Fix auto-applying | | Wait mode |
| Apply via MCP | | Wait mode |
| Apply locally + push | | Wait mode |
| Reject + fix + push | | Wait mode |
| Fix failed + local fix + push | | Wait mode |
| No fix + local fix + push | | Wait mode |
| Environment rerun | | Wait mode |
| No-new-CIPE + auto-fix + push | | Wait mode |
expectedCommitShalast_cipe_url| 操作 | 跟踪内容 | 子代理模式 |
|---|---|---|
| 修复自动应用中 | | 等待模式 |
| 通过MCP应用修复 | | 等待模式 |
| 本地应用+推送 | | 等待模式 |
| 拒绝+修复+推送 | | 等待模式 |
| 修复失败+本地修复+推送 | | 等待模式 |
| 无可用修复+本地修复+推送 | | 等待模式 |
| 环境问题重新运行 | | 等待模式 |
| 无新CIPE+自动修复+推送 | | 等待模式 |
expectedCommitShalast_cipe_urlno_progress_count = 0no_progress_count++local_verify_count = 0no_progress_count = 0no_progress_count++local_verify_count = 0| Level | What to Report |
|---|---|
| Only final result (success/failure/timeout) |
| State changes + periodic updates ("Cycle N | Elapsed: Xm | Status: ...") |
| All of medium + full subagent responses, git outputs, MCP responses |
| 级别 | 报告内容 |
|---|---|
| 仅输出最终结果(成功/失败/超时) |
| 状态变化 + 定期更新("第N次循环 | 已耗时: X分钟 | 状态: ...") |
| 包含所有medium级别的内容 + 完整子代理响应、Git输出、MCP响应 |
| Instruction | Effect |
|---|---|
| "never auto-apply" | Always prompt before applying any fix |
| "always ask before git push" | Prompt before each push |
| "reject any fix for e2e tasks" | Auto-reject if |
| "apply all fixes regardless of verification" | Skip verification check, apply everything |
| "if confidence < 70, reject" | Check confidence field before applying |
| "run 'nx affected -t typecheck' before applying" | Add local verification step |
| "auto-fix workflow failures" | Attempt lockfile updates on pre-CIPE failures |
| "wait 45 min for new CIPE" | Override new-CIPE timeout (default: 10 min) |
| 指令 | 效果 |
|---|---|
| "never auto-apply" | 应用任何修复前始终提示用户 |
| "always ask before git push" | 每次推送前提示用户 |
| "reject any fix for e2e tasks" | 如果 |
| "apply all fixes regardless of verification" | 跳过验证检查,应用所有修复 |
| "if confidence < 70, reject" | 应用前检查置信度字段 |
| "run 'nx affected -t typecheck' before applying" | 添加本地验证步骤 |
| "auto-fix workflow failures" | 尝试修复CI前阶段失败的问题 |
| "wait 45 min for new CIPE" | 覆盖新CIPE超时时间(默认:10分钟) |
| Error | Action |
|---|---|
| Git rebase conflict | Report to user, exit |
| Report to user, attempt manual patch or exit |
| MCP tool error | Retry once, if fails report to user |
| Subagent spawn failure | Retry once, if fails exit with error |
| No new CIPE detected | If |
| Lockfile auto-fix fails | Report to user, exit with guidance to check CI logs |
| 错误 | 操作 |
|---|---|
| Git变基冲突 | 向用户报告并退出 |
| 向用户报告,尝试手动补丁或退出 |
| MCP工具错误 | 重试一次,如果失败则向用户报告 |
| 子代理启动失败 | 重试一次,如果失败则报错退出 |
| 未检测到新CIPE | 如果已配置 |
| 锁文件自动修复失败 | 向用户报告,退出并指导用户检查CI日志 |
[ci-monitor] Starting CI monitor for branch 'feature/add-auth'
[ci-monitor] Config: max-cycles=5, timeout=120m, verbosity=medium
[ci-monitor] Spawning subagent to poll CI status...
[CI Monitor] CI attempt: IN_PROGRESS | Self-Healing: NOT_STARTED | Elapsed: 1m
[CI Monitor] CI attempt: FAILED | Self-Healing: IN_PROGRESS | Elapsed: 3m
[CI Monitor] CI attempt: FAILED | Self-Healing: COMPLETED | Elapsed: 5m
[ci-monitor] Fix available! Verification: COMPLETED
[ci-monitor] Applying fix via MCP...
[ci-monitor] Fix applied in CI. Waiting for new CI attempt...
[ci-monitor] Spawning subagent to poll CI status...
[CI Monitor] New CI attempt detected!
[CI Monitor] CI attempt: SUCCEEDED | Elapsed: 8m
[ci-monitor] CI passed successfully!
[ci-monitor] Summary:
- Total cycles: 2
- Total time: 12m 34s
- Fixes applied: 1
- Result: SUCCESS[ci-monitor] 开始监控分支'feature/add-auth'的CI状态
[ci-monitor] 配置:max-cycles=5, timeout=120m, verbosity=medium
[ci-monitor] 启动子代理轮询CI状态...
[CI Monitor] CI执行状态:IN_PROGRESS | 自愈功能:NOT_STARTED | 已耗时:1分钟
[CI Monitor] CI执行状态:FAILED | 自愈功能:IN_PROGRESS | 已耗时:3分钟
[CI Monitor] CI执行状态:FAILED | 自愈功能:COMPLETED | 已耗时:5分钟
[ci-monitor] 发现可用修复!验证状态:COMPLETED
[ci-monitor] 通过MCP应用修复...
[ci-monitor] 修复已在CI中应用。等待新CI执行...
[ci-monitor] 启动子代理轮询CI状态...
[CI Monitor] 检测到新CI执行!
[CI Monitor] CI执行状态:SUCCEEDED | 已耗时:8分钟
[ci-monitor] CI执行成功!
[ci-monitor] 摘要:
- 总循环次数: 2
- 总耗时: 12分34秒
- 应用修复次数: 1
- 结果: SUCCESS[ci-monitor] Starting CI monitor for branch 'feature/add-products'
[ci-monitor] Config: max-cycles=5, timeout=120m, auto-fix-workflow=true
[ci-monitor] Spawning subagent to poll CI status...
[CI Monitor] CI attempt: FAILED | Self-Healing: COMPLETED | Elapsed: 2m
[ci-monitor] Applying fix locally, enhancing, and pushing...
[ci-monitor] Committed: abc1234
[ci-monitor] Spawning subagent to poll CI status...
[CI Monitor] Waiting for new CI attempt... (expected SHA: abc1234)
[CI Monitor] ⚠️ CI attempt timeout (10 min). Returning no_new_cipe.
[ci-monitor] Status: no_new_cipe
[ci-monitor] --auto-fix-workflow enabled. Attempting lockfile update...
[ci-monitor] Lockfile updated. Committed: def5678
[ci-monitor] Spawning subagent to poll CI status...
[CI Monitor] New CI attempt detected!
[CI Monitor] CI attempt: SUCCEEDED | Elapsed: 18m
[ci-monitor] CI passed successfully!
[ci-monitor] Summary:
- Total cycles: 3
- Total time: 22m 15s
- Fixes applied: 1 (self-healing) + 1 (lockfile)
- Result: SUCCESS[ci-monitor] 开始监控分支'feature/add-products'的CI状态
[ci-monitor] 配置:max-cycles=5, timeout=120m, auto-fix-workflow=true
[ci-monitor] 启动子代理轮询CI状态...
[CI Monitor] CI执行状态:FAILED | 自愈功能:COMPLETED | 已耗时:2分钟
[ci-monitor] 本地应用修复、优化并推送...
[ci-monitor] 已提交:abc1234
[ci-monitor] 启动子代理轮询CI状态...
[CI Monitor] 等待新CI执行...(预期SHA:abc1234)
[CI Monitor] ⚠️ CI执行超时(10分钟)。返回no_new_cipe状态。
[ci-monitor] 状态:no_new_cipe
[ci-monitor] --auto-fix-workflow已启用。尝试更新锁文件...
[ci-monitor] 锁文件已更新。已提交:def5678
[ci-monitor] 启动子代理轮询CI状态...
[CI Monitor] 检测到新CI执行!
[CI Monitor] CI执行状态:SUCCEEDED | 已耗时:18分钟
[ci-monitor] CI执行成功!
[ci-monitor] 摘要:
- 总循环次数: 3
- 总耗时: 22分15秒
- 应用修复次数: 1(自愈) + 1(锁文件)
- 结果: SUCCESS