@fitlab-ai/agent-infra 0.9.8 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/bin/internal-cli.js +11 -1
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +58 -21
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +25 -11
- package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +173 -10
- package/dist/lib/agent-clients/adapters/codex-lifecycle/controller-context.js +127 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +14 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +63 -92
- package/dist/lib/agent-clients/adapters/codex-sandbox.js +72 -11
- package/dist/lib/agent-clients/adapters/index.js +3 -1
- package/dist/lib/agent-clients/adapters/traecli.js +66 -0
- package/dist/lib/agent-clients/tokens.js +2 -2
- package/dist/lib/agent-clients/types.js +2 -1
- package/dist/lib/defaults.json +5 -0
- package/dist/lib/git/workflow.js +10 -1
- package/dist/lib/internal/codex-lifecycle.js +20 -6
- package/dist/lib/internal/codex-sandbox-controller.js +9 -15
- package/dist/lib/internal/git-workflow.js +5 -7
- package/dist/lib/internal/platform-pr.js +20 -7
- package/dist/lib/internal/release-workflow.js +2 -1
- package/dist/lib/internal/sandbox-control.js +79 -2
- package/dist/lib/internal/task-finalization.js +54 -0
- package/dist/lib/internal/task-orchestration.js +156 -291
- package/dist/lib/{task/commands/validate.js → internal/task-validate.js} +75 -42
- package/dist/lib/platform/pr-summary.js +48 -10
- package/dist/lib/platform/pull-requests.js +205 -41
- package/dist/lib/run/tui.js +5 -2
- package/dist/lib/sandbox/commands/rm.js +316 -55
- package/dist/lib/sandbox/control/client.js +190 -6
- package/dist/lib/sandbox/control/controller-registration.js +275 -0
- package/dist/lib/sandbox/control/executor.js +140 -5
- package/dist/lib/sandbox/control/lifecycle.js +3 -1
- package/dist/lib/sandbox/control/protocol.js +67 -6
- package/dist/lib/sandbox/index.js +5 -3
- package/dist/lib/sandbox/managed-fs.js +5 -0
- package/dist/lib/sandbox/task-resolver.js +50 -6
- package/dist/lib/sandbox/workspace-identity.js +27 -0
- package/dist/lib/sandbox/worktree-safety.js +215 -2
- package/dist/lib/task/codex-orchestration.js +161 -39
- package/dist/lib/task/commands/status.js +59 -1
- package/dist/lib/task/commit-operation.js +335 -0
- package/dist/lib/task/commit-policy.js +18 -0
- package/dist/lib/task/delegation-receipts.js +248 -6
- package/dist/lib/task/finalization.js +593 -0
- package/dist/lib/task/index.js +0 -9
- package/dist/lib/task/operation-outcome.js +33 -0
- package/dist/lib/task/orchestration.js +187 -761
- package/dist/lib/task/short-id.js +59 -1
- package/dist/lib/task/task-execution-lock.js +6 -1
- package/dist/lib/task/verification-engine.js +110 -60
- package/dist/lib/task/verification.js +2 -1
- package/dist/lib/task/workflow-warning-intents.js +50 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +61 -19
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +37 -10
- package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +276 -12
- package/lib/agent-clients/adapters/codex-lifecycle/controller-context.ts +163 -0
- package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +19 -0
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +9 -1
- package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +91 -118
- package/lib/agent-clients/adapters/codex-sandbox.ts +89 -14
- package/lib/agent-clients/adapters/index.ts +3 -1
- package/lib/agent-clients/adapters/traecli.ts +67 -0
- package/lib/agent-clients/tokens.ts +2 -2
- package/lib/agent-clients/types.ts +2 -1
- package/lib/defaults.json +5 -0
- package/lib/git/workflow.ts +11 -2
- package/lib/internal/codex-lifecycle.ts +19 -6
- package/lib/internal/codex-sandbox-controller.ts +9 -14
- package/lib/internal/git-workflow.ts +5 -6
- package/lib/internal/platform-pr.ts +14 -7
- package/lib/internal/release-workflow.ts +2 -1
- package/lib/internal/sandbox-control.ts +92 -2
- package/lib/internal/task-finalization.ts +68 -0
- package/lib/internal/task-orchestration.ts +20 -103
- package/lib/{task/commands/validate.ts → internal/task-validate.ts} +75 -40
- package/lib/platform/pr-summary.ts +55 -11
- package/lib/platform/pull-requests.ts +211 -41
- package/lib/run/tui.ts +5 -3
- package/lib/sandbox/commands/rm.ts +413 -61
- package/lib/sandbox/control/client.ts +255 -6
- package/lib/sandbox/control/controller-registration.ts +352 -0
- package/lib/sandbox/control/executor.ts +169 -5
- package/lib/sandbox/control/lifecycle.ts +2 -1
- package/lib/sandbox/control/protocol.ts +80 -7
- package/lib/sandbox/index.ts +5 -3
- package/lib/sandbox/managed-fs.ts +5 -0
- package/lib/sandbox/task-resolver.ts +58 -7
- package/lib/sandbox/workspace-identity.ts +50 -2
- package/lib/sandbox/workspace-view.ts +3 -3
- package/lib/sandbox/worktree-safety.ts +236 -2
- package/lib/task/codex-orchestration.ts +168 -40
- package/lib/task/commands/status.ts +78 -1
- package/lib/task/commit-operation.ts +430 -0
- package/lib/task/commit-policy.ts +30 -0
- package/lib/task/delegation-receipts.ts +263 -4
- package/lib/task/finalization.ts +761 -0
- package/lib/task/index.ts +0 -8
- package/lib/task/operation-outcome.ts +48 -0
- package/lib/task/orchestration.ts +218 -982
- package/lib/task/short-id.ts +65 -1
- package/lib/task/task-execution-lock.ts +10 -1
- package/lib/task/verification-engine.ts +115 -63
- package/lib/task/verification.ts +3 -2
- package/lib/task/workflow-warning-intents.ts +57 -2
- package/package.json +2 -2
- package/templates/.agents/QUICKSTART.en.md +3 -4
- package/templates/.agents/QUICKSTART.zh-CN.md +3 -4
- package/templates/.agents/hooks/lifecycle-delegation.js +1 -21
- package/templates/.agents/rules/README.en.md +1 -0
- package/templates/.agents/rules/README.zh-CN.md +1 -0
- package/templates/.agents/rules/compatibility-policy.en.md +39 -0
- package/templates/.agents/rules/compatibility-policy.zh-CN.md +39 -0
- package/templates/.agents/rules/lifecycle-orchestration.en.md +4 -4
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +4 -4
- package/templates/.agents/rules/pr-sync.en.md +1 -1
- package/templates/.agents/rules/pr-sync.github.en.md +2 -1
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +2 -0
- package/templates/.agents/rules/pr-sync.zh-CN.md +1 -0
- package/templates/.agents/rules/review-method.en.md +1 -0
- package/templates/.agents/rules/review-method.zh-CN.md +1 -0
- package/templates/.agents/rules/task-management.en.md +2 -2
- package/templates/.agents/rules/task-management.zh-CN.md +2 -2
- package/templates/.agents/skills/analyze-task/SKILL.en.md +1 -0
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +1 -0
- package/templates/.agents/skills/block-task/SKILL.en.md +2 -4
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -4
- package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -3
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/close-codescan/SKILL.en.md +6 -2
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +6 -2
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +6 -2
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +6 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +1 -0
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +2 -0
- package/templates/.agents/skills/commit/SKILL.en.md +41 -125
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +52 -123
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +14 -43
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +14 -49
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -35
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -35
- package/templates/.agents/skills/complete-task/SKILL.en.md +31 -38
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +31 -38
- package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +1 -1
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/SKILL.en.md +17 -9
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +17 -9
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +41 -0
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +41 -0
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +2 -2
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +2 -2
- package/templates/.agents/skills/plan-task/SKILL.en.md +2 -1
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -1
- package/templates/.agents/skills/review-code/reference/migration-risks.en.md +8 -6
- package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +8 -6
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +3 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.en.md +1 -1
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.zh-CN.md +1 -1
- package/templates/.agents/skills/run-manual-validation/reference/report-template.en.md +2 -2
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +2 -2
- package/templates/.agents/skills/run-task/SKILL.en.md +6 -6
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +6 -6
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +2 -2
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +2 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +24 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +1 -1
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +1 -1
- package/templates/.codex/hooks.json +4 -4
- package/templates/.trae/skills/update-agent-infra.en.md +8 -0
- package/templates/.trae/skills/update-agent-infra.zh-CN.md +8 -0
- package/dist/lib/task/commit-finalization.js +0 -305
- package/dist/lib/task/commit-intent.js +0 -165
- package/lib/task/commit-finalization.ts +0 -419
- package/lib/task/commit-intent.ts +0 -230
|
@@ -1,169 +1,85 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: commit
|
|
3
3
|
description: >
|
|
4
|
-
Commit
|
|
5
|
-
Use when
|
|
4
|
+
Commit current changes to Git.
|
|
5
|
+
Use when completed work needs to be recorded as a Git commit.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# Commit
|
|
9
|
-
> `--agent` values follow the "Collaborator Token Specification" in `.agents/rules/task-management.md`: standard AI short tokens (`claude`/`codex`/`antigravity`/`opencode`/`cursor`), long-name normalization (`claude-code`->`claude`, `antigravity-cli`->`antigravity`), or the `human` manual exception.
|
|
8
|
+
# Commit code
|
|
10
9
|
|
|
10
|
+
Use the standard agent token from `.agents/rules/task-management.md`.
|
|
11
11
|
|
|
12
|
-
Create a Git commit without overwriting
|
|
12
|
+
Create a Git commit without overwriting local work, and update the associated task only when a task context exists.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
The commit core returns one primary result: `committed`, `no_op`, `committed_with_warnings`, `failed`, or `blocked`, with structured `warnings`. A push failure or protected-branch policy never rolls back a local commit.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## Task context
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Resolve the optional task scope with `agent-infra-internal task-context resolve {task-scope}`.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
- An explicit task-resolution failure stops the operation.
|
|
21
|
+
- Without an explicit task scope, only `TASK_CONTEXT_NOT_FOUND` may enter taskless direct mode; detached HEAD, malformed candidates, and multiple matches fail closed.
|
|
22
|
+
- If the literal `--orchestrated` is present in the business operands, use `mode=orchestrated`; otherwise use `mode=direct`. Never infer the mode from files or environment.
|
|
23
|
+
- Taskless direct mode does not read, create, or complete task intent, receipt, checkpoint, or task.md records.
|
|
24
|
+
- Task-bound direct mode does not require a delegation receipt; orchestrated mode must validate the matching activated commit receipt and capability in the core.
|
|
25
|
+
- After resolution, use only the core-returned `taskId`; never infer task identity from the environment, branch, or filename.
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|------|------|
|
|
24
|
-
| "The tests already ran earlier, so I do not need to rerun them." | The staged content is the current truth; before committing, re-check `git status` and `git diff` instead of relying on memory. |
|
|
25
|
-
| "`git add -A` is faster." | `git add -A` and `git add .` are forbidden; stage only explicitly listed files to avoid including unrelated changes. |
|
|
26
|
-
| "This file has a copyright header, but the year can wait." | If you changed it, update the copyright year using `date +%Y`; this is a hard pre-commit check. |
|
|
27
|
+
## 1. Inspect local changes
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
> The entry point may omit the task ref and also accepts a legacy positional ref or `--task <ref>` / `-t <ref>`. Separate task scope from the full arguments while preserving every business operand, then call `agent-infra-internal task-context resolve {task-scope}` where `{task-scope}` is empty, one positional ref, or one task flag. Read only `taskId` from the structured result and bind `{task-id}` to that full `TASK-YYYYMMDD-HHMMSS` for downstream commands. Pass through resolution failures without scanning tasks locally.
|
|
31
|
-
|
|
32
|
-
Without explicit task scope, only `TASK_CONTEXT_NOT_FOUND` may continue through the existing bare-commit path. Detached HEAD, damaged candidates, or multiple matches are ambiguity errors. Any explicit task-scope failure is fatal.
|
|
33
|
-
|
|
34
|
-
## Step Start: Recover or Create a Controlled Attempt
|
|
35
|
-
|
|
36
|
-
When `{task-id}` is resolved, call `commit-status` first. Finalize `recoverable`; safely clear `prepared` and query status again; reuse `retryable-start` through `commit-recover --agent {standard-agent-token}`. Fail closed for `invalid` / `conflict` / `orphaned-start`. For `idle`, call `commit-start --agent {standard-agent-token}` so the core atomically writes the structured started entry and returns its attempt/baseline.
|
|
37
|
-
|
|
38
|
-
Read `{commit-attempt}` only from structured `commit-start` / `commit-recover` output. Never hand-write, copy, or guess an attempt. A bare commit without task context skips this protocol.
|
|
39
|
-
|
|
40
|
-
## 1. Check Local Modifications (CRITICAL)
|
|
41
|
-
|
|
42
|
-
Before any edit, inspect:
|
|
29
|
+
Before editing, run:
|
|
43
30
|
|
|
44
31
|
```bash
|
|
45
32
|
git status --short
|
|
46
33
|
git diff
|
|
47
34
|
```
|
|
48
35
|
|
|
49
|
-
Respect existing user changes
|
|
50
|
-
|
|
51
|
-
## 2. Update Copyright Headers
|
|
52
|
-
|
|
53
|
-
Use the current year dynamically and only update files that are already modified.
|
|
54
|
-
|
|
55
|
-
> The full copyright workflow lives in `reference/copyright-check.md`. Read `reference/copyright-check.md` before editing any header.
|
|
56
|
-
|
|
57
|
-
## 3. Build the Commit Message
|
|
58
|
-
|
|
59
|
-
Review status, diff, and recent history, then prepare a Conventional Commit with the correct co-author lines.
|
|
60
|
-
|
|
61
|
-
> Commit message rules, examples, and multi-agent co-authorship details live in `reference/commit-message.md`. Read `reference/commit-message.md` before writing the commit.
|
|
62
|
-
|
|
63
|
-
## 4. Create the Commit
|
|
64
|
-
|
|
65
|
-
When `{task-id}` was resolved, read `reference/commit-orchestration.md` before this step and complete `commit-begin` before any successful Git/platform side effect. A taskless Git-only commit skips the intent protocol entirely.
|
|
66
|
-
|
|
67
|
-
Detect the restricted push-only scenario first. Otherwise write message, explicit paths, and expected HEAD/tree to JSON and call `agent-infra-internal git-workflow commit --input {file}`.
|
|
68
|
-
|
|
69
|
-
Immediately after a normal commit succeeds, run the committed checkpoint from that reference. If the checkpoint fails, retain the intent and stop before push or success-state writes.
|
|
70
|
-
|
|
71
|
-
If this commit is associated with a task and a `review-code` artifact exists, read the highest-round `review-code` artifact before committing:
|
|
72
|
-
- If that artifact's `Overall Verdict` / `总体结论` is Approved, parse `R`, `F`, and `Reviewed Snapshot Tree` / `审查快照树` (`T`)
|
|
73
|
-
- After staging the explicit files, record `pre_head=$(git rev-parse HEAD)` and use the helper's JSON mode to generate the complete worktree tree `W` and normalized staged tree `S`
|
|
74
|
-
- Before `git commit`, require `pre_head == R && W == T && S == T`; use the helper's `compare` mode to produce added, missing, and different diagnostics for both worktree and staged snapshots
|
|
75
|
-
- If any condition fails, enter Scenario 4 in `reference/task-status-update.md`; do not run `git commit`, push, successful state updates, PR summary sync, or the completion gate
|
|
76
|
-
- After all comparisons match and the commit succeeds, the Step 6 `commit-complete` core finalizer atomically writes `last_reviewed_commit` and Commit done; the caller must not write them
|
|
77
|
-
- Do not scan backward to earlier Approved artifacts; the highest-round `review-code` artifact is the only authoritative source
|
|
78
|
-
|
|
79
|
-
## 5. Push to the Existing PR When Applicable
|
|
36
|
+
Respect existing user changes and stop on a conflict according to the no-mid-flow-questions rule.
|
|
80
37
|
|
|
81
|
-
|
|
38
|
+
## 2. Update copyright years
|
|
82
39
|
|
|
83
|
-
|
|
40
|
+
Get the current year dynamically and update only touched files that contain a copyright header. Read `reference/copyright-check.md` for the complete procedure.
|
|
84
41
|
|
|
85
|
-
|
|
42
|
+
## 3. Create the commit message
|
|
86
43
|
|
|
87
|
-
|
|
44
|
+
Review status, diff, and recent history. Use an imperative Conventional Commit message and read `reference/commit-message.md` for co-author handling.
|
|
88
45
|
|
|
89
|
-
|
|
46
|
+
## 4. Call the single commit core
|
|
90
47
|
|
|
91
|
-
|
|
48
|
+
Read `reference/commit-orchestration.md` before this step.
|
|
92
49
|
|
|
93
|
-
|
|
94
|
-
- Platform unavailable / unauthenticated / detection failed / no open PR -> do not push; continue.
|
|
95
|
-
- `git push` fails (needs `git pull --rebase`, no upstream, network error) -> keep the local commit and tell the user to push manually.
|
|
96
|
-
|
|
97
|
-
Fold the push outcome (pushed / skipped(no PR) / failed) into the next step's "Update Task Status" Activity Log note or user output.
|
|
98
|
-
|
|
99
|
-
## 6. Update Task Status When Applicable
|
|
100
|
-
|
|
101
|
-
After checkpoints and before synchronization or the completion gate, call `commit-complete`. Under the task lock, core writes the review anchor, Commit done, and planned orchestration bytes, then deletes the intent last. On failure retain the intent and let the next skill run use status/recover.
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Get the current time:
|
|
50
|
+
Write the message, explicit paths, expected HEAD/tree, task scope, agent, mode, and optional push policy to a temporary JSON file, then call:
|
|
108
51
|
|
|
109
52
|
```bash
|
|
110
|
-
|
|
53
|
+
agent-infra-internal git-workflow commit --input {commit-operation.json}
|
|
111
54
|
```
|
|
112
55
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
> Before rendering next steps, read `.agents/rules/next-step-output.md` and invoke the shared helper for the scenario selected from `reference/task-status-update.md`.
|
|
116
|
-
|
|
117
|
-
After core finalization succeeds, choose exactly one next-step case:
|
|
118
|
-
- open PR and successful push -> `watch-pr {task-ref}`; this takes precedence over the final-commit `prFlow` route
|
|
119
|
-
- failed push -> keep the task active and show only push/synchronization diagnostics; do not show `watch-pr` or `complete-task`
|
|
120
|
-
- final commit -> render the next step by `.agents/.airc.json`'s `prFlow` (`disabled` -> single option `complete-task`; `required` -> single option `create-pr`; absent -> two options `create-pr` / `complete-task`); see Case 1 in `reference/task-status-update.md`
|
|
121
|
-
- more work remains -> update task.md and stop
|
|
122
|
-
- ready for review -> `review-code {task-id}`
|
|
56
|
+
Taskless direct mode omits `taskRef`; orchestrated mode must pass `taskRef`, `agent`, and `mode: "orchestrated"`. The core owns repository/worktree mutation locking, task locking when bound, path and sensitive-file checks, staged scope, HEAD/tree, branch/ref, commit, push, protected-branch policy, warnings, and idempotency.
|
|
123
57
|
|
|
124
|
-
|
|
58
|
+
- Create at most one local commit for explicit changes.
|
|
59
|
+
- If there are no changes but HEAD is ahead and delivery is requested, perform push-only and do not create an empty commit.
|
|
60
|
+
- Skip automatic push on `main` / `master` with `COMMIT_AUTOPUSH_PROTECTED_BRANCH`; retain the local commit.
|
|
61
|
+
- Return `COMMIT_PUSH_FAILED` as a warning on ordinary push failure; a retry only repairs push and never creates a second commit.
|
|
62
|
+
- Successful taskless operations write no task.md, review, receipt, checkpoint, or Activity Log record.
|
|
125
63
|
|
|
126
|
-
|
|
64
|
+
## 5. Finish task and platform synchronization
|
|
127
65
|
|
|
128
|
-
|
|
129
|
-
>
|
|
130
|
-
> If this step touches the code-hosting platform, complete the prerequisite checks in `.agents/rules/issue-pr-commands.md` first.
|
|
66
|
+
Continue task synchronization only for task-bound operations. For an associated Issue or PR, follow the issue, PR-summary, and platform rules; the commit path passes `--result no_op` to summary-sync because it only synchronizes an existing PR identity. Synchronization failures are warnings and do not roll back the local commit.
|
|
131
67
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## 8. Sync PR Summary When Applicable
|
|
135
|
-
|
|
136
|
-
When `{task-id}` exists and task.md contains a valid `pr_number`, refresh the PR summary comment marked with the PR summary marker defined in `.agents/rules/pr-sync.md` on the PR. Otherwise, skip this step.
|
|
137
|
-
|
|
138
|
-
> The full trigger conditions, aggregation rules, PATCH/POST flow, shell-safety constraints, and error handling live in `reference/pr-summary-sync.md` (which in turn points to `.agents/rules/pr-sync.md`). Read `reference/pr-summary-sync.md` before executing this step.
|
|
139
|
-
>
|
|
140
|
-
> If this step touches the code-hosting platform, complete the prerequisite checks in `.agents/rules/issue-pr-commands.md` first so the runtime context required by `.agents/rules/pr-sync.md` is ready.
|
|
141
|
-
|
|
142
|
-
Failure handling matches "Update Task Status When Applicable": warn, but do **not** block an already completed `git commit`.
|
|
143
|
-
|
|
144
|
-
## 9. Verification Gate
|
|
145
|
-
|
|
146
|
-
If this operation is associated with `{task-id}`, run the verification gate to confirm task metadata and sync state. If there is no task context, skip this step.
|
|
68
|
+
After task-bound finalization, run:
|
|
147
69
|
|
|
148
70
|
```bash
|
|
71
|
+
date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
|
|
149
72
|
agent-infra-internal task-verify {task-id} commit.completed --format text
|
|
150
73
|
```
|
|
151
74
|
|
|
152
|
-
|
|
153
|
-
- exit code 0 (all checks passed) -> continue the remaining wrap-up steps
|
|
154
|
-
- exit code 1 (validation failed) -> fix the reported issues and run the gate again
|
|
155
|
-
- exit code 2 (network blocked) -> stop and tell the user that human intervention is required
|
|
75
|
+
Do not claim task finalization without fresh verification output.
|
|
156
76
|
|
|
157
|
-
|
|
77
|
+
## 6. Render the next step
|
|
158
78
|
|
|
159
|
-
|
|
79
|
+
Read `.agents/rules/next-step-output.md` immediately before calling the single next-step helper. A failed push keeps the task active and reports diagnostics; a final commit routes to `create-pr` or `complete-task` according to `prFlow`.
|
|
160
80
|
|
|
161
81
|
## Notes
|
|
162
82
|
|
|
163
|
-
- Never commit
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
|
|
167
|
-
## Error Handling
|
|
168
|
-
|
|
169
|
-
- If the task status update fails, warn the user but do not block the commit
|
|
83
|
+
- Never commit `.env`, credentials, keys, or other sensitive files.
|
|
84
|
+
- Never use `git add -A` or `git add .`.
|
|
85
|
+
- Never hand-write task Activity Log, review anchors, receipts, or checkpoints.
|
|
@@ -6,44 +6,25 @@ description: >
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# 提交代码
|
|
9
|
-
> `--agent` 取值见 `.agents/rules/task-management.md`「合作者 token 规范」:标准 AI 短名(`claude`/`codex`/`antigravity`/`opencode`/`cursor`)、长名归一化(`claude-code`→`claude`、`antigravity-cli`→`antigravity`)或人工例外 `human`。
|
|
10
9
|
|
|
10
|
+
> `--agent` 取值见 `.agents/rules/task-management.md`「合作者 token 规范」。
|
|
11
11
|
|
|
12
12
|
在不覆盖用户本地工作的前提下创建 Git commit,并在需要时更新关联任务状态。
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
commit core 只返回一个主结果:`committed`、`no_op`、`committed_with_warnings`、`failed` 或 `blocked`,并附带结构化 `warnings`。push 失败或保护分支策略不会撤销已经创建的本地提交。
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## 任务上下文
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
入口允许省略 task ref,也接受旧位置 task ref 或 `--task <ref>` / `-t <ref>`。先调用 `agent-infra-internal task-context resolve {task-scope}`。
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
- 显式 task scope 解析失败时停止。
|
|
21
|
+
- 未显式指定 task scope 时,只有 `TASK_CONTEXT_NOT_FOUND` 可进入 taskless direct;detached HEAD、损坏候选或多匹配必须 fail closed。
|
|
22
|
+
- 入口业务操作数包含字面 `--orchestrated` 时使用 `mode=orchestrated`,否则使用 `mode=direct`;不得从 run 文件或环境推断模式。
|
|
23
|
+
- taskless direct 不读取、创建或完成 task intent、receipt、checkpoint 或 task.md 收尾记录。
|
|
24
|
+
- task-bound direct 不要求 delegation receipt;orchestrated 必须由 core 验证匹配的 activated commit receipt 和 capability。
|
|
25
|
+
- 解析成功后只使用 core 返回的 `taskId`;不得从环境、分支或文件名猜测任务身份。
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|------|------|
|
|
24
|
-
| 「测试之前跑过了,不用重跑」 | 暂存内容是最新现实;提交前必须重新核对 `git status`/`git diff`,不能凭记忆。 |
|
|
25
|
-
| 「`git add -A` 更省事」 | 禁止 `git add -A`/`git add .`;只暂存明确列出的文件,避免带入无关改动。 |
|
|
26
|
-
| 「改了带版权头的文件,年份先不动」 | 改了就更新版权年份(动态取 `date +%Y`),这是提交前的硬性检查。 |
|
|
27
|
-
|
|
28
|
-
## 任务上下文解析
|
|
29
|
-
|
|
30
|
-
> 入口允许省略 task ref,也接受旧位置 task ref 或 `--task <ref>` / `-t <ref>`。先从完整参数中分离 task scope 并原样保留其他业务操作数,再调用 `agent-infra-internal task-context resolve {task-scope}`;`{task-scope}` 为空、位置 ref 或 task flag 之一。只读取结构化结果的 `taskId`,后续把 `{task-id}` 绑定为该完整 `TASK-YYYYMMDD-HHMMSS`。解析失败时透传非零退出码,不自行扫描任务。
|
|
31
|
-
|
|
32
|
-
未显式指定 task scope 时,只有 `TASK_CONTEXT_NOT_FOUND` 可继续既有纯提交路径;detached HEAD、损坏候选或多匹配属于歧义,必须失败。显式 task scope 解析失败时一律失败。
|
|
33
|
-
|
|
34
|
-
## 步骤开始:恢复或创建受控 attempt
|
|
35
|
-
|
|
36
|
-
已解析出 `{task-id}` 时,先调用 `agent-infra-internal task-orchestration {task-id} commit-status`:
|
|
37
|
-
|
|
38
|
-
- `recoverable`:调用 `commit-recover --agent {standard-agent-token}` 完成收尾,不得重复 commit 或 push。
|
|
39
|
-
- `prepared`:调用 `commit-recover --agent {standard-agent-token}` 安全清理 intent,再次查询 status 并复用返回的 `retryable-start` attempt。
|
|
40
|
-
- `retryable-start`:调用 `commit-recover --agent {standard-agent-token}` 取得原 attempt,不追加第二条 started。
|
|
41
|
-
- `invalid` / `conflict` / `orphaned-start`:输出结构化 code 与状态证据并停止。
|
|
42
|
-
- `idle`:调用 `commit-start --agent {standard-agent-token}`,由核心在任务锁内原子写入结构化 started 并返回 attempt/baseline。
|
|
43
|
-
|
|
44
|
-
只从 `commit-start` / `commit-recover` 的结构化输出读取 `{commit-attempt}`;不得手写、复制或猜测 attempt。无任务上下文的纯提交跳过本协议。
|
|
45
|
-
|
|
46
|
-
## 1. 检查本地修改(关键)
|
|
27
|
+
## 1. 检查本地修改
|
|
47
28
|
|
|
48
29
|
在任何编辑前先检查:
|
|
49
30
|
|
|
@@ -52,126 +33,74 @@ git status --short
|
|
|
52
33
|
git diff
|
|
53
34
|
```
|
|
54
35
|
|
|
55
|
-
|
|
36
|
+
必须尊重现有用户改动;如果计划与之冲突,按禁言规则停止并记录阻塞原因。
|
|
56
37
|
|
|
57
38
|
## 2. 更新版权头年份
|
|
58
39
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
> 完整版权检查流程见 `reference/copyright-check.md`。修改任何版权头前,先读取 `reference/copyright-check.md`。
|
|
40
|
+
动态获取当前年份,只更新已经改动过的带版权头文件。完整流程见 `reference/copyright-check.md`。
|
|
62
41
|
|
|
63
42
|
## 3. 生成提交信息
|
|
64
43
|
|
|
65
|
-
检查状态、diff
|
|
66
|
-
|
|
67
|
-
> 提交信息规则、示例和多代理署名细节见 `reference/commit-message.md`。写 commit message 前先读取 `reference/commit-message.md`。
|
|
68
|
-
|
|
69
|
-
## 4. 创建提交
|
|
70
|
-
|
|
71
|
-
已解析出 `{task-id}` 时,执行本步骤前先读取 `reference/commit-orchestration.md`,并在任何 Git/平台成功副作用前完成 `commit-begin`;无任务上下文的纯 Git 提交完全跳过 intent 协议。
|
|
72
|
-
|
|
73
|
-
先判断受限 push-only 场景;否则把 message、显式路径、expected HEAD/tree 写入临时 JSON,并调用 `agent-infra-internal git-workflow commit --input {file}`。core 负责范围、敏感文件、暂存树和幂等校验。
|
|
74
|
-
|
|
75
|
-
普通 commit 成功后必须立即按该 reference 执行 committed checkpoint;checkpoint 失败时保留 intent 并停止,不得继续 push 或写成功状态。
|
|
76
|
-
|
|
77
|
-
如果本次提交关联任务且存在 `review-code` 产物,在提交前读取最高轮 `review-code` 产物:
|
|
78
|
-
- 若该产物 `总体结论` / `Overall Verdict` 为 Approved,解析 `R`、`F` 与 `审查快照树` / `Reviewed Snapshot Tree`(`T`)
|
|
79
|
-
- 暂存明确文件后记录 `pre_head=$(git rev-parse HEAD)`,并以 helper 的 JSON 模式生成当前完整工作区树 `W` 与规范化暂存树 `S`
|
|
80
|
-
- 在 `git commit` 前要求 `pre_head == R && W == T && S == T`;分别运行 helper 的 `compare` 模式生成 worktree/staged 的 added、missing、different 路径诊断
|
|
81
|
-
- 任一条件不满足时进入 `reference/task-status-update.md` 的“场景 4:提交前快照阻断”,不得执行 `git commit`、push、成功状态更新、PR 摘要同步或完成 gate
|
|
82
|
-
- 全部相等并成功提交后,由步骤 6 的 `commit-complete` 核心收尾原子写入 `last_reviewed_commit` 与 Commit done;调用方不得手写
|
|
83
|
-
- 不向后扫描更早的 Approved 产物;最高轮 `review-code` 产物是唯一权威来源
|
|
84
|
-
|
|
85
|
-
## 5. 推送到已有 PR(按需)
|
|
86
|
-
|
|
87
|
-
新提交完成或步骤 4 命中 push-only 后,如果当前分支已存在开放的 Pull Request,则把 HEAD 普通推送上去让 PR 自动更新;否则保持现状(首次推送仍由 `create-pr` 负责)。本步骤不创建额外/空 commit,也不在无 PR 时推送;与是否关联任务无关。
|
|
88
|
-
|
|
89
|
-
> 检测当前分支是否有开放 PR、以及平台认证,统一按 `.agents/rules/issue-pr-commands.md` 执行;该规则不可用或检测失败时,按下方降级处理。
|
|
90
|
-
|
|
91
|
-
a. 按 `.agents/rules/issue-pr-commands.md` 检测当前分支(head)是否存在开放 PR。
|
|
44
|
+
检查状态、diff 和最近历史,按 Conventional Commits 生成英文祈使句 message,并读取 `reference/commit-message.md` 处理协作署名。
|
|
92
45
|
|
|
93
|
-
|
|
46
|
+
## 4. 调用唯一 commit core
|
|
94
47
|
|
|
95
|
-
|
|
48
|
+
执行本步骤前读取 `reference/commit-orchestration.md`。
|
|
96
49
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
c. 安全降级(不阻塞已完成的 `git commit`,仅提示用户):
|
|
100
|
-
- 平台不可用 / 未认证 / 检测失败 / 未命中开放 PR -> 不推送,继续后续步骤。
|
|
101
|
-
- `git push` 失败(如需 `git pull --rebase`、无 upstream、网络异常)-> 保留本地提交,提示用户手动推送。
|
|
102
|
-
|
|
103
|
-
把推送结果(pushed / skipped(no PR) / failed)并入下一步「更新任务状态」的 Activity Log 说明或用户输出。
|
|
104
|
-
|
|
105
|
-
## 6. 按需更新任务状态
|
|
106
|
-
|
|
107
|
-
普通 commit/push checkpoint 完成后,先调用核心收尾;它在同一任务锁内写入审查锚点、Commit done 与 orchestration planned bytes,最后删除 intent:
|
|
50
|
+
将 message、明确 paths、expected HEAD/tree、task scope、agent、mode 和可选 push policy 写入临时 JSON,然后调用:
|
|
108
51
|
|
|
109
52
|
```bash
|
|
110
|
-
agent-infra-internal
|
|
53
|
+
agent-infra-internal git-workflow commit --input {commit-operation.json}
|
|
111
54
|
```
|
|
112
55
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
56
|
+
示例:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"taskRef": "TASK-YYYYMMDD-HHMMSS",
|
|
61
|
+
"agent": "codex",
|
|
62
|
+
"mode": "direct",
|
|
63
|
+
"paths": ["lib/example.ts", "tests/example.test.ts"],
|
|
64
|
+
"message": "fix(core): validate example input",
|
|
65
|
+
"expectedHead": "{HEAD}",
|
|
66
|
+
"expectedTree": "{TREE}",
|
|
67
|
+
"push": {
|
|
68
|
+
"remote": "origin",
|
|
69
|
+
"refs": ["refs/heads/{branch}"],
|
|
70
|
+
"automatic": true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
119
73
|
```
|
|
120
74
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
> 渲染下一步前先读取 `.agents/rules/next-step-output.md`,并按 `reference/task-status-update.md` 的已选场景调用统一 helper。
|
|
75
|
+
taskless direct 省略 `taskRef`;orchestrated 必须显式传 `taskRef`、`agent` 和 `mode: "orchestrated"`。core 统一负责 repository/worktree mutation lock、task lock(仅 task-bound)、路径和敏感文件、staged scope、HEAD/tree、branch/ref、commit、push、保护分支、warning 和幂等校验。
|
|
124
76
|
|
|
125
|
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
- 准备审查 -> `review-code {task-id}`
|
|
77
|
+
- 有明确修改时最多创建一个本地 commit。
|
|
78
|
+
- 无修改但需要交付本地领先的 HEAD 时只执行 push-only,不创建空 commit。
|
|
79
|
+
- `main` / `master` 的自动 push 跳过并返回 `COMMIT_AUTOPUSH_PROTECTED_BRANCH`;本地 commit 保留。
|
|
80
|
+
- 普通 push 失败返回 `COMMIT_PUSH_FAILED` warning;重跑只补当前 push,不重复创建 commit。
|
|
81
|
+
- taskless 成功不写 task.md、review、receipt、checkpoint 或 Activity Log。
|
|
131
82
|
|
|
132
|
-
##
|
|
83
|
+
## 5. 任务收尾与平台同步
|
|
133
84
|
|
|
134
|
-
|
|
85
|
+
task-bound 操作按 core 返回的 task 结果继续执行任务同步;taskless 操作跳过任务校验和任务平台同步。
|
|
135
86
|
|
|
136
|
-
|
|
137
|
-
>
|
|
138
|
-
> 如果本步骤会访问代码托管平台,则先按 `.agents/rules/issue-pr-commands.md` 完成前置检测。
|
|
87
|
+
当 task 存在且关联 Issue/PR 时,按 `reference/issue-metadata-sync.md`、`reference/pr-summary-sync.md` 和平台规则执行同步;commit 路径调用 summary-sync 时固定传入 `--result no_op`,因为它只同步已有 PR 身份。同步失败只产生 warning,不撤销本地 commit。
|
|
139
88
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
## 8. 同步 PR 摘要(按需)
|
|
143
|
-
|
|
144
|
-
当 `{task-id}` 存在且 task.md 包含有效 `pr_number` 时,刷新 PR 上由 `.agents/rules/pr-sync.md` 中定义的 PR 摘要评论标记对应的摘要评论;否则跳过。
|
|
145
|
-
|
|
146
|
-
> 完整的触发条件、聚合规则、PATCH/POST 流程、Shell 安全约束和错误处理见 `reference/pr-summary-sync.md`(其内联引用 `.agents/rules/pr-sync.md`)。执行此步骤前先读取 `reference/pr-summary-sync.md`。
|
|
147
|
-
>
|
|
148
|
-
> 如果本步骤会访问代码托管平台,则先按 `.agents/rules/issue-pr-commands.md` 完成前置检测,确保 `.agents/rules/pr-sync.md` 所需的运行时上下文已就绪。
|
|
149
|
-
|
|
150
|
-
失败处理与「按需更新任务状态」一致:警告但**不**阻塞已完成的 `git commit`。
|
|
151
|
-
|
|
152
|
-
## 9. 完成校验
|
|
153
|
-
|
|
154
|
-
如果本次操作关联了 `{task-id}`,运行完成校验,确认任务元数据和同步状态符合规范;如果没有任务上下文,跳过本步骤。
|
|
89
|
+
完成 task-bound 收尾后运行:
|
|
155
90
|
|
|
156
91
|
```bash
|
|
92
|
+
date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
|
|
157
93
|
agent-infra-internal task-verify {task-id} commit.completed --format text
|
|
158
94
|
```
|
|
159
95
|
|
|
160
|
-
|
|
161
|
-
- 退出码 0(全部通过)-> 继续后续收尾步骤
|
|
162
|
-
- 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
|
|
163
|
-
- 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
|
|
96
|
+
没有当次校验输出,不得声明任务收尾完成。
|
|
164
97
|
|
|
165
|
-
|
|
98
|
+
## 6. 输出下一步
|
|
166
99
|
|
|
167
|
-
|
|
100
|
+
渲染下一步前先读取 `.agents/rules/next-step-output.md`,并根据最新 task/PR 状态只调用一次统一 helper。push 失败时保持任务 active,只输出诊断;最终提交则按 `prFlow` 选择 `create-pr` 或 `complete-task`。
|
|
168
101
|
|
|
169
102
|
## 注意事项
|
|
170
103
|
|
|
171
|
-
- 不要提交 `.env
|
|
172
|
-
-
|
|
173
|
-
-
|
|
174
|
-
|
|
175
|
-
## 错误处理
|
|
176
|
-
|
|
177
|
-
- 如果任务状态更新失败,警告用户,但不要因此阻止提交
|
|
104
|
+
- 不要提交 `.env`、凭据、密钥等敏感文件。
|
|
105
|
+
- 不要使用 `git add -A` 或 `git add .`。
|
|
106
|
+
- 不要手写 task Activity Log、review anchor、receipt 或 checkpoint。
|
|
@@ -1,50 +1,21 @@
|
|
|
1
|
-
# Commit
|
|
1
|
+
# Commit core boundary
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Commit, push, result mapping, and task finalization use one `commit-operation.execute`. The entry point only resolves task scope, explicit agent, and the literal `--orchestrated`; it never infers the source from state files.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Entry modes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- `mode=direct`: explicit user invocation is the authorization. Task-bound direct may read task facts but does not require a delegation receipt; taskless direct is allowed only for `TASK_CONTEXT_NOT_FOUND` and skips task facts, review, task lock, checkpoint, and task.md finalization.
|
|
8
|
+
- `mode=orchestrated`: an explicit task is required. Before the first Git write, the core validates the matching activated commit receipt, agent, stage, round, artifact, role, and unconsumed capability. Missing evidence returns `blocked` without writing Git.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Shared order
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
1. Acquire the repository/worktree mutation lock; task-bound execution also acquires the task lock.
|
|
13
|
+
2. Validate the repository, current branch, explicit paths, sensitive paths, staged scope, expected HEAD/tree, remote, and full heads ref.
|
|
14
|
+
3. Validate the authorization for the selected mode.
|
|
15
|
+
4. Create at most one local commit; with no changes, allow push-only and never create an empty commit.
|
|
16
|
+
5. Return `COMMIT_AUTOPUSH_PROTECTED_BRANCH` on protected automatic push, or `COMMIT_PUSH_FAILED` on ordinary push failure, while retaining local facts.
|
|
17
|
+
6. Return one primary result: `committed`, `no_op`, `committed_with_warnings`, `failed`, or `blocked`.
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
## Retry boundary
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head" --attempt "$commit_attempt")
|
|
18
|
-
commit_intent_token=$(printf '%s' "$commit_intent_result" | node -e 'let input = ""; process.stdin.on("data", chunk => input += chunk).on("end", () => process.stdout.write(JSON.parse(input).token))')
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Set `commit_intent_token` from the one-use `token` in structured output and keep it only in the current process. A failed begin forbids all later side effects.
|
|
22
|
-
|
|
23
|
-
## Side-effect checkpoints
|
|
24
|
-
|
|
25
|
-
Immediately after a normal commit succeeds, record its new HEAD:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind committed --head "$new_head"
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Immediately after a push succeeds and remote verification completes, record the verified remote/ref/HEAD:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind pushed --head "$pushed_head" --remote "$remote" --ref "$ref"
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
A push-only path skips the committed checkpoint; its pushed HEAD must equal the begin baseline.
|
|
38
|
-
|
|
39
|
-
## Completion and recovery
|
|
40
|
-
|
|
41
|
-
After the committed/pushed checkpoint and before task synchronization or `task-verify commit.completed`, run:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
- If an intent exists but no side effect occurred, use `commit-abort --token ... --expected-head ...` while HEAD still equals baseline; when abandoning the attempt, then close it with `commit-terminate --attempt "$commit_attempt" --agent {standard-agent-token} --code <STABLE_CODE>`.
|
|
48
|
-
- If begin failed before intent creation, retain the attempt for retry or terminate it only while HEAD is unchanged.
|
|
49
|
-
- After a commit or push, never abort. Retain the intent and use `commit-status` / `commit-recover` for cross-session recovery.
|
|
50
|
-
- Stop when `commit-complete` fails. Do not repeat commit/push or mark a run complete without its full receipt lifecycle.
|
|
21
|
+
Retries reread current HEAD, worktree, branch, and remote facts. A local commit that already exists is push-only and cannot produce a second commit. Taskless retries create no task record. Orchestration owns stage completion, sealing, and consumption of receipts; direct mode never fabricates them.
|
|
@@ -1,56 +1,21 @@
|
|
|
1
|
-
# Commit
|
|
1
|
+
# Commit Core 边界
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
commit、push、结果映射和任务收尾使用同一个 `commit-operation.execute`。入口只负责解析 task scope、显式 agent 和字面 `--orchestrated`,不得从状态文件推断执行来源。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 入口模式
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- `mode=direct`:用户显式调用授权。task-bound direct 可读取 task facts,但不要求 delegation receipt;taskless direct 只在 `TASK_CONTEXT_NOT_FOUND` 时允许,并跳过 task facts、review、task lock、checkpoint 和 task.md 收尾。
|
|
8
|
+
- `mode=orchestrated`:必须绑定明确 task,且 core 在第一个 Git 写入前验证匹配的 activated commit receipt、agent、stage、round、artifact、role 和未消费 capability。缺少任一项都返回 `blocked`,不写 Git。
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 共享执行顺序
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
1. 获取 repository/worktree mutation lock;task-bound 额外获取 task lock。
|
|
13
|
+
2. 验证 repository、当前 branch、明确 paths、敏感路径、staged scope、expected HEAD/tree、remote 和 full heads ref。
|
|
14
|
+
3. 完成模式对应的授权校验。
|
|
15
|
+
4. 最多创建一个本地 commit;无修改时只允许 push-only,不创建空 commit。
|
|
16
|
+
5. `main` / `master` 自动 push 返回 `COMMIT_AUTOPUSH_PROTECTED_BRANCH` warning;普通 push 失败返回 `COMMIT_PUSH_FAILED` warning,并保留本地事实。
|
|
17
|
+
6. 返回唯一主结果:`committed`、`no_op`、`committed_with_warnings`、`failed` 或 `blocked`。
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
agent-infra-internal task-orchestration {task-id} commit-recover --agent {standard-agent-token}
|
|
16
|
-
```
|
|
19
|
+
## 重试边界
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
完成状态、版权、提交信息、review snapshot 和 push 场景的只读准备后,记录 `baseline_head=$(git rev-parse HEAD)`,并在任何 commit、push、任务成功日志或平台成功同步之前调用:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head" --attempt "$commit_attempt")
|
|
24
|
-
commit_intent_token=$(printf '%s' "$commit_intent_result" | node -e 'let input = ""; process.stdin.on("data", chunk => input += chunk).on("end", () => process.stdout.write(JSON.parse(input).token))')
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
`commit_intent_token` 只从结构化输出读取一次性 `token`,并仅保存在当前进程内。begin 失败时不得执行后续副作用。
|
|
28
|
-
|
|
29
|
-
## 副作用 checkpoint
|
|
30
|
-
|
|
31
|
-
普通 commit 成功后立即记录新 HEAD:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind committed --head "$new_head"
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
push 成功并完成远端复核后立即记录已验证的 remote/ref/HEAD:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind pushed --head "$pushed_head" --remote "$remote" --ref "$ref"
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
push-only 路径跳过 committed checkpoint,pushed HEAD 必须等于 begin 时的 baseline HEAD。
|
|
44
|
-
|
|
45
|
-
## 完成与恢复
|
|
46
|
-
|
|
47
|
-
committed/pushed checkpoint 完成后、任务同步与 `task-verify commit.completed` 之前调用:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
- begin 已创建 intent、但第一个副作用前失败时,先在 HEAD 仍等于 baseline 时调用 `commit-abort --token ... --expected-head ...`;若本轮明确放弃,再调用 `commit-terminate --attempt "$commit_attempt" --agent {standard-agent-token} --code <STABLE_CODE>` 闭合 started。
|
|
54
|
-
- begin 在 intent 创建前失败时可保留 attempt 供下次复用;明确放弃时仅可在 HEAD 未漂移时调用 `commit-terminate`。
|
|
55
|
-
- commit 或 push 发生后失败时不得 abort;保留 intent,并调用 `commit-status` 输出不含 token/digest 的恢复证据。跨会话重跑通过 `commit-recover` 收尾。
|
|
56
|
-
- `commit-complete` 失败时停止。不得重复执行 commit/push,也不得把缺少完整 receipt 生命周期的 run 标记为完成。
|
|
21
|
+
重跑重新读取当前 HEAD、worktree、branch 和 remote 事实。已有本地 commit 时只补 push,不创建第二个 commit;taskless 重跑不创建任何任务记录。orchestrated receipt 的 stage completion、seal 和 consume 由 orchestration core 负责,不由 direct 路径伪造。
|
|
@@ -4,6 +4,6 @@ Run only when `{task-id}` is valid and task.md has a valid `pr_number`.
|
|
|
4
4
|
|
|
5
5
|
1. Run `agent-infra-internal platform-pr summary-context {task-id}`.
|
|
6
6
|
2. Generate the plain summary body per `.agents/rules/pr-sync.md` and write it to a temporary file.
|
|
7
|
-
3. Run `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file}`.
|
|
7
|
+
3. Run `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --result no_op`. The commit path only synchronizes an existing PR summary and neither creates nor reuses a PR, so `no_op` explicitly represents the unchanged PR identity.
|
|
8
8
|
|
|
9
9
|
Failure records a warning but never blocks or rolls back the completed commit. `no-op` maps to `summary skipped (no diff)`.
|