lycheedev 1.1.0 → 1.1.1

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.
@@ -1,413 +1,128 @@
1
- # Automation: task delivery, reload and receipt
2
-
3
- This reference covers the automated loop between an Agent, the Python tooling
4
- in `scripts/`, and the in-game Automation page (`/dev` > Automation). The full
5
- design lives in the addon repository at
6
- `add-on/docs/design/AutomationOpticalTransport.md`; this page is the practical
7
- contract and describes the CLI exactly as implemented.
8
-
9
- ## The loop in one paragraph
10
-
11
- You (the Agent) prepare a bounded Lua probe and deliver it as one task block in
12
- the installed `Modules/Automation/auto/auto.lua`. The block only registers
13
- data; it never runs at load. After an input-side `/reload`, the command
14
- `/dev auto run <task-id>` executes the block. While it runs, three RGB status
15
- blocks show at the top-left of the screen. When the result is committed to the
16
- in-memory SavedVariables database, they are replaced by one static QR code at
17
- the top-left that carries only the identity:
18
- `{"v":1,"ticket":"...","task":"...","run":"...","ts":...}`. `capture`, `run`
19
- and `bugs` keep one WGC capture session open and poll it until that notice is
20
- decoded or `--timeout` expires. The tooling then cross-checks the notice `task`
21
- and `run` against the request it actually delivered, logs a `reload_requested`
22
- intent, sends one `/reload` so the game writes the database to disk, then reads
23
- the exact Ticket out of the SavedVariables file, verifies its identity,
24
- payload and checksum, and stores the complete report as local artifacts.
25
- `/dev auto bug <n>` skips the task file and the input-side reload; it snapshots
26
- recent error records and follows the same notice -> reload -> read path.
27
-
28
- ## Hard rules
29
-
30
- - One execution per client at a time: while a request is running the addon
31
- answers new requests with a busy message. Finished results that you have not
32
- acknowledged may queue up to three; only the cap refuses new work, and a
33
- reload resets the count.
34
- - Always acknowledge what you read. The addon cannot see whether a result was
35
- picked up, so run `ack --status received` (or `failed`) after reading one.
36
- Without it the result keeps occupying a backlog slot until a reload.
37
- - The same `requestId` never executes twice in one session; re-running the
38
- command re-shows the same notice instead.
39
- - Results awaiting their reload are protected: normal export pruning, record
40
- deletion and cache clears skip them. `/dev auto stop` only hides the notice
41
- UI; it never cancels a run and never deletes pending results.
42
- - One notice triggers at most one reload. The host log deduplicates on
43
- `(installation, requestId, ticket)`; after a script restart, check the log
44
- and the SavedVariables file before repeating anything.
45
- - A decoded notice is accepted only when its `task` (and `run`, when known)
46
- matches the command that was just delivered. A stale QR left on screen from
47
- an earlier run is logged as `notice_identity_mismatch` and ignored.
48
- - Host wait timeouts mean "unknown", not "failed": never auto-rerun a task
49
- because its notice was missed. Inspect first (see Recovery).
50
-
51
- ## Task blocks
52
-
53
- Write task blocks only through the CLI so locking, escaping and limits stay
54
- correct:
1
+ # 后台自动化闭环
55
2
 
56
- ```text
57
- python scripts/automation.py task upsert --install-dir <addon dir> \
58
- --id inspect-example --source-file probe.lua \
59
- --request-id req-20260912-000001-aaaaaa --revision rev-1
60
- python scripts/automation.py task list --install-dir <addon dir>
61
- python scripts/automation.py task remove --install-dir <addon dir> --id inspect-example
62
- ```
3
+ 检索:目标绑定、任务区块、状态、执行、错误快照、ACK、恢复、清理、证据。
63
4
 
