@kylecheng3146/agent-ops 0.2.7 → 0.3.0
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/dist/packages/cli/src/args.js +48 -2
- package/dist/packages/cli/src/bin.js +67 -3
- package/dist/packages/cli/src/cli.js +31 -0
- package/dist/packages/cli/src/commands/hook.js +4 -1
- package/dist/packages/cli/src/commands/parallel.js +87 -0
- package/dist/packages/cli/src/commands/review.js +6 -2
- package/dist/packages/cli/src/hook-process.js +31 -7
- package/dist/runtime/src/adapters/agy/output.js +2 -1
- package/dist/runtime/src/adapters/claude/config.js +4 -1
- package/dist/runtime/src/adapters/claude/input.js +24 -0
- package/dist/runtime/src/adapters/claude/output.js +2 -1
- package/dist/runtime/src/config/merge.js +10 -2
- package/dist/runtime/src/hooks/codex-loop.js +11 -1
- package/dist/runtime/src/hooks/completion-gate.js +141 -7
- package/dist/runtime/src/hooks/dispatch.js +5 -0
- package/dist/runtime/src/install/doctor.js +4 -1
- package/dist/runtime/src/install/harness.js +1 -1
- package/dist/runtime/src/install/plan.js +4 -1
- package/dist/runtime/src/parallel/finish.js +263 -0
- package/dist/runtime/src/parallel/guard.js +59 -0
- package/dist/runtime/src/parallel/manage.js +147 -0
- package/dist/runtime/src/parallel/service.js +263 -0
- package/dist/runtime/src/review/attestation.js +87 -0
- package/dist/runtime/src/review/runner.js +27 -1
- package/dist/runtime/src/schema/validate.js +50 -1
- package/docs/en/guides/configuration.md +42 -0
- package/docs/en/spec/delegation.md +10 -0
- package/docs/zh-TW/guides/configuration.md +40 -0
- package/docs/zh-TW/spec/delegation.md +11 -1
- package/package.json +1 -1
- package/schemas/config.schema.json +35 -0
|
@@ -132,6 +132,48 @@ agent-ops doctor --check-auth # one real print call per target
|
|
|
132
132
|
reports what to do but never fixes it: every target authenticates through
|
|
133
133
|
interactive OAuth, so there is no `--fix`. Run `<target> login` yourself.
|
|
134
134
|
|
|
135
|
+
### Parallel sessions in worktrees
|
|
136
|
+
|
|
137
|
+
Verification, review and the completion gate all fingerprint the whole Git
|
|
138
|
+
change surface, so two conversations editing one checkout void each other's
|
|
139
|
+
evidence. Give each editing conversation its own worktree instead:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"worktree": {
|
|
144
|
+
"mode": "auto",
|
|
145
|
+
"setup": [{ "command": "pnpm", "args": ["install", "--frozen-lockfile"] }]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- `mode: "auto"` routes every editing conversation through
|
|
151
|
+
`agent-ops worktree add <name> --session <id>`, run from the main checkout.
|
|
152
|
+
On Claude Code a direct Edit or Write of the main checkout outside
|
|
153
|
+
`.worktrees/` is denied (run `agent-ops update` once so the PreToolUse hook
|
|
154
|
+
matches the file tools). Absent or `"off"` keeps today's single checkout.
|
|
155
|
+
- `add` creates `.worktrees/<name>` on branch `agent-ops/<name>` from the main
|
|
156
|
+
checkout's HEAD and excludes `/.worktrees/` through `.git/info/exclude`,
|
|
157
|
+
never `.gitignore`. It copies the ignored files agent-ops installed and any
|
|
158
|
+
file matched by a root `.worktreeinclude` (gitignore syntax, for example
|
|
159
|
+
`.env` or `local.properties`); a file Git already checked out is never
|
|
160
|
+
overwritten. Trust is inherited only when the main checkout is trusted and
|
|
161
|
+
the worktree's effective config is identical.
|
|
162
|
+
- `setup` commands run in the new worktree (default timeout ten minutes) for
|
|
163
|
+
what Git does not carry, such as installed dependencies. They are part of
|
|
164
|
+
the trusted config, so they need no separate approval; a failing step
|
|
165
|
+
removes the worktree again.
|
|
166
|
+
- The session's completion gate follows it: Claude Code enters the worktree
|
|
167
|
+
with EnterWorktree, and a host that cannot move a session (agy) is judged by
|
|
168
|
+
the worktree's gate through a redirect the main checkout records.
|
|
169
|
+
- `agent-ops worktree finish <name>` merges by fast-forward only, one finish
|
|
170
|
+
at a time. If the target moved, it rebases; a clean rebase whose own patch
|
|
171
|
+
is unchanged is re-verified before merging, and a conflict is reported with
|
|
172
|
+
the `refs/notes/agent-ops` intent of the work that landed first.
|
|
173
|
+
- `worktree list`, `resume <name> --session <id>` and `remove <name>` manage
|
|
174
|
+
what is left; `remove --force` discards work and asks the user first.
|
|
175
|
+
`doctor` reports worktrees idle for more than seven days.
|
|
176
|
+
|
|
135
177
|
### Project-local loop profile
|
|
136
178
|
|
|
137
179
|
`--profile loop` is an opt-in project-scope profile. Select `codex`, `claude`,
|
|
@@ -29,3 +29,13 @@ Concurrent delegated writers MUST NOT share one working tree.
|
|
|
29
29
|
- Evidence: `agent-ops verify` returns a status other than `UNKNOWN` for the run.
|
|
30
30
|
- Positive: `Read-only scans run in parallel; the single edit runs in the coordinator worktree.`
|
|
31
31
|
- Negative: `Two subagents edit the same files while verification runs.`
|
|
32
|
+
|
|
33
|
+
## DELEGATE-ISOLATION-002
|
|
34
|
+
|
|
35
|
+
Parallel editing conversations in one repository MUST each work in their own agent-ops worktree.
|
|
36
|
+
|
|
37
|
+
- Trigger: `worktree.mode` is `auto`, or a second conversation will edit the repository while another is still open.
|
|
38
|
+
- Action: Run `agent-ops worktree add <name> --session <id>` from the main checkout before the first edit, work only in the printed path, and merge with `agent-ops worktree finish <name>` after the task completes against the printed `--base`.
|
|
39
|
+
- Evidence: `agent-ops worktree list` shows one worktree per editing session, and each finish reports a fast-forward merge.
|
|
40
|
+
- Positive: `Two conversations edit .worktrees/login and .worktrees/cart; each verifies, reviews and finishes on its own.`
|
|
41
|
+
- Negative: `Two conversations edit the main checkout at once, so each one's verification and review is voided by the other's writes.`
|
|
@@ -116,6 +116,46 @@ agent-ops doctor --check-auth # 每個目標一次真實 print 呼叫
|
|
|
116
116
|
不會代為修復:所有目標都經由互動式 OAuth 認證,因此沒有 `--fix`。
|
|
117
117
|
請自行執行 `<target> login`。
|
|
118
118
|
|
|
119
|
+
### 在 worktree 中並行 session
|
|
120
|
+
|
|
121
|
+
Verification、review 與 completion gate 都對整個 Git change surface 計算
|
|
122
|
+
fingerprint,因此兩個對話修改同一個 checkout 會互相作廢對方的 evidence。
|
|
123
|
+
請讓每個修改中的對話使用自己的 worktree:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"worktree": {
|
|
128
|
+
"mode": "auto",
|
|
129
|
+
"setup": [{ "command": "pnpm", "args": ["install", "--frozen-lockfile"] }]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- `mode: "auto"` 讓每個修改中的對話都先在主 checkout 執行
|
|
135
|
+
`agent-ops worktree add <name> --session <id>`。Claude Code 直接以 Edit 或
|
|
136
|
+
Write 修改主 checkout 中 `.worktrees/` 以外的檔案會被拒絕(需先執行一次
|
|
137
|
+
`agent-ops update`,讓 PreToolUse hook 比對檔案工具)。未設定或 `"off"` 則維持
|
|
138
|
+
目前的單一 checkout。
|
|
139
|
+
- `add` 從主 checkout 的 HEAD 建立 `.worktrees/<name>` 與 branch
|
|
140
|
+
`agent-ops/<name>`,並透過 `.git/info/exclude`(而非 `.gitignore`)排除
|
|
141
|
+
`/.worktrees/`。它會複製 agent-ops 安裝的 ignored 檔案,以及根目錄
|
|
142
|
+
`.worktreeinclude`(gitignore 語法,例如 `.env` 或 `local.properties`)比對到
|
|
143
|
+
的檔案;Git 已 checkout 的檔案一律不覆寫。只有主 checkout 已 trusted 且
|
|
144
|
+
worktree 的 effective config 完全相同時才繼承 trust。
|
|
145
|
+
- `setup` 指令在新 worktree 中執行(預設 timeout 十分鐘),處理 Git 不會帶過去
|
|
146
|
+
的東西,例如已安裝的相依套件。它屬於 trusted config 的一部分,不需另外核准;
|
|
147
|
+
任一步驟失敗會移除該 worktree。
|
|
148
|
+
- Session 的 completion gate 會跟著它:Claude Code 以 EnterWorktree 進入
|
|
149
|
+
worktree;無法移動 session 的 host(agy)則透過主 checkout 記錄的 redirect,
|
|
150
|
+
由 worktree 的 gate 判定。
|
|
151
|
+
- `agent-ops worktree finish <name>` 只以 fast-forward 合併,一次只執行一個
|
|
152
|
+
finish。Target 若已前進會先 rebase;沒有衝突且自身 patch 不變的 rebase 會先
|
|
153
|
+
重新驗證再合併;衝突則連同先合併那份工作在 `refs/notes/agent-ops` 的意圖一起
|
|
154
|
+
回報。
|
|
155
|
+
- `worktree list`、`resume <name> --session <id>` 與 `remove <name>` 管理剩下的
|
|
156
|
+
worktree;`remove --force` 會丟棄工作,執行前會先詢問使用者。`doctor` 會回報
|
|
157
|
+
閒置超過七天的 worktree。
|
|
158
|
+
|
|
119
159
|
### Project-local loop profile
|
|
120
160
|
|
|
121
161
|
`--profile loop` 是明確 opt-in 的 project-scope profile。請選擇 `codex`、
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 委派
|
|
2
2
|
|
|
3
|
-
English source version: 2026-
|
|
3
|
+
English source version: 2026-09-24. Revalidate: when the English specification changes.
|
|
4
4
|
|
|
5
5
|
## DELEGATE-SCOPE-001
|
|
6
6
|
|
|
@@ -31,3 +31,13 @@ English source version: 2026-07-23. Revalidate: when the English specification c
|
|
|
31
31
|
- Evidence: `agent-ops verify` 該次執行回傳非 `UNKNOWN` 的狀態。
|
|
32
32
|
- Positive: `唯讀掃描並行執行;唯一的修改在協調者工作區進行。`
|
|
33
33
|
- Negative: `兩個 subagent 在驗證執行期間修改相同檔案。`
|
|
34
|
+
|
|
35
|
+
## DELEGATE-ISOLATION-002
|
|
36
|
+
|
|
37
|
+
同一個 repository 中並行修改檔案的對話 MUST 各自在自己的 agent-ops worktree 中工作。
|
|
38
|
+
|
|
39
|
+
- Trigger: `worktree.mode` 為 `auto`,或另一個對話仍開著時,第二個對話也要修改這個 repository。
|
|
40
|
+
- Action: 第一次修改前,在主 checkout 執行 `agent-ops worktree add <name> --session <id>`,只在印出的路徑中工作;task 以印出的 `--base` 完成後,用 `agent-ops worktree finish <name>` 合併。
|
|
41
|
+
- Evidence: `agent-ops worktree list` 顯示每個修改中的 session 各有一個 worktree,且每次 finish 都回報 fast-forward 合併。
|
|
42
|
+
- Positive: `兩個對話分別修改 .worktrees/login 與 .worktrees/cart;各自驗證、review 並 finish。`
|
|
43
|
+
- Negative: `兩個對話同時修改主 checkout,彼此的寫入讓對方的驗證與 review 全部作廢。`
|
package/package.json
CHANGED
|
@@ -119,6 +119,41 @@
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
|
+
"worktree": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"additionalProperties": false,
|
|
125
|
+
"required": ["mode"],
|
|
126
|
+
"properties": {
|
|
127
|
+
"mode": {
|
|
128
|
+
"enum": ["auto", "off"]
|
|
129
|
+
},
|
|
130
|
+
"setup": {
|
|
131
|
+
"type": "array",
|
|
132
|
+
"items": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"additionalProperties": false,
|
|
135
|
+
"required": ["command", "args"],
|
|
136
|
+
"properties": {
|
|
137
|
+
"command": {
|
|
138
|
+
"$ref": "#/$defs/nonEmptyString"
|
|
139
|
+
},
|
|
140
|
+
"args": {
|
|
141
|
+
"type": "array",
|
|
142
|
+
"items": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"pattern": "^[^\\u0000]*$"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"timeoutMs": {
|
|
148
|
+
"type": "integer",
|
|
149
|
+
"minimum": 1,
|
|
150
|
+
"maximum": 2147483647
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
122
157
|
"securityExceptions": {
|
|
123
158
|
"type": "array",
|
|
124
159
|
"items": {
|