readfirst 0.6.0 → 0.6.2
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 +2 -1
- package/src/cli.mjs +17 -10
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "readfirst",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"mcpName": "io.github.jeonghun917/readfirst",
|
|
4
5
|
"description": "What to read and check before you (or your AI agent) change a file: project rules, risks and tests tied to code.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"license": "MIT",
|
package/src/cli.mjs
CHANGED
|
@@ -218,6 +218,23 @@ export function main(argv, io = { out: (s) => process.stdout.write(s), err: (s)
|
|
|
218
218
|
if (out) io.out(`${out}\n`);
|
|
219
219
|
return 0;
|
|
220
220
|
}
|
|
221
|
+
if (cmd === 'mcp') {
|
|
222
|
+
// The server starts and answers initialize and tools/list anywhere, also outside a git repository (directories
|
|
223
|
+
// start it in an empty container to check it). The repository is looked up at each tool call.
|
|
224
|
+
const version = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
225
|
+
const run = (argv) => {
|
|
226
|
+
let out = ''; let err = ''; let code;
|
|
227
|
+
try {
|
|
228
|
+
const root = args.root ?? (() => {
|
|
229
|
+
try { return git(process.cwd(), 'rev-parse', '--show-toplevel').trim(); } catch { throw new Error(`not inside a git repository (${process.cwd()}): start the server in your repository, or pass --root <dir>`); }
|
|
230
|
+
})();
|
|
231
|
+
code = main(['--root', root, ...argv], { out: (s) => { out += s; }, err: (s) => { err += s; } });
|
|
232
|
+
} catch (e) { code = 2; err += e.message; }
|
|
233
|
+
return { code, out, err };
|
|
234
|
+
};
|
|
235
|
+
serveMcp({ handle: mcpHandler({ run, version }), input: process.stdin, output: process.stdout });
|
|
236
|
+
return 0;
|
|
237
|
+
}
|
|
221
238
|
const root = args.root ?? git(process.cwd(), 'rev-parse', '--show-toplevel').trim();
|
|
222
239
|
const files = repoFiles(root);
|
|
223
240
|
const commit = (() => { try { return git(root, 'rev-parse', 'HEAD').trim(); } catch { return null; } })();
|
|
@@ -298,16 +315,6 @@ export function main(argv, io = { out: (s) => process.stdout.write(s), err: (s)
|
|
|
298
315
|
io.out(args.json ? `${JSON.stringify(list, null, 2)}\n` : `${toMarkdown(list)}\n`);
|
|
299
316
|
return 0;
|
|
300
317
|
}
|
|
301
|
-
if (cmd === 'mcp') {
|
|
302
|
-
const version = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
303
|
-
const run = (argv) => {
|
|
304
|
-
let out = ''; let err = ''; let code;
|
|
305
|
-
try { code = main(['--root', root, ...argv], { out: (s) => { out += s; }, err: (s) => { err += s; } }); } catch (e) { code = 2; err += e.message; }
|
|
306
|
-
return { code, out, err };
|
|
307
|
-
};
|
|
308
|
-
serveMcp({ handle: mcpHandler({ run, version }), input: process.stdin, output: process.stdout });
|
|
309
|
-
return 0;
|
|
310
|
-
}
|
|
311
318
|
if (cmd === 'verify') {
|
|
312
319
|
const map = loadMapLenient(root, files, io);
|
|
313
320
|
const changed = changedFiles(root, args.base);
|