@parity-app/cli 0.7.2 → 0.7.4

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
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-BtxrNeIk.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";
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";
@@ -144,7 +144,7 @@ const executeOperation = {
144
144
  /** Discovery uses the same contract, with just the two historical MCP field aliases. */
145
145
  inputSchema: discoverySchema,
146
146
  async run(input, send) {
147
- return execResponse(await send("exec", executeRequest(input), "tab", replies.exec));
147
+ return execResponse(await send("exec", executeRequest(input), "tab"));
148
148
  }
149
149
  };
150
150
  // src/check.ts
@@ -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-tY0sf-AQ.mjs");
164
- const { newestEntries, registryDir } = await import("./src-Chy2scQg.mjs");
163
+ const { componentNode, generateId, librarySource, withLibraryContext } = await import("./src-Btr2eWdT.mjs");
164
+ const { newestEntries, registryDir } = await import("./src-Q382DbAK.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,8 +295,8 @@ 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-CPka3fhs.mjs");
299
- const { covers, registryDir, registryEntries } = await import("./src-Chy2scQg.mjs");
298
+ const { appManifestPath, generateLibrary, manifestText, mergeManifest, reviseLibrary } = await import("./src-Bf12xdm5.mjs");
299
+ const { covers, registryDir, registryEntries } = await import("./src-Q382DbAK.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)) {
@@ -307,7 +307,7 @@ async function runLib(packageName, options) {
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-CPka3fhs.mjs");
310
+ const { parseLibraryEdits } = await import("./src-Bf12xdm5.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;
@@ -470,7 +470,8 @@ function describeReport(report) {
470
470
  * An operation whose canonical result is built from the app's checked answer, given the checked request. A request's
471
471
  * error points at the field, since an operation's fields are flat.
472
472
  */
473
- function mapped(method, input, reply, result, options = {}) {
473
+ function mapped(method, result, options = {}) {
474
+ const input = requests[method];
474
475
  const fields = Object.keys(input.shape);
475
476
  const routing = routingFor(fields);
476
477
  return {
@@ -479,7 +480,7 @@ function mapped(method, input, reply, result, options = {}) {
479
480
  routing,
480
481
  async run(given, send) {
481
482
  const request = readRequest(input, given, 1);
482
- return result(await send(method, request, routing, reply), request);
483
+ return result(await send(method, request, routing), request);
483
484
  },
484
485
  failed: options.failed ?? (() => false),
485
486
  structured: options.structured ?? ((value) => Object.fromEntries(Object.entries(value)))
@@ -492,8 +493,8 @@ function routingFor(fields) {
492
493
  return "copies";
493
494
  }
494
495
  /** An operation whose canonical result is the app's answer. */
495
- function operation(method, input, reply, options = {}) {
496
- return mapped(method, input, reply, (answer) => answer, options);
496
+ function operation(method, options = {}) {
497
+ return mapped(method, (answer) => answer, options);
497
498
  }
498
499
  /** The first `count` items, with how many there were, so a reply says when it left some out. */
499
500
  function bounded(items, count, keep = "first") {
@@ -518,18 +519,18 @@ z.looseObject({
518
519
  ...truncation
519
520
  });
520
521
  const operations = {
521
- tabs: mapped("tabs", requests.tabs, replies.tabs, (tabs) => ({ tabs })),
522
- state: operation("state", requests.state, replies.state),
523
- status: operation("status", requests.status, replies.status),
524
- modes: operation("modes", requests.modes, replies.modes),
525
- open: operation("open", requests.open, replies.open),
526
- screenshot: mapped("screenshot", requests.screenshot, replies.screenshot, (reply) => execResponse(reply, Object.keys(requests.screenshot.shape)), {
522
+ tabs: mapped("tabs", (tabs) => ({ tabs })),
523
+ state: operation("state"),
524
+ status: operation("status"),
525
+ modes: operation("modes"),
526
+ open: operation("open"),
527
+ screenshot: mapped("screenshot", (reply) => execResponse(reply, Object.keys(requests.screenshot.shape)), {
527
528
  failed: executionFailed,
528
529
  structured: structuredExec
529
530
  }),
530
- problems: operation("problems", requests.problems, replies.problems, { failed: (result) => result.problems.length > 0 }),
531
- accessibility: operation("accessibility", requests.accessibility, replies.accessibility, { failed: (result) => result.findings.length > 0 }),
532
- console: mapped("console", requests.console, replies.console, ({ tab, entries }, request) => {
531
+ problems: operation("problems", { failed: (result) => result.problems.length > 0 }),
532
+ accessibility: operation("accessibility", { failed: (result) => result.findings.length > 0 }),
533
+ console: mapped("console", ({ tab, entries }, request) => {
533
534
  const { items, total, truncated } = bounded(entries, request.limit, "last");
534
535
  return {
535
536
  tab,
@@ -538,7 +539,7 @@ const operations = {
538
539
  truncated
539
540
  };
540
541
  }),
541
- tokens: mapped("tokens", requests.tokens, replies.tokens, (tokens, request) => {
542
+ tokens: mapped("tokens", (tokens, request) => {
542
543
  const { items, total, truncated } = bounded(tokens, request.limit);
543
544
  return {
544
545
  tokens: items,
@@ -546,8 +547,8 @@ const operations = {
546
547
  truncated
547
548
  };
548
549
  }),
549
- components: operation("components", requests.components, replies.components),
550
- props: operation("props", requests.props, replies.props)
550
+ components: operation("components"),
551
+ props: operation("props")
551
552
  };
552
553
  const skillOperation = {
553
554
  inputSchema: requestJsonSchema(skillRequest),
@@ -886,9 +886,10 @@ function setCaller(name, session = false) {
886
886
  * in `@parity-app/agent/routing`, and returns its answer once `reply` has checked it. Fails with a clear message, and a
887
887
  * code, when no copy is running, none has the project, or the call fails: the app's own code when it gives one.
888
888
  */
889
- async function call(method, params, routing, reply) {
889
+ async function call(method, given, routing) {
890
+ const params = given;
890
891
  const copies = await runningCopies();
891
- if (routing === "copies") return answer(reply, openTabs(copies), "tabs");
892
+ if (routing === "copies") return answer(replies[method], openTabs(copies), "tabs");
892
893
  const target = route(copies, routing === "open" ? {
893
894
  kind: "open",
894
895
  root: String(params.root)
@@ -909,7 +910,7 @@ async function call(method, params, routing, reply) {
909
910
  return send(target.copy.entry, method, target.tab ? {
910
911
  ...params,
911
912
  tab: target.tab.id
912
- } : params, reply);
913
+ } : params);
913
914
  }
914
915
  /** A folder's real path, through any link, or the folder as named when it can't be read. */
915
916
  function real(path) {
@@ -951,17 +952,18 @@ async function runningCopies() {
951
952
  /** What a copy has open and when it was last used; just its tabs from an app too old to say more. */
952
953
  async function reportOf(entry) {
953
954
  try {
954
- return await send(entry, "copy", {}, replies.copy, 5e3);
955
+ return await send(entry, "copy", {}, 5e3);
955
956
  } catch (error) {
956
957
  if (!(error instanceof CodedError) || error.details.code !== "app_error") return void 0;
957
958
  try {
958
- return { tabs: await send(entry, "tabs", {}, replies.tabs, 5e3) };
959
+ return { tabs: await send(entry, "tabs", {}, 5e3) };
959
960
  } catch {
960
961
  return;
961
962
  }
962
963
  }
963
964
  }
964
- async function send(entry, method, params, reply, timeout) {
965
+ /** Asks one copy, and returns its answer once the method's schema in `contracts.ts` has checked it. */
966
+ async function send(entry, method, params, timeout) {
965
967
  let response;
966
968
  try {
967
969
  response = await fetch(`${entry.url}/rpc`, {
@@ -986,7 +988,7 @@ async function send(entry, method, params, reply, timeout) {
986
988
  }
987
989
  const body = answer(jsonText(rpcReply), await response.text(), method);
988
990
  if (body.error !== void 0) throw new CodedError(body.error, readErrorDetails(body.details) ?? { code: "app_error" });
989
- return answer(reply, body.result, method);
991
+ return answer(replies[method], body.result, method);
990
992
  }
991
993
  /** The app's answer to `method` once `schema` has checked it, or `app_error` saying what this CLI couldn't read. */
992
994
  function answer(schema, value, method) {
package/dist/index.d.mts CHANGED
@@ -594,6 +594,16 @@ declare const replies: {
594
594
  }, z.core.$loose>>;
595
595
  }, z.core.$loose>;
596
596
  };
597
+ /**
598
+ * Each RPC method's params, as the CLI sends them once its request schema has read them, and its answer (PAR-564). The
599
+ * CLI client asks by it and the app's dispatch answers by it, so a shape that drifts on either side fails to compile.
600
+ * `copy` takes nothing.
601
+ */
602
+ type AgentMethods = { [M in keyof typeof replies]: {
603
+ params: M extends keyof typeof requests ? z.output<(typeof requests)[M]> : Record<string, never>;
604
+ result: z.output<(typeof replies)[M]>;
605
+ }; };
606
+ type AgentMethod = keyof AgentMethods;
597
607
  declare const tabsResult: z.ZodObject<{
598
608
  tabs: z.ZodArray<z.ZodObject<{
599
609
  id: z.ZodString;
@@ -788,7 +798,7 @@ export type Routing = "tab" | "open" | "copies";
788
798
  * in `@parity-app/agent/routing`, and returns its answer once `reply` has checked it. Fails with a clear message, and a
789
799
  * code, when no copy is running, none has the project, or the call fails: the app's own code when it gives one.
790
800
  */
791
- export declare function call<Reply extends z.ZodType>(method: string, params: Record<string, unknown>, routing: Routing, reply: Reply): Promise<z.output<Reply>>;
801
+ export declare function call<M extends AgentMethod>(method: M, given: AgentMethods[M]["params"], routing: Routing): Promise<AgentMethods[M]["result"]>;
792
802
  /** A readable account of an exec call, for terminals and for agents. */
793
803
  export declare function describeExec(result: ExecResponse): string;
794
804
  /** Where a tab's edits stand: the revision, what's applied and undoable, what's on disk, and what failed to write. */
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-BtxrNeIk.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-D6bpjpy-.mjs";
@@ -1,4 +1,4 @@
1
- import { d as libraryManifestExtension, m as parseLibraryManifest, o as applyLibraryEdits, p as parseLibraryEdits } from "./src-Csdxx4kB.mjs";
1
+ import { d as libraryManifestExtension, m as parseLibraryManifest, o as applyLibraryEdits, p as parseLibraryEdits } from "./src-DjSCuWcT.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { readFile, readdir } from "node:fs/promises";
4
4
  import { dirname, join, resolve } from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { i as jsonText, o as parseData, r as finiteNumber, s as plainObject } from "./schema-CemdtCeF.mjs";
2
- import { D as collectCustomProperties, M as lengthToPixels, N as packageManifest, c as isMadeValue, d as libraryManifestExtension, h as renderSlotOf, l as isSampleElement, m as parseLibraryManifest, o as applyLibraryEdits, p as parseLibraryEdits, u as isSampleRender } from "./src-Csdxx4kB.mjs";
3
- import { r as readLibraryEdits, s as parseJsonc } from "./src-CzZ9eIU8.mjs";
2
+ import { F as packageManifest, P as lengthToPixels, c as isMadeValue, d as libraryManifestExtension, h as renderSlotOf, k as collectCustomProperties, l as isSampleElement, m as parseLibraryManifest, o as applyLibraryEdits, p as parseLibraryEdits, u as isSampleRender } from "./src-DjSCuWcT.mjs";
3
+ import { r as readLibraryEdits, s as parseJsonc } from "./src-B9VW36v9.mjs";
4
4
  import { a as publishedVersions, n as packageFile, o as repositoryFiles, r as publishedSource } from "./published-CdXoUgfD.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import { mkdir, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
@@ -0,0 +1,5 @@
1
+ import "./schema-CemdtCeF.mjs";
2
+ import "./client-D6bpjpy-.mjs";
3
+ export { t as componentNode, D as generateId, n as librarySource, i as withLibraryContext } from "./src-DjSCuWcT.mjs";
4
+ import "./src-B9VW36v9.mjs";
5
+ import "./src-Bf12xdm5.mjs";
@@ -733,6 +733,7 @@ function problem(context, path, message) {
733
733
  path
734
734
  });
735
735
  }
736
+ /** A project file's schema, which the project service also checks a saved document with (PAR-565). */
736
737
  const canvasDocument = fileObject({
737
738
  version: z.literal(3),
738
739
  containers: z.array(containerSpec),
@@ -1467,4 +1468,4 @@ function sampleIds(sample, library) {
1467
1468
  ...sample.children ? { children: sample.children.map(child) } : {}
1468
1469
  };
1469
1470
  }
1470
- export { viewportWidthProperty as A, parseCanvasDocument as C, collectCustomProperties as D, modeSettings as E, lengthToPixels as M, packageManifest as N, remProperty as O, paramTypes as S, generateId as T, containerKinds as _, openProps as a, linkEndKinds as b, isMadeValue as c, libraryManifestExtension as d, parentSignals as f, canvasObjectKinds as g, renderSlotOf as h, withLibraryContext as i, deviceKinds as j, viewportHeightProperty as k, isSampleElement as l, parseLibraryManifest as m, librarySource as n, applyLibraryEdits as o, parseLibraryEdits as p, sampleIds as r, componentEvidence as s, componentNode as t, isSampleRender as u, imageFits as v, walkNodes as w, linkTypes as x, linkAllowed as y };
1471
+ export { remProperty as A, linkTypes as C, generateId as D, walkNodes as E, packageManifest as F, viewportWidthProperty as M, deviceKinds as N, modeSettings as O, lengthToPixels as P, linkEndKinds as S, parseCanvasDocument as T, canvasObjectKinds as _, openProps as a, imageFits as b, isMadeValue as c, libraryManifestExtension as d, parentSignals as f, canvasDocument as g, renderSlotOf as h, withLibraryContext as i, viewportHeightProperty as j, collectCustomProperties as k, isSampleElement as l, parseLibraryManifest as m, librarySource as n, applyLibraryEdits as o, parseLibraryEdits as p, sampleIds as r, componentEvidence as s, componentNode as t, isSampleRender as u, containerKinds as v, paramTypes as w, linkAllowed as x, detectionCorrections as y };
@@ -1 +1 @@
1
- export { t as covers, n as newestEntries, i as registryDir, a as registryEntries } from "./src-CzZ9eIU8.mjs";
1
+ export { t as covers, n as newestEntries, i as registryDir, a as registryEntries } from "./src-B9VW36v9.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity-app/cli",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Drive the Parity app from a terminal or an agent: read state, run edits, take screenshots, serve MCP.",
package/skills/execute.md CHANGED
@@ -403,6 +403,20 @@ theme, or `SetTokens({ primary: { default: "…", dark: "…" } })` per theme. E
403
403
  saving writes them into the project's code, so do it only when the person asks to change the design system, not to style
404
404
  one design. They're undone with the call's other changes.
405
405
 
406
+ `SetTokens` refuses a value the Tokens panel would refuse, throwing an `invalid_input` error that names the token and
407
+ theme and says what's wrong: a bracket or quote left open, a `var()` naming no token, or a token built on itself. None
408
+ of that call's values are kept. A value that isn't its token's kind (`"bluish"` for a color) is refused when the call
409
+ ends, and then nothing in the call is applied.
410
+
411
+ ```js
412
+ SetTokens({ primary: { default: "oklch(0.55 0.2 260)", dark: "var(--foreground)" } })
413
+ try {
414
+ SetTokens({ primary: "oklch(0.55 0.2 260" })
415
+ } catch (error) {
416
+ Print(error.message) // SetTokens/primary/default: A bracket isn't closed. Add ) at the end.
417
+ }
418
+ ```
419
+
406
420
  ## Checking
407
421
 
408
422
  `Screenshot` renders frames offscreen at their real widths and returns how many it took; the images come back with the
@@ -1,5 +0,0 @@
1
- import "./schema-CemdtCeF.mjs";
2
- import "./client-BtxrNeIk.mjs";
3
- export { t as componentNode, T as generateId, n as librarySource, i as withLibraryContext } from "./src-Csdxx4kB.mjs";
4
- import "./src-CzZ9eIU8.mjs";
5
- import "./src-CPka3fhs.mjs";