lycheedev 1.0.6 → 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,327 +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-right 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 stop` | Hides the notice UI only; the pending record and the busy state stay. |
120
-
121
- ### Reporting the read outcome back
122
-
123
- The plugin cannot observe whether the host actually read a result, so nothing on
124
- the game side changes when a ticket is picked up. While a result is pending its
125
- disk write, the controller answers every new request with the busy message, and
126
- that block only ends with a reload — unless you tell it what happened:
5
+ ## 工具与协议
127
6
 
128
- ```text
129
- python scripts/automation.py --installation retail-main ack \
130
- --hwnd 0x1234 --ticket LYCHEE-... --status received
7
+ 发送使用 Python `scripts/automation.py` 的 `--mode messages`(当前默认);读取使用 WGC + zxing-cpp。不要重写 ctypes 投递、拼接临时按键脚本或改成 GDI。Node CLI 负责安装/发现,游戏与 SV 逻辑由 Python 持有。
8
+
9
+ 运行时 RGB 色块表示状态;完成 QR 只包含版本、Ticket、task、requestId、时间戳等短元数据:
10
+
11
+ ```json
12
+ {"v":1,"ticket":"LYCHEE-...","task":"probe","run":"req-...","ts":1234567890}
131
13
  ```
132
14
 
133
- That sends `/dev auto ack <ticket> received` through the normal command channel.
134
- Use `--status failed` when the read failed; the reason stays in your host log.
135
- The index record keeps `receivedAt` and `receivedStatus`, and the Automation page
136
- shows "Read by the host" / "Host read failed" instead of a permanent
137
- "Awaiting reload". Acknowledging an unknown ticket or an invalid status changes
138
- nothing and reports why.
15
+ 无论正文大小,一律在输出 reload 后读取 SavedVariables。二维码不承担正文传输。成功/失败/取消都可能生成报告,必须读取报告的 status/complete/incompleteReasons,不能看见二维码就说调查成功。
139
16
 
140
- The built-in error task is reported with task ID `bug` and inner report
141
- `requestType` `bug`; its `params` are `{"count": n, "scope": ...}`.
17
+ 固定一个稳定的 `--installation` 标识(对应安装目录与会话绑定),并在所有命令中沿用同一个 `--data-dir`。宿主默认目录是 `%LOCALAPPDATA%/LycheeDev/automation`,保存 `session.log.jsonl`、配置和 `received/<Ticket>/` 下的 evidence/report/content 文件。插件内存中的数据库只有在 reload、退出或登出后才落盘。
142
18
 
143
- ## Host CLI
19
+ ## 职责和完成边界
144
20
 
145
- Global options, valid for every subcommand:
21
+ Agent 负责目标选择、设计有界 Lua、连续推进各阶段、解释异常。Python 负责注册表原子更新、输入、QR 校验、reload 去重、SV 校验和 ACK。当前不存在一个涵盖所有步骤的 `workflow` 命令;用下面的真实命令连续编排,不让用户逐条接力。
146
22
 
147
- - `--data-dir <dir>` — host data directory holding the log, artifacts and
148
- profiles; default `%LOCALAPPDATA%\LycheeDev\automation`.
149
- - `--installation <name>` — installation scope for the log and the reload
150
- dedup key; default `default`. Pass the same name to every command of one
151
- orchestration session, and use `--all-installations` when inspecting more
152
- 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;自有测试资源处理完成 | 向用户报告结果 |
153
32
 
154
- ### task
33
+ `run`/`bugs` 当前负责到 SV 读取,不自动执行 `ack`。返回 0 后必须继续 ACK。`send` 返回 0 不能当作游戏成功。`recover` 没有未决 reload 也不证明 ACK/界面清理完成,需要检查对应阶段事件。
155
34
 
156
- `task upsert|remove|list` with `--install-dir <dir>` or `--profile <name>`.
157
- Upsert also takes `--id`, `--source-file`, `--request-id`, `--revision`,
158
- `--expect-revision`, `--created-at`, `--expires-at`, `--expected-interface`
159
- and `--output-limit`. Generated IDs are `req-<UTC stamp>-<hex>`.
35
+ ## 准备任务
160
36
 
