refira-cli 0.1.1 → 0.1.2

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 +39 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1892,6 +1892,23 @@ var {
1892
1892
  } = exports_commander;
1893
1893
 
1894
1894
  // src/api-client.ts
1895
+ function extractFontFamily(typography, fallback = "Inter") {
1896
+ if (!typography)
1897
+ return fallback;
1898
+ if (typeof typography.font_family === "string" && typography.font_family.trim().length > 0) {
1899
+ return typography.font_family;
1900
+ }
1901
+ if (typography.primary && typeof typography.primary.font_family === "string" && typography.primary.font_family.trim().length > 0) {
1902
+ return typography.primary.font_family;
1903
+ }
1904
+ for (const item of Object.values(typography)) {
1905
+ if (item && typeof item === "object" && typeof item.font_family === "string") {
1906
+ return item.font_family;
1907
+ }
1908
+ }
1909
+ return fallback;
1910
+ }
1911
+
1895
1912
  class CliApiClient {
1896
1913
  apiUrl;
1897
1914
  apiKey;
@@ -2047,18 +2064,22 @@ async function contextCommand(opts) {
2047
2064
  const client = new CliApiClient(config.apiUrl, config.apiKey);
2048
2065
  try {
2049
2066
  const data = await client.getProjectContext(projectId);
2067
+ const projectName = data.context?.project_name ?? data.context?.project?.name ?? "Refira Project";
2068
+ const resolvedProjectId = data.context?.project_id ?? data.context?.project?.id ?? projectId;
2050
2069
  console.log(`
2051
2070
  ======================================================================`);
2052
- console.log(`\uD83D\uDCE6 REFIRA DESIGN CONTEXT: ${data.context.project.name} (${data.context.project.id})`);
2071
+ console.log(`\uD83D\uDCE6 REFIRA DESIGN CONTEXT: ${projectName} (${resolvedProjectId})`);
2053
2072
  console.log("======================================================================");
2054
- const font = data.context.tokens?.typography?.font_family || data.context.project.fontFamily || "Inter";
2073
+ const font = extractFontFamily(data.context?.tokens?.typography, data.context?.project?.fontFamily ?? "Inter");
2055
2074
  console.log(`
2056
2075
  \uD83D\uDD24 Primary Typography: Google Fonts "${font}"`);
2057
- if (data.context.tokens?.color) {
2076
+ const colorTokens = data.context?.tokens?.colors ?? data.context?.tokens?.color;
2077
+ if (colorTokens) {
2058
2078
  console.log(`
2059
2079
  \uD83C\uDFA8 Design Color Tokens:`);
2060
- for (const [tokenName, tokenVal] of Object.entries(data.context.tokens.color)) {
2061
- console.log(` --${tokenName}: ${tokenVal}`);
2080
+ for (const [tokenName, tokenVal] of Object.entries(colorTokens)) {
2081
+ const displayVal = typeof tokenVal === "string" ? tokenVal : tokenVal?.hex ?? tokenVal?.oklch ?? JSON.stringify(tokenVal);
2082
+ console.log(` --${tokenName}: ${displayVal}`);
2062
2083
  }
2063
2084
  }
2064
2085
  console.log(`
@@ -2201,8 +2222,8 @@ async function initCommand(opts) {
2201
2222
  const client = new CliApiClient(apiUrl, apiKey);
2202
2223
  try {
2203
2224
  const data = await client.getProjectContext(projectId);
2204
- const projectName = data.context.project.name || "Refira Project";
2205
- const fontFamily = data.context.tokens?.typography?.font_family || data.context.project.fontFamily || "Inter";
2225
+ const projectName = data.context?.project_name ?? data.context?.project?.name ?? "Refira Project";
2226
+ const fontFamily = extractFontFamily(data.context?.tokens?.typography, data.context?.project?.fontFamily ?? "Inter");
2206
2227
  const agentsGuide = generateAgentsGuide({
2207
2228
  projectName,
2208
2229
  projectId,
@@ -3898,9 +3919,16 @@ async function scaffoldCommand(opts) {
3898
3919
  try {
3899
3920
  const client = new CliApiClient(config.apiUrl, config.apiKey);
3900
3921
  const data = await client.getProjectContext(config.projectId);
3901
- projectName = data.context.project.name || projectName;
3902
- fontFamily = data.context.tokens?.typography?.font_family || data.context.project.fontFamily || fontFamily;
3903
- colorTokens = data.context.tokens?.color;
3922
+ projectName = data.context?.project_name ?? data.context?.project?.name ?? projectName;
3923
+ fontFamily = extractFontFamily(data.context?.tokens?.typography, data.context?.project?.fontFamily ?? fontFamily);
3924
+ const colors = data.context?.tokens?.colors ?? data.context?.tokens?.color;
3925
+ if (colors) {
3926
+ const parsed = {};
3927
+ for (const [k, v] of Object.entries(colors)) {
3928
+ parsed[k] = typeof v === "string" ? v : v?.hex ?? v?.oklch ?? "";
3929
+ }
3930
+ colorTokens = parsed;
3931
+ }
3904
3932
  } catch {}
3905
3933
  }
3906
3934
  const pageName = pageSlug.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
@@ -3939,7 +3967,7 @@ AI coding agents will automatically recognize this skill for high-aesthetic prot
3939
3967
 
3940
3968
  // src/index.ts
3941
3969
  var program2 = new Command2;
3942
- program2.name("refira").description("Refira CLI tool and AI Agent Harness for deterministic prototype generation").version("0.1.0");
3970
+ program2.name("refira").description("Refira CLI tool and AI Agent Harness for deterministic prototype generation").version("0.1.2");
3943
3971
  var auth = program2.command("auth").description("Manage Refira API authentication and sessions");
3944
3972
  auth.command("login").description("Login to Refira using an API key").option("--api-url <url>", "Refira backend API base URL", "http://localhost:3001").option("--api-key <key>", "Project API key (rfr_...)").option("-g, --global", "Save credentials globally in user home directory", false).action(loginCommand);
3945
3973
  auth.command("status").description("Verify and display current Refira authentication session").action(statusCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "refira-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Refira CLI tool and AI Agent Harness for deterministic prototype generation",
5
5
  "type": "module",
6
6
  "bin": {