@getcoherent/cli 0.6.24 → 0.6.25
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.
|
@@ -679,6 +679,10 @@ function replaceRawColors(classes, colorMap) {
|
|
|
679
679
|
async function autoFixCode(code, context) {
|
|
680
680
|
const fixes = [];
|
|
681
681
|
let fixed = code;
|
|
682
|
+
if (!fixed.includes("\n") && fixed.includes("\\n")) {
|
|
683
|
+
fixed = fixed.replace(/\\n/g, "\n");
|
|
684
|
+
fixes.push("unescaped literal \\n to real newlines");
|
|
685
|
+
}
|
|
682
686
|
const beforeQuoteFix = fixed;
|
|
683
687
|
fixed = fixed.replace(/\\'(\s*[}\],])/g, "'$1");
|
|
684
688
|
fixed = fixed.replace(/(:\s*'.+)\\'(\s*)$/gm, "$1'$2");
|
|
@@ -799,6 +803,32 @@ ${fixed}`;
|
|
|
799
803
|
}
|
|
800
804
|
fixes.push("<button> \u2192 <Button> (with import)");
|
|
801
805
|
}
|
|
806
|
+
if (/<input\b[^>]*(?:\/>|>)/i.test(fixed) && !fixed.includes('type="hidden"')) {
|
|
807
|
+
const inputLines = fixed.split("\n");
|
|
808
|
+
let hasReplacedInput = false;
|
|
809
|
+
for (let i = 0; i < inputLines.length; i++) {
|
|
810
|
+
if (!/<input\b/i.test(inputLines[i])) continue;
|
|
811
|
+
if (inputLines[i].includes('type="hidden"') || inputLines[i].includes("type='hidden'")) continue;
|
|
812
|
+
inputLines[i] = inputLines[i].replace(/<input\b/gi, "<Input");
|
|
813
|
+
hasReplacedInput = true;
|
|
814
|
+
}
|
|
815
|
+
if (hasReplacedInput) {
|
|
816
|
+
fixed = inputLines.join("\n");
|
|
817
|
+
const hasInputImport = /import\s.*\bInput\b.*from\s+['"]@\/components\/ui\/input['"]/.test(fixed);
|
|
818
|
+
if (!hasInputImport) {
|
|
819
|
+
const lastImportIdx = fixed.lastIndexOf("\nimport ");
|
|
820
|
+
if (lastImportIdx !== -1) {
|
|
821
|
+
const lineEnd = fixed.indexOf("\n", lastImportIdx + 1);
|
|
822
|
+
fixed = fixed.slice(0, lineEnd + 1) + "import { Input } from '@/components/ui/input'\n" + fixed.slice(lineEnd + 1);
|
|
823
|
+
} else {
|
|
824
|
+
const hasUseClient2 = /^['"]use client['"]/.test(fixed.trim());
|
|
825
|
+
const insertAfter2 = hasUseClient2 ? fixed.indexOf("\n") + 1 : 0;
|
|
826
|
+
fixed = fixed.slice(0, insertAfter2) + "import { Input } from '@/components/ui/input'\n" + fixed.slice(insertAfter2);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
fixes.push("<input> \u2192 <Input> (with import)");
|
|
830
|
+
}
|
|
831
|
+
}
|
|
802
832
|
const compositeComponents = {
|
|
803
833
|
select: [
|
|
804
834
|
"Select",
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
formatIssues,
|
|
8
8
|
validatePageQuality,
|
|
9
9
|
verifyIncrementalEdit
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-H644LLXJ.js";
|
|
11
11
|
import {
|
|
12
12
|
generateArchitecturePlan,
|
|
13
13
|
getPageGroup,
|
|
@@ -8546,7 +8546,7 @@ async function chatCommand(message, options) {
|
|
|
8546
8546
|
spinner.start(`Creating shared component: ${componentName}...`);
|
|
8547
8547
|
const { createAIProvider: createAIProvider2 } = await import("./ai-provider-CGSIYFZT.js");
|
|
8548
8548
|
const { generateSharedComponent: generateSharedComponent7 } = await import("@getcoherent/core");
|
|
8549
|
-
const { autoFixCode: autoFixCode2 } = await import("./quality-validator-
|
|
8549
|
+
const { autoFixCode: autoFixCode2 } = await import("./quality-validator-VDQXXDAV.js");
|
|
8550
8550
|
const { extractPropsInterface, extractDependencies } = await import("./component-extractor-VYJLT5NR.js");
|
|
8551
8551
|
const aiProvider = await createAIProvider2(provider ?? "auto");
|
|
8552
8552
|
const prompt = `Generate a React component called "${componentName}". Description: ${message}.
|
|
@@ -9013,9 +9013,10 @@ Return JSON: { "requests": [{ "type": "add-page", "changes": { "name": "${compon
|
|
|
9013
9013
|
}
|
|
9014
9014
|
}
|
|
9015
9015
|
try {
|
|
9016
|
-
const { validateReuse } = await import("./reuse-validator-
|
|
9016
|
+
const { validateReuse } = await import("./reuse-validator-XR2ZEYC4.js");
|
|
9017
9017
|
const { inferPageTypeFromRoute: inferPageTypeFromRoute2 } = await import("./design-constraints-EIP2XM7T.js");
|
|
9018
9018
|
const manifest2 = await loadManifest8(projectRoot);
|
|
9019
|
+
const reuseplan = projectRoot ? loadPlan(projectRoot) : null;
|
|
9019
9020
|
if (manifest2.shared.length > 0) {
|
|
9020
9021
|
for (const request of normalizedRequests) {
|
|
9021
9022
|
if (request.type !== "add-page") continue;
|
|
@@ -9024,7 +9025,8 @@ Return JSON: { "requests": [{ "type": "add-page", "changes": { "name": "${compon
|
|
|
9024
9025
|
if (!pageCode) continue;
|
|
9025
9026
|
const route = changes.route || "";
|
|
9026
9027
|
const pageType = inferPageTypeFromRoute2(route);
|
|
9027
|
-
const
|
|
9028
|
+
const planned = reuseplan ? new Set(reuseplan.sharedComponents.filter((c) => c.usedBy.includes(route)).map((c) => c.name)) : void 0;
|
|
9029
|
+
const warnings = validateReuse(manifest2, pageCode, pageType, void 0, planned);
|
|
9028
9030
|
for (const w of warnings) {
|
|
9029
9031
|
console.log(chalk13.yellow(` \u26A0 ${w.message}`));
|
|
9030
9032
|
}
|
|
@@ -11412,7 +11414,7 @@ async function checkCommand(opts = {}) {
|
|
|
11412
11414
|
}
|
|
11413
11415
|
if (!skipShared) {
|
|
11414
11416
|
try {
|
|
11415
|
-
const { validateReuse } = await import("./reuse-validator-
|
|
11417
|
+
const { validateReuse } = await import("./reuse-validator-XR2ZEYC4.js");
|
|
11416
11418
|
const { inferPageTypeFromRoute: inferPageTypeFromRoute2 } = await import("./design-constraints-EIP2XM7T.js");
|
|
11417
11419
|
const manifest = await loadManifest11(projectRoot);
|
|
11418
11420
|
const appDir = resolve14(projectRoot, "app");
|
|
@@ -6,11 +6,12 @@ var RELEVANT_TYPES = {
|
|
|
6
6
|
auth: /* @__PURE__ */ new Set(["form", "feedback"]),
|
|
7
7
|
marketing: /* @__PURE__ */ new Set(["section", "layout"])
|
|
8
8
|
};
|
|
9
|
-
function validateReuse(manifest, generatedCode, pageType, newComponents) {
|
|
9
|
+
function validateReuse(manifest, generatedCode, pageType, newComponents, plannedComponentNames) {
|
|
10
10
|
const warnings = [];
|
|
11
11
|
const relevantTypes = RELEVANT_TYPES[pageType] || RELEVANT_TYPES.app;
|
|
12
12
|
for (const comp of manifest.shared) {
|
|
13
13
|
if (!relevantTypes.has(comp.type)) continue;
|
|
14
|
+
if (plannedComponentNames && !plannedComponentNames.has(comp.name)) continue;
|
|
14
15
|
const isImported = generatedCode.includes(`from '@/components/shared/`) && (generatedCode.includes(`{ ${comp.name} }`) || generatedCode.includes(`{ ${comp.name},`));
|
|
15
16
|
if (!isImported) {
|
|
16
17
|
warnings.push({
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.6.
|
|
6
|
+
"version": "0.6.25",
|
|
7
7
|
"description": "CLI interface for Coherent Design Method",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"ora": "^7.0.1",
|
|
44
44
|
"prompts": "^2.4.2",
|
|
45
45
|
"zod": "^3.22.4",
|
|
46
|
-
"@getcoherent/core": "0.6.
|
|
46
|
+
"@getcoherent/core": "0.6.25"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^20.11.0",
|