@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,148 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Pre-Tool Grounding Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs BEFORE dangerous tool operations execute.
|
|
5
|
+
# It provides a safety layer to prevent destructive actions
|
|
6
|
+
# when Claude may have lost context due to compaction.
|
|
7
|
+
#
|
|
8
|
+
# Exit codes:
|
|
9
|
+
# 0 = Allow operation
|
|
10
|
+
# 2 = Block operation (message sent to Claude via stderr)
|
|
11
|
+
#
|
|
12
|
+
# Installation:
|
|
13
|
+
# This hook is configured via .claude/settings.local.json
|
|
14
|
+
# and called by Claude Code's PreToolUse hook system.
|
|
15
|
+
|
|
16
|
+
set -e
|
|
17
|
+
|
|
18
|
+
# Configuration
|
|
19
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
20
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
21
|
+
ANCHORS_DIR="$PROJECT_ROOT/koan/anchors"
|
|
22
|
+
LOG_FILE="$HEALTH_DIR/grounding.log"
|
|
23
|
+
|
|
24
|
+
# Ensure directories exist
|
|
25
|
+
mkdir -p "$HEALTH_DIR"
|
|
26
|
+
|
|
27
|
+
# Get tool input from Claude Code
|
|
28
|
+
TOOL_INPUT="${CLAUDE_TOOL_INPUT:-}"
|
|
29
|
+
TOOL_NAME="${CLAUDE_TOOL_NAME:-Bash}"
|
|
30
|
+
|
|
31
|
+
# Sanitize input for safe grep matching (escape special regex chars in input)
|
|
32
|
+
# This prevents command injection through crafted TOOL_INPUT
|
|
33
|
+
sanitize_for_grep() {
|
|
34
|
+
# Use printf to safely handle the input without eval
|
|
35
|
+
printf '%s' "$1"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# ============================================================================
|
|
39
|
+
# DANGEROUS PATTERNS - Warn when context is degraded
|
|
40
|
+
# ============================================================================
|
|
41
|
+
# Note: Catastrophic patterns (rm -rf /, dd if=, mkfs, etc.) are blocked at
|
|
42
|
+
# the permissions level via settings.local.json `permissions.deny` — they
|
|
43
|
+
# never reach this hook. This hook adds compression-aware warnings for
|
|
44
|
+
# dangerous-but-sometimes-needed patterns.
|
|
45
|
+
|
|
46
|
+
DANGEROUS_PATTERNS=(
|
|
47
|
+
"rm -rf"
|
|
48
|
+
"rm -r"
|
|
49
|
+
"git reset --hard"
|
|
50
|
+
"git clean -fd"
|
|
51
|
+
"git checkout -- \."
|
|
52
|
+
"git stash drop"
|
|
53
|
+
"git branch -D"
|
|
54
|
+
"DROP TABLE"
|
|
55
|
+
"DROP DATABASE"
|
|
56
|
+
"TRUNCATE"
|
|
57
|
+
"DELETE FROM .* WHERE 1"
|
|
58
|
+
"--force"
|
|
59
|
+
"--hard"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# ============================================================================
|
|
63
|
+
# LOGGING FUNCTION WITH ROTATION
|
|
64
|
+
# ============================================================================
|
|
65
|
+
|
|
66
|
+
# Rotate log if it exceeds 10MB
|
|
67
|
+
rotate_log_if_needed() {
|
|
68
|
+
local max_size=10485760 # 10MB
|
|
69
|
+
if [ -f "$LOG_FILE" ]; then
|
|
70
|
+
local size=$(stat -f%z "$LOG_FILE" 2>/dev/null || stat --printf="%s" "$LOG_FILE" 2>/dev/null || echo 0)
|
|
71
|
+
if [ "$size" -gt "$max_size" ]; then
|
|
72
|
+
mv "$LOG_FILE" "${LOG_FILE}.old"
|
|
73
|
+
echo "[$TIMESTAMP] [INFO] Log rotated (exceeded 10MB)" > "$LOG_FILE"
|
|
74
|
+
fi
|
|
75
|
+
fi
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
log_event() {
|
|
79
|
+
local level="$1"
|
|
80
|
+
local message="$2"
|
|
81
|
+
rotate_log_if_needed
|
|
82
|
+
echo "[$TIMESTAMP] [$level] $message" >> "$LOG_FILE"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# ============================================================================
|
|
86
|
+
# CHECK FUNCTIONS
|
|
87
|
+
# ============================================================================
|
|
88
|
+
|
|
89
|
+
check_dangerous_patterns() {
|
|
90
|
+
for pattern in "${DANGEROUS_PATTERNS[@]}"; do
|
|
91
|
+
# Use printf to safely pipe input (prevents command injection)
|
|
92
|
+
if printf '%s\n' "$TOOL_INPUT" | grep -qiE -- "$pattern"; then
|
|
93
|
+
log_event "DANGEROUS" "Dangerous pattern detected: $pattern | Command: $TOOL_INPUT"
|
|
94
|
+
|
|
95
|
+
# Check if we're in a degraded context state (SQLite)
|
|
96
|
+
local compression_count=0
|
|
97
|
+
if zen_state_available; then
|
|
98
|
+
compression_count=$(zen_checkpoint_count_by_type "pre_compact")
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
if [ "$compression_count" -gt 0 ]; then
|
|
102
|
+
echo "WARNING: Dangerous operation detected after context compression." >&2
|
|
103
|
+
echo "Pattern: $pattern" >&2
|
|
104
|
+
echo "Context has been compressed $compression_count time(s) this session." >&2
|
|
105
|
+
echo "Please verify your understanding of the current state before proceeding." >&2
|
|
106
|
+
log_event "WARN" "Dangerous op after compression (count: $compression_count)"
|
|
107
|
+
fi
|
|
108
|
+
return 0
|
|
109
|
+
fi
|
|
110
|
+
done
|
|
111
|
+
return 0
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
verify_working_directory() {
|
|
115
|
+
if [ -f "$ANCHORS_DIR/directory.anchor.yaml" ]; then
|
|
116
|
+
local expected_dir=$(grep -oP 'working_directory: "\K[^"]+' "$ANCHORS_DIR/directory.anchor.yaml" 2>/dev/null || echo "")
|
|
117
|
+
local current_dir=$(pwd)
|
|
118
|
+
|
|
119
|
+
if [ -n "$expected_dir" ] && [ "$expected_dir" != "$current_dir" ]; then
|
|
120
|
+
log_event "WARN" "Directory mismatch: expected=$expected_dir current=$current_dir"
|
|
121
|
+
fi
|
|
122
|
+
fi
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
update_health_status() {
|
|
126
|
+
# Log grounding check event to SQLite
|
|
127
|
+
if zen_state_available; then
|
|
128
|
+
zen_event_log "grounding-$(date +%s)" "grounding_check" "{\"tool\":\"${TOOL_NAME}\"}" || true
|
|
129
|
+
fi
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# ============================================================================
|
|
133
|
+
# MAIN EXECUTION
|
|
134
|
+
# ============================================================================
|
|
135
|
+
|
|
136
|
+
main() {
|
|
137
|
+
if [ -z "$TOOL_INPUT" ]; then
|
|
138
|
+
exit 0
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
check_dangerous_patterns
|
|
142
|
+
verify_working_directory
|
|
143
|
+
update_health_status
|
|
144
|
+
|
|
145
|
+
exit 0
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
main "$@"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Session Exit Checkpoint Hook
|
|
3
|
+
#
|
|
4
|
+
# Creates a checkpoint when the Claude Code session ends or is about to exit.
|
|
5
|
+
# Called by stop.sh when conditions warrant checkpoint creation.
|
|
6
|
+
#
|
|
7
|
+
# This hook captures:
|
|
8
|
+
# - Current git state (branch, uncommitted files)
|
|
9
|
+
# - Last commit information
|
|
10
|
+
# - Restoration prompt for next session
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
15
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
16
|
+
|
|
17
|
+
TIMESTAMP=$(date -u +"%Y%m%d-%H%M%S")
|
|
18
|
+
CREATED_AT=$(zen_timestamp_iso)
|
|
19
|
+
CHECKPOINT_ID="chk-session-exit-${TIMESTAMP}"
|
|
20
|
+
|
|
21
|
+
# Get git info
|
|
22
|
+
GIT_BRANCH=$(zen_git_branch)
|
|
23
|
+
LAST_COMMIT=$(zen_git_last_commit)
|
|
24
|
+
UNCOMMITTED_FILES=$(zen_git_uncommitted_count)
|
|
25
|
+
|
|
26
|
+
# Build JSON data for SQLite
|
|
27
|
+
JSON_DATA="{\"automatic\":true,\"git_state\":{\"branch\":\"${GIT_BRANCH}\",\"last_commit\":\"${LAST_COMMIT}\",\"uncommitted_files\":${UNCOMMITTED_FILES}},\"restoration_prompt\":\"Session ended on branch ${GIT_BRANCH}. Last commit: ${LAST_COMMIT}. Uncommitted files: ${UNCOMMITTED_FILES}.\"}"
|
|
28
|
+
|
|
29
|
+
# Write to SQLite
|
|
30
|
+
if zen_state_available; then
|
|
31
|
+
zen_checkpoint_save "$CHECKPOINT_ID" "session-exit-${TIMESTAMP}" "session_exit" "$JSON_DATA"
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
echo "Session checkpoint saved: $CHECKPOINT_ID"
|
|
35
|
+
exit 0
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen SessionStart Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs when a Claude Code session starts.
|
|
5
|
+
# It checks for available checkpoints and displays session context.
|
|
6
|
+
#
|
|
7
|
+
# Output goes to stdout and is shown to Claude in the transcript.
|
|
8
|
+
# Use $CLAUDE_ENV_FILE to persist environment variables.
|
|
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
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
16
|
+
echo "🧘 Zen Session Started"
|
|
17
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
18
|
+
|
|
19
|
+
# Check for available checkpoints (SQLite)
|
|
20
|
+
CHECKPOINT_COUNT=0
|
|
21
|
+
LATEST_NAME=""
|
|
22
|
+
LATEST_DESC=""
|
|
23
|
+
|
|
24
|
+
if zen_state_available; then
|
|
25
|
+
CHECKPOINT_COUNT=$(zen_checkpoint_count)
|
|
26
|
+
if [ "$CHECKPOINT_COUNT" -gt 0 ] 2>/dev/null; then
|
|
27
|
+
# Output: id|name|type|created_at
|
|
28
|
+
LATEST_ROW=$(zen_checkpoint_latest)
|
|
29
|
+
LATEST_NAME=$(echo "$LATEST_ROW" | cut -d'|' -f2)
|
|
30
|
+
LATEST_DESC=$(zen_checkpoint_latest_description)
|
|
31
|
+
LATEST_DESC="${LATEST_DESC:-Auto-saved checkpoint}"
|
|
32
|
+
fi
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [ "$CHECKPOINT_COUNT" -gt 0 ] 2>/dev/null; then
|
|
36
|
+
echo ""
|
|
37
|
+
echo "📍 Available Checkpoints: $CHECKPOINT_COUNT"
|
|
38
|
+
echo " Latest: $LATEST_NAME"
|
|
39
|
+
echo " Description: $LATEST_DESC"
|
|
40
|
+
echo ""
|
|
41
|
+
echo " 💡 Use /restore to load checkpoint context"
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Check health status (SQLite)
|
|
45
|
+
CONTEXT_USAGE=""
|
|
46
|
+
if zen_state_available; then
|
|
47
|
+
# Output: pct|zone
|
|
48
|
+
HEALTH_ROW=$(zen_health_get)
|
|
49
|
+
if [ -n "$HEALTH_ROW" ]; then
|
|
50
|
+
CONTEXT_USAGE=$(echo "$HEALTH_ROW" | cut -d'|' -f1)
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
if [ -n "$CONTEXT_USAGE" ] && [ "$CONTEXT_USAGE" != "0" ]; then
|
|
55
|
+
echo "📊 Context Usage: ${CONTEXT_USAGE}%"
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# Set environment variables for the session
|
|
59
|
+
if [ -n "$CLAUDE_ENV_FILE" ]; then
|
|
60
|
+
echo "ZEN_PROJECT_ROOT=$PROJECT_ROOT" >> "$CLAUDE_ENV_FILE"
|
|
61
|
+
echo "ZEN_SESSION_START=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$CLAUDE_ENV_FILE"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
echo ""
|
|
65
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
66
|
+
|
|
67
|
+
exit 0
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Status Line
|
|
3
|
+
#
|
|
4
|
+
# Displays real-time context usage alongside Zen-specific state.
|
|
5
|
+
# Called by Claude Code with JSON input on stdin.
|
|
6
|
+
#
|
|
7
|
+
# Output format: [Model] ctx% | checkpoints | health | workflows
|
|
8
|
+
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
# Read JSON input from Claude Code
|
|
12
|
+
INPUT=$(cat)
|
|
13
|
+
|
|
14
|
+
# Project root for Zen state files
|
|
15
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
16
|
+
|
|
17
|
+
# =============================================================================
|
|
18
|
+
# Parse Claude Code JSON
|
|
19
|
+
# =============================================================================
|
|
20
|
+
|
|
21
|
+
# Model name (short form)
|
|
22
|
+
MODEL=$(echo "$INPUT" | jq -r '.model.display_name // "Unknown"' 2>/dev/null | sed 's/Claude //' | sed 's/ /-/')
|
|
23
|
+
|
|
24
|
+
# Context window metrics
|
|
25
|
+
#
|
|
26
|
+
# Token types from Claude Code:
|
|
27
|
+
# input_tokens: Fresh tokens (not from cache) in this request
|
|
28
|
+
# cache_creation_input_tokens: Tokens being cached this request
|
|
29
|
+
# cache_read_input_tokens: Tokens read from cache (still occupy context)
|
|
30
|
+
#
|
|
31
|
+
# Total context usage = all tokens in the window, regardless of caching
|
|
32
|
+
# Caching affects cost, not context window occupancy
|
|
33
|
+
#
|
|
34
|
+
CONTEXT_SIZE=$(echo "$INPUT" | jq -r '.context_window.context_window_size // 200000' 2>/dev/null)
|
|
35
|
+
CURRENT_USAGE=$(echo "$INPUT" | jq -r '.context_window.current_usage // empty' 2>/dev/null)
|
|
36
|
+
|
|
37
|
+
if [ -n "$CURRENT_USAGE" ]; then
|
|
38
|
+
INPUT_TOKENS=$(echo "$CURRENT_USAGE" | jq -r '.input_tokens // 0')
|
|
39
|
+
CACHE_CREATE=$(echo "$CURRENT_USAGE" | jq -r '.cache_creation_input_tokens // 0')
|
|
40
|
+
CACHE_READ=$(echo "$CURRENT_USAGE" | jq -r '.cache_read_input_tokens // 0')
|
|
41
|
+
|
|
42
|
+
# Total context = all token types (caching is for cost, not context size)
|
|
43
|
+
TOTAL_TOKENS=$((INPUT_TOKENS + CACHE_CREATE + CACHE_READ))
|
|
44
|
+
CONTEXT_PCT=$((TOTAL_TOKENS * 100 / CONTEXT_SIZE))
|
|
45
|
+
else
|
|
46
|
+
CONTEXT_PCT="?"
|
|
47
|
+
TOTAL_TOKENS=0
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# =============================================================================
|
|
51
|
+
# Read Zen State (SQLite preferred, YAML fallback)
|
|
52
|
+
# =============================================================================
|
|
53
|
+
|
|
54
|
+
STATE_DB="$PROJECT_ROOT/koan/state/state.db"
|
|
55
|
+
|
|
56
|
+
# Checkpoint count (SQLite only)
|
|
57
|
+
CHECKPOINT_COUNT=0
|
|
58
|
+
if command -v sqlite3 &>/dev/null && [ -f "$STATE_DB" ]; then
|
|
59
|
+
CHECKPOINT_COUNT=$(sqlite3 "$STATE_DB" "SELECT COUNT(*) FROM checkpoints;" 2>/dev/null || echo "0")
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Health status (simplified) — use real context data computed below
|
|
63
|
+
HEALTH_STATUS="--"
|
|
64
|
+
|
|
65
|
+
# =============================================================================
|
|
66
|
+
# Context Threshold Checkpoint
|
|
67
|
+
# =============================================================================
|
|
68
|
+
# Trigger safety checkpoint at 70% context usage
|
|
69
|
+
|
|
70
|
+
THRESHOLD_FILE="$PROJECT_ROOT/koan/events/.context-threshold"
|
|
71
|
+
CONTEXT_THRESHOLD=70
|
|
72
|
+
|
|
73
|
+
# Only trigger if we have valid context percentage
|
|
74
|
+
if [ "$CONTEXT_PCT" != "?" ] && [ "$CONTEXT_PCT" -ge "$CONTEXT_THRESHOLD" ] 2>/dev/null; then
|
|
75
|
+
# Check if we already triggered at this threshold
|
|
76
|
+
LAST_TRIGGER_PCT=0
|
|
77
|
+
if [ -f "$THRESHOLD_FILE" ]; then
|
|
78
|
+
LAST_TRIGGER_PCT=$(cat "$THRESHOLD_FILE" 2>/dev/null || echo "0")
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# Only trigger once per threshold crossing (70-75% range)
|
|
82
|
+
if [ "$LAST_TRIGGER_PCT" -lt "$CONTEXT_THRESHOLD" ] && [ "$CONTEXT_PCT" -lt 75 ]; then
|
|
83
|
+
# Record that we triggered
|
|
84
|
+
mkdir -p "$(dirname "$THRESHOLD_FILE")"
|
|
85
|
+
echo "$CONTEXT_PCT" > "$THRESHOLD_FILE"
|
|
86
|
+
|
|
87
|
+
# Save checkpoint directly via SQLite
|
|
88
|
+
if command -v sqlite3 &>/dev/null && [ -f "$STATE_DB" ]; then
|
|
89
|
+
CHECKPOINT_ID="ctx-threshold-$(date +%s)"
|
|
90
|
+
CHECKPOINT_DATA="{\"context_pct\":${CONTEXT_PCT},\"threshold\":${CONTEXT_THRESHOLD},\"tokens_used\":${TOTAL_TOKENS},\"model\":\"${MODEL}\"}"
|
|
91
|
+
sqlite3 "$STATE_DB" "INSERT OR IGNORE INTO checkpoints (id, name, type, data, created_at) VALUES ('$CHECKPOINT_ID', 'context-threshold-${CONTEXT_PCT}pct', 'context_threshold', '$CHECKPOINT_DATA', datetime('now'));" 2>/dev/null || true
|
|
92
|
+
fi
|
|
93
|
+
fi
|
|
94
|
+
elif [ "$CONTEXT_PCT" != "?" ] && [ "$CONTEXT_PCT" -lt 50 ] 2>/dev/null; then
|
|
95
|
+
# Reset threshold tracking when context drops below 50%
|
|
96
|
+
rm -f "$THRESHOLD_FILE" 2>/dev/null || true
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# =============================================================================
|
|
100
|
+
# Update Health Status with Real Context Data (SQLite preferred)
|
|
101
|
+
# =============================================================================
|
|
102
|
+
|
|
103
|
+
if [ "$CONTEXT_PCT" != "?" ]; then
|
|
104
|
+
# Determine zone based on actual usage
|
|
105
|
+
if [ "$CONTEXT_PCT" -lt 50 ]; then
|
|
106
|
+
ZONE="green"
|
|
107
|
+
elif [ "$CONTEXT_PCT" -lt 80 ]; then
|
|
108
|
+
ZONE="yellow"
|
|
109
|
+
else
|
|
110
|
+
ZONE="red"
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
HEALTH_STATUS="$ZONE"
|
|
114
|
+
|
|
115
|
+
if command -v sqlite3 &>/dev/null && [ -f "$STATE_DB" ]; then
|
|
116
|
+
sqlite3 "$STATE_DB" "INSERT OR REPLACE INTO health (id, context_usage_percent, zone, updated_at) VALUES (1, ${CONTEXT_PCT}.0, '$ZONE', datetime('now'));" 2>/dev/null || true
|
|
117
|
+
fi
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# =============================================================================
|
|
121
|
+
# Build Status Line
|
|
122
|
+
# =============================================================================
|
|
123
|
+
|
|
124
|
+
# Context indicator with visual cue
|
|
125
|
+
if [ "$CONTEXT_PCT" = "?" ]; then
|
|
126
|
+
CTX_DISPLAY="ctx:?"
|
|
127
|
+
elif [ "$CONTEXT_PCT" -lt 50 ]; then
|
|
128
|
+
CTX_DISPLAY="ctx:${CONTEXT_PCT}%"
|
|
129
|
+
elif [ "$CONTEXT_PCT" -lt 80 ]; then
|
|
130
|
+
CTX_DISPLAY="ctx:${CONTEXT_PCT}%~"
|
|
131
|
+
else
|
|
132
|
+
CTX_DISPLAY="ctx:${CONTEXT_PCT}%!"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# Build output segments
|
|
136
|
+
OUTPUT="[$MODEL] $CTX_DISPLAY"
|
|
137
|
+
|
|
138
|
+
# Add checkpoint info if any exist
|
|
139
|
+
if [ "$CHECKPOINT_COUNT" -gt 0 ]; then
|
|
140
|
+
OUTPUT="$OUTPUT | cp:$CHECKPOINT_COUNT"
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
# Add health if available
|
|
144
|
+
if [ "$HEALTH_STATUS" != "--" ]; then
|
|
145
|
+
OUTPUT="$OUTPUT | $HEALTH_STATUS"
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
echo "$OUTPUT"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Stop Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs when Claude Code completes a response.
|
|
5
|
+
# It updates health status and can trigger auto-saves.
|
|
6
|
+
#
|
|
7
|
+
# Environment variables available:
|
|
8
|
+
# - CLAUDE_RESPONSE_TOKENS: Tokens in the response
|
|
9
|
+
# - CLAUDE_TOOL_CALLS: Number of tool calls made
|
|
10
|
+
|
|
11
|
+
set -e
|
|
12
|
+
|
|
13
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
14
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
15
|
+
|
|
16
|
+
# Track session metrics in SQLite if available
|
|
17
|
+
if zen_state_available; then
|
|
18
|
+
local_id="stop-$(date +%s%N)"
|
|
19
|
+
zen_event_log "$local_id" "session_interaction" "{\"tool_calls\":${CLAUDE_TOOL_CALLS:-0},\"response_tokens\":${CLAUDE_RESPONSE_TOKENS:-0}}" || true
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# =============================================================================
|
|
23
|
+
# Session Exit Checkpoint Logic
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# Create checkpoint if there's uncommitted work and it's been a while since last checkpoint
|
|
26
|
+
|
|
27
|
+
UNCOMMITTED="$(zen_git_uncommitted_count)"
|
|
28
|
+
CHECKPOINT_AGE=9999
|
|
29
|
+
|
|
30
|
+
if zen_state_available; then
|
|
31
|
+
CHECKPOINT_AGE=$(zen_checkpoint_age_minutes)
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Create session checkpoint if:
|
|
35
|
+
# 1. There's uncommitted work AND
|
|
36
|
+
# 2. It's been more than 30 minutes since last checkpoint
|
|
37
|
+
if [ "$UNCOMMITTED" -gt 0 ] && [ "$CHECKPOINT_AGE" -gt 30 ]; then
|
|
38
|
+
SESSION_CHECKPOINT_SCRIPT="$PROJECT_ROOT/.claude/hooks/session-exit-checkpoint.sh"
|
|
39
|
+
if [ -x "$SESSION_CHECKPOINT_SCRIPT" ]; then
|
|
40
|
+
"$SESSION_CHECKPOINT_SCRIPT" > /dev/null 2>&1 || true
|
|
41
|
+
fi
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Silent operation - don't pollute output on every response
|
|
45
|
+
exit 0
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen SubagentStop Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs when a subagent (concept) completes execution.
|
|
5
|
+
# It tracks costs via SQLite events.
|
|
6
|
+
#
|
|
7
|
+
# Environment variables available:
|
|
8
|
+
# - CLAUDE_AGENT_NAME: Name of the subagent that stopped
|
|
9
|
+
# - CLAUDE_AGENT_DURATION_MS: How long the agent ran (milliseconds)
|
|
10
|
+
# - CLAUDE_AGENT_INPUT_TOKENS: Input tokens used
|
|
11
|
+
# - CLAUDE_AGENT_OUTPUT_TOKENS: Output tokens used
|
|
12
|
+
|
|
13
|
+
set -e
|
|
14
|
+
|
|
15
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
16
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
17
|
+
|
|
18
|
+
# Only track concept agents
|
|
19
|
+
case "$CLAUDE_AGENT_NAME" in
|
|
20
|
+
story-concept|architecture-concept|implementation-concept|quality-concept|version-concept|context-concept)
|
|
21
|
+
;;
|
|
22
|
+
*)
|
|
23
|
+
# Not a concept agent, skip
|
|
24
|
+
exit 0
|
|
25
|
+
;;
|
|
26
|
+
esac
|
|
27
|
+
|
|
28
|
+
# Extract concept name
|
|
29
|
+
CONCEPT_NAME=$(echo "$CLAUDE_AGENT_NAME" | sed 's/-concept//')
|
|
30
|
+
|
|
31
|
+
# Log concept completion to SQLite
|
|
32
|
+
if zen_state_available; then
|
|
33
|
+
zen_event_log "concept-$(date +%s%N)" "concept_complete" "{\"concept\":\"$CONCEPT_NAME\",\"duration_ms\":${CLAUDE_AGENT_DURATION_MS:-0},\"input_tokens\":${CLAUDE_AGENT_INPUT_TOKENS:-0},\"output_tokens\":${CLAUDE_AGENT_OUTPUT_TOKENS:-0}}" || true
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Output confirmation (visible in transcript)
|
|
37
|
+
DURATION_SEC=$((${CLAUDE_AGENT_DURATION_MS:-0} / 1000))
|
|
38
|
+
echo "Concept completed: $CONCEPT_NAME (${DURATION_SEC}s, ${CLAUDE_AGENT_INPUT_TOKENS:-0}+${CLAUDE_AGENT_OUTPUT_TOKENS:-0} tokens)"
|
|
39
|
+
|
|
40
|
+
exit 0
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Sync Blocked Hook
|
|
3
|
+
#
|
|
4
|
+
# Called when a synchronization rule is blocked (prerequisites not met).
|
|
5
|
+
# Logs blocked events to SQLite for workflow debugging and optimization.
|
|
6
|
+
#
|
|
7
|
+
# Usage: sync-blocked.sh <rule-id> <reason> [blocking-condition]
|
|
8
|
+
#
|
|
9
|
+
# Arguments:
|
|
10
|
+
# $1 - Sync rule ID (e.g., "story-to-arch", "arch-to-impl")
|
|
11
|
+
# $2 - Reason for blocking (e.g., "prerequisite_failed", "condition_not_met")
|
|
12
|
+
# $3 - Optional: The specific condition that caused blocking
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
RULE_ID="${1:-unknown}"
|
|
17
|
+
REASON="${2:-unknown}"
|
|
18
|
+
BLOCKING_CONDITION="${3:-}"
|
|
19
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
20
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
21
|
+
|
|
22
|
+
# Log blocked event to SQLite
|
|
23
|
+
if zen_state_available; then
|
|
24
|
+
zen_event_log "sync-blocked-$(date +%s%N)" "sync_blocked" "{\"rule_id\":\"$RULE_ID\",\"reason\":\"$REASON\",\"condition\":\"$BLOCKING_CONDITION\"}" || true
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# Rule-specific handling
|
|
28
|
+
case "$RULE_ID" in
|
|
29
|
+
story-to-arch)
|
|
30
|
+
# Story not ready - might need clarification
|
|
31
|
+
;;
|
|
32
|
+
arch-to-impl)
|
|
33
|
+
# Architecture incomplete or high risk awaiting approval
|
|
34
|
+
;;
|
|
35
|
+
impl-to-quality*)
|
|
36
|
+
# Implementation has blockers
|
|
37
|
+
;;
|
|
38
|
+
quality-to-version)
|
|
39
|
+
# Quality checks not passed
|
|
40
|
+
;;
|
|
41
|
+
esac
|
|
42
|
+
|
|
43
|
+
# Output for hook runner
|
|
44
|
+
echo "sync-blocked: $RULE_ID ($REASON)"
|
|
45
|
+
exit 0
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen Timeout Hook
|
|
3
|
+
#
|
|
4
|
+
# Called when a concept or sync rule times out.
|
|
5
|
+
# Logs timeout events and can trigger recovery actions.
|
|
6
|
+
#
|
|
7
|
+
# Usage: timeout.sh <source-type> <source-id> <timeout-ms>
|
|
8
|
+
#
|
|
9
|
+
# Arguments:
|
|
10
|
+
# $1 - Source type: "concept" or "sync"
|
|
11
|
+
# $2 - Source identifier (concept name or sync rule ID)
|
|
12
|
+
# $3 - Timeout duration in milliseconds
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
SOURCE_TYPE="${1:-unknown}"
|
|
17
|
+
SOURCE_ID="${2:-unknown}"
|
|
18
|
+
TIMEOUT_MS="${3:-0}"
|
|
19
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
20
|
+
source "$PROJECT_ROOT/.claude/hooks/lib/common.sh"
|
|
21
|
+
|
|
22
|
+
# Log timeout event to SQLite
|
|
23
|
+
if zen_state_available; then
|
|
24
|
+
EVENT_ID="timeout-$(date +%s%N)"
|
|
25
|
+
zen_event_log "$EVENT_ID" "timeout" "{\"source_type\":\"${SOURCE_TYPE}\",\"source_id\":\"${SOURCE_ID}\",\"timeout_ms\":${TIMEOUT_MS}}"
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Source-specific timeout handling
|
|
29
|
+
case "$SOURCE_TYPE" in
|
|
30
|
+
concept)
|
|
31
|
+
# Could notify user or trigger fallback
|
|
32
|
+
case "$SOURCE_ID" in
|
|
33
|
+
architecture)
|
|
34
|
+
# Architecture timeout is serious - might need simpler approach
|
|
35
|
+
;;
|
|
36
|
+
implementation)
|
|
37
|
+
# Implementation timeout - could break into smaller chunks
|
|
38
|
+
;;
|
|
39
|
+
esac
|
|
40
|
+
;;
|
|
41
|
+
sync)
|
|
42
|
+
# Sync rule timeout - log for sync evaluation skip
|
|
43
|
+
;;
|
|
44
|
+
esac
|
|
45
|
+
|
|
46
|
+
# Output for hook runner
|
|
47
|
+
echo "timeout: $SOURCE_TYPE/$SOURCE_ID after ${TIMEOUT_MS}ms"
|
|
48
|
+
exit 0
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Zen UserPromptSubmit Hook
|
|
3
|
+
#
|
|
4
|
+
# This hook runs when the user submits a prompt.
|
|
5
|
+
# It can classify intent and suggest workflows.
|
|
6
|
+
#
|
|
7
|
+
# Environment variables available:
|
|
8
|
+
# - CLAUDE_USER_PROMPT: The user's prompt text (may be truncated)
|
|
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
|
+
# Get prompt (handle potential truncation)
|
|
16
|
+
PROMPT="${CLAUDE_USER_PROMPT:-}"
|
|
17
|
+
|
|
18
|
+
# Skip if empty or very short
|
|
19
|
+
if [ ${#PROMPT} -lt 5 ]; then
|
|
20
|
+
exit 0
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Simple keyword-based intent classification
|
|
24
|
+
# (More sophisticated classification would use the /classify command)
|
|
25
|
+
INTENT="general"
|
|
26
|
+
SUGGESTED_WORKFLOW=""
|
|
27
|
+
|
|
28
|
+
# Check for feature/story keywords
|
|
29
|
+
if echo "$PROMPT" | grep -qiE "(add|create|implement|build|new feature|add feature)"; then
|
|
30
|
+
INTENT="feature"
|
|
31
|
+
SUGGESTED_WORKFLOW="/feature"
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Check for bug/fix keywords
|
|
35
|
+
if echo "$PROMPT" | grep -qiE "(fix|bug|broken|error|issue|doesn't work|not working)"; then
|
|
36
|
+
INTENT="bugfix"
|
|
37
|
+
SUGGESTED_WORKFLOW="/feature (bugfix mode)"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Check for refactor keywords
|
|
41
|
+
if echo "$PROMPT" | grep -qiE "(refactor|clean up|improve|optimize|reorganize)"; then
|
|
42
|
+
INTENT="refactor"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# Check for review keywords
|
|
46
|
+
if echo "$PROMPT" | grep -qiE "(review|check|audit|analyze|examine)"; then
|
|
47
|
+
INTENT="review"
|
|
48
|
+
SUGGESTED_WORKFLOW="/pr-review"
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Check for exploration keywords
|
|
52
|
+
if echo "$PROMPT" | grep -qiE "(explore|understand|how does|explain|what is)"; then
|
|
53
|
+
INTENT="exploration"
|
|
54
|
+
SUGGESTED_WORKFLOW="/explore"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# Log classification to SQLite
|
|
58
|
+
if zen_state_available; then
|
|
59
|
+
SAFE_PREVIEW=$(echo "$PROMPT" | head -c 100 | tr '"' "'" | tr '\n' ' ')
|
|
60
|
+
zen_event_log "route-$(date +%s)-$$" "intent_classification" "{\"intent\":\"$INTENT\",\"suggested_workflow\":\"$SUGGESTED_WORKFLOW\",\"prompt_length\":${#PROMPT},\"prompt_preview\":\"${SAFE_PREVIEW}...\"}" || true
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Only output suggestion for clear workflow matches
|
|
64
|
+
if [ -n "$SUGGESTED_WORKFLOW" ] && [ "$INTENT" != "general" ]; then
|
|
65
|
+
echo "Intent: $INTENT | Suggested: $SUGGESTED_WORKFLOW"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
exit 0
|