@intentius/chant 0.124.31 → 0.124.32

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 (321) hide show
  1. package/bin/chant +7 -2
  2. package/dist/cli/commands/check-lexicon-plugin.d.ts +7 -4
  3. package/dist/cli/commands/check-lexicon-plugin.d.ts.map +1 -1
  4. package/dist/cli/commands/check-lexicon-plugin.js +10 -7
  5. package/dist/cli/commands/check-lexicon.d.ts.map +1 -1
  6. package/dist/cli/commands/check-lexicon.js +18 -12
  7. package/dist/cli/commands/import.d.ts +10 -0
  8. package/dist/cli/commands/import.d.ts.map +1 -1
  9. package/dist/cli/commands/import.js +37 -0
  10. package/dist/cli/commands/init-lexicon/templates/project.d.ts.map +1 -1
  11. package/dist/cli/commands/init-lexicon/templates/project.js +4 -3
  12. package/dist/cli/commands/onboard.d.ts.map +1 -1
  13. package/dist/cli/commands/onboard.js +8 -4
  14. package/dist/cli/commands/update.d.ts.map +1 -1
  15. package/dist/cli/commands/update.js +2 -1
  16. package/dist/cli/dependencies.d.ts +18 -0
  17. package/dist/cli/dependencies.d.ts.map +1 -0
  18. package/dist/cli/dependencies.js +120 -0
  19. package/dist/cli/handlers/build.d.ts.map +1 -1
  20. package/dist/cli/handlers/build.js +23 -4
  21. package/dist/cli/handlers/fan-out.d.ts.map +1 -1
  22. package/dist/cli/handlers/fan-out.js +12 -4
  23. package/dist/cli/handlers/graph.d.ts.map +1 -1
  24. package/dist/cli/handlers/graph.js +16 -6
  25. package/dist/cli/handlers/lint.d.ts.map +1 -1
  26. package/dist/cli/handlers/lint.js +6 -0
  27. package/dist/cli/handlers/operator.d.ts +2 -2
  28. package/dist/cli/handlers/operator.js +3 -3
  29. package/dist/cli/handlers/pr.d.ts +14 -0
  30. package/dist/cli/handlers/pr.d.ts.map +1 -1
  31. package/dist/cli/handlers/pr.js +488 -32
  32. package/dist/cli/handlers/promote.d.ts.map +1 -1
  33. package/dist/cli/handlers/promote.js +3 -1
  34. package/dist/cli/handlers/run.d.ts +13 -1
  35. package/dist/cli/handlers/run.d.ts.map +1 -1
  36. package/dist/cli/handlers/run.js +38 -15
  37. package/dist/cli/main.d.ts.map +1 -1
  38. package/dist/cli/main.js +44 -16
  39. package/dist/cli/parse-args.d.ts.map +1 -1
  40. package/dist/cli/parse-args.js +15 -0
  41. package/dist/cli/registry.d.ts +13 -4
  42. package/dist/cli/registry.d.ts.map +1 -1
  43. package/dist/cli/registry.js +6 -2
  44. package/dist/codegen/generate-post-synth-barrel.js +2 -2
  45. package/dist/codegen/lexicon-regen.d.ts +4 -0
  46. package/dist/codegen/lexicon-regen.d.ts.map +1 -1
  47. package/dist/codegen/lexicon-regen.js +1 -1
  48. package/dist/codegen/pinned-upgrade.js +2 -2
  49. package/dist/components/capability.d.ts +44 -3
  50. package/dist/components/capability.d.ts.map +1 -1
  51. package/dist/components/capability.js +21 -0
  52. package/dist/components/changed-files.d.ts +7 -1
  53. package/dist/components/changed-files.d.ts.map +1 -1
  54. package/dist/components/changed-files.js +9 -1
  55. package/dist/components/driver.d.ts +38 -0
  56. package/dist/components/driver.d.ts.map +1 -1
  57. package/dist/components/driver.js +47 -6
  58. package/dist/components/fan-out-record.d.ts +6 -1
  59. package/dist/components/fan-out-record.d.ts.map +1 -1
  60. package/dist/components/fan-out-record.js +24 -0
  61. package/dist/components/fan-out-run.d.ts +20 -0
  62. package/dist/components/fan-out-run.d.ts.map +1 -1
  63. package/dist/components/fan-out-run.js +21 -1
  64. package/dist/components/pr-pipeline.d.ts +65 -2
  65. package/dist/components/pr-pipeline.d.ts.map +1 -1
  66. package/dist/components/pr-pipeline.js +107 -15
  67. package/dist/components/pr-run.d.ts +127 -29
  68. package/dist/components/pr-run.d.ts.map +1 -1
  69. package/dist/components/pr-run.js +290 -70
  70. package/dist/components/wave-plan.d.ts +5 -2
  71. package/dist/components/wave-plan.d.ts.map +1 -1
  72. package/dist/components/wave-plan.js +12 -1
  73. package/dist/discovery/fold-import.d.ts.map +1 -1
  74. package/dist/discovery/fold-import.js +16 -6
  75. package/dist/discovery/sandbox/bundle.d.ts.map +1 -1
  76. package/dist/discovery/sandbox/bundle.js +6 -0
  77. package/dist/discovery/specifier-resolve.d.ts.map +1 -1
  78. package/dist/discovery/specifier-resolve.js +8 -2
  79. package/dist/fold/fold.d.ts.map +1 -1
  80. package/dist/fold/fold.js +68 -1
  81. package/dist/fold/subset.d.ts +37 -0
  82. package/dist/fold/subset.d.ts.map +1 -1
  83. package/dist/fold/subset.js +88 -0
  84. package/dist/lexicon-module.d.ts +10 -0
  85. package/dist/lexicon-module.d.ts.map +1 -1
  86. package/dist/lexicon-module.js +53 -8
  87. package/dist/lexicon-plugin-helpers.d.ts.map +1 -1
  88. package/dist/lexicon-plugin-helpers.js +6 -4
  89. package/dist/lexicon.d.ts +2 -0
  90. package/dist/lexicon.d.ts.map +1 -1
  91. package/dist/lifecycle/affected.d.ts.map +1 -1
  92. package/dist/lifecycle/affected.js +7 -1
  93. package/dist/lifecycle/release-ledger.d.ts +21 -0
  94. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  95. package/dist/lifecycle/release-ledger.js +24 -0
  96. package/dist/lifecycle/work-dir.d.ts +45 -0
  97. package/dist/lifecycle/work-dir.d.ts.map +1 -0
  98. package/dist/lifecycle/work-dir.js +78 -0
  99. package/dist/lint/discover.d.ts +17 -9
  100. package/dist/lint/discover.d.ts.map +1 -1
  101. package/dist/lint/discover.js +62 -54
  102. package/dist/module-source.d.ts +57 -0
  103. package/dist/module-source.d.ts.map +1 -0
  104. package/dist/module-source.js +104 -0
  105. package/dist/op/activities/factory.js +1 -1
  106. package/dist/op/discover.d.ts.map +1 -1
  107. package/dist/op/discover.js +13 -3
  108. package/dist/op/gate.d.ts.map +1 -1
  109. package/dist/op/gate.js +3 -0
  110. package/dist/op/op-waves-run.d.ts.map +1 -1
  111. package/dist/op/op-waves-run.js +20 -5
  112. package/dist/op/operator.d.ts +2 -2
  113. package/dist/op/operator.js +2 -2
  114. package/dist/op/steward.d.ts +6 -4
  115. package/dist/op/steward.d.ts.map +1 -1
  116. package/dist/op/steward.js +5 -3
  117. package/dist/op/work-lease-run.d.ts +20 -7
  118. package/dist/op/work-lease-run.d.ts.map +1 -1
  119. package/dist/op/work-lease-run.js +56 -12
  120. package/dist/pr-forge.d.ts +10 -0
  121. package/dist/pr-forge.d.ts.map +1 -1
  122. package/dist/pr-forge.js +39 -0
  123. package/dist/pr-loop.d.ts +141 -4
  124. package/dist/pr-loop.d.ts.map +1 -1
  125. package/dist/pr-loop.js +122 -6
  126. package/dist/pr-report-url.d.ts +2 -2
  127. package/dist/pr-report-url.d.ts.map +1 -1
  128. package/dist/pr-report-url.js +5 -5
  129. package/dist/ts-loader.d.ts +38 -4
  130. package/dist/ts-loader.d.ts.map +1 -1
  131. package/dist/ts-loader.js +190 -16
  132. package/dist/wave-runtime.mjs +208 -208
  133. package/dist/workspace/chant-migrations/fountain-retired-kinds.d.ts +34 -0
  134. package/dist/workspace/chant-migrations/fountain-retired-kinds.d.ts.map +1 -0
  135. package/dist/workspace/chant-migrations/fountain-retired-kinds.js +176 -0
  136. package/dist/workspace/chant-migrations.d.ts.map +1 -1
  137. package/dist/workspace/chant-migrations.js +2 -0
  138. package/dist/workspace/checks/boxes.d.ts +6 -6
  139. package/dist/workspace/checks/boxes.js +9 -9
  140. package/dist/workspace/ci-green-forge.d.ts +6 -4
  141. package/dist/workspace/ci-green-forge.d.ts.map +1 -1
  142. package/dist/workspace/ci-green.d.ts +28 -12
  143. package/dist/workspace/ci-green.d.ts.map +1 -1
  144. package/dist/workspace/ci-green.js +49 -21
  145. package/dist/workspace/ci-list.schema.json +12 -6
  146. package/dist/workspace/ci-report-url.d.ts +18 -0
  147. package/dist/workspace/ci-report-url.d.ts.map +1 -0
  148. package/dist/workspace/ci-report-url.js +33 -0
  149. package/dist/workspace/ci-run-index.d.ts +12 -0
  150. package/dist/workspace/ci-run-index.d.ts.map +1 -1
  151. package/dist/workspace/ci-run-index.js +6 -4
  152. package/dist/workspace/ci-run-index.schema.json +5 -3
  153. package/dist/workspace/ci-run.d.ts +75 -2
  154. package/dist/workspace/ci-run.d.ts.map +1 -1
  155. package/dist/workspace/ci-run.js +195 -53
  156. package/dist/workspace/ci-runner-key.d.ts +16 -3
  157. package/dist/workspace/ci-runner-key.d.ts.map +1 -1
  158. package/dist/workspace/ci-runner-key.js +30 -10
  159. package/dist/workspace/ci-serve.d.ts +54 -4
  160. package/dist/workspace/ci-serve.d.ts.map +1 -1
  161. package/dist/workspace/ci-serve.js +175 -26
  162. package/dist/workspace/declaration.d.ts +8 -0
  163. package/dist/workspace/declaration.d.ts.map +1 -1
  164. package/dist/workspace/declaration.js +11 -2
  165. package/dist/workspace/declaration.schema.json +7 -2
  166. package/dist/workspace/export.d.ts +1 -1
  167. package/dist/workspace/export.d.ts.map +1 -1
  168. package/dist/workspace/export.js +7 -3
  169. package/dist/workspace/ls.d.ts +6 -1
  170. package/dist/workspace/ls.d.ts.map +1 -1
  171. package/dist/workspace/ls.js +1 -0
  172. package/dist/workspace/ls.schema.json +7 -1
  173. package/dist/workspace/pin-integrity.d.ts.map +1 -1
  174. package/dist/workspace/pin-integrity.js +3 -2
  175. package/dist/workspace/pr-report.schema.json +74 -7
  176. package/dist/workspace/reason-codes.d.ts +1 -1
  177. package/dist/workspace/reason-codes.d.ts.map +1 -1
  178. package/dist/workspace/reason-codes.js +2 -2
  179. package/dist/workspace/run-event.schema.json +3 -1
  180. package/dist/workspace/status.schema.json +3 -1
  181. package/dist/workspace/write-scope.d.ts +9 -0
  182. package/dist/workspace/write-scope.d.ts.map +1 -1
  183. package/dist/workspace/write-scope.js +11 -1
  184. package/package.json +1 -1
  185. package/src/__fixtures__/pr-loop/pr-apply-wave-waiting.note.golden.md +48 -0
  186. package/src/cli/commands/__fixtures__/init-lexicon-output/package.json +3 -3
  187. package/src/cli/commands/audit.test.ts +2 -2
  188. package/src/cli/commands/check-lexicon-plugin.test.ts +9 -0
  189. package/src/cli/commands/check-lexicon-plugin.ts +11 -8
  190. package/src/cli/commands/check-lexicon.test.ts +1 -1
  191. package/src/cli/commands/check-lexicon.ts +16 -11
  192. package/src/cli/commands/import.ts +40 -0
  193. package/src/cli/commands/init-lexicon/templates/project.ts +4 -3
  194. package/src/cli/commands/init-lexicon.test.ts +8 -5
  195. package/src/cli/commands/onboard.test.ts +45 -0
  196. package/src/cli/commands/onboard.ts +8 -4
  197. package/src/cli/commands/update.test.ts +6 -0
  198. package/src/cli/commands/update.ts +4 -1
  199. package/src/cli/compiled-cli.e2e.test.ts +76 -11
  200. package/src/cli/dependencies.e2e.test.ts +101 -0
  201. package/src/cli/dependencies.test.ts +93 -0
  202. package/src/cli/dependencies.ts +122 -0
  203. package/src/cli/handlers/build.test.ts +69 -0
  204. package/src/cli/handlers/build.ts +20 -4
  205. package/src/cli/handlers/fan-out.test.ts +73 -0
  206. package/src/cli/handlers/fan-out.ts +11 -4
  207. package/src/cli/handlers/graph.test.ts +76 -0
  208. package/src/cli/handlers/graph.ts +19 -12
  209. package/src/cli/handlers/lint.test.ts +42 -0
  210. package/src/cli/handlers/lint.ts +6 -0
  211. package/src/cli/handlers/operator.ts +3 -3
  212. package/src/cli/handlers/pr-waves.test.ts +449 -0
  213. package/src/cli/handlers/pr.test.ts +134 -0
  214. package/src/cli/handlers/pr.ts +523 -31
  215. package/src/cli/handlers/promote.test.ts +26 -1
  216. package/src/cli/handlers/promote.ts +3 -2
  217. package/src/cli/handlers/run-components-exit.test.ts +99 -0
  218. package/src/cli/handlers/run-signer.test.ts +79 -0
  219. package/src/cli/handlers/run.ts +34 -16
  220. package/src/cli/main.test.ts +18 -0
  221. package/src/cli/main.ts +43 -16
  222. package/src/cli/parse-args.ts +12 -0
  223. package/src/cli/registry.ts +19 -6
  224. package/src/codegen/generate-post-synth-barrel.ts +2 -2
  225. package/src/codegen/lexicon-regen.ts +1 -1
  226. package/src/codegen/pinned-upgrade.ts +2 -2
  227. package/src/codegen/post-synth-barrel-guards.test.ts +6 -11
  228. package/src/components/capability.ts +51 -3
  229. package/src/components/changed-files.test.ts +16 -1
  230. package/src/components/changed-files.ts +9 -1
  231. package/src/components/driver.test.ts +36 -1
  232. package/src/components/driver.ts +76 -4
  233. package/src/components/fan-out-record.ts +29 -1
  234. package/src/components/fan-out-run.test.ts +35 -0
  235. package/src/components/fan-out-run.ts +40 -1
  236. package/src/components/pr-pipeline.test.ts +100 -0
  237. package/src/components/pr-pipeline.ts +132 -17
  238. package/src/components/pr-run.test.ts +323 -18
  239. package/src/components/pr-run.ts +354 -75
  240. package/src/components/wave-plan.ts +16 -4
  241. package/src/discovery/fold-host-method.test.ts +87 -0
  242. package/src/discovery/fold-import.ts +15 -5
  243. package/src/discovery/fold-package-composite.test.ts +27 -0
  244. package/src/discovery/fold-specifiers.test.ts +8 -0
  245. package/src/discovery/sandbox/bundle.ts +6 -0
  246. package/src/discovery/specifier-resolve.ts +8 -2
  247. package/src/fold/fold.test.ts +72 -0
  248. package/src/fold/fold.ts +71 -0
  249. package/src/fold/subset.test.ts +31 -0
  250. package/src/fold/subset.ts +99 -0
  251. package/src/lexicon-dist.e2e.test.ts +254 -0
  252. package/src/lexicon-module.test.ts +47 -0
  253. package/src/lexicon-module.ts +49 -7
  254. package/src/lexicon-plugin-helpers.ts +6 -4
  255. package/src/lexicon.ts +2 -0
  256. package/src/lifecycle/affected.test.ts +7 -0
  257. package/src/lifecycle/affected.ts +6 -1
  258. package/src/lifecycle/release-ledger.ts +34 -0
  259. package/src/lifecycle/work-dir.test.ts +77 -0
  260. package/src/lifecycle/work-dir.ts +82 -0
  261. package/src/lint/discover.test.ts +46 -2
  262. package/src/lint/discover.ts +55 -49
  263. package/src/module-source.test.ts +85 -0
  264. package/src/module-source.ts +112 -0
  265. package/src/op/activities/factory.ts +1 -1
  266. package/src/op/discover-root.test.ts +31 -2
  267. package/src/op/discover.ts +14 -4
  268. package/src/op/gate.test.ts +30 -0
  269. package/src/op/gate.ts +3 -0
  270. package/src/op/op-waves-run.ts +20 -5
  271. package/src/op/op-waves.test.ts +49 -0
  272. package/src/op/operator.ts +2 -2
  273. package/src/op/steward.ts +6 -4
  274. package/src/op/work-lease-run.test.ts +88 -2
  275. package/src/op/work-lease-run.ts +52 -12
  276. package/src/pr-forge-bundle.test.ts +2 -2
  277. package/src/pr-forge.test.ts +42 -0
  278. package/src/pr-forge.ts +40 -0
  279. package/src/pr-loop-bundle.test.ts +2 -1
  280. package/src/pr-loop.test.ts +117 -1
  281. package/src/pr-loop.ts +252 -10
  282. package/src/pr-report-url.ts +5 -5
  283. package/src/terraform/__fixtures__/advise.test.ts +21 -2
  284. package/src/ts-loader.test.ts +89 -1
  285. package/src/ts-loader.ts +180 -13
  286. package/src/workspace/changes.test.ts +1 -1
  287. package/src/workspace/chant-migrations/fountain-retired-kinds.test.ts +33 -0
  288. package/src/workspace/chant-migrations/fountain-retired-kinds.ts +190 -0
  289. package/src/workspace/chant-migrations.e2e.test.ts +5 -0
  290. package/src/workspace/chant-migrations.ts +2 -0
  291. package/src/workspace/checks/boxes.ts +9 -9
  292. package/src/workspace/ci-green-forge.ts +6 -4
  293. package/src/workspace/ci-green-runs.test.ts +53 -11
  294. package/src/workspace/ci-green.test.ts +1 -1
  295. package/src/workspace/ci-green.ts +50 -22
  296. package/src/workspace/ci-list.schema.json +12 -6
  297. package/src/workspace/ci-report-url.test.ts +220 -0
  298. package/src/workspace/ci-report-url.ts +33 -0
  299. package/src/workspace/ci-run-index.schema.json +5 -3
  300. package/src/workspace/ci-run-index.test.ts +42 -3
  301. package/src/workspace/ci-run-index.ts +18 -4
  302. package/src/workspace/ci-run.test.ts +185 -7
  303. package/src/workspace/ci-run.ts +224 -54
  304. package/src/workspace/ci-runner-key.test.ts +55 -17
  305. package/src/workspace/ci-runner-key.ts +36 -11
  306. package/src/workspace/ci-serve.test.ts +150 -6
  307. package/src/workspace/ci-serve.ts +169 -25
  308. package/src/workspace/declaration.schema.json +7 -2
  309. package/src/workspace/declaration.test.ts +23 -0
  310. package/src/workspace/declaration.ts +19 -3
  311. package/src/workspace/export.ts +6 -3
  312. package/src/workspace/ls.schema.json +7 -1
  313. package/src/workspace/ls.ts +7 -2
  314. package/src/workspace/pin-integrity.test.ts +5 -0
  315. package/src/workspace/pin-integrity.ts +3 -2
  316. package/src/workspace/pr-report.schema.json +74 -7
  317. package/src/workspace/reason-codes.ts +2 -2
  318. package/src/workspace/run-event.schema.json +3 -1
  319. package/src/workspace/status.schema.json +3 -1
  320. package/src/workspace/write-scope.test.ts +29 -1
  321. package/src/workspace/write-scope.ts +12 -1
