nx-ci-monitor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCI Monitor Command
CI 监控命令
You are the orchestrator for monitoring Nx Cloud CI pipeline executions and handling self-healing fixes. You spawn the subagent to poll CI status and make decisions based on the results.
ci-watcher你是监控Nx Cloud CI流水线执行情况并处理自愈修复的协调器。你将启动子代理来轮询CI状态,并根据结果做出决策。
ci-watcherContext
上下文信息
- Current Branch: !
git branch --show-current - Current Commit: !
git rev-parse --short HEAD - Remote Status: !
git status -sb | head -1
- 当前分支: !
git branch --show-current - 当前提交: !
git rev-parse --short HEAD - 远程状态: !
git status -sb | head -1
User Instructions
用户指令
$ARGUMENTS
Important: If user provides specific instructions, respect them over default behaviors described below.
$ARGUMENTS
重要提示: 如果用户提供了特定指令,请优先遵循用户指令,而非以下默认行为。
Configuration Defaults
配置默认值
| 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 |
Parse any overrides from and merge with defaults.
$ARGUMENTS| 设置项 | 默认值 | 说明 |
|---|---|---|
| 10 | 超时前的最大CIPE循环次数 |
| 120 | 最大持续时长(分钟) |
| medium | 输出级别:minimal(极简)、medium(中等)、verbose(详细) |
| (自动检测) | 要监控的分支 |
| 60 | 子代理轮询超时时间(分钟) |
| false | 忽略之前的上下文,重新开始 |
| false | 尝试修复CIPE执行前的常见问题(如锁文件更新) |
| 10 | 执行操作后等待新CIPE生成的时长(分钟) |
| 3 | 推送到CI前的本地验证+优化循环的最大次数 |
解析中的任何覆盖配置,并与默认值合并。
$ARGUMENTSNx Cloud Connection Check
Nx Cloud 连接检查
CRITICAL: Before starting the monitoring loop, verify the workspace is connected to Nx Cloud.
关键步骤: 在启动监控循环前,需验证工作区已连接到Nx Cloud。
Step 0: Verify Nx Cloud Connection
步骤0:验证Nx Cloud连接
-
Checkat workspace root for
nx.jsonornxCloudIdnxCloudAccessToken -
Ifmissing OR neither property exists → exit with:
nx.json[ci-monitor] Nx Cloud not connected. Unlock 70% faster CI and auto-fix broken PRs with https://nx.dev/nx-cloud -
If connected → continue to main loop
-
检查:在工作区根目录查看是否存在
nx.json或nxCloudId字段nxCloudAccessToken -
如果缺失或两个字段都不存在 → 退出并提示:
nx.json[ci-monitor] Nx Cloud未连接。访问https://nx.dev/nx-cloud可解锁70%更快的CI速度,并实现PR自动修复功能 -
如果已连接 → 进入主循环
Session Context Behavior
会话上下文行为
Important: Within a Claude Code session, conversation context persists. If you Ctrl+C to interrupt the monitor and re-run , Claude remembers the previous state and may continue from where it left off.
/ci-monitor- To continue monitoring: Just re-run (context is preserved)
/ci-monitor - To start fresh: Use to ignore previous context
/ci-monitor --fresh - For a completely clean slate: Exit Claude Code and restart
claude
重要提示: 在Claude Code会话中,对话上下文会保留。如果你通过Ctrl+C中断监控并重新运行,Claude会记住之前的状态,并可能从中断处继续。
/ci-monitor- 继续监控: 直接重新运行(上下文会被保留)
/ci-monitor - 重新开始: 使用来忽略之前的上下文
/ci-monitor --fresh - 完全重置: 退出Claude Code并重新启动
claude
Default Behaviors by Status
按状态划分的默认行为
The subagent returns with one of the following statuses. This table defines the default behavior for each status. User instructions can override any of these.
| 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 Available Decision Logic
修复可用决策逻辑
When subagent returns , main agent compares vs :
fix_availablefailedTaskIdsverifiedTaskIds当子代理返回时,主代理会对比和:
fix_availablefailedTaskIdsverifiedTaskIdsStep 1: Categorize Tasks
步骤1:任务分类
- Verified tasks = tasks in both AND
failedTaskIdsverifiedTaskIds - Unverified tasks = tasks in but NOT in
failedTaskIdsverifiedTaskIds - E2E tasks = unverified tasks where target contains "e2e" (task format: or
<project>:<target>)<project>:<target>:<config> - Verifiable tasks = unverified tasks that are NOT e2e
- 已验证任务 = 同时存在于和
failedTaskIds中的任务verifiedTaskIds - 未验证任务 = 存在于但不存在于
failedTaskIds中的任务verifiedTaskIds - E2E任务 = 任务名称包含"e2e"的未验证任务(任务格式:或
<project>:<target>)<project>:<target>:<config> - 可验证任务 = 非E2E的未验证任务
Step 2: Determine Path
步骤2:确定处理路径
| 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应用(视为已足够验证) |
| 存在可验证任务 | 本地验证流程 |
Step 3a: Apply via MCP (fully/e2e-only verified)
步骤3a:通过MCP应用(完全验证/仅E2E验证)
- Call
update_self_healing_fix({ shortLink, action: "APPLY" }) - Record , spawn subagent in wait mode
last_cipe_url
- 调用
update_self_healing_fix({ shortLink, action: "APPLY" }) - 记录,启动处于等待模式的子代理
last_cipe_url
Step 3b: Local Verification Flow
步骤3b:本地验证流程
When verifiable (non-e2e) unverified tasks exist:
-
Detect package manager:
- exists →
pnpm-lock.yamlpnpm nx - exists →
yarn.lockyarn nx - Otherwise →
npx nx
-
Run verifiable tasks in parallel:
- Spawn subagents to run each task concurrently
general - Each subagent runs:
<pm> nx run <taskId> - Collect pass/fail results from all subagents
- Spawn
-
Evaluate results:
| Result | Action |
|---|---|
| ALL verifiable tasks pass | Apply via MCP |
| ANY verifiable task fails | Apply-locally + enhance flow |
-
Apply-locally + enhance flow:
- Run
nx apply-locally <shortLink> - Enhance the code to fix failing tasks
- Run failing tasks again to verify fix
- If still failing → increment , loop back to enhance
local_verify_count - If passing → commit and push, record , spawn subagent in wait mode
expected_commit_sha
- Run
-
Track attempts (wraps step 4):
- Increment after each enhance cycle
local_verify_count - If (default: 3):
local_verify_count >= local_verify_attempts-
Get code in commit-able state
-
Commit and push with message indicating local verification failed
-
Report to user:
[ci-monitor] Local verification failed after <N> attempts. Pushed to CI for final validation. Failed: <taskIds> -
Record, spawn subagent in wait mode (let CI be final judge)
expected_commit_sha
-
- Increment
当存在可验证(非E2E)的未验证任务时:
-
检测包管理器:
- 存在→ 使用
pnpm-lock.yamlpnpm nx - 存在→ 使用
yarn.lockyarn nx - 否则 → 使用
npx nx
- 存在
-
并行运行可验证任务:
- 启动子代理来并发运行每个任务
general - 每个子代理执行:
<pm> nx run <taskId> - 收集所有子代理的执行结果(成功/失败)
- 启动
-
评估结果:
| 结果 | 操作 |
|---|---|
| 所有可验证任务执行成功 | 通过MCP应用 |
| 任何可验证任务执行失败 | 本地应用+优化流程 |
-
本地应用+优化流程:
- 执行
nx apply-locally <shortLink> - 优化代码以修复失败的任务
- 重新运行失败的任务以验证修复效果
- 如果仍然失败 → 增加计数,回到优化步骤循环
local_verify_count - 如果执行成功 → 提交并推送,记录,启动处于等待模式的子代理
expected_commit_sha
- 执行
-
跟踪尝试次数(包含步骤4):
- 每次优化循环后增加计数
local_verify_count - 如果(默认值:3):
local_verify_count >= local_verify_attempts-
将代码调整为可提交状态
-
提交并推送,提交信息需说明本地验证失败
-
向用户报告:
[ci-monitor] 经过<N>次尝试后本地验证失败。已推送到CI进行最终验证。失败任务:<taskIds> -
记录,启动处于等待模式的子代理(让CI作为最终判断)
expected_commit_sha
-
- 每次优化循环后增加
Commit Message Format
提交信息格式
bash
git commit -m "fix(<projects>): <brief description>
Failed tasks: <taskId1>, <taskId2>
Local verification: passed|enhanced|failed-pushing-to-ci"bash
git commit -m "fix(<projects>): <简要描述>
Failed tasks: <taskId1>, <taskId2>
Local verification: passed|enhanced|failed-pushing-to-ci"Unverified Fix Flow (No Verification Attempted)
未验证修复流程(未尝试验证)
When is , , or fix has with no verification:
verificationStatusFAILEDNOT_EXECUTABLEcouldAutoApplyTasks != true- Analyze fix content (,
suggestedFix,suggestedFixReasoning)taskOutputSummary - If fix looks correct → apply via MCP
- If fix needs enhancement → use Apply Locally + Enhance Flow above
- If fix is wrong → reject via MCP, fix from scratch, commit, push
当为、,或修复的且未进行验证时:
verificationStatusFAILEDNOT_EXECUTABLEcouldAutoApplyTasks != true- 分析修复内容(、
suggestedFix、suggestedFixReasoning)taskOutputSummary - 如果修复看起来正确 → 通过MCP应用
- 如果修复需要优化 → 使用上述的本地应用+优化流程
- 如果修复错误 → 通过MCP拒绝,从头修复,提交并推送
Auto-Apply Eligibility
自动应用资格
The field indicates whether the fix is eligible for automatic application:
couldAutoApplyTasks- : Fix is eligible for auto-apply. Subagent keeps polling while verification is in progress. Returns
truewhen verified, orfix_auto_applyingif verification fails.fix_available - or
false: Fix requires manual action (apply via MCP, apply locally, or reject)null
Key point: When subagent returns , do NOT call MCP to apply - self-healing handles it. Just spawn a new subagent in wait mode.
fix_auto_applyingcouldAutoApplyTasks- : 修复符合自动应用条件。子代理在验证过程中会持续轮询。验证通过后返回
true,验证失败则返回fix_auto_applying。fix_available - 或
false: 修复需要手动操作(通过MCP应用、本地应用或拒绝)null
关键点: 当子代理返回时,请勿调用MCP来应用修复 - 自愈系统会处理此事。只需启动一个新的处于等待模式的子代理即可。
fix_auto_applyingApply vs Reject vs Apply Locally
应用 vs 拒绝 vs 本地应用
- Apply via MCP: Calls . Self-healing agent applies the fix in CI and a new CIPE spawns automatically. No local git operations needed.
update_self_healing_fix({ shortLink, action: "APPLY" }) - Apply Locally: Runs . Applies the patch to your local working directory and sets state to
nx apply-locally <shortLink>. Use this when you want to enhance the fix before pushing.APPLIED_LOCALLY - Reject via MCP: Calls . Marks fix as rejected. Use only when the fix is completely wrong and you'll fix from scratch.
update_self_healing_fix({ shortLink, action: "REJECT" })
- 通过MCP应用: 调用。自愈代理会在CI中应用修复,新的CIPE会自动生成。无需本地Git操作。
update_self_healing_fix({ shortLink, action: "APPLY" }) - 本地应用: 执行。将补丁应用到本地工作目录,并将状态设置为
nx apply-locally <shortLink>。当你想在推送前优化修复时使用此方式。APPLIED_LOCALLY - 通过MCP拒绝: 调用。标记修复为已拒绝。仅当修复完全错误且你需要从头修复时使用。
update_self_healing_fix({ shortLink, action: "REJECT" })
Apply Locally + Enhance Flow
本地应用+优化流程
When the fix needs enhancement (use , NOT reject):
nx apply-locally-
Apply the patch locally:(this also updates state to
nx apply-locally <shortLink>)APPLIED_LOCALLY -
Make additional changes as needed
-
Commit and push:bash
git add -A git commit -m "fix: resolve <failedTaskIds>" git push origin $(git branch --show-current) -
Loop to poll for new CIPE
当修复需要优化时(使用,而非拒绝):
nx apply-locally-
本地应用补丁:(这也会将状态更新为
nx apply-locally <shortLink>)APPLIED_LOCALLY -
根据需要进行额外修改
-
提交并推送:bash
git add -A git commit -m "fix: resolve <failedTaskIds>" git push origin $(git branch --show-current) -
循环轮询新的CIPE
Reject + Fix From Scratch Flow
拒绝+从头修复流程
When the fix is completely wrong:
-
Call MCP to reject:
update_self_healing_fix({ shortLink, action: "REJECT" }) -
Fix the issue from scratch locally
-
Commit and push:bash
git add -A git commit -m "fix: resolve <failedTaskIds>" git push origin $(git branch --show-current) -
Loop to poll for new CIPE
当修复完全错误时:
-
调用MCP拒绝修复:
update_self_healing_fix({ shortLink, action: "REJECT" }) -
本地从头修复问题
-
提交并推送:bash
git add -A git commit -m "fix: resolve <failedTaskIds>" git push origin $(git branch --show-current) -
循环轮询新的CIPE
Environment Issue Handling
环境问题处理
When :
failureClassification == 'ENVIRONMENT_STATE'- Call MCP to request rerun:
update_self_healing_fix({ shortLink, action: "RERUN_ENVIRONMENT_STATE" }) - New CIPE spawns automatically (no local git operations needed)
- Loop to poll for new CIPE with set
previousCipeUrl
当时:
failureClassification == 'ENVIRONMENT_STATE'- 调用MCP请求重新运行:
update_self_healing_fix({ shortLink, action: "RERUN_ENVIRONMENT_STATE" }) - 新的CIPE会自动生成(无需本地Git操作)
- 设置并循环轮询新的CIPE
previousCipeUrl
No-New-CIPE Handling
无新CIPE处理
When :
status == 'no_new_cipe'This means the expected CIPE was never created - CI likely failed before Nx tasks could run.
-
Report to user:
[ci-monitor] No CI attempt for <sha> after 10 min. Check CI provider for pre-Nx failures (install, checkout, auth). Last CI attempt: <previousCipeUrl> -
If user configured auto-fix attempts (e.g.,):
--auto-fix-workflow-
Detect package manager: check for,
pnpm-lock.yaml,yarn.lockpackage-lock.json -
Run install to update lockfile:bash
pnpm install # or npm install / yarn install -
If lockfile changed:bash
git add pnpm-lock.yaml # or appropriate lockfile git commit -m "chore: update lockfile" git push origin $(git branch --show-current) -
Record new commit SHA, loop to poll with
expectedCommitSha
-
-
Otherwise: Exit withstatus, providing guidance for user to investigate
no_new_cipe
当时:
status == 'no_new_cipe'这意味着预期的CIPE从未创建 - CI可能在Nx任务执行前就失败了。
-
向用户报告:
[ci-monitor] 等待10分钟后,<sha>仍无CI执行记录。请检查CI提供商的Nx前置阶段失败情况(安装、检出、授权)。上一次CI执行:<previousCipeUrl> -
如果用户配置了自动修复尝试(如):
--auto-fix-workflow-
检测包管理器:检查是否存在、
pnpm-lock.yaml、yarn.lockpackage-lock.json -
执行安装以更新锁文件:bash
pnpm install # 或 npm install / yarn install -
如果锁文件已更改:bash
git add pnpm-lock.yaml # 或对应的锁文件 git commit -m "chore: update lockfile" git push origin $(git branch --show-current) -
记录新的提交SHA,设置并循环轮询
expectedCommitSha
-
-
否则: 以状态退出,为用户提供排查指导
no_new_cipe
Exit Conditions
退出条件
Exit the monitoring loop when ANY of these conditions are met:
| 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且未配置自动修复 | CIPE前置失败 |
| 用户取消 | 已取消 |
Main Loop
主循环
Step 1: Initialize Tracking
步骤1:初始化跟踪
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 = nullStep 2: Spawn Subagent
步骤2:启动子代理
Spawn the subagent to poll CI status:
ci-watcherFresh start (first spawn, no expected CIPE):
Task(
agent: "ci-watcher",
prompt: "Monitor CI for branch '<branch>'.
Subagent timeout: <subagent-timeout> minutes.
New-CIPE timeout: <new-cipe-timeout> minutes.
Verbosity: <verbosity>."
)After action that triggers new CIPE (wait mode):
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状态:
ci-watcher全新启动(首次启动,无预期CIPE):
Task(
agent: "ci-watcher",
prompt: "Monitor CI for branch '<branch>'.
Subagent timeout: <subagent-timeout> minutes.
New-CIPE timeout: <new-cipe-timeout> minutes.
Verbosity: <verbosity>."
)执行触发新CIPE的操作后(等待模式):
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>"
)Step 3: Handle Subagent Response
步骤3:处理子代理响应
When subagent returns:
- Check the returned status
- Look up default behavior in the table above
- Check if user instructions override the default
- Execute the appropriate action
- If action expects new CIPE, update tracking (see Step 3a)
- If action results in looping, go to Step 2
当子代理返回响应时:
- 检查返回的状态
- 查阅上述表格中的默认行为
- 检查用户指令是否覆盖默认行为
- 执行相应操作
- 如果操作预期会生成新CIPE,更新跟踪信息(见步骤3a)
- 如果操作需要循环,回到步骤2
Step 3a: Track State for New-CIPE Detection
步骤3a:跟踪新CIPE检测状态
After actions that should trigger a new CIPE, record state before looping:
| 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 |
CRITICAL: When passing or to the subagent, it enters wait mode:
expectedCommitShalast_cipe_url- Subagent will completely ignore the old/stale CIPE
- Subagent will only wait for new CIPE to appear
- Subagent will NOT return to main agent with stale CIPE data
- Once new CIPE detected, subagent switches to normal polling
Why wait mode matters for context preservation: Stale CIPE data can be very large (task output summaries, suggested fix patches, reasoning). If subagent returns this to main agent, it pollutes main agent's context with useless data since we already processed that CIPE. Wait mode keeps stale data in the subagent, never sending it to main agent.
执行会触发新CIPE的操作后,在循环前记录状态:
| 操作 | 跟踪内容 | 子代理模式 |
|---|---|---|
| 修复自动应用中 | | 等待模式 |
| 通过MCP应用 | | 等待模式 |
| 本地应用+推送 | | 等待模式 |
| 拒绝+修复+推送 | | 等待模式 |
| 修复失败+本地修复+推送 | | 等待模式 |
| 无修复+本地修复+推送 | | 等待模式 |
| 环境问题重新运行 | | 等待模式 |
| 无新CIPE+自动修复+推送 | | 等待模式 |
关键提示: 当向子代理传递或时,子代理会进入等待模式:
expectedCommitShalast_cipe_url- 子代理将完全忽略旧的/过期的CIPE
- 子代理只会等待新的CIPE出现
- 子代理不会向主代理返回过期的CIPE数据
- 检测到新CIPE后,子代理会切换到正常轮询模式
等待模式对上下文保留的重要性: 过期的CIPE数据可能非常庞大(任务输出摘要、建议修复补丁、推理过程)。如果子代理将这些数据返回给主代理,会导致主代理的上下文被无用数据污染,因为我们已经处理过该CIPE。等待模式让过期数据保留在子代理中,不会发送给主代理。
Step 4: Progress Tracking
步骤4:进度跟踪
After each action:
- If state changed significantly → reset
no_progress_count = 0 - If state unchanged →
no_progress_count++ - On new CI attempt detected → reset
local_verify_count = 0
每次操作后:
- 如果状态发生显著变化 → 重置
no_progress_count = 0 - 如果状态未变化 →
no_progress_count++ - 检测到新的CI执行时 → 重置
local_verify_count = 0
Status Reporting
状态报告
Based on verbosity level:
| 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次循环 |
| 包含所有medium级别的内容 + 完整的子代理响应、Git输出、MCP响应 |
User Instruction Examples
用户指令示例
Users can override default behaviors:
| 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" | 在CIPE前置失败时尝试更新锁file |
| "wait 45 min for new CIPE" | 覆盖新CIPE超时时间(默认:10分钟) |
Error Handling
错误处理
| 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 rebase冲突 | 向用户报告并退出 |
| 向用户报告,尝试手动补丁或退出 |
| MCP工具错误 | 重试一次,如果失败则向用户报告 |
| 子代理启动失败 | 重试一次,如果失败则以错误状态退出 |
| 未检测到新CIPE | 如果启用 |
| 锁文件自动修复失败 | 向用户报告,退出并指导用户检查CI日志 |
Example Session
示例会话
Example 1: Normal Flow with Self-Healing (medium verbosity)
示例1:带自愈功能的正常流程(中等详细程度)
[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
- 结果:SUCCESSExample 2: Pre-CI Failure (medium verbosity)
示例2:CI前置失败(中等详细程度)
[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