@multiplatform.one/cli 7.90.6 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ A project is the multiplatform.one monorepo at one commit, pruned:
30
30
  - `public/` is gone; `@multiplatform.one/*` come from npmjs, the default
31
31
  registry, at `^<cli version>` (`--mpo-version` overrides the range).
32
32
  - The singleton apps are ethereum, frappe, keycloak, solana, storybook,
33
- storybook-expo, sui, uxpin and vocs; only the ones asked for stay.
33
+ storybook-expo, sui and vocs; only the ones asked for stay.
34
34
  `--frappe` and `--keycloak` are shorthands for `--service`.
35
35
  - Without `--service frappe` the project keeps the Frappe client
36
36
  (`createApp`'s wiring, the `# frappe client` keys in `.env.example`) and
@@ -94,11 +94,16 @@ git add -A && git commit -m "chore: mpo update <old> → <new>"
94
94
 
95
95
  A three-way merge: **base** is the scaffold at the commit recorded in
96
96
  `.mpo.json` with the recorded apps and services, **ours** is your `HEAD`,
97
- **theirs** is the same scaffold at the commit this CLI was built from (or
98
- `--source`/`--checkout`). Your commits are preserved, the monorepo's changes
99
- land as the diff, every product app receives the One app's changes, and
100
- nothing is committed. Conflicts land with normal markers; `pnpm install` runs
101
- on a clean merge (`--skip-install` to skip it).
97
+ **theirs** is that selection scaffolded at the commit this CLI was built
98
+ from (or `--source`/`--checkout`). Your commits are preserved, the
99
+ monorepo's changes land as the diff, every product app receives the One
100
+ app's changes, and nothing is committed. Conflicts land with normal markers;
101
+ `pnpm install` runs on a clean merge (`--skip-install` to skip it).
102
+
103
+ Each side runs the `scaffold.sh` its own commit carries, so whatever the
104
+ scaffold changed since your recorded commit lands too: a root rule it now
105
+ drops is removed from your project. If you edited those lines, the file
106
+ conflicts instead.
102
107
 
103
108
  `.updateignore` entries (exact files or directory prefixes, not globs) and
104
109
  `pnpm-lock.yaml` stay pinned to your version. Dependency-range drift in
@@ -168,7 +173,8 @@ sh scripts/scaffold.sh [--app <name>]... [--service <name>]... [--mpo-version <r
168
173
  `pnpm --filter @multiplatform.one/cli test` runs the vitest specs: the
169
174
  provenance and merge units, and `updateApp.spec.ts`, which scaffolds from
170
175
  this checkout at `HEAD`, updates from a second clone that moved ahead, and
171
- adds an app. `make -C public/cli test/bats` runs `tests/*.bats` against
176
+ adds an app, and `updateCleanups.spec.ts`, which updates from a stand-in
177
+ monorepo whose scaffold gains a cleanup. `make -C public/cli test/bats` runs `tests/*.bats` against
172
178
  `scripts/scaffold.sh` directly (needs `bats`). `pnpm build` stamps
173
179
  `lib/source.json` from `git rev-parse HEAD` (`MPO_SOURCE_SHA` /
174
180
  `MPO_SOURCE_URL` override it), unless `HEAD` carries another CLI version;
@@ -53,21 +53,12 @@ async function getPresentAppNames(projectRoot) {
53
53
  return [];
54
54
  }
55
55
  }
56
- /** Discover app that has Playwright config (for E2E test cwd). Returns app name (e.g. "one") or null. */
56
+ /** Discover the app whose package.json names it the e2e app (`"mpo": { "e2e": true }`), for E2E test cwd. Returns app name (e.g. "one") or null. */
57
57
  async function discoverE2EApp(projectRoot) {
58
- const names = await getPresentAppNames(projectRoot);
59
- for (const name of names) {
60
- const appPath = path.join(projectRoot, "apps", name);
61
- for (const config of [
62
- "playwright.config.ts",
63
- "playwright.config.js",
64
- "playwright.config.mjs"
65
- ]) try {
66
- await fs.access(path.join(appPath, config));
67
- return name;
68
- } catch {}
69
- }
70
- return null;
58
+ const named = [];
59
+ for (const name of await getPresentAppNames(projectRoot)) if (JSON.parse(await fs.readFile(path.join(projectRoot, "apps", name, "package.json"), "utf8"))?.mpo?.e2e === true) named.push(name);
60
+ if (named.length > 1) throw new Error(`more than one app sets "mpo": { "e2e": true } in its package.json: ${named.join(", ")}. Keep it on the one app mpo test e2e should run and delete it from the others.`);
61
+ return named[0] ?? null;
71
62
  }
72
63
  async function detectServices(projectRoot) {
73
64
  const services = [];
@@ -255,7 +246,7 @@ async function runE2ESession(projectRoot, options) {
255
246
  if (options.upOnly) return;
256
247
  const e2eApp = await discoverE2EApp(projectRoot);
257
248
  if (!e2eApp) {
258
- console.error("No E2E app found: no app under apps/ has playwright.config.ts or playwright.config.js.");
249
+ console.error("No E2E app found: no apps/*/package.json sets \"mpo\": { \"e2e\": true }.");
259
250
  await tearDown(projectRoot, sessionFilePath);
260
251
  process.exit(1);
261
252
  }
@@ -23,7 +23,6 @@ const SINGLETON_APPS = [
23
23
  "storybook",
24
24
  "storybook-expo",
25
25
  "sui",
26
- "uxpin",
27
26
  "vocs"
28
27
  ];
29
28
  const SINGLETON_DESCRIPTIONS = {
@@ -34,7 +33,6 @@ const SINGLETON_DESCRIPTIONS = {
34
33
  storybook: "Storybook (web)",
35
34
  "storybook-expo": "Storybook (native)",
36
35
  sui: "Move packages + localnet",
37
- uxpin: "UXPin Merge library",
38
36
  vocs: "Docs site"
39
37
  };
40
38
  function unique(values) {
@@ -25,9 +25,9 @@ function reportKept(stdout) {
25
25
  for (const path of kept) console.log(` ${path}`);
26
26
  }
27
27
  /** Run scaffold.sh and return the provenance it wrote. */
28
- async function runScaffold(request) {
28
+ async function runScaffold(request, script = scaffoldScript()) {
29
29
  await checkSourceAccess(request.source);
30
- const args = [scaffoldScript()];
30
+ const args = [script];
31
31
  for (const app of request.apps) args.push("--app", app);
32
32
  for (const service of request.services) args.push("--service", service);
33
33
  if (request.mpoVersion) args.push("--mpo-version", request.mpoVersion);
@@ -50,6 +50,62 @@ async function runScaffold(request) {
50
50
  if (!provenance?.source) throw new ScaffoldError(`scaffold.sh wrote no provenance into ${request.target}`, request);
51
51
  return provenance;
52
52
  }
53
+ /** Where the monorepo keeps its scaffold, at every commit since MPO-310. */
54
+ const scaffoldPath = "public/cli/scripts/scaffold.sh";
55
+ /**
56
+ * Write the scaffold.sh that `source` carries at `ref` to `file`; false when
57
+ * that commit carries none. A merge baseline made with it is what that
58
+ * commit's own CLI scaffolded, so whatever the scaffold learned between two
59
+ * commits (a cleanup of root wiring, say) is part of the difference between
60
+ * their baselines and reaches the project, with no step of it named here. A
61
+ * url is fetched shallow and blobless, then the one blob, as scaffold.sh does.
62
+ */
63
+ async function scaffoldScriptAt(source, ref, file) {
64
+ await checkSourceAccess(source);
65
+ const script = [
66
+ "set -eu",
67
+ "SOURCE=\"$1\"; REF=\"$2\"; SCRIPT=\"$3\"; OUT=\"$4\"",
68
+ "if [ -d \"$SOURCE\" ]; then",
69
+ " REPO=\"$SOURCE\"",
70
+ " COMMIT=\"$(git -C \"$REPO\" rev-parse --verify --quiet \"$REF^{commit}\")\" ||",
71
+ " { printf \"%s is not a commit in %s\\n\" \"$REF\" \"$REPO\" >&2; exit 1; }",
72
+ "else",
73
+ " REPO=\"$(mktemp -d \"${TMPDIR:-/tmp}/mpo-scaffold-script.XXXXXX\")\"",
74
+ " trap 'rm -rf \"$REPO\"' EXIT",
75
+ " git init -q \"$REPO\"",
76
+ " git -C \"$REPO\" remote add origin \"$SOURCE\"",
77
+ " git -C \"$REPO\" fetch -q --depth 1 --filter=blob:none origin \"$REF\"",
78
+ " COMMIT=\"$(git -C \"$REPO\" rev-parse --verify --quiet \"FETCH_HEAD^{commit}\")\"",
79
+ "fi",
80
+ "BLOB=\"$(git -C \"$REPO\" ls-tree \"$COMMIT\" -- \"$SCRIPT\" | awk '$2 == \"blob\" { print $3 }')\"",
81
+ "[ -n \"$BLOB\" ] || exit 3",
82
+ "if [ \"$(git -C \"$REPO\" config --get remote.origin.promisor || true)\" = true ]; then",
83
+ " printf \"%s\\n\" \"$BLOB\" | git -C \"$REPO\" -c fetch.negotiationAlgorithm=noop fetch -q \\",
84
+ " --no-tags --no-write-fetch-head --filter=blob:none --stdin origin",
85
+ "fi",
86
+ "git -C \"$REPO\" cat-file blob \"$BLOB\" >\"$OUT\""
87
+ ].join("\n");
88
+ try {
89
+ await spawn("sh", [
90
+ "-c",
91
+ script,
92
+ "sh",
93
+ source,
94
+ ref,
95
+ scaffoldPath,
96
+ file
97
+ ], { stdio: [
98
+ "ignore",
99
+ "ignore",
100
+ "pipe"
101
+ ] });
102
+ return true;
103
+ } catch (err) {
104
+ if (err.exitCode === 3) return false;
105
+ const detail = (err.stderr ?? "").trim().split("\n").filter(Boolean).pop() ?? err.message;
106
+ throw new Error(`could not read ${scaffoldPath} at ${ref} from ${source}: ${detail}`);
107
+ }
108
+ }
53
109
  /** A scaffold in a temp dir (merge baselines). */
54
110
  async function scaffoldToTemp(request) {
55
111
  const parent = mkdtempSync(join(tmpdir(), "mpo-scaffold-"));
@@ -59,12 +115,15 @@ async function scaffoldToTemp(request) {
59
115
  force: true
60
116
  });
61
117
  try {
118
+ const script = join(parent, "scaffold.sh");
119
+ const carried = await scaffoldScriptAt(request.source, request.ref, script);
120
+ if (!carried) console.warn(`⚠️ ${request.ref} carries no ${scaffoldPath}; using this CLI's for that side`);
62
121
  return {
63
122
  dir,
64
123
  provenance: await runScaffold({
65
124
  ...request,
66
125
  target: dir
67
- }),
126
+ }, carried ? script : void 0),
68
127
  cleanup
69
128
  };
70
129
  } catch (err) {
@@ -1,4 +1,3 @@
1
- import { discoverE2EApp } from "./e2e.mjs";
2
1
  import fsSync from "node:fs";
3
2
  import path from "node:path";
4
3
  import fs from "node:fs/promises";
@@ -110,13 +109,15 @@ function parseTestTiers(args) {
110
109
  /**
111
110
  * `bench run-tests` for every frappe app with a pyproject.toml, limited to the
112
111
  * pytest marker expression. Skipped when the bench is not bootstrapped
113
- * (no apps/frappe/sites); once it is, any app whose run fails fails the tier.
112
+ * (no apps/frappe/sites), or failed when `required`; once it is, any app
113
+ * whose run fails fails the tier.
114
114
  */
115
- async function runBenchTests(projectRoot, marker, spawn) {
115
+ async function runBenchTests(projectRoot, marker, spawn, required) {
116
116
  const benchDir = path.join(projectRoot, "apps", "frappe");
117
117
  const apps = (await getFrappeApps(projectRoot)).filter((app) => fsSync.existsSync(path.join(app.absolutePath, "pyproject.toml")));
118
118
  if (!apps.length) return;
119
119
  if (!fsSync.existsSync(path.join(benchDir, "sites"))) {
120
+ if (required) throw new Error(`no frappe bench (apps/frappe/sites): bench tests -m "${marker}" need one`);
120
121
  console.warn(`no frappe bench (apps/frappe/sites): skipped bench tests -m "${marker}"`);
121
122
  return;
122
123
  }
@@ -139,25 +140,45 @@ async function runBenchTests(projectRoot, marker, spawn) {
139
140
  }
140
141
  if (failed.length) throw new Error(`bench tests -m "${marker}" failed: ${failed.join(", ")}`);
141
142
  }
142
- /** The unit tier: turbo test minus missing services and the e2e app, then the bench's non-integration tests. */
143
+ /** The unit tier: turbo test minus missing services, then the bench's non-integration tests. */
143
144
  async function runUnitTests(projectRoot, spawn$1 = spawn) {
144
- const excludeFilters = await getTurboExcludeFiltersForMissing(projectRoot);
145
- const e2eApp = await discoverE2EApp(projectRoot);
146
145
  await spawn$1("pnpm", [
147
146
  "turbo",
148
147
  "run",
149
148
  "test",
150
- ...[...excludeFilters.flatMap((f) => ["--filter", f]), ...e2eApp ? ["--filter", `'!./apps/${e2eApp}'`] : []]
149
+ ...(await getTurboExcludeFiltersForMissing(projectRoot)).flatMap((f) => ["--filter", f])
151
150
  ], {
152
151
  stdio: "inherit",
153
152
  shell: true,
154
153
  cwd: projectRoot
155
154
  });
156
- await runBenchTests(projectRoot, "not integration", spawn$1);
155
+ await runBenchTests(projectRoot, "not integration", spawn$1, false);
157
156
  }
158
- /** The integration tier: the bench's integration-marked tests only; the JS suite belongs to unit. */
157
+ /** The integration tier: turbo test:integration, then the bench's integration-marked tests; a missing service fails it. */
159
158
  async function runIntegrationTests(projectRoot, spawn$2 = spawn) {
160
- await runBenchTests(projectRoot, "integration", spawn$2);
159
+ const filters = (await getTurboExcludeFiltersForMissing(projectRoot)).flatMap((f) => ["--filter", f]);
160
+ const failures = [];
161
+ try {
162
+ await spawn$2("pnpm", [
163
+ "turbo",
164
+ "run",
165
+ "test:integration",
166
+ "--continue",
167
+ ...filters
168
+ ], {
169
+ stdio: "inherit",
170
+ shell: true,
171
+ cwd: projectRoot
172
+ });
173
+ } catch (error) {
174
+ failures.push(error.message);
175
+ }
176
+ try {
177
+ await runBenchTests(projectRoot, "integration", spawn$2, true);
178
+ } catch (error) {
179
+ failures.push(error.message);
180
+ }
181
+ if (failures.length) throw new Error(failures.join("\n"));
161
182
  }
162
183
  /** `mpo build`: the packages, then every present app with a build script, each once. */
163
184
  async function runBuild(args, projectRoot, spawn$3 = spawn) {
package/lib/source.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "cliVersion": "7.90.6",
2
+ "cliVersion": "8.1.0",
3
3
  "url": "https://git.corp.bitspur.com/multiplatform.one/mpo.git",
4
- "sha": "5be8b3d5567335c111c400a58bdc37114ab02f01"
4
+ "sha": "e31385ea6386809a964fcf0fe7ac01b1dc2c7668"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/cli",
3
- "version": "7.90.6",
3
+ "version": "8.1.0",
4
4
  "description": "multiplatform.one cli — mpo init clones and prunes the monorepo, mpo update merges it back",
5
5
  "keywords": [
6
6
  "create-multiplatform-app",
@@ -57,7 +57,7 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@multiplatform.one/utils": "^7.90.6",
60
+ "@multiplatform.one/utils": "^8.1.0",
61
61
  "commander": "^15.0.0",
62
62
  "dotenv": "^17.4.2",
63
63
  "inquirer": "^14.2.3",
@@ -17,7 +17,7 @@
17
17
  # --app <name> product app derived from apps/one (repeatable)
18
18
  # --service <name> singleton app under apps/ to keep (repeatable):
19
19
  # ethereum frappe keycloak solana storybook
20
- # storybook-expo sui uxpin vocs
20
+ # storybook-expo sui vocs
21
21
  # --mpo-version <range> range written for @multiplatform.one/* deps
22
22
  # (default: ^<version of public/cli in the source tree>)
23
23
  # --keep <dir> keep a pruned top-level path (repeatable):
@@ -345,6 +345,18 @@ fi
345
345
  for _app in $APPS; do
346
346
  [ ! -e "$TREE/apps/$_app" ] || die "apps/$_app already exists in the source tree; pick another product name"
347
347
  cp -R "$TREE/apps/one" "$TREE/apps/$_app"
348
+ if [ "$_app" != "$FIRST_APP" ]; then
349
+ node - "$TREE/apps/$_app/package.json" <<'NODE'
350
+ const fs = require("node:fs");
351
+ const [file] = process.argv.slice(2);
352
+ const text = fs
353
+ .readFileSync(file, "utf8")
354
+ .replace(/,\n {2}"mpo": \{\n {4}"e2e": true\n {2}\}(?=\n\}\n?$)/, "")
355
+ .replace(/\n {2}"mpo": \{\n {4}"e2e": true\n {2}\},/, "");
356
+ if (JSON.parse(text).mpo?.e2e) throw new Error(`${file}: could not drop "mpo": { "e2e": true }`);
357
+ fs.writeFileSync(file, text);
358
+ NODE
359
+ fi
348
360
  # A feature module of that name already satisfies the app/features twin
349
361
  # (features/pokemon is the One app's own pokemon feature). The index
350
362
  # routes import features/<app>/screen, so a module without one gets
@@ -422,13 +422,13 @@ program
422
422
  .action(async (args: string[], options) => {
423
423
  const parsed = parseTestTiers(args);
424
424
 
425
- // Handle unit tests (turbo test with dynamic excludes: missing services + E2E app, plus frappe app unit tests)
425
+ // Handle unit tests (turbo test with dynamic excludes: missing services, plus frappe app unit tests)
426
426
  if (parsed.includes("unit")) {
427
427
  await runUnitTests(projectRoot);
428
428
  if (parsed.length === 1) return;
429
429
  }
430
430
 
431
- // Handle integration tests (frappe app integration tests)
431
+ // Handle integration tests (turbo test:integration plus frappe app integration tests)
432
432
  if (parsed.includes("integration")) {
433
433
  await runIntegrationTests(projectRoot);
434
434
  if (parsed.length === 1) return;
@@ -64,25 +64,22 @@ async function getPresentAppNames(projectRoot: string): Promise<string[]> {
64
64
  }
65
65
  }
66
66
 
67
- /** Discover app that has Playwright config (for E2E test cwd). Returns app name (e.g. "one") or null. */
67
+ /** Discover the app whose package.json names it the e2e app (`"mpo": { "e2e": true }`), for E2E test cwd. Returns app name (e.g. "one") or null. */
68
68
  export async function discoverE2EApp(projectRoot: string): Promise<string | null> {
69
- const names = await getPresentAppNames(projectRoot);
70
- for (const name of names) {
71
- const appPath = path.join(projectRoot, "apps", name);
72
- for (const config of [
73
- "playwright.config.ts",
74
- "playwright.config.js",
75
- "playwright.config.mjs",
76
- ]) {
77
- try {
78
- await fs.access(path.join(appPath, config));
79
- return name;
80
- } catch {
81
- // continue
82
- }
83
- }
69
+ const named: string[] = [];
70
+ for (const name of await getPresentAppNames(projectRoot)) {
71
+ const pkg = JSON.parse(
72
+ await fs.readFile(path.join(projectRoot, "apps", name, "package.json"), "utf8"),
73
+ );
74
+ if (pkg?.mpo?.e2e === true) named.push(name);
75
+ }
76
+ if (named.length > 1) {
77
+ throw new Error(
78
+ `more than one app sets "mpo": { "e2e": true } in its package.json: ${named.join(", ")}. ` +
79
+ "Keep it on the one app mpo test e2e should run and delete it from the others.",
80
+ );
84
81
  }
85
- return null;
82
+ return named[0] ?? null;
86
83
  }
87
84
 
88
85
  export async function detectServices(projectRoot: string): Promise<string[]> {
@@ -319,12 +316,10 @@ export async function runE2ESession(projectRoot: string, options: E2EOptions): P
319
316
  return;
320
317
  }
321
318
 
322
- // Run Playwright tests (discover app that has playwright.config)
319
+ // Run Playwright tests (discover the app its package.json names)
323
320
  const e2eApp = await discoverE2EApp(projectRoot);
324
321
  if (!e2eApp) {
325
- console.error(
326
- "No E2E app found: no app under apps/ has playwright.config.ts or playwright.config.js.",
327
- );
322
+ console.error('No E2E app found: no apps/*/package.json sets "mpo": { "e2e": true }.');
328
323
  await tearDown(projectRoot, sessionFilePath);
329
324
  process.exit(1);
330
325
  }
@@ -23,7 +23,6 @@ export const SINGLETON_APPS = [
23
23
  "storybook",
24
24
  "storybook-expo",
25
25
  "sui",
26
- "uxpin",
27
26
  "vocs",
28
27
  ] as const;
29
28
  export type SingletonApp = (typeof SINGLETON_APPS)[number];
@@ -36,7 +35,6 @@ const SINGLETON_DESCRIPTIONS: Record<SingletonApp, string> = {
36
35
  storybook: "Storybook (web)",
37
36
  "storybook-expo": "Storybook (native)",
38
37
  sui: "Move packages + localnet",
39
- uxpin: "UXPin Merge library",
40
38
  vocs: "Docs site",
41
39
  };
42
40
 
@@ -53,9 +53,12 @@ function reportKept(stdout: string): void {
53
53
  }
54
54
 
55
55
  /** Run scaffold.sh and return the provenance it wrote. */
56
- export async function runScaffold(request: ScaffoldRequest): Promise<MpoProvenance> {
56
+ export async function runScaffold(
57
+ request: ScaffoldRequest,
58
+ script = scaffoldScript(),
59
+ ): Promise<MpoProvenance> {
57
60
  await checkSourceAccess(request.source);
58
- const args = [scaffoldScript()];
61
+ const args = [script];
59
62
  for (const app of request.apps) args.push("--app", app);
60
63
  for (const service of request.services) args.push("--service", service);
61
64
  if (request.mpoVersion) args.push("--mpo-version", request.mpoVersion);
@@ -88,6 +91,55 @@ export interface TempScaffold {
88
91
  cleanup: () => void;
89
92
  }
90
93
 
94
+ /** Where the monorepo keeps its scaffold, at every commit since MPO-310. */
95
+ const scaffoldPath = "public/cli/scripts/scaffold.sh";
96
+
97
+ /**
98
+ * Write the scaffold.sh that `source` carries at `ref` to `file`; false when
99
+ * that commit carries none. A merge baseline made with it is what that
100
+ * commit's own CLI scaffolded, so whatever the scaffold learned between two
101
+ * commits (a cleanup of root wiring, say) is part of the difference between
102
+ * their baselines and reaches the project, with no step of it named here. A
103
+ * url is fetched shallow and blobless, then the one blob, as scaffold.sh does.
104
+ */
105
+ async function scaffoldScriptAt(source: string, ref: string, file: string): Promise<boolean> {
106
+ await checkSourceAccess(source);
107
+ const script = [
108
+ "set -eu",
109
+ 'SOURCE="$1"; REF="$2"; SCRIPT="$3"; OUT="$4"',
110
+ 'if [ -d "$SOURCE" ]; then',
111
+ ' REPO="$SOURCE"',
112
+ ' COMMIT="$(git -C "$REPO" rev-parse --verify --quiet "$REF^{commit}")" ||',
113
+ ' { printf "%s is not a commit in %s\\n" "$REF" "$REPO" >&2; exit 1; }',
114
+ "else",
115
+ ' REPO="$(mktemp -d "${TMPDIR:-/tmp}/mpo-scaffold-script.XXXXXX")"',
116
+ " trap 'rm -rf \"$REPO\"' EXIT",
117
+ ' git init -q "$REPO"',
118
+ ' git -C "$REPO" remote add origin "$SOURCE"',
119
+ ' git -C "$REPO" fetch -q --depth 1 --filter=blob:none origin "$REF"',
120
+ ' COMMIT="$(git -C "$REPO" rev-parse --verify --quiet "FETCH_HEAD^{commit}")"',
121
+ "fi",
122
+ 'BLOB="$(git -C "$REPO" ls-tree "$COMMIT" -- "$SCRIPT" | awk \'$2 == "blob" { print $3 }\')"',
123
+ '[ -n "$BLOB" ] || exit 3',
124
+ 'if [ "$(git -C "$REPO" config --get remote.origin.promisor || true)" = true ]; then',
125
+ ' printf "%s\\n" "$BLOB" | git -C "$REPO" -c fetch.negotiationAlgorithm=noop fetch -q \\',
126
+ " --no-tags --no-write-fetch-head --filter=blob:none --stdin origin",
127
+ "fi",
128
+ 'git -C "$REPO" cat-file blob "$BLOB" >"$OUT"',
129
+ ].join("\n");
130
+ try {
131
+ await spawn("sh", ["-c", script, "sh", source, ref, scaffoldPath, file], {
132
+ stdio: ["ignore", "ignore", "pipe"],
133
+ });
134
+ return true;
135
+ } catch (err) {
136
+ if ((err as { exitCode?: number }).exitCode === 3) return false;
137
+ const stderr = ((err as { stderr?: string }).stderr ?? "").trim();
138
+ const detail = stderr.split("\n").filter(Boolean).pop() ?? (err as Error).message;
139
+ throw new Error(`could not read ${scaffoldPath} at ${ref} from ${source}: ${detail}`);
140
+ }
141
+ }
142
+
91
143
  /** A scaffold in a temp dir (merge baselines). */
92
144
  export async function scaffoldToTemp(
93
145
  request: Omit<ScaffoldRequest, "target" | "into">,
@@ -96,7 +148,12 @@ export async function scaffoldToTemp(
96
148
  const dir = join(parent, "project");
97
149
  const cleanup = () => rmSync(parent, { recursive: true, force: true });
98
150
  try {
99
- const provenance = await runScaffold({ ...request, target: dir });
151
+ const script = join(parent, "scaffold.sh");
152
+ const carried = await scaffoldScriptAt(request.source, request.ref, script);
153
+ if (!carried) {
154
+ console.warn(`⚠️ ${request.ref} carries no ${scaffoldPath}; using this CLI's for that side`);
155
+ }
156
+ const provenance = await runScaffold({ ...request, target: dir }, carried ? script : undefined);
100
157
  return { dir, provenance, cleanup };
101
158
  } catch (err) {
102
159
  cleanup();