rafters 0.0.83 → 0.0.84
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/index.js +121 -16
- package/dist/registry/types.d.ts +1 -0
- package/dist/registry/types.js +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28427,7 +28427,8 @@ var RegistryItemSchema = external_exports.object({
|
|
|
28427
28427
|
// Per-target facets. zod v4's `z.record(enum, ...)` demands EVERY enum key be
|
|
28428
28428
|
// present; a component built for only some targets must parse, so this is a
|
|
28429
28429
|
// partial record (only the built targets appear).
|
|
28430
|
-
facets: external_exports.partialRecord(ComponentTargetSchema, FacetSchema).default({})
|
|
28430
|
+
facets: external_exports.partialRecord(ComponentTargetSchema, FacetSchema).default({}),
|
|
28431
|
+
parent: external_exports.string().optional()
|
|
28431
28432
|
});
|
|
28432
28433
|
var RegistryIndexSchema = external_exports.object({
|
|
28433
28434
|
name: external_exports.string(),
|
|
@@ -31315,6 +31316,8 @@ function resolveWorkspace(workspaces, defaultWorkspace, name) {
|
|
|
31315
31316
|
}
|
|
31316
31317
|
|
|
31317
31318
|
// src/mcp/graph.ts
|
|
31319
|
+
var EXPAND_OP = "*";
|
|
31320
|
+
var PROBE_OP = "?";
|
|
31318
31321
|
function assembleGraph(items) {
|
|
31319
31322
|
const nodes = /* @__PURE__ */ new Map();
|
|
31320
31323
|
for (const item of items) {
|
|
@@ -31330,13 +31333,45 @@ function assembleGraph(items) {
|
|
|
31330
31333
|
if (src?.accessibility !== void 0) intel.accessibility = src.accessibility;
|
|
31331
31334
|
if (src?.attentionEconomics !== void 0) intel.attentionEconomics = src.attentionEconomics;
|
|
31332
31335
|
if (src?.trustBuilding !== void 0) intel.trustBuilding = src.trustBuilding;
|
|
31333
|
-
|
|
31336
|
+
const gn = {
|
|
31334
31337
|
id: item.name,
|
|
31335
31338
|
kind,
|
|
31336
31339
|
intel,
|
|
31337
31340
|
facets: item.facets ?? {},
|
|
31338
|
-
composesWith: item.composites
|
|
31339
|
-
|
|
31341
|
+
composesWith: item.composites,
|
|
31342
|
+
parts: []
|
|
31343
|
+
};
|
|
31344
|
+
if (item.parent !== void 0) gn.parent = item.parent;
|
|
31345
|
+
nodes.set(item.name, gn);
|
|
31346
|
+
}
|
|
31347
|
+
for (const node of nodes.values()) {
|
|
31348
|
+
if (node.parent === void 0) continue;
|
|
31349
|
+
if (node.parent === node.id) {
|
|
31350
|
+
throw new Error(`graph: node "${node.id}" parent references itself`);
|
|
31351
|
+
}
|
|
31352
|
+
if (!nodes.has(node.parent)) {
|
|
31353
|
+
throw new Error(`graph: node "${node.id}" parent names unknown id "${node.parent}"`);
|
|
31354
|
+
}
|
|
31355
|
+
}
|
|
31356
|
+
for (const node of nodes.values()) {
|
|
31357
|
+
if (node.parent === void 0) continue;
|
|
31358
|
+
const visited = /* @__PURE__ */ new Set();
|
|
31359
|
+
visited.add(node.id);
|
|
31360
|
+
let current = node.parent;
|
|
31361
|
+
while (current !== void 0) {
|
|
31362
|
+
if (visited.has(current)) {
|
|
31363
|
+
throw new Error(
|
|
31364
|
+
`graph: node "${node.id}" has a circular parent chain through "${current}"`
|
|
31365
|
+
);
|
|
31366
|
+
}
|
|
31367
|
+
visited.add(current);
|
|
31368
|
+
current = nodes.get(current)?.parent;
|
|
31369
|
+
}
|
|
31370
|
+
}
|
|
31371
|
+
for (const node of nodes.values()) {
|
|
31372
|
+
if (node.parent === void 0) continue;
|
|
31373
|
+
const parentNode = nodes.get(node.parent);
|
|
31374
|
+
if (parentNode) parentNode.parts.push(node.id);
|
|
31340
31375
|
}
|
|
31341
31376
|
for (const node of nodes.values()) {
|
|
31342
31377
|
for (const target of node.composesWith) {
|
|
@@ -31366,6 +31401,7 @@ function describe(addr, graph, target) {
|
|
|
31366
31401
|
const [head, ...rest] = parts;
|
|
31367
31402
|
if (head === void 0) return { error: `cannot resolve: ${addr}` };
|
|
31368
31403
|
if (head === "components" || head === "composites") {
|
|
31404
|
+
if (rest.length > 0) return { error: `cannot expand: ${addr}` };
|
|
31369
31405
|
const kind = head === "components" ? "component" : "composite";
|
|
31370
31406
|
const roster = [];
|
|
31371
31407
|
for (const node2 of graph.nodes.values()) {
|
|
@@ -31373,9 +31409,24 @@ function describe(addr, graph, target) {
|
|
|
31373
31409
|
}
|
|
31374
31410
|
return roster;
|
|
31375
31411
|
}
|
|
31412
|
+
if (parts[parts.length - 1] === PROBE_OP) {
|
|
31413
|
+
const baseAddr = parts.slice(0, -1).join(".");
|
|
31414
|
+
const result = describe(baseAddr, graph, target);
|
|
31415
|
+
if (typeof result === "object" && result !== null && "error" in result) return null;
|
|
31416
|
+
return result;
|
|
31417
|
+
}
|
|
31418
|
+
if (head === EXPAND_OP || head === PROBE_OP) {
|
|
31419
|
+
return { error: `cannot expand at root: use 'components' or 'composites'` };
|
|
31420
|
+
}
|
|
31376
31421
|
const node = graph.nodes.get(head);
|
|
31377
31422
|
if (!node) return { error: `unknown node: ${head}` };
|
|
31378
|
-
if (rest.length === 0) return layer0(node, target);
|
|
31423
|
+
if (rest.length === 0) return layer0(node, graph, target);
|
|
31424
|
+
if (rest[rest.length - 1] === EXPAND_OP) {
|
|
31425
|
+
const prefix = rest.slice(0, -1);
|
|
31426
|
+
if (prefix.length === 0) return expandNode(node, target);
|
|
31427
|
+
if (prefix.length === 1 && prefix[0] === "props") return expandProps(node, target);
|
|
31428
|
+
return { error: `cannot expand: ${addr}` };
|
|
31429
|
+
}
|
|
31379
31430
|
if (rest.length === 1 && rest[0] === "composesWith") {
|
|
31380
31431
|
return resolveEdges(node, graph, target);
|
|
31381
31432
|
}
|
|
@@ -31396,7 +31447,7 @@ function toAgentProp(prop) {
|
|
|
31396
31447
|
}
|
|
31397
31448
|
return prop;
|
|
31398
31449
|
}
|
|
31399
|
-
function layer0(node, target) {
|
|
31450
|
+
function layer0(node, graph, target) {
|
|
31400
31451
|
const facet = target === void 0 ? void 0 : node.facets[target];
|
|
31401
31452
|
const children = [];
|
|
31402
31453
|
if (facet) {
|
|
@@ -31409,12 +31460,23 @@ function layer0(node, target) {
|
|
|
31409
31460
|
if (node.composesWith.length > 0) {
|
|
31410
31461
|
children.push({ addr: `${node.id}.composesWith`, type: "edge" });
|
|
31411
31462
|
}
|
|
31463
|
+
for (const partId of node.parts) {
|
|
31464
|
+
children.push({ addr: partId, type: "part" });
|
|
31465
|
+
}
|
|
31412
31466
|
const result = { id: node.id, kind: node.kind, intel: node.intel, children };
|
|
31413
31467
|
if (facet) {
|
|
31414
31468
|
result.snippet = facet.snippet;
|
|
31415
31469
|
if (facet.slots !== void 0) result.slots = facet.slots;
|
|
31416
31470
|
if (facet.events !== void 0) result.events = facet.events;
|
|
31417
31471
|
}
|
|
31472
|
+
if (node.parent !== void 0) {
|
|
31473
|
+
result.parent = node.parent;
|
|
31474
|
+
const parentNode = graph.nodes.get(node.parent);
|
|
31475
|
+
if (parentNode) {
|
|
31476
|
+
const siblings = parentNode.parts.filter((id) => id !== node.id);
|
|
31477
|
+
if (siblings.length > 0) result.siblings = siblings;
|
|
31478
|
+
}
|
|
31479
|
+
}
|
|
31418
31480
|
return result;
|
|
31419
31481
|
}
|
|
31420
31482
|
function resolveEdges(node, graph, target) {
|
|
@@ -31424,10 +31486,43 @@ function resolveEdges(node, graph, target) {
|
|
|
31424
31486
|
if (seen.has(edgeId)) continue;
|
|
31425
31487
|
seen.add(edgeId);
|
|
31426
31488
|
const edgeNode = graph.nodes.get(edgeId);
|
|
31427
|
-
if (edgeNode) results.push(layer0(edgeNode, target));
|
|
31489
|
+
if (edgeNode) results.push(layer0(edgeNode, graph, target));
|
|
31428
31490
|
}
|
|
31429
31491
|
return results;
|
|
31430
31492
|
}
|
|
31493
|
+
function expandProps(node, target) {
|
|
31494
|
+
const facet = target === void 0 ? void 0 : node.facets[target];
|
|
31495
|
+
const props = {};
|
|
31496
|
+
if (facet) {
|
|
31497
|
+
for (const [name, prop] of Object.entries(facet.props)) {
|
|
31498
|
+
props[name] = toAgentProp(prop);
|
|
31499
|
+
}
|
|
31500
|
+
}
|
|
31501
|
+
return { expanded: true, props };
|
|
31502
|
+
}
|
|
31503
|
+
function expandNode(node, target) {
|
|
31504
|
+
const facet = target === void 0 ? void 0 : node.facets[target];
|
|
31505
|
+
const props = {};
|
|
31506
|
+
if (facet) {
|
|
31507
|
+
for (const [name, prop] of Object.entries(facet.props)) {
|
|
31508
|
+
props[name] = toAgentProp(prop);
|
|
31509
|
+
}
|
|
31510
|
+
}
|
|
31511
|
+
const result = {
|
|
31512
|
+
id: node.id,
|
|
31513
|
+
kind: node.kind,
|
|
31514
|
+
intel: node.intel,
|
|
31515
|
+
props
|
|
31516
|
+
};
|
|
31517
|
+
if (node.composesWith.length > 0) result.composesWith = node.composesWith;
|
|
31518
|
+
if (node.parts.length > 0) result.parts = node.parts;
|
|
31519
|
+
if (facet) {
|
|
31520
|
+
result.snippet = facet.snippet;
|
|
31521
|
+
if (facet.slots !== void 0) result.slots = facet.slots;
|
|
31522
|
+
if (facet.events !== void 0) result.events = facet.events;
|
|
31523
|
+
}
|
|
31524
|
+
return result;
|
|
31525
|
+
}
|
|
31431
31526
|
|
|
31432
31527
|
// src/mcp/intent.ts
|
|
31433
31528
|
var INTENT_TAGS = {
|
|
@@ -31551,7 +31646,7 @@ function selectNearMiss(use, decisive, matchedTags, graph) {
|
|
|
31551
31646
|
}
|
|
31552
31647
|
function describeNode(id, graph) {
|
|
31553
31648
|
const result = describe(id, graph);
|
|
31554
|
-
if (!Array.isArray(result) && "children" in result) return result;
|
|
31649
|
+
if (result !== null && !Array.isArray(result) && "children" in result) return result;
|
|
31555
31650
|
return void 0;
|
|
31556
31651
|
}
|
|
31557
31652
|
function noMatch() {
|
|
@@ -31573,22 +31668,32 @@ function describeWithOverlay(addr, graph, ctx) {
|
|
|
31573
31668
|
return roster.map((entry) => ({ id: entry.id, presence: presenceOf(set3, entry.id) }));
|
|
31574
31669
|
}
|
|
31575
31670
|
if (addr !== "" && !addr.includes(".") && isNodeResult(result)) {
|
|
31576
|
-
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
target: ctx.target,
|
|
31581
|
-
rendersForTarget: ctx.target !== void 0 && graph.nodes.get(result.id)?.facets[ctx.target] !== void 0
|
|
31582
|
-
};
|
|
31671
|
+
return { ...result, ...stampOf(result.id, result.kind, graph, ctx) };
|
|
31672
|
+
}
|
|
31673
|
+
if (isExpandedNodeResult(result)) {
|
|
31674
|
+
return { ...result, ...stampOf(result.id, result.kind, graph, ctx) };
|
|
31583
31675
|
}
|
|
31584
31676
|
return result;
|
|
31585
31677
|
}
|
|
31586
31678
|
function presenceOf(set3, id) {
|
|
31587
31679
|
return set3.has(id) ? "installed" : "available";
|
|
31588
31680
|
}
|
|
31681
|
+
function stampOf(id, kind, graph, ctx) {
|
|
31682
|
+
const set3 = kind === "component" ? ctx.installed.components : ctx.installed.composites;
|
|
31683
|
+
return {
|
|
31684
|
+
presence: presenceOf(set3, id),
|
|
31685
|
+
target: ctx.target,
|
|
31686
|
+
// rendersForTarget reads the node's own facets (on the universal graph):
|
|
31687
|
+
// does a facet for the resolved target exist?
|
|
31688
|
+
rendersForTarget: ctx.target !== void 0 && graph.nodes.get(id)?.facets[ctx.target] !== void 0
|
|
31689
|
+
};
|
|
31690
|
+
}
|
|
31589
31691
|
function isNodeResult(result) {
|
|
31590
31692
|
return typeof result === "object" && result !== null && !Array.isArray(result) && "id" in result && "kind" in result && "children" in result;
|
|
31591
31693
|
}
|
|
31694
|
+
function isExpandedNodeResult(result) {
|
|
31695
|
+
return typeof result === "object" && result !== null && !Array.isArray(result) && "id" in result && "kind" in result && "props" in result && !("children" in result);
|
|
31696
|
+
}
|
|
31592
31697
|
|
|
31593
31698
|
// src/mcp/tools.ts
|
|
31594
31699
|
function isSafeRelPath(p2) {
|
|
@@ -31679,7 +31784,7 @@ var TOOL_DEFINITIONS = [
|
|
|
31679
31784
|
},
|
|
31680
31785
|
{
|
|
31681
31786
|
name: "rafters_describe",
|
|
31682
|
-
description: 'Recursively introspect the component/composite intel graph. describe() returns the installed surface; describe(components)/describe(composites) list the kind roster; describe(button) returns a node -- intel plus type-marked, drillable children; describe(button.props.fill) drills into a prop; describe(button.props.fill.vocab) returns the real token values. A natural-language question (e.g. "what do I use when it needs to be above everything") routes to the best-matching node plus a near-miss counter-example instead of an address.',
|
|
31787
|
+
description: 'Recursively introspect the component/composite intel graph. describe() returns the installed surface; describe(components)/describe(composites) list the kind roster; describe(button) returns a node -- intel plus type-marked, drillable children; describe(button.props.fill) drills into a prop; describe(button.props.fill.vocab) returns the real token values. describe(button.*) expands all props inline in one call (no more drill-per-prop round trips); describe(button.props.fill.?) probes safely (null on miss, not an error). A natural-language question (e.g. "what do I use when it needs to be above everything") routes to the best-matching node plus a near-miss counter-example instead of an address.',
|
|
31683
31788
|
inputSchema: {
|
|
31684
31789
|
type: "object",
|
|
31685
31790
|
properties: {
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -209,6 +209,7 @@ declare const RegistryItemSchema: z.ZodObject<{
|
|
|
209
209
|
events: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
210
210
|
snippet: z.ZodString;
|
|
211
211
|
}, z.core.$strip>>>;
|
|
212
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
212
213
|
}, z.core.$strip>;
|
|
213
214
|
type RegistryItem = z.infer<typeof RegistryItemSchema>;
|
|
214
215
|
/**
|
package/dist/registry/types.js
CHANGED
|
@@ -67,7 +67,8 @@ var RegistryItemSchema = z.object({
|
|
|
67
67
|
// Per-target facets. zod v4's `z.record(enum, ...)` demands EVERY enum key be
|
|
68
68
|
// present; a component built for only some targets must parse, so this is a
|
|
69
69
|
// partial record (only the built targets appear).
|
|
70
|
-
facets: z.partialRecord(ComponentTargetSchema, FacetSchema).default({})
|
|
70
|
+
facets: z.partialRecord(ComponentTargetSchema, FacetSchema).default({}),
|
|
71
|
+
parent: z.string().optional()
|
|
71
72
|
});
|
|
72
73
|
var RegistryIndexSchema = z.object({
|
|
73
74
|
name: z.string(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rafters",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.84",
|
|
4
4
|
"description": "Design Intelligence CLI. Scaffold tokens, import existing shadcn/Tailwind v4 sources, add components, and serve an MCP server so AI agents read decisions instead of guessing.",
|
|
5
5
|
"homepage": "https://rafters.studio",
|
|
6
6
|
"license": "MIT",
|