@getcoherent/cli 0.5.12 → 0.5.14
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.
|
@@ -316,6 +316,54 @@ Tasks:
|
|
|
316
316
|
if (!content) throw new Error("Empty response from OpenAI");
|
|
317
317
|
return content.trim().replace(/^```(?:tsx?|jsx?)\s*/i, "").replace(/\s*```$/i, "");
|
|
318
318
|
}
|
|
319
|
+
async extractSharedComponents(pageCode, reservedNames, existingSharedNames) {
|
|
320
|
+
try {
|
|
321
|
+
const response = await this.client.chat.completions.create({
|
|
322
|
+
model: this.defaultModel,
|
|
323
|
+
messages: [
|
|
324
|
+
{
|
|
325
|
+
role: "system",
|
|
326
|
+
content: "You are a React/Next.js component extraction specialist. Analyze page code and identify reusable UI patterns that can be extracted into shared components. Return valid JSON only."
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
role: "user",
|
|
330
|
+
content: `Analyze this page and extract reusable components.
|
|
331
|
+
|
|
332
|
+
PAGE CODE:
|
|
333
|
+
${pageCode}
|
|
334
|
+
|
|
335
|
+
Rules:
|
|
336
|
+
- Extract 1-5 components maximum
|
|
337
|
+
- Each component must be \u226510 lines of meaningful JSX
|
|
338
|
+
- Output complete, self-contained TypeScript modules with:
|
|
339
|
+
- "use client" directive (if hooks or event handlers are used)
|
|
340
|
+
- All necessary imports (shadcn/ui from @/components/ui/*, lucide-react, next/link, etc.)
|
|
341
|
+
- A typed props interface exported as a named type
|
|
342
|
+
- A named export function (not default export)
|
|
343
|
+
- Do NOT extract: the entire page, trivial wrappers, layout components (header, footer, nav)
|
|
344
|
+
- Do NOT use these names (reserved for shadcn/ui): ${reservedNames.join(", ")}
|
|
345
|
+
- Do NOT use these names (already shared): ${existingSharedNames.join(", ")}
|
|
346
|
+
- Look for: cards with icon+title+description, pricing tiers, testimonial blocks, stat displays, CTA sections
|
|
347
|
+
|
|
348
|
+
Each component object: "name" (PascalCase), "type" ("section"|"widget"), "description", "propsInterface", "code" (full TSX module as string)
|
|
349
|
+
|
|
350
|
+
If no repeating patterns found: { "components": [] }`
|
|
351
|
+
}
|
|
352
|
+
],
|
|
353
|
+
response_format: { type: "json_object" },
|
|
354
|
+
temperature: 0.3,
|
|
355
|
+
max_tokens: 16384
|
|
356
|
+
});
|
|
357
|
+
const content = response.choices[0]?.message?.content;
|
|
358
|
+
if (!content) return { components: [] };
|
|
359
|
+
const jsonText = this.extractJSON(content);
|
|
360
|
+
const parsed = JSON.parse(jsonText);
|
|
361
|
+
const components = Array.isArray(parsed.components) ? parsed.components : [];
|
|
362
|
+
return { components };
|
|
363
|
+
} catch {
|
|
364
|
+
return { components: [] };
|
|
365
|
+
}
|
|
366
|
+
}
|
|
319
367
|
async extractBlockAsComponent(pageCode, blockHint, componentName) {
|
|
320
368
|
const response = await this.client.chat.completions.create({
|
|
321
369
|
model: this.defaultModel,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.5.
|
|
6
|
+
"version": "0.5.14",
|
|
7
7
|
"description": "CLI interface for Coherent Design Method",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
@@ -33,15 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"author": "Coherent Design Method",
|
|
35
35
|
"license": "MIT",
|
|
36
|
-
"scripts": {
|
|
37
|
-
"dev": "tsup --watch",
|
|
38
|
-
"build": "tsup",
|
|
39
|
-
"typecheck": "tsc --noEmit",
|
|
40
|
-
"test": "vitest"
|
|
41
|
-
},
|
|
42
36
|
"dependencies": {
|
|
43
37
|
"@anthropic-ai/sdk": "^0.32.0",
|
|
44
|
-
"@getcoherent/core": "workspace:*",
|
|
45
38
|
"chalk": "^5.3.0",
|
|
46
39
|
"chokidar": "^4.0.1",
|
|
47
40
|
"commander": "^11.1.0",
|
|
@@ -49,12 +42,19 @@
|
|
|
49
42
|
"open": "^10.1.0",
|
|
50
43
|
"ora": "^7.0.1",
|
|
51
44
|
"prompts": "^2.4.2",
|
|
52
|
-
"zod": "^3.22.4"
|
|
45
|
+
"zod": "^3.22.4",
|
|
46
|
+
"@getcoherent/core": "0.5.14"
|
|
53
47
|
},
|
|
54
48
|
"devDependencies": {
|
|
55
49
|
"@types/node": "^20.11.0",
|
|
56
50
|
"@types/prompts": "^2.4.9",
|
|
57
51
|
"tsup": "^8.0.1",
|
|
58
52
|
"typescript": "^5.3.3"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"test": "vitest"
|
|
59
59
|
}
|
|
60
|
-
}
|
|
60
|
+
}
|