@@ -3,6 +3,7 @@ import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync,
3
3
  import { createRequire } from "node:module";
4
4
  import { tmpdir } from "node:os";
5
5
  import { dirname, join, resolve as resolvePath } from "node:path";
6
+ import { SOURCE_EXPORT_CONDITIONS } from "../../module-source.js";
6
7
  /**
7
8
  * chant #1045 Phase 2 — bundles the generated sandbox driver (`./driver.ts`)
8
9
  * into one self-contained ESM file with esbuild, so the sandboxed child never
@@ -201,6 +202,11 @@ export async function bundleDriver(driverSource) {
201
202
  format: "esm",
202
203
  absWorkingDir: bundleDir,
203
204
  logLevel: "silent",
205
+ // #3981 — from source, a lexicon bundles from its src/*.ts, as the
206
+ // unsandboxed build imports it; compiled, from the dist/*.js it ships.
207
+ // Setting `conditions` replaces esbuild's default ["module"], so it is
208
+ // kept, and compiled the option is left out as before.
209
+ ...(SOURCE_EXPORT_CONDITIONS.length > 0 ? { conditions: ["module", ...SOURCE_EXPORT_CONDITIONS] } : {}),
204
210
  plugins: [plugin],
205
211
  });
206
212
  }
@@ -1 +1 @@
1
- {"version":3,"file":"specifier-resolve.d.ts","sourceRoot":"","sources":["../../src/discovery/specifier-resolve.ts"],"names":[],"mappings":"AA2BA,oDAAoD;AACpD,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5C;AAmBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,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jB,QAAQ,EAAE,MAAM,GACf;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAiCzD;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3F"}
@@ -24,6 +24,7 @@
24
24
  import * as ts from "typescript";
25
25
  import { readFileSync, statSync } from "node:fs";
26
26
  import { dirname, extname, isAbsolute, join, resolve as resolvePath } from "node:path";
27
+ import { SOURCE_EXPORT_CONDITIONS } from "../module-source.js";
27
28
  /** True when `path` is an existing regular file. */
