byterover-cli 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -63
- package/bin/dev.js +8 -1
- package/bin/run.js +7 -0
- package/dist/commands/cipher-agent/run.d.ts +30 -0
- package/dist/commands/cipher-agent/run.js +123 -61
- package/dist/commands/cipher-agent/set-prompt.d.ts +2 -0
- package/dist/commands/cipher-agent/set-prompt.js +13 -8
- package/dist/commands/cipher-agent/show-prompt.d.ts +2 -0
- package/dist/commands/cipher-agent/show-prompt.js +17 -12
- package/dist/commands/curate.d.ts +3 -60
- package/dist/commands/curate.js +45 -341
- package/dist/commands/foo.d.ts +4 -2
- package/dist/commands/foo.js +21 -16
- package/dist/commands/main.d.ts +9 -0
- package/dist/commands/main.js +34 -0
- package/dist/commands/query.d.ts +2 -48
- package/dist/commands/query.js +19 -287
- package/dist/commands/status.d.ts +2 -13
- package/dist/commands/status.js +12 -91
- package/dist/commands/watch.d.ts +2 -0
- package/dist/commands/watch.js +23 -19
- package/dist/config/environment.d.ts +1 -1
- package/dist/config/environment.js +2 -2
- package/dist/constants.d.ts +4 -5
- package/dist/constants.js +5 -5
- package/dist/core/domain/cipher/errors/storage-error.d.ts +89 -0
- package/dist/core/domain/cipher/errors/storage-error.js +130 -0
- package/dist/core/domain/cipher/queue/types.d.ts +71 -0
- package/dist/core/domain/cipher/queue/types.js +9 -0
- package/dist/core/domain/cipher/storage/message-storage-types.d.ts +218 -0
- package/dist/core/domain/cipher/storage/message-storage-types.js +18 -0
- package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
- package/dist/core/domain/cipher/tools/constants.js +1 -0
- package/dist/core/domain/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +5 -0
- package/dist/core/domain/entities/global-config.d.ts +36 -0
- package/dist/core/domain/entities/global-config.js +66 -0
- package/dist/core/domain/knowledge/directory-manager.d.ts +10 -0
- package/dist/core/domain/knowledge/directory-manager.js +18 -0
- package/dist/core/domain/knowledge/markdown-writer.d.ts +9 -0
- package/dist/core/domain/knowledge/markdown-writer.js +51 -1
- package/dist/core/interfaces/cipher/i-agent-storage.d.ts +152 -0
- package/dist/core/interfaces/cipher/i-agent-storage.js +1 -0
- package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +2 -0
- package/dist/core/interfaces/cipher/i-key-storage.d.ts +91 -0
- package/dist/core/interfaces/cipher/i-key-storage.js +1 -0
- package/dist/core/interfaces/i-global-config-store.d.ts +34 -0
- package/dist/core/interfaces/i-global-config-store.js +1 -0
- package/dist/core/interfaces/i-onboarding-preference-store.d.ts +20 -0
- package/dist/core/interfaces/i-onboarding-preference-store.js +1 -0
- package/dist/core/interfaces/i-terminal.d.ts +146 -0
- package/dist/core/interfaces/i-terminal.js +1 -0
- package/dist/core/interfaces/i-workspace-detector-service.d.ts +8 -0
- package/dist/core/interfaces/i-workspace-detector-service.js +1 -0
- package/dist/core/interfaces/usecase/i-clear-use-case.d.ts +6 -0
- package/dist/core/interfaces/usecase/i-clear-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-curate-use-case.d.ts +10 -0
- package/dist/core/interfaces/usecase/i-curate-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-init-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-init-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-login-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-login-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-logout-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-logout-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-pull-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-pull-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-push-use-case.d.ts +6 -0
- package/dist/core/interfaces/usecase/i-push-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-query-use-case.d.ts +9 -0
- package/dist/core/interfaces/usecase/i-query-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-space-list-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-space-list-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-space-switch-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-space-switch-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-status-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-status-use-case.js +1 -0
- package/dist/hooks/init/update-notifier.js +1 -5
- package/dist/hooks/init/welcome.js +1 -2
- package/dist/infra/cipher/agent-service-factory.d.ts +13 -6
- package/dist/infra/cipher/agent-service-factory.js +40 -16
- package/dist/infra/cipher/cipher-agent.js +4 -4
- package/dist/infra/cipher/consumer/consumer-lock.d.ts +20 -0
- package/dist/infra/cipher/consumer/consumer-lock.js +40 -0
- package/dist/infra/cipher/consumer/consumer-service.d.ts +99 -0
- package/dist/infra/cipher/consumer/consumer-service.js +165 -0
- package/dist/infra/cipher/consumer/execution-consumer.d.ts +121 -0
- package/dist/infra/cipher/consumer/execution-consumer.js +523 -0
- package/dist/infra/cipher/consumer/index.d.ts +33 -0
- package/dist/infra/cipher/consumer/index.js +33 -0
- package/dist/infra/cipher/consumer/queue-polling-service.d.ts +120 -0
- package/dist/infra/cipher/consumer/queue-polling-service.js +248 -0
- package/dist/infra/cipher/http/internal-llm-http-service.d.ts +94 -0
- package/dist/infra/cipher/http/internal-llm-http-service.js +118 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +106 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.js +132 -0
- package/dist/infra/cipher/llm/context/compaction/index.d.ts +9 -0
- package/dist/infra/cipher/llm/context/compaction/index.js +9 -0
- package/dist/infra/cipher/llm/context/context-manager.d.ts +46 -2
- package/dist/infra/cipher/llm/context/context-manager.js +68 -4
- package/dist/infra/cipher/llm/context/rw-lock.d.ts +72 -0
- package/dist/infra/cipher/llm/context/rw-lock.js +145 -0
- package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +7 -7
- package/dist/infra/cipher/llm/generators/byterover-content-generator.js +8 -8
- package/dist/infra/cipher/llm/internal-llm-service.js +2 -0
- package/dist/infra/cipher/session/session-manager.d.ts +4 -4
- package/dist/infra/cipher/session/session-manager.js +5 -5
- package/dist/infra/cipher/storage/agent-storage.d.ts +246 -0
- package/dist/infra/cipher/storage/agent-storage.js +956 -0
- package/dist/infra/cipher/storage/dual-format-history-storage.d.ts +77 -0
- package/dist/infra/cipher/storage/dual-format-history-storage.js +149 -0
- package/dist/infra/cipher/storage/granular-history-storage.d.ts +65 -0
- package/dist/infra/cipher/storage/granular-history-storage.js +118 -0
- package/dist/infra/cipher/storage/message-storage-service.d.ts +108 -0
- package/dist/infra/cipher/storage/message-storage-service.js +529 -0
- package/dist/infra/cipher/storage/process-utils.d.ts +16 -0
- package/dist/infra/cipher/storage/process-utils.js +43 -0
- package/dist/infra/cipher/storage/sqlite-key-storage.d.ts +105 -0
- package/dist/infra/cipher/storage/sqlite-key-storage.js +404 -0
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +1 -0
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +7 -0
- package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
- package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +10 -0
- package/dist/infra/cipher/tools/implementations/curate-tool.js +371 -0
- package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +11 -8
- package/dist/infra/cipher/tools/tool-manager.d.ts +8 -2
- package/dist/infra/cipher/tools/tool-manager.js +29 -2
- package/dist/infra/cipher/tools/tool-registry.js +7 -0
- package/dist/infra/http/authenticated-http-client.d.ts +21 -0
- package/dist/infra/http/authenticated-http-client.js +38 -0
- package/dist/infra/repl/commands/arg-parser.d.ts +97 -0
- package/dist/infra/repl/commands/arg-parser.js +129 -0
- package/dist/infra/repl/commands/clear-command.d.ts +5 -0
- package/dist/infra/repl/commands/clear-command.js +61 -0
- package/dist/infra/repl/commands/curate-command.d.ts +9 -0
- package/dist/infra/repl/commands/curate-command.js +88 -0
- package/dist/infra/repl/commands/gen-rules-command.d.ts +7 -0
- package/dist/infra/repl/commands/gen-rules-command.js +38 -0
- package/dist/infra/repl/commands/index.d.ts +8 -0
- package/dist/infra/repl/commands/index.js +36 -0
- package/dist/infra/repl/commands/init-command.d.ts +7 -0
- package/dist/infra/repl/commands/init-command.js +83 -0
- package/dist/infra/repl/commands/login-command.d.ts +7 -0
- package/dist/infra/repl/commands/login-command.js +50 -0
- package/dist/infra/repl/commands/logout-command.d.ts +5 -0
- package/dist/infra/repl/commands/logout-command.js +48 -0
- package/dist/infra/repl/commands/pull-command.d.ts +5 -0
- package/dist/infra/repl/commands/pull-command.js +61 -0
- package/dist/infra/repl/commands/push-command.d.ts +5 -0
- package/dist/infra/repl/commands/push-command.js +66 -0
- package/dist/infra/repl/commands/query-command.d.ts +5 -0
- package/dist/infra/repl/commands/query-command.js +66 -0
- package/dist/infra/repl/commands/space/index.d.ts +5 -0
- package/dist/infra/repl/commands/space/index.js +14 -0
- package/dist/infra/repl/commands/space/list-command.d.ts +5 -0
- package/dist/infra/repl/commands/space/list-command.js +70 -0
- package/dist/infra/repl/commands/space/switch-command.d.ts +5 -0
- package/dist/infra/repl/commands/space/switch-command.js +37 -0
- package/dist/infra/repl/commands/status-command.d.ts +5 -0
- package/dist/infra/repl/commands/status-command.js +39 -0
- package/dist/infra/repl/repl-startup.d.ts +18 -0
- package/dist/infra/repl/repl-startup.js +26 -0
- package/dist/infra/storage/file-global-config-store.d.ts +22 -0
- package/dist/infra/storage/file-global-config-store.js +65 -0
- package/dist/infra/storage/file-onboarding-preference-store.d.ts +10 -0
- package/dist/infra/storage/file-onboarding-preference-store.js +46 -0
- package/dist/infra/terminal/oclif-terminal.d.ts +19 -0
- package/dist/infra/terminal/oclif-terminal.js +60 -0
- package/dist/infra/terminal/repl-terminal.d.ts +31 -0
- package/dist/infra/terminal/repl-terminal.js +116 -0
- package/dist/infra/tracking/mixpanel-tracking-service.d.ts +11 -1
- package/dist/infra/tracking/mixpanel-tracking-service.js +18 -13
- package/dist/infra/usecase/clear-use-case.d.ts +20 -0
- package/dist/infra/usecase/clear-use-case.js +58 -0
- package/dist/infra/usecase/curate-use-case.d.ts +66 -0
- package/dist/infra/usecase/curate-use-case.js +283 -0
- package/dist/{commands/gen-rules.d.ts → infra/usecase/generate-rules-use-case.d.ts} +14 -20
- package/dist/{commands/gen-rules.js → infra/usecase/generate-rules-use-case.js} +59 -78
- package/dist/infra/usecase/init-use-case.d.ts +139 -0
- package/dist/{commands/init.js → infra/usecase/init-use-case.js} +184 -230
- package/dist/infra/usecase/login-use-case.d.ts +28 -0
- package/dist/infra/usecase/login-use-case.js +88 -0
- package/dist/infra/usecase/logout-use-case.d.ts +22 -0
- package/dist/infra/usecase/logout-use-case.js +51 -0
- package/dist/infra/usecase/pull-use-case.d.ts +35 -0
- package/dist/infra/usecase/pull-use-case.js +89 -0
- package/dist/infra/usecase/push-use-case.d.ts +37 -0
- package/dist/infra/usecase/push-use-case.js +124 -0
- package/dist/infra/usecase/query-use-case.d.ts +78 -0
- package/dist/infra/usecase/query-use-case.js +401 -0
- package/dist/infra/usecase/space-list-use-case.d.ts +27 -0
- package/dist/infra/usecase/space-list-use-case.js +64 -0
- package/dist/infra/usecase/space-switch-use-case.d.ts +36 -0
- package/dist/infra/usecase/space-switch-use-case.js +140 -0
- package/dist/infra/usecase/status-use-case.d.ts +27 -0
- package/dist/infra/usecase/status-use-case.js +97 -0
- package/dist/infra/workspace/workspace-detector-service.d.ts +3 -6
- package/dist/resources/prompts/curate-context-tree-curation.yml +23 -11
- package/dist/resources/prompts/query-context-tree-retrieval.yml +3 -4
- package/dist/resources/prompts/system-prompt.yml +1 -1
- package/dist/resources/prompts/tool-outputs.yml +4 -3
- package/dist/templates/sections/command-reference.md +12 -0
- package/dist/templates/sections/workflow.md +10 -1
- package/dist/tui/app.d.ts +9 -0
- package/dist/tui/app.js +26 -0
- package/dist/tui/components/enter-prompt.d.ts +13 -0
- package/dist/tui/components/enter-prompt.js +15 -0
- package/dist/tui/components/execution/execution-changes.d.ts +14 -0
- package/dist/tui/components/execution/execution-changes.js +15 -0
- package/dist/tui/components/execution/execution-content.d.ts +25 -0
- package/dist/tui/components/execution/execution-content.js +67 -0
- package/dist/tui/components/execution/execution-input.d.ts +12 -0
- package/dist/tui/components/execution/execution-input.js +16 -0
- package/dist/tui/components/execution/execution-progress.d.ts +21 -0
- package/dist/tui/components/execution/execution-progress.js +21 -0
- package/dist/tui/components/execution/execution-status.d.ts +13 -0
- package/dist/tui/components/execution/execution-status.js +19 -0
- package/dist/tui/components/execution/index.d.ts +11 -0
- package/dist/tui/components/execution/index.js +11 -0
- package/dist/tui/components/execution/log-item.d.ts +17 -0
- package/dist/tui/components/execution/log-item.js +25 -0
- package/dist/tui/components/footer.d.ts +5 -0
- package/dist/tui/components/footer.js +12 -0
- package/dist/tui/components/header.d.ts +18 -0
- package/dist/tui/components/header.js +18 -0
- package/dist/tui/components/index.d.ts +17 -0
- package/dist/tui/components/index.js +14 -0
- package/dist/tui/components/inline-prompts/index.d.ts +15 -0
- package/dist/tui/components/inline-prompts/index.js +10 -0
- package/dist/tui/components/inline-prompts/inline-confirm.d.ts +17 -0
- package/dist/tui/components/inline-prompts/inline-confirm.js +32 -0
- package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +43 -0
- package/dist/tui/components/inline-prompts/inline-file-selector.js +185 -0
- package/dist/tui/components/inline-prompts/inline-input.d.ts +19 -0
- package/dist/tui/components/inline-prompts/inline-input.js +32 -0
- package/dist/tui/components/inline-prompts/inline-search.d.ts +20 -0
- package/dist/tui/components/inline-prompts/inline-search.js +50 -0
- package/dist/tui/components/inline-prompts/inline-select.d.ts +20 -0
- package/dist/tui/components/inline-prompts/inline-select.js +34 -0
- package/dist/tui/components/logo.d.ts +43 -0
- package/dist/tui/components/logo.js +103 -0
- package/dist/tui/components/message-item.d.ts +12 -0
- package/dist/tui/components/message-item.js +12 -0
- package/dist/tui/components/onboarding/copyable-prompt.d.ts +15 -0
- package/dist/tui/components/onboarding/copyable-prompt.js +65 -0
- package/dist/tui/components/onboarding/index.d.ts +7 -0
- package/dist/tui/components/onboarding/index.js +6 -0
- package/dist/tui/components/onboarding/onboarding-flow.d.ts +13 -0
- package/dist/tui/components/onboarding/onboarding-flow.js +304 -0
- package/dist/tui/components/onboarding/onboarding-step.d.ts +23 -0
- package/dist/tui/components/onboarding/onboarding-step.js +12 -0
- package/dist/tui/components/output-log.d.ts +14 -0
- package/dist/tui/components/output-log.js +13 -0
- package/dist/tui/components/scrollable-list.d.ts +30 -0
- package/dist/tui/components/scrollable-list.js +121 -0
- package/dist/tui/components/suggestions.d.ts +16 -0
- package/dist/tui/components/suggestions.js +162 -0
- package/dist/tui/components/tab-bar.d.ts +10 -0
- package/dist/tui/components/tab-bar.js +12 -0
- package/dist/tui/constants.d.ts +11 -0
- package/dist/tui/constants.js +13 -0
- package/dist/tui/contexts/auth-context.d.ts +30 -0
- package/dist/tui/contexts/auth-context.js +153 -0
- package/dist/tui/contexts/consumer.d.ts +31 -0
- package/dist/tui/contexts/consumer.js +56 -0
- package/dist/tui/contexts/index.d.ts +6 -0
- package/dist/tui/contexts/index.js +6 -0
- package/dist/tui/contexts/onboarding-context.d.ts +43 -0
- package/dist/tui/contexts/onboarding-context.js +181 -0
- package/dist/tui/contexts/services-context.d.ts +29 -0
- package/dist/tui/contexts/services-context.js +20 -0
- package/dist/tui/contexts/use-commands.d.ts +29 -0
- package/dist/tui/contexts/use-commands.js +53 -0
- package/dist/tui/contexts/use-mode.d.ts +43 -0
- package/dist/tui/contexts/use-mode.js +76 -0
- package/dist/tui/contexts/use-theme.d.ts +53 -0
- package/dist/tui/contexts/use-theme.js +60 -0
- package/dist/tui/hooks/index.d.ts +17 -0
- package/dist/tui/hooks/index.js +14 -0
- package/dist/tui/hooks/use-activity-logs.d.ts +26 -0
- package/dist/tui/hooks/use-activity-logs.js +90 -0
- package/dist/tui/hooks/use-consumer.d.ts +12 -0
- package/dist/tui/hooks/use-consumer.js +50 -0
- package/dist/tui/hooks/use-onboarding.d.ts +7 -0
- package/dist/tui/hooks/use-onboarding.js +6 -0
- package/dist/tui/hooks/use-queue-polling.d.ts +31 -0
- package/dist/tui/hooks/use-queue-polling.js +90 -0
- package/dist/tui/hooks/use-slash-command-processor.d.ts +16 -0
- package/dist/tui/hooks/use-slash-command-processor.js +132 -0
- package/dist/tui/hooks/use-slash-completion.d.ts +30 -0
- package/dist/tui/hooks/use-slash-completion.js +230 -0
- package/dist/tui/hooks/use-tab-navigation.d.ts +10 -0
- package/dist/tui/hooks/use-tab-navigation.js +35 -0
- package/dist/tui/hooks/use-visible-window.d.ts +22 -0
- package/dist/tui/hooks/use-visible-window.js +37 -0
- package/dist/tui/index.d.ts +1 -0
- package/dist/tui/index.js +1 -0
- package/dist/tui/providers/app-providers.d.ts +25 -0
- package/dist/tui/providers/app-providers.js +9 -0
- package/dist/tui/types/commands.d.ts +252 -0
- package/dist/tui/types/commands.js +16 -0
- package/dist/tui/types/dialogs.d.ts +37 -0
- package/dist/tui/types/dialogs.js +4 -0
- package/dist/tui/types/index.d.ts +11 -0
- package/dist/tui/types/index.js +7 -0
- package/dist/tui/types/messages.d.ts +55 -0
- package/dist/tui/types/messages.js +4 -0
- package/dist/tui/types/prompts.d.ts +100 -0
- package/dist/tui/types/prompts.js +4 -0
- package/dist/tui/types/ui.d.ts +14 -0
- package/dist/tui/types/ui.js +4 -0
- package/dist/tui/types.d.ts +1 -0
- package/dist/tui/types.js +1 -0
- package/dist/tui/views/command-view.d.ts +12 -0
- package/dist/tui/views/command-view.js +451 -0
- package/dist/tui/views/index.d.ts +6 -0
- package/dist/tui/views/index.js +6 -0
- package/dist/tui/views/login-view.d.ts +10 -0
- package/dist/tui/views/login-view.js +30 -0
- package/dist/tui/views/logs-view.d.ts +11 -0
- package/dist/tui/views/logs-view.js +73 -0
- package/dist/utils/file-validator.d.ts +16 -0
- package/dist/utils/file-validator.js +81 -0
- package/dist/utils/global-config-path.d.ts +15 -0
- package/dist/utils/global-config-path.js +38 -0
- package/oclif.manifest.json +29 -315
- package/package.json +11 -4
- package/dist/commands/clear.d.ts +0 -19
- package/dist/commands/clear.js +0 -78
- package/dist/commands/init.d.ts +0 -130
- package/dist/commands/login.d.ts +0 -22
- package/dist/commands/login.js +0 -108
- package/dist/commands/logout.d.ts +0 -16
- package/dist/commands/logout.js +0 -61
- package/dist/commands/pull.d.ts +0 -33
- package/dist/commands/pull.js +0 -115
- package/dist/commands/push.d.ts +0 -35
- package/dist/commands/push.js +0 -160
- package/dist/commands/space/list.d.ts +0 -25
- package/dist/commands/space/list.js +0 -114
- package/dist/commands/space/switch.d.ts +0 -36
- package/dist/commands/space/switch.js +0 -160
- package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +0 -149
- package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +0 -364
- package/dist/infra/cipher/grpc/internal-llm-grpc.proto +0 -94
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared argument parser for REPL commands
|
|
3
|
+
*
|
|
4
|
+
* Combines shell-like string splitting with oclif's Parser for consistent
|
|
5
|
+
* flag and argument handling across REPL commands.
|
|
6
|
+
*/
|
|
7
|
+
import { type Interfaces } from '@oclif/core';
|
|
8
|
+
import type { CommandFlag } from '../../../tui/types.js';
|
|
9
|
+
export { Args, Flags } from '@oclif/core';
|
|
10
|
+
type ArgInput = Interfaces.ArgInput;
|
|
11
|
+
type FlagInput = Interfaces.FlagInput;
|
|
12
|
+
/**
|
|
13
|
+
* Convert oclif flag definitions to CommandFlag[] for SlashCommand.flags
|
|
14
|
+
*
|
|
15
|
+
* This allows defining flags once using oclif format and auto-generating
|
|
16
|
+
* the CommandFlag[] needed for help display.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const flags = {
|
|
20
|
+
* apiKey: Flags.string({char: 'k', description: 'API key'}),
|
|
21
|
+
* verbose: Flags.boolean({char: 'v', description: 'Verbose output'}),
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* export const myCommand: SlashCommand = {
|
|
25
|
+
* action(context, args) {
|
|
26
|
+
* const parsed = await parseReplArgs(args, {flags})
|
|
27
|
+
* },
|
|
28
|
+
* flags: toCommandFlags(flags),
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
export declare function toCommandFlags(flags: FlagInput): CommandFlag[];
|
|
32
|
+
/**
|
|
33
|
+
* Result from splitArgs with file references
|
|
34
|
+
*/
|
|
35
|
+
export interface SplitArgsResult {
|
|
36
|
+
/** Regular arguments */
|
|
37
|
+
args: string[];
|
|
38
|
+
/** File references (tokens starting with @) */
|
|
39
|
+
files: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Split a string into args array, respecting quoted strings
|
|
43
|
+
* Handles both single and double quotes, and extracts @file references
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* splitArgs('"hello world" --force') // { args: ['hello world', '--force'], files: [] }
|
|
47
|
+
* splitArgs("'hello world' -f") // { args: ['hello world', '-f'], files: [] }
|
|
48
|
+
* splitArgs('query @src/file.ts') // { args: ['query'], files: ['src/file.ts'] }
|
|
49
|
+
* splitArgs('"context" @src/a.ts @src/b.ts') // { args: ['context'], files: ['src/a.ts', 'src/b.ts'] }
|
|
50
|
+
*/
|
|
51
|
+
export declare function splitArgs(input: string): SplitArgsResult;
|
|
52
|
+
/**
|
|
53
|
+
* Parse result from parseReplArgs
|
|
54
|
+
*/
|
|
55
|
+
export interface ParsedReplArgs<TFlags extends FlagInput, TArgs extends ArgInput> {
|
|
56
|
+
/** Parsed arguments */
|
|
57
|
+
args: {
|
|
58
|
+
[K in keyof TArgs]: TArgs[K] extends {
|
|
59
|
+
required: true;
|
|
60
|
+
} ? string : string | undefined;
|
|
61
|
+
};
|
|
62
|
+
/** Remaining unparsed arguments (when strict: false) */
|
|
63
|
+
argv: string[];
|
|
64
|
+
/** File references extracted from @filepath tokens */
|
|
65
|
+
files: string[];
|
|
66
|
+
/** Parsed flags */
|
|
67
|
+
flags: {
|
|
68
|
+
[K in keyof TFlags]: TFlags[K] extends {
|
|
69
|
+
type: 'boolean';
|
|
70
|
+
} ? boolean : string | undefined;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parse REPL command arguments using oclif's Parser
|
|
75
|
+
*
|
|
76
|
+
* @param input - Raw input string from REPL (e.g., '"hello world" --force @src/file.ts')
|
|
77
|
+
* @param options - Parser options
|
|
78
|
+
* @param options.args - Argument definitions using Args from @oclif/core
|
|
79
|
+
* @param options.flags - Flag definitions using Flags from @oclif/core
|
|
80
|
+
* @param options.strict - Whether to error on unknown flags (default: false)
|
|
81
|
+
* @returns Parsed flags, args, remaining argv, and file references
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const result = await parseReplArgs('query text --verbose @src/auth.ts', {
|
|
85
|
+
* args: { query: Args.string({ required: true }) },
|
|
86
|
+
* flags: { verbose: Flags.boolean({ char: 'v' }) },
|
|
87
|
+
* })
|
|
88
|
+
* // result.args.query === 'query'
|
|
89
|
+
* // result.flags.verbose === true
|
|
90
|
+
* // result.argv === ['query', 'text']
|
|
91
|
+
* // result.files === ['src/auth.ts']
|
|
92
|
+
*/
|
|
93
|
+
export declare function parseReplArgs<TFlags extends FlagInput, TArgs extends ArgInput>(input: string, options: {
|
|
94
|
+
args?: TArgs;
|
|
95
|
+
flags?: TFlags;
|
|
96
|
+
strict?: boolean;
|
|
97
|
+
}): Promise<ParsedReplArgs<TFlags, TArgs>>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared argument parser for REPL commands
|
|
3
|
+
*
|
|
4
|
+
* Combines shell-like string splitting with oclif's Parser for consistent
|
|
5
|
+
* flag and argument handling across REPL commands.
|
|
6
|
+
*/
|
|
7
|
+
import { Parser } from '@oclif/core';
|
|
8
|
+
// Re-export Args and Flags for use by REPL commands
|
|
9
|
+
export { Args, Flags } from '@oclif/core';
|
|
10
|
+
/**
|
|
11
|
+
* Convert oclif flag definitions to CommandFlag[] for SlashCommand.flags
|
|
12
|
+
*
|
|
13
|
+
* This allows defining flags once using oclif format and auto-generating
|
|
14
|
+
* the CommandFlag[] needed for help display.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const flags = {
|
|
18
|
+
* apiKey: Flags.string({char: 'k', description: 'API key'}),
|
|
19
|
+
* verbose: Flags.boolean({char: 'v', description: 'Verbose output'}),
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* export const myCommand: SlashCommand = {
|
|
23
|
+
* action(context, args) {
|
|
24
|
+
* const parsed = await parseReplArgs(args, {flags})
|
|
25
|
+
* },
|
|
26
|
+
* flags: toCommandFlags(flags),
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export function toCommandFlags(flags) {
|
|
30
|
+
return Object.entries(flags).map(([name, flag]) => ({
|
|
31
|
+
char: flag.char,
|
|
32
|
+
default: flag.default,
|
|
33
|
+
description: flag.description ?? '',
|
|
34
|
+
name,
|
|
35
|
+
type: flag.type === 'boolean' ? 'boolean' : 'string',
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Split a string into args array, respecting quoted strings
|
|
40
|
+
* Handles both single and double quotes, and extracts @file references
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* splitArgs('"hello world" --force') // { args: ['hello world', '--force'], files: [] }
|
|
44
|
+
* splitArgs("'hello world' -f") // { args: ['hello world', '-f'], files: [] }
|
|
45
|
+
* splitArgs('query @src/file.ts') // { args: ['query'], files: ['src/file.ts'] }
|
|
46
|
+
* splitArgs('"context" @src/a.ts @src/b.ts') // { args: ['context'], files: ['src/a.ts', 'src/b.ts'] }
|
|
47
|
+
*/
|
|
48
|
+
export function splitArgs(input) {
|
|
49
|
+
const args = [];
|
|
50
|
+
const files = [];
|
|
51
|
+
let current = '';
|
|
52
|
+
let inQuote = null;
|
|
53
|
+
for (const char of input) {
|
|
54
|
+
if (inQuote) {
|
|
55
|
+
// Inside a quoted string
|
|
56
|
+
if (char === inQuote) {
|
|
57
|
+
// End of quoted string - don't include the quote
|
|
58
|
+
inQuote = null;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
current += char;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (char === '"' || char === "'") {
|
|
65
|
+
// Start of quoted string - don't include the quote
|
|
66
|
+
inQuote = char;
|
|
67
|
+
}
|
|
68
|
+
else if (char === ' ' || char === '\t') {
|
|
69
|
+
// Whitespace outside quotes - end current arg
|
|
70
|
+
if (current) {
|
|
71
|
+
if (current.startsWith('@')) {
|
|
72
|
+
// File reference - strip the @ prefix
|
|
73
|
+
files.push(current.slice(1));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
args.push(current);
|
|
77
|
+
}
|
|
78
|
+
current = '';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
current += char;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Don't forget the last arg
|
|
86
|
+
if (current) {
|
|
87
|
+
if (current.startsWith('@')) {
|
|
88
|
+
files.push(current.slice(1));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
args.push(current);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { args, files };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parse REPL command arguments using oclif's Parser
|
|
98
|
+
*
|
|
99
|
+
* @param input - Raw input string from REPL (e.g., '"hello world" --force @src/file.ts')
|
|
100
|
+
* @param options - Parser options
|
|
101
|
+
* @param options.args - Argument definitions using Args from @oclif/core
|
|
102
|
+
* @param options.flags - Flag definitions using Flags from @oclif/core
|
|
103
|
+
* @param options.strict - Whether to error on unknown flags (default: false)
|
|
104
|
+
* @returns Parsed flags, args, remaining argv, and file references
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const result = await parseReplArgs('query text --verbose @src/auth.ts', {
|
|
108
|
+
* args: { query: Args.string({ required: true }) },
|
|
109
|
+
* flags: { verbose: Flags.boolean({ char: 'v' }) },
|
|
110
|
+
* })
|
|
111
|
+
* // result.args.query === 'query'
|
|
112
|
+
* // result.flags.verbose === true
|
|
113
|
+
* // result.argv === ['query', 'text']
|
|
114
|
+
* // result.files === ['src/auth.ts']
|
|
115
|
+
*/
|
|
116
|
+
export async function parseReplArgs(input, options) {
|
|
117
|
+
const { args: argv, files } = splitArgs(input);
|
|
118
|
+
const result = await Parser.parse(argv, {
|
|
119
|
+
args: options.args ?? {},
|
|
120
|
+
flags: options.flags ?? {},
|
|
121
|
+
strict: options.strict ?? false,
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
args: result.args,
|
|
125
|
+
argv: result.argv,
|
|
126
|
+
files,
|
|
127
|
+
flags: result.flags,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
2
|
+
import { FileContextTreeService } from '../../context-tree/file-context-tree-service.js';
|
|
3
|
+
import { FileContextTreeSnapshotService } from '../../context-tree/file-context-tree-snapshot-service.js';
|
|
4
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
5
|
+
import { ClearUseCase } from '../../usecase/clear-use-case.js';
|
|
6
|
+
import { Args, Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
7
|
+
// Flags - defined once, used for both parsing and help display
|
|
8
|
+
const clearFlags = {
|
|
9
|
+
yes: Flags.boolean({
|
|
10
|
+
char: 'y',
|
|
11
|
+
default: false,
|
|
12
|
+
description: 'Skip confirmation prompt',
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
// Args - defined once for parsing
|
|
16
|
+
const clearArgs = {
|
|
17
|
+
directory: Args.string({
|
|
18
|
+
description: 'Project directory (defaults to current directory)',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* clear command
|
|
24
|
+
*/
|
|
25
|
+
export const clearCommand = {
|
|
26
|
+
action(_context, args) {
|
|
27
|
+
return {
|
|
28
|
+
async execute(onMessage, onPrompt) {
|
|
29
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
30
|
+
const parsed = await parseReplArgs(args, {
|
|
31
|
+
args: clearArgs,
|
|
32
|
+
flags: clearFlags,
|
|
33
|
+
strict: false,
|
|
34
|
+
});
|
|
35
|
+
const useCase = new ClearUseCase({
|
|
36
|
+
contextTreeService: new FileContextTreeService(),
|
|
37
|
+
contextTreeSnapshotService: new FileContextTreeSnapshotService(),
|
|
38
|
+
terminal,
|
|
39
|
+
});
|
|
40
|
+
await useCase.run({
|
|
41
|
+
directory: parsed.args.directory,
|
|
42
|
+
skipConfirmation: parsed.flags.yes ?? false,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
type: 'streaming',
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
aliases: [],
|
|
49
|
+
args: [
|
|
50
|
+
{
|
|
51
|
+
description: 'Project directory (defaults to current directory)',
|
|
52
|
+
name: 'directory',
|
|
53
|
+
required: false,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
autoExecute: true,
|
|
57
|
+
description: 'Reset the current context tree and start with 6 default domains',
|
|
58
|
+
flags: toCommandFlags(clearFlags),
|
|
59
|
+
kind: CommandKind.BUILT_IN,
|
|
60
|
+
name: 'clear',
|
|
61
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SlashCommand } from '../../../tui/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Curate command - Curate context to the context tree
|
|
4
|
+
*
|
|
5
|
+
* Supports both modes:
|
|
6
|
+
* - Autonomous mode: /curate "your context" @file1 @file2
|
|
7
|
+
* - Interactive mode: /curate (no args) - navigates context tree
|
|
8
|
+
*/
|
|
9
|
+
export declare const curateCommand: SlashCommand;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isDevelopment } from '../../../config/environment.js';
|
|
3
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
4
|
+
import { ProjectConfigStore } from '../../config/file-config-store.js';
|
|
5
|
+
import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
|
|
6
|
+
import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
|
|
7
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
8
|
+
import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
|
|
9
|
+
import { CurateUseCase } from '../../usecase/curate-use-case.js';
|
|
10
|
+
import { Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
11
|
+
// Dev-only flags - defined once, used for both parsing and help display
|
|
12
|
+
const devFlags = {
|
|
13
|
+
apiKey: Flags.string({ char: 'k', description: 'OpenRouter API key [Dev only]' }),
|
|
14
|
+
model: Flags.string({ char: 'm', description: 'Model to use [Dev only]' }),
|
|
15
|
+
verbose: Flags.boolean({ char: 'v', description: 'Enable verbose debug output [Dev only]' }),
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Curate command - Curate context to the context tree
|
|
19
|
+
*
|
|
20
|
+
* Supports both modes:
|
|
21
|
+
* - Autonomous mode: /curate "your context" @file1 @file2
|
|
22
|
+
* - Interactive mode: /curate (no args) - navigates context tree
|
|
23
|
+
*/
|
|
24
|
+
export const curateCommand = {
|
|
25
|
+
action(context, args) {
|
|
26
|
+
return {
|
|
27
|
+
async execute(onMessage, onPrompt) {
|
|
28
|
+
// Files are pre-extracted by the command processor
|
|
29
|
+
const files = context.invocation?.files ?? [];
|
|
30
|
+
// Parse flags and get context text
|
|
31
|
+
let contextText;
|
|
32
|
+
let flags = {};
|
|
33
|
+
if (isDevelopment()) {
|
|
34
|
+
const parsed = await parseReplArgs(args, { flags: devFlags, strict: false });
|
|
35
|
+
contextText = parsed.argv.join(' ') || undefined;
|
|
36
|
+
flags = parsed.flags;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
contextText = args || undefined;
|
|
40
|
+
}
|
|
41
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
42
|
+
const tokenStore = new KeychainTokenStore();
|
|
43
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
44
|
+
const useCase = new CurateUseCase({
|
|
45
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
46
|
+
terminal,
|
|
47
|
+
tokenStore,
|
|
48
|
+
trackingService: new MixpanelTrackingService({ globalConfigStore, tokenStore }),
|
|
49
|
+
});
|
|
50
|
+
// Run the use case - mode determined by whether context is provided
|
|
51
|
+
await useCase.run({
|
|
52
|
+
apiKey: flags.apiKey,
|
|
53
|
+
context: contextText,
|
|
54
|
+
files: files.length > 0 ? files : undefined,
|
|
55
|
+
model: flags.model,
|
|
56
|
+
verbose: flags.verbose,
|
|
57
|
+
});
|
|
58
|
+
onMessage({
|
|
59
|
+
content: 'View in Activity tab. [tab]',
|
|
60
|
+
id: randomUUID(),
|
|
61
|
+
type: 'output',
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
type: 'streaming',
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
aliases: [],
|
|
68
|
+
args: [
|
|
69
|
+
{
|
|
70
|
+
description: 'Knowledge context (optional, triggers autonomous mode)',
|
|
71
|
+
name: 'context',
|
|
72
|
+
required: false,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
autoExecute: true,
|
|
76
|
+
description: 'Curate context to the context tree.',
|
|
77
|
+
flags: [
|
|
78
|
+
{
|
|
79
|
+
char: '@',
|
|
80
|
+
description: 'Include files (type @ to browse, max 5)',
|
|
81
|
+
name: 'files',
|
|
82
|
+
type: 'file',
|
|
83
|
+
},
|
|
84
|
+
...(isDevelopment() ? toCommandFlags(devFlags) : []),
|
|
85
|
+
],
|
|
86
|
+
kind: CommandKind.BUILT_IN,
|
|
87
|
+
name: 'curate',
|
|
88
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
2
|
+
import { FsFileService } from '../../file/fs-file-service.js';
|
|
3
|
+
import { LegacyRuleDetector } from '../../rule/legacy-rule-detector.js';
|
|
4
|
+
import { RuleTemplateService } from '../../rule/rule-template-service.js';
|
|
5
|
+
import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
|
|
6
|
+
import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
|
|
7
|
+
import { FsTemplateLoader } from '../../template/fs-template-loader.js';
|
|
8
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
9
|
+
import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
|
|
10
|
+
import { GenerateRulesUseCase } from '../../usecase/generate-rules-use-case.js';
|
|
11
|
+
/**
|
|
12
|
+
* Generate rules command
|
|
13
|
+
*
|
|
14
|
+
* Creates and runs GenerateRulesUseCase with ReplTerminal for TUI integration.
|
|
15
|
+
*/
|
|
16
|
+
export const genRulesCommand = {
|
|
17
|
+
action: () => ({
|
|
18
|
+
async execute(onMessage, onPrompt) {
|
|
19
|
+
// Create ReplTerminal with callbacks
|
|
20
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
21
|
+
// Create services
|
|
22
|
+
const fileService = new FsFileService();
|
|
23
|
+
const templateLoader = new FsTemplateLoader(fileService);
|
|
24
|
+
const templateService = new RuleTemplateService(templateLoader);
|
|
25
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
26
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore: new KeychainTokenStore() });
|
|
27
|
+
// Create and run UseCase
|
|
28
|
+
const useCase = new GenerateRulesUseCase(fileService, new LegacyRuleDetector(), templateService, terminal, trackingService);
|
|
29
|
+
await useCase.run();
|
|
30
|
+
},
|
|
31
|
+
type: 'streaming',
|
|
32
|
+
}),
|
|
33
|
+
aliases: [],
|
|
34
|
+
autoExecute: true,
|
|
35
|
+
description: 'Generate rule instructions for coding agents to work with ByteRover correctly',
|
|
36
|
+
kind: CommandKind.BUILT_IN,
|
|
37
|
+
name: 'gen-rules',
|
|
38
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SlashCommand } from '../../../tui/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load all REPL slash commands.
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: Order matters - commands are displayed in the UI suggestions
|
|
6
|
+
* in the same order as defined here. Keep grouped by priority/category.
|
|
7
|
+
*/
|
|
8
|
+
export declare const load: () => SlashCommand[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { clearCommand } from './clear-command.js';
|
|
2
|
+
import { curateCommand } from './curate-command.js';
|
|
3
|
+
import { genRulesCommand } from './gen-rules-command.js';
|
|
4
|
+
import { initCommand } from './init-command.js';
|
|
5
|
+
import { loginCommand } from './login-command.js';
|
|
6
|
+
import { logoutCommand } from './logout-command.js';
|
|
7
|
+
import { pullCommand } from './pull-command.js';
|
|
8
|
+
import { pushCommand } from './push-command.js';
|
|
9
|
+
import { queryCommand } from './query-command.js';
|
|
10
|
+
import { spaceCommand } from './space/index.js';
|
|
11
|
+
import { statusCommand } from './status-command.js';
|
|
12
|
+
/**
|
|
13
|
+
* Load all REPL slash commands.
|
|
14
|
+
*
|
|
15
|
+
* IMPORTANT: Order matters - commands are displayed in the UI suggestions
|
|
16
|
+
* in the same order as defined here. Keep grouped by priority/category.
|
|
17
|
+
*/
|
|
18
|
+
export const load = () => [
|
|
19
|
+
// Core workflow - most frequently used
|
|
20
|
+
statusCommand, // Quick check current state
|
|
21
|
+
curateCommand, // Add context (primary action)
|
|
22
|
+
queryCommand, // Query context tree
|
|
23
|
+
// Sync operations
|
|
24
|
+
pushCommand, // Push to cloud
|
|
25
|
+
pullCommand, // Pull from cloud
|
|
26
|
+
// Space management
|
|
27
|
+
spaceCommand, // Switch/list spaces
|
|
28
|
+
// Context tree management
|
|
29
|
+
genRulesCommand, // Generate rule files
|
|
30
|
+
clearCommand, // Reset context tree (destructive)
|
|
31
|
+
// Setup
|
|
32
|
+
initCommand, // Project setup (once per project)
|
|
33
|
+
// Auth
|
|
34
|
+
loginCommand, // Sign in
|
|
35
|
+
logoutCommand, // Sign out
|
|
36
|
+
];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { getCurrentConfig } from '../../../config/environment.js';
|
|
2
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
3
|
+
import { HttpCogitPullService } from '../../cogit/http-cogit-pull-service.js';
|
|
4
|
+
import { ProjectConfigStore } from '../../config/file-config-store.js';
|
|
5
|
+
import { FileContextTreeService } from '../../context-tree/file-context-tree-service.js';
|
|
6
|
+
import { FileContextTreeSnapshotService } from '../../context-tree/file-context-tree-snapshot-service.js';
|
|
7
|
+
import { FileContextTreeWriterService } from '../../context-tree/file-context-tree-writer-service.js';
|
|
8
|
+
import { FsFileService } from '../../file/fs-file-service.js';
|
|
9
|
+
import { LegacyRuleDetector } from '../../rule/legacy-rule-detector.js';
|
|
10
|
+
import { RuleTemplateService } from '../../rule/rule-template-service.js';
|
|
11
|
+
import { HttpSpaceService } from '../../space/http-space-service.js';
|
|
12
|
+
import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
|
|
13
|
+
import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
|
|
14
|
+
import { HttpTeamService } from '../../team/http-team-service.js';
|
|
15
|
+
import { FsTemplateLoader } from '../../template/fs-template-loader.js';
|
|
16
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
17
|
+
import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
|
|
18
|
+
import { InitUseCase } from '../../usecase/init-use-case.js';
|
|
19
|
+
import { Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
20
|
+
// Flags - defined once, used for both parsing and help display
|
|
21
|
+
const initFlags = {
|
|
22
|
+
force: Flags.boolean({ char: 'f', description: 'Force re-initialization without confirmation prompt' }),
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Initialize command
|
|
26
|
+
*
|
|
27
|
+
* Creates and runs InitUseCase with ReplTerminal for TUI integration.
|
|
28
|
+
*/
|
|
29
|
+
export const initCommand = {
|
|
30
|
+
action(_context, args) {
|
|
31
|
+
return {
|
|
32
|
+
async execute(onMessage, onPrompt) {
|
|
33
|
+
// Parse flags
|
|
34
|
+
const parsed = await parseReplArgs(args, { flags: initFlags });
|
|
35
|
+
const force = parsed.flags.force ?? false;
|
|
36
|
+
// Create ReplTerminal with callbacks
|
|
37
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
38
|
+
// Create services
|
|
39
|
+
const envConfig = getCurrentConfig();
|
|
40
|
+
const tokenStore = new KeychainTokenStore();
|
|
41
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
42
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
43
|
+
const fileService = new FsFileService();
|
|
44
|
+
const templateLoader = new FsTemplateLoader(fileService);
|
|
45
|
+
const ruleTemplateService = new RuleTemplateService(templateLoader);
|
|
46
|
+
const legacyRuleDetector = new LegacyRuleDetector();
|
|
47
|
+
const contextTreeSnapshotService = new FileContextTreeSnapshotService();
|
|
48
|
+
// Create and run use case
|
|
49
|
+
const useCase = new InitUseCase({
|
|
50
|
+
cogitPullService: new HttpCogitPullService({
|
|
51
|
+
apiBaseUrl: envConfig.cogitApiBaseUrl,
|
|
52
|
+
}),
|
|
53
|
+
contextTreeService: new FileContextTreeService(),
|
|
54
|
+
contextTreeSnapshotService,
|
|
55
|
+
contextTreeWriterService: new FileContextTreeWriterService({
|
|
56
|
+
snapshotService: contextTreeSnapshotService,
|
|
57
|
+
}),
|
|
58
|
+
fileService,
|
|
59
|
+
legacyRuleDetector,
|
|
60
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
61
|
+
spaceService: new HttpSpaceService({
|
|
62
|
+
apiBaseUrl: envConfig.apiBaseUrl,
|
|
63
|
+
}),
|
|
64
|
+
teamService: new HttpTeamService({
|
|
65
|
+
apiBaseUrl: envConfig.apiBaseUrl,
|
|
66
|
+
}),
|
|
67
|
+
templateService: ruleTemplateService,
|
|
68
|
+
terminal,
|
|
69
|
+
tokenStore,
|
|
70
|
+
trackingService,
|
|
71
|
+
});
|
|
72
|
+
await useCase.run({ force });
|
|
73
|
+
},
|
|
74
|
+
type: 'streaming',
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
aliases: [],
|
|
78
|
+
autoExecute: true,
|
|
79
|
+
description: 'Initialize a project with ByteRover',
|
|
80
|
+
flags: toCommandFlags(initFlags),
|
|
81
|
+
kind: CommandKind.BUILT_IN,
|
|
82
|
+
name: 'init',
|
|
83
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getAuthConfig } from '../../../config/auth.config.js';
|
|
2
|
+
import { getCurrentConfig } from '../../../config/environment.js';
|
|
3
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
4
|
+
import { OAuthService } from '../../auth/oauth-service.js';
|
|
5
|
+
import { OidcDiscoveryService } from '../../auth/oidc-discovery-service.js';
|
|
6
|
+
import { SystemBrowserLauncher } from '../../browser/system-browser-launcher.js';
|
|
7
|
+
import { CallbackHandler } from '../../http/callback-handler.js';
|
|
8
|
+
import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
|
|
9
|
+
import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
|
|
10
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
11
|
+
import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
|
|
12
|
+
import { LoginUseCase } from '../../usecase/login-use-case.js';
|
|
13
|
+
import { HttpUserService } from '../../user/http-user-service.js';
|
|
14
|
+
/**
|
|
15
|
+
* Login command
|
|
16
|
+
*
|
|
17
|
+
* Creates and runs LoginUseCase with ReplTerminal for TUI integration.
|
|
18
|
+
*/
|
|
19
|
+
export const loginCommand = {
|
|
20
|
+
action: () => ({
|
|
21
|
+
async execute(onMessage, onPrompt) {
|
|
22
|
+
// Create ReplTerminal with callbacks
|
|
23
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
24
|
+
// Create services
|
|
25
|
+
const config = getCurrentConfig();
|
|
26
|
+
const tokenStore = new KeychainTokenStore();
|
|
27
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
28
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
29
|
+
const discoveryService = new OidcDiscoveryService();
|
|
30
|
+
const authConfig = await getAuthConfig(discoveryService);
|
|
31
|
+
// Create and run LoginUseCase
|
|
32
|
+
const useCase = new LoginUseCase({
|
|
33
|
+
authService: new OAuthService(authConfig),
|
|
34
|
+
browserLauncher: new SystemBrowserLauncher(),
|
|
35
|
+
callbackHandler: new CallbackHandler(),
|
|
36
|
+
terminal,
|
|
37
|
+
tokenStore,
|
|
38
|
+
trackingService,
|
|
39
|
+
userService: new HttpUserService({ apiBaseUrl: config.apiBaseUrl }),
|
|
40
|
+
});
|
|
41
|
+
await useCase.run();
|
|
42
|
+
},
|
|
43
|
+
type: 'streaming',
|
|
44
|
+
}),
|
|
45
|
+
aliases: [],
|
|
46
|
+
autoExecute: true,
|
|
47
|
+
description: 'Authenticate with ByteRover using OAuth 2.0 + PKCE',
|
|
48
|
+
kind: CommandKind.BUILT_IN,
|
|
49
|
+
name: 'login',
|
|
50
|
+
};
|