161
- ### profile
37
+ 目标目录是 `<addon>/Modules/Automation/auto/auto.lua`,按 task-id 分区。只能通过注册表工具改自己的区块,保留别人的块和标记外文本:
162
38
 
163
39
  ```text
164
- python scripts/automation.py profile set --name retail-main --client retail \
165
- --wow-root <WoW root> --addon-dir <addon dir> \
166
- --sv-path "<WoW>/WTF/Account/<account>/SavedVariables/Lychee Dev.lua"
167
- python scripts/automation.py profile show --name retail-main
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>
168
41
  ```
169
42
 
170
- `profile set` requires `--client`, `--wow-root` and `--addon-dir`; both
171
- directories must exist. The stored profile also records the client folder
172
- (`retail` -> `_retail_`, `classic` -> `_classic_`, `titan` -> `_classic_arena`).
173
- Profiles are written atomically to `<data-dir>/profiles.json`.
43
+ task-id 是 `[A-Za-z0-9_-]{1,64}`;requestId 建议只用字母、数字、点、连字符(兼容插件与 Python)。一项新执行分配新 requestId,源码变化同时换 revision;超时恢复保持原 requestId。更新已有块时用 `--expect-revision` 防覆盖。
44
+
45
+ 源码是 UTF-8 Lua 5.1,最多 256 KiB;注册表最多 16 块/1 MiB。标准输出限制默认 384 KiB、最大 512 KiB,以实际安装工具限制为准。不要用不受支持的 schema/kind 扩展协议。区块只注册数据,不会加载即执行。
174
46
 
175
- ### sv find / sv read
47
+ 同步调查返回紧凑结构。异步调查调用 `SetAsync()`,通过 `Finish(...)` 或 `Fail(message, code)` 完成,用 `OnCleanup(fn)` 释放自己创建的资源,检查 `IsCancelled()`;`Log` 与 `print` 输出有界。不得返回尚未完成的表并指望后来修改自动保存。
48
+
49
+ 输入侧 reload:发送 `/reload` 后等待客户端恢复可交互状态再发执行命令。SV mtime 变化只证明开始写盘,不证明加载已结束。用 WGC 观察世界画面恢复或验证过的就绪信号;固定等待数秒不能单独作为就绪证明。不得因暂时加载中而连续发命令试探。
50
+
51
+ ## 执行已绑定账户的任务
52
+
53
+ 下面示例的全局 `--data-dir`(如有)放在子命令前。全部窗口操作沿用本次绑定:
176
54
 
177
55
  ```text
178
- python scripts/automation.py --installation retail-main sv find --profile retail-main
179
- python scripts/automation.py --installation retail-main sv read --profile retail-main \
180
- --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
181
58
  ```
182
59
 
183
- - `sv find` requires `--profile`, resolves the client folder under `--wow-root`
184
- (a profile may point at the WoW root or at the client folder itself) and
185
- prints each account-level `SavedVariables/Lychee Dev.lua` candidate. It exits
186
- 1 when there is no candidate.
187
- - `sv read` requires `--ticket` plus either `--sv <path>` or `--profile`. It
188
- refuses any file that is not named `Lychee Dev.lua` and refuses `.bak`.
189
- - Optional identity checks: `--task`, `--request-id`, `--revision`,
190
- `--created-at`, `--request-type task|bug`.
191
- - `--retries` (default 3) and `--retry-delay` (default 0.5 s) bound the reads
192
- of a torn, replaced or temporarily unreadable file; the failure message
193
- reports how many attempts were made.
194
- - The reader uses a restricted parser (no Lua evaluation), exactly locates
195
- `LycheeDevDB.exports.records[TICKET]`, verifies the envelope (`schema`,
196
- `ticket`, `createdAt`), the payload (`mediaType` `application/json`,
197
- `encoding` `utf-8`, real UTF-8 byte count against `byteCount`, 1 MiB report
198
- limit), the metadata identity (`taskId`, `executionId`, `revision`,
199
- `resultSchema`, terminal `status`, `complete`, `checksumAlgorithm adler32`)
200
- and recomputes the Adler-32 `contentChecksum`. It then parses the inner
201
- `lychee.automation.result.v1` JSON report and verifies its version, terminal
202
- status, `complete`/`incompleteReasons`, client/character `environment`,
203
- `requestType` and, for bug reports, `params`.
204
- - Success prints
205
- `{"ticket":...,"status":...,"complete":...,"byteCount":N,"sha256":"...","attempts":N,"artifacts":{...}}`.
206
- - Artifacts (`evidence.json`, `report.json`, `content.json`) land under
207
- `<data-dir>/received/<ticket>/` and are written byte-for-byte: the recorded
208
- `byteCount` and SHA-256 describe the exact bytes on disk, with no newline
209
- translation of `payload.content`. The host log records `received` with the
210
- attempt count and whether the file changed during the read.
211
-
212
- ### 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。
213
63
 
