@gadicc/loom 1.17.0 → 1.19.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.
Files changed (70) hide show
  1. package/README.md +120 -43
  2. package/deno.json +3 -0
  3. package/esm/src/cli/mod.d.ts +3 -1
  4. package/esm/src/cli/mod.d.ts.map +1 -1
  5. package/esm/src/cli/mod.js +968 -342
  6. package/esm/src/cli/projectTooling.d.ts +138 -0
  7. package/esm/src/cli/projectTooling.d.ts.map +1 -0
  8. package/esm/src/cli/projectTooling.js +614 -0
  9. package/esm/src/jobs/controller.d.ts +14 -1
  10. package/esm/src/jobs/controller.d.ts.map +1 -1
  11. package/esm/src/jobs/controller.js +54 -3
  12. package/esm/src/jobs/events.d.ts +9 -1
  13. package/esm/src/jobs/events.d.ts.map +1 -1
  14. package/esm/src/jobs/events.js +15 -2
  15. package/esm/src/jobs/mod.d.ts +1 -0
  16. package/esm/src/jobs/mod.d.ts.map +1 -1
  17. package/esm/src/jobs/mod.js +1 -0
  18. package/esm/src/jobs/run.d.ts +20 -1
  19. package/esm/src/jobs/run.d.ts.map +1 -1
  20. package/esm/src/jobs/run.js +29 -4
  21. package/esm/src/jobs/sanitize.d.ts +30 -0
  22. package/esm/src/jobs/sanitize.d.ts.map +1 -0
  23. package/esm/src/jobs/sanitize.js +91 -0
  24. package/esm/src/mail/postal.d.ts.map +1 -1
  25. package/esm/src/mail/postal.js +25 -20
  26. package/esm/src/mail/sender.d.ts +5 -0
  27. package/esm/src/mail/sender.d.ts.map +1 -0
  28. package/esm/src/mail/sender.js +48 -0
  29. package/esm/src/mail/service.d.ts.map +1 -1
  30. package/esm/src/mail/service.js +7 -5
  31. package/esm/src/next/jobs/route.d.ts.map +1 -1
  32. package/esm/src/next/jobs/route.js +1 -1
  33. package/package.json +3 -2
  34. package/script/src/cli/mod.d.ts +3 -1
  35. package/script/src/cli/mod.d.ts.map +1 -1
  36. package/script/src/cli/mod.js +968 -342
  37. package/script/src/cli/projectTooling.d.ts +138 -0
  38. package/script/src/cli/projectTooling.d.ts.map +1 -0
  39. package/script/src/cli/projectTooling.js +634 -0
  40. package/script/src/jobs/controller.d.ts +14 -1
  41. package/script/src/jobs/controller.d.ts.map +1 -1
  42. package/script/src/jobs/controller.js +54 -3
  43. package/script/src/jobs/events.d.ts +9 -1
  44. package/script/src/jobs/events.d.ts.map +1 -1
  45. package/script/src/jobs/events.js +15 -2
  46. package/script/src/jobs/mod.d.ts +1 -0
  47. package/script/src/jobs/mod.d.ts.map +1 -1
  48. package/script/src/jobs/mod.js +1 -0
  49. package/script/src/jobs/run.d.ts +20 -1
  50. package/script/src/jobs/run.d.ts.map +1 -1
  51. package/script/src/jobs/run.js +29 -4
  52. package/script/src/jobs/sanitize.d.ts +30 -0
  53. package/script/src/jobs/sanitize.d.ts.map +1 -0
  54. package/script/src/jobs/sanitize.js +97 -0
  55. package/script/src/mail/postal.d.ts.map +1 -1
  56. package/script/src/mail/postal.js +25 -20
  57. package/script/src/mail/sender.d.ts +5 -0
  58. package/script/src/mail/sender.d.ts.map +1 -0
  59. package/script/src/mail/sender.js +52 -0
  60. package/script/src/mail/service.d.ts.map +1 -1
  61. package/script/src/mail/service.js +7 -5
  62. package/script/src/next/jobs/route.d.ts.map +1 -1
  63. package/script/src/next/jobs/route.js +1 -1
  64. package/skills/loom/SKILL.md +38 -23
  65. package/skills/loom-db/SKILL.md +9 -7
  66. package/skills/loom-db/references/db-stack.md +2 -1
  67. package/skills/loom-jobs/SKILL.md +36 -6
  68. package/skills/loom-lingui/SKILL.md +38 -0
  69. package/skills/loom-lingui/agents/openai.yaml +4 -0
  70. package/skills/loom-mail/SKILL.md +14 -3
@@ -10,6 +10,7 @@ import { DEFAULT_API_KEY_AUDIT_RETENTION } from "../apiKeys/retention.js";
10
10
  import { checkProjectSkills, getProjectSkillStatus, LOOM_EXTERNAL_SKILLS_GITIGNORE_LINE, removeLegacyNextSkillLink, setProjectSkillDisabled, syncExternalProjectSkills, syncInstalledPackageSkills, } from "./projectSkills.js";
11
11
  import { resolveMigrationEnvironment, resolveMigrationEnvironmentFromEnvFile, } from "./migrationEnv.js";
12
12
  import { prepareVercelBuildEnvironment, verifyVercelBuildArtifact, } from "./vercelBuildEnv.js";
13
+ import { detectProjectTooling, ensureTask, ensureTaskFollowup, ensureTaskPrerequisite, findTaskConflicts, formatTaskInvocation, getTaskCommand, mutateDenoLinks, mutateProjectDependencies, readDenoLinks, readProjectPackageMetadata, readTaskStore, taskInvokes, taskRunsBeforeCommand, } from "./projectTooling.js";
13
14
  export const DEFAULT_LOOM_RANGE = "^1.0.0";
14
15
  export const LOOM_DEPENDENCY = "@gadicc/loom";
15
16
  export const LOOM_MANIFEST_SCHEMA = "https://loom.gadicc.local/project-manifest.schema.json";
@@ -103,6 +104,12 @@ const managedSkills = [
103
104
  relativePackagePath: "skills/loom-mail",
104
105
  skillName: "loom-mail",
105
106
  },
107
+ {
108
+ featureKey: "lingui",
109
+ label: "loom Lingui skill",
110
+ relativePackagePath: "skills/loom-lingui",
111
+ skillName: "loom-lingui",
112
+ },
106
113
  ];
