byterover-cli 0.3.5 → 0.4.1
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 +8 -1
- 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/welcome.js +10 -26
- 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 +28 -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 +288 -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} +197 -233
- package/dist/infra/usecase/login-use-case.d.ts +28 -0
- package/dist/infra/usecase/login-use-case.js +94 -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 +402 -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 +54 -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,28 @@
|
|
|
1
|
+
import type { IAuthService } from '../../core/interfaces/i-auth-service.js';
|
|
2
|
+
import type { IBrowserLauncher } from '../../core/interfaces/i-browser-launcher.js';
|
|
3
|
+
import type { ICallbackHandler } from '../../core/interfaces/i-callback-handler.js';
|
|
4
|
+
import type { ITerminal } from '../../core/interfaces/i-terminal.js';
|
|
5
|
+
import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
|
|
6
|
+
import type { ITrackingService } from '../../core/interfaces/i-tracking-service.js';
|
|
7
|
+
import type { IUserService } from '../../core/interfaces/i-user-service.js';
|
|
8
|
+
import type { ILoginUseCase } from '../../core/interfaces/usecase/i-login-use-case.js';
|
|
9
|
+
export interface LoginUseCaseOptions {
|
|
10
|
+
authService: IAuthService;
|
|
11
|
+
browserLauncher: IBrowserLauncher;
|
|
12
|
+
callbackHandler: ICallbackHandler;
|
|
13
|
+
terminal: ITerminal;
|
|
14
|
+
tokenStore: ITokenStore;
|
|
15
|
+
trackingService: ITrackingService;
|
|
16
|
+
userService: IUserService;
|
|
17
|
+
}
|
|
18
|
+
export declare class LoginUseCase implements ILoginUseCase {
|
|
19
|
+
private readonly authService;
|
|
20
|
+
private readonly browserLauncher;
|
|
21
|
+
private readonly callbackHandler;
|
|
22
|
+
private readonly terminal;
|
|
23
|
+
private readonly tokenStore;
|
|
24
|
+
private readonly trackingService;
|
|
25
|
+
private readonly userService;
|
|
26
|
+
constructor(options: LoginUseCaseOptions);
|
|
27
|
+
run(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AuthToken } from '../../core/domain/entities/auth-token.js';
|
|
2
|
+
import { DiscoveryError } from '../../core/domain/errors/discovery-error.js';
|
|
3
|
+
export class LoginUseCase {
|
|
4
|
+
authService;
|
|
5
|
+
browserLauncher;
|
|
6
|
+
callbackHandler;
|
|
7
|
+
terminal;
|
|
8
|
+
tokenStore;
|
|
9
|
+
trackingService;
|
|
10
|
+
userService;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.authService = options.authService;
|
|
13
|
+
this.browserLauncher = options.browserLauncher;
|
|
14
|
+
this.callbackHandler = options.callbackHandler;
|
|
15
|
+
this.terminal = options.terminal;
|
|
16
|
+
this.tokenStore = options.tokenStore;
|
|
17
|
+
this.trackingService = options.trackingService;
|
|
18
|
+
this.userService = options.userService;
|
|
19
|
+
}
|
|
20
|
+
async run() {
|
|
21
|
+
try {
|
|
22
|
+
await this.trackingService.track('auth:sign_in', { status: 'started' });
|
|
23
|
+
this.terminal.log('Starting authentication process...');
|
|
24
|
+
// Start callback server
|
|
25
|
+
await this.callbackHandler.start();
|
|
26
|
+
// Get port and build redirect URI
|
|
27
|
+
const port = this.callbackHandler.getPort();
|
|
28
|
+
if (!port) {
|
|
29
|
+
const getPortFailedErr = 'Failed to get callback server port';
|
|
30
|
+
await this.trackingService.track('auth:sign_in', { message: getPortFailedErr, status: 'error' });
|
|
31
|
+
throw new Error(getPortFailedErr);
|
|
32
|
+
}
|
|
33
|
+
const redirectUri = `http://localhost:${port}/callback`;
|
|
34
|
+
// Initiate authorization (generates PKCE parameters and state internally)
|
|
35
|
+
const authContext = this.authService.initiateAuthorization(redirectUri);
|
|
36
|
+
// Try to open browser
|
|
37
|
+
let browserOpened = false;
|
|
38
|
+
try {
|
|
39
|
+
await this.browserLauncher.open(authContext.authUrl);
|
|
40
|
+
browserOpened = true;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Browser launch failed, will return URL to user
|
|
44
|
+
await this.trackingService.track('auth:sign_in', { message: 'browser launch failed', status: 'error' });
|
|
45
|
+
}
|
|
46
|
+
// If browser failed to open, display the URL for manual copy
|
|
47
|
+
if (!browserOpened) {
|
|
48
|
+
this.terminal.log('\nBrowser failed to open automatically.');
|
|
49
|
+
this.terminal.log('Please open this URL in your browser:');
|
|
50
|
+
this.terminal.log(authContext.authUrl);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// Wait for callback with 5 minute timeout
|
|
54
|
+
const { code } = await this.callbackHandler.waitForCallback(authContext.state, 5 * 60 * 1000);
|
|
55
|
+
const authTokenData = await this.authService.exchangeCodeForToken(code, authContext, redirectUri);
|
|
56
|
+
const user = await this.userService.getCurrentUser(authTokenData.accessToken, authTokenData.sessionKey);
|
|
57
|
+
const authToken = new AuthToken({
|
|
58
|
+
accessToken: authTokenData.accessToken,
|
|
59
|
+
expiresAt: authTokenData.expiresAt,
|
|
60
|
+
refreshToken: authTokenData.refreshToken,
|
|
61
|
+
sessionKey: authTokenData.sessionKey,
|
|
62
|
+
tokenType: authTokenData.tokenType,
|
|
63
|
+
userEmail: user.email,
|
|
64
|
+
userId: user.id,
|
|
65
|
+
});
|
|
66
|
+
await this.tokenStore.save(authToken);
|
|
67
|
+
await this.trackingService.track('auth:sign_in', { status: 'finished' });
|
|
68
|
+
this.terminal.log(`Logged in as ${user.email}`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// Throw error to let oclif handle display
|
|
72
|
+
const errorMessage = error instanceof Error ? error.message : 'Authentication failed';
|
|
73
|
+
await this.trackingService.track('auth:sign_in', { message: errorMessage, status: 'error' });
|
|
74
|
+
this.terminal.error(errorMessage);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof DiscoveryError) {
|
|
79
|
+
const errorMessage = `Failed to configure authentication: ${error.message}\n` +
|
|
80
|
+
'Please check your network connection and try again.';
|
|
81
|
+
await this.trackingService.track('auth:sign_in', { message: errorMessage, status: 'error' });
|
|
82
|
+
this.terminal.error(errorMessage);
|
|
83
|
+
}
|
|
84
|
+
// Throw error to let oclif handle display
|
|
85
|
+
const errorMessage = error instanceof Error ? error.message : 'Authentication failed';
|
|
86
|
+
await this.trackingService.track('auth:sign_in', { message: errorMessage, status: 'error' });
|
|
87
|
+
this.terminal.error(errorMessage);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
// Always cleanup server
|
|
91
|
+
await this.callbackHandler.stop();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IOnboardingPreferenceStore } from "../../core/interfaces/i-onboarding-preference-store.js";
|
|
2
|
+
import type { ITerminal } from "../../core/interfaces/i-terminal.js";
|
|
3
|
+
import type { ITokenStore } from "../../core/interfaces/i-token-store.js";
|
|
4
|
+
import type { ITrackingService } from "../../core/interfaces/i-tracking-service.js";
|
|
5
|
+
import type { ILogoutUseCase } from "../../core/interfaces/usecase/i-logout-use-case.js";
|
|
6
|
+
export interface LogoutUseCaseDeps {
|
|
7
|
+
onboardingPreferenceStore: IOnboardingPreferenceStore;
|
|
8
|
+
terminal: ITerminal;
|
|
9
|
+
tokenStore: ITokenStore;
|
|
10
|
+
trackingService: ITrackingService;
|
|
11
|
+
}
|
|
12
|
+
export declare class LogoutUseCase implements ILogoutUseCase {
|
|
13
|
+
private readonly onboardingPreferenceStore;
|
|
14
|
+
private readonly terminal;
|
|
15
|
+
private readonly tokenStore;
|
|
16
|
+
private readonly trackingService;
|
|
17
|
+
constructor(deps: LogoutUseCaseDeps);
|
|
18
|
+
protected confirmLogout(userEmail: string): Promise<boolean>;
|
|
19
|
+
run(options: {
|
|
20
|
+
skipConfirmation: boolean;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class LogoutUseCase {
|
|
2
|
+
onboardingPreferenceStore;
|
|
3
|
+
terminal;
|
|
4
|
+
tokenStore;
|
|
5
|
+
trackingService;
|
|
6
|
+
constructor(deps) {
|
|
7
|
+
this.onboardingPreferenceStore = deps.onboardingPreferenceStore;
|
|
8
|
+
this.terminal = deps.terminal;
|
|
9
|
+
this.tokenStore = deps.tokenStore;
|
|
10
|
+
this.trackingService = deps.trackingService;
|
|
11
|
+
}
|
|
12
|
+
async confirmLogout(userEmail) {
|
|
13
|
+
return this.terminal.confirm({
|
|
14
|
+
default: true,
|
|
15
|
+
message: `Logging out ${userEmail}. Are you sure?`,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async run(options) {
|
|
19
|
+
try {
|
|
20
|
+
const token = await this.tokenStore.load();
|
|
21
|
+
if (token === undefined) {
|
|
22
|
+
this.terminal.log("You are not currently logged in.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!options.skipConfirmation) {
|
|
26
|
+
const confirmed = await this.confirmLogout(token.userEmail);
|
|
27
|
+
if (!confirmed) {
|
|
28
|
+
this.terminal.log("Logout cancelled");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
await this.trackingService.track("auth:signed_out");
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Tracking failures should not block logout
|
|
37
|
+
}
|
|
38
|
+
await this.tokenStore.clear();
|
|
39
|
+
await this.onboardingPreferenceStore.clear();
|
|
40
|
+
this.terminal.log("Successfully logged out.");
|
|
41
|
+
this.terminal.log("Run 'brv login' to authenticate again.");
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error instanceof Error && error.message.includes("keychain")) {
|
|
45
|
+
this.terminal.error("Unable to access system keychain. Please check your system permissions and try again.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.terminal.error(error instanceof Error ? error.message : "Logout failed");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AuthToken } from '../../core/domain/entities/auth-token.js';
|
|
2
|
+
import type { BrvConfig } from '../../core/domain/entities/brv-config.js';
|
|
3
|
+
import type { ICogitPullService } from '../../core/interfaces/i-cogit-pull-service.js';
|
|
4
|
+
import type { IContextTreeSnapshotService } from '../../core/interfaces/i-context-tree-snapshot-service.js';
|
|
5
|
+
import type { IContextTreeWriterService } from '../../core/interfaces/i-context-tree-writer-service.js';
|
|
6
|
+
import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
|
|
7
|
+
import type { ITerminal } from '../../core/interfaces/i-terminal.js';
|
|
8
|
+
import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
|
|
9
|
+
import type { ITrackingService } from '../../core/interfaces/i-tracking-service.js';
|
|
10
|
+
import type { IPullUseCase } from '../../core/interfaces/usecase/i-pull-use-case.js';
|
|
11
|
+
export interface PullUseCaseOptions {
|
|
12
|
+
cogitPullService: ICogitPullService;
|
|
13
|
+
contextTreeSnapshotService: IContextTreeSnapshotService;
|
|
14
|
+
contextTreeWriterService: IContextTreeWriterService;
|
|
15
|
+
projectConfigStore: IProjectConfigStore;
|
|
16
|
+
terminal: ITerminal;
|
|
17
|
+
tokenStore: ITokenStore;
|
|
18
|
+
trackingService: ITrackingService;
|
|
19
|
+
}
|
|
20
|
+
export declare class PullUseCase implements IPullUseCase {
|
|
21
|
+
private readonly cogitPullService;
|
|
22
|
+
private readonly contextTreeSnapshotService;
|
|
23
|
+
private readonly contextTreeWriterService;
|
|
24
|
+
private readonly projectConfigStore;
|
|
25
|
+
private readonly terminal;
|
|
26
|
+
private readonly tokenStore;
|
|
27
|
+
private readonly trackingService;
|
|
28
|
+
constructor(options: PullUseCaseOptions);
|
|
29
|
+
protected checkLocalChanges(): Promise<boolean>;
|
|
30
|
+
protected checkProjectInit(): Promise<BrvConfig>;
|
|
31
|
+
run(options: {
|
|
32
|
+
branch: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
protected validateAuth(): Promise<AuthToken | undefined>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { WorkspaceNotInitializedError } from '../cipher/validation/workspace-validator.js';
|
|
2
|
+
export class PullUseCase {
|
|
3
|
+
cogitPullService;
|
|
4
|
+
contextTreeSnapshotService;
|
|
5
|
+
contextTreeWriterService;
|
|
6
|
+
projectConfigStore;
|
|
7
|
+
terminal;
|
|
8
|
+
tokenStore;
|
|
9
|
+
trackingService;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.cogitPullService = options.cogitPullService;
|
|
12
|
+
this.contextTreeSnapshotService = options.contextTreeSnapshotService;
|
|
13
|
+
this.contextTreeWriterService = options.contextTreeWriterService;
|
|
14
|
+
this.projectConfigStore = options.projectConfigStore;
|
|
15
|
+
this.terminal = options.terminal;
|
|
16
|
+
this.tokenStore = options.tokenStore;
|
|
17
|
+
this.trackingService = options.trackingService;
|
|
18
|
+
}
|
|
19
|
+
async checkLocalChanges() {
|
|
20
|
+
const changes = await this.contextTreeSnapshotService.getChanges();
|
|
21
|
+
return changes.added.length > 0 || changes.modified.length > 0 || changes.deleted.length > 0;
|
|
22
|
+
}
|
|
23
|
+
async checkProjectInit() {
|
|
24
|
+
const projectConfig = await this.projectConfigStore.read();
|
|
25
|
+
if (projectConfig === undefined) {
|
|
26
|
+
throw new WorkspaceNotInitializedError('Project not initialized. Please run "brv init" to select your team and workspace.', '.brv');
|
|
27
|
+
}
|
|
28
|
+
return projectConfig;
|
|
29
|
+
}
|
|
30
|
+
async run(options) {
|
|
31
|
+
try {
|
|
32
|
+
await this.trackingService.track('mem:pull');
|
|
33
|
+
const token = await this.validateAuth();
|
|
34
|
+
if (!token)
|
|
35
|
+
return;
|
|
36
|
+
const projectConfig = await this.checkProjectInit();
|
|
37
|
+
// Check for local changes
|
|
38
|
+
this.terminal.actionStart('Checking for local Context Tree changes');
|
|
39
|
+
const hasLocalChanges = await this.checkLocalChanges();
|
|
40
|
+
this.terminal.actionStop();
|
|
41
|
+
if (hasLocalChanges) {
|
|
42
|
+
this.terminal.log('You have local changes that have not been pushed. Run "brv push" first.');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Pull from CoGit
|
|
46
|
+
this.terminal.log('Pulling from ByteRover...');
|
|
47
|
+
const snapshot = await this.cogitPullService.pull({
|
|
48
|
+
accessToken: token.accessToken,
|
|
49
|
+
branch: options.branch,
|
|
50
|
+
sessionKey: token.sessionKey,
|
|
51
|
+
spaceId: projectConfig.spaceId,
|
|
52
|
+
teamId: projectConfig.teamId,
|
|
53
|
+
});
|
|
54
|
+
// Sync files to local context tree
|
|
55
|
+
this.terminal.actionStart('Syncing context files');
|
|
56
|
+
const syncResult = await this.contextTreeWriterService.sync({ files: snapshot.files });
|
|
57
|
+
this.terminal.actionStop();
|
|
58
|
+
// Update snapshot ONLY after successful sync
|
|
59
|
+
await this.contextTreeSnapshotService.saveSnapshot();
|
|
60
|
+
// Success message
|
|
61
|
+
this.terminal.log('\n✓ Successfully pulled context tree from ByteRover memory storage!');
|
|
62
|
+
this.terminal.log(` Branch: ${options.branch}`);
|
|
63
|
+
this.terminal.log(` Commit: ${snapshot.commitSha.slice(0, 7)}`);
|
|
64
|
+
this.terminal.log(` Added: ${syncResult.added.length}, Edited: ${syncResult.edited.length}, Deleted: ${syncResult.deleted.length}`);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
// Stop action if it's in progress
|
|
68
|
+
this.terminal.actionStop();
|
|
69
|
+
if (error instanceof WorkspaceNotInitializedError) {
|
|
70
|
+
this.terminal.log('Project not initialized. Please run "brv init" to select your team and workspace.');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const message = error instanceof Error ? error.message : 'Pull failed';
|
|
74
|
+
this.terminal.error(`Failed to pull: ${message}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async validateAuth() {
|
|
78
|
+
const token = await this.tokenStore.load();
|
|
79
|
+
if (token === undefined) {
|
|
80
|
+
this.terminal.error('Not authenticated. Run "brv login" first.');
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
if (!token.isValid()) {
|
|
84
|
+
this.terminal.error('Authentication token expired. Run "brv login" again.');
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return token;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ICogitPushService } from '../../core/interfaces/i-cogit-push-service.js';
|
|
2
|
+
import type { IContextFileReader } from '../../core/interfaces/i-context-file-reader.js';
|
|
3
|
+
import type { IContextTreeSnapshotService } from '../../core/interfaces/i-context-tree-snapshot-service.js';
|
|
4
|
+
import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
|
|
5
|
+
import type { ITerminal } from '../../core/interfaces/i-terminal.js';
|
|
6
|
+
import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
|
|
7
|
+
import type { ITrackingService } from '../../core/interfaces/i-tracking-service.js';
|
|
8
|
+
import type { IPushUseCase } from '../../core/interfaces/usecase/i-push-use-case.js';
|
|
9
|
+
export interface PushUseCaseOptions {
|
|
10
|
+
cogitPushService: ICogitPushService;
|
|
11
|
+
contextFileReader: IContextFileReader;
|
|
12
|
+
contextTreeSnapshotService: IContextTreeSnapshotService;
|
|
13
|
+
projectConfigStore: IProjectConfigStore;
|
|
14
|
+
terminal: ITerminal;
|
|
15
|
+
tokenStore: ITokenStore;
|
|
16
|
+
trackingService: ITrackingService;
|
|
17
|
+
webAppUrl: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class PushUseCase implements IPushUseCase {
|
|
20
|
+
private readonly cogitPushService;
|
|
21
|
+
private readonly contextFileReader;
|
|
22
|
+
private readonly contextTreeSnapshotService;
|
|
23
|
+
private readonly projectConfigStore;
|
|
24
|
+
private readonly terminal;
|
|
25
|
+
private readonly tokenStore;
|
|
26
|
+
private readonly trackingService;
|
|
27
|
+
private readonly webAppUrl;
|
|
28
|
+
constructor(options: PushUseCaseOptions);
|
|
29
|
+
run(options: {
|
|
30
|
+
branch: string;
|
|
31
|
+
skipConfirmation: boolean;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
private buildSpaceUrl;
|
|
34
|
+
private checkProjectInit;
|
|
35
|
+
private confirmPush;
|
|
36
|
+
private validateAuth;
|
|
37
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { WorkspaceNotInitializedError } from '../cipher/validation/workspace-validator.js';
|
|
2
|
+
import { mapToPushContexts } from '../cogit/context-tree-to-push-context-mapper.js';
|
|
3
|
+
export class PushUseCase {
|
|
4
|
+
cogitPushService;
|
|
5
|
+
contextFileReader;
|
|
6
|
+
contextTreeSnapshotService;
|
|
7
|
+
projectConfigStore;
|
|
8
|
+
terminal;
|
|
9
|
+
tokenStore;
|
|
10
|
+
trackingService;
|
|
11
|
+
webAppUrl;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.cogitPushService = options.cogitPushService;
|
|
14
|
+
this.contextFileReader = options.contextFileReader;
|
|
15
|
+
this.contextTreeSnapshotService = options.contextTreeSnapshotService;
|
|
16
|
+
this.projectConfigStore = options.projectConfigStore;
|
|
17
|
+
this.terminal = options.terminal;
|
|
18
|
+
this.tokenStore = options.tokenStore;
|
|
19
|
+
this.trackingService = options.trackingService;
|
|
20
|
+
this.webAppUrl = options.webAppUrl;
|
|
21
|
+
}
|
|
22
|
+
async run(options) {
|
|
23
|
+
try {
|
|
24
|
+
await this.trackingService.track('mem:push');
|
|
25
|
+
const token = await this.validateAuth();
|
|
26
|
+
if (!token)
|
|
27
|
+
return;
|
|
28
|
+
const projectConfig = await this.checkProjectInit();
|
|
29
|
+
// Check for changes
|
|
30
|
+
this.terminal.actionStart('Checking for Context Tree changes');
|
|
31
|
+
const contextTreeChanges = await this.contextTreeSnapshotService.getChanges();
|
|
32
|
+
this.terminal.actionStop();
|
|
33
|
+
if (contextTreeChanges.added.length === 0 &&
|
|
34
|
+
contextTreeChanges.modified.length === 0 &&
|
|
35
|
+
contextTreeChanges.deleted.length === 0) {
|
|
36
|
+
this.terminal.log('No context changes to push.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Prompt for confirmation unless skipConfirmation is true
|
|
40
|
+
if (!options.skipConfirmation) {
|
|
41
|
+
const confirmed = await this.confirmPush(projectConfig, options.branch);
|
|
42
|
+
if (!confirmed) {
|
|
43
|
+
this.terminal.log('Push cancelled.');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Read and prepare files
|
|
48
|
+
this.terminal.actionStart('Reading context files');
|
|
49
|
+
const [addedFiles, modifiedFiles] = await Promise.all([
|
|
50
|
+
this.contextFileReader.readMany(contextTreeChanges.added),
|
|
51
|
+
this.contextFileReader.readMany(contextTreeChanges.modified),
|
|
52
|
+
]);
|
|
53
|
+
this.terminal.actionStop();
|
|
54
|
+
const pushContexts = mapToPushContexts({
|
|
55
|
+
addedFiles,
|
|
56
|
+
deletedPaths: contextTreeChanges.deleted,
|
|
57
|
+
modifiedFiles,
|
|
58
|
+
});
|
|
59
|
+
if (pushContexts.length === 0) {
|
|
60
|
+
this.terminal.log('\nNo valid context files to push.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Push to CoGit (with two-request SHA flow)
|
|
64
|
+
this.terminal.log('Pushing to ByteRover...');
|
|
65
|
+
await this.cogitPushService.push({
|
|
66
|
+
accessToken: token.accessToken,
|
|
67
|
+
branch: options.branch,
|
|
68
|
+
contexts: pushContexts,
|
|
69
|
+
sessionKey: token.sessionKey,
|
|
70
|
+
spaceId: projectConfig.spaceId,
|
|
71
|
+
teamId: projectConfig.teamId,
|
|
72
|
+
});
|
|
73
|
+
// Update snapshot ONLY after successful push
|
|
74
|
+
await this.contextTreeSnapshotService.saveSnapshot();
|
|
75
|
+
// Success message
|
|
76
|
+
this.terminal.log('\n✓ Successfully pushed context tree to ByteRover memory storage!');
|
|
77
|
+
this.terminal.log(` Branch: ${options.branch}`);
|
|
78
|
+
this.terminal.log(` Added: ${addedFiles.length}, Edited: ${modifiedFiles.length}, Deleted: ${contextTreeChanges.deleted.length}`);
|
|
79
|
+
this.terminal.log(` View: ${this.buildSpaceUrl(projectConfig.teamName, projectConfig.spaceName)}`);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// Stop action if it's in progress
|
|
83
|
+
this.terminal.actionStop();
|
|
84
|
+
if (error instanceof WorkspaceNotInitializedError) {
|
|
85
|
+
this.terminal.log('Project not initialized. Please run "brv init" to select your team and workspace.');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// For other errors, to properly display error before exit
|
|
89
|
+
const message = error instanceof Error ? error.message : 'Push failed';
|
|
90
|
+
this.terminal.error(`Failed to push: ${message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
buildSpaceUrl(teamName, spaceName) {
|
|
94
|
+
return `${this.webAppUrl}/${teamName}/${spaceName}`;
|
|
95
|
+
}
|
|
96
|
+
async checkProjectInit() {
|
|
97
|
+
const projectConfig = await this.projectConfigStore.read();
|
|
98
|
+
if (projectConfig === undefined) {
|
|
99
|
+
throw new WorkspaceNotInitializedError('Project not initialized. Please run "brv init" to select your team and workspace.', '.brv');
|
|
100
|
+
}
|
|
101
|
+
return projectConfig;
|
|
102
|
+
}
|
|
103
|
+
async confirmPush(projectConfig, branch) {
|
|
104
|
+
this.terminal.log('\nYou are about to push to ByteRover memory storage:');
|
|
105
|
+
this.terminal.log(` Space: ${projectConfig.spaceName}`);
|
|
106
|
+
this.terminal.log(` Branch: ${branch}`);
|
|
107
|
+
return this.terminal.confirm({
|
|
108
|
+
default: false,
|
|
109
|
+
message: 'Push to ByteRover?',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async validateAuth() {
|
|
113
|
+
const token = await this.tokenStore.load();
|
|
114
|
+
if (token === undefined) {
|
|
115
|
+
this.terminal.error('Not authenticated. Run "brv login" first.');
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
if (!token.isValid()) {
|
|
119
|
+
this.terminal.error('Authentication token expired. Run "brv login" again.');
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
return token;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { BrvConfig } from '../../core/domain/entities/brv-config.js';
|
|
2
|
+
import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
|
|
3
|
+
import type { ITerminal } from '../../core/interfaces/i-terminal.js';
|
|
4
|
+
import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
|
|
5
|
+
import type { ITrackingService } from '../../core/interfaces/i-tracking-service.js';
|
|
6
|
+
import type { IQueryUseCase, QueryUseCaseRunOptions } from '../../core/interfaces/usecase/i-query-use-case.js';
|
|
7
|
+
import { CipherAgent } from '../cipher/cipher-agent.js';
|
|
8
|
+
export interface QueryUseCaseOptions {
|
|
9
|
+
projectConfigStore: IProjectConfigStore;
|
|
10
|
+
terminal: ITerminal;
|
|
11
|
+
tokenStore: ITokenStore;
|
|
12
|
+
trackingService: ITrackingService;
|
|
13
|
+
}
|
|
14
|
+
export declare class QueryUseCase implements IQueryUseCase {
|
|
15
|
+
private readonly projectConfigStore;
|
|
16
|
+
private readonly terminal;
|
|
17
|
+
private readonly tokenStore;
|
|
18
|
+
private readonly trackingService;
|
|
19
|
+
constructor(options: QueryUseCaseOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Create CipherAgent instance. Protected to allow test overrides.
|
|
22
|
+
*/
|
|
23
|
+
protected createCipherAgent(llmConfig: any, brvConfig: BrvConfig): CipherAgent;
|
|
24
|
+
/**
|
|
25
|
+
* Generate a unique session ID for the query agent.
|
|
26
|
+
* Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
|
|
27
|
+
*/
|
|
28
|
+
protected generateSessionId(): string;
|
|
29
|
+
run(options: QueryUseCaseRunOptions): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Create result summary for tool call
|
|
32
|
+
*/
|
|
33
|
+
private createResultSummary;
|
|
34
|
+
/**
|
|
35
|
+
* Extract summary from curate tool result
|
|
36
|
+
*/
|
|
37
|
+
private extractCurateSummary;
|
|
38
|
+
/**
|
|
39
|
+
* Format curate tool operation summary
|
|
40
|
+
*/
|
|
41
|
+
private formatCurateResult;
|
|
42
|
+
/**
|
|
43
|
+
* Format items count from list_directory result
|
|
44
|
+
*/
|
|
45
|
+
private formatItemsCount;
|
|
46
|
+
/**
|
|
47
|
+
* Format matches count from grep_content result
|
|
48
|
+
*/
|
|
49
|
+
private formatMatchesCount;
|
|
50
|
+
/**
|
|
51
|
+
* Format tool result summary for display
|
|
52
|
+
*/
|
|
53
|
+
private formatToolResultSummary;
|
|
54
|
+
/**
|
|
55
|
+
* Format topics count from find_knowledge_topics result
|
|
56
|
+
*/
|
|
57
|
+
private formatTopicsCount;
|
|
58
|
+
/**
|
|
59
|
+
* Get user-friendly description for a tool
|
|
60
|
+
*
|
|
61
|
+
* @param toolName - Name of the tool
|
|
62
|
+
* @param args - Tool arguments
|
|
63
|
+
* @returns User-friendly description
|
|
64
|
+
*/
|
|
65
|
+
private getToolDescription;
|
|
66
|
+
/**
|
|
67
|
+
* Handle workspace not initialized error
|
|
68
|
+
*/
|
|
69
|
+
private handleWorkspaceError;
|
|
70
|
+
/**
|
|
71
|
+
* Setup event listeners for CipherAgent
|
|
72
|
+
*/
|
|
73
|
+
private setupEventListeners;
|
|
74
|
+
/**
|
|
75
|
+
* Setup tool call tracking to persist in database
|
|
76
|
+
*/
|
|
77
|
+
private setupToolCallTracking;
|
|
78
|
+
}
|