64
- - Task IDs are `[A-Za-z0-9_-]{1,64}`. Each Agent owns its own task IDs;
65
- never remove or rewrite another task's block.
66
- - A new execution needs a new `requestId`. Updating the source always means a
67
- new `requestId` and a new `revision`.
68
- - The writer verifies `--expect-revision` on replacement, holds an exclusive
69
- lock file (`auto.lua.lock` in the installation directory), preserves
70
- everything outside the `BEGIN`/`END LYCHEE DEV TASK` markers verbatim, and
71
- replaces the file atomically. It refuses more than 16 blocks, more than
72
- 1 MiB of registry, or a source over 256 KiB.
73
- - The source file is read as raw bytes and must be valid UTF-8, but it does not
74
- have to be ASCII: the generated Lua shell stays ASCII and escapes every
75
- non-ASCII byte as `\ddd`. `sourceBytes` and the block's `sourceChecksum` are
76
- computed on those exact source bytes, so a CRLF source file keeps its CRLF.
77
- - `task upsert` prints one JSON object:
78
- `{"taskId":...,"requestId":...,"revision":...,"sourceBytes":N,"fileHash":"<sha256 of the written file>"}`.
79
- `fileHash` is recorded after the atomic write, so it identifies the file
80
- revision another writer may have replaced.
81
- - `task list` prints `taskId<TAB>requestId<TAB>revision<TAB>sourceBytesB`;
82
- `task remove` prints `removed <id>` or `<id> not present`.
83
- - Task sources must be Lua 5.1 with clear boundaries: register cleanup
84
- handlers with `ctx.OnCleanup(fn)`, stop your own timers/frames/events there.
85
- - Release packaging always ships an empty registry; keep local probes out of
86
- commits.
87
-
88
- ## The execution context
89
-
90
- The task runs with full access to WoW globals inside a captured environment:
91
-
92
- - `print(...)` — captured into the report stdout (bounded by the block's
93
- `outputLimit`, default 384 KiB).
94
- - `Finish(value, ...)` — complete the task successfully with return values.
95
- - `Fail(message[, code])` — complete as failed.
96
- - `SetAsync()` — declare the task asynchronous; the chunk returning then does
97
- NOT complete it. Sync tasks end when they return; async tasks must call
98
- `Finish`/`Fail` from their own callbacks. Late callbacks are ignored.
99
- - `IsCancelled()` — cooperative cancel flag; `/dev auto cancel <task-id>`
100
- finalizes the run as `cancelled` and runs your cleanup handlers.
101
- - `OnCleanup(fn)` — register cleanup; handlers run on any finalization.
102
- - `Log(message)` — bounded lifecycle log line (128 entries / 16 KiB in the
103
- report).
104
-
105
- The architecture cannot force-stop an infinite loop and cannot roll back side
106
- effects. Generate bounded, cancellable probes only.
107
-
108
- ## In-game commands
109
-
110
- | Command | Behavior |
111
- | --- | --- |
112
- | `/dev` | Opens the workbench (unchanged). |
113
- | `/dev auto run <task-id>` | Validates the loaded block and executes its current request. |
114
- | `/dev auto bug <1-100> [request-id]` | Snapshots up to 100 saved error records (all sessions, provider storage order, newest last-first). |
115
- | `/dev auto status <task-id>` | Prints the latest execution state; re-shows the notice when the result still exists. |
116
- | `/dev auto show <ticket>` | Re-shows the notice for a kept historical result. |
117
- | `/dev auto cancel <task-id>` | Cooperative cancel; saves a cancelled report and its Ticket. |
118
- | `/dev auto ack <ticket> received\|failed` | Records that the host read this ticket (or failed to). Clears the pending-flush block so the next run can start **without a reload**. |
119
- | `/dev auto identify` | Shows the identity marker: a small QR code at the top-left carrying this character, realm, client and build, so a host with several windows open can learn which window is which. Not shown by default; it shares the corner with the completion notice. |
120
- | `/dev auto unidentify` | Hides the identity marker. |
121
- | `/dev auto stop` | Hides the notice UI only; the pending record and the busy state stay. |
122
-
123
- ### Identity marker vs completion notice
124
-
125
- Both are small JSON QR codes at the top-left, and they are told apart by shape, not
126
- by position:
127
-
128
- | | identity marker | completion notice |
129
- | --- | --- | --- |
130
- | has `id` + `client` | yes | no |
131
- | has `ticket` + `task` + `run` | no | yes |
132
- | shown when | the user runs `/dev auto identify` | a result is committed |
133
- | purpose | identify the window before input | deliver the ticket after a run |
5
+ ## 工具与协议
134
6
 
135
- `lycheedev instances --identify` reads the markers through window capture, so no
136
- window is focused and nothing is typed. This is what lets a caller name the window
137
- it is about to drive instead of guessing from a pid. Two windows showing the same
138
- character and realm remain indistinguishable.
7
+ 发送使用 Python `scripts/automation.py` 的 `--mode messages`(当前默认);读取使用 WGC + zxing-cpp。不要重写 ctypes 投递、拼接临时按键脚本或改成 GDI。Node CLI 负责安装/发现,游戏与 SV 逻辑由 Python 持有。
139
8
 
140
- ### Reporting the read outcome back
9
+ 运行时 RGB 色块表示状态;完成 QR 只包含版本、Ticket、task、requestId、时间戳等短元数据:
141
10
 
