nulladrift 0.1.1 → 0.1.3
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 +82 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -275,6 +275,11 @@ function anchorCwd(server2, projectRoot) {
|
|
|
275
275
|
if (transport2.type !== "stdio" || transport2.cwd === void 0 || isAbsolute(transport2.cwd)) return server2;
|
|
276
276
|
return { ...server2, transport: { ...transport2, cwd: resolve2(projectRoot, transport2.cwd) } };
|
|
277
277
|
}
|
|
278
|
+
function describeSearch(searched, filesRead) {
|
|
279
|
+
const read = new Set(filesRead);
|
|
280
|
+
const lines = searched.map((path) => ` ${(read.has(path) ? "read" : "absent").padEnd(6)} ${path}`);
|
|
281
|
+
return lines.join("\n");
|
|
282
|
+
}
|
|
278
283
|
async function discoverServers(projectRoot, extraFiles = []) {
|
|
279
284
|
const context = { workspaceFolder: projectRoot, env: process.env };
|
|
280
285
|
const files = [
|
|
@@ -319,6 +324,7 @@ async function discoverServers(projectRoot, extraFiles = []) {
|
|
|
319
324
|
servers: [...byName2.values()].map((entry) => entry.server).sort((a, b) => a.name.localeCompare(b.name)),
|
|
320
325
|
skipped,
|
|
321
326
|
filesRead,
|
|
327
|
+
searched: files.map((file) => file.path),
|
|
322
328
|
shadowed,
|
|
323
329
|
problems
|
|
324
330
|
};
|
|
@@ -654,7 +660,7 @@ import { dirname, join as join2 } from "path";
|
|
|
654
660
|
import { ClientCredentialsProvider, UnauthorizedError } from "@modelcontextprotocol/client";
|
|
655
661
|
|
|
656
662
|
// src/lib/version.ts
|
|
657
|
-
var VERSION = "0.1.
|
|
663
|
+
var VERSION = "0.1.3";
|
|
658
664
|
var USER_AGENT = `nulladrift/${VERSION}`;
|
|
659
665
|
|
|
660
666
|
// src/mcp/oauth.ts
|
|
@@ -1448,6 +1454,43 @@ function diffLockfiles(before, after) {
|
|
|
1448
1454
|
return sortChanges(changes);
|
|
1449
1455
|
}
|
|
1450
1456
|
|
|
1457
|
+
// ../core/src/lock/reseal.ts
|
|
1458
|
+
function sealMember(member) {
|
|
1459
|
+
const { digest: _discarded, ...body } = member;
|
|
1460
|
+
return { ...body, digest: digest(toJson(body)) };
|
|
1461
|
+
}
|
|
1462
|
+
function reseal(entry) {
|
|
1463
|
+
switch (entry.kind) {
|
|
1464
|
+
case "mcp-server":
|
|
1465
|
+
return resealMcpServer(entry);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
function resealMcpServer(entry) {
|
|
1469
|
+
const tools = (entry.tools ?? []).map((tool2) => sealMember(tool2));
|
|
1470
|
+
const resources = (entry.resources ?? []).map((resource2) => sealMember(resource2));
|
|
1471
|
+
const resourceTemplates = (entry.resourceTemplates ?? []).map((template) => sealMember(template));
|
|
1472
|
+
const prompts = (entry.prompts ?? []).map((prompt2) => sealMember(prompt2));
|
|
1473
|
+
const covered = {
|
|
1474
|
+
transport: entry.transport,
|
|
1475
|
+
protocol: entry.protocol,
|
|
1476
|
+
serverInfo: entry.serverInfo,
|
|
1477
|
+
capabilities: entry.capabilities,
|
|
1478
|
+
instructions: entry.instructions,
|
|
1479
|
+
tools: tools.map((tool2) => tool2.digest),
|
|
1480
|
+
resources: resources.map((resource2) => resource2.digest),
|
|
1481
|
+
resourceTemplates: resourceTemplates.map((template) => template.digest),
|
|
1482
|
+
prompts: prompts.map((prompt2) => prompt2.digest)
|
|
1483
|
+
};
|
|
1484
|
+
return {
|
|
1485
|
+
...entry,
|
|
1486
|
+
tools: tools.length > 0 ? tools : void 0,
|
|
1487
|
+
resources: resources.length > 0 ? resources : void 0,
|
|
1488
|
+
resourceTemplates: resourceTemplates.length > 0 ? resourceTemplates : void 0,
|
|
1489
|
+
prompts: prompts.length > 0 ? prompts : void 0,
|
|
1490
|
+
digest: digest(toJson(covered))
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1451
1494
|
// src/lock/io.ts
|
|
1452
1495
|
import { readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
|
|
1453
1496
|
|
|
@@ -1714,10 +1757,21 @@ async function readLockfile(path) {
|
|
|
1714
1757
|
if (code === "ENOENT") throw new LockfileError(`no lockfile at ${path}. Run \`nulladrift init\` first.`);
|
|
1715
1758
|
throw new LockfileError(`could not read ${path}: ${error.message}`);
|
|
1716
1759
|
}
|
|
1717
|
-
|
|
1760
|
+
const lock = parseLockfile(text, path);
|
|
1761
|
+
return {
|
|
1762
|
+
...lock,
|
|
1763
|
+
subjects: Object.fromEntries(Object.entries(lock.subjects).map(([name, subject]) => [name, reseal(subject)]))
|
|
1764
|
+
};
|
|
1718
1765
|
}
|
|
1719
1766
|
async function writeLockfile(path, lock) {
|
|
1720
|
-
|
|
1767
|
+
try {
|
|
1768
|
+
await writeFile2(path, serializeLockfile(lock), "utf8");
|
|
1769
|
+
} catch (error) {
|
|
1770
|
+
const code = error.code;
|
|
1771
|
+
if (code === "ENOENT") throw new LockfileError(`cannot write ${path}: the directory does not exist. Note that --lock is resolved against --cwd.`);
|
|
1772
|
+
if (code === "EACCES" || code === "EPERM") throw new LockfileError(`cannot write ${path}: permission denied.`);
|
|
1773
|
+
throw new LockfileError(`cannot write ${path}: ${error.message}`);
|
|
1774
|
+
}
|
|
1721
1775
|
}
|
|
1722
1776
|
|
|
1723
1777
|
// src/lib/exit.ts
|
|
@@ -1753,7 +1807,9 @@ function renderChange(change2) {
|
|
|
1753
1807
|
function renderHumanReport(report) {
|
|
1754
1808
|
const lines = [];
|
|
1755
1809
|
if (report.changes.length > 0) {
|
|
1756
|
-
|
|
1810
|
+
const drifted = new Set(report.changes.map((change2) => change2.server)).size;
|
|
1811
|
+
const heading = report.serversChecked === 0 ? `Drift in ${drifted} server(s), none of which is still configured:` : `Drift in ${drifted} of ${report.serversChecked} server(s):`;
|
|
1812
|
+
lines.push("", bold(heading), "");
|
|
1757
1813
|
for (const change2 of report.changes) lines.push(...renderChange(change2), "");
|
|
1758
1814
|
const quiet = serversThatShippedNothing(report.changes);
|
|
1759
1815
|
if (quiet.length > 0) {
|
|
@@ -1836,6 +1892,7 @@ function renderJsonReport(report, exitCode) {
|
|
|
1836
1892
|
}
|
|
1837
1893
|
|
|
1838
1894
|
// src/report/sarif.ts
|
|
1895
|
+
import { isAbsolute as isAbsolute2, relative as relative2, sep as sep2 } from "path";
|
|
1839
1896
|
import { createHash as createHash3 } from "crypto";
|
|
1840
1897
|
|
|
1841
1898
|
// src/lib/meta.ts
|
|
@@ -1872,6 +1929,12 @@ var RULE_HELP = {
|
|
|
1872
1929
|
function fingerprint(change2) {
|
|
1873
1930
|
return createHash3("sha256").update(`${change2.kind}\0${change2.server}\0${change2.member ?? ""}`).digest("hex").slice(0, 32);
|
|
1874
1931
|
}
|
|
1932
|
+
function sarifUri(report) {
|
|
1933
|
+
if (report.projectRoot === void 0) return report.lockPath;
|
|
1934
|
+
const rel = relative2(report.projectRoot, report.lockPath);
|
|
1935
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) return report.lockPath;
|
|
1936
|
+
return rel.split(sep2).join("/");
|
|
1937
|
+
}
|
|
1875
1938
|
function renderSarifReport(report) {
|
|
1876
1939
|
const used = [...new Set(report.changes.map((change2) => change2.kind))].sort();
|
|
1877
1940
|
const document = {
|
|
@@ -1900,7 +1963,7 @@ function renderSarifReport(report) {
|
|
|
1900
1963
|
message: { text: change2.member ? `${change2.server} \u203A ${change2.member}: ${change2.summary}` : `${change2.server}: ${change2.summary}` },
|
|
1901
1964
|
locations: [
|
|
1902
1965
|
{
|
|
1903
|
-
physicalLocation: { artifactLocation: { uri: report
|
|
1966
|
+
physicalLocation: { artifactLocation: { uri: sarifUri(report), uriBaseId: "%SRCROOT%" } },
|
|
1904
1967
|
logicalLocations: [{ name: change2.member ?? change2.server, fullyQualifiedName: change2.member ? `${change2.server}/${change2.member}` : change2.server, kind: "member" }]
|
|
1905
1968
|
}
|
|
1906
1969
|
],
|
|
@@ -2123,7 +2186,8 @@ async function buildReport(options) {
|
|
|
2123
2186
|
changes,
|
|
2124
2187
|
unreachable: result.unreachable,
|
|
2125
2188
|
serversChecked: Object.keys(result.lock.subjects).length,
|
|
2126
|
-
lockPath: options.lockPath
|
|
2189
|
+
lockPath: options.lockPath,
|
|
2190
|
+
projectRoot: options.projectRoot
|
|
2127
2191
|
};
|
|
2128
2192
|
return {
|
|
2129
2193
|
report,
|
|
@@ -2293,9 +2357,14 @@ async function runInit(options) {
|
|
|
2293
2357
|
const names = Object.keys(result.lock.subjects);
|
|
2294
2358
|
if (names.length === 0 && result.unreachable.length === 0) {
|
|
2295
2359
|
process.stderr.write(
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2360
|
+
[
|
|
2361
|
+
"No MCP servers found.",
|
|
2362
|
+
dim("Looked in:"),
|
|
2363
|
+
dim(describeSearch(result.discovery.searched, result.discovery.filesRead)),
|
|
2364
|
+
dim("Nothing was written. `nulladrift check` needs a lockfile, so it will fail until a"),
|
|
2365
|
+
dim("config declaring at least one server exists."),
|
|
2366
|
+
""
|
|
2367
|
+
].join("\n")
|
|
2299
2368
|
);
|
|
2300
2369
|
return EXIT_CLEAN;
|
|
2301
2370
|
}
|
|
@@ -2514,11 +2583,12 @@ async function runPush(options) {
|
|
|
2514
2583
|
const apiUrl = (options.apiUrl ?? process.env["NULLADRIFT_API_URL"] ?? "").replace(/\/+$/, "");
|
|
2515
2584
|
const token = options.token ?? process.env["NULLADRIFT_TOKEN"] ?? "";
|
|
2516
2585
|
if (!apiUrl || !token) {
|
|
2586
|
+
const missing = !apiUrl && !token ? "a control plane to push to, and a token" : !apiUrl ? "a control plane to push to" : "a collector token";
|
|
2517
2587
|
process.stderr.write(
|
|
2518
2588
|
[
|
|
2519
|
-
red(
|
|
2520
|
-
dim(" --api <url> or NULLADRIFT_API_URL"),
|
|
2521
|
-
dim(" --token <token> or NULLADRIFT_TOKEN"),
|
|
2589
|
+
red(`push needs ${missing}.`),
|
|
2590
|
+
...!apiUrl ? [dim(" --api <url> or NULLADRIFT_API_URL")] : [],
|
|
2591
|
+
...!token ? [dim(" --token <token> or NULLADRIFT_TOKEN")] : [],
|
|
2522
2592
|
""
|
|
2523
2593
|
].join("\n")
|
|
2524
2594
|
);
|