feat: add VCS workflows and cycle extension

This commit is contained in:
liujing
2026-07-17 09:07:28 +08:00
parent c9d76d8f58
commit d13f31d9d1
14 changed files with 2335 additions and 189 deletions
+31 -11
View File
@@ -14,11 +14,12 @@ Support these explicit operations:
```text
$agent-workflow-host 执行已确认计划
$agent-workflow-host 使用 claude 执行已确认计划
$agent-workflow-host 使用 svn 执行已确认计划
$agent-workflow-host 继续 <run-id>
$agent-workflow-host 查看 <run-id>
$agent-workflow-host 清理后重试 <run-id>
$agent-workflow-host 执行器重试 <run-id>
$agent-workflow-host 执行器重试 <run-id>
$agent-workflow-host 延长 <run-id> 添加 <n> 个周期
$agent-workflow-host 中止 <run-id> 原因:需求变化
$agent-workflow-host 日志 <run-id> [--follow]
```
@@ -34,15 +35,16 @@ $agent-workflow-host 日志 <run-id> [--follow]
- Codex owns plan normalization, finding classification, verification, and acceptance.
- The executor owns implementation, tests, and fixes. During an active workflow, Codex must not edit target repository files itself.
- `agent-workflow review` only prepares evidence for Codex. Do not invoke another reviewer as an acceptance gate.
- Never run or authorize `git commit`, `git push`, `git reset`, history rewriting, or branch deletion.
- Never run or authorize `git commit`, `git push`, `git reset`, `svn commit`, `svn switch`, `svn update`, history rewriting, or branch deletion.
- Never broaden the approved scope or silently change requirements after start. Abort and create a new plan when requirements materially change.
## Start A Confirmed Plan
1. Resolve the target Git root and inspect the repository before execution.
1. Resolve the target VCS root (Git or SVN) and inspect the repository before execution.
2. Run these preflight checks:
- `command -v agent-workflow`
- `git status --porcelain` must be empty.
- For Git: `git status --porcelain` must be empty.
- For SVN: `svn status` must show a clean working copy with no mixed revisions.
- Probe the selected executor with `<executor> --version`.
- Confirm no unresolved active workflow prevents a new run.
3. Do not install tools, commit, or stash automatically. Report the exact missing prerequisite and stop.
@@ -64,7 +66,7 @@ $agent-workflow-host 日志 <run-id> [--follow]
7. Start the run and record the emitted run ID, then immediately print a logs-follow command the user can run independently:
```bash
agent-workflow start --plan <temp-plan.json> --executor <reasonix|claude|agy>
agent-workflow start --plan <temp-plan.json> --executor <reasonix|claude|agy> [--vcs <git|svn>]
```
After starting, announce:
@@ -72,7 +74,7 @@ After starting, announce:
Run <run-id> started. Monitor live output: agent-workflow logs --run <run-id> --follow
```
Honor an explicit `max-cycles` argument. Otherwise use project configuration and workflow defaults.
Honor an explicit `max-cycles` argument or `--vcs` flag. Otherwise use project configuration and workflow defaults. VCS is auto-detected if not specified.
## Drive The State Machine
@@ -143,24 +145,42 @@ Create `HostDecisionV1` in the temporary directory:
After `fix`, repeat review and decision for the new cycle. Respect the configured cycle budget and the engine's persistence/oscillation stop conditions.
## Resume, Inspect, Or Abort
## Resume, Inspect, Extend, Or Abort
- For `查看 <run-id>`, run `agent-workflow status --run <run-id> --json`, summarize it, and do not advance the workflow.
- For `继续 <run-id>`, read status first, then continue from `awaiting_review`, `awaiting_scope_resolution`, or `awaiting_host`. Read the persisted state and referenced cycle artifacts when earlier command output is no longer in context; do not reconstruct findings from memory.
- For `清理后重试 <run-id>`, run `agent-workflow retry-review --run <run-id>` after the approved scope artifacts have been removed. It must refuse when HEAD drift or out-of-scope paths remain.
- For `执行器重试 <run-id>`, run `agent-workflow retry-execute --run <run-id>` after the external cause of an executor failure is cleared (e.g., session conflict resolved, transient error gone). It preserves failed attempt logs and reuses the same session handle. Initial-cycle retries continue from the original plan; later-cycle retries resume from the preceding decision. Refuses when HEAD has drifted, scope violations exist, or the cycle already produced review artifacts.
- Treat `completed`, `needs_human`, `blocked`, `budget_exhausted`, and `aborted` as terminal. Report them instead of attempting another cycle.
- For `清理后重试 <run-id>`, run `agent-workflow retry-review --run <run-id>` after the approved scope artifacts have been removed. It must refuse when baseline drift or out-of-scope paths remain.
- For `执行器重试 <run-id>`, run `agent-workflow retry-execute --run <run-id>` after the external cause of an executor failure is cleared (e.g., session conflict resolved, transient error gone). It preserves failed attempt logs and reuses the same session handle. Initial-cycle retries continue from the original plan; later-cycle retries resume from the preceding decision. Refuses when baseline has drifted, scope violations exist, or the cycle already produced review artifacts.
- For `延长 <run-id> 添加 <n> 个周期`, run `agent-workflow extend --run <run-id> --additional-cycles <n>` to extend a `budget_exhausted` run. This requires: the run ended at `budget_exhausted`, has a valid session handle, the last decision was `fix`, baseline hasn't drifted, and scope is clean. Returns to `awaiting_host` state to continue the same executor session.
- Treat `completed`, `needs_human`, `blocked`, and `aborted` as terminal. Report them instead of attempting another cycle.
- `budget_exhausted` is terminal but can be extended with the extend command if all conditions are met.
- For an explicit abort, run `agent-workflow abort --run <run-id> --reason <text>` and report the resulting status.
## Failure Handling
- Missing session handle, executor failure, or HEAD drift must stop as `blocked`; do not work around the gate.
- Missing session handle, executor failure, or baseline drift (Git HEAD change, SVN revision change) must stop as `blocked`; do not work around the gate.
- When a resume failed before producing cycle artifacts because the same session was busy, ask the user to close the owning executor process, then use `retry-execute`; never kill an unrelated process automatically.
- Out-of-scope edits must enter `awaiting_scope_resolution`; inspect and remediate them through the same executor session. Repeated identical violations must stop as `needs_human`.
- Same finding in consecutive reviews or disappear/reappear oscillation must stop as `needs_human` when the engine reports non-convergence.
- If the cycle budget is exhausted and more work remains, explain the `extend` command option to the user.
- If interrupted, preserve the run ID. A later explicit `继续 <run-id>` invocation resumes from durable state.
- If the user changes requirements, abort the active run and return to plan discussion. Do not mutate the frozen plan in place.
## VCS-Specific Guidance
### Git Workflows
- Standard baseline tracking with HEAD SHA
- Diff includes tracked changes and unversioned additions
- Scope checking via `git diff --name-only` and `git ls-files`
### SVN Workflows (Strict Mode)
- Baseline includes repository URL, UUID, and single working revision
- Before starting: verify `svn info` shows consistent state, no mixed revisions
- Diff includes tracked modifications, unversioned additions, deletions, and property changes
- The executor never runs `svn commit`, `svn switch`, or `svn update`
- Reject runs with switched paths, externals, conflicts, or incomplete states
- If mixed revisions detected: stop and instruct user to run `svn update`
## Final Report
Report: