@squidcode/forever-plugin 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.
- package/dist/index.js +80 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createApiClient } from './client.js';
|
|
|
9
9
|
import { getOrCreateMachineId } from './machine.js';
|
|
10
10
|
const server = new McpServer({
|
|
11
11
|
name: 'forever',
|
|
12
|
-
version: '0.
|
|
12
|
+
version: '0.3.0',
|
|
13
13
|
});
|
|
14
14
|
const machineId = getOrCreateMachineId();
|
|
15
15
|
const sessionId = `${Date.now()}-${randomBytes(4).toString('hex')}`;
|
|
@@ -177,6 +177,85 @@ server.tool('memory_get_recent', 'Get recent memory entries for a project', {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
|
+
server.tool('memory_get_sessions', 'Get recent sessions for a project, grouped by session with machine info. Use at startup to detect cross-machine handoffs.', {
|
|
181
|
+
project: z
|
|
182
|
+
.string()
|
|
183
|
+
.optional()
|
|
184
|
+
.describe('Project name or git remote URL (auto-detected from git if omitted)'),
|
|
185
|
+
limit: z
|
|
186
|
+
.number()
|
|
187
|
+
.optional()
|
|
188
|
+
.default(10)
|
|
189
|
+
.describe('Number of recent sessions to fetch'),
|
|
190
|
+
}, async ({ project, limit }) => {
|
|
191
|
+
const api = createApiClient();
|
|
192
|
+
if (!api) {
|
|
193
|
+
return {
|
|
194
|
+
content: [
|
|
195
|
+
{
|
|
196
|
+
type: 'text',
|
|
197
|
+
text: 'Not authenticated. Run: npx @squidcode/forever-plugin login',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const resolvedProject = resolveProject(project);
|
|
203
|
+
if (!resolvedProject) {
|
|
204
|
+
return {
|
|
205
|
+
content: [
|
|
206
|
+
{
|
|
207
|
+
type: 'text',
|
|
208
|
+
text: 'Could not detect project. Please specify a project name.',
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const res = await api.get('/logs/sessions', {
|
|
215
|
+
params: { project: resolvedProject, machineId, limit },
|
|
216
|
+
});
|
|
217
|
+
const { sessions, hasRemoteActivity } = res.data;
|
|
218
|
+
if (!sessions.length) {
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: 'text',
|
|
223
|
+
text: `No previous sessions found for "${resolvedProject}".`,
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const lines = [];
|
|
229
|
+
if (hasRemoteActivity) {
|
|
230
|
+
lines.push('⚡ REMOTE ACTIVITY DETECTED — Sessions from other machines found for this project.\n');
|
|
231
|
+
}
|
|
232
|
+
for (const s of sessions) {
|
|
233
|
+
const machine = s.machineName || 'unknown';
|
|
234
|
+
const remote = s.isRemote ? ' [REMOTE]' : ' [LOCAL]';
|
|
235
|
+
const branch = s.gitBranch ? ` on ${s.gitBranch}` : '';
|
|
236
|
+
const commit = s.gitCommit ? ` @ ${s.gitCommit}` : '';
|
|
237
|
+
lines.push(`## Session ${s.sessionId}${remote}`);
|
|
238
|
+
lines.push(`Machine: ${machine}${branch}${commit}`);
|
|
239
|
+
lines.push(`Time: ${s.startedAt} → ${s.endedAt} (${s.logCount} logs)`);
|
|
240
|
+
if (s.directory)
|
|
241
|
+
lines.push(`Directory: ${s.directory}`);
|
|
242
|
+
if (s.summary)
|
|
243
|
+
lines.push(`Summary: ${s.summary}`);
|
|
244
|
+
lines.push('');
|
|
245
|
+
}
|
|
246
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
return {
|
|
250
|
+
content: [
|
|
251
|
+
{
|
|
252
|
+
type: 'text',
|
|
253
|
+
text: `Failed to fetch sessions: ${err.message}`,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
});
|
|
180
259
|
server.tool('memory_search', 'Search memory entries across projects', {
|
|
181
260
|
query: z.string().describe('Search query'),
|
|
182
261
|
project: z.string().optional().describe('Filter by project'),
|