@web-auto/webauto 0.1.1 → 0.1.3
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/apps/desktop-console/default-settings.json +1 -0
- package/apps/desktop-console/dist/main/index.mjs +1618 -0
- package/apps/desktop-console/{src → dist}/main/preload.mjs +10 -0
- package/apps/desktop-console/dist/renderer/index.js +3063 -0
- package/apps/desktop-console/entry/ui-console.mjs +299 -0
- package/apps/webauto/entry/account.mjs +356 -0
- package/apps/webauto/entry/lib/account-detect.mjs +160 -0
- package/apps/webauto/entry/lib/account-store.mjs +587 -0
- package/apps/webauto/entry/lib/profilepool.mjs +1 -1
- package/apps/webauto/entry/xhs-install.mjs +27 -3
- package/apps/webauto/entry/xhs-status.mjs +152 -0
- package/apps/webauto/entry/xhs-unified.mjs +595 -17
- package/bin/webauto.mjs +263 -15
- package/dist/apps/webauto/server.js +66 -0
- package/dist/modules/camo-backend/src/index.js +575 -0
- package/dist/modules/camo-backend/src/internal/BrowserSession.js +817 -0
- package/dist/modules/camo-backend/src/internal/ElementRegistry.js +61 -0
- package/dist/modules/camo-backend/src/internal/ProfileLock.js +85 -0
- package/dist/modules/camo-backend/src/internal/SessionManager.js +172 -0
- package/dist/modules/camo-backend/src/internal/container-matcher.js +852 -0
- package/dist/modules/camo-backend/src/internal/engine-manager.js +258 -0
- package/dist/modules/camo-backend/src/internal/fingerprint.js +203 -0
- package/dist/modules/camo-backend/src/internal/pageRuntime.js +29 -0
- package/dist/modules/camo-backend/src/internal/runtimeInjector.js +30 -0
- package/dist/modules/camo-backend/src/internal/state-bus.js +46 -0
- package/dist/modules/camo-backend/src/internal/storage-paths.js +36 -0
- package/dist/modules/camo-backend/src/internal/ws-server.js +1202 -0
- package/dist/modules/camo-runtime/src/utils/browser-service.mjs +423 -0
- package/dist/modules/camo-runtime/src/utils/config.mjs +77 -0
- package/dist/modules/container-registry/src/index.js +184 -0
- package/dist/modules/logging/src/index.js +92 -0
- package/dist/modules/operations/src/builtin.js +27 -0
- package/dist/modules/operations/src/container-binding.js +75 -0
- package/dist/modules/operations/src/executor.js +146 -0
- package/dist/modules/operations/src/operations/click.js +167 -0
- package/dist/modules/operations/src/operations/extract.js +204 -0
- package/dist/modules/operations/src/operations/find-child.js +17 -0
- package/dist/modules/operations/src/operations/highlight.js +138 -0
- package/dist/modules/operations/src/operations/key.js +61 -0
- package/dist/modules/operations/src/operations/navigate.js +148 -0
- package/dist/modules/operations/src/operations/scroll.js +126 -0
- package/dist/modules/operations/src/operations/type.js +190 -0
- package/dist/modules/operations/src/queue.js +100 -0
- package/dist/modules/operations/src/registry.js +11 -0
- package/dist/modules/operations/src/system/mouse.js +33 -0
- package/dist/modules/state/src/atomic-json.js +33 -0
- package/dist/modules/workflow/blocks/AnchorVerificationBlock.js +71 -0
- package/dist/modules/workflow/blocks/BehaviorRandomizer.js +26 -0
- package/dist/modules/workflow/blocks/CallWorkflowBlock.js +38 -0
- package/dist/modules/workflow/blocks/CloseDetailBlock.js +209 -0
- package/dist/modules/workflow/blocks/CollectBatch.js +137 -0
- package/dist/modules/workflow/blocks/CollectCommentsBlock.js +415 -0
- package/dist/modules/workflow/blocks/CollectSearchListBlock.js +599 -0
- package/dist/modules/workflow/blocks/CollectWeiboPosts.js +229 -0
- package/dist/modules/workflow/blocks/DetectPageStateBlock.js +259 -0
- package/dist/modules/workflow/blocks/EnsureLoginBlock.js +162 -0
- package/dist/modules/workflow/blocks/EnsureSession.js +426 -0
- package/dist/modules/workflow/blocks/ErrorClassifier.js +164 -0
- package/dist/modules/workflow/blocks/ErrorRecoveryBlock.js +319 -0
- package/dist/modules/workflow/blocks/ExpandCommentsBlock.js +1032 -0
- package/dist/modules/workflow/blocks/ExtractDetailBlock.js +310 -0
- package/dist/modules/workflow/blocks/ExtractPostFields.js +88 -0
- package/dist/modules/workflow/blocks/GenerateSmartReplyBlock.js +68 -0
- package/dist/modules/workflow/blocks/GoToSearchBlock.js +497 -0
- package/dist/modules/workflow/blocks/GracefulFallbackBlock.js +104 -0
- package/dist/modules/workflow/blocks/HighlightBlock.js +66 -0
- package/dist/modules/workflow/blocks/InitAutoScroll.js +65 -0
- package/dist/modules/workflow/blocks/LoadContainerDefinition.js +50 -0
- package/dist/modules/workflow/blocks/LoadContainerIndex.js +43 -0
- package/dist/modules/workflow/blocks/LocateAndGuardBlock.js +176 -0
- package/dist/modules/workflow/blocks/LoginRecoveryBlock.js +242 -0
- package/dist/modules/workflow/blocks/MatchContainers.js +64 -0
- package/dist/modules/workflow/blocks/MonitoringBlock.js +190 -0
- package/dist/modules/workflow/blocks/OpenDetailBlock.js +1240 -0
- package/dist/modules/workflow/blocks/OrganizeXhsNotesBlock.js +117 -0
- package/dist/modules/workflow/blocks/PersistXhsNoteBlock.js +270 -0
- package/dist/modules/workflow/blocks/PickSinglePost.js +69 -0
- package/dist/modules/workflow/blocks/ProgressTracker.js +125 -0
- package/dist/modules/workflow/blocks/RecordFixtureBlock.js +44 -0
- package/dist/modules/workflow/blocks/RenderMarkdown.js +48 -0
- package/dist/modules/workflow/blocks/SaveFile.js +54 -0
- package/dist/modules/workflow/blocks/ScrollNextBatch.js +72 -0
- package/dist/modules/workflow/blocks/SessionHealthBlock.js +73 -0
- package/dist/modules/workflow/blocks/StartBrowserService.js +45 -0
- package/dist/modules/workflow/blocks/ValidateContainerDefinition.js +67 -0
- package/dist/modules/workflow/blocks/ValidateExtract.js +35 -0
- package/dist/modules/workflow/blocks/WaitSearchPermitBlock.js +162 -0
- package/dist/modules/workflow/blocks/WaitStable.js +74 -0
- package/dist/modules/workflow/blocks/WarmupCommentsBlock.js +120 -0
- package/dist/modules/workflow/blocks/WorkflowExecutor.js +156 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectFromLinksBlock.js +1004 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectLinksBlock.js +1049 -0
- package/dist/modules/workflow/blocks/XiaohongshuFullCollectBlock.js +782 -0
- package/dist/modules/workflow/blocks/helpers/anchorVerify.js +198 -0
- package/dist/modules/workflow/blocks/helpers/asyncWorkQueue.js +53 -0
- package/dist/modules/workflow/blocks/helpers/commentScroller.js +334 -0
- package/dist/modules/workflow/blocks/helpers/commentSectionLocator.js +126 -0
- package/dist/modules/workflow/blocks/helpers/containerAnchors.js +301 -0
- package/dist/modules/workflow/blocks/helpers/debugArtifacts.js +6 -0
- package/dist/modules/workflow/blocks/helpers/downloadPaths.js +29 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsController.js +53 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsExtractor.js +129 -0
- package/dist/modules/workflow/blocks/helpers/macosVisionOcrPlugin.js +116 -0
- package/dist/modules/workflow/blocks/helpers/mergeXhsMarkdown.js +109 -0
- package/dist/modules/workflow/blocks/helpers/openDetailController.js +56 -0
- package/dist/modules/workflow/blocks/helpers/openDetailTypes.js +7 -0
- package/dist/modules/workflow/blocks/helpers/openDetailViewport.js +474 -0
- package/dist/modules/workflow/blocks/helpers/openDetailWaiter.js +104 -0
- package/dist/modules/workflow/blocks/helpers/operationLogger.js +195 -0
- package/dist/modules/workflow/blocks/helpers/persistedNotes.js +107 -0
- package/dist/modules/workflow/blocks/helpers/replyExpander.js +260 -0
- package/dist/modules/workflow/blocks/helpers/scrollIntoView.js +138 -0
- package/dist/modules/workflow/blocks/helpers/searchExecutor.js +328 -0
- package/dist/modules/workflow/blocks/helpers/searchGate.js +46 -0
- package/dist/modules/workflow/blocks/helpers/searchPageState.js +164 -0
- package/dist/modules/workflow/blocks/helpers/searchResultWaiter.js +64 -0
- package/dist/modules/workflow/blocks/helpers/simpleAnchor.js +134 -0
- package/dist/modules/workflow/blocks/helpers/smartReply.js +40 -0
- package/dist/modules/workflow/blocks/helpers/systemInput.js +635 -0
- package/dist/modules/workflow/blocks/helpers/targetCountMode.js +9 -0
- package/dist/modules/workflow/blocks/helpers/xhsCliArgs.js +80 -0
- package/dist/modules/workflow/blocks/helpers/xhsCommentDom.js +805 -0
- package/dist/modules/workflow/blocks/helpers/xhsNoteOrganizer.js +140 -0
- package/dist/modules/workflow/blocks/restore/RestorePhaseBlock.js +204 -0
- package/dist/modules/workflow/config/workflowRegistry.js +32 -0
- package/dist/modules/workflow/definitions/batch-collect-workflow.js +63 -0
- package/dist/modules/workflow/definitions/scroll-extract-workflow.js +74 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow-v2.js +81 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow.js +57 -0
- package/dist/modules/workflow/definitions/xiaohongshu-full-collect-workflow-v3.js +68 -0
- package/dist/modules/workflow/definitions/xiaohongshu-note-collect.js +49 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase1-workflow-v3.js +30 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase2-links-workflow-v3.js +40 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase3-collect-workflow-v1.js +54 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase34-from-links-workflow-v3.js +25 -0
- package/dist/modules/workflow/src/WeiboEventDrivenWorkflowRunner.js +308 -0
- package/dist/modules/workflow/src/context.js +70 -0
- package/dist/modules/workflow/src/index.js +5 -0
- package/dist/modules/workflow/src/orchestrator.js +230 -0
- package/dist/modules/workflow/src/runner.js +55 -0
- package/dist/modules/workflow/src/runtime.js +70 -0
- package/dist/modules/workflow/workflows/WeiboFeedExtractionWorkflow.js +359 -0
- package/dist/modules/workflow/workflows/XiaohongshuLoginWorkflow.js +110 -0
- package/dist/modules/xiaohongshu/app/src/blocks/MatchCommentsBlock.js +139 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1EnsureServicesBlock.js +36 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1MonitorCookieBlock.js +213 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1StartProfileBlock.js +121 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2CollectLinksBlock.js +1249 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2SearchBlock.js +703 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseDetailBlock.js +41 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseTabsBlock.js +44 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CollectCommentsBlock.js +150 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ExtractDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenDetailBlock.js +102 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenTabsBlock.js +109 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34PersistDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ProcessSingleNoteBlock.js +114 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ValidateLinksBlock.js +90 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase3InteractBlock.js +1009 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase4MultiTabHarvestBlock.js +233 -0
- package/dist/modules/xiaohongshu/app/src/blocks/ReplyInteractBlock.js +291 -0
- package/dist/modules/xiaohongshu/app/src/blocks/XhsDiscoverFallbackBlock.js +240 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatchDsl.js +126 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatcher.js +99 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/evidence.js +27 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/sharding.js +42 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/xhsComments.js +270 -0
- package/dist/modules/xiaohongshu/app/src/index.js +9 -0
- package/dist/modules/xiaohongshu/app/src/utils/checkpoints.js +222 -0
- package/dist/modules/xiaohongshu/app/src/utils/controllerAction.js +43 -0
- package/dist/services/controller/src/controller.js +1476 -0
- package/dist/services/controller/src/index.js +2 -0
- package/dist/services/controller/src/payload-normalizer.js +129 -0
- package/dist/services/shared/heartbeat.js +120 -0
- package/dist/services/shared/lib/errorHandler.js +2 -0
- package/dist/services/shared/serviceProcessLogger.js +139 -0
- package/dist/services/unified-api/RemoteBrowserSession.js +176 -0
- package/dist/services/unified-api/RemoteSessionManager.js +148 -0
- package/dist/services/unified-api/container-operations-handler.js +115 -0
- package/dist/services/unified-api/server.js +652 -0
- package/dist/services/unified-api/state-registry.js +274 -0
- package/dist/services/unified-api/task-persistence.js +66 -0
- package/dist/services/unified-api/task-state.js +130 -0
- package/modules/camo-runtime/src/autoscript/action-providers/xhs/search.mjs +12 -5
- package/modules/xiaohongshu/app/pnpm-lock.yaml +24 -0
- package/package.json +38 -10
- package/.beads/README.md +0 -81
- package/.beads/config.yaml +0 -67
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +0 -180
- package/.beads/metadata.json +0 -4
- package/.claude/settings.local.json +0 -10
- package/.github/workflows/ci.yml +0 -55
- package/AGENTS.md +0 -253
- package/apps/desktop-console/README.md +0 -27
- package/apps/desktop-console/package-lock.json +0 -897
- package/apps/desktop-console/package.json +0 -20
- package/apps/desktop-console/scripts/build-and-install.mjs +0 -19
- package/apps/desktop-console/scripts/build.mjs +0 -45
- package/apps/desktop-console/scripts/test-preload.mjs +0 -13
- package/apps/desktop-console/src/main/config.mts +0 -26
- package/apps/desktop-console/src/main/core-daemon-manager.mts +0 -131
- package/apps/desktop-console/src/main/desktop-settings.mts +0 -267
- package/apps/desktop-console/src/main/heartbeat-watchdog.mts +0 -50
- package/apps/desktop-console/src/main/heartbeat-watchdog.test.mts +0 -68
- package/apps/desktop-console/src/main/index-streaming.test.mts +0 -20
- package/apps/desktop-console/src/main/index.mts +0 -980
- package/apps/desktop-console/src/main/profile-store.mts +0 -239
- package/apps/desktop-console/src/main/profile-store.test.mts +0 -54
- package/apps/desktop-console/src/main/state-bridge.mts +0 -114
- package/apps/desktop-console/src/main/task-state-types.ts +0 -32
- package/apps/desktop-console/src/renderer/hooks/use-task-state.mts +0 -120
- package/apps/desktop-console/src/renderer/index.mts +0 -133
- package/apps/desktop-console/src/renderer/index.test.mts +0 -34
- package/apps/desktop-console/src/renderer/path-helpers.mts +0 -46
- package/apps/desktop-console/src/renderer/path-helpers.test.mts +0 -14
- package/apps/desktop-console/src/renderer/tabs/debug.mts +0 -48
- package/apps/desktop-console/src/renderer/tabs/debug.test.mts +0 -22
- package/apps/desktop-console/src/renderer/tabs/logs.mts +0 -421
- package/apps/desktop-console/src/renderer/tabs/logs.test.mts +0 -27
- package/apps/desktop-console/src/renderer/tabs/preflight.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/preflight.test.mts +0 -33
- package/apps/desktop-console/src/renderer/tabs/profile-pool.mts +0 -213
- package/apps/desktop-console/src/renderer/tabs/results.mts +0 -171
- package/apps/desktop-console/src/renderer/tabs/run.test.mts +0 -63
- package/apps/desktop-console/src/renderer/tabs/runtime.mts +0 -151
- package/apps/desktop-console/src/renderer/tabs/settings.mts +0 -146
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/account-flow.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/guide-browser-check.mts +0 -56
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/helpers.mts +0 -262
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/layout-block.mts +0 -430
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/live-stats.mts +0 -847
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/run-flow.mts +0 -443
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu-state.mts +0 -425
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.mts +0 -497
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.test.mts +0 -291
- package/apps/desktop-console/src/renderer/ui-components.mts +0 -31
- package/docs/README_camoufox_chinese.md +0 -141
- package/docs/USAGE_V3.md +0 -163
- package/docs/arch/OCR_MACOS_PLUGIN.md +0 -39
- package/docs/arch/PORTS.md +0 -40
- package/docs/arch/REGRESSION_CHECKLIST.md +0 -121
- package/docs/arch/SEARCH_GATE.md +0 -224
- package/docs/arch/VIEWPORT_SAFETY.md +0 -182
- package/docs/arch/XIAOHONGSHU_OFFLINE_MOCK_DESIGN.md +0 -267
- package/docs/xiaohongshu-container-driven-summary.md +0 -221
- package/docs/xiaohongshu-full-collect-runbook.md +0 -134
- package/docs/xiaohongshu-next-steps.md +0 -228
- package/docs/xiaohongshu-quickstart.md +0 -73
- package/docs/xiaohongshu-workflow-summary.md +0 -227
- package/modules/container-registry/tests/container-registry.test.ts +0 -16
- package/modules/logging/tests/logging.test.ts +0 -38
- package/modules/operations/tests/operations.test.ts +0 -22
- package/modules/operations/tests/viewport-filter.test.ts +0 -161
- package/modules/operations/tests/visible-only.test.ts +0 -250
- package/modules/session-manager/tests/session-manager.test.ts +0 -23
- package/modules/state/src/atomic-json.test.ts +0 -30
- package/modules/state/src/paths.test.ts +0 -59
- package/modules/state/src/xiaohongshu-collect-state.test.ts +0 -259
- package/modules/workflow/blocks/AnchorVerificationBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/AnchorVerificationBlock.js.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.js.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.js.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.js.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.js.map +0 -1
- package/modules/workflow/blocks/helpers/downloadPaths.test.ts +0 -62
- package/modules/workflow/blocks/helpers/mergeXhsMarkdown.test.ts +0 -121
- package/modules/workflow/blocks/helpers/operationLogger.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/operationLogger.js.map +0 -1
- package/modules/workflow/blocks/helpers/persistedNotes.test.ts +0 -268
- package/modules/workflow/blocks/helpers/searchPageState.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/searchPageState.js.map +0 -1
- package/modules/workflow/blocks/helpers/targetCountMode.test.ts +0 -29
- package/modules/workflow/blocks/helpers/xhsCliArgs.test.ts +0 -75
- package/modules/workflow/tests/smartReply.test.ts +0 -32
- package/modules/xiaohongshu/app/src/blocks/Phase3Interact.matcher.test.ts +0 -33
- package/modules/xiaohongshu/app/src/utils/__tests__/checkpoints.test.ts +0 -141
- package/modules/xiaohongshu/app/tests/commentMatchDsl.test.ts +0 -50
- package/modules/xiaohongshu/app/tests/commentMatcher.test.ts +0 -46
- package/modules/xiaohongshu/app/tests/sharding.test.ts +0 -31
- package/package-scripts.json +0 -8
- package/runtime/infra/utils/README.md +0 -13
- package/runtime/infra/utils/scripts/README.md +0 -0
- package/runtime/infra/utils/scripts/development/eval-in-session.mjs +0 -40
- package/runtime/infra/utils/scripts/development/highlight-search-containers.mjs +0 -35
- package/runtime/infra/utils/scripts/service/kill-port.mjs +0 -24
- package/runtime/infra/utils/scripts/service/start-api.mjs +0 -39
- package/runtime/infra/utils/scripts/service/start-browser-service.mjs +0 -106
- package/runtime/infra/utils/scripts/service/stop-api.mjs +0 -18
- package/runtime/infra/utils/scripts/service/stop-browser-service.mjs +0 -104
- package/runtime/infra/utils/scripts/test-services.mjs +0 -94
- package/services/shared/heartbeat.test.ts +0 -102
- package/services/unified-api/__tests__/task-state.test.ts +0 -95
- package/sitecustomize.py +0 -19
- package/tests/README.md +0 -194
- package/tests/e2e/workflows/weibo-feed-extraction.test.ts +0 -171
- package/tests/fixtures/data/container-definitions.json +0 -67
- package/tests/fixtures/pages/simple-page.html +0 -69
- package/tests/integration/01-test-container-match.mjs +0 -188
- package/tests/integration/02-test-dom-branch.mjs +0 -161
- package/tests/integration/03-test-container-operation-system.mjs +0 -91
- package/tests/integration/05-test-container-lifecycle-events.mjs +0 -224
- package/tests/integration/05-test-container-lifecycle-with-events.mjs +0 -250
- package/tests/integration/06-test-container-dom-tree-drawing.mjs +0 -256
- package/tests/integration/07-test-weibo-container-lifecycle.mjs +0 -355
- package/tests/integration/08-test-weibo-feed-workflow.test.mjs +0 -164
- package/tests/integration/10-test-visual-analyzer.mjs +0 -312
- package/tests/integration/11-test-visual-loop.mjs +0 -284
- package/tests/integration/12-test-simple-visual-loop.mjs +0 -242
- package/tests/integration/13-test-visual-robust.mjs +0 -185
- package/tests/integration/14-test-visual-highlight-loop.mjs +0 -271
- package/tests/integration/inspect-page.mjs +0 -50
- package/tests/integration/run-all-tests.mjs +0 -95
- package/tests/patch_verification/CODEX_PATCH_TEST.md +0 -103
- package/tests/patch_verification/PHASE2_ANALYSIS.md +0 -179
- package/tests/patch_verification/PHASE2_OPTIMIZATION_REPORT.md +0 -55
- package/tests/patch_verification/PHASE2_TO_PHASE4_SUMMARY.md +0 -126
- package/tests/patch_verification/QUICK_TEST_SEQUENCE.md +0 -262
- package/tests/patch_verification/README.md +0 -143
- package/tests/patch_verification/RUN_TESTS.md +0 -60
- package/tests/patch_verification/TEST_EXECUTION.md +0 -99
- package/tests/patch_verification/TEST_PLAN.md +0 -328
- package/tests/patch_verification/TEST_RESULTS.md +0 -34
- package/tests/patch_verification/TOOL_TEST_PLAN.md +0 -48
- package/tests/patch_verification/run-tool-test.mjs +0 -121
- package/tests/patch_verification/temp_test_files/test01.txt +0 -1
- package/tests/patch_verification/temp_test_files/test02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test02_gnu.txt +0 -3
- package/tests/patch_verification/temp_test_files/test03.txt +0 -1
- package/tests/patch_verification/temp_test_files/test03_multiline.txt +0 -5
- package/tests/patch_verification/temp_test_files/test04_function.ts +0 -5
- package/tests/patch_verification/temp_test_files/test05_import.ts +0 -4
- package/tests/patch_verification/temp_test_files/test06_special_chars.txt +0 -4
- package/tests/patch_verification/temp_test_files/test07_indentation.ts +0 -5
- package/tests/patch_verification/temp_test_files/test08_mismatch.txt +0 -1
- package/tests/patch_verification/temp_test_files/test_add_02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test_simple.txt +0 -1
- package/tests/runner/TestReporter.mjs +0 -57
- package/tests/runner/TestRunner.mjs +0 -244
- package/tests/unit/commands/profile.test.mjs +0 -10
- package/tests/unit/container/change-notifier.test.mjs +0 -181
- package/tests/unit/lifecycle/session-registry.test.mjs +0 -135
- package/tests/unit/operations/registry.test.ts +0 -73
- package/tests/unit/utils/browser-service.test.mjs +0 -153
- package/tests/unit/utils/config.test.mjs +0 -166
- package/tests/unit/utils/fingerprint.test.mjs +0 -166
- package/tsconfig.json +0 -31
- package/tsconfig.services.json +0 -26
- /package/apps/desktop-console/{src → dist}/renderer/index.html +0 -0
- /package/apps/desktop-console/{src/renderer/tabs → dist/renderer}/run.mts +0 -0
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import { promises as fs } from 'node:fs';
|
|
6
|
-
import { countPersistedNotes } from './persistedNotes.js';
|
|
7
|
-
|
|
8
|
-
async function writeNote(keywordDir: string, noteId: string, files: Record<string, string>) {
|
|
9
|
-
const base = path.join(keywordDir, noteId);
|
|
10
|
-
await fs.mkdir(base, { recursive: true });
|
|
11
|
-
await Promise.all(
|
|
12
|
-
Object.entries(files).map(async ([name, content]) => {
|
|
13
|
-
const full = path.join(base, name);
|
|
14
|
-
await fs.mkdir(path.dirname(full), { recursive: true });
|
|
15
|
-
await fs.writeFile(full, content, 'utf-8');
|
|
16
|
-
}),
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
test('countPersistedNotes accepts stoppedByMaxComments as done', async (t) => {
|
|
21
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-'));
|
|
22
|
-
t.after(async () => {
|
|
23
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'limit-case');
|
|
27
|
-
await writeNote(keywordDir, 'note1', {
|
|
28
|
-
'content.md': '# Note 1',
|
|
29
|
-
'comments.md': ['reachedEnd=否', 'stoppedByMaxComments=yes', '评论统计: 抓取=10, header=200'].join('\n'),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const out = await countPersistedNotes({
|
|
33
|
-
platform: 'xiaohongshu',
|
|
34
|
-
env: 'debug',
|
|
35
|
-
keyword: 'limit-case',
|
|
36
|
-
downloadRoot: root,
|
|
37
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
38
|
-
requireCommentsDone: true,
|
|
39
|
-
minCommentsCoverageRatio: 0.9,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
assert.equal(out.count, 1);
|
|
43
|
-
assert.deepEqual(out.noteIds, ['note1']);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('countPersistedNotes accepts comments.done.json marker', async (t) => {
|
|
47
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-done-'));
|
|
48
|
-
t.after(async () => {
|
|
49
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'done-case');
|
|
53
|
-
await writeNote(keywordDir, 'note1', {
|
|
54
|
-
'content.md': '# Note 1',
|
|
55
|
-
'comments.md': ['reachedEnd=鍚?', 'empty=鍚?'].join('\n'),
|
|
56
|
-
'comments.done.json': JSON.stringify({ done: true }),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const out = await countPersistedNotes({
|
|
60
|
-
platform: 'xiaohongshu',
|
|
61
|
-
env: 'debug',
|
|
62
|
-
keyword: 'done-case',
|
|
63
|
-
downloadRoot: root,
|
|
64
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
65
|
-
requireCommentsDone: true,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
assert.equal(out.count, 1);
|
|
69
|
-
assert.deepEqual(out.noteIds, ['note1']);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('countPersistedNotes returns empty when keyword dir missing', async (t) => {
|
|
73
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-missing-'));
|
|
74
|
-
t.after(async () => {
|
|
75
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const out = await countPersistedNotes({
|
|
79
|
-
platform: 'xiaohongshu',
|
|
80
|
-
env: 'debug',
|
|
81
|
-
keyword: 'missing-keyword',
|
|
82
|
-
downloadRoot: root,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
assert.equal(out.count, 0);
|
|
86
|
-
assert.deepEqual(out.noteIds, []);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('countPersistedNotes skips when required file missing', async (t) => {
|
|
90
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-missing-file-'));
|
|
91
|
-
t.after(async () => {
|
|
92
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'missing-file');
|
|
96
|
-
await writeNote(keywordDir, 'note1', {
|
|
97
|
-
'content.md': '# Note 1',
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const out = await countPersistedNotes({
|
|
101
|
-
platform: 'xiaohongshu',
|
|
102
|
-
env: 'debug',
|
|
103
|
-
keyword: 'missing-file',
|
|
104
|
-
downloadRoot: root,
|
|
105
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
106
|
-
requireCommentsDone: true,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
assert.equal(out.count, 0);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test('countPersistedNotes treats unreadable comments as not done', async (t) => {
|
|
113
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-unreadable-'));
|
|
114
|
-
t.after(async () => {
|
|
115
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'unreadable');
|
|
119
|
-
await writeNote(keywordDir, 'note1', {
|
|
120
|
-
'content.md': '# Note 1',
|
|
121
|
-
});
|
|
122
|
-
await fs.mkdir(path.join(keywordDir, 'note1', 'comments.md'), { recursive: true });
|
|
123
|
-
|
|
124
|
-
const out = await countPersistedNotes({
|
|
125
|
-
platform: 'xiaohongshu',
|
|
126
|
-
env: 'debug',
|
|
127
|
-
keyword: 'unreadable',
|
|
128
|
-
downloadRoot: root,
|
|
129
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
130
|
-
requireCommentsDone: true,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
assert.equal(out.count, 0);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test('countPersistedNotes skips comments checks when requireCommentsDone=false', async (t) => {
|
|
137
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-simple-'));
|
|
138
|
-
t.after(async () => {
|
|
139
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'simple-case');
|
|
143
|
-
await writeNote(keywordDir, 'note1', {
|
|
144
|
-
'content.md': '# Note 1',
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const out = await countPersistedNotes({
|
|
148
|
-
platform: 'xiaohongshu',
|
|
149
|
-
env: 'debug',
|
|
150
|
-
keyword: 'simple-case',
|
|
151
|
-
downloadRoot: root,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
assert.equal(out.count, 1);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
test('countPersistedNotes allows unknown header when empty=是', async (t) => {
|
|
158
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-empty-'));
|
|
159
|
-
t.after(async () => {
|
|
160
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'empty-case');
|
|
164
|
-
await writeNote(keywordDir, 'note1', {
|
|
165
|
-
'content.md': '# Note 1',
|
|
166
|
-
'comments.md': ['empty=是', '评论统计: 抓取=1, header=unknown'].join('\n'),
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
const out = await countPersistedNotes({
|
|
170
|
-
platform: 'xiaohongshu',
|
|
171
|
-
env: 'debug',
|
|
172
|
-
keyword: 'empty-case',
|
|
173
|
-
downloadRoot: root,
|
|
174
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
175
|
-
requireCommentsDone: true,
|
|
176
|
-
minCommentsCoverageRatio: 0.9,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
assert.equal(out.count, 1);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test('countPersistedNotes skips coverage when ratio not provided', async (t) => {
|
|
183
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-ratio-'));
|
|
184
|
-
t.after(async () => {
|
|
185
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'ratio-case');
|
|
189
|
-
await writeNote(keywordDir, 'note1', {
|
|
190
|
-
'content.md': '# Note 1',
|
|
191
|
-
'comments.md': ['reachedEnd=是', '评论统计: 抓取=1, header=10'].join('\n'),
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const out = await countPersistedNotes({
|
|
195
|
-
platform: 'xiaohongshu',
|
|
196
|
-
env: 'debug',
|
|
197
|
-
keyword: 'ratio-case',
|
|
198
|
-
downloadRoot: root,
|
|
199
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
200
|
-
requireCommentsDone: true,
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
assert.equal(out.count, 1);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test('countPersistedNotes handles coverage read errors', async (t) => {
|
|
207
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-coverage-err-'));
|
|
208
|
-
t.after(async () => {
|
|
209
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'coverage-err');
|
|
213
|
-
await writeNote(keywordDir, 'note1', {
|
|
214
|
-
'content.md': '# Note 1',
|
|
215
|
-
'comments.md': ['reachedEnd=是', '评论统计: 抓取=9, header=10'].join('\n'),
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
const originalReadFile = fs.readFile.bind(fs);
|
|
219
|
-
let readCount = 0;
|
|
220
|
-
fs.readFile = (async (...args: Parameters<typeof originalReadFile>) => {
|
|
221
|
-
readCount += 1;
|
|
222
|
-
if (readCount >= 2) {
|
|
223
|
-
throw new Error('mock read error');
|
|
224
|
-
}
|
|
225
|
-
return originalReadFile(...args);
|
|
226
|
-
}) as typeof fs.readFile;
|
|
227
|
-
|
|
228
|
-
try {
|
|
229
|
-
const out = await countPersistedNotes({
|
|
230
|
-
platform: 'xiaohongshu',
|
|
231
|
-
env: 'debug',
|
|
232
|
-
keyword: 'coverage-err',
|
|
233
|
-
downloadRoot: root,
|
|
234
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
235
|
-
requireCommentsDone: true,
|
|
236
|
-
minCommentsCoverageRatio: 0.9,
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
assert.equal(out.count, 0);
|
|
240
|
-
} finally {
|
|
241
|
-
fs.readFile = originalReadFile;
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
test('countPersistedNotes enforces coverage when not stoppedByMaxComments', async (t) => {
|
|
246
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-notes-coverage-'));
|
|
247
|
-
t.after(async () => {
|
|
248
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
const keywordDir = path.join(root, 'xiaohongshu', 'debug', 'coverage-case');
|
|
252
|
-
await writeNote(keywordDir, 'note1', {
|
|
253
|
-
'content.md': '# Note 1',
|
|
254
|
-
'comments.md': ['reachedEnd=是', '评论统计: 抓取=5, header=10'].join('\n'),
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
const out = await countPersistedNotes({
|
|
258
|
-
platform: 'xiaohongshu',
|
|
259
|
-
env: 'debug',
|
|
260
|
-
keyword: 'coverage-case',
|
|
261
|
-
downloadRoot: root,
|
|
262
|
-
requiredFiles: ['content.md', 'comments.md'],
|
|
263
|
-
requireCommentsDone: true,
|
|
264
|
-
minCommentsCoverageRatio: 0.9,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
assert.equal(out.count, 0);
|
|
268
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchPageState.d.ts","sourceRoot":"","sources":["searchPageState.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAUD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAuBtE;AAED,wBA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,EAAE,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { resolveTargetCount } from './targetCountMode.js';
|
|
4
|
-
|
|
5
|
-
test('resolveTargetCount uses absolute mode by default', () => {
|
|
6
|
-
const out = resolveTargetCount({ targetCount: 12, baseCount: 5 });
|
|
7
|
-
assert.equal(out.mode, 'absolute');
|
|
8
|
-
assert.equal(out.requested, 12);
|
|
9
|
-
assert.equal(out.targetTotal, 12);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('resolveTargetCount supports incremental mode', () => {
|
|
13
|
-
const out = resolveTargetCount({ targetCount: 12, baseCount: 5, mode: 'incremental' });
|
|
14
|
-
assert.equal(out.mode, 'incremental');
|
|
15
|
-
assert.equal(out.requested, 12);
|
|
16
|
-
assert.equal(out.targetTotal, 17);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('resolveTargetCount normalizes invalid targetCount', () => {
|
|
20
|
-
const out = resolveTargetCount({ targetCount: -3, baseCount: 5, mode: 'incremental' });
|
|
21
|
-
assert.equal(out.requested, 0);
|
|
22
|
-
assert.equal(out.targetTotal, 5);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('resolveTargetCount handles non-finite targetCount', () => {
|
|
26
|
-
const out = resolveTargetCount({ targetCount: Number.NaN, baseCount: 2, mode: 'absolute' });
|
|
27
|
-
assert.equal(out.requested, 0);
|
|
28
|
-
assert.equal(out.targetTotal, 0);
|
|
29
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { parseXhsCliArgs, phaseOrder } from './xhsCliArgs.js';
|
|
4
|
-
|
|
5
|
-
test('parseXhsCliArgs shows help on empty args', () => {
|
|
6
|
-
const out = parseXhsCliArgs([]);
|
|
7
|
-
assert.equal(out.showHelp, true);
|
|
8
|
-
assert.equal(out.showVersion, false);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('parseXhsCliArgs parses keyword and defaults', () => {
|
|
12
|
-
const out = parseXhsCliArgs(['-k', 'phone']);
|
|
13
|
-
assert.equal(out.keyword, 'phone');
|
|
14
|
-
assert.equal(out.targetCount, 100);
|
|
15
|
-
assert.equal(out.maxComments, null);
|
|
16
|
-
assert.equal(out.headless, true);
|
|
17
|
-
assert.equal(out.startAt, 'phase1');
|
|
18
|
-
assert.equal(out.stopAfter, 'phase34');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('parseXhsCliArgs accepts positional keyword', () => {
|
|
22
|
-
const out = parseXhsCliArgs(['case']);
|
|
23
|
-
assert.equal(out.keyword, 'case');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('parseXhsCliArgs supports headful', () => {
|
|
27
|
-
const out = parseXhsCliArgs(['-k', 'demo', '-n', '5', '--headful']);
|
|
28
|
-
assert.equal(out.keyword, 'demo');
|
|
29
|
-
assert.equal(out.targetCount, 5);
|
|
30
|
-
assert.equal(out.headless, false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('parseXhsCliArgs supports dev flag', () => {
|
|
34
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--dev']);
|
|
35
|
-
assert.equal(out.dev, true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('parseXhsCliArgs normalizes -cn alias', () => {
|
|
39
|
-
const out = parseXhsCliArgs(['-k', 'demo', '-cn', '20']);
|
|
40
|
-
assert.equal(out.maxComments, 20);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('parseXhsCliArgs ignores non-positive comment count', () => {
|
|
44
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--commentCount', '0']);
|
|
45
|
-
assert.equal(out.maxComments, null);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('parseXhsCliArgs parses phase flags', () => {
|
|
49
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--startAt', '2', '--stopAfter', 'phase34']);
|
|
50
|
-
assert.equal(out.startAt, 'phase2');
|
|
51
|
-
assert.equal(out.stopAfter, 'phase34');
|
|
52
|
-
assert.ok(phaseOrder(out.startAt) < phaseOrder(out.stopAfter));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('parseXhsCliArgs falls back on invalid phase', () => {
|
|
56
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--startAt', 'oops']);
|
|
57
|
-
assert.equal(out.startAt, 'phase1');
|
|
58
|
-
assert.equal(phaseOrder(null), 999);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('parseXhsCliArgs keeps NaN for invalid count', () => {
|
|
62
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--count', 'oops']);
|
|
63
|
-
assert.ok(Number.isNaN(out.targetCount));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('parseXhsCliArgs uses defaults for empty env and sessionId', () => {
|
|
67
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--env', '', '--sessionId', '']);
|
|
68
|
-
assert.equal(out.env, 'prod');
|
|
69
|
-
assert.equal(out.sessionId, 'xiaohongshu_fresh');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('parseXhsCliArgs ignores non-numeric comment count', () => {
|
|
73
|
-
const out = parseXhsCliArgs(['-k', 'demo', '--commentCount', 'oops']);
|
|
74
|
-
assert.equal(out.maxComments, null);
|
|
75
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
import { buildSmartReplyUserPrompt, sanitizeSmartReply, mockSmartReply } from '../blocks/helpers/smartReply.js';
|
|
5
|
-
import { execute as generate } from '../blocks/GenerateSmartReplyBlock.js';
|
|
6
|
-
|
|
7
|
-
test('buildSmartReplyUserPrompt contains note/comment tags', () => {
|
|
8
|
-
const s = buildSmartReplyUserPrompt({ note: '帖子正文', comment: '当前评论', maxChars: 20 });
|
|
9
|
-
assert.ok(s.includes('<note>帖子正文</note>'));
|
|
10
|
-
assert.ok(s.includes('<comment>当前评论</comment>'));
|
|
11
|
-
assert.ok(s.includes('不超过 20 字'));
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('sanitizeSmartReply trims and enforces max chars', () => {
|
|
15
|
-
const out = sanitizeSmartReply('“回复: 这个真的太好用了哈哈哈哈哈哈哈哈哈哈”', 10);
|
|
16
|
-
assert.equal(Array.from(out).length <= 10, true);
|
|
17
|
-
assert.equal(out.includes('回复'), false);
|
|
18
|
-
assert.equal(out.includes('“'), false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('mockSmartReply returns non-empty <= maxChars', () => {
|
|
22
|
-
const out = mockSmartReply('一些内容', '一些评论', 20);
|
|
23
|
-
assert.ok(out.length > 0);
|
|
24
|
-
assert.equal(Array.from(out).length <= 20, true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('GenerateSmartReplyBlock uses mock in dryRun mode', async () => {
|
|
28
|
-
const res = await generate({ note: 'note', comment: 'comment', dryRun: true, maxChars: 20 });
|
|
29
|
-
assert.equal(res.success, true);
|
|
30
|
-
assert.equal(res.usedMock, true);
|
|
31
|
-
assert.ok(res.reply.length > 0);
|
|
32
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
import { compileLikeRules, matchLikeText } from './Phase3InteractBlock.js';
|
|
5
|
-
|
|
6
|
-
test('compileLikeRules parses plain token and brace syntax', () => {
|
|
7
|
-
const rules = compileLikeRules(['求链接', '{工作服 + 定制}', '{求链接 - 已买}', '{坏格式}']);
|
|
8
|
-
assert.equal(rules.length, 4);
|
|
9
|
-
assert.deepEqual(rules[0], { kind: 'contains', include: '求链接', raw: '求链接' });
|
|
10
|
-
assert.deepEqual(rules[1], { kind: 'and', includeA: '工作服', includeB: '定制', raw: '{工作服 + 定制}' });
|
|
11
|
-
assert.deepEqual(rules[2], { kind: 'include_without', include: '求链接', exclude: '已买', raw: '{求链接 - 已买}' });
|
|
12
|
-
assert.deepEqual(rules[3], { kind: 'contains', include: '{坏格式}', raw: '{坏格式}' });
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('matchLikeText supports any-hit across mixed rule list', () => {
|
|
16
|
-
const rules = compileLikeRules(['{求链接 + 工作服}', '{求链接 - 已买}', '操底']);
|
|
17
|
-
|
|
18
|
-
const andHit = matchLikeText('大佬 求链接 工作服 有吗', rules);
|
|
19
|
-
assert.equal(andHit.ok, true);
|
|
20
|
-
assert.equal(andHit.matchedRule, '{求链接 + 工作服}');
|
|
21
|
-
|
|
22
|
-
const minusHit = matchLikeText('求链接,顺便问下尺码', rules);
|
|
23
|
-
assert.equal(minusHit.ok, true);
|
|
24
|
-
assert.equal(minusHit.matchedRule, '{求链接 - 已买}');
|
|
25
|
-
|
|
26
|
-
const plainHit = matchLikeText('今天准备操底', rules);
|
|
27
|
-
assert.equal(plainHit.ok, true);
|
|
28
|
-
assert.equal(plainHit.matchedRule, '操底');
|
|
29
|
-
|
|
30
|
-
const miss = matchLikeText('已买了,不需要链接', rules);
|
|
31
|
-
assert.equal(miss.ok, false);
|
|
32
|
-
assert.equal(miss.reason, 'no_rule_match');
|
|
33
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import type { XhsCheckpointId } from '../checkpoints.js';
|
|
4
|
-
|
|
5
|
-
function detectCheckpointFromMatchIds(
|
|
6
|
-
matchIds: string[],
|
|
7
|
-
url: string,
|
|
8
|
-
dom?: { hasDetailMask?: boolean; hasSearchInput?: boolean; title?: string }
|
|
9
|
-
): { checkpoint: XhsCheckpointId; signals: string[] } {
|
|
10
|
-
const signals: string[] = [];
|
|
11
|
-
const lowerUrl = url.toLowerCase();
|
|
12
|
-
|
|
13
|
-
if (lowerUrl.includes('/website-login/captcha') || lowerUrl.includes('verifyuuid=')) {
|
|
14
|
-
return { checkpoint: 'risk_control', signals: ['risk_control_url'] };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!url.includes('xiaohongshu.com')) {
|
|
18
|
-
return { checkpoint: 'offsite', signals: ['offsite'] };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (dom?.hasDetailMask === false && dom?.hasSearchInput === true) {
|
|
22
|
-
const isInSearch = url.includes('/search_result') || url.includes('keyword=');
|
|
23
|
-
return {
|
|
24
|
-
checkpoint: isInSearch ? 'search_ready' : 'home_ready',
|
|
25
|
-
signals: ['no_detail_mask', 'has_search_input', isInSearch ? 'search_ready' : 'home_ready'],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (matchIds.includes('xiaohongshu_login.login_guard')) {
|
|
30
|
-
return { checkpoint: 'login_guard', signals: ['login_guard'] };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (matchIds.some(id => id.includes('qrcode_guard') || id.includes('captcha_guard'))) {
|
|
34
|
-
return { checkpoint: 'risk_control', signals: ['risk_control'] };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (matchIds.some(id => id.includes('comment_section'))) {
|
|
38
|
-
return { checkpoint: 'comments_ready', signals: ['comments_anchor'] };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (matchIds.includes('xiaohongshu_detail.modal_shell') && matchIds.includes('xiaohongshu_detail.content_anchor')) {
|
|
42
|
-
return { checkpoint: 'detail_ready', signals: ['detail_shell', 'content_anchor'] };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (matchIds.includes('xiaohongshu_search.search_bar') && matchIds.includes('xiaohongshu_search.search_result_list')) {
|
|
46
|
-
return { checkpoint: 'search_ready', signals: ['search_bar', 'search_result_list'] };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (matchIds.some(id => id.includes('xiaohongshu_home'))) {
|
|
50
|
-
return { checkpoint: 'home_ready', signals: ['home'] };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return { checkpoint: 'unknown', signals: [] };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
test('DOM-first priority: home_ready when no detail mask and has search input', () => {
|
|
57
|
-
const result = detectCheckpointFromMatchIds(
|
|
58
|
-
['xiaohongshu_home', 'xiaohongshu_home.search_input'],
|
|
59
|
-
'https://www.xiaohongshu.com/explore',
|
|
60
|
-
{ hasDetailMask: false, hasSearchInput: true }
|
|
61
|
-
);
|
|
62
|
-
assert.strictEqual(result.checkpoint, 'home_ready');
|
|
63
|
-
assert.ok(result.signals.includes('no_detail_mask'));
|
|
64
|
-
assert.ok(result.signals.includes('has_search_input'));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('DOM-first priority: search_ready when in search_result with search input', () => {
|
|
68
|
-
const result = detectCheckpointFromMatchIds(
|
|
69
|
-
['xiaohongshu_search', 'xiaohongshu_search.search_bar'],
|
|
70
|
-
'https://www.xiaohongshu.com/search_result?keyword=test',
|
|
71
|
-
{ hasDetailMask: false, hasSearchInput: true }
|
|
72
|
-
);
|
|
73
|
-
assert.strictEqual(result.checkpoint, 'search_ready');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('hard stops: risk_control from URL pattern', () => {
|
|
77
|
-
const result = detectCheckpointFromMatchIds(
|
|
78
|
-
['xiaohongshu_home'],
|
|
79
|
-
'https://www.xiaohongshu.com/website-login/captcha?redirectPath=...'
|
|
80
|
-
);
|
|
81
|
-
assert.strictEqual(result.checkpoint, 'risk_control');
|
|
82
|
-
assert.ok(result.signals.includes('risk_control_url'));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('hard stops: offsite when not xiaohongshu.com', () => {
|
|
86
|
-
const result = detectCheckpointFromMatchIds(
|
|
87
|
-
['some_other_container'],
|
|
88
|
-
'https://www.google.com'
|
|
89
|
-
);
|
|
90
|
-
assert.strictEqual(result.checkpoint, 'offsite');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('hard stops: login_guard', () => {
|
|
94
|
-
const result = detectCheckpointFromMatchIds(
|
|
95
|
-
['xiaohongshu_login.login_guard'],
|
|
96
|
-
'https://www.xiaohongshu.com/signup'
|
|
97
|
-
);
|
|
98
|
-
assert.strictEqual(result.checkpoint, 'login_guard');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('page states: detail_ready', () => {
|
|
102
|
-
const result = detectCheckpointFromMatchIds(
|
|
103
|
-
['xiaohongshu_detail.modal_shell', 'xiaohongshu_detail.content_anchor'],
|
|
104
|
-
'https://www.xiaohongshu.com/explore/123456'
|
|
105
|
-
);
|
|
106
|
-
assert.strictEqual(result.checkpoint, 'detail_ready');
|
|
107
|
-
assert.ok(result.signals.includes('detail_shell'));
|
|
108
|
-
assert.ok(result.signals.includes('content_anchor'));
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('page states: comments_ready', () => {
|
|
112
|
-
const result = detectCheckpointFromMatchIds(
|
|
113
|
-
['xiaohongshu_detail.comment_section', 'xiaohongshu_detail.comment_section.comment_item'],
|
|
114
|
-
'https://www.xiaohongshu.com/explore/123456'
|
|
115
|
-
);
|
|
116
|
-
assert.strictEqual(result.checkpoint, 'comments_ready');
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('page states: search_ready from containers', () => {
|
|
120
|
-
const result = detectCheckpointFromMatchIds(
|
|
121
|
-
['xiaohongshu_search.search_bar', 'xiaohongshu_search.search_result_list'],
|
|
122
|
-
'https://www.xiaohongshu.com/search_result?keyword=test'
|
|
123
|
-
);
|
|
124
|
-
assert.strictEqual(result.checkpoint, 'search_ready');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('page states: home_ready from home container', () => {
|
|
128
|
-
const result = detectCheckpointFromMatchIds(
|
|
129
|
-
['xiaohongshu_home', 'xiaohongshu_home.feed_list'],
|
|
130
|
-
'https://www.xiaohongshu.com/explore'
|
|
131
|
-
);
|
|
132
|
-
assert.strictEqual(result.checkpoint, 'home_ready');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('edge cases: unknown for unrecognized state', () => {
|
|
136
|
-
const result = detectCheckpointFromMatchIds(
|
|
137
|
-
['some_random_container'],
|
|
138
|
-
'https://www.xiaohongshu.com/unknown-page'
|
|
139
|
-
);
|
|
140
|
-
assert.strictEqual(result.checkpoint, 'unknown');
|
|
141
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
import { matchCommentTextDsl, type CommentMatchDslRule } from '../src/blocks/helpers/commentMatchDsl.js';
|
|
5
|
-
|
|
6
|
-
test('dsl require:any matches any one', () => {
|
|
7
|
-
const res = matchCommentTextDsl('求链接 谢谢', { require: { op: 'any', terms: ['链接', '地址'] } });
|
|
8
|
-
assert.equal(res.ok, true);
|
|
9
|
-
assert.deepEqual(res.requireHits, ['链接']);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('dsl require:atLeast supports any two', () => {
|
|
13
|
-
const res = matchCommentTextDsl('a c', { caseSensitive: true, require: { op: 'atLeast', terms: ['a', 'b', 'c'], min: 2 } });
|
|
14
|
-
assert.equal(res.ok, true);
|
|
15
|
-
assert.equal(res.requireHits.length, 2);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('dsl exclude rejects when matched', () => {
|
|
19
|
-
const res = matchCommentTextDsl('淘宝 链接', { require: { op: 'any', terms: ['链接'] }, exclude: { op: 'any', terms: ['淘宝'] } });
|
|
20
|
-
assert.equal(res.ok, false);
|
|
21
|
-
assert.equal(res.rejectedBy, 'exclude');
|
|
22
|
-
assert.deepEqual(res.excludeHits, ['淘宝']);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('dsl supports and/or/not composition', () => {
|
|
26
|
-
const rule: CommentMatchDslRule = {
|
|
27
|
-
caseSensitive: true,
|
|
28
|
-
require: {
|
|
29
|
-
op: 'and',
|
|
30
|
-
exprs: [
|
|
31
|
-
{ op: 'or', exprs: [{ op: 'any', terms: ['a'] }, { op: 'any', terms: ['b'] }] },
|
|
32
|
-
{ op: 'not', expr: { op: 'any', terms: ['x'] } },
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
assert.equal(matchCommentTextDsl('a', rule).ok, true);
|
|
38
|
-
assert.equal(matchCommentTextDsl('b', rule).ok, true);
|
|
39
|
-
assert.equal(matchCommentTextDsl('x a', rule).ok, false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('dsl prefer contributes to score', () => {
|
|
43
|
-
const res = matchCommentTextDsl('求链接 真的太喜欢了', {
|
|
44
|
-
require: { op: 'any', terms: ['链接'] },
|
|
45
|
-
prefer: { op: 'any', terms: ['喜欢', '爱了'] },
|
|
46
|
-
});
|
|
47
|
-
assert.equal(res.ok, true);
|
|
48
|
-
assert.ok(res.score >= 100);
|
|
49
|
-
assert.deepEqual(res.preferHits, ['喜欢']);
|
|
50
|
-
});
|