@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.
- package/bin/chant +7 -2
- package/dist/cli/commands/check-lexicon-plugin.d.ts +7 -4
- package/dist/cli/commands/check-lexicon-plugin.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon-plugin.js +10 -7
- package/dist/cli/commands/check-lexicon.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon.js +18 -12
- package/dist/cli/commands/import.d.ts +10 -0
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +37 -0
- package/dist/cli/commands/init-lexicon/templates/project.d.ts.map +1 -1
- package/dist/cli/commands/init-lexicon/templates/project.js +4 -3
- package/dist/cli/commands/onboard.d.ts.map +1 -1
- package/dist/cli/commands/onboard.js +8 -4
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +2 -1
- package/dist/cli/dependencies.d.ts +18 -0
- package/dist/cli/dependencies.d.ts.map +1 -0
- package/dist/cli/dependencies.js +120 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +23 -4
- package/dist/cli/handlers/fan-out.d.ts.map +1 -1
- package/dist/cli/handlers/fan-out.js +12 -4
- package/dist/cli/handlers/graph.d.ts.map +1 -1
- package/dist/cli/handlers/graph.js +16 -6
- package/dist/cli/handlers/lint.d.ts.map +1 -1
- package/dist/cli/handlers/lint.js +6 -0
- package/dist/cli/handlers/operator.d.ts +2 -2
- package/dist/cli/handlers/operator.js +3 -3
- package/dist/cli/handlers/pr.d.ts +14 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +488 -32
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +3 -1
- package/dist/cli/handlers/run.d.ts +13 -1
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +38 -15
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +44 -16
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +15 -0
- package/dist/cli/registry.d.ts +13 -4
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cli/registry.js +6 -2
- package/dist/codegen/generate-post-synth-barrel.js +2 -2
- package/dist/codegen/lexicon-regen.d.ts +4 -0
- package/dist/codegen/lexicon-regen.d.ts.map +1 -1
- package/dist/codegen/lexicon-regen.js +1 -1
- package/dist/codegen/pinned-upgrade.js +2 -2
- package/dist/components/capability.d.ts +44 -3
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/capability.js +21 -0
- package/dist/components/changed-files.d.ts +7 -1
- package/dist/components/changed-files.d.ts.map +1 -1
- package/dist/components/changed-files.js +9 -1
- package/dist/components/driver.d.ts +38 -0
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +47 -6
- package/dist/components/fan-out-record.d.ts +6 -1
- package/dist/components/fan-out-record.d.ts.map +1 -1
- package/dist/components/fan-out-record.js +24 -0
- package/dist/components/fan-out-run.d.ts +20 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +21 -1
- package/dist/components/pr-pipeline.d.ts +65 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +107 -15
- package/dist/components/pr-run.d.ts +127 -29
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +290 -70
- package/dist/components/wave-plan.d.ts +5 -2
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +12 -1
- package/dist/discovery/fold-import.d.ts.map +1 -1
- package/dist/discovery/fold-import.js +16 -6
- package/dist/discovery/sandbox/bundle.d.ts.map +1 -1
- package/dist/discovery/sandbox/bundle.js +6 -0
- package/dist/discovery/specifier-resolve.d.ts.map +1 -1
- package/dist/discovery/specifier-resolve.js +8 -2
- package/dist/fold/fold.d.ts.map +1 -1
- package/dist/fold/fold.js +68 -1
- package/dist/fold/subset.d.ts +37 -0
- package/dist/fold/subset.d.ts.map +1 -1
- package/dist/fold/subset.js +88 -0
- package/dist/lexicon-module.d.ts +10 -0
- package/dist/lexicon-module.d.ts.map +1 -1
- package/dist/lexicon-module.js +53 -8
- package/dist/lexicon-plugin-helpers.d.ts.map +1 -1
- package/dist/lexicon-plugin-helpers.js +6 -4
- package/dist/lexicon.d.ts +2 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/affected.d.ts.map +1 -1
- package/dist/lifecycle/affected.js +7 -1
- package/dist/lifecycle/release-ledger.d.ts +21 -0
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +24 -0
- package/dist/lifecycle/work-dir.d.ts +45 -0
- package/dist/lifecycle/work-dir.d.ts.map +1 -0
- package/dist/lifecycle/work-dir.js +78 -0
- package/dist/lint/discover.d.ts +17 -9
- package/dist/lint/discover.d.ts.map +1 -1
- package/dist/lint/discover.js +62 -54
- package/dist/module-source.d.ts +57 -0
- package/dist/module-source.d.ts.map +1 -0
- package/dist/module-source.js +104 -0
- package/dist/op/activities/factory.js +1 -1
- package/dist/op/discover.d.ts.map +1 -1
- package/dist/op/discover.js +13 -3
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +3 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +20 -5
- package/dist/op/operator.d.ts +2 -2
- package/dist/op/operator.js +2 -2
- package/dist/op/steward.d.ts +6 -4
- package/dist/op/steward.d.ts.map +1 -1
- package/dist/op/steward.js +5 -3
- package/dist/op/work-lease-run.d.ts +20 -7
- package/dist/op/work-lease-run.d.ts.map +1 -1
- package/dist/op/work-lease-run.js +56 -12
- package/dist/pr-forge.d.ts +10 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +39 -0
- package/dist/pr-loop.d.ts +141 -4
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +122 -6
- package/dist/pr-report-url.d.ts +2 -2
- package/dist/pr-report-url.d.ts.map +1 -1
- package/dist/pr-report-url.js +5 -5
- package/dist/ts-loader.d.ts +38 -4
- package/dist/ts-loader.d.ts.map +1 -1
- package/dist/ts-loader.js +190 -16
- package/dist/wave-runtime.mjs +208 -208
- package/dist/workspace/chant-migrations/fountain-retired-kinds.d.ts +34 -0
- package/dist/workspace/chant-migrations/fountain-retired-kinds.d.ts.map +1 -0
- package/dist/workspace/chant-migrations/fountain-retired-kinds.js +176 -0
- package/dist/workspace/chant-migrations.d.ts.map +1 -1
- package/dist/workspace/chant-migrations.js +2 -0
- package/dist/workspace/checks/boxes.d.ts +6 -6
- package/dist/workspace/checks/boxes.js +9 -9
- package/dist/workspace/ci-green-forge.d.ts +6 -4
- package/dist/workspace/ci-green-forge.d.ts.map +1 -1
- package/dist/workspace/ci-green.d.ts +28 -12
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +49 -21
- package/dist/workspace/ci-list.schema.json +12 -6
- package/dist/workspace/ci-report-url.d.ts +18 -0
- package/dist/workspace/ci-report-url.d.ts.map +1 -0
- package/dist/workspace/ci-report-url.js +33 -0
- package/dist/workspace/ci-run-index.d.ts +12 -0
- package/dist/workspace/ci-run-index.d.ts.map +1 -1
- package/dist/workspace/ci-run-index.js +6 -4
- package/dist/workspace/ci-run-index.schema.json +5 -3
- package/dist/workspace/ci-run.d.ts +75 -2
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +195 -53
- package/dist/workspace/ci-runner-key.d.ts +16 -3
- package/dist/workspace/ci-runner-key.d.ts.map +1 -1
- package/dist/workspace/ci-runner-key.js +30 -10
- package/dist/workspace/ci-serve.d.ts +54 -4
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +175 -26
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +11 -2
- package/dist/workspace/declaration.schema.json +7 -2
- package/dist/workspace/export.d.ts +1 -1
- package/dist/workspace/export.d.ts.map +1 -1
- package/dist/workspace/export.js +7 -3
- package/dist/workspace/ls.d.ts +6 -1
- package/dist/workspace/ls.d.ts.map +1 -1
- package/dist/workspace/ls.js +1 -0
- package/dist/workspace/ls.schema.json +7 -1
- package/dist/workspace/pin-integrity.d.ts.map +1 -1
- package/dist/workspace/pin-integrity.js +3 -2
- package/dist/workspace/pr-report.schema.json +74 -7
- package/dist/workspace/reason-codes.d.ts +1 -1
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +2 -2
- package/dist/workspace/run-event.schema.json +3 -1
- package/dist/workspace/status.schema.json +3 -1
- package/dist/workspace/write-scope.d.ts +9 -0
- package/dist/workspace/write-scope.d.ts.map +1 -1
- package/dist/workspace/write-scope.js +11 -1
- package/package.json +1 -1
- package/src/__fixtures__/pr-loop/pr-apply-wave-waiting.note.golden.md +48 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/package.json +3 -3
- package/src/cli/commands/audit.test.ts +2 -2
- package/src/cli/commands/check-lexicon-plugin.test.ts +9 -0
- package/src/cli/commands/check-lexicon-plugin.ts +11 -8
- package/src/cli/commands/check-lexicon.test.ts +1 -1
- package/src/cli/commands/check-lexicon.ts +16 -11
- package/src/cli/commands/import.ts +40 -0
- package/src/cli/commands/init-lexicon/templates/project.ts +4 -3
- package/src/cli/commands/init-lexicon.test.ts +8 -5
- package/src/cli/commands/onboard.test.ts +45 -0
- package/src/cli/commands/onboard.ts +8 -4
- package/src/cli/commands/update.test.ts +6 -0
- package/src/cli/commands/update.ts +4 -1
- package/src/cli/compiled-cli.e2e.test.ts +76 -11
- package/src/cli/dependencies.e2e.test.ts +101 -0
- package/src/cli/dependencies.test.ts +93 -0
- package/src/cli/dependencies.ts +122 -0
- package/src/cli/handlers/build.test.ts +69 -0
- package/src/cli/handlers/build.ts +20 -4
- package/src/cli/handlers/fan-out.test.ts +73 -0
- package/src/cli/handlers/fan-out.ts +11 -4
- package/src/cli/handlers/graph.test.ts +76 -0
- package/src/cli/handlers/graph.ts +19 -12
- package/src/cli/handlers/lint.test.ts +42 -0
- package/src/cli/handlers/lint.ts +6 -0
- package/src/cli/handlers/operator.ts +3 -3
- package/src/cli/handlers/pr-waves.test.ts +449 -0
- package/src/cli/handlers/pr.test.ts +134 -0
- package/src/cli/handlers/pr.ts +523 -31
- package/src/cli/handlers/promote.test.ts +26 -1
- package/src/cli/handlers/promote.ts +3 -2
- package/src/cli/handlers/run-components-exit.test.ts +99 -0
- package/src/cli/handlers/run-signer.test.ts +79 -0
- package/src/cli/handlers/run.ts +34 -16
- package/src/cli/main.test.ts +18 -0
- package/src/cli/main.ts +43 -16
- package/src/cli/parse-args.ts +12 -0
- package/src/cli/registry.ts +19 -6
- package/src/codegen/generate-post-synth-barrel.ts +2 -2
- package/src/codegen/lexicon-regen.ts +1 -1
- package/src/codegen/pinned-upgrade.ts +2 -2
- package/src/codegen/post-synth-barrel-guards.test.ts +6 -11
- package/src/components/capability.ts +51 -3
- package/src/components/changed-files.test.ts +16 -1
- package/src/components/changed-files.ts +9 -1
- package/src/components/driver.test.ts +36 -1
- package/src/components/driver.ts +76 -4
- package/src/components/fan-out-record.ts +29 -1
- package/src/components/fan-out-run.test.ts +35 -0
- package/src/components/fan-out-run.ts +40 -1
- package/src/components/pr-pipeline.test.ts +100 -0
- package/src/components/pr-pipeline.ts +132 -17
- package/src/components/pr-run.test.ts +323 -18
- package/src/components/pr-run.ts +354 -75
- package/src/components/wave-plan.ts +16 -4
- package/src/discovery/fold-host-method.test.ts +87 -0
- package/src/discovery/fold-import.ts +15 -5
- package/src/discovery/fold-package-composite.test.ts +27 -0
- package/src/discovery/fold-specifiers.test.ts +8 -0
- package/src/discovery/sandbox/bundle.ts +6 -0
- package/src/discovery/specifier-resolve.ts +8 -2
- package/src/fold/fold.test.ts +72 -0
- package/src/fold/fold.ts +71 -0
- package/src/fold/subset.test.ts +31 -0
- package/src/fold/subset.ts +99 -0
- package/src/lexicon-dist.e2e.test.ts +254 -0
- package/src/lexicon-module.test.ts +47 -0
- package/src/lexicon-module.ts +49 -7
- package/src/lexicon-plugin-helpers.ts +6 -4
- package/src/lexicon.ts +2 -0
- package/src/lifecycle/affected.test.ts +7 -0
- package/src/lifecycle/affected.ts +6 -1
- package/src/lifecycle/release-ledger.ts +34 -0
- package/src/lifecycle/work-dir.test.ts +77 -0
- package/src/lifecycle/work-dir.ts +82 -0
- package/src/lint/discover.test.ts +46 -2
- package/src/lint/discover.ts +55 -49
- package/src/module-source.test.ts +85 -0
- package/src/module-source.ts +112 -0
- package/src/op/activities/factory.ts +1 -1
- package/src/op/discover-root.test.ts +31 -2
- package/src/op/discover.ts +14 -4
- package/src/op/gate.test.ts +30 -0
- package/src/op/gate.ts +3 -0
- package/src/op/op-waves-run.ts +20 -5
- package/src/op/op-waves.test.ts +49 -0
- package/src/op/operator.ts +2 -2
- package/src/op/steward.ts +6 -4
- package/src/op/work-lease-run.test.ts +88 -2
- package/src/op/work-lease-run.ts +52 -12
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +42 -0
- package/src/pr-forge.ts +40 -0
- package/src/pr-loop-bundle.test.ts +2 -1
- package/src/pr-loop.test.ts +117 -1
- package/src/pr-loop.ts +252 -10
- package/src/pr-report-url.ts +5 -5
- package/src/terraform/__fixtures__/advise.test.ts +21 -2
- package/src/ts-loader.test.ts +89 -1
- package/src/ts-loader.ts +180 -13
- package/src/workspace/changes.test.ts +1 -1
- package/src/workspace/chant-migrations/fountain-retired-kinds.test.ts +33 -0
- package/src/workspace/chant-migrations/fountain-retired-kinds.ts +190 -0
- package/src/workspace/chant-migrations.e2e.test.ts +5 -0
- package/src/workspace/chant-migrations.ts +2 -0
- package/src/workspace/checks/boxes.ts +9 -9
- package/src/workspace/ci-green-forge.ts +6 -4
- package/src/workspace/ci-green-runs.test.ts +53 -11
- package/src/workspace/ci-green.test.ts +1 -1
- package/src/workspace/ci-green.ts +50 -22
- package/src/workspace/ci-list.schema.json +12 -6
- package/src/workspace/ci-report-url.test.ts +220 -0
- package/src/workspace/ci-report-url.ts +33 -0
- package/src/workspace/ci-run-index.schema.json +5 -3
- package/src/workspace/ci-run-index.test.ts +42 -3
- package/src/workspace/ci-run-index.ts +18 -4
- package/src/workspace/ci-run.test.ts +185 -7
- package/src/workspace/ci-run.ts +224 -54
- package/src/workspace/ci-runner-key.test.ts +55 -17
- package/src/workspace/ci-runner-key.ts +36 -11
- package/src/workspace/ci-serve.test.ts +150 -6
- package/src/workspace/ci-serve.ts +169 -25
- package/src/workspace/declaration.schema.json +7 -2
- package/src/workspace/declaration.test.ts +23 -0
- package/src/workspace/declaration.ts +19 -3
- package/src/workspace/export.ts +6 -3
- package/src/workspace/ls.schema.json +7 -1
- package/src/workspace/ls.ts +7 -2
- package/src/workspace/pin-integrity.test.ts +5 -0
- package/src/workspace/pin-integrity.ts +3 -2
- package/src/workspace/pr-report.schema.json +74 -7
- package/src/workspace/reason-codes.ts +2 -2
- package/src/workspace/run-event.schema.json +3 -1
- package/src/workspace/status.schema.json +3 -1
- package/src/workspace/write-scope.test.ts +29 -1
- 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":"
|
|
1
|
+
{"version":3,"file":"specifier-resolve.d.ts","sourceRoot":"","sources":["../../src/discovery/specifier-resolve.ts"],"names":[],"mappings":"AA4BA,oDAAoD;AACpD,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5C;AAmBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmBhE;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAOnG;AAmCD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA0B/F;AA+ID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,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
|
-
/**
|
|
91
|
-
|
|
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
|
package/dist/fold/fold.d.ts.map
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/fold/fold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CA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,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
|
*
|
package/dist/fold/subset.d.ts
CHANGED
|
@@ -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;AAElC,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/C,uGAAuG;AACvG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,0FAA0F;AAC1F,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,EAAE,CAAC,UAAU,CAchE,CAAC;AAEH,oFAAoF;AACpF,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,EAAE,CAAC,UAAU,CAG/D,CAAC;AAEH,gHAAgH;AAChH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,EAAE,CAAC,YAAY,GACpB,IAAI,IAAI,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,aAAa,GAAG,EAAE,CAAC,cAAc,CAE9D;AAED,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,EA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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"}
|
package/dist/fold/subset.js
CHANGED
|
@@ -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;
|
package/dist/lexicon-module.d.ts
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"lexicon-module.d.ts","sourceRoot":"","sources":["../src/lexicon-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MA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6CAA6C;AAC7C,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACrC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAa9C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAsB,EAC/B,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAe,GAC/C,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,GAAE,WAAW,CAAC,MAAM,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"}
|
package/dist/lexicon-module.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
10
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
/**
|