142
- The plugin cannot observe whether the host actually read a result, so nothing on
143
- the game side changes when a ticket is picked up. While a result is pending its
144
- disk write, the controller answers every new request with the busy message, and
145
- that block only ends with a reload — unless you tell it what happened:
146
-
147
- ```text
148
- python scripts/automation.py --installation retail-main ack \
149
- --hwnd 0x1234 --ticket LYCHEE-... --status received
11
+ ```json
12
+ {"v":1,"ticket":"LYCHEE-...","task":"probe","run":"req-...","ts":1234567890}
150
13
  ```
151
14
 
152
- That sends `/dev auto ack <ticket> received` through the normal command channel.
153
- Use `--status failed` when the read failed; the reason stays in your host log.
154
- The index record keeps `receivedAt` and `receivedStatus`, and the Automation page
155
- shows "Read by the host" / "Host read failed" instead of a permanent
156
- "Awaiting reload". Acknowledging an unknown ticket or an invalid status changes
157
- nothing and reports why.
15
+ 无论正文大小,一律在输出 reload 后读取 SavedVariables。二维码不承担正文传输。成功/失败/取消都可能生成报告,必须读取报告的 status/complete/incompleteReasons,不能看见二维码就说调查成功。
158
16
 
159
- The built-in error task is reported with task ID `bug` and inner report
160
- `requestType` `bug`; its `params` are `{"count": n, "scope": ...}`.
17
+ 固定一个稳定的 `--installation` 标识(对应安装目录与会话绑定),并在所有命令中沿用同一个 `--data-dir`。宿主默认目录是 `%LOCALAPPDATA%/LycheeDev/automation`,保存 `session.log.jsonl`、配置和 `received/<Ticket>/` 下的 evidence/report/content 文件。插件内存中的数据库只有在 reload、退出或登出后才落盘。
161
18
 
162
- ## Host CLI
19
+ ## 职责和完成边界
163
20
 
164
- Global options, valid for every subcommand:
21
+ Agent 负责目标选择、设计有界 Lua、连续推进各阶段、解释异常。Python 负责注册表原子更新、输入、QR 校验、reload 去重、SV 校验和 ACK。当前不存在一个涵盖所有步骤的 `workflow` 命令;用下面的真实命令连续编排,不让用户逐条接力。
165
22
 
166
- - `--data-dir <dir>` — host data directory holding the log, artifacts and
167
- profiles; default `%LOCALAPPDATA%\LycheeDev\automation`.
168
- - `--installation <name>` — installation scope for the log and the reload
169
- dedup key; default `default`. Pass the same name to every command of one
170
- orchestration session, and use `--all-installations` when inspecting more
171
- than one.
23
+ | 阶段 | 通过证据 | 下一步 |
24
+ | --- | --- | --- |
25
+ | 目标绑定 | 本次进程与产品/角色/安装匹配 | 写自己的任务区块 |
26
+ | 源码已准备 | upsert 的 hash/requestId/revision | 输入侧 reload 使新源码加载 |
27
+ | 输入已提交 | command_submitted,仅表示投递完成 | 等待匹配 task/run 的完成 QR |
28
+ | 游戏已完成 | 匹配 QR | 输出 reload 一次 |
29
+ | 已落盘读取 | 精确 Ticket、环境、完整性和校验通过 | ACK received |
30
+ | ACK 已确认 | Ticket/nonce/status 匹配 | 按该 nonce 清理并观察码消失 |
31
+ | 已收尾 | ticket_ack_cleared;自有测试资源处理完成 | 向用户报告结果 |
172
32
 
173
- ### identify
33
+ `run`/`bugs` 当前负责到 SV 读取,不自动执行 `ack`。返回 0 后必须继续 ACK。`send` 返回 0 不能当作游戏成功。`recover` 没有未决 reload 也不证明 ACK/界面清理完成,需要检查对应阶段事件。
174
34
 
175
- Reads the in-game identity marker from one or more game windows, so a window can
176
- be named before anything is typed into it. Nothing observable from outside the
177
- game says which character is behind which window; the marker is how the game
178
- tells you.
35
+ ## 准备任务
36
+
37
+ 目标目录是 `<addon>/Modules/Automation/auto/auto.lua`,按 task-id 分区。只能通过注册表工具改自己的区块,保留别人的块和标记外文本:
179
38
 
180
39
  ```text
