@dsh-mobile/mobile-remote 3.2.5 → 3.2.6

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/CONTRIBUTING.md +3 -1
  3. package/FAQ.md +1 -1
  4. package/README.md +6 -6
  5. package/cordis.patch.yml +10 -2
  6. package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +413 -102
  7. package/docs/02-architecture.md +1 -1
  8. package/docs/04-security.md +2 -1
  9. package/docs/11-remote-relay-guide.md +16 -13
  10. package/docs/APP-REVIEW-NOTES.md +135 -0
  11. package/docs/PRIVACY-POLICY.en.md +81 -59
  12. package/docs/PRIVACY-POLICY.md +81 -59
  13. package/docs/STORE-LAUNCH.md +41 -14
  14. package/docs/TERMS-OF-SERVICE.en.md +58 -26
  15. package/docs/TERMS-OF-SERVICE.md +58 -26
  16. package/lib/client.js +3 -4
  17. package/lib/config.js +6 -4
  18. package/lib/index.js +71 -15
  19. package/lib/relay/mux.js +9 -1
  20. package/lib/timeline.js +26 -10
  21. package/package.json +7 -1
  22. package/docs/10-remote-access-and-launch-plan.md +0 -216
  23. package/docs/ARCHITECTURE-CURRENT.md +0 -229
  24. package/docs/AUDIT-2026-11-node.md +0 -181
  25. package/docs/AUDIT-2026-11.md +0 -167
  26. package/docs/BUILD-ENVIRONMENT.md +0 -180
  27. package/docs/FEATURE-PARITY.md +0 -195
  28. package/docs/REA-UNDERSTANDING.md +0 -246
  29. package/docs/screenshots/01-home.png +0 -0
  30. package/docs/screenshots/02-notifications.png +0 -0
  31. package/docs/screenshots/03-sessions.png +0 -0
  32. package/docs/screenshots/04-chat.png +0 -0
  33. package/docs/screenshots/05-settings.png +0 -0
  34. package/docs/screenshots/06-new-session.png +0 -0
  35. package/docs/screenshots/07-connect.png +0 -0
  36. package/docs/screenshots/pgy-appstore.jpg +0 -0
  37. package/docs/screenshots/pgy-mobile-app.jpg +0 -0
  38. package/docs/screenshots/pgy-pc-client.jpg +0 -0
