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,272 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Conservatively normalize and validate PPT design.json.
|
|
3
|
+
|
|
4
|
+
This gate exists because downstream deterministic scripts cannot operate on a
|
|
5
|
+
broken design document. It intentionally fixes only mechanical JSON wrappers
|
|
6
|
+
and trailing commas; it does not invent missing fields or repair arbitrary
|
|
7
|
+
syntax.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import json
|
|
14
|
+
import re
|
|
15
|
+
import sys
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
from json import JSONDecodeError
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class NormalizeResult:
|
|
24
|
+
ok: bool
|
|
25
|
+
data: dict[str, Any] | None = None
|
|
26
|
+
normalized_text: str = ""
|
|
27
|
+
error: str = ""
|
|
28
|
+
position: int | None = None
|
|
29
|
+
snippet: str = ""
|
|
30
|
+
source: str = ""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _strip_bom(text: str) -> str:
|
|
34
|
+
return text.lstrip("\ufeff")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _extract_fenced_json(text: str) -> str:
|
|
38
|
+
fence = re.search(r"```(?:json)?\s*(.*?)```", text, flags=re.IGNORECASE | re.DOTALL)
|
|
39
|
+
if fence and "{" in fence.group(1):
|
|
40
|
+
return fence.group(1).strip()
|
|
41
|
+
return text.strip()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _extract_first_json_object(text: str) -> str:
|
|
45
|
+
start = text.find("{")
|
|
46
|
+
if start < 0:
|
|
47
|
+
return text.strip()
|
|
48
|
+
|
|
49
|
+
depth = 0
|
|
50
|
+
in_string = False
|
|
51
|
+
escaped = False
|
|
52
|
+
for i, ch in enumerate(text[start:], start):
|
|
53
|
+
if in_string:
|
|
54
|
+
if escaped:
|
|
55
|
+
escaped = False
|
|
56
|
+
elif ch == "\\":
|
|
57
|
+
escaped = True
|
|
58
|
+
elif ch == '"':
|
|
59
|
+
in_string = False
|
|
60
|
+
continue
|
|
61
|
+
if ch == '"':
|
|
62
|
+
in_string = True
|
|
63
|
+
elif ch == "{":
|
|
64
|
+
depth += 1
|
|
65
|
+
elif ch == "}":
|
|
66
|
+
depth -= 1
|
|
67
|
+
if depth == 0:
|
|
68
|
+
return text[start : i + 1].strip()
|
|
69
|
+
return text[start:].strip()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _remove_trailing_commas(text: str) -> str:
|
|
73
|
+
return re.sub(r",(\s*[}\]])", r"\1", text)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _escape_unescaped_inner_quotes(text: str) -> str:
|
|
77
|
+
"""修 LLM 高频 JSON 错:字符串值里嵌英文双引号不转义(2026-07-02 真机 halt:
|
|
78
|
+
`"speaker_notes": "5层架构按"采集→…"自下而上。…"`)。
|
|
79
|
+
|
|
80
|
+
状态机扫描:**串内**遇到未转义 `"` 时向后看第一个非空白字符——
|
|
81
|
+
是 `,` `}` `]` `:` 之一 → 真终结符(键/值正常收尾);否则视为内容引号,转义成 \\"。
|
|
82
|
+
修不动的花样(如内容引号后恰好跟逗号)parse 仍失败 → 走原有报错路径,保守不瞎猜。
|
|
83
|
+
"""
|
|
84
|
+
out: list[str] = []
|
|
85
|
+
in_string = False
|
|
86
|
+
escaped = False
|
|
87
|
+
n = len(text)
|
|
88
|
+
for i, ch in enumerate(text):
|
|
89
|
+
if not in_string:
|
|
90
|
+
if ch == '"':
|
|
91
|
+
in_string = True
|
|
92
|
+
out.append(ch)
|
|
93
|
+
continue
|
|
94
|
+
if escaped:
|
|
95
|
+
escaped = False
|
|
96
|
+
out.append(ch)
|
|
97
|
+
continue
|
|
98
|
+
if ch == "\\":
|
|
99
|
+
escaped = True
|
|
100
|
+
out.append(ch)
|
|
101
|
+
continue
|
|
102
|
+
if ch == '"':
|
|
103
|
+
j = i + 1
|
|
104
|
+
while j < n and text[j] in " \t\r\n":
|
|
105
|
+
j += 1
|
|
106
|
+
if j >= n or text[j] in ',}]:':
|
|
107
|
+
in_string = False
|
|
108
|
+
out.append(ch)
|
|
109
|
+
else:
|
|
110
|
+
out.append('\\"')
|
|
111
|
+
continue
|
|
112
|
+
out.append(ch)
|
|
113
|
+
return "".join(out)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _error_snippet(text: str, position: int | None) -> str:
|
|
117
|
+
if position is None:
|
|
118
|
+
return text[:480]
|
|
119
|
+
start = max(0, position - 240)
|
|
120
|
+
end = min(len(text), position + 240)
|
|
121
|
+
marker = " " * (position - start) + "^"
|
|
122
|
+
return text[start:end] + "\n" + marker
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _validate_design(data: Any) -> list[str]:
|
|
126
|
+
errors: list[str] = []
|
|
127
|
+
if not isinstance(data, dict):
|
|
128
|
+
return ["top-level JSON must be an object"]
|
|
129
|
+
pages = data.get("pages")
|
|
130
|
+
if not isinstance(pages, list) or not pages:
|
|
131
|
+
return ["top-level object must contain a non-empty pages array"]
|
|
132
|
+
|
|
133
|
+
numbers: list[int] = []
|
|
134
|
+
for index, page in enumerate(pages, 1):
|
|
135
|
+
if not isinstance(page, dict):
|
|
136
|
+
errors.append(f"pages[{index - 1}] must be an object")
|
|
137
|
+
continue
|
|
138
|
+
number = page.get("page")
|
|
139
|
+
if not isinstance(number, int):
|
|
140
|
+
errors.append(f"pages[{index - 1}].page must be an integer")
|
|
141
|
+
continue
|
|
142
|
+
numbers.append(number)
|
|
143
|
+
|
|
144
|
+
expected = list(range(1, len(pages) + 1))
|
|
145
|
+
if len(numbers) == len(pages) and numbers != expected:
|
|
146
|
+
errors.append(f"page numbers must be continuous 1..{len(pages)}, got {numbers}")
|
|
147
|
+
return errors
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def normalize_design_text(text: str, source: str = "design.json") -> NormalizeResult:
|
|
151
|
+
raw = _strip_bom(text)
|
|
152
|
+
candidate = _extract_first_json_object(_extract_fenced_json(raw))
|
|
153
|
+
attempts = [candidate]
|
|
154
|
+
trailing_fixed = _remove_trailing_commas(candidate)
|
|
155
|
+
if trailing_fixed != candidate:
|
|
156
|
+
attempts.append(trailing_fixed)
|
|
157
|
+
quote_repaired = _escape_unescaped_inner_quotes(trailing_fixed)
|
|
158
|
+
if quote_repaired not in attempts:
|
|
159
|
+
attempts.append(quote_repaired)
|
|
160
|
+
|
|
161
|
+
last_error: JSONDecodeError | None = None
|
|
162
|
+
last_text = candidate
|
|
163
|
+
for attempt in attempts:
|
|
164
|
+
last_text = attempt
|
|
165
|
+
try:
|
|
166
|
+
data = json.loads(attempt)
|
|
167
|
+
except JSONDecodeError as exc:
|
|
168
|
+
last_error = exc
|
|
169
|
+
continue
|
|
170
|
+
errors = _validate_design(data)
|
|
171
|
+
if errors:
|
|
172
|
+
return NormalizeResult(
|
|
173
|
+
ok=False,
|
|
174
|
+
error="; ".join(errors),
|
|
175
|
+
snippet=_error_snippet(attempt, None),
|
|
176
|
+
source=source,
|
|
177
|
+
)
|
|
178
|
+
normalized = json.dumps(data, ensure_ascii=False, indent=2) + "\n"
|
|
179
|
+
return NormalizeResult(ok=True, data=data, normalized_text=normalized, source=source)
|
|
180
|
+
|
|
181
|
+
if last_error is None:
|
|
182
|
+
return NormalizeResult(
|
|
183
|
+
ok=False,
|
|
184
|
+
error="no JSON object found",
|
|
185
|
+
snippet=_error_snippet(last_text, None),
|
|
186
|
+
source=source,
|
|
187
|
+
)
|
|
188
|
+
return NormalizeResult(
|
|
189
|
+
ok=False,
|
|
190
|
+
error=f"{last_error.msg}: line {last_error.lineno} column {last_error.colno} (char {last_error.pos})",
|
|
191
|
+
position=last_error.pos,
|
|
192
|
+
snippet=_error_snippet(last_text, last_error.pos),
|
|
193
|
+
source=source,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _read_design_source(build: Path) -> tuple[str, str]:
|
|
198
|
+
for name in ("design.json", "design.draft.json", "design.md"):
|
|
199
|
+
path = build / name
|
|
200
|
+
if path.exists():
|
|
201
|
+
return path.read_text(encoding="utf-8", errors="replace"), name
|
|
202
|
+
raise FileNotFoundError("missing design.json/design.draft.json/design.md")
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _write_report(build: Path, result: NormalizeResult) -> None:
|
|
206
|
+
payload = {
|
|
207
|
+
"ok": result.ok,
|
|
208
|
+
"source": result.source,
|
|
209
|
+
"error": result.error,
|
|
210
|
+
"position": result.position,
|
|
211
|
+
"snippet": result.snippet,
|
|
212
|
+
"page_count": len(result.data.get("pages", [])) if result.data else 0,
|
|
213
|
+
}
|
|
214
|
+
(build / "design_json_gate.json").write_text(
|
|
215
|
+
json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
|
|
216
|
+
encoding="utf-8",
|
|
217
|
+
)
|
|
218
|
+
if result.ok:
|
|
219
|
+
text = (
|
|
220
|
+
"# 设计 JSON 硬验收\n\n"
|
|
221
|
+
f"- ok: true\n- source: {result.source}\n- pages: {payload['page_count']}\n"
|
|
222
|
+
)
|
|
223
|
+
else:
|
|
224
|
+
text = (
|
|
225
|
+
"# 设计 JSON 硬验收失败\n\n"
|
|
226
|
+
f"- ok: false\n- source: {result.source}\n- error: {result.error}\n\n"
|
|
227
|
+
"## 附近片段\n\n```text\n"
|
|
228
|
+
f"{result.snippet}\n"
|
|
229
|
+
"```\n"
|
|
230
|
+
)
|
|
231
|
+
(build / "design_json_gate.md").write_text(text, encoding="utf-8")
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def normalize_build(build: Path) -> NormalizeResult:
|
|
235
|
+
build.mkdir(parents=True, exist_ok=True)
|
|
236
|
+
ok_marker = build / "design_json_ok"
|
|
237
|
+
ok_marker.unlink(missing_ok=True)
|
|
238
|
+
|
|
239
|
+
raw_text, source = _read_design_source(build)
|
|
240
|
+
(build / "design.raw.json").write_text(raw_text, encoding="utf-8")
|
|
241
|
+
result = normalize_design_text(raw_text, source=source)
|
|
242
|
+
_write_report(build, result)
|
|
243
|
+
if result.ok:
|
|
244
|
+
(build / "design.json").write_text(result.normalized_text, encoding="utf-8")
|
|
245
|
+
ok_marker.touch()
|
|
246
|
+
return result
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def main(argv: list[str] | None = None) -> int:
|
|
250
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
251
|
+
parser.add_argument("--build", default="./build", help="Build directory containing design.json")
|
|
252
|
+
args = parser.parse_args(argv)
|
|
253
|
+
|
|
254
|
+
try:
|
|
255
|
+
result = normalize_build(Path(args.build))
|
|
256
|
+
except Exception as exc: # noqa: BLE001 - CLI should report all IO/setup failures.
|
|
257
|
+
print(f"DESIGN_JSON_INVALID: {exc}", file=sys.stderr)
|
|
258
|
+
return 1
|
|
259
|
+
|
|
260
|
+
if result.ok:
|
|
261
|
+
page_count = len(result.data.get("pages", [])) if result.data else 0
|
|
262
|
+
print(f"DESIGN_JSON_OK: {page_count} pages -> {Path(args.build) / 'design.json'}")
|
|
263
|
+
return 0
|
|
264
|
+
|
|
265
|
+
print(f"DESIGN_JSON_INVALID: {result.error}", file=sys.stderr)
|
|
266
|
+
if result.snippet:
|
|
267
|
+
print(result.snippet, file=sys.stderr)
|
|
268
|
+
return 1
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if __name__ == "__main__":
|
|
272
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import tempfile
|
|
7
|
+
import unittest
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from normalize_design_json import normalize_build
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NormalizeDesignJsonTest(unittest.TestCase):
|
|
14
|
+
def run_case(self, text: str):
|
|
15
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
16
|
+
build = Path(tmp)
|
|
17
|
+
(build / "design.json").write_text(text, encoding="utf-8")
|
|
18
|
+
result = normalize_build(build)
|
|
19
|
+
return result, build
|
|
20
|
+
|
|
21
|
+
def test_pretty_json_passes_and_writes_marker(self) -> None:
|
|
22
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
23
|
+
build = Path(tmp)
|
|
24
|
+
(build / "design.json").write_text(
|
|
25
|
+
json.dumps({"pages": [{"page": 1, "title": "第一页"}]}, ensure_ascii=False, indent=2),
|
|
26
|
+
encoding="utf-8",
|
|
27
|
+
)
|
|
28
|
+
result = normalize_build(build)
|
|
29
|
+
self.assertTrue(result.ok)
|
|
30
|
+
self.assertTrue((build / "design_json_ok").exists())
|
|
31
|
+
data = json.loads((build / "design.json").read_text(encoding="utf-8"))
|
|
32
|
+
self.assertEqual(data["pages"][0]["title"], "第一页")
|
|
33
|
+
|
|
34
|
+
def test_markdown_fence_is_extracted(self) -> None:
|
|
35
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
36
|
+
build = Path(tmp)
|
|
37
|
+
(build / "design.json").write_text(
|
|
38
|
+
'```json\n{"pages":[{"page":1,"title":"A"}]}\n```',
|
|
39
|
+
encoding="utf-8",
|
|
40
|
+
)
|
|
41
|
+
result = normalize_build(build)
|
|
42
|
+
self.assertTrue(result.ok)
|
|
43
|
+
self.assertTrue((build / "design_json_ok").exists())
|
|
44
|
+
|
|
45
|
+
def test_trailing_commas_are_removed(self) -> None:
|
|
46
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
47
|
+
build = Path(tmp)
|
|
48
|
+
(build / "design.json").write_text(
|
|
49
|
+
'{"pages":[{"page":1,"title":"A",},],}',
|
|
50
|
+
encoding="utf-8",
|
|
51
|
+
)
|
|
52
|
+
result = normalize_build(build)
|
|
53
|
+
self.assertTrue(result.ok)
|
|
54
|
+
data = json.loads((build / "design.json").read_text(encoding="utf-8"))
|
|
55
|
+
self.assertEqual(data["pages"][0]["page"], 1)
|
|
56
|
+
|
|
57
|
+
def test_malformed_json_fails_with_snippet(self) -> None:
|
|
58
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
59
|
+
build = Path(tmp)
|
|
60
|
+
(build / "design.json").write_text(
|
|
61
|
+
'{"pages":[{"page":1,"evidence":["a"]},"points":[{"k":"x"}]}',
|
|
62
|
+
encoding="utf-8",
|
|
63
|
+
)
|
|
64
|
+
result = normalize_build(build)
|
|
65
|
+
self.assertFalse(result.ok)
|
|
66
|
+
self.assertFalse((build / "design_json_ok").exists())
|
|
67
|
+
report = (build / "design_json_gate.md").read_text(encoding="utf-8")
|
|
68
|
+
self.assertIn("设计 JSON 硬验收失败", report)
|
|
69
|
+
self.assertIn("^", report)
|
|
70
|
+
|
|
71
|
+
def test_missing_pages_fails(self) -> None:
|
|
72
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
73
|
+
build = Path(tmp)
|
|
74
|
+
(build / "design.json").write_text('{"slides":[]}', encoding="utf-8")
|
|
75
|
+
result = normalize_build(build)
|
|
76
|
+
self.assertFalse(result.ok)
|
|
77
|
+
self.assertIn("pages", result.error)
|
|
78
|
+
|
|
79
|
+
def test_non_continuous_pages_fail(self) -> None:
|
|
80
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
81
|
+
build = Path(tmp)
|
|
82
|
+
(build / "design.json").write_text(
|
|
83
|
+
'{"pages":[{"page":1},{"page":3}]}',
|
|
84
|
+
encoding="utf-8",
|
|
85
|
+
)
|
|
86
|
+
result = normalize_build(build)
|
|
87
|
+
self.assertFalse(result.ok)
|
|
88
|
+
self.assertIn("continuous", result.error)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class UnescapedInnerQuoteRepairTest(unittest.TestCase):
|
|
92
|
+
"""未转义内嵌引号修复(2026-07-02 真机 halt:speaker_notes 里 按"采集→…"自下而上 未转义)。"""
|
|
93
|
+
|
|
94
|
+
def test_unescaped_chinese_quoted_phrase_is_repaired(self) -> None:
|
|
95
|
+
from normalize_design_json import normalize_design_text
|
|
96
|
+
broken = (
|
|
97
|
+
'{"pages":[{"page":1,'
|
|
98
|
+
'"speaker_notes":"5层架构按"采集→网络→平台→应用→标准规范"自下而上。",'
|
|
99
|
+
'"blocks":[{"content":"五层架构","render":"text","role":"title"}]}]}'
|
|
100
|
+
)
|
|
101
|
+
result = normalize_design_text(broken)
|
|
102
|
+
self.assertTrue(result.ok, result.error)
|
|
103
|
+
self.assertIn("按\"采集", result.data["pages"][0]["speaker_notes"])
|
|
104
|
+
|
|
105
|
+
def test_valid_json_untouched_by_repair_path(self) -> None:
|
|
106
|
+
from normalize_design_json import normalize_design_text
|
|
107
|
+
ok_text = '{"pages":[{"page":1,"title":"含冒号: 与引号\\"转义\\"的合法串"}]}'
|
|
108
|
+
result = normalize_design_text(ok_text)
|
|
109
|
+
self.assertTrue(result.ok, result.error)
|
|
110
|
+
self.assertEqual(result.data["pages"][0]["title"], '含冒号: 与引号"转义"的合法串')
|
|
111
|
+
|
|
112
|
+
def test_unrepairable_still_fails_loudly(self) -> None:
|
|
113
|
+
from normalize_design_json import normalize_design_text
|
|
114
|
+
result = normalize_design_text('{"pages":[{"page":1,"t"::::}]}')
|
|
115
|
+
self.assertFalse(result.ok)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
unittest.main()
|