@parity-app/cli 0.6.2 → 0.7.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 +14 -15
- package/dist/{client-BUaE9b77.mjs → client-D5kbiMmn.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/schema-DcQLoUPP.mjs +239 -0
- package/dist/src-BaOpaXkV.mjs +4 -0
- package/dist/{src-V9wTMkxO.mjs → src-CSah1pZ-.mjs} +605 -715
- package/dist/src-D2kRGtaF.mjs +129 -0
- package/dist/src-vUHtM2X4.mjs +1 -0
- package/dist/{src-BvKhu6dX.mjs → src-x0VQ8I6l.mjs} +260 -123
- package/package.json +1 -1
- package/skills/SKILL.md +16 -16
- package/dist/schema-zRNxotYl.mjs +0 -121
- package/dist/src-BIVDlIGc.mjs +0 -53
- package/dist/src-BgQ7gnXE.mjs +0 -3
- package/dist/src-CiqdFzei.mjs +0 -1
package/dist/schema-zRNxotYl.mjs
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// ../core/src/errors.ts
|
|
3
|
-
/**
|
|
4
|
-
* Why an agent's call failed, as a stable code it can act on without reading the message. The CLI and MCP publish
|
|
5
|
-
* these; the app throws them where it knows the cause.
|
|
6
|
-
*/
|
|
7
|
-
const errorCodes = [
|
|
8
|
-
"invalid_input",
|
|
9
|
-
"not_running",
|
|
10
|
-
"not_answering",
|
|
11
|
-
"unknown_tab",
|
|
12
|
-
"tab_not_ready",
|
|
13
|
-
"unknown_design",
|
|
14
|
-
"unknown_node",
|
|
15
|
-
"ambiguous_reference",
|
|
16
|
-
"unknown_state",
|
|
17
|
-
"unknown_mode",
|
|
18
|
-
"unknown_viewport",
|
|
19
|
-
"unknown_component",
|
|
20
|
-
"unknown_icon_set",
|
|
21
|
-
"unknown_edit_id",
|
|
22
|
-
"conflict",
|
|
23
|
-
"execution_failed",
|
|
24
|
-
"app_error"
|
|
25
|
-
];
|
|
26
|
-
/** Details as another process sends them. Each field that's malformed falls back on its own; only the code must hold. */
|
|
27
|
-
const errorDetailsSchema = z.object({
|
|
28
|
-
code: z.enum(errorCodes),
|
|
29
|
-
/** Whether sending the same request again, unchanged, can succeed. */
|
|
30
|
-
retryable: z.boolean().catch(false),
|
|
31
|
-
/** The request field at fault, as a path: `design`, `state`, `edits/0/find`. */
|
|
32
|
-
field: z.string().min(1).optional().catch(void 0),
|
|
33
|
-
/** Valid references to use instead of an unknown or ambiguous one, at most `alternativeLimit` of them. */
|
|
34
|
-
alternatives: z.array(z.unknown()).transform((items) => items.filter((item) => typeof item === "string").slice(0, 20)).optional().catch(void 0)
|
|
35
|
-
});
|
|
36
|
-
/** An error with a stable code, the field it's about and what to use instead. */
|
|
37
|
-
var CodedError = class extends Error {
|
|
38
|
-
details;
|
|
39
|
-
constructor(message, details) {
|
|
40
|
-
super(message);
|
|
41
|
-
this.name = "CodedError";
|
|
42
|
-
this.details = {
|
|
43
|
-
...details,
|
|
44
|
-
retryable: details.retryable ?? false
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
/** An unknown reference, naming the valid ones closest to what was asked for, up to `alternativeLimit`. */
|
|
49
|
-
function unknownReference(code, message, reference, candidates, field) {
|
|
50
|
-
return new CodedError(message, {
|
|
51
|
-
code,
|
|
52
|
-
...field === void 0 ? {} : { field },
|
|
53
|
-
alternatives: closest(reference, candidates)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Candidates sharing text with the reference first, ignoring case, then the rest by how few single-character edits
|
|
58
|
-
* away they are, so a typo's intended id makes the cut; ties keep their own order. All of them when they fit.
|
|
59
|
-
*/
|
|
60
|
-
function closest(reference, candidates, limit = 20) {
|
|
61
|
-
const unique = [...new Set(candidates)];
|
|
62
|
-
if (unique.length <= limit) return unique;
|
|
63
|
-
const wanted = reference.toLowerCase();
|
|
64
|
-
const ranked = unique.map((candidate, index) => {
|
|
65
|
-
const lower = candidate.toLowerCase();
|
|
66
|
-
const near = wanted.length > 0 && (lower.includes(wanted) || wanted.includes(lower));
|
|
67
|
-
return {
|
|
68
|
-
candidate,
|
|
69
|
-
index,
|
|
70
|
-
near: near ? 0 : 1,
|
|
71
|
-
distance: near ? 0 : editDistance(wanted, lower)
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
ranked.sort((a, b) => a.near - b.near || a.distance - b.distance || a.index - b.index);
|
|
75
|
-
return ranked.slice(0, limit).map(({ candidate }) => candidate);
|
|
76
|
-
}
|
|
77
|
-
/** How many single-character insertions, deletions or substitutions turn one string into the other. */
|
|
78
|
-
function editDistance(a, b) {
|
|
79
|
-
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
80
|
-
for (let i = 1; i <= a.length; i++) {
|
|
81
|
-
const row = [i];
|
|
82
|
-
for (let j = 1; j <= b.length; j++) row[j] = Math.min(previous[j] + 1, row[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
83
|
-
previous = row;
|
|
84
|
-
}
|
|
85
|
-
return previous[b.length];
|
|
86
|
-
}
|
|
87
|
-
/** A thrown value's details, when it carries them. */
|
|
88
|
-
function errorDetails(error) {
|
|
89
|
-
return error instanceof CodedError ? error.details : void 0;
|
|
90
|
-
}
|
|
91
|
-
/** Details that came from another process, checked before they're trusted. Anything malformed reads as none. */
|
|
92
|
-
function readErrorDetails(value) {
|
|
93
|
-
return errorDetailsSchema.safeParse(value).data;
|
|
94
|
-
}
|
|
95
|
-
// ../core/src/schema.ts
|
|
96
|
-
/**
|
|
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
|
|
99
|
-
* pointer to the value at fault, then what was expected there, as in `/containers/0/name: expected a string`.
|
|
100
|
-
*/
|
|
101
|
-
/** An object with string keys, and not an array or null. */
|
|
102
|
-
const plainObject = z.record(z.string(), z.unknown());
|
|
103
|
-
/** Text with something besides whitespace, trimmed. */
|
|
104
|
-
const nonBlankString = z.string().trim().min(1, "can't be blank");
|
|
105
|
-
/** A number other than NaN or ±Infinity, which zod 4 refuses on its own. */
|
|
106
|
-
const finiteNumber = z.number();
|
|
107
|
-
/** JSON text holding what `schema` checks. Text that isn't JSON fails as `expected JSON`. */
|
|
108
|
-
function jsonText(schema) {
|
|
109
|
-
return z.string().transform((text, context) => {
|
|
110
|
-
try {
|
|
111
|
-
return JSON.parse(text);
|
|
112
|
-
} catch {
|
|
113
|
-
context.addIssue({
|
|
114
|
-
code: "custom",
|
|
115
|
-
message: "expected JSON"
|
|
116
|
-
});
|
|
117
|
-
return z.NEVER;
|
|
118
|
-
}
|
|
119
|
-
}).pipe(schema);
|
|
120
|
-
}
|
|
121
|
-
export { CodedError as a, errorDetails as c, plainObject as i, readErrorDetails as l, jsonText as n, closest as o, nonBlankString as r, errorCodes as s, finiteNumber as t, unknownReference as u };
|
package/dist/src-BIVDlIGc.mjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { p as parseLibraryManifest, u as libraryManifestExtension } from "./src-V9wTMkxO.mjs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { existsSync } from "node:fs";
|
|
6
|
-
import semver from "semver";
|
|
7
|
-
// ../registry/src/index.ts
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
|
-
/**
|
|
10
|
-
* The folder the registry's files are in. The published CLI bundles this module and ships the files beside it, where
|
|
11
|
-
* the package can't be resolved. Otherwise they're found through the package's own `package.json`, so it's the same
|
|
12
|
-
* whether this module runs from source or bundled into the app.
|
|
13
|
-
*/
|
|
14
|
-
function registryDir() {
|
|
15
|
-
const bundled = join(import.meta.dirname, "libraries");
|
|
16
|
-
if (existsSync(bundled)) return bundled;
|
|
17
|
-
return join(dirname(require.resolve("@parity-app/registry/package.json")), "libraries");
|
|
18
|
-
}
|
|
19
|
-
let cache;
|
|
20
|
-
/** Every file in the registry, read once. One that doesn't parse is skipped with a warning. */
|
|
21
|
-
function registryEntries(dir = registryDir()) {
|
|
22
|
-
if (dir !== registryDir()) return readEntries(dir);
|
|
23
|
-
cache ??= readEntries(dir);
|
|
24
|
-
return cache;
|
|
25
|
-
}
|
|
26
|
-
async function readEntries(dir) {
|
|
27
|
-
const files = (await readdir(dir).catch(() => [])).filter((file) => file.endsWith(libraryManifestExtension)).sort();
|
|
28
|
-
const entries = [];
|
|
29
|
-
for (const file of files) {
|
|
30
|
-
const path = join(dir, file);
|
|
31
|
-
try {
|
|
32
|
-
const manifest = parseLibraryManifest(JSON.parse(await readFile(path, "utf8")));
|
|
33
|
-
if (!manifest.package) throw new TypeError("/package: a registry file names the package it describes");
|
|
34
|
-
entries.push({
|
|
35
|
-
file,
|
|
36
|
-
path,
|
|
37
|
-
manifest
|
|
38
|
-
});
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.warn(`Skipping registry file ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return entries;
|
|
44
|
-
}
|
|
45
|
-
/** Whether a manifest describes this version of its package. A manifest without a range covers every version. */
|
|
46
|
-
function covers(manifest, version) {
|
|
47
|
-
const range = manifest.package?.range;
|
|
48
|
-
if (!range) return true;
|
|
49
|
-
if (!version) return false;
|
|
50
|
-
const parsed = semver.coerce(version, { includePrerelease: true });
|
|
51
|
-
return parsed !== null && semver.satisfies(parsed, range, { includePrerelease: true });
|
|
52
|
-
}
|
|
53
|
-
export { registryDir as n, registryEntries as r, covers as t };
|
package/dist/src-BgQ7gnXE.mjs
DELETED
package/dist/src-CiqdFzei.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as covers, n as registryDir, r as registryEntries } from "./src-BIVDlIGc.mjs";
|