@soleri/core 9.0.4 → 9.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/dist/brain/intelligence.d.ts +27 -0
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +160 -14
- package/dist/brain/intelligence.js.map +1 -1
- package/dist/brain/learning-radar.d.ts +4 -0
- package/dist/brain/learning-radar.d.ts.map +1 -1
- package/dist/brain/learning-radar.js +20 -1
- package/dist/brain/learning-radar.js.map +1 -1
- package/dist/brain/strength-scorer.d.ts +31 -0
- package/dist/brain/strength-scorer.d.ts.map +1 -0
- package/dist/brain/strength-scorer.js +264 -0
- package/dist/brain/strength-scorer.js.map +1 -0
- package/dist/chat/agent-loop.d.ts.map +1 -1
- package/dist/chat/agent-loop.js +2 -0
- package/dist/chat/agent-loop.js.map +1 -1
- package/dist/chat/notifications.d.ts.map +1 -1
- package/dist/chat/notifications.js +2 -0
- package/dist/chat/notifications.js.map +1 -1
- package/dist/claudemd/compose.js +1 -1
- package/dist/claudemd/compose.js.map +1 -1
- package/dist/control/intent-router.d.ts.map +1 -1
- package/dist/control/intent-router.js +12 -4
- package/dist/control/intent-router.js.map +1 -1
- package/dist/curator/contradiction-detector.d.ts +27 -0
- package/dist/curator/contradiction-detector.d.ts.map +1 -0
- package/dist/curator/contradiction-detector.js +62 -0
- package/dist/curator/contradiction-detector.js.map +1 -0
- package/dist/curator/curator.d.ts +3 -4
- package/dist/curator/curator.d.ts.map +1 -1
- package/dist/curator/curator.js +90 -525
- package/dist/curator/curator.js.map +1 -1
- package/dist/curator/duplicate-detector.d.ts +14 -0
- package/dist/curator/duplicate-detector.d.ts.map +1 -0
- package/dist/curator/duplicate-detector.js +77 -0
- package/dist/curator/duplicate-detector.js.map +1 -0
- package/dist/curator/health-audit.d.ts +15 -0
- package/dist/curator/health-audit.d.ts.map +1 -0
- package/dist/curator/health-audit.js +97 -0
- package/dist/curator/health-audit.js.map +1 -0
- package/dist/curator/metadata-enricher.d.ts +17 -0
- package/dist/curator/metadata-enricher.d.ts.map +1 -0
- package/dist/curator/metadata-enricher.js +60 -0
- package/dist/curator/metadata-enricher.js.map +1 -0
- package/dist/curator/schema.d.ts +7 -0
- package/dist/curator/schema.d.ts.map +1 -0
- package/dist/curator/schema.js +62 -0
- package/dist/curator/schema.js.map +1 -0
- package/dist/curator/tag-manager.d.ts +36 -0
- package/dist/curator/tag-manager.d.ts.map +1 -0
- package/dist/curator/tag-manager.js +78 -0
- package/dist/curator/tag-manager.js.map +1 -0
- package/dist/engine/bin/soleri-engine.js +24 -3
- package/dist/engine/bin/soleri-engine.js.map +1 -1
- package/dist/engine/core-ops.d.ts.map +1 -1
- package/dist/engine/core-ops.js +23 -8
- package/dist/engine/core-ops.js.map +1 -1
- package/dist/engine/module-manifest.d.ts.map +1 -1
- package/dist/engine/module-manifest.js +22 -2
- package/dist/engine/module-manifest.js.map +1 -1
- package/dist/engine/register-engine.d.ts.map +1 -1
- package/dist/engine/register-engine.js +26 -2
- package/dist/engine/register-engine.js.map +1 -1
- package/dist/errors/retry.d.ts.map +1 -1
- package/dist/errors/retry.js +2 -0
- package/dist/errors/retry.js.map +1 -1
- package/dist/facades/types.d.ts +1 -1
- package/dist/flows/chain-types.d.ts +18 -18
- package/dist/flows/gate-evaluator.d.ts.map +1 -1
- package/dist/flows/gate-evaluator.js +22 -0
- package/dist/flows/gate-evaluator.js.map +1 -1
- package/dist/flows/types.d.ts +157 -28
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/flows/types.js +4 -0
- package/dist/flows/types.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/intake/intake-pipeline.d.ts.map +1 -1
- package/dist/intake/intake-pipeline.js +1 -0
- package/dist/intake/intake-pipeline.js.map +1 -1
- package/dist/intake/text-ingester.d.ts.map +1 -1
- package/dist/intake/text-ingester.js +2 -0
- package/dist/intake/text-ingester.js.map +1 -1
- package/dist/llm/key-pool.d.ts +1 -1
- package/dist/llm/key-pool.d.ts.map +1 -1
- package/dist/llm/key-pool.js +3 -4
- package/dist/llm/key-pool.js.map +1 -1
- package/dist/llm/utils.d.ts.map +1 -1
- package/dist/llm/utils.js +2 -0
- package/dist/llm/utils.js.map +1 -1
- package/dist/migrations/migration-runner.test-helpers.d.ts +13 -0
- package/dist/migrations/migration-runner.test-helpers.d.ts.map +1 -0
- package/dist/migrations/migration-runner.test-helpers.js +47 -0
- package/dist/migrations/migration-runner.test-helpers.js.map +1 -0
- package/dist/operator/operator-profile.d.ts +44 -0
- package/dist/operator/operator-profile.d.ts.map +1 -0
- package/dist/operator/operator-profile.js +377 -0
- package/dist/operator/operator-profile.js.map +1 -0
- package/dist/operator/operator-signals.d.ts +45 -0
- package/dist/operator/operator-signals.d.ts.map +1 -0
- package/dist/operator/operator-signals.js +228 -0
- package/dist/operator/operator-signals.js.map +1 -0
- package/dist/operator/operator-types.d.ts +360 -0
- package/dist/operator/operator-types.d.ts.map +1 -0
- package/dist/operator/operator-types.js +24 -0
- package/dist/operator/operator-types.js.map +1 -0
- package/dist/packs/types.d.ts +27 -27
- package/dist/paths.d.ts +40 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +98 -0
- package/dist/paths.js.map +1 -0
- package/dist/persistence/index.d.ts +1 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +1 -1
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/sqlite-provider.d.ts +2 -0
- package/dist/persistence/sqlite-provider.d.ts.map +1 -1
- package/dist/persistence/sqlite-provider.js +8 -5
- package/dist/persistence/sqlite-provider.js.map +1 -1
- package/dist/planning/evidence-collector.d.ts +13 -1
- package/dist/planning/evidence-collector.d.ts.map +1 -1
- package/dist/planning/evidence-collector.js +33 -0
- package/dist/planning/evidence-collector.js.map +1 -1
- package/dist/planning/gap-analysis.d.ts +5 -4
- package/dist/planning/gap-analysis.d.ts.map +1 -1
- package/dist/planning/gap-analysis.js +7 -341
- package/dist/planning/gap-analysis.js.map +1 -1
- package/dist/planning/gap-passes.d.ts +19 -0
- package/dist/planning/gap-passes.d.ts.map +1 -0
- package/dist/planning/gap-passes.js +157 -0
- package/dist/planning/gap-passes.js.map +1 -0
- package/dist/planning/gap-patterns.d.ts +29 -0
- package/dist/planning/gap-patterns.d.ts.map +1 -0
- package/dist/planning/gap-patterns.js +129 -0
- package/dist/planning/gap-patterns.js.map +1 -0
- package/dist/planning/gap-types.d.ts +1 -1
- package/dist/planning/gap-types.d.ts.map +1 -1
- package/dist/planning/gap-types.js +1 -0
- package/dist/planning/gap-types.js.map +1 -1
- package/dist/planning/github-projection.d.ts +122 -0
- package/dist/planning/github-projection.d.ts.map +1 -0
- package/dist/planning/github-projection.js +294 -0
- package/dist/planning/github-projection.js.map +1 -0
- package/dist/planning/impact-analyzer.d.ts +26 -0
- package/dist/planning/impact-analyzer.d.ts.map +1 -0
- package/dist/planning/impact-analyzer.js +199 -0
- package/dist/planning/impact-analyzer.js.map +1 -0
- package/dist/planning/plan-lifecycle.d.ts +136 -0
- package/dist/planning/plan-lifecycle.d.ts.map +1 -0
- package/dist/planning/plan-lifecycle.js +296 -0
- package/dist/planning/plan-lifecycle.js.map +1 -0
- package/dist/planning/planner-types.d.ts +202 -0
- package/dist/planning/planner-types.d.ts.map +1 -0
- package/dist/planning/planner-types.js +6 -0
- package/dist/planning/planner-types.js.map +1 -0
- package/dist/planning/planner.d.ts +31 -383
- package/dist/planning/planner.d.ts.map +1 -1
- package/dist/planning/planner.js +154 -878
- package/dist/planning/planner.js.map +1 -1
- package/dist/planning/rationalization-detector.d.ts +32 -0
- package/dist/planning/rationalization-detector.d.ts.map +1 -0
- package/dist/planning/rationalization-detector.js +89 -0
- package/dist/planning/rationalization-detector.js.map +1 -0
- package/dist/planning/reconciliation-engine.d.ts +47 -0
- package/dist/planning/reconciliation-engine.d.ts.map +1 -0
- package/dist/planning/reconciliation-engine.js +128 -0
- package/dist/planning/reconciliation-engine.js.map +1 -0
- package/dist/planning/task-verifier.d.ts +85 -0
- package/dist/planning/task-verifier.d.ts.map +1 -0
- package/dist/planning/task-verifier.js +227 -0
- package/dist/planning/task-verifier.js.map +1 -0
- package/dist/plugins/types.d.ts +4 -4
- package/dist/runtime/admin-ops.d.ts +2 -2
- package/dist/runtime/admin-ops.d.ts.map +1 -1
- package/dist/runtime/admin-ops.js +44 -17
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/admin-setup-ops.d.ts.map +1 -1
- package/dist/runtime/admin-setup-ops.js +21 -46
- package/dist/runtime/admin-setup-ops.js.map +1 -1
- package/dist/runtime/archive-ops.d.ts +10 -0
- package/dist/runtime/archive-ops.d.ts.map +1 -0
- package/dist/runtime/archive-ops.js +310 -0
- package/dist/runtime/archive-ops.js.map +1 -0
- package/dist/runtime/capture-ops.d.ts.map +1 -1
- package/dist/runtime/capture-ops.js +42 -7
- package/dist/runtime/capture-ops.js.map +1 -1
- package/dist/runtime/claude-md-helpers.js +1 -1
- package/dist/runtime/claude-md-helpers.js.map +1 -1
- package/dist/runtime/context-health.d.ts +31 -0
- package/dist/runtime/context-health.d.ts.map +1 -0
- package/dist/runtime/context-health.js +57 -0
- package/dist/runtime/context-health.js.map +1 -0
- package/dist/runtime/facades/archive-facade.d.ts +10 -0
- package/dist/runtime/facades/archive-facade.d.ts.map +1 -0
- package/dist/runtime/facades/archive-facade.js +11 -0
- package/dist/runtime/facades/archive-facade.js.map +1 -0
- package/dist/runtime/facades/brain-facade.d.ts.map +1 -1
- package/dist/runtime/facades/brain-facade.js +2 -0
- package/dist/runtime/facades/brain-facade.js.map +1 -1
- package/dist/runtime/facades/chat-facade.d.ts +7 -0
- package/dist/runtime/facades/chat-facade.d.ts.map +1 -1
- package/dist/runtime/facades/chat-facade.js +15 -800
- package/dist/runtime/facades/chat-facade.js.map +1 -1
- package/dist/runtime/facades/chat-service-ops.d.ts +9 -0
- package/dist/runtime/facades/chat-service-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-service-ops.js +330 -0
- package/dist/runtime/facades/chat-service-ops.js.map +1 -0
- package/dist/runtime/facades/chat-session-ops.d.ts +8 -0
- package/dist/runtime/facades/chat-session-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-session-ops.js +136 -0
- package/dist/runtime/facades/chat-session-ops.js.map +1 -0
- package/dist/runtime/facades/chat-state.d.ts +31 -0
- package/dist/runtime/facades/chat-state.d.ts.map +1 -0
- package/dist/runtime/facades/chat-state.js +32 -0
- package/dist/runtime/facades/chat-state.js.map +1 -0
- package/dist/runtime/facades/chat-transport-ops.d.ts +9 -0
- package/dist/runtime/facades/chat-transport-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-transport-ops.js +337 -0
- package/dist/runtime/facades/chat-transport-ops.js.map +1 -0
- package/dist/runtime/facades/control-facade.d.ts.map +1 -1
- package/dist/runtime/facades/control-facade.js +4 -1
- package/dist/runtime/facades/control-facade.js.map +1 -1
- package/dist/runtime/facades/index.d.ts.map +1 -1
- package/dist/runtime/facades/index.js +6 -0
- package/dist/runtime/facades/index.js.map +1 -1
- package/dist/runtime/facades/memory-facade.d.ts.map +1 -1
- package/dist/runtime/facades/memory-facade.js +75 -6
- package/dist/runtime/facades/memory-facade.js.map +1 -1
- package/dist/runtime/facades/operator-facade.d.ts +8 -0
- package/dist/runtime/facades/operator-facade.d.ts.map +1 -0
- package/dist/runtime/facades/operator-facade.js +220 -0
- package/dist/runtime/facades/operator-facade.js.map +1 -0
- package/dist/runtime/facades/orchestrate-facade.js +3 -3
- package/dist/runtime/facades/orchestrate-facade.js.map +1 -1
- package/dist/runtime/facades/plan-facade.d.ts.map +1 -1
- package/dist/runtime/facades/plan-facade.js +39 -6
- package/dist/runtime/facades/plan-facade.js.map +1 -1
- package/dist/runtime/facades/review-facade.d.ts +7 -0
- package/dist/runtime/facades/review-facade.d.ts.map +1 -0
- package/dist/runtime/facades/review-facade.js +8 -0
- package/dist/runtime/facades/review-facade.js.map +1 -0
- package/dist/runtime/facades/sync-facade.d.ts +7 -0
- package/dist/runtime/facades/sync-facade.d.ts.map +1 -0
- package/dist/runtime/facades/sync-facade.js +8 -0
- package/dist/runtime/facades/sync-facade.js.map +1 -0
- package/dist/runtime/facades/vault-facade.d.ts +4 -1
- package/dist/runtime/facades/vault-facade.d.ts.map +1 -1
- package/dist/runtime/facades/vault-facade.js +13 -66
- package/dist/runtime/facades/vault-facade.js.map +1 -1
- package/dist/runtime/github-integration.d.ts +49 -0
- package/dist/runtime/github-integration.d.ts.map +1 -0
- package/dist/runtime/github-integration.js +113 -0
- package/dist/runtime/github-integration.js.map +1 -0
- package/dist/runtime/grading-ops.js +1 -1
- package/dist/runtime/grading-ops.js.map +1 -1
- package/dist/runtime/memory-extra-ops.d.ts.map +1 -1
- package/dist/runtime/memory-extra-ops.js +6 -2
- package/dist/runtime/memory-extra-ops.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +367 -40
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/dist/runtime/planning-extra-ops.d.ts.map +1 -1
- package/dist/runtime/planning-extra-ops.js +69 -4
- package/dist/runtime/planning-extra-ops.js.map +1 -1
- package/dist/runtime/review-ops.d.ts +10 -0
- package/dist/runtime/review-ops.d.ts.map +1 -0
- package/dist/runtime/review-ops.js +97 -0
- package/dist/runtime/review-ops.js.map +1 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +27 -12
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/session-briefing.d.ts +3 -0
- package/dist/runtime/session-briefing.d.ts.map +1 -1
- package/dist/runtime/session-briefing.js +68 -1
- package/dist/runtime/session-briefing.js.map +1 -1
- package/dist/runtime/sync-ops.d.ts +12 -0
- package/dist/runtime/sync-ops.d.ts.map +1 -0
- package/dist/runtime/sync-ops.js +288 -0
- package/dist/runtime/sync-ops.js.map +1 -0
- package/dist/runtime/types.d.ts +10 -4
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.d.ts +5 -4
- package/dist/runtime/vault-extra-ops.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.js +5 -300
- package/dist/runtime/vault-extra-ops.js.map +1 -1
- package/dist/runtime/vault-sharing-ops.d.ts +4 -4
- package/dist/runtime/vault-sharing-ops.d.ts.map +1 -1
- package/dist/runtime/vault-sharing-ops.js +5 -300
- package/dist/runtime/vault-sharing-ops.js.map +1 -1
- package/dist/skills/sync-skills.d.ts +27 -0
- package/dist/skills/sync-skills.d.ts.map +1 -0
- package/dist/skills/sync-skills.js +81 -0
- package/dist/skills/sync-skills.js.map +1 -0
- package/dist/update-check.d.ts +14 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +96 -0
- package/dist/update-check.js.map +1 -0
- package/dist/vault/linking.d.ts +10 -12
- package/dist/vault/linking.d.ts.map +1 -1
- package/dist/vault/linking.js +104 -161
- package/dist/vault/linking.js.map +1 -1
- package/dist/vault/vault-entries.d.ts +69 -0
- package/dist/vault/vault-entries.d.ts.map +1 -0
- package/dist/vault/vault-entries.js +257 -0
- package/dist/vault/vault-entries.js.map +1 -0
- package/dist/vault/vault-interfaces.d.ts +153 -0
- package/dist/vault/vault-interfaces.d.ts.map +1 -0
- package/dist/vault/vault-interfaces.js +2 -0
- package/dist/vault/vault-interfaces.js.map +1 -0
- package/dist/vault/vault-maintenance.d.ts +40 -0
- package/dist/vault/vault-maintenance.d.ts.map +1 -0
- package/dist/vault/vault-maintenance.js +142 -0
- package/dist/vault/vault-maintenance.js.map +1 -0
- package/dist/vault/vault-markdown-sync.d.ts +22 -0
- package/dist/vault/vault-markdown-sync.d.ts.map +1 -0
- package/dist/vault/vault-markdown-sync.js +143 -0
- package/dist/vault/vault-markdown-sync.js.map +1 -0
- package/dist/vault/vault-memories.d.ts +61 -0
- package/dist/vault/vault-memories.d.ts.map +1 -0
- package/dist/vault/vault-memories.js +240 -0
- package/dist/vault/vault-memories.js.map +1 -0
- package/dist/vault/vault-schema.d.ts +9 -0
- package/dist/vault/vault-schema.d.ts.map +1 -0
- package/dist/vault/vault-schema.js +179 -0
- package/dist/vault/vault-schema.js.map +1 -0
- package/dist/vault/vault.d.ts +29 -81
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +78 -931
- package/dist/vault/vault.js.map +1 -1
- package/package.json +1 -1
- package/src/agency/agency-manager.test.ts +600 -0
- package/src/agency/default-rules.test.ts +228 -0
- package/src/{__tests__ → brain}/brain-intelligence.test.ts +37 -14
- package/src/{__tests__ → brain}/brain.test.ts +1 -1
- package/src/brain/intelligence.ts +196 -15
- package/src/brain/learning-radar.ts +22 -1
- package/src/{__tests__ → brain}/second-brain-features.test.ts +4 -4
- package/src/{__tests__ → brain}/session-lifecycle.test.ts +2 -2
- package/src/brain/strength-scorer.ts +404 -0
- package/src/capabilities/chain-mapping.test.ts +66 -0
- package/src/capabilities/registry.test.ts +369 -0
- package/src/chat/agent-loop.test.ts +394 -0
- package/src/chat/agent-loop.ts +2 -0
- package/src/{__tests__ → chat}/chat-differentiators.test.ts +3 -3
- package/src/{__tests__ → chat}/chat-enhanced.test.ts +4 -4
- package/src/{__tests__ → chat}/chat-transport.test.ts +6 -6
- package/src/chat/mcp-bridge.test.ts +173 -0
- package/src/chat/notifications.ts +2 -0
- package/src/chat/output-compressor.test.ts +164 -0
- package/src/claudemd/compose.test.ts +178 -0
- package/src/claudemd/compose.ts +1 -1
- package/src/claudemd/inject.test.ts +211 -0
- package/src/context/context-engine.test.ts +461 -0
- package/src/control/identity-manager.test.ts +305 -0
- package/src/control/intent-router.test.ts +360 -0
- package/src/control/intent-router.ts +13 -4
- package/src/curator/classifier.test.ts +104 -0
- package/src/curator/contradiction-detector.test.ts +180 -0
- package/src/curator/contradiction-detector.ts +87 -0
- package/src/{__tests__ → curator}/curator-pipeline-e2e.test.ts +10 -10
- package/src/{__tests__ → curator}/curator.test.ts +77 -1
- package/src/curator/curator.ts +115 -777
- package/src/curator/duplicate-detector.test.ts +183 -0
- package/src/curator/duplicate-detector.ts +103 -0
- package/src/curator/health-audit.ts +126 -0
- package/src/curator/metadata-enricher.ts +84 -0
- package/src/curator/quality-gate.test.ts +135 -0
- package/src/curator/schema.ts +65 -0
- package/src/curator/tag-manager.test.ts +165 -0
- package/src/curator/tag-manager.ts +109 -0
- package/src/domain-packs/inject-rules.test.ts +117 -0
- package/src/domain-packs/knowledge-installer.test.ts +171 -0
- package/src/domain-packs/loader.test.ts +86 -0
- package/src/domain-packs/pack-runtime.test.ts +140 -0
- package/src/domain-packs/skills-installer.test.ts +135 -0
- package/src/domain-packs/token-resolver.test.ts +150 -0
- package/src/domain-packs/types.test.ts +130 -0
- package/src/enforcement/adapters/claude-code.test.ts +216 -0
- package/src/enforcement/registry.test.ts +264 -0
- package/src/engine/bin/soleri-engine.ts +28 -4
- package/src/engine/core-ops.test.ts +254 -0
- package/src/engine/core-ops.ts +25 -8
- package/src/engine/module-manifest.test.ts +124 -0
- package/src/engine/module-manifest.ts +22 -2
- package/src/engine/register-engine.test.ts +230 -0
- package/src/engine/register-engine.ts +26 -2
- package/src/errors/classify.test.ts +199 -0
- package/src/errors/retry.test.ts +156 -0
- package/src/errors/retry.ts +2 -0
- package/src/errors/types.test.ts +108 -0
- package/src/events/event-bus.test.ts +149 -0
- package/src/extensions/middleware.test.ts +234 -0
- package/src/facades/facade-factory.test.ts +424 -0
- package/src/flows/chain-runner.test.ts +273 -0
- package/src/flows/context-router.test.ts +52 -0
- package/src/flows/dispatch-registry.test.ts +128 -0
- package/src/flows/epilogue.test.ts +107 -0
- package/src/flows/executor.test.ts +263 -0
- package/src/flows/gate-evaluator.test.ts +194 -0
- package/src/flows/gate-evaluator.ts +25 -0
- package/src/flows/types.ts +4 -0
- package/src/governance/governance.test.ts +726 -0
- package/src/health/health-registry.test.ts +186 -0
- package/src/health/vault-integrity.test.ts +110 -0
- package/src/index.ts +92 -0
- package/src/intake/content-classifier.test.ts +209 -0
- package/src/intake/dedup-gate.test.ts +131 -0
- package/src/intake/intake-pipeline.test.ts +506 -0
- package/src/intake/intake-pipeline.ts +1 -0
- package/src/intake/text-ingester.test.ts +194 -0
- package/src/intake/text-ingester.ts +2 -0
- package/src/llm/key-pool.test.ts +236 -0
- package/src/llm/key-pool.ts +3 -4
- package/src/llm/llm-client.test.ts +345 -0
- package/src/llm/oauth-discovery.test.ts +180 -0
- package/src/llm/utils.test.ts +327 -0
- package/src/llm/utils.ts +2 -0
- package/src/{__tests__ → logging}/logger.test.ts +41 -62
- package/src/loop/loop-manager.test.ts +519 -0
- package/src/migrations/migration-runner.edge-cases.test.ts +319 -0
- package/src/migrations/migration-runner.test-helpers.ts +64 -0
- package/src/migrations/migration-runner.test.ts +385 -0
- package/src/operator/auto-signal-pipeline.test.ts +207 -0
- package/src/operator/operator-profile-extended.test.ts +320 -0
- package/src/operator/operator-profile.test.ts +314 -0
- package/src/operator/operator-profile.ts +469 -0
- package/src/operator/operator-signals-extended.test.ts +245 -0
- package/src/operator/operator-signals.test.ts +281 -0
- package/src/operator/operator-signals.ts +261 -0
- package/src/operator/operator-types.ts +444 -0
- package/src/operator/prompts/hook-precompact-operator-dispatch.md +94 -0
- package/src/operator/prompts/subagent-soft-signal-extractor.md +125 -0
- package/src/operator/prompts/subagent-synthesis-cognition.md +181 -0
- package/src/operator/prompts/subagent-synthesis-communication.md +140 -0
- package/src/operator/prompts/subagent-synthesis-technical.md +160 -0
- package/src/operator/prompts/subagent-synthesis-trust.md +143 -0
- package/src/{__tests__ → packs}/pack-lockfile.test.ts +3 -3
- package/src/{__tests__ → packs}/pack-system.test.ts +2 -2
- package/src/paths.ts +115 -0
- package/src/persistence/index.ts +1 -1
- package/src/persistence/sqlite-provider.test.ts +540 -0
- package/src/persistence/sqlite-provider.ts +8 -5
- package/src/persona/defaults.test.ts +59 -0
- package/src/persona/loader.test.ts +67 -0
- package/src/persona/prompt-generator.test.ts +127 -0
- package/src/planning/evidence-collector.test.ts +406 -0
- package/src/planning/evidence-collector.ts +50 -0
- package/src/planning/gap-analysis-alternatives.test.ts +169 -0
- package/src/planning/gap-analysis.ts +21 -636
- package/src/planning/gap-passes.test.ts +372 -0
- package/src/planning/gap-passes.ts +298 -0
- package/src/planning/gap-patterns.test.ts +320 -0
- package/src/planning/gap-patterns.ts +234 -0
- package/src/planning/gap-types.ts +4 -1
- package/src/planning/github-projection.test.ts +177 -0
- package/src/planning/github-projection.ts +425 -0
- package/src/planning/impact-analyzer.test.ts +180 -0
- package/src/planning/impact-analyzer.ts +264 -0
- package/src/planning/plan-lifecycle.test.ts +312 -0
- package/src/planning/plan-lifecycle.ts +346 -0
- package/src/planning/planner-types.ts +215 -0
- package/src/{__tests__ → planning}/planner.test.ts +169 -15
- package/src/planning/planner.ts +197 -1228
- package/src/planning/rationalization-detector.test.ts +171 -0
- package/src/planning/rationalization-detector.ts +138 -0
- package/src/planning/reconciliation-engine.test.ts +141 -0
- package/src/planning/reconciliation-engine.ts +162 -0
- package/src/planning/task-verifier.test.ts +235 -0
- package/src/planning/task-verifier.ts +303 -0
- package/src/planning/verification-protocol.test.ts +201 -0
- package/src/playbooks/generic/generic-playbooks.test.ts +438 -0
- package/src/playbooks/index.test.ts +77 -0
- package/src/playbooks/playbook-executor.test.ts +255 -0
- package/src/playbooks/playbook-registry.test.ts +232 -0
- package/src/playbooks/playbook-seeder.test.ts +153 -0
- package/src/plugins/plugin-loader.test.ts +212 -0
- package/src/plugins/plugin-registry.test.ts +272 -0
- package/src/project/project-registry.test.ts +428 -0
- package/src/prompts/parser.test.ts +100 -0
- package/src/prompts/template-manager.test.ts +109 -0
- package/src/{__tests__ → queue}/async-infrastructure.test.ts +3 -3
- package/src/queue/job-queue.test.ts +331 -0
- package/src/queue/pipeline-runner.test.ts +209 -0
- package/src/runtime/admin-extra-ops.test.ts +527 -0
- package/src/runtime/admin-ops.test.ts +257 -0
- package/src/runtime/admin-ops.ts +45 -17
- package/src/runtime/admin-setup-ops.test.ts +328 -0
- package/src/runtime/admin-setup-ops.ts +20 -43
- package/src/runtime/archive-ops.test.ts +269 -0
- package/src/runtime/archive-ops.ts +347 -0
- package/src/runtime/capture-ops.test.ts +433 -0
- package/src/runtime/capture-ops.ts +50 -8
- package/src/runtime/chain-ops.test.ts +149 -0
- package/src/runtime/claude-md-helpers.test.ts +191 -0
- package/src/runtime/claude-md-helpers.ts +1 -1
- package/src/runtime/context-health.test.ts +78 -0
- package/src/runtime/context-health.ts +85 -0
- package/src/runtime/curator-extra-ops.test.ts +202 -0
- package/src/runtime/deprecation.test.ts +98 -0
- package/src/runtime/domain-ops.test.ts +268 -0
- package/src/runtime/facades/admin-facade.test.ts +333 -0
- package/src/runtime/facades/agency-facade.test.ts +278 -0
- package/src/runtime/facades/archive-facade.test.ts +294 -0
- package/src/runtime/facades/archive-facade.ts +14 -0
- package/src/runtime/facades/brain-facade.test.ts +714 -0
- package/src/runtime/facades/brain-facade.ts +2 -0
- package/src/runtime/facades/chat-facade.test.ts +166 -0
- package/src/runtime/facades/chat-facade.ts +15 -906
- package/src/runtime/facades/chat-service-ops.test.ts +276 -0
- package/src/runtime/facades/chat-service-ops.ts +374 -0
- package/src/runtime/facades/chat-session-ops.test.ts +197 -0
- package/src/runtime/facades/chat-session-ops.ts +146 -0
- package/src/runtime/facades/chat-state.ts +60 -0
- package/src/runtime/facades/chat-transport-ops.test.ts +269 -0
- package/src/runtime/facades/chat-transport-ops.ts +380 -0
- package/src/runtime/facades/context-facade.test.ts +108 -0
- package/src/runtime/facades/control-facade.test.ts +436 -0
- package/src/runtime/facades/control-facade.ts +6 -1
- package/src/runtime/facades/curator-facade.test.ts +303 -0
- package/src/runtime/facades/index.ts +6 -0
- package/src/runtime/facades/loop-facade.test.ts +245 -0
- package/src/runtime/facades/memory-facade.test.ts +269 -0
- package/src/runtime/facades/memory-facade.ts +78 -6
- package/src/runtime/facades/operator-facade.test.ts +208 -0
- package/src/runtime/facades/operator-facade.ts +236 -0
- package/src/runtime/facades/orchestrate-facade.test.ts +185 -0
- package/src/runtime/facades/orchestrate-facade.ts +3 -3
- package/src/runtime/facades/plan-facade.test.ts +266 -0
- package/src/runtime/facades/plan-facade.ts +42 -6
- package/src/runtime/facades/review-facade.test.ts +82 -0
- package/src/runtime/facades/review-facade.ts +11 -0
- package/src/runtime/facades/sync-facade.test.ts +113 -0
- package/src/runtime/facades/sync-facade.ts +11 -0
- package/src/runtime/facades/vault-facade.test.ts +631 -0
- package/src/runtime/facades/vault-facade.ts +15 -70
- package/src/runtime/feature-flags.test.ts +140 -0
- package/src/runtime/github-integration.test.ts +89 -0
- package/src/runtime/github-integration.ts +159 -0
- package/src/runtime/grading-ops.test.ts +141 -0
- package/src/runtime/grading-ops.ts +1 -1
- package/src/runtime/intake-ops.test.ts +208 -0
- package/src/runtime/loop-ops.test.ts +238 -0
- package/src/runtime/memory-cross-project-ops.test.ts +177 -0
- package/src/runtime/memory-extra-ops.test.ts +453 -0
- package/src/runtime/memory-extra-ops.ts +6 -2
- package/src/runtime/orchestrate-ops.test.ts +302 -0
- package/src/runtime/orchestrate-ops.ts +435 -46
- package/src/runtime/pack-ops.test.ts +158 -0
- package/src/runtime/planning-extra-ops.test.ts +583 -0
- package/src/runtime/planning-extra-ops.ts +72 -4
- package/src/{__tests__ → runtime}/playbook-ops-execution.test.ts +3 -3
- package/src/runtime/playbook-ops.test.ts +262 -0
- package/src/runtime/plugin-ops.test.ts +201 -0
- package/src/runtime/project-ops.test.ts +235 -0
- package/src/runtime/review-ops.test.ts +142 -0
- package/src/runtime/review-ops.ts +99 -0
- package/src/runtime/runtime.test.ts +363 -0
- package/src/runtime/runtime.ts +39 -12
- package/src/runtime/session-briefing.test.ts +302 -0
- package/src/runtime/session-briefing.ts +80 -1
- package/src/runtime/sync-ops.test.ts +221 -0
- package/src/runtime/sync-ops.ts +325 -0
- package/src/runtime/telemetry-ops.test.ts +132 -0
- package/src/runtime/types.ts +10 -4
- package/src/runtime/vault-extra-ops.test.ts +246 -0
- package/src/runtime/vault-extra-ops.ts +5 -332
- package/src/runtime/vault-linking-ops.test.ts +237 -0
- package/src/runtime/vault-sharing-ops.test.ts +130 -0
- package/src/runtime/vault-sharing-ops.ts +5 -329
- package/src/skills/sync-skills.ts +108 -0
- package/src/streams/normalize.test.ts +95 -0
- package/src/streams/replayable-stream.test.ts +166 -0
- package/src/telemetry/telemetry.test.ts +143 -0
- package/src/transport/http-server.test.ts +394 -0
- package/src/transport/lsp-server.test.ts +458 -0
- package/src/transport/rate-limiter.test.ts +126 -0
- package/src/transport/session-manager.test.ts +133 -0
- package/src/transport/token-auth.test.ts +136 -0
- package/src/transport/ws-server.test.ts +294 -0
- package/src/update-check.ts +111 -0
- package/src/vault/__tests__/vault-characterization.test.ts +168 -0
- package/src/vault/content-hash.test.ts +78 -0
- package/src/vault/git-vault-sync.test.ts +234 -0
- package/src/vault/knowledge-review.test.ts +269 -0
- package/src/vault/linking.test.ts +358 -0
- package/src/vault/linking.ts +149 -183
- package/src/vault/obsidian-sync.test.ts +342 -0
- package/src/vault/playbook.test.ts +152 -0
- package/src/vault/scope-detector.test.ts +187 -0
- package/src/vault/vault-branching.test.ts +250 -0
- package/src/{__tests__ → vault}/vault-connect.test.ts +1 -1
- package/src/vault/vault-entries.ts +282 -0
- package/src/vault/vault-interfaces.ts +56 -0
- package/src/vault/vault-maintenance.ts +205 -0
- package/src/vault/vault-manager.test.ts +206 -0
- package/src/vault/vault-markdown-sync.test.ts +203 -0
- package/src/vault/vault-markdown-sync.ts +160 -0
- package/src/vault/vault-memories.ts +339 -0
- package/src/{__tests__ → vault}/vault-scaling.test.ts +1 -1
- package/src/vault/vault-schema.ts +181 -0
- package/src/{__tests__ → vault}/vault-sharing.test.ts +4 -4
- package/src/{__tests__ → vault}/vault.test.ts +2 -2
- package/src/vault/vault.ts +89 -1171
- package/dist/cognee/client.d.ts +0 -43
- package/dist/cognee/client.d.ts.map +0 -1
- package/dist/cognee/client.js +0 -375
- package/dist/cognee/client.js.map +0 -1
- package/dist/cognee/sync-manager.d.ts +0 -153
- package/dist/cognee/sync-manager.d.ts.map +0 -1
- package/dist/cognee/sync-manager.js +0 -390
- package/dist/cognee/sync-manager.js.map +0 -1
- package/dist/cognee/types.d.ts +0 -62
- package/dist/cognee/types.d.ts.map +0 -1
- package/dist/cognee/types.js +0 -3
- package/dist/cognee/types.js.map +0 -1
- package/dist/governance/index.d.ts +0 -3
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/index.js +0 -2
- package/dist/governance/index.js.map +0 -1
- package/dist/health/doctor-checks.d.ts +0 -15
- package/dist/health/doctor-checks.d.ts.map +0 -1
- package/dist/health/doctor-checks.js +0 -98
- package/dist/health/doctor-checks.js.map +0 -1
- package/dist/persistence/postgres-provider.d.ts +0 -81
- package/dist/persistence/postgres-provider.d.ts.map +0 -1
- package/dist/persistence/postgres-provider.js +0 -256
- package/dist/persistence/postgres-provider.js.map +0 -1
- package/dist/runtime/cognee-sync-ops.d.ts +0 -12
- package/dist/runtime/cognee-sync-ops.d.ts.map +0 -1
- package/dist/runtime/cognee-sync-ops.js +0 -93
- package/dist/runtime/cognee-sync-ops.js.map +0 -1
- package/dist/runtime/core-ops.d.ts +0 -23
- package/dist/runtime/core-ops.d.ts.map +0 -1
- package/dist/runtime/core-ops.js +0 -1296
- package/dist/runtime/core-ops.js.map +0 -1
- package/dist/runtime/facades/cognee-facade.d.ts +0 -8
- package/dist/runtime/facades/cognee-facade.d.ts.map +0 -1
- package/dist/runtime/facades/cognee-facade.js +0 -156
- package/dist/runtime/facades/cognee-facade.js.map +0 -1
- package/src/__tests__/admin-extra-ops.test.ts +0 -484
- package/src/__tests__/admin-ops.test.ts +0 -268
- package/src/__tests__/admin-setup-ops.test.ts +0 -355
- package/src/__tests__/agency-manager.test.ts +0 -374
- package/src/__tests__/agent-loop.test.ts +0 -256
- package/src/__tests__/capture-ops.test.ts +0 -784
- package/src/__tests__/claudemd.test.ts +0 -282
- package/src/__tests__/content-hash.test.ts +0 -60
- package/src/__tests__/context-engine.test.ts +0 -251
- package/src/__tests__/core-ops.test.ts +0 -550
- package/src/__tests__/curator-extra-ops.test.ts +0 -383
- package/src/__tests__/deprecation.test.ts +0 -78
- package/src/__tests__/domain-ops.test.ts +0 -226
- package/src/__tests__/domain-packs.test.ts +0 -421
- package/src/__tests__/enforcement.test.ts +0 -153
- package/src/__tests__/errors.test.ts +0 -388
- package/src/__tests__/extensions.test.ts +0 -233
- package/src/__tests__/facade-factory.test.ts +0 -271
- package/src/__tests__/feature-flags.test.ts +0 -137
- package/src/__tests__/flows.test.ts +0 -604
- package/src/__tests__/git-vault-sync.test.ts +0 -230
- package/src/__tests__/governance.test.ts +0 -522
- package/src/__tests__/grading-ops.test.ts +0 -361
- package/src/__tests__/health-registry.test.ts +0 -173
- package/src/__tests__/identity-manager.test.ts +0 -243
- package/src/__tests__/intake-pipeline.test.ts +0 -162
- package/src/__tests__/intent-router.test.ts +0 -222
- package/src/__tests__/knowledge-review.test.ts +0 -104
- package/src/__tests__/llm-client.test.ts +0 -69
- package/src/__tests__/llm.test.ts +0 -556
- package/src/__tests__/loader.test.ts +0 -176
- package/src/__tests__/loop-ops.test.ts +0 -469
- package/src/__tests__/lsp-transport.test.ts +0 -442
- package/src/__tests__/memory-cross-project-ops.test.ts +0 -248
- package/src/__tests__/memory-extra-ops.test.ts +0 -352
- package/src/__tests__/migration-runner.test.ts +0 -170
- package/src/__tests__/module-manifest-drift.test.ts +0 -59
- package/src/__tests__/normalize.test.ts +0 -85
- package/src/__tests__/obsidian-sync.test.ts +0 -354
- package/src/__tests__/orchestrate-ops.test.ts +0 -289
- package/src/__tests__/pack-ops.test.ts +0 -146
- package/src/__tests__/persistence.test.ts +0 -291
- package/src/__tests__/planning-extra-ops.test.ts +0 -706
- package/src/__tests__/playbook-executor.test.ts +0 -249
- package/src/__tests__/playbook-registry.test.ts +0 -326
- package/src/__tests__/playbook-seeder.test.ts +0 -163
- package/src/__tests__/playbook.test.ts +0 -389
- package/src/__tests__/plugin-ops.test.ts +0 -411
- package/src/__tests__/plugin-system.test.ts +0 -509
- package/src/__tests__/project-ops.test.ts +0 -381
- package/src/__tests__/replayable-stream.test.ts +0 -177
- package/src/__tests__/runtime.test.ts +0 -95
- package/src/__tests__/scope-detector.test.ts +0 -121
- package/src/__tests__/template-manager.test.ts +0 -222
- package/src/__tests__/token-resolver.test.ts +0 -79
- package/src/__tests__/transport.test.ts +0 -758
- package/src/__tests__/vault-branching.test.ts +0 -274
- package/src/__tests__/vault-extra-ops.test.ts +0 -482
- package/src/__tests__/vault-integrity.test.ts +0 -71
- package/src/__tests__/vault-manager.test.ts +0 -238
- package/src/__tests__/ws-transport.test.ts +0 -479
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curator Schema — DDL for curator tables.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { PersistenceProvider } from '../persistence/types.js';
|
|
6
|
+
|
|
7
|
+
export const CURATOR_SCHEMA = `
|
|
8
|
+
CREATE TABLE IF NOT EXISTS curator_entry_state (
|
|
9
|
+
entry_id TEXT PRIMARY KEY,
|
|
10
|
+
status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active', 'stale', 'archived')),
|
|
11
|
+
confidence REAL NOT NULL DEFAULT 1.0,
|
|
12
|
+
source TEXT NOT NULL DEFAULT 'unknown' CHECK(source IN ('manual', 'capture', 'seed', 'unknown')),
|
|
13
|
+
last_groomed_at INTEGER,
|
|
14
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS curator_tag_canonical (
|
|
18
|
+
tag TEXT PRIMARY KEY,
|
|
19
|
+
description TEXT,
|
|
20
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
CREATE TABLE IF NOT EXISTS curator_tag_alias (
|
|
24
|
+
alias TEXT PRIMARY KEY,
|
|
25
|
+
canonical TEXT NOT NULL,
|
|
26
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
27
|
+
FOREIGN KEY (canonical) REFERENCES curator_tag_canonical(tag)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE IF NOT EXISTS curator_changelog (
|
|
31
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
32
|
+
action TEXT NOT NULL,
|
|
33
|
+
entry_id TEXT NOT NULL,
|
|
34
|
+
before_value TEXT,
|
|
35
|
+
after_value TEXT,
|
|
36
|
+
reason TEXT NOT NULL,
|
|
37
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE IF NOT EXISTS curator_entry_history (
|
|
41
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
42
|
+
entry_id TEXT NOT NULL,
|
|
43
|
+
snapshot TEXT NOT NULL,
|
|
44
|
+
changed_by TEXT DEFAULT 'system',
|
|
45
|
+
change_reason TEXT,
|
|
46
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
CREATE TABLE IF NOT EXISTS curator_contradictions (
|
|
50
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
51
|
+
pattern_id TEXT NOT NULL,
|
|
52
|
+
antipattern_id TEXT NOT NULL,
|
|
53
|
+
similarity REAL NOT NULL,
|
|
54
|
+
status TEXT NOT NULL DEFAULT 'open' CHECK(status IN ('open', 'resolved', 'dismissed')),
|
|
55
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
56
|
+
resolved_at INTEGER,
|
|
57
|
+
UNIQUE(pattern_id, antipattern_id)
|
|
58
|
+
);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_curator_state_status ON curator_entry_state(status);
|
|
60
|
+
CREATE INDEX IF NOT EXISTS idx_curator_changelog_entry ON curator_changelog(entry_id);
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
export function initializeTables(provider: PersistenceProvider): void {
|
|
64
|
+
provider.execSql(CURATOR_SCHEMA);
|
|
65
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
normalizeTag,
|
|
4
|
+
normalizeTags,
|
|
5
|
+
normalizeAndDedup,
|
|
6
|
+
addTagAlias,
|
|
7
|
+
getCanonicalTags,
|
|
8
|
+
seedDefaultAliases,
|
|
9
|
+
DEFAULT_TAG_ALIASES,
|
|
10
|
+
type TagStore,
|
|
11
|
+
} from './tag-manager.js';
|
|
12
|
+
|
|
13
|
+
function mockTagStore(): TagStore {
|
|
14
|
+
const aliases = new Map<string, string>();
|
|
15
|
+
const canonicals = new Map<string, string | null>();
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
getAlias: vi.fn((lower: string) => aliases.get(lower) ?? null),
|
|
19
|
+
insertCanonical: vi.fn((tag: string) => { canonicals.set(tag, null); }),
|
|
20
|
+
upsertAlias: vi.fn((alias: string, canonical: string) => { aliases.set(alias, canonical); }),
|
|
21
|
+
getCanonicalRows: vi.fn(() =>
|
|
22
|
+
Array.from(canonicals.entries()).map(([tag, description]) => ({
|
|
23
|
+
tag,
|
|
24
|
+
description,
|
|
25
|
+
alias_count: Array.from(aliases.values()).filter((c) => c === tag).length,
|
|
26
|
+
})),
|
|
27
|
+
),
|
|
28
|
+
countTagUsage: vi.fn(() => 0),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('tag-manager', () => {
|
|
33
|
+
let store: TagStore;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
store = mockTagStore();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('DEFAULT_TAG_ALIASES', () => {
|
|
40
|
+
it('exports expected alias count', () => {
|
|
41
|
+
expect(DEFAULT_TAG_ALIASES.length).toBe(13);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('includes common aliases', () => {
|
|
45
|
+
const aliasMap = new Map(DEFAULT_TAG_ALIASES);
|
|
46
|
+
expect(aliasMap.get('a11y')).toBe('accessibility');
|
|
47
|
+
expect(aliasMap.get('ts')).toBe('typescript');
|
|
48
|
+
expect(aliasMap.get('js')).toBe('javascript');
|
|
49
|
+
expect(aliasMap.get('perf')).toBe('performance');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('normalizeTag', () => {
|
|
54
|
+
it('returns aliased result when store has alias', () => {
|
|
55
|
+
(store.getAlias as ReturnType<typeof vi.fn>).mockReturnValue('accessibility');
|
|
56
|
+
const result = normalizeTag('a11y', store);
|
|
57
|
+
expect(result).toEqual({ original: 'a11y', normalized: 'accessibility', wasAliased: true });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('returns lowercased tag when no alias found', () => {
|
|
61
|
+
const result = normalizeTag('MyCustomTag', store);
|
|
62
|
+
expect(result).toEqual({ original: 'MyCustomTag', normalized: 'mycustomtag', wasAliased: false });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('trims whitespace', () => {
|
|
66
|
+
const result = normalizeTag(' spaced ', store);
|
|
67
|
+
expect(result.normalized).toBe('spaced');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('lowercases before lookup', () => {
|
|
71
|
+
normalizeTag('A11Y', store);
|
|
72
|
+
expect(store.getAlias).toHaveBeenCalledWith('a11y');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('normalizeTags', () => {
|
|
77
|
+
it('normalizes each tag in the array', () => {
|
|
78
|
+
(store.getAlias as ReturnType<typeof vi.fn>)
|
|
79
|
+
.mockReturnValueOnce('accessibility')
|
|
80
|
+
.mockReturnValueOnce(null);
|
|
81
|
+
const results = normalizeTags(['a11y', 'custom'], store);
|
|
82
|
+
expect(results).toHaveLength(2);
|
|
83
|
+
expect(results[0].wasAliased).toBe(true);
|
|
84
|
+
expect(results[1].wasAliased).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('returns empty array for empty input', () => {
|
|
88
|
+
expect(normalizeTags([], store)).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('normalizeAndDedup', () => {
|
|
93
|
+
it('deduplicates after normalization', () => {
|
|
94
|
+
(store.getAlias as ReturnType<typeof vi.fn>)
|
|
95
|
+
.mockReturnValueOnce('styling') // css -> styling
|
|
96
|
+
.mockReturnValueOnce('styling'); // tailwind -> styling
|
|
97
|
+
const { results, dedupedTags, changed } = normalizeAndDedup(['css', 'tailwind'], store);
|
|
98
|
+
expect(results).toHaveLength(2);
|
|
99
|
+
expect(dedupedTags).toEqual(['styling']);
|
|
100
|
+
expect(changed).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('reports changed=false when no aliases applied', () => {
|
|
104
|
+
const { changed } = normalizeAndDedup(['custom', 'other'], store);
|
|
105
|
+
expect(changed).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('reports changed=true when any tag is aliased', () => {
|
|
109
|
+
(store.getAlias as ReturnType<typeof vi.fn>)
|
|
110
|
+
.mockReturnValueOnce('accessibility')
|
|
111
|
+
.mockReturnValueOnce(null);
|
|
112
|
+
const { changed } = normalizeAndDedup(['a11y', 'custom'], store);
|
|
113
|
+
expect(changed).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('addTagAlias', () => {
|
|
118
|
+
it('inserts canonical and upserts alias', () => {
|
|
119
|
+
addTagAlias('react', 'frontend', store);
|
|
120
|
+
expect(store.insertCanonical).toHaveBeenCalledWith('frontend');
|
|
121
|
+
expect(store.upsertAlias).toHaveBeenCalledWith('react', 'frontend');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('lowercases and trims both alias and canonical', () => {
|
|
125
|
+
addTagAlias(' React ', ' Frontend ', store);
|
|
126
|
+
expect(store.insertCanonical).toHaveBeenCalledWith('frontend');
|
|
127
|
+
expect(store.upsertAlias).toHaveBeenCalledWith('react', 'frontend');
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('getCanonicalTags', () => {
|
|
132
|
+
it('maps rows to CanonicalTag objects', () => {
|
|
133
|
+
(store.getCanonicalRows as ReturnType<typeof vi.fn>).mockReturnValue([
|
|
134
|
+
{ tag: 'styling', description: 'CSS stuff', alias_count: 3 },
|
|
135
|
+
]);
|
|
136
|
+
(store.countTagUsage as ReturnType<typeof vi.fn>).mockReturnValue(5);
|
|
137
|
+
|
|
138
|
+
const tags = getCanonicalTags(store);
|
|
139
|
+
expect(tags).toEqual([
|
|
140
|
+
{ tag: 'styling', description: 'CSS stuff', usageCount: 5, aliasCount: 3 },
|
|
141
|
+
]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('returns empty array when no canonicals', () => {
|
|
145
|
+
(store.getCanonicalRows as ReturnType<typeof vi.fn>).mockReturnValue([]);
|
|
146
|
+
expect(getCanonicalTags(store)).toEqual([]);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('seedDefaultAliases', () => {
|
|
151
|
+
it('inserts all unique canonical tags', () => {
|
|
152
|
+
seedDefaultAliases(store);
|
|
153
|
+
const uniqueCanonicals = new Set(DEFAULT_TAG_ALIASES.map(([, c]) => c));
|
|
154
|
+
expect(store.insertCanonical).toHaveBeenCalledTimes(uniqueCanonicals.size);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('upserts all alias pairs', () => {
|
|
158
|
+
seedDefaultAliases(store);
|
|
159
|
+
expect(store.upsertAlias).toHaveBeenCalledTimes(DEFAULT_TAG_ALIASES.length);
|
|
160
|
+
// Spot check
|
|
161
|
+
expect(store.upsertAlias).toHaveBeenCalledWith('a11y', 'accessibility');
|
|
162
|
+
expect(store.upsertAlias).toHaveBeenCalledWith('ts', 'typescript');
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tag Manager — tag normalization, aliasing, and suggestion logic.
|
|
3
|
+
*
|
|
4
|
+
* Pure logic where possible; database access is delegated via a TagStore interface.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { TagNormalizationResult, CanonicalTag } from './types.js';
|
|
8
|
+
|
|
9
|
+
// ─── Constants ──────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_TAG_ALIASES: Array<[string, string]> = [
|
|
12
|
+
['a11y', 'accessibility'],
|
|
13
|
+
['ts', 'typescript'],
|
|
14
|
+
['js', 'javascript'],
|
|
15
|
+
['css', 'styling'],
|
|
16
|
+
['tailwind', 'styling'],
|
|
17
|
+
['tw', 'styling'],
|
|
18
|
+
['vitest', 'testing'],
|
|
19
|
+
['jest', 'testing'],
|
|
20
|
+
['perf', 'performance'],
|
|
21
|
+
['sec', 'security'],
|
|
22
|
+
['auth', 'authentication'],
|
|
23
|
+
['i18n', 'internationalization'],
|
|
24
|
+
['l10n', 'localization'],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
// ─── Tag Store Interface ────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Thin abstraction over the persistence layer for tag operations.
|
|
31
|
+
* Implemented by the Curator facade using its PersistenceProvider.
|
|
32
|
+
*/
|
|
33
|
+
export interface TagStore {
|
|
34
|
+
getAlias(lower: string): string | null;
|
|
35
|
+
insertCanonical(tag: string): void;
|
|
36
|
+
upsertAlias(alias: string, canonical: string): void;
|
|
37
|
+
getCanonicalRows(): Array<{ tag: string; description: string | null; alias_count: number }>;
|
|
38
|
+
countTagUsage(tag: string): number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ─── Normalize ──────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export function normalizeTag(tag: string, store: TagStore): TagNormalizationResult {
|
|
44
|
+
const lower = tag.toLowerCase().trim();
|
|
45
|
+
const canonical = store.getAlias(lower);
|
|
46
|
+
if (canonical) {
|
|
47
|
+
return { original: tag, normalized: canonical, wasAliased: true };
|
|
48
|
+
}
|
|
49
|
+
return { original: tag, normalized: lower, wasAliased: false };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function normalizeTags(tags: string[], store: TagStore): TagNormalizationResult[] {
|
|
53
|
+
return tags.map((tag) => normalizeTag(tag, store));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Deduplicate and return final tag list after normalization.
|
|
58
|
+
*/
|
|
59
|
+
export function normalizeAndDedup(
|
|
60
|
+
tags: string[],
|
|
61
|
+
store: TagStore,
|
|
62
|
+
): { results: TagNormalizationResult[]; dedupedTags: string[]; changed: boolean } {
|
|
63
|
+
const results: TagNormalizationResult[] = [];
|
|
64
|
+
const normalizedTags: string[] = [];
|
|
65
|
+
let changed = false;
|
|
66
|
+
|
|
67
|
+
for (const tag of tags) {
|
|
68
|
+
const result = normalizeTag(tag, store);
|
|
69
|
+
results.push(result);
|
|
70
|
+
normalizedTags.push(result.normalized);
|
|
71
|
+
if (result.normalized !== tag) changed = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const dedupedTags = [...new Set(normalizedTags)];
|
|
75
|
+
return { results, dedupedTags, changed };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ─── Alias Management ───────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
export function addTagAlias(alias: string, canonical: string, store: TagStore): void {
|
|
81
|
+
const lower = alias.toLowerCase().trim();
|
|
82
|
+
const canonicalLower = canonical.toLowerCase().trim();
|
|
83
|
+
store.insertCanonical(canonicalLower);
|
|
84
|
+
store.upsertAlias(lower, canonicalLower);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ─── Canonical Tags ─────────────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
export function getCanonicalTags(store: TagStore): CanonicalTag[] {
|
|
90
|
+
const rows = store.getCanonicalRows();
|
|
91
|
+
return rows.map((row) => ({
|
|
92
|
+
tag: row.tag,
|
|
93
|
+
description: row.description,
|
|
94
|
+
usageCount: store.countTagUsage(row.tag),
|
|
95
|
+
aliasCount: row.alias_count,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ─── Seed ───────────────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
export function seedDefaultAliases(store: TagStore): void {
|
|
102
|
+
const canonicals = new Set(DEFAULT_TAG_ALIASES.map(([, c]) => c));
|
|
103
|
+
for (const tag of canonicals) {
|
|
104
|
+
store.insertCanonical(tag);
|
|
105
|
+
}
|
|
106
|
+
for (const [alias, canonical] of DEFAULT_TAG_ALIASES) {
|
|
107
|
+
store.upsertAlias(alias, canonical);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colocated tests for domain-packs/inject-rules.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests: inject into new file, inject into existing, idempotent replace,
|
|
5
|
+
* remove, no-op on empty content.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
9
|
+
import { mkdtempSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { injectDomainRules, removeDomainRules } from './inject-rules.js';
|
|
13
|
+
|
|
14
|
+
let tempDir: string;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
tempDir = mkdtempSync(join(tmpdir(), 'inject-rules-test-'));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('injectDomainRules', () => {
|
|
25
|
+
it('creates file if it does not exist', () => {
|
|
26
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
27
|
+
injectDomainRules(filePath, 'design', '## Design Rules\nUse semantic tokens.');
|
|
28
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
29
|
+
expect(content).toContain('<!-- domain:design -->');
|
|
30
|
+
expect(content).toContain('## Design Rules');
|
|
31
|
+
expect(content).toContain('<!-- /domain:design -->');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('appends to existing file', () => {
|
|
35
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
36
|
+
writeFileSync(filePath, '# Agent Rules\n\nExisting content.\n');
|
|
37
|
+
injectDomainRules(filePath, 'security', 'Security rules here.');
|
|
38
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
39
|
+
expect(content).toContain('# Agent Rules');
|
|
40
|
+
expect(content).toContain('<!-- domain:security -->');
|
|
41
|
+
expect(content).toContain('Security rules here.');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is idempotent — replaces existing block', () => {
|
|
45
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
46
|
+
writeFileSync(filePath, '# Header\n');
|
|
47
|
+
injectDomainRules(filePath, 'design', 'Version 1');
|
|
48
|
+
injectDomainRules(filePath, 'design', 'Version 2');
|
|
49
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
50
|
+
expect(content).not.toContain('Version 1');
|
|
51
|
+
expect(content).toContain('Version 2');
|
|
52
|
+
// Only one pair of markers
|
|
53
|
+
const openCount = content.split('<!-- domain:design -->').length - 1;
|
|
54
|
+
expect(openCount).toBe(1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('does nothing when content is empty', () => {
|
|
58
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
59
|
+
writeFileSync(filePath, 'Original');
|
|
60
|
+
injectDomainRules(filePath, 'design', '');
|
|
61
|
+
expect(readFileSync(filePath, 'utf-8')).toBe('Original');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('does nothing when content is whitespace-only', () => {
|
|
65
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
66
|
+
writeFileSync(filePath, 'Original');
|
|
67
|
+
injectDomainRules(filePath, 'design', ' \n \n ');
|
|
68
|
+
expect(readFileSync(filePath, 'utf-8')).toBe('Original');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('handles multiple pack injections independently', () => {
|
|
72
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
73
|
+
writeFileSync(filePath, '# Agent\n');
|
|
74
|
+
injectDomainRules(filePath, 'design', 'Design rules');
|
|
75
|
+
injectDomainRules(filePath, 'security', 'Security rules');
|
|
76
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
77
|
+
expect(content).toContain('<!-- domain:design -->');
|
|
78
|
+
expect(content).toContain('<!-- domain:security -->');
|
|
79
|
+
expect(content).toContain('Design rules');
|
|
80
|
+
expect(content).toContain('Security rules');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('removeDomainRules', () => {
|
|
85
|
+
it('removes injected block', () => {
|
|
86
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
87
|
+
writeFileSync(filePath, '# Header\n');
|
|
88
|
+
injectDomainRules(filePath, 'design', 'Rules to remove');
|
|
89
|
+
removeDomainRules(filePath, 'design');
|
|
90
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
91
|
+
expect(content).not.toContain('<!-- domain:design -->');
|
|
92
|
+
expect(content).not.toContain('Rules to remove');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('does nothing if file does not exist', () => {
|
|
96
|
+
// Should not throw
|
|
97
|
+
removeDomainRules(join(tempDir, 'nonexistent.md'), 'design');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('does nothing if markers are not found', () => {
|
|
101
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
102
|
+
writeFileSync(filePath, '# Header\nNo markers here.\n');
|
|
103
|
+
removeDomainRules(filePath, 'design');
|
|
104
|
+
expect(readFileSync(filePath, 'utf-8')).toBe('# Header\nNo markers here.\n');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('only removes the targeted pack block', () => {
|
|
108
|
+
const filePath = join(tempDir, 'CLAUDE.md');
|
|
109
|
+
writeFileSync(filePath, '# Header\n');
|
|
110
|
+
injectDomainRules(filePath, 'design', 'Design rules');
|
|
111
|
+
injectDomainRules(filePath, 'security', 'Security rules');
|
|
112
|
+
removeDomainRules(filePath, 'design');
|
|
113
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
114
|
+
expect(content).not.toContain('Design rules');
|
|
115
|
+
expect(content).toContain('Security rules');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colocated tests for domain-packs/knowledge-installer.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests: three-tier installation, immutable canonical skip, empty knowledge,
|
|
5
|
+
* missing directories.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
9
|
+
import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from 'node:fs';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { installKnowledge } from './knowledge-installer.js';
|
|
13
|
+
import type { DomainPack } from './types.js';
|
|
14
|
+
import type { AgentRuntime } from '../runtime/types.js';
|
|
15
|
+
|
|
16
|
+
let tempDir: string;
|
|
17
|
+
|
|
18
|
+
function mockPack(overrides: Partial<DomainPack> = {}): DomainPack {
|
|
19
|
+
return {
|
|
20
|
+
name: 'test-pack',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
domains: ['testing'],
|
|
23
|
+
ops: [],
|
|
24
|
+
...overrides,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function mockRuntime(): AgentRuntime {
|
|
29
|
+
const entries = new Map<string, unknown>();
|
|
30
|
+
return {
|
|
31
|
+
vault: {
|
|
32
|
+
get: vi.fn((id: string) => entries.get(id) ?? null),
|
|
33
|
+
add: vi.fn((entry: Record<string, unknown>) => entries.set(entry.id as string, entry)),
|
|
34
|
+
search: vi.fn(() => []),
|
|
35
|
+
},
|
|
36
|
+
} as unknown;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function writeMdFiles(dir: string, files: Record<string, string>) {
|
|
40
|
+
mkdirSync(dir, { recursive: true });
|
|
41
|
+
for (const [name, content] of Object.entries(files)) {
|
|
42
|
+
writeFileSync(join(dir, name), content, 'utf-8');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
tempDir = mkdtempSync(join(tmpdir(), 'knowledge-test-'));
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('installKnowledge', () => {
|
|
55
|
+
it('returns zeros when pack has no knowledge', async () => {
|
|
56
|
+
const result = await installKnowledge(mockPack(), mockRuntime(), tempDir);
|
|
57
|
+
expect(result).toEqual({ canonical: 0, curated: 0, captured: 0, skipped: 0 });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('installs canonical entries', async () => {
|
|
61
|
+
const canonicalDir = join(tempDir, 'canonical');
|
|
62
|
+
writeMdFiles(canonicalDir, {
|
|
63
|
+
'no-raw-colors.md': '# No Raw Colors\nAlways use tokens.',
|
|
64
|
+
'token-priority.md': '# Token Priority\nSemantic first.',
|
|
65
|
+
});
|
|
66
|
+
const runtime = mockRuntime();
|
|
67
|
+
const result = await installKnowledge(
|
|
68
|
+
mockPack({ knowledge: { canonical: 'canonical' } }),
|
|
69
|
+
runtime,
|
|
70
|
+
tempDir,
|
|
71
|
+
);
|
|
72
|
+
expect(result.canonical).toBe(2);
|
|
73
|
+
expect(runtime.vault.add).toHaveBeenCalledTimes(2);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('installs curated entries', async () => {
|
|
77
|
+
const curatedDir = join(tempDir, 'curated');
|
|
78
|
+
writeMdFiles(curatedDir, { 'pattern-a.md': 'Pattern A content.' });
|
|
79
|
+
const runtime = mockRuntime();
|
|
80
|
+
const result = await installKnowledge(
|
|
81
|
+
mockPack({ knowledge: { curated: 'curated' } }),
|
|
82
|
+
runtime,
|
|
83
|
+
tempDir,
|
|
84
|
+
);
|
|
85
|
+
expect(result.curated).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('installs captured entries', async () => {
|
|
89
|
+
const capturedDir = join(tempDir, 'captured');
|
|
90
|
+
writeMdFiles(capturedDir, { 'lesson-1.md': 'A lesson.' });
|
|
91
|
+
const runtime = mockRuntime();
|
|
92
|
+
const result = await installKnowledge(
|
|
93
|
+
mockPack({ knowledge: { captured: 'captured' } }),
|
|
94
|
+
runtime,
|
|
95
|
+
tempDir,
|
|
96
|
+
);
|
|
97
|
+
expect(result.captured).toBe(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('skips canonical entries that already exist (immutable)', async () => {
|
|
101
|
+
const canonicalDir = join(tempDir, 'canonical');
|
|
102
|
+
writeMdFiles(canonicalDir, { 'existing.md': 'Content.' });
|
|
103
|
+
const runtime = mockRuntime();
|
|
104
|
+
// Pre-populate vault with existing entry
|
|
105
|
+
(runtime.vault.get as unknown).mockImplementation((id: string) =>
|
|
106
|
+
id === 'pack-test-pack-existing' ? { id } : null,
|
|
107
|
+
);
|
|
108
|
+
const result = await installKnowledge(
|
|
109
|
+
mockPack({ knowledge: { canonical: 'canonical' } }),
|
|
110
|
+
runtime,
|
|
111
|
+
tempDir,
|
|
112
|
+
);
|
|
113
|
+
expect(result.canonical).toBe(0);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('skips non-existing directories gracefully', async () => {
|
|
117
|
+
const runtime = mockRuntime();
|
|
118
|
+
const result = await installKnowledge(
|
|
119
|
+
mockPack({ knowledge: { canonical: 'no-such-dir', curated: 'also-missing' } }),
|
|
120
|
+
runtime,
|
|
121
|
+
tempDir,
|
|
122
|
+
);
|
|
123
|
+
expect(result.canonical).toBe(0);
|
|
124
|
+
expect(result.curated).toBe(0);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('tags entries with pack source and tier', async () => {
|
|
128
|
+
const canonicalDir = join(tempDir, 'canonical');
|
|
129
|
+
writeMdFiles(canonicalDir, { 'tagged.md': 'Tagged entry.' });
|
|
130
|
+
const runtime = mockRuntime();
|
|
131
|
+
await installKnowledge(
|
|
132
|
+
mockPack({ knowledge: { canonical: 'canonical' } }),
|
|
133
|
+
runtime,
|
|
134
|
+
tempDir,
|
|
135
|
+
);
|
|
136
|
+
const addCall = (runtime.vault.add as unknown).mock.calls[0][0];
|
|
137
|
+
expect(addCall.tags).toContain('pack:test-pack');
|
|
138
|
+
expect(addCall.tags).toContain('tier:canonical');
|
|
139
|
+
expect(addCall.origin).toBe('pack');
|
|
140
|
+
expect(addCall.domain).toBe('test-pack');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('generates correct entry id from pack name and filename', async () => {
|
|
144
|
+
const curatedDir = join(tempDir, 'curated');
|
|
145
|
+
writeMdFiles(curatedDir, { 'my-pattern.md': 'Content.' });
|
|
146
|
+
const runtime = mockRuntime();
|
|
147
|
+
await installKnowledge(
|
|
148
|
+
mockPack({ knowledge: { curated: 'curated' } }),
|
|
149
|
+
runtime,
|
|
150
|
+
tempDir,
|
|
151
|
+
);
|
|
152
|
+
const addCall = (runtime.vault.add as unknown).mock.calls[0][0];
|
|
153
|
+
expect(addCall.id).toBe('pack-test-pack-my-pattern');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('installs all three tiers in a single call', async () => {
|
|
157
|
+
writeMdFiles(join(tempDir, 'c'), { 'a.md': 'A' });
|
|
158
|
+
writeMdFiles(join(tempDir, 'u'), { 'b.md': 'B' });
|
|
159
|
+
writeMdFiles(join(tempDir, 'p'), { 'c.md': 'C' });
|
|
160
|
+
const runtime = mockRuntime();
|
|
161
|
+
const result = await installKnowledge(
|
|
162
|
+
mockPack({ knowledge: { canonical: 'c', curated: 'u', captured: 'p' } }),
|
|
163
|
+
runtime,
|
|
164
|
+
tempDir,
|
|
165
|
+
);
|
|
166
|
+
expect(result.canonical).toBe(1);
|
|
167
|
+
expect(result.curated).toBe(1);
|
|
168
|
+
expect(result.captured).toBe(1);
|
|
169
|
+
expect(runtime.vault.add).toHaveBeenCalledTimes(3);
|
|
170
|
+
});
|
|
171
|
+
});
|