cognitive-core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +88 -0
- package/.claude/settings.local.json +11 -0
- package/.entire/settings.json +4 -0
- package/CLAUDE.md +233 -0
- package/README.md +841 -255
- package/dist/atlas.d.ts +150 -12
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +391 -31
- 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/provider.d.ts.map +1 -1
- package/dist/embeddings/provider.js +6 -3
- package/dist/embeddings/provider.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 +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -8
- 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 +11 -2
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +20 -3
- 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/knowledge-extractor.d.ts +56 -0
- package/dist/learning/knowledge-extractor.d.ts.map +1 -0
- package/dist/learning/knowledge-extractor.js +336 -0
- package/dist/learning/knowledge-extractor.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 +7 -0
- package/dist/learning/meta-learner.d.ts.map +1 -1
- package/dist/learning/meta-learner.js +47 -21
- package/dist/learning/meta-learner.js.map +1 -1
- package/dist/learning/pipeline.d.ts +55 -4
- package/dist/learning/pipeline.d.ts.map +1 -1
- package/dist/learning/pipeline.js +134 -16
- 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/team-ingester.d.ts +152 -0
- package/dist/learning/team-ingester.d.ts.map +1 -0
- package/dist/learning/team-ingester.js +333 -0
- package/dist/learning/team-ingester.js.map +1 -0
- package/dist/learning/team-meta-learner.d.ts +50 -0
- package/dist/learning/team-meta-learner.d.ts.map +1 -0
- package/dist/learning/team-meta-learner.js +417 -0
- package/dist/learning/team-meta-learner.js.map +1 -0
- package/dist/learning/team-pipeline.d.ts +76 -0
- package/dist/learning/team-pipeline.d.ts.map +1 -0
- package/dist/learning/team-pipeline.js +266 -0
- package/dist/learning/team-pipeline.js.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts +41 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.js +330 -0
- package/dist/learning/trajectory-sources/dataclaw.js.map +1 -0
- package/dist/learning/trajectory-sources/entire.d.ts +31 -0
- package/dist/learning/trajectory-sources/entire.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/entire.js +189 -0
- package/dist/learning/trajectory-sources/entire.js.map +1 -0
- package/dist/learning/trajectory-sources/file.d.ts +23 -0
- package/dist/learning/trajectory-sources/file.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/file.js +101 -0
- package/dist/learning/trajectory-sources/file.js.map +1 -0
- package/dist/learning/trajectory-sources/huggingface.d.ts +36 -0
- package/dist/learning/trajectory-sources/huggingface.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/huggingface.js +157 -0
- package/dist/learning/trajectory-sources/huggingface.js.map +1 -0
- package/dist/learning/trajectory-sources/in-memory.d.ts +21 -0
- package/dist/learning/trajectory-sources/in-memory.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/in-memory.js +43 -0
- package/dist/learning/trajectory-sources/in-memory.js.map +1 -0
- package/dist/learning/trajectory-sources/index.d.ts +7 -0
- package/dist/learning/trajectory-sources/index.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/index.js +7 -0
- package/dist/learning/trajectory-sources/index.js.map +1 -0
- package/dist/learning/trajectory-sources/pipeline.d.ts +24 -0
- package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/pipeline.js +47 -0
- package/dist/learning/trajectory-sources/pipeline.js.map +1 -0
- package/dist/learning/unified-pipeline.d.ts +281 -0
- package/dist/learning/unified-pipeline.d.ts.map +1 -0
- package/dist/learning/unified-pipeline.js +637 -0
- package/dist/learning/unified-pipeline.js.map +1 -0
- package/dist/memory/candidate-retrieval.d.ts +43 -0
- package/dist/memory/candidate-retrieval.d.ts.map +1 -0
- package/dist/memory/candidate-retrieval.js +41 -0
- package/dist/memory/candidate-retrieval.js.map +1 -0
- package/dist/memory/causal-store.d.ts +97 -0
- package/dist/memory/causal-store.d.ts.map +1 -0
- package/dist/memory/causal-store.js +209 -0
- package/dist/memory/causal-store.js.map +1 -0
- package/dist/memory/coherence.d.ts +71 -0
- package/dist/memory/coherence.d.ts.map +1 -0
- package/dist/memory/coherence.js +176 -0
- package/dist/memory/coherence.js.map +1 -0
- package/dist/memory/experience.d.ts +39 -6
- package/dist/memory/experience.d.ts.map +1 -1
- package/dist/memory/experience.js +193 -49
- package/dist/memory/experience.js.map +1 -1
- package/dist/memory/graph-layers/base.d.ts +29 -0
- package/dist/memory/graph-layers/base.d.ts.map +1 -0
- package/dist/memory/graph-layers/base.js +143 -0
- package/dist/memory/graph-layers/base.js.map +1 -0
- package/dist/memory/graph-layers/causal.d.ts +14 -0
- package/dist/memory/graph-layers/causal.d.ts.map +1 -0
- package/dist/memory/graph-layers/causal.js +14 -0
- package/dist/memory/graph-layers/causal.js.map +1 -0
- package/dist/memory/graph-layers/entity.d.ts +14 -0
- package/dist/memory/graph-layers/entity.d.ts.map +1 -0
- package/dist/memory/graph-layers/entity.js +14 -0
- package/dist/memory/graph-layers/entity.js.map +1 -0
- package/dist/memory/graph-layers/index.d.ts +6 -0
- package/dist/memory/graph-layers/index.d.ts.map +1 -0
- package/dist/memory/graph-layers/index.js +6 -0
- package/dist/memory/graph-layers/index.js.map +1 -0
- package/dist/memory/graph-layers/semantic.d.ts +14 -0
- package/dist/memory/graph-layers/semantic.d.ts.map +1 -0
- package/dist/memory/graph-layers/semantic.js +14 -0
- package/dist/memory/graph-layers/semantic.js.map +1 -0
- package/dist/memory/graph-layers/temporal.d.ts +14 -0
- package/dist/memory/graph-layers/temporal.d.ts.map +1 -0
- package/dist/memory/graph-layers/temporal.js +14 -0
- package/dist/memory/graph-layers/temporal.js.map +1 -0
- package/dist/memory/index.d.ts +15 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +22 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/knowledge-bank.d.ts +234 -0
- package/dist/memory/knowledge-bank.d.ts.map +1 -0
- package/dist/memory/knowledge-bank.js +1048 -0
- package/dist/memory/knowledge-bank.js.map +1 -0
- package/dist/memory/knowledge-defrag.d.ts +49 -0
- package/dist/memory/knowledge-defrag.d.ts.map +1 -0
- package/dist/memory/knowledge-defrag.js +257 -0
- package/dist/memory/knowledge-defrag.js.map +1 -0
- package/dist/memory/knowledge-graph.d.ts +41 -0
- package/dist/memory/knowledge-graph.d.ts.map +1 -0
- package/dist/memory/knowledge-graph.js +273 -0
- package/dist/memory/knowledge-graph.js.map +1 -0
- 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/search-provider.d.ts +31 -0
- package/dist/memory/search-provider.d.ts.map +1 -0
- package/dist/memory/search-provider.js +2 -0
- package/dist/memory/search-provider.js.map +1 -0
- package/dist/memory/search-providers/index.d.ts +3 -0
- package/dist/memory/search-providers/index.d.ts.map +1 -0
- package/dist/memory/search-providers/index.js +3 -0
- package/dist/memory/search-providers/index.js.map +1 -0
- package/dist/memory/search-providers/minimem.d.ts +43 -0
- package/dist/memory/search-providers/minimem.d.ts.map +1 -0
- package/dist/memory/search-providers/minimem.js +56 -0
- package/dist/memory/search-providers/minimem.js.map +1 -0
- package/dist/memory/search-providers/text-similarity.d.ts +15 -0
- package/dist/memory/search-providers/text-similarity.d.ts.map +1 -0
- package/dist/memory/search-providers/text-similarity.js +21 -0
- package/dist/memory/search-providers/text-similarity.js.map +1 -0
- package/dist/memory/skill-exporter.d.ts +75 -0
- package/dist/memory/skill-exporter.d.ts.map +1 -0
- package/dist/memory/skill-exporter.js +248 -0
- package/dist/memory/skill-exporter.js.map +1 -0
- package/dist/memory/system.d.ts +20 -3
- package/dist/memory/system.d.ts.map +1 -1
- package/dist/memory/system.js +61 -11
- package/dist/memory/system.js.map +1 -1
- package/dist/memory/team-experience.d.ts +298 -0
- package/dist/memory/team-experience.d.ts.map +1 -0
- package/dist/memory/team-experience.js +355 -0
- package/dist/memory/team-experience.js.map +1 -0
- 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/backends/acp-protocol.d.ts +49 -0
- package/dist/runtime/backends/acp-protocol.d.ts.map +1 -0
- package/dist/runtime/backends/acp-protocol.js +166 -0
- package/dist/runtime/backends/acp-protocol.js.map +1 -0
- package/dist/runtime/backends/acp.d.ts +26 -26
- package/dist/runtime/backends/acp.d.ts.map +1 -1
- package/dist/runtime/backends/acp.js +32 -156
- package/dist/runtime/backends/acp.js.map +1 -1
- package/dist/runtime/backends/index.d.ts +3 -1
- package/dist/runtime/backends/index.d.ts.map +1 -1
- package/dist/runtime/backends/index.js +3 -1
- package/dist/runtime/backends/index.js.map +1 -1
- package/dist/runtime/backends/macro-agent.d.ts +104 -0
- package/dist/runtime/backends/macro-agent.d.ts.map +1 -0
- package/dist/runtime/backends/macro-agent.js +107 -0
- package/dist/runtime/backends/macro-agent.js.map +1 -0
- package/dist/runtime/compute-provider.d.ts +87 -0
- package/dist/runtime/compute-provider.d.ts.map +1 -0
- package/dist/runtime/compute-provider.js +87 -0
- package/dist/runtime/compute-provider.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/runtime/index.d.ts +3 -2
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/manager.d.ts +37 -4
- package/dist/runtime/manager.d.ts.map +1 -1
- package/dist/runtime/manager.js +139 -20
- package/dist/runtime/manager.js.map +1 -1
- package/dist/runtime/types.d.ts +38 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/search/evaluator.d.ts +7 -0
- package/dist/search/evaluator.d.ts.map +1 -1
- package/dist/search/evaluator.js +24 -4
- package/dist/search/evaluator.js.map +1 -1
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +4 -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/refinement-loop.d.ts +17 -0
- package/dist/search/refinement-loop.d.ts.map +1 -1
- package/dist/search/refinement-loop.js +77 -6
- package/dist/search/refinement-loop.js.map +1 -1
- package/dist/search/refinement-types.d.ts +2 -2
- 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/search/team-router.d.ts +91 -0
- package/dist/search/team-router.d.ts.map +1 -0
- package/dist/search/team-router.js +315 -0
- package/dist/search/team-router.js.map +1 -0
- package/dist/session-bank/git-reader.d.ts +44 -0
- package/dist/session-bank/git-reader.d.ts.map +1 -0
- package/dist/session-bank/git-reader.js +172 -0
- package/dist/session-bank/git-reader.js.map +1 -0
- package/dist/session-bank/index.d.ts +5 -0
- package/dist/session-bank/index.d.ts.map +1 -0
- package/dist/session-bank/index.js +4 -0
- package/dist/session-bank/index.js.map +1 -0
- package/dist/session-bank/parser.d.ts +50 -0
- package/dist/session-bank/parser.d.ts.map +1 -0
- package/dist/session-bank/parser.js +338 -0
- package/dist/session-bank/parser.js.map +1 -0
- package/dist/session-bank/session-bank.d.ts +40 -0
- package/dist/session-bank/session-bank.d.ts.map +1 -0
- package/dist/session-bank/session-bank.js +347 -0
- package/dist/session-bank/session-bank.js.map +1 -0
- package/dist/session-bank/types.d.ts +132 -0
- package/dist/session-bank/types.d.ts.map +1 -0
- package/dist/session-bank/types.js +7 -0
- package/dist/session-bank/types.js.map +1 -0
- package/dist/surfacing/index.d.ts +4 -0
- package/dist/surfacing/index.d.ts.map +1 -1
- package/dist/surfacing/index.js +3 -0
- package/dist/surfacing/index.js.map +1 -1
- package/dist/surfacing/publisher.d.ts +22 -0
- package/dist/surfacing/publisher.d.ts.map +1 -0
- package/dist/surfacing/publisher.js +9 -0
- package/dist/surfacing/publisher.js.map +1 -0
- package/dist/surfacing/skill-library.d.ts +12 -0
- package/dist/surfacing/skill-library.d.ts.map +1 -1
- package/dist/surfacing/skill-library.js +26 -0
- package/dist/surfacing/skill-library.js.map +1 -1
- package/dist/surfacing/skill-publisher.d.ts +43 -0
- package/dist/surfacing/skill-publisher.d.ts.map +1 -0
- package/dist/surfacing/skill-publisher.js +169 -0
- package/dist/surfacing/skill-publisher.js.map +1 -0
- package/dist/surfacing/sqlite-storage-adapter.d.ts +42 -0
- package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -0
- package/dist/surfacing/sqlite-storage-adapter.js +199 -0
- package/dist/surfacing/sqlite-storage-adapter.js.map +1 -0
- package/dist/surfacing/team-skill-library.d.ts +180 -0
- package/dist/surfacing/team-skill-library.d.ts.map +1 -0
- package/dist/surfacing/team-skill-library.js +384 -0
- package/dist/surfacing/team-skill-library.js.map +1 -0
- package/dist/types/config.d.ts +1318 -44
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +243 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/dataclaw.d.ts +286 -0
- package/dist/types/dataclaw.d.ts.map +1 -0
- package/dist/types/dataclaw.js +84 -0
- package/dist/types/dataclaw.js.map +1 -0
- package/dist/types/index.d.ts +9 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +13 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/knowledge-graph.d.ts +148 -0
- package/dist/types/knowledge-graph.d.ts.map +1 -0
- package/dist/types/knowledge-graph.js +40 -0
- package/dist/types/knowledge-graph.js.map +1 -0
- package/dist/types/knowledge.d.ts +280 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +191 -0
- package/dist/types/knowledge.js.map +1 -0
- 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/types/team-meta.d.ts +160 -0
- package/dist/types/team-meta.d.ts.map +1 -0
- package/dist/types/team-meta.js +42 -0
- package/dist/types/team-meta.js.map +1 -0
- package/dist/types/team-playbook.d.ts +276 -0
- package/dist/types/team-playbook.d.ts.map +1 -0
- package/dist/types/team-playbook.js +85 -0
- package/dist/types/team-playbook.js.map +1 -0
- package/dist/types/team-trajectory.d.ts +305 -0
- package/dist/types/team-trajectory.d.ts.map +1 -0
- package/dist/types/team-trajectory.js +304 -0
- package/dist/types/team-trajectory.js.map +1 -0
- package/dist/types/trajectory-source.d.ts +39 -0
- package/dist/types/trajectory-source.d.ts.map +1 -0
- package/dist/types/trajectory-source.js +2 -0
- package/dist/types/trajectory-source.js.map +1 -0
- 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/frontmatter.d.ts +34 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +93 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -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/index.d.ts +6 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +11 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/runner.d.ts +49 -0
- package/dist/workspace/runner.d.ts.map +1 -0
- package/dist/workspace/runner.js +219 -0
- package/dist/workspace/runner.js.map +1 -0
- package/dist/workspace/skill-converter.d.ts +18 -0
- package/dist/workspace/skill-converter.d.ts.map +1 -0
- package/dist/workspace/skill-converter.js +257 -0
- package/dist/workspace/skill-converter.js.map +1 -0
- package/dist/workspace/templates/index.d.ts +11 -0
- package/dist/workspace/templates/index.d.ts.map +1 -0
- package/dist/workspace/templates/index.js +21 -0
- package/dist/workspace/templates/index.js.map +1 -0
- package/dist/workspace/templates/knowledge-defrag.d.ts +25 -0
- package/dist/workspace/templates/knowledge-defrag.d.ts.map +1 -0
- package/dist/workspace/templates/knowledge-defrag.js +154 -0
- package/dist/workspace/templates/knowledge-defrag.js.map +1 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts +25 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/knowledge-extraction.js +246 -0
- package/dist/workspace/templates/knowledge-extraction.js.map +1 -0
- package/dist/workspace/templates/meta-reflection.d.ts +47 -0
- package/dist/workspace/templates/meta-reflection.d.ts.map +1 -0
- package/dist/workspace/templates/meta-reflection.js +135 -0
- package/dist/workspace/templates/meta-reflection.js.map +1 -0
- package/dist/workspace/templates/playbook-extraction.d.ts +20 -0
- package/dist/workspace/templates/playbook-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-extraction.js +189 -0
- package/dist/workspace/templates/playbook-extraction.js.map +1 -0
- package/dist/workspace/templates/refinement-analysis.d.ts +31 -0
- package/dist/workspace/templates/refinement-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/refinement-analysis.js +107 -0
- package/dist/workspace/templates/refinement-analysis.js.map +1 -0
- package/dist/workspace/templates/solution-evaluation.d.ts +21 -0
- package/dist/workspace/templates/solution-evaluation.d.ts.map +1 -0
- package/dist/workspace/templates/solution-evaluation.js +131 -0
- package/dist/workspace/templates/solution-evaluation.js.map +1 -0
- package/dist/workspace/templates/team-playbook-extraction.d.ts +44 -0
- package/dist/workspace/templates/team-playbook-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/team-playbook-extraction.js +497 -0
- package/dist/workspace/templates/team-playbook-extraction.js.map +1 -0
- package/dist/workspace/templates/team-trajectory-analysis.d.ts +19 -0
- package/dist/workspace/templates/team-trajectory-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/team-trajectory-analysis.js +442 -0
- package/dist/workspace/templates/team-trajectory-analysis.js.map +1 -0
- package/dist/workspace/templates/trajectory-analysis.d.ts +19 -0
- package/dist/workspace/templates/trajectory-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/trajectory-analysis.js +170 -0
- package/dist/workspace/templates/trajectory-analysis.js.map +1 -0
- package/dist/workspace/templates/usage-inference.d.ts +19 -0
- package/dist/workspace/templates/usage-inference.d.ts.map +1 -0
- package/dist/workspace/templates/usage-inference.js +125 -0
- package/dist/workspace/templates/usage-inference.js.map +1 -0
- package/dist/workspace/types.d.ts +152 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/dist/workspace/types.js +17 -0
- package/dist/workspace/types.js.map +1 -0
- package/docs/DESIGN-agentic-workspace.md +2057 -0
- package/docs/DESIGN-semantic-memory-knowledge-bank.md +1789 -0
- package/docs/DESIGN-session-bank.md +1134 -0
- package/docs/DESIGN-team-extraction-pipeline.md +1369 -0
- package/docs/PROPOSAL-team-aware-learning.md +1080 -0
- package/docs/RESEARCH-semantic-memory-knowledge-structures.md +517 -0
- package/docs/RESEARCH-team-trajectory-learning.md +553 -0
- package/gaps.md +204 -0
- package/package.json +27 -7
- package/references/agent-workspace/CLAUDE.md +74 -0
- package/references/agent-workspace/README.md +587 -0
- package/references/agent-workspace/media/banner.png +0 -0
- package/references/agent-workspace/package-lock.json +2061 -0
- package/references/agent-workspace/package.json +54 -0
- package/references/agent-workspace/src/handle.ts +122 -0
- package/references/agent-workspace/src/index.ts +32 -0
- package/references/agent-workspace/src/manager.ts +102 -0
- package/references/agent-workspace/src/readers/json.ts +71 -0
- package/references/agent-workspace/src/readers/markdown.ts +37 -0
- package/references/agent-workspace/src/readers/raw.ts +27 -0
- package/references/agent-workspace/src/types.ts +68 -0
- package/references/agent-workspace/src/validation.ts +93 -0
- package/references/agent-workspace/src/writers/json.ts +17 -0
- package/references/agent-workspace/src/writers/markdown.ts +27 -0
- package/references/agent-workspace/src/writers/raw.ts +22 -0
- package/references/agent-workspace/tests/errors.test.ts +652 -0
- package/references/agent-workspace/tests/handle.test.ts +144 -0
- package/references/agent-workspace/tests/manager.test.ts +124 -0
- package/references/agent-workspace/tests/readers.test.ts +205 -0
- package/references/agent-workspace/tests/validation.test.ts +196 -0
- package/references/agent-workspace/tests/writers.test.ts +108 -0
- package/references/agent-workspace/tsconfig.json +20 -0
- package/references/agent-workspace/tsup.config.ts +9 -0
- package/references/minimem/.claude/settings.json +7 -0
- package/references/minimem/.sudocode/issues.jsonl +18 -0
- package/references/minimem/.sudocode/specs.jsonl +1 -0
- package/references/minimem/CLAUDE.md +310 -0
- package/references/minimem/README.md +556 -0
- package/references/minimem/claude-plugin/.claude-plugin/plugin.json +10 -0
- package/references/minimem/claude-plugin/.mcp.json +7 -0
- package/references/minimem/claude-plugin/README.md +158 -0
- package/references/minimem/claude-plugin/commands/recall.md +47 -0
- package/references/minimem/claude-plugin/commands/remember.md +41 -0
- package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +272 -0
- package/references/minimem/claude-plugin/hooks/hooks.json +27 -0
- package/references/minimem/claude-plugin/hooks/session-end.sh +86 -0
- package/references/minimem/claude-plugin/hooks/session-start.sh +85 -0
- package/references/minimem/claude-plugin/skills/memory/SKILL.md +108 -0
- package/references/minimem/package-lock.json +5373 -0
- package/references/minimem/package.json +60 -0
- package/references/minimem/scripts/postbuild.js +35 -0
- package/references/minimem/src/__tests__/edge-cases.test.ts +371 -0
- package/references/minimem/src/__tests__/errors.test.ts +265 -0
- package/references/minimem/src/__tests__/helpers.ts +199 -0
- package/references/minimem/src/__tests__/internal.test.ts +407 -0
- package/references/minimem/src/__tests__/knowledge.test.ts +287 -0
- package/references/minimem/src/__tests__/minimem.integration.test.ts +1127 -0
- package/references/minimem/src/__tests__/session.test.ts +190 -0
- package/references/minimem/src/cli/__tests__/commands.test.ts +759 -0
- package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +141 -0
- package/references/minimem/src/cli/commands/append.ts +76 -0
- package/references/minimem/src/cli/commands/config.ts +262 -0
- package/references/minimem/src/cli/commands/conflicts.ts +413 -0
- package/references/minimem/src/cli/commands/daemon.ts +169 -0
- package/references/minimem/src/cli/commands/index.ts +12 -0
- package/references/minimem/src/cli/commands/init.ts +88 -0
- package/references/minimem/src/cli/commands/mcp.ts +177 -0
- package/references/minimem/src/cli/commands/push-pull.ts +213 -0
- package/references/minimem/src/cli/commands/search.ts +158 -0
- package/references/minimem/src/cli/commands/status.ts +84 -0
- package/references/minimem/src/cli/commands/sync-init.ts +290 -0
- package/references/minimem/src/cli/commands/sync.ts +70 -0
- package/references/minimem/src/cli/commands/upsert.ts +197 -0
- package/references/minimem/src/cli/config.ts +584 -0
- package/references/minimem/src/cli/index.ts +264 -0
- package/references/minimem/src/cli/shared.ts +161 -0
- package/references/minimem/src/cli/sync/__tests__/central.test.ts +152 -0
- package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +209 -0
- package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +118 -0
- package/references/minimem/src/cli/sync/__tests__/detection.test.ts +207 -0
- package/references/minimem/src/cli/sync/__tests__/integration.test.ts +476 -0
- package/references/minimem/src/cli/sync/__tests__/registry.test.ts +363 -0
- package/references/minimem/src/cli/sync/__tests__/state.test.ts +255 -0
- package/references/minimem/src/cli/sync/__tests__/validation.test.ts +193 -0
- package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +178 -0
- package/references/minimem/src/cli/sync/central.ts +292 -0
- package/references/minimem/src/cli/sync/conflicts.ts +204 -0
- package/references/minimem/src/cli/sync/daemon.ts +407 -0
- package/references/minimem/src/cli/sync/detection.ts +138 -0
- package/references/minimem/src/cli/sync/index.ts +107 -0
- package/references/minimem/src/cli/sync/operations.ts +373 -0
- package/references/minimem/src/cli/sync/registry.ts +279 -0
- package/references/minimem/src/cli/sync/state.ts +355 -0
- package/references/minimem/src/cli/sync/validation.ts +206 -0
- package/references/minimem/src/cli/sync/watcher.ts +234 -0
- package/references/minimem/src/cli/version.ts +34 -0
- package/references/minimem/src/core/index.ts +9 -0
- package/references/minimem/src/core/indexer.ts +628 -0
- package/references/minimem/src/core/searcher.ts +221 -0
- package/references/minimem/src/db/schema.ts +183 -0
- package/references/minimem/src/db/sqlite-vec.ts +24 -0
- package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +431 -0
- package/references/minimem/src/embeddings/batch-gemini.ts +392 -0
- package/references/minimem/src/embeddings/batch-openai.ts +409 -0
- package/references/minimem/src/embeddings/embeddings.ts +434 -0
- package/references/minimem/src/index.ts +109 -0
- package/references/minimem/src/internal.ts +299 -0
- package/references/minimem/src/minimem.ts +1276 -0
- package/references/minimem/src/search/__tests__/hybrid.test.ts +247 -0
- package/references/minimem/src/search/graph.ts +234 -0
- package/references/minimem/src/search/hybrid.ts +151 -0
- package/references/minimem/src/search/search.ts +256 -0
- package/references/minimem/src/server/__tests__/mcp.test.ts +341 -0
- package/references/minimem/src/server/__tests__/tools.test.ts +364 -0
- package/references/minimem/src/server/mcp.ts +326 -0
- package/references/minimem/src/server/tools.ts +720 -0
- package/references/minimem/src/session.ts +460 -0
- package/references/minimem/tsconfig.json +19 -0
- package/references/minimem/tsup.config.ts +26 -0
- package/references/minimem/vitest.config.ts +24 -0
- 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/.claude/settings.json +6 -0
- package/references/skill-tree/.sudocode/issues.jsonl +19 -0
- package/references/skill-tree/.sudocode/specs.jsonl +3 -0
- package/references/skill-tree/CLAUDE.md +126 -0
- package/references/skill-tree/README.md +372 -0
- package/references/skill-tree/docs/GAPS_v1.md +221 -0
- package/references/skill-tree/docs/INTEGRATION_PLAN.md +467 -0
- package/references/skill-tree/docs/TODOS.md +91 -0
- package/references/skill-tree/docs/anthropic_skill_guide.md +1364 -0
- package/references/skill-tree/docs/design/federated-skill-trees.md +524 -0
- package/references/skill-tree/docs/design/multi-agent-sync.md +759 -0
- package/references/skill-tree/docs/scraper/BRAINSTORM.md +583 -0
- package/references/skill-tree/docs/scraper/POC_PLAN.md +420 -0
- package/references/skill-tree/docs/scraper/README.md +170 -0
- package/references/skill-tree/examples/basic-usage.ts +164 -0
- package/references/skill-tree/package-lock.json +1852 -0
- package/references/skill-tree/package.json +66 -0
- package/references/skill-tree/scraper/README.md +123 -0
- package/references/skill-tree/scraper/docs/DESIGN.md +683 -0
- package/references/skill-tree/scraper/docs/PLAN.md +336 -0
- package/references/skill-tree/scraper/drizzle.config.ts +10 -0
- package/references/skill-tree/scraper/package-lock.json +6329 -0
- package/references/skill-tree/scraper/package.json +68 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +27 -0
- package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +21 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +54 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +24 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +93 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +22 -0
- package/references/skill-tree/scraper/tsup.config.ts +14 -0
- package/references/skill-tree/scraper/vitest.config.ts +17 -0
- package/references/skill-tree/scripts/convert-to-vitest.ts +166 -0
- package/references/skill-tree/skills/skill-writer/SKILL.md +339 -0
- package/references/skill-tree/skills/skill-writer/references/examples.md +326 -0
- package/references/skill-tree/skills/skill-writer/references/patterns.md +210 -0
- package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +123 -0
- package/references/skill-tree/test/run-all.ts +106 -0
- package/references/skill-tree/test/utils.ts +128 -0
- package/references/skill-tree/vitest.config.ts +16 -0
- package/src/atlas.ts +583 -41
- 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/provider.ts +10 -3
- package/src/embeddings/vector-store.ts +21 -9
- package/src/factory.ts +33 -16
- package/src/index.ts +231 -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 +104 -13
- package/src/learning/instant-loop.ts +357 -0
- package/src/learning/knowledge-extractor.ts +470 -0
- package/src/learning/maintenance-scheduler.ts +271 -0
- package/src/learning/meta-learner.ts +59 -23
- package/src/learning/reflexion-generator.ts +273 -0
- package/src/learning/team-ingester.ts +499 -0
- package/src/learning/team-meta-learner.ts +558 -0
- package/src/learning/team-pipeline.ts +364 -0
- package/src/learning/trajectory-sources/dataclaw.ts +403 -0
- package/src/learning/trajectory-sources/entire.ts +251 -0
- package/src/learning/trajectory-sources/file.ts +136 -0
- package/src/learning/trajectory-sources/huggingface.ts +248 -0
- package/src/learning/trajectory-sources/in-memory.ts +61 -0
- package/src/learning/trajectory-sources/index.ts +15 -0
- package/src/learning/trajectory-sources/pipeline.ts +69 -0
- package/src/learning/unified-pipeline.ts +921 -0
- package/src/memory/candidate-retrieval.ts +71 -0
- package/src/memory/causal-store.ts +273 -0
- package/src/memory/coherence.ts +252 -0
- package/src/memory/experience.ts +217 -50
- package/src/memory/graph-layers/base.ts +184 -0
- package/src/memory/graph-layers/causal.ts +16 -0
- package/src/memory/graph-layers/entity.ts +16 -0
- package/src/memory/graph-layers/index.ts +5 -0
- package/src/memory/graph-layers/semantic.ts +16 -0
- package/src/memory/graph-layers/temporal.ts +16 -0
- package/src/memory/index.ts +88 -0
- package/src/memory/knowledge-bank.ts +1317 -0
- package/src/memory/knowledge-defrag.ts +329 -0
- package/src/memory/knowledge-graph.ts +361 -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/search-provider.ts +35 -0
- package/src/memory/search-providers/index.ts +3 -0
- package/src/memory/search-providers/minimem.ts +84 -0
- package/src/memory/search-providers/text-similarity.ts +35 -0
- package/src/memory/skill-exporter.ts +357 -0
- package/src/memory/system.ts +80 -11
- package/src/memory/team-experience.ts +604 -0
- 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/backends/acp-protocol.ts +231 -0
- package/src/runtime/backends/acp.ts +57 -196
- package/src/runtime/backends/index.ts +14 -0
- package/src/runtime/backends/macro-agent.ts +177 -0
- package/src/runtime/compute-provider.ts +206 -0
- package/src/runtime/flows/learning.ts +25 -42
- package/src/runtime/index.ts +22 -0
- package/src/runtime/manager.ts +167 -23
- package/src/runtime/types.ts +41 -0
- package/src/search/evaluator.ts +29 -4
- package/src/search/index.ts +19 -0
- package/src/search/moe-gate.ts +304 -0
- package/src/search/refinement-loop.ts +106 -12
- package/src/search/router.ts +111 -4
- package/src/search/team-router.ts +459 -0
- package/src/session-bank/git-reader.ts +200 -0
- package/src/session-bank/index.ts +26 -0
- package/src/session-bank/parser.ts +548 -0
- package/src/session-bank/session-bank.ts +485 -0
- package/src/session-bank/types.ts +176 -0
- package/src/surfacing/index.ts +23 -0
- package/src/surfacing/publisher.ts +23 -0
- package/src/surfacing/skill-library.ts +31 -0
- package/src/surfacing/skill-publisher.ts +191 -0
- package/src/surfacing/sqlite-storage-adapter.ts +285 -0
- package/src/surfacing/team-skill-library.ts +610 -0
- package/src/types/config.ts +282 -0
- package/src/types/dataclaw.ts +99 -0
- package/src/types/huggingface-transformers.d.ts +12 -0
- package/src/types/index.ts +159 -0
- package/src/types/knowledge-graph.ts +246 -0
- package/src/types/knowledge.ts +388 -0
- package/src/types/memory.ts +30 -0
- package/src/types/playbook.ts +4 -0
- package/src/types/team-meta.ts +212 -0
- package/src/types/team-playbook.ts +384 -0
- package/src/types/team-trajectory.ts +673 -0
- package/src/types/trajectory-source.ts +47 -0
- package/src/utils/error-classifier.ts +113 -0
- package/src/utils/frontmatter.ts +118 -0
- package/src/utils/index.ts +25 -0
- package/src/utils/partitioned-store.ts +299 -0
- package/src/utils/trajectory-helpers.ts +79 -0
- package/src/workspace/index.ts +48 -0
- package/src/workspace/runner.ts +281 -0
- package/src/workspace/skill-converter.ts +288 -0
- package/src/workspace/templates/index.ts +64 -0
- package/src/workspace/templates/knowledge-defrag.ts +223 -0
- package/src/workspace/templates/knowledge-extraction.ts +337 -0
- package/src/workspace/templates/meta-reflection.ts +208 -0
- package/src/workspace/templates/playbook-extraction.ts +240 -0
- package/src/workspace/templates/refinement-analysis.ts +162 -0
- package/src/workspace/templates/solution-evaluation.ts +199 -0
- package/src/workspace/templates/team-playbook-extraction.ts +631 -0
- package/src/workspace/templates/team-trajectory-analysis.ts +564 -0
- package/src/workspace/templates/trajectory-analysis.ts +234 -0
- package/src/workspace/templates/usage-inference.ts +163 -0
- package/src/workspace/types.ts +241 -0
- package/tests/atlas-knowledge.test.ts +165 -0
- package/tests/embeddings/inverted-index.test.ts +138 -0
- package/tests/feature-toggles.test.ts +275 -0
- package/tests/gap-fixes.test.ts +1116 -0
- package/tests/integration/cli-e2e.test.ts +621 -0
- package/tests/integration/dataclaw-e2e.test.ts +559 -0
- package/tests/integration/e2e.test.ts +412 -4
- package/tests/integration/entire-e2e.test.ts +376 -0
- package/tests/integration/huggingface-e2e.test.ts +627 -0
- package/tests/integration/persistence-e2e.test.ts +741 -0
- package/tests/integration/phase-e2e.test.ts +1143 -0
- package/tests/integration/session-bank.test.ts +231 -0
- package/tests/integration/sessionlog-e2e.test.ts +329 -0
- package/tests/integration/skill-tree-wiring.test.ts +152 -0
- package/tests/integration/unified-pipeline-e2e.test.ts +634 -0
- package/tests/learning/analyzer.test.ts +1 -1
- package/tests/learning/dataclaw-trajectory-source.test.ts +642 -0
- package/tests/learning/energy-evaluator.test.ts +180 -0
- package/tests/learning/entire-trajectory-source.test.ts +380 -0
- package/tests/learning/healing-orchestrator.test.ts +269 -0
- package/tests/learning/huggingface-trajectory-source.test.ts +817 -0
- package/tests/learning/instant-loop.test.ts +243 -0
- package/tests/learning/knowledge-extractor.test.ts +491 -0
- package/tests/learning/maintenance-scheduler.test.ts +191 -0
- package/tests/learning/reflexion-generator.test.ts +411 -0
- package/tests/learning/team-ingester.test.ts +349 -0
- package/tests/learning/team-meta-learner.test.ts +618 -0
- package/tests/learning/team-pipeline.test.ts +334 -0
- package/tests/learning/trajectory-sources.test.ts +320 -0
- package/tests/learning/unified-pipeline.test.ts +322 -0
- package/tests/mcp/playbook-server.test.ts +6 -1
- package/tests/memory/causal-store.test.ts +276 -0
- package/tests/memory/coherence.test.ts +232 -0
- package/tests/memory/experience.test.ts +8 -3
- package/tests/memory/graph-layers/semantic.test.ts +219 -0
- package/tests/memory/knowledge-bank-extraction.test.ts +558 -0
- package/tests/memory/knowledge-bank.test.ts +705 -0
- package/tests/memory/knowledge-defrag.test.ts +366 -0
- package/tests/memory/knowledge-evolution.test.ts +563 -0
- package/tests/memory/knowledge-graph.test.ts +492 -0
- package/tests/memory/knowledge-inbox.test.ts +258 -0
- package/tests/memory/knowledge-minimem.test.ts +251 -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 +475 -0
- package/tests/memory/system.test.ts +6 -1
- package/tests/memory/team-experience.test.ts +411 -0
- 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 +7 -2
- package/tests/runtime/compute-provider.test.ts +288 -0
- package/tests/runtime/delegate.test.ts +354 -0
- package/tests/runtime/macro-agent-backend.test.ts +266 -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/team-router.test.ts +376 -0
- package/tests/session-bank/fixtures/multi-tool-session/full.jsonl +12 -0
- package/tests/session-bank/fixtures/multi-tool-session/metadata.json +28 -0
- package/tests/session-bank/fixtures/root-metadata.json +18 -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/fixtures/simple-session/full.jsonl +6 -0
- package/tests/session-bank/fixtures/simple-session/metadata.json +38 -0
- package/tests/session-bank/git-reader.test.ts +232 -0
- package/tests/session-bank/parser.test.ts +453 -0
- package/tests/session-bank/session-bank.test.ts +546 -0
- package/tests/surfacing/skill-library.test.ts +6 -1
- package/tests/surfacing/skill-publisher.test.ts +364 -0
- package/tests/surfacing/sqlite-storage-adapter.test.ts +206 -0
- package/tests/surfacing/team-skill-library.test.ts +444 -0
- package/tests/types/team-meta.test.ts +147 -0
- package/tests/types/team-playbook.test.ts +246 -0
- package/tests/types/team-trajectory.test.ts +557 -0
- package/tests/utils/frontmatter.test.ts +208 -0
- package/tests/utils/partitioned-store.test.ts +230 -0
- package/tests/workspace/full-flow.test.ts +845 -0
- package/tests/workspace/manager.test.ts +215 -0
- package/tests/workspace/runner.test.ts +336 -0
- package/tests/workspace/skill-converter.test.ts +205 -0
- package/tests/workspace/templates/knowledge-extraction.test.ts +235 -0
- package/tests/workspace/templates/team-playbook-extraction.test.ts +341 -0
- package/tests/workspace/templates/team-trajectory-analysis.test.ts +417 -0
- package/src/learning/llm-extractor.ts +0 -542
- package/src/learning/pipeline.ts +0 -244
- package/tests/learning/pipeline.test.ts +0 -176
|
@@ -0,0 +1,2057 @@
|
|
|
1
|
+
# Design: Agentic Analysis Workspace
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
cognitive-core has ~12 analysis points that transform execution data into learning signals. Most are implemented as brittle heuristics (word overlap, regex matching, exponential decay) when they should use semantic understanding. A few already use LLM calls or spawn agents, but each does it differently with no shared infrastructure.
|
|
6
|
+
|
|
7
|
+
| Analysis Point | Current | Should Be |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| Credit assignment (`analyzer.ts`) | Exponential decay / outcome-based | Semantic causal reasoning |
|
|
10
|
+
| Key step identification (`analyzer.ts`) | Score threshold | Counterfactual reasoning |
|
|
11
|
+
| Error pattern detection (`analyzer.ts`) | Regex matching | Semantic classification |
|
|
12
|
+
| Playbook extraction (`playbook-extractor.ts`) | Action normalization + frequency | Semantic pattern recognition |
|
|
13
|
+
| LLM playbook extraction (`llm-extractor.ts`) | Single LLM call | Iterative agentic extraction |
|
|
14
|
+
| Meta-learning reflection (`meta-learner.ts`) | Word overlap heuristics | Semantic reflection |
|
|
15
|
+
| Usage inference (`usage-inference.ts`) | Word overlap matching | Semantic matching |
|
|
16
|
+
| Solution evaluation (`evaluator.ts`) | Tier 2: agent, Tier 3: heuristic | Workspace-based analysis |
|
|
17
|
+
| Routing decision (`router.ts`) | Threshold-based rules | Reasoned strategy selection |
|
|
18
|
+
| Effectiveness tracking (`effectiveness.ts`) | Counting / aggregation | OK as heuristic (pure metrics) |
|
|
19
|
+
| Refinement strategy (`refinement-loop.ts`) | Issue listing + retry | Root cause analysis |
|
|
20
|
+
| **Team analysis** (new) | N/A | Agentic workspace |
|
|
21
|
+
| **Team playbook extraction** (new) | N/A | Agentic workspace |
|
|
22
|
+
|
|
23
|
+
The pattern is the same across all of these:
|
|
24
|
+
|
|
25
|
+
1. Prepare structured input data
|
|
26
|
+
2. An agent (or LLM) analyzes it with semantic understanding
|
|
27
|
+
3. Structured output is validated and stored
|
|
28
|
+
4. The analysis agent's own execution is captured for meta-learning
|
|
29
|
+
|
|
30
|
+
This document designs a **reusable agentic workspace** that standardizes this pattern.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Design Overview
|
|
35
|
+
|
|
36
|
+
Three components:
|
|
37
|
+
|
|
38
|
+
1. **`AgenticTaskTemplate<TInput, TOutput>`** — a declarative recipe for an analysis task (what goes in, what comes out, what skills are available, what output shape is expected)
|
|
39
|
+
2. **`WorkspaceManager`** — creates, populates, validates, and cleans up filesystem workspaces
|
|
40
|
+
3. **`AgenticTaskRunner`** — orchestrates the full lifecycle: workspace → agent spawn → output collection → meta-learning
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
AgenticTaskTemplate WorkspaceManager
|
|
44
|
+
(declarative recipe) (filesystem lifecycle)
|
|
45
|
+
│ │
|
|
46
|
+
└──────────┬─────────────────┘
|
|
47
|
+
│
|
|
48
|
+
▼
|
|
49
|
+
AgenticTaskRunner
|
|
50
|
+
(orchestration)
|
|
51
|
+
│
|
|
52
|
+
┌──────────┼──────────────┐
|
|
53
|
+
│ │ │
|
|
54
|
+
▼ ▼ ▼
|
|
55
|
+
AgentManager Output LearningPipeline
|
|
56
|
+
(spawn agent) Validation (meta-learning from
|
|
57
|
+
analysis trajectory)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Workspace Directory Structure
|
|
61
|
+
|
|
62
|
+
Every workspace follows a standard layout:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
{workspace}/
|
|
66
|
+
├── input/ # Prepared input data
|
|
67
|
+
│ ├── context.md # YAML frontmatter + markdown body
|
|
68
|
+
│ ├── trajectories/ # JSONL files (one step per line)
|
|
69
|
+
│ │ ├── agent-a.jsonl
|
|
70
|
+
│ │ └── agent-b.jsonl
|
|
71
|
+
│ └── ...task-specific data...
|
|
72
|
+
├── resources/ # Configurable supplementary data
|
|
73
|
+
│ ├── codebase/ # Optional codebase snapshot
|
|
74
|
+
│ ├── docs/ # Optional reference docs
|
|
75
|
+
│ └── ...per-template...
|
|
76
|
+
├── skills/ # Agent Skills (open standard format)
|
|
77
|
+
│ ├── trajectory-analysis/
|
|
78
|
+
│ │ └── SKILL.md
|
|
79
|
+
│ └── ...
|
|
80
|
+
├── workspace/ # Agent scratch space (notes, temp files)
|
|
81
|
+
└── output/ # Structured results per outputConfig
|
|
82
|
+
├── output.json # Primary output (with schema validation)
|
|
83
|
+
├── SKILL.md # If task produces skills
|
|
84
|
+
└── ...
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Data Format Conventions
|
|
88
|
+
|
|
89
|
+
| Data Type | Format | Rationale |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| Trajectories | **JSONL** (`.jsonl`) | One step per line. Greppable, streamable, works with `head`/`tail`/`wc -l`. Agent can search with standard tools. |
|
|
92
|
+
| Text-heavy content | **Markdown + YAML frontmatter** | Context docs, lessons, assessments. Structured metadata in frontmatter, readable prose in body. |
|
|
93
|
+
| Structured data | **JSON** | Configs, schemas, structured results. Validated against Zod schemas. |
|
|
94
|
+
| Skills | **SKILL.md** (Agent Skills open standard) | Portable skill format. Converter between Playbook ↔ Skill assumed. |
|
|
95
|
+
|
|
96
|
+
### Raw Data First Principle
|
|
97
|
+
|
|
98
|
+
Early pipeline agents receive **raw data** (full trajectories, original task descriptions). Later pipeline agents receive **derivative data** from previous analysis (credits, annotations, extracted patterns). This ensures early agents can discover novel patterns that preprocessed summaries might obscure.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## AgenticTaskTemplate
|
|
103
|
+
|
|
104
|
+
A template defines everything about a specific type of analysis task. Different analysis tasks (trajectory analysis, playbook extraction, team analysis) are different templates.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
/**
|
|
108
|
+
* Declarative recipe for an agentic analysis task.
|
|
109
|
+
*
|
|
110
|
+
* TInput: the typed input data for this analysis
|
|
111
|
+
* TOutput: the typed output the agent produces
|
|
112
|
+
*/
|
|
113
|
+
interface AgenticTaskTemplate<TInput, TOutput> {
|
|
114
|
+
/** Unique identifier for this task type */
|
|
115
|
+
taskType: string;
|
|
116
|
+
// e.g., 'trajectory-analysis', 'playbook-extraction', 'team-analysis'
|
|
117
|
+
|
|
118
|
+
/** Domain for knowledge injection and meta-learning.
|
|
119
|
+
* Analysis playbooks accumulate in this domain. */
|
|
120
|
+
domain: string;
|
|
121
|
+
// e.g., 'trajectory-analysis' → playbooks about how to analyze trajectories
|
|
122
|
+
|
|
123
|
+
/** Human-readable description */
|
|
124
|
+
description: string;
|
|
125
|
+
|
|
126
|
+
// === WORKSPACE SETUP ===
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Prepare the workspace filesystem from typed input.
|
|
130
|
+
* Writes input files (JSONL trajectories, markdown context docs, etc.)
|
|
131
|
+
* that the agent will read using standard tools.
|
|
132
|
+
*/
|
|
133
|
+
prepareWorkspace(input: TInput, workspacePath: string): Promise<void>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Build the task description for the agent.
|
|
137
|
+
* This is the natural language prompt explaining what to do,
|
|
138
|
+
* what files to read, and what output to produce.
|
|
139
|
+
*/
|
|
140
|
+
buildTaskPrompt(input: TInput): string;
|
|
141
|
+
|
|
142
|
+
// === SKILLS ===
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Skills to load into the workspace skills/ directory.
|
|
146
|
+
* These are SKILL.md files in the Agent Skills open standard format.
|
|
147
|
+
* Playbooks from memory are converted to skills via the converter.
|
|
148
|
+
*/
|
|
149
|
+
getSkills(input: TInput): AgentSkillSpec[];
|
|
150
|
+
|
|
151
|
+
// === RESOURCES ===
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Supplementary resources to load into the workspace resources/ directory.
|
|
155
|
+
* Configurable per task — codebase snapshots, reference docs, etc.
|
|
156
|
+
*/
|
|
157
|
+
getResources(input: TInput): ResourceSpec[];
|
|
158
|
+
|
|
159
|
+
// === KNOWLEDGE ===
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Additional memory queries to inject domain-specific knowledge.
|
|
163
|
+
* Beyond the automatic domain-scoped query, templates can request
|
|
164
|
+
* additional knowledge based on the input.
|
|
165
|
+
*/
|
|
166
|
+
getAdditionalKnowledge?(
|
|
167
|
+
input: TInput,
|
|
168
|
+
memory: MemorySystem
|
|
169
|
+
): Promise<MemoryQueryResultV2>;
|
|
170
|
+
|
|
171
|
+
// === OUTPUT ===
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Configuration defining the expected output shape.
|
|
175
|
+
* Different tasks produce different outputs — JSON with schema,
|
|
176
|
+
* SKILL.md files, markdown reports, etc.
|
|
177
|
+
*/
|
|
178
|
+
outputConfig: OutputConfig;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Read and validate agent output from workspace.
|
|
182
|
+
* Validates against outputConfig schema if applicable.
|
|
183
|
+
* Returns typed output or throws if validation fails.
|
|
184
|
+
*/
|
|
185
|
+
collectOutput(workspacePath: string): Promise<TOutput>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Process the validated output — store results, accumulate
|
|
189
|
+
* for batch learning, update memory, etc.
|
|
190
|
+
*/
|
|
191
|
+
processOutput(
|
|
192
|
+
output: TOutput,
|
|
193
|
+
input: TInput,
|
|
194
|
+
context: ProcessingContext
|
|
195
|
+
): Promise<void>;
|
|
196
|
+
|
|
197
|
+
// === COMPLEXITY ASSESSMENT ===
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Assess whether this input needs agentic analysis or can
|
|
201
|
+
* use a heuristic fallback. This controls cost — simple inputs
|
|
202
|
+
* don't need a full agent spawn.
|
|
203
|
+
*/
|
|
204
|
+
assessComplexity(input: TInput): AnalysisComplexity;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Heuristic fallback for simple cases.
|
|
208
|
+
* If assessComplexity returns 'heuristic', this is called
|
|
209
|
+
* instead of spawning an agent.
|
|
210
|
+
*/
|
|
211
|
+
heuristicFallback?(input: TInput): Promise<TOutput>;
|
|
212
|
+
|
|
213
|
+
// === CONFIGURATION ===
|
|
214
|
+
|
|
215
|
+
/** Agent type to spawn */
|
|
216
|
+
agentType?: string; // default: 'claude-code'
|
|
217
|
+
|
|
218
|
+
/** Timeout for the analysis agent */
|
|
219
|
+
timeout?: number; // default: 120_000 (2 minutes)
|
|
220
|
+
|
|
221
|
+
/** Whether to capture detailed tool calls */
|
|
222
|
+
captureToolCalls?: boolean; // default: true
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Output configuration — defines what shape of output the agent produces.
|
|
227
|
+
*/
|
|
228
|
+
interface OutputConfig {
|
|
229
|
+
/** Primary output file(s) the agent must produce */
|
|
230
|
+
files: OutputFileSpec[];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
interface OutputFileSpec {
|
|
234
|
+
/** Path relative to output/ directory */
|
|
235
|
+
path: string;
|
|
236
|
+
/** File format */
|
|
237
|
+
format: 'json' | 'jsonl' | 'markdown' | 'skill-md';
|
|
238
|
+
/** Zod schema for JSON/JSONL validation (optional) */
|
|
239
|
+
schema?: ZodSchema;
|
|
240
|
+
/** Whether this file is required or optional */
|
|
241
|
+
required: boolean;
|
|
242
|
+
/** Description shown to the agent */
|
|
243
|
+
description: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Skill to load into workspace skills/ directory.
|
|
248
|
+
*/
|
|
249
|
+
interface AgentSkillSpec {
|
|
250
|
+
/** Skill directory name */
|
|
251
|
+
name: string;
|
|
252
|
+
/** SKILL.md content (Agent Skills open standard format) */
|
|
253
|
+
content: string;
|
|
254
|
+
/** Source — converted from a Playbook, or loaded from curated skills */
|
|
255
|
+
source: 'playbook-conversion' | 'curated' | 'extracted';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Supplementary resource to load into workspace resources/ directory.
|
|
260
|
+
*/
|
|
261
|
+
interface ResourceSpec {
|
|
262
|
+
/** Path relative to resources/ directory */
|
|
263
|
+
path: string;
|
|
264
|
+
/** How to populate this resource */
|
|
265
|
+
type: 'directory' | 'file' | 'symlink';
|
|
266
|
+
/** Source path (for symlink/copy) or content (for file) */
|
|
267
|
+
source: string;
|
|
268
|
+
/** Description for the agent */
|
|
269
|
+
description?: string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
type AnalysisComplexity =
|
|
273
|
+
| 'heuristic' // Use heuristicFallback(), no agent needed
|
|
274
|
+
| 'lightweight' // Agent with small budget, simple workspace
|
|
275
|
+
| 'standard' // Agent with moderate budget, full workspace
|
|
276
|
+
| 'thorough'; // Agent with large budget, full workspace, more time
|
|
277
|
+
|
|
278
|
+
interface ProcessingContext {
|
|
279
|
+
memory: MemorySystem;
|
|
280
|
+
teamMemory?: TeamMemorySystem;
|
|
281
|
+
learningPipeline: LearningPipeline;
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## WorkspaceManager
|
|
288
|
+
|
|
289
|
+
Handles filesystem lifecycle — creating the directory structure, populating inputs, validating outputs, cleanup.
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
class WorkspaceManager {
|
|
293
|
+
private baseDir: string; // default: os.tmpdir()
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Create a workspace directory with standard structure.
|
|
297
|
+
*/
|
|
298
|
+
async create(taskType: string): Promise<WorkspaceHandle> {
|
|
299
|
+
const id = `${taskType}-${Date.now()}-${randomId()}`;
|
|
300
|
+
const path = join(this.baseDir, 'atlas-workspaces', id);
|
|
301
|
+
|
|
302
|
+
await mkdir(join(path, 'input'), { recursive: true });
|
|
303
|
+
await mkdir(join(path, 'resources'), { recursive: true });
|
|
304
|
+
await mkdir(join(path, 'skills'), { recursive: true });
|
|
305
|
+
await mkdir(join(path, 'workspace'), { recursive: true });
|
|
306
|
+
await mkdir(join(path, 'output'), { recursive: true });
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
id,
|
|
310
|
+
path,
|
|
311
|
+
inputDir: join(path, 'input'),
|
|
312
|
+
resourcesDir: join(path, 'resources'),
|
|
313
|
+
skillsDir: join(path, 'skills'),
|
|
314
|
+
workspaceDir: join(path, 'workspace'),
|
|
315
|
+
outputDir: join(path, 'output'),
|
|
316
|
+
createdAt: new Date(),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// === INPUT WRITERS ===
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Write a JSON file to the input directory.
|
|
324
|
+
*/
|
|
325
|
+
async writeInputJson(
|
|
326
|
+
handle: WorkspaceHandle,
|
|
327
|
+
filename: string,
|
|
328
|
+
data: unknown
|
|
329
|
+
): Promise<void> {
|
|
330
|
+
const filePath = join(handle.inputDir, filename);
|
|
331
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
332
|
+
await writeFile(filePath, JSON.stringify(data, null, 2));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Write a JSONL file to the input directory.
|
|
337
|
+
* Each item becomes one line — ideal for trajectories (one step per line).
|
|
338
|
+
* Agents can search with grep, count with wc -l, peek with head/tail.
|
|
339
|
+
*/
|
|
340
|
+
async writeInputJsonl(
|
|
341
|
+
handle: WorkspaceHandle,
|
|
342
|
+
filename: string,
|
|
343
|
+
items: unknown[]
|
|
344
|
+
): Promise<void> {
|
|
345
|
+
const filePath = join(handle.inputDir, filename);
|
|
346
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
347
|
+
const lines = items.map(item => JSON.stringify(item));
|
|
348
|
+
await writeFile(filePath, lines.join('\n') + '\n');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Write a markdown file with YAML frontmatter to the input directory.
|
|
353
|
+
* Used for text-heavy content: context docs, lessons, assessments.
|
|
354
|
+
*/
|
|
355
|
+
async writeInputMarkdown(
|
|
356
|
+
handle: WorkspaceHandle,
|
|
357
|
+
filename: string,
|
|
358
|
+
frontmatter: Record<string, unknown>,
|
|
359
|
+
body: string
|
|
360
|
+
): Promise<void> {
|
|
361
|
+
const filePath = join(handle.inputDir, filename);
|
|
362
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
363
|
+
const yaml = this.toYamlFrontmatter(frontmatter);
|
|
364
|
+
await writeFile(filePath, `---\n${yaml}---\n\n${body}`);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Write a raw file (any format) to the input directory.
|
|
369
|
+
*/
|
|
370
|
+
async writeInputRaw(
|
|
371
|
+
handle: WorkspaceHandle,
|
|
372
|
+
filename: string,
|
|
373
|
+
content: string
|
|
374
|
+
): Promise<void> {
|
|
375
|
+
const filePath = join(handle.inputDir, filename);
|
|
376
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
377
|
+
await writeFile(filePath, content);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// === SKILLS ===
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Write a SKILL.md file to the skills directory.
|
|
384
|
+
* Agent Skills open standard format.
|
|
385
|
+
*/
|
|
386
|
+
async writeSkill(
|
|
387
|
+
handle: WorkspaceHandle,
|
|
388
|
+
skill: AgentSkillSpec
|
|
389
|
+
): Promise<void> {
|
|
390
|
+
const skillDir = join(handle.skillsDir, skill.name);
|
|
391
|
+
await mkdir(skillDir, { recursive: true });
|
|
392
|
+
await writeFile(join(skillDir, 'SKILL.md'), skill.content);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Write multiple skills to the workspace.
|
|
397
|
+
*/
|
|
398
|
+
async writeSkills(
|
|
399
|
+
handle: WorkspaceHandle,
|
|
400
|
+
skills: AgentSkillSpec[]
|
|
401
|
+
): Promise<void> {
|
|
402
|
+
await Promise.all(skills.map(s => this.writeSkill(handle, s)));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// === RESOURCES ===
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Populate a resource in the resources directory.
|
|
409
|
+
*/
|
|
410
|
+
async writeResource(
|
|
411
|
+
handle: WorkspaceHandle,
|
|
412
|
+
resource: ResourceSpec
|
|
413
|
+
): Promise<void> {
|
|
414
|
+
const targetPath = join(handle.resourcesDir, resource.path);
|
|
415
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
416
|
+
|
|
417
|
+
switch (resource.type) {
|
|
418
|
+
case 'file':
|
|
419
|
+
await writeFile(targetPath, resource.source);
|
|
420
|
+
break;
|
|
421
|
+
case 'symlink':
|
|
422
|
+
await symlink(resource.source, targetPath);
|
|
423
|
+
break;
|
|
424
|
+
case 'directory':
|
|
425
|
+
await cp(resource.source, targetPath, { recursive: true });
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Write multiple resources to the workspace.
|
|
432
|
+
*/
|
|
433
|
+
async writeResources(
|
|
434
|
+
handle: WorkspaceHandle,
|
|
435
|
+
resources: ResourceSpec[]
|
|
436
|
+
): Promise<void> {
|
|
437
|
+
await Promise.all(resources.map(r => this.writeResource(handle, r)));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// === OUTPUT READERS ===
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Read and parse a JSON output file.
|
|
444
|
+
* Returns null if file doesn't exist.
|
|
445
|
+
*/
|
|
446
|
+
async readOutputJson<T>(
|
|
447
|
+
handle: WorkspaceHandle,
|
|
448
|
+
filename: string,
|
|
449
|
+
schema?: ZodSchema<T>
|
|
450
|
+
): Promise<T | null> {
|
|
451
|
+
const filePath = join(handle.outputDir, filename);
|
|
452
|
+
try {
|
|
453
|
+
const raw = await readFile(filePath, 'utf-8');
|
|
454
|
+
const parsed = JSON.parse(raw);
|
|
455
|
+
return schema ? schema.parse(parsed) : parsed;
|
|
456
|
+
} catch {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Read a JSONL output file as an array of parsed items.
|
|
463
|
+
*/
|
|
464
|
+
async readOutputJsonl<T>(
|
|
465
|
+
handle: WorkspaceHandle,
|
|
466
|
+
filename: string,
|
|
467
|
+
schema?: ZodSchema<T>
|
|
468
|
+
): Promise<T[]> {
|
|
469
|
+
const filePath = join(handle.outputDir, filename);
|
|
470
|
+
try {
|
|
471
|
+
const raw = await readFile(filePath, 'utf-8');
|
|
472
|
+
const lines = raw.trim().split('\n').filter(l => l.length > 0);
|
|
473
|
+
const items = lines.map(line => JSON.parse(line));
|
|
474
|
+
return schema ? items.map(item => schema.parse(item)) : items;
|
|
475
|
+
} catch {
|
|
476
|
+
return [];
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Read a markdown output file (returns raw content).
|
|
482
|
+
*/
|
|
483
|
+
async readOutputMarkdown(
|
|
484
|
+
handle: WorkspaceHandle,
|
|
485
|
+
filename: string
|
|
486
|
+
): Promise<string | null> {
|
|
487
|
+
const filePath = join(handle.outputDir, filename);
|
|
488
|
+
try {
|
|
489
|
+
return await readFile(filePath, 'utf-8');
|
|
490
|
+
} catch {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Read all files in an output subdirectory.
|
|
497
|
+
*/
|
|
498
|
+
async readOutputDir<T>(
|
|
499
|
+
handle: WorkspaceHandle,
|
|
500
|
+
dirName: string,
|
|
501
|
+
schema?: ZodSchema<T>
|
|
502
|
+
): Promise<Map<string, T>> {
|
|
503
|
+
const dirPath = join(handle.outputDir, dirName);
|
|
504
|
+
const results = new Map<string, T>();
|
|
505
|
+
try {
|
|
506
|
+
const files = await readdir(dirPath);
|
|
507
|
+
for (const file of files) {
|
|
508
|
+
if (file.endsWith('.json')) {
|
|
509
|
+
const data = await this.readOutputJson<T>(
|
|
510
|
+
handle,
|
|
511
|
+
join(dirName, file),
|
|
512
|
+
schema
|
|
513
|
+
);
|
|
514
|
+
if (data) results.set(file.replace('.json', ''), data);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
} catch {
|
|
518
|
+
// directory doesn't exist
|
|
519
|
+
}
|
|
520
|
+
return results;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Validate that all required output files exist per OutputConfig.
|
|
525
|
+
*/
|
|
526
|
+
async validateOutput(
|
|
527
|
+
handle: WorkspaceHandle,
|
|
528
|
+
config: OutputConfig
|
|
529
|
+
): Promise<{ valid: boolean; missing: string[] }> {
|
|
530
|
+
const missing: string[] = [];
|
|
531
|
+
for (const file of config.files) {
|
|
532
|
+
if (file.required) {
|
|
533
|
+
const filePath = join(handle.outputDir, file.path);
|
|
534
|
+
try {
|
|
535
|
+
await access(filePath);
|
|
536
|
+
} catch {
|
|
537
|
+
missing.push(file.path);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return { valid: missing.length === 0, missing };
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// === LIFECYCLE ===
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Cleanup workspace directory.
|
|
548
|
+
*/
|
|
549
|
+
async cleanup(handle: WorkspaceHandle): Promise<void> {
|
|
550
|
+
await rm(handle.path, { recursive: true, force: true });
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* List active workspaces (for monitoring/debugging).
|
|
555
|
+
*/
|
|
556
|
+
async listActive(): Promise<WorkspaceHandle[]> {
|
|
557
|
+
// scan baseDir/atlas-workspaces/ for directories
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Cleanup workspaces older than maxAge.
|
|
562
|
+
*/
|
|
563
|
+
async pruneStale(maxAgeMs: number): Promise<number> {
|
|
564
|
+
// remove workspaces older than maxAge
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// === HELPERS ===
|
|
568
|
+
|
|
569
|
+
private toYamlFrontmatter(data: Record<string, unknown>): string {
|
|
570
|
+
// Simple YAML serialization for frontmatter
|
|
571
|
+
// Handles strings, numbers, booleans, arrays, dates
|
|
572
|
+
return Object.entries(data)
|
|
573
|
+
.map(([key, value]) => {
|
|
574
|
+
if (Array.isArray(value)) {
|
|
575
|
+
return `${key}:\n${value.map(v => ` - ${v}`).join('\n')}`;
|
|
576
|
+
}
|
|
577
|
+
if (value instanceof Date) {
|
|
578
|
+
return `${key}: ${value.toISOString()}`;
|
|
579
|
+
}
|
|
580
|
+
return `${key}: ${value}`;
|
|
581
|
+
})
|
|
582
|
+
.join('\n') + '\n';
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
interface WorkspaceHandle {
|
|
587
|
+
id: string;
|
|
588
|
+
path: string;
|
|
589
|
+
inputDir: string;
|
|
590
|
+
resourcesDir: string;
|
|
591
|
+
skillsDir: string;
|
|
592
|
+
workspaceDir: string;
|
|
593
|
+
outputDir: string;
|
|
594
|
+
createdAt: Date;
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## AgenticTaskRunner
|
|
601
|
+
|
|
602
|
+
The orchestrator that ties templates, workspaces, and agent spawning together.
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
class AgenticTaskRunner {
|
|
606
|
+
constructor(
|
|
607
|
+
private workspaceManager: WorkspaceManager,
|
|
608
|
+
private agentManager: AgentManager,
|
|
609
|
+
private memory: MemorySystem,
|
|
610
|
+
private learningPipeline: LearningPipeline,
|
|
611
|
+
private config: AgenticTaskRunnerConfig
|
|
612
|
+
) {}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Run an agentic analysis task.
|
|
616
|
+
*
|
|
617
|
+
* This is the main entry point. It:
|
|
618
|
+
* 1. Checks complexity — uses heuristic fallback for simple inputs
|
|
619
|
+
* 2. Creates workspace and populates input files
|
|
620
|
+
* 3. Populates input data (JSONL trajectories, markdown context, etc.)
|
|
621
|
+
* 4. Loads skills (converted from playbooks + curated SKILL.md files)
|
|
622
|
+
* 5. Loads resources (codebase snapshots, docs, etc.)
|
|
623
|
+
* 6. Queries knowledge for injection
|
|
624
|
+
* 7. Spawns agent with workspace as cwd
|
|
625
|
+
* 8. Validates output against outputConfig
|
|
626
|
+
* 9. Collects and validates output
|
|
627
|
+
* 10. Processes output (store, accumulate, etc.)
|
|
628
|
+
* 11. Routes analysis agent's trajectory through learning pipeline
|
|
629
|
+
* 12. Cleans up workspace
|
|
630
|
+
*/
|
|
631
|
+
async run<TInput, TOutput>(
|
|
632
|
+
template: AgenticTaskTemplate<TInput, TOutput>,
|
|
633
|
+
input: TInput
|
|
634
|
+
): Promise<AgenticTaskResult<TOutput>> {
|
|
635
|
+
|
|
636
|
+
// Step 1: Complexity assessment
|
|
637
|
+
const complexity = template.assessComplexity(input);
|
|
638
|
+
|
|
639
|
+
if (complexity === 'heuristic' && template.heuristicFallback) {
|
|
640
|
+
const output = await template.heuristicFallback(input);
|
|
641
|
+
return {
|
|
642
|
+
output,
|
|
643
|
+
method: 'heuristic',
|
|
644
|
+
metrics: { totalTimeMs: 0, tokensUsed: 0, toolCalls: 0 },
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// Step 2: Create workspace
|
|
649
|
+
const workspace = await this.workspaceManager.create(template.taskType);
|
|
650
|
+
|
|
651
|
+
try {
|
|
652
|
+
// Step 3: Populate input files
|
|
653
|
+
await template.prepareWorkspace(input, workspace.path);
|
|
654
|
+
|
|
655
|
+
// Step 4: Populate skills (converted from playbooks + curated)
|
|
656
|
+
const skills = template.getSkills(input);
|
|
657
|
+
await this.workspaceManager.writeSkills(workspace, skills);
|
|
658
|
+
|
|
659
|
+
// Step 5: Populate resources (codebase snapshots, docs, etc.)
|
|
660
|
+
const resources = template.getResources(input);
|
|
661
|
+
await this.workspaceManager.writeResources(workspace, resources);
|
|
662
|
+
|
|
663
|
+
// Step 6: Query knowledge
|
|
664
|
+
const knowledge = await this.getKnowledge(template, input);
|
|
665
|
+
|
|
666
|
+
// Step 7: Spawn agent
|
|
667
|
+
const agentResult = await this.agentManager.spawn({
|
|
668
|
+
agentType: template.agentType ?? 'claude-code',
|
|
669
|
+
task: {
|
|
670
|
+
id: `${template.taskType}-${workspace.id}`,
|
|
671
|
+
domain: template.domain,
|
|
672
|
+
description: template.buildTaskPrompt(input),
|
|
673
|
+
},
|
|
674
|
+
cwd: workspace.path,
|
|
675
|
+
injectedKnowledge: knowledge,
|
|
676
|
+
captureToolCalls: template.captureToolCalls ?? true,
|
|
677
|
+
timeout: this.getTimeout(template, complexity),
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// Step 8: Validate output against outputConfig
|
|
681
|
+
const validation = await this.workspaceManager.validateOutput(
|
|
682
|
+
workspace, template.outputConfig
|
|
683
|
+
);
|
|
684
|
+
if (!validation.valid) {
|
|
685
|
+
// Agent may not have finished writing — retry or error
|
|
686
|
+
throw new AgenticTaskOutputError(
|
|
687
|
+
template.taskType,
|
|
688
|
+
new Error(`Missing required output files: ${validation.missing.join(', ')}`)
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// Step 9: Collect and validate output
|
|
693
|
+
const output = await this.collectWithRetry(
|
|
694
|
+
template, workspace, agentResult
|
|
695
|
+
);
|
|
696
|
+
|
|
697
|
+
// Step 10: Process output
|
|
698
|
+
const context: ProcessingContext = {
|
|
699
|
+
memory: this.memory,
|
|
700
|
+
learningPipeline: this.learningPipeline,
|
|
701
|
+
};
|
|
702
|
+
await template.processOutput(output, input, context);
|
|
703
|
+
|
|
704
|
+
// Step 11: Meta-learning — route analysis agent's own trajectory
|
|
705
|
+
// through the individual learning pipeline
|
|
706
|
+
await this.learningPipeline.processTrajectory(
|
|
707
|
+
agentResult.trajectory
|
|
708
|
+
);
|
|
709
|
+
|
|
710
|
+
return {
|
|
711
|
+
output,
|
|
712
|
+
method: 'agentic',
|
|
713
|
+
agentTrajectoryId: agentResult.trajectory.id,
|
|
714
|
+
metrics: {
|
|
715
|
+
totalTimeMs: agentResult.metrics.totalTime,
|
|
716
|
+
tokensUsed: agentResult.metrics.tokenEstimate ?? 0,
|
|
717
|
+
toolCalls: agentResult.metrics.toolCallCount,
|
|
718
|
+
},
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
} finally {
|
|
722
|
+
// Step 12: Cleanup
|
|
723
|
+
if (this.config.cleanupWorkspaces) {
|
|
724
|
+
await this.workspaceManager.cleanup(workspace);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Query knowledge for the analysis agent.
|
|
731
|
+
* Combines domain-scoped query + template-specific additional queries.
|
|
732
|
+
*/
|
|
733
|
+
private async getKnowledge<TInput, TOutput>(
|
|
734
|
+
template: AgenticTaskTemplate<TInput, TOutput>,
|
|
735
|
+
input: TInput
|
|
736
|
+
): Promise<MemoryQueryResultV2> {
|
|
737
|
+
// Always query for playbooks in the template's domain
|
|
738
|
+
// (these are playbooks about HOW to do this type of analysis)
|
|
739
|
+
const domainKnowledge = await this.memory.queryV2(
|
|
740
|
+
template.description,
|
|
741
|
+
{ domains: [template.domain] }
|
|
742
|
+
);
|
|
743
|
+
|
|
744
|
+
// Template-specific additional knowledge
|
|
745
|
+
let additionalKnowledge: MemoryQueryResultV2 | undefined;
|
|
746
|
+
if (template.getAdditionalKnowledge) {
|
|
747
|
+
additionalKnowledge = await template.getAdditionalKnowledge(
|
|
748
|
+
input, this.memory
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return mergeKnowledge(domainKnowledge, additionalKnowledge);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Collect output with retry on validation failure.
|
|
757
|
+
* If the agent produced invalid output, we can optionally
|
|
758
|
+
* send a follow-up message asking it to fix the output.
|
|
759
|
+
*/
|
|
760
|
+
private async collectWithRetry<TInput, TOutput>(
|
|
761
|
+
template: AgenticTaskTemplate<TInput, TOutput>,
|
|
762
|
+
workspace: WorkspaceHandle,
|
|
763
|
+
agentResult: AgentResult,
|
|
764
|
+
maxRetries: number = 1
|
|
765
|
+
): Promise<TOutput> {
|
|
766
|
+
try {
|
|
767
|
+
return await template.collectOutput(workspace.path);
|
|
768
|
+
} catch (validationError) {
|
|
769
|
+
if (maxRetries > 0 && agentResult.session.state === 'completed') {
|
|
770
|
+
// Could send follow-up message to fix output
|
|
771
|
+
// For now, throw
|
|
772
|
+
}
|
|
773
|
+
throw new AgenticTaskOutputError(
|
|
774
|
+
template.taskType,
|
|
775
|
+
validationError as Error
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Get timeout based on template default and complexity.
|
|
782
|
+
*/
|
|
783
|
+
private getTimeout<TInput, TOutput>(
|
|
784
|
+
template: AgenticTaskTemplate<TInput, TOutput>,
|
|
785
|
+
complexity: AnalysisComplexity
|
|
786
|
+
): number {
|
|
787
|
+
const base = template.timeout ?? 120_000;
|
|
788
|
+
switch (complexity) {
|
|
789
|
+
case 'lightweight': return Math.min(base, 60_000);
|
|
790
|
+
case 'standard': return base;
|
|
791
|
+
case 'thorough': return base * 2;
|
|
792
|
+
default: return base;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
interface AgenticTaskResult<TOutput> {
|
|
798
|
+
output: TOutput;
|
|
799
|
+
method: 'heuristic' | 'agentic';
|
|
800
|
+
agentTrajectoryId?: string;
|
|
801
|
+
metrics: {
|
|
802
|
+
totalTimeMs: number;
|
|
803
|
+
tokensUsed: number;
|
|
804
|
+
toolCalls: number;
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
interface AgenticTaskRunnerConfig {
|
|
809
|
+
/** Cleanup workspaces after completion */
|
|
810
|
+
cleanupWorkspaces: boolean; // default: true
|
|
811
|
+
|
|
812
|
+
/** Keep workspaces for failed tasks (for debugging) */
|
|
813
|
+
keepFailedWorkspaces: boolean; // default: true
|
|
814
|
+
|
|
815
|
+
/** Maximum concurrent analysis agents */
|
|
816
|
+
maxConcurrentAgents: number; // default: 3
|
|
817
|
+
|
|
818
|
+
/** Stale workspace cleanup threshold */
|
|
819
|
+
staleWorkspaceMaxAgeMs: number; // default: 3600_000 (1 hour)
|
|
820
|
+
}
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
---
|
|
824
|
+
|
|
825
|
+
## Concrete Templates
|
|
826
|
+
|
|
827
|
+
### Template 1: Trajectory Analysis
|
|
828
|
+
|
|
829
|
+
Replaces the heuristic `TrajectoryAnalyzer` with semantic analysis for complex trajectories.
|
|
830
|
+
|
|
831
|
+
```typescript
|
|
832
|
+
const trajectoryAnalysisTemplate: AgenticTaskTemplate<
|
|
833
|
+
TrajectoryAnalysisInput,
|
|
834
|
+
AnalysisResult
|
|
835
|
+
> = {
|
|
836
|
+
taskType: 'trajectory-analysis',
|
|
837
|
+
domain: 'trajectory-analysis',
|
|
838
|
+
description: 'Analyze agent trajectory for credit assignment and pattern detection',
|
|
839
|
+
|
|
840
|
+
outputConfig: {
|
|
841
|
+
files: [
|
|
842
|
+
{
|
|
843
|
+
path: 'analysis.json',
|
|
844
|
+
format: 'json',
|
|
845
|
+
schema: AnalysisResultSchema,
|
|
846
|
+
required: true,
|
|
847
|
+
description: 'Credit assignment, error patterns, and abstractability assessment',
|
|
848
|
+
},
|
|
849
|
+
],
|
|
850
|
+
},
|
|
851
|
+
|
|
852
|
+
assessComplexity(input) {
|
|
853
|
+
// Short, successful trajectories → heuristic is fine
|
|
854
|
+
if (input.trajectory.steps.length <= 5 && input.trajectory.outcome.success) {
|
|
855
|
+
return 'heuristic';
|
|
856
|
+
}
|
|
857
|
+
// Failed trajectories or complex ones → agent analysis
|
|
858
|
+
if (!input.trajectory.outcome.success || input.trajectory.steps.length > 20) {
|
|
859
|
+
return 'standard';
|
|
860
|
+
}
|
|
861
|
+
return 'lightweight';
|
|
862
|
+
},
|
|
863
|
+
|
|
864
|
+
heuristicFallback(input) {
|
|
865
|
+
// Existing TrajectoryAnalyzer logic — exponential decay + regex patterns
|
|
866
|
+
const analyzer = new TrajectoryAnalyzer(input.creditStrategy);
|
|
867
|
+
return analyzer.analyze(input.trajectory);
|
|
868
|
+
},
|
|
869
|
+
|
|
870
|
+
getSkills(input) {
|
|
871
|
+
// Convert any relevant playbooks about trajectory analysis into SKILL.md
|
|
872
|
+
return convertPlaybooksToSkills(input.analysisPlaybooks ?? []);
|
|
873
|
+
},
|
|
874
|
+
|
|
875
|
+
getResources(input) {
|
|
876
|
+
// No supplementary resources needed for trajectory analysis
|
|
877
|
+
return [];
|
|
878
|
+
},
|
|
879
|
+
|
|
880
|
+
async prepareWorkspace(input, workspacePath) {
|
|
881
|
+
const wm = this.workspaceManager;
|
|
882
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
883
|
+
|
|
884
|
+
// Raw trajectory as JSONL — one step per line, agent can grep/head/tail
|
|
885
|
+
await wm.writeInputJsonl(handle, 'trajectories/execution.jsonl',
|
|
886
|
+
input.trajectory.steps.map(step => ({
|
|
887
|
+
...step,
|
|
888
|
+
// Flatten for greppability
|
|
889
|
+
_action_summary: step.action.slice(0, 200),
|
|
890
|
+
}))
|
|
891
|
+
);
|
|
892
|
+
|
|
893
|
+
// Task context as markdown with YAML frontmatter
|
|
894
|
+
await wm.writeInputMarkdown(handle, 'context.md', {
|
|
895
|
+
taskId: input.trajectory.task.id,
|
|
896
|
+
domain: input.trajectory.task.domain,
|
|
897
|
+
outcome: input.trajectory.outcome.success ? 'success' : 'failure',
|
|
898
|
+
stepCount: input.trajectory.steps.length,
|
|
899
|
+
wallTimeSeconds: input.trajectory.wallTimeSeconds,
|
|
900
|
+
}, `# Task\n\n${input.trajectory.task.description}\n\n` +
|
|
901
|
+
`# Outcome\n\n${input.trajectory.outcome.success ? 'Success' : 'Failure'}\n` +
|
|
902
|
+
(input.trajectory.outcome.errorInfo
|
|
903
|
+
? `\n**Error:** ${input.trajectory.outcome.errorInfo}\n` : '')
|
|
904
|
+
);
|
|
905
|
+
},
|
|
906
|
+
|
|
907
|
+
buildTaskPrompt(input) {
|
|
908
|
+
return `
|
|
909
|
+
Analyze the agent trajectory in this workspace.
|
|
910
|
+
|
|
911
|
+
## Input Files
|
|
912
|
+
- input/context.md — Task description, outcome, and metadata (YAML frontmatter)
|
|
913
|
+
- input/trajectories/execution.jsonl — Full trajectory (one step per line, use grep to search)
|
|
914
|
+
|
|
915
|
+
## Available Skills
|
|
916
|
+
- Check skills/ directory for analysis guidance
|
|
917
|
+
|
|
918
|
+
## Instructions
|
|
919
|
+
1. Read the context to understand what task was attempted and whether it succeeded.
|
|
920
|
+
2. Read the trajectory JSONL. Use grep to find error patterns, key actions, etc.
|
|
921
|
+
3. For each step, assess its causal contribution to the outcome.
|
|
922
|
+
Write reasoning about WHY each step mattered or didn't.
|
|
923
|
+
4. Identify error patterns — not just by regex, but by understanding
|
|
924
|
+
what went wrong and why.
|
|
925
|
+
5. Determine if this trajectory contains abstractable patterns
|
|
926
|
+
worth extracting into playbooks.
|
|
927
|
+
|
|
928
|
+
## Output
|
|
929
|
+
Write your analysis to output/analysis.json matching the required schema.
|
|
930
|
+
Use workspace/ for intermediate notes.
|
|
931
|
+
`;
|
|
932
|
+
},
|
|
933
|
+
|
|
934
|
+
async collectOutput(workspacePath) {
|
|
935
|
+
// Read and validate output/analysis.json against AnalysisResult schema
|
|
936
|
+
},
|
|
937
|
+
|
|
938
|
+
async processOutput(output, input, context) {
|
|
939
|
+
// Apply attribution scores to trajectory steps
|
|
940
|
+
// Store in experience memory
|
|
941
|
+
},
|
|
942
|
+
};
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
**Workspace layout:**
|
|
946
|
+
```
|
|
947
|
+
input/
|
|
948
|
+
context.md # YAML frontmatter: taskId, domain, outcome, stepCount
|
|
949
|
+
trajectories/
|
|
950
|
+
execution.jsonl # One step per line — raw trajectory data
|
|
951
|
+
skills/
|
|
952
|
+
trajectory-analysis/
|
|
953
|
+
SKILL.md # Converted from analysis playbooks
|
|
954
|
+
resources/ # (empty for this template)
|
|
955
|
+
workspace/ # Agent scratch space
|
|
956
|
+
output/
|
|
957
|
+
analysis.json # AnalysisResult (validated against schema)
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
### Template 2: Playbook Extraction
|
|
961
|
+
|
|
962
|
+
Replaces both `PlaybookExtractor` (heuristic) and `LLMPlaybookExtractor` (single-call) with iterative agentic extraction.
|
|
963
|
+
|
|
964
|
+
```typescript
|
|
965
|
+
const playbookExtractionTemplate: AgenticTaskTemplate<
|
|
966
|
+
PlaybookExtractionInput,
|
|
967
|
+
ExtractedPlaybooks
|
|
968
|
+
> = {
|
|
969
|
+
taskType: 'playbook-extraction',
|
|
970
|
+
domain: 'playbook-extraction',
|
|
971
|
+
description: 'Extract reusable playbooks from trajectory batch',
|
|
972
|
+
timeout: 300_000, // 5 minutes — analyzing multiple trajectories
|
|
973
|
+
|
|
974
|
+
outputConfig: {
|
|
975
|
+
files: [
|
|
976
|
+
{
|
|
977
|
+
path: 'playbooks/',
|
|
978
|
+
format: 'json',
|
|
979
|
+
required: false, // May find no new playbooks
|
|
980
|
+
description: 'Newly extracted playbooks (one JSON per playbook)',
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
path: 'skills/',
|
|
984
|
+
format: 'skill-md',
|
|
985
|
+
required: false,
|
|
986
|
+
description: 'Newly extracted skills in SKILL.md format',
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
path: 'updates/',
|
|
990
|
+
format: 'json',
|
|
991
|
+
required: false,
|
|
992
|
+
description: 'Updates to existing playbooks',
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
path: 'extraction-summary.json',
|
|
996
|
+
format: 'json',
|
|
997
|
+
required: true,
|
|
998
|
+
description: 'Summary of extraction results: counts, patterns found, confidence',
|
|
999
|
+
},
|
|
1000
|
+
],
|
|
1001
|
+
},
|
|
1002
|
+
|
|
1003
|
+
assessComplexity(input) {
|
|
1004
|
+
// Small batches with clear patterns → heuristic
|
|
1005
|
+
if (input.trajectories.length <= 3) return 'heuristic';
|
|
1006
|
+
// Large diverse batches → thorough agent analysis
|
|
1007
|
+
if (input.trajectories.length > 10) return 'thorough';
|
|
1008
|
+
return 'standard';
|
|
1009
|
+
},
|
|
1010
|
+
|
|
1011
|
+
heuristicFallback(input) {
|
|
1012
|
+
// Existing PlaybookExtractor logic
|
|
1013
|
+
const extractor = new PlaybookExtractor();
|
|
1014
|
+
return extractor.extract(input.trajectories, input.analyses, input.existingPlaybooks);
|
|
1015
|
+
},
|
|
1016
|
+
|
|
1017
|
+
getSkills(input) {
|
|
1018
|
+
return convertPlaybooksToSkills(input.extractionPlaybooks ?? []);
|
|
1019
|
+
},
|
|
1020
|
+
|
|
1021
|
+
getResources(input) {
|
|
1022
|
+
// No supplementary resources typically needed
|
|
1023
|
+
return [];
|
|
1024
|
+
},
|
|
1025
|
+
|
|
1026
|
+
async prepareWorkspace(input, workspacePath) {
|
|
1027
|
+
const wm = this.workspaceManager;
|
|
1028
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
1029
|
+
|
|
1030
|
+
// Batch summary as markdown with frontmatter
|
|
1031
|
+
await wm.writeInputMarkdown(handle, 'summary.md', {
|
|
1032
|
+
batchSize: input.trajectories.length,
|
|
1033
|
+
domains: [...new Set(input.trajectories.map(t => t.task.domain))],
|
|
1034
|
+
successRate: input.trajectories.filter(t => t.outcome.success).length / input.trajectories.length,
|
|
1035
|
+
dateRange: {
|
|
1036
|
+
earliest: input.trajectories[0]?.metadata?.timestamp,
|
|
1037
|
+
latest: input.trajectories[input.trajectories.length - 1]?.metadata?.timestamp,
|
|
1038
|
+
},
|
|
1039
|
+
}, `# Trajectory Batch Summary\n\nThis batch contains ${input.trajectories.length} trajectories for pattern extraction.`);
|
|
1040
|
+
|
|
1041
|
+
// Each trajectory as JSONL — raw data, agent can grep across all
|
|
1042
|
+
for (const trajectory of input.trajectories) {
|
|
1043
|
+
await wm.writeInputJsonl(handle,
|
|
1044
|
+
`trajectories/${trajectory.id}.jsonl`,
|
|
1045
|
+
trajectory.steps
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// Analyses as derivative data (from previous pipeline stage)
|
|
1050
|
+
for (const analysis of input.analyses) {
|
|
1051
|
+
await wm.writeInputJson(handle,
|
|
1052
|
+
`analyses/${analysis.trajectoryId}.json`,
|
|
1053
|
+
analysis
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// Existing playbooks for deduplication
|
|
1058
|
+
for (const playbook of input.existingPlaybooks) {
|
|
1059
|
+
await wm.writeInputJson(handle,
|
|
1060
|
+
`existing-playbooks/${playbook.name}.json`,
|
|
1061
|
+
playbook
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
|
|
1066
|
+
buildTaskPrompt(input) {
|
|
1067
|
+
return `
|
|
1068
|
+
Extract reusable playbooks from the trajectory batch in this workspace.
|
|
1069
|
+
|
|
1070
|
+
## Input Files
|
|
1071
|
+
- input/summary.md — Batch overview with metadata (YAML frontmatter)
|
|
1072
|
+
- input/trajectories/*.jsonl — Raw trajectories (one step per line, use grep across all)
|
|
1073
|
+
- input/analyses/*.json — Analysis results from previous pipeline stage (derivative data)
|
|
1074
|
+
- input/existing-playbooks/*.json — Current playbooks for deduplication
|
|
1075
|
+
|
|
1076
|
+
## Available Skills
|
|
1077
|
+
- Check skills/ directory for extraction guidance
|
|
1078
|
+
|
|
1079
|
+
## Instructions
|
|
1080
|
+
1. Read the summary for batch overview.
|
|
1081
|
+
2. Read analyses for each trajectory — these contain credit assignments and patterns.
|
|
1082
|
+
3. Grep across raw trajectories to identify recurring action patterns.
|
|
1083
|
+
4. Identify common patterns across successful trajectories:
|
|
1084
|
+
- Recurring strategies (not just action sequences — semantic patterns)
|
|
1085
|
+
- Error recovery approaches that worked
|
|
1086
|
+
- Domain-specific techniques
|
|
1087
|
+
5. Check against existing playbooks — if a pattern matches, generate an update.
|
|
1088
|
+
6. For each new playbook, provide:
|
|
1089
|
+
- Clear name, situations, triggers
|
|
1090
|
+
- Strategy and tactics (actionable, not generic)
|
|
1091
|
+
- Verification criteria
|
|
1092
|
+
- Confidence based on evidence strength
|
|
1093
|
+
|
|
1094
|
+
## Output
|
|
1095
|
+
- Write new playbooks to output/playbooks/ (JSON)
|
|
1096
|
+
- Write new skills to output/skills/ (SKILL.md format)
|
|
1097
|
+
- Write updates to output/updates/ (JSON)
|
|
1098
|
+
- Write extraction summary to output/extraction-summary.json (required)
|
|
1099
|
+
- Use workspace/ for notes and pattern analysis.
|
|
1100
|
+
`;
|
|
1101
|
+
},
|
|
1102
|
+
|
|
1103
|
+
async collectOutput(workspacePath) {
|
|
1104
|
+
// Read output/playbooks/*.json, output/skills/*/SKILL.md, output/updates/*.json
|
|
1105
|
+
},
|
|
1106
|
+
|
|
1107
|
+
async processOutput(output, input, context) {
|
|
1108
|
+
// Add new playbooks to PlaybookLibrary
|
|
1109
|
+
// Convert new SKILL.md files to playbooks (or store as skills)
|
|
1110
|
+
// Apply updates to existing playbooks
|
|
1111
|
+
},
|
|
1112
|
+
};
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
**Workspace layout:**
|
|
1116
|
+
```
|
|
1117
|
+
input/
|
|
1118
|
+
summary.md # YAML frontmatter: batchSize, domains, successRate
|
|
1119
|
+
trajectories/
|
|
1120
|
+
traj-001.jsonl # Raw trajectory — one step per line
|
|
1121
|
+
traj-002.jsonl
|
|
1122
|
+
...
|
|
1123
|
+
analyses/ # Derivative data from prior analysis
|
|
1124
|
+
traj-001.json
|
|
1125
|
+
traj-002.json
|
|
1126
|
+
...
|
|
1127
|
+
existing-playbooks/
|
|
1128
|
+
*.json
|
|
1129
|
+
skills/
|
|
1130
|
+
playbook-extraction/
|
|
1131
|
+
SKILL.md # Guidance on how to extract playbooks
|
|
1132
|
+
resources/ # (empty for this template)
|
|
1133
|
+
workspace/ # Agent scratch space
|
|
1134
|
+
output/
|
|
1135
|
+
playbooks/ # New playbooks (JSON)
|
|
1136
|
+
skills/ # New skills (SKILL.md format)
|
|
1137
|
+
updates/ # Updates to existing playbooks
|
|
1138
|
+
extraction-summary.json # Required summary of results
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
### Template 3: Meta-Learning Reflection
|
|
1142
|
+
|
|
1143
|
+
Replaces the heuristic `MetaLearner.generateReflection()` with semantic analysis.
|
|
1144
|
+
|
|
1145
|
+
```typescript
|
|
1146
|
+
const metaReflectionTemplate: AgenticTaskTemplate<
|
|
1147
|
+
MetaReflectionInput,
|
|
1148
|
+
MetaObservation
|
|
1149
|
+
> = {
|
|
1150
|
+
taskType: 'meta-reflection',
|
|
1151
|
+
domain: 'meta-reflection',
|
|
1152
|
+
description: 'Reflect on task execution to generate meta-learning observations',
|
|
1153
|
+
|
|
1154
|
+
outputConfig: {
|
|
1155
|
+
files: [
|
|
1156
|
+
{
|
|
1157
|
+
path: 'meta-observation.json',
|
|
1158
|
+
format: 'json',
|
|
1159
|
+
schema: MetaObservationSchema,
|
|
1160
|
+
required: true,
|
|
1161
|
+
description: 'Reflection observations: what worked, what failed, lessons learned',
|
|
1162
|
+
},
|
|
1163
|
+
],
|
|
1164
|
+
},
|
|
1165
|
+
|
|
1166
|
+
assessComplexity(input) {
|
|
1167
|
+
// Simple successful tasks with clear routing → heuristic
|
|
1168
|
+
if (input.trajectory.outcome.success &&
|
|
1169
|
+
input.routingDecision.confidence > 0.8) {
|
|
1170
|
+
return 'heuristic';
|
|
1171
|
+
}
|
|
1172
|
+
// Failed tasks or uncertain routing → agent reflection
|
|
1173
|
+
return 'lightweight';
|
|
1174
|
+
},
|
|
1175
|
+
|
|
1176
|
+
heuristicFallback(input) {
|
|
1177
|
+
// Existing MetaLearner logic
|
|
1178
|
+
},
|
|
1179
|
+
|
|
1180
|
+
getSkills(input) {
|
|
1181
|
+
return convertPlaybooksToSkills(input.reflectionPlaybooks ?? []);
|
|
1182
|
+
},
|
|
1183
|
+
|
|
1184
|
+
getResources(input) {
|
|
1185
|
+
return [];
|
|
1186
|
+
},
|
|
1187
|
+
|
|
1188
|
+
async prepareWorkspace(input, workspacePath) {
|
|
1189
|
+
const wm = this.workspaceManager;
|
|
1190
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
1191
|
+
|
|
1192
|
+
// Raw trajectory as JSONL
|
|
1193
|
+
await wm.writeInputJsonl(handle, 'trajectories/execution.jsonl',
|
|
1194
|
+
input.trajectory.steps
|
|
1195
|
+
);
|
|
1196
|
+
|
|
1197
|
+
// Context with routing decision and injected playbooks
|
|
1198
|
+
await wm.writeInputMarkdown(handle, 'context.md', {
|
|
1199
|
+
taskId: input.trajectory.task.id,
|
|
1200
|
+
domain: input.trajectory.task.domain,
|
|
1201
|
+
outcome: input.trajectory.outcome.success ? 'success' : 'failure',
|
|
1202
|
+
routingStrategy: input.routingDecision.strategy,
|
|
1203
|
+
routingConfidence: input.routingDecision.confidence,
|
|
1204
|
+
playbooksInjected: input.playbooksUsed.map(p => p.name),
|
|
1205
|
+
}, `# Task\n\n${input.trajectory.task.description}\n\n` +
|
|
1206
|
+
`# Routing Decision\n\n` +
|
|
1207
|
+
`Strategy: ${input.routingDecision.strategy}\n` +
|
|
1208
|
+
`Reasoning: ${input.routingDecision.reasoning}\n\n` +
|
|
1209
|
+
`# Injected Playbooks\n\n` +
|
|
1210
|
+
input.playbooksUsed.map(p =>
|
|
1211
|
+
`- **${p.name}**: ${p.guidance.strategy}`
|
|
1212
|
+
).join('\n')
|
|
1213
|
+
);
|
|
1214
|
+
},
|
|
1215
|
+
|
|
1216
|
+
buildTaskPrompt(input) {
|
|
1217
|
+
return `
|
|
1218
|
+
Reflect on the task execution to understand what worked and what didn't.
|
|
1219
|
+
|
|
1220
|
+
## Input Files
|
|
1221
|
+
- input/context.md — Task, routing decision, and injected playbooks (YAML frontmatter)
|
|
1222
|
+
- input/trajectories/execution.jsonl — Full trajectory (one step per line)
|
|
1223
|
+
|
|
1224
|
+
## Instructions
|
|
1225
|
+
1. Read the context — was the chosen strategy appropriate for this task?
|
|
1226
|
+
2. Review which playbooks were injected — were they actually helpful?
|
|
1227
|
+
Did the agent follow the guidance? Was the guidance relevant?
|
|
1228
|
+
3. Analyze the trajectory — identify execution patterns:
|
|
1229
|
+
- Was decomposition used? Was it effective?
|
|
1230
|
+
- Were there refinement iterations? Were they productive?
|
|
1231
|
+
- Was there backtracking or wasted effort?
|
|
1232
|
+
4. Assess the outcome quality relative to the effort expended.
|
|
1233
|
+
5. Generate concrete lessons: what worked, what failed, what to change next time.
|
|
1234
|
+
|
|
1235
|
+
## Output
|
|
1236
|
+
Write your reflection to output/meta-observation.json.
|
|
1237
|
+
`;
|
|
1238
|
+
},
|
|
1239
|
+
|
|
1240
|
+
async collectOutput(workspacePath) {
|
|
1241
|
+
// Read output/meta-observation.json
|
|
1242
|
+
},
|
|
1243
|
+
|
|
1244
|
+
async processOutput(output, input, context) {
|
|
1245
|
+
// Store in MetaMemory
|
|
1246
|
+
// Check if strategy generation threshold reached
|
|
1247
|
+
},
|
|
1248
|
+
};
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
### Template 4: Usage Inference
|
|
1252
|
+
|
|
1253
|
+
Replaces the heuristic `PlaybookUsageInference` with semantic matching.
|
|
1254
|
+
|
|
1255
|
+
```typescript
|
|
1256
|
+
const usageInferenceTemplate: AgenticTaskTemplate<
|
|
1257
|
+
UsageInferenceInput,
|
|
1258
|
+
PlaybookUsageResult[]
|
|
1259
|
+
> = {
|
|
1260
|
+
taskType: 'usage-inference',
|
|
1261
|
+
domain: 'usage-inference',
|
|
1262
|
+
description: 'Determine which injected playbooks were actually followed',
|
|
1263
|
+
|
|
1264
|
+
outputConfig: {
|
|
1265
|
+
files: [
|
|
1266
|
+
{
|
|
1267
|
+
path: 'usage-results.json',
|
|
1268
|
+
format: 'json',
|
|
1269
|
+
schema: PlaybookUsageResultArraySchema,
|
|
1270
|
+
required: true,
|
|
1271
|
+
description: 'Per-playbook usage assessment: followed, partially, not followed, helpfulness',
|
|
1272
|
+
},
|
|
1273
|
+
],
|
|
1274
|
+
},
|
|
1275
|
+
|
|
1276
|
+
assessComplexity(input) {
|
|
1277
|
+
// No playbooks injected → trivial
|
|
1278
|
+
if (input.injectedPlaybooks.length === 0) return 'heuristic';
|
|
1279
|
+
// Few playbooks, short trajectory → heuristic word matching is OK
|
|
1280
|
+
if (input.injectedPlaybooks.length <= 2 &&
|
|
1281
|
+
input.trajectory.steps.length <= 10) {
|
|
1282
|
+
return 'heuristic';
|
|
1283
|
+
}
|
|
1284
|
+
return 'lightweight';
|
|
1285
|
+
},
|
|
1286
|
+
|
|
1287
|
+
heuristicFallback(input) {
|
|
1288
|
+
// Existing PlaybookUsageInference logic
|
|
1289
|
+
const inference = new PlaybookUsageInference();
|
|
1290
|
+
return inference.inferUsage(input.trajectory, input.injectedPlaybooks);
|
|
1291
|
+
},
|
|
1292
|
+
|
|
1293
|
+
getSkills(input) {
|
|
1294
|
+
return convertPlaybooksToSkills(input.inferencePlaybooks ?? []);
|
|
1295
|
+
},
|
|
1296
|
+
|
|
1297
|
+
getResources(input) {
|
|
1298
|
+
return [];
|
|
1299
|
+
},
|
|
1300
|
+
|
|
1301
|
+
async prepareWorkspace(input, workspacePath) {
|
|
1302
|
+
const wm = this.workspaceManager;
|
|
1303
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
1304
|
+
|
|
1305
|
+
// Raw trajectory as JSONL
|
|
1306
|
+
await wm.writeInputJsonl(handle, 'trajectories/execution.jsonl',
|
|
1307
|
+
input.trajectory.steps
|
|
1308
|
+
);
|
|
1309
|
+
|
|
1310
|
+
// Each injected playbook as its own markdown file
|
|
1311
|
+
for (const playbook of input.injectedPlaybooks) {
|
|
1312
|
+
await wm.writeInputMarkdown(handle, `playbooks/${playbook.name}.md`, {
|
|
1313
|
+
playbookId: playbook.id,
|
|
1314
|
+
name: playbook.name,
|
|
1315
|
+
confidence: playbook.confidence,
|
|
1316
|
+
domains: playbook.applicability.domains,
|
|
1317
|
+
}, `# ${playbook.name}\n\n` +
|
|
1318
|
+
`## Strategy\n${playbook.guidance.strategy}\n\n` +
|
|
1319
|
+
`## Tactics\n${playbook.guidance.tactics.map(t => `- ${t}`).join('\n')}\n\n` +
|
|
1320
|
+
(playbook.guidance.steps
|
|
1321
|
+
? `## Steps\n${playbook.guidance.steps.map((s, i) => `${i+1}. ${s}`).join('\n')}\n`
|
|
1322
|
+
: '')
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
},
|
|
1326
|
+
|
|
1327
|
+
buildTaskPrompt(input) {
|
|
1328
|
+
return `
|
|
1329
|
+
Determine which injected playbooks were actually followed during the trajectory.
|
|
1330
|
+
|
|
1331
|
+
## Input Files
|
|
1332
|
+
- input/trajectories/execution.jsonl — Full trajectory (one step per line)
|
|
1333
|
+
- input/playbooks/*.md — Each injected playbook (YAML frontmatter + guidance)
|
|
1334
|
+
|
|
1335
|
+
## Instructions
|
|
1336
|
+
For each playbook:
|
|
1337
|
+
1. Read its strategy, tactics, and steps from the markdown file.
|
|
1338
|
+
2. Grep the trajectory for evidence of following the guidance.
|
|
1339
|
+
Look for semantic alignment, not just keyword matching.
|
|
1340
|
+
3. Assess confidence: clearly followed, partially followed, or not followed?
|
|
1341
|
+
4. If followed, was it helpful to the outcome?
|
|
1342
|
+
|
|
1343
|
+
## Output
|
|
1344
|
+
Write results to output/usage-results.json.
|
|
1345
|
+
`;
|
|
1346
|
+
},
|
|
1347
|
+
|
|
1348
|
+
async collectOutput(workspacePath) {
|
|
1349
|
+
// Read output/usage-results.json
|
|
1350
|
+
},
|
|
1351
|
+
|
|
1352
|
+
async processOutput(output, input, context) {
|
|
1353
|
+
// Update playbook success/failure counts in SkillLibrary
|
|
1354
|
+
// Feed into effectiveness tracker
|
|
1355
|
+
},
|
|
1356
|
+
};
|
|
1357
|
+
```
|
|
1358
|
+
|
|
1359
|
+
### Template 5: Solution Evaluation
|
|
1360
|
+
|
|
1361
|
+
Enhances the existing `evaluator.ts` Tier 2 with a workspace.
|
|
1362
|
+
|
|
1363
|
+
```typescript
|
|
1364
|
+
const solutionEvaluationTemplate: AgenticTaskTemplate<
|
|
1365
|
+
SolutionEvaluationInput,
|
|
1366
|
+
EvaluationResult
|
|
1367
|
+
> = {
|
|
1368
|
+
taskType: 'solution-evaluation',
|
|
1369
|
+
domain: 'solution-evaluation',
|
|
1370
|
+
description: 'Evaluate solution quality from trajectory',
|
|
1371
|
+
|
|
1372
|
+
outputConfig: {
|
|
1373
|
+
files: [
|
|
1374
|
+
{
|
|
1375
|
+
path: 'evaluation.json',
|
|
1376
|
+
format: 'json',
|
|
1377
|
+
schema: EvaluationResultSchema,
|
|
1378
|
+
required: true,
|
|
1379
|
+
description: 'Quality assessment: meets requirements, edge cases, overall rating',
|
|
1380
|
+
},
|
|
1381
|
+
],
|
|
1382
|
+
},
|
|
1383
|
+
|
|
1384
|
+
assessComplexity(input) {
|
|
1385
|
+
// Has programmatic verification → use that, skip agent
|
|
1386
|
+
if (input.task.verification) return 'heuristic';
|
|
1387
|
+
// Short successful trajectory → lightweight check
|
|
1388
|
+
if (input.trajectory.outcome.success &&
|
|
1389
|
+
input.trajectory.steps.length <= 10) {
|
|
1390
|
+
return 'lightweight';
|
|
1391
|
+
}
|
|
1392
|
+
return 'standard';
|
|
1393
|
+
},
|
|
1394
|
+
|
|
1395
|
+
heuristicFallback(input) {
|
|
1396
|
+
// Existing Tier 1 (verification) + Tier 3 (heuristic) logic
|
|
1397
|
+
},
|
|
1398
|
+
|
|
1399
|
+
getSkills(input) {
|
|
1400
|
+
return convertPlaybooksToSkills(input.evaluationPlaybooks ?? []);
|
|
1401
|
+
},
|
|
1402
|
+
|
|
1403
|
+
getResources(input) {
|
|
1404
|
+
// For code evaluation, include codebase snapshot if available
|
|
1405
|
+
if (input.codebasePath) {
|
|
1406
|
+
return [{
|
|
1407
|
+
path: 'codebase',
|
|
1408
|
+
type: 'symlink' as const,
|
|
1409
|
+
source: input.codebasePath,
|
|
1410
|
+
description: 'Codebase snapshot for verifying solution against actual code',
|
|
1411
|
+
}];
|
|
1412
|
+
}
|
|
1413
|
+
return [];
|
|
1414
|
+
},
|
|
1415
|
+
|
|
1416
|
+
async prepareWorkspace(input, workspacePath) {
|
|
1417
|
+
const wm = this.workspaceManager;
|
|
1418
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
1419
|
+
|
|
1420
|
+
// Raw trajectory as JSONL
|
|
1421
|
+
await wm.writeInputJsonl(handle, 'trajectories/execution.jsonl',
|
|
1422
|
+
input.trajectory.steps
|
|
1423
|
+
);
|
|
1424
|
+
|
|
1425
|
+
// Task and solution context
|
|
1426
|
+
await wm.writeInputMarkdown(handle, 'context.md', {
|
|
1427
|
+
taskId: input.task.id,
|
|
1428
|
+
domain: input.task.domain,
|
|
1429
|
+
outcome: input.trajectory.outcome.success ? 'success' : 'failure',
|
|
1430
|
+
hasSolution: input.solution !== undefined,
|
|
1431
|
+
}, `# Task\n\n${input.task.description}\n\n` +
|
|
1432
|
+
`# Solution\n\n\`\`\`\n${JSON.stringify(input.solution, null, 2)}\n\`\`\`\n`
|
|
1433
|
+
);
|
|
1434
|
+
},
|
|
1435
|
+
|
|
1436
|
+
buildTaskPrompt(input) {
|
|
1437
|
+
return `
|
|
1438
|
+
Evaluate the quality of the solution produced by the agent.
|
|
1439
|
+
|
|
1440
|
+
## Input Files
|
|
1441
|
+
- input/context.md — Task description and solution (YAML frontmatter)
|
|
1442
|
+
- input/trajectories/execution.jsonl — Full trajectory (one step per line)
|
|
1443
|
+
${input.codebasePath ? '- resources/codebase/ — Codebase snapshot for verification' : ''}
|
|
1444
|
+
|
|
1445
|
+
## Instructions
|
|
1446
|
+
1. Read the original task and its success criteria from context.md.
|
|
1447
|
+
2. Grep the trajectory for key decision points and the approach taken.
|
|
1448
|
+
3. Assess:
|
|
1449
|
+
- Does the solution meet the stated requirements?
|
|
1450
|
+
- Are there edge cases or failure modes?
|
|
1451
|
+
- Is the approach efficient or over-engineered?
|
|
1452
|
+
- What is the overall quality (excellent/good/acceptable/poor)?
|
|
1453
|
+
4. If codebase is available, verify the solution against actual code.
|
|
1454
|
+
|
|
1455
|
+
## Output
|
|
1456
|
+
Write evaluation to output/evaluation.json.
|
|
1457
|
+
`;
|
|
1458
|
+
},
|
|
1459
|
+
|
|
1460
|
+
async collectOutput(workspacePath) {
|
|
1461
|
+
// Read output/evaluation.json
|
|
1462
|
+
},
|
|
1463
|
+
|
|
1464
|
+
async processOutput(output, input, context) {
|
|
1465
|
+
// Return to refinement loop if needed
|
|
1466
|
+
},
|
|
1467
|
+
};
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
### Template 6: Team Analysis
|
|
1471
|
+
|
|
1472
|
+
The team-specific template from `DESIGN-team-extraction-pipeline.md`, now using the standard workspace infrastructure.
|
|
1473
|
+
|
|
1474
|
+
```typescript
|
|
1475
|
+
const teamAnalysisTemplate: AgenticTaskTemplate<
|
|
1476
|
+
TeamAnalysisInput,
|
|
1477
|
+
TeamAnalysisResult
|
|
1478
|
+
> = {
|
|
1479
|
+
taskType: 'team-analysis',
|
|
1480
|
+
domain: 'team-analysis',
|
|
1481
|
+
description: 'Analyze multi-agent team execution and extract learning signals',
|
|
1482
|
+
timeout: 300_000,
|
|
1483
|
+
|
|
1484
|
+
outputConfig: {
|
|
1485
|
+
files: [
|
|
1486
|
+
{
|
|
1487
|
+
path: 'agent-credits.json',
|
|
1488
|
+
format: 'json',
|
|
1489
|
+
required: true,
|
|
1490
|
+
description: 'Per-agent credit assignment based on causal contribution',
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
path: 'interaction-credits.json',
|
|
1494
|
+
format: 'json',
|
|
1495
|
+
required: true,
|
|
1496
|
+
description: 'Per-interaction credit assignment',
|
|
1497
|
+
},
|
|
1498
|
+
{
|
|
1499
|
+
path: 'coordination-assessment.md',
|
|
1500
|
+
format: 'markdown',
|
|
1501
|
+
required: true,
|
|
1502
|
+
description: 'Overall coordination quality assessment',
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
path: 'lessons.json',
|
|
1506
|
+
format: 'json',
|
|
1507
|
+
required: true,
|
|
1508
|
+
description: 'Role-specific and team-level lessons extracted',
|
|
1509
|
+
},
|
|
1510
|
+
],
|
|
1511
|
+
},
|
|
1512
|
+
|
|
1513
|
+
assessComplexity(input) {
|
|
1514
|
+
// Small teams with clear outcomes → lightweight
|
|
1515
|
+
if (input.members.length <= 2) return 'lightweight';
|
|
1516
|
+
// Large teams or complex failures → thorough
|
|
1517
|
+
if (input.members.length > 5 || !input.outcome.success) return 'thorough';
|
|
1518
|
+
return 'standard';
|
|
1519
|
+
},
|
|
1520
|
+
|
|
1521
|
+
// No heuristic fallback — team analysis always needs semantic understanding
|
|
1522
|
+
|
|
1523
|
+
getSkills(input) {
|
|
1524
|
+
return convertPlaybooksToSkills(input.teamAnalysisPlaybooks ?? []);
|
|
1525
|
+
},
|
|
1526
|
+
|
|
1527
|
+
getResources(input) {
|
|
1528
|
+
// For coding teams, include codebase snapshot
|
|
1529
|
+
if (input.codebasePath) {
|
|
1530
|
+
return [{
|
|
1531
|
+
path: 'codebase',
|
|
1532
|
+
type: 'symlink' as const,
|
|
1533
|
+
source: input.codebasePath,
|
|
1534
|
+
description: 'Codebase for verifying team code contributions',
|
|
1535
|
+
}];
|
|
1536
|
+
}
|
|
1537
|
+
return [];
|
|
1538
|
+
},
|
|
1539
|
+
|
|
1540
|
+
async prepareWorkspace(input, workspacePath) {
|
|
1541
|
+
const wm = this.workspaceManager;
|
|
1542
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
1543
|
+
|
|
1544
|
+
// Team context as markdown with frontmatter
|
|
1545
|
+
await wm.writeInputMarkdown(handle, 'context.md', {
|
|
1546
|
+
objective: input.objective,
|
|
1547
|
+
teamSize: input.members.length,
|
|
1548
|
+
roles: input.members.map(m => m.role),
|
|
1549
|
+
outcome: input.outcome.success ? 'success' : 'failure',
|
|
1550
|
+
totalInteractions: input.interactions.length,
|
|
1551
|
+
}, `# Team Objective\n\n${input.objective}\n\n` +
|
|
1552
|
+
`# Team Composition\n\n` +
|
|
1553
|
+
input.members.map(m => `- **${m.role}** (${m.agentType}): ${m.description ?? 'N/A'}`).join('\n') +
|
|
1554
|
+
`\n\n# Outcome\n\n${input.outcome.success ? 'Success' : 'Failure'}` +
|
|
1555
|
+
(input.outcome.errorInfo ? `\n\n**Error:** ${input.outcome.errorInfo}` : '')
|
|
1556
|
+
);
|
|
1557
|
+
|
|
1558
|
+
// Each agent's trajectory as JSONL — raw data
|
|
1559
|
+
for (const member of input.members) {
|
|
1560
|
+
await wm.writeInputJsonl(handle,
|
|
1561
|
+
`trajectories/${member.role}.jsonl`,
|
|
1562
|
+
member.trajectory.steps
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// Interaction graph and timeline as JSON (structured data)
|
|
1567
|
+
await wm.writeInputJson(handle, 'interactions/graph.json', input.interactionGraph);
|
|
1568
|
+
await wm.writeInputJson(handle, 'interactions/timeline.json', input.interactions);
|
|
1569
|
+
|
|
1570
|
+
// Structural metrics (pre-computed, lightweight)
|
|
1571
|
+
await wm.writeInputJson(handle, 'structural-metrics.json', input.structuralMetrics);
|
|
1572
|
+
},
|
|
1573
|
+
|
|
1574
|
+
buildTaskPrompt(input) {
|
|
1575
|
+
return `
|
|
1576
|
+
Analyze this multi-agent team execution to extract learning signals.
|
|
1577
|
+
|
|
1578
|
+
## Input Files
|
|
1579
|
+
- input/context.md — Team objective, composition, and outcome (YAML frontmatter)
|
|
1580
|
+
- input/trajectories/*.jsonl — Per-agent raw trajectories (one step per line)
|
|
1581
|
+
- input/interactions/graph.json — Interaction graph (nodes = agents, edges = interactions)
|
|
1582
|
+
- input/interactions/timeline.json — Chronological interaction sequence
|
|
1583
|
+
- input/structural-metrics.json — Pre-computed structural metrics
|
|
1584
|
+
${input.codebasePath ? '- resources/codebase/ — Codebase snapshot' : ''}
|
|
1585
|
+
|
|
1586
|
+
## Available Skills
|
|
1587
|
+
- Check skills/ directory for team analysis guidance
|
|
1588
|
+
|
|
1589
|
+
## Instructions
|
|
1590
|
+
1. Read context.md for team overview and outcome.
|
|
1591
|
+
2. Grep across per-agent trajectories for cross-references and coordination patterns.
|
|
1592
|
+
3. Analyze the interaction graph for communication bottlenecks, delegation chains.
|
|
1593
|
+
4. Assess each agent's causal contribution to the team outcome (credit assignment).
|
|
1594
|
+
5. Evaluate coordination quality: was delegation effective? Were handoffs clean?
|
|
1595
|
+
6. Extract role-specific and team-level lessons.
|
|
1596
|
+
|
|
1597
|
+
## Output
|
|
1598
|
+
- output/agent-credits.json — Per-agent credit scores with reasoning
|
|
1599
|
+
- output/interaction-credits.json — Per-interaction effectiveness scores
|
|
1600
|
+
- output/coordination-assessment.md — Qualitative coordination assessment
|
|
1601
|
+
- output/lessons.json — Extracted lessons (role-specific + team-level)
|
|
1602
|
+
`;
|
|
1603
|
+
},
|
|
1604
|
+
|
|
1605
|
+
async getAdditionalKnowledge(input, memory) {
|
|
1606
|
+
// Query for team playbooks matching this task type
|
|
1607
|
+
// Query for past team analysis experiences
|
|
1608
|
+
},
|
|
1609
|
+
|
|
1610
|
+
async collectOutput(workspacePath) {
|
|
1611
|
+
// Read all output files
|
|
1612
|
+
},
|
|
1613
|
+
|
|
1614
|
+
async processOutput(output, input, context) {
|
|
1615
|
+
// Store in TeamExperienceMemory
|
|
1616
|
+
// Record TeamMetaObservation
|
|
1617
|
+
// Accumulate for batch playbook extraction
|
|
1618
|
+
},
|
|
1619
|
+
};
|
|
1620
|
+
```
|
|
1621
|
+
|
|
1622
|
+
### Template 7: Team Playbook Extraction
|
|
1623
|
+
|
|
1624
|
+
```typescript
|
|
1625
|
+
const teamPlaybookExtractionTemplate: AgenticTaskTemplate<
|
|
1626
|
+
TeamPlaybookExtractionInput,
|
|
1627
|
+
ExtractedTeamPlaybooks
|
|
1628
|
+
> = {
|
|
1629
|
+
taskType: 'team-playbook-extraction',
|
|
1630
|
+
domain: 'team-playbook-extraction',
|
|
1631
|
+
description: 'Extract team coordination and role playbooks from lesson batch',
|
|
1632
|
+
timeout: 600_000,
|
|
1633
|
+
|
|
1634
|
+
outputConfig: {
|
|
1635
|
+
files: [
|
|
1636
|
+
{
|
|
1637
|
+
path: 'team-playbooks/',
|
|
1638
|
+
format: 'json',
|
|
1639
|
+
required: false,
|
|
1640
|
+
description: 'Team coordination playbooks',
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
path: 'role-playbooks/',
|
|
1644
|
+
format: 'json',
|
|
1645
|
+
required: false,
|
|
1646
|
+
description: 'Role-specific playbooks',
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
path: 'team-skills/',
|
|
1650
|
+
format: 'skill-md',
|
|
1651
|
+
required: false,
|
|
1652
|
+
description: 'Team coordination skills in SKILL.md format',
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
path: 'role-skills/',
|
|
1656
|
+
format: 'skill-md',
|
|
1657
|
+
required: false,
|
|
1658
|
+
description: 'Role-specific skills in SKILL.md format',
|
|
1659
|
+
},
|
|
1660
|
+
{
|
|
1661
|
+
path: 'updates/',
|
|
1662
|
+
format: 'json',
|
|
1663
|
+
required: false,
|
|
1664
|
+
description: 'Updates to existing team/role playbooks',
|
|
1665
|
+
},
|
|
1666
|
+
{
|
|
1667
|
+
path: 'meta-strategies/',
|
|
1668
|
+
format: 'json',
|
|
1669
|
+
required: false,
|
|
1670
|
+
description: 'Meta-level team formation strategies',
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
path: 'extraction-summary.json',
|
|
1674
|
+
format: 'json',
|
|
1675
|
+
required: true,
|
|
1676
|
+
description: 'Summary of what was extracted and why',
|
|
1677
|
+
},
|
|
1678
|
+
],
|
|
1679
|
+
},
|
|
1680
|
+
|
|
1681
|
+
assessComplexity(input) {
|
|
1682
|
+
// Always agentic — this is complex semantic work
|
|
1683
|
+
if (input.lessonBatches.length > 10) return 'thorough';
|
|
1684
|
+
return 'standard';
|
|
1685
|
+
},
|
|
1686
|
+
|
|
1687
|
+
getSkills(input) {
|
|
1688
|
+
return convertPlaybooksToSkills(input.extractionPlaybooks ?? []);
|
|
1689
|
+
},
|
|
1690
|
+
|
|
1691
|
+
getResources(input) {
|
|
1692
|
+
return [];
|
|
1693
|
+
},
|
|
1694
|
+
|
|
1695
|
+
async prepareWorkspace(input, workspacePath) {
|
|
1696
|
+
const wm = this.workspaceManager;
|
|
1697
|
+
const handle = { inputDir: join(workspacePath, 'input') } as WorkspaceHandle;
|
|
1698
|
+
|
|
1699
|
+
// Batch overview
|
|
1700
|
+
await wm.writeInputMarkdown(handle, 'summary.md', {
|
|
1701
|
+
batchCount: input.lessonBatches.length,
|
|
1702
|
+
totalLessons: input.lessonBatches.reduce((acc, b) => acc + b.lessons.length, 0),
|
|
1703
|
+
roles: [...new Set(input.lessonBatches.flatMap(b => b.roles))],
|
|
1704
|
+
existingTeamPlaybooks: input.existingTeamPlaybooks.length,
|
|
1705
|
+
existingRolePlaybooks: input.existingRolePlaybooks.length,
|
|
1706
|
+
}, `# Team Playbook Extraction Batch\n\n` +
|
|
1707
|
+
`Extracting team coordination and role-specific playbooks from ` +
|
|
1708
|
+
`${input.lessonBatches.length} lesson batches.`
|
|
1709
|
+
);
|
|
1710
|
+
|
|
1711
|
+
// Lesson batches — derivative data from prior team analysis
|
|
1712
|
+
for (let i = 0; i < input.lessonBatches.length; i++) {
|
|
1713
|
+
const batch = input.lessonBatches[i];
|
|
1714
|
+
await wm.writeInputMarkdown(handle, `lesson-batches/batch-${i}.md`, {
|
|
1715
|
+
teamObjective: batch.objective,
|
|
1716
|
+
teamOutcome: batch.outcome,
|
|
1717
|
+
roles: batch.roles,
|
|
1718
|
+
lessonCount: batch.lessons.length,
|
|
1719
|
+
}, `# Lessons from: ${batch.objective}\n\n` +
|
|
1720
|
+
batch.lessons.map(l =>
|
|
1721
|
+
`## ${l.type === 'role' ? `Role: ${l.role}` : 'Team'}\n\n${l.content}\n`
|
|
1722
|
+
).join('\n')
|
|
1723
|
+
);
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
// Existing playbooks for deduplication
|
|
1727
|
+
for (const pb of input.existingTeamPlaybooks) {
|
|
1728
|
+
await wm.writeInputJson(handle, `existing/team/${pb.name}.json`, pb);
|
|
1729
|
+
}
|
|
1730
|
+
for (const pb of input.existingRolePlaybooks) {
|
|
1731
|
+
await wm.writeInputJson(handle, `existing/role/${pb.name}.json`, pb);
|
|
1732
|
+
}
|
|
1733
|
+
},
|
|
1734
|
+
|
|
1735
|
+
buildTaskPrompt(input) {
|
|
1736
|
+
return `
|
|
1737
|
+
Extract team coordination and role playbooks from the lesson batches.
|
|
1738
|
+
|
|
1739
|
+
## Input Files
|
|
1740
|
+
- input/summary.md — Batch overview (YAML frontmatter)
|
|
1741
|
+
- input/lesson-batches/*.md — Lessons from prior team analyses (derivative data)
|
|
1742
|
+
- input/existing/team/*.json — Existing team coordination playbooks
|
|
1743
|
+
- input/existing/role/*.json — Existing role-specific playbooks
|
|
1744
|
+
|
|
1745
|
+
## Available Skills
|
|
1746
|
+
- Check skills/ directory for extraction guidance
|
|
1747
|
+
|
|
1748
|
+
## Instructions
|
|
1749
|
+
1. Read the summary for an overview of what's available.
|
|
1750
|
+
2. Read each lesson batch — identify recurring patterns across batches.
|
|
1751
|
+
3. Extract three types of knowledge:
|
|
1752
|
+
- **Role playbooks**: How to play a specific role effectively (delegation patterns,
|
|
1753
|
+
communication styles, when to escalate)
|
|
1754
|
+
- **Team coordination playbooks**: How to compose and coordinate teams
|
|
1755
|
+
(formation patterns, interaction protocols, handoff strategies)
|
|
1756
|
+
- **Meta-strategies**: Higher-level patterns about team formation itself
|
|
1757
|
+
(when to use hub-and-spoke vs mesh, team size guidelines)
|
|
1758
|
+
4. Check against existing playbooks for deduplication and updates.
|
|
1759
|
+
5. Output both JSON playbooks and SKILL.md format skills.
|
|
1760
|
+
|
|
1761
|
+
## Output
|
|
1762
|
+
- output/team-playbooks/ — Team coordination playbooks (JSON)
|
|
1763
|
+
- output/role-playbooks/ — Role-specific playbooks (JSON)
|
|
1764
|
+
- output/team-skills/ — Team coordination skills (SKILL.md format)
|
|
1765
|
+
- output/role-skills/ — Role-specific skills (SKILL.md format)
|
|
1766
|
+
- output/updates/ — Updates to existing playbooks
|
|
1767
|
+
- output/meta-strategies/ — Meta-level team formation strategies
|
|
1768
|
+
- output/extraction-summary.json — Required summary of extraction results
|
|
1769
|
+
`;
|
|
1770
|
+
},
|
|
1771
|
+
|
|
1772
|
+
async collectOutput(workspacePath) {
|
|
1773
|
+
// Read all output directories
|
|
1774
|
+
},
|
|
1775
|
+
|
|
1776
|
+
async processOutput(output, input, context) {
|
|
1777
|
+
// Store new playbooks
|
|
1778
|
+
// Convert SKILL.md outputs to playbooks (or store as skills)
|
|
1779
|
+
// Apply updates
|
|
1780
|
+
// Store meta-strategies
|
|
1781
|
+
},
|
|
1782
|
+
};
|
|
1783
|
+
```
|
|
1784
|
+
|
|
1785
|
+
---
|
|
1786
|
+
|
|
1787
|
+
## Playbook ↔ Skill Conversion
|
|
1788
|
+
|
|
1789
|
+
The system stores knowledge as Playbooks internally but presents it to workspace agents as Skills (SKILL.md, Agent Skills open standard format). A bidirectional converter handles the translation:
|
|
1790
|
+
|
|
1791
|
+
```typescript
|
|
1792
|
+
/**
|
|
1793
|
+
* Convert Playbooks to Agent Skills for workspace loading.
|
|
1794
|
+
*/
|
|
1795
|
+
function convertPlaybooksToSkills(playbooks: Playbook[]): AgentSkillSpec[] {
|
|
1796
|
+
return playbooks.map(playbook => ({
|
|
1797
|
+
name: playbook.name,
|
|
1798
|
+
source: 'playbook-conversion' as const,
|
|
1799
|
+
content: generateSkillMd(playbook),
|
|
1800
|
+
}));
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* Generate SKILL.md content from a Playbook.
|
|
1805
|
+
*/
|
|
1806
|
+
function generateSkillMd(playbook: Playbook): string {
|
|
1807
|
+
const sections = [
|
|
1808
|
+
`# ${playbook.name}`,
|
|
1809
|
+
'',
|
|
1810
|
+
`## When to Use`,
|
|
1811
|
+
...playbook.applicability.situations.map(s => `- ${s}`),
|
|
1812
|
+
'',
|
|
1813
|
+
`## Triggers`,
|
|
1814
|
+
...playbook.applicability.triggers.map(t => `- ${t}`),
|
|
1815
|
+
'',
|
|
1816
|
+
`## Strategy`,
|
|
1817
|
+
playbook.guidance.strategy,
|
|
1818
|
+
'',
|
|
1819
|
+
`## Tactics`,
|
|
1820
|
+
...playbook.guidance.tactics.map(t => `- ${t}`),
|
|
1821
|
+
];
|
|
1822
|
+
|
|
1823
|
+
if (playbook.guidance.steps?.length) {
|
|
1824
|
+
sections.push('', '## Steps');
|
|
1825
|
+
playbook.guidance.steps.forEach((step, i) => {
|
|
1826
|
+
sections.push(`${i + 1}. ${step}`);
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
if (playbook.guidance.codeExample) {
|
|
1831
|
+
sections.push('', '## Example', '```', playbook.guidance.codeExample, '```');
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
sections.push(
|
|
1835
|
+
'', '## Verification',
|
|
1836
|
+
...playbook.verification.successIndicators.map(s => `- ✓ ${s}`),
|
|
1837
|
+
...playbook.verification.failureIndicators.map(f => `- ✗ ${f}`),
|
|
1838
|
+
);
|
|
1839
|
+
|
|
1840
|
+
return sections.join('\n');
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Parse SKILL.md output back into a Playbook.
|
|
1845
|
+
*/
|
|
1846
|
+
function parseSkillMdToPlaybook(skillMd: string, skillName: string): Playbook {
|
|
1847
|
+
// Parse markdown sections → populate Playbook fields
|
|
1848
|
+
// Used when agents produce SKILL.md outputs
|
|
1849
|
+
}
|
|
1850
|
+
```
|
|
1851
|
+
|
|
1852
|
+
This approach means:
|
|
1853
|
+
- **Input side**: Agents receive domain-appropriate SKILL.md files — a standard format they can read naturally
|
|
1854
|
+
- **Output side**: Agents can produce either JSON playbooks or SKILL.md files — both are accepted
|
|
1855
|
+
- **Storage**: Everything is stored as Playbooks internally for consistency with the existing evolution/confidence tracking
|
|
1856
|
+
|
|
1857
|
+
---
|
|
1858
|
+
|
|
1859
|
+
## Integration with Existing Pipeline
|
|
1860
|
+
|
|
1861
|
+
### Before: Direct calls to heuristic analyzers
|
|
1862
|
+
|
|
1863
|
+
```typescript
|
|
1864
|
+
// Current LearningPipeline.processTrajectory()
|
|
1865
|
+
async processTrajectory(trajectory: Trajectory): Promise<ProcessResult> {
|
|
1866
|
+
await this.memory.storeTrajectory(trajectory);
|
|
1867
|
+
const analysis = await this.analyzer.analyze(trajectory); // heuristic
|
|
1868
|
+
this.accumulated.push({ trajectory, analysis });
|
|
1869
|
+
return { stored: true, analysis, abstractable: analysis.abstractable };
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
// Current LearningPipeline.runBatchLearning()
|
|
1873
|
+
async runBatchLearning(): Promise<BatchResult> {
|
|
1874
|
+
const extracted = this.extractor.extract( // heuristic
|
|
1875
|
+
this.accumulated.map(a => a.trajectory),
|
|
1876
|
+
this.accumulated.map(a => a.analysis),
|
|
1877
|
+
existingPlaybooks
|
|
1878
|
+
);
|
|
1879
|
+
// ...
|
|
1880
|
+
}
|
|
1881
|
+
```
|
|
1882
|
+
|
|
1883
|
+
### After: Route through AgenticTaskRunner
|
|
1884
|
+
|
|
1885
|
+
```typescript
|
|
1886
|
+
// Updated LearningPipeline.processTrajectory()
|
|
1887
|
+
async processTrajectory(trajectory: Trajectory): Promise<ProcessResult> {
|
|
1888
|
+
await this.memory.storeTrajectory(trajectory);
|
|
1889
|
+
|
|
1890
|
+
// Agentic analysis (with heuristic fallback for simple cases)
|
|
1891
|
+
const { output: analysis } = await this.taskRunner.run(
|
|
1892
|
+
trajectoryAnalysisTemplate,
|
|
1893
|
+
{ trajectory, creditStrategy: this.config.creditStrategy }
|
|
1894
|
+
);
|
|
1895
|
+
|
|
1896
|
+
this.accumulated.push({ trajectory, analysis });
|
|
1897
|
+
return { stored: true, analysis, abstractable: analysis.abstractable };
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
// Updated LearningPipeline.runBatchLearning()
|
|
1901
|
+
async runBatchLearning(): Promise<BatchResult> {
|
|
1902
|
+
const { output: extracted } = await this.taskRunner.run(
|
|
1903
|
+
playbookExtractionTemplate,
|
|
1904
|
+
{
|
|
1905
|
+
trajectories: this.accumulated.map(a => a.trajectory),
|
|
1906
|
+
analyses: this.accumulated.map(a => a.analysis),
|
|
1907
|
+
existingPlaybooks,
|
|
1908
|
+
}
|
|
1909
|
+
);
|
|
1910
|
+
// ...
|
|
1911
|
+
}
|
|
1912
|
+
```
|
|
1913
|
+
|
|
1914
|
+
The calling code barely changes. The `AgenticTaskRunner` handles all workspace lifecycle, knowledge injection, and meta-learning internally. The `assessComplexity` check means simple trajectories still use the fast heuristic path.
|
|
1915
|
+
|
|
1916
|
+
### Updated Atlas Integration
|
|
1917
|
+
|
|
1918
|
+
```typescript
|
|
1919
|
+
class Atlas {
|
|
1920
|
+
private taskRunner: AgenticTaskRunner;
|
|
1921
|
+
|
|
1922
|
+
constructor(config: AtlasConfig) {
|
|
1923
|
+
const workspaceManager = new WorkspaceManager(config.workspaceBaseDir);
|
|
1924
|
+
this.taskRunner = new AgenticTaskRunner(
|
|
1925
|
+
workspaceManager,
|
|
1926
|
+
this.agentManager,
|
|
1927
|
+
this.memory,
|
|
1928
|
+
this.learningPipeline,
|
|
1929
|
+
config.agenticTasks
|
|
1930
|
+
);
|
|
1931
|
+
|
|
1932
|
+
// Inject runner into pipelines
|
|
1933
|
+
this.learningPipeline.setTaskRunner(this.taskRunner);
|
|
1934
|
+
this.teamPipeline.setTaskRunner(this.taskRunner);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// Existing methods work as before — the runner is internal
|
|
1938
|
+
async solve(task: Task): Promise<SolveResult> { /* unchanged */ }
|
|
1939
|
+
|
|
1940
|
+
// Team methods use the same runner
|
|
1941
|
+
async processTeamTrajectory(input: TeamTrajectoryInput) {
|
|
1942
|
+
return this.taskRunner.run(teamAnalysisTemplate, input);
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
async runTeamBatchLearning() {
|
|
1946
|
+
return this.taskRunner.run(teamPlaybookExtractionTemplate, this.teamAccumulated);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
```
|
|
1950
|
+
|
|
1951
|
+
---
|
|
1952
|
+
|
|
1953
|
+
## Cost Management
|
|
1954
|
+
|
|
1955
|
+
The `assessComplexity` method on each template is the primary cost control. Not every analysis needs a full agent:
|
|
1956
|
+
|
|
1957
|
+
```
|
|
1958
|
+
┌───────────────────────────────────────────────────┐
|
|
1959
|
+
│ COMPLEXITY ASSESSMENT │
|
|
1960
|
+
│ │
|
|
1961
|
+
│ Input characteristics Execution path │
|
|
1962
|
+
│ ───────────────────── ────────────── │
|
|
1963
|
+
│ │
|
|
1964
|
+
│ Simple, clear outcome ──────► heuristic │
|
|
1965
|
+
│ (5 steps, success) (existing code) │
|
|
1966
|
+
│ ~0 tokens │
|
|
1967
|
+
│ │
|
|
1968
|
+
│ Moderate complexity ──────► lightweight agent │
|
|
1969
|
+
│ (10-20 steps) ~2K tokens │
|
|
1970
|
+
│ 60s timeout │
|
|
1971
|
+
│ │
|
|
1972
|
+
│ Complex / failed ──────► standard agent │
|
|
1973
|
+
│ (20+ steps, failure) ~5K tokens │
|
|
1974
|
+
│ 120s timeout │
|
|
1975
|
+
│ │
|
|
1976
|
+
│ Large batch / team ──────► thorough agent │
|
|
1977
|
+
│ (10+ trajectories) ~10K tokens │
|
|
1978
|
+
│ 300s timeout │
|
|
1979
|
+
└───────────────────────────────────────────────────┘
|
|
1980
|
+
```
|
|
1981
|
+
|
|
1982
|
+
Estimates for a typical workflow:
|
|
1983
|
+
|
|
1984
|
+
| Event | Template | Likely Complexity | Cost |
|
|
1985
|
+
|-------|----------|-------------------|------|
|
|
1986
|
+
| Simple task completed | trajectory-analysis | heuristic | ~0 |
|
|
1987
|
+
| Complex task failed | trajectory-analysis | standard | ~5K tokens |
|
|
1988
|
+
| Playbook usage check (2 playbooks) | usage-inference | heuristic | ~0 |
|
|
1989
|
+
| Playbook usage check (5 playbooks) | usage-inference | lightweight | ~2K tokens |
|
|
1990
|
+
| Post-task reflection (clear success) | meta-reflection | heuristic | ~0 |
|
|
1991
|
+
| Post-task reflection (ambiguous failure) | meta-reflection | lightweight | ~2K tokens |
|
|
1992
|
+
| Batch of 10 trajectories | playbook-extraction | standard | ~8K tokens |
|
|
1993
|
+
| Team execution (3 agents) | team-analysis | lightweight | ~4K tokens |
|
|
1994
|
+
| Team execution (6 agents, failure) | team-analysis | thorough | ~15K tokens |
|
|
1995
|
+
| Team lesson batch (5 executions) | team-playbook-extraction | standard | ~10K tokens |
|
|
1996
|
+
|
|
1997
|
+
Most individual task completions hit the heuristic path. Agent analysis is reserved for cases where semantic understanding matters: failures, complex trajectories, batch extraction.
|
|
1998
|
+
|
|
1999
|
+
---
|
|
2000
|
+
|
|
2001
|
+
## Meta-Learning Across All Templates
|
|
2002
|
+
|
|
2003
|
+
Every agentic analysis produces a trajectory that feeds through the individual learning pipeline. Over time, each analysis domain accumulates its own playbooks:
|
|
2004
|
+
|
|
2005
|
+
```
|
|
2006
|
+
Domain: trajectory-analysis
|
|
2007
|
+
Playbooks about how to analyze trajectories effectively
|
|
2008
|
+
→ Injected into future trajectory analysis agents
|
|
2009
|
+
|
|
2010
|
+
Domain: playbook-extraction
|
|
2011
|
+
Playbooks about how to extract playbooks effectively
|
|
2012
|
+
→ Injected into future extraction agents
|
|
2013
|
+
|
|
2014
|
+
Domain: meta-reflection
|
|
2015
|
+
Playbooks about how to reflect on executions effectively
|
|
2016
|
+
→ Injected into future reflection agents
|
|
2017
|
+
|
|
2018
|
+
Domain: team-analysis
|
|
2019
|
+
Playbooks about how to analyze team executions effectively
|
|
2020
|
+
→ Injected into future team analysis agents
|
|
2021
|
+
|
|
2022
|
+
Domain: team-playbook-extraction
|
|
2023
|
+
Playbooks about how to extract team playbooks effectively
|
|
2024
|
+
→ Injected into future team extraction agents
|
|
2025
|
+
```
|
|
2026
|
+
|
|
2027
|
+
This is the recursive loop: the system learns how to learn. The `AgenticTaskRunner` makes this automatic — every template domain accumulates analysis expertise through the existing learning pipeline, without any template-specific meta-learning code.
|
|
2028
|
+
|
|
2029
|
+
---
|
|
2030
|
+
|
|
2031
|
+
## Migration Path
|
|
2032
|
+
|
|
2033
|
+
### Phase 1: Infrastructure
|
|
2034
|
+
- Implement `WorkspaceManager`
|
|
2035
|
+
- Implement `AgenticTaskRunner`
|
|
2036
|
+
- Define `AgenticTaskTemplate` interface
|
|
2037
|
+
- Wire into Atlas constructor
|
|
2038
|
+
|
|
2039
|
+
### Phase 2: First Template (team analysis)
|
|
2040
|
+
- Implement `teamAnalysisTemplate` (new, no existing code to replace)
|
|
2041
|
+
- Implement `teamPlaybookExtractionTemplate` (new)
|
|
2042
|
+
- Validates the infrastructure end-to-end
|
|
2043
|
+
|
|
2044
|
+
### Phase 3: Migrate Existing Analysis
|
|
2045
|
+
- `trajectoryAnalysisTemplate` replacing `TrajectoryAnalyzer` (keep as heuristic fallback)
|
|
2046
|
+
- `playbookExtractionTemplate` replacing `PlaybookExtractor` + `LLMPlaybookExtractor`
|
|
2047
|
+
- `metaReflectionTemplate` replacing `MetaLearner.generateReflection()`
|
|
2048
|
+
- `usageInferenceTemplate` replacing `PlaybookUsageInference`
|
|
2049
|
+
- `solutionEvaluationTemplate` enhancing `evaluator.ts` Tier 2
|
|
2050
|
+
|
|
2051
|
+
Each migration preserves the existing heuristic as `heuristicFallback` — no functionality is lost, and simple cases stay fast.
|
|
2052
|
+
|
|
2053
|
+
### Phase 4: Tuning
|
|
2054
|
+
- Calibrate `assessComplexity` thresholds based on real usage
|
|
2055
|
+
- Monitor cost vs. quality tradeoffs per template
|
|
2056
|
+
- Refine task prompts based on accumulated analysis playbooks
|
|
2057
|
+
- Prune unnecessary agentic invocations where heuristics are sufficient
|