@parity-app/cli 0.0.0 → 0.2.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/README.md CHANGED
@@ -5,8 +5,7 @@ agent. Parity is a design canvas that draws a project's real components, styled
5
5
  open project's designs, components and tokens, runs edits as one undoable step, takes screenshots, checks accessibility,
6
6
  and serves all of this as MCP tools.
7
7
 
8
- > **Pre-release.** The CLI isn't on npm yet; its first publish is pending. Until then, run it from a checkout of the
9
- > repository with `node packages/cli/src/bin.ts`.
8
+ > **Pre-release.** Versions before 1.0 may change their commands and output between releases.
10
9
 
11
10
  ## Install
12
11
 
@@ -22,15 +21,22 @@ or install it to get the `parity` command:
22
21
  npm install --global @parity-app/cli
23
22
  ```
24
23
 
25
- Most commands act on a running Parity app, on its active tab unless `--tab` names another. `parity lib` runs without the
24
+ Most commands act on a project open in a running Parity app: the one `--tab` names, else the one the current folder is
25
+ in, else the active tab of the Parity window used last (`--tab active` names that one). `parity lib` runs without the
26
26
  app.
27
27
 
28
+ Each running copy of the app writes where to reach it to `~/.parity/agents`, and each call goes to the copy that has its
29
+ project open; a project open in two copies goes to the one running longest. A copy started with `PARITY_AGENT_FILE`
30
+ writes only that file, and a CLI given the same file reaches only that copy.
31
+
28
32
  ## Commands
29
33
 
30
34
  | Command | What it does |
31
35
  | ---------------------------- | ------------------------------------------------------------------------------------------ |
32
36
  | `parity tabs` | Lists the open projects. |
33
37
  | `parity state` | A tab's designs, selection, modes, components and tokens. Start here. |
38
+ | `parity status` | Revision, unsaved files and token values, the last save, and undo and redo. |
39
+ | `parity modes [design]` | Viewports, modes and what each design shows; a design adds its frames' sizes. |
34
40
  | `parity exec [file]` | Runs a JavaScript snippet against the designs, from a file or stdin, as one undoable step. |
35
41
  | `parity screenshot <design>` | Renders a design in its states and modes, offscreen, as images. |
36
42
  | `parity problems <design>` | Render errors, overflow, clipping and unknown components, per frame. |
@@ -61,6 +67,85 @@ Add the MCP server to your agent's configuration:
61
67
 
62
68
  Then have the agent read the skill first, with the `read_skill` tool or `parity skill`.
63
69
 
70
+ ## Execute contract
71
+
72
+ CLI `exec` and MCP `execute` share one operation. CLI file/stdin becomes MCP's `input`; `--label` becomes `description`;
73
+ `--tab`, `--edit-id` and parsed `--edits` have the same meaning in both. The default task label is `Edit designs`, and
74
+ an omitted tab uses the open project the current folder is in, else the active tab.
75
+
76
+ Send a nonblank snippet or a failed call's `editId`, not both. Retry patches need a nonempty `find`, a string `replace`
77
+ (which can be empty), and optional boolean `all`; omitted patches default to an empty list. Invalid requests are
78
+ rejected before reaching the desktop. Caller identity and session IDs travel separately from operation inputs.
79
+
80
+ CLI failures exit with 1; MCP failures set `isError` and include the same failure and retry details, as the structured
81
+ `error` below. CLI `--json` omits screenshot image data; MCP returns image content blocks.
82
+
83
+ ## Shared operations
84
+
85
+ All desktop commands use the same operation contracts as their MCP counterparts:
86
+
87
+ | CLI | MCP |
88
+ | ------------------------ | --------------------- |
89
+ | `tabs` | `get_tabs` |
90
+ | `state` | `get_app_state` |
91
+ | `status` | `get_status` |
92
+ | `modes` | `get_modes` |
93
+ | `exec` | `execute` |
94
+ | `screenshot` | `screenshot` |
95
+ | `problems` | `find_problems` |
96
+ | `a11y` / `accessibility` | `check_accessibility` |
97
+ | `console` | `get_console` |
98
+ | `open` | `open_project` |
99
+ | `tokens` | `get_tokens` |
100
+ | `components` | `get_components` |
101
+ | `props` | `get_props` |
102
+ | `skill` | `read_skill` |
103
+
104
+ Screenshot scale defaults to 1 and must be a finite number from 0.25 to 3. Screenshot state and mode default to the
105
+ current state and primary mode. Audits default to every state and shown modes. State and mode accept a nonblank string
106
+ or a nonempty list of nonblank strings; one-item lists normalize to strings. `clear` for console and `all` for props
107
+ default to false. Requests with invalid input fail before contacting the app.
108
+
109
+ Screenshots that fail and audits that find issues exit with 1 in the CLI and set MCP `isError`, retaining the full
110
+ report. CLI JSON omits screenshot image data; MCP emits image blocks. CLI `open` resolves relative folders; MCP requires
111
+ an absolute path. Skill reading uses the same local reader and default `SKILL.md` in both transports. Library generation
112
+ and checking remain CLI commands; library checking runs its snippets through the shared execute operation.
113
+
114
+ ## Structured results
115
+
116
+ Every command takes `--json` and prints the same data the MCP tool returns as `structuredContent`. `tools/list` doesn't
117
+ publish output schemas, since agents would pay for them in context; `operations.ts` and `execute.ts` hold them. Human
118
+ text and screenshot images stay beside it. A failure is
119
+ `{ "error": { code, message, retryable, path?, alternatives?, editId? } }` (with `--json` on stdout, and the message on
120
+ stderr), or, for `exec` and `screenshot`, the whole report with `error` in it:
121
+
122
+ - `code` is stable: `invalid_input`, `not_running`, `not_answering`, `unknown_tab`, `tab_not_ready`, `unknown_design`,
123
+ `unknown_node`, `ambiguous_reference`, `unknown_state`, `unknown_mode`, `unknown_viewport`, `unknown_component`,
124
+ `unknown_icon_set`, `unknown_edit_id`, `conflict`, `execution_failed` or `app_error`.
125
+ - `retryable` is true when the same request, unchanged, can succeed: the app is starting, or edits collided.
126
+ - `path` is a JSON pointer to the input at fault, in the transport's field names (`/design`, `/input`, `/edits/0/find`).
127
+ - `alternatives` lists up to 20 valid ids for an unknown or ambiguous one, closest first.
128
+ - `editId` retries a failed snippet with `edits`.
129
+
130
+ ```sh
131
+ $ parity props Buton --json
132
+ { "error": { "code": "unknown_component", "message": "\"Buton\" isn't one of the project's components. Check Components().",
133
+ "retryable": false, "path": "/component", "alternatives": ["Avatar", "Badge", "Button", "Card", …] } }
134
+ ```
135
+
136
+ `tokens` returns the first 100 unless `--limit` (up to 1000) says otherwise, and `console` the newest 50; both say
137
+ `total` and `truncated`. `tabs` is `{ "tabs": [...] }`.
138
+
64
139
  ## Licence
65
140
 
66
141
  MIT. See [LICENSE](https://github.com/betterapps-hq/parity/blob/main/LICENSE).
142
+
143
+ ## Caller name on the canvas
144
+
145
+ For CLI calls, set `PARITY_AGENT_NAME` to the name you want shown on cursors and badges (for example,
146
+ `DeepSeek Harness`). Without a nonblank name, calls show `Terminal`. Use `PARITY_AGENT_ID` to distinguish concurrent CLI
147
+ callers sharing a display name. `--label` names the task separately.
148
+
149
+ For MCP, Parity uses the client's declared `clientInfo.title`, then `clientInfo.name`, then `Agent` if neither is
150
+ nonblank. Names are trimmed and otherwise preserved; no list of known agents or tool environment detection is needed.
151
+ These display names are self-reported, not authentication.