rafters 0.0.31 → 0.0.32

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.
Files changed (2) hide show
  1. package/dist/index.js +117 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13431,30 +13431,33 @@ function transformFileContent(content, config3, fileType = "component") {
13431
13431
  let transformed = content;
13432
13432
  const componentsPath = config3?.componentsPath ?? "components/ui";
13433
13433
  const primitivesPath = config3?.primitivesPath ?? "lib/primitives";
13434
+ const stripSourceRoot = (p2) => p2.replace(/^(src|app)\//, "");
13435
+ const aliasComponents = stripSourceRoot(componentsPath);
13436
+ const aliasPrimitives = stripSourceRoot(primitivesPath);
13434
13437
  transformed = transformed.replace(
13435
13438
  /from\s+['"]\.\.\/\.\.\/primitives\/([^'"]+)['"]/g,
13436
- `from '@/${primitivesPath}/$1'`
13439
+ `from '@/${aliasPrimitives}/$1'`
13437
13440
  );
13438
13441
  transformed = transformed.replace(
13439
13442
  /from\s+['"]\.\.\/primitives\/([^'"]+)['"]/g,
13440
- `from '@/${primitivesPath}/$1'`
13443
+ `from '@/${aliasPrimitives}/$1'`
13441
13444
  );
13442
- const siblingPath = fileType === "primitive" ? primitivesPath : componentsPath;
13443
- transformed = transformed.replace(/from\s+['"]\.\/([^'"]+)['"]/g, `from '@/${siblingPath}/$1'`);
13444
- const libPath = dirname(primitivesPath);
13445
+ const aliasSibling = fileType === "primitive" ? aliasPrimitives : aliasComponents;
13446
+ transformed = transformed.replace(/from\s+['"]\.\/([^'"]+)['"]/g, `from '@/${aliasSibling}/$1'`);
13447
+ const aliasLib = stripSourceRoot(dirname(primitivesPath));
13445
13448
  transformed = transformed.replace(
13446
13449
  /from\s+['"]\.\.\/lib\/([^'"]+)['"]/g,
13447
- `from '@/${libPath}/$1'`
13450
+ `from '@/${aliasLib}/$1'`
13448
13451
  );
13449
- const componentsMatch = componentsPath.match(/^(.*)components\/ui$/);
13450
- const hooksPath = componentsMatch ? `${componentsMatch[1]}hooks`.replace(/^\//, "") : "hooks";
13452
+ const componentsMatch = aliasComponents.match(/^(.*)components\/ui$/);
13453
+ const aliasHooks = componentsMatch ? `${componentsMatch[1]}hooks`.replace(/^\//, "") : "hooks";
13451
13454
  transformed = transformed.replace(
13452
13455
  /from\s+['"]\.\.\/hooks\/([^'"]+)['"]/g,
13453
- `from '@/${hooksPath}/$1'`
13456
+ `from '@/${aliasHooks}/$1'`
13454
13457
  );
13455
13458
  transformed = transformed.replace(
13456
13459
  /from\s+['"]\.\.\/(?!lib\/|hooks\/)([^'"]+)['"]/g,
13457
- `from '@/${componentsPath}/$1'`
13460
+ `from '@/${aliasComponents}/$1'`
13458
13461
  );
13459
13462
  return transformed;
13460
13463
  }
@@ -46876,7 +46879,7 @@ function generateThemeInlineBlock(semanticTokens) {
46876
46879
  lines.push("}");
46877
46880
  return lines.join("\n");
46878
46881
  }
46879
- function generateRootBlock(semanticTokens) {
46882
+ function generateRootBlock(semanticTokens, darkMode = "class") {
46880
46883
  const semanticMappings = getSemanticMappingsFromTokens(semanticTokens);
46881
46884
  const lines = [];
46882
46885
  lines.push(":root {");
@@ -46893,17 +46896,20 @@ function generateRootBlock(semanticTokens) {
46893
46896
  }
46894
46897
  lines.push("}");
46895
46898
  lines.push("");
46896
- lines.push("@media (prefers-color-scheme: dark) {");
46897
- lines.push(" :root {");
46898
- for (const name2 of Object.keys(semanticMappings)) {
46899
- lines.push(` --${name2}: var(--rafters-dark-${name2});`);
46899
+ if (darkMode === "class") {
46900
+ lines.push("@custom-variant dark (&:where(.dark, .dark *));");
46901
+ lines.push("");
46902
+ lines.push(".dark {");
46903
+ } else {
46904
+ lines.push("@media (prefers-color-scheme: dark) {");
46905
+ lines.push(" :root {");
46900
46906
  }
46901
- lines.push(" }");
46902
- lines.push("}");
46903
- lines.push("");
46904
- lines.push(".dark {");
46905
46907
  for (const name2 of Object.keys(semanticMappings)) {
46906
- lines.push(` --${name2}: var(--rafters-dark-${name2});`);
46908
+ const indent2 = darkMode === "media" ? " " : " ";
46909
+ lines.push(`${indent2}--${name2}: var(--rafters-dark-${name2});`);
46910
+ }
46911
+ if (darkMode === "media") {
46912
+ lines.push(" }");
46907
46913
  }
46908
46914
  lines.push("}");
46909
46915
  lines.push("");
@@ -47126,7 +47132,7 @@ function tokensToTailwind(tokens, options = {}) {
47126
47132
  const themeInlineBlock = generateThemeInlineBlock(groups.semantic);
47127
47133
  sections.push(themeInlineBlock);
47128
47134
  sections.push("");
47129
- const rootBlock = generateRootBlock(groups.semantic);
47135
+ const rootBlock = generateRootBlock(groups.semantic, options.darkMode ?? "class");
47130
47136
  sections.push(rootBlock);
47131
47137
  sections.push("");
47132
47138
  const keyframes = generateKeyframes(groups.motion);
@@ -58443,10 +58449,10 @@ async function ensureTailwindCli(cwd) {
58443
58449
  );
58444
58450
  }
58445
58451
  }
58446
- async function generateOutputs(cwd, paths, registry2, exports, shadcn) {
58452
+ async function generateOutputs(cwd, paths, registry2, exports, shadcn, darkMode = "class") {
58447
58453
  const outputs = [];
58448
58454
  if (exports.tailwind) {
58449
- const tailwindCss = registryToTailwind(registry2, { includeImport: !shadcn });
58455
+ const tailwindCss = registryToTailwind(registry2, { includeImport: !shadcn, darkMode });
58450
58456
  await writeFile3(join9(paths.output, "rafters.css"), tailwindCss);
58451
58457
  outputs.push("rafters.css");
58452
58458
  }
@@ -58631,6 +58637,91 @@ async function resetToDefaults(cwd, paths, shadcn, isAgentMode2, framework) {
58631
58637
  path: paths.output
58632
58638
  });
58633
58639
  }
58640
+ async function writeRaftersSkill(cwd) {
58641
+ const skillDir = join9(cwd, ".claude", "skills", "rafters-frontend");
58642
+ await mkdir3(skillDir, { recursive: true });
58643
+ const skill = `---
58644
+ name: rafters-frontend
58645
+ description: Use when building frontend UI in a Rafters project -- enforces Container, Grid, typography components, and design token usage.
58646
+ ---
58647
+
58648
+ ## Layout Is Solved
58649
+
58650
+ Container and Grid handle ALL layout. You do not write layout code.
58651
+
58652
+ \`\`\`tsx
58653
+ // WRONG
58654
+ <div className={classy("flex gap-4 p-6")}>
58655
+
58656
+ // RIGHT
58657
+ <Container>
58658
+ <Grid preset="sidebar-main">
58659
+ <aside>Sidebar</aside>
58660
+ <main>Content</main>
58661
+ </Grid>
58662
+ </Container>
58663
+ \`\`\`
58664
+
58665
+ **Never use:** flex, grid, gap-*, p-*, m-*, items-*, justify-*
58666
+
58667
+ ### Grid Presets
58668
+
58669
+ | Preset | Use for |
58670
+ |---|---|
58671
+ | sidebar-main | Navigation + content |
58672
+ | form | Label/input pairs |
58673
+ | cards | Responsive card grid |
58674
+ | row | Horizontal group |
58675
+ | stack | Vertical sequence |
58676
+ | split | Equal columns |
58677
+
58678
+ ## Typography -- Components, Not Utilities
58679
+
58680
+ | Instead of | Use |
58681
+ |---|---|
58682
+ | \`<p className="text-sm text-muted-foreground">\` | \`<Muted>\` |
58683
+ | \`<p>\` | \`<P>\` |
58684
+ | \`<h1 className="text-4xl font-bold">\` | \`<H1>\` |
58685
+ | \`<h2>\` | \`<H2>\` |
58686
+ | \`<h3>\` | \`<H3>\` |
58687
+ | \`<span className="text-xs">\` | \`<Small>\` |
58688
+ | \`<span className="text-lg font-semibold">\` | \`<Large>\` |
58689
+
58690
+ ## Color -- Tokens, Not Values
58691
+
58692
+ Use semantic tokens as Tailwind classes: \`bg-primary\`, \`text-destructive\`, \`border-success\`.
58693
+ Never use hex, HSL, or palette internals.
58694
+
58695
+ ## A Correct Page
58696
+
58697
+ \`\`\`tsx
58698
+ import { Container, Grid } from "@rafters/ui"
58699
+ import { H1, Lead } from "@rafters/ui/components/ui/typography"
58700
+ import { Card } from "@rafters/ui/components/ui/card"
58701
+ import { Button } from "@rafters/ui/components/ui/button"
58702
+
58703
+ export default function Page() {
58704
+ return (
58705
+ <Container>
58706
+ <H1>Title</H1>
58707
+ <Lead>Description.</Lead>
58708
+ <Grid preset="cards">
58709
+ <Card>...</Card>
58710
+ <Card>...</Card>
58711
+ </Grid>
58712
+ <Grid preset="row">
58713
+ <Button variant="secondary">Cancel</Button>
58714
+ <Button>Save</Button>
58715
+ </Grid>
58716
+ </Container>
58717
+ )
58718
+ }
58719
+ \`\`\`
58720
+
58721
+ No flex. No gap. No padding. No text utilities.
58722
+ `;
58723
+ await writeFile3(join9(skillDir, "SKILL.md"), skill);
58724
+ }
58634
58725
  async function init(options) {
58635
58726
  setAgentMode(options.agent ?? false);
58636
58727
  const isAgentMode2 = options.agent ?? false;
@@ -58750,6 +58841,7 @@ async function init(options) {
58750
58841
  }
58751
58842
  };
58752
58843
  await writeFile3(paths.config, JSON.stringify(config3, null, 2));
58844
+ await writeRaftersSkill(cwd);
58753
58845
  const existingCssPath = detectedCssPath ?? (shadcn?.tailwind?.css || null);
58754
58846
  if (existingCssPath) {
58755
58847
  try {
@@ -60975,7 +61067,8 @@ var RaftersToolHandler = class _RaftersToolHandler {
60975
61067
  const shadcn = config3?.shadcn ?? false;
60976
61068
  await mkdir4(paths.output, { recursive: true });
60977
61069
  if (exports.tailwind) {
60978
- const css3 = registryToTailwind(registry2, { includeImport: !shadcn });
61070
+ const darkMode = config3?.darkMode ?? "class";
61071
+ const css3 = registryToTailwind(registry2, { includeImport: !shadcn, darkMode });
60979
61072
  await writeFile4(join10(paths.output, "rafters.css"), css3);
60980
61073
  }
60981
61074
  if (exports.typescript) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "CLI for Rafters design system - scaffold tokens and add components",
5
5
  "license": "MIT",
6
6
  "type": "module",