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,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding Context
|
|
3
|
+
*
|
|
4
|
+
* Global context for managing onboarding state and step derivation.
|
|
5
|
+
* State is derived from brvConfig and sessionExecutions.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const {currentStep, shouldShowOnboarding, completeOnboarding} = useOnboarding()
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
export type OnboardingStep = 'complete' | 'curate' | 'init' | 'query';
|
|
14
|
+
export interface OnboardingContextValue {
|
|
15
|
+
/** Set onboarding complete state. Pass skipped=true when user skips via Esc */
|
|
16
|
+
completeOnboarding: (skipped?: boolean) => void;
|
|
17
|
+
/** Whether user has acknowledged curate completion */
|
|
18
|
+
curateAcknowledged: boolean;
|
|
19
|
+
/** Current onboarding step */
|
|
20
|
+
currentStep: OnboardingStep;
|
|
21
|
+
/** Whether curate has been completed at least once */
|
|
22
|
+
hasCurated: boolean;
|
|
23
|
+
/** Whether query has been completed at least once */
|
|
24
|
+
hasQueried: boolean;
|
|
25
|
+
/** Whether the project is initialized (brvConfig exists) */
|
|
26
|
+
isInitialized: boolean;
|
|
27
|
+
/** Whether user has acknowledged query completion */
|
|
28
|
+
queryAcknowledged: boolean;
|
|
29
|
+
/** Set curate acknowledged state */
|
|
30
|
+
setCurateAcknowledged: (value: boolean) => void;
|
|
31
|
+
/** Set query acknowledged state */
|
|
32
|
+
setQueryAcknowledged: (value: boolean) => void;
|
|
33
|
+
/** Whether onboarding should be shown */
|
|
34
|
+
shouldShowOnboarding: boolean;
|
|
35
|
+
/** Total number of steps (excluding complete) */
|
|
36
|
+
totalSteps: number;
|
|
37
|
+
}
|
|
38
|
+
interface OnboardingProviderProps {
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export declare function OnboardingProvider({ children }: OnboardingProviderProps): React.ReactElement;
|
|
42
|
+
export declare function useOnboarding(): OnboardingContextValue;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Onboarding Context
|
|
4
|
+
*
|
|
5
|
+
* Global context for managing onboarding state and step derivation.
|
|
6
|
+
* State is derived from brvConfig and sessionExecutions.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const {currentStep, shouldShowOnboarding, completeOnboarding} = useOnboarding()
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import { useAuth } from './auth-context.js';
|
|
15
|
+
import { useConsumer } from './index.js';
|
|
16
|
+
import { useServices } from './services-context.js';
|
|
17
|
+
const OnboardingContext = createContext(undefined);
|
|
18
|
+
/**
|
|
19
|
+
* Provider for onboarding state
|
|
20
|
+
*
|
|
21
|
+
* State derivation:
|
|
22
|
+
* - Init: When !brvConfig
|
|
23
|
+
* - Curate: When brvConfig exists but no curate completion in session
|
|
24
|
+
* - Query: When curate completed but no query completion in session
|
|
25
|
+
* - Complete: When both curate and query completed
|
|
26
|
+
*
|
|
27
|
+
* Onboarding starts when project is not initialized on mount and
|
|
28
|
+
* continues until all steps are completed and dismissed.
|
|
29
|
+
*/
|
|
30
|
+
/** Cooldown period in milliseconds (7 days) */
|
|
31
|
+
const ONBOARDING_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1000;
|
|
32
|
+
export function OnboardingProvider({ children }) {
|
|
33
|
+
const { brvConfig, isInitialConfigLoaded } = useAuth();
|
|
34
|
+
const { sessionExecutions } = useConsumer();
|
|
35
|
+
const { onboardingPreferenceStore, trackingService } = useServices();
|
|
36
|
+
const isInitialized = brvConfig !== undefined;
|
|
37
|
+
// Track if we've already checked initial config state
|
|
38
|
+
const hasCheckedRef = useRef(false);
|
|
39
|
+
// Track if project was not initialized after initial config check
|
|
40
|
+
// This determines whether we're in onboarding mode for this session
|
|
41
|
+
const wasNotInitializedRef = useRef(true);
|
|
42
|
+
// Track if onboarding is in cooldown (dismissed less than a week ago)
|
|
43
|
+
const [isInCooldown, setIsInCooldown] = useState(true); // Start true until we check
|
|
44
|
+
// Check cooldown on mount
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const checkCooldown = async () => {
|
|
47
|
+
const lastDismissedAt = await onboardingPreferenceStore.getLastDismissedAt();
|
|
48
|
+
if (lastDismissedAt) {
|
|
49
|
+
const elapsed = Date.now() - lastDismissedAt;
|
|
50
|
+
setIsInCooldown(elapsed < ONBOARDING_COOLDOWN_MS);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Never dismissed before - not in cooldown
|
|
54
|
+
setIsInCooldown(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
checkCooldown();
|
|
58
|
+
}, [onboardingPreferenceStore]);
|
|
59
|
+
// Update ref once initial config load completes (only once)
|
|
60
|
+
// This distinguishes "async load found existing config" from "user just ran init"
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (isInitialConfigLoaded && !hasCheckedRef.current) {
|
|
63
|
+
hasCheckedRef.current = true;
|
|
64
|
+
if (isInitialized) {
|
|
65
|
+
// Config existed before user interaction - don't show onboarding
|
|
66
|
+
wasNotInitializedRef.current = false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, [isInitialConfigLoaded, isInitialized]);
|
|
70
|
+
// Track acknowledgment for completed steps (user pressed Enter after seeing output)
|
|
71
|
+
const [curateAcknowledged, setCurateAcknowledgedState] = useState(false);
|
|
72
|
+
const [queryAcknowledged, setQueryAcknowledgedState] = useState(false);
|
|
73
|
+
// Track if user has dismissed the onboarding (pressed Enter on complete step)
|
|
74
|
+
const [onboardingDismissed, setOnboardingDismissed] = useState(false);
|
|
75
|
+
// Track if init was completed during this onboarding session (to avoid duplicate tracking)
|
|
76
|
+
const initTrackedRef = useRef(false);
|
|
77
|
+
// Track init completion when isInitialized changes during onboarding
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (wasNotInitializedRef.current && isInitialized && !initTrackedRef.current) {
|
|
80
|
+
initTrackedRef.current = true;
|
|
81
|
+
trackingService.track('onboarding:init_completed');
|
|
82
|
+
}
|
|
83
|
+
}, [isInitialized, trackingService]);
|
|
84
|
+
// Wrapper for setCurateAcknowledged that also tracks
|
|
85
|
+
const setCurateAcknowledged = useCallback((value) => {
|
|
86
|
+
setCurateAcknowledgedState(value);
|
|
87
|
+
if (value) {
|
|
88
|
+
trackingService.track('onboarding:curate_completed');
|
|
89
|
+
}
|
|
90
|
+
}, [trackingService]);
|
|
91
|
+
// Wrapper for setQueryAcknowledged that also tracks
|
|
92
|
+
const setQueryAcknowledged = useCallback((value) => {
|
|
93
|
+
setQueryAcknowledgedState(value);
|
|
94
|
+
if (value) {
|
|
95
|
+
trackingService.track('onboarding:query_completed');
|
|
96
|
+
}
|
|
97
|
+
}, [trackingService]);
|
|
98
|
+
// Check for completed curate/query executions in session
|
|
99
|
+
const { hasCurated, hasQueried } = useMemo(() => {
|
|
100
|
+
let curateCompleted = false;
|
|
101
|
+
let queryCompleted = false;
|
|
102
|
+
for (const { execution } of sessionExecutions) {
|
|
103
|
+
if (execution.status === 'completed') {
|
|
104
|
+
if (execution.type === 'curate') {
|
|
105
|
+
curateCompleted = true;
|
|
106
|
+
}
|
|
107
|
+
else if (execution.type === 'query') {
|
|
108
|
+
queryCompleted = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Early exit if both found
|
|
112
|
+
if (curateCompleted && queryCompleted)
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return { hasCurated: curateCompleted, hasQueried: queryCompleted };
|
|
116
|
+
}, [sessionExecutions]);
|
|
117
|
+
// Derive current step (considering acknowledgment)
|
|
118
|
+
// Stay on curate/query step until user acknowledges the completion
|
|
119
|
+
const currentStep = useMemo(() => {
|
|
120
|
+
if (!isInitialized)
|
|
121
|
+
return 'init';
|
|
122
|
+
if (!hasCurated)
|
|
123
|
+
return 'curate';
|
|
124
|
+
// hasCurated is true but not yet acknowledged -> stay on curate
|
|
125
|
+
if (!curateAcknowledged)
|
|
126
|
+
return 'curate';
|
|
127
|
+
if (!hasQueried)
|
|
128
|
+
return 'query';
|
|
129
|
+
// hasQueried is true but not yet acknowledged -> stay on query
|
|
130
|
+
if (!queryAcknowledged)
|
|
131
|
+
return 'query';
|
|
132
|
+
return 'complete';
|
|
133
|
+
}, [isInitialized, hasCurated, hasQueried, curateAcknowledged, queryAcknowledged]);
|
|
134
|
+
// Show onboarding if:
|
|
135
|
+
// 1. Project was not initialized after initial config check, AND
|
|
136
|
+
// 2. User has not dismissed the onboarding in this session, AND
|
|
137
|
+
// 3. Not in cooldown period (dismissed less than a week ago)
|
|
138
|
+
const shouldShowOnboarding = wasNotInitializedRef.current && !onboardingDismissed && !isInCooldown;
|
|
139
|
+
const completeOnboarding = useCallback((skipped = false) => {
|
|
140
|
+
setOnboardingDismissed(true);
|
|
141
|
+
// Save the dismissal timestamp to enforce cooldown period
|
|
142
|
+
onboardingPreferenceStore.setLastDismissedAt(Date.now());
|
|
143
|
+
if (skipped) {
|
|
144
|
+
trackingService.track('onboarding:skipped', { step: currentStep });
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
trackingService.track('onboarding:completed');
|
|
148
|
+
}
|
|
149
|
+
}, [currentStep, onboardingPreferenceStore, trackingService]);
|
|
150
|
+
const contextValue = useMemo(() => ({
|
|
151
|
+
completeOnboarding,
|
|
152
|
+
curateAcknowledged,
|
|
153
|
+
currentStep,
|
|
154
|
+
hasCurated,
|
|
155
|
+
hasQueried,
|
|
156
|
+
isInitialized,
|
|
157
|
+
queryAcknowledged,
|
|
158
|
+
setCurateAcknowledged,
|
|
159
|
+
setQueryAcknowledged,
|
|
160
|
+
shouldShowOnboarding,
|
|
161
|
+
totalSteps: 3, // init, curate, query (complete is not counted)
|
|
162
|
+
}), [
|
|
163
|
+
completeOnboarding,
|
|
164
|
+
curateAcknowledged,
|
|
165
|
+
currentStep,
|
|
166
|
+
hasCurated,
|
|
167
|
+
hasQueried,
|
|
168
|
+
isInCooldown,
|
|
169
|
+
isInitialized,
|
|
170
|
+
queryAcknowledged,
|
|
171
|
+
shouldShowOnboarding,
|
|
172
|
+
]);
|
|
173
|
+
return _jsx(OnboardingContext.Provider, { value: contextValue, children: children });
|
|
174
|
+
}
|
|
175
|
+
export function useOnboarding() {
|
|
176
|
+
const context = useContext(OnboardingContext);
|
|
177
|
+
if (!context) {
|
|
178
|
+
throw new Error('useOnboarding must be used within OnboardingProvider');
|
|
179
|
+
}
|
|
180
|
+
return context;
|
|
181
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Services Context
|
|
3
|
+
*
|
|
4
|
+
* Provides dependency injection for stores and app config.
|
|
5
|
+
* This context is stable - values don't change during the app lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { IOnboardingPreferenceStore } from '../../core/interfaces/i-onboarding-preference-store.js';
|
|
9
|
+
import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
|
|
10
|
+
import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
|
|
11
|
+
import type { ITrackingService } from '../../core/interfaces/i-tracking-service.js';
|
|
12
|
+
export interface ServicesContextValue {
|
|
13
|
+
onboardingPreferenceStore: IOnboardingPreferenceStore;
|
|
14
|
+
projectConfigStore: IProjectConfigStore;
|
|
15
|
+
tokenStore: ITokenStore;
|
|
16
|
+
trackingService: ITrackingService;
|
|
17
|
+
version: string;
|
|
18
|
+
}
|
|
19
|
+
interface ServicesProviderProps {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
onboardingPreferenceStore: IOnboardingPreferenceStore;
|
|
22
|
+
projectConfigStore: IProjectConfigStore;
|
|
23
|
+
tokenStore: ITokenStore;
|
|
24
|
+
trackingService: ITrackingService;
|
|
25
|
+
version: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function ServicesProvider({ children, onboardingPreferenceStore, projectConfigStore, tokenStore, trackingService, version, }: ServicesProviderProps): React.ReactElement;
|
|
28
|
+
export declare function useServices(): ServicesContextValue;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Services Context
|
|
4
|
+
*
|
|
5
|
+
* Provides dependency injection for stores and app config.
|
|
6
|
+
* This context is stable - values don't change during the app lifecycle.
|
|
7
|
+
*/
|
|
8
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
9
|
+
const ServicesContext = createContext(undefined);
|
|
10
|
+
export function ServicesProvider({ children, onboardingPreferenceStore, projectConfigStore, tokenStore, trackingService, version, }) {
|
|
11
|
+
const value = useMemo(() => ({ onboardingPreferenceStore, projectConfigStore, tokenStore, trackingService, version }), [onboardingPreferenceStore, projectConfigStore, tokenStore, trackingService, version]);
|
|
12
|
+
return _jsx(ServicesContext.Provider, { value: value, children: children });
|
|
13
|
+
}
|
|
14
|
+
export function useServices() {
|
|
15
|
+
const context = useContext(ServicesContext);
|
|
16
|
+
if (!context) {
|
|
17
|
+
throw new Error('useServices must be used within ServicesProvider');
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands Context
|
|
3
|
+
*
|
|
4
|
+
* Global context for managing slash commands across the entire app.
|
|
5
|
+
* Loads commands on mount and provides them to any component.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const {commands, handleSlashCommand} = useCommands()
|
|
10
|
+
*
|
|
11
|
+
* // Access commands
|
|
12
|
+
* commands.forEach(cmd => console.log(cmd.name))
|
|
13
|
+
*
|
|
14
|
+
* // Execute a command
|
|
15
|
+
* const result = await handleSlashCommand('/help')
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import type { SlashCommand, SlashCommandActionReturn } from '../types.js';
|
|
20
|
+
interface CommandsContextValue {
|
|
21
|
+
commands: readonly SlashCommand[];
|
|
22
|
+
handleSlashCommand: (input: string) => Promise<SlashCommandActionReturn>;
|
|
23
|
+
}
|
|
24
|
+
interface CommandsProviderProps {
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
export declare function CommandsProvider({ children }: CommandsProviderProps): React.ReactElement;
|
|
28
|
+
export declare function useCommands(): CommandsContextValue;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Commands Context
|
|
4
|
+
*
|
|
5
|
+
* Global context for managing slash commands across the entire app.
|
|
6
|
+
* Loads commands on mount and provides them to any component.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const {commands, handleSlashCommand} = useCommands()
|
|
11
|
+
*
|
|
12
|
+
* // Access commands
|
|
13
|
+
* commands.forEach(cmd => console.log(cmd.name))
|
|
14
|
+
*
|
|
15
|
+
* // Execute a command
|
|
16
|
+
* const result = await handleSlashCommand('/help')
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
20
|
+
import { load } from '../../infra/repl/commands/index.js';
|
|
21
|
+
import { useSlashCommandProcessor } from '../hooks/index.js';
|
|
22
|
+
const CommandsContext = createContext(undefined);
|
|
23
|
+
export function CommandsProvider({ children }) {
|
|
24
|
+
const [commands, setCommands] = useState([]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const abortController = new AbortController();
|
|
27
|
+
async function loadCommands() {
|
|
28
|
+
setCommands(load());
|
|
29
|
+
}
|
|
30
|
+
loadCommands();
|
|
31
|
+
return () => {
|
|
32
|
+
abortController.abort();
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
const commandContext = useMemo(() => ({
|
|
36
|
+
slashCommands: commands,
|
|
37
|
+
// version:, -> need pass version here
|
|
38
|
+
// syncService:, -> need pass sync service here
|
|
39
|
+
}), [commands]);
|
|
40
|
+
const { handleSlashCommand } = useSlashCommandProcessor(commandContext, commands);
|
|
41
|
+
const contextValue = useMemo(() => ({
|
|
42
|
+
commands,
|
|
43
|
+
handleSlashCommand,
|
|
44
|
+
}), [commands, handleSlashCommand]);
|
|
45
|
+
return _jsx(CommandsContext.Provider, { value: contextValue, children: children });
|
|
46
|
+
}
|
|
47
|
+
export function useCommands() {
|
|
48
|
+
const context = useContext(CommandsContext);
|
|
49
|
+
if (!context) {
|
|
50
|
+
throw new Error('useCommands must be used within CommandsProvider');
|
|
51
|
+
}
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mode Context
|
|
3
|
+
*
|
|
4
|
+
* Global context for managing application mode state and keyboard shortcuts.
|
|
5
|
+
* Any component can access the current mode, switch modes, or get mode-specific shortcuts.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const {mode, setMode, shortcuts} = useMode()
|
|
10
|
+
*
|
|
11
|
+
* // Access current mode
|
|
12
|
+
* console.log(mode) // "activity" or "console"
|
|
13
|
+
*
|
|
14
|
+
* // Switch mode
|
|
15
|
+
* setMode('suggestions')
|
|
16
|
+
*
|
|
17
|
+
* // Access mode-specific shortcuts
|
|
18
|
+
* shortcuts.forEach(s => console.log(`${s.key}: ${s.description}`))
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import React from 'react';
|
|
22
|
+
type Mode = 'activity' | 'console' | 'suggestions';
|
|
23
|
+
/**
|
|
24
|
+
* Keyboard shortcut definition
|
|
25
|
+
*/
|
|
26
|
+
export interface Shortcut {
|
|
27
|
+
description: string;
|
|
28
|
+
key: string;
|
|
29
|
+
}
|
|
30
|
+
interface ModeContextValue {
|
|
31
|
+
appendShortcuts: (shortcuts: Shortcut[]) => void;
|
|
32
|
+
mode: Mode;
|
|
33
|
+
removeShortcuts: (keys: string[]) => void;
|
|
34
|
+
setMode: (mode: Mode) => void;
|
|
35
|
+
shortcuts: readonly Shortcut[];
|
|
36
|
+
}
|
|
37
|
+
interface ModeProviderProps {
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
initialMode?: Mode;
|
|
40
|
+
}
|
|
41
|
+
export declare function ModeProvider({ children, initialMode }: ModeProviderProps): React.ReactElement;
|
|
42
|
+
export declare function useMode(): ModeContextValue;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Mode Context
|
|
4
|
+
*
|
|
5
|
+
* Global context for managing application mode state and keyboard shortcuts.
|
|
6
|
+
* Any component can access the current mode, switch modes, or get mode-specific shortcuts.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const {mode, setMode, shortcuts} = useMode()
|
|
11
|
+
*
|
|
12
|
+
* // Access current mode
|
|
13
|
+
* console.log(mode) // "activity" or "console"
|
|
14
|
+
*
|
|
15
|
+
* // Switch mode
|
|
16
|
+
* setMode('suggestions')
|
|
17
|
+
*
|
|
18
|
+
* // Access mode-specific shortcuts
|
|
19
|
+
* shortcuts.forEach(s => console.log(`${s.key}: ${s.description}`))
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
23
|
+
/**
|
|
24
|
+
* Keyboard shortcuts by mode
|
|
25
|
+
*/
|
|
26
|
+
const SHORTCUTS_BY_MODE = {
|
|
27
|
+
activity: [
|
|
28
|
+
{ description: 'scroll logs', key: '↑↓' },
|
|
29
|
+
{ description: 'switch view', key: 'tab' },
|
|
30
|
+
{ description: 'quit', key: 'ctrl+c' },
|
|
31
|
+
],
|
|
32
|
+
console: [
|
|
33
|
+
{ description: 'scroll', key: '↑↓' },
|
|
34
|
+
{ description: 'switch view', key: 'tab' },
|
|
35
|
+
{ description: 'quit', key: 'ctrl+c' },
|
|
36
|
+
],
|
|
37
|
+
suggestions: [
|
|
38
|
+
{ description: 'navigate', key: '↑↓' },
|
|
39
|
+
{ description: 'select', key: 'enter' },
|
|
40
|
+
{ description: 'insert', key: 'tab' },
|
|
41
|
+
{ description: 'close', key: 'esc' },
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
const ModeContext = createContext(undefined);
|
|
45
|
+
export function ModeProvider({ children, initialMode = 'activity' }) {
|
|
46
|
+
const [mode, setModeState] = useState(initialMode);
|
|
47
|
+
const [extraShortcuts, setExtraShortcuts] = useState([]);
|
|
48
|
+
const setMode = useCallback((newMode) => {
|
|
49
|
+
setModeState(newMode);
|
|
50
|
+
}, []);
|
|
51
|
+
const appendShortcuts = useCallback((shortcuts) => {
|
|
52
|
+
setExtraShortcuts((prev) => [...prev, ...shortcuts]);
|
|
53
|
+
}, []);
|
|
54
|
+
const removeShortcuts = useCallback((keys) => {
|
|
55
|
+
setExtraShortcuts((prev) => prev.filter((s) => !keys.includes(s.key)));
|
|
56
|
+
}, []);
|
|
57
|
+
const shortcuts = useMemo(() => {
|
|
58
|
+
const base = [...SHORTCUTS_BY_MODE[mode]];
|
|
59
|
+
return [...base, ...extraShortcuts];
|
|
60
|
+
}, [mode, extraShortcuts]);
|
|
61
|
+
const contextValue = useMemo(() => ({
|
|
62
|
+
appendShortcuts,
|
|
63
|
+
mode,
|
|
64
|
+
removeShortcuts,
|
|
65
|
+
setMode,
|
|
66
|
+
shortcuts,
|
|
67
|
+
}), [appendShortcuts, mode, removeShortcuts, setMode, shortcuts]);
|
|
68
|
+
return _jsx(ModeContext.Provider, { value: contextValue, children: children });
|
|
69
|
+
}
|
|
70
|
+
export function useMode() {
|
|
71
|
+
const context = useContext(ModeContext);
|
|
72
|
+
if (!context) {
|
|
73
|
+
throw new Error('useMode must be used within ModeProvider');
|
|
74
|
+
}
|
|
75
|
+
return context;
|
|
76
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Context
|
|
3
|
+
*
|
|
4
|
+
* Global context for managing theme state across the entire app.
|
|
5
|
+
* Any component can access the current theme or switch themes dynamically.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const {theme, setTheme} = useTheme()
|
|
10
|
+
*
|
|
11
|
+
* // Access theme properties
|
|
12
|
+
* <Text color={theme.colors.primary}>Hello</Text>
|
|
13
|
+
*
|
|
14
|
+
* // Switch theme (future feature)
|
|
15
|
+
* setTheme('default')
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import React from 'react';
|
|
19
|
+
export interface ThemeColors {
|
|
20
|
+
bg1: string;
|
|
21
|
+
bg2: string;
|
|
22
|
+
border: string;
|
|
23
|
+
curateCommand: string;
|
|
24
|
+
dimText: string;
|
|
25
|
+
errorText: string;
|
|
26
|
+
info: string;
|
|
27
|
+
logoBold: string;
|
|
28
|
+
logoDecor: string;
|
|
29
|
+
logoVersion: string;
|
|
30
|
+
primary: string;
|
|
31
|
+
queryCommand: string;
|
|
32
|
+
secondary: string;
|
|
33
|
+
text: string;
|
|
34
|
+
warning: string;
|
|
35
|
+
}
|
|
36
|
+
export interface Theme {
|
|
37
|
+
colors: ThemeColors;
|
|
38
|
+
}
|
|
39
|
+
export declare const themes: {
|
|
40
|
+
readonly default: Theme;
|
|
41
|
+
};
|
|
42
|
+
export type ThemeName = keyof typeof themes;
|
|
43
|
+
interface ThemeContextValue {
|
|
44
|
+
setTheme: (name: ThemeName) => void;
|
|
45
|
+
theme: Theme;
|
|
46
|
+
}
|
|
47
|
+
interface ThemeProviderProps {
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
initialTheme?: ThemeName;
|
|
50
|
+
}
|
|
51
|
+
export declare function ThemeProvider({ children, initialTheme }: ThemeProviderProps): React.ReactElement;
|
|
52
|
+
export declare function useTheme(): ThemeContextValue;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Theme Context
|
|
4
|
+
*
|
|
5
|
+
* Global context for managing theme state across the entire app.
|
|
6
|
+
* Any component can access the current theme or switch themes dynamically.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const {theme, setTheme} = useTheme()
|
|
11
|
+
*
|
|
12
|
+
* // Access theme properties
|
|
13
|
+
* <Text color={theme.colors.primary}>Hello</Text>
|
|
14
|
+
*
|
|
15
|
+
* // Switch theme (future feature)
|
|
16
|
+
* setTheme('default')
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
20
|
+
const defaultTheme = {
|
|
21
|
+
colors: {
|
|
22
|
+
bg1: '#020202',
|
|
23
|
+
bg2: '#222221',
|
|
24
|
+
border: '#3D3D3D',
|
|
25
|
+
curateCommand: '#E5C76B',
|
|
26
|
+
dimText: '#747474',
|
|
27
|
+
errorText: '#E5484D',
|
|
28
|
+
info: '#00B8D9',
|
|
29
|
+
logoBold: '#00CC66',
|
|
30
|
+
logoDecor: '#00E6A8',
|
|
31
|
+
logoVersion: '#7FFFD4',
|
|
32
|
+
primary: '#03BF86',
|
|
33
|
+
queryCommand: '#C477FF',
|
|
34
|
+
secondary: '#4CCEBF60',
|
|
35
|
+
text: '#F3F3F3',
|
|
36
|
+
warning: '#F5A623'
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const themes = {
|
|
40
|
+
default: defaultTheme,
|
|
41
|
+
};
|
|
42
|
+
const ThemeContext = createContext(undefined);
|
|
43
|
+
export function ThemeProvider({ children, initialTheme = 'default' }) {
|
|
44
|
+
const [theme, setThemeState] = useState(themes[initialTheme]);
|
|
45
|
+
const setTheme = useCallback((name) => {
|
|
46
|
+
setThemeState(themes[name]);
|
|
47
|
+
}, []);
|
|
48
|
+
const contextValue = useMemo(() => ({
|
|
49
|
+
setTheme,
|
|
50
|
+
theme,
|
|
51
|
+
}), [theme, setTheme]);
|
|
52
|
+
return _jsx(ThemeContext.Provider, { value: contextValue, children: children });
|
|
53
|
+
}
|
|
54
|
+
export function useTheme() {
|
|
55
|
+
const context = useContext(ThemeContext);
|
|
56
|
+
if (!context) {
|
|
57
|
+
throw new Error('useTheme must be used within ThemeProvider');
|
|
58
|
+
}
|
|
59
|
+
return context;
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI Hooks
|
|
3
|
+
*/
|
|
4
|
+
export { CommandsProvider, useCommands } from '../contexts/use-commands.js';
|
|
5
|
+
export { ModeProvider, useMode } from '../contexts/use-mode.js';
|
|
6
|
+
export { ThemeProvider, useTheme } from '../contexts/use-theme.js';
|
|
7
|
+
export { composeChangesFromToolCalls, parseExecutionContent, useActivityLogs } from './use-activity-logs.js';
|
|
8
|
+
export type { UseActivityLogsReturn } from './use-activity-logs.js';
|
|
9
|
+
export { useConsumer } from './use-consumer.js';
|
|
10
|
+
export { useOnboarding } from './use-onboarding.js';
|
|
11
|
+
export type { OnboardingStep, UseOnboardingReturn } from './use-onboarding.js';
|
|
12
|
+
export { useQueuePolling, useQueuePollingCleanup } from './use-queue-polling.js';
|
|
13
|
+
export { useSlashCommandProcessor } from './use-slash-command-processor.js';
|
|
14
|
+
export { useSlashCompletion } from './use-slash-completion.js';
|
|
15
|
+
export { useTabNavigation } from './use-tab-navigation.js';
|
|
16
|
+
export { useVisibleWindow } from './use-visible-window.js';
|
|
17
|
+
export type { UseVisibleWindowReturn } from './use-visible-window.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI Hooks
|
|
3
|
+
*/
|
|
4
|
+
export { CommandsProvider, useCommands } from '../contexts/use-commands.js';
|
|
5
|
+
export { ModeProvider, useMode } from '../contexts/use-mode.js';
|
|
6
|
+
export { ThemeProvider, useTheme } from '../contexts/use-theme.js';
|
|
7
|
+
export { composeChangesFromToolCalls, parseExecutionContent, useActivityLogs } from './use-activity-logs.js';
|
|
8
|
+
export { useConsumer } from './use-consumer.js';
|
|
9
|
+
export { useOnboarding } from './use-onboarding.js';
|
|
10
|
+
export { useQueuePolling, useQueuePollingCleanup } from './use-queue-polling.js';
|
|
11
|
+
export { useSlashCommandProcessor } from './use-slash-command-processor.js';
|
|
12
|
+
export { useSlashCompletion } from './use-slash-completion.js';
|
|
13
|
+
export { useTabNavigation } from './use-tab-navigation.js';
|
|
14
|
+
export { useVisibleWindow } from './use-visible-window.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity Logs Hook
|
|
3
|
+
*
|
|
4
|
+
* Transforms sessionExecutions into ActivityLog format for display.
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolCall } from '../../core/domain/cipher/queue/types.js';
|
|
7
|
+
import type { ActivityLog } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Parse execution input to extract content
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseExecutionContent(input: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Extract file changes from curate tool calls
|
|
14
|
+
*/
|
|
15
|
+
export declare function composeChangesFromToolCalls(toolCalls: ToolCall[]): {
|
|
16
|
+
created: string[];
|
|
17
|
+
updated: string[];
|
|
18
|
+
};
|
|
19
|
+
export interface UseActivityLogsReturn {
|
|
20
|
+
/** Activity logs derived from session executions */
|
|
21
|
+
logs: ActivityLog[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hook that transforms sessionExecutions into ActivityLog format
|
|
25
|
+
*/
|
|
26
|
+
export declare function useActivityLogs(): UseActivityLogsReturn;
|