rafters 0.0.1 → 0.0.2
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 +123 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -50518,6 +50518,20 @@ var TOOL_DEFINITIONS = [
|
|
|
50518
50518
|
},
|
|
50519
50519
|
required: ["name"]
|
|
50520
50520
|
}
|
|
50521
|
+
},
|
|
50522
|
+
{
|
|
50523
|
+
name: "rafters_token",
|
|
50524
|
+
description: "Get full intelligence for a design token: current value, derivation rule, dependencies, dependents (cascade impact), and human override context. Shows what the system computes vs what a designer chose and why. Use when you need to understand token relationships or respect designer decisions.",
|
|
50525
|
+
inputSchema: {
|
|
50526
|
+
type: "object",
|
|
50527
|
+
properties: {
|
|
50528
|
+
name: {
|
|
50529
|
+
type: "string",
|
|
50530
|
+
description: 'Token name (e.g., "spacing-6", "primary-500", "spacing-base"). Use rafters_vocabulary to see available tokens.'
|
|
50531
|
+
}
|
|
50532
|
+
},
|
|
50533
|
+
required: ["name"]
|
|
50534
|
+
}
|
|
50521
50535
|
}
|
|
50522
50536
|
];
|
|
50523
50537
|
var RaftersToolHandler = class {
|
|
@@ -50538,6 +50552,8 @@ var RaftersToolHandler = class {
|
|
|
50538
50552
|
return this.getPattern(args.pattern);
|
|
50539
50553
|
case "rafters_component":
|
|
50540
50554
|
return this.getComponent(args.name);
|
|
50555
|
+
case "rafters_token":
|
|
50556
|
+
return this.getToken(args.name);
|
|
50541
50557
|
default:
|
|
50542
50558
|
return {
|
|
50543
50559
|
content: [{ type: "text", text: `Unknown tool: ${name2}` }],
|
|
@@ -50897,6 +50913,113 @@ var RaftersToolHandler = class {
|
|
|
50897
50913
|
return this.handleError("getComponent", error47);
|
|
50898
50914
|
}
|
|
50899
50915
|
}
|
|
50916
|
+
// ==================== Tool 4: Token ====================
|
|
50917
|
+
/**
|
|
50918
|
+
* Get full token intelligence including dependency graph and override context
|
|
50919
|
+
*/
|
|
50920
|
+
async getToken(tokenName) {
|
|
50921
|
+
try {
|
|
50922
|
+
const namespaces = ["color", "spacing", "typography"];
|
|
50923
|
+
let foundToken = null;
|
|
50924
|
+
let foundNamespace = "";
|
|
50925
|
+
for (const ns of namespaces) {
|
|
50926
|
+
try {
|
|
50927
|
+
const tokens = await this.adapter.loadNamespace(ns);
|
|
50928
|
+
const token = tokens.find((t2) => t2.name === tokenName);
|
|
50929
|
+
if (token) {
|
|
50930
|
+
foundToken = token;
|
|
50931
|
+
foundNamespace = ns;
|
|
50932
|
+
break;
|
|
50933
|
+
}
|
|
50934
|
+
} catch {
|
|
50935
|
+
}
|
|
50936
|
+
}
|
|
50937
|
+
if (!foundToken) {
|
|
50938
|
+
const allTokenNames = [];
|
|
50939
|
+
for (const ns of namespaces) {
|
|
50940
|
+
try {
|
|
50941
|
+
const tokens = await this.adapter.loadNamespace(ns);
|
|
50942
|
+
allTokenNames.push(...tokens.map((t2) => t2.name));
|
|
50943
|
+
} catch {
|
|
50944
|
+
}
|
|
50945
|
+
}
|
|
50946
|
+
const similar = allTokenNames.filter((n) => n.includes(tokenName) || tokenName.includes(n.split("-")[0] || "")).slice(0, 5);
|
|
50947
|
+
return {
|
|
50948
|
+
content: [
|
|
50949
|
+
{
|
|
50950
|
+
type: "text",
|
|
50951
|
+
text: JSON.stringify(
|
|
50952
|
+
{
|
|
50953
|
+
error: `Token "${tokenName}" not found`,
|
|
50954
|
+
similar: similar.length > 0 ? similar : void 0,
|
|
50955
|
+
suggestion: "Use rafters_vocabulary to see all available tokens"
|
|
50956
|
+
},
|
|
50957
|
+
null,
|
|
50958
|
+
2
|
|
50959
|
+
)
|
|
50960
|
+
}
|
|
50961
|
+
],
|
|
50962
|
+
isError: true
|
|
50963
|
+
};
|
|
50964
|
+
}
|
|
50965
|
+
const intelligence = {
|
|
50966
|
+
name: foundToken.name,
|
|
50967
|
+
namespace: foundNamespace,
|
|
50968
|
+
value: foundToken.value
|
|
50969
|
+
};
|
|
50970
|
+
if (foundToken.generationRule) {
|
|
50971
|
+
intelligence.derivation = {
|
|
50972
|
+
rule: foundToken.generationRule,
|
|
50973
|
+
mathRelationship: foundToken.mathRelationship,
|
|
50974
|
+
progressionSystem: foundToken.progressionSystem,
|
|
50975
|
+
scalePosition: foundToken.scalePosition
|
|
50976
|
+
};
|
|
50977
|
+
}
|
|
50978
|
+
if (foundToken.dependsOn && foundToken.dependsOn.length > 0) {
|
|
50979
|
+
intelligence.dependsOn = foundToken.dependsOn;
|
|
50980
|
+
}
|
|
50981
|
+
if (foundToken.computedValue !== void 0) {
|
|
50982
|
+
intelligence.computedValue = foundToken.computedValue;
|
|
50983
|
+
}
|
|
50984
|
+
if (foundToken.userOverride) {
|
|
50985
|
+
intelligence.override = {
|
|
50986
|
+
previousValue: foundToken.userOverride.previousValue,
|
|
50987
|
+
reason: foundToken.userOverride.reason,
|
|
50988
|
+
overriddenBy: foundToken.userOverride.overriddenBy,
|
|
50989
|
+
overriddenAt: foundToken.userOverride.overriddenAt,
|
|
50990
|
+
context: foundToken.userOverride.context,
|
|
50991
|
+
tags: foundToken.userOverride.tags,
|
|
50992
|
+
revertAfter: foundToken.userOverride.revertAfter
|
|
50993
|
+
};
|
|
50994
|
+
intelligence.isOverridden = true;
|
|
50995
|
+
} else {
|
|
50996
|
+
intelligence.isOverridden = false;
|
|
50997
|
+
}
|
|
50998
|
+
if (foundToken.semanticMeaning) {
|
|
50999
|
+
intelligence.semanticMeaning = foundToken.semanticMeaning;
|
|
51000
|
+
}
|
|
51001
|
+
if (foundToken.usageContext) {
|
|
51002
|
+
intelligence.usageContext = foundToken.usageContext;
|
|
51003
|
+
}
|
|
51004
|
+
if (foundToken.usagePatterns) {
|
|
51005
|
+
intelligence.do = foundToken.usagePatterns.do;
|
|
51006
|
+
intelligence.never = foundToken.usagePatterns.never;
|
|
51007
|
+
}
|
|
51008
|
+
if (foundToken.containerQueryAware !== void 0) {
|
|
51009
|
+
intelligence.containerQueryAware = foundToken.containerQueryAware;
|
|
51010
|
+
}
|
|
51011
|
+
return {
|
|
51012
|
+
content: [
|
|
51013
|
+
{
|
|
51014
|
+
type: "text",
|
|
51015
|
+
text: JSON.stringify(intelligence, null, 2)
|
|
51016
|
+
}
|
|
51017
|
+
]
|
|
51018
|
+
};
|
|
51019
|
+
} catch (error47) {
|
|
51020
|
+
return this.handleError("getToken", error47);
|
|
51021
|
+
}
|
|
51022
|
+
}
|
|
50900
51023
|
/**
|
|
50901
51024
|
* Handle errors consistently
|
|
50902
51025
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rafters",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "CLI for Rafters design system - scaffold tokens and add components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"typescript": "5.9.3",
|
|
29
29
|
"vitest": "^3.2.0",
|
|
30
30
|
"zocker": "^3.0.0",
|
|
31
|
-
"@rafters/
|
|
32
|
-
"@rafters/
|
|
31
|
+
"@rafters/design-tokens": "0.0.1",
|
|
32
|
+
"@rafters/shared": "0.0.1"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|