@getcoherent/cli 0.5.13 → 0.5.15
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sergei Kovtun
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -357,6 +357,49 @@ Requirements:
|
|
|
357
357
|
if (content.type !== "text") throw new Error("Unexpected response type");
|
|
358
358
|
return content.text.trim().replace(/^```(?:tsx?|jsx?)\s*/i, "").replace(/\s*```$/i, "");
|
|
359
359
|
}
|
|
360
|
+
async extractSharedComponents(pageCode, reservedNames, existingSharedNames) {
|
|
361
|
+
try {
|
|
362
|
+
const response = await this.client.messages.create({
|
|
363
|
+
model: this.defaultModel,
|
|
364
|
+
max_tokens: 16384,
|
|
365
|
+
messages: [
|
|
366
|
+
{
|
|
367
|
+
role: "user",
|
|
368
|
+
content: `Analyze this page and extract reusable components.
|
|
369
|
+
|
|
370
|
+
PAGE CODE:
|
|
371
|
+
${pageCode}
|
|
372
|
+
|
|
373
|
+
Rules:
|
|
374
|
+
- Extract 1-5 components maximum
|
|
375
|
+
- Each component must be \u226510 lines of meaningful JSX
|
|
376
|
+
- Output complete, self-contained TypeScript modules with:
|
|
377
|
+
- "use client" directive (if hooks or event handlers are used)
|
|
378
|
+
- All necessary imports (shadcn/ui from @/components/ui/*, lucide-react, next/link, etc.)
|
|
379
|
+
- A typed props interface exported as a named type
|
|
380
|
+
- A named export function (not default export)
|
|
381
|
+
- Do NOT extract: the entire page, trivial wrappers, layout components (header, footer, nav)
|
|
382
|
+
- Do NOT use these names (reserved for shadcn/ui): ${reservedNames.join(", ")}
|
|
383
|
+
- Do NOT use these names (already shared): ${existingSharedNames.join(", ")}
|
|
384
|
+
- Look for: cards with icon+title+description, pricing tiers, testimonial blocks, stat displays, CTA sections
|
|
385
|
+
|
|
386
|
+
Each component object: "name" (PascalCase), "type" ("section"|"widget"), "description", "propsInterface", "code" (full TSX module as string)
|
|
387
|
+
|
|
388
|
+
If no repeating patterns found: { "components": [] }`
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
system: "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 ONLY valid JSON. No markdown fencing, no explanation outside the JSON object."
|
|
392
|
+
});
|
|
393
|
+
const content = response.content[0];
|
|
394
|
+
if (content.type !== "text") return { components: [] };
|
|
395
|
+
const jsonText = this.extractJSON(content.text);
|
|
396
|
+
const parsed = JSON.parse(jsonText);
|
|
397
|
+
const components = Array.isArray(parsed.components) ? parsed.components : [];
|
|
398
|
+
return { components };
|
|
399
|
+
} catch {
|
|
400
|
+
return { components: [] };
|
|
401
|
+
}
|
|
402
|
+
}
|
|
360
403
|
};
|
|
361
404
|
export {
|
|
362
405
|
ClaudeClient
|