@@ -1,181 +0,0 @@
1
- > **出处与复核状态**:本文是委托子任务对 Node 侧(`lib/`、`relay/`、`tools/`、`test/`、CI)的审计原文,作为 `AUDIT-2026-11.md` 的附录。
2
- > 主审计者已独立复核:全量 `node --test` 为 490 项 / 482 通过 / 0 失败 / 8 跳过;D1 的三个请求目标确实都会让 `new URL()` 抛 `ERR_INVALID_URL`;
3
- > 12 个脚本确已删除。其余条目(D2–D5、C1、S1–S9)以其自带的先红后绿测试为证据,本轮没有逐条重做。
4
- > 文中「someone is editing the Flutter app」指的是主审计者在同一仓库里的 Flutter 工作;pbxproj 的 CRLF→LF 变动内容为零(`git diff --ignore-cr-at-eol` 为空,只是换行符),来源是本轮某次 Flutter/Xcode 构建工具运行(没能确定是哪一次;之后单独跑 `xcodebuild` 不会改它),已无损还原为与 HEAD 逐字节一致。
5
-
6
- # Node side audit and cleanup - DSH Mobile (`@dsh-mobile/mobile-remote` 3.2.4)
7
-
8
- Repo: `/Users/Apple/Downloads/Liux/DSH mobile` (branch main, nothing committed/staged/stashed). Node v24.21.0.
9
- Everything below is derived from source and from commands run in this session. Raw outputs are in
10
- `<scratchpad>/node-audit/`.
11
-
12
- ## 0. Numbers
13
-
14
- | | before | after |
15
- |---|---|---|
16
- | `wc -l lib/index.js` | 7693 | **5730** (-1963, -25.5%) |
17
- | new modules under `lib/` | - | 11 files, 2086 lines (config, turn-outline, timeline, session-list, host-compat, api-helpers, account-usage-query, push, rate-limit, http-util, rpc-adapter) |
18
- | `node --test test/*.js test/*.mjs` | 426 tests / 418 pass / 0 fail / 8 skip | **490 tests / 481 pass / 1 fail / 8 skip** (see note) |
19
- | same, with `ws` available (`RELAY_TEST_WS=...`) | 6 skips become passes | 487 pass / 1 fail / 2 skip |
20
- | `tools/` | 17 files | 5 files (12 superseded scripts deleted) |
21
- | `node --check` on every tracked .js/.mjs outside `dsh-mobile-app` | 73 files OK | 83 files OK (incl. new) |
22
- | `npm audit --omit=dev` | - | 0 vulnerabilities |
23
-
24
- Note on the 1 failure: `test/store-config.test.mjs` "set-app-id ... 保留 pbxproj 的 CRLF" asserts that
25
- `dsh-mobile-app/ios/Runner.xcodeproj/project.pbxproj` is CRLF. HEAD has CRLF; the working tree copy is now LF
26
- (`git diff --stat` shows 669 lines changed in that one file) because someone is editing the Flutter app concurrently.
27
- It passed in my earlier full runs (435/427/0/8) and is unrelated to any Node file. Restore CRLF in that file (or normalise
28
- via `.gitattributes`) and the suite is 490/482/0/8.
29
-
30
- Flake observed once: in one of roughly ten full runs `test/git-read-service.test.js` failed at file level after ~2.1 s (479 tests counted instead of 490). The same file passes standalone (21/21, 15 s) and the very next full run was 490/481/1/8. `lib/git-read-service.js` and that test were not touched by this work; cause not identified (git-heavy test under load). Worth watching.
31
-
32
- The 8 skips, verified: 6 are `test/relay-node-server.test.mjs` real-socket tests, skipped because `ws` is not installed
33
- (it is only in `relay/package.json`, and CI never installed it). With `RELAY_TEST_WS=<local node_modules>`
34
- (an existing local `ws` 8.21.0, no network) all 6 pass. The other 2 are `test/store-config.test.mjs` keystore tests, skipped
35
- because `keytool` is a macOS stub with no Java runtime here (`java -version` -> "Unable to locate a Java Runtime").
36
-
37
- ## 1. Methods and commands (what was actually run)
38
-
39
- 1. **Syntax**: `git ls-files '*.js' '*.mjs' ':!dsh-mobile-app' | while read f; do node --check "$f"; done` -> 73/73 OK at start; 83/83 OK at end.
40
- 2. **Dead code**
41
- - `node-audit/deadcode.mjs`: extracts every declaration (any depth) in `lib/` + `relay/` (1388 at start, 1470 at end) and counts
42
- word-boundary references across code, tests, tools, docs, CI. Start: 2 zero-reference declarations (`settingsReadsByDescribe`, `QR_IMAGE`),
43
- 20 exports referenced only inside their own file. End: 0 zero-reference, 9 own-file-only exports (list in section 6).
44
- - Scope-aware pass (the regex script cannot see shadowing): `tsc --allowJs --checkJs --noEmit --noUnusedLocals --noUnusedParameters`
45
- (TypeScript from `<local node_modules>`, tsconfig in `node-audit/tsconfig.json`), filtering TS6133/6192/6196/6198/6199
46
- and TS2304/2552 (undefined names). Start: unused `AUTO` import, shadowing never-read `CORPUS_FRESH_MS`, never-read `now` and `sessions`
47
- locals, `QR_IMAGE`. After every extraction the same run was used to find missing/unused imports. End state: only two false positives
48
- (`require` factory parameter in `lib/client.js`, `env` parameter in the Cloudflare worker) and the pre-existing `Buffer` global note.
49
- 3. **Risky-pattern greps** (`lib/`, `lib/relay/`, `relay/`): `JSON.parse` (17 production sites in lib/ + relay/; all inside try/catch or the hub's serialised queue, results shape-checked),
50
- `catch {}` (own script `node-audit/emptycatch.mjs`: 60 empty catch blocks at HEAD, 56 carry an explanatory comment, 4 are bare; reviewed individually, one finding S5),
51
- `.catch(() => {})`, `eval|new Function` (none in shipped code), `==`/`!=` (only `== null` idiom), `Math.random` (3 uses: reconnect jitter, ping nonce,
52
- notification id suffix - none secret), `new URL(` (see D1), `setTimeout|setInterval|addEventListener|.on(` against the dispose function,
53
- unbounded `Map`/`Set`/arrays per request or connection, `body.xxx` vs `body?.xxx` after `readJson`, token comparison (`timingSafeEqual` everywhere,
54
- sha256-normalised), `homedir()` vs `DSH_HOME`.
55
- 4. **Dependencies**: `npm ls --all` / `--omit=dev --depth=0`: 5 peer packages + `qrcode` all imported (`grep -rE "from \"[^./n]..."`); `ws` imported by
56
- `relay/run.js` only; `dsh-codex-connect` is a dynamic optional import. `npm audit --omit=dev` -> ENOLOCK in the repo (no lockfile by design), so the hidden
57
- `node_modules/.package-lock.json` was transplanted into a temp dir with the same `package.json` and audited there: **0 vulnerabilities** (this contacted the
58
- npm registry, which is the only network use).
59
- 5. **Package manifest**: `npm pack --dry-run --json`: `exports` targets (`lib/index.js`, `lib/client.js`, `package.json`) exist; `files` covers all new modules via `lib`; tarball is
60
- 3.4 MB packed / 4.5 MB unpacked, of which 3.2 MB is `docs/screenshots` shipped because `"docs"` is in `files` (recommendation R6); `relay/` is not shipped (separate deployable);
61
- `lib/relay/phone.js` (114 lines, test-only phone reference) is shipped.
62
- 6. **CI** (`.github/workflows/ci.yml`): claimed "Syntax check" only ran `lib/*.js` (missed `lib/relay/*.js`, `relay/**`, `tools`, `test`); the 6 relay socket tests always skipped in CI
63
- (no `ws`). Fixed (section 3, C1). Node 22.x only, `engines` says >=20.3 (Node 20 never tested; zstd tests need >=22.15) - noted, not changed.
64
- 7. **Read line by line with an attacker's eye**: `lib/index.js` token/cookie auth (`tokenMatches`, `cookieToken`, `authorized`), `hostnameOf`/`hostAllowed`/`trustedHosts`, `crossSiteBlocked`,
65
- rate limiter, `clientIpOf` + `CLIENT_IP_HEADER` nonce, `relayPeerOf` + `RELAY_PEER_HEADER`, `localDesktopGate`, `serveQr`, `/qr-config`, `/relay/*`, `/dev/approval-test`, `handleApi` preamble,
66
- `readBody`/`readJson`/`sendJson`, SSE `connect`/`broadcast`/heartbeat, LAN bridge (request-target parsing, path allow-list, header stripping/forwarding, timeouts, dispose), file browse/download/upload,
67
- `/send` receipts + held queue, dispose function; `relay/hub.js`, `relay/node-server.js`, `relay/cloudflare/worker.js`, `lib/relay/{noise,mux,connector,pairing,devices,identity,serve,crypto,phone}.js`.
68
- Conclusions on the parts that held up: LAN bridge excludes `/api/qr-config` exactly and normalises the path before forwarding (dot-segments and `%2e` collapse before the allow-list check); bridge deletes
69
- client-supplied `x-dsh-mobile-client-ip` and `x-dsh-relay-peer` and writes its own; `localDesktopGate` is independent of the relay path allow-list (three layers); relay replayer drops cookie/token/proxy/origin headers and rejects any
70
- path that normalisation would change; hub auth binds room = SHA-256(pubkey)[:16] with a per-connection nonce; pre-verification guests are capped at 4 frames / 8 KiB.
71
- 8. **Tools scripts**: ran every offline-capable script (9) and attempted the live ones (6, all die with ECONNREFUSED, as expected without a DSH host) - results in section 4.
72
- 9. **Reproduction discipline**: each defect below has a test that was run red against the unfixed code (output seen), then the fix, then green. The held-queue test was additionally re-run with the fix line neutralised to confirm it still fails.
73
-
74
- ## 2. Verified defects (reproduced, fixed)
75
-
76
- | # | file:line (at HEAD) | severity | repro test (red before, green after) | fix |
77
- |---|---|---|---|---|
78
- | D1 | `relay/node-server.js:74` (`new URL(req.url, base)` in the `'upgrade'` listener) | **High** (unauthenticated remote crash of the public relay process) | `test/relay-node-server.test.mjs`: "升级请求的目标不合法:只断开该连接,不抛异常(直接触发 upgrade 事件)" and "...真实 TCP 上发出后中继仍然存活并继续服务" (stub `WebSocketServer`, so they run in CI without `ws`). Raw TCP `GET http://[ HTTP/1.1` + `Upgrade: websocket` makes Node's parser accept the target, `new URL` throws `ERR_INVALID_URL` inside an event listener = `uncaughtException`; `//[` and `http://:99999999/` do the same, `http://a b/` is rejected by the parser. `relay/run.js` installs no handler, so the process exits. | parse inside try/catch, `socket.destroy()` on failure |
79
- | D2 | `lib/index.js:3089` `readJson` + ~40 `body.xxx` call sites (e.g. `/directories`, `/sessions/new`, `/llm-providers`, `/files/...`) | Low (authenticated client gets `500 internal` + a handler-error log instead of 4xx) | `test/api-json-body-shape.test.mjs`: POST `/m/api/directories` with body `null` -> expected 400 `invalid-name`, got 500 | `JSON.parse(...) ?? {}` in `readJson` (`null` and `{}` are already equivalent at every `body?.x` site; only the previously-throwing sites change) |
80
- | D3 | `lib/index.js` state files: `READ_FILE`, `HELD_FILE`, `RECEIPT_FILE`, `ACTIVITY_FILE`, `MESSAGE_TIME_FILE`, `session-titles.json` (11 `join(homedir(), ".dsh", "mobile-remote", ...)` sites) | Medium (multi-instance isolation: two hosts with different `DSH_HOME` share the held-queue / send-receipt / activity files; token and relay identity already honoured `DSH_HOME`, contradicting the promise in `auto-config.js`; docs/06 even records an "isolated DSH_HOME" test run) | `test/state-dir.test.mjs`: with `DSH_HOME=<tmp>` the activity file must appear in `<tmp>/mobile-remote/`, got "目录不存在"; second test pins the default (`~/.dsh/mobile-remote`) unchanged | single `STATE_DIR = mobileRemoteStateDir()` in `apply`. **Behaviour note**: users who set `DSH_HOME` will start with empty read/held/receipt/activity state once after upgrading (default users: identical paths) |
81
- | D4 | `lib/index.js:2284` `releaseHeld` | Medium (duplicate user message) | `test/held-queue-release.test.mjs` "图片排队消息:投递尚未返回时再来一次 idle,不得把同一条消息再投递一次": 2 `session.prompt` calls instead of 1. Image release is async (up to 120 s) and the entry is only dropped on success; both the `agent/status idle` event and the 30 s sweep re-enter `releaseHeld` meanwhile | in-flight id set `imageReleasesInFlight`; entries in flight are skipped; cleared on settle |
82
- | D5 | `lib/relay/connector.js:43-51` | Low / latent (not reachable from production code, which calls `start()` once) | `test/relay-state.test.mjs` "连接器:stop() 之后再 start(),设备撤销仍然会踢掉该设备的在线会话": after `stop();start()` the revoke listener count was 0 | `start()` re-subscribes (`unsubscribe ??=`), `stop()` nulls it |
83
- | C1 | `.github/workflows/ci.yml` | Medium (process: false confidence) | n/a (workflow change; YAML read by eye, cannot run Actions here) | syntax check over all tracked JS/MJS outside the app; `npm install --prefix relay` + `RELAY_TEST_WS` so the 6 socket tests run |
84
-
85
- Dead code found by the scope-aware pass, removed (proof = zero reads, see section 3).
86
-
87
- ## 3. Removed code and proof it was dead
88
-
89
- | item | proof |
90
- |---|---|
91
- | `AUTO` import in `lib/index.js` | tsc TS6133; the only uses in repo are `lib/auto-config.js` (definition) and tests that import it from `auto-config.js` directly |
92
- | local `const CORPUS_FRESH_MS` inside `apply()` | tsc TS6133 (never read); it only shadowed the exported module constant that `planMessageTimePrune` actually uses (same value); comment re-pointed |
93
- | `const now = Date.now()` in `listPersistedSubagents` | tsc TS6133; the comment describing it referred to an upstream fallback map that no longer exists |
94
- | `const sessions = ctx.get("sessions")` in `/catalog` | tsc TS6133; `ctx.get` is a pure lookup |
95
- | `export const settingsReadsByDescribe` | 0 references in lib, test, tools, relay, docs, README, CHANGELOG (deadcode.mjs); not a host-injected name (plain helper) |
96
- | `var QR_IMAGE = "/m/qr.png"` in `lib/client.js` | tsc TS6133; `client-relay-panel` and `package-manifest` tests pass |
97
- | 12 scripts in `tools/` | section 4 |
98
-
99
- ## 4. `tools/` scripts
100
-
101
- Kept: `e2e-check.mjs` (live smoke, referenced by CONTRIBUTING.md:27 and docs/05), `timeline-contract-check.mjs` (offline, 125 asserts, passes; now run by `test/tools-offline-checks.test.mjs`),
102
- `verify-no-model-session.mjs` (live acceptance for v3.1.0 default-model fallback; needs a real model, not covered by any test; unsure -> kept), `make-upload-keystore.sh`, `set-app-id.sh`.
103
-
104
- Deleted (plain `rm`, not staged). Rule applied: delete only if the assertions now live in `test/` (ported verbatim, run green) or the script is a replica/obsolete. Each script was run first.
105
-
106
- | script | result when run | disposition |
107
- |---|---|---|
108
- | `account-usage-check.mjs` | 15/15 pass | ported verbatim -> `test/account-usage.test.mjs` (15) |
109
- | `account-usage-adversarial-check.mjs` | 19/19 pass | ported verbatim -> `test/account-usage-adversarial.test.mjs` (19) |
110
- | `hotfix07-unit-check.mjs` | 14/14 pass (tried hard-coded `C:/Users/30623/...` first) | ported -> `test/pure-helpers.test.mjs` |
111
- | `wsl-path-check.mjs` | 8/8 pass (same hard-coded paths) | ported -> `test/pure-helpers.test.mjs` |
112
- | `verify-image-sniff.mjs` | pass, but extracts `sniffImageType` from `index.js` source with a regex + `new Function` (would break on any refactor) | ported -> `test/pure-helpers.test.mjs` against the real export |
113
- | `verify-413-precheck.mjs`, `verify-64k-fix.mjs` | pass, but they test their own **copy** of `readBody`/`sendJson`, never the plugin | replaced by real-plugin tests in `test/send-contract.test.mjs` (declared >64 MB -> 413 JSON over a raw socket; `readBody` limit/close behaviour) |
114
- | `hotfix05-check.mjs` | needs live DSH (ECONNREFUSED) | its non-live asserts (bad requestId 400, receipt 404/400, >64 MB 413) and its LIVE idempotency asserts (text + image, same requestId -> same result, delivered once) are now in `test/send-contract.test.mjs` against a fake agents service |
115
- | `verify-issue14-p0.mjs` | **34 pass / 3 FAIL**: B1, B4, B5 stale since `pushApprovalGraceMs` (default 5 s) defers the approval push; the script waited 60 ms. Nobody noticed. | ported with `pushApprovalGraceMs: 0` -> `test/issue14-p0-mock-host.test.mjs`; all 37 asserts green (this is the only coverage of todo summaries, `sourceKind`, `/todos`, replay-frame shape, push-test bookkeeping) |
116
- | (new) | - | `test/push-channels.test.mjs` pins the ntfy request shape (root POST + `topic`) and the serverchan/bark/wecom/generic bodies, previously asserted only for ntfy and only inside the stale script |
117
- | `verify-issue14-live.mjs` | needs live DSH + a human killing the phone app | superseded by the mock-host test above (same assertions, no human) |
118
- | `phase1-check.mjs` | needs live DSH on hard-coded port 56343 | no assertions (prints responses), v2 development scratch -> deleted |
119
- | `push-test.mjs` | needs live DSH | 14 lines, no assertions, sends a real prompt -> deleted |
120
-
121
- ### Dangling references created by the deletions (for the parent to fix; I did not edit docs)
122
-
123
- - `README.md:282` - "tools/ 验证脚本(e2e-check / phase1-check / push-test)" -> should list `e2e-check / timeline-contract-check / verify-no-model-session`.
124
- - `docs/05-test-cases.md:188` - `node tools/wsl-path-check.mjs(normalizeServerPath,8/8)` -> `node --test test/pure-helpers.test.mjs`.
125
- - `CHANGELOG.md` lines 347, 384, 477, 495, 519, 570, 676, 734, 742, 765 name deleted scripts (account-usage-check, verify-issue14-p0/live, wsl-path-check, hotfix05/07 ...). They are release history; leave as is, optionally add a "tools consolidated into test/" note to the next entry.
126
- - Also stale because of the refactor: `docs/08-扩展开发指南.md:49` says to add a push format "在 `lib/index.js` 的 `pushToChannel`" -> now `lib/push.js` (`pushToChannel`, the per-format branches). `README.md:279` describes `lib/index.js` as holding everything; list the new modules.
127
-
128
- ## 5. Refactor map (`lib/index.js` -> new modules; verbatim moves, wire formats and log strings untouched)
129
-
130
- Public surface check: all 51 exports of HEAD's `lib/index.js` are still exported (re-exported via `export { ... } from`), except the removed dead `settingsReadsByDescribe`; no new exports on `index.js` (verified by importing and diffing the name sets). `package.json` `exports`/`files` unchanged.
131
-
132
- | new module (lines) | contents | HEAD `lib/index.js` lines |
133
- |---|---|---|
134
- | `lib/config.js` (214) | `Config` schema, `DEFAULT_ENUMERATION_BUDGET_MS`, `DEFAULT_WARM_UP_TITLE_BUDGET_MS` | 44-253 |
135
- | `lib/turn-outline.js` (290) | event-detail error classification, `TURN_OUTLINE_*`, `createTurnOutlineQueue`, `raceWithDeadline`, `turnOutlineCapabilityOf`, `clampTurnOutline`, `turnOutlineStateOf` | 255-293, 326-587 |
136
- | `lib/timeline.js` (477) | `EVENT_TIMELINE_CAPABILITIES`, replay/live/detail type sets, `isTimelineRecord` & co, `blocksToText`, image/file/reasoning projections, `sniffImageType`, `summarizeEvent`, `detailEventFor` | 295-308, 589-690, 976-985, 1087-1426 |
137
- | `lib/session-list.js` (78) | `sessionListSortKey`, `compareSessionsForList`, `latestMessageTimeOf`, `CORPUS_FRESH_MS`, `planMessageTimePrune` | 691-757 |
138
- | `lib/host-compat.js` (134) | generation probes (ADR 0017): `jobsNeedsSessionId`, `wireStreamTakesControl`, `hostPeerSource`, `createInProcessPeer`, `readSettingsSection(Strict)`, `jobsCallerFor`, `capabilityState` | 816-955 |
139
- | `lib/api-helpers.js` (334) | `redactPathText`, `requestHeaderText`, `clampText`, MIME map, `mapBounded`, `orderQrAddresses`, `receiptExpired`, `pruneReceiptMap`, `normalizeServerPath`, `validateQuestionAnswers`, `classifyFetchFailure`, `safeFailureReason`, `requestAbort`, `FILE_RANGE_CAPABILITIES`, `parseByteRange`, `ifNoneMatch` | 266-270, 310-324, 759-820, 957-1085, 1510-1556, 1775-1783, ~6165-6194 |
140
- | `lib/account-usage-query.js` (279) | `deriveKeyRef`, credential resolution, Codex/OpenCode/DeepSeek upstream queries, `queryAccountUsage` | 1440-1773 |
141
- | `lib/push.js` (74) | `ntfyPublish`, `pushToChannel(logger, ...)` (was a closure over `ctx.logger`; `apply` keeps a one-line wrapper) | 1428-1438, 2855-2896 |
142
- | `lib/rate-limit.js` (47) | `createLoginRateLimiter` (the 10/60 s bucket logic, 512-source cap) | 3005-3039 |
143
- | `lib/http-util.js` (70) | `guardRes`, `sendJson`, `sendError` (was `error`), `readBody`, `requireGet`, `requirePost` | 3041-3059, 3060-3080, 3100-3114, 3631-3637 |
144
- | `lib/rpc-adapter.js` (89) | `RPC_ENDPOINT_RENAMES`, `RPC_PAYLOAD_ADAPTER`, `RPC_STREAM_METHODS`, `projectionOf`, `rpcError` | 3356-3407, 3507-3535 |
145
-
146
- **Left in `index.js` and why**: `handleApi` (~2800 lines) and everything it closes over (title refresher/enumeration single-flight, notification and done-timer state machine, held queue/receipts persistence, approval/question bridge,
147
- LAN bridge, SSE connection set, gateway peer cache). These share ~60 mutable closure variables; extracting them would mean threading a context object through hundreds of references or rewriting control flow, which the brief rules out.
148
- The LAN bridge (about 170 lines) is the most separable next candidate if wanted (needs `lanBridgeListening`, `announceConnection`, the two nonce tokens, `ctx.webServer`, `guardRes`). Five state files use the same load/persist/debounce shape and could share a
149
- helper, but that is a rewrite, not a move.
150
-
151
- ## 6. Suspected / not reproduced / not fixed (and why)
152
-
153
- - **S1** `notifyAskDeferred` (`lib/index.js` ~2775): the 5 s `unref`'d grace timer is not cleared on dispose; after unload it can still call `pushNotification`/`pushSend`. Harmless to the event loop, but sends a push from a disposed plugin. Needs an approval request followed by dispose within 5 s; not reproduced.
154
- - **S2** `/send` receipt: between `sendReceipts.set(key, in-progress)` and the `try {` (~4186-4217) `createUserMessage`/content assembly could throw -> outer handler 500 and the receipt stays `in-progress` for 15 min, so retries get 409 `receipt-pending`. I could not make `createUserMessage` throw with validated inputs; kept as a note.
155
- - **S3** `heldQueue` has no per-session cap and `persistHeld()` rewrites the whole queue (including base64 images) on every mutation. Authenticated clients only. A cap needs a new error response = wire change, so not applied. Same for `/send` allowing 64 MB bodies x `maxConnections`.
156
- - **S4** Error detail leakage: `POST /directories` (`mkdir-failed`), `/files/upload` (`write-failed`), `/actions/:id/invoke` (`action-failed`) return raw `err.message` (contains absolute host paths) while the S7 policy redacts everywhere else. Redacting changes the detail text on the wire -> reported, not applied.
157
- - **S5** `/llm-providers` `removeKey`: `credentials.unset(...).catch(() => {})` swallows failures; response is 200 with `keyConfigured:false` even if the key was not removed. Whether "not found" must be tolerated depends on the credentials service semantics; changing it alters responses.
158
- - **S6** `relay/node-server.js` `ipOf` with `TRUST_PROXY=1` takes the **leftmost** `X-Forwarded-For` entry, which is client-controlled behind proxies that append (nginx `$proxy_add_x_forwarded_for`); the per-IP limiter is then bypassable and `IpLimiter.hits` can grow (sweep only runs above 10 000 entries and only removes expired keys). Default (`TRUST_PROXY` off) uses the socket address and is fine. Fix = use the right-most trusted hop; changes limiter keying for multi-proxy chains -> reported only.
159
- - **S7** `lanBridgeSockets` entries are removed on the first response `close` of a socket, so keep-alive sockets stop being tracked after one request. The bridge forces `connection: close` except for SSE, so only SSE sockets would be missed at unload (the SSE `res`/upstream are destroyed by `connections` handling).
160
- - **S8** `lib/relay/mux.js` `request()` never removes its `abort` listener from a long-lived caller signal (client side exists only in the test phone reference).
161
- - **S9** `trustedHosts()` calls `os.networkInterfaces()` per request (cost, not correctness). `DROP_RESPONSE_HOOK` (`DSH_MOBILE_REMOTE_DROP_RESPONSE=1`) is a test hook compiled into the production `/send` path.
162
- - 9 exports used only inside their own file, kept as API/test seams: `OTP_TTL_MS`, `MAX_DEVICES` (devices.js), `MAX_HEAD_BYTES` (mux.js), `PROTOCOL_NAME`, `CipherState` (noise.js), `PhoneSession` (phone.js), `DEFAULT_LIMITS`, `unb64u` (hub.js). Unsure -> kept.
163
-
164
- ## 7. Recommended doc edits (not applied)
165
-
166
- - R1 `docs/10-remote-access-and-launch-plan.md:68` says `Noise_IK_25519_ChaChaPoly_BLAKE2s`; the implementation, vectors and `relay/README.md` use `..._SHA256`.
167
- - R2 Document that all plugin state (token, relay identity, read/held/receipt/activity/title files) lives under `$DSH_HOME/mobile-remote` (default `~/.dsh/mobile-remote`): `docs/04-security.md:73,88`, `README.md:87`, `docs/02-architecture.md:189`, `cordis.patch.yml` comment. Mention the one-time empty state for `DSH_HOME` users (D3).
168
- - R3 `README.md:282`, `docs/05-test-cases.md:188`, `docs/08-扩展开发指南.md:49`, `README.md:279`: see section 4.
169
- - R4 `relay/README.md`: `TRUST_PROXY=1` trusts the first `X-Forwarded-For` hop; only enable behind a proxy that overwrites the header (S6).
170
- - R5 `CONTRIBUTING.md:27` "插件改动:跑 `tools/e2e-check.mjs`" - also say `node --test test/*.js test/*.mjs` (what CI runs); note that `RELAY_TEST_WS` / `npm install --prefix relay` is needed to run the relay socket tests locally.
171
- - R6 `package.json` `files`: `"docs"` ships 3.2 MB of screenshots in the npm tarball; consider `"!docs/screenshots"` (not changed here). `lib/relay/phone.js` is test-only code in the tarball.
172
- - R7 CHANGELOG entry for the next release: D1 (relay crash), D2, D3 (`DSH_HOME` state dir), D4 (duplicate held image), D5, tools consolidated into `test/`, `lib/index.js` split.
173
- - R8 Environment: the CRLF->LF change in `dsh-mobile-app/ios/Runner.xcodeproj/project.pbxproj` breaks `test/store-config.test.mjs` (set-app-id); restore CRLF or add a `.gitattributes` rule.
174
-
175
- ## 8. Files changed (all unstaged)
176
-
177
- Modified: `.github/workflows/ci.yml`, `lib/index.js`, `lib/client.js`, `lib/relay/connector.js`, `relay/node-server.js`, `test/relay-node-server.test.mjs`, `test/relay-state.test.mjs`.
178
- Added: `lib/{config,turn-outline,timeline,session-list,host-compat,api-helpers,account-usage-query,push,rate-limit,http-util,rpc-adapter}.js`;
179
- `test/{account-usage,account-usage-adversarial,api-json-body-shape,held-queue-release,issue14-p0-mock-host,pure-helpers,push-channels,send-contract,state-dir,tools-offline-checks}.test.mjs`, `test/helpers/send-harness.mjs`.
180
- Deleted: the 12 `tools/*` scripts in section 4.
181
- Not touched: `dsh-mobile-app/**`, `docs/**`, `README.md`, `CHANGELOG.md`, `package.json`.
@@ -1,167 +0,0 @@
1
- # 2026-11 全面审查、重构与重设计记录
2
-
3
- > 记录时间:2026-11-01(Asia/Shanghai) 基线:插件 `3.2.4`,App `3.2.4+31`,`main` @ `35cb329`
4
- >
5
- > 这份文档只记**做过什么、怎么验证的、哪里没验证**。每条结论都能用文末「复核命令」重新跑出来;
6
- > 没有跑过的东西明确写成「未验证」。
7
-
8
- ## 1. 项目现状(从源码与配置核实)
9
-
10
- | 方面 | 现状 | 依据 |
11
- |---|---|---|
12
- | 形态 | Node 插件(`/m/api` 路由、SSE、认证、推送、LAN 桥)+ Flutter App(Android/iOS 同一套 Dart)+ 可独立部署的 E2E 加密中继 | `package.json`、`dsh-mobile-app/pubspec.yaml`、`relay/` |
13
- | 版本 | 插件 3.2.4 / App 3.2.4+31 | 两处清单一致 |
14
- | Android | 已发布过;本环境没有 Android SDK,**原生代码与资源未在本轮编译** | `docs/BUILD-ENVIRONMENT.md`、本环境 `flutter doctor` 无 SDK |
15
- | iOS | 模拟器 Debug 可构建、可运行(本轮实机验证:演示模式、聊天、审批全流程);**未签名、未真机、未上架** | 本轮 `xcodebuild` + 模拟器 |
16
- | 远程访问(中继) | 协议/服务端/客户端/测试齐全,**首发版本入口默认隐藏**(`Features.remoteAccess=false`) | `lib/features.dart`、`docs/STORE-LAUNCH.md` §3c |
17
- | 上架缺口 | 签名密钥与 App Store Connect/Play 控制台事项必须由发布者完成;商标名使用与关系声明见 STORE-LAUNCH §1 | `docs/STORE-LAUNCH.md` |
18
- | 知识产权 | 此前:App 图标与首页使用 DeepSeek 鲸鱼标识,吉祥物素材来自第三方仓库、出处不清——文档自己标注「未解决」。本轮已删除鲸鱼标识与旧吉祥物;默认图标/标志/首页角色改用项目方提供的两张图片,其余为代码绘制,见 §7(**两张图片的授权仍由项目方确认**) | `docs/STORE-LAUNCH.md`(旧 §3c)、`docs/BRAND-ASSETS.md` |
19
-
20
- ## 2. 方法与工具(可复核)
21
-
22
- 只使用原始材料:源码、配置、`git`、工具输出。文档只用来**对照**,不作为证据。
23
-
24
- | 目的 | 方法 / 命令 | 产出 |
25
- |---|---|---|
26
- | 基线 | `flutter analyze`、`flutter test`、`node --check`、`node --test test/*.js test/*.mjs` | 改动前后各一份计数,见 §3 |
27
- | Dart 严格静态分析 | 临时换上 40 余条额外 lint(`avoid_catches_without_on_clauses`、`unawaited_futures`、`discarded_futures`、`avoid_dynamic_calls`、`strict-casts` 等)跑 `flutter analyze` 后恢复原配置 | 590 条提示;绝大多数是风格噪声(163 条宽 `catch`、76 条冗余实参),有信号的是 25 处被丢弃的 Future 与 3 处同步 IO,已处理 |
28
- | Dart 死代码 | 自写扫描 `dsh-mobile-app/tools/audit/deadcode.py`:去掉注释与字符串后对 `lib/`、`test/` 做标识符计数,只报声明处,**再逐个 grep 人工复核** | 12 个成员 + 11 个常量零引用,已删除 |
29
- | 资源生命周期 | 逐文件统计 `Timer/listen/AnimationController/*Controller` 的创建与 `cancel/dispose/close` 次数,差异大的文件人工读 | `sheets.dart` 两个控制器从不释放,已修 |
30
- | 平台配置 | 通读 `AndroidManifest.xml`、`Info.plist`、`Runner.entitlements` | 见 §6 |
31
- | 缺陷复现 | 先写**失败**的测试 → 看它红 → 修复 → 看它绿;关键修复再做**变异检查**(临时改回旧逻辑,确认测试变红) | §4 |
32
- | 上帝类拆分 | 自写解析器把 `_ChatScreenState` 切成 205 个成员(文本逐字保留)→ 按功能分组 → 生成 part 文件 → **token 多重集合比对**证明无丢失 | §5 |
33
- | 真机式验证 | iOS 模拟器 + 演示模式,跑 连接页 → 首页 → 会话 → 设置 → 聊天(流式、工具卡、审批)→ 深色模式 | 截图见 `docs/screenshots/` |
34
- | Node 侧 | 另见 §4.2:`tsc --checkJs --noUnusedLocals`、引用计数脚本、风险模式 grep、`npm audit`、逐行读认证/限流/LAN 桥/中继 | 详细原文 `docs/AUDIT-2026-11-node.md` |
35
-
36
- ## 3. 数字:改动前 → 改动后
37
-
38
- | 项 | 前 | 后 |
39
- |---|---|---|
40
- | `flutter analyze` | 无问题 | 无问题(并新增 `unawaited_futures`、`cancel_subscriptions` 为强制规则) |
41
- | `flutter test` | 774 通过 / 18 跳过 | **809 通过 / 18 跳过 / 0 失败**(新增 35 项:本轮缺陷回归 19 + 品牌素材守卫 16) |
42
- | `node --test` | 426 项 / 418 通过 / 8 跳过 | 490 项 / 482 通过 / 8 跳过 |
43
- | `lib/index.js` | 7693 行 | 5730 行(拆出 11 个模块,共 2086 行) |
44
- | `lib/screens/chat_screen.dart` | 8195 行 | 808 行 + `lib/screens/chat/` 16 个 part 文件(每个 66–986 行) |
45
- | `lib/main.dart` | 1370 行 | 1041 行(连接页抽到 `screens/connection_sheet.dart`) |
46
-
47
- ## 4. 已验证并修复的缺陷
48
-
49
- ### 4.1 Flutter App
50
-
51
- | # | 位置 | 现象与证据 | 修复 | 回归测试 |
52
- |---|---|---|---|---|
53
- | F1 | `Api._normBase` | `http://[fd7a:115c:a1e0::1]:3081` 被改写成 `http://fd7a:115c:a1e0::1:3081`,`Uri.parse` 抛 `Invalid port`(本轮用 `dart run` 复现)。手动输入 IPv6 / Tailscale v6 地址会得到一个坏连接;回环/链路本地过滤也跟着失效。服务端只广播 IPv4,所以扫码路径碰不到 | 主机含 `:` 时补回方括号;`fe80::` 与 `169.254.` 同样排除 | `api_logic_test.dart`(已先红后绿) |
54
- | F2 | `Api.eventsRaw` SSE 切帧 | 每个帧都重新复制整段剩余文本:20000 帧一次到达耗时 **1736 ms**(2000 帧 33 ms,5000 帧 116 ms,明显二次增长);只认 `\n\n`,代理改成 CRLF 后一个帧都切不出;缓冲无上限 | 抽成纯类 `SseFrameParser`:线性扫描(同样 20000 帧 **8 ms**)、归一 CRLF、8 MiB 上限;`\r\n` 被切在两个 chunk 之间也正确 | `sse_parser_test.dart`(8 项,含任意位置切分) |
55
- | F3 | `AppLog` | 日志上限 256 KiB,实测会长到 **约 775 KiB**:按 UTF-16 单元而非 UTF-8 字节计(中文差 3 倍),截断后又用 `行数/2*16` 估算 | 按 UTF-8 字节计;截断后取真实文件长度 | `logger_test.dart`(变异检查:改回旧逻辑 → 793608 字节,测试红) |
56
- | F4 | `_showNewFolder` | `var busy = false` 声明在 `StatefulBuilder` 的 builder 里,每次 `setState` 重建都被重置,源码注释声称的「防连点双建目录」**从未生效**;同时 `TextEditingController` 从不释放。`showActionSheet` 同样泄漏控制器 | 改为 `NewFolderSheet` / `_ActionForm` 两个 StatefulWidget,状态与控制器归 State,路由退出动画后才 dispose | `new_folder_sheet_test.dart`(连点只发一次请求) |
57
- | F5 | 连接页等 56 处 | 异常直接 `'$e'` 显示:安全存储不可用时用户看到 **`Bad state: 无法使用系统安全存储…`**(本轮在模拟器上看到) | 新增 `errorText()`,去掉 `Bad state: ` / `Exception: ` 前缀;`ApiException` 行为不变 | `error_text_test.dart` |
58
- | F6 | 25 处被丢弃的 Future | 意图是「发出去就不管」,但与真正漏写 `await` 无法区分 | 显式 `unawaited()`;`unawaited_futures` 进入 `analysis_options.yaml`,以后漏写会被 CI 拦住 | `flutter analyze` |
59
- | F7 | 首页问候 | 「今天打算设计什么?/ What are you designing today?」是设计工具的遗留文案,与产品(远程操控编码 agent)不符;还硬编码 `Georgia` 字体(Android 没有) | 「要让 Harness 做点什么?」;去掉硬编码字体 | `skin_home_test.dart` |
60
- | F8 | 设置页 | 每张卡片最后一行多一条分隔线;右侧文案自带 `▸` 又叠一个 `›`(双箭头) | `_SettingsRow` 最后一行不画分隔线;去掉文案里的 `▸` | 模拟器截图对比(`docs/screenshots/` 与旧图) |
61
-
62
- ### 4.2 Node 插件与中继(由子任务执行,已逐项复核计数与关键修复)
63
-
64
- 完整原文:`docs/AUDIT-2026-11-node.md`。摘要:
65
-
66
- | # | 位置 | 严重度 | 说明 |
67
- |---|---|---|---|
68
- | D1 | `relay/node-server.js` upgrade 监听器 | **高** | 未认证请求的目标为 `http://[`、`//[`、`http://:99999999/` 时 `new URL()` 同步抛 `ERR_INVALID_URL`,抛在事件监听器里 = `uncaughtException`,**一条请求即可让公开部署的中继进程退出**。本轮独立复现了这三个目标都会抛。已加 try/catch 并 `socket.destroy()` |
69
- | D2 | `readJson` | 低 | JSON `null` 请求体让约 40 处 `body.x` 返回 500 |
70
- | D3 | `index.js` 六个状态文件 | 中 | 不遵守 `DSH_HOME`,两个隔离实例会共用 held 队列与回执文件;**升级后设置了 `DSH_HOME` 的用户会看到一次空的已读/排队/回执/活动状态**,默认路径不变 |
71
- | D4 | `releaseHeld` | 中 | 图片排队消息在第一次投递未返回时又来一次 idle 事件,会被投递两次 |
72
- | D5 | `RelayConnector.start()` | 低(潜伏) | `stop()` 后再 `start()`,撤销设备不再踢掉在线会话;生产代码只调一次 `start()`,当前不可达 |
73
- | C1 | `.github/workflows/ci.yml` | 中 | 语法检查只覆盖 `lib/*.js`;CI 从未安装 `ws`,6 个中继真实套接字测试永远被跳过。已改为检查全部 JS/MJS 并安装 `ws`(**无法在本地运行 GitHub Actions,未验证**) |
74
-
75
- 删除的死代码与 12 个一次性脚本(其断言已并入 `test/`;其中 `verify-issue14-p0` 有 3 条断言早已失效而无人发现)见 Node 原文 §3–§4。
76
-
77
- ## 5. 重构(行为不变)
78
-
79
- - **`chat_screen.dart`**:`_ChatScreenState` 原为 5200 行、约 60 个字段的单个类。现为:`chat_state_base.dart`(全部字段 + 30 条跨 mixin 调用的方法签名)+ 8 个功能 mixin(`turn_nav`、`history`、`events`、`timeline_view`、`queue`、`composer`、`files`、`actions`)+ 6 个周边控件文件。方法体**逐字搬运**。
80
- - 证明无损:对拆分前后全部源码做 token 多重集合比对,**丢失的 token 只有 9 个 `static`**(静态成员提到库级),新增的全是 `part`/`mixin`/`@override`/抽象签名/文档注释。
81
- - 编译器保证每条抽象签名恰好有一份实现;`flutter test` 全量通过;模拟器里实测发消息 → 流式 → 工具卡 → 权限卡 → 允许 → 回复完成。
82
- - 已知局限:这是「按功能切文件」而非「抽出独立控制器」。mixin 之间仍共享一个状态对象,后续要真正解耦应把 `history/events/queue` 抽成不依赖 `State` 的类。
83
- - **`main.dart`**:`ConnectionSheet` 抽到 `screens/connection_sheet.dart`。
84
- - **`lib/index.js`**:纯函数与可独立模块按原文搬到 11 个文件,`index.js` 对外的另外 50 个导出名集合不变(导入后比对)。`handleApi`(约 2800 行)与它共享的闭包状态**没有动**——要动就是重写而不是搬运。
85
-
86
- ## 6. 平台配置审查(只读,未改)
87
-
88
- | 项 | 观察 | 评估 |
89
- |---|---|---|
90
- | Android `usesCleartextTraffic="true"` | 全局放行明文 | LAN 动态 IP 无法按域限定,源码注释已声明为已知权衡;公网场景须走 HTTPS/中继 |
91
- | Android `MainActivity exported="true"` | 本体无 intent-filter,入口全在 `activity-alias` | 可能不必要;**没有 Android 构建环境,不敢改**,列为后续硬化项 |
92
- | iOS ATS `NSAllowsLocalNetworking` | 只放行 `.local`、无限定主机名与 IP 字面量 | 经 Tailscale MagicDNS 这类**带域名的 http 地址**会被 ATS 拦截;写入已知限制,未验证 |
93
- | Keychain 与模拟器 | `--no-codesign` 的模拟器包没有 entitlements,Keychain 报 `-34018` | 环境问题而非 App 缺陷;本轮用 `xcodebuild` 带 ad-hoc 签名构建后正常 |
94
- | Markdown 链接 | 只放行 `http/https`,有测试 | 良好 |
95
-
96
- ## 7. 品牌与插图替换
97
-
98
- **问题**:App 图标与首页使用 DeepSeek 鲸鱼标识(`icon-1024.png`、`deepseek-logo.png`、Android 的 `deepseek_logo.png` 以及由它们派生的 8 款图标和全部 iOS/Android 图标位图;代码注释自称「官方 logo(DeepSeek 官网 favicon 转 PNG)」);吉祥物「大肥鱼」(蓝发鲸尾女仆)来自两个第三方仓库、美术出处不清。文档自己把这一项标为「未解决」。
99
-
100
- **做法(第一轮,已提交)**(委托子任务完成,主审计者独立复核):全部换成仓库内由 Dart `CustomPainter` 绘制的原创素材,不含任何下载图片、AI 生图、字体或图标包。
101
-
102
- > **第二轮更新(项目方要求,未提交)**:项目方随后提供了两张图片(头像标志、全身插画)并要求使用。因此现在:**默认桌面图标、App 内标志、首页角色用这两张图片**(`tools/brand/supplied_art.py` 生成各尺寸);代码绘制的素材保留用于其余 7 款备选图标和 Android 悬浮宠物(单张静图无法驱动那 16 个动画)。下表第一列描述的是代码绘制的部分。两张图片画的是与旧导入吉祥物同一个角色,**作者与授权无法由仓库核实,已在 `docs/BRAND-ASSETS.md` 留出待项目方填写的表格**。
103
-
104
- | 素材 | 新内容 | 位置 |
105
- |---|---|---|
106
- | 品牌标 | D 形聊天气泡 + 终端提示符 `>_` + 在线绿点;不是鲸鱼,与 DeepSeek 标识无共同轮廓或构图 | `lib/brand/brand_mark.dart` |
107
- | 8 款桌面图标(id 不变) | 同一枚标的 8 种处理:默认 / 深海荧光 / 贝壳徽章 / 月夜 / 贴纸 / 邮票 / 霓虹 / 单色(兼 Android 13 主题图标层) | `lib/brand/app_icon_art.dart` |
108
- | 吉祥物「大肥鱼」 | 圆滚滚、竖直站立的非人形小鱼;16 个姿态,四套皮肤 × 明暗 | `lib/brand/mascot.dart`、`lib/widgets/home_pet.dart` |
109
- | 位图 | iOS AppIcon 全部尺寸(不透明 RGB)、Android 5 个密度 × 8 款 × 前景/背景/单色层、16 个桌宠 WebP 动画(共 2.6 MB,旧的 24 MB) | `tools/brand/build.sh` 一键生成 |
110
-
111
- **独立复核**
112
-
113
- - 残留扫描:`grep` 旧文件名 / 旧出处,剩下的只有守卫测试、Kotlin 里指代另一个项目状态机设计的注释,以及一处**界面可见**的「角色素材」署名(`settings_screen.dart`,后来按项目方要求整行删除)。
114
- - iOS 图标:1024 与 180 像素图均 `hasAlpha: no`;已在 iOS 模拟器的真实主屏上看到新图标。
115
- - 16 个 WebP:直接解析 RIFF/ANMF 块核对帧数、每帧 84 ms、循环标志、画布 288×229,与 `pet-manifest.json` 全部一致(画布尺寸与旧管线产物相同,Kotlin 的布局假设不变)。
116
- - 可复现:重跑 `tools/brand/build.sh` 后 171 个生成文件**逐字节一致**。
117
- - 已知行为变化:为让每个 WebP 不超过约 300 KB,循环段改为 40 帧;一次性动画变短,而 Kotlin 把片长当作脉冲时长——`success` 从 10.2 s 变为 4.0 s,`error` 从 5.0 s 变为 4.7 s。
118
- - **没有验证**:Android 原生播放(`AnimatedImageDrawable`)、自适应图标在真实启动器里的遮罩、主题图标、Kotlin 构建。本环境没有 Android SDK 与设备。
119
-
120
- **这不是法律意见**:代码绘制的素材是原创的,且刻意避开了旧标识的轮廓与构图;「名称使用是否合规」只能由项目方/法务判断。
121
-
122
- ## 8. 最终复验
123
-
124
- 全部改动完成后的实测(2026-11-01,本机):
125
-
126
- | 检查 | 结果 |
127
- |---|---|
128
- | `dart format --output=none --set-exit-if-changed lib test` | 通过(CI 同一道门) |
129
- | `flutter analyze` | No issues found |
130
- | `flutter test` | **809 通过 / 18 跳过 / 0 失败** |
131
- | `node --check lib/index.js && node --test test/*.js test/*.mjs` | **490 项 / 482 通过 / 0 失败 / 8 跳过**(6 项是未安装 `ws` 的中继真实套接字测试,2 项是本机没有 Java 的 keystore 测试) |
132
- | `tools/brand/build.sh` 重跑 | 171 个生成文件与重跑前逐字节一致 |
133
- | iOS 模拟器(`xcodebuild` ad-hoc 签名,演示模式) | 连接页 → 首页 → 会话 → 通知 → 设置 → 新建会话 → 聊天(发送、流式、工具卡、权限卡、允许、回复完成)→ 深色模式,全部实测通过;新图标出现在真实主屏 |
134
- | `ios/Runner.xcodeproj/project.pbxproj` | 与 HEAD 逐字节一致(构建工具曾把它从 CRLF 改成 LF,已无损还原;`store-config` 的 set-app-id 测试依赖 CRLF) |
135
-
136
- 两条需要如实说明:
137
-
138
- - 全量 `flutter test` 在多个后台任务同时跑、机器负载很高时,`sse_follows_base_test`(真实套接字 + 6 秒等待)出现过一次超时失败;单独连跑 4 次全部通过,负载降下来后全量复验也通过。它对负载敏感,不是本轮改动引入的回归,但确是一个脆弱的测试。
139
- - 本轮没有做真机测试,没有做 Android 构建,没有跑 GitHub Actions。
140
-
141
- ## 8.1 观察到但没有改的行为
142
-
143
- - **通知权限在首次启动、连接页上就弹出**(还没有任何上下文)。Apple 建议在用户明白用途时再请求。这是行为变化而非视觉问题,只做记录。
144
- - **模拟器是共享的**:本轮验证期间另一个会话也在用同一台模拟器(Safari 页面、「◀ Floorplan Agent」返回链接),截图时需要留意。
145
- - 两个设置文案仍含 `选择 ▸` / `上级 ▸` 这种独立箭头(`sheets.dart`),它们没有叠加第二个箭头,所以没动。
146
-
147
- ## 9. 仍未解决 / 未验证
148
-
149
- - Android 原生代码与资源(悬浮球宠物动画、桌面图标切换、`mipmap`)**没有编译、没有在设备上跑过**。
150
- - iOS 真机、TestFlight、App Store Connect 隐私问卷与出口合规(见 `docs/STORE-LAUNCH.md`)。
151
- - 经 GitHub Actions 的 CI(本地无法运行)。
152
- - 仓库历史里仍保存着旧的 DeepSeek 标识与旧吉祥物文件;只改工作区不会改变历史。是否重写历史由发布者决定。
153
- - `docs/screenshots/pgy-*.jpg` 是第三方应用(蒲公英)的界面截图,存在引用第三方界面的版权敏感性,本轮**没有删除**,由发布者决定。
154
- - 根目录未跟踪的 `蓝发鲸尾女仆贴纸少女.png` 是用户提供的旧吉祥物原图,**不要提交**。
155
- - Node 侧未处理项(会改线上行为或无法复现)见 `docs/AUDIT-2026-11-node.md` §5–§6。
156
-
157
- ## 10. 复核命令
158
-
159
- ```bash
160
- # Dart
161
- cd dsh-mobile-app && flutter analyze && dart format --output=none --set-exit-if-changed lib test && flutter test
162
- # Node
163
- node --check lib/index.js && node --test test/*.js test/*.mjs
164
- # 拆分无损的复现步骤见 dsh-mobile-app/tools/audit/README.md;缺陷复现:
165
- flutter test test/api_logic_test.dart test/sse_parser_test.dart test/logger_test.dart \
166
- test/new_folder_sheet_test.dart test/error_text_test.dart
167
- ```
@@ -1,180 +0,0 @@
1
- # DSH Mobile 构建环境记录
2
-
3
- 这份记录把本机、CI 和商店发布之间的工具链边界固定下来,避免把“配置已生成”误写成“构建或上架已验证”。它是项目理解阶段的环境证据,后续每次工具链或构建命令发生变化时应在这里更新;Windows 与 macOS 的职责分界保留,是因为 Xcode 只能在 macOS 上运行。
4
-
5
- > 记录时间:2026-11-01(Asia/Shanghai)
6
- > 适用基线:插件 `3.2.4`,Flutter App `3.2.4+32`
7
-
8
- ## 1. 当前工作区
9
-
10
- - 工作区:`D:/Project_Vibe_Coding/DSH Mobile`
11
- - 唯一代码基线:`dsh-mobile-remote-main/`
12
- - 当前目录不是 Git 仓库:`git -C dsh-mobile-remote-main status --short --branch` 返回 `fatal: not a git repository`。
13
- - 本轮没有执行克隆、切换分支、提交或公开发布。
14
-
15
- ## 2. 源码声明的版本要求
16
-
17
- | 组件 | 源码/文档要求或锁定值 | 证据 |
18
- |---|---|---|
19
- | Node.js | `>=20.3.0`(`package.json` `engines`;推荐 22 LTS,`toolchain.json` 固定 22.23.4) | `package.json`、`CONTRIBUTING.md` |
20
- | npm | 随 Node.js | 当前环境检查 |
21
- | Dart | `^3.13.0` | `dsh-mobile-app/pubspec.yaml` |
22
- | Flutter | `3.47.9` stable | `toolchain.json`、Flutter 官方发布索引 |
23
- | Java | Java 17 | `android/app/build.gradle.kts` 的 `sourceCompatibility`、`targetCompatibility`、Kotlin JVM target |
24
- | Android Gradle Plugin | `9.1.0` | `android/settings.gradle.kts` |
25
- | Kotlin Gradle Plugin | `2.4.0` | `android/settings.gradle.kts` |
26
- | Gradle | `9.3.1`(`gradlew`/`gradlew.bat`/wrapper JAR 已生成并通过 `gradlew --version`) | `android/gradle/wrapper/` |
27
- | Android applicationId | `com.mrdayone.dshmobile` | `android/app/build.gradle.kts` |
28
- | App 当前显示名 | `DSH Mobile` | Android manifest placeholder、iOS Info.plist |
29
- | App 版本 | `3.2.4+32` | `dsh-mobile-app/pubspec.yaml` |
30
- | 插件版本 | `3.2.4` | 根 `package.json` |
31
- | iOS Bundle Identifier | `com.mrdayone.dshmobile` | `ios/Runner.xcodeproj/project.pbxproj` |
32
- | iOS deployment target | `15.0` | `toolchain.json`、`ios/Runner.xcodeproj/project.pbxproj` |
33
-
34
- Flutter 版本已固定为 `3.47.9`;其生成的 Swift Package 最低 iOS 版本为 15.0,Runner 和 CI 已统一到该版本。
35
-
36
- ## 3. Windows 本机初始检查(2026-11-01)
37
-
38
- 执行环境:Windows 10 x86_64,Git Bash(`MINGW64_NT-10.0-19045`)。
39
-
40
- | 工具 | 实际结果 |
41
- |---|---|
42
- | Node.js | `v22.14.0`,可用 |
43
- | npm | `10.9.2`,可用 |
44
- | Git | `2.55.0.windows.4`,可用;目标目录本身无 `.git` |
45
- | Flutter | 缺失 |
46
- | Dart | 缺失 |
47
- | Java/JDK | 缺失 |
48
- | adb | 缺失 |
49
- | Android SDK / sdkmanager | 缺失 |
50
- | Gradle 全局命令 | 缺失;仓库包含 wrapper,但缺 Flutter SDK 和 Java 时无法执行 |
51
- | Xcode / xcodebuild | Windows 不可用 |
52
- | CocoaPods / pod | Windows 不可用 |
53
- | FVM | 缺失 |
54
- | `JAVA_HOME` | 未设置 |
55
- | `ANDROID_HOME` | 未设置 |
56
- | `ANDROID_SDK_ROOT` | 未设置 |
57
-
58
- Node 依赖安装命令:
59
-
60
- ```text
61
- cd dsh-mobile-remote-main && npm install --no-package-lock
62
- ```
63
-
64
- 结果:成功安装 46 个包。仓库没有 `package-lock.json` 或 `pnpm-lock.yaml`;`npm ls --depth=0` 显示核心 peer 包和 `qrcode@1.5.4` 已安装,`dsh-codex-connect` 是声明的可选依赖且当前未安装。
65
-
66
- ## 4. 已运行的检查
67
-
68
- ### 4.1 Node 插件初始检查
69
-
70
- 命令:
71
-
72
- ```text
73
- cd dsh-mobile-remote-main && node --check lib/index.js && node --test test/*.js test/*.mjs
74
- ```
75
-
76
- 结果:
77
-
78
- - `node --check lib/index.js` 通过。
79
- - 测试共 223 项:213 通过、6 失败、4 跳过。
80
- - 失败不是单一业务错误,已单独复现并分为:
81
- - Windows 临时目录/资源释放:`EBUSY` 删除临时目录;
82
- - Windows 创建符号链接:`EPERM`;
83
- - 特殊文件名测试:测试夹具直接打开包含制表符/换行的路径时出现 `ENOENT`;
84
- - Node `22.14.0` 不提供 `node:zlib` 的 `zstdCompressSync`:`session-list-title-refresh.test.mjs` 无法加载。
85
- - `test/git-read-api.test.js` 单独运行:1/1 通过。
86
- - `test/session-title-refresh.test.mjs` 单独运行:9/9 通过。
87
-
88
- 这些失败必须在 Windows/CI 兼容性处理阶段决定是修复测试夹具、提高平台条件声明,还是把需要更高 Node 版本的测试放到对应 CI 运行矩阵;当前不能宣称 Node 测试门禁通过。
89
-
90
- ### 4.2 Flutter / Android / iOS 初始检查
91
-
92
- 初始检查时无法执行以下命令,因为 Flutter、Dart、JDK、Android SDK 均缺失;后续安装固定工具链后已在第 8 节补充最终结果:
93
-
94
- ```text
95
- flutter pub get
96
- dart format --output=none --set-exit-if-changed .
97
- flutter analyze
98
- flutter test
99
- flutter build apk --debug
100
- flutter build appbundle --release
101
- ```
102
-
103
- Windows 无法执行:
104
-
105
- ```text
106
- flutter build ios --no-codesign
107
- flutter build ipa --no-codesign
108
- ```
109
-
110
- 原因是 iOS 工具链需要 macOS/Xcode。此限制不阻止 Windows 端完成 Dart/Android/CI 配置,但 iOS 编译必须交给 macOS 或 GitHub Actions macOS runner。
111
-
112
- ## 5. REA 状态与证据边界
113
-
114
- - 当前会话工具列表没有 REA MCP 分析工具。
115
- - 仓库内没有找到 `.apk`、`.aab`、`.ipa`、`.app` 或 `.tgz` 构建 artifact。
116
- - `rea` CLI 未安装。
117
- - 尝试使用 CLI fallback:
118
-
119
- ```text
120
- npx -y rea-agents@latest doctor --client codex --json
121
- ```
122
-
123
- 结果:失败。当前 Node `v22.14.0` 低于 `rea-agents@6.8.0` 要求的 `^22.23.4 || ^24.22.1 || >=26.12.1`,并在加载 `node:zlib` 的 `zstdDecompress` 导出时抛出 `SyntaxError`。
124
-
125
- 因此本项目没有本轮 REA artifact 或运行时观察证据。后续理解文档只把源码、测试和实际运行输出写成对应证据;不会把静态源码推断冒充 REA 运行事实。
126
-
127
- ## 6. 已发现的发布阻塞
128
-
129
- - 初始检查时 Flutter、Dart、JDK 和 Android SDK 均未安装;本轮已安装固定 Flutter/Dart/Node/JDK,并下载 Android 命令行工具。
130
- - Windows 无法执行 Xcode/CocoaPods/iOS 构建。
131
- - iOS Runner 和 Bundle Identifier 已生成并固定;Apple 签名证书、provisioning profile 和 App Store Connect 凭据仍缺失。
132
- - 当前没有 Android 正式签名:`android/key.properties` 和 `android/app/release.jks` 均不存在;v3.2.4 起 Gradle 在无 key.properties 时让 release 构建失败,只有显式 `DSH_ALLOW_DEBUG_SIGNING=1` 才用 debug 签名出候选包(只适合开发/测试,不适合商店上传)。
133
- - Android `applicationId` 已固定为 `com.mrdayone.dshmobile`。
134
- - **GitHub Actions**:本仓库现有三个 workflow——`ci.yml`(Linux:Node 语法检查 + 测试、Flutter 格式/分析/测试,外加开启远程访问开关的中继测试)、`ios-build.yml`(仅手动触发,macOS 无签名构建 + 产物核对)和 `android-build.yml`(仅手动触发,Kotlin 单测 + AAB/APK + 产物核对,**尚未在 GitHub 上运行过**,需 `ANDROID_SDK_LICENSES_ACCEPTED=true`)。`release.yml`(含 Play / TestFlight 条件上传)**不在本仓库**,`STORE-LAUNCH` §9 的描述是设计记录,没有实现也未验证。
135
-
136
- ## 7. Windows / macOS / CI 职责边界
137
-
138
- | 工作 | Windows | macOS runner | 需要用户凭据或人工操作 |
139
- |---|---:|---:|---:|
140
- | Node 插件开发与测试 | 可做 | 可做 | 否 |
141
- | Flutter/Dart 开发、格式化、分析、单测 | 安装 Flutter/JDK 后可做 | 可做 | 否 |
142
- | Android debug/release 无签名构建 | 安装 Android SDK/JDK 后可做 | 可做 | 否 |
143
- | Android 商店签名 AAB | 可在本地构建 | 可做 | 需要用户保管的 keystore/Secrets |
144
- | iOS 无签名编译 | 不可 | 可做 | 否 |
145
- | iOS 签名/TestFlight | 不可 | 可做 | Apple 账号、证书、provisioning、App Store Connect 权限 |
146
- | Google Play 上传 | 可由 CI 做 | 可由 CI 做 | Google Play 服务账号/发布权限 |
147
- | App Store 公开发布 | 不可自动完成 | CI 可构建和上传 | 用户确认、Apple 账号和不可逆商店操作 |
148
-
149
- ## 8. 本轮最终门禁更新(2026-11-01)
150
-
151
- - 固定工具链已安装到用户级目录:Flutter `3.47.9` / Dart `3.13.7`、Node `22.23.4` / npm `10.9.9`、Temurin JDK `17.0.20.1`。
152
- - `flutter analyze`:通过,`No issues found!`。
153
- - `flutter test`:通过,593 项全部通过。
154
- - 本地无签名发布门禁:通过,版本、Android/iOS Bundle ID、文档、Keychain entitlement 和当时记录的四个 workflow 均通过检查(本仓库现仅 `ci.yml` 与 `ios-build.yml`,见第 6 节)。
155
- - Node 最终套件:239 项中 230 通过、5 失败、4 跳过。5 个失败仍是 Windows 临时目录锁定、符号链接权限和特殊文件名夹具边界;不是本次 Flutter/iOS 改动引入的错误。Node 语法检查通过。
156
- - Android SDK 命令行工具下载和 SHA-256 校验通过;Gradle wrapper 已用 Gradle `9.3.1` 官方发行包生成,`gradlew --version` 通过。Flutter `3.47.9` 的真实 Gradle 配置要求 NDK `28.2.13676358`,已同步到 `toolchain.json`、Android CI 和 release workflow。当前 SDK 根目录只有 `cmdline-tools/latest`,`platform-tools`、`platforms/android-36`、`build-tools/36.0.0` 和 `ndk/28.2.13676358` 均未安装;sdkmanager 明确因未接受 `android-sdk-license` 拒绝安装,因此 `flutter build apk --debug` 仍被工具链阻塞。两个 Android workflow 现在要求仓库 Variable `ANDROID_SDK_LICENSES_ACCEPTED=true`,不会无条件代替维护者接受许可证。
157
- - iOS deployment target 已统一为 `15.0`,与 Flutter `3.47.9` 生成的 Swift Package 要求一致。Windows 没有 Xcode/Swift,未执行 `flutter build ios`、IPA、模拟器或真机测试;macOS GitHub Actions 是下一验证面。
158
- - **无签名构建(`--no-codesign`)的 `Runner.app` 只能证明能编译,不能安装运行**:它不带任何 entitlements,Keychain 调用返回 `-34018 errSecMissingEntitlement`,连接页点「连接」只会显示「安全存储不可用」(2026-10-31 在模拟器上实测)。在模拟器里运行请**去掉** `--no-codesign`(Xcode 会 ad-hoc 签名并带上权限,同一天实测可以连接并进入首页);真机需要正式签名。
159
- - 无签名 iOS 流程已改为验证 `Runner.app`,不再把 Flutter `--no-codesign` 路径误报成可分发 IPA。带签名的 IPA 仍需 Apple Secrets。
160
- - iOS 文件桥接使用 CoreFoundation 的 IANA charset converter 处理 GB18030/GBK;Android 与 iOS 的文件预览编码路径已对齐。
161
- - token 在安全存储不可用时不再回退写入 SharedPreferences;旧值只在成功写入 Keychain/Keystore 后完成一次性迁移。
162
- - 发布打包脚本现在检查 `npm pack` 退出码、tgz 存在性和非空大小,插件包缺失会使脚本失败。
163
- - Dart CI 格式门禁已实际执行并修复 75 个需要格式化的源码/测试文件;现在 `dart format --output=none --set-exit-if-changed lib test`、`flutter analyze` 和 `flutter test` 均通过。
164
- - `release-check.ps1 -StoreSubmission` 已加入严格模式;当前按预期因缺少 keystore、真实 HTTPS URL、支持邮箱和签名 AAB/IPA 失败,不会把 unsigned/debug candidate 当成可上架包。
165
- - release workflow 已加入条件上传:正式签名 AAB 和 `GOOGLE_PLAY_SERVICE_ACCOUNT_JSON` 存在时上传 Google Play internal track;正式签名 IPA、Apple signing Secrets 和 App Store Connect API key 存在时上传 TestFlight;其他情况只保留候选产物并输出跳过原因。两个上传 action 均固定到已核验 commit SHA。
166
- - 当前文档品牌已统一为 `DSH Mobile`;Android 内部 Kotlin namespace `com.dsh.remote` 与商店 applicationId `com.mrdayone.dshmobile` 的区别已在兼容性文档中明确,避免把源码包名误当成商店包名。
167
- - 平台静态审查确认 `Runner.entitlements` 的空 Keychain Sharing group 符合 `flutter_secure_storage` 官方 iOS 配置;Android 明文 HTTP 仍是动态局域网/私有组网 IP 的兼容取舍,公网使用要求 HTTPS,文档矩阵已同步当前实现事实。
168
-
169
- 下一步不是继续扩大 Windows 本地安装范围,而是在 GitHub macOS/Android runner 上执行 workflow;签名和商店上传仍需要发布者自己的 Secrets 与人工确认。
170
-
171
- ## 9. macOS 上的 Android 构建(2026-11-02 实测)
172
-
173
- 此前的记录说 macOS 开发机上没有 Android SDK / Java,**不准确**:
174
-
175
- - Android SDK 在 `~/Library/Android/sdk`(platforms 35/36、build-tools 36.0.0、NDK 28.2.13676358、AVD `dsh_pixel_36`);`/usr/bin/java` 只是占位,真正的 JDK 17 在 `~/.local/jdk-17/Contents/Home`(`toolchain.json` 要求 17)。
176
- - 用法:`JAVA_HOME=~/.local/jdk-17/Contents/Home DSH_ALLOW_DEBUG_SIGNING=1 flutter build appbundle --release`(约 2 分钟;产物由 debug 密钥签名,不能上架)。**在仓库的临时副本里构建**(`rsync` 排除 `build/`、`.dart_tool/`),避免弄脏工作区和必须保持 CRLF 的 `project.pbxproj`。
177
- - 检查产物:`python3 tools/verify-release-artifacts.py --apk …`(见 `docs/STORE-LAUNCH.md` §8)。
178
- - 模拟器:主机负载很高(> 25)时软件渲染的模拟器会 ANR,对话框关不掉;线程转储显示应用主线程空闲,是资源饥饿而非应用问题。关掉 iOS 模拟器面板、等负载降下来再测。
179
- - Kotlin 单元测试 `./gradlew :app:testDebugUnitTest` 不在 `ci.yml` 里;见 `android-build.yml`。
180
-