@getcoherent/cli 0.6.26 → 0.6.28

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.
@@ -715,9 +715,10 @@ async function autoFixCode(code, context) {
715
715
  if (fixed !== beforeEntityFix) {
716
716
  fixes.push("Fixed syntax issues");
717
717
  }
718
+ const isJsExpr = (text) => /[().;=&|!?]/.test(text);
718
719
  const beforeLtFix = fixed;
719
- fixed = fixed.replace(/>([^<{}\n]*)<(\d)/g, ">$1&lt;$2");
720
- fixed = fixed.replace(/>([^<{}\n]*)<([^/a-zA-Z!{>\n])/g, ">$1&lt;$2");
720
+ fixed = fixed.replace(/>([^<{}\n]*)<(\d)/g, (m, text, d) => isJsExpr(text) ? m : `>${text}&lt;${d}`);
721
+ fixed = fixed.replace(/>([^<{}\n]*)<([^/a-zA-Z!{>\n])/g, (m, text, ch) => isJsExpr(text) ? m : `>${text}&lt;${ch}`);
721
722
  if (fixed !== beforeLtFix) {
722
723
  fixes.push("escaped < in JSX text content");
723
724
  }
@@ -1049,7 +1050,25 @@ ${selectImport}`
1049
1050
  for (const m of fixed.matchAll(/import\s*\{([^}]+)\}\s*from\s*["'](?!lucide-react)([^"']+)["']/g)) {
1050
1051
  m[1].split(",").map((s) => s.trim()).filter(Boolean).forEach((n) => nonLucideImports.add(n));
1051
1052
  }
1052
- const rawIconEntries = lucideImportMatch[1].split(",").map((s) => s.trim()).filter(Boolean);
1053
+ let rawIconEntries = lucideImportMatch[1].split(",").map((s) => s.trim()).filter(Boolean);
1054
+ const seenLocals = /* @__PURE__ */ new Map();
1055
+ for (let i = 0; i < rawIconEntries.length; i++) {
1056
+ const local = rawIconEntries[i].split(/\s+as\s+/).pop().trim();
1057
+ if (seenLocals.has(local)) {
1058
+ const prevIdx = seenLocals.get(local);
1059
+ const prevHasAlias = rawIconEntries[prevIdx].includes(" as ");
1060
+ const curHasAlias = rawIconEntries[i].includes(" as ");
1061
+ if (curHasAlias && !prevHasAlias) {
1062
+ rawIconEntries[prevIdx] = "";
1063
+ } else {
1064
+ rawIconEntries[i] = "";
1065
+ }
1066
+ fixes.push(`removed duplicate import ${local}`);
1067
+ } else {
1068
+ seenLocals.set(local, i);
1069
+ }
1070
+ }
1071
+ rawIconEntries = rawIconEntries.filter(Boolean);
1053
1072
  const iconNames = rawIconEntries.map((entry) => {
1054
1073
  const parts = entry.split(/\s+as\s+/);
1055
1074
  return parts[0].trim();
@@ -1058,7 +1077,7 @@ ${selectImport}`
1058
1077
  const alias = entry.split(/\s+as\s+/).pop().trim();
1059
1078
  return nonLucideImports.has(alias);
1060
1079
  });
1061
- let newImport = lucideImportMatch[1];
1080
+ let newImport = rawIconEntries.join(", ");
1062
1081
  for (const dup of duplicates) {
1063
1082
  const escaped = dup.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1064
1083
  newImport = newImport.replace(new RegExp(`${escaped},?\\s*`), "");
@@ -1106,7 +1125,8 @@ ${selectImport}`
1106
1125
  }
1107
1126
  fixes.push(`invalid lucide icons: ${replacements.join(", ")}`);
1108
1127
  }
1109
- if (duplicates.length > 0 || invalid.length > 0) {
1128
+ const dedupHappened = seenLocals.size < lucideImportMatch[1].split(",").filter((s) => s.trim()).length;
1129
+ if (duplicates.length > 0 || invalid.length > 0 || dedupHappened) {
1110
1130
  const importedNames = [
1111
1131
  ...new Set(
1112
1132
  newImport.split(",").map((s) => s.trim()).filter(Boolean)
@@ -1132,7 +1152,10 @@ ${selectImport}`
1132
1152
  if (lucideExports2) {
1133
1153
  const allImportedNames = /* @__PURE__ */ new Set();
1134
1154
  for (const m of fixed.matchAll(/import\s*\{([^}]+)\}\s*from/g)) {
1135
- m[1].split(",").map((s) => s.trim()).filter(Boolean).forEach((n) => allImportedNames.add(n));
1155
+ m[1].split(",").map((s) => s.trim()).filter(Boolean).forEach((n) => {
1156
+ const alias = n.split(/\s+as\s+/).pop().trim();
1157
+ allImportedNames.add(alias);
1158
+ });
1136
1159
  }
1137
1160
  for (const m of fixed.matchAll(/import\s+([A-Z]\w+)\s+from/g)) {
1138
1161
  allImportedNames.add(m[1]);
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-5AHG4NNX.js";
6
6
  import {
7
7
  autoFixCode
8
- } from "./chunk-H644LLXJ.js";
8
+ } from "./chunk-NP2CGABX.js";
9
9
 
10
10
  // src/commands/chat/plan-generator.ts
11
11
  import { z } from "zod";
@@ -0,0 +1,30 @@
1
+ import {
2
+ buildAppLayoutCode,
3
+ buildGroupLayoutCode,
4
+ ensureAppRouteGroupLayout,
5
+ ensureComponentsInstalled,
6
+ ensurePlanGroupLayouts,
7
+ regenerateComponent,
8
+ regenerateFiles,
9
+ regenerateLayout,
10
+ regeneratePage,
11
+ scanAndInstallSharedDeps,
12
+ validateAndFixGeneratedCode
13
+ } from "./chunk-KUXMS2EF.js";
14
+ import "./chunk-RKXLSNDV.js";
15
+ import "./chunk-5AHG4NNX.js";
16
+ import "./chunk-NP2CGABX.js";
17
+ import "./chunk-3RG5ZIWI.js";
18
+ export {
19
+ buildAppLayoutCode,
20
+ buildGroupLayoutCode,
21
+ ensureAppRouteGroupLayout,
22
+ ensureComponentsInstalled,
23
+ ensurePlanGroupLayouts,
24
+ regenerateComponent,
25
+ regenerateFiles,
26
+ regenerateLayout,
27
+ regeneratePage,
28
+ scanAndInstallSharedDeps,
29
+ validateAndFixGeneratedCode
30
+ };