@platforma-sdk/block-tools 2.11.10 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/cli.js +13 -13
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +845 -625
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/cmd/software/build.d.ts +2 -0
  6. package/dist/cmd/software/ecr-login.d.ts +3 -0
  7. package/dist/cmd/software/env.d.ts +5 -0
  8. package/dist/cmd/software/index.d.ts +2 -0
  9. package/dist/cmd/software/knobs.d.ts +26 -0
  10. package/dist/cmd/software/run-build.d.ts +19 -0
  11. package/dist/structure/engine/version.d.ts +5 -4
  12. package/dist/structure/rules/root-package-json.d.ts +1 -2
  13. package/dist/structure/rules/root-pnpm-workspace.d.ts +7 -1
  14. package/package.json +7 -5
  15. package/src/cli.test.ts +20 -1
  16. package/src/cli.ts +2 -0
  17. package/src/cmd/software/build.ts +175 -0
  18. package/src/cmd/software/ecr-login.test.ts +92 -0
  19. package/src/cmd/software/ecr-login.ts +75 -0
  20. package/src/cmd/software/env.test.ts +17 -0
  21. package/src/cmd/software/env.ts +22 -0
  22. package/src/cmd/software/index.ts +9 -0
  23. package/src/cmd/software/knobs.test.ts +52 -0
  24. package/src/cmd/software/knobs.ts +61 -0
  25. package/src/cmd/software/run-build.test.ts +291 -0
  26. package/src/cmd/software/run-build.ts +156 -0
  27. package/src/structure/__tests__/floor-version.test.ts +2 -2
  28. package/src/structure/engine/__tests__/version.test.ts +14 -17
  29. package/src/structure/engine/discovery-fs.ts +4 -13
  30. package/src/structure/engine/runner.ts +4 -4
  31. package/src/structure/engine/version.ts +11 -13
  32. package/src/structure/rules/migrations.ts +1 -1
  33. package/src/structure/rules/root-package-json.ts +38 -14
  34. package/src/structure/rules/root-pnpm-workspace.ts +8 -1
  35. package/src/structure/rules/root.ts +1 -1
  36. package/src/structure/rules/software-package-json.ts +23 -10
  37. package/src/structure/templates/static/root/turbo.json +15 -1
package/dist/cli.mjs CHANGED
@@ -1,120 +1,124 @@
1
- import { H as e, O as t, Q as n, Tt as r, W as i, Y as a, _ as o, b as s, n as c, p as l, q as u, st as d, ut as ee } from "./config-CiC347sB.mjs";
2
- import { Command as f, Option as p } from "commander";
3
- import m from "node:path";
4
- import h from "node:fs";
5
- import { BlockPackManifest as te, StableChannel as ne, overrideDescriptionVersion as re, overrideManifestVersion as ie } from "@milaboratories/pl-model-middle-layer";
6
- import { ConsoleLoggerAdapter as g } from "@milaboratories/ts-helpers";
7
- import ae, { parse as oe, parseDocument as se, stringify as ce } from "yaml";
8
- import { setTimeout as le } from "node:timers/promises";
1
+ import { H as e, O as t, Q as n, Tt as r, W as i, Y as a, _ as o, b as s, n as c, p as l, q as u, st as d, ut as f } from "./config-CiC347sB.mjs";
2
+ import { Command as p, Option as m } from "commander";
3
+ import h from "node:path";
4
+ import g from "node:fs";
5
+ import { BlockPackManifest as ee, StableChannel as te, overrideDescriptionVersion as ne, overrideManifestVersion as re } from "@milaboratories/pl-model-middle-layer";
6
+ import { ConsoleLoggerAdapter as _ } from "@milaboratories/ts-helpers";
7
+ import ie, { parse as ae, parseDocument as oe, stringify as se } from "yaml";
8
+ import { setTimeout as ce } from "node:timers/promises";
9
+ import * as le from "node:os";
9
10
  import { confirm as ue, input as de, select as fe } from "@inquirer/prompts";
11
+ import { createBuilder as pe, defaults as me, envs as v, util as y } from "@platforma-sdk/package-builder-lib";
12
+ import { spawnSync as he } from "node:child_process";
13
+ import { ECRPUBLICClient as ge, GetAuthorizationTokenCommand as _e } from "@aws-sdk/client-ecr-public";
10
14
  //#region src/cmd/build-meta.ts
11
- function pe() {
12
- let e = new f("build-meta").description("Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.");
15
+ function ve() {
16
+ let e = new p("build-meta").description("Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.");
13
17
  return e.option("-i, --modulePath <path>", "input module path", "."), e.requiredOption("-o, --destination <path>", "output meta.json file"), e.action(async (e) => {
14
- let t = m.resolve(e.modulePath), n = await d(await ee((await a(t)).meta, t));
15
- await h.promises.writeFile(m.resolve(e.destination), JSON.stringify(n));
18
+ let t = h.resolve(e.modulePath), n = await d(await f((await a(t)).meta, t));
19
+ await g.promises.writeFile(h.resolve(e.destination), JSON.stringify(n));
16
20
  }), e;
17
21
  }
18
22
  //#endregion
19
23
  //#region src/cmd/build-model.ts
20
- async function me(e) {
24
+ async function ye(e) {
21
25
  try {
22
- return await h.promises.readFile(e, "utf8");
26
+ return await g.promises.readFile(e, "utf8");
23
27
  } catch (e) {
24
28
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return;
25
29
  throw e;
26
30
  }
27
31
  }
28
- function he() {
29
- let e = new f("build-model").description("Extracts and outputs block model JSON from pre-built block model module");
32
+ function be() {
33
+ let e = new p("build-model").description("Extracts and outputs block model JSON from pre-built block model module");
30
34
  return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-b, --sourceBundle <path>", "bundled model code to embed into the model for callback-based rendering to work", "./dist/bundle.js"), e.option("-o, --destination <path>", "output model file", "./dist/model.json"), e.action(async (e) => {
31
- let { model: t, platforma: n } = r(m.resolve(e.modulePath));
35
+ let { model: t, platforma: n } = r(h.resolve(e.modulePath));
32
36
  if (t ||= n, !t) throw Error("\"model\" export not found");
33
37
  let { config: i } = t;
34
38
  if (!i) throw Error("Malformed \"model\" object, check it is created with \"BlockModel\" and \".done()\" is executed as the call in the chain.");
35
39
  if (!("outputs" in i) || !("sections" in i)) throw Error("\"config\" has unexpected structure");
36
- let a = await me(e.sourceBundle);
40
+ let a = await ye(e.sourceBundle);
37
41
  a !== void 0 && (i.code = {
38
42
  type: "plain",
39
43
  content: a
40
- }), await h.promises.writeFile(m.resolve(e.destination), JSON.stringify(i));
44
+ }), await g.promises.writeFile(h.resolve(e.destination), JSON.stringify(i));
41
45
  }), e;
42
46
  }
43
47
  //#endregion
44
48
  //#region src/cmd/pack.ts
45
- function ge() {
46
- let e = new f("pack").description("Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder");
49
+ function xe() {
50
+ let e = new p("pack").description("Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder");
47
51
  return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-o, --destinationPath <path>", "output folder", "./block-pack"), e.action(async (e) => {
48
- await n(await u(m.resolve(e.modulePath)), m.resolve(e.destinationPath));
52
+ await n(await u(h.resolve(e.modulePath)), h.resolve(e.destinationPath));
49
53
  }), e;
50
54
  }
51
55
  //#endregion
52
56
  //#region src/cmd/publish.ts
53
- function _e(e, t) {
57
+ function Se(e, t) {
54
58
  let n = { ...e };
55
- for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] = _e(n[e], t[e]) : n[e] = t[e];
59
+ for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] = Se(n[e], t[e]) : n[e] = t[e];
56
60
  return n;
57
61
  }
58
- function ve() {
59
- let n = new f("publish").description("Publishes the block package and refreshes the registry (for v2 block-pack schema)");
60
- return n.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), n.addOption(new p("--registry-serve-url <url>", "CDN serve URL written into block-pack/published.json (npm-consumed blocks)").env("PL_REGISTRY_SERVE_URL").makeOptionMandatory()), n.option("-m, --manifest <path>", "manifest file path", `./block-pack/${t}`), n.option("-v, --version-override <path>", "override package version"), n.addOption(new p("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), n.option("--no-refresh", "do not refresh repository after adding the package"), n.addOption(new p("--unstable", "do not add the published package to stable channel").default(!1).env("PL_PUBLISH_UNSTABLE")), n.action(async (t) => {
61
- let n = new g(), r = m.resolve(t.manifest), a = JSON.parse(await h.promises.readFile(r, { encoding: "utf-8" })), c = te.parse(a);
62
- c = _e(a, c);
63
- let l = m.dirname(r);
64
- n.info(`Manifest root = ${l}`), t.versionOverride && (c = ie(c, t.versionOverride));
62
+ function Ce() {
63
+ let n = new p("publish").description("Publishes the block package and refreshes the registry (for v2 block-pack schema)");
64
+ return n.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), n.addOption(new m("--registry-serve-url <url>", "CDN serve URL written into block-pack/published.json (npm-consumed blocks)").env("PL_REGISTRY_SERVE_URL").makeOptionMandatory()), n.option("-m, --manifest <path>", "manifest file path", `./block-pack/${t}`), n.option("-v, --version-override <path>", "override package version"), n.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), n.option("--no-refresh", "do not refresh repository after adding the package"), n.addOption(new m("--unstable", "do not add the published package to stable channel").default(!1).env("PL_PUBLISH_UNSTABLE")), n.action(async (t) => {
65
+ let n = new _(), r = h.resolve(t.manifest), a = JSON.parse(await g.promises.readFile(r, { encoding: "utf-8" })), c = ee.parse(a);
66
+ c = Se(a, c);
67
+ let l = h.dirname(r);
68
+ n.info(`Manifest root = ${l}`), t.versionOverride && (c = re(c, t.versionOverride));
65
69
  let u = new s(o(t.registry), n);
66
- await u.publishPackage(c, async (e) => Buffer.from(await h.promises.readFile(m.resolve(l, e)))), t.unstable || (n.info(`Adding package to ${ne} channel...`), await u.addPackageToChannel(c.description.id, ne)), await i(l, e({
70
+ await u.publishPackage(c, async (e) => Buffer.from(await g.promises.readFile(h.resolve(l, e)))), t.unstable || (n.info(`Adding package to ${te} channel...`), await u.addPackageToChannel(c.description.id, te)), await i(l, e({
67
71
  registryUrl: t.registryServeUrl,
68
72
  id: c.description.id
69
- })), n.info(`Wrote published coordinates to ${m.resolve(l, "published.json")}`), t.refresh && await u.updateIfNeeded();
73
+ })), n.info(`Wrote published coordinates to ${h.resolve(l, "published.json")}`), t.refresh && await u.updateIfNeeded();
70
74
  }), n;
71
75
  }
72
76
  //#endregion
73
77
  //#region src/cmd/refresh-registry.ts
74
- function ye() {
75
- let e = new f("refresh-registry").description("Refresh overview files based on published but not proecessed artefacts");
76
- return e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new p("-m, --mode <mode>", "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")").choices([
78
+ function we() {
79
+ let e = new p("refresh-registry").description("Refresh overview files based on published but not proecessed artefacts");
80
+ return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("-m, --mode <mode>", "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")").choices([
77
81
  "force",
78
82
  "normal",
79
83
  "dry-run"
80
84
  ]).env("PL_REGISTRY_REFRESH_DRY_RUN").default("normal")), e.action(async (e) => {
81
- await new s(o(e.registry), new g()).updateIfNeeded(e.mode);
85
+ await new s(o(e.registry), new _()).updateIfNeeded(e.mode);
82
86
  }), e;
83
87
  }
84
88
  //#endregion
85
89
  //#region src/cmd/mark-stable.ts
86
- function be() {
87
- let e = new f("mark-stable").description("Mark target block stable");
88
- return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new p("-c, --channel <channel name>", "custom channel").default(ne).hideHelp()), e.option("-v, --version-override <path>", "override package version"), e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new p("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.option("--unmark", "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package", !1), e.action(async (e) => {
89
- let t = await a(m.resolve(e.modulePath));
90
- e.versionOverride && (t = re(t, e.versionOverride));
91
- let n = new s(o(e.registry), new g());
90
+ function Te() {
91
+ let e = new p("mark-stable").description("Mark target block stable");
92
+ return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new m("-c, --channel <channel name>", "custom channel").default(te).hideHelp()), e.option("-v, --version-override <path>", "override package version"), e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.option("--unmark", "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package", !1), e.action(async (e) => {
93
+ let t = await a(h.resolve(e.modulePath));
94
+ e.versionOverride && (t = ne(t, e.versionOverride));
95
+ let n = new s(o(e.registry), new _());
92
96
  e.unmark ? await n.removePackageFromChannel(t.id, e.channel) : await n.addPackageToChannel(t.id, e.channel), e.refresh && await n.updateIfNeeded();
93
97
  }), e;
94
98
  }
95
99
  //#endregion
96
100
  //#region src/structure/engine/fs/node.ts
