designsource 0.15.1 → 0.16.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/dist/index.js +93 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1013,7 +1013,6 @@ Commands
|
|
|
1013
1013
|
connect connect your coding apps (Claude Code, Cursor, VS Code, Codex, Gemini CLI) to this design system
|
|
1014
1014
|
login sign in for coding agents, so your agent can create design systems from this folder
|
|
1015
1015
|
logout sign this computer out of the account login signed in to
|
|
1016
|
-
integrate [folder] add the design system to an existing app \u2014 writes design-system/ (default folder: .)
|
|
1017
1016
|
create [folder] new Next.js project with the tokens, every component and your mockup page (default folder: ${CREATE_DEFAULT_FOLDER})
|
|
1018
1017
|
mcp serve the design system to a coding agent over MCP (stdio) \u2014 for .mcp.json, not for a terminal
|
|
1019
1018
|
|
|
@@ -1132,7 +1131,7 @@ function baseArgs(env) {
|
|
|
1132
1131
|
return args;
|
|
1133
1132
|
}
|
|
1134
1133
|
var HELP = /* @__PURE__ */ new Set(["--help", "-h", "help"]);
|
|
1135
|
-
var USE_VERBS = "Use setup, add, connect, login, logout,
|
|
1134
|
+
var USE_VERBS = "Use setup, add, connect, login, logout, create or mcp.";
|
|
1136
1135
|
function parseArgs(argv, env) {
|
|
1137
1136
|
const [first, ...rest] = argv;
|
|
1138
1137
|
if (first === void 0) return { kind: "setup", args: { api: DEFAULT_API_ORIGIN, apiGiven: false }, bare: true };
|
|
@@ -1351,9 +1350,10 @@ function parseVerb(verb, argv, env) {
|
|
|
1351
1350
|
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
|
|
1352
1351
|
import { join as join3 } from "node:path";
|
|
1353
1352
|
var NO_PACKAGE_JSON = "No package.json here. Run this in your React app's folder.";
|
|
1354
|
-
var
|
|
1353
|
+
var REACT_ONLY_SENTENCE = "DS source supports React apps only for now.";
|
|
1354
|
+
var NO_REACT = `This folder has no React app. Run this in your React app's folder. ${REACT_ONLY_SENTENCE}`;
|
|
1355
1355
|
var OLD_REACT = (major) => `The UI kit needs React 19 \u2014 this app is on React ${major}.`;
|
|
1356
|
-
var NO_TYPESCRIPT = "The UI kit is TypeScript and this app is plain JavaScript
|
|
1356
|
+
var NO_TYPESCRIPT = "The UI kit is TypeScript and this app is plain JavaScript, so it cannot go in yet.";
|
|
1357
1357
|
var LOCKFILES = [["pnpm-lock.yaml", "pnpm"], ["yarn.lock", "yarn"], ["bun.lockb", "bun"], ["bun.lock", "bun"], ["package-lock.json", "npm"]];
|
|
1358
1358
|
function majorOf(spec) {
|
|
1359
1359
|
if (spec === void 0) return null;
|
|
@@ -4692,18 +4692,34 @@ function askFolder(fallback) {
|
|
|
4692
4692
|
return process.stdin.isTTY === true ? ask("Folder", fallback) : Promise.resolve(fallback);
|
|
4693
4693
|
}
|
|
4694
4694
|
var TOKEN_REQUIRED = "A project token is required. In the workbench open Project settings and copy the project token.";
|
|
4695
|
+
var NO_DESIGN_SYSTEM_HERE = "No design system is connected to this folder. Ask the user to run npx designsource in a terminal in this folder, then run this command again. Do not paste a project token into a command.";
|
|
4695
4696
|
var isTerminal = () => process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
4696
|
-
|
|
4697
|
+
var noToken = () => new CliError(isTerminal() ? TOKEN_REQUIRED : NO_DESIGN_SYSTEM_HERE);
|
|
4698
|
+
async function askTokenHidden() {
|
|
4699
|
+
try {
|
|
4700
|
+
return await askHidden("Project token (workbench \u2192 Project settings):");
|
|
4701
|
+
} catch (e) {
|
|
4702
|
+
if (e instanceof CliError && e.message === EOF_MESSAGE && !isTerminal()) return "";
|
|
4703
|
+
throw e;
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
async function requireToken(given, opts, ask2 = {}) {
|
|
4697
4707
|
if (!opts) {
|
|
4698
|
-
const token = given ??
|
|
4699
|
-
if (!token) throw
|
|
4708
|
+
const token = given ?? (ask2.prompt === false ? "" : await askTokenHidden());
|
|
4709
|
+
if (!token) throw noToken();
|
|
4700
4710
|
return token;
|
|
4701
4711
|
}
|
|
4702
4712
|
return (await requireSavedToken(given, opts)).token;
|
|
4703
4713
|
}
|
|
4704
4714
|
async function requireSavedToken(given, opts) {
|
|
4705
|
-
|
|
4706
|
-
|
|
4715
|
+
let resolved;
|
|
4716
|
+
try {
|
|
4717
|
+
resolved = await resolveToken({ given, cwd: opts.cwd, store: opts.store ?? defaultStore(), interactive: opts.interactive ?? isTerminal(), prompt: true });
|
|
4718
|
+
} catch (e) {
|
|
4719
|
+
if (e instanceof CliError && e.message === EOF_MESSAGE && !isTerminal()) throw noToken();
|
|
4720
|
+
throw e;
|
|
4721
|
+
}
|
|
4722
|
+
if (!resolved) throw noToken();
|
|
4707
4723
|
return resolved;
|
|
4708
4724
|
}
|
|
4709
4725
|
async function savedToken(given, opts) {
|
|
@@ -4781,7 +4797,7 @@ async function runAddCommand(args, io, exec = spawnExec, store, accounts) {
|
|
|
4781
4797
|
if (first) mode = await pick(PICK_QUESTION, ADD_MODES, 0);
|
|
4782
4798
|
}
|
|
4783
4799
|
const access = await savedOrLinked(args, { cwd: root, store, accounts, interactive: terminal });
|
|
4784
|
-
const { token, api, account } = access ?? { token: await requireToken(void 0), api: apiFor(args, null), account: null };
|
|
4800
|
+
const { token, api, account } = access ?? { token: await requireToken(void 0, void 0, { prompt: !args.yes }), api: apiFor(args, null), account: null };
|
|
4785
4801
|
if (account) io.stdout(`${USING_LINK(printable(account.email), account.origin)}
|
|
4786
4802
|
`);
|
|
4787
4803
|
const questions = interactive ? ttyQuestions(args, mode, io) : nonInteractiveQuestions(args);
|
|
@@ -5023,7 +5039,10 @@ var INTEGRATE_OPTIONS = [
|
|
|
5023
5039
|
{ value: "angular", label: "Angular" },
|
|
5024
5040
|
{ value: "css", label: "Plain CSS", hint: "any other stack" }
|
|
5025
5041
|
];
|
|
5042
|
+
var INTEGRATE_NOT_SUPPORTED = "integrate is not supported for now: DS source supports React apps. It still runs, but it may change or go away.";
|
|
5026
5043
|
async function runIntegrate(args, env, io, store, accounts) {
|
|
5044
|
+
io.stderr(`${INTEGRATE_NOT_SUPPORTED}
|
|
5045
|
+
`);
|
|
5027
5046
|
const framework = args.framework ?? await pick("Framework", INTEGRATE_OPTIONS, 0);
|
|
5028
5047
|
const access = await savedOrLinked(args, { cwd: io.cwd, store, accounts });
|
|
5029
5048
|
const folder = args.folder ?? await askFolder(INTEGRATE_DEFAULT_FOLDER);
|
|
@@ -5217,7 +5236,7 @@ async function runLogout(args, io, deps = defaultLoginDeps(process.env)) {
|
|
|
5217
5236
|
import { homedir as homedir6 } from "node:os";
|
|
5218
5237
|
|
|
5219
5238
|
// src/version.ts
|
|
5220
|
-
var VERSION = true ? "0.
|
|
5239
|
+
var VERSION = true ? "0.16.0" : "0.0.0-dev";
|
|
5221
5240
|
|
|
5222
5241
|
// src/mcp/jsonrpc.ts
|
|
5223
5242
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -5681,14 +5700,14 @@ var CATEGORIES = ["color", "spacing", "radius", "typography", "shadow", "zIndex"
|
|
|
5681
5700
|
var NO_INPUT = { type: "object", properties: {}, additionalProperties: false };
|
|
5682
5701
|
var pretty = (v) => JSON.stringify(v, null, 2);
|
|
5683
5702
|
var NO_BLOCKS = "This server sent no blocks. Update designsource and the server.";
|
|
5684
|
-
var SOURCE_HEADER = "// Reference implementation
|
|
5703
|
+
var SOURCE_HEADER = "// Reference implementation for React + Tailwind (React apps only for now). add_ui_kit writes it into the app; do not copy it by hand.";
|
|
5685
5704
|
var FALLBACK_BLOCK_SOURCE_HEADER = `${SOURCE_HEADER}
|
|
5686
5705
|
// The block renders inside BlockStage (components/blocks/stage.tsx, below), which supplies the @container/stage its
|
|
5687
5706
|
// responsive classes query and the frame height its min-h-full fills: render <BlockStage><Block /></BlockStage> as a
|
|
5688
5707
|
// full-viewport page. components/ui/preview-portal.tsx is the portal context the stage provides; the kit components
|
|
5689
5708
|
// list_blocks names for this block come from get_component_source.`;
|
|
5690
|
-
var UTILS_HEADER = "// The `cn` helper every component imports from `@/lib/utils
|
|
5691
|
-
var PORTAL_HEADER = "// The portal context components import from `./preview-portal`. Save it beside them as components/ui/preview-portal.tsx in React: with no provider it portals to document.body, as stock shadcn does.
|
|
5709
|
+
var UTILS_HEADER = "// The `cn` helper every component imports from `@/lib/utils`, at lib/utils.ts in a React app (add_ui_kit writes it).";
|
|
5710
|
+
var PORTAL_HEADER = "// The portal context components import from `./preview-portal`. Save it beside them as components/ui/preview-portal.tsx in React: with no provider it portals to document.body, as stock shadcn does.";
|
|
5692
5711
|
var blockAppPath = (key) => key.startsWith("kit/") ? `components/ui/${key.slice("kit/".length)}` : `components/${key}`;
|
|
5693
5712
|
var componentsIn = (snapshot) => [...new Set(snapshot.canonical.tokens.map((t) => t.component).filter((c) => c !== null))].sort();
|
|
5694
5713
|
function optionalEnum(args, key, allowed) {
|
|
@@ -5779,6 +5798,42 @@ function targetSources(ctx, base) {
|
|
|
5779
5798
|
...ctx.token !== null ? { savedFolders: ctx.projectFolders } : {}
|
|
5780
5799
|
};
|
|
5781
5800
|
}
|
|
5801
|
+
var READER_FOOTER_NO_KIT = "This app does not have the UI kit yet. Do not apply these values by hand: call add_ui_kit, then use its components.";
|
|
5802
|
+
var READER_FOOTER_NOT_REACT = "DS source supports React apps only for now. Tell the user this app is not supported yet; do not apply these values by hand.";
|
|
5803
|
+
var READER_FOOTER_PASS_FOLDER = "Pass the app's folder to add_ui_kit.";
|
|
5804
|
+
function appKind(root) {
|
|
5805
|
+
if (!existsSync14(join15(root, "package.json"))) return "none";
|
|
5806
|
+
try {
|
|
5807
|
+
const info = detectApp(root);
|
|
5808
|
+
if (info.reactMajor === null) return "not-react";
|
|
5809
|
+
const targets = info.shadcn ? resolveTargets(root, info.shadcn) : defaultTargets(root, info);
|
|
5810
|
+
return previouslyAdded(root, targets).some((n) => n !== "utils") ? "react-kit" : "react-no-kit";
|
|
5811
|
+
} catch {
|
|
5812
|
+
return "none";
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5815
|
+
function readerFooter(ctx) {
|
|
5816
|
+
try {
|
|
5817
|
+
const fallback = ctx.token !== null ? resolveProjectFolder(ctx.cwd, ctx.projectFolders === null ? null : { folders: ctx.projectFolders }) : ctx.account?.workFolder ?? null;
|
|
5818
|
+
if (fallback === null) return null;
|
|
5819
|
+
const root = normaliseFolder(fallback);
|
|
5820
|
+
const kind = appKind(root);
|
|
5821
|
+
if (kind === "react-no-kit") return READER_FOOTER_NO_KIT;
|
|
5822
|
+
if (kind === "not-react") return READER_FOOTER_NOT_REACT;
|
|
5823
|
+
if (kind === "react-kit") return null;
|
|
5824
|
+
const near = ctx.account?.folder ?? root;
|
|
5825
|
+
const below = appCandidates(root, near, targetSources(ctx, root), ctx.account?.trustedFolders?.() ?? []).apps.map(appKind);
|
|
5826
|
+
return below.includes("react-no-kit") && !below.includes("react-kit") ? `${READER_FOOTER_NO_KIT} ${READER_FOOTER_PASS_FOLDER}` : null;
|
|
5827
|
+
} catch {
|
|
5828
|
+
return null;
|
|
5829
|
+
}
|
|
5830
|
+
}
|
|
5831
|
+
function withFooter(body, ctx) {
|
|
5832
|
+
const footer = readerFooter(ctx);
|
|
5833
|
+
return textResult(footer === null ? body : `${body}
|
|
5834
|
+
|
|
5835
|
+
${footer}`);
|
|
5836
|
+
}
|
|
5782
5837
|
var BLOCKS_BOTH_FOR_AGENT = '"blocks" and "no_blocks" cannot both be true.';
|
|
5783
5838
|
async function addUiKit(args, ctx) {
|
|
5784
5839
|
const { components, replace_existing: replace, no_blocks: noBlocks, blocks: addBlocks } = args;
|
|
@@ -5882,7 +5937,7 @@ var TOOLS = [
|
|
|
5882
5937
|
additionalProperties: false
|
|
5883
5938
|
},
|
|
5884
5939
|
annotations: READ_ONLY,
|
|
5885
|
-
run: (snapshot, _at, args) => {
|
|
5940
|
+
run: (snapshot, _at, args, ctx) => {
|
|
5886
5941
|
const tier = optionalEnum(args, "tier", TIERS);
|
|
5887
5942
|
if (!tier.ok) return tier.error;
|
|
5888
5943
|
const category = optionalEnum(args, "category", CATEGORIES);
|
|
@@ -5892,22 +5947,22 @@ var TOOLS = [
|
|
|
5892
5947
|
const component = optionalEnum(args, "component", components);
|
|
5893
5948
|
if (!component.ok) return component.error;
|
|
5894
5949
|
const rows = snapshot.canonical.tokens.filter((t) => (tier.value === void 0 || t.tier === tier.value) && (category.value === void 0 || t.category === category.value) && (component.value === void 0 || t.component === component.value)).map(({ path, $type, $value, ref }) => ({ path, $type, $value, ref }));
|
|
5895
|
-
return
|
|
5950
|
+
return withFooter(rows.length ? pretty(rows) : "No tokens match.", ctx);
|
|
5896
5951
|
}
|
|
5897
5952
|
},
|
|
5898
5953
|
{
|
|
5899
5954
|
name: "get_css_variables",
|
|
5900
|
-
description: "The whole design system as plain CSS custom properties
|
|
5955
|
+
description: "The whole design system as plain CSS custom properties: design tokens in :root, semantic and component tokens as var() aliases per theme, light and dark via [data-theme] and prefers-color-scheme.",
|
|
5901
5956
|
inputSchema: NO_INPUT,
|
|
5902
5957
|
annotations: READ_ONLY,
|
|
5903
|
-
run: (snapshot) =>
|
|
5958
|
+
run: (snapshot, _at, _args, ctx) => withFooter(snapshot.cssVars, ctx)
|
|
5904
5959
|
},
|
|
5905
5960
|
{
|
|
5906
5961
|
name: "get_shadcn_theme",
|
|
5907
5962
|
description: "The design system as a shadcn/ui theme stylesheet for Tailwind v4: :root and .dark blocks plus @theme inline. Use on the React + Tailwind path.",
|
|
5908
5963
|
inputSchema: NO_INPUT,
|
|
5909
5964
|
annotations: READ_ONLY,
|
|
5910
|
-
run: (snapshot) =>
|
|
5965
|
+
run: (snapshot, _at, _args, ctx) => withFooter(snapshot.shadcnTheme, ctx)
|
|
5911
5966
|
},
|
|
5912
5967
|
{
|
|
5913
5968
|
name: "list_components",
|
|
@@ -5923,16 +5978,16 @@ var TOOLS = [
|
|
|
5923
5978
|
},
|
|
5924
5979
|
{
|
|
5925
5980
|
name: "get_component_source",
|
|
5926
|
-
description: 'The React + Tailwind source of one component (see list_components), or a helper: "utils" for the cn helper, "preview-portal" for the portal context components import.
|
|
5981
|
+
description: 'The React + Tailwind source of one component (see list_components), or a helper: "utils" for the cn helper, "preview-portal" for the portal context components import. React apps only for now: add_ui_kit writes it into the app, so do not copy it by hand.',
|
|
5927
5982
|
inputSchema: { type: "object", properties: { name: { type: "string", description: "A name from list_components, or a helper (utils, preview-portal)." } }, required: ["name"], additionalProperties: false },
|
|
5928
5983
|
annotations: READ_ONLY,
|
|
5929
|
-
run: (snapshot, _at, args) => {
|
|
5984
|
+
run: (snapshot, _at, args, ctx) => {
|
|
5930
5985
|
const names = Object.keys(snapshot.kit.sources).sort();
|
|
5931
5986
|
const name = args.name;
|
|
5932
5987
|
if (typeof name !== "string" || !names.includes(name)) return errorResult(`"name" must be one of: ${names.join(", ")}.`);
|
|
5933
5988
|
const header = name in snapshot.kit.variables ? SOURCE_HEADER : name === "preview-portal" ? PORTAL_HEADER : UTILS_HEADER;
|
|
5934
|
-
return
|
|
5935
|
-
${snapshot.kit.sources[name]}
|
|
5989
|
+
return withFooter(`${header}
|
|
5990
|
+
${snapshot.kit.sources[name]}`, ctx);
|
|
5936
5991
|
}
|
|
5937
5992
|
},
|
|
5938
5993
|
{
|
|
@@ -5965,7 +6020,7 @@ ${files.join("\n")}`);
|
|
|
5965
6020
|
},
|
|
5966
6021
|
{
|
|
5967
6022
|
name: "get_block_source",
|
|
5968
|
-
description: "Every file of one block (see list_blocks), each headed by the path it takes in the app: the block under components/blocks/, plus BlockStage (components/blocks/stage.tsx), which supplies the @container/stage its responsive classes query and the frame height, and the portal context it provides (components/ui/preview-portal.tsx). Render <BlockStage><Block /></BlockStage> as a full-viewport page.
|
|
6023
|
+
description: "Every file of one block (see list_blocks), each headed by the path it takes in the app: the block under components/blocks/, plus BlockStage (components/blocks/stage.tsx), which supplies the @container/stage its responsive classes query and the frame height, and the portal context it provides (components/ui/preview-portal.tsx). Render <BlockStage><Block /></BlockStage> as a full-viewport page. React apps only for now: use verbatim in React + Tailwind.",
|
|
5969
6024
|
inputSchema: { type: "object", properties: { id: { type: "string", description: "A block id from list_blocks." } }, required: ["id"], additionalProperties: false },
|
|
5970
6025
|
annotations: READ_ONLY,
|
|
5971
6026
|
run: (snapshot, _at, args) => {
|
|
@@ -6025,6 +6080,7 @@ function findTool(name) {
|
|
|
6025
6080
|
|
|
6026
6081
|
// src/mcp/protocol.ts
|
|
6027
6082
|
var SUPPORTED_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
6083
|
+
var SERVER_INSTRUCTIONS = "DS source design systems, React apps only for now. Order: if this folder has no design system, create_design_system (or use_design_system); then add_ui_kit; then restyle the app with the components it added. Never copy tokens, CSS variables or component source into the app by hand. Call get_integration_guide for the full steps.";
|
|
6028
6084
|
var NO_SNAPSHOT = {};
|
|
6029
6085
|
var asObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
|
|
6030
6086
|
async function handle(parsed, deps) {
|
|
@@ -6039,7 +6095,7 @@ async function request(msg, deps) {
|
|
|
6039
6095
|
case "initialize": {
|
|
6040
6096
|
const asked = params.protocolVersion;
|
|
6041
6097
|
const protocolVersion = typeof asked === "string" && SUPPORTED_VERSIONS.includes(asked) ? asked : SUPPORTED_VERSIONS[0];
|
|
6042
|
-
return respond(id, { protocolVersion, capabilities: { tools: {}, prompts: {} }, serverInfo: { name: "designsource", version: deps.version } });
|
|
6098
|
+
return respond(id, { protocolVersion, capabilities: { tools: {}, prompts: {} }, serverInfo: { name: "designsource", version: deps.version }, instructions: SERVER_INSTRUCTIONS });
|
|
6043
6099
|
}
|
|
6044
6100
|
case "ping":
|
|
6045
6101
|
return respond(id, {});
|
|
@@ -6339,14 +6395,14 @@ function readSetupState(cwd, home) {
|
|
|
6339
6395
|
const onlyGit = names.length > 0 && names.every((n) => n === ".git" || n === ".DS_Store");
|
|
6340
6396
|
return { kind: "empty", root, found: "Empty folder.", dotfiles: names.length > 0, onlyGit };
|
|
6341
6397
|
}
|
|
6342
|
-
return { kind: "other-stack", root, found: "No package.json here, so this is
|
|
6398
|
+
return { kind: "other-stack", root, found: "No package.json here, so this is not a React app.", framework: "css" };
|
|
6343
6399
|
}
|
|
6344
6400
|
const deps = readDeps(root);
|
|
6345
6401
|
if (deps === null) throw new CliError("package.json is not valid JSON.");
|
|
6346
6402
|
if (!("react" in deps) && (hasWorkspaces(root) || existsSync15(join16(root, "pnpm-workspace.yaml")))) return { kind: "refused", message: WORKSPACE_ROOT };
|
|
6347
6403
|
if (!("react" in deps)) {
|
|
6348
6404
|
const framework = frameworkOf(deps);
|
|
6349
|
-
return { kind: "other-stack", root, found: framework === "css" ? "No React here
|
|
6405
|
+
return { kind: "other-stack", root, found: framework === "css" ? "No React here." : `${FRAMEWORK_LABELS[framework]} app.`, framework };
|
|
6350
6406
|
}
|
|
6351
6407
|
const info = detectApp(root);
|
|
6352
6408
|
let cannotAdd = null;
|
|
@@ -6371,14 +6427,15 @@ function readSetupState(cwd, home) {
|
|
|
6371
6427
|
// src/commands/setup.ts
|
|
6372
6428
|
var SETUP_NEEDS_TERMINAL = "setup asks questions, so it needs a terminal. In a script, use add, connect or login.";
|
|
6373
6429
|
var SETUP_NOT_A_PROJECT = "This folder is neither a repository nor an app. Run npx designsource in your app's folder.";
|
|
6374
|
-
var CANNOT_ADD_AGENT_ONLY = "The UI kit cannot go into this app, so setup connects your coding agent only
|
|
6430
|
+
var CANNOT_ADD_AGENT_ONLY = "The UI kit cannot go into this app yet, so setup connects your coding agent only.";
|
|
6431
|
+
var REACT_ONLY = "DS source supports React apps only for now. Vue, Svelte, Angular and plain CSS are coming later.";
|
|
6375
6432
|
var MAKE_NEW_WAIT = "Make your design system in the browser. This continues when it is saved.";
|
|
6376
6433
|
var WAIT_TIMEOUT = "Still waiting? Run npx designsource again once your design system is saved.";
|
|
6377
6434
|
var NO_APPS_HERE = "No coding apps found on this computer. Run npx designsource login --apps claude (or cursor, vscode, codex, gemini) to set one up.";
|
|
6378
6435
|
var BLOCKS_HINT = "Want the ready-made blocks too? Run npx designsource add --blocks";
|
|
6379
6436
|
var USING = (name) => `Using \u201C${name}\u201D.`;
|
|
6380
6437
|
var upgradeUrl = (origin) => `${origin}/credits?upgrade=pro`;
|
|
6381
|
-
var FREE_PLAN_HEADING = (what) => `Free plan: ${what === "kit" ? "the kit was not added to this app" :
|
|
6438
|
+
var FREE_PLAN_HEADING = (what) => `Free plan: ${what === "kit" ? "the kit was not added to this app" : "the app was not created"}.`;
|
|
6382
6439
|
var FREE_PLAN_LINES = (origin, what, color = false) => [
|
|
6383
6440
|
"",
|
|
6384
6441
|
` ${color ? `\x1B[1;33m${FREE_PLAN_HEADING(what)}\x1B[0m` : FREE_PLAN_HEADING(what)}`,
|
|
@@ -6394,7 +6451,6 @@ var SET_UP_STATUS = (name, components, section, screens) => `\u201C${name}\u201D
|
|
|
6394
6451
|
].join(", ")}).`;
|
|
6395
6452
|
var NEXT_STEP = (sentence) => ["Next: ask your coding agent", ` \u201C${sentence}\u201D`];
|
|
6396
6453
|
var RESTYLE_SENTENCE = "Restyle this app's existing screens with the design system.";
|
|
6397
|
-
var APPLY_SENTENCE = "Apply the design system in design-system/ to this app.";
|
|
6398
6454
|
var WAIT_MS = 30 * 6e4;
|
|
6399
6455
|
var POLL_MS = 5e3;
|
|
6400
6456
|
var PICKER_MAX = 20;
|
|
@@ -6440,16 +6496,14 @@ async function runSetup(args, io, deps) {
|
|
|
6440
6496
|
const state = readSetupState(io.cwd, deps.home);
|
|
6441
6497
|
if (state.kind === "refused") throw new CliError(state.message);
|
|
6442
6498
|
say([state.found]);
|
|
6499
|
+
const { work, trust, worktree } = projectFolders(io.cwd);
|
|
6500
|
+
if (state.kind !== "empty" && !isProjectFolder(work) && !isProjectFolder(state.root)) throw new CliError(SETUP_NOT_A_PROJECT);
|
|
6501
|
+
if (state.kind === "other-stack") throw new CliError(REACT_ONLY);
|
|
6443
6502
|
if (state.kind === "react-fresh" && state.cannotAdd) say([state.cannotAdd, CANNOT_ADD_AGENT_ONLY]);
|
|
6444
6503
|
if (state.kind === "empty") {
|
|
6445
6504
|
const choice = await prompts.pick("What do you want to do?", [{ value: "create", label: "Create a new Next.js app here" }, { value: "other", label: "Something else\u2026" }]);
|
|
6446
6505
|
if (choice === "other") return deps.menu();
|
|
6447
|
-
} else if (state.kind === "other-stack") {
|
|
6448
|
-
const choice = await prompts.pick("What do you want to do?", [{ value: "files", label: `Add the design system files for ${FRAMEWORK_LABELS[state.framework]}` }, { value: "other", label: "Something else\u2026" }]);
|
|
6449
|
-
if (choice === "other") return deps.menu();
|
|
6450
6506
|
}
|
|
6451
|
-
const { work, trust, worktree } = projectFolders(io.cwd);
|
|
6452
|
-
if (state.kind !== "empty" && !isProjectFolder(work) && !isProjectFolder(state.root)) throw new CliError(SETUP_NOT_A_PROJECT);
|
|
6453
6507
|
const api = loginApi(args, true);
|
|
6454
6508
|
const apps = await chooseApps(work, deps, prompts);
|
|
6455
6509
|
const saved = await resolveToken({ cwd: io.cwd, store: deps.store, interactive: true, prompt: false });
|
|
@@ -6520,11 +6574,6 @@ async function runSetup(args, io, deps) {
|
|
|
6520
6574
|
kitStep = async () => pushKit(await addKit(state, access, kitPath(), false, deps, io));
|
|
6521
6575
|
} else if (state.kind === "react-fresh") {
|
|
6522
6576
|
if (state.cannotAdd === null) kitStep = async () => pushKit(await addKit(state, access, kitPath(), true, deps, io));
|
|
6523
|
-
} else if (state.kind === "other-stack") {
|
|
6524
|
-
stop = "files";
|
|
6525
|
-
kitStep = async () => {
|
|
6526
|
-
await (deps.runIntegrate ?? runIntegrate)({ folder: ".", framework: state.framework, api: args.api, apiGiven: args.apiGiven, force: false }, process.env, io, deps.store, deps.accounts);
|
|
6527
|
-
};
|
|
6528
6577
|
} else if (state.kind === "empty") {
|
|
6529
6578
|
stop = "app";
|
|
6530
6579
|
kitStep = async () => {
|
|
@@ -6541,7 +6590,7 @@ async function runSetup(args, io, deps) {
|
|
|
6541
6590
|
}
|
|
6542
6591
|
if (state.kind === "empty") writeAgents();
|
|
6543
6592
|
const noKit = planStopped || state.kind === "react-fresh" && state.cannotAdd !== null;
|
|
6544
|
-
const sentence = noKit ? null : state.kind === "
|
|
6593
|
+
const sentence = noKit ? null : state.kind === "empty" ? null : RESTYLE_SENTENCE;
|
|
6545
6594
|
say([...kitLines, ...agentLines(), ...sentence ? NEXT_STEP(sentence) : []]);
|
|
6546
6595
|
function agentLines() {
|
|
6547
6596
|
const done = agent;
|
|
@@ -6678,14 +6727,15 @@ async function addKit(state, access, kitPath, fresh, deps, io) {
|
|
|
6678
6727
|
return { lines: [...summaryLines(result), ...hint], planStopped: false };
|
|
6679
6728
|
}
|
|
6680
6729
|
|
|
6681
|
-
// src/
|
|
6730
|
+
// src/menu.ts
|
|
6682
6731
|
var MENU = [
|
|
6683
6732
|
{ value: "add", label: "Add the UI kit to a React app", hint: "your components and theme, set up for you" },
|
|
6684
6733
|
{ value: "connect", label: "Connect your coding apps", hint: "Claude Code, Cursor, VS Code and more" },
|
|
6685
6734
|
{ value: "login", label: "Sign in for coding agents", hint: "lets your agent create design systems" },
|
|
6686
|
-
{ value: "integrate", label: "Add to an existing project", hint: "writes design-system/ \u2014 tokens, prompt, reference kit" },
|
|
6687
6735
|
{ value: "create", label: "Create a new project", hint: "a Next.js app with every component and your mockup page" }
|
|
6688
6736
|
];
|
|
6737
|
+
|
|
6738
|
+
// src/index.ts
|
|
6689
6739
|
async function main(argv, env, io) {
|
|
6690
6740
|
let command;
|
|
6691
6741
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "designsource",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "The DS source CLI: add your design system's UI kit to a React app (add), add the design system to any other app (integrate), start a new Next.js project from it (create), or serve it to a coding agent over MCP (mcp) — tokens, every component and your mockup page.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|