@lotagate/cli 0.1.20 → 0.1.22
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/dist/application/agent/agent-history.d.ts +3 -0
- package/dist/application/agent/agent-history.js +81 -0
- package/dist/application/agent/agent-input-context.d.ts +9 -0
- package/dist/application/agent/agent-input-context.js +12 -0
- package/dist/application/agent/agent-limit.d.ts +3 -0
- package/dist/application/agent/agent-limit.js +12 -0
- package/dist/application/agent/agent-run-tracker.d.ts +30 -0
- package/dist/application/agent/agent-run-tracker.js +68 -0
- package/dist/application/agent/agent-session-store.d.ts +19 -0
- package/dist/application/agent/agent-session-store.js +74 -0
- package/dist/application/agent/capability-profile.d.ts +37 -0
- package/dist/application/agent/capability-profile.js +13 -0
- package/dist/application/agent/cli-agent-execution-service.d.ts +81 -0
- package/dist/application/agent/cli-agent-execution-service.js +279 -0
- package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
- package/dist/application/agent/context-compaction-persistence.js +27 -0
- package/dist/application/agent/context-compaction.d.ts +20 -0
- package/dist/application/agent/context-compaction.js +114 -0
- package/dist/application/agent/prompt-data-safety.d.ts +14 -0
- package/dist/application/agent/prompt-data-safety.js +38 -0
- package/dist/application/agent/safe-system-prompt.d.ts +3 -0
- package/dist/application/agent/safe-system-prompt.js +19 -0
- package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
- package/dist/application/agent/scoped-tool-executor.js +32 -0
- package/dist/application/agent/system-prompt-builder.d.ts +14 -0
- package/dist/application/agent/system-prompt-builder.js +199 -0
- package/dist/application/agent/tool-catalog.d.ts +14 -0
- package/dist/application/agent/tool-catalog.js +30 -0
- package/dist/application/agent/tool-display.d.ts +6 -0
- package/dist/application/agent/tool-display.js +59 -0
- package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
- package/dist/application/agent/tool-hook-lifecycle.js +85 -0
- package/dist/application/auth/authentication-service.d.ts +20 -0
- package/dist/application/auth/authentication-service.js +44 -0
- package/dist/application/chat/chat-service.d.ts +12 -0
- package/dist/application/chat/chat-service.js +19 -0
- package/dist/application/chat/pending-attachment-store.d.ts +12 -0
- package/dist/application/chat/pending-attachment-store.js +28 -0
- package/dist/application/commands/application-command-executor.d.ts +20 -0
- package/dist/application/commands/application-command-executor.js +66 -0
- package/dist/application/commands/cli-args.d.ts +6 -0
- package/dist/application/commands/cli-args.js +43 -0
- package/dist/application/commands/cli-command-services.d.ts +16 -0
- package/dist/application/commands/cli-command-services.js +405 -0
- package/dist/application/commands/command-catalog.d.ts +6 -0
- package/dist/application/commands/command-catalog.js +159 -0
- package/dist/application/commands/command-contract.d.ts +58 -0
- package/dist/application/commands/command-contract.js +1 -0
- package/dist/application/commands/command-hints.d.ts +9 -0
- package/dist/application/commands/command-hints.js +17 -0
- package/dist/application/commands/command-output.d.ts +4 -0
- package/dist/application/commands/command-output.js +1 -0
- package/dist/application/commands/command-parser.d.ts +10 -0
- package/dist/application/commands/command-parser.js +155 -0
- package/dist/application/commands/command-presentation.d.ts +7 -0
- package/dist/application/commands/command-presentation.js +131 -0
- package/dist/application/commands/command-registry.d.ts +11 -0
- package/dist/application/commands/command-registry.js +64 -0
- package/dist/application/commands/command-runtime.d.ts +2 -0
- package/dist/application/commands/command-runtime.js +3 -0
- package/dist/application/commands/goal-command-handlers.d.ts +3 -0
- package/dist/application/commands/goal-command-handlers.js +120 -0
- package/dist/application/commands/media-command-handlers.d.ts +9 -0
- package/dist/application/commands/media-command-handlers.js +307 -0
- package/dist/application/commands/media-command-output.d.ts +11 -0
- package/dist/application/commands/media-command-output.js +8 -0
- package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
- package/dist/application/commands/runtime-command-handlers.js +177 -0
- package/dist/application/commands/stream-output.d.ts +4 -0
- package/dist/application/commands/stream-output.js +10 -0
- package/dist/application/commands/utility-commands.d.ts +6 -0
- package/dist/application/commands/utility-commands.js +81 -0
- package/dist/application/config/execution-config.d.ts +4 -0
- package/dist/application/config/execution-config.js +6 -0
- package/dist/application/extensions/extension-list-contract.d.ts +13 -0
- package/dist/application/extensions/extension-list-contract.js +1 -0
- package/dist/application/extensions/extension-list-formatters.d.ts +31 -0
- package/dist/application/extensions/extension-list-formatters.js +98 -0
- package/dist/application/extensions/extension-list-output.d.ts +3 -0
- package/dist/application/extensions/extension-list-output.js +7 -0
- package/dist/application/extensions/plugin-contribution-registry.d.ts +15 -0
- package/dist/application/extensions/plugin-contribution-registry.js +80 -0
- package/dist/application/extensions/skill-scope-store.d.ts +23 -0
- package/dist/application/extensions/skill-scope-store.js +33 -0
- package/dist/application/formatting/compact-number.d.ts +2 -0
- package/dist/application/formatting/compact-number.js +18 -0
- package/dist/application/formatting/compact-table.d.ts +22 -0
- package/dist/application/formatting/compact-table.js +49 -0
- package/dist/application/media/video-operation-poller.d.ts +5 -0
- package/dist/application/media/video-operation-poller.js +42 -0
- package/dist/application/model/cached-model-catalog.d.ts +13 -0
- package/dist/application/model/cached-model-catalog.js +31 -0
- package/dist/application/model/initial-model-selection.d.ts +10 -0
- package/dist/application/model/initial-model-selection.js +11 -0
- package/dist/application/model/model-catalog-service.d.ts +6 -0
- package/dist/application/model/model-catalog-service.js +13 -0
- package/dist/application/model/model-context-window.d.ts +3 -0
- package/dist/application/model/model-context-window.js +23 -0
- package/dist/application/orchestration/cli-subagent-service.d.ts +70 -0
- package/dist/application/orchestration/cli-subagent-service.js +328 -0
- package/dist/application/orchestration/cli-turn-event-projector.d.ts +12 -0
- package/dist/application/orchestration/cli-turn-event-projector.js +81 -0
- package/dist/application/orchestration/cli-turn-events.d.ts +76 -0
- package/dist/application/orchestration/cli-turn-events.js +39 -0
- package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
- package/dist/application/orchestration/cli-turn-persistence.js +14 -0
- package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
- package/dist/application/orchestration/goal-evaluator.js +88 -0
- package/dist/application/orchestration/goal-input.d.ts +3 -0
- package/dist/application/orchestration/goal-input.js +19 -0
- package/dist/application/orchestration/goal-output.d.ts +2 -0
- package/dist/application/orchestration/goal-output.js +11 -0
- package/dist/application/orchestration/goal-runner.d.ts +22 -0
- package/dist/application/orchestration/goal-runner.js +153 -0
- package/dist/application/orchestration/goal-usage.d.ts +9 -0
- package/dist/application/orchestration/goal-usage.js +19 -0
- package/dist/application/orchestration/headless-agent-turn.d.ts +32 -0
- package/dist/application/orchestration/headless-agent-turn.js +82 -0
- package/dist/application/orchestration/plan-generator.d.ts +7 -0
- package/dist/application/orchestration/plan-generator.js +34 -0
- package/dist/application/orchestration/subagent-coordinator.d.ts +33 -0
- package/dist/application/orchestration/subagent-coordinator.js +28 -0
- package/dist/application/orchestration/subagent-handoff.d.ts +2 -0
- package/dist/application/orchestration/subagent-handoff.js +68 -0
- package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
- package/dist/application/orchestration/subagent-tool-executor.js +93 -0
- package/dist/application/orchestration/task-assessment.d.ts +4 -0
- package/dist/application/orchestration/task-assessment.js +35 -0
- package/dist/application/orchestration/task-graph.d.ts +13 -0
- package/dist/application/orchestration/task-graph.js +56 -0
- package/dist/application/orchestration/task-scheduler.d.ts +18 -0
- package/dist/application/orchestration/task-scheduler.js +88 -0
- package/dist/application/project/project-trust-service.d.ts +13 -0
- package/dist/application/project/project-trust-service.js +74 -0
- package/dist/application/protocol/browser-host-tool-executor.d.ts +41 -0
- package/dist/application/protocol/browser-host-tool-executor.js +88 -0
- package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
- package/dist/application/protocol/desktop-agent-command.js +663 -0
- package/dist/application/protocol/desktop-attachment-store.d.ts +16 -0
- package/dist/application/protocol/desktop-attachment-store.js +82 -0
- package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
- package/dist/application/protocol/desktop-command-catalog.js +19 -0
- package/dist/application/protocol/desktop-command-contract.d.ts +22 -0
- package/dist/application/protocol/desktop-command-contract.js +3 -0
- package/dist/application/protocol/desktop-command-executor.d.ts +16 -0
- package/dist/application/protocol/desktop-command-executor.js +47 -0
- package/dist/application/protocol/desktop-command-output.d.ts +15 -0
- package/dist/application/protocol/desktop-command-output.js +24 -0
- package/dist/application/protocol/desktop-execution-policy.d.ts +17 -0
- package/dist/application/protocol/desktop-execution-policy.js +49 -0
- package/dist/application/protocol/desktop-host-tool-executor.d.ts +57 -0
- package/dist/application/protocol/desktop-host-tool-executor.js +53 -0
- package/dist/application/protocol/desktop-orchestration-events.d.ts +5 -0
- package/dist/application/protocol/desktop-orchestration-events.js +37 -0
- package/dist/application/protocol/json-line-writer.d.ts +9 -0
- package/dist/application/protocol/json-line-writer.js +19 -0
- package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
- package/dist/application/protocol/jsonl-agent-command.js +97 -0
- package/dist/application/protocol/jsonl-protocol.d.ts +52 -0
- package/dist/application/protocol/jsonl-protocol.js +170 -0
- package/dist/application/security/desktop-tool-scope-policy.d.ts +3 -0
- package/dist/application/security/desktop-tool-scope-policy.js +52 -0
- package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
- package/dist/application/security/tool-action-risk-analyzer.js +64 -0
- package/dist/application/security/tool-approval-service.d.ts +35 -0
- package/dist/application/security/tool-approval-service.js +97 -0
- package/dist/application/security/tool-risk-classifier.d.ts +11 -0
- package/dist/application/security/tool-risk-classifier.js +65 -0
- package/dist/application/security/workspace-permission-policy.d.ts +10 -0
- package/dist/application/security/workspace-permission-policy.js +50 -0
- package/dist/application/session/project-session-access.d.ts +8 -0
- package/dist/application/session/project-session-access.js +19 -0
- package/dist/application/session/session-compaction-service.d.ts +10 -0
- package/dist/application/session/session-compaction-service.js +43 -0
- package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
- package/dist/application/session/session-turn-lifecycle.js +31 -0
- package/dist/application/workspace/workspace-file-index.d.ts +15 -0
- package/dist/application/workspace/workspace-file-index.js +60 -0
- package/dist/application/workspace/workspace-file-reference-resolver.d.ts +14 -0
- package/dist/application/workspace/workspace-file-reference-resolver.js +123 -0
- package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
- package/dist/application/workspace/workspace-instruction-loader.js +55 -0
- package/dist/bootstrap/composition-root.d.ts +6 -0
- package/dist/bootstrap/composition-root.js +4 -0
- package/dist/bootstrap/global-cli-options.d.ts +6 -0
- package/dist/bootstrap/global-cli-options.js +29 -0
- package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
- package/dist/bootstrap/native-devtools-stub.js +10 -0
- package/dist/bootstrap/native-entry.d.ts +1 -0
- package/dist/bootstrap/native-entry.js +6 -0
- package/dist/bootstrap/native-tiktoken.d.ts +4 -0
- package/dist/bootstrap/native-tiktoken.js +5 -0
- package/dist/bootstrap/runtime-factory.d.ts +35 -0
- package/dist/bootstrap/runtime-factory.js +44 -0
- package/dist/bootstrap/shutdown-manager.d.ts +10 -0
- package/dist/bootstrap/shutdown-manager.js +14 -0
- package/dist/bootstrap/startup-sequence.d.ts +5 -0
- package/dist/bootstrap/startup-sequence.js +10 -0
- package/dist/domain/auth/auth-profile.d.ts +14 -0
- package/dist/domain/auth/auth-profile.js +39 -0
- package/dist/domain/config/config-schema.d.ts +17 -0
- package/dist/domain/config/config-schema.js +105 -0
- package/dist/domain/errors/cli-command-hint.d.ts +5 -0
- package/dist/domain/errors/cli-command-hint.js +1 -0
- package/dist/domain/errors/cli-error.d.ts +35 -0
- package/dist/domain/errors/cli-error.js +129 -0
- package/dist/domain/errors/error-codes.d.ts +46 -0
- package/dist/domain/errors/error-codes.js +45 -0
- package/dist/domain/extensions/extension-scope.d.ts +3 -0
- package/dist/domain/extensions/extension-scope.js +23 -0
- package/dist/domain/extensions/extension-state.d.ts +5 -0
- package/dist/domain/extensions/extension-state.js +11 -0
- package/dist/domain/extensions/hook-manifest.d.ts +10 -0
- package/dist/domain/extensions/hook-manifest.js +23 -0
- package/dist/domain/extensions/mcp-config.d.ts +18 -0
- package/dist/domain/extensions/mcp-config.js +111 -0
- package/dist/domain/extensions/plugin-manifest.d.ts +11 -0
- package/dist/domain/extensions/plugin-manifest.js +43 -0
- package/dist/domain/extensions/skill-manifest.d.ts +10 -0
- package/dist/domain/extensions/skill-manifest.js +51 -0
- package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
- package/dist/domain/filesystem/file-change-diff.js +60 -0
- package/dist/domain/media/gateway-media-contract.d.ts +23 -0
- package/dist/domain/media/gateway-media-contract.js +163 -0
- package/dist/domain/media/media-contract.d.ts +28 -0
- package/dist/domain/media/media-contract.js +1 -0
- package/dist/domain/media/media-execution-policy.d.ts +9 -0
- package/dist/domain/media/media-execution-policy.js +31 -0
- package/dist/domain/orchestration/goal.d.ts +58 -0
- package/dist/domain/orchestration/goal.js +113 -0
- package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
- package/dist/domain/orchestration/subagent-identity.js +8 -0
- package/dist/domain/orchestration/subagent.d.ts +33 -0
- package/dist/domain/orchestration/subagent.js +1 -0
- package/dist/domain/orchestration/task.d.ts +31 -0
- package/dist/domain/orchestration/task.js +1 -0
- package/dist/domain/project/project-identity.d.ts +6 -0
- package/dist/domain/project/project-identity.js +4 -0
- package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
- package/dist/domain/runtime/assistant-delta-normalizer.js +19 -0
- package/dist/domain/runtime/resource-limits.d.ts +60 -0
- package/dist/domain/runtime/resource-limits.js +60 -0
- package/dist/domain/session/attachment.d.ts +13 -0
- package/dist/domain/session/attachment.js +1 -0
- package/dist/domain/session/session-schema.d.ts +6 -0
- package/dist/domain/session/session-schema.js +28 -0
- package/dist/domain/session/session.d.ts +27 -0
- package/dist/domain/session/session.js +1 -0
- package/dist/domain/settings/settings-document.d.ts +8 -0
- package/dist/domain/settings/settings-document.js +36 -0
- package/dist/domain/validation/record-schema.d.ts +4 -0
- package/dist/domain/validation/record-schema.js +9 -0
- package/dist/domain/workspace/workspace-settings.d.ts +12 -0
- package/dist/domain/workspace/workspace-settings.js +44 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.js +31 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +447 -0
- package/dist/infrastructure/cache/cache-policy.d.ts +7 -0
- package/dist/infrastructure/cache/cache-policy.js +18 -0
- package/dist/infrastructure/cache/file-cache-store.d.ts +17 -0
- package/dist/infrastructure/cache/file-cache-store.js +121 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +98 -0
- package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
- package/dist/infrastructure/clipboard/clipboard-policy.js +19 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +94 -0
- package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
- package/dist/infrastructure/clipboard/image-normalizer.js +78 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +66 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +70 -0
- package/dist/infrastructure/config/config-loader.d.ts +19 -0
- package/dist/infrastructure/config/config-loader.js +76 -0
- package/dist/infrastructure/config/environment-values.d.ts +2 -0
- package/dist/infrastructure/config/environment-values.js +7 -0
- package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/composite-credential-store.js +32 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.js +181 -0
- package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/environment-credential-store.js +37 -0
- package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
- package/dist/infrastructure/credentials/secret-input.js +44 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.js +10 -0
- package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
- package/dist/infrastructure/extensions/extension-directory-reader.js +15 -0
- package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
- package/dist/infrastructure/extensions/extension-source-resolver.js +126 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.js +66 -0
- package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
- package/dist/infrastructure/extensions/hook-runtime.js +66 -0
- package/dist/infrastructure/extensions/mcp-runtime.d.ts +12 -0
- package/dist/infrastructure/extensions/mcp-runtime.js +52 -0
- package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
- package/dist/infrastructure/extensions/plugin-discovery.js +52 -0
- package/dist/infrastructure/extensions/plugin-manager.d.ts +26 -0
- package/dist/infrastructure/extensions/plugin-manager.js +139 -0
- package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
- package/dist/infrastructure/extensions/skill-discovery.js +29 -0
- package/dist/infrastructure/extensions/skill-installer.d.ts +8 -0
- package/dist/infrastructure/extensions/skill-installer.js +88 -0
- package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
- package/dist/infrastructure/extensions/skill-manager.js +67 -0
- package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
- package/dist/infrastructure/extensions/skill-roots.js +25 -0
- package/dist/infrastructure/extensions/skill-tool-executor.d.ts +18 -0
- package/dist/infrastructure/extensions/skill-tool-executor.js +53 -0
- package/dist/infrastructure/filesystem/atomic-file-store.d.ts +12 -0
- package/dist/infrastructure/filesystem/atomic-file-store.js +106 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.js +24 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.js +7 -0
- package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
- package/dist/infrastructure/filesystem/fs-errors.js +6 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.js +49 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +21 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +176 -0
- package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
- package/dist/infrastructure/filesystem/path-resolver.js +119 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +152 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +20 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.js +75 -0
- package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
- package/dist/infrastructure/logging/log-redactor.js +26 -0
- package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
- package/dist/infrastructure/logging/logging-policy.js +6 -0
- package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
- package/dist/infrastructure/logging/structured-logger.js +40 -0
- package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
- package/dist/infrastructure/network/safe-media-downloader.js +239 -0
- package/dist/infrastructure/platform/host-platform.d.ts +14 -0
- package/dist/infrastructure/platform/host-platform.js +23 -0
- package/dist/infrastructure/platform/host-process.d.ts +17 -0
- package/dist/infrastructure/platform/host-process.js +116 -0
- package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
- package/dist/infrastructure/platform/platform-paths.js +33 -0
- package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
- package/dist/infrastructure/project/file-project-trust-store.js +59 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.js +115 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.js +8 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.js +28 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +20 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.js +97 -0
- package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
- package/dist/infrastructure/sessions/file-goal-store.js +160 -0
- package/dist/infrastructure/sessions/file-session-store.d.ts +48 -0
- package/dist/infrastructure/sessions/file-session-store.js +525 -0
- package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
- package/dist/infrastructure/sessions/project-session-paths.js +41 -0
- package/dist/infrastructure/sessions/session-index.d.ts +16 -0
- package/dist/infrastructure/sessions/session-index.js +84 -0
- package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
- package/dist/infrastructure/sessions/session-journal.js +137 -0
- package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
- package/dist/infrastructure/sessions/subagent-journal-store.js +30 -0
- package/dist/infrastructure/shell/shell-tool-executor.d.ts +17 -0
- package/dist/infrastructure/shell/shell-tool-executor.js +115 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.js +48 -0
- package/dist/infrastructure/workspace/workspace-settings-store.d.ts +9 -0
- package/dist/infrastructure/workspace/workspace-settings-store.js +75 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +66 -0
- package/dist/ports/cache-store.d.ts +10 -0
- package/dist/ports/cache-store.js +1 -0
- package/dist/ports/chat-model.d.ts +30 -0
- package/dist/ports/chat-model.js +1 -0
- package/dist/ports/clipboard-adapter.d.ts +7 -0
- package/dist/ports/clipboard-adapter.js +1 -0
- package/dist/ports/clipboard-text-adapter.d.ts +3 -0
- package/dist/ports/clipboard-text-adapter.js +1 -0
- package/dist/ports/credential-store.d.ts +7 -0
- package/dist/ports/credential-store.js +1 -0
- package/dist/ports/goal-store.d.ts +12 -0
- package/dist/ports/goal-store.js +1 -0
- package/dist/ports/logger.d.ts +8 -0
- package/dist/ports/logger.js +1 -0
- package/dist/ports/media-gateway-client.d.ts +54 -0
- package/dist/ports/media-gateway-client.js +1 -0
- package/dist/ports/model-diagnostics.d.ts +17 -0
- package/dist/ports/model-diagnostics.js +1 -0
- package/dist/ports/project-trust-store.d.ts +12 -0
- package/dist/ports/project-trust-store.js +1 -0
- package/dist/ports/session-store.d.ts +58 -0
- package/dist/ports/session-store.js +1 -0
- package/dist/ports/subagent-lifecycle.d.ts +31 -0
- package/dist/ports/subagent-lifecycle.js +1 -0
- package/dist/ports/tool-activity.d.ts +13 -0
- package/dist/ports/tool-activity.js +1 -0
- package/dist/presentation/themes/theme.d.ts +19 -0
- package/dist/presentation/themes/theme.js +8 -0
- package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
- package/dist/presentation/tui/agent-initialization-renderer.js +37 -0
- package/dist/presentation/tui/context-display.d.ts +21 -0
- package/dist/presentation/tui/context-display.js +33 -0
- package/dist/presentation/tui/formatters.d.ts +6 -0
- package/dist/presentation/tui/formatters.js +60 -0
- package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
- package/dist/presentation/tui/ink/choice-window.js +5 -0
- package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
- package/dist/presentation/tui/ink/components/activity-entry.js +16 -0
- package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
- package/dist/presentation/tui/ink/components/activity-status.js +21 -0
- package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
- package/dist/presentation/tui/ink/components/choice-modal.js +29 -0
- package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
- package/dist/presentation/tui/ink/components/composer.js +271 -0
- package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
- package/dist/presentation/tui/ink/components/file-diff.js +34 -0
- package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
- package/dist/presentation/tui/ink/components/modal.js +110 -0
- package/dist/presentation/tui/ink/components/shimmer-text.d.ts +6 -0
- package/dist/presentation/tui/ink/components/shimmer-text.js +9 -0
- package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
- package/dist/presentation/tui/ink/components/subagent-activity.js +61 -0
- package/dist/presentation/tui/ink/components/transcript.d.ts +39 -0
- package/dist/presentation/tui/ink/components/transcript.js +121 -0
- package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
- package/dist/presentation/tui/ink/components/welcome-panel.js +20 -0
- package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
- package/dist/presentation/tui/ink/lotagate-tui.js +136 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.js +20 -0
- package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
- package/dist/presentation/tui/ink/markdown-inline.js +91 -0
- package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
- package/dist/presentation/tui/ink/markdown-message.js +66 -0
- package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
- package/dist/presentation/tui/ink/markdown-table.js +77 -0
- package/dist/presentation/tui/ink/tui-bridge.d.ts +195 -0
- package/dist/presentation/tui/ink/tui-bridge.js +289 -0
- package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
- package/dist/presentation/tui/terminal-capabilities.js +7 -0
- package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
- package/dist/presentation/tui/terminal-mouse.js +19 -0
- package/dist/presentation/tui/terminal-screen.d.ts +10 -0
- package/dist/presentation/tui/terminal-screen.js +23 -0
- package/dist/presentation/tui/tui-agent-event-runner.d.ts +24 -0
- package/dist/presentation/tui/tui-agent-event-runner.js +69 -0
- package/dist/presentation/tui/tui-application-contract.d.ts +10 -0
- package/dist/presentation/tui/tui-application-contract.js +8 -0
- package/dist/presentation/tui/tui-application.d.ts +62 -0
- package/dist/presentation/tui/tui-application.js +675 -0
- package/dist/presentation/tui/tui-attachment-input.d.ts +2 -0
- package/dist/presentation/tui/tui-attachment-input.js +5 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.js +25 -0
- package/dist/presentation/tui/tui-command-context.d.ts +3 -0
- package/dist/presentation/tui/tui-command-context.js +1 -0
- package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
- package/dist/presentation/tui/tui-command-executor.js +214 -0
- package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
- package/dist/presentation/tui/tui-command-host-factory.js +23 -0
- package/dist/presentation/tui/tui-context-compaction.d.ts +5 -0
- package/dist/presentation/tui/tui-context-compaction.js +22 -0
- package/dist/presentation/tui/tui-context-service.d.ts +34 -0
- package/dist/presentation/tui/tui-context-service.js +126 -0
- package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
- package/dist/presentation/tui/tui-file-suggestions.js +8 -0
- package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
- package/dist/presentation/tui/tui-goal-controller.js +52 -0
- package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
- package/dist/presentation/tui/tui-initial-model.js +28 -0
- package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
- package/dist/presentation/tui/tui-lifecycle-actions.js +45 -0
- package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
- package/dist/presentation/tui/tui-manual-compaction.js +31 -0
- package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
- package/dist/presentation/tui/tui-media-model-selection.js +38 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.js +38 -0
- package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
- package/dist/presentation/tui/tui-skill-controller.js +13 -0
- package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
- package/dist/presentation/tui/tui-tool-approval.js +73 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +9 -8
- package/scripts/install-native.mjs +11 -11
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const ALL = ['direct', 'tui'];
|
|
2
|
+
const DIRECT = ['direct'];
|
|
3
|
+
const TUI = ['tui'];
|
|
4
|
+
const scopeOption = {
|
|
5
|
+
name: 'scope', valueName: '<user|project>', description: 'Extension scope', allowedValues: ['user', 'project'], requiredOn: DIRECT,
|
|
6
|
+
};
|
|
7
|
+
const goalLimitOptions = [
|
|
8
|
+
{ name: 'token-budget', valueName: '<n>', description: 'Maximum token budget' },
|
|
9
|
+
{ name: 'max-turns', valueName: '<n>', description: 'Maximum goal turns' },
|
|
10
|
+
{ name: 'max-duration-ms', valueName: '<n>', description: 'Maximum goal duration' },
|
|
11
|
+
];
|
|
12
|
+
const modelOverrideOption = { name: 'model', valueName: '<model-id>', description: 'Use this model for this request only' };
|
|
13
|
+
const outputOptions = [
|
|
14
|
+
{ name: 'out', valueName: '<filename>', description: 'Output filename without extension' },
|
|
15
|
+
{ name: 'out-dir', valueName: '<directory>', description: 'Local output directory, inside or outside the workspace' },
|
|
16
|
+
{ name: 'force', description: 'Allow --out to replace an existing generated file' },
|
|
17
|
+
];
|
|
18
|
+
const imageOptions = [
|
|
19
|
+
modelOverrideOption,
|
|
20
|
+
{ name: 'n', valueName: '<count>', description: 'Number of images' },
|
|
21
|
+
{ name: 'size', valueName: '<size>', description: 'Requested image size' },
|
|
22
|
+
{ name: 'quality', valueName: '<low|medium|high|auto>', description: 'Image quality', allowedValues: ['low', 'medium', 'high', 'auto'] },
|
|
23
|
+
{ name: 'background', valueName: '<transparent|opaque|auto>', description: 'Image background', allowedValues: ['transparent', 'opaque', 'auto'] },
|
|
24
|
+
{ name: 'output-format', valueName: '<png|jpeg|webp>', description: 'Image output format', allowedValues: ['png', 'jpeg', 'webp'] },
|
|
25
|
+
{ name: 'output-compression', valueName: '<0-100>', description: 'Image output compression' },
|
|
26
|
+
{ name: 'moderation', valueName: '<mode>', description: 'Image moderation mode' },
|
|
27
|
+
{ name: 'user', valueName: '<id>', description: 'End-user identifier' },
|
|
28
|
+
...outputOptions,
|
|
29
|
+
];
|
|
30
|
+
function action(spec) {
|
|
31
|
+
return spec;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Executable command contract for every public direct and slash command.
|
|
35
|
+
* Presentation layers consume this catalog; application handlers remain separate.
|
|
36
|
+
*/
|
|
37
|
+
export const COMMAND_ACTIONS = [
|
|
38
|
+
action({ id: 'help', path: ['help'], surfaces: ALL, summary: 'Show available commands', executor: 'help' }),
|
|
39
|
+
action({ id: 'version', path: ['version'], surfaces: ALL, summary: 'Show the CLI version', executor: 'version' }),
|
|
40
|
+
action({ id: 'config.get.default', path: ['config'], handlerPath: ['get'], surfaces: ALL, summary: 'Read effective configuration', arguments: [{ name: 'key', required: false }], executor: 'config', defaultAction: true, hiddenFromHelp: true }),
|
|
41
|
+
action({ id: 'config.get', path: ['config', 'get'], handlerPath: ['get'], surfaces: ALL, summary: 'Read effective configuration', arguments: [{ name: 'key', required: false }], executor: 'config' }),
|
|
42
|
+
action({ id: 'config.set', path: ['config', 'set'], handlerPath: ['set'], surfaces: ALL, summary: 'Update global configuration', arguments: [{ name: 'key', required: true }, { name: 'value', required: true }], executor: 'config' }),
|
|
43
|
+
action({ id: 'config.path', path: ['config', 'path'], handlerPath: ['path'], surfaces: ALL, summary: 'Show configuration paths', executor: 'config' }),
|
|
44
|
+
action({ id: 'auth.status.default', path: ['auth'], handlerPath: ['status'], surfaces: ALL, summary: 'Show authentication status', executor: 'auth', defaultAction: true, hiddenFromHelp: true }),
|
|
45
|
+
action({ id: 'auth.login.direct', path: ['auth', 'login'], handlerPath: ['login'], surfaces: DIRECT, summary: 'Save an API-key profile', options: [{ name: 'profile', valueName: '<name>', description: 'Profile name' }, { name: 'base-url', valueName: '<url>', description: 'Provider base URL' }], executor: 'auth', desktop: { exposed: false } }),
|
|
46
|
+
action({ id: 'auth.login.tui', path: ['auth', 'login'], handlerPath: ['login'], surfaces: TUI, summary: 'Save an API-key profile', options: [{ name: 'profile', valueName: '<name>', description: 'Profile name' }, { name: 'base-url', valueName: '<url>', description: 'Provider base URL' }], executor: 'tui-auth-login' }),
|
|
47
|
+
action({ id: 'auth.logout', path: ['auth', 'logout'], handlerPath: ['logout'], surfaces: ALL, summary: 'Remove an API-key profile', arguments: [{ name: 'profile', required: false }], executor: 'auth' }),
|
|
48
|
+
action({ id: 'auth.list', path: ['auth', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List authentication profiles', executor: 'auth' }),
|
|
49
|
+
action({ id: 'auth.status', path: ['auth', 'status'], handlerPath: ['status'], surfaces: ALL, summary: 'Show authentication status', executor: 'auth' }),
|
|
50
|
+
action({ id: 'auth.use', path: ['auth', 'use'], handlerPath: ['use'], surfaces: ALL, summary: 'Select an authentication profile', arguments: [{ name: 'profile', required: true }], executor: 'auth' }),
|
|
51
|
+
action({ id: 'model.current.direct', path: ['model'], handlerPath: ['current'], surfaces: DIRECT, summary: 'Show the selected model', executor: 'model', defaultAction: true, hiddenFromHelp: true }),
|
|
52
|
+
action({ id: 'model.select.tui', path: ['model'], surfaces: TUI, summary: 'Select a model', executor: 'tui-model-select', defaultAction: true, hiddenFromHelp: true }),
|
|
53
|
+
action({ id: 'model.current', path: ['model', 'current'], handlerPath: ['current'], surfaces: ALL, summary: 'Show the selected model', executor: 'model' }),
|
|
54
|
+
action({ id: 'model.use', path: ['model', 'use'], handlerPath: ['use'], surfaces: ALL, summary: 'Select a model', arguments: [{ name: 'model', required: true }], executor: 'model' }),
|
|
55
|
+
action({ id: 'model.list', path: ['model', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'Fetch the model catalog', executor: 'model' }),
|
|
56
|
+
action({ id: 'model.refresh', path: ['model', 'refresh'], handlerPath: ['refresh'], surfaces: ALL, summary: 'Refresh the model catalog', executor: 'model' }),
|
|
57
|
+
action({ id: 'model.doctor', path: ['model', 'doctor'], handlerPath: ['doctor'], surfaces: ALL, summary: 'Inspect model configuration', executor: 'model' }),
|
|
58
|
+
action({ id: 'trust.status.default', path: ['trust'], handlerPath: ['status'], surfaces: ALL, summary: 'Show current project trust', executor: 'trust', defaultAction: true, hiddenFromHelp: true }),
|
|
59
|
+
action({ id: 'trust.status', path: ['trust', 'status'], handlerPath: ['status'], surfaces: ALL, summary: 'Show current project trust', executor: 'trust' }),
|
|
60
|
+
action({ id: 'trust.list', path: ['trust', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List trusted projects', executor: 'trust' }),
|
|
61
|
+
action({ id: 'trust.grant', path: ['trust', 'grant'], handlerPath: ['grant'], surfaces: ALL, summary: 'Trust the current project', executor: 'trust' }),
|
|
62
|
+
action({ id: 'trust.revoke', path: ['trust', 'revoke'], handlerPath: ['revoke'], surfaces: ALL, summary: 'Revoke current project trust', executor: 'trust' }),
|
|
63
|
+
action({ id: 'inspect', path: ['inspect'], surfaces: ALL, summary: 'Inspect current project identity', executor: 'inspect' }),
|
|
64
|
+
action({ id: 'hook.list.default', path: ['hook'], handlerPath: ['list'], surfaces: ALL, summary: 'List project and plugin hooks', executor: 'hook', defaultAction: true, hiddenFromHelp: true }),
|
|
65
|
+
action({ id: 'hook.list', path: ['hook', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List project and plugin hooks', executor: 'hook' }),
|
|
66
|
+
action({ id: 'mcp.list.default', path: ['mcp'], surfaces: ALL, summary: 'List configured MCP servers', executor: 'mcp', defaultAction: true, hiddenFromHelp: true }),
|
|
67
|
+
action({ id: 'mcp.list', path: ['mcp', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List configured MCP servers', executor: 'mcp' }),
|
|
68
|
+
action({ id: 'mcp.get', path: ['mcp', 'get'], handlerPath: ['get'], surfaces: ALL, summary: 'Inspect an MCP server', arguments: [{ name: 'name', required: true }], options: [scopeOption], executor: 'mcp' }),
|
|
69
|
+
action({ id: 'mcp.add', path: ['mcp', 'add'], handlerPath: ['add'], surfaces: ALL, summary: 'Add an MCP server', arguments: [{ name: 'name', required: true }], options: [
|
|
70
|
+
{ name: 'type', valueName: '<stdio|http|sse>', description: 'MCP transport type (defaults to stdio)', allowedValues: ['stdio', 'http', 'sse'] },
|
|
71
|
+
{ name: 'command', valueName: '<command>', description: 'stdio command', requiredWhen: { option: 'type', values: ['stdio'], absent: true } },
|
|
72
|
+
{ name: 'url', valueName: '<url>', description: 'HTTP or SSE URL', requiredWhen: { option: 'type', values: ['http', 'sse'] } },
|
|
73
|
+
{ name: 'args', valueName: '<a,b>', description: 'Comma-separated stdio arguments' }, scopeOption,
|
|
74
|
+
], executor: 'mcp' }),
|
|
75
|
+
action({ id: 'mcp.reload', path: ['mcp', 'reload'], handlerPath: ['reload'], surfaces: ALL, summary: 'Reconnect configured MCP servers', executor: 'mcp' }),
|
|
76
|
+
action({ id: 'mcp.doctor', path: ['mcp', 'doctor'], handlerPath: ['doctor'], surfaces: ALL, summary: 'Validate MCP servers', executor: 'mcp' }),
|
|
77
|
+
...['enable', 'disable', 'remove'].map((name) => action({ id: `mcp.${name}`, path: ['mcp', name], handlerPath: [name], surfaces: ALL, summary: `${name[0].toUpperCase()}${name.slice(1)} an MCP server`, arguments: [{ name: 'name', required: true }], options: [scopeOption], executor: 'mcp' })),
|
|
78
|
+
action({ id: 'plugin.list.default', path: ['plugin'], surfaces: ALL, summary: 'List installed plugins', executor: 'plugin', defaultAction: true, hiddenFromHelp: true }),
|
|
79
|
+
action({ id: 'plugin.list', path: ['plugin', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List installed plugins', executor: 'plugin' }),
|
|
80
|
+
action({ id: 'plugin.install', path: ['plugin', 'install'], handlerPath: ['install'], surfaces: ALL, summary: 'Install a plugin or standalone skill', arguments: [{ name: 'source', required: true }], options: [scopeOption, { name: 'sha256', valueName: '<hex>', description: 'Expected archive checksum' }, { name: 'signature', valueName: '<base64>', description: 'Archive signature' }, { name: 'public-key', valueName: '<pem>', description: 'Signature public key' }], executor: 'plugin' }),
|
|
81
|
+
...['enable', 'disable', 'uninstall'].map((name) => action({ id: `plugin.${name}`, path: ['plugin', name], handlerPath: [name], surfaces: ALL, summary: `${name[0].toUpperCase()}${name.slice(1)} a plugin`, arguments: [{ name: 'name', required: true }], options: [scopeOption], executor: 'plugin' })),
|
|
82
|
+
action({ id: 'skill.list.default', path: ['skill'], surfaces: ALL, summary: 'List available skills', executor: 'skill', defaultAction: true, hiddenFromHelp: true }),
|
|
83
|
+
action({ id: 'skill.list', path: ['skill', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List available skills', executor: 'skill' }),
|
|
84
|
+
...['info', 'enable', 'disable', 'remove'].map((name) => action({ id: `skill.${name}`, path: ['skill', name], handlerPath: [name], surfaces: ALL, summary: `${name[0].toUpperCase()}${name.slice(1)} a skill`, arguments: [{ name: 'name', required: true }], options: [scopeOption], executor: 'skill' })),
|
|
85
|
+
action({ id: 'skill.run.direct', path: ['skill', 'run'], handlerPath: ['run'], surfaces: DIRECT, summary: 'Print an enabled skill prompt', arguments: [{ name: 'name', required: true }], options: [scopeOption], executor: 'skill' }),
|
|
86
|
+
action({ id: 'skill.run.tui', path: ['skill', 'run'], surfaces: TUI, summary: 'Run an enabled skill', arguments: [{ name: 'name', required: true }, { name: 'arguments', required: false, variadic: true }], options: [scopeOption], executor: 'tui-skill-run' }),
|
|
87
|
+
action({ id: 'session.list.default', path: ['session'], surfaces: ALL, summary: 'List durable sessions', executor: 'session', defaultAction: true, hiddenFromHelp: true }),
|
|
88
|
+
action({ id: 'session.list', path: ['session', 'list'], handlerPath: ['list'], surfaces: ALL, summary: 'List durable sessions', executor: 'session' }),
|
|
89
|
+
action({ id: 'session.show', path: ['session', 'show'], handlerPath: ['show'], surfaces: ALL, summary: 'Show a session transcript', arguments: [{ name: 'id', required: true }], executor: 'session' }),
|
|
90
|
+
action({ id: 'session.import', path: ['session', 'import'], handlerPath: ['import'], surfaces: ALL, summary: 'Import a session bundle', options: [{ name: 'file', valueName: '<path>', description: 'Session bundle path', required: true }], executor: 'session' }),
|
|
91
|
+
action({ id: 'session.resume.direct', path: ['session', 'resume'], handlerPath: ['resume'], surfaces: DIRECT, summary: 'Inspect or resume a session', arguments: [{ name: 'id', required: true }], options: [{ name: 'interactive', description: 'Open the session in the TUI' }], executor: 'session' }),
|
|
92
|
+
action({ id: 'session.resume.tui', path: ['session', 'resume'], surfaces: TUI, summary: 'Resume a session in this TUI', arguments: [{ name: 'id', required: true }], executor: 'tui-session-resume' }),
|
|
93
|
+
action({ id: 'session.fork', path: ['session', 'fork'], handlerPath: ['fork'], surfaces: ALL, summary: 'Fork a session', arguments: [{ name: 'id', required: true }], executor: 'session' }),
|
|
94
|
+
action({ id: 'session.compact.direct', path: ['session', 'compact'], handlerPath: ['compact'], surfaces: DIRECT, summary: 'Compact a session', arguments: [{ name: 'id', required: true }], executor: 'session' }),
|
|
95
|
+
action({ id: 'session.compact.tui', path: ['session', 'compact'], surfaces: TUI, summary: 'Compact the active session', executor: 'tui-session-compact' }),
|
|
96
|
+
action({ id: 'session.export', path: ['session', 'export'], handlerPath: ['export'], surfaces: ALL, summary: 'Export a session bundle', arguments: [{ name: 'id', required: true }], options: [{ name: 'out', valueName: '<path>', description: 'Output path' }], executor: 'session' }),
|
|
97
|
+
...['recover', 'repair', 'delete'].map((name) => action({ id: `session.${name}`, path: ['session', name], handlerPath: [name], surfaces: ALL, summary: `${name[0].toUpperCase()}${name.slice(1)} a session`, arguments: [{ name: 'id', required: true }], executor: 'session' })),
|
|
98
|
+
action({ id: 'session.rename', path: ['session', 'rename'], surfaces: TUI, summary: 'Rename the active session', arguments: [{ name: 'name', required: true, variadic: true }], executor: 'tui-session-rename' }),
|
|
99
|
+
action({ id: 'goal.status.direct', path: ['goal', 'status'], handlerPath: ['status'], surfaces: DIRECT, summary: 'Show a session goal', arguments: [{ name: 'id', required: true }], options: [{ name: 'json', description: 'Use JSON output' }], executor: 'goal' }),
|
|
100
|
+
action({ id: 'goal.set', path: ['goal', 'set'], handlerPath: ['set'], surfaces: DIRECT, summary: 'Set a session goal', arguments: [{ name: 'id', required: true }, { name: 'objective', required: true, variadic: true }], options: [...goalLimitOptions, { name: 'json', description: 'Use JSON output' }], executor: 'goal' }),
|
|
101
|
+
action({ id: 'goal.pause.direct', path: ['goal', 'pause'], handlerPath: ['pause'], surfaces: DIRECT, summary: 'Pause a session goal', arguments: [{ name: 'id', required: true }], options: [{ name: 'json', description: 'Use JSON output' }], executor: 'goal' }),
|
|
102
|
+
action({ id: 'goal.resume.direct', path: ['goal', 'resume'], handlerPath: ['resume'], surfaces: DIRECT, summary: 'Resume a session goal', arguments: [{ name: 'id', required: true }], options: [...goalLimitOptions, { name: 'json', description: 'Use JSON output' }], executor: 'goal' }),
|
|
103
|
+
action({ id: 'goal.clear.direct', path: ['goal', 'clear'], handlerPath: ['clear'], surfaces: DIRECT, summary: 'Clear a session goal', arguments: [{ name: 'id', required: true }], executor: 'goal' }),
|
|
104
|
+
action({ id: 'goal.run', path: ['goal', 'run'], handlerPath: ['run'], surfaces: DIRECT, summary: 'Run a durable multi-turn goal', arguments: [{ name: 'objective', required: true, variadic: true }], options: goalLimitOptions, executor: 'goal' }),
|
|
105
|
+
...['status', 'pause', 'resume', 'clear'].map((name) => action({ id: `goal.${name}.tui`, path: ['goal', name], surfaces: TUI, summary: `${name[0].toUpperCase()}${name.slice(1)} the active goal`, executor: 'tui-goal' })),
|
|
106
|
+
action({ id: 'goal.start.tui', path: ['goal'], surfaces: TUI, summary: 'Start a goal for the active session', arguments: [{ name: 'objective', required: true, variadic: true }], options: goalLimitOptions, executor: 'tui-goal', defaultAction: true, hiddenFromHelp: true }),
|
|
107
|
+
action({ id: 'doctor', path: ['doctor'], surfaces: ALL, summary: 'Run local diagnostics', executor: 'doctor' }),
|
|
108
|
+
action({ id: 'chat.direct', path: ['chat'], surfaces: DIRECT, summary: 'Stream a chat completion', arguments: [{ name: 'prompt', required: false, variadic: true }], executor: 'chat' }),
|
|
109
|
+
action({ id: 'chat.tui', path: ['chat'], surfaces: TUI, summary: 'Send an interactive chat prompt', arguments: [{ name: 'prompt', required: true, variadic: true }], executor: 'tui-prompt' }),
|
|
110
|
+
action({ id: 'image.generate', path: ['image'], surfaces: ALL, summary: 'Generate image artifacts', arguments: [{ name: 'prompt', required: true, variadic: true }], options: imageOptions, executor: 'media' }),
|
|
111
|
+
action({ id: 'image.edit', path: ['image', 'edit'], handlerPath: ['edit'], surfaces: ALL, summary: 'Edit image artifacts', arguments: [{ name: 'prompt', required: true, variadic: true }], options: [
|
|
112
|
+
...imageOptions,
|
|
113
|
+
{ name: 'image', valueName: '<path[,path]>', description: 'Source local image files', required: true },
|
|
114
|
+
{ name: 'mask', valueName: '<path>', description: 'Optional local mask image' },
|
|
115
|
+
{ name: 'input-fidelity', valueName: '<low|high>', description: 'Input image fidelity', allowedValues: ['low', 'high'] },
|
|
116
|
+
], executor: 'media' }),
|
|
117
|
+
action({ id: 'audio.speech', path: ['audio', 'speech'], handlerPath: ['speech'], surfaces: ALL, summary: 'Generate speech audio', arguments: [{ name: 'input', required: true, variadic: true }], options: [
|
|
118
|
+
modelOverrideOption, { name: 'voice', valueName: '<voice>', description: 'Voice identifier', required: true },
|
|
119
|
+
{ name: 'instructions', valueName: '<text>', description: 'Voice instructions' },
|
|
120
|
+
{ name: 'response-format', valueName: '<mp3|opus|aac|flac|wav|pcm>', description: 'Audio output format', allowedValues: ['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'] },
|
|
121
|
+
{ name: 'speed', valueName: '<number>', description: 'Speech speed' }, ...outputOptions,
|
|
122
|
+
], executor: 'media' }),
|
|
123
|
+
action({ id: 'audio.transcribe', path: ['audio', 'transcribe'], handlerPath: ['transcribe'], surfaces: ALL, summary: 'Transcribe an audio file', options: [
|
|
124
|
+
modelOverrideOption, { name: 'file', valueName: '<path>', description: 'Local audio file', required: true },
|
|
125
|
+
{ name: 'language', valueName: '<code>', description: 'Input language code' }, { name: 'prompt', valueName: '<text>', description: 'Transcript prompt' },
|
|
126
|
+
{ name: 'response-format', valueName: '<json|text|srt|verbose_json|vtt|diarized_json>', description: 'Transcript format', allowedValues: ['json', 'text', 'srt', 'verbose_json', 'vtt', 'diarized_json'] },
|
|
127
|
+
{ name: 'temperature', valueName: '<number>', description: 'Sampling temperature' }, { name: 'timestamp-granularities', valueName: '<word,segment>', description: 'Timestamp granularities' },
|
|
128
|
+
{ name: 'include', valueName: '<value[,value]>', description: 'Provider response fields' }, ...outputOptions,
|
|
129
|
+
], executor: 'media' }),
|
|
130
|
+
action({ id: 'audio.translate', path: ['audio', 'translate'], handlerPath: ['translate'], surfaces: ALL, summary: 'Translate an audio file', options: [
|
|
131
|
+
modelOverrideOption, { name: 'file', valueName: '<path>', description: 'Local audio file', required: true },
|
|
132
|
+
{ name: 'prompt', valueName: '<text>', description: 'Translation prompt' },
|
|
133
|
+
{ name: 'response-format', valueName: '<json|text|srt|verbose_json|vtt>', description: 'Translation format', allowedValues: ['json', 'text', 'srt', 'verbose_json', 'vtt'] },
|
|
134
|
+
{ name: 'temperature', valueName: '<number>', description: 'Sampling temperature' }, ...outputOptions,
|
|
135
|
+
], executor: 'media' }),
|
|
136
|
+
action({ id: 'video.generate', path: ['video'], surfaces: ALL, summary: 'Create and retrieve a video artifact', arguments: [{ name: 'prompt', required: true, variadic: true }], options: [
|
|
137
|
+
modelOverrideOption, { name: 'parameters', valueName: '<json>', description: 'Provider video parameter object' }, { name: 'no-wait', description: 'Return the operation id without waiting' }, ...outputOptions,
|
|
138
|
+
], executor: 'media' }),
|
|
139
|
+
action({ id: 'video.status', path: ['video', 'status'], handlerPath: ['status'], surfaces: ALL, summary: 'Show a video operation status', arguments: [{ name: 'operation-id', required: true }], executor: 'media' }),
|
|
140
|
+
action({ id: 'video.download', path: ['video', 'download'], handlerPath: ['download'], surfaces: ALL, summary: 'Download a completed video artifact', arguments: [{ name: 'operation-id', required: true }], options: outputOptions, executor: 'media' }),
|
|
141
|
+
action({ id: 'exec.direct', path: ['exec'], surfaces: DIRECT, summary: 'Run a headless agent prompt', arguments: [{ name: 'prompt', required: true, variadic: true }], options: [{ name: 'image', valueName: '<path[,path]>', description: 'Image attachments' }, { name: 'json', description: 'Use JSON events' }, { name: 'jsonl', description: 'Use JSONL events' }], executor: 'exec', desktop: { exposed: false } }),
|
|
142
|
+
action({ id: 'exec.tui', path: ['exec'], surfaces: TUI, summary: 'Run an interactive agent prompt', arguments: [{ name: 'prompt', required: true, variadic: true }], executor: 'tui-prompt' }),
|
|
143
|
+
action({ id: 'agent.stdio', path: ['agent', 'stdio'], handlerPath: ['stdio'], surfaces: DIRECT, summary: 'Run the JSONL agent protocol', executor: 'agent', desktop: { exposed: false } }),
|
|
144
|
+
action({ id: 'agent.desktop', path: ['agent', 'desktop'], handlerPath: ['desktop'], surfaces: DIRECT, summary: 'Run the desktop application protocol', executor: 'agent', desktop: { exposed: false } }),
|
|
145
|
+
action({ id: 'agent.info', path: ['agent'], surfaces: TUI, summary: 'Explain the direct JSONL agent protocol', executor: 'tui-agent-info' }),
|
|
146
|
+
...['bash', 'zsh', 'powershell'].map((shell) => action({ id: `completions.${shell}`, path: ['completions', shell], handlerPath: [shell], surfaces: ALL, summary: `Print ${shell} completion definitions`, executor: 'completions', desktop: { exposed: false } })),
|
|
147
|
+
action({ id: 'completions.default', path: ['completions'], surfaces: ALL, summary: 'Print PowerShell completion definitions', executor: 'completions', defaultAction: true, hiddenFromHelp: true, desktop: { exposed: false } }),
|
|
148
|
+
action({ id: 'update.check.default', path: ['update'], handlerPath: ['check'], surfaces: ALL, summary: 'Check update policy', executor: 'update', defaultAction: true, hiddenFromHelp: true }),
|
|
149
|
+
action({ id: 'update.check', path: ['update', 'check'], handlerPath: ['check'], surfaces: ALL, summary: 'Check update policy', executor: 'update' }),
|
|
150
|
+
action({ id: 'tui.clear', path: ['clear'], surfaces: TUI, summary: 'Clear the current transcript view', executor: 'tui-clear' }),
|
|
151
|
+
action({ id: 'tui.stop', path: ['stop'], surfaces: TUI, summary: 'Stop the active response', executor: 'tui-stop' }),
|
|
152
|
+
action({ id: 'tui.context', path: ['context'], surfaces: TUI, summary: 'Show context usage and session composition', executor: 'tui-context' }),
|
|
153
|
+
action({ id: 'tui.details', path: ['details'], surfaces: TUI, summary: 'Toggle tool execution details', executor: 'tui-details' }),
|
|
154
|
+
action({ id: 'tui.exit', path: ['exit'], surfaces: TUI, summary: 'Exit the interactive session', executor: 'tui-exit' }),
|
|
155
|
+
action({ id: 'attachments.list.default', path: ['attachments'], surfaces: TUI, summary: 'List pending attachments', executor: 'tui-attachments', defaultAction: true, hiddenFromHelp: true }),
|
|
156
|
+
action({ id: 'attachments.list', path: ['attachments', 'list'], surfaces: TUI, summary: 'List pending attachments', executor: 'tui-attachments' }),
|
|
157
|
+
action({ id: 'attachments.paste', path: ['attachments', 'paste'], surfaces: TUI, summary: 'Add an image from the clipboard', executor: 'tui-attachments' }),
|
|
158
|
+
action({ id: 'attachments.remove', path: ['attachments', 'remove'], surfaces: TUI, summary: 'Remove a pending attachment', arguments: [{ name: 'id', required: true }], executor: 'tui-attachments' }),
|
|
159
|
+
];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type CommandSurface = 'direct' | 'tui';
|
|
2
|
+
export type CommandExecutorId = 'help' | 'version' | 'config' | 'auth' | 'tui-auth-login' | 'trust' | 'inspect' | 'hook' | 'model' | 'tui-model-select' | 'mcp' | 'plugin' | 'skill' | 'tui-skill-run' | 'session' | 'tui-session-resume' | 'tui-session-compact' | 'tui-session-rename' | 'goal' | 'tui-goal' | 'doctor' | 'chat' | 'exec' | 'media' | 'tui-prompt' | 'agent' | 'tui-agent-info' | 'completions' | 'update' | 'tui-clear' | 'tui-stop' | 'tui-context' | 'tui-details' | 'tui-attachments' | 'tui-exit';
|
|
3
|
+
export interface CommandArgumentSpec {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly required: boolean;
|
|
6
|
+
readonly variadic?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CommandOptionRequirement {
|
|
9
|
+
readonly option: string;
|
|
10
|
+
readonly values?: readonly string[];
|
|
11
|
+
readonly absent?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CommandOptionSpec {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly valueName?: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly required?: boolean;
|
|
18
|
+
readonly requiredOn?: readonly CommandSurface[];
|
|
19
|
+
readonly requiredWhen?: CommandOptionRequirement;
|
|
20
|
+
readonly allowedValues?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface CommandActionSpec {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
/** Tokens used to select this action on a supported surface. */
|
|
25
|
+
readonly path: readonly string[];
|
|
26
|
+
/** Tokens the existing application handler expects before parsed arguments. */
|
|
27
|
+
readonly handlerPath?: readonly string[];
|
|
28
|
+
readonly surfaces: readonly CommandSurface[];
|
|
29
|
+
readonly summary: string;
|
|
30
|
+
readonly arguments?: readonly CommandArgumentSpec[];
|
|
31
|
+
readonly options?: readonly CommandOptionSpec[];
|
|
32
|
+
readonly executor: CommandExecutorId;
|
|
33
|
+
/**
|
|
34
|
+
* Optional exposure policy for the Desktop JSONL protocol. Direct and TUI
|
|
35
|
+
* users continue to resolve commands from `surfaces`; this metadata only
|
|
36
|
+
* controls whether a command is safe and meaningful for a non-terminal
|
|
37
|
+
* Desktop client.
|
|
38
|
+
*/
|
|
39
|
+
readonly desktop?: {
|
|
40
|
+
readonly exposed?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** Default action for a command group, such as `mcp` → `mcp list`. */
|
|
43
|
+
readonly defaultAction?: boolean;
|
|
44
|
+
/** Default routes are executable but excluded from command lists. */
|
|
45
|
+
readonly hiddenFromHelp?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface CommandInvocation {
|
|
48
|
+
readonly surface: CommandSurface;
|
|
49
|
+
readonly action: CommandActionSpec;
|
|
50
|
+
readonly positionals: readonly string[];
|
|
51
|
+
readonly options: ReadonlyMap<string, string | boolean>;
|
|
52
|
+
readonly handlerPositionals: readonly string[];
|
|
53
|
+
}
|
|
54
|
+
export interface CommandSuggestion {
|
|
55
|
+
readonly value: string;
|
|
56
|
+
readonly label: string;
|
|
57
|
+
readonly description: string;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CliError } from '../../domain/errors/cli-error.js';
|
|
2
|
+
import type { CliCommandHint } from '../../domain/errors/cli-command-hint.js';
|
|
3
|
+
export type CommandSurface = 'tui' | 'direct';
|
|
4
|
+
export declare function commandHint(actionId: string, tuiActionId?: string): CliCommandHint;
|
|
5
|
+
export declare const AUTH_LOGIN_HINT: CliCommandHint;
|
|
6
|
+
export declare const MODEL_SELECT_HINT: CliCommandHint;
|
|
7
|
+
export declare const TRUST_GRANT_HINT: CliCommandHint;
|
|
8
|
+
export declare function formatCommandHint(hint: CliCommandHint, surface: CommandSurface): string;
|
|
9
|
+
export declare function formatCliErrorMessage(error: CliError, surface: CommandSurface): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { formatCommandUsage } from './command-presentation.js';
|
|
2
|
+
import { COMMAND_REGISTRY } from './command-runtime.js';
|
|
3
|
+
export function commandHint(actionId, tuiActionId) {
|
|
4
|
+
return tuiActionId === undefined ? { actionId } : { actionId, tuiActionId };
|
|
5
|
+
}
|
|
6
|
+
export const AUTH_LOGIN_HINT = commandHint('auth.login.direct', 'auth.login.tui');
|
|
7
|
+
export const MODEL_SELECT_HINT = commandHint('model.use');
|
|
8
|
+
export const TRUST_GRANT_HINT = commandHint('trust.grant');
|
|
9
|
+
export function formatCommandHint(hint, surface) {
|
|
10
|
+
const action = COMMAND_REGISTRY.get(surface === 'tui' ? hint.tuiActionId ?? hint.actionId : hint.actionId);
|
|
11
|
+
if (action === undefined)
|
|
12
|
+
return 'Try the relevant command from the command help.';
|
|
13
|
+
return `Try \`${formatCommandUsage(action, surface)}\`.`;
|
|
14
|
+
}
|
|
15
|
+
export function formatCliErrorMessage(error, surface) {
|
|
16
|
+
return error.hint === undefined ? error.userMessage : `${error.userMessage} ${formatCommandHint(error.hint, surface)}`;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandInvocation, CommandSurface } from './command-contract.js';
|
|
2
|
+
import type { CommandRegistry } from './command-registry.js';
|
|
3
|
+
export declare function tokenizeCommandInput(value: string): readonly string[];
|
|
4
|
+
export declare function parseCommandInvocation(tokens: readonly string[], surface: CommandSurface, registry: CommandRegistry): CommandInvocation;
|
|
5
|
+
/**
|
|
6
|
+
* Validates an already selected action. Protocol callers use this when the
|
|
7
|
+
* action id and parsed values are transported separately from the command
|
|
8
|
+
* text, while direct and TUI callers continue to use token parsing above.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseCommandInvocationForAction(actionId: string, positionals: readonly string[], options: ReadonlyMap<string, string | boolean>, surface: CommandSurface, registry: CommandRegistry): CommandInvocation;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { CliError } from '../../domain/errors/cli-error.js';
|
|
2
|
+
import { CLI_ERROR_CODES } from '../../domain/errors/error-codes.js';
|
|
3
|
+
export function tokenizeCommandInput(value) {
|
|
4
|
+
const tokens = [];
|
|
5
|
+
let current = '';
|
|
6
|
+
let quote;
|
|
7
|
+
let escaping = false;
|
|
8
|
+
for (const character of value.trim()) {
|
|
9
|
+
if (escaping) {
|
|
10
|
+
current += character;
|
|
11
|
+
escaping = false;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (character === '\\') {
|
|
15
|
+
if (quote !== undefined)
|
|
16
|
+
escaping = true;
|
|
17
|
+
else
|
|
18
|
+
current += character;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (quote !== undefined) {
|
|
22
|
+
if (character === quote)
|
|
23
|
+
quote = undefined;
|
|
24
|
+
else
|
|
25
|
+
current += character;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (character === '"' || character === "'") {
|
|
29
|
+
quote = character;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (/\s/u.test(character)) {
|
|
33
|
+
if (current.length > 0) {
|
|
34
|
+
tokens.push(current);
|
|
35
|
+
current = '';
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
current += character;
|
|
40
|
+
}
|
|
41
|
+
if (escaping)
|
|
42
|
+
current += '\\';
|
|
43
|
+
if (current.length > 0)
|
|
44
|
+
tokens.push(current);
|
|
45
|
+
return tokens;
|
|
46
|
+
}
|
|
47
|
+
export function parseCommandInvocation(tokens, surface, registry) {
|
|
48
|
+
const action = registry.resolve(tokens, surface);
|
|
49
|
+
const remainder = tokens.slice(action.path.length);
|
|
50
|
+
const { positionals, options } = parseOptions(remainder, action);
|
|
51
|
+
return createInvocation(action, positionals, options, surface);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Validates an already selected action. Protocol callers use this when the
|
|
55
|
+
* action id and parsed values are transported separately from the command
|
|
56
|
+
* text, while direct and TUI callers continue to use token parsing above.
|
|
57
|
+
*/
|
|
58
|
+
export function parseCommandInvocationForAction(actionId, positionals, options, surface, registry) {
|
|
59
|
+
const action = registry.get(actionId);
|
|
60
|
+
if (action === undefined)
|
|
61
|
+
throw invalidArgument(`Unknown command action: ${actionId}.`);
|
|
62
|
+
if (!action.surfaces.includes(surface))
|
|
63
|
+
throw invalidArgument(`Command action ${actionId} is not available on the ${surface} surface.`);
|
|
64
|
+
return createInvocation(action, positionals, options, surface);
|
|
65
|
+
}
|
|
66
|
+
function createInvocation(action, positionals, options, surface) {
|
|
67
|
+
validateArguments(action, positionals);
|
|
68
|
+
validateOptions(action, options, surface);
|
|
69
|
+
return {
|
|
70
|
+
surface,
|
|
71
|
+
action,
|
|
72
|
+
positionals,
|
|
73
|
+
options,
|
|
74
|
+
handlerPositionals: [...(action.handlerPath ?? action.path.slice(1)), ...positionals],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function parseOptions(tokens, action) {
|
|
78
|
+
const positionals = [];
|
|
79
|
+
const options = new Map();
|
|
80
|
+
const definitions = new Map((action.options ?? []).map((option) => [option.name, option]));
|
|
81
|
+
let optionParsing = true;
|
|
82
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
83
|
+
const token = tokens[index];
|
|
84
|
+
if (optionParsing && token === '--') {
|
|
85
|
+
optionParsing = false;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!optionParsing || !token.startsWith('--') || token.length === 2) {
|
|
89
|
+
positionals.push(token);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const separator = token.indexOf('=');
|
|
93
|
+
const name = token.slice(2, separator < 0 ? undefined : separator);
|
|
94
|
+
const definition = definitions.get(name);
|
|
95
|
+
if (definition === undefined)
|
|
96
|
+
throw invalidArgument(`Unsupported option --${name} for ${action.path.join(' ')}.`);
|
|
97
|
+
if (options.has(name))
|
|
98
|
+
throw invalidArgument(`Option --${name} was provided more than once.`);
|
|
99
|
+
const inlineValue = separator < 0 ? undefined : token.slice(separator + 1);
|
|
100
|
+
if (definition.valueName === undefined) {
|
|
101
|
+
if (inlineValue !== undefined && inlineValue !== 'true')
|
|
102
|
+
throw invalidArgument(`Option --${name} does not accept a value.`);
|
|
103
|
+
options.set(name, inlineValue === undefined ? true : inlineValue);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const next = tokens[index + 1];
|
|
107
|
+
const value = inlineValue ?? (next === undefined || next === '--' || next.startsWith('--') ? undefined : next);
|
|
108
|
+
if (value === undefined || value.trim().length === 0)
|
|
109
|
+
throw missingArgument(`Missing value for --${name}.`);
|
|
110
|
+
if (inlineValue === undefined)
|
|
111
|
+
index += 1;
|
|
112
|
+
options.set(name, value);
|
|
113
|
+
}
|
|
114
|
+
return { positionals, options };
|
|
115
|
+
}
|
|
116
|
+
function validateArguments(action, positionals) {
|
|
117
|
+
const definitions = action.arguments ?? [];
|
|
118
|
+
const required = definitions.filter((argument) => argument.required).length;
|
|
119
|
+
if (positionals.length < required) {
|
|
120
|
+
const missing = definitions[positionals.length];
|
|
121
|
+
throw missingArgument(`Missing required argument: ${missing?.name ?? 'value'}.`);
|
|
122
|
+
}
|
|
123
|
+
const variadic = definitions.at(-1)?.variadic === true;
|
|
124
|
+
if (!variadic && positionals.length > definitions.length)
|
|
125
|
+
throw invalidArgument(`Too many arguments for ${action.path.join(' ')}.`);
|
|
126
|
+
}
|
|
127
|
+
function validateOptions(action, options, surface) {
|
|
128
|
+
const definitions = new Map((action.options ?? []).map((option) => [option.name, option]));
|
|
129
|
+
for (const name of options.keys()) {
|
|
130
|
+
if (!definitions.has(name))
|
|
131
|
+
throw invalidArgument(`Unsupported option --${name} for ${action.path.join(' ')}.`);
|
|
132
|
+
}
|
|
133
|
+
for (const definition of action.options ?? []) {
|
|
134
|
+
const requiredForSurface = definition.required === true || definition.requiredOn?.includes(surface) === true;
|
|
135
|
+
const conditionMatches = definition.requiredWhen === undefined ? false : matchesCondition(definition.requiredWhen, options);
|
|
136
|
+
if ((requiredForSurface || conditionMatches) && !options.has(definition.name))
|
|
137
|
+
throw missingArgument(`Missing required option --${definition.name}.`);
|
|
138
|
+
const value = options.get(definition.name);
|
|
139
|
+
if (definition.allowedValues !== undefined && typeof value === 'string' && !definition.allowedValues.includes(value)) {
|
|
140
|
+
throw invalidArgument(`Invalid value for --${definition.name}. Expected one of: ${definition.allowedValues.join(', ')}.`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function matchesCondition(condition, options) {
|
|
145
|
+
const value = options.get(condition.option);
|
|
146
|
+
const absentMatches = condition.absent === true && value === undefined;
|
|
147
|
+
const valueMatches = condition.values === undefined ? value !== undefined : typeof value === 'string' && condition.values.includes(value);
|
|
148
|
+
return absentMatches || valueMatches;
|
|
149
|
+
}
|
|
150
|
+
function missingArgument(userMessage) {
|
|
151
|
+
return new CliError(CLI_ERROR_CODES.MISSING_ARGUMENT, userMessage, { category: 'arguments', userMessage });
|
|
152
|
+
}
|
|
153
|
+
function invalidArgument(userMessage) {
|
|
154
|
+
return new CliError(CLI_ERROR_CODES.INVALID_ARGUMENT, userMessage, { category: 'arguments', userMessage });
|
|
155
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandActionSpec, CommandSuggestion, CommandSurface } from './command-contract.js';
|
|
2
|
+
import type { CommandRegistry } from './command-registry.js';
|
|
3
|
+
export declare function formatCommandReference(action: CommandActionSpec, surface: CommandSurface): string;
|
|
4
|
+
export declare function formatCommandUsage(action: CommandActionSpec, surface: CommandSurface): string;
|
|
5
|
+
export declare function formatCommandInvocation(action: CommandActionSpec, surface: CommandSurface, positionals?: readonly string[], options?: ReadonlyMap<string, string | boolean>): string;
|
|
6
|
+
export declare function formatCommandHelp(registry: CommandRegistry, surface: CommandSurface): string;
|
|
7
|
+
export declare function commandSuggestions(input: string, registry: CommandRegistry, surface: CommandSurface): readonly CommandSuggestion[];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { tokenizeCommandInput } from './command-parser.js';
|
|
2
|
+
export function formatCommandReference(action, surface) {
|
|
3
|
+
return `${surface === 'direct' ? 'lotagate ' : '/'}${action.path.join(' ')}`;
|
|
4
|
+
}
|
|
5
|
+
export function formatCommandUsage(action, surface) {
|
|
6
|
+
const argumentTokens = formatArgumentTokens(action);
|
|
7
|
+
const optionTokens = (action.options ?? []).map((option) => {
|
|
8
|
+
const value = option.valueName === undefined ? `--${option.name}` : `--${option.name} ${option.valueName}`;
|
|
9
|
+
return isOptionRequired(option, surface) ? value : `[${value}]`;
|
|
10
|
+
});
|
|
11
|
+
return [formatCommandReference(action, surface), ...argumentTokens, ...optionTokens].join(' ');
|
|
12
|
+
}
|
|
13
|
+
export function formatCommandInvocation(action, surface, positionals = [], options = new Map()) {
|
|
14
|
+
const optionTokens = [...options.entries()].flatMap(([name, value]) => value === true ? [`--${name}`] : [`--${name}`, value]);
|
|
15
|
+
return [formatCommandReference(action, surface), ...positionals, ...optionTokens].join(' ');
|
|
16
|
+
}
|
|
17
|
+
export function formatCommandHelp(registry, surface) {
|
|
18
|
+
const rows = registry.list(surface)
|
|
19
|
+
.map((action) => ({ usage: formatCommandUsage(action, surface), summary: action.summary }));
|
|
20
|
+
const width = Math.max(...rows.map((row) => row.usage.length), 0);
|
|
21
|
+
const header = surface === 'direct' ? 'LotaGate CLI commands:' : 'Interactive commands:';
|
|
22
|
+
return `${header}\n${rows.map((row) => ` ${row.usage.padEnd(width)} ${row.summary}`).join('\n')}`;
|
|
23
|
+
}
|
|
24
|
+
export function commandSuggestions(input, registry, surface) {
|
|
25
|
+
const prefix = surface === 'tui' ? '/' : '';
|
|
26
|
+
const source = surface === 'tui' ? input.trimStart().slice(1) : input.trimStart();
|
|
27
|
+
const trailingSpace = /\s$/u.test(source);
|
|
28
|
+
const tokens = tokenizeCommandInput(source);
|
|
29
|
+
if (tokens.length === 0)
|
|
30
|
+
return rootSuggestions(prefix, registry, surface, '');
|
|
31
|
+
if (tokens.length === 1 && !trailingSpace)
|
|
32
|
+
return rootSuggestions(prefix, registry, surface, tokens[0]);
|
|
33
|
+
const root = tokens[0].toLowerCase();
|
|
34
|
+
const allRootActions = registry.actionsForRoot(root, surface);
|
|
35
|
+
const rootActions = allRootActions.filter((action) => !action.hiddenFromHelp);
|
|
36
|
+
if (allRootActions.length === 0)
|
|
37
|
+
return [];
|
|
38
|
+
const currentSubcommand = trailingSpace ? '' : tokens[1] ?? '';
|
|
39
|
+
if (tokens.length <= 2) {
|
|
40
|
+
const defaultAction = findDefaultRootAction(allRootActions);
|
|
41
|
+
const exactSubcommand = tokens.length === 2 && rootActions.some((action) => action.path.length === 2 && action.path[1] === tokens[1]?.toLowerCase());
|
|
42
|
+
const partialSubcommand = !trailingSpace && tokens.length === 2 && rootActions.some((action) => action.path.length === 2 && action.path[1].startsWith(currentSubcommand.toLowerCase()));
|
|
43
|
+
if (tokens.length === 1 || (trailingSpace && tokens.length === 1) || exactSubcommand || partialSubcommand) {
|
|
44
|
+
if (!exactSubcommand)
|
|
45
|
+
return subcommandSuggestions(prefix, root, currentSubcommand, registry, surface);
|
|
46
|
+
}
|
|
47
|
+
else if (defaultAction !== undefined)
|
|
48
|
+
return optionSuggestions(input, defaultAction, surface, tokens);
|
|
49
|
+
else
|
|
50
|
+
return subcommandSuggestions(prefix, root, currentSubcommand, registry, surface);
|
|
51
|
+
}
|
|
52
|
+
const action = resolveSuggestionAction(tokens, registry, surface);
|
|
53
|
+
if (action === undefined)
|
|
54
|
+
return subcommandSuggestions(prefix, root, currentSubcommand, registry, surface);
|
|
55
|
+
if (!trailingSpace && tokens.length === action.path.length)
|
|
56
|
+
return [toCommandSuggestion(action, surface)];
|
|
57
|
+
return optionSuggestions(input, action, surface, tokens);
|
|
58
|
+
}
|
|
59
|
+
function rootSuggestions(prefix, registry, surface, query) {
|
|
60
|
+
const roots = new Map();
|
|
61
|
+
for (const action of registry.list(surface))
|
|
62
|
+
if (!roots.has(action.path[0]))
|
|
63
|
+
roots.set(action.path[0], action);
|
|
64
|
+
return [...roots.entries()]
|
|
65
|
+
.filter(([name]) => name.startsWith(query.toLowerCase()))
|
|
66
|
+
.map(([name, action]) => ({ value: `${prefix}${name}`, label: `${prefix}${name}`, description: action.summary }));
|
|
67
|
+
}
|
|
68
|
+
function subcommandSuggestions(prefix, root, query, registry, surface) {
|
|
69
|
+
const choices = new Map();
|
|
70
|
+
const actions = registry.actionsForRoot(root, surface);
|
|
71
|
+
for (const action of actions) {
|
|
72
|
+
if (action.hiddenFromHelp || action.path.length < 2)
|
|
73
|
+
continue;
|
|
74
|
+
const subcommand = action.path[1];
|
|
75
|
+
if (!subcommand.startsWith(query.toLowerCase()) || choices.has(subcommand))
|
|
76
|
+
continue;
|
|
77
|
+
choices.set(subcommand, action);
|
|
78
|
+
}
|
|
79
|
+
const defaultAction = findDefaultRootAction(actions);
|
|
80
|
+
return [
|
|
81
|
+
...(defaultAction === undefined || !(defaultAction.arguments?.some((argument) => argument.required) ?? false) ? [] : [toCommandSuggestion(defaultAction, surface, prefix)]),
|
|
82
|
+
...[...choices.values()].map((action) => toCommandSuggestion(action, surface, prefix)),
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
function findDefaultRootAction(actions) {
|
|
86
|
+
return actions.find((action) => action.defaultAction === true && action.path.length === 1)
|
|
87
|
+
?? actions.find((action) => action.path.length === 1 && !action.hiddenFromHelp);
|
|
88
|
+
}
|
|
89
|
+
function optionSuggestions(input, action, surface, tokens) {
|
|
90
|
+
const prefix = surface === 'tui' ? '/' : '';
|
|
91
|
+
const used = new Set(tokens.filter((token) => token.startsWith('--')).map((token) => token.slice(2).split('=')[0]));
|
|
92
|
+
const source = surface === 'tui' ? input.trimStart().slice(1) : input.trimStart();
|
|
93
|
+
const trailingSpace = /\s$/u.test(source);
|
|
94
|
+
const current = trailingSpace ? '' : tokens.at(-1) ?? '';
|
|
95
|
+
if (!current.startsWith('--'))
|
|
96
|
+
return [];
|
|
97
|
+
const replacementBase = trailingSpace ? source.trimEnd() : source.slice(0, Math.max(0, source.lastIndexOf(' '))).trimEnd();
|
|
98
|
+
return (action.options ?? [])
|
|
99
|
+
.filter((option) => !used.has(option.name) && `--${option.name}`.startsWith(current))
|
|
100
|
+
.map((option) => {
|
|
101
|
+
const token = `--${option.name}`;
|
|
102
|
+
const value = `${prefix}${replacementBase}${replacementBase.length === 0 ? '' : ' '}${token}`;
|
|
103
|
+
const label = option.valueName === undefined ? token : `${token} ${option.valueName}`;
|
|
104
|
+
return { value, label: isOptionRequired(option, surface) ? label : `[${label}]`, description: option.description };
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function resolveSuggestionAction(tokens, registry, surface) {
|
|
108
|
+
try {
|
|
109
|
+
return registry.resolve(tokens, surface);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function toCommandSuggestion(action, surface, prefix) {
|
|
116
|
+
const value = prefix === undefined ? formatCommandReference(action, surface) : `${prefix}${action.path.join(' ')}`;
|
|
117
|
+
const label = formatCommandSuggestion(action, surface);
|
|
118
|
+
return { value, label, description: action.summary };
|
|
119
|
+
}
|
|
120
|
+
function formatCommandSuggestion(action, surface) {
|
|
121
|
+
return [formatCommandReference(action, surface), ...formatArgumentTokens(action)].join(' ');
|
|
122
|
+
}
|
|
123
|
+
function formatArgumentTokens(action) {
|
|
124
|
+
return (action.arguments ?? []).map((argument) => {
|
|
125
|
+
const value = argument.variadic ? `${argument.name}...` : argument.name;
|
|
126
|
+
return argument.required ? `<${value}>` : `[${value}]`;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function isOptionRequired(option, surface) {
|
|
130
|
+
return option.required === true || option.requiredOn?.includes(surface) === true;
|
|
131
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandActionSpec, CommandSurface } from './command-contract.js';
|
|
2
|
+
export declare class CommandRegistry {
|
|
3
|
+
private readonly actions;
|
|
4
|
+
private readonly byId;
|
|
5
|
+
constructor(actions: readonly CommandActionSpec[]);
|
|
6
|
+
get(id: string): CommandActionSpec | undefined;
|
|
7
|
+
list(surface: CommandSurface, includeHidden?: boolean): readonly CommandActionSpec[];
|
|
8
|
+
actionsForRoot(root: string, surface: CommandSurface): readonly CommandActionSpec[];
|
|
9
|
+
resolve(tokens: readonly string[], surface: CommandSurface): CommandActionSpec;
|
|
10
|
+
private assertNoSurfaceCollisions;
|
|
11
|
+
}
|