181
- python scripts/automation.py identify --hwnd 0x1234 [--hwnd 0x5678] [--timeout 1.5]
182
- python scripts/automation.py identify --windows-json <instances.json>
40
+ python <skill>/scripts/automation.py --installation <binding> task upsert --install-dir <addon> --id <task> --source-file <probe.lua> --request-id <request> --revision <revision> --expected-interface <interface>
183
41
  ```
184
42
 
185
- - `--windows-json <file>` takes the instance list printed by
186
- `lycheedev instances`; each entry needs an `hwnd`. Prefer this when probing
187
- several windows, because the list survives the trip intact.
188
- - Prints one entry per window, in the input order, as JSON:
189
- `{"hwnd":...,"pid":...,"flavorId":...,"identity":{...}|null,"error":null|"..."}`.
190
- - **`identity: null` is not an error.** It is the ordinary state until the user
191
- runs `/dev auto identify` in that window. Only `error` marks a window that
192
- could not be probed.
193
- - Exit code 5 means no window yielded a marker (including when every window was
194
- unreadable); a partly readable set exits 0. A missing capture package exits 4.
195
- - Capture reads the window surface directly, so **no window needs the
196
- foreground** and nothing is typed. Windows are probed concurrently.
197
- - A window showing the completion notice instead of a marker is not
198
- mis-identified: the two payloads are told apart by shape, not position.
199
-
200
- Ask the user to run `/dev auto identify` in each window they care about, then
201
- probe, then confirm the character back to them before sending any command.
202
- `/dev auto unidentify` hides the marker again.
203
-
204
- ### task
205
-
206
- `task upsert|remove|list` with `--install-dir <dir>` or `--profile <name>`.
207
- Upsert also takes `--id`, `--source-file`, `--request-id`, `--revision`,
208
- `--expect-revision`, `--created-at`, `--expires-at`, `--expected-interface`
209
- and `--output-limit`. Generated IDs are `req-<UTC stamp>-<hex>`.
210
-
211
- ### profile
43
+ task-id 是 `[A-Za-z0-9_-]{1,64}`;requestId 建议只用字母、数字、点、连字符(兼容插件与 Python)。一项新执行分配新 requestId,源码变化同时换 revision;超时恢复保持原 requestId。更新已有块时用 `--expect-revision` 防覆盖。
212
44
 
213
- ```text
214
- python scripts/automation.py profile set --name retail-main --client retail \
215
- --wow-root <WoW root> --addon-dir <addon dir> \
216
- --sv-path "<WoW>/WTF/Account/<account>/SavedVariables/Lychee Dev.lua"
217
- python scripts/automation.py profile show --name retail-main
218
- ```
45
+ 源码是 UTF-8 Lua 5.1,最多 256 KiB;注册表最多 16 块/1 MiB。标准输出限制默认 384 KiB、最大 512 KiB,以实际安装工具限制为准。不要用不受支持的 schema/kind 扩展协议。区块只注册数据,不会加载即执行。
219
46
 
220
- `profile set` requires `--client`, `--wow-root` and `--addon-dir`; both
221
- directories must exist. `--client` accepts `retail`, `classic`, `titan` and
222
- `forever`. The stored profile records the client folder, and every accepted
223
- location for that client is kept so a build that moved folders still resolves:
47
+ 同步调查返回紧凑结构。异步调查调用 `SetAsync()`,通过 `Finish(...)` 或 `Fail(message, code)` 完成,用 `OnCleanup(fn)` 释放自己创建的资源,检查 `IsCancelled()`;`Log` 与 `print` 输出有界。不得返回尚未完成的表并指望后来修改自动保存。
224
48
 
225
- | `--client` | Client folder |
226
- | --- | --- |
227
- | `retail` | `_retail_` |
228
- | `classic` | `_classic_` |
229
- | `titan` | `_classic_titan_` |
230
- | `forever` | `_classic_beta_`, or `_forever_` |
49
+ 输入侧 reload:发送 `/reload` 后等待客户端恢复可交互状态再发执行命令。SV mtime 变化只证明开始写盘,不证明加载已结束。用 WGC 观察世界画面恢复或验证过的就绪信号;固定等待数秒不能单独作为就绪证明。不得因暂时加载中而连续发命令试探。
231
50
 
232
- A folder name is a location rather than an identity: WoW: Forever currently ships
233
- in `_classic_beta_` on the test track, which a MoP-era classic test client also
234
- uses. `sv find` therefore tries every accepted folder under `--wow-root` and
235
- falls back to the root itself, rather than trusting the recorded name.
236
- Profiles are written atomically to `<data-dir>/profiles.json`.
51
+ ## 执行已绑定账户的任务
237
52
 
238
- ### sv find / sv read
53
+ 下面示例的全局 `--data-dir`(如有)放在子命令前。全部窗口操作沿用本次绑定:
239
54
 
240
55
  ```text
