zyncat-ui 0.13.1 → 0.15.0
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/README.md +4 -3
- package/dist/cli.js +135 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,9 +9,10 @@ pnpm dlx zyncat-ui init
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Run it inside a React project. One command installs `@zyncat/ui` (and React 19 if the project
|
|
12
|
-
needs it), imports the base stylesheet at your app root, installs the agent
|
|
13
|
-
`.claude/skills/`, and registers the MCP server in `.mcp.json`.
|
|
14
|
-
`@zyncat/ui`
|
|
12
|
+
needs it), imports the base stylesheet at your app root, writes the theme file, installs the agent
|
|
13
|
+
skill into `.claude/skills/`, and registers the MCP server in `.mcp.json`. In a Tailwind v4 project
|
|
14
|
+
it also imports `@zyncat/ui/tailwind.css` above `tailwindcss`, so the token vocabulary arrives as
|
|
15
|
+
utilities with IntelliSense. Re-run it after upgrading `@zyncat/ui` to refresh everything.
|
|
15
16
|
|
|
16
17
|
This package is where the CLI lives, and it holds the unscoped name so the command works before
|
|
17
18
|
`@zyncat/ui` is installed. It ships one bundled file and declares zero runtime dependencies - the
|
package/dist/cli.js
CHANGED
|
@@ -156,8 +156,8 @@ var require_picocolors = __commonJS({
|
|
|
156
156
|
|
|
157
157
|
// src/detect.ts
|
|
158
158
|
import { spawnSync } from "child_process";
|
|
159
|
-
import { existsSync, readFileSync } from "fs";
|
|
160
|
-
import { dirname, join } from "path";
|
|
159
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
160
|
+
import { dirname, join, relative, sep } from "path";
|
|
161
161
|
import { fileURLToPath } from "url";
|
|
162
162
|
var PACKAGE_MANAGERS = ["pnpm", "npm", "yarn", "bun"];
|
|
163
163
|
function readJson(path) {
|
|
@@ -237,10 +237,36 @@ function findAppEntry(cwd) {
|
|
|
237
237
|
for (const candidate of ENTRY_CANDIDATES) if (existsSync(join(cwd, candidate))) return candidate;
|
|
238
238
|
return null;
|
|
239
239
|
}
|
|
240
|
+
var TAILWIND_IMPORT = /^\s*@import\s+(['"])tailwindcss(?:\/[\w./-]+)?\1[^;]*;/m;
|
|
241
|
+
var STYLESHEET_SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "coverage", "public"]);
|
|
242
|
+
var STYLESHEET_SEARCH_DEPTH = 4;
|
|
243
|
+
function tailwindMajor(cwd, pkg) {
|
|
244
|
+
const range = pkg?.dependencies?.tailwindcss ?? pkg?.devDependencies?.tailwindcss;
|
|
245
|
+
if (!range) return null;
|
|
246
|
+
return majorOf(installedVersion(cwd, "tailwindcss") ?? void 0) ?? majorOf(range);
|
|
247
|
+
}
|
|
248
|
+
function findTailwindEntry(cwd) {
|
|
249
|
+
const found = [];
|
|
250
|
+
const walk = (dir, depth) => {
|
|
251
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
252
|
+
if (entry.isDirectory()) {
|
|
253
|
+
if (depth < STYLESHEET_SEARCH_DEPTH && !STYLESHEET_SKIP_DIRS.has(entry.name) && !entry.name.startsWith("."))
|
|
254
|
+
walk(join(dir, entry.name), depth + 1);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (!entry.name.endsWith(".css")) continue;
|
|
258
|
+
const path = join(dir, entry.name);
|
|
259
|
+
if (TAILWIND_IMPORT.test(readFileSync(path, "utf8"))) found.push(relative(cwd, path).split(sep).join("/"));
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
walk(cwd, 0);
|
|
263
|
+
found.sort((a2, b) => a2.split("/").length - b.split("/").length || a2.localeCompare(b));
|
|
264
|
+
return found[0] ?? null;
|
|
265
|
+
}
|
|
240
266
|
|
|
241
267
|
// src/init.ts
|
|
242
|
-
import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync as
|
|
243
|
-
import { join as join3 } from "path";
|
|
268
|
+
import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync as readdirSync3, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
269
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
244
270
|
|
|
245
271
|
// ../../node_modules/.pnpm/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
|
|
246
272
|
import { styleText } from "util";
|
|
@@ -938,7 +964,7 @@ var n$1 = class n extends V {
|
|
|
938
964
|
import { styleText as styleText2, stripVTControlCharacters } from "util";
|
|
939
965
|
import process$1 from "process";
|
|
940
966
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
941
|
-
import { existsSync as existsSync2, lstatSync, readdirSync } from "fs";
|
|
967
|
+
import { existsSync as existsSync2, lstatSync, readdirSync as readdirSync2 } from "fs";
|
|
942
968
|
import { dirname as dirname2, join as join2 } from "path";
|
|
943
969
|
function isUnicodeSupported() {
|
|
944
970
|
if (process$1.platform !== "win32") {
|
|
@@ -1472,7 +1498,7 @@ var teal = { 200: "#a4e5e7", 300: "#6dcfd1", 400: "#28b5b9", 500: "#009ea3", 600
|
|
|
1472
1498
|
var accent = fg(teal[400]);
|
|
1473
1499
|
var accentDeep = fg(teal[500]);
|
|
1474
1500
|
var accentBright = fg(teal[300]);
|
|
1475
|
-
var { dim, bold, red
|
|
1501
|
+
var { dim, bold, red } = import_picocolors.default;
|
|
1476
1502
|
function gradientText(text, from, to) {
|
|
1477
1503
|
if (!truecolor) return import_picocolors.default.isColorSupported ? import_picocolors.default.cyan(text) : text;
|
|
1478
1504
|
const chars = [...text];
|
|
@@ -1536,6 +1562,10 @@ function row(label, value) {
|
|
|
1536
1562
|
var PACKAGE = "@zyncat/ui";
|
|
1537
1563
|
var MCP_SERVER_ENTRY = { command: "node", args: ["./node_modules/@zyncat/ui/dist/mcp.js"] };
|
|
1538
1564
|
var STYLES_IMPORT = "import '@zyncat/ui/styles.css';";
|
|
1565
|
+
var THEME_FILE = "zyncat.theme.css";
|
|
1566
|
+
var THEME_IMPORT = `import './${THEME_FILE}';`;
|
|
1567
|
+
var THEME_SOURCE = "src/tokens/decisions.css";
|
|
1568
|
+
var TAILWIND_BRIDGE = "@zyncat/ui/tailwind.css";
|
|
1539
1569
|
var DOCS_URL = "https://ui.zyncat.app";
|
|
1540
1570
|
var interactive = () => Boolean(process.stdout.isTTY && process.stdin.isTTY);
|
|
1541
1571
|
var installTouchedProject = false;
|
|
@@ -1701,7 +1731,7 @@ function wireSkill(cwd, packageRoot, pm) {
|
|
|
1701
1731
|
const dest = join3(cwd, ".claude/skills");
|
|
1702
1732
|
const existed = existsSync3(join3(dest, "zyncat-ui"));
|
|
1703
1733
|
mkdirSync(dest, { recursive: true });
|
|
1704
|
-
for (const name of
|
|
1734
|
+
for (const name of readdirSync3(source))
|
|
1705
1735
|
cpSync(join3(source, name), join3(dest, name), { recursive: true, force: true });
|
|
1706
1736
|
return { line: row("Agent skill", `.claude/skills/zyncat-ui \xB7 ${existed ? "refreshed" : "installed"}`), done: true };
|
|
1707
1737
|
}
|
|
@@ -1719,25 +1749,98 @@ function wireMcp(cwd) {
|
|
|
1719
1749
|
`);
|
|
1720
1750
|
return { line: row("MCP server", existed ? ".mcp.json \xB7 kept" : `.mcp.json ${arrow} zyncat-ui`), done: true };
|
|
1721
1751
|
}
|
|
1722
|
-
function
|
|
1723
|
-
const
|
|
1752
|
+
function themeFileText(packageRoot) {
|
|
1753
|
+
const source = join3(packageRoot, THEME_SOURCE);
|
|
1754
|
+
if (!existsSync3(source)) return null;
|
|
1755
|
+
const css = readFileSync2(source, "utf8");
|
|
1756
|
+
const rule = /^\s*:root\s*\{/m.exec(css);
|
|
1757
|
+
if (!rule) return null;
|
|
1758
|
+
const open = rule.index + rule[0].length - 1;
|
|
1759
|
+
const close = css.indexOf("}", open);
|
|
1760
|
+
if (close === -1) return null;
|
|
1761
|
+
const lines = css.slice(open + 1, close).split("\n").filter((line) => line.trim());
|
|
1762
|
+
const indent = Math.min(...lines.map((line) => line.length - line.trimStart().length));
|
|
1763
|
+
const body = lines.map((line) => ` ${line.slice(indent)}`).join("\n");
|
|
1764
|
+
return [
|
|
1765
|
+
`/* ${THEME_FILE} - the decisions every other token derives from, written by zyncat-ui init.`,
|
|
1766
|
+
" Loaded after @zyncat/ui/styles.css, so a value here wins; whatever you delete keeps the default.",
|
|
1767
|
+
" A [data-theme='dark'] block here extends the shipped dark theme. Docs: https://ui.zyncat.app/theming */",
|
|
1768
|
+
":root {",
|
|
1769
|
+
body,
|
|
1770
|
+
"}",
|
|
1771
|
+
""
|
|
1772
|
+
].join("\n");
|
|
1773
|
+
}
|
|
1774
|
+
function wireTheme(cwd, packageRoot, pm, entry) {
|
|
1775
|
+
const dir = entry ? dirname3(entry) : ".";
|
|
1776
|
+
const rel = dir === "." ? THEME_FILE : `${dir}/${THEME_FILE}`;
|
|
1777
|
+
const path = join3(cwd, rel);
|
|
1778
|
+
if (existsSync3(path)) return { line: row("Theme file", `${rel} \xB7 kept`), done: true };
|
|
1779
|
+
const text = themeFileText(packageRoot);
|
|
1780
|
+
if (!text)
|
|
1781
|
+
return {
|
|
1782
|
+
line: row("Theme file", `skipped \xB7 ${PACKAGE} ships no ${THEME_SOURCE}`),
|
|
1783
|
+
done: false,
|
|
1784
|
+
hint: `Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`
|
|
1785
|
+
};
|
|
1786
|
+
writeFileSync(path, text);
|
|
1787
|
+
return { line: row("Theme file", `${rel} \xB7 written`), done: true };
|
|
1788
|
+
}
|
|
1789
|
+
function wireStyles(cwd, entry) {
|
|
1724
1790
|
if (!entry)
|
|
1725
1791
|
return {
|
|
1726
|
-
line: row("Stylesheet", "no app entry found \xB7 add the
|
|
1792
|
+
line: row("Stylesheet", "no app entry found \xB7 add the imports yourself"),
|
|
1727
1793
|
done: false,
|
|
1728
|
-
hint: `Put ${STYLES_IMPORT} at your app root, above your own stylesheets.`
|
|
1794
|
+
hint: `Put ${STYLES_IMPORT} then ${THEME_IMPORT} at your app root, above your own stylesheets.`
|
|
1729
1795
|
};
|
|
1730
1796
|
const path = join3(cwd, entry);
|
|
1731
1797
|
const text = readFileSync2(path, "utf8");
|
|
1732
|
-
if (text.includes("@zyncat/ui/styles.css"))
|
|
1733
|
-
return { line: row("Stylesheet", `${entry} \xB7 already imported`), done: true };
|
|
1734
1798
|
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
1735
1799
|
const lines = text.split(eol);
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1800
|
+
const added = [];
|
|
1801
|
+
let stylesAt = lines.findIndex((line) => line.includes("@zyncat/ui/styles.css"));
|
|
1802
|
+
if (stylesAt === -1) {
|
|
1803
|
+
stylesAt = 0;
|
|
1804
|
+
while (stylesAt < lines.length && (lines[stylesAt].trim() === "" || /^(['"])use [\w-]+\1;?$/.test(lines[stylesAt].trim())))
|
|
1805
|
+
stylesAt++;
|
|
1806
|
+
lines.splice(stylesAt, 0, STYLES_IMPORT);
|
|
1807
|
+
added.push("styles");
|
|
1808
|
+
}
|
|
1809
|
+
if (existsSync3(join3(cwd, dirname3(entry), THEME_FILE)) && !text.includes(THEME_FILE)) {
|
|
1810
|
+
lines.splice(stylesAt + 1, 0, THEME_IMPORT);
|
|
1811
|
+
added.push("theme");
|
|
1812
|
+
}
|
|
1813
|
+
if (!added.length) return { line: row("Stylesheet", `${entry} \xB7 already imported`), done: true };
|
|
1739
1814
|
writeFileSync(path, lines.join(eol));
|
|
1740
|
-
|
|
1815
|
+
const what = added.length === 2 ? "imports added" : added[0] === "theme" ? "theme import added" : "import added";
|
|
1816
|
+
return { line: row("Stylesheet", `${entry} \xB7 ${what}`), done: true };
|
|
1817
|
+
}
|
|
1818
|
+
function wireTailwind(cwd, targetPkg) {
|
|
1819
|
+
const major = tailwindMajor(cwd, targetPkg);
|
|
1820
|
+
if (major === null) return null;
|
|
1821
|
+
if (major < 4)
|
|
1822
|
+
return {
|
|
1823
|
+
line: row("Tailwind", `skipped \xB7 Tailwind ${major} has no @theme`),
|
|
1824
|
+
done: false,
|
|
1825
|
+
hint: `The bridge needs Tailwind v4 - ${DOCS_URL}/theming#tailwind.`
|
|
1826
|
+
};
|
|
1827
|
+
const entry = findTailwindEntry(cwd);
|
|
1828
|
+
if (!entry)
|
|
1829
|
+
return {
|
|
1830
|
+
line: row("Tailwind", "no stylesheet imports tailwindcss \xB7 add the line yourself"),
|
|
1831
|
+
done: false,
|
|
1832
|
+
hint: `Put @import '${TAILWIND_BRIDGE}'; above @import 'tailwindcss'; in the stylesheet Tailwind compiles.`
|
|
1833
|
+
};
|
|
1834
|
+
const path = join3(cwd, entry);
|
|
1835
|
+
const text = readFileSync2(path, "utf8");
|
|
1836
|
+
if (text.includes(TAILWIND_BRIDGE)) return { line: row("Tailwind", `${entry} \xB7 already imported`), done: true };
|
|
1837
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
1838
|
+
const lines = text.split(eol);
|
|
1839
|
+
const at = lines.findIndex((line) => TAILWIND_IMPORT.test(line));
|
|
1840
|
+
const quote = lines[at].includes('"') ? '"' : "'";
|
|
1841
|
+
lines.splice(at, 0, `@import ${quote}${TAILWIND_BRIDGE}${quote};`);
|
|
1842
|
+
writeFileSync(path, lines.join(eol));
|
|
1843
|
+
return { line: row("Tailwind", `${entry} \xB7 import added`), done: true };
|
|
1741
1844
|
}
|
|
1742
1845
|
async function init(flags) {
|
|
1743
1846
|
const startedAt = performance.now();
|
|
@@ -1766,13 +1869,21 @@ async function init(flags) {
|
|
|
1766
1869
|
if (plan.reactNote) log.warn(plan.reactNote);
|
|
1767
1870
|
await alignVersion(pm, cwd, version2);
|
|
1768
1871
|
const packageRoot = sourceRoot(cwd, ownRoot);
|
|
1769
|
-
const
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1872
|
+
const entry = findAppEntry(cwd);
|
|
1873
|
+
const tailwind = wireTailwind(cwd, targetPkg);
|
|
1874
|
+
const rows = [
|
|
1875
|
+
wireSkill(cwd, packageRoot, pm),
|
|
1876
|
+
wireMcp(cwd),
|
|
1877
|
+
wireTheme(cwd, packageRoot, pm, entry),
|
|
1878
|
+
wireStyles(cwd, entry),
|
|
1879
|
+
...tailwind ? [tailwind] : []
|
|
1880
|
+
];
|
|
1881
|
+
for (const [index, entry2] of rows.entries()) {
|
|
1882
|
+
log.message(entry2.line, { symbol: entry2.done ? check : skip, spacing: index === 0 ? 1 : 0 });
|
|
1883
|
+
if (entry2.hint) log.message(dim(entry2.hint), { spacing: 0 });
|
|
1773
1884
|
}
|
|
1774
1885
|
log.message(`${dim("Docs")} ${arrow} ${accentDeep(DOCS_URL)}`);
|
|
1775
|
-
const skipped = rows.filter((
|
|
1886
|
+
const skipped = rows.filter((entry2) => !entry2.done).length;
|
|
1776
1887
|
const closing = skipped ? `${bold(`Done in ${seconds(performance.now() - startedAt)}.`)} ${skipped} step${skipped === 1 ? "" : "s"} left for you, above.` : `${bold(`Ready in ${seconds(performance.now() - startedAt)}.`)} Restart your agent session to load the skill.`;
|
|
1777
1888
|
outro(closing);
|
|
1778
1889
|
}
|
|
@@ -1797,7 +1908,8 @@ function help(version2) {
|
|
|
1797
1908
|
` ${wordmark(version2)}`,
|
|
1798
1909
|
"",
|
|
1799
1910
|
` ${dim("Sets up @zyncat/ui in a React project: installs the package,")}`,
|
|
1800
|
-
` ${dim("the agent skill, the MCP server
|
|
1911
|
+
` ${dim("the agent skill, the MCP server, the stylesheet, a theme file")}`,
|
|
1912
|
+
` ${dim("and, under Tailwind v4, the utility bridge.")}`,
|
|
1801
1913
|
"",
|
|
1802
1914
|
` ${bold("Usage")}`,
|
|
1803
1915
|
` zyncat-ui init ${dim("[flags]")}`,
|