project-graph-mcp 1.5.0 → 2.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.
Files changed (121) hide show
  1. package/README.md +128 -8
  2. package/package.json +12 -8
  3. package/src/.project-graph-cache.json +1 -1
  4. package/src/analysis/analysis-cache.js +7 -0
  5. package/src/analysis/complexity.js +14 -0
  6. package/src/analysis/custom-rules.js +36 -0
  7. package/src/analysis/db-analysis.js +9 -0
  8. package/src/analysis/dead-code.js +19 -0
  9. package/src/analysis/full-analysis.js +18 -0
  10. package/src/analysis/jsdoc-checker.js +24 -0
  11. package/src/analysis/jsdoc-generator.js +10 -0
  12. package/src/analysis/large-files.js +11 -0
  13. package/src/analysis/outdated-patterns.js +12 -0
  14. package/src/analysis/similar-functions.js +16 -0
  15. package/src/analysis/test-annotations.js +21 -0
  16. package/src/analysis/type-checker.js +8 -0
  17. package/src/analysis/undocumented.js +14 -0
  18. package/src/cli/cli-handlers.js +4 -0
  19. package/src/cli/cli.js +5 -0
  20. package/src/compact/ai-context.js +7 -0
  21. package/src/compact/compact.js +18 -0
  22. package/src/compact/compress.js +13 -0
  23. package/src/compact/ctx-to-jsdoc.js +29 -0
  24. package/src/compact/doc-dialect.js +30 -0
  25. package/src/compact/expand.js +37 -0
  26. package/src/compact/framework-references.js +5 -0
  27. package/src/compact/instructions.js +3 -0
  28. package/src/compact/mode-config.js +8 -0
  29. package/src/compact/validate-pipeline.js +9 -0
  30. package/src/core/event-bus.js +9 -0
  31. package/src/core/filters.js +14 -0
  32. package/src/core/graph-builder.js +12 -0
  33. package/src/core/parser.js +31 -0
  34. package/src/core/workspace.js +8 -0
  35. package/src/lang/lang-go.js +17 -0
  36. package/src/lang/lang-python.js +12 -0
  37. package/src/lang/lang-sql.js +23 -0
  38. package/src/lang/lang-typescript.js +9 -0
  39. package/src/lang/lang-utils.js +4 -0
  40. package/src/mcp/mcp-server.js +17 -0
  41. package/src/mcp/tool-defs.js +3 -0
  42. package/src/mcp/tools.js +25 -0
  43. package/src/network/backend-lifecycle.js +19 -0
  44. package/src/network/backend.js +5 -0
  45. package/src/network/local-gateway.js +23 -0
  46. package/src/network/mdns.js +13 -0
  47. package/src/network/server.js +10 -0
  48. package/src/network/web-server.js +34 -0
  49. package/web/.project-graph-cache.json +1 -0
  50. package/web/app.js +16 -0
  51. package/web/components/code-block.js +3 -0
  52. package/web/components/quick-open.js +5 -0
  53. package/web/dashboard-state.js +3 -0
  54. package/web/dashboard.html +27 -0
  55. package/web/dashboard.js +8 -0
  56. package/web/highlight.js +13 -0
  57. package/web/index.html +35 -0
  58. package/web/panels/ActionBoard/ActionBoard.css.js +1 -0
  59. package/web/panels/ActionBoard/ActionBoard.js +4 -0
  60. package/web/panels/ActionBoard/ActionBoard.tpl.js +1 -0
  61. package/web/panels/EventItem/EventItem.css.js +1 -0
  62. package/web/panels/EventItem/EventItem.js +4 -0
  63. package/web/panels/EventItem/EventItem.tpl.js +1 -0
  64. package/web/panels/ProjectItem/ProjectItem.css.js +1 -0
  65. package/web/panels/ProjectItem/ProjectItem.js +5 -0
  66. package/web/panels/ProjectItem/ProjectItem.tpl.js +1 -0
  67. package/web/panels/ProjectList/ProjectList.css.js +1 -0
  68. package/web/panels/ProjectList/ProjectList.js +4 -0
  69. package/web/panels/ProjectList/ProjectList.tpl.js +1 -0
  70. package/web/panels/SettingsPanel/.project-graph-cache.json +1 -0
  71. package/web/panels/SettingsPanel/SettingsPanel.css.js +1 -0
  72. package/web/panels/SettingsPanel/SettingsPanel.js +7 -0
  73. package/web/panels/SettingsPanel/SettingsPanel.tpl.js +1 -0
  74. package/web/panels/code-viewer.js +5 -0
  75. package/web/panels/ctx-panel.js +4 -0
  76. package/web/panels/dep-graph.js +6 -0
  77. package/web/panels/file-tree.js +188 -0
  78. package/web/panels/health-panel.js +3 -0
  79. package/web/panels/live-monitor.js +3 -0
  80. package/web/state.js +17 -0
  81. package/web/style.css +157 -0
  82. package/references/symbiote-3x.md +0 -834
  83. package/src/ai-context.js +0 -113
  84. package/src/analysis-cache.js +0 -155
  85. package/src/cli-handlers.js +0 -271
  86. package/src/cli.js +0 -95
  87. package/src/compact.js +0 -207
  88. package/src/complexity.js +0 -237
  89. package/src/compress.js +0 -319
  90. package/src/ctx-to-jsdoc.js +0 -514
  91. package/src/custom-rules.js +0 -584
  92. package/src/db-analysis.js +0 -194
  93. package/src/dead-code.js +0 -468
  94. package/src/doc-dialect.js +0 -716
  95. package/src/filters.js +0 -227
  96. package/src/framework-references.js +0 -177
  97. package/src/full-analysis.js +0 -470
  98. package/src/graph-builder.js +0 -299
  99. package/src/instructions.js +0 -73
  100. package/src/jsdoc-checker.js +0 -351
  101. package/src/jsdoc-generator.js +0 -203
  102. package/src/lang-go.js +0 -285
  103. package/src/lang-python.js +0 -197
  104. package/src/lang-sql.js +0 -309
  105. package/src/lang-typescript.js +0 -190
  106. package/src/lang-utils.js +0 -124
  107. package/src/large-files.js +0 -163
  108. package/src/mcp-server.js +0 -675
  109. package/src/mode-config.js +0 -127
  110. package/src/outdated-patterns.js +0 -296
  111. package/src/parser.js +0 -662
  112. package/src/server.js +0 -28
  113. package/src/similar-functions.js +0 -279
  114. package/src/test-annotations.js +0 -323
  115. package/src/tool-defs.js +0 -793
  116. package/src/tools.js +0 -470
  117. package/src/type-checker.js +0 -188
  118. package/src/undocumented.js +0 -259
  119. package/src/workspace.js +0 -70
  120. /package/{AGENT_ROLE.md → docs/examples/AGENT_ROLE.md} +0 -0
  121. /package/{AGENT_ROLE_MINIMAL.md → docs/examples/AGENT_ROLE_MINIMAL.md} +0 -0