241
- python scripts/automation.py --installation retail-main sv find --profile retail-main
242
- python scripts/automation.py --installation retail-main sv read --profile retail-main \
243
- --ticket LYCHEE-... --task inspect-example --request-id req-... --revision rev-1
56
+ python <skill>/scripts/automation.py --installation <binding> send --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --text "/reload"
57
+ python <skill>/scripts/automation.py --installation <binding> run --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --task <task> --install-dir <addon> --sv <verified-sv> --timeout 120
244
58
  ```
245
59
 
246
- - `sv find` requires `--profile`, resolves the client folder under `--wow-root`
247
- (a profile may point at the WoW root or at the client folder itself) and
248
- prints each account-level `SavedVariables/Lychee Dev.lua` candidate. It exits
249
- 1 when there is no candidate.
250
- - `sv read` requires `--ticket` plus either `--sv <path>` or `--profile`. It
251
- refuses any file that is not named `Lychee Dev.lua` and refuses `.bak`.
252
- - Optional identity checks: `--task`, `--request-id`, `--revision`,
253
- `--created-at`, `--request-type task|bug`.
254
- - `--retries` (default 3) and `--retry-delay` (default 0.5 s) bound the reads
255
- of a torn, replaced or temporarily unreadable file; the failure message
256
- reports how many attempts were made.
257
- - The reader uses a restricted parser (no Lua evaluation), exactly locates
258
- `LycheeDevDB.exports.records[TICKET]`, verifies the envelope (`schema`,
259
- `ticket`, `createdAt`), the payload (`mediaType` `application/json`,
260
- `encoding` `utf-8`, real UTF-8 byte count against `byteCount`, 1 MiB report
261
- limit), the metadata identity (`taskId`, `executionId`, `revision`,
262
- `resultSchema`, terminal `status`, `complete`, `checksumAlgorithm adler32`)
263
- and recomputes the Adler-32 `contentChecksum`. It then parses the inner
264
- `lychee.automation.result.v1` JSON report and verifies its version, terminal
265
- status, `complete`/`incompleteReasons`, client/character `environment`,
266
- `requestType` and, for bug reports, `params`.
267
- - Success prints
268
- `{"ticket":...,"status":...,"complete":...,"byteCount":N,"sha256":"...","attempts":N,"artifacts":{...}}`.
269
- - Artifacts (`evidence.json`, `report.json`, `content.json`) land under
270
- `<data-dir>/received/<ticket>/` and are written byte-for-byte: the recorded
271
- `byteCount` and SHA-256 describe the exact bytes on disk, with no newline
272
- translation of `payload.content`. The host log records `received` with the
273
- attempt count and whether the file changed during the read.
274
-
275
- ### capture / send
60
+ 不要把两条命令无条件贴在同一个连续执行脚本里:输入 reload 后需先确认就绪。`run` 读取安装区块的 requestId/revision,提交 `/dev auto run <task>`,过滤旧完成码,记录输出 reload 去重键,再校验 SV 并保存完整报告。
61
+
62
+ 账户未绑定时按 [clients.md](clients.md) 分段执行:`send` 运行、`capture` 取码、Agent 验证 task/run、带 requestId/Ticket 发送一次 `/reload`、定位精确记录,再 `sv read`。`capture` 本身只验证 QR 格式,不知道本次预期 task/run,不能拿任何码直接触发 reload。
276
63
 
277
64
  ```text
278
- python scripts/automation.py capture --hwnd 0x1234 [--pid <pid>] [--exe-path <exe>] \
279
- [--timeout 120] [--interval 0.1]
280
- python scripts/automation.py send --hwnd 0x1234 --text "/reload" \
281
- [--pid <pid>] [--exe-path <exe>] [--request-id req-... --ticket LYCHEE-...]
65
+ python <skill>/scripts/automation.py --installation <binding> send --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --text "/dev auto run <task>"
66
+ python <skill>/scripts/automation.py capture --hwnd <hwnd> --pid <pid> --exe-path <exe> --timeout 120
67
+ python <skill>/scripts/automation.py --installation <binding> send --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --text "/reload" --request-id <request> --ticket <ticket>
68
+ python <skill>/scripts/automation.py --installation <binding> sv read --sv <matched-sv> --ticket <ticket> --task <task> --request-id <request> --revision <revision> --request-type task
282
69
  ```
283
70
 
284
- - `capture` opens one `windows-capture` session for the window, decodes the
285
- QR with `zxingcpp.read_barcodes` (QR only) and prints the notice JSON. It
286
- compares the top-left ROI on every `--interval` (default 0.1 s) until
287
- `--timeout` (default 120 s) expires, then exits 5. Only the newest ROI is
288
- kept, so frames never pile up.
289
- - `send` always logs `command_sent` before input. When the text is `/reload`
290
- and both `--request-id` and `--ticket` are given it also applies the reload
291
- dedup key, so the same notice can never trigger a second reload.
292
- - Both confirm the window identity (HWND, and `--pid`/`--exe-path` when given)
293
- immediately before use and re-check the foreground before typing.
71
+ 同一个 `(installation, requestId, Ticket)` 的输出 reload 只允许自动发一次。写盘暂时未完成时进行有界读取等待,不重跑 Lua。
294
72
 
295
- ### run / bugs
73
+ ## 最近 n 条错误
296
74
 
297
75
  ```text