107
114
  const featureDefinitions = [
108
115
  {
@@ -125,6 +132,10 @@ const featureDefinitions = [
125
132
  key: "jobs",
126
133
  description: "Shared App Router admin jobs pages, route handlers, direct-run helpers, and job controller wiring.",
127
134
  },
135
+ {
136
+ key: "lingui",
137
+ description: "Lingui catalog source policy, generated-catalog ignores, dependencies, tasks, and build wiring.",
138
+ },
128
139
  {
129
140
  key: "mail",
130
141
  description: "Durable outgoing mail, Postal transport/webhooks, and admin-gated test-mail UI.",
@@ -202,6 +213,30 @@ const PWA_GITIGNORE_LINES = [
202
213
  "/public/workbox-*.js",
203
214
  "/public/workbox-*.js.map",
204
215
  ];
216
+ const LINGUI_DEFAULT_DEPENDENCIES = {
217
+ "@lingui/core": "^6.5.0",
218
+ "@lingui/react": "^6.5.0",
219
+ };
220
+ const LINGUI_DEFAULT_DEV_DEPENDENCIES = {
221
+ "@lingui/cli": "^6.5.0",
222
+ "@lingui/format-po": "^6.5.0",
223
+ "@lingui/swc-plugin": "^6.5.0",
224
+ };
225
+ const LINGUI_LOADER_DEV_DEPENDENCIES = {
226
+ "@lingui/loader": "^6.5.0",
227
+ };
228
+ const LINGUI_CONFIG_CANDIDATES = [
229
+ "lingui.config.ts",
230
+ "lingui.config.js",
231
+ "lingui.config.mts",
232
+ "lingui.config.mjs",
233
+ "lingui.config.cjs",
234
+ ];
235
+ const LINGUI_DEFAULT_TASKS = {
236
+ build: "build",
237
+ compile: "i18n:compile",
238
+ extract: "i18n:extract",
239
+ };
205
240
  const PWA_UPDATE_PROMPT = "A newer version of this web app is available. Reload to update?";
206
241
  const DB_CONNECTION_ENV_NAMES = [
207
242
  "DATABASE_URL",
@@ -329,11 +364,14 @@ async function readManifestFramework(cwd) {
329
364
  if (manifest?.project?.framework) {
330
365
  return manifest.project.framework;
331
366
  }
332
- const packageJsonText = await readTextIfExists(join(cwd, "package.json"));
333
- if (!packageJsonText) {
367
+ let metadata;
368
+ try {
369
+ metadata = await readProjectPackageMetadata(cwd);
370
+ }
371
+ catch {
334
372
  return null;
335
373
  }
336
- return await detectFramework(cwd, parseJson(packageJsonText, "package.json"));
374
+ return await detectFramework(cwd, metadata.packageJson);
337
375
  }
338
376
  async function loadProjectEnv(cwd) {
339
377
  const framework = await readManifestFramework(cwd);
@@ -429,7 +467,8 @@ function dbScriptBypassesEnvRunner(scriptName, scriptCommand) {
429
467
  return false;
430
468
  }
431
469
  return !scriptUsesLoomEnvRunner(scriptCommand) &&
432
- !/\bpnpm\s+drizzle-kit\b/.test(scriptCommand);
470
+ !/\b(?:pnpm|yarn|npx)\s+drizzle-kit\b/.test(scriptCommand) &&
471
+ !/\bdeno\s+run\s+-A\s+npm:drizzle-kit\b/.test(scriptCommand);
433
472
  }
434
473
  function jobsScriptBypassesEnvRunner(scriptName, scriptCommand) {
435
474
  if (!scriptCommand) {
@@ -438,7 +477,7 @@ function jobsScriptBypassesEnvRunner(scriptName, scriptCommand) {
438
477
  return (scriptName === "job" || scriptCommand.includes("jobDirect.ts")) &&
439
478
  !scriptUsesLoomEnvRunner(scriptCommand);
440
479
  }
441
- async function checkEnvRunnerAdoption(cwd, manifest, packageJson) {
480
+ async function checkEnvRunnerAdoption(cwd, manifest) {
442
481
  const issues = [];
443
482
  const suggestions = new Set();
444
483
  const activeDb = manifest.features.db?.status === "active";
@@ -453,14 +492,25 @@ async function checkEnvRunnerAdoption(cwd, manifest, packageJson) {
453
492
  if (directEnvLoaderFiles.length) {
454
493
  suggestions.add("Move env loading into package scripts with `loom env -- <command>` and remove `dotenv`/`@next/env` imports from implementation files.");
455
494
  }
456
- for (const [scriptName, scriptCommand] of Object.entries(packageJson.scripts ?? {})) {
495
+ const tooling = await getProjectTooling(cwd, manifest);
496
+ const taskStore = await readTaskStore(cwd, tooling.tasks);
497
+ for (const [scriptName, definition] of Object.entries(taskStore.definitions)) {
498
+ const scriptCommand = getTaskCommand(definition);
457
499
  if (activeDb && dbScriptBypassesEnvRunner(scriptName, scriptCommand)) {
458
- issues.push(`DB package.json script bypasses the Loom env runner: ${scriptName}`);
459
- suggestions.add("Run `loom add db` to refresh DB package scripts.");
500
+ issues.push(taskStore.config === "package.json"
501
+ ? `DB package.json script bypasses the Loom env runner: ${scriptName}`
502
+ : `DB task in ${taskStore.config} bypasses the Loom env runner: ${scriptName}`);
503
+ suggestions.add(taskStore.config === "package.json"
504
+ ? "Run `loom add db` to refresh DB package scripts."
505
+ : "Run `loom add db` to refresh DB tasks.");
460
506
  }
461
507
  if (activeJobs && jobsScriptBypassesEnvRunner(scriptName, scriptCommand)) {
462
- issues.push(`Jobs package.json script bypasses the Loom env runner: ${scriptName}`);
463
- suggestions.add("Run `loom add jobs` to refresh jobs package scripts.");
508
+ issues.push(taskStore.config === "package.json"
509
+ ? `Jobs package.json script bypasses the Loom env runner: ${scriptName}`
510
+ : `Jobs task in ${taskStore.config} bypasses the Loom env runner: ${scriptName}`);
511
+ suggestions.add(taskStore.config === "package.json"
512
+ ? "Run `loom add jobs` to refresh jobs package scripts."
513
+ : "Run `loom add jobs` to refresh jobs tasks.");
464
514
  }
465
515
  }
466
516
  return {
@@ -725,6 +775,29 @@ function ensurePwaGitignoreText(existingText) {
725
775
  text: nextText,
726
776
  };
727
777
  }
778
+ function normalizeGitignorePattern(pattern) {
779
+ return pattern.trim().replaceAll("\\", "/").replace(/^\.\//, "");
780
+ }
781
+ function linguiGitignoreLineMatches(line, expectedLine) {
782
+ const normalized = normalizeGitignorePattern(line).replace(/^\//, "");
783
+ const expected = normalizeGitignorePattern(expectedLine).replace(/^\//, "");
784
+ return normalized === expected;
785
+ }
786
+ function ensureLinguiGitignoreText(existingText, generatedCatalogs) {
787
+ const normalized = existingText ? normalizeText(existingText) : "";
788
+ const lines = normalized
789
+ .split("\n")
790
+ .filter((line, index, array) => index < array.length - 1 || line !== "");
791
+ const missingLines = generatedCatalogs.filter((expectedLine) => !lines.some((line) => linguiGitignoreLineMatches(line, expectedLine)));
792
+ const nextText = missingLines.length
793
+ ? `${[...lines, ...missingLines].join("\n")}\n`
794
+ : normalized;
795
+ return {
796
+ changed: nextText !== normalized,
797
+ missingLines,
798
+ text: nextText,
799
+ };
800
+ }
728
801
  function loomDevStateGitignoreLineMatches(line) {
729
802
  const normalized = line.trim().replace(/^\/?/, "");
730
803
  return normalized === LOOM_LOCAL_DEV_STATE_GITIGNORE_LINE ||
@@ -758,58 +831,30 @@ export function ensurePackageJsonDependency(packageJson, versionRange = DEFAULT_
758
831
  previous: current,
759
832
  };
760
833
  }
761
- function ensurePackageJsonDependencies(packageJson, field, dependencies) {
762
- const nextPackageJson = structuredClone(packageJson);
763
- nextPackageJson[field] ??= {};
764
- const changedKeys = [];
765
- for (const [dependencyName, versionRange] of Object.entries(dependencies)) {
766
- if (!nextPackageJson[field][dependencyName]) {
767
- nextPackageJson[field][dependencyName] = versionRange;
768
- changedKeys.push(dependencyName);
769
- }
770
- }
771
- return {
772
- changed: changedKeys.length > 0,
773
- changedKeys,
774
- packageJson: nextPackageJson,
775
- };
776
- }
777
- function removePackageJsonDependencies(packageJson, dependencyNames) {
778
- const nextPackageJson = structuredClone(packageJson);
779
- const removedKeys = [];
780
- for (const dependencyName of dependencyNames) {
781
- if (nextPackageJson.dependencies?.[dependencyName]) {
782
- delete nextPackageJson.dependencies[dependencyName];
783
- removedKeys.push(dependencyName);
784
- }
785
- if (nextPackageJson.devDependencies?.[dependencyName]) {
786
- delete nextPackageJson.devDependencies[dependencyName];
787
- removedKeys.push(dependencyName);
788
- }
789
- }
790
- return {
791
- changed: removedKeys.length > 0,
792
- packageJson: nextPackageJson,
793
- removedKeys,
794
- };
834
+ async function getProjectTooling(cwd, manifest) {
835
+ return await detectProjectTooling(cwd, manifest.project?.tooling);
795
836
  }
796
- function ensurePackageJsonScripts(packageJson, scripts) {
797
- const nextPackageJson = structuredClone(packageJson);
798
- nextPackageJson.scripts ??= {};
837
+ async function ensureProjectTasks(cwd, manifest, tasks) {
838
+ const tooling = await getProjectTooling(cwd, manifest);
799
839
  const changedKeys = [];
800
- for (const [scriptName, scriptCommand] of Object.entries(scripts)) {
801
- if (nextPackageJson.scripts[scriptName] !== scriptCommand) {
802
- nextPackageJson.scripts[scriptName] = scriptCommand;
803
- changedKeys.push(scriptName);
804
- }
840
+ for (const [name, definition] of Object.entries(tasks)) {
841
+ const result = await ensureTask(cwd, tooling.tasks, { definition, name });
842
+ if (result.changed)
843
+ changedKeys.push(name);
805
844
  }
845
+ return { changedKeys, config: tooling.tasks.config, tooling };
846
+ }
847
+ async function checkProjectTasks(cwd, manifest, expected) {
848
+ const tooling = await getProjectTooling(cwd, manifest);
849
+ const store = await readTaskStore(cwd, tooling.tasks);
806
850
  return {
807
- changed: changedKeys.length > 0,
808
- changedKeys,
809
- packageJson: nextPackageJson,
851
+ config: tooling.tasks.config,
852
+ mismatches: Object.entries(expected).flatMap(([name, command]) => getTaskCommand(store.definitions[name]) === command ? [] : [name]),
853
+ store,
854
+ tooling,
810
855
  };
811
856
  }
812
- export function buildManifest(cwd, packageJson, framework, existingManifest) {
857
+ export function buildManifest(cwd, packageJson, framework, existingManifest, tooling) {
813
858
  return {
814
859
  $schema: existingManifest?.$schema ?? LOOM_MANIFEST_SCHEMA,
815
860
  version: 1,
@@ -821,6 +866,7 @@ export function buildManifest(cwd, packageJson, framework, existingManifest) {
821
866
  ...existingManifest?.project?.framework,
822
867
  ...framework,
823
868
  },
869
+ tooling: existingManifest?.project?.tooling ?? tooling,
824
870
  },
825
871
  features: existingManifest?.features ?? {},
826
872
  };
@@ -840,33 +886,6 @@ function hasPackageDependency(packageJson, dependencyName) {
840
886
  return Boolean(packageJson.dependencies?.[dependencyName] ||
841
887
  packageJson.devDependencies?.[dependencyName]);
842
888
  }
843
- async function detectPackageManager(cwd, packageJson) {
844
- if (packageJson.packageManager?.startsWith("pnpm@")) {
845
- return "pnpm";
846
- }
847
- if (packageJson.packageManager?.startsWith("yarn@")) {
848
- return "yarn";
849
- }
850
- if (packageJson.packageManager?.startsWith("npm@")) {
851
- return "npm";
852
- }
853
- if (await exists(join(cwd, "pnpm-lock.yaml"))) {
854
- return "pnpm";
855
- }
856
- if (await exists(join(cwd, "yarn.lock"))) {
857
- return "yarn";
858
- }
859
- return "npm";
860
- }
861
- function getRunScriptCommand(packageManager, scriptName) {
862
- if (packageManager === "pnpm") {
863
- return `pnpm ${scriptName}`;
864
- }
865
- if (packageManager === "yarn") {
866
- return `yarn ${scriptName}`;
867
- }
868
- return `npm run ${scriptName}`;
869
- }
870
889
  function scriptRunsSerwistBuild(script) {
871
890
  return Boolean(script && (/\bserwist\s+build\b/.test(script) ||
872
891
  script.includes("@serwist/cli") ||
@@ -881,35 +900,6 @@ function formatTsNumberLiteral(value) {
881
900
  function numberLiteralRegExp(value) {
882
901
  return String(value).split("").map((digit) => `${digit}_?`).join("");
883
902
  }
884
- function ensurePwaPackageJsonScripts(packageJson, packageManager) {
885
- const nextPackageJson = structuredClone(packageJson);
886
- nextPackageJson.scripts ??= {};
887
- const changedKeys = [];
888
- const notes = [];
889
- if (nextPackageJson.scripts["pwa:build"] !== PWA_BUILD_SCRIPT) {
890
- nextPackageJson.scripts["pwa:build"] = PWA_BUILD_SCRIPT;
891
- changedKeys.push("pwa:build");
892
- }
893
- const buildScript = nextPackageJson.scripts.build;
894
- if (!buildScript) {
895
- nextPackageJson.scripts.build = `next build && ${getRunScriptCommand(packageManager, "pwa:build")}`;
896
- changedKeys.push("build");
897
- }
898
- else if (buildScript.includes("next build") &&
899
- !scriptRunsSerwistBuild(buildScript)) {
900
- nextPackageJson.scripts.build = `${buildScript} && ${getRunScriptCommand(packageManager, "pwa:build")}`;
901
- changedKeys.push("build");
902
- }
903
- else if (!scriptRunsSerwistBuild(buildScript)) {
904
- notes.push("PWA build script was added, but the existing build script does not visibly run `next build`; wire `pwa:build` after the app's Next.js build step.");
905
- }
906
- return {
907
- changed: changedKeys.length > 0,
908
- changedKeys,
909
- notes,
910
- packageJson: nextPackageJson,
911
- };
912
- }
913
903
  function getJobsConfig(framework) {
914
904
  const appRoot = framework.srcDir ? "src/app" : "app";
915
905
  const jobsRoot = framework.srcDir ? "src/jobs" : "jobs";
@@ -1152,12 +1142,37 @@ async function mergeAuthConfig(cwd, framework, featureConfig) {
1152
1142
  },
1153
1143
  };
1154
1144
  }
1155
- function getDbExpectedScripts(config) {
1145
+ function dependencyExecutable(tooling, executable) {
1146
+ switch (tooling.manager) {
1147
+ case "deno":
1148
+ return `deno run -A npm:${executable}`;
1149
+ case "npm":
1150
+ return `npx ${executable}`;
1151
+ case "pnpm":
1152
+ return `pnpm ${executable}`;
1153
+ case "yarn":
1154
+ return `yarn ${executable}`;
1155
+ }
1156
+ }
1157
+ function dependencyRefreshCommand(tooling, name, version) {
1158
+ switch (tooling.manager) {
1159
+ case "deno":
1160
+ return "deno install";
1161
+ case "npm":
1162
+ return `npm install --save-exact ${name}@${version}`;
1163
+ case "pnpm":
1164
+ return `pnpm update --no-save ${name}@${version} && pnpm install`;
1165
+ case "yarn":
1166
+ return `yarn add --exact ${name}@${version}`;
1167
+ }
1168
+ }
1169
+ function getDbExpectedScripts(config, tooling) {
1170
+ const drizzleKit = dependencyExecutable(tooling.dependencies, "drizzle-kit");
1156
1171
  return {
1157
1172
  "db:fixtures": "loom db fixtures",
1158
- "db:generate": "pnpm drizzle-kit generate",
1159
- "db:migrate": "pnpm drizzle-kit migrate",
1160
- "db:push": "pnpm drizzle-kit push",
1173
+ "db:generate": `${drizzleKit} generate`,
1174
+ "db:migrate": `${drizzleKit} migrate`,
1175
+ "db:push": `${drizzleKit} push`,
1161
1176
  "drizzle-kit": `NODE_OPTIONS='--import tsx' loom env -- drizzle-kit --config=./${config.modules.drizzleConfig}`,
1162
1177
  "schema:gen": "loom db schema-gen",
1163
1178
  };
@@ -1790,9 +1805,10 @@ For all work in this repo:
1790
1805
  1. Use the \`loom\` skill first.
1791
1806
  2. Read \`loom.json\` before making Loom-related changes.
1792
1807
  3. Treat active Loom features and configured paths as the contract between the app and the shared package.
1793
- 4. If the task touches a specific active Loom feature, also use the matching feature skill such as \`loom-jobs\`.
1794
- 5. Next commands load \`.env*\` themselves; non-Next commands that need env should use project scripts or \`loom env -- <command>\`, not inline env-loader imports.
1795
- 6. Keep project-specific rules outside this managed block; shared Loom policy lives in the \`loom\` skill.
1808
+ 4. Read \`project.tooling\` in \`loom.json\`; do not assume tasks live in \`package.json\` or that pnpm is the runner.
1809
+ 5. If the task touches a specific active Loom feature, also use the matching feature skill such as \`loom-jobs\`.
1810
+ 6. Next commands load \`.env*\` themselves; non-Next commands that need env should use the authoritative project task or \`loom env -- <command>\`, not inline env-loader imports.
1811
+ 7. Keep project-specific rules outside this managed block; shared Loom policy lives in the \`loom\` skill.
1796
1812
  ${LOOM_MANAGED_AGENTS_END}
1797
1813
  `;
1798
1814
  }
@@ -2055,6 +2071,37 @@ async function ensurePnpmProject(cwd, packageJson) {
2055
2071
  }
2056
2072
  throw new Error("loom dev local/published currently supports pnpm projects only.");
2057
2073
  }
2074
+ function usesDenoTooling(tooling) {
2075
+ return tooling.tasks.runner === "deno" ||
2076
+ tooling.dependencies.manager === "deno";
2077
+ }
2078
+ async function getDenoConfigForLinks(cwd, tooling) {
2079
+ for (const config of [
2080
+ tooling.tasks.config,
2081
+ tooling.dependencies.config,
2082
+ "deno.json",
2083
+ "deno.jsonc",
2084
+ ]) {
2085
+ if ((config === "deno.json" || config === "deno.jsonc") &&
2086
+ await exists(join(cwd, config))) {
2087
+ return config;
2088
+ }
2089
+ }
2090
+ throw new Error("Deno local development requires a deno.json or deno.jsonc workspace root.");
2091
+ }
2092
+ async function findLocalLoomDenoLink(cwd, links) {
2093
+ for (const link of links) {
2094
+ const path = resolve(cwd, link);
2095
+ const packageText = await readTextIfExists(join(path, "package.json"));
2096
+ if (!packageText)
2097
+ continue;
2098
+ if (parseJson(packageText, `${link}/package.json`).name ===
2099
+ LOOM_DEPENDENCY) {
2100
+ return { link, path };
2101
+ }
2102
+ }
2103
+ return null;
2104
+ }
2058
2105
  async function resolveLocalLoomPackagePath(cwd, inputPath) {
2059
2106
  const resolvedInput = resolve(cwd, inputPath);
2060
2107
  const candidates = [resolvedInput, join(resolvedInput, "npm")];
@@ -2170,6 +2217,9 @@ async function readPackageVersion(packagePath) {
2170
2217
  }
2171
2218
  return parseJson(packageJsonText, join(packagePath, "package.json")).version;
2172
2219
  }
2220
+ function versionFromDependencySpec(spec) {
2221
+ return spec?.match(/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/)?.[1];
2222
+ }
2173
2223
  async function getGitStdout(commandRunner, cwd, args, env) {
2174
2224
  const result = await commandRunner("git", args, { cwd, env });
2175
2225
  if (result.code !== 0) {
@@ -2236,7 +2286,7 @@ async function writeLocalDevStateIfChanged(cwd, state) {
2236
2286
  await writeFile(gitignorePath, gitignoreUpdate.text, "utf8");
2237
2287
  gitignoreChanged = true;
2238
2288
  }
2239
- return stateChanged || gitignoreChanged;
2289
+ return { gitignoreChanged, stateChanged };
2240
2290
  }
2241
2291
  async function getCurrentLocalDevState(cwd, workspaceText) {
2242
2292
  return getManagedDevState(workspaceText) ?? await readLocalDevState(cwd);
@@ -2352,10 +2402,19 @@ async function resolveLoomCommitPublication(sourceRoot, sourceCommit, commandRun
2352
2402
  return { status: "no-release-tag" };
2353
2403
  }
2354
2404
  export async function syncLocalDevPackage(cwd, options = {}) {
2405
+ const manifest = await readManifestIfExists(cwd);
2406
+ const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
2407
+ const denoMode = usesDenoTooling(tooling);
2355
2408
  const workspacePath = join(cwd, "pnpm-workspace.yaml");
2356
2409
  const workspaceText = await readTextIfExists(workspacePath);
2357
2410
  const overrideSpec = getManagedDevOverrideSpec(workspaceText);
2358
- if (!overrideSpec) {
2411
+ const denoConfig = denoMode
2412
+ ? await getDenoConfigForLinks(cwd, tooling)
2413
+ : null;
2414
+ const denoLink = denoConfig
2415
+ ? await findLocalLoomDenoLink(cwd, await readDenoLinks(cwd, denoConfig))
2416
+ : null;
2417
+ if (!overrideSpec && !denoLink) {
2359
2418
  if (options.requireActive) {
2360
2419
  throw new Error("No managed Loom local-dev override is active. Run `loom dev local /path/to/loom` first.");
2361
2420
  }
@@ -2368,20 +2427,31 @@ export async function syncLocalDevPackage(cwd, options = {}) {
2368
2427
  };
2369
2428
  }
2370
2429
  const { packageJson } = await readProjectPackageJson(cwd);
2371
- await ensurePnpmProject(cwd, packageJson);
2430
+ if (!denoMode)
2431
+ await ensurePnpmProject(cwd, packageJson);
2372
2432
  const commandRunner = options.commandRunner ?? defaultCommandRunner;
2373
2433
  const env = options.env ?? process.env;
2374
- const localPackagePath = fileSpecToPath(cwd, overrideSpec);
2434
+ const localPackagePath = denoLink?.path ??
2435
+ fileSpecToPath(cwd, overrideSpec);
2375
2436
  const sourceRoot = await resolveLocalLoomSourceRoot(localPackagePath);
2437
+ const configuredSpec = packageJson.dependencies?.[LOOM_DEPENDENCY] ??
2438
+ packageJson.devDependencies?.[LOOM_DEPENDENCY];
2439
+ const desiredLocalVersion = await readPackageVersion(join(cwd, "node_modules", LOOM_DEPENDENCY)) ?? versionFromDependencySpec(configuredSpec) ??
2440
+ await readPackageVersion(localPackagePath);
2441
+ const currentLocalVersion = await readPackageVersion(localPackagePath);
2442
+ const buildEnv = desiredLocalVersion && !env.NPM_PACKAGE_VERSION
2443
+ ? { ...env, NPM_PACKAGE_VERSION: desiredLocalVersion }
2444
+ : env;
2376
2445
  const ranCommands = [];
2377
2446
  let buildRan = false;
2378
- if (options.force || await isLocalLoomBuildStale(sourceRoot, localPackagePath)) {
2447
+ if (options.force || denoMode && currentLocalVersion !== desiredLocalVersion ||
2448
+ await isLocalLoomBuildStale(sourceRoot, localPackagePath)) {
2379
2449
  if (!sourceRoot) {
2380
2450
  throw new Error(`Could not find the Loom source checkout for ${localPackagePath}; cannot rebuild the local package.`);
2381
2451
  }
2382
2452
  await runCommandOrThrow(commandRunner, "deno", ["task", "build"], {
2383
2453
  cwd: sourceRoot,
2384
- env,
2454
+ env: buildEnv,
2385
2455
  stdio: "inherit",
2386
2456
  });
2387
2457
  ranCommands.push("deno task build");
@@ -2391,25 +2461,39 @@ export async function syncLocalDevPackage(cwd, options = {}) {
2391
2461
  await isInstalledLocalLoomPackageStale(cwd, localPackagePath);
2392
2462
  let packageRefreshRan = false;
2393
2463
  if (options.force || packageRefreshNeeded) {
2394
- const packageSpec = `${LOOM_DEPENDENCY}@file:${localPackagePath}`;
2395
- await runCommandOrThrow(commandRunner, "pnpm", ["update", "--no-save", packageSpec], { cwd, env, stdio: "inherit" });
2396
- ranCommands.push(`pnpm update --no-save ${packageSpec}`);
2397
- await runCommandOrThrow(commandRunner, "pnpm", ["install"], {
2398
- cwd,
2399
- env,
2400
- stdio: "inherit",
2401
- });
2402
- ranCommands.push("pnpm install");
2464
+ if (denoMode) {
2465
+ await runCommandOrThrow(commandRunner, "deno", ["install"], {
2466
+ cwd,
2467
+ env,
2468
+ stdio: "inherit",
2469
+ });
2470
+ ranCommands.push("deno install");
2471
+ }
2472
+ else {
2473
+ const packageSpec = `${LOOM_DEPENDENCY}@file:${localPackagePath}`;
2474
+ await runCommandOrThrow(commandRunner, "pnpm", ["update", "--no-save", packageSpec], { cwd, env, stdio: "inherit" });
2475
+ ranCommands.push(`pnpm update --no-save ${packageSpec}`);
2476
+ await runCommandOrThrow(commandRunner, "pnpm", ["install"], {
2477
+ cwd,
2478
+ env,
2479
+ stdio: "inherit",
2480
+ });
2481
+ ranCommands.push("pnpm install");
2482
+ }
2403
2483
  packageRefreshRan = true;
2404
2484
  }
2405
2485
  const currentWorkspaceText = await readTextIfExists(workspacePath);
2406
- const currentState = await getCurrentLocalDevState(cwd, currentWorkspaceText);
2486
+ const currentState = denoMode
2487
+ ? await readLocalDevState(cwd)
2488
+ : await getCurrentLocalDevState(cwd, currentWorkspaceText);
2407
2489
  let state = null;
2408
2490
  if (buildRan || packageRefreshRan || !currentState) {
2409
2491
  state = await buildLocalDevState(localPackagePath, sourceRoot, commandRunner, env);
2410
- const stateUpdate = setManagedDevStateText(await readTextIfExists(workspacePath), overrideSpec, state);
2411
- if (stateUpdate.changed) {
2412
- await writeTextOrDeleteIfEmpty(workspacePath, stateUpdate.text);
2492
+ if (!denoMode) {
2493
+ const stateUpdate = setManagedDevStateText(await readTextIfExists(workspacePath), overrideSpec, state);
2494
+ if (stateUpdate.changed) {
2495
+ await writeTextOrDeleteIfEmpty(workspacePath, stateUpdate.text);
2496
+ }
2413
2497
  }
2414
2498
  }
2415
2499
  if (state ?? currentState) {
@@ -2438,16 +2522,43 @@ export async function syncLocalDevPackage(cwd, options = {}) {
2438
2522
  };
2439
2523
  }
2440
2524
  export async function useLocalDevPackage(cwd, inputPath) {
2441
- const packageJsonPath = join(cwd, "package.json");
2442
- const packageJsonText = await readTextIfExists(packageJsonPath);
2443
- if (!packageJsonText) {
2444
- throw new Error(`No package.json found in ${cwd}`);
2525
+ const { packageJson } = await readProjectPackageJson(cwd);
2526
+ const manifest = await readManifestIfExists(cwd);
2527
+ const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
2528
+ const localPackagePath = await resolveLocalLoomPackagePath(cwd, inputPath);
2529
+ const publishedSpec = getPublishedLoomDependencySpec(packageJson);
2530
+ if (usesDenoTooling(tooling)) {
2531
+ if (!await exists(join(localPackagePath, "deno.json"))) {
2532
+ throw new Error(`Local Deno development requires ${localPackagePath}/deno.json. Rebuild the Loom npm output before linking it.`);
2533
+ }
2534
+ const denoConfig = await getDenoConfigForLinks(cwd, tooling);
2535
+ const relativeLocalPackagePath = relative(cwd, localPackagePath)
2536
+ .replaceAll("\\", "/");
2537
+ const update = await mutateDenoLinks(cwd, denoConfig, {
2538
+ add: relativeLocalPackagePath,
2539
+ });
2540
+ const state = {
2541
+ dependency: LOOM_DEPENDENCY,
2542
+ localPackagePath,
2543
+ packageVersion: await readPackageVersion(localPackagePath),
2544
+ syncedAt: new Date().toISOString(),
2545
+ version: 1,
2546
+ };
2547
+ const stateUpdate = await writeLocalDevStateIfChanged(cwd, state);
2548
+ const changedFiles = update.changed ? [denoConfig] : [];
2549
+ if (stateUpdate.gitignoreChanged)
2550
+ changedFiles.push(".gitignore");
2551
+ return {
2552
+ changedFiles,
2553
+ notes: [
2554
+ `Local Loom dev link is active in ${denoConfig}: ${localPackagePath}`,
2555
+ "Run `loom dev sync` to rebuild the local Loom package and refresh Deno's dependency installation when needed.",
2556
+ `Before committing or shipping a published build, run loom dev published, then deno install to restore ${LOOM_DEPENDENCY}@${publishedSpec}.`,
2557
+ ],
2558
+ };
2445
2559
  }
2446
- const packageJson = parseJson(packageJsonText, "package.json");
2447
2560
  await ensurePnpmProject(cwd, packageJson);
2448
- const localPackagePath = await resolveLocalLoomPackagePath(cwd, inputPath);
2449
2561
  const overrideSpec = `file:${localPackagePath}`;
2450
- const publishedSpec = getPublishedLoomDependencySpec(packageJson);
2451
2562
  const workspacePath = join(cwd, "pnpm-workspace.yaml");
2452
2563
  const update = ensurePnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath), overrideSpec);
2453
2564
  if (update.conflict) {
@@ -2468,20 +2579,30 @@ export async function useLocalDevPackage(cwd, inputPath) {
2468
2579
  };
2469
2580
  }
2470
2581
  export async function usePublishedDevPackage(cwd, options = {}) {
2471
- const packageJsonPath = join(cwd, "package.json");
2472
- const packageJsonText = await readTextIfExists(packageJsonPath);
2473
- if (!packageJsonText) {
2474
- throw new Error(`No package.json found in ${cwd}`);
2475
- }
2476
- const packageJson = parseJson(packageJsonText, "package.json");
2477
- await ensurePnpmProject(cwd, packageJson);
2582
+ const { packageJson } = await readProjectPackageJson(cwd);
2583
+ const manifest = await readManifestIfExists(cwd);
2584
+ const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
2585
+ const denoMode = usesDenoTooling(tooling);
2586
+ if (!denoMode)
2587
+ await ensurePnpmProject(cwd, packageJson);
2478
2588
  const commandRunner = options.commandRunner ?? defaultCommandRunner;
2479
2589
  const env = options.env ?? process.env;
2480
2590
  const workspacePath = join(cwd, "pnpm-workspace.yaml");
2481
2591
  const workspaceText = await readTextIfExists(workspacePath);
2482
- const activeOverrideSpec = getManagedDevOverrideSpec(workspaceText);
2483
- const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
2484
- const state = await getCurrentLocalDevState(cwd, workspaceText);
2592
+ const denoConfig = denoMode
2593
+ ? await getDenoConfigForLinks(cwd, tooling)
2594
+ : null;
2595
+ const denoLink = denoConfig
2596
+ ? await findLocalLoomDenoLink(cwd, await readDenoLinks(cwd, denoConfig))
2597
+ : null;
2598
+ const activeOverrideSpec = denoLink?.link ??
2599
+ getManagedDevOverrideSpec(workspaceText);
2600
+ const localLockfileResolution = denoMode
2601
+ ? null
2602
+ : await getProjectLocalLoomLockfileResolution(cwd);
2603
+ const state = denoMode
2604
+ ? await readLocalDevState(cwd)
2605
+ : await getCurrentLocalDevState(cwd, workspaceText);
2485
2606
  const notes = [];
2486
2607
  let publishedSpec = getPublishedLoomDependencySpec(packageJson);
2487
2608
  const needsPublicationProof = Boolean(activeOverrideSpec || localLockfileResolution);
@@ -2504,21 +2625,33 @@ export async function usePublishedDevPackage(cwd, options = {}) {
2504
2625
  else if (needsPublicationProof) {
2505
2626
  notes.push("No recorded Loom sync commit was found; switching back to the existing published dependency without proving whether local Loom changes were required.");
2506
2627
  }
2507
- const dependencyUpdate = ensurePackageJsonDependency(packageJson, publishedSpec);
2508
- if (dependencyUpdate.changed) {
2509
- await writeFile(packageJsonPath, stringifyJson(dependencyUpdate.packageJson), "utf8");
2510
- }
2511
- const update = clearPnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath));
2628
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, {
2629
+ dependencies: { [LOOM_DEPENDENCY]: publishedSpec },
2630
+ replace: true,
2631
+ });
2632
+ const denoUpdate = denoConfig && denoLink
2633
+ ? await mutateDenoLinks(cwd, denoConfig, { remove: denoLink.link })
2634
+ : null;
2635
+ const update = denoMode
2636
+ ? { changed: denoUpdate?.changed ?? false, text: "" }
2637
+ : clearPnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath));
2512
2638
  const changedFiles = [];
2513
2639
  if (dependencyUpdate.changed) {
2514
- changedFiles.push("package.json");
2640
+ changedFiles.push(dependencyUpdate.config);
2515
2641
  }
2516
2642
  if (update.changed) {
2517
- await writeTextOrDeleteIfEmpty(workspacePath, update.text);
2518
- changedFiles.push("pnpm-workspace.yaml");
2643
+ if (denoMode) {
2644
+ changedFiles.push(denoConfig);
2645
+ }
2646
+ else {
2647
+ await writeTextOrDeleteIfEmpty(workspacePath, update.text);
2648
+ changedFiles.push("pnpm-workspace.yaml");
2649
+ }
2519
2650
  }
2520
2651
  if (update.changed || localLockfileResolution) {
2521
- notes.push(`Run \`pnpm update --no-save ${LOOM_DEPENDENCY}@${publishedSpec}\` and then \`pnpm install\` in this project to return node_modules and the lockfile to the published ${LOOM_DEPENDENCY} dependency.`);
2652
+ notes.push(denoMode
2653
+ ? `Run \`deno install\` in this project to return node_modules and deno.lock to published ${LOOM_DEPENDENCY}@${publishedSpec}.`
2654
+ : `Run \`pnpm update --no-save ${LOOM_DEPENDENCY}@${publishedSpec}\` and then \`pnpm install\` in this project to return node_modules and the lockfile to the published ${LOOM_DEPENDENCY} dependency.`);
2522
2655
  }
2523
2656
  if (localLockfileResolution) {
2524
2657
  notes.push(`pnpm-lock.yaml still resolves ${LOOM_DEPENDENCY} to ${localLockfileResolution} until that update is run.`);
@@ -2652,26 +2785,43 @@ async function checkManagedAgentsFile(cwd) {
2652
2785
  };
2653
2786
  }
2654
2787
  async function checkManagedLocalDevOverride(cwd, production = false) {
2788
+ const manifest = await readManifestIfExists(cwd);
2789
+ let denoLink = null;
2790
+ let denoConfig = null;
2791
+ try {
2792
+ const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
2793
+ if (usesDenoTooling(tooling)) {
2794
+ denoConfig = await getDenoConfigForLinks(cwd, tooling);
2795
+ denoLink = await findLocalLoomDenoLink(cwd, await readDenoLinks(cwd, denoConfig));
2796
+ }
2797
+ }
2798
+ catch {
2799
+ // The main project tooling check reports invalid configuration separately.
2800
+ }
2655
2801
  const workspaceText = await readTextIfExists(join(cwd, "pnpm-workspace.yaml"));
2656
2802
  const overrideSpec = getManagedDevOverrideSpec(workspaceText);
2657
- if (!overrideSpec) {
2803
+ if (!overrideSpec && !denoLink) {
2658
2804
  return {
2659
2805
  issues: [],
2660
2806
  suggestions: [],
2661
2807
  warnings: [],
2662
2808
  };
2663
2809
  }
2810
+ const location = denoLink
2811
+ ? `${denoConfig} links: ${denoLink.link}`
2812
+ : `pnpm-workspace.yaml: ${overrideSpec}`;
2813
+ const restore = denoLink
2814
+ ? "Run `loom dev published`, then run `deno install` before committing or shipping a published build."
2815
+ : `Run \`loom dev published\`, then follow its printed \`pnpm update --no-save ${LOOM_DEPENDENCY}@<version>\` command and run \`pnpm install\` before committing or shipping a published build.`;
2664
2816
  return {
2665
2817
  issues: production
2666
2818
  ? [
2667
- `Local Loom dev override is active in pnpm-workspace.yaml: ${overrideSpec}`,
2819
+ `Local Loom dev override is active in ${location}`,
2668
2820
  ]
2669
2821
  : [],
2670
- suggestions: [
2671
- `Run \`loom dev published\`, then follow its printed \`pnpm update --no-save ${LOOM_DEPENDENCY}@<version>\` command and run \`pnpm install\` before committing or shipping a published build.`,
2672
- ],
2822
+ suggestions: [restore],
2673
2823
  warnings: production ? [] : [
2674
- `Local Loom dev override is active in pnpm-workspace.yaml: ${overrideSpec}`,
2824
+ `Local Loom dev override is active in ${location}`,
2675
2825
  ],
2676
2826
  };
2677
2827
  }
@@ -2712,6 +2862,18 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2712
2862
  const warnings = [];
2713
2863
  const dependency = packageJson.dependencies?.[LOOM_DEPENDENCY];
2714
2864
  const production = options.production;
2865
+ const projectMetadata = await readProjectPackageMetadata(cwd);
2866
+ let dependencyTooling = {
2867
+ config: projectMetadata.config,
2868
+ manager: projectMetadata.config === "package.json" ? "pnpm" : "deno",
2869
+ };
2870
+ try {
2871
+ const manifest = await readManifestIfExists(cwd);
2872
+ dependencyTooling = (await detectProjectTooling(cwd, manifest?.project?.tooling)).dependencies;
2873
+ }
2874
+ catch {
2875
+ // The main tooling check owns the validation error; release hints can fall back.
2876
+ }
2715
2877
  const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
2716
2878
  const devState = await readLocalDevState(cwd);
2717
2879
  if (localLockfileResolution) {
@@ -2745,8 +2907,8 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2745
2907
  "package-equivalent"
2746
2908
  ? `package-relevant files match ${LOOM_DEPENDENCY}@${publication.version}`
2747
2909
  : `it is published as ${LOOM_DEPENDENCY}@${publication.version}`;
2748
- addReleaseCheckMessage(issues, warnings, production, `This app was last synced against Loom commit ${shortCommit}; ${publicationDescription}, but package.json is pinned to ${dependency}.`);
2749
- suggestions.add(`Run \`pnpm update --no-save ${LOOM_DEPENDENCY}@${publication.version}\` and then \`pnpm install\`.`);
2910
+ addReleaseCheckMessage(issues, warnings, production, `This app was last synced against Loom commit ${shortCommit}; ${publicationDescription}, but ${dependencyTooling.config} is pinned to ${dependency}.`);
2911
+ suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, LOOM_DEPENDENCY, publication.version)}.`);
2750
2912
  }
2751
2913
  else if (localLockfileResolution) {
2752
2914
  const publicationDescription = publication.reason ===
@@ -2754,7 +2916,7 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2754
2916
  ? `has no package-relevant changes after ${publication.tag}, so ${LOOM_DEPENDENCY}@${publication.version} covers it`
2755
2917
  : `is published as ${LOOM_DEPENDENCY}@${publication.version}`;
2756
2918
  warnings.push(`The synced Loom commit ${shortCommit} ${publicationDescription}; refresh the lockfile away from ${localLockfileResolution}.`);
2757
- suggestions.add(`Run \`pnpm update --no-save ${LOOM_DEPENDENCY}@${publication.version}\` and then \`pnpm install\`.`);
2919
+ suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, LOOM_DEPENDENCY, publication.version)}.`);
2758
2920
  }
2759
2921
  break;
2760
2922
  }
@@ -2779,8 +2941,8 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2779
2941
  else {
2780
2942
  const installedPackage = parseJson(installedPackageText, join("node_modules", LOOM_DEPENDENCY, "package.json"));
2781
2943
  if (installedPackage.version !== dependency) {
2782
- issues.push(`Installed ${LOOM_DEPENDENCY} version ${installedPackage.version} does not match package.json ${dependency}.`);
2783
- suggestions.add(`Run \`pnpm update --no-save ${LOOM_DEPENDENCY}@${dependency}\` and then \`pnpm install\`.`);
2944
+ issues.push(`Installed ${LOOM_DEPENDENCY} version ${installedPackage.version} does not match ${dependencyTooling.config} ${dependency}.`);
2945
+ suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, LOOM_DEPENDENCY, dependency)}.`);
2784
2946
  }
2785
2947
  }
2786
2948
  }
@@ -2854,7 +3016,7 @@ function getGithubWorkflowStepBlocks(text) {
2854
3016
  }
2855
3017
  function workflowInstallsNodeDependencies(stepBlocks) {
2856
3018
  return stepBlocks.some((block) => /uses:\s*actions\/setup-node@/m.test(block) ||
2857
- /\b(?:pnpm\s+(?:install|i)|npm\s+(?:ci|install)|yarn\s+install|bun\s+install)\b/
3019
+ /\b(?:deno\s+install|pnpm\s+(?:install|i)|npm\s+(?:ci|install)|yarn\s+install|bun\s+install)\b/
2858
3020
  .test(block));
2859
3021
  }
2860
3022
  function hasGithubPackagesSetupNodeConfig(stepBlocks) {
@@ -2977,14 +3139,14 @@ function githubWorkflowRunsOnMainPush(text) {
2977
3139
  return !hasBranchFilter && !ignoresMain;
2978
3140
  }
2979
3141
  function workflowStepRunsDbMigrate(block) {
2980
- return /\b(?:pnpm\s+(?:run\s+)?db:migrate|npm\s+run\s+db:migrate|yarn\s+(?:run\s+)?db:migrate|bun\s+run\s+db:migrate)\b/
3142
+ return /\b(?:deno\s+task\s+db:migrate|pnpm\s+(?:run\s+)?db:migrate|npm\s+run\s+db:migrate|yarn\s+(?:run\s+)?db:migrate|bun\s+run\s+db:migrate)\b/
2981
3143
  .test(block) ||
2982
3144
  /\bdrizzle-kit\s+migrate\b/.test(block) ||
2983
3145
  /spawnSync\(\s*["']pnpm["'][\s\S]*["']db:migrate["']/.test(block);
2984
3146
  }
2985
3147
  function workflowStepUsesVercelCommand(block, subcommand) {
2986
3148
  const launcher = String
2987
- .raw `(?:vercel|pnpm\s+(?:dlx|exec)\s+vercel(?:@[^\s]+)?|npx\s+vercel(?:@[^\s]+)?|yarn\s+(?:dlx\s+)?vercel(?:@[^\s]+)?|bunx\s+vercel(?:@[^\s]+)?)`;
3149
+ .raw `(?:vercel|deno\s+run\s+-A\s+npm:vercel(?:@[^\s]+)?|pnpm\s+(?:dlx|exec)\s+vercel(?:@[^\s]+)?|npx\s+vercel(?:@[^\s]+)?|yarn\s+(?:dlx\s+)?vercel(?:@[^\s]+)?|bunx\s+vercel(?:@[^\s]+)?)`;
2988
3150
  const globalFlags = String
2989
3151
  .raw `(?:\s+(?:--[A-Za-z-]+(?:=(?:"[^"]+"|'[^']+'|[^\s]+)|\s+(?:"[^"]+"|'[^']+'|[^\s]+))?|-[A-Za-z](?:\s+(?:"[^"]+"|'[^']+'|[^\s]+))?))*`;
2990
3152
  return new RegExp(String.raw `\b${launcher}${globalFlags}\s+${subcommand}\b`)
@@ -3946,10 +4108,13 @@ function dbScriptsTsconfigTemplate() {
3946
4108
  }
3947
4109
  `;
3948
4110
  }
3949
- function dbPgliteHarnessTemplate(config) {
4111
+ function dbPgliteHarnessTemplate(config, testRunner = "vitest") {
3950
4112
  const schemaImportPath = toRelativeImportPath(config.modules.pgliteHarnessModule, join(config.dirs.schemaDir, "index.ts"));
4113
+ const afterAllImport = testRunner === "deno"
4114
+ ? 'import { afterAll } from "jsr:@std/testing@^1.0.19/bdd";'
4115
+ : 'import { afterAll } from "vitest";';
3951
4116
  return `import { createMemoryPgliteHarness } from "@gadicc/loom/db/testing";
3952
- import { afterAll } from "vitest";
4117
+ ${afterAllImport}
3953
4118
  import * as schema from "${schemaImportPath}";
3954
4119
 
3955
4120
  const harness = await createMemoryPgliteHarness({
@@ -3970,6 +4135,14 @@ afterAll(closeMemoryPglite);
3970
4135
  export const { client, db, tableLoader } = harness;
3971
4136
  `;
3972
4137
  }
4138
+ async function getDbTestRunner(cwd, tooling) {
4139
+ if (tooling.tasks.runner !== "deno")
4140
+ return "vitest";
4141
+ const taskStore = await readTaskStore(cwd, tooling.tasks);
4142
+ return /\bvitest\b/.test(getTaskCommand(taskStore.definitions.test) ?? "")
4143
+ ? "vitest"
4144
+ : "deno";
4145
+ }
3973
4146
  function dbFixturesScriptTemplate(config) {
3974
4147
  const schemaImportPath = toRelativeImportPath(config.modules.fixtureDumpScript, join(config.dirs.schemaDir, "index.ts"));
3975
4148
  const neonImportPath = toRelativeImportPath(config.modules.fixtureDumpScript, config.modules.neonModule);
@@ -4318,6 +4491,11 @@ export function getDefaultMailFromEmail() {
4318
4491
  return requireEnv("POSTAL_FROM_EMAIL");
4319
4492
  }
4320
4493
 
4494
+ /** Reads the optional default sender display name from the app environment. */
4495
+ export function getDefaultMailFromName() {
4496
+ return process.env.POSTAL_FROM_NAME?.trim() || undefined;
4497
+ }
4498
+
4321
4499
  export function getPostalWebhookPublicKeys(): PostalWebhookPublicKey[] {
4322
4500
  const raw = process.env.POSTAL_WEBHOOK_PUBLIC_KEYS?.trim();
4323
4501
  if (!raw) throw new Error("POSTAL_WEBHOOK_PUBLIC_KEYS is not set.");
@@ -4343,6 +4521,7 @@ function mailServiceTemplate(config) {
4343
4521
  import { mailRepository } from "${toAliasImportPath(config.modules.repositoryModule)}";
4344
4522
  import {
4345
4523
  getDefaultMailFromEmail,
4524
+ getDefaultMailFromName,
4346
4525
  mailTransport,
4347
4526
  } from "${toAliasImportPath(config.modules.transportModule)}";
4348
4527
 
@@ -4350,6 +4529,9 @@ export const mailService = createLoomMailService({
4350
4529
  get defaultFromEmail() {
4351
4530
  return getDefaultMailFromEmail();
4352
4531
  },
4532
+ get defaultFromName() {
4533
+ return getDefaultMailFromName();
4534
+ },
4353
4535
  repository: mailRepository,
4354
4536
  transport: mailTransport,
4355
4537
  });
@@ -5008,14 +5190,11 @@ async function materializeManagedSchema(cwd, schema, dbConfig) {
5008
5190
  };
5009
5191
  }
5010
5192
  async function readProjectPackageJson(cwd) {
5011
- const packageJsonPath = join(cwd, "package.json");
5012
- const packageJsonText = await readTextIfExists(packageJsonPath);
5013
- if (!packageJsonText) {
5014
- throw new Error(`No package.json found in ${cwd}`);
5015
- }
5193
+ const metadata = await readProjectPackageMetadata(cwd);
5016
5194
  return {
5017
- packageJson: parseJson(packageJsonText, "package.json"),
5018
- packageJsonPath,
5195
+ packageJson: metadata.packageJson,
5196
+ packageJsonPath: metadata.path,
5197
+ projectConfig: metadata.config,
5019
5198
  };
5020
5199
  }
5021
5200
  async function resolveDbProjectConfig(cwd) {
@@ -5104,7 +5283,8 @@ export async function syncDbSchemas(cwd) {
5104
5283
  changedFiles.push("loom.json");
5105
5284
  }
5106
5285
  if (changedFiles.length) {
5107
- notes.push("No migrations were generated. Review the schema diff, then run `pnpm db:generate` if the schema changed.");
5286
+ const tooling = await getProjectTooling(cwd, manifest);
5287
+ notes.push(`No migrations were generated. Review the schema diff, then run ${formatTaskInvocation(tooling.tasks, "db:generate")} if the schema changed.`);
5108
5288
  }
5109
5289
  return {
5110
5290
  changedFiles: [...new Set(changedFiles)],
@@ -5445,7 +5625,7 @@ export async function setupCloudflareR2(cwd, options = {}) {
5445
5625
  if (options.localProvider === "r2" && !options.localBucket) {
5446
5626
  throw new Error("--local-provider r2 requires an explicit --local-bucket.");
5447
5627
  }
5448
- const { packageJson, packageJsonPath } = await readProjectPackageJson(cwd);
5628
+ const { packageJson } = await readProjectPackageJson(cwd);
5449
5629
  const framework = await detectFramework(cwd, packageJson);
5450
5630
  const manifestPath = join(cwd, "loom.json");
5451
5631
  const manifestText = await readTextIfExists(manifestPath);
@@ -5453,6 +5633,7 @@ export async function setupCloudflareR2(cwd, options = {}) {
5453
5633
  throw new Error("Missing loom.json. Run `loom add files` first.");
5454
5634
  }
5455
5635
  const manifest = parseJson(manifestText, "loom.json");
5636
+ const tooling = await getProjectTooling(cwd, manifest);
5456
5637
  const feature = manifest.features.files;
5457
5638
  if (!feature || feature.status !== "active") {
5458
5639
  throw new Error("The files feature is not active. Run `loom add files` first.");
@@ -5610,11 +5791,10 @@ export async function setupCloudflareR2(cwd, options = {}) {
5610
5791
  throw new Error(`R2 bucket \`${bucket}\` exists, but Loom could not verify its private-access policy: ${privacy.detail}. Rerun after Wrangler can inspect public URL and custom-domain settings.`);
5611
5792
  }
5612
5793
  }
5613
- const dependencyUpdate = ensurePackageJsonDependencies(packageJson, "dependencies", FILES_S3_DEPENDENCIES);
5794
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, { dependencies: FILES_S3_DEPENDENCIES });
5614
5795
  if (dependencyUpdate.changed) {
5615
- await writeFile(packageJsonPath, stringifyJson(dependencyUpdate.packageJson), "utf8");
5616
- changedFiles.push("package.json");
5617
- notes.push(`Added files storage dependency: ${dependencyUpdate.changedKeys.join(", ")}.`);
5796
+ changedFiles.push(dependencyUpdate.config);
5797
+ notes.push(`Added files storage dependency: ${dependencyUpdate.changedKeys.join(", ")} to ${dependencyUpdate.config}.`);
5618
5798
  }
5619
5799
  const storagePath = join(cwd, config.modules.storageModule);
5620
5800
  const storageText = await readTextIfExists(storagePath);
@@ -7067,26 +7247,21 @@ async function applyJobsFeature(cwd, framework, manifest, activate) {
7067
7247
  ? structuredClone(currentFeature)
7068
7248
  : { status: "planned" };
7069
7249
  const config = mergeJobsConfig(framework, feature.config);
7070
- const { packageJsonPath, packageJson } = await readProjectPackageJson(cwd);
7071
- let nextPackageJson = packageJson;
7072
- const dependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "dependencies", JOBS_DEFAULT_DEPENDENCIES);
7073
- nextPackageJson = dependencyUpdate.packageJson;
7074
- const devDependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "devDependencies", JOBS_DEFAULT_DEV_DEPENDENCIES);
7075
- nextPackageJson = devDependencyUpdate.packageJson;
7076
- const scriptsUpdate = ensurePackageJsonScripts(nextPackageJson, getJobsExpectedScripts(config));
7077
- nextPackageJson = scriptsUpdate.packageJson;
7078
- if (dependencyUpdate.changed || devDependencyUpdate.changed ||
7079
- scriptsUpdate.changed) {
7080
- await writeFile(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
7081
- changedFiles.push("package.json");
7082
- }
7083
- if (dependencyUpdate.changedKeys.length ||
7084
- devDependencyUpdate.changedKeys.length) {
7085
- notes.push(`Added jobs package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
7086
- .join(", ")}`);
7250
+ const tooling = await getProjectTooling(cwd, manifest);
7251
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, {
7252
+ dependencies: JOBS_DEFAULT_DEPENDENCIES,
7253
+ devDependencies: JOBS_DEFAULT_DEV_DEPENDENCIES,
7254
+ });
7255
+ const scriptsUpdate = await ensureProjectTasks(cwd, manifest, getJobsExpectedScripts(config));
7256
+ if (dependencyUpdate.changed)
7257
+ changedFiles.push(dependencyUpdate.config);
7258
+ if (scriptsUpdate.changedKeys.length)
7259
+ changedFiles.push(scriptsUpdate.config);
7260
+ if (dependencyUpdate.changedKeys.length) {
7261
+ notes.push(`Added jobs dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
7087
7262
  }
7088
7263
  if (scriptsUpdate.changedKeys.length) {
7089
- notes.push(`Updated jobs package.json scripts: ${scriptsUpdate.changedKeys.join(", ")}`);
7264
+ notes.push(`Updated jobs tasks in ${scriptsUpdate.config}: ${scriptsUpdate.changedKeys.join(", ")}`);
7090
7265
  }
7091
7266
  if (activate && feature.status !== "active") {
7092
7267
  feature.status = "active";
@@ -7181,41 +7356,35 @@ async function applyDbFeature(cwd, framework, manifest, activate) {
7181
7356
  }
7182
7357
  feature.config = config;
7183
7358
  manifest.features.db = feature;
7184
- const { packageJsonPath, packageJson } = await readProjectPackageJson(cwd);
7185
- let nextPackageJson = packageJson;
7186
- let packageJsonChanged = false;
7187
- const dependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "dependencies", DB_DEFAULT_DEPENDENCIES);
7188
- nextPackageJson = dependencyUpdate.packageJson;
7189
- packageJsonChanged ||= dependencyUpdate.changed;
7190
- const devDependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "devDependencies", DB_DEFAULT_DEV_DEPENDENCIES);
7191
- nextPackageJson = devDependencyUpdate.packageJson;
7192
- packageJsonChanged ||= devDependencyUpdate.changed;
7193
- const scriptsUpdate = ensurePackageJsonScripts(nextPackageJson, getDbExpectedScripts(config));
7194
- nextPackageJson = scriptsUpdate.packageJson;
7195
- packageJsonChanged ||= scriptsUpdate.changed;
7196
- const removedDependencyUpdate = removePackageJsonDependencies(nextPackageJson, DB_MOVED_DEPENDENCIES);
7197
- nextPackageJson = removedDependencyUpdate.packageJson;
7198
- packageJsonChanged ||= removedDependencyUpdate.changed;
7199
- if (packageJsonChanged) {
7200
- await writeFile(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
7201
- changedFiles.push("package.json");
7202
- }
7203
- if (dependencyUpdate.changedKeys.length ||
7204
- devDependencyUpdate.changedKeys.length) {
7205
- notes.push(`Added DB package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
7206
- .join(", ")}`);
7359
+ const tooling = await getProjectTooling(cwd, manifest);
7360
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, {
7361
+ dependencies: DB_DEFAULT_DEPENDENCIES,
7362
+ devDependencies: DB_DEFAULT_DEV_DEPENDENCIES,
7363
+ remove: DB_MOVED_DEPENDENCIES,
7364
+ });
7365
+ const scriptsUpdate = await ensureProjectTasks(cwd, manifest, getDbExpectedScripts(config, tooling));
7366
+ const testRunner = await getDbTestRunner(cwd, tooling);
7367
+ if (dependencyUpdate.changed)
7368
+ changedFiles.push(dependencyUpdate.config);
7369
+ if (scriptsUpdate.changedKeys.length)
7370
+ changedFiles.push(scriptsUpdate.config);
7371
+ if (dependencyUpdate.changedKeys.length) {
7372
+ notes.push(`Added DB dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
7207
7373
  }
7208
7374
  if (scriptsUpdate.changedKeys.length) {
7209
- notes.push(`Updated DB package.json scripts: ${scriptsUpdate.changedKeys.join(", ")}`);
7375
+ notes.push(`Updated DB tasks in ${scriptsUpdate.config}: ${scriptsUpdate.changedKeys.join(", ")}`);
7210
7376
  }
7211
- if (removedDependencyUpdate.removedKeys.length) {
7212
- notes.push(`Removed consumer-managed DB generator dependencies now owned by Loom: ${removedDependencyUpdate.removedKeys.join(", ")}`);
7377
+ if (dependencyUpdate.removedKeys.length) {
7378
+ notes.push(`Removed consumer-managed DB generator dependencies now owned by Loom: ${dependencyUpdate.removedKeys.join(", ")}`);
7213
7379
  }
7214
7380
  const managedFiles = [
7215
7381
  [config.modules.neonModule, dbNeonTemplate()],
7216
7382
  [config.modules.neonFullModule, dbNeonFullTemplate()],
7217
7383
  [config.modules.drizzleConfig, dbDrizzleConfigTemplate(config)],
7218
- [config.modules.pgliteHarnessModule, dbPgliteHarnessTemplate(config)],
7384
+ [
7385
+ config.modules.pgliteHarnessModule,
7386
+ dbPgliteHarnessTemplate(config, testRunner),
7387
+ ],
7219
7388
  [config.modules.scriptsTsconfig, dbScriptsTsconfigTemplate()],
7220
7389
  [
7221
7390
  config.modules.refinementsCommonModule,
@@ -7285,7 +7454,8 @@ async function applyFilesFeature(cwd, framework, manifest, activate) {
7285
7454
  changedFiles.push(...materialized.changedFiles);
7286
7455
  notes.push(...materialized.notes);
7287
7456
  config.schema = materialized.schema;
7288
- notes.push("No migration was generated. Review the schema diff, then run `pnpm db:generate` when you are ready to create the app-local migration.");
7457
+ const tooling = await getProjectTooling(cwd, manifest);
7458
+ notes.push(`No migration was generated. Review the schema diff, then run ${formatTaskInvocation(tooling.tasks, "db:generate")} when you are ready to create the app-local migration.`);
7289
7459
  }
7290
7460
  const scaffoldFiles = [
7291
7461
  [
@@ -7357,7 +7527,7 @@ async function applyMailFeature(cwd, framework, manifest, activate) {
7357
7527
  changedFiles.push(...materialized.changedFiles);
7358
7528
  notes.push(...materialized.notes);
7359
7529
  config.schema = materialized.schema;
7360
- notes.push("No migration was generated. Review the mail schema diff, then create and apply the app-local migration deliberately.", "Configure POSTAL_API_KEY, POSTAL_HOST, POSTAL_FROM_EMAIL, and POSTAL_WEBHOOK_PUBLIC_KEYS before sending mail or receiving webhooks.");
7530
+ notes.push("No migration was generated. Review the mail schema diff, then create and apply the app-local migration deliberately.", "Configure POSTAL_API_KEY, POSTAL_HOST, and POSTAL_WEBHOOK_PUBLIC_KEYS before sending mail or receiving webhooks.", "Set POSTAL_FROM_EMAIL=noreply@example.com to a bare default sender address; optionally set POSTAL_FROM_NAME=Example App.");
7361
7531
  }
7362
7532
  const scaffolds = [
7363
7533
  [config.modules.accessModule, mailAccessTemplate(), "admin access policy"],
@@ -7541,12 +7711,246 @@ async function applyAuthFeature(cwd, framework, manifest, activate) {
7541
7711
  }
7542
7712
  return { changedFiles, notes };
7543
7713
  }
7714
+ function linguiCliCommand(tooling) {
7715
+ switch (tooling.dependencies.manager) {
7716
+ case "deno":
7717
+ return "deno run -A npm:@lingui/cli";
7718
+ case "npm":
7719
+ return "npx lingui";
7720
+ case "pnpm":
7721
+ return "pnpm lingui";
7722
+ case "yarn":
7723
+ return "yarn lingui";
7724
+ }
7725
+ }
7726
+ function linguiConfigTemplate(framework) {
7727
+ const sourceRoot = framework.srcDir ? "src/" : "";
7728
+ return `import { formatter } from "@lingui/format-po";
7729
+
7730
+ /** @type {import("@lingui/conf").LinguiConfig} */
7731
+ export default {
7732
+ locales: ["en"],
7733
+ sourceLocale: "en",
7734
+ catalogs: [
7735
+ {
7736
+ path: "<rootDir>/${sourceRoot}locales/{locale}/messages",
7737
+ include: ["<rootDir>/${sourceRoot}**/*.{ts,tsx}"],
7738
+ },
7739
+ ],
7740
+ format: formatter({ lineNumbers: false }),
7741
+ };
7742
+ `;
7743
+ }
7744
+ function generatedLinguiCatalogsFromConfig(configText, framework) {
7745
+ const paths = [...configText.matchAll(/\bpath\s*:\s*["'`]([^"'`]+)["'`]/g)]
7746
+ .map((match) => match[1])
7747
+ .filter((path) => Boolean(path))
7748
+ .map((path) => path
7749
+ .replace(/^<rootDir>\//, "")
7750
+ .replaceAll("{locale}", "*")
7751
+ .replaceAll("{name}", "*")
7752
+ .replaceAll("\\", "/")
7753
+ .replace(/\.(?:js|po)$/, "") + ".js");
7754
+ return [
7755
+ ...new Set(paths.length
7756
+ ? paths
7757
+ : [`${framework.srcDir ? "src/" : ""}locales/*/messages.js`]),
7758
+ ];
7759
+ }
7760
+ async function findLinguiConfigPath(cwd) {
7761
+ return await findFirstExistingRelativePath(cwd, [
7762
+ ...LINGUI_CONFIG_CANDIDATES,
7763
+ ]);
7764
+ }
7765
+ async function findSourceFilesMatching(cwd, pattern, relativeDir = "") {
7766
+ const results = [];
7767
+ let entries;
7768
+ try {
7769
+ entries = await readdir(join(cwd, relativeDir), { withFileTypes: true });
7770
+ }
7771
+ catch (error) {
7772
+ if (isNodeErrorCode(error, "ENOENT"))
7773
+ return results;
7774
+ throw error;
7775
+ }
7776
+ for (const entry of entries) {
7777
+ const relativePath = relativeDir
7778
+ ? join(relativeDir, entry.name)
7779
+ : entry.name;
7780
+ if (entry.isDirectory()) {
7781
+ if (!ENV_LOADER_SCAN_IGNORED_DIRS.has(entry.name)) {
7782
+ results.push(...await findSourceFilesMatching(cwd, pattern, relativePath));
7783
+ }
7784
+ continue;
7785
+ }
7786
+ if (!entry.isFile() || !hasScannedSourceExtension(entry.name))
7787
+ continue;
7788
+ const text = await readTextIfExists(join(cwd, relativePath));
7789
+ pattern.lastIndex = 0;
7790
+ if (text && pattern.test(text)) {
7791
+ results.push(relativePath.replaceAll("\\", "/"));
7792
+ }
7793
+ }
7794
+ return results.sort();
7795
+ }
7796
+ async function detectLinguiCatalogMode(cwd) {
7797
+ const poImports = await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']+\.po["']/);
7798
+ if (poImports.length)
7799
+ return "loader";
7800
+ const nextConfigPath = await findNextConfigPath(cwd);
7801
+ const nextConfigText = nextConfigPath
7802
+ ? await readTextIfExists(join(cwd, nextConfigPath))
7803
+ : null;
7804
+ return nextConfigText?.includes("@lingui/loader") ? "loader" : "precompile";
7805
+ }
7806
+ async function getLinguiConfig(cwd, framework, currentConfig) {
7807
+ const configFile = currentConfig?.configFile ??
7808
+ await findLinguiConfigPath(cwd) ?? "lingui.config.ts";
7809
+ const configText = await readTextIfExists(join(cwd, configFile)) ??
7810
+ linguiConfigTemplate(framework);
7811
+ return {
7812
+ catalogMode: currentConfig?.catalogMode ??
7813
+ await detectLinguiCatalogMode(cwd),
7814
+ configFile,
7815
+ generatedCatalogs: currentConfig?.generatedCatalogs?.length
7816
+ ? [...new Set(currentConfig.generatedCatalogs)]
7817
+ : generatedLinguiCatalogsFromConfig(configText, framework),
7818
+ tasks: {
7819
+ ...LINGUI_DEFAULT_TASKS,
7820
+ ...currentConfig?.tasks,
7821
+ },
7822
+ };
7823
+ }
7824
+ function linguiTaskRuns(command, action) {
7825
+ return Boolean(command?.includes("lingui") &&
7826
+ new RegExp(`(?:^|\\s)${action}(?:\\s|$)`).test(command));
7827
+ }
7828
+ function dependencyMajor(spec) {
7829
+ const match = spec?.match(/(?:^|[^0-9])(\d+)\./);
7830
+ return match ? Number(match[1]) : null;
7831
+ }
7832
+ function linguiPoDeclarationTemplate() {
7833
+ return `declare module "*.po" {
7834
+ import type { Messages } from "@lingui/core";
7835
+
7836
+ export const messages: Messages;
7837
+ }
7838
+ `;
7839
+ }
7840
+ async function applyLinguiFeature(cwd, framework, manifest, activate) {
7841
+ const changedFiles = [];
7842
+ const notes = [];
7843
+ const currentFeature = manifest.features.lingui;
7844
+ const config = await getLinguiConfig(cwd, framework, currentFeature?.config);
7845
+ const feature = currentFeature
7846
+ ? structuredClone(currentFeature)
7847
+ : { status: "planned" };
7848
+ if (activate && feature.status !== "active") {
7849
+ feature.status = "active";
7850
+ feature.activatedOn ??= todayIso();
7851
+ }
7852
+ feature.config = config;
7853
+ manifest.features.lingui = feature;
7854
+ const { packageJson } = await readProjectPackageJson(cwd);
7855
+ const tooling = await getProjectTooling(cwd, manifest);
7856
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, {
7857
+ dependencies: LINGUI_DEFAULT_DEPENDENCIES,
7858
+ devDependencies: {
7859
+ ...LINGUI_DEFAULT_DEV_DEPENDENCIES,
7860
+ ...(config.catalogMode === "loader"
7861
+ ? LINGUI_LOADER_DEV_DEPENDENCIES
7862
+ : {}),
7863
+ },
7864
+ });
7865
+ if (dependencyUpdate.changed)
7866
+ changedFiles.push(dependencyUpdate.config);
7867
+ const configState = await scaffoldTextFile(join(cwd, config.configFile), linguiConfigTemplate(framework));
7868
+ if (configState === "created") {
7869
+ changedFiles.push(config.configFile);
7870
+ notes.push(`Scaffolded ${config.configFile} with an English starter locale; update its locales and catalog include paths for the app.`);
7871
+ }
7872
+ else if (activate && configState === "preserved") {
7873
+ notes.push(`Preserved existing Lingui config: ${config.configFile}`);
7874
+ }
7875
+ const taskChanges = [];
7876
+ const executable = linguiCliCommand(tooling);
7877
+ for (const [name, command] of [
7878
+ [config.tasks.extract, `${executable} extract --clean`],
7879
+ [config.tasks.compile, `${executable} compile`],
7880
+ ]) {
7881
+ const result = await ensureTask(cwd, tooling.tasks, {
7882
+ definition: command,
7883
+ name,
7884
+ });
7885
+ if (result.changed)
7886
+ taskChanges.push(name);
7887
+ }
7888
+ let taskStore = await readTaskStore(cwd, tooling.tasks);
7889
+ if (!getTaskCommand(taskStore.definitions[config.tasks.build])) {
7890
+ const result = await ensureTask(cwd, tooling.tasks, {
7891
+ definition: framework.kind === "nextjs" ? "next build" : "build",
7892
+ name: config.tasks.build,
7893
+ });
7894
+ if (result.changed)
7895
+ taskChanges.push(config.tasks.build);
7896
+ taskStore = await readTaskStore(cwd, tooling.tasks);
7897
+ }
7898
+ const buildCommand = getTaskCommand(taskStore.definitions[config.tasks.build]);
7899
+ if (config.catalogMode === "precompile" && buildCommand &&
7900
+ !taskInvokes(taskStore, config.tasks.build, config.tasks.compile)) {
7901
+ const result = await ensureTaskPrerequisite(cwd, tooling.tasks, config.tasks.build, config.tasks.compile);
7902
+ if (result.changed)
7903
+ taskChanges.push(config.tasks.build);
7904
+ }
7905
+ if (taskChanges.length)
7906
+ changedFiles.push(tooling.tasks.config);
7907
+ const gitignorePath = join(cwd, ".gitignore");
7908
+ const gitignoreUpdate = ensureLinguiGitignoreText(await readTextIfExists(gitignorePath), config.generatedCatalogs);
7909
+ if (gitignoreUpdate.changed) {
7910
+ await writeFile(gitignorePath, gitignoreUpdate.text, "utf8");
7911
+ changedFiles.push(".gitignore");
7912
+ }
7913
+ if (config.catalogMode === "loader") {
7914
+ const poDeclarations = await findSourceFilesMatching(cwd, /declare\s+module\s+["']\*\.po["']/);
7915
+ if (!poDeclarations.length) {
7916
+ const declarationPath = `${framework.srcDir ? "src/" : ""}lingui.d.ts`;
7917
+ if (await writeTextIfChanged(join(cwd, declarationPath), linguiPoDeclarationTemplate())) {
7918
+ changedFiles.push(declarationPath);
7919
+ }
7920
+ }
7921
+ }
7922
+ if (framework.kind === "nextjs") {
7923
+ const nextConfigPath = await findNextConfigPath(cwd);
7924
+ const nextConfigText = nextConfigPath
7925
+ ? await readTextIfExists(join(cwd, nextConfigPath))
7926
+ : null;
7927
+ if (!nextConfigText?.includes("@lingui/swc-plugin")) {
7928
+ notes.push("Add @lingui/swc-plugin to experimental.swcPlugins in the app-owned Next config.");
7929
+ }
7930
+ if (config.catalogMode === "loader" &&
7931
+ !nextConfigText?.includes("@lingui/loader")) {
7932
+ notes.push("Add @lingui/loader .po rules for Turbopack and webpack in the app-owned Next config.");
7933
+ }
7934
+ }
7935
+ if (dependencyUpdate.changedKeys.length) {
7936
+ notes.push(`Added Lingui dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
7937
+ }
7938
+ if (taskChanges.length) {
7939
+ notes.push(`Updated Lingui tasks in ${tooling.tasks.config}: ${[...new Set(taskChanges)].join(", ")}`);
7940
+ }
7941
+ if (packageJson.dependencies?.["@lingui/macro"] ||
7942
+ packageJson.devDependencies?.["@lingui/macro"]) {
7943
+ notes.push("The legacy @lingui/macro package remains app-owned; migrate imports to the v6 macro entrypoints before removing it.");
7944
+ }
7945
+ return { changedFiles, notes };
7946
+ }
7544
7947
  async function applyPwaFeature(cwd, framework, manifest, activate) {
7545
7948
  const changedFiles = [];
7546
7949
  const notes = [];
7547
7950
  const currentFeature = manifest.features.pwa;
7548
7951
  const currentConfig = currentFeature?.config;
7549
- const { packageJsonPath, packageJson } = await readProjectPackageJson(cwd);
7952
+ const { packageJson } = await readProjectPackageJson(cwd);
7953
+ const tooling = await getProjectTooling(cwd, manifest);
7550
7954
  const config = await getPwaConfig(cwd, framework, packageJson, currentConfig, activate);
7551
7955
  const feature = currentFeature
7552
7956
  ? structuredClone(currentFeature)
@@ -7557,31 +7961,48 @@ async function applyPwaFeature(cwd, framework, manifest, activate) {
7557
7961
  }
7558
7962
  feature.config = config;
7559
7963
  manifest.features.pwa = feature;
7560
- let nextPackageJson = packageJson;
7561
- let packageJsonChanged = false;
7562
- const dependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "dependencies", PWA_DEFAULT_DEPENDENCIES);
7563
- nextPackageJson = dependencyUpdate.packageJson;
7564
- packageJsonChanged ||= dependencyUpdate.changed;
7565
- const devDependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "devDependencies", PWA_DEFAULT_DEV_DEPENDENCIES);
7566
- nextPackageJson = devDependencyUpdate.packageJson;
7567
- packageJsonChanged ||= devDependencyUpdate.changed;
7568
- const packageManager = await detectPackageManager(cwd, nextPackageJson);
7569
- const scriptsUpdate = ensurePwaPackageJsonScripts(nextPackageJson, packageManager);
7570
- nextPackageJson = scriptsUpdate.packageJson;
7571
- packageJsonChanged ||= scriptsUpdate.changed;
7572
- if (packageJsonChanged) {
7573
- await writeFile(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
7574
- changedFiles.push("package.json");
7575
- }
7576
- if (dependencyUpdate.changedKeys.length ||
7577
- devDependencyUpdate.changedKeys.length) {
7578
- notes.push(`Added PWA package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
7579
- .join(", ")}`);
7964
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, {
7965
+ dependencies: PWA_DEFAULT_DEPENDENCIES,
7966
+ devDependencies: PWA_DEFAULT_DEV_DEPENDENCIES,
7967
+ });
7968
+ if (dependencyUpdate.changed)
7969
+ changedFiles.push(dependencyUpdate.config);
7970
+ const scriptsChanged = [];
7971
+ const pwaTask = await ensureTask(cwd, tooling.tasks, {
7972
+ definition: PWA_BUILD_SCRIPT,
7973
+ name: "pwa:build",
7974
+ });
7975
+ if (pwaTask.changed)
7976
+ scriptsChanged.push("pwa:build");
7977
+ const taskStore = await readTaskStore(cwd, tooling.tasks);
7978
+ const buildCommand = getTaskCommand(taskStore.definitions.build);
7979
+ if (!buildCommand) {
7980
+ const build = await ensureTask(cwd, tooling.tasks, {
7981
+ definition: `next build && ${formatTaskInvocation(tooling.tasks, "pwa:build")}`,
7982
+ name: "build",
7983
+ });
7984
+ if (build.changed)
7985
+ scriptsChanged.push("build");
7580
7986
  }
7581
- if (scriptsUpdate.changedKeys.length) {
7582
- notes.push(`Updated PWA package.json scripts: ${scriptsUpdate.changedKeys.join(", ")}`);
7987
+ else if (buildCommand.includes("next build") &&
7988
+ !taskInvokes(taskStore, "build", "pwa:build") &&
7989
+ !scriptRunsSerwistBuild(buildCommand)) {
7990
+ const build = await ensureTaskFollowup(cwd, tooling.tasks, "build", "pwa:build");
7991
+ if (build.changed)
7992
+ scriptsChanged.push("build");
7993
+ }
7994
+ else if (!taskInvokes(taskStore, "build", "pwa:build") &&
7995
+ !scriptRunsSerwistBuild(buildCommand)) {
7996
+ notes.push("PWA build task was added, but the existing build task does not visibly run `next build`; wire `pwa:build` after the app's Next.js build step.");
7997
+ }
7998
+ if (scriptsChanged.length)
7999
+ changedFiles.push(tooling.tasks.config);
8000
+ if (dependencyUpdate.changedKeys.length) {
8001
+ notes.push(`Added PWA dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
8002
+ }
8003
+ if (scriptsChanged.length) {
8004
+ notes.push(`Updated PWA tasks in ${tooling.tasks.config}: ${scriptsChanged.join(", ")}`);
7583
8005
  }
7584
- notes.push(...scriptsUpdate.notes);
7585
8006
  const serwistConfigState = await scaffoldTextFile(join(cwd, config.modules.serwistConfig), pwaSerwistConfigTemplate(config));
7586
8007
  if (serwistConfigState === "created") {
7587
8008
  changedFiles.push(config.modules.serwistConfig);
@@ -7635,13 +8056,13 @@ async function checkJobsFeature(cwd, framework, manifest) {
7635
8056
  return { issues, suggestions: [], warnings: [] };
7636
8057
  }
7637
8058
  const config = mergeJobsConfig(framework, feature.config);
7638
- const { packageJson } = await readProjectPackageJson(cwd);
7639
8059
  const expectedScripts = getJobsExpectedScripts(config);
7640
- for (const [scriptName, scriptCommand] of Object.entries(expectedScripts)) {
7641
- if (packageJson.scripts?.[scriptName] !== scriptCommand) {
7642
- issues.push(`Jobs package.json script does not match Loom defaults: ${scriptName}`);
7643
- suggestions.add("Run `loom add jobs`.");
7644
- }
8060
+ const taskCheck = await checkProjectTasks(cwd, manifest, expectedScripts);
8061
+ for (const taskName of taskCheck.mismatches) {
8062
+ issues.push(taskCheck.config === "package.json"
8063
+ ? `Jobs package.json script does not match Loom defaults: ${taskName}`
8064
+ : `Jobs task in ${taskCheck.config} does not match Loom defaults: ${taskName}`);
8065
+ suggestions.add("Run `loom add jobs`.");
7645
8066
  }
7646
8067
  const requiredFiles = [
7647
8068
  JOBS_SCRIPTS_TSCONFIG_PATH,
@@ -7798,7 +8219,9 @@ async function checkDbFeature(cwd, framework, manifest, options) {
7798
8219
  }
7799
8220
  const config = mergeDbConfig(framework, feature.config);
7800
8221
  const { packageJson } = await readProjectPackageJson(cwd);
7801
- const expectedScripts = getDbExpectedScripts(config);
8222
+ const tooling = await getProjectTooling(cwd, manifest);
8223
+ const testRunner = await getDbTestRunner(cwd, tooling);
8224
+ const expectedScripts = getDbExpectedScripts(config, tooling);
7802
8225
  const migrationFlowCheck = await checkDbProductionMigrationFlow(cwd, options.production ?? false);
7803
8226
  issues.push(...migrationFlowCheck.issues);
7804
8227
  warnings.push(...migrationFlowCheck.warnings);
@@ -7806,29 +8229,36 @@ async function checkDbFeature(cwd, framework, manifest, options) {
7806
8229
  suggestions.add(suggestion);
7807
8230
  }
7808
8231
  for (const dependencyName of Object.keys(DB_DEFAULT_DEPENDENCIES)) {
7809
- if (!packageJson.dependencies?.[dependencyName]) {
7810
- issues.push(`DB dependency is missing from package.json dependencies: ${dependencyName}`);
8232
+ if (!hasPackageDependency(packageJson, dependencyName)) {
8233
+ issues.push(tooling.dependencies.config === "package.json"
8234
+ ? `DB dependency is missing from package.json dependencies: ${dependencyName}`
8235
+ : `DB dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
7811
8236
  suggestions.add("Run `loom add db`.");
7812
8237
  }
7813
8238
  }
7814
8239
  for (const dependencyName of Object.keys(DB_DEFAULT_DEV_DEPENDENCIES)) {
7815
- if (!packageJson.devDependencies?.[dependencyName]) {
7816
- issues.push(`DB dependency is missing from package.json devDependencies: ${dependencyName}`);
8240
+ if (!hasPackageDependency(packageJson, dependencyName)) {
8241
+ issues.push(tooling.dependencies.config === "package.json"
8242
+ ? `DB dependency is missing from package.json devDependencies: ${dependencyName}`
8243
+ : `DB development dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
7817
8244
  suggestions.add("Run `loom add db`.");
7818
8245
  }
7819
8246
  }
7820
8247
  for (const dependencyName of DB_MOVED_DEPENDENCIES) {
7821
8248
  if (packageJson.dependencies?.[dependencyName] ||
7822
8249
  packageJson.devDependencies?.[dependencyName]) {
7823
- issues.push(`Consumer package.json still declares a Loom-managed DB generator dependency: ${dependencyName}`);
7824
- suggestions.add("Run `loom add db` to rewrite package.json.");
8250
+ issues.push(tooling.dependencies.config === "package.json"
8251
+ ? `Consumer package.json still declares a Loom-managed DB generator dependency: ${dependencyName}`
8252
+ : `Consumer ${tooling.dependencies.config} still declares a Loom-managed DB generator dependency: ${dependencyName}`);
8253
+ suggestions.add(`Run loom add db to rewrite ${tooling.dependencies.config}.`);
7825
8254
  }
7826
8255
  }
7827
- for (const [scriptName, scriptCommand] of Object.entries(expectedScripts)) {
7828
- if (packageJson.scripts?.[scriptName] !== scriptCommand) {
7829
- issues.push(`DB package.json script does not match Loom defaults: ${scriptName}`);
7830
- suggestions.add("Run `loom add db`.");
7831
- }
8256
+ const taskCheck = await checkProjectTasks(cwd, manifest, expectedScripts);
8257
+ for (const taskName of taskCheck.mismatches) {
8258
+ issues.push(taskCheck.config === "package.json"
8259
+ ? `DB package.json script does not match Loom defaults: ${taskName}`
8260
+ : `DB task in ${taskCheck.config} does not match Loom defaults: ${taskName}`);
8261
+ suggestions.add("Run `loom add db`.");
7832
8262
  }
7833
8263
  const requiredFiles = [
7834
8264
  config.modules.neonModule,
@@ -7864,7 +8294,7 @@ async function checkDbFeature(cwd, framework, manifest, options) {
7864
8294
  ],
7865
8295
  [
7866
8296
  config.modules.pgliteHarnessModule,
7867
- dbPgliteHarnessTemplate(config),
8297
+ dbPgliteHarnessTemplate(config, testRunner),
7868
8298
  "PGlite test harness does not match the Loom-managed wrapper",
7869
8299
  ],
7870
8300
  [
@@ -7955,6 +8385,8 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
7955
8385
  const dbConfig = mergeDbConfig(framework, dbFeature.config);
7956
8386
  const config = getFilesConfig(framework, dbConfig, feature.config);
7957
8387
  const { packageJson } = await readProjectPackageJson(cwd);
8388
+ const tooling = await getProjectTooling(cwd, manifest);
8389
+ const generateCommand = formatTaskInvocation(tooling.tasks, "db:generate");
7958
8390
  const schema = config.schema;
7959
8391
  const latestSchema = getLatestManagedSchemaConfig(schema);
7960
8392
  if (schema.mode !== "managed-local" || schema.blueprint !== "files") {
@@ -7968,7 +8400,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
7968
8400
  }
7969
8401
  else if (schema.version < supportedVersion) {
7970
8402
  warnings.push(`Files schema blueprint is stale: ${schema.version} < ${supportedVersion}.`);
7971
- suggestions.add("Run `loom db schemas sync`, review the schema diff, then run `pnpm db:generate` if the schema changed.");
8403
+ suggestions.add(`Run loom db schemas sync, review the schema diff, then run ${generateCommand} if the schema changed.`);
7972
8404
  }
7973
8405
  const schemaRelativeToDir = relative(dbConfig.dirs.schemaDir, schema.module)
7974
8406
  .replaceAll("\\", "/");
@@ -7983,7 +8415,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
7983
8415
  const schemaText = await readTextIfExists(join(cwd, schema.module));
7984
8416
  if (!schemaText) {
7985
8417
  issues.push(`Files schema file is missing: ${schema.module}`);
7986
- suggestions.add("Run `loom db schemas sync`, review the schema diff, then run `pnpm db:generate` if the schema changed.");
8418
+ suggestions.add(`Run loom db schemas sync, review the schema diff, then run ${generateCommand} if the schema changed.`);
7987
8419
  }
7988
8420
  else {
7989
8421
  const currentHash = hashManagedSchemaText(schemaText);
@@ -8099,8 +8531,8 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
8099
8531
  suggestions.add("Replace the generated files storage stub with an S3 or app-specific storage adapter before production use.");
8100
8532
  }
8101
8533
  if (config.storage.adapter === "s3") {
8102
- if (!packageJson.dependencies?.["@aws-sdk/client-s3"]) {
8103
- issues.push("Files S3/R2 storage requires @aws-sdk/client-s3 in package.json dependencies.");
8534
+ if (!hasPackageDependency(packageJson, "@aws-sdk/client-s3")) {
8535
+ issues.push(`Files S3/R2 storage requires @aws-sdk/client-s3 in ${tooling.dependencies.config}.`);
8104
8536
  suggestions.add("Run `loom files r2 setup` to restore the dependency.");
8105
8537
  }
8106
8538
  for (const envName of FILES_S3_REQUIRED_ENV_NAMES) {
@@ -8584,6 +9016,125 @@ async function findNextConfigPath(cwd) {
8584
9016
  ];
8585
9017
  return await findFirstExistingRelativePath(cwd, candidates);
8586
9018
  }
9019
+ async function checkLinguiFeature(cwd, framework, manifest, options) {
9020
+ const issues = [];
9021
+ const suggestions = new Set();
9022
+ const warnings = [];
9023
+ const feature = manifest.features.lingui;
9024
+ if (!feature || feature.status !== "active") {
9025
+ return { issues, suggestions: [], warnings };
9026
+ }
9027
+ const { packageJson } = await readProjectPackageJson(cwd);
9028
+ const tooling = await getProjectTooling(cwd, manifest);
9029
+ const config = await getLinguiConfig(cwd, framework, feature.config);
9030
+ const requiredDependencies = {
9031
+ ...LINGUI_DEFAULT_DEPENDENCIES,
9032
+ ...LINGUI_DEFAULT_DEV_DEPENDENCIES,
9033
+ ...(config.catalogMode === "loader" ? LINGUI_LOADER_DEV_DEPENDENCIES : {}),
9034
+ };
9035
+ for (const dependencyName of Object.keys(requiredDependencies)) {
9036
+ if (!hasPackageDependency(packageJson, dependencyName)) {
9037
+ issues.push(`Lingui dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
9038
+ suggestions.add("Run `loom add lingui`.");
9039
+ }
9040
+ }
9041
+ if (!await exists(join(cwd, config.configFile))) {
9042
+ issues.push(`Lingui config is missing: ${config.configFile}`);
9043
+ suggestions.add("Run `loom add lingui`.");
9044
+ }
9045
+ const taskStore = await readTaskStore(cwd, tooling.tasks);
9046
+ if (!linguiTaskRuns(getTaskCommand(taskStore.definitions[config.tasks.extract]), "extract")) {
9047
+ issues.push(`Lingui extraction task is missing or invalid in ${tooling.tasks.config}: ${config.tasks.extract}`);
9048
+ suggestions.add("Run `loom add lingui`.");
9049
+ }
9050
+ if (!linguiTaskRuns(getTaskCommand(taskStore.definitions[config.tasks.compile]), "compile")) {
9051
+ issues.push(`Lingui compile task is missing or invalid in ${tooling.tasks.config}: ${config.tasks.compile}`);
9052
+ suggestions.add("Run `loom add lingui`.");
9053
+ }
9054
+ if (config.catalogMode === "precompile") {
9055
+ if (!taskInvokes(taskStore, config.tasks.build, config.tasks.compile)) {
9056
+ issues.push(`Build task does not compile Lingui catalogs in ${tooling.tasks.config}: ${config.tasks.build}`);
9057
+ suggestions.add("Run `loom add lingui`.");
9058
+ }
9059
+ else {
9060
+ const buildCommand = getTaskCommand(taskStore.definitions[config.tasks.build]);
9061
+ if (buildCommand?.includes("next build") &&
9062
+ !taskRunsBeforeCommand(taskStore, config.tasks.build, config.tasks.compile, "next build")) {
9063
+ issues.push(`Lingui catalogs are compiled after Next.js starts building in ${tooling.tasks.config}: ${config.tasks.build}`);
9064
+ suggestions.add(`Run ${config.tasks.compile} before the framework build command.`);
9065
+ }
9066
+ }
9067
+ }
9068
+ const gitignoreUpdate = ensureLinguiGitignoreText(await readTextIfExists(join(cwd, ".gitignore")), config.generatedCatalogs);
9069
+ if (gitignoreUpdate.missingLines.length) {
9070
+ issues.push(`Lingui generated catalogs are missing from .gitignore: ${gitignoreUpdate.missingLines.join(", ")}`);
9071
+ suggestions.add("Run `loom add lingui`.");
9072
+ }
9073
+ const gitResult = await (options.commandRunner ?? defaultCommandRunner)("git", ["ls-files", "--", ...config.generatedCatalogs], { cwd, stdio: "pipe" });
9074
+ const trackedCatalogs = gitResult.code === 0
9075
+ ? gitResult.stdout.trim().split(/\r?\n/).filter(Boolean)
9076
+ : [];
9077
+ if (trackedCatalogs.length) {
9078
+ issues.push(`Lingui generated catalogs are still tracked by git: ${trackedCatalogs.join(", ")}`);
9079
+ suggestions.add("Remove generated catalogs from the git index while keeping the source .po catalogs tracked.");
9080
+ }
9081
+ const nextConfigPath = await findNextConfigPath(cwd);
9082
+ const nextConfigText = nextConfigPath
9083
+ ? await readTextIfExists(join(cwd, nextConfigPath))
9084
+ : null;
9085
+ if (framework.kind === "nextjs") {
9086
+ if (!nextConfigText?.includes("@lingui/swc-plugin")) {
9087
+ issues.push(`Next config is missing @lingui/swc-plugin${nextConfigPath ? `: ${nextConfigPath}` : "."}`);
9088
+ suggestions.add("Add @lingui/swc-plugin to experimental.swcPlugins in the Next config.");
9089
+ }
9090
+ if (config.catalogMode === "loader" &&
9091
+ !nextConfigText?.includes("@lingui/loader")) {
9092
+ issues.push(`Lingui loader mode is not wired in the Next config${nextConfigPath ? `: ${nextConfigPath}` : "."}`);
9093
+ suggestions.add("Add matching .po rules for Turbopack and webpack, or switch the manifest to precompile mode.");
9094
+ }
9095
+ if (nextConfigText && /\breactCompiler\s*:\s*true/.test(nextConfigText)) {
9096
+ warnings.push("Next.js React Compiler and the Lingui SWC plugin are both enabled; keep this combination covered by a production build test when upgrading either tool.");
9097
+ }
9098
+ }
9099
+ const poImports = await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']+\.po["']/);
9100
+ if (config.catalogMode === "precompile" && poImports.length) {
9101
+ issues.push(`Lingui is configured for precompile mode but source files import .po catalogs: ${poImports.join(", ")}`);
9102
+ suggestions.add("Switch loom.json to loader mode or import the generated .js catalogs.");
9103
+ }
9104
+ if (config.catalogMode === "loader" && !poImports.length) {
9105
+ warnings.push("Lingui is configured for loader mode, but no source .po imports were found.");
9106
+ }
9107
+ if (config.catalogMode === "loader") {
9108
+ const poDeclarations = await findSourceFilesMatching(cwd, /declare\s+module\s+["']\*\.po["']/);
9109
+ if (!poDeclarations.length) {
9110
+ issues.push("Lingui loader mode is missing a TypeScript *.po module declaration.");
9111
+ suggestions.add("Run `loom add lingui`.");
9112
+ }
9113
+ }
9114
+ const configImports = (await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']*lingui\.config(?:\.[cm]?[jt]s)?["']/)).filter((relativePath) => relativePath !== config.configFile);
9115
+ if (configImports.length) {
9116
+ warnings.push(`Lingui config is imported by runtime source; keep config evaluation build-time only: ${configImports.join(", ")}`);
9117
+ }
9118
+ const linguiCoreMajor = dependencyMajor(packageJson.dependencies?.["@lingui/core"] ??
9119
+ packageJson.devDependencies?.["@lingui/core"]);
9120
+ const legacyMacroSpec = packageJson.dependencies?.["@lingui/macro"] ??
9121
+ packageJson.devDependencies?.["@lingui/macro"];
9122
+ if (legacyMacroSpec && linguiCoreMajor !== null &&
9123
+ dependencyMajor(legacyMacroSpec) !== linguiCoreMajor) {
9124
+ warnings.push(`Legacy @lingui/macro (${legacyMacroSpec}) does not match @lingui/core's major version; prefer @lingui/react/macro and @lingui/core/macro imports.`);
9125
+ }
9126
+ const linguiFamilyMajors = Object.keys(requiredDependencies).flatMap((dependencyName) => {
9127
+ const spec = packageJson.dependencies?.[dependencyName] ??
9128
+ packageJson.devDependencies?.[dependencyName];
9129
+ const major = dependencyMajor(spec);
9130
+ return major === null ? [] : [`${dependencyName}@${major}`];
9131
+ });
9132
+ if (new Set(linguiFamilyMajors.map((entry) => entry.split("@").at(-1))).size >
9133
+ 1) {
9134
+ warnings.push(`Lingui packages span multiple major versions: ${linguiFamilyMajors.join(", ")}`);
9135
+ }
9136
+ return { issues, suggestions: [...suggestions], warnings };
9137
+ }
8587
9138
  async function checkPwaFeature(cwd, framework, manifest) {
8588
9139
  const issues = [];
8589
9140
  const suggestions = new Set();
@@ -8593,6 +9144,7 @@ async function checkPwaFeature(cwd, framework, manifest) {
8593
9144
  return { issues, suggestions: [], warnings };
8594
9145
  }
8595
9146
  const { packageJson } = await readProjectPackageJson(cwd);
9147
+ const tooling = await getProjectTooling(cwd, manifest);
8596
9148
  const config = await getPwaConfig(cwd, framework, packageJson, feature.config, false);
8597
9149
  const hasMui = hasPackageDependency(packageJson, "@mui/material");
8598
9150
  if (framework.kind !== "nextjs" || framework.router !== "app") {
@@ -8600,23 +9152,25 @@ async function checkPwaFeature(cwd, framework, manifest) {
8600
9152
  suggestions.add("Update loom.json if this project intentionally uses a custom PWA integration.");
8601
9153
  }
8602
9154
  for (const dependencyName of Object.keys(PWA_DEFAULT_DEPENDENCIES)) {
8603
- if (!packageJson.dependencies?.[dependencyName]) {
8604
- issues.push(`PWA dependency is missing from package.json dependencies: ${dependencyName}`);
9155
+ if (!hasPackageDependency(packageJson, dependencyName)) {
9156
+ issues.push(`PWA dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
8605
9157
  suggestions.add("Run `loom add pwa`.");
8606
9158
  }
8607
9159
  }
8608
9160
  for (const dependencyName of Object.keys(PWA_DEFAULT_DEV_DEPENDENCIES)) {
8609
- if (!packageJson.devDependencies?.[dependencyName]) {
8610
- issues.push(`PWA dependency is missing from package.json devDependencies: ${dependencyName}`);
9161
+ if (!hasPackageDependency(packageJson, dependencyName)) {
9162
+ issues.push(`PWA development dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
8611
9163
  suggestions.add("Run `loom add pwa`.");
8612
9164
  }
8613
9165
  }
8614
- if (!scriptRunsSerwistBuild(packageJson.scripts?.["pwa:build"])) {
8615
- issues.push("PWA package.json script does not build Serwist: pwa:build");
9166
+ const taskStore = await readTaskStore(cwd, tooling.tasks);
9167
+ if (!scriptRunsSerwistBuild(getTaskCommand(taskStore.definitions["pwa:build"]))) {
9168
+ issues.push(`PWA task in ${tooling.tasks.config} does not build Serwist: pwa:build`);
8616
9169
  suggestions.add("Run `loom add pwa`.");
8617
9170
  }
8618
- if (!scriptRunsSerwistBuild(packageJson.scripts?.build)) {
8619
- issues.push("PWA package.json build script does not run Serwist after the Next.js build.");
9171
+ if (!scriptRunsSerwistBuild(getTaskCommand(taskStore.definitions.build)) &&
9172
+ !taskInvokes(taskStore, "build", "pwa:build")) {
9173
+ issues.push(`PWA build task in ${tooling.tasks.config} does not run Serwist after the Next.js build.`);
8620
9174
  suggestions.add("Run `loom add pwa`.");
8621
9175
  }
8622
9176
  const gitignoreUpdate = ensurePwaGitignoreText(await readTextIfExists(join(cwd, ".gitignore")));
@@ -8797,6 +9351,10 @@ const featureHooks = {
8797
9351
  apply: applyJobsFeature,
8798
9352
  check: checkJobsFeature,
8799
9353
  },
9354
+ lingui: {
9355
+ apply: applyLinguiFeature,
9356
+ check: checkLinguiFeature,
9357
+ },
8800
9358
  mail: {
8801
9359
  apply: applyMailFeature,
8802
9360
  check: checkMailFeature,
@@ -8824,11 +9382,14 @@ async function ensureActiveFeatureScaffolds(cwd, framework, manifest) {
8824
9382
  export async function initProject(cwd, versionRange) {
8825
9383
  const changedFiles = [];
8826
9384
  const notes = [];
8827
- const packageJsonPath = join(cwd, "package.json");
8828
- const packageJsonText = await readTextIfExists(packageJsonPath);
8829
- if (!packageJsonText) {
8830
- throw new Error(`No package.json found in ${cwd}`);
8831
- }
9385
+ const loomManifestPath = join(cwd, "loom.json");
9386
+ const existingManifestText = await readTextIfExists(loomManifestPath);
9387
+ const existingManifest = existingManifestText
9388
+ ? parseJson(existingManifestText, "loom.json")
9389
+ : null;
9390
+ const tooling = await detectProjectTooling(cwd, existingManifest?.project?.tooling);
9391
+ const initialMetadata = await readProjectPackageMetadata(cwd);
9392
+ const initialPackageJson = initialMetadata.packageJson;
8832
9393
  const npmrcPath = join(cwd, ".npmrc");
8833
9394
  const npmrcUpdate = removeLegacyLoomNpmrcText(await readTextIfExists(npmrcPath));
8834
9395
  if (npmrcUpdate.changed) {
@@ -8836,19 +9397,23 @@ export async function initProject(cwd, versionRange) {
8836
9397
  changedFiles.push(".npmrc");
8837
9398
  notes.push("Removed Loom's obsolete GitHub Packages registry configuration.");
8838
9399
  }
8839
- const packageJson = parseJson(packageJsonText, "package.json");
8840
- const dependencyUpdate = ensurePackageJsonDependency(packageJson, versionRange ?? getPublishedLoomDependencySpec(packageJson));
9400
+ const dependencyUpdate = await mutateProjectDependencies(cwd, tooling.dependencies, {
9401
+ dependencies: {
9402
+ [LOOM_DEPENDENCY]: versionRange ??
9403
+ getPublishedLoomDependencySpec(initialPackageJson),
9404
+ },
9405
+ replace: true,
9406
+ });
8841
9407
  if (dependencyUpdate.changed) {
8842
- await writeFile(packageJsonPath, stringifyJson(dependencyUpdate.packageJson), "utf8");
8843
- changedFiles.push("package.json");
9408
+ changedFiles.push(tooling.dependencies.config);
9409
+ if (tooling.dependencies.config !== "package.json") {
9410
+ notes.push(`Recorded ${LOOM_DEPENDENCY} in ${tooling.dependencies.config} imports and enabled Deno's local node_modules directory when needed.`);
9411
+ }
8844
9412
  }
8845
- const framework = await detectFramework(cwd, dependencyUpdate.packageJson);
8846
- const loomManifestPath = join(cwd, "loom.json");
8847
- const existingManifestText = await readTextIfExists(loomManifestPath);
8848
- const existingManifest = existingManifestText
8849
- ? parseJson(existingManifestText, "loom.json")
8850
- : null;
8851
- const manifest = buildManifest(cwd, dependencyUpdate.packageJson, framework, existingManifest);
9413
+ const packageJson = (await readProjectPackageMetadata(cwd))
9414
+ .packageJson;
9415
+ const framework = await detectFramework(cwd, packageJson);
9416
+ const manifest = buildManifest(cwd, packageJson, framework, existingManifest, tooling);
8852
9417
  const featureInit = await ensureActiveFeatureScaffolds(cwd, framework, manifest);
8853
9418
  changedFiles.push(...featureInit.changedFiles);
8854
9419
  notes.push(...featureInit.notes);
@@ -8859,7 +9424,7 @@ export async function initProject(cwd, versionRange) {
8859
9424
  if (agentsInit.changed) {
8860
9425
  changedFiles.push("AGENTS.md");
8861
9426
  }
8862
- const nextAgentsInit = await ensureNextAgentsFile(cwd, dependencyUpdate.packageJson);
9427
+ const nextAgentsInit = await ensureNextAgentsFile(cwd, packageJson);
8863
9428
  if (nextAgentsInit.changed)
8864
9429
  changedFiles.push("AGENTS.md");
8865
9430
  if (nextAgentsInit.note)
@@ -8883,7 +9448,8 @@ export async function initProject(cwd, versionRange) {
8883
9448
  framework,
8884
9449
  manifest,
8885
9450
  notes,
8886
- packageJson: parseJson(await readFile(packageJsonPath, "utf8"), "package.json"),
9451
+ packageJson: (await readProjectPackageMetadata(cwd))
9452
+ .packageJson,
8887
9453
  };
8888
9454
  }
8889
9455
  export async function addFeature(cwd, featureKey, versionRange) {
@@ -9029,18 +9595,20 @@ export async function checkProject(cwd, env = process.env, options = {}) {
9029
9595
  const issues = [];
9030
9596
  const suggestions = new Set();
9031
9597
  const warnings = [];
9032
- const packageJsonPath = join(cwd, "package.json");
9033
- const packageJsonText = await readTextIfExists(packageJsonPath);
9034
- if (!packageJsonText) {
9598
+ let projectMetadata;
9599
+ try {
9600
+ projectMetadata = await readProjectPackageMetadata(cwd);
9601
+ }
9602
+ catch (error) {
9035
9603
  return {
9036
- issues: [`Missing ${packageJsonPath}`],
9604
+ issues: [error.message],
9037
9605
  suggestions: [
9038
- "Run `loom init` from a project that already has package.json.",
9606
+ "Run `loom init` from a project with package.json, deno.json, or deno.jsonc.",
9039
9607
  ],
9040
9608
  warnings: [],
9041
9609
  };
9042
9610
  }
9043
- const packageJson = parseJson(packageJsonText, "package.json");
9611
+ const packageJson = projectMetadata.packageJson;
9044
9612
  const npmrcText = await readTextIfExists(join(cwd, ".npmrc"));
9045
9613
  if (removeLegacyLoomNpmrcText(npmrcText).changed) {
9046
9614
  warnings.push(".npmrc retains Loom's obsolete GitHub Packages registry configuration.");
@@ -9049,7 +9617,7 @@ export async function checkProject(cwd, env = process.env, options = {}) {
9049
9617
  const framework = await detectFramework(cwd, packageJson);
9050
9618
  const dependency = packageJson.dependencies?.[LOOM_DEPENDENCY];
9051
9619
  if (!dependency) {
9052
- issues.push(`Missing ${LOOM_DEPENDENCY} in package.json dependencies.`);
9620
+ issues.push(`Missing ${LOOM_DEPENDENCY} in ${projectMetadata.config} dependencies/imports.`);
9053
9621
  suggestions.add("Run `loom init`.");
9054
9622
  }
9055
9623
  else if (isLocalPackageSpec(dependency)) {
@@ -9066,6 +9634,26 @@ export async function checkProject(cwd, env = process.env, options = {}) {
9066
9634
  manifest = parseJson(manifestText, "loom.json");
9067
9635
  }
9068
9636
  if (manifest) {
9637
+ let tooling = null;
9638
+ if (!manifest.project?.tooling) {
9639
+ warnings.push("loom.json does not record authoritative project tooling.");
9640
+ suggestions.add("Run `loom init` to adopt the detected project tooling.");
9641
+ }
9642
+ try {
9643
+ tooling = await detectProjectTooling(cwd, manifest.project?.tooling);
9644
+ }
9645
+ catch (error) {
9646
+ issues.push(`Invalid project tooling configuration: ${error.message}`);
9647
+ suggestions.add("Fix the recorded project.tooling config in loom.json.");
9648
+ }
9649
+ if (tooling) {
9650
+ for (const conflict of await findTaskConflicts(cwd, tooling.tasks)) {
9651
+ const deploymentWarning = conflict.name === "build"
9652
+ ? " Deployment may invoke the wrong build task."
9653
+ : "";
9654
+ warnings.push(`Conflicting '${conflict.name}' tasks in ${conflict.authoritativeConfig} (authoritative) and ${conflict.secondaryConfig}.${deploymentWarning}`);
9655
+ }
9656
+ }
9069
9657
  for (const [featureKey, feature] of Object.entries(manifest.features)) {
9070
9658
  if (feature.status !== "active")
9071
9659
  continue;
@@ -9097,7 +9685,7 @@ export async function checkProject(cwd, env = process.env, options = {}) {
9097
9685
  for (const suggestion of agentsCheck.suggestions) {
9098
9686
  suggestions.add(suggestion);
9099
9687
  }
9100
- const envRunnerCheck = await checkEnvRunnerAdoption(cwd, manifest, packageJson);
9688
+ const envRunnerCheck = await checkEnvRunnerAdoption(cwd, manifest);
9101
9689
  for (const issue of envRunnerCheck.issues) {
9102
9690
  issues.push(issue);
9103
9691
  }
@@ -9151,13 +9739,16 @@ export async function checkProjectNetwork(cwd, env = process.env, options = {})
9151
9739
  const suggestions = new Set();
9152
9740
  const warnings = [];
9153
9741
  const steps = [];
9154
- const packageJsonText = await readTextIfExists(join(cwd, "package.json"));
9155
- if (!packageJsonText) {
9742
+ let projectMetadata;
9743
+ try {
9744
+ projectMetadata = await readProjectPackageMetadata(cwd);
9745
+ }
9746
+ catch (error) {
9156
9747
  return {
9157
- issues: [`Missing ${join(cwd, "package.json")}`],
9748
+ issues: [error.message],
9158
9749
  steps,
9159
9750
  suggestions: [
9160
- "Run `loom init` from a project that already has package.json.",
9751
+ "Run `loom init` from a package.json or Deno project.",
9161
9752
  ],
9162
9753
  warnings,
9163
9754
  };
@@ -9171,7 +9762,7 @@ export async function checkProjectNetwork(cwd, env = process.env, options = {})
9171
9762
  warnings,
9172
9763
  };
9173
9764
  }
9174
- const packageJson = parseJson(packageJsonText, "package.json");
9765
+ const packageJson = projectMetadata.packageJson;
9175
9766
  const framework = await detectFramework(cwd, packageJson);
9176
9767
  const manifest = parseJson(manifestText, "loom.json");
9177
9768
  const context = {
@@ -9500,13 +10091,15 @@ function formatSkillLinkState(state) {
9500
10091
  }
9501
10092
  }
9502
10093
  async function runStatus(cwd, io) {
9503
- const packageJsonPath = join(cwd, "package.json");
9504
- const packageJsonText = await readTextIfExists(packageJsonPath);
9505
- if (!packageJsonText) {
9506
- io.err(`No package.json found in ${cwd}.`);
10094
+ let projectMetadata;
10095
+ try {
10096
+ projectMetadata = await readProjectPackageMetadata(cwd);
10097
+ }
10098
+ catch (error) {
10099
+ io.err(error.message);
9507
10100
  return 1;
9508
10101
  }
9509
- const packageJson = parseJson(packageJsonText, "package.json");
10102
+ const packageJson = projectMetadata.packageJson;
9510
10103
  const manifestText = await readTextIfExists(join(cwd, "loom.json"));
9511
10104
  const manifest = manifestText
9512
10105
  ? parseJson(manifestText, "loom.json")
@@ -9521,6 +10114,19 @@ async function runStatus(cwd, io) {
9521
10114
  : null;
9522
10115
  const workspaceText = await readTextIfExists(join(cwd, "pnpm-workspace.yaml"));
9523
10116
  const overrideSpec = getManagedDevOverrideSpec(workspaceText);
10117
+ let denoOverride = null;
10118
+ try {
10119
+ const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
10120
+ if (usesDenoTooling(tooling)) {
10121
+ const config = await getDenoConfigForLinks(cwd, tooling);
10122
+ const link = await findLocalLoomDenoLink(cwd, await readDenoLinks(cwd, config));
10123
+ if (link)
10124
+ denoOverride = { config, link: link.link };
10125
+ }
10126
+ }
10127
+ catch {
10128
+ // Status reports stored project data even when live detection fails.
10129
+ }
9524
10130
  const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
9525
10131
  const devState = getManagedDevState(workspaceText) ??
9526
10132
  await readLocalDevState(cwd);
@@ -9529,14 +10135,22 @@ async function runStatus(cwd, io) {
9529
10135
  io.out(`Loom status for ${projectName}`);
9530
10136
  io.out("");
9531
10137
  io.out("Package:");
9532
- io.out(` package.json: ${dependencySpec ? `${LOOM_DEPENDENCY} ${dependencySpec}` : "not declared"}`);
10138
+ io.out(` ${projectMetadata.config}: ${dependencySpec ? `${LOOM_DEPENDENCY} ${dependencySpec}` : "not declared"}`);
9533
10139
  io.out(` installed: ${installedPackage?.version ?? "not installed"}`);
9534
- io.out(` local dev override: ${overrideSpec ? `active (${overrideSpec})` : "none"}`);
10140
+ io.out(` local dev override: ${denoOverride
10141
+ ? `active (${denoOverride.config} links ${denoOverride.link})`
10142
+ : overrideSpec
10143
+ ? `active (${overrideSpec})`
10144
+ : "none"}`);
9535
10145
  io.out(` lockfile local resolution: ${localLockfileResolution ?? "none"}`);
9536
10146
  io.out("");
9537
10147
  io.out("Project:");
9538
10148
  io.out(` loom.json: ${manifest ? `version ${manifest.version}` : "missing"}`);
9539
10149
  io.out(` framework: ${formatFrameworkInfo(framework)}`);
10150
+ if (manifest?.project?.tooling) {
10151
+ io.out(` tasks: ${manifest.project.tooling.tasks.config} via ${manifest.project.tooling.tasks.runner}`);
10152
+ io.out(` dependencies: ${manifest.project.tooling.dependencies.config} via ${manifest.project.tooling.dependencies.manager}`);
10153
+ }
9540
10154
  io.out("");
9541
10155
  io.out("Features:");
9542
10156
  if (!manifest) {
@@ -9625,7 +10239,7 @@ function printHelp({ out }) {
9625
10239
  out("loom <command>");
9626
10240
  out("");
9627
10241
  out("Commands:");
9628
- out(" init Set up package.json, loom.json, managed AGENTS.md guidance, first-party links, and npm package skills.");
10242
+ out(" init Set up package/Deno config, loom.json, managed AGENTS.md guidance, first-party links, and package skills.");
9629
10243
  out(" add <feature> Activate a shared feature. Run `loom add` to list available features.");
9630
10244
  out(" files id-generation uuid-v4|uuid-v7 Select the managed Files schema ID default.");
9631
10245
  out(" files r2 setup Create/reuse private Cloudflare R2 buckets, configure Vercel Production/Preview, and configure local MinIO by default.");
@@ -9647,8 +10261,8 @@ function printHelp({ out }) {
9647
10261
  out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
9648
10262
  out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
9649
10263
  out(" db release verify-build-env <output> <manifest> Reject build-only placeholders in a deployable Vercel artifact.");
9650
- out(" dev local Enable local Loom development using a managed file: override in pnpm-workspace.yaml.");
9651
- out(" dev sync Rebuild the local Loom package and refresh this project's pnpm install when the managed local-dev override is active.");
10264
+ out(" dev local Enable local Loom development using a managed pnpm override or Deno link.");
10265
+ out(" dev sync Rebuild local Loom and refresh this project's pnpm or Deno install when linked.");
9652
10266
  out(" dev published Remove the managed local-dev override and return to the published dependency.");
9653
10267
  out("");
9654
10268
  out("Options:");
@@ -9887,12 +10501,15 @@ async function runSkills(cwd, command, args, io, options) {
9887
10501
  printSkillsHelp(io);
9888
10502
  return 0;
9889
10503
  }
9890
- const packageJsonText = await readTextIfExists(join(cwd, "package.json"));
9891
- if (!packageJsonText) {
9892
- io.err(`No package.json found in ${cwd}.`);
10504
+ let projectMetadata;
10505
+ try {
10506
+ projectMetadata = await readProjectPackageMetadata(cwd);
10507
+ }
10508
+ catch (error) {
10509
+ io.err(error.message);
9893
10510
  return 1;
9894
10511
  }
9895
- const packageJson = parseJson(packageJsonText, "package.json");
10512
+ const packageJson = projectMetadata.packageJson;
9896
10513
  const manifestText = await readTextIfExists(join(cwd, "loom.json"));
9897
10514
  const manifest = manifestText
9898
10515
  ? parseJson(manifestText, "loom.json")
@@ -10060,7 +10677,16 @@ async function runDbSchemaGen(cwd, forwardedArgs, io) {
10060
10677
  if (!isNodeErrorCode(error, "MODULE_NOT_FOUND")) {
10061
10678
  throw error;
10062
10679
  }
10063
- io.out("Biome is not installed; generated Valibot files were left unformatted.");
10680
+ const manifest = await readManifestIfExists(cwd);
10681
+ const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
10682
+ if (usesDenoTooling(tooling)) {
10683
+ const formatExitCode = await runInheritedChild("deno", ["fmt", config.dirs.valibotGeneratedDir], cwd);
10684
+ if (formatExitCode !== 0)
10685
+ return formatExitCode;
10686
+ }
10687
+ else {
10688
+ io.out("Biome is not installed; generated Valibot files were left unformatted.");
10689
+ }
10064
10690
  }
10065
10691
  if (await syncValibotBarrel(cwd, config)) {
10066
10692
  io.out(`Updated ${config.modules.valibotBarrelModule}.`);
@@ -10363,7 +10989,7 @@ async function runDev(cwd, mode, pathInput, io, options = {}) {
10363
10989
  io.out(`Updated ${result.changedFiles.join(", ")}.`);
10364
10990
  }
10365
10991
  else if (result.notes.length) {
10366
- io.out("Project package.json uses a published @gadicc/loom dependency, but follow-up is still needed.");
10992
+ io.out("Project config uses a published @gadicc/loom dependency, but follow-up is still needed.");
10367
10993
  }
10368
10994
  else {
10369
10995
  io.out("Project already uses the published @gadicc/loom dependency.");