@dragonflymcp/plugin 1.0.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-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/core/annotations.d.ts +71 -0
- package/dist/core/annotations.d.ts.map +1 -0
- package/dist/core/annotations.js +61 -0
- package/dist/core/annotations.js.map +1 -0
- package/dist/core/config.d.ts +66 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +131 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/dispatcher.d.ts +77 -0
- package/dist/core/dispatcher.d.ts.map +1 -0
- package/dist/core/dispatcher.js +132 -0
- package/dist/core/dispatcher.js.map +1 -0
- package/dist/core/server.d.ts +24 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +41 -0
- package/dist/core/server.js.map +1 -0
- package/dist/core/store.d.ts +91 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +157 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/types.d.ts +128 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -0
- package/dist/test-utils/store-harness.d.ts +41 -0
- package/dist/test-utils/store-harness.d.ts.map +1 -0
- package/dist/test-utils/store-harness.js +61 -0
- package/dist/test-utils/store-harness.js.map +1 -0
- package/dist/tools/analytics/aggregators.d.ts +18 -0
- package/dist/tools/analytics/aggregators.d.ts.map +1 -0
- package/dist/tools/analytics/aggregators.js +260 -0
- package/dist/tools/analytics/aggregators.js.map +1 -0
- package/dist/tools/analytics/aggregators.test.d.ts +2 -0
- package/dist/tools/analytics/aggregators.test.d.ts.map +1 -0
- package/dist/tools/analytics/aggregators.test.js +177 -0
- package/dist/tools/analytics/aggregators.test.js.map +1 -0
- package/dist/tools/analytics/drift.d.ts +15 -0
- package/dist/tools/analytics/drift.d.ts.map +1 -0
- package/dist/tools/analytics/drift.js +135 -0
- package/dist/tools/analytics/drift.js.map +1 -0
- package/dist/tools/analytics/drift.test.d.ts +2 -0
- package/dist/tools/analytics/drift.test.d.ts.map +1 -0
- package/dist/tools/analytics/drift.test.js +99 -0
- package/dist/tools/analytics/drift.test.js.map +1 -0
- package/dist/tools/analytics/index.d.ts +10 -0
- package/dist/tools/analytics/index.d.ts.map +1 -0
- package/dist/tools/analytics/index.js +192 -0
- package/dist/tools/analytics/index.js.map +1 -0
- package/dist/tools/analytics/learner.d.ts +29 -0
- package/dist/tools/analytics/learner.d.ts.map +1 -0
- package/dist/tools/analytics/learner.js +135 -0
- package/dist/tools/analytics/learner.js.map +1 -0
- package/dist/tools/analytics/learner.test.d.ts +2 -0
- package/dist/tools/analytics/learner.test.d.ts.map +1 -0
- package/dist/tools/analytics/learner.test.js +118 -0
- package/dist/tools/analytics/learner.test.js.map +1 -0
- package/dist/tools/analytics/observe.d.ts +22 -0
- package/dist/tools/analytics/observe.d.ts.map +1 -0
- package/dist/tools/analytics/observe.js +143 -0
- package/dist/tools/analytics/observe.js.map +1 -0
- package/dist/tools/analytics/observe.test.d.ts +2 -0
- package/dist/tools/analytics/observe.test.d.ts.map +1 -0
- package/dist/tools/analytics/observe.test.js +95 -0
- package/dist/tools/analytics/observe.test.js.map +1 -0
- package/dist/tools/analytics/store.d.ts +29 -0
- package/dist/tools/analytics/store.d.ts.map +1 -0
- package/dist/tools/analytics/store.js +192 -0
- package/dist/tools/analytics/store.js.map +1 -0
- package/dist/tools/analytics/types.d.ts +290 -0
- package/dist/tools/analytics/types.d.ts.map +1 -0
- package/dist/tools/analytics/types.js +7 -0
- package/dist/tools/analytics/types.js.map +1 -0
- package/dist/tools/ast/index.d.ts +8 -0
- package/dist/tools/ast/index.d.ts.map +1 -0
- package/dist/tools/ast/index.js +242 -0
- package/dist/tools/ast/index.js.map +1 -0
- package/dist/tools/ast/indexer.d.ts +41 -0
- package/dist/tools/ast/indexer.d.ts.map +1 -0
- package/dist/tools/ast/indexer.js +617 -0
- package/dist/tools/ast/indexer.js.map +1 -0
- package/dist/tools/ast/store.d.ts +87 -0
- package/dist/tools/ast/store.d.ts.map +1 -0
- package/dist/tools/ast/store.js +280 -0
- package/dist/tools/ast/store.js.map +1 -0
- package/dist/tools/ast/store.test.d.ts +6 -0
- package/dist/tools/ast/store.test.d.ts.map +1 -0
- package/dist/tools/ast/store.test.js +257 -0
- package/dist/tools/ast/store.test.js.map +1 -0
- package/dist/tools/bridge/bridge.d.ts +37 -0
- package/dist/tools/bridge/bridge.d.ts.map +1 -0
- package/dist/tools/bridge/bridge.js +82 -0
- package/dist/tools/bridge/bridge.js.map +1 -0
- package/dist/tools/bridge/bridge.test.d.ts +2 -0
- package/dist/tools/bridge/bridge.test.d.ts.map +1 -0
- package/dist/tools/bridge/bridge.test.js +119 -0
- package/dist/tools/bridge/bridge.test.js.map +1 -0
- package/dist/tools/bridge/index.d.ts +8 -0
- package/dist/tools/bridge/index.d.ts.map +1 -0
- package/dist/tools/bridge/index.js +153 -0
- package/dist/tools/bridge/index.js.map +1 -0
- package/dist/tools/bridge/store.d.ts +45 -0
- package/dist/tools/bridge/store.d.ts.map +1 -0
- package/dist/tools/bridge/store.js +307 -0
- package/dist/tools/bridge/store.js.map +1 -0
- package/dist/tools/bridge/store.test.d.ts +2 -0
- package/dist/tools/bridge/store.test.d.ts.map +1 -0
- package/dist/tools/bridge/store.test.js +180 -0
- package/dist/tools/bridge/store.test.js.map +1 -0
- package/dist/tools/bridge/types.d.ts +44 -0
- package/dist/tools/bridge/types.d.ts.map +1 -0
- package/dist/tools/bridge/types.js +6 -0
- package/dist/tools/bridge/types.js.map +1 -0
- package/dist/tools/evolve/algorithm.d.ts +33 -0
- package/dist/tools/evolve/algorithm.d.ts.map +1 -0
- package/dist/tools/evolve/algorithm.js +64 -0
- package/dist/tools/evolve/algorithm.js.map +1 -0
- package/dist/tools/evolve/algorithm.test.d.ts +6 -0
- package/dist/tools/evolve/algorithm.test.d.ts.map +1 -0
- package/dist/tools/evolve/algorithm.test.js +138 -0
- package/dist/tools/evolve/algorithm.test.js.map +1 -0
- package/dist/tools/evolve/index.d.ts +11 -0
- package/dist/tools/evolve/index.d.ts.map +1 -0
- package/dist/tools/evolve/index.js +300 -0
- package/dist/tools/evolve/index.js.map +1 -0
- package/dist/tools/evolve/store.d.ts +27 -0
- package/dist/tools/evolve/store.d.ts.map +1 -0
- package/dist/tools/evolve/store.js +147 -0
- package/dist/tools/evolve/store.js.map +1 -0
- package/dist/tools/evolve/store.test.d.ts +6 -0
- package/dist/tools/evolve/store.test.d.ts.map +1 -0
- package/dist/tools/evolve/store.test.js +162 -0
- package/dist/tools/evolve/store.test.js.map +1 -0
- package/dist/tools/evolve/types.d.ts +38 -0
- package/dist/tools/evolve/types.d.ts.map +1 -0
- package/dist/tools/evolve/types.js +6 -0
- package/dist/tools/evolve/types.js.map +1 -0
- package/dist/tools/framework/content-loader.d.ts +45 -0
- package/dist/tools/framework/content-loader.d.ts.map +1 -0
- package/dist/tools/framework/content-loader.js +258 -0
- package/dist/tools/framework/content-loader.js.map +1 -0
- package/dist/tools/framework/content-loader.test.d.ts +5 -0
- package/dist/tools/framework/content-loader.test.d.ts.map +1 -0
- package/dist/tools/framework/content-loader.test.js +262 -0
- package/dist/tools/framework/content-loader.test.js.map +1 -0
- package/dist/tools/framework/index.d.ts +30 -0
- package/dist/tools/framework/index.d.ts.map +1 -0
- package/dist/tools/framework/index.js +517 -0
- package/dist/tools/framework/index.js.map +1 -0
- package/dist/tools/framework/session.d.ts +85 -0
- package/dist/tools/framework/session.d.ts.map +1 -0
- package/dist/tools/framework/session.js +311 -0
- package/dist/tools/framework/session.js.map +1 -0
- package/dist/tools/framework/session.test.d.ts +5 -0
- package/dist/tools/framework/session.test.d.ts.map +1 -0
- package/dist/tools/framework/session.test.js +291 -0
- package/dist/tools/framework/session.test.js.map +1 -0
- package/dist/tools/framework/sync-evaluator.d.ts +41 -0
- package/dist/tools/framework/sync-evaluator.d.ts.map +1 -0
- package/dist/tools/framework/sync-evaluator.js +298 -0
- package/dist/tools/framework/sync-evaluator.js.map +1 -0
- package/dist/tools/framework/sync-evaluator.test.d.ts +5 -0
- package/dist/tools/framework/sync-evaluator.test.d.ts.map +1 -0
- package/dist/tools/framework/sync-evaluator.test.js +288 -0
- package/dist/tools/framework/sync-evaluator.test.js.map +1 -0
- package/dist/tools/framework/types.d.ts +279 -0
- package/dist/tools/framework/types.d.ts.map +1 -0
- package/dist/tools/framework/types.js +6 -0
- package/dist/tools/framework/types.js.map +1 -0
- package/dist/tools/framework/workflow-intelligence.d.ts +55 -0
- package/dist/tools/framework/workflow-intelligence.d.ts.map +1 -0
- package/dist/tools/framework/workflow-intelligence.js +199 -0
- package/dist/tools/framework/workflow-intelligence.js.map +1 -0
- package/dist/tools/framework/workflow-intelligence.test.d.ts +6 -0
- package/dist/tools/framework/workflow-intelligence.test.d.ts.map +1 -0
- package/dist/tools/framework/workflow-intelligence.test.js +257 -0
- package/dist/tools/framework/workflow-intelligence.test.js.map +1 -0
- package/dist/tools/framework/workflow-planner.d.ts +10 -0
- package/dist/tools/framework/workflow-planner.d.ts.map +1 -0
- package/dist/tools/framework/workflow-planner.js +214 -0
- package/dist/tools/framework/workflow-planner.js.map +1 -0
- package/dist/tools/framework/workflow-planner.test.d.ts +5 -0
- package/dist/tools/framework/workflow-planner.test.d.ts.map +1 -0
- package/dist/tools/framework/workflow-planner.test.js +137 -0
- package/dist/tools/framework/workflow-planner.test.js.map +1 -0
- package/dist/tools/knowledge/bridge.d.ts +34 -0
- package/dist/tools/knowledge/bridge.d.ts.map +1 -0
- package/dist/tools/knowledge/bridge.js +249 -0
- package/dist/tools/knowledge/bridge.js.map +1 -0
- package/dist/tools/knowledge/bridge.test.d.ts +5 -0
- package/dist/tools/knowledge/bridge.test.d.ts.map +1 -0
- package/dist/tools/knowledge/bridge.test.js +221 -0
- package/dist/tools/knowledge/bridge.test.js.map +1 -0
- package/dist/tools/knowledge/extractor.d.ts +22 -0
- package/dist/tools/knowledge/extractor.d.ts.map +1 -0
- package/dist/tools/knowledge/extractor.js +154 -0
- package/dist/tools/knowledge/extractor.js.map +1 -0
- package/dist/tools/knowledge/index.d.ts +12 -0
- package/dist/tools/knowledge/index.d.ts.map +1 -0
- package/dist/tools/knowledge/index.js +505 -0
- package/dist/tools/knowledge/index.js.map +1 -0
- package/dist/tools/knowledge/retrieval.d.ts +28 -0
- package/dist/tools/knowledge/retrieval.d.ts.map +1 -0
- package/dist/tools/knowledge/retrieval.js +164 -0
- package/dist/tools/knowledge/retrieval.js.map +1 -0
- package/dist/tools/knowledge/store.d.ts +96 -0
- package/dist/tools/knowledge/store.d.ts.map +1 -0
- package/dist/tools/knowledge/store.js +562 -0
- package/dist/tools/knowledge/store.js.map +1 -0
- package/dist/tools/knowledge/store.test.d.ts +6 -0
- package/dist/tools/knowledge/store.test.d.ts.map +1 -0
- package/dist/tools/knowledge/store.test.js +385 -0
- package/dist/tools/knowledge/store.test.js.map +1 -0
- package/dist/tools/knowledge/types.d.ts +168 -0
- package/dist/tools/knowledge/types.d.ts.map +1 -0
- package/dist/tools/knowledge/types.js +6 -0
- package/dist/tools/knowledge/types.js.map +1 -0
- package/dist/tools/memory/evolution.d.ts +31 -0
- package/dist/tools/memory/evolution.d.ts.map +1 -0
- package/dist/tools/memory/evolution.js +130 -0
- package/dist/tools/memory/evolution.js.map +1 -0
- package/dist/tools/memory/index.d.ts +11 -0
- package/dist/tools/memory/index.d.ts.map +1 -0
- package/dist/tools/memory/index.js +239 -0
- package/dist/tools/memory/index.js.map +1 -0
- package/dist/tools/memory/store.d.ts +75 -0
- package/dist/tools/memory/store.d.ts.map +1 -0
- package/dist/tools/memory/store.js +398 -0
- package/dist/tools/memory/store.js.map +1 -0
- package/dist/tools/memory/store.test.d.ts +6 -0
- package/dist/tools/memory/store.test.d.ts.map +1 -0
- package/dist/tools/memory/store.test.js +429 -0
- package/dist/tools/memory/store.test.js.map +1 -0
- package/dist/tools/memory/types.d.ts +171 -0
- package/dist/tools/memory/types.d.ts.map +1 -0
- package/dist/tools/memory/types.js +6 -0
- package/dist/tools/memory/types.js.map +1 -0
- package/dist/tools/pipeline/composer.d.ts +29 -0
- package/dist/tools/pipeline/composer.d.ts.map +1 -0
- package/dist/tools/pipeline/composer.js +225 -0
- package/dist/tools/pipeline/composer.js.map +1 -0
- package/dist/tools/pipeline/composer.test.d.ts +2 -0
- package/dist/tools/pipeline/composer.test.d.ts.map +1 -0
- package/dist/tools/pipeline/composer.test.js +162 -0
- package/dist/tools/pipeline/composer.test.js.map +1 -0
- package/dist/tools/pipeline/index.d.ts +8 -0
- package/dist/tools/pipeline/index.d.ts.map +1 -0
- package/dist/tools/pipeline/index.js +102 -0
- package/dist/tools/pipeline/index.js.map +1 -0
- package/dist/tools/pipeline/planner.d.ts +10 -0
- package/dist/tools/pipeline/planner.d.ts.map +1 -0
- package/dist/tools/pipeline/planner.js +147 -0
- package/dist/tools/pipeline/planner.js.map +1 -0
- package/dist/tools/pipeline/planner.test.d.ts +2 -0
- package/dist/tools/pipeline/planner.test.d.ts.map +1 -0
- package/dist/tools/pipeline/planner.test.js +96 -0
- package/dist/tools/pipeline/planner.test.js.map +1 -0
- package/dist/tools/pipeline/preconditions.d.ts +14 -0
- package/dist/tools/pipeline/preconditions.d.ts.map +1 -0
- package/dist/tools/pipeline/preconditions.js +65 -0
- package/dist/tools/pipeline/preconditions.js.map +1 -0
- package/dist/tools/pipeline/preconditions.test.d.ts +2 -0
- package/dist/tools/pipeline/preconditions.test.d.ts.map +1 -0
- package/dist/tools/pipeline/preconditions.test.js +74 -0
- package/dist/tools/pipeline/preconditions.test.js.map +1 -0
- package/dist/tools/pipeline/types.d.ts +105 -0
- package/dist/tools/pipeline/types.d.ts.map +1 -0
- package/dist/tools/pipeline/types.js +6 -0
- package/dist/tools/pipeline/types.js.map +1 -0
- package/dist/tools/repair/index.d.ts +8 -0
- package/dist/tools/repair/index.d.ts.map +1 -0
- package/dist/tools/repair/index.js +384 -0
- package/dist/tools/repair/index.js.map +1 -0
- package/dist/tools/repair/repairer.d.ts +67 -0
- package/dist/tools/repair/repairer.d.ts.map +1 -0
- package/dist/tools/repair/repairer.js +257 -0
- package/dist/tools/repair/repairer.js.map +1 -0
- package/dist/tools/repair/repairer.test.d.ts +6 -0
- package/dist/tools/repair/repairer.test.d.ts.map +1 -0
- package/dist/tools/repair/repairer.test.js +159 -0
- package/dist/tools/repair/repairer.test.js.map +1 -0
- package/dist/tools/semantic/chunker.d.ts +23 -0
- package/dist/tools/semantic/chunker.d.ts.map +1 -0
- package/dist/tools/semantic/chunker.js +244 -0
- package/dist/tools/semantic/chunker.js.map +1 -0
- package/dist/tools/semantic/embedder.d.ts +16 -0
- package/dist/tools/semantic/embedder.d.ts.map +1 -0
- package/dist/tools/semantic/embedder.js +88 -0
- package/dist/tools/semantic/embedder.js.map +1 -0
- package/dist/tools/semantic/index.d.ts +8 -0
- package/dist/tools/semantic/index.d.ts.map +1 -0
- package/dist/tools/semantic/index.js +144 -0
- package/dist/tools/semantic/index.js.map +1 -0
- package/dist/tools/semantic/store.d.ts +31 -0
- package/dist/tools/semantic/store.d.ts.map +1 -0
- package/dist/tools/semantic/store.js +168 -0
- package/dist/tools/semantic/store.js.map +1 -0
- package/dist/tools/semantic/store.test.d.ts +6 -0
- package/dist/tools/semantic/store.test.d.ts.map +1 -0
- package/dist/tools/semantic/store.test.js +240 -0
- package/dist/tools/semantic/store.test.js.map +1 -0
- package/dist/tools/spec/generator.d.ts +32 -0
- package/dist/tools/spec/generator.d.ts.map +1 -0
- package/dist/tools/spec/generator.js +278 -0
- package/dist/tools/spec/generator.js.map +1 -0
- package/dist/tools/spec/generator.test.d.ts +6 -0
- package/dist/tools/spec/generator.test.d.ts.map +1 -0
- package/dist/tools/spec/generator.test.js +208 -0
- package/dist/tools/spec/generator.test.js.map +1 -0
- package/dist/tools/spec/index.d.ts +11 -0
- package/dist/tools/spec/index.d.ts.map +1 -0
- package/dist/tools/spec/index.js +426 -0
- package/dist/tools/spec/index.js.map +1 -0
- package/dist/tools/spec/store.d.ts +24 -0
- package/dist/tools/spec/store.d.ts.map +1 -0
- package/dist/tools/spec/store.js +104 -0
- package/dist/tools/spec/store.js.map +1 -0
- package/dist/tools/spec/store.test.d.ts +6 -0
- package/dist/tools/spec/store.test.d.ts.map +1 -0
- package/dist/tools/spec/store.test.js +173 -0
- package/dist/tools/spec/store.test.js.map +1 -0
- package/dist/tools/spec/types.d.ts +61 -0
- package/dist/tools/spec/types.d.ts.map +1 -0
- package/dist/tools/spec/types.js +6 -0
- package/dist/tools/spec/types.js.map +1 -0
- package/dist/tools/state/index.d.ts +11 -0
- package/dist/tools/state/index.d.ts.map +1 -0
- package/dist/tools/state/index.js +386 -0
- package/dist/tools/state/index.js.map +1 -0
- package/dist/tools/state/migrate.d.ts +39 -0
- package/dist/tools/state/migrate.d.ts.map +1 -0
- package/dist/tools/state/migrate.js +242 -0
- package/dist/tools/state/migrate.js.map +1 -0
- package/dist/tools/state/migrate.test.d.ts +2 -0
- package/dist/tools/state/migrate.test.d.ts.map +1 -0
- package/dist/tools/state/migrate.test.js +265 -0
- package/dist/tools/state/migrate.test.js.map +1 -0
- package/dist/tools/state/store.d.ts +107 -0
- package/dist/tools/state/store.d.ts.map +1 -0
- package/dist/tools/state/store.js +365 -0
- package/dist/tools/state/store.js.map +1 -0
- package/dist/tools/state/store.test.d.ts +5 -0
- package/dist/tools/state/store.test.d.ts.map +1 -0
- package/dist/tools/state/store.test.js +293 -0
- package/dist/tools/state/store.test.js.map +1 -0
- package/dist/tools/state/types.d.ts +90 -0
- package/dist/tools/state/types.d.ts.map +1 -0
- package/dist/tools/state/types.js +6 -0
- package/dist/tools/state/types.js.map +1 -0
- package/dist/tools/testing/analyzer.d.ts +44 -0
- package/dist/tools/testing/analyzer.d.ts.map +1 -0
- package/dist/tools/testing/analyzer.js +280 -0
- package/dist/tools/testing/analyzer.js.map +1 -0
- package/dist/tools/testing/generator.d.ts +57 -0
- package/dist/tools/testing/generator.d.ts.map +1 -0
- package/dist/tools/testing/generator.js +478 -0
- package/dist/tools/testing/generator.js.map +1 -0
- package/dist/tools/testing/generator.test.d.ts +6 -0
- package/dist/tools/testing/generator.test.d.ts.map +1 -0
- package/dist/tools/testing/generator.test.js +285 -0
- package/dist/tools/testing/generator.test.js.map +1 -0
- package/dist/tools/testing/index.d.ts +8 -0
- package/dist/tools/testing/index.d.ts.map +1 -0
- package/dist/tools/testing/index.js +373 -0
- package/dist/tools/testing/index.js.map +1 -0
- package/dist/utils/embedder.d.ts +7 -0
- package/dist/utils/embedder.d.ts.map +1 -0
- package/dist/utils/embedder.js +13 -0
- package/dist/utils/embedder.js.map +1 -0
- package/dist/utils/execution.d.ts +68 -0
- package/dist/utils/execution.d.ts.map +1 -0
- package/dist/utils/execution.js +467 -0
- package/dist/utils/execution.js.map +1 -0
- package/dist/utils/graph.d.ts +26 -0
- package/dist/utils/graph.d.ts.map +1 -0
- package/dist/utils/graph.js +32 -0
- package/dist/utils/graph.js.map +1 -0
- package/dist/utils/guards.d.ts +32 -0
- package/dist/utils/guards.d.ts.map +1 -0
- package/dist/utils/guards.js +40 -0
- package/dist/utils/guards.js.map +1 -0
- package/dist/utils/ids.d.ts +5 -0
- package/dist/utils/ids.d.ts.map +1 -0
- package/dist/utils/ids.js +7 -0
- package/dist/utils/ids.js.map +1 -0
- package/dist/utils/languages.d.ts +34 -0
- package/dist/utils/languages.d.ts.map +1 -0
- package/dist/utils/languages.js +153 -0
- package/dist/utils/languages.js.map +1 -0
- package/dist/utils/lazy.d.ts +17 -0
- package/dist/utils/lazy.d.ts.map +1 -0
- package/dist/utils/lazy.js +35 -0
- package/dist/utils/lazy.js.map +1 -0
- package/dist/utils/project.d.ts +41 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +82 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/responses.d.ts +27 -0
- package/dist/utils/responses.d.ts.map +1 -0
- package/dist/utils/responses.js +72 -0
- package/dist/utils/responses.js.map +1 -0
- package/dist/utils/vectors.d.ts +33 -0
- package/dist/utils/vectors.d.ts.map +1 -0
- package/dist/utils/vectors.js +80 -0
- package/dist/utils/vectors.js.map +1 -0
- package/dist/utils/vectors.test.d.ts +6 -0
- package/dist/utils/vectors.test.d.ts.map +1 -0
- package/dist/utils/vectors.test.js +96 -0
- package/dist/utils/vectors.test.js.map +1 -0
- package/package.json +69 -0
- package/scripts/init.js +142 -0
- package/templates/CLAUDE.md.template +96 -0
- package/templates/agents/architecture-concept.md +237 -0
- package/templates/agents/checkpoint-concept.md +218 -0
- package/templates/agents/code-analysis-concept.md +171 -0
- package/templates/agents/compete-control.md +44 -0
- package/templates/agents/compete-evaluator.md +87 -0
- package/templates/agents/compete-treatment.md +55 -0
- package/templates/agents/context-concept.md +254 -0
- package/templates/agents/debate-advocate.md +127 -0
- package/templates/agents/debate-critic.md +119 -0
- package/templates/agents/debate-synthesis.md +160 -0
- package/templates/agents/documentation-concept.md +294 -0
- package/templates/agents/implementation-concept.md +165 -0
- package/templates/agents/quality-concept.md +299 -0
- package/templates/agents/research-concept.md +169 -0
- package/templates/agents/security-concept.md +255 -0
- package/templates/agents/story-concept.md +207 -0
- package/templates/agents/verification-concept.md +456 -0
- package/templates/agents/version-concept.md +163 -0
- package/templates/anchors/directory.anchor.yaml.template +53 -0
- package/templates/anchors/rules.anchor.yaml.template +70 -0
- package/templates/anchors/safety.anchor.yaml.template +96 -0
- package/templates/claude-md-managed.template +105 -0
- package/templates/commands/cache.md.template +439 -0
- package/templates/commands/checkpoint.md.template +121 -0
- package/templates/commands/classify.md.template +138 -0
- package/templates/commands/compete.md.template +90 -0
- package/templates/commands/costs.md.template +111 -0
- package/templates/commands/estimate.md.template +196 -0
- package/templates/commands/explore.md.template +186 -0
- package/templates/commands/feature.md.template +216 -0
- package/templates/commands/forget.md.template +104 -0
- package/templates/commands/global-recall.md.template +250 -0
- package/templates/commands/global-remember.md.template +187 -0
- package/templates/commands/health.md.template +107 -0
- package/templates/commands/help.md.template +253 -0
- package/templates/commands/observe.md.template +211 -0
- package/templates/commands/pr-review.md.template +164 -0
- package/templates/commands/predict-cost.md.template +251 -0
- package/templates/commands/profile.md.template +142 -0
- package/templates/commands/reasoning.md.template +228 -0
- package/templates/commands/recall.md.template +197 -0
- package/templates/commands/remember.md.template +148 -0
- package/templates/commands/replay.md.template +449 -0
- package/templates/commands/restore.md.template +87 -0
- package/templates/commands/retrospective.md.template +47 -0
- package/templates/commands/slo.md.template +286 -0
- package/templates/commands/spec.md.template +164 -0
- package/templates/commands/status.md.template +53 -0
- package/templates/commands/sync.md.template +321 -0
- package/templates/commands/task.md.template +86 -0
- package/templates/commands/trace.md.template +86 -0
- package/templates/commands/visualize.md.template +216 -0
- package/templates/commands/workflow.md.template +375 -0
- package/templates/concepts/README.md +329 -0
- package/templates/concepts/architecture.md.template +74 -0
- package/templates/concepts/code-analysis.md.template +186 -0
- package/templates/concepts/context-compactor.md.template +393 -0
- package/templates/concepts/context.md.template +62 -0
- package/templates/concepts/documentation.md.template +452 -0
- package/templates/concepts/estimator.md.template +214 -0
- package/templates/concepts/exploration.md.template +257 -0
- package/templates/concepts/global-memory.md.template +222 -0
- package/templates/concepts/implementation.md.template +62 -0
- package/templates/concepts/pr-review.md.template +277 -0
- package/templates/concepts/project-profile.md.template +358 -0
- package/templates/concepts/quality.md.template +63 -0
- package/templates/concepts/react-fallback.md.template +286 -0
- package/templates/concepts/research.md.template +221 -0
- package/templates/concepts/retrospective.md.template +93 -0
- package/templates/concepts/security.md.template +442 -0
- package/templates/concepts/slo.md.template +274 -0
- package/templates/concepts/spec.md.template +71 -0
- package/templates/concepts/story.md.template +50 -0
- package/templates/concepts/tool-router.md.template +289 -0
- package/templates/concepts/verification-synthesizer.md.template +279 -0
- package/templates/concepts/version.md.template +61 -0
- package/templates/config.yaml.template +347 -0
- package/templates/examples/README.md +77 -0
- package/templates/examples/architecture/api-design.yaml.template +286 -0
- package/templates/examples/architecture/oauth-authentication.yaml.template +305 -0
- package/templates/health/status.yaml.template +120 -0
- package/templates/hooks/concept-complete.sh.template +45 -0
- package/templates/hooks/lib/common.sh.template +160 -0
- package/templates/hooks/post-commit.sh.template +37 -0
- package/templates/hooks/post-concept-action.template +39 -0
- package/templates/hooks/post-tool-structure-check.sh.template +138 -0
- package/templates/hooks/post-tool-use.sh.template +51 -0
- package/templates/hooks/pre-compact.sh.template +48 -0
- package/templates/hooks/pre-tool-grounding.template +148 -0
- package/templates/hooks/session-exit-checkpoint.sh.template +35 -0
- package/templates/hooks/session-start.sh.template +67 -0
- package/templates/hooks/statusline.sh.template +148 -0
- package/templates/hooks/stop.sh.template +45 -0
- package/templates/hooks/subagent-stop.sh.template +40 -0
- package/templates/hooks/sync-blocked.sh.template +45 -0
- package/templates/hooks/timeout.sh.template +48 -0
- package/templates/hooks/user-prompt-submit.sh.template +68 -0
- package/templates/koan/README.md +58 -0
- package/templates/memory/index.yaml.template +48 -0
- package/templates/memory/procedural/debugging.yaml.template +24 -0
- package/templates/memory/procedural/workflows.yaml.template +22 -0
- package/templates/memory/semantic/architecture.yaml.template +21 -0
- package/templates/memory/semantic/conventions.yaml.template +18 -0
- package/templates/memory/semantic/patterns.yaml.template +21 -0
- package/templates/memory/semantic/preferences.yaml.template +18 -0
- package/templates/prompts/architecture.yaml.template +349 -0
- package/templates/prompts/context.yaml.template +384 -0
- package/templates/prompts/implementation.yaml.template +365 -0
- package/templates/prompts/planning.yaml.template +303 -0
- package/templates/prompts/quality.yaml.template +345 -0
- package/templates/prompts/retrospective.yaml.template +231 -0
- package/templates/prompts/slo.yaml.template +360 -0
- package/templates/prompts/story.yaml.template +236 -0
- package/templates/prompts/tree-of-thoughts.yaml.template +299 -0
- package/templates/prompts/verification.yaml.template +286 -0
- package/templates/prompts/version.yaml.template +279 -0
- package/templates/schemas/agent-schema.json +98 -0
- package/templates/schemas/architecture.schema.json +69 -0
- package/templates/schemas/config-schema.json +165 -0
- package/templates/schemas/implementation.schema.json +75 -0
- package/templates/schemas/planning.schema.json +243 -0
- package/templates/schemas/provenance.schema.json +111 -0
- package/templates/schemas/retrospective.schema.json +174 -0
- package/templates/schemas/review.schema.json +284 -0
- package/templates/schemas/slo.schema.json +443 -0
- package/templates/schemas/story.schema.json +68 -0
- package/templates/schemas/sync-schema.json +196 -0
- package/templates/schemas/task.schema.json +127 -0
- package/templates/schemas/tree-of-thoughts.schema.json +175 -0
- package/templates/schemas/verification.schema.json +106 -0
- package/templates/settings.full.json.template +135 -0
- package/templates/settings.minimal.json.template +68 -0
- package/templates/settings.standard.json.template +135 -0
- package/templates/skills/acceptance-criteria-generation.md.template +330 -0
- package/templates/skills/accessibility-checking.md.template +341 -0
- package/templates/skills/api-design-patterns.md.template +395 -0
- package/templates/skills/batch-processing.md.template +605 -0
- package/templates/skills/branch-strategy.md.template +362 -0
- package/templates/skills/changelog-generation.md.template +403 -0
- package/templates/skills/code-coverage-analysis.md.template +362 -0
- package/templates/skills/code-style-enforcement.md.template +294 -0
- package/templates/skills/code-template-patterns.md.template +419 -0
- package/templates/skills/concept-development.md.template +159 -0
- package/templates/skills/context-prioritization.md.template +306 -0
- package/templates/skills/cost-optimization.md.template +482 -0
- package/templates/skills/cross-project-knowledge.md.template +316 -0
- package/templates/skills/dependency-impact-analysis.md.template +263 -0
- package/templates/skills/documentation-generation.md.template +409 -0
- package/templates/skills/effort-estimation.md.template +350 -0
- package/templates/skills/error-classification.md.template +709 -0
- package/templates/skills/error-messages.md.template +339 -0
- package/templates/skills/ide-diagnostics.md.template +480 -0
- package/templates/skills/incremental-loading.md.template +574 -0
- package/templates/skills/output-caching.md.template +524 -0
- package/templates/skills/performance-estimation.md.template +325 -0
- package/templates/skills/performance-testing-patterns.md.template +341 -0
- package/templates/skills/phase2-optimizations-summary.md.template +458 -0
- package/templates/skills/progressive-disclosure-pattern.md.template +190 -0
- package/templates/skills/project-structure.md.template +372 -0
- package/templates/skills/provenance-analysis.md.template +609 -0
- package/templates/skills/react-executor.md.template +366 -0
- package/templates/skills/refactoring-patterns.md.template +422 -0
- package/templates/skills/release-management.md.template +373 -0
- package/templates/skills/requirement-prioritization.md.template +357 -0
- package/templates/skills/schema-validation.md.template +321 -0
- package/templates/skills/security-design-patterns.md.template +692 -0
- package/templates/skills/security-vulnerability-scanning.md.template +663 -0
- package/templates/skills/semantic-memory.md.template +266 -0
- package/templates/skills/semantic-versioning.md.template +371 -0
- package/templates/skills/smart-retry.md.template +676 -0
- package/templates/skills/smart-summarization.md.template +358 -0
- package/templates/skills/story-decomposition.md.template +278 -0
- package/templates/skills/synchronization-patterns.md.template +303 -0
- package/templates/skills/test-generation-strategy.md.template +247 -0
- package/templates/skills/workflow-replay.md.template +478 -0
- package/templates/skills/wysiwid-principles.md.template +364 -0
- package/templates/skills-manifest.yaml.template +526 -0
- package/templates/stubs/agents/architecture-concept.md +20 -0
- package/templates/stubs/agents/checkpoint-concept.md +19 -0
- package/templates/stubs/agents/code-analysis-concept.md +36 -0
- package/templates/stubs/agents/context-concept.md +37 -0
- package/templates/stubs/agents/debate-advocate.md +12 -0
- package/templates/stubs/agents/debate-critic.md +12 -0
- package/templates/stubs/agents/debate-synthesis.md +12 -0
- package/templates/stubs/agents/documentation-concept.md +39 -0
- package/templates/stubs/agents/implementation-concept.md +41 -0
- package/templates/stubs/agents/quality-concept.md +41 -0
- package/templates/stubs/agents/research-concept.md +35 -0
- package/templates/stubs/agents/security-concept.md +40 -0
- package/templates/stubs/agents/spec-concept.md +35 -0
- package/templates/stubs/agents/story-concept.md +36 -0
- package/templates/stubs/agents/verification-concept.md +39 -0
- package/templates/stubs/agents/version-concept.md +37 -0
- package/templates/stubs/commands/cache.md.template +2 -0
- package/templates/stubs/commands/checkpoint.md.template +2 -0
- package/templates/stubs/commands/classify.md.template +2 -0
- package/templates/stubs/commands/compete.md.template +2 -0
- package/templates/stubs/commands/costs.md.template +2 -0
- package/templates/stubs/commands/estimate.md.template +2 -0
- package/templates/stubs/commands/explore.md.template +2 -0
- package/templates/stubs/commands/feature.md.template +2 -0
- package/templates/stubs/commands/forget.md.template +2 -0
- package/templates/stubs/commands/global-recall.md.template +2 -0
- package/templates/stubs/commands/global-remember.md.template +2 -0
- package/templates/stubs/commands/health.md.template +2 -0
- package/templates/stubs/commands/help.md.template +2 -0
- package/templates/stubs/commands/observe.md.template +2 -0
- package/templates/stubs/commands/pr-review.md.template +2 -0
- package/templates/stubs/commands/predict-cost.md.template +2 -0
- package/templates/stubs/commands/profile.md.template +2 -0
- package/templates/stubs/commands/reasoning.md.template +2 -0
- package/templates/stubs/commands/recall.md.template +2 -0
- package/templates/stubs/commands/remember.md.template +2 -0
- package/templates/stubs/commands/replay.md.template +2 -0
- package/templates/stubs/commands/restore.md.template +2 -0
- package/templates/stubs/commands/retrospective.md.template +2 -0
- package/templates/stubs/commands/slo.md.template +2 -0
- package/templates/stubs/commands/spec.md.template +2 -0
- package/templates/stubs/commands/sync.md.template +2 -0
- package/templates/stubs/commands/task.md.template +2 -0
- package/templates/stubs/commands/trace.md.template +2 -0
- package/templates/stubs/commands/visualize.md.template +2 -0
- package/templates/stubs/commands/workflow.md.template +2 -0
- package/templates/synchronizations/archive/adaptive-learning.yaml.template +595 -0
- package/templates/synchronizations/archive/code-understanding-flow.yaml.template +533 -0
- package/templates/synchronizations/archive/collaboration-flow.yaml.template +521 -0
- package/templates/synchronizations/archive/context-folding.yaml.template +353 -0
- package/templates/synchronizations/archive/dead-letter-queue.yaml.template +530 -0
- package/templates/synchronizations/archive/documentation-flow.yaml.template +560 -0
- package/templates/synchronizations/archive/error-recovery-flow.yaml.template +1031 -0
- package/templates/synchronizations/archive/execution-loop.yaml.template +336 -0
- package/templates/synchronizations/archive/exploration-flow.yaml.template +369 -0
- package/templates/synchronizations/archive/feature-development.yaml.template +2145 -0
- package/templates/synchronizations/archive/learning-loop.yaml.template +657 -0
- package/templates/synchronizations/archive/multi-verify.yaml.template +346 -0
- package/templates/synchronizations/archive/planning-flow.yaml.template +312 -0
- package/templates/synchronizations/archive/retrospective-flow.yaml.template +277 -0
- package/templates/synchronizations/archive/security-flow.yaml.template +477 -0
- package/templates/synchronizations/archive/slo-monitoring.yaml.template +209 -0
- package/templates/synchronizations/archive/task-routing.yaml.template +489 -0
- package/templates/synchronizations/archive/test-driven.yaml.template +291 -0
- package/templates/synchronizations/archive/tool-routing.yaml.template +326 -0
- package/templates/synchronizations/archive/verification-flow.yaml.template +407 -0
- package/templates/synchronizations/error-policy.yaml.template +188 -0
- package/templates/synchronizations/main.sync.template +319 -0
- package/templates/synchronizations/slo-registry.yaml.template +229 -0
- package/templates/tasks/task.yaml.template +67 -0
- package/templates/zen-profile.yaml.template +14 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Zen Context Health Status
|
|
2
|
+
# This file gives Claude awareness of its own context state
|
|
3
|
+
#
|
|
4
|
+
# Updated by: post-concept-action hook, pre-tool-grounding hook
|
|
5
|
+
# Read by: Claude before operations, /health command
|
|
6
|
+
#
|
|
7
|
+
# Claude should read this to calibrate confidence in its understanding
|
|
8
|
+
|
|
9
|
+
health_id: "health-current"
|
|
10
|
+
generated_at: "${TIMESTAMP}"
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
|
|
13
|
+
# ============================================================================
|
|
14
|
+
# TOKEN BUDGET STATUS
|
|
15
|
+
# ============================================================================
|
|
16
|
+
tokens:
|
|
17
|
+
estimated_used: 0
|
|
18
|
+
budget_total: 200000
|
|
19
|
+
budget_remaining: 200000
|
|
20
|
+
usage_percent: 0.0
|
|
21
|
+
zone: "green" # green (<70%), yellow (70-80%), red (>80%)
|
|
22
|
+
|
|
23
|
+
# Zone meanings:
|
|
24
|
+
# green: Safe to continue normally
|
|
25
|
+
# yellow: Consider compacting, be more careful
|
|
26
|
+
# red: High risk of context loss, verify before acting
|
|
27
|
+
|
|
28
|
+
# ============================================================================
|
|
29
|
+
# COMPRESSION STATUS
|
|
30
|
+
# ============================================================================
|
|
31
|
+
compression:
|
|
32
|
+
last_compaction: null
|
|
33
|
+
compressions_this_session: 0
|
|
34
|
+
data_potentially_lost: []
|
|
35
|
+
# Example when compression occurs:
|
|
36
|
+
# data_potentially_lost:
|
|
37
|
+
# - "Detailed error messages from turns 1-15"
|
|
38
|
+
# - "Specific file paths discussed early in session"
|
|
39
|
+
# - "Rationale for early decisions"
|
|
40
|
+
|
|
41
|
+
# ============================================================================
|
|
42
|
+
# SESSION CONTINUITY
|
|
43
|
+
# ============================================================================
|
|
44
|
+
session:
|
|
45
|
+
started_at: "${TIMESTAMP}"
|
|
46
|
+
interactions: 0
|
|
47
|
+
concepts_executed: 0
|
|
48
|
+
checkpoints_created: 0
|
|
49
|
+
last_action: null
|
|
50
|
+
# Example:
|
|
51
|
+
# last_action:
|
|
52
|
+
# concept: "implementation"
|
|
53
|
+
# action: "generate"
|
|
54
|
+
# timestamp: "2025-12-05T10:30:00Z"
|
|
55
|
+
|
|
56
|
+
# ============================================================================
|
|
57
|
+
# GROUNDING STATUS
|
|
58
|
+
# ============================================================================
|
|
59
|
+
grounding:
|
|
60
|
+
last_grounding_check: "${TIMESTAMP}"
|
|
61
|
+
directory_verified: true
|
|
62
|
+
rules_loaded: true
|
|
63
|
+
anchors_current: true
|
|
64
|
+
safety_constraints_active: true
|
|
65
|
+
|
|
66
|
+
# ============================================================================
|
|
67
|
+
# CONFIDENCE INDICATORS
|
|
68
|
+
# ============================================================================
|
|
69
|
+
confidence:
|
|
70
|
+
overall: "high" # high, medium, low
|
|
71
|
+
factors:
|
|
72
|
+
context_fresh: true
|
|
73
|
+
no_compression: true
|
|
74
|
+
anchors_loaded: true
|
|
75
|
+
recent_verification: true
|
|
76
|
+
|
|
77
|
+
# Confidence meanings:
|
|
78
|
+
# high: Proceed normally
|
|
79
|
+
# medium: Verify assumptions before destructive ops
|
|
80
|
+
# low: Re-read anchors, verify state before any action
|
|
81
|
+
|
|
82
|
+
# ============================================================================
|
|
83
|
+
# WARNINGS FOR CLAUDE TO SEE
|
|
84
|
+
# ============================================================================
|
|
85
|
+
warnings: []
|
|
86
|
+
# Example warnings:
|
|
87
|
+
# - type: "compression_occurred"
|
|
88
|
+
# message: "Context was compressed 2 turns ago. Verify assumptions."
|
|
89
|
+
# severity: "medium"
|
|
90
|
+
# recommendation: "Re-read koan/anchors/ before destructive operations"
|
|
91
|
+
#
|
|
92
|
+
# - type: "directory_mismatch"
|
|
93
|
+
# message: "Working directory may have changed"
|
|
94
|
+
# severity: "high"
|
|
95
|
+
# recommendation: "Run 'pwd' to verify current location"
|
|
96
|
+
#
|
|
97
|
+
# - type: "long_session"
|
|
98
|
+
# message: "Session has 50+ interactions, context may be degraded"
|
|
99
|
+
# severity: "low"
|
|
100
|
+
# recommendation: "Consider creating a checkpoint"
|
|
101
|
+
|
|
102
|
+
# ============================================================================
|
|
103
|
+
# RECOMMENDATIONS
|
|
104
|
+
# ============================================================================
|
|
105
|
+
recommendations: []
|
|
106
|
+
# Example recommendations based on state:
|
|
107
|
+
# - "Continue normally - context is healthy"
|
|
108
|
+
# - "Consider running /checkpoint before next major operation"
|
|
109
|
+
# - "Re-read koan/anchors/rules.anchor.yaml to refresh safety rules"
|
|
110
|
+
|
|
111
|
+
# ============================================================================
|
|
112
|
+
# RECOVERY INFORMATION
|
|
113
|
+
# ============================================================================
|
|
114
|
+
recovery:
|
|
115
|
+
last_checkpoint: null
|
|
116
|
+
checkpoint_available: false
|
|
117
|
+
# Example when checkpoint exists:
|
|
118
|
+
# last_checkpoint: "ckpt-003-impl"
|
|
119
|
+
# checkpoint_available: true
|
|
120
|
+
# checkpoint_phase: "implementation_complete"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Concept Complete Hook
|
|
3
|
+
#
|
|
4
|
+
# Called by agent frontmatter when a concept completes.
|
|
5
|
+
# Records concept-specific completion data via SQLite events.
|
|
6
|
+
#
|
|
7
|
+
# Usage: concept-complete.sh <concept-name>
|
|
8
|
+
#
|
|
9
|
+
# Arguments:
|
|
10
|
+
# $1 - Concept name (story, architecture, implementation, quality, version, context)
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
CONCEPT_NAME="${1:-unknown}"
|
|
15
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
16
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
17
|
+
|
|
18
|
+
# Log concept completion to SQLite
|
|
19
|
+
if zen_state_available; then
|
|
20
|
+
zen_event_log "concept-complete-$(date +%s%N)" "concept_complete_frontmatter" "{\"concept\":\"$CONCEPT_NAME\"}" || true
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Concept-specific post-processing
|
|
24
|
+
case "$CONCEPT_NAME" in
|
|
25
|
+
story)
|
|
26
|
+
# Could trigger story validation or sync evaluation
|
|
27
|
+
;;
|
|
28
|
+
architecture)
|
|
29
|
+
# Could trigger ADR generation or diagram updates
|
|
30
|
+
;;
|
|
31
|
+
implementation)
|
|
32
|
+
# Could trigger test generation or linting
|
|
33
|
+
;;
|
|
34
|
+
quality)
|
|
35
|
+
# Could trigger coverage report generation
|
|
36
|
+
;;
|
|
37
|
+
version)
|
|
38
|
+
# Could trigger changelog updates
|
|
39
|
+
;;
|
|
40
|
+
context)
|
|
41
|
+
# Could trigger checkpoint creation
|
|
42
|
+
;;
|
|
43
|
+
esac
|
|
44
|
+
|
|
45
|
+
exit 0
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Hook Common Library
|
|
3
|
+
#
|
|
4
|
+
# Shared functions and variables for all Zen hooks.
|
|
5
|
+
# Source this at the top of any hook script:
|
|
6
|
+
#
|
|
7
|
+
# source "$(dirname "$0")/lib/common.sh"
|
|
8
|
+
#
|
|
9
|
+
# Or from deployed location:
|
|
10
|
+
# HOOKS_DIR="${HOOKS_DIR:-$(dirname "$0")}"
|
|
11
|
+
# source "$HOOKS_DIR/lib/common.sh"
|
|
12
|
+
#
|
|
13
|
+
# Provides:
|
|
14
|
+
# Variables: PROJECT_ROOT, KOAN_DIR, STATE_DB, etc.
|
|
15
|
+
# Functions: zen_timestamp, zen_git_*, zen_ensure_dir, zen_state_available, zen_event_log, etc.
|
|
16
|
+
|
|
17
|
+
# =============================================================================
|
|
18
|
+
# Project Paths
|
|
19
|
+
# =============================================================================
|
|
20
|
+
|
|
21
|
+
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
|
|
22
|
+
|
|
23
|
+
KOAN_DIR="$PROJECT_ROOT/koan"
|
|
24
|
+
HEALTH_DIR="$KOAN_DIR/health"
|
|
25
|
+
HOOKS_DIR="$PROJECT_ROOT/.claude/hooks"
|
|
26
|
+
|
|
27
|
+
# =============================================================================
|
|
28
|
+
# Timestamps
|
|
29
|
+
# =============================================================================
|
|
30
|
+
|
|
31
|
+
# ISO 8601 UTC timestamp (e.g., 2026-01-15T08:30:00Z)
|
|
32
|
+
zen_timestamp_iso() {
|
|
33
|
+
date -u +"%Y-%m-%dT%H:%M:%SZ"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Compact timestamp for IDs (e.g., 20260115-083000)
|
|
37
|
+
zen_timestamp_compact() {
|
|
38
|
+
date -u +"%Y%m%d-%H%M%S"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Epoch seconds (for unique IDs)
|
|
42
|
+
zen_timestamp_epoch() {
|
|
43
|
+
date +%s
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Convenience: set TIMESTAMP to ISO format (most common usage)
|
|
47
|
+
TIMESTAMP="${TIMESTAMP:-$(zen_timestamp_iso)}"
|
|
48
|
+
|
|
49
|
+
# =============================================================================
|
|
50
|
+
# Git Context
|
|
51
|
+
# =============================================================================
|
|
52
|
+
|
|
53
|
+
# Current branch name
|
|
54
|
+
zen_git_branch() {
|
|
55
|
+
git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Short hash of HEAD
|
|
59
|
+
zen_git_short_hash() {
|
|
60
|
+
git rev-parse --short HEAD 2>/dev/null || echo "unknown"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# Last commit as "hash subject"
|
|
64
|
+
zen_git_last_commit() {
|
|
65
|
+
git log -1 --format="%h %s" 2>/dev/null || echo "no commits"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# Count of uncommitted files (staged + unstaged + untracked)
|
|
69
|
+
zen_git_uncommitted_count() {
|
|
70
|
+
git status --porcelain 2>/dev/null | wc -l | tr -d ' '
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# =============================================================================
|
|
74
|
+
# Directory Helpers
|
|
75
|
+
# =============================================================================
|
|
76
|
+
|
|
77
|
+
# Ensure one or more directories exist.
|
|
78
|
+
# Usage: zen_ensure_dir "/path/to/dir1" "/path/to/dir2"
|
|
79
|
+
zen_ensure_dir() {
|
|
80
|
+
for dir in "$@"; do
|
|
81
|
+
mkdir -p "$dir"
|
|
82
|
+
done
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# =============================================================================
|
|
86
|
+
# SQLite State Helpers (state.db — single source of truth)
|
|
87
|
+
# =============================================================================
|
|
88
|
+
|
|
89
|
+
STATE_DB="$KOAN_DIR/state/state.db"
|
|
90
|
+
|
|
91
|
+
# Check if sqlite3 is available and state.db exists
|
|
92
|
+
zen_state_available() {
|
|
93
|
+
command -v sqlite3 &>/dev/null && [ -f "$STATE_DB" ]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# ─── Health ────────────────────────────────────────────────
|
|
97
|
+
|
|
98
|
+
# Read health from SQLite. Output: "pct|zone"
|
|
99
|
+
zen_health_get() {
|
|
100
|
+
sqlite3 "$STATE_DB" "SELECT context_usage_percent, zone FROM health ORDER BY rowid DESC LIMIT 1;" 2>/dev/null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Write health to SQLite (upsert)
|
|
104
|
+
zen_health_update() {
|
|
105
|
+
local pct="$1" zone="$2"
|
|
106
|
+
sqlite3 "$STATE_DB" "INSERT OR REPLACE INTO health (id, context_usage_percent, zone, updated_at) VALUES (1, $pct, '$zone', datetime('now'));" 2>/dev/null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# ─── Events ───────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
# Log an event to SQLite
|
|
112
|
+
zen_event_log() {
|
|
113
|
+
local id="$1" type="$2" data="$3"
|
|
114
|
+
sqlite3 "$STATE_DB" "INSERT OR IGNORE INTO events (id, type, data, created_at) VALUES ('$id', '$type', '${data//\'/\'\'}', datetime('now'));" 2>/dev/null
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# ─── Checkpoints ──────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
# Save a checkpoint to SQLite
|
|
120
|
+
zen_checkpoint_save() {
|
|
121
|
+
local id="$1" name="$2" type="$3" data="$4"
|
|
122
|
+
sqlite3 "$STATE_DB" "INSERT OR IGNORE INTO checkpoints (id, name, type, data, created_at) VALUES ('$id', '$name', '$type', '${data//\'/\'\'}', datetime('now'));" 2>/dev/null
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Count checkpoints in SQLite
|
|
126
|
+
zen_checkpoint_count() {
|
|
127
|
+
sqlite3 "$STATE_DB" "SELECT COUNT(*) FROM checkpoints;" 2>/dev/null || echo "0"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Get latest checkpoint. Output: "id|name|type|created_at"
|
|
131
|
+
zen_checkpoint_latest() {
|
|
132
|
+
sqlite3 "$STATE_DB" "SELECT id, name, type, created_at FROM checkpoints ORDER BY created_at DESC LIMIT 1;" 2>/dev/null
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# Get minutes since last checkpoint (returns 9999 if no checkpoints)
|
|
136
|
+
zen_checkpoint_age_minutes() {
|
|
137
|
+
sqlite3 "$STATE_DB" "SELECT CAST((julianday('now') - julianday(created_at)) * 1440 AS INTEGER) FROM checkpoints ORDER BY created_at DESC LIMIT 1;" 2>/dev/null || echo "9999"
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# Count checkpoints by type
|
|
141
|
+
zen_checkpoint_count_by_type() {
|
|
142
|
+
local type="$1"
|
|
143
|
+
sqlite3 "$STATE_DB" "SELECT COUNT(*) FROM checkpoints WHERE type='$type';" 2>/dev/null || echo "0"
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# Get description from latest checkpoint JSON data
|
|
147
|
+
zen_checkpoint_latest_description() {
|
|
148
|
+
sqlite3 "$STATE_DB" "SELECT json_extract(data, '$.description') FROM checkpoints ORDER BY created_at DESC LIMIT 1;" 2>/dev/null || echo ""
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# =============================================================================
|
|
152
|
+
# Logging
|
|
153
|
+
# =============================================================================
|
|
154
|
+
|
|
155
|
+
# Append a timestamped log entry.
|
|
156
|
+
# Usage: zen_log <file> <level> <message>
|
|
157
|
+
zen_log() {
|
|
158
|
+
local file="$1" level="$2" message="$3"
|
|
159
|
+
echo "[$(zen_timestamp_iso)] [$level] $message" >> "$file"
|
|
160
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Post-Commit Hook
|
|
3
|
+
#
|
|
4
|
+
# Called after version.commit completes successfully.
|
|
5
|
+
# Logs commit data to SQLite events.
|
|
6
|
+
#
|
|
7
|
+
# Usage: post-commit.sh <story-id> <commit-hash> <flow-id>
|
|
8
|
+
#
|
|
9
|
+
# Arguments:
|
|
10
|
+
# $1 - Story ID associated with this commit
|
|
11
|
+
# $2 - Git commit hash
|
|
12
|
+
# $3 - Flow ID for provenance tracking
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
STORY_ID="${1:-unknown}"
|
|
17
|
+
COMMIT_HASH="${2:-unknown}"
|
|
18
|
+
FLOW_ID="${3:-unknown}"
|
|
19
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
20
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
21
|
+
|
|
22
|
+
# Get commit message
|
|
23
|
+
COMMIT_MSG=""
|
|
24
|
+
if [ "$COMMIT_HASH" != "unknown" ]; then
|
|
25
|
+
COMMIT_MSG=$(git log -1 --format="%s" "$COMMIT_HASH" 2>/dev/null || echo "")
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Log commit to SQLite
|
|
29
|
+
if zen_state_available; then
|
|
30
|
+
# Escape commit message for JSON (replace quotes and newlines)
|
|
31
|
+
SAFE_MSG=$(echo "$COMMIT_MSG" | tr '"' "'" | tr '\n' ' ')
|
|
32
|
+
zen_event_log "commit-$(date +%s)" "git_commit" "{\"story_id\":\"$STORY_ID\",\"commit_hash\":\"$COMMIT_HASH\",\"flow_id\":\"$FLOW_ID\",\"message\":\"$SAFE_MSG\"}" || true
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# Output for hook runner
|
|
36
|
+
echo "post-commit: $STORY_ID -> $COMMIT_HASH"
|
|
37
|
+
exit 0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Post-Concept-Action Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs after any concept completes an action.
|
|
5
|
+
# It logs provenance to SQLite events and can trigger synchronizations.
|
|
6
|
+
#
|
|
7
|
+
# Hook Contract:
|
|
8
|
+
# - Receives action data via environment variables
|
|
9
|
+
# - Creates provenance event in SQLite
|
|
10
|
+
# - Must complete quickly (<100ms)
|
|
11
|
+
#
|
|
12
|
+
# Environment Variables (set by Claude Code):
|
|
13
|
+
# - ZEN_CONCEPT: Which concept performed the action
|
|
14
|
+
# - ZEN_ACTION: Which action was performed
|
|
15
|
+
# - ZEN_ACTION_ID: Unique action identifier
|
|
16
|
+
# - ZEN_STATUS: Action status (completed/blocked/failed)
|
|
17
|
+
# - ZEN_FLOW_ID: Parent flow identifier (if part of workflow)
|
|
18
|
+
# - ZEN_TRIGGERED_BY: Parent action ID (if triggered by sync)
|
|
19
|
+
# - ZEN_SYNC_ID: Synchronization rule ID (if triggered by sync)
|
|
20
|
+
# - ZEN_MODEL: Which model was used (haiku/sonnet)
|
|
21
|
+
# - ZEN_COST_USD: Estimated cost in USD
|
|
22
|
+
|
|
23
|
+
set -e
|
|
24
|
+
|
|
25
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
26
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
27
|
+
|
|
28
|
+
# Generate action ID if not provided
|
|
29
|
+
ACTION_ID="${ZEN_ACTION_ID:-act-$(date +%s)}"
|
|
30
|
+
GIT_BRANCH="$(zen_git_branch)"
|
|
31
|
+
GIT_COMMIT="$(zen_git_short_hash)"
|
|
32
|
+
|
|
33
|
+
# Log provenance event to SQLite
|
|
34
|
+
if zen_state_available; then
|
|
35
|
+
zen_event_log "$ACTION_ID" "concept_action" "{\"concept\":\"${ZEN_CONCEPT:-unknown}\",\"action\":\"${ZEN_ACTION:-unknown}\",\"status\":\"${ZEN_STATUS:-unknown}\",\"flow_id\":\"${ZEN_FLOW_ID:-null}\",\"triggered_by\":\"${ZEN_TRIGGERED_BY:-null}\",\"sync_id\":\"${ZEN_SYNC_ID:-null}\",\"model\":\"${ZEN_MODEL:-unknown}\",\"cost_usd\":${ZEN_COST_USD:-0.0},\"git_branch\":\"$GIT_BRANCH\",\"git_commit\":\"$GIT_COMMIT\"}" || true
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Success
|
|
39
|
+
exit 0
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Project Structure Validation Hook
|
|
3
|
+
#
|
|
4
|
+
# Runs after Write/Edit tool use to detect files in wrong locations.
|
|
5
|
+
# Warns but does not block (to avoid breaking workflows).
|
|
6
|
+
#
|
|
7
|
+
# Protected directories:
|
|
8
|
+
# - koan/ → ONLY state files (.yaml, .db) allowed
|
|
9
|
+
# - .claude/ → ONLY Zen config files allowed
|
|
10
|
+
# - .zen/ → NEVER modify (submodule)
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
# Get tool input from stdin (JSON)
|
|
15
|
+
INPUT=$(cat)
|
|
16
|
+
|
|
17
|
+
# Extract file path from tool input
|
|
18
|
+
# Handles both Write and Edit tools
|
|
19
|
+
FILE_PATH=$(echo "$INPUT" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' | head -n 1 | sed 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
|
|
20
|
+
|
|
21
|
+
# If no file path found, exit silently
|
|
22
|
+
[ -z "$FILE_PATH" ] && exit 0
|
|
23
|
+
|
|
24
|
+
# Get project root
|
|
25
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
26
|
+
|
|
27
|
+
# Make path relative for checking
|
|
28
|
+
REL_PATH="${FILE_PATH#$PROJECT_ROOT/}"
|
|
29
|
+
|
|
30
|
+
# Function to output warning
|
|
31
|
+
warn() {
|
|
32
|
+
echo ""
|
|
33
|
+
echo "⚠️ PROJECT STRUCTURE WARNING"
|
|
34
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
35
|
+
echo "$1"
|
|
36
|
+
echo ""
|
|
37
|
+
echo "See: .claude/skills/project-structure.md"
|
|
38
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
39
|
+
echo ""
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Check 1: .zen/ directory (NEVER modify)
|
|
43
|
+
if [[ "$REL_PATH" == .zen/* ]]; then
|
|
44
|
+
warn "Modifying .zen/ submodule is not allowed.
|
|
45
|
+
|
|
46
|
+
File: $REL_PATH
|
|
47
|
+
|
|
48
|
+
The .zen/ directory is a git submodule and should never be modified.
|
|
49
|
+
To customize Zen, edit files in .claude/ instead."
|
|
50
|
+
exit 0
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Check 2: koan/ directory (ONLY state files)
|
|
54
|
+
if [[ "$REL_PATH" == koan/* ]]; then
|
|
55
|
+
# Allow .yaml, .db, .md, .log files
|
|
56
|
+
if [[ "$REL_PATH" != *.yaml && "$REL_PATH" != *.db && "$REL_PATH" != *.md && "$REL_PATH" != *.log ]]; then
|
|
57
|
+
EXTENSION="${REL_PATH##*.}"
|
|
58
|
+
warn "Unexpected file detected in koan/ directory.
|
|
59
|
+
|
|
60
|
+
File: $REL_PATH
|
|
61
|
+
Extension: .$EXTENSION
|
|
62
|
+
|
|
63
|
+
The koan/ directory should ONLY contain:
|
|
64
|
+
- .db files (SQLite state)
|
|
65
|
+
- .yaml files (configuration/anchors)
|
|
66
|
+
- README.md (documentation)
|
|
67
|
+
|
|
68
|
+
Source code should be placed in:
|
|
69
|
+
- src/ (source files)
|
|
70
|
+
- tests/ (test files)
|
|
71
|
+
- lib/ (libraries)
|
|
72
|
+
|
|
73
|
+
Please move this file to the appropriate project directory."
|
|
74
|
+
exit 0
|
|
75
|
+
fi
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Check 3: .claude/ directory (ONLY Zen config)
|
|
79
|
+
if [[ "$REL_PATH" == .claude/* ]]; then
|
|
80
|
+
# Allow known Zen file types
|
|
81
|
+
case "$REL_PATH" in
|
|
82
|
+
*.md|*.yaml|*.json|*.sh)
|
|
83
|
+
# These are valid Zen config files
|
|
84
|
+
;;
|
|
85
|
+
*)
|
|
86
|
+
EXTENSION="${REL_PATH##*.}"
|
|
87
|
+
# Check for source code extensions
|
|
88
|
+
case "$EXTENSION" in
|
|
89
|
+
ts|js|tsx|jsx|py|go|rs|java|cpp|c|h|rb|php|swift|kt)
|
|
90
|
+
warn "Source code detected in .claude/ directory.
|
|
91
|
+
|
|
92
|
+
File: $REL_PATH
|
|
93
|
+
Extension: .$EXTENSION
|
|
94
|
+
|
|
95
|
+
The .claude/ directory should ONLY contain Zen configuration:
|
|
96
|
+
- concepts/*.md
|
|
97
|
+
- agents/*.md
|
|
98
|
+
- skills/*.md
|
|
99
|
+
- commands/*.md
|
|
100
|
+
- synchronizations/*.yaml
|
|
101
|
+
- schemas/*.json
|
|
102
|
+
- hooks/*.sh
|
|
103
|
+
|
|
104
|
+
Source code should be placed in:
|
|
105
|
+
- src/ (source files)
|
|
106
|
+
- tests/ (test files)
|
|
107
|
+
- lib/ (libraries)
|
|
108
|
+
|
|
109
|
+
Please move this file to the appropriate project directory."
|
|
110
|
+
;;
|
|
111
|
+
esac
|
|
112
|
+
;;
|
|
113
|
+
esac
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
# Check 4: Source code extensions in root koan subdirectories
|
|
117
|
+
# This catches things like koan/implementations/auth.ts
|
|
118
|
+
if [[ "$REL_PATH" == koan/*/* ]]; then
|
|
119
|
+
EXTENSION="${REL_PATH##*.}"
|
|
120
|
+
case "$EXTENSION" in
|
|
121
|
+
ts|js|tsx|jsx|py|go|rs|java|cpp|c|h|rb|php|swift|kt|css|scss|html|vue|svelte)
|
|
122
|
+
warn "Source code detected in koan/ subdirectory.
|
|
123
|
+
|
|
124
|
+
File: $REL_PATH
|
|
125
|
+
Extension: .$EXTENSION
|
|
126
|
+
|
|
127
|
+
The koan/ directory and its subdirectories should ONLY contain state files (.db, .yaml).
|
|
128
|
+
|
|
129
|
+
Example of correct structure:
|
|
130
|
+
koan/implementations/impl-001.yaml (metadata about implementation)
|
|
131
|
+
src/auth.ts (actual source code)
|
|
132
|
+
|
|
133
|
+
Please move the source code to the project's src/ directory."
|
|
134
|
+
;;
|
|
135
|
+
esac
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
exit 0
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen PostToolUse Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs after tool execution completes.
|
|
5
|
+
# It tracks provenance for concept actions (Task tool) via SQLite events.
|
|
6
|
+
#
|
|
7
|
+
# Environment variables available:
|
|
8
|
+
# - CLAUDE_TOOL_NAME: Name of the tool that was executed
|
|
9
|
+
# - CLAUDE_TOOL_INPUT: JSON input to the tool
|
|
10
|
+
# - CLAUDE_TOOL_OUTPUT: JSON output from the tool (may be truncated)
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
# Only track Task tool calls (concept actions)
|
|
15
|
+
if [ "$CLAUDE_TOOL_NAME" != "Task" ]; then
|
|
16
|
+
exit 0
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
20
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
21
|
+
|
|
22
|
+
# Extract subagent type from input (simplified parsing)
|
|
23
|
+
SUBAGENT_TYPE=""
|
|
24
|
+
if [ -n "$CLAUDE_TOOL_INPUT" ]; then
|
|
25
|
+
SUBAGENT_TYPE=$(echo "$CLAUDE_TOOL_INPUT" | grep -o '"subagent_type"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*: *"//' | tr -d '"' || echo "")
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Only track concept actions
|
|
29
|
+
case "$SUBAGENT_TYPE" in
|
|
30
|
+
story-concept|architecture-concept|implementation-concept|quality-concept|version-concept|context-concept)
|
|
31
|
+
;;
|
|
32
|
+
*)
|
|
33
|
+
# Not a concept action, skip
|
|
34
|
+
exit 0
|
|
35
|
+
;;
|
|
36
|
+
esac
|
|
37
|
+
|
|
38
|
+
# Determine concept name from subagent type
|
|
39
|
+
CONCEPT_NAME=$(echo "$SUBAGENT_TYPE" | sed 's/-concept//')
|
|
40
|
+
GIT_BRANCH="$(zen_git_branch)"
|
|
41
|
+
GIT_COMMIT="$(zen_git_short_hash)"
|
|
42
|
+
|
|
43
|
+
# Log task invocation to SQLite
|
|
44
|
+
if zen_state_available; then
|
|
45
|
+
zen_event_log "task-$(date +%s%N)" "task_invocation" "{\"concept\":\"$CONCEPT_NAME\",\"subagent_type\":\"$SUBAGENT_TYPE\",\"git_branch\":\"$GIT_BRANCH\",\"git_commit\":\"$GIT_COMMIT\"}" || true
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Output confirmation (visible in transcript)
|
|
49
|
+
echo "Provenance recorded: $CONCEPT_NAME"
|
|
50
|
+
|
|
51
|
+
exit 0
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen PreCompact Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs before Claude Code compresses the conversation history.
|
|
5
|
+
# It saves a checkpoint to preserve critical context.
|
|
6
|
+
#
|
|
7
|
+
# Environment variables available:
|
|
8
|
+
# - CLAUDE_CONTEXT_TOKENS: Current token count before compaction
|
|
9
|
+
|
|
10
|
+
set -e
|
|
11
|
+
|
|
12
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
13
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
14
|
+
|
|
15
|
+
CHECKPOINT_ID="pre-compact-$(date +%s)"
|
|
16
|
+
GIT_BRANCH="$(zen_git_branch)"
|
|
17
|
+
GIT_COMMIT="$(zen_git_short_hash)"
|
|
18
|
+
|
|
19
|
+
# Build checkpoint data
|
|
20
|
+
JSON_DATA="{\"automatic\":true,\"description\":\"Auto-saved before context compaction\",\"context_tokens\":\"${CLAUDE_CONTEXT_TOKENS:-unknown}\",\"git_state\":{\"branch\":\"${GIT_BRANCH}\",\"commit\":\"${GIT_COMMIT}\"},\"session_start\":\"${ZEN_SESSION_START:-unknown}\"}"
|
|
21
|
+
|
|
22
|
+
# Write to SQLite
|
|
23
|
+
if zen_state_available; then
|
|
24
|
+
zen_checkpoint_save "$CHECKPOINT_ID" "$CHECKPOINT_ID" "pre_compact" "$JSON_DATA"
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# Output confirmation
|
|
28
|
+
echo "Pre-compaction checkpoint saved: $CHECKPOINT_ID"
|
|
29
|
+
echo "Context tokens: ${CLAUDE_CONTEXT_TOKENS:-unknown}"
|
|
30
|
+
|
|
31
|
+
# Inject project rules from anchors so they survive compaction
|
|
32
|
+
RULES_ANCHOR="$PROJECT_ROOT/koan/anchors/rules.anchor.yaml"
|
|
33
|
+
if [ -f "$RULES_ANCHOR" ]; then
|
|
34
|
+
echo ""
|
|
35
|
+
echo "=== PROJECT RULES (from koan/anchors/rules.anchor.yaml) ==="
|
|
36
|
+
grep -A1 'text:' "$RULES_ANCHOR" | grep 'text:' | sed 's/.*text: "/- /' | sed 's/"$//' || true
|
|
37
|
+
echo "=== Read koan/anchors/rules.anchor.yaml after compaction for full context ==="
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Output critical reminders for post-compaction
|
|
41
|
+
echo ""
|
|
42
|
+
echo "╔══════════════════════════════════════════════════════════════════╗"
|
|
43
|
+
echo "║ AFTER COMPACTION: ║"
|
|
44
|
+
echo "║ 1. Read \$PROJECT_ROOT/CLAUDE.md ║"
|
|
45
|
+
echo "║ 2. Run /restore to rebuild context from last checkpoint ║"
|
|
46
|
+
echo "╚══════════════════════════════════════════════════════════════════╝"
|
|
47
|
+
|
|
48
|
+
exit 0
|