214
64
  ```text
215
- python scripts/automation.py capture --hwnd 0x1234 [--pid <pid>] [--exe-path <exe>] \
216
- [--timeout 120] [--interval 0.1]
217
- python scripts/automation.py send --hwnd 0x1234 --text "/reload" \
218
- [--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
219
69
  ```
220
70
 
221
- - `capture` opens one `windows-capture` session for the window, decodes the
222
- QR with `zxingcpp.read_barcodes` (QR only) and prints the notice JSON. It
223
- compares the top-right ROI on every `--interval` (default 0.1 s) until
224
- `--timeout` (default 120 s) expires, then exits 5. Only the newest ROI is
225
- kept, so frames never pile up.
226
- - `send` always logs `command_sent` before input. When the text is `/reload`
227
- and both `--request-id` and `--ticket` are given it also applies the reload
228
- dedup key, so the same notice can never trigger a second reload.
229
- - Both confirm the window identity (HWND, and `--pid`/`--exe-path` when given)
230
- immediately before use and re-check the foreground before typing.
71
+ 同一个 `(installation, requestId, Ticket)` 的输出 reload 只允许自动发一次。写盘暂时未完成时进行有界读取等待,不重跑 Lua。
231
72
 
232
- ### run / bugs
73
+ ## 最近 n 条错误
233
74
 
234
75
  ```text
235
- python scripts/automation.py --installation retail-main run \
236
- --task inspect-example --sv "<...>/Lychee Dev.lua" --hwnd 0x1234 \
237
- --install-dir <addon dir> [--request-id req-...] [--revision rev-1] \
238
- [--timeout 120] [--interval 0.1]
239
- python scripts/automation.py --installation retail-main bugs \
240
- --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
241
77
  ```
242
78
 
243
- - `run` does not send the input-side `/reload` itself: after `task upsert` the
244
- new block is only in the file, so reload the client first (or run a task that
245
- is already loaded), then call `run`.
246
- - `run` delivers `/dev auto run <task-id>`, then polls for a notice whose
247
- `task` equals `--task` and whose `run` equals the loaded block's `requestId`
248
- (read from `Modules/Automation/auto/auto.lua` when `--install-dir` or
249
- `--profile` is given). A missing task block is an explicit failure.
250
- - `bugs` validates that `--count` is 1-100 without silently fixing it,
251
- delivers `/dev auto bug <count>` and requires a notice with task `bug`.
252
- - On a matching notice both flows log the `reload_requested` intent, snapshot
253
- the SV file, send one `/reload`, wait for the file to change within
254
- `--timeout`, then run the same verification as `sv read`.
255
- - Because a task can run far longer than one capture interval, the capture
256
- session stays open for the whole wait; it stops when the notice is decoded,
257
- the window closes, or the timeout expires.
258
-
259
- ### 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 为失败。
260
84
 
261
85
  ```text
262
- python scripts/automation.py --installation retail-main status --limit 50 [--event received]
263
- 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
264
87
  ```
265
88
 
