@bezel-labs/bezel-kit 0.9.0 → 0.10.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 +26 -8
- package/dist/agent-skill.cjs +5 -5
- package/dist/agent-skill.cjs.map +1 -1
- package/dist/agent-skill.js +1 -1
- package/dist/{chunk-DXZXDPQ6.js → chunk-N57FDE2K.js} +118 -1
- package/dist/chunk-N57FDE2K.js.map +1 -0
- package/dist/chunk-NCIAL4MY.js +17 -0
- package/dist/chunk-NCIAL4MY.js.map +1 -0
- package/dist/chunk-U3AGS46P.js +444 -0
- package/dist/chunk-U3AGS46P.js.map +1 -0
- package/dist/cli.cjs +430 -67
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +84 -5
- package/dist/cli.js.map +1 -1
- package/dist/{index-Bme8IB4Z.d.cts → index-CA8VoEc5.d.cts} +79 -1
- package/dist/{index-BF0AyEbO.d.ts → index-HiFqW1Ju.d.ts} +79 -1
- package/dist/index.cjs +135 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -4
- package/dist/node.cjs +383 -42
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +53 -9
- package/dist/node.d.ts +53 -9
- package/dist/node.js +36 -6
- package/package.json +2 -1
- package/dist/chunk-ACUFL3QJ.js +0 -238
- package/dist/chunk-ACUFL3QJ.js.map +0 -1
- package/dist/chunk-DXZXDPQ6.js.map +0 -1
- package/dist/chunk-WQRF54FG.js +0 -17
- package/dist/chunk-WQRF54FG.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts","../src/config.ts","../src/managed-block.ts","../src/gitignore.ts","../src/init.ts","../src/tokens-sync.ts"],"sourcesContent":["/**\n * bezel/node — Node entry.\n *\n * Re-exports the full isomorphic core, plus the filesystem conveniences:\n * read a DTCG tokens file and write the generated `variables.css` (and optional\n * `contexts.ts`/`fonts.ts`) to disk. This module imports `node:*` and is not\n * browser-safe; for the pure transform use `bezel`.\n */\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\"\nimport { dirname, relative, resolve, sep } from \"node:path\"\nimport { resolveOptions, type BezelOptions, type ResolvedOptions } from \"./config\"\nimport { emitCss } from \"./emit\"\nimport { formatContextsModule, getContexts } from \"./contexts\"\nimport { formatFontsModule, getFonts } from \"./fonts\"\nimport { mergeGitignore } from \"./gitignore\"\nimport { SYNC_STAGING_PATH } from \"./lockfile\"\nimport type { DtcgNode } from \"./types\"\n\nexport * from \"./index\"\nexport { resolveOptions } from \"./config\"\nexport type { BezelOptions, ResolvedOptions } from \"./config\"\nexport { initConfig, readPackageScripts } from \"./init\"\nexport type { InitOptions, InitResult } from \"./init\"\nexport { DEFAULT_CONFIG_FILE, DEFAULT_OUTPUT_DIR, FALLBACK_OUTPUT_DIR } from \"./defaults\"\nexport {\n diffTokens,\n syncFromStaging,\n removeLockfileForOtherProject,\n changedPaths,\n} from \"./tokens-sync\"\nexport type {\n DiffTokensResult,\n SyncFromStagingResult,\n SyncProblem,\n SyncProblemReason,\n} from \"./tokens-sync\"\n\n/**\n * Generate a scoped `variables.css` from a W3C DTCG tokens file.\n *\n * Reads the tokens file, resolves each configured context (with `$root` fallback\n * and reference resolution), and writes one CSS scope per context — the base\n * context in full, others as override-only blocks. Returns the generated CSS.\n *\n * The tokens file is always read from `design-tokens.json` at the project root\n * (resolved against `cwd`); the name and location are fixed and not configurable.\n *\n * @example\n * // zero-config: ./design-tokens.json → ./src/bezel/variables.css\n * await generateVariablesCss()\n *\n * @example\n * await generateVariablesCss({\n * variablesOutput: \"packages/ui/src/bezel/variables.css\",\n * })\n */\nexport async function generateVariablesCss(options: BezelOptions = {}): Promise<string> {\n const resolved = resolveOptions(options)\n\n let raw: string\n try {\n raw = await readFile(resolved.inputPath, \"utf8\")\n } catch (err) {\n throw new Error(\n `bezel: could not read tokens file at \"${resolved.inputPath}\". ` +\n `A \"design-tokens.json\" file must exist at the project root.\\n${(err as Error).message}`,\n )\n }\n\n let tokens: DtcgNode\n try {\n tokens = JSON.parse(raw) as DtcgNode\n } catch (err) {\n throw new Error(`bezel: \"${resolved.inputPath}\" is not valid JSON.\\n${(err as Error).message}`)\n }\n\n const css = emitCss(tokens, resolved)\n\n if (resolved.write) {\n await mkdir(dirname(resolved.variablesOutputPath), { recursive: true })\n await writeFile(resolved.variablesOutputPath, css, \"utf8\")\n\n if (resolved.contextsOutput) {\n const contextsModule = formatContextsModule(getContexts(tokens))\n await mkdir(dirname(resolved.contextsOutput), { recursive: true })\n await writeFile(resolved.contextsOutput, contextsModule, \"utf8\")\n }\n\n if (resolved.fontsOutput) {\n const fontsModule = formatFontsModule(getFonts(tokens))\n await mkdir(dirname(resolved.fontsOutput), { recursive: true })\n await writeFile(resolved.fontsOutput, fontsModule, \"utf8\")\n }\n\n if (resolved.gitignore) {\n await updateGitignore(resolved)\n }\n }\n\n return css\n}\n\n/**\n * Create or update the project `.gitignore` so the generated outputs are ignored.\n * Outputs are written as paths relative to the `.gitignore`, anchored with a leading\n * `/`. Outputs outside the `.gitignore`'s directory can't be anchored from it and are\n * skipped with a warning. The file is only rewritten when its contents actually change.\n */\nasync function updateGitignore(resolved: ResolvedOptions): Promise<void> {\n const dir = dirname(resolved.gitignorePath)\n const outputs = [\n resolved.variablesOutputPath,\n resolved.contextsOutput,\n resolved.fontsOutput,\n // The MCP's sync payload is a temporary hand-off file; the lockfile itself is committed.\n resolve(dirname(resolved.inputPath), SYNC_STAGING_PATH),\n ].filter((p): p is string => p !== null)\n\n const entries: string[] = []\n for (const output of outputs) {\n const rel = relative(dir, output)\n if (rel === \"\" || rel.startsWith(\"..\")) {\n process.stderr.write(\n `bezel: skipping .gitignore entry for \"${output}\" — outside ${resolved.gitignorePath}\\n`,\n )\n continue\n }\n entries.push(`/${rel.split(sep).join(\"/\")}`)\n }\n\n if (entries.length === 0) return\n\n let existing = \"\"\n try {\n existing = await readFile(resolved.gitignorePath, \"utf8\")\n } catch {\n // No existing .gitignore — create one.\n }\n\n const next = mergeGitignore(existing, entries)\n if (next !== existing) {\n await mkdir(dir, { recursive: true })\n await writeFile(resolved.gitignorePath, next, \"utf8\")\n }\n}\n","import { isAbsolute, resolve } from \"node:path\"\nimport { DEFAULT_INPUT, DEFAULT_VARIABLES_OUTPUT } from \"./defaults\"\nimport { resolveCssOptions, type CssOptions } from \"./options\"\n\nexport {\n DEFAULT_CONFIG_FILE,\n DEFAULT_CONTEXTS,\n DEFAULT_INPUT,\n DEFAULT_OUTPUT_DIR,\n DEFAULT_VARIABLES_OUTPUT,\n DEFAULT_NAME_EXTENSION,\n FALLBACK_OUTPUT_DIR,\n} from \"./defaults\"\n\n/**\n * Options for {@link generateVariablesCss} — the Node, file-oriented surface.\n * Extends the pure {@link CssOptions} with input/output paths. All optional;\n * defaults make the zero-config case work.\n */\nexport interface BezelOptions extends CssOptions {\n /**\n * The Bezel project this repo is linked to (a UUID). Read only by the Bezel MCP to\n * know which project to pull `design-tokens.json` from — ignored by `build`.\n */\n projectId?: string\n /**\n * Which tokens the Bezel MCP fetches: `\"latest\"` (the project's latest snapshot) or a\n * published semver like `\"1.4.0\"`. Missing means `\"latest\"`. Ignored by `build`.\n */\n version?: string\n /** Path to write the generated CSS. Default: `\"src/bezel/variables.css\"` (resolved from `cwd`). */\n variablesOutput?: string\n /** Base directory paths are resolved against. Default: `process.cwd()`. */\n cwd?: string\n /**\n * When set, also write a generated TypeScript module exporting `CONTEXTS` (the list of\n * context names derived from the tokens). Path resolved against `cwd`. Default: none.\n */\n contextsOutput?: string\n /**\n * When set, also write a generated TypeScript module exporting `FONTS` (the web fonts\n * derived from the tokens). Path resolved against `cwd`. Default: none.\n */\n fontsOutput?: string\n /** When `false`, return the CSS string without touching the filesystem. Default: `true`. */\n write?: boolean\n /**\n * Create/update a project `.gitignore` so the generated outputs are ignored. The\n * entries live in a marked block, rewritten on each run so renamed outputs are\n * cleaned up. Default: `true`.\n */\n gitignore?: boolean\n /** Path to the `.gitignore` to manage. Default: `\".gitignore\"` (resolved from `cwd`). */\n gitignorePath?: string\n}\n\n/** Fully-resolved options (no `undefined`), produced by {@link resolveOptions}. */\nexport interface ResolvedOptions {\n inputPath: string\n variablesOutputPath: string\n contexts: Record<string, string>\n colorFormat: \"oklch\" | \"hex\"\n dimensionUnit: \"preserve\" | \"rem\"\n nameExtension: string\n includeAll: boolean\n contextsOutput: string | null\n fontsOutput: string | null\n write: boolean\n gitignore: boolean\n gitignorePath: string\n}\n\n/** Apply defaults and resolve input/output paths against `cwd`. */\nexport function resolveOptions(options: BezelOptions = {}): ResolvedOptions {\n const cwd = options.cwd ?? process.cwd()\n const toAbs = (p: string) => (isAbsolute(p) ? p : resolve(cwd, p))\n\n const css = resolveCssOptions(options)\n\n return {\n // The tokens file is always `design-tokens.json` at the project root — not configurable.\n inputPath: toAbs(DEFAULT_INPUT),\n variablesOutputPath: toAbs(options.variablesOutput ?? DEFAULT_VARIABLES_OUTPUT),\n ...css,\n contextsOutput: options.contextsOutput ? toAbs(options.contextsOutput) : null,\n fontsOutput: options.fontsOutput ? toAbs(options.fontsOutput) : null,\n write: options.write ?? true,\n gitignore: options.gitignore ?? true,\n gitignorePath: toAbs(options.gitignorePath ?? \".gitignore\"),\n }\n}\n","/**\n * bezel — managed-block merging for text files Bezel shares with the user.\n *\n * Pure string transforms (no `node:fs`): given a file's existing contents and the\n * lines Bezel wants to own, produce the new contents. Bezel's lines live between a\n * start and end marker so repeated runs rewrite just that span — stale lines drop out,\n * nothing duplicates, and everything the user wrote outside the markers is preserved.\n * `.gitignore` uses `#` comment markers; `AGENTS.md` uses HTML comment markers.\n */\n\nexport interface BlockMarkers {\n /** Opening marker line. */\n start: string\n /** Closing marker line. */\n end: string\n}\n\n/**\n * Merge a managed block into existing file contents.\n *\n * - Empty `existing` → just the block.\n * - An existing block (delimited by the markers) → replaced in place, preserving\n * everything before and after.\n * - No block → appended after the existing content, separated by a blank line.\n *\n * The result always ends with a single trailing newline.\n */\nexport function mergeManagedBlock(\n existing: string,\n lines: string[],\n markers: BlockMarkers,\n): string {\n const block = [markers.start, ...lines, markers.end].join(\"\\n\")\n\n if (existing.trim() === \"\") return `${block}\\n`\n\n const start = existing.indexOf(markers.start)\n if (start !== -1) {\n const endMarker = existing.indexOf(markers.end, start)\n if (endMarker !== -1) {\n const before = existing.slice(0, start).replace(/\\n+$/, \"\")\n const after = existing.slice(endMarker + markers.end.length).replace(/^\\n+/, \"\")\n const head = before === \"\" ? \"\" : `${before}\\n\\n`\n const tail = after === \"\" ? \"\" : `\\n\\n${after.replace(/\\n+$/, \"\")}`\n return `${head}${block}${tail}\\n`\n }\n }\n\n return `${existing.replace(/\\n+$/, \"\")}\\n\\n${block}\\n`\n}\n","/**\n * bezel — `.gitignore` managed-block merging.\n *\n * Given the existing `.gitignore` contents and the list of generated outputs to\n * ignore, produce the new contents. Bezel's entries live inside a marked block so\n * repeated runs rewrite just that span — renamed/removed outputs drop out\n * automatically and entries never duplicate, while the user's own rules outside the\n * markers are preserved. See {@link mergeManagedBlock} for the shared mechanics.\n */\nimport { mergeManagedBlock } from \"./managed-block\"\n\n/** Opening marker for the Bezel-managed block. */\nexport const START = \"# bezel:start (generated — do not edit)\"\n/** Closing marker for the Bezel-managed block. */\nexport const END = \"# bezel:end\"\n\n/**\n * Merge Bezel's managed block into existing `.gitignore` contents.\n *\n * - Empty `existing` → just the block.\n * - An existing block (delimited by {@link START}…{@link END}) → replaced in place,\n * preserving everything before and after.\n * - No block → appended after the existing content, separated by a blank line.\n *\n * The result always ends with a single trailing newline.\n */\nexport function mergeGitignore(existing: string, entries: string[]): string {\n return mergeManagedBlock(existing, entries, { start: START, end: END })\n}\n","/**\n * bezel — `bezel.json` scaffolding.\n *\n * Writes the config file `bezel build` auto-loads, so a project doesn't have to\n * hand-author it. Defaults are derived from the project itself: outputs land in\n * `src/bezel/` when there's a `src/` (otherwise `bezel/`), and the TypeScript\n * modules are only scaffolded for a TypeScript project — `contexts.ts`/`fonts.ts`\n * are emitted as TS (`as const`, `export type`) and would be dead weight in a\n * JavaScript one.\n *\n * Non-destructive: an existing `bezel.json` is never overwritten without `force`.\n * The one exception is the project link: passing `projectId` and/or `version` to an\n * existing config updates just those keys in place, leaving everything else as-is. Relinking\n * to a different project deletes a `design-tokens-lock.json` that belongs to the old one.\n */\nimport { existsSync } from \"node:fs\"\nimport { readFile, writeFile } from \"node:fs/promises\"\nimport { isAbsolute, resolve } from \"node:path\"\nimport type { BezelOptions } from \"./config\"\nimport {\n CONTEXTS_FILE,\n DEFAULT_CONFIG_FILE,\n DEFAULT_INPUT,\n DEFAULT_OUTPUT_DIR,\n FALLBACK_OUTPUT_DIR,\n FONTS_FILE,\n VARIABLES_FILE,\n} from \"./defaults\"\nimport { removeLockfileForOtherProject } from \"./tokens-sync\"\n\n/** Options for {@link initConfig}. All optional — the zero-arg call is the happy path. */\nexport interface InitOptions {\n /** Project root to scaffold into. Default: `process.cwd()`. */\n cwd?: string\n /**\n * Directory for all three outputs, relative to `cwd`. Default: `\"src/bezel\"` when\n * the project has a `src/`, otherwise `\"bezel\"`. Ignored for any output whose path\n * is set explicitly.\n */\n outputDir?: string\n /** Explicit path for the generated CSS. Overrides {@link InitOptions.outputDir}. */\n variablesOutput?: string\n /** Explicit path for the generated contexts module. Implies `contexts: true`. */\n contextsOutput?: string\n /** Explicit path for the generated fonts module. Implies `fonts: true`. */\n fontsOutput?: string\n /** Include `contextsOutput`. Default: true for a TypeScript project. */\n contexts?: boolean\n /** Include `fontsOutput`. Default: true for a TypeScript project. */\n fonts?: boolean\n /** Written to the config only when set — otherwise the build default applies. */\n colorFormat?: \"oklch\" | \"hex\"\n /** Written to the config only when set — otherwise the build default applies. */\n dimensionUnit?: \"preserve\" | \"rem\"\n /** Written to the config only when `true` — otherwise the build default (`false`) applies. */\n includeAll?: boolean\n /** Overwrite an existing `bezel.json`. Default: `false`. */\n force?: boolean\n /**\n * The Bezel project to link this repo to (a UUID). Written as `projectId`; on an\n * existing config it updates just that key without needing `force`.\n */\n projectId?: string\n /**\n * Tokens version the Bezel MCP fetches: `\"latest\"` or a semver like `\"1.4.0\"`.\n * Always written — defaults to `\"latest\"` on a fresh init; on an existing config it\n * updates just that key without needing `force`.\n */\n version?: string\n}\n\n/** Outcome of {@link initConfig}. */\nexport interface InitResult {\n /** Absolute path of the config file. */\n configPath: string\n /** The config that was written — or the one that would have been, when `written` is false. */\n config: BezelOptions\n /** False when an existing `bezel.json` was left untouched (no `force`). */\n written: boolean\n /** Whether a `design-tokens.json` is already present at the project root. */\n hasTokensFile: boolean\n /** Whether the project looks like TypeScript (drives the contexts/fonts defaults). */\n isTypeScript: boolean\n /** True when only `projectId`/`version` were merged into an existing `bezel.json`. */\n updated: boolean\n /** The `projectId` that was in the file before an update, if any. */\n previousProjectId?: string\n /** The `version` that was in the file before an update, if any. */\n previousVersion?: string\n /** True when a `design-tokens-lock.json` for a different project was deleted. */\n removedLockfile?: boolean\n}\n\n/** Whether `value` is a UUID — the shape of a Bezel project id. */\nexport const isUuid = (value: string): boolean =>\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)\n\n/** Whether `value` is a valid tokens version: `\"latest\"` or a semver like `1.4.0`. */\nexport const isTokensVersion = (value: string): boolean =>\n value === \"latest\" || /^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$/.test(value)\n\n/**\n * Join config path segments with forward slashes.\n *\n * Config values are portable JSON, so they always use `/` — `node:path.join` would\n * emit backslashes on Windows and bake a platform into a committed file.\n */\nconst joinPath = (dir: string, file: string): string =>\n dir === \"\" ? file : `${dir.replace(/\\/+$/, \"\")}/${file}`\n\n/**\n * Create a `bezel.json` in the project root, inferring sensible defaults from the\n * project layout.\n *\n * @example\n * // src/bezel/{variables.css,contexts.ts,fonts.ts} for a TS project with a src/\n * await initConfig()\n *\n * @example\n * await initConfig({ outputDir: \"packages/ui/src/bezel\", fonts: false })\n */\nexport async function initConfig(options: InitOptions = {}): Promise<InitResult> {\n if (options.projectId !== undefined && !isUuid(options.projectId)) {\n throw new Error(`bezel: --project must be a UUID, got \"${options.projectId}\"`)\n }\n if (options.version !== undefined && !isTokensVersion(options.version)) {\n throw new Error(\n `bezel: --tokens-version must be \"latest\" or a semver like 1.4.0, got \"${options.version}\"`,\n )\n }\n\n const cwd = options.cwd ?? process.cwd()\n const toAbs = (p: string) => (isAbsolute(p) ? p : resolve(cwd, p))\n\n const configPath = toAbs(DEFAULT_CONFIG_FILE)\n const hasTokensFile = existsSync(toAbs(DEFAULT_INPUT))\n const isTypeScript = existsSync(toAbs(\"tsconfig.json\"))\n\n const hasSrc = existsSync(toAbs(\"src\"))\n const outputDir = options.outputDir ?? (hasSrc ? DEFAULT_OUTPUT_DIR : FALLBACK_OUTPUT_DIR)\n\n // An explicit path is itself an opt-in; otherwise TypeScript projects get the\n // generated modules and JavaScript ones don't.\n const wantsContexts = options.contextsOutput !== undefined || (options.contexts ?? isTypeScript)\n const wantsFonts = options.fontsOutput !== undefined || (options.fonts ?? isTypeScript)\n\n // Link keys come first so the file reads project → version → outputs.\n const config: BezelOptions = {}\n if (options.projectId !== undefined) config.projectId = options.projectId\n config.version = options.version ?? \"latest\"\n config.variablesOutput = options.variablesOutput ?? joinPath(outputDir, VARIABLES_FILE)\n if (wantsContexts) {\n config.contextsOutput = options.contextsOutput ?? joinPath(outputDir, CONTEXTS_FILE)\n }\n if (wantsFonts) {\n config.fontsOutput = options.fontsOutput ?? joinPath(outputDir, FONTS_FILE)\n }\n // Only persist the transform options that were asked for, so the file stays minimal\n // and keeps tracking the library defaults for everything else.\n if (options.colorFormat) config.colorFormat = options.colorFormat\n if (options.dimensionUnit) config.dimensionUnit = options.dimensionUnit\n if (options.includeAll) config.includeAll = true\n\n if (existsSync(configPath) && !options.force) {\n const wantsLinkUpdate = options.projectId !== undefined || options.version !== undefined\n if (!wantsLinkUpdate) {\n return { configPath, config, written: false, updated: false, hasTokensFile, isTypeScript }\n }\n\n // Link-only update: replace just the link keys, keep every other key in place.\n const existing = JSON.parse(await readFile(configPath, \"utf8\")) as BezelOptions & { revision?: unknown }\n // `revision` lived in bezel.json in 0.9.0; it now belongs to design-tokens-lock.json.\n delete existing.revision\n const { projectId: previousProjectId, version: previousVersion, ...rest } = existing\n const merged: BezelOptions = {}\n const projectId = options.projectId ?? previousProjectId\n if (projectId !== undefined) merged.projectId = projectId\n merged.version = options.version ?? previousVersion ?? \"latest\"\n Object.assign(merged, rest)\n\n await writeFile(configPath, `${JSON.stringify(merged, null, 2)}\\n`, \"utf8\")\n const removedLockfile = projectId !== undefined ? await removeLockfileForOtherProject(cwd, projectId) : false\n\n return {\n removedLockfile,\n configPath,\n config: merged,\n written: true,\n updated: true,\n previousProjectId,\n previousVersion,\n hasTokensFile,\n isTypeScript,\n }\n }\n\n await writeFile(configPath, `${JSON.stringify(config, null, 2)}\\n`, \"utf8\")\n const removedLockfile =\n config.projectId !== undefined ? await removeLockfileForOtherProject(cwd, config.projectId) : false\n\n return { configPath, config, written: true, updated: false, removedLockfile, hasTokensFile, isTypeScript }\n}\n\n/**\n * Read the `\"scripts\"` block of the project's `package.json`, if there is one.\n * Used only to tailor the post-init hint — a missing or unparsable file is not an error.\n */\nexport async function readPackageScripts(cwd: string): Promise<Record<string, string>> {\n try {\n const raw = await readFile(resolve(cwd, \"package.json\"), \"utf8\")\n const parsed = JSON.parse(raw) as { scripts?: Record<string, string> }\n return parsed.scripts ?? {}\n } catch {\n return {}\n }\n}\n","/**\n * Keeps `design-tokens.json` and `design-tokens-lock.json` moving together.\n *\n * - `diffTokens`: the local edits, as RFC 6902 operations from the lockfile's tokens (what\n * Bezel had at the last sync or push) to `design-tokens.json`. The Bezel MCP push sends\n * exactly these, the same way the Bezel app saves.\n * - `syncFromStaging`: applies the lockfile the Bezel MCP returned (written by the agent to\n * `.bezel/sync.json`): writes the lockfile, then `design-tokens.json` from it. Refuses to\n * drop local edits Bezel does not have; edits Bezel already has (a push) pass through.\n *\n * Every sync and every push ends with `syncFromStaging`, and it is the only writer of both\n * files, so they cannot drift apart.\n */\nimport { existsSync } from \"node:fs\"\nimport { readFile, rm, writeFile } from \"node:fs/promises\"\nimport { resolve } from \"node:path\"\nimport jsonPatch from \"fast-json-patch\"\nimport { DEFAULT_CONFIG_FILE, DEFAULT_INPUT } from \"./defaults\"\nimport {\n LOCKFILE_NAME,\n SYNC_STAGING_PATH,\n parseLockfile,\n serializeLockfile,\n serializeTokensFile,\n type TokensLockfile,\n} from \"./lockfile\"\nimport { jsonEqual, unappliedOperations, type JsonPatchOperation } from \"./patch-applied\"\n\n// fast-json-patch ships CommonJS; Node's ESM loader only exposes its default export.\nconst { compare } = jsonPatch\n\nexport type SyncProblemReason =\n | \"no-config\"\n | \"no-project\"\n | \"no-lockfile\"\n | \"lockfile-invalid\"\n | \"project-mismatch\"\n | \"version-mismatch\"\n | \"no-tokens-file\"\n | \"tokens-file-invalid\"\n | \"no-staging\"\n | \"staging-invalid\"\n | \"unpushed-edits\"\n | \"unknown-local-edits\"\n\nexport type SyncProblem = { ok: false; reason: SyncProblemReason; message: string }\n\nconst SYNC_HINT = 'Sync from Bezel (ask your agent to \"sync my Bezel tokens\").'\n\ntype Link = { projectId: string; version: string }\n\nasync function readLink(cwd: string): Promise<{ ok: true; link: Link } | SyncProblem> {\n const path = resolve(cwd, DEFAULT_CONFIG_FILE)\n if (!existsSync(path)) {\n return { ok: false, reason: \"no-config\", message: `No ${DEFAULT_CONFIG_FILE} here. Run \"bezel init --project <uuid>\" first.` }\n }\n let config: { projectId?: unknown; version?: unknown }\n try {\n config = JSON.parse(await readFile(path, \"utf8\")) as typeof config\n } catch {\n return { ok: false, reason: \"no-config\", message: `${DEFAULT_CONFIG_FILE} is not valid JSON.` }\n }\n if (typeof config.projectId !== \"string\" || config.projectId === \"\") {\n return {\n ok: false,\n reason: \"no-project\",\n message: `${DEFAULT_CONFIG_FILE} has no projectId. Link the repo with \"bezel init --project <uuid>\".`,\n }\n }\n const version = typeof config.version === \"string\" && config.version !== \"\" ? config.version : \"latest\"\n return { ok: true, link: { projectId: config.projectId, version } }\n}\n\nasync function readTokensFile(cwd: string): Promise<{ ok: true; tokens: Record<string, unknown> } | SyncProblem> {\n const path = resolve(cwd, DEFAULT_INPUT)\n if (!existsSync(path)) {\n return { ok: false, reason: \"no-tokens-file\", message: `No ${DEFAULT_INPUT} here. ${SYNC_HINT}` }\n }\n try {\n const parsed: unknown = JSON.parse(await readFile(path, \"utf8\"))\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) throw new Error(\"not an object\")\n return { ok: true, tokens: parsed as Record<string, unknown> }\n } catch {\n return {\n ok: false,\n reason: \"tokens-file-invalid\",\n message: `${DEFAULT_INPUT} is not a JSON object. Fix the file (or sync from Bezel to replace it).`,\n }\n }\n}\n\n/** The lockfile, `null` when there is none, or the problem with it. */\nasync function readCurrentLockfile(cwd: string): Promise<{ ok: true; lockfile: TokensLockfile | null } | SyncProblem> {\n const path = resolve(cwd, LOCKFILE_NAME)\n if (!existsSync(path)) return { ok: true, lockfile: null }\n const parsed = parseLockfile(await readFile(path, \"utf8\"))\n if (parsed.ok === false) return { ok: false, reason: \"lockfile-invalid\", message: parsed.message }\n return { ok: true, lockfile: parsed.lockfile }\n}\n\nfunction checkLockMatchesLink(lockfile: TokensLockfile, link: Link, name: string): SyncProblem | null {\n if (lockfile.projectId !== link.projectId) {\n return {\n ok: false,\n reason: \"project-mismatch\",\n message: `${name} is for project ${lockfile.projectId}, but ${DEFAULT_CONFIG_FILE} links ${link.projectId}. ${SYNC_HINT}`,\n }\n }\n if (lockfile.version !== link.version) {\n return {\n ok: false,\n reason: \"version-mismatch\",\n message: `${name} holds version \"${lockfile.version}\", but ${DEFAULT_CONFIG_FILE} tracks \"${link.version}\". ${SYNC_HINT}`,\n }\n }\n return null\n}\n\n/**\n * Dotted token-ish paths an operation list touches, for human summaries: the pointer up to\n * the first `$` key (`/color/primary/$root/$value` -> `color.primary`), deduped.\n */\nexport function changedPaths(operations: JsonPatchOperation[]): string[] {\n const paths = new Set<string>()\n for (const operation of operations) {\n if (operation.op === \"test\") continue\n const segments: string[] = []\n for (const raw of operation.path.split(\"/\").slice(1)) {\n const segment = raw.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n if (segment.startsWith(\"$\")) break\n segments.push(segment)\n }\n paths.add(segments.length > 0 ? segments.join(\".\") : \"(root)\")\n }\n return [...paths]\n}\n\nexport type DiffTokensResult =\n | {\n ok: true\n projectId: string\n version: string\n /** The revision the lockfile records: what Bezel had when these edits started */\n baseRevision: number\n /** RFC 6902 operations, with `test` guards, from the lockfile's tokens to design-tokens.json */\n operations: JsonPatchOperation[]\n }\n | SyncProblem\n\n/** Local edits to push: `compare(lockfile.tokens, design-tokens.json, true)`, like the Bezel app's save. */\nexport async function diffTokens({ cwd = process.cwd() }: { cwd?: string } = {}): Promise<DiffTokensResult> {\n const link = await readLink(cwd)\n if (link.ok === false) return link\n\n const current = await readCurrentLockfile(cwd)\n if (current.ok === false) return current\n if (current.lockfile === null) {\n return {\n ok: false,\n reason: \"no-lockfile\",\n message: `No ${LOCKFILE_NAME} yet, so local edits cannot be told apart from Bezel's tokens. ${SYNC_HINT}`,\n }\n }\n const mismatch = checkLockMatchesLink(current.lockfile, link.link, LOCKFILE_NAME)\n if (mismatch) return mismatch\n\n const local = await readTokensFile(cwd)\n if (local.ok === false) return local\n\n const operations = compare(current.lockfile.tokens, local.tokens, true) as JsonPatchOperation[]\n return {\n ok: true,\n projectId: current.lockfile.projectId,\n version: current.lockfile.version,\n baseRevision: current.lockfile.revision,\n operations,\n }\n}\n\nexport type SyncFromStagingResult =\n | {\n ok: true\n projectId: string\n version: string\n revision: number\n /** False when design-tokens.json already held these tokens */\n tokensChanged: boolean\n /** Local edits that were dropped because `discardLocalEdits` was set */\n discardedEdits: number\n }\n | (SyncProblem & { unpushedPaths?: string[] })\n\n/**\n * Applies `.bezel/sync.json` (the lockfile text the Bezel MCP returned): checks it, refuses\n * when design-tokens.json has edits the incoming tokens lack (unless `discardLocalEdits`),\n * writes design-tokens-lock.json and then design-tokens.json, and removes the staging file.\n */\nexport async function syncFromStaging({\n cwd = process.cwd(),\n discardLocalEdits = false,\n}: { cwd?: string; discardLocalEdits?: boolean } = {}): Promise<SyncFromStagingResult> {\n const stagingPath = resolve(cwd, SYNC_STAGING_PATH)\n if (!existsSync(stagingPath)) {\n return {\n ok: false,\n reason: \"no-staging\",\n message: `Nothing to sync: ${SYNC_STAGING_PATH} is missing. Write the \"lockfileContent\" from the Bezel MCP's get-design-tokens-file there first.`,\n }\n }\n const incoming = parseLockfile(await readFile(stagingPath, \"utf8\"), SYNC_STAGING_PATH)\n if (incoming.ok === false) {\n return {\n ok: false,\n reason: \"staging-invalid\",\n message: `${incoming.message.replace(/ Sync from Bezel to rewrite it\\.$/, \"\")} Write the \"lockfileContent\" from get-design-tokens-file to ${SYNC_STAGING_PATH} exactly as returned, then run \"bezel sync\" again.`,\n }\n }\n const next = incoming.lockfile\n\n const link = await readLink(cwd)\n if (link.ok === false) return link\n const mismatch = checkLockMatchesLink(next, link.link, SYNC_STAGING_PATH)\n if (mismatch) {\n return {\n ...mismatch,\n message: `${SYNC_STAGING_PATH} is for project ${next.projectId} version \"${next.version}\", but ${DEFAULT_CONFIG_FILE} links ${link.link.projectId} version \"${link.link.version}\". Fetch the tokens for the linked project and version, or relink with \"bezel init --project <uuid> --tokens-version <v>\".`,\n }\n }\n\n const tokensPath = resolve(cwd, DEFAULT_INPUT)\n let discardedEdits = 0\n let tokensChanged = true\n\n if (existsSync(tokensPath)) {\n const local = await readTokensFile(cwd)\n if (local.ok === true) {\n tokensChanged = !jsonEqual(local.tokens, next.tokens)\n const current = await readCurrentLockfile(cwd)\n const base =\n current.ok === true && current.lockfile !== null && checkLockMatchesLink(current.lockfile, link.link, LOCKFILE_NAME) === null\n ? current.lockfile\n : null\n\n if (tokensChanged) {\n if (base === null) {\n // No usable lockfile: the local file cannot be told apart from older Bezel tokens.\n if (!discardLocalEdits) {\n return {\n ok: false,\n reason: \"unknown-local-edits\",\n message: `${DEFAULT_INPUT} differs from Bezel's tokens and there is no usable ${LOCKFILE_NAME} to tell local edits from older Bezel tokens. If the file has no edits worth keeping, run \"bezel sync --discard-local-edits\" to replace it.`,\n }\n }\n } else {\n const localEdits = compare(base.tokens, local.tokens, true) as JsonPatchOperation[]\n const unpushed = unappliedOperations(next.tokens, localEdits)\n if (unpushed.length > 0 && !discardLocalEdits) {\n const paths = changedPaths(unpushed)\n return {\n ok: false,\n reason: \"unpushed-edits\",\n unpushedPaths: paths,\n message: `${DEFAULT_INPUT} has ${unpushed.length} local ${unpushed.length === 1 ? \"edit\" : \"edits\"} Bezel does not have (${paths.slice(0, 10).join(\", \")}${paths.length > 10 ? \", ...\" : \"\"}). Push them to Bezel first, or run \"bezel sync --discard-local-edits\" to drop them.`,\n }\n }\n discardedEdits = unpushed.length\n }\n }\n } else if (!discardLocalEdits) {\n return {\n ...local,\n message: `${local.message.replace(/ \\(or sync from Bezel to replace it\\)/, \"\")} Or run \"bezel sync --discard-local-edits\" to replace it with Bezel's tokens.`,\n }\n }\n }\n\n // Lockfile first, tokens last: an interrupted sync shows up as local edits and a rerun fixes it.\n await writeFile(resolve(cwd, LOCKFILE_NAME), serializeLockfile(next), \"utf8\")\n if (tokensChanged) await writeFile(tokensPath, serializeTokensFile(next.tokens), \"utf8\")\n await rm(stagingPath, { force: true })\n\n return { ok: true, projectId: next.projectId, version: next.version, revision: next.revision, tokensChanged, discardedEdits }\n}\n\n/** Deletes a lockfile that belongs to another project (used when `bezel init` relinks). */\nexport async function removeLockfileForOtherProject(cwd: string, projectId: string): Promise<boolean> {\n const path = resolve(cwd, LOCKFILE_NAME)\n if (!existsSync(path)) return false\n try {\n const parsed = JSON.parse(await readFile(path, \"utf8\")) as { projectId?: unknown }\n if (parsed.projectId === projectId) return false\n } catch {\n // An unreadable lockfile is no use for the new project either.\n }\n await rm(path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I,QAAQ,WAAW,EAAG;AAE1B,MAAI,WAAW;AACf,MAAI;AACF,eAAW,MAAMF,UAAS,SAAS,eAAe,MAAM;AAAA,EAC1D,QAAQ;AAAA,EAER;AAEA,QAAM,OAAO,eAAe,UAAU,OAAO;AAC7C,MAAI,SAAS,UAAU;AACrB,UAAM,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AACpC,UAAMC,WAAU,SAAS,eAAe,MAAM,MAAM;AAAA,EACtD;AACF;","names":["readFile","writeFile","resolve","existsSync","readFile","writeFile","isAbsolute","resolve","resolve","resolve","isAbsolute","resolve","existsSync","readFile","writeFile","removedLockfile","readFile","writeFile","resolve"]}
|