causantic 0.2.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/LICENSE +19 -0
- package/README.md +332 -0
- package/config.schema.json +254 -0
- package/dist/cli/commands/archive.d.ts +4 -0
- package/dist/cli/commands/archive.d.ts.map +1 -0
- package/dist/cli/commands/archive.js +76 -0
- package/dist/cli/commands/archive.js.map +1 -0
- package/dist/cli/commands/benchmark-collection.d.ts +8 -0
- package/dist/cli/commands/benchmark-collection.d.ts.map +1 -0
- package/dist/cli/commands/benchmark-collection.js +146 -0
- package/dist/cli/commands/benchmark-collection.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +69 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +3 -0
- package/dist/cli/commands/dashboard.d.ts.map +1 -0
- package/dist/cli/commands/dashboard.js +12 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/commands/encryption.d.ts +3 -0
- package/dist/cli/commands/encryption.d.ts.map +1 -0
- package/dist/cli/commands/encryption.js +207 -0
- package/dist/cli/commands/encryption.js.map +1 -0
- package/dist/cli/commands/hook.d.ts +3 -0
- package/dist/cli/commands/hook.d.ts.map +1 -0
- package/dist/cli/commands/hook.js +35 -0
- package/dist/cli/commands/hook.js.map +1 -0
- package/dist/cli/commands/ingest.d.ts +4 -0
- package/dist/cli/commands/ingest.d.ts.map +1 -0
- package/dist/cli/commands/ingest.js +31 -0
- package/dist/cli/commands/ingest.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +680 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/maintenance.d.ts +3 -0
- package/dist/cli/commands/maintenance.d.ts.map +1 -0
- package/dist/cli/commands/maintenance.js +67 -0
- package/dist/cli/commands/maintenance.js.map +1 -0
- package/dist/cli/commands/search.d.ts +3 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +16 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +3 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +19 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +4 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +49 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/commands/uninstall.d.ts +3 -0
- package/dist/cli/commands/uninstall.d.ts.map +1 -0
- package/dist/cli/commands/uninstall.js +10 -0
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +86 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/skill-templates.d.ts +19 -0
- package/dist/cli/skill-templates.d.ts.map +1 -0
- package/dist/cli/skill-templates.js +1128 -0
- package/dist/cli/skill-templates.js.map +1 -0
- package/dist/cli/types.d.ts +10 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +5 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/uninstall.d.ts +66 -0
- package/dist/cli/uninstall.d.ts.map +1 -0
- package/dist/cli/uninstall.js +490 -0
- package/dist/cli/uninstall.js.map +1 -0
- package/dist/cli/utils.d.ts +26 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +105 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/clusters/cluster-manager.d.ts +96 -0
- package/dist/clusters/cluster-manager.d.ts.map +1 -0
- package/dist/clusters/cluster-manager.js +321 -0
- package/dist/clusters/cluster-manager.js.map +1 -0
- package/dist/clusters/cluster-refresh.d.ts +56 -0
- package/dist/clusters/cluster-refresh.d.ts.map +1 -0
- package/dist/clusters/cluster-refresh.js +187 -0
- package/dist/clusters/cluster-refresh.js.map +1 -0
- package/dist/clusters/hdbscan/cluster-extraction.d.ts +26 -0
- package/dist/clusters/hdbscan/cluster-extraction.d.ts.map +1 -0
- package/dist/clusters/hdbscan/cluster-extraction.js +232 -0
- package/dist/clusters/hdbscan/cluster-extraction.js.map +1 -0
- package/dist/clusters/hdbscan/core-distance-worker.d.ts +6 -0
- package/dist/clusters/hdbscan/core-distance-worker.d.ts.map +1 -0
- package/dist/clusters/hdbscan/core-distance-worker.js +54 -0
- package/dist/clusters/hdbscan/core-distance-worker.js.map +1 -0
- package/dist/clusters/hdbscan/core-distance.d.ts +26 -0
- package/dist/clusters/hdbscan/core-distance.d.ts.map +1 -0
- package/dist/clusters/hdbscan/core-distance.js +94 -0
- package/dist/clusters/hdbscan/core-distance.js.map +1 -0
- package/dist/clusters/hdbscan/distance-cache.d.ts +46 -0
- package/dist/clusters/hdbscan/distance-cache.d.ts.map +1 -0
- package/dist/clusters/hdbscan/distance-cache.js +84 -0
- package/dist/clusters/hdbscan/distance-cache.js.map +1 -0
- package/dist/clusters/hdbscan/hierarchy.d.ts +34 -0
- package/dist/clusters/hdbscan/hierarchy.d.ts.map +1 -0
- package/dist/clusters/hdbscan/hierarchy.js +442 -0
- package/dist/clusters/hdbscan/hierarchy.js.map +1 -0
- package/dist/clusters/hdbscan/incremental.d.ts +30 -0
- package/dist/clusters/hdbscan/incremental.d.ts.map +1 -0
- package/dist/clusters/hdbscan/incremental.js +130 -0
- package/dist/clusters/hdbscan/incremental.js.map +1 -0
- package/dist/clusters/hdbscan/kd-tree.d.ts +51 -0
- package/dist/clusters/hdbscan/kd-tree.d.ts.map +1 -0
- package/dist/clusters/hdbscan/kd-tree.js +130 -0
- package/dist/clusters/hdbscan/kd-tree.js.map +1 -0
- package/dist/clusters/hdbscan/min-heap.d.ts +62 -0
- package/dist/clusters/hdbscan/min-heap.d.ts.map +1 -0
- package/dist/clusters/hdbscan/min-heap.js +139 -0
- package/dist/clusters/hdbscan/min-heap.js.map +1 -0
- package/dist/clusters/hdbscan/mst.d.ts +20 -0
- package/dist/clusters/hdbscan/mst.d.ts.map +1 -0
- package/dist/clusters/hdbscan/mst.js +77 -0
- package/dist/clusters/hdbscan/mst.js.map +1 -0
- package/dist/clusters/hdbscan/probabilities.d.ts +37 -0
- package/dist/clusters/hdbscan/probabilities.d.ts.map +1 -0
- package/dist/clusters/hdbscan/probabilities.js +149 -0
- package/dist/clusters/hdbscan/probabilities.js.map +1 -0
- package/dist/clusters/hdbscan/types.d.ts +123 -0
- package/dist/clusters/hdbscan/types.d.ts.map +1 -0
- package/dist/clusters/hdbscan/types.js +5 -0
- package/dist/clusters/hdbscan/types.js.map +1 -0
- package/dist/clusters/hdbscan/union-find.d.ts +51 -0
- package/dist/clusters/hdbscan/union-find.d.ts.map +1 -0
- package/dist/clusters/hdbscan/union-find.js +115 -0
- package/dist/clusters/hdbscan/union-find.js.map +1 -0
- package/dist/clusters/hdbscan.d.ts +71 -0
- package/dist/clusters/hdbscan.d.ts.map +1 -0
- package/dist/clusters/hdbscan.js +283 -0
- package/dist/clusters/hdbscan.js.map +1 -0
- package/dist/clusters/index.d.ts +8 -0
- package/dist/clusters/index.d.ts.map +1 -0
- package/dist/clusters/index.js +8 -0
- package/dist/clusters/index.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +105 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +339 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/memory-config.d.ts +109 -0
- package/dist/config/memory-config.d.ts.map +1 -0
- package/dist/config/memory-config.js +182 -0
- package/dist/config/memory-config.js.map +1 -0
- package/dist/core/benchmark-types.d.ts +62 -0
- package/dist/core/benchmark-types.d.ts.map +1 -0
- package/dist/core/benchmark-types.js +11 -0
- package/dist/core/benchmark-types.js.map +1 -0
- package/dist/core/decay-types.d.ts +111 -0
- package/dist/core/decay-types.d.ts.map +1 -0
- package/dist/core/decay-types.js +30 -0
- package/dist/core/decay-types.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lexical-features.d.ts +34 -0
- package/dist/core/lexical-features.d.ts.map +1 -0
- package/dist/core/lexical-features.js +155 -0
- package/dist/core/lexical-features.js.map +1 -0
- package/dist/dashboard/client/assets/index-CMUKy4f9.css +1 -0
- package/dist/dashboard/client/assets/index-esv8TpCN.js +168 -0
- package/dist/dashboard/client/index.html +14 -0
- package/dist/dashboard/middleware/async-handler.d.ts +11 -0
- package/dist/dashboard/middleware/async-handler.d.ts.map +1 -0
- package/dist/dashboard/middleware/async-handler.js +12 -0
- package/dist/dashboard/middleware/async-handler.js.map +1 -0
- package/dist/dashboard/middleware/error-handler.d.ts +9 -0
- package/dist/dashboard/middleware/error-handler.d.ts.map +1 -0
- package/dist/dashboard/middleware/error-handler.js +14 -0
- package/dist/dashboard/middleware/error-handler.js.map +1 -0
- package/dist/dashboard/routes/benchmark-collection.d.ts +11 -0
- package/dist/dashboard/routes/benchmark-collection.d.ts.map +1 -0
- package/dist/dashboard/routes/benchmark-collection.js +49 -0
- package/dist/dashboard/routes/benchmark-collection.js.map +1 -0
- package/dist/dashboard/routes/chunks.d.ts +3 -0
- package/dist/dashboard/routes/chunks.d.ts.map +1 -0
- package/dist/dashboard/routes/chunks.js +25 -0
- package/dist/dashboard/routes/chunks.js.map +1 -0
- package/dist/dashboard/routes/clusters.d.ts +3 -0
- package/dist/dashboard/routes/clusters.d.ts.map +1 -0
- package/dist/dashboard/routes/clusters.js +28 -0
- package/dist/dashboard/routes/clusters.js.map +1 -0
- package/dist/dashboard/routes/edges.d.ts +3 -0
- package/dist/dashboard/routes/edges.d.ts.map +1 -0
- package/dist/dashboard/routes/edges.js +32 -0
- package/dist/dashboard/routes/edges.js.map +1 -0
- package/dist/dashboard/routes/graph.d.ts +3 -0
- package/dist/dashboard/routes/graph.d.ts.map +1 -0
- package/dist/dashboard/routes/graph.js +158 -0
- package/dist/dashboard/routes/graph.js.map +1 -0
- package/dist/dashboard/routes/projects.d.ts +3 -0
- package/dist/dashboard/routes/projects.d.ts.map +1 -0
- package/dist/dashboard/routes/projects.js +9 -0
- package/dist/dashboard/routes/projects.js.map +1 -0
- package/dist/dashboard/routes/search.d.ts +3 -0
- package/dist/dashboard/routes/search.d.ts.map +1 -0
- package/dist/dashboard/routes/search.js +105 -0
- package/dist/dashboard/routes/search.js.map +1 -0
- package/dist/dashboard/routes/sessions.d.ts +3 -0
- package/dist/dashboard/routes/sessions.d.ts.map +1 -0
- package/dist/dashboard/routes/sessions.js +16 -0
- package/dist/dashboard/routes/sessions.js.map +1 -0
- package/dist/dashboard/routes/stats.d.ts +3 -0
- package/dist/dashboard/routes/stats.d.ts.map +1 -0
- package/dist/dashboard/routes/stats.js +38 -0
- package/dist/dashboard/routes/stats.js.map +1 -0
- package/dist/dashboard/server.d.ts +3 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +85 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/eval/annotation-schema.d.ts +41 -0
- package/dist/eval/annotation-schema.d.ts.map +1 -0
- package/dist/eval/annotation-schema.js +171 -0
- package/dist/eval/annotation-schema.js.map +1 -0
- package/dist/eval/benchmark-runner.d.ts +15 -0
- package/dist/eval/benchmark-runner.d.ts.map +1 -0
- package/dist/eval/benchmark-runner.js +93 -0
- package/dist/eval/benchmark-runner.js.map +1 -0
- package/dist/eval/cluster-evaluator.d.ts +39 -0
- package/dist/eval/cluster-evaluator.d.ts.map +1 -0
- package/dist/eval/cluster-evaluator.js +51 -0
- package/dist/eval/cluster-evaluator.js.map +1 -0
- package/dist/eval/code-nl-alignment.d.ts +25 -0
- package/dist/eval/code-nl-alignment.d.ts.map +1 -0
- package/dist/eval/code-nl-alignment.js +49 -0
- package/dist/eval/code-nl-alignment.js.map +1 -0
- package/dist/eval/collection-benchmark/graph-value.d.ts +16 -0
- package/dist/eval/collection-benchmark/graph-value.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/graph-value.js +162 -0
- package/dist/eval/collection-benchmark/graph-value.js.map +1 -0
- package/dist/eval/collection-benchmark/health.d.ts +12 -0
- package/dist/eval/collection-benchmark/health.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/health.js +246 -0
- package/dist/eval/collection-benchmark/health.js.map +1 -0
- package/dist/eval/collection-benchmark/history.d.ts +27 -0
- package/dist/eval/collection-benchmark/history.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/history.js +134 -0
- package/dist/eval/collection-benchmark/history.js.map +1 -0
- package/dist/eval/collection-benchmark/latency.d.ts +16 -0
- package/dist/eval/collection-benchmark/latency.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/latency.js +115 -0
- package/dist/eval/collection-benchmark/latency.js.map +1 -0
- package/dist/eval/collection-benchmark/reporter.d.ts +18 -0
- package/dist/eval/collection-benchmark/reporter.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/reporter.js +244 -0
- package/dist/eval/collection-benchmark/reporter.js.map +1 -0
- package/dist/eval/collection-benchmark/retrieval.d.ts +15 -0
- package/dist/eval/collection-benchmark/retrieval.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/retrieval.js +203 -0
- package/dist/eval/collection-benchmark/retrieval.js.map +1 -0
- package/dist/eval/collection-benchmark/runner.d.ts +20 -0
- package/dist/eval/collection-benchmark/runner.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/runner.js +189 -0
- package/dist/eval/collection-benchmark/runner.js.map +1 -0
- package/dist/eval/collection-benchmark/sampler.d.ts +18 -0
- package/dist/eval/collection-benchmark/sampler.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/sampler.js +186 -0
- package/dist/eval/collection-benchmark/sampler.js.map +1 -0
- package/dist/eval/collection-benchmark/tuning.d.ts +12 -0
- package/dist/eval/collection-benchmark/tuning.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/tuning.js +222 -0
- package/dist/eval/collection-benchmark/tuning.js.map +1 -0
- package/dist/eval/collection-benchmark/types.d.ts +183 -0
- package/dist/eval/collection-benchmark/types.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/types.js +7 -0
- package/dist/eval/collection-benchmark/types.js.map +1 -0
- package/dist/eval/context-window-test.d.ts +34 -0
- package/dist/eval/context-window-test.d.ts.map +1 -0
- package/dist/eval/context-window-test.js +59 -0
- package/dist/eval/context-window-test.js.map +1 -0
- package/dist/eval/corpus-builder.d.ts +33 -0
- package/dist/eval/corpus-builder.d.ts.map +1 -0
- package/dist/eval/corpus-builder.js +88 -0
- package/dist/eval/corpus-builder.js.map +1 -0
- package/dist/eval/experiments/boilerplate-filter.d.ts +26 -0
- package/dist/eval/experiments/boilerplate-filter.d.ts.map +1 -0
- package/dist/eval/experiments/boilerplate-filter.js +95 -0
- package/dist/eval/experiments/boilerplate-filter.js.map +1 -0
- package/dist/eval/experiments/cluster-threshold/index.d.ts +6 -0
- package/dist/eval/experiments/cluster-threshold/index.d.ts.map +1 -0
- package/dist/eval/experiments/cluster-threshold/index.js +5 -0
- package/dist/eval/experiments/cluster-threshold/index.js.map +1 -0
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.d.ts +58 -0
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.d.ts.map +1 -0
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.js +246 -0
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.js.map +1 -0
- package/dist/eval/experiments/code-focused-mode.d.ts +20 -0
- package/dist/eval/experiments/code-focused-mode.d.ts.map +1 -0
- package/dist/eval/experiments/code-focused-mode.js +66 -0
- package/dist/eval/experiments/code-focused-mode.js.map +1 -0
- package/dist/eval/experiments/edge-decay/decay-curves.d.ts +59 -0
- package/dist/eval/experiments/edge-decay/decay-curves.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/decay-curves.js +124 -0
- package/dist/eval/experiments/edge-decay/decay-curves.js.map +1 -0
- package/dist/eval/experiments/edge-decay/index.d.ts +13 -0
- package/dist/eval/experiments/edge-decay/index.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/index.js +16 -0
- package/dist/eval/experiments/edge-decay/index.js.map +1 -0
- package/dist/eval/experiments/edge-decay/presets.d.ts +52 -0
- package/dist/eval/experiments/edge-decay/presets.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/presets.js +234 -0
- package/dist/eval/experiments/edge-decay/presets.js.map +1 -0
- package/dist/eval/experiments/edge-decay/reference-extractor.d.ts +34 -0
- package/dist/eval/experiments/edge-decay/reference-extractor.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/reference-extractor.js +353 -0
- package/dist/eval/experiments/edge-decay/reference-extractor.js.map +1 -0
- package/dist/eval/experiments/edge-decay/reference-types.d.ts +131 -0
- package/dist/eval/experiments/edge-decay/reference-types.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/reference-types.js +5 -0
- package/dist/eval/experiments/edge-decay/reference-types.js.map +1 -0
- package/dist/eval/experiments/edge-decay/retrieval-ranking.d.ts +64 -0
- package/dist/eval/experiments/edge-decay/retrieval-ranking.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/retrieval-ranking.js +565 -0
- package/dist/eval/experiments/edge-decay/retrieval-ranking.js.map +1 -0
- package/dist/eval/experiments/edge-decay/run-experiments.d.ts +25 -0
- package/dist/eval/experiments/edge-decay/run-experiments.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/run-experiments.js +229 -0
- package/dist/eval/experiments/edge-decay/run-experiments.js.map +1 -0
- package/dist/eval/experiments/edge-decay/simulate.d.ts +42 -0
- package/dist/eval/experiments/edge-decay/simulate.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/simulate.js +232 -0
- package/dist/eval/experiments/edge-decay/simulate.js.map +1 -0
- package/dist/eval/experiments/edge-decay/types.d.ts +10 -0
- package/dist/eval/experiments/edge-decay/types.d.ts.map +1 -0
- package/dist/eval/experiments/edge-decay/types.js +9 -0
- package/dist/eval/experiments/edge-decay/types.js.map +1 -0
- package/dist/eval/experiments/hdbscan-sweep.d.ts +19 -0
- package/dist/eval/experiments/hdbscan-sweep.d.ts.map +1 -0
- package/dist/eval/experiments/hdbscan-sweep.js +71 -0
- package/dist/eval/experiments/hdbscan-sweep.js.map +1 -0
- package/dist/eval/experiments/single-model-run.d.ts +54 -0
- package/dist/eval/experiments/single-model-run.d.ts.map +1 -0
- package/dist/eval/experiments/single-model-run.js +120 -0
- package/dist/eval/experiments/single-model-run.js.map +1 -0
- package/dist/eval/experiments/thinking-ablation.d.ts +21 -0
- package/dist/eval/experiments/thinking-ablation.d.ts.map +1 -0
- package/dist/eval/experiments/thinking-ablation.js +68 -0
- package/dist/eval/experiments/thinking-ablation.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/embedding-classifier.d.ts +55 -0
- package/dist/eval/experiments/topic-continuity/embedding-classifier.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/embedding-classifier.js +126 -0
- package/dist/eval/experiments/topic-continuity/embedding-classifier.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.d.ts +68 -0
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.js +175 -0
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/index.d.ts +13 -0
- package/dist/eval/experiments/topic-continuity/index.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/index.js +17 -0
- package/dist/eval/experiments/topic-continuity/index.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/labeler.d.ts +42 -0
- package/dist/eval/experiments/topic-continuity/labeler.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/labeler.js +253 -0
- package/dist/eval/experiments/topic-continuity/labeler.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/lexical-features.d.ts +26 -0
- package/dist/eval/experiments/topic-continuity/lexical-features.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/lexical-features.js +58 -0
- package/dist/eval/experiments/topic-continuity/lexical-features.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/run-experiment.d.ts +40 -0
- package/dist/eval/experiments/topic-continuity/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/run-experiment.js +379 -0
- package/dist/eval/experiments/topic-continuity/run-experiment.js.map +1 -0
- package/dist/eval/experiments/topic-continuity/types.d.ts +146 -0
- package/dist/eval/experiments/topic-continuity/types.d.ts.map +1 -0
- package/dist/eval/experiments/topic-continuity/types.js +9 -0
- package/dist/eval/experiments/topic-continuity/types.js.map +1 -0
- package/dist/eval/experiments/truncation.d.ts +21 -0
- package/dist/eval/experiments/truncation.d.ts.map +1 -0
- package/dist/eval/experiments/truncation.js +59 -0
- package/dist/eval/experiments/truncation.js.map +1 -0
- package/dist/eval/experiments/types.d.ts +37 -0
- package/dist/eval/experiments/types.d.ts.map +1 -0
- package/dist/eval/experiments/types.js +13 -0
- package/dist/eval/experiments/types.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.d.ts +10 -0
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.js +229 -0
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.d.ts +12 -0
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.js +316 -0
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.d.ts +19 -0
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.js +127 -0
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/index.d.ts +11 -0
- package/dist/eval/experiments/vector-decay-shapes/index.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/index.js +11 -0
- package/dist/eval/experiments/vector-decay-shapes/index.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.d.ts +14 -0
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.js +274 -0
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/presets.d.ts +36 -0
- package/dist/eval/experiments/vector-decay-shapes/presets.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/presets.js +157 -0
- package/dist/eval/experiments/vector-decay-shapes/presets.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.d.ts +20 -0
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.js +504 -0
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.js.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/types.d.ts +111 -0
- package/dist/eval/experiments/vector-decay-shapes/types.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-shapes/types.js +15 -0
- package/dist/eval/experiments/vector-decay-shapes/types.js.map +1 -0
- package/dist/eval/experiments/vector-decay-sweep/index.d.ts +7 -0
- package/dist/eval/experiments/vector-decay-sweep/index.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-sweep/index.js +7 -0
- package/dist/eval/experiments/vector-decay-sweep/index.js.map +1 -0
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.d.ts +30 -0
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.js +378 -0
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.js.map +1 -0
- package/dist/eval/experiments/vector-decay-sweep/types.d.ts +109 -0
- package/dist/eval/experiments/vector-decay-sweep/types.d.ts.map +1 -0
- package/dist/eval/experiments/vector-decay-sweep/types.js +16 -0
- package/dist/eval/experiments/vector-decay-sweep/types.js.map +1 -0
- package/dist/eval/metrics.d.ts +45 -0
- package/dist/eval/metrics.d.ts.map +1 -0
- package/dist/eval/metrics.js +134 -0
- package/dist/eval/metrics.js.map +1 -0
- package/dist/hooks/claudemd-generator.d.ts +62 -0
- package/dist/hooks/claudemd-generator.d.ts.map +1 -0
- package/dist/hooks/claudemd-generator.js +220 -0
- package/dist/hooks/claudemd-generator.js.map +1 -0
- package/dist/hooks/hook-utils.d.ts +84 -0
- package/dist/hooks/hook-utils.d.ts.map +1 -0
- package/dist/hooks/hook-utils.js +187 -0
- package/dist/hooks/hook-utils.js.map +1 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/pre-compact.d.ts +58 -0
- package/dist/hooks/pre-compact.d.ts.map +1 -0
- package/dist/hooks/pre-compact.js +127 -0
- package/dist/hooks/pre-compact.js.map +1 -0
- package/dist/hooks/session-start.d.ts +62 -0
- package/dist/hooks/session-start.d.ts.map +1 -0
- package/dist/hooks/session-start.js +249 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/batch-ingest.d.ts +94 -0
- package/dist/ingest/batch-ingest.d.ts.map +1 -0
- package/dist/ingest/batch-ingest.js +167 -0
- package/dist/ingest/batch-ingest.js.map +1 -0
- package/dist/ingest/brief-debrief-detector.d.ts +74 -0
- package/dist/ingest/brief-debrief-detector.d.ts.map +1 -0
- package/dist/ingest/brief-debrief-detector.js +253 -0
- package/dist/ingest/brief-debrief-detector.js.map +1 -0
- package/dist/ingest/cross-session-linker.d.ts +39 -0
- package/dist/ingest/cross-session-linker.d.ts.map +1 -0
- package/dist/ingest/cross-session-linker.js +103 -0
- package/dist/ingest/cross-session-linker.js.map +1 -0
- package/dist/ingest/edge-creator.d.ts +62 -0
- package/dist/ingest/edge-creator.d.ts.map +1 -0
- package/dist/ingest/edge-creator.js +186 -0
- package/dist/ingest/edge-creator.js.map +1 -0
- package/dist/ingest/edge-detector.d.ts +37 -0
- package/dist/ingest/edge-detector.d.ts.map +1 -0
- package/dist/ingest/edge-detector.js +234 -0
- package/dist/ingest/edge-detector.js.map +1 -0
- package/dist/ingest/index.d.ts +14 -0
- package/dist/ingest/index.d.ts.map +1 -0
- package/dist/ingest/index.js +14 -0
- package/dist/ingest/index.js.map +1 -0
- package/dist/ingest/ingest-session.d.ts +83 -0
- package/dist/ingest/ingest-session.d.ts.map +1 -0
- package/dist/ingest/ingest-session.js +415 -0
- package/dist/ingest/ingest-session.js.map +1 -0
- package/dist/maintenance/index.d.ts +5 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +5 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/scheduler.d.ts +79 -0
- package/dist/maintenance/scheduler.d.ts.map +1 -0
- package/dist/maintenance/scheduler.js +362 -0
- package/dist/maintenance/scheduler.js.map +1 -0
- package/dist/maintenance/tasks/cleanup-vectors.d.ts +10 -0
- package/dist/maintenance/tasks/cleanup-vectors.d.ts.map +1 -0
- package/dist/maintenance/tasks/cleanup-vectors.js +23 -0
- package/dist/maintenance/tasks/cleanup-vectors.js.map +1 -0
- package/dist/maintenance/tasks/index.d.ts +9 -0
- package/dist/maintenance/tasks/index.d.ts.map +1 -0
- package/dist/maintenance/tasks/index.js +9 -0
- package/dist/maintenance/tasks/index.js.map +1 -0
- package/dist/maintenance/tasks/prune-graph.d.ts +12 -0
- package/dist/maintenance/tasks/prune-graph.d.ts.map +1 -0
- package/dist/maintenance/tasks/prune-graph.js +23 -0
- package/dist/maintenance/tasks/prune-graph.js.map +1 -0
- package/dist/maintenance/tasks/scan-projects.d.ts +12 -0
- package/dist/maintenance/tasks/scan-projects.d.ts.map +1 -0
- package/dist/maintenance/tasks/scan-projects.js +31 -0
- package/dist/maintenance/tasks/scan-projects.js.map +1 -0
- package/dist/maintenance/tasks/update-clusters.d.ts +12 -0
- package/dist/maintenance/tasks/update-clusters.d.ts.map +1 -0
- package/dist/maintenance/tasks/update-clusters.js +41 -0
- package/dist/maintenance/tasks/update-clusters.js.map +1 -0
- package/dist/maintenance/tasks/vacuum.d.ts +10 -0
- package/dist/maintenance/tasks/vacuum.d.ts.map +1 -0
- package/dist/maintenance/tasks/vacuum.js +23 -0
- package/dist/maintenance/tasks/vacuum.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +90 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +395 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +52 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +292 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/models/device-detector.d.ts +32 -0
- package/dist/models/device-detector.d.ts.map +1 -0
- package/dist/models/device-detector.js +123 -0
- package/dist/models/device-detector.js.map +1 -0
- package/dist/models/embedder.d.ts +60 -0
- package/dist/models/embedder.d.ts.map +1 -0
- package/dist/models/embedder.js +171 -0
- package/dist/models/embedder.js.map +1 -0
- package/dist/models/model-registry.d.ts +25 -0
- package/dist/models/model-registry.d.ts.map +1 -0
- package/dist/models/model-registry.js +56 -0
- package/dist/models/model-registry.js.map +1 -0
- package/dist/parser/chunker.d.ts +74 -0
- package/dist/parser/chunker.d.ts.map +1 -0
- package/dist/parser/chunker.js +330 -0
- package/dist/parser/chunker.js.map +1 -0
- package/dist/parser/session-reader.d.ts +75 -0
- package/dist/parser/session-reader.d.ts.map +1 -0
- package/dist/parser/session-reader.js +198 -0
- package/dist/parser/session-reader.js.map +1 -0
- package/dist/parser/turn-assembler.d.ts +18 -0
- package/dist/parser/turn-assembler.d.ts.map +1 -0
- package/dist/parser/turn-assembler.js +150 -0
- package/dist/parser/turn-assembler.js.map +1 -0
- package/dist/parser/types.d.ts +124 -0
- package/dist/parser/types.d.ts.map +1 -0
- package/dist/parser/types.js +8 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/report/reporter.d.ts +18 -0
- package/dist/report/reporter.d.ts.map +1 -0
- package/dist/report/reporter.js +121 -0
- package/dist/report/reporter.js.map +1 -0
- package/dist/retrieval/cluster-expander.d.ts +30 -0
- package/dist/retrieval/cluster-expander.d.ts.map +1 -0
- package/dist/retrieval/cluster-expander.js +87 -0
- package/dist/retrieval/cluster-expander.js.map +1 -0
- package/dist/retrieval/context-assembler.d.ts +89 -0
- package/dist/retrieval/context-assembler.d.ts.map +1 -0
- package/dist/retrieval/context-assembler.js +313 -0
- package/dist/retrieval/context-assembler.js.map +1 -0
- package/dist/retrieval/index.d.ts +12 -0
- package/dist/retrieval/index.d.ts.map +1 -0
- package/dist/retrieval/index.js +12 -0
- package/dist/retrieval/index.js.map +1 -0
- package/dist/retrieval/rrf.d.ts +25 -0
- package/dist/retrieval/rrf.d.ts.map +1 -0
- package/dist/retrieval/rrf.js +56 -0
- package/dist/retrieval/rrf.js.map +1 -0
- package/dist/retrieval/session-reconstructor.d.ts +79 -0
- package/dist/retrieval/session-reconstructor.d.ts.map +1 -0
- package/dist/retrieval/session-reconstructor.js +173 -0
- package/dist/retrieval/session-reconstructor.js.map +1 -0
- package/dist/retrieval/traverser.d.ts +66 -0
- package/dist/retrieval/traverser.d.ts.map +1 -0
- package/dist/retrieval/traverser.js +160 -0
- package/dist/retrieval/traverser.js.map +1 -0
- package/dist/storage/archive.d.ts +81 -0
- package/dist/storage/archive.d.ts.map +1 -0
- package/dist/storage/archive.js +204 -0
- package/dist/storage/archive.js.map +1 -0
- package/dist/storage/audit-log.d.ts +29 -0
- package/dist/storage/audit-log.d.ts.map +1 -0
- package/dist/storage/audit-log.js +69 -0
- package/dist/storage/audit-log.js.map +1 -0
- package/dist/storage/checkpoint-store.d.ts +38 -0
- package/dist/storage/checkpoint-store.d.ts.map +1 -0
- package/dist/storage/checkpoint-store.js +76 -0
- package/dist/storage/checkpoint-store.js.map +1 -0
- package/dist/storage/chunk-store.d.ts +111 -0
- package/dist/storage/chunk-store.d.ts.map +1 -0
- package/dist/storage/chunk-store.js +298 -0
- package/dist/storage/chunk-store.js.map +1 -0
- package/dist/storage/clock-store.d.ts +80 -0
- package/dist/storage/clock-store.d.ts.map +1 -0
- package/dist/storage/clock-store.js +155 -0
- package/dist/storage/clock-store.js.map +1 -0
- package/dist/storage/cluster-store.d.ts +63 -0
- package/dist/storage/cluster-store.d.ts.map +1 -0
- package/dist/storage/cluster-store.js +219 -0
- package/dist/storage/cluster-store.js.map +1 -0
- package/dist/storage/db.d.ts +57 -0
- package/dist/storage/db.d.ts.map +1 -0
- package/dist/storage/db.js +249 -0
- package/dist/storage/db.js.map +1 -0
- package/dist/storage/decay.d.ts +125 -0
- package/dist/storage/decay.d.ts.map +1 -0
- package/dist/storage/decay.js +276 -0
- package/dist/storage/decay.js.map +1 -0
- package/dist/storage/edge-store.d.ts +75 -0
- package/dist/storage/edge-store.d.ts.map +1 -0
- package/dist/storage/edge-store.js +259 -0
- package/dist/storage/edge-store.js.map +1 -0
- package/dist/storage/embedding-cache.d.ts +51 -0
- package/dist/storage/embedding-cache.d.ts.map +1 -0
- package/dist/storage/embedding-cache.js +155 -0
- package/dist/storage/embedding-cache.js.map +1 -0
- package/dist/storage/encryption.d.ts +55 -0
- package/dist/storage/encryption.d.ts.map +1 -0
- package/dist/storage/encryption.js +130 -0
- package/dist/storage/encryption.js.map +1 -0
- package/dist/storage/index.d.ts +15 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +20 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/keyword-store.d.ts +25 -0
- package/dist/storage/keyword-store.d.ts.map +1 -0
- package/dist/storage/keyword-store.js +104 -0
- package/dist/storage/keyword-store.js.map +1 -0
- package/dist/storage/migrations.d.ts +12 -0
- package/dist/storage/migrations.d.ts.map +1 -0
- package/dist/storage/migrations.js +345 -0
- package/dist/storage/migrations.js.map +1 -0
- package/dist/storage/pruner.d.ts +111 -0
- package/dist/storage/pruner.d.ts.map +1 -0
- package/dist/storage/pruner.js +280 -0
- package/dist/storage/pruner.js.map +1 -0
- package/dist/storage/schema-loader.d.ts +18 -0
- package/dist/storage/schema-loader.d.ts.map +1 -0
- package/dist/storage/schema-loader.js +62 -0
- package/dist/storage/schema-loader.js.map +1 -0
- package/dist/storage/schema.sql +133 -0
- package/dist/storage/types.d.ts +278 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +14 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/storage/vector-store.d.ts +213 -0
- package/dist/storage/vector-store.d.ts.map +1 -0
- package/dist/storage/vector-store.js +440 -0
- package/dist/storage/vector-store.js.map +1 -0
- package/dist/temporal/clock-compactor.d.ts +65 -0
- package/dist/temporal/clock-compactor.d.ts.map +1 -0
- package/dist/temporal/clock-compactor.js +157 -0
- package/dist/temporal/clock-compactor.js.map +1 -0
- package/dist/temporal/index.d.ts +6 -0
- package/dist/temporal/index.d.ts.map +1 -0
- package/dist/temporal/index.js +6 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/vector-clock.d.ts +143 -0
- package/dist/temporal/vector-clock.d.ts.map +1 -0
- package/dist/temporal/vector-clock.js +231 -0
- package/dist/temporal/vector-clock.js.map +1 -0
- package/dist/utils/angular-distance.d.ts +31 -0
- package/dist/utils/angular-distance.d.ts.map +1 -0
- package/dist/utils/angular-distance.js +61 -0
- package/dist/utils/angular-distance.js.map +1 -0
- package/dist/utils/array-utils.d.ts +28 -0
- package/dist/utils/array-utils.d.ts.map +1 -0
- package/dist/utils/array-utils.js +67 -0
- package/dist/utils/array-utils.js.map +1 -0
- package/dist/utils/embedding-utils.d.ts +25 -0
- package/dist/utils/embedding-utils.d.ts.map +1 -0
- package/dist/utils/embedding-utils.js +30 -0
- package/dist/utils/embedding-utils.js.map +1 -0
- package/dist/utils/errors.d.ts +143 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +220 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/keychain.d.ts +43 -0
- package/dist/utils/keychain.d.ts.map +1 -0
- package/dist/utils/keychain.js +82 -0
- package/dist/utils/keychain.js.map +1 -0
- package/dist/utils/logger.d.ts +50 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +104 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/secret-store.d.ts +110 -0
- package/dist/utils/secret-store.d.ts.map +1 -0
- package/dist/utils/secret-store.js +340 -0
- package/dist/utils/secret-store.js.map +1 -0
- package/dist/utils/secure-buffer.d.ts +66 -0
- package/dist/utils/secure-buffer.d.ts.map +1 -0
- package/dist/utils/secure-buffer.js +104 -0
- package/dist/utils/secure-buffer.js.map +1 -0
- package/dist/utils/token-counter.d.ts +13 -0
- package/dist/utils/token-counter.d.ts.map +1 -0
- package/dist/utils/token-counter.js +18 -0
- package/dist/utils/token-counter.js.map +1 -0
- package/package.json +110 -0
- package/src/dashboard/client/package-lock.json +3045 -0
- package/src/dashboard/client/package.json +30 -0
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { runTask } from '../../maintenance/scheduler.js';
|
|
6
|
+
import { getDb, storeDbKey } from '../../storage/db.js';
|
|
7
|
+
import { getChunkCount } from '../../storage/chunk-store.js';
|
|
8
|
+
import { createSecretStore } from '../../utils/secret-store.js';
|
|
9
|
+
import { promptPassword, promptYesNo, promptUser } from '../utils.js';
|
|
10
|
+
/** Resolve the CLI entry point path for MCP/hook configuration. */
|
|
11
|
+
function getCliEntryPath() {
|
|
12
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'index.js');
|
|
13
|
+
}
|
|
14
|
+
function checkNodeVersion() {
|
|
15
|
+
const nodeVersion = process.versions.node;
|
|
16
|
+
const majorVersion = parseInt(nodeVersion.split('.')[0], 10);
|
|
17
|
+
if (majorVersion >= 20) {
|
|
18
|
+
console.log(`\u2713 Node.js ${nodeVersion}`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.log(`\u2717 Node.js ${nodeVersion} (requires 20+)`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function createDirectoryStructure(causanticDir) {
|
|
26
|
+
const vectorsDir = path.join(causanticDir, 'vectors');
|
|
27
|
+
for (const dir of [causanticDir, vectorsDir]) {
|
|
28
|
+
if (!fs.existsSync(dir)) {
|
|
29
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
30
|
+
console.log(`\u2713 Created ${dir}`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.log(`\u2713 Directory exists: ${dir}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function setupEncryption(causanticDir) {
|
|
38
|
+
const dbPath = path.join(causanticDir, 'memory.db');
|
|
39
|
+
const existingDbExists = fs.existsSync(dbPath) && fs.statSync(dbPath).size > 0;
|
|
40
|
+
let existingDbIsUnencrypted = false;
|
|
41
|
+
if (existingDbExists) {
|
|
42
|
+
try {
|
|
43
|
+
const Database = (await import('better-sqlite3-multiple-ciphers')).default;
|
|
44
|
+
const testDb = new Database(dbPath);
|
|
45
|
+
testDb.prepare('SELECT 1').get();
|
|
46
|
+
testDb.close();
|
|
47
|
+
existingDbIsUnencrypted = true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// DB exists but can't be opened without key — may already be encrypted
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
console.log('');
|
|
54
|
+
console.log('Enable database encryption?');
|
|
55
|
+
console.log('Protects conversation data, embeddings, and work patterns.');
|
|
56
|
+
if (existingDbIsUnencrypted) {
|
|
57
|
+
console.log('');
|
|
58
|
+
console.log('\u26a0 Existing unencrypted database detected.');
|
|
59
|
+
console.log(' Enabling encryption will back up the existing database and create a new encrypted one.');
|
|
60
|
+
console.log(' Your data will be migrated automatically.');
|
|
61
|
+
}
|
|
62
|
+
if (!(await promptYesNo('Enable encryption?')))
|
|
63
|
+
return false;
|
|
64
|
+
const { generatePassword } = await import('../../storage/encryption.js');
|
|
65
|
+
if (existingDbIsUnencrypted) {
|
|
66
|
+
const backupPath = dbPath + '.unencrypted.bak';
|
|
67
|
+
fs.copyFileSync(dbPath, backupPath);
|
|
68
|
+
console.log(`\u2713 Backed up existing database to ${path.basename(backupPath)}`);
|
|
69
|
+
fs.unlinkSync(dbPath);
|
|
70
|
+
for (const suffix of ['-wal', '-shm']) {
|
|
71
|
+
const walPath = dbPath + suffix;
|
|
72
|
+
if (fs.existsSync(walPath))
|
|
73
|
+
fs.unlinkSync(walPath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
console.log('');
|
|
77
|
+
console.log('Generating encryption key...');
|
|
78
|
+
const key = generatePassword(32);
|
|
79
|
+
await storeDbKey(key);
|
|
80
|
+
const configPath = path.join(causanticDir, 'config.json');
|
|
81
|
+
const existingConfig = fs.existsSync(configPath)
|
|
82
|
+
? JSON.parse(fs.readFileSync(configPath, 'utf-8'))
|
|
83
|
+
: {};
|
|
84
|
+
fs.writeFileSync(configPath, JSON.stringify({
|
|
85
|
+
...existingConfig,
|
|
86
|
+
encryption: { enabled: true, cipher: 'chacha20', keySource: 'keychain' },
|
|
87
|
+
}, null, 2));
|
|
88
|
+
console.log('\u2713 Key stored in system keychain');
|
|
89
|
+
console.log('\u2713 Encryption enabled with ChaCha20-Poly1305');
|
|
90
|
+
if (existingDbIsUnencrypted) {
|
|
91
|
+
await migrateToEncryptedDb(dbPath);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
async function migrateToEncryptedDb(dbPath) {
|
|
96
|
+
const backupPath = dbPath + '.unencrypted.bak';
|
|
97
|
+
try {
|
|
98
|
+
const newDb = getDb();
|
|
99
|
+
const Database = (await import('better-sqlite3-multiple-ciphers')).default;
|
|
100
|
+
const oldDb = new Database(backupPath);
|
|
101
|
+
const tables = oldDb
|
|
102
|
+
.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name != 'schema_version'")
|
|
103
|
+
.all();
|
|
104
|
+
let migratedRows = 0;
|
|
105
|
+
for (const { name } of tables) {
|
|
106
|
+
const exists = newDb
|
|
107
|
+
.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?")
|
|
108
|
+
.get(name);
|
|
109
|
+
if (!exists)
|
|
110
|
+
continue;
|
|
111
|
+
const rows = oldDb.prepare(`SELECT * FROM "${name}"`).all();
|
|
112
|
+
if (rows.length === 0)
|
|
113
|
+
continue;
|
|
114
|
+
const columns = Object.keys(rows[0]);
|
|
115
|
+
const placeholders = columns.map(() => '?').join(', ');
|
|
116
|
+
const insert = newDb.prepare(`INSERT OR IGNORE INTO "${name}" (${columns.map((c) => `"${c}"`).join(', ')}) VALUES (${placeholders})`);
|
|
117
|
+
const batchInsert = newDb.transaction((rowBatch) => {
|
|
118
|
+
for (const row of rowBatch) {
|
|
119
|
+
insert.run(...columns.map((c) => row[c]));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
batchInsert(rows);
|
|
123
|
+
migratedRows += rows.length;
|
|
124
|
+
}
|
|
125
|
+
oldDb.close();
|
|
126
|
+
console.log(`\u2713 Migrated ${migratedRows} rows to encrypted database`);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
console.log(`\u26a0 Migration error: ${err.message}`);
|
|
130
|
+
console.log(` Backup preserved at: ${backupPath}`);
|
|
131
|
+
console.log(' You can manually re-import with: causantic import');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function initializeDatabase(encryptionEnabled) {
|
|
135
|
+
try {
|
|
136
|
+
const db = getDb();
|
|
137
|
+
db.prepare('SELECT 1').get();
|
|
138
|
+
console.log('\u2713 Database initialized' + (encryptionEnabled ? ' (encrypted)' : ''));
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.log(`\u2717 Database error: ${error.message}`);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function configureMcp(claudeConfigPath) {
|
|
146
|
+
if (!fs.existsSync(claudeConfigPath)) {
|
|
147
|
+
console.log('\u26a0 Claude Code config not found');
|
|
148
|
+
console.log(' Create it manually or install Claude Code first');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
console.log('\u2713 Claude Code config found');
|
|
152
|
+
try {
|
|
153
|
+
const configContent = fs.readFileSync(claudeConfigPath, 'utf-8');
|
|
154
|
+
const config = JSON.parse(configContent);
|
|
155
|
+
const CAUSANTIC_SERVER_KEY = 'causantic';
|
|
156
|
+
// Migrate old 'memory' key -> 'causantic'
|
|
157
|
+
if (config.mcpServers?.memory && !config.mcpServers[CAUSANTIC_SERVER_KEY]) {
|
|
158
|
+
config.mcpServers[CAUSANTIC_SERVER_KEY] = config.mcpServers.memory;
|
|
159
|
+
delete config.mcpServers.memory;
|
|
160
|
+
fs.writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2));
|
|
161
|
+
console.log('\u2713 Migrated config: memory \u2192 causantic');
|
|
162
|
+
}
|
|
163
|
+
if (config.mcpServers?.[CAUSANTIC_SERVER_KEY]) {
|
|
164
|
+
if (config.mcpServers[CAUSANTIC_SERVER_KEY].command === 'npx') {
|
|
165
|
+
config.mcpServers[CAUSANTIC_SERVER_KEY] = {
|
|
166
|
+
command: process.execPath,
|
|
167
|
+
args: [getCliEntryPath(), 'serve'],
|
|
168
|
+
};
|
|
169
|
+
fs.writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2));
|
|
170
|
+
console.log('\u2713 Updated Causantic config to use absolute paths');
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
console.log('\u2713 Causantic already configured in Claude Code');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
if (await promptYesNo('Add Causantic to Claude Code MCP config?', true)) {
|
|
178
|
+
config.mcpServers = config.mcpServers || {};
|
|
179
|
+
config.mcpServers[CAUSANTIC_SERVER_KEY] = {
|
|
180
|
+
command: process.execPath,
|
|
181
|
+
args: [getCliEntryPath(), 'serve'],
|
|
182
|
+
};
|
|
183
|
+
fs.writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2));
|
|
184
|
+
console.log('\u2713 Added Causantic to Claude Code config');
|
|
185
|
+
console.log(` Node: ${process.execPath}`);
|
|
186
|
+
console.log(' Restart Claude Code to activate');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
console.log('\u26a0 Could not parse Claude Code config');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function patchProjectMcpFiles() {
|
|
195
|
+
const claudeProjectsDir = path.join(os.homedir(), '.claude', 'projects');
|
|
196
|
+
if (!fs.existsSync(claudeProjectsDir))
|
|
197
|
+
return;
|
|
198
|
+
const serverConfig = {
|
|
199
|
+
command: process.execPath,
|
|
200
|
+
args: [getCliEntryPath(), 'serve'],
|
|
201
|
+
};
|
|
202
|
+
const CAUSANTIC_KEY = 'causantic';
|
|
203
|
+
const projectsToFix = [];
|
|
204
|
+
try {
|
|
205
|
+
const entries = fs.readdirSync(claudeProjectsDir, { withFileTypes: true });
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
if (!entry.isDirectory() || entry.name.startsWith('.'))
|
|
208
|
+
continue;
|
|
209
|
+
const projectPath = '/' + entry.name.replace(/^-/, '').replace(/-/g, '/');
|
|
210
|
+
const mcpPath = path.join(projectPath, '.mcp.json');
|
|
211
|
+
if (!fs.existsSync(mcpPath))
|
|
212
|
+
continue;
|
|
213
|
+
try {
|
|
214
|
+
const mcpContent = JSON.parse(fs.readFileSync(mcpPath, 'utf-8'));
|
|
215
|
+
if (!mcpContent.mcpServers)
|
|
216
|
+
continue;
|
|
217
|
+
const readableName = projectPath.replace(new RegExp(`^/Users/${os.userInfo().username}/`), '~/');
|
|
218
|
+
if (mcpContent.mcpServers.memory && !mcpContent.mcpServers[CAUSANTIC_KEY]) {
|
|
219
|
+
projectsToFix.push({ name: readableName, mcpPath, needsMigrate: true });
|
|
220
|
+
}
|
|
221
|
+
else if (!mcpContent.mcpServers[CAUSANTIC_KEY]) {
|
|
222
|
+
projectsToFix.push({ name: readableName, mcpPath, needsMigrate: false });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Skip unparseable files
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (projectsToFix.length === 0)
|
|
234
|
+
return;
|
|
235
|
+
const migrateCount = projectsToFix.filter((p) => p.needsMigrate).length;
|
|
236
|
+
const addCount = projectsToFix.length - migrateCount;
|
|
237
|
+
console.log('');
|
|
238
|
+
if (migrateCount > 0 && addCount > 0) {
|
|
239
|
+
console.log(`Found ${addCount} project(s) missing Causantic and ${migrateCount} to migrate:`);
|
|
240
|
+
}
|
|
241
|
+
else if (migrateCount > 0) {
|
|
242
|
+
console.log(`Found ${migrateCount} project(s) with old 'memory' key to migrate:`);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
console.log(`Found ${addCount} project(s) with .mcp.json missing Causantic:`);
|
|
246
|
+
}
|
|
247
|
+
for (const p of projectsToFix) {
|
|
248
|
+
console.log(` ${p.name}${p.needsMigrate ? ' (migrate)' : ''}`);
|
|
249
|
+
}
|
|
250
|
+
if (!(await promptYesNo('Add/migrate Causantic server in these projects?', true)))
|
|
251
|
+
return;
|
|
252
|
+
let patched = 0;
|
|
253
|
+
for (const p of projectsToFix) {
|
|
254
|
+
try {
|
|
255
|
+
const mcpContent = JSON.parse(fs.readFileSync(p.mcpPath, 'utf-8'));
|
|
256
|
+
if (p.needsMigrate) {
|
|
257
|
+
mcpContent.mcpServers[CAUSANTIC_KEY] = mcpContent.mcpServers.memory;
|
|
258
|
+
delete mcpContent.mcpServers.memory;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
mcpContent.mcpServers[CAUSANTIC_KEY] = serverConfig;
|
|
262
|
+
}
|
|
263
|
+
fs.writeFileSync(p.mcpPath, JSON.stringify(mcpContent, null, 2) + '\n');
|
|
264
|
+
patched++;
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
console.log(` \u26a0 Could not patch ${p.name}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (patched > 0) {
|
|
271
|
+
console.log(`\u2713 Updated Causantic in ${patched} project .mcp.json file(s)`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function installSkillsAndClaudeMd() {
|
|
275
|
+
const { CAUSANTIC_SKILLS, getMinimalClaudeMdBlock } = await import('../skill-templates.js');
|
|
276
|
+
const skillsDir = path.join(os.homedir(), '.claude', 'skills');
|
|
277
|
+
let skillsInstalled = 0;
|
|
278
|
+
for (const skill of CAUSANTIC_SKILLS) {
|
|
279
|
+
try {
|
|
280
|
+
const skillDir = path.join(skillsDir, skill.dirName);
|
|
281
|
+
if (!fs.existsSync(skillDir)) {
|
|
282
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
283
|
+
}
|
|
284
|
+
fs.writeFileSync(path.join(skillDir, 'SKILL.md'), skill.content);
|
|
285
|
+
skillsInstalled++;
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
console.log(`\u26a0 Could not install skill: ${skill.dirName}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (skillsInstalled > 0) {
|
|
292
|
+
console.log(`\u2713 Installed ${skillsInstalled} Causantic skills to ~/.claude/skills/`);
|
|
293
|
+
}
|
|
294
|
+
const claudeMdPath = path.join(os.homedir(), '.claude', 'CLAUDE.md');
|
|
295
|
+
const CAUSANTIC_START = '<!-- CAUSANTIC_MEMORY_START -->';
|
|
296
|
+
const CAUSANTIC_END = '<!-- CAUSANTIC_MEMORY_END -->';
|
|
297
|
+
const memoryInstructions = getMinimalClaudeMdBlock();
|
|
298
|
+
try {
|
|
299
|
+
let claudeMd = '';
|
|
300
|
+
if (fs.existsSync(claudeMdPath)) {
|
|
301
|
+
claudeMd = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
302
|
+
}
|
|
303
|
+
if (claudeMd.includes(CAUSANTIC_START)) {
|
|
304
|
+
const startIdx = claudeMd.indexOf(CAUSANTIC_START);
|
|
305
|
+
const endIdx = claudeMd.indexOf(CAUSANTIC_END);
|
|
306
|
+
if (endIdx > startIdx) {
|
|
307
|
+
claudeMd = claudeMd.slice(0, startIdx) + memoryInstructions + claudeMd.slice(endIdx + CAUSANTIC_END.length);
|
|
308
|
+
fs.writeFileSync(claudeMdPath, claudeMd);
|
|
309
|
+
console.log('\u2713 Updated CLAUDE.md with skill references');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
const separator = claudeMd.length > 0 && !claudeMd.endsWith('\n\n') ? '\n' : '';
|
|
314
|
+
fs.writeFileSync(claudeMdPath, claudeMd + separator + memoryInstructions + '\n');
|
|
315
|
+
console.log('\u2713 Added Causantic reference to CLAUDE.md');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
console.log('\u26a0 Could not update CLAUDE.md');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async function configureHooks(claudeConfigPath) {
|
|
323
|
+
try {
|
|
324
|
+
const settingsContent = fs.readFileSync(claudeConfigPath, 'utf-8');
|
|
325
|
+
const config = JSON.parse(settingsContent);
|
|
326
|
+
const cliEntry = getCliEntryPath();
|
|
327
|
+
const nodeBin = process.execPath;
|
|
328
|
+
const causanticHooks = [
|
|
329
|
+
{
|
|
330
|
+
event: 'PreCompact',
|
|
331
|
+
matcher: '',
|
|
332
|
+
hook: {
|
|
333
|
+
type: 'command',
|
|
334
|
+
command: `${nodeBin} ${cliEntry} hook pre-compact`,
|
|
335
|
+
timeout: 300,
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
event: 'SessionStart',
|
|
340
|
+
matcher: '',
|
|
341
|
+
hook: {
|
|
342
|
+
type: 'command',
|
|
343
|
+
command: `${nodeBin} ${cliEntry} hook session-start`,
|
|
344
|
+
timeout: 60,
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
];
|
|
348
|
+
if (!config.hooks) {
|
|
349
|
+
config.hooks = {};
|
|
350
|
+
}
|
|
351
|
+
let hooksAdded = 0;
|
|
352
|
+
for (const { event, matcher, hook } of causanticHooks) {
|
|
353
|
+
if (!config.hooks[event]) {
|
|
354
|
+
config.hooks[event] = [];
|
|
355
|
+
}
|
|
356
|
+
const alreadyConfigured = config.hooks[event].some((entry) => entry.hooks?.some((h) => h.command?.includes('causantic')));
|
|
357
|
+
if (!alreadyConfigured) {
|
|
358
|
+
config.hooks[event].push({
|
|
359
|
+
matcher,
|
|
360
|
+
hooks: [hook],
|
|
361
|
+
});
|
|
362
|
+
hooksAdded++;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (hooksAdded > 0) {
|
|
366
|
+
fs.writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2));
|
|
367
|
+
console.log(`\u2713 Configured ${hooksAdded} Claude Code hooks (PreCompact, SessionStart)`);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
console.log('\u2713 Claude Code hooks already configured');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
console.log('\u26a0 Could not configure Claude Code hooks');
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
async function runHealthCheck() {
|
|
378
|
+
console.log('');
|
|
379
|
+
console.log('Running health check...');
|
|
380
|
+
try {
|
|
381
|
+
const { vectorStore } = await import('../../storage/vector-store.js');
|
|
382
|
+
if (vectorStore && typeof vectorStore.count === 'function') {
|
|
383
|
+
await vectorStore.count();
|
|
384
|
+
}
|
|
385
|
+
console.log('\u2713 Vector store OK');
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
console.log(`\u26a0 Vector store: ${error.message}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
/** Create a terminal spinner for progress display. */
|
|
392
|
+
function createSpinner() {
|
|
393
|
+
const frames = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f'];
|
|
394
|
+
let idx = 0;
|
|
395
|
+
let timer = null;
|
|
396
|
+
let text = '';
|
|
397
|
+
const writeLine = (line) => {
|
|
398
|
+
if (process.stdout.isTTY) {
|
|
399
|
+
process.stdout.write('\r\x1b[K' + line);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
return {
|
|
403
|
+
start(label) {
|
|
404
|
+
if (!process.stdout.isTTY)
|
|
405
|
+
return;
|
|
406
|
+
text = label;
|
|
407
|
+
idx = 0;
|
|
408
|
+
writeLine(`${frames[0]} ${text}`);
|
|
409
|
+
timer = setInterval(() => {
|
|
410
|
+
idx = (idx + 1) % frames.length;
|
|
411
|
+
writeLine(`${frames[idx]} ${text}`);
|
|
412
|
+
}, 80);
|
|
413
|
+
},
|
|
414
|
+
update(label) {
|
|
415
|
+
text = label;
|
|
416
|
+
},
|
|
417
|
+
stop(doneText) {
|
|
418
|
+
if (timer) {
|
|
419
|
+
clearInterval(timer);
|
|
420
|
+
timer = null;
|
|
421
|
+
}
|
|
422
|
+
if (process.stdout.isTTY) {
|
|
423
|
+
process.stdout.write('\r\x1b[K');
|
|
424
|
+
}
|
|
425
|
+
if (doneText) {
|
|
426
|
+
console.log(doneText);
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
async function offerBatchIngest() {
|
|
432
|
+
const claudeProjectsDir = path.join(os.homedir(), '.claude', 'projects');
|
|
433
|
+
if (!fs.existsSync(claudeProjectsDir))
|
|
434
|
+
return;
|
|
435
|
+
console.log('');
|
|
436
|
+
console.log('Existing Claude Code sessions found.');
|
|
437
|
+
const projectDirs = [];
|
|
438
|
+
try {
|
|
439
|
+
const entries = fs.readdirSync(claudeProjectsDir, { withFileTypes: true });
|
|
440
|
+
for (const entry of entries) {
|
|
441
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
442
|
+
const projectPath = path.join(claudeProjectsDir, entry.name);
|
|
443
|
+
const files = fs.readdirSync(projectPath);
|
|
444
|
+
const sessionCount = files.filter((f) => f.endsWith('.jsonl') &&
|
|
445
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.jsonl$/i.test(f)).length;
|
|
446
|
+
if (sessionCount > 0) {
|
|
447
|
+
const readableName = entry.name
|
|
448
|
+
.replace(/^-/, '')
|
|
449
|
+
.replace(/-/g, '/')
|
|
450
|
+
.replace(/^Users\/[^/]+\//, '~/');
|
|
451
|
+
projectDirs.push({ name: readableName, path: projectPath, sessionCount });
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
catch {
|
|
457
|
+
// Ignore errors reading projects
|
|
458
|
+
}
|
|
459
|
+
if (projectDirs.length === 0)
|
|
460
|
+
return;
|
|
461
|
+
projectDirs.sort((a, b) => b.sessionCount - a.sessionCount);
|
|
462
|
+
const totalSessions = projectDirs.reduce((sum, p) => sum + p.sessionCount, 0);
|
|
463
|
+
console.log(`Found ${projectDirs.length} projects with ${totalSessions} total sessions.`);
|
|
464
|
+
console.log('');
|
|
465
|
+
console.log('Import existing sessions?');
|
|
466
|
+
console.log(' [A] All projects');
|
|
467
|
+
console.log(' [S] Select specific projects');
|
|
468
|
+
console.log(' [N] Skip (can run "causantic batch-ingest" later)');
|
|
469
|
+
console.log('');
|
|
470
|
+
const importChoice = (await promptUser('Choice [A/s/n]: ')).toLowerCase() || 'a';
|
|
471
|
+
let projectsToIngest = [];
|
|
472
|
+
if (importChoice === 'a' || importChoice === 'all') {
|
|
473
|
+
projectsToIngest = projectDirs.map((p) => p.path);
|
|
474
|
+
}
|
|
475
|
+
else if (importChoice === 's' || importChoice === 'select') {
|
|
476
|
+
console.log('');
|
|
477
|
+
console.log('Select projects to import (comma-separated numbers, or "all"):');
|
|
478
|
+
console.log('');
|
|
479
|
+
projectDirs.forEach((p, i) => {
|
|
480
|
+
console.log(` [${i + 1}] ${p.name} (${p.sessionCount} sessions)`);
|
|
481
|
+
});
|
|
482
|
+
console.log('');
|
|
483
|
+
const selection = (await promptUser('Projects: ')).trim();
|
|
484
|
+
if (selection.toLowerCase() === 'all') {
|
|
485
|
+
projectsToIngest = projectDirs.map((p) => p.path);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const indices = selection.split(',').map((s) => parseInt(s.trim(), 10) - 1);
|
|
489
|
+
for (const idx of indices) {
|
|
490
|
+
if (idx >= 0 && idx < projectDirs.length) {
|
|
491
|
+
projectsToIngest.push(projectDirs[idx].path);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
console.log('Skipping session import.');
|
|
498
|
+
}
|
|
499
|
+
if (projectsToIngest.length === 0)
|
|
500
|
+
return;
|
|
501
|
+
const spinner = createSpinner();
|
|
502
|
+
const { detectDevice } = await import('../../models/device-detector.js');
|
|
503
|
+
const { setLogLevel } = await import('../../utils/logger.js');
|
|
504
|
+
const detectedDevice = detectDevice();
|
|
505
|
+
console.log('');
|
|
506
|
+
const availableHint = detectedDevice.available?.length
|
|
507
|
+
? ` (${detectedDevice.available.join(', ')} available)`
|
|
508
|
+
: '';
|
|
509
|
+
console.log(`\u2713 Inference: ${detectedDevice.label}${availableHint}`);
|
|
510
|
+
console.log(`Importing ${projectsToIngest.length} project(s)...`);
|
|
511
|
+
console.log('');
|
|
512
|
+
setLogLevel('warn');
|
|
513
|
+
const { discoverSessions, batchIngest } = await import('../../ingest/batch-ingest.js');
|
|
514
|
+
const { Embedder } = await import('../../models/embedder.js');
|
|
515
|
+
const { getModel } = await import('../../models/model-registry.js');
|
|
516
|
+
const sharedEmbedder = new Embedder();
|
|
517
|
+
await sharedEmbedder.load(getModel('jina-small'), { device: detectedDevice.device });
|
|
518
|
+
let totalIngested = 0;
|
|
519
|
+
let totalSkipped = 0;
|
|
520
|
+
let totalChunks = 0;
|
|
521
|
+
let totalEdges = 0;
|
|
522
|
+
for (const projectPath of projectsToIngest) {
|
|
523
|
+
const projectName = path.basename(projectPath)
|
|
524
|
+
.replace(/^-/, '')
|
|
525
|
+
.replace(/-/g, '/')
|
|
526
|
+
.replace(/^Users\/[^/]+\//, '~/');
|
|
527
|
+
const shortName = projectName.split('/').pop() || projectName;
|
|
528
|
+
const sessions = await discoverSessions(projectPath);
|
|
529
|
+
if (sessions.length === 0) {
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
spinner.start(`${shortName}: 0/${sessions.length} sessions`);
|
|
533
|
+
const result = await batchIngest(sessions, {
|
|
534
|
+
embeddingDevice: detectedDevice.device,
|
|
535
|
+
embedder: sharedEmbedder,
|
|
536
|
+
progressCallback: (progress) => {
|
|
537
|
+
spinner.update(`${shortName}: ${progress.done}/${progress.total} sessions, ${progress.totalChunks} chunks`);
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
spinner.stop();
|
|
541
|
+
if (result.successCount > 0) {
|
|
542
|
+
console.log(` \u2713 ${shortName}: ${result.successCount} sessions, ${result.totalChunks} chunks, ${result.totalEdges} edges`);
|
|
543
|
+
}
|
|
544
|
+
else if (result.skippedCount > 0) {
|
|
545
|
+
console.log(` \u2713 ${shortName}: ${result.skippedCount} sessions (already ingested)`);
|
|
546
|
+
}
|
|
547
|
+
totalIngested += result.successCount;
|
|
548
|
+
totalSkipped += result.skippedCount;
|
|
549
|
+
totalChunks += result.totalChunks;
|
|
550
|
+
totalEdges += result.totalEdges;
|
|
551
|
+
}
|
|
552
|
+
await sharedEmbedder.dispose();
|
|
553
|
+
setLogLevel('info');
|
|
554
|
+
if (totalIngested === 0 && totalSkipped === 0) {
|
|
555
|
+
console.log(' No sessions found to import.');
|
|
556
|
+
}
|
|
557
|
+
else if (totalIngested === 0) {
|
|
558
|
+
console.log('');
|
|
559
|
+
console.log(`\u2713 All ${totalSkipped} sessions already ingested`);
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
console.log('');
|
|
563
|
+
const skippedSuffix = totalSkipped > 0 ? `, ${totalSkipped} skipped` : '';
|
|
564
|
+
console.log(`\u2713 Total: ${totalIngested} sessions, ${totalChunks} chunks, ${totalEdges} edges${skippedSuffix}`);
|
|
565
|
+
}
|
|
566
|
+
// Run post-ingestion maintenance tasks
|
|
567
|
+
const existingChunks = getChunkCount();
|
|
568
|
+
if (existingChunks > 0) {
|
|
569
|
+
console.log('');
|
|
570
|
+
console.log('Running post-ingestion processing...');
|
|
571
|
+
const { setLogLevel: setPostLogLevel } = await import('../../utils/logger.js');
|
|
572
|
+
setPostLogLevel('warn');
|
|
573
|
+
spinner.start('Pruning graph...');
|
|
574
|
+
try {
|
|
575
|
+
const pruneResult = await runTask('prune-graph');
|
|
576
|
+
spinner.stop(pruneResult.success
|
|
577
|
+
? ' \u2713 Graph pruned'
|
|
578
|
+
: ` \u26a0 Pruning: ${pruneResult.message}`);
|
|
579
|
+
}
|
|
580
|
+
catch (err) {
|
|
581
|
+
spinner.stop(` \u2717 Pruning error: ${err.message}`);
|
|
582
|
+
}
|
|
583
|
+
spinner.start('Building clusters...');
|
|
584
|
+
try {
|
|
585
|
+
const clusterResult = await runTask('update-clusters');
|
|
586
|
+
spinner.stop(clusterResult.success
|
|
587
|
+
? ' \u2713 Clusters built'
|
|
588
|
+
: ` \u26a0 Clustering: ${clusterResult.message}`);
|
|
589
|
+
}
|
|
590
|
+
catch (err) {
|
|
591
|
+
spinner.stop(` \u2717 Clustering error: ${err.message}`);
|
|
592
|
+
}
|
|
593
|
+
await offerApiKeySetup(spinner);
|
|
594
|
+
setPostLogLevel('info');
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
async function offerApiKeySetup(spinner) {
|
|
598
|
+
console.log('');
|
|
599
|
+
console.log('Cluster labeling uses Claude Haiku to generate human-readable');
|
|
600
|
+
console.log('descriptions for topic clusters.');
|
|
601
|
+
if (!(await promptYesNo('Add Anthropic API key for cluster labeling?')))
|
|
602
|
+
return;
|
|
603
|
+
const apiKey = await promptPassword('Enter Anthropic API key: ');
|
|
604
|
+
if (apiKey && apiKey.startsWith('sk-ant-')) {
|
|
605
|
+
const store = createSecretStore();
|
|
606
|
+
await store.set('anthropic-api-key', apiKey);
|
|
607
|
+
console.log('\u2713 API key stored in system keychain');
|
|
608
|
+
process.env.ANTHROPIC_API_KEY = apiKey;
|
|
609
|
+
spinner.start('Labeling clusters (0/?)...');
|
|
610
|
+
try {
|
|
611
|
+
const { clusterRefresher } = await import('../../clusters/cluster-refresh.js');
|
|
612
|
+
const results = await clusterRefresher.refreshAllClusters({
|
|
613
|
+
onProgress: (current, total) => {
|
|
614
|
+
spinner.update(`Labeling clusters (${current}/${total})...`);
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
spinner.stop(` \u2713 ${results.length} clusters labeled`);
|
|
618
|
+
}
|
|
619
|
+
catch (err) {
|
|
620
|
+
spinner.stop(` \u2717 Labeling error: ${err.message}`);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
else if (apiKey) {
|
|
624
|
+
console.log('\u26a0 Invalid API key format (should start with sk-ant-)');
|
|
625
|
+
console.log(' You can add it later with: causantic config set-key anthropic-api-key');
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
console.log(' Skipping cluster labeling.');
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
export const initCommand = {
|
|
632
|
+
name: 'init',
|
|
633
|
+
description: 'Initialize Causantic (setup wizard)',
|
|
634
|
+
usage: 'causantic init [--skip-mcp] [--skip-encryption] [--skip-ingest]',
|
|
635
|
+
handler: async (args) => {
|
|
636
|
+
const skipMcp = args.includes('--skip-mcp');
|
|
637
|
+
const skipEncryption = args.includes('--skip-encryption');
|
|
638
|
+
const skipIngest = args.includes('--skip-ingest');
|
|
639
|
+
console.log('Causantic - Setup');
|
|
640
|
+
console.log('=================');
|
|
641
|
+
console.log('');
|
|
642
|
+
checkNodeVersion();
|
|
643
|
+
const causanticDir = path.join(os.homedir(), '.causantic');
|
|
644
|
+
createDirectoryStructure(causanticDir);
|
|
645
|
+
let encryptionEnabled = false;
|
|
646
|
+
if (!skipEncryption && process.stdin.isTTY) {
|
|
647
|
+
encryptionEnabled = await setupEncryption(causanticDir);
|
|
648
|
+
}
|
|
649
|
+
initializeDatabase(encryptionEnabled);
|
|
650
|
+
const claudeConfigPath = path.join(os.homedir(), '.claude', 'settings.json');
|
|
651
|
+
console.log('');
|
|
652
|
+
console.log(`Claude Code config: ${claudeConfigPath}`);
|
|
653
|
+
if (!skipMcp) {
|
|
654
|
+
await configureMcp(claudeConfigPath);
|
|
655
|
+
if (process.stdin.isTTY) {
|
|
656
|
+
await patchProjectMcpFiles();
|
|
657
|
+
}
|
|
658
|
+
await installSkillsAndClaudeMd();
|
|
659
|
+
await configureHooks(claudeConfigPath);
|
|
660
|
+
}
|
|
661
|
+
await runHealthCheck();
|
|
662
|
+
if (!skipIngest && process.stdin.isTTY) {
|
|
663
|
+
await offerBatchIngest();
|
|
664
|
+
}
|
|
665
|
+
console.log('');
|
|
666
|
+
console.log('Setup complete!');
|
|
667
|
+
console.log('');
|
|
668
|
+
console.log('Next steps:');
|
|
669
|
+
if (!skipIngest && process.stdin.isTTY) {
|
|
670
|
+
console.log(' 1. Restart Claude Code');
|
|
671
|
+
console.log(' 2. Ask Claude: "What did we work on recently?"');
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
console.log(' 1. npx causantic batch-ingest ~/.claude/projects');
|
|
675
|
+
console.log(' 2. Restart Claude Code');
|
|
676
|
+
console.log(' 3. Ask Claude: "What did we work on recently?"');
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
};
|
|
680
|
+
//# sourceMappingURL=init.js.map
|