package/src/lang-go.js DELETED
@@ -1,285 +0,0 @@
1
- import { stripStringsAndComments } from './lang-utils.js';
2
-
3
- /**
4
- * Parse Go file using regex-based structural extraction.
5
- * @param {string} code - Go source code
6
- * @param {string} filename - File path
7
- * @returns {ParseResult}
8
- */
9
- export function parseGo(code, filename) {
10
- const result = {
11
- file: filename,
12
- classes: [],
13
- functions: [],
14
- imports: [],
15
- exports: []
16
- };
17
-
18
- const { imports, packageNames } = extractImports(code);
19
- result.imports = imports;
20
-
21
- const cleanCode = stripStringsAndComments(code, {
22
- singleQuote: false,
23
- backtick: true,
24
- templateInterpolation: false
25
- });
26
-
27
- const classesMap = new Map();
28
-
29
- // Extract Structs (mapped to classes)
30
- const structRegex = /^\s*type\s+([a-zA-Z_]\w*)\s+struct\s*\{/gm;
31
- let match;
32
- while ((match = structRegex.exec(cleanCode)) !== null) {
33
- const name = match[1];
34
- const start = match.index + match[0].length;
35
- const body = getBody(cleanCode, start);
36
- const line = code.substring(0, match.index).split('\n').length;
37
-
38
- let extendsName = null;
39
- const properties = [];
40
-
41
- const lines = body.split('\n').map(l => l.trim()).filter(l => l);
42
- for (const lineStr of lines) {
43
- const parts = lineStr.split(/\s+/);
44
- if (parts.length === 1) {
45
- extendsName = parts[0].replace(/^\*/, ''); // Remove pointer if embedded
46
- } else if (parts.length >= 2) {
47
- const propName = parts[0].replace(/,$/, '');
48
- properties.push(propName);
49
- }
50
- }
51
-
52
- classesMap.set(name, {
53
- name,
54
- extends: extendsName,
55
- methods: [],
56
- properties,
57
- calls: [],
58
- file: filename,
59
- line
60
- });
61
- }
62
-
63
- // Extract Interfaces (mapped to classes)
64
- const interfaceRegex = /^\s*type\s+([a-zA-Z_]\w*)\s+interface\s*\{/gm;
65
- while ((match = interfaceRegex.exec(cleanCode)) !== null) {
66
- const name = match[1];
67
- const start = match.index + match[0].length;
68
- const body = getBody(cleanCode, start);
69
- const line = code.substring(0, match.index).split('\n').length;
70
-
71
- let extendsName = null;
72
- const methods = [];
73
-
74
- const lines = body.split('\n').map(l => l.trim()).filter(l => l);
75
- for (const lineStr of lines) {
76
- const parenIndex = lineStr.indexOf('(');
77
- if (parenIndex !== -1) {
78
- const beforeParen = lineStr.substring(0, parenIndex).trim();
79
- const parts = beforeParen.split(/\s+/);
80
- const methodName = parts[parts.length - 1];
81
- if (methodName) {
82
- methods.push(methodName);
83
- }
84
- } else {
85
- const parts = lineStr.split(/\s+/);
86
- if (parts.length === 1) {
87
- extendsName = parts[0];
88
- }
89
- }
90
- }
91
-
92
- classesMap.set(name, {
93
- name,
94
- extends: extendsName,
95
- methods,
96
- properties: [],
97
- calls: [],
98
- file: filename,
99
- line
100
- });
101
- }
102
-
103
- // Extract Methods
104
- const methodRegex = /^\s*func\s+\(\s*[a-zA-Z_]\w*\s+\*?([a-zA-Z_]\w*)\s*\)\s+([a-zA-Z_]\w*)[^{]*\{/gm;
105
- while ((match = methodRegex.exec(cleanCode)) !== null) {
106
- const className = match[1];
107
- const methodName = match[2];
108
- const start = match.index + match[0].length;
109
- const body = getBody(cleanCode, start);
110
- const line = code.substring(0, match.index).split('\n').length;
111
-
112
- const methodCalls = extractCalls(body, packageNames);
113
-
114
- if (!classesMap.has(className)) {
115
- classesMap.set(className, {
116
- name: className,
117
- extends: null,
118
- methods: [],
119
- properties: [],
120
- calls: [],
121
- file: filename,
122
- line
123
- });
124
- }
125
-
126
- const classInfo = classesMap.get(className);
127
- classInfo.methods.push(methodName);
128
-
129
- for (const call of methodCalls) {
130
- if (!classInfo.calls.includes(call)) {
131
- classInfo.calls.push(call);
132
- }
133
- }
134
- }
135
-
136
- // Extract Functions (top-level)
137
- const funcRegex = /^\s*func\s+([a-zA-Z_]\w*)\s*\(([^)]*)\)[^{]*\{/gm;
138
- while ((match = funcRegex.exec(cleanCode)) !== null) {
139
- const name = match[1];
140
- const paramsStr = match[2];
141
- const params = paramsStr.split(',')
142
- .map(p => p.trim().split(/\s+/)[0])
143
- .filter(p => p);
144
-
145
- const exported = /^[A-Z]/.test(name);
146
- const start = match.index + match[0].length;
147
- const body = getBody(cleanCode, start);
148
- const line = code.substring(0, match.index).split('\n').length;
149
-
150
- const calls = extractCalls(body, packageNames);
151
-
152
- result.functions.push({
153
- name,
154
- exported,
155
- calls,
156
- params,
157
- file: filename,
158
- line
159
- });
160
- }
161
-
162
- result.classes = Array.from(classesMap.values());
163
-
164
- // Extract Exports
165
- for (const cls of result.classes) {
166
- if (/^[A-Z]/.test(cls.name)) {
167
- result.exports.push(cls.name);
168
- }
169
- }
170
- for (const fn of result.functions) {
171
- if (fn.exported) {
172
- result.exports.push(fn.name);
173
- }
174
- }
175
-
176
- return result;
177
- }
178
-
179
- function extractImports(text) {
180
- const imports = [];
181
- const packageNames = new Set();
182
-
183
- // Strip comments to avoid commented out imports
184
- const noComments = text.replace(/\/\/.*/g, '').replace(/\/\*[\s\S]*?\*\//g, '');
185
-
186
- const importBlockRegex = /import\s*\(([\s\S]*?)\)/g;
187
- let match;
188
- while ((match = importBlockRegex.exec(noComments)) !== null) {
189
- const block = match[1];
190
- const lines = block.split('\n');
191
- for (const line of lines) {
192
- const lineMatch = line.match(/(?:([a-zA-Z_]\w*)\s+)?"([^"]+)"/);
193
- if (lineMatch) {
194
- const alias = lineMatch[1];
195
- const pkgPath = lineMatch[2];
196
- if (alias) {
197
- if (!imports.includes(alias)) {
198
- imports.push(alias);
199
- packageNames.add(alias);
200
- }
201
- } else {
202
- if (!imports.includes(pkgPath)) {
203
- imports.push(pkgPath);
204
- const parts = pkgPath.split('/');
205
- packageNames.add(parts[parts.length - 1]);
206
- }
207
- }
208
- }
209
- }
210
- }
211
-
212
- const singleImportRegex = /import\s+(?:([a-zA-Z_]\w*)\s+)?"([^"]+)"/g;
213
- while ((match = singleImportRegex.exec(noComments)) !== null) {
214
- const alias = match[1];
215
- const pkgPath = match[2];
216
- if (alias) {
217
- if (!imports.includes(alias)) {
218
- imports.push(alias);
219
- packageNames.add(alias);
220
- }
221
- } else {
222
- if (!imports.includes(pkgPath)) {
223
- imports.push(pkgPath);
224
- const parts = pkgPath.split('/');
225
- packageNames.add(parts[parts.length - 1]);
226
- }
227
- }
228
- }
229
-
230
- return { imports, packageNames };
231
- }
232
-
233
- /**
234
- * Extract block body correctly handling nested braces.
235
- * @param {string} code
236
- * @param {number} startIndex
237
- * @returns {string}
238
- */
239
- function getBody(code, startIndex) {
240
- let braces = 1;
241
- let end = startIndex;
242
- while (end < code.length && braces > 0) {
243
- if (code[end] === '{') braces++;
244
- else if (code[end] === '}') braces--;
245
- end++;
246
- }
247
- return code.substring(startIndex, end - 1);
248
- }
249
-
250
- /**
251
- * Extract method calls from a block of code, filtering out Go keywords.
252
- * @param {string} body
253
- * @param {Set<string>} packageNames
254
- * @returns {string[]}
255
- */
256
- function extractCalls(body, packageNames) {
257
- const calls = [];
258
- const callRegex = /([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)?)\s*\(/g;
259
- let match;
260
- while ((match = callRegex.exec(body)) !== null) {
261
- let callName = match[1];
262
-
263
- const keywords = [
264
- 'if', 'for', 'switch', 'func', 'panic', 'recover', 'len', 'cap',
265
- 'make', 'new', 'append', 'copy', 'delete', 'close',
266
- 'int', 'string', 'bool', 'byte', 'rune', 'float32', 'float64',
267
- 'int32', 'int64', 'uint32', 'uint64', 'complex64', 'complex128'
268
- ];
269
- if (keywords.includes(callName)) continue;
270
-
271
- if (callName.includes('.')) {
272
- const parts = callName.split('.');
273
- // If the first part is a known package name, keep it (e.g., fmt.Println)
274
- // Otherwise, assume it's a method call on a variable and strip it (e.g., s.Handle -> Handle)
275
- if (!packageNames.has(parts[0])) {
276
- callName = parts[1];
277
- }
278
- }
279
-
280
- if (!calls.includes(callName)) {
281
- calls.push(callName);
282
- }
283
- }
284
- return calls;
285
- }
@@ -1,197 +0,0 @@
1
- import { stripStringsAndComments } from './lang-utils.js';
2
-
3
- /**
4
- * Parse Python file using regex-based structural extraction.
5
- * @param {string} code - Python source code
6
- * @param {string} filename - File path
7
- * @returns {ParseResult}
8
- */
9
- export function parsePython(code = '', filename = '') {
10
- const result = {
11
- file: filename,
12
- classes: [],
13
- functions: [],
14
- imports: [],
15
- exports: []
16
- };
17
-
18
- // Pre-process: remove docstrings, triple-quoted strings, and line comments
19
- const cleanCode = stripStringsAndComments(code, {
20
- singleQuote: true,
21
- hashComment: true,
22
- tripleQuote: true
23
- });
24
-
25
- const lines = cleanCode.split('\n');
26
-
27
- let currentClass = null;
28
- let currentFunc = null;
29
- let classIndent = -1;
30
-
31
- for (let i = 0; i < lines.length; i++) {
32
- const line = lines[i];
33
- if (!line.trim()) continue;
34
-
35
- const indentMatch = line.match(/^([ \t]*)/);
36
- const indent = indentMatch ? indentMatch[1].length : 0;
37
-
38
- // Check if we exited a class scope
39
- if (currentClass && indent <= classIndent) {
40
- currentClass = null;
41
- classIndent = -1;
42
- }
43
-
44
- // Check if we exited a function scope
45
- if (currentFunc && indent === 0) {
46
- currentFunc = null;
47
- }
48
-
49
- // Match Class (top-level)
50
- const classMatch = line.match(/^class\s+([a-zA-Z_]\w*)(?:\s*\((.*?)\))?\s*:/);
51
- if (classMatch) {
52
- currentClass = {
53
- name: classMatch[1],
54
- extends: classMatch[2] ? classMatch[2].trim() : null,
55
- methods: [],
56
- properties: [],
57
- calls: [],
58
- file: filename,
59
- line: i + 1
60
- };
61
- result.classes.push(currentClass);
62
- classIndent = indent;
63
- currentFunc = null;
64
- continue;
65
- }
66
-
67
- // Match top-level function
68
- const funcMatch = line.match(/^(?:async\s+)?def\s+([a-zA-Z_]\w*)\s*\(([^)]*)\)?/);
69
- if (funcMatch) {
70
- const paramsStr = funcMatch[2] || '';
71
- const params = paramsStr.split(',')
72
- .map(p => p.split(/[:=]/)[0].trim())
73
- .filter(p => p && p !== 'self' && p !== 'cls');
74
-
75
- currentFunc = {
76
- name: funcMatch[1],
77
- exported: true, // we'll adjust later if __all__ is present
78
- calls: [],
79
- params: params,
80
- file: filename,
81
- line: i + 1
82
- };
83
- result.functions.push(currentFunc);
84
- currentClass = null;
85
- continue;
86
- }
87
-
88
- // Match Method (inside class)
89
- const methodMatch = line.match(/^[ \t]+(?:async\s+)?def\s+([a-zA-Z_]\w*)\s*\(/);
90
- if (methodMatch && currentClass && indent > classIndent) {
91
- const methodName = methodMatch[1];
92
- if (methodName !== '__init__') {
93
- currentClass.methods.push(methodName);
94
- }
95
- currentFunc = null; // not a top-level function
96
- continue;
97
- }
98
-
99
- // Match Imports
100
- const importMatch = line.match(/^\s*import\s+(.+)/);
101
- if (importMatch) {
102
- const parts = importMatch[1].split(',');
103
- for (const part of parts) {
104
- const p = part.trim();
105
- const asMatch = p.match(/(?:.+)\s+as\s+([a-zA-Z_]\w*)/);
106
- if (asMatch) {
107
- result.imports.push(asMatch[1]);
108
- } else {
109
- result.imports.push(p.split('.')[0]); // take root module
110
- }
111
- }
112
- continue;
113
- }
114
-
115
- const fromImportMatch = line.match(/^\s*from\s+([.\w]+)\s+import\s*(.*)/);
116
- if (fromImportMatch) {
117
- let imported = fromImportMatch[2];
118
- if (imported.includes('(') && !imported.includes(')')) {
119
- let j = i + 1;
120
- while (j < lines.length) {
121
- imported += ' ' + lines[j];
122
- if (lines[j].includes(')')) {
123
- i = j;
124
- break;
125
- }
126
- j++;
127
- }
128
- }
129
- imported = imported.replace(/[()]/g, '');
130
- const parts = imported.split(',');
131
- for (const part of parts) {
132
- const p = part.trim();
133
- if (!p) continue;
134
- const asMatch = p.match(/(?:.+)\s+as\s+([a-zA-Z_]\w*)/);
135
- if (asMatch) {
136
- result.imports.push(asMatch[1]);
137
- } else {
138
- result.imports.push(p);
139
- }
140
- }
141
- continue;
142
- }
143
-
144
- // Extract calls: look for func(...)
145
- const callRegex = /([a-zA-Z_][\w.]*)\s*\(/g;
146
- let match;
147
- const keywords = new Set(['if', 'while', 'for', 'elif', 'return', 'yield', 'def', 'class', 'and', 'or', 'not', 'in', 'is', 'print']);
148
- while ((match = callRegex.exec(line)) !== null) {
149
- const callName = match[1];
150
- if (keywords.has(callName)) continue;
151
-
152
- let cleanCallName = callName;
153
- if (cleanCallName.startsWith('self.')) {
154
- cleanCallName = cleanCallName.substring(5);
155
- }
156
-
157
- if (currentFunc) {
158
- if (!currentFunc.calls.includes(cleanCallName)) {
159
- currentFunc.calls.push(cleanCallName);
160
- }
161
- } else if (currentClass) {
162
- if (!currentClass.calls.includes(cleanCallName)) {
163
- currentClass.calls.push(cleanCallName);
164
- }
165
- }
166
- }
167
- }
168
-
169
- // Handle Exports (__all__)
170
- const allMatch = code.match(/__all__\s*=\s*\[(.*?)\]/s);
171
- if (allMatch) {
172
- const exportsRaw = allMatch[1];
173
- const exportRegex = /['"]([^'"]+)['"]/g;
174
- let exMatch;
175
- while ((exMatch = exportRegex.exec(exportsRaw)) !== null) {
176
- result.exports.push(exMatch[1]);
177
- }
178
- // Update exported flags for functions
179
- for (const fn of result.functions) {
180
- fn.exported = result.exports.includes(fn.name);
181
- }
182
- } else {
183
- // Implicit exports: all top-level functions and classes are exported
184
- for (const cls of result.classes) {
185
- result.exports.push(cls.name);
186
- }
187
- for (const fn of result.functions) {
188
- result.exports.push(fn.name);
189
- fn.exported = true;
190
- }
191
- }
192
-
193
- // Deduplicate imports
194
- result.imports = [...new Set(result.imports)];
195
-
196
- return result;
197
- }