byterover-cli 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -63
- package/bin/dev.js +8 -1
- package/bin/run.js +7 -0
- package/dist/commands/cipher-agent/run.d.ts +30 -0
- package/dist/commands/cipher-agent/run.js +123 -61
- package/dist/commands/cipher-agent/set-prompt.d.ts +2 -0
- package/dist/commands/cipher-agent/set-prompt.js +13 -8
- package/dist/commands/cipher-agent/show-prompt.d.ts +2 -0
- package/dist/commands/cipher-agent/show-prompt.js +17 -12
- package/dist/commands/curate.d.ts +3 -60
- package/dist/commands/curate.js +45 -341
- package/dist/commands/foo.d.ts +4 -2
- package/dist/commands/foo.js +21 -16
- package/dist/commands/main.d.ts +9 -0
- package/dist/commands/main.js +34 -0
- package/dist/commands/query.d.ts +2 -48
- package/dist/commands/query.js +19 -287
- package/dist/commands/status.d.ts +2 -13
- package/dist/commands/status.js +12 -91
- package/dist/commands/watch.d.ts +2 -0
- package/dist/commands/watch.js +23 -19
- package/dist/config/environment.d.ts +1 -1
- package/dist/config/environment.js +2 -2
- package/dist/constants.d.ts +4 -5
- package/dist/constants.js +5 -5
- package/dist/core/domain/cipher/errors/storage-error.d.ts +89 -0
- package/dist/core/domain/cipher/errors/storage-error.js +130 -0
- package/dist/core/domain/cipher/queue/types.d.ts +71 -0
- package/dist/core/domain/cipher/queue/types.js +9 -0
- package/dist/core/domain/cipher/storage/message-storage-types.d.ts +218 -0
- package/dist/core/domain/cipher/storage/message-storage-types.js +18 -0
- package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
- package/dist/core/domain/cipher/tools/constants.js +1 -0
- package/dist/core/domain/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +5 -0
- package/dist/core/domain/entities/global-config.d.ts +36 -0
- package/dist/core/domain/entities/global-config.js +66 -0
- package/dist/core/domain/knowledge/directory-manager.d.ts +10 -0
- package/dist/core/domain/knowledge/directory-manager.js +18 -0
- package/dist/core/domain/knowledge/markdown-writer.d.ts +9 -0
- package/dist/core/domain/knowledge/markdown-writer.js +51 -1
- package/dist/core/interfaces/cipher/i-agent-storage.d.ts +152 -0
- package/dist/core/interfaces/cipher/i-agent-storage.js +1 -0
- package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +2 -0
- package/dist/core/interfaces/cipher/i-key-storage.d.ts +91 -0
- package/dist/core/interfaces/cipher/i-key-storage.js +1 -0
- package/dist/core/interfaces/i-global-config-store.d.ts +34 -0
- package/dist/core/interfaces/i-global-config-store.js +1 -0
- package/dist/core/interfaces/i-onboarding-preference-store.d.ts +20 -0
- package/dist/core/interfaces/i-onboarding-preference-store.js +1 -0
- package/dist/core/interfaces/i-terminal.d.ts +146 -0
- package/dist/core/interfaces/i-terminal.js +1 -0
- package/dist/core/interfaces/i-workspace-detector-service.d.ts +8 -0
- package/dist/core/interfaces/i-workspace-detector-service.js +1 -0
- package/dist/core/interfaces/usecase/i-clear-use-case.d.ts +6 -0
- package/dist/core/interfaces/usecase/i-clear-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-curate-use-case.d.ts +10 -0
- package/dist/core/interfaces/usecase/i-curate-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-init-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-init-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-login-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-login-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-logout-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-logout-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-pull-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-pull-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-push-use-case.d.ts +6 -0
- package/dist/core/interfaces/usecase/i-push-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-query-use-case.d.ts +9 -0
- package/dist/core/interfaces/usecase/i-query-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-space-list-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-space-list-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-space-switch-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-space-switch-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-status-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-status-use-case.js +1 -0
- package/dist/hooks/init/update-notifier.js +1 -5
- package/dist/hooks/init/welcome.js +1 -2
- package/dist/infra/cipher/agent-service-factory.d.ts +13 -6
- package/dist/infra/cipher/agent-service-factory.js +40 -16
- package/dist/infra/cipher/cipher-agent.js +4 -4
- package/dist/infra/cipher/consumer/consumer-lock.d.ts +20 -0
- package/dist/infra/cipher/consumer/consumer-lock.js +40 -0
- package/dist/infra/cipher/consumer/consumer-service.d.ts +99 -0
- package/dist/infra/cipher/consumer/consumer-service.js +165 -0
- package/dist/infra/cipher/consumer/execution-consumer.d.ts +121 -0
- package/dist/infra/cipher/consumer/execution-consumer.js +523 -0
- package/dist/infra/cipher/consumer/index.d.ts +33 -0
- package/dist/infra/cipher/consumer/index.js +33 -0
- package/dist/infra/cipher/consumer/queue-polling-service.d.ts +120 -0
- package/dist/infra/cipher/consumer/queue-polling-service.js +248 -0
- package/dist/infra/cipher/http/internal-llm-http-service.d.ts +94 -0
- package/dist/infra/cipher/http/internal-llm-http-service.js +118 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +106 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.js +132 -0
- package/dist/infra/cipher/llm/context/compaction/index.d.ts +9 -0
- package/dist/infra/cipher/llm/context/compaction/index.js +9 -0
- package/dist/infra/cipher/llm/context/context-manager.d.ts +46 -2
- package/dist/infra/cipher/llm/context/context-manager.js +68 -4
- package/dist/infra/cipher/llm/context/rw-lock.d.ts +72 -0
- package/dist/infra/cipher/llm/context/rw-lock.js +145 -0
- package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +7 -7
- package/dist/infra/cipher/llm/generators/byterover-content-generator.js +8 -8
- package/dist/infra/cipher/llm/internal-llm-service.js +2 -0
- package/dist/infra/cipher/session/session-manager.d.ts +4 -4
- package/dist/infra/cipher/session/session-manager.js +5 -5
- package/dist/infra/cipher/storage/agent-storage.d.ts +246 -0
- package/dist/infra/cipher/storage/agent-storage.js +956 -0
- package/dist/infra/cipher/storage/dual-format-history-storage.d.ts +77 -0
- package/dist/infra/cipher/storage/dual-format-history-storage.js +149 -0
- package/dist/infra/cipher/storage/granular-history-storage.d.ts +65 -0
- package/dist/infra/cipher/storage/granular-history-storage.js +118 -0
- package/dist/infra/cipher/storage/message-storage-service.d.ts +108 -0
- package/dist/infra/cipher/storage/message-storage-service.js +529 -0
- package/dist/infra/cipher/storage/process-utils.d.ts +16 -0
- package/dist/infra/cipher/storage/process-utils.js +43 -0
- package/dist/infra/cipher/storage/sqlite-key-storage.d.ts +105 -0
- package/dist/infra/cipher/storage/sqlite-key-storage.js +404 -0
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +1 -0
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +7 -0
- package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
- package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +10 -0
- package/dist/infra/cipher/tools/implementations/curate-tool.js +371 -0
- package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +11 -8
- package/dist/infra/cipher/tools/tool-manager.d.ts +8 -2
- package/dist/infra/cipher/tools/tool-manager.js +29 -2
- package/dist/infra/cipher/tools/tool-registry.js +7 -0
- package/dist/infra/http/authenticated-http-client.d.ts +21 -0
- package/dist/infra/http/authenticated-http-client.js +38 -0
- package/dist/infra/repl/commands/arg-parser.d.ts +97 -0
- package/dist/infra/repl/commands/arg-parser.js +129 -0
- package/dist/infra/repl/commands/clear-command.d.ts +5 -0
- package/dist/infra/repl/commands/clear-command.js +61 -0
- package/dist/infra/repl/commands/curate-command.d.ts +9 -0
- package/dist/infra/repl/commands/curate-command.js +88 -0
- package/dist/infra/repl/commands/gen-rules-command.d.ts +7 -0
- package/dist/infra/repl/commands/gen-rules-command.js +38 -0
- package/dist/infra/repl/commands/index.d.ts +8 -0
- package/dist/infra/repl/commands/index.js +36 -0
- package/dist/infra/repl/commands/init-command.d.ts +7 -0
- package/dist/infra/repl/commands/init-command.js +83 -0
- package/dist/infra/repl/commands/login-command.d.ts +7 -0
- package/dist/infra/repl/commands/login-command.js +50 -0
- package/dist/infra/repl/commands/logout-command.d.ts +5 -0
- package/dist/infra/repl/commands/logout-command.js +48 -0
- package/dist/infra/repl/commands/pull-command.d.ts +5 -0
- package/dist/infra/repl/commands/pull-command.js +61 -0
- package/dist/infra/repl/commands/push-command.d.ts +5 -0
- package/dist/infra/repl/commands/push-command.js +66 -0
- package/dist/infra/repl/commands/query-command.d.ts +5 -0
- package/dist/infra/repl/commands/query-command.js +66 -0
- package/dist/infra/repl/commands/space/index.d.ts +5 -0
- package/dist/infra/repl/commands/space/index.js +14 -0
- package/dist/infra/repl/commands/space/list-command.d.ts +5 -0
- package/dist/infra/repl/commands/space/list-command.js +70 -0
- package/dist/infra/repl/commands/space/switch-command.d.ts +5 -0
- package/dist/infra/repl/commands/space/switch-command.js +37 -0
- package/dist/infra/repl/commands/status-command.d.ts +5 -0
- package/dist/infra/repl/commands/status-command.js +39 -0
- package/dist/infra/repl/repl-startup.d.ts +18 -0
- package/dist/infra/repl/repl-startup.js +26 -0
- package/dist/infra/storage/file-global-config-store.d.ts +22 -0
- package/dist/infra/storage/file-global-config-store.js +65 -0
- package/dist/infra/storage/file-onboarding-preference-store.d.ts +10 -0
- package/dist/infra/storage/file-onboarding-preference-store.js +46 -0
- package/dist/infra/terminal/oclif-terminal.d.ts +19 -0
- package/dist/infra/terminal/oclif-terminal.js +60 -0
- package/dist/infra/terminal/repl-terminal.d.ts +31 -0
- package/dist/infra/terminal/repl-terminal.js +116 -0
- package/dist/infra/tracking/mixpanel-tracking-service.d.ts +11 -1
- package/dist/infra/tracking/mixpanel-tracking-service.js +18 -13
- package/dist/infra/usecase/clear-use-case.d.ts +20 -0
- package/dist/infra/usecase/clear-use-case.js +58 -0
- package/dist/infra/usecase/curate-use-case.d.ts +66 -0
- package/dist/infra/usecase/curate-use-case.js +283 -0
- package/dist/{commands/gen-rules.d.ts → infra/usecase/generate-rules-use-case.d.ts} +14 -20
- package/dist/{commands/gen-rules.js → infra/usecase/generate-rules-use-case.js} +59 -78
- package/dist/infra/usecase/init-use-case.d.ts +139 -0
- package/dist/{commands/init.js → infra/usecase/init-use-case.js} +184 -230
- package/dist/infra/usecase/login-use-case.d.ts +28 -0
- package/dist/infra/usecase/login-use-case.js +88 -0
- package/dist/infra/usecase/logout-use-case.d.ts +22 -0
- package/dist/infra/usecase/logout-use-case.js +51 -0
- package/dist/infra/usecase/pull-use-case.d.ts +35 -0
- package/dist/infra/usecase/pull-use-case.js +89 -0
- package/dist/infra/usecase/push-use-case.d.ts +37 -0
- package/dist/infra/usecase/push-use-case.js +124 -0
- package/dist/infra/usecase/query-use-case.d.ts +78 -0
- package/dist/infra/usecase/query-use-case.js +401 -0
- package/dist/infra/usecase/space-list-use-case.d.ts +27 -0
- package/dist/infra/usecase/space-list-use-case.js +64 -0
- package/dist/infra/usecase/space-switch-use-case.d.ts +36 -0
- package/dist/infra/usecase/space-switch-use-case.js +140 -0
- package/dist/infra/usecase/status-use-case.d.ts +27 -0
- package/dist/infra/usecase/status-use-case.js +97 -0
- package/dist/infra/workspace/workspace-detector-service.d.ts +3 -6
- package/dist/resources/prompts/curate-context-tree-curation.yml +23 -11
- package/dist/resources/prompts/query-context-tree-retrieval.yml +3 -4
- package/dist/resources/prompts/system-prompt.yml +1 -1
- package/dist/resources/prompts/tool-outputs.yml +4 -3
- package/dist/templates/sections/command-reference.md +12 -0
- package/dist/templates/sections/workflow.md +10 -1
- package/dist/tui/app.d.ts +9 -0
- package/dist/tui/app.js +26 -0
- package/dist/tui/components/enter-prompt.d.ts +13 -0
- package/dist/tui/components/enter-prompt.js +15 -0
- package/dist/tui/components/execution/execution-changes.d.ts +14 -0
- package/dist/tui/components/execution/execution-changes.js +15 -0
- package/dist/tui/components/execution/execution-content.d.ts +25 -0
- package/dist/tui/components/execution/execution-content.js +67 -0
- package/dist/tui/components/execution/execution-input.d.ts +12 -0
- package/dist/tui/components/execution/execution-input.js +16 -0
- package/dist/tui/components/execution/execution-progress.d.ts +21 -0
- package/dist/tui/components/execution/execution-progress.js +21 -0
- package/dist/tui/components/execution/execution-status.d.ts +13 -0
- package/dist/tui/components/execution/execution-status.js +19 -0
- package/dist/tui/components/execution/index.d.ts +11 -0
- package/dist/tui/components/execution/index.js +11 -0
- package/dist/tui/components/execution/log-item.d.ts +17 -0
- package/dist/tui/components/execution/log-item.js +25 -0
- package/dist/tui/components/footer.d.ts +5 -0
- package/dist/tui/components/footer.js +12 -0
- package/dist/tui/components/header.d.ts +18 -0
- package/dist/tui/components/header.js +18 -0
- package/dist/tui/components/index.d.ts +17 -0
- package/dist/tui/components/index.js +14 -0
- package/dist/tui/components/inline-prompts/index.d.ts +15 -0
- package/dist/tui/components/inline-prompts/index.js +10 -0
- package/dist/tui/components/inline-prompts/inline-confirm.d.ts +17 -0
- package/dist/tui/components/inline-prompts/inline-confirm.js +32 -0
- package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +43 -0
- package/dist/tui/components/inline-prompts/inline-file-selector.js +185 -0
- package/dist/tui/components/inline-prompts/inline-input.d.ts +19 -0
- package/dist/tui/components/inline-prompts/inline-input.js +32 -0
- package/dist/tui/components/inline-prompts/inline-search.d.ts +20 -0
- package/dist/tui/components/inline-prompts/inline-search.js +50 -0
- package/dist/tui/components/inline-prompts/inline-select.d.ts +20 -0
- package/dist/tui/components/inline-prompts/inline-select.js +34 -0
- package/dist/tui/components/logo.d.ts +43 -0
- package/dist/tui/components/logo.js +103 -0
- package/dist/tui/components/message-item.d.ts +12 -0
- package/dist/tui/components/message-item.js +12 -0
- package/dist/tui/components/onboarding/copyable-prompt.d.ts +15 -0
- package/dist/tui/components/onboarding/copyable-prompt.js +65 -0
- package/dist/tui/components/onboarding/index.d.ts +7 -0
- package/dist/tui/components/onboarding/index.js +6 -0
- package/dist/tui/components/onboarding/onboarding-flow.d.ts +13 -0
- package/dist/tui/components/onboarding/onboarding-flow.js +304 -0
- package/dist/tui/components/onboarding/onboarding-step.d.ts +23 -0
- package/dist/tui/components/onboarding/onboarding-step.js +12 -0
- package/dist/tui/components/output-log.d.ts +14 -0
- package/dist/tui/components/output-log.js +13 -0
- package/dist/tui/components/scrollable-list.d.ts +30 -0
- package/dist/tui/components/scrollable-list.js +121 -0
- package/dist/tui/components/suggestions.d.ts +16 -0
- package/dist/tui/components/suggestions.js +162 -0
- package/dist/tui/components/tab-bar.d.ts +10 -0
- package/dist/tui/components/tab-bar.js +12 -0
- package/dist/tui/constants.d.ts +11 -0
- package/dist/tui/constants.js +13 -0
- package/dist/tui/contexts/auth-context.d.ts +30 -0
- package/dist/tui/contexts/auth-context.js +153 -0
- package/dist/tui/contexts/consumer.d.ts +31 -0
- package/dist/tui/contexts/consumer.js +56 -0
- package/dist/tui/contexts/index.d.ts +6 -0
- package/dist/tui/contexts/index.js +6 -0
- package/dist/tui/contexts/onboarding-context.d.ts +43 -0
- package/dist/tui/contexts/onboarding-context.js +181 -0
- package/dist/tui/contexts/services-context.d.ts +29 -0
- package/dist/tui/contexts/services-context.js +20 -0
- package/dist/tui/contexts/use-commands.d.ts +29 -0
- package/dist/tui/contexts/use-commands.js +53 -0
- package/dist/tui/contexts/use-mode.d.ts +43 -0
- package/dist/tui/contexts/use-mode.js +76 -0
- package/dist/tui/contexts/use-theme.d.ts +53 -0
- package/dist/tui/contexts/use-theme.js +60 -0
- package/dist/tui/hooks/index.d.ts +17 -0
- package/dist/tui/hooks/index.js +14 -0
- package/dist/tui/hooks/use-activity-logs.d.ts +26 -0
- package/dist/tui/hooks/use-activity-logs.js +90 -0
- package/dist/tui/hooks/use-consumer.d.ts +12 -0
- package/dist/tui/hooks/use-consumer.js +50 -0
- package/dist/tui/hooks/use-onboarding.d.ts +7 -0
- package/dist/tui/hooks/use-onboarding.js +6 -0
- package/dist/tui/hooks/use-queue-polling.d.ts +31 -0
- package/dist/tui/hooks/use-queue-polling.js +90 -0
- package/dist/tui/hooks/use-slash-command-processor.d.ts +16 -0
- package/dist/tui/hooks/use-slash-command-processor.js +132 -0
- package/dist/tui/hooks/use-slash-completion.d.ts +30 -0
- package/dist/tui/hooks/use-slash-completion.js +230 -0
- package/dist/tui/hooks/use-tab-navigation.d.ts +10 -0
- package/dist/tui/hooks/use-tab-navigation.js +35 -0
- package/dist/tui/hooks/use-visible-window.d.ts +22 -0
- package/dist/tui/hooks/use-visible-window.js +37 -0
- package/dist/tui/index.d.ts +1 -0
- package/dist/tui/index.js +1 -0
- package/dist/tui/providers/app-providers.d.ts +25 -0
- package/dist/tui/providers/app-providers.js +9 -0
- package/dist/tui/types/commands.d.ts +252 -0
- package/dist/tui/types/commands.js +16 -0
- package/dist/tui/types/dialogs.d.ts +37 -0
- package/dist/tui/types/dialogs.js +4 -0
- package/dist/tui/types/index.d.ts +11 -0
- package/dist/tui/types/index.js +7 -0
- package/dist/tui/types/messages.d.ts +55 -0
- package/dist/tui/types/messages.js +4 -0
- package/dist/tui/types/prompts.d.ts +100 -0
- package/dist/tui/types/prompts.js +4 -0
- package/dist/tui/types/ui.d.ts +14 -0
- package/dist/tui/types/ui.js +4 -0
- package/dist/tui/types.d.ts +1 -0
- package/dist/tui/types.js +1 -0
- package/dist/tui/views/command-view.d.ts +12 -0
- package/dist/tui/views/command-view.js +451 -0
- package/dist/tui/views/index.d.ts +6 -0
- package/dist/tui/views/index.js +6 -0
- package/dist/tui/views/login-view.d.ts +10 -0
- package/dist/tui/views/login-view.js +30 -0
- package/dist/tui/views/logs-view.d.ts +11 -0
- package/dist/tui/views/logs-view.js +73 -0
- package/dist/utils/file-validator.d.ts +16 -0
- package/dist/utils/file-validator.js +81 -0
- package/dist/utils/global-config-path.d.ts +15 -0
- package/dist/utils/global-config-path.js +38 -0
- package/oclif.manifest.json +29 -315
- package/package.json +11 -4
- package/dist/commands/clear.d.ts +0 -19
- package/dist/commands/clear.js +0 -78
- package/dist/commands/init.d.ts +0 -130
- package/dist/commands/login.d.ts +0 -22
- package/dist/commands/login.js +0 -108
- package/dist/commands/logout.d.ts +0 -16
- package/dist/commands/logout.js +0 -61
- package/dist/commands/pull.d.ts +0 -33
- package/dist/commands/pull.js +0 -115
- package/dist/commands/push.d.ts +0 -35
- package/dist/commands/push.js +0 -160
- package/dist/commands/space/list.d.ts +0 -25
- package/dist/commands/space/list.js +0 -114
- package/dist/commands/space/switch.d.ts +0 -36
- package/dist/commands/space/switch.js +0 -160
- package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +0 -149
- package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +0 -364
- package/dist/infra/cipher/grpc/internal-llm-grpc.proto +0 -94
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity Logs Hook
|
|
3
|
+
*
|
|
4
|
+
* Transforms sessionExecutions into ActivityLog format for display.
|
|
5
|
+
*/
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
import { array as zArray, object as zObject, string as zString } from 'zod';
|
|
9
|
+
import { BRV_DIR, CONTEXT_TREE_DIR } from '../../constants.js';
|
|
10
|
+
import { useConsumer } from '../contexts/index.js';
|
|
11
|
+
const ExecutionInputSchema = zObject({
|
|
12
|
+
content: zString(),
|
|
13
|
+
});
|
|
14
|
+
const CurateResultSchema = zObject({
|
|
15
|
+
result: zObject({
|
|
16
|
+
applied: zArray(zObject({
|
|
17
|
+
path: zString(),
|
|
18
|
+
status: zString(),
|
|
19
|
+
type: zString(),
|
|
20
|
+
})).optional(),
|
|
21
|
+
}).optional(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Parse execution input to extract content
|
|
25
|
+
*/
|
|
26
|
+
export function parseExecutionContent(input) {
|
|
27
|
+
try {
|
|
28
|
+
return ExecutionInputSchema.safeParse(JSON.parse(input))?.data?.content ?? input;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return input;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Extract file changes from curate tool calls
|
|
36
|
+
*/
|
|
37
|
+
export function composeChangesFromToolCalls(toolCalls) {
|
|
38
|
+
const changes = { created: [], updated: [] };
|
|
39
|
+
const contextTreeDir = join(BRV_DIR, CONTEXT_TREE_DIR);
|
|
40
|
+
for (const tc of toolCalls) {
|
|
41
|
+
if (tc.status !== 'completed' || tc.name !== 'curate' || !tc.result) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const parseResult = CurateResultSchema.safeParse(JSON.parse(tc.result));
|
|
45
|
+
if (!parseResult.success) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const result = parseResult.data.result || {};
|
|
49
|
+
for (const operation of result.applied || []) {
|
|
50
|
+
if (operation.status !== 'success') {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const contextPath = join(contextTreeDir, operation.path, 'context.md');
|
|
54
|
+
if (operation.type === 'ADD') {
|
|
55
|
+
changes.created.push(contextPath);
|
|
56
|
+
}
|
|
57
|
+
else if (operation.type === 'UPDATE') {
|
|
58
|
+
changes.updated.push(contextPath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return changes;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Hook that transforms sessionExecutions into ActivityLog format
|
|
66
|
+
*/
|
|
67
|
+
export function useActivityLogs() {
|
|
68
|
+
const { sessionExecutions } = useConsumer();
|
|
69
|
+
const logs = useMemo(() => sessionExecutions.map(({ execution, toolCalls }) => {
|
|
70
|
+
const progress = toolCalls.map((tc) => ({
|
|
71
|
+
id: tc.id,
|
|
72
|
+
status: tc.status,
|
|
73
|
+
toolCallName: tc.name,
|
|
74
|
+
}));
|
|
75
|
+
const changes = composeChangesFromToolCalls(toolCalls);
|
|
76
|
+
const activityLog = {
|
|
77
|
+
changes,
|
|
78
|
+
content: execution.status === 'failed' ? execution.error ?? '' : execution.result ?? '',
|
|
79
|
+
id: execution.id,
|
|
80
|
+
input: parseExecutionContent(execution.input),
|
|
81
|
+
progress,
|
|
82
|
+
source: 'agent',
|
|
83
|
+
status: execution.status,
|
|
84
|
+
timestamp: new Date(execution.updatedAt),
|
|
85
|
+
type: execution.type,
|
|
86
|
+
};
|
|
87
|
+
return activityLog;
|
|
88
|
+
}), [sessionExecutions]);
|
|
89
|
+
return { logs };
|
|
90
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer Hook
|
|
3
|
+
*
|
|
4
|
+
* Hook to manage consumer lifecycle
|
|
5
|
+
*/
|
|
6
|
+
import type { ConsumerStatus } from '../types.js';
|
|
7
|
+
export declare function useConsumer(): {
|
|
8
|
+
consumerError: Error | null;
|
|
9
|
+
consumerId: null | string;
|
|
10
|
+
consumerStatus: ConsumerStatus;
|
|
11
|
+
restart: () => Promise<void>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer Hook
|
|
3
|
+
*
|
|
4
|
+
* Hook to manage consumer lifecycle
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { ConsumerService } from '../../infra/cipher/consumer/consumer-service.js';
|
|
8
|
+
export function useConsumer() {
|
|
9
|
+
const [status, setStatus] = useState('starting');
|
|
10
|
+
const [consumerError, setConsumerError] = useState(null);
|
|
11
|
+
const [consumerId, setConsumerId] = useState(null);
|
|
12
|
+
const consumerRef = useRef(new ConsumerService());
|
|
13
|
+
const mountedRef = useRef(true);
|
|
14
|
+
const startConsumer = useCallback(async () => {
|
|
15
|
+
try {
|
|
16
|
+
setStatus('starting');
|
|
17
|
+
setConsumerError(null);
|
|
18
|
+
await consumerRef.current.start();
|
|
19
|
+
if (mountedRef.current) {
|
|
20
|
+
setStatus('running');
|
|
21
|
+
setConsumerId(consumerRef.current.getConsumerId());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (mountedRef.current) {
|
|
26
|
+
setStatus('error');
|
|
27
|
+
setConsumerError(error instanceof Error ? error : new Error(String(error)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, []);
|
|
31
|
+
const restart = useCallback(async () => {
|
|
32
|
+
// Dispose current consumer
|
|
33
|
+
consumerRef.current.dispose();
|
|
34
|
+
setStatus('stopped');
|
|
35
|
+
setConsumerId(null);
|
|
36
|
+
// Create new consumer and start
|
|
37
|
+
consumerRef.current = new ConsumerService();
|
|
38
|
+
await startConsumer();
|
|
39
|
+
}, [startConsumer]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
mountedRef.current = true;
|
|
42
|
+
startConsumer();
|
|
43
|
+
return () => {
|
|
44
|
+
mountedRef.current = false;
|
|
45
|
+
consumerRef.current.dispose();
|
|
46
|
+
setStatus('stopped');
|
|
47
|
+
};
|
|
48
|
+
}, [startConsumer]);
|
|
49
|
+
return { consumerError, consumerId, consumerStatus: status, restart };
|
|
50
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding Hook
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from onboarding context for backward compatibility.
|
|
5
|
+
*/
|
|
6
|
+
export { OnboardingProvider, useOnboarding } from '../contexts/onboarding-context.js';
|
|
7
|
+
export type { OnboardingStep, OnboardingContextValue as UseOnboardingReturn } from '../contexts/onboarding-context.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Polling Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for subscribing to QueuePollingService events
|
|
5
|
+
*
|
|
6
|
+
* Architecture:
|
|
7
|
+
* - Connects to singleton QueuePollingService
|
|
8
|
+
* - Updates React state only when data changes
|
|
9
|
+
* - Cleans up on unmount
|
|
10
|
+
* - Prevents memory leaks via singleton pattern
|
|
11
|
+
*
|
|
12
|
+
* Usage in Ink component:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const { stats, sessionExecutions, error } = useQueuePolling({ consumerId })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import type { ExecutionWithToolCalls, QueueStats } from '../../infra/cipher/consumer/queue-polling-service.js';
|
|
18
|
+
export declare function useQueuePolling(options?: {
|
|
19
|
+
consumerId?: string;
|
|
20
|
+
pollInterval?: number;
|
|
21
|
+
}): {
|
|
22
|
+
error: Error | null;
|
|
23
|
+
isConnected: boolean;
|
|
24
|
+
reconnectCount: number;
|
|
25
|
+
sessionExecutions: ExecutionWithToolCalls[];
|
|
26
|
+
stats: null | QueueStats;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Cleanup hook - call when dashboard unmounts
|
|
30
|
+
*/
|
|
31
|
+
export declare function useQueuePollingCleanup(): () => void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Polling Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for subscribing to QueuePollingService events
|
|
5
|
+
*
|
|
6
|
+
* Architecture:
|
|
7
|
+
* - Connects to singleton QueuePollingService
|
|
8
|
+
* - Updates React state only when data changes
|
|
9
|
+
* - Cleans up on unmount
|
|
10
|
+
* - Prevents memory leaks via singleton pattern
|
|
11
|
+
*
|
|
12
|
+
* Usage in Ink component:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const { stats, sessionExecutions, error } = useQueuePolling({ consumerId })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import { useEffect, useState } from 'react';
|
|
18
|
+
import { getQueuePollingService, stopQueuePollingService } from '../../infra/cipher/consumer/queue-polling-service.js';
|
|
19
|
+
export function useQueuePolling(options) {
|
|
20
|
+
const [stats, setStats] = useState(null);
|
|
21
|
+
const [sessionExecutions, setSessionExecutions] = useState([]);
|
|
22
|
+
const [error, setError] = useState(null);
|
|
23
|
+
const [isConnected, setIsConnected] = useState(false);
|
|
24
|
+
const [reconnectCount, setReconnectCount] = useState(0);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const service = getQueuePollingService({ pollInterval: options?.pollInterval });
|
|
27
|
+
// Update consumerId when it changes (e.g., after consumer starts)
|
|
28
|
+
if (options?.consumerId) {
|
|
29
|
+
service.setConsumerId(options.consumerId);
|
|
30
|
+
}
|
|
31
|
+
// Subscribe to events
|
|
32
|
+
const handleSnapshot = (snapshot) => {
|
|
33
|
+
setStats(snapshot.stats);
|
|
34
|
+
setSessionExecutions(snapshot.sessionExecutions);
|
|
35
|
+
setIsConnected(true);
|
|
36
|
+
};
|
|
37
|
+
const handleError = (err) => {
|
|
38
|
+
setError(err);
|
|
39
|
+
};
|
|
40
|
+
const handleStopped = () => {
|
|
41
|
+
setIsConnected(false);
|
|
42
|
+
};
|
|
43
|
+
const handleReconnected = () => {
|
|
44
|
+
// Clear error on successful reconnect
|
|
45
|
+
setError(null);
|
|
46
|
+
setReconnectCount((prev) => prev + 1);
|
|
47
|
+
};
|
|
48
|
+
service.on('snapshot', handleSnapshot);
|
|
49
|
+
service.on('error', handleError);
|
|
50
|
+
service.on('stopped', handleStopped);
|
|
51
|
+
service.on('reconnected', handleReconnected);
|
|
52
|
+
// Start service if not running
|
|
53
|
+
if (service.isRunning()) {
|
|
54
|
+
// Get current snapshot immediately
|
|
55
|
+
const current = service.getCurrentSnapshot();
|
|
56
|
+
if (current) {
|
|
57
|
+
handleSnapshot(current);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
service.start().catch((error_) => {
|
|
62
|
+
setError(error_ instanceof Error ? error_ : new Error(String(error_)));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Cleanup on unmount
|
|
66
|
+
return () => {
|
|
67
|
+
service.off('snapshot', handleSnapshot);
|
|
68
|
+
service.off('error', handleError);
|
|
69
|
+
service.off('stopped', handleStopped);
|
|
70
|
+
service.off('reconnected', handleReconnected);
|
|
71
|
+
// Note: Don't stop service here - other components may be using it
|
|
72
|
+
// Service is stopped via stopQueuePollingService() when app exits
|
|
73
|
+
};
|
|
74
|
+
}, [options?.consumerId, options?.pollInterval]);
|
|
75
|
+
return {
|
|
76
|
+
error,
|
|
77
|
+
isConnected,
|
|
78
|
+
reconnectCount,
|
|
79
|
+
sessionExecutions,
|
|
80
|
+
stats,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Cleanup hook - call when dashboard unmounts
|
|
85
|
+
*/
|
|
86
|
+
export function useQueuePollingCleanup() {
|
|
87
|
+
return () => {
|
|
88
|
+
stopQueuePollingService();
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CommandContext, SlashCommand, SlashCommandActionReturn } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hook return type
|
|
4
|
+
*/
|
|
5
|
+
interface UseSlashCommandProcessorReturn {
|
|
6
|
+
/** Handle a slash command input */
|
|
7
|
+
handleSlashCommand: (input: string) => Promise<SlashCommandActionReturn>;
|
|
8
|
+
/** Whether a command is currently being processed */
|
|
9
|
+
isProcessing: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook for processing slash commands
|
|
13
|
+
* Handles command parsing, execution, and result handling
|
|
14
|
+
*/
|
|
15
|
+
export declare function useSlashCommandProcessor(context: CommandContext, commands: readonly SlashCommand[]): UseSlashCommandProcessorReturn;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { splitArgs } from '../../infra/repl/commands/arg-parser.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parse user input to extract command, subcommand, and arguments
|
|
5
|
+
*/
|
|
6
|
+
function parseInput(input, commands) {
|
|
7
|
+
const trimmed = input.trim();
|
|
8
|
+
if (!trimmed.startsWith('/')) {
|
|
9
|
+
return { args: trimmed, isCommand: false };
|
|
10
|
+
}
|
|
11
|
+
const withoutSlash = trimmed.slice(1);
|
|
12
|
+
const parts = withoutSlash.split(/\s+/);
|
|
13
|
+
const commandName = parts[0]?.toLowerCase();
|
|
14
|
+
if (!commandName) {
|
|
15
|
+
return { args: '', isCommand: true };
|
|
16
|
+
}
|
|
17
|
+
// Find command by name or alias
|
|
18
|
+
const command = commands.find((cmd) => cmd.name === commandName || cmd.aliases?.includes(commandName));
|
|
19
|
+
if (!command) {
|
|
20
|
+
return { args: parts.slice(1).join(' '), isCommand: true };
|
|
21
|
+
}
|
|
22
|
+
// Check for subcommand
|
|
23
|
+
if (command.subCommands?.length && parts.length > 1) {
|
|
24
|
+
const subCommandName = parts[1]?.toLowerCase();
|
|
25
|
+
const subCommand = command.subCommands.find((sub) => sub.name === subCommandName || sub.aliases?.includes(subCommandName));
|
|
26
|
+
if (subCommand) {
|
|
27
|
+
return {
|
|
28
|
+
args: parts.slice(2).join(' '),
|
|
29
|
+
command,
|
|
30
|
+
isCommand: true,
|
|
31
|
+
subCommand,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
args: parts.slice(1).join(' '),
|
|
37
|
+
command,
|
|
38
|
+
isCommand: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hook for processing slash commands
|
|
43
|
+
* Handles command parsing, execution, and result handling
|
|
44
|
+
*/
|
|
45
|
+
export function useSlashCommandProcessor(context, commands) {
|
|
46
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
47
|
+
const handleSlashCommand = useCallback(async (input) => {
|
|
48
|
+
const { args, command, isCommand, subCommand } = parseInput(input, commands);
|
|
49
|
+
if (!isCommand) {
|
|
50
|
+
// Slash command only mode - show warning for non-slash input
|
|
51
|
+
return {
|
|
52
|
+
content: 'Please use a slash command. Type / for available commands.',
|
|
53
|
+
messageType: 'error',
|
|
54
|
+
type: 'message',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (!command) {
|
|
58
|
+
const commandName = input.trim().slice(1).split(/\s+/)[0];
|
|
59
|
+
return {
|
|
60
|
+
content: `Unknown command: /${commandName}. Type / for available commands.`,
|
|
61
|
+
messageType: 'error',
|
|
62
|
+
type: 'message',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Determine which action to execute
|
|
66
|
+
const actionToExecute = subCommand?.action ?? command.action;
|
|
67
|
+
const commandNameForContext = subCommand ? `${command.name} ${subCommand.name}` : command.name;
|
|
68
|
+
if (!actionToExecute) {
|
|
69
|
+
// Command has no action and no matching subcommand
|
|
70
|
+
if (command.subCommands?.length) {
|
|
71
|
+
const subNames = command.subCommands.map((s) => s.name).join('|');
|
|
72
|
+
return {
|
|
73
|
+
content: `Usage: /${command.name} <${subNames}>`,
|
|
74
|
+
messageType: 'error',
|
|
75
|
+
type: 'message',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
content: `Command /${command.name} has no action defined.`,
|
|
80
|
+
messageType: 'error',
|
|
81
|
+
type: 'message',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Check for required arguments
|
|
85
|
+
const targetCommand = subCommand ?? command;
|
|
86
|
+
const requiredArgs = targetCommand.args?.filter((arg) => arg.required) ?? [];
|
|
87
|
+
if (requiredArgs.length > 0 && !args.trim()) {
|
|
88
|
+
const argNames = requiredArgs.map((a) => `<${a.name}>`).join(' ');
|
|
89
|
+
const flagsStr = targetCommand.flags?.map((f) => `[--${f.name}]`).join(' ') ?? '';
|
|
90
|
+
const usage = `/${commandNameForContext} ${argNames}${flagsStr ? ' ' + flagsStr : ''}`;
|
|
91
|
+
return {
|
|
92
|
+
content: `Missing required argument(s).\nUsage: ${usage}`,
|
|
93
|
+
messageType: 'error',
|
|
94
|
+
type: 'message',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Extract file references from args
|
|
98
|
+
const { args: argsWithoutFiles, files } = splitArgs(args);
|
|
99
|
+
const cleanArgs = argsWithoutFiles.join(' ');
|
|
100
|
+
// Build execution context with invocation details
|
|
101
|
+
const execContext = {
|
|
102
|
+
...context,
|
|
103
|
+
invocation: {
|
|
104
|
+
args: cleanArgs,
|
|
105
|
+
files,
|
|
106
|
+
name: commandNameForContext,
|
|
107
|
+
raw: input,
|
|
108
|
+
},
|
|
109
|
+
slashCommands: commands,
|
|
110
|
+
};
|
|
111
|
+
setIsProcessing(true);
|
|
112
|
+
try {
|
|
113
|
+
const result = await actionToExecute(execContext, cleanArgs);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
118
|
+
return {
|
|
119
|
+
content: `Error executing /${commandNameForContext}: ${errorMessage}`,
|
|
120
|
+
messageType: 'error',
|
|
121
|
+
type: 'message',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
setIsProcessing(false);
|
|
126
|
+
}
|
|
127
|
+
}, [commands, context]);
|
|
128
|
+
return {
|
|
129
|
+
handleSlashCommand,
|
|
130
|
+
isProcessing,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CommandSuggestion } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hook return type
|
|
4
|
+
*/
|
|
5
|
+
interface UseSlashCompletionReturn {
|
|
6
|
+
/** Index of currently active suggestion (-1 if none) */
|
|
7
|
+
activeIndex: number;
|
|
8
|
+
/** Clear suggestions */
|
|
9
|
+
clearSuggestions: () => void;
|
|
10
|
+
/** Whether the input matches a known command (even if typing arguments) */
|
|
11
|
+
hasMatchedCommand: boolean;
|
|
12
|
+
/** Whether input is a slash command attempt (starts with /) */
|
|
13
|
+
isCommandAttempt: boolean;
|
|
14
|
+
/** Move to next suggestion */
|
|
15
|
+
nextSuggestion: () => void;
|
|
16
|
+
/** Move to previous suggestion */
|
|
17
|
+
prevSuggestion: () => void;
|
|
18
|
+
/** Select the current suggestion and return the value to insert */
|
|
19
|
+
selectSuggestion: () => null | string;
|
|
20
|
+
/** Set active index directly */
|
|
21
|
+
setActiveIndex: (index: number) => void;
|
|
22
|
+
/** Current suggestions */
|
|
23
|
+
suggestions: CommandSuggestion[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook for slash command auto-completion
|
|
27
|
+
* Generates suggestions based on input and manages selection state
|
|
28
|
+
*/
|
|
29
|
+
export declare function useSlashCompletion(input: string): UseSlashCompletionReturn;
|
|
30
|
+
export {};
|