@coderule/mcp 2.2.0 → 2.2.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/dist/cli.cjs +69 -17
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +68 -16
- package/dist/cli.js.map +1 -1
- package/dist/mcp-cli.cjs +42 -25
- package/dist/mcp-cli.cjs.map +1 -1
- package/dist/mcp-cli.js +42 -25
- package/dist/mcp-cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var fs8 = require('fs/promises');
|
|
5
5
|
var path2 = require('path');
|
|
6
|
+
var clients = require('@coderule/clients');
|
|
6
7
|
var crypto = require('crypto');
|
|
7
8
|
var envPaths = require('env-paths');
|
|
8
9
|
var pino = require('pino');
|
|
9
10
|
var os = require('os');
|
|
10
11
|
var Database = require('better-sqlite3');
|
|
11
12
|
var qulite = require('@coderule/qulite');
|
|
12
|
-
var clients = require('@coderule/clients');
|
|
13
13
|
var fs3 = require('fs');
|
|
14
14
|
var worker_threads = require('worker_threads');
|
|
15
15
|
var chokidar = require('chokidar');
|
|
16
16
|
|
|
17
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var fs8__default = /*#__PURE__*/_interopDefault(fs8);
|
|
20
20
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
21
21
|
var envPaths__default = /*#__PURE__*/_interopDefault(envPaths);
|
|
22
22
|
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
@@ -81,7 +81,7 @@ function collectCandidateSources(options) {
|
|
|
81
81
|
}
|
|
82
82
|
async function pathExists(targetPath) {
|
|
83
83
|
try {
|
|
84
|
-
await
|
|
84
|
+
await fs8__default.default.access(targetPath);
|
|
85
85
|
return true;
|
|
86
86
|
} catch {
|
|
87
87
|
return false;
|
|
@@ -89,7 +89,7 @@ async function pathExists(targetPath) {
|
|
|
89
89
|
}
|
|
90
90
|
async function isDirectory(targetPath) {
|
|
91
91
|
try {
|
|
92
|
-
const stat = await
|
|
92
|
+
const stat = await fs8__default.default.stat(targetPath);
|
|
93
93
|
return stat.isDirectory();
|
|
94
94
|
} catch {
|
|
95
95
|
return false;
|
|
@@ -273,7 +273,7 @@ async function resolveConfig({
|
|
|
273
273
|
const rootId = sha256(normalized);
|
|
274
274
|
const dataDir = process.env.CODERULE_DATA_DIR || envPaths__default.default("coderule").data;
|
|
275
275
|
const watchDir = path2__default.default.join(dataDir, "watch");
|
|
276
|
-
await
|
|
276
|
+
await fs8__default.default.mkdir(watchDir, { recursive: true });
|
|
277
277
|
const dbPath = path2__default.default.join(watchDir, `${rootId}.sqlite`);
|
|
278
278
|
const baseConfig = {
|
|
279
279
|
token: resolvedToken,
|
|
@@ -1049,7 +1049,7 @@ var Hasher = class {
|
|
|
1049
1049
|
}
|
|
1050
1050
|
async ensureExists(absPath, record) {
|
|
1051
1051
|
try {
|
|
1052
|
-
await
|
|
1052
|
+
await fs8__default.default.access(absPath);
|
|
1053
1053
|
return true;
|
|
1054
1054
|
} catch (error) {
|
|
1055
1055
|
this.log.warn(
|
|
@@ -1210,7 +1210,7 @@ function cloneStats(stats) {
|
|
|
1210
1210
|
}
|
|
1211
1211
|
async function readSymlinkTarget(absPath, log) {
|
|
1212
1212
|
try {
|
|
1213
|
-
return await
|
|
1213
|
+
return await fs8__default.default.readlink(absPath);
|
|
1214
1214
|
} catch (error) {
|
|
1215
1215
|
log.warn({ err: error, path: absPath }, "Failed to read symlink target");
|
|
1216
1216
|
return null;
|
|
@@ -1220,7 +1220,7 @@ async function walkDirectory(current, opts, stats) {
|
|
|
1220
1220
|
const dirLogger = opts.logger;
|
|
1221
1221
|
let dirents;
|
|
1222
1222
|
try {
|
|
1223
|
-
dirents = await
|
|
1223
|
+
dirents = await fs8__default.default.readdir(current, { withFileTypes: true });
|
|
1224
1224
|
} catch (error) {
|
|
1225
1225
|
dirLogger.warn({ err: error, path: current }, "Failed to read directory");
|
|
1226
1226
|
return;
|
|
@@ -1239,7 +1239,7 @@ async function walkDirectory(current, opts, stats) {
|
|
|
1239
1239
|
if (dirent.isSymbolicLink() || dirent.isFile()) {
|
|
1240
1240
|
let stat;
|
|
1241
1241
|
try {
|
|
1242
|
-
stat = await
|
|
1242
|
+
stat = await fs8__default.default.lstat(absPath);
|
|
1243
1243
|
} catch (error) {
|
|
1244
1244
|
dirLogger.warn({ err: error, path: absPath }, "Failed to stat file");
|
|
1245
1245
|
continue;
|
|
@@ -1382,7 +1382,7 @@ async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts
|
|
|
1382
1382
|
for (const missingFile of list) {
|
|
1383
1383
|
const absPath = path2__default.default.join(rootPath, missingFile.file_path);
|
|
1384
1384
|
try {
|
|
1385
|
-
const buffer = await
|
|
1385
|
+
const buffer = await fs8__default.default.readFile(absPath);
|
|
1386
1386
|
const serviceHash = computeServiceFileHash(
|
|
1387
1387
|
missingFile.file_path,
|
|
1388
1388
|
buffer
|
|
@@ -1695,7 +1695,7 @@ function computeBackoff(attempts) {
|
|
|
1695
1695
|
var PUBLISH_MAX_MS = 5 * 6e4;
|
|
1696
1696
|
async function readSymlinkTarget2(absPath) {
|
|
1697
1697
|
try {
|
|
1698
|
-
return await
|
|
1698
|
+
return await fs8__default.default.readlink(absPath);
|
|
1699
1699
|
} catch {
|
|
1700
1700
|
return null;
|
|
1701
1701
|
}
|
|
@@ -1856,7 +1856,7 @@ var ServiceRunner = class {
|
|
|
1856
1856
|
async handleAddChange(absPath, _stats) {
|
|
1857
1857
|
let fileStats;
|
|
1858
1858
|
try {
|
|
1859
|
-
fileStats = await
|
|
1859
|
+
fileStats = await fs8__default.default.lstat(absPath);
|
|
1860
1860
|
} catch (error) {
|
|
1861
1861
|
this.runtime.logger.warn(
|
|
1862
1862
|
{ err: error, path: absPath },
|
|
@@ -2166,6 +2166,8 @@ Options:
|
|
|
2166
2166
|
--max-snapshot-attempts <n> Override CODERULE_MAX_SNAPSHOT_ATTEMPTS
|
|
2167
2167
|
--upload-chunk-size <n> Override CODERULE_UPLOAD_CHUNK_SIZE (default 1)
|
|
2168
2168
|
--max-wait-time <sec> Override CODERULE_MAX_WAIT_TIME (default 50s)
|
|
2169
|
+
--dump-bush <path> Download HDF5 bush file to <path> (must end with .h5)
|
|
2170
|
+
--dump-skill Print HDF5 bush reader skill (format docs + examples)
|
|
2169
2171
|
KEY=value Set arbitrary environment variable
|
|
2170
2172
|
--help Show this message
|
|
2171
2173
|
`);
|
|
@@ -2176,6 +2178,8 @@ function parseArgs(argv) {
|
|
|
2176
2178
|
let mode = "service";
|
|
2177
2179
|
let clean = false;
|
|
2178
2180
|
let inlineHasher = false;
|
|
2181
|
+
let dumpBush;
|
|
2182
|
+
let dumpSkill = false;
|
|
2179
2183
|
const env = {};
|
|
2180
2184
|
const args = [...argv];
|
|
2181
2185
|
while (args.length > 0) {
|
|
@@ -2200,6 +2204,22 @@ function parseArgs(argv) {
|
|
|
2200
2204
|
inlineHasher = true;
|
|
2201
2205
|
continue;
|
|
2202
2206
|
}
|
|
2207
|
+
if (arg === "--dump-bush") {
|
|
2208
|
+
if (args.length === 0) {
|
|
2209
|
+
throw new Error("Option --dump-bush requires a file path");
|
|
2210
|
+
}
|
|
2211
|
+
dumpBush = args.shift();
|
|
2212
|
+
if (!dumpBush.endsWith(".h5")) {
|
|
2213
|
+
throw new Error("--dump-bush path must end with .h5");
|
|
2214
|
+
}
|
|
2215
|
+
mode = "initial";
|
|
2216
|
+
continue;
|
|
2217
|
+
}
|
|
2218
|
+
if (arg === "--dump-skill") {
|
|
2219
|
+
dumpSkill = true;
|
|
2220
|
+
mode = "initial";
|
|
2221
|
+
continue;
|
|
2222
|
+
}
|
|
2203
2223
|
if (arg === "--root") {
|
|
2204
2224
|
if (args.length === 0) {
|
|
2205
2225
|
throw new Error("Option --root requires a value");
|
|
@@ -2239,7 +2259,16 @@ function parseArgs(argv) {
|
|
|
2239
2259
|
"Missing token. Provide via argument or CODERULE_TOKEN env."
|
|
2240
2260
|
);
|
|
2241
2261
|
}
|
|
2242
|
-
return {
|
|
2262
|
+
return {
|
|
2263
|
+
token,
|
|
2264
|
+
rootPath,
|
|
2265
|
+
mode,
|
|
2266
|
+
clean,
|
|
2267
|
+
inlineHasher,
|
|
2268
|
+
dumpBush,
|
|
2269
|
+
dumpSkill,
|
|
2270
|
+
env
|
|
2271
|
+
};
|
|
2243
2272
|
}
|
|
2244
2273
|
async function ensureClean(configToken, rootPath) {
|
|
2245
2274
|
const config = await resolveConfig({ token: configToken, rootPath });
|
|
@@ -2248,13 +2277,13 @@ async function ensureClean(configToken, rootPath) {
|
|
|
2248
2277
|
`${config.dbPath}-shm`,
|
|
2249
2278
|
`${config.dbPath}-wal`
|
|
2250
2279
|
];
|
|
2251
|
-
await Promise.all(targets.map((target) =>
|
|
2252
|
-
await
|
|
2280
|
+
await Promise.all(targets.map((target) => fs8__default.default.rm(target, { force: true })));
|
|
2281
|
+
await fs8__default.default.rm(path2__default.default.join(config.dataDir, "watch", `${config.rootId}.sqlite-shm`), {
|
|
2253
2282
|
force: true
|
|
2254
2283
|
}).catch(() => {
|
|
2255
2284
|
});
|
|
2256
2285
|
const dir = path2__default.default.dirname(config.dbPath);
|
|
2257
|
-
await
|
|
2286
|
+
await fs8__default.default.mkdir(dir, { recursive: true });
|
|
2258
2287
|
console.log(`Removed scanner database at ${config.dbPath}`);
|
|
2259
2288
|
}
|
|
2260
2289
|
async function main() {
|
|
@@ -2279,6 +2308,29 @@ async function main() {
|
|
|
2279
2308
|
rootPath: options.rootPath
|
|
2280
2309
|
});
|
|
2281
2310
|
console.log("Initial sync result:", JSON.stringify(result, null, 2));
|
|
2311
|
+
if (options.dumpBush || options.dumpSkill) {
|
|
2312
|
+
const clients$1 = new clients.CoderuleClients({ token: options.token });
|
|
2313
|
+
try {
|
|
2314
|
+
await clients$1.sync.checkSnapshotStatus(result.snapshotHash);
|
|
2315
|
+
if (options.dumpBush) {
|
|
2316
|
+
const buf = await clients$1.sync.downloadSnapshotBush(
|
|
2317
|
+
result.snapshotHash
|
|
2318
|
+
);
|
|
2319
|
+
const dir = path2__default.default.dirname(options.dumpBush);
|
|
2320
|
+
await fs8__default.default.mkdir(dir, { recursive: true });
|
|
2321
|
+
await fs8__default.default.writeFile(options.dumpBush, Buffer.from(buf));
|
|
2322
|
+
console.log(
|
|
2323
|
+
`HDF5 bush saved to ${options.dumpBush} (${buf.byteLength} bytes)`
|
|
2324
|
+
);
|
|
2325
|
+
}
|
|
2326
|
+
if (options.dumpSkill) {
|
|
2327
|
+
const skill = await clients$1.sync.getHdf5BushReaderSkill();
|
|
2328
|
+
console.log(skill);
|
|
2329
|
+
}
|
|
2330
|
+
} finally {
|
|
2331
|
+
clients$1.close();
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2282
2334
|
} else {
|
|
2283
2335
|
await runService({ token: options.token, rootPath: options.rootPath });
|
|
2284
2336
|
}
|