rafters 0.0.12 → 0.0.13
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 +64 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13290,7 +13290,7 @@ function transformPath(registryPath, config3) {
|
|
|
13290
13290
|
function fileExists(cwd, relativePath) {
|
|
13291
13291
|
return existsSync(join3(cwd, relativePath));
|
|
13292
13292
|
}
|
|
13293
|
-
function transformFileContent(content, config3) {
|
|
13293
|
+
function transformFileContent(content, config3, fileType = "component") {
|
|
13294
13294
|
let transformed = content;
|
|
13295
13295
|
const componentsPath = config3?.componentsPath ?? "components/ui";
|
|
13296
13296
|
const primitivesPath = config3?.primitivesPath ?? "lib/primitives";
|
|
@@ -13302,10 +13302,8 @@ function transformFileContent(content, config3) {
|
|
|
13302
13302
|
/from\s+['"]\.\.\/primitives\/([^'"]+)['"]/g,
|
|
13303
13303
|
`from '@/${primitivesPath}/$1'`
|
|
13304
13304
|
);
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
`from '@/${componentsPath}/$1'`
|
|
13308
|
-
);
|
|
13305
|
+
const siblingPath = fileType === "primitive" ? primitivesPath : componentsPath;
|
|
13306
|
+
transformed = transformed.replace(/from\s+['"]\.\/([^'"]+)['"]/g, `from '@/${siblingPath}/$1'`);
|
|
13309
13307
|
const libPath = dirname(primitivesPath);
|
|
13310
13308
|
transformed = transformed.replace(
|
|
13311
13309
|
/from\s+['"]\.\.\/lib\/([^'"]+)['"]/g,
|
|
@@ -13342,7 +13340,8 @@ async function installItem(cwd, item, options, config3) {
|
|
|
13342
13340
|
}
|
|
13343
13341
|
}
|
|
13344
13342
|
await mkdir(dirname(targetPath), { recursive: true });
|
|
13345
|
-
const
|
|
13343
|
+
const fileType = item.type === "primitive" ? "primitive" : "component";
|
|
13344
|
+
const transformedContent = transformFileContent(file2.content, config3, fileType);
|
|
13346
13345
|
await writeFile(targetPath, transformedContent, "utf-8");
|
|
13347
13346
|
installedFiles.push(projectPath);
|
|
13348
13347
|
}
|
|
@@ -24715,7 +24714,7 @@ var require_volume = __commonJS({
|
|
|
24715
24714
|
var Dir_1 = require_Dir();
|
|
24716
24715
|
var resolveCrossPlatform = pathModule.resolve;
|
|
24717
24716
|
var { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_DIRECTORY, O_SYMLINK, F_OK, COPYFILE_EXCL, COPYFILE_FICLONE_FORCE } = constants_1.constants;
|
|
24718
|
-
var { sep: sep2, relative:
|
|
24717
|
+
var { sep: sep2, relative: relative3, join: join12, dirname: dirname4 } = pathModule.posix ? pathModule.posix : pathModule;
|
|
24719
24718
|
var kMinPoolSpace = 128;
|
|
24720
24719
|
var EPERM = "EPERM";
|
|
24721
24720
|
var ENOENT2 = "ENOENT";
|
|
@@ -25058,7 +25057,7 @@ var require_volume = __commonJS({
|
|
|
25058
25057
|
if (node.isFile()) {
|
|
25059
25058
|
let filename = child.getPath();
|
|
25060
25059
|
if (path2)
|
|
25061
|
-
filename =
|
|
25060
|
+
filename = relative3(path2, filename);
|
|
25062
25061
|
json3[filename] = asBuffer ? node.getBuffer() : node.getString();
|
|
25063
25062
|
} else if (node.isDirectory()) {
|
|
25064
25063
|
this._toJSON(child, json3, path2, asBuffer);
|
|
@@ -25066,7 +25065,7 @@ var require_volume = __commonJS({
|
|
|
25066
25065
|
}
|
|
25067
25066
|
let dirPath = link.getPath();
|
|
25068
25067
|
if (path2)
|
|
25069
|
-
dirPath =
|
|
25068
|
+
dirPath = relative3(path2, dirPath);
|
|
25070
25069
|
if (dirPath && isEmpty) {
|
|
25071
25070
|
json3[dirPath] = null;
|
|
25072
25071
|
}
|
|
@@ -26544,7 +26543,7 @@ var require_volume = __commonJS({
|
|
|
26544
26543
|
const filepath = link.getPath();
|
|
26545
26544
|
const node = link.getNode();
|
|
26546
26545
|
const onNodeChange = () => {
|
|
26547
|
-
let filename =
|
|
26546
|
+
let filename = relative3(this._filename, filepath);
|
|
26548
26547
|
if (!filename) {
|
|
26549
26548
|
filename = this._getName();
|
|
26550
26549
|
}
|
|
@@ -26559,7 +26558,7 @@ var require_volume = __commonJS({
|
|
|
26559
26558
|
var _a;
|
|
26560
26559
|
const node = link.getNode();
|
|
26561
26560
|
const onLinkChildAdd = (l) => {
|
|
26562
|
-
this.emit("change", "rename",
|
|
26561
|
+
this.emit("change", "rename", relative3(this._filename, l.getPath()));
|
|
26563
26562
|
setTimeout(() => {
|
|
26564
26563
|
watchLinkNodeChanged(l);
|
|
26565
26564
|
watchLinkChildrenChanged(l);
|
|
@@ -26580,7 +26579,7 @@ var require_volume = __commonJS({
|
|
|
26580
26579
|
}
|
|
26581
26580
|
};
|
|
26582
26581
|
removeLinkNodeListeners(l);
|
|
26583
|
-
this.emit("change", "rename",
|
|
26582
|
+
this.emit("change", "rename", relative3(this._filename, l.getPath()));
|
|
26584
26583
|
};
|
|
26585
26584
|
for (const [name2, childLink] of link.children.entries()) {
|
|
26586
26585
|
if (childLink && name2 !== "." && name2 !== "..") {
|
|
@@ -33680,10 +33679,10 @@ var Ignore = class {
|
|
|
33680
33679
|
ignored(p) {
|
|
33681
33680
|
const fullpath = p.fullpath();
|
|
33682
33681
|
const fullpaths = `${fullpath}/`;
|
|
33683
|
-
const
|
|
33684
|
-
const relatives = `${
|
|
33682
|
+
const relative3 = p.relative() || ".";
|
|
33683
|
+
const relatives = `${relative3}/`;
|
|
33685
33684
|
for (const m of this.relative) {
|
|
33686
|
-
if (m.match(
|
|
33685
|
+
if (m.match(relative3) || m.match(relatives))
|
|
33687
33686
|
return true;
|
|
33688
33687
|
}
|
|
33689
33688
|
for (const m of this.absolute) {
|
|
@@ -33694,9 +33693,9 @@ var Ignore = class {
|
|
|
33694
33693
|
}
|
|
33695
33694
|
childrenIgnored(p) {
|
|
33696
33695
|
const fullpath = p.fullpath() + "/";
|
|
33697
|
-
const
|
|
33696
|
+
const relative3 = (p.relative() || ".") + "/";
|
|
33698
33697
|
for (const m of this.relativeChildren) {
|
|
33699
|
-
if (m.match(
|
|
33698
|
+
if (m.match(relative3))
|
|
33700
33699
|
return true;
|
|
33701
33700
|
}
|
|
33702
33701
|
for (const m of this.absoluteChildren) {
|
|
@@ -46629,6 +46628,9 @@ function getSemanticMappingsFromTokens(semanticTokens) {
|
|
|
46629
46628
|
function tokenValueToCSS(token) {
|
|
46630
46629
|
const { value: value2 } = token;
|
|
46631
46630
|
if (typeof value2 === "string") {
|
|
46631
|
+
if (value2.startsWith("{") || value2.startsWith("[")) {
|
|
46632
|
+
return null;
|
|
46633
|
+
}
|
|
46632
46634
|
return value2;
|
|
46633
46635
|
}
|
|
46634
46636
|
if (typeof value2 === "object" && value2 !== null) {
|
|
@@ -46754,6 +46756,7 @@ function generateThemeBlock(groups) {
|
|
|
46754
46756
|
if (groups.color.length > 0) {
|
|
46755
46757
|
for (const token of groups.color) {
|
|
46756
46758
|
const value2 = tokenValueToCSS(token);
|
|
46759
|
+
if (value2 === null) continue;
|
|
46757
46760
|
lines.push(` --color-${token.name}: ${value2};`);
|
|
46758
46761
|
}
|
|
46759
46762
|
lines.push("");
|
|
@@ -46761,6 +46764,7 @@ function generateThemeBlock(groups) {
|
|
|
46761
46764
|
if (groups.spacing.length > 0) {
|
|
46762
46765
|
for (const token of groups.spacing) {
|
|
46763
46766
|
const value2 = tokenValueToCSS(token);
|
|
46767
|
+
if (value2 === null) continue;
|
|
46764
46768
|
lines.push(` --spacing-${token.name}: ${value2};`);
|
|
46765
46769
|
}
|
|
46766
46770
|
lines.push("");
|
|
@@ -46768,6 +46772,7 @@ function generateThemeBlock(groups) {
|
|
|
46768
46772
|
if (groups.typography.length > 0) {
|
|
46769
46773
|
for (const token of groups.typography) {
|
|
46770
46774
|
const value2 = tokenValueToCSS(token);
|
|
46775
|
+
if (value2 === null) continue;
|
|
46771
46776
|
lines.push(` --${token.name}: ${value2};`);
|
|
46772
46777
|
if (token.lineHeight) {
|
|
46773
46778
|
lines.push(` --${token.name}--line-height: ${token.lineHeight};`);
|
|
@@ -46778,6 +46783,7 @@ function generateThemeBlock(groups) {
|
|
|
46778
46783
|
if (groups.radius.length > 0) {
|
|
46779
46784
|
for (const token of groups.radius) {
|
|
46780
46785
|
const value2 = tokenValueToCSS(token);
|
|
46786
|
+
if (value2 === null) continue;
|
|
46781
46787
|
lines.push(` --radius-${token.name}: ${value2};`);
|
|
46782
46788
|
}
|
|
46783
46789
|
lines.push("");
|
|
@@ -46785,6 +46791,7 @@ function generateThemeBlock(groups) {
|
|
|
46785
46791
|
if (groups.shadow.length > 0) {
|
|
46786
46792
|
for (const token of groups.shadow) {
|
|
46787
46793
|
const value2 = tokenValueToCSS(token);
|
|
46794
|
+
if (value2 === null) continue;
|
|
46788
46795
|
lines.push(` --shadow-${token.name}: ${value2};`);
|
|
46789
46796
|
}
|
|
46790
46797
|
lines.push("");
|
|
@@ -46792,6 +46799,7 @@ function generateThemeBlock(groups) {
|
|
|
46792
46799
|
if (groups.depth.length > 0) {
|
|
46793
46800
|
for (const token of groups.depth) {
|
|
46794
46801
|
const value2 = tokenValueToCSS(token);
|
|
46802
|
+
if (value2 === null) continue;
|
|
46795
46803
|
lines.push(` --${token.name}: ${value2};`);
|
|
46796
46804
|
}
|
|
46797
46805
|
lines.push("");
|
|
@@ -46799,6 +46807,7 @@ function generateThemeBlock(groups) {
|
|
|
46799
46807
|
if (groups.motion.length > 0) {
|
|
46800
46808
|
for (const token of groups.motion) {
|
|
46801
46809
|
const value2 = tokenValueToCSS(token);
|
|
46810
|
+
if (value2 === null) continue;
|
|
46802
46811
|
lines.push(` --${token.name}: ${value2};`);
|
|
46803
46812
|
}
|
|
46804
46813
|
lines.push("");
|
|
@@ -46806,6 +46815,7 @@ function generateThemeBlock(groups) {
|
|
|
46806
46815
|
if (groups.breakpoint.length > 0) {
|
|
46807
46816
|
for (const token of groups.breakpoint) {
|
|
46808
46817
|
const value2 = tokenValueToCSS(token);
|
|
46818
|
+
if (value2 === null) continue;
|
|
46809
46819
|
lines.push(` --${token.name}: ${value2};`);
|
|
46810
46820
|
}
|
|
46811
46821
|
lines.push("");
|
|
@@ -46813,6 +46823,7 @@ function generateThemeBlock(groups) {
|
|
|
46813
46823
|
if (groups.elevation.length > 0) {
|
|
46814
46824
|
for (const token of groups.elevation) {
|
|
46815
46825
|
const value2 = tokenValueToCSS(token);
|
|
46826
|
+
if (value2 === null) continue;
|
|
46816
46827
|
lines.push(` --${token.name}: ${value2};`);
|
|
46817
46828
|
}
|
|
46818
46829
|
lines.push("");
|
|
@@ -46820,6 +46831,7 @@ function generateThemeBlock(groups) {
|
|
|
46820
46831
|
if (groups.focus.length > 0) {
|
|
46821
46832
|
for (const token of groups.focus) {
|
|
46822
46833
|
const value2 = tokenValueToCSS(token);
|
|
46834
|
+
if (value2 === null) continue;
|
|
46823
46835
|
lines.push(` --${token.name}: ${value2};`);
|
|
46824
46836
|
}
|
|
46825
46837
|
lines.push("");
|
|
@@ -46827,6 +46839,7 @@ function generateThemeBlock(groups) {
|
|
|
46827
46839
|
if (groups.other.length > 0) {
|
|
46828
46840
|
for (const token of groups.other) {
|
|
46829
46841
|
const value2 = tokenValueToCSS(token);
|
|
46842
|
+
if (value2 === null) continue;
|
|
46830
46843
|
lines.push(` --${token.name}: ${value2};`);
|
|
46831
46844
|
}
|
|
46832
46845
|
lines.push("");
|
|
@@ -47008,6 +47021,9 @@ async function registryToCompiled(registry2, options = {}) {
|
|
|
47008
47021
|
function tokenValueToTS(token) {
|
|
47009
47022
|
const { value: value2 } = token;
|
|
47010
47023
|
if (typeof value2 === "string") {
|
|
47024
|
+
if (value2.startsWith("{") || value2.startsWith("[")) {
|
|
47025
|
+
return value2;
|
|
47026
|
+
}
|
|
47011
47027
|
return escapeStringValue(value2);
|
|
47012
47028
|
}
|
|
47013
47029
|
if (typeof value2 === "object" && value2 !== null) {
|
|
@@ -51494,7 +51510,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprot
|
|
|
51494
51510
|
// src/mcp/tools.ts
|
|
51495
51511
|
import { existsSync as existsSync4 } from "fs";
|
|
51496
51512
|
import { readdir as readdir3, readFile as readFile6 } from "fs/promises";
|
|
51497
|
-
import { basename, join as join10 } from "path";
|
|
51513
|
+
import { basename, join as join10, relative as relative2 } from "path";
|
|
51498
51514
|
|
|
51499
51515
|
// src/mcp/cognitive-load.ts
|
|
51500
51516
|
var BUDGET_TIERS = {
|
|
@@ -52912,16 +52928,30 @@ var RaftersToolHandler = class {
|
|
|
52912
52928
|
return { sizes: {}, weights: [] };
|
|
52913
52929
|
}
|
|
52914
52930
|
}
|
|
52931
|
+
/**
|
|
52932
|
+
* Load and cache the project's Rafters config from .rafters/config.rafters.json.
|
|
52933
|
+
* Returns null when no config exists or when it cannot be parsed.
|
|
52934
|
+
*/
|
|
52935
|
+
async loadConfig() {
|
|
52936
|
+
try {
|
|
52937
|
+
const paths = getRaftersPaths(this.projectRoot);
|
|
52938
|
+
if (!existsSync4(paths.config)) {
|
|
52939
|
+
return null;
|
|
52940
|
+
}
|
|
52941
|
+
const content = await readFile6(paths.config, "utf-8");
|
|
52942
|
+
return JSON.parse(content);
|
|
52943
|
+
} catch {
|
|
52944
|
+
return null;
|
|
52945
|
+
}
|
|
52946
|
+
}
|
|
52915
52947
|
/**
|
|
52916
52948
|
* Extract compact component vocabulary
|
|
52917
52949
|
*/
|
|
52918
52950
|
async getComponentVocabulary() {
|
|
52919
52951
|
let installed = [];
|
|
52920
52952
|
try {
|
|
52921
|
-
const
|
|
52922
|
-
if (
|
|
52923
|
-
const content = await readFile6(paths.config, "utf-8");
|
|
52924
|
-
const config3 = JSON.parse(content);
|
|
52953
|
+
const config3 = await this.loadConfig();
|
|
52954
|
+
if (config3) {
|
|
52925
52955
|
installed = config3.installed?.components ?? [];
|
|
52926
52956
|
}
|
|
52927
52957
|
} catch {
|
|
@@ -52973,17 +53003,22 @@ var RaftersToolHandler = class {
|
|
|
52973
53003
|
}
|
|
52974
53004
|
// ==================== Tool 3: Component ====================
|
|
52975
53005
|
/**
|
|
52976
|
-
* Get path to UI components directory
|
|
53006
|
+
* Get path to UI components directory.
|
|
53007
|
+
* Reads componentsPath from .rafters/config.rafters.json when available,
|
|
53008
|
+
* falls back to the monorepo layout for local development.
|
|
52977
53009
|
*/
|
|
52978
|
-
getComponentsPath() {
|
|
52979
|
-
const
|
|
52980
|
-
|
|
53010
|
+
async getComponentsPath() {
|
|
53011
|
+
const config3 = await this.loadConfig();
|
|
53012
|
+
if (config3?.componentsPath) {
|
|
53013
|
+
return join10(this.projectRoot, config3.componentsPath);
|
|
53014
|
+
}
|
|
53015
|
+
return join10(this.projectRoot, "packages/ui/src/components/ui");
|
|
52981
53016
|
}
|
|
52982
53017
|
/**
|
|
52983
53018
|
* Load component metadata from source file
|
|
52984
53019
|
*/
|
|
52985
53020
|
async loadComponentMetadata(name2) {
|
|
52986
|
-
const componentsPath = this.getComponentsPath();
|
|
53021
|
+
const componentsPath = await this.getComponentsPath();
|
|
52987
53022
|
const filePath = join10(componentsPath, `${name2}.tsx`);
|
|
52988
53023
|
try {
|
|
52989
53024
|
const source = await readFile6(filePath, "utf-8");
|
|
@@ -53002,7 +53037,7 @@ var RaftersToolHandler = class {
|
|
|
53002
53037
|
sizes: extractSizes(source),
|
|
53003
53038
|
dependencies: extractDependencies(source),
|
|
53004
53039
|
primitives: extractPrimitiveDependencies(source),
|
|
53005
|
-
filePath:
|
|
53040
|
+
filePath: relative2(this.projectRoot, join10(componentsPath, `${name2}.tsx`))
|
|
53006
53041
|
};
|
|
53007
53042
|
if (hasAnyDeps(jsDocDeps)) {
|
|
53008
53043
|
metadata.jsDocDependencies = jsDocDeps;
|
|
@@ -53094,7 +53129,7 @@ var RaftersToolHandler = class {
|
|
|
53094
53129
|
try {
|
|
53095
53130
|
const metadata = await this.loadComponentMetadata(name2);
|
|
53096
53131
|
if (!metadata) {
|
|
53097
|
-
const componentsPath = this.getComponentsPath();
|
|
53132
|
+
const componentsPath = await this.getComponentsPath();
|
|
53098
53133
|
let available = [];
|
|
53099
53134
|
try {
|
|
53100
53135
|
const files = await readdir3(componentsPath);
|