@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,328 +0,0 @@
|
|
|
1
|
-
# apply_patch 工具完整测试计划
|
|
2
|
-
|
|
3
|
-
## 测试目标
|
|
4
|
-
|
|
5
|
-
验证 `apply_patch` 工具在各种场景下的正确性和鲁棒性,确保其在正常和边界情况下都能正确应用补丁。
|
|
6
|
-
|
|
7
|
-
## 测试环境
|
|
8
|
-
|
|
9
|
-
- 工作目录:`/Users/fanzhang/Documents/github/webauto/tests/patch_verification/`
|
|
10
|
-
- 源文件目录:`test_files/`
|
|
11
|
-
- 预期输出目录:`expected/`
|
|
12
|
-
- 实际输出目录:`actual/`
|
|
13
|
-
|
|
14
|
-
## 测试用例分类
|
|
15
|
-
|
|
16
|
-
### 阶段 1:基础功能测试
|
|
17
|
-
|
|
18
|
-
#### T1.1 简单文本替换
|
|
19
|
-
**目标**:验证最基本的单行文本替换
|
|
20
|
-
- **操作**:将文件中的 "hello" 替换为 "world"
|
|
21
|
-
- **验证点**:
|
|
22
|
-
- 目标文本被正确替换
|
|
23
|
-
- 文件其他部分保持不变
|
|
24
|
-
- 无多余内容插入
|
|
25
|
-
|
|
26
|
-
#### T1.2 多行文本替换
|
|
27
|
-
**目标**:验证连续多行文本的替换
|
|
28
|
-
- **操作**:将 3-5 行连续文本替换为新的多行内容
|
|
29
|
-
- **验证点**:
|
|
30
|
-
- 所有目标行被替换
|
|
31
|
-
- 保持原有缩进
|
|
32
|
-
- 行尾换行符正确
|
|
33
|
-
|
|
34
|
-
#### T1.3 单行插入(行首)
|
|
35
|
-
**目标**:验证在文件开头插入新内容
|
|
36
|
-
- **操作**:在第一行之前插入新行
|
|
37
|
-
- **验证点**:
|
|
38
|
-
- 新内容正确插入
|
|
39
|
-
- 原有内容顺序保持
|
|
40
|
-
|
|
41
|
-
#### T1.4 单行插入(行尾)
|
|
42
|
-
**目标**:验证在文件末尾追加新内容
|
|
43
|
-
- **操作**:在最后一行之后添加新行
|
|
44
|
-
- **验证点**:
|
|
45
|
-
- 新内容正确追加
|
|
46
|
-
- 不影响原有内容
|
|
47
|
-
|
|
48
|
-
#### T1.5 单行插入(中间)
|
|
49
|
-
**目标**:验证在文件中间位置插入新行
|
|
50
|
-
- **操作**:在指定行后插入新内容
|
|
51
|
-
- **验证点**:
|
|
52
|
-
- 插入位置准确
|
|
53
|
-
- 前后内容保持不变
|
|
54
|
-
|
|
55
|
-
#### T1.6 单行删除
|
|
56
|
-
**目标**:验证删除指定行
|
|
57
|
-
- **操作**:删除文件中的某一行
|
|
58
|
-
- **验证点**:
|
|
59
|
-
- 目标行被删除
|
|
60
|
-
- 前后内容正确连接
|
|
61
|
-
- 无多余空行
|
|
62
|
-
|
|
63
|
-
### 阶段 2:代码编辑测试
|
|
64
|
-
|
|
65
|
-
#### T2.1 函数内容替换
|
|
66
|
-
**目标**:验证替换函数体内的代码块
|
|
67
|
-
- **操作**:替换一个完整函数的实现
|
|
68
|
-
- **验证点**:
|
|
69
|
-
- 函数签名保持不变
|
|
70
|
-
- 函数体被完整替换
|
|
71
|
-
- 缩进格式正确
|
|
72
|
-
|
|
73
|
-
#### T2.2 添加新函数
|
|
74
|
-
**目标**:验证在现有代码中添加新函数
|
|
75
|
-
- **操作**:在文件末尾添加一个新的完整函数
|
|
76
|
-
- **验证点**:
|
|
77
|
-
- 新函数格式正确
|
|
78
|
-
- 不影响原有函数
|
|
79
|
-
- 符合语言语法
|
|
80
|
-
|
|
81
|
-
#### T2.3 修改配置文件
|
|
82
|
-
**目标**:验证对 JSON/YAML 配置文件的修改
|
|
83
|
-
- **操作**:修改配置项的值
|
|
84
|
-
- **验证点**:
|
|
85
|
-
- 配置项被正确更新
|
|
86
|
-
- JSON/YAML 语法有效
|
|
87
|
-
- 其他配置项保持不变
|
|
88
|
-
|
|
89
|
-
#### T2.4 导入语句添加
|
|
90
|
-
**目标**:验证在文件头部添加 import 语句
|
|
91
|
-
- **操作**:在现有 import 语句后添加新的 import
|
|
92
|
-
- **验证点**:
|
|
93
|
-
- 新 import 语句位置正确
|
|
94
|
-
- 符合语言规范
|
|
95
|
-
- 不破坏现有导入
|
|
96
|
-
|
|
97
|
-
#### T2.5 注释修改
|
|
98
|
-
**目标**:验证对注释内容的修改
|
|
99
|
-
- **操作**:修改文件中的多行注释
|
|
100
|
-
- **验证点**:
|
|
101
|
-
- 注释内容正确更新
|
|
102
|
-
- 注释格式保持
|
|
103
|
-
|
|
104
|
-
### 阶段 3:边界条件测试
|
|
105
|
-
|
|
106
|
-
#### T3.1 空文件操作
|
|
107
|
-
**目标**:验证对空文件的编辑
|
|
108
|
-
- **操作**:向空文件中添加内容
|
|
109
|
-
- **验证点**:
|
|
110
|
-
- 内容正确添加
|
|
111
|
-
- 文件结构有效
|
|
112
|
-
|
|
113
|
-
#### T3.2 大文件操作
|
|
114
|
-
**目标**:验证对较大文件的处理能力
|
|
115
|
-
- **操作**:修改 1000+ 行文件中的内容
|
|
116
|
-
- **验证点**:
|
|
117
|
-
- 修改位置准确
|
|
118
|
-
- 文件其他部分不受影响
|
|
119
|
-
- 性能可接受
|
|
120
|
-
|
|
121
|
-
#### T3.3 特殊字符处理
|
|
122
|
-
**目标**:验证对特殊字符的处理
|
|
123
|
-
- **操作**:包含以下字符的文本替换
|
|
124
|
-
- 引号(单引号、双引号、反引号)
|
|
125
|
-
- 反斜杠
|
|
126
|
-
- 正则表达式模式
|
|
127
|
-
- Unicode 字符
|
|
128
|
-
- HTML 标签
|
|
129
|
-
- **验证点**:
|
|
130
|
-
- 特殊字符正确保留
|
|
131
|
-
- 转义符正确处理
|
|
132
|
-
|
|
133
|
-
#### T3.4 重复文本处理
|
|
134
|
-
**目标**:验证当文件中存在多个相同文本时的处理
|
|
135
|
-
- **操作**:替换文件中出现多次的相同文本
|
|
136
|
-
- **验证点**:
|
|
137
|
-
- 只替换指定的那一个
|
|
138
|
-
- 其他重复文本保持不变
|
|
139
|
-
|
|
140
|
-
#### T3.5 缩进处理
|
|
141
|
-
**目标**:验证对各种缩进格式的处理
|
|
142
|
-
- **操作**:修改带有不同缩进层次的代码
|
|
143
|
-
- 2 空格缩进
|
|
144
|
-
- 4 空格缩进
|
|
145
|
-
- Tab 缩进
|
|
146
|
-
- 混合缩进
|
|
147
|
-
- **验证点**:
|
|
148
|
-
- 缩进格式保持一致
|
|
149
|
-
- 新内容缩进正确
|
|
150
|
-
|
|
151
|
-
#### T3.6 换行符处理
|
|
152
|
-
**目标**:验证对不同换行符的处理
|
|
153
|
-
- **操作**:
|
|
154
|
-
- LF (Unix) 文件编辑
|
|
155
|
-
- CRLF (Windows) 文件编辑
|
|
156
|
-
- 混合换行符文件编辑
|
|
157
|
-
- **验证点**:
|
|
158
|
-
- 换行符正确处理
|
|
159
|
-
- 不引入不一致的换行符
|
|
160
|
-
|
|
161
|
-
### 阶段 4:复杂场景测试
|
|
162
|
-
|
|
163
|
-
#### T4.1 多处修改
|
|
164
|
-
**目标**:验证在同一文件中进行多处修改
|
|
165
|
-
- **操作**:在一个补丁中修改文件的多个不同位置
|
|
166
|
-
- **验证点**:
|
|
167
|
-
- 所有修改都正确应用
|
|
168
|
-
- 修改之间不相互干扰
|
|
169
|
-
|
|
170
|
-
#### T4.2 跨行块操作
|
|
171
|
-
**目标**:验证跨越多个非连续行的块操作
|
|
172
|
-
- **操作**:选择并替换不连续的多行(如第 10-12 行和第 20-22 行)
|
|
173
|
-
- **验证点**:
|
|
174
|
-
- 所有目标行都被处理
|
|
175
|
-
- 中间行保持不变
|
|
176
|
-
|
|
177
|
-
#### T4.3 代码重构场景
|
|
178
|
-
**目标**:模拟真实的代码重构操作
|
|
179
|
-
- **操作**:将一个函数拆分成多个小函数
|
|
180
|
-
- **验证点**:
|
|
181
|
-
- 代码结构正确
|
|
182
|
-
- 功能等价
|
|
183
|
-
- 格式规范
|
|
184
|
-
|
|
185
|
-
#### T4.4 文档字符串修改
|
|
186
|
-
**目标**:验证对多行文档字符串的修改
|
|
187
|
-
- **操作**:修改 JSDoc/Python docstring 类型的文档注释
|
|
188
|
-
- **验证点**:
|
|
189
|
-
- 文档内容正确更新
|
|
190
|
-
- 格式保持
|
|
191
|
-
|
|
192
|
-
#### T4.5 条件编译指令
|
|
193
|
-
**目标**:验证对预处理指令的修改
|
|
194
|
-
- **操作**:修改 #ifdef/#ifndef 等条件编译块
|
|
195
|
-
- **验证点**:
|
|
196
|
-
- 指令正确更新
|
|
197
|
-
- 块结构保持
|
|
198
|
-
|
|
199
|
-
### 阶段 5:错误处理测试
|
|
200
|
-
|
|
201
|
-
#### T5.1 文件不存在
|
|
202
|
-
**目标**:验证当目标文件不存在时的处理
|
|
203
|
-
- **操作**:尝试对不存在的文件应用补丁
|
|
204
|
-
- **预期结果**:返回清晰的错误信息
|
|
205
|
-
|
|
206
|
-
#### T5.2 内容不匹配
|
|
207
|
-
**目标**:验证当待替换内容在文件中不存在时的处理
|
|
208
|
-
- **操作**:替换一个不存在的文本
|
|
209
|
-
- **预期结果**:返回清晰的错误信息
|
|
210
|
-
|
|
211
|
-
#### T5.3 权限错误
|
|
212
|
-
**目标**:验证当无文件写入权限时的处理
|
|
213
|
-
- **操作**:尝试修改只读文件
|
|
214
|
-
- **预期结果**:返回清晰的错误信息
|
|
215
|
-
|
|
216
|
-
#### T5.4 语法破坏
|
|
217
|
-
**目标**:验证补丁可能导致语法错误时的处理
|
|
218
|
-
- **操作**:应用一个会导致语法错误的补丁
|
|
219
|
-
- **预期结果**:工具应能应用但给出警告
|
|
220
|
-
|
|
221
|
-
#### T5.5 并发修改
|
|
222
|
-
**目标**:验证文件已被其他进程修改时的处理
|
|
223
|
-
- **操作**:在文件被外部修改后应用补丁
|
|
224
|
-
- **预期结果**:检测到冲突并报错
|
|
225
|
-
|
|
226
|
-
## 测试执行流程
|
|
227
|
-
|
|
228
|
-
### 准备阶段
|
|
229
|
-
1. 创建测试目录结构
|
|
230
|
-
2. 为每个测试用例生成:
|
|
231
|
-
- 原始测试文件(test_files/)
|
|
232
|
-
- 预期结果文件(expected/)
|
|
233
|
-
- 补丁定义文件(patches/)
|
|
234
|
-
|
|
235
|
-
### 执行阶段
|
|
236
|
-
对每个测试用例:
|
|
237
|
-
1. 复制原始文件到工作区
|
|
238
|
-
2. 记录文件初始状态
|
|
239
|
-
3. 应用补丁
|
|
240
|
-
4. 记录文件结果状态
|
|
241
|
-
5. 比较实际结果与预期结果
|
|
242
|
-
6. 记录测试结果
|
|
243
|
-
|
|
244
|
-
### 验证阶段
|
|
245
|
-
对每个测试用例验证:
|
|
246
|
-
- 文件内容是否与预期完全一致
|
|
247
|
-
- 文件编码是否正确
|
|
248
|
-
- 换行符是否一致
|
|
249
|
-
- 文件权限是否合理
|
|
250
|
-
- 是否有意外的副作用
|
|
251
|
-
|
|
252
|
-
### 报告阶段
|
|
253
|
-
生成测试报告包含:
|
|
254
|
-
- 每个测试用例的执行状态(通过/失败)
|
|
255
|
-
- 失败测试用例的详细差异
|
|
256
|
-
- 性能指标(执行时间)
|
|
257
|
-
- 错误日志
|
|
258
|
-
- 总体统计(通过率、失败率)
|
|
259
|
-
|
|
260
|
-
## 测试数据示例
|
|
261
|
-
|
|
262
|
-
### T1.1 测试数据
|
|
263
|
-
**原始文件** (test_files/simple_replace.txt):
|
|
264
|
-
```
|
|
265
|
-
hello world
|
|
266
|
-
this is a test
|
|
267
|
-
hello again
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
**补丁**:
|
|
271
|
-
```
|
|
272
|
-
hello -> world
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
**预期结果** (expected/simple_replace_result.txt):
|
|
276
|
-
```
|
|
277
|
-
world world
|
|
278
|
-
this is a test
|
|
279
|
-
world again
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### T2.1 测试数据
|
|
283
|
-
**原始文件** (test_files/function_replace.ts):
|
|
284
|
-
```typescript
|
|
285
|
-
function greet(name: string) {
|
|
286
|
-
console.log("Hello, " + name);
|
|
287
|
-
return name;
|
|
288
|
-
}
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
**补丁**:
|
|
292
|
-
```
|
|
293
|
-
function greet(name: string) {
|
|
294
|
-
console.log("Hello, " + name);
|
|
295
|
-
return name;
|
|
296
|
-
} ->
|
|
297
|
-
function greet(name: string) {
|
|
298
|
-
const message = `Hello, ${name}`;
|
|
299
|
-
console.log(message);
|
|
300
|
-
return message;
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
**预期结果** (expected/function_replace_result.ts):
|
|
305
|
-
```typescript
|
|
306
|
-
function greet(name: string) {
|
|
307
|
-
const message = `Hello, ${name}`;
|
|
308
|
-
console.log(message);
|
|
309
|
-
return message;
|
|
310
|
-
}
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## 成功标准
|
|
314
|
-
|
|
315
|
-
- ✅ 所有阶段 1 测试用例 100% 通过
|
|
316
|
-
- ✅ 所有阶段 2 测试用例 100% 通过
|
|
317
|
-
- ✅ 阶段 3 测试用例至少 90% 通过
|
|
318
|
-
- ✅ 阶段 4 测试用例至少 80% 通过
|
|
319
|
-
- ✅ 阶段 5 错误处理测试能够正确识别和报告错误
|
|
320
|
-
|
|
321
|
-
## 测试工具
|
|
322
|
-
|
|
323
|
-
建议实现以下辅助工具:
|
|
324
|
-
1. `test_runner.mjs` - 自动化测试执行器
|
|
325
|
-
2. `file_comparator.mjs` - 文件内容对比工具
|
|
326
|
-
3. `patch_generator.mjs` - 根据差异自动生成补丁定义
|
|
327
|
-
4. `report_generator.mjs` - 测试报告生成器
|
|
328
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Codex apply_patch 工具测试结果
|
|
2
|
-
|
|
3
|
-
## 观察到的问题
|
|
4
|
-
|
|
5
|
-
### 问题1: 空文件无法使用 @@ 格式
|
|
6
|
-
- 文件: test01.txt \(空文件\)
|
|
7
|
-
- 尝试格式: `@@ -0,0 +1,3 @@`
|
|
8
|
-
- 错误: "Failed to find context"
|
|
9
|
-
- **结论**: 空文件或新文件不能使用 unified diff 格式
|
|
10
|
-
|
|
11
|
-
### 问题2: 简单替换格式不工作
|
|
12
|
-
- 文件: test02.txt
|
|
13
|
-
- 尝试格式:
|
|
14
|
-
```
|
|
15
|
-
Line 2
|
|
16
|
-
---
|
|
17
|
-
Modified Line 2
|
|
18
|
-
```
|
|
19
|
-
- 错误: "Failed to find expected lines"
|
|
20
|
-
- **需要确认**: 正确的分隔符是什么?
|
|
21
|
-
|
|
22
|
-
## 需要明确的格式规则
|
|
23
|
-
|
|
24
|
-
1. **新建文件**: 应该使用什么格式?
|
|
25
|
-
2. **修改现有文件**: `---` 分隔符前后是否需要空格?
|
|
26
|
-
3. **搜索内容**: 行首的空格是否必需?
|
|
27
|
-
|
|
28
|
-
## 测试暂停
|
|
29
|
-
|
|
30
|
-
在继续之前,请您提供:
|
|
31
|
-
1. apply_patch 工具的完整格式说明
|
|
32
|
-
2. 对于新文件和现有文件的不同处理方式
|
|
33
|
-
3. 示例补丁格式
|
|
34
|
-
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Apply Patch 工具自身测试计划
|
|
2
|
-
|
|
3
|
-
## 目标
|
|
4
|
-
验证当前正在使用的 apply_patch 工具能够正确处理各种代码修改场景
|
|
5
|
-
|
|
6
|
-
## 测试策略
|
|
7
|
-
创建临时测试文件 → 应用补丁 → 验证结果 → 清理
|
|
8
|
-
|
|
9
|
-
## 测试用例列表
|
|
10
|
-
|
|
11
|
-
### Phase 1: 基础文本操作 (必须100%通过)
|
|
12
|
-
1. **TEST-01**: 创建新文件
|
|
13
|
-
2. **TEST-02**: 简单单行替换
|
|
14
|
-
3. **TEST-03**: 多行替换
|
|
15
|
-
4. **TEST-04**: 文件头部插入
|
|
16
|
-
5. **TEST-05**: 文件尾部追加
|
|
17
|
-
|
|
18
|
-
### Phase 2: 代码结构操作 (必须100%通过)
|
|
19
|
-
6. **TEST-06**: 函数内容替换
|
|
20
|
-
7. **TEST-07**: 添加import语句
|
|
21
|
-
8. **TEST-08**: 修改对象属性
|
|
22
|
-
9. **TEST-09**: 添加新方法
|
|
23
|
-
10. **TEST-10**: 修改函数参数
|
|
24
|
-
|
|
25
|
-
### Phase 3: 复杂场景 (必须≥90%通过)
|
|
26
|
-
11. **TEST-11**: 特殊字符处理(引号、反斜杠)
|
|
27
|
-
12. **TEST-12**: 缩进保持
|
|
28
|
-
13. **TEST-13**: 多处修改(连续应用多个补丁)
|
|
29
|
-
14. **TEST-14**: 大块代码替换
|
|
30
|
-
15. **TEST-15**: 空行和注释处理
|
|
31
|
-
|
|
32
|
-
### Phase 4: 边界条件 (必须正确报错)
|
|
33
|
-
16. **TEST-16**: 文件不存在
|
|
34
|
-
17. **TEST-17**: 搜索内容不匹配
|
|
35
|
-
18. **TEST-18**: 空文件处理
|
|
36
|
-
|
|
37
|
-
## 执行顺序
|
|
38
|
-
1. Phase 1 → 全部通过才继续
|
|
39
|
-
2. Phase 2 → 全部通过才继续
|
|
40
|
-
3. Phase 3 → ≥90%通过才继续
|
|
41
|
-
4. Phase 4 → 验证错误处理正确
|
|
42
|
-
5. 清理测试文件
|
|
43
|
-
|
|
44
|
-
## 成功标准
|
|
45
|
-
- Phase 1: 5/5 通过
|
|
46
|
-
- Phase 2: 5/5 通过
|
|
47
|
-
- Phase 3: ≥14/15 通过
|
|
48
|
-
- Phase 4: 错误信息清晰准确
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Apply Patch 工具自动化测试脚本
|
|
5
|
-
* 验证 apply_patch 工具在各种场景下的正确性
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { readFileSync, writeFileSync, mkdirSync, rmSync, existsSync } from 'fs';
|
|
9
|
-
import { join, dirname } from 'path';
|
|
10
|
-
import { fileURLToPath } from 'url';
|
|
11
|
-
|
|
12
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
const TEST_DIR = join(__dirname, 'temp_test_files');
|
|
14
|
-
|
|
15
|
-
// 测试结果统计
|
|
16
|
-
const results = {
|
|
17
|
-
phase1: { passed: 0, failed: 0, total: 5 },
|
|
18
|
-
phase2: { passed: 0, failed: 0, total: 5 },
|
|
19
|
-
phase3: { passed: 0, failed: 0, total: 5 },
|
|
20
|
-
phase4: { passed: 0, failed: 0, total: 3 },
|
|
21
|
-
failures: []
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// 工具函数
|
|
25
|
-
function setupTestEnv() {
|
|
26
|
-
if (existsSync(TEST_DIR)) {
|
|
27
|
-
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
28
|
-
}
|
|
29
|
-
mkdirSync(TEST_DIR, { recursive: true });
|
|
30
|
-
console.log('✓ 测试环境已创建:', TEST_DIR);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function cleanupTestEnv() {
|
|
34
|
-
if (existsSync(TEST_DIR)) {
|
|
35
|
-
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
36
|
-
}
|
|
37
|
-
console.log('✓ 测试环境已清理');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function createTestFile(filename, content) {
|
|
41
|
-
const filepath = join(TEST_DIR, filename);
|
|
42
|
-
writeFileSync(filepath, content, 'utf-8');
|
|
43
|
-
return filepath;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function readTestFile(filename) {
|
|
47
|
-
const filepath = join(TEST_DIR, filename);
|
|
48
|
-
if (!existsSync(filepath)) return null;
|
|
49
|
-
return readFileSync(filepath, 'utf-8');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function verifyContent(filename, expected) {
|
|
53
|
-
const actual = readTestFile(filename);
|
|
54
|
-
return actual === expected;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function recordResult(phase, testId, testName, passed, error = null) {
|
|
58
|
-
const status = passed ? '✓ PASS' : '✗ FAIL';
|
|
59
|
-
const color = passed ? '\x1b[32m' : '\x1b[31m';
|
|
60
|
-
console.log(`${color}${status}\x1b[0m ${testId}: ${testName}`);
|
|
61
|
-
|
|
62
|
-
if (passed) {
|
|
63
|
-
results[phase].passed++;
|
|
64
|
-
} else {
|
|
65
|
-
results[phase].failed++;
|
|
66
|
-
results.failures.push({ testId, testName, error });
|
|
67
|
-
if (error) console.log(` Error: ${error}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ==================== Phase 1: 基础文本操作 ====================
|
|
72
|
-
console.log('\n' + '='.repeat(60));
|
|
73
|
-
console.log('Phase 1: 基础文本操作 (必须100%通过)');
|
|
74
|
-
console.log('='.repeat(60));
|
|
75
|
-
|
|
76
|
-
// TEST-01: 创建新文件
|
|
77
|
-
console.log('\n[TEST-01] 创建新文件');
|
|
78
|
-
const test01Pass = (() => {
|
|
79
|
-
try {
|
|
80
|
-
// apply_patch 应该能够创建新文件
|
|
81
|
-
// 这里我们先手动创建,因为 apply_patch 主要用于修改现有文件
|
|
82
|
-
createTestFile('test01.txt', '');
|
|
83
|
-
return existsSync(join(TEST_DIR, 'test01.txt'));
|
|
84
|
-
} catch (e) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
})();
|
|
88
|
-
recordResult('phase1', 'TEST-01', '创建新文件', test01Pass);
|
|
89
|
-
|
|
90
|
-
// TEST-02: 简单单行替换
|
|
91
|
-
console.log('\n[TEST-02] 简单单行替换');
|
|
92
|
-
console.log('步骤: 创建文件 → 应用补丁 → 验证结果');
|
|
93
|
-
createTestFile('test02.txt', 'hello world\n');
|
|
94
|
-
console.log('原始内容: "hello world\\n"');
|
|
95
|
-
console.log('目标内容: "goodbye world\\n"');
|
|
96
|
-
console.log('\n请手动执行以下补丁:');
|
|
97
|
-
console.log('---');
|
|
98
|
-
console.log('*** Begin Patch');
|
|
99
|
-
console.log('*** Update File: tests/patch_verification/temp_test_files/test02.txt');
|
|
100
|
-
console.log('hello world');
|
|
101
|
-
console.log('---');
|
|
102
|
-
console.log('goodbye world');
|
|
103
|
-
console.log('*** End Patch');
|
|
104
|
-
console.log('---');
|
|
105
|
-
console.log('按回车继续验证...');
|
|
106
|
-
|
|
107
|
-
// 暂停等待手动应用补丁
|
|
108
|
-
// 在自动化版本中,我们需要调用 apply_patch 工具
|
|
109
|
-
|
|
110
|
-
// ==================== 注意 ====================
|
|
111
|
-
// 这个脚本需要与 apply_patch 工具集成
|
|
112
|
-
// 当前版本仅输出测试步骤,需要手动验证
|
|
113
|
-
// ==================== 注意 ====================
|
|
114
|
-
|
|
115
|
-
console.log('\n\n');
|
|
116
|
-
console.log('='.repeat(60));
|
|
117
|
-
console.log('测试计划输出完成');
|
|
118
|
-
console.log('='.repeat(60));
|
|
119
|
-
console.log('\n下一步: 实现与 apply_patch 工具的集成');
|
|
120
|
-
console.log('建议: 先手动执行以下测试步骤验证工具是否正常工作\n');
|
|
121
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hello world
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hello world
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
actual content
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hello world
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Test Reporter - 生成测试报告
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import fs from 'node:fs/promises';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
|
|
10
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const PROJECT_ROOT = path.resolve(__dirname, '../..');
|
|
12
|
-
|
|
13
|
-
class TestReporter {
|
|
14
|
-
async generate(results) {
|
|
15
|
-
const passed = results.filter(r => r.status === 'passed').length;
|
|
16
|
-
const failed = results.filter(r => r.status === 'failed').length;
|
|
17
|
-
const duration = results.reduce((sum, r) => sum + (r.duration || 0), 0);
|
|
18
|
-
|
|
19
|
-
const report = {
|
|
20
|
-
summary: {
|
|
21
|
-
total: results.length,
|
|
22
|
-
passed,
|
|
23
|
-
failed,
|
|
24
|
-
skipped: 0,
|
|
25
|
-
duration,
|
|
26
|
-
successRate: results.length > 0 ? `${(passed / results.length * 100).toFixed(2)}%` : '0%'
|
|
27
|
-
},
|
|
28
|
-
results: results.map(r => ({
|
|
29
|
-
name: r.name,
|
|
30
|
-
status: r.status,
|
|
31
|
-
duration: r.duration,
|
|
32
|
-
error: r.error
|
|
33
|
-
})),
|
|
34
|
-
timestamp: new Date().toISOString()
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const reportPath = path.join(PROJECT_ROOT, 'tests', 'reports', `test-report-${Date.now()}.json`);
|
|
38
|
-
|
|
39
|
-
// Ensure reports directory exists
|
|
40
|
-
await fs.mkdir(path.dirname(reportPath), { recursive: true });
|
|
41
|
-
|
|
42
|
-
// Write report
|
|
43
|
-
await fs.writeFile(reportPath, JSON.stringify(report, null, 2));
|
|
44
|
-
|
|
45
|
-
console.log(`📄 Report saved: ${reportPath}`);
|
|
46
|
-
|
|
47
|
-
return report;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// CLI
|
|
52
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
53
|
-
console.log('TestReporter: Run through TestRunner instead');
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default TestReporter;
|