@getcoherent/cli 0.6.15 → 0.6.16

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.
Files changed (2) hide show
  1. package/dist/index.js +79 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5037,7 +5037,7 @@ var AUTH_SYNONYMS = {
5037
5037
  };
5038
5038
  function deduplicatePages(pages) {
5039
5039
  const canonicalize = (route) => AUTH_SYNONYMS[route] || route;
5040
- const normalize = (route) => canonicalize(route).replace(/\/$/, "").replace(/s$/, "").replace(/ue$/, "");
5040
+ const normalize = (route) => canonicalize(route).replace(/\/$/, "");
5041
5041
  const seen = /* @__PURE__ */ new Map();
5042
5042
  return pages.filter((page, idx) => {
5043
5043
  const norm = normalize(page.route);
@@ -5949,7 +5949,7 @@ function extractStyleContext(pageCode) {
5949
5949
  return `STYLE CONTEXT (match these patterns exactly for visual consistency with the anchor page):
5950
5950
  ${lines.map((l) => ` - ${l}`).join("\n")}`;
5951
5951
  }
5952
- var VALID_NAV_TYPES = /* @__PURE__ */ new Set(["header", "sidebar", "both"]);
5952
+ var VALID_NAV_TYPES = /* @__PURE__ */ new Set(["header", "sidebar", "both", "none"]);
5953
5953
  function parseNavTypeFromPlan(planResult) {
5954
5954
  const nav = planResult.navigation;
5955
5955
  if (nav && typeof nav.type === "string" && VALID_NAV_TYPES.has(nav.type)) {
@@ -6720,7 +6720,9 @@ async function regeneratePage(pageId, config2, projectRoot) {
6720
6720
  const code = await generator.generate(page, appType);
6721
6721
  const route = page.route || "/";
6722
6722
  const isAuth = isAuthRoute(route) || isAuthRoute(page.name || page.id || "");
6723
- const filePath = routeToFsPath(projectRoot, route, isAuth);
6723
+ const { loadPlan: loadPlanForPath } = await import("./plan-generator-ITHYNYJI.js");
6724
+ const planForPath = loadPlanForPath(projectRoot);
6725
+ const filePath = routeToFsPath(projectRoot, route, planForPath || isAuth);
6724
6726
  await mkdir3(dirname5(filePath), { recursive: true });
6725
6727
  await writeFile(filePath, code);
6726
6728
  }
@@ -6834,7 +6836,8 @@ async function ensureAppRouteGroupLayout(projectRoot, navType, forceUpdate = fal
6834
6836
  function buildAppLayoutCode(navType) {
6835
6837
  const hasSidebar = navType === "sidebar" || navType === "both";
6836
6838
  if (hasSidebar) {
6837
- return `import { Sidebar } from '@/components/shared/sidebar'
6839
+ return `import { AppSidebar } from '@/components/shared/sidebar'
6840
+ import { SidebarProvider, SidebarInset } from '@/components/ui/sidebar'
6838
6841
 
6839
6842
  export default function AppLayout({
6840
6843
  children,
@@ -6842,12 +6845,14 @@ export default function AppLayout({
6842
6845
  children: React.ReactNode
6843
6846
  }) {
6844
6847
  return (
6845
- <div className="flex min-h-[calc(100vh-3.5rem)]">
6846
- <Sidebar />
6847
- <main className="flex-1 px-4 sm:px-6 lg:px-8 py-6">
6848
- {children}
6849
- </main>
6850
- </div>
6848
+ <SidebarProvider>
6849
+ <AppSidebar />
6850
+ <SidebarInset>
6851
+ <main className="flex-1 px-4 sm:px-6 lg:px-8 py-6">
6852
+ {children}
6853
+ </main>
6854
+ </SidebarInset>
6855
+ </SidebarProvider>
6851
6856
  )
6852
6857
  }
6853
6858
  `;
@@ -6867,7 +6872,8 @@ export default function AppLayout({
6867
6872
  }
6868
6873
  function buildGroupLayoutCode(layout, _pages) {
6869
6874
  if (layout === "sidebar" || layout === "both") {
6870
- return `import { Sidebar } from '@/components/shared/sidebar'
6875
+ return `import { AppSidebar } from '@/components/shared/sidebar'
6876
+ import { SidebarProvider, SidebarInset } from '@/components/ui/sidebar'
6871
6877
 
6872
6878
  export default function GroupLayout({
6873
6879
  children,
@@ -6875,12 +6881,14 @@ export default function GroupLayout({
6875
6881
  children: React.ReactNode
6876
6882
  }) {
6877
6883
  return (
6878
- <div className="flex min-h-[calc(100vh-3.5rem)]">
6879
- <Sidebar />
6880
- <main className="flex-1 px-4 sm:px-6 lg:px-8 py-6">
6881
- {children}
6882
- </main>
6883
- </div>
6884
+ <SidebarProvider>
6885
+ <AppSidebar />
6886
+ <SidebarInset>
6887
+ <main className="flex-1 px-4 sm:px-6 lg:px-8 py-6">
6888
+ {children}
6889
+ </main>
6890
+ </SidebarInset>
6891
+ </SidebarProvider>
6884
6892
  )
6885
6893
  }
6886
6894
  `;
@@ -7404,7 +7412,8 @@ async function applyModification(request, dsm, cm, pm, projectRoot, aiProvider,
7404
7412
  modified: []
7405
7413
  };
7406
7414
  }
7407
- const pageFilePath = routeToFsPath(projectRoot, route, false);
7415
+ const readPlan = projectRoot ? loadPlan(projectRoot) : null;
7416
+ const pageFilePath = routeToFsPath(projectRoot, route, readPlan || false);
7408
7417
  let pageCode;
7409
7418
  try {
7410
7419
  pageCode = await readFile(pageFilePath);
@@ -7687,13 +7696,13 @@ async function applyModification(request, dsm, cm, pm, projectRoot, aiProvider,
7687
7696
  if (isAuth) {
7688
7697
  await ensureAuthRouteGroup(projectRoot);
7689
7698
  }
7690
- const filePath = routeToFsPath(projectRoot, route, isAuth);
7699
+ const currentPlan = projectRoot ? loadPlan(projectRoot) : null;
7700
+ const filePath = routeToFsPath(projectRoot, route, currentPlan || isAuth);
7691
7701
  await mkdir4(dirname6(filePath), { recursive: true });
7692
7702
  const { fixedCode, fixes: postFixes } = await validateAndFixGeneratedCode(projectRoot, finalPageCode, {
7693
7703
  isPage: true
7694
7704
  });
7695
7705
  let codeToWrite = fixedCode;
7696
- const currentPlan = projectRoot ? loadPlan(projectRoot) : null;
7697
7706
  const autoFixCtx = route ? {
7698
7707
  currentRoute: route,
7699
7708
  knownRoutes: dsm.getConfig().pages.map((p) => p.route).filter(Boolean),
@@ -7853,7 +7862,8 @@ Rules:
7853
7862
  if (pageDef?.route) {
7854
7863
  const route = pageDef.route;
7855
7864
  const isAuth = isAuthRoute(route) || isAuthRoute(pageDef.name || pageDef.id || "");
7856
- const absPath = routeToFsPath(projectRoot, route, isAuth);
7865
+ const updatePlan = projectRoot ? loadPlan(projectRoot) : null;
7866
+ const absPath = routeToFsPath(projectRoot, route, updatePlan || isAuth);
7857
7867
  if (!resolvedPageCode && instruction) {
7858
7868
  let currentCode;
7859
7869
  try {
@@ -7987,7 +7997,54 @@ ${pagesCtx}`
7987
7997
  allShared: manifestForAudit.shared,
7988
7998
  layoutShared: manifestForAudit.shared.filter((c) => c.type === "layout")
7989
7999
  });
7990
- const issues = validatePageQuality(codeToWrite, void 0, qualityPageType2);
8000
+ let issues = validatePageQuality(codeToWrite, void 0, qualityPageType2);
8001
+ let qualityErrors = issues.filter((i) => i.severity === "error");
8002
+ const MAX_UPDATE_QUALITY_FIX_ATTEMPTS = 2;
8003
+ for (let attempt = 0; attempt < MAX_UPDATE_QUALITY_FIX_ATTEMPTS && qualityErrors.length > 0; attempt++) {
8004
+ if (!aiProvider) break;
8005
+ try {
8006
+ const ai = await createAIProvider(aiProvider);
8007
+ if (!ai.editPageCode) break;
8008
+ const errorList = qualityErrors.map((e) => `Line ${e.line}: [${e.type}] ${e.message}`).join("\n");
8009
+ const fixInstruction = `Fix these quality issues:
8010
+ ${errorList}
8011
+
8012
+ Rules:
8013
+ - Replace raw Tailwind colors with semantic tokens (bg-primary, text-muted-foreground, etc.)
8014
+ - Replace placeholder content with realistic contextual content
8015
+ - Ensure heading hierarchy
8016
+ - Keep all existing functionality and layout intact`;
8017
+ const qFixedCode = await ai.editPageCode(
8018
+ codeToWrite,
8019
+ fixInstruction,
8020
+ pageDef.name || pageDef.id || "Page"
8021
+ );
8022
+ if (qFixedCode && qFixedCode.length > 100 && /export\s+(default\s+)?function/.test(qFixedCode)) {
8023
+ const recheck = validatePageQuality(qFixedCode, void 0, qualityPageType2);
8024
+ const recheckErrors = recheck.filter((i) => i.severity === "error");
8025
+ if (recheckErrors.length < qualityErrors.length) {
8026
+ codeToWrite = qFixedCode;
8027
+ const { code: reFixed } = await autoFixCode(codeToWrite, autoFixCtx2);
8028
+ codeToWrite = reFixed;
8029
+ await writeFile(absPath, codeToWrite);
8030
+ qualityErrors = recheckErrors;
8031
+ console.log(
8032
+ chalk11.green(
8033
+ ` \u2714 Quality fix: ${qualityErrors.length + (qualityErrors.length - recheckErrors.length)} \u2192 ${recheckErrors.length} errors`
8034
+ )
8035
+ );
8036
+ if (qualityErrors.length === 0) break;
8037
+ } else {
8038
+ break;
8039
+ }
8040
+ } else {
8041
+ break;
8042
+ }
8043
+ } catch {
8044
+ break;
8045
+ }
8046
+ }
8047
+ issues = validatePageQuality(codeToWrite, void 0, qualityPageType2);
7991
8048
  const report = formatIssues(issues);
7992
8049
  if (report) {
7993
8050
  console.log(chalk11.yellow(`
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.6.15",
6
+ "version": "0.6.16",
7
7
  "description": "CLI interface for Coherent Design Method",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",