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
package/dist/commands/foo.js
CHANGED
|
@@ -3,11 +3,14 @@ import { isDevelopment } from '../config/environment.js';
|
|
|
3
3
|
import { CodingAgentLogParser } from '../infra/cipher/parsers/coding-agent-log-parser.js';
|
|
4
4
|
import { CodingAgentLogWatcher } from '../infra/cipher/watcher/coding-agent-log-watcher.js';
|
|
5
5
|
import { ProjectConfigStore } from '../infra/config/file-config-store.js';
|
|
6
|
+
import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
|
|
6
7
|
import { FileWatcherService } from '../infra/watcher/file-watcher-service.js';
|
|
7
8
|
export default class Foo extends Command {
|
|
8
9
|
static description = 'Purely for testing CodingAgentLogWatcher [Development only]';
|
|
9
10
|
static hidden = !isDevelopment();
|
|
11
|
+
terminal = {};
|
|
10
12
|
async createServices() {
|
|
13
|
+
this.terminal = new OclifTerminal(this);
|
|
11
14
|
const projectConfigStore = new ProjectConfigStore();
|
|
12
15
|
const fileWatcherService = new FileWatcherService();
|
|
13
16
|
const codingAgentLogParser = new CodingAgentLogParser();
|
|
@@ -18,43 +21,45 @@ export default class Foo extends Command {
|
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
async run() {
|
|
24
|
+
const { codingAgentLogWatcher, projectConfigStore } = await this.createServices();
|
|
21
25
|
if (!isDevelopment()) {
|
|
22
|
-
this.error('This command is only available in development environment');
|
|
26
|
+
this.terminal.error('This command is only available in development environment');
|
|
27
|
+
return;
|
|
23
28
|
}
|
|
24
|
-
const { codingAgentLogWatcher, projectConfigStore } = await this.createServices();
|
|
25
29
|
const projectConfig = await projectConfigStore.read();
|
|
26
30
|
if (projectConfig === undefined) {
|
|
27
|
-
this.error('No project config found. Run "brv init" first.');
|
|
31
|
+
this.terminal.error('No project config found. Run "brv init" first.');
|
|
32
|
+
return;
|
|
28
33
|
}
|
|
29
34
|
// Defensive checking nill
|
|
30
35
|
if (projectConfig.chatLogPath === undefined) {
|
|
31
|
-
this.error('No chat log path configured in project config. Run "brv init" first.');
|
|
36
|
+
this.terminal.error('No chat log path configured in project config. Run "brv init" first.');
|
|
32
37
|
}
|
|
33
38
|
if (projectConfig.ide === undefined) {
|
|
34
|
-
this.error('No coding agent selected. Run "brv init" first.');
|
|
39
|
+
this.terminal.error('No coding agent selected. Run "brv init" first.');
|
|
35
40
|
}
|
|
36
|
-
this.log(`Watching ${projectConfig.ide} log files...`);
|
|
41
|
+
this.terminal.log(`Watching ${projectConfig.ide} log files...`);
|
|
37
42
|
await codingAgentLogWatcher.start({
|
|
38
43
|
codingAgentInfo: {
|
|
39
44
|
chatLogPath: projectConfig.chatLogPath,
|
|
40
45
|
name: projectConfig.ide,
|
|
41
46
|
},
|
|
42
47
|
onCleanSession: (cleanSession) => new Promise((resolve) => {
|
|
43
|
-
this.log(`New Clean Session from ${cleanSession.type}:`);
|
|
44
|
-
this.log(`Clean Session title: ${cleanSession.title}`);
|
|
45
|
-
this.log('Clean Session messages:');
|
|
48
|
+
this.terminal.log(`New Clean Session from ${cleanSession.type}:`);
|
|
49
|
+
this.terminal.log(`Clean Session title: ${cleanSession.title}`);
|
|
50
|
+
this.terminal.log('Clean Session messages:');
|
|
46
51
|
for (const message of cleanSession.messages) {
|
|
47
|
-
this.log(`${JSON.stringify(message, undefined, 2)}]\n`);
|
|
52
|
+
this.terminal.log(`${JSON.stringify(message, undefined, 2)}]\n`);
|
|
48
53
|
}
|
|
49
|
-
this.log(`Clean Session ID: ${cleanSession.id}`);
|
|
50
|
-
this.log(`Clean Session Metadata: ${JSON.stringify(cleanSession.metadata, undefined, 2)}`);
|
|
54
|
+
this.terminal.log(`Clean Session ID: ${cleanSession.id}`);
|
|
55
|
+
this.terminal.log(`Clean Session Metadata: ${JSON.stringify(cleanSession.metadata, undefined, 2)}`);
|
|
51
56
|
resolve();
|
|
52
|
-
this.log(`Clean Session timestamp: ${cleanSession.timestamp}`);
|
|
53
|
-
this.log(`Clean Session workspace paths:`);
|
|
57
|
+
this.terminal.log(`Clean Session timestamp: ${cleanSession.timestamp}`);
|
|
58
|
+
this.terminal.log(`Clean Session workspace paths:`);
|
|
54
59
|
for (const workspacePath of cleanSession.workspacePaths) {
|
|
55
|
-
this.log(`${workspacePath}`);
|
|
60
|
+
this.terminal.log(`${workspacePath}`);
|
|
56
61
|
}
|
|
57
|
-
this.log('\n\n');
|
|
62
|
+
this.terminal.log('\n\n');
|
|
58
63
|
}),
|
|
59
64
|
});
|
|
60
65
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { ProjectConfigStore } from '../infra/config/file-config-store.js';
|
|
3
|
+
import { startRepl } from '../infra/repl/repl-startup.js';
|
|
4
|
+
import { FileGlobalConfigStore } from "../infra/storage/file-global-config-store.js";
|
|
5
|
+
import { FileOnboardingPreferenceStore } from '../infra/storage/file-onboarding-preference-store.js';
|
|
6
|
+
import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
|
|
7
|
+
import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
|
|
8
|
+
export default class Main extends Command {
|
|
9
|
+
static description = 'ByteRover CLI - Interactive REPL';
|
|
10
|
+
/**
|
|
11
|
+
* Hide from help listing since this is the default command (only 'brv')
|
|
12
|
+
*/
|
|
13
|
+
static hidden = true;
|
|
14
|
+
async run() {
|
|
15
|
+
// Check if running in an interactive terminal
|
|
16
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
17
|
+
this.log('ByteRover REPL requires an interactive terminal.');
|
|
18
|
+
this.log("Run 'brv --help' for available commands.");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const tokenStore = new KeychainTokenStore();
|
|
22
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
23
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
24
|
+
const onboardingPreferenceStore = new FileOnboardingPreferenceStore();
|
|
25
|
+
// Start the interactive REPL
|
|
26
|
+
await startRepl({
|
|
27
|
+
onboardingPreferenceStore,
|
|
28
|
+
projectConfigStore: new ProjectConfigStore(),
|
|
29
|
+
tokenStore,
|
|
30
|
+
trackingService,
|
|
31
|
+
version: this.config.version,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/commands/query.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import type {
|
|
3
|
-
import type { ITrackingService } from '../core/interfaces/i-tracking-service.js';
|
|
2
|
+
import type { IQueryUseCase } from '../core/interfaces/usecase/i-query-use-case.js';
|
|
4
3
|
export default class Query extends Command {
|
|
5
4
|
static args: {
|
|
6
5
|
query: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -13,51 +12,6 @@ export default class Query extends Command {
|
|
|
13
12
|
verbose?: import("@oclif/core/interfaces").BooleanFlag<boolean> | undefined;
|
|
14
13
|
};
|
|
15
14
|
static strict: boolean;
|
|
16
|
-
|
|
17
|
-
oclif?: {
|
|
18
|
-
exit: number;
|
|
19
|
-
};
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
protected createServices(): {
|
|
22
|
-
projectConfigStore: IProjectConfigStore;
|
|
23
|
-
trackingService: ITrackingService;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Generate a unique session ID for the query agent.
|
|
27
|
-
* Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
|
|
28
|
-
*/
|
|
29
|
-
protected generateSessionId(): string;
|
|
15
|
+
protected createUseCase(): IQueryUseCase;
|
|
30
16
|
run(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Format items count from list_directory result
|
|
33
|
-
*/
|
|
34
|
-
private formatItemsCount;
|
|
35
|
-
/**
|
|
36
|
-
* Format matches count from grep_content result
|
|
37
|
-
*/
|
|
38
|
-
private formatMatchesCount;
|
|
39
|
-
/**
|
|
40
|
-
* Format tool result summary for display
|
|
41
|
-
*/
|
|
42
|
-
private formatToolResultSummary;
|
|
43
|
-
/**
|
|
44
|
-
* Format topics count from find_knowledge_topics result
|
|
45
|
-
*/
|
|
46
|
-
private formatTopicsCount;
|
|
47
|
-
/**
|
|
48
|
-
* Get user-friendly description for a tool
|
|
49
|
-
*
|
|
50
|
-
* @param toolName - Name of the tool
|
|
51
|
-
* @param args - Tool arguments
|
|
52
|
-
* @returns User-friendly description
|
|
53
|
-
*/
|
|
54
|
-
private getToolDescription;
|
|
55
|
-
/**
|
|
56
|
-
* Handle workspace not initialized error
|
|
57
|
-
*/
|
|
58
|
-
private handleWorkspaceError;
|
|
59
|
-
/**
|
|
60
|
-
* Setup event listeners for CipherAgent
|
|
61
|
-
*/
|
|
62
|
-
private setupEventListeners;
|
|
63
17
|
}
|
package/dist/commands/query.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
3
|
-
import { getCurrentConfig, isDevelopment } from '../config/environment.js';
|
|
4
|
-
import { PROJECT } from '../constants.js';
|
|
5
|
-
import { CipherAgent } from '../infra/cipher/cipher-agent.js';
|
|
6
|
-
import { ExitCode, ExitError, exitWithCode } from '../infra/cipher/exit-codes.js';
|
|
7
|
-
import { WorkspaceNotInitializedError } from '../infra/cipher/validation/workspace-validator.js';
|
|
2
|
+
import { isDevelopment } from '../config/environment.js';
|
|
8
3
|
import { ProjectConfigStore } from '../infra/config/file-config-store.js';
|
|
4
|
+
import { FileGlobalConfigStore } from '../infra/storage/file-global-config-store.js';
|
|
9
5
|
import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
|
|
6
|
+
import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
|
|
10
7
|
import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
|
|
11
|
-
import {
|
|
12
|
-
import { formatToolCall, formatToolResult } from '../utils/tool-display-formatter.js';
|
|
8
|
+
import { QueryUseCase } from '../infra/usecase/query-use-case.js';
|
|
13
9
|
export default class Query extends Command {
|
|
14
10
|
static args = {
|
|
15
11
|
query: Args.string({
|
|
@@ -63,288 +59,24 @@ Bad:
|
|
|
63
59
|
: {}),
|
|
64
60
|
};
|
|
65
61
|
static strict = false;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
// Backwards compatibility: also check oclif.exit property
|
|
73
|
-
if (error.oclif?.exit !== undefined) {
|
|
74
|
-
// Error already displayed by exitWithCode, silently exit
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// For other errors, re-throw to let oclif handle them
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
createServices() {
|
|
81
|
-
return {
|
|
62
|
+
createUseCase() {
|
|
63
|
+
const tokenStore = new KeychainTokenStore();
|
|
64
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
65
|
+
return new QueryUseCase({
|
|
82
66
|
projectConfigStore: new ProjectConfigStore(),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* Generate a unique session ID for the query agent.
|
|
88
|
-
* Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
|
|
89
|
-
*/
|
|
90
|
-
generateSessionId() {
|
|
91
|
-
return randomUUID();
|
|
67
|
+
terminal: new OclifTerminal(this),
|
|
68
|
+
tokenStore,
|
|
69
|
+
trackingService: new MixpanelTrackingService({ globalConfigStore, tokenStore }),
|
|
70
|
+
});
|
|
92
71
|
}
|
|
93
72
|
async run() {
|
|
94
73
|
const { argv, flags } = await this.parse(Query);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
// Load project config
|
|
104
|
-
const brvConfig = await projectConfigStore.read();
|
|
105
|
-
// Validate workspace is initialized
|
|
106
|
-
if (!brvConfig) {
|
|
107
|
-
throw new WorkspaceNotInitializedError('Project not initialized. Please run "brv init" to select your team and workspace.', '.brv');
|
|
108
|
-
}
|
|
109
|
-
// Create LLM config
|
|
110
|
-
const model = flags.model ?? (flags.apiKey ? 'google/gemini-2.5-pro' : 'gemini-2.5-pro');
|
|
111
|
-
const envConfig = getCurrentConfig();
|
|
112
|
-
const llmConfig = {
|
|
113
|
-
accessToken: token.accessToken,
|
|
114
|
-
fileSystemConfig: { workingDirectory: process.cwd() },
|
|
115
|
-
grpcEndpoint: envConfig.llmGrpcEndpoint,
|
|
116
|
-
maxIterations: 5,
|
|
117
|
-
maxTokens: 2048,
|
|
118
|
-
model,
|
|
119
|
-
openRouterApiKey: flags.apiKey,
|
|
120
|
-
projectId: PROJECT,
|
|
121
|
-
sessionKey: token.sessionKey,
|
|
122
|
-
temperature: 0.7,
|
|
123
|
-
topK: 10,
|
|
124
|
-
topP: 0.95,
|
|
125
|
-
verbose: flags.verbose ?? false,
|
|
126
|
-
};
|
|
127
|
-
// Create and start CipherAgent
|
|
128
|
-
const agent = new CipherAgent(llmConfig, brvConfig);
|
|
129
|
-
this.log('Querying context tree...');
|
|
130
|
-
await agent.start();
|
|
131
|
-
try {
|
|
132
|
-
const sessionId = this.generateSessionId();
|
|
133
|
-
// Setup event listeners
|
|
134
|
-
this.setupEventListeners(agent, flags.verbose ?? false);
|
|
135
|
-
// Combine all query terms from argv (everything after flags)
|
|
136
|
-
const queryTerms = argv.join(' ');
|
|
137
|
-
// Execute with autonomous mode and query commandType
|
|
138
|
-
const prompt = `Search the context tree for: ${queryTerms}`;
|
|
139
|
-
const response = await agent.execute(prompt, sessionId, {
|
|
140
|
-
executionContext: { commandType: 'query' },
|
|
141
|
-
mode: 'autonomous',
|
|
142
|
-
});
|
|
143
|
-
this.log('\nQuery Results:');
|
|
144
|
-
this.log(response);
|
|
145
|
-
// Track query
|
|
146
|
-
await trackingService.track('mem:query');
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
// console.log('Logic for agent stopping and resource cleanup may go here!')
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
if (error instanceof WorkspaceNotInitializedError) {
|
|
154
|
-
this.handleWorkspaceError(error);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
// Display context on one line, error on separate line
|
|
158
|
-
process.stderr.write('Failed to query context tree:\n');
|
|
159
|
-
exitWithCode(ExitCode.RUNTIME_ERROR, formatError(error));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Format items count from list_directory result
|
|
164
|
-
*/
|
|
165
|
-
formatItemsCount(result) {
|
|
166
|
-
if (typeof result === 'string') {
|
|
167
|
-
const lines = result.split('\n').filter((line) => line.trim());
|
|
168
|
-
return `${lines.length} items`;
|
|
169
|
-
}
|
|
170
|
-
if (Array.isArray(result)) {
|
|
171
|
-
return `${result.length} items`;
|
|
172
|
-
}
|
|
173
|
-
return '';
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Format matches count from grep_content result
|
|
177
|
-
*/
|
|
178
|
-
formatMatchesCount(result) {
|
|
179
|
-
if (typeof result === 'string') {
|
|
180
|
-
const lines = result.split('\n').filter((line) => line.trim());
|
|
181
|
-
return `${lines.length} matches found`;
|
|
182
|
-
}
|
|
183
|
-
if (Array.isArray(result)) {
|
|
184
|
-
return `${result.length} matches found`;
|
|
185
|
-
}
|
|
186
|
-
return '';
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Format tool result summary for display
|
|
190
|
-
*/
|
|
191
|
-
formatToolResultSummary(toolName, result) {
|
|
192
|
-
try {
|
|
193
|
-
switch (toolName) {
|
|
194
|
-
case 'bash_exec':
|
|
195
|
-
case 'create_knowledge_topic':
|
|
196
|
-
case 'delete_knowledge_topic':
|
|
197
|
-
case 'detect_domains':
|
|
198
|
-
case 'read_file':
|
|
199
|
-
case 'update_knowledge_topic':
|
|
200
|
-
case 'write_file': {
|
|
201
|
-
return '';
|
|
202
|
-
}
|
|
203
|
-
case 'find_knowledge_topics': {
|
|
204
|
-
return this.formatTopicsCount(result);
|
|
205
|
-
}
|
|
206
|
-
case 'grep_content': {
|
|
207
|
-
return this.formatMatchesCount(result);
|
|
208
|
-
}
|
|
209
|
-
case 'list_directory': {
|
|
210
|
-
return this.formatItemsCount(result);
|
|
211
|
-
}
|
|
212
|
-
default: {
|
|
213
|
-
return '';
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return '';
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Format topics count from find_knowledge_topics result
|
|
223
|
-
*/
|
|
224
|
-
formatTopicsCount(result) {
|
|
225
|
-
if (typeof result === 'string') {
|
|
226
|
-
try {
|
|
227
|
-
const parsed = JSON.parse(result);
|
|
228
|
-
const count = Array.isArray(parsed) ? parsed.length : Object.keys(parsed).length;
|
|
229
|
-
return `${count} topics retrieved`;
|
|
230
|
-
}
|
|
231
|
-
catch {
|
|
232
|
-
return '';
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (typeof result === 'object' && result !== null) {
|
|
236
|
-
const resultObj = result;
|
|
237
|
-
if (Array.isArray(resultObj.results)) {
|
|
238
|
-
return `${resultObj.results.length} topics retrieved`;
|
|
239
|
-
}
|
|
240
|
-
if (typeof resultObj.total === 'number') {
|
|
241
|
-
return `${resultObj.total} topics retrieved`;
|
|
242
|
-
}
|
|
243
|
-
if (Array.isArray(result)) {
|
|
244
|
-
return `${result.length} topics retrieved`;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return '';
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Get user-friendly description for a tool
|
|
251
|
-
*
|
|
252
|
-
* @param toolName - Name of the tool
|
|
253
|
-
* @param args - Tool arguments
|
|
254
|
-
* @returns User-friendly description
|
|
255
|
-
*/
|
|
256
|
-
getToolDescription(toolName, args) {
|
|
257
|
-
switch (toolName) {
|
|
258
|
-
case 'bash_exec': {
|
|
259
|
-
const cmd = String(args.command ?? '');
|
|
260
|
-
return cmd.length > 60 ? `Running command...` : `Running: ${cmd}`;
|
|
261
|
-
}
|
|
262
|
-
case 'create_knowledge_topic': {
|
|
263
|
-
return 'Creating knowledge topic...';
|
|
264
|
-
}
|
|
265
|
-
case 'find_knowledge_topics': {
|
|
266
|
-
return 'Querying knowledge base...';
|
|
267
|
-
}
|
|
268
|
-
case 'grep_content': {
|
|
269
|
-
return 'Searching context tree...';
|
|
270
|
-
}
|
|
271
|
-
case 'list_directory': {
|
|
272
|
-
return 'Listing directory...';
|
|
273
|
-
}
|
|
274
|
-
case 'read_file': {
|
|
275
|
-
return `Reading file...`;
|
|
276
|
-
}
|
|
277
|
-
case 'update_knowledge_topic': {
|
|
278
|
-
return 'Updating knowledge topic...';
|
|
279
|
-
}
|
|
280
|
-
case 'write_file': {
|
|
281
|
-
return 'Writing file...';
|
|
282
|
-
}
|
|
283
|
-
default: {
|
|
284
|
-
return 'Processing...';
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Handle workspace not initialized error
|
|
290
|
-
*/
|
|
291
|
-
handleWorkspaceError(_error) {
|
|
292
|
-
const message = 'Project not initialized. Please run "brv init" to select your team and workspace.';
|
|
293
|
-
exitWithCode(ExitCode.VALIDATION_ERROR, message);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Setup event listeners for CipherAgent
|
|
297
|
-
*/
|
|
298
|
-
setupEventListeners(agent, verbose) {
|
|
299
|
-
if (!agent.agentEventBus) {
|
|
300
|
-
throw new Error('Agent event bus not initialized');
|
|
301
|
-
}
|
|
302
|
-
const eventBus = agent.agentEventBus;
|
|
303
|
-
if (verbose) {
|
|
304
|
-
// Verbose mode: show detailed events
|
|
305
|
-
eventBus.on('llmservice:thinking', () => {
|
|
306
|
-
this.log('🤔 [Event] LLM is thinking...');
|
|
307
|
-
});
|
|
308
|
-
eventBus.on('llmservice:response', (payload) => {
|
|
309
|
-
this.log(`✅ [Event] LLM Response (${payload.provider}/${payload.model})`);
|
|
310
|
-
});
|
|
311
|
-
eventBus.on('llmservice:toolCall', (payload) => {
|
|
312
|
-
// Clear any spinner on current line before printing (use spaces instead of ANSI codes)
|
|
313
|
-
const formattedCall = formatToolCall(payload.toolName, payload.args);
|
|
314
|
-
this.log(`🔧 [Event] Tool Call: ${formattedCall}`);
|
|
315
|
-
});
|
|
316
|
-
eventBus.on('llmservice:toolResult', (payload) => {
|
|
317
|
-
const resultSummary = formatToolResult(payload.toolName, payload.success, payload.result, payload.error);
|
|
318
|
-
if (payload.success) {
|
|
319
|
-
this.log(`✓ [Event] Tool Success: ${payload.toolName} → ${resultSummary}`);
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
this.log(`✗ [Event] Tool Error: ${payload.toolName} → ${resultSummary}`);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
// NOTE: llmservice:error is handled by catch block in the run method
|
|
326
|
-
// which displays error via this.error(). DO NOT display here to avoid duplicate.
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
// Non-verbose mode: show concise tool progress with descriptions
|
|
330
|
-
eventBus.on('llmservice:toolCall', (payload) => {
|
|
331
|
-
// Clear any spinner on current line before printing (use spaces instead of ANSI codes)
|
|
332
|
-
const description = this.getToolDescription(payload.toolName, payload.args);
|
|
333
|
-
this.log(`🔧 ${payload.toolName} → ${description}`);
|
|
334
|
-
});
|
|
335
|
-
eventBus.on('llmservice:toolResult', (payload) => {
|
|
336
|
-
if (payload.success) {
|
|
337
|
-
// Show brief success summary for tool completion
|
|
338
|
-
const summary = this.formatToolResultSummary(payload.toolName, payload.result);
|
|
339
|
-
const completionText = summary ? `Complete (${summary})` : 'Complete';
|
|
340
|
-
this.log(`✅ ${payload.toolName} → ${completionText}`);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
this.log(`✗ ${payload.toolName} → Failed: ${payload.error}`);
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
// NOTE: llmservice:error is handled by catch block in the run method
|
|
347
|
-
// which displays error via this.error(). DO NOT display here to avoid duplicate.
|
|
348
|
-
}
|
|
74
|
+
const queryTerms = argv.join(' ');
|
|
75
|
+
await this.createUseCase().run({
|
|
76
|
+
apiKey: flags.apiKey,
|
|
77
|
+
model: flags.model,
|
|
78
|
+
query: queryTerms,
|
|
79
|
+
verbose: flags.verbose ?? false,
|
|
80
|
+
});
|
|
349
81
|
}
|
|
350
82
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import type {
|
|
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 { ITokenStore } from '../core/interfaces/i-token-store.js';
|
|
6
|
-
import { ITrackingService } from '../core/interfaces/i-tracking-service.js';
|
|
2
|
+
import type { IStatusUseCase } from '../core/interfaces/usecase/i-status-use-case.js';
|
|
7
3
|
export default class Status extends Command {
|
|
8
4
|
static args: {
|
|
9
5
|
directory: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
@@ -13,13 +9,6 @@ export default class Status extends Command {
|
|
|
13
9
|
static flags: {
|
|
14
10
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
11
|
};
|
|
16
|
-
|
|
17
|
-
protected createServices(): {
|
|
18
|
-
contextTreeService: IContextTreeService;
|
|
19
|
-
contextTreeSnapshotService: IContextTreeSnapshotService;
|
|
20
|
-
projectConfigStore: IProjectConfigStore;
|
|
21
|
-
tokenStore: ITokenStore;
|
|
22
|
-
trackingService: ITrackingService;
|
|
23
|
-
};
|
|
12
|
+
protected createUseCase(): IStatusUseCase;
|
|
24
13
|
run(): Promise<void>;
|
|
25
14
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { BRV_DIR, CONTEXT_TREE_DIR } from '../constants.js';
|
|
5
2
|
import { ProjectConfigStore } from '../infra/config/file-config-store.js';
|
|
6
3
|
import { FileContextTreeService } from '../infra/context-tree/file-context-tree-service.js';
|
|
7
4
|
import { FileContextTreeSnapshotService } from '../infra/context-tree/file-context-tree-snapshot-service.js';
|
|
5
|
+
import { FileGlobalConfigStore } from '../infra/storage/file-global-config-store.js';
|
|
8
6
|
import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
|
|
7
|
+
import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
|
|
9
8
|
import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
|
|
10
|
-
import {
|
|
9
|
+
import { StatusUseCase } from '../infra/usecase/status-use-case.js';
|
|
11
10
|
export default class Status extends Command {
|
|
12
11
|
static args = {
|
|
13
12
|
directory: Args.string({ description: 'Project directory (defaults to current directory)', required: false }),
|
|
@@ -29,99 +28,21 @@ export default class Status extends Command {
|
|
|
29
28
|
options: ['table', 'json'],
|
|
30
29
|
}),
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
async catch(error) {
|
|
34
|
-
// Status command should always succeed and just show status
|
|
35
|
-
// Any errors are already handled and logged in run()
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
createServices() {
|
|
31
|
+
createUseCase() {
|
|
39
32
|
const tokenStore = new KeychainTokenStore();
|
|
40
|
-
const
|
|
41
|
-
|
|
33
|
+
const globalConfigStore = new FileGlobalConfigStore();
|
|
34
|
+
const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
|
|
35
|
+
const contextTreeSnapshotService = new FileContextTreeSnapshotService();
|
|
36
|
+
return new StatusUseCase({
|
|
42
37
|
contextTreeService: new FileContextTreeService(),
|
|
43
|
-
contextTreeSnapshotService
|
|
38
|
+
contextTreeSnapshotService,
|
|
44
39
|
projectConfigStore: new ProjectConfigStore(),
|
|
40
|
+
terminal: new OclifTerminal(this),
|
|
45
41
|
tokenStore,
|
|
46
42
|
trackingService,
|
|
47
|
-
};
|
|
43
|
+
});
|
|
48
44
|
}
|
|
49
45
|
async run() {
|
|
50
|
-
|
|
51
|
-
this.log(`CLI Version: ${this.config.version}`);
|
|
52
|
-
try {
|
|
53
|
-
const token = await tokenStore.load();
|
|
54
|
-
if (token !== undefined && token.isValid()) {
|
|
55
|
-
this.log(`Status: Logged in as ${token.userEmail}`);
|
|
56
|
-
}
|
|
57
|
-
else if (token === undefined) {
|
|
58
|
-
this.log('Status: Not logged in');
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.log('Status: Session expired (login required)');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
this.log('Status: Unable to check authentication status');
|
|
66
|
-
this.warn(`Warning: ${getErrorMessage(error)}`);
|
|
67
|
-
}
|
|
68
|
-
const cwd = process.cwd();
|
|
69
|
-
this.log(`Current Directory: ${cwd}`);
|
|
70
|
-
try {
|
|
71
|
-
const isInitialized = await projectConfigStore.exists();
|
|
72
|
-
if (isInitialized) {
|
|
73
|
-
const config = await projectConfigStore.read();
|
|
74
|
-
if (config) {
|
|
75
|
-
this.log(`Project Status: Connected to ${config.teamName}/${config.spaceName}`);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this.log('Project Status: Configuration file exists but is invalid');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.log('Project Status: Not initialized');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
this.log('Project Status: Unable to read project configuration');
|
|
87
|
-
this.warn(`Warning: ${getErrorMessage(error)}`);
|
|
88
|
-
}
|
|
89
|
-
// Context tree status
|
|
90
|
-
try {
|
|
91
|
-
const contextTreeExists = await contextTreeService.exists();
|
|
92
|
-
if (!contextTreeExists) {
|
|
93
|
-
this.log('Context Tree: Not initialized');
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const hasSnapshot = await contextTreeSnapshotService.hasSnapshot();
|
|
97
|
-
// Auto-create empty snapshot if none exists (all files will show as "added")
|
|
98
|
-
if (!hasSnapshot) {
|
|
99
|
-
await contextTreeSnapshotService.initEmptySnapshot();
|
|
100
|
-
}
|
|
101
|
-
const changes = await contextTreeSnapshotService.getChanges();
|
|
102
|
-
const hasChanges = changes.added.length > 0 || changes.modified.length > 0 || changes.deleted.length > 0;
|
|
103
|
-
if (!hasChanges) {
|
|
104
|
-
this.log('Context Tree: No changes');
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const contextTreeRelPath = join(BRV_DIR, CONTEXT_TREE_DIR);
|
|
108
|
-
const formatPath = (file) => join(contextTreeRelPath, file);
|
|
109
|
-
// Build unified list with status, sort by path ascending
|
|
110
|
-
const allChanges = [
|
|
111
|
-
...changes.modified.map((f) => ({ color: chalk.red, path: f, status: 'modified:' })),
|
|
112
|
-
...changes.added.map((f) => ({ color: chalk.red, path: f, status: 'new file:' })),
|
|
113
|
-
...changes.deleted.map((f) => ({ color: chalk.red, path: f, status: 'deleted:' })),
|
|
114
|
-
].sort((a, b) => a.path.localeCompare(b.path));
|
|
115
|
-
this.log('Context Tree Changes:');
|
|
116
|
-
for (const change of allChanges) {
|
|
117
|
-
this.log(`\t${change.color(`${change.status.padEnd(10)} ${formatPath(change.path)}`)}`);
|
|
118
|
-
}
|
|
119
|
-
// Track status
|
|
120
|
-
await trackingService.track('mem:status');
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
this.log('Context Tree: Unable to check status');
|
|
124
|
-
this.warn(`Warning: ${error instanceof Error ? error.message : 'Context Tree unable to check status'}`);
|
|
125
|
-
}
|
|
46
|
+
await this.createUseCase().run({ cliVersion: this.config.version });
|
|
126
47
|
}
|
|
127
48
|
}
|