@parity-app/cli 0.8.0 → 0.9.0

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-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";
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-Cgwc4jGv.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,7 +160,7 @@ 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-C4S96XEj.mjs");
163
+ const { componentNode, generateId, librarySource, withLibraryContext } = await import("./src-B9dFylXR.mjs");
164
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}"`);
@@ -651,7 +651,7 @@ const tools = [
651
651
  operationTool("get_console", "Read what the project's own code wrote to the console: errors, warnings and logs from its components on the canvas, including while the person interacts with them, and from offscreen renders such as screenshots. Oldest first; the same message several times in a row is counted once. clear: true empties it after reading, so the next read shows only what's new.", operations.console, (result) => [text(describeConsole(result))]),
652
652
  operationTool("open_project", "Open a project folder in a new Parity tab, or switch to it if it's already open.", operations.open, json),
653
653
  operationTool("get_tokens", "Read tokens filtered by category, source or name, with values in every theme.", operations.tokens, (result) => [text(describeTokens(result))]),
654
- operationTool("get_components", "List project components, libraries, icon sets and exports that were left out or failed to render.", operations.components, (result) => [text(describeComponents(result))]),
654
+ operationTool("get_components", "List project components with the file each is written in, libraries, icon sets and exports that were left out or failed to render.", operations.components, (result) => [text(describeComponents(result))]),
655
655
  operationTool("get_props", "Read a component's props from source, and its composition: the parents or provider it goes inside, the parts it holds, its slots and an example node to insert. all includes attributes it passes through.", operations.props, (result) => [text(describeProps(result))]),
656
656
  {
657
657
  name: "read_skill",
@@ -494,7 +494,10 @@ const consoleReply = z.looseObject({
494
494
  where: z.enum(["canvas", "offscreen"]),
495
495
  count: z.int(),
496
496
  first: number,
497
- last: number
497
+ last: number,
498
+ design: z.string().optional().describe("The design that wrote it, by key (path#id), when known."),
499
+ state: z.string().optional(),
500
+ mode: z.string().optional()
498
501
  }))
499
502
  });
