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
package/src/ui/MessageList.js
CHANGED
|
@@ -34,6 +34,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
34
34
|
*/
|
|
35
35
|
import React from 'react';
|
|
36
36
|
import { Box, Static, Text } from 'ink';
|
|
37
|
+
import { friendlyToolDescription } from '../loop.js';
|
|
38
|
+
import { contentToDisplayText, contentToPlainText } from '../multimodal.js';
|
|
39
|
+
import { splitThinkBlocks } from '../utils/stripThink.js';
|
|
40
|
+
import { figures } from './figures.js';
|
|
41
|
+
import { renderMarkdownLines } from './markdown.js';
|
|
42
|
+
import { theme } from './theme.js';
|
|
37
43
|
/** 中断标记 user message 的固定内容(loop.ts 写入) */
|
|
38
44
|
const INTERRUPT_USER_CONTENT = '(用户按下了 ESC/Ctrl+C 中断了任务)';
|
|
39
45
|
const MAX_TOOL_PREVIEW_LINES = 3;
|
|
@@ -41,6 +47,58 @@ const MAX_TOOL_PREVIEW_LINES = 3;
|
|
|
41
47
|
const NARROW_TERMINAL_ROWS = 28;
|
|
42
48
|
/** reasoning 超过此字符数截尾 —— 防撑爆历史 */
|
|
43
49
|
const REASONING_MAX_CHARS = 2000;
|
|
50
|
+
/**
|
|
51
|
+
* 把 assistant 最终正文拆成展示行:markdown 管线(src/ui/markdown.ts)产出
|
|
52
|
+
* prose/code/fence 三类行,⏺ 锚点落在**第一条非空 prose 行**——答案以代码块
|
|
53
|
+
* 开头时代码顶格在前、⏺ 顺延;全代码答案无 ⏺(代码纯净优先)。
|
|
54
|
+
* 纯文本无 markdown 特征时走快路径,与旧「按 \n 切 + wrap='end'」逐行一致。
|
|
55
|
+
*/
|
|
56
|
+
export function buildAssistantDisplayLines(text) {
|
|
57
|
+
if (text.length === 0)
|
|
58
|
+
return [];
|
|
59
|
+
let anchorPlaced = false;
|
|
60
|
+
return renderMarkdownLines(text).map((line) => {
|
|
61
|
+
if (line.kind !== 'prose') {
|
|
62
|
+
return { content: line.text, prefix: '', kind: line.kind, wrap: 'end' };
|
|
63
|
+
}
|
|
64
|
+
if (!anchorPlaced && line.text.trim() !== '') {
|
|
65
|
+
anchorPlaced = true;
|
|
66
|
+
return { content: line.text, prefix: '⏺ ', kind: line.kind, wrap: 'end' };
|
|
67
|
+
}
|
|
68
|
+
return { content: line.text, prefix: ' ', kind: line.kind, wrap: 'end' };
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 扫 history 里全部 assistant.tool_calls,建 tool_call_id → 人话描述 索引。
|
|
73
|
+
* tool 消息本身只有 content + tool_call_id(不动 history 字节的前提下,
|
|
74
|
+
* 头行要显示「哪个工具在干什么」只能反查发起方)。<Static> 提交时序保证
|
|
75
|
+
* assistant(tool_calls) 恒先于对应 tool 消息入 history,索引命中无竞态。
|
|
76
|
+
*/
|
|
77
|
+
export function buildToolCallIndex(history) {
|
|
78
|
+
const map = new Map();
|
|
79
|
+
for (const m of history) {
|
|
80
|
+
if (m.role !== 'assistant' || !m.tool_calls)
|
|
81
|
+
continue;
|
|
82
|
+
for (const tc of m.tool_calls) {
|
|
83
|
+
map.set(tc.id, {
|
|
84
|
+
toolName: tc.function.name,
|
|
85
|
+
friendly: friendlyToolDescription(tc.function.name, tc.function.arguments),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return map;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 从 Agent 子任务报告的统计尾巴(agent.ts 固定格式
|
|
93
|
+
* 「(子任务「x」[type]:N 轮 · M 次工具调用,K 次失败)」)解析统计数。
|
|
94
|
+
* 失败结果(错误文案)不匹配 → null,头行只显示描述不显示 ✓ 统计。
|
|
95
|
+
*/
|
|
96
|
+
export function agentResultStats(content) {
|
|
97
|
+
const m = /(子任务「[^」]*」\[[^\]]+\]:(\d+) 轮 · (\d+) 次工具调用(?:,(\d+) 次失败)?)/.exec(content);
|
|
98
|
+
if (!m)
|
|
99
|
+
return null;
|
|
100
|
+
return { turns: Number(m[1]), tools: Number(m[2]), failed: m[3] ? Number(m[3]) : 0 };
|
|
101
|
+
}
|
|
44
102
|
/**
|
|
45
103
|
* 把 assistant message 的两个字符串型 reasoning 字段拼成单字符串。
|
|
46
104
|
* `reasoning_details` 是结构化数组,本期不展开。两个字段任一非空即返回拼接结果;
|
|
@@ -80,7 +138,8 @@ export function summarizeTurn(history) {
|
|
|
80
138
|
const turnStartIndices = [];
|
|
81
139
|
for (let i = 0; i < history.length; i++) {
|
|
82
140
|
const m = history[i];
|
|
83
|
-
if (m.role === 'user' &&
|
|
141
|
+
if (m.role === 'user' &&
|
|
142
|
+
contentToPlainText(m.content) !== INTERRUPT_USER_CONTENT) {
|
|
84
143
|
turnStartIndices.push(i);
|
|
85
144
|
}
|
|
86
145
|
}
|
|
@@ -144,6 +203,7 @@ function formatDuration(ms) {
|
|
|
144
203
|
export const MessageList = React.memo(function MessageList({ history, compactGeneration, bannerText, terminalRows, }) {
|
|
145
204
|
const items = React.useMemo(() => {
|
|
146
205
|
const turnMetas = summarizeTurn(history);
|
|
206
|
+
const toolIndex = buildToolCallIndex(history);
|
|
147
207
|
return [
|
|
148
208
|
...(bannerText
|
|
149
209
|
? [
|
|
@@ -158,6 +218,7 @@ export const MessageList = React.memo(function MessageList({ history, compactGen
|
|
|
158
218
|
kind: 'message',
|
|
159
219
|
msg: m,
|
|
160
220
|
turnMeta: turnMetas[idx],
|
|
221
|
+
toolMeta: m.role === 'tool' ? (toolIndex.get(m.tool_call_id) ?? null) : null,
|
|
161
222
|
// 纯派生 key:有 id 用 id,没有就用 idx 兜底。绝不在 render 期 mutate 消息对象
|
|
162
223
|
// (<Static> 已 commit 的行永不重绘,key 仅在 append 对账时用,idx 已足够稳定)。
|
|
163
224
|
key: m.id ?? `message-${idx}`,
|
|
@@ -170,7 +231,7 @@ export const MessageList = React.memo(function MessageList({ history, compactGen
|
|
|
170
231
|
if (item.kind === 'banner') {
|
|
171
232
|
return _jsx(BannerRow, { text: item.text }, item.key);
|
|
172
233
|
}
|
|
173
|
-
return (_jsx(MessageRow, { message: item.msg, turnMeta: item.turnMeta, foldReasoning: foldReasoning }, item.key));
|
|
234
|
+
return (_jsx(MessageRow, { message: item.msg, turnMeta: item.turnMeta, toolMeta: item.toolMeta, foldReasoning: foldReasoning }, item.key));
|
|
174
235
|
} }, compactGeneration));
|
|
175
236
|
});
|
|
176
237
|
function BannerRow({ text }) {
|
|
@@ -179,9 +240,9 @@ function BannerRow({ text }) {
|
|
|
179
240
|
const splitAt = text.indexOf(' ·');
|
|
180
241
|
const head = splitAt >= 0 ? text.slice(0, splitAt) : text;
|
|
181
242
|
const tail = splitAt >= 0 ? text.slice(splitAt) : '';
|
|
182
|
-
return (_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color:
|
|
243
|
+
return (_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: theme.user, bold: true, children: head }), tail.length > 0 && _jsx(Text, { color: theme.subtle, children: tail })] }));
|
|
183
244
|
}
|
|
184
|
-
function MessageRow({ message, turnMeta, foldReasoning, }) {
|
|
245
|
+
function MessageRow({ message, turnMeta, toolMeta, foldReasoning, }) {
|
|
185
246
|
switch (message.role) {
|
|
186
247
|
case 'system': {
|
|
187
248
|
// v2.x:ephemeral system message 是 UI 临时提示(slash 命令输出等),
|
|
@@ -190,20 +251,27 @@ function MessageRow({ message, turnMeta, foldReasoning, }) {
|
|
|
190
251
|
if (!ephemeral)
|
|
191
252
|
return null;
|
|
192
253
|
const lines = message.content.split('\n');
|
|
193
|
-
return (_jsx(Box, { marginBottom: 1, paddingLeft: 2, children: _jsx(Box, { flexDirection: "column", children: lines.map((line, i) => (_jsx(Text, { color:
|
|
254
|
+
return (_jsx(Box, { marginBottom: 1, paddingLeft: 2, children: _jsx(Box, { flexDirection: "column", children: lines.map((line, i) => (_jsx(Text, { color: theme.subtle, dimColor: true, wrap: "end", children: line }, `eph-${i}`))) }) }));
|
|
194
255
|
}
|
|
195
256
|
case 'user': {
|
|
257
|
+
const rule = figures.hr.repeat(6);
|
|
196
258
|
const headerLine = turnMeta !== null
|
|
197
|
-
?
|
|
259
|
+
? `${rule} Turn ${turnMeta.turnN} · ${formatTime(turnMeta.timestamp)} · ${formatDuration(turnMeta.durationMs)} · ${turnMeta.toolsCount} tools ${rule}`
|
|
198
260
|
: null;
|
|
199
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [headerLine !== null && (_jsx(Text, { color:
|
|
261
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [headerLine !== null && (_jsx(Text, { color: theme.subtle, dimColor: true, children: headerLine })), _jsxs(Box, { children: [_jsx(Text, { color: theme.user, bold: true, children: '> ' }), _jsx(Text, { color: theme.user, wrap: "end", children: contentToDisplayText(message.content) })] })] }));
|
|
200
262
|
}
|
|
201
263
|
case 'assistant': {
|
|
202
264
|
// assistant 可能只有 tool_calls 没有 content(content 为 null)
|
|
203
|
-
const
|
|
265
|
+
const raw = message.content ?? '';
|
|
266
|
+
// 展示层切分内联 <think>(MiniMax 等把思维链写进 content,内核有意不剥):
|
|
267
|
+
// thought 并入 💭 块(灰 dim + 折叠,与结构化 reasoning 同款待遇),
|
|
268
|
+
// 正文只显示净化后的部分。纯展示层——history 字节零改动(KV 缓存约束)。
|
|
269
|
+
const { thought, answer } = splitThinkBlocks(raw);
|
|
204
270
|
const tcCount = message.tool_calls?.length ?? 0;
|
|
205
|
-
// reasoning
|
|
206
|
-
let reasoningText = combineReasoning(message)
|
|
271
|
+
// reasoning 拼接:结构化字段在前,内联 <think> 在后
|
|
272
|
+
let reasoningText = [combineReasoning(message), thought]
|
|
273
|
+
.filter(Boolean)
|
|
274
|
+
.join('\n');
|
|
207
275
|
let truncatedCharsHint = '';
|
|
208
276
|
if (reasoningText.length > REASONING_MAX_CHARS) {
|
|
209
277
|
const omitted = reasoningText.length - REASONING_MAX_CHARS;
|
|
@@ -215,17 +283,35 @@ function MessageRow({ message, turnMeta, foldReasoning, }) {
|
|
|
215
283
|
? reasoningLines.slice(0, 2)
|
|
216
284
|
: reasoningLines;
|
|
217
285
|
const hiddenReasoningCount = reasoningLines.length - visibleReasoningLines.length;
|
|
218
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [visibleReasoningLines.length > 0 && (_jsxs(Box, { flexDirection: "column", children: [visibleReasoningLines.map((line, i) => (_jsx(Text, { color:
|
|
219
|
-
|
|
286
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [visibleReasoningLines.length > 0 && (_jsxs(Box, { flexDirection: "column", children: [visibleReasoningLines.map((line, i) => (_jsx(Text, { color: theme.subtle, dimColor: true, wrap: "end", children: i === 0 ? `${figures.thought} ${line}` : ` ${line}` }, `r-${i}`))), hiddenReasoningCount > 0 && (_jsx(Text, { color: theme.subtle, dimColor: true, children: ` ${figures.fold} ${hiddenReasoningCount} 行 reasoning 折叠(终端高度 < ${NARROW_TERMINAL_ROWS})` })), truncatedCharsHint.length > 0 && (_jsx(Text, { color: theme.subtle, dimColor: true, children: ` ${truncatedCharsHint}` }))] })), buildAssistantDisplayLines(answer).map((line, i) => {
|
|
287
|
+
if (line.kind === 'fence') {
|
|
288
|
+
return (_jsx(Text, { color: theme.subtle, dimColor: true, wrap: line.wrap, children: line.content }, `a-${i}`));
|
|
289
|
+
}
|
|
290
|
+
if (line.kind === 'code') {
|
|
291
|
+
return (_jsx(Text, { wrap: line.wrap, children: line.content.length > 0 ? line.content : ' ' }, `a-${i}`));
|
|
292
|
+
}
|
|
293
|
+
return line.prefix === '⏺ ' ? (_jsxs(Box, { children: [_jsx(Text, { color: theme.anchor, bold: true, wrap: line.wrap, children: line.prefix }), _jsx(Text, { wrap: line.wrap, children: line.content.length > 0 ? line.content : ' ' })] }, `a-${i}`)) : (_jsx(Text, { wrap: line.wrap, children: `${line.prefix}${line.content}`.length > 0
|
|
294
|
+
? `${line.prefix}${line.content}`
|
|
295
|
+
: ' ' }, `a-${i}`));
|
|
296
|
+
}), tcCount > 0 && (_jsx(Text, { color: theme.warning, dimColor: true, wrap: "end", children: ` ${figures.corner} 调用了 ${tcCount} 个工具:${(message.tool_calls ?? [])
|
|
220
297
|
.map((tc) => tc.function.name)
|
|
221
298
|
.join(', ')}` }))] }));
|
|
222
299
|
}
|
|
223
300
|
case 'tool': {
|
|
224
301
|
const lines = message.content.split('\n');
|
|
225
|
-
const
|
|
302
|
+
const previewLines = lines.slice(0, MAX_TOOL_PREVIEW_LINES);
|
|
226
303
|
const hidden = Math.max(0, lines.length - MAX_TOOL_PREVIEW_LINES);
|
|
227
304
|
const shortId = message.tool_call_id.slice(-8);
|
|
228
|
-
|
|
305
|
+
// 头行升级:有 toolMeta(发起方反查命中)显示人话描述;Agent 子任务
|
|
306
|
+
// 再解析统计尾巴显示 ✓ N 轮 · M 次工具。无 meta(历史重载等)兜底旧格式。
|
|
307
|
+
const stats = toolMeta?.toolName === 'Agent' ? agentResultStats(message.content) : null;
|
|
308
|
+
const statsTail = stats
|
|
309
|
+
? ` ${figures.ok} ${stats.turns} 轮 · ${stats.tools} 次工具${stats.failed > 0 ? `(${stats.failed} 次失败)` : ''}`
|
|
310
|
+
: '';
|
|
311
|
+
const headText = toolMeta
|
|
312
|
+
? `[${toolMeta.friendly} · #${shortId}]${statsTail}`
|
|
313
|
+
: `[tool result · #${shortId}]`;
|
|
314
|
+
return (_jsx(Box, { marginBottom: 1, paddingLeft: 2, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: theme.subtle, dimColor: true, wrap: "end", children: headText }), previewLines.map((line, i) => (_jsx(Text, { color: theme.subtle, wrap: "end", children: line.length > 0 ? line : ' ' }, `p-${i}`))), hidden > 0 && (_jsx(Text, { color: theme.subtle, dimColor: true, children: `... ${figures.fold} 完整 ${lines.length} 行(输入 /show ${shortId} 查看)` }))] }) }));
|
|
229
315
|
}
|
|
230
316
|
}
|
|
231
317
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
4
|
+
import { theme } from './theme.js';
|
|
5
|
+
export function ModelPicker({ models, currentModelId, title, nullOptionLabel, onSelect, onCancel, }) {
|
|
6
|
+
const enabledModels = models.filter((m) => m.enabled && m.apiKey);
|
|
7
|
+
const hasNullOption = Boolean(nullOptionLabel);
|
|
8
|
+
const nullIndex = hasNullOption ? enabledModels.length : -1;
|
|
9
|
+
const listLength = enabledModels.length + (hasNullOption ? 1 : 0);
|
|
10
|
+
const initialIdx = (() => {
|
|
11
|
+
const idx = enabledModels.findIndex((m) => m.id === currentModelId);
|
|
12
|
+
if (idx >= 0)
|
|
13
|
+
return idx;
|
|
14
|
+
if (hasNullOption && !currentModelId)
|
|
15
|
+
return nullIndex;
|
|
16
|
+
return 0;
|
|
17
|
+
})();
|
|
18
|
+
const [idx, setIdx] = useState(Math.max(0, Math.min(initialIdx, listLength - 1)));
|
|
19
|
+
useInput((input, key) => {
|
|
20
|
+
if (key.escape || (key.ctrl && input === 'c')) {
|
|
21
|
+
onCancel();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (key.upArrow) {
|
|
25
|
+
setIdx((i) => (i - 1 + listLength) % listLength);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (key.downArrow) {
|
|
29
|
+
setIdx((i) => (i + 1) % listLength);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (key.return) {
|
|
33
|
+
if (hasNullOption && idx === nullIndex) {
|
|
34
|
+
onSelect(null);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const target = enabledModels[idx];
|
|
38
|
+
if (target)
|
|
39
|
+
onSelect(target.id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: theme.user, bold: true, children: title }) }), _jsx(Text, { color: theme.subtle, children: "\u5728\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u4E2D\u9009\u62E9\uFF1B\u9009\u62E9\u540E\u7ACB\u5373\u751F\u6548\uFF0C\u540E\u7EED\u8BF7\u6C42\u4F7F\u7528\u65B0\u6A21\u578B\u3002" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [enabledModels.map((m, i) => {
|
|
44
|
+
const active = i === idx;
|
|
45
|
+
const isCurrent = m.id === currentModelId;
|
|
46
|
+
const displayName = m.displayName || m.model;
|
|
47
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: active ? theme.user : undefined, children: [active ? '> ' : ' ', isCurrent ? '✓ ' : ' ', _jsx(Text, { color: active ? theme.user : undefined, bold: isCurrent, children: displayName }), isCurrent ? _jsx(Text, { color: theme.subtle, children: " \uFF08\u5F53\u524D\uFF09" }) : null] }), _jsxs(Text, { color: theme.subtle, children: [' ', m.model, " \u00B7 ", formatContextWindow(m.contextWindow)] })] }, m.id));
|
|
48
|
+
}), hasNullOption && (_jsxs(Text, { color: idx === nullIndex ? theme.user : theme.subtle, children: [idx === nullIndex ? '> ' : ' ', !currentModelId ? '✓ ' : ' ', nullOptionLabel] }))] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.subtle, children: "\u2191\u2193 \u9009\u62E9 \u00B7 Enter \u786E\u8BA4 \u00B7 ESC \u53D6\u6D88" }) })] }));
|
|
49
|
+
}
|
|
50
|
+
function formatContextWindow(tokens) {
|
|
51
|
+
if (tokens >= 1_000_000)
|
|
52
|
+
return `${(tokens / 1_000_000).toFixed(1)}M context`;
|
|
53
|
+
if (tokens >= 1_000)
|
|
54
|
+
return `${Math.round(tokens / 1_000)}K context`;
|
|
55
|
+
return `${tokens} context`;
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { theme } from './theme.js';
|
|
4
|
+
function truncate(s, maxLen) {
|
|
5
|
+
const oneLine = s.replace(/\n/g, ' ').trim();
|
|
6
|
+
if (oneLine.length <= maxLen)
|
|
7
|
+
return oneLine;
|
|
8
|
+
return `${oneLine.slice(0, maxLen - 1)}…`;
|
|
9
|
+
}
|
|
10
|
+
export function QueuedMessagesBanner({ items }) {
|
|
11
|
+
if (items.length === 0)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.warning, paddingX: 1, marginBottom: 1, children: [_jsx(Box, { children: _jsxs(Text, { color: theme.warning, bold: true, children: ["\uD83D\uDCEC \u6392\u961F\u4E2D ", items.length, " \u6761\u8865\u5145\u6D88\u606F\uFF08\u5F53\u524D\u4EFB\u52A1\u7ED3\u675F\u540E\u5C06\u9010\u6761\u5904\u7406\uFF09\uFF1A"] }) }), items.map((item, idx) => (_jsxs(Box, { children: [_jsxs(Text, { color: theme.subtle, dimColor: true, children: [idx + 1, ".", ' '] }), _jsx(Text, { color: theme.user, children: truncate(item.value, 80) })] }, item.id)))] }));
|
|
14
|
+
}
|
package/src/ui/Root.js
CHANGED
|
@@ -4,15 +4,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* src/ui/Root.tsx —— TUI 顶层 phase 切换器
|
|
5
5
|
* ------------------------------------------------------------
|
|
6
6
|
* 作为 Ink 渲染树的根节点,根据"有没有 Provider 配置"决定渲染:
|
|
7
|
-
* - 没有 → <
|
|
7
|
+
* - 没有 → <ConfigMenu mode="first-run">:菜单式分段配置,完成基座
|
|
8
|
+
* 模型配置(可选顺带配其它项)后切到 App
|
|
8
9
|
* - 有 → <App>:常规对话界面
|
|
9
10
|
*
|
|
10
11
|
* 为什么需要这一层而不是直接在 main.tsx 二选一渲染?
|
|
11
|
-
*
|
|
12
|
-
* 切换是最自然的方式,无需 ink unmount/remount 的额外开销。
|
|
12
|
+
* 菜单里选"完成退出"后必须直接进 App,不能让用户手动重跑命令。在 React
|
|
13
|
+
* 树里用 state 切换是最自然的方式,无需 ink unmount/remount 的额外开销。
|
|
13
14
|
*
|
|
14
|
-
* initialHistory 的构造(buildFullSystemPrompt +
|
|
15
|
-
*
|
|
15
|
+
* initialHistory 的构造(buildFullSystemPrompt + 历史持久化加载)在菜单退出
|
|
16
|
+
* 后才跑,因为:
|
|
16
17
|
* - 系统提示词本身不依赖 provider,但流程上推迟到"确定要进 App"那一刻
|
|
17
18
|
* 最干净。
|
|
18
19
|
* - 第一次启动时常常没历史可加载,buildInitialHistory 行为是只返 system
|
|
@@ -22,11 +23,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
22
23
|
import { useEffect, useState } from 'react';
|
|
23
24
|
import { Box, Text } from 'ink';
|
|
24
25
|
import { getWorkingDir } from '../bootstrap/workingDir.js';
|
|
25
|
-
import {
|
|
26
|
+
import { ConfigMenu } from '../cli/configMenu.js';
|
|
26
27
|
import { loadContext } from '../context/persistContext.js';
|
|
28
|
+
import { getActiveSession } from '../context/sessionRegistry.js';
|
|
29
|
+
import { resolveSessionFile } from '../context/sessionPath.js';
|
|
30
|
+
import { workspaceIndexService } from '../context/workspaceIndex.js';
|
|
27
31
|
import { buildFullSystemPrompt } from '../prompts/system.js';
|
|
28
32
|
import { ALL_TOOLS } from '../tools/index.js';
|
|
29
33
|
import { App } from './App.js';
|
|
34
|
+
import { theme } from './theme.js';
|
|
30
35
|
export function Root({ initialProvider }) {
|
|
31
36
|
const [phase, setPhase] = useState(initialProvider
|
|
32
37
|
? { kind: 'loading-history', provider: initialProvider }
|
|
@@ -46,12 +51,13 @@ export function Root({ initialProvider }) {
|
|
|
46
51
|
};
|
|
47
52
|
}, [phase]);
|
|
48
53
|
if (phase.kind === 'wizard') {
|
|
49
|
-
return (_jsx(
|
|
50
|
-
|
|
54
|
+
return (_jsx(ConfigMenu, { mode: "first-run", onDone: (provider) => {
|
|
55
|
+
if (provider)
|
|
56
|
+
setPhase({ kind: 'loading-history', provider });
|
|
51
57
|
} }));
|
|
52
58
|
}
|
|
53
59
|
if (phase.kind === 'loading-history') {
|
|
54
|
-
return (_jsx(Box, { paddingX: 1, children: _jsx(Text, { color:
|
|
60
|
+
return (_jsx(Box, { paddingX: 1, children: _jsx(Text, { color: theme.subtle, children: "\u6B63\u5728\u52A0\u8F7D\u5386\u53F2\u4E0A\u4E0B\u6587..." }) }));
|
|
55
61
|
}
|
|
56
62
|
return _jsx(App, { provider: phase.provider, initialHistory: phase.initialHistory });
|
|
57
63
|
}
|
|
@@ -60,9 +66,11 @@ export function Root({ initialProvider }) {
|
|
|
60
66
|
* 这里独立一份是为了让 Root 内部能在向导成功后即时构造,不必返工 main.tsx。
|
|
61
67
|
*/
|
|
62
68
|
async function buildInitialHistory() {
|
|
69
|
+
await workspaceIndexService.register(getWorkingDir()).catch(() => { });
|
|
63
70
|
const content = await buildFullSystemPrompt(getWorkingDir(), ALL_TOOLS);
|
|
64
71
|
const fresh = { role: 'system', content };
|
|
65
|
-
const
|
|
72
|
+
const activeSession = await getActiveSession(getWorkingDir());
|
|
73
|
+
const persisted = await loadContext(await resolveSessionFile(getWorkingDir(), activeSession));
|
|
66
74
|
if (!persisted || persisted.length === 0)
|
|
67
75
|
return [fresh];
|
|
68
76
|
const rest = persisted[0]?.role === 'system' ? persisted.slice(1) : persisted;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ============================================================
|
|
4
|
+
* src/ui/SessionPicker.tsx —— /session /sessions /resume 的会话选择界面
|
|
5
|
+
* ------------------------------------------------------------
|
|
6
|
+
* 内核(context/sessionRegistry.ts)早就支持同一工作目录下多个隔离 session,
|
|
7
|
+
* 这个组件只是给 TUI 补上一个真实的"列出 + 选择 + 新建"入口——此前 App.tsx
|
|
8
|
+
* 的 /session /sessions 只回显固定提示语,不做真正的切换/列出。
|
|
9
|
+
*
|
|
10
|
+
* 交互设计照抄已验证过的 AskQuestion.tsx:手写 useInput,↑↓ 移动 + Enter 确认 +
|
|
11
|
+
* ESC 取消,零新依赖(不引 ink-select-input)。列表末尾追加一个"+ 新建会话"伪
|
|
12
|
+
* 选项,选中后进入文本子模式输入标题——与 AskQuestion.tsx 处理"其他(自由输入)"
|
|
13
|
+
* 伪选项完全同构。
|
|
14
|
+
* ============================================================
|
|
15
|
+
*/
|
|
16
|
+
import { useState } from 'react';
|
|
17
|
+
import { Box, Text, useInput } from 'ink';
|
|
18
|
+
import { theme } from './theme.js';
|
|
19
|
+
const PREVIEW_MAX = 60;
|
|
20
|
+
function clampPreview(s) {
|
|
21
|
+
const oneLine = s.replace(/\s+/g, ' ').trim();
|
|
22
|
+
return oneLine.length > PREVIEW_MAX ? `${oneLine.slice(0, PREVIEW_MAX - 1)}…` : oneLine;
|
|
23
|
+
}
|
|
24
|
+
/** 粗粒度相对时间,够用即可(不追求 Claude Code 那种精确到分钟的实现)。 */
|
|
25
|
+
function formatRelativeTime(ms) {
|
|
26
|
+
const diff = Date.now() - ms;
|
|
27
|
+
if (diff < 60_000)
|
|
28
|
+
return '刚刚';
|
|
29
|
+
const minutes = Math.floor(diff / 60_000);
|
|
30
|
+
if (minutes < 60)
|
|
31
|
+
return `${minutes}分钟前`;
|
|
32
|
+
const hours = Math.floor(minutes / 60);
|
|
33
|
+
if (hours < 24)
|
|
34
|
+
return `${hours}小时前`;
|
|
35
|
+
const days = Math.floor(hours / 24);
|
|
36
|
+
return `${days}天前`;
|
|
37
|
+
}
|
|
38
|
+
/** 一行元数据:相对时间 · 最后一条消息预览(借用 kakadeai formatLogMetadata 的 parts+join 写法,简化到本项目实际有的字段)。 */
|
|
39
|
+
function formatMetaLine(s) {
|
|
40
|
+
const parts = [formatRelativeTime(s.updatedAt)];
|
|
41
|
+
if (s.lastMessagePreview)
|
|
42
|
+
parts.push(clampPreview(s.lastMessagePreview));
|
|
43
|
+
return parts.join(' · ');
|
|
44
|
+
}
|
|
45
|
+
export function SessionPicker({ sessions, activeSessionId, onSelect, onCreate, onCancel, }) {
|
|
46
|
+
// 末尾"+ 新建会话"伪选项占据下标 sessions.length
|
|
47
|
+
const createIndex = sessions.length;
|
|
48
|
+
const listLength = sessions.length + 1;
|
|
49
|
+
const [idx, setIdx] = useState(0);
|
|
50
|
+
const [textMode, setTextMode] = useState(false);
|
|
51
|
+
const [draft, setDraft] = useState('');
|
|
52
|
+
useInput((input, key) => {
|
|
53
|
+
if (textMode) {
|
|
54
|
+
if (key.escape) {
|
|
55
|
+
// 退回列表,不取消整个 picker
|
|
56
|
+
setTextMode(false);
|
|
57
|
+
setDraft('');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (key.return) {
|
|
61
|
+
const title = draft.trim();
|
|
62
|
+
onCreate(title); // 空标题时 createSession 会用它自己的默认标题兜底
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (key.backspace || key.delete) {
|
|
66
|
+
setDraft((s) => s.slice(0, -1));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (input && !key.meta && !key.ctrl) {
|
|
70
|
+
setDraft((s) => s + input);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (key.escape || (key.ctrl && input === 'c')) {
|
|
75
|
+
onCancel();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (key.upArrow) {
|
|
79
|
+
setIdx((i) => (i - 1 + listLength) % listLength);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (key.downArrow) {
|
|
83
|
+
setIdx((i) => (i + 1) % listLength);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (key.return) {
|
|
87
|
+
if (idx === createIndex) {
|
|
88
|
+
setTextMode(true);
|
|
89
|
+
setDraft('');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const target = sessions[idx];
|
|
93
|
+
if (target)
|
|
94
|
+
onSelect(target.id);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: theme.user, bold: true, children: ["\u9009\u62E9\u4F1A\u8BDD\uFF08\u5F53\u524D ", sessions.length, " \u4E2A\uFF09"] }) }), textMode ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: theme.subtle, children: "\u270F\uFE0F \u65B0\u4F1A\u8BDD\u6807\u9898\uFF08\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4\u6807\u9898\uFF09\uFF1A" }), _jsx(Box, { marginTop: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: _jsx(Text, { children: draft || ' ' }) }), _jsx(Text, { color: theme.subtle, children: "\u8F93\u5165\u540E Enter \u521B\u5EFA \u00B7 ESC \u8FD4\u56DE\u5217\u8868" })] })) : (_jsxs(Box, { flexDirection: "column", children: [sessions.map((s, i) => {
|
|
98
|
+
const active = i === idx;
|
|
99
|
+
const isCurrent = s.id === activeSessionId;
|
|
100
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: active ? theme.user : undefined, children: [active ? '> ' : ' ', s.title, isCurrent ? ' (当前)' : ''] }), _jsxs(Text, { color: theme.subtle, children: [' ', formatMetaLine(s)] })] }, s.id));
|
|
101
|
+
}), _jsxs(Text, { color: idx === createIndex ? theme.user : undefined, children: [idx === createIndex ? '> ' : ' ', "+ \u65B0\u5EFA\u4F1A\u8BDD"] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.subtle, children: "\u2191\u2193 \u9009\u62E9 \u00B7 Enter \u786E\u8BA4 \u00B7 ESC \u53D6\u6D88" }) })] }))] }));
|
|
102
|
+
}
|
package/src/ui/StatusLine.js
CHANGED
|
@@ -14,6 +14,7 @@ import { homedir } from 'node:os';
|
|
|
14
14
|
import { sep } from 'node:path';
|
|
15
15
|
import { getWorkingDir } from '../bootstrap/workingDir.js';
|
|
16
16
|
import { useTokenUsage } from './hooks/useTokenUsage.js';
|
|
17
|
+
import { theme } from './theme.js';
|
|
17
18
|
/**
|
|
18
19
|
* React.memo 包装。
|
|
19
20
|
*
|
|
@@ -23,12 +24,20 @@ import { useTokenUsage } from './hooks/useTokenUsage.js';
|
|
|
23
24
|
*
|
|
24
25
|
* 流式 streamingText 高频更新不影响 history 引用,StatusLine 不会被带着 rerender。
|
|
25
26
|
*/
|
|
26
|
-
export const StatusLine = React.memo(function StatusLine({ provider, history, pluginProgress, }) {
|
|
27
|
-
const
|
|
27
|
+
export const StatusLine = React.memo(function StatusLine({ provider, history, pluginProgress, contextUsage, }) {
|
|
28
|
+
const estimated = useTokenUsage(history, provider);
|
|
29
|
+
const usage = contextUsage
|
|
30
|
+
? {
|
|
31
|
+
tokens: contextUsage.usedTokens,
|
|
32
|
+
threshold: contextUsage.compactThreshold,
|
|
33
|
+
contextWindow: contextUsage.contextWindow,
|
|
34
|
+
toThreshold: contextUsage.compactThreshold - contextUsage.usedTokens,
|
|
35
|
+
}
|
|
36
|
+
: estimated;
|
|
28
37
|
const ratio = usage.tokens / usage.threshold;
|
|
29
|
-
const color = ratio >= 1 ?
|
|
38
|
+
const color = ratio >= 1 ? theme.error : ratio >= 0.7 ? theme.warning : theme.ok;
|
|
30
39
|
const cwdDisplay = shortenPath(getWorkingDir());
|
|
31
|
-
return (_jsxs(Box, { children: [pluginProgress && (_jsxs(_Fragment, { children: [_jsxs(Text, { color:
|
|
40
|
+
return (_jsxs(Box, { children: [pluginProgress && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.plugin, children: ["\uD83D\uDD04 ", pluginProgress.pluginId, " "] }), pluginProgress.current !== undefined && (_jsxs(Text, { color: theme.plugin, children: [pluginProgress.current, "/", pluginProgress.max ?? '?'] })), _jsx(Text, { color: theme.subtle, children: ' · ' })] })), _jsx(Text, { color: theme.user, children: "cwd " }), _jsx(Text, { color: theme.subtle, children: cwdDisplay }), _jsx(Text, { color: theme.subtle, children: ' · ' }), _jsxs(Text, { color: theme.subtle, children: [provider.name, "/", provider.model] }), _jsx(Text, { color: theme.subtle, children: ' · ' }), _jsxs(Text, { color: color, children: ["tokens ", fmt(usage.tokens), " / ", fmt(usage.contextWindow)] }), _jsx(Text, { color: theme.subtle, children: ' · ' }), _jsx(Text, { color: color, children: usage.toThreshold > 0 ? `距压缩 ${fmt(usage.toThreshold)}` : `已超阈值(下轮压缩)` })] }));
|
|
32
41
|
});
|
|
33
42
|
/** 把整数格式化为 1.2K / 12.3K / 1.5M */
|
|
34
43
|
function fmt(n) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
4
|
+
import { theme } from './theme.js';
|
|
5
|
+
export function WorkspacePicker({ workspaces, currentPath, currentSessionId, onSelect, onCancel }) {
|
|
6
|
+
const available = useMemo(() => workspaces.filter((workspace) => workspace.sessions.length > 0), [workspaces]);
|
|
7
|
+
const [workspaceIndex, setWorkspaceIndex] = useState(0);
|
|
8
|
+
const [selectedWorkspace, setSelectedWorkspace] = useState(null);
|
|
9
|
+
const [sessionIndex, setSessionIndex] = useState(0);
|
|
10
|
+
const items = selectedWorkspace?.sessions ?? available;
|
|
11
|
+
const index = selectedWorkspace ? sessionIndex : workspaceIndex;
|
|
12
|
+
const setIndex = selectedWorkspace ? setSessionIndex : setWorkspaceIndex;
|
|
13
|
+
useInput((input, key) => {
|
|
14
|
+
if (key.escape || (key.ctrl && input === 'c')) {
|
|
15
|
+
if (selectedWorkspace) {
|
|
16
|
+
setSelectedWorkspace(null);
|
|
17
|
+
setSessionIndex(0);
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
onCancel();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!items.length)
|
|
24
|
+
return;
|
|
25
|
+
if (key.upArrow) {
|
|
26
|
+
setIndex((value) => (value - 1 + items.length) % items.length);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (key.downArrow) {
|
|
30
|
+
setIndex((value) => (value + 1) % items.length);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!key.return)
|
|
34
|
+
return;
|
|
35
|
+
if (!selectedWorkspace) {
|
|
36
|
+
const workspace = available[workspaceIndex];
|
|
37
|
+
if (workspace) {
|
|
38
|
+
if (!workspace.available)
|
|
39
|
+
return;
|
|
40
|
+
setSelectedWorkspace(workspace);
|
|
41
|
+
const activeIndex = workspace.sessions.findIndex((session) => session.id === workspace.activeSessionId);
|
|
42
|
+
setSessionIndex(Math.max(0, activeIndex));
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const session = selectedWorkspace.sessions[sessionIndex];
|
|
47
|
+
if (session)
|
|
48
|
+
onSelect(selectedWorkspace.displayPath, session.id);
|
|
49
|
+
});
|
|
50
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Text, { color: theme.user, bold: true, children: selectedWorkspace ? `${selectedWorkspace.displayName} · 选择会话` : `选择工作区(${available.length})` }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [!items.length ? _jsx(Text, { color: theme.subtle, children: "\u6682\u65E0\u53EF\u6062\u590D\u7684\u5DE5\u4F5C\u533A\u4F1A\u8BDD" }) : null, selectedWorkspace
|
|
51
|
+
? selectedWorkspace.sessions.map((session, itemIndex) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: itemIndex === sessionIndex ? theme.user : undefined, children: [itemIndex === sessionIndex ? '> ' : ' ', session.title, selectedWorkspace.displayPath === currentPath && session.id === currentSessionId ? ' (当前)' : ''] }), session.lastMessagePreview ? _jsxs(Text, { color: theme.subtle, children: [" ", session.lastMessagePreview.slice(0, 72)] }) : null] }, session.id)))
|
|
52
|
+
: available.map((workspace, itemIndex) => (_jsxs(Text, { color: itemIndex === workspaceIndex ? theme.user : workspace.available ? undefined : theme.subtle, children: [itemIndex === workspaceIndex ? '> ' : ' ', workspace.displayName, " \u00B7 ", workspace.sessions.length, " \u4E2A\u4F1A\u8BDD", !workspace.available ? ' · 未连接' : ''] }, workspace.id)))] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.subtle, children: !selectedWorkspace && available[workspaceIndex]?.available === false
|
|
53
|
+
? '该工作区未连接,重新挂载磁盘后才能打开 · ESC 取消'
|
|
54
|
+
: `↑↓ 选择 · Enter 确认${selectedWorkspace ? ' · ESC 返回工作区' : ' · ESC 取消'}` }) })] }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* src/ui/figures.ts —— TUI 符号表(单一出处)
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 借鉴 Claude Code 的 constants/figures.ts:所有语义符号集中一处,
|
|
6
|
+
* 组件不再散落硬编码字符。
|
|
7
|
+
*
|
|
8
|
+
* ⚠️ 出现在 LiveArea(live 区)的字形必须被 liveViewport.charWidth
|
|
9
|
+
* 按宽度 2 上界覆盖(INV-1 行宽记账依赖它,宁宽不窄)——新增符号时
|
|
10
|
+
* 确认其码点落在 charWidth 已覆盖的区间内。
|
|
11
|
+
*
|
|
12
|
+
* SPINNER_FRAMES 留在 LiveArea 本地:它是动画帧组不是语义符号。
|
|
13
|
+
* ============================================================
|
|
14
|
+
*/
|
|
15
|
+
export const figures = {
|
|
16
|
+
/** 答案锚点(assistant 首条 prose 行前缀) */
|
|
17
|
+
anchor: '⏺',
|
|
18
|
+
/** 思维链块 */
|
|
19
|
+
thought: '💭',
|
|
20
|
+
/** 折叠提示 */
|
|
21
|
+
fold: '▾',
|
|
22
|
+
/** 工作流步骤开始 */
|
|
23
|
+
step: '▶',
|
|
24
|
+
/** 成功 */
|
|
25
|
+
ok: '✓',
|
|
26
|
+
/** 失败 */
|
|
27
|
+
fail: '✗',
|
|
28
|
+
/** 跳过 */
|
|
29
|
+
skip: '⊘',
|
|
30
|
+
/** 树分支(非末条) */
|
|
31
|
+
branch: '├─',
|
|
32
|
+
/** 树末条 */
|
|
33
|
+
corner: '└─',
|
|
34
|
+
/** 树竖线 */
|
|
35
|
+
pipe: '│',
|
|
36
|
+
/** 结果/子行连接符(借鉴 Claude Code 的 ⎿ 语汇) */
|
|
37
|
+
elbow: '⎿',
|
|
38
|
+
/** 蜂群(并行子任务)头行 */
|
|
39
|
+
swarm: '⚡',
|
|
40
|
+
/** 引用块竖条 */
|
|
41
|
+
quote: '▎',
|
|
42
|
+
/** 水平分隔 */
|
|
43
|
+
hr: '─',
|
|
44
|
+
};
|