symbiote-cli 0.1.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/LICENSE +21 -0
- package/dist/bin/symbiote.d.ts +3 -0
- package/dist/bin/symbiote.d.ts.map +1 -0
- package/dist/bin/symbiote.js +202 -0
- package/dist/bin/symbiote.js.map +1 -0
- package/dist/bin/synapse.d.ts +3 -0
- package/dist/bin/synapse.d.ts.map +1 -0
- package/dist/bin/synapse.js +369 -0
- package/dist/bin/synapse.js.map +1 -0
- package/dist/src/brain/embeddings.d.ts +9 -0
- package/dist/src/brain/embeddings.d.ts.map +1 -0
- package/dist/src/brain/embeddings.js +24 -0
- package/dist/src/brain/embeddings.js.map +1 -0
- package/dist/src/brain/health/constraint-checker.d.ts +16 -0
- package/dist/src/brain/health/constraint-checker.d.ts.map +1 -0
- package/dist/src/brain/health/constraint-checker.js +93 -0
- package/dist/src/brain/health/constraint-checker.js.map +1 -0
- package/dist/src/brain/health/coupling-analyzer.d.ts +9 -0
- package/dist/src/brain/health/coupling-analyzer.d.ts.map +1 -0
- package/dist/src/brain/health/coupling-analyzer.js +105 -0
- package/dist/src/brain/health/coupling-analyzer.js.map +1 -0
- package/dist/src/brain/health/cycle-detector.d.ts +12 -0
- package/dist/src/brain/health/cycle-detector.d.ts.map +1 -0
- package/dist/src/brain/health/cycle-detector.js +79 -0
- package/dist/src/brain/health/cycle-detector.js.map +1 -0
- package/dist/src/brain/health/dead-code-detector.d.ts +9 -0
- package/dist/src/brain/health/dead-code-detector.d.ts.map +1 -0
- package/dist/src/brain/health/dead-code-detector.js +72 -0
- package/dist/src/brain/health/dead-code-detector.js.map +1 -0
- package/dist/src/brain/health/history.d.ts +21 -0
- package/dist/src/brain/health/history.d.ts.map +1 -0
- package/dist/src/brain/health/history.js +35 -0
- package/dist/src/brain/health/history.js.map +1 -0
- package/dist/src/brain/health/index.d.ts +25 -0
- package/dist/src/brain/health/index.d.ts.map +1 -0
- package/dist/src/brain/health/index.js +76 -0
- package/dist/src/brain/health/index.js.map +1 -0
- package/dist/src/brain/health/scorer.d.ts +19 -0
- package/dist/src/brain/health/scorer.d.ts.map +1 -0
- package/dist/src/brain/health/scorer.js +47 -0
- package/dist/src/brain/health/scorer.js.map +1 -0
- package/dist/src/brain/health/types.d.ts +67 -0
- package/dist/src/brain/health/types.d.ts.map +1 -0
- package/dist/src/brain/health/types.js +2 -0
- package/dist/src/brain/health/types.js.map +1 -0
- package/dist/src/brain/health.d.ts +30 -0
- package/dist/src/brain/health.d.ts.map +1 -0
- package/dist/src/brain/health.js +147 -0
- package/dist/src/brain/health.js.map +1 -0
- package/dist/src/brain/index.d.ts +3 -0
- package/dist/src/brain/index.d.ts.map +1 -0
- package/dist/src/brain/index.js +3 -0
- package/dist/src/brain/index.js.map +1 -0
- package/dist/src/brain/intent.d.ts +31 -0
- package/dist/src/brain/intent.d.ts.map +1 -0
- package/dist/src/brain/intent.js +120 -0
- package/dist/src/brain/intent.js.map +1 -0
- package/dist/src/commands/dna.d.ts +2 -0
- package/dist/src/commands/dna.d.ts.map +1 -0
- package/dist/src/commands/dna.js +128 -0
- package/dist/src/commands/dna.js.map +1 -0
- package/dist/src/commands/hooks.d.ts +6 -0
- package/dist/src/commands/hooks.d.ts.map +1 -0
- package/dist/src/commands/hooks.js +210 -0
- package/dist/src/commands/hooks.js.map +1 -0
- package/dist/src/commands/impact.d.ts +2 -0
- package/dist/src/commands/impact.d.ts.map +1 -0
- package/dist/src/commands/impact.js +50 -0
- package/dist/src/commands/impact.js.map +1 -0
- package/dist/src/commands/index.d.ts +9 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +9 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/init.d.ts +2 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +132 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/install.d.ts +2 -0
- package/dist/src/commands/install.d.ts.map +1 -0
- package/dist/src/commands/install.js +67 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/mcp.d.ts +2 -0
- package/dist/src/commands/mcp.d.ts.map +1 -0
- package/dist/src/commands/mcp.js +51 -0
- package/dist/src/commands/mcp.js.map +1 -0
- package/dist/src/commands/scan.d.ts +2 -0
- package/dist/src/commands/scan.d.ts.map +1 -0
- package/dist/src/commands/scan.js +46 -0
- package/dist/src/commands/scan.js.map +1 -0
- package/dist/src/commands/serve.d.ts +2 -0
- package/dist/src/commands/serve.d.ts.map +1 -0
- package/dist/src/commands/serve.js +93 -0
- package/dist/src/commands/serve.js.map +1 -0
- package/dist/src/commands/shared.d.ts +11 -0
- package/dist/src/commands/shared.d.ts.map +1 -0
- package/dist/src/commands/shared.js +137 -0
- package/dist/src/commands/shared.js.map +1 -0
- package/dist/src/commands/unbond.d.ts +2 -0
- package/dist/src/commands/unbond.d.ts.map +1 -0
- package/dist/src/commands/unbond.js +29 -0
- package/dist/src/commands/unbond.js.map +1 -0
- package/dist/src/core/algorithms.d.ts +19 -0
- package/dist/src/core/algorithms.d.ts.map +1 -0
- package/dist/src/core/algorithms.js +98 -0
- package/dist/src/core/algorithms.js.map +1 -0
- package/dist/src/core/embeddings.d.ts +12 -0
- package/dist/src/core/embeddings.d.ts.map +1 -0
- package/dist/src/core/embeddings.js +64 -0
- package/dist/src/core/embeddings.js.map +1 -0
- package/dist/src/core/git-impact.d.ts +25 -0
- package/dist/src/core/git-impact.d.ts.map +1 -0
- package/dist/src/core/git-impact.js +97 -0
- package/dist/src/core/git-impact.js.map +1 -0
- package/dist/src/core/graph-builder.d.ts +5 -0
- package/dist/src/core/graph-builder.d.ts.map +1 -0
- package/dist/src/core/graph-builder.js +88 -0
- package/dist/src/core/graph-builder.js.map +1 -0
- package/dist/src/core/graph.d.ts +34 -0
- package/dist/src/core/graph.d.ts.map +1 -0
- package/dist/src/core/graph.js +95 -0
- package/dist/src/core/graph.js.map +1 -0
- package/dist/src/core/impact.d.ts +22 -0
- package/dist/src/core/impact.d.ts.map +1 -0
- package/dist/src/core/impact.js +68 -0
- package/dist/src/core/impact.js.map +1 -0
- package/dist/src/core/languages.d.ts +4 -0
- package/dist/src/core/languages.d.ts.map +1 -0
- package/dist/src/core/languages.js +59 -0
- package/dist/src/core/languages.js.map +1 -0
- package/dist/src/core/parser.d.ts +16 -0
- package/dist/src/core/parser.d.ts.map +1 -0
- package/dist/src/core/parser.js +689 -0
- package/dist/src/core/parser.js.map +1 -0
- package/dist/src/core/scanner.d.ts +26 -0
- package/dist/src/core/scanner.d.ts.map +1 -0
- package/dist/src/core/scanner.js +87 -0
- package/dist/src/core/scanner.js.map +1 -0
- package/dist/src/core/search.d.ts +34 -0
- package/dist/src/core/search.d.ts.map +1 -0
- package/dist/src/core/search.js +146 -0
- package/dist/src/core/search.js.map +1 -0
- package/dist/src/core/types.d.ts +29 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/core/types.js +12 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/cortex/engine.d.ts +10 -0
- package/dist/src/cortex/engine.d.ts.map +1 -0
- package/dist/src/cortex/engine.js +93 -0
- package/dist/src/cortex/engine.js.map +1 -0
- package/dist/src/cortex/index.d.ts +13 -0
- package/dist/src/cortex/index.d.ts.map +1 -0
- package/dist/src/cortex/index.js +12 -0
- package/dist/src/cortex/index.js.map +1 -0
- package/dist/src/cortex/patterns.d.ts +63 -0
- package/dist/src/cortex/patterns.d.ts.map +1 -0
- package/dist/src/cortex/patterns.js +242 -0
- package/dist/src/cortex/patterns.js.map +1 -0
- package/dist/src/cortex/pgq-queries.d.ts +11 -0
- package/dist/src/cortex/pgq-queries.d.ts.map +1 -0
- package/dist/src/cortex/pgq-queries.js +23 -0
- package/dist/src/cortex/pgq-queries.js.map +1 -0
- package/dist/src/cortex/pgq.d.ts +5 -0
- package/dist/src/cortex/pgq.d.ts.map +1 -0
- package/dist/src/cortex/pgq.js +54 -0
- package/dist/src/cortex/pgq.js.map +1 -0
- package/dist/src/cortex/real-time-enrichment.d.ts +20 -0
- package/dist/src/cortex/real-time-enrichment.d.ts.map +1 -0
- package/dist/src/cortex/real-time-enrichment.js +96 -0
- package/dist/src/cortex/real-time-enrichment.js.map +1 -0
- package/dist/src/cortex/repository.d.ts +231 -0
- package/dist/src/cortex/repository.d.ts.map +1 -0
- package/dist/src/cortex/repository.js +1078 -0
- package/dist/src/cortex/repository.js.map +1 -0
- package/dist/src/cortex/schema.d.ts +9 -0
- package/dist/src/cortex/schema.d.ts.map +1 -0
- package/dist/src/cortex/schema.js +364 -0
- package/dist/src/cortex/schema.js.map +1 -0
- package/dist/src/cortex/stage-0-structure.d.ts +7 -0
- package/dist/src/cortex/stage-0-structure.d.ts.map +1 -0
- package/dist/src/cortex/stage-0-structure.js +119 -0
- package/dist/src/cortex/stage-0-structure.js.map +1 -0
- package/dist/src/cortex/stage-1-symbols.d.ts +7 -0
- package/dist/src/cortex/stage-1-symbols.d.ts.map +1 -0
- package/dist/src/cortex/stage-1-symbols.js +605 -0
- package/dist/src/cortex/stage-1-symbols.js.map +1 -0
- package/dist/src/cortex/stage-2-resolution.d.ts +7 -0
- package/dist/src/cortex/stage-2-resolution.d.ts.map +1 -0
- package/dist/src/cortex/stage-2-resolution.js +469 -0
- package/dist/src/cortex/stage-2-resolution.js.map +1 -0
- package/dist/src/cortex/stage-3-callgraph.d.ts +7 -0
- package/dist/src/cortex/stage-3-callgraph.d.ts.map +1 -0
- package/dist/src/cortex/stage-3-callgraph.js +323 -0
- package/dist/src/cortex/stage-3-callgraph.js.map +1 -0
- package/dist/src/cortex/stage-4-types.d.ts +7 -0
- package/dist/src/cortex/stage-4-types.d.ts.map +1 -0
- package/dist/src/cortex/stage-4-types.js +462 -0
- package/dist/src/cortex/stage-4-types.js.map +1 -0
- package/dist/src/cortex/stage-5-flow.d.ts +7 -0
- package/dist/src/cortex/stage-5-flow.d.ts.map +1 -0
- package/dist/src/cortex/stage-5-flow.js +702 -0
- package/dist/src/cortex/stage-5-flow.js.map +1 -0
- package/dist/src/cortex/stage-6-topology.d.ts +15 -0
- package/dist/src/cortex/stage-6-topology.d.ts.map +1 -0
- package/dist/src/cortex/stage-6-topology.js +382 -0
- package/dist/src/cortex/stage-6-topology.js.map +1 -0
- package/dist/src/cortex/stage-7-intelligence.d.ts +34 -0
- package/dist/src/cortex/stage-7-intelligence.d.ts.map +1 -0
- package/dist/src/cortex/stage-7-intelligence.js +258 -0
- package/dist/src/cortex/stage-7-intelligence.js.map +1 -0
- package/dist/src/cortex/topology-types.d.ts +78 -0
- package/dist/src/cortex/topology-types.d.ts.map +1 -0
- package/dist/src/cortex/topology-types.js +2 -0
- package/dist/src/cortex/topology-types.js.map +1 -0
- package/dist/src/cortex/types.d.ts +250 -0
- package/dist/src/cortex/types.d.ts.map +1 -0
- package/dist/src/cortex/types.js +2 -0
- package/dist/src/cortex/types.js.map +1 -0
- package/dist/src/dna/embeddings.d.ts +10 -0
- package/dist/src/dna/embeddings.d.ts.map +1 -0
- package/dist/src/dna/embeddings.js +46 -0
- package/dist/src/dna/embeddings.js.map +1 -0
- package/dist/src/dna/engine.d.ts +30 -0
- package/dist/src/dna/engine.d.ts.map +1 -0
- package/dist/src/dna/engine.js +254 -0
- package/dist/src/dna/engine.js.map +1 -0
- package/dist/src/dna/index.d.ts +5 -0
- package/dist/src/dna/index.d.ts.map +1 -0
- package/dist/src/dna/index.js +5 -0
- package/dist/src/dna/index.js.map +1 -0
- package/dist/src/dna/storage.d.ts +19 -0
- package/dist/src/dna/storage.d.ts.map +1 -0
- package/dist/src/dna/storage.js +112 -0
- package/dist/src/dna/storage.js.map +1 -0
- package/dist/src/dna/types.d.ts +38 -0
- package/dist/src/dna/types.d.ts.map +1 -0
- package/dist/src/dna/types.js +114 -0
- package/dist/src/dna/types.js.map +1 -0
- package/dist/src/events/bus.d.ts +10 -0
- package/dist/src/events/bus.d.ts.map +1 -0
- package/dist/src/events/bus.js +36 -0
- package/dist/src/events/bus.js.map +1 -0
- package/dist/src/events/ipc.d.ts +3 -0
- package/dist/src/events/ipc.d.ts.map +1 -0
- package/dist/src/events/ipc.js +25 -0
- package/dist/src/events/ipc.js.map +1 -0
- package/dist/src/events/session.d.ts +21 -0
- package/dist/src/events/session.d.ts.map +1 -0
- package/dist/src/events/session.js +39 -0
- package/dist/src/events/session.js.map +1 -0
- package/dist/src/events/types.d.ts +15 -0
- package/dist/src/events/types.d.ts.map +1 -0
- package/dist/src/events/types.js +26 -0
- package/dist/src/events/types.js.map +1 -0
- package/dist/src/hooks/attention.d.ts +26 -0
- package/dist/src/hooks/attention.d.ts.map +1 -0
- package/dist/src/hooks/attention.js +90 -0
- package/dist/src/hooks/attention.js.map +1 -0
- package/dist/src/hooks/handlers/post-tool-use-failure.d.ts +20 -0
- package/dist/src/hooks/handlers/post-tool-use-failure.d.ts.map +1 -0
- package/dist/src/hooks/handlers/post-tool-use-failure.js +60 -0
- package/dist/src/hooks/handlers/post-tool-use-failure.js.map +1 -0
- package/dist/src/hooks/handlers/post-tool-use.d.ts +22 -0
- package/dist/src/hooks/handlers/post-tool-use.d.ts.map +1 -0
- package/dist/src/hooks/handlers/post-tool-use.js +96 -0
- package/dist/src/hooks/handlers/post-tool-use.js.map +1 -0
- package/dist/src/hooks/handlers/pre-compact.d.ts +17 -0
- package/dist/src/hooks/handlers/pre-compact.d.ts.map +1 -0
- package/dist/src/hooks/handlers/pre-compact.js +28 -0
- package/dist/src/hooks/handlers/pre-compact.js.map +1 -0
- package/dist/src/hooks/handlers/pre-tool-use.d.ts +32 -0
- package/dist/src/hooks/handlers/pre-tool-use.d.ts.map +1 -0
- package/dist/src/hooks/handlers/pre-tool-use.js +219 -0
- package/dist/src/hooks/handlers/pre-tool-use.js.map +1 -0
- package/dist/src/hooks/handlers/session-end.d.ts +18 -0
- package/dist/src/hooks/handlers/session-end.d.ts.map +1 -0
- package/dist/src/hooks/handlers/session-end.js +42 -0
- package/dist/src/hooks/handlers/session-end.js.map +1 -0
- package/dist/src/hooks/handlers/session-start.d.ts +25 -0
- package/dist/src/hooks/handlers/session-start.d.ts.map +1 -0
- package/dist/src/hooks/handlers/session-start.js +61 -0
- package/dist/src/hooks/handlers/session-start.js.map +1 -0
- package/dist/src/hooks/handlers/stop.d.ts +21 -0
- package/dist/src/hooks/handlers/stop.d.ts.map +1 -0
- package/dist/src/hooks/handlers/stop.js +40 -0
- package/dist/src/hooks/handlers/stop.js.map +1 -0
- package/dist/src/hooks/handlers/subagent-start.d.ts +17 -0
- package/dist/src/hooks/handlers/subagent-start.d.ts.map +1 -0
- package/dist/src/hooks/handlers/subagent-start.js +48 -0
- package/dist/src/hooks/handlers/subagent-start.js.map +1 -0
- package/dist/src/hooks/handlers/user-prompt-submit.d.ts +12 -0
- package/dist/src/hooks/handlers/user-prompt-submit.d.ts.map +1 -0
- package/dist/src/hooks/handlers/user-prompt-submit.js +31 -0
- package/dist/src/hooks/handlers/user-prompt-submit.js.map +1 -0
- package/dist/src/hooks/index.d.ts +14 -0
- package/dist/src/hooks/index.d.ts.map +1 -0
- package/dist/src/hooks/index.js +13 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/post-tool-use.d.ts +12 -0
- package/dist/src/hooks/post-tool-use.d.ts.map +1 -0
- package/dist/src/hooks/post-tool-use.js +33 -0
- package/dist/src/hooks/post-tool-use.js.map +1 -0
- package/dist/src/hooks/pre-tool-use.d.ts +24 -0
- package/dist/src/hooks/pre-tool-use.d.ts.map +1 -0
- package/dist/src/hooks/pre-tool-use.js +117 -0
- package/dist/src/hooks/pre-tool-use.js.map +1 -0
- package/dist/src/hooks/session-store.d.ts +55 -0
- package/dist/src/hooks/session-store.d.ts.map +1 -0
- package/dist/src/hooks/session-store.js +69 -0
- package/dist/src/hooks/session-store.js.map +1 -0
- package/dist/src/hooks/types.d.ts +67 -0
- package/dist/src/hooks/types.d.ts.map +1 -0
- package/dist/src/hooks/types.js +28 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/init/agent-connector.d.ts +43 -0
- package/dist/src/init/agent-connector.d.ts.map +1 -0
- package/dist/src/init/agent-connector.js +338 -0
- package/dist/src/init/agent-connector.js.map +1 -0
- package/dist/src/init/dna-bootstrap.d.ts +10 -0
- package/dist/src/init/dna-bootstrap.d.ts.map +1 -0
- package/dist/src/init/dna-bootstrap.js +32 -0
- package/dist/src/init/dna-bootstrap.js.map +1 -0
- package/dist/src/init/index.d.ts +29 -0
- package/dist/src/init/index.d.ts.map +1 -0
- package/dist/src/init/index.js +81 -0
- package/dist/src/init/index.js.map +1 -0
- package/dist/src/init/overview-generator.d.ts +5 -0
- package/dist/src/init/overview-generator.d.ts.map +1 -0
- package/dist/src/init/overview-generator.js +85 -0
- package/dist/src/init/overview-generator.js.map +1 -0
- package/dist/src/init/parsers/eslint-config.d.ts +10 -0
- package/dist/src/init/parsers/eslint-config.d.ts.map +1 -0
- package/dist/src/init/parsers/eslint-config.js +50 -0
- package/dist/src/init/parsers/eslint-config.js.map +1 -0
- package/dist/src/init/parsers/markdown-rules.d.ts +3 -0
- package/dist/src/init/parsers/markdown-rules.d.ts.map +1 -0
- package/dist/src/init/parsers/markdown-rules.js +90 -0
- package/dist/src/init/parsers/markdown-rules.js.map +1 -0
- package/dist/src/init/parsers/package-json.d.ts +17 -0
- package/dist/src/init/parsers/package-json.d.ts.map +1 -0
- package/dist/src/init/parsers/package-json.js +75 -0
- package/dist/src/init/parsers/package-json.js.map +1 -0
- package/dist/src/init/parsers/prettier-config.d.ts +16 -0
- package/dist/src/init/parsers/prettier-config.d.ts.map +1 -0
- package/dist/src/init/parsers/prettier-config.js +30 -0
- package/dist/src/init/parsers/prettier-config.js.map +1 -0
- package/dist/src/init/parsers/tsconfig.d.ts +32 -0
- package/dist/src/init/parsers/tsconfig.d.ts.map +1 -0
- package/dist/src/init/parsers/tsconfig.js +64 -0
- package/dist/src/init/parsers/tsconfig.js.map +1 -0
- package/dist/src/init/parsers/types.d.ts +27 -0
- package/dist/src/init/parsers/types.d.ts.map +1 -0
- package/dist/src/init/parsers/types.js +2 -0
- package/dist/src/init/parsers/types.js.map +1 -0
- package/dist/src/init/project-analyzer.d.ts +3 -0
- package/dist/src/init/project-analyzer.d.ts.map +1 -0
- package/dist/src/init/project-analyzer.js +102 -0
- package/dist/src/init/project-analyzer.js.map +1 -0
- package/dist/src/init/rule-importer.d.ts +3 -0
- package/dist/src/init/rule-importer.d.ts.map +1 -0
- package/dist/src/init/rule-importer.js +101 -0
- package/dist/src/init/rule-importer.js.map +1 -0
- package/dist/src/mcp/context.d.ts +43 -0
- package/dist/src/mcp/context.d.ts.map +1 -0
- package/dist/src/mcp/context.js +167 -0
- package/dist/src/mcp/context.js.map +1 -0
- package/dist/src/mcp/http-api.d.ts +10 -0
- package/dist/src/mcp/http-api.d.ts.map +1 -0
- package/dist/src/mcp/http-api.js +580 -0
- package/dist/src/mcp/http-api.js.map +1 -0
- package/dist/src/mcp/index.d.ts +8 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +8 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/resources.d.ts +5 -0
- package/dist/src/mcp/resources.d.ts.map +1 -0
- package/dist/src/mcp/resources.js +78 -0
- package/dist/src/mcp/resources.js.map +1 -0
- package/dist/src/mcp/server.d.ts +6 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +265 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/mcp/tool-response.d.ts +6 -0
- package/dist/src/mcp/tool-response.d.ts.map +1 -0
- package/dist/src/mcp/tool-response.js +19 -0
- package/dist/src/mcp/tool-response.js.map +1 -0
- package/dist/src/mcp/tools/architecture-tools.d.ts +15 -0
- package/dist/src/mcp/tools/architecture-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/architecture-tools.js +56 -0
- package/dist/src/mcp/tools/architecture-tools.js.map +1 -0
- package/dist/src/mcp/tools/dna-tools.d.ts +21 -0
- package/dist/src/mcp/tools/dna-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/dna-tools.js +15 -0
- package/dist/src/mcp/tools/dna-tools.js.map +1 -0
- package/dist/src/mcp/tools/graph-tools.d.ts +49 -0
- package/dist/src/mcp/tools/graph-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/graph-tools.js +45 -0
- package/dist/src/mcp/tools/graph-tools.js.map +1 -0
- package/dist/src/mcp/tools/health-tools.d.ts +5 -0
- package/dist/src/mcp/tools/health-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/health-tools.js +7 -0
- package/dist/src/mcp/tools/health-tools.js.map +1 -0
- package/dist/src/mcp/tools/impact-tools.d.ts +21 -0
- package/dist/src/mcp/tools/impact-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/impact-tools.js +23 -0
- package/dist/src/mcp/tools/impact-tools.js.map +1 -0
- package/dist/src/mcp/tools/intent-tools.d.ts +32 -0
- package/dist/src/mcp/tools/intent-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/intent-tools.js +77 -0
- package/dist/src/mcp/tools/intent-tools.js.map +1 -0
- package/dist/src/mcp/tools/project-tools.d.ts +53 -0
- package/dist/src/mcp/tools/project-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/project-tools.js +91 -0
- package/dist/src/mcp/tools/project-tools.js.map +1 -0
- package/dist/src/mcp/tools/rename-tool.d.ts +25 -0
- package/dist/src/mcp/tools/rename-tool.d.ts.map +1 -0
- package/dist/src/mcp/tools/rename-tool.js +106 -0
- package/dist/src/mcp/tools/rename-tool.js.map +1 -0
- package/dist/src/mcp/tools/trace-tools.d.ts +4 -0
- package/dist/src/mcp/tools/trace-tools.d.ts.map +1 -0
- package/dist/src/mcp/tools/trace-tools.js +268 -0
- package/dist/src/mcp/tools/trace-tools.js.map +1 -0
- package/dist/src/storage/db.d.ts +13 -0
- package/dist/src/storage/db.d.ts.map +1 -0
- package/dist/src/storage/db.js +230 -0
- package/dist/src/storage/db.js.map +1 -0
- package/dist/src/storage/repository.d.ts +54 -0
- package/dist/src/storage/repository.d.ts.map +1 -0
- package/dist/src/storage/repository.js +257 -0
- package/dist/src/storage/repository.js.map +1 -0
- package/dist/src/utils/config.d.ts +18 -0
- package/dist/src/utils/config.d.ts.map +1 -0
- package/dist/src/utils/config.js +93 -0
- package/dist/src/utils/config.js.map +1 -0
- package/dist/src/utils/files.d.ts +3 -0
- package/dist/src/utils/files.d.ts.map +1 -0
- package/dist/src/utils/files.js +52 -0
- package/dist/src/utils/files.js.map +1 -0
- package/dist/src/utils/strings.d.ts +2 -0
- package/dist/src/utils/strings.d.ts.map +1 -0
- package/dist/src/utils/strings.js +11 -0
- package/dist/src/utils/strings.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/hooks/post-tool-use.sh +37 -0
- package/hooks/pre-tool-use.sh +43 -0
- package/hooks/session-start.sh +67 -0
- package/package.json +103 -0
- package/skills/symbiote-init/SKILL.md +104 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createEvent } from '#events/types.js';
|
|
3
|
+
const FILE_READ_TOOLS = new Set(['Read']);
|
|
4
|
+
const FILE_WRITE_TOOLS = new Set(['Edit', 'Write']);
|
|
5
|
+
function toRelative(projectRoot, filePath) {
|
|
6
|
+
return path.isAbsolute(filePath) ? path.relative(projectRoot, filePath) : filePath;
|
|
7
|
+
}
|
|
8
|
+
function collectSymbolIds(graph, fileNodeId) {
|
|
9
|
+
if (!graph.hasNode(fileNodeId)) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const symbols = [];
|
|
13
|
+
graph.forEachOutEdge(fileNodeId, (_edge, attrs, _source, target) => {
|
|
14
|
+
if (attrs.type === 'contains') {
|
|
15
|
+
symbols.push(target);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return symbols;
|
|
19
|
+
}
|
|
20
|
+
export class PostToolUseHandler {
|
|
21
|
+
config;
|
|
22
|
+
constructor(config) {
|
|
23
|
+
this.config = config;
|
|
24
|
+
}
|
|
25
|
+
async handle(payload) {
|
|
26
|
+
try {
|
|
27
|
+
await this.processPayload(payload);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Hooks must never fail
|
|
31
|
+
}
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
async processPayload(payload) {
|
|
35
|
+
const { tool_name, tool_input } = payload;
|
|
36
|
+
if (FILE_WRITE_TOOLS.has(tool_name)) {
|
|
37
|
+
const rawPath = typeof tool_input.file_path === 'string' ? tool_input.file_path : undefined;
|
|
38
|
+
if (rawPath) {
|
|
39
|
+
const relativePath = toRelative(this.config.projectRoot, rawPath);
|
|
40
|
+
await this.config.onReindexFile(relativePath);
|
|
41
|
+
this.config.attention.touchFile(relativePath);
|
|
42
|
+
const symbolIds = collectSymbolIds(this.config.graph, `file:${relativePath}`);
|
|
43
|
+
for (const symId of symbolIds) {
|
|
44
|
+
this.config.attention.touchSymbol(symId);
|
|
45
|
+
}
|
|
46
|
+
const eventType = tool_name === 'Write' ? 'file:create' : 'file:edit';
|
|
47
|
+
this.config.eventBus.emit(createEvent(eventType, { filePath: relativePath }));
|
|
48
|
+
await this.config.sessionStore.recordObservation({
|
|
49
|
+
sessionId: this.config.sessionId,
|
|
50
|
+
timestamp: Date.now(),
|
|
51
|
+
toolName: tool_name,
|
|
52
|
+
event: eventType,
|
|
53
|
+
filePath: relativePath,
|
|
54
|
+
symbolsAffected: symbolIds,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (FILE_READ_TOOLS.has(tool_name)) {
|
|
60
|
+
const rawPath = typeof tool_input.file_path === 'string' ? tool_input.file_path : undefined;
|
|
61
|
+
if (rawPath) {
|
|
62
|
+
const relativePath = toRelative(this.config.projectRoot, rawPath);
|
|
63
|
+
this.config.attention.touchFile(relativePath);
|
|
64
|
+
this.config.eventBus.emit(createEvent('file:read', { filePath: relativePath }));
|
|
65
|
+
await this.config.sessionStore.recordObservation({
|
|
66
|
+
sessionId: this.config.sessionId,
|
|
67
|
+
timestamp: Date.now(),
|
|
68
|
+
toolName: tool_name,
|
|
69
|
+
event: 'file:read',
|
|
70
|
+
filePath: relativePath,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (tool_name === 'Bash') {
|
|
76
|
+
const command = typeof tool_input.command === 'string' ? tool_input.command : undefined;
|
|
77
|
+
if (command && /git\s+commit/.test(command)) {
|
|
78
|
+
await this.config.onFullRescan();
|
|
79
|
+
}
|
|
80
|
+
await this.config.sessionStore.recordObservation({
|
|
81
|
+
sessionId: this.config.sessionId,
|
|
82
|
+
timestamp: Date.now(),
|
|
83
|
+
toolName: tool_name,
|
|
84
|
+
event: 'tool:use',
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await this.config.sessionStore.recordObservation({
|
|
89
|
+
sessionId: this.config.sessionId,
|
|
90
|
+
timestamp: Date.now(),
|
|
91
|
+
toolName: tool_name,
|
|
92
|
+
event: 'tool:use',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=post-tool-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-tool-use.js","sourceRoot":"","sources":["../../../../src/hooks/handlers/post-tool-use.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAM7B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAa/C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;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CAAC,MAAM,CAAC,YAAY,CAAC,iBAAiB,CAAC;YAC7C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,UAAU;SACpB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PreCompactPayload, HttpHookResponse } from '#hooks/types.js';
|
|
2
|
+
import type { SessionStore } from '#hooks/session-store.js';
|
|
3
|
+
import type { AttentionSet } from '#hooks/attention.js';
|
|
4
|
+
import { EventBus } from '#events/bus.js';
|
|
5
|
+
export interface PreCompactHandlerConfig {
|
|
6
|
+
sessionStore: SessionStore;
|
|
7
|
+
attention: AttentionSet;
|
|
8
|
+
eventBus: EventBus;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class PreCompactHandler {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: PreCompactHandlerConfig);
|
|
14
|
+
handle(payload: PreCompactPayload): Promise<HttpHookResponse>;
|
|
15
|
+
private processPayload;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=pre-compact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-compact.d.ts","sourceRoot":"","sources":["../../../../src/hooks/handlers/pre-compact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,WAAW,uBAAuB;IACpC,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB;AAKD,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,EAAE,uBAAuB;IAIrC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAQrD,cAAc;CAgB/B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createEvent } from '#events/types.js';
|
|
2
|
+
const COMPACT_CONTEXT = "Session context preserved by Symbiote. After compaction, use get_project_overview and get_context_for_file MCP tools to restore context for files you're working on.";
|
|
3
|
+
export class PreCompactHandler {
|
|
4
|
+
config;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
async handle(payload) {
|
|
9
|
+
try {
|
|
10
|
+
return await this.processPayload(payload);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async processPayload(_payload) {
|
|
17
|
+
const snapshot = this.config.attention.toSnapshot();
|
|
18
|
+
await this.config.sessionStore.saveSnapshot(this.config.sessionId, JSON.stringify(snapshot));
|
|
19
|
+
this.config.eventBus.emit(createEvent('intelligence:snapshot', {}));
|
|
20
|
+
return {
|
|
21
|
+
hookSpecificOutput: {
|
|
22
|
+
hookEventName: 'PreCompact',
|
|
23
|
+
additionalContext: COMPACT_CONTEXT,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=pre-compact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-compact.js","sourceRoot":"","sources":["../../../../src/hooks/handlers/pre-compact.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAS/C,MAAM,eAAe,GACjB,sKAAsK,CAAC;AAE3K,MAAM,OAAO,iBAAiB;IAClB,MAAM,CAA0B;IAExC,YAAY,MAA+B;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAA0B;QACnC,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,QAA2B;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CACvC,IAAI,CAAC,MAAM,CAAC,SAAS,EACrB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC3B,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,CAAC;QAEpE,OAAO;YACH,kBAAkB,EAAE;gBAChB,aAAa,EAAE,YAAY;gBAC3B,iBAAiB,EAAE,eAAe;aACrC;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PreToolUsePayload, HttpHookResponse } from '#hooks/types.js';
|
|
2
|
+
import type { GraphInstance } from '#core/types.js';
|
|
3
|
+
import type { AttentionSet } from '#hooks/attention.js';
|
|
4
|
+
import type { DnaEngine } from '#dna/engine.js';
|
|
5
|
+
export interface ConstraintRef {
|
|
6
|
+
scope: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PreToolUseHandlerConfig {
|
|
10
|
+
graph: GraphInstance;
|
|
11
|
+
projectRoot: string;
|
|
12
|
+
constraints: ConstraintRef[];
|
|
13
|
+
attention: AttentionSet;
|
|
14
|
+
dnaEngine: DnaEngine;
|
|
15
|
+
}
|
|
16
|
+
export declare class PreToolUseHandler {
|
|
17
|
+
private graph;
|
|
18
|
+
private projectRoot;
|
|
19
|
+
private constraints;
|
|
20
|
+
private attention;
|
|
21
|
+
private dnaEngine;
|
|
22
|
+
constructor(config: PreToolUseHandlerConfig);
|
|
23
|
+
handle(payload: PreToolUsePayload): HttpHookResponse;
|
|
24
|
+
private handleFileTool;
|
|
25
|
+
private handleAgentTool;
|
|
26
|
+
private handleBashTool;
|
|
27
|
+
private collectSymbols;
|
|
28
|
+
private collectDependencies;
|
|
29
|
+
private collectDependents;
|
|
30
|
+
private findMatchingConstraints;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=pre-tool-use.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-tool-use.d.ts","sourceRoot":"","sources":["../../../../src/hooks/handlers/pre-tool-use.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;CACxB;AAMD,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,SAAS,CAAY;gBAEjB,MAAM,EAAE,uBAAuB;IAQ3C,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB;IAoBpD,OAAO,CAAC,cAAc;IAmFtB,OAAO,CAAC,eAAe;IAuCvB,OAAO,CAAC,cAAc;IA2DtB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,uBAAuB;CAMlC"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
const FILE_TOOLS = new Set(['Read', 'Edit', 'Write']);
|
|
3
|
+
const PASSTHROUGH_TOOLS = new Set(['Grep', 'Glob', 'WebFetch', 'WebSearch']);
|
|
4
|
+
const IMPACT_DEPENDENT_THRESHOLD = 5;
|
|
5
|
+
export class PreToolUseHandler {
|
|
6
|
+
graph;
|
|
7
|
+
projectRoot;
|
|
8
|
+
constraints;
|
|
9
|
+
attention;
|
|
10
|
+
dnaEngine;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.graph = config.graph;
|
|
13
|
+
this.projectRoot = config.projectRoot;
|
|
14
|
+
this.constraints = config.constraints;
|
|
15
|
+
this.attention = config.attention;
|
|
16
|
+
this.dnaEngine = config.dnaEngine;
|
|
17
|
+
}
|
|
18
|
+
handle(payload) {
|
|
19
|
+
if (PASSTHROUGH_TOOLS.has(payload.tool_name)) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
if (payload.tool_name === 'Agent') {
|
|
23
|
+
return this.handleAgentTool();
|
|
24
|
+
}
|
|
25
|
+
if (payload.tool_name === 'Bash') {
|
|
26
|
+
return this.handleBashTool(payload);
|
|
27
|
+
}
|
|
28
|
+
if (FILE_TOOLS.has(payload.tool_name)) {
|
|
29
|
+
return this.handleFileTool(payload);
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
handleFileTool(payload) {
|
|
34
|
+
const filePath = payload.tool_input.file_path;
|
|
35
|
+
if (!filePath) {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
const relativePath = path.isAbsolute(filePath)
|
|
39
|
+
? path.relative(this.projectRoot, filePath)
|
|
40
|
+
: filePath;
|
|
41
|
+
this.attention.touchFile(relativePath);
|
|
42
|
+
const fileNodeId = `file:${relativePath}`;
|
|
43
|
+
if (!this.graph.hasNode(fileNodeId)) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
const symbols = this.collectSymbols(fileNodeId);
|
|
47
|
+
const dependencies = this.collectDependencies(symbols);
|
|
48
|
+
const dependents = this.collectDependents(symbols);
|
|
49
|
+
const matchingConstraints = this.findMatchingConstraints(relativePath);
|
|
50
|
+
const lines = [];
|
|
51
|
+
lines.push(`File context for ${relativePath}:`);
|
|
52
|
+
if (symbols.length > 0) {
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push('Symbols in this file:');
|
|
55
|
+
for (const sym of symbols) {
|
|
56
|
+
if (!this.graph.hasNode(sym))
|
|
57
|
+
continue;
|
|
58
|
+
const attrs = this.graph.getNodeAttributes(sym);
|
|
59
|
+
lines.push(` - ${attrs.name} (${attrs.type}, lines ${attrs.lineStart}-${attrs.lineEnd})`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (dependencies.length > 0) {
|
|
63
|
+
lines.push('');
|
|
64
|
+
lines.push('Dependencies:');
|
|
65
|
+
for (const dep of dependencies) {
|
|
66
|
+
if (!this.graph.hasNode(dep))
|
|
67
|
+
continue;
|
|
68
|
+
const attrs = this.graph.getNodeAttributes(dep);
|
|
69
|
+
lines.push(` - ${attrs.name} (${attrs.filePath})`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (dependents.length > 0) {
|
|
73
|
+
lines.push('');
|
|
74
|
+
lines.push('Dependents:');
|
|
75
|
+
for (const dep of dependents) {
|
|
76
|
+
if (!this.graph.hasNode(dep))
|
|
77
|
+
continue;
|
|
78
|
+
const attrs = this.graph.getNodeAttributes(dep);
|
|
79
|
+
lines.push(` - ${attrs.name} (${attrs.filePath})`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (matchingConstraints.length > 0) {
|
|
83
|
+
lines.push('');
|
|
84
|
+
lines.push('Constraints:');
|
|
85
|
+
for (const constraint of matchingConstraints) {
|
|
86
|
+
lines.push(` - [${constraint.scope}] ${constraint.content}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if ((payload.tool_name === 'Edit' || payload.tool_name === 'Write') &&
|
|
90
|
+
dependents.length > IMPACT_DEPENDENT_THRESHOLD) {
|
|
91
|
+
lines.push('');
|
|
92
|
+
lines.push(`Impact warning: ${dependents.length} dependents will be affected by changes to this file.`);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
hookSpecificOutput: {
|
|
96
|
+
hookEventName: 'PreToolUse',
|
|
97
|
+
additionalContext: lines.join('\n'),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
handleAgentTool() {
|
|
102
|
+
const lines = [];
|
|
103
|
+
const activeEntries = this.dnaEngine
|
|
104
|
+
.getActiveEntries()
|
|
105
|
+
.slice(0, 10)
|
|
106
|
+
.map((e) => `[${e.frontmatter.category}] ${e.content}`);
|
|
107
|
+
if (activeEntries.length > 0) {
|
|
108
|
+
lines.push('Developer DNA (active):');
|
|
109
|
+
for (const entry of activeEntries) {
|
|
110
|
+
lines.push(` - ${entry}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const activeConstraints = this.constraints.filter((c) => c.scope === '*' || c.scope === 'global');
|
|
114
|
+
if (activeConstraints.length > 0) {
|
|
115
|
+
if (lines.length > 0)
|
|
116
|
+
lines.push('');
|
|
117
|
+
lines.push('Active constraints:');
|
|
118
|
+
for (const c of activeConstraints) {
|
|
119
|
+
lines.push(` - [${c.scope}] ${c.content}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (lines.length === 0) {
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
hookSpecificOutput: {
|
|
127
|
+
hookEventName: 'PreToolUse',
|
|
128
|
+
additionalContext: lines.join('\n'),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
handleBashTool(payload) {
|
|
133
|
+
const command = payload.tool_input.command;
|
|
134
|
+
if (!command) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
const filePathMatch = command.match(/(?:^|\s)((?:\.{1,2}\/)?[\w./-]+\.(?:ts|js|tsx|jsx|py|go|rs|java|rb|php|cs|cpp|c|h))/);
|
|
138
|
+
if (!filePathMatch) {
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
const rawPath = filePathMatch[1];
|
|
142
|
+
const relativePath = path.isAbsolute(rawPath)
|
|
143
|
+
? path.relative(this.projectRoot, rawPath)
|
|
144
|
+
: rawPath;
|
|
145
|
+
const fileNodeId = `file:${relativePath}`;
|
|
146
|
+
if (!this.graph.hasNode(fileNodeId)) {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
this.attention.touchFile(relativePath);
|
|
150
|
+
const symbols = this.collectSymbols(fileNodeId);
|
|
151
|
+
const matchingConstraints = this.findMatchingConstraints(relativePath);
|
|
152
|
+
const lines = [];
|
|
153
|
+
lines.push(`File context for ${relativePath}:`);
|
|
154
|
+
if (symbols.length > 0) {
|
|
155
|
+
lines.push('');
|
|
156
|
+
lines.push('Symbols in this file:');
|
|
157
|
+
for (const sym of symbols) {
|
|
158
|
+
if (!this.graph.hasNode(sym))
|
|
159
|
+
continue;
|
|
160
|
+
const attrs = this.graph.getNodeAttributes(sym);
|
|
161
|
+
lines.push(` - ${attrs.name} (${attrs.type}, lines ${attrs.lineStart}-${attrs.lineEnd})`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (matchingConstraints.length > 0) {
|
|
165
|
+
lines.push('');
|
|
166
|
+
lines.push('Constraints:');
|
|
167
|
+
for (const c of matchingConstraints) {
|
|
168
|
+
lines.push(` - [${c.scope}] ${c.content}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
hookSpecificOutput: {
|
|
173
|
+
hookEventName: 'PreToolUse',
|
|
174
|
+
additionalContext: lines.join('\n'),
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
collectSymbols(fileNodeId) {
|
|
179
|
+
const symbols = [];
|
|
180
|
+
this.graph.forEachOutEdge(fileNodeId, (_edge, attrs, _source, target) => {
|
|
181
|
+
if (attrs.type === 'contains') {
|
|
182
|
+
symbols.push(target);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return symbols;
|
|
186
|
+
}
|
|
187
|
+
collectDependencies(symbols) {
|
|
188
|
+
const deps = new Set();
|
|
189
|
+
const symbolSet = new Set(symbols);
|
|
190
|
+
for (const symbol of symbols) {
|
|
191
|
+
this.graph.forEachOutEdge(symbol, (_edge, attrs, _source, target) => {
|
|
192
|
+
if (attrs.type !== 'contains' && !symbolSet.has(target)) {
|
|
193
|
+
deps.add(target);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return [...deps];
|
|
198
|
+
}
|
|
199
|
+
collectDependents(symbols) {
|
|
200
|
+
const dependents = new Set();
|
|
201
|
+
const symbolSet = new Set(symbols);
|
|
202
|
+
for (const symbol of symbols) {
|
|
203
|
+
this.graph.forEachInEdge(symbol, (_edge, attrs, source) => {
|
|
204
|
+
if (attrs.type !== 'contains' && !symbolSet.has(source)) {
|
|
205
|
+
dependents.add(source);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return [...dependents];
|
|
210
|
+
}
|
|
211
|
+
findMatchingConstraints(relativePath) {
|
|
212
|
+
return this.constraints.filter((c) => {
|
|
213
|
+
if (c.scope === '*' || c.scope === 'global')
|
|
214
|
+
return true;
|
|
215
|
+
return relativePath.startsWith(c.scope) || relativePath.includes(c.scope);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=pre-tool-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-tool-use.js","sourceRoot":"","sources":["../../../../src/hooks/handlers/pre-tool-use.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAmB7B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACtD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AAC7E,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAErC,MAAM,OAAO,iBAAiB;IAClB,KAAK,CAAgB;IACrB,WAAW,CAAS;IACpB,WAAW,CAAkB;IAC7B,SAAS,CAAe;IACxB,SAAS,CAAY;IAE7B,YAAY,MAA+B;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,OAA0B;QAC7B,IAAI,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3C,OAAO,EAAE,CAAC;QACd,CAAC;QAED,IAAI,OAAO,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;QAClC,CAAC;QAED,IAAI,OAAO,C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2
|
+
import type { SessionStore } from '#hooks/session-store.js';
|
|
3
|
+
import type { DnaEngine } from '#dna/engine.js';
|
|
4
|
+
import { EventBus } from '#events/bus.js';
|
|
5
|
+
export interface SessionEndHandlerConfig {
|
|
6
|
+
sessionStore: SessionStore;
|
|
7
|
+
dnaEngine: DnaEngine;
|
|
8
|
+
eventBus: EventBus;
|
|
9
|
+
}
|
|
10
|
+
export declare class SessionEndHandler {
|
|
11
|
+
private sessionStore;
|
|
12
|
+
private dnaEngine;
|
|
13
|
+
private eventBus;
|
|
14
|
+
constructor(config: SessionEndHandlerConfig);
|
|
15
|
+
handle(payload: SessionEndPayload): Promise<HttpHookResponse>;
|
|
16
|
+
private processPayload;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=session-end.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-end.d.ts","sourceRoot":"","sources":["../../../../src/hooks/handlers/session-end.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,WAAW,uBAAuB;IACpC,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,QAAQ,CAAW;gBAEf,MAAM,EAAE,uBAAuB;IAMrC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAUrD,cAAc;CA4B/B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createEvent } from '#events/types.js';
|
|
2
|
+
export class SessionEndHandler {
|
|
3
|
+
sessionStore;
|
|
4
|
+
dnaEngine;
|
|
5
|
+
eventBus;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.sessionStore = config.sessionStore;
|
|
8
|
+
this.dnaEngine = config.dnaEngine;
|
|
9
|
+
this.eventBus = config.eventBus;
|
|
10
|
+
}
|
|
11
|
+
async handle(payload) {
|
|
12
|
+
try {
|
|
13
|
+
await this.processPayload(payload);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// Hooks must never fail
|
|
17
|
+
}
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
async processPayload(payload) {
|
|
21
|
+
const { session_id, reason } = payload;
|
|
22
|
+
const session = await this.sessionStore.getSession(session_id);
|
|
23
|
+
if (!session) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const toolCounts = await this.sessionStore.getToolCounts(session_id);
|
|
27
|
+
const hotspots = await this.sessionStore.getHotspots(session_id, 1);
|
|
28
|
+
await this.sessionStore.endSession(session_id, {
|
|
29
|
+
endedAt: Date.now(),
|
|
30
|
+
reason,
|
|
31
|
+
filesTouched: hotspots,
|
|
32
|
+
toolCounts,
|
|
33
|
+
});
|
|
34
|
+
this.dnaEngine.batchPassiveReinforce();
|
|
35
|
+
this.dnaEngine.autoPromote();
|
|
36
|
+
this.dnaEngine.decayUnseenEntries(session_id);
|
|
37
|
+
this.eventBus.emit(createEvent('intelligence:snapshot', {
|
|
38
|
+
metadata: { sessionId: session_id, reason, toolCounts },
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=session-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-end.js","sourceRoot":"","sources":["../../../../src/hooks/handlers/session-end.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC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AC;QAE9C,IAAI,CAAC,QAAQ,CAAC,IAAI,CACd,WAAW,CAAC,uBAAuB,EAAE;YACjC,QAAQ,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;SAC1D,CAAC,CACL,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HttpHookResponse } from '#hooks/types.js';
|
|
2
|
+
import type { SessionStore } from '#hooks/session-store.js';
|
|
3
|
+
import type { DnaEngine } from '#dna/engine.js';
|
|
4
|
+
import type { ConstraintRef } from '#hooks/handlers/pre-tool-use.js';
|
|
5
|
+
export interface SessionStartHandlerConfig {
|
|
6
|
+
dnaEngine: DnaEngine;
|
|
7
|
+
sessionStore: SessionStore;
|
|
8
|
+
constraints: ConstraintRef[];
|
|
9
|
+
projectName: string;
|
|
10
|
+
fileCount: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class SessionStartHandler {
|
|
13
|
+
private dnaEngine;
|
|
14
|
+
private sessionStore;
|
|
15
|
+
private constraints;
|
|
16
|
+
private projectName;
|
|
17
|
+
private fileCount;
|
|
18
|
+
constructor(config: SessionStartHandlerConfig);
|
|
19
|
+
handle(input: {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
source: string;
|
|
22
|
+
}): Promise<HttpHookResponse>;
|
|
23
|
+
private buildResponse;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=session-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-start.d.ts","sourceRoot":"","sources":["../../../../src/hooks/handlers/session-start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,WAAW,yBAAyB;IACtC,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,yBAAyB;IAQvC,MAAM,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAQvE,aAAa;CAyD9B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export class SessionStartHandler {
|
|
2
|
+
dnaEngine;
|
|
3
|
+
sessionStore;
|
|
4
|
+
constraints;
|
|
5
|
+
projectName;
|
|
6
|
+
fileCount;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.dnaEngine = config.dnaEngine;
|
|
9
|
+
this.sessionStore = config.sessionStore;
|
|
10
|
+
this.constraints = config.constraints;
|
|
11
|
+
this.projectName = config.projectName;
|
|
12
|
+
this.fileCount = config.fileCount;
|
|
13
|
+
}
|
|
14
|
+
async handle(input) {
|
|
15
|
+
try {
|
|
16
|
+
return await this.buildResponse(input);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async buildResponse(input) {
|
|
23
|
+
const { sessionId, source } = input;
|
|
24
|
+
const activeEntries = this.dnaEngine.getActiveEntries().slice(0, 5);
|
|
25
|
+
const dnaRules = activeEntries.map((e) => e.content).join(', ');
|
|
26
|
+
const activeConstraints = this.constraints.filter((c) => c.scope === '*' || c.scope === 'global');
|
|
27
|
+
const lines = [];
|
|
28
|
+
lines.push(`[Symbiote] Project: ${this.projectName} (${this.fileCount} files)`);
|
|
29
|
+
if (dnaRules) {
|
|
30
|
+
lines.push(`DNA: ${dnaRules}`);
|
|
31
|
+
}
|
|
32
|
+
if (activeConstraints.length > 0) {
|
|
33
|
+
const constraintText = activeConstraints.map((c) => c.content).join(', ');
|
|
34
|
+
lines.push(`Constraints: ${constraintText}`);
|
|
35
|
+
}
|
|
36
|
+
if (source === 'compact') {
|
|
37
|
+
const snapshot = await this.sessionStore.getSnapshot(sessionId);
|
|
38
|
+
if (snapshot) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(snapshot);
|
|
41
|
+
if (parsed.filesModified && parsed.filesModified.length > 0) {
|
|
42
|
+
lines.push(`Files modified this session: ${parsed.filesModified.join(', ')}`);
|
|
43
|
+
}
|
|
44
|
+
if (parsed.attention && parsed.attention.length > 0) {
|
|
45
|
+
lines.push(`Active attention: ${parsed.attention.join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
lines.push(snapshot);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
hookSpecificOutput: {
|
|
55
|
+
hookEventName: 'SessionStart',
|
|
56
|
+
additionalContext: lines.join('\n'),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=session-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-start.js","sourceRoot":"","sources":["../../../../src/hooks/handlers/session-start.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,mBAAmB;IACpB,SAAS,CAAY;IACrB,YAAY,CAAe;IAC3B,WAAW,CAAkB;IAC7B,WAAW,CAAS;IACpB,SAAS,CAAS;IAE1B,YAAY,MAAiC;QACzC,IAAI,CAAC,SAAS,GAAG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ookResponse } from '#hooks/types.js';
|
|
2
|
+
import type { SessionStore } from '#hooks/session-store.js';
|
|
3
|
+
import type { AttentionSet } from '#hooks/attention.js';
|
|
4
|
+
import type { DnaEngine } from '#dna/engine.js';
|
|
5
|
+
export interface StopHandlerConfig {
|
|
6
|
+
sessionStore: SessionStore;
|
|
7
|
+
attention: AttentionSet;
|
|
8
|
+
dnaEngine: DnaEngine;
|
|
9
|
+
}
|
|
10
|
+
export declare class StopHandler {
|
|
11
|
+
private sessionStore;
|
|
12
|
+
private attention;
|
|
13
|
+
private dnaEngine;
|
|
14
|
+
private interactionCount;
|
|
15
|
+
private lastHeavyweightAt;
|
|
16
|
+
constructor(config: StopHandlerConfig);
|
|
17
|
+
handle(payload: StopPayload): Promise<HttpHookResponse>;
|
|
18
|
+
private processPayload;
|
|
19
|
+
private runHeavyweightAnalysis;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=stop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../../src/hooks/handlers/stop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAC9B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;CACxB;AAID,qBAAa,WAAW;IACpB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,iBAAiB,CAAK;gBAElB,MAAM,EAAE,iBAAiB;IAM/B,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAU/C,cAAc;YAUd,sBAAsB;CAevC"}
|