nulladrift 0.1.1 → 0.1.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/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.1";
663
+ var VERSION = "0.1.2";
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
- return parseLockfile(text, path);
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
- await writeFile2(path, serializeLockfile(lock), "utf8");
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
- lines.push("", bold(`Drift in ${new Set(report.changes.map((change2) => change2.server)).size} of ${report.serversChecked} server(s):`), "");
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) {
@@ -2293,9 +2349,14 @@ async function runInit(options) {
2293
2349
  const names = Object.keys(result.lock.subjects);
2294
2350
  if (names.length === 0 && result.unreachable.length === 0) {
2295
2351
  process.stderr.write(
2296
- `No MCP servers found.
2297
- ${dim(`Looked in: ${result.discovery.filesRead.length > 0 ? result.discovery.filesRead.join(", ") : "no client config files exist for this project"}`)}
2298
- `
2352
+ [
2353
+ "No MCP servers found.",
2354
+ dim("Looked in:"),
2355
+ dim(describeSearch(result.discovery.searched, result.discovery.filesRead)),
2356
+ dim("Nothing was written. `nulladrift check` needs a lockfile, so it will fail until a"),
2357
+ dim("config declaring at least one server exists."),
2358
+ ""
2359
+ ].join("\n")
2299
2360
  );
2300
2361
  return EXIT_CLEAN;
2301
2362
  }
@@ -2514,11 +2575,12 @@ async function runPush(options) {
2514
2575
  const apiUrl = (options.apiUrl ?? process.env["NULLADRIFT_API_URL"] ?? "").replace(/\/+$/, "");
2515
2576
  const token = options.token ?? process.env["NULLADRIFT_TOKEN"] ?? "";
2516
2577
  if (!apiUrl || !token) {
2578
+ const missing = !apiUrl && !token ? "a control plane to push to, and a token" : !apiUrl ? "a control plane to push to" : "a collector token";
2517
2579
  process.stderr.write(
2518
2580
  [
2519
- red("push needs a control plane to push to."),
2520
- dim(" --api <url> or NULLADRIFT_API_URL"),
2521
- dim(" --token <token> or NULLADRIFT_TOKEN"),
2581
+ red(`push needs ${missing}.`),
2582
+ ...!apiUrl ? [dim(" --api <url> or NULLADRIFT_API_URL")] : [],
2583
+ ...!token ? [dim(" --token <token> or NULLADRIFT_TOKEN")] : [],
2522
2584
  ""
2523
2585
  ].join("\n")
2524
2586
  );