@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
@@ -80,6 +80,7 @@ const retention_js_1 = require("../apiKeys/retention.js");
80
80
  const projectSkills_js_1 = require("./projectSkills.js");
81
81
  const migrationEnv_js_1 = require("./migrationEnv.js");
82
82
  const vercelBuildEnv_js_1 = require("./vercelBuildEnv.js");
83
+ const projectTooling_js_1 = require("./projectTooling.js");
83
84
  exports.DEFAULT_LOOM_RANGE = "^1.0.0";
84
85
  exports.LOOM_DEPENDENCY = "@gadicc/loom";
85
86
  exports.LOOM_MANIFEST_SCHEMA = "https://loom.gadicc.local/project-manifest.schema.json";
@@ -173,6 +174,12 @@ const managedSkills = [
173
174
  relativePackagePath: "skills/loom-mail",
174
175
  skillName: "loom-mail",
175
176
  },
177
+ {
178
+ featureKey: "lingui",
179
+ label: "loom Lingui skill",
180
+ relativePackagePath: "skills/loom-lingui",
181
+ skillName: "loom-lingui",
182
+ },
176
183
  ];
177
184
  const featureDefinitions = [
178
185
  {
@@ -195,6 +202,10 @@ const featureDefinitions = [
195
202
  key: "jobs",
196
203
  description: "Shared App Router admin jobs pages, route handlers, direct-run helpers, and job controller wiring.",
197
204
  },
205
+ {
206
+ key: "lingui",
207
+ description: "Lingui catalog source policy, generated-catalog ignores, dependencies, tasks, and build wiring.",
208
+ },
198
209
  {
199
210
  key: "mail",
200
211
  description: "Durable outgoing mail, Postal transport/webhooks, and admin-gated test-mail UI.",
@@ -272,6 +283,30 @@ const PWA_GITIGNORE_LINES = [
272
283
  "/public/workbox-*.js",
273
284
  "/public/workbox-*.js.map",
274
285
  ];
286
+ const LINGUI_DEFAULT_DEPENDENCIES = {
287
+ "@lingui/core": "^6.5.0",
288
+ "@lingui/react": "^6.5.0",
289
+ };
290
+ const LINGUI_DEFAULT_DEV_DEPENDENCIES = {
291
+ "@lingui/cli": "^6.5.0",
292
+ "@lingui/format-po": "^6.5.0",
293
+ "@lingui/swc-plugin": "^6.5.0",
294
+ };
295
+ const LINGUI_LOADER_DEV_DEPENDENCIES = {
296
+ "@lingui/loader": "^6.5.0",
297
+ };
298
+ const LINGUI_CONFIG_CANDIDATES = [
299
+ "lingui.config.ts",
300
+ "lingui.config.js",
301
+ "lingui.config.mts",
302
+ "lingui.config.mjs",
303
+ "lingui.config.cjs",
304
+ ];
305
+ const LINGUI_DEFAULT_TASKS = {
306
+ build: "build",
307
+ compile: "i18n:compile",
308
+ extract: "i18n:extract",
309
+ };
275
310
  const PWA_UPDATE_PROMPT = "A newer version of this web app is available. Reload to update?";
276
311
  const DB_CONNECTION_ENV_NAMES = [
277
312
  "DATABASE_URL",
@@ -399,11 +434,14 @@ async function readManifestFramework(cwd) {
399
434
  if (manifest?.project?.framework) {
400
435
  return manifest.project.framework;
401
436
  }
402
- const packageJsonText = await readTextIfExists((0, node_path_1.join)(cwd, "package.json"));
403
- if (!packageJsonText) {
437
+ let metadata;
438
+ try {
439
+ metadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
440
+ }
441
+ catch {
404
442
  return null;
405
443
  }
406
- return await detectFramework(cwd, parseJson(packageJsonText, "package.json"));
444
+ return await detectFramework(cwd, metadata.packageJson);
407
445
  }
408
446
  async function loadProjectEnv(cwd) {
409
447
  const framework = await readManifestFramework(cwd);
@@ -499,7 +537,8 @@ function dbScriptBypassesEnvRunner(scriptName, scriptCommand) {
499
537
  return false;
500
538
  }
501
539
  return !scriptUsesLoomEnvRunner(scriptCommand) &&
502
- !/\bpnpm\s+drizzle-kit\b/.test(scriptCommand);
540
+ !/\b(?:pnpm|yarn|npx)\s+drizzle-kit\b/.test(scriptCommand) &&
541
+ !/\bdeno\s+run\s+-A\s+npm:drizzle-kit\b/.test(scriptCommand);
503
542
  }
504
543
  function jobsScriptBypassesEnvRunner(scriptName, scriptCommand) {
505
544
  if (!scriptCommand) {
@@ -508,7 +547,7 @@ function jobsScriptBypassesEnvRunner(scriptName, scriptCommand) {
508
547
  return (scriptName === "job" || scriptCommand.includes("jobDirect.ts")) &&
509
548
  !scriptUsesLoomEnvRunner(scriptCommand);
510
549
  }
511
- async function checkEnvRunnerAdoption(cwd, manifest, packageJson) {
550
+ async function checkEnvRunnerAdoption(cwd, manifest) {
512
551
  const issues = [];
513
552
  const suggestions = new Set();
514
553
  const activeDb = manifest.features.db?.status === "active";
@@ -523,14 +562,25 @@ async function checkEnvRunnerAdoption(cwd, manifest, packageJson) {
523
562
  if (directEnvLoaderFiles.length) {
524
563
  suggestions.add("Move env loading into package scripts with `loom env -- <command>` and remove `dotenv`/`@next/env` imports from implementation files.");
525
564
  }
526
- for (const [scriptName, scriptCommand] of Object.entries(packageJson.scripts ?? {})) {
565
+ const tooling = await getProjectTooling(cwd, manifest);
566
+ const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
567
+ for (const [scriptName, definition] of Object.entries(taskStore.definitions)) {
568
+ const scriptCommand = (0, projectTooling_js_1.getTaskCommand)(definition);
527
569
  if (activeDb && dbScriptBypassesEnvRunner(scriptName, scriptCommand)) {
528
- issues.push(`DB package.json script bypasses the Loom env runner: ${scriptName}`);
529
- suggestions.add("Run `loom add db` to refresh DB package scripts.");
570
+ issues.push(taskStore.config === "package.json"
571
+ ? `DB package.json script bypasses the Loom env runner: ${scriptName}`
572
+ : `DB task in ${taskStore.config} bypasses the Loom env runner: ${scriptName}`);
573
+ suggestions.add(taskStore.config === "package.json"
574
+ ? "Run `loom add db` to refresh DB package scripts."
575
+ : "Run `loom add db` to refresh DB tasks.");
530
576
  }
531
577
  if (activeJobs && jobsScriptBypassesEnvRunner(scriptName, scriptCommand)) {
532
- issues.push(`Jobs package.json script bypasses the Loom env runner: ${scriptName}`);
533
- suggestions.add("Run `loom add jobs` to refresh jobs package scripts.");
578
+ issues.push(taskStore.config === "package.json"
579
+ ? `Jobs package.json script bypasses the Loom env runner: ${scriptName}`
580
+ : `Jobs task in ${taskStore.config} bypasses the Loom env runner: ${scriptName}`);
581
+ suggestions.add(taskStore.config === "package.json"
582
+ ? "Run `loom add jobs` to refresh jobs package scripts."
583
+ : "Run `loom add jobs` to refresh jobs tasks.");
534
584
  }
535
585
  }
536
586
  return {
@@ -795,6 +845,29 @@ function ensurePwaGitignoreText(existingText) {
795
845
  text: nextText,
796
846
  };
797
847
  }
848
+ function normalizeGitignorePattern(pattern) {
849
+ return pattern.trim().replaceAll("\\", "/").replace(/^\.\//, "");
850
+ }
851
+ function linguiGitignoreLineMatches(line, expectedLine) {
852
+ const normalized = normalizeGitignorePattern(line).replace(/^\//, "");
853
+ const expected = normalizeGitignorePattern(expectedLine).replace(/^\//, "");
854
+ return normalized === expected;
855
+ }
856
+ function ensureLinguiGitignoreText(existingText, generatedCatalogs) {
857
+ const normalized = existingText ? normalizeText(existingText) : "";
858
+ const lines = normalized
859
+ .split("\n")
860
+ .filter((line, index, array) => index < array.length - 1 || line !== "");
861
+ const missingLines = generatedCatalogs.filter((expectedLine) => !lines.some((line) => linguiGitignoreLineMatches(line, expectedLine)));
862
+ const nextText = missingLines.length
863
+ ? `${[...lines, ...missingLines].join("\n")}\n`
864
+ : normalized;
865
+ return {
866
+ changed: nextText !== normalized,
867
+ missingLines,
868
+ text: nextText,
869
+ };
870
+ }
798
871
  function loomDevStateGitignoreLineMatches(line) {
799
872
  const normalized = line.trim().replace(/^\/?/, "");
800
873
  return normalized === exports.LOOM_LOCAL_DEV_STATE_GITIGNORE_LINE ||
@@ -828,58 +901,30 @@ function ensurePackageJsonDependency(packageJson, versionRange = exports.DEFAULT
828
901
  previous: current,
829
902
  };
830
903
  }
831
- function ensurePackageJsonDependencies(packageJson, field, dependencies) {
832
- const nextPackageJson = structuredClone(packageJson);
833
- nextPackageJson[field] ??= {};
834
- const changedKeys = [];
835
- for (const [dependencyName, versionRange] of Object.entries(dependencies)) {
836
- if (!nextPackageJson[field][dependencyName]) {
837
- nextPackageJson[field][dependencyName] = versionRange;
838
- changedKeys.push(dependencyName);
839
- }
840
- }
841
- return {
842
- changed: changedKeys.length > 0,
843
- changedKeys,
844
- packageJson: nextPackageJson,
845
- };
846
- }
847
- function removePackageJsonDependencies(packageJson, dependencyNames) {
848
- const nextPackageJson = structuredClone(packageJson);
849
- const removedKeys = [];
850
- for (const dependencyName of dependencyNames) {
851
- if (nextPackageJson.dependencies?.[dependencyName]) {
852
- delete nextPackageJson.dependencies[dependencyName];
853
- removedKeys.push(dependencyName);
854
- }
855
- if (nextPackageJson.devDependencies?.[dependencyName]) {
856
- delete nextPackageJson.devDependencies[dependencyName];
857
- removedKeys.push(dependencyName);
858
- }
859
- }
860
- return {
861
- changed: removedKeys.length > 0,
862
- packageJson: nextPackageJson,
863
- removedKeys,
864
- };
904
+ async function getProjectTooling(cwd, manifest) {
905
+ return await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest.project?.tooling);
865
906
  }
866
- function ensurePackageJsonScripts(packageJson, scripts) {
867
- const nextPackageJson = structuredClone(packageJson);
868
- nextPackageJson.scripts ??= {};
907
+ async function ensureProjectTasks(cwd, manifest, tasks) {
908
+ const tooling = await getProjectTooling(cwd, manifest);
869
909
  const changedKeys = [];
870
- for (const [scriptName, scriptCommand] of Object.entries(scripts)) {
871
- if (nextPackageJson.scripts[scriptName] !== scriptCommand) {
872
- nextPackageJson.scripts[scriptName] = scriptCommand;
873
- changedKeys.push(scriptName);
874
- }
910
+ for (const [name, definition] of Object.entries(tasks)) {
911
+ const result = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, { definition, name });
912
+ if (result.changed)
913
+ changedKeys.push(name);
875
914
  }
915
+ return { changedKeys, config: tooling.tasks.config, tooling };
916
+ }
917
+ async function checkProjectTasks(cwd, manifest, expected) {
918
+ const tooling = await getProjectTooling(cwd, manifest);
919
+ const store = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
876
920
  return {
877
- changed: changedKeys.length > 0,
878
- changedKeys,
879
- packageJson: nextPackageJson,
921
+ config: tooling.tasks.config,
922
+ mismatches: Object.entries(expected).flatMap(([name, command]) => (0, projectTooling_js_1.getTaskCommand)(store.definitions[name]) === command ? [] : [name]),
923
+ store,
924
+ tooling,
880
925
  };
881
926
  }
882
- function buildManifest(cwd, packageJson, framework, existingManifest) {
927
+ function buildManifest(cwd, packageJson, framework, existingManifest, tooling) {
883
928
  return {
884
929
  $schema: existingManifest?.$schema ?? exports.LOOM_MANIFEST_SCHEMA,
885
930
  version: 1,
@@ -891,6 +936,7 @@ function buildManifest(cwd, packageJson, framework, existingManifest) {
891
936
  ...existingManifest?.project?.framework,
892
937
  ...framework,
893
938
  },
939
+ tooling: existingManifest?.project?.tooling ?? tooling,
894
940
  },
895
941
  features: existingManifest?.features ?? {},
896
942
  };
@@ -910,33 +956,6 @@ function hasPackageDependency(packageJson, dependencyName) {
910
956
  return Boolean(packageJson.dependencies?.[dependencyName] ||
911
957
  packageJson.devDependencies?.[dependencyName]);
912
958
  }
913
- async function detectPackageManager(cwd, packageJson) {
914
- if (packageJson.packageManager?.startsWith("pnpm@")) {
915
- return "pnpm";
916
- }
917
- if (packageJson.packageManager?.startsWith("yarn@")) {
918
- return "yarn";
919
- }
920
- if (packageJson.packageManager?.startsWith("npm@")) {
921
- return "npm";
922
- }
923
- if (await exists((0, node_path_1.join)(cwd, "pnpm-lock.yaml"))) {
924
- return "pnpm";
925
- }
926
- if (await exists((0, node_path_1.join)(cwd, "yarn.lock"))) {
927
- return "yarn";
928
- }
929
- return "npm";
930
- }
931
- function getRunScriptCommand(packageManager, scriptName) {
932
- if (packageManager === "pnpm") {
933
- return `pnpm ${scriptName}`;
934
- }
935
- if (packageManager === "yarn") {
936
- return `yarn ${scriptName}`;
937
- }
938
- return `npm run ${scriptName}`;
939
- }
940
959
  function scriptRunsSerwistBuild(script) {
941
960
  return Boolean(script && (/\bserwist\s+build\b/.test(script) ||
942
961
  script.includes("@serwist/cli") ||
@@ -951,35 +970,6 @@ function formatTsNumberLiteral(value) {
951
970
  function numberLiteralRegExp(value) {
952
971
  return String(value).split("").map((digit) => `${digit}_?`).join("");
953
972
  }
954
- function ensurePwaPackageJsonScripts(packageJson, packageManager) {
955
- const nextPackageJson = structuredClone(packageJson);
956
- nextPackageJson.scripts ??= {};
957
- const changedKeys = [];
958
- const notes = [];
959
- if (nextPackageJson.scripts["pwa:build"] !== PWA_BUILD_SCRIPT) {
960
- nextPackageJson.scripts["pwa:build"] = PWA_BUILD_SCRIPT;
961
- changedKeys.push("pwa:build");
962
- }
963
- const buildScript = nextPackageJson.scripts.build;
964
- if (!buildScript) {
965
- nextPackageJson.scripts.build = `next build && ${getRunScriptCommand(packageManager, "pwa:build")}`;
966
- changedKeys.push("build");
967
- }
968
- else if (buildScript.includes("next build") &&
969
- !scriptRunsSerwistBuild(buildScript)) {
970
- nextPackageJson.scripts.build = `${buildScript} && ${getRunScriptCommand(packageManager, "pwa:build")}`;
971
- changedKeys.push("build");
972
- }
973
- else if (!scriptRunsSerwistBuild(buildScript)) {
974
- 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.");
975
- }
976
- return {
977
- changed: changedKeys.length > 0,
978
- changedKeys,
979
- notes,
980
- packageJson: nextPackageJson,
981
- };
982
- }
983
973
  function getJobsConfig(framework) {
984
974
  const appRoot = framework.srcDir ? "src/app" : "app";
985
975
  const jobsRoot = framework.srcDir ? "src/jobs" : "jobs";
@@ -1222,12 +1212,37 @@ async function mergeAuthConfig(cwd, framework, featureConfig) {
1222
1212
  },
1223
1213
  };
1224
1214
  }
1225
- function getDbExpectedScripts(config) {
1215
+ function dependencyExecutable(tooling, executable) {
1216
+ switch (tooling.manager) {
1217
+ case "deno":
1218
+ return `deno run -A npm:${executable}`;
1219
+ case "npm":
1220
+ return `npx ${executable}`;
1221
+ case "pnpm":
1222
+ return `pnpm ${executable}`;
1223
+ case "yarn":
1224
+ return `yarn ${executable}`;
1225
+ }
1226
+ }
1227
+ function dependencyRefreshCommand(tooling, name, version) {
1228
+ switch (tooling.manager) {
1229
+ case "deno":
1230
+ return "deno install";
1231
+ case "npm":
1232
+ return `npm install --save-exact ${name}@${version}`;
1233
+ case "pnpm":
1234
+ return `pnpm update --no-save ${name}@${version} && pnpm install`;
1235
+ case "yarn":
1236
+ return `yarn add --exact ${name}@${version}`;
1237
+ }
1238
+ }
1239
+ function getDbExpectedScripts(config, tooling) {
1240
+ const drizzleKit = dependencyExecutable(tooling.dependencies, "drizzle-kit");
1226
1241
  return {
1227
1242
  "db:fixtures": "loom db fixtures",
1228
- "db:generate": "pnpm drizzle-kit generate",
1229
- "db:migrate": "pnpm drizzle-kit migrate",
1230
- "db:push": "pnpm drizzle-kit push",
1243
+ "db:generate": `${drizzleKit} generate`,
1244
+ "db:migrate": `${drizzleKit} migrate`,
1245
+ "db:push": `${drizzleKit} push`,
1231
1246
  "drizzle-kit": `NODE_OPTIONS='--import tsx' loom env -- drizzle-kit --config=./${config.modules.drizzleConfig}`,
1232
1247
  "schema:gen": "loom db schema-gen",
1233
1248
  };
@@ -1860,9 +1875,10 @@ For all work in this repo:
1860
1875
  1. Use the \`loom\` skill first.
1861
1876
  2. Read \`loom.json\` before making Loom-related changes.
1862
1877
  3. Treat active Loom features and configured paths as the contract between the app and the shared package.
1863
- 4. If the task touches a specific active Loom feature, also use the matching feature skill such as \`loom-jobs\`.
1864
- 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.
1865
- 6. Keep project-specific rules outside this managed block; shared Loom policy lives in the \`loom\` skill.
1878
+ 4. Read \`project.tooling\` in \`loom.json\`; do not assume tasks live in \`package.json\` or that pnpm is the runner.
1879
+ 5. If the task touches a specific active Loom feature, also use the matching feature skill such as \`loom-jobs\`.
1880
+ 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.
1881
+ 7. Keep project-specific rules outside this managed block; shared Loom policy lives in the \`loom\` skill.
1866
1882
  ${exports.LOOM_MANAGED_AGENTS_END}
1867
1883
  `;
1868
1884
  }
@@ -2125,6 +2141,37 @@ async function ensurePnpmProject(cwd, packageJson) {
2125
2141
  }
2126
2142
  throw new Error("loom dev local/published currently supports pnpm projects only.");
2127
2143
  }
2144
+ function usesDenoTooling(tooling) {
2145
+ return tooling.tasks.runner === "deno" ||
2146
+ tooling.dependencies.manager === "deno";
2147
+ }
2148
+ async function getDenoConfigForLinks(cwd, tooling) {
2149
+ for (const config of [
2150
+ tooling.tasks.config,
2151
+ tooling.dependencies.config,
2152
+ "deno.json",
2153
+ "deno.jsonc",
2154
+ ]) {
2155
+ if ((config === "deno.json" || config === "deno.jsonc") &&
2156
+ await exists((0, node_path_1.join)(cwd, config))) {
2157
+ return config;
2158
+ }
2159
+ }
2160
+ throw new Error("Deno local development requires a deno.json or deno.jsonc workspace root.");
2161
+ }
2162
+ async function findLocalLoomDenoLink(cwd, links) {
2163
+ for (const link of links) {
2164
+ const path = (0, node_path_1.resolve)(cwd, link);
2165
+ const packageText = await readTextIfExists((0, node_path_1.join)(path, "package.json"));
2166
+ if (!packageText)
2167
+ continue;
2168
+ if (parseJson(packageText, `${link}/package.json`).name ===
2169
+ exports.LOOM_DEPENDENCY) {
2170
+ return { link, path };
2171
+ }
2172
+ }
2173
+ return null;
2174
+ }
2128
2175
  async function resolveLocalLoomPackagePath(cwd, inputPath) {
2129
2176
  const resolvedInput = (0, node_path_1.resolve)(cwd, inputPath);
2130
2177
  const candidates = [resolvedInput, (0, node_path_1.join)(resolvedInput, "npm")];
@@ -2240,6 +2287,9 @@ async function readPackageVersion(packagePath) {
2240
2287
  }
2241
2288
  return parseJson(packageJsonText, (0, node_path_1.join)(packagePath, "package.json")).version;
2242
2289
  }
2290
+ function versionFromDependencySpec(spec) {
2291
+ return spec?.match(/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/)?.[1];
2292
+ }
2243
2293
  async function getGitStdout(commandRunner, cwd, args, env) {
2244
2294
  const result = await commandRunner("git", args, { cwd, env });
2245
2295
  if (result.code !== 0) {
@@ -2306,7 +2356,7 @@ async function writeLocalDevStateIfChanged(cwd, state) {
2306
2356
  await (0, promises_1.writeFile)(gitignorePath, gitignoreUpdate.text, "utf8");
2307
2357
  gitignoreChanged = true;
2308
2358
  }
2309
- return stateChanged || gitignoreChanged;
2359
+ return { gitignoreChanged, stateChanged };
2310
2360
  }
2311
2361
  async function getCurrentLocalDevState(cwd, workspaceText) {
2312
2362
  return getManagedDevState(workspaceText) ?? await readLocalDevState(cwd);
@@ -2422,10 +2472,19 @@ async function resolveLoomCommitPublication(sourceRoot, sourceCommit, commandRun
2422
2472
  return { status: "no-release-tag" };
2423
2473
  }
2424
2474
  async function syncLocalDevPackage(cwd, options = {}) {
2475
+ const manifest = await readManifestIfExists(cwd);
2476
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
2477
+ const denoMode = usesDenoTooling(tooling);
2425
2478
  const workspacePath = (0, node_path_1.join)(cwd, "pnpm-workspace.yaml");
2426
2479
  const workspaceText = await readTextIfExists(workspacePath);
2427
2480
  const overrideSpec = getManagedDevOverrideSpec(workspaceText);
2428
- if (!overrideSpec) {
2481
+ const denoConfig = denoMode
2482
+ ? await getDenoConfigForLinks(cwd, tooling)
2483
+ : null;
2484
+ const denoLink = denoConfig
2485
+ ? await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, denoConfig))
2486
+ : null;
2487
+ if (!overrideSpec && !denoLink) {
2429
2488
  if (options.requireActive) {
2430
2489
  throw new Error("No managed Loom local-dev override is active. Run `loom dev local /path/to/loom` first.");
2431
2490
  }
@@ -2438,20 +2497,31 @@ async function syncLocalDevPackage(cwd, options = {}) {
2438
2497
  };
2439
2498
  }
2440
2499
  const { packageJson } = await readProjectPackageJson(cwd);
2441
- await ensurePnpmProject(cwd, packageJson);
2500
+ if (!denoMode)
2501
+ await ensurePnpmProject(cwd, packageJson);
2442
2502
  const commandRunner = options.commandRunner ?? defaultCommandRunner;
2443
2503
  const env = options.env ?? node_process_1.default.env;
2444
- const localPackagePath = fileSpecToPath(cwd, overrideSpec);
2504
+ const localPackagePath = denoLink?.path ??
2505
+ fileSpecToPath(cwd, overrideSpec);
2445
2506
  const sourceRoot = await resolveLocalLoomSourceRoot(localPackagePath);
2507
+ const configuredSpec = packageJson.dependencies?.[exports.LOOM_DEPENDENCY] ??
2508
+ packageJson.devDependencies?.[exports.LOOM_DEPENDENCY];
2509
+ const desiredLocalVersion = await readPackageVersion((0, node_path_1.join)(cwd, "node_modules", exports.LOOM_DEPENDENCY)) ?? versionFromDependencySpec(configuredSpec) ??
2510
+ await readPackageVersion(localPackagePath);
2511
+ const currentLocalVersion = await readPackageVersion(localPackagePath);
2512
+ const buildEnv = desiredLocalVersion && !env.NPM_PACKAGE_VERSION
2513
+ ? { ...env, NPM_PACKAGE_VERSION: desiredLocalVersion }
2514
+ : env;
2446
2515
  const ranCommands = [];
2447
2516
  let buildRan = false;
2448
- if (options.force || await isLocalLoomBuildStale(sourceRoot, localPackagePath)) {
2517
+ if (options.force || denoMode && currentLocalVersion !== desiredLocalVersion ||
2518
+ await isLocalLoomBuildStale(sourceRoot, localPackagePath)) {
2449
2519
  if (!sourceRoot) {
2450
2520
  throw new Error(`Could not find the Loom source checkout for ${localPackagePath}; cannot rebuild the local package.`);
2451
2521
  }
2452
2522
  await runCommandOrThrow(commandRunner, "deno", ["task", "build"], {
2453
2523
  cwd: sourceRoot,
2454
- env,
2524
+ env: buildEnv,
2455
2525
  stdio: "inherit",
2456
2526
  });
2457
2527
  ranCommands.push("deno task build");
@@ -2461,25 +2531,39 @@ async function syncLocalDevPackage(cwd, options = {}) {
2461
2531
  await isInstalledLocalLoomPackageStale(cwd, localPackagePath);
2462
2532
  let packageRefreshRan = false;
2463
2533
  if (options.force || packageRefreshNeeded) {
2464
- const packageSpec = `${exports.LOOM_DEPENDENCY}@file:${localPackagePath}`;
2465
- await runCommandOrThrow(commandRunner, "pnpm", ["update", "--no-save", packageSpec], { cwd, env, stdio: "inherit" });
2466
- ranCommands.push(`pnpm update --no-save ${packageSpec}`);
2467
- await runCommandOrThrow(commandRunner, "pnpm", ["install"], {
2468
- cwd,
2469
- env,
2470
- stdio: "inherit",
2471
- });
2472
- ranCommands.push("pnpm install");
2534
+ if (denoMode) {
2535
+ await runCommandOrThrow(commandRunner, "deno", ["install"], {
2536
+ cwd,
2537
+ env,
2538
+ stdio: "inherit",
2539
+ });
2540
+ ranCommands.push("deno install");
2541
+ }
2542
+ else {
2543
+ const packageSpec = `${exports.LOOM_DEPENDENCY}@file:${localPackagePath}`;
2544
+ await runCommandOrThrow(commandRunner, "pnpm", ["update", "--no-save", packageSpec], { cwd, env, stdio: "inherit" });
2545
+ ranCommands.push(`pnpm update --no-save ${packageSpec}`);
2546
+ await runCommandOrThrow(commandRunner, "pnpm", ["install"], {
2547
+ cwd,
2548
+ env,
2549
+ stdio: "inherit",
2550
+ });
2551
+ ranCommands.push("pnpm install");
2552
+ }
2473
2553
  packageRefreshRan = true;
2474
2554
  }
2475
2555
  const currentWorkspaceText = await readTextIfExists(workspacePath);
2476
- const currentState = await getCurrentLocalDevState(cwd, currentWorkspaceText);
2556
+ const currentState = denoMode
2557
+ ? await readLocalDevState(cwd)
2558
+ : await getCurrentLocalDevState(cwd, currentWorkspaceText);
2477
2559
  let state = null;
2478
2560
  if (buildRan || packageRefreshRan || !currentState) {
2479
2561
  state = await buildLocalDevState(localPackagePath, sourceRoot, commandRunner, env);
2480
- const stateUpdate = setManagedDevStateText(await readTextIfExists(workspacePath), overrideSpec, state);
2481
- if (stateUpdate.changed) {
2482
- await writeTextOrDeleteIfEmpty(workspacePath, stateUpdate.text);
2562
+ if (!denoMode) {
2563
+ const stateUpdate = setManagedDevStateText(await readTextIfExists(workspacePath), overrideSpec, state);
2564
+ if (stateUpdate.changed) {
2565
+ await writeTextOrDeleteIfEmpty(workspacePath, stateUpdate.text);
2566
+ }
2483
2567
  }
2484
2568
  }
2485
2569
  if (state ?? currentState) {
@@ -2508,16 +2592,43 @@ async function syncLocalDevPackage(cwd, options = {}) {
2508
2592
  };
2509
2593
  }
2510
2594
  async function useLocalDevPackage(cwd, inputPath) {
2511
- const packageJsonPath = (0, node_path_1.join)(cwd, "package.json");
2512
- const packageJsonText = await readTextIfExists(packageJsonPath);
2513
- if (!packageJsonText) {
2514
- throw new Error(`No package.json found in ${cwd}`);
2595
+ const { packageJson } = await readProjectPackageJson(cwd);
2596
+ const manifest = await readManifestIfExists(cwd);
2597
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
2598
+ const localPackagePath = await resolveLocalLoomPackagePath(cwd, inputPath);
2599
+ const publishedSpec = getPublishedLoomDependencySpec(packageJson);
2600
+ if (usesDenoTooling(tooling)) {
2601
+ if (!await exists((0, node_path_1.join)(localPackagePath, "deno.json"))) {
2602
+ throw new Error(`Local Deno development requires ${localPackagePath}/deno.json. Rebuild the Loom npm output before linking it.`);
2603
+ }
2604
+ const denoConfig = await getDenoConfigForLinks(cwd, tooling);
2605
+ const relativeLocalPackagePath = (0, node_path_1.relative)(cwd, localPackagePath)
2606
+ .replaceAll("\\", "/");
2607
+ const update = await (0, projectTooling_js_1.mutateDenoLinks)(cwd, denoConfig, {
2608
+ add: relativeLocalPackagePath,
2609
+ });
2610
+ const state = {
2611
+ dependency: exports.LOOM_DEPENDENCY,
2612
+ localPackagePath,
2613
+ packageVersion: await readPackageVersion(localPackagePath),
2614
+ syncedAt: new Date().toISOString(),
2615
+ version: 1,
2616
+ };
2617
+ const stateUpdate = await writeLocalDevStateIfChanged(cwd, state);
2618
+ const changedFiles = update.changed ? [denoConfig] : [];
2619
+ if (stateUpdate.gitignoreChanged)
2620
+ changedFiles.push(".gitignore");
2621
+ return {
2622
+ changedFiles,
2623
+ notes: [
2624
+ `Local Loom dev link is active in ${denoConfig}: ${localPackagePath}`,
2625
+ "Run `loom dev sync` to rebuild the local Loom package and refresh Deno's dependency installation when needed.",
2626
+ `Before committing or shipping a published build, run loom dev published, then deno install to restore ${exports.LOOM_DEPENDENCY}@${publishedSpec}.`,
2627
+ ],
2628
+ };
2515
2629
  }
2516
- const packageJson = parseJson(packageJsonText, "package.json");
2517
2630
  await ensurePnpmProject(cwd, packageJson);
2518
- const localPackagePath = await resolveLocalLoomPackagePath(cwd, inputPath);
2519
2631
  const overrideSpec = `file:${localPackagePath}`;
2520
- const publishedSpec = getPublishedLoomDependencySpec(packageJson);
2521
2632
  const workspacePath = (0, node_path_1.join)(cwd, "pnpm-workspace.yaml");
2522
2633
  const update = ensurePnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath), overrideSpec);
2523
2634
  if (update.conflict) {
@@ -2538,20 +2649,30 @@ async function useLocalDevPackage(cwd, inputPath) {
2538
2649
  };
2539
2650
  }
2540
2651
  async function usePublishedDevPackage(cwd, options = {}) {
2541
- const packageJsonPath = (0, node_path_1.join)(cwd, "package.json");
2542
- const packageJsonText = await readTextIfExists(packageJsonPath);
2543
- if (!packageJsonText) {
2544
- throw new Error(`No package.json found in ${cwd}`);
2545
- }
2546
- const packageJson = parseJson(packageJsonText, "package.json");
2547
- await ensurePnpmProject(cwd, packageJson);
2652
+ const { packageJson } = await readProjectPackageJson(cwd);
2653
+ const manifest = await readManifestIfExists(cwd);
2654
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
2655
+ const denoMode = usesDenoTooling(tooling);
2656
+ if (!denoMode)
2657
+ await ensurePnpmProject(cwd, packageJson);
2548
2658
  const commandRunner = options.commandRunner ?? defaultCommandRunner;
2549
2659
  const env = options.env ?? node_process_1.default.env;
2550
2660
  const workspacePath = (0, node_path_1.join)(cwd, "pnpm-workspace.yaml");
2551
2661
  const workspaceText = await readTextIfExists(workspacePath);
2552
- const activeOverrideSpec = getManagedDevOverrideSpec(workspaceText);
2553
- const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
2554
- const state = await getCurrentLocalDevState(cwd, workspaceText);
2662
+ const denoConfig = denoMode
2663
+ ? await getDenoConfigForLinks(cwd, tooling)
2664
+ : null;
2665
+ const denoLink = denoConfig
2666
+ ? await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, denoConfig))
2667
+ : null;
2668
+ const activeOverrideSpec = denoLink?.link ??
2669
+ getManagedDevOverrideSpec(workspaceText);
2670
+ const localLockfileResolution = denoMode
2671
+ ? null
2672
+ : await getProjectLocalLoomLockfileResolution(cwd);
2673
+ const state = denoMode
2674
+ ? await readLocalDevState(cwd)
2675
+ : await getCurrentLocalDevState(cwd, workspaceText);
2555
2676
  const notes = [];
2556
2677
  let publishedSpec = getPublishedLoomDependencySpec(packageJson);
2557
2678
  const needsPublicationProof = Boolean(activeOverrideSpec || localLockfileResolution);
@@ -2574,21 +2695,33 @@ async function usePublishedDevPackage(cwd, options = {}) {
2574
2695
  else if (needsPublicationProof) {
2575
2696
  notes.push("No recorded Loom sync commit was found; switching back to the existing published dependency without proving whether local Loom changes were required.");
2576
2697
  }
2577
- const dependencyUpdate = ensurePackageJsonDependency(packageJson, publishedSpec);
2578
- if (dependencyUpdate.changed) {
2579
- await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(dependencyUpdate.packageJson), "utf8");
2580
- }
2581
- const update = clearPnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath));
2698
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
2699
+ dependencies: { [exports.LOOM_DEPENDENCY]: publishedSpec },
2700
+ replace: true,
2701
+ });
2702
+ const denoUpdate = denoConfig && denoLink
2703
+ ? await (0, projectTooling_js_1.mutateDenoLinks)(cwd, denoConfig, { remove: denoLink.link })
2704
+ : null;
2705
+ const update = denoMode
2706
+ ? { changed: denoUpdate?.changed ?? false, text: "" }
2707
+ : clearPnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath));
2582
2708
  const changedFiles = [];
2583
2709
  if (dependencyUpdate.changed) {
2584
- changedFiles.push("package.json");
2710
+ changedFiles.push(dependencyUpdate.config);
2585
2711
  }
2586
2712
  if (update.changed) {
2587
- await writeTextOrDeleteIfEmpty(workspacePath, update.text);
2588
- changedFiles.push("pnpm-workspace.yaml");
2713
+ if (denoMode) {
2714
+ changedFiles.push(denoConfig);
2715
+ }
2716
+ else {
2717
+ await writeTextOrDeleteIfEmpty(workspacePath, update.text);
2718
+ changedFiles.push("pnpm-workspace.yaml");
2719
+ }
2589
2720
  }
2590
2721
  if (update.changed || localLockfileResolution) {
2591
- notes.push(`Run \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@${publishedSpec}\` and then \`pnpm install\` in this project to return node_modules and the lockfile to the published ${exports.LOOM_DEPENDENCY} dependency.`);
2722
+ notes.push(denoMode
2723
+ ? `Run \`deno install\` in this project to return node_modules and deno.lock to published ${exports.LOOM_DEPENDENCY}@${publishedSpec}.`
2724
+ : `Run \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@${publishedSpec}\` and then \`pnpm install\` in this project to return node_modules and the lockfile to the published ${exports.LOOM_DEPENDENCY} dependency.`);
2592
2725
  }
2593
2726
  if (localLockfileResolution) {
2594
2727
  notes.push(`pnpm-lock.yaml still resolves ${exports.LOOM_DEPENDENCY} to ${localLockfileResolution} until that update is run.`);
@@ -2722,26 +2855,43 @@ async function checkManagedAgentsFile(cwd) {
2722
2855
  };
2723
2856
  }
2724
2857
  async function checkManagedLocalDevOverride(cwd, production = false) {
2858
+ const manifest = await readManifestIfExists(cwd);
2859
+ let denoLink = null;
2860
+ let denoConfig = null;
2861
+ try {
2862
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
2863
+ if (usesDenoTooling(tooling)) {
2864
+ denoConfig = await getDenoConfigForLinks(cwd, tooling);
2865
+ denoLink = await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, denoConfig));
2866
+ }
2867
+ }
2868
+ catch {
2869
+ // The main project tooling check reports invalid configuration separately.
2870
+ }
2725
2871
  const workspaceText = await readTextIfExists((0, node_path_1.join)(cwd, "pnpm-workspace.yaml"));
2726
2872
  const overrideSpec = getManagedDevOverrideSpec(workspaceText);
2727
- if (!overrideSpec) {
2873
+ if (!overrideSpec && !denoLink) {
2728
2874
  return {
2729
2875
  issues: [],
2730
2876
  suggestions: [],
2731
2877
  warnings: [],
2732
2878
  };
2733
2879
  }
2880
+ const location = denoLink
2881
+ ? `${denoConfig} links: ${denoLink.link}`
2882
+ : `pnpm-workspace.yaml: ${overrideSpec}`;
2883
+ const restore = denoLink
2884
+ ? "Run `loom dev published`, then run `deno install` before committing or shipping a published build."
2885
+ : `Run \`loom dev published\`, then follow its printed \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@<version>\` command and run \`pnpm install\` before committing or shipping a published build.`;
2734
2886
  return {
2735
2887
  issues: production
2736
2888
  ? [
2737
- `Local Loom dev override is active in pnpm-workspace.yaml: ${overrideSpec}`,
2889
+ `Local Loom dev override is active in ${location}`,
2738
2890
  ]
2739
2891
  : [],
2740
- suggestions: [
2741
- `Run \`loom dev published\`, then follow its printed \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@<version>\` command and run \`pnpm install\` before committing or shipping a published build.`,
2742
- ],
2892
+ suggestions: [restore],
2743
2893
  warnings: production ? [] : [
2744
- `Local Loom dev override is active in pnpm-workspace.yaml: ${overrideSpec}`,
2894
+ `Local Loom dev override is active in ${location}`,
2745
2895
  ],
2746
2896
  };
2747
2897
  }
@@ -2782,6 +2932,18 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2782
2932
  const warnings = [];
2783
2933
  const dependency = packageJson.dependencies?.[exports.LOOM_DEPENDENCY];
2784
2934
  const production = options.production;
2935
+ const projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
2936
+ let dependencyTooling = {
2937
+ config: projectMetadata.config,
2938
+ manager: projectMetadata.config === "package.json" ? "pnpm" : "deno",
2939
+ };
2940
+ try {
2941
+ const manifest = await readManifestIfExists(cwd);
2942
+ dependencyTooling = (await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling)).dependencies;
2943
+ }
2944
+ catch {
2945
+ // The main tooling check owns the validation error; release hints can fall back.
2946
+ }
2785
2947
  const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
2786
2948
  const devState = await readLocalDevState(cwd);
2787
2949
  if (localLockfileResolution) {
@@ -2815,8 +2977,8 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2815
2977
  "package-equivalent"
2816
2978
  ? `package-relevant files match ${exports.LOOM_DEPENDENCY}@${publication.version}`
2817
2979
  : `it is published as ${exports.LOOM_DEPENDENCY}@${publication.version}`;
2818
- addReleaseCheckMessage(issues, warnings, production, `This app was last synced against Loom commit ${shortCommit}; ${publicationDescription}, but package.json is pinned to ${dependency}.`);
2819
- suggestions.add(`Run \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@${publication.version}\` and then \`pnpm install\`.`);
2980
+ addReleaseCheckMessage(issues, warnings, production, `This app was last synced against Loom commit ${shortCommit}; ${publicationDescription}, but ${dependencyTooling.config} is pinned to ${dependency}.`);
2981
+ suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, exports.LOOM_DEPENDENCY, publication.version)}.`);
2820
2982
  }
2821
2983
  else if (localLockfileResolution) {
2822
2984
  const publicationDescription = publication.reason ===
@@ -2824,7 +2986,7 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2824
2986
  ? `has no package-relevant changes after ${publication.tag}, so ${exports.LOOM_DEPENDENCY}@${publication.version} covers it`
2825
2987
  : `is published as ${exports.LOOM_DEPENDENCY}@${publication.version}`;
2826
2988
  warnings.push(`The synced Loom commit ${shortCommit} ${publicationDescription}; refresh the lockfile away from ${localLockfileResolution}.`);
2827
- suggestions.add(`Run \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@${publication.version}\` and then \`pnpm install\`.`);
2989
+ suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, exports.LOOM_DEPENDENCY, publication.version)}.`);
2828
2990
  }
2829
2991
  break;
2830
2992
  }
@@ -2849,8 +3011,8 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
2849
3011
  else {
2850
3012
  const installedPackage = parseJson(installedPackageText, (0, node_path_1.join)("node_modules", exports.LOOM_DEPENDENCY, "package.json"));
2851
3013
  if (installedPackage.version !== dependency) {
2852
- issues.push(`Installed ${exports.LOOM_DEPENDENCY} version ${installedPackage.version} does not match package.json ${dependency}.`);
2853
- suggestions.add(`Run \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@${dependency}\` and then \`pnpm install\`.`);
3014
+ issues.push(`Installed ${exports.LOOM_DEPENDENCY} version ${installedPackage.version} does not match ${dependencyTooling.config} ${dependency}.`);
3015
+ suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, exports.LOOM_DEPENDENCY, dependency)}.`);
2854
3016
  }
2855
3017
  }
2856
3018
  }
@@ -2924,7 +3086,7 @@ function getGithubWorkflowStepBlocks(text) {
2924
3086
  }
2925
3087
  function workflowInstallsNodeDependencies(stepBlocks) {
2926
3088
  return stepBlocks.some((block) => /uses:\s*actions\/setup-node@/m.test(block) ||
2927
- /\b(?:pnpm\s+(?:install|i)|npm\s+(?:ci|install)|yarn\s+install|bun\s+install)\b/
3089
+ /\b(?:deno\s+install|pnpm\s+(?:install|i)|npm\s+(?:ci|install)|yarn\s+install|bun\s+install)\b/
2928
3090
  .test(block));
2929
3091
  }
2930
3092
  function hasGithubPackagesSetupNodeConfig(stepBlocks) {
@@ -3047,14 +3209,14 @@ function githubWorkflowRunsOnMainPush(text) {
3047
3209
  return !hasBranchFilter && !ignoresMain;
3048
3210
  }
3049
3211
  function workflowStepRunsDbMigrate(block) {
3050
- 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/
3212
+ 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/
3051
3213
  .test(block) ||
3052
3214
  /\bdrizzle-kit\s+migrate\b/.test(block) ||
3053
3215
  /spawnSync\(\s*["']pnpm["'][\s\S]*["']db:migrate["']/.test(block);
3054
3216
  }
3055
3217
  function workflowStepUsesVercelCommand(block, subcommand) {
3056
3218
  const launcher = String
3057
- .raw `(?:vercel|pnpm\s+(?:dlx|exec)\s+vercel(?:@[^\s]+)?|npx\s+vercel(?:@[^\s]+)?|yarn\s+(?:dlx\s+)?vercel(?:@[^\s]+)?|bunx\s+vercel(?:@[^\s]+)?)`;
3219
+ .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]+)?)`;
3058
3220
  const globalFlags = String
3059
3221
  .raw `(?:\s+(?:--[A-Za-z-]+(?:=(?:"[^"]+"|'[^']+'|[^\s]+)|\s+(?:"[^"]+"|'[^']+'|[^\s]+))?|-[A-Za-z](?:\s+(?:"[^"]+"|'[^']+'|[^\s]+))?))*`;
3060
3222
  return new RegExp(String.raw `\b${launcher}${globalFlags}\s+${subcommand}\b`)
@@ -4016,10 +4178,13 @@ function dbScriptsTsconfigTemplate() {
4016
4178
  }
4017
4179
  `;
4018
4180
  }
4019
- function dbPgliteHarnessTemplate(config) {
4181
+ function dbPgliteHarnessTemplate(config, testRunner = "vitest") {
4020
4182
  const schemaImportPath = toRelativeImportPath(config.modules.pgliteHarnessModule, (0, node_path_1.join)(config.dirs.schemaDir, "index.ts"));
4183
+ const afterAllImport = testRunner === "deno"
4184
+ ? 'import { afterAll } from "jsr:@std/testing@^1.0.19/bdd";'
4185
+ : 'import { afterAll } from "vitest";';
4021
4186
  return `import { createMemoryPgliteHarness } from "@gadicc/loom/db/testing";
4022
- import { afterAll } from "vitest";
4187
+ ${afterAllImport}
4023
4188
  import * as schema from "${schemaImportPath}";
4024
4189
 
4025
4190
  const harness = await createMemoryPgliteHarness({
@@ -4040,6 +4205,14 @@ afterAll(closeMemoryPglite);
4040
4205
  export const { client, db, tableLoader } = harness;
4041
4206
  `;
4042
4207
  }
4208
+ async function getDbTestRunner(cwd, tooling) {
4209
+ if (tooling.tasks.runner !== "deno")
4210
+ return "vitest";
4211
+ const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
4212
+ return /\bvitest\b/.test((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions.test) ?? "")
4213
+ ? "vitest"
4214
+ : "deno";
4215
+ }
4043
4216
  function dbFixturesScriptTemplate(config) {
4044
4217
  const schemaImportPath = toRelativeImportPath(config.modules.fixtureDumpScript, (0, node_path_1.join)(config.dirs.schemaDir, "index.ts"));
4045
4218
  const neonImportPath = toRelativeImportPath(config.modules.fixtureDumpScript, config.modules.neonModule);
@@ -4388,6 +4561,11 @@ export function getDefaultMailFromEmail() {
4388
4561
  return requireEnv("POSTAL_FROM_EMAIL");
4389
4562
  }
4390
4563
 
4564
+ /** Reads the optional default sender display name from the app environment. */
4565
+ export function getDefaultMailFromName() {
4566
+ return process.env.POSTAL_FROM_NAME?.trim() || undefined;
4567
+ }
4568
+
4391
4569
  export function getPostalWebhookPublicKeys(): PostalWebhookPublicKey[] {
4392
4570
  const raw = process.env.POSTAL_WEBHOOK_PUBLIC_KEYS?.trim();
4393
4571
  if (!raw) throw new Error("POSTAL_WEBHOOK_PUBLIC_KEYS is not set.");
@@ -4413,6 +4591,7 @@ function mailServiceTemplate(config) {
4413
4591
  import { mailRepository } from "${toAliasImportPath(config.modules.repositoryModule)}";
4414
4592
  import {
4415
4593
  getDefaultMailFromEmail,
4594
+ getDefaultMailFromName,
4416
4595
  mailTransport,
4417
4596
  } from "${toAliasImportPath(config.modules.transportModule)}";
4418
4597
 
@@ -4420,6 +4599,9 @@ export const mailService = createLoomMailService({
4420
4599
  get defaultFromEmail() {
4421
4600
  return getDefaultMailFromEmail();
4422
4601
  },
4602
+ get defaultFromName() {
4603
+ return getDefaultMailFromName();
4604
+ },
4423
4605
  repository: mailRepository,
4424
4606
  transport: mailTransport,
4425
4607
  });
@@ -5078,14 +5260,11 @@ async function materializeManagedSchema(cwd, schema, dbConfig) {
5078
5260
  };
5079
5261
  }
5080
5262
  async function readProjectPackageJson(cwd) {
5081
- const packageJsonPath = (0, node_path_1.join)(cwd, "package.json");
5082
- const packageJsonText = await readTextIfExists(packageJsonPath);
5083
- if (!packageJsonText) {
5084
- throw new Error(`No package.json found in ${cwd}`);
5085
- }
5263
+ const metadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
5086
5264
  return {
5087
- packageJson: parseJson(packageJsonText, "package.json"),
5088
- packageJsonPath,
5265
+ packageJson: metadata.packageJson,
5266
+ packageJsonPath: metadata.path,
5267
+ projectConfig: metadata.config,
5089
5268
  };
5090
5269
  }
5091
5270
  async function resolveDbProjectConfig(cwd) {
@@ -5174,7 +5353,8 @@ async function syncDbSchemas(cwd) {
5174
5353
  changedFiles.push("loom.json");
5175
5354
  }
5176
5355
  if (changedFiles.length) {
5177
- notes.push("No migrations were generated. Review the schema diff, then run `pnpm db:generate` if the schema changed.");
5356
+ const tooling = await getProjectTooling(cwd, manifest);
5357
+ notes.push(`No migrations were generated. Review the schema diff, then run ${(0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "db:generate")} if the schema changed.`);
5178
5358
  }
5179
5359
  return {
5180
5360
  changedFiles: [...new Set(changedFiles)],
@@ -5515,7 +5695,7 @@ async function setupCloudflareR2(cwd, options = {}) {
5515
5695
  if (options.localProvider === "r2" && !options.localBucket) {
5516
5696
  throw new Error("--local-provider r2 requires an explicit --local-bucket.");
5517
5697
  }
5518
- const { packageJson, packageJsonPath } = await readProjectPackageJson(cwd);
5698
+ const { packageJson } = await readProjectPackageJson(cwd);
5519
5699
  const framework = await detectFramework(cwd, packageJson);
5520
5700
  const manifestPath = (0, node_path_1.join)(cwd, "loom.json");
5521
5701
  const manifestText = await readTextIfExists(manifestPath);
@@ -5523,6 +5703,7 @@ async function setupCloudflareR2(cwd, options = {}) {
5523
5703
  throw new Error("Missing loom.json. Run `loom add files` first.");
5524
5704
  }
5525
5705
  const manifest = parseJson(manifestText, "loom.json");
5706
+ const tooling = await getProjectTooling(cwd, manifest);
5526
5707
  const feature = manifest.features.files;
5527
5708
  if (!feature || feature.status !== "active") {
5528
5709
  throw new Error("The files feature is not active. Run `loom add files` first.");
@@ -5680,11 +5861,10 @@ async function setupCloudflareR2(cwd, options = {}) {
5680
5861
  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.`);
5681
5862
  }
5682
5863
  }
5683
- const dependencyUpdate = ensurePackageJsonDependencies(packageJson, "dependencies", FILES_S3_DEPENDENCIES);
5864
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, { dependencies: FILES_S3_DEPENDENCIES });
5684
5865
  if (dependencyUpdate.changed) {
5685
- await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(dependencyUpdate.packageJson), "utf8");
5686
- changedFiles.push("package.json");
5687
- notes.push(`Added files storage dependency: ${dependencyUpdate.changedKeys.join(", ")}.`);
5866
+ changedFiles.push(dependencyUpdate.config);
5867
+ notes.push(`Added files storage dependency: ${dependencyUpdate.changedKeys.join(", ")} to ${dependencyUpdate.config}.`);
5688
5868
  }
5689
5869
  const storagePath = (0, node_path_1.join)(cwd, config.modules.storageModule);
5690
5870
  const storageText = await readTextIfExists(storagePath);
@@ -7137,26 +7317,21 @@ async function applyJobsFeature(cwd, framework, manifest, activate) {
7137
7317
  ? structuredClone(currentFeature)
7138
7318
  : { status: "planned" };
7139
7319
  const config = mergeJobsConfig(framework, feature.config);
7140
- const { packageJsonPath, packageJson } = await readProjectPackageJson(cwd);
7141
- let nextPackageJson = packageJson;
7142
- const dependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "dependencies", JOBS_DEFAULT_DEPENDENCIES);
7143
- nextPackageJson = dependencyUpdate.packageJson;
7144
- const devDependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "devDependencies", JOBS_DEFAULT_DEV_DEPENDENCIES);
7145
- nextPackageJson = devDependencyUpdate.packageJson;
7146
- const scriptsUpdate = ensurePackageJsonScripts(nextPackageJson, getJobsExpectedScripts(config));
7147
- nextPackageJson = scriptsUpdate.packageJson;
7148
- if (dependencyUpdate.changed || devDependencyUpdate.changed ||
7149
- scriptsUpdate.changed) {
7150
- await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
7151
- changedFiles.push("package.json");
7152
- }
7153
- if (dependencyUpdate.changedKeys.length ||
7154
- devDependencyUpdate.changedKeys.length) {
7155
- notes.push(`Added jobs package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
7156
- .join(", ")}`);
7320
+ const tooling = await getProjectTooling(cwd, manifest);
7321
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
7322
+ dependencies: JOBS_DEFAULT_DEPENDENCIES,
7323
+ devDependencies: JOBS_DEFAULT_DEV_DEPENDENCIES,
7324
+ });
7325
+ const scriptsUpdate = await ensureProjectTasks(cwd, manifest, getJobsExpectedScripts(config));
7326
+ if (dependencyUpdate.changed)
7327
+ changedFiles.push(dependencyUpdate.config);
7328
+ if (scriptsUpdate.changedKeys.length)
7329
+ changedFiles.push(scriptsUpdate.config);
7330
+ if (dependencyUpdate.changedKeys.length) {
7331
+ notes.push(`Added jobs dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
7157
7332
  }
7158
7333
  if (scriptsUpdate.changedKeys.length) {
7159
- notes.push(`Updated jobs package.json scripts: ${scriptsUpdate.changedKeys.join(", ")}`);
7334
+ notes.push(`Updated jobs tasks in ${scriptsUpdate.config}: ${scriptsUpdate.changedKeys.join(", ")}`);
7160
7335
  }
7161
7336
  if (activate && feature.status !== "active") {
7162
7337
  feature.status = "active";
@@ -7251,41 +7426,35 @@ async function applyDbFeature(cwd, framework, manifest, activate) {
7251
7426
  }
7252
7427
  feature.config = config;
7253
7428
  manifest.features.db = feature;
7254
- const { packageJsonPath, packageJson } = await readProjectPackageJson(cwd);
7255
- let nextPackageJson = packageJson;
7256
- let packageJsonChanged = false;
7257
- const dependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "dependencies", DB_DEFAULT_DEPENDENCIES);
7258
- nextPackageJson = dependencyUpdate.packageJson;
7259
- packageJsonChanged ||= dependencyUpdate.changed;
7260
- const devDependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "devDependencies", DB_DEFAULT_DEV_DEPENDENCIES);
7261
- nextPackageJson = devDependencyUpdate.packageJson;
7262
- packageJsonChanged ||= devDependencyUpdate.changed;
7263
- const scriptsUpdate = ensurePackageJsonScripts(nextPackageJson, getDbExpectedScripts(config));
7264
- nextPackageJson = scriptsUpdate.packageJson;
7265
- packageJsonChanged ||= scriptsUpdate.changed;
7266
- const removedDependencyUpdate = removePackageJsonDependencies(nextPackageJson, DB_MOVED_DEPENDENCIES);
7267
- nextPackageJson = removedDependencyUpdate.packageJson;
7268
- packageJsonChanged ||= removedDependencyUpdate.changed;
7269
- if (packageJsonChanged) {
7270
- await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
7271
- changedFiles.push("package.json");
7272
- }
7273
- if (dependencyUpdate.changedKeys.length ||
7274
- devDependencyUpdate.changedKeys.length) {
7275
- notes.push(`Added DB package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
7276
- .join(", ")}`);
7429
+ const tooling = await getProjectTooling(cwd, manifest);
7430
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
7431
+ dependencies: DB_DEFAULT_DEPENDENCIES,
7432
+ devDependencies: DB_DEFAULT_DEV_DEPENDENCIES,
7433
+ remove: DB_MOVED_DEPENDENCIES,
7434
+ });
7435
+ const scriptsUpdate = await ensureProjectTasks(cwd, manifest, getDbExpectedScripts(config, tooling));
7436
+ const testRunner = await getDbTestRunner(cwd, tooling);
7437
+ if (dependencyUpdate.changed)
7438
+ changedFiles.push(dependencyUpdate.config);
7439
+ if (scriptsUpdate.changedKeys.length)
7440
+ changedFiles.push(scriptsUpdate.config);
7441
+ if (dependencyUpdate.changedKeys.length) {
7442
+ notes.push(`Added DB dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
7277
7443
  }
7278
7444
  if (scriptsUpdate.changedKeys.length) {
7279
- notes.push(`Updated DB package.json scripts: ${scriptsUpdate.changedKeys.join(", ")}`);
7445
+ notes.push(`Updated DB tasks in ${scriptsUpdate.config}: ${scriptsUpdate.changedKeys.join(", ")}`);
7280
7446
  }
7281
- if (removedDependencyUpdate.removedKeys.length) {
7282
- notes.push(`Removed consumer-managed DB generator dependencies now owned by Loom: ${removedDependencyUpdate.removedKeys.join(", ")}`);
7447
+ if (dependencyUpdate.removedKeys.length) {
7448
+ notes.push(`Removed consumer-managed DB generator dependencies now owned by Loom: ${dependencyUpdate.removedKeys.join(", ")}`);
7283
7449
  }
7284
7450
  const managedFiles = [
7285
7451
  [config.modules.neonModule, dbNeonTemplate()],
7286
7452
  [config.modules.neonFullModule, dbNeonFullTemplate()],
7287
7453
  [config.modules.drizzleConfig, dbDrizzleConfigTemplate(config)],
7288
- [config.modules.pgliteHarnessModule, dbPgliteHarnessTemplate(config)],
7454
+ [
7455
+ config.modules.pgliteHarnessModule,
7456
+ dbPgliteHarnessTemplate(config, testRunner),
7457
+ ],
7289
7458
  [config.modules.scriptsTsconfig, dbScriptsTsconfigTemplate()],
7290
7459
  [
7291
7460
  config.modules.refinementsCommonModule,
@@ -7355,7 +7524,8 @@ async function applyFilesFeature(cwd, framework, manifest, activate) {
7355
7524
  changedFiles.push(...materialized.changedFiles);
7356
7525
  notes.push(...materialized.notes);
7357
7526
  config.schema = materialized.schema;
7358
- 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.");
7527
+ const tooling = await getProjectTooling(cwd, manifest);
7528
+ notes.push(`No migration was generated. Review the schema diff, then run ${(0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "db:generate")} when you are ready to create the app-local migration.`);
7359
7529
  }
7360
7530
  const scaffoldFiles = [
7361
7531
  [
@@ -7427,7 +7597,7 @@ async function applyMailFeature(cwd, framework, manifest, activate) {
7427
7597
  changedFiles.push(...materialized.changedFiles);
7428
7598
  notes.push(...materialized.notes);
7429
7599
  config.schema = materialized.schema;
7430
- 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.");
7600
+ 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.");
7431
7601
  }
7432
7602
  const scaffolds = [
7433
7603
  [config.modules.accessModule, mailAccessTemplate(), "admin access policy"],
@@ -7611,12 +7781,246 @@ async function applyAuthFeature(cwd, framework, manifest, activate) {
7611
7781
  }
7612
7782
  return { changedFiles, notes };
7613
7783
  }
7784
+ function linguiCliCommand(tooling) {
7785
+ switch (tooling.dependencies.manager) {
7786
+ case "deno":
7787
+ return "deno run -A npm:@lingui/cli";
7788
+ case "npm":
7789
+ return "npx lingui";
7790
+ case "pnpm":
7791
+ return "pnpm lingui";
7792
+ case "yarn":
7793
+ return "yarn lingui";
7794
+ }
7795
+ }
7796
+ function linguiConfigTemplate(framework) {
7797
+ const sourceRoot = framework.srcDir ? "src/" : "";
7798
+ return `import { formatter } from "@lingui/format-po";
7799
+
7800
+ /** @type {import("@lingui/conf").LinguiConfig} */
7801
+ export default {
7802
+ locales: ["en"],
7803
+ sourceLocale: "en",
7804
+ catalogs: [
7805
+ {
7806
+ path: "<rootDir>/${sourceRoot}locales/{locale}/messages",
7807
+ include: ["<rootDir>/${sourceRoot}**/*.{ts,tsx}"],
7808
+ },
7809
+ ],
7810
+ format: formatter({ lineNumbers: false }),
7811
+ };
7812
+ `;
7813
+ }
7814
+ function generatedLinguiCatalogsFromConfig(configText, framework) {
7815
+ const paths = [...configText.matchAll(/\bpath\s*:\s*["'`]([^"'`]+)["'`]/g)]
7816
+ .map((match) => match[1])
7817
+ .filter((path) => Boolean(path))
7818
+ .map((path) => path
7819
+ .replace(/^<rootDir>\//, "")
7820
+ .replaceAll("{locale}", "*")
7821
+ .replaceAll("{name}", "*")
7822
+ .replaceAll("\\", "/")
7823
+ .replace(/\.(?:js|po)$/, "") + ".js");
7824
+ return [
7825
+ ...new Set(paths.length
7826
+ ? paths
7827
+ : [`${framework.srcDir ? "src/" : ""}locales/*/messages.js`]),
7828
+ ];
7829
+ }
7830
+ async function findLinguiConfigPath(cwd) {
7831
+ return await findFirstExistingRelativePath(cwd, [
7832
+ ...LINGUI_CONFIG_CANDIDATES,
7833
+ ]);
7834
+ }
7835
+ async function findSourceFilesMatching(cwd, pattern, relativeDir = "") {
7836
+ const results = [];
7837
+ let entries;
7838
+ try {
7839
+ entries = await (0, promises_1.readdir)((0, node_path_1.join)(cwd, relativeDir), { withFileTypes: true });
7840
+ }
7841
+ catch (error) {
7842
+ if (isNodeErrorCode(error, "ENOENT"))
7843
+ return results;
7844
+ throw error;
7845
+ }
7846
+ for (const entry of entries) {
7847
+ const relativePath = relativeDir
7848
+ ? (0, node_path_1.join)(relativeDir, entry.name)
7849
+ : entry.name;
7850
+ if (entry.isDirectory()) {
7851
+ if (!ENV_LOADER_SCAN_IGNORED_DIRS.has(entry.name)) {
7852
+ results.push(...await findSourceFilesMatching(cwd, pattern, relativePath));
7853
+ }
7854
+ continue;
7855
+ }
7856
+ if (!entry.isFile() || !hasScannedSourceExtension(entry.name))
7857
+ continue;
7858
+ const text = await readTextIfExists((0, node_path_1.join)(cwd, relativePath));
7859
+ pattern.lastIndex = 0;
7860
+ if (text && pattern.test(text)) {
7861
+ results.push(relativePath.replaceAll("\\", "/"));
7862
+ }
7863
+ }
7864
+ return results.sort();
7865
+ }
7866
+ async function detectLinguiCatalogMode(cwd) {
7867
+ const poImports = await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']+\.po["']/);
7868
+ if (poImports.length)
7869
+ return "loader";
7870
+ const nextConfigPath = await findNextConfigPath(cwd);
7871
+ const nextConfigText = nextConfigPath
7872
+ ? await readTextIfExists((0, node_path_1.join)(cwd, nextConfigPath))
7873
+ : null;
7874
+ return nextConfigText?.includes("@lingui/loader") ? "loader" : "precompile";
7875
+ }
7876
+ async function getLinguiConfig(cwd, framework, currentConfig) {
7877
+ const configFile = currentConfig?.configFile ??
7878
+ await findLinguiConfigPath(cwd) ?? "lingui.config.ts";
7879
+ const configText = await readTextIfExists((0, node_path_1.join)(cwd, configFile)) ??
7880
+ linguiConfigTemplate(framework);
7881
+ return {
7882
+ catalogMode: currentConfig?.catalogMode ??
7883
+ await detectLinguiCatalogMode(cwd),
7884
+ configFile,
7885
+ generatedCatalogs: currentConfig?.generatedCatalogs?.length
7886
+ ? [...new Set(currentConfig.generatedCatalogs)]
7887
+ : generatedLinguiCatalogsFromConfig(configText, framework),
7888
+ tasks: {
7889
+ ...LINGUI_DEFAULT_TASKS,
7890
+ ...currentConfig?.tasks,
7891
+ },
7892
+ };
7893
+ }
7894
+ function linguiTaskRuns(command, action) {
7895
+ return Boolean(command?.includes("lingui") &&
7896
+ new RegExp(`(?:^|\\s)${action}(?:\\s|$)`).test(command));
7897
+ }
7898
+ function dependencyMajor(spec) {
7899
+ const match = spec?.match(/(?:^|[^0-9])(\d+)\./);
7900
+ return match ? Number(match[1]) : null;
7901
+ }
7902
+ function linguiPoDeclarationTemplate() {
7903
+ return `declare module "*.po" {
7904
+ import type { Messages } from "@lingui/core";
7905
+
7906
+ export const messages: Messages;
7907
+ }
7908
+ `;
7909
+ }
7910
+ async function applyLinguiFeature(cwd, framework, manifest, activate) {
7911
+ const changedFiles = [];
7912
+ const notes = [];
7913
+ const currentFeature = manifest.features.lingui;
7914
+ const config = await getLinguiConfig(cwd, framework, currentFeature?.config);
7915
+ const feature = currentFeature
7916
+ ? structuredClone(currentFeature)
7917
+ : { status: "planned" };
7918
+ if (activate && feature.status !== "active") {
7919
+ feature.status = "active";
7920
+ feature.activatedOn ??= todayIso();
7921
+ }
7922
+ feature.config = config;
7923
+ manifest.features.lingui = feature;
7924
+ const { packageJson } = await readProjectPackageJson(cwd);
7925
+ const tooling = await getProjectTooling(cwd, manifest);
7926
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
7927
+ dependencies: LINGUI_DEFAULT_DEPENDENCIES,
7928
+ devDependencies: {
7929
+ ...LINGUI_DEFAULT_DEV_DEPENDENCIES,
7930
+ ...(config.catalogMode === "loader"
7931
+ ? LINGUI_LOADER_DEV_DEPENDENCIES
7932
+ : {}),
7933
+ },
7934
+ });
7935
+ if (dependencyUpdate.changed)
7936
+ changedFiles.push(dependencyUpdate.config);
7937
+ const configState = await scaffoldTextFile((0, node_path_1.join)(cwd, config.configFile), linguiConfigTemplate(framework));
7938
+ if (configState === "created") {
7939
+ changedFiles.push(config.configFile);
7940
+ notes.push(`Scaffolded ${config.configFile} with an English starter locale; update its locales and catalog include paths for the app.`);
7941
+ }
7942
+ else if (activate && configState === "preserved") {
7943
+ notes.push(`Preserved existing Lingui config: ${config.configFile}`);
7944
+ }
7945
+ const taskChanges = [];
7946
+ const executable = linguiCliCommand(tooling);
7947
+ for (const [name, command] of [
7948
+ [config.tasks.extract, `${executable} extract --clean`],
7949
+ [config.tasks.compile, `${executable} compile`],
7950
+ ]) {
7951
+ const result = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
7952
+ definition: command,
7953
+ name,
7954
+ });
7955
+ if (result.changed)
7956
+ taskChanges.push(name);
7957
+ }
7958
+ let taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
7959
+ if (!(0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.build])) {
7960
+ const result = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
7961
+ definition: framework.kind === "nextjs" ? "next build" : "build",
7962
+ name: config.tasks.build,
7963
+ });
7964
+ if (result.changed)
7965
+ taskChanges.push(config.tasks.build);
7966
+ taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
7967
+ }
7968
+ const buildCommand = (0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.build]);
7969
+ if (config.catalogMode === "precompile" && buildCommand &&
7970
+ !(0, projectTooling_js_1.taskInvokes)(taskStore, config.tasks.build, config.tasks.compile)) {
7971
+ const result = await (0, projectTooling_js_1.ensureTaskPrerequisite)(cwd, tooling.tasks, config.tasks.build, config.tasks.compile);
7972
+ if (result.changed)
7973
+ taskChanges.push(config.tasks.build);
7974
+ }
7975
+ if (taskChanges.length)
7976
+ changedFiles.push(tooling.tasks.config);
7977
+ const gitignorePath = (0, node_path_1.join)(cwd, ".gitignore");
7978
+ const gitignoreUpdate = ensureLinguiGitignoreText(await readTextIfExists(gitignorePath), config.generatedCatalogs);
7979
+ if (gitignoreUpdate.changed) {
7980
+ await (0, promises_1.writeFile)(gitignorePath, gitignoreUpdate.text, "utf8");
7981
+ changedFiles.push(".gitignore");
7982
+ }
7983
+ if (config.catalogMode === "loader") {
7984
+ const poDeclarations = await findSourceFilesMatching(cwd, /declare\s+module\s+["']\*\.po["']/);
7985
+ if (!poDeclarations.length) {
7986
+ const declarationPath = `${framework.srcDir ? "src/" : ""}lingui.d.ts`;
7987
+ if (await writeTextIfChanged((0, node_path_1.join)(cwd, declarationPath), linguiPoDeclarationTemplate())) {
7988
+ changedFiles.push(declarationPath);
7989
+ }
7990
+ }
7991
+ }
7992
+ if (framework.kind === "nextjs") {
7993
+ const nextConfigPath = await findNextConfigPath(cwd);
7994
+ const nextConfigText = nextConfigPath
7995
+ ? await readTextIfExists((0, node_path_1.join)(cwd, nextConfigPath))
7996
+ : null;
7997
+ if (!nextConfigText?.includes("@lingui/swc-plugin")) {
7998
+ notes.push("Add @lingui/swc-plugin to experimental.swcPlugins in the app-owned Next config.");
7999
+ }
8000
+ if (config.catalogMode === "loader" &&
8001
+ !nextConfigText?.includes("@lingui/loader")) {
8002
+ notes.push("Add @lingui/loader .po rules for Turbopack and webpack in the app-owned Next config.");
8003
+ }
8004
+ }
8005
+ if (dependencyUpdate.changedKeys.length) {
8006
+ notes.push(`Added Lingui dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
8007
+ }
8008
+ if (taskChanges.length) {
8009
+ notes.push(`Updated Lingui tasks in ${tooling.tasks.config}: ${[...new Set(taskChanges)].join(", ")}`);
8010
+ }
8011
+ if (packageJson.dependencies?.["@lingui/macro"] ||
8012
+ packageJson.devDependencies?.["@lingui/macro"]) {
8013
+ notes.push("The legacy @lingui/macro package remains app-owned; migrate imports to the v6 macro entrypoints before removing it.");
8014
+ }
8015
+ return { changedFiles, notes };
8016
+ }
7614
8017
  async function applyPwaFeature(cwd, framework, manifest, activate) {
7615
8018
  const changedFiles = [];
7616
8019
  const notes = [];
7617
8020
  const currentFeature = manifest.features.pwa;
7618
8021
  const currentConfig = currentFeature?.config;
7619
- const { packageJsonPath, packageJson } = await readProjectPackageJson(cwd);
8022
+ const { packageJson } = await readProjectPackageJson(cwd);
8023
+ const tooling = await getProjectTooling(cwd, manifest);
7620
8024
  const config = await getPwaConfig(cwd, framework, packageJson, currentConfig, activate);
7621
8025
  const feature = currentFeature
7622
8026
  ? structuredClone(currentFeature)
@@ -7627,31 +8031,48 @@ async function applyPwaFeature(cwd, framework, manifest, activate) {
7627
8031
  }
7628
8032
  feature.config = config;
7629
8033
  manifest.features.pwa = feature;
7630
- let nextPackageJson = packageJson;
7631
- let packageJsonChanged = false;
7632
- const dependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "dependencies", PWA_DEFAULT_DEPENDENCIES);
7633
- nextPackageJson = dependencyUpdate.packageJson;
7634
- packageJsonChanged ||= dependencyUpdate.changed;
7635
- const devDependencyUpdate = ensurePackageJsonDependencies(nextPackageJson, "devDependencies", PWA_DEFAULT_DEV_DEPENDENCIES);
7636
- nextPackageJson = devDependencyUpdate.packageJson;
7637
- packageJsonChanged ||= devDependencyUpdate.changed;
7638
- const packageManager = await detectPackageManager(cwd, nextPackageJson);
7639
- const scriptsUpdate = ensurePwaPackageJsonScripts(nextPackageJson, packageManager);
7640
- nextPackageJson = scriptsUpdate.packageJson;
7641
- packageJsonChanged ||= scriptsUpdate.changed;
7642
- if (packageJsonChanged) {
7643
- await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
7644
- changedFiles.push("package.json");
7645
- }
7646
- if (dependencyUpdate.changedKeys.length ||
7647
- devDependencyUpdate.changedKeys.length) {
7648
- notes.push(`Added PWA package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
7649
- .join(", ")}`);
8034
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
8035
+ dependencies: PWA_DEFAULT_DEPENDENCIES,
8036
+ devDependencies: PWA_DEFAULT_DEV_DEPENDENCIES,
8037
+ });
8038
+ if (dependencyUpdate.changed)
8039
+ changedFiles.push(dependencyUpdate.config);
8040
+ const scriptsChanged = [];
8041
+ const pwaTask = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
8042
+ definition: PWA_BUILD_SCRIPT,
8043
+ name: "pwa:build",
8044
+ });
8045
+ if (pwaTask.changed)
8046
+ scriptsChanged.push("pwa:build");
8047
+ const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
8048
+ const buildCommand = (0, projectTooling_js_1.getTaskCommand)(taskStore.definitions.build);
8049
+ if (!buildCommand) {
8050
+ const build = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
8051
+ definition: `next build && ${(0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "pwa:build")}`,
8052
+ name: "build",
8053
+ });
8054
+ if (build.changed)
8055
+ scriptsChanged.push("build");
7650
8056
  }
7651
- if (scriptsUpdate.changedKeys.length) {
7652
- notes.push(`Updated PWA package.json scripts: ${scriptsUpdate.changedKeys.join(", ")}`);
8057
+ else if (buildCommand.includes("next build") &&
8058
+ !(0, projectTooling_js_1.taskInvokes)(taskStore, "build", "pwa:build") &&
8059
+ !scriptRunsSerwistBuild(buildCommand)) {
8060
+ const build = await (0, projectTooling_js_1.ensureTaskFollowup)(cwd, tooling.tasks, "build", "pwa:build");
8061
+ if (build.changed)
8062
+ scriptsChanged.push("build");
8063
+ }
8064
+ else if (!(0, projectTooling_js_1.taskInvokes)(taskStore, "build", "pwa:build") &&
8065
+ !scriptRunsSerwistBuild(buildCommand)) {
8066
+ 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.");
8067
+ }
8068
+ if (scriptsChanged.length)
8069
+ changedFiles.push(tooling.tasks.config);
8070
+ if (dependencyUpdate.changedKeys.length) {
8071
+ notes.push(`Added PWA dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
8072
+ }
8073
+ if (scriptsChanged.length) {
8074
+ notes.push(`Updated PWA tasks in ${tooling.tasks.config}: ${scriptsChanged.join(", ")}`);
7653
8075
  }
7654
- notes.push(...scriptsUpdate.notes);
7655
8076
  const serwistConfigState = await scaffoldTextFile((0, node_path_1.join)(cwd, config.modules.serwistConfig), pwaSerwistConfigTemplate(config));
7656
8077
  if (serwistConfigState === "created") {
7657
8078
  changedFiles.push(config.modules.serwistConfig);
@@ -7705,13 +8126,13 @@ async function checkJobsFeature(cwd, framework, manifest) {
7705
8126
  return { issues, suggestions: [], warnings: [] };
7706
8127
  }
7707
8128
  const config = mergeJobsConfig(framework, feature.config);
7708
- const { packageJson } = await readProjectPackageJson(cwd);
7709
8129
  const expectedScripts = getJobsExpectedScripts(config);
7710
- for (const [scriptName, scriptCommand] of Object.entries(expectedScripts)) {
7711
- if (packageJson.scripts?.[scriptName] !== scriptCommand) {
7712
- issues.push(`Jobs package.json script does not match Loom defaults: ${scriptName}`);
7713
- suggestions.add("Run `loom add jobs`.");
7714
- }
8130
+ const taskCheck = await checkProjectTasks(cwd, manifest, expectedScripts);
8131
+ for (const taskName of taskCheck.mismatches) {
8132
+ issues.push(taskCheck.config === "package.json"
8133
+ ? `Jobs package.json script does not match Loom defaults: ${taskName}`
8134
+ : `Jobs task in ${taskCheck.config} does not match Loom defaults: ${taskName}`);
8135
+ suggestions.add("Run `loom add jobs`.");
7715
8136
  }
7716
8137
  const requiredFiles = [
7717
8138
  JOBS_SCRIPTS_TSCONFIG_PATH,
@@ -7868,7 +8289,9 @@ async function checkDbFeature(cwd, framework, manifest, options) {
7868
8289
  }
7869
8290
  const config = mergeDbConfig(framework, feature.config);
7870
8291
  const { packageJson } = await readProjectPackageJson(cwd);
7871
- const expectedScripts = getDbExpectedScripts(config);
8292
+ const tooling = await getProjectTooling(cwd, manifest);
8293
+ const testRunner = await getDbTestRunner(cwd, tooling);
8294
+ const expectedScripts = getDbExpectedScripts(config, tooling);
7872
8295
  const migrationFlowCheck = await checkDbProductionMigrationFlow(cwd, options.production ?? false);
7873
8296
  issues.push(...migrationFlowCheck.issues);
7874
8297
  warnings.push(...migrationFlowCheck.warnings);
@@ -7876,29 +8299,36 @@ async function checkDbFeature(cwd, framework, manifest, options) {
7876
8299
  suggestions.add(suggestion);
7877
8300
  }
7878
8301
  for (const dependencyName of Object.keys(DB_DEFAULT_DEPENDENCIES)) {
7879
- if (!packageJson.dependencies?.[dependencyName]) {
7880
- issues.push(`DB dependency is missing from package.json dependencies: ${dependencyName}`);
8302
+ if (!hasPackageDependency(packageJson, dependencyName)) {
8303
+ issues.push(tooling.dependencies.config === "package.json"
8304
+ ? `DB dependency is missing from package.json dependencies: ${dependencyName}`
8305
+ : `DB dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
7881
8306
  suggestions.add("Run `loom add db`.");
7882
8307
  }
7883
8308
  }
7884
8309
  for (const dependencyName of Object.keys(DB_DEFAULT_DEV_DEPENDENCIES)) {
7885
- if (!packageJson.devDependencies?.[dependencyName]) {
7886
- issues.push(`DB dependency is missing from package.json devDependencies: ${dependencyName}`);
8310
+ if (!hasPackageDependency(packageJson, dependencyName)) {
8311
+ issues.push(tooling.dependencies.config === "package.json"
8312
+ ? `DB dependency is missing from package.json devDependencies: ${dependencyName}`
8313
+ : `DB development dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
7887
8314
  suggestions.add("Run `loom add db`.");
7888
8315
  }
7889
8316
  }
7890
8317
  for (const dependencyName of DB_MOVED_DEPENDENCIES) {
7891
8318
  if (packageJson.dependencies?.[dependencyName] ||
7892
8319
  packageJson.devDependencies?.[dependencyName]) {
7893
- issues.push(`Consumer package.json still declares a Loom-managed DB generator dependency: ${dependencyName}`);
7894
- suggestions.add("Run `loom add db` to rewrite package.json.");
8320
+ issues.push(tooling.dependencies.config === "package.json"
8321
+ ? `Consumer package.json still declares a Loom-managed DB generator dependency: ${dependencyName}`
8322
+ : `Consumer ${tooling.dependencies.config} still declares a Loom-managed DB generator dependency: ${dependencyName}`);
8323
+ suggestions.add(`Run loom add db to rewrite ${tooling.dependencies.config}.`);
7895
8324
  }
7896
8325
  }
7897
- for (const [scriptName, scriptCommand] of Object.entries(expectedScripts)) {
7898
- if (packageJson.scripts?.[scriptName] !== scriptCommand) {
7899
- issues.push(`DB package.json script does not match Loom defaults: ${scriptName}`);
7900
- suggestions.add("Run `loom add db`.");
7901
- }
8326
+ const taskCheck = await checkProjectTasks(cwd, manifest, expectedScripts);
8327
+ for (const taskName of taskCheck.mismatches) {
8328
+ issues.push(taskCheck.config === "package.json"
8329
+ ? `DB package.json script does not match Loom defaults: ${taskName}`
8330
+ : `DB task in ${taskCheck.config} does not match Loom defaults: ${taskName}`);
8331
+ suggestions.add("Run `loom add db`.");
7902
8332
  }
7903
8333
  const requiredFiles = [
7904
8334
  config.modules.neonModule,
@@ -7934,7 +8364,7 @@ async function checkDbFeature(cwd, framework, manifest, options) {
7934
8364
  ],
7935
8365
  [
7936
8366
  config.modules.pgliteHarnessModule,
7937
- dbPgliteHarnessTemplate(config),
8367
+ dbPgliteHarnessTemplate(config, testRunner),
7938
8368
  "PGlite test harness does not match the Loom-managed wrapper",
7939
8369
  ],
7940
8370
  [
@@ -8025,6 +8455,8 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
8025
8455
  const dbConfig = mergeDbConfig(framework, dbFeature.config);
8026
8456
  const config = getFilesConfig(framework, dbConfig, feature.config);
8027
8457
  const { packageJson } = await readProjectPackageJson(cwd);
8458
+ const tooling = await getProjectTooling(cwd, manifest);
8459
+ const generateCommand = (0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "db:generate");
8028
8460
  const schema = config.schema;
8029
8461
  const latestSchema = getLatestManagedSchemaConfig(schema);
8030
8462
  if (schema.mode !== "managed-local" || schema.blueprint !== "files") {
@@ -8038,7 +8470,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
8038
8470
  }
8039
8471
  else if (schema.version < supportedVersion) {
8040
8472
  warnings.push(`Files schema blueprint is stale: ${schema.version} < ${supportedVersion}.`);
8041
- suggestions.add("Run `loom db schemas sync`, review the schema diff, then run `pnpm db:generate` if the schema changed.");
8473
+ suggestions.add(`Run loom db schemas sync, review the schema diff, then run ${generateCommand} if the schema changed.`);
8042
8474
  }
8043
8475
  const schemaRelativeToDir = (0, node_path_1.relative)(dbConfig.dirs.schemaDir, schema.module)
8044
8476
  .replaceAll("\\", "/");
@@ -8053,7 +8485,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
8053
8485
  const schemaText = await readTextIfExists((0, node_path_1.join)(cwd, schema.module));
8054
8486
  if (!schemaText) {
8055
8487
  issues.push(`Files schema file is missing: ${schema.module}`);
8056
- suggestions.add("Run `loom db schemas sync`, review the schema diff, then run `pnpm db:generate` if the schema changed.");
8488
+ suggestions.add(`Run loom db schemas sync, review the schema diff, then run ${generateCommand} if the schema changed.`);
8057
8489
  }
8058
8490
  else {
8059
8491
  const currentHash = hashManagedSchemaText(schemaText);
@@ -8169,8 +8601,8 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
8169
8601
  suggestions.add("Replace the generated files storage stub with an S3 or app-specific storage adapter before production use.");
8170
8602
  }
8171
8603
  if (config.storage.adapter === "s3") {
8172
- if (!packageJson.dependencies?.["@aws-sdk/client-s3"]) {
8173
- issues.push("Files S3/R2 storage requires @aws-sdk/client-s3 in package.json dependencies.");
8604
+ if (!hasPackageDependency(packageJson, "@aws-sdk/client-s3")) {
8605
+ issues.push(`Files S3/R2 storage requires @aws-sdk/client-s3 in ${tooling.dependencies.config}.`);
8174
8606
  suggestions.add("Run `loom files r2 setup` to restore the dependency.");
8175
8607
  }
8176
8608
  for (const envName of FILES_S3_REQUIRED_ENV_NAMES) {
@@ -8654,6 +9086,125 @@ async function findNextConfigPath(cwd) {
8654
9086
  ];
8655
9087
  return await findFirstExistingRelativePath(cwd, candidates);
8656
9088
  }
9089
+ async function checkLinguiFeature(cwd, framework, manifest, options) {
9090
+ const issues = [];
9091
+ const suggestions = new Set();
9092
+ const warnings = [];
9093
+ const feature = manifest.features.lingui;
9094
+ if (!feature || feature.status !== "active") {
9095
+ return { issues, suggestions: [], warnings };
9096
+ }
9097
+ const { packageJson } = await readProjectPackageJson(cwd);
9098
+ const tooling = await getProjectTooling(cwd, manifest);
9099
+ const config = await getLinguiConfig(cwd, framework, feature.config);
9100
+ const requiredDependencies = {
9101
+ ...LINGUI_DEFAULT_DEPENDENCIES,
9102
+ ...LINGUI_DEFAULT_DEV_DEPENDENCIES,
9103
+ ...(config.catalogMode === "loader" ? LINGUI_LOADER_DEV_DEPENDENCIES : {}),
9104
+ };
9105
+ for (const dependencyName of Object.keys(requiredDependencies)) {
9106
+ if (!hasPackageDependency(packageJson, dependencyName)) {
9107
+ issues.push(`Lingui dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
9108
+ suggestions.add("Run `loom add lingui`.");
9109
+ }
9110
+ }
9111
+ if (!await exists((0, node_path_1.join)(cwd, config.configFile))) {
9112
+ issues.push(`Lingui config is missing: ${config.configFile}`);
9113
+ suggestions.add("Run `loom add lingui`.");
9114
+ }
9115
+ const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
9116
+ if (!linguiTaskRuns((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.extract]), "extract")) {
9117
+ issues.push(`Lingui extraction task is missing or invalid in ${tooling.tasks.config}: ${config.tasks.extract}`);
9118
+ suggestions.add("Run `loom add lingui`.");
9119
+ }
9120
+ if (!linguiTaskRuns((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.compile]), "compile")) {
9121
+ issues.push(`Lingui compile task is missing or invalid in ${tooling.tasks.config}: ${config.tasks.compile}`);
9122
+ suggestions.add("Run `loom add lingui`.");
9123
+ }
9124
+ if (config.catalogMode === "precompile") {
9125
+ if (!(0, projectTooling_js_1.taskInvokes)(taskStore, config.tasks.build, config.tasks.compile)) {
9126
+ issues.push(`Build task does not compile Lingui catalogs in ${tooling.tasks.config}: ${config.tasks.build}`);
9127
+ suggestions.add("Run `loom add lingui`.");
9128
+ }
9129
+ else {
9130
+ const buildCommand = (0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.build]);
9131
+ if (buildCommand?.includes("next build") &&
9132
+ !(0, projectTooling_js_1.taskRunsBeforeCommand)(taskStore, config.tasks.build, config.tasks.compile, "next build")) {
9133
+ issues.push(`Lingui catalogs are compiled after Next.js starts building in ${tooling.tasks.config}: ${config.tasks.build}`);
9134
+ suggestions.add(`Run ${config.tasks.compile} before the framework build command.`);
9135
+ }
9136
+ }
9137
+ }
9138
+ const gitignoreUpdate = ensureLinguiGitignoreText(await readTextIfExists((0, node_path_1.join)(cwd, ".gitignore")), config.generatedCatalogs);
9139
+ if (gitignoreUpdate.missingLines.length) {
9140
+ issues.push(`Lingui generated catalogs are missing from .gitignore: ${gitignoreUpdate.missingLines.join(", ")}`);
9141
+ suggestions.add("Run `loom add lingui`.");
9142
+ }
9143
+ const gitResult = await (options.commandRunner ?? defaultCommandRunner)("git", ["ls-files", "--", ...config.generatedCatalogs], { cwd, stdio: "pipe" });
9144
+ const trackedCatalogs = gitResult.code === 0
9145
+ ? gitResult.stdout.trim().split(/\r?\n/).filter(Boolean)
9146
+ : [];
9147
+ if (trackedCatalogs.length) {
9148
+ issues.push(`Lingui generated catalogs are still tracked by git: ${trackedCatalogs.join(", ")}`);
9149
+ suggestions.add("Remove generated catalogs from the git index while keeping the source .po catalogs tracked.");
9150
+ }
9151
+ const nextConfigPath = await findNextConfigPath(cwd);
9152
+ const nextConfigText = nextConfigPath
9153
+ ? await readTextIfExists((0, node_path_1.join)(cwd, nextConfigPath))
9154
+ : null;
9155
+ if (framework.kind === "nextjs") {
9156
+ if (!nextConfigText?.includes("@lingui/swc-plugin")) {
9157
+ issues.push(`Next config is missing @lingui/swc-plugin${nextConfigPath ? `: ${nextConfigPath}` : "."}`);
9158
+ suggestions.add("Add @lingui/swc-plugin to experimental.swcPlugins in the Next config.");
9159
+ }
9160
+ if (config.catalogMode === "loader" &&
9161
+ !nextConfigText?.includes("@lingui/loader")) {
9162
+ issues.push(`Lingui loader mode is not wired in the Next config${nextConfigPath ? `: ${nextConfigPath}` : "."}`);
9163
+ suggestions.add("Add matching .po rules for Turbopack and webpack, or switch the manifest to precompile mode.");
9164
+ }
9165
+ if (nextConfigText && /\breactCompiler\s*:\s*true/.test(nextConfigText)) {
9166
+ 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.");
9167
+ }
9168
+ }
9169
+ const poImports = await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']+\.po["']/);
9170
+ if (config.catalogMode === "precompile" && poImports.length) {
9171
+ issues.push(`Lingui is configured for precompile mode but source files import .po catalogs: ${poImports.join(", ")}`);
9172
+ suggestions.add("Switch loom.json to loader mode or import the generated .js catalogs.");
9173
+ }
9174
+ if (config.catalogMode === "loader" && !poImports.length) {
9175
+ warnings.push("Lingui is configured for loader mode, but no source .po imports were found.");
9176
+ }
9177
+ if (config.catalogMode === "loader") {
9178
+ const poDeclarations = await findSourceFilesMatching(cwd, /declare\s+module\s+["']\*\.po["']/);
9179
+ if (!poDeclarations.length) {
9180
+ issues.push("Lingui loader mode is missing a TypeScript *.po module declaration.");
9181
+ suggestions.add("Run `loom add lingui`.");
9182
+ }
9183
+ }
9184
+ const configImports = (await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']*lingui\.config(?:\.[cm]?[jt]s)?["']/)).filter((relativePath) => relativePath !== config.configFile);
9185
+ if (configImports.length) {
9186
+ warnings.push(`Lingui config is imported by runtime source; keep config evaluation build-time only: ${configImports.join(", ")}`);
9187
+ }
9188
+ const linguiCoreMajor = dependencyMajor(packageJson.dependencies?.["@lingui/core"] ??
9189
+ packageJson.devDependencies?.["@lingui/core"]);
9190
+ const legacyMacroSpec = packageJson.dependencies?.["@lingui/macro"] ??
9191
+ packageJson.devDependencies?.["@lingui/macro"];
9192
+ if (legacyMacroSpec && linguiCoreMajor !== null &&
9193
+ dependencyMajor(legacyMacroSpec) !== linguiCoreMajor) {
9194
+ warnings.push(`Legacy @lingui/macro (${legacyMacroSpec}) does not match @lingui/core's major version; prefer @lingui/react/macro and @lingui/core/macro imports.`);
9195
+ }
9196
+ const linguiFamilyMajors = Object.keys(requiredDependencies).flatMap((dependencyName) => {
9197
+ const spec = packageJson.dependencies?.[dependencyName] ??
9198
+ packageJson.devDependencies?.[dependencyName];
9199
+ const major = dependencyMajor(spec);
9200
+ return major === null ? [] : [`${dependencyName}@${major}`];
9201
+ });
9202
+ if (new Set(linguiFamilyMajors.map((entry) => entry.split("@").at(-1))).size >
9203
+ 1) {
9204
+ warnings.push(`Lingui packages span multiple major versions: ${linguiFamilyMajors.join(", ")}`);
9205
+ }
9206
+ return { issues, suggestions: [...suggestions], warnings };
9207
+ }
8657
9208
  async function checkPwaFeature(cwd, framework, manifest) {
8658
9209
  const issues = [];
8659
9210
  const suggestions = new Set();
@@ -8663,6 +9214,7 @@ async function checkPwaFeature(cwd, framework, manifest) {
8663
9214
  return { issues, suggestions: [], warnings };
8664
9215
  }
8665
9216
  const { packageJson } = await readProjectPackageJson(cwd);
9217
+ const tooling = await getProjectTooling(cwd, manifest);
8666
9218
  const config = await getPwaConfig(cwd, framework, packageJson, feature.config, false);
8667
9219
  const hasMui = hasPackageDependency(packageJson, "@mui/material");
8668
9220
  if (framework.kind !== "nextjs" || framework.router !== "app") {
@@ -8670,23 +9222,25 @@ async function checkPwaFeature(cwd, framework, manifest) {
8670
9222
  suggestions.add("Update loom.json if this project intentionally uses a custom PWA integration.");
8671
9223
  }
8672
9224
  for (const dependencyName of Object.keys(PWA_DEFAULT_DEPENDENCIES)) {
8673
- if (!packageJson.dependencies?.[dependencyName]) {
8674
- issues.push(`PWA dependency is missing from package.json dependencies: ${dependencyName}`);
9225
+ if (!hasPackageDependency(packageJson, dependencyName)) {
9226
+ issues.push(`PWA dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
8675
9227
  suggestions.add("Run `loom add pwa`.");
8676
9228
  }
8677
9229
  }
8678
9230
  for (const dependencyName of Object.keys(PWA_DEFAULT_DEV_DEPENDENCIES)) {
8679
- if (!packageJson.devDependencies?.[dependencyName]) {
8680
- issues.push(`PWA dependency is missing from package.json devDependencies: ${dependencyName}`);
9231
+ if (!hasPackageDependency(packageJson, dependencyName)) {
9232
+ issues.push(`PWA development dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
8681
9233
  suggestions.add("Run `loom add pwa`.");
8682
9234
  }
8683
9235
  }
8684
- if (!scriptRunsSerwistBuild(packageJson.scripts?.["pwa:build"])) {
8685
- issues.push("PWA package.json script does not build Serwist: pwa:build");
9236
+ const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
9237
+ if (!scriptRunsSerwistBuild((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions["pwa:build"]))) {
9238
+ issues.push(`PWA task in ${tooling.tasks.config} does not build Serwist: pwa:build`);
8686
9239
  suggestions.add("Run `loom add pwa`.");
8687
9240
  }
8688
- if (!scriptRunsSerwistBuild(packageJson.scripts?.build)) {
8689
- issues.push("PWA package.json build script does not run Serwist after the Next.js build.");
9241
+ if (!scriptRunsSerwistBuild((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions.build)) &&
9242
+ !(0, projectTooling_js_1.taskInvokes)(taskStore, "build", "pwa:build")) {
9243
+ issues.push(`PWA build task in ${tooling.tasks.config} does not run Serwist after the Next.js build.`);
8690
9244
  suggestions.add("Run `loom add pwa`.");
8691
9245
  }
8692
9246
  const gitignoreUpdate = ensurePwaGitignoreText(await readTextIfExists((0, node_path_1.join)(cwd, ".gitignore")));
@@ -8867,6 +9421,10 @@ const featureHooks = {
8867
9421
  apply: applyJobsFeature,
8868
9422
  check: checkJobsFeature,
8869
9423
  },
9424
+ lingui: {
9425
+ apply: applyLinguiFeature,
9426
+ check: checkLinguiFeature,
9427
+ },
8870
9428
  mail: {
8871
9429
  apply: applyMailFeature,
8872
9430
  check: checkMailFeature,
@@ -8894,11 +9452,14 @@ async function ensureActiveFeatureScaffolds(cwd, framework, manifest) {
8894
9452
  async function initProject(cwd, versionRange) {
8895
9453
  const changedFiles = [];
8896
9454
  const notes = [];
8897
- const packageJsonPath = (0, node_path_1.join)(cwd, "package.json");
8898
- const packageJsonText = await readTextIfExists(packageJsonPath);
8899
- if (!packageJsonText) {
8900
- throw new Error(`No package.json found in ${cwd}`);
8901
- }
9455
+ const loomManifestPath = (0, node_path_1.join)(cwd, "loom.json");
9456
+ const existingManifestText = await readTextIfExists(loomManifestPath);
9457
+ const existingManifest = existingManifestText
9458
+ ? parseJson(existingManifestText, "loom.json")
9459
+ : null;
9460
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, existingManifest?.project?.tooling);
9461
+ const initialMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
9462
+ const initialPackageJson = initialMetadata.packageJson;
8902
9463
  const npmrcPath = (0, node_path_1.join)(cwd, ".npmrc");
8903
9464
  const npmrcUpdate = removeLegacyLoomNpmrcText(await readTextIfExists(npmrcPath));
8904
9465
  if (npmrcUpdate.changed) {
@@ -8906,19 +9467,23 @@ async function initProject(cwd, versionRange) {
8906
9467
  changedFiles.push(".npmrc");
8907
9468
  notes.push("Removed Loom's obsolete GitHub Packages registry configuration.");
8908
9469
  }
8909
- const packageJson = parseJson(packageJsonText, "package.json");
8910
- const dependencyUpdate = ensurePackageJsonDependency(packageJson, versionRange ?? getPublishedLoomDependencySpec(packageJson));
9470
+ const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
9471
+ dependencies: {
9472
+ [exports.LOOM_DEPENDENCY]: versionRange ??
9473
+ getPublishedLoomDependencySpec(initialPackageJson),
9474
+ },
9475
+ replace: true,
9476
+ });
8911
9477
  if (dependencyUpdate.changed) {
8912
- await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(dependencyUpdate.packageJson), "utf8");
8913
- changedFiles.push("package.json");
9478
+ changedFiles.push(tooling.dependencies.config);
9479
+ if (tooling.dependencies.config !== "package.json") {
9480
+ notes.push(`Recorded ${exports.LOOM_DEPENDENCY} in ${tooling.dependencies.config} imports and enabled Deno's local node_modules directory when needed.`);
9481
+ }
8914
9482
  }
8915
- const framework = await detectFramework(cwd, dependencyUpdate.packageJson);
8916
- const loomManifestPath = (0, node_path_1.join)(cwd, "loom.json");
8917
- const existingManifestText = await readTextIfExists(loomManifestPath);
8918
- const existingManifest = existingManifestText
8919
- ? parseJson(existingManifestText, "loom.json")
8920
- : null;
8921
- const manifest = buildManifest(cwd, dependencyUpdate.packageJson, framework, existingManifest);
9483
+ const packageJson = (await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd))
9484
+ .packageJson;
9485
+ const framework = await detectFramework(cwd, packageJson);
9486
+ const manifest = buildManifest(cwd, packageJson, framework, existingManifest, tooling);
8922
9487
  const featureInit = await ensureActiveFeatureScaffolds(cwd, framework, manifest);
8923
9488
  changedFiles.push(...featureInit.changedFiles);
8924
9489
  notes.push(...featureInit.notes);
@@ -8929,7 +9494,7 @@ async function initProject(cwd, versionRange) {
8929
9494
  if (agentsInit.changed) {
8930
9495
  changedFiles.push("AGENTS.md");
8931
9496
  }
8932
- const nextAgentsInit = await ensureNextAgentsFile(cwd, dependencyUpdate.packageJson);
9497
+ const nextAgentsInit = await ensureNextAgentsFile(cwd, packageJson);
8933
9498
  if (nextAgentsInit.changed)
8934
9499
  changedFiles.push("AGENTS.md");
8935
9500
  if (nextAgentsInit.note)
@@ -8953,7 +9518,8 @@ async function initProject(cwd, versionRange) {
8953
9518
  framework,
8954
9519
  manifest,
8955
9520
  notes,
8956
- packageJson: parseJson(await (0, promises_1.readFile)(packageJsonPath, "utf8"), "package.json"),
9521
+ packageJson: (await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd))
9522
+ .packageJson,
8957
9523
  };
8958
9524
  }
8959
9525
  async function addFeature(cwd, featureKey, versionRange) {
@@ -9099,18 +9665,20 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
9099
9665
  const issues = [];
9100
9666
  const suggestions = new Set();
9101
9667
  const warnings = [];
9102
- const packageJsonPath = (0, node_path_1.join)(cwd, "package.json");
9103
- const packageJsonText = await readTextIfExists(packageJsonPath);
9104
- if (!packageJsonText) {
9668
+ let projectMetadata;
9669
+ try {
9670
+ projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
9671
+ }
9672
+ catch (error) {
9105
9673
  return {
9106
- issues: [`Missing ${packageJsonPath}`],
9674
+ issues: [error.message],
9107
9675
  suggestions: [
9108
- "Run `loom init` from a project that already has package.json.",
9676
+ "Run `loom init` from a project with package.json, deno.json, or deno.jsonc.",
9109
9677
  ],
9110
9678
  warnings: [],
9111
9679
  };
9112
9680
  }
9113
- const packageJson = parseJson(packageJsonText, "package.json");
9681
+ const packageJson = projectMetadata.packageJson;
9114
9682
  const npmrcText = await readTextIfExists((0, node_path_1.join)(cwd, ".npmrc"));
9115
9683
  if (removeLegacyLoomNpmrcText(npmrcText).changed) {
9116
9684
  warnings.push(".npmrc retains Loom's obsolete GitHub Packages registry configuration.");
@@ -9119,7 +9687,7 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
9119
9687
  const framework = await detectFramework(cwd, packageJson);
9120
9688
  const dependency = packageJson.dependencies?.[exports.LOOM_DEPENDENCY];
9121
9689
  if (!dependency) {
9122
- issues.push(`Missing ${exports.LOOM_DEPENDENCY} in package.json dependencies.`);
9690
+ issues.push(`Missing ${exports.LOOM_DEPENDENCY} in ${projectMetadata.config} dependencies/imports.`);
9123
9691
  suggestions.add("Run `loom init`.");
9124
9692
  }
9125
9693
  else if (isLocalPackageSpec(dependency)) {
@@ -9136,6 +9704,26 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
9136
9704
  manifest = parseJson(manifestText, "loom.json");
9137
9705
  }
9138
9706
  if (manifest) {
9707
+ let tooling = null;
9708
+ if (!manifest.project?.tooling) {
9709
+ warnings.push("loom.json does not record authoritative project tooling.");
9710
+ suggestions.add("Run `loom init` to adopt the detected project tooling.");
9711
+ }
9712
+ try {
9713
+ tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest.project?.tooling);
9714
+ }
9715
+ catch (error) {
9716
+ issues.push(`Invalid project tooling configuration: ${error.message}`);
9717
+ suggestions.add("Fix the recorded project.tooling config in loom.json.");
9718
+ }
9719
+ if (tooling) {
9720
+ for (const conflict of await (0, projectTooling_js_1.findTaskConflicts)(cwd, tooling.tasks)) {
9721
+ const deploymentWarning = conflict.name === "build"
9722
+ ? " Deployment may invoke the wrong build task."
9723
+ : "";
9724
+ warnings.push(`Conflicting '${conflict.name}' tasks in ${conflict.authoritativeConfig} (authoritative) and ${conflict.secondaryConfig}.${deploymentWarning}`);
9725
+ }
9726
+ }
9139
9727
  for (const [featureKey, feature] of Object.entries(manifest.features)) {
9140
9728
  if (feature.status !== "active")
9141
9729
  continue;
@@ -9167,7 +9755,7 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
9167
9755
  for (const suggestion of agentsCheck.suggestions) {
9168
9756
  suggestions.add(suggestion);
9169
9757
  }
9170
- const envRunnerCheck = await checkEnvRunnerAdoption(cwd, manifest, packageJson);
9758
+ const envRunnerCheck = await checkEnvRunnerAdoption(cwd, manifest);
9171
9759
  for (const issue of envRunnerCheck.issues) {
9172
9760
  issues.push(issue);
9173
9761
  }
@@ -9221,13 +9809,16 @@ async function checkProjectNetwork(cwd, env = node_process_1.default.env, option
9221
9809
  const suggestions = new Set();
9222
9810
  const warnings = [];
9223
9811
  const steps = [];
9224
- const packageJsonText = await readTextIfExists((0, node_path_1.join)(cwd, "package.json"));
9225
- if (!packageJsonText) {
9812
+ let projectMetadata;
9813
+ try {
9814
+ projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
9815
+ }
9816
+ catch (error) {
9226
9817
  return {
9227
- issues: [`Missing ${(0, node_path_1.join)(cwd, "package.json")}`],
9818
+ issues: [error.message],
9228
9819
  steps,
9229
9820
  suggestions: [
9230
- "Run `loom init` from a project that already has package.json.",
9821
+ "Run `loom init` from a package.json or Deno project.",
9231
9822
  ],
9232
9823
  warnings,
9233
9824
  };
@@ -9241,7 +9832,7 @@ async function checkProjectNetwork(cwd, env = node_process_1.default.env, option
9241
9832
  warnings,
9242
9833
  };
9243
9834
  }
9244
- const packageJson = parseJson(packageJsonText, "package.json");
9835
+ const packageJson = projectMetadata.packageJson;
9245
9836
  const framework = await detectFramework(cwd, packageJson);
9246
9837
  const manifest = parseJson(manifestText, "loom.json");
9247
9838
  const context = {
@@ -9570,13 +10161,15 @@ function formatSkillLinkState(state) {
9570
10161
  }
9571
10162
  }
9572
10163
  async function runStatus(cwd, io) {
9573
- const packageJsonPath = (0, node_path_1.join)(cwd, "package.json");
9574
- const packageJsonText = await readTextIfExists(packageJsonPath);
9575
- if (!packageJsonText) {
9576
- io.err(`No package.json found in ${cwd}.`);
10164
+ let projectMetadata;
10165
+ try {
10166
+ projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
10167
+ }
10168
+ catch (error) {
10169
+ io.err(error.message);
9577
10170
  return 1;
9578
10171
  }
9579
- const packageJson = parseJson(packageJsonText, "package.json");
10172
+ const packageJson = projectMetadata.packageJson;
9580
10173
  const manifestText = await readTextIfExists((0, node_path_1.join)(cwd, "loom.json"));
9581
10174
  const manifest = manifestText
9582
10175
  ? parseJson(manifestText, "loom.json")
@@ -9591,6 +10184,19 @@ async function runStatus(cwd, io) {
9591
10184
  : null;
9592
10185
  const workspaceText = await readTextIfExists((0, node_path_1.join)(cwd, "pnpm-workspace.yaml"));
9593
10186
  const overrideSpec = getManagedDevOverrideSpec(workspaceText);
10187
+ let denoOverride = null;
10188
+ try {
10189
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
10190
+ if (usesDenoTooling(tooling)) {
10191
+ const config = await getDenoConfigForLinks(cwd, tooling);
10192
+ const link = await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, config));
10193
+ if (link)
10194
+ denoOverride = { config, link: link.link };
10195
+ }
10196
+ }
10197
+ catch {
10198
+ // Status reports stored project data even when live detection fails.
10199
+ }
9594
10200
  const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
9595
10201
  const devState = getManagedDevState(workspaceText) ??
9596
10202
  await readLocalDevState(cwd);
@@ -9599,14 +10205,22 @@ async function runStatus(cwd, io) {
9599
10205
  io.out(`Loom status for ${projectName}`);
9600
10206
  io.out("");
9601
10207
  io.out("Package:");
9602
- io.out(` package.json: ${dependencySpec ? `${exports.LOOM_DEPENDENCY} ${dependencySpec}` : "not declared"}`);
10208
+ io.out(` ${projectMetadata.config}: ${dependencySpec ? `${exports.LOOM_DEPENDENCY} ${dependencySpec}` : "not declared"}`);
9603
10209
  io.out(` installed: ${installedPackage?.version ?? "not installed"}`);
9604
- io.out(` local dev override: ${overrideSpec ? `active (${overrideSpec})` : "none"}`);
10210
+ io.out(` local dev override: ${denoOverride
10211
+ ? `active (${denoOverride.config} links ${denoOverride.link})`
10212
+ : overrideSpec
10213
+ ? `active (${overrideSpec})`
10214
+ : "none"}`);
9605
10215
  io.out(` lockfile local resolution: ${localLockfileResolution ?? "none"}`);
9606
10216
  io.out("");
9607
10217
  io.out("Project:");
9608
10218
  io.out(` loom.json: ${manifest ? `version ${manifest.version}` : "missing"}`);
9609
10219
  io.out(` framework: ${formatFrameworkInfo(framework)}`);
10220
+ if (manifest?.project?.tooling) {
10221
+ io.out(` tasks: ${manifest.project.tooling.tasks.config} via ${manifest.project.tooling.tasks.runner}`);
10222
+ io.out(` dependencies: ${manifest.project.tooling.dependencies.config} via ${manifest.project.tooling.dependencies.manager}`);
10223
+ }
9610
10224
  io.out("");
9611
10225
  io.out("Features:");
9612
10226
  if (!manifest) {
@@ -9695,7 +10309,7 @@ function printHelp({ out }) {
9695
10309
  out("loom <command>");
9696
10310
  out("");
9697
10311
  out("Commands:");
9698
- out(" init Set up package.json, loom.json, managed AGENTS.md guidance, first-party links, and npm package skills.");
10312
+ out(" init Set up package/Deno config, loom.json, managed AGENTS.md guidance, first-party links, and package skills.");
9699
10313
  out(" add <feature> Activate a shared feature. Run `loom add` to list available features.");
9700
10314
  out(" files id-generation uuid-v4|uuid-v7 Select the managed Files schema ID default.");
9701
10315
  out(" files r2 setup Create/reuse private Cloudflare R2 buckets, configure Vercel Production/Preview, and configure local MinIO by default.");
@@ -9717,8 +10331,8 @@ function printHelp({ out }) {
9717
10331
  out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
9718
10332
  out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
9719
10333
  out(" db release verify-build-env <output> <manifest> Reject build-only placeholders in a deployable Vercel artifact.");
9720
- out(" dev local Enable local Loom development using a managed file: override in pnpm-workspace.yaml.");
9721
- out(" dev sync Rebuild the local Loom package and refresh this project's pnpm install when the managed local-dev override is active.");
10334
+ out(" dev local Enable local Loom development using a managed pnpm override or Deno link.");
10335
+ out(" dev sync Rebuild local Loom and refresh this project's pnpm or Deno install when linked.");
9722
10336
  out(" dev published Remove the managed local-dev override and return to the published dependency.");
9723
10337
  out("");
9724
10338
  out("Options:");
@@ -9957,12 +10571,15 @@ async function runSkills(cwd, command, args, io, options) {
9957
10571
  printSkillsHelp(io);
9958
10572
  return 0;
9959
10573
  }
9960
- const packageJsonText = await readTextIfExists((0, node_path_1.join)(cwd, "package.json"));
9961
- if (!packageJsonText) {
9962
- io.err(`No package.json found in ${cwd}.`);
10574
+ let projectMetadata;
10575
+ try {
10576
+ projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
10577
+ }
10578
+ catch (error) {
10579
+ io.err(error.message);
9963
10580
  return 1;
9964
10581
  }
9965
- const packageJson = parseJson(packageJsonText, "package.json");
10582
+ const packageJson = projectMetadata.packageJson;
9966
10583
  const manifestText = await readTextIfExists((0, node_path_1.join)(cwd, "loom.json"));
9967
10584
  const manifest = manifestText
9968
10585
  ? parseJson(manifestText, "loom.json")
@@ -10130,7 +10747,16 @@ async function runDbSchemaGen(cwd, forwardedArgs, io) {
10130
10747
  if (!isNodeErrorCode(error, "MODULE_NOT_FOUND")) {
10131
10748
  throw error;
10132
10749
  }
10133
- io.out("Biome is not installed; generated Valibot files were left unformatted.");
10750
+ const manifest = await readManifestIfExists(cwd);
10751
+ const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
10752
+ if (usesDenoTooling(tooling)) {
10753
+ const formatExitCode = await runInheritedChild("deno", ["fmt", config.dirs.valibotGeneratedDir], cwd);
10754
+ if (formatExitCode !== 0)
10755
+ return formatExitCode;
10756
+ }
10757
+ else {
10758
+ io.out("Biome is not installed; generated Valibot files were left unformatted.");
10759
+ }
10134
10760
  }
10135
10761
  if (await syncValibotBarrel(cwd, config)) {
10136
10762
  io.out(`Updated ${config.modules.valibotBarrelModule}.`);
@@ -10433,7 +11059,7 @@ async function runDev(cwd, mode, pathInput, io, options = {}) {
10433
11059
  io.out(`Updated ${result.changedFiles.join(", ")}.`);
10434
11060
  }
10435
11061
  else if (result.notes.length) {
10436
- io.out("Project package.json uses a published @gadicc/loom dependency, but follow-up is still needed.");
11062
+ io.out("Project config uses a published @gadicc/loom dependency, but follow-up is still needed.");
10437
11063
  }
10438
11064
  else {
10439
11065
  io.out("Project already uses the published @gadicc/loom dependency.");