byterover-cli 2.6.0 → 3.0.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/.env.production +1 -0
- package/README.md +240 -14
- package/dist/agent/core/domain/knowledge/conflict-detector.d.ts +38 -0
- package/dist/agent/core/domain/knowledge/conflict-detector.js +71 -0
- package/dist/agent/core/domain/knowledge/conflict-resolver.d.ts +17 -0
- package/dist/agent/core/domain/knowledge/conflict-resolver.js +118 -0
- package/dist/agent/core/domain/knowledge/utils.d.ts +4 -0
- package/dist/agent/core/domain/knowledge/utils.js +6 -0
- package/dist/agent/core/interfaces/i-curate-service.d.ts +6 -0
- package/dist/agent/infra/tools/implementations/curate-tool.d.ts +67 -34
- package/dist/agent/infra/tools/implementations/curate-tool.js +294 -47
- package/dist/agent/resources/prompts/system-prompt.yml +15 -8
- package/dist/agent/resources/tools/code_exec.txt +3 -0
- package/dist/agent/resources/tools/curate.txt +12 -3
- package/dist/oclif/commands/connectors/install.d.ts +2 -1
- package/dist/oclif/commands/connectors/install.js +38 -3
- package/dist/oclif/commands/curate/index.d.ts +18 -0
- package/dist/oclif/commands/curate/index.js +78 -1
- package/dist/oclif/commands/init.d.ts +12 -0
- package/dist/oclif/commands/init.js +75 -0
- package/dist/oclif/commands/locations.js +1 -1
- package/dist/oclif/commands/providers/connect.d.ts +31 -1
- package/dist/oclif/commands/providers/connect.js +307 -27
- package/dist/oclif/commands/pull.d.ts +1 -0
- package/dist/oclif/commands/pull.js +7 -0
- package/dist/oclif/commands/push.d.ts +1 -0
- package/dist/oclif/commands/push.js +8 -0
- package/dist/oclif/commands/review/approve.d.ts +17 -0
- package/dist/oclif/commands/review/approve.js +37 -0
- package/dist/oclif/commands/review/base-review-decision.d.ts +18 -0
- package/dist/oclif/commands/review/base-review-decision.js +71 -0
- package/dist/oclif/commands/review/pending.d.ts +13 -0
- package/dist/oclif/commands/review/pending.js +94 -0
- package/dist/oclif/commands/review/reject.d.ts +17 -0
- package/dist/oclif/commands/review/reject.js +38 -0
- package/dist/oclif/commands/space/list.d.ts +2 -2
- package/dist/oclif/commands/space/list.js +13 -35
- package/dist/oclif/commands/space/switch.d.ts +2 -7
- package/dist/oclif/commands/space/switch.js +13 -56
- package/dist/oclif/commands/status.d.ts +1 -0
- package/dist/oclif/commands/status.js +11 -1
- package/dist/oclif/commands/vc/add.d.ts +7 -0
- package/dist/oclif/commands/vc/add.js +29 -0
- package/dist/oclif/commands/vc/branch.d.ts +15 -0
- package/dist/oclif/commands/vc/branch.js +70 -0
- package/dist/oclif/commands/vc/checkout.d.ts +14 -0
- package/dist/oclif/commands/vc/checkout.js +47 -0
- package/dist/oclif/commands/vc/clone.d.ts +9 -0
- package/dist/oclif/commands/vc/clone.js +61 -0
- package/dist/oclif/commands/vc/commit.d.ts +10 -0
- package/dist/oclif/commands/vc/commit.js +32 -0
- package/dist/oclif/commands/vc/config.d.ts +10 -0
- package/dist/oclif/commands/vc/config.js +30 -0
- package/dist/oclif/commands/vc/fetch.d.ts +10 -0
- package/dist/oclif/commands/vc/fetch.js +42 -0
- package/dist/oclif/commands/vc/index.d.ts +6 -0
- package/dist/oclif/commands/vc/index.js +8 -0
- package/dist/oclif/commands/vc/init.d.ts +6 -0
- package/dist/oclif/commands/vc/init.js +25 -0
- package/dist/oclif/commands/vc/log.d.ts +13 -0
- package/dist/oclif/commands/vc/log.js +48 -0
- package/dist/oclif/commands/vc/merge.d.ts +19 -0
- package/dist/oclif/commands/vc/merge.js +130 -0
- package/dist/oclif/commands/vc/pull.d.ts +13 -0
- package/dist/oclif/commands/vc/pull.js +60 -0
- package/dist/oclif/commands/vc/push.d.ts +13 -0
- package/dist/oclif/commands/vc/push.js +60 -0
- package/dist/oclif/commands/vc/remote/add.d.ts +10 -0
- package/dist/oclif/commands/vc/remote/add.js +30 -0
- package/dist/oclif/commands/vc/remote/index.d.ts +6 -0
- package/dist/oclif/commands/vc/remote/index.js +16 -0
- package/dist/oclif/commands/vc/remote/set-url.d.ts +10 -0
- package/dist/oclif/commands/vc/remote/set-url.js +30 -0
- package/dist/oclif/commands/vc/reset.d.ts +13 -0
- package/dist/oclif/commands/vc/reset.js +62 -0
- package/dist/oclif/commands/vc/status.d.ts +8 -0
- package/dist/oclif/commands/vc/status.js +106 -0
- package/dist/oclif/hooks/init/validate-brv-config.d.ts +26 -0
- package/dist/oclif/hooks/init/validate-brv-config.js +62 -0
- package/dist/oclif/lib/daemon-client.d.ts +2 -0
- package/dist/oclif/lib/daemon-client.js +36 -10
- package/dist/oclif/lib/prompt-utils.d.ts +43 -0
- package/dist/oclif/lib/prompt-utils.js +84 -0
- package/dist/oclif/lib/spinner.d.ts +8 -0
- package/dist/oclif/lib/spinner.js +23 -0
- package/dist/oclif/lib/task-client.d.ts +5 -0
- package/dist/oclif/lib/task-client.js +15 -2
- package/dist/server/config/environment.d.ts +2 -0
- package/dist/server/config/environment.js +2 -0
- package/dist/server/constants.d.ts +3 -0
- package/dist/server/constants.js +9 -0
- package/dist/server/core/domain/entities/auth-token.d.ts +2 -0
- package/dist/server/core/domain/entities/auth-token.js +7 -1
- package/dist/server/core/domain/entities/curate-log-entry.d.ts +11 -0
- package/dist/server/core/domain/entities/space.d.ts +4 -0
- package/dist/server/core/domain/entities/space.js +8 -0
- package/dist/server/core/domain/entities/team.d.ts +2 -0
- package/dist/server/core/domain/entities/team.js +4 -0
- package/dist/server/core/domain/errors/git-error.d.ts +6 -0
- package/dist/server/core/domain/errors/git-error.js +12 -0
- package/dist/server/core/domain/errors/task-error.d.ts +4 -0
- package/dist/server/core/domain/errors/task-error.js +8 -0
- package/dist/server/core/domain/errors/vc-error.d.ts +5 -0
- package/dist/server/core/domain/errors/vc-error.js +8 -0
- package/dist/server/core/domain/knowledge/markdown-writer.d.ts +4 -1
- package/dist/server/core/domain/knowledge/markdown-writer.js +37 -7
- package/dist/server/core/domain/transport/schemas.d.ts +6 -6
- package/dist/server/core/interfaces/context-tree/i-context-tree-service.d.ts +11 -0
- package/dist/server/core/interfaces/process/i-task-lifecycle-hook.d.ts +6 -0
- package/dist/server/core/interfaces/services/i-git-service.d.ts +234 -0
- package/dist/server/core/interfaces/services/i-git-service.js +1 -0
- package/dist/server/core/interfaces/storage/i-curate-log-store.d.ts +5 -0
- package/dist/server/core/interfaces/storage/i-review-backup-store.d.ts +19 -0
- package/dist/server/core/interfaces/storage/i-review-backup-store.js +1 -0
- package/dist/server/core/interfaces/vc/i-vc-git-config-store.d.ts +8 -0
- package/dist/server/core/interfaces/vc/i-vc-git-config-store.js +1 -0
- package/dist/server/infra/config/auto-init.d.ts +0 -2
- package/dist/server/infra/config/auto-init.js +0 -1
- package/dist/server/infra/context-tree/file-context-tree-service.d.ts +2 -0
- package/dist/server/infra/context-tree/file-context-tree-service.js +13 -0
- package/dist/server/infra/daemon/brv-server.js +23 -3
- package/dist/server/infra/git/cogit-url.d.ts +17 -0
- package/dist/server/infra/git/cogit-url.js +39 -0
- package/dist/server/infra/git/git-http-wrapper.d.ts +20 -0
- package/dist/server/infra/git/git-http-wrapper.js +334 -0
- package/dist/server/infra/git/isomorphic-git-service.d.ts +78 -0
- package/dist/server/infra/git/isomorphic-git-service.js +983 -0
- package/dist/server/infra/http/review-api-handler.d.ts +13 -0
- package/dist/server/infra/http/review-api-handler.js +286 -0
- package/dist/server/infra/http/review-ui.d.ts +7 -0
- package/dist/server/infra/http/review-ui.js +606 -0
- package/dist/server/infra/mcp/tools/brv-curate-tool.d.ts +2 -2
- package/dist/server/infra/process/curate-log-handler.d.ts +18 -2
- package/dist/server/infra/process/curate-log-handler.js +50 -13
- package/dist/server/infra/process/feature-handlers.js +41 -1
- package/dist/server/infra/process/task-router.js +16 -0
- package/dist/server/infra/space/http-space-service.js +2 -0
- package/dist/server/infra/storage/file-curate-log-store.d.ts +10 -0
- package/dist/server/infra/storage/file-curate-log-store.js +35 -0
- package/dist/server/infra/storage/file-review-backup-store.d.ts +29 -0
- package/dist/server/infra/storage/file-review-backup-store.js +121 -0
- package/dist/server/infra/transport/handlers/auth-handler.js +9 -5
- package/dist/server/infra/transport/handlers/handler-types.d.ts +9 -0
- package/dist/server/infra/transport/handlers/handler-types.js +11 -0
- package/dist/server/infra/transport/handlers/index.d.ts +4 -0
- package/dist/server/infra/transport/handlers/index.js +2 -0
- package/dist/server/infra/transport/handlers/init-handler.d.ts +1 -0
- package/dist/server/infra/transport/handlers/init-handler.js +13 -1
- package/dist/server/infra/transport/handlers/pull-handler.d.ts +3 -0
- package/dist/server/infra/transport/handlers/pull-handler.js +5 -1
- package/dist/server/infra/transport/handlers/push-handler.d.ts +20 -0
- package/dist/server/infra/transport/handlers/push-handler.js +116 -14
- package/dist/server/infra/transport/handlers/reset-handler.d.ts +11 -0
- package/dist/server/infra/transport/handlers/reset-handler.js +37 -1
- package/dist/server/infra/transport/handlers/review-handler.d.ts +35 -0
- package/dist/server/infra/transport/handlers/review-handler.js +162 -0
- package/dist/server/infra/transport/handlers/space-handler.d.ts +3 -0
- package/dist/server/infra/transport/handlers/space-handler.js +4 -1
- package/dist/server/infra/transport/handlers/status-handler.d.ts +5 -0
- package/dist/server/infra/transport/handlers/status-handler.js +51 -16
- package/dist/server/infra/transport/handlers/vc-handler.d.ts +100 -0
- package/dist/server/infra/transport/handlers/vc-handler.js +1050 -0
- package/dist/server/infra/transport/socket-io-transport-server.d.ts +7 -0
- package/dist/server/infra/transport/socket-io-transport-server.js +12 -1
- package/dist/server/infra/transport/transport-connector.d.ts +1 -1
- package/dist/server/infra/transport/transport-connector.js +2 -1
- package/dist/server/infra/vc/file-vc-git-config-store.d.ts +11 -0
- package/dist/server/infra/vc/file-vc-git-config-store.js +43 -0
- package/dist/server/templates/skill/SKILL.md +167 -33
- package/dist/server/utils/curate-result-parser.d.ts +64 -0
- package/dist/server/utils/curate-result-parser.js +8 -0
- package/dist/server/utils/gitignore.d.ts +9 -0
- package/dist/server/utils/gitignore.js +47 -0
- package/dist/shared/transport/events/index.d.ts +6 -0
- package/dist/shared/transport/events/index.js +3 -0
- package/dist/shared/transport/events/init-events.d.ts +8 -0
- package/dist/shared/transport/events/init-events.js +1 -0
- package/dist/shared/transport/events/push-events.d.ts +6 -0
- package/dist/shared/transport/events/review-events.d.ts +41 -0
- package/dist/shared/transport/events/review-events.js +5 -0
- package/dist/shared/transport/events/vc-events.d.ts +257 -0
- package/dist/shared/transport/events/vc-events.js +67 -0
- package/dist/shared/transport/types/dto.d.ts +6 -1
- package/dist/tui/app/pages/init-project-page.d.ts +9 -0
- package/dist/tui/app/pages/init-project-page.js +54 -0
- package/dist/tui/app/pages/protected-routes.js +14 -6
- package/dist/tui/components/index.d.ts +0 -2
- package/dist/tui/components/index.js +0 -1
- package/dist/tui/features/activity/hooks/use-activity-logs.js +7 -1
- package/dist/tui/features/commands/definitions/index.js +3 -0
- package/dist/tui/features/commands/definitions/space-list.js +9 -18
- package/dist/tui/features/commands/definitions/space-switch.js +10 -6
- package/dist/tui/features/commands/definitions/vc-add.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-add.js +15 -0
- package/dist/tui/features/commands/definitions/vc-branch.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-branch.js +33 -0
- package/dist/tui/features/commands/definitions/vc-checkout.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-checkout.js +32 -0
- package/dist/tui/features/commands/definitions/vc-clone.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-clone.js +18 -0
- package/dist/tui/features/commands/definitions/vc-commit.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-commit.js +32 -0
- package/dist/tui/features/commands/definitions/vc-config.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-config.js +40 -0
- package/dist/tui/features/commands/definitions/vc-fetch.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-fetch.js +37 -0
- package/dist/tui/features/commands/definitions/vc-init.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-init.js +11 -0
- package/dist/tui/features/commands/definitions/vc-log.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-log.js +25 -0
- package/dist/tui/features/commands/definitions/vc-merge.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-merge.js +48 -0
- package/dist/tui/features/commands/definitions/vc-pull.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-pull.js +42 -0
- package/dist/tui/features/commands/definitions/vc-push.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-push.js +38 -0
- package/dist/tui/features/commands/definitions/vc-remote.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-remote.js +57 -0
- package/dist/tui/features/commands/definitions/vc-reset.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-reset.js +35 -0
- package/dist/tui/features/commands/definitions/vc-status.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc-status.js +11 -0
- package/dist/tui/features/commands/definitions/vc.d.ts +2 -0
- package/dist/tui/features/commands/definitions/vc.js +36 -0
- package/dist/tui/features/commands/hooks/use-slash-command-processor.js +5 -5
- package/dist/tui/features/log/api/execute-log.d.ts +8 -0
- package/dist/tui/features/log/api/execute-log.js +13 -0
- package/dist/tui/features/log/components/log-flow.d.ts +14 -0
- package/dist/tui/features/log/components/log-flow.js +29 -0
- package/dist/tui/features/log/utils/format-log.d.ts +3 -0
- package/dist/tui/features/log/utils/format-log.js +42 -0
- package/dist/tui/features/onboarding/hooks/use-app-view-mode.d.ts +9 -5
- package/dist/tui/features/onboarding/hooks/use-app-view-mode.js +12 -5
- package/dist/tui/features/push/components/push-flow.js +9 -2
- package/dist/tui/features/reset/components/reset-flow.js +2 -1
- package/dist/tui/features/status/components/status-view.js +2 -1
- package/dist/tui/features/status/utils/format-status.js +9 -0
- package/dist/tui/features/tasks/hooks/use-task-subscriptions.js +11 -0
- package/dist/tui/features/tasks/stores/tasks-store.d.ts +10 -0
- package/dist/tui/features/tasks/stores/tasks-store.js +16 -0
- package/dist/tui/features/vc/add/api/execute-vc-add.d.ts +8 -0
- package/dist/tui/features/vc/add/api/execute-vc-add.js +13 -0
- package/dist/tui/features/vc/add/components/vc-add-flow.d.ts +7 -0
- package/dist/tui/features/vc/add/components/vc-add-flow.js +35 -0
- package/dist/tui/features/vc/branch/api/execute-vc-branch.d.ts +8 -0
- package/dist/tui/features/vc/branch/api/execute-vc-branch.js +13 -0
- package/dist/tui/features/vc/branch/components/vc-branch-flow.d.ts +8 -0
- package/dist/tui/features/vc/branch/components/vc-branch-flow.js +53 -0
- package/dist/tui/features/vc/branch/utils/format-branch.d.ts +4 -0
- package/dist/tui/features/vc/branch/utils/format-branch.js +12 -0
- package/dist/tui/features/vc/checkout/api/execute-vc-checkout.d.ts +8 -0
- package/dist/tui/features/vc/checkout/api/execute-vc-checkout.js +13 -0
- package/dist/tui/features/vc/checkout/components/vc-checkout-flow.d.ts +8 -0
- package/dist/tui/features/vc/checkout/components/vc-checkout-flow.js +33 -0
- package/dist/tui/features/vc/clone/api/execute-vc-clone.d.ts +8 -0
- package/dist/tui/features/vc/clone/api/execute-vc-clone.js +13 -0
- package/dist/tui/features/vc/clone/components/vc-clone-flow.d.ts +7 -0
- package/dist/tui/features/vc/clone/components/vc-clone-flow.js +79 -0
- package/dist/tui/features/vc/commit/api/execute-vc-commit.d.ts +8 -0
- package/dist/tui/features/vc/commit/api/execute-vc-commit.js +13 -0
- package/dist/tui/features/vc/commit/components/vc-commit-flow.d.ts +7 -0
- package/dist/tui/features/vc/commit/components/vc-commit-flow.js +29 -0
- package/dist/tui/features/vc/config/api/execute-vc-config.d.ts +8 -0
- package/dist/tui/features/vc/config/api/execute-vc-config.js +13 -0
- package/dist/tui/features/vc/config/components/vc-config-flow.d.ts +9 -0
- package/dist/tui/features/vc/config/components/vc-config-flow.js +30 -0
- package/dist/tui/features/vc/fetch/api/execute-vc-fetch.d.ts +8 -0
- package/dist/tui/features/vc/fetch/api/execute-vc-fetch.js +13 -0
- package/dist/tui/features/vc/fetch/components/vc-fetch-flow.d.ts +8 -0
- package/dist/tui/features/vc/fetch/components/vc-fetch-flow.js +75 -0
- package/dist/tui/features/vc/init/api/execute-vc-init.d.ts +8 -0
- package/dist/tui/features/vc/init/api/execute-vc-init.js +13 -0
- package/dist/tui/features/vc/init/components/vc-init-flow.d.ts +10 -0
- package/dist/tui/features/vc/init/components/vc-init-flow.js +37 -0
- package/dist/tui/features/vc/merge/api/execute-vc-merge.d.ts +8 -0
- package/dist/tui/features/vc/merge/api/execute-vc-merge.js +13 -0
- package/dist/tui/features/vc/merge/components/vc-merge-flow.d.ts +11 -0
- package/dist/tui/features/vc/merge/components/vc-merge-flow.js +72 -0
- package/dist/tui/features/vc/pull/api/execute-vc-pull.d.ts +8 -0
- package/dist/tui/features/vc/pull/api/execute-vc-pull.js +13 -0
- package/dist/tui/features/vc/pull/components/vc-pull-flow.d.ts +9 -0
- package/dist/tui/features/vc/pull/components/vc-pull-flow.js +83 -0
- package/dist/tui/features/vc/push/api/execute-vc-push.d.ts +8 -0
- package/dist/tui/features/vc/push/api/execute-vc-push.js +13 -0
- package/dist/tui/features/vc/push/components/vc-push-flow.d.ts +8 -0
- package/dist/tui/features/vc/push/components/vc-push-flow.js +83 -0
- package/dist/tui/features/vc/remote/api/execute-vc-remote.d.ts +8 -0
- package/dist/tui/features/vc/remote/api/execute-vc-remote.js +13 -0
- package/dist/tui/features/vc/remote/components/vc-remote-flow.d.ts +9 -0
- package/dist/tui/features/vc/remote/components/vc-remote-flow.js +42 -0
- package/dist/tui/features/vc/reset/api/execute-vc-reset.d.ts +8 -0
- package/dist/tui/features/vc/reset/api/execute-vc-reset.js +13 -0
- package/dist/tui/features/vc/reset/components/vc-reset-flow.d.ts +10 -0
- package/dist/tui/features/vc/reset/components/vc-reset-flow.js +63 -0
- package/dist/tui/features/vc/status/api/execute-vc-status.d.ts +8 -0
- package/dist/tui/features/vc/status/api/execute-vc-status.js +13 -0
- package/dist/tui/features/vc/status/components/vc-status-flow.d.ts +10 -0
- package/dist/tui/features/vc/status/components/vc-status-flow.js +133 -0
- package/dist/tui/lib/environment.d.ts +8 -0
- package/dist/tui/lib/environment.js +8 -0
- package/dist/tui/utils/error-messages.d.ts +5 -1
- package/dist/tui/utils/error-messages.js +32 -3
- package/oclif.manifest.json +1018 -98
- package/package.json +9 -3
- package/dist/oclif/hooks/prerun/validate-brv-config-version.d.ts +0 -33
- package/dist/oclif/hooks/prerun/validate-brv-config-version.js +0 -86
- package/dist/tui/components/init.d.ts +0 -33
- package/dist/tui/components/init.js +0 -234
- package/dist/tui/features/space/api/get-spaces.d.ts +0 -16
- package/dist/tui/features/space/api/get-spaces.js +0 -17
- package/dist/tui/features/space/api/switch-space.d.ts +0 -11
- package/dist/tui/features/space/api/switch-space.js +0 -24
- package/dist/tui/features/space/components/space-list-view.d.ts +0 -12
- package/dist/tui/features/space/components/space-list-view.js +0 -56
- package/dist/tui/features/space/components/space-switch-flow.d.ts +0 -13
- package/dist/tui/features/space/components/space-switch-flow.js +0 -97
package/.env.production
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
BRV_API_BASE_URL=https://iam.byterover.dev/api/v1
|
|
2
2
|
BRV_AUTHORIZATION_URL=https://iam.byterover.dev/api/v1/oidc/authorize
|
|
3
3
|
BRV_COGIT_API_BASE_URL=https://v3-cgit.byterover.dev/api/v1
|
|
4
|
+
BRV_GIT_REMOTE_BASE_URL=https://byterover.dev
|
|
4
5
|
BRV_ISSUER_URL=https://iam.byterover.dev/api/v1/oidc
|
|
5
6
|
BRV_LLM_API_BASE_URL=https://llm.byterover.dev
|
|
6
7
|
BRV_TOKEN_URL=https://iam.byterover.dev/api/v1/oidc/token
|
package/README.md
CHANGED
|
@@ -1,15 +1,71 @@
|
|
|
1
1
|
# ByteRover CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://npmjs.org/package/byterover-cli)
|
|
5
|
+
<img src="./assets/images/logo/byterover-logo.svg" alt="ByteRover Logo" width="280" />
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>Interactive REPL CLI for AI-powered context memory</em>
|
|
9
|
+
</p>
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-Elastic%202.0-blue.svg" alt="License" /></a>
|
|
13
|
+
<a href="https://npmjs.org/package/byterover-cli"><img src="https://img.shields.io/npm/v/byterover-cli.svg" alt="Version" /></a>
|
|
14
|
+
<a href="https://npmjs.org/package/byterover-cli"><img src="https://img.shields.io/npm/dw/byterover-cli.svg" alt="Downloads" /></a>
|
|
15
|
+
<a href="https://docs.byterover.dev"><img src="https://img.shields.io/badge/Docs-Documentation-green.svg" alt="Documentation" /></a>
|
|
16
|
+
<a href="https://discord.com/invite/UMRrpNjh5W"><img src="https://img.shields.io/badge/Discord-Join%20Community-7289da" alt="Discord" /></a>
|
|
17
|
+
</p>
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
ByteRover CLI (`brv`) gives AI coding agents persistent, structured memory. It lets developers curate project knowledge into a context tree, sync it to the cloud, and share it across tools and teammates.
|
|
24
|
+
|
|
25
|
+
Run `brv` in any project directory to start an interactive REPL powered by your choice of LLM. The agent understands your codebase through an agentic map, can read and write files, execute code, and store knowledge for future sessions.
|
|
26
|
+
|
|
27
|
+
📄 Read the [paper](https://arxiv.org/abs/2604.01599) for the full technical details.
|
|
28
|
+
|
|
29
|
+
Or download our self-hosted PDF version of the paper [here](https://byterover.dev/paper).
|
|
30
|
+
|
|
31
|
+
**Key Features:**
|
|
32
|
+
|
|
33
|
+
- 🖥️ Interactive TUI with REPL interface (React/Ink)
|
|
34
|
+
- 🧠 Context tree and knowledge storage management
|
|
35
|
+
- 🔀 Git-like version control for the context tree (branch, commit, merge, push/pull)
|
|
36
|
+
- 🤖 18 LLM providers (Anthropic, OpenAI, Google, Groq, Mistral, xAI, and more)
|
|
37
|
+
- 🛠️ 24 built-in agent tools (code exec, file ops, knowledge search, memory management)
|
|
38
|
+
- 🔄 Cloud sync with push/pull
|
|
39
|
+
- 👀 Review workflow for curate operations (approve/reject pending changes)
|
|
40
|
+
- 🔌 MCP (Model Context Protocol) integration
|
|
41
|
+
- 📦 Hub and connectors ecosystem for skills and bundles
|
|
42
|
+
- 🤝 Works with 22+ AI coding agents (Cursor, Claude Code, Windsurf, Cline, and more)
|
|
43
|
+
- 🏢 Enterprise proxy support
|
|
44
|
+
|
|
45
|
+
## Benchmark Results
|
|
46
|
+
|
|
47
|
+
All benchmarks are run using the production `byterover-cli` codebase in this repository - no separate research prototype.
|
|
48
|
+
|
|
49
|
+
We evaluate on two long-term conversational memory benchmarks:
|
|
50
|
+
|
|
51
|
+
- **LoCoMo** - ultra-long conversations (~20K tokens, 35 sessions) testing single-hop, multi-hop, temporal, and open-domain retrieval.
|
|
52
|
+
- **LongMemEval-S** - large-scale benchmark (23,867 docs, ~48 sessions per question) testing 6 memory abilities including knowledge update, temporal reasoning, and multi-session synthesis.
|
|
53
|
+
|
|
54
|
+
**LoCoMo** - 96.1% overall accuracy (1,982 questions, 272 docs).
|
|
55
|
+
|
|
56
|
+
**LongMemEval-S** - 92.8% overall accuracy (500 questions, 23,867 docs).
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
<img src="assets/images/benchmarks/longmemeval-s-by-category.png" alt="LongMemEval-S Benchmark by Category" width="700" />
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
All metrics are LLM-as-Judge accuracy (%). See the [paper](https://arxiv.org/abs/2604.01599), or self-hosted [PDF](https://byterover.dev/paper) for full details.
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
### Shell Script (macOS & Linux)
|
|
67
|
+
|
|
68
|
+
No Node.js required - everything is bundled.
|
|
13
69
|
|
|
14
70
|
```bash
|
|
15
71
|
curl -fsSL https://byterover.dev/install.sh | sh
|
|
@@ -17,7 +73,7 @@ curl -fsSL https://byterover.dev/install.sh | sh
|
|
|
17
73
|
|
|
18
74
|
Supported platforms: macOS ARM64, Linux x64, Linux ARM64.
|
|
19
75
|
|
|
20
|
-
###
|
|
76
|
+
### npm (All Platforms)
|
|
21
77
|
|
|
22
78
|
Requires Node.js >= 20.
|
|
23
79
|
|
|
@@ -31,28 +87,198 @@ npm install -g byterover-cli
|
|
|
31
87
|
brv --version
|
|
32
88
|
```
|
|
33
89
|
|
|
34
|
-
|
|
90
|
+
### First Run
|
|
35
91
|
|
|
36
92
|
```bash
|
|
37
93
|
cd your/project
|
|
38
94
|
brv
|
|
39
95
|
```
|
|
40
96
|
|
|
41
|
-
The REPL auto-configures on first run
|
|
97
|
+
The REPL auto-configures on first run - no setup needed. Type `/` to discover all available commands:
|
|
42
98
|
|
|
43
99
|
```
|
|
44
100
|
/curate "Auth uses JWT with 24h expiry" @src/middleware/auth.ts
|
|
45
101
|
/query How is authentication implemented?
|
|
46
102
|
```
|
|
47
103
|
|
|
48
|
-
|
|
104
|
+
## ByteRover Cloud
|
|
105
|
+
|
|
106
|
+
ByteRover Cloud is a hosted platform for teams to sync, share, and manage context knowledge across projects and machines.
|
|
107
|
+
Everything works locally by default - Cloud adds collaboration and persistence without changing your workflow.
|
|
108
|
+
|
|
109
|
+
<p>
|
|
110
|
+
<a href="https://app.byterover.dev"><img src="https://img.shields.io/badge/Try%20ByteRover%20Cloud-Free-blue?style=for-the-badge" alt="Try ByteRover Cloud" /></a>
|
|
111
|
+
</p>
|
|
112
|
+
|
|
113
|
+
Sign in with your ByteRover account via `/login` (TUI) or
|
|
114
|
+
an [API key](https://app.byterover.dev/settings/keys) (`brv login`) to get started.
|
|
115
|
+
|
|
116
|
+
- 🔄 **Team context sync** — push and pull shared knowledge across teammates
|
|
117
|
+
- 📂 **Shared spaces** — organize context across multiple projects and teams
|
|
118
|
+
- 💻 **Multi-machine access** — sync your context tree across devices with cloud backup
|
|
119
|
+
- 🧠 **Built-in hosted LLM** — start immediately with limited free usage
|
|
120
|
+
- 👥 **Team management** — manage members, spaces, and permissions via the web app
|
|
121
|
+
- 📊 **Usage analytics** — track seat allocation and monthly credit consumption
|
|
122
|
+
- 🔒 **SOC 2 Type II** certified infrastructure with privacy mode
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
<summary><h2>CLI Usage</h2></summary>
|
|
126
|
+
|
|
127
|
+
### Core Workflow
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
brv # Start interactive REPL
|
|
131
|
+
brv status # Show project and daemon status
|
|
132
|
+
brv curate # Add context to knowledge storage
|
|
133
|
+
brv curate view # View curate history
|
|
134
|
+
brv query # Query context tree and knowledge
|
|
135
|
+
brv review pending # List pending review operations
|
|
136
|
+
brv review approve # Approve curate operations
|
|
137
|
+
brv review reject # Reject curate operations
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Sync (Legacy)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
brv push # Legacy — migrate or snapshot context to cloud
|
|
144
|
+
brv pull # Legacy — restore context from cloud snapshot
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> Use `brv vc push` / `brv vc pull` for version-controlled sync going forward.
|
|
148
|
+
|
|
149
|
+
### Version Control
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
brv vc init # Initialize version control for context tree
|
|
153
|
+
brv vc status # Show version control status
|
|
154
|
+
brv vc add # Stage files for the next commit
|
|
155
|
+
brv vc commit # Save staged changes as a commit
|
|
156
|
+
brv vc log # Show commit history
|
|
157
|
+
brv vc branch # List, create, or delete branches
|
|
158
|
+
brv vc checkout # Switch branches
|
|
159
|
+
brv vc merge # Merge a branch into the current branch
|
|
160
|
+
brv vc clone # Clone a ByteRover space repository
|
|
161
|
+
brv vc push # Push commits to ByteRover cloud
|
|
162
|
+
brv vc pull # Pull commits from ByteRover cloud
|
|
163
|
+
brv vc fetch # Fetch refs from ByteRover cloud
|
|
164
|
+
brv vc remote # Show current remote origin
|
|
165
|
+
brv vc remote add # Add a named remote
|
|
166
|
+
brv vc remote set-url # Update a remote URL
|
|
167
|
+
brv vc config # Get or set commit author
|
|
168
|
+
brv vc reset # Unstage files or undo commits
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Providers & Models
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
brv providers list # List available LLM providers
|
|
175
|
+
brv providers connect # Connect to an LLM provider
|
|
176
|
+
brv providers switch # Switch active provider
|
|
177
|
+
brv providers disconnect # Disconnect a provider
|
|
178
|
+
brv model list # List available models
|
|
179
|
+
brv model switch # Switch active model
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Hub & Connectors
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
brv hub list # List available hub packages
|
|
186
|
+
brv hub install # Install a hub package
|
|
187
|
+
brv hub registry add # Add a custom registry
|
|
188
|
+
brv hub registry list # List registries
|
|
189
|
+
brv hub registry remove # Remove a registry
|
|
190
|
+
brv connectors list # List connectors
|
|
191
|
+
brv connectors install # Install a connector
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Spaces (Deprecated)
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
brv space list # Deprecated — use web dashboard
|
|
198
|
+
brv space switch # Deprecated — use brv vc clone
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Other
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
brv mcp # Start MCP server
|
|
205
|
+
brv login # Authenticate to ByteRover
|
|
206
|
+
brv logout # Disconnect and clear credentials
|
|
207
|
+
brv locations # List registered projects
|
|
208
|
+
brv restart # Restart daemon
|
|
209
|
+
brv debug # Debug mode
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Run `brv --help` for the full command reference.
|
|
213
|
+
|
|
214
|
+
</details>
|
|
215
|
+
|
|
216
|
+
<details>
|
|
217
|
+
<summary><h2>Supported LLM Providers</h2></summary>
|
|
218
|
+
|
|
219
|
+
ByteRover CLI supports 18 LLM providers out of the box. Use `brv providers connect` to set up a provider and `brv providers switch` to change the active one.
|
|
220
|
+
|
|
221
|
+
| Provider | Description |
|
|
222
|
+
|----------|-------------|
|
|
223
|
+
| Anthropic | Claude models |
|
|
224
|
+
| OpenAI | GPT models |
|
|
225
|
+
| Google | Gemini models |
|
|
226
|
+
| Groq | Fast inference |
|
|
227
|
+
| Mistral | Mistral models |
|
|
228
|
+
| xAI | Grok models |
|
|
229
|
+
| Cerebras | Fast inference |
|
|
230
|
+
| Cohere | Command models |
|
|
231
|
+
| DeepInfra | Open-source model hosting |
|
|
232
|
+
| OpenRouter | Multi-provider gateway |
|
|
233
|
+
| Perplexity | Search-augmented models |
|
|
234
|
+
| TogetherAI | Open-source model hosting |
|
|
235
|
+
| Vercel | AI SDK provider |
|
|
236
|
+
| Minimax | Minimax models |
|
|
237
|
+
| Moonshot | Kimi models |
|
|
238
|
+
| GLM | GLM models |
|
|
239
|
+
| OpenAI-Compatible | Any OpenAI-compatible API |
|
|
240
|
+
| ByteRover | ByteRover's hosted models |
|
|
241
|
+
|
|
242
|
+
</details>
|
|
49
243
|
|
|
50
244
|
## Documentation
|
|
51
245
|
|
|
52
|
-
Visit [**docs.byterover.dev**](https://docs.byterover.dev) for full guides on
|
|
246
|
+
Visit [**docs.byterover.dev**](https://docs.byterover.dev) for full guides on setup, integrations, and advanced usage.
|
|
247
|
+
|
|
248
|
+
| Topic | Description |
|
|
249
|
+
|-------|-------------|
|
|
250
|
+
| [Getting Started](https://docs.byterover.dev) | Installation, first run, and basic usage |
|
|
251
|
+
| [Cloud Sync](https://docs.byterover.dev) | Push/pull workflows and team sharing |
|
|
252
|
+
| [Version Control](https://docs.byterover.dev) | Context tree branching, commits, and collaboration |
|
|
253
|
+
| [LLM Providers](https://docs.byterover.dev) | Provider setup and model configuration |
|
|
254
|
+
| [AI Agent Integrations](https://docs.byterover.dev) | Using ByteRover with Cursor, Claude Code, Windsurf, etc. |
|
|
255
|
+
| [Hub & Connectors](https://docs.byterover.dev) | Skills, bundles, and the connector ecosystem |
|
|
256
|
+
| CLI Reference | Run `brv --help` |
|
|
257
|
+
|
|
258
|
+
## Contributing
|
|
259
|
+
|
|
260
|
+
We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md) for development setup, coding standards, and the PR workflow.
|
|
261
|
+
|
|
262
|
+
## Community & Support
|
|
263
|
+
|
|
264
|
+
ByteRover CLI is built and maintained by the [ByteRover team](https://byterover.dev/).
|
|
265
|
+
|
|
266
|
+
- Join our [Discord](https://discord.com/invite/UMRrpNjh5W) to share projects, ask questions, or just say hi
|
|
267
|
+
- [Report issues](https://github.com/campfirein/byterover-cli/issues) <!-- TODO: ENG-1575 --> on GitHub
|
|
268
|
+
- If you enjoy ByteRover CLI, please give us a star on GitHub — it helps a lot!
|
|
269
|
+
- Follow [@kevinnguyendn](https://x.com/kevinnguyendn) on X
|
|
270
|
+
|
|
271
|
+
## Contributors
|
|
272
|
+
|
|
273
|
+
<!-- TODO: ENG-1575 -->
|
|
274
|
+
[](https://github.com/campfirein/byterover-cli/graphs/contributors)
|
|
275
|
+
|
|
276
|
+
## Star History
|
|
53
277
|
|
|
54
|
-
|
|
278
|
+
<a href="https://star-history.com/#campfirein/byterover-cli&Date">
|
|
279
|
+
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=campfirein/byterover-cli&type=Date&v=2">
|
|
280
|
+
</a>
|
|
55
281
|
|
|
56
|
-
|
|
282
|
+
## License
|
|
57
283
|
|
|
58
|
-
|
|
284
|
+
Elastic License 2.0. See [LICENSE](LICENSE) for full terms.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ContextData } from '../../../../server/core/domain/knowledge/markdown-writer.js';
|
|
2
|
+
/**
|
|
3
|
+
* Summary of detected structural loss when comparing existing vs proposed content.
|
|
4
|
+
*/
|
|
5
|
+
export type StructuralLoss = {
|
|
6
|
+
hasLoss: boolean;
|
|
7
|
+
/** Number of rawConcept array items (changes, files) that would be lost */
|
|
8
|
+
lostArrayItems: number;
|
|
9
|
+
/** Number of narrative fields that would be lost */
|
|
10
|
+
lostNarrativeFields: number;
|
|
11
|
+
/** Number of rawConcept scalar fields that would be lost */
|
|
12
|
+
lostRawConceptFields: number;
|
|
13
|
+
/** Number of relations that would be lost */
|
|
14
|
+
lostRelations: number;
|
|
15
|
+
/** Number of snippets that would be lost */
|
|
16
|
+
lostSnippets: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Detect structural loss between existing content and proposed content.
|
|
20
|
+
*
|
|
21
|
+
* Only flags when existing content would be LOST, not when new content is added.
|
|
22
|
+
* This prevents false positives when the LLM is enriching content.
|
|
23
|
+
*
|
|
24
|
+
* @param existing - Parsed content from the existing file
|
|
25
|
+
* @param proposed - Proposed new content from the curate operation
|
|
26
|
+
* @returns StructuralLoss summary
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectStructuralLoss(existing: ContextData, proposed: ContextData): StructuralLoss;
|
|
29
|
+
/**
|
|
30
|
+
* Derive the structural impact level from detected loss.
|
|
31
|
+
*
|
|
32
|
+
* - Any structural loss → 'high'
|
|
33
|
+
* - No loss → 'low'
|
|
34
|
+
*
|
|
35
|
+
* @param loss - Structural loss summary from detectStructuralLoss
|
|
36
|
+
* @returns Impact level derived from structural evidence
|
|
37
|
+
*/
|
|
38
|
+
export declare function deriveImpactFromLoss(loss: StructuralLoss): 'high' | 'low';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { normalize } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Find items in `existing` that are not in `proposed` (case-insensitive).
|
|
4
|
+
*/
|
|
5
|
+
function countLostItems(existing, proposed) {
|
|
6
|
+
const proposedSet = new Set(proposed.map((s) => normalize(s)));
|
|
7
|
+
return existing.filter((item) => !proposedSet.has(normalize(item))).length;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Count narrative fields that exist in `existing` but are absent in `proposed`.
|
|
11
|
+
*/
|
|
12
|
+
function countLostNarrativeFields(existing, proposed) {
|
|
13
|
+
if (!existing)
|
|
14
|
+
return 0;
|
|
15
|
+
const fields = ['dependencies', 'examples', 'highlights', 'rules', 'structure'];
|
|
16
|
+
return fields.filter((field) => existing[field] && !proposed?.[field]).length;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Count rawConcept scalar fields and array items that would be lost.
|
|
20
|
+
*/
|
|
21
|
+
function countLostRawConceptFields(existing, proposed) {
|
|
22
|
+
if (!existing)
|
|
23
|
+
return { arrayItems: 0, scalars: 0 };
|
|
24
|
+
const scalarFields = ['author', 'flow', 'task', 'timestamp'];
|
|
25
|
+
const scalars = scalarFields.filter((field) => existing[field] && !proposed?.[field]).length;
|
|
26
|
+
const existingChanges = existing.changes ?? [];
|
|
27
|
+
const existingFiles = existing.files ?? [];
|
|
28
|
+
const proposedChanges = proposed?.changes ?? [];
|
|
29
|
+
const proposedFiles = proposed?.files ?? [];
|
|
30
|
+
const arrayItems = countLostItems(existingChanges, proposedChanges) + countLostItems(existingFiles, proposedFiles);
|
|
31
|
+
return { arrayItems, scalars };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Detect structural loss between existing content and proposed content.
|
|
35
|
+
*
|
|
36
|
+
* Only flags when existing content would be LOST, not when new content is added.
|
|
37
|
+
* This prevents false positives when the LLM is enriching content.
|
|
38
|
+
*
|
|
39
|
+
* @param existing - Parsed content from the existing file
|
|
40
|
+
* @param proposed - Proposed new content from the curate operation
|
|
41
|
+
* @returns StructuralLoss summary
|
|
42
|
+
*/
|
|
43
|
+
export function detectStructuralLoss(existing, proposed) {
|
|
44
|
+
const lostSnippets = countLostItems(existing.snippets ?? [], proposed.snippets ?? []);
|
|
45
|
+
const lostRelations = countLostItems(existing.relations ?? [], proposed.relations ?? []);
|
|
46
|
+
const lostNarrativeFields = countLostNarrativeFields(existing.narrative, proposed.narrative);
|
|
47
|
+
const { arrayItems: lostArrayItems, scalars: lostRawConceptFields } = countLostRawConceptFields(existing.rawConcept, proposed.rawConcept);
|
|
48
|
+
const hasLoss = lostSnippets > 0 || lostRelations > 0 || lostNarrativeFields > 0 || lostRawConceptFields > 0 || lostArrayItems > 0;
|
|
49
|
+
return {
|
|
50
|
+
hasLoss,
|
|
51
|
+
lostArrayItems,
|
|
52
|
+
lostNarrativeFields,
|
|
53
|
+
lostRawConceptFields,
|
|
54
|
+
lostRelations,
|
|
55
|
+
lostSnippets,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Derive the structural impact level from detected loss.
|
|
60
|
+
*
|
|
61
|
+
* - Any structural loss → 'high'
|
|
62
|
+
* - No loss → 'low'
|
|
63
|
+
*
|
|
64
|
+
* @param loss - Structural loss summary from detectStructuralLoss
|
|
65
|
+
* @returns Impact level derived from structural evidence
|
|
66
|
+
*/
|
|
67
|
+
export function deriveImpactFromLoss(loss) {
|
|
68
|
+
if (!loss.hasLoss)
|
|
69
|
+
return 'low';
|
|
70
|
+
return 'high';
|
|
71
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ContextData } from '../../../../server/core/domain/knowledge/markdown-writer.js';
|
|
2
|
+
import type { StructuralLoss } from './conflict-detector.js';
|
|
3
|
+
/**
|
|
4
|
+
* Auto-resolve structural loss by merging existing content into proposed content.
|
|
5
|
+
*
|
|
6
|
+
* Resolution strategy:
|
|
7
|
+
* - Arrays (snippets, relations, changes, files): Union merge with deduplication
|
|
8
|
+
* - Scalars (narrative fields, rawConcept scalars): Proposed wins; preserve existing if proposed empty
|
|
9
|
+
*
|
|
10
|
+
* Only runs when `loss.hasLoss` is true. When no loss is detected, returns proposed as-is.
|
|
11
|
+
*
|
|
12
|
+
* @param existing - Parsed content from the existing file (before update)
|
|
13
|
+
* @param proposed - Proposed new content from the curate operation
|
|
14
|
+
* @param loss - Structural loss summary from detectStructuralLoss
|
|
15
|
+
* @returns Resolved content with lost items merged back in
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveStructuralLoss(existing: ContextData, proposed: ContextData, loss: StructuralLoss): ContextData;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { normalize } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Merge two arrays with case-insensitive deduplication.
|
|
4
|
+
* Existing items come first (preserves original order), then new items from proposed.
|
|
5
|
+
*/
|
|
6
|
+
function mergeArraysWithDedup(existing, proposed) {
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
const result = [];
|
|
9
|
+
for (const item of existing) {
|
|
10
|
+
const key = normalize(item);
|
|
11
|
+
if (!seen.has(key)) {
|
|
12
|
+
seen.add(key);
|
|
13
|
+
result.push(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
for (const item of proposed) {
|
|
17
|
+
const key = normalize(item);
|
|
18
|
+
if (!seen.has(key)) {
|
|
19
|
+
seen.add(key);
|
|
20
|
+
result.push(item);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Merge narrative fields.
|
|
27
|
+
* Use proposed if provided, otherwise preserve existing (prevents data loss).
|
|
28
|
+
*/
|
|
29
|
+
function mergeNarrative(existing, proposed) {
|
|
30
|
+
if (!existing && !proposed)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (!existing)
|
|
33
|
+
return proposed;
|
|
34
|
+
if (!proposed)
|
|
35
|
+
return existing;
|
|
36
|
+
const merged = {};
|
|
37
|
+
const fields = ['dependencies', 'examples', 'highlights', 'rules', 'structure'];
|
|
38
|
+
for (const field of fields) {
|
|
39
|
+
const value = proposed[field] ?? existing[field];
|
|
40
|
+
if (value !== undefined) {
|
|
41
|
+
// Type assertion needed due to heterogeneous union (string | Array)
|
|
42
|
+
;
|
|
43
|
+
merged[field] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Diagrams: union merge by content
|
|
47
|
+
const existingDiagrams = existing.diagrams ?? [];
|
|
48
|
+
const proposedDiagrams = proposed.diagrams ?? [];
|
|
49
|
+
if (existingDiagrams.length > 0 || proposedDiagrams.length > 0) {
|
|
50
|
+
const seen = new Set(existingDiagrams.map((d) => normalize(d.content)));
|
|
51
|
+
const mergedDiagrams = [...existingDiagrams];
|
|
52
|
+
for (const diagram of proposedDiagrams) {
|
|
53
|
+
if (!seen.has(normalize(diagram.content))) {
|
|
54
|
+
mergedDiagrams.push(diagram);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
merged.diagrams = mergedDiagrams;
|
|
58
|
+
}
|
|
59
|
+
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Merge rawConcept fields.
|
|
63
|
+
* Scalars: use proposed if provided, otherwise preserve existing.
|
|
64
|
+
* Arrays (changes, files): union merge with deduplication.
|
|
65
|
+
*/
|
|
66
|
+
function mergeRawConcept(existing, proposed) {
|
|
67
|
+
if (!existing && !proposed)
|
|
68
|
+
return undefined;
|
|
69
|
+
if (!existing)
|
|
70
|
+
return proposed;
|
|
71
|
+
if (!proposed)
|
|
72
|
+
return existing;
|
|
73
|
+
const merged = {};
|
|
74
|
+
// Scalar fields: proposed wins, fall back to existing
|
|
75
|
+
const scalarFields = ['author', 'flow', 'task', 'timestamp'];
|
|
76
|
+
for (const field of scalarFields) {
|
|
77
|
+
const value = proposed[field] ?? existing[field];
|
|
78
|
+
if (value !== undefined) {
|
|
79
|
+
;
|
|
80
|
+
merged[field] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// patterns: proposed wins, fall back to existing
|
|
84
|
+
merged.patterns = proposed.patterns ?? existing.patterns;
|
|
85
|
+
// Array fields: union merge
|
|
86
|
+
const mergedChanges = mergeArraysWithDedup(existing.changes ?? [], proposed.changes ?? []);
|
|
87
|
+
if (mergedChanges.length > 0)
|
|
88
|
+
merged.changes = mergedChanges;
|
|
89
|
+
const mergedFiles = mergeArraysWithDedup(existing.files ?? [], proposed.files ?? []);
|
|
90
|
+
if (mergedFiles.length > 0)
|
|
91
|
+
merged.files = mergedFiles;
|
|
92
|
+
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Auto-resolve structural loss by merging existing content into proposed content.
|
|
96
|
+
*
|
|
97
|
+
* Resolution strategy:
|
|
98
|
+
* - Arrays (snippets, relations, changes, files): Union merge with deduplication
|
|
99
|
+
* - Scalars (narrative fields, rawConcept scalars): Proposed wins; preserve existing if proposed empty
|
|
100
|
+
*
|
|
101
|
+
* Only runs when `loss.hasLoss` is true. When no loss is detected, returns proposed as-is.
|
|
102
|
+
*
|
|
103
|
+
* @param existing - Parsed content from the existing file (before update)
|
|
104
|
+
* @param proposed - Proposed new content from the curate operation
|
|
105
|
+
* @param loss - Structural loss summary from detectStructuralLoss
|
|
106
|
+
* @returns Resolved content with lost items merged back in
|
|
107
|
+
*/
|
|
108
|
+
export function resolveStructuralLoss(existing, proposed, loss) {
|
|
109
|
+
if (!loss.hasLoss)
|
|
110
|
+
return proposed;
|
|
111
|
+
return {
|
|
112
|
+
...proposed,
|
|
113
|
+
narrative: mergeNarrative(existing.narrative, proposed.narrative),
|
|
114
|
+
rawConcept: mergeRawConcept(existing.rawConcept, proposed.rawConcept),
|
|
115
|
+
relations: mergeArraysWithDedup(existing.relations ?? [], proposed.relations ?? []),
|
|
116
|
+
snippets: mergeArraysWithDedup(existing.snippets ?? [], proposed.snippets ?? []),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -114,10 +114,14 @@ export type CurateOperationType = 'ADD' | 'DELETE' | 'MERGE' | 'UPDATE' | 'UPSER
|
|
|
114
114
|
* Single curate operation.
|
|
115
115
|
*/
|
|
116
116
|
export interface CurateOperation {
|
|
117
|
+
/** LLM-assessed confidence in the accuracy and completeness of this operation */
|
|
118
|
+
confidence?: 'high' | 'low';
|
|
117
119
|
/** Content for ADD/UPDATE operations */
|
|
118
120
|
content?: CurateContent;
|
|
119
121
|
/** Domain-level context for new domains */
|
|
120
122
|
domainContext?: CurateDomainContext;
|
|
123
|
+
/** Estimated scope of impact of this knowledge change */
|
|
124
|
+
impact?: 'high' | 'low';
|
|
121
125
|
/** Target path for MERGE operation */
|
|
122
126
|
mergeTarget?: string;
|
|
123
127
|
/** Title of the target file for MERGE operation */
|
|
@@ -128,6 +132,8 @@ export interface CurateOperation {
|
|
|
128
132
|
reason: string;
|
|
129
133
|
/** Subtopic-level context for new subtopics */
|
|
130
134
|
subtopicContext?: CurateSubtopicContext;
|
|
135
|
+
/** One-line semantic summary of what the knowledge file contains after this operation */
|
|
136
|
+
summary?: string;
|
|
131
137
|
/** Title for the context file (becomes {title}.md) */
|
|
132
138
|
title?: string;
|
|
133
139
|
/** Topic-level context for new topics */
|