minimal-agent 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/package.json +52 -5
- package/plugins/computer_use/.claude-plugin/plugin.json +6 -0
- package/plugins/computer_use/README.md +94 -0
- package/plugins/computer_use/app/_template.md +142 -0
- package/plugins/computer_use/app/chrome.md +165 -0
- package/plugins/computer_use/app/finder.md +76 -0
- package/plugins/computer_use/app/macos-system-settings.md +81 -0
- package/plugins/computer_use/app/microsoft-excel.md +80 -0
- package/plugins/computer_use/app/microsoft-powerpoint.md +80 -0
- package/plugins/computer_use/app/microsoft-word.md +79 -0
- package/plugins/computer_use/app/wechat.md +413 -0
- package/plugins/computer_use/app/weread.md +319 -0
- package/plugins/computer_use/commands/computeruse.md +25 -0
- package/plugins/computer_use/commands/cu.md +9 -0
- package/plugins/computer_use/plugin.js +26 -0
- package/plugins/computer_use/plugin.ts +30 -0
- package/plugins/computer_use/src/capture.js +90 -0
- package/plugins/computer_use/src/capture.ts +104 -0
- package/plugins/computer_use/src/commands.js +91 -0
- package/plugins/computer_use/src/commands.ts +103 -0
- package/plugins/computer_use/src/daemon.js +134 -0
- package/plugins/computer_use/src/daemon.ts +161 -0
- package/plugins/computer_use/src/manuals.js +135 -0
- package/plugins/computer_use/src/manuals.ts +159 -0
- package/plugins/computer_use/src/verify.js +168 -0
- package/plugins/computer_use/src/verify.ts +219 -0
- package/plugins/computer_use/test/commands.test.ts +73 -0
- package/plugins/cron-runner/plugin.ts +38 -0
- package/plugins/cron-runner/src/commands.ts +373 -0
- package/plugins/cron-runner/src/cronTime.ts +155 -0
- package/plugins/cron-runner/src/lock.ts +79 -0
- package/plugins/cron-runner/src/runs.ts +99 -0
- package/plugins/cron-runner/src/scheduleEngine.ts +76 -0
- package/plugins/cron-runner/src/scheduler.ts +376 -0
- package/plugins/cron-runner/src/schema.ts +139 -0
- package/plugins/cron-runner/src/service.ts +193 -0
- package/plugins/cron-runner/src/store.ts +333 -0
- package/plugins/cron-runner/src/types.ts +141 -0
- package/plugins/cron-runner/test/cronTime.test.ts +41 -0
- package/plugins/cron-runner/test/plugin-integration.test.ts +47 -0
- package/plugins/cron-runner/test/scheduleEngine.test.ts +41 -0
- package/plugins/cron-runner/test/service.test.ts +76 -0
- package/plugins/cron-runner/test/store-and-scheduler.test.ts +501 -0
- package/plugins/workflow-runner/plugin.js +56 -2
- package/plugins/workflow-runner/plugin.ts +113 -0
- package/plugins/workflow-runner/src/agentCommon.js +43 -4
- package/plugins/workflow-runner/src/agentCommon.ts +435 -0
- package/plugins/workflow-runner/src/controlFlow/branch.js +40 -0
- package/plugins/workflow-runner/src/controlFlow/branch.ts +46 -0
- package/plugins/workflow-runner/src/controlFlow/loop.js +211 -0
- package/plugins/workflow-runner/src/controlFlow/loop.ts +248 -0
- package/plugins/workflow-runner/src/controlFlow/pause.js +129 -0
- package/plugins/workflow-runner/src/controlFlow/pause.ts +141 -0
- package/plugins/workflow-runner/src/controlFlow/signal.js +21 -0
- package/plugins/workflow-runner/src/controlFlow/signal.ts +29 -0
- package/plugins/workflow-runner/src/controlFlow/types.js +18 -0
- package/plugins/workflow-runner/src/controlFlow/types.ts +63 -0
- package/plugins/workflow-runner/src/dslManifest.ts +127 -0
- package/plugins/workflow-runner/src/expressions.ts +622 -0
- package/plugins/workflow-runner/src/index.js +13 -4
- package/plugins/workflow-runner/src/index.ts +338 -0
- package/plugins/workflow-runner/src/jsonPayload.ts +84 -0
- package/plugins/workflow-runner/src/loader.js +23 -0
- package/plugins/workflow-runner/src/loader.ts +721 -0
- package/plugins/workflow-runner/src/multimodal.js +2 -1
- package/plugins/workflow-runner/src/multimodal.ts +64 -0
- package/plugins/workflow-runner/src/recovery.ts +149 -0
- package/plugins/workflow-runner/src/runner.js +75 -659
- package/plugins/workflow-runner/src/runner.ts +604 -0
- package/plugins/workflow-runner/src/stepExecutors/agent.ts +234 -0
- package/plugins/workflow-runner/src/stepExecutors/assert.ts +50 -0
- package/plugins/workflow-runner/src/stepExecutors/echo.js +31 -0
- package/plugins/workflow-runner/src/stepExecutors/echo.ts +38 -0
- package/plugins/workflow-runner/src/stepExecutors/llm.ts +133 -0
- package/plugins/workflow-runner/src/stepExecutors/set.js +49 -0
- package/plugins/workflow-runner/src/stepExecutors/set.ts +56 -0
- package/plugins/workflow-runner/src/stepExecutors/skill.js +5 -6
- package/plugins/workflow-runner/src/stepExecutors/skill.ts +140 -0
- package/plugins/workflow-runner/src/stepExecutors/tool.js +80 -8
- package/plugins/workflow-runner/src/stepExecutors/tool.ts +256 -0
- package/plugins/workflow-runner/src/stepExecutors/verify.ts +68 -0
- package/plugins/workflow-runner/src/stepPipeline.js +277 -0
- package/plugins/workflow-runner/src/stepPipeline.ts +366 -0
- package/plugins/workflow-runner/src/taskIdentity.ts +405 -0
- package/plugins/workflow-runner/src/toolRuntime.js +48 -0
- package/plugins/workflow-runner/src/toolRuntime.ts +64 -0
- package/plugins/workflow-runner/src/types.js +37 -1
- package/plugins/workflow-runner/src/types.ts +602 -0
- package/plugins/workflow-runner/src/workflowState.ts +733 -0
- package/plugins/workflow-runner/test/agent.test.ts +587 -0
- package/plugins/workflow-runner/test/agentLlmError.test.ts +373 -0
- package/plugins/workflow-runner/test/bashBlacklist.sweep.test.ts +65 -0
- package/plugins/workflow-runner/test/captureMisbind.test.ts +99 -0
- package/plugins/workflow-runner/test/cli.e2e.test.ts +147 -0
- package/plugins/workflow-runner/test/context-files.test.ts +320 -0
- package/plugins/workflow-runner/test/e2e.test.ts +370 -0
- package/plugins/workflow-runner/test/engineRobustness.test.ts +226 -0
- package/plugins/workflow-runner/test/expressions.test.ts +397 -0
- package/plugins/workflow-runner/test/foundation.test.ts +126 -0
- package/plugins/workflow-runner/test/graceful.test.ts +139 -0
- package/plugins/workflow-runner/test/greedyInputs.load.test.ts +47 -0
- package/plugins/workflow-runner/test/hostCapability.test.ts +108 -0
- package/plugins/workflow-runner/test/illustrate.load.test.ts +183 -0
- package/plugins/workflow-runner/test/jsonPayload.test.ts +83 -0
- package/plugins/workflow-runner/test/loader.test.ts +617 -0
- package/plugins/workflow-runner/test/maxTurnsRetryDelay.test.ts +33 -0
- package/plugins/workflow-runner/test/multimodal.test.ts +342 -0
- package/plugins/workflow-runner/test/output-schema.test.ts +213 -0
- package/plugins/workflow-runner/test/parseWorkflowArgs.test.ts +87 -0
- package/plugins/workflow-runner/test/pluginRunner.isolation.test.ts +269 -0
- package/plugins/workflow-runner/test/ppt.load.test.ts +1220 -0
- package/plugins/workflow-runner/test/ralphLoop.e2e.test.ts +220 -0
- package/plugins/workflow-runner/test/recovery.test.ts +265 -0
- package/plugins/workflow-runner/test/runner.test.ts +911 -0
- package/plugins/workflow-runner/test/runnerPreflight.test.ts +379 -0
- package/plugins/workflow-runner/test/skillTurnDone.test.ts +71 -0
- package/plugins/workflow-runner/test/stateLifecycle.test.ts +150 -0
- package/plugins/workflow-runner/test/stepPipeline.test.ts +114 -0
- package/plugins/workflow-runner/test/taskArbitration.test.ts +338 -0
- package/plugins/workflow-runner/test/taskIdentity.test.ts +237 -0
- package/plugins/workflow-runner/test/taskLifecycle.test.ts +270 -0
- package/plugins/workflow-runner/test/toolArtifactOverwrite.test.ts +221 -0
- package/plugins/workflow-runner/test/toolCapabilityBoundary.test.ts +29 -0
- package/plugins/workflow-runner/test/toolRuntimeIntegration.test.ts +168 -0
- package/plugins/workflow-runner/test/webppt.load.test.ts +250 -0
- package/plugins/workflow-runner/test/word.load.test.ts +208 -0
- package/plugins/workflow-runner/test/workflows.smoke.test.ts +76 -0
- package/plugins/workflow-runner/test/yamlGuardConditions.test.ts +207 -0
- package/skills/browser-automation/SKILL.md +9 -19
- package/skills/web-crawler/SKILL.md +9 -11
- package/src/askBridge.ts +249 -0
- package/src/bootstrap/cwdArg.js +10 -3
- package/src/bootstrap/cwdArg.ts +31 -0
- package/src/bootstrap/workingDir.ts +48 -0
- package/src/cli/args.js +70 -7
- package/src/cli/args.ts +146 -0
- package/src/cli/computerUse.js +185 -0
- package/src/cli/computerUse.ts +221 -0
- package/src/cli/configMenu.js +274 -202
- package/src/cli/configMenu.tsx +521 -0
- package/src/cli/memoryAccess.js +45 -0
- package/src/cli/memoryAccess.ts +53 -0
- package/src/cli/print.js +119 -5
- package/src/cli/print.ts +597 -0
- package/src/cli/quickModelSetup.js +60 -0
- package/src/cli/quickModelSetup.tsx +96 -0
- package/src/cli/streamJson.js +80 -4
- package/src/cli/streamJson.ts +433 -0
- package/src/cli/wizards/advisorWizard.js +1 -0
- package/src/cli/wizards/advisorWizard.tsx +195 -0
- package/src/cli/wizards/agentRuntimeWizard.js +84 -0
- package/src/cli/wizards/agentRuntimeWizard.tsx +134 -0
- package/src/cli/wizards/browserWizard.js +55 -0
- package/src/cli/wizards/browserWizard.tsx +77 -0
- package/src/cli/wizards/contextAdvisorWizard.js +84 -0
- package/src/cli/wizards/contextAdvisorWizard.tsx +124 -0
- package/src/cli/wizards/fieldForm.js +7 -4
- package/src/cli/wizards/fieldForm.tsx +250 -0
- package/src/cli/wizards/imageWizard.js +4 -5
- package/src/cli/wizards/imageWizard.tsx +96 -0
- package/src/cli/wizards/openRouterWizard.tsx +48 -0
- package/src/cli/wizards/providerPresets.js +1 -8
- package/src/cli/wizards/providerPresets.ts +106 -0
- package/src/cli/wizards/providerWizard.js +152 -205
- package/src/cli/wizards/providerWizard.tsx +266 -0
- package/src/cli/wizards/searchWizard.tsx +47 -0
- package/src/cli/wizards/ttsWizard.js +4 -3
- package/src/cli/wizards/ttsWizard.tsx +61 -0
- package/src/config/configDefaults.js +25 -0
- package/src/config/configDefaults.ts +33 -0
- package/src/config/configDiagnostics.js +117 -0
- package/src/config/configDiagnostics.ts +166 -0
- package/src/config/configFile.js +52 -32
- package/src/config/configFile.ts +633 -0
- package/src/config/configManagement.js +126 -0
- package/src/config/configManagement.ts +159 -0
- package/src/config/configService.js +66 -11
- package/src/config/configService.ts +554 -0
- package/src/config/numericLimits.js +61 -0
- package/src/config/numericLimits.ts +80 -0
- package/src/config.ts +109 -0
- package/src/context/agentHome.ts +11 -0
- package/src/context/archive.ts +144 -0
- package/src/context/budgetPlan.js +54 -0
- package/src/context/budgetPlan.ts +88 -0
- package/src/context/compact.js +179 -106
- package/src/context/compact.ts +584 -0
- package/src/context/contextBundle.js +119 -0
- package/src/context/contextBundle.ts +176 -0
- package/src/context/contextLock.ts +84 -0
- package/src/context/microCompactLite.ts +218 -0
- package/src/context/persistContext.ts +177 -0
- package/src/context/reactiveCompact.js +19 -4
- package/src/context/reactiveCompact.ts +240 -0
- package/src/context/recentDirs.ts +42 -0
- package/src/context/sessionPath.ts +206 -0
- package/src/context/sessionRegistry.js +8 -2
- package/src/context/sessionRegistry.ts +414 -0
- package/src/context/snipCompact.ts +163 -0
- package/src/context/tokenCounter.ts +106 -0
- package/src/context/workspaceIndex.js +2 -2
- package/src/context/workspaceIndex.ts +751 -0
- package/src/entry.compiled.tsx +20 -0
- package/src/harness/claimValidation.js +9 -0
- package/src/harness/claimValidation.ts +22 -0
- package/src/harness/evidenceLedger.js +92 -0
- package/src/harness/evidenceLedger.ts +96 -0
- package/src/harness/stallGuard.js +60 -0
- package/src/harness/stallGuard.ts +81 -0
- package/src/humanIntervention.js +129 -0
- package/src/humanIntervention.ts +216 -0
- package/src/infra/verification.ts +295 -0
- package/src/irreversible/rules.js +216 -0
- package/src/irreversible/rules.ts +261 -0
- package/src/llm/client.js +40 -3
- package/src/llm/client.ts +621 -0
- package/src/llm/promptCache.js +27 -0
- package/src/llm/promptCache.ts +41 -0
- package/src/llm/providers/anthropicFormat.js +41 -5
- package/src/llm/providers/anthropicFormat.ts +290 -0
- package/src/llm/providers/openaiFormat.js +186 -8
- package/src/llm/providers/openaiFormat.ts +428 -0
- package/src/loop.js +614 -63
- package/src/loop.ts +1454 -0
- package/src/main.js +67 -10
- package/src/main.tsx +344 -0
- package/src/memory/codec.js +204 -0
- package/src/memory/codec.ts +249 -0
- package/src/memory/constants.js +34 -0
- package/src/memory/constants.ts +50 -0
- package/src/memory/episodicMemory.js +684 -0
- package/src/memory/episodicMemory.ts +815 -0
- package/src/memory/fileStore.js +148 -0
- package/src/memory/fileStore.ts +184 -0
- package/src/memory/memoryService.js +570 -0
- package/src/memory/memoryService.ts +859 -0
- package/src/memory/migration.js +128 -0
- package/src/memory/migration.ts +160 -0
- package/src/memory/repository.js +789 -0
- package/src/memory/repository.ts +893 -0
- package/src/memory/retrieval.js +108 -0
- package/src/memory/retrieval.ts +145 -0
- package/src/memory/searchIndex.js +107 -0
- package/src/memory/searchIndex.ts +153 -0
- package/src/memory/topicView.js +82 -0
- package/src/memory/topicView.ts +95 -0
- package/src/memory/turnJournal.js +95 -0
- package/src/memory/turnJournal.ts +120 -0
- package/src/memory/types.js +2 -0
- package/src/memory/types.ts +186 -0
- package/src/messageQueue.ts +123 -0
- package/src/multimodal.js +128 -46
- package/src/multimodal.ts +349 -0
- package/src/plugin-sdk.js +21 -1
- package/src/plugin-sdk.ts +134 -0
- package/src/plugins/builtinPluginIds.js +47 -0
- package/src/plugins/builtinPluginIds.ts +51 -0
- package/src/plugins/builtinRegistry.ts +43 -0
- package/src/plugins/commandRouter.js +40 -26
- package/src/plugins/commandRouter.ts +261 -0
- package/src/plugins/hookEngine.ts +341 -0
- package/src/plugins/pluginApi.ts +133 -0
- package/src/plugins/pluginLifecycle.ts +34 -0
- package/src/plugins/pluginLoader.ts +147 -0
- package/src/plugins/pluginManifest.js +127 -0
- package/src/plugins/pluginManifest.ts +152 -0
- package/src/plugins/pluginRunner.js +47 -2
- package/src/plugins/pluginRunner.ts +207 -0
- package/src/plugins/transcript.ts +208 -0
- package/src/prompts/lint.js +169 -0
- package/src/prompts/lint.ts +220 -0
- package/src/prompts/pluginList.js +32 -16
- package/src/prompts/pluginList.ts +86 -0
- package/src/prompts/policyRegistry.js +318 -0
- package/src/prompts/policyRegistry.ts +358 -0
- package/src/prompts/projectInstructions.js +24 -0
- package/src/prompts/projectInstructions.ts +81 -0
- package/src/prompts/promptAssembly.js +311 -202
- package/src/prompts/promptAssembly.ts +510 -0
- package/src/prompts/skillList.js +106 -45
- package/src/prompts/skillList.ts +198 -0
- package/src/prompts/system.js +31 -6
- package/src/prompts/system.ts +81 -0
- package/src/runtime/agentRuntimeContext.js +53 -0
- package/src/runtime/agentRuntimeContext.ts +112 -0
- package/src/session/runAgentTurn.js +71 -12
- package/src/session/runAgentTurn.ts +181 -0
- package/src/session/runTurn.js +29 -0
- package/src/session/runTurn.ts +160 -0
- package/src/session/runtimeStore.js +149 -0
- package/src/session/runtimeStore.ts +197 -0
- package/src/session/sessionState.js +79 -3
- package/src/session/sessionState.ts +134 -0
- package/src/toolGate.ts +50 -0
- package/src/tools/advisor/advisor.js +76 -15
- package/src/tools/advisor/advisor.ts +512 -0
- package/src/tools/agent/agent.js +245 -29
- package/src/tools/agent/agent.ts +837 -0
- package/src/tools/agent/agentTaskService.js +60 -0
- package/src/tools/agent/agentTaskService.ts +113 -0
- package/src/tools/agent/agentTypes.js +20 -8
- package/src/tools/agent/agentTypes.ts +94 -0
- package/src/tools/agent/coordinator.ts +111 -0
- package/src/tools/agent/worktree.ts +296 -0
- package/src/tools/ask/ask.js +17 -0
- package/src/tools/ask/ask.ts +122 -0
- package/src/tools/bash/attachImage.js +223 -0
- package/src/tools/bash/attachImage.ts +281 -0
- package/src/tools/bash/bash.js +132 -14
- package/src/tools/bash/bash.ts +642 -0
- package/src/tools/bash/semantics.ts +103 -0
- package/src/tools/bash/warnings.js +17 -11
- package/src/tools/bash/warnings.ts +117 -0
- package/src/tools/capabilities.js +42 -0
- package/src/tools/capabilities.ts +69 -0
- package/src/tools/computeruse/accessibilityPermission.js +261 -0
- package/src/tools/computeruse/accessibilityPermission.ts +294 -0
- package/src/tools/computeruse/axSearch.js +96 -0
- package/src/tools/computeruse/axSearch.ts +120 -0
- package/src/tools/computeruse/axSnap.js +272 -0
- package/src/tools/computeruse/axSnap.ts +349 -0
- package/src/tools/computeruse/capabilityLabels.js +95 -0
- package/src/tools/computeruse/capabilityLabels.ts +115 -0
- package/src/tools/computeruse/computerUseService.js +2235 -0
- package/src/tools/computeruse/computerUseService.ts +2686 -0
- package/src/tools/computeruse/computeruse.js +2742 -0
- package/src/tools/computeruse/computeruse.ts +3265 -0
- package/src/tools/computeruse/diagnosticTrace.js +154 -0
- package/src/tools/computeruse/diagnosticTrace.ts +195 -0
- package/src/tools/computeruse/diagnostics.js +369 -0
- package/src/tools/computeruse/diagnostics.ts +453 -0
- package/src/tools/computeruse/grants.js +53 -0
- package/src/tools/computeruse/grants.ts +70 -0
- package/src/tools/computeruse/humanBoundary.js +159 -0
- package/src/tools/computeruse/humanBoundary.ts +199 -0
- package/src/tools/computeruse/intervention.js +77 -0
- package/src/tools/computeruse/intervention.ts +110 -0
- package/src/tools/computeruse/manualSchema.js +709 -0
- package/src/tools/computeruse/manualSchema.ts +916 -0
- package/src/tools/computeruse/observationImages.js +705 -0
- package/src/tools/computeruse/observationImages.ts +889 -0
- package/src/tools/computeruse/protocol.js +60 -0
- package/src/tools/computeruse/protocol.ts +515 -0
- package/src/tools/computeruse/telemetryLog.js +57 -0
- package/src/tools/computeruse/telemetryLog.ts +67 -0
- package/src/tools/computeruse/vision/appGuide.js +325 -0
- package/src/tools/computeruse/vision/appGuide.ts +482 -0
- package/src/tools/computeruse/vision/focus.js +291 -0
- package/src/tools/computeruse/vision/focus.ts +382 -0
- package/src/tools/computeruse/vision/frames.js +248 -0
- package/src/tools/computeruse/vision/frames.ts +329 -0
- package/src/tools/computeruse/vision/geometry.js +131 -0
- package/src/tools/computeruse/vision/geometry.ts +163 -0
- package/src/tools/computeruse/vision/imaging.js +201 -0
- package/src/tools/computeruse/vision/imaging.ts +281 -0
- package/src/tools/computeruse/vision/png.js +274 -0
- package/src/tools/computeruse/vision/png.ts +317 -0
- package/src/tools/computeruse/vision/raster.js +320 -0
- package/src/tools/computeruse/vision/raster.ts +408 -0
- package/src/tools/computeruse/vision/settle.js +131 -0
- package/src/tools/computeruse/vision/settle.ts +220 -0
- package/src/tools/computeruse/vision/telemetry.js +196 -0
- package/src/tools/computeruse/vision/telemetry.ts +241 -0
- package/src/tools/computeruse/visionOcr.js +115 -0
- package/src/tools/computeruse/visionOcr.ts +128 -0
- package/src/tools/computeruse/waitFor.js +237 -0
- package/src/tools/computeruse/waitFor.ts +291 -0
- package/src/tools/download/download.js +10 -6
- package/src/tools/download/download.ts +187 -0
- package/src/tools/edit/edit.js +30 -18
- package/src/tools/edit/edit.ts +349 -0
- package/src/tools/edit/multi-edit.js +25 -14
- package/src/tools/edit/multi-edit.ts +223 -0
- package/src/tools/effectiveToolSet.js +73 -0
- package/src/tools/effectiveToolSet.ts +91 -0
- package/src/tools/genimage/genimage.ts +257 -0
- package/src/tools/genspeech/genspeech.ts +83 -0
- package/src/tools/glob/glob.js +176 -29
- package/src/tools/glob/glob.ts +283 -0
- package/src/tools/grep/grep.js +61 -19
- package/src/tools/grep/grep.ts +239 -0
- package/src/tools/grep/rgPath.ts +206 -0
- package/src/tools/index.js +99 -5
- package/src/tools/index.ts +293 -0
- package/src/tools/lsp/config.js +113 -0
- package/src/tools/lsp/config.ts +113 -0
- package/src/tools/lsp/lsp.js +256 -0
- package/src/tools/lsp/lsp.ts +274 -0
- package/src/tools/lsp/service.js +303 -0
- package/src/tools/lsp/service.ts +296 -0
- package/src/tools/memory/memory.js +520 -0
- package/src/tools/memory/memory.ts +625 -0
- package/src/tools/memory/policy.js +53 -0
- package/src/tools/memory/policy.ts +72 -0
- package/src/tools/notebook/notebookEdit.js +114 -0
- package/src/tools/notebook/notebookEdit.ts +126 -0
- package/src/tools/powershell/powershell.js +210 -0
- package/src/tools/powershell/powershell.ts +239 -0
- package/src/tools/presentresult/presentresult.js +145 -0
- package/src/tools/presentresult/presentresult.ts +156 -0
- package/src/tools/read/read.js +371 -163
- package/src/tools/read/read.ts +558 -0
- package/src/tools/shared/diffSummary.js +44 -0
- package/src/tools/shared/diffSummary.ts +63 -0
- package/src/tools/shared/fileActivity.js +51 -0
- package/src/tools/shared/fileActivity.ts +66 -0
- package/src/tools/shared/fileMutationBus.js +13 -0
- package/src/tools/shared/fileMutationBus.ts +14 -0
- package/src/tools/shared/fileState.js +73 -65
- package/src/tools/shared/fileState.ts +145 -0
- package/src/tools/shared/fileUtils.js +81 -4
- package/src/tools/shared/fileUtils.ts +504 -0
- package/src/tools/shared/killTree.ts +50 -0
- package/src/tools/shared/permanentDeleteGuard.js +26 -0
- package/src/tools/shared/permanentDeleteGuard.ts +34 -0
- package/src/tools/shared/schemas.ts +20 -0
- package/src/tools/shared/toolOutputStore.js +97 -0
- package/src/tools/shared/toolOutputStore.ts +110 -0
- package/src/tools/skill/skill.js +86 -0
- package/src/tools/skill/skill.ts +94 -0
- package/src/tools/snip/snip.js +67 -0
- package/src/tools/snip/snip.ts +80 -0
- package/src/tools/tasks/backgroundTaskService.js +275 -0
- package/src/tools/tasks/backgroundTaskService.ts +369 -0
- package/src/tools/tasks/processEvidence.js +24 -0
- package/src/tools/tasks/processEvidence.ts +34 -0
- package/src/tools/tasks/taskManagement.js +163 -0
- package/src/tools/tasks/taskManagement.ts +180 -0
- package/src/tools/tasks/taskOutput.js +113 -0
- package/src/tools/tasks/taskOutput.ts +145 -0
- package/src/tools/tasks/taskStop.js +74 -0
- package/src/tools/tasks/taskStop.ts +99 -0
- package/src/tools/tasks/taskStore.js +46 -0
- package/src/tools/tasks/taskStore.ts +77 -0
- package/src/tools/terminal/terminalCapture.js +167 -0
- package/src/tools/terminal/terminalCapture.ts +179 -0
- package/src/tools/trash/trash.js +233 -0
- package/src/tools/trash/trash.ts +283 -0
- package/src/tools/types.js +1 -1
- package/src/tools/types.ts +24 -0
- package/src/tools/webbrowser/agentBrowserPath.ts +286 -0
- package/src/tools/webbrowser/browser.js +214 -11
- package/src/tools/webbrowser/browser.ts +293 -0
- package/src/tools/webbrowser/browserControl.js +153 -48
- package/src/tools/webbrowser/browserControl.ts +262 -0
- package/src/tools/webbrowser/browserDaemon.js +147 -39
- package/src/tools/webbrowser/browserDaemon.ts +270 -0
- package/src/tools/webbrowser/browserOutcome.js +273 -0
- package/src/tools/webbrowser/browserOutcome.ts +306 -0
- package/src/tools/webbrowser/browserRunRegistry.js +150 -0
- package/src/tools/webbrowser/browserRunRegistry.ts +179 -0
- package/src/tools/webbrowser/browserService.js +20 -6
- package/src/tools/webbrowser/browserService.ts +56 -0
- package/src/tools/webbrowser/browserStream.js +30 -1
- package/src/tools/webbrowser/browserStream.ts +216 -0
- package/src/tools/webbrowser/browserTabs.js +143 -0
- package/src/tools/webbrowser/browserTabs.ts +210 -0
- package/src/tools/webbrowser/webbrowser.js +831 -150
- package/src/tools/webbrowser/webbrowser.ts +1537 -0
- package/src/tools/webfetch/preapproved.ts +274 -0
- package/src/tools/webfetch/webfetch.js +24 -23
- package/src/tools/webfetch/webfetch.ts +383 -0
- package/src/tools/websearch/websearch.js +12 -11
- package/src/tools/websearch/websearch.ts +292 -0
- package/src/tools/worktree/sessionWorktree.js +128 -0
- package/src/tools/worktree/sessionWorktree.ts +158 -0
- package/src/tools/write/write.js +27 -44
- package/src/tools/write/write.ts +136 -0
- package/src/types.ts +960 -0
- package/src/ui/App.js +216 -12
- package/src/ui/App.tsx +879 -0
- package/src/ui/AskQuestion.tsx +300 -0
- package/src/ui/InputBox.js +77 -1
- package/src/ui/InputBox.tsx +567 -0
- package/src/ui/LiveArea.tsx +344 -0
- package/src/ui/MessageList.js +27 -6
- package/src/ui/MessageList.tsx +559 -0
- package/src/ui/ModelPicker.tsx +107 -0
- package/src/ui/QueuedMessagesBanner.tsx +51 -0
- package/src/ui/Root.js +6 -8
- package/src/ui/Root.tsx +100 -0
- package/src/ui/SessionPicker.tsx +169 -0
- package/src/ui/StatusLine.js +22 -1
- package/src/ui/StatusLine.tsx +145 -0
- package/src/ui/WorkspacePicker.tsx +84 -0
- package/src/ui/advisorCommand.js +54 -0
- package/src/ui/advisorCommand.ts +63 -0
- package/src/ui/computerCommand.js +19 -0
- package/src/ui/computerCommand.ts +35 -0
- package/src/ui/figures.ts +45 -0
- package/src/ui/hooks/askSlot.ts +112 -0
- package/src/ui/hooks/useChat.js +271 -7
- package/src/ui/hooks/useChat.ts +1578 -0
- package/src/ui/hooks/useInputHistory.ts +235 -0
- package/src/ui/hooks/usePasteHandler.ts +220 -0
- package/src/ui/hooks/useTerminalSize.ts +41 -0
- package/src/ui/hooks/useTextBuffer.ts +108 -0
- package/src/ui/hooks/useTokenUsage.ts +44 -0
- package/src/ui/liveViewport.ts +189 -0
- package/src/ui/markdown.ts +230 -0
- package/src/ui/textBuffer.ts +239 -0
- package/src/ui/theme.ts +35 -0
- package/src/utils/clipboardImage.js +358 -0
- package/src/utils/clipboardImage.ts +420 -0
- package/src/utils/debugLog.ts +50 -0
- package/src/utils/greenRoot.ts +35 -0
- package/src/utils/packageRoot.ts +40 -0
- package/src/utils/pathContains.js +28 -0
- package/src/utils/pathContains.ts +31 -0
- package/src/utils/resourcePaths.ts +71 -0
- package/src/utils/stripThink.ts +49 -0
- package/src/utils/zodToJson.ts +73 -0
- package/src/web/browserBridge.js +365 -66
- package/src/web/browserBridge.ts +672 -0
- package/src/web/protocol.ts +1804 -0
- package/vendor/computer-use/arm64-darwin/cu-helperd +0 -0
- package/workflows/ppt.yaml +13 -2
- package/workflows/wechat-reading-shots.yaml +315 -0
- package/workflows/word.yaml +11 -1
- package/skills/docx/scripts/office/helpers/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/helpers/__pycache__/merge_runs.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/helpers/__pycache__/simplify_redlines.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/base.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/docx.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/pptx.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/redlining.cpython-314.pyc +0 -0
- package/skills/image-stats/scripts/__pycache__/image_stats.cpython-314.pyc +0 -0
- package/skills/image-stats/scripts/__pycache__/image_stats_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/assemble_material.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/assemble_material_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/chart_sanity_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_language_policy.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_ui_artifact.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_ui_artifact_pptx_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_pages_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_pages_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_visual_style_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_visual_style_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_budget_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_budget_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_repair_hints.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_repair_hints_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_style_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_style_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/draft_coverage_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/extract_source_assets.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/extract_source_assets_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/generated_image_review_collect.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/generated_image_review_collect_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_plan_lint.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_plan_lint_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_prompt_rewrite.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_prompt_rewrite_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/layout_balance.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/layout_balance_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/normalize_design_json.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/normalize_design_json_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/plan_source_layout.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/plan_source_layout_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_hint.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_hint_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_input.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_input_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/scaffold_ui_artifact.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/source_usage_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/source_usage_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/text_readability_pixel.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/visual_quality_gate.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/visual_quality_gate_test.cpython-314.pyc +0 -0
- /package/skills/ai-image/scripts/{generate_test.mjs → generate.selftest.mjs} +0 -0
- /package/skills/ai-image/scripts/{generate_from_plan_test.mjs → generate_from_plan.selftest.mjs} +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
---
|
|
2
|
+
schemaVersion: 2
|
|
3
|
+
guideVersion: 1
|
|
4
|
+
status: layout-verified
|
|
5
|
+
platforms: [macOS]
|
|
6
|
+
match:
|
|
7
|
+
bundleId: [com.tencent.weread, com.tencent.wereadmac]
|
|
8
|
+
processName: [WeRead, 微信读书]
|
|
9
|
+
displayName: [微信读书, WeRead]
|
|
10
|
+
irreversible:
|
|
11
|
+
critical: []
|
|
12
|
+
normal:
|
|
13
|
+
- intent:purchase
|
|
14
|
+
- intent:subscribe
|
|
15
|
+
- intent:share
|
|
16
|
+
- intent:gift
|
|
17
|
+
verifiedRange:
|
|
18
|
+
macOS: 微信读书 iOS 套壳版(/Applications/微信读书.app/Wrapper/WeRead.app),身份 / 分区 / 页码位置 / 翻页键 / 沉浸模式唤出菜单 / 返回流程
|
|
19
|
+
lastVerifiedAt: 2026-08-09
|
|
20
|
+
|
|
21
|
+
# ---- schema v2 结构化部分 ----
|
|
22
|
+
#
|
|
23
|
+
# ⚠️ 微信读书是 **iOS 应用套壳**,无障碍树只给得出一个空壳 AXGroup(实测焦点恒为
|
|
24
|
+
# `AXGroup · caret(51,97)` 这类窗口角落的退化包装节点)。所以这里**不写 ax 锚点、
|
|
25
|
+
# 不写绝对 rect** —— 写了就是编的,而编出来的锚点比没有更糟:模型会拿它当事实去点。
|
|
26
|
+
# 分区只声明「存在、大致在窗口的哪一带」,真实位置每次从当次观测里读。
|
|
27
|
+
#
|
|
28
|
+
# ⚠️ 所有位置一律用**窗口相对比例**表达,不用屏幕坐标。见正文「坐标必须锚窗口」一节,
|
|
29
|
+
# 那是本应用最容易致命的一个坑。
|
|
30
|
+
|
|
31
|
+
layout:
|
|
32
|
+
- id: tab_bar
|
|
33
|
+
desc: 窗口**底部**四个标签「阅读 / 书架 / 书友 / 我」,y 约在窗口高度的 93% 一带;只在非阅读界面出现
|
|
34
|
+
verified: true
|
|
35
|
+
- id: search_box
|
|
36
|
+
desc: 窗口**顶部**通栏搜索框,y 约在窗口高度的 7% 一带;**阅读页和书架页都有**,不必先切到书架
|
|
37
|
+
verified: true
|
|
38
|
+
- id: weekly_card
|
|
39
|
+
desc: 「阅读」页左上角的「本周阅读」卡片,右侧横排着最近在读的书,封面上直接印着书名 —— 常读的书从这里一次点击就能进
|
|
40
|
+
verified: true
|
|
41
|
+
- id: shelf_grid
|
|
42
|
+
desc: 「书架」页的封面网格,书名印在封面上;常看的书直接点封面即可
|
|
43
|
+
verified: true
|
|
44
|
+
- id: search_results
|
|
45
|
+
desc: 搜索结果页,**分两组且书架组在上**:「在书架中搜索:<词>」(你账号里已有的书)在上,「在书城中搜索:<词>」在下;顶部还有 全部/电子书/有声书/全文/作者/书单/公众号/文章 分类
|
|
46
|
+
verified: true
|
|
47
|
+
- id: book_detail
|
|
48
|
+
desc: 书籍详情页(书名 + 推荐值 + 点评);**底部一条通栏蓝色大按钮**「阅读 / 继续阅读」是进正文的入口
|
|
49
|
+
verified: true
|
|
50
|
+
- id: reading_pane
|
|
51
|
+
desc: 正文阅读区,宽窗口下是**左右双页对开**(左右各一页),窄窗口下单页;沉浸模式下没有标题栏也没有返回箭头
|
|
52
|
+
verified: true
|
|
53
|
+
- id: page_footer
|
|
54
|
+
desc: 页码在**每一页的右下角**(不是居中):左页那个在中缝左侧、右页那个在窗口最右侧,形如「32 / 115」(当前页 / 总页数)
|
|
55
|
+
verified: true
|
|
56
|
+
- id: back_arrow
|
|
57
|
+
desc: 窗口**左上角**的返回箭头 ‹;在搜索结果页/详情页/二级页面常驻,在沉浸阅读模式下隐藏(点窗口正中心唤出菜单后才出现)
|
|
58
|
+
verified: true
|
|
59
|
+
- id: reading_toolbar
|
|
60
|
+
desc: 沉浸阅读模式下唤出的底部工具条,含目录/书签、主题切换、字体大小调节、Ai 等按钮;与返回箭头同时出现/同时隐藏
|
|
61
|
+
verified: true
|
|
62
|
+
- id: reading_topbar
|
|
63
|
+
desc: 沉浸阅读模式下唤出的顶部工具栏,含左侧返回箭头、右侧分享/目录/设置等图标;与底部工具条同步显隐
|
|
64
|
+
verified: true
|
|
65
|
+
|
|
66
|
+
controls: []
|
|
67
|
+
|
|
68
|
+
flows:
|
|
69
|
+
read_page_number:
|
|
70
|
+
goal: 读出当前页码 —— 本应用一切定位的基础,翻页前必做
|
|
71
|
+
verified: true
|
|
72
|
+
steps:
|
|
73
|
+
- do: |
|
|
74
|
+
observe 时带上放大镜读页脚,**坐标用相对窗口的、固定值**:
|
|
75
|
+
magnify: { x: 0, y: 945, width: 1000, height: 55 }
|
|
76
|
+
magnifyAnchor: "window"
|
|
77
|
+
引擎会按当前窗口位置自己换算 —— 你**不需要**从回执里抠窗口范围手算。
|
|
78
|
+
它从**原始分辨率帧**裁一条窗口底部通宽的横条放大后附成第 2 张图。
|
|
79
|
+
页码形如「32 / 115」(当前页 / 总页数),双页对开时左右两页各一个。
|
|
80
|
+
- do: 框不中就把 y 在 900~975 之间挪一挪重试(仍用 magnifyAnchor:"window")
|
|
81
|
+
pitfalls:
|
|
82
|
+
- ⛔ **不用放大镜是读不出页码的。** 原图 5120×2880 压到约 1371×771 才发给你,20px 高的页码只剩约 5px,是一团马赛克 —— 猜必错,此前模型报的页码全是蒙的
|
|
83
|
+
- 宽度必须取整个窗口宽(width:1000 + anchor window):两个页码分别贴在左页和右页的右下角,只框中间那一段会把右页那个切掉
|
|
84
|
+
- ⛔ 放大镜只能**读字**,不能拿来定位点击 —— 点击坐标一律以第 1 张全屏图为准
|
|
85
|
+
- 放大镜里读不到「N / 总数」= 当前不是正文页(封面/详情/目录/附件文件夹页),此时所有键盘翻页都无效
|
|
86
|
+
|
|
87
|
+
toggle_reading_menu:
|
|
88
|
+
goal: 在沉浸阅读模式下唤出或隐藏顶部返回箭头 + 底部工具条
|
|
89
|
+
verified: true
|
|
90
|
+
steps:
|
|
91
|
+
- do: |
|
|
92
|
+
点击**窗口正中心**(约 L+W×0.5, T+H×0.5)。
|
|
93
|
+
这是唯一可靠的切换方式:点一下唤出,再点一下隐藏。
|
|
94
|
+
- do: observe 确认左上角返回箭头 ‹ 和底部工具条是否出现
|
|
95
|
+
pitfalls:
|
|
96
|
+
- ⛔ **不要点页面边缘**:点左/右边缘会触发翻页,点顶部/底部可能点到页码或空白
|
|
97
|
+
- ⛔ **不要连续点多次**:菜单是切换式的,点两下又回去了;每次只点一下,observe 确认后再决定
|
|
98
|
+
- ⛔ 不要点正文中的图片/插图:会把图片放大成遮罩盖住整本书,后续截图全废
|
|
99
|
+
- 唤出菜单后不操作,过几秒会自动隐藏;要操作就抓紧
|
|
100
|
+
|
|
101
|
+
open_book:
|
|
102
|
+
goal: 从任意主界面打开指定的书并进入正文
|
|
103
|
+
verified: true
|
|
104
|
+
steps:
|
|
105
|
+
- do: observe 看清在哪。底部四个标签是「阅读 / 书架 / 书友 / 我」,顶部一行是搜索框(阅读页、书架页都有)
|
|
106
|
+
- do: |
|
|
107
|
+
**先走不用搜索的最短路**(一次点击就进书):
|
|
108
|
+
· 「阅读」页左上的「本周阅读」卡片里横排着最近在读的书
|
|
109
|
+
· 「书架」页是封面网格
|
|
110
|
+
两处的封面上都直接印着书名。看得见目标书 → **直接点封面中心**。
|
|
111
|
+
- do: |
|
|
112
|
+
看不见才搜索:点顶部搜索框 → 输入书名 → 回车 → observe。
|
|
113
|
+
结果**分两组**:「在书架中搜索:<词>」在上,「在书城中搜索:<词>」在下。
|
|
114
|
+
→ **优先点书架组**那条 —— 那是账号里已有的书,点开直接能读。
|
|
115
|
+
- do: 若落在书籍详情页(底部一条通栏蓝色「阅读 / 继续阅读」按钮)→ 点它 → observe
|
|
116
|
+
- do: 按 read_page_number 确认能读到「N / 总数」页码 —— 读得到才算真进了正文
|
|
117
|
+
pitfalls:
|
|
118
|
+
- ⚠️ **书城里名字高度相似的书极多**(实测搜「claude code」同时列出「Claude Code 实战」「Claude Code 橙皮书」「Claude Code 源码架构」「Claude Code 源码解析」…),只看前几个字必点错 —— 必须核对**完整书名 + 作者**
|
|
119
|
+
- 书架组的结果永远排在书城组上面;点书城组的书可能要购买/订阅,是只读任务的红线
|
|
120
|
+
- 书重新打开时停在**上次读到的位置**,不是第 1 页
|
|
121
|
+
- 详情页/封面页/目录页上键盘翻页全部无效,必须先真正进到正文
|
|
122
|
+
- 点封面时要点**封面中心区域**,点边缘可能触发翻页或其他交互
|
|
123
|
+
|
|
124
|
+
back_to_home:
|
|
125
|
+
goal: 从任意界面退回到带底部标签栏的主界面
|
|
126
|
+
verified: true
|
|
127
|
+
steps:
|
|
128
|
+
- do: observe 一次,先看清在哪;⛔ 不要在看清之前点任何东西。窗口范围 L/T/R/B 的取法见 read_page_number 第 1 步
|
|
129
|
+
- do: |
|
|
130
|
+
看**窗口**左上角(约 L+W×0.02, T+H×0.04)有没有返回箭头 ‹ —— 有就点它退一级,然后 observe
|
|
131
|
+
注意:点返回箭头的命中区域很小,要精确点在箭头符号上,点偏可能变成翻页或无反应
|
|
132
|
+
- do: 没有返回箭头就点一次**窗口正中心**(约 L+W×0.5, T+H×0.5)把菜单唤出来,再看左上角
|
|
133
|
+
- do: 重复上面两步,直到窗口底部出现那排标签(阅读 / 书架 / 书友 / 我)
|
|
134
|
+
- do: |
|
|
135
|
+
试到第 4 轮还回不去就**彻底关掉应用重启**,别在原地耗:
|
|
136
|
+
hotkey cmd+q → wait 2 秒 → activate_app com.tencent.weread → observe
|
|
137
|
+
重启后会落在首页,流程就能回到正轨。这一招只用一次。
|
|
138
|
+
pitfalls:
|
|
139
|
+
- ⛔ **返回箭头在窗口左上角,不是屏幕左上角。** 窗口通常不是全屏的,按屏幕坐标点会点到窗口外面的别的应用上(实测点 x=10,y=60 → 前台变成 Google Chrome,任务当场卡死)
|
|
140
|
+
- 这个循环里只许点两个位置:窗口左上角返回箭头、窗口正中心。点窗口右上角是最大化/关闭;点目录、书签、附件文件夹、正文里的图片都会把状态搞乱
|
|
141
|
+
- ⛔ 点中正文插图会把图片放大成遮罩盖住整本书,后续截图全废
|
|
142
|
+
- 菜单唤出后如果等太久会自动隐藏,要及时点返回箭头
|
|
143
|
+
- 返回箭头按钮很小(约 20×20 px),点偏一点都不触发;AX 吸附有时能自动校正,但别依赖
|
|
144
|
+
|
|
145
|
+
seek_to_page:
|
|
146
|
+
goal: 把书翻到指定页码
|
|
147
|
+
verified: true
|
|
148
|
+
steps:
|
|
149
|
+
- do: 按 read_page_number 流程读出当前页码 N(不读页码就翻页 = 盲翻,方向都可能是反的)
|
|
150
|
+
- do: |
|
|
151
|
+
先算**还要按几次**(不是页码差!双页对开一次翻两页,两者差一倍,混淆会永远进不了批量档):
|
|
152
|
+
方向 = 当前页 > 目标页 ? left : right
|
|
153
|
+
按键次数 N = 向上取整( |当前页 − 目标页| ÷ 2 )
|
|
154
|
+
- do: |
|
|
155
|
+
N ≥ 5 → **批量档**,一次发满:
|
|
156
|
+
{action:"key", key:"<方向>", repeat:<min(N,8)>, repeatFrames:"last"}
|
|
157
|
+
N ≤ 4 → **精准档**,一次一按:{action:"key", key:"<方向>"}
|
|
158
|
+
- do: 每发完一批(或一下)都回去重读页码,按新的 N 决定下一批;以**读到的页码**为准,不要凭按了几下推算
|
|
159
|
+
pitfalls:
|
|
160
|
+
- 批量翻页不加 repeatFrames:"last" 的话,repeat:8 会一次回 8 张全屏图(约 1 万 token),而中间那些页根本不看
|
|
161
|
+
- 回执报「变化很小」(前后差分接近 0)= 撞到书的首页或末页了,继续按不会有任何变化
|
|
162
|
+
- ⚠️ **批量翻页可能被「前台被别的窗口抢走」打断**。回执里会写「repeat:已连续执行 M/N 次」——
|
|
163
|
+
**以 M 为准算页码,不要按你请求的 N 推算**。前台被抢时还会附一句自动恢复提示
|
|
164
|
+
- 目标页可能落在对开的左页或右页任意一侧,两边命中都算到位,不必强求落在左页
|
|
165
|
+
|
|
166
|
+
verification:
|
|
167
|
+
environment: macOS 26.5.2 / 微信读书 iOS 套壳版 / 5120×2880 屏,窗口非全屏;证据来自本仓库多轮实机 trace 与截图
|
|
168
|
+
verifiedAt: 2026-08-09
|
|
169
|
+
verifiedItems: [identity, layout, page-number-position, paging-keys, pages-per-keypress, window-anchored-coordinates, toggle-reading-menu, open-book, back-to-home]
|
|
170
|
+
unverifiedItems: []
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
# 微信读书 / WeRead App Guide
|
|
174
|
+
|
|
175
|
+
## 稳定身份
|
|
176
|
+
|
|
177
|
+
- Bundle ID:`com.tencent.weread` / `com.tencent.wereadmac`
|
|
178
|
+
- 这是 **iOS 应用套壳**:`/Applications/微信读书.app/Wrapper/WeRead.app`
|
|
179
|
+
- 后果:无障碍树只有一个空壳 `AXGroup`(实测焦点恒为窗口角落的退化包装节点,
|
|
180
|
+
形如 `AXGroup · caret(51,97)`)。**`elementId` / `textTarget` 全部走不通**,
|
|
181
|
+
只能看截图估比例坐标 + 键盘。
|
|
182
|
+
|
|
183
|
+
## ⛔ 坐标必须锚窗口,不能锚屏幕
|
|
184
|
+
|
|
185
|
+
这是本应用**最容易致命**的一个坑,而且症状完全指不向原因。
|
|
186
|
+
|
|
187
|
+
微信读书的窗口通常**不是全屏**的。observe 回执的窗口列表里有一行形如:
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
方括号里是 0–1000 比例坐标 `[左,上]-[右,下]`。记作 `L / T / R / B`,`W = R−L`,`H = B−T`。
|
|
191
|
+
所有位置都从这四个数算:
|
|
192
|
+
|
|
193
|
+
| 目标 | 算法 |
|
|
194
|
+
|---|---|
|
|
195
|
+
| 左上角返回箭头 | `x ≈ L + W×0.02`,`y ≈ T + H×0.04` |
|
|
196
|
+
| 窗口正中心(唤出菜单用) | `x ≈ L + W×0.50`,`y ≈ T + H×0.50` |
|
|
197
|
+
| 底部标签栏 | `y ≈ T + H×0.93` 一带 |
|
|
198
|
+
| 顶部搜索框 | `y ≈ T + H×0.07` 一带 |
|
|
199
|
+
| 页脚页码放大镜 | `{ x: L, y: B − H×0.055, width: W, height: H×0.055 }` |
|
|
200
|
+
|
|
201
|
+
**实测事故**:按屏幕坐标点「左上角」用了 `x=10, y=60` —— 那个位置在窗口**外面**,
|
|
202
|
+
点中了后面的 Google Chrome,前台被抢走,整个任务当场卡死,
|
|
203
|
+
而回执只报 `human_intervention_required: 前台应用已变成「Google Chrome」`,
|
|
204
|
+
根本看不出是坐标锚错了参照系。
|
|
205
|
+
|
|
206
|
+
## ★ 页码必须用放大镜读,直接看全屏图是读不出来的
|
|
207
|
+
|
|
208
|
+
页码在**每一页的右下角**(不是居中),形如 `32 / 115`(当前页 / 总页数)。
|
|
209
|
+
宽窗口是左右双页对开:左页那个落在中缝左侧(约窗口宽的 48%),右页那个落在窗口最右(约 98%)。
|
|
210
|
+
所以放大镜的框**必须取整个窗口宽**,只框中间会把右页那个切掉。
|
|
211
|
+
|
|
212
|
+
**为什么必须放大**:原始截图 5120×2880,发给模型前会被压到约 1371×771(约 100 万像素预算)。
|
|
213
|
+
页码原本约 20px 高,压完只剩约 **5px** —— 把那张图再放大 8 倍看到的是一团马赛克,
|
|
214
|
+
**信息在降采样那一步就物理销毁了,任何提示词都救不回来**。此前模型报的页码全是猜的。
|
|
215
|
+
|
|
216
|
+
正确做法是 `observe` 带上 `magnify`,它从**原始分辨率帧**上裁一块放大,作为第 2 张图附上:
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
宽度取**整个窗口宽**:两个页码分别贴在左页和右页的右下角,只框中间那一段会把右页那个切掉。
|
|
220
|
+
框不中就把 `y` 上下挪几十再试一次。
|
|
221
|
+
|
|
222
|
+
⛔ 放大镜**只能读字,不能拿来定位点击** —— 点击坐标一律以第 1 张全屏图为准。
|
|
223
|
+
|
|
224
|
+
## 翻页只用键盘
|
|
225
|
+
|
|
226
|
+
| 键 | 效果 |
|
|
227
|
+
|---|---|
|
|
228
|
+
| `right` | 下一页 |
|
|
229
|
+
| `left` | 上一页 |
|
|
230
|
+
|
|
231
|
+
宽窗口是双页对开,**按一次翻两页**(已多次实测验证),
|
|
232
|
+
所以按键次数 N = 向上取整(页码差 ÷ 2)。
|
|
233
|
+
|
|
234
|
+
⚠️ **选档位用 N(按键次数),不是页码差。** 两者差一倍 —— 拿页码差去比阈值,
|
|
235
|
+
或者拿 N 去比一个按页码差定的阈值,都会让批量档几乎永远进不去。
|
|
236
|
+
`N ≥ 5` 走批量(`repeat` 一次发满),`N ≤ 4` 一次一按。
|
|
237
|
+
|
|
238
|
+
判断有没有翻动看回执里的**前后差分变化率**:实测真翻动是 **15%~26%**,
|
|
239
|
+
撞到书的首页/末页是**精确的 0.00**,两者泾渭分明,可以直接当判据用。
|
|
240
|
+
|
|
241
|
+
**不要用鼠标翻页。** 进了正文之后点击只有坏处:会唤出菜单、会点中插图把它放大成遮罩
|
|
242
|
+
盖住整本书、会点中正文里的链接。方向键翻页零副作用。
|
|
243
|
+
|
|
244
|
+
想快速翻很多页时用 `repeat`(上限 8)批量连发,并且**必须加 `repeatFrames:"last"`** ——
|
|
245
|
+
不加的话 `repeat:8` 会一次回 8 张全屏图(约 1 万 token),而中间翻过的页根本不看。
|
|
246
|
+
|
|
247
|
+
## ★ 沉浸阅读模式与菜单唤出
|
|
248
|
+
|
|
249
|
+
进入书籍正文后默认进入**沉浸阅读模式**:
|
|
250
|
+
|
|
251
|
+
- 满屏正文,没有标题栏、没有底部标签栏、没有返回箭头
|
|
252
|
+
- 左右双页对开(宽窗口),每页右下角有页码
|
|
253
|
+
- 所有 UI 控件全部隐藏
|
|
254
|
+
|
|
255
|
+
**唤出菜单的唯一方式:点击窗口正中心**
|
|
256
|
+
|
|
257
|
+
- 点一下 → 顶部返回箭头 + 底部工具条同时出现
|
|
258
|
+
- 再点一下 → 同时隐藏(切换式)
|
|
259
|
+
- 唤出后不操作,过几秒会自动隐藏
|
|
260
|
+
|
|
261
|
+
底部工具条从左到右大致包含:目录/书签按钮、主题切换、字体大小、Ai 按钮等。
|
|
262
|
+
顶部工具栏左侧是返回箭头 ‹,右侧有分享、目录、设置等图标。
|
|
263
|
+
|
|
264
|
+
**点击位置的注意事项:**
|
|
265
|
+
|
|
266
|
+
- ✅ 点窗口正中心(W×0.5, H×0.5)附近的正文文字区域 —— 最稳妥
|
|
267
|
+
- ❌ 不要点左/右边缘 —— 会触发翻页
|
|
268
|
+
- ❌ 不要点正文中的图片 —— 会把图片放大成全屏遮罩
|
|
269
|
+
- ❌ 不要连续点多次 —— 菜单是切换的,点两下又回去了
|
|
270
|
+
|
|
271
|
+
## 界面状态与出入口
|
|
272
|
+
|
|
273
|
+
- **沉浸阅读模式**:满屏正文,没有标题栏、没有底部标签栏、没有返回箭头。
|
|
274
|
+
点一次**窗口正中心**把菜单唤出来,左上角的返回箭头才会出现。
|
|
275
|
+
- **首页(「阅读」标签)**:顶部通栏搜索框;左上角「本周阅读」卡片里横排着最近在读的书。
|
|
276
|
+
- **书架页**:封面网格,书名印在封面上。看得见目标书就**直接点封面**,一次点击进书 ——
|
|
277
|
+
这是最短路径。搜索是后备:点框 + 输入 + 回车 + 挑结果,四个来回,一步偏就容易开始乱试。
|
|
278
|
+
- **搜索结果页**:分「在书架中搜索」(在上,账号里已有的书)和「在书城中搜索」(在下)两组,
|
|
279
|
+
优先点书架组。书城组里名字高度相似的书极多,只看前几个字必点错。
|
|
280
|
+
- **书籍详情页**:底部一条通栏蓝色「阅读 / 继续阅读」按钮,点它进正文。
|
|
281
|
+
- **书重新打开时停在上次读到的位置**,不要假设在第 1 页。
|
|
282
|
+
- **前置附件 / 文件夹页**(如「XX 9MB,3个项目」的蓝色文件夹图标页):
|
|
283
|
+
实测 `right/left/up/down/pageup/pagedown/space/return/tab` 和 `scroll` **全部 0.0%**,
|
|
284
|
+
键盘在这类页面上完全无效。判据很简单:**放大镜里读不到「N / 总数」页码,就不是正文页**,
|
|
285
|
+
得先靠返回箭头退出去、重新从书架进正文。
|
|
286
|
+
|
|
287
|
+
## 返回首页的完整流程
|
|
288
|
+
|
|
289
|
+
从沉浸阅读模式返回首页,标准操作序列:
|
|
290
|
+
|
|
291
|
+
1. **observe** 确认当前在正文页(能看到双页正文,但看不到返回箭头和底部标签栏)
|
|
292
|
+
2. 点击**窗口正中心**唤出菜单 → observe 确认左上角返回箭头出现
|
|
293
|
+
3. 点击**窗口左上角返回箭头** ‹ → observe
|
|
294
|
+
4. 确认底部出现「阅读 / 书架 / 书友 / 我」标签栏 = 回到首页
|
|
295
|
+
|
|
296
|
+
如果第 3 步点完还在二级页面(如详情页、搜索结果页),继续点左上角返回箭头,直到底部标签栏出现。
|
|
297
|
+
|
|
298
|
+
**关键口诀:中心唤菜单,左上角返回。**
|
|
299
|
+
|
|
300
|
+
## 只读边界
|
|
301
|
+
|
|
302
|
+
微信读书在自动化里应当按**只读**对待:不点「购买」「订阅」「分享」「赠一得一」「加入书架」
|
|
303
|
+
这类按钮。翻页、截图、读页码都不改变书的任何状态(阅读进度会前进,这是可接受的副作用)。
|
|
304
|
+
|
|
305
|
+
## 实测记录
|
|
306
|
+
|
|
307
|
+
- 2026-08-09 · 沉浸模式唤出菜单:从「阅读」页点击本周阅读中的《Claude Code 源码解析》封面,进入沉浸阅读模式,满屏无 UI。点击窗口正中心后,顶部返回箭头和底部工具条同时出现,AX 吸附自动识别到「返回」按钮。再次点击中心后菜单隐藏。
|
|
308
|
+
- 2026-08-09 · 返回流程验证:在沉浸阅读模式下,点中心唤出菜单 → 点左上角返回箭头 → 成功回到「阅读」首页,底部四格标签栏可见。
|
|
309
|
+
- 2026-08-09 · bundleId 补充:macOS 桌面端微信读书的 bundleId 同时存在 `com.tencent.weread` 和 `com.tencent.wereadmac` 两种,match 列表中均已收录。
|
|
310
|
+
- 2026-08-06 · 页码位置与放大镜读数:窗口 `[36,44]-[932,862]`,
|
|
311
|
+
`magnify {x:36, y:817, width:896, height:45}` 裁出 4588×130 的横条,
|
|
312
|
+
页码 `81 / 116`、`84 / 115` 清晰可读。同一处在模型看到的全屏图上是约 5px 的马赛克。
|
|
313
|
+
- 2026-08-06 · 翻页键:连按 3 次 `right`,书从 15/106 翻到 21/106(6 页),
|
|
314
|
+
逐次前后差分 0.151 / 0.209 / 0.241。撞到书末后连续 10 次 `right` 全部精确 0.00。
|
|
315
|
+
- 2026-08-06 · 坐标锚参照系:按屏幕坐标点 `x=10,y=60` 找返回箭头 → 前台变成 Google Chrome。
|
|
316
|
+
按窗口算 `(33,82)`(窗口 `[20,48]-[916,864]`,即 `L+W×0.014, T+H×0.042`)一次命中。
|
|
317
|
+
- 2026-08-06 · 书架进书:停在书架页时,`observe → 点封面` 两个动作即进入正文。
|
|
318
|
+
同一任务停在【发现】页时改走搜索,用了 `click → return → click → hotkey×2 → type×3 →
|
|
319
|
+
click → click失败 → 重新激活 → click → click` 共十余个动作仍未进书。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Computer Use 状态、权限体检、应用说明书、遥测与审计
|
|
3
|
+
argument-hint: "[doctor|apps|app <name>|capture [name] [--write]|report|audit [n]|observe]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /computeruse
|
|
7
|
+
|
|
8
|
+
由 computer-use 插件接管(plugin.ts.runCommand),**全部子命令都是确定性的**,
|
|
9
|
+
不经过 LLM。
|
|
10
|
+
|
|
11
|
+
| 子命令 | 作用 |
|
|
12
|
+
|---|---|
|
|
13
|
+
| (空) | 总览:平台、守护进程、权限、能力三态分组、说明书写入目录 |
|
|
14
|
+
| `doctor` | 权限体检 + 逐项修复指引 |
|
|
15
|
+
| `apps` | 列出所有应用说明书、冲突,并指出当前前台应用命中哪一份 |
|
|
16
|
+
| `app <name>` | 打印某份说明书的摘要与校验报告 |
|
|
17
|
+
| `capture [name] [--write]` | 观测当前前台应用生成说明书草稿;默认只打印,`--write` 才落盘(写前确认、不覆盖已有文件) |
|
|
18
|
+
| `observe` | 跑一次观测,结果直接给你看 |
|
|
19
|
+
| `report` | 遥测汇总 |
|
|
20
|
+
| `audit [n]` | 守护进程审计流水 + 不可逆授权记录(两份并排,不合并) |
|
|
21
|
+
|
|
22
|
+
`/cu` 是等价别名。
|
|
23
|
+
|
|
24
|
+
**注意**:真正操作桌面用 `ComputerUse` 工具,不是这些命令。这里只做诊断与知识
|
|
25
|
+
管理——命令是给人用的,工具是给模型用的。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* plugins/computer_use/plugin.ts —— computer-use 插件入口
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 两件事:
|
|
6
|
+
* ① `app/` 下的应用说明书 —— 由内核 `vision/appGuide.ts::appManualProviders`
|
|
7
|
+
* 按目录约定发现,**不经过本文件**。工具在每次观测时强制注入,
|
|
8
|
+
* 模型没有「不看」这个选项。
|
|
9
|
+
* ② `/computeruse`(别名 `/cu`)—— 确定性的诊断与知识管理命令面。
|
|
10
|
+
*
|
|
11
|
+
* 刻意不实现 `activate()`:本插件没有需要在宿主启动时常驻的东西。
|
|
12
|
+
* ============================================================
|
|
13
|
+
*/
|
|
14
|
+
import { handleComputerUseCommand } from './src/commands.js';
|
|
15
|
+
const api = {
|
|
16
|
+
async *runCommand(commandName, args, ctx) {
|
|
17
|
+
if (commandName !== 'computeruse' && commandName !== 'cu') {
|
|
18
|
+
yield { type: 'error', error: `computer-use: 未知命令 /${commandName}` };
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const text = await handleComputerUseCommand(args, ctx.signal);
|
|
22
|
+
yield { type: 'text', delta: text };
|
|
23
|
+
yield { type: 'turn_done' };
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export default api;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* plugins/computer_use/plugin.ts —— computer-use 插件入口
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 两件事:
|
|
6
|
+
* ① `app/` 下的应用说明书 —— 由内核 `vision/appGuide.ts::appManualProviders`
|
|
7
|
+
* 按目录约定发现,**不经过本文件**。工具在每次观测时强制注入,
|
|
8
|
+
* 模型没有「不看」这个选项。
|
|
9
|
+
* ② `/computeruse`(别名 `/cu`)—— 确定性的诊断与知识管理命令面。
|
|
10
|
+
*
|
|
11
|
+
* 刻意不实现 `activate()`:本插件没有需要在宿主启动时常驻的东西。
|
|
12
|
+
* ============================================================
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { PluginApi } from '../../src/plugin-sdk.js';
|
|
16
|
+
import { handleComputerUseCommand } from './src/commands.js';
|
|
17
|
+
|
|
18
|
+
const api: PluginApi = {
|
|
19
|
+
async *runCommand(commandName, args, ctx) {
|
|
20
|
+
if (commandName !== 'computeruse' && commandName !== 'cu') {
|
|
21
|
+
yield { type: 'error', error: `computer-use: 未知命令 /${commandName}` };
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const text = await handleComputerUseCommand(args, ctx.signal);
|
|
25
|
+
yield { type: 'text', delta: text };
|
|
26
|
+
yield { type: 'turn_done' };
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default api;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* plugins/computer_use/src/capture.ts —— 把一次真实观测沉淀成说明书草稿
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 这条命令存在的理由是**闭环**:说明书里绝大多数内容目前是从面向人的文档
|
|
6
|
+
* 转写来的、没实机跑过。没有采集入口,「观察真实 App → 生成草稿 → 实机
|
|
7
|
+
* 校验 → 沉淀」这个提升成功率的循环就断在第一步。
|
|
8
|
+
*
|
|
9
|
+
* ★ 采集与写盘都在内核门面(`computerUseDiagnostics`)里:写盘要用户确认 +
|
|
10
|
+
* 原子写,若留在插件里,插件就得直接 import askBridge 与文件 API ——
|
|
11
|
+
* 刚收窄的 SDK 会立刻从别的路径重新变宽。本文件只负责**编排与呈现**。
|
|
12
|
+
*
|
|
13
|
+
* ★ 默认只打印。`--write` 才落盘,因为这是往用户项目里放文件。
|
|
14
|
+
* ============================================================
|
|
15
|
+
*/
|
|
16
|
+
import { computerUseDiagnostics } from '../../../src/plugin-sdk.js';
|
|
17
|
+
/**
|
|
18
|
+
* 解析 `capture [name] [--write]`。
|
|
19
|
+
*
|
|
20
|
+
* 名字可省:省了就由内核按前台应用的 bundleId 末段推。显式给名字的场景是
|
|
21
|
+
* 「我知道这份该叫什么」,比如已有 `wechat.md` 想重采一份对照。
|
|
22
|
+
*/
|
|
23
|
+
export function parseCaptureArgs(raw) {
|
|
24
|
+
const parts = raw.trim().split(/\s+/).filter(Boolean);
|
|
25
|
+
const write = parts.includes('--write');
|
|
26
|
+
const name = parts.find((part) => !part.startsWith('--'));
|
|
27
|
+
return { ...(name ? { name } : {}), write };
|
|
28
|
+
}
|
|
29
|
+
export async function runCapture(raw, signal) {
|
|
30
|
+
const args = parseCaptureArgs(raw);
|
|
31
|
+
const draft = await computerUseDiagnostics.captureDraft(args.name, signal);
|
|
32
|
+
// 内核在无法采集时返回一句人话(平台不支持 / 权限不足 / 拿不到前台应用),
|
|
33
|
+
// 不抛异常也不返回半个草稿 —— 「采不到」和「采到了但内容少」是两回事。
|
|
34
|
+
if (typeof draft === 'string')
|
|
35
|
+
return `# 采集说明书草稿\n\n${draft}`;
|
|
36
|
+
const sections = [
|
|
37
|
+
`# 采集说明书草稿:${draft.name}`,
|
|
38
|
+
'',
|
|
39
|
+
...renderWarnings(draft),
|
|
40
|
+
...(args.write ? await renderWriteResult(draft, signal) : renderPreview(draft)),
|
|
41
|
+
];
|
|
42
|
+
return sections.join('\n');
|
|
43
|
+
}
|
|
44
|
+
function renderWarnings(draft) {
|
|
45
|
+
if (draft.warnings.length === 0)
|
|
46
|
+
return [];
|
|
47
|
+
return ['## 采集时的情况', '', ...draft.warnings.map((warning) => `- ${warning}`), ''];
|
|
48
|
+
}
|
|
49
|
+
function renderPreview(draft) {
|
|
50
|
+
return [
|
|
51
|
+
'## 草稿',
|
|
52
|
+
'',
|
|
53
|
+
'```markdown',
|
|
54
|
+
draft.markdown.trimEnd(),
|
|
55
|
+
'```',
|
|
56
|
+
'',
|
|
57
|
+
'## 下一步',
|
|
58
|
+
'',
|
|
59
|
+
// 说清楚它是什么、不是什么。草稿看起来很像成品,这句话是防止它被当成成品。
|
|
60
|
+
'这份草稿里**只有应用身份是实测的**:控件候选来自采集当时的 AX 树、未经验证,',
|
|
61
|
+
'界面分区与典型流程是空的(一次观测看不出它们,编出来的比空着更糟)。',
|
|
62
|
+
'**不可逆动作清单也是空的** —— 屏幕上看不出「哪个动作收不回来」,那是产品语义,',
|
|
63
|
+
'必须由人补全;留空等于这个应用没有任何不可逆防护。',
|
|
64
|
+
'',
|
|
65
|
+
`想直接落盘到 \`${computerUseDiagnostics.manualDir()}\`,重跑一次并加 \`--write\`:`,
|
|
66
|
+
'',
|
|
67
|
+
` /computeruse capture ${draft.name} --write`,
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
async function renderWriteResult(draft, signal) {
|
|
71
|
+
const result = await computerUseDiagnostics.writeManualDraft(draft, signal);
|
|
72
|
+
if (result.ok) {
|
|
73
|
+
return [
|
|
74
|
+
'## 已写入',
|
|
75
|
+
'',
|
|
76
|
+
`✅ ${result.path}`,
|
|
77
|
+
'',
|
|
78
|
+
'它现在会被 `/computeruse apps` 与 ComputerUse 工具一起加载。',
|
|
79
|
+
'**请立刻补全 frontmatter 里的 `irreversible:` 清单** —— 空清单意味着这个应用',
|
|
80
|
+
'的任何操作都不会触发不可逆确认。',
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
return [
|
|
84
|
+
'## 未写入',
|
|
85
|
+
'',
|
|
86
|
+
`❌ ${result.error}`,
|
|
87
|
+
'',
|
|
88
|
+
'草稿没有丢:去掉 `--write` 重跑一次就能拿到完整内容自己保存。',
|
|
89
|
+
];
|
|
90
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* plugins/computer_use/src/capture.ts —— 把一次真实观测沉淀成说明书草稿
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 这条命令存在的理由是**闭环**:说明书里绝大多数内容目前是从面向人的文档
|
|
6
|
+
* 转写来的、没实机跑过。没有采集入口,「观察真实 App → 生成草稿 → 实机
|
|
7
|
+
* 校验 → 沉淀」这个提升成功率的循环就断在第一步。
|
|
8
|
+
*
|
|
9
|
+
* ★ 采集与写盘都在内核门面(`computerUseDiagnostics`)里:写盘要用户确认 +
|
|
10
|
+
* 原子写,若留在插件里,插件就得直接 import askBridge 与文件 API ——
|
|
11
|
+
* 刚收窄的 SDK 会立刻从别的路径重新变宽。本文件只负责**编排与呈现**。
|
|
12
|
+
*
|
|
13
|
+
* ★ 默认只打印。`--write` 才落盘,因为这是往用户项目里放文件。
|
|
14
|
+
* ============================================================
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { computerUseDiagnostics, type ManualDraft } from '../../../src/plugin-sdk.js';
|
|
18
|
+
|
|
19
|
+
export interface CaptureArgs {
|
|
20
|
+
name?: string;
|
|
21
|
+
write: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 解析 `capture [name] [--write]`。
|
|
26
|
+
*
|
|
27
|
+
* 名字可省:省了就由内核按前台应用的 bundleId 末段推。显式给名字的场景是
|
|
28
|
+
* 「我知道这份该叫什么」,比如已有 `wechat.md` 想重采一份对照。
|
|
29
|
+
*/
|
|
30
|
+
export function parseCaptureArgs(raw: string): CaptureArgs {
|
|
31
|
+
const parts = raw.trim().split(/\s+/).filter(Boolean);
|
|
32
|
+
const write = parts.includes('--write');
|
|
33
|
+
const name = parts.find((part) => !part.startsWith('--'));
|
|
34
|
+
return { ...(name ? { name } : {}), write };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function runCapture(raw: string, signal?: AbortSignal): Promise<string> {
|
|
38
|
+
const args = parseCaptureArgs(raw);
|
|
39
|
+
const draft = await computerUseDiagnostics.captureDraft(args.name, signal);
|
|
40
|
+
|
|
41
|
+
// 内核在无法采集时返回一句人话(平台不支持 / 权限不足 / 拿不到前台应用),
|
|
42
|
+
// 不抛异常也不返回半个草稿 —— 「采不到」和「采到了但内容少」是两回事。
|
|
43
|
+
if (typeof draft === 'string') return `# 采集说明书草稿\n\n${draft}`;
|
|
44
|
+
|
|
45
|
+
const sections = [
|
|
46
|
+
`# 采集说明书草稿:${draft.name}`,
|
|
47
|
+
'',
|
|
48
|
+
...renderWarnings(draft),
|
|
49
|
+
...(args.write ? await renderWriteResult(draft, signal) : renderPreview(draft)),
|
|
50
|
+
];
|
|
51
|
+
return sections.join('\n');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function renderWarnings(draft: ManualDraft): string[] {
|
|
55
|
+
if (draft.warnings.length === 0) return [];
|
|
56
|
+
return ['## 采集时的情况', '', ...draft.warnings.map((warning) => `- ${warning}`), ''];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function renderPreview(draft: ManualDraft): string[] {
|
|
60
|
+
return [
|
|
61
|
+
'## 草稿',
|
|
62
|
+
'',
|
|
63
|
+
'```markdown',
|
|
64
|
+
draft.markdown.trimEnd(),
|
|
65
|
+
'```',
|
|
66
|
+
'',
|
|
67
|
+
'## 下一步',
|
|
68
|
+
'',
|
|
69
|
+
// 说清楚它是什么、不是什么。草稿看起来很像成品,这句话是防止它被当成成品。
|
|
70
|
+
'这份草稿里**只有应用身份是实测的**:控件候选来自采集当时的 AX 树、未经验证,',
|
|
71
|
+
'界面分区与典型流程是空的(一次观测看不出它们,编出来的比空着更糟)。',
|
|
72
|
+
'**不可逆动作清单也是空的** —— 屏幕上看不出「哪个动作收不回来」,那是产品语义,',
|
|
73
|
+
'必须由人补全;留空等于这个应用没有任何不可逆防护。',
|
|
74
|
+
'',
|
|
75
|
+
`想直接落盘到 \`${computerUseDiagnostics.manualDir()}\`,重跑一次并加 \`--write\`:`,
|
|
76
|
+
'',
|
|
77
|
+
` /computeruse capture ${draft.name} --write`,
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function renderWriteResult(
|
|
82
|
+
draft: ManualDraft,
|
|
83
|
+
signal?: AbortSignal,
|
|
84
|
+
): Promise<string[]> {
|
|
85
|
+
const result = await computerUseDiagnostics.writeManualDraft(draft, signal);
|
|
86
|
+
if (result.ok) {
|
|
87
|
+
return [
|
|
88
|
+
'## 已写入',
|
|
89
|
+
'',
|
|
90
|
+
`✅ ${result.path}`,
|
|
91
|
+
'',
|
|
92
|
+
'它现在会被 `/computeruse apps` 与 ComputerUse 工具一起加载。',
|
|
93
|
+
'**请立刻补全 frontmatter 里的 `irreversible:` 清单** —— 空清单意味着这个应用',
|
|
94
|
+
'的任何操作都不会触发不可逆确认。',
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
return [
|
|
98
|
+
'## 未写入',
|
|
99
|
+
'',
|
|
100
|
+
`❌ ${result.error}`,
|
|
101
|
+
'',
|
|
102
|
+
'草稿没有丢:去掉 `--write` 重跑一次就能拿到完整内容自己保存。',
|
|
103
|
+
];
|
|
104
|
+
}
|