@eyeglass/bridge 0.1.2 → 0.1.4

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/dist/http.js CHANGED
@@ -50,7 +50,7 @@ export function startHttpServer() {
50
50
  }
51
51
  res.json({ success: true });
52
52
  });
53
- // Undo changes for a specific interaction
53
+ // Undo/discard changes for a specific interaction
54
54
  app.post('/undo', async (req, res) => {
55
55
  const { interactionId } = req.body;
56
56
  // Type validation
@@ -58,7 +58,27 @@ export function startHttpServer() {
58
58
  res.status(400).json({ error: 'Missing or invalid interactionId' });
59
59
  return;
60
60
  }
61
- const result = await store.undoInteraction(interactionId);
61
+ // Try discard first (for uncommitted changes), then undo (for committed changes)
62
+ let result = await store.discardChanges(interactionId);
63
+ if (!result.success && result.message !== 'Not a git repository') {
64
+ // If discard didn't work, try undo (revert commit)
65
+ result = await store.undoInteraction(interactionId);
66
+ }
67
+ if (!result.success) {
68
+ res.status(400).json({ error: result.message });
69
+ return;
70
+ }
71
+ res.json({ success: true, message: result.message });
72
+ });
73
+ // Commit changes for a specific interaction (when autoCommit is disabled)
74
+ app.post('/commit', (req, res) => {
75
+ const { interactionId } = req.body;
76
+ // Type validation
77
+ if (typeof interactionId !== 'string' || !interactionId) {
78
+ res.status(400).json({ error: 'Missing or invalid interactionId' });
79
+ return;
80
+ }
81
+ const result = store.manualCommit(interactionId);
62
82
  if (!result.success) {
63
83
  res.status(400).json({ error: result.message });
64
84
  return;
package/dist/mcp.js CHANGED
@@ -226,9 +226,13 @@ Handle this request now.`,
226
226
  };
227
227
  }
228
228
  store.updateStatus(active.interactionId, status, message);
229
+ // On success/failed, hint to continue listening for more requests
230
+ const continueHint = (status === 'success' || status === 'failed')
231
+ ? '\n\n**Ready for next request.** Call `wait_for_request()` to continue listening for user requests.'
232
+ : '';
229
233
  return {
230
234
  content: [
231
- { type: 'text', text: `Status updated to "${status}"${message ? `: ${message}` : ''}` },
235
+ { type: 'text', text: `Status updated to "${status}"${message ? `: ${message}` : ''}${continueHint}` },
232
236
  ],
233
237
  };
234
238
  }
package/dist/store.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class ContextStore extends EventEmitter {
7
7
  private pendingQuestion;
8
8
  private pendingWait;
9
9
  private commitMap;
10
+ private pendingCommitMessage;
10
11
  setFocus(payload: FocusPayload): void;
11
12
  /**
12
13
  * Wait for a new focus request from the browser.
@@ -33,6 +34,20 @@ export declare class ContextStore extends EventEmitter {
33
34
  message: string;
34
35
  }>;
35
36
  private revertCommit;
37
+ /**
38
+ * Manually commit changes for an interaction (when autoCommit is disabled)
39
+ */
40
+ manualCommit(interactionId: string): {
41
+ success: boolean;
42
+ message: string;
43
+ };
44
+ /**
45
+ * Discard uncommitted changes for an interaction (when autoCommit is disabled)
46
+ */
47
+ discardChanges(interactionId: string): Promise<{
48
+ success: boolean;
49
+ message: string;
50
+ }>;
36
51
  sendThought(interactionId: string, content: string): void;
37
52
  reportAction(interactionId: string, action: 'reading' | 'writing' | 'searching' | 'thinking', target: string, complete?: boolean): void;
38
53
  askQuestion(interactionId: string, questionId: string, question: string, options: Array<{
package/dist/store.js CHANGED
@@ -13,6 +13,7 @@ export class ContextStore extends EventEmitter {
13
13
  this.pendingQuestion = null;
14
14
  this.pendingWait = null;
15
15
  this.commitMap = new Map(); // interactionId -> commitHash
16
+ this.pendingCommitMessage = new Map(); // interactionId -> message (for manual commits)
16
17
  }
17
18
  setFocus(payload) {
18
19
  if (this.active) {
@@ -100,9 +101,16 @@ export class ContextStore extends EventEmitter {
100
101
  if (this.active?.interactionId !== interactionId)
101
102
  return;
102
103
  this.currentStatus = status;
103
- // Auto-commit changes when marked as success
104
+ // Auto-commit changes when marked as success (if autoCommit is enabled)
104
105
  if (status === 'success') {
105
- this.commitChanges(interactionId, message);
106
+ const shouldAutoCommit = this.active.autoCommit !== false; // Default to true
107
+ if (shouldAutoCommit) {
108
+ this.commitChanges(interactionId, message);
109
+ }
110
+ else {
111
+ // Store message for potential manual commit later
112
+ this.pendingCommitMessage.set(interactionId, message || 'Eyeglass change');
113
+ }
106
114
  }
107
115
  this.emitActivity({
108
116
  type: 'status',
@@ -193,6 +201,60 @@ export class ContextStore extends EventEmitter {
193
201
  return { success: false, message: `Failed to revert: ${errorMessage}` };
194
202
  }
195
203
  }
204
+ /**
205
+ * Manually commit changes for an interaction (when autoCommit is disabled)
206
+ */
207
+ manualCommit(interactionId) {
208
+ // Check if already committed
209
+ if (this.commitMap.has(interactionId)) {
210
+ return { success: false, message: 'Changes already committed' };
211
+ }
212
+ const commitMessage = this.pendingCommitMessage.get(interactionId) || 'Eyeglass change';
213
+ this.pendingCommitMessage.delete(interactionId);
214
+ try {
215
+ this.commitChanges(interactionId, commitMessage);
216
+ // Check if commit was successful
217
+ if (this.commitMap.has(interactionId)) {
218
+ return { success: true, message: 'Changes committed successfully' };
219
+ }
220
+ else {
221
+ return { success: false, message: 'No changes to commit' };
222
+ }
223
+ }
224
+ catch (err) {
225
+ const errorMessage = err instanceof Error ? err.message : 'Unknown error';
226
+ return { success: false, message: `Failed to commit: ${errorMessage}` };
227
+ }
228
+ }
229
+ /**
230
+ * Discard uncommitted changes for an interaction (when autoCommit is disabled)
231
+ */
232
+ async discardChanges(interactionId) {
233
+ // If already committed, use revert
234
+ if (this.commitMap.has(interactionId)) {
235
+ return this.undoInteraction(interactionId);
236
+ }
237
+ try {
238
+ const cwd = process.cwd();
239
+ // Check if we're in a git repo
240
+ try {
241
+ execFileSync('git', ['rev-parse', '--git-dir'], { cwd, stdio: 'pipe' });
242
+ }
243
+ catch {
244
+ return { success: false, message: 'Not a git repository' };
245
+ }
246
+ // Discard all uncommitted changes
247
+ execFileSync('git', ['checkout', '.'], { cwd, stdio: 'pipe' });
248
+ execFileSync('git', ['clean', '-fd'], { cwd, stdio: 'pipe' });
249
+ // Clean up pending commit message
250
+ this.pendingCommitMessage.delete(interactionId);
251
+ return { success: true, message: 'Changes discarded' };
252
+ }
253
+ catch (err) {
254
+ const errorMessage = err instanceof Error ? err.message : 'Unknown error';
255
+ return { success: false, message: `Failed to discard: ${errorMessage}` };
256
+ }
257
+ }
196
258
  // Send a thought/reasoning to the user
197
259
  sendThought(interactionId, content) {
198
260
  if (this.active?.interactionId !== interactionId)
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@eyeglass/bridge",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "MCP server bridge for Eyeglass",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "eyeglass-bridge": "./dist/index.js"
9
+ "eyeglass-bridge": "dist/index.js"
10
10
  },
11
11
  "files": [
12
12
  "dist"
@@ -26,7 +26,7 @@
26
26
  "license": "MIT",
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "https://github.com/donutboyband/eyeglass.git",
29
+ "url": "git+https://github.com/donutboyband/eyeglass.git",
30
30
  "directory": "packages/bridge"
31
31
  },
32
32
  "dependencies": {