266
- Both read the host log scoped to `--installation` (use `--all-installations`
267
- to read every scope). `status` prints the most recent records (`--limit`,
268
- default 20; 0 prints all). `recover` prints recent records and lists tickets
269
- whose reload was requested but never received. For those, read the
270
- SavedVariables file first: if the Ticket is already on disk, run `sv read`
271
- directly; if not, exactly one explicit reload retry is allowed — never a loop.
272
- If the game crashed before writing, the report is lost; record that
273
- uncertainty in your findings.
89
+ 输出 reload 后先确认世界已恢复。ACK 分配新 nonce,等待含该 nonce、Ticket 和 outcome 的 QR;随后发送 `/dev auto unidentify <nonce>`,只隐藏对应 ACK 标记,再观察该码消失。`ticket_ack_confirmed` 和 `ticket_ack_cleared` 分开记录;确认成功但清理超时不等于任务失败。
274
90
 
275
- ## Exit codes
91
+ 旧版插件只支持两参数 ACK,不支持 nonce 清理。使用前核对工具与插件协议版本;授权的测试/更新应备份后同步相应源码并 reload。不能在旧插件上持续重试不支持的命令。`/dev auto unidentify` 无参数会隐藏身份标记,仅在明确属于自己的标记且没有新回执时用;不能用通用 stop 掩盖未处理证据。
276
92
 
277
- | Code | Meaning |
278
- | --- | --- |
279
- | 0 | Success. |
280
- | 1 | Invalid usage, missing binding/profile, unsafe path refused, non-UTF-8 source, or an unexpected failure (with traceback). |
281
- | 2 | Task registry failure (schema, kind, marker, revision conflict, lock/limit refusal). |
282
- | 3 | SavedVariables read or verification failure after all attempts. |
283
- | 4 | Window identity, command input, or missing optional capture dependency (`windows-capture`/`numpy`/`zxing-cpp`) failure. |
284
- | 5 | No notice decoded before the timeout, or the game did not rewrite its SavedVariables file in time. |
93
+ 读取 ACK 不需要又一次输出 reload;receivedAt/receivedStatus 留在内存,下一次正常 reload 才持久化。不要为了把确认再确认一遍制造无限 ACK/reload 环。
285
94
 
286
- Expected failures print one `error: ...` line on stderr; they never dump a
287
- traceback for a missing dependency, a missing argument or a bad source file.
95
+ 自有临时任务结束后用 `task remove --install-dir <addon> --id <task>` 清理磁盘区块,保留证据和他人区块;是否额外 reload 清除内存定义按实际需要决定,不为界面整洁无条件多做 reload。
288
96
 
289
- ## Optional dependencies
97
+ ## 完整报告校验
290
98
 
291
- ```text
292
- python -m pip install --target <dir> -r scripts/requirements.txt
293
- ```
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 证明它就是选定窗口。
294
100
 
295
- `scripts/requirements.txt` pins the verified versions: `zxing-cpp==3.1.1`,
296
- `windows-capture==2.0.1`, `numpy==2.5.3`, `opencv-python==5.0.0.93`. The code
297
- uses only the interfaces those versions actually expose: `read_barcodes`
298
- (zxing-cpp 3.x, `read_bars` does not exist), `WindowsCapture(window_hwnd=...)`
299
- with `on_frame_arrived`/`on_closed` handlers, `start_free_threaded()` /
300
- `CaptureControl.stop()` and `Frame.convert_to_bgr()`.
101
+ `received/<Ticket>/content.json` 是字节精确的完整 payload,report.json 是解析报告,evidence.json 是外层证据。报告给用户时引用实际文件与 Ticket,不能只给 QR 截图或日志摘要。
301
102
 
302
- ## Recovery
103
+ ## 中断、超时与恢复
303
104
 
304
- ```text
305
- python scripts/automation.py --installation retail-main recover
306
- python scripts/automation.py --installation retail-main status --event run_unresolved
307
- ```
105
+ 先读本 installation 的 `status`/`recover`、本次保存的 task/request/Ticket 和当前画面;不要从第一条命令重新开始。
106
+
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。缺依赖时先在受管目录修复,不切换传输通道。
308
127
 
