cognitive-core 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +111 -2
- package/.sessionlog/settings.json +4 -0
- 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 +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -6
- 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 +311 -0
- package/dist/learning/unified-pipeline.d.ts.map +1 -0
- package/dist/learning/unified-pipeline.js +844 -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 +43 -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/efficacy-toolkit.d.ts +164 -0
- package/dist/workspace/efficacy-toolkit.d.ts.map +1 -0
- package/dist/workspace/efficacy-toolkit.js +281 -0
- package/dist/workspace/efficacy-toolkit.js.map +1 -0
- package/dist/workspace/index.d.ts +2 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/index.js.map +1 -1
- 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/templates/index.d.ts +3 -0
- package/dist/workspace/templates/index.d.ts.map +1 -1
- package/dist/workspace/templates/index.js +6 -0
- package/dist/workspace/templates/index.js.map +1 -1
- package/dist/workspace/templates/playbook-decay-detection.d.ts +46 -0
- package/dist/workspace/templates/playbook-decay-detection.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-decay-detection.js +197 -0
- package/dist/workspace/templates/playbook-decay-detection.js.map +1 -0
- package/dist/workspace/templates/playbook-efficacy-audit.d.ts +46 -0
- package/dist/workspace/templates/playbook-efficacy-audit.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-efficacy-audit.js +160 -0
- package/dist/workspace/templates/playbook-efficacy-audit.js.map +1 -0
- package/dist/workspace/templates/playbook-lifecycle-review.d.ts +51 -0
- package/dist/workspace/templates/playbook-lifecycle-review.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-lifecycle-review.js +187 -0
- package/dist/workspace/templates/playbook-lifecycle-review.js.map +1 -0
- 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 +12 -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 +136 -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 +66 -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 +1191 -0
- package/src/memory/candidate-retrieval.ts +72 -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/efficacy-toolkit.ts +496 -0
- package/src/workspace/index.ts +29 -0
- package/src/workspace/runner.ts +3 -3
- package/src/workspace/templates/index.ts +24 -0
- package/src/workspace/templates/playbook-decay-detection.ts +272 -0
- package/src/workspace/templates/playbook-efficacy-audit.ts +246 -0
- package/src/workspace/templates/playbook-lifecycle-review.ts +274 -0
- 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/fixtures/behavioral-trajectories.ts +210 -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/pipeline-data-correctness.test.ts +794 -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/meta-learner.test.ts +418 -0
- package/tests/learning/pipeline-memory-updates.test.ts +721 -0
- package/tests/learning/reflexion-generator.test.ts +411 -0
- package/tests/learning/trajectory-sources.test.ts +12 -4
- package/tests/learning/unified-pipeline-efficacy.test.ts +232 -0
- package/tests/learning/unified-pipeline.test.ts +322 -0
- package/tests/mcp/playbook-server.test.ts +6 -1
- package/tests/memory/candidate-retrieval.test.ts +167 -0
- 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/meta.test.ts +399 -0
- 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/evaluator.test.ts +257 -0
- 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/search/verification-runner.test.ts +357 -0
- 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/error-classifier.test.ts +149 -0
- package/tests/utils/partitioned-store.test.ts +230 -0
- package/tests/utils/trajectory-helpers.test.ts +163 -0
- package/tests/workspace/efficacy-toolkit.test.ts +404 -0
- package/tests/workspace/full-flow.test.ts +10 -4
- package/tests/workspace/runner.test.ts +10 -4
- package/tests/workspace/templates/playbook-efficacy.test.ts +377 -0
- 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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
VerificationRunner,
|
|
4
|
+
createVerificationRunner,
|
|
5
|
+
TestRunners,
|
|
6
|
+
type CommandVerificationConfig,
|
|
7
|
+
} from '../../src/search/verification-runner.js';
|
|
8
|
+
import { createTrajectory } from '../../src/types/trajectory.js';
|
|
9
|
+
import { createTask } from '../../src/types/task.js';
|
|
10
|
+
import { createStep } from '../../src/types/step.js';
|
|
11
|
+
import { successOutcome } from '../../src/types/outcome.js';
|
|
12
|
+
import type { Trajectory } from '../../src/types/trajectory.js';
|
|
13
|
+
import type { Task } from '../../src/types/task.js';
|
|
14
|
+
|
|
15
|
+
function makeTask(): Task {
|
|
16
|
+
return createTask({
|
|
17
|
+
domain: 'test-domain',
|
|
18
|
+
description: 'test task',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function makeTrajectory(): Trajectory {
|
|
23
|
+
return createTrajectory({
|
|
24
|
+
task: makeTask(),
|
|
25
|
+
steps: [createStep({ action: 'echo hello', observation: 'hello' })],
|
|
26
|
+
outcome: successOutcome('hello world'),
|
|
27
|
+
agentId: 'agent',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('VerificationRunner', () => {
|
|
32
|
+
let runner: VerificationRunner;
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
runner = createVerificationRunner({ cwd: '/tmp', timeout: 5000 });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('runCommand', () => {
|
|
39
|
+
it('should execute a simple command and capture stdout', async () => {
|
|
40
|
+
const result = await runner.runCommand('echo hello', {});
|
|
41
|
+
expect(result.stdout.trim()).toBe('hello');
|
|
42
|
+
expect(result.exitCode).toBe(0);
|
|
43
|
+
expect(result.timedOut).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should capture stderr', async () => {
|
|
47
|
+
const result = await runner.runCommand('echo error >&2', {});
|
|
48
|
+
expect(result.stderr.trim()).toBe('error');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should return non-zero exit code for failing commands', async () => {
|
|
52
|
+
const result = await runner.runCommand('exit 42', {});
|
|
53
|
+
expect(result.exitCode).toBe(42);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should handle command timeout', { timeout: 20000 }, async () => {
|
|
57
|
+
// Use a bash loop that responds to SIGTERM better than plain sleep
|
|
58
|
+
const result = await runner.runCommand('while true; do sleep 0.1; done', { timeout: 500 });
|
|
59
|
+
expect(result.timedOut).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should handle command not found', async () => {
|
|
63
|
+
const result = await runner.runCommand('nonexistent_command_xyz_12345', {});
|
|
64
|
+
expect(result.exitCode).not.toBe(0);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should pass environment variables', async () => {
|
|
68
|
+
const result = await runner.runCommand('echo $MY_TEST_VAR', {
|
|
69
|
+
env: { MY_TEST_VAR: 'hello123' },
|
|
70
|
+
});
|
|
71
|
+
expect(result.stdout.trim()).toBe('hello123');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should use specified working directory', async () => {
|
|
75
|
+
const result = await runner.runCommand('pwd', { cwd: '/tmp' });
|
|
76
|
+
expect(result.stdout.trim()).toMatch(/\/tmp/);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('runCommandSync', () => {
|
|
81
|
+
it('should execute command synchronously', () => {
|
|
82
|
+
const result = runner.runCommandSync('echo sync-test');
|
|
83
|
+
expect(result.stdout.trim()).toBe('sync-test');
|
|
84
|
+
expect(result.exitCode).toBe(0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should handle sync command failure', () => {
|
|
88
|
+
const result = runner.runCommandSync('exit 1');
|
|
89
|
+
expect(result.exitCode).toBe(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should detect sync command failure on timeout', () => {
|
|
93
|
+
const result = runner.runCommandSync('sleep 30', { timeout: 500 });
|
|
94
|
+
// execSync throws on timeout; killed + SIGTERM detection may vary by platform
|
|
95
|
+
// The important thing is that the command does not succeed
|
|
96
|
+
expect(result.exitCode).not.toBe(0);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('createVerifier', () => {
|
|
101
|
+
it('should create verifier that passes on exit code 0', async () => {
|
|
102
|
+
const config: CommandVerificationConfig = {
|
|
103
|
+
command: 'echo "all tests pass"',
|
|
104
|
+
timeout: 5000,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const verifier = runner.createVerifier(config);
|
|
108
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
109
|
+
|
|
110
|
+
expect(result.passed).toBe(true);
|
|
111
|
+
expect(result.confidence).toBe(0.7); // No pattern/extractor → 0.7
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should create verifier that fails on non-zero exit', async () => {
|
|
115
|
+
const config: CommandVerificationConfig = {
|
|
116
|
+
command: 'exit 1',
|
|
117
|
+
timeout: 5000,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const verifier = runner.createVerifier(config);
|
|
121
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
122
|
+
|
|
123
|
+
expect(result.passed).toBe(false);
|
|
124
|
+
expect(result.issues!.length).toBeGreaterThan(0);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should check success pattern when provided', async () => {
|
|
128
|
+
const config: CommandVerificationConfig = {
|
|
129
|
+
command: 'echo "Tests: 5 passed, 0 failed"',
|
|
130
|
+
successPattern: /\d+ passed, 0 failed/,
|
|
131
|
+
timeout: 5000,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const verifier = runner.createVerifier(config);
|
|
135
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
136
|
+
|
|
137
|
+
expect(result.passed).toBe(true);
|
|
138
|
+
expect(result.confidence).toBe(0.9); // Has successPattern → 0.9
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should check failure pattern when provided', async () => {
|
|
142
|
+
const config: CommandVerificationConfig = {
|
|
143
|
+
command: 'echo "FAIL test_login"',
|
|
144
|
+
failurePattern: /FAIL/,
|
|
145
|
+
successOnZeroExit: false,
|
|
146
|
+
timeout: 5000,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const verifier = runner.createVerifier(config);
|
|
150
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
151
|
+
|
|
152
|
+
expect(result.passed).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should use custom issue extractor', async () => {
|
|
156
|
+
const config: CommandVerificationConfig = {
|
|
157
|
+
command: 'echo "ERROR: missing return"',
|
|
158
|
+
timeout: 5000,
|
|
159
|
+
successOnZeroExit: false,
|
|
160
|
+
issueExtractor: (output) => {
|
|
161
|
+
const match = output.match(/ERROR:\s*(.+)/);
|
|
162
|
+
return match
|
|
163
|
+
? [{ type: 'error' as const, description: match[1], severity: 'critical' as const }]
|
|
164
|
+
: [];
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const verifier = runner.createVerifier(config);
|
|
169
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
170
|
+
|
|
171
|
+
expect(result.confidence).toBe(0.9); // Has issueExtractor
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should handle timeout in verifier', { timeout: 20000 }, async () => {
|
|
175
|
+
const config: CommandVerificationConfig = {
|
|
176
|
+
command: 'while true; do sleep 0.1; done',
|
|
177
|
+
timeout: 500,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const verifier = runner.createVerifier(config);
|
|
181
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
182
|
+
|
|
183
|
+
expect(result.passed).toBe(false);
|
|
184
|
+
expect(result.confidence).toBe(0.5); // Timeout → 0.5
|
|
185
|
+
expect(result.details).toContain('timed out');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should interpolate {{taskId}} and {{trajectoryId}} in command', async () => {
|
|
189
|
+
const config: CommandVerificationConfig = {
|
|
190
|
+
command: 'echo "task={{taskId}} traj={{trajectoryId}}"',
|
|
191
|
+
timeout: 5000,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const trajectory = makeTrajectory();
|
|
195
|
+
const task = makeTask();
|
|
196
|
+
const verifier = runner.createVerifier(config);
|
|
197
|
+
const result = await verifier(trajectory, task);
|
|
198
|
+
|
|
199
|
+
expect(result.details).toContain(`task=${task.id}`);
|
|
200
|
+
expect(result.details).toContain(`traj=${trajectory.id}`);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
describe('createCompositeVerifier', () => {
|
|
205
|
+
it('should pass when all verifiers pass', async () => {
|
|
206
|
+
const composite = runner.createCompositeVerifier([
|
|
207
|
+
{ command: 'echo pass1', timeout: 5000 },
|
|
208
|
+
{ command: 'echo pass2', timeout: 5000 },
|
|
209
|
+
]);
|
|
210
|
+
|
|
211
|
+
const result = await composite(makeTrajectory(), makeTask());
|
|
212
|
+
expect(result.passed).toBe(true);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should fail when any verifier fails', async () => {
|
|
216
|
+
const composite = runner.createCompositeVerifier([
|
|
217
|
+
{ command: 'echo pass', timeout: 5000 },
|
|
218
|
+
{ command: 'exit 1', timeout: 5000 },
|
|
219
|
+
]);
|
|
220
|
+
|
|
221
|
+
const result = await composite(makeTrajectory(), makeTask());
|
|
222
|
+
expect(result.passed).toBe(false);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should aggregate issues from all verifiers', async () => {
|
|
226
|
+
const composite = runner.createCompositeVerifier([
|
|
227
|
+
{ command: 'exit 1', timeout: 5000 },
|
|
228
|
+
{ command: 'exit 2', timeout: 5000 },
|
|
229
|
+
]);
|
|
230
|
+
|
|
231
|
+
const result = await composite(makeTrajectory(), makeTask());
|
|
232
|
+
expect(result.issues!.length).toBeGreaterThanOrEqual(1);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('should fail fast on critical issues', async () => {
|
|
236
|
+
let secondRan = false;
|
|
237
|
+
const configs: CommandVerificationConfig[] = [
|
|
238
|
+
{
|
|
239
|
+
command: 'exit 1',
|
|
240
|
+
timeout: 5000,
|
|
241
|
+
issueExtractor: () => [
|
|
242
|
+
{ type: 'error', description: 'critical failure', severity: 'critical' },
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
command: 'echo should-not-run',
|
|
247
|
+
timeout: 5000,
|
|
248
|
+
issueExtractor: () => {
|
|
249
|
+
secondRan = true;
|
|
250
|
+
return [];
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
const composite = runner.createCompositeVerifier(configs);
|
|
256
|
+
await composite(makeTrajectory(), makeTask());
|
|
257
|
+
|
|
258
|
+
// Second verifier should not have run due to fail-fast
|
|
259
|
+
expect(secondRan).toBe(false);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should average confidence across verifiers', async () => {
|
|
263
|
+
const composite = runner.createCompositeVerifier([
|
|
264
|
+
{ command: 'echo pass', timeout: 5000 }, // confidence 0.7
|
|
265
|
+
{ command: 'echo pass', timeout: 5000 }, // confidence 0.7
|
|
266
|
+
]);
|
|
267
|
+
|
|
268
|
+
const result = await composite(makeTrajectory(), makeTask());
|
|
269
|
+
expect(result.confidence).toBeCloseTo(0.7, 1);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe('TestRunners presets', () => {
|
|
274
|
+
it('should create vitest configuration', () => {
|
|
275
|
+
const config = TestRunners.vitest('tests/foo.test.ts');
|
|
276
|
+
expect(config.command).toContain('vitest');
|
|
277
|
+
expect(config.command).toContain('tests/foo.test.ts');
|
|
278
|
+
expect(config.timeout).toBe(60000);
|
|
279
|
+
expect(config.issueExtractor).toBeDefined();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('should create jest configuration', () => {
|
|
283
|
+
const config = TestRunners.jest();
|
|
284
|
+
expect(config.command).toContain('jest');
|
|
285
|
+
expect(config.issueExtractor).toBeDefined();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('should create typescript configuration', () => {
|
|
289
|
+
const config = TestRunners.typescript();
|
|
290
|
+
expect(config.command).toContain('tsc --noEmit');
|
|
291
|
+
expect(config.issueExtractor).toBeDefined();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('should create eslint configuration', () => {
|
|
295
|
+
const config = TestRunners.eslint('src/');
|
|
296
|
+
expect(config.command).toContain('eslint');
|
|
297
|
+
expect(config.command).toContain('src/');
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('should create pytest configuration', () => {
|
|
301
|
+
const config = TestRunners.pytest();
|
|
302
|
+
expect(config.command).toContain('pytest');
|
|
303
|
+
expect(config.failurePattern).toBeDefined();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('should create go test configuration', () => {
|
|
307
|
+
const config = TestRunners.goTest();
|
|
308
|
+
expect(config.command).toContain('go test');
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('should create cargo test configuration', () => {
|
|
312
|
+
const config = TestRunners.cargoTest();
|
|
313
|
+
expect(config.command).toContain('cargo test');
|
|
314
|
+
expect(config.timeout).toBe(120000);
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
describe('default issue extraction', () => {
|
|
319
|
+
it('should extract error messages from output', async () => {
|
|
320
|
+
const config: CommandVerificationConfig = {
|
|
321
|
+
command: 'echo "Error: cannot read file" && exit 1',
|
|
322
|
+
timeout: 5000,
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const verifier = runner.createVerifier(config);
|
|
326
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
327
|
+
|
|
328
|
+
expect(result.issues!.length).toBeGreaterThan(0);
|
|
329
|
+
expect(result.issues![0].description).toContain('cannot read file');
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('should extract fail messages from output', async () => {
|
|
333
|
+
const config: CommandVerificationConfig = {
|
|
334
|
+
command: 'echo "Fail: test_login" && exit 1',
|
|
335
|
+
timeout: 5000,
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const verifier = runner.createVerifier(config);
|
|
339
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
340
|
+
|
|
341
|
+
expect(result.issues!.length).toBeGreaterThan(0);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it('should generate generic issue when no pattern matches', async () => {
|
|
345
|
+
const config: CommandVerificationConfig = {
|
|
346
|
+
command: 'exit 99',
|
|
347
|
+
timeout: 5000,
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const verifier = runner.createVerifier(config);
|
|
351
|
+
const result = await verifier(makeTrajectory(), makeTask());
|
|
352
|
+
|
|
353
|
+
expect(result.issues!.length).toBeGreaterThan(0);
|
|
354
|
+
expect(result.issues![0].description).toContain('exit code 99');
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cliVersion": "opentasks-sessionlog",
|
|
3
|
+
"checkpointID": "c4d5e6f7a8b9",
|
|
4
|
+
"strategy": "manual-commit",
|
|
5
|
+
"branch": "main",
|
|
6
|
+
"checkpointsCount": 3,
|
|
7
|
+
"filesTouched": ["src/api.ts", "tests/api.test.ts"],
|
|
8
|
+
"sessions": [
|
|
9
|
+
{
|
|
10
|
+
"metadata": "1/metadata.json",
|
|
11
|
+
"transcript": "1/full.jsonl",
|
|
12
|
+
"context": "1/context.md",
|
|
13
|
+
"prompt": "1/prompt.txt"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{"type":"user","uuid":"msg-sl-001","message":{"content":"Add input validation to the API endpoint using Zod"}}
|
|
2
|
+
{"type":"assistant","uuid":"msg-sl-002","message":{"content":[{"type":"text","text":"I'll examine the API endpoint first."},{"type":"tool_use","id":"tool-sl-001","name":"Read","input":{"file_path":"/src/api.ts"}}]}}
|
|
3
|
+
{"type":"user","uuid":"msg-sl-003","message":{"content":[{"type":"tool_result","tool_use_id":"tool-sl-001","content":"export function handler(req, res) {\n const body = req.body;\n // TODO: validate\n res.json({ ok: true });\n}"}]}}
|
|
4
|
+
{"type":"assistant","uuid":"msg-sl-004","message":{"content":[{"type":"text","text":"I'll add Zod validation."},{"type":"tool_use","id":"tool-sl-002","name":"Edit","input":{"file_path":"/src/api.ts","old_string":"const body = req.body;","new_string":"const body = schema.parse(req.body);"}}]}}
|
|
5
|
+
{"type":"user","uuid":"msg-sl-005","message":{"content":[{"type":"tool_result","tool_use_id":"tool-sl-002","content":"File edited successfully"}]}}
|
|
6
|
+
{"type":"assistant","uuid":"msg-sl-006","message":{"content":[{"type":"text","text":"Validation added. The endpoint now validates input using the Zod schema before processing."}]}}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cliVersion": "opentasks-sessionlog",
|
|
3
|
+
"checkpointID": "c4d5e6f7a8b9",
|
|
4
|
+
"sessionID": "2026-02-15-aabbccdd-1122-3344-5566-778899aabbcc",
|
|
5
|
+
"strategy": "manual-commit",
|
|
6
|
+
"createdAt": "2026-02-15T09:00:00Z",
|
|
7
|
+
"branch": "main",
|
|
8
|
+
"filesTouched": ["src/api.ts", "tests/api.test.ts"],
|
|
9
|
+
"agent": "Claude Code",
|
|
10
|
+
"turnID": "turn-001",
|
|
11
|
+
"isTask": false,
|
|
12
|
+
"checkpointTranscriptStart": 0,
|
|
13
|
+
"tokenUsage": {
|
|
14
|
+
"inputTokens": 20000,
|
|
15
|
+
"cacheCreationTokens": 3000,
|
|
16
|
+
"cacheReadTokens": 6000,
|
|
17
|
+
"outputTokens": 4000,
|
|
18
|
+
"apiCallCount": 10,
|
|
19
|
+
"subagentTokens": {
|
|
20
|
+
"inputTokens": 2000,
|
|
21
|
+
"cacheCreationTokens": 0,
|
|
22
|
+
"cacheReadTokens": 0,
|
|
23
|
+
"outputTokens": 800,
|
|
24
|
+
"apiCallCount": 3
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"summary": {
|
|
28
|
+
"intent": "Add validation to the API endpoint",
|
|
29
|
+
"outcome": "Added input validation with Zod schema",
|
|
30
|
+
"learnings": {
|
|
31
|
+
"repo": ["API routes use Zod for validation"],
|
|
32
|
+
"code": [
|
|
33
|
+
{
|
|
34
|
+
"path": "src/api.ts",
|
|
35
|
+
"line": 15,
|
|
36
|
+
"finding": "Zod schema must be defined before route handler"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"workflow": ["Run API tests with --reporter=verbose flag"]
|
|
40
|
+
},
|
|
41
|
+
"friction": ["Had to look up Zod coercion syntax"],
|
|
42
|
+
"openItems": ["Add validation for the PUT endpoint too"]
|
|
43
|
+
},
|
|
44
|
+
"initialAttribution": {
|
|
45
|
+
"calculatedAt": "2026-02-15T09:30:00Z",
|
|
46
|
+
"agentLines": 30,
|
|
47
|
+
"humanAdded": 3,
|
|
48
|
+
"humanModified": 1,
|
|
49
|
+
"humanRemoved": 0,
|
|
50
|
+
"totalCommitted": 34,
|
|
51
|
+
"agentPercentage": 0.88
|
|
52
|
+
},
|
|
53
|
+
"tasks": {},
|
|
54
|
+
"skillsUsed": []
|
|
55
|
+
}
|
|
@@ -3,7 +3,7 @@ import { mkdtemp, rm, readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { execFileSync } from 'node:child_process';
|
|
6
|
-
import {
|
|
6
|
+
import { CheckpointGitReader } from '../../src/session-bank/git-reader.js';
|
|
7
7
|
|
|
8
8
|
const FIXTURES = join(import.meta.dirname, 'fixtures');
|
|
9
9
|
|
|
@@ -126,14 +126,14 @@ async function createFixtureRepo(): Promise<string> {
|
|
|
126
126
|
const orphanCommit = commitTree(tmpDir, rootTree, 'checkpoint data');
|
|
127
127
|
git(tmpDir, [
|
|
128
128
|
'update-ref',
|
|
129
|
-
'refs/heads/
|
|
129
|
+
'refs/heads/sessionlog/checkpoints/v1',
|
|
130
130
|
orphanCommit,
|
|
131
131
|
]);
|
|
132
132
|
|
|
133
133
|
return tmpDir;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
describe('
|
|
136
|
+
describe('CheckpointGitReader', () => {
|
|
137
137
|
let tmpDir: string;
|
|
138
138
|
|
|
139
139
|
beforeEach(async () => {
|
|
@@ -145,12 +145,12 @@ describe('EntireGitReader', () => {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
it('should detect that the orphan branch exists', async () => {
|
|
148
|
-
const reader = new
|
|
148
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
149
149
|
expect(await reader.branchExists()).toBe(true);
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
it('should return false for non-existent branch', async () => {
|
|
153
|
-
const reader = new
|
|
153
|
+
const reader = new CheckpointGitReader({
|
|
154
154
|
repoPath: tmpDir,
|
|
155
155
|
branch: 'nonexistent/branch',
|
|
156
156
|
});
|
|
@@ -158,7 +158,7 @@ describe('EntireGitReader', () => {
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
it('should list checkpoint paths', async () => {
|
|
161
|
-
const reader = new
|
|
161
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
162
162
|
const checkpoints = await reader.listCheckpoints();
|
|
163
163
|
|
|
164
164
|
expect(checkpoints).toHaveLength(1);
|
|
@@ -166,7 +166,7 @@ describe('EntireGitReader', () => {
|
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
it('should list session indices', async () => {
|
|
169
|
-
const reader = new
|
|
169
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
170
170
|
const sessions = await reader.listSessions('a3/b2c4d5e6f7');
|
|
171
171
|
|
|
172
172
|
expect(sessions).toHaveLength(1);
|
|
@@ -174,7 +174,7 @@ describe('EntireGitReader', () => {
|
|
|
174
174
|
});
|
|
175
175
|
|
|
176
176
|
it('should read a file from the orphan branch', async () => {
|
|
177
|
-
const reader = new
|
|
177
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
178
178
|
const content = await reader.readFile(
|
|
179
179
|
'a3/b2c4d5e6f7/0/metadata.json',
|
|
180
180
|
);
|
|
@@ -185,7 +185,7 @@ describe('EntireGitReader', () => {
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
it('should batch-read multiple files', async () => {
|
|
188
|
-
const reader = new
|
|
188
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
189
189
|
const files = await reader.readFiles([
|
|
190
190
|
'a3/b2c4d5e6f7/0/metadata.json',
|
|
191
191
|
'a3/b2c4d5e6f7/0/full.jsonl',
|
|
@@ -199,13 +199,13 @@ describe('EntireGitReader', () => {
|
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
it('should return null for missing files', async () => {
|
|
202
|
-
const reader = new
|
|
202
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
203
203
|
const content = await reader.readFileOrNull('does/not/exist');
|
|
204
204
|
expect(content).toBeNull();
|
|
205
205
|
});
|
|
206
206
|
|
|
207
207
|
it('should get the orphan branch HEAD SHA', async () => {
|
|
208
|
-
const reader = new
|
|
208
|
+
const reader = new CheckpointGitReader({ repoPath: tmpDir });
|
|
209
209
|
const sha = await reader.getBranchHead();
|
|
210
210
|
|
|
211
211
|
expect(sha).toBeDefined();
|
|
@@ -213,7 +213,7 @@ describe('EntireGitReader', () => {
|
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
it('should return null for HEAD of non-existent branch', async () => {
|
|
216
|
-
const reader = new
|
|
216
|
+
const reader = new CheckpointGitReader({
|
|
217
217
|
repoPath: tmpDir,
|
|
218
218
|
branch: 'nope',
|
|
219
219
|
});
|
|
@@ -222,7 +222,7 @@ describe('EntireGitReader', () => {
|
|
|
222
222
|
});
|
|
223
223
|
|
|
224
224
|
it('should return empty checkpoints for non-existent branch', async () => {
|
|
225
|
-
const reader = new
|
|
225
|
+
const reader = new CheckpointGitReader({
|
|
226
226
|
repoPath: tmpDir,
|
|
227
227
|
branch: 'nope',
|
|
228
228
|
});
|