97
- var xe = class {
101
+ var Ee = class {
98
102
  constructor(e) {
99
103
  this.root = e;
100
104
  }
101
105
  abs(e) {
102
- return m.resolve(this.root, e);
106
+ return h.resolve(this.root, e);
103
107
  }
104
108
  read(e) {
105
- return h.readFileSync(this.abs(e), "utf-8");
109
+ return g.readFileSync(this.abs(e), "utf-8");
106
110
  }
107
111
  write(e, t) {
108
112
  let n = this.abs(e);
109
- h.mkdirSync(m.dirname(n), { recursive: !0 }), h.writeFileSync(n, t, "utf-8");
113
+ g.mkdirSync(h.dirname(n), { recursive: !0 }), g.writeFileSync(n, t, "utf-8");
110
114
  }
111
115
  writeBinary(e, t) {
112
116
  let n = this.abs(e);
113
- h.mkdirSync(m.dirname(n), { recursive: !0 }), h.writeFileSync(n, t);
117
+ g.mkdirSync(h.dirname(n), { recursive: !0 }), g.writeFileSync(n, t);
114
118
  }
115
119
  exists(e) {
116
120
  try {
117
- return h.statSync(this.abs(e)), !0;
121
+ return g.statSync(this.abs(e)), !0;
118
122
  } catch {
119
123
  return !1;
120
124
  }
@@ -122,15 +126,15 @@ var xe = class {
122
126
  list(e) {
123
127
  let t = this.abs(e);
124
128
  try {
125
- if (!h.statSync(t).isDirectory()) return [];
129
+ if (!g.statSync(t).isDirectory()) return [];
126
130
  } catch {
127
131
  return [];
128
132
  }
129
133
  let n = [];
130
134
  function r(e, t) {
131
- let i = h.readdirSync(t, { withFileTypes: !0 });
135
+ let i = g.readdirSync(t, { withFileTypes: !0 });
132
136
  for (let a of i) {
133
- let i = e ? `${e}/${a.name}` : a.name, o = m.join(t, a.name);
137
+ let i = e ? `${e}/${a.name}` : a.name, o = h.join(t, a.name);
134
138
  a.isDirectory() ? r(i, o) : a.isFile() && n.push(i);
135
139
  }
136
140
  }
@@ -139,7 +143,7 @@ var xe = class {
139
143
  listDir(e) {
140
144
  let t = this.abs(e), n;
141
145
  try {
142
- n = h.readdirSync(t, { withFileTypes: !0 });
146
+ n = g.readdirSync(t, { withFileTypes: !0 });
143
147
  } catch {
144
148
  return [];
145
149
  }
@@ -150,48 +154,48 @@ var xe = class {
150
154
  }
151
155
  move(e, t) {
152
156
  let n = this.abs(e), r = this.abs(t);
153
- h.mkdirSync(m.dirname(r), { recursive: !0 }), h.renameSync(n, r);
157
+ g.mkdirSync(h.dirname(r), { recursive: !0 }), g.renameSync(n, r);
154
158
  }
155
159
  delete(e) {
156
- h.rmSync(this.abs(e), {
160
+ g.rmSync(this.abs(e), {
157
161
  recursive: !0,
158
162
  force: !0
159
163
  });
160
164
  }
161
- }, Se = class {
165
+ }, De = class {
162
166
  constructor(e) {
163
167
  this.root = e;
164
168
  }
165
169
  staticRead(e) {
166
- return h.readFileSync(m.resolve(this.root, "static", e), "utf-8");
170
+ return g.readFileSync(h.resolve(this.root, "static", e), "utf-8");
167
171
  }
168
172
  staticReadBinary(e) {
169
- return h.readFileSync(m.resolve(this.root, "static", e));
173
+ return g.readFileSync(h.resolve(this.root, "static", e));
170
174
  }
171
175
  textRead(e) {
172
- return h.readFileSync(m.resolve(this.root, "text", e), "utf-8");
176
+ return g.readFileSync(h.resolve(this.root, "text", e), "utf-8");
173
177
  }
174
178
  };
175
- function Ce(e, t) {
179
+ function Oe(e, t) {
176
180
  return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (e, n) => t[n] ?? `\${${n}}`);
177
181
  }
178
182
  //#endregion
179
183
  //#region src/structure/engine/flatten.ts
180
- var we = ["default", "init"];
181
- function Te(e, t) {
184
+ var ke = ["default", "init"];
185
+ function Ae(e, t) {
182
186
  if (!e) return t;
183
187
  if (!t) return e;
184
188
  let n = e.endsWith("/") ? e.slice(0, -1) : e, r = t.startsWith("/") ? t.slice(1) : t;
185
189
  return r ? `${n}/${r}` : n;
186
190
  }
187
- function Ee(e, t) {
191
+ function je(e, t) {
188
192
  return e.filter((e) => e.scope === t).slice().sort((e, t) => e.path.localeCompare(t.path));
189
193
  }
190
- function De(e, t) {
194
+ function Me(e, t) {
191
195
  let n = [];
192
196
  function r(e, i, a, o, s) {
193
197
  if (e.kind === "scope") {
194
- let n = Ee(t.modules, e.scope);
198
+ let n = je(t.modules, e.scope);
195
199
  for (let t of n) for (let n of e.children) r(n, e.scope, t.path, o, s);
196
200
  return;
197
201
  }
@@ -204,14 +208,14 @@ function De(e, t) {
204
208
  for (let t of e.children) r(t, i, a, o, e.modes);
205
209
  return;
206
210
  }
207
- if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${ke(e)}' is not inside a scope() frame`);
211
+ if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${Pe(e)}' is not inside a scope() frame`);
208
212
  if (e.kind === "rename") {
209
213
  n.push({
210
214
  leaf: e,
211
215
  scope: i,
212
216
  modulePath: a,
213
- resolvedPath: Te(a, e.from),
214
- resolvedTo: Te(a, e.to),
217
+ resolvedPath: Ae(a, e.from),
218
+ resolvedTo: Ae(a, e.to),
215
219
  triggers: o,
216
220
  modes: s
217
221
  });
@@ -221,15 +225,15 @@ function De(e, t) {
221
225
  leaf: e,
222
226
  scope: i,
223
227
  modulePath: a,
224
- resolvedPath: Te(a, Oe(e)),
228
+ resolvedPath: Ae(a, Ne(e)),
225
229
  triggers: o,
226
230
  modes: s
227
231
  });
228
232
  }
229
- for (let t of e.children) r(t, void 0, void 0, [], we);
233
+ for (let t of e.children) r(t, void 0, void 0, [], ke);
230
234
  return n;
231
235
  }
232
- function Oe(e) {
236
+ function Ne(e) {
233
237
  switch (e.kind) {
234
238
  case "fixed":
235
239
  case "managed":
@@ -239,63 +243,63 @@ function Oe(e) {
239
243
  case "rename": return e.from;
240
244
  }
241
245
  }
242
- function ke(e) {
246
+ function Pe(e) {
243
247
  return e.kind === "rename" ? `rename ${e.from} -> ${e.to}` : `${e.kind} ${e.path}`;
244
248
  }
245
249
  //#endregion
246
250
  //#region src/structure/engine/glob.ts
247
- var Ae = /[.+^${}()|[\]\\]/g;
248
- function je(e) {
251
+ var Fe = /[.+^${}()|[\]\\]/g;
252
+ function Ie(e) {
249
253
  let t = "";
250
254
  for (let n = 0; n < e.length; n++) {
251
255
  let r = e[n];
252
- r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : r === "?" ? t += "[^/]" : t += r.replace(Ae, "\\$&");
256
+ r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : r === "?" ? t += "[^/]" : t += r.replace(Fe, "\\$&");
253
257
  }
254
258
  return RegExp(`^${t}$`);
255
259
  }
256
- function Me(e, t) {
257
- return je(e).test(t);
260
+ function Le(e, t) {
261
+ return Ie(e).test(t);
258
262
  }
259
263
  //#endregion
260
264
  //#region src/structure/engine/builders.ts
261
- var _, v;
262
- function Ne(e) {
263
- if (!_) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
264
- return _;
265
+ var b, Re;
266
+ function ze(e) {
267
+ if (!b) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
268
+ return b;
265
269
  }
266
- function y(e, t) {
267
- let n = Ne(e);
270
+ function x(e, t) {
271
+ let n = ze(e);
268
272
  n.stack[n.stack.length - 1].push(t);
269
273
  }
270
- function Pe(e, t) {
271
- let n = v;
272
- v = e;
274
+ function Be(e, t) {
275
+ let n = Re;
276
+ Re = e;
273
277
  try {
274
278
  return t();
275
279
  } finally {
276
- v = n;
280
+ Re = n;
277
281
  }
278
282
  }
279
- function Fe() {
280
- return v;
283
+ function Ve() {
284
+ return Re;
281
285
  }
282
- function Ie(e) {
283
- if (_) throw Error("defineStructure() cannot be called from inside another defineStructure().");
286
+ function He(e) {
287
+ if (b) throw Error("defineStructure() cannot be called from inside another defineStructure().");
284
288
  let t = [], n = {
285
289
  root: t,
286
290
  stack: [t],
287
291
  inScope: !1
288
292
  };
289
- _ = n;
293
+ b = n;
290
294
  try {
291
295
  if (e(), n.stack.length !== 1) throw Error(`defineStructure: builder body left ${n.stack.length - 1} unclosed group frame(s)`);
292
296
  let r = { children: t };
293
- return Le(r), r;
297
+ return Ue(r), r;
294
298
  } finally {
295
- _ = void 0;
299
+ b = void 0;
296
300
  }
297
301
  }
298
- function Le(e) {
302
+ function Ue(e) {
299
303
  let t = /* @__PURE__ */ new Map();
300
304
  function n(e, r) {
301
305
  if (e.kind === "scope") {
@@ -318,8 +322,8 @@ function Le(e) {
318
322
  throw Error(`defineStructure validation: path '${t}' under scope '${e}' is declared as both seed and ${n}. Seeds are block-author territory (written once at init, untouched thereafter); engine-managed primitives (fixed/managed/scaffold) rewrite on every refresh. The two contracts cannot coexist on the same path.`);
319
323
  }
320
324
  }
321
- function b(e, t) {
322
- let n = Ne("scope");
325
+ function S(e, t) {
326
+ let n = ze("scope");
323
327
  if (n.inScope) throw Error("scope() cannot nest. Already inside a scope.");
324
328
  let r = {
325
329
  kind: "scope",
@@ -333,22 +337,22 @@ function b(e, t) {
333
337
  n.stack.pop(), n.inScope = !1;
334
338
  }
335
339
  }
336
- var Re;
337
- function ze(e) {
338
- Re = e;
340
+ var We;
341
+ function Ge(e) {
342
+ We = e;
339
343
  }
340
- function x(e, t, n) {
341
- Be(e, t), n && Be((t) => !e(t), n);
344
+ function C(e, t, n) {
345
+ Ke(e, t), n && Ke((t) => !e(t), n);
342
346
  }
343
- function Be(e, t) {
344
- if (_) {
345
- Ve(e, t);
347
+ function Ke(e, t) {
348
+ if (b) {
349
+ qe(e, t);
346
350
  return;
347
351
  }
348
- if (!(Re?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
352
+ if (!(We?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
349
353
  }
350
- function Ve(e, t) {
351
- let n = _, r = {
354
+ function qe(e, t) {
355
+ let n = b, r = {
352
356
  kind: "when",
353
357
  trigger: e,
354
358
  children: []
@@ -360,11 +364,11 @@ function Ve(e, t) {
360
364
  n.stack.pop();
361
365
  }
362
366
  }
363
- function S(e) {
367
+ function w(e) {
364
368
  return (t) => t.filesMatch(e);
365
369
  }
366
- function He(e, t, n) {
367
- let r = Ne(e), i = {
370
+ function Je(e, t, n) {
371
+ let r = ze(e), i = {
368
372
  kind: "mode",
369
373
  modes: t,
370
374
  children: []
@@ -376,70 +380,70 @@ function He(e, t, n) {
376
380
  r.stack.pop();
377
381
  }
378
382
  }
379
- function Ue(e) {
380
- He("onInitOrUpdate", ["init", "updateDeps"], e);
383
+ function Ye(e) {
384
+ Je("onInitOrUpdate", ["init", "updateDeps"], e);
381
385
  }
382
- function C(e, t) {
383
- y("fixed", {
386
+ function T(e, t) {
387
+ x("fixed", {
384
388
  kind: "fixed",
385
389
  path: e,
386
390
  content: t
387
391
  });
388
392
  }
389
- function w(e, t, n) {
390
- y("managed", {
393
+ function E(e, t, n) {
394
+ x("managed", {
391
395
  kind: "managed",
392
396
  path: e,
393
397
  initial: t,
394
398
  body: n
395
399
  });
396
400
  }
397
- function T(e, t) {
398
- y("scaffold", {
401
+ function D(e, t) {
402
+ x("scaffold", {
399
403
  kind: "scaffold",
400
404
  path: e,
401
405
  initial: t
402
406
  });
403
407
  }
404
- function E(e, t) {
405
- y("seed", {
408
+ function O(e, t) {
409
+ x("seed", {
406
410
  kind: "seed",
407
411
  path: e,
408
412
  initial: t
409
413
  });
410
414
  }
411
- function D(e) {
412
- y("remove", {
415
+ function k(e) {
416
+ x("remove", {
413
417
  kind: "remove",
414
418
  path: e
415
419
  });
416
420
  }
417
- function O(e) {
421
+ function A(e) {
418
422
  return {
419
423
  kind: "file",
420
424
  path: e
421
425
  };
422
426
  }
423
- function We(e) {
427
+ function Xe(e) {
424
428
  return {
425
429
  kind: "binary",
426
430
  path: e
427
431
  };
428
432
  }
429
- function Ge(e) {
433
+ function Ze(e) {
430
434
  return {
431
435
  kind: "text",
432
436
  value: e
433
437
  };
434
438
  }
435
- function k(e, t) {
439
+ function j(e, t) {
436
440
  return {
437
441
  kind: "tpl",
438
442
  path: e,
439
443
  vars: t
440
444
  };
441
445
  }
442
- function A(e) {
446
+ function M(e) {
443
447
  return {
444
448
  kind: "generate",
445
449
  fn: e
@@ -447,69 +451,69 @@ function A(e) {
447
451
  }
448
452
  //#endregion
449
453
  //#region src/structure/engine/parsers/json.ts
450
- function Ke(e) {
454
+ function Qe(e) {
451
455
  return JSON.parse(e);
452
456
  }
453
- var qe = 100, Je = 2;
454
- function Ye(e) {
455
- return e.length === 0 ? "[]" : "[" + e.map(Xe).join(", ") + "]";
457
+ var $e = 100, et = 2;
458
+ function tt(e) {
459
+ return e.length === 0 ? "[]" : "[" + e.map(nt).join(", ") + "]";
456
460
  }
457
- function Xe(e) {
458
- if (Array.isArray(e)) return Ye(e);
459
- if (M(e)) {
461
+ function nt(e) {
462
+ if (Array.isArray(e)) return tt(e);
463
+ if (N(e)) {
460
464
  let t = Object.entries(e);
461
- return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${Xe(t)}`).join(", ") + " }";
465
+ return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${nt(t)}`).join(", ") + " }";
462
466
  }
463
467
  return JSON.stringify(e);
464
468
  }
465
- function Ze(e, t, n, r) {
466
- let i = t + Je, a = " ".repeat(i);
469
+ function rt(e, t, n, r) {
470
+ let i = t + et, a = " ".repeat(i);
467
471
  if (Array.isArray(e)) {
468
- let o = Ye(e);
469
- if (n + o.length + r <= qe) return o;
472
+ let o = tt(e);
473
+ if (n + o.length + r <= $e) return o;
470
474
  let s = e.length - 1;
471
- return "[\n" + e.map((e, t) => a + Ze(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
475
+ return "[\n" + e.map((e, t) => a + rt(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
472
476
  }
473
- if (M(e)) {
477
+ if (N(e)) {
474
478
  let n = Object.entries(e);
475
479
  if (n.length === 0) return "{}";
476
480
  let r = n.length - 1;
477
481
  return "{\n" + n.map(([e, t], n) => {
478
482
  let o = `${a}${JSON.stringify(e)}: `;
479
- return o + Ze(t, i, o.length, n === r ? 0 : 1);
483
+ return o + rt(t, i, o.length, n === r ? 0 : 1);
480
484
  }).join(",\n") + "\n" + " ".repeat(t) + "}";
481
485
  }
482
486
  return JSON.stringify(e);
483
487
  }
484
- function Qe(e, t) {
485
- return t?.collapse ? Ze(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
488
+ function it(e, t) {
489
+ return t?.collapse ? rt(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
486
490
  }
487
- function j(e) {
491
+ function at(e) {
488
492
  return e === "" || e === void 0 ? [] : e.split(".");
489
493
  }
490
- function M(e) {
494
+ function N(e) {
491
495
  return typeof e == "object" && !!e && !Array.isArray(e);
492
496
  }
493
- function $e(e, t) {
494
- let n = j(t), r = e;
497
+ function ot(e, t) {
498
+ let n = at(t), r = e;
495
499
  for (let e of n) {
496
- if (!M(r)) return;
500
+ if (!N(r)) return;
497
501
  r = r[e];
498
502
  }
499
503
  return r;
500
504
  }
501
- function et(e, t) {
502
- let n = j(t);
505
+ function st(e, t) {
506
+ let n = at(t);
503
507
  if (n.length === 0) return !0;
504
508
  let r = e;
505
509
  for (let e = 0; e < n.length - 1; e++) {
506
- if (!M(r)) return !1;
510
+ if (!N(r)) return !1;
507
511
  r = r[n[e]];
508
512
  }
509
- return M(r) ? n[n.length - 1] in r : !1;
513
+ return N(r) ? n[n.length - 1] in r : !1;
510
514
  }
511
- function tt(e, t, n) {
512
- let r = j(t);
515
+ function ct(e, t, n) {
516
+ let r = at(t);
513
517
  if (r.length === 0) throw Error("setAtPath: jsonPath must be non-empty");
514
518
  let i = e;
515
519
  for (let e = 0; e < r.length - 1; e++) {
@@ -517,22 +521,22 @@ function tt(e, t, n) {
517
521
  if (n === void 0) {
518
522
  let e = {};
519
523
  i[t] = e, i = e;
520
- } else if (M(n)) i = n;
524
+ } else if (N(n)) i = n;
521
525
  else throw Error(`setAtPath: cannot descend into non-object at '${r.slice(0, e + 1).join(".")}'`);
522
526
  }
523
527
  i[r[r.length - 1]] = n;
524
528
  }
525
- function nt(e, t) {
526
- let n = j(t);
529
+ function lt(e, t) {
530
+ let n = at(t);
527
531
  if (n.length === 0) throw Error("deleteAtPath: jsonPath must be non-empty");
528
532
  let r = e;
529
533
  for (let e = 0; e < n.length - 1; e++) {
530
- if (!M(r)) return;
534
+ if (!N(r)) return;
531
535
  r = r[n[e]];
532
536
  }
533
- M(r) && delete r[n[n.length - 1]];
537
+ N(r) && delete r[n[n.length - 1]];
534
538
  }
535
- function rt(e, t) {
539
+ function ut(e, t) {
536
540
  let n = new Set(t), r = Object.keys(e), i = /* @__PURE__ */ new Map();
537
541
  i.set("", []);
538
542
  let a = "";
@@ -547,72 +551,72 @@ function rt(e, t) {
547
551
  }
548
552
  //#endregion
549
553
  //#region src/structure/engine/parsers/lines.ts
550
- function it(e) {
554
+ function dt(e) {
551
555
  let t = e.split("\n");
552
556
  return t.length > 0 && t[t.length - 1] === "" && t.pop(), t;
553
557
  }
554
- function at(e) {
558
+ function ft(e) {
555
559
  return e.join("\n") + "\n";
556
560
  }
557
- function ot(e) {
561
+ function pt(e) {
558
562
  return e.replace(/(^|\s)#.*$/, "$1").trim();
559
563
  }
560
- function st(e, t) {
561
- let n = ot(e);
564
+ function mt(e, t) {
565
+ let n = pt(e);
562
566
  return n === "" ? !1 : n === t.trim();
563
567
  }
564
- function ct(e, t) {
565
- for (let n of e) if (st(n, t)) return !0;
568
+ function ht(e, t) {
569
+ for (let n of e) if (mt(n, t)) return !0;
566
570
  return !1;
567
571
  }
568
572
  //#endregion
569
573
  //#region src/structure/engine/content-rules.ts
570
- function lt(e, t) {
574
+ function gt(e, t) {
571
575
  return e === "sdk:" ? t ? "workspace:*" : "catalog:" : e;
572
576
  }
573
- var ut = [
577
+ var _t = [
574
578
  "dependencies",
575
579
  "devDependencies",
576
580
  "peerDependencies",
577
581
  "optionalDependencies"
578
582
  ];
579
- function dt(e, t) {
580
- if (I(e)) for (let n of ut) {
583
+ function vt(e, t) {
584
+ if (L(e)) for (let n of _t) {
581
585
  let r = e[n];
582
- if (I(r)) for (let e of Object.keys(r)) r[e] === "sdk:" && (r[e] = t ? "workspace:*" : "catalog:");
586
+ if (L(r)) for (let e of Object.keys(r)) r[e] === "sdk:" && (r[e] = t ? "workspace:*" : "catalog:");
583
587
  }
584
588
  }
585
- var N;
586
- function ft(e) {
587
- if (!N) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
588
- return N;
589
+ var P;
590
+ function yt(e) {
591
+ if (!P) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
592
+ return P;
589
593
  }
590
- function P(e) {
591
- let t = ft(e);
594
+ function F(e) {
595
+ let t = yt(e);
592
596
  if (t.kind !== "json") throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);
593
597
  return t;
594
598
  }
595
- function F(e) {
596
- let t = ft(e);
599
+ function I(e) {
600
+ let t = yt(e);
597
601
  if (t.kind !== "yaml") throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);
598
602
  return t;
599
603
  }
600
- function pt(e) {
601
- let t = ft(e);
604
+ function bt(e) {
605
+ let t = yt(e);
602
606
  if (t.kind !== "lines") throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);
603
607
  return t;
604
608
  }
605
- function mt(e, t) {
606
- let n = e.ctx ?? Fe();
609
+ function xt(e, t) {
610
+ let n = e.ctx ?? Ve();
607
611
  if (!n) throw Error(`${t}() needs a RunContext but none is active. Pass { ctx } via the with-managed-* helper or run inside engine.run(...).`);
608
612
  return n;
609
613
  }
610
- function I(e) {
614
+ function L(e) {
611
615
  return typeof e == "object" && !!e && !Array.isArray(e);
612
616
  }
613
- function ht(e, t, n = {}) {
614
- if (N) throw Error("Nested managed(...) body — engine bug.");
615
- N = {
617
+ function St(e, t, n = {}) {
618
+ if (P) throw Error("Nested managed(...) body — engine bug.");
619
+ P = {
616
620
  kind: "json",
617
621
  obj: e,
618
622
  ctx: n.ctx,
@@ -621,12 +625,12 @@ function ht(e, t, n = {}) {
621
625
  try {
622
626
  return t(n.ctx ?? n.triggerContext?.ctx), e;
623
627
  } finally {
624
- N = void 0;
628
+ P = void 0;
625
629
  }
626
630
  }
627
- function gt(e, t, n = {}) {
628
- if (N) throw Error("Nested managed(...) body — engine bug.");
629
- N = {
631
+ function Ct(e, t, n = {}) {
632
+ if (P) throw Error("Nested managed(...) body — engine bug.");
633
+ P = {
630
634
  kind: "yaml",
631
635
  doc: e,
632
636
  ctx: n.ctx,
@@ -637,12 +641,12 @@ function gt(e, t, n = {}) {
637
641
  try {
638
642
  return t(n.ctx ?? n.triggerContext?.ctx), e;
639
643
  } finally {
640
- N = void 0;
644
+ P = void 0;
641
645
  }
642
646
  }
643
- function _t(e, t, n = {}) {
644
- if (N) throw Error("Nested managed(...) body — engine bug.");
645
- N = {
647
+ function wt(e, t, n = {}) {
648
+ if (P) throw Error("Nested managed(...) body — engine bug.");
649
+ P = {
646
650
  kind: "lines",
647
651
  lines: e,
648
652
  ctx: n.ctx,
@@ -651,170 +655,178 @@ function _t(e, t, n = {}) {
651
655
  try {
652
656
  return t(n.ctx ?? n.triggerContext?.ctx), e;
653
657
  } finally {
654
- N = void 0;
658
+ P = void 0;
655
659
  }
656
660
  }
657
- ze((e, t) => {
658
- if (!N) return !1;
659
- let n = N.triggerContext;
661
+ Ge((e, t) => {
662
+ if (!P) return !1;
663
+ let n = P.triggerContext;
660
664
  if (!n) throw Error("when() inside a managed(...) body requires a triggerContext. The runner supplies it via the `triggerContext` opt to with-managed-*; ensure your test/test helper passes one.");
661
665
  return e(n) && t(), !0;
662
666
  });
663
- function L(e, t) {
664
- tt(P("ensureField").obj, e, t);
665
- }
666
667
  function R(e, t) {
667
- let n = P("removeField").obj;
668
- et(n, e) && (t && !t($e(n, e)) || nt(n, e));
669
- }
670
- function vt(e, t) {
671
- let n = P("requireField").obj;
672
- if (!et(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
668
+ ct(F("ensureField").obj, e, t);
673
669
  }
674
670
  function z(e, t) {
675
- L(`scripts.${e}`, t);
671
+ let n = F("removeField").obj;
672
+ st(n, e) && (t && !t(ot(n, e)) || lt(n, e));
676
673
  }
677
- function B(e) {
678
- R(`scripts.${e}`);
674
+ function Tt(e, t) {
675
+ let n = F("requireField").obj;
676
+ if (!st(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
679
677
  }
680
- var yt = [
678
+ function B(e, t) {
679
+ R(`scripts.${e}`, t);
680
+ }
681
+ function V(e) {
682
+ z(`scripts.${e}`);
683
+ }
684
+ var Et = [
681
685
  "dependencies",
682
686
  "devDependencies",
683
687
  "peerDependencies",
684
688
  "optionalDependencies"
685
689
  ];
686
- function V(e, t, n, r) {
687
- let i = P(e), a = i.obj, o = n === "sdk:" ? lt(n, mt(i, e).isSdkInternal) : n;
688
- for (let e of yt) {
690
+ function Dt(e, t, n, r) {
691
+ let i = F(e), a = i.obj, o = n === "sdk:" ? gt(n, xt(i, e).isSdkInternal) : n;
692
+ for (let e of Et) {
689
693
  if (e === r) continue;
690
694
  let n = a[e];
691
- I(n) && t in n && delete n[t];
695
+ L(n) && t in n && delete n[t];
692
696
  }
693
- let s = a[r], c = I(s) ? s : {};
694
- c[t] = o, I(s) || (a[r] = c);
697
+ let s = a[r], c = L(s) ? s : {};
698
+ c[t] = o, L(s) || (a[r] = c);
695
699
  }
696
700
  function H(e, t) {
697
- V("ensureDep", e, t, "dependencies");
701
+ Dt("ensureDep", e, t, "dependencies");
698
702
  }
699
703
  function U(e, t) {
700
- V("ensureDevDep", e, t, "devDependencies");
704
+ Dt("ensureDevDep", e, t, "devDependencies");
701
705
  }
702
- function bt(e, t) {
703
- V("ensurePeerDep", e, t, "peerDependencies");
706
+ function Ot(e, t) {
707
+ Dt("ensurePeerDep", e, t, "peerDependencies");
704
708
  }
705
709
  function W(e) {
706
- let t = P("removeDep").obj;
707
- for (let n of yt) {
710
+ let t = F("removeDep").obj;
711
+ for (let n of Et) {
708
712
  let r = t[n];
709
- I(r) && e in r && delete r[e];
713
+ L(r) && e in r && delete r[e];
710
714
  }
711
715
  }
712
716
  function G(e) {
713
717
  for (let [t, n] of Object.entries(e)) U(t, n);
714
718
  }
715
- function xt(e) {
716
- for (let [t, n] of Object.entries(e)) bt(t, n);
719
+ function kt(e) {
720
+ for (let [t, n] of Object.entries(e)) Ot(t, n);
717
721
  }
718
- function St(e, t, n) {
719
- let r = mt(P(e), e);
720
- for (let i of r.modules) i.scope === t && V(e, i.name, "workspace:*", n);
722
+ function At(e, t, n) {
723
+ let r = xt(F(e), e);
724
+ for (let i of r.modules) i.scope === t && Dt(e, i.name, "workspace:*", n);
721
725
  }
722
- function Ct(e) {
723
- St("ensureWorkspaceScopeDeps", e, "dependencies");
726
+ function jt(e) {
727
+ At("ensureWorkspaceScopeDeps", e, "dependencies");
724
728
  }
725
- function wt(e) {
726
- St("ensureWorkspaceScopeDevDeps", e, "devDependencies");
729
+ function Mt(e) {
730
+ At("ensureWorkspaceScopeDevDeps", e, "devDependencies");
727
731
  }
728
- function Tt(e) {
729
- let t = P("pruneKeysMatching").obj;
732
+ function Nt(e) {
733
+ let t = F("pruneKeysMatching").obj;
730
734
  for (let n of Object.keys(t)) e(n, t[n]) && delete t[n];
731
735
  }
732
- function Et(e, t) {
733
- let n = rt(e, t);
736
+ function Pt(e, t) {
737
+ let n = ut(e, t);
734
738
  for (let t of Object.keys(e)) delete e[t];
735
739
  for (let t of Object.keys(n)) e[t] = n[t];
736
740
  }
737
741
  function K(e) {
738
- Et(P("enforceFieldOrder").obj, e);
742
+ Pt(F("enforceFieldOrder").obj, e);
739
743
  }
740
- function Dt(e, t) {
744
+ function Ft(e, t) {
741
745
  let n = Object.keys(e).sort(), r = {};
742
746
  for (let t of n) r[t] = e[t];
743
747
  for (let t of Object.keys(e)) delete e[t];
744
- for (let i of n) e[i] = r[i], t && I(e[i]) && Dt(e[i], !0);
748
+ for (let i of n) e[i] = r[i], t && L(e[i]) && Ft(e[i], !0);
745
749
  }
746
750
  function q(e = "", t = {}) {
747
751
  let n = t.recursive ?? !1;
748
752
  if (e === "" && !n) return;
749
- let r = P("enforceAlphabeticalOrder").obj;
753
+ let r = F("enforceAlphabeticalOrder").obj;
750
754
  if (e === "") {
751
- Dt(r, !0);
755
+ Ft(r, !0);
752
756
  return;
753
757
  }
754
- let i = $e(r, e);
755
- I(i) && Dt(i, n);
758
+ let i = ot(r, e);
759
+ L(i) && Ft(i, n);
756
760
  }
757
- function Ot() {
758
- let e = F("ensureWorkspaceModulePaths"), t = mt(e, "ensureWorkspaceModulePaths").modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = e.doc.toJSON()?.packages;
761
+ function It() {
762
+ let e = I("ensureWorkspaceModulePaths"), t = xt(e, "ensureWorkspaceModulePaths").modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = e.doc.toJSON()?.packages;
759
763
  Array.isArray(n) && n.length === t.length && n.every((e, n) => e === t[n]) || e.doc.setIn(["packages"], t);
760
764
  }
761
- function kt(e, t) {
765
+ function Lt(e, t) {
762
766
  let n = e.doc.getIn(["catalog", t]);
763
767
  return typeof n == "string" ? n : void 0;
764
768
  }
765
- function At(e, t) {
766
- let n = F("ensureCatalogVersion");
767
- kt(n, e) === void 0 && n.doc.setIn(["catalog", e], t);
769
+ function Rt(e, t) {
770
+ let n = I("ensureCatalogVersion");
771
+ Lt(n, e) === void 0 && n.doc.setIn(["catalog", e], t);
768
772
  }
769
- function jt(e) {
770
- let t = F("ensureCatalogLatest");
773
+ function zt(e) {
774
+ let t = I("ensureCatalogLatest");
771
775
  if (!t.getLatestVersion) return;
772
776
  let n = t.getLatestVersion(e);
773
- n !== void 0 && kt(t, e) !== n && t.doc.setIn(["catalog", e], n);
777
+ n !== void 0 && Lt(t, e) !== n && t.doc.setIn(["catalog", e], n);
774
778
  }
775
- function Mt(e, t) {
776
- let n = F("pinCatalogToDependencyOf");
779
+ function Bt(e, t) {
780
+ let n = I("pinCatalogToDependencyOf");
777
781
  if (!n.getDerivedDependencyPin) return;
778
782
  let r = n.getDerivedDependencyPin(e);
779
- r !== void 0 && kt(n, e) !== r && n.doc.setIn(["catalog", e], r);
783
+ r !== void 0 && Lt(n, e) !== r && n.doc.setIn(["catalog", e], r);
780
784
  }
781
- function Nt(e) {
782
- let t = F("ensureCatalogAbsent");
785
+ function Vt(e) {
786
+ let t = I("ensureCatalogAbsent");
783
787
  t.doc.hasIn(["catalog", e]) && t.doc.deleteIn(["catalog", e]);
784
788
  }
785
- function Pt(e) {
786
- let t = pt("ensureGitignoreEntries");
787
- for (let n of e) ct(t.lines, n) || t.lines.push(n);
789
+ function Ht(e) {
790
+ let t = bt("ensureGitignoreEntries");
791
+ for (let n of e) ht(t.lines, n) || t.lines.push(n);
788
792
  }
789
793
  //#endregion
790
794
  //#region src/structure/engine/parsers/yaml.ts
791
- function Ft(e) {
792
- return se(e);
795
+ function Ut(e) {
796
+ return oe(e);
793
797
  }
794
- function It(e) {
798
+ function Wt(e) {
795
799
  return e.toString();
796
800
  }
797
- var Lt = ".structure";
798
- function Rt(e, t = 0) {
799
- if (e < t) throw new zt(e, t);
801
+ var Gt = ".structure";
802
+ function Kt(e) {
803
+ if (!e.exists(".structure")) return { version: 0 };
804
+ try {
805
+ let t = JSON.parse(e.read(Gt));
806
+ return { version: typeof t?.version == "number" ? t.version : 0 };
807
+ } catch {
808
+ return { version: 0 };
809
+ }
800
810
  }
801
- var zt = class extends Error {
811
+ function qt(e, t = 0) {
812
+ if (e < t) throw new Jt(e, t);
813
+ }
814
+ var Jt = class extends Error {
802
815
  constructor(e, t) {
803
816
  super(`Block .structure version is ${e}, below floor ${t}. Bootstrap via the legacy-migration skill, then re-run.`), this.version = e, this.floor = t, this.name = "StructureVersionFloorError";
804
817
  }
805
818
  };
806
- function Bt(e, t = 1) {
807
- let n = { version: t };
808
- e.write(Lt, JSON.stringify(n));
819
+ function Yt(e, t) {
820
+ e.write(Gt, JSON.stringify(t));
809
821
  }
810
822
  //#endregion
811
823
  //#region src/structure/engine/runner.ts
812
- var Vt = class extends Error {
824
+ var Xt = class extends Error {
813
825
  constructor(e) {
814
826
  super(`Post-run recheck: rule set not idempotent. Failing item: ${e.primitive} '${e.path}' (scope=${e.scope}, action=${e.action}). Engine bug.`), this.failing = e, this.name = "RecheckError";
815
827
  }
816
828
  };
817
- function Ht(e, t, n, r) {
829
+ function Zt(e, t, n, r) {
818
830
  switch (e.kind) {
819
831
  case "text": return e.value;
820
832
  case "file":
@@ -822,47 +834,47 @@ function Ht(e, t, n, r) {
822
834
  return n.staticRead(e.path);
823
835
  case "tpl":
824
836
  if (!n) throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
825
- return Ce(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
837
+ return Oe(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
826
838
  case "generate": {
827
839
  let n = e.fn(r);
828
- if (t.endsWith(".json")) return dt(n, r.isSdkInternal), Qe(n, { collapse: !t.endsWith("package.json") });
829
- if (t.endsWith(".yaml") || t.endsWith(".yml")) return ce(n);
840
+ if (t.endsWith(".json")) return vt(n, r.isSdkInternal), it(n, { collapse: !t.endsWith("package.json") });
841
+ if (t.endsWith(".yaml") || t.endsWith(".yml")) return se(n);
830
842
  if (typeof n != "string") throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);
831
843
  return n;
832
844
  }
833
845
  case "binary": throw Error(`binary('${e.path}') cannot be resolved to a string; it is only valid inside seed()/scaffold(), which copy it verbatim via fs.writeBinary.`);
834
846
  }
835
847
  }
836
- function Ut(e, t, n, r, i) {
848
+ function Qt(e, t, n, r, i) {
837
849
  if (n.kind === "binary") {
838
850
  if (!r) throw Error(`binary('${n.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
839
851
  e.writeBinary(t, r.staticReadBinary(n.path));
840
852
  return;
841
853
  }
842
- e.write(t, Ht(n, t, r, i));
854
+ e.write(t, Zt(n, t, r, i));
843
855
  }
844
- function Wt(e, t, n, r, i, a) {
856
+ function $t(e, t, n, r, i, a) {
845
857
  let o = e.split("/").pop() ?? e;
846
858
  if (e.endsWith(".json")) {
847
- let i = Ke(t);
859
+ let i = Qe(t);
848
860
  if (typeof i != "object" || !i || Array.isArray(i)) throw Error(`managed: parsed value at '${e}' is not a JSON object`);
849
- return ht(i, n, { triggerContext: r }), Qe(i, { collapse: o !== "package.json" });
861
+ return St(i, n, { triggerContext: r }), it(i, { collapse: o !== "package.json" });
850
862
  }
851
863
  if (e.endsWith(".yaml") || e.endsWith(".yml")) {
852
- let e = Ft(t);
853
- return gt(e, n, {
864
+ let e = Ut(t);
865
+ return Ct(e, n, {
854
866
  triggerContext: r,
855
867
  getLatestVersion: i,
856
868
  getDerivedDependencyPin: a
857
- }), It(e);
869
+ }), Wt(e);
858
870
  }
859
871
  if (o === ".gitignore" || o.endsWith(".gitignore")) {
860
- let e = it(t);
861
- return _t(e, n, { triggerContext: r }), at(e);
872
+ let e = dt(t);
873
+ return wt(e, n, { triggerContext: r }), ft(e);
862
874
  }
863
875
  throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`);
864
876
  }
865
- function Gt(e) {
877
+ function en(e) {
866
878
  let t = e.list(""), n = /* @__PURE__ */ new Set();
867
879
  for (let e of t) {
868
880
  n.add(e);
@@ -871,37 +883,37 @@ function Gt(e) {
871
883
  }
872
884
  return n;
873
885
  }
874
- function Kt(e, t) {
886
+ function tn(e, t) {
875
887
  let n = t === "" ? t : t.endsWith("/") ? t.slice(0, -1) : t;
876
888
  return e.has(n);
877
889
  }
878
- function qt(e, t, n) {
890
+ function nn(e, t, n) {
879
891
  return {
880
892
  ctx: t,
881
893
  version: t.version,
882
- pathExists: (t) => Kt(e, t),
883
- pathMissing: (t) => !Kt(e, t),
894
+ pathExists: (t) => tn(e, t),
895
+ pathMissing: (t) => !tn(e, t),
884
896
  filesMatch: (t) => {
885
897
  let r = n ? `${n}/${t}` : t;
886
- for (let t of e) if (Me(r, t)) return !0;
898
+ for (let t of e) if (Le(r, t)) return !0;
887
899
  return !1;
888
900
  }
889
901
  };
890
902
  }
891
- function Jt(e, t) {
903
+ function rn(e, t) {
892
904
  for (let n of e.triggers) if (!n(t)) return !1;
893
905
  return !0;
894
906
  }
895
- function Yt(e, t) {
907
+ function an(e, t) {
896
908
  return t ? "init" : e.updateDepsOnly ? "updateDeps" : "default";
897
909
  }
898
- function Xt(e, t) {
910
+ function on(e, t) {
899
911
  return e.filter((e) => e.modes.includes(t));
900
912
  }
901
- function Zt(e, t, n, r, i, a) {
913
+ function sn(e, t, n, r, i, a) {
902
914
  let o = e.leaf;
903
915
  if (o.kind === "fixed") {
904
- let i = Ht(o.content, e.resolvedPath, r, a);
916
+ let i = Zt(o.content, e.resolvedPath, r, a);
905
917
  return t.exists(e.resolvedPath) ? t.read(e.resolvedPath) === i ? void 0 : (n || t.write(e.resolvedPath, i), {
906
918
  scope: e.scope,
907
919
  path: e.resolvedPath,
@@ -914,13 +926,13 @@ function Zt(e, t, n, r, i, a) {
914
926
  action: "create"
915
927
  });
916
928
  }
917
- if (o.kind === "scaffold") return t.exists(e.resolvedPath) ? void 0 : (n || Ut(t, e.resolvedPath, o.initial, r, a), {
929
+ if (o.kind === "scaffold") return t.exists(e.resolvedPath) ? void 0 : (n || Qt(t, e.resolvedPath, o.initial, r, a), {
918
930
  scope: e.scope,
919
931
  path: e.resolvedPath,
920
932
  primitive: "scaffold",
921
933
  action: "create"
922
934
  });
923
- if (o.kind === "seed") return !i || t.exists(e.resolvedPath) ? void 0 : (n || Ut(t, e.resolvedPath, o.initial, r, a), {
935
+ if (o.kind === "seed") return !i || t.exists(e.resolvedPath) ? void 0 : (n || Qt(t, e.resolvedPath, o.initial, r, a), {
924
936
  scope: e.scope,
925
937
  path: e.resolvedPath,
926
938
  primitive: "seed",
@@ -943,58 +955,58 @@ function Zt(e, t, n, r, i, a) {
943
955
  });
944
956
  }
945
957
  }
946
- function Qt(e, t, n, r, i, a, o, s) {
958
+ function cn(e, t, n, r, i, a, o, s) {
947
959
  if (e.leaf.kind !== "managed") return;
948
- let c = e.leaf, l = e.resolvedPath, u = t.exists(l), d, ee = !1;
949
- u ? d = t.read(l) : (d = Ht(c.initial, l, i, s), ee = !0);
950
- let f = Wt(l, d, c.body, r, a, o);
951
- if (ee) return n || t.write(l, f), {
960
+ let c = e.leaf, l = e.resolvedPath, u = t.exists(l), d, f = !1;
961
+ u ? d = t.read(l) : (d = Zt(c.initial, l, i, s), f = !0);
962
+ let p = $t(l, d, c.body, r, a, o);
963
+ if (f) return n || t.write(l, p), {
952
964
  scope: e.scope,
953
965
  path: l,
954
966
  primitive: "managed",
955
967
  action: "create"
956
968
  };
957
- if (f !== d) return n || t.write(l, f), {
969
+ if (p !== d) return n || t.write(l, p), {
958
970
  scope: e.scope,
959
971
  path: l,
960
972
  primitive: "managed",
961
973
  action: "update"
962
974
  };
963
975
  }
964
- function $t(e, t, n, r, i, a, o, s) {
965
- let c = Xt(e, Yt(n, a)), l = [], u = Gt(t);
976
+ function ln(e, t, n, r, i, a, o, s) {
977
+ let c = on(e, an(n, a)), l = [], u = en(t);
966
978
  for (let e of c) {
967
- if (e.leaf.kind === "managed" || !Jt(e, qt(u, n, e.modulePath))) continue;
968
- let o = Zt(e, t, r, i, a, n);
979
+ if (e.leaf.kind === "managed" || !rn(e, nn(u, n, e.modulePath))) continue;
980
+ let o = sn(e, t, r, i, a, n);
969
981
  o && l.push(o);
970
982
  }
971
- let d = Gt(t);
983
+ let d = en(t);
972
984
  for (let e of c) {
973
985
  if (e.leaf.kind !== "managed") continue;
974
- let a = qt(d, n, e.modulePath);
975
- if (!Jt(e, a)) continue;
976
- let c = Qt(e, t, r, a, i, o, s, n);
986
+ let a = nn(d, n, e.modulePath);
987
+ if (!rn(e, a)) continue;
988
+ let c = cn(e, t, r, a, i, o, s, n);
977
989
  c && l.push(c);
978
990
  }
979
991
  return l;
980
992
  }
981
- function en(e, t, n, r = {}) {
982
- return Pe(n, () => {
983
- let i = De(e, n), a = !!r.initMode, o = $t(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
993
+ function un(e, t, n, r = {}) {
994
+ return Be(n, () => {
995
+ let i = Me(e, n), a = !!r.initMode, o = ln(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
984
996
  if (!n.dryRun && !n.updateDepsOnly && !a) {
985
- Bt(t);
997
+ Yt(t, { version: 2 });
986
998
  let i = {
987
999
  ...r.rediscover ? r.rediscover(t) : n,
988
1000
  dryRun: !0
989
- }, a = $t(De(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== Lt);
990
- if (a.length > 0) throw new Vt(a[0]);
1001
+ }, a = ln(Me(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== Gt);
1002
+ if (a.length > 0) throw new Xt(a[0]);
991
1003
  }
992
- return a && !n.dryRun && Bt(t), { changes: o };
1004
+ return a && !n.dryRun && Yt(t, { version: 2 }), { changes: o };
993
1005
  });
994
1006
  }
995
1007
  //#endregion
996
1008
  //#region src/structure/engine/discovery.ts
997
- var tn = [
1009
+ var dn = [
998
1010
  "root",
999
1011
  "block",
1000
1012
  "model",
@@ -1002,12 +1014,12 @@ var tn = [
1002
1014
  "workflow",
1003
1015
  "test",
1004
1016
  "software"
1005
- ], nn = class extends Error {
1017
+ ], fn = class extends Error {
1006
1018
  constructor(e, t) {
1007
1019
  super(e), this.path = t, this.name = "DiscoveryError";
1008
1020
  }
1009
1021
  };
1010
- function rn(e) {
1022
+ function pn(e) {
1011
1023
  let t = /* @__PURE__ */ new Set();
1012
1024
  for (let n of [
1013
1025
  e.dependencies,
@@ -1017,18 +1029,18 @@ function rn(e) {
1017
1029
  ]) if (n) for (let e of Object.keys(n)) t.add(e);
1018
1030
  return t;
1019
1031
  }
1020
- function an(e) {
1032
+ function mn(e) {
1021
1033
  return e === "" || e === ".";
1022
1034
  }
1023
- function on(e) {
1035
+ function hn(e) {
1024
1036
  let t = e.pkg["block-scope"];
1025
1037
  if (typeof t == "string") {
1026
- if (!tn.includes(t)) throw new nn(`package.json "block-scope" must be one of ${tn.join(", ")}, got '${t}'`, e.path);
1038
+ if (!dn.includes(t)) throw new fn(`package.json "block-scope" must be one of ${dn.join(", ")}, got '${t}'`, e.path);
1027
1039
  return t;
1028
1040
  }
1029
- if (an(e.path)) return "root";
1041
+ if (mn(e.path)) return "root";
1030
1042
  if (e.pkg.block !== void 0) return "block";
1031
- let n = rn(e.pkg);
1043
+ let n = pn(e.pkg);
1032
1044
  if (e.pkg["block-software"] !== void 0) return "software";
1033
1045
  if (n.has("@platforma-sdk/package-builder")) {
1034
1046
  for (let e of n) if (/^@platforma-open\/.*runenv/.test(e)) return "software";
@@ -1038,15 +1050,15 @@ function on(e) {
1038
1050
  if (n.has("@platforma-sdk/model") && e.pkg.main) return "model";
1039
1051
  if (n.has("@platforma-sdk/test")) return "test";
1040
1052
  }
1041
- function sn(e) {
1053
+ function gn(e) {
1042
1054
  let t = [];
1043
1055
  for (let n of e) {
1044
- let e = on(n);
1045
- if (!e) throw new nn(`Unclassified workspace package at '${n.path}'. Add a top-level "block-scope" string to its package.json.`, n.path);
1056
+ let e = hn(n);
1057
+ if (!e) throw new fn(`Unclassified workspace package at '${n.path}'. Add a top-level "block-scope" string to its package.json.`, n.path);
1046
1058
  t.push({
1047
1059
  scope: e,
1048
1060
  name: n.pkg.name ?? n.path,
1049
- path: an(n.path) ? "" : n.path
1061
+ path: mn(n.path) ? "" : n.path
1050
1062
  });
1051
1063
  }
1052
1064
  return t;
@@ -1056,21 +1068,21 @@ function sn(e) {
1056
1068
  function J(e, t) {
1057
1069
  return e.modules.filter((e) => e.scope === t);
1058
1070
  }
1059
- function cn(e, t) {
1071
+ function _n(e, t) {
1060
1072
  let n = J(e, t);
1061
1073
  if (n.length === 0) throw Error(`findModule: expected one '${t}' module, found none`);
1062
1074
  if (n.length > 1) throw Error(`findModule: expected exactly one '${t}' module, found ${n.length}`);
1063
1075
  return n[0];
1064
1076
  }
1065
- function ln(e, t) {
1066
- return { [cn(e, t).name]: "workspace:*" };
1077
+ function vn(e, t) {
1078
+ return { [_n(e, t).name]: "workspace:*" };
1067
1079
  }
1068
- function un(e, t) {
1080
+ function yn(e, t) {
1069
1081
  let n = {};
1070
1082
  for (let r of J(e, t)) n[r.name] = "workspace:*";
1071
1083
  return n;
1072
1084
  }
1073
- function dn(e) {
1085
+ function bn(e) {
1074
1086
  let t = e.facadeName, n = [
1075
1087
  {
1076
1088
  scope: "root",
@@ -1109,7 +1121,7 @@ function dn(e) {
1109
1121
  path: "software"
1110
1122
  }), n;
1111
1123
  }
1112
- function fn(e) {
1124
+ function xn(e) {
1113
1125
  return {
1114
1126
  isSdkInternal: e.isSdkInternal ?? !1,
1115
1127
  updateDepsOnly: e.updateDepsOnly ?? !1,
@@ -1126,36 +1138,36 @@ var Y = class extends Error {
1126
1138
  super(e), this.name = "StructureCliError";
1127
1139
  }
1128
1140
  };
1129
- function pn(e, t) {
1141
+ function Sn(e, t) {
1130
1142
  return e === "" ? t : `${e}/${t}`;
1131
1143
  }
1132
- function mn(e, t) {
1144
+ function Cn(e, t) {
1133
1145
  try {
1134
1146
  return JSON.parse(e.read(t));
1135
1147
  } catch {
1136
1148
  return;
1137
1149
  }
1138
1150
  }
1139
- function hn(e) {
1151
+ function wn(e) {
1140
1152
  if (e.includes("*")) throw new Y(`pnpm-workspace.yaml 'packages:' entry '${e}' contains a glob. The structurer requires literal package paths — replace the glob with one entry per package directory.`);
1141
1153
  let t = e.replace(/^\.\//, "").replace(/\/$/, "");
1142
1154
  return t === "." ? "" : t;
1143
1155
  }
1144
- function gn(e) {
1156
+ function Tn(e) {
1145
1157
  let t;
1146
1158
  try {
1147
1159
  t = e.read("pnpm-workspace.yaml");
1148
1160
  } catch {
1149
1161
  throw new Y("No pnpm-workspace.yaml found. This directory is empty or unrecognisable as a block — run 'block-tools structure init' instead, or pass --sdk-internal for an in-monorepo block.");
1150
1162
  }
1151
- let n = oe(t) ?? {}, r = Array.isArray(n.packages) ? n.packages : [], i = new Set([""]);
1163
+ let n = ae(t) ?? {}, r = Array.isArray(n.packages) ? n.packages : [], i = new Set([""]);
1152
1164
  for (let t of r) {
1153
- let n = hn(t);
1165
+ let n = wn(t);
1154
1166
  (n === "" || e.exists(n)) && i.add(n);
1155
1167
  }
1156
1168
  let a = [];
1157
1169
  for (let t of i) {
1158
- let n = mn(e, pn(t, "package.json"));
1170
+ let n = Cn(e, Sn(t, "package.json"));
1159
1171
  n && a.push({
1160
1172
  path: t,
1161
1173
  pkg: n
@@ -1163,7 +1175,7 @@ function gn(e) {
1163
1175
  }
1164
1176
  return a;
1165
1177
  }
1166
- function _n(e) {
1178
+ function En(e) {
1167
1179
  let t = [], n = new Set([
1168
1180
  "node_modules",
1169
1181
  ".turbo",
@@ -1175,7 +1187,7 @@ function _n(e) {
1175
1187
  let o = e.listDir(i);
1176
1188
  for (let s of o) {
1177
1189
  if (!s.isDirectory || n.has(s.name)) continue;
1178
- let o = pn(i, s.name), c = mn(e, pn(o, "package.json"));
1190
+ let o = Sn(i, s.name), c = Cn(e, Sn(o, "package.json"));
1179
1191
  c && t.push({
1180
1192
  path: o,
1181
1193
  pkg: c
@@ -1184,7 +1196,7 @@ function _n(e) {
1184
1196
  }
1185
1197
  return r("", 1), t;
1186
1198
  }
1187
- function vn(e) {
1199
+ function Dn(e) {
1188
1200
  let t = e.indexOf("/");
1189
1201
  if (!e.startsWith("@") || t < 0) throw new Y(`Cannot parse block name '${e}': expected '@npm-org/org-scope.short-name'.`);
1190
1202
  let n = e.slice(0, t), r = e.slice(t + 1), i = r.indexOf(".");
@@ -1197,28 +1209,20 @@ function vn(e) {
1197
1209
  shortName: r.slice(i + 1)
1198
1210
  };
1199
1211
  }
1200
- function yn(e) {
1201
- try {
1202
- let t = JSON.parse(e.read(Lt));
1203
- return typeof t.version == "number" ? t.version : 0;
1204
- } catch {
1205
- return 0;
1206
- }
1207
- }
1208
- function bn(e) {
1209
- let { fs: t, isSdkInternal: n } = e, r = n ? _n(t) : gn(t);
1212
+ function On(e) {
1213
+ let { fs: t, isSdkInternal: n } = e, r = n ? En(t) : Tn(t);
1210
1214
  if (r.length === 0) throw new Y("No workspace packages found. Run 'block-tools structure init' to scaffold a block.");
1211
- let i = sn(r), a = yn(t);
1212
- Rt(a, 0);
1215
+ let i = gn(r), a = Kt(t);
1216
+ qt(a.version, 0);
1213
1217
  let o = i.find((e) => e.scope === "block") ?? i.find((e) => e.scope === "root");
1214
1218
  if (!o) throw new Y("Could not find a 'block' (or root-as-block) package to derive BlockVars from.");
1215
- let s = vn(o.name.replace(/\.block$/, ""));
1216
- return fn({
1219
+ let s = Dn(o.name.replace(/\.block$/, ""));
1220
+ return xn({
1217
1221
  isSdkInternal: n,
1218
1222
  updateDepsOnly: e.updateDepsOnly ?? !1,
1219
1223
  modules: i,
1220
1224
  blockVars: s,
1221
- version: a,
1225
+ version: a.version,
1222
1226
  dryRun: e.dryRun ?? !1
1223
1227
  });
1224
1228
  }
@@ -1245,20 +1249,25 @@ var X = [
1245
1249
  "pnpm",
1246
1250
  "block",
1247
1251
  "block-software"
1248
- ];
1249
- //#endregion
1250
- //#region src/structure/rules/root-package-json.ts
1251
- function xn(e) {
1252
+ ], kn = {
1253
+ "build:dev-local": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=local turbo run build",
1254
+ "build:dev-remote": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build",
1255
+ "build:dev-no-software": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=none turbo run build",
1256
+ "build:dev-binary-existing": "env PL_BUILD_CHANNEL=dev PL_BUILD_USE_PUBLISHED=true turbo run build",
1257
+ "build:release": "env PL_BUILD_CHANNEL=release PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build"
1258
+ }, An = {
1259
+ test: "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --concurrency 1",
1260
+ "test:dry-run": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --dry-run=json"
1261
+ };
1262
+ function jn() {
1252
1263
  return {
1253
1264
  version: "1.0.0",
1254
1265
  private: !0,
1255
1266
  scripts: {
1256
1267
  fmt: "turbo run fmt",
1257
1268
  check: "turbo run check",
1258
- build: "turbo run build",
1259
- "build:dev": "env PL_PKG_DEV=local turbo run build",
1260
- test: "env PL_PKG_DEV=local turbo run test --concurrency 1",
1261
- "test:dry-run": "env PL_PKG_DEV=local turbo run test --dry-run=json",
1269
+ ...kn,
1270
+ ...An,
1262
1271
  "mark-stable": "turbo run mark-stable",
1263
1272
  "do-pack": "turbo run do-pack",
1264
1273
  watch: "turbo watch build",
@@ -1281,17 +1290,20 @@ function xn(e) {
1281
1290
  packageManager: "pnpm@9.12.0"
1282
1291
  };
1283
1292
  }
1284
- function Sn() {
1285
- L("packageManager", "pnpm@9.12.0"), R("name"), z("fmt", "turbo run fmt"), z("check", "turbo run check"), z("build", "turbo run build"), z("build:dev", "env PL_PKG_DEV=local turbo run build"), z("test", "env PL_PKG_DEV=local turbo run test --concurrency 1"), z("test:dry-run", "env PL_PKG_DEV=local turbo run test --dry-run=json"), z("mark-stable", "turbo run mark-stable"), z("do-pack", "turbo run do-pack"), z("watch", "turbo watch build"), z("changeset", "changeset"), z("version-packages", "changeset version"), z("update-sdk", "block-tools structure refresh --update-deps-only"), B("update"), z("upgrade-sdk", "block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt"), G({
1293
+ function Mn() {
1294
+ R("packageManager", "pnpm@9.12.0"), z("name"), B("fmt", "turbo run fmt"), B("check", "turbo run check");
1295
+ for (let [e, t] of Object.entries(kn)) B(e, t);
1296
+ for (let [e, t] of Object.entries(An)) B(e, t);
1297
+ V("build"), V("build:dev"), B("mark-stable", "turbo run mark-stable"), B("do-pack", "turbo run do-pack"), B("watch", "turbo watch build"), B("changeset", "changeset"), B("version-packages", "changeset version"), B("update-sdk", "block-tools structure refresh --update-deps-only"), V("update"), B("upgrade-sdk", "block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt"), G({
1286
1298
  "@changesets/cli": "catalog:",
1287
1299
  "@milaboratories/ts-builder": "sdk:",
1288
1300
  "@platforma-sdk/block-tools": "sdk:",
1289
1301
  shx: "catalog:",
1290
1302
  turbo: "catalog:"
1291
- }), xt({
1303
+ }), kt({
1292
1304
  oxlint: "*",
1293
1305
  oxfmt: "*"
1294
- }), Tt((e, t) => {
1306
+ }), Nt((e, t) => {
1295
1307
  if (!/^(\/\/|--)/.test(e) || typeof t != "object" || !t) return !1;
1296
1308
  let n = t;
1297
1309
  return n.pnpm !== void 0 || n.overrides !== void 0;
@@ -1299,70 +1311,70 @@ function Sn() {
1299
1311
  }
1300
1312
  //#endregion
1301
1313
  //#region src/structure/engine/registry-client.ts
1302
- var Cn = 2, wn = 500, Tn = 3e4;
1303
- function En(e) {
1314
+ var Nn = 2, Pn = 500, Fn = 3e4;
1315
+ function In(e) {
1304
1316
  if (!e) return null;
1305
1317
  let t = Number(e);
1306
1318
  if (Number.isFinite(t) && t > 0) return t * 1e3;
1307
1319
  let n = Date.parse(e);
1308
1320
  return Number.isNaN(n) ? null : Math.max(0, n - Date.now());
1309
1321
  }
1310
- async function Dn(e) {
1322
+ async function Ln(e) {
1311
1323
  for (let t = 1;; t++) {
1312
1324
  let n;
1313
1325
  try {
1314
- n = await fetch(e, { signal: AbortSignal.timeout(Tn) });
1326
+ n = await fetch(e, { signal: AbortSignal.timeout(Fn) });
1315
1327
  } catch (e) {
1316
- if (t > Cn) throw e;
1317
- await le(wn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1328
+ if (t > Nn) throw e;
1329
+ await ce(Pn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1318
1330
  continue;
1319
1331
  }
1320
1332
  if (n.ok) return n;
1321
- if (!(n.status === 429 || n.status >= 500) || t > Cn) throw Error(`registry returned HTTP ${n.status}`);
1322
- let r = En(n.headers.get("retry-after"));
1333
+ if (!(n.status === 429 || n.status >= 500) || t > Nn) throw Error(`registry returned HTTP ${n.status}`);
1334
+ let r = In(n.headers.get("retry-after"));
1323
1335
  if (r != null) {
1324
- await le(r);
1336
+ await ce(r);
1325
1337
  continue;
1326
1338
  }
1327
- await le(wn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1339
+ await ce(Pn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1328
1340
  }
1329
1341
  }
1330
- function On() {
1342
+ function Rn() {
1331
1343
  return {
1332
1344
  async getLatestVersion(e) {
1333
- let t = (await (await Dn(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;
1345
+ let t = (await (await Ln(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;
1334
1346
  if (!t) throw Error("no 'latest' dist-tag in registry response");
1335
1347
  return t;
1336
1348
  },
1337
1349
  async getDeclaredDependency(e, t, n) {
1338
- let r = await (await Dn(`https://registry.npmjs.org/${e}/${t}`)).json();
1350
+ let r = await (await Ln(`https://registry.npmjs.org/${e}/${t}`)).json();
1339
1351
  return r.dependencies?.[n] ?? r.peerDependencies?.[n];
1340
1352
  }
1341
1353
  };
1342
1354
  }
1343
- async function kn(e, t) {
1355
+ async function zn(e, t) {
1344
1356
  let n = await Promise.all(t.map(async (t) => [t, await e.getLatestVersion(t)]));
1345
1357
  return new Map(n);
1346
1358
  }
1347
- function An(e) {
1359
+ function Bn(e) {
1348
1360
  return (t) => e.get(t);
1349
1361
  }
1350
- var jn = [/^@platforma-sdk\//, /^@milaboratories\//];
1351
- function Mn(e) {
1352
- return jn.some((t) => t.test(e));
1362
+ var Vn = [/^@platforma-sdk\//, /^@milaboratories\//];
1363
+ function Hn(e) {
1364
+ return Vn.some((t) => t.test(e));
1353
1365
  }
1354
- async function Nn(e, t = On()) {
1355
- return e.length === 0 ? () => void 0 : An(await kn(t, e));
1366
+ async function Un(e, t = Rn()) {
1367
+ return e.length === 0 ? () => void 0 : Bn(await zn(t, e));
1356
1368
  }
1357
- function Pn(e) {
1369
+ function Wn(e) {
1358
1370
  return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e);
1359
1371
  }
1360
- async function Fn(e, t = On()) {
1372
+ async function Gn(e, t = Rn()) {
1361
1373
  if (e.length === 0) return () => void 0;
1362
1374
  let n = await Promise.all(e.map(async (e) => {
1363
1375
  let n = await t.getDeclaredDependency(e.of, e.ofVersion ?? "latest", e.entry);
1364
1376
  if (n === void 0) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares no dependency '${e.entry}'. A derived pin requires the source to declare the dep as an exact version.`);
1365
- if (!Pn(n)) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);
1377
+ if (!Wn(n)) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);
1366
1378
  return [e.entry, n];
1367
1379
  })), r = new Map(n);
1368
1380
  return (e) => r.get(e);
@@ -1370,7 +1382,7 @@ async function Fn(e, t = On()) {
1370
1382
  //#endregion
1371
1383
  //#region src/structure/rules/shared/retired-deps.ts
1372
1384
  // @vitejs/plugin-vue — bundled by ts-builder's internal vite config.
1373
- var In = [
1385
+ var Kn = [
1374
1386
  "vite",
1375
1387
  "tsup",
1376
1388
  "vue-tsc",
@@ -1378,8 +1390,8 @@ var In = [
1378
1390
  "vite-plugin-dts",
1379
1391
  "@platforma-sdk/eslint-config"
1380
1392
  ];
1381
- function Ln() {
1382
- for (let e of In) W(e);
1393
+ function qn() {
1394
+ for (let e of Kn) W(e);
1383
1395
  }
1384
1396
  //#endregion
1385
1397
  //#region src/structure/rules/root-pnpm-workspace.ts
@@ -1393,32 +1405,35 @@ var Z = [
1393
1405
  "@platforma-sdk/package-builder",
1394
1406
  "@milaboratories/ts-builder",
1395
1407
  "@milaboratories/ts-configs"
1396
- ], Rn = "0.0.0-init-must-fetch";
1397
- for (let e of Z) if (!Mn(e)) throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);
1398
- var zn = {
1408
+ ], Jn = "0.0.0-init-must-fetch";
1409
+ for (let e of Z) if (!Hn(e)) throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);
1410
+ var Yn = {
1399
1411
  turbo: "~2.8.11",
1400
1412
  shx: "~0.4.0",
1401
1413
  "@changesets/cli": "~2.29.8",
1402
1414
  vitest: "~4.0.18"
1403
- }, Bn = [{
1415
+ }, Xn = [{
1404
1416
  entry: "vue",
1405
1417
  of: "@platforma-sdk/ui-vue"
1406
- }], Vn = "@platforma-open/milaboratories.runenv-python-3", Hn = "1.8.2";
1407
- function Un(e) {
1418
+ }, {
1419
+ entry: "@milaboratories/helpers",
1420
+ of: "@platforma-sdk/model"
1421
+ }], Zn = "@platforma-open/milaboratories.runenv-python-3", Qn = "1.8.2";
1422
+ function $n(e) {
1408
1423
  let t = e.modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = {};
1409
- for (let e of Z) n[e] = Rn;
1410
- return Object.assign(n, zn), e.modules.some((e) => e.scope === "software") && (n[Vn] = Hn), {
1424
+ for (let e of Z) n[e] = Jn;
1425
+ return Object.assign(n, Yn), e.modules.some((e) => e.scope === "software") && (n[Zn] = Qn), {
1411
1426
  packages: t,
1412
1427
  catalog: n
1413
1428
  };
1414
1429
  }
1415
- function Wn() {
1416
- Ot();
1417
- for (let e of In) Nt(e);
1430
+ function er() {
1431
+ It();
1432
+ for (let e of Kn) Vt(e);
1418
1433
  }
1419
1434
  //#endregion
1420
1435
  //#region src/structure/rules/root-gitignore.ts
1421
- var Gn = [
1436
+ var tr = [
1422
1437
  ".test_auth.json",
1423
1438
  "node_modules/",
1424
1439
  "dist/",
@@ -1433,45 +1448,45 @@ var Gn = [
1433
1448
  ".vscode/sftp.json",
1434
1449
  "test-dry-run.json"
1435
1450
  ];
1436
- function Kn() {
1437
- Pt(Gn);
1451
+ function nr() {
1452
+ Ht(tr);
1438
1453
  }
1439
1454
  //#endregion
1440
1455
  //#region src/structure/rules/root.ts
1441
- function qn() {
1442
- b("root", () => {
1443
- x(({ ctx: e }) => !e.isSdkInternal, () => {
1444
- C("turbo.json", O("root/turbo.json")), C(".vscode/settings.json", O("root/.vscode/settings.json")), w("package.json", A((e) => xn(e)), () => {
1445
- Sn();
1446
- }), w("pnpm-workspace.yaml", A((e) => Un(e)), () => {
1447
- Wn();
1448
- }), w(".gitignore", O("root/.gitignore"), () => {
1449
- Kn();
1456
+ function rr() {
1457
+ S("root", () => {
1458
+ C(({ ctx: e }) => !e.isSdkInternal, () => {
1459
+ T("turbo.json", A("root/turbo.json")), T(".vscode/settings.json", A("root/.vscode/settings.json")), E("package.json", M(() => jn()), () => {
1460
+ Mn();
1461
+ }), E("pnpm-workspace.yaml", M((e) => $n(e)), () => {
1462
+ er();
1463
+ }), E(".gitignore", A("root/.gitignore"), () => {
1464
+ nr();
1450
1465
  });
1451
1466
  });
1452
1467
  });
1453
1468
  }
1454
1469
  //#endregion
1455
1470
  //#region src/structure/rules/root-ci.ts
1456
- function Jn(e) {
1471
+ function ir(e) {
1457
1472
  return e.split(/[-_]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
1458
1473
  }
1459
- function Yn() {
1460
- b("root", () => {
1461
- x(({ ctx: e }) => !e.isSdkInternal, () => {
1462
- C(".github/workflows/build.yaml", k("workflows/build.tpl.yaml", (e) => {
1474
+ function ar() {
1475
+ S("root", () => {
1476
+ C(({ ctx: e }) => !e.isSdkInternal, () => {
1477
+ T(".github/workflows/build.yaml", j("workflows/build.tpl.yaml", (e) => {
1463
1478
  let t = e.blockVars.shortName;
1464
1479
  return {
1465
- appName: `Block: ${Jn(t)}`,
1480
+ appName: `Block: ${ir(t)}`,
1466
1481
  appNameSlug: `block-${t}`
1467
1482
  };
1468
- })), C(".github/workflows/mark-stable.yaml", k("workflows/mark-stable.tpl.yaml", (e) => ({ appName: `Block: ${Jn(e.blockVars.shortName)} - Mark Stable` })));
1483
+ })), T(".github/workflows/mark-stable.yaml", j("workflows/mark-stable.tpl.yaml", (e) => ({ appName: `Block: ${ir(e.blockVars.shortName)} - Mark Stable` })));
1469
1484
  });
1470
1485
  });
1471
1486
  }
1472
1487
  //#endregion
1473
1488
  //#region src/structure/rules/block-package-json.ts
1474
- var Xn = {
1489
+ var or = {
1475
1490
  "@platforma-open": {
1476
1491
  s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
1477
1492
  serveUrl: "https://blocks.pl-open.science"
@@ -1480,45 +1495,45 @@ var Xn = {
1480
1495
  s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
1481
1496
  serveUrl: "https://block.registry.platforma.bio/releases"
1482
1497
  }
1483
- }, Zn = {
1498
+ }, sr = {
1484
1499
  s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
1485
1500
  serveUrl: "https://blocks.pl-open.science"
1486
- }, Qn = {
1501
+ }, cr = {
1487
1502
  s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1",
1488
1503
  serveUrl: "https://aux-blocks.pl-open.science"
1489
1504
  };
1490
- function $n(e, t) {
1491
- let n = t ? Qn : Xn[e] ?? Zn;
1505
+ function lr(e, t) {
1506
+ let n = t ? cr : or[e] ?? sr;
1492
1507
  return `block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`;
1493
1508
  }
1494
- function er(e) {
1509
+ function ur(e) {
1495
1510
  let t = {};
1496
1511
  for (let n of J(e, "workflow")) t.workflow = `${n.name}/dist/tengo/tpl/main.plj.gz`;
1497
1512
  for (let n of J(e, "model")) t.model = `${n.name}/dist/model.json`;
1498
1513
  for (let n of J(e, "ui")) t.ui = `${n.name}/dist`;
1499
1514
  return t;
1500
1515
  }
1501
- function tr(e, t) {
1516
+ function dr(e, t) {
1502
1517
  return {
1503
1518
  build: "ts-builder build --target block-facade && block-tools pack",
1504
1519
  check: "ts-builder type-check --target block-facade",
1505
- prepublishOnly: $n(e, t),
1520
+ prepublishOnly: lr(e, t),
1506
1521
  "do-pack": "shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz"
1507
1522
  };
1508
1523
  }
1509
- var nr = {
1524
+ var fr = {
1510
1525
  "@milaboratories/ts-builder": "sdk:",
1511
1526
  "@milaboratories/ts-configs": "sdk:",
1512
1527
  "@platforma-sdk/block-tools": "sdk:",
1513
1528
  "@platforma-sdk/model": "sdk:",
1514
1529
  shx: "catalog:",
1515
1530
  typescript: "catalog:"
1516
- }, rr = { ".": {
1531
+ }, pr = { ".": {
1517
1532
  sources: "./src/index.ts",
1518
1533
  types: "./dist/index.d.ts",
1519
1534
  default: "./dist/index.js"
1520
1535
  } };
1521
- function ir(e) {
1536
+ function mr(e) {
1522
1537
  if (Object.keys(e.components).length === 0) throw Error("block.components is empty — no workflow/model/ui module was discovered");
1523
1538
  let t = e.meta, n = [
1524
1539
  ["block.meta.title", t.title],
@@ -1530,14 +1545,14 @@ function ir(e) {
1530
1545
  ];
1531
1546
  for (let [e, t] of n) if (typeof t != "string" || t === "") throw Error(`required block field '${e}' is empty`);
1532
1547
  }
1533
- function ar(e) {
1548
+ function hr(e) {
1534
1549
  let t = e.blockVars, n = {
1535
- ...nr,
1536
- ...un(e, "model"),
1537
- ...un(e, "ui"),
1538
- ...un(e, "workflow")
1550
+ ...fr,
1551
+ ...yn(e, "model"),
1552
+ ...yn(e, "ui"),
1553
+ ...yn(e, "workflow")
1539
1554
  }, r = {
1540
- components: er(e),
1555
+ components: ur(e),
1541
1556
  meta: {
1542
1557
  title: t.shortName,
1543
1558
  description: `${t.shortName} block`,
@@ -1549,7 +1564,7 @@ function ar(e) {
1549
1564
  }
1550
1565
  }
1551
1566
  };
1552
- return ir(r), {
1567
+ return mr(r), {
1553
1568
  name: `${t.facadeName}.block`,
1554
1569
  version: "1.0.0",
1555
1570
  type: "module",
@@ -1557,35 +1572,35 @@ function ar(e) {
1557
1572
  main: "./dist/index.js",
1558
1573
  module: "./dist/index.js",
1559
1574
  types: "./dist/index.d.ts",
1560
- exports: rr,
1561
- scripts: tr(t.npmOrg, e.isSdkInternal),
1575
+ exports: pr,
1576
+ scripts: dr(t.npmOrg, e.isSdkInternal),
1562
1577
  dependencies: {},
1563
1578
  devDependencies: n,
1564
1579
  block: r
1565
1580
  };
1566
1581
  }
1567
- function or(e) {
1582
+ function gr(e) {
1568
1583
  let t = e.blockVars;
1569
- L("type", "module"), L("files", ["dist", "block-pack"]), L("main", "./dist/index.js"), L("module", "./dist/index.js"), L("types", "./dist/index.d.ts"), L("exports", rr);
1570
- let n = tr(t.npmOrg, e.isSdkInternal);
1571
- for (let [e, t] of Object.entries(n)) z(e, t);
1572
- B("mark-stable"), wt("model"), wt("ui"), wt("workflow"), U("@milaboratories/ts-builder", "sdk:"), U("@milaboratories/ts-configs", "sdk:"), U("@platforma-sdk/block-tools", "sdk:"), U("@platforma-sdk/model", "sdk:"), U("shx", "catalog:"), U("typescript", "catalog:"), L("block.components", er(e)), vt("version", "facade package.json must carry a 'version' (the facade publishes)"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1584
+ R("type", "module"), R("files", ["dist", "block-pack"]), R("main", "./dist/index.js"), R("module", "./dist/index.js"), R("types", "./dist/index.d.ts"), R("exports", pr);
1585
+ let n = dr(t.npmOrg, e.isSdkInternal);
1586
+ for (let [e, t] of Object.entries(n)) B(e, t);
1587
+ V("mark-stable"), Mt("model"), Mt("ui"), Mt("workflow"), U("@milaboratories/ts-builder", "sdk:"), U("@milaboratories/ts-configs", "sdk:"), U("@platforma-sdk/block-tools", "sdk:"), U("@platforma-sdk/model", "sdk:"), U("shx", "catalog:"), U("typescript", "catalog:"), R("block.components", ur(e)), Tt("version", "facade package.json must carry a 'version' (the facade publishes)"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1573
1588
  }
1574
1589
  //#endregion
1575
1590
  //#region src/structure/rules/shared/pascal-case.ts
1576
- function sr(e) {
1591
+ function _r(e) {
1577
1592
  let t = e.split(/[^A-Za-z0-9]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
1578
1593
  return /^[0-9]/.test(t) ? `_${t}` : t;
1579
1594
  }
1580
1595
  //#endregion
1581
1596
  //#region src/structure/rules/block.ts
1582
- function cr() {
1583
- b("block", () => {
1584
- D("index.js"), D("index.d.ts"), C("src/index.ts", k("block/src/index.tpl.ts", (e) => ({
1597
+ function vr() {
1598
+ S("block", () => {
1599
+ k("index.js"), k("index.d.ts"), T("src/index.ts", j("block/src/index.tpl.ts", (e) => ({
1585
1600
  facadeName: e.blockVars.facadeName,
1586
- pascalName: sr(e.blockVars.shortName)
1587
- }))), C("src/AGENTS.ts", O("block/src/AGENTS.ts")), T("src/block-extra.ts", O("block/src/block-extra.ts")), T("src/agents-extra.ts", O("block/src/agents-extra.ts")), C("tsconfig.json", O("block/tsconfig.json")), E("logos/block-logo.png", We("block/logos/block-logo.png")), E("logos/organization-logo.png", We("block/logos/organization-logo.png")), w("package.json", A((e) => ar(e)), (e) => {
1588
- or(e);
1601
+ pascalName: _r(e.blockVars.shortName)
1602
+ }))), T("src/AGENTS.ts", A("block/src/AGENTS.ts")), D("src/block-extra.ts", A("block/src/block-extra.ts")), D("src/agents-extra.ts", A("block/src/agents-extra.ts")), T("tsconfig.json", A("block/tsconfig.json")), O("logos/block-logo.png", Xe("block/logos/block-logo.png")), O("logos/organization-logo.png", Xe("block/logos/organization-logo.png")), E("package.json", M((e) => hr(e)), (e) => {
1603
+ gr(e);
1589
1604
  });
1590
1605
  });
1591
1606
  }
@@ -1594,7 +1609,7 @@ function cr() {
1594
1609
  var Q = "src/**/*.test.ts";
1595
1610
  //#endregion
1596
1611
  //#region src/structure/rules/model-package-json.ts
1597
- function lr(e) {
1612
+ function yr(e) {
1598
1613
  return {
1599
1614
  name: `${e.blockVars.facadeName}.model`,
1600
1615
  private: !0,
@@ -1628,37 +1643,37 @@ function lr(e) {
1628
1643
  }
1629
1644
  };
1630
1645
  }
1631
- function ur() {
1632
- L("private", !0), L("type", "module"), L("main", "dist/index.cjs"), L("module", "dist/index.js"), L("types", "dist/index.d.ts"), L("exports", {
1646
+ function br() {
1647
+ R("private", !0), R("type", "module"), R("main", "dist/index.cjs"), R("module", "dist/index.js"), R("types", "dist/index.d.ts"), R("exports", {
1633
1648
  ".": {
1634
1649
  types: "./dist/index.d.ts",
1635
1650
  sources: "./src/index.ts",
1636
1651
  import: "./dist/index.js"
1637
1652
  },
1638
1653
  "./dist/*": "./dist/*"
1639
- }), z("fmt", "ts-builder format"), z("watch", "ts-builder build --target block-model --watch"), z("build", "ts-builder build --target block-model && block-tools build-model"), z("check", "ts-builder check --target block-model"), H("@platforma-sdk/model", "sdk:"), G({
1654
+ }), B("fmt", "ts-builder format"), B("watch", "ts-builder build --target block-model --watch"), B("build", "ts-builder build --target block-model && block-tools build-model"), B("check", "ts-builder check --target block-model"), H("@platforma-sdk/model", "sdk:"), G({
1640
1655
  "@milaboratories/ts-builder": "sdk:",
1641
1656
  "@milaboratories/ts-configs": "sdk:",
1642
1657
  "@platforma-sdk/block-tools": "sdk:"
1643
- }), xt({
1658
+ }), kt({
1644
1659
  "@types/node": "*",
1645
1660
  typescript: "*"
1646
- }), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1647
- z("test", "vitest run --passWithNoTests"), U("vitest", "catalog:"), U("@types/node", "*");
1648
- }, () => W("vitest"))), Ln(), R("tsup"), B("lint"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1661
+ }), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
1662
+ B("test", "vitest run --passWithNoTests"), U("vitest", "catalog:"), U("@types/node", "*");
1663
+ }, () => W("vitest"))), qn(), z("tsup"), V("lint"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1649
1664
  }
1650
1665
  //#endregion
1651
1666
  //#region src/structure/rules/model.ts
1652
- function dr() {
1653
- b("model", () => {
1654
- x(S(Q), () => C("tsconfig.json", O("model/tsconfig.node.json")), () => C("tsconfig.json", O("model/tsconfig.json"))), C(".oxlintrc.json", O("model/.oxlintrc.json")), C(".oxfmtrc.json", O("model/.oxfmtrc.json")), E("src/index.ts", O("model/src/index.ts")), w("package.json", A((e) => lr(e)), () => {
1655
- ur();
1667
+ function xr() {
1668
+ S("model", () => {
1669
+ C(w(Q), () => T("tsconfig.json", A("model/tsconfig.node.json")), () => T("tsconfig.json", A("model/tsconfig.json"))), T(".oxlintrc.json", A("model/.oxlintrc.json")), T(".oxfmtrc.json", A("model/.oxfmtrc.json")), O("src/index.ts", A("model/src/index.ts")), E("package.json", M((e) => yr(e)), () => {
1670
+ br();
1656
1671
  });
1657
1672
  });
1658
1673
  }
1659
1674
  //#endregion
1660
1675
  //#region src/structure/rules/ui-package-json.ts
1661
- function fr(e) {
1676
+ function Sr(e) {
1662
1677
  return {
1663
1678
  name: `${e.blockVars.facadeName}.ui`,
1664
1679
  private: !0,
@@ -1673,7 +1688,7 @@ function fr(e) {
1673
1688
  dependencies: {
1674
1689
  "@platforma-sdk/ui-vue": "sdk:",
1675
1690
  vue: "catalog:",
1676
- ...ln(e, "model")
1691
+ ...vn(e, "model")
1677
1692
  },
1678
1693
  devDependencies: {
1679
1694
  "@milaboratories/ts-builder": "sdk:",
@@ -1685,29 +1700,29 @@ function fr(e) {
1685
1700
  }
1686
1701
  };
1687
1702
  }
1688
- function pr() {
1689
- L("private", !0), L("type", "module"), z("fmt", "ts-builder format"), z("dev", "ts-builder serve --target block-ui"), z("watch", "ts-builder build --target block-ui --watch"), z("build", "ts-builder build --target block-ui"), z("check", "ts-builder check --target block-ui"), H("@platforma-sdk/ui-vue", "sdk:"), H("vue", "catalog:"), Ct("model"), G({
1703
+ function Cr() {
1704
+ R("private", !0), R("type", "module"), B("fmt", "ts-builder format"), B("dev", "ts-builder serve --target block-ui"), B("watch", "ts-builder build --target block-ui --watch"), B("build", "ts-builder build --target block-ui"), B("check", "ts-builder check --target block-ui"), H("@platforma-sdk/ui-vue", "sdk:"), H("vue", "catalog:"), jt("model"), G({
1690
1705
  "@milaboratories/ts-builder": "sdk:",
1691
1706
  "@milaboratories/ts-configs": "sdk:"
1692
- }), Ln(), B("preview"), B("lint"), xt({
1707
+ }), qn(), V("preview"), V("lint"), kt({
1693
1708
  "@types/node": "*",
1694
1709
  typescript: "*"
1695
- }), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1696
- z("test", "vitest run --passWithNoTests"), U("vitest", "catalog:"), U("@types/node", "*");
1710
+ }), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
1711
+ B("test", "vitest run --passWithNoTests"), U("vitest", "catalog:"), U("@types/node", "*");
1697
1712
  }, () => W("vitest"))), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1698
1713
  }
1699
1714
  //#endregion
1700
1715
  //#region src/structure/rules/ui.ts
1701
- function mr() {
1702
- b("ui", () => {
1703
- x(S(Q), () => C("tsconfig.json", O("ui/tsconfig.node.json")), () => C("tsconfig.json", O("ui/tsconfig.json"))), C(".oxlintrc.json", O("ui/.oxlintrc.json")), C(".oxfmtrc.json", O("ui/.oxfmtrc.json")), T("index.html", O("ui/index.html")), E("src/main.ts", O("ui/src/main.ts")), E("src/app.ts", k("ui/src/app.tpl.ts", (e) => ({ modelPkg: `${e.blockVars.facadeName}.model` }))), E("src/MainPage.vue", k("ui/src/MainPage.tpl.vue", (e) => ({ shortName: e.blockVars.shortName }))), w("package.json", A((e) => fr(e)), () => {
1704
- pr();
1716
+ function wr() {
1717
+ S("ui", () => {
1718
+ C(w(Q), () => T("tsconfig.json", A("ui/tsconfig.node.json")), () => T("tsconfig.json", A("ui/tsconfig.json"))), T(".oxlintrc.json", A("ui/.oxlintrc.json")), T(".oxfmtrc.json", A("ui/.oxfmtrc.json")), D("index.html", A("ui/index.html")), O("src/main.ts", A("ui/src/main.ts")), O("src/app.ts", j("ui/src/app.tpl.ts", (e) => ({ modelPkg: `${e.blockVars.facadeName}.model` }))), O("src/MainPage.vue", j("ui/src/MainPage.tpl.vue", (e) => ({ shortName: e.blockVars.shortName }))), E("package.json", M((e) => Sr(e)), () => {
1719
+ Cr();
1705
1720
  });
1706
1721
  });
1707
1722
  }
1708
1723
  //#endregion
1709
1724
  //#region src/structure/rules/workflow-package-json.ts
1710
- function hr(e) {
1725
+ function Tr(e) {
1711
1726
  return {
1712
1727
  name: `${e.blockVars.facadeName}.workflow`,
1713
1728
  private: !0,
@@ -1719,7 +1734,7 @@ function hr(e) {
1719
1734
  },
1720
1735
  dependencies: {
1721
1736
  "@platforma-sdk/workflow-tengo": "sdk:",
1722
- ...un(e, "software")
1737
+ ...yn(e, "software")
1723
1738
  },
1724
1739
  devDependencies: {
1725
1740
  "@platforma-sdk/tengo-builder": "sdk:",
@@ -1728,31 +1743,31 @@ function hr(e) {
1728
1743
  }
1729
1744
  };
1730
1745
  }
1731
- function gr() {
1732
- L("private", !0), L("type", "module"), z("build", "shx rm -rf dist && pl-tengo build"), z("check", "pl-tengo check"), z("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1733
- z("test", "vitest run --passWithNoTests"), G({ vitest: "catalog:" });
1734
- }, () => W("vitest"))), H("@platforma-sdk/workflow-tengo", "sdk:"), Ct("software"), G({
1746
+ function Er() {
1747
+ R("private", !0), R("type", "module"), B("build", "shx rm -rf dist && pl-tengo build"), B("check", "pl-tengo check"), B("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
1748
+ B("test", "vitest run --passWithNoTests"), G({ vitest: "catalog:" });
1749
+ }, () => W("vitest"))), H("@platforma-sdk/workflow-tengo", "sdk:"), jt("software"), G({
1735
1750
  "@platforma-sdk/tengo-builder": "sdk:",
1736
1751
  "@platforma-sdk/test": "sdk:",
1737
1752
  shx: "catalog:"
1738
- }), Ln(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1753
+ }), qn(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1739
1754
  }
1740
1755
  //#endregion
1741
1756
  //#region src/structure/rules/workflow.ts
1742
- function _r() {
1743
- b("workflow", () => {
1744
- C("format.el", O("workflow/format.el")), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1745
- C("tsconfig.json", O("workflow/tsconfig.json")), T("vitest.config.mts", O("workflow/vitest.config.mts"));
1757
+ function Dr() {
1758
+ S("workflow", () => {
1759
+ T("format.el", A("workflow/format.el")), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
1760
+ T("tsconfig.json", A("workflow/tsconfig.json")), D("vitest.config.mts", A("workflow/vitest.config.mts"));
1746
1761
  }, () => {
1747
- D("tsconfig.json"), D("vitest.config.mts");
1748
- })), D("index.js"), D("index.d.ts"), E("src/main.tpl.tengo", k("workflow/src/main.tpl.tengo", (e) => ({ shortName: e.blockVars.shortName }))), w("package.json", A((e) => hr(e)), () => {
1749
- gr();
1762
+ k("tsconfig.json"), k("vitest.config.mts");
1763
+ })), k("index.js"), k("index.d.ts"), O("src/main.tpl.tengo", j("workflow/src/main.tpl.tengo", (e) => ({ shortName: e.blockVars.shortName }))), E("package.json", M((e) => Tr(e)), () => {
1764
+ Er();
1750
1765
  });
1751
1766
  });
1752
1767
  }
1753
1768
  //#endregion
1754
1769
  //#region src/structure/rules/test-package-json.ts
1755
- function vr(e) {
1770
+ function Or(e) {
1756
1771
  return {
1757
1772
  name: `${e.blockVars.facadeName}.test`,
1758
1773
  private: !0,
@@ -1771,26 +1786,27 @@ function vr(e) {
1771
1786
  }
1772
1787
  };
1773
1788
  }
1774
- function yr() {
1775
- L("private", !0), L("type", "module"), z("fmt", "ts-builder format"), z("check", "ts-builder check --target block-test"), z("test", "vitest run --passWithNoTests"), B("lint"), G({
1789
+ function kr() {
1790
+ R("private", !0), R("type", "module"), B("fmt", "ts-builder format"), B("check", "ts-builder check --target block-test"), B("test", "vitest run --passWithNoTests"), V("lint"), G({
1776
1791
  "@platforma-sdk/test": "sdk:",
1777
1792
  "@milaboratories/ts-builder": "sdk:",
1778
1793
  "@milaboratories/ts-configs": "sdk:",
1779
1794
  vitest: "catalog:"
1780
- }), xt({ typescript: "*" }), W("@types/node"), Ln(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1795
+ }), kt({ typescript: "*" }), W("@types/node"), qn(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1781
1796
  }
1782
1797
  //#endregion
1783
1798
  //#region src/structure/rules/test.ts
1784
- function br() {
1785
- b("test", () => {
1786
- C("tsconfig.json", O("test/tsconfig.json")), C(".oxlintrc.json", O("test/.oxlintrc.json")), C(".oxfmtrc.json", O("test/.oxfmtrc.json")), T("vitest.config.mts", O("test/vitest.config.mts")), E("src/demo.test.ts", Ge("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), w("package.json", A((e) => vr(e)), () => {
1787
- yr();
1799
+ function Ar() {
1800
+ S("test", () => {
1801
+ T("tsconfig.json", A("test/tsconfig.json")), T(".oxlintrc.json", A("test/.oxlintrc.json")), T(".oxfmtrc.json", A("test/.oxfmtrc.json")), D("vitest.config.mts", A("test/vitest.config.mts")), O("src/demo.test.ts", Ze("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), E("package.json", M((e) => Or(e)), () => {
1802
+ kr();
1788
1803
  });
1789
1804
  });
1790
1805
  }
1791
1806
  //#endregion
1792
1807
  //#region src/structure/rules/software-package-json.ts
1793
- function xr() {
1808
+ var jr = "block-tools software build", Mr = "shx rm -f *.tgz && block-tools software build && pnpm pack && shx mv platforma-open*.tgz package.tgz";
1809
+ function Nr() {
1794
1810
  return { entrypoints: { main: { binary: {
1795
1811
  artifact: {
1796
1812
  type: "python",
@@ -1805,68 +1821,65 @@ function xr() {
1805
1821
  cmd: ["python", "{pkg}/main.py"]
1806
1822
  } } } };
1807
1823
  }
1808
- function Sr(e) {
1824
+ function Pr(e) {
1809
1825
  return {
1810
1826
  name: `${e.blockVars.facadeName}.software`,
1811
1827
  type: "module",
1812
1828
  description: "Block Software",
1813
1829
  files: ["./dist/**/*"],
1814
1830
  scripts: {
1815
- build: "pl-pkg build",
1816
- prepublishOnly: "pl-pkg prepublish",
1831
+ build: jr,
1832
+ "do-pack": Mr,
1817
1833
  changeset: "changeset",
1818
1834
  "version-packages": "changeset version"
1819
1835
  },
1820
- "block-software": xr(),
1836
+ "block-software": Nr(),
1821
1837
  devDependencies: {
1822
1838
  "@platforma-open/milaboratories.runenv-python-3": "catalog:",
1823
- "@platforma-sdk/package-builder": "sdk:"
1839
+ "@platforma-sdk/block-tools": "sdk:"
1824
1840
  }
1825
1841
  };
1826
1842
  }
1827
- function Cr() {
1828
- R("private"), L("type", "module"), L("files", ["./dist/**/*"]), z("build", "pl-pkg build"), z("prepublishOnly", "pl-pkg prepublish"), z("changeset", "changeset"), z("version-packages", "changeset version"), G({
1829
- "@platforma-open/milaboratories.runenv-python-3": "catalog:",
1830
- "@platforma-sdk/package-builder": "sdk:"
1831
- }), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1843
+ function Fr() {
1844
+ z("private"), R("type", "module"), R("files", ["./dist/**/*"]), B("build", jr), B("do-pack", Mr), V("prepublishOnly"), B("changeset", "changeset"), B("version-packages", "changeset version"), U("@platforma-open/milaboratories.runenv-python-3", "catalog:"), U("@platforma-sdk/block-tools", "sdk:"), W("@platforma-sdk/package-builder"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1832
1845
  }
1833
1846
  //#endregion
1834
1847
  //#region src/structure/rules/software.ts
1835
- var wr = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Tr = "# No dependencies specified for this script\n";
1836
- function Er() {
1837
- b("software", () => {
1838
- E("src/main.py", Ge(wr)), E("src/requirements.txt", Ge(Tr)), w("package.json", A((e) => Sr(e)), () => {
1839
- Cr();
1848
+ var Ir = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Lr = "# No dependencies specified for this script\n";
1849
+ function Rr() {
1850
+ S("software", () => {
1851
+ O("src/main.py", Ze(Ir)), O("src/requirements.txt", Ze(Lr)), E("package.json", M((e) => Pr(e)), () => {
1852
+ Fr();
1840
1853
  });
1841
1854
  });
1842
1855
  }
1843
- function Dr() {
1844
- b("model", () => {
1845
- D("eslint.config.mjs"), D("vite.config.mts");
1846
- }), b("ui", () => {
1847
- D("eslint.config.mjs"), D("vite.config.ts"), D("tsconfig.app.json"), D("tsconfig.node.json");
1848
- }), b("test", () => {
1849
- D("eslint.config.mjs");
1850
- }), b("root", () => {
1851
- D(".prettierrc"), w("package.json", A((e) => xn(e)), () => {
1852
- B("pretty"), W("@platforma-sdk/blocks-deps-updater");
1856
+ function zr() {
1857
+ S("model", () => {
1858
+ k("eslint.config.mjs"), k("vite.config.mts");
1859
+ }), S("ui", () => {
1860
+ k("eslint.config.mjs"), k("vite.config.ts"), k("tsconfig.app.json"), k("tsconfig.node.json");
1861
+ }), S("test", () => {
1862
+ k("eslint.config.mjs");
1863
+ }), S("root", () => {
1864
+ k(".prettierrc"), E("package.json", M(() => jn()), () => {
1865
+ V("pretty"), W("@platforma-sdk/blocks-deps-updater");
1853
1866
  });
1854
1867
  });
1855
1868
  }
1856
1869
  //#endregion
1857
1870
  //#region src/structure/rules/root-catalog-bump.ts
1858
- function Or() {
1859
- Ue(() => {
1860
- b("root", () => {
1861
- x(({ ctx: e }) => !e.isSdkInternal, () => {
1862
- w("pnpm-workspace.yaml", A((e) => Un(e)), (e) => {
1863
- for (let e of Z) jt(e);
1864
- for (let e of Bn) Mt(e.entry, {
1871
+ function Br() {
1872
+ Ye(() => {
1873
+ S("root", () => {
1874
+ C(({ ctx: e }) => !e.isSdkInternal, () => {
1875
+ E("pnpm-workspace.yaml", M((e) => $n(e)), (e) => {
1876
+ for (let e of Z) zt(e);
1877
+ for (let e of Xn) Bt(e.entry, {
1865
1878
  of: e.of,
1866
1879
  ofVersion: e.ofVersion
1867
1880
  });
1868
- for (let [e, t] of Object.entries(zn)) At(e, t);
1869
- e.modules.some((e) => e.scope === "software") && At(Vn, Hn);
1881
+ for (let [e, t] of Object.entries(Yn)) Rt(e, t);
1882
+ e.modules.some((e) => e.scope === "software") && Rt(Zn, Qn);
1870
1883
  });
1871
1884
  });
1872
1885
  });
@@ -1874,25 +1887,25 @@ function Or() {
1874
1887
  }
1875
1888
  //#endregion
1876
1889
  //#region src/structure/structure-definition.ts
1877
- var kr = Ie(() => {
1878
- qn(), Yn(), cr(), dr(), mr(), _r(), br(), Er(), Dr(), Or();
1890
+ var Vr = He(() => {
1891
+ rr(), ar(), vr(), xr(), wr(), Dr(), Ar(), Rr(), zr(), Br();
1879
1892
  });
1880
1893
  //#endregion
1881
1894
  //#region src/structure/cli/run-structure.ts
1882
- async function Ar() {
1883
- return Nn(Z.filter(Mn));
1895
+ async function Hr() {
1896
+ return Un(Z.filter(Hn));
1884
1897
  }
1885
- async function jr(e) {
1886
- let t = m.resolve(e.blockPath), n = e.mode === "check", r = new xe(t), i = new Se(e.templatesRoot), a = en(kr, r, bn({
1898
+ async function Ur(e) {
1899
+ let t = h.resolve(e.blockPath), n = e.mode === "check", r = new Ee(t), i = new De(e.templatesRoot), a = un(Vr, r, On({
1887
1900
  fs: r,
1888
1901
  isSdkInternal: e.isSdkInternal,
1889
1902
  updateDepsOnly: e.updateDepsOnly,
1890
1903
  dryRun: n
1891
1904
  }), {
1892
1905
  templates: i,
1893
- registryLookup: e.updateDepsOnly ? await Ar() : void 0,
1894
- derivedPinLookup: e.updateDepsOnly ? await Fn(Bn) : void 0,
1895
- rediscover: () => bn({
1906
+ registryLookup: e.updateDepsOnly ? await Hr() : void 0,
1907
+ derivedPinLookup: e.updateDepsOnly ? await Gn(Xn) : void 0,
1908
+ rediscover: () => On({
1896
1909
  fs: r,
1897
1910
  isSdkInternal: e.isSdkInternal,
1898
1911
  updateDepsOnly: !1,
@@ -1904,16 +1917,16 @@ async function jr(e) {
1904
1917
  changes: a.changes
1905
1918
  };
1906
1919
  }
1907
- function Mr(e, t) {
1920
+ function Wr(e, t) {
1908
1921
  if (t.length === 0) return ` ${e}: up to date (0 changes)`;
1909
1922
  let n = t.map((e) => ` ${e.action.padEnd(6)} ${e.primitive.padEnd(8)} ${e.path} [${e.scope}]`);
1910
1923
  return ` ${e}: ${t.length} change(s)\n${n.join("\n")}`;
1911
1924
  }
1912
1925
  //#endregion
1913
1926
  //#region src/cmd/structure/refresh.ts
1914
- async function Nr(e) {
1927
+ async function Gr(e) {
1915
1928
  for (let t of e.paths) {
1916
- let n = await jr({
1929
+ let n = await Ur({
1917
1930
  blockPath: t,
1918
1931
  isSdkInternal: e.isSdkInternal,
1919
1932
  updateDepsOnly: e.updateDepsOnly,
@@ -1921,43 +1934,43 @@ async function Nr(e) {
1921
1934
  templatesRoot: e.templatesRoot,
1922
1935
  log: (t) => e.logger.info(t)
1923
1936
  });
1924
- e.logger.info(Mr(t, n.changes));
1937
+ e.logger.info(Wr(t, n.changes));
1925
1938
  }
1926
1939
  }
1927
- function Pr(e) {
1928
- let t = new f("refresh").description("Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).");
1940
+ function Kr(e) {
1941
+ let t = new p("refresh").description("Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).");
1929
1942
  return t.argument("[paths...]", "block path(s); defaults to the current directory"), t.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules"), t.option("--update-deps-only", "fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh."), t.action(async (t, n) => {
1930
- let r = t.length > 0 ? t : ["."], i = m.join(e, "src", "structure", "templates");
1931
- await Nr({
1943
+ let r = t.length > 0 ? t : ["."], i = h.join(e, "src", "structure", "templates");
1944
+ await Gr({
1932
1945
  paths: r,
1933
1946
  isSdkInternal: !!n.sdkInternal,
1934
1947
  updateDepsOnly: !!n.updateDepsOnly,
1935
1948
  templatesRoot: i,
1936
- logger: new g()
1949
+ logger: new _()
1937
1950
  });
1938
1951
  }), t;
1939
1952
  }
1940
1953
  //#endregion
1941
1954
  //#region src/cmd/update-deps.ts
1942
- function Fr(e) {
1943
- let t = new f("update-deps").description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");
1955
+ function qr(e) {
1956
+ let t = new p("update-deps").description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");
1944
1957
  return t.action(async () => {
1945
- let t = new g();
1946
- t.warn("`block-tools update-deps` is deprecated and will be removed in a future release. Use `block-tools structure refresh --update-deps-only` instead. Delegating now."), await Nr({
1958
+ let t = new _();
1959
+ t.warn("`block-tools update-deps` is deprecated and will be removed in a future release. Use `block-tools structure refresh --update-deps-only` instead. Delegating now."), await Gr({
1947
1960
  paths: ["."],
1948
1961
  isSdkInternal: !1,
1949
1962
  updateDepsOnly: !0,
1950
- templatesRoot: m.join(e, "src", "structure", "templates"),
1963
+ templatesRoot: h.join(e, "src", "structure", "templates"),
1951
1964
  logger: t
1952
1965
  });
1953
1966
  }), t;
1954
1967
  }
1955
1968
  //#endregion
1956
1969
  //#region src/cmd/list-overview-snapshots.ts
1957
- function Ir() {
1958
- let e = new f("list-overview-snapshots").description("List all available global overview snapshots in the registry");
1959
- return e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.option("--json", "output in JSON format", !1), e.action(async (e) => {
1960
- let t = new g(), n = await new s(o(e.registry), t).listGlobalOverviewSnapshots();
1970
+ function Jr() {
1971
+ let e = new p("list-overview-snapshots").description("List all available global overview snapshots in the registry");
1972
+ return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.option("--json", "output in JSON format", !1), e.action(async (e) => {
1973
+ let t = new _(), n = await new s(o(e.registry), t).listGlobalOverviewSnapshots();
1961
1974
  if (e.json) t.info(JSON.stringify(n, null, 2));
1962
1975
  else if (n.length === 0) t.info("No snapshots found.");
1963
1976
  else {
@@ -1968,10 +1981,10 @@ function Ir() {
1968
1981
  }
1969
1982
  //#endregion
1970
1983
  //#region src/cmd/restore-overview-from-snapshot.ts
1971
- function Lr() {
1972
- let e = new f("restore-overview-from-snapshot").description("Restore global overview from a snapshot");
1973
- return e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.requiredOption("-s, --snapshot <timestamp>", "snapshot timestamp ID to restore from"), e.option("--skip-confirmation", "skip confirmation prompt (use with caution)", !1), e.action(async (e) => {
1974
- let t = new g(), n = new s(o(e.registry), t), r = await n.listGlobalOverviewSnapshots();
1984
+ function Yr() {
1985
+ let e = new p("restore-overview-from-snapshot").description("Restore global overview from a snapshot");
1986
+ return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.requiredOption("-s, --snapshot <timestamp>", "snapshot timestamp ID to restore from"), e.option("--skip-confirmation", "skip confirmation prompt (use with caution)", !1), e.action(async (e) => {
1987
+ let t = new _(), n = new s(o(e.registry), t), r = await n.listGlobalOverviewSnapshots();
1975
1988
  if (!r.find((t) => t.timestamp === e.snapshot)) throw Error(`Snapshot '${e.snapshot}' not found. Available snapshots:\n${r.map((e) => ` - ${e.timestamp}`).join("\n") || " (none)"}`);
1976
1989
  if (!e.skipConfirmation) {
1977
1990
  let n = (await import("node:readline")).createInterface({
@@ -1994,7 +2007,7 @@ function Lr() {
1994
2007
  }
1995
2008
  //#endregion
1996
2009
  //#region src/registry_v1/flags.ts
1997
- function Rr(e) {
2010
+ function Xr(e) {
1998
2011
  let t = e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
1999
2012
  if (t) {
2000
2013
  let { src: e, destName: n } = t.groups;
@@ -2004,33 +2017,33 @@ function Rr(e) {
2004
2017
  };
2005
2018
  } else return {
2006
2019
  src: e,
2007
- destName: m.basename(e)
2020
+ destName: h.basename(e)
2008
2021
  };
2009
2022
  }
2010
- function zr(e, t) {
2011
- return new p(e, t).argParser((e, t) => [...t ?? [], Rr(e)]).default([]);
2023
+ function Zr(e, t) {
2024
+ return new m(e, t).argParser((e, t) => [...t ?? [], Xr(e)]).default([]);
2012
2025
  }
2013
2026
  //#endregion
2014
2027
  //#region src/cmd/upload-package-v1.ts
2015
- var Br = [
2028
+ var Qr = [
2016
2029
  "registry",
2017
2030
  "organization",
2018
2031
  "package",
2019
2032
  "version"
2020
2033
  ];
2021
- function Vr() {
2022
- let e = new f("upload-package-v1").description("Uploads V1 package and refreshes the registry");
2023
- return e.addOption(new p("-r, --registry <address|alias>", "full address of the registry or alias from .pl.reg").env("PL_REGISTRY")), e.addOption(new p("-o, --organization <organization>", "target organisation").env("PL_PACKAGE_ORGANIZATION")), e.addOption(new p("-p, --package <package>", "target package").env("PL_PACKAGE_NAME")), e.addOption(new p("-v, --version <version>", "target version").env("PL_PACKAGE_VERSION")), e.option("-m, --meta <path>", "json file containing meta information to associate with tha package"), e.addOption(zr("-f, --file <file>", "package files")), e.addOption(new p("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.action(async (e) => {
2024
- let t = new g(), n = l.parse({});
2025
- for (let t of Br) e[t] && (n[t] = e[t]);
2026
- e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await h.promises.readFile(e.meta, { encoding: "utf-8" })) : e.meta.endsWith(".yaml") && (n.meta = ae.parse(await h.promises.readFile(e.meta, { encoding: "utf-8" }))));
2034
+ function $r() {
2035
+ let e = new p("upload-package-v1").description("Uploads V1 package and refreshes the registry");
2036
+ return e.addOption(new m("-r, --registry <address|alias>", "full address of the registry or alias from .pl.reg").env("PL_REGISTRY")), e.addOption(new m("-o, --organization <organization>", "target organisation").env("PL_PACKAGE_ORGANIZATION")), e.addOption(new m("-p, --package <package>", "target package").env("PL_PACKAGE_NAME")), e.addOption(new m("-v, --version <version>", "target version").env("PL_PACKAGE_VERSION")), e.option("-m, --meta <path>", "json file containing meta information to associate with tha package"), e.addOption(Zr("-f, --file <file>", "package files")), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.action(async (e) => {
2037
+ let t = new _(), n = l.parse({});
2038
+ for (let t of Qr) e[t] && (n[t] = e[t]);
2039
+ e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await g.promises.readFile(e.meta, { encoding: "utf-8" })) : e.meta.endsWith(".yaml") && (n.meta = ie.parse(await g.promises.readFile(e.meta, { encoding: "utf-8" }))));
2027
2040
  for (let t of e.file) n.files[t.destName] = t.src;
2028
2041
  let r = await c(n);
2029
- t.info(ae.stringify(r.conf));
2042
+ t.info(ie.stringify(r.conf));
2030
2043
  let i = r.createRegistry(t), a = r.fullPackageName, o = i.constructNewPackage(a);
2031
2044
  for (let [e, n] of Object.entries(r.conf.files)) {
2032
2045
  t.info(`Uploading ${n} -> ${e} ...`);
2033
- let r = await h.promises.readFile(n);
2046
+ let r = await g.promises.readFile(n);
2034
2047
  await o.addFile(e, r);
2035
2048
  }
2036
2049
  t.info("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), e.refresh && await i.updateIfNeeded();
@@ -2038,12 +2051,12 @@ function Vr() {
2038
2051
  }
2039
2052
  //#endregion
2040
2053
  //#region src/cmd/structure/check.ts
2041
- function Hr(e) {
2042
- let t = new f("check").description("Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.");
2054
+ function ei(e) {
2055
+ let t = new p("check").description("Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.");
2043
2056
  return t.argument("[paths...]", "block path(s); defaults to the current directory"), t.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules"), t.action(async (t, n) => {
2044
- let r = new g(), i = t.length > 0 ? t : ["."], a = m.join(e, "src", "structure", "templates"), o = !1;
2057
+ let r = new _(), i = t.length > 0 ? t : ["."], a = h.join(e, "src", "structure", "templates"), o = !1;
2045
2058
  for (let e of i) {
2046
- let t = await jr({
2059
+ let t = await Ur({
2047
2060
  blockPath: e,
2048
2061
  isSdkInternal: !!n.sdkInternal,
2049
2062
  updateDepsOnly: !1,
@@ -2051,35 +2064,35 @@ function Hr(e) {
2051
2064
  templatesRoot: a,
2052
2065
  log: (e) => r.info(e)
2053
2066
  });
2054
- r.info(Mr(e, t.changes)), t.changes.length > 0 && (o = !0);
2067
+ r.info(Wr(e, t.changes)), t.changes.length > 0 && (o = !0);
2055
2068
  }
2056
2069
  if (o) throw Error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.");
2057
2070
  }), t;
2058
2071
  }
2059
2072
  //#endregion
2060
2073
  //#region src/structure/init-block-constructor.ts
2061
- var $ = ["python"], Ur = class extends Error {
2074
+ var $ = ["python"], ti = class extends Error {
2062
2075
  constructor(e) {
2063
2076
  super(`Missing required flag --${e} in --non-interactive mode. Supply every BlockVars flag, or drop --non-interactive to be prompted.`), this.name = "InitFlagError";
2064
2077
  }
2065
2078
  };
2066
- async function Wr(e, t, n, r) {
2079
+ async function ni(e, t, n, r) {
2067
2080
  if (e !== void 0 && e !== "") return e;
2068
- if (n) throw new Ur(t);
2081
+ if (n) throw new ti(t);
2069
2082
  return r();
2070
2083
  }
2071
- async function Gr(e) {
2072
- let t = await Wr(e.npmOrg, "npm-org", e.nonInteractive, () => de({
2084
+ async function ri(e) {
2085
+ let t = await ni(e.npmOrg, "npm-org", e.nonInteractive, () => de({
2073
2086
  message: "npm org (e.g. @platforma-open):",
2074
2087
  default: "@platforma-open"
2075
- })), n = await Wr(e.orgScope, "org-scope", e.nonInteractive, () => de({ message: "org scope (e.g. my-org):" })), r = await Wr(e.shortName, "short-name", e.nonInteractive, () => de({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
2088
+ })), n = await ni(e.orgScope, "org-scope", e.nonInteractive, () => de({ message: "org scope (e.g. my-org):" })), r = await ni(e.shortName, "short-name", e.nonInteractive, () => de({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
2076
2089
  i = e.withSoftware === void 0 ? e.nonInteractive ? !1 : await ue({
2077
2090
  message: "Include a software module?",
2078
2091
  default: !1
2079
2092
  }) : e.withSoftware;
2080
2093
  let a;
2081
2094
  if (i) {
2082
- if (a = await Wr(e.platform, "platform", e.nonInteractive, () => fe({
2095
+ if (a = await ni(e.platform, "platform", e.nonInteractive, () => fe({
2083
2096
  message: "Software platform:",
2084
2097
  choices: $.map((e) => ({
2085
2098
  name: e,
@@ -2096,20 +2109,20 @@ async function Gr(e) {
2096
2109
  softwarePlatform: a
2097
2110
  };
2098
2111
  }
2099
- async function Kr(e) {
2100
- let t = e.vars, n = dn(t), r = new xe(e.blockPath), i = new Se(e.templatesRoot), a = fn({
2112
+ async function ii(e) {
2113
+ let t = e.vars, n = bn(t), r = new Ee(e.blockPath), i = new De(e.templatesRoot), a = xn({
2101
2114
  blockVars: t,
2102
2115
  modules: n,
2103
2116
  isSdkInternal: !1,
2104
- version: 1,
2117
+ version: 2,
2105
2118
  dryRun: !1
2106
- }), o = Z.filter(Mn), s, c;
2119
+ }), o = Z.filter(Hn), s, c;
2107
2120
  try {
2108
- s = await Nn(o), c = await Fn(Bn);
2121
+ s = await Un(o), c = await Gn(Xn);
2109
2122
  } catch (e) {
2110
2123
  throw Error(`init requires network access to resolve SDK catalog versions from npm, but the registry lookup failed: ${e instanceof Error ? e.message : String(e)}`);
2111
2124
  }
2112
- return en(kr, r, a, {
2125
+ return un(Vr, r, a, {
2113
2126
  templates: i,
2114
2127
  initMode: !0,
2115
2128
  registryLookup: s,
@@ -2118,12 +2131,12 @@ async function Kr(e) {
2118
2131
  }
2119
2132
  //#endregion
2120
2133
  //#region src/cmd/structure/init.ts
2121
- function qr(e) {
2122
- let t = new f("init").description("Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.");
2123
- return t.argument("[path]", "target directory (default: <short-name> under the current directory)"), t.option("--npm-org <org>", "npm org, e.g. @platforma-open"), t.option("--org-scope <scope>", "org scope, e.g. my-org"), t.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping"), t.option("--with-software", "include a software module"), t.option("--no-software", "omit the software module"), t.addOption(new p("--platform <platform>", "software platform (single-valued)").choices([...$])), t.option("--non-interactive", "error on any missing flag instead of prompting"), t.action(async (t, n) => {
2124
- let r = new g(), i = n.withSoftware === !0, a = n.software === !1;
2134
+ function ai(e) {
2135
+ let t = new p("init").description("Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.");
2136
+ return t.argument("[path]", "target directory (default: <short-name> under the current directory)"), t.option("--npm-org <org>", "npm org, e.g. @platforma-open"), t.option("--org-scope <scope>", "org scope, e.g. my-org"), t.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping"), t.option("--with-software", "include a software module"), t.option("--no-software", "omit the software module"), t.addOption(new m("--platform <platform>", "software platform (single-valued)").choices([...$])), t.option("--non-interactive", "error on any missing flag instead of prompting"), t.action(async (t, n) => {
2137
+ let r = new _(), i = n.withSoftware === !0, a = n.software === !1;
2125
2138
  if (i && a) throw Error("--with-software and --no-software are mutually exclusive.");
2126
- let o = i ? !0 : a ? !1 : void 0, s = await Gr({
2139
+ let o = i ? !0 : a ? !1 : void 0, s = await ri({
2127
2140
  npmOrg: n.npmOrg,
2128
2141
  orgScope: n.orgScope,
2129
2142
  shortName: n.shortName,
@@ -2131,26 +2144,233 @@ function qr(e) {
2131
2144
  platform: n.platform,
2132
2145
  nonInteractive: n.nonInteractive
2133
2146
  });
2134
- await Kr({
2147
+ await ii({
2135
2148
  vars: s,
2136
- blockPath: t ? m.resolve(t) : m.resolve(process.cwd(), s.shortName),
2137
- templatesRoot: m.join(e, "src", "structure", "templates"),
2149
+ blockPath: t ? h.resolve(t) : h.resolve(process.cwd(), s.shortName),
2150
+ templatesRoot: h.join(e, "src", "structure", "templates"),
2138
2151
  log: (e) => r.info(e)
2139
2152
  });
2140
2153
  }), t;
2141
2154
  }
2142
2155
  //#endregion
2156
+ //#region src/cmd/software/knobs.ts
2157
+ var oi = ["dev", "release"], si = [
2158
+ "docker",
2159
+ "binary",
2160
+ "all",
2161
+ "none"
2162
+ ], ci = ["local", "remote"];
2163
+ function li(e) {
2164
+ if (e.usePublished) {
2165
+ if (e.variant === "docker" || e.variant === "all") throw y.CLIError(`--use-published is binary-only and cannot be combined with --variant ${e.variant}`);
2166
+ return { kind: "binary-existing" };
2167
+ }
2168
+ return e.variant === "none" ? { kind: "no-software" } : e.location === void 0 ? { kind: "bare" } : {
2169
+ kind: "target",
2170
+ channel: e.channel ?? "release",
2171
+ variant: e.variant ?? "all",
2172
+ location: e.location
2173
+ };
2174
+ }
2175
+ //#endregion
2176
+ //#region src/cmd/software/ecr-login.ts
2177
+ var ui = "public.ecr.aws", di = "us-east-1";
2178
+ function fi(e) {
2179
+ if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE) return;
2180
+ let t = process.env.PL_AWS_PROFILE ?? me.AWS_DEV_PROFILE;
2181
+ process.env.AWS_PROFILE = t, e?.debug(`Using AWS profile '${t}' for dev push credentials`);
2182
+ }
2183
+ function pi(e) {
2184
+ return new URL(`https://${e}`).hostname;
2185
+ }
2186
+ function mi() {
2187
+ return ` aws sso login --profile ${process.env.AWS_PROFILE ?? process.env.PL_AWS_PROFILE ?? me.AWS_DEV_PROFILE}`;
2188
+ }
2189
+ async function hi(e, t) {
2190
+ let n = pi(e);
2191
+ if (n !== ui) throw y.CLIError(`automatic docker login is only supported for '${ui}', not '${n}'.\nLog in manually, or drop the ecr:// scheme from the push target to opt out.`);
2192
+ t?.info(`Logging in to ECR registry '${n}'...`);
2193
+ let r, i;
2194
+ try {
2195
+ let e = (await new ge({ region: di }).send(new _e({}))).authorizationData?.authorizationToken;
2196
+ if (!e) throw Error("empty authorization token");
2197
+ let t = Buffer.from(e, "base64").toString("utf8"), n = t.indexOf(":");
2198
+ if (n < 0) throw Error("malformed authorization token (no ':' separator)");
2199
+ r = t.slice(0, n), i = t.slice(n + 1);
2200
+ } catch (e) {
2201
+ throw y.CLIError(`failed to obtain an ECR login token for '${n}': ${e instanceof Error ? e.message : String(e)}\nYour AWS/SSO session is likely expired or absent — log in and retry:\n` + mi());
2202
+ }
2203
+ let a = he("docker", [
2204
+ "login",
2205
+ "--username",
2206
+ r,
2207
+ "--password-stdin",
2208
+ n
2209
+ ], {
2210
+ input: i,
2211
+ stdio: [
2212
+ "pipe",
2213
+ "inherit",
2214
+ "inherit"
2215
+ ],
2216
+ env: {
2217
+ ...process.env,
2218
+ HOME: process.env.HOME || le.homedir()
2219
+ }
2220
+ });
2221
+ if (a.error || a.status !== 0) throw y.CLIError(`'docker login ${n}' failed`);
2222
+ }
2223
+ //#endregion
2224
+ //#region src/cmd/software/run-build.ts
2225
+ async function gi(e) {
2226
+ let { core: t, scenario: n, options: r = {}, logger: i } = e, a = r.ids;
2227
+ t.buildMode = _i(n);
2228
+ let o = () => t.buildSoftwareArchives({
2229
+ ids: a,
2230
+ forceBuild: !!r.force,
2231
+ contentRoot: r.contentRoot,
2232
+ skipIfEmpty: !a,
2233
+ condaBuild: r.condaBuild
2234
+ });
2235
+ switch (n.kind) {
2236
+ case "binary-existing":
2237
+ t.writePublishedArtifactInfo({ ids: a });
2238
+ break;
2239
+ case "no-software": break;
2240
+ case "bare":
2241
+ r.buildDocker && t.buildDockerImages({
2242
+ ids: a,
2243
+ registry: r.dockerRegistry,
2244
+ strictPlatformMatching: v.isCI()
2245
+ }), await o(), r.pushDocker && t.publishDockerImages({
2246
+ ids: a,
2247
+ pushTo: r.dockerPushTo,
2248
+ strictPlatformMatching: v.isCI()
2249
+ });
2250
+ break;
2251
+ case "target": {
2252
+ let { channel: e, variant: s, location: c } = n, l = s !== "binary", u = s !== "docker", d = c === "remote", f = bi(e, r);
2253
+ l && t.buildDockerImages({
2254
+ ids: a,
2255
+ registry: f.pull,
2256
+ strictPlatformMatching: v.isCI()
2257
+ }), u && await o(), d && e === "dev" && (l || u) && fi(i), l && d && (f.autoLogin && f.push && await hi(f.push, i), t.publishDockerImages({
2258
+ ids: a,
2259
+ pushTo: f.push,
2260
+ strictPlatformMatching: v.isCI()
2261
+ })), u && d && await t.publishPackages({
2262
+ ids: a,
2263
+ storageURL: r.storageUrl
2264
+ });
2265
+ break;
2266
+ }
2267
+ default: y.assertNever(n);
2268
+ }
2269
+ t.buildSwJsonFiles({
2270
+ packageIds: a,
2271
+ noSoftware: n.kind === "no-software"
2272
+ });
2273
+ }
2274
+ function _i(e) {
2275
+ return e.kind !== "target" || e.channel === "release" ? "release" : e.variant !== "docker" && e.location === "remote" ? "dev-remote" : "dev-local";
2276
+ }
2277
+ function vi(e) {
2278
+ if (!e.includes("://")) return e;
2279
+ let t = new URL(e);
2280
+ return t.host + t.pathname;
2281
+ }
2282
+ function yi(e) {
2283
+ return {
2284
+ registry: vi(e),
2285
+ autoLogin: e.startsWith("ecr://")
2286
+ };
2287
+ }
2288
+ function bi(e, t) {
2289
+ let n = e === "dev", r = process.env[n ? v.PL_DEV_DOCKER_PUSH_URL : v.PL_RELEASE_DOCKER_PUSH_URL], i = process.env[n ? v.PL_DEV_DOCKER_PULL_URL : v.PL_RELEASE_DOCKER_PULL_URL], a = t.dockerPushTo ?? r ?? (n ? me.DEV_DOCKER_PUSH_TARGET : void 0), o = a ? yi(a) : {
2290
+ registry: void 0,
2291
+ autoLogin: !1
2292
+ }, s = t.dockerRegistry ?? i ?? a;
2293
+ return {
2294
+ pull: s ? vi(s) : void 0,
2295
+ push: o.registry,
2296
+ autoLogin: o.autoLogin
2297
+ };
2298
+ }
2299
+ //#endregion
2300
+ //#region src/cmd/software/env.ts
2301
+ var xi = "PL_BUILD_CHANNEL", Si = "PL_BUILD_VARIANT", Ci = "PL_BUILD_LOCATION", wi = "PL_BUILD_USE_PUBLISHED";
2302
+ v.PL_DOCKER_REGISTRY_PUSH_TO, v.PL_DEV_DOCKER_PUSH_URL, v.PL_DEV_DOCKER_PULL_URL, v.PL_DEV_BINARY_UPLOAD_URL, v.PL_RELEASE_DOCKER_PUSH_URL, v.PL_RELEASE_DOCKER_PULL_URL, v.PL_RELEASE_BINARY_UPLOAD_URL;
2303
+ //#endregion
2304
+ //#region src/cmd/software/build.ts
2305
+ function Ti() {
2306
+ let e = new p("build").description("Build a software module for a target and write its .sw.json descriptor (build + push in one pass)");
2307
+ return e.addOption(new m("--channel <channel>", "registry channel to build for").choices([...oi]).env(xi)), e.addOption(new m("--variant <variant>", "artifact kind to build (default: all declared)").choices([...si]).env(Si)), e.addOption(new m("--location <location>", "where the artifact lands (local = no push)").choices([...ci]).env(Ci)), e.addOption(new m("--use-published", "do not build or push; emit a descriptor pointing at the already-published release artifact").env(wi)), e.addOption(new m("--log-level <level>", "logging level").choices([
2308
+ "error",
2309
+ "warn",
2310
+ "info",
2311
+ "debug"
2312
+ ]).default("info")), e.addOption(new m("--package-root <path>", "path to directory with package.json file")), e.addOption(new m("--force", "force action, ignoring automatic safety checks").default(!1)), e.addOption(new m("--version <value>", "override package version (ignore package.json)")), e.addOption(new m("--platform <os-arch>", "{os}-{arch} pair; no effect on cross-platform packages").choices([...y.AllPlatforms]).env(v.PL_PKG_OS)), e.addOption(new m("--all-platforms", "build for all supported platforms").default(!1)), e.addOption(new m("--full-dir-hash", "hash file contents (not metadata) for the dev content hash").env(v.PL_PKG_FULL_HASH).default(!1)), e.addOption(new m("--package-id <id...>", "act only on selected packages")), e.addOption(new m("--content-root <path>", "override software content root").env(v.PL_PKG_CONTENT_ROOT)), e.addOption(new m("--storage-url <url>", "override binary upload registry URL").env(v.PL_PKG_STORAGE_URL)), e.addOption(new m("--docker-registry <registry>", "docker pull registry embedded in the descriptor").env(v.PL_DOCKER_REGISTRY)), e.addOption(new m("--docker-push-to <registry>", "alternative registry for docker push").env(v.PL_DOCKER_REGISTRY_PUSH_TO)), e.addOption(new m("--docker-build", "build docker images").env(v.PL_DOCKER_BUILD).default(!1)), e.addOption(new m("--docker-no-build", "do not build docker images").env(v.PL_DOCKER_NO_BUILD).default(!1)), e.addOption(new m("--docker-autopush", "push docker images after build").env(v.PL_DOCKER_AUTOPUSH).default(!1)), e.addOption(new m("--docker-no-autopush", "do not push docker images").env(v.PL_DOCKER_NO_AUTOPUSH).default(!1)), e.addOption(new m("--conda-build", "build conda environment before packing").env(v.PL_CONDA_BUILD).default(!1)), e.addOption(new m("--conda-no-build", "do not build conda environment").env(v.PL_CONDA_NO_BUILD).default(!1)), e.action(async (e) => {
2313
+ let t = y.createLogger(e.logLevel);
2314
+ try {
2315
+ let n = li({
2316
+ channel: e.channel,
2317
+ variant: e.variant,
2318
+ location: e.location,
2319
+ usePublished: !!e.usePublished
2320
+ }), r = pe(t, { packageRoot: e.packageRoot });
2321
+ r.version = e.version, r.targetPlatform = e.platform, r.allPlatforms = !!e.allPlatforms, r.fullDirHash = !!e.fullDirHash;
2322
+ let i = y.shouldDoAction({
2323
+ default: v.isCI(),
2324
+ enable: e.dockerBuild,
2325
+ disable: e.dockerNoBuild
2326
+ }), a = i && y.shouldDoAction({
2327
+ default: v.isCI() && !r.isPrivate,
2328
+ enable: e.dockerAutopush,
2329
+ disable: e.dockerNoAutopush
2330
+ });
2331
+ await gi({
2332
+ core: r,
2333
+ scenario: n,
2334
+ logger: t,
2335
+ options: {
2336
+ ids: e.packageId,
2337
+ force: e.force,
2338
+ contentRoot: e.contentRoot,
2339
+ storageUrl: e.storageUrl,
2340
+ dockerRegistry: e.dockerRegistry,
2341
+ dockerPushTo: e.dockerPushTo,
2342
+ buildDocker: i,
2343
+ pushDocker: a,
2344
+ condaBuild: y.shouldDoAction({
2345
+ default: !0,
2346
+ enable: e.condaBuild,
2347
+ disable: e.condaNoBuild
2348
+ })
2349
+ }
2350
+ });
2351
+ } catch (e) {
2352
+ throw t.debug(e), e instanceof Error && t.debug(e.stack), e;
2353
+ }
2354
+ }), e;
2355
+ }
2356
+ //#endregion
2357
+ //#region src/cmd/software/index.ts
2358
+ function Ei() {
2359
+ let e = new p("software").description("Build and publish a block's software modules");
2360
+ return e.addCommand(Ti()), e;
2361
+ }
2362
+ //#endregion
2143
2363
  //#region src/cli.ts
2144
- function Jr(e = process.cwd()) {
2145
- let t = new f();
2146
- t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(pe()), t.addCommand(he()), t.addCommand(ge()), t.addCommand(ve()), t.addCommand(ye()), t.addCommand(be()), t.addCommand(Fr(e)), t.addCommand(Ir()), t.addCommand(Lr()), t.addCommand(Vr());
2147
- let n = new f("structure").description("Manage block scaffolding against the canonical structure (check / init / refresh)");
2148
- return n.addCommand(Hr(e)), n.addCommand(qr(e)), n.addCommand(Pr(e)), t.addCommand(n), t;
2364
+ function Di(e = process.cwd()) {
2365
+ let t = new p();
2366
+ t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(ve()), t.addCommand(be()), t.addCommand(xe()), t.addCommand(Ce()), t.addCommand(we()), t.addCommand(Te()), t.addCommand(qr(e)), t.addCommand(Jr()), t.addCommand(Yr()), t.addCommand($r()), t.addCommand(Ei());
2367
+ let n = new p("structure").description("Manage block scaffolding against the canonical structure (check / init / refresh)");
2368
+ return n.addCommand(ei(e)), n.addCommand(ai(e)), n.addCommand(Kr(e)), t.addCommand(n), t;
2149
2369
  }
2150
- async function Yr(e, t) {
2151
- await Jr(t).parseAsync(e);
2370
+ async function Oi(e, t) {
2371
+ await Di(t).parseAsync(e);
2152
2372
  }
2153
2373
  //#endregion
2154
- export { Jr as buildProgram, Yr as run };
2374
+ export { Di as buildProgram, Oi as run };
2155
2375
 
2156
2376
  //# sourceMappingURL=cli.mjs.map