symbiote-cli 0.1.1 → 0.1.3
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/README.md +4 -3
- package/dist/bin/symbiote.js +0 -0
- package/dist/src/brain/health/constraint-checker.d.ts +2 -4
- package/dist/src/brain/health/constraint-checker.d.ts.map +1 -1
- package/dist/src/brain/health/constraint-checker.js +2 -9
- package/dist/src/brain/health/constraint-checker.js.map +1 -1
- package/dist/src/brain/health/coupling-analyzer.d.ts +1 -4
- package/dist/src/brain/health/coupling-analyzer.d.ts.map +1 -1
- package/dist/src/brain/health/coupling-analyzer.js +3 -6
- package/dist/src/brain/health/coupling-analyzer.js.map +1 -1
- package/dist/src/brain/health/cycle-detector.d.ts +2 -4
- package/dist/src/brain/health/cycle-detector.d.ts.map +1 -1
- package/dist/src/brain/health/cycle-detector.js +33 -48
- package/dist/src/brain/health/cycle-detector.js.map +1 -1
- package/dist/src/brain/health/dead-code-detector.d.ts +1 -4
- package/dist/src/brain/health/dead-code-detector.d.ts.map +1 -1
- package/dist/src/brain/health/dead-code-detector.js +13 -17
- package/dist/src/brain/health/dead-code-detector.js.map +1 -1
- package/dist/src/brain/health/index.d.ts +5 -9
- package/dist/src/brain/health/index.d.ts.map +1 -1
- package/dist/src/brain/health/index.js +56 -19
- package/dist/src/brain/health/index.js.map +1 -1
- package/dist/src/brain/intent.d.ts +2 -0
- package/dist/src/brain/intent.d.ts.map +1 -1
- package/dist/src/brain/intent.js.map +1 -1
- package/dist/src/brain/metrics.d.ts +45 -0
- package/dist/src/brain/metrics.d.ts.map +1 -0
- package/dist/src/brain/metrics.js +136 -0
- package/dist/src/brain/metrics.js.map +1 -0
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +16 -31
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +14 -3
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/serve.d.ts.map +1 -1
- package/dist/src/commands/serve.js +2 -12
- package/dist/src/commands/serve.js.map +1 -1
- package/dist/src/commands/shared.d.ts +1 -0
- package/dist/src/commands/shared.d.ts.map +1 -1
- package/dist/src/commands/shared.js +34 -0
- package/dist/src/commands/shared.js.map +1 -1
- package/dist/src/core/search.d.ts +1 -0
- package/dist/src/core/search.d.ts.map +1 -1
- package/dist/src/core/search.js +18 -7
- package/dist/src/core/search.js.map +1 -1
- package/dist/src/cortex/repository.d.ts +2 -25
- package/dist/src/cortex/repository.d.ts.map +1 -1
- package/dist/src/cortex/repository.js +1 -112
- package/dist/src/cortex/repository.js.map +1 -1
- package/dist/src/cortex/schema.js +12 -12
- package/dist/src/dna/engine.d.ts +1 -1
- package/dist/src/dna/engine.d.ts.map +1 -1
- package/dist/src/dna/engine.js +4 -4
- package/dist/src/dna/engine.js.map +1 -1
- package/dist/src/dna/types.d.ts +1 -0
- package/dist/src/dna/types.d.ts.map +1 -1
- package/dist/src/dna/types.js +4 -0
- package/dist/src/dna/types.js.map +1 -1
- package/dist/src/events/types.d.ts +1 -1
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/events/types.js +4 -10
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/hooks/attention.d.ts +19 -2
- package/dist/src/hooks/attention.d.ts.map +1 -1
- package/dist/src/hooks/attention.js +67 -5
- package/dist/src/hooks/attention.js.map +1 -1
- package/dist/src/hooks/dna-checker.d.ts +3 -0
- package/dist/src/hooks/dna-checker.d.ts.map +1 -0
- package/dist/src/hooks/dna-checker.js +22 -0
- package/dist/src/hooks/dna-checker.js.map +1 -0
- package/dist/src/hooks/handlers/post-tool-use.d.ts +14 -0
- package/dist/src/hooks/handlers/post-tool-use.d.ts.map +1 -1
- package/dist/src/hooks/handlers/post-tool-use.js +139 -9
- package/dist/src/hooks/handlers/post-tool-use.js.map +1 -1
- package/dist/src/hooks/handlers/pre-tool-use.d.ts +21 -0
- package/dist/src/hooks/handlers/pre-tool-use.d.ts.map +1 -1
- package/dist/src/hooks/handlers/pre-tool-use.js +167 -6
- package/dist/src/hooks/handlers/pre-tool-use.js.map +1 -1
- package/dist/src/hooks/handlers/session-start.d.ts +12 -4
- package/dist/src/hooks/handlers/session-start.d.ts.map +1 -1
- package/dist/src/hooks/handlers/session-start.js +80 -25
- package/dist/src/hooks/handlers/session-start.js.map +1 -1
- package/dist/src/hooks/handlers/user-prompt-submit.d.ts +8 -6
- package/dist/src/hooks/handlers/user-prompt-submit.d.ts.map +1 -1
- package/dist/src/hooks/handlers/user-prompt-submit.js +45 -20
- package/dist/src/hooks/handlers/user-prompt-submit.js.map +1 -1
- package/dist/src/hooks/symbol-cache.d.ts +18 -0
- package/dist/src/hooks/symbol-cache.d.ts.map +1 -0
- package/dist/src/hooks/symbol-cache.js +23 -0
- package/dist/src/hooks/symbol-cache.js.map +1 -0
- package/dist/src/init/agent-connector.d.ts +4 -0
- package/dist/src/init/agent-connector.d.ts.map +1 -1
- package/dist/src/init/agent-connector.js +13 -11
- package/dist/src/init/agent-connector.js.map +1 -1
- package/dist/src/mcp/context.d.ts +15 -0
- package/dist/src/mcp/context.d.ts.map +1 -1
- package/dist/src/mcp/context.js +55 -1
- package/dist/src/mcp/context.js.map +1 -1
- package/dist/src/mcp/http-api.d.ts.map +1 -1
- package/dist/src/mcp/http-api.js +27 -6
- package/dist/src/mcp/http-api.js.map +1 -1
- package/dist/src/mcp/proxy-handler.d.ts +4 -0
- package/dist/src/mcp/proxy-handler.d.ts.map +1 -0
- package/dist/src/mcp/proxy-handler.js +129 -0
- package/dist/src/mcp/proxy-handler.js.map +1 -0
- package/dist/src/mcp/proxy-server.d.ts +5 -0
- package/dist/src/mcp/proxy-server.d.ts.map +1 -0
- package/dist/src/mcp/proxy-server.js +206 -0
- package/dist/src/mcp/proxy-server.js.map +1 -0
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +32 -20
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools/dna-tools.d.ts +1 -0
- package/dist/src/mcp/tools/dna-tools.d.ts.map +1 -1
- package/dist/src/mcp/tools/dna-tools.js +5 -1
- package/dist/src/mcp/tools/dna-tools.js.map +1 -1
- package/dist/src/mcp/tools/trace-tools.d.ts +34 -0
- package/dist/src/mcp/tools/trace-tools.d.ts.map +1 -1
- package/dist/src/mcp/tools/trace-tools.js +6 -6
- package/dist/src/mcp/tools/trace-tools.js.map +1 -1
- package/dist/src/storage/repository.d.ts +1 -0
- package/dist/src/storage/repository.d.ts.map +1 -1
- package/dist/src/storage/repository.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/LICENSE +0 -21
- package/dist/bin/synapse.d.ts +0 -3
- package/dist/bin/synapse.d.ts.map +0 -1
- package/dist/bin/synapse.js +0 -369
- package/dist/bin/synapse.js.map +0 -1
- package/dist/src/brain/embeddings.d.ts +0 -9
- package/dist/src/brain/embeddings.d.ts.map +0 -1
- package/dist/src/brain/embeddings.js +0 -24
- package/dist/src/brain/embeddings.js.map +0 -1
- package/dist/src/brain/health.d.ts +0 -30
- package/dist/src/brain/health.d.ts.map +0 -1
- package/dist/src/brain/health.js +0 -147
- package/dist/src/brain/health.js.map +0 -1
- package/dist/src/commands/init.d.ts +0 -2
- package/dist/src/commands/init.d.ts.map +0 -1
- package/dist/src/commands/init.js +0 -132
- package/dist/src/commands/init.js.map +0 -1
- package/dist/src/hooks/post-tool-use.d.ts +0 -12
- package/dist/src/hooks/post-tool-use.d.ts.map +0 -1
- package/dist/src/hooks/post-tool-use.js +0 -33
- package/dist/src/hooks/post-tool-use.js.map +0 -1
- package/dist/src/hooks/pre-tool-use.d.ts +0 -24
- package/dist/src/hooks/pre-tool-use.d.ts.map +0 -1
- package/dist/src/hooks/pre-tool-use.js +0 -117
- package/dist/src/hooks/pre-tool-use.js.map +0 -1
- package/dist/src/init/dna-bootstrap.d.ts +0 -10
- package/dist/src/init/dna-bootstrap.d.ts.map +0 -1
- package/dist/src/init/dna-bootstrap.js +0 -32
- package/dist/src/init/dna-bootstrap.js.map +0 -1
- package/dist/src/init/index.d.ts +0 -29
- package/dist/src/init/index.d.ts.map +0 -1
- package/dist/src/init/index.js +0 -81
- package/dist/src/init/index.js.map +0 -1
- package/dist/src/init/overview-generator.d.ts +0 -5
- package/dist/src/init/overview-generator.d.ts.map +0 -1
- package/dist/src/init/overview-generator.js +0 -85
- package/dist/src/init/overview-generator.js.map +0 -1
- package/dist/src/init/parsers/eslint-config.d.ts +0 -10
- package/dist/src/init/parsers/eslint-config.d.ts.map +0 -1
- package/dist/src/init/parsers/eslint-config.js +0 -50
- package/dist/src/init/parsers/eslint-config.js.map +0 -1
- package/dist/src/init/parsers/markdown-rules.d.ts +0 -3
- package/dist/src/init/parsers/markdown-rules.d.ts.map +0 -1
- package/dist/src/init/parsers/markdown-rules.js +0 -90
- package/dist/src/init/parsers/markdown-rules.js.map +0 -1
- package/dist/src/init/parsers/package-json.d.ts +0 -17
- package/dist/src/init/parsers/package-json.d.ts.map +0 -1
- package/dist/src/init/parsers/package-json.js +0 -75
- package/dist/src/init/parsers/package-json.js.map +0 -1
- package/dist/src/init/parsers/prettier-config.d.ts +0 -16
- package/dist/src/init/parsers/prettier-config.d.ts.map +0 -1
- package/dist/src/init/parsers/prettier-config.js +0 -30
- package/dist/src/init/parsers/prettier-config.js.map +0 -1
- package/dist/src/init/parsers/tsconfig.d.ts +0 -32
- package/dist/src/init/parsers/tsconfig.d.ts.map +0 -1
- package/dist/src/init/parsers/tsconfig.js +0 -64
- package/dist/src/init/parsers/tsconfig.js.map +0 -1
- package/dist/src/init/parsers/types.d.ts +0 -27
- package/dist/src/init/parsers/types.d.ts.map +0 -1
- package/dist/src/init/parsers/types.js +0 -2
- package/dist/src/init/parsers/types.js.map +0 -1
- package/dist/src/init/project-analyzer.d.ts +0 -3
- package/dist/src/init/project-analyzer.d.ts.map +0 -1
- package/dist/src/init/project-analyzer.js +0 -102
- package/dist/src/init/project-analyzer.js.map +0 -1
- package/dist/src/init/rule-importer.d.ts +0 -3
- package/dist/src/init/rule-importer.d.ts.map +0 -1
- package/dist/src/init/rule-importer.js +0 -101
- package/dist/src/init/rule-importer.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "symbiote-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Symbiote bonds with your AI tools — giving them memory, context, and your coding DNA.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/node": "^22.0.0",
|
|
74
74
|
"typescript": "^5.7.0",
|
|
75
|
-
"vite-tsconfig-paths": "^6.1.1",
|
|
76
75
|
"vitest": "^3.0.0"
|
|
77
76
|
},
|
|
78
77
|
"keywords": [
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Mohamed Ashraf
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/bin/synapse.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synapse.d.ts","sourceRoot":"","sources":["../../bin/synapse.ts"],"names":[],"mappings":""}
|
package/dist/bin/synapse.js
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { Command } from 'commander';
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const MIME_TYPES = {
|
|
8
|
-
'.html': 'text/html',
|
|
9
|
-
'.js': 'application/javascript',
|
|
10
|
-
'.css': 'text/css',
|
|
11
|
-
'.json': 'application/json',
|
|
12
|
-
'.png': 'image/png',
|
|
13
|
-
'.svg': 'image/svg+xml',
|
|
14
|
-
'.ico': 'image/x-icon',
|
|
15
|
-
'.woff2': 'font/woff2',
|
|
16
|
-
'.woff': 'font/woff',
|
|
17
|
-
'.map': 'application/json',
|
|
18
|
-
};
|
|
19
|
-
function serveStatic(webDistDir, pathname, res) {
|
|
20
|
-
const safePath = path
|
|
21
|
-
.normalize(pathname)
|
|
22
|
-
.replace(/^(\.\.[/\\])+/, '');
|
|
23
|
-
let filePath = path.join(webDistDir, safePath);
|
|
24
|
-
if (!fs.existsSync(filePath) ||
|
|
25
|
-
fs.statSync(filePath).isDirectory()) {
|
|
26
|
-
filePath = path.join(webDistDir, 'index.html');
|
|
27
|
-
}
|
|
28
|
-
if (!fs.existsSync(filePath))
|
|
29
|
-
return false;
|
|
30
|
-
const ext = path.extname(filePath);
|
|
31
|
-
const contentType = MIME_TYPES[ext] ?? 'application/octet-stream';
|
|
32
|
-
res.writeHead(200, { 'Content-Type': contentType });
|
|
33
|
-
fs.createReadStream(filePath).pipe(res);
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
import { createDatabase } from '../src/storage/db.js';
|
|
37
|
-
import { Repository } from '../src/storage/repository.js';
|
|
38
|
-
import { Scanner } from '../src/core/scanner.js';
|
|
39
|
-
import { ensureBrainDir, ensureSynapseHome, getBrainDbPath, } from '../src/utils/config.js';
|
|
40
|
-
import { DnaStorage } from '../src/dna/storage.js';
|
|
41
|
-
import { DnaEngine } from '../src/dna/engine.js';
|
|
42
|
-
import { createMcpServer } from '../src/mcp/server.js';
|
|
43
|
-
import { createServerContext } from '../src/mcp/context.js';
|
|
44
|
-
import { handleApiRequest } from '../src/mcp/http-api.js';
|
|
45
|
-
const program = new Command();
|
|
46
|
-
program
|
|
47
|
-
.name('synapse')
|
|
48
|
-
.description('AI-powered project brain — a living, queryable knowledge layer for your codebase')
|
|
49
|
-
.version('0.1.0');
|
|
50
|
-
program
|
|
51
|
-
.command('init')
|
|
52
|
-
.description('Initialize Synapse for the current project')
|
|
53
|
-
.action(async () => {
|
|
54
|
-
const { SmartInit } = await import('../src/init/index.js');
|
|
55
|
-
const projectRoot = process.cwd();
|
|
56
|
-
console.log(`Initializing Synapse in ${projectRoot}...`);
|
|
57
|
-
const synapseHome = ensureSynapseHome();
|
|
58
|
-
const brainDir = ensureBrainDir(projectRoot);
|
|
59
|
-
const dbPath = getBrainDbPath(projectRoot);
|
|
60
|
-
const db = createDatabase(dbPath);
|
|
61
|
-
const repo = new Repository(db);
|
|
62
|
-
const scanner = new Scanner(repo);
|
|
63
|
-
console.log('Scanning codebase...');
|
|
64
|
-
const scanResult = await scanner.scan(projectRoot);
|
|
65
|
-
console.log('Analyzing project...');
|
|
66
|
-
const init = new SmartInit({
|
|
67
|
-
projectRoot,
|
|
68
|
-
synapseHome,
|
|
69
|
-
brainDir,
|
|
70
|
-
scanResult,
|
|
71
|
-
});
|
|
72
|
-
const result = init.run();
|
|
73
|
-
db.close();
|
|
74
|
-
console.log('');
|
|
75
|
-
console.log('Synapse initialized successfully.');
|
|
76
|
-
console.log('');
|
|
77
|
-
console.log(` Brain: ${scanResult.nodesCreated} nodes, ${scanResult.edgesCreated} edges`);
|
|
78
|
-
console.log(` Files scanned: ${scanResult.filesScanned}`);
|
|
79
|
-
console.log(` Rules imported: ${result.rulesImported}`);
|
|
80
|
-
console.log(` Intent entries: ${result.intentEntriesCreated} constraints/decisions`);
|
|
81
|
-
console.log(` DNA entries: ${result.dnaEntriesLoaded} loaded, ${result.dnaEntriesImported} imported`);
|
|
82
|
-
console.log(` Tech stack: ${result.techStack.map((t) => t.name).join(', ') || 'none detected'}`);
|
|
83
|
-
console.log('');
|
|
84
|
-
if (result.architectureSignals.length > 0) {
|
|
85
|
-
console.log(' Architecture:');
|
|
86
|
-
for (const signal of result.architectureSignals.slice(0, 5)) {
|
|
87
|
-
console.log(` - ${signal.pattern}`);
|
|
88
|
-
}
|
|
89
|
-
console.log('');
|
|
90
|
-
}
|
|
91
|
-
if (scanResult.errors.length > 0) {
|
|
92
|
-
console.log(` ${scanResult.errors.length} files had parse errors.`);
|
|
93
|
-
}
|
|
94
|
-
console.log("Run 'synapse serve' to start the MCP server and web UI.");
|
|
95
|
-
});
|
|
96
|
-
program
|
|
97
|
-
.command('scan')
|
|
98
|
-
.description('Scan the codebase and rebuild the project graph')
|
|
99
|
-
.option('-f, --force', 'Force full rescan (ignore file hashes)')
|
|
100
|
-
.action(async (options) => {
|
|
101
|
-
const projectRoot = process.cwd();
|
|
102
|
-
const dbPath = getBrainDbPath(projectRoot);
|
|
103
|
-
const db = createDatabase(dbPath);
|
|
104
|
-
const repo = new Repository(db);
|
|
105
|
-
const scanner = new Scanner(repo);
|
|
106
|
-
console.log('Scanning codebase...');
|
|
107
|
-
const result = await scanner.scan(projectRoot, {
|
|
108
|
-
force: options.force,
|
|
109
|
-
});
|
|
110
|
-
db.close();
|
|
111
|
-
console.log(`Done. Scanned: ${result.filesScanned}, ` +
|
|
112
|
-
`Skipped: ${result.filesSkipped}, ` +
|
|
113
|
-
`Nodes: ${result.nodesCreated}, Edges: ${result.edgesCreated}`);
|
|
114
|
-
});
|
|
115
|
-
program
|
|
116
|
-
.command('serve')
|
|
117
|
-
.description('Start MCP server and web UI')
|
|
118
|
-
.option('-p, --port <number>', 'HTTP port', '3333')
|
|
119
|
-
.action(async (options) => {
|
|
120
|
-
const { SSEServerTransport } = await import('@modelcontextprotocol/sdk/server/sse.js');
|
|
121
|
-
const http = await import('node:http');
|
|
122
|
-
const projectRoot = process.cwd();
|
|
123
|
-
const brainDir = ensureBrainDir(projectRoot);
|
|
124
|
-
const synapseHome = ensureSynapseHome();
|
|
125
|
-
const dbPath = getBrainDbPath(projectRoot);
|
|
126
|
-
const db = createDatabase(dbPath);
|
|
127
|
-
const ctx = createServerContext({
|
|
128
|
-
db,
|
|
129
|
-
brainDir,
|
|
130
|
-
synapseHome,
|
|
131
|
-
});
|
|
132
|
-
const { server } = createMcpServer(ctx);
|
|
133
|
-
const port = parseInt(options.port, 10);
|
|
134
|
-
const transports = new Map();
|
|
135
|
-
const httpServer = http.createServer(async (req, res) => {
|
|
136
|
-
const url = new URL(req.url ?? '/', `http://localhost:${port}`);
|
|
137
|
-
if (url.pathname === '/sse' && req.method === 'GET') {
|
|
138
|
-
const transport = new SSEServerTransport('/messages', res);
|
|
139
|
-
transports.set(transport.sessionId, transport);
|
|
140
|
-
await server.connect(transport);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (url.pathname === '/messages' &&
|
|
144
|
-
req.method === 'POST') {
|
|
145
|
-
const sessionId = url.searchParams.get('sessionId');
|
|
146
|
-
const transport = sessionId
|
|
147
|
-
? transports.get(sessionId)
|
|
148
|
-
: undefined;
|
|
149
|
-
if (!transport) {
|
|
150
|
-
res.writeHead(404);
|
|
151
|
-
res.end('Session not found');
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
await transport.handlePostMessage(req, res);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (url.pathname === '/health') {
|
|
158
|
-
res.writeHead(200, {
|
|
159
|
-
'Content-Type': 'application/json',
|
|
160
|
-
});
|
|
161
|
-
res.end(JSON.stringify({ status: 'ok' }));
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (url.pathname.startsWith('/api/')) {
|
|
165
|
-
if (handleApiRequest(ctx, url.pathname, req, res))
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const webDistDir = path.resolve(__dirname, '../../../web/dist');
|
|
169
|
-
if (fs.existsSync(webDistDir)) {
|
|
170
|
-
if (serveStatic(webDistDir, url.pathname, res))
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
res.writeHead(404);
|
|
174
|
-
res.end('Not found');
|
|
175
|
-
});
|
|
176
|
-
httpServer.listen(port, () => {
|
|
177
|
-
console.log(`Synapse server running on http://localhost:${port}`);
|
|
178
|
-
console.log(`MCP SSE endpoint: http://localhost:${port}/sse`);
|
|
179
|
-
console.log(`Health check: http://localhost:${port}/health`);
|
|
180
|
-
});
|
|
181
|
-
process.on('SIGINT', () => {
|
|
182
|
-
httpServer.close();
|
|
183
|
-
db.close();
|
|
184
|
-
process.exit(0);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
program
|
|
188
|
-
.command('mcp')
|
|
189
|
-
.description('Start MCP server only (stdio, for editor integration)')
|
|
190
|
-
.action(async () => {
|
|
191
|
-
const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
|
|
192
|
-
const projectRoot = process.cwd();
|
|
193
|
-
const brainDir = ensureBrainDir(projectRoot);
|
|
194
|
-
const synapseHome = ensureSynapseHome();
|
|
195
|
-
const dbPath = getBrainDbPath(projectRoot);
|
|
196
|
-
const db = createDatabase(dbPath);
|
|
197
|
-
const ctx = createServerContext({
|
|
198
|
-
db,
|
|
199
|
-
brainDir,
|
|
200
|
-
synapseHome,
|
|
201
|
-
});
|
|
202
|
-
const { server } = createMcpServer(ctx);
|
|
203
|
-
const transport = new StdioServerTransport();
|
|
204
|
-
await server.connect(transport);
|
|
205
|
-
process.on('SIGINT', () => {
|
|
206
|
-
db.close();
|
|
207
|
-
process.exit(0);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
const dnaCommand = program
|
|
211
|
-
.command('dna')
|
|
212
|
-
.description('View and manage your developer DNA');
|
|
213
|
-
dnaCommand
|
|
214
|
-
.command('list')
|
|
215
|
-
.description('List all DNA entries')
|
|
216
|
-
.option('-s, --status <status>', 'Filter by status (suggested, approved, rejected)')
|
|
217
|
-
.option('-c, --category <category>', 'Filter by category (style, preferences, anti-patterns, decisions)')
|
|
218
|
-
.action(async (options) => {
|
|
219
|
-
const synapseHome = ensureSynapseHome();
|
|
220
|
-
const dnaDir = path.join(synapseHome, 'dna');
|
|
221
|
-
const storage = new DnaStorage(dnaDir);
|
|
222
|
-
storage.ensureDirectories();
|
|
223
|
-
const entries = storage.listEntries({
|
|
224
|
-
status: options.status,
|
|
225
|
-
category: options.category,
|
|
226
|
-
});
|
|
227
|
-
if (entries.length === 0) {
|
|
228
|
-
console.log('No DNA entries found.');
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
console.log(`\nDeveloper DNA — ${entries.length} entries\n`);
|
|
232
|
-
console.log('\u2500'.repeat(70));
|
|
233
|
-
for (const entry of entries) {
|
|
234
|
-
const fm = entry.frontmatter;
|
|
235
|
-
const statusIcon = fm.status === 'approved'
|
|
236
|
-
? '[+]'
|
|
237
|
-
: fm.status === 'rejected'
|
|
238
|
-
? '[-]'
|
|
239
|
-
: '[?]';
|
|
240
|
-
console.log(`${statusIcon} ${fm.id} (${fm.category}, confidence: ${fm.confidence}, occurrences: ${fm.occurrences})`);
|
|
241
|
-
console.log(` ${entry.content.slice(0, 100)}${entry.content.length > 100 ? '...' : ''}`);
|
|
242
|
-
console.log('\u2500'.repeat(70));
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
dnaCommand
|
|
246
|
-
.command('approve <id>')
|
|
247
|
-
.description('Approve a suggested DNA entry')
|
|
248
|
-
.action(async (id) => {
|
|
249
|
-
const synapseHome = ensureSynapseHome();
|
|
250
|
-
const dnaDir = path.join(synapseHome, 'dna');
|
|
251
|
-
const storage = new DnaStorage(dnaDir);
|
|
252
|
-
storage.ensureDirectories();
|
|
253
|
-
const engine = new DnaEngine(storage);
|
|
254
|
-
const entry = engine.approveEntry(id);
|
|
255
|
-
if (entry) {
|
|
256
|
-
console.log(`Approved: ${entry.frontmatter.id}`);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
console.log(`Entry not found: ${id}`);
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
dnaCommand
|
|
263
|
-
.command('reject <id>')
|
|
264
|
-
.description('Reject a suggested DNA entry')
|
|
265
|
-
.action(async (id) => {
|
|
266
|
-
const synapseHome = ensureSynapseHome();
|
|
267
|
-
const dnaDir = path.join(synapseHome, 'dna');
|
|
268
|
-
const storage = new DnaStorage(dnaDir);
|
|
269
|
-
storage.ensureDirectories();
|
|
270
|
-
const engine = new DnaEngine(storage);
|
|
271
|
-
const entry = engine.rejectEntry(id);
|
|
272
|
-
if (entry) {
|
|
273
|
-
console.log(`Rejected: ${entry.frontmatter.id}`);
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
console.log(`Entry not found: ${id}`);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
dnaCommand
|
|
280
|
-
.command('show <id>')
|
|
281
|
-
.description('Show a specific DNA entry')
|
|
282
|
-
.action(async (id) => {
|
|
283
|
-
const synapseHome = ensureSynapseHome();
|
|
284
|
-
const dnaDir = path.join(synapseHome, 'dna');
|
|
285
|
-
const storage = new DnaStorage(dnaDir);
|
|
286
|
-
storage.ensureDirectories();
|
|
287
|
-
const entry = storage.readEntry(id);
|
|
288
|
-
if (!entry) {
|
|
289
|
-
console.log(`Entry not found: ${id}`);
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
const fm = entry.frontmatter;
|
|
293
|
-
console.log(`\nID: ${fm.id}`);
|
|
294
|
-
console.log(`Category: ${fm.category}`);
|
|
295
|
-
console.log(`Status: ${fm.status}`);
|
|
296
|
-
console.log(`Confidence: ${fm.confidence}`);
|
|
297
|
-
console.log(`Source: ${fm.source}`);
|
|
298
|
-
console.log(`First seen: ${fm.firstSeen}`);
|
|
299
|
-
console.log(`Last seen: ${fm.lastSeen}`);
|
|
300
|
-
console.log(`Occurrences: ${fm.occurrences}`);
|
|
301
|
-
console.log(`Sessions: ${fm.sessionIds.length}`);
|
|
302
|
-
console.log(`\n${entry.content}\n`);
|
|
303
|
-
});
|
|
304
|
-
dnaCommand
|
|
305
|
-
.command('delete <id>')
|
|
306
|
-
.description('Delete a DNA entry')
|
|
307
|
-
.action(async (id) => {
|
|
308
|
-
const synapseHome = ensureSynapseHome();
|
|
309
|
-
const dnaDir = path.join(synapseHome, 'dna');
|
|
310
|
-
const storage = new DnaStorage(dnaDir);
|
|
311
|
-
storage.ensureDirectories();
|
|
312
|
-
storage.deleteEntry(id);
|
|
313
|
-
console.log(`Deleted: ${id}`);
|
|
314
|
-
});
|
|
315
|
-
dnaCommand.action(async () => {
|
|
316
|
-
const synapseHome = ensureSynapseHome();
|
|
317
|
-
const dnaDir = path.join(synapseHome, 'dna');
|
|
318
|
-
const storage = new DnaStorage(dnaDir);
|
|
319
|
-
storage.ensureDirectories();
|
|
320
|
-
const all = storage.listEntries();
|
|
321
|
-
const approved = all.filter((e) => e.frontmatter.status === 'approved');
|
|
322
|
-
const suggested = all.filter((e) => e.frontmatter.status === 'suggested');
|
|
323
|
-
const rejected = all.filter((e) => e.frontmatter.status === 'rejected');
|
|
324
|
-
console.log('\nDeveloper DNA Summary');
|
|
325
|
-
console.log('\u2500'.repeat(21));
|
|
326
|
-
console.log(`Total: ${all.length}`);
|
|
327
|
-
console.log(`Approved: ${approved.length}`);
|
|
328
|
-
console.log(`Suggested: ${suggested.length}`);
|
|
329
|
-
console.log(`Rejected: ${rejected.length}`);
|
|
330
|
-
if (suggested.length > 0) {
|
|
331
|
-
console.log('\nPending review:');
|
|
332
|
-
for (const entry of suggested) {
|
|
333
|
-
console.log(` [?] ${entry.frontmatter.id} (confidence: ${entry.frontmatter.confidence})`);
|
|
334
|
-
}
|
|
335
|
-
console.log("\nRun 'synapse dna approve <id>' or 'synapse dna reject <id>' to review.");
|
|
336
|
-
}
|
|
337
|
-
console.log();
|
|
338
|
-
});
|
|
339
|
-
program.action(async () => {
|
|
340
|
-
const { SmartInit } = await import('../src/init/index.js');
|
|
341
|
-
const projectRoot = process.cwd();
|
|
342
|
-
const synapseHome = ensureSynapseHome();
|
|
343
|
-
const brainDir = ensureBrainDir(projectRoot);
|
|
344
|
-
const dbPath = getBrainDbPath(projectRoot);
|
|
345
|
-
const db = createDatabase(dbPath);
|
|
346
|
-
const repo = new Repository(db);
|
|
347
|
-
const scanner = new Scanner(repo);
|
|
348
|
-
console.log('Scanning codebase...');
|
|
349
|
-
const scanResult = await scanner.scan(projectRoot);
|
|
350
|
-
console.log('Analyzing project...');
|
|
351
|
-
const init = new SmartInit({
|
|
352
|
-
projectRoot,
|
|
353
|
-
synapseHome,
|
|
354
|
-
brainDir,
|
|
355
|
-
scanResult,
|
|
356
|
-
});
|
|
357
|
-
const result = init.run();
|
|
358
|
-
console.log(`Synapse is ready. Brain: ${scanResult.nodesCreated} nodes, ` +
|
|
359
|
-
`${scanResult.edgesCreated} edges. ` +
|
|
360
|
-
`Rules: ${result.rulesImported} imported. ` +
|
|
361
|
-
`DNA: ${result.dnaEntriesLoaded + result.dnaEntriesImported} entries.`);
|
|
362
|
-
if (scanResult.errors.length > 0) {
|
|
363
|
-
console.log(`${scanResult.errors.length} files had errors.`);
|
|
364
|
-
}
|
|
365
|
-
console.log("Run 'synapse serve' to start the MCP server and web UI.");
|
|
366
|
-
db.close();
|
|
367
|
-
});
|
|
368
|
-
program.parse();
|
|
369
|
-
//# sourceMappingURL=synapse.js.map
|
package/dist/bin/synapse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synapse.js","sourceRoot":"","sources":["../../bin/synapse.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,UAAU,GAA2B;IACvC,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,cAAc;IACtB,QAAQ,EAAE,YAAY;IACtB,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,kBAAkB;CAC7B,CAAC;AAEF,SAAS,WAAW,CAChB,UAAkB,EAClB,QAAgB,EAChB,GAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI;SAChB,SAAS,CAAC,QAAQ,CAAC;SACnB,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE/C,IACI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QACxB,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,EACrC,CAAC;Q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AAa;QAC3C,QAAQ,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,WAAW,CAC7E,CAAC;IAEF,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CACP,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,oBAAoB,CAClD,CAAC;IACN,CAAC;IAED,OAAO,CAAC,GAAG,CACP,yDAAyD,CAC5D,CAAC;IACF,EAAE,CAAC,KAAK,EAAE,CAAC;AACf,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SymbioteDB } from '../storage/db.js';
|
|
2
|
-
export interface SearchResult {
|
|
3
|
-
nodeId: string;
|
|
4
|
-
distance: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function storeEmbedding(db: SymbioteDB, nodeId: string, vector: number[]): Promise<void>;
|
|
7
|
-
export declare function deleteEmbeddingsForFile(db: SymbioteDB, filePath: string): Promise<void>;
|
|
8
|
-
export declare function semanticSearch(db: SymbioteDB, queryVector: number[], limit?: number): Promise<SearchResult[]>;
|
|
9
|
-
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../../src/brain/embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,cAAc,CAChC,EAAE,EAAE,UAAU,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,uBAAuB,CACzC,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,cAAc,CAChC,EAAE,EAAE,UAAU,EACd,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,GAAE,MAAW,GACnB,OAAO,CAAC,YAAY,EAAE,CAAC,CAkBzB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export async function storeEmbedding(db, nodeId, vector) {
|
|
2
|
-
const arrayLiteral = `[${vector.join(',')}]`;
|
|
3
|
-
await db.run(`INSERT OR REPLACE INTO embeddings (node_id, vector) VALUES ($1, $2::FLOAT[384])`, nodeId, arrayLiteral);
|
|
4
|
-
}
|
|
5
|
-
export async function deleteEmbeddingsForFile(db, filePath) {
|
|
6
|
-
await db.run(`DELETE FROM embeddings WHERE node_id IN (
|
|
7
|
-
SELECT id FROM nodes WHERE file_path = $1
|
|
8
|
-
)`, filePath);
|
|
9
|
-
}
|
|
10
|
-
export async function semanticSearch(db, queryVector, limit = 10) {
|
|
11
|
-
const arrayLiteral = `[${queryVector.join(',')}]`;
|
|
12
|
-
const rows = await db.all(`SELECT
|
|
13
|
-
node_id,
|
|
14
|
-
array_cosine_similarity(vector, $1::FLOAT[384]) AS similarity
|
|
15
|
-
FROM embeddings
|
|
16
|
-
WHERE vector IS NOT NULL
|
|
17
|
-
ORDER BY similarity DESC
|
|
18
|
-
LIMIT $2`, arrayLiteral, limit);
|
|
19
|
-
return rows.map((r) => ({
|
|
20
|
-
nodeId: r.node_id,
|
|
21
|
-
distance: 1 - r.similarity,
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=embeddings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"embeddings.js","sourceRoot":"","sources":["../../../src/brain/embeddings.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,EAAc,EACd,MAAc,EACd,MAAgB;IAEhB,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7C,MAAM,EAAE,CAAC,GAAG,CACR,iFAAiF,EACjF,MAAM,EACN,YAAY,CACf,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,EAAc,EACd,QAAgB;IAEhB,MAAM,EAAE,CAAC,GAAG,CACR;;UAEE,EACF,QAAQ,CACX,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,EAAc,EACd,WAAqB,EACrB,QAAgB,EAAE;IAElB,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClD,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,GAAG,CACrB;;;;;;kBAMU,EACV,YAAY,EACZ,KAAK,CAC0C,CAAC;IAEpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpB,MAAM,EAAE,CAAC,CAAC,OAAO;QACjB,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU;KAC7B,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Repository, NodeRecord } from '../storage/repository.js';
|
|
2
|
-
import type { IntentStore } from './intent.js';
|
|
3
|
-
export interface HealthViolation {
|
|
4
|
-
constraintId: string;
|
|
5
|
-
description: string;
|
|
6
|
-
scope: string;
|
|
7
|
-
}
|
|
8
|
-
export interface CircularDep {
|
|
9
|
-
nodeIds: string[];
|
|
10
|
-
filePaths: string[];
|
|
11
|
-
}
|
|
12
|
-
export interface HealthReport {
|
|
13
|
-
score: number;
|
|
14
|
-
orphanFiles: string[];
|
|
15
|
-
circularDeps: CircularDep[];
|
|
16
|
-
constraintViolations: HealthViolation[];
|
|
17
|
-
deadCode: NodeRecord[];
|
|
18
|
-
}
|
|
19
|
-
export declare class HealthAnalyzer {
|
|
20
|
-
private repo;
|
|
21
|
-
private intent;
|
|
22
|
-
constructor(repo: Repository, intent: IntentStore);
|
|
23
|
-
analyze(): HealthReport;
|
|
24
|
-
private findOrphanFiles;
|
|
25
|
-
private findCircularDeps;
|
|
26
|
-
private checkConstraints;
|
|
27
|
-
private findDeadCode;
|
|
28
|
-
private computeScore;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=health.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/brain/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,oBAAoB,EAAE,eAAe,EAAE,CAAC;IACxC,QAAQ,EAAE,UAAU,EAAE,CAAC;CAC1B;AAOD,qBAAa,cAAc;IAEnB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,WAAW;IAG/B,OAAO,IAAI,YAAY;IAsBvB,OAAO,CAAC,eAAe;IAyCvB,OAAO,CAAC,gBAAgB;IAkExB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,YAAY;CAiCvB"}
|
package/dist/src/brain/health.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
const WEIGHT_CONSTRAINTS = 0.4;
|
|
2
|
-
const WEIGHT_CIRCULAR = 0.2;
|
|
3
|
-
const WEIGHT_DEAD_CODE = 0.2;
|
|
4
|
-
const WEIGHT_COUPLING = 0.2;
|
|
5
|
-
export class HealthAnalyzer {
|
|
6
|
-
repo;
|
|
7
|
-
intent;
|
|
8
|
-
constructor(repo, intent) {
|
|
9
|
-
this.repo = repo;
|
|
10
|
-
this.intent = intent;
|
|
11
|
-
}
|
|
12
|
-
analyze() {
|
|
13
|
-
const orphanFiles = this.findOrphanFiles();
|
|
14
|
-
const circularDeps = this.findCircularDeps();
|
|
15
|
-
const constraintViolations = this.checkConstraints();
|
|
16
|
-
const deadCode = this.findDeadCode();
|
|
17
|
-
const score = this.computeScore(orphanFiles, circularDeps, constraintViolations, deadCode);
|
|
18
|
-
return {
|
|
19
|
-
score,
|
|
20
|
-
orphanFiles,
|
|
21
|
-
circularDeps,
|
|
22
|
-
constraintViolations,
|
|
23
|
-
deadCode,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
findOrphanFiles() {
|
|
27
|
-
const stats = this.repo.getStats();
|
|
28
|
-
if (stats.nodes === 0)
|
|
29
|
-
return [];
|
|
30
|
-
const allFiles = new Set();
|
|
31
|
-
const importedFiles = new Set();
|
|
32
|
-
const allNodes = this.repo.getAllNodes();
|
|
33
|
-
for (const node of allNodes) {
|
|
34
|
-
allFiles.add(node.filePath);
|
|
35
|
-
}
|
|
36
|
-
const allEdges = this.repo.getAllEdges();
|
|
37
|
-
for (const edge of allEdges) {
|
|
38
|
-
if (edge.type === 'imports') {
|
|
39
|
-
const match = edge.targetId.match(/^file:(.+)$/);
|
|
40
|
-
if (match)
|
|
41
|
-
importedFiles.add(match[1]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const orphans = [];
|
|
45
|
-
for (const file of allFiles) {
|
|
46
|
-
const hasIncoming = allEdges.some((e) => {
|
|
47
|
-
const targetNode = this.repo.getNodeById(e.targetId);
|
|
48
|
-
return (targetNode &&
|
|
49
|
-
targetNode.filePath === file &&
|
|
50
|
-
e.sourceId !== e.targetId);
|
|
51
|
-
});
|
|
52
|
-
const isImported = importedFiles.has(file);
|
|
53
|
-
if (!hasIncoming && !isImported) {
|
|
54
|
-
orphans.push(file);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return orphans;
|
|
58
|
-
}
|
|
59
|
-
findCircularDeps() {
|
|
60
|
-
const cycles = [];
|
|
61
|
-
const allEdges = this.repo.getAllEdges();
|
|
62
|
-
const adjacency = new Map();
|
|
63
|
-
for (const edge of allEdges) {
|
|
64
|
-
if (!adjacency.has(edge.sourceId)) {
|
|
65
|
-
adjacency.set(edge.sourceId, []);
|
|
66
|
-
}
|
|
67
|
-
adjacency.get(edge.sourceId).push(edge.targetId);
|
|
68
|
-
}
|
|
69
|
-
const visited = new Set();
|
|
70
|
-
const inStack = new Set();
|
|
71
|
-
const dfs = (nodeId, nodePath) => {
|
|
72
|
-
if (inStack.has(nodeId)) {
|
|
73
|
-
const cycleStart = nodePath.indexOf(nodeId);
|
|
74
|
-
if (cycleStart >= 0) {
|
|
75
|
-
const cycleIds = nodePath.slice(cycleStart);
|
|
76
|
-
const filePaths = [
|
|
77
|
-
...new Set(cycleIds
|
|
78
|
-
.map((id) => this.repo.getNodeById(id))
|
|
79
|
-
.filter((n) => n !== undefined)
|
|
80
|
-
.map((n) => n.filePath)),
|
|
81
|
-
];
|
|
82
|
-
if (filePaths.length > 1) {
|
|
83
|
-
cycles.push({
|
|
84
|
-
nodeIds: cycleIds,
|
|
85
|
-
filePaths,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (visited.has(nodeId))
|
|
92
|
-
return;
|
|
93
|
-
visited.add(nodeId);
|
|
94
|
-
inStack.add(nodeId);
|
|
95
|
-
const neighbors = adjacency.get(nodeId) ?? [];
|
|
96
|
-
for (const neighbor of neighbors) {
|
|
97
|
-
dfs(neighbor, [...nodePath, nodeId]);
|
|
98
|
-
}
|
|
99
|
-
inStack.delete(nodeId);
|
|
100
|
-
};
|
|
101
|
-
for (const nodeId of adjacency.keys()) {
|
|
102
|
-
if (!visited.has(nodeId)) {
|
|
103
|
-
dfs(nodeId, []);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return cycles;
|
|
107
|
-
}
|
|
108
|
-
checkConstraints() {
|
|
109
|
-
const constraints = this.intent.listEntries('constraint', {
|
|
110
|
-
status: 'active',
|
|
111
|
-
});
|
|
112
|
-
return constraints.map((c) => ({
|
|
113
|
-
constraintId: c.frontmatter.id,
|
|
114
|
-
description: c.content,
|
|
115
|
-
scope: c.frontmatter.scope,
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
findDeadCode() {
|
|
119
|
-
const allNodes = this.repo.getAllNodes();
|
|
120
|
-
const allEdges = this.repo.getAllEdges();
|
|
121
|
-
const referencedIds = new Set();
|
|
122
|
-
for (const edge of allEdges) {
|
|
123
|
-
referencedIds.add(edge.targetId);
|
|
124
|
-
}
|
|
125
|
-
return allNodes.filter((node) => (node.type === 'function' || node.type === 'method') &&
|
|
126
|
-
!referencedIds.has(node.id));
|
|
127
|
-
}
|
|
128
|
-
computeScore(orphanFiles, circularDeps, constraintViolations, deadCode) {
|
|
129
|
-
const constraintScore = constraintViolations.length === 0
|
|
130
|
-
? 100
|
|
131
|
-
: Math.max(0, 100 - constraintViolations.length * 20);
|
|
132
|
-
const circularScore = circularDeps.length === 0
|
|
133
|
-
? 100
|
|
134
|
-
: Math.max(0, 100 - circularDeps.length * 25);
|
|
135
|
-
const deadCodeScore = deadCode.length === 0
|
|
136
|
-
? 100
|
|
137
|
-
: Math.max(0, 100 - deadCode.length * 5);
|
|
138
|
-
const couplingScore = orphanFiles.length === 0
|
|
139
|
-
? 100
|
|
140
|
-
: Math.max(0, 100 - orphanFiles.length * 10);
|
|
141
|
-
return Math.round(constraintScore * WEIGHT_CONSTRAINTS +
|
|
142
|
-
circularScore * WEIGHT_CIRCULAR +
|
|
143
|
-
deadCodeScore * WEIGHT_DEAD_CODE +
|
|
144
|
-
couplingScore * WEIGHT_COUPLING);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=health.js.map
|