@timmeck/brain 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BRAIN_PLAN.md +3324 -0
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/brain.d.ts +11 -0
- package/dist/brain.js +166 -0
- package/dist/brain.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +2 -0
- package/dist/cli/commands/dashboard.js +457 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/commands/export.d.ts +2 -0
- package/dist/cli/commands/export.js +25 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/import.d.ts +2 -0
- package/dist/cli/commands/import.js +173 -0
- package/dist/cli/commands/import.js.map +1 -0
- package/dist/cli/commands/insights.d.ts +2 -0
- package/dist/cli/commands/insights.js +32 -0
- package/dist/cli/commands/insights.js.map +1 -0
- package/dist/cli/commands/modules.d.ts +2 -0
- package/dist/cli/commands/modules.js +29 -0
- package/dist/cli/commands/modules.js.map +1 -0
- package/dist/cli/commands/network.d.ts +2 -0
- package/dist/cli/commands/network.js +56 -0
- package/dist/cli/commands/network.js.map +1 -0
- package/dist/cli/commands/query.d.ts +2 -0
- package/dist/cli/commands/query.js +40 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/start.d.ts +2 -0
- package/dist/cli/commands/start.js +56 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.js +60 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +2 -0
- package/dist/cli/commands/stop.js +34 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/ipc-helper.d.ts +2 -0
- package/dist/cli/ipc-helper.js +25 -0
- package/dist/cli/ipc-helper.js.map +1 -0
- package/dist/code/analyzer.d.ts +12 -0
- package/dist/code/analyzer.js +58 -0
- package/dist/code/analyzer.js.map +1 -0
- package/dist/code/fingerprint.d.ts +2 -0
- package/dist/code/fingerprint.js +84 -0
- package/dist/code/fingerprint.js.map +1 -0
- package/dist/code/matcher.d.ts +9 -0
- package/dist/code/matcher.js +37 -0
- package/dist/code/matcher.js.map +1 -0
- package/dist/code/parsers/generic.d.ts +7 -0
- package/dist/code/parsers/generic.js +22 -0
- package/dist/code/parsers/generic.js.map +1 -0
- package/dist/code/parsers/python.d.ts +7 -0
- package/dist/code/parsers/python.js +45 -0
- package/dist/code/parsers/python.js.map +1 -0
- package/dist/code/parsers/typescript.d.ts +7 -0
- package/dist/code/parsers/typescript.js +58 -0
- package/dist/code/parsers/typescript.js.map +1 -0
- package/dist/code/registry.d.ts +22 -0
- package/dist/code/registry.js +31 -0
- package/dist/code/registry.js.map +1 -0
- package/dist/code/scorer.d.ts +15 -0
- package/dist/code/scorer.js +103 -0
- package/dist/code/scorer.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +110 -0
- package/dist/config.js.map +1 -0
- package/dist/db/connection.d.ts +2 -0
- package/dist/db/connection.js +19 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/db/migrations/001_core_schema.d.ts +2 -0
- package/dist/db/migrations/001_core_schema.js +119 -0
- package/dist/db/migrations/001_core_schema.js.map +1 -0
- package/dist/db/migrations/002_learning_schema.d.ts +2 -0
- package/dist/db/migrations/002_learning_schema.js +37 -0
- package/dist/db/migrations/002_learning_schema.js.map +1 -0
- package/dist/db/migrations/003_code_schema.d.ts +2 -0
- package/dist/db/migrations/003_code_schema.js +52 -0
- package/dist/db/migrations/003_code_schema.js.map +1 -0
- package/dist/db/migrations/004_synapses_schema.d.ts +2 -0
- package/dist/db/migrations/004_synapses_schema.js +56 -0
- package/dist/db/migrations/004_synapses_schema.js.map +1 -0
- package/dist/db/migrations/005_fts_indexes.d.ts +2 -0
- package/dist/db/migrations/005_fts_indexes.js +77 -0
- package/dist/db/migrations/005_fts_indexes.js.map +1 -0
- package/dist/db/migrations/006_synapses_phase3.d.ts +2 -0
- package/dist/db/migrations/006_synapses_phase3.js +14 -0
- package/dist/db/migrations/006_synapses_phase3.js.map +1 -0
- package/dist/db/migrations/index.d.ts +2 -0
- package/dist/db/migrations/index.js +49 -0
- package/dist/db/migrations/index.js.map +1 -0
- package/dist/db/repositories/antipattern.repository.d.ts +26 -0
- package/dist/db/repositories/antipattern.repository.js +44 -0
- package/dist/db/repositories/antipattern.repository.js.map +1 -0
- package/dist/db/repositories/code-module.repository.d.ts +19 -0
- package/dist/db/repositories/code-module.repository.js +64 -0
- package/dist/db/repositories/code-module.repository.js.map +1 -0
- package/dist/db/repositories/error.repository.d.ts +20 -0
- package/dist/db/repositories/error.repository.js +134 -0
- package/dist/db/repositories/error.repository.js.map +1 -0
- package/dist/db/repositories/insight.repository.d.ts +18 -0
- package/dist/db/repositories/insight.repository.js +57 -0
- package/dist/db/repositories/insight.repository.js.map +1 -0
- package/dist/db/repositories/notification.repository.d.ts +24 -0
- package/dist/db/repositories/notification.repository.js +40 -0
- package/dist/db/repositories/notification.repository.js.map +1 -0
- package/dist/db/repositories/project.repository.d.ts +25 -0
- package/dist/db/repositories/project.repository.js +72 -0
- package/dist/db/repositories/project.repository.js.map +1 -0
- package/dist/db/repositories/rule.repository.d.ts +31 -0
- package/dist/db/repositories/rule.repository.js +81 -0
- package/dist/db/repositories/rule.repository.js.map +1 -0
- package/dist/db/repositories/solution.repository.d.ts +27 -0
- package/dist/db/repositories/solution.repository.js +132 -0
- package/dist/db/repositories/solution.repository.js.map +1 -0
- package/dist/db/repositories/synapse.repository.d.ts +25 -0
- package/dist/db/repositories/synapse.repository.js +115 -0
- package/dist/db/repositories/synapse.repository.js.map +1 -0
- package/dist/db/repositories/terminal.repository.d.ts +27 -0
- package/dist/db/repositories/terminal.repository.js +78 -0
- package/dist/db/repositories/terminal.repository.js.map +1 -0
- package/dist/hooks/post-tool-use.d.ts +2 -0
- package/dist/hooks/post-tool-use.js +77 -0
- package/dist/hooks/post-tool-use.js.map +1 -0
- package/dist/hooks/post-write.d.ts +2 -0
- package/dist/hooks/post-write.js +102 -0
- package/dist/hooks/post-write.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/client.d.ts +16 -0
- package/dist/ipc/client.js +101 -0
- package/dist/ipc/client.js.map +1 -0
- package/dist/ipc/protocol.d.ts +8 -0
- package/dist/ipc/protocol.js +29 -0
- package/dist/ipc/protocol.js.map +1 -0
- package/dist/ipc/router.d.ts +28 -0
- package/dist/ipc/router.js +70 -0
- package/dist/ipc/router.js.map +1 -0
- package/dist/ipc/server.d.ts +14 -0
- package/dist/ipc/server.js +98 -0
- package/dist/ipc/server.js.map +1 -0
- package/dist/learning/confidence-scorer.d.ts +13 -0
- package/dist/learning/confidence-scorer.js +35 -0
- package/dist/learning/confidence-scorer.js.map +1 -0
- package/dist/learning/decay.d.ts +13 -0
- package/dist/learning/decay.js +37 -0
- package/dist/learning/decay.js.map +1 -0
- package/dist/learning/learning-engine.d.ts +30 -0
- package/dist/learning/learning-engine.js +121 -0
- package/dist/learning/learning-engine.js.map +1 -0
- package/dist/learning/pattern-extractor.d.ts +16 -0
- package/dist/learning/pattern-extractor.js +61 -0
- package/dist/learning/pattern-extractor.js.map +1 -0
- package/dist/learning/rule-generator.d.ts +18 -0
- package/dist/learning/rule-generator.js +50 -0
- package/dist/learning/rule-generator.js.map +1 -0
- package/dist/matching/error-matcher.d.ts +13 -0
- package/dist/matching/error-matcher.js +84 -0
- package/dist/matching/error-matcher.js.map +1 -0
- package/dist/matching/fingerprint.d.ts +3 -0
- package/dist/matching/fingerprint.js +23 -0
- package/dist/matching/fingerprint.js.map +1 -0
- package/dist/matching/similarity.d.ts +3 -0
- package/dist/matching/similarity.js +53 -0
- package/dist/matching/similarity.js.map +1 -0
- package/dist/matching/tfidf.d.ts +15 -0
- package/dist/matching/tfidf.js +68 -0
- package/dist/matching/tfidf.js.map +1 -0
- package/dist/matching/tokenizer.d.ts +4 -0
- package/dist/matching/tokenizer.js +36 -0
- package/dist/matching/tokenizer.js.map +1 -0
- package/dist/mcp/auto-detect.d.ts +1 -0
- package/dist/mcp/auto-detect.js +81 -0
- package/dist/mcp/auto-detect.js.map +1 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +68 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +3 -0
- package/dist/mcp/tools.js +201 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/parsing/error-parser.d.ts +3 -0
- package/dist/parsing/error-parser.js +26 -0
- package/dist/parsing/error-parser.js.map +1 -0
- package/dist/parsing/parsers/compiler.d.ts +2 -0
- package/dist/parsing/parsers/compiler.js +83 -0
- package/dist/parsing/parsers/compiler.js.map +1 -0
- package/dist/parsing/parsers/generic.d.ts +2 -0
- package/dist/parsing/parsers/generic.js +23 -0
- package/dist/parsing/parsers/generic.js.map +1 -0
- package/dist/parsing/parsers/go.d.ts +2 -0
- package/dist/parsing/parsers/go.js +85 -0
- package/dist/parsing/parsers/go.js.map +1 -0
- package/dist/parsing/parsers/node.d.ts +2 -0
- package/dist/parsing/parsers/node.js +61 -0
- package/dist/parsing/parsers/node.js.map +1 -0
- package/dist/parsing/parsers/python.d.ts +2 -0
- package/dist/parsing/parsers/python.js +50 -0
- package/dist/parsing/parsers/python.js.map +1 -0
- package/dist/parsing/parsers/rust.d.ts +2 -0
- package/dist/parsing/parsers/rust.js +43 -0
- package/dist/parsing/parsers/rust.js.map +1 -0
- package/dist/parsing/parsers/shell.d.ts +2 -0
- package/dist/parsing/parsers/shell.js +36 -0
- package/dist/parsing/parsers/shell.js.map +1 -0
- package/dist/parsing/types.d.ts +28 -0
- package/dist/parsing/types.js +21 -0
- package/dist/parsing/types.js.map +1 -0
- package/dist/research/gap-analyzer.d.ts +23 -0
- package/dist/research/gap-analyzer.js +119 -0
- package/dist/research/gap-analyzer.js.map +1 -0
- package/dist/research/insight-generator.d.ts +23 -0
- package/dist/research/insight-generator.js +107 -0
- package/dist/research/insight-generator.js.map +1 -0
- package/dist/research/research-engine.d.ts +31 -0
- package/dist/research/research-engine.js +97 -0
- package/dist/research/research-engine.js.map +1 -0
- package/dist/research/synergy-detector.d.ts +24 -0
- package/dist/research/synergy-detector.js +109 -0
- package/dist/research/synergy-detector.js.map +1 -0
- package/dist/research/template-extractor.d.ts +18 -0
- package/dist/research/template-extractor.js +116 -0
- package/dist/research/template-extractor.js.map +1 -0
- package/dist/research/trend-analyzer.d.ts +20 -0
- package/dist/research/trend-analyzer.js +111 -0
- package/dist/research/trend-analyzer.js.map +1 -0
- package/dist/services/analytics.service.d.ts +52 -0
- package/dist/services/analytics.service.js +59 -0
- package/dist/services/analytics.service.js.map +1 -0
- package/dist/services/code.service.d.ts +39 -0
- package/dist/services/code.service.js +98 -0
- package/dist/services/code.service.js.map +1 -0
- package/dist/services/error.service.d.ts +35 -0
- package/dist/services/error.service.js +118 -0
- package/dist/services/error.service.js.map +1 -0
- package/dist/services/notification.service.d.ts +17 -0
- package/dist/services/notification.service.js +29 -0
- package/dist/services/notification.service.js.map +1 -0
- package/dist/services/prevention.service.d.ts +35 -0
- package/dist/services/prevention.service.js +82 -0
- package/dist/services/prevention.service.js.map +1 -0
- package/dist/services/research.service.d.ts +35 -0
- package/dist/services/research.service.js +60 -0
- package/dist/services/research.service.js.map +1 -0
- package/dist/services/solution.service.d.ts +30 -0
- package/dist/services/solution.service.js +73 -0
- package/dist/services/solution.service.js.map +1 -0
- package/dist/services/synapse.service.d.ts +30 -0
- package/dist/services/synapse.service.js +25 -0
- package/dist/services/synapse.service.js.map +1 -0
- package/dist/services/terminal.service.d.ts +20 -0
- package/dist/services/terminal.service.js +66 -0
- package/dist/services/terminal.service.js.map +1 -0
- package/dist/synapses/activation.d.ts +13 -0
- package/dist/synapses/activation.js +50 -0
- package/dist/synapses/activation.js.map +1 -0
- package/dist/synapses/decay.d.ts +11 -0
- package/dist/synapses/decay.js +27 -0
- package/dist/synapses/decay.js.map +1 -0
- package/dist/synapses/hebbian.d.ts +13 -0
- package/dist/synapses/hebbian.js +36 -0
- package/dist/synapses/hebbian.js.map +1 -0
- package/dist/synapses/pathfinder.d.ts +14 -0
- package/dist/synapses/pathfinder.js +50 -0
- package/dist/synapses/pathfinder.js.map +1 -0
- package/dist/synapses/synapse-manager.d.ts +30 -0
- package/dist/synapses/synapse-manager.js +72 -0
- package/dist/synapses/synapse-manager.js.map +1 -0
- package/dist/types/code.types.d.ts +47 -0
- package/dist/types/code.types.js +2 -0
- package/dist/types/code.types.js.map +1 -0
- package/dist/types/config.types.d.ts +70 -0
- package/dist/types/config.types.js +2 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/error.types.d.ts +60 -0
- package/dist/types/error.types.js +2 -0
- package/dist/types/error.types.js.map +1 -0
- package/dist/types/ipc.types.d.ts +11 -0
- package/dist/types/ipc.types.js +2 -0
- package/dist/types/ipc.types.js.map +1 -0
- package/dist/types/mcp.types.d.ts +46 -0
- package/dist/types/mcp.types.js +2 -0
- package/dist/types/mcp.types.js.map +1 -0
- package/dist/types/research.types.d.ts +25 -0
- package/dist/types/research.types.js +2 -0
- package/dist/types/research.types.js.map +1 -0
- package/dist/types/solution.types.d.ts +28 -0
- package/dist/types/solution.types.js +2 -0
- package/dist/types/solution.types.js.map +1 -0
- package/dist/types/synapse.types.d.ts +37 -0
- package/dist/types/synapse.types.js +2 -0
- package/dist/types/synapse.types.js.map +1 -0
- package/dist/utils/events.d.ts +59 -0
- package/dist/utils/events.js +23 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +5 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.js +39 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paths.d.ts +3 -0
- package/dist/utils/paths.js +18 -0
- package/dist/utils/paths.js.map +1 -0
- package/package.json +43 -0
- package/src/brain.ts +220 -0
- package/src/cli/commands/dashboard.ts +495 -0
- package/src/cli/commands/export.ts +27 -0
- package/src/cli/commands/import.ts +190 -0
- package/src/cli/commands/insights.ts +33 -0
- package/src/cli/commands/modules.ts +30 -0
- package/src/cli/commands/network.ts +61 -0
- package/src/cli/commands/query.ts +43 -0
- package/src/cli/commands/start.ts +59 -0
- package/src/cli/commands/status.ts +69 -0
- package/src/cli/commands/stop.ts +33 -0
- package/src/cli/ipc-helper.ts +21 -0
- package/src/code/analyzer.ts +77 -0
- package/src/code/fingerprint.ts +87 -0
- package/src/code/matcher.ts +64 -0
- package/src/code/parsers/generic.ts +29 -0
- package/src/code/parsers/python.ts +54 -0
- package/src/code/parsers/typescript.ts +65 -0
- package/src/code/registry.ts +60 -0
- package/src/code/scorer.ts +108 -0
- package/src/config.ts +111 -0
- package/src/db/connection.ts +22 -0
- package/src/db/migrations/001_core_schema.ts +120 -0
- package/src/db/migrations/002_learning_schema.ts +38 -0
- package/src/db/migrations/003_code_schema.ts +53 -0
- package/src/db/migrations/004_synapses_schema.ts +57 -0
- package/src/db/migrations/005_fts_indexes.ts +78 -0
- package/src/db/migrations/006_synapses_phase3.ts +17 -0
- package/src/db/migrations/index.ts +64 -0
- package/src/db/repositories/antipattern.repository.ts +66 -0
- package/src/db/repositories/code-module.repository.ts +80 -0
- package/src/db/repositories/error.repository.ts +149 -0
- package/src/db/repositories/insight.repository.ts +78 -0
- package/src/db/repositories/notification.repository.ts +66 -0
- package/src/db/repositories/project.repository.ts +93 -0
- package/src/db/repositories/rule.repository.ts +108 -0
- package/src/db/repositories/solution.repository.ts +154 -0
- package/src/db/repositories/synapse.repository.ts +153 -0
- package/src/db/repositories/terminal.repository.ts +101 -0
- package/src/hooks/post-tool-use.ts +90 -0
- package/src/hooks/post-write.ts +117 -0
- package/src/index.ts +53 -0
- package/src/ipc/client.ts +118 -0
- package/src/ipc/protocol.ts +35 -0
- package/src/ipc/router.ts +106 -0
- package/src/ipc/server.ts +110 -0
- package/src/learning/confidence-scorer.ts +47 -0
- package/src/learning/decay.ts +46 -0
- package/src/learning/learning-engine.ts +162 -0
- package/src/learning/pattern-extractor.ts +90 -0
- package/src/learning/rule-generator.ts +74 -0
- package/src/main.rs:10:5 +0 -0
- package/src/matching/error-matcher.ts +115 -0
- package/src/matching/fingerprint.ts +29 -0
- package/src/matching/similarity.ts +61 -0
- package/src/matching/tfidf.ts +74 -0
- package/src/matching/tokenizer.ts +41 -0
- package/src/mcp/auto-detect.ts +93 -0
- package/src/mcp/server.ts +73 -0
- package/src/mcp/tools.ts +290 -0
- package/src/parsing/error-parser.ts +28 -0
- package/src/parsing/parsers/compiler.ts +93 -0
- package/src/parsing/parsers/generic.ts +28 -0
- package/src/parsing/parsers/go.ts +97 -0
- package/src/parsing/parsers/node.ts +69 -0
- package/src/parsing/parsers/python.ts +62 -0
- package/src/parsing/parsers/rust.ts +50 -0
- package/src/parsing/parsers/shell.ts +42 -0
- package/src/parsing/types.ts +47 -0
- package/src/research/gap-analyzer.ts +135 -0
- package/src/research/insight-generator.ts +123 -0
- package/src/research/research-engine.ts +116 -0
- package/src/research/synergy-detector.ts +126 -0
- package/src/research/template-extractor.ts +130 -0
- package/src/research/trend-analyzer.ts +127 -0
- package/src/services/analytics.service.ts +87 -0
- package/src/services/code.service.ts +140 -0
- package/src/services/error.service.ts +164 -0
- package/src/services/notification.service.ts +41 -0
- package/src/services/prevention.service.ts +119 -0
- package/src/services/research.service.ts +93 -0
- package/src/services/solution.service.ts +116 -0
- package/src/services/synapse.service.ts +59 -0
- package/src/services/terminal.service.ts +81 -0
- package/src/synapses/activation.ts +80 -0
- package/src/synapses/decay.ts +38 -0
- package/src/synapses/hebbian.ts +69 -0
- package/src/synapses/pathfinder.ts +81 -0
- package/src/synapses/synapse-manager.ts +109 -0
- package/src/types/code.types.ts +52 -0
- package/src/types/config.types.ts +79 -0
- package/src/types/error.types.ts +67 -0
- package/src/types/ipc.types.ts +8 -0
- package/src/types/mcp.types.ts +53 -0
- package/src/types/research.types.ts +28 -0
- package/src/types/solution.types.ts +30 -0
- package/src/types/synapse.types.ts +49 -0
- package/src/utils/events.ts +45 -0
- package/src/utils/hash.ts +5 -0
- package/src/utils/logger.ts +48 -0
- package/src/utils/paths.ts +19 -0
- package/tests/fixtures/code-modules/modules.ts +83 -0
- package/tests/fixtures/errors/go.ts +9 -0
- package/tests/fixtures/errors/node.ts +24 -0
- package/tests/fixtures/errors/python.ts +21 -0
- package/tests/fixtures/errors/rust.ts +25 -0
- package/tests/fixtures/errors/shell.ts +15 -0
- package/tests/fixtures/solutions/solutions.ts +27 -0
- package/tests/helpers/setup-db.ts +52 -0
- package/tests/integration/code-flow.test.ts +86 -0
- package/tests/integration/error-flow.test.ts +83 -0
- package/tests/integration/ipc-flow.test.ts +166 -0
- package/tests/integration/learning-cycle.test.ts +82 -0
- package/tests/integration/synapse-flow.test.ts +117 -0
- package/tests/unit/code/analyzer.test.ts +58 -0
- package/tests/unit/code/fingerprint.test.ts +51 -0
- package/tests/unit/code/scorer.test.ts +55 -0
- package/tests/unit/learning/confidence-scorer.test.ts +60 -0
- package/tests/unit/learning/decay.test.ts +45 -0
- package/tests/unit/learning/pattern-extractor.test.ts +50 -0
- package/tests/unit/matching/error-matcher.test.ts +69 -0
- package/tests/unit/matching/fingerprint.test.ts +47 -0
- package/tests/unit/matching/similarity.test.ts +65 -0
- package/tests/unit/matching/tfidf.test.ts +71 -0
- package/tests/unit/matching/tokenizer.test.ts +83 -0
- package/tests/unit/parsing/parsers.test.ts +113 -0
- package/tests/unit/research/gap-analyzer.test.ts +45 -0
- package/tests/unit/research/trend-analyzer.test.ts +45 -0
- package/tests/unit/synapses/activation.test.ts +80 -0
- package/tests/unit/synapses/decay.test.ts +27 -0
- package/tests/unit/synapses/hebbian.test.ts +96 -0
- package/tests/unit/synapses/pathfinder.test.ts +72 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function findPath(repo, from, to, maxDepth = 5) {
|
|
2
|
+
const visited = new Set();
|
|
3
|
+
const queue = [{ node: from, path: [], totalWeight: 1.0 }];
|
|
4
|
+
let bestPath = null;
|
|
5
|
+
while (queue.length > 0) {
|
|
6
|
+
const current = queue.shift();
|
|
7
|
+
const key = `${current.node.type}:${current.node.id}`;
|
|
8
|
+
if (visited.has(key))
|
|
9
|
+
continue;
|
|
10
|
+
visited.add(key);
|
|
11
|
+
if (current.node.type === to.type && current.node.id === to.id) {
|
|
12
|
+
if (!bestPath || current.totalWeight > bestPath.totalWeight) {
|
|
13
|
+
bestPath = {
|
|
14
|
+
from,
|
|
15
|
+
to,
|
|
16
|
+
synapses: current.path,
|
|
17
|
+
totalWeight: current.totalWeight,
|
|
18
|
+
hops: current.path.length,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (current.path.length >= maxDepth)
|
|
24
|
+
continue;
|
|
25
|
+
const outgoing = repo.getOutgoing(current.node.type, current.node.id);
|
|
26
|
+
for (const synapse of outgoing) {
|
|
27
|
+
const targetKey = `${synapse.target_type}:${synapse.target_id}`;
|
|
28
|
+
if (!visited.has(targetKey)) {
|
|
29
|
+
queue.push({
|
|
30
|
+
node: { type: synapse.target_type, id: synapse.target_id },
|
|
31
|
+
path: [...current.path, synapse],
|
|
32
|
+
totalWeight: current.totalWeight * synapse.weight,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const incoming = repo.getIncoming(current.node.type, current.node.id);
|
|
37
|
+
for (const synapse of incoming) {
|
|
38
|
+
const sourceKey = `${synapse.source_type}:${synapse.source_id}`;
|
|
39
|
+
if (!visited.has(sourceKey)) {
|
|
40
|
+
queue.push({
|
|
41
|
+
node: { type: synapse.source_type, id: synapse.source_id },
|
|
42
|
+
path: [...current.path, synapse],
|
|
43
|
+
totalWeight: current.totalWeight * synapse.weight,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return bestPath;
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OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM;iBAClD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SynapsesConfig } from '../types/config.types.js';
|
|
2
|
+
import type { SynapseType, SynapseRecord, NetworkStats } from '../types/synapse.types.js';
|
|
3
|
+
import type { SynapseRepository } from '../db/repositories/synapse.repository.js';
|
|
4
|
+
import { type NodeRef } from './hebbian.js';
|
|
5
|
+
import { type ActivationResult } from './activation.js';
|
|
6
|
+
import { type SynapsePath } from './pathfinder.js';
|
|
7
|
+
export declare class SynapseManager {
|
|
8
|
+
private repo;
|
|
9
|
+
private config;
|
|
10
|
+
private logger;
|
|
11
|
+
constructor(repo: SynapseRepository, config: SynapsesConfig);
|
|
12
|
+
strengthen(source: NodeRef, target: NodeRef, synapseType: SynapseType, context?: Record<string, unknown>): SynapseRecord;
|
|
13
|
+
weaken(synapseId: number, factor?: number): void;
|
|
14
|
+
find(source: NodeRef, target: NodeRef, synapseType: SynapseType): SynapseRecord | undefined;
|
|
15
|
+
activate(startNode: NodeRef, maxDepth?: number, minWeight?: number): ActivationResult[];
|
|
16
|
+
findPath(from: NodeRef, to: NodeRef, maxDepth?: number): SynapsePath | null;
|
|
17
|
+
runDecay(): {
|
|
18
|
+
decayed: number;
|
|
19
|
+
pruned: number;
|
|
20
|
+
};
|
|
21
|
+
getErrorContext(errorId: number): {
|
|
22
|
+
solutions: ActivationResult[];
|
|
23
|
+
relatedErrors: ActivationResult[];
|
|
24
|
+
relevantModules: ActivationResult[];
|
|
25
|
+
preventionRules: ActivationResult[];
|
|
26
|
+
insights: ActivationResult[];
|
|
27
|
+
};
|
|
28
|
+
getStrongestSynapses(limit?: number): SynapseRecord[];
|
|
29
|
+
getNetworkStats(): NetworkStats;
|
|
30
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { strengthen, weaken } from './hebbian.js';
|
|
2
|
+
import { decayAll } from './decay.js';
|
|
3
|
+
import { spreadingActivation } from './activation.js';
|
|
4
|
+
import { findPath } from './pathfinder.js';
|
|
5
|
+
import { getLogger } from '../utils/logger.js';
|
|
6
|
+
export class SynapseManager {
|
|
7
|
+
repo;
|
|
8
|
+
config;
|
|
9
|
+
logger = getLogger();
|
|
10
|
+
constructor(repo, config) {
|
|
11
|
+
this.repo = repo;
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
strengthen(source, target, synapseType, context) {
|
|
15
|
+
this.logger.debug(`Strengthening synapse ${source.type}:${source.id} --${synapseType}--> ${target.type}:${target.id}`);
|
|
16
|
+
return strengthen(this.repo, source, target, synapseType, {
|
|
17
|
+
initialWeight: this.config.initialWeight,
|
|
18
|
+
learningRate: this.config.learningRate,
|
|
19
|
+
pruneThreshold: this.config.pruneThreshold,
|
|
20
|
+
}, context);
|
|
21
|
+
}
|
|
22
|
+
weaken(synapseId, factor = 0.5) {
|
|
23
|
+
this.logger.debug(`Weakening synapse ${synapseId} by factor ${factor}`);
|
|
24
|
+
weaken(this.repo, synapseId, {
|
|
25
|
+
initialWeight: this.config.initialWeight,
|
|
26
|
+
learningRate: this.config.learningRate,
|
|
27
|
+
pruneThreshold: this.config.pruneThreshold,
|
|
28
|
+
}, factor);
|
|
29
|
+
}
|
|
30
|
+
find(source, target, synapseType) {
|
|
31
|
+
return this.repo.findBySourceTarget(source.type, source.id, target.type, target.id, synapseType);
|
|
32
|
+
}
|
|
33
|
+
activate(startNode, maxDepth, minWeight) {
|
|
34
|
+
return spreadingActivation(this.repo, startNode, maxDepth ?? this.config.maxDepth, minWeight ?? this.config.minActivationWeight);
|
|
35
|
+
}
|
|
36
|
+
findPath(from, to, maxDepth) {
|
|
37
|
+
return findPath(this.repo, from, to, maxDepth ?? this.config.maxDepth + 2);
|
|
38
|
+
}
|
|
39
|
+
runDecay() {
|
|
40
|
+
this.logger.info('Running synapse decay cycle');
|
|
41
|
+
const result = decayAll(this.repo, {
|
|
42
|
+
decayHalfLifeDays: this.config.decayHalfLifeDays,
|
|
43
|
+
decayAfterDays: this.config.decayAfterDays,
|
|
44
|
+
pruneThreshold: this.config.pruneThreshold,
|
|
45
|
+
});
|
|
46
|
+
this.logger.info(`Decay complete: ${result.decayed} decayed, ${result.pruned} pruned`);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
getErrorContext(errorId) {
|
|
50
|
+
const all = this.activate({ type: 'error', id: errorId });
|
|
51
|
+
return {
|
|
52
|
+
solutions: all.filter(a => a.node.type === 'solution'),
|
|
53
|
+
relatedErrors: all.filter(a => a.node.type === 'error'),
|
|
54
|
+
relevantModules: all.filter(a => a.node.type === 'code_module'),
|
|
55
|
+
preventionRules: all.filter(a => a.node.type === 'rule'),
|
|
56
|
+
insights: all.filter(a => a.node.type === 'insight'),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
getStrongestSynapses(limit = 20) {
|
|
60
|
+
return this.repo.topByWeight(limit);
|
|
61
|
+
}
|
|
62
|
+
getNetworkStats() {
|
|
63
|
+
return {
|
|
64
|
+
totalNodes: this.repo.countNodes(),
|
|
65
|
+
totalSynapses: this.repo.totalCount(),
|
|
66
|
+
avgWeight: this.repo.avgWeight(),
|
|
67
|
+
nodesByType: {},
|
|
68
|
+
synapsesByType: this.repo.countByType(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=synapse-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synapse-manager.js","sourceRoot":"","sources":["../../src/synapses/synapse-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAgB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAyB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,Q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AAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC;YACtD,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;YACvD,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC;YAC/D,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;YACxD,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;SACrD,CAAC;IACJ,CAAC;IAED,oBAAoB,CAAC,QAAgB,EAAE;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,eAAe;QACb,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YAChC,WAAW,EAAE,EAA8B;YAC3C,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAiC;SACvE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface CodeModuleRecord {
|
|
2
|
+
id: number;
|
|
3
|
+
project_id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
file_path: string;
|
|
6
|
+
language: string;
|
|
7
|
+
fingerprint: string;
|
|
8
|
+
description: string | null;
|
|
9
|
+
source_hash: string;
|
|
10
|
+
lines_of_code: number;
|
|
11
|
+
complexity: number | null;
|
|
12
|
+
reusability_score: number;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ModuleUsage {
|
|
17
|
+
id: number;
|
|
18
|
+
module_id: number;
|
|
19
|
+
used_in_project_id: number;
|
|
20
|
+
used_in_file: string;
|
|
21
|
+
usage_type: string;
|
|
22
|
+
first_used: string;
|
|
23
|
+
last_used: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ModuleSimilarity {
|
|
26
|
+
id: number;
|
|
27
|
+
module_a_id: number;
|
|
28
|
+
module_b_id: number;
|
|
29
|
+
similarity_score: number;
|
|
30
|
+
computed_at: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CodeUnit {
|
|
33
|
+
name: string;
|
|
34
|
+
filePath: string;
|
|
35
|
+
language: string;
|
|
36
|
+
source: string;
|
|
37
|
+
exports: ExportInfo[];
|
|
38
|
+
}
|
|
39
|
+
export interface ExportInfo {
|
|
40
|
+
name: string;
|
|
41
|
+
type: 'function' | 'class' | 'constant' | 'type' | 'interface' | 'variable';
|
|
42
|
+
}
|
|
43
|
+
export interface ReusabilitySignal {
|
|
44
|
+
name: string;
|
|
45
|
+
score: number;
|
|
46
|
+
reason: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.types.js","sourceRoot":"","sources":["../../src/types/code.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export interface IpcConfig {
|
|
2
|
+
pipeName: string;
|
|
3
|
+
timeout: number;
|
|
4
|
+
}
|
|
5
|
+
export interface LearningConfig {
|
|
6
|
+
intervalMs: number;
|
|
7
|
+
minOccurrences: number;
|
|
8
|
+
minSuccessRate: number;
|
|
9
|
+
minConfidence: number;
|
|
10
|
+
pruneThreshold: number;
|
|
11
|
+
maxRejectionRate: number;
|
|
12
|
+
decayHalfLifeDays: number;
|
|
13
|
+
}
|
|
14
|
+
export interface TerminalConfig {
|
|
15
|
+
staleTimeout: number;
|
|
16
|
+
maxConnected: number;
|
|
17
|
+
}
|
|
18
|
+
export interface MatchingConfig {
|
|
19
|
+
fingerprintFields: string[];
|
|
20
|
+
similarityThreshold: number;
|
|
21
|
+
maxResults: number;
|
|
22
|
+
}
|
|
23
|
+
export interface CodeConfig {
|
|
24
|
+
supportedLanguages: string[];
|
|
25
|
+
maxModuleSize: number;
|
|
26
|
+
similarityThreshold: number;
|
|
27
|
+
}
|
|
28
|
+
export interface SynapsesConfig {
|
|
29
|
+
initialWeight: number;
|
|
30
|
+
learningRate: number;
|
|
31
|
+
decayHalfLifeDays: number;
|
|
32
|
+
pruneThreshold: number;
|
|
33
|
+
decayAfterDays: number;
|
|
34
|
+
maxDepth: number;
|
|
35
|
+
minActivationWeight: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ResearchConfig {
|
|
38
|
+
intervalMs: number;
|
|
39
|
+
initialDelayMs: number;
|
|
40
|
+
minDataPoints: number;
|
|
41
|
+
trendWindowDays: number;
|
|
42
|
+
gapMinOccurrences: number;
|
|
43
|
+
synergyMinWeight: number;
|
|
44
|
+
templateMinAdaptations: number;
|
|
45
|
+
insightExpiryDays: number;
|
|
46
|
+
}
|
|
47
|
+
export interface LogConfig {
|
|
48
|
+
level: string;
|
|
49
|
+
file: string;
|
|
50
|
+
maxSize: number;
|
|
51
|
+
maxFiles: number;
|
|
52
|
+
}
|
|
53
|
+
export interface RetentionConfig {
|
|
54
|
+
errorDays: number;
|
|
55
|
+
solutionDays: number;
|
|
56
|
+
insightDays: number;
|
|
57
|
+
}
|
|
58
|
+
export interface BrainConfig {
|
|
59
|
+
dataDir: string;
|
|
60
|
+
dbPath: string;
|
|
61
|
+
ipc: IpcConfig;
|
|
62
|
+
learning: LearningConfig;
|
|
63
|
+
terminal: TerminalConfig;
|
|
64
|
+
matching: MatchingConfig;
|
|
65
|
+
code: CodeConfig;
|
|
66
|
+
synapses: SynapsesConfig;
|
|
67
|
+
research: ResearchConfig;
|
|
68
|
+
log: LogConfig;
|
|
69
|
+
retention: RetentionConfig;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.types.js","sourceRoot":"","sources":["../../src/types/config.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface ErrorRecord {
|
|
2
|
+
id: number;
|
|
3
|
+
project_id: number;
|
|
4
|
+
terminal_id: number | null;
|
|
5
|
+
fingerprint: string;
|
|
6
|
+
type: string;
|
|
7
|
+
message: string;
|
|
8
|
+
raw_output: string;
|
|
9
|
+
context: string | null;
|
|
10
|
+
file_path: string | null;
|
|
11
|
+
line_number: number | null;
|
|
12
|
+
column_number: number | null;
|
|
13
|
+
occurrence_count: number;
|
|
14
|
+
first_seen: string;
|
|
15
|
+
last_seen: string;
|
|
16
|
+
resolved: number;
|
|
17
|
+
resolved_at: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface StackFrame {
|
|
20
|
+
file: string;
|
|
21
|
+
line: number;
|
|
22
|
+
column: number | null;
|
|
23
|
+
function_name: string | null;
|
|
24
|
+
source: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ParsedError {
|
|
27
|
+
type: string;
|
|
28
|
+
message: string;
|
|
29
|
+
fingerprint: string;
|
|
30
|
+
stackFrames: StackFrame[];
|
|
31
|
+
filePath: string | null;
|
|
32
|
+
lineNumber: number | null;
|
|
33
|
+
columnNumber: number | null;
|
|
34
|
+
context: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface ErrorParser {
|
|
37
|
+
name: string;
|
|
38
|
+
canParse(raw: string): boolean;
|
|
39
|
+
parse(raw: string): ParsedError | null;
|
|
40
|
+
}
|
|
41
|
+
export interface MatchSignal {
|
|
42
|
+
field: string;
|
|
43
|
+
similarity: number;
|
|
44
|
+
weight: number;
|
|
45
|
+
}
|
|
46
|
+
export interface MatchResult {
|
|
47
|
+
errorId: number;
|
|
48
|
+
score: number;
|
|
49
|
+
signals: MatchSignal[];
|
|
50
|
+
}
|
|
51
|
+
export interface ErrorSolutionPair {
|
|
52
|
+
error: ErrorRecord;
|
|
53
|
+
solutionIds: number[];
|
|
54
|
+
}
|
|
55
|
+
export interface Pattern {
|
|
56
|
+
type: string;
|
|
57
|
+
message: string;
|
|
58
|
+
count: number;
|
|
59
|
+
lastSeen: string;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.types.js","sourceRoot":"","sources":["../../src/types/error.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipc.types.js","sourceRoot":"","sources":["../../src/types/ipc.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface HookInput {
|
|
2
|
+
tool: string;
|
|
3
|
+
arguments: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
export interface ReportErrorParams {
|
|
6
|
+
project: string;
|
|
7
|
+
error_output: string;
|
|
8
|
+
file_path?: string;
|
|
9
|
+
terminal_id?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface GetSolutionsParams {
|
|
12
|
+
error_output?: string;
|
|
13
|
+
error_id?: number;
|
|
14
|
+
project?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ApplySolutionParams {
|
|
17
|
+
error_id: number;
|
|
18
|
+
solution_id: number;
|
|
19
|
+
terminal_id?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface RegisterModuleParams {
|
|
22
|
+
project: string;
|
|
23
|
+
name: string;
|
|
24
|
+
file_path: string;
|
|
25
|
+
language: string;
|
|
26
|
+
source: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SearchModulesParams {
|
|
30
|
+
query: string;
|
|
31
|
+
language?: string;
|
|
32
|
+
project?: string;
|
|
33
|
+
limit?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface GetInsightsParams {
|
|
36
|
+
project?: string;
|
|
37
|
+
type?: string;
|
|
38
|
+
active_only?: boolean;
|
|
39
|
+
limit?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface GetNetworkParams {
|
|
42
|
+
node_type: string;
|
|
43
|
+
node_id: number;
|
|
44
|
+
depth?: number;
|
|
45
|
+
min_weight?: number;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.types.js","sourceRoot":"","sources":["../../src/types/mcp.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type InsightType = 'pattern' | 'correlation' | 'suggestion' | 'warning' | 'optimization' | 'trend' | 'gap' | 'synergy' | 'template_candidate' | 'project_suggestion';
|
|
2
|
+
export interface InsightRecord {
|
|
3
|
+
id: number;
|
|
4
|
+
type: InsightType;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
evidence: string;
|
|
8
|
+
priority: number;
|
|
9
|
+
project_id: number | null;
|
|
10
|
+
active: number;
|
|
11
|
+
expires_at: string | null;
|
|
12
|
+
created_at: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ResearchCycleResult {
|
|
15
|
+
insightsGenerated: number;
|
|
16
|
+
patternsFound: number;
|
|
17
|
+
correlationsFound: number;
|
|
18
|
+
duration: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ProjectTemplateSuggestion {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
basedOn: string[];
|
|
24
|
+
confidence: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research.types.js","sourceRoot":"","sources":["../../src/types/research.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SolutionRecord {
|
|
2
|
+
id: number;
|
|
3
|
+
description: string;
|
|
4
|
+
commands: string | null;
|
|
5
|
+
code_change: string | null;
|
|
6
|
+
source: string;
|
|
7
|
+
confidence: number;
|
|
8
|
+
success_count: number;
|
|
9
|
+
fail_count: number;
|
|
10
|
+
created_at: string;
|
|
11
|
+
updated_at: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ErrorSolution {
|
|
14
|
+
id: number;
|
|
15
|
+
error_id: number;
|
|
16
|
+
solution_id: number;
|
|
17
|
+
applied_at: string | null;
|
|
18
|
+
success: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface SolutionAttempt {
|
|
21
|
+
id: number;
|
|
22
|
+
error_solution_id: number;
|
|
23
|
+
terminal_id: number | null;
|
|
24
|
+
attempted_at: string;
|
|
25
|
+
success: number;
|
|
26
|
+
output: string | null;
|
|
27
|
+
duration_ms: number | null;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solution.types.js","sourceRoot":"","sources":["../../src/types/solution.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type NodeType = 'error' | 'solution' | 'code_module' | 'rule' | 'antipattern' | 'project' | 'insight';
|
|
2
|
+
export type SynapseType = 'solves' | 'causes' | 'similar_to' | 'uses_module' | 'derived_from' | 'co_occurs' | 'prevents' | 'improves' | 'generalizes' | 'cross_project';
|
|
3
|
+
export interface SynapseRecord {
|
|
4
|
+
id: number;
|
|
5
|
+
source_type: NodeType;
|
|
6
|
+
source_id: number;
|
|
7
|
+
target_type: NodeType;
|
|
8
|
+
target_id: number;
|
|
9
|
+
synapse_type: SynapseType;
|
|
10
|
+
weight: number;
|
|
11
|
+
activation_count: number;
|
|
12
|
+
last_activated_at: string;
|
|
13
|
+
metadata: string | null;
|
|
14
|
+
created_at: string;
|
|
15
|
+
updated_at: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ActivationResult {
|
|
18
|
+
nodeType: NodeType;
|
|
19
|
+
nodeId: number;
|
|
20
|
+
activationStrength: number;
|
|
21
|
+
path: SynapsePath;
|
|
22
|
+
}
|
|
23
|
+
export interface SynapsePath {
|
|
24
|
+
nodes: Array<{
|
|
25
|
+
type: NodeType;
|
|
26
|
+
id: number;
|
|
27
|
+
}>;
|
|
28
|
+
totalWeight: number;
|
|
29
|
+
hops: number;
|
|
30
|
+
}
|
|
31
|
+
export interface NetworkStats {
|
|
32
|
+
totalNodes: number;
|
|
33
|
+
totalSynapses: number;
|
|
34
|
+
avgWeight: number;
|
|
35
|
+
nodesByType: Record<NodeType, number>;
|
|
36
|
+
synapsesByType: Record<SynapseType, number>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synapse.types.js","sourceRoot":"","sources":["../../src/types/synapse.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
export interface BrainEvents {
|
|
3
|
+
'error:reported': {
|
|
4
|
+
errorId: number;
|
|
5
|
+
projectId: number;
|
|
6
|
+
fingerprint: string;
|
|
7
|
+
};
|
|
8
|
+
'error:resolved': {
|
|
9
|
+
errorId: number;
|
|
10
|
+
solutionId: number;
|
|
11
|
+
};
|
|
12
|
+
'solution:applied': {
|
|
13
|
+
errorId: number;
|
|
14
|
+
solutionId: number;
|
|
15
|
+
success: boolean;
|
|
16
|
+
};
|
|
17
|
+
'solution:created': {
|
|
18
|
+
solutionId: number;
|
|
19
|
+
};
|
|
20
|
+
'module:registered': {
|
|
21
|
+
moduleId: number;
|
|
22
|
+
projectId: number;
|
|
23
|
+
};
|
|
24
|
+
'module:updated': {
|
|
25
|
+
moduleId: number;
|
|
26
|
+
};
|
|
27
|
+
'synapse:created': {
|
|
28
|
+
synapseId: number;
|
|
29
|
+
sourceType: string;
|
|
30
|
+
targetType: string;
|
|
31
|
+
};
|
|
32
|
+
'synapse:strengthened': {
|
|
33
|
+
synapseId: number;
|
|
34
|
+
newWeight: number;
|
|
35
|
+
};
|
|
36
|
+
'insight:created': {
|
|
37
|
+
insightId: number;
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
'rule:learned': {
|
|
41
|
+
ruleId: number;
|
|
42
|
+
pattern: string;
|
|
43
|
+
};
|
|
44
|
+
'terminal:connected': {
|
|
45
|
+
terminalId: number;
|
|
46
|
+
uuid: string;
|
|
47
|
+
};
|
|
48
|
+
'terminal:disconnected': {
|
|
49
|
+
terminalId: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export type BrainEventName = keyof BrainEvents;
|
|
53
|
+
export declare class TypedEventBus extends EventEmitter {
|
|
54
|
+
emit<K extends BrainEventName>(event: K, data: BrainEvents[K]): boolean;
|
|
55
|
+
on<K extends BrainEventName>(event: K, listener: (data: BrainEvents[K]) => void): this;
|
|
56
|
+
once<K extends BrainEventName>(event: K, listener: (data: BrainEvents[K]) => void): this;
|
|
57
|
+
off<K extends BrainEventName>(event: K, listener: (data: BrainEvents[K]) => void): this;
|
|
58
|
+
}
|
|
59
|
+
export declare function getEventBus(): TypedEventBus;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
export class TypedEventBus extends EventEmitter {
|
|
3
|
+
emit(event, data) {
|
|
4
|
+
return super.emit(event, data);
|
|
5
|
+
}
|
|
6
|
+
on(event, listener) {
|
|
7
|
+
return super.on(event, listener);
|
|
8
|
+
}
|
|
9
|
+
once(event, listener) {
|
|
10
|
+
return super.once(event, listener);
|
|
11
|
+
}
|
|
12
|
+
off(event, listener) {
|
|
13
|
+
return super.off(event, listener);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
let busInstance = null;
|
|
17
|
+
export function getEventBus() {
|
|
18
|
+
if (!busInstance) {
|
|
19
|
+
busInstance = new TypedEventBus();
|
|
20
|
+
}
|
|
21
|
+
return busInstance;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmB3C,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C,IAAI,CAA2B,KAAQ,EAAE,IAAoB;QAC3D,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,EAAE,CAA2B,KAAQ,EAAE,QAAwC;QAC7E,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAA2B,KAAQ,EAAE,QAAwC;QAC/E,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,GAAG,CAA2B,KAAQ,EAAE,QAAwC;QAC9E,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;CACF;AAED,IAAI,WAAW,GAAyB,IAAI,CAAC;AAE7C,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,aAAa,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sha256(input: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC"}
|