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,689 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { detectLanguage, getGrammar } from './languages.js';
|
|
5
|
+
const cjsRequire = createRequire(import.meta.url);
|
|
6
|
+
const Parser = cjsRequire('tree-sitter');
|
|
7
|
+
const JS_TS_CONFIG = {
|
|
8
|
+
functionTypes: new Set([
|
|
9
|
+
'function_declaration',
|
|
10
|
+
'function',
|
|
11
|
+
'arrow_function',
|
|
12
|
+
'generator_function',
|
|
13
|
+
'generator_function_declaration',
|
|
14
|
+
]),
|
|
15
|
+
classTypes: new Set(['class_declaration', 'class']),
|
|
16
|
+
methodTypes: new Set(['method_definition', 'public_field_definition']),
|
|
17
|
+
interfaceTypes: new Set(['interface_declaration']),
|
|
18
|
+
typeAliasTypes: new Set(['type_alias_declaration']),
|
|
19
|
+
enumTypes: new Set(['enum_declaration']),
|
|
20
|
+
importTypes: new Set(['import_statement']),
|
|
21
|
+
callTypes: new Set(['call_expression', 'new_expression']),
|
|
22
|
+
importSourceField: 'source',
|
|
23
|
+
extensions: [
|
|
24
|
+
'.ts',
|
|
25
|
+
'.tsx',
|
|
26
|
+
'.js',
|
|
27
|
+
'.jsx',
|
|
28
|
+
'.mjs',
|
|
29
|
+
'/index.ts',
|
|
30
|
+
'/index.tsx',
|
|
31
|
+
'/index.js',
|
|
32
|
+
'/index.jsx',
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
const PYTHON_CONFIG = {
|
|
36
|
+
functionTypes: new Set(['function_definition']),
|
|
37
|
+
classTypes: new Set(['class_definition']),
|
|
38
|
+
methodTypes: new Set(['function_definition']),
|
|
39
|
+
interfaceTypes: new Set(),
|
|
40
|
+
typeAliasTypes: new Set(),
|
|
41
|
+
enumTypes: new Set(),
|
|
42
|
+
importTypes: new Set(['import_statement', 'import_from_statement']),
|
|
43
|
+
callTypes: new Set(['call']),
|
|
44
|
+
importSourceField: 'module_name',
|
|
45
|
+
extensions: ['.py', '/__init__.py'],
|
|
46
|
+
};
|
|
47
|
+
const GO_CONFIG = {
|
|
48
|
+
functionTypes: new Set(['function_declaration', 'method_declaration']),
|
|
49
|
+
classTypes: new Set(),
|
|
50
|
+
methodTypes: new Set(),
|
|
51
|
+
interfaceTypes: new Set(),
|
|
52
|
+
typeAliasTypes: new Set(),
|
|
53
|
+
enumTypes: new Set(),
|
|
54
|
+
importTypes: new Set(['import_declaration']),
|
|
55
|
+
callTypes: new Set(['call_expression']),
|
|
56
|
+
importSourceField: 'path',
|
|
57
|
+
extensions: ['.go'],
|
|
58
|
+
};
|
|
59
|
+
const RUST_CONFIG = {
|
|
60
|
+
functionTypes: new Set(['function_item']),
|
|
61
|
+
classTypes: new Set(['struct_item']),
|
|
62
|
+
methodTypes: new Set(['function_item']),
|
|
63
|
+
interfaceTypes: new Set(['trait_item']),
|
|
64
|
+
typeAliasTypes: new Set(['type_item']),
|
|
65
|
+
enumTypes: new Set(['enum_item']),
|
|
66
|
+
importTypes: new Set(['use_declaration']),
|
|
67
|
+
callTypes: new Set(['call_expression']),
|
|
68
|
+
importSourceField: 'argument',
|
|
69
|
+
extensions: ['.rs'],
|
|
70
|
+
};
|
|
71
|
+
const JAVA_CONFIG = {
|
|
72
|
+
functionTypes: new Set(),
|
|
73
|
+
classTypes: new Set(['class_declaration']),
|
|
74
|
+
methodTypes: new Set(['method_declaration', 'constructor_declaration']),
|
|
75
|
+
interfaceTypes: new Set(['interface_declaration']),
|
|
76
|
+
typeAliasTypes: new Set(),
|
|
77
|
+
enumTypes: new Set(['enum_declaration']),
|
|
78
|
+
importTypes: new Set(['import_declaration']),
|
|
79
|
+
callTypes: new Set(['method_invocation', 'object_creation_expression']),
|
|
80
|
+
importSourceField: '',
|
|
81
|
+
extensions: ['.java'],
|
|
82
|
+
};
|
|
83
|
+
const RUBY_CONFIG = {
|
|
84
|
+
functionTypes: new Set(['method']),
|
|
85
|
+
classTypes: new Set(['class', 'module']),
|
|
86
|
+
methodTypes: new Set(['method', 'singleton_method']),
|
|
87
|
+
interfaceTypes: new Set(),
|
|
88
|
+
typeAliasTypes: new Set(),
|
|
89
|
+
enumTypes: new Set(),
|
|
90
|
+
importTypes: new Set(),
|
|
91
|
+
callTypes: new Set(['call', 'method_call']),
|
|
92
|
+
importSourceField: '',
|
|
93
|
+
extensions: ['.rb'],
|
|
94
|
+
};
|
|
95
|
+
const PHP_CONFIG = {
|
|
96
|
+
functionTypes: new Set(['function_definition']),
|
|
97
|
+
classTypes: new Set(['class_declaration']),
|
|
98
|
+
methodTypes: new Set(['method_declaration']),
|
|
99
|
+
interfaceTypes: new Set(['interface_declaration']),
|
|
100
|
+
typeAliasTypes: new Set(),
|
|
101
|
+
enumTypes: new Set(['enum_declaration']),
|
|
102
|
+
importTypes: new Set(['namespace_use_declaration']),
|
|
103
|
+
callTypes: new Set(['function_call_expression', 'member_call_expression']),
|
|
104
|
+
importSourceField: '',
|
|
105
|
+
extensions: ['.php'],
|
|
106
|
+
};
|
|
107
|
+
const C_CPP_CONFIG = {
|
|
108
|
+
functionTypes: new Set(['function_definition']),
|
|
109
|
+
classTypes: new Set(['class_specifier']),
|
|
110
|
+
methodTypes: new Set(['function_definition']),
|
|
111
|
+
interfaceTypes: new Set(),
|
|
112
|
+
typeAliasTypes: new Set(),
|
|
113
|
+
enumTypes: new Set(),
|
|
114
|
+
importTypes: new Set(['preproc_include']),
|
|
115
|
+
callTypes: new Set(['call_expression']),
|
|
116
|
+
importSourceField: 'path',
|
|
117
|
+
extensions: ['.c', '.h', '.cpp', '.cc', '.hpp'],
|
|
118
|
+
};
|
|
119
|
+
const LANGUAGE_CONFIGS = {
|
|
120
|
+
javascript: JS_TS_CONFIG,
|
|
121
|
+
typescript: JS_TS_CONFIG,
|
|
122
|
+
tsx: JS_TS_CONFIG,
|
|
123
|
+
python: PYTHON_CONFIG,
|
|
124
|
+
go: GO_CONFIG,
|
|
125
|
+
rust: RUST_CONFIG,
|
|
126
|
+
java: JAVA_CONFIG,
|
|
127
|
+
ruby: RUBY_CONFIG,
|
|
128
|
+
php: PHP_CONFIG,
|
|
129
|
+
c: C_CPP_CONFIG,
|
|
130
|
+
cpp: C_CPP_CONFIG,
|
|
131
|
+
};
|
|
132
|
+
const resolveCache = new Map();
|
|
133
|
+
export function parseFile(filePath, content) {
|
|
134
|
+
if (!content && !fs.existsSync(filePath))
|
|
135
|
+
return null;
|
|
136
|
+
const language = detectLanguage(filePath);
|
|
137
|
+
if (!language)
|
|
138
|
+
return null;
|
|
139
|
+
const grammar = getGrammar(language);
|
|
140
|
+
if (!grammar)
|
|
141
|
+
return null;
|
|
142
|
+
const source = content ?? fs.readFileSync(filePath, 'utf-8');
|
|
143
|
+
const parser = new Parser();
|
|
144
|
+
parser.setLanguage(grammar);
|
|
145
|
+
const tree = parser.parse(source);
|
|
146
|
+
const config = LANGUAGE_CONFIGS[language] ?? JS_TS_CONFIG;
|
|
147
|
+
const nodes = [];
|
|
148
|
+
const edges = [];
|
|
149
|
+
const lineCount = tree.rootNode.endPosition.row + 1;
|
|
150
|
+
nodes.push({
|
|
151
|
+
id: `file:${filePath}`,
|
|
152
|
+
type: 'file',
|
|
153
|
+
name: path.basename(filePath),
|
|
154
|
+
filePath,
|
|
155
|
+
lineStart: 1,
|
|
156
|
+
lineEnd: lineCount,
|
|
157
|
+
});
|
|
158
|
+
extractNodes(tree.rootNode, filePath, language, config, nodes);
|
|
159
|
+
extractImports(tree.rootNode, filePath, language, config, edges);
|
|
160
|
+
const symbolTable = buildSymbolTable(tree.rootNode, filePath, language, config);
|
|
161
|
+
extractImportBindings(symbolTable, filePath, edges);
|
|
162
|
+
extractCalls(tree.rootNode, filePath, config, nodes, symbolTable, edges);
|
|
163
|
+
for (const node of nodes) {
|
|
164
|
+
if (node.type !== 'file') {
|
|
165
|
+
edges.push({
|
|
166
|
+
sourceId: `file:${filePath}`,
|
|
167
|
+
targetId: node.id,
|
|
168
|
+
type: 'contains',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return { filePath, language, nodes, edges, symbolTable };
|
|
173
|
+
}
|
|
174
|
+
function extractNodes(root, filePath, language, config, nodes) {
|
|
175
|
+
const cursor = root.walk();
|
|
176
|
+
let reachedRoot = false;
|
|
177
|
+
while (!reachedRoot) {
|
|
178
|
+
const node = cursor.currentNode;
|
|
179
|
+
if (config.functionTypes.has(node.type)) {
|
|
180
|
+
const insideClass = isInsideClass(node, config);
|
|
181
|
+
if (!insideClass) {
|
|
182
|
+
const name = getFunctionName(node, language);
|
|
183
|
+
if (name) {
|
|
184
|
+
nodes.push({
|
|
185
|
+
id: `fn:${filePath}:${name}`,
|
|
186
|
+
type: 'function',
|
|
187
|
+
name,
|
|
188
|
+
filePath,
|
|
189
|
+
lineStart: node.startPosition.row + 1,
|
|
190
|
+
lineEnd: node.endPosition.row + 1,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (config.interfaceTypes.has(node.type)) {
|
|
196
|
+
const name = node.childForFieldName('name')?.text;
|
|
197
|
+
if (name) {
|
|
198
|
+
nodes.push({
|
|
199
|
+
id: `interface:${filePath}:${name}`,
|
|
200
|
+
type: 'interface',
|
|
201
|
+
name,
|
|
202
|
+
filePath,
|
|
203
|
+
lineStart: node.startPosition.row + 1,
|
|
204
|
+
lineEnd: node.endPosition.row + 1,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (config.typeAliasTypes.has(node.type)) {
|
|
209
|
+
const name = node.childForFieldName('name')?.text;
|
|
210
|
+
if (name) {
|
|
211
|
+
nodes.push({
|
|
212
|
+
id: `type:${filePath}:${name}`,
|
|
213
|
+
type: 'type_alias',
|
|
214
|
+
name,
|
|
215
|
+
filePath,
|
|
216
|
+
lineStart: node.startPosition.row + 1,
|
|
217
|
+
lineEnd: node.endPosition.row + 1,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (config.enumTypes.has(node.type)) {
|
|
222
|
+
const name = node.childForFieldName('name')?.text;
|
|
223
|
+
if (name) {
|
|
224
|
+
nodes.push({
|
|
225
|
+
id: `enum:${filePath}:${name}`,
|
|
226
|
+
type: 'enum',
|
|
227
|
+
name,
|
|
228
|
+
filePath,
|
|
229
|
+
lineStart: node.startPosition.row + 1,
|
|
230
|
+
lineEnd: node.endPosition.row + 1,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (config.classTypes.has(node.type)) {
|
|
235
|
+
const name = getClassName(node, language);
|
|
236
|
+
if (name) {
|
|
237
|
+
nodes.push({
|
|
238
|
+
id: `class:${filePath}:${name}`,
|
|
239
|
+
type: 'class',
|
|
240
|
+
name,
|
|
241
|
+
filePath,
|
|
242
|
+
lineStart: node.startPosition.row + 1,
|
|
243
|
+
lineEnd: node.endPosition.row + 1,
|
|
244
|
+
});
|
|
245
|
+
extractMethods(node, filePath, name, language, config, nodes);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if ((language === 'c' || language === 'cpp') && node.type === 'type_definition') {
|
|
249
|
+
const declarator = node.childForFieldName('declarator');
|
|
250
|
+
if (declarator?.type === 'type_identifier') {
|
|
251
|
+
const hasStruct = node.children.some((c) => c.type === 'struct_specifier');
|
|
252
|
+
const hasEnum = node.children.some((c) => c.type === 'enum_specifier');
|
|
253
|
+
const nodeType = hasStruct ? 'class' : hasEnum ? 'enum' : 'type_alias';
|
|
254
|
+
const prefix = hasStruct ? 'class' : hasEnum ? 'enum' : 'type';
|
|
255
|
+
nodes.push({
|
|
256
|
+
id: `${prefix}:${filePath}:${declarator.text}`,
|
|
257
|
+
type: nodeType,
|
|
258
|
+
name: declarator.text,
|
|
259
|
+
filePath,
|
|
260
|
+
lineStart: node.startPosition.row + 1,
|
|
261
|
+
lineEnd: node.endPosition.row + 1,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (language === 'go' && node.type === 'type_declaration') {
|
|
266
|
+
for (const spec of node.children) {
|
|
267
|
+
if (spec.type === 'type_spec') {
|
|
268
|
+
const name = spec.childForFieldName('name')?.text;
|
|
269
|
+
const typeNode = spec.childForFieldName('type');
|
|
270
|
+
if (name && typeNode) {
|
|
271
|
+
if (typeNode.type === 'struct_type') {
|
|
272
|
+
nodes.push({
|
|
273
|
+
id: `class:${filePath}:${name}`,
|
|
274
|
+
type: 'class',
|
|
275
|
+
name,
|
|
276
|
+
filePath,
|
|
277
|
+
lineStart: spec.startPosition.row + 1,
|
|
278
|
+
lineEnd: spec.endPosition.row + 1,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
else if (typeNode.type === 'interface_type') {
|
|
282
|
+
nodes.push({
|
|
283
|
+
id: `interface:${filePath}:${name}`,
|
|
284
|
+
type: 'interface',
|
|
285
|
+
name,
|
|
286
|
+
filePath,
|
|
287
|
+
lineStart: spec.startPosition.row + 1,
|
|
288
|
+
lineEnd: spec.endPosition.row + 1,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (cursor.gotoFirstChild())
|
|
296
|
+
continue;
|
|
297
|
+
if (cursor.gotoNextSibling())
|
|
298
|
+
continue;
|
|
299
|
+
while (true) {
|
|
300
|
+
if (!cursor.gotoParent()) {
|
|
301
|
+
reachedRoot = true;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
if (cursor.gotoNextSibling())
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function isInsideClass(node, config) {
|
|
310
|
+
let parent = node.parent;
|
|
311
|
+
while (parent) {
|
|
312
|
+
if (config.classTypes.has(parent.type))
|
|
313
|
+
return true;
|
|
314
|
+
if (parent.type === 'impl_item')
|
|
315
|
+
return true;
|
|
316
|
+
parent = parent.parent;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
function extractMethods(classNode, filePath, className, language, config, nodes) {
|
|
321
|
+
const body = classNode.childForFieldName('body') ?? findClassBody(classNode);
|
|
322
|
+
if (!body)
|
|
323
|
+
return;
|
|
324
|
+
for (const child of body.children) {
|
|
325
|
+
if (config.methodTypes.has(child.type)) {
|
|
326
|
+
const name = getFunctionName(child, language);
|
|
327
|
+
if (name) {
|
|
328
|
+
nodes.push({
|
|
329
|
+
id: `method:${filePath}:${className}.${name}`,
|
|
330
|
+
type: 'method',
|
|
331
|
+
name: `${className}.${name}`,
|
|
332
|
+
filePath,
|
|
333
|
+
lineStart: child.startPosition.row + 1,
|
|
334
|
+
lineEnd: child.endPosition.row + 1,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function findClassBody(node) {
|
|
341
|
+
for (const child of node.children) {
|
|
342
|
+
if (child.type === 'class_body' ||
|
|
343
|
+
child.type === 'block' ||
|
|
344
|
+
child.type === 'declaration_list' ||
|
|
345
|
+
child.type === 'field_declaration_list') {
|
|
346
|
+
return child;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
function extractImports(root, filePath, language, config, edges) {
|
|
352
|
+
for (const child of root.children) {
|
|
353
|
+
if (!config.importTypes.has(child.type))
|
|
354
|
+
continue;
|
|
355
|
+
const importPath = extractImportPath(child, language, config);
|
|
356
|
+
if (importPath) {
|
|
357
|
+
edges.push({
|
|
358
|
+
sourceId: `file:${filePath}`,
|
|
359
|
+
targetId: `file:${resolveImportPath(filePath, importPath, config)}`,
|
|
360
|
+
type: 'imports',
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function extractImportPath(node, language, config) {
|
|
366
|
+
if (language === 'python') {
|
|
367
|
+
if (node.type === 'import_from_statement') {
|
|
368
|
+
const moduleName = node.childForFieldName('module_name');
|
|
369
|
+
return moduleName?.text ?? null;
|
|
370
|
+
}
|
|
371
|
+
if (node.type === 'import_statement') {
|
|
372
|
+
const name = node.childForFieldName('name');
|
|
373
|
+
return name?.text ?? null;
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
if (language === 'c' || language === 'cpp') {
|
|
378
|
+
const pathNode = node.childForFieldName('path');
|
|
379
|
+
if (pathNode)
|
|
380
|
+
return pathNode.text.replace(/[<>"]/g, '');
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
if (language === 'java') {
|
|
384
|
+
for (const child of node.children) {
|
|
385
|
+
if (child.type === 'scoped_identifier')
|
|
386
|
+
return child.text;
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
if (language === 'go') {
|
|
391
|
+
for (const child of node.children) {
|
|
392
|
+
if (child.type === 'import_spec_list') {
|
|
393
|
+
for (const spec of child.children) {
|
|
394
|
+
if (spec.type === 'import_spec') {
|
|
395
|
+
const pathNode = spec.childForFieldName('path');
|
|
396
|
+
if (pathNode)
|
|
397
|
+
return pathNode.text.replace(/"/g, '');
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (child.type === 'import_spec') {
|
|
402
|
+
const pathNode = child.childForFieldName('path');
|
|
403
|
+
if (pathNode)
|
|
404
|
+
return pathNode.text.replace(/"/g, '');
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
if (language === 'rust') {
|
|
410
|
+
const arg = node.childForFieldName('argument');
|
|
411
|
+
if (arg)
|
|
412
|
+
return arg.text.replace(/::\{.*\}$/, '');
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
if (config.importSourceField) {
|
|
416
|
+
const source = node.childForFieldName(config.importSourceField);
|
|
417
|
+
if (source)
|
|
418
|
+
return source.text.replace(/['"]/g, '');
|
|
419
|
+
}
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
function getFunctionName(node, language) {
|
|
423
|
+
const nameNode = node.childForFieldName('name');
|
|
424
|
+
if (nameNode && nameNode.type !== 'ERROR')
|
|
425
|
+
return nameNode.text;
|
|
426
|
+
if (language === 'c' || language === 'cpp') {
|
|
427
|
+
const declarator = node.childForFieldName('declarator');
|
|
428
|
+
if (declarator) {
|
|
429
|
+
const inner = declarator.childForFieldName('declarator');
|
|
430
|
+
if (inner) {
|
|
431
|
+
if (inner.type === 'identifier')
|
|
432
|
+
return inner.text;
|
|
433
|
+
const deepest = inner.childForFieldName('declarator');
|
|
434
|
+
if (deepest?.type === 'identifier')
|
|
435
|
+
return deepest.text;
|
|
436
|
+
}
|
|
437
|
+
if (declarator.type === 'identifier')
|
|
438
|
+
return declarator.text;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
const parent = node.parent;
|
|
442
|
+
if (parent?.type === 'variable_declarator') {
|
|
443
|
+
const name = parent.childForFieldName('name');
|
|
444
|
+
if (name)
|
|
445
|
+
return name.text;
|
|
446
|
+
}
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
function getClassName(node, _language) {
|
|
450
|
+
const nameNode = node.childForFieldName('name');
|
|
451
|
+
if (nameNode)
|
|
452
|
+
return nameNode.text;
|
|
453
|
+
for (const child of node.children) {
|
|
454
|
+
if (child.type === 'type_identifier' || child.type === 'identifier') {
|
|
455
|
+
return child.text;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
function extractCalls(root, filePath, config, nodes, symbolTable, edges) {
|
|
461
|
+
const fnScopes = new Map(nodes
|
|
462
|
+
.filter((n) => n.type === 'function' || n.type === 'method')
|
|
463
|
+
.map((n) => [n.id, { lineStart: n.lineStart, lineEnd: n.lineEnd, id: n.id }]));
|
|
464
|
+
const cursor = root.walk();
|
|
465
|
+
let done = false;
|
|
466
|
+
while (!done) {
|
|
467
|
+
const node = cursor.currentNode;
|
|
468
|
+
if (config.callTypes.has(node.type)) {
|
|
469
|
+
if (node.type === 'new_expression' || node.type === 'object_creation_expression') {
|
|
470
|
+
const nameNode = node.childForFieldName('constructor') ?? node.childForFieldName('type');
|
|
471
|
+
if (nameNode) {
|
|
472
|
+
const caller = findEnclosingFunction(node, filePath, fnScopes);
|
|
473
|
+
if (caller) {
|
|
474
|
+
const entry = symbolTable.get(nameNode.text);
|
|
475
|
+
const target = entry
|
|
476
|
+
? `class:${entry.resolvedSourcePath}:${entry.originalName}`
|
|
477
|
+
: `class:${filePath}:${nameNode.text}`;
|
|
478
|
+
edges.push({ sourceId: caller, targetId: target, type: 'calls' });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
const info = resolveCallExpression(node, filePath, fnScopes);
|
|
484
|
+
if (info) {
|
|
485
|
+
const targetId = resolveCallTarget(info, filePath, symbolTable);
|
|
486
|
+
if (targetId) {
|
|
487
|
+
edges.push({ sourceId: info.callerNodeId, targetId, type: 'calls' });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (cursor.gotoFirstChild())
|
|
493
|
+
continue;
|
|
494
|
+
if (cursor.gotoNextSibling())
|
|
495
|
+
continue;
|
|
496
|
+
while (true) {
|
|
497
|
+
if (!cursor.gotoParent()) {
|
|
498
|
+
done = true;
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
if (cursor.gotoNextSibling())
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function findEnclosingFunction(node, filePath, fnScopes) {
|
|
507
|
+
const line = node.startPosition.row + 1;
|
|
508
|
+
let best = null;
|
|
509
|
+
let bestSize = Infinity;
|
|
510
|
+
for (const [, fn] of fnScopes) {
|
|
511
|
+
if (line >= fn.lineStart && line <= fn.lineEnd) {
|
|
512
|
+
const size = fn.lineEnd - fn.lineStart;
|
|
513
|
+
if (size < bestSize) {
|
|
514
|
+
bestSize = size;
|
|
515
|
+
best = fn.id;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return best ?? `file:${filePath}`;
|
|
520
|
+
}
|
|
521
|
+
function resolveCallExpression(node, filePath, fnScopes) {
|
|
522
|
+
const fnField = node.childForFieldName('function') ??
|
|
523
|
+
node.childForFieldName('name') ??
|
|
524
|
+
node.childForFieldName('method');
|
|
525
|
+
if (!fnField)
|
|
526
|
+
return null;
|
|
527
|
+
const callerNodeId = findEnclosingFunction(node, filePath, fnScopes);
|
|
528
|
+
if (!callerNodeId)
|
|
529
|
+
return null;
|
|
530
|
+
if (fnField.type === 'member_expression' ||
|
|
531
|
+
fnField.type === 'attribute' ||
|
|
532
|
+
fnField.type === 'selector_expression' ||
|
|
533
|
+
fnField.type === 'field_expression') {
|
|
534
|
+
const property = fnField.childForFieldName('property') ??
|
|
535
|
+
fnField.childForFieldName('attribute') ??
|
|
536
|
+
fnField.childForFieldName('field');
|
|
537
|
+
if (!property)
|
|
538
|
+
return null;
|
|
539
|
+
return {
|
|
540
|
+
callerNodeId,
|
|
541
|
+
calledName: property.text,
|
|
542
|
+
isMethodCall: true,
|
|
543
|
+
objectName: fnField.childForFieldName('object')?.text,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
if (fnField.type === 'identifier' || fnField.type === 'scoped_identifier') {
|
|
547
|
+
return { callerNodeId, calledName: fnField.text, isMethodCall: false };
|
|
548
|
+
}
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
function resolveCallTarget(call, filePath, symbolTable) {
|
|
552
|
+
if (call.isMethodCall && call.objectName) {
|
|
553
|
+
const entry = symbolTable.get(call.objectName);
|
|
554
|
+
if (entry) {
|
|
555
|
+
return `method:${entry.resolvedSourcePath}:${entry.originalName}.${call.calledName}`;
|
|
556
|
+
}
|
|
557
|
+
return `method:${filePath}:${call.objectName}.${call.calledName}`;
|
|
558
|
+
}
|
|
559
|
+
const entry = symbolTable.get(call.calledName);
|
|
560
|
+
if (entry)
|
|
561
|
+
return `fn:${entry.resolvedSourcePath}:${entry.originalName}`;
|
|
562
|
+
return `fn:${filePath}:${call.calledName}`;
|
|
563
|
+
}
|
|
564
|
+
function buildSymbolTable(root, filePath, language, config) {
|
|
565
|
+
const table = new Map();
|
|
566
|
+
for (const child of root.children) {
|
|
567
|
+
if (!config.importTypes.has(child.type))
|
|
568
|
+
continue;
|
|
569
|
+
const importPath = extractImportPath(child, language, config);
|
|
570
|
+
if (!importPath)
|
|
571
|
+
continue;
|
|
572
|
+
const resolvedPath = resolveImportPath(filePath, importPath, config);
|
|
573
|
+
if (language === 'javascript' || language === 'typescript' || language === 'tsx') {
|
|
574
|
+
buildJsSymbolTable(child, importPath, resolvedPath, table);
|
|
575
|
+
}
|
|
576
|
+
else if (language === 'python') {
|
|
577
|
+
buildPythonSymbolTable(child, importPath, resolvedPath, table);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return table;
|
|
581
|
+
}
|
|
582
|
+
function buildJsSymbolTable(importNode, importPath, resolvedPath, table) {
|
|
583
|
+
const importClause = importNode.children.find((c) => c.type === 'import_clause');
|
|
584
|
+
if (!importClause)
|
|
585
|
+
return;
|
|
586
|
+
for (const clause of importClause.children) {
|
|
587
|
+
if (clause.type === 'named_imports') {
|
|
588
|
+
for (const spec of clause.children) {
|
|
589
|
+
if (spec.type !== 'import_specifier')
|
|
590
|
+
continue;
|
|
591
|
+
const nameNode = spec.childForFieldName('name');
|
|
592
|
+
const aliasNode = spec.childForFieldName('alias');
|
|
593
|
+
if (!nameNode)
|
|
594
|
+
continue;
|
|
595
|
+
const originalName = nameNode.text;
|
|
596
|
+
const localName = aliasNode?.text ?? originalName;
|
|
597
|
+
table.set(localName, {
|
|
598
|
+
localName,
|
|
599
|
+
originalName,
|
|
600
|
+
sourcePath: importPath,
|
|
601
|
+
resolvedSourcePath: resolvedPath,
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (clause.type === 'identifier') {
|
|
606
|
+
table.set(clause.text, {
|
|
607
|
+
localName: clause.text,
|
|
608
|
+
originalName: 'default',
|
|
609
|
+
sourcePath: importPath,
|
|
610
|
+
resolvedSourcePath: resolvedPath,
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function buildPythonSymbolTable(importNode, importPath, resolvedPath, table) {
|
|
616
|
+
if (importNode.type !== 'import_from_statement')
|
|
617
|
+
return;
|
|
618
|
+
for (const child of importNode.children) {
|
|
619
|
+
if (child.type === 'dotted_name' && child !== importNode.childForFieldName('module_name')) {
|
|
620
|
+
const aliasNode = child.parent?.children.find((c) => c.type === 'aliased_import');
|
|
621
|
+
const localName = aliasNode?.childForFieldName('alias')?.text ?? child.text;
|
|
622
|
+
table.set(localName, {
|
|
623
|
+
localName,
|
|
624
|
+
originalName: child.text,
|
|
625
|
+
sourcePath: importPath,
|
|
626
|
+
resolvedSourcePath: resolvedPath,
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
if (child.type === 'aliased_import') {
|
|
630
|
+
const nameNode = child.childForFieldName('name');
|
|
631
|
+
const aliasNode = child.childForFieldName('alias');
|
|
632
|
+
if (nameNode) {
|
|
633
|
+
const localName = aliasNode?.text ?? nameNode.text;
|
|
634
|
+
table.set(localName, {
|
|
635
|
+
localName,
|
|
636
|
+
originalName: nameNode.text,
|
|
637
|
+
sourcePath: importPath,
|
|
638
|
+
resolvedSourcePath: resolvedPath,
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function extractImportBindings(symbolTable, filePath, edges) {
|
|
645
|
+
for (const [, entry] of symbolTable) {
|
|
646
|
+
const prefix = guessNodePrefix(entry.originalName);
|
|
647
|
+
edges.push({
|
|
648
|
+
sourceId: `file:${filePath}`,
|
|
649
|
+
targetId: `${prefix}:${entry.resolvedSourcePath}:${entry.originalName}`,
|
|
650
|
+
type: 'imports_symbol',
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
function guessNodePrefix(name) {
|
|
655
|
+
if (!name || name === 'default')
|
|
656
|
+
return 'fn';
|
|
657
|
+
if (name[0] === name[0].toUpperCase() && name[0] !== name[0].toLowerCase())
|
|
658
|
+
return 'class';
|
|
659
|
+
return 'fn';
|
|
660
|
+
}
|
|
661
|
+
function resolveImportPath(fromFile, importPath, config) {
|
|
662
|
+
if (!importPath.startsWith('.'))
|
|
663
|
+
return importPath;
|
|
664
|
+
const cacheKey = `${fromFile}:${importPath}`;
|
|
665
|
+
const cached = resolveCache.get(cacheKey);
|
|
666
|
+
if (cached)
|
|
667
|
+
return cached;
|
|
668
|
+
const dir = path.dirname(fromFile);
|
|
669
|
+
const resolved = path.resolve(dir, importPath);
|
|
670
|
+
if (fs.existsSync(resolved)) {
|
|
671
|
+
resolveCache.set(cacheKey, resolved);
|
|
672
|
+
return resolved;
|
|
673
|
+
}
|
|
674
|
+
for (const ext of config.extensions) {
|
|
675
|
+
const withExt = resolved + ext;
|
|
676
|
+
if (fs.existsSync(withExt)) {
|
|
677
|
+
resolveCache.set(cacheKey, withExt);
|
|
678
|
+
return withExt;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
const stripped = resolved.replace(/\.js$/, '.ts');
|
|
682
|
+
if (stripped !== resolved && fs.existsSync(stripped)) {
|
|
683
|
+
resolveCache.set(cacheKey, stripped);
|
|
684
|
+
return stripped;
|
|
685
|
+
}
|
|
686
|
+
resolveCache.set(cacheKey, resolved);
|
|
687
|
+
return resolved;
|
|
688
|
+
}
|
|
689
|
+
//# sourceMappingURL=parser.js.map
|