309
- `recover` prints recent host log events and lists tickets whose reload was
310
- requested but never received. For those, read the SavedVariables file first:
311
- if the Ticket is already on disk, run `sv read` directly; if not, exactly one
312
- explicit reload retry is allowed — never a loop. `run_unresolved`,
313
- `sv_write_timeout` and `notice_identity_mismatch` records tell you which step
314
- stopped and why. If the game crashed before writing, the report is lost;
315
- record that uncertainty in your findings.
316
-
317
- ## Known verification gaps
318
-
319
- Live-window steps (WGC capture, SendInput delivery, real SavedVariables
320
- writes, DPI/scaling) are implemented against the verified installed package
321
- interfaces but have not been exercised in a running game. Before relying on
322
- them: run `capture`/`send` against a real client, measure the notice QR size
323
- and DPI scaling per client, confirm command input reliability, and record real
324
- reload timing. The offline-verified parts are the task registry writer, the
325
- restricted SavedVariables reader and verifier, the session log/dedup/artifacts,
326
- the notice validation and identity checks, the polling shape and the CLI exit
327
- 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 与剪贴板入口,仍成功。不要将该结果扩大为所有客户端/窗口状态都通过。
@@ -1,135 +1,51 @@
1
- # Clients, builds and instances
1
+ # 选择客户端、实例与证据位置
2
2
 
3
- How to tell which World of Warcraft client you are driving, and how to target
4
- one when several are running. Read this before any command that types into the
5
- game (`send`, `run`, `bugs`, `capture`, `ack`).
3
+ 发送前使用本节。目标顺序是 **版本 → 该版本实例 → 角色/服务器 → 安装目录与 SV**。PID/HWND 是内部绑定参数,不是要求用户理解的选择菜单。
6
4
 
7
- ## Supported builds
5
+ ## 产品识别
8
6
 
9
- The addon ships one catalog per supported build. Nothing else loads it.
7
+ | 产品 | 版本基线 | Interface | 常见位置 |
8
+ | --- | --- | --- | --- |
9
+ | retail | 12.1.0 | 120100 | `_retail_` |
10
+ | classic | 5.5.4 | 50504 | `_classic_` |
11
+ | titan | 3.80.2 | 38002 | `_classic_titan_` |
12
+ | forever | 1.60.1 | 16001 | `_classic_beta_` 或 `_forever_` |
10
13
 
11
- | Build | Version | Interface | Catalog | Install folder |
12
- | --- | --- | --- | --- | --- |
13
- | Retail | `12.1.0` | `120100` | `Lychee Dev_Mainline.toc` | `_retail_` |
14
- | Classic | `5.5.4` | `50504` | `Lychee Dev_Mists.toc` | `_classic_` |
15
- | Classic Titan | `3.80.2` | `38002` | `Lychee Dev_Wrath.toc` | `_classic_titan_` |
14
+ 读取 `.flavor.info` 的 product code,再读取 `version.txt` 或可执行文件版本,最后才以文件夹名兜底。`_classic_beta_` 可能是 Forever,也可能是 MoP 测试轨;所有非 Retail 产品都可能使用 WowClassic.exe。窗口标题和 exe 文件名不证明产品。不自动扩展到 Era、Anniversary、PTR 等产品。
16
15
 
17
- Other folders may exist on a machine (`_classic_era_`, `_anniversary_`,
18
- `_beta_`). They are reported as **not served by the addon** and are deliberately
19
- skipped. Do not install into them and do not tell the user they are supported.
16
+ `lycheedev clients` 列出安装;`lycheedev instances` 枚举运行实例。用户已选版本就沿用;仅一种受支持版本运行时可直接使用,多种且未指定时先让用户选版本。只有选定产品的窗口进入后续扫描,不先把所有 PID 列给用户。
20
17
 
21
- The Titan folder is `_classic_titan_`. An earlier release used
22
- `_classic_arena_`, which does not exist; that made an installed Titan client
23
- invisible to both `install` and `doctor`. If a user reports "Titan was never
24
- installed", check the folder name before anything else.
18
+ ## 实例选择
25
19
 
26
- ## The executable name does not identify the build
20
+ 选定版本只有一个实例:自动绑定该实例,不再问 PID。记录本次枚举得到的 HWND、PID、完整 exe 路径、实际版本和安装目录。对多个安装目录不能仅按产品名选配置。
27
21
 
