statecli-mcp-server 0.1.2 → 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.
- package/README.md +334 -153
- package/dist/cross-file-impact.d.ts +85 -0
- package/dist/cross-file-impact.d.ts.map +1 -0
- package/dist/cross-file-impact.js +338 -0
- package/dist/cross-file-impact.js.map +1 -0
- package/dist/dependency-tracker.d.ts +78 -0
- package/dist/dependency-tracker.d.ts.map +1 -0
- package/dist/dependency-tracker.js +334 -0
- package/dist/dependency-tracker.js.map +1 -0
- package/dist/enhanced-mcp-server.d.ts +50 -0
- package/dist/enhanced-mcp-server.d.ts.map +1 -0
- package/dist/enhanced-mcp-server.js +664 -0
- package/dist/enhanced-mcp-server.js.map +1 -0
- package/dist/error-recovery.d.ts +66 -0
- package/dist/error-recovery.d.ts.map +1 -0
- package/dist/error-recovery.js +210 -0
- package/dist/error-recovery.js.map +1 -0
- package/dist/file-tracker.d.ts +81 -0
- package/dist/file-tracker.d.ts.map +1 -0
- package/dist/file-tracker.js +252 -0
- package/dist/file-tracker.js.map +1 -0
- package/dist/git-integration.d.ts +95 -0
- package/dist/git-integration.d.ts.map +1 -0
- package/dist/git-integration.js +219 -0
- package/dist/git-integration.js.map +1 -0
- package/dist/index-enhanced.d.ts +12 -0
- package/dist/index-enhanced.d.ts.map +1 -0
- package/dist/index-enhanced.js +27 -0
- package/dist/index-enhanced.js.map +1 -0
- package/dist/rollback-preview.d.ts +77 -0
- package/dist/rollback-preview.d.ts.map +1 -0
- package/dist/rollback-preview.js +244 -0
- package/dist/rollback-preview.js.map +1 -0
- package/dist/session-memory.d.ts +85 -0
- package/dist/session-memory.d.ts.map +1 -0
- package/dist/session-memory.js +325 -0
- package/dist/session-memory.js.map +1 -0
- package/dist/test-awareness.d.ts +85 -0
- package/dist/test-awareness.d.ts.map +1 -0
- package/dist/test-awareness.js +329 -0
- package/dist/test-awareness.js.map +1 -0
- package/dist/types.d.ts +11 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File Tracker - Auto-tracking of file edits
|
|
4
|
+
*
|
|
5
|
+
* Automatically tracks file changes and integrates with StateCLI
|
|
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.FileTracker = void 0;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const crypto = __importStar(require("crypto"));
|
|
45
|
+
const DEFAULT_CONFIG = {
|
|
46
|
+
watchPaths: ['.'],
|
|
47
|
+
ignorePatterns: ['node_modules', '.git', 'dist', '*.log', '.statecli'],
|
|
48
|
+
autoCheckpoint: true,
|
|
49
|
+
checkpointThreshold: 10
|
|
50
|
+
};
|
|
51
|
+
class FileTracker {
|
|
52
|
+
statecli;
|
|
53
|
+
config;
|
|
54
|
+
fileHashes = new Map();
|
|
55
|
+
changeCount = 0;
|
|
56
|
+
watchers = [];
|
|
57
|
+
constructor(statecli, config) {
|
|
58
|
+
this.statecli = statecli;
|
|
59
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Start watching files for changes
|
|
63
|
+
*/
|
|
64
|
+
startWatching() {
|
|
65
|
+
for (const watchPath of this.config.watchPaths) {
|
|
66
|
+
this.watchDirectory(watchPath);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Stop watching files
|
|
71
|
+
*/
|
|
72
|
+
stopWatching() {
|
|
73
|
+
for (const watcher of this.watchers) {
|
|
74
|
+
watcher.close();
|
|
75
|
+
}
|
|
76
|
+
this.watchers = [];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Track a file change manually
|
|
80
|
+
*/
|
|
81
|
+
trackFileChange(filePath, operation, beforeContent, afterContent, actor = 'ai-agent') {
|
|
82
|
+
const diff = this.computeDiff(beforeContent, afterContent);
|
|
83
|
+
const timestamp = new Date().toISOString();
|
|
84
|
+
const change = {
|
|
85
|
+
filePath: path.normalize(filePath),
|
|
86
|
+
operation,
|
|
87
|
+
before: beforeContent,
|
|
88
|
+
after: afterContent,
|
|
89
|
+
diff,
|
|
90
|
+
timestamp
|
|
91
|
+
};
|
|
92
|
+
// Track in StateCLI
|
|
93
|
+
this.statecli.track('file', filePath, {
|
|
94
|
+
operation,
|
|
95
|
+
contentHash: afterContent ? this.hashContent(afterContent) : null,
|
|
96
|
+
lineCount: afterContent ? afterContent.split('\n').length : 0,
|
|
97
|
+
diff: diff.slice(0, 50), // Store first 50 diff lines
|
|
98
|
+
timestamp
|
|
99
|
+
}, actor);
|
|
100
|
+
this.changeCount++;
|
|
101
|
+
// Auto-checkpoint if threshold reached
|
|
102
|
+
if (this.config.autoCheckpoint &&
|
|
103
|
+
this.changeCount >= this.config.checkpointThreshold) {
|
|
104
|
+
this.createAutoCheckpoint();
|
|
105
|
+
}
|
|
106
|
+
return change;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Track a file edit with before/after content
|
|
110
|
+
*/
|
|
111
|
+
trackEdit(filePath, beforeContent, afterContent, actor = 'ai-agent') {
|
|
112
|
+
return this.trackFileChange(filePath, 'modify', beforeContent, afterContent, actor);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Track a file creation
|
|
116
|
+
*/
|
|
117
|
+
trackCreate(filePath, content, actor = 'ai-agent') {
|
|
118
|
+
return this.trackFileChange(filePath, 'create', null, content, actor);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Track a file deletion
|
|
122
|
+
*/
|
|
123
|
+
trackDelete(filePath, previousContent, actor = 'ai-agent') {
|
|
124
|
+
return this.trackFileChange(filePath, 'delete', previousContent, null, actor);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get file change history
|
|
128
|
+
*/
|
|
129
|
+
getFileHistory(filePath) {
|
|
130
|
+
return this.statecli.replay(`file:${path.normalize(filePath)}`);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Compute simple diff between two strings
|
|
134
|
+
*/
|
|
135
|
+
computeDiff(before, after) {
|
|
136
|
+
const diff = [];
|
|
137
|
+
if (before === null && after !== null) {
|
|
138
|
+
// New file
|
|
139
|
+
const lines = after.split('\n');
|
|
140
|
+
lines.forEach((line, i) => {
|
|
141
|
+
diff.push(`+${i + 1}: ${line}`);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else if (before !== null && after === null) {
|
|
145
|
+
// Deleted file
|
|
146
|
+
const lines = before.split('\n');
|
|
147
|
+
lines.forEach((line, i) => {
|
|
148
|
+
diff.push(`-${i + 1}: ${line}`);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else if (before !== null && after !== null) {
|
|
152
|
+
// Modified file - simple line-by-line diff
|
|
153
|
+
const beforeLines = before.split('\n');
|
|
154
|
+
const afterLines = after.split('\n');
|
|
155
|
+
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
156
|
+
for (let i = 0; i < maxLines; i++) {
|
|
157
|
+
const beforeLine = beforeLines[i];
|
|
158
|
+
const afterLine = afterLines[i];
|
|
159
|
+
if (beforeLine !== afterLine) {
|
|
160
|
+
if (beforeLine !== undefined) {
|
|
161
|
+
diff.push(`-${i + 1}: ${beforeLine}`);
|
|
162
|
+
}
|
|
163
|
+
if (afterLine !== undefined) {
|
|
164
|
+
diff.push(`+${i + 1}: ${afterLine}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return diff;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Create a hash of file content
|
|
173
|
+
*/
|
|
174
|
+
hashContent(content) {
|
|
175
|
+
return crypto.createHash('md5').update(content).digest('hex');
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Watch a directory for changes
|
|
179
|
+
*/
|
|
180
|
+
watchDirectory(dirPath) {
|
|
181
|
+
try {
|
|
182
|
+
const watcher = fs.watch(dirPath, { recursive: true }, (eventType, filename) => {
|
|
183
|
+
if (filename && !this.shouldIgnore(filename)) {
|
|
184
|
+
this.handleFileEvent(path.join(dirPath, filename), eventType);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
this.watchers.push(watcher);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error(`Failed to watch directory ${dirPath}:`, error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Check if a file should be ignored
|
|
195
|
+
*/
|
|
196
|
+
shouldIgnore(filePath) {
|
|
197
|
+
for (const pattern of this.config.ignorePatterns) {
|
|
198
|
+
if (pattern.includes('*')) {
|
|
199
|
+
const regex = new RegExp(pattern.replace('*', '.*'));
|
|
200
|
+
if (regex.test(filePath))
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
if (filePath.includes(pattern))
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Handle a file system event
|
|
212
|
+
*/
|
|
213
|
+
handleFileEvent(filePath, eventType) {
|
|
214
|
+
const normalizedPath = path.normalize(filePath);
|
|
215
|
+
const previousHash = this.fileHashes.get(normalizedPath);
|
|
216
|
+
try {
|
|
217
|
+
if (fs.existsSync(filePath)) {
|
|
218
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
219
|
+
const newHash = this.hashContent(content);
|
|
220
|
+
if (previousHash !== newHash) {
|
|
221
|
+
this.fileHashes.set(normalizedPath, newHash);
|
|
222
|
+
if (previousHash === undefined) {
|
|
223
|
+
// New file or first time seeing it
|
|
224
|
+
this.trackCreate(normalizedPath, content);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Modified file
|
|
228
|
+
this.trackEdit(normalizedPath, '', content); // We don't have old content in watch mode
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (previousHash !== undefined) {
|
|
233
|
+
// File was deleted
|
|
234
|
+
this.fileHashes.delete(normalizedPath);
|
|
235
|
+
this.trackDelete(normalizedPath, '');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
// File might be locked or inaccessible
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create an automatic checkpoint
|
|
244
|
+
*/
|
|
245
|
+
createAutoCheckpoint() {
|
|
246
|
+
const checkpointName = `auto-${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
247
|
+
this.statecli.checkpoint('session:current', checkpointName);
|
|
248
|
+
this.changeCount = 0;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.FileTracker = FileTracker;
|
|
252
|
+
//# sourceMappingURL=file-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tracker.js","sourceRoot":"","sources":["../src/file-tracker.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AAmBjC,MAAM,cAAc,GAAsB;IACxC,UAAU,EAAE,CAAC,GAAG,CAAC;IACjB,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC;IACtE,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,EAAE;CACxB,CAAC;AAEF,MAAa,WAAW;IACd,QAAQ,CAAW;IACnB,MAAM,CAAoB;IAC1B,UAAU,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC5C,WAAW,GAAW,CAAC,CAAC;IACxB,QAAQ,GAAmB,EAAE,CAAC;IAEtC,YAAY,QAAkB,EAAE,MAAmC;QACjE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH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C,OAAO,KAAK,EAAE,CAAC;YACf,uCAAuC;QACzC,CAAC;IACH,CAAC;IAED;;OAEG;IACK,oBAAoB;QAC1B,MAAM,cAAc,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACvB,CAAC;CACF;AA5OD,kCA4OC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Integration - Track changes between commits
|
|
3
|
+
*
|
|
4
|
+
* Integrates with git to provide commit-level state tracking
|
|
5
|
+
*/
|
|
6
|
+
import { StateCLI } from './statecli';
|
|
7
|
+
export interface GitCommit {
|
|
8
|
+
hash: string;
|
|
9
|
+
shortHash: string;
|
|
10
|
+
message: string;
|
|
11
|
+
author: string;
|
|
12
|
+
date: string;
|
|
13
|
+
files: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface GitDiff {
|
|
16
|
+
file: string;
|
|
17
|
+
additions: number;
|
|
18
|
+
deletions: number;
|
|
19
|
+
changes: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface CommitComparison {
|
|
22
|
+
fromCommit: string;
|
|
23
|
+
toCommit: string;
|
|
24
|
+
files: GitDiff[];
|
|
25
|
+
summary: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class GitIntegration {
|
|
28
|
+
private statecli;
|
|
29
|
+
private repoPath;
|
|
30
|
+
constructor(statecli: StateCLI, repoPath?: string);
|
|
31
|
+
/**
|
|
32
|
+
* Check if current directory is a git repository
|
|
33
|
+
*/
|
|
34
|
+
isGitRepo(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get current branch name
|
|
37
|
+
*/
|
|
38
|
+
getCurrentBranch(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get current commit hash
|
|
41
|
+
*/
|
|
42
|
+
getCurrentCommit(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get recent commits
|
|
45
|
+
*/
|
|
46
|
+
getRecentCommits(count?: number): GitCommit[];
|
|
47
|
+
/**
|
|
48
|
+
* Get files changed in a commit
|
|
49
|
+
*/
|
|
50
|
+
getCommitFiles(commitHash: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Compare two commits
|
|
53
|
+
*/
|
|
54
|
+
compareCommits(fromCommit: string, toCommit: string): CommitComparison;
|
|
55
|
+
/**
|
|
56
|
+
* Get diff for a specific file between commits
|
|
57
|
+
*/
|
|
58
|
+
getFileDiff(fromCommit: string, toCommit: string, filePath: string): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Track current git state in StateCLI
|
|
61
|
+
*/
|
|
62
|
+
trackGitState(actor?: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Create a checkpoint at current git state
|
|
65
|
+
*/
|
|
66
|
+
createGitCheckpoint(name?: string): {
|
|
67
|
+
checkpointId: string;
|
|
68
|
+
commit: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Get what happened between two commits in StateCLI format
|
|
72
|
+
*/
|
|
73
|
+
getCommitHistory(fromCommit: string, toCommit: string): {
|
|
74
|
+
commits: GitCommit[];
|
|
75
|
+
comparison: CommitComparison;
|
|
76
|
+
stateChanges: ReturnType<StateCLI['replay']>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Get commits between two commit hashes
|
|
80
|
+
*/
|
|
81
|
+
private getCommitsBetween;
|
|
82
|
+
/**
|
|
83
|
+
* Get uncommitted changes
|
|
84
|
+
*/
|
|
85
|
+
getUncommittedChanges(): {
|
|
86
|
+
staged: string[];
|
|
87
|
+
unstaged: string[];
|
|
88
|
+
untracked: string[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Execute a git command
|
|
92
|
+
*/
|
|
93
|
+
private execGit;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=git-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-integration.d.ts","sourceRoot":"","sources":["../src/git-integration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAE,MAAY;IAKtD;;OAEG;IACH,SAAS,IAAI,OAAO;IASpB;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;OAEG;IACH,gBAAgB,CAAC,KAAK,GAAE,MAAW,GAAG,SAAS,EAAE;IAYjD;;OAEG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAS5C;;OAEG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAwBtE;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAS7E;;OAEG;IACH,aAAa,CAAC,KAAK,GAAE,MAA0B,GAAG,IAAI;IAiBtD;;OAEG;IACH,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAY5E;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;QACtD,OAAO,EAAE,SAAS,EAAE,CAAC;QACrB,UAAU,EAAE,gBAAgB,CAAC;QAC7B,YAAY,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;KAC9C;IAaD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgBzB;;OAEG;IACH,qBAAqB,IAAI;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE;IAQtF;;OAEG;IACH,OAAO,CAAC,OAAO;CAWhB"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Git Integration - Track changes between commits
|
|
4
|
+
*
|
|
5
|
+
* Integrates with git to provide commit-level state tracking
|
|
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.GitIntegration = void 0;
|
|
42
|
+
const child_process_1 = require("child_process");
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
class GitIntegration {
|
|
45
|
+
statecli;
|
|
46
|
+
repoPath;
|
|
47
|
+
constructor(statecli, repoPath = '.') {
|
|
48
|
+
this.statecli = statecli;
|
|
49
|
+
this.repoPath = path.resolve(repoPath);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if current directory is a git repository
|
|
53
|
+
*/
|
|
54
|
+
isGitRepo() {
|
|
55
|
+
try {
|
|
56
|
+
this.execGit('rev-parse --git-dir');
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get current branch name
|
|
65
|
+
*/
|
|
66
|
+
getCurrentBranch() {
|
|
67
|
+
return this.execGit('rev-parse --abbrev-ref HEAD').trim();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get current commit hash
|
|
71
|
+
*/
|
|
72
|
+
getCurrentCommit() {
|
|
73
|
+
return this.execGit('rev-parse HEAD').trim();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get recent commits
|
|
77
|
+
*/
|
|
78
|
+
getRecentCommits(count = 10) {
|
|
79
|
+
const format = '%H|%h|%s|%an|%ai';
|
|
80
|
+
const log = this.execGit(`log -${count} --pretty=format:"${format}"`);
|
|
81
|
+
return log.split('\n').filter(line => line.trim()).map(line => {
|
|
82
|
+
const [hash, shortHash, message, author, date] = line.split('|');
|
|
83
|
+
const files = this.getCommitFiles(hash);
|
|
84
|
+
return { hash, shortHash, message, author, date, files };
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get files changed in a commit
|
|
89
|
+
*/
|
|
90
|
+
getCommitFiles(commitHash) {
|
|
91
|
+
try {
|
|
92
|
+
const output = this.execGit(`diff-tree --no-commit-id --name-only -r ${commitHash}`);
|
|
93
|
+
return output.split('\n').filter(f => f.trim());
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Compare two commits
|
|
101
|
+
*/
|
|
102
|
+
compareCommits(fromCommit, toCommit) {
|
|
103
|
+
const diffOutput = this.execGit(`diff --stat ${fromCommit}..${toCommit}`);
|
|
104
|
+
const files = [];
|
|
105
|
+
// Parse diff stat output
|
|
106
|
+
const lines = diffOutput.split('\n');
|
|
107
|
+
for (const line of lines) {
|
|
108
|
+
const match = line.match(/^\s*(.+?)\s+\|\s+(\d+)\s+(\++)?(-+)?/);
|
|
109
|
+
if (match) {
|
|
110
|
+
const [, file, total, additions, deletions] = match;
|
|
111
|
+
files.push({
|
|
112
|
+
file: file.trim(),
|
|
113
|
+
additions: (additions || '').length,
|
|
114
|
+
deletions: (deletions || '').length,
|
|
115
|
+
changes: this.getFileDiff(fromCommit, toCommit, file.trim())
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const summary = `Comparing ${fromCommit.substring(0, 7)} to ${toCommit.substring(0, 7)}: ${files.length} files changed`;
|
|
120
|
+
return { fromCommit, toCommit, files, summary };
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get diff for a specific file between commits
|
|
124
|
+
*/
|
|
125
|
+
getFileDiff(fromCommit, toCommit, filePath) {
|
|
126
|
+
try {
|
|
127
|
+
const diff = this.execGit(`diff ${fromCommit}..${toCommit} -- "${filePath}"`);
|
|
128
|
+
return diff.split('\n').slice(0, 100); // Limit to 100 lines
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Track current git state in StateCLI
|
|
136
|
+
*/
|
|
137
|
+
trackGitState(actor = 'git-integration') {
|
|
138
|
+
const branch = this.getCurrentBranch();
|
|
139
|
+
const commit = this.getCurrentCommit();
|
|
140
|
+
const recentCommits = this.getRecentCommits(5);
|
|
141
|
+
this.statecli.track('git', 'state', {
|
|
142
|
+
branch,
|
|
143
|
+
commit,
|
|
144
|
+
shortCommit: commit.substring(0, 7),
|
|
145
|
+
recentCommits: recentCommits.map(c => ({
|
|
146
|
+
hash: c.shortHash,
|
|
147
|
+
message: c.message
|
|
148
|
+
})),
|
|
149
|
+
timestamp: new Date().toISOString()
|
|
150
|
+
}, actor);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create a checkpoint at current git state
|
|
154
|
+
*/
|
|
155
|
+
createGitCheckpoint(name) {
|
|
156
|
+
const commit = this.getCurrentCommit();
|
|
157
|
+
const checkpointName = name || `git-${commit.substring(0, 7)}`;
|
|
158
|
+
const result = this.statecli.checkpoint('git:state', checkpointName);
|
|
159
|
+
return {
|
|
160
|
+
checkpointId: result.id,
|
|
161
|
+
commit
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get what happened between two commits in StateCLI format
|
|
166
|
+
*/
|
|
167
|
+
getCommitHistory(fromCommit, toCommit) {
|
|
168
|
+
// Get commits between the two
|
|
169
|
+
const commits = this.getCommitsBetween(fromCommit, toCommit);
|
|
170
|
+
// Get comparison
|
|
171
|
+
const comparison = this.compareCommits(fromCommit, toCommit);
|
|
172
|
+
// Get StateCLI state changes during this period
|
|
173
|
+
const stateChanges = this.statecli.replay('git:state');
|
|
174
|
+
return { commits, comparison, stateChanges };
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get commits between two commit hashes
|
|
178
|
+
*/
|
|
179
|
+
getCommitsBetween(fromCommit, toCommit) {
|
|
180
|
+
const format = '%H|%h|%s|%an|%ai';
|
|
181
|
+
try {
|
|
182
|
+
const log = this.execGit(`log ${fromCommit}..${toCommit} --pretty=format:"${format}"`);
|
|
183
|
+
return log.split('\n').filter(line => line.trim()).map(line => {
|
|
184
|
+
const [hash, shortHash, message, author, date] = line.split('|');
|
|
185
|
+
const files = this.getCommitFiles(hash);
|
|
186
|
+
return { hash, shortHash, message, author, date, files };
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get uncommitted changes
|
|
195
|
+
*/
|
|
196
|
+
getUncommittedChanges() {
|
|
197
|
+
const staged = this.execGit('diff --cached --name-only').split('\n').filter(f => f.trim());
|
|
198
|
+
const unstaged = this.execGit('diff --name-only').split('\n').filter(f => f.trim());
|
|
199
|
+
const untracked = this.execGit('ls-files --others --exclude-standard').split('\n').filter(f => f.trim());
|
|
200
|
+
return { staged, unstaged, untracked };
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Execute a git command
|
|
204
|
+
*/
|
|
205
|
+
execGit(command) {
|
|
206
|
+
try {
|
|
207
|
+
return (0, child_process_1.execSync)(`git ${command}`, {
|
|
208
|
+
cwd: this.repoPath,
|
|
209
|
+
encoding: 'utf-8',
|
|
210
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
throw new Error(`Git command failed: ${error.message}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.GitIntegration = GitIntegration;
|
|
219
|
+
//# sourceMappingURL=git-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-integration.js","sourceRoot":"","sources":["../src/git-integration.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAyC;AACzC,2CAA6B;AA0B7B,MAAa,cAAc;IACjB,QAAQ,CAAW;IACnB,QAAQ,CAAS;IAEzB,YAAY,QAAkB,EAAE,WAAmB,GAAG;QACpD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI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C3F,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACpF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAEzG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED;;OAEG;IACK,OAAO,CAAC,OAAe;QAC7B,IAAI,CAAC;YACH,OAAO,IAAA,wBAAQ,EAAC,OAAO,OAAO,EAAE,EAAE;gBAChC,GAAG,EAAE,IAAI,CAAC,QAAQ;gBAClB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF;AAxMD,wCAwMC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* StateCLI Enhanced MCP Server Entry Point
|
|
4
|
+
*
|
|
5
|
+
* Includes all advanced features:
|
|
6
|
+
* - File tracking with diffs
|
|
7
|
+
* - Error recovery and auto-rollback
|
|
8
|
+
* - Session memory and cross-session queries
|
|
9
|
+
* - Git integration
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=index-enhanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-enhanced.d.ts","sourceRoot":"","sources":["../src/index-enhanced.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* StateCLI Enhanced MCP Server Entry Point
|
|
5
|
+
*
|
|
6
|
+
* Includes all advanced features:
|
|
7
|
+
* - File tracking with diffs
|
|
8
|
+
* - Error recovery and auto-rollback
|
|
9
|
+
* - Session memory and cross-session queries
|
|
10
|
+
* - Git integration
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const enhanced_mcp_server_1 = require("./enhanced-mcp-server");
|
|
14
|
+
const server = new enhanced_mcp_server_1.EnhancedStateCLIMCPServer();
|
|
15
|
+
process.on('SIGINT', () => {
|
|
16
|
+
server.close();
|
|
17
|
+
process.exit(0);
|
|
18
|
+
});
|
|
19
|
+
process.on('SIGTERM', () => {
|
|
20
|
+
server.close();
|
|
21
|
+
process.exit(0);
|
|
22
|
+
});
|
|
23
|
+
server.run().catch((error) => {
|
|
24
|
+
console.error('Failed to start enhanced server:', error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=index-enhanced.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-enhanced.js","sourceRoot":"","sources":["../src/index-enhanced.ts"],"names":[],"mappings":";;AACA;;;;;;;;GAQG;;AAEH,+DAAkE;AAElE,MAAM,MAAM,GAAG,IAAI,+CAAyB,EAAE,CAAC;AAE/C,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|