500
503
  const tokenInfo = z.looseObject({
@@ -505,6 +508,8 @@ const tokenInfo = z.looseObject({
505
508
  });
506
509
  const componentsReply = z.looseObject({
507
510
  components: strings,
511
+ /** The file each of the project's own components is written in, from the project root, by component (PAR-167). */
512
+ files: z.record(z.string(), z.string()).optional(),
508
513
  iconLibraries: strings.optional(),
509
514
  /** The app's capitalised exports the type checker left out, with why. */
510
515
  leftOut: z.array(z.looseObject({
@@ -1234,10 +1239,11 @@ function describeTokens({ tokens, total, truncated }) {
1234
1239
  return lines.join("\n");
1235
1240
  }
1236
1241
  /**
1237
- * The project's own components, then each library's, then the icon libraries, then the exports left out and why, the
1238
- * components failing to draw and why, and what the person corrected by hand.
1242
+ * The project's own components, by the file each is written in when that's known, then each library's, then the icon
1243
+ * libraries, then the exports left out and why, the components failing to draw and why, and what the person corrected
1244
+ * by hand.
1239
1245
  */
1240
- function describeComponents({ components, iconLibraries = [], leftOut = [], drawn = 0, failing = [], corrections = {} }) {
1246
+ function describeComponents({ components, files = {}, iconLibraries = [], leftOut = [], drawn = 0, failing = [], corrections = {} }) {
1241
1247
  const groups = /* @__PURE__ */ new Map();
1242
1248
  for (const component of components) {
1243
1249
  const slash = component.indexOf("/");
@@ -1245,7 +1251,8 @@ function describeComponents({ components, iconLibraries = [], leftOut = [], draw
1245
1251
  groups.set(group, [...groups.get(group) ?? [], slash > 0 ? component.slice(slash + 1) : component]);
1246
1252
  }
1247
1253
  const lines = [];
1248
- for (const [group, names] of [...groups].sort(([a], [b]) => first("", a, b))) lines.push(group ? `${group}, as ${group}/Name:` : "The project's own:", ` ${names.join(", ")}`, "");
1254
+ for (const [group, names] of [...groups].sort(([a], [b]) => first("", a, b))) if (group) lines.push(`${group}, as ${group}/Name:`, ` ${names.join(", ")}`, "");
1255
+ else lines.push(...ownComponents(names, files), "");
1249
1256
  if (iconLibraries.length > 0) lines.push(`Icons: ${iconLibraries.map((library) => `${library}, as ${library}/Name`).join("; ")}`, "");
1250
1257
  if (leftOut.length > 0) {
1251
1258
  lines.push("Not components:");
@@ -1265,6 +1272,22 @@ function describeComponents({ components, iconLibraries = [], leftOut = [], draw
1265
1272
  }
1266
1273
  return lines.join("\n").trimEnd();
1267
1274
  }
1275
+ /** The project's own components, under the file each is written in when the app says, files in order (PAR-167). */
1276
+ function ownComponents(names, files) {
1277
+ const byFile = /* @__PURE__ */ new Map();
1278
+ const unplaced = [];
1279
+ for (const name of names) {
1280
+ const file = files[name];
1281
+ if (file) byFile.set(file, [...byFile.get(file) ?? [], name]);
1282
+ else unplaced.push(name);
1283
+ }
1284
+ if (byFile.size === 0) return ["The project's own:", ` ${names.join(", ")}`];
1285
+ return [
1286
+ "The project's own, by file:",
1287
+ ...[...byFile].sort(([a], [b]) => a.localeCompare(b)).map(([file, inFile]) => ` ${file}: ${inFile.join(", ")}`),
1288
+ ...unplaced.length > 0 ? [` file not known yet: ${unplaced.join(", ")}`] : []
1289
+ ];
1290
+ }
1268
1291
  /** A component's props, with each variant's options and default, then what it needs around it and holds. */
1269
1292
  function describeProps(result) {
1270
1293
  const lines = [];
@@ -1325,10 +1348,16 @@ function describeConsole(result) {
1325
1348
  const [first = "", ...rest] = entry.text.split("\n");
1326
1349
  lines.push("", `${time} ${entry.level}${repeats}: ${first}`, ...rest.map((line) => ` ${line}`));
1327
1350
  const offscreen = entry.where === "offscreen" ? ", in an offscreen render" : "";
1328
- lines.push(` at ${scriptPath(entry.source)}:${entry.line}${offscreen}`);
1351
+ lines.push(` at ${scriptPath(entry.source)}:${entry.line}${offscreen}${writtenBy(entry)}`);
1329
1352
  }
1330
1353
  return lines.join("\n");
1331
1354
  }
1355
+ /** The design a message came from, by id, with the state and mode it was drawn in, when the app knows (PAR-147). */
1356
+ function writtenBy({ design, state, mode }) {
1357
+ if (!design) return "";
1358
+ const frame = [state, mode].filter(Boolean).join(", ");
1359
+ return `, from design ${design.slice(design.lastIndexOf("#") + 1)}${frame ? ` (${frame})` : ""}`;
1360
+ }
1332
1361
  /** Compares two names alphabetically, with `name` before every other. */
1333
1362
  function first(name, a, b) {
1334
1363
  if (a === name) return -1;
package/dist/index.d.mts CHANGED
@@ -488,6 +488,9 @@ declare const replies: {
488
488
  count: z.ZodInt;
489
489
  first: z.ZodNumber;
490
490
  last: z.ZodNumber;
491
+ design: z.ZodOptional<z.ZodString>;
492
+ state: z.ZodOptional<z.ZodString>;
493
+ mode: z.ZodOptional<z.ZodString>;
491
494
  }, z.core.$loose>>;
492
495
  }, z.core.$loose>;
493
496
  tokens: z.ZodArray<z.ZodObject<{
@@ -498,6 +501,7 @@ declare const replies: {
498
501
  }, z.core.$loose>>;
499
502
  components: z.ZodObject<{
500
503
  components: z.ZodArray<z.ZodString>;
504
+ files: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
501
505
  iconLibraries: z.ZodOptional<z.ZodArray<z.ZodString>>;
502
506
  leftOut: z.ZodOptional<z.ZodArray<z.ZodObject<{
503
507
  name: z.ZodString;
@@ -643,6 +647,9 @@ declare const consoleResult: z.ZodObject<{
643
647
  count: z.ZodInt;
644
648
  first: z.ZodNumber;
645
649
  last: z.ZodNumber;
650
+ design: z.ZodOptional<z.ZodString>;
651
+ state: z.ZodOptional<z.ZodString>;
652
+ mode: z.ZodOptional<z.ZodString>;
646
653
  }, z.core.$loose>>;
647
654
  }, z.core.$loose>;
648
655
  declare const tokensResult: z.ZodObject<{
@@ -818,10 +825,11 @@ export declare function describeProblems(result: ProblemsResponse): string;
818
825
  /** Tokens by category, each with its value in every theme that sets one. */
819
826
  export declare function describeTokens({ tokens, total, truncated }: TokensResponse): string;
820
827
  /**
821
- * The project's own components, then each library's, then the icon libraries, then the exports left out and why, the
822
- * components failing to draw and why, and what the person corrected by hand.
828
+ * The project's own components, by the file each is written in when that's known, then each library's, then the icon
829
+ * libraries, then the exports left out and why, the components failing to draw and why, and what the person corrected
830
+ * by hand.
823
831
  */
824
- export declare function describeComponents({ components, iconLibraries, leftOut, drawn, failing, corrections }: ComponentsResponse): string;
832
+ export declare function describeComponents({ components, files, iconLibraries, leftOut, drawn, failing, corrections }: ComponentsResponse): string;
825
833
  /** A component's props, with each variant's options and default, then what it needs around it and holds. */
826
834
  export declare function describeProps(result: PropsResponse): string;
827
835
  /** A readable account of what a project's code wrote to the console, oldest first, with where each came from. */
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-CkT-5H3_.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-Cgwc4jGv.mjs";
@@ -1,5 +1,5 @@
1
1
  import "./schema-Dp5Jhloe.mjs";
2
- import "./client-CkT-5H3_.mjs";
2
+ import "./client-Cgwc4jGv.mjs";
3
3
  export { t as componentNode, K as generateId, n as librarySource, i as withLibraryContext } from "./src-Ck9A-Gxr.mjs";
4
4
  import "./src-gCnKQqH5.mjs";
5
5
  import "./src-XUZS4M-k.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity-app/cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
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/SKILL.md CHANGED
@@ -45,9 +45,10 @@ project, pass `tab: "active"` (`--tab active`) and read `get_app_state` for the
45
45
  | `read_skill` | `parity skill [file]` | This skill. |
46
46
 
47
47
  The token, component and prop tools read what designs can use without writing a snippet in either transport.
48
- `parity components` also says which of the app's exports aren't components and why, which components fail to draw on the
49
- canvas and why (often a missing provider, which a decorator adds), and what the person listed or took off the list by
50
- hand.
48
+ `parity components` also says which file each of the project's own components is written in, which of the app's exports
49
+ aren't components and why, which components fail to draw on the canvas and why (often a missing provider, which a
50
+ decorator adds), and what the person listed or took off the list by hand. `Measure` gives the file and line that writes
51
+ each node's element.
51
52
 
52
53
  CLI commands and MCP tools share validation and defaults. Screenshot scale defaults to 1 and accepts 0.25 to 3. Audits
53
54
  check every state and shown mode unless narrowed; a single-element selector list is equivalent to a string. Screenshot
package/skills/execute.md CHANGED
@@ -438,12 +438,13 @@ token values not yet saved show, the person's edits and this call's own `SetToke
438
438
 
439
439
  `Measure` lays out one frame and returns its state, mode and size, whether it overflows sideways, and every node's box
440
440
  with the node it's drawn inside (`parent`); a node an ancestor cuts off has `clipped` and that ancestor's box in `clip`.
441
- `Problems` checks frames for render errors, overflow, clipping and unknown components. Each layout problem has its
442
- `kind`: `frame-overflow` for a node that sticks out of the frame, by its position or its width, or `clipped` for one an
443
- ancestor that hides overflow cuts off. It names the `node`, its `box`, the `container` it overflows (the clipping node,
444
- or the frame, which has no `node`) with that box, and the pixels past each edge in `overflow`. A node past a parent that
445
- doesn't clip, inside the frame, shows, so it isn't a problem; children going no further than a reported parent are left
446
- out.
441
+ A node whose element the project's code writes, such as a component's, has `source`: the file, line and column, as
442
+ `src/components/ui/button.tsx:44:5`, to open or edit. Parity's own layers have none. `Problems` checks frames for render
443
+ errors, overflow, clipping and unknown components. Each layout problem has its `kind`: `frame-overflow` for a node that
444
+ sticks out of the frame, by its position or its width, or `clipped` for one an ancestor that hides overflow cuts off. It
445
+ names the `node`, its `box`, the `container` it overflows (the clipping node, or the frame, which has no `node`) with
446
+ that box, and the pixels past each edge in `overflow`. A node past a parent that doesn't clip, inside the frame, shows,
447
+ so it isn't a problem; children going no further than a reported parent are left out.
447
448
 
448
449
  ```js
449
450
  const id = CreateDesign({ name: "Checkout" })