@decantr/cli 1.7.29 → 1.9.0

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.
@@ -205,15 +205,22 @@ var YELLOW = "\x1B[33m";
205
205
  var CYAN = "\x1B[36m";
206
206
  var RESET = "\x1B[0m";
207
207
  var DIM = "\x1B[2m";
208
- async function cmdHeal(projectRoot = process.cwd(), options = {}) {
208
+ function collectCheckIssues(projectRoot = process.cwd(), options = {}) {
209
209
  const essencePath = join2(projectRoot, "decantr.essence.json");
210
210
  if (!existsSync2(essencePath)) {
211
- console.error("No decantr.essence.json found. Run `decantr init` first.");
212
- process.exitCode = 1;
213
- return;
211
+ return {
212
+ essence: null,
213
+ issues: [
214
+ {
215
+ type: "error",
216
+ rule: "essence-missing",
217
+ message: "No decantr.essence.json found. Run `decantr init` first."
218
+ }
219
+ ],
220
+ missingEssence: true
221
+ };
214
222
  }
215
223
  const essence = JSON.parse(readFileSync2(essencePath, "utf-8"));
216
- console.log("Scanning for issues...\n");
217
224
  const issues = [];
218
225
  const validation = validateEssence(essence);
219
226
  if (!validation.valid) {
@@ -266,6 +273,18 @@ async function cmdHeal(projectRoot = process.cwd(), options = {}) {
266
273
  });
267
274
  }
268
275
  }
276
+ return { essence, issues, missingEssence: false };
277
+ }
278
+ async function cmdHeal(projectRoot = process.cwd(), options = {}) {
279
+ const result = collectCheckIssues(projectRoot, options);
280
+ console.log("Scanning for issues...\n");
281
+ if (result.missingEssence) {
282
+ console.error(result.issues[0]?.message ?? "No decantr.essence.json found.");
283
+ process.exitCode = 1;
284
+ return;
285
+ }
286
+ const issues = result.issues;
287
+ const essence = result.essence ?? {};
269
288
  if (issues.length === 0) {
270
289
  console.log(`${GREEN}No issues found. Project is healthy.${RESET}`);
271
290
  await maybeSendTelemetry(projectRoot, essence, issues, options);
@@ -302,6 +321,8 @@ ${CYAN}Telemetry enabled.${RESET} Anonymous guard metrics will be sent on future
302
321
  sendGuardMetrics(metrics);
303
322
  }
304
323
  }
324
+
305
325
  export {
326
+ collectCheckIssues,
306
327
  cmdHeal
307
328
  };
@@ -3756,7 +3756,16 @@ Start implementation from the shell layouts and shared route structure before fi
3756
3756
  }
3757
3757
  briefLines.push(`- **Guard mode:** ${params.guardMode}`);
3758
3758
  briefLines.push("");
3759
- const escDecCell = (s) => s.replace(/\|/g, "\\|");
3759
+ const escDecCell = (s) => {
3760
+ let escaped = "";
3761
+ for (const char of s) {
3762
+ if (char === "\\") escaped += "\\\\";
3763
+ else if (char === "|") escaped += "\\|";
3764
+ else if (char === "\n" || char === "\r") escaped += "<br>";
3765
+ else escaped += char;
3766
+ }
3767
+ return escaped;
3768
+ };
3760
3769
  if (params.decoratorDefinitions && Object.keys(params.decoratorDefinitions).length > 0) {
3761
3770
  briefLines.push("### Decorator Quick Reference");
3762
3771
  briefLines.push(