@parity-app/cli 0.7.5 → 0.7.7

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/bin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { c as CodedError, d as errorDetails, f as readErrorDetails, i as jsonText, l as closest, s as plainObject, t as checkData, u as errorCodes } from "./schema-CemdtCeF.mjs";
3
- import { _ as requests, a as describeExec, c as describeProps, f as setCaller, g as requestJsonSchema, h as replies, i as describeConsole, l as describeStatus, m as readRequest, n as describeAccessibility, o as describeModes, p as mcpCallerName, r as describeComponents, s as describeProblems, t as call, u as describeTokens, v as skillRequest } from "./client-D6bpjpy-.mjs";
2
+ import { c as CodedError, d as errorDetails, f as readErrorDetails, i as jsonText, l as closest, s as plainObject, t as checkData, u as errorCodes } from "./schema-Dp5Jhloe.mjs";
3
+ import { _ as requests, a as describeExec, c as describeProps, f as setCaller, g as requestJsonSchema, h as replies, i as describeConsole, l as describeStatus, m as readRequest, n as describeAccessibility, o as describeModes, p as mcpCallerName, r as describeComponents, s as describeProblems, t as call, u as describeTokens, v as skillRequest } from "./client-CkT-5H3_.mjs";
4
4
  import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
5
5
  import { dirname, join, normalize, relative, resolve, sep } from "node:path";
6
6
  import { parseArgs } from "node:util";
@@ -160,8 +160,8 @@ const appErrorsFile = jsonText(z.record(z.string(), z.string()));
160
160
  */