298
- python scripts/automation.py --installation retail-main run \
299
- --task inspect-example --sv "<...>/Lychee Dev.lua" --hwnd 0x1234 \
300
- --install-dir <addon dir> [--request-id req-...] [--revision rev-1] \
301
- [--timeout 120] [--interval 0.1]
302
- python scripts/automation.py --installation retail-main bugs \
303
- --count 20 --sv "<...>/Lychee Dev.lua" --hwnd 0x1234 [--timeout 120] [--interval 0.1]
76
+ python <skill>/scripts/automation.py --installation <binding> bugs --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --count <n> --request-id <request> --sv <verified-sv> --timeout 120
304
77
  ```
305
78
 
306
- - `run` does not send the input-side `/reload` itself: after `task upsert` the
307
- new block is only in the file, so reload the client first (or run a task that
308
- is already loaded), then call `run`.
309
- - `run` delivers `/dev auto run <task-id>`, then polls for a notice whose
310
- `task` equals `--task` and whose `run` equals the loaded block's `requestId`
311
- (read from `Modules/Automation/auto/auto.lua` when `--install-dir` or
312
- `--profile` is given). A missing task block is an explicit failure.
313
- - `bugs` validates that `--count` is 1-100 without silently fixing it,
314
- delivers `/dev auto bug <count>` and requires a notice with task `bug`.
315
- - On a matching notice both flows log the `reload_requested` intent, snapshot
316
- the SV file, send one `/reload`, wait for the file to change within
317
- `--timeout`, then run the same verification as `sv read`.
318
- - Because a task can run far longer than one capture interval, the capture
319
- session stays open for the whole wait; it stops when the notice is decoded,
320
- the window closes, or the timeout expires.
321
-
322
- ### status / recover
79
+ n 在 1–100 之间。该流程发送 `/dev auto bug <n> <request>`,完成码 task 为 `bug`,内层报告 requestType 为 `bug`。数量是上限;按 provider storage order 读取可能跨会话的现有日志,不能未经核对就声称是本次测试产生的 n 个错误。报告保留 scope/排序信息,不用 metadata 代替错误正文。账户未知时同样分段定位 Ticket。
80
+
81
+ ## ACK 与正常收尾
82
+
83
+ SV 内容已完整验证后发送 received;读失败但已明确决定结束本次接收才用 failed,不把一次暂时读盘失败直接 ACK 为失败。
323
84
 
324
85
  ```text
