cognitive-core 0.1.2 → 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/CLAUDE.md +233 -0
- package/README.md +370 -54
- package/dist/atlas.d.ts +10 -10
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +79 -48
- package/dist/atlas.js.map +1 -1
- package/dist/bin/cli-utils.d.ts +37 -0
- package/dist/bin/cli-utils.d.ts.map +1 -0
- package/dist/bin/cli-utils.js +176 -0
- package/dist/bin/cli-utils.js.map +1 -0
- package/dist/bin/cognitive-core.d.ts +2 -12
- package/dist/bin/cognitive-core.d.ts.map +1 -1
- package/dist/bin/cognitive-core.js +76 -351
- package/dist/bin/cognitive-core.js.map +1 -1
- package/dist/bin/commands/kb.d.ts +6 -0
- package/dist/bin/commands/kb.d.ts.map +1 -0
- package/dist/bin/commands/kb.js +240 -0
- package/dist/bin/commands/kb.js.map +1 -0
- package/dist/bin/commands/learn.d.ts +6 -0
- package/dist/bin/commands/learn.d.ts.map +1 -0
- package/dist/bin/commands/learn.js +91 -0
- package/dist/bin/commands/learn.js.map +1 -0
- package/dist/bin/commands/legacy.d.ts +12 -0
- package/dist/bin/commands/legacy.d.ts.map +1 -0
- package/dist/bin/commands/legacy.js +142 -0
- package/dist/bin/commands/legacy.js.map +1 -0
- package/dist/bin/commands/run.d.ts +3 -0
- package/dist/bin/commands/run.d.ts.map +1 -0
- package/dist/bin/commands/run.js +99 -0
- package/dist/bin/commands/run.js.map +1 -0
- package/dist/bin/commands/sessions.d.ts +9 -0
- package/dist/bin/commands/sessions.d.ts.map +1 -0
- package/dist/bin/commands/sessions.js +183 -0
- package/dist/bin/commands/sessions.js.map +1 -0
- package/dist/bin/commands/skills.d.ts +6 -0
- package/dist/bin/commands/skills.d.ts.map +1 -0
- package/dist/bin/commands/skills.js +135 -0
- package/dist/bin/commands/skills.js.map +1 -0
- package/dist/embeddings/index.d.ts +1 -0
- package/dist/embeddings/index.d.ts.map +1 -1
- package/dist/embeddings/index.js +2 -0
- package/dist/embeddings/index.js.map +1 -1
- package/dist/embeddings/inverted-index.d.ts +47 -0
- package/dist/embeddings/inverted-index.d.ts.map +1 -0
- package/dist/embeddings/inverted-index.js +122 -0
- package/dist/embeddings/inverted-index.js.map +1 -0
- package/dist/embeddings/manager.d.ts +3 -1
- package/dist/embeddings/manager.d.ts.map +1 -1
- package/dist/embeddings/manager.js +12 -7
- package/dist/embeddings/manager.js.map +1 -1
- package/dist/embeddings/vector-store.d.ts +7 -3
- package/dist/embeddings/vector-store.d.ts.map +1 -1
- package/dist/embeddings/vector-store.js +22 -6
- package/dist/embeddings/vector-store.js.map +1 -1
- package/dist/factory.d.ts +11 -12
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +20 -7
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -5
- package/dist/index.js.map +1 -1
- package/dist/learning/analyzer.d.ts.map +1 -1
- package/dist/learning/analyzer.js +17 -35
- package/dist/learning/analyzer.js.map +1 -1
- package/dist/learning/energy-evaluator.d.ts +128 -0
- package/dist/learning/energy-evaluator.d.ts.map +1 -0
- package/dist/learning/energy-evaluator.js +175 -0
- package/dist/learning/energy-evaluator.js.map +1 -0
- package/dist/learning/healing-orchestrator.d.ts +182 -0
- package/dist/learning/healing-orchestrator.d.ts.map +1 -0
- package/dist/learning/healing-orchestrator.js +250 -0
- package/dist/learning/healing-orchestrator.js.map +1 -0
- package/dist/learning/index.d.ts +7 -2
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +13 -2
- package/dist/learning/index.js.map +1 -1
- package/dist/learning/instant-loop.d.ts +87 -0
- package/dist/learning/instant-loop.d.ts.map +1 -0
- package/dist/learning/instant-loop.js +264 -0
- package/dist/learning/instant-loop.js.map +1 -0
- package/dist/learning/loop-coordinator.d.ts +61 -0
- package/dist/learning/loop-coordinator.d.ts.map +1 -0
- package/dist/learning/loop-coordinator.js +96 -0
- package/dist/learning/loop-coordinator.js.map +1 -0
- package/dist/learning/maintenance-scheduler.d.ts +141 -0
- package/dist/learning/maintenance-scheduler.d.ts.map +1 -0
- package/dist/learning/maintenance-scheduler.js +186 -0
- package/dist/learning/maintenance-scheduler.js.map +1 -0
- package/dist/learning/meta-learner.d.ts.map +1 -1
- package/dist/learning/meta-learner.js +4 -21
- package/dist/learning/meta-learner.js.map +1 -1
- package/dist/learning/pipeline.d.ts +31 -4
- package/dist/learning/pipeline.d.ts.map +1 -1
- package/dist/learning/pipeline.js +64 -12
- package/dist/learning/pipeline.js.map +1 -1
- package/dist/learning/reflexion-generator.d.ts +64 -0
- package/dist/learning/reflexion-generator.d.ts.map +1 -0
- package/dist/learning/reflexion-generator.js +194 -0
- package/dist/learning/reflexion-generator.js.map +1 -0
- package/dist/learning/trajectory-sources/entire.d.ts +8 -5
- package/dist/learning/trajectory-sources/entire.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/entire.js +13 -6
- package/dist/learning/trajectory-sources/entire.js.map +1 -1
- package/dist/learning/trajectory-sources/index.d.ts +1 -1
- package/dist/learning/trajectory-sources/index.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/index.js +1 -1
- package/dist/learning/trajectory-sources/index.js.map +1 -1
- package/dist/learning/trajectory-sources/pipeline.d.ts +4 -4
- package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/pipeline.js +2 -2
- package/dist/learning/trajectory-sources/pipeline.js.map +1 -1
- package/dist/learning/unified-pipeline.d.ts +281 -0
- package/dist/learning/unified-pipeline.d.ts.map +1 -0
- package/dist/learning/unified-pipeline.js +637 -0
- package/dist/learning/unified-pipeline.js.map +1 -0
- package/dist/memory/candidate-retrieval.d.ts +43 -0
- package/dist/memory/candidate-retrieval.d.ts.map +1 -0
- package/dist/memory/candidate-retrieval.js +41 -0
- package/dist/memory/candidate-retrieval.js.map +1 -0
- package/dist/memory/causal-store.d.ts +97 -0
- package/dist/memory/causal-store.d.ts.map +1 -0
- package/dist/memory/causal-store.js +209 -0
- package/dist/memory/causal-store.js.map +1 -0
- package/dist/memory/coherence.d.ts +71 -0
- package/dist/memory/coherence.d.ts.map +1 -0
- package/dist/memory/coherence.js +176 -0
- package/dist/memory/coherence.js.map +1 -0
- package/dist/memory/experience.d.ts +39 -6
- package/dist/memory/experience.d.ts.map +1 -1
- package/dist/memory/experience.js +193 -49
- package/dist/memory/experience.js.map +1 -1
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +12 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/knowledge-bank.d.ts +14 -0
- package/dist/memory/knowledge-bank.d.ts.map +1 -1
- package/dist/memory/knowledge-bank.js +45 -0
- package/dist/memory/knowledge-bank.js.map +1 -1
- package/dist/memory/meta.d.ts +7 -8
- package/dist/memory/meta.d.ts.map +1 -1
- package/dist/memory/meta.js +73 -79
- package/dist/memory/meta.js.map +1 -1
- package/dist/memory/playbook.d.ts +26 -9
- package/dist/memory/playbook.d.ts.map +1 -1
- package/dist/memory/playbook.js +198 -74
- package/dist/memory/playbook.js.map +1 -1
- package/dist/memory/reasoning-bank.d.ts +130 -0
- package/dist/memory/reasoning-bank.d.ts.map +1 -0
- package/dist/memory/reasoning-bank.js +342 -0
- package/dist/memory/reasoning-bank.js.map +1 -0
- package/dist/memory/reflexion.d.ts +59 -0
- package/dist/memory/reflexion.d.ts.map +1 -0
- package/dist/memory/reflexion.js +96 -0
- package/dist/memory/reflexion.js.map +1 -0
- package/dist/memory/system.d.ts +7 -2
- package/dist/memory/system.d.ts.map +1 -1
- package/dist/memory/system.js +19 -7
- package/dist/memory/system.js.map +1 -1
- package/dist/memory/temporal-compressor.d.ts +126 -0
- package/dist/memory/temporal-compressor.d.ts.map +1 -0
- package/dist/memory/temporal-compressor.js +335 -0
- package/dist/memory/temporal-compressor.js.map +1 -0
- package/dist/persistence/index.d.ts +11 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +11 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/migrator.d.ts +40 -0
- package/dist/persistence/migrator.d.ts.map +1 -0
- package/dist/persistence/migrator.js +238 -0
- package/dist/persistence/migrator.js.map +1 -0
- package/dist/persistence/serializers.d.ts +45 -0
- package/dist/persistence/serializers.d.ts.map +1 -0
- package/dist/persistence/serializers.js +80 -0
- package/dist/persistence/serializers.js.map +1 -0
- package/dist/persistence/sqlite-persistence.d.ts +228 -0
- package/dist/persistence/sqlite-persistence.d.ts.map +1 -0
- package/dist/persistence/sqlite-persistence.js +588 -0
- package/dist/persistence/sqlite-persistence.js.map +1 -0
- package/dist/runtime/flows/learning.d.ts +10 -12
- package/dist/runtime/flows/learning.d.ts.map +1 -1
- package/dist/runtime/flows/learning.js +10 -23
- package/dist/runtime/flows/learning.js.map +1 -1
- package/dist/search/index.d.ts +1 -0
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +2 -0
- package/dist/search/index.js.map +1 -1
- package/dist/search/moe-gate.d.ts +124 -0
- package/dist/search/moe-gate.d.ts.map +1 -0
- package/dist/search/moe-gate.js +234 -0
- package/dist/search/moe-gate.js.map +1 -0
- package/dist/search/router.d.ts +32 -2
- package/dist/search/router.d.ts.map +1 -1
- package/dist/search/router.js +87 -4
- package/dist/search/router.js.map +1 -1
- package/dist/session-bank/git-reader.d.ts +9 -4
- package/dist/session-bank/git-reader.d.ts.map +1 -1
- package/dist/session-bank/git-reader.js +22 -15
- package/dist/session-bank/git-reader.js.map +1 -1
- package/dist/session-bank/index.d.ts +2 -2
- package/dist/session-bank/index.d.ts.map +1 -1
- package/dist/session-bank/index.js +2 -2
- package/dist/session-bank/index.js.map +1 -1
- package/dist/session-bank/parser.d.ts +16 -5
- package/dist/session-bank/parser.d.ts.map +1 -1
- package/dist/session-bank/parser.js +187 -80
- package/dist/session-bank/parser.js.map +1 -1
- package/dist/session-bank/session-bank.d.ts +5 -0
- package/dist/session-bank/session-bank.d.ts.map +1 -1
- package/dist/session-bank/session-bank.js +30 -9
- package/dist/session-bank/session-bank.js.map +1 -1
- package/dist/session-bank/types.d.ts +4 -1
- package/dist/session-bank/types.d.ts.map +1 -1
- package/dist/session-bank/types.js +3 -3
- package/dist/session-bank/types.js.map +1 -1
- package/dist/surfacing/skill-publisher.d.ts.map +1 -1
- package/dist/surfacing/skill-publisher.js +15 -43
- package/dist/surfacing/skill-publisher.js.map +1 -1
- package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -1
- package/dist/surfacing/sqlite-storage-adapter.js +13 -21
- package/dist/surfacing/sqlite-storage-adapter.js.map +1 -1
- package/dist/types/config.d.ts +100 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +27 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/memory.d.ts +52 -0
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/types/memory.js +13 -0
- package/dist/types/memory.js.map +1 -1
- package/dist/types/playbook.d.ts +4 -0
- package/dist/types/playbook.d.ts.map +1 -1
- package/dist/types/playbook.js.map +1 -1
- package/dist/utils/error-classifier.d.ts +30 -0
- package/dist/utils/error-classifier.d.ts.map +1 -0
- package/dist/utils/error-classifier.js +85 -0
- package/dist/utils/error-classifier.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/partitioned-store.d.ts +93 -0
- package/dist/utils/partitioned-store.d.ts.map +1 -0
- package/dist/utils/partitioned-store.js +251 -0
- package/dist/utils/partitioned-store.js.map +1 -0
- package/dist/utils/trajectory-helpers.d.ts +39 -0
- package/dist/utils/trajectory-helpers.d.ts.map +1 -0
- package/dist/utils/trajectory-helpers.js +57 -0
- package/dist/utils/trajectory-helpers.js.map +1 -0
- package/dist/workspace/runner.d.ts +3 -4
- package/dist/workspace/runner.d.ts.map +1 -1
- package/dist/workspace/runner.js.map +1 -1
- package/dist/workspace/types.d.ts +9 -2
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/types.js.map +1 -1
- package/package.json +6 -4
- package/references/sessionlog/.husky/pre-commit +1 -0
- package/references/sessionlog/.lintstagedrc.json +4 -0
- package/references/sessionlog/.prettierignore +4 -0
- package/references/sessionlog/.prettierrc.json +11 -0
- package/references/sessionlog/LICENSE +21 -0
- package/references/sessionlog/README.md +453 -0
- package/references/sessionlog/eslint.config.js +58 -0
- package/references/sessionlog/package-lock.json +3672 -0
- package/references/sessionlog/package.json +65 -0
- package/references/sessionlog/src/__tests__/agent-hooks.test.ts +570 -0
- package/references/sessionlog/src/__tests__/agent-registry.test.ts +127 -0
- package/references/sessionlog/src/__tests__/claude-code-hooks.test.ts +225 -0
- package/references/sessionlog/src/__tests__/claude-generator.test.ts +46 -0
- package/references/sessionlog/src/__tests__/commit-msg.test.ts +86 -0
- package/references/sessionlog/src/__tests__/cursor-agent.test.ts +224 -0
- package/references/sessionlog/src/__tests__/e2e-live.test.ts +890 -0
- package/references/sessionlog/src/__tests__/event-log.test.ts +183 -0
- package/references/sessionlog/src/__tests__/flush-sentinel.test.ts +105 -0
- package/references/sessionlog/src/__tests__/gemini-agent.test.ts +375 -0
- package/references/sessionlog/src/__tests__/git-hooks.test.ts +78 -0
- package/references/sessionlog/src/__tests__/hook-managers.test.ts +121 -0
- package/references/sessionlog/src/__tests__/lifecycle-tasks.test.ts +759 -0
- package/references/sessionlog/src/__tests__/opencode-agent.test.ts +338 -0
- package/references/sessionlog/src/__tests__/redaction.test.ts +136 -0
- package/references/sessionlog/src/__tests__/session-repo.test.ts +353 -0
- package/references/sessionlog/src/__tests__/session-store.test.ts +166 -0
- package/references/sessionlog/src/__tests__/setup-ccweb.test.ts +466 -0
- package/references/sessionlog/src/__tests__/skill-live.test.ts +461 -0
- package/references/sessionlog/src/__tests__/summarize.test.ts +348 -0
- package/references/sessionlog/src/__tests__/task-plan-e2e.test.ts +610 -0
- package/references/sessionlog/src/__tests__/task-plan-live.test.ts +632 -0
- package/references/sessionlog/src/__tests__/transcript-timestamp.test.ts +121 -0
- package/references/sessionlog/src/__tests__/types.test.ts +166 -0
- package/references/sessionlog/src/__tests__/utils.test.ts +333 -0
- package/references/sessionlog/src/__tests__/validation.test.ts +103 -0
- package/references/sessionlog/src/__tests__/worktree.test.ts +57 -0
- package/references/sessionlog/src/agent/agents/claude-code.ts +1089 -0
- package/references/sessionlog/src/agent/agents/cursor.ts +361 -0
- package/references/sessionlog/src/agent/agents/gemini-cli.ts +632 -0
- package/references/sessionlog/src/agent/agents/opencode.ts +540 -0
- package/references/sessionlog/src/agent/registry.ts +143 -0
- package/references/sessionlog/src/agent/session-types.ts +113 -0
- package/references/sessionlog/src/agent/types.ts +220 -0
- package/references/sessionlog/src/cli.ts +597 -0
- package/references/sessionlog/src/commands/clean.ts +133 -0
- package/references/sessionlog/src/commands/disable.ts +84 -0
- package/references/sessionlog/src/commands/doctor.ts +145 -0
- package/references/sessionlog/src/commands/enable.ts +202 -0
- package/references/sessionlog/src/commands/explain.ts +261 -0
- package/references/sessionlog/src/commands/reset.ts +105 -0
- package/references/sessionlog/src/commands/resume.ts +180 -0
- package/references/sessionlog/src/commands/rewind.ts +195 -0
- package/references/sessionlog/src/commands/setup-ccweb.ts +275 -0
- package/references/sessionlog/src/commands/status.ts +172 -0
- package/references/sessionlog/src/config.ts +165 -0
- package/references/sessionlog/src/events/event-log.ts +126 -0
- package/references/sessionlog/src/git-operations.ts +558 -0
- package/references/sessionlog/src/hooks/git-hooks.ts +165 -0
- package/references/sessionlog/src/hooks/lifecycle.ts +391 -0
- package/references/sessionlog/src/index.ts +650 -0
- package/references/sessionlog/src/security/redaction.ts +283 -0
- package/references/sessionlog/src/session/state-machine.ts +452 -0
- package/references/sessionlog/src/store/checkpoint-store.ts +509 -0
- package/references/sessionlog/src/store/native-store.ts +173 -0
- package/references/sessionlog/src/store/provider-types.ts +99 -0
- package/references/sessionlog/src/store/session-store.ts +266 -0
- package/references/sessionlog/src/strategy/attribution.ts +296 -0
- package/references/sessionlog/src/strategy/common.ts +207 -0
- package/references/sessionlog/src/strategy/content-overlap.ts +228 -0
- package/references/sessionlog/src/strategy/manual-commit.ts +988 -0
- package/references/sessionlog/src/strategy/types.ts +279 -0
- package/references/sessionlog/src/summarize/claude-generator.ts +115 -0
- package/references/sessionlog/src/summarize/summarize.ts +432 -0
- package/references/sessionlog/src/types.ts +508 -0
- package/references/sessionlog/src/utils/chunk-files.ts +49 -0
- package/references/sessionlog/src/utils/commit-message.ts +65 -0
- package/references/sessionlog/src/utils/detect-agent.ts +36 -0
- package/references/sessionlog/src/utils/hook-managers.ts +125 -0
- package/references/sessionlog/src/utils/ide-tags.ts +32 -0
- package/references/sessionlog/src/utils/paths.ts +79 -0
- package/references/sessionlog/src/utils/preview-rewind.ts +80 -0
- package/references/sessionlog/src/utils/rewind-conflict.ts +121 -0
- package/references/sessionlog/src/utils/shadow-branch.ts +109 -0
- package/references/sessionlog/src/utils/string-utils.ts +46 -0
- package/references/sessionlog/src/utils/todo-extract.ts +188 -0
- package/references/sessionlog/src/utils/trailers.ts +187 -0
- package/references/sessionlog/src/utils/transcript-parse.ts +177 -0
- package/references/sessionlog/src/utils/transcript-timestamp.ts +59 -0
- package/references/sessionlog/src/utils/tree-ops.ts +219 -0
- package/references/sessionlog/src/utils/tty.ts +72 -0
- package/references/sessionlog/src/utils/validation.ts +65 -0
- package/references/sessionlog/src/utils/worktree.ts +58 -0
- package/references/sessionlog/src/wire-types.ts +59 -0
- package/references/sessionlog/templates/setup-env.sh +153 -0
- package/references/sessionlog/tsconfig.json +18 -0
- package/references/sessionlog/vitest.config.ts +12 -0
- package/references/skill-tree/.sudocode/issues.jsonl +8 -0
- package/references/skill-tree/.sudocode/specs.jsonl +2 -0
- package/references/skill-tree/CLAUDE.md +56 -80
- package/references/skill-tree/README.md +188 -140
- package/references/skill-tree/examples/basic-usage.ts +95 -121
- package/references/skill-tree/package-lock.json +369 -26
- package/references/skill-tree/package.json +1 -1
- package/src/atlas.ts +97 -67
- package/src/bin/cli-utils.ts +220 -0
- package/src/bin/cognitive-core.ts +84 -392
- package/src/bin/commands/kb.ts +266 -0
- package/src/bin/commands/learn.ts +100 -0
- package/src/bin/commands/legacy.ts +182 -0
- package/src/bin/commands/run.ts +113 -0
- package/src/bin/commands/sessions.ts +221 -0
- package/src/bin/commands/skills.ts +146 -0
- package/src/embeddings/index.ts +3 -0
- package/src/embeddings/inverted-index.ts +134 -0
- package/src/embeddings/manager.ts +13 -8
- package/src/embeddings/vector-store.ts +21 -9
- package/src/factory.ts +33 -16
- package/src/index.ts +109 -9
- package/src/learning/analyzer.ts +21 -37
- package/src/learning/energy-evaluator.ts +282 -0
- package/src/learning/healing-orchestrator.ts +383 -0
- package/src/learning/index.ts +65 -9
- package/src/learning/instant-loop.ts +357 -0
- package/src/learning/maintenance-scheduler.ts +271 -0
- package/src/learning/meta-learner.ts +5 -23
- package/src/learning/reflexion-generator.ts +273 -0
- package/src/learning/trajectory-sources/entire.ts +24 -13
- package/src/learning/trajectory-sources/index.ts +2 -2
- package/src/learning/trajectory-sources/pipeline.ts +5 -5
- package/src/learning/unified-pipeline.ts +921 -0
- package/src/memory/candidate-retrieval.ts +71 -0
- package/src/memory/causal-store.ts +273 -0
- package/src/memory/coherence.ts +252 -0
- package/src/memory/experience.ts +217 -50
- package/src/memory/index.ts +43 -0
- package/src/memory/knowledge-bank.ts +57 -0
- package/src/memory/meta.ts +78 -96
- package/src/memory/playbook.ts +239 -75
- package/src/memory/reasoning-bank.ts +458 -0
- package/src/memory/reflexion.ts +122 -0
- package/src/memory/system.ts +21 -5
- package/src/memory/temporal-compressor.ts +409 -0
- package/src/persistence/index.ts +37 -0
- package/src/persistence/migrator.ts +298 -0
- package/src/persistence/serializers.ts +79 -0
- package/src/persistence/sqlite-persistence.ts +925 -0
- package/src/runtime/flows/learning.ts +25 -42
- package/src/search/index.ts +10 -0
- package/src/search/moe-gate.ts +304 -0
- package/src/search/router.ts +111 -4
- package/src/session-bank/git-reader.ts +29 -19
- package/src/session-bank/index.ts +4 -2
- package/src/session-bank/parser.ts +280 -98
- package/src/session-bank/session-bank.ts +33 -12
- package/src/session-bank/types.ts +8 -5
- package/src/surfacing/skill-publisher.ts +17 -49
- package/src/surfacing/sqlite-storage-adapter.ts +16 -32
- package/src/types/config.ts +30 -0
- package/src/types/index.ts +3 -0
- package/src/types/memory.ts +30 -0
- package/src/types/playbook.ts +4 -0
- package/src/utils/error-classifier.ts +113 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/partitioned-store.ts +299 -0
- package/src/utils/trajectory-helpers.ts +79 -0
- package/src/workspace/runner.ts +3 -3
- package/src/workspace/types.ts +10 -2
- package/tests/embeddings/inverted-index.test.ts +138 -0
- package/tests/feature-toggles.test.ts +275 -0
- package/tests/gap-fixes.test.ts +17 -4
- package/tests/integration/cli-e2e.test.ts +621 -0
- package/tests/integration/e2e.test.ts +6 -5
- package/tests/integration/entire-e2e.test.ts +314 -125
- package/tests/integration/persistence-e2e.test.ts +741 -0
- package/tests/integration/phase-e2e.test.ts +1143 -0
- package/tests/integration/session-bank.test.ts +20 -14
- package/tests/integration/sessionlog-e2e.test.ts +329 -0
- package/tests/integration/unified-pipeline-e2e.test.ts +634 -0
- package/tests/learning/analyzer.test.ts +1 -1
- package/tests/learning/energy-evaluator.test.ts +180 -0
- package/tests/learning/entire-trajectory-source.test.ts +25 -25
- package/tests/learning/healing-orchestrator.test.ts +269 -0
- package/tests/learning/instant-loop.test.ts +243 -0
- package/tests/learning/maintenance-scheduler.test.ts +191 -0
- package/tests/learning/reflexion-generator.test.ts +411 -0
- package/tests/learning/trajectory-sources.test.ts +12 -4
- package/tests/learning/unified-pipeline.test.ts +322 -0
- package/tests/mcp/playbook-server.test.ts +6 -1
- package/tests/memory/causal-store.test.ts +276 -0
- package/tests/memory/coherence.test.ts +232 -0
- package/tests/memory/experience.test.ts +8 -3
- package/tests/memory/playbook.test.ts +307 -1
- package/tests/memory/provenance.test.ts +11 -2
- package/tests/memory/reasoning-bank.test.ts +239 -0
- package/tests/memory/reflexion.test.ts +166 -0
- package/tests/memory/skill-exporter.test.ts +6 -1
- package/tests/memory/system.test.ts +6 -1
- package/tests/memory/temporal-compressor.test.ts +318 -0
- package/tests/persistence/migrator.test.ts +1009 -0
- package/tests/persistence/sqlite-persistence.test.ts +635 -0
- package/tests/runtime/agent-manager.test.ts +6 -1
- package/tests/runtime/delegate.test.ts +6 -1
- package/tests/search/moe-gate.test.ts +250 -0
- package/tests/search/refinement-loop.test.ts +11 -2
- package/tests/search/router.test.ts +81 -2
- package/tests/session-bank/fixtures/sessionlog-root-metadata.json +16 -0
- package/tests/session-bank/fixtures/sessionlog-session/full.jsonl +6 -0
- package/tests/session-bank/fixtures/sessionlog-session/metadata.json +55 -0
- package/tests/session-bank/git-reader.test.ts +13 -13
- package/tests/session-bank/parser.test.ts +135 -3
- package/tests/session-bank/session-bank.test.ts +1 -1
- package/tests/surfacing/skill-library.test.ts +6 -1
- package/tests/surfacing/skill-publisher.test.ts +24 -58
- package/tests/surfacing/sqlite-storage-adapter.test.ts +11 -23
- package/tests/utils/partitioned-store.test.ts +230 -0
- package/tests/workspace/full-flow.test.ts +10 -4
- package/tests/workspace/runner.test.ts +10 -4
- package/docs/DESIGN-workspace-migration.md +0 -1079
- package/docs/PLAN-agentic-workspace-implementation.md +0 -717
- package/docs/PLAN-graph-migration.md +0 -299
- package/docs/PLAN-session-bank-implementation.md +0 -474
- package/src/learning/pipeline.ts +0 -323
- package/tests/learning/pipeline.test.ts +0 -176
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { CheckpointParser, detectFormat } from '../../src/session-bank/parser.js';
|
|
5
5
|
|
|
6
6
|
const FIXTURES = join(import.meta.dirname, 'fixtures');
|
|
7
7
|
|
|
@@ -11,8 +11,8 @@ async function loadFixture(
|
|
|
11
11
|
return readFile(join(FIXTURES, ...segments), 'utf-8');
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
describe('
|
|
15
|
-
const parser = new
|
|
14
|
+
describe('CheckpointParser', () => {
|
|
15
|
+
const parser = new CheckpointParser();
|
|
16
16
|
|
|
17
17
|
// ──────────────────────────────────────────────────────────────
|
|
18
18
|
// parseMetadata
|
|
@@ -318,4 +318,136 @@ describe('EntireTranscriptParser', () => {
|
|
|
318
318
|
expect(session.source.sessionIndex).toBe('0');
|
|
319
319
|
});
|
|
320
320
|
});
|
|
321
|
+
|
|
322
|
+
// ──────────────────────────────────────────────────────────────
|
|
323
|
+
// detectFormat
|
|
324
|
+
// ──────────────────────────────────────────────────────────────
|
|
325
|
+
|
|
326
|
+
describe('detectFormat', () => {
|
|
327
|
+
it('should detect Entire CLI format (snake_case)', () => {
|
|
328
|
+
expect(detectFormat({ checkpoint_id: 'abc' })).toBe('entire');
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('should detect SessionLog format (camelCase)', () => {
|
|
332
|
+
expect(detectFormat({ checkpointID: 'abc' })).toBe('sessionlog');
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('should detect SessionLog via cliVersion', () => {
|
|
336
|
+
expect(detectFormat({ cliVersion: 'opentasks-sessionlog' })).toBe('sessionlog');
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('should detect Entire via cli_version', () => {
|
|
340
|
+
expect(detectFormat({ cli_version: '0.4.0' })).toBe('entire');
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('should return unknown for empty object', () => {
|
|
344
|
+
expect(detectFormat({})).toBe('unknown');
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// ──────────────────────────────────────────────────────────────
|
|
349
|
+
// SessionLog format parsing
|
|
350
|
+
// ──────────────────────────────────────────────────────────────
|
|
351
|
+
|
|
352
|
+
describe('SessionLog format', () => {
|
|
353
|
+
it('should parse SessionLog camelCase metadata', async () => {
|
|
354
|
+
const json = await loadFixture('sessionlog-session', 'metadata.json');
|
|
355
|
+
const result = parser.parseMetadata(json);
|
|
356
|
+
|
|
357
|
+
expect(result.format).toBe('sessionlog');
|
|
358
|
+
expect(result.sessionId).toBe(
|
|
359
|
+
'2026-02-15-aabbccdd-1122-3344-5566-778899aabbcc',
|
|
360
|
+
);
|
|
361
|
+
expect(result.checkpointId).toBe('c4d5e6f7a8b9');
|
|
362
|
+
expect(result.metadata.cliVersion).toBe('opentasks-sessionlog');
|
|
363
|
+
expect(result.metadata.strategy).toBe('manual-commit');
|
|
364
|
+
expect(result.metadata.createdAt).toBeInstanceOf(Date);
|
|
365
|
+
expect(result.metadata.branch).toBe('main');
|
|
366
|
+
expect(result.metadata.agent).toBe('Claude Code');
|
|
367
|
+
expect(result.metadata.filesTouched).toEqual([
|
|
368
|
+
'src/api.ts',
|
|
369
|
+
'tests/api.test.ts',
|
|
370
|
+
]);
|
|
371
|
+
expect(result.metadata.isTask).toBe(false);
|
|
372
|
+
expect(result.metadata.checkpointTranscriptStart).toBe(0);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('should parse SessionLog summary with CodeLearning normalization', async () => {
|
|
376
|
+
const json = await loadFixture('sessionlog-session', 'metadata.json');
|
|
377
|
+
const result = parser.parseMetadata(json);
|
|
378
|
+
|
|
379
|
+
expect(result.summary).toBeDefined();
|
|
380
|
+
expect(result.summary!.intent).toBe('Add validation to the API endpoint');
|
|
381
|
+
expect(result.summary!.outcome).toContain('Zod schema');
|
|
382
|
+
expect(result.summary!.learnings.repoPatterns).toEqual([
|
|
383
|
+
'API routes use Zod for validation',
|
|
384
|
+
]);
|
|
385
|
+
// CodeLearning[] → string[]
|
|
386
|
+
expect(result.summary!.learnings.codeFindings).toHaveLength(1);
|
|
387
|
+
expect(result.summary!.learnings.codeFindings[0]).toBe(
|
|
388
|
+
'src/api.ts:15 - Zod schema must be defined before route handler',
|
|
389
|
+
);
|
|
390
|
+
expect(result.summary!.learnings.workflowPractices).toEqual([
|
|
391
|
+
'Run API tests with --reporter=verbose flag',
|
|
392
|
+
]);
|
|
393
|
+
expect(result.summary!.frictionPoints).toEqual([
|
|
394
|
+
'Had to look up Zod coercion syntax',
|
|
395
|
+
]);
|
|
396
|
+
expect(result.summary!.openItems).toEqual([
|
|
397
|
+
'Add validation for the PUT endpoint too',
|
|
398
|
+
]);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('should parse SessionLog token usage with single subagentTokens', async () => {
|
|
402
|
+
const json = await loadFixture('sessionlog-session', 'metadata.json');
|
|
403
|
+
const result = parser.parseMetadata(json);
|
|
404
|
+
|
|
405
|
+
expect(result.tokenUsage.inputTokens).toBe(20000);
|
|
406
|
+
expect(result.tokenUsage.cacheCreationTokens).toBe(3000);
|
|
407
|
+
expect(result.tokenUsage.cacheReadTokens).toBe(6000);
|
|
408
|
+
expect(result.tokenUsage.outputTokens).toBe(4000);
|
|
409
|
+
expect(result.tokenUsage.apiCallCount).toBe(10);
|
|
410
|
+
expect(result.tokenUsage.total).toBe(20000 + 3000 + 6000 + 4000);
|
|
411
|
+
|
|
412
|
+
// Single subagentTokens object wrapped in array
|
|
413
|
+
expect(result.tokenUsage.subagentUsage).toBeDefined();
|
|
414
|
+
expect(result.tokenUsage.subagentUsage).toHaveLength(1);
|
|
415
|
+
expect(result.tokenUsage.subagentUsage![0].inputTokens).toBe(2000);
|
|
416
|
+
expect(result.tokenUsage.subagentUsage![0].outputTokens).toBe(800);
|
|
417
|
+
expect(result.tokenUsage.subagentUsage![0].total).toBe(2000 + 800);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('should parse SessionLog attribution', async () => {
|
|
421
|
+
const json = await loadFixture('sessionlog-session', 'metadata.json');
|
|
422
|
+
const result = parser.parseMetadata(json);
|
|
423
|
+
|
|
424
|
+
expect(result.attribution).toBeDefined();
|
|
425
|
+
expect(result.attribution!.agentLinesAdded).toBe(30);
|
|
426
|
+
expect(result.attribution!.humanAdditions).toBe(3);
|
|
427
|
+
expect(result.attribution!.humanModifications).toBe(1);
|
|
428
|
+
expect(result.attribution!.humanRemovals).toBe(0);
|
|
429
|
+
expect(result.attribution!.totalCommittedLines).toBe(34);
|
|
430
|
+
expect(result.attribution!.agentContribution).toBe(0.88);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it('should parse SessionLog transcript (uses "user" not "human")', async () => {
|
|
434
|
+
const jsonl = await loadFixture('sessionlog-session', 'full.jsonl');
|
|
435
|
+
const messages = parser.parseTranscript(jsonl);
|
|
436
|
+
|
|
437
|
+
expect(messages).toHaveLength(6);
|
|
438
|
+
expect(messages[0].role).toBe('user');
|
|
439
|
+
expect(messages[0].uuid).toBe('msg-sl-001');
|
|
440
|
+
expect(messages[1].role).toBe('assistant');
|
|
441
|
+
expect(messages[1].content).toHaveLength(2);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it('should parse SessionLog root checkpoint summary', async () => {
|
|
445
|
+
const json = await loadFixture('sessionlog-root-metadata.json');
|
|
446
|
+
const ref = parser.parseCheckpointSummary(json, 'c4/d5e6f7a8b9');
|
|
447
|
+
|
|
448
|
+
expect(ref.checkpointId).toBe('c4d5e6f7a8b9');
|
|
449
|
+
expect(ref.path).toBe('c4/d5e6f7a8b9');
|
|
450
|
+
expect(ref.sessionCount).toBe(1);
|
|
451
|
+
});
|
|
452
|
+
});
|
|
321
453
|
});
|
|
@@ -167,7 +167,7 @@ async function createFixtureRepo(): Promise<string> {
|
|
|
167
167
|
);
|
|
168
168
|
|
|
169
169
|
const orphanCommit = commitTree(tmpDir, rootTree, 'checkpoint data');
|
|
170
|
-
git(tmpDir, ['update-ref', 'refs/heads/
|
|
170
|
+
git(tmpDir, ['update-ref', 'refs/heads/sessionlog/checkpoints/v1', orphanCommit]);
|
|
171
171
|
|
|
172
172
|
return tmpDir;
|
|
173
173
|
}
|
|
@@ -3,6 +3,7 @@ import { SkillLibrary, createSkillLibrary } from '../../src/surfacing/skill-libr
|
|
|
3
3
|
import { PlaybookLibrary, createPlaybookLibrary } from '../../src/memory/playbook.js';
|
|
4
4
|
import type { Playbook } from '../../src/types/playbook.js';
|
|
5
5
|
import type { Task } from '../../src/types/task.js';
|
|
6
|
+
import { createSqlitePersistence } from '../../src/persistence/index.js';
|
|
6
7
|
import { mkdtemp, rm } from 'node:fs/promises';
|
|
7
8
|
import { join } from 'node:path';
|
|
8
9
|
import { tmpdir } from 'node:os';
|
|
@@ -11,10 +12,13 @@ describe('SkillLibrary', () => {
|
|
|
11
12
|
let tempDir: string;
|
|
12
13
|
let playbooks: PlaybookLibrary;
|
|
13
14
|
let skillLibrary: SkillLibrary;
|
|
15
|
+
let persistence: any;
|
|
14
16
|
|
|
15
17
|
beforeEach(async () => {
|
|
16
18
|
tempDir = await mkdtemp(join(tmpdir(), 'atlas-test-'));
|
|
17
|
-
|
|
19
|
+
persistence = createSqlitePersistence({ baseDir: tempDir });
|
|
20
|
+
await persistence.init();
|
|
21
|
+
playbooks = createPlaybookLibrary(persistence);
|
|
18
22
|
await playbooks.init();
|
|
19
23
|
skillLibrary = createSkillLibrary(playbooks, {
|
|
20
24
|
promotion: {
|
|
@@ -32,6 +36,7 @@ describe('SkillLibrary', () => {
|
|
|
32
36
|
|
|
33
37
|
afterEach(async () => {
|
|
34
38
|
await playbooks.close();
|
|
39
|
+
persistence.close();
|
|
35
40
|
await rm(tempDir, { recursive: true, force: true });
|
|
36
41
|
});
|
|
37
42
|
|
|
@@ -73,34 +73,34 @@ describe('SkillPublisher', () => {
|
|
|
73
73
|
expect(skill.status).toBe('active');
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
it('should map situations to
|
|
76
|
+
it('should map situations to description and instructions', () => {
|
|
77
77
|
const playbook = createSamplePlaybook();
|
|
78
78
|
const skill = convertPlaybookToSkill(playbook);
|
|
79
79
|
|
|
80
80
|
expect(skill.description).toBe('TypeScript import fails with TS2307');
|
|
81
|
-
expect(skill.
|
|
81
|
+
expect(skill.instructions).toContain('TypeScript import fails with TS2307');
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
it('should build
|
|
84
|
+
it('should build instructions from strategy, tactics, and steps', () => {
|
|
85
85
|
const playbook = createSamplePlaybook();
|
|
86
86
|
const skill = convertPlaybookToSkill(playbook);
|
|
87
87
|
|
|
88
|
-
expect(skill.
|
|
89
|
-
expect(skill.
|
|
90
|
-
expect(skill.
|
|
91
|
-
expect(skill.
|
|
92
|
-
expect(skill.
|
|
88
|
+
expect(skill.instructions).toContain('Add .js extension to ES module imports');
|
|
89
|
+
expect(skill.instructions).toContain('Tactics:');
|
|
90
|
+
expect(skill.instructions).toContain('Check for imports without file extensions');
|
|
91
|
+
expect(skill.instructions).toContain('Steps:');
|
|
92
|
+
expect(skill.instructions).toContain('Verify with tsc --noEmit');
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
it('should
|
|
95
|
+
it('should include verification and notes in instructions', () => {
|
|
96
96
|
const playbook = createSamplePlaybook();
|
|
97
97
|
const skill = convertPlaybookToSkill(playbook);
|
|
98
98
|
|
|
99
|
-
expect(skill.
|
|
100
|
-
expect(skill.
|
|
101
|
-
expect(skill.
|
|
102
|
-
expect(skill.
|
|
103
|
-
expect(skill.
|
|
99
|
+
expect(skill.instructions).toContain('Build passes');
|
|
100
|
+
expect(skill.instructions).toContain('Do NOT use when:');
|
|
101
|
+
expect(skill.instructions).toContain('Watch for:');
|
|
102
|
+
expect(skill.instructions).toContain('Refinements:');
|
|
103
|
+
expect(skill.instructions).toContain('Rollback:');
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
it('should compute metrics from evolution data', () => {
|
|
@@ -113,50 +113,20 @@ describe('SkillPublisher', () => {
|
|
|
113
113
|
expect(skill.metrics.lastUsed).toBeDefined();
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
it('should
|
|
116
|
+
it('should include code example in instructions', () => {
|
|
117
117
|
const playbook = createSamplePlaybook();
|
|
118
118
|
const skill = convertPlaybookToSkill(playbook);
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
expect(
|
|
122
|
-
expect(contextTriggers[0].value).toContain('TS2307');
|
|
123
|
-
|
|
124
|
-
const errorTriggers = skill.triggerConditions.filter(t => t.type === 'error');
|
|
125
|
-
expect(errorTriggers.some(t => t.value === 'TS2307')).toBe(true);
|
|
126
|
-
|
|
127
|
-
const keywordTriggers = skill.triggerConditions.filter(t => t.type === 'keyword');
|
|
128
|
-
expect(keywordTriggers.some(t => t.value === 'Cannot find module')).toBe(true);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should detect pattern-type triggers', () => {
|
|
132
|
-
const playbook = createSamplePlaybook({
|
|
133
|
-
applicability: {
|
|
134
|
-
situations: [],
|
|
135
|
-
triggers: ['*.config.ts', '/src/**/*.tsx'],
|
|
136
|
-
antiPatterns: [],
|
|
137
|
-
domains: [],
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
const skill = convertPlaybookToSkill(playbook);
|
|
141
|
-
|
|
142
|
-
const patternTriggers = skill.triggerConditions.filter(t => t.type === 'pattern');
|
|
143
|
-
expect(patternTriggers.length).toBe(2);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should map code example to examples array', () => {
|
|
147
|
-
const playbook = createSamplePlaybook();
|
|
148
|
-
const skill = convertPlaybookToSkill(playbook);
|
|
149
|
-
|
|
150
|
-
expect(skill.examples.length).toBe(1);
|
|
151
|
-
expect(skill.examples[0].after).toContain('utils.js');
|
|
120
|
+
expect(skill.instructions).toContain('utils.js');
|
|
121
|
+
expect(skill.instructions).toContain('Example');
|
|
152
122
|
});
|
|
153
123
|
|
|
154
|
-
it('should
|
|
124
|
+
it('should omit example section when no codeExample', () => {
|
|
155
125
|
const playbook = createSamplePlaybook();
|
|
156
126
|
playbook.guidance.codeExample = undefined;
|
|
157
127
|
const skill = convertPlaybookToSkill(playbook);
|
|
158
128
|
|
|
159
|
-
expect(skill.
|
|
129
|
+
expect(skill.instructions).not.toContain('## Example');
|
|
160
130
|
});
|
|
161
131
|
|
|
162
132
|
it('should set serving metadata with token estimate', () => {
|
|
@@ -195,11 +165,8 @@ describe('SkillPublisher', () => {
|
|
|
195
165
|
});
|
|
196
166
|
const skill = convertPlaybookToSkill(playbook);
|
|
197
167
|
|
|
198
|
-
expect(skill.problem).toBe('');
|
|
199
|
-
expect(skill.triggerConditions.length).toBe(0);
|
|
200
168
|
expect(skill.tags.length).toBe(0);
|
|
201
|
-
expect(skill.
|
|
202
|
-
expect(skill.verification).toContain('Verify the approach worked');
|
|
169
|
+
expect(skill.instructions).toContain('Verify the approach worked');
|
|
203
170
|
});
|
|
204
171
|
|
|
205
172
|
it('should be type-compatible with skill-tree Skill', () => {
|
|
@@ -252,7 +219,7 @@ describe('SkillPublisher', () => {
|
|
|
252
219
|
|
|
253
220
|
const skill = await storage.getSkill('update-1');
|
|
254
221
|
expect(skill!.version).toBe('2.0.0');
|
|
255
|
-
expect(skill!.
|
|
222
|
+
expect(skill!.instructions).toContain('Updated approach');
|
|
256
223
|
});
|
|
257
224
|
|
|
258
225
|
it('should track published IDs', async () => {
|
|
@@ -298,7 +265,7 @@ describe('SkillPublisher', () => {
|
|
|
298
265
|
|
|
299
266
|
const skill = await storage.getSkill('dep-1');
|
|
300
267
|
expect(skill!.status).toBe('deprecated');
|
|
301
|
-
expect(skill!.
|
|
268
|
+
expect(skill!.description).toContain('Deprecated: Low performance');
|
|
302
269
|
});
|
|
303
270
|
|
|
304
271
|
it('should return error for non-existent skill', async () => {
|
|
@@ -315,13 +282,12 @@ describe('SkillPublisher', () => {
|
|
|
315
282
|
await publisher.publishPlaybook(createSamplePlaybook({ id: 'notes-1' }));
|
|
316
283
|
|
|
317
284
|
const before = await storage.getSkill('notes-1');
|
|
318
|
-
expect(before!.
|
|
285
|
+
expect(before!.instructions).toContain('Do NOT use when:');
|
|
319
286
|
|
|
320
287
|
await publisher.deprecateSkill('notes-1', 'Superseded');
|
|
321
288
|
|
|
322
289
|
const after = await storage.getSkill('notes-1');
|
|
323
|
-
expect(after!.
|
|
324
|
-
expect(after!.notes).toContain('Deprecated: Superseded');
|
|
290
|
+
expect(after!.description).toContain('Deprecated: Superseded');
|
|
325
291
|
});
|
|
326
292
|
});
|
|
327
293
|
|
|
@@ -12,19 +12,10 @@ function createSampleSkill(overrides?: Partial<Skill>): Skill {
|
|
|
12
12
|
name: 'fix-ts-import',
|
|
13
13
|
version: '1.0.0',
|
|
14
14
|
description: 'Fix TypeScript import errors',
|
|
15
|
-
|
|
16
|
-
solution: 'Add .js extension to ES module imports',
|
|
17
|
-
verification: 'Build passes without TS2307 errors',
|
|
18
|
-
notes: undefined,
|
|
15
|
+
instructions: 'Add .js extension to ES module imports',
|
|
19
16
|
author: 'cognitive-core',
|
|
20
17
|
status: 'active',
|
|
21
18
|
tags: ['typescript', 'nodejs'],
|
|
22
|
-
triggerConditions: [
|
|
23
|
-
{ type: 'error', value: 'TS2307', description: 'Import error' },
|
|
24
|
-
],
|
|
25
|
-
examples: [
|
|
26
|
-
{ scenario: 'Missing .js extension', before: 'import { x } from "./util"', after: 'import { x } from "./util.js"' },
|
|
27
|
-
],
|
|
28
19
|
metrics: {
|
|
29
20
|
usageCount: 8,
|
|
30
21
|
successRate: 0.9,
|
|
@@ -44,7 +35,7 @@ function createSampleSkill(overrides?: Partial<Skill>): Skill {
|
|
|
44
35
|
createdAt: now,
|
|
45
36
|
updatedAt: now,
|
|
46
37
|
...overrides,
|
|
47
|
-
}
|
|
38
|
+
};
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
describe('SqliteStorageAdapter', () => {
|
|
@@ -77,7 +68,7 @@ describe('SqliteStorageAdapter', () => {
|
|
|
77
68
|
expect(retrieved!.id).toBe('skill-roundtrip');
|
|
78
69
|
expect(retrieved!.name).toBe('fix-ts-import');
|
|
79
70
|
expect(retrieved!.version).toBe('1.0.0');
|
|
80
|
-
expect(retrieved!.
|
|
71
|
+
expect(retrieved!.instructions).toBe('Add .js extension to ES module imports');
|
|
81
72
|
expect(retrieved!.status).toBe('active');
|
|
82
73
|
});
|
|
83
74
|
|
|
@@ -90,12 +81,12 @@ describe('SqliteStorageAdapter', () => {
|
|
|
90
81
|
const skill = createSampleSkill({ id: 'skill-update', version: '1.0.0' });
|
|
91
82
|
await adapter.saveSkill(skill);
|
|
92
83
|
|
|
93
|
-
const updated = createSampleSkill({ id: 'skill-update', version: '2.0.0',
|
|
84
|
+
const updated = createSampleSkill({ id: 'skill-update', version: '2.0.0', instructions: 'Updated solution' });
|
|
94
85
|
await adapter.saveSkill(updated);
|
|
95
86
|
|
|
96
87
|
const retrieved = await adapter.getSkill('skill-update');
|
|
97
88
|
expect(retrieved!.version).toBe('2.0.0');
|
|
98
|
-
expect(retrieved!.
|
|
89
|
+
expect(retrieved!.instructions).toBe('Updated solution');
|
|
99
90
|
});
|
|
100
91
|
|
|
101
92
|
it('listSkills() returns all skills', async () => {
|
|
@@ -135,13 +126,10 @@ describe('SqliteStorageAdapter', () => {
|
|
|
135
126
|
|
|
136
127
|
const retrieved = await adapter.getSkill('skill-json');
|
|
137
128
|
expect(retrieved!.tags).toEqual(['typescript', 'nodejs']);
|
|
138
|
-
expect(retrieved!.triggerConditions).toHaveLength(1);
|
|
139
|
-
expect(retrieved!.triggerConditions[0].type).toBe('error');
|
|
140
|
-
expect(retrieved!.examples).toHaveLength(1);
|
|
141
129
|
expect(retrieved!.metrics.usageCount).toBe(8);
|
|
142
130
|
expect(retrieved!.metrics.successRate).toBe(0.9);
|
|
143
|
-
expect(retrieved!.source
|
|
144
|
-
expect(retrieved!.serving
|
|
131
|
+
expect(retrieved!.source!.type).toBe('extracted');
|
|
132
|
+
expect(retrieved!.serving!.tokenEstimate).toBe(150);
|
|
145
133
|
});
|
|
146
134
|
|
|
147
135
|
it('Date fields survive round-trip', async () => {
|
|
@@ -173,7 +161,7 @@ describe('SqliteStorageAdapter', () => {
|
|
|
173
161
|
const skill1 = createSampleSkill({ id: 'skill-versioned', version: '1.0.0' });
|
|
174
162
|
await adapter.saveSkill(skill1);
|
|
175
163
|
|
|
176
|
-
const skill2 = createSampleSkill({ id: 'skill-versioned', version: '2.0.0',
|
|
164
|
+
const skill2 = createSampleSkill({ id: 'skill-versioned', version: '2.0.0', instructions: 'Updated' });
|
|
177
165
|
await adapter.saveSkill(skill2);
|
|
178
166
|
|
|
179
167
|
const history = await adapter.getVersionHistory('skill-versioned');
|
|
@@ -198,17 +186,17 @@ describe('SqliteStorageAdapter', () => {
|
|
|
198
186
|
|
|
199
187
|
it('searchSkills() finds by name', async () => {
|
|
200
188
|
await adapter.saveSkill(createSampleSkill({ id: 'skill-search', name: 'fix-import-error' }));
|
|
201
|
-
await adapter.saveSkill(createSampleSkill({ id: 'skill-other', name: 'refactor-tests',
|
|
189
|
+
await adapter.saveSkill(createSampleSkill({ id: 'skill-other', name: 'refactor-tests', instructions: 'Reorganize test files' }));
|
|
202
190
|
|
|
203
191
|
const results = await adapter.searchSkills('refactor');
|
|
204
192
|
expect(results).toHaveLength(1);
|
|
205
193
|
expect(results[0].id).toBe('skill-other');
|
|
206
194
|
});
|
|
207
195
|
|
|
208
|
-
it('searchSkills() finds by
|
|
196
|
+
it('searchSkills() finds by instructions content', async () => {
|
|
209
197
|
await adapter.saveSkill(createSampleSkill({
|
|
210
198
|
id: 'skill-solution',
|
|
211
|
-
|
|
199
|
+
instructions: 'Use jest.mock() to mock dependencies',
|
|
212
200
|
}));
|
|
213
201
|
|
|
214
202
|
const results = await adapter.searchSkills('jest.mock');
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { PartitionedStore } from '../../src/utils/partitioned-store.js';
|
|
3
|
+
import { mkdtemp, rm, writeFile, mkdir, readdir } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
|
|
7
|
+
interface TestItem {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
domain?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe('PartitionedStore', () => {
|
|
14
|
+
let tempDir: string;
|
|
15
|
+
let store: PartitionedStore<TestItem>;
|
|
16
|
+
|
|
17
|
+
beforeEach(async () => {
|
|
18
|
+
tempDir = await mkdtemp(join(tmpdir(), 'atlas-partitioned-test-'));
|
|
19
|
+
store = new PartitionedStore<TestItem>(
|
|
20
|
+
tempDir,
|
|
21
|
+
'items',
|
|
22
|
+
(item) => item.domain || undefined,
|
|
23
|
+
{ pretty: true },
|
|
24
|
+
);
|
|
25
|
+
await store.init();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
await store.close();
|
|
30
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('set and get', () => {
|
|
34
|
+
it('should store and retrieve items', async () => {
|
|
35
|
+
const item: TestItem = { id: 'a', name: 'alpha', domain: 'ts' };
|
|
36
|
+
store.set('a', item);
|
|
37
|
+
|
|
38
|
+
expect(store.get('a')).toEqual(item);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should route items to correct partition', async () => {
|
|
42
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
43
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
44
|
+
|
|
45
|
+
expect(store.valuesInPartition('ts')).toHaveLength(1);
|
|
46
|
+
expect(store.valuesInPartition('ts')[0].name).toBe('alpha');
|
|
47
|
+
expect(store.valuesInPartition('py')).toHaveLength(1);
|
|
48
|
+
expect(store.valuesInPartition('py')[0].name).toBe('beta');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should put items without domain in _global partition', async () => {
|
|
52
|
+
store.set('a', { id: 'a', name: 'alpha' }); // no domain
|
|
53
|
+
expect(store.valuesInPartition('_global')).toHaveLength(1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should return undefined for non-existent key', () => {
|
|
57
|
+
expect(store.get('missing')).toBeUndefined();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should move item to new partition when domain changes', () => {
|
|
61
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
62
|
+
expect(store.valuesInPartition('ts')).toHaveLength(1);
|
|
63
|
+
|
|
64
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'py' });
|
|
65
|
+
expect(store.valuesInPartition('ts')).toHaveLength(0);
|
|
66
|
+
expect(store.valuesInPartition('py')).toHaveLength(1);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('delete', () => {
|
|
71
|
+
it('should delete an item from its partition', () => {
|
|
72
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
73
|
+
expect(store.has('a')).toBe(true);
|
|
74
|
+
|
|
75
|
+
const deleted = store.delete('a');
|
|
76
|
+
expect(deleted).toBe(true);
|
|
77
|
+
expect(store.has('a')).toBe(false);
|
|
78
|
+
expect(store.size()).toBe(0);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should return false for non-existent key', () => {
|
|
82
|
+
expect(store.delete('missing')).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('has', () => {
|
|
87
|
+
it('should return true for existing items', () => {
|
|
88
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
89
|
+
expect(store.has('a')).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should return false for missing items', () => {
|
|
93
|
+
expect(store.has('missing')).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('values and valuesInPartition', () => {
|
|
98
|
+
it('should return all values across partitions', () => {
|
|
99
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
100
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
101
|
+
store.set('c', { id: 'c', name: 'gamma' }); // global
|
|
102
|
+
|
|
103
|
+
const all = store.values();
|
|
104
|
+
expect(all).toHaveLength(3);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should return only values in a specific partition', () => {
|
|
108
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
109
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'ts' });
|
|
110
|
+
store.set('c', { id: 'c', name: 'gamma', domain: 'py' });
|
|
111
|
+
|
|
112
|
+
expect(store.valuesInPartition('ts')).toHaveLength(2);
|
|
113
|
+
expect(store.valuesInPartition('py')).toHaveLength(1);
|
|
114
|
+
expect(store.valuesInPartition('unknown')).toHaveLength(0);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('keys, entries, size', () => {
|
|
119
|
+
it('should return all keys across partitions', () => {
|
|
120
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
121
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
122
|
+
|
|
123
|
+
const keys = store.keys();
|
|
124
|
+
expect(keys).toContain('a');
|
|
125
|
+
expect(keys).toContain('b');
|
|
126
|
+
expect(keys).toHaveLength(2);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should return correct size across partitions', () => {
|
|
130
|
+
expect(store.size()).toBe(0);
|
|
131
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
132
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
133
|
+
expect(store.size()).toBe(2);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('should return all entries', () => {
|
|
137
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
138
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
139
|
+
|
|
140
|
+
const entries = store.entries();
|
|
141
|
+
expect(entries).toHaveLength(2);
|
|
142
|
+
expect(entries.map(([k]) => k)).toContain('a');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('getPartitionNames', () => {
|
|
147
|
+
it('should list all partition names', () => {
|
|
148
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
149
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
150
|
+
|
|
151
|
+
const names = store.getPartitionNames();
|
|
152
|
+
expect(names).toContain('_global');
|
|
153
|
+
expect(names).toContain('ts');
|
|
154
|
+
expect(names).toContain('py');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('persistence', () => {
|
|
159
|
+
it('should persist data across reloads', async () => {
|
|
160
|
+
store.set('a', { id: 'a', name: 'alpha', domain: 'ts' });
|
|
161
|
+
store.set('b', { id: 'b', name: 'beta', domain: 'py' });
|
|
162
|
+
await store.flush();
|
|
163
|
+
await store.close();
|
|
164
|
+
|
|
165
|
+
// Create new store instance
|
|
166
|
+
const store2 = new PartitionedStore<TestItem>(
|
|
167
|
+
tempDir,
|
|
168
|
+
'items',
|
|
169
|
+
(item) => item.domain || undefined,
|
|
170
|
+
{ pretty: true },
|
|
171
|
+
);
|
|
172
|
+
await store2.init();
|
|
173
|
+
|
|
174
|
+
expect(store2.get('a')?.name).toBe('alpha');
|
|
175
|
+
expect(store2.get('b')?.name).toBe('beta');
|
|
176
|
+
expect(store2.size()).toBe(2);
|
|
177
|
+
|
|
178
|
+
await store2.close();
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('migration from flat layout', () => {
|
|
183
|
+
it('should auto-migrate flat JSON files into partition subdirectories', async () => {
|
|
184
|
+
await store.close();
|
|
185
|
+
|
|
186
|
+
// Create a flat layout manually (files directly in collection dir)
|
|
187
|
+
const collectionDir = join(tempDir, 'migrated');
|
|
188
|
+
await mkdir(collectionDir, { recursive: true });
|
|
189
|
+
|
|
190
|
+
await writeFile(
|
|
191
|
+
join(collectionDir, 'item1.json'),
|
|
192
|
+
JSON.stringify({ id: 'item1', name: 'first', domain: 'ts' }),
|
|
193
|
+
);
|
|
194
|
+
await writeFile(
|
|
195
|
+
join(collectionDir, 'item2.json'),
|
|
196
|
+
JSON.stringify({ id: 'item2', name: 'second', domain: 'py' }),
|
|
197
|
+
);
|
|
198
|
+
await writeFile(
|
|
199
|
+
join(collectionDir, 'item3.json'),
|
|
200
|
+
JSON.stringify({ id: 'item3', name: 'third' }), // no domain → _global
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
// Create PartitionedStore on top of it
|
|
204
|
+
const migratingStore = new PartitionedStore<TestItem>(
|
|
205
|
+
tempDir,
|
|
206
|
+
'migrated',
|
|
207
|
+
(item) => item.domain || undefined,
|
|
208
|
+
{ pretty: true },
|
|
209
|
+
);
|
|
210
|
+
await migratingStore.init();
|
|
211
|
+
|
|
212
|
+
// Flat files should have been migrated into subdirs
|
|
213
|
+
expect(migratingStore.get('item1')?.name).toBe('first');
|
|
214
|
+
expect(migratingStore.get('item2')?.name).toBe('second');
|
|
215
|
+
expect(migratingStore.get('item3')?.name).toBe('third');
|
|
216
|
+
|
|
217
|
+
expect(migratingStore.valuesInPartition('ts')).toHaveLength(1);
|
|
218
|
+
expect(migratingStore.valuesInPartition('py')).toHaveLength(1);
|
|
219
|
+
expect(migratingStore.valuesInPartition('_global')).toHaveLength(1);
|
|
220
|
+
|
|
221
|
+
// Verify subdirectories were created on disk
|
|
222
|
+
const entries = await readdir(collectionDir);
|
|
223
|
+
expect(entries).toContain('ts');
|
|
224
|
+
expect(entries).toContain('py');
|
|
225
|
+
expect(entries).toContain('_global');
|
|
226
|
+
|
|
227
|
+
await migratingStore.close();
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|