@armadra/agent 0.3.0 → 0.5.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/CHANGELOG.md +257 -0
- package/README.md +263 -95
- package/THIRD_PARTY_NOTICES.md +34 -0
- package/dist/acp.d.ts +18 -0
- package/dist/acp.js +19 -0
- package/dist/agent/limits.d.ts +38 -0
- package/dist/agent/limits.js +127 -0
- package/dist/agent/loop-guard.d.ts +38 -0
- package/dist/agent/loop-guard.js +95 -0
- package/dist/agent/loop.d.ts +4 -0
- package/dist/agent/loop.js +7 -0
- package/dist/agent/prompt-rules.d.ts +12 -0
- package/dist/agent/prompt-rules.js +18 -0
- package/dist/agent/reminders.d.ts +59 -0
- package/dist/agent/reminders.js +327 -0
- package/dist/agent/retry.d.ts +1 -1
- package/dist/agent/retry.js +2 -1
- package/dist/agent/session-cache.d.ts +5 -0
- package/dist/agent/session-cache.js +18 -2
- package/dist/agent/session-classifier.d.ts +18 -0
- package/dist/agent/session-classifier.js +105 -0
- package/dist/agent/session-compaction.d.ts +35 -6
- package/dist/agent/session-compaction.js +157 -31
- package/dist/agent/session-core.d.ts +40 -1
- package/dist/agent/session-extensions.d.ts +61 -0
- package/dist/agent/session-extensions.js +129 -0
- package/dist/agent/session-images.d.ts +23 -0
- package/dist/agent/session-images.js +97 -0
- package/dist/agent/session-plan.d.ts +21 -0
- package/dist/agent/session-plan.js +524 -0
- package/dist/agent/session-rewind.d.ts +81 -0
- package/dist/agent/session-rewind.js +354 -0
- package/dist/agent/session-run.d.ts +28 -1
- package/dist/agent/session-run.js +157 -6
- package/dist/agent/session-settings.d.ts +49 -0
- package/dist/agent/session-settings.js +95 -0
- package/dist/agent/session-subagent.d.ts +36 -24
- package/dist/agent/session-subagent.js +259 -129
- package/dist/agent/session-sync.d.ts +10 -3
- package/dist/agent/session-sync.js +37 -8
- package/dist/agent/session-telemetry.d.ts +39 -0
- package/dist/agent/session-telemetry.js +231 -0
- package/dist/agent/session-tools.js +63 -3
- package/dist/agent/session.d.ts +33 -29
- package/dist/agent/session.js +91 -126
- package/dist/agent/subagent-registry.d.ts +91 -0
- package/dist/agent/subagent-registry.js +494 -0
- package/dist/agent/system-prompt.d.ts +6 -3
- package/dist/agent/system-prompt.js +7 -2
- package/dist/agent/tool-runner.d.ts +8 -1
- package/dist/agent/tool-runner.js +72 -6
- package/dist/agent/types-w5.d.ts +192 -0
- package/dist/agent/types-w5.js +10 -0
- package/dist/agent/types.d.ts +55 -4
- package/dist/agent/types.js +2 -0
- package/dist/agent/worktree.d.ts +36 -0
- package/dist/agent/worktree.js +86 -0
- package/dist/agents/builtin.d.ts +14 -0
- package/dist/agents/builtin.js +39 -0
- package/dist/agents/catalog.d.ts +43 -0
- package/dist/agents/catalog.js +82 -0
- package/dist/agents/discover.d.ts +35 -0
- package/dist/agents/discover.js +83 -0
- package/dist/agents/external.d.ts +82 -0
- package/dist/agents/external.js +326 -0
- package/dist/agents/parse.d.ts +18 -0
- package/dist/agents/parse.js +116 -0
- package/dist/agents/result.d.ts +32 -0
- package/dist/agents/result.js +67 -0
- package/dist/agents/task-control.d.ts +17 -0
- package/dist/agents/task-control.js +17 -0
- package/dist/agents/task-record.d.ts +78 -0
- package/dist/agents/task-record.js +141 -0
- package/dist/agents/types.d.ts +46 -0
- package/dist/agents/types.js +8 -0
- package/dist/ai/apis/anthropic-compat.d.ts +36 -0
- package/dist/ai/apis/anthropic-compat.js +92 -0
- package/dist/ai/apis/anthropic-messages.js +3 -2
- package/dist/ai/apis/anthropic-request.d.ts +7 -6
- package/dist/ai/apis/anthropic-request.js +10 -28
- package/dist/ai/apis/cache-params.d.ts +11 -2
- package/dist/ai/apis/cache-params.js +25 -6
- package/dist/ai/apis/google-generative-ai.js +3 -2
- package/dist/ai/apis/openai-compat.d.ts +4 -1
- package/dist/ai/apis/openai-compat.js +8 -1
- package/dist/ai/apis/openai-completions.js +3 -2
- package/dist/ai/apis/openai-responses.js +3 -2
- package/dist/ai/http.d.ts +28 -6
- package/dist/ai/http.js +41 -8
- package/dist/ai/image-limits.d.ts +45 -0
- package/dist/ai/image-limits.js +68 -0
- package/dist/ai/providers/builtin.d.ts +18 -6
- package/dist/ai/providers/builtin.js +135 -6
- package/dist/ai/providers/catalog-data.js +17 -13
- package/dist/ai/providers/catalog.d.ts +60 -7
- package/dist/ai/providers/catalog.js +197 -38
- package/dist/ai/providers/channels.d.ts +33 -3
- package/dist/ai/providers/channels.js +108 -7
- package/dist/ai/providers/enrich.d.ts +6 -3
- package/dist/ai/providers/enrich.js +19 -4
- package/dist/ai/providers/models-dev-cache.d.ts +28 -24
- package/dist/ai/providers/models-dev-cache.js +92 -78
- package/dist/ai/providers/models-dev-data.d.ts +7 -0
- package/dist/ai/providers/models-dev-data.js +32 -0
- package/dist/ai/providers/models-dev-snapshot.d.ts +50 -0
- package/dist/ai/providers/models-dev-snapshot.js +137 -0
- package/dist/ai/providers/models-dev.d.ts +51 -10
- package/dist/ai/providers/models-dev.js +132 -39
- package/dist/ai/providers/registry.d.ts +28 -11
- package/dist/ai/providers/registry.js +112 -65
- package/dist/ai/providers/suggest.d.ts +18 -0
- package/dist/ai/providers/suggest.js +72 -0
- package/dist/ai/sse.d.ts +6 -2
- package/dist/ai/sse.js +22 -2
- package/dist/ai/types.d.ts +37 -4
- package/dist/ai/types.js +5 -0
- package/dist/bundle/ama.cjs +41979 -21147
- package/dist/checkpoints/backend.d.ts +61 -0
- package/dist/checkpoints/backend.js +135 -0
- package/dist/checkpoints/blobs.d.ts +60 -0
- package/dist/checkpoints/blobs.js +203 -0
- package/dist/checkpoints/gc.d.ts +47 -0
- package/dist/checkpoints/gc.js +144 -0
- package/dist/checkpoints/git-head.d.ts +15 -0
- package/dist/checkpoints/git-head.js +89 -0
- package/dist/checkpoints/index.d.ts +17 -0
- package/dist/checkpoints/index.js +17 -0
- package/dist/checkpoints/replay.d.ts +48 -0
- package/dist/checkpoints/replay.js +154 -0
- package/dist/checkpoints/restore.d.ts +86 -0
- package/dist/checkpoints/restore.js +263 -0
- package/dist/checkpoints/settings.d.ts +14 -0
- package/dist/checkpoints/settings.js +23 -0
- package/dist/checkpoints/shadow-git.d.ts +108 -0
- package/dist/checkpoints/shadow-git.js +491 -0
- package/dist/checkpoints/shadow-restore.d.ts +25 -0
- package/dist/checkpoints/shadow-restore.js +128 -0
- package/dist/checkpoints/tracker.d.ts +64 -0
- package/dist/checkpoints/tracker.js +192 -0
- package/dist/checkpoints/types.d.ts +99 -0
- package/dist/checkpoints/types.js +12 -0
- package/dist/cli/args.d.ts +26 -7
- package/dist/cli/args.js +75 -82
- package/dist/cli/bootstrap.js +40 -4
- package/dist/cli/codemode-notice.d.ts +21 -0
- package/dist/cli/codemode-notice.js +56 -0
- package/dist/cli/compose-agents.d.ts +27 -0
- package/dist/cli/compose-agents.js +111 -0
- package/dist/cli/compose-extensions.d.ts +29 -0
- package/dist/cli/compose-extensions.js +44 -0
- package/dist/cli/compose-session.d.ts +8 -0
- package/dist/cli/compose-session.js +76 -2
- package/dist/cli/compose-store.d.ts +1 -1
- package/dist/cli/compose-store.js +3 -1
- package/dist/cli/compose.d.ts +17 -4
- package/dist/cli/compose.js +60 -14
- package/dist/cli/default-model.d.ts +38 -1
- package/dist/cli/default-model.js +96 -9
- package/dist/cli/deps.d.ts +42 -0
- package/dist/cli/exit-codes.d.ts +12 -0
- package/dist/cli/exit-codes.js +15 -0
- package/dist/cli/fake-visibility.d.ts +13 -0
- package/dist/cli/fake-visibility.js +26 -0
- package/dist/cli/from-prompt.d.ts +18 -0
- package/dist/cli/from-prompt.js +49 -0
- package/dist/cli/help-text.d.ts +4 -0
- package/dist/cli/help-text.js +102 -0
- package/dist/cli/main.d.ts +9 -2
- package/dist/cli/main.js +77 -3
- package/dist/cli/proxy.d.ts +51 -0
- package/dist/cli/proxy.js +135 -0
- package/dist/cli/startup-screen.d.ts +29 -0
- package/dist/cli/startup-screen.js +51 -2
- package/dist/cli/startup-steps.d.ts +1 -1
- package/dist/cli/startup-steps.js +21 -13
- package/dist/cli/subcommands/config.d.ts +22 -3
- package/dist/cli/subcommands/config.js +119 -21
- package/dist/cli/subcommands/context.js +4 -1
- package/dist/cli/subcommands/doctor.js +33 -1
- package/dist/cli/subcommands/init.js +2 -1
- package/dist/cli/subcommands/models-discover.d.ts +15 -9
- package/dist/cli/subcommands/models-discover.js +58 -52
- package/dist/cli/subcommands/models.d.ts +2 -0
- package/dist/cli/subcommands/models.js +33 -14
- package/dist/cli/subcommands/probe-runner.d.ts +96 -0
- package/dist/cli/subcommands/probe-runner.js +264 -0
- package/dist/cli/subcommands/providers-probe.d.ts +34 -0
- package/dist/cli/subcommands/providers-probe.js +87 -0
- package/dist/cli/subcommands/providers.d.ts +3 -2
- package/dist/cli/subcommands/providers.js +53 -51
- package/dist/cli/subcommands/sessions-export.d.ts +10 -0
- package/dist/cli/subcommands/sessions-export.js +59 -0
- package/dist/cli/subcommands/sessions-search.d.ts +13 -0
- package/dist/cli/subcommands/sessions-search.js +103 -0
- package/dist/cli/subcommands/sessions.d.ts +6 -3
- package/dist/cli/subcommands/sessions.js +58 -3
- package/dist/cli/subcommands/stats.d.ts +17 -0
- package/dist/cli/subcommands/stats.js +198 -0
- package/dist/cli/system-prompt-arg.d.ts +11 -0
- package/dist/cli/system-prompt-arg.js +34 -0
- package/dist/codemode/capability.d.ts +24 -7
- package/dist/codemode/capability.js +38 -10
- package/dist/codemode/host-side.d.ts +14 -0
- package/dist/codemode/host-side.js +24 -1
- package/dist/codemode/modes.d.ts +4 -11
- package/dist/codemode/modes.js +5 -27
- package/dist/codemode/tool.d.ts +18 -14
- package/dist/codemode/tool.js +76 -31
- package/dist/compaction/breaker.d.ts +25 -9
- package/dist/compaction/breaker.js +47 -17
- package/dist/compaction/estimate.d.ts +11 -3
- package/dist/compaction/estimate.js +64 -22
- package/dist/compaction/image-budget.d.ts +45 -0
- package/dist/compaction/image-budget.js +115 -0
- package/dist/compaction/post-compact.d.ts +38 -0
- package/dist/compaction/post-compact.js +152 -0
- package/dist/compaction/protect.d.ts +27 -0
- package/dist/compaction/protect.js +56 -0
- package/dist/compaction/prune-tier.d.ts +58 -12
- package/dist/compaction/prune-tier.js +120 -54
- package/dist/compaction/summarize-tier.d.ts +23 -4
- package/dist/compaction/summarize-tier.js +100 -29
- package/dist/config/checker.d.ts +28 -0
- package/dist/config/checker.js +97 -0
- package/dist/config/init.d.ts +6 -2
- package/dist/config/init.js +12 -5
- package/dist/config/json-schema.d.ts +1 -0
- package/dist/config/json-schema.js +98 -4
- package/dist/config/key-docs.d.ts +22 -0
- package/dist/config/key-docs.js +174 -0
- package/dist/config/merge.d.ts +12 -9
- package/dist/config/merge.js +102 -13
- package/dist/config/profile.d.ts +2 -0
- package/dist/config/profile.js +2 -0
- package/dist/config/schema-w5.d.ts +18 -0
- package/dist/config/schema-w5.js +109 -0
- package/dist/config/schema.d.ts +5 -9
- package/dist/config/schema.js +91 -118
- package/dist/config/types-w5.d.ts +118 -0
- package/dist/config/types-w5.js +20 -0
- package/dist/config/types.d.ts +84 -7
- package/dist/config/types.js +29 -1
- package/dist/drivers/acp/client.d.ts +57 -0
- package/dist/drivers/acp/client.js +160 -0
- package/dist/drivers/acp/driver.d.ts +31 -0
- package/dist/drivers/acp/driver.js +274 -0
- package/dist/drivers/acp/testing/fake-agent-main.d.ts +5 -0
- package/dist/drivers/acp/testing/fake-agent-main.js +7 -0
- package/dist/drivers/acp/testing/fake-agent.d.ts +27 -0
- package/dist/drivers/acp/testing/fake-agent.js +211 -0
- package/dist/drivers/acp/types.d.ts +285 -0
- package/dist/drivers/acp/types.js +36 -0
- package/dist/drivers/agents.d.ts +58 -0
- package/dist/drivers/agents.js +142 -0
- package/dist/drivers/base.d.ts +35 -0
- package/dist/drivers/base.js +59 -0
- package/dist/drivers/catalog.d.ts +46 -0
- package/dist/drivers/catalog.js +167 -0
- package/dist/drivers/env.d.ts +20 -0
- package/dist/drivers/env.js +46 -0
- package/dist/drivers/host-runners.d.ts +18 -0
- package/dist/drivers/host-runners.js +45 -0
- package/dist/drivers/jsonrpc.d.ts +58 -0
- package/dist/drivers/jsonrpc.js +180 -0
- package/dist/drivers/native/claude-normalize.d.ts +46 -0
- package/dist/drivers/native/claude-normalize.js +106 -0
- package/dist/drivers/native/claude-stream.d.ts +29 -0
- package/dist/drivers/native/claude-stream.js +456 -0
- package/dist/drivers/native/codex-app-server.d.ts +26 -0
- package/dist/drivers/native/codex-app-server.js +407 -0
- package/dist/drivers/native/codex-normalize.d.ts +38 -0
- package/dist/drivers/native/codex-normalize.js +124 -0
- package/dist/drivers/native/oneshot.d.ts +28 -0
- package/dist/drivers/native/oneshot.js +312 -0
- package/dist/drivers/permissions.d.ts +40 -0
- package/dist/drivers/permissions.js +92 -0
- package/dist/drivers/pids.d.ts +32 -0
- package/dist/drivers/pids.js +93 -0
- package/dist/drivers/pool.d.ts +28 -0
- package/dist/drivers/pool.js +96 -0
- package/dist/drivers/probe.d.ts +47 -0
- package/dist/drivers/probe.js +172 -0
- package/dist/drivers/process.d.ts +48 -0
- package/dist/drivers/process.js +100 -0
- package/dist/drivers/runner.d.ts +61 -0
- package/dist/drivers/runner.js +388 -0
- package/dist/drivers/store.d.ts +49 -0
- package/dist/drivers/store.js +91 -0
- package/dist/drivers/turn.d.ts +41 -0
- package/dist/drivers/turn.js +99 -0
- package/dist/drivers/types.d.ts +122 -0
- package/dist/drivers/types.js +11 -0
- package/dist/git/info.d.ts +75 -0
- package/dist/git/info.js +191 -0
- package/dist/hooks/protocol.js +6 -1
- package/dist/hooks/types.d.ts +10 -1
- package/dist/hooks/types.js +2 -0
- package/dist/host/api-impl.d.ts +7 -0
- package/dist/host/api-impl.js +15 -0
- package/dist/host/types.d.ts +24 -2
- package/dist/host/types.js +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/modes/acp/acp-events.d.ts +46 -0
- package/dist/modes/acp/acp-events.js +233 -0
- package/dist/modes/acp/acp-mode.d.ts +17 -0
- package/dist/modes/acp/acp-mode.js +47 -0
- package/dist/modes/acp/acp-server.d.ts +79 -0
- package/dist/modes/acp/acp-server.js +315 -0
- package/dist/modes/commands-core.d.ts +7 -1
- package/dist/modes/commands-core.js +61 -5
- package/dist/modes/image-input.d.ts +12 -4
- package/dist/modes/image-input.js +22 -5
- package/dist/modes/interactive/agent-panels.d.ts +14 -0
- package/dist/modes/interactive/agent-panels.js +103 -0
- package/dist/modes/interactive/agent-ui.d.ts +73 -0
- package/dist/modes/interactive/agent-ui.js +234 -0
- package/dist/modes/interactive/approval-dialog.d.ts +40 -7
- package/dist/modes/interactive/approval-dialog.js +192 -35
- package/dist/modes/interactive/approval-merge.d.ts +41 -0
- package/dist/modes/interactive/approval-merge.js +89 -0
- package/dist/modes/interactive/clipboard-paste.d.ts +18 -0
- package/dist/modes/interactive/clipboard-paste.js +28 -0
- package/dist/modes/interactive/commands.d.ts +20 -3
- package/dist/modes/interactive/commands.js +75 -16
- package/dist/modes/interactive/double-esc.d.ts +20 -0
- package/dist/modes/interactive/double-esc.js +34 -0
- package/dist/modes/interactive/event-notices.d.ts +32 -0
- package/dist/modes/interactive/event-notices.js +79 -0
- package/dist/modes/interactive/external-editor.d.ts +16 -0
- package/dist/modes/interactive/external-editor.js +39 -0
- package/dist/modes/interactive/interactive-mode.d.ts +16 -2
- package/dist/modes/interactive/interactive-mode.js +184 -202
- package/dist/modes/interactive/key-dispatch.d.ts +18 -2
- package/dist/modes/interactive/key-dispatch.js +53 -6
- package/dist/modes/interactive/line/line-mode.d.ts +3 -1
- package/dist/modes/interactive/line/line-mode.js +28 -9
- package/dist/modes/interactive/line/line-render.d.ts +6 -1
- package/dist/modes/interactive/line/line-render.js +66 -8
- package/dist/modes/interactive/message-view.d.ts +49 -10
- package/dist/modes/interactive/message-view.js +262 -46
- package/dist/modes/interactive/panels.d.ts +35 -0
- package/dist/modes/interactive/panels.js +157 -0
- package/dist/modes/interactive/pickers.d.ts +23 -2
- package/dist/modes/interactive/pickers.js +48 -15
- package/dist/modes/interactive/plan-command.d.ts +40 -0
- package/dist/modes/interactive/plan-command.js +129 -0
- package/dist/modes/interactive/plan-dialog.d.ts +98 -0
- package/dist/modes/interactive/plan-dialog.js +290 -0
- package/dist/modes/interactive/plan-flow.d.ts +34 -0
- package/dist/modes/interactive/plan-flow.js +98 -0
- package/dist/modes/interactive/rewind-command.d.ts +31 -0
- package/dist/modes/interactive/rewind-command.js +106 -0
- package/dist/modes/interactive/rewind-flow.d.ts +37 -0
- package/dist/modes/interactive/rewind-flow.js +151 -0
- package/dist/modes/interactive/rewind-list.d.ts +36 -0
- package/dist/modes/interactive/rewind-list.js +123 -0
- package/dist/modes/interactive/rewind-panel.d.ts +77 -0
- package/dist/modes/interactive/rewind-panel.js +309 -0
- package/dist/modes/interactive/rewind-text.d.ts +40 -0
- package/dist/modes/interactive/rewind-text.js +139 -0
- package/dist/modes/interactive/run-indicator.d.ts +51 -0
- package/dist/modes/interactive/run-indicator.js +189 -0
- package/dist/modes/interactive/session-events.d.ts +24 -0
- package/dist/modes/interactive/session-events.js +96 -0
- package/dist/modes/interactive/startup-header.d.ts +40 -0
- package/dist/modes/interactive/startup-header.js +169 -0
- package/dist/modes/interactive/status-area.d.ts +73 -0
- package/dist/modes/interactive/status-area.js +190 -0
- package/dist/modes/interactive/status-bar.d.ts +107 -16
- package/dist/modes/interactive/status-bar.js +306 -81
- package/dist/modes/interactive/status-line.d.ts +33 -0
- package/dist/modes/interactive/status-line.js +113 -0
- package/dist/modes/interactive/subagent-view.d.ts +56 -0
- package/dist/modes/interactive/subagent-view.js +154 -0
- package/dist/modes/interactive/tasks-report.d.ts +27 -0
- package/dist/modes/interactive/tasks-report.js +114 -0
- package/dist/modes/interactive/tool-summary.d.ts +46 -0
- package/dist/modes/interactive/tool-summary.js +218 -0
- package/dist/modes/interactive/tool-view.d.ts +58 -15
- package/dist/modes/interactive/tool-view.js +233 -145
- package/dist/modes/print/print-mode.d.ts +40 -4
- package/dist/modes/print/print-mode.js +161 -8
- package/dist/modes/rpc/commands.d.ts +9 -0
- package/dist/modes/rpc/commands.js +49 -0
- package/dist/modes/rpc/rpc-mode.js +7 -1
- package/dist/modes/session-report.d.ts +11 -0
- package/dist/modes/session-report.js +48 -1
- package/dist/permissions/auto-safe.d.ts +65 -0
- package/dist/permissions/auto-safe.js +547 -0
- package/dist/permissions/classifier.d.ts +68 -0
- package/dist/permissions/classifier.js +186 -0
- package/dist/permissions/dangerous.d.ts +5 -0
- package/dist/permissions/dangerous.js +1 -1
- package/dist/permissions/modes.d.ts +30 -0
- package/dist/permissions/modes.js +78 -0
- package/dist/permissions/pipeline.d.ts +72 -6
- package/dist/permissions/pipeline.js +306 -11
- package/dist/permissions/protected.d.ts +19 -0
- package/dist/permissions/protected.js +74 -0
- package/dist/permissions/readonly-bash.d.ts +30 -0
- package/dist/permissions/readonly-bash.js +118 -0
- package/dist/permissions/rules.js +3 -0
- package/dist/permissions/types.d.ts +92 -3
- package/dist/permissions/types.js +3 -0
- package/dist/plan/compose.d.ts +9 -0
- package/dist/plan/compose.js +19 -0
- package/dist/plan/controller.d.ts +71 -0
- package/dist/plan/controller.js +27 -0
- package/dist/plan/done-markers.d.ts +17 -0
- package/dist/plan/done-markers.js +51 -0
- package/dist/plan/extract.d.ts +29 -0
- package/dist/plan/extract.js +160 -0
- package/dist/plan/prompts.d.ts +36 -0
- package/dist/plan/prompts.js +89 -0
- package/dist/plan/store.d.ts +37 -0
- package/dist/plan/store.js +90 -0
- package/dist/rpc.d.ts +58 -2
- package/dist/rpc.js +7 -0
- package/dist/sandbox/bash.d.ts +74 -0
- package/dist/sandbox/bash.js +126 -0
- package/dist/sandbox/detect.d.ts +48 -0
- package/dist/sandbox/detect.js +149 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/profile.d.ts +33 -0
- package/dist/sandbox/profile.js +76 -0
- package/dist/sandbox/wrap.d.ts +29 -0
- package/dist/sandbox/wrap.js +117 -0
- package/dist/sdk.d.ts +42 -5
- package/dist/sdk.js +34 -4
- package/dist/session/export.d.ts +32 -0
- package/dist/session/export.js +187 -0
- package/dist/session/redact.d.ts +15 -0
- package/dist/session/redact.js +55 -0
- package/dist/session/reuse.d.ts +33 -0
- package/dist/session/reuse.js +86 -0
- package/dist/session/scan.d.ts +34 -0
- package/dist/session/scan.js +140 -0
- package/dist/session/search.d.ts +52 -0
- package/dist/session/search.js +211 -0
- package/dist/session/stats-aggregate.d.ts +63 -0
- package/dist/session/stats-aggregate.js +163 -0
- package/dist/session/stats-index.d.ts +26 -0
- package/dist/session/stats-index.js +91 -0
- package/dist/session/stats-scan.d.ts +54 -0
- package/dist/session/stats-scan.js +236 -0
- package/dist/session/types.d.ts +3 -1
- package/dist/session/types.js +1 -0
- package/dist/skills/builtin.d.ts +31 -0
- package/dist/skills/builtin.js +109 -0
- package/dist/skills/discover.d.ts +2 -1
- package/dist/skills/index-prompt.js +5 -8
- package/dist/tools/background-jobs.d.ts +71 -0
- package/dist/tools/background-jobs.js +198 -0
- package/dist/tools/bash.d.ts +53 -1
- package/dist/tools/bash.js +158 -7
- package/dist/tools/clipboard-image.d.ts +44 -0
- package/dist/tools/clipboard-image.js +148 -0
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.js +18 -3
- package/dist/tools/image-file.d.ts +38 -3
- package/dist/tools/image-file.js +81 -10
- package/dist/tools/image-resize.d.ts +58 -0
- package/dist/tools/image-resize.js +97 -0
- package/dist/tools/presets.d.ts +40 -8
- package/dist/tools/presets.js +65 -19
- package/dist/tools/read.d.ts +5 -2
- package/dist/tools/read.js +13 -10
- package/dist/tools/registry.d.ts +7 -1
- package/dist/tools/registry.js +27 -4
- package/dist/tools/task-ctl.d.ts +22 -0
- package/dist/tools/task-ctl.js +116 -0
- package/dist/tools/task.d.ts +22 -10
- package/dist/tools/task.js +66 -26
- package/dist/tools/todo.d.ts +22 -2
- package/dist/tools/todo.js +58 -14
- package/dist/tools/truncate.d.ts +15 -0
- package/dist/tools/truncate.js +25 -0
- package/dist/tools/types.d.ts +113 -0
- package/dist/tools/types.js +5 -0
- package/dist/tools/write.js +3 -0
- package/dist/tui/component.d.ts +8 -2
- package/dist/tui/component.js +3 -1
- package/dist/tui/components/box.d.ts +6 -1
- package/dist/tui/components/box.js +16 -6
- package/dist/tui/components/card.d.ts +23 -0
- package/dist/tui/components/card.js +37 -0
- package/dist/tui/components/editor-history.d.ts +6 -0
- package/dist/tui/components/editor-history.js +45 -0
- package/dist/tui/components/editor-paste.d.ts +1 -1
- package/dist/tui/components/editor-paste.js +4 -4
- package/dist/tui/components/editor.d.ts +11 -5
- package/dist/tui/components/editor.js +52 -58
- package/dist/tui/components/key-value.d.ts +3 -0
- package/dist/tui/components/key-value.js +16 -6
- package/dist/tui/components/loader.d.ts +37 -7
- package/dist/tui/components/loader.js +84 -21
- package/dist/tui/components/markdown.d.ts +5 -1
- package/dist/tui/components/markdown.js +45 -21
- package/dist/tui/components/meter.d.ts +3 -3
- package/dist/tui/components/meter.js +13 -11
- package/dist/tui/components/select-list.d.ts +23 -1
- package/dist/tui/components/select-list.js +76 -13
- package/dist/tui/glyphs.d.ts +72 -0
- package/dist/tui/glyphs.js +118 -0
- package/dist/tui/keybindings.d.ts +5 -0
- package/dist/tui/keybindings.js +5 -0
- package/dist/tui/theme.d.ts +30 -6
- package/dist/tui/theme.js +103 -17
- package/dist/tui.d.ts +4 -2
- package/dist/tui.js +3 -1
- package/docs/acp.md +78 -0
- package/docs/agents.md +250 -0
- package/docs/codemode.md +28 -10
- package/docs/hooks.md +36 -32
- package/docs/permissions.md +212 -0
- package/docs/plan.md +107 -0
- package/docs/providers.md +261 -62
- package/docs/rewind-plan.md +181 -0
- package/docs/rpc.md +127 -40
- package/docs/sandbox.md +215 -0
- package/docs/session-format.md +43 -22
- package/docs/sessions.md +174 -0
- package/docs/tui-design.md +751 -0
- package/docs/tui.md +260 -64
- package/package.json +15 -2
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 运行指示(设计 §12.1、§12.6;终端界面视觉设计 v1 §3.7)。[B4]
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 一行 `⠋ 动词 · 已用时 · 附加项…`:spinner `accent`、动词正文色、其余 `dim`,以 ` · ` 连接。
|
|
5
|
+
* - `setVerb(verb, extras, { elapsed })` 换动词(思考中 / 回复中 / 运行 bash / 等待确认……);
|
|
6
|
+
* `setMessage(text)` 是只换动词的旧接口。
|
|
7
|
+
* - 帧取 `theme.glyphs.spinner`(Unicode 10 帧 80 ms、ASCII 4 帧 250 ms);`frame` 暴露当前帧字形,
|
|
8
|
+
* `onFrame` 让别的组件(运行中的工具摘要行)与 Loader 同帧换字,保证一帧只多改一行。
|
|
9
|
+
* - `animation: false`:spinner 固定为 `glyphs.spinnerStatic`,定时器每秒一次,已用时变了才请求重绘。
|
|
10
|
+
* - `stop()` 后不再触发渲染。时钟可注入便于测试。
|
|
5
11
|
*/
|
|
6
12
|
import { truncateToWidth } from "../ansi.js";
|
|
7
|
-
|
|
13
|
+
import { UNICODE_GLYPHS } from "../glyphs.js";
|
|
14
|
+
/** Unicode 帧表(兼容旧导出;实际帧取 `theme.glyphs.spinner`)。 */
|
|
15
|
+
export const LOADER_FRAMES = UNICODE_GLYPHS.spinner;
|
|
8
16
|
export function formatElapsed(ms) {
|
|
9
17
|
const total = Math.max(0, Math.floor(ms / 1000));
|
|
10
18
|
if (total < 60)
|
|
@@ -16,31 +24,74 @@ export function formatElapsed(ms) {
|
|
|
16
24
|
export class Loader {
|
|
17
25
|
requestRender;
|
|
18
26
|
options;
|
|
19
|
-
|
|
27
|
+
frameIndex = 0;
|
|
20
28
|
timer = null;
|
|
21
29
|
startedAt;
|
|
22
|
-
|
|
30
|
+
verb;
|
|
31
|
+
extras = [];
|
|
32
|
+
verbElapsed;
|
|
33
|
+
lastElapsed = "";
|
|
34
|
+
listeners = new Set();
|
|
23
35
|
now;
|
|
24
36
|
constructor(requestRender, options = {}) {
|
|
25
37
|
this.requestRender = requestRender;
|
|
26
38
|
this.options = options;
|
|
27
39
|
this.now = options.now ?? Date.now;
|
|
28
|
-
this.
|
|
40
|
+
this.verb = options.message ?? "";
|
|
29
41
|
this.startedAt = this.now();
|
|
30
42
|
}
|
|
31
43
|
get running() {
|
|
32
44
|
return this.timer !== null;
|
|
33
45
|
}
|
|
34
|
-
|
|
35
|
-
this.
|
|
46
|
+
get frames() {
|
|
47
|
+
return (this.options.theme?.glyphs ?? UNICODE_GLYPHS).spinner;
|
|
48
|
+
}
|
|
49
|
+
get animated() {
|
|
50
|
+
return this.options.animation !== false;
|
|
51
|
+
}
|
|
52
|
+
/** 当前帧字形(静止时为 `spinnerStatic`)。 */
|
|
53
|
+
get frame() {
|
|
54
|
+
const glyphs = this.options.theme?.glyphs ?? UNICODE_GLYPHS;
|
|
55
|
+
return this.animated
|
|
56
|
+
? this.frames[this.frameIndex % this.frames.length]
|
|
57
|
+
: glyphs.spinnerStatic;
|
|
58
|
+
}
|
|
59
|
+
/** 订阅换帧(返回取消函数)。 */
|
|
60
|
+
onFrame(listener) {
|
|
61
|
+
this.listeners.add(listener);
|
|
62
|
+
return () => this.listeners.delete(listener);
|
|
63
|
+
}
|
|
64
|
+
/** 换动词与附加项(附加项 dim,排在已用时之后)。 */
|
|
65
|
+
setVerb(verb, extras = [], options = {}) {
|
|
66
|
+
const same = verb === this.verb &&
|
|
67
|
+
options.elapsed === this.verbElapsed &&
|
|
68
|
+
extras.length === this.extras.length &&
|
|
69
|
+
extras.every((e, i) => e === this.extras[i]);
|
|
70
|
+
if (same)
|
|
71
|
+
return;
|
|
72
|
+
this.verb = verb;
|
|
73
|
+
this.extras = [...extras];
|
|
74
|
+
this.verbElapsed = options.elapsed;
|
|
36
75
|
this.requestRender();
|
|
37
76
|
}
|
|
77
|
+
/** 旧接口:只换动词。 */
|
|
78
|
+
setMessage(message) {
|
|
79
|
+
this.setVerb(message);
|
|
80
|
+
}
|
|
81
|
+
/** 已用时从现在重新算(换到另一段工作时)。 */
|
|
82
|
+
resetElapsed() {
|
|
83
|
+
this.startedAt = this.now();
|
|
84
|
+
}
|
|
38
85
|
start() {
|
|
39
86
|
if (this.timer !== null)
|
|
40
87
|
return;
|
|
41
88
|
this.startedAt = this.now();
|
|
42
|
-
this.
|
|
43
|
-
|
|
89
|
+
this.frameIndex = 0;
|
|
90
|
+
const glyphs = this.options.theme?.glyphs ?? UNICODE_GLYPHS;
|
|
91
|
+
const interval = this.animated
|
|
92
|
+
? (this.options.intervalMs ?? (glyphs.ascii ? 250 : 80))
|
|
93
|
+
: Math.max(this.options.intervalMs ?? 1000, 1000);
|
|
94
|
+
this.timer = setInterval(() => this.tick(), interval);
|
|
44
95
|
this.timer.unref?.();
|
|
45
96
|
this.requestRender();
|
|
46
97
|
}
|
|
@@ -50,22 +101,34 @@ export class Loader {
|
|
|
50
101
|
clearInterval(this.timer);
|
|
51
102
|
this.timer = null;
|
|
52
103
|
}
|
|
53
|
-
/**
|
|
104
|
+
/** 推进一帧(定时器调用;测试可直接调用)。静止时只在已用时变化时重绘。 */
|
|
54
105
|
tick() {
|
|
55
|
-
|
|
106
|
+
if (this.animated)
|
|
107
|
+
this.frameIndex = (this.frameIndex + 1) % this.frames.length;
|
|
108
|
+
else if (this.elapsedText() === this.lastElapsed)
|
|
109
|
+
return;
|
|
110
|
+
const frame = this.frame;
|
|
111
|
+
for (const listener of this.listeners)
|
|
112
|
+
listener(frame);
|
|
56
113
|
this.requestRender();
|
|
57
114
|
}
|
|
115
|
+
elapsedText() {
|
|
116
|
+
return formatElapsed(this.now() - this.startedAt);
|
|
117
|
+
}
|
|
58
118
|
render(width) {
|
|
59
119
|
const theme = this.options.theme;
|
|
60
|
-
const
|
|
61
|
-
const parts = [
|
|
62
|
-
if (this.
|
|
63
|
-
parts.push(this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
120
|
+
const dim = (s) => (theme ? theme.fg("dim", s) : s);
|
|
121
|
+
const parts = [];
|
|
122
|
+
if (this.verb !== "")
|
|
123
|
+
parts.push(this.verb);
|
|
124
|
+
const elapsed = this.elapsedText();
|
|
125
|
+
this.lastElapsed = elapsed;
|
|
126
|
+
if (this.verbElapsed ?? this.options.showElapsed !== false)
|
|
127
|
+
parts.push(dim(elapsed));
|
|
128
|
+
for (const extra of this.extras)
|
|
129
|
+
parts.push(dim(extra));
|
|
130
|
+
const spinner = theme ? theme.fg("accent", this.frame) : this.frame;
|
|
131
|
+
return [truncateToWidth(`${spinner} ${parts.join(dim(" · "))}`, width)];
|
|
69
132
|
}
|
|
70
133
|
invalidate() { }
|
|
71
134
|
}
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* 支持:ATX 标题、段落(软换行合并为空格,行尾两个空格或 `\` 为硬换行)、无序 / 有序列表(缩进嵌套)、
|
|
5
5
|
* 围栏代码块(边框 + 语言标签;流式时未闭合的围栏按代码块渲染)、引用、分隔线、
|
|
6
6
|
* 行内 `code` / **粗体** / *斜体* / ~~删除线~~ / [链接](url) / <自动链接> / 反斜杠转义。
|
|
7
|
-
*
|
|
7
|
+
* 表格降级为等宽对齐文本(列间两个空格、首行粗体其下一条规则线、不换行、超宽截断);不做语法高亮(§12.9)。
|
|
8
|
+
*
|
|
9
|
+
* 配色(终端界面视觉设计 v1 §3.3):h1 / h2 `accent` 粗体,h3+ 粗体;行内代码 `code`;链接文字 `link`
|
|
10
|
+
* 加下划线、URL 以 ` (url)` `dim` 追加;列表符号 `muted`;代码块全宽、边框 `border`、语言标签 `dim`、
|
|
11
|
+
* 正文 `text`;引用 `▎` + `muted` 斜体。字形(圆点、框线、竖条)取 `theme.glyphs`。
|
|
8
12
|
*
|
|
9
13
|
* 缓存:按块缓存渲染结果(键 = 宽度 + 块源文本),流式追加时只有末块重新渲染;解析也是增量的
|
|
10
14
|
* (`Markdown.append` 只从尾部可能变化的块重新解析)。
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* 支持:ATX 标题、段落(软换行合并为空格,行尾两个空格或 `\` 为硬换行)、无序 / 有序列表(缩进嵌套)、
|
|
5
5
|
* 围栏代码块(边框 + 语言标签;流式时未闭合的围栏按代码块渲染)、引用、分隔线、
|
|
6
6
|
* 行内 `code` / **粗体** / *斜体* / ~~删除线~~ / [链接](url) / <自动链接> / 反斜杠转义。
|
|
7
|
-
*
|
|
7
|
+
* 表格降级为等宽对齐文本(列间两个空格、首行粗体其下一条规则线、不换行、超宽截断);不做语法高亮(§12.9)。
|
|
8
|
+
*
|
|
9
|
+
* 配色(终端界面视觉设计 v1 §3.3):h1 / h2 `accent` 粗体,h3+ 粗体;行内代码 `code`;链接文字 `link`
|
|
10
|
+
* 加下划线、URL 以 ` (url)` `dim` 追加;列表符号 `muted`;代码块全宽、边框 `border`、语言标签 `dim`、
|
|
11
|
+
* 正文 `text`;引用 `▎` + `muted` 斜体。字形(圆点、框线、竖条)取 `theme.glyphs`。
|
|
8
12
|
*
|
|
9
13
|
* 缓存:按块缓存渲染结果(键 = 宽度 + 块源文本),流式追加时只有末块重新渲染;解析也是增量的
|
|
10
14
|
* (`Markdown.append` 只从尾部可能变化的块重新解析)。
|
|
@@ -208,8 +212,8 @@ export function renderInline(text, theme) {
|
|
|
208
212
|
const url = link[2];
|
|
209
213
|
out +=
|
|
210
214
|
link[1] === url || url === ""
|
|
211
|
-
? theme.underline(label || url)
|
|
212
|
-
: theme.underline(label) + theme.fg("dim", ` (${url})`);
|
|
215
|
+
? theme.fg("link", theme.underline(label || url))
|
|
216
|
+
: theme.fg("link", theme.underline(label)) + theme.fg("dim", ` (${url})`);
|
|
213
217
|
i += link[0].length;
|
|
214
218
|
continue;
|
|
215
219
|
}
|
|
@@ -217,7 +221,7 @@ export function renderInline(text, theme) {
|
|
|
217
221
|
if (ch === "<") {
|
|
218
222
|
const auto = /^<((?:https?|mailto):[^>\s]+)>/.exec(text.slice(i));
|
|
219
223
|
if (auto) {
|
|
220
|
-
out += theme.underline(auto[1]);
|
|
224
|
+
out += theme.fg("link", theme.underline(auto[1]));
|
|
221
225
|
i += auto[0].length;
|
|
222
226
|
continue;
|
|
223
227
|
}
|
|
@@ -263,17 +267,19 @@ export function renderBlock(block, width, theme) {
|
|
|
263
267
|
switch (block.kind) {
|
|
264
268
|
case "heading": {
|
|
265
269
|
const text = renderInline(block.text, theme);
|
|
266
|
-
const styled = block.level <= 2
|
|
270
|
+
const styled = block.level <= 2
|
|
271
|
+
? theme.fg("accent", theme.bold(text))
|
|
272
|
+
: theme.fg("text", theme.bold(text));
|
|
267
273
|
return wrapTextWithAnsi(styled, width);
|
|
268
274
|
}
|
|
269
275
|
case "paragraph":
|
|
270
276
|
return wrapTextWithAnsi(renderInline(block.text, theme), width);
|
|
271
277
|
case "hr":
|
|
272
|
-
return [theme.fg("border",
|
|
278
|
+
return [theme.fg("border", theme.glyphs.rule.repeat(Math.max(1, width)))];
|
|
273
279
|
case "quote": {
|
|
274
|
-
const bar = theme.fg("border", "
|
|
275
|
-
const
|
|
276
|
-
return
|
|
280
|
+
const bar = theme.fg("border", theme.glyphs.card) + " ";
|
|
281
|
+
const body = theme.fg("muted", theme.italic(renderInline(block.text, theme)));
|
|
282
|
+
return wrapTextWithAnsi(body, Math.max(1, width - 2)).map((line) => bar + line);
|
|
277
283
|
}
|
|
278
284
|
case "list":
|
|
279
285
|
return renderList(block.items, width, theme);
|
|
@@ -283,15 +289,24 @@ export function renderBlock(block, width, theme) {
|
|
|
283
289
|
return renderTable(block.rows, width, theme);
|
|
284
290
|
}
|
|
285
291
|
}
|
|
286
|
-
const BULLETS = ["•", "◦", "▪"];
|
|
287
292
|
function renderList(items, width, theme) {
|
|
288
293
|
const lines = [];
|
|
294
|
+
const bullets = theme.glyphs.bullets;
|
|
295
|
+
/** 各层的正文起始列与无序层数(嵌套项对齐父项正文,圆点按无序层数换)。 */
|
|
296
|
+
const columns = [];
|
|
297
|
+
const unordered = [];
|
|
289
298
|
for (const item of items) {
|
|
290
|
-
const
|
|
299
|
+
const depth = Math.min(item.depth, columns.length);
|
|
300
|
+
const indent = depth === 0 ? 0 : columns[depth - 1];
|
|
291
301
|
const ordered = /\d/.test(item.marker);
|
|
292
|
-
const
|
|
293
|
-
const
|
|
302
|
+
const level = (depth === 0 ? 0 : unordered[depth - 1]) + (ordered ? 0 : 1);
|
|
303
|
+
const bullet = ordered ? item.marker : bullets[(level - 1) % bullets.length];
|
|
304
|
+
const head = " ".repeat(indent) + theme.fg("muted", bullet) + " ";
|
|
294
305
|
const headWidth = visibleWidth(head);
|
|
306
|
+
columns.length = depth;
|
|
307
|
+
unordered.length = depth;
|
|
308
|
+
columns.push(headWidth);
|
|
309
|
+
unordered.push(level);
|
|
295
310
|
const body = wrapTextWithAnsi(renderInline(item.text, theme), Math.max(1, width - headWidth));
|
|
296
311
|
body.forEach((line, index) => {
|
|
297
312
|
lines.push((index === 0 ? head : " ".repeat(headWidth)) + line);
|
|
@@ -304,18 +319,21 @@ function renderCode(lang, body, width, theme) {
|
|
|
304
319
|
if (width < 8)
|
|
305
320
|
return code.map((line) => truncateToWidth(line, width));
|
|
306
321
|
const inner = width - 4;
|
|
322
|
+
const g = theme.glyphs.box;
|
|
307
323
|
const border = (s) => theme.fg("border", s);
|
|
308
324
|
const label = lang === "" ? "" : truncateToWidth(` ${lang} `, inner - 1);
|
|
309
|
-
const top = border(
|
|
325
|
+
const top = border(g.topLeft + g.horizontal) +
|
|
310
326
|
theme.fg("dim", label) +
|
|
311
|
-
border(
|
|
327
|
+
border(g.horizontal.repeat(width - 3 - visibleWidth(label)) + g.topRight);
|
|
312
328
|
const lines = [top];
|
|
313
329
|
for (const line of code) {
|
|
314
330
|
for (const piece of wrapCode(line, inner)) {
|
|
315
|
-
lines.push(border(
|
|
331
|
+
lines.push(border(g.vertical + " ") +
|
|
332
|
+
padToWidth(theme.fg("text", piece), inner) +
|
|
333
|
+
border(" " + g.vertical));
|
|
316
334
|
}
|
|
317
335
|
}
|
|
318
|
-
lines.push(border(
|
|
336
|
+
lines.push(border(g.bottomLeft + g.horizontal.repeat(width - 2) + g.bottomRight));
|
|
319
337
|
return lines;
|
|
320
338
|
}
|
|
321
339
|
/** 代码按列硬断行(不按词),空行保留。 */
|
|
@@ -345,12 +363,18 @@ function renderTable(rows, width, theme) {
|
|
|
345
363
|
for (const row of rendered) {
|
|
346
364
|
row.forEach((cell, c) => (widths[c] = Math.max(widths[c], visibleWidth(cell))));
|
|
347
365
|
}
|
|
348
|
-
const
|
|
349
|
-
|
|
366
|
+
const lines = [];
|
|
367
|
+
rendered.forEach((row, r) => {
|
|
350
368
|
const cells = widths.map((w, c) => padToWidth(row[c] ?? "", w));
|
|
351
|
-
const line = cells.join(
|
|
352
|
-
|
|
369
|
+
const line = cells.join(" ").replace(/\s+$/, "");
|
|
370
|
+
const header = r === 0 && rows.length > 1;
|
|
371
|
+
lines.push(truncateToWidth(header ? theme.bold(line) : line, width));
|
|
372
|
+
if (header) {
|
|
373
|
+
const total = widths.reduce((sum, w) => sum + w, 0) + 2 * Math.max(0, cols - 1);
|
|
374
|
+
lines.push(theme.fg("border", theme.glyphs.rule.repeat(Math.max(1, Math.min(total, width)))));
|
|
375
|
+
}
|
|
353
376
|
});
|
|
377
|
+
return lines;
|
|
354
378
|
}
|
|
355
379
|
export class Markdown {
|
|
356
380
|
text;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* - `value` 是 0–1 的比例(越界夹紧);undefined 显示 `—`,格子全空;
|
|
5
5
|
* - 阈值着色(需要 theme):≥ `dangerAt`(缺省 0.9)error,≥ `warnAt`(缺省 0.7)warning,否则 success;
|
|
6
6
|
* 空格子 dim;
|
|
7
|
-
* - 宽度不够时先去掉格子,只剩「标签
|
|
7
|
+
* - 宽度不够时先去掉格子,只剩「标签 百分比」,再不够就截断;格子字形取 `theme.glyphs`(ASCII `# .`)。
|
|
8
8
|
*/
|
|
9
9
|
import type { Component, SemanticColor, Theme } from "../component.js";
|
|
10
10
|
export interface MeterOptions {
|
|
@@ -15,8 +15,8 @@ export interface MeterOptions {
|
|
|
15
15
|
dangerAt?: number;
|
|
16
16
|
theme?: Theme;
|
|
17
17
|
}
|
|
18
|
-
export declare const METER_FULL
|
|
19
|
-
export declare const METER_EMPTY
|
|
18
|
+
export declare const METER_FULL: string;
|
|
19
|
+
export declare const METER_EMPTY: string;
|
|
20
20
|
export declare class Meter implements Component {
|
|
21
21
|
private value;
|
|
22
22
|
private readonly options;
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
* - `value` 是 0–1 的比例(越界夹紧);undefined 显示 `—`,格子全空;
|
|
5
5
|
* - 阈值着色(需要 theme):≥ `dangerAt`(缺省 0.9)error,≥ `warnAt`(缺省 0.7)warning,否则 success;
|
|
6
6
|
* 空格子 dim;
|
|
7
|
-
* - 宽度不够时先去掉格子,只剩「标签
|
|
7
|
+
* - 宽度不够时先去掉格子,只剩「标签 百分比」,再不够就截断;格子字形取 `theme.glyphs`(ASCII `# .`)。
|
|
8
8
|
*/
|
|
9
9
|
import { truncateToWidth, visibleWidth } from "../ansi.js";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { levelColor } from "../theme.js";
|
|
11
|
+
import { UNICODE_GLYPHS } from "../glyphs.js";
|
|
12
|
+
export const METER_FULL = UNICODE_GLYPHS.meterFull;
|
|
13
|
+
export const METER_EMPTY = UNICODE_GLYPHS.meterEmpty;
|
|
12
14
|
export class Meter {
|
|
13
15
|
value;
|
|
14
16
|
options;
|
|
@@ -21,12 +23,11 @@ export class Meter {
|
|
|
21
23
|
}
|
|
22
24
|
/** 当前阈值档位对应的语义色。 */
|
|
23
25
|
level() {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return "success";
|
|
26
|
+
const { warnAt, dangerAt } = this.options;
|
|
27
|
+
return levelColor(this.value ?? 0, {
|
|
28
|
+
...(warnAt !== undefined ? { warnAt } : {}),
|
|
29
|
+
...(dangerAt !== undefined ? { dangerAt } : {}),
|
|
30
|
+
});
|
|
30
31
|
}
|
|
31
32
|
render(width) {
|
|
32
33
|
const { theme, label, cells = 10 } = this.options;
|
|
@@ -35,8 +36,9 @@ export class Meter {
|
|
|
35
36
|
const color = (c, text) => (theme ? theme.fg(c, text) : text);
|
|
36
37
|
const head = label === undefined || label === "" ? "" : `${label} `;
|
|
37
38
|
const filled = ratio === undefined ? 0 : Math.round(ratio * cells);
|
|
38
|
-
const
|
|
39
|
-
|
|
39
|
+
const glyphs = theme?.glyphs ?? UNICODE_GLYPHS;
|
|
40
|
+
const bar = color(this.level(), glyphs.meterFull.repeat(filled)) +
|
|
41
|
+
color("dim", glyphs.meterEmpty.repeat(cells - filled));
|
|
40
42
|
const tail = color(ratio === undefined ? "dim" : this.level(), percent);
|
|
41
43
|
const full = `${head}${bar} ${tail}`;
|
|
42
44
|
if (visibleWidth(full) <= width)
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* 键位走 `tui.select.*`:上下移动(循环)、翻页、确认(Enter / Tab)、取消(Esc / Ctrl+C)。
|
|
5
5
|
* `filterable` 时可打印字符追加到过滤词、退格删除;过滤为大小写不敏感的分词子串匹配
|
|
6
6
|
* (每个词都要出现在 label / value / group / description 之一中)。
|
|
7
|
+
*
|
|
8
|
+
* `badge` 靠右显示(如 `Default`、`Recommended`);`numberKeys` 时右侧标 1–9,按数字直接选中并确认;
|
|
9
|
+
* `stacked` 时说明换到标签下一行(缩进、暗色),适合「名字 + 一行说明」的短列表。
|
|
10
|
+
*
|
|
11
|
+
* 终端界面视觉设计 v1:选中行 `›` + `selection` 底色(< 256 色退化为 accent 粗体,stacked 时两行都上);
|
|
12
|
+
* `currentValue` 的项标 `✓`;`footer` 是列表下的一行按键提示(dim),`showCount` 时前面带 `(i/n)`
|
|
13
|
+
* (缺省只在超出一屏时带);过滤框提示符 `›`。字形取 `theme.glyphs`。
|
|
7
14
|
*/
|
|
8
|
-
import type { Component, Focusable, Theme } from "../component.js";
|
|
15
|
+
import type { Component, Focusable, SemanticColor, Theme } from "../component.js";
|
|
9
16
|
import { type Keybindings } from "../keybindings.js";
|
|
10
17
|
export interface SelectItem {
|
|
11
18
|
value: string;
|
|
@@ -13,6 +20,10 @@ export interface SelectItem {
|
|
|
13
20
|
description?: string;
|
|
14
21
|
/** 相邻项 group 不同时插入分组标题行。 */
|
|
15
22
|
group?: string;
|
|
23
|
+
/** 靠右的徽标文字。 */
|
|
24
|
+
badge?: string;
|
|
25
|
+
/** 徽标颜色,缺省 accent。 */
|
|
26
|
+
badgeColor?: SemanticColor;
|
|
16
27
|
}
|
|
17
28
|
export interface SelectListOptions {
|
|
18
29
|
/** 一屏最多显示的条目数,缺省 10。 */
|
|
@@ -21,6 +32,16 @@ export interface SelectListOptions {
|
|
|
21
32
|
keybindings?: Keybindings;
|
|
22
33
|
filterable?: boolean;
|
|
23
34
|
emptyText?: string;
|
|
35
|
+
/** 右侧标序号,按 1–9 直接选中并确认(不与 filterable 同用)。 */
|
|
36
|
+
numberKeys?: boolean;
|
|
37
|
+
/** 说明放在标签下一行。 */
|
|
38
|
+
stacked?: boolean;
|
|
39
|
+
/** 列表下的按键提示行(dim)。 */
|
|
40
|
+
footer?: string;
|
|
41
|
+
/** 提示行前带 `(i/n)`;缺省只在超出一屏时带。 */
|
|
42
|
+
showCount?: boolean;
|
|
43
|
+
/** 当前值:该项标签前标 `✓`(其余项留同宽空白)。 */
|
|
44
|
+
currentValue?: string;
|
|
24
45
|
onSelect?(item: SelectItem): void;
|
|
25
46
|
onCancel?(): void;
|
|
26
47
|
onSelectionChange?(item: SelectItem | undefined): void;
|
|
@@ -48,6 +69,7 @@ export declare class SelectList implements Component, Focusable {
|
|
|
48
69
|
selectValue(value: string): boolean;
|
|
49
70
|
moveSelection(delta: number, wrap?: boolean): void;
|
|
50
71
|
handleInput(data: string): void;
|
|
72
|
+
private get glyphs();
|
|
51
73
|
render(width: number): string[];
|
|
52
74
|
invalidate(): void;
|
|
53
75
|
private renderItem;
|
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
* 键位走 `tui.select.*`:上下移动(循环)、翻页、确认(Enter / Tab)、取消(Esc / Ctrl+C)。
|
|
5
5
|
* `filterable` 时可打印字符追加到过滤词、退格删除;过滤为大小写不敏感的分词子串匹配
|
|
6
6
|
* (每个词都要出现在 label / value / group / description 之一中)。
|
|
7
|
+
*
|
|
8
|
+
* `badge` 靠右显示(如 `Default`、`Recommended`);`numberKeys` 时右侧标 1–9,按数字直接选中并确认;
|
|
9
|
+
* `stacked` 时说明换到标签下一行(缩进、暗色),适合「名字 + 一行说明」的短列表。
|
|
10
|
+
*
|
|
11
|
+
* 终端界面视觉设计 v1:选中行 `›` + `selection` 底色(< 256 色退化为 accent 粗体,stacked 时两行都上);
|
|
12
|
+
* `currentValue` 的项标 `✓`;`footer` 是列表下的一行按键提示(dim),`showCount` 时前面带 `(i/n)`
|
|
13
|
+
* (缺省只在超出一屏时带);过滤框提示符 `›`。字形取 `theme.glyphs`。
|
|
7
14
|
*/
|
|
8
15
|
import { padToWidth, truncateToWidth, visibleWidth } from "../ansi.js";
|
|
16
|
+
import { UNICODE_GLYPHS } from "../glyphs.js";
|
|
9
17
|
import { defaultKeybindings } from "../keybindings.js";
|
|
10
18
|
import { isPrintableText, matchesKey } from "../keys.js";
|
|
11
19
|
export function filterItems(items, filter) {
|
|
@@ -83,6 +91,14 @@ export class SelectList {
|
|
|
83
91
|
}
|
|
84
92
|
handleInput(data) {
|
|
85
93
|
const k = this.keys;
|
|
94
|
+
if (this.options.numberKeys === true && /^[1-9]$/.test(data)) {
|
|
95
|
+
const index = Number(data) - 1;
|
|
96
|
+
if (index < this.filtered.length) {
|
|
97
|
+
this.setSelectedIndex(index);
|
|
98
|
+
this.options.onSelect?.(this.filtered[index]);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
86
102
|
if (k.matches(data, "tui.select.up"))
|
|
87
103
|
this.moveSelection(-1);
|
|
88
104
|
else if (k.matches(data, "tui.select.down"))
|
|
@@ -108,16 +124,23 @@ export class SelectList {
|
|
|
108
124
|
}
|
|
109
125
|
}
|
|
110
126
|
}
|
|
127
|
+
get glyphs() {
|
|
128
|
+
return this.options.theme?.glyphs ?? UNICODE_GLYPHS;
|
|
129
|
+
}
|
|
111
130
|
render(width) {
|
|
112
131
|
const theme = this.options.theme;
|
|
113
132
|
const dim = (s) => (theme ? theme.fg("dim", s) : s);
|
|
114
133
|
const lines = [];
|
|
115
134
|
if (this.options.filterable) {
|
|
116
|
-
const
|
|
135
|
+
const mark = `${this.glyphs.prompt} `;
|
|
136
|
+
const prompt = theme ? theme.fg("accent", mark) : mark;
|
|
117
137
|
lines.push(truncateToWidth(prompt + this.filter + (this.focused ? "▏" : ""), width));
|
|
118
138
|
}
|
|
119
139
|
if (this.filtered.length === 0) {
|
|
120
140
|
lines.push(truncateToWidth(dim(` ${this.options.emptyText ?? "(no matches)"}`), width));
|
|
141
|
+
if (this.options.footer !== undefined) {
|
|
142
|
+
lines.push(truncateToWidth(dim(this.options.footer), width));
|
|
143
|
+
}
|
|
121
144
|
return lines;
|
|
122
145
|
}
|
|
123
146
|
const end = Math.min(this.filtered.length, this.scrollTop + this.maxVisible);
|
|
@@ -129,27 +152,67 @@ export class SelectList {
|
|
|
129
152
|
lines.push(truncateToWidth(dim(item.group), width));
|
|
130
153
|
}
|
|
131
154
|
lastGroup = item.group;
|
|
132
|
-
lines.push(this.renderItem(item, i
|
|
155
|
+
lines.push(...this.renderItem(item, i, labelWidth, width));
|
|
133
156
|
}
|
|
134
|
-
|
|
135
|
-
|
|
157
|
+
const overflow = this.filtered.length > this.maxVisible;
|
|
158
|
+
const count = `(${this.selected + 1}/${this.filtered.length})`;
|
|
159
|
+
const footer = this.options.footer;
|
|
160
|
+
if (footer !== undefined) {
|
|
161
|
+
const withCount = this.options.showCount ?? overflow;
|
|
162
|
+
lines.push(truncateToWidth(dim(`${withCount ? `${count} ` : ""}${footer}`), width));
|
|
163
|
+
}
|
|
164
|
+
else if (overflow) {
|
|
165
|
+
lines.push(truncateToWidth(dim(` ${count}`), width));
|
|
136
166
|
}
|
|
137
167
|
return lines;
|
|
138
168
|
}
|
|
139
169
|
invalidate() { }
|
|
140
|
-
renderItem(item,
|
|
170
|
+
renderItem(item, index, labelWidth, width) {
|
|
141
171
|
const theme = this.options.theme;
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
172
|
+
const selected = index === this.selected;
|
|
173
|
+
const dim = (s) => (theme ? theme.fg("dim", s) : s);
|
|
174
|
+
const rightParts = [];
|
|
175
|
+
if (item.badge !== undefined && item.badge !== "") {
|
|
176
|
+
rightParts.push(theme ? theme.fg(item.badgeColor ?? "accent", item.badge) : item.badge);
|
|
177
|
+
}
|
|
178
|
+
if (this.options.numberKeys === true && index < 9)
|
|
179
|
+
rightParts.push(dim(String(index + 1)));
|
|
180
|
+
let right = rightParts.join(" ");
|
|
181
|
+
if (visibleWidth(right) > Math.max(0, width - 8))
|
|
182
|
+
right = "";
|
|
183
|
+
const rightWidth = right === "" ? 0 : visibleWidth(right) + 1;
|
|
184
|
+
const g = this.glyphs;
|
|
185
|
+
const current = this.options.currentValue;
|
|
186
|
+
const check = current === undefined
|
|
187
|
+
? ""
|
|
188
|
+
: item.value === current
|
|
189
|
+
? (theme ? theme.fg(selected ? "accent" : "success", g.check) : g.check) + " "
|
|
190
|
+
: " ";
|
|
191
|
+
const prefix = (selected ? `${g.prompt} ` : " ") + check;
|
|
192
|
+
const prefixWidth = visibleWidth(prefix);
|
|
193
|
+
const labelRoom = Math.max(1, width - prefixWidth - rightWidth);
|
|
194
|
+
const label = truncateToWidth(item.label, labelRoom);
|
|
195
|
+
let line = padToWidth(label, Math.min(labelWidth, labelRoom));
|
|
145
196
|
if (selected && theme)
|
|
146
197
|
line = theme.fg("accent", theme.bold(line));
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
198
|
+
line = (selected && theme ? theme.fg("accent", theme.bold(prefix)) : prefix) + line;
|
|
199
|
+
const stacked = this.options.stacked === true;
|
|
200
|
+
if (!stacked) {
|
|
201
|
+
const room = width - visibleWidth(line) - 2 - rightWidth;
|
|
202
|
+
if (item.description && room > 4) {
|
|
203
|
+
line += " " + dim(truncateToWidth(item.description, room));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (right !== "") {
|
|
207
|
+
line =
|
|
208
|
+
padToWidth(truncateToWidth(line, width - rightWidth), width - rightWidth) + " " + right;
|
|
209
|
+
}
|
|
210
|
+
const out = [truncateToWidth(line, width)];
|
|
211
|
+
if (stacked && item.description) {
|
|
212
|
+
const indent = " ".repeat(prefixWidth + 2);
|
|
213
|
+
out.push(truncateToWidth(`${indent}${dim(truncateToWidth(item.description, Math.max(1, width - indent.length)))}`, width));
|
|
151
214
|
}
|
|
152
|
-
return
|
|
215
|
+
return selected && theme ? out.map((l) => theme.bg("selection", l)) : out;
|
|
153
216
|
}
|
|
154
217
|
labelColumnWidth(end) {
|
|
155
218
|
let max = 0;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 字形表与 ASCII 回退(终端界面视觉设计 v1 §2.2)。
|
|
3
|
+
*
|
|
4
|
+
* 所有组件通过 `theme.glyphs` 取字形,不另加参数;`UNICODE_GLYPHS` 里每个字形都是 1 列宽
|
|
5
|
+
* (`codePointWidth` 判定,与 wcwidth 一致;个别字体把 `⏺` 画成两格时用 `AMA_ASCII=1`)。
|
|
6
|
+
*
|
|
7
|
+
* ASCII 触发:`ui.ascii: true` / `AMA_ASCII=1`,或自动检测——区域设置(`LC_ALL` > `LC_CTYPE` > `LANG`)
|
|
8
|
+
* 已设置但不含 UTF-8、`TERM=linux`、Windows 上 `WT_SESSION` 与 `TERM_PROGRAM` 都为空(旧 conhost)。
|
|
9
|
+
* `AMA_ASCII=0` 强制 Unicode。区域变量都没设时按 Unicode 处理(容器与 CI 里常见)。
|
|
10
|
+
*/
|
|
11
|
+
export interface BoxGlyphs {
|
|
12
|
+
readonly topLeft: string;
|
|
13
|
+
readonly topRight: string;
|
|
14
|
+
readonly bottomLeft: string;
|
|
15
|
+
readonly bottomRight: string;
|
|
16
|
+
readonly vertical: string;
|
|
17
|
+
readonly horizontal: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Glyphs {
|
|
20
|
+
/** 是否 ASCII 回退表。 */
|
|
21
|
+
readonly ascii: boolean;
|
|
22
|
+
/** 用户消息、输入框提示符。 */
|
|
23
|
+
readonly prompt: string;
|
|
24
|
+
/** 工具调用标题。 */
|
|
25
|
+
readonly tool: string;
|
|
26
|
+
/** 结果连接符。 */
|
|
27
|
+
readonly result: string;
|
|
28
|
+
readonly ok: string;
|
|
29
|
+
readonly fail: string;
|
|
30
|
+
readonly warn: string;
|
|
31
|
+
/** 思考块、启动头标识。 */
|
|
32
|
+
readonly thinking: string;
|
|
33
|
+
/** 排队消息。 */
|
|
34
|
+
readonly queued: string;
|
|
35
|
+
/** 重试提示。 */
|
|
36
|
+
readonly retry: string;
|
|
37
|
+
/** Hook 阻止提示。 */
|
|
38
|
+
readonly blocked: string;
|
|
39
|
+
/** 左侧竖条卡片。 */
|
|
40
|
+
readonly card: string;
|
|
41
|
+
readonly expand: string;
|
|
42
|
+
readonly collapse: string;
|
|
43
|
+
/** 缓存保温。 */
|
|
44
|
+
readonly warm: string;
|
|
45
|
+
/** 当前项(选择器里打勾)。 */
|
|
46
|
+
readonly check: string;
|
|
47
|
+
/** 列表圆点(按嵌套深度循环)。 */
|
|
48
|
+
readonly bullets: readonly string[];
|
|
49
|
+
readonly meterFull: string;
|
|
50
|
+
readonly meterEmpty: string;
|
|
51
|
+
readonly box: BoxGlyphs;
|
|
52
|
+
/** 规则线(输入框上下、分隔线)。 */
|
|
53
|
+
readonly rule: string;
|
|
54
|
+
/** Loader 帧。 */
|
|
55
|
+
readonly spinner: readonly string[];
|
|
56
|
+
/** 静态 spinner(`ui.animation: false`)。 */
|
|
57
|
+
readonly spinnerStatic: string;
|
|
58
|
+
readonly ellipsis: string;
|
|
59
|
+
readonly arrowUp: string;
|
|
60
|
+
readonly arrowDown: string;
|
|
61
|
+
/** [W5-A] 状态栏 git 分支标记。 */
|
|
62
|
+
readonly branch: string;
|
|
63
|
+
/** [W5-A] 速率行分隔点。 */
|
|
64
|
+
readonly dot: string;
|
|
65
|
+
}
|
|
66
|
+
export declare const UNICODE_GLYPHS: Glyphs;
|
|
67
|
+
export declare const ASCII_GLYPHS: Glyphs;
|
|
68
|
+
/** 由环境判断是否用 ASCII 字形(`AMA_ASCII` 优先)。 */
|
|
69
|
+
export declare function detectAscii(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
70
|
+
/** 配置与环境合并:`AMA_ASCII` 显式值 > `ui.ascii` > 自动检测。 */
|
|
71
|
+
export declare function resolveAscii(configured: boolean | undefined, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
72
|
+
export declare function glyphsFor(ascii: boolean): Glyphs;
|