minimal-agent 0.8.2 → 0.10.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 +14 -12
- package/package.json +34 -1
- package/plugins/cron-runner/.claude-plugin/plugin.json +5 -0
- package/plugins/cron-runner/commands/cron.md +26 -0
- package/plugins/cron-runner/commands/crons.md +7 -0
- package/plugins/cron-runner/plugin.js +34 -0
- package/plugins/cron-runner/src/commands.js +348 -0
- package/plugins/cron-runner/src/cronTime.js +148 -0
- package/plugins/cron-runner/src/lock.js +68 -0
- package/plugins/cron-runner/src/runs.js +89 -0
- package/plugins/cron-runner/src/scheduleEngine.js +72 -0
- package/plugins/cron-runner/src/scheduler.js +355 -0
- package/plugins/cron-runner/src/schema.js +140 -0
- package/plugins/cron-runner/src/service.js +167 -0
- package/plugins/cron-runner/src/store.js +298 -0
- package/plugins/cron-runner/src/types.js +1 -0
- package/plugins/workflow-runner/commands/workflow.md +4 -4
- package/plugins/workflow-runner/commands/workflows.md +1 -1
- package/plugins/workflow-runner/plugin.js +3 -1
- package/plugins/workflow-runner/src/agentCommon.js +249 -51
- package/plugins/workflow-runner/src/dslManifest.js +72 -0
- package/plugins/workflow-runner/src/expressions.js +198 -15
- package/plugins/workflow-runner/src/index.js +40 -8
- package/plugins/workflow-runner/src/jsonPayload.js +1 -1
- package/plugins/workflow-runner/src/loader.js +286 -72
- package/plugins/workflow-runner/src/multimodal.js +37 -0
- package/plugins/workflow-runner/src/recovery.js +49 -39
- package/plugins/workflow-runner/src/runner.js +802 -287
- package/plugins/workflow-runner/src/stepExecutors/agent.js +157 -39
- package/plugins/workflow-runner/src/stepExecutors/assert.js +16 -3
- package/plugins/workflow-runner/src/stepExecutors/llm.js +60 -111
- package/plugins/workflow-runner/src/stepExecutors/skill.js +47 -47
- package/plugins/workflow-runner/src/stepExecutors/tool.js +76 -10
- package/plugins/workflow-runner/src/stepExecutors/verify.js +27 -10
- package/plugins/workflow-runner/src/taskIdentity.js +296 -0
- package/plugins/workflow-runner/src/types.js +19 -9
- package/plugins/workflow-runner/src/workflowState.js +516 -33
- package/skills/adversarial-review/SKILL.md +0 -1
- package/skills/ai-image/SKILL.md +89 -0
- package/skills/ai-image/scripts/generate.mjs +497 -0
- package/skills/ai-image/scripts/generate_from_plan.mjs +469 -0
- package/skills/ai-image/scripts/generate_from_plan_test.mjs +223 -0
- package/skills/ai-image/scripts/generate_test.mjs +74 -0
- package/skills/browser-automation/SKILL.md +47 -0
- package/skills/docx/SKILL.md +25 -3
- 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/docx/scripts/opc_check.py +253 -0
- package/skills/image-gen-openrouter/SKILL.md +10 -2
- package/skills/image-stats/SKILL.md +65 -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/image-stats/scripts/image_stats.py +368 -0
- package/skills/image-stats/scripts/image_stats_test.py +181 -0
- package/skills/pptx/SKILL.md +123 -95
- package/skills/pptx/design.md +82 -0
- package/skills/pptx/examples/README.md +29 -0
- package/skills/pptx/examples/hybrid_example.mjs +107 -0
- package/skills/pptx/examples/hybrid_example.pptx +0 -0
- package/skills/pptx/pptxgenjs.md +41 -0
- package/skills/pptx/scripts/deck_helpers.mjs +224 -0
- package/skills/pptx/scripts/layout_lint.py +293 -0
- package/skills/pptx/scripts/layout_lint_test.py +160 -0
- package/skills/pptx/scripts/opc_check.py +339 -0
- package/skills/pptx/scripts/svg_fallback.mjs +145 -0
- package/skills/pptx/svg.md +67 -0
- package/skills/tts-zh/SKILL.md +19 -2
- package/skills/ui-design/SKILL.md +158 -0
- package/skills/ui-design/claude_design.md +309 -0
- package/skills/ui-design/evals/evals.json +254 -0
- package/skills/ui-design/references/aesthetic-direction.md +83 -0
- package/skills/ui-design/references/claude-design-protocol.md +36 -0
- package/skills/ui-design/references/design-context.md +53 -0
- package/skills/ui-design/references/design-execution-playbook.md +82 -0
- package/skills/ui-design/references/export-pptx.md +124 -0
- package/skills/ui-design/references/layout-composition.md +654 -0
- package/skills/ui-design/references/preview-feedback.md +37 -0
- package/skills/ui-design/references/source-image-layout.md +189 -0
- package/skills/ui-design/references/starter-components.md +78 -0
- package/skills/ui-design/references/vi-aegis-vector.md +144 -0
- package/skills/ui-design/references/vi-amber-prism.md +133 -0
- package/skills/ui-design/references/vi-aqua-glass.md +200 -0
- package/skills/ui-design/references/vi-comfort-vision.md +147 -0
- package/skills/ui-design/references/vi-ember-prism.md +140 -0
- package/skills/ui-design/references/vi-nebula-console.md +151 -0
- package/skills/ui-design/references/vi-obsidian-optics.md +139 -0
- package/skills/ui-design/references/vi-obsidian-xui.md +143 -0
- package/skills/ui-design/references/vi-precision-horizon-dark.md +117 -0
- package/skills/ui-design/references/vi-precision-horizon.md +215 -0
- package/skills/ui-design/references/vi-solar-relay.md +130 -0
- package/skills/ui-design/references/vi-template-workflow.md +48 -0
- package/skills/ui-design/references/vi-verdant-grid.md +141 -0
- package/skills/ui-design/references/vi-violet-meridian.md +172 -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/ui-design/scripts/assemble_material.py +217 -0
- package/skills/ui-design/scripts/assemble_material_test.py +149 -0
- package/skills/ui-design/scripts/browser_check_ui_artifact.mjs +221 -0
- package/skills/ui-design/scripts/chart_sanity_check.py +261 -0
- package/skills/ui-design/scripts/chart_sanity_check_test.py +165 -0
- package/skills/ui-design/scripts/check_language_policy.py +351 -0
- package/skills/ui-design/scripts/check_ui_artifact.py +435 -0
- package/skills/ui-design/scripts/check_ui_artifact_pptx_test.py +251 -0
- package/skills/ui-design/scripts/deck_pages_check.py +158 -0
- package/skills/ui-design/scripts/deck_pages_check_test.py +134 -0
- package/skills/ui-design/scripts/deck_visual_style_check.py +767 -0
- package/skills/ui-design/scripts/deck_visual_style_check_test.py +713 -0
- package/skills/ui-design/scripts/design_budget_check.py +271 -0
- package/skills/ui-design/scripts/design_budget_check_test.py +183 -0
- package/skills/ui-design/scripts/design_repair_hints.py +162 -0
- package/skills/ui-design/scripts/design_repair_hints_test.py +54 -0
- package/skills/ui-design/scripts/design_style_check.py +397 -0
- package/skills/ui-design/scripts/design_style_check_test.py +233 -0
- package/skills/ui-design/scripts/draft_coverage_check.py +184 -0
- package/skills/ui-design/scripts/draft_coverage_check_test.py +131 -0
- package/skills/ui-design/scripts/export_pptx_from_html.mjs +2367 -0
- package/skills/ui-design/scripts/extract_source_assets.py +607 -0
- package/skills/ui-design/scripts/extract_source_assets_test.py +256 -0
- package/skills/ui-design/scripts/generated_image_review_collect.py +206 -0
- package/skills/ui-design/scripts/generated_image_review_collect_test.py +91 -0
- package/skills/ui-design/scripts/image_plan_lint.py +571 -0
- package/skills/ui-design/scripts/image_plan_lint_test.py +515 -0
- package/skills/ui-design/scripts/image_prompt_rewrite.py +713 -0
- package/skills/ui-design/scripts/image_prompt_rewrite_test.py +966 -0
- package/skills/ui-design/scripts/layout_balance.py +881 -0
- package/skills/ui-design/scripts/layout_balance_test.py +927 -0
- package/skills/ui-design/scripts/normalize_design_json.py +272 -0
- package/skills/ui-design/scripts/normalize_design_json_test.py +119 -0
- package/skills/ui-design/scripts/plan_source_layout.py +1450 -0
- package/skills/ui-design/scripts/plan_source_layout_test.py +1136 -0
- package/skills/ui-design/scripts/resolve_source_input.py +270 -0
- package/skills/ui-design/scripts/resolve_source_input_test.py +98 -0
- package/skills/ui-design/scripts/scaffold_ui_artifact.py +377 -0
- package/skills/ui-design/scripts/source_usage_check.py +581 -0
- package/skills/ui-design/scripts/source_usage_check_test.py +427 -0
- package/skills/ui-design/scripts/text_readability_pixel.py +340 -0
- package/skills/ui-design/scripts/text_readability_pixel_test.py +219 -0
- package/skills/ui-design/scripts/visual_quality_gate.py +301 -0
- package/skills/ui-design/scripts/visual_quality_gate_test.py +233 -0
- package/skills/ui-design/tests/e2e/prompts/deck.md +19 -0
- package/skills/ui-design/tests/e2e/prompts/webpage.md +17 -0
- package/skills/ui-design/tests/e2e/render_check.mjs +101 -0
- package/skills/ui-design/tests/e2e/rubric.json +54 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/checks/language-check.txt +12 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/checks/static-check.txt +15 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/outputs/index.html +837 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/prompt.md +12 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/review.md +21 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/outputs/homepage.html +373 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/outputs/platform.html +378 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/review.md +26 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/homepage/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/homepage/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/homepage/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/platform/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/platform/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/platform/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/outputs/index.html +656 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/prompt.md +12 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/render_check.mjs +67 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/outputs/index.html +587 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/prompt.md +12 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/review.md +36 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/checks/language-check.txt +8 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/checks/static-check.txt +16 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/outputs/index.html +739 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/prompt.md +11 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/review.md +22 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/checks/browser-check.json +52 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/outputs/index.html +641 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/outputs/index.html +467 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/screenshots/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/outputs/homepage.html +373 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/outputs/platform.html +378 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/review.md +26 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/homepage/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/homepage/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/homepage/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/platform/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/platform/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/platform/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/checks/language-check.txt +4 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/execution_notes.md +10 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/outputs/index.html +587 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/prompt.md +14 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/review.md +13 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/checks/browser-check.json +24 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/execution_notes.md +21 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/outputs/deck.html +451 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/screenshots/slide-01.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/screenshots/slide-02.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/review.md +79 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/checks/browser-check.json +26 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/execution_notes.md +20 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/outputs/index.html +534 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/browser-check.json +64 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/language-check.txt +7 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/static-console.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/static-homepage.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/outputs/console.html +600 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/outputs/homepage.html +556 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/prompt.md +29 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/review.md +57 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/console-desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/console-mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/homepage-desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/homepage-mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/browser-check.json +33 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/language-check.txt +6 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/outputs/index.html +682 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/review.md +59 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/outputs/page-01.html +466 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/outputs/page-02.html +433 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-01/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-01/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-01/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-02/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-02/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-02/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/checks/language-check.txt +3 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/execution_notes.md +24 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/outputs/index.html +723 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/prompt.md +15 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/review.md +26 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/browser-dark.json +49 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/browser-light.json +49 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/language-check.txt +11 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/static-dark.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/static-light.txt +3 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/execution_notes.md +23 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/outputs/dark.html +392 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/outputs/light.html +476 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/prompt.md +23 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/review.md +41 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/dark/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/dark/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/light/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/light/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/browser-check.json +54 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/language-check.txt +5 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/outputs/index.html +765 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/prompt.md +15 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/review.md +59 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/outputs/index.html +508 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/screenshots/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/browser-check.json +54 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/language-check.txt +6 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/outputs/index.html +788 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/prompt.md +14 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/review.md +60 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/screenshots/mobile.png +0 -0
- package/skills/video-compose/SKILL.md +8 -1
- package/skills/web-crawler/SKILL.md +70 -0
- package/skills/web-crawler/scripts/crawl.mjs +538 -0
- package/skills/web-crawler/scripts/crawl.test.mjs +204 -0
- package/skills/xlsx/SKILL.md +12 -0
- package/skills/xlsx/scripts/opc_check.py +253 -0
- package/src/advisorState.js +22 -0
- package/src/askBridge.js +97 -3
- package/src/bootstrap/workingDir.js +12 -1
- package/src/cli/args.js +17 -1
- package/src/cli/configMenu.js +236 -0
- package/src/cli/configWizard.js +7 -5
- package/src/cli/print.js +37 -4
- package/src/cli/streamJson.js +77 -24
- package/src/cli/wizards/advisorWizard.js +147 -0
- package/src/cli/wizards/fieldForm.js +149 -0
- package/src/cli/wizards/imageWizard.js +60 -0
- package/src/cli/wizards/openRouterWizard.js +23 -0
- package/src/cli/wizards/providerPresets.js +95 -0
- package/src/cli/wizards/providerWizard.js +219 -0
- package/src/cli/wizards/searchWizard.js +23 -0
- package/src/cli/wizards/ttsWizard.js +34 -0
- package/src/config/configFile.js +441 -83
- package/src/config/configService.js +446 -0
- package/src/config.js +24 -64
- package/src/context/agentHome.js +9 -0
- package/src/context/archive.js +7 -2
- package/src/context/compact.js +8 -5
- package/src/context/contextLock.js +81 -0
- package/src/context/persistContext.js +30 -11
- package/src/context/reactiveCompact.js +4 -2
- package/src/context/recentDirs.js +21 -61
- package/src/context/sessionPath.js +97 -23
- package/src/context/sessionRegistry.js +303 -24
- package/src/context/tokenCounter.js +18 -0
- package/src/context/workspaceIndex.js +731 -0
- package/src/infra/verification.js +28 -15
- package/src/llm/client.js +394 -159
- package/src/llm/providers/anthropicFormat.js +241 -0
- package/src/llm/providers/openaiFormat.js +190 -0
- package/src/loop.js +219 -32
- package/src/main.js +61 -11
- package/src/messageQueue.js +97 -0
- package/src/multimodal.js +203 -0
- package/src/plugin-sdk.js +15 -0
- package/src/plugins/commandRouter.js +3 -0
- package/src/plugins/hookEngine.js +5 -1
- package/src/plugins/pluginLifecycle.js +28 -0
- package/src/plugins/pluginLoader.js +2 -1
- package/src/plugins/pluginRunner.js +49 -21
- package/src/plugins/transcript.js +4 -3
- package/src/prompts/pluginList.js +5 -5
- package/src/prompts/projectInstructions.js +3 -3
- package/src/prompts/promptAssembly.js +133 -144
- package/src/prompts/skillList.js +12 -22
- package/src/prompts/system.js +0 -1
- package/src/session/runAgentTurn.js +70 -0
- package/src/session/runTurn.js +41 -6
- package/src/toolGate.js +17 -0
- package/src/tools/advisor/advisor.js +379 -0
- package/src/tools/agent/agent.js +555 -0
- package/src/tools/agent/agentTypes.js +59 -0
- package/src/tools/agent/coordinator.js +93 -0
- package/src/tools/agent/worktree.js +270 -0
- package/src/tools/ask/ask.js +7 -2
- package/src/tools/bash/bash.js +112 -18
- package/src/tools/download/download.js +144 -0
- package/src/tools/edit/edit.js +1 -0
- package/src/tools/edit/multi-edit.js +1 -0
- package/src/tools/genimage/genimage.js +242 -0
- package/src/tools/genspeech/genspeech.js +67 -0
- package/src/tools/glob/glob.js +1 -0
- package/src/tools/grep/grep.js +3 -0
- package/src/tools/grep/rgPath.js +2 -0
- package/src/tools/index.js +25 -2
- package/src/tools/read/read.js +1 -0
- package/src/tools/shared/killTree.js +52 -0
- package/src/tools/toolProgressBridge.js +48 -0
- package/src/tools/webbrowser/agentBrowserPath.js +258 -0
- package/src/tools/webbrowser/browser.js +59 -42
- package/src/tools/webbrowser/browserControl.js +118 -0
- package/src/tools/webbrowser/browserDaemon.js +97 -0
- package/src/tools/webbrowser/browserService.js +27 -0
- package/src/tools/webbrowser/browserStream.js +119 -0
- package/src/tools/webbrowser/webbrowser.js +699 -130
- package/src/tools/webfetch/webfetch.js +1 -0
- package/src/tools/websearch/websearch.js +134 -51
- package/src/tools/write/write.js +1 -0
- package/src/ui/App.js +249 -22
- package/src/ui/AskQuestion.js +29 -10
- package/src/ui/InputBox.js +104 -12
- package/src/ui/LiveArea.js +112 -19
- package/src/ui/MessageList.js +100 -14
- package/src/ui/ModelPicker.js +56 -0
- package/src/ui/QueuedMessagesBanner.js +14 -0
- package/src/ui/Root.js +18 -10
- package/src/ui/SessionPicker.js +102 -0
- package/src/ui/StatusLine.js +13 -4
- package/src/ui/WorkspacePicker.js +55 -0
- package/src/ui/figures.js +44 -0
- package/src/ui/hooks/askSlot.js +82 -0
- package/src/ui/hooks/useChat.js +358 -64
- package/src/ui/hooks/usePasteHandler.js +11 -1
- package/src/ui/hooks/useTextBuffer.js +1 -3
- package/src/ui/liveViewport.js +5 -1
- package/src/ui/markdown.js +206 -0
- package/src/ui/textBuffer.js +0 -7
- package/src/ui/theme.js +32 -0
- package/src/utils/debugLog.js +0 -4
- package/src/utils/resourcePaths.js +2 -2
- package/src/utils/stripThink.js +50 -0
- package/src/web/browserBridge.js +447 -0
- package/src/web/protocol.js +19 -0
- package/workflows/adaptive-research.yaml +13 -5
- package/workflows/book-review-short.yaml +36 -10
- package/workflows/e2e-write-greet.yaml +6 -2
- package/workflows/illustrate.yaml +227 -0
- package/workflows/plan.yaml +460 -179
- package/workflows/ppt.yaml +1659 -0
- package/workflows/ralph-loop.yaml +199 -0
- package/workflows/schema.json +81 -23
- package/workflows/webppt.yaml +496 -0
- package/workflows/word.yaml +710 -0
- package/workflows/youtube-shorts.yaml +46 -15
- package/MINIMAL-TRACE.md +0 -77
- package/plugins/HOW-TO-WRITE-A-PLUGIN.md +0 -186
- package/plugins/ralph-wiggum/.claude-plugin/plugin.json +0 -9
- package/plugins/ralph-wiggum/README.md +0 -197
- package/plugins/ralph-wiggum/commands/cancel-ralph.md +0 -18
- package/plugins/ralph-wiggum/commands/help.md +0 -137
- package/plugins/ralph-wiggum/commands/ralph-loop.md +0 -85
- package/plugins/ralph-wiggum/hooks/hooks.json +0 -15
- package/plugins/ralph-wiggum/hooks/stop-hook.sh +0 -191
- package/plugins/ralph-wiggum/plugin.js +0 -280
- package/plugins/ralph-wiggum/src/goalState.js +0 -258
- package/plugins/ralph-wiggum/src/sentinels.js +0 -76
- package/plugins/ralph-wiggum/src/stopHookRunner.js +0 -104
- package/plugins/ralph-wiggum/src/verificationGate.js +0 -202
- package/plugins/workflow-runner/src/miniReAct.js +0 -223
- package/plugins/workflow-runner/src/voteHelpers.js +0 -110
- package/skills/config/SKILL.md +0 -123
- package/skills/frontend-design/LICENSE.txt +0 -177
- package/skills/frontend-design/SKILL.md +0 -42
- package/src/ui/ProgressPanel.js +0 -54
- package/src/ui/StreamingBlock.js +0 -11
- package/src/ui/ToolStatus.js +0 -11
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
assemble_material.py —— 把摄取阶段的多份产物确定性合并成「用户原始材料」统一中间文件。
|
|
5
|
+
|
|
6
|
+
为什么需要
|
|
7
|
+
==========
|
|
8
|
+
ppt 工作流摄取阶段分三步采集事实:① extract_source_assets.py 抽文字+图片+base manifest;
|
|
9
|
+
② image-stats 算图像统计;③ 多模态逐图识图写 vision/*.json。这三份分散的事实必须**确定性**合并成
|
|
10
|
+
一份下游全程都吃的统一材料(文字 + 每张图的 路径/识图详述/重点区/统计),不该再开 LLM 步去「复述拼接」
|
|
11
|
+
(会改写、会丢字、会幻觉)。同 image_plan_lint / extract_source_assets 哲学:机械合并交脚本。
|
|
12
|
+
|
|
13
|
+
合并什么 → 产出什么(都在 --build 目录,默认 ./build)
|
|
14
|
+
====================================================
|
|
15
|
+
读:source_assets.json(base manifest)+ source.md(文字主干)+ source_stats.json(image-stats --json 数组)
|
|
16
|
+
+ vision/<file>.json(逐图识图,可缺)
|
|
17
|
+
写:
|
|
18
|
+
- material.md :人/LLM 读——文字主干 + 每张图一块(路径+来源+朝向+识图详述+重点区+建议文字位+统计)
|
|
19
|
+
- material.json :机读富 manifest——images[] 每条在 base 字段上并入 stats / vision(缺则 null)
|
|
20
|
+
|
|
21
|
+
容缺:统计 / 识图 缺失时该图只记已有信息(标注「未完成」),绝不报错——识图依赖多模态模型,
|
|
22
|
+
文本模型跑不了视觉时本步要能优雅产出「只有文字+统计」的材料。
|
|
23
|
+
|
|
24
|
+
退出码:0(恒成功,缺源也写 has_source:false 的空材料)。只用标准库。
|
|
25
|
+
|
|
26
|
+
用法
|
|
27
|
+
====
|
|
28
|
+
python assemble_material.py [--build ./build]
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
import argparse
|
|
32
|
+
import json
|
|
33
|
+
import os
|
|
34
|
+
import sys
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _load_json(path, default=None):
|
|
38
|
+
# utf-8-sig:既读普通 UTF-8,也容忍带 BOM 的产物(某些工具/重定向会写 BOM)。
|
|
39
|
+
try:
|
|
40
|
+
with open(path, encoding="utf-8-sig") as f:
|
|
41
|
+
return json.load(f)
|
|
42
|
+
except Exception:
|
|
43
|
+
return default
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _stats_by_file(stats_list):
|
|
47
|
+
"""image-stats --json 数组 → {basename(path): stats}。"""
|
|
48
|
+
out = {}
|
|
49
|
+
if isinstance(stats_list, list):
|
|
50
|
+
for s in stats_list:
|
|
51
|
+
if isinstance(s, dict) and isinstance(s.get("path"), str):
|
|
52
|
+
out[os.path.basename(s["path"])] = s
|
|
53
|
+
return out
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _fmt_region(kr):
|
|
57
|
+
if not isinstance(kr, dict):
|
|
58
|
+
return None
|
|
59
|
+
try:
|
|
60
|
+
return (
|
|
61
|
+
f"x{float(kr.get('x', 0)):.2f} y{float(kr.get('y', 0)):.2f} "
|
|
62
|
+
f"w{float(kr.get('w', 0)):.2f} h{float(kr.get('h', 0)):.2f}"
|
|
63
|
+
)
|
|
64
|
+
except Exception:
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _fmt_stats_line(stats):
|
|
69
|
+
if not isinstance(stats, dict):
|
|
70
|
+
return "(统计缺失)"
|
|
71
|
+
parts = []
|
|
72
|
+
ac = stats.get("average_color")
|
|
73
|
+
if isinstance(ac, dict) and ac.get("hex"):
|
|
74
|
+
parts.append(f"平均色 {ac['hex']}")
|
|
75
|
+
doms = stats.get("dominant_colors")
|
|
76
|
+
if isinstance(doms, list) and doms:
|
|
77
|
+
hexes = " ".join(d.get("hex", "") for d in doms[:4] if isinstance(d, dict))
|
|
78
|
+
if hexes.strip():
|
|
79
|
+
parts.append(f"主色 {hexes}")
|
|
80
|
+
tone = stats.get("tone")
|
|
81
|
+
if isinstance(tone, dict) and tone.get("category"):
|
|
82
|
+
parts.append(f"色调 {tone['category']}")
|
|
83
|
+
bri = stats.get("brightness")
|
|
84
|
+
if isinstance(bri, dict) and bri.get("mean") is not None:
|
|
85
|
+
parts.append(f"平均亮度 {bri['mean']}/255")
|
|
86
|
+
return " | ".join(parts) if parts else "(统计缺失)"
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _image_md_block(n, img):
|
|
90
|
+
"""单张图在 material.md 里的一块。"""
|
|
91
|
+
L = []
|
|
92
|
+
L.append(f"\n### 图 {n}:{img['path']}\n")
|
|
93
|
+
meta = (
|
|
94
|
+
f"- 来源:{img.get('origin', '?')} | 章节:{img.get('section', '?')} | "
|
|
95
|
+
f"朝向:{img.get('orient', '?')}({img.get('w', '?')}×{img.get('h', '?')},比例 {img.get('aspect_ratio', '?')})"
|
|
96
|
+
)
|
|
97
|
+
L.append(meta)
|
|
98
|
+
if img.get("near_text"):
|
|
99
|
+
L.append(f"- 邻近文案:{img['near_text']}")
|
|
100
|
+
vision = img.get("vision")
|
|
101
|
+
if isinstance(vision, dict):
|
|
102
|
+
if vision.get("description"):
|
|
103
|
+
L.append(f"- 识图:{vision['description']}")
|
|
104
|
+
ke = vision.get("key_elements")
|
|
105
|
+
if isinstance(ke, list) and ke:
|
|
106
|
+
L.append(f"- 重点元素:{', '.join(str(x) for x in ke)}")
|
|
107
|
+
region = _fmt_region(vision.get("key_region"))
|
|
108
|
+
if region:
|
|
109
|
+
zone = vision.get("recommended_text_zone")
|
|
110
|
+
tail = f"(建议文字放 {zone}、勿压此区)" if zone else ""
|
|
111
|
+
L.append(f"- 重点区域(归一化):{region}{tail}")
|
|
112
|
+
if vision.get("suitable_as_background") is not None:
|
|
113
|
+
L.append(f"- 适合做背景:{'是' if vision['suitable_as_background'] else '否'}")
|
|
114
|
+
if vision.get("palette_impression"):
|
|
115
|
+
L.append(f"- 配色印象:{vision['palette_impression']}")
|
|
116
|
+
if vision.get("key_message"):
|
|
117
|
+
L.append(f"- 🚨 图表核心结论(须体现在 draft.md 论点/证据里):{vision['key_message']}")
|
|
118
|
+
dp = vision.get("data_points")
|
|
119
|
+
if isinstance(dp, list) and dp:
|
|
120
|
+
L.append(f"- 关键数据点:{', '.join(str(x) for x in dp)}")
|
|
121
|
+
et = vision.get("embedded_text")
|
|
122
|
+
if isinstance(et, list) and et:
|
|
123
|
+
quoted = "、".join(
|
|
124
|
+
f"「{it.get('text')}」" for it in et if isinstance(it, dict) and it.get("text")
|
|
125
|
+
)
|
|
126
|
+
if quoted:
|
|
127
|
+
L.append(f"- 图上原有文字(图生图阶段会被去除,写稿时若信息有价值应整合进正文):{quoted}")
|
|
128
|
+
if vision.get("notes"):
|
|
129
|
+
L.append(f"- 备注:{vision['notes']}")
|
|
130
|
+
else:
|
|
131
|
+
L.append("- 识图:(未完成——无多模态模型或本图识图失败)")
|
|
132
|
+
L.append(f"- 图像统计:{_fmt_stats_line(img.get('stats'))}")
|
|
133
|
+
return "\n".join(L)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def assemble(build_dir):
|
|
137
|
+
build_dir = os.path.abspath(build_dir)
|
|
138
|
+
manifest = _load_json(os.path.join(build_dir, "source_assets.json"), {})
|
|
139
|
+
has_source = bool(manifest.get("has_source"))
|
|
140
|
+
base_images = manifest.get("images") or []
|
|
141
|
+
stats_map = _stats_by_file(_load_json(os.path.join(build_dir, "source_stats.json"), []))
|
|
142
|
+
|
|
143
|
+
source_md = ""
|
|
144
|
+
p = os.path.join(build_dir, "source.md")
|
|
145
|
+
if os.path.isfile(p):
|
|
146
|
+
with open(p, encoding="utf-8") as f:
|
|
147
|
+
source_md = f.read().strip()
|
|
148
|
+
|
|
149
|
+
merged_images = []
|
|
150
|
+
for img in base_images:
|
|
151
|
+
if not isinstance(img, dict) or not img.get("file"):
|
|
152
|
+
continue
|
|
153
|
+
file = img["file"]
|
|
154
|
+
vision_path = os.path.join(build_dir, "vision", f"{file}.json")
|
|
155
|
+
vision = _load_json(vision_path)
|
|
156
|
+
# 识图 JSON 缺失/非法必须响亮(2026-07-02 事故:src_6 识图正确写出了「旧 PPT 截图勿覆盖文字」,
|
|
157
|
+
# 但 LLM 落盘的 JSON 引号未转义 → 这里静默吞成 None → 规划器盲态把整版截图当无字普通图铺背景)。
|
|
158
|
+
# 仍不阻断(识图是增强信息、盲态有保守分支),但逐图打 WARNING 让工作流日志/用户看得见。
|
|
159
|
+
if not isinstance(vision, dict):
|
|
160
|
+
if os.path.isfile(vision_path):
|
|
161
|
+
print(f"WARNING: {file}: vision JSON 非法(解析失败)——识图结论丢失,规划将按盲态保守处理")
|
|
162
|
+
else:
|
|
163
|
+
print(f"WARNING: {file}: vision JSON 缺失——识图未跑或未落盘,规划将按盲态保守处理")
|
|
164
|
+
merged = dict(img)
|
|
165
|
+
merged["path"] = f"assets/{file}"
|
|
166
|
+
merged["stats"] = stats_map.get(file)
|
|
167
|
+
merged["vision"] = vision if isinstance(vision, dict) else None
|
|
168
|
+
merged_images.append(merged)
|
|
169
|
+
|
|
170
|
+
material = {
|
|
171
|
+
"has_source": has_source,
|
|
172
|
+
"sources": manifest.get("sources") or [],
|
|
173
|
+
"text_file": "material.md",
|
|
174
|
+
"images": merged_images,
|
|
175
|
+
}
|
|
176
|
+
with open(os.path.join(build_dir, "material.json"), "w", encoding="utf-8") as f:
|
|
177
|
+
json.dump(material, f, ensure_ascii=False, indent=2)
|
|
178
|
+
|
|
179
|
+
# material.md
|
|
180
|
+
md = ["# 用户原始材料(统一中间形式)\n"]
|
|
181
|
+
md.append(
|
|
182
|
+
"> 确定性合并:文档/表格文字 + 每张图片(路径 + LLM 识图详述 + 图像统计)。"
|
|
183
|
+
"下游研究/设计/配图全程以此为准;**所有客户图片都必须用进 PPT**。\n"
|
|
184
|
+
)
|
|
185
|
+
md.append("\n## 一、文字内容\n")
|
|
186
|
+
md.append(source_md if source_md else "(无文档文字——纯图片 / 纯 topic 输入)")
|
|
187
|
+
md.append(f"\n\n## 二、图片素材({len(merged_images)} 张,均须用进 PPT)\n")
|
|
188
|
+
if merged_images:
|
|
189
|
+
for i, img in enumerate(merged_images, 1):
|
|
190
|
+
md.append(_image_md_block(i, img))
|
|
191
|
+
else:
|
|
192
|
+
md.append("\n(无客户图片)")
|
|
193
|
+
with open(os.path.join(build_dir, "material.md"), "w", encoding="utf-8") as f:
|
|
194
|
+
f.write("\n".join(md).strip() + "\n")
|
|
195
|
+
|
|
196
|
+
return material
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def main() -> int:
|
|
200
|
+
parser = argparse.ArgumentParser(
|
|
201
|
+
description="合并 source.md + manifest + 统计 + 识图 → material.md/json(确定性)"
|
|
202
|
+
)
|
|
203
|
+
parser.add_argument("--build", default="./build", help="摄取产物目录(默认 ./build)")
|
|
204
|
+
args = parser.parse_args()
|
|
205
|
+
|
|
206
|
+
material = assemble(args.build)
|
|
207
|
+
n_vision = sum(1 for im in material["images"] if im.get("vision"))
|
|
208
|
+
n_stats = sum(1 for im in material["images"] if im.get("stats"))
|
|
209
|
+
print(
|
|
210
|
+
f"MATERIAL_ASSEMBLED: {len(material['images'])} 张图(识图 {n_vision}、统计 {n_stats})"
|
|
211
|
+
f"、has_source={material['has_source']} → {os.path.join(args.build, 'material.json')}"
|
|
212
|
+
)
|
|
213
|
+
return 0
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
if __name__ == "__main__":
|
|
217
|
+
sys.exit(main())
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
assemble_material_test.py —— assemble_material.py 单测(合成 manifest/stats/vision 断言合并 + 容缺)。
|
|
5
|
+
|
|
6
|
+
锁定:
|
|
7
|
+
- material.json:images[] 在 base 字段上并入 stats(按 basename 对齐)/ vision(按 file 对齐)。
|
|
8
|
+
- material.md:含文字主干 + 每图块(路径/朝向/识图详述/重点区/统计)。
|
|
9
|
+
- 容缺:某图缺 vision / 缺 stats 时该图 vision/stats=null、md 标注「未完成/缺失」,不报错。
|
|
10
|
+
- 无 source_assets.json → has_source:false 的空材料,退出 0。
|
|
11
|
+
依赖:标准库。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
import tempfile
|
|
18
|
+
import unittest
|
|
19
|
+
|
|
20
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
21
|
+
import assemble_material as am # noqa: E402
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _write(path, obj):
|
|
25
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
26
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
27
|
+
if isinstance(obj, str):
|
|
28
|
+
f.write(obj)
|
|
29
|
+
else:
|
|
30
|
+
json.dump(obj, f, ensure_ascii=False)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TestAssemble(unittest.TestCase):
|
|
34
|
+
def setUp(self):
|
|
35
|
+
self.build = os.path.join(tempfile.mkdtemp(prefix="assemble-"), "build")
|
|
36
|
+
os.makedirs(self.build, exist_ok=True)
|
|
37
|
+
|
|
38
|
+
def _seed_full(self):
|
|
39
|
+
_write(os.path.join(self.build, "source.md"), "# 来源:brief.pptx\n## 产品概览\n相机很强。")
|
|
40
|
+
_write(os.path.join(self.build, "source_assets.json"), {
|
|
41
|
+
"has_source": True, "sources": ["brief.pptx"], "text_file": "source.md",
|
|
42
|
+
"images": [
|
|
43
|
+
{"file": "src_1.png", "w": 1920, "h": 1080, "aspect_ratio": 1.78,
|
|
44
|
+
"orient": "landscape", "section": "产品概览", "near_text": "相机特写",
|
|
45
|
+
"origin": "brief.pptx#slide3"},
|
|
46
|
+
{"file": "src_2.png", "w": 600, "h": 1000, "aspect_ratio": 0.6,
|
|
47
|
+
"orient": "portrait", "section": "细节", "near_text": "", "origin": "brief.pptx#slide5"},
|
|
48
|
+
],
|
|
49
|
+
})
|
|
50
|
+
_write(os.path.join(self.build, "source_stats.json"), [
|
|
51
|
+
{"path": "./build/assets/src_1.png",
|
|
52
|
+
"average_color": {"hex": "#334455"}, "tone": {"category": "cool"},
|
|
53
|
+
"brightness": {"mean": 88}, "dominant_colors": [{"hex": "#112233"}]},
|
|
54
|
+
{"path": "./build/assets/src_2.png",
|
|
55
|
+
"average_color": {"hex": "#AABBCC"}, "tone": {"category": "warm"},
|
|
56
|
+
"brightness": {"mean": 180}, "dominant_colors": [{"hex": "#FFAA00"}]},
|
|
57
|
+
])
|
|
58
|
+
# 只给 src_1 识图(src_2 故意缺 → 测容缺)
|
|
59
|
+
_write(os.path.join(self.build, "vision", "src_1.png.json"), {
|
|
60
|
+
"description": "一块电路板特写", "key_elements": ["电容", "芯片"],
|
|
61
|
+
"key_region": {"x": 0.3, "y": 0.2, "w": 0.45, "h": 0.5},
|
|
62
|
+
"suitable_as_background": False, "recommended_text_zone": "right",
|
|
63
|
+
"palette_impression": "冷色金属", "notes": "右上留白",
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
def test_merge_full(self):
|
|
67
|
+
self._seed_full()
|
|
68
|
+
m = am.assemble(self.build)
|
|
69
|
+
self.assertTrue(m["has_source"])
|
|
70
|
+
self.assertEqual(len(m["images"]), 2)
|
|
71
|
+
i1 = m["images"][0]
|
|
72
|
+
self.assertEqual(i1["path"], "assets/src_1.png")
|
|
73
|
+
# stats 按 basename 对齐
|
|
74
|
+
self.assertEqual(i1["stats"]["average_color"]["hex"], "#334455")
|
|
75
|
+
# vision 按 file 对齐
|
|
76
|
+
self.assertEqual(i1["vision"]["description"], "一块电路板特写")
|
|
77
|
+
self.assertEqual(i1["vision"]["key_region"]["w"], 0.45)
|
|
78
|
+
# material.json / material.md 落盘
|
|
79
|
+
self.assertTrue(os.path.isfile(os.path.join(self.build, "material.json")))
|
|
80
|
+
with open(os.path.join(self.build, "material.md"), encoding="utf-8") as f:
|
|
81
|
+
md = f.read()
|
|
82
|
+
self.assertIn("产品概览", md) # 文字主干
|
|
83
|
+
self.assertIn("assets/src_1.png", md) # 图块路径
|
|
84
|
+
self.assertIn("一块电路板特写", md) # 识图详述
|
|
85
|
+
self.assertIn("色调 cool", md) # 统计
|
|
86
|
+
|
|
87
|
+
def test_graceful_missing_vision_and_stats(self):
|
|
88
|
+
self._seed_full()
|
|
89
|
+
m = am.assemble(self.build)
|
|
90
|
+
i2 = m["images"][1] # src_2 缺 vision,但有 stats
|
|
91
|
+
self.assertIsNone(i2["vision"])
|
|
92
|
+
self.assertEqual(i2["stats"]["tone"]["category"], "warm")
|
|
93
|
+
with open(os.path.join(self.build, "material.md"), encoding="utf-8") as f:
|
|
94
|
+
md = f.read()
|
|
95
|
+
self.assertIn("(未完成", md) # src_2 识图未完成标注
|
|
96
|
+
|
|
97
|
+
def test_chart_key_message_and_data_points_rendered(self):
|
|
98
|
+
# 2026-07-03 新增字段:图表核心结论 + 关键数据点,须渲染进 material.md 供 draft 阶段读到
|
|
99
|
+
# (治「客户图配不上」——图的价值此前只在识图内部,没往下游透传)。
|
|
100
|
+
self._seed_full()
|
|
101
|
+
with open(os.path.join(self.build, "vision", "src_1.png.json"), "w", encoding="utf-8") as f:
|
|
102
|
+
json.dump({
|
|
103
|
+
"description": "一块电路板特写", "content_type": "chart",
|
|
104
|
+
"key_message": "巡检效率提升三倍", "data_points": ["68% → 12%", "3 倍提速"],
|
|
105
|
+
}, f, ensure_ascii=False)
|
|
106
|
+
am.assemble(self.build)
|
|
107
|
+
with open(os.path.join(self.build, "material.md"), encoding="utf-8") as f:
|
|
108
|
+
md = f.read()
|
|
109
|
+
self.assertIn("巡检效率提升三倍", md)
|
|
110
|
+
self.assertIn("68% → 12%", md)
|
|
111
|
+
self.assertIn("3 倍提速", md)
|
|
112
|
+
|
|
113
|
+
def test_embedded_text_rendered(self):
|
|
114
|
+
# 2026-07-03:图上原有文字(图生图会去除)须透传进 material.md,供 draft 阶段判断是否要整合进正文
|
|
115
|
+
# (治「带字图去字后信息直接丢失」——src_6 真机事故:标题「AI全景相机优势」若有价值不能凭空消失)。
|
|
116
|
+
self._seed_full()
|
|
117
|
+
with open(os.path.join(self.build, "vision", "src_1.png.json"), "w", encoding="utf-8") as f:
|
|
118
|
+
json.dump({
|
|
119
|
+
"description": "一张完整的演示页截图", "content_type": "screenshot_slide",
|
|
120
|
+
"embedded_text": [
|
|
121
|
+
{"text": "AI全景相机优势", "region": "顶部标题"},
|
|
122
|
+
{"text": "多台监控", "region": "左箭头标签"},
|
|
123
|
+
],
|
|
124
|
+
}, f, ensure_ascii=False)
|
|
125
|
+
am.assemble(self.build)
|
|
126
|
+
with open(os.path.join(self.build, "material.md"), encoding="utf-8") as f:
|
|
127
|
+
md = f.read()
|
|
128
|
+
self.assertIn("AI全景相机优势", md)
|
|
129
|
+
self.assertIn("多台监控", md)
|
|
130
|
+
self.assertIn("图生图阶段会被去除", md)
|
|
131
|
+
|
|
132
|
+
def test_no_source_writes_empty_material(self):
|
|
133
|
+
_write(os.path.join(self.build, "source_assets.json"), {
|
|
134
|
+
"has_source": False, "sources": [], "text_file": None, "images": [],
|
|
135
|
+
})
|
|
136
|
+
m = am.assemble(self.build)
|
|
137
|
+
self.assertFalse(m["has_source"])
|
|
138
|
+
self.assertEqual(m["images"], [])
|
|
139
|
+
self.assertTrue(os.path.isfile(os.path.join(self.build, "material.json")))
|
|
140
|
+
|
|
141
|
+
def test_no_manifest_at_all(self):
|
|
142
|
+
# 连 source_assets.json 都没有 → 不报错,写空材料
|
|
143
|
+
m = am.assemble(self.build)
|
|
144
|
+
self.assertFalse(m["has_source"])
|
|
145
|
+
self.assertEqual(m["images"], [])
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if __name__ == "__main__":
|
|
149
|
+
unittest.main(verbosity=2)
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { chromium } from 'playwright-core';
|
|
6
|
+
|
|
7
|
+
function parseArgs(argv) {
|
|
8
|
+
const args = {
|
|
9
|
+
html: '',
|
|
10
|
+
outDir: '',
|
|
11
|
+
screenshotsDir: '',
|
|
12
|
+
report: '',
|
|
13
|
+
desktop: '1440x980',
|
|
14
|
+
mobile: '390x844',
|
|
15
|
+
wait: 250,
|
|
16
|
+
requireTweaks: false,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
20
|
+
const item = argv[index];
|
|
21
|
+
if (item === '--help' || item === '-h') {
|
|
22
|
+
console.log(`用法: browser_check_ui_artifact.mjs <html文件> --out-dir <输出目录>
|
|
23
|
+
|
|
24
|
+
选项:
|
|
25
|
+
--screenshots-dir <目录> 截图输出目录,默认等于 --out-dir
|
|
26
|
+
--report <文件> JSON 报告路径,默认写入 --out-dir/browser-check.json
|
|
27
|
+
--desktop 1440x980 桌面截图视口
|
|
28
|
+
--mobile 390x844 移动端截图视口
|
|
29
|
+
--wait 250 页面加载后等待毫秒数
|
|
30
|
+
--require-tweaks 要求存在唯一 EDITMODE block 与完整 Tweaks 消息(原型/变体页使用)
|
|
31
|
+
|
|
32
|
+
输出:
|
|
33
|
+
desktop.png
|
|
34
|
+
mobile.png
|
|
35
|
+
browser-check.json`);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
if (item === '--out-dir') {
|
|
39
|
+
args.outDir = argv[index + 1] || '';
|
|
40
|
+
index += 1;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (item === '--screenshots-dir') {
|
|
44
|
+
args.screenshotsDir = argv[index + 1] || '';
|
|
45
|
+
index += 1;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (item === '--report') {
|
|
49
|
+
args.report = argv[index + 1] || '';
|
|
50
|
+
index += 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (item === '--desktop') {
|
|
54
|
+
args.desktop = argv[index + 1] || args.desktop;
|
|
55
|
+
index += 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (item === '--mobile') {
|
|
59
|
+
args.mobile = argv[index + 1] || args.mobile;
|
|
60
|
+
index += 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (item === '--wait') {
|
|
64
|
+
args.wait = Number(argv[index + 1] || args.wait);
|
|
65
|
+
index += 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (item === '--require-tweaks') {
|
|
69
|
+
args.requireTweaks = true;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!args.html) {
|
|
73
|
+
args.html = item;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`未知参数: ${item}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!args.html || !args.outDir) {
|
|
80
|
+
throw new Error('必须提供 <html文件> 和 --out-dir。使用 --help 查看说明。');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return args;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function parseViewport(value) {
|
|
87
|
+
const match = /^(\d+)x(\d+)$/.exec(value);
|
|
88
|
+
if (!match) {
|
|
89
|
+
throw new Error(`视口格式错误: ${value},应类似 1440x980。`);
|
|
90
|
+
}
|
|
91
|
+
return { width: Number(match[1]), height: Number(match[2]) };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function inspectPage(page) {
|
|
95
|
+
return page.evaluate(() => {
|
|
96
|
+
const html = document.documentElement.outerHTML;
|
|
97
|
+
const buttons = Array.from(document.querySelectorAll('button, a[role="button"], .button, .btn, .cta'));
|
|
98
|
+
const smallTargets = buttons
|
|
99
|
+
.map((node) => {
|
|
100
|
+
const rect = node.getBoundingClientRect();
|
|
101
|
+
const text = (node.textContent || node.getAttribute('aria-label') || '').trim().slice(0, 40);
|
|
102
|
+
return { text, width: Math.round(rect.width), height: Math.round(rect.height) };
|
|
103
|
+
})
|
|
104
|
+
.filter((item) => item.width > 0 && item.height > 0 && (item.width < 44 || item.height < 44));
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
title: document.title,
|
|
108
|
+
screenLabels: Array.from(document.querySelectorAll('[data-screen-label]')).map((node) =>
|
|
109
|
+
node.getAttribute('data-screen-label'),
|
|
110
|
+
),
|
|
111
|
+
editModeBlocks: (html.match(/EDITMODE-BEGIN/g) || []).length,
|
|
112
|
+
hasEditModeAvailable: html.includes('__edit_mode_available'),
|
|
113
|
+
hasEditModeSetKeys: html.includes('__edit_mode_set_keys'),
|
|
114
|
+
hasEditsPayload: /\bedits\s*:|["']edits["']/.test(html),
|
|
115
|
+
documentWidth: document.documentElement.scrollWidth,
|
|
116
|
+
viewportWidth: window.innerWidth,
|
|
117
|
+
horizontalOverflow: document.documentElement.scrollWidth > window.innerWidth + 2,
|
|
118
|
+
smallTargets,
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function checkViewport(page, url, viewport, screenshotPath, waitMs) {
|
|
124
|
+
const consoleMessages = [];
|
|
125
|
+
const onConsole = (msg) => consoleMessages.push({ type: msg.type(), text: msg.text() });
|
|
126
|
+
const onPageError = (error) => consoleMessages.push({ type: 'pageerror', text: error.message });
|
|
127
|
+
page.on('console', onConsole);
|
|
128
|
+
page.on('pageerror', onPageError);
|
|
129
|
+
await page.setViewportSize(viewport);
|
|
130
|
+
await page.goto(url, { waitUntil: 'load' });
|
|
131
|
+
if (waitMs > 0) {
|
|
132
|
+
await page.waitForTimeout(waitMs);
|
|
133
|
+
}
|
|
134
|
+
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
135
|
+
const inspection = await inspectPage(page);
|
|
136
|
+
page.off('console', onConsole);
|
|
137
|
+
page.off('pageerror', onPageError);
|
|
138
|
+
return { viewport, screenshot: screenshotPath, console: consoleMessages, inspection };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function collectIssues(result, options) {
|
|
142
|
+
const issues = [];
|
|
143
|
+
for (const key of ['desktop', 'mobile']) {
|
|
144
|
+
const item = result[key];
|
|
145
|
+
const badConsole = item.console.filter((entry) => entry.type === 'error' || entry.type === 'pageerror');
|
|
146
|
+
if (badConsole.length) {
|
|
147
|
+
issues.push(`${key}: 存在 console error 或 pageerror。`);
|
|
148
|
+
}
|
|
149
|
+
if (item.inspection.horizontalOverflow) {
|
|
150
|
+
issues.push(`${key}: 存在横向溢出。`);
|
|
151
|
+
}
|
|
152
|
+
if (!item.inspection.screenLabels.length) {
|
|
153
|
+
issues.push(`${key}: 缺少 data-screen-label。`);
|
|
154
|
+
}
|
|
155
|
+
if (options.requireTweaks) {
|
|
156
|
+
if (item.inspection.editModeBlocks !== 1) {
|
|
157
|
+
issues.push(`${key}: EDITMODE JSON block 数量不是 1。`);
|
|
158
|
+
}
|
|
159
|
+
if (!item.inspection.hasEditModeAvailable || !item.inspection.hasEditModeSetKeys) {
|
|
160
|
+
issues.push(`${key}: Tweaks 协议消息不完整。`);
|
|
161
|
+
}
|
|
162
|
+
if (!item.inspection.hasEditsPayload) {
|
|
163
|
+
issues.push(`${key}: Tweaks 未检测到 edits payload。`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const smallMobileTargets = result.mobile.inspection.smallTargets;
|
|
168
|
+
if (smallMobileTargets.length) {
|
|
169
|
+
issues.push(`mobile: ${smallMobileTargets.length} 个可点击目标小于 44px。`);
|
|
170
|
+
}
|
|
171
|
+
return issues;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function main() {
|
|
175
|
+
const args = parseArgs(process.argv.slice(2));
|
|
176
|
+
const htmlPath = resolve(args.html);
|
|
177
|
+
const outDir = resolve(args.outDir);
|
|
178
|
+
const screenshotsDir = resolve(args.screenshotsDir || args.outDir);
|
|
179
|
+
const reportPath = resolve(args.report || resolve(args.outDir, 'browser-check.json'));
|
|
180
|
+
await mkdir(outDir, { recursive: true });
|
|
181
|
+
await mkdir(screenshotsDir, { recursive: true });
|
|
182
|
+
|
|
183
|
+
const browser = await chromium.launch({ headless: true });
|
|
184
|
+
const url = pathToFileURL(htmlPath).href;
|
|
185
|
+
const result = { html: htmlPath, options: { requireTweaks: args.requireTweaks } };
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
const desktopPage = await browser.newPage();
|
|
189
|
+
result.desktop = await checkViewport(
|
|
190
|
+
desktopPage,
|
|
191
|
+
url,
|
|
192
|
+
parseViewport(args.desktop),
|
|
193
|
+
resolve(screenshotsDir, 'desktop.png'),
|
|
194
|
+
args.wait,
|
|
195
|
+
);
|
|
196
|
+
await desktopPage.close();
|
|
197
|
+
|
|
198
|
+
const mobilePage = await browser.newPage();
|
|
199
|
+
result.mobile = await checkViewport(
|
|
200
|
+
mobilePage,
|
|
201
|
+
url,
|
|
202
|
+
parseViewport(args.mobile),
|
|
203
|
+
resolve(screenshotsDir, 'mobile.png'),
|
|
204
|
+
args.wait,
|
|
205
|
+
);
|
|
206
|
+
await mobilePage.close();
|
|
207
|
+
} finally {
|
|
208
|
+
await browser.close();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
result.issues = collectIssues(result, args);
|
|
212
|
+
result.pass = result.issues.length === 0;
|
|
213
|
+
await writeFile(reportPath, JSON.stringify(result, null, 2));
|
|
214
|
+
console.log(JSON.stringify({ pass: result.pass, issues: result.issues }, null, 2));
|
|
215
|
+
process.exit(result.pass ? 0 : 1);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
main().catch((error) => {
|
|
219
|
+
console.error(error);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
});
|