28
29
  export function isFile(path) {
29
30
  try {
@@ -87,8 +88,13 @@ export function splitBareSpecifier(specifier) {
87
88
  const rest = segments.slice(nameLength).join("/");
88
89
  return { name, subpath: rest === "" ? "." : `./${rest}` };
89
90
  }
90
- /** The conditions an ESM import in Node matches, which is what the run path does. */
91
- const EXPORT_CONDITIONS = new Set(["import", "node", "default"]);
91
+ /**
92
+ * The conditions an ESM import in Node matches, which is what the run path
93
+ * does. From source, `development` too (#3981): the run path there resolves a
94
+ * chant package to its `src/*.ts`, not to the compiled `dist/*.js` its
95
+ * `default` names.
96
+ */
97
+ const EXPORT_CONDITIONS = new Set(["import", "node", "default", ...SOURCE_EXPORT_CONDITIONS]);
92
98
  /**
93
99
  * The target an `exports` value selects, with `star` substituted for each `*`
94
100
  * when it came from a pattern key. A string is the target; an array yields its
@@ -1 +1 @@
1
- {"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/fold/fold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAoE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACjH,OAAO,EAaL,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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BAAgB,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAYnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,GAAG,MAAM,CAGtD;AAwUD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,EAClC,UAAU,GAAE,SAAS,YAAY,EAAO,EACxC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAygBb;AAgDD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,EAAE,CAAC,aAAa,EACtB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,EAClC,UAAU,GAAE,SAAS,YAAY,EAAO,EACxC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,cAAc,CA6BhB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,SAAc,EACtB,UAAU,GAAE,SAAS,YAAY,EAAO,GACvC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CA6BjC"}
package/dist/fold/fold.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as ts from "typescript";
2
2
  import { relative } from "node:path";
3
3
  import { intrinsicCallFolds, intrinsicCallFoldsEagerly, intrinsicTagFolds } from "../lexicon.js";
4
- import { SUPPORTED_BINARY_OPERATORS, SUPPORTED_UNARY_OPERATORS, UNSUPPORTED_OBJECT_MEMBER_MESSAGE, UNSUPPORTED_UNARY_MESSAGE, briefNodeText, callExpressionMessage, computedPropertyNameMessage, dynamicElementAccessMessage, isLiteralElementKey, isLiteralPropertyName, unsupportedBinaryMessage, unsupportedExpressionMessage, } from "./subset.js";
4
+ import { SUPPORTED_BINARY_OPERATORS, SUPPORTED_UNARY_OPERATORS, UNSUPPORTED_OBJECT_MEMBER_MESSAGE, UNSUPPORTED_UNARY_MESSAGE, FOLDABLE_HOST_METHODS, REFUSED_METHOD_NAMES, briefNodeText, callExpressionMessage, computedPropertyNameMessage, dynamicElementAccessMessage, isLiteralElementKey, isLiteralPropertyName, refusedMethodMessage, unsupportedBinaryMessage, unsupportedExpressionMessage, } from "./subset.js";
5
5
  import { isFoldableHelperName } from "./foldable-helpers.js";
6
6
  /**
7
7
  * Symbolic reference produced when a property/element access resolves to an
@@ -1310,8 +1310,16 @@ export function fold(node, consts, intrinsics = [], externals) {
1310
1310
  // named property on it is actually a function. Calling it with the folded
1311
1311
  // arguments is then no different from what running the file would do:
1312
1312
  // the receiver is the same real object either way.
1313
+ //
1314
+ // chant#4011 — "never checked by name" let `[].constructor.constructor`
1315
+ // reach `Function`, so a folded file could run any code. A name in
1316
+ // REFUSED_METHOD_NAMES is refused on every receiver, before the receiver
1317
+ // is folded, exactly as EVL001 refuses it; a host (native) method must be
1318
+ // in FOLDABLE_HOST_METHODS for its receiver's type ({@link hostMethodRefusal}).
1313
1319
  if (ts.isPropertyAccessExpression(node.expression)) {
1314
1320
  const methodName = node.expression.name.text;
1321
+ if (REFUSED_METHOD_NAMES.has(methodName))
1322
+ throw foldError(node, refusedMethodMessage(methodName));
1315
1323
  const receiver = fold(node.expression.expression, consts, intrinsics, externals);
1316
1324
  // chant #2328 — a call is a link of an optional chain like any other:
1317
1325
  // `a?.b()` and `a?.b.c()` on a nullish `a` are `undefined` in
@@ -1331,13 +1339,72 @@ export function fold(node, consts, intrinsics = [], externals) {
1331
1339
  if (typeof method !== "function") {
1332
1340
  throw foldError(node, `"${methodName}" is not a callable method on the folded value — falls back to run`);
1333
1341
  }
1342
+ // The arguments fold first, so `list.map((n) => …)` keeps refusing on
1343
+ // its callback, the reason the docs give for it.
1334
1344
  const args = node.arguments.map((arg) => fold(arg, consts, intrinsics, externals));
1345
+ if (isNativeFunction(method)) {
1346
+ const refusal = hostMethodRefusal(receiver, methodName, method);
1347
+ if (refusal)
1348
+ throw foldError(node, refusal);
1349
+ // A host method handed a function calls it (`"x".replace("x", fn)`),
1350
+ // and the only functions a fold produces as values are host ones read
1351
+ // by property access (`[].constructor`), so none is passed in.
1352
+ if (args.some((arg) => typeof arg === "function")) {
1353
+ throw foldError(node, `a function passed to the host method \`.${methodName}(...)\` is not foldable — falls back to run`);
1354
+ }
1355
+ }
1335
1356
  return method.apply(receiver, args);
1336
1357
  }
1337
1358
  throw foldError(node, callExpressionMessage(node));
1338
1359
  }
1339
1360
  throw foldError(node, unsupportedExpressionMessage(node));
1340
1361
  }
1362
+ /**
1363
+ * chant#4011 — true when `fn` is provided by the JavaScript engine rather than
1364
+ * written in JavaScript. A lexicon's own method (`Expression.prototype.toString`)
1365
+ * is JavaScript source; `Function`, `Date.now` and `Array.prototype.join` are
1366
+ * not. `Function.prototype.toString` prints a native function's body as
1367
+ * `[native code]` (ECMA-262, NativeFunction), and is read off the prototype so
1368
+ * a receiver cannot override it.
1369
+ */
1370
+ function isNativeFunction(fn) {
1371
+ return typeof fn === "function" && /\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(fn));
1372
+ }
1373
+ const HOST_PROTOTYPES = {
1374
+ string: String.prototype,
1375
+ number: Number.prototype,
1376
+ boolean: Boolean.prototype,
1377
+ array: Array.prototype,
1378
+ object: Object.prototype,
1379
+ };
1380
+ /**
1381
+ * chant#4011 — why a host method `method`, read as `receiver[methodName]`,
1382
+ * does not fold, or `undefined` when it does. It folds only when the
1383
+ * receiver's type has a row in {@link FOLDABLE_HOST_METHODS} listing the name
1384
+ * and `method` is the function that type's prototype carries under it. A
1385
+ * function receiver (`[].constructor.from(...)`) has no row; neither does a
1386
+ * host object such as a `Date`, which has its own prototype.
1387
+ */
1388
+ function hostMethodRefusal(receiver, methodName, method) {
1389
+ let kind;
1390
+ if (typeof receiver === "string")
1391
+ kind = "string";
1392
+ else if (typeof receiver === "number")
1393
+ kind = "number";
1394
+ else if (typeof receiver === "boolean")
1395
+ kind = "boolean";
1396
+ else if (Array.isArray(receiver))
1397
+ kind = "array";
1398
+ else if (typeof receiver === "object" && receiver !== null)
1399
+ kind = "object";
1400
+ const listed = kind !== undefined &&
1401
+ FOLDABLE_HOST_METHODS[kind].has(methodName) &&
1402
+ HOST_PROTOTYPES[kind][methodName] === method;
1403
+ if (listed)
1404
+ return undefined;
1405
+ return (`the host method \`.${methodName}(...)\` is not in the foldable table for a ${kind ?? typeof receiver} ` +
1406
+ "receiver (chant#4011) — falls back to run");
1407
+ }
1341
1408
  /**
1342
1409
  * Fold a resource constructor call to its spec.
1343
1410
  *
@@ -316,6 +316,43 @@ export declare function unsupportedBinaryMessage(opKind: ts.SyntaxKind): string;
316
316
  */
317
317
  export declare function callExpressionMessage(node: ts.CallExpression): string;
318
318
  export declare function unsupportedExpressionMessage(node: ts.Node): string;
319
+ /**
320
+ * chant#4011 — S-CallMethod's closed table of HOST methods, by receiver type.
321
+ * PROVISIONAL until typescript-as-data narrows F-Eval-CallMethod to the same
322
+ * table (INTENTIUS/typescript-as-data#264; see the module doc's provisional path).
323
+ *
324
+ * Since #1966 `fold()` called any function-valued property on a real
325
+ * receiver, so `[].constructor.constructor("return Date.now()")` reached
326
+ * `Function` and a `[fold:fold]` file could put the clock, `process.env` or
327
+ * `Math.random()` in its output. A method the JavaScript engine provides
328
+ * (a native function) now folds only when it is listed here for the
329
+ * receiver's type AND is the very function that type's prototype carries, so
330
+ * an own property cannot shadow a listed name. Every entry is deterministic
331
+ * given its receiver and arguments: no callbacks (`map`, `filter`), no
332
+ * mutation (`push`, `sort`), and no `toLocale*` or `localeCompare`, whose
333
+ * answer follows the host's locale and time zone.
334
+ *
335
+ * A method defined by a lexicon package's own code (the github lexicon's
336
+ * `Expression.prototype.toString`) is not a host method and is not looked up
337
+ * here; it is the same class of package code as an eager intrinsic call.
338
+ */
339
+ export declare const FOLDABLE_HOST_METHODS: {
340
+ readonly string: ReadonlySet<string>;
341
+ readonly number: ReadonlySet<string>;
342
+ readonly boolean: ReadonlySet<string>;
343
+ readonly array: ReadonlySet<string>;
344
+ readonly object: ReadonlySet<string>;
345
+ };
346
+ /**
347
+ * chant#4011 — method names `fold()` refuses on every receiver, lexicon
348
+ * objects included. These are the names that reach `Function` (`constructor`,
349
+ * and `call`/`apply`/`bind` on whatever it returns) or read the host locale.
350
+ * Unlike {@link FOLDABLE_HOST_METHODS}, which needs the receiver's runtime
351
+ * type, a name in this set is decidable from syntax, so EVL001 refuses it too.
352
+ */
353
+ export declare const REFUSED_METHOD_NAMES: ReadonlySet<string>;
354
+ /** The refusal for a method name in {@link REFUSED_METHOD_NAMES}, shared by `fold()` and EVL001. */
355
+ export declare function refusedMethodMessage(methodName: string): string;
319
356
  /**
320
357
  * Classify one object-literal member (`{ a: 1 }`'s `a: 1`, `{ ...x }`'s
321
358
  * `...x`, or a shorthand `{ a }`). Checks the key's shape before the
@@ -1 +1 @@
1
- {"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../src/fold/subset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAiD,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0KG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,eAAO,MAAM,YAAY,QAAQ,CAAC;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IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAElE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,EAAE;IAClC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAiCtC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAenD,CAAC;AAEH,oGAAoG;AACpG,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,EAAE,CAAC,wBAAwB,EACjC,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,GACnC,eAAe,GAAG,SAAS,CAc7B;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,GACnC,eAAe,GAAG,SAAS,CAyO7B"}
@@ -432,6 +432,87 @@ export function callExpressionMessage(node) {
432
432
  export function unsupportedExpressionMessage(node) {
433
433
  return `unsupported expression: ${ts.SyntaxKind[node.kind]}`;
434
434
  }
435
+ /**
436
+ * chant#4011 — S-CallMethod's closed table of HOST methods, by receiver type.
437
+ * PROVISIONAL until typescript-as-data narrows F-Eval-CallMethod to the same
438
+ * table (INTENTIUS/typescript-as-data#264; see the module doc's provisional path).
439
+ *
440
+ * Since #1966 `fold()` called any function-valued property on a real
441
+ * receiver, so `[].constructor.constructor("return Date.now()")` reached
442
+ * `Function` and a `[fold:fold]` file could put the clock, `process.env` or
443
+ * `Math.random()` in its output. A method the JavaScript engine provides
444
+ * (a native function) now folds only when it is listed here for the
445
+ * receiver's type AND is the very function that type's prototype carries, so
446
+ * an own property cannot shadow a listed name. Every entry is deterministic
447
+ * given its receiver and arguments: no callbacks (`map`, `filter`), no
448
+ * mutation (`push`, `sort`), and no `toLocale*` or `localeCompare`, whose
449
+ * answer follows the host's locale and time zone.
450
+ *
451
+ * A method defined by a lexicon package's own code (the github lexicon's
452
+ * `Expression.prototype.toString`) is not a host method and is not looked up
453
+ * here; it is the same class of package code as an eager intrinsic call.
454
+ */
455
+ export const FOLDABLE_HOST_METHODS = {
456
+ string: new Set([
457
+ "at",
458
+ "charAt",
459
+ "charCodeAt",
460
+ "codePointAt",
461
+ "concat",
462
+ "endsWith",
463
+ "includes",
464
+ "indexOf",
465
+ "lastIndexOf",
466
+ "padEnd",
467
+ "padStart",
468
+ "repeat",
469
+ "replace",
470
+ "replaceAll",
471
+ "slice",
472
+ "split",
473
+ "startsWith",
474
+ "substring",
475
+ "toLowerCase",
476
+ "toString",
477
+ "toUpperCase",
478
+ "trim",
479
+ "trimEnd",
480
+ "trimStart",
481
+ "valueOf",
482
+ ]),
483
+ number: new Set(["toExponential", "toFixed", "toPrecision", "toString", "valueOf"]),
484
+ boolean: new Set(["toString", "valueOf"]),
485
+ array: new Set(["at", "concat", "flat", "includes", "indexOf", "join", "lastIndexOf", "slice", "toString"]),
486
+ object: new Set(["hasOwnProperty", "toString", "valueOf"]),
487
+ };
488
+ /**
489
+ * chant#4011 — method names `fold()` refuses on every receiver, lexicon
490
+ * objects included. These are the names that reach `Function` (`constructor`,
491
+ * and `call`/`apply`/`bind` on whatever it returns) or read the host locale.
492
+ * Unlike {@link FOLDABLE_HOST_METHODS}, which needs the receiver's runtime
493
+ * type, a name in this set is decidable from syntax, so EVL001 refuses it too.
494
+ */
495
+ export const REFUSED_METHOD_NAMES = new Set([
496
+ "constructor",
497
+ "call",
498
+ "apply",
499
+ "bind",
500
+ "toLocaleString",
501
+ "toLocaleDateString",
502
+ "toLocaleTimeString",
503
+ "toLocaleUpperCase",
504
+ "toLocaleLowerCase",
505
+ "localeCompare",
506
+ "__defineGetter__",
507
+ "__defineSetter__",
508
+ "__lookupGetter__",
509
+ "__lookupSetter__",
510
+ ]);
511
+ /** The refusal for a method name in {@link REFUSED_METHOD_NAMES}, shared by `fold()` and EVL001. */
512
+ export function refusedMethodMessage(methodName) {
513
+ return (`method call \`.${methodName}(...)\` is not foldable: it reaches \`Function\` or the host locale, ` +
514
+ "so its result is not determined by the source (chant#4011) — falls back to run");
515
+ }
435
516
  /**
436
517
  * Classify one object-literal member (`{ a: 1 }`'s `a: 1`, `{ ...x }`'s
437
518
  * `...x`, or a shorthand `{ a }`). Checks the key's shape before the
@@ -660,7 +741,14 @@ export function findSubsetViolation(node, intrinsics) {
660
741
  // a same-file `new` used as a value (#1169). Accepted here regardless of
661
742
  // the intrinsics registry, unlike the two cases just above: nothing about
662
743
  // whether a method call folds depends on a lexicon's registration.
744
+ //
745
+ // chant#4011 — except a name `fold()` refuses on every receiver, which is
746
+ // decidable here. The per-type host table needs the receiver's value, so
747
+ // it stays on `fold()`'s side, in the direction F-Direction allows.
663
748
  if (ts.isPropertyAccessExpression(node.expression)) {
749
+ if (REFUSED_METHOD_NAMES.has(node.expression.name.text)) {
750
+ return violation(node, refusedMethodMessage(node.expression.name.text));
751
+ }
664
752
  const v = findSubsetViolation(node.expression.expression, intrinsics);
665
753
  if (v)
666
754
  return v;
@@ -97,6 +97,9 @@ export declare function resetLexiconModules(): void;
97
97
  * `typeScript: false` imports it with plain node, without registering tsx
98
98
  * (#3276): tsx's ESM hooks run on a thread of their own, which costs the
99
99
  * compiled CLI about 200 MB, so a caller whose module is JavaScript says so.
100
+ * Left out, the module's extension decides (#3981): a `.js` or `.mjs` module
101
+ * imports with plain node, and anything else (`.ts`, or no extension, which
102
+ * only tsx's resolver completes) registers tsx first.
100
103
  */
101
104
  export declare function importLexiconModule(name: string, options?: {
102
105
  typeScript?: boolean;
@@ -133,6 +136,13 @@ export declare function resolveFromProject(spec: string, fromDir?: string): stri
133
136
  * that installs its lexicons in its own node_modules, it is resolved from
134
137
  * `fromDir` (the project) and imported from there. Any other failure, and a
135
138
  * package the project doesn't have either, rethrows the first error.
139
+ *
140
+ * #3981 — tsx is registered only when the module resolves to TypeScript. A
141
+ * lexicon that ships compiled JS imports with plain node. The module is
142
+ * resolved before it is imported, because a failed import is cached: one
143
+ * tried without tsx cannot be tried again with it. A resolution that fails
144
+ * for any reason but a missing package registers tsx, whose resolver may
145
+ * still complete it.
136
146
  */
137
147
  export declare function importLexiconPackage(spec: string, fromDir?: string): Promise<Record<string, unknown>>;
138
148
  //# sourceMappingURL=lexicon-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-module.d.ts","sourceRoot":"","sources":["../src/lexicon-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F,mEAAmE;AACnE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAExE;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAAC;AAC/E,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAiBvG;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,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,EAAE,MAAM,CAAe,GAC/C,MAAM,EAAE,CAEV;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9D;AAUD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsB,GAAG,MAAM,GAAG,SAAS,CAMpG;AAcD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqB1H"}
@@ -26,8 +26,9 @@
26
26
  import { createRequire } from "node:module";
27
27
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
28
28
  import { pathToFileURL } from "node:url";
29
- import { ensureTypeScriptLoader } from "./ts-loader.js";
29
+ import { ensureTypeScriptLoader, ensureTypeScriptLoaderFor, typeScriptLoaderPending } from "./ts-loader.js";
30
30
  import { esModuleNamespace } from "./module-interop.js";
31
+ import { isJavaScriptModule } from "./module-source.js";
31
32
  /** The lexicon name an entry declares, whichever form it takes. */
32
33
  export function lexiconDeclarationName(entry) {
33
34
  return typeof entry === "string" ? entry : entry.name;
@@ -154,13 +155,17 @@ export function resetLexiconModules() {
154
155
  * `typeScript: false` imports it with plain node, without registering tsx
155
156
  * (#3276): tsx's ESM hooks run on a thread of their own, which costs the
156
157
  * compiled CLI about 200 MB, so a caller whose module is JavaScript says so.
158
+ * Left out, the module's extension decides (#3981): a `.js` or `.mjs` module
159
+ * imports with plain node, and anything else (`.ts`, or no extension, which
160
+ * only tsx's resolver completes) registers tsx first.
157
161
  */
158
162
  export async function importLexiconModule(name, options = {}) {
159
163
  const path = modulePaths.get(name);
160
164
  if (path === undefined)
161
165
  return undefined;
162
166
  try {
163
- if (options.typeScript !== false)
167
+ const typeScript = options.typeScript ?? !isJavaScriptModule(path);
168
+ if (typeScript)
164
169
  ensureTypeScriptLoader();
165
170
  return esModuleNamespace((await import(path)));
166
171
  }
@@ -221,6 +226,19 @@ export function resolveFromProject(spec, fromDir = process.cwd()) {
221
226
  return undefined;
222
227
  }
223
228
  }
229
+ /**
230
+ * #3981 — where `spec` resolves from this module, as `import(spec)` here
231
+ * would resolve it. Throws as the import would when it cannot be resolved.
232
+ * An absolute path is its own file URL.
233
+ */
234
+ function resolveImport(spec) {
235
+ if (isAbsolute(spec))
236
+ return pathToFileURL(spec).href;
237
+ const resolveMeta = import.meta.resolve;
238
+ if (typeof resolveMeta === "function")
239
+ return resolveMeta(spec);
240
+ return pathToFileURL(createRequire(import.meta.url).resolve(spec)).href;
241
+ }
224
242
  /**
225
243
  * chant#2845 — import a lexicon package, or one of its subpaths, by its bare
226
244
  * specifier. chant's own install is tried first, as a bare `import()` always
@@ -229,19 +247,46 @@ export function resolveFromProject(spec, fromDir = process.cwd()) {
229
247
  * that installs its lexicons in its own node_modules, it is resolved from
230
248
  * `fromDir` (the project) and imported from there. Any other failure, and a
231
249
  * package the project doesn't have either, rethrows the first error.
250
+ *
251
+ * #3981 — tsx is registered only when the module resolves to TypeScript. A
252
+ * lexicon that ships compiled JS imports with plain node. The module is
253
+ * resolved before it is imported, because a failed import is cached: one
254
+ * tried without tsx cannot be tried again with it. A resolution that fails
255
+ * for any reason but a missing package registers tsx, whose resolver may
256
+ * still complete it.
232
257
  */
233
258
  export async function importLexiconPackage(spec, fromDir = process.cwd()) {
259
+ const pkg = packageNameOf(spec);
260
+ if (typeScriptLoaderPending()) {
261
+ let resolved;
262
+ try {
263
+ resolved = resolveImport(spec);
264
+ }
265
+ catch (err) {
266
+ if (pkg === undefined || !isPackageNotFound(err, pkg)) {
267
+ ensureTypeScriptLoader();
268
+ }
269
+ else {
270
+ return importFromProject(spec, fromDir, err);
271
+ }
272
+ }
273
+ if (resolved !== undefined)
274
+ ensureTypeScriptLoaderFor(resolved);
275
+ }
234
276
  try {
235
- ensureTypeScriptLoader();
236
277
  return esModuleNamespace((await import(spec)));
237
278
  }
238
279
  catch (err) {
239
- const pkg = packageNameOf(spec);
240
280
  if (pkg === undefined || !isPackageNotFound(err, pkg))
241
281
  throw err;
242
- const resolved = resolveFromProject(spec, fromDir);
243
- if (resolved === undefined)
244
- throw err;
245
- return esModuleNamespace((await import(pathToFileURL(resolved).href)));
282
+ return importFromProject(spec, fromDir, err);
246
283
  }
247
284
  }
285
+ /** The project's copy of `spec`, for {@link importLexiconPackage}. Rethrows `err` when the project has none. */
286
+ async function importFromProject(spec, fromDir, err) {
287
+ const resolved = resolveFromProject(spec, fromDir);
288
+ if (resolved === undefined)
289
+ throw err;
290
+ ensureTypeScriptLoaderFor(resolved);
291
+ return esModuleNamespace((await import(pathToFileURL(resolved).href)));
292
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-plugin-helpers.d.ts","sourceRoot":"","sources":["../src/lexicon-plugin-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG;IAC7D,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,aAAa,EAAE,GACrB,MAAM,eAAe,EAAE,CAYzB;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,mBAAmB,CAsBrB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,uBAAuB,CAmBzB"}
1
+ {"version":3,"file":"lexicon-plugin-helpers.d.ts","sourceRoot":"","sources":["../src/lexicon-plugin-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG;IAC7D,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,aAAa,EAAE,GACrB,MAAM,eAAe,EAAE,CAazB;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,mBAAmB,CAsBrB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,uBAAuB,CAoBzB"}
@@ -6,8 +6,8 @@
6
6
  * MCP diff tool, and MCP catalog resource.
7
7
  */
8
8
  import { readFileSync } from "fs";
9
- import { join, dirname } from "path";
10
- import { fileURLToPath } from "url";
9
+ import { join } from "path";
10
+ import { moduleSourceDir } from "./module-source.js";
11
11
  /**
12
12
  * Create a skills loader that reads .md files from a lexicon's skills directory.
13
13
  *
@@ -25,7 +25,8 @@ import { fileURLToPath } from "url";
25
25
  */
26
26
  export function createSkillsLoader(importMetaUrl, specs) {
27
27
  return () => {
28
- const skillsDir = join(dirname(fileURLToPath(importMetaUrl)), "skills");
28
+ // Skills are markdown beside the source; a compiled plugin finds them under src/ (#3981).
29
+ const skillsDir = join(moduleSourceDir(importMetaUrl), "skills");
29
30
  return specs.map(({ file, ...meta }) => {
30
31
  try {
31
32
  const content = readFileSync(join(skillsDir, file), "utf-8");
@@ -91,7 +92,8 @@ export function createCatalogResource(importMetaUrl, name, description, lexiconJ
91
92
  description,
92
93
  mimeType: "application/json",
93
94
  async handler() {
94
- const dir = dirname(fileURLToPath(importMetaUrl));
95
+ // Generated JSON sits beside the source; a compiled plugin finds it under src/ (#3981).
96
+ const dir = moduleSourceDir(importMetaUrl);
95
97
  const lexicon = JSON.parse(readFileSync(join(dir, "generated", lexiconJsonFile), "utf-8"));
96
98
  const entries = Object.entries(lexicon).map(([className, entry]) => ({
97
99
  className,
package/dist/lexicon.d.ts CHANGED
@@ -470,6 +470,8 @@ export interface ComponentPipelineOptions {
470
470
  * `wave-<k>` runs `chant components fan-out --wave-gate <gate> --wave <k>`
471
471
  * and hands the attempt record to the next job. See
472
472
  * `components/gated-wave-pipeline.ts`. Unset, the pipeline is unchanged.
473
+ * Beside `prLoop` (#4003) it gives the pull request's apply a gate per
474
+ * wave instead: one apply job per wave (`prLoopWithWaves`).
473
475
  */
474
476
  gatedWaves?: GatedWavePipelineOptions;
475
477
  /**