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,48 @@
|
|
|
1
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
2
|
+
import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
|
|
3
|
+
import { FileOnboardingPreferenceStore } from '../../storage/file-onboarding-preference-store.js';
|
|
4
|
+
import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
|
|
5
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
6
|
+
import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
|
|
7
|
+
import { LogoutUseCase } from '../../usecase/logout-use-case.js';
|
|
8
|
+
import { Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
9
|
+
// Flags - defined once, used for both parsing and help display
|
|
10
|
+
const logoutFlags = {
|
|
11
|
+
yes: Flags.boolean({
|
|
12
|
+
char: 'y',
|
|
13
|
+
default: false,
|
|
14
|
+
description: 'Skip confirmation prompt',
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Logout command
|
|
19
|
+
*/
|
|
20
|
+
export const logoutCommand = {
|
|
21
|
+
action(_context, args) {
|
|
22
|
+
return {
|
|
23
|
+
async execute(onMessage, onPrompt) {
|
|
24
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
25
|
+
const parsed = await parseReplArgs(args, {
|
|
26
|
+
flags: logoutFlags,
|
|
27
|
+
strict: false,
|
|
28
|
+
});
|
|
29
|
+
const tokenStore = new KeychainTokenStore();
|
|
30
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
31
|
+
const useCase = new LogoutUseCase({
|
|
32
|
+
onboardingPreferenceStore: new FileOnboardingPreferenceStore(),
|
|
33
|
+
terminal,
|
|
34
|
+
tokenStore,
|
|
35
|
+
trackingService: new MixpanelTrackingService({ globalConfigStore, tokenStore }),
|
|
36
|
+
});
|
|
37
|
+
await useCase.run({ skipConfirmation: parsed.flags.yes ?? false });
|
|
38
|
+
},
|
|
39
|
+
type: 'streaming',
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
aliases: [],
|
|
43
|
+
autoExecute: true,
|
|
44
|
+
description: 'Log out of ByteRover CLI and clear authentication',
|
|
45
|
+
flags: toCommandFlags(logoutFlags),
|
|
46
|
+
kind: CommandKind.BUILT_IN,
|
|
47
|
+
name: 'logout',
|
|
48
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getCurrentConfig } from '../../../config/environment.js';
|
|
2
|
+
import { DEFAULT_BRANCH } from '../../../constants.js';
|
|
3
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
4
|
+
import { HttpCogitPullService } from '../../cogit/http-cogit-pull-service.js';
|
|
5
|
+
import { ProjectConfigStore } from '../../config/file-config-store.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 { 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 { PullUseCase } from '../../usecase/pull-use-case.js';
|
|
13
|
+
import { Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
14
|
+
const pullFlags = {
|
|
15
|
+
branch: Flags.string({
|
|
16
|
+
char: 'b',
|
|
17
|
+
default: DEFAULT_BRANCH,
|
|
18
|
+
description: 'ByteRover branch name (not Git branch)',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Pull command
|
|
23
|
+
*/
|
|
24
|
+
export const pullCommand = {
|
|
25
|
+
action(_context, args) {
|
|
26
|
+
return {
|
|
27
|
+
async execute(onMessage, onPrompt) {
|
|
28
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
29
|
+
const parsed = await parseReplArgs(args, { flags: pullFlags, strict: false });
|
|
30
|
+
const envConfig = getCurrentConfig();
|
|
31
|
+
const tokenStore = new KeychainTokenStore();
|
|
32
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
33
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
34
|
+
const contextTreeSnapshotService = new FileContextTreeSnapshotService();
|
|
35
|
+
const useCase = new PullUseCase({
|
|
36
|
+
cogitPullService: new HttpCogitPullService({
|
|
37
|
+
apiBaseUrl: envConfig.cogitApiBaseUrl,
|
|
38
|
+
}),
|
|
39
|
+
contextTreeSnapshotService,
|
|
40
|
+
contextTreeWriterService: new FileContextTreeWriterService({
|
|
41
|
+
snapshotService: contextTreeSnapshotService,
|
|
42
|
+
}),
|
|
43
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
44
|
+
terminal,
|
|
45
|
+
tokenStore,
|
|
46
|
+
trackingService,
|
|
47
|
+
});
|
|
48
|
+
await useCase.run({
|
|
49
|
+
branch: parsed.flags.branch ?? DEFAULT_BRANCH,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
type: 'streaming',
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
aliases: [],
|
|
56
|
+
autoExecute: true,
|
|
57
|
+
description: 'Pull context tree from ByteRover memory storage',
|
|
58
|
+
flags: toCommandFlags(pullFlags),
|
|
59
|
+
kind: CommandKind.BUILT_IN,
|
|
60
|
+
name: 'pull',
|
|
61
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getCurrentConfig } from '../../../config/environment.js';
|
|
2
|
+
import { DEFAULT_BRANCH } from '../../../constants.js';
|
|
3
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
4
|
+
import { HttpCogitPushService } from '../../cogit/http-cogit-push-service.js';
|
|
5
|
+
import { ProjectConfigStore } from '../../config/file-config-store.js';
|
|
6
|
+
import { FileContextFileReader } from '../../context-tree/file-context-file-reader.js';
|
|
7
|
+
import { FileContextTreeSnapshotService } from '../../context-tree/file-context-tree-snapshot-service.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 { PushUseCase } from '../../usecase/push-use-case.js';
|
|
13
|
+
import { Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
14
|
+
// Flags - defined once, used for both parsing and help display
|
|
15
|
+
const pushFlags = {
|
|
16
|
+
branch: Flags.string({
|
|
17
|
+
char: 'b',
|
|
18
|
+
default: DEFAULT_BRANCH,
|
|
19
|
+
description: 'ByteRover branch name (not Git branch)',
|
|
20
|
+
}),
|
|
21
|
+
yes: Flags.boolean({
|
|
22
|
+
char: 'y',
|
|
23
|
+
default: false,
|
|
24
|
+
description: 'Skip confirmation prompt',
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Push command
|
|
29
|
+
*/
|
|
30
|
+
export const pushCommand = {
|
|
31
|
+
action(_context, args) {
|
|
32
|
+
return {
|
|
33
|
+
async execute(onMessage, onPrompt) {
|
|
34
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
35
|
+
const parsed = await parseReplArgs(args, { flags: pushFlags, strict: false });
|
|
36
|
+
const envConfig = getCurrentConfig();
|
|
37
|
+
const tokenStore = new KeychainTokenStore();
|
|
38
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
39
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
40
|
+
const useCase = new PushUseCase({
|
|
41
|
+
cogitPushService: new HttpCogitPushService({
|
|
42
|
+
apiBaseUrl: envConfig.cogitApiBaseUrl,
|
|
43
|
+
}),
|
|
44
|
+
contextFileReader: new FileContextFileReader(),
|
|
45
|
+
contextTreeSnapshotService: new FileContextTreeSnapshotService(),
|
|
46
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
47
|
+
terminal,
|
|
48
|
+
tokenStore,
|
|
49
|
+
trackingService,
|
|
50
|
+
webAppUrl: envConfig.webAppUrl,
|
|
51
|
+
});
|
|
52
|
+
await useCase.run({
|
|
53
|
+
branch: parsed.flags.branch ?? DEFAULT_BRANCH,
|
|
54
|
+
skipConfirmation: parsed.flags.yes ?? false,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
type: 'streaming',
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
aliases: [],
|
|
61
|
+
autoExecute: true,
|
|
62
|
+
description: 'Push context tree to ByteRover memory storage',
|
|
63
|
+
flags: toCommandFlags(pushFlags),
|
|
64
|
+
kind: CommandKind.BUILT_IN,
|
|
65
|
+
name: 'push',
|
|
66
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isDevelopment } from '../../../config/environment.js';
|
|
2
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
3
|
+
import { ProjectConfigStore } from '../../config/file-config-store.js';
|
|
4
|
+
import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
|
|
5
|
+
import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
|
|
6
|
+
import { ReplTerminal } from '../../terminal/repl-terminal.js';
|
|
7
|
+
import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
|
|
8
|
+
import { QueryUseCase } from '../../usecase/query-use-case.js';
|
|
9
|
+
import { Flags, parseReplArgs, toCommandFlags } from './arg-parser.js';
|
|
10
|
+
// Dev-only flags - defined once, used for both parsing and help display
|
|
11
|
+
const devFlags = {
|
|
12
|
+
apiKey: Flags.string({ char: 'k', description: 'OpenRouter API key [Dev only]' }),
|
|
13
|
+
model: Flags.string({ char: 'm', description: 'Model to use [Dev only]' }),
|
|
14
|
+
verbose: Flags.boolean({ char: 'v', description: 'Enable verbose debug output [Dev only]' }),
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Query command - Query and retrieve information from the context tree
|
|
18
|
+
*/
|
|
19
|
+
export const queryCommand = {
|
|
20
|
+
action(_context, args) {
|
|
21
|
+
return {
|
|
22
|
+
async execute(onMessage, onPrompt) {
|
|
23
|
+
// Parse flags only in dev mode, otherwise use args directly as query
|
|
24
|
+
let query;
|
|
25
|
+
let flags = {};
|
|
26
|
+
if (isDevelopment()) {
|
|
27
|
+
const parsed = await parseReplArgs(args, { flags: devFlags, strict: false });
|
|
28
|
+
query = parsed.argv.join(' ');
|
|
29
|
+
flags = parsed.flags;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
query = args;
|
|
33
|
+
}
|
|
34
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
35
|
+
const tokenStore = new KeychainTokenStore();
|
|
36
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
37
|
+
const useCase = new QueryUseCase({
|
|
38
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
39
|
+
terminal,
|
|
40
|
+
tokenStore,
|
|
41
|
+
trackingService: new MixpanelTrackingService({ globalConfigStore, tokenStore }),
|
|
42
|
+
});
|
|
43
|
+
await useCase.run({
|
|
44
|
+
apiKey: flags.apiKey,
|
|
45
|
+
model: flags.model,
|
|
46
|
+
query,
|
|
47
|
+
verbose: Boolean(flags.verbose),
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
type: 'streaming',
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
aliases: ['q'],
|
|
54
|
+
args: [
|
|
55
|
+
{
|
|
56
|
+
description: 'Natural language question about your codebase',
|
|
57
|
+
name: 'query',
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
autoExecute: false,
|
|
62
|
+
description: 'Query and retrieve information from the context tree',
|
|
63
|
+
flags: isDevelopment() ? toCommandFlags(devFlags) : [],
|
|
64
|
+
kind: CommandKind.BUILT_IN,
|
|
65
|
+
name: 'query',
|
|
66
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandKind } from '../../../../tui/types.js';
|
|
2
|
+
import { listCommand } from './list-command.js';
|
|
3
|
+
import { switchCommand } from './switch-command.js';
|
|
4
|
+
/**
|
|
5
|
+
* Space command - manages ByteRover spaces
|
|
6
|
+
*/
|
|
7
|
+
export const spaceCommand = {
|
|
8
|
+
aliases: [],
|
|
9
|
+
autoExecute: true,
|
|
10
|
+
description: 'Manage ByteRover spaces',
|
|
11
|
+
kind: CommandKind.BUILT_IN,
|
|
12
|
+
name: 'space',
|
|
13
|
+
subCommands: [listCommand, switchCommand],
|
|
14
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { getCurrentConfig } from '../../../../config/environment.js';
|
|
2
|
+
import { CommandKind } from '../../../../tui/types.js';
|
|
3
|
+
import { ProjectConfigStore } from '../../../config/file-config-store.js';
|
|
4
|
+
import { HttpSpaceService } from '../../../space/http-space-service.js';
|
|
5
|
+
import { KeychainTokenStore } from '../../../storage/keychain-token-store.js';
|
|
6
|
+
import { ReplTerminal } from '../../../terminal/repl-terminal.js';
|
|
7
|
+
import { SpaceListUseCase } from '../../../usecase/space-list-use-case.js';
|
|
8
|
+
import { Flags, parseReplArgs, toCommandFlags } from '../arg-parser.js';
|
|
9
|
+
const DEFAULT_LIMIT = 50;
|
|
10
|
+
const DEFAULT_OFFSET = 0;
|
|
11
|
+
// Flags - defined once, used for both parsing and help display
|
|
12
|
+
const listFlags = {
|
|
13
|
+
all: Flags.boolean({
|
|
14
|
+
char: 'a',
|
|
15
|
+
default: false,
|
|
16
|
+
description: 'Fetch all spaces (may be slow for large teams)',
|
|
17
|
+
}),
|
|
18
|
+
json: Flags.boolean({
|
|
19
|
+
char: 'j',
|
|
20
|
+
default: false,
|
|
21
|
+
description: 'Output in JSON format',
|
|
22
|
+
}),
|
|
23
|
+
limit: Flags.integer({
|
|
24
|
+
char: 'l',
|
|
25
|
+
default: DEFAULT_LIMIT,
|
|
26
|
+
description: 'Maximum number of spaces to fetch',
|
|
27
|
+
}),
|
|
28
|
+
offset: Flags.integer({
|
|
29
|
+
char: 'o',
|
|
30
|
+
default: DEFAULT_OFFSET,
|
|
31
|
+
description: 'Number of spaces to skip',
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* List spaces command
|
|
36
|
+
*/
|
|
37
|
+
export const listCommand = {
|
|
38
|
+
action(_context, args) {
|
|
39
|
+
return {
|
|
40
|
+
async execute(onMessage, onPrompt) {
|
|
41
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
42
|
+
const parsed = await parseReplArgs(args, {
|
|
43
|
+
flags: listFlags,
|
|
44
|
+
strict: false,
|
|
45
|
+
});
|
|
46
|
+
const envConfig = getCurrentConfig();
|
|
47
|
+
const useCase = new SpaceListUseCase({
|
|
48
|
+
flags: {
|
|
49
|
+
all: parsed.flags.all ?? false,
|
|
50
|
+
json: parsed.flags.json ?? false,
|
|
51
|
+
limit: Number(parsed.flags.limit ?? DEFAULT_LIMIT),
|
|
52
|
+
offset: Number(parsed.flags.offset ?? DEFAULT_OFFSET),
|
|
53
|
+
},
|
|
54
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
55
|
+
spaceService: new HttpSpaceService({ apiBaseUrl: envConfig.apiBaseUrl }),
|
|
56
|
+
terminal,
|
|
57
|
+
tokenStore: new KeychainTokenStore(),
|
|
58
|
+
});
|
|
59
|
+
await useCase.run();
|
|
60
|
+
},
|
|
61
|
+
type: 'streaming',
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
aliases: [],
|
|
65
|
+
autoExecute: true,
|
|
66
|
+
description: 'List all spaces for the current team',
|
|
67
|
+
flags: toCommandFlags(listFlags),
|
|
68
|
+
kind: CommandKind.BUILT_IN,
|
|
69
|
+
name: 'list',
|
|
70
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getCurrentConfig } from '../../../../config/environment.js';
|
|
2
|
+
import { CommandKind } from '../../../../tui/types.js';
|
|
3
|
+
import { ProjectConfigStore } from '../../../config/file-config-store.js';
|
|
4
|
+
import { HttpSpaceService } from '../../../space/http-space-service.js';
|
|
5
|
+
import { KeychainTokenStore } from '../../../storage/keychain-token-store.js';
|
|
6
|
+
import { HttpTeamService } from '../../../team/http-team-service.js';
|
|
7
|
+
import { ReplTerminal } from '../../../terminal/repl-terminal.js';
|
|
8
|
+
import { SpaceSwitchUseCase } from '../../../usecase/space-switch-use-case.js';
|
|
9
|
+
import { WorkspaceDetectorService } from '../../../workspace/workspace-detector-service.js';
|
|
10
|
+
/**
|
|
11
|
+
* Switch space command
|
|
12
|
+
*/
|
|
13
|
+
export const switchCommand = {
|
|
14
|
+
action(_context, _args) {
|
|
15
|
+
return {
|
|
16
|
+
async execute(onMessage, onPrompt) {
|
|
17
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
18
|
+
const envConfig = getCurrentConfig();
|
|
19
|
+
const useCase = new SpaceSwitchUseCase({
|
|
20
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
21
|
+
spaceService: new HttpSpaceService({ apiBaseUrl: envConfig.apiBaseUrl }),
|
|
22
|
+
teamService: new HttpTeamService({ apiBaseUrl: envConfig.apiBaseUrl }),
|
|
23
|
+
terminal,
|
|
24
|
+
tokenStore: new KeychainTokenStore(),
|
|
25
|
+
workspaceDetector: new WorkspaceDetectorService(),
|
|
26
|
+
});
|
|
27
|
+
await useCase.run();
|
|
28
|
+
},
|
|
29
|
+
type: 'streaming',
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
aliases: [],
|
|
33
|
+
autoExecute: true,
|
|
34
|
+
description: 'Switch to a different space',
|
|
35
|
+
kind: CommandKind.BUILT_IN,
|
|
36
|
+
name: 'switch',
|
|
37
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CommandKind } from '../../../tui/types.js';
|
|
2
|
+
import { ProjectConfigStore } from '../../config/file-config-store.js';
|
|
3
|
+
import { FileContextTreeService } from '../../context-tree/file-context-tree-service.js';
|
|
4
|
+
import { FileContextTreeSnapshotService } from '../../context-tree/file-context-tree-snapshot-service.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 { StatusUseCase } from '../../usecase/status-use-case.js';
|
|
10
|
+
/**
|
|
11
|
+
* Status command
|
|
12
|
+
*/
|
|
13
|
+
export const statusCommand = {
|
|
14
|
+
action(context, _args) {
|
|
15
|
+
return {
|
|
16
|
+
async execute(onMessage, onPrompt) {
|
|
17
|
+
const terminal = new ReplTerminal({ onMessage, onPrompt });
|
|
18
|
+
const tokenStore = new KeychainTokenStore();
|
|
19
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
20
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
21
|
+
const useCase = new StatusUseCase({
|
|
22
|
+
contextTreeService: new FileContextTreeService(),
|
|
23
|
+
contextTreeSnapshotService: new FileContextTreeSnapshotService(),
|
|
24
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
25
|
+
terminal,
|
|
26
|
+
tokenStore,
|
|
27
|
+
trackingService,
|
|
28
|
+
});
|
|
29
|
+
await useCase.run({ cliVersion: context.version ?? '' });
|
|
30
|
+
},
|
|
31
|
+
type: 'streaming',
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
aliases: [],
|
|
35
|
+
autoExecute: true,
|
|
36
|
+
description: 'Show CLI status and project information',
|
|
37
|
+
kind: CommandKind.BUILT_IN,
|
|
38
|
+
name: 'status',
|
|
39
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IOnboardingPreferenceStore } from '../../core/interfaces/i-onboarding-preference-store.js';
|
|
2
|
+
import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
|
|
3
|
+
import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
|
|
4
|
+
import type { ITrackingService } from '../../core/interfaces/i-tracking-service.js';
|
|
5
|
+
/**
|
|
6
|
+
* Options for starting the REPL
|
|
7
|
+
*/
|
|
8
|
+
export interface ReplOptions {
|
|
9
|
+
onboardingPreferenceStore: IOnboardingPreferenceStore;
|
|
10
|
+
projectConfigStore: IProjectConfigStore;
|
|
11
|
+
tokenStore: ITokenStore;
|
|
12
|
+
trackingService: ITrackingService;
|
|
13
|
+
version: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Start the ByteRover REPL
|
|
17
|
+
*/
|
|
18
|
+
export declare function startRepl(options: ReplOptions): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from 'ink';
|
|
3
|
+
import { App } from '../../tui/app.js';
|
|
4
|
+
import { AppProviders } from '../../tui/providers/app-providers.js';
|
|
5
|
+
import { stopQueuePollingService } from '../cipher/consumer/queue-polling-service.js';
|
|
6
|
+
/**
|
|
7
|
+
* Start the ByteRover REPL
|
|
8
|
+
*/
|
|
9
|
+
export async function startRepl(options) {
|
|
10
|
+
const { onboardingPreferenceStore, projectConfigStore, tokenStore, trackingService, version } = options;
|
|
11
|
+
// Check initial auth state
|
|
12
|
+
const authToken = await tokenStore.load();
|
|
13
|
+
const isAuthorized = authToken !== undefined && authToken.isValid();
|
|
14
|
+
// Load project config if authorized
|
|
15
|
+
let brvConfig;
|
|
16
|
+
if (isAuthorized) {
|
|
17
|
+
const configExists = await projectConfigStore.exists();
|
|
18
|
+
if (configExists) {
|
|
19
|
+
brvConfig = await projectConfigStore.read();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Render the App with providers
|
|
23
|
+
const { waitUntilExit } = render(_jsx(AppProviders, { initialAuthToken: isAuthorized ? authToken : undefined, initialBrvConfig: brvConfig, onboardingPreferenceStore: onboardingPreferenceStore, projectConfigStore: projectConfigStore, tokenStore: tokenStore, trackingService: trackingService, version: version, children: _jsx(App, {}) }));
|
|
24
|
+
await waitUntilExit();
|
|
25
|
+
stopQueuePollingService();
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IGlobalConfigStore } from '../../core/interfaces/i-global-config-store.js';
|
|
2
|
+
import { GlobalConfig } from '../../core/domain/entities/global-config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Dependencies for FileGlobalConfigStore.
|
|
5
|
+
* Allows injection for testing.
|
|
6
|
+
*/
|
|
7
|
+
export interface FileGlobalConfigStoreDeps {
|
|
8
|
+
readonly getConfigDir: () => string;
|
|
9
|
+
readonly getConfigPath: () => string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* File-based implementation of IGlobalConfigStore.
|
|
13
|
+
* Stores global configuration in the user's config directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FileGlobalConfigStore implements IGlobalConfigStore {
|
|
16
|
+
private readonly deps;
|
|
17
|
+
constructor(deps?: FileGlobalConfigStoreDeps);
|
|
18
|
+
getOrCreateDeviceId(): Promise<string>;
|
|
19
|
+
read(): Promise<GlobalConfig | undefined>;
|
|
20
|
+
regenerateDeviceId(): Promise<string>;
|
|
21
|
+
write(config: GlobalConfig): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { GlobalConfig } from '../../core/domain/entities/global-config.js';
|
|
5
|
+
import { getGlobalConfigDir, getGlobalConfigPath } from '../../utils/global-config-path.js';
|
|
6
|
+
/**
|
|
7
|
+
* Default dependencies using the real path functions.
|
|
8
|
+
*/
|
|
9
|
+
const defaultDeps = {
|
|
10
|
+
getConfigDir: getGlobalConfigDir,
|
|
11
|
+
getConfigPath: getGlobalConfigPath,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* File-based implementation of IGlobalConfigStore.
|
|
15
|
+
* Stores global configuration in the user's config directory.
|
|
16
|
+
*/
|
|
17
|
+
export class FileGlobalConfigStore {
|
|
18
|
+
deps;
|
|
19
|
+
constructor(deps = defaultDeps) {
|
|
20
|
+
this.deps = deps;
|
|
21
|
+
}
|
|
22
|
+
async getOrCreateDeviceId() {
|
|
23
|
+
// Try to read existing config
|
|
24
|
+
const existingConfig = await this.read();
|
|
25
|
+
if (existingConfig !== undefined) {
|
|
26
|
+
return existingConfig.deviceId;
|
|
27
|
+
}
|
|
28
|
+
// Generate new device ID and persist
|
|
29
|
+
const deviceId = randomUUID();
|
|
30
|
+
const newConfig = GlobalConfig.create(deviceId);
|
|
31
|
+
await this.write(newConfig);
|
|
32
|
+
return deviceId;
|
|
33
|
+
}
|
|
34
|
+
async read() {
|
|
35
|
+
const configPath = this.deps.getConfigPath();
|
|
36
|
+
if (!existsSync(configPath)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const content = await readFile(configPath, 'utf8');
|
|
41
|
+
const json = JSON.parse(content);
|
|
42
|
+
return GlobalConfig.fromJson(json);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Return undefined for any error (corrupted file, permission issues, etc.)
|
|
46
|
+
// The caller can regenerate the config if needed
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async regenerateDeviceId() {
|
|
51
|
+
const newDeviceId = randomUUID();
|
|
52
|
+
const newConfig = GlobalConfig.create(newDeviceId);
|
|
53
|
+
await this.write(newConfig);
|
|
54
|
+
return newDeviceId;
|
|
55
|
+
}
|
|
56
|
+
async write(config) {
|
|
57
|
+
const configDir = this.deps.getConfigDir();
|
|
58
|
+
const configPath = this.deps.getConfigPath();
|
|
59
|
+
// Create config directory if it doesn't exist
|
|
60
|
+
await mkdir(configDir, { recursive: true });
|
|
61
|
+
// Write config.json
|
|
62
|
+
const content = JSON.stringify(config.toJson(), null, 2);
|
|
63
|
+
await writeFile(configPath, content, 'utf8');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IOnboardingPreferenceStore } from '../../core/interfaces/i-onboarding-preference-store.js';
|
|
2
|
+
/**
|
|
3
|
+
* Onboarding preference store implementation using a lock file.
|
|
4
|
+
* Stores last dismissed timestamp in ~/.brv/.onboarding-dismissed
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileOnboardingPreferenceStore implements IOnboardingPreferenceStore {
|
|
7
|
+
clear(): Promise<void>;
|
|
8
|
+
getLastDismissedAt(): Promise<number | undefined>;
|
|
9
|
+
setLastDismissedAt(timestamp: number): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
const BRV_HOME_DIR = join(homedir(), '.brv');
|
|
5
|
+
const ONBOARDING_LOCK_FILE = join(BRV_HOME_DIR, '.onboarding-dismissed');
|
|
6
|
+
/**
|
|
7
|
+
* Onboarding preference store implementation using a lock file.
|
|
8
|
+
* Stores last dismissed timestamp in ~/.brv/.onboarding-dismissed
|
|
9
|
+
*/
|
|
10
|
+
export class FileOnboardingPreferenceStore {
|
|
11
|
+
async clear() {
|
|
12
|
+
try {
|
|
13
|
+
if (existsSync(ONBOARDING_LOCK_FILE)) {
|
|
14
|
+
rmSync(ONBOARDING_LOCK_FILE);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Ignore errors
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async getLastDismissedAt() {
|
|
22
|
+
try {
|
|
23
|
+
if (!existsSync(ONBOARDING_LOCK_FILE)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const content = readFileSync(ONBOARDING_LOCK_FILE, 'utf8').trim();
|
|
27
|
+
const timestamp = Number.parseInt(content, 10);
|
|
28
|
+
return Number.isNaN(timestamp) ? undefined : timestamp;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async setLastDismissedAt(timestamp) {
|
|
35
|
+
try {
|
|
36
|
+
// Ensure ~/.brv directory exists
|
|
37
|
+
if (!existsSync(BRV_HOME_DIR)) {
|
|
38
|
+
mkdirSync(BRV_HOME_DIR, { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
writeFileSync(ONBOARDING_LOCK_FILE, String(timestamp), 'utf8');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Silently ignore errors - onboarding preference is non-critical
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|