325
- python scripts/automation.py --installation retail-main status --limit 50 [--event received]
326
- python scripts/automation.py --installation retail-main recover
86
+ python <skill>/scripts/automation.py --installation <binding> ack --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --ticket <ticket> --status received --timeout 30
327
87
  ```
328
88
 
329
- Both read the host log scoped to `--installation` (use `--all-installations`
330
- to read every scope). `status` prints the most recent records (`--limit`,
331
- default 20; 0 prints all). `recover` prints recent records and lists tickets
332
- whose reload was requested but never received. For those, read the
333
- SavedVariables file first: if the Ticket is already on disk, run `sv read`
334
- directly; if not, exactly one explicit reload retry is allowed — never a loop.
335
- If the game crashed before writing, the report is lost; record that
336
- uncertainty in your findings.
89
+ 输出 reload 后先确认世界已恢复。ACK 分配新 nonce,等待含该 nonce、Ticket 和 outcome 的 QR;随后发送 `/dev auto unidentify <nonce>`,只隐藏对应 ACK 标记,再观察该码消失。`ticket_ack_confirmed` 和 `ticket_ack_cleared` 分开记录;确认成功但清理超时不等于任务失败。
337
90
 
338
- ## Exit codes
91
+ 旧版插件只支持两参数 ACK,不支持 nonce 清理。使用前核对工具与插件协议版本;授权的测试/更新应备份后同步相应源码并 reload。不能在旧插件上持续重试不支持的命令。`/dev auto unidentify` 无参数会隐藏身份标记,仅在明确属于自己的标记且没有新回执时用;不能用通用 stop 掩盖未处理证据。
339
92
 
340
- | Code | Meaning |
341
- | --- | --- |
342
- | 0 | Success. |
343
- | 1 | Invalid usage, missing binding/profile, unsafe path refused, non-UTF-8 source, or an unexpected failure (with traceback). |
344
- | 2 | Task registry failure (schema, kind, marker, revision conflict, lock/limit refusal). |
345
- | 3 | SavedVariables read or verification failure after all attempts. |
346
- | 4 | Window identity, command input, or missing optional capture dependency (`windows-capture`/`numpy`/`zxing-cpp`) failure. |
347
- | 5 | No notice decoded before the timeout, no window yielded an identity marker, or the game did not rewrite its SavedVariables file in time. |
93
+ 读取 ACK 不需要又一次输出 reload;receivedAt/receivedStatus 留在内存,下一次正常 reload 才持久化。不要为了把确认再确认一遍制造无限 ACK/reload 环。
348
94
 
349
- Expected failures print one `error: ...` line on stderr; they never dump a
350
- traceback for a missing dependency, a missing argument or a bad source file.
95
+ 自有临时任务结束后用 `task remove --install-dir <addon> --id <task>` 清理磁盘区块,保留证据和他人区块;是否额外 reload 清除内存定义按实际需要决定,不为界面整洁无条件多做 reload。
351
96
 
352
- ## Optional dependencies
97
+ ## 完整报告校验
353
98
 
354
- ```text
355
- python -m pip install --target <dir> -r scripts/requirements.txt
356
- ```
99
+ 读取当前 `Lychee Dev.lua`,用受限 Lua 数据解析器定位 `LycheeDevDB.exports.records[Ticket]`。校验 envelope schema/ticket/createdAt、payload 的 UTF-8 字节数与编码、Adler-32、metadata taskId/executionId/revision、内层 schema/status/complete/requestType。Agent 另将 environment 的角色/服务器/产品/build 与当前绑定比较;当前 reader 验证环境结构,不替 Agent 证明它就是选定窗口。
357
100
 
358
- `scripts/requirements.txt` pins the verified versions: `zxing-cpp==3.1.1`,
359
- `windows-capture==2.0.1`, `numpy==2.5.3`, `opencv-python==5.0.0.93`. The code
360
- uses only the interfaces those versions actually expose: `read_barcodes`
361
- (zxing-cpp 3.x, `read_bars` does not exist), `WindowsCapture(window_hwnd=...)`
362
- with `on_frame_arrived`/`on_closed` handlers, `start_free_threaded()` /
363
- `CaptureControl.stop()` and `Frame.convert_to_bgr()`.
101
+ `received/<Ticket>/content.json` 是字节精确的完整 payload,report.json 是解析报告,evidence.json 是外层证据。报告给用户时引用实际文件与 Ticket,不能只给 QR 截图或日志摘要。
364
102
 
365
- `capture`, `run`, `bugs` and `identify` read the screen and need these packages;
366
- without them they fail with an explicit dependency message and exit 4 rather than
367
- a traceback. `send` and `ack` import the same module but only use ctypes, so
368
- keyboard delivery works without them. Everything else — `task`, `profile`, `sv`,
369
- `status`, `recover` — runs on the standard library alone.
103
+ ## 中断、超时与恢复
370
104
 
371
- ## Recovery
105
+ 先读本 installation 的 `status`/`recover`、本次保存的 task/request/Ticket 和当前画面;不要从第一条命令重新开始。
372
106
 
373
- ```text
374
- python scripts/automation.py --installation retail-main recover
375
- python scripts/automation.py --installation retail-main status --event run_unresolved
376
- ```
107
+ | 停留状态 | 恢复动作 |
108
+ | --- | --- |
109
+ | 已 upsert、未确认加载 | 核对源码与客户端状态,完成输入侧 reload,不运行旧区块 |
110
+ | 已提交、无完成码 | 有界等待/只读观察;超时记 unresolved,不自动生成新 request 重跑 |
111
+ | 完成码在屏幕 | 校验 task/run;查是否已请求 reload、Ticket 是否已在 SV,再决定推进 |
112
+ | 已请求 reload、读不到 Ticket | 等待写盘并搜索该安装所有候选;拒绝 newest-file 猜测 |
113
+ | SV 已验证、ACK 未完成 | 只继续 ACK,不重新执行任务或输出 reload |
114
+ | ACK 已确认、码仍显示 | 从日志取原 nonce,仅补对应 unidentify 和读取验证 |
115
+ | HWND/PID/角色变了 | 重新绑定,再恢复只读阶段;不沿用旧窗口序号 |
116
+ | 留有自有未提交草稿 | 核对仍是原窗口,取消草稿;不按 Enter“继续” |
117
+
118
+ 仅在证据证明上次 reload 未执行且任务仍在内存,并处于现有授权内时,允许一次明确记录的恢复 reload;不循环试错。游戏崩溃前未落盘的内容可能丢失,应直接说明。
119
+
120
+ 后台 PostMessage 不使用前台/剪贴板,但队列接受不证明 Escape 被消费或焦点处于聊天框。不要把 SendInput 当补救。输入错误后检查状态,修复明确原因或报告阻塞;不要留下未说明的测试草稿再开始别的用例。
121
+
122
+ 退出码:0 为该命令完成,1 为参数/绑定错误,2 为注册表错误,3 为 SV 读取或验证失败,4 为窗口/输入/依赖问题,5 为回执、写盘或清理观察超时。已经确认的阶段不能因后续阶段失败而被抹掉。
123
+
124
+ ## 依赖与验证范围
125
+
126
+ Python 图像依赖放在 `~/.lycheedev/python`,通过 PYTHONPATH 加载,使用随工具 requirements.txt 的版本;不要装进用户 site-packages。后台发送只依赖 ctypes;QR 读取及 ACK 的确认/清理需要 WGC、numpy、zxing-cpp。缺依赖时先在受管目录修复,不切换传输通道。
377
127
 
378
- `recover` prints recent host log events and lists tickets whose reload was
379
- requested but never received. For those, read the SavedVariables file first:
380
- if the Ticket is already on disk, run `sv read` directly; if not, exactly one
381
- explicit reload retry is allowed — never a loop. `run_unresolved`,
382
- `sv_write_timeout` and `notice_identity_mismatch` records tell you which step
383
- stopped and why. If the game crashed before writing, the report is lost;
384
- record that uncertainty in your findings.
385
-
386
- ## Known verification gaps
387
-
388
- Do not describe these as proven, and do not repeat them as if they were:
389
-
390
- - **On-screen rendering of the notice and identity QR codes.** The encoding
391
- round-trips (the addon's own Lua encoder produces a matrix that the host's
392
- `zxing-cpp` decoder reads back, at every module size from 2 to 8 px), but the
393
- actual pixels drawn by the game have not been measured. Marker size and
394
- scannability under DPI/UI scaling, occlusion, minimization, exclusive
395
- fullscreen and HDR are all unmeasured.
396
- - **Identity probe against a window that really shows a marker.** The capture
397
- pipeline itself has been exercised on a live client (frames arrive in 78-94 ms,
398
- ~3 ms to decode an empty ROI, no frame errors), but no probe has yet read a
399
- marker the game actually rendered. `/dev auto identify` has not been run in a
400
- game.
401
- - **SendInput delivery reliability.** Keyboard input reaches the foreground
402
- window through the focus-verify-paste-confirm sequence; whether the game
403
- processes a given slash command still depends on client state, and `SendInput`
404
- returning success does not prove it did.
405
- - **Real SavedVariables write timing** and the reload cost of a large report.
406
- - **WoW: Forever in a running client.** Its TOC, client profile and event catalog
407
- are statically verified and pass the four-client matrix, but the addon has not
408
- been loaded in a Forever client.
409
-
410
- The offline-verified parts are the task registry writer, the restricted
411
- SavedVariables reader and verifier, the session log/dedup/artifacts, the notice
412
- validation, the identity marker shape and probe concurrency, the polling shape
413
- and the CLI exit behaviour; they are covered by `scripts/selftest_offline.py`.
128
+ 已有实机证据:Retail 12.1.0.69875 / Interface 120100 后台身份 QR、13,019 字节任务报告、reload 落盘和 nonce ACK 已通过。四客户端离线矩阵通过不等于四客户端实机通过;最小化、全部编辑状态、句柄重用仍未完整验证。同一 Retail 实例的 ACK 自动收尾已实测:确认后按 nonce 隐藏,WGC 再读取无残留码;测试禁止调用前台激活、SendInput 与剪贴板入口,仍成功。不要将该结果扩大为所有客户端/窗口状态都通过。