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,148 @@
|
|
|
1
|
+
const FIELD_RANGES = [
|
|
2
|
+
{ min: 0, max: 59 },
|
|
3
|
+
{ min: 0, max: 23 },
|
|
4
|
+
{ min: 1, max: 31 },
|
|
5
|
+
{ min: 1, max: 12 },
|
|
6
|
+
{ min: 0, max: 6 },
|
|
7
|
+
];
|
|
8
|
+
function expandField(field, min, max) {
|
|
9
|
+
const out = new Set();
|
|
10
|
+
for (const raw of field.split(',')) {
|
|
11
|
+
const part = raw.trim();
|
|
12
|
+
const stepMatch = part.match(/^\*(?:\/(\d+))?$/);
|
|
13
|
+
if (stepMatch) {
|
|
14
|
+
const step = stepMatch[1] ? Number.parseInt(stepMatch[1], 10) : 1;
|
|
15
|
+
if (step < 1)
|
|
16
|
+
return null;
|
|
17
|
+
for (let i = min; i <= max; i += step)
|
|
18
|
+
out.add(i);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const rangeMatch = part.match(/^(\d+)-(\d+)(?:\/(\d+))?$/);
|
|
22
|
+
if (rangeMatch) {
|
|
23
|
+
const lo = Number.parseInt(rangeMatch[1], 10);
|
|
24
|
+
const hi = Number.parseInt(rangeMatch[2], 10);
|
|
25
|
+
const step = rangeMatch[3] ? Number.parseInt(rangeMatch[3], 10) : 1;
|
|
26
|
+
const isDow = min === 0 && max === 6;
|
|
27
|
+
const effMax = isDow ? 7 : max;
|
|
28
|
+
if (lo > hi || step < 1 || lo < min || hi > effMax)
|
|
29
|
+
return null;
|
|
30
|
+
for (let i = lo; i <= hi; i += step)
|
|
31
|
+
out.add(isDow && i === 7 ? 0 : i);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (/^\d+$/.test(part)) {
|
|
35
|
+
let n = Number.parseInt(part, 10);
|
|
36
|
+
if (min === 0 && max === 6 && n === 7)
|
|
37
|
+
n = 0;
|
|
38
|
+
if (n < min || n > max)
|
|
39
|
+
return null;
|
|
40
|
+
out.add(n);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return out.size > 0 ? Array.from(out).sort((a, b) => a - b) : null;
|
|
46
|
+
}
|
|
47
|
+
export function parseCronExpression(expr) {
|
|
48
|
+
const parts = expr.trim().split(/\s+/);
|
|
49
|
+
if (parts.length !== 5)
|
|
50
|
+
return null;
|
|
51
|
+
const expanded = parts.map((p, i) => expandField(p, FIELD_RANGES[i].min, FIELD_RANGES[i].max));
|
|
52
|
+
if (expanded.some((v) => v === null))
|
|
53
|
+
return null;
|
|
54
|
+
return {
|
|
55
|
+
minute: expanded[0],
|
|
56
|
+
hour: expanded[1],
|
|
57
|
+
dayOfMonth: expanded[2],
|
|
58
|
+
month: expanded[3],
|
|
59
|
+
dayOfWeek: expanded[4],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function nextCronRunMs(cron, fromMs = Date.now()) {
|
|
63
|
+
const fields = parseCronExpression(cron);
|
|
64
|
+
if (!fields)
|
|
65
|
+
return null;
|
|
66
|
+
const next = computeNextCronRun(fields, new Date(fromMs));
|
|
67
|
+
return next ? next.getTime() : null;
|
|
68
|
+
}
|
|
69
|
+
export function computeNextCronRun(fields, from) {
|
|
70
|
+
const t = new Date(from.getTime());
|
|
71
|
+
t.setSeconds(0, 0);
|
|
72
|
+
t.setMinutes(t.getMinutes() + 1);
|
|
73
|
+
for (let i = 0; i < 366 * 24 * 60; i++) {
|
|
74
|
+
if (cronFieldsMatchDate(fields, t)) {
|
|
75
|
+
return new Date(t.getTime());
|
|
76
|
+
}
|
|
77
|
+
t.setMinutes(t.getMinutes() + 1);
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
export function cronFieldsMatchDate(fields, date) {
|
|
82
|
+
const domMatches = fields.dayOfMonth.includes(date.getDate());
|
|
83
|
+
const dowMatches = fields.dayOfWeek.includes(date.getDay());
|
|
84
|
+
const domWild = fields.dayOfMonth.length === 31;
|
|
85
|
+
const dowWild = fields.dayOfWeek.length === 7;
|
|
86
|
+
const dayMatches = domWild && dowWild
|
|
87
|
+
? true
|
|
88
|
+
: domWild
|
|
89
|
+
? dowMatches
|
|
90
|
+
: dowWild
|
|
91
|
+
? domMatches
|
|
92
|
+
: domMatches || dowMatches;
|
|
93
|
+
return (fields.month.includes(date.getMonth() + 1) &&
|
|
94
|
+
dayMatches &&
|
|
95
|
+
fields.hour.includes(date.getHours()) &&
|
|
96
|
+
fields.minute.includes(date.getMinutes()));
|
|
97
|
+
}
|
|
98
|
+
export function cronToHuman(cron) {
|
|
99
|
+
const parts = cron.trim().split(/\s+/);
|
|
100
|
+
if (parts.length !== 5)
|
|
101
|
+
return cron;
|
|
102
|
+
const [minute, hour, dom, month, dow] = parts;
|
|
103
|
+
if (minute === '*' && hour === '*' && dom === '*' && month === '*' && dow === '*') {
|
|
104
|
+
return '每分钟'; // 全通配 = 每分钟一次(否则会掉进下面「每天 * *」的无意义分支)
|
|
105
|
+
}
|
|
106
|
+
const time = /^\d+$/.test(minute) && /^\d+$/.test(hour)
|
|
107
|
+
? `${hour.padStart(2, '0')}:${minute.padStart(2, '0')}`
|
|
108
|
+
: `${minute} ${hour}`;
|
|
109
|
+
if (/^\d+$/.test(minute) && hour === '*')
|
|
110
|
+
return `每小时 ${minute.padStart(2, '0')} 分`;
|
|
111
|
+
const hourStep = hour.match(/^\*\/(\d+)$/);
|
|
112
|
+
if (/^\d+$/.test(minute) && hourStep && dom === '*' && month === '*' && dow === '*') {
|
|
113
|
+
return `每 ${hourStep[1]} 小时 ${minute.padStart(2, '0')} 分`;
|
|
114
|
+
}
|
|
115
|
+
const minuteStep = minute.match(/^\*\/(\d+)$/);
|
|
116
|
+
if (minuteStep && hour === '*' && dom === '*' && month === '*' && dow === '*') {
|
|
117
|
+
return `每 ${minuteStep[1]} 分钟`;
|
|
118
|
+
}
|
|
119
|
+
if (dom === '*' && month === '*' && dow === '*')
|
|
120
|
+
return `每天 ${time}`;
|
|
121
|
+
if (dom === '*' && month === '*' && dow === '1-5')
|
|
122
|
+
return `工作日 ${time}`;
|
|
123
|
+
if (dom === '*' && month === '*' && dow)
|
|
124
|
+
return `每周 ${formatDow(dow)} ${time}`;
|
|
125
|
+
return cron;
|
|
126
|
+
}
|
|
127
|
+
export function formatDateTime(msOrIso) {
|
|
128
|
+
if (msOrIso === undefined)
|
|
129
|
+
return '-';
|
|
130
|
+
const d = typeof msOrIso === 'number' ? new Date(msOrIso) : new Date(msOrIso);
|
|
131
|
+
if (Number.isNaN(d.getTime()))
|
|
132
|
+
return '-';
|
|
133
|
+
return d.toLocaleString('zh-CN', {
|
|
134
|
+
year: 'numeric',
|
|
135
|
+
month: '2-digit',
|
|
136
|
+
day: '2-digit',
|
|
137
|
+
weekday: 'short',
|
|
138
|
+
hour: '2-digit',
|
|
139
|
+
minute: '2-digit',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function formatDow(dow) {
|
|
143
|
+
const names = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
144
|
+
const fields = parseCronExpression(`0 0 * * ${dow}`)?.dayOfWeek;
|
|
145
|
+
if (!fields)
|
|
146
|
+
return dow;
|
|
147
|
+
return fields.map((d) => names[d]).join('、');
|
|
148
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
export function schedulerLockFile(root) {
|
|
4
|
+
return join(root, 'scheduler.lock');
|
|
5
|
+
}
|
|
6
|
+
export async function tryAcquireSchedulerLock(file, owner) {
|
|
7
|
+
await mkdir(dirname(file), { recursive: true });
|
|
8
|
+
const lock = {
|
|
9
|
+
owner,
|
|
10
|
+
pid: process.pid,
|
|
11
|
+
createdAt: new Date().toISOString(),
|
|
12
|
+
updatedAt: new Date().toISOString(),
|
|
13
|
+
};
|
|
14
|
+
if (await tryCreateExclusive(file, lock))
|
|
15
|
+
return true;
|
|
16
|
+
const existing = await readLock(file);
|
|
17
|
+
if (!existing)
|
|
18
|
+
return await tryCreateExclusive(file, lock);
|
|
19
|
+
if (existing.owner === owner) {
|
|
20
|
+
await writeFile(file, JSON.stringify({ ...existing, pid: process.pid, updatedAt: lock.updatedAt }, null, 2), 'utf8');
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (isPidAlive(existing.pid))
|
|
24
|
+
return false;
|
|
25
|
+
await rm(file, { force: true });
|
|
26
|
+
return await tryCreateExclusive(file, lock);
|
|
27
|
+
}
|
|
28
|
+
export async function releaseSchedulerLock(file, owner) {
|
|
29
|
+
const existing = await readLock(file);
|
|
30
|
+
if (!existing || existing.owner !== owner)
|
|
31
|
+
return;
|
|
32
|
+
await rm(file, { force: true });
|
|
33
|
+
}
|
|
34
|
+
async function tryCreateExclusive(file, lock) {
|
|
35
|
+
try {
|
|
36
|
+
await writeFile(file, JSON.stringify(lock, null, 2), { encoding: 'utf8', flag: 'wx' });
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function readLock(file) {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(await readFile(file, 'utf8'));
|
|
46
|
+
if (typeof parsed.owner !== 'string' ||
|
|
47
|
+
typeof parsed.pid !== 'number' ||
|
|
48
|
+
typeof parsed.createdAt !== 'string' ||
|
|
49
|
+
typeof parsed.updatedAt !== 'string') {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isPidAlive(pid) {
|
|
59
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
60
|
+
return false;
|
|
61
|
+
try {
|
|
62
|
+
process.kill(pid, 0);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { appendFile, mkdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
export async function appendRun(runsDir, record) {
|
|
5
|
+
await mkdir(runsDir, { recursive: true });
|
|
6
|
+
await appendFile(join(runsDir, `${record.taskId}.jsonl`), `${JSON.stringify(record)}\n`, 'utf8');
|
|
7
|
+
}
|
|
8
|
+
export async function recentRuns(runsDir, taskId, limit = 5) {
|
|
9
|
+
const file = join(runsDir, `${taskId}.jsonl`);
|
|
10
|
+
if (!existsSync(file))
|
|
11
|
+
return [];
|
|
12
|
+
try {
|
|
13
|
+
const raw = await readFile(file, 'utf8');
|
|
14
|
+
const byId = new Map();
|
|
15
|
+
for (const line of raw.trim().split('\n').filter(Boolean)) {
|
|
16
|
+
const record = JSON.parse(line);
|
|
17
|
+
byId.set(record.id, { ...(byId.get(record.id) ?? {}), ...record });
|
|
18
|
+
}
|
|
19
|
+
return Array.from(byId.values())
|
|
20
|
+
.sort((a, b) => Date.parse(b.startedAt) - Date.parse(a.startedAt))
|
|
21
|
+
.slice(0, limit);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function markRunsRead(runsDir, taskId) {
|
|
28
|
+
if (!existsSync(runsDir))
|
|
29
|
+
return;
|
|
30
|
+
const now = new Date().toISOString();
|
|
31
|
+
const taskIds = taskId ? [taskId] : await listRunTaskIds(runsDir);
|
|
32
|
+
for (const id of taskIds) {
|
|
33
|
+
for (const run of await recentRuns(runsDir, id, Number.MAX_SAFE_INTEGER)) {
|
|
34
|
+
if (!run.readAt)
|
|
35
|
+
await appendRun(runsDir, { ...run, readAt: now });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function listRunTaskIds(runsDir) {
|
|
40
|
+
const { readdir } = await import('node:fs/promises');
|
|
41
|
+
try {
|
|
42
|
+
return (await readdir(runsDir))
|
|
43
|
+
.filter((name) => name.endsWith('.jsonl'))
|
|
44
|
+
.map((name) => name.slice(0, -6));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export async function appendMissed(file, record) {
|
|
51
|
+
await mkdir(dirname(file), { recursive: true });
|
|
52
|
+
await appendFile(file, `${JSON.stringify(record)}\n`, 'utf8');
|
|
53
|
+
}
|
|
54
|
+
export async function listMissed(file, limit = 20) {
|
|
55
|
+
if (!existsSync(file))
|
|
56
|
+
return [];
|
|
57
|
+
try {
|
|
58
|
+
const raw = await readFile(file, 'utf8');
|
|
59
|
+
const bySlot = new Map();
|
|
60
|
+
for (const line of raw.trim().split('\n').filter(Boolean)) {
|
|
61
|
+
const parsed = JSON.parse(line);
|
|
62
|
+
const record = {
|
|
63
|
+
...parsed,
|
|
64
|
+
reason: parsed.reason === 'overlap' || parsed.reason === 'binding_unavailable'
|
|
65
|
+
? parsed.reason
|
|
66
|
+
: 'offline',
|
|
67
|
+
missedCount: typeof parsed.missedCount === 'number' && parsed.missedCount > 0
|
|
68
|
+
? parsed.missedCount
|
|
69
|
+
: 1,
|
|
70
|
+
};
|
|
71
|
+
bySlot.set(`${record.taskId}:${record.scheduledFor}`, record);
|
|
72
|
+
}
|
|
73
|
+
return Array.from(bySlot.values())
|
|
74
|
+
.sort((a, b) => Date.parse(b.detectedAt) - Date.parse(a.detectedAt))
|
|
75
|
+
.slice(0, limit);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export async function markMissedRead(file, taskId) {
|
|
82
|
+
const records = await listMissed(file, Number.MAX_SAFE_INTEGER);
|
|
83
|
+
const now = new Date().toISOString();
|
|
84
|
+
for (const record of records) {
|
|
85
|
+
if (!record.readAt && (!taskId || record.taskId === taskId)) {
|
|
86
|
+
await appendMissed(file, { ...record, readAt: now });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { cronFieldsMatchDate, nextCronRunMs, parseCronExpression } from './cronTime.js';
|
|
2
|
+
export const MIN_INTERVAL_MS = 60_000;
|
|
3
|
+
export function intervalToHuman(intervalMs) {
|
|
4
|
+
const units = [
|
|
5
|
+
{ ms: 7 * 24 * 60 * 60_000, label: '周' },
|
|
6
|
+
{ ms: 24 * 60 * 60_000, label: '天' },
|
|
7
|
+
{ ms: 60 * 60_000, label: '小时' },
|
|
8
|
+
{ ms: 60_000, label: '分钟' },
|
|
9
|
+
];
|
|
10
|
+
for (const unit of units) {
|
|
11
|
+
if (intervalMs % unit.ms === 0)
|
|
12
|
+
return `每 ${intervalMs / unit.ms} ${unit.label}`;
|
|
13
|
+
}
|
|
14
|
+
return `每 ${Math.round(intervalMs / 60_000)} 分钟`;
|
|
15
|
+
}
|
|
16
|
+
/** Return the first wall-clock slot strictly after `fromMs`. */
|
|
17
|
+
export function nextScheduleRunMs(schedule, fromMs) {
|
|
18
|
+
if (schedule.type === 'cron')
|
|
19
|
+
return nextCronRunMs(schedule.cron, fromMs);
|
|
20
|
+
const anchor = Date.parse(schedule.anchorAt);
|
|
21
|
+
if (!Number.isFinite(anchor) || schedule.intervalMs < MIN_INTERVAL_MS)
|
|
22
|
+
return null;
|
|
23
|
+
if (fromMs < anchor)
|
|
24
|
+
return anchor;
|
|
25
|
+
return anchor + (Math.floor((fromMs - anchor) / schedule.intervalMs) + 1) * schedule.intervalMs;
|
|
26
|
+
}
|
|
27
|
+
/** Return the latest slot at or before `atMs`. */
|
|
28
|
+
export function latestScheduleRunMs(schedule, atMs) {
|
|
29
|
+
if (schedule.type === 'interval') {
|
|
30
|
+
const anchor = Date.parse(schedule.anchorAt);
|
|
31
|
+
if (!Number.isFinite(anchor) || atMs < anchor || schedule.intervalMs < MIN_INTERVAL_MS) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return anchor + Math.floor((atMs - anchor) / schedule.intervalMs) * schedule.intervalMs;
|
|
35
|
+
}
|
|
36
|
+
const fields = parseCronExpression(schedule.cron);
|
|
37
|
+
if (!fields)
|
|
38
|
+
return null;
|
|
39
|
+
const cursor = new Date(atMs);
|
|
40
|
+
cursor.setSeconds(0, 0);
|
|
41
|
+
for (let i = 0; i < 366 * 24 * 60; i++) {
|
|
42
|
+
if (cronFieldsMatchDate(fields, cursor))
|
|
43
|
+
return cursor.getTime();
|
|
44
|
+
cursor.setMinutes(cursor.getMinutes() - 1);
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
export function countScheduleSlots(schedule, afterExclusiveMs, throughInclusiveMs) {
|
|
49
|
+
if (throughInclusiveMs <= afterExclusiveMs)
|
|
50
|
+
return 0;
|
|
51
|
+
if (schedule.type === 'interval') {
|
|
52
|
+
const first = nextScheduleRunMs(schedule, afterExclusiveMs);
|
|
53
|
+
if (!first || first > throughInclusiveMs)
|
|
54
|
+
return 0;
|
|
55
|
+
return Math.floor((throughInclusiveMs - first) / schedule.intervalMs) + 1;
|
|
56
|
+
}
|
|
57
|
+
let count = 0;
|
|
58
|
+
let cursor = afterExclusiveMs;
|
|
59
|
+
while (count < 10_000) {
|
|
60
|
+
const next = nextScheduleRunMs(schedule, cursor);
|
|
61
|
+
if (!next || next > throughInclusiveMs)
|
|
62
|
+
break;
|
|
63
|
+
count++;
|
|
64
|
+
cursor = next;
|
|
65
|
+
}
|
|
66
|
+
return count;
|
|
67
|
+
}
|
|
68
|
+
export function scheduleAnchorMs(schedule, createdAt) {
|
|
69
|
+
const value = schedule.type === 'interval' ? schedule.anchorAt : createdAt;
|
|
70
|
+
const parsed = Date.parse(value);
|
|
71
|
+
return Number.isFinite(parsed) ? parsed : Date.now();
|
|
72
|
+
}
|