statecli-mcp-server 0.2.0 → 0.3.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.
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+ /**
3
+ * Dependency Tracker - Understand code dependencies
4
+ *
5
+ * Analyzes imports/exports to understand what code depends on what.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.DependencyTracker = void 0;
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ class DependencyTracker {
45
+ statecli;
46
+ projectPath;
47
+ graph;
48
+ fileExtensions;
49
+ constructor(statecli, projectPath = '.', options) {
50
+ this.statecli = statecli;
51
+ this.projectPath = path.resolve(projectPath);
52
+ this.fileExtensions = options?.extensions || ['.ts', '.tsx', '.js', '.jsx', '.py', '.java'];
53
+ this.graph = { files: new Map(), edges: [] };
54
+ }
55
+ /**
56
+ * Build dependency graph for the project
57
+ */
58
+ buildGraph(rootDir) {
59
+ const startDir = rootDir || this.projectPath;
60
+ this.graph = { files: new Map(), edges: [] };
61
+ this.scanDirectory(startDir);
62
+ this.buildReverseLinks();
63
+ // Track graph build in StateCLI
64
+ this.statecli.track('dependency', 'graph', {
65
+ fileCount: this.graph.files.size,
66
+ edgeCount: this.graph.edges.length,
67
+ timestamp: new Date().toISOString()
68
+ }, 'dependency-tracker');
69
+ return this.graph;
70
+ }
71
+ /**
72
+ * Analyze impact of changing a file
73
+ */
74
+ analyzeImpact(filePath) {
75
+ const normalizedPath = this.normalizePath(filePath);
76
+ const node = this.graph.files.get(normalizedPath);
77
+ if (!node) {
78
+ // File not in graph, try to rebuild
79
+ this.buildGraph();
80
+ }
81
+ const directDependents = this.getDirectDependents(normalizedPath);
82
+ const transitiveDependents = this.getTransitiveDependents(normalizedPath);
83
+ // Calculate risk level
84
+ const totalImpact = transitiveDependents.length;
85
+ let riskLevel;
86
+ let recommendation;
87
+ if (totalImpact === 0) {
88
+ riskLevel = 'low';
89
+ recommendation = 'No other files depend on this. Safe to modify.';
90
+ }
91
+ else if (totalImpact <= 3) {
92
+ riskLevel = 'low';
93
+ recommendation = `${totalImpact} files may be affected. Review changes carefully.`;
94
+ }
95
+ else if (totalImpact <= 10) {
96
+ riskLevel = 'medium';
97
+ recommendation = `${totalImpact} files may be affected. Consider creating a checkpoint first.`;
98
+ }
99
+ else if (totalImpact <= 25) {
100
+ riskLevel = 'high';
101
+ recommendation = `${totalImpact} files may be affected. Test thoroughly before committing.`;
102
+ }
103
+ else {
104
+ riskLevel = 'critical';
105
+ recommendation = `${totalImpact} files may be affected. This is a core file - proceed with extreme caution.`;
106
+ }
107
+ // Track analysis
108
+ this.statecli.track('dependency', 'impact-analysis', {
109
+ file: normalizedPath,
110
+ directCount: directDependents.length,
111
+ transitiveCount: transitiveDependents.length,
112
+ riskLevel
113
+ }, 'dependency-tracker');
114
+ return {
115
+ changedFile: normalizedPath,
116
+ directDependents,
117
+ transitiveDependents,
118
+ riskLevel,
119
+ recommendation
120
+ };
121
+ }
122
+ /**
123
+ * Get what a file depends on
124
+ */
125
+ getDependencies(filePath) {
126
+ const normalizedPath = this.normalizePath(filePath);
127
+ const node = this.graph.files.get(normalizedPath);
128
+ return node?.dependsOn || [];
129
+ }
130
+ /**
131
+ * Get what depends on a file
132
+ */
133
+ getDependents(filePath) {
134
+ const normalizedPath = this.normalizePath(filePath);
135
+ const node = this.graph.files.get(normalizedPath);
136
+ return node?.dependedBy || [];
137
+ }
138
+ /**
139
+ * Find circular dependencies
140
+ */
141
+ findCircularDependencies() {
142
+ const cycles = [];
143
+ const visited = new Set();
144
+ const recursionStack = new Set();
145
+ const dfs = (file, path) => {
146
+ visited.add(file);
147
+ recursionStack.add(file);
148
+ path.push(file);
149
+ const node = this.graph.files.get(file);
150
+ if (node) {
151
+ for (const dep of node.dependsOn) {
152
+ if (!visited.has(dep)) {
153
+ dfs(dep, [...path]);
154
+ }
155
+ else if (recursionStack.has(dep)) {
156
+ // Found cycle
157
+ const cycleStart = path.indexOf(dep);
158
+ cycles.push(path.slice(cycleStart));
159
+ }
160
+ }
161
+ }
162
+ recursionStack.delete(file);
163
+ };
164
+ for (const file of this.graph.files.keys()) {
165
+ if (!visited.has(file)) {
166
+ dfs(file, []);
167
+ }
168
+ }
169
+ return cycles;
170
+ }
171
+ /**
172
+ * Get dependency tree as a string for display
173
+ */
174
+ getDependencyTree(filePath, maxDepth = 3) {
175
+ const normalizedPath = this.normalizePath(filePath);
176
+ const lines = [normalizedPath];
177
+ const buildTree = (file, depth, prefix) => {
178
+ if (depth >= maxDepth)
179
+ return;
180
+ const node = this.graph.files.get(file);
181
+ if (!node)
182
+ return;
183
+ const deps = node.dependsOn;
184
+ for (let i = 0; i < deps.length; i++) {
185
+ const isLast = i === deps.length - 1;
186
+ const connector = isLast ? '└── ' : '├── ';
187
+ const newPrefix = isLast ? ' ' : '│ ';
188
+ lines.push(`${prefix}${connector}${path.basename(deps[i])}`);
189
+ buildTree(deps[i], depth + 1, prefix + newPrefix);
190
+ }
191
+ };
192
+ buildTree(normalizedPath, 0, '');
193
+ return lines.join('\n');
194
+ }
195
+ /**
196
+ * Get most depended-upon files (core files)
197
+ */
198
+ getCoreFiles(limit = 10) {
199
+ const counts = [];
200
+ for (const [file, node] of this.graph.files) {
201
+ counts.push({
202
+ file,
203
+ dependentCount: node.dependedBy.length
204
+ });
205
+ }
206
+ return counts
207
+ .sort((a, b) => b.dependentCount - a.dependentCount)
208
+ .slice(0, limit);
209
+ }
210
+ scanDirectory(dir) {
211
+ try {
212
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
213
+ for (const entry of entries) {
214
+ const fullPath = path.join(dir, entry.name);
215
+ if (entry.isDirectory()) {
216
+ // Skip common non-source directories
217
+ if (!['node_modules', '.git', 'dist', 'build', '__pycache__', '.next'].includes(entry.name)) {
218
+ this.scanDirectory(fullPath);
219
+ }
220
+ }
221
+ else if (entry.isFile() && this.fileExtensions.some(ext => entry.name.endsWith(ext))) {
222
+ this.analyzeFile(fullPath);
223
+ }
224
+ }
225
+ }
226
+ catch (error) {
227
+ // Directory might not be readable
228
+ }
229
+ }
230
+ analyzeFile(filePath) {
231
+ try {
232
+ const content = fs.readFileSync(filePath, 'utf-8');
233
+ const normalizedPath = this.normalizePath(filePath);
234
+ const imports = [];
235
+ const exports = [];
236
+ // Parse imports/requires
237
+ const importPatterns = [
238
+ /import\s+.*?\s+from\s+['"](.+?)['"]/g,
239
+ /import\s+['"](.+?)['"]/g,
240
+ /require\s*\(\s*['"](.+?)['"]\s*\)/g,
241
+ /from\s+(\S+)\s+import/g // Python
242
+ ];
243
+ for (const pattern of importPatterns) {
244
+ let match;
245
+ while ((match = pattern.exec(content)) !== null) {
246
+ const importPath = this.resolveImportPath(normalizedPath, match[1]);
247
+ if (importPath) {
248
+ imports.push(importPath);
249
+ this.graph.edges.push({
250
+ source: normalizedPath,
251
+ target: importPath,
252
+ type: 'import'
253
+ });
254
+ }
255
+ }
256
+ }
257
+ // Parse exports
258
+ const exportPattern = /export\s+(?:default\s+)?(?:class|function|const|let|var|interface|type)\s+(\w+)/g;
259
+ let match;
260
+ while ((match = exportPattern.exec(content)) !== null) {
261
+ exports.push(match[1]);
262
+ }
263
+ this.graph.files.set(normalizedPath, {
264
+ path: normalizedPath,
265
+ imports,
266
+ exports,
267
+ dependsOn: imports,
268
+ dependedBy: [] // Will be filled by buildReverseLinks
269
+ });
270
+ }
271
+ catch (error) {
272
+ // File might not be readable
273
+ }
274
+ }
275
+ buildReverseLinks() {
276
+ for (const [file, node] of this.graph.files) {
277
+ for (const dep of node.dependsOn) {
278
+ const depNode = this.graph.files.get(dep);
279
+ if (depNode && !depNode.dependedBy.includes(file)) {
280
+ depNode.dependedBy.push(file);
281
+ }
282
+ }
283
+ }
284
+ }
285
+ resolveImportPath(fromFile, importPath) {
286
+ // Handle relative imports
287
+ if (importPath.startsWith('.')) {
288
+ const dir = path.dirname(fromFile);
289
+ let resolved = path.resolve(dir, importPath);
290
+ // Try adding extensions
291
+ for (const ext of this.fileExtensions) {
292
+ if (fs.existsSync(resolved + ext)) {
293
+ return this.normalizePath(resolved + ext);
294
+ }
295
+ // Try index file
296
+ const indexPath = path.join(resolved, `index${ext}`);
297
+ if (fs.existsSync(indexPath)) {
298
+ return this.normalizePath(indexPath);
299
+ }
300
+ }
301
+ // Check if it exists as-is
302
+ if (fs.existsSync(resolved)) {
303
+ return this.normalizePath(resolved);
304
+ }
305
+ }
306
+ // Non-relative imports (node_modules, etc.) - skip
307
+ return null;
308
+ }
309
+ normalizePath(filePath) {
310
+ return path.relative(this.projectPath, filePath).replace(/\\/g, '/');
311
+ }
312
+ getDirectDependents(filePath) {
313
+ const node = this.graph.files.get(filePath);
314
+ return node?.dependedBy || [];
315
+ }
316
+ getTransitiveDependents(filePath, visited = new Set()) {
317
+ if (visited.has(filePath))
318
+ return [];
319
+ visited.add(filePath);
320
+ const direct = this.getDirectDependents(filePath);
321
+ const transitive = [...direct];
322
+ for (const dep of direct) {
323
+ const nested = this.getTransitiveDependents(dep, visited);
324
+ for (const n of nested) {
325
+ if (!transitive.includes(n)) {
326
+ transitive.push(n);
327
+ }
328
+ }
329
+ }
330
+ return transitive;
331
+ }
332
+ }
333
+ exports.DependencyTracker = DependencyTracker;
334
+ //# sourceMappingURL=dependency-tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-tracker.js","sourceRoot":"","sources":["../src/dependency-tracker.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AA+B7B,MAAa,iBAAiB;IACpB,QAAQ,CAAW;IACnB,WAAW,CAAS;IACpB,KAAK,CAAkB;IACvB,cAAc,CAAW;IAEjC,YACE,QAAkB,EAClB,cAAsB,GAAG,EACzB,OAEC;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAgB;QACzB,MAAM,QAAQ,GAAG,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,EA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AAC;QAClD,MAAM,UAAU,GAAa,CAAC,GAAG,MAAM,CAAC,CAAC;QAEzC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC1D,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;gBACvB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC5B,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA3UD,8CA2UC"}
@@ -11,6 +11,10 @@ export declare class EnhancedStateCLIMCPServer {
11
11
  private errorRecovery;
12
12
  private sessionMemory;
13
13
  private gitIntegration;
14
+ private testAwareness;
15
+ private dependencyTracker;
16
+ private rollbackPreview;
17
+ private crossFileImpact;
14
18
  constructor(config?: Partial<StateCLIConfig>);
15
19
  private setupHandlers;
16
20
  private handleReplay;
@@ -29,6 +33,17 @@ export declare class EnhancedStateCLIMCPServer {
29
33
  private handleGitStatus;
30
34
  private handleGitHistory;
31
35
  private handleGitCheckpoint;
36
+ private handleRunTests;
37
+ private handleTestImpact;
38
+ private handleSuggestTests;
39
+ private handleAnalyzeDependencies;
40
+ private handleDependencyTree;
41
+ private handleFindCircular;
42
+ private handlePreviewUndo;
43
+ private handleSimulateUndo;
44
+ private handlePredictImpact;
45
+ private handleIsSafe;
46
+ private handleSafeChangeOrder;
32
47
  run(): Promise<void>;
33
48
  close(): void;
34
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enhanced-mcp-server.d.ts","sourceRoot":"","sources":["../src/enhanced-mcp-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAsNzC,qBAAa,yBAAyB;IACpC,OAAO,CAAC,MAAM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AAkB;gBAE7B,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAmB5C,OAAO,CAAC,aAAa;IA6FrB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,qBAAqB;IAMvB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1B,KAAK,IAAI,IAAI;CAId"}
@@ -14,6 +14,10 @@ const file_tracker_1 = require("./file-tracker");
14
14
  const error_recovery_1 = require("./error-recovery");
15
15
  const session_memory_1 = require("./session-memory");
16
16
  const git_integration_1 = require("./git-integration");
17
+ const test_awareness_1 = require("./test-awareness");
18
+ const dependency_tracker_1 = require("./dependency-tracker");
19
+ const rollback_preview_1 = require("./rollback-preview");
20
+ const cross_file_impact_1 = require("./cross-file-impact");
17
21
  const ENHANCED_TOOLS = [
18
22
  // Original tools
19
23
  {
@@ -219,6 +223,136 @@ const ENHANCED_TOOLS = [
219
223
  },
220
224
  required: []
221
225
  }
226
+ },
227
+ // NEW v0.3.0: Test awareness tools
228
+ {
229
+ name: 'statecli_run_tests',
230
+ description: 'Run tests and track results. Correlates with recent code changes.',
231
+ inputSchema: {
232
+ type: 'object',
233
+ properties: {
234
+ files: { type: 'array', items: { type: 'string' }, description: 'Specific test files to run' },
235
+ grep: { type: 'string', description: 'Filter tests by pattern' }
236
+ },
237
+ required: []
238
+ }
239
+ },
240
+ {
241
+ name: 'statecli_test_impact',
242
+ description: 'Analyze which tests are affected by a changed file.',
243
+ inputSchema: {
244
+ type: 'object',
245
+ properties: {
246
+ file: { type: 'string', description: 'Changed file path' }
247
+ },
248
+ required: ['file']
249
+ }
250
+ },
251
+ {
252
+ name: 'statecli_suggest_tests',
253
+ description: 'Suggest which tests to run based on recent changes.',
254
+ inputSchema: {
255
+ type: 'object',
256
+ properties: {},
257
+ required: []
258
+ }
259
+ },
260
+ // NEW v0.3.0: Dependency tracking tools
261
+ {
262
+ name: 'statecli_analyze_dependencies',
263
+ description: 'Analyze what files depend on a given file. Shows impact of changes.',
264
+ inputSchema: {
265
+ type: 'object',
266
+ properties: {
267
+ file: { type: 'string', description: 'File to analyze' }
268
+ },
269
+ required: ['file']
270
+ }
271
+ },
272
+ {
273
+ name: 'statecli_dependency_tree',
274
+ description: 'Get dependency tree for a file.',
275
+ inputSchema: {
276
+ type: 'object',
277
+ properties: {
278
+ file: { type: 'string', description: 'File path' },
279
+ depth: { type: 'number', description: 'Max depth (default: 3)' }
280
+ },
281
+ required: ['file']
282
+ }
283
+ },
284
+ {
285
+ name: 'statecli_find_circular',
286
+ description: 'Find circular dependencies in the project.',
287
+ inputSchema: {
288
+ type: 'object',
289
+ properties: {},
290
+ required: []
291
+ }
292
+ },
293
+ // NEW v0.3.0: Rollback preview tools
294
+ {
295
+ name: 'statecli_preview_undo',
296
+ description: 'Preview what will happen if you undo N steps. Shows diff before executing.',
297
+ inputSchema: {
298
+ type: 'object',
299
+ properties: {
300
+ entity: { type: 'string', description: 'Entity identifier' },
301
+ steps: { type: 'number', description: 'Steps to preview undoing (default: 1)' }
302
+ },
303
+ required: ['entity']
304
+ }
305
+ },
306
+ {
307
+ name: 'statecli_simulate_undo',
308
+ description: 'Simulate undo without executing. Shows resulting state and side effects.',
309
+ inputSchema: {
310
+ type: 'object',
311
+ properties: {
312
+ entity: { type: 'string', description: 'Entity identifier' },
313
+ steps: { type: 'number', description: 'Steps to simulate (default: 1)' }
314
+ },
315
+ required: ['entity']
316
+ }
317
+ },
318
+ // NEW v0.3.0: Cross-file impact tools
319
+ {
320
+ name: 'statecli_predict_impact',
321
+ description: 'Predict impact of a proposed change. Shows affected files and breaking changes.',
322
+ inputSchema: {
323
+ type: 'object',
324
+ properties: {
325
+ file: { type: 'string', description: 'File to change' },
326
+ change_type: { type: 'string', enum: ['modify', 'rename', 'delete', 'move'], description: 'Type of change' },
327
+ symbol: { type: 'string', description: 'Specific symbol being changed (optional)' },
328
+ new_name: { type: 'string', description: 'New name if renaming (optional)' }
329
+ },
330
+ required: ['file', 'change_type']
331
+ }
332
+ },
333
+ {
334
+ name: 'statecli_is_safe',
335
+ description: 'Check if a proposed change is safe to make.',
336
+ inputSchema: {
337
+ type: 'object',
338
+ properties: {
339
+ file: { type: 'string', description: 'File to change' },
340
+ change_type: { type: 'string', enum: ['modify', 'rename', 'delete', 'move'], description: 'Type of change' },
341
+ symbol: { type: 'string', description: 'Specific symbol (optional)' }
342
+ },
343
+ required: ['file', 'change_type']
344
+ }
345
+ },
346
+ {
347
+ name: 'statecli_safe_change_order',
348
+ description: 'Get recommended order for changing multiple files safely.',
349
+ inputSchema: {
350
+ type: 'object',
351
+ properties: {
352
+ files: { type: 'array', items: { type: 'string' }, description: 'Files to change' }
353
+ },
354
+ required: ['files']
355
+ }
222
356
  }
223
357
  ];
224
358
  class EnhancedStateCLIMCPServer {
@@ -228,13 +362,21 @@ class EnhancedStateCLIMCPServer {
228
362
  errorRecovery;
229
363
  sessionMemory;
230
364
  gitIntegration;
365
+ testAwareness;
366
+ dependencyTracker;
367
+ rollbackPreview;
368
+ crossFileImpact;
231
369
  constructor(config) {
232
370
  this.statecli = new statecli_1.StateCLI(config);
233
371
  this.fileTracker = new file_tracker_1.FileTracker(this.statecli);
234
372
  this.errorRecovery = new error_recovery_1.ErrorRecovery(this.statecli);
235
373
  this.sessionMemory = new session_memory_1.SessionMemory(this.statecli);
236
374
  this.gitIntegration = new git_integration_1.GitIntegration(this.statecli);
237
- this.server = new index_js_1.Server({ name: 'statecli-enhanced', version: '2.0.0' }, { capabilities: { tools: {} } });
375
+ this.testAwareness = new test_awareness_1.TestAwareness(this.statecli);
376
+ this.dependencyTracker = new dependency_tracker_1.DependencyTracker(this.statecli);
377
+ this.rollbackPreview = new rollback_preview_1.RollbackPreview(this.statecli);
378
+ this.crossFileImpact = new cross_file_impact_1.CrossFileImpact(this.statecli);
379
+ this.server = new index_js_1.Server({ name: 'statecli-enhanced', version: '3.0.0' }, { capabilities: { tools: {} } });
238
380
  this.setupHandlers();
239
381
  }
240
382
  setupHandlers() {
@@ -282,6 +424,32 @@ class EnhancedStateCLIMCPServer {
282
424
  return this.handleGitHistory(args);
283
425
  case 'statecli_git_checkpoint':
284
426
  return this.handleGitCheckpoint(args);
427
+ // Test awareness (v0.3.0)
428
+ case 'statecli_run_tests':
429
+ return this.handleRunTests(args);
430
+ case 'statecli_test_impact':
431
+ return this.handleTestImpact(args);
432
+ case 'statecli_suggest_tests':
433
+ return this.handleSuggestTests();
434
+ // Dependency tracking (v0.3.0)
435
+ case 'statecli_analyze_dependencies':
436
+ return this.handleAnalyzeDependencies(args);
437
+ case 'statecli_dependency_tree':
438
+ return this.handleDependencyTree(args);
439
+ case 'statecli_find_circular':
440
+ return this.handleFindCircular();
441
+ // Rollback preview (v0.3.0)
442
+ case 'statecli_preview_undo':
443
+ return this.handlePreviewUndo(args);
444
+ case 'statecli_simulate_undo':
445
+ return this.handleSimulateUndo(args);
446
+ // Cross-file impact (v0.3.0)
447
+ case 'statecli_predict_impact':
448
+ return this.handlePredictImpact(args);
449
+ case 'statecli_is_safe':
450
+ return this.handleIsSafe(args);
451
+ case 'statecli_safe_change_order':
452
+ return this.handleSafeChangeOrder(args);
285
453
  default:
286
454
  return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
287
455
  }
@@ -411,6 +579,77 @@ class EnhancedStateCLIMCPServer {
411
579
  const result = this.gitIntegration.createGitCheckpoint(args.name);
412
580
  return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
413
581
  }
582
+ // Test awareness handlers (v0.3.0)
583
+ handleRunTests(args) {
584
+ const result = this.testAwareness.runTests({ files: args.files, grep: args.grep, trackChanges: true });
585
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
586
+ }
587
+ handleTestImpact(args) {
588
+ const result = this.testAwareness.analyzeTestImpact(args.file);
589
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
590
+ }
591
+ handleSuggestTests() {
592
+ const result = this.testAwareness.suggestTests();
593
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
594
+ }
595
+ // Dependency tracking handlers (v0.3.0)
596
+ handleAnalyzeDependencies(args) {
597
+ this.dependencyTracker.buildGraph();
598
+ const result = this.dependencyTracker.analyzeImpact(args.file);
599
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
600
+ }
601
+ handleDependencyTree(args) {
602
+ this.dependencyTracker.buildGraph();
603
+ const result = this.dependencyTracker.getDependencyTree(args.file, args.depth || 3);
604
+ return { content: [{ type: 'text', text: result }] };
605
+ }
606
+ handleFindCircular() {
607
+ this.dependencyTracker.buildGraph();
608
+ const cycles = this.dependencyTracker.findCircularDependencies();
609
+ return {
610
+ content: [{
611
+ type: 'text',
612
+ text: JSON.stringify({
613
+ found: cycles.length,
614
+ cycles: cycles.slice(0, 10)
615
+ }, null, 2)
616
+ }]
617
+ };
618
+ }
619
+ // Rollback preview handlers (v0.3.0)
620
+ handlePreviewUndo(args) {
621
+ const result = this.rollbackPreview.previewUndo(args.entity, args.steps || 1);
622
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
623
+ }
624
+ handleSimulateUndo(args) {
625
+ const result = this.rollbackPreview.simulateUndo(args.entity, args.steps || 1);
626
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
627
+ }
628
+ // Cross-file impact handlers (v0.3.0)
629
+ handlePredictImpact(args) {
630
+ this.crossFileImpact.buildIndex();
631
+ const result = this.crossFileImpact.predictImpact({
632
+ file: args.file,
633
+ changeType: args.change_type,
634
+ symbol: args.symbol,
635
+ newValue: args.new_name
636
+ });
637
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
638
+ }
639
+ handleIsSafe(args) {
640
+ this.crossFileImpact.buildIndex();
641
+ const result = this.crossFileImpact.isChangeSafe({
642
+ file: args.file,
643
+ changeType: args.change_type,
644
+ symbol: args.symbol
645
+ });
646
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
647
+ }
648
+ handleSafeChangeOrder(args) {
649
+ this.dependencyTracker.buildGraph();
650
+ const result = this.crossFileImpact.getSafeChangeOrder(args.files);
651
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
652
+ }
414
653
  async run() {
415
654
  const transport = new stdio_js_1.StdioServerTransport();
416
655
  await this.server.connect(transport);