@getcoherent/cli 0.6.13 → 0.6.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.
- package/LICENSE +21 -0
- package/dist/ai-classifier-EGXPFJLN.js +42 -0
- package/dist/ai-provider-HUQO64P3.js +13 -0
- package/dist/chunk-25JRF5MA.js +124 -0
- package/dist/{chunk-CLPILU3Z.js → chunk-5AHG4NNX.js} +10 -292
- package/dist/chunk-N6H73ROO.js +1244 -0
- package/dist/chunk-WRDWFCQJ.js +323 -0
- package/dist/component-extractor-VYJLT5NR.js +56 -0
- package/dist/design-constraints-EIP2XM7T.js +43 -0
- package/dist/index.js +857 -1914
- package/dist/{plan-generator-QUESV7GS.js → plan-generator-H55WEIY2.js} +2 -1
- package/dist/quality-validator-3K5BMJSR.js +15 -0
- package/dist/reuse-validator-HC4LZEKF.js +74 -0
- package/package.json +10 -10
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
autoFixCode,
|
|
3
|
+
checkDesignConsistency,
|
|
4
|
+
formatIssues,
|
|
5
|
+
validatePageQuality,
|
|
6
|
+
verifyIncrementalEdit
|
|
7
|
+
} from "./chunk-N6H73ROO.js";
|
|
8
|
+
import "./chunk-3RG5ZIWI.js";
|
|
9
|
+
export {
|
|
10
|
+
autoFixCode,
|
|
11
|
+
checkDesignConsistency,
|
|
12
|
+
formatIssues,
|
|
13
|
+
validatePageQuality,
|
|
14
|
+
verifyIncrementalEdit
|
|
15
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "./chunk-3RG5ZIWI.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/reuse-validator.ts
|
|
4
|
+
var RELEVANT_TYPES = {
|
|
5
|
+
app: /* @__PURE__ */ new Set(["data-display", "form", "navigation", "feedback"]),
|
|
6
|
+
auth: /* @__PURE__ */ new Set(["form", "feedback"]),
|
|
7
|
+
marketing: /* @__PURE__ */ new Set(["section", "layout"])
|
|
8
|
+
};
|
|
9
|
+
function validateReuse(manifest, generatedCode, pageType, newComponents) {
|
|
10
|
+
const warnings = [];
|
|
11
|
+
const relevantTypes = RELEVANT_TYPES[pageType] || RELEVANT_TYPES.app;
|
|
12
|
+
for (const comp of manifest.shared) {
|
|
13
|
+
if (!relevantTypes.has(comp.type)) continue;
|
|
14
|
+
const isImported = generatedCode.includes(`from '@/components/shared/`) && (generatedCode.includes(`{ ${comp.name} }`) || generatedCode.includes(`{ ${comp.name},`));
|
|
15
|
+
if (!isImported) {
|
|
16
|
+
warnings.push({
|
|
17
|
+
type: "missed-reuse",
|
|
18
|
+
componentId: comp.id,
|
|
19
|
+
componentName: comp.name,
|
|
20
|
+
message: `${comp.name} (${comp.id}) is available but not imported. Consider using it instead of inline patterns.`
|
|
21
|
+
});
|
|
22
|
+
} else if (comp.propsInterface) {
|
|
23
|
+
const requiredProps = parseProps(comp.propsInterface);
|
|
24
|
+
const usageMatch = generatedCode.match(new RegExp(`<${comp.name}\\s([^>]*?)/?>`));
|
|
25
|
+
if (usageMatch) {
|
|
26
|
+
const usedProps = new Set((usageMatch[1].match(/(\w+)=/g) || []).map((p) => p.replace("=", "")));
|
|
27
|
+
for (const req of requiredProps) {
|
|
28
|
+
if (!usedProps.has(req) && !comp.propsInterface.includes(`${req}?`)) {
|
|
29
|
+
warnings.push({
|
|
30
|
+
type: "wrong-usage",
|
|
31
|
+
componentId: comp.id,
|
|
32
|
+
componentName: comp.name,
|
|
33
|
+
message: `${comp.name} (${comp.id}) is missing required prop "${req}".`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (newComponents) {
|
|
41
|
+
for (const newComp of newComponents) {
|
|
42
|
+
for (const existing of manifest.shared) {
|
|
43
|
+
if (existing.type !== newComp.type) continue;
|
|
44
|
+
const existingProps = parseProps(existing.propsInterface || "");
|
|
45
|
+
const newProps = parseProps(newComp.propsInterface || "");
|
|
46
|
+
const overlap = propOverlap(existingProps, newProps);
|
|
47
|
+
if (overlap > 0.5) {
|
|
48
|
+
warnings.push({
|
|
49
|
+
type: "duplicate-creation",
|
|
50
|
+
componentId: existing.id,
|
|
51
|
+
componentName: newComp.name,
|
|
52
|
+
message: `New ${newComp.name} looks similar to existing ${existing.name} (${existing.id}). Consider reusing ${existing.name} instead.`
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return warnings;
|
|
59
|
+
}
|
|
60
|
+
function parseProps(propsStr) {
|
|
61
|
+
const names = propsStr.match(/(\w+)\s*[?:]?\s*:/g) || [];
|
|
62
|
+
return new Set(names.map((n) => n.replace(/[?:\s]/g, "")));
|
|
63
|
+
}
|
|
64
|
+
function propOverlap(a, b) {
|
|
65
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
66
|
+
let shared = 0;
|
|
67
|
+
for (const prop of a) {
|
|
68
|
+
if (b.has(prop)) shared++;
|
|
69
|
+
}
|
|
70
|
+
return shared / Math.max(a.size, b.size);
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
validateReuse
|
|
74
|
+
};
|
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.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.6.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
|
+
}
|