@pixerate/editor 0.271.0 → 0.272.1
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/agent/index.cjs +34 -32
- package/dist/agent/index.js +10 -8
- package/dist/animation-editor/index.cjs +60 -60
- package/dist/animation-editor/index.js +4 -4
- package/dist/brushes/index.cjs +69 -66
- package/dist/brushes/index.js +6 -3
- package/dist/brushes/patch.d.cts +1 -1
- package/dist/brushes/patch.d.ts +1 -1
- package/dist/brushes/schema.d.cts +1 -0
- package/dist/brushes/schema.d.ts +1 -0
- package/dist/brushes/types.d.cts +8 -0
- package/dist/brushes/types.d.ts +8 -0
- package/dist/{brushstrokeRender-WR2N5HHY.cjs → brushstrokeRender-5YBCLFDQ.cjs} +15 -15
- package/dist/{brushstrokeRender-A727TTNQ.js → brushstrokeRender-DZGFU3J4.js} +3 -3
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/chart/contract.d.cts +95 -0
- package/dist/chart/contract.d.ts +95 -0
- package/dist/chart/controller.d.cts +4 -0
- package/dist/chart/controller.d.ts +4 -0
- package/dist/chart/index.cjs +492 -26
- package/dist/chart/index.d.cts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.js +476 -10
- package/dist/chart/tools.d.cts +3 -0
- package/dist/chart/tools.d.ts +3 -0
- package/dist/chart-maps/index.cjs +4 -64
- package/dist/chart-maps/index.js +3 -63
- package/dist/{chunk-YNFSH72F.js → chunk-2F3YDXCN.js} +1 -1
- package/dist/{chunk-QYXUE37Q.js → chunk-2XDNF73E.js} +1 -1
- package/dist/{chunk-3KNQ2W6X.cjs → chunk-3JKCREEU.cjs} +59 -53
- package/dist/{chunk-NMZQMPFZ.js → chunk-4LZQO5Y7.js} +2 -0
- package/dist/{chunk-B5W677L7.js → chunk-5HP2VSAS.js} +1 -1
- package/dist/chunk-5UGRMVNE.js +328 -0
- package/dist/{chunk-X4FTNFIA.js → chunk-7MGPW2OV.js} +1 -1
- package/dist/{chunk-BPJSI4NT.cjs → chunk-7W2EQQBP.cjs} +2 -2
- package/dist/{chunk-DGITFN73.cjs → chunk-BWJBZAUE.cjs} +8 -8
- package/dist/chunk-CHZYVNXZ.js +336 -0
- package/dist/{chunk-LETF75CA.js → chunk-CLB2I2FU.js} +1 -1
- package/dist/chunk-DRMZ5R3S.cjs +67 -0
- package/dist/{chunk-BAZMCFVL.js → chunk-DZVRH63Y.js} +1 -1
- package/dist/chunk-EI5GFTKG.js +67 -0
- package/dist/{chunk-U2ASNGO6.cjs → chunk-FXVCB6YG.cjs} +35 -35
- package/dist/{chunk-EU2ZZA6L.cjs → chunk-GHGBIAWQ.cjs} +126 -39
- package/dist/chunk-JV7DKLMX.js +1073 -0
- package/dist/{chunk-2WOGXEDX.cjs → chunk-M3RZOF3G.cjs} +1 -1
- package/dist/chunk-MFBUQC67.cjs +328 -0
- package/dist/{chunk-GSTSZPSR.js → chunk-N3SKPQEH.js} +225 -18
- package/dist/{chunk-J5VQYK7T.cjs → chunk-N5IMDAHM.cjs} +251 -44
- package/dist/{chunk-ININNHLM.js → chunk-NAHJV3O6.js} +11 -5
- package/dist/{chunk-IBXEQOGI.js → chunk-PYHB2EHE.js} +2 -324
- package/dist/chunk-QEUI6OGE.cjs +336 -0
- package/dist/{chunk-6ZSFRRJI.js → chunk-RSF6BT34.js} +1 -1
- package/dist/{chunk-JJ2H25JG.cjs → chunk-SNAFFCAX.cjs} +200 -174
- package/dist/chunk-T2HUQBRC.cjs +1073 -0
- package/dist/{chunk-M2ZVPU7L.cjs → chunk-TNLKFW7D.cjs} +23 -23
- package/dist/{chunk-KZI3YWKW.js → chunk-UXYCY3HP.js} +93 -6
- package/dist/{chunk-GSLOH2IN.cjs → chunk-VF6ODSYX.cjs} +2 -0
- package/dist/{chunk-NQUKTRKN.cjs → chunk-WZLNNGG3.cjs} +45 -45
- package/dist/{chunk-NRBGAEFI.cjs → chunk-Y3RUYOOW.cjs} +8 -330
- package/dist/{chunk-DDL3ZBHK.cjs → chunk-YJANF2BL.cjs} +86 -86
- package/dist/{chunk-TNHDCP4R.js → chunk-ZEI7ZEA4.js} +31 -5
- package/dist/commands/index.cjs +7 -323
- package/dist/commands/index.js +5 -321
- package/dist/extensions/index.cjs +4 -4
- package/dist/extensions/index.js +3 -3
- package/dist/image-editor/index.cjs +789 -789
- package/dist/image-editor/index.js +5 -5
- package/dist/index.cjs +9 -9
- package/dist/index.js +3 -3
- package/dist/paint/index.cjs +2 -2
- package/dist/paint/index.js +1 -1
- package/dist/paint/wet/world.d.cts +37 -1
- package/dist/paint/wet/world.d.ts +37 -1
- package/dist/paint-editor/brush-controls.d.cts +2 -0
- package/dist/paint-editor/brush-controls.d.ts +2 -0
- package/dist/paint-editor/brush-model.d.cts +14 -1
- package/dist/paint-editor/brush-model.d.ts +14 -1
- package/dist/paint-editor/index.cjs +343 -306
- package/dist/paint-editor/index.js +48 -11
- package/dist/paint-editor/ui.d.cts +1 -1
- package/dist/paint-editor/ui.d.ts +1 -1
- package/dist/paint-editor/wet.d.cts +8 -1
- package/dist/paint-editor/wet.d.ts +8 -1
- package/dist/persistence/index.cjs +24 -1042
- package/dist/persistence/index.js +22 -1040
- package/dist/tools/index.cjs +5 -3
- package/dist/tools/index.js +8 -6
- package/dist/vector/index.cjs +999 -999
- package/dist/vector/index.js +5 -5
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +4 -11
- package/skills/pixerate-paint-editor/references/brush-facets.md +1 -0
- package/skills/pixerate-paint-editor/references/ghost.md +47 -0
- package/skills/pixerate-paint-watercolour/SKILL.md +1 -0
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMFBUQC67cjs = require('./chunk-MFBUQC67.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk3SLBXKAWcjs = require('./chunk-3SLBXKAW.cjs');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
var _chunkWOFXZ3XUcjs = require('./chunk-WOFXZ3XU.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunk2BSBFBOAcjs = require('./chunk-2BSBFBOA.cjs');
|
|
14
|
-
|
|
15
8
|
// src/tools/skill-evals.ts
|
|
16
9
|
function listSkillEvals(files) {
|
|
17
10
|
const out = [];
|
|
@@ -182,316 +175,6 @@ async function runToolScript(source, script, options = {}) {
|
|
|
182
175
|
return finish(true);
|
|
183
176
|
}
|
|
184
177
|
|
|
185
|
-
// src/tools/style.ts
|
|
186
|
-
var STYLE_SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
187
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
188
|
-
function parseStyleDomains(markdown) {
|
|
189
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(markdown);
|
|
190
|
-
const line = _optionalChain([match, 'optionalAccess', _13 => _13[1], 'access', _14 => _14.split, 'call', _15 => _15(/\r?\n/), 'access', _16 => _16.find, 'call', _17 => _17((l) => /^domains:/.test(l))]);
|
|
191
|
-
if (!line) return void 0;
|
|
192
|
-
const raw = line.slice("domains:".length).trim().replace(/^\[|\]$/g, "");
|
|
193
|
-
return raw.split(",").map((d) => d.trim().replace(/^(['"])(.*)\1$/, "$2")).filter(Boolean);
|
|
194
|
-
}
|
|
195
|
-
function memoryStyleStore(initial = {}, state = {}) {
|
|
196
|
-
const files = /* @__PURE__ */ new Map();
|
|
197
|
-
const states = new Map(Object.entries(state));
|
|
198
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
199
|
-
const notify = () => listeners.forEach((l) => l());
|
|
200
|
-
for (const [path, text] of Object.entries(initial)) {
|
|
201
|
-
const [dir, ...rest] = path.replace(/\\/g, "/").replace(/^\.?\//, "").split("/");
|
|
202
|
-
if (!dir || !rest.length) continue;
|
|
203
|
-
if (!files.has(dir)) files.set(dir, /* @__PURE__ */ new Map());
|
|
204
|
-
files.get(dir).set(rest.join("/"), text);
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
list: () => [.../* @__PURE__ */ new Set([...files.keys(), ...states.keys()])].sort().map((name) => ({ name, ...states.get(name) })),
|
|
208
|
-
read: (name, file) => _optionalChain([files, 'access', _18 => _18.get, 'call', _19 => _19(name), 'optionalAccess', _20 => _20.get, 'call', _21 => _21(file)]),
|
|
209
|
-
files: (name) => [..._nullishCoalesce(_optionalChain([files, 'access', _22 => _22.get, 'call', _23 => _23(name), 'optionalAccess', _24 => _24.keys, 'call', _25 => _25()]), () => ( []))].sort(),
|
|
210
|
-
subscribe(listener) {
|
|
211
|
-
listeners.add(listener);
|
|
212
|
-
return () => listeners.delete(listener);
|
|
213
|
-
},
|
|
214
|
-
set(name, skillFiles) {
|
|
215
|
-
files.set(name, new Map(Object.entries(skillFiles)));
|
|
216
|
-
notify();
|
|
217
|
-
},
|
|
218
|
-
remove(name) {
|
|
219
|
-
files.delete(name);
|
|
220
|
-
states.delete(name);
|
|
221
|
-
notify();
|
|
222
|
-
},
|
|
223
|
-
setState(name, next) {
|
|
224
|
-
if (next) states.set(name, next);
|
|
225
|
-
else states.delete(name);
|
|
226
|
-
notify();
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
function resolveTokens(value, tokens, path, errors) {
|
|
231
|
-
if (Array.isArray(value)) return value.map((v, i) => resolveTokens(v, tokens, `${path}[${i}]`, errors));
|
|
232
|
-
if (!isPlainObject(value)) return value;
|
|
233
|
-
if ("$token" in value) {
|
|
234
|
-
const token = value.$token;
|
|
235
|
-
const mode = value.mode;
|
|
236
|
-
if (typeof token !== "string" || !token || mode !== void 0 && typeof mode !== "string" || Object.keys(value).some((k) => k !== "$token" && k !== "mode")) {
|
|
237
|
-
errors.push(`${path || "profile"}: a token reference is { "$token": "<variable name or id>", "mode"?: "<mode>" }.`);
|
|
238
|
-
return void 0;
|
|
239
|
-
}
|
|
240
|
-
if (!tokens) {
|
|
241
|
-
errors.push(`${path}: "${token}" is a token reference, but this host has no design tokens to resolve it.`);
|
|
242
|
-
return void 0;
|
|
243
|
-
}
|
|
244
|
-
const resolved = tokens.resolve({ token, ...mode ? { mode } : {} });
|
|
245
|
-
if (!resolved.ok) errors.push(`${path}: ${resolved.message}`);
|
|
246
|
-
return resolved.ok ? resolved.value : void 0;
|
|
247
|
-
}
|
|
248
|
-
const out = {};
|
|
249
|
-
for (const [k, v] of Object.entries(value)) out[k] = resolveTokens(v, tokens, path ? `${path}.${k}` : k, errors);
|
|
250
|
-
return out;
|
|
251
|
-
}
|
|
252
|
-
function checkListErrors(list, domain) {
|
|
253
|
-
if (list === void 0) return [];
|
|
254
|
-
if (!Array.isArray(list)) return ['checks: expected a list of check ids or { "id": ..., options } objects.'];
|
|
255
|
-
const errors = [];
|
|
256
|
-
list.forEach((entry, i) => {
|
|
257
|
-
const id = typeof entry === "string" ? entry : isPlainObject(entry) ? entry.id : void 0;
|
|
258
|
-
if (typeof id !== "string" || !id) {
|
|
259
|
-
errors.push(`checks[${i}]: expected a check id or { "id": ..., options }.`);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const check = domain.checks.find((c) => c.id === id);
|
|
263
|
-
if (!check || typeof entry === "string") return;
|
|
264
|
-
const { id: _id, ...options } = entry;
|
|
265
|
-
const schema = _nullishCoalesce(check.optionsSchema, () => ( { type: "object", properties: {}, additionalProperties: false }));
|
|
266
|
-
for (const e of _chunkWOFXZ3XUcjs.validateJsonSchema.call(void 0, options, schema)) errors.push(`checks[${i}] (${id})${e.path}: ${e.message}`);
|
|
267
|
-
});
|
|
268
|
-
return errors;
|
|
269
|
-
}
|
|
270
|
-
function mergeProfile(target, value, layer, skill, sources, locked, issues, prefix = "") {
|
|
271
|
-
for (const [key, next] of Object.entries(value)) {
|
|
272
|
-
if (_chunk2BSBFBOAcjs.isUnsafeJsonKey.call(void 0, key) || next === void 0) continue;
|
|
273
|
-
const path = prefix ? `${prefix}.${key}` : key;
|
|
274
|
-
const lockedBy = [...locked.entries()].find(([p]) => p === path || path.startsWith(`${p}.`) || p.startsWith(`${path}.`));
|
|
275
|
-
if (isPlainObject(next)) {
|
|
276
|
-
if (!isPlainObject(target[key])) {
|
|
277
|
-
if (lockedBy && lockedBy[1] !== layer.id && target[key] !== void 0) {
|
|
278
|
-
issues.push({ skill, layer: layer.id, message: `"${path}" is locked by the ${lockedBy[1]} layer, so this skill's value is ignored.` });
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
target[key] = {};
|
|
282
|
-
delete sources[path];
|
|
283
|
-
}
|
|
284
|
-
mergeProfile(target[key], next, layer, skill, sources, locked, issues, path);
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
if (lockedBy && lockedBy[1] !== layer.id) {
|
|
288
|
-
issues.push({ skill, layer: layer.id, message: `"${path}" is locked by the ${lockedBy[1]} layer, so this skill's value is ignored.` });
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
target[key] = Array.isArray(next) ? structuredClone(next) : next;
|
|
292
|
-
for (const p of Object.keys(sources)) if (p.startsWith(`${path}.`)) delete sources[p];
|
|
293
|
-
sources[path] = layer.id;
|
|
294
|
-
if (layer.locked) locked.set(path, layer.id);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
function createStyleResolver(options) {
|
|
298
|
-
const layers = [...options.layers];
|
|
299
|
-
const domains = [...options.domains];
|
|
300
|
-
const ids = /* @__PURE__ */ new Set();
|
|
301
|
-
for (const layer of layers) {
|
|
302
|
-
if (ids.has(layer.id)) throw new Error(`Two style layers are called "${layer.id}"; give each layer its own id.`);
|
|
303
|
-
ids.add(layer.id);
|
|
304
|
-
}
|
|
305
|
-
const domainIds = domains.map((d) => d.id);
|
|
306
|
-
const requireDomain = (id) => {
|
|
307
|
-
const domain = domains.find((d) => d.id === id);
|
|
308
|
-
if (!domain) throw new Error(`There is no house-style domain "${id}"; expected one of ${domainIds.map((d) => `"${d}"`).join(", ") || "(none registered)"}.`);
|
|
309
|
-
return domain;
|
|
310
|
-
};
|
|
311
|
-
async function load() {
|
|
312
|
-
const issues = [];
|
|
313
|
-
const entries = await Promise.all(layers.map(async (layer) => [...await layer.store.list()]));
|
|
314
|
-
const names = [...new Set(entries.flat().map((e) => e.name))];
|
|
315
|
-
const skills = [];
|
|
316
|
-
for (const name of names) {
|
|
317
|
-
if (!STYLE_SKILL_NAME.test(name)) {
|
|
318
|
-
issues.push({ skill: name, message: `"${name}" is not a valid skill name (lowercase letters, digits and hyphens, at most 64).` });
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const copies = [];
|
|
322
|
-
for (let i = 0; i < layers.length; i++) {
|
|
323
|
-
const text = await layers[i].store.read(name, "SKILL.md");
|
|
324
|
-
if (text !== void 0) copies.push({ index: i, text });
|
|
325
|
-
}
|
|
326
|
-
if (!copies.length) continue;
|
|
327
|
-
const lockedCopy = copies.find((c) => layers[c.index].locked);
|
|
328
|
-
const winner = _nullishCoalesce(lockedCopy, () => ( copies[copies.length - 1]));
|
|
329
|
-
const layer = layers[winner.index];
|
|
330
|
-
const skillIssues = [];
|
|
331
|
-
for (const c of copies) {
|
|
332
|
-
if (c.index > winner.index) skillIssues.push(`The ${layers[c.index].id} layer's copy is ignored: the ${layer.id} layer is locked.`);
|
|
333
|
-
}
|
|
334
|
-
let enabled = true;
|
|
335
|
-
let order = 0;
|
|
336
|
-
for (let i = 0; i < layers.length; i++) {
|
|
337
|
-
const entry = entries[i].find((e) => e.name === name);
|
|
338
|
-
if (!entry) continue;
|
|
339
|
-
if (i === winner.index && entry.order !== void 0) order = entry.order;
|
|
340
|
-
if (entry.enabled === void 0) continue;
|
|
341
|
-
if (layer.required && i !== winner.index) {
|
|
342
|
-
if (entry.enabled === false) skillIssues.push(`The ${layers[i].id} layer cannot switch it off: the ${layer.id} layer requires it.`);
|
|
343
|
-
continue;
|
|
344
|
-
}
|
|
345
|
-
enabled = entry.enabled;
|
|
346
|
-
}
|
|
347
|
-
const { description = "", body } = _chunk7TD63DZPcjs.parseSkillFrontmatter.call(void 0, winner.text);
|
|
348
|
-
const named = parseStyleDomains(winner.text);
|
|
349
|
-
const applies = /* @__PURE__ */ new Set();
|
|
350
|
-
for (const d of _nullishCoalesce(named, () => ( domainIds))) {
|
|
351
|
-
if (domainIds.includes(d)) applies.add(d);
|
|
352
|
-
else skillIssues.push(`It names an unknown domain "${d}"; the domains here are ${domainIds.join(", ")}.`);
|
|
353
|
-
}
|
|
354
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
355
|
-
for (const domain of domains) {
|
|
356
|
-
const raw = await layer.store.read(name, `${domain.id}.json`);
|
|
357
|
-
if (raw === void 0) continue;
|
|
358
|
-
const file = `${domain.id}.json`;
|
|
359
|
-
if (!applies.has(domain.id)) {
|
|
360
|
-
skillIssues.push(`${file} is left out: the skill's domains do not include ${domain.id}.`);
|
|
361
|
-
continue;
|
|
362
|
-
}
|
|
363
|
-
let parsed;
|
|
364
|
-
try {
|
|
365
|
-
parsed = _chunk2BSBFBOAcjs.stripPrototypeKeys.call(void 0, JSON.parse(raw));
|
|
366
|
-
} catch (error) {
|
|
367
|
-
skillIssues.push(`${file} is not valid JSON: ${error.message}`);
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (!isPlainObject(parsed)) {
|
|
371
|
-
skillIssues.push(`${file} must hold a JSON object.`);
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
const errors = [];
|
|
375
|
-
const resolved = resolveTokens(parsed, options.tokens, "", errors);
|
|
376
|
-
const { checks, ...rest } = resolved;
|
|
377
|
-
errors.push(..._chunkWOFXZ3XUcjs.validateJsonSchema.call(void 0, rest, domain.profileSchema).map((e) => `${e.path || "(profile)"}: ${e.message}`));
|
|
378
|
-
errors.push(...checkListErrors(checks, domain));
|
|
379
|
-
if (errors.length) {
|
|
380
|
-
skillIssues.push(`${file} is left out: ${errors.join(" ")}`);
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
profiles.set(domain.id, resolved);
|
|
384
|
-
}
|
|
385
|
-
skills.push({
|
|
386
|
-
info: {
|
|
387
|
-
name,
|
|
388
|
-
description,
|
|
389
|
-
layer: layer.id,
|
|
390
|
-
domains: [...applies],
|
|
391
|
-
profiles: [...profiles.keys()],
|
|
392
|
-
enabled,
|
|
393
|
-
order,
|
|
394
|
-
issues: skillIssues
|
|
395
|
-
},
|
|
396
|
-
layerIndex: winner.index,
|
|
397
|
-
body: body.trim(),
|
|
398
|
-
profiles,
|
|
399
|
-
applies
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
skills.sort((a, b) => a.layerIndex - b.layerIndex || a.info.order - b.info.order || a.info.name.localeCompare(b.info.name));
|
|
403
|
-
return { skills, issues };
|
|
404
|
-
}
|
|
405
|
-
async function resolve2(domainId) {
|
|
406
|
-
requireDomain(domainId);
|
|
407
|
-
const { skills, issues: loadIssues } = await load();
|
|
408
|
-
const issues = [...loadIssues];
|
|
409
|
-
const profile = {};
|
|
410
|
-
const sources = {};
|
|
411
|
-
const locked = /* @__PURE__ */ new Map();
|
|
412
|
-
const applied = [];
|
|
413
|
-
for (const skill of skills) {
|
|
414
|
-
if (!skill.applies.has(domainId)) continue;
|
|
415
|
-
for (const message of skill.info.issues) issues.push({ skill: skill.info.name, layer: skill.info.layer, message });
|
|
416
|
-
if (!skill.info.enabled) continue;
|
|
417
|
-
applied.push({ name: skill.info.name, description: skill.info.description, layer: skill.info.layer, body: skill.body });
|
|
418
|
-
const own = skill.profiles.get(domainId);
|
|
419
|
-
if (own) mergeProfile(profile, own, layers[skill.layerIndex], skill.info.name, sources, locked, issues);
|
|
420
|
-
}
|
|
421
|
-
return { domain: domainId, skills: applied, profile, sources, issues };
|
|
422
|
-
}
|
|
423
|
-
async function winnerLayer(name) {
|
|
424
|
-
const copies = [];
|
|
425
|
-
for (let i = 0; i < layers.length; i++) if (await layers[i].store.read(name, "SKILL.md") !== void 0) copies.push(i);
|
|
426
|
-
if (!copies.length) return void 0;
|
|
427
|
-
return layers[_nullishCoalesce(copies.find((i) => layers[i].locked), () => ( copies[copies.length - 1]))];
|
|
428
|
-
}
|
|
429
|
-
return {
|
|
430
|
-
layers,
|
|
431
|
-
domains,
|
|
432
|
-
async list(opts = {}) {
|
|
433
|
-
if (opts.domain !== void 0) requireDomain(opts.domain);
|
|
434
|
-
const { skills } = await load();
|
|
435
|
-
return skills.filter((s) => opts.domain === void 0 || s.applies.has(opts.domain)).map((s) => s.info);
|
|
436
|
-
},
|
|
437
|
-
resolve: resolve2,
|
|
438
|
-
async readFile(name, file) {
|
|
439
|
-
const layer = await winnerLayer(name);
|
|
440
|
-
return layer ? layer.store.read(name, file) : void 0;
|
|
441
|
-
},
|
|
442
|
-
async files(name) {
|
|
443
|
-
const layer = await winnerLayer(name);
|
|
444
|
-
return layer ? [...await layer.store.files(name)] : void 0;
|
|
445
|
-
},
|
|
446
|
-
async check(domainId, state) {
|
|
447
|
-
const domain = requireDomain(domainId);
|
|
448
|
-
const style = await resolve2(domainId);
|
|
449
|
-
return { ...runStyleChecks(domain, state, style), style };
|
|
450
|
-
},
|
|
451
|
-
subscribe(listener) {
|
|
452
|
-
const offs = [...layers.map((l) => _optionalChain([l, 'access', _26 => _26.store, 'access', _27 => _27.subscribe, 'optionalCall', _28 => _28(listener)])), _optionalChain([options, 'access', _29 => _29.tokens, 'optionalAccess', _30 => _30.subscribe, 'optionalCall', _31 => _31(listener)])];
|
|
453
|
-
return () => offs.forEach((off) => _optionalChain([off, 'optionalCall', _32 => _32()]));
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
function runStyleChecks(domain, state, style) {
|
|
458
|
-
const report = { findings: [], ran: [], skipped: [] };
|
|
459
|
-
const list = Array.isArray(style.profile.checks) ? style.profile.checks : [];
|
|
460
|
-
const layer = style.sources.checks;
|
|
461
|
-
for (const entry of list) {
|
|
462
|
-
const id = typeof entry === "string" ? entry : isPlainObject(entry) && typeof entry.id === "string" ? entry.id : void 0;
|
|
463
|
-
if (!id) continue;
|
|
464
|
-
const check = domain.checks.find((c) => c.id === id);
|
|
465
|
-
if (!check) {
|
|
466
|
-
report.skipped.push({ check: id, reason: `There is no "${id}" check for ${domain.id}; it has ${domain.checks.map((c) => `"${c.id}"`).join(", ")}.` });
|
|
467
|
-
continue;
|
|
468
|
-
}
|
|
469
|
-
const { id: _id, ...options } = isPlainObject(entry) ? entry : { id };
|
|
470
|
-
try {
|
|
471
|
-
for (const f of check.run(state, style.profile, options)) report.findings.push({ ...f, check: id, ...layer ? { layer } : {} });
|
|
472
|
-
report.ran.push(id);
|
|
473
|
-
} catch (error) {
|
|
474
|
-
report.skipped.push({ check: id, reason: `The check could not run: ${error.message}` });
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return report;
|
|
478
|
-
}
|
|
479
|
-
var escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
480
|
-
function renderStyle(style) {
|
|
481
|
-
if (!style.skills.length) return `No house style applies to ${style.domain}.`;
|
|
482
|
-
const blocks = style.skills.map((s) => {
|
|
483
|
-
const body = s.body.replace(/<(\/?)style_skill/gi, "<$1style_skill");
|
|
484
|
-
return `<style_skill name="${escapeAttribute(s.name)}" layer="${escapeAttribute(s.layer)}">
|
|
485
|
-
${body}
|
|
486
|
-
</style_skill>`;
|
|
487
|
-
});
|
|
488
|
-
const profile = Object.keys(style.profile).length ? `
|
|
489
|
-
|
|
490
|
-
Merged ${style.domain} profile:
|
|
491
|
-
${JSON.stringify(style.profile, null, 2)}` : "";
|
|
492
|
-
return `${blocks.join("\n\n")}${profile}`;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
178
|
// src/tools/style-tools.ts
|
|
496
179
|
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
497
180
|
function createStyleToolProvider(styles, options = {}) {
|
|
@@ -525,7 +208,7 @@ function createStyleToolProvider(styles, options = {}) {
|
|
|
525
208
|
handler: async ({ domain }) => {
|
|
526
209
|
const style = await styles.resolve(domain);
|
|
527
210
|
return {
|
|
528
|
-
content: [{ type: "text", text: renderStyle(style) }],
|
|
211
|
+
content: [{ type: "text", text: _chunkMFBUQC67cjs.renderStyle.call(void 0, style) }],
|
|
529
212
|
structuredContent: { domain, skills: style.skills.map(({ name, description, layer }) => ({ name, description, layer })), profile: style.profile, sources: style.sources, issues: style.issues }
|
|
530
213
|
};
|
|
531
214
|
}
|
|
@@ -586,11 +269,11 @@ function createStyleToolProvider(styles, options = {}) {
|
|
|
586
269
|
function createOriginMiddleware(options) {
|
|
587
270
|
const fallback = _nullishCoalesce(options.fallbackOrigin, () => ( "agent:anonymous"));
|
|
588
271
|
return (call, next) => {
|
|
589
|
-
if (_optionalChain([call, 'access',
|
|
272
|
+
if (_optionalChain([call, 'access', _13 => _13.tool, 'access', _14 => _14.annotations, 'optionalAccess', _15 => _15.readOnlyHint]) === true) return next();
|
|
590
273
|
const found = typeof options.histories === "function" ? options.histories(call) : options.histories;
|
|
591
274
|
const targets = !found ? [] : Array.isArray(found) ? found : [found];
|
|
592
275
|
if (!targets.length) return next();
|
|
593
|
-
const origin = _optionalChain([call, 'access',
|
|
276
|
+
const origin = _optionalChain([call, 'access', _16 => _16.context, 'access', _17 => _17.actor, 'optionalAccess', _18 => _18.id]) ? `agent:${call.context.actor.id}` : fallback;
|
|
594
277
|
const run = targets.reduceRight((inner, target) => () => target.withOrigin(origin, inner), next);
|
|
595
278
|
return run();
|
|
596
279
|
};
|
|
@@ -708,7 +391,7 @@ function resolveConformanceArguments(value, ids) {
|
|
|
708
391
|
}
|
|
709
392
|
function conformanceResult(result) {
|
|
710
393
|
if (result.isError) {
|
|
711
|
-
const error = _nullishCoalesce(_optionalChain([result, 'access',
|
|
394
|
+
const error = _nullishCoalesce(_optionalChain([result, 'access', _19 => _19.structuredContent, 'optionalAccess', _20 => _20.error]), () => ( {}));
|
|
712
395
|
const value = { code: _nullishCoalesce(error.code, () => ( "tool_failed")), message: _nullishCoalesce(_nullishCoalesce(error.message, () => ( resultText(result))), () => ( "")), ...error.details !== void 0 ? { details: error.details } : {} };
|
|
713
396
|
return { value: { error: value }, isError: true };
|
|
714
397
|
}
|
|
@@ -739,7 +422,7 @@ function conformanceValuesMatch(a, b) {
|
|
|
739
422
|
}
|
|
740
423
|
async function runConformanceScenario(scenario, host) {
|
|
741
424
|
const ids = new ConformanceIds();
|
|
742
|
-
const isId = _optionalChain([host, 'access',
|
|
425
|
+
const isId = _optionalChain([host, 'access', _21 => _21.isGeneratedId, 'optionalAccess', _22 => _22.bind, 'call', _23 => _23(host)]);
|
|
743
426
|
const outputs = [];
|
|
744
427
|
try {
|
|
745
428
|
for (const step of scenario.steps) {
|
|
@@ -759,7 +442,7 @@ async function runConformanceScenario(scenario, host) {
|
|
|
759
442
|
outputs.push(output);
|
|
760
443
|
}
|
|
761
444
|
} finally {
|
|
762
|
-
_optionalChain([host, 'access',
|
|
445
|
+
_optionalChain([host, 'access', _24 => _24.dispose, 'optionalCall', _25 => _25()]);
|
|
763
446
|
}
|
|
764
447
|
return outputs;
|
|
765
448
|
}
|
|
@@ -784,9 +467,4 @@ async function runConformanceScenario(scenario, host) {
|
|
|
784
467
|
|
|
785
468
|
|
|
786
469
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
exports.listSkillEvals = listSkillEvals; exports.imageEvalFixturePixels = imageEvalFixturePixels; exports.callEvalTool = callEvalTool; exports.matchesEvalExpectation = matchesEvalExpectation; exports.failedEvalChecks = failedEvalChecks; exports.toolResultValue = toolResultValue; exports.toolResultError = toolResultError; exports.runToolScript = runToolScript; exports.parseStyleDomains = parseStyleDomains; exports.memoryStyleStore = memoryStyleStore; exports.createStyleResolver = createStyleResolver; exports.runStyleChecks = runStyleChecks; exports.renderStyle = renderStyle; exports.createStyleToolProvider = createStyleToolProvider; exports.createOriginMiddleware = createOriginMiddleware; exports.ConformanceIds = ConformanceIds; exports.CONFORMANCE_BINARY_MIN_LENGTH = CONFORMANCE_BINARY_MIN_LENGTH; exports.normalizeConformanceValue = normalizeConformanceValue; exports.omitConformancePaths = omitConformancePaths; exports.resolveConformanceArguments = resolveConformanceArguments; exports.conformanceResult = conformanceResult; exports.CONFORMANCE_NUMBER_TOLERANCE = CONFORMANCE_NUMBER_TOLERANCE; exports.conformanceValuesMatch = conformanceValuesMatch; exports.runConformanceScenario = runConformanceScenario;
|
|
470
|
+
exports.listSkillEvals = listSkillEvals; exports.imageEvalFixturePixels = imageEvalFixturePixels; exports.callEvalTool = callEvalTool; exports.matchesEvalExpectation = matchesEvalExpectation; exports.failedEvalChecks = failedEvalChecks; exports.toolResultValue = toolResultValue; exports.toolResultError = toolResultError; exports.runToolScript = runToolScript; exports.createStyleToolProvider = createStyleToolProvider; exports.createOriginMiddleware = createOriginMiddleware; exports.ConformanceIds = ConformanceIds; exports.CONFORMANCE_BINARY_MIN_LENGTH = CONFORMANCE_BINARY_MIN_LENGTH; exports.normalizeConformanceValue = normalizeConformanceValue; exports.omitConformancePaths = omitConformancePaths; exports.resolveConformanceArguments = resolveConformanceArguments; exports.conformanceResult = conformanceResult; exports.CONFORMANCE_NUMBER_TOLERANCE = CONFORMANCE_NUMBER_TOLERANCE; exports.conformanceValuesMatch = conformanceValuesMatch; exports.runConformanceScenario = runConformanceScenario;
|