161
161
  async function runCheck(library, options) {
162
162
  if (!library) throw new Error("parity lib check <library> [--tab t] [--mode m]");
163
- const { componentNode, generateId, librarySource, withLibraryContext } = await import("./src-Btr2eWdT.mjs");
164
- const { newestEntries, registryDir } = await import("./src-Q382DbAK.mjs");
163
+ const { componentNode, generateId, librarySource, withLibraryContext } = await import("./src-C4S96XEj.mjs");
164
+ const { newestEntries, registryDir } = await import("./src-ZsXhzNYa.mjs");
165
165
  const entry = (await newestEntries()).find((item) => item.manifest.id === library);
166
166
  if (!entry) throw new Error(`The registry has no library "${library}"`);
167
167
  const list = entry.manifest.components?.list ?? {};
@@ -295,19 +295,19 @@ function describeCheck(report) {
295
295
  * because it reads the project's files and its own copy of TypeScript.
296
296
  */
297
297
  async function runLib(packageName, options) {
298
- const { appManifestPath, generateLibrary, manifestText, mergeManifest, reviseLibrary } = await import("./src-Bf12xdm5.mjs");
299
- const { covers, registryDir, registryEntries } = await import("./src-Q382DbAK.mjs");
298
+ const { appManifestPath, generateLibrary, manifestText, mergeManifest, reviseLibrary } = await import("./src-XUZS4M-k.mjs");
299
+ const { covers, registryDir, registryEntries } = await import("./src-ZsXhzNYa.mjs");
300
300
  const spec = packageName === void 0 ? void 0 : packageSpec(packageName);
301
301
  let root = resolve(options.root ?? ".");
302
302
  if (spec && (spec.version !== void 0 || options.registry && !options.root)) {
303
- const { installedVersion, publishedVersion } = await import("./published-BtL8RM6W.mjs");
303
+ const { installedVersion, publishedVersion } = await import("./published-B0sNR0jd.mjs");
304
304
  const listed = (await registryEntries()).filter((entry) => entry.manifest.package?.name === spec.name);
305
305
  if (spec.version === void 0 && listed.length > 1) throw new Error(`The registry has ${listed.length} files for ${spec.name}; name a version, as ${spec.name}@1.2.3`);
306
306
  const version = await publishedVersion(spec.name, spec.version ?? listed[0]?.manifest.package?.version ?? "latest");
307
307
  console.error(`Installing ${spec.name} ${version} on its own…`);
308
308
  root = await installedVersion(spec.name, version);
309
309
  }
310
- const { parseLibraryEdits } = await import("./src-Bf12xdm5.mjs");
310
+ const { parseLibraryEdits } = await import("./src-XUZS4M-k.mjs");
311
311
  const trialEdits = options.edits ? parseLibraryEdits(JSON.parse(await readFile(resolve(options.edits), "utf8"))) : void 0;
312
312
  const recordedId = options.registry && spec ? options.id ?? (await registryEntries()).find((entry) => entry.manifest.package?.name === spec.name)?.manifest.id : void 0;
313
313
  const appErrors = recordedId ? await readAppErrors(registryDir(), recordedId) : void 0;
@@ -1,4 +1,4 @@
1
- import { a as nonBlankString, c as CodedError, f as readErrorDetails, i as jsonText, p as unknownReference, s as plainObject, t as checkData } from "./schema-CemdtCeF.mjs";
1
+ import { a as nonBlankString, c as CodedError, f as readErrorDetails, i as jsonText, p as unknownReference, s as plainObject, t as checkData } from "./schema-Dp5Jhloe.mjs";
2
2
  import { join } from "node:path";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
@@ -27,7 +27,7 @@ const propGroups = [
27
27
  /**
28
28
  * What agents send Parity and what it answers, as zod schemas (PAR-590): each RPC method's params and its result. The
29
29
  * CLI and its MCP server check agents' requests with them, publish them to MCP clients as JSON Schema, and check the
30
- * app's answers before reading them. The app can check what it's sent with the same schemas (PAR-598). Nothing here
30
+ * app's answers before reading them. The app checks what it's sent with the same schemas (PAR-598). Nothing here
31
31
  * touches files or the network, or loads the rest of core or the agent's workspace, so the CLI starts quickly.
32
32
  */
33
33
  /**
@@ -185,6 +185,12 @@ const requests = {
185
185
  };
186
186
  /** Reading the skill or a file it references, which the CLI does on its own, with no app. */
187
187
  const skillRequest = fields({ path: text("path", "Skill file to read.").default("SKILL.md") });
188
+ jsonText(z.object({
189
+ method: z.string("method must be a string"),
190
+ params: z.unknown().optional(),
191
+ agent: z.unknown().optional(),
192
+ agentId: z.unknown().optional()
193
+ }, "The request must be a JSON object"));
188
194
  /** What the app answers over HTTP: the method's result, or the error with its details when it knew the cause. */
189
195
  const rpcReply = z.looseObject({
190
196
  result: z.unknown().optional(),
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as call, n as describeAccessibility, r as describeComponents, i as describeConsole, a as describeExec, o as describeModes, s as describeProblems, c as describeProps, l as describeStatus, u as describeTokens, d as registry, f as setCaller } from "./client-D6bpjpy-.mjs";
1
+ export { t as call, n as describeAccessibility, r as describeComponents, i as describeConsole, a as describeExec, o as describeModes, s as describeProblems, c as describeProps, l as describeStatus, u as describeTokens, d as registry, f as setCaller } from "./client-CkT-5H3_.mjs";
@@ -1 +1 @@
1
- export { t as installedVersion, i as publishedVersion } from "./published-CdXoUgfD.mjs";
1
+ export { t as installedVersion, i as publishedVersion } from "./published-DYY8_8m9.mjs";
@@ -1,33 +1,74 @@
1
+ import { o as parseData } from "./schema-Dp5Jhloe.mjs";
2
+ import { tt as parseManifest } from "./src-Ck9A-Gxr.mjs";
1
3
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
2
4
  import { dirname, join } from "node:path";
3
5
  import { promisify } from "node:util";
6
+ import { z } from "zod";
4
7
  import { homedir } from "node:os";
5
8
  import { exec, execFile } from "node:child_process";
6
9
  import { gunzipSync } from "node:zlib";
7
- // ../libgen/src/published.ts
10
+ // ../libgen/src/npm.ts
11
+ /**
12
+ * npm's registry documents, as loose schemas of the fields libgen reads (PAR-599): a package's document, with every
13
+ * version it has published, and one version's.
14
+ */
8
15
  const registry = "https://registry.npmjs.org";
16
+ /** One published version, as the package's document lists it. */
17
+ const listedVersion = z.looseObject({ gitHead: z.string().optional() });
18
+ /** A package's document. `time` has each version's publishing date, and an `unpublished` record when it was pulled. */
19
+ const npmPackage = z.looseObject({
20
+ versions: z.record(z.string(), listedVersion).optional(),
21
+ "dist-tags": z.record(z.string(), z.string()).optional(),
22
+ time: z.object({ unpublished: z.unknown().optional() }).catchall(z.string()).optional()
23
+ });
24
+ /** One version's document: the commit it was published from, its repository and its tarball. */
25
+ const npmVersion = listedVersion.extend({
26
+ repository: z.union([z.string(), z.looseObject({ url: z.string().optional() })]).optional(),
27
+ dist: z.looseObject({ tarball: z.string().optional() }).optional()
28
+ });
29
+ /**
30
+ * A package's document from npm. The abbreviated one npm installs from has no publishing dates; `full` asks for the
31
+ * whole document, which has them. Throws when npm has no such package or its answer doesn't match.
32
+ */
33
+ async function packageDocument(name, options = {}) {
34
+ const response = await fetch(`${registry}/${name.replace("/", "%2F")}`, {
35
+ headers: { accept: options.full ? "application/json" : "application/vnd.npm.install-v1+json" },
36
+ ...options.signal ? { signal: options.signal } : {}
37
+ });
38
+ if (!response.ok) throw new Error(`npm has no ${name} (${response.status})`);
39
+ return readDocument(npmPackage, await response.json(), name);
40
+ }
41
+ /** One version's document from npm. Throws when npm has no such version or its answer doesn't match. */
42
+ async function versionDocument(name, version) {
43
+ const response = await fetch(`${registry}/${name.replace("/", "%2F")}/${version}`);
44
+ if (!response.ok) throw new Error(`npm has no ${name}@${version} (${response.status})`);
45
+ return readDocument(npmVersion, await response.json(), `${name}@${version}`);
46
+ }
47
+ function readDocument(schema, value, what) {
48
+ try {
49
+ return parseData(schema, value);
50
+ } catch (error) {
51
+ throw new TypeError(`npm's document for ${what}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
52
+ }
53
+ }
54
+ // ../libgen/src/published.ts
9
55
  const run = promisify(execFile);
10
56
  const shell = promisify(exec);
11
57
  /** The versions npm has published of a package. */
12
58
  async function publishedVersions(name) {
13
- return Object.keys((await packument(name)).versions ?? {});
59
+ return Object.keys((await packageDocument(name)).versions ?? {});
14
60
  }
15
61
  /**
16
62
  * The version of a package that `wanted` names: that version when npm has published it, or the one a tag such as
17
63
  * `latest` points to.
18
64
  */
19
65
  async function publishedVersion(name, wanted) {
20
- const { versions, "dist-tags": tags } = await packument(name);
66
+ const { versions, "dist-tags": tags } = await packageDocument(name);
21
67
  if (versions?.[wanted]) return wanted;
22
68
  const tagged = tags?.[wanted];
23
69
  if (tagged) return tagged;
24
70
  throw new Error(`npm has no ${name}@${wanted}: give a version it has published, or a tag such as latest`);
25
71
  }
26
- async function packument(name) {
27
- const response = await fetch(`${registry}/${name.replace("/", "%2F")}`, { headers: { accept: "application/vnd.npm.install-v1+json" } });
28
- if (!response.ok) throw new Error(`npm has no ${name} (${response.status})`);
29
- return await response.json();
30
- }
31
72
  /**
32
73
  * A folder with one version of a package installed, and what it depends on, so a library can be described without a
33
74
  * project that has it. npm installs it with its peers, such as React, and without running anyone's install scripts. A
@@ -55,7 +96,8 @@ async function installedVersion(name, version, cacheRoot = join(homedir(), ".par
55
96
  windowsHide: true
56
97
  });
57
98
  await npm();
58
- const react = await readFile(join(dir, "node_modules", "react", "package.json"), "utf8").then((text) => JSON.parse(text).version, () => void 0);
99
+ const reactManifest = join(dir, "node_modules", "react", "package.json");
100
+ const react = await readFile(reactManifest, "utf8").then((text) => parseManifest(text, reactManifest).version, () => void 0);
59
101
  if (react && /^\d+\.\d+\.\d+$/.test(react)) {
60
102
  const major = react.split(".")[0];
61
103
  await npm(` --save-exact react@${react} react-dom@${react} @types/react@${major} @types/react-dom@${major}`);
@@ -68,9 +110,7 @@ async function installedVersion(name, version, cacheRoot = join(homedir(), ".par
68
110
  * repository is the URL git fetches, whichever way the package wrote it (`git+https://….git`, `github:owner/name`).
69
111
  */
70
112
  async function publishedSource(name, version) {
71
- const response = await fetch(`${registry}/${name.replace("/", "%2F")}/${version}`);
72
- if (!response.ok) throw new Error(`npm has no ${name}@${version} (${response.status})`);
73
- const { gitHead, repository } = await response.json();
113
+ const { gitHead, repository } = await versionDocument(name, version);
74
114
  const url = typeof repository === "string" ? repository : repository?.url;
75
115
  return {
76
116
  ...url ? { repository: repositoryUrl(url) } : {},
@@ -162,9 +202,7 @@ async function packageFile(name, version, path, cacheRoot = join(homedir(), ".pa
162
202
  try {
163
203
  return await readFile(cached, "utf8");
164
204
  } catch {}
165
- const meta = await fetch(`${registry}/${name.replace("/", "%2F")}/${version}`);
166
- if (!meta.ok) throw new Error(`npm has no ${name}@${version} (${meta.status})`);
167
- const tarball = (await meta.json()).dist?.tarball;
205
+ const tarball = (await versionDocument(name, version)).dist?.tarball;
168
206
  if (!tarball) throw new Error(`npm gives no tarball for ${name}@${version}`);
169
207
  const archive = await fetch(tarball);
170
208
  if (!archive.ok) throw new Error(`${name}@${version}'s tarball couldn't be downloaded (${archive.status})`);
@@ -197,4 +235,4 @@ function tarEntry(archive, wanted) {
197
235
  if ((type === "0" || type === "") && name === wanted) return body;
198
236
  }
199
237
  }
200
- export { publishedVersions as a, tarEntry as c, publishedVersion as i, packageFile as n, repositoryFiles as o, publishedSource as r, repositoryUrl as s, installedVersion as t };
238
+ export { publishedVersions as a, tarEntry as c, publishedVersion as i, packageDocument as l, packageFile as n, repositoryFiles as o, publishedSource as r, repositoryUrl as s, installedVersion as t };
@@ -95,7 +95,7 @@ function readErrorDetails(value) {
95
95
  // ../core/src/schema.ts
96
96
  /**
97
97
  * Checks for data Parity didn't make (PAR-578): files, agent input, environment variables, other programs' JSON. A zod
98
- * schema is both the check and the type. A failed check reads as core's hand-written ones in `validate.ts` do: a JSON
98
+ * schema is both the check and the type. A failed check reads as core's hand-written ones in `validate.ts` did: a JSON
99
99
  * pointer to the value at fault, then what was expected there, as in `/containers/0/name: expected a string`.
100
100
  */
101
101
  /** An object with string keys, and not an array or null. */
@@ -204,7 +204,7 @@ function expectation(issue) {
204
204
  if (issue.code === "invalid_type") return typeName(issue.expected);
205
205
  if (issue.code === "invalid_value") return issue.values.map(literal).join(" or ");
206
206
  }
207
- /** Zod's issues in `validate.ts`'s words. Messages a schema gives itself win, and anything else keeps zod's own. */
207
+ /** Zod's issues in the words of core's old `validate.ts`. Messages a schema gives itself win, and anything else keeps zod's own. */
208
208
  function issueText(issue) {
209
209
  switch (issue.code) {
210
210
  case "invalid_type": return `expected ${typeName(issue.expected)}`;
@@ -0,0 +1,5 @@
1
+ import "./schema-Dp5Jhloe.mjs";
2
+ import "./client-CkT-5H3_.mjs";
3
+ export { t as componentNode, K as generateId, n as librarySource, i as withLibraryContext } from "./src-Ck9A-Gxr.mjs";
4
+ import "./src-gCnKQqH5.mjs";
5
+ import "./src-XUZS4M-k.mjs";