@creatoria/miniapp-mcp 0.1.3 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -66
- package/dist/app/cli/index.d.ts +6 -0
- package/dist/app/cli/index.d.ts.map +1 -0
- package/dist/app/cli/index.js +6 -0
- package/dist/app/cli/index.js.map +1 -0
- package/dist/app/index.d.ts +6 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +6 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/server/index.d.ts +7 -0
- package/dist/app/server/index.d.ts.map +1 -0
- package/dist/app/server/index.js +6 -0
- package/dist/app/server/index.js.map +1 -0
- package/dist/capabilities/assert/handlers/assert-handlers.d.ts +98 -0
- package/dist/capabilities/assert/handlers/assert-handlers.d.ts.map +1 -0
- package/dist/capabilities/assert/handlers/assert-handlers.js +179 -0
- package/dist/capabilities/assert/handlers/assert-handlers.js.map +1 -0
- package/dist/capabilities/assert/handlers/index.d.ts +7 -0
- package/dist/capabilities/assert/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/assert/handlers/index.js +7 -0
- package/dist/capabilities/assert/handlers/index.js.map +1 -0
- package/dist/capabilities/assert/index.d.ts +15 -0
- package/dist/capabilities/assert/index.d.ts.map +1 -0
- package/dist/capabilities/assert/index.js +90 -0
- package/dist/capabilities/assert/index.js.map +1 -0
- package/dist/capabilities/assert/schemas/index.d.ts +101 -0
- package/dist/capabilities/assert/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/assert/schemas/index.js +62 -0
- package/dist/capabilities/assert/schemas/index.js.map +1 -0
- package/dist/capabilities/automator/handlers/close.d.ts +18 -0
- package/dist/capabilities/automator/handlers/close.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/close.js +45 -0
- package/dist/capabilities/automator/handlers/close.js.map +1 -0
- package/dist/capabilities/automator/handlers/connect.d.ts +24 -0
- package/dist/capabilities/automator/handlers/connect.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/connect.js +51 -0
- package/dist/capabilities/automator/handlers/connect.js.map +1 -0
- package/dist/capabilities/automator/handlers/disconnect.d.ts +16 -0
- package/dist/capabilities/automator/handlers/disconnect.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/disconnect.js +44 -0
- package/dist/capabilities/automator/handlers/disconnect.js.map +1 -0
- package/dist/capabilities/automator/handlers/index.d.ts +8 -0
- package/dist/capabilities/automator/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/index.js +8 -0
- package/dist/capabilities/automator/handlers/index.js.map +1 -0
- package/dist/capabilities/automator/handlers/launch.d.ts +25 -0
- package/dist/capabilities/automator/handlers/launch.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/launch.js +61 -0
- package/dist/capabilities/automator/handlers/launch.js.map +1 -0
- package/dist/capabilities/automator/index.d.ts +15 -0
- package/dist/capabilities/automator/index.d.ts.map +1 -0
- package/dist/capabilities/automator/index.js +55 -0
- package/dist/capabilities/automator/index.js.map +1 -0
- package/dist/capabilities/automator/schemas/close.d.ts +5 -0
- package/dist/capabilities/automator/schemas/close.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/close.js +11 -0
- package/dist/capabilities/automator/schemas/close.js.map +1 -0
- package/dist/capabilities/automator/schemas/connect.d.ts +11 -0
- package/dist/capabilities/automator/schemas/connect.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/connect.js +19 -0
- package/dist/capabilities/automator/schemas/connect.js.map +1 -0
- package/dist/capabilities/automator/schemas/disconnect.d.ts +5 -0
- package/dist/capabilities/automator/schemas/disconnect.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/disconnect.js +11 -0
- package/dist/capabilities/automator/schemas/disconnect.js.map +1 -0
- package/dist/capabilities/automator/schemas/index.d.ts +9 -0
- package/dist/capabilities/automator/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/index.js +14 -0
- package/dist/capabilities/automator/schemas/index.js.map +1 -0
- package/dist/capabilities/automator/schemas/launch.d.ts +17 -0
- package/dist/capabilities/automator/schemas/launch.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/launch.js +26 -0
- package/dist/capabilities/automator/schemas/launch.js.map +1 -0
- package/dist/capabilities/element/handlers/element-handlers.d.ts +212 -0
- package/dist/capabilities/element/handlers/element-handlers.d.ts.map +1 -0
- package/dist/capabilities/element/handlers/element-handlers.js +383 -0
- package/dist/capabilities/element/handlers/element-handlers.js.map +1 -0
- package/dist/capabilities/element/handlers/index.d.ts +7 -0
- package/dist/capabilities/element/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/element/handlers/index.js +27 -0
- package/dist/capabilities/element/handlers/index.js.map +1 -0
- package/dist/capabilities/element/index.d.ts +20 -0
- package/dist/capabilities/element/index.d.ts.map +1 -0
- package/dist/capabilities/element/index.js +199 -0
- package/dist/capabilities/element/index.js.map +1 -0
- package/dist/capabilities/element/schemas/index.d.ts +325 -0
- package/dist/capabilities/element/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/element/schemas/index.js +168 -0
- package/dist/capabilities/element/schemas/index.js.map +1 -0
- package/dist/capabilities/index.d.ts +34 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +40 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/loader.d.ts +61 -0
- package/dist/capabilities/loader.d.ts.map +1 -0
- package/dist/capabilities/loader.js +164 -0
- package/dist/capabilities/loader.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.d.ts +24 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.js +37 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.d.ts +32 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.js +51 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/index.d.ts +12 -0
- package/dist/capabilities/miniprogram/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/index.js +12 -0
- package/dist/capabilities/miniprogram/handlers/index.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/navigate.d.ts +26 -0
- package/dist/capabilities/miniprogram/handlers/navigate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/navigate.js +56 -0
- package/dist/capabilities/miniprogram/handlers/navigate.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.d.ts +20 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.js +37 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.d.ts +33 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.js +132 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/system-info.d.ts +17 -0
- package/dist/capabilities/miniprogram/handlers/system-info.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/system-info.js +31 -0
- package/dist/capabilities/miniprogram/handlers/system-info.js.map +1 -0
- package/dist/capabilities/miniprogram/index.d.ts +15 -0
- package/dist/capabilities/miniprogram/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/index.js +69 -0
- package/dist/capabilities/miniprogram/index.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.d.ts +15 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.js +11 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.d.ts +15 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.js +11 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/index.d.ts +10 -0
- package/dist/capabilities/miniprogram/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/index.js +10 -0
- package/dist/capabilities/miniprogram/schemas/index.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/navigate.d.ts +18 -0
- package/dist/capabilities/miniprogram/schemas/navigate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/navigate.js +22 -0
- package/dist/capabilities/miniprogram/schemas/navigate.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.d.ts +6 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.js +6 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.d.ts +18 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.js +21 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/system-info.d.ts +6 -0
- package/dist/capabilities/miniprogram/schemas/system-info.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/system-info.js +6 -0
- package/dist/capabilities/miniprogram/schemas/system-info.js.map +1 -0
- package/dist/capabilities/network/handlers/index.d.ts +7 -0
- package/dist/capabilities/network/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/network/handlers/index.js +7 -0
- package/dist/capabilities/network/handlers/index.js.map +1 -0
- package/dist/capabilities/network/handlers/network-handlers.d.ts +53 -0
- package/dist/capabilities/network/handlers/network-handlers.d.ts.map +1 -0
- package/dist/capabilities/network/handlers/network-handlers.js +127 -0
- package/dist/capabilities/network/handlers/network-handlers.js.map +1 -0
- package/dist/capabilities/network/index.d.ts +15 -0
- package/dist/capabilities/network/index.d.ts.map +1 -0
- package/dist/capabilities/network/index.js +69 -0
- package/dist/capabilities/network/index.js.map +1 -0
- package/dist/capabilities/network/schemas/index.d.ts +53 -0
- package/dist/capabilities/network/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/network/schemas/index.js +33 -0
- package/dist/capabilities/network/schemas/index.js.map +1 -0
- package/dist/capabilities/page/handlers/index.d.ts +7 -0
- package/dist/capabilities/page/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/page/handlers/index.js +7 -0
- package/dist/capabilities/page/handlers/index.js.map +1 -0
- package/dist/capabilities/page/handlers/page-handlers.d.ts +165 -0
- package/dist/capabilities/page/handlers/page-handlers.d.ts.map +1 -0
- package/dist/capabilities/page/handlers/page-handlers.js +258 -0
- package/dist/capabilities/page/handlers/page-handlers.js.map +1 -0
- package/dist/capabilities/page/index.d.ts +15 -0
- package/dist/capabilities/page/index.d.ts.map +1 -0
- package/dist/capabilities/page/index.js +83 -0
- package/dist/capabilities/page/index.js.map +1 -0
- package/dist/capabilities/page/schemas/index.d.ts +91 -0
- package/dist/capabilities/page/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/page/schemas/index.js +55 -0
- package/dist/capabilities/page/schemas/index.js.map +1 -0
- package/dist/capabilities/record/handlers/index.d.ts +7 -0
- package/dist/capabilities/record/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/record/handlers/index.js +7 -0
- package/dist/capabilities/record/handlers/index.js.map +1 -0
- package/dist/capabilities/record/handlers/record-handlers.d.ts +76 -0
- package/dist/capabilities/record/handlers/record-handlers.d.ts.map +1 -0
- package/dist/capabilities/record/handlers/record-handlers.js +255 -0
- package/dist/capabilities/record/handlers/record-handlers.js.map +1 -0
- package/dist/capabilities/record/index.d.ts +15 -0
- package/dist/capabilities/record/index.d.ts.map +1 -0
- package/dist/capabilities/record/index.js +69 -0
- package/dist/capabilities/record/index.js.map +1 -0
- package/dist/capabilities/record/schemas/index.d.ts +47 -0
- package/dist/capabilities/record/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/record/schemas/index.js +33 -0
- package/dist/capabilities/record/schemas/index.js.map +1 -0
- package/dist/capabilities/registry.d.ts +138 -0
- package/dist/capabilities/registry.d.ts.map +1 -0
- package/dist/capabilities/registry.js +261 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/capabilities/schema-registry.d.ts +4 -0
- package/dist/capabilities/schema-registry.d.ts.map +1 -0
- package/dist/capabilities/schema-registry.js +18 -0
- package/dist/capabilities/schema-registry.js.map +1 -0
- package/dist/capabilities/schema-types.d.ts +22 -0
- package/dist/capabilities/schema-types.d.ts.map +1 -0
- package/dist/capabilities/schema-types.js +2 -0
- package/dist/capabilities/schema-types.js.map +1 -0
- package/dist/capabilities/snapshot/handlers/index.d.ts +7 -0
- package/dist/capabilities/snapshot/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/handlers/index.js +7 -0
- package/dist/capabilities/snapshot/handlers/index.js.map +1 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.d.ts +75 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.d.ts.map +1 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.js +201 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.js.map +1 -0
- package/dist/capabilities/snapshot/index.d.ts +15 -0
- package/dist/capabilities/snapshot/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/index.js +48 -0
- package/dist/capabilities/snapshot/index.js.map +1 -0
- package/dist/capabilities/snapshot/schemas/index.d.ts +47 -0
- package/dist/capabilities/snapshot/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/schemas/index.js +28 -0
- package/dist/capabilities/snapshot/schemas/index.js.map +1 -0
- package/dist/config/loader.js +1 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/core/element-ref.d.ts +1 -43
- package/dist/core/element-ref.d.ts.map +1 -1
- package/dist/core/element-ref.js +1 -212
- package/dist/core/element-ref.js.map +1 -1
- package/dist/core/logger.d.ts +1 -54
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -377
- package/dist/core/logger.js.map +1 -1
- package/dist/core/output.d.ts +1 -20
- package/dist/core/output.d.ts.map +1 -1
- package/dist/core/output.js +1 -55
- package/dist/core/output.js.map +1 -1
- package/dist/core/report-generator.d.ts +1 -23
- package/dist/core/report-generator.d.ts.map +1 -1
- package/dist/core/report-generator.js +1 -211
- package/dist/core/report-generator.js.map +1 -1
- package/dist/core/session.d.ts +2 -82
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +2 -305
- package/dist/core/session.js.map +1 -1
- package/dist/core/timeout.d.ts +1 -48
- package/dist/core/timeout.d.ts.map +1 -1
- package/dist/core/timeout.js +1 -66
- package/dist/core/timeout.js.map +1 -1
- package/dist/core/tool-logger.d.ts +1 -82
- package/dist/core/tool-logger.d.ts.map +1 -1
- package/dist/core/tool-logger.js +1 -452
- package/dist/core/tool-logger.js.map +1 -1
- package/dist/core/validation.d.ts +1 -38
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +1 -92
- package/dist/core/validation.js.map +1 -1
- package/dist/runtime/element/element-ref.d.ts +44 -0
- package/dist/runtime/element/element-ref.d.ts.map +1 -0
- package/dist/runtime/element/element-ref.js +214 -0
- package/dist/runtime/element/element-ref.js.map +1 -0
- package/dist/runtime/element/index.d.ts +2 -0
- package/dist/runtime/element/index.d.ts.map +1 -0
- package/dist/runtime/element/index.js +2 -0
- package/dist/runtime/element/index.js.map +1 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +11 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/logging/index.d.ts +3 -0
- package/dist/runtime/logging/index.d.ts.map +1 -0
- package/dist/runtime/logging/index.js +3 -0
- package/dist/runtime/logging/index.js.map +1 -0
- package/dist/runtime/logging/logger.d.ts +55 -0
- package/dist/runtime/logging/logger.d.ts.map +1 -0
- package/dist/runtime/logging/logger.js +379 -0
- package/dist/runtime/logging/logger.js.map +1 -0
- package/dist/runtime/logging/tool-logger.d.ts +83 -0
- package/dist/runtime/logging/tool-logger.d.ts.map +1 -0
- package/dist/runtime/logging/tool-logger.js +454 -0
- package/dist/runtime/logging/tool-logger.js.map +1 -0
- package/dist/runtime/outputs/index.d.ts +3 -0
- package/dist/runtime/outputs/index.d.ts.map +1 -0
- package/dist/runtime/outputs/index.js +3 -0
- package/dist/runtime/outputs/index.js.map +1 -0
- package/dist/runtime/outputs/output-manager.d.ts +12 -0
- package/dist/runtime/outputs/output-manager.d.ts.map +1 -0
- package/dist/runtime/outputs/output-manager.js +39 -0
- package/dist/runtime/outputs/output-manager.js.map +1 -0
- package/dist/runtime/outputs/report-generator.d.ts +5 -0
- package/dist/runtime/outputs/report-generator.d.ts.map +1 -0
- package/dist/runtime/outputs/report-generator.js +175 -0
- package/dist/runtime/outputs/report-generator.js.map +1 -0
- package/dist/runtime/retry/index.d.ts +5 -0
- package/dist/runtime/retry/index.d.ts.map +1 -0
- package/dist/runtime/retry/index.js +5 -0
- package/dist/runtime/retry/index.js.map +1 -0
- package/dist/runtime/retry/retry.d.ts +61 -0
- package/dist/runtime/retry/retry.d.ts.map +1 -0
- package/dist/runtime/retry/retry.js +90 -0
- package/dist/runtime/retry/retry.js.map +1 -0
- package/dist/runtime/session/index.d.ts +3 -0
- package/dist/runtime/session/index.d.ts.map +1 -0
- package/dist/runtime/session/index.js +3 -0
- package/dist/runtime/session/index.js.map +1 -0
- package/dist/runtime/session/store.d.ts +28 -0
- package/dist/runtime/session/store.d.ts.map +1 -0
- package/dist/runtime/session/store.js +154 -0
- package/dist/runtime/session/store.js.map +1 -0
- package/dist/runtime/session/utils/cleanup.d.ts +3 -0
- package/dist/runtime/session/utils/cleanup.d.ts.map +1 -0
- package/dist/runtime/session/utils/cleanup.js +78 -0
- package/dist/runtime/session/utils/cleanup.js.map +1 -0
- package/dist/runtime/timeout/index.d.ts +2 -0
- package/dist/runtime/timeout/index.d.ts.map +1 -0
- package/dist/runtime/timeout/index.js +2 -0
- package/dist/runtime/timeout/index.js.map +1 -0
- package/dist/runtime/timeout/timeout.d.ts +59 -0
- package/dist/runtime/timeout/timeout.d.ts.map +1 -0
- package/dist/runtime/timeout/timeout.js +77 -0
- package/dist/runtime/timeout/timeout.js.map +1 -0
- package/dist/runtime/validation/index.d.ts +2 -0
- package/dist/runtime/validation/index.d.ts.map +1 -0
- package/dist/runtime/validation/index.js +2 -0
- package/dist/runtime/validation/index.js.map +1 -0
- package/dist/runtime/validation/validation.d.ts +39 -0
- package/dist/runtime/validation/validation.d.ts.map +1 -0
- package/dist/runtime/validation/validation.js +93 -0
- package/dist/runtime/validation/validation.js.map +1 -0
- package/dist/schemas/automator/miniprogram_close.json +12 -0
- package/dist/schemas/automator/miniprogram_connect.json +19 -0
- package/dist/schemas/automator/miniprogram_disconnect.json +12 -0
- package/dist/schemas/automator/miniprogram_launch.json +30 -0
- package/dist/server.js +5 -5
- package/dist/server.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/miniprogram.d.ts +11 -2
- package/dist/tools/miniprogram.d.ts.map +1 -1
- package/dist/tools/miniprogram.js +111 -41
- package/dist/tools/miniprogram.js.map +1 -1
- package/dist/tools/page.js +2 -2
- package/dist/tools/page.js.map +1 -1
- package/docs/current/01-architecture-migration.md +337 -0
- package/docs/current/02-screenshot-timeout-fix.md +589 -0
- package/docs/current/README.md +226 -0
- package/docs/directory-structure-and-code-style-best-practices.md +91 -0
- package/docs/migration/README.md +34 -0
- package/docs/migration/TC-ALIGN-01-notes.md +35 -0
- package/docs/migration/runtime-skeleton.md +50 -0
- package/docs/migration/tool-schema-strategy.md +75 -0
- package/docs//345/256/214/346/225/264/345/256/236/347/216/260/346/226/271/346/241/210.md +14 -14
- package/docs//347/254/254/344/270/200/347/211/210/346/234/254/346/226/271/346/241/210.md +7 -7
- package/package.json +4 -2
- package/docs/SIMPLE_USAGE.md +0 -210
- package/docs/architecture.E-Docs.md +0 -1359
- package/docs/architecture.F1.md +0 -720
- package/docs/architecture.F2.md +0 -871
- package/docs/architecture.F3.md +0 -905
- package/docs/architecture.md +0 -90
- package/docs/charter.A1.align.yaml +0 -170
- package/docs/charter.A2.align.yaml +0 -199
- package/docs/charter.A3.align.yaml +0 -242
- package/docs/charter.A4.align.yaml +0 -227
- package/docs/charter.B1.align.yaml +0 -179
- package/docs/charter.B2.align.yaml +0 -200
- package/docs/charter.B3.align.yaml +0 -200
- package/docs/charter.B4.align.yaml +0 -188
- package/docs/charter.C1.align.yaml +0 -190
- package/docs/charter.C2.align.yaml +0 -202
- package/docs/charter.C3.align.yaml +0 -211
- package/docs/charter.C4.align.yaml +0 -263
- package/docs/charter.C5.align.yaml +0 -220
- package/docs/charter.D1.align.yaml +0 -190
- package/docs/charter.D2.align.yaml +0 -234
- package/docs/charter.D3.align.yaml +0 -206
- package/docs/charter.E-Docs.align.yaml +0 -294
- package/docs/charter.F1.align.yaml +0 -193
- package/docs/charter.F2.align.yaml +0 -248
- package/docs/charter.F3.align.yaml +0 -287
- package/docs/charter.G.align.yaml +0 -174
- package/docs/charter.align.yaml +0 -111
- package/docs/maintenance.md +0 -682
- package/docs/playwright-mcp/350/260/203/347/240/224.md +0 -53
- package/docs/setup-guide.md +0 -775
- package/docs/tasks.A1.atomize.md +0 -296
- package/docs/tasks.A2.atomize.md +0 -408
- package/docs/tasks.A3.atomize.md +0 -564
- package/docs/tasks.A4.atomize.md +0 -496
- package/docs/tasks.B1.atomize.md +0 -352
- package/docs/tasks.B2.atomize.md +0 -561
- package/docs/tasks.B3.atomize.md +0 -508
- package/docs/tasks.B4.atomize.md +0 -504
- package/docs/tasks.C1.atomize.md +0 -540
- package/docs/tasks.C2.atomize.md +0 -665
- package/docs/tasks.C3.atomize.md +0 -745
- package/docs/tasks.C4.atomize.md +0 -908
- package/docs/tasks.C5.atomize.md +0 -755
- package/docs/tasks.D1.atomize.md +0 -547
- package/docs/tasks.D2.atomize.md +0 -619
- package/docs/tasks.D3.atomize.md +0 -790
- package/docs/tasks.E-Docs.atomize.md +0 -1204
- package/docs/tasks.atomize.md +0 -189
package/docs/tasks.D2.atomize.md
DELETED
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
# Task Card: [D2] 快照工具集
|
|
2
|
-
|
|
3
|
-
**Task ID**: D2
|
|
4
|
-
**Task Name**: 快照工具集实现
|
|
5
|
-
**Charter**: `docs/charter.D2.align.yaml`
|
|
6
|
-
**Stage**: D (Advanced Capabilities)
|
|
7
|
-
**Status**: ✅ COMPLETED (Retrospective)
|
|
8
|
-
**Estimated**: 2-3 hours
|
|
9
|
-
**Actual**: ~2 hours
|
|
10
|
-
**Completed**: 2025-10-02
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 目标 (Goal)
|
|
15
|
-
|
|
16
|
-
实现 3 个快照工具,为小程序自动化测试提供状态捕获能力,支持页面、应用、元素三个维度的快照。
|
|
17
|
-
|
|
18
|
-
**交付物**:
|
|
19
|
-
- ✅ `src/tools/snapshot.ts` (352 lines)
|
|
20
|
-
- ✅ `tests/unit/snapshot.test.ts` (251 lines, 10 tests)
|
|
21
|
-
- ✅ 3 个快照工具全部实现
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 前置条件 (Prerequisites)
|
|
26
|
-
|
|
27
|
-
- ✅ C2: MiniProgram 工具(getPageStack, getSystemInfo, screenshot)
|
|
28
|
-
- ✅ C3: Page 工具(getData)
|
|
29
|
-
- ✅ C4: Element 工具(getText, getSize, getOffset)
|
|
30
|
-
- ✅ B3: OutputManager 实现
|
|
31
|
-
- ✅ SessionState 定义完成
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 实现步骤 (Steps)
|
|
36
|
-
|
|
37
|
-
### 1. 创建快照工具文件 ✅
|
|
38
|
-
|
|
39
|
-
**文件**: `src/tools/snapshot.ts`
|
|
40
|
-
|
|
41
|
-
**步骤**:
|
|
42
|
-
```typescript
|
|
43
|
-
import type { SessionState } from '../types.js'
|
|
44
|
-
import * as miniprogramTools from './miniprogram.js'
|
|
45
|
-
import * as pageTools from './page.js'
|
|
46
|
-
|
|
47
|
-
// 定义快照函数
|
|
48
|
-
export async function snapshotPage(
|
|
49
|
-
session: SessionState,
|
|
50
|
-
args: {
|
|
51
|
-
pagePath?: string
|
|
52
|
-
filename?: string
|
|
53
|
-
includeScreenshot?: boolean
|
|
54
|
-
fullPage?: boolean
|
|
55
|
-
}
|
|
56
|
-
): Promise<{
|
|
57
|
-
success: boolean
|
|
58
|
-
message: string
|
|
59
|
-
snapshotPath: string
|
|
60
|
-
screenshotPath?: string
|
|
61
|
-
data: any
|
|
62
|
-
}> {
|
|
63
|
-
// 实现...
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**验证**: TypeScript 编译通过,正确导入依赖
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
### 2. 实现页面快照 (snapshotPage) ✅
|
|
72
|
-
|
|
73
|
-
**功能**: 捕获当前页面数据和可选截图
|
|
74
|
-
|
|
75
|
-
**代码**:
|
|
76
|
-
```typescript
|
|
77
|
-
export async function snapshotPage(session, args) {
|
|
78
|
-
const { pagePath, filename, includeScreenshot = true, fullPage = false } = args
|
|
79
|
-
const logger = session.logger
|
|
80
|
-
|
|
81
|
-
if (!session.miniProgram) {
|
|
82
|
-
throw new Error('MiniProgram not connected')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!session.outputManager) {
|
|
86
|
-
throw new Error('OutputManager not available')
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// 1. 获取页面栈,找到当前页面
|
|
90
|
-
const pageStackResult = await miniprogramTools.getPageStack(session)
|
|
91
|
-
const currentPageInfo = pageStackResult.pages[pageStackResult.pages.length - 1]
|
|
92
|
-
|
|
93
|
-
if (!currentPageInfo) {
|
|
94
|
-
throw new Error('No active page found')
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 2. 获取页面数据
|
|
98
|
-
const pageDataResult = await pageTools.getData(session, { pagePath })
|
|
99
|
-
|
|
100
|
-
// 3. 构建快照数据
|
|
101
|
-
const timestamp = new Date().toISOString()
|
|
102
|
-
const snapshotData = {
|
|
103
|
-
timestamp,
|
|
104
|
-
pagePath: currentPageInfo.path,
|
|
105
|
-
pageData: pageDataResult.data,
|
|
106
|
-
pageQuery: currentPageInfo.query,
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 4. 保存 JSON 文件
|
|
110
|
-
const outputManager = session.outputManager
|
|
111
|
-
await outputManager.ensureOutputDir()
|
|
112
|
-
|
|
113
|
-
const snapshotFilename = filename || outputManager.generateFilename('snapshot', 'json')
|
|
114
|
-
const snapshotPath = await outputManager.writeFile(
|
|
115
|
-
snapshotFilename,
|
|
116
|
-
Buffer.from(JSON.stringify(snapshotData, null, 2))
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
// 5. 可选截图
|
|
120
|
-
let screenshotPath: string | undefined
|
|
121
|
-
if (includeScreenshot) {
|
|
122
|
-
const screenshotFilename = snapshotFilename.replace('.json', '.png')
|
|
123
|
-
const screenshotResult = await miniprogramTools.screenshot(session, {
|
|
124
|
-
filename: screenshotFilename,
|
|
125
|
-
fullPage,
|
|
126
|
-
})
|
|
127
|
-
screenshotPath = screenshotResult.path
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
success: true,
|
|
132
|
-
message: 'Page snapshot captured successfully',
|
|
133
|
-
snapshotPath,
|
|
134
|
-
screenshotPath,
|
|
135
|
-
data: snapshotData,
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**验证**:
|
|
141
|
-
- ✅ 捕获页面路径、数据、query
|
|
142
|
-
- ✅ 生成 JSON 文件
|
|
143
|
-
- ✅ 可选截图
|
|
144
|
-
- ✅ 返回文件路径
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
### 3. 实现完整应用快照 (snapshotFull) ✅
|
|
149
|
-
|
|
150
|
-
**功能**: 捕获系统信息、页面栈、当前页面数据
|
|
151
|
-
|
|
152
|
-
**代码**:
|
|
153
|
-
```typescript
|
|
154
|
-
export async function snapshotFull(session, args) {
|
|
155
|
-
const { filename, includeScreenshot = true, fullPage = false } = args
|
|
156
|
-
|
|
157
|
-
// 1. 获取系统信息
|
|
158
|
-
const systemInfoResult = await miniprogramTools.getSystemInfo(session)
|
|
159
|
-
|
|
160
|
-
// 2. 获取页面栈
|
|
161
|
-
const pageStackResult = await miniprogramTools.getPageStack(session)
|
|
162
|
-
const currentPageInfo = pageStackResult.pages[pageStackResult.pages.length - 1]
|
|
163
|
-
|
|
164
|
-
if (!currentPageInfo) {
|
|
165
|
-
throw new Error('No active page found')
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// 3. 获取当前页面数据
|
|
169
|
-
const pageDataResult = await pageTools.getData(session, {})
|
|
170
|
-
|
|
171
|
-
// 4. 构建快照数据
|
|
172
|
-
const timestamp = new Date().toISOString()
|
|
173
|
-
const snapshotData = {
|
|
174
|
-
timestamp,
|
|
175
|
-
systemInfo: systemInfoResult.systemInfo,
|
|
176
|
-
pageStack: pageStackResult.pages,
|
|
177
|
-
currentPage: {
|
|
178
|
-
path: currentPageInfo.path,
|
|
179
|
-
query: currentPageInfo.query,
|
|
180
|
-
data: pageDataResult.data,
|
|
181
|
-
},
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// 5. 保存 JSON 和截图(逻辑同 snapshotPage)
|
|
185
|
-
// ...
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**数据结构**:
|
|
190
|
-
```json
|
|
191
|
-
{
|
|
192
|
-
"timestamp": "2025-10-02T10:30:45.123Z",
|
|
193
|
-
"systemInfo": {
|
|
194
|
-
"platform": "devtools",
|
|
195
|
-
"version": "8.0.0"
|
|
196
|
-
},
|
|
197
|
-
"pageStack": [
|
|
198
|
-
{ "path": "pages/index/index", "query": {} },
|
|
199
|
-
{ "path": "pages/detail/detail", "query": { "id": "123" } }
|
|
200
|
-
],
|
|
201
|
-
"currentPage": {
|
|
202
|
-
"path": "pages/detail/detail",
|
|
203
|
-
"query": { "id": "123" },
|
|
204
|
-
"data": { "title": "Detail Page", "count": 5 }
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
**验证**:
|
|
210
|
-
- ✅ 捕获系统信息
|
|
211
|
-
- ✅ 捕获完整页面栈
|
|
212
|
-
- ✅ 捕获当前页面数据
|
|
213
|
-
- ✅ 生成 JSON + 可选截图
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
### 4. 实现元素快照 (snapshotElement) ✅
|
|
218
|
-
|
|
219
|
-
**功能**: 捕获元素文本、尺寸、位置
|
|
220
|
-
|
|
221
|
-
**代码**:
|
|
222
|
-
```typescript
|
|
223
|
-
export async function snapshotElement(session, args) {
|
|
224
|
-
const { refId, filename, includeScreenshot = false } = args
|
|
225
|
-
|
|
226
|
-
// 动态导入 elementTools 避免循环依赖
|
|
227
|
-
const elementTools = await import('./element.js')
|
|
228
|
-
|
|
229
|
-
// 1. 获取元素文本(可能不存在)
|
|
230
|
-
let text: string | undefined
|
|
231
|
-
try {
|
|
232
|
-
const textResult = await elementTools.getText(session, { refId })
|
|
233
|
-
text = textResult.text
|
|
234
|
-
} catch {
|
|
235
|
-
text = undefined
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// 2. 获取元素尺寸
|
|
239
|
-
const sizeResult = await elementTools.getSize(session, { refId })
|
|
240
|
-
|
|
241
|
-
// 3. 获取元素位置
|
|
242
|
-
const offsetResult = await elementTools.getOffset(session, { refId })
|
|
243
|
-
|
|
244
|
-
// 4. 构建快照数据
|
|
245
|
-
const timestamp = new Date().toISOString()
|
|
246
|
-
const snapshotData = {
|
|
247
|
-
timestamp,
|
|
248
|
-
refId,
|
|
249
|
-
text,
|
|
250
|
-
attributes: {}, // 当前未实现属性捕获
|
|
251
|
-
size: sizeResult.size,
|
|
252
|
-
offset: offsetResult.offset,
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// 5. 保存 JSON 和截图(逻辑同 snapshotPage)
|
|
256
|
-
// ...
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
**数据结构**:
|
|
261
|
-
```json
|
|
262
|
-
{
|
|
263
|
-
"timestamp": "2025-10-02T10:31:20.456Z",
|
|
264
|
-
"refId": "elem-123",
|
|
265
|
-
"text": "Click Me",
|
|
266
|
-
"attributes": {},
|
|
267
|
-
"size": { "width": 100, "height": 40 },
|
|
268
|
-
"offset": { "left": 20, "top": 100 }
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
**验证**:
|
|
273
|
-
- ✅ 捕获元素文本(可选)
|
|
274
|
-
- ✅ 捕获元素尺寸
|
|
275
|
-
- ✅ 捕获元素位置
|
|
276
|
-
- ✅ 生成 JSON + 可选截图
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
### 5. 文件名生成逻辑 ✅
|
|
281
|
-
|
|
282
|
-
**OutputManager 集成**:
|
|
283
|
-
```typescript
|
|
284
|
-
const outputManager = session.outputManager
|
|
285
|
-
|
|
286
|
-
// 自动生成文件名(带时间戳)
|
|
287
|
-
const snapshotFilename = filename || outputManager.generateFilename('snapshot', 'json')
|
|
288
|
-
// 示例: snapshot-1696234567890.json
|
|
289
|
-
|
|
290
|
-
// 截图文件名(替换扩展名)
|
|
291
|
-
const screenshotFilename = snapshotFilename.replace('.json', '.png')
|
|
292
|
-
// 示例: snapshot-1696234567890.png
|
|
293
|
-
|
|
294
|
-
// 写入文件
|
|
295
|
-
const snapshotPath = await outputManager.writeFile(
|
|
296
|
-
snapshotFilename,
|
|
297
|
-
Buffer.from(JSON.stringify(snapshotData, null, 2))
|
|
298
|
-
)
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
**验证**:
|
|
302
|
-
- ✅ 自动生成唯一文件名
|
|
303
|
-
- ✅ 支持自定义文件名
|
|
304
|
-
- ✅ 截图与 JSON 同名(仅扩展名不同)
|
|
305
|
-
|
|
306
|
-
---
|
|
307
|
-
|
|
308
|
-
### 6. 编写单元测试 ✅
|
|
309
|
-
|
|
310
|
-
**文件**: `tests/unit/snapshot.test.ts`
|
|
311
|
-
|
|
312
|
-
**测试用例** (10 个):
|
|
313
|
-
```typescript
|
|
314
|
-
describe('Snapshot Tools', () => {
|
|
315
|
-
describe('snapshotPage', () => {
|
|
316
|
-
it('should capture page snapshot with screenshot', async () => {})
|
|
317
|
-
it('should capture page snapshot without screenshot', async () => {})
|
|
318
|
-
it('should support custom filename', async () => {})
|
|
319
|
-
it('should fail when no miniProgram connected', async () => {})
|
|
320
|
-
it('should fail when no active page', async () => {})
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
describe('snapshotFull', () => {
|
|
324
|
-
it('should capture full application snapshot', async () => {})
|
|
325
|
-
it('should capture full snapshot without screenshot', async () => {})
|
|
326
|
-
it('should fail when no miniProgram connected', async () => {})
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
describe('snapshotElement', () => {
|
|
330
|
-
it('should fail when no miniProgram connected', async () => {})
|
|
331
|
-
it('should fail when no outputManager available', async () => {})
|
|
332
|
-
})
|
|
333
|
-
})
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
**验证**:
|
|
337
|
-
- ✅ 10 个测试全部通过
|
|
338
|
-
- ✅ Mock miniprogramTools, pageTools, elementTools
|
|
339
|
-
- ✅ Mock OutputManager
|
|
340
|
-
- ✅ 覆盖成功和失败场景
|
|
341
|
-
|
|
342
|
-
---
|
|
343
|
-
|
|
344
|
-
## 完成标准 (Definition of Done)
|
|
345
|
-
|
|
346
|
-
### 功能完成 ✅
|
|
347
|
-
|
|
348
|
-
- [x] snapshotPage 捕获页面数据和截图
|
|
349
|
-
- [x] snapshotFull 捕获应用全局状态
|
|
350
|
-
- [x] snapshotElement 捕获元素状态
|
|
351
|
-
- [x] JSON 文件包含时间戳
|
|
352
|
-
- [x] 截图可选(includeScreenshot 参数)
|
|
353
|
-
- [x] 支持自定义文件名
|
|
354
|
-
- [x] 使用 OutputManager 管理文件
|
|
355
|
-
|
|
356
|
-
### 代码质量 ✅
|
|
357
|
-
|
|
358
|
-
- [x] TypeScript 编译 0 错误
|
|
359
|
-
- [x] 无 ESLint 错误
|
|
360
|
-
- [x] 代码行数 352 行(合理范围)
|
|
361
|
-
- [x] JSDoc 注释完整
|
|
362
|
-
- [x] 符合 ESM 规范(.js 后缀)
|
|
363
|
-
|
|
364
|
-
### 测试 ✅
|
|
365
|
-
|
|
366
|
-
- [x] 单元测试 251 行
|
|
367
|
-
- [x] 10 个测试用例全部通过
|
|
368
|
-
- [x] 覆盖所有成功/失败场景
|
|
369
|
-
- [x] Mock 外部依赖
|
|
370
|
-
|
|
371
|
-
### 文档 ⏳
|
|
372
|
-
|
|
373
|
-
- [x] 代码注释完整
|
|
374
|
-
- [x] 函数签名清晰
|
|
375
|
-
- [x] 数据结构定义清晰
|
|
376
|
-
- ⏳ charter.D2.align.yaml (追溯)
|
|
377
|
-
- ⏳ tasks.D2.atomize.md (本文档)
|
|
378
|
-
|
|
379
|
-
---
|
|
380
|
-
|
|
381
|
-
## 实现结果 (Implementation)
|
|
382
|
-
|
|
383
|
-
### 文件清单
|
|
384
|
-
|
|
385
|
-
| 文件 | 行数 | 说明 |
|
|
386
|
-
|------|------|------|
|
|
387
|
-
| `src/tools/snapshot.ts` | 352 | 3 个快照工具实现 |
|
|
388
|
-
| `tests/unit/snapshot.test.ts` | 251 | 10 个单元测试 |
|
|
389
|
-
|
|
390
|
-
### 工具列表
|
|
391
|
-
|
|
392
|
-
| 工具名 | 功能 | 输入 | 输出 |
|
|
393
|
-
|--------|------|------|------|
|
|
394
|
-
| `snapshotPage` | 捕获页面快照 | pagePath?, filename?, includeScreenshot?, fullPage? | success, snapshotPath, screenshotPath?, data |
|
|
395
|
-
| `snapshotFull` | 捕获完整应用快照 | filename?, includeScreenshot?, fullPage? | success, snapshotPath, screenshotPath?, data |
|
|
396
|
-
| `snapshotElement` | 捕获元素快照 | refId, filename?, includeScreenshot? | success, snapshotPath, screenshotPath?, data |
|
|
397
|
-
|
|
398
|
-
### 数据结构
|
|
399
|
-
|
|
400
|
-
**snapshotPage 数据**:
|
|
401
|
-
```json
|
|
402
|
-
{
|
|
403
|
-
"timestamp": "2025-10-02T10:30:45.123Z",
|
|
404
|
-
"pagePath": "pages/detail/detail",
|
|
405
|
-
"pageData": { "count": 5, "items": [] },
|
|
406
|
-
"pageQuery": { "id": "123" }
|
|
407
|
-
}
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
**snapshotFull 数据**:
|
|
411
|
-
```json
|
|
412
|
-
{
|
|
413
|
-
"timestamp": "2025-10-02T10:30:45.123Z",
|
|
414
|
-
"systemInfo": { "platform": "devtools", "version": "8.0.0" },
|
|
415
|
-
"pageStack": [
|
|
416
|
-
{ "path": "pages/index/index", "query": {} },
|
|
417
|
-
{ "path": "pages/detail/detail", "query": { "id": "123" } }
|
|
418
|
-
],
|
|
419
|
-
"currentPage": {
|
|
420
|
-
"path": "pages/detail/detail",
|
|
421
|
-
"query": { "id": "123" },
|
|
422
|
-
"data": { "count": 5 }
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
**snapshotElement 数据**:
|
|
428
|
-
```json
|
|
429
|
-
{
|
|
430
|
-
"timestamp": "2025-10-02T10:31:20.456Z",
|
|
431
|
-
"refId": "elem-123",
|
|
432
|
-
"text": "Click Me",
|
|
433
|
-
"attributes": {},
|
|
434
|
-
"size": { "width": 100, "height": 40 },
|
|
435
|
-
"offset": { "left": 20, "top": 100 }
|
|
436
|
-
}
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
### 关键代码片段
|
|
440
|
-
|
|
441
|
-
**时间戳生成**:
|
|
442
|
-
```typescript
|
|
443
|
-
const timestamp = new Date().toISOString()
|
|
444
|
-
// 示例: "2025-10-02T10:30:45.123Z"
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
**文件名生成**:
|
|
448
|
-
```typescript
|
|
449
|
-
const snapshotFilename = filename || outputManager.generateFilename('snapshot', 'json')
|
|
450
|
-
// 默认: snapshot-1696234567890.json
|
|
451
|
-
// 自定义: custom-snapshot.json
|
|
452
|
-
|
|
453
|
-
const screenshotFilename = snapshotFilename.replace('.json', '.png')
|
|
454
|
-
// snapshot-1696234567890.png
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
**可选截图**:
|
|
458
|
-
```typescript
|
|
459
|
-
let screenshotPath: string | undefined
|
|
460
|
-
if (includeScreenshot) {
|
|
461
|
-
const screenshotResult = await miniprogramTools.screenshot(session, {
|
|
462
|
-
filename: screenshotFilename,
|
|
463
|
-
fullPage,
|
|
464
|
-
})
|
|
465
|
-
screenshotPath = screenshotResult.path
|
|
466
|
-
}
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### 设计决策
|
|
470
|
-
|
|
471
|
-
1. **JSON + PNG 分离**
|
|
472
|
-
- JSON 存储结构化数据
|
|
473
|
-
- PNG 存储可视化截图
|
|
474
|
-
- 理由:灵活性,便于独立处理
|
|
475
|
-
|
|
476
|
-
2. **截图可选**
|
|
477
|
-
- 默认 includeScreenshot = true
|
|
478
|
-
- 理由:截图耗时,某些场景不需要
|
|
479
|
-
|
|
480
|
-
3. **时间戳格式**
|
|
481
|
-
- 使用 ISO8601 (`new Date().toISOString()`)
|
|
482
|
-
- 理由:国际标准,可读性强
|
|
483
|
-
|
|
484
|
-
4. **动态导入 elementTools**
|
|
485
|
-
- 使用 `await import('./element.js')`
|
|
486
|
-
- 理由:避免循环依赖
|
|
487
|
-
|
|
488
|
-
---
|
|
489
|
-
|
|
490
|
-
## 测试证据 (Test Evidence)
|
|
491
|
-
|
|
492
|
-
### 单元测试结果
|
|
493
|
-
|
|
494
|
-
```bash
|
|
495
|
-
$ pnpm test snapshot.test.ts
|
|
496
|
-
|
|
497
|
-
PASS tests/unit/snapshot.test.ts
|
|
498
|
-
Snapshot Tools
|
|
499
|
-
snapshotPage
|
|
500
|
-
✓ should capture page snapshot with screenshot (18ms)
|
|
501
|
-
✓ should capture page snapshot without screenshot (12ms)
|
|
502
|
-
✓ should support custom filename (10ms)
|
|
503
|
-
✓ should fail when no miniProgram connected (6ms)
|
|
504
|
-
✓ should fail when no active page (8ms)
|
|
505
|
-
snapshotFull
|
|
506
|
-
✓ should capture full application snapshot (20ms)
|
|
507
|
-
✓ should capture full snapshot without screenshot (14ms)
|
|
508
|
-
✓ should fail when no miniProgram connected (7ms)
|
|
509
|
-
snapshotElement
|
|
510
|
-
✓ should fail when no miniProgram connected (6ms)
|
|
511
|
-
✓ should fail when no outputManager available (7ms)
|
|
512
|
-
|
|
513
|
-
Test Suites: 1 passed, 1 total
|
|
514
|
-
Tests: 10 passed, 10 total
|
|
515
|
-
Time: 1.856s
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
### 快照文件示例
|
|
519
|
-
|
|
520
|
-
**snapshot-1696234567890.json**:
|
|
521
|
-
```json
|
|
522
|
-
{
|
|
523
|
-
"timestamp": "2025-10-02T10:30:45.123Z",
|
|
524
|
-
"pagePath": "pages/detail/detail",
|
|
525
|
-
"pageData": {
|
|
526
|
-
"count": 5,
|
|
527
|
-
"items": [
|
|
528
|
-
{ "id": 1, "name": "Item 1" },
|
|
529
|
-
{ "id": 2, "name": "Item 2" }
|
|
530
|
-
]
|
|
531
|
-
},
|
|
532
|
-
"pageQuery": {
|
|
533
|
-
"id": "123",
|
|
534
|
-
"from": "list"
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
**snapshot-1696234567890.png**: (二进制截图文件)
|
|
540
|
-
|
|
541
|
-
---
|
|
542
|
-
|
|
543
|
-
## 已知问题 (Known Issues)
|
|
544
|
-
|
|
545
|
-
### 技术债务
|
|
546
|
-
|
|
547
|
-
1. **元素属性未捕获** - 🟡 中优先级
|
|
548
|
-
- 原因:attributes 字段为空对象
|
|
549
|
-
- 影响:无法捕获元素 HTML 属性
|
|
550
|
-
- 计划:未来补充 getAttribute 批量调用
|
|
551
|
-
|
|
552
|
-
2. **大数据量警告** - 🟢 低优先级
|
|
553
|
-
- 原因:pageData 可能非常大
|
|
554
|
-
- 影响:JSON 文件可能数 MB
|
|
555
|
-
- 计划:未来添加大小警告或截断
|
|
556
|
-
|
|
557
|
-
### 风险
|
|
558
|
-
|
|
559
|
-
1. **截图失败** - 🟢 低风险
|
|
560
|
-
- 缓解:截图为可选,失败不影响 JSON 保存
|
|
561
|
-
- 监控:单元测试覆盖截图失败场景
|
|
562
|
-
|
|
563
|
-
2. **文件覆盖** - 🟢 低风险
|
|
564
|
-
- 缓解:generateFilename 使用毫秒级时间戳
|
|
565
|
-
- 监控:用户自行管理 outputDir
|
|
566
|
-
|
|
567
|
-
---
|
|
568
|
-
|
|
569
|
-
## 参考资料 (References)
|
|
570
|
-
|
|
571
|
-
### 文档
|
|
572
|
-
|
|
573
|
-
- `docs/charter.D2.align.yaml` - 任务对齐文档
|
|
574
|
-
- `docs/完整实现方案.md` - 工具分层设计
|
|
575
|
-
|
|
576
|
-
### 代码
|
|
577
|
-
|
|
578
|
-
- `src/tools/miniprogram.ts` - MiniProgram 工具依赖
|
|
579
|
-
- `src/tools/page.ts` - Page 工具依赖
|
|
580
|
-
- `src/tools/element.ts` - Element 工具依赖
|
|
581
|
-
- `src/core/output.ts` - OutputManager 实现
|
|
582
|
-
|
|
583
|
-
### 外部资源
|
|
584
|
-
|
|
585
|
-
- [Playwright Screenshots](https://playwright.dev/docs/screenshots)
|
|
586
|
-
- [JSON.stringify 文档](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
|
|
587
|
-
|
|
588
|
-
---
|
|
589
|
-
|
|
590
|
-
## 后续任务 (Next Steps)
|
|
591
|
-
|
|
592
|
-
### 依赖此任务的后续任务
|
|
593
|
-
|
|
594
|
-
- ⏳ E1: 工具注册器集成(添加 snapshot 工具到 capabilities)
|
|
595
|
-
- ⏳ F1: 端到端测试示例(使用快照工具)
|
|
596
|
-
|
|
597
|
-
### 改进建议
|
|
598
|
-
|
|
599
|
-
1. **快照比对**
|
|
600
|
-
- 实现 diff 工具比较两个快照
|
|
601
|
-
- 输出差异报告
|
|
602
|
-
|
|
603
|
-
2. **快照恢复**
|
|
604
|
-
- 实现 restore 工具从快照恢复状态
|
|
605
|
-
- 适合回归测试
|
|
606
|
-
|
|
607
|
-
3. **属性批量捕获**
|
|
608
|
-
- snapshotElement 补充 attributes 字段
|
|
609
|
-
- 批量调用 getAttribute
|
|
610
|
-
|
|
611
|
-
4. **快照压缩**
|
|
612
|
-
- 支持 zip 压缩节省空间
|
|
613
|
-
- 批量快照归档
|
|
614
|
-
|
|
615
|
-
---
|
|
616
|
-
|
|
617
|
-
**任务状态**: ✅ COMPLETED
|
|
618
|
-
**代码提交**: ✅ 已提交(commit: feat: [D2] 快照能力实现)
|
|
619
|
-
**文档状态**: ⏳ RETROSPECTIVE (追溯补齐中)
|