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,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Partitioned Store
|
|
3
|
+
*
|
|
4
|
+
* Domain-partitioned wrapper around JsonStore. Items are routed to partition
|
|
5
|
+
* subdirectories based on a caller-supplied key function. Queries can target
|
|
6
|
+
* a single partition (fast) or scan all partitions (full).
|
|
7
|
+
*
|
|
8
|
+
* On first init with existing flat data (no partition subdirs), items are
|
|
9
|
+
* auto-migrated into partition directories. This is a one-time operation.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { JsonStore, ensureDir, loadJson, listFiles } from './storage.js';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { existsSync } from 'node:fs';
|
|
15
|
+
import { rename } from 'node:fs/promises';
|
|
16
|
+
|
|
17
|
+
const GLOBAL_PARTITION = '_global';
|
|
18
|
+
|
|
19
|
+
export interface PartitionedStoreOptions {
|
|
20
|
+
autoSaveInterval?: number;
|
|
21
|
+
pretty?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Domain-partitioned key-value store backed by JSON files
|
|
26
|
+
*/
|
|
27
|
+
export class PartitionedStore<T> {
|
|
28
|
+
private partitions: Map<string, JsonStore<T>> = new Map();
|
|
29
|
+
private keyIndex: Map<string, string> = new Map(); // key → partition name
|
|
30
|
+
private baseDir: string;
|
|
31
|
+
private collection: string;
|
|
32
|
+
private partitionKeyFn: (item: T) => string | undefined;
|
|
33
|
+
private options: PartitionedStoreOptions;
|
|
34
|
+
private initialized = false;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
baseDir: string,
|
|
38
|
+
collection: string,
|
|
39
|
+
partitionKeyFn: (item: T) => string | undefined,
|
|
40
|
+
options?: PartitionedStoreOptions,
|
|
41
|
+
) {
|
|
42
|
+
this.baseDir = baseDir;
|
|
43
|
+
this.collection = collection;
|
|
44
|
+
this.partitionKeyFn = partitionKeyFn;
|
|
45
|
+
this.options = options ?? {};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Initialize — discover existing partitions, auto-migrate flat data if needed
|
|
50
|
+
*/
|
|
51
|
+
async init(): Promise<void> {
|
|
52
|
+
if (this.initialized) return;
|
|
53
|
+
|
|
54
|
+
const collectionDir = join(this.baseDir, this.collection);
|
|
55
|
+
await ensureDir(collectionDir);
|
|
56
|
+
|
|
57
|
+
// Check if we need to migrate from flat layout
|
|
58
|
+
await this.maybeMigrate(collectionDir);
|
|
59
|
+
|
|
60
|
+
// Discover partition subdirectories
|
|
61
|
+
const entries = await listFiles(collectionDir);
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
const entryPath = join(collectionDir, entry);
|
|
64
|
+
if (existsSync(entryPath) && !entry.endsWith('.json')) {
|
|
65
|
+
// It's a directory — treat as partition
|
|
66
|
+
await this.getOrCreatePartition(entry);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Ensure global partition exists
|
|
71
|
+
await this.getOrCreatePartition(GLOBAL_PARTITION);
|
|
72
|
+
|
|
73
|
+
this.initialized = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get an item by key. If partition is known, searches only that partition.
|
|
78
|
+
*/
|
|
79
|
+
get(key: string, partition?: string): T | undefined {
|
|
80
|
+
if (partition) {
|
|
81
|
+
return this.partitions.get(partition)?.get(key);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Check index first
|
|
85
|
+
const knownPartition = this.keyIndex.get(key);
|
|
86
|
+
if (knownPartition) {
|
|
87
|
+
return this.partitions.get(knownPartition)?.get(key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Fall back to scanning all partitions
|
|
91
|
+
for (const store of this.partitions.values()) {
|
|
92
|
+
const item = store.get(key);
|
|
93
|
+
if (item !== undefined) return item;
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Set an item — auto-routes to the correct partition based on partitionKeyFn
|
|
100
|
+
*/
|
|
101
|
+
set(key: string, value: T): void {
|
|
102
|
+
const partitionName = this.partitionKeyFn(value) || GLOBAL_PARTITION;
|
|
103
|
+
|
|
104
|
+
// If the item was in a different partition, remove it from the old one
|
|
105
|
+
const oldPartition = this.keyIndex.get(key);
|
|
106
|
+
if (oldPartition && oldPartition !== partitionName) {
|
|
107
|
+
this.partitions.get(oldPartition)?.delete(key);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const store = this.partitions.get(partitionName);
|
|
111
|
+
if (store) {
|
|
112
|
+
store.set(key, value);
|
|
113
|
+
this.keyIndex.set(key, partitionName);
|
|
114
|
+
} else {
|
|
115
|
+
// Partition doesn't exist yet — create it synchronously by using the map
|
|
116
|
+
// (the directory will be created on flush/save)
|
|
117
|
+
const newStore = new JsonStore<T>(
|
|
118
|
+
join(this.baseDir, this.collection),
|
|
119
|
+
partitionName,
|
|
120
|
+
this.options,
|
|
121
|
+
);
|
|
122
|
+
this.partitions.set(partitionName, newStore);
|
|
123
|
+
newStore.set(key, value);
|
|
124
|
+
this.keyIndex.set(key, partitionName);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Delete an item by key
|
|
130
|
+
*/
|
|
131
|
+
delete(key: string): boolean {
|
|
132
|
+
const partition = this.keyIndex.get(key);
|
|
133
|
+
if (partition) {
|
|
134
|
+
this.keyIndex.delete(key);
|
|
135
|
+
return this.partitions.get(partition)?.delete(key) ?? false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Fall back to scanning
|
|
139
|
+
for (const store of this.partitions.values()) {
|
|
140
|
+
if (store.has(key)) {
|
|
141
|
+
store.delete(key);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Check if a key exists
|
|
150
|
+
*/
|
|
151
|
+
has(key: string): boolean {
|
|
152
|
+
if (this.keyIndex.has(key)) return true;
|
|
153
|
+
for (const store of this.partitions.values()) {
|
|
154
|
+
if (store.has(key)) return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get all values within a single partition
|
|
161
|
+
*/
|
|
162
|
+
valuesInPartition(partition: string): T[] {
|
|
163
|
+
return this.partitions.get(partition)?.values() ?? [];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get all values across all partitions
|
|
168
|
+
*/
|
|
169
|
+
values(): T[] {
|
|
170
|
+
const result: T[] = [];
|
|
171
|
+
for (const store of this.partitions.values()) {
|
|
172
|
+
result.push(...store.values());
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get all keys across all partitions
|
|
179
|
+
*/
|
|
180
|
+
keys(): string[] {
|
|
181
|
+
const result: string[] = [];
|
|
182
|
+
for (const store of this.partitions.values()) {
|
|
183
|
+
result.push(...store.keys());
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Get total item count across all partitions
|
|
190
|
+
*/
|
|
191
|
+
size(): number {
|
|
192
|
+
let total = 0;
|
|
193
|
+
for (const store of this.partitions.values()) {
|
|
194
|
+
total += store.size();
|
|
195
|
+
}
|
|
196
|
+
return total;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Get names of all partitions
|
|
201
|
+
*/
|
|
202
|
+
getPartitionNames(): string[] {
|
|
203
|
+
return Array.from(this.partitions.keys());
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Get all entries across all partitions
|
|
208
|
+
*/
|
|
209
|
+
entries(): Array<[string, T]> {
|
|
210
|
+
const result: Array<[string, T]> = [];
|
|
211
|
+
for (const store of this.partitions.values()) {
|
|
212
|
+
result.push(...store.entries());
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Flush all dirty partitions to disk
|
|
219
|
+
*/
|
|
220
|
+
async flush(): Promise<void> {
|
|
221
|
+
for (const store of this.partitions.values()) {
|
|
222
|
+
await store.flush();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Save a single item immediately
|
|
228
|
+
*/
|
|
229
|
+
async save(key: string): Promise<void> {
|
|
230
|
+
const partition = this.keyIndex.get(key);
|
|
231
|
+
if (partition) {
|
|
232
|
+
await this.partitions.get(partition)?.save(key);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Close all partitions
|
|
238
|
+
*/
|
|
239
|
+
async close(): Promise<void> {
|
|
240
|
+
for (const store of this.partitions.values()) {
|
|
241
|
+
await store.close();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Get or create a partition's JsonStore, loading its data
|
|
247
|
+
*/
|
|
248
|
+
private async getOrCreatePartition(name: string): Promise<JsonStore<T>> {
|
|
249
|
+
let store = this.partitions.get(name);
|
|
250
|
+
if (store) return store;
|
|
251
|
+
|
|
252
|
+
store = new JsonStore<T>(
|
|
253
|
+
join(this.baseDir, this.collection),
|
|
254
|
+
name,
|
|
255
|
+
this.options,
|
|
256
|
+
);
|
|
257
|
+
await store.init();
|
|
258
|
+
this.partitions.set(name, store);
|
|
259
|
+
|
|
260
|
+
// Build key index for this partition
|
|
261
|
+
for (const key of store.keys()) {
|
|
262
|
+
this.keyIndex.set(key, name);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return store;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Migrate flat layout (files directly in collection dir) to partitioned layout.
|
|
270
|
+
* Only runs if flat JSON files exist alongside no partition directories.
|
|
271
|
+
*/
|
|
272
|
+
private async maybeMigrate(collectionDir: string): Promise<void> {
|
|
273
|
+
const entries = await listFiles(collectionDir);
|
|
274
|
+
const jsonFiles = entries.filter(
|
|
275
|
+
(f) => f.endsWith('.json') && !f.startsWith('_'),
|
|
276
|
+
);
|
|
277
|
+
const subdirs = entries.filter((f) => {
|
|
278
|
+
const p = join(collectionDir, f);
|
|
279
|
+
return existsSync(p) && !f.endsWith('.json');
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Only migrate if there are JSON files and no subdirectories yet
|
|
283
|
+
if (jsonFiles.length === 0 || subdirs.length > 0) return;
|
|
284
|
+
|
|
285
|
+
// Load each file, determine its partition, move it
|
|
286
|
+
for (const file of jsonFiles) {
|
|
287
|
+
const filePath = join(collectionDir, file);
|
|
288
|
+
const data = await loadJson<T>(filePath);
|
|
289
|
+
if (!data) continue;
|
|
290
|
+
|
|
291
|
+
const partitionName = this.partitionKeyFn(data) || GLOBAL_PARTITION;
|
|
292
|
+
const partitionDir = join(collectionDir, partitionName);
|
|
293
|
+
await ensureDir(partitionDir);
|
|
294
|
+
|
|
295
|
+
const destPath = join(partitionDir, file);
|
|
296
|
+
await rename(filePath, destPath);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared trajectory analysis helpers.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates action repetition detection and tool name extraction
|
|
5
|
+
* previously duplicated across analyzer.ts, reflexion-generator.ts,
|
|
6
|
+
* and meta-learner.ts.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Step } from '../types/index.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An action that was repeated beyond the threshold.
|
|
13
|
+
*/
|
|
14
|
+
export interface RepeatedAction {
|
|
15
|
+
/** The action string (or normalized prefix) */
|
|
16
|
+
action: string;
|
|
17
|
+
/** How many times it occurred */
|
|
18
|
+
count: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Detect repeated actions in a list of steps.
|
|
23
|
+
*
|
|
24
|
+
* @param steps - The trajectory steps to analyze
|
|
25
|
+
* @param threshold - Minimum count to flag as repeated (default: 3)
|
|
26
|
+
* @param normalize - Optional normalization function for action strings.
|
|
27
|
+
* Defaults to lowercasing + truncating to 50 chars.
|
|
28
|
+
* @returns Array of repeated actions exceeding the threshold.
|
|
29
|
+
*/
|
|
30
|
+
export function detectRepeatedActions(
|
|
31
|
+
steps: ReadonlyArray<Pick<Step, 'action'>>,
|
|
32
|
+
threshold = 3,
|
|
33
|
+
normalize?: (action: string) => string,
|
|
34
|
+
): RepeatedAction[] {
|
|
35
|
+
const norm = normalize ?? ((a: string) => a.toLowerCase().slice(0, 50));
|
|
36
|
+
const counts = new Map<string, number>();
|
|
37
|
+
|
|
38
|
+
for (const step of steps) {
|
|
39
|
+
if (!step.action) continue;
|
|
40
|
+
const key = norm(step.action);
|
|
41
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const repeated: RepeatedAction[] = [];
|
|
45
|
+
for (const [action, count] of counts) {
|
|
46
|
+
if (count >= threshold) {
|
|
47
|
+
repeated.push({ action, count });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return repeated;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Extract tool names from trajectory steps.
|
|
56
|
+
*
|
|
57
|
+
* Handles both formats:
|
|
58
|
+
* - "ToolName args..."
|
|
59
|
+
* - "tool_use: ToolName args..."
|
|
60
|
+
*
|
|
61
|
+
* @param steps - The trajectory steps to analyze
|
|
62
|
+
* @returns Set of unique tool names found.
|
|
63
|
+
*/
|
|
64
|
+
export function extractToolNames(
|
|
65
|
+
steps: ReadonlyArray<Pick<Step, 'action'>>,
|
|
66
|
+
): Set<string> {
|
|
67
|
+
const tools = new Set<string>();
|
|
68
|
+
|
|
69
|
+
for (const step of steps) {
|
|
70
|
+
if (!step.action) continue;
|
|
71
|
+
// Matches "tool_use: ToolName ..." or "ToolName ..."
|
|
72
|
+
const match = step.action.match(/^(?:tool_use:\s*)?(\w+(?:[A-Z]\w*)*)/);
|
|
73
|
+
if (match) {
|
|
74
|
+
tools.add(match[1]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return tools;
|
|
79
|
+
}
|