28
- Every non-retail client ships as `WowClassic.exe`. `Wow.exe` is retail,
29
- `WowB.exe` is beta, and `WowVoiceProxy.exe` is a helper, not a client.
30
-
31
- The **install path** does identify the build, because each one lives under a
32
- `_build_` directory:
33
-
34
- ```text
35
- D:\Game\World of Warcraft\_retail_\Wow.exe -> retail
36
- D:\Game\World of Warcraft\_classic_\WowClassic.exe -> classic
37
- D:\Game\World of Warcraft\_classic_titan_\WowClassic.exe -> titan
38
- ```
39
-
40
- Never infer the build from the window title. Retail's title is localized (for
41
- example `魔兽世界`) and gives no build information.
42
-
43
- ## Commands
44
-
45
- ### `lycheedev clients`
46
-
47
- Every build on disk, with its real version read from the executable, and whether
48
- the addon is installed:
22
+ 同版本多个实例:逐个后台触发身份标记,然后读取该窗口;完成整轮后展示“角色—服务器”供选择。每个窗口使用本次枚举的精确参数:
49
23
 
50
24
  ```text
51
- retail _retail_ v12.1.0.69587 addon installed
52
- classic _classic_ v5.5.4.69585 addon installed
53
- titan _classic_titan_ v3.80.2.69496 addon installed
54
- classicEra _classic_era_ v1.15.9.69547 not served by the addon
25
+ python <skill>/scripts/automation.py send --mode messages --hwnd <hwnd> --pid <pid> --exe-path <exe> --text "/dev auto identify"
26
+ python <skill>/scripts/automation.py identify --hwnd <hwnd> --pid <pid> --exe-path <exe> --timeout 3
55
27
  ```
56
28
 
57
- ### `lycheedev instances`
58
-
59
- Which clients are running right now, with the pid, window handle and build:
29
+ `identify` 是只读解码器,不会自动让游戏显示二维码。`instances --identify` 同样不能替代触发步骤。不要并发给多个窗口打字;当前 Python 批量读取器虽然支持并发捕获,编排时仍逐个触发和读取,以隔离窗口状态。
60
30
 
61
- ```text
62
- running instances:
63
- [0] Retail pid=62460 hwnd=0x12410c7a "魔兽世界"
64
-
65
- commands target this instance automatically
66
- ```
31
+ 核对身份 QR 的 `v/id/realm/client/build` 与所选产品和进程版本一致。完成标记含 `ticket`,不能当作角色身份标记。若有他人的运行中色块或待收取完成码,先处理其归属,不能用身份标记覆盖证据。只清理自己触发的身份码:`/dev auto unidentify`。
67
32
 
68
- The `[index]` is what you pass to `--instance` and to `use`.
33
+ 名字缺失、realm 缺失、重复角色+服务器或读取失败均保持未识别;不能静默挑第一个/ordinal 0。先说明未识别窗口的原因,继续可独立完成的读取;仍无法消歧时让用户指明角色或关闭多余实例。不要以“后台不需要焦点”为由跳过角色识别。
69
34
 
70
- ### `lycheedev use [index]`
35
+ ## 绑定的有效期与现有 CLI 限制
71
36
 
72
- Pin one running client as the default target, so later commands need no flag:
37
+ 每次开始输入以及中断恢复时重新枚举。进程退出、重启、角色改变或安装目录改变后重新绑定;不要把旧 PID/HWND 或旧 ordinal 当作持久身份。
73
38
 
74
- ```text
75
- lycheedev use # the only running client
76
- lycheedev use 1 # the instance at index 1, when the builds differ
77
- lycheedev use --clear
78
- ```
79
-
80
- Only the build and the instance ordinal are stored, because pids and window
81
- handles change on every launch. The pin therefore survives a restart: it
82
- re-resolves against whatever is running now. If the pinned build is not
83
- running, commands fail with a clear message instead of typing into the wrong
84
- game.
85
-
86
- Pinning is for choosing **between builds**. If two windows of the same build are
87
- open, `use` refuses and asks for one window to be closed — see the ambiguity rule
88
- below.
89
-
90
- ## Choosing a target: precedence
91
-
92
- 1. `--hwnd` / `--pid` — explicit, for scripted use
93
- 2. `--instance <index>` — one command only, overrides the pin
94
- 3. the saved pin from `use`
95
- 4. `--client retail|classic|titan` — filter by build
96
- 5. the single running instance, when there is exactly one
97
-
98
- Several instances of **different** builds are safe to keep open: the install path
99
- separates them, so `--client` picks one.
100
-
101
- Several instances of the **same** build cannot be told apart. Nothing observable
102
- from outside the game says which character is behind which window — only a
103
- build-specific memory reader could, and none ships here. Pinning an ordinal would
104
- only look precise while risking a slash command in the wrong game. The CLI
105
- therefore refuses and tells the user to close the extras:
106
-
107
- ```text
108
- error: 2 Retail clients are running and cannot be told apart
109
- close all but one, or close these pids: 62460, 71824
110
- ```
39
+ 当前 wrapper 的 pin 仍可能回退 ordinal,默认配置客户端也可能与选中运行实例不同。不要依赖这个回退;Agent 按上述步骤选择后,直接调用 Python,显式传 HWND/PID/exe、安装目录和 SV。当前 helper 只核对 PID/exe,尚未核对进程创建时间;不能声称它已排除所有句柄/PID 重用。
111
40
 
112
- **Ask the user to close all but one window of that build.** Do not invent a way
113
- to pick between them, and do not offer to pin one.
41
+ 同版本多实例扫描目前由 Agent 组织,CLI 没有完整的“先版本后角色”交互向导;不要编造参数或声称自动向导已实现。
114
42
 
115
- ## Multiple installations
43
+ ## SavedVariables 绑定
116
44
 
117
- A machine can hold more than one WoW root. `--wow-root <path>` selects which one
118
- to install into and is remembered in `~/.lycheedev/config.json`. `doctor`
119
- reports the root it is using. Run `lycheedev clients --wow-root <other>` to
120
- inspect a second root without changing the saved one.
45
+ 每个安装的候选文件位于该客户端目录的 `WTF/Account/*/SavedVariables/Lychee Dev.lua`。配置中的 svPath 只是候选;最新 mtime 也不是账户身份。不要读取 `.bak` 代替当前数据。
121
46
 
122
- ## What cannot be done from outside the game
47
+ 已有 Ticket:在选中安装的候选文件中定位精确 Ticket,读完整报告后核对角色、服务器、产品与版本。
123
48
 
124
- - The **character** on a running client is not readable without a
125
- build-specific memory reader. Nothing here guesses it. Two instances of the
126
- same build can only be told apart by pid, window handle or index.
127
- - The **account** behind a running client is likewise not exposed. SavedVariables
128
- files are per account, and the newest file is not necessarily the live
129
- session's account when several accounts are configured.
130
- - WoW ignores posted window messages, so keyboard delivery needs the window in
131
- the foreground. That is why targeting the right window matters.
49
+ 新调查但账户未绑定:先准备任务并取得匹配完成码,执行一次有去重记录的输出 reload,然后在候选 SV 中查找精确 Ticket。唯一且环境吻合后才绑定该路径。不能给 `run --sv` 随便填一个账户再把读失败视作任务失败。不同文件出现同一 Ticket 时结合 requestId/revision/environment 消歧,仍不唯一就停在定位阶段。
132
50
 
133
- If the user must be certain which client is which, ask them to run a trivial
134
- in-game command (`/dev auto status <task>`) in the window they mean, or to close
135
- the others.
51
+ 从 QR 取得的版本可能只含语义版本;完整 build 用进程版本和报告 environment 补全。每次实机结论都记录实际版本,不拿本表基线代替现场版本。
@@ -1,5 +1,12 @@
1
1
  # Bounded memory and CPU investigations through Run
2
2
 
3
+ For authorized background investigations, deliver the probe through the task registry
4
+ and follow [automation.md](automation.md) through receipt and cleanup. The pasted
5
+ Run input guidance below applies when the user chooses that UI workflow; it is not
6
+ the default delivery path and does not require switching a background task to the
7
+ foreground.
8
+
9
+
3
10
  Use this reference when a Lychee Dev investigation concerns memory, CPU, stutter, startup or repeated operations. The output is a question-specific script and evidence interpretation, not a replacement background profiler.
4
11
 
5
12
  ## Define the question before the probe