@stage-labs/metro 0.1.0-beta.128 → 0.1.0-beta.129
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stage-labs/metro",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.129",
|
|
4
4
|
"description": "The metro command line. Sign in once per machine, then hand your MCP connector list to Claude Code without the credentials touching disk, argv or shell history.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.129",
|
|
4
4
|
"description": "Metro for Claude Code, installed by the metro daemon on this machine: every connector the agent holds as its own MCP server relayed through the daemon, the orchestrator-only guard on the main thread, the standing rules loaded at each session start, and a refresh skill for when the daemon could not keep the server list current. No vendor credential ever sits in a config file.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bonustrack",
|
|
@@ -104,11 +104,17 @@ const seenIn = (body: Record<string, unknown>): string | null | undefined =>
|
|
|
104
104
|
|
|
105
105
|
const WRITE_HEADS = new Set(['settings', 'skills', 'memory', 'sessions']);
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
interface Write {
|
|
108
|
+
text: string;
|
|
109
|
+
seen: string | null | undefined;
|
|
110
|
+
modifiedAt: string | undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function writeItem(head: string, item: string, write: Write, search: string, dir: string): unknown {
|
|
114
|
+
if (head === 'skills') return writeClaudeSkill(decodeURIComponent(item), write.text, write.seen, dir);
|
|
115
|
+
if (head === 'sessions') return writeSessionFile(projectOf(new URLSearchParams(search)), item, write.text, dir);
|
|
116
|
+
if (head === 'memory') return writeMemoryFile(projectOf(new URLSearchParams(search)), decodeURIComponent(item), write.text, dir, write.modifiedAt);
|
|
117
|
+
return writeClaudeSettings(item, write.text, write.seen, dir);
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
async function writeAnswer(req: IncomingMessage, path: string, search: string, dir: string): Promise<unknown> {
|
|
@@ -116,7 +122,8 @@ async function writeAnswer(req: IncomingMessage, path: string, search: string, d
|
|
|
116
122
|
if (!WRITE_HEADS.has(head) || item === '') throw new ApiError('method not allowed', 405);
|
|
117
123
|
const body = await readJsonBody(req, head === 'sessions' ? SESSION_BODY_MAX : BODY_MAX);
|
|
118
124
|
if (!isRecord(body) || typeof body.text !== 'string') throw new ApiError('text is required', 400);
|
|
119
|
-
|
|
125
|
+
const modifiedAt = typeof body.modifiedAt === 'string' ? body.modifiedAt : undefined;
|
|
126
|
+
return writeItem(head, item, { text: body.text, seen: seenIn(body), modifiedAt }, search, dir);
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
async function created(req: IncomingMessage, path: string, dir: string): Promise<unknown> {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
renameSync,
|
|
10
10
|
rmSync,
|
|
11
11
|
statSync,
|
|
12
|
+
utimesSync,
|
|
12
13
|
writeFileSync,
|
|
13
14
|
} from 'node:fs';
|
|
14
15
|
import { homedir } from 'node:os';
|
|
@@ -322,12 +323,18 @@ export function listMemory(project: string, dir = claudeDir()): MemoryListing {
|
|
|
322
323
|
const s = statSync(join(path, name));
|
|
323
324
|
return { name, bytes: s.size, modifiedAt: s.mtime.toISOString() };
|
|
324
325
|
})
|
|
325
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
326
|
+
.sort((a, b) => b.modifiedAt.localeCompare(a.modifiedAt) || a.name.localeCompare(b.name));
|
|
326
327
|
const index = join(path, 'MEMORY.md');
|
|
327
328
|
return { files, index: existsSync(index) ? readCapped(index) : null };
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
|
|
331
|
+
const stampOf = (raw: string | undefined): Date | null => {
|
|
332
|
+
if (raw === undefined) return null;
|
|
333
|
+
const at = new Date(raw);
|
|
334
|
+
return Number.isNaN(at.getTime()) ? null : at;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export function writeMemoryFile(project: string, name: string, text: string, dir = claudeDir(), modifiedAt?: string): MemoryFile {
|
|
331
338
|
if (text.trim() === '') throw new ApiError('a memory file cannot be empty', 400);
|
|
332
339
|
if (Buffer.byteLength(text, 'utf8') > MEMORY_MAX)
|
|
333
340
|
throw new ApiError(`a memory file is at most ${String(MEMORY_MAX)} bytes`, 400);
|
|
@@ -338,6 +345,8 @@ export function writeMemoryFile(project: string, name: string, text: string, dir
|
|
|
338
345
|
const tmp = `${path}.metro-${String(process.pid)}`;
|
|
339
346
|
writeFileSync(tmp, text, { mode: MEMORY_MODE });
|
|
340
347
|
renameSync(tmp, path);
|
|
348
|
+
const stamp = stampOf(modifiedAt);
|
|
349
|
+
if (stamp !== null) utimesSync(path, stamp, stamp);
|
|
341
350
|
const stat = statSync(path);
|
|
342
351
|
return { name: file, bytes: stat.size, modifiedAt: stat.mtime.toISOString() };
|
|
343
352
|
}
|
package/runtime/runtime.json
CHANGED