@skillstech/thunderlang 0.5.11 → 0.5.12

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 (66) hide show
  1. package/CHANGELOG.md +437 -0
  2. package/dist/core.cjs +30431 -7604
  3. package/dist/index.cjs +28577 -5331
  4. package/dist/learn.cjs +22676 -3870
  5. package/package.json +12 -3
  6. package/src/bicep.mjs +167 -0
  7. package/src/cli.mjs +169 -3
  8. package/src/commands.mjs +464 -0
  9. package/src/core.d.ts +12 -4
  10. package/src/core.mjs +12 -4
  11. package/src/emit.mjs +1 -1
  12. package/src/executed.d.mts +53 -0
  13. package/src/executed.mjs +465 -0
  14. package/src/faithful.mjs +137 -0
  15. package/src/file-formats.mjs +35 -0
  16. package/src/hcl.mjs +94 -0
  17. package/src/index.d.ts +7 -1
  18. package/src/index.mjs +6 -1
  19. package/src/infra-bicep.mjs +312 -0
  20. package/src/infra-cloud.mjs +348 -0
  21. package/src/infra-compose.mjs +315 -0
  22. package/src/infra-containers.mjs +100 -0
  23. package/src/infra-docker.mjs +267 -0
  24. package/src/infra-expr.mjs +509 -0
  25. package/src/infra-gha.mjs +350 -0
  26. package/src/infra-k8s.mjs +657 -0
  27. package/src/infra-terraform.mjs +499 -0
  28. package/src/infra-words.mjs +811 -0
  29. package/src/libraries.mjs +202 -0
  30. package/src/lift.mjs +48 -6
  31. package/src/meaning.d.mts +89 -0
  32. package/src/meaning.mjs +2544 -0
  33. package/src/model.d.mts +59 -12
  34. package/src/model.mjs +462 -80
  35. package/src/powershell.mjs +1361 -0
  36. package/src/read-repo-fs.mjs +29 -7
  37. package/src/read-repo.d.mts +5 -1
  38. package/src/read-repo.mjs +33 -7
  39. package/src/read.d.mts +21 -1
  40. package/src/read.mjs +1015 -42
  41. package/src/review.d.mts +35 -0
  42. package/src/review.mjs +671 -0
  43. package/src/rlang.mjs +1084 -0
  44. package/src/round-trip.d.mts +12 -0
  45. package/src/round-trip.mjs +174 -0
  46. package/src/runners/thunder-generate.mjs +56 -0
  47. package/src/runners/thunder-trace.cjs +284 -0
  48. package/src/runners/thunder_trace.py +599 -0
  49. package/src/running.d.mts +104 -0
  50. package/src/running.mjs +787 -0
  51. package/src/same.d.mts +1 -0
  52. package/src/same.mjs +24 -3
  53. package/src/shell.mjs +1212 -0
  54. package/src/sql.mjs +3 -2
  55. package/src/steps.d.mts +6 -1
  56. package/src/steps.mjs +1448 -86
  57. package/src/system.d.mts +12 -0
  58. package/src/system.mjs +845 -0
  59. package/src/things-langs.mjs +275 -0
  60. package/src/thunderize.mjs +3 -3
  61. package/src/visual.d.mts +5 -5
  62. package/src/visual.mjs +24 -3
  63. package/src/write-steps.d.mts +64 -0
  64. package/src/write-steps.mjs +1608 -0
  65. package/src/write.mjs +2 -1
  66. package/src/yaml.mjs +403 -0
@@ -0,0 +1,267 @@
1
+ // Dockerfiles in Thunder: how an app is packaged and started. Each build stage is one Steps card ("Image build" for
2
+ // a single stage, or the stage's own name), its instructions read in words: "Starts from node:22-slim", "Copies
3
+ // package.json into the image", "Installs what it needs (npm ci)", "Opens port 3000", "Starts with npm start". The
4
+ // image it makes is a Resource that knows what it starts from, its ports, its user, how it starts, and its settings
5
+ // (a value only when the file writes it, never a secret's). Deterministic, browser-safe, line by line.
6
+ import { shellSteps, commandSays, listWords, lc, cap, SECRET_NAME } from './infra-words.mjs';
7
+
8
+ const BUILT = 'worked out when it is built';
9
+ const hasVar = (s) => /\$\{?[A-Za-z_]/.test(String(s));
10
+ const words = (s) => String(s).replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ').toLowerCase().trim();
11
+
12
+ /** Instructions with their lines: continuation lines joined, comments skipped, heredocs kept with their body. */
13
+ export function dockerInstructions(src) {
14
+ const lines = String(src ?? '').replace(/^/, '').split('\n').map((l) => l.replace(/\r$/, ''));
15
+ let escape = '\\';
16
+ // Parser directives (`# escape=\``) are only read at the very top.
17
+ for (const l of lines) { const m = /^#\s*([a-z]+)\s*=\s*(\S+)\s*$/i.exec(l); if (!m) break; if (m[1].toLowerCase() === 'escape') escape = m[2]; }
18
+ const out = [];
19
+ let comments = [];
20
+ for (let i = 0; i < lines.length; i++) {
21
+ const t = lines[i].trim();
22
+ if (!t) { comments = []; continue; }
23
+ if (t.startsWith('#')) { comments.push(t.replace(/^#+\s?/, '')); continue; }
24
+ const line = i + 1;
25
+ let text = '';
26
+ let cur = lines[i];
27
+ // Join lines that end with the escape character; comment and blank lines inside are skipped.
28
+ while (true) {
29
+ const tr = cur.replace(/\s+$/, '');
30
+ if (tr.endsWith(escape) && i + 1 < lines.length) {
31
+ text += `${tr.slice(0, -1)} `;
32
+ i++;
33
+ while (i < lines.length && (/^\s*#/.test(lines[i]) || !lines[i].trim()) && i + 1 < lines.length) i++;
34
+ cur = lines[i];
35
+ continue;
36
+ }
37
+ text += tr;
38
+ break;
39
+ }
40
+ const m = /^\s*([A-Za-z]+)\s*(.*)$/.exec(text);
41
+ if (!m) continue;
42
+ const ins = { op: m[1].toUpperCase(), args: m[2].trim(), line, endLine: i + 1, ...(comments.length ? { doc: comments.join(' ') } : {}) };
43
+ comments = [];
44
+ // Heredocs: RUN <<EOF … EOF, COPY <<EOF /path … EOF.
45
+ const hd = /<<-?\s*["']?([A-Za-z_]\w*)["']?/.exec(ins.args);
46
+ if (hd && (ins.op === 'RUN' || ins.op === 'COPY' || ins.op === 'ADD')) {
47
+ const body = [];
48
+ const bodyLine = i + 2;
49
+ while (++i < lines.length && lines[i].trim() !== hd[1]) body.push(lines[i]);
50
+ ins.heredoc = { word: hd[1], body: body.join('\n'), line: bodyLine };
51
+ ins.endLine = i + 1;
52
+ }
53
+ out.push(ins);
54
+ }
55
+ return out;
56
+ }
57
+
58
+ /** `["npm", "start"]` -> 'npm start'; shell form stays as written. */
59
+ function execForm(args) {
60
+ const a = String(args).trim();
61
+ if (!a.startsWith('[')) return { text: a, exec: false };
62
+ try { const arr = JSON.parse(a); if (Array.isArray(arr)) return { text: arr.map((x) => (/\s/.test(x) ? `"${x}"` : x)).join(' '), exec: true, parts: arr }; } catch { /* not JSON: shell form */ }
63
+ return { text: a, exec: false };
64
+ }
65
+
66
+ /** Flags at the start of an instruction (`--from=build --chown=app`), and the rest. */
67
+ function flags(args) {
68
+ const f = {};
69
+ let rest = String(args).trim();
70
+ let m;
71
+ while ((m = /^--([\w-]+)(?:=(\S*))?\s*/.exec(rest))) { f[m[1]] = m[2] ?? true; rest = rest.slice(m[0].length); }
72
+ return { f, rest };
73
+ }
74
+
75
+ /** KEY=value pairs (or the old `KEY value` form), with quotes removed. */
76
+ function pairs(args) {
77
+ const a = String(args).trim();
78
+ if (!/^[\w.-]+=/.test(a)) { const m = /^(\S+)\s+(.*)$/.exec(a); return m ? [{ key: m[1], value: m[2].replace(/^["']|["']$/g, '') }] : a ? [{ key: a, value: null }] : []; }
79
+ const out = [];
80
+ let i = 0;
81
+ while (i < a.length) {
82
+ while (a[i] === ' ') i++;
83
+ let k = '';
84
+ while (i < a.length && a[i] !== '=' && a[i] !== ' ') k += a[i++];
85
+ if (!k) break;
86
+ if (a[i] !== '=') { out.push({ key: k, value: null }); continue; }
87
+ i++;
88
+ let v = '';
89
+ if (a[i] === '"' || a[i] === "'") { const q = a[i++]; while (i < a.length && a[i] !== q) { if (a[i] === '\\' && q === '"') i++; v += a[i++]; } i++; }
90
+ else while (i < a.length && a[i] !== ' ') { if (a[i] === '\\') i++; v += a[i++]; }
91
+ out.push({ key: k, value: v });
92
+ }
93
+ return out;
94
+ }
95
+
96
+ const imageWords = (image) => (image.toLowerCase() === 'scratch' ? 'nothing (an empty image)' : `${image}${hasVar(image) ? ` (${BUILT})` : ''}`);
97
+ const sourcesWords = (srcs) => (srcs.length === 1 && (srcs[0] === '.' || srcs[0] === './') ? 'the whole project folder' : listWords(srcs));
98
+ const destWords = (dest, srcs = []) => (!dest || dest === '.' || dest === './' || (srcs.length === 1 && dest.replace(/^\.\/|\/$/g, '') === srcs[0].replace(/^\.\/|\/$/g, '')) ? 'into the image' : `into ${dest}`);
99
+ const portWords = (ports) => `${ports.length === 1 ? 'port' : 'ports'} ${listWords(ports.map((p) => p.replace(/\/tcp$/i, '').replace(/^(\d+)\/udp$/i, '$1 (UDP)')))}`;
100
+ const userWords = (u) => (/^(root|0)(:.*)?$/.test(u) ? 'root, the user that can do anything' : `the user ${u}`);
101
+
102
+ /**
103
+ * Read a Dockerfile: stages as Steps items (kind 'function'), plus the Resource it makes, its settings, facts, and the
104
+ * links between stages. `file` names the image after its folder.
105
+ */
106
+ export function readDockerfile(src, file = 'Dockerfile') {
107
+ const all = dockerInstructions(src);
108
+ const stages = [];
109
+ const globalArgs = [];
110
+ for (const ins of all) {
111
+ if (ins.op === 'FROM') {
112
+ const { f, rest } = flags(ins.args);
113
+ const m = /^(\S+)(?:\s+AS\s+(\S+))?/i.exec(rest);
114
+ stages.push({ from: m?.[1] ?? rest, name: m?.[2] ?? null, platform: f.platform, line: ins.line, doc: ins.doc, ins: [] });
115
+ } else if (!stages.length) { if (ins.op === 'ARG') globalArgs.push(ins); }
116
+ else stages.at(-1).ins.push(ins);
117
+ }
118
+ const stageNames = new Map([...stages.map((s, i) => [String(i), i]), ...stages.filter((s) => s.name).map((s) => [s.name.toLowerCase(), stages.indexOf(s)])]);
119
+ const stageOf = (ref) => stageNames.get(String(ref).toLowerCase());
120
+ const single = stages.length === 1;
121
+ const itemName = (s, i) => (s.name ?? (single ? 'image build' : `stage ${i + 1}`));
122
+ const stageLabel = (s, i) => (single && !s.name ? 'Image build' : s.name ? `The ${words(s.name)} stage` : `Stage ${i + 1}`);
123
+ const items = [], settings = [], facts = [], links = [];
124
+ const fact = (kind, says, line) => facts.push({ id: `${file}#${kind}#${line}`, kind, says, file, line });
125
+ const setting = (name, source, line, secret = SECRET_NAME.test(name)) => { if (!settings.some((x) => x.name === name && x.source === source)) settings.push({ name, source, secret, file, line, ...(source === 'computed' ? { computed: true } : {}) }); };
126
+
127
+ for (const a of globalArgs) for (const p of pairs(a.args)) setting(p.key, 'parameter', a.line);
128
+
129
+ stages.forEach((s, i) => {
130
+ const steps = [];
131
+ const prev = stageOf(s.from);
132
+ if (prev != null && prev < i) {
133
+ steps.push({ kind: 'call', says: `Starts from the ${words(stages[prev].name ?? `stage ${prev + 1}`)} stage`, code: `FROM ${s.from}`, line: s.line });
134
+ links.push({ from: `${itemName(s, i)}:${s.line}`, to: `${itemName(stages[prev], prev)}:${stages[prev].line}`, kind: 'uses', file, line: s.line });
135
+ } else {
136
+ steps.push({ kind: 'call', says: `Starts from ${imageWords(s.from)}${s.platform ? ` for ${s.platform}` : ''}`, code: `FROM ${s.from}`, line: s.line });
137
+ if (!/^scratch$/i.test(s.from) && !/@sha256:/.test(s.from)) fact('image-not-pinned', `It starts from ${s.from} without a pinned digest (@sha256:…), so the image it starts from can change between builds.`, s.line);
138
+ }
139
+ const last = [];
140
+ let cmd = null, entry = null;
141
+ for (const ins of s.ins) {
142
+ const code = `${ins.op} ${ins.args}`.trim();
143
+ const step = (says, kind = 'call', extra = {}) => ({ kind, says, code, line: ins.line, ...extra });
144
+ const { f, rest } = flags(ins.args);
145
+ switch (ins.op) {
146
+ case 'WORKDIR': steps.push(step(`Works in ${rest}${hasVar(rest) ? ` (${BUILT})` : ''}`)); break;
147
+ case 'COPY': case 'ADD': {
148
+ if (ins.heredoc) { steps.push(step(`Writes the file ${rest.replace(/<<-?\s*["']?\w+["']?\s*/, '').trim() || 'shown here'} into the image`)); break; }
149
+ const ex = execForm(rest);
150
+ const parts = ex.exec ? ex.parts : rest.split(/\s+/).filter(Boolean);
151
+ const dest = parts.length > 1 ? parts.at(-1) : null;
152
+ const srcs = parts.length > 1 ? parts.slice(0, -1) : parts;
153
+ const from = f.from != null ? stageOf(f.from) : undefined;
154
+ const where = f.from == null ? '' : from != null ? ` from the ${words(stages[from].name ?? `stage ${from + 1}`)} stage` : ` from the image ${f.from}`;
155
+ if (from != null) links.push({ from: `${itemName(s, i)}:${s.line}`, to: `${itemName(stages[from], from)}:${stages[from].line}`, kind: 'uses', file, line: ins.line });
156
+ const remote = ins.op === 'ADD' && srcs.some((x) => /^(https?|git):\/\//.test(x) || /^git@/.test(x));
157
+ const unpack = ins.op === 'ADD' && srcs.some((x) => /\.(tar(\.\w+)?|tgz|tbz2|txz)$/i.test(x));
158
+ steps.push(step(remote ? `Downloads ${listWords(srcs)} ${destWords(dest)}` : `Copies ${sourcesWords(srcs)}${where} ${destWords(dest, f.from == null ? srcs : [])}${unpack ? ' (and unpacks it)' : ''}`));
159
+ break;
160
+ }
161
+ case 'RUN': {
162
+ const ex = execForm(rest);
163
+ if (ins.heredoc) { steps.push(...shellSteps(ins.heredoc.body, ins.heredoc.line)); break; }
164
+ const inner = shellSteps(ex.text, ins.line).map((st) => ({ ...st, code: st.code ?? code }));
165
+ if (f.mount && /type=secret/.test(String(f.mount))) { const id = /id=([\w-]+)/.exec(String(f.mount))?.[1]; if (id) setting(id, 'secret', ins.line, true); inner.forEach((st) => { st.says += id ? ` (uses the secret ${id})` : ' (uses a secret)'; }); }
166
+ steps.push(...inner);
167
+ break;
168
+ }
169
+ case 'ENV': for (const p of pairs(ins.args)) {
170
+ const secret = SECRET_NAME.test(p.key);
171
+ const computed = hasVar(p.value ?? '');
172
+ setting(p.key, computed ? 'computed' : 'literal', ins.line, secret);
173
+ if (secret && p.value && !computed) fact('secret-in-plain-env', `ENV ${p.key} has its value written in the Dockerfile, where anyone with the image can read it.`, ins.line);
174
+ steps.push(step(secret ? `Sets ${p.key} (its value is written here, not shown)` : `Sets ${p.key} to ${p.value ?? 'nothing'}${computed ? ` (${BUILT})` : ''}`, 'set'));
175
+ } break;
176
+ case 'ARG': for (const p of pairs(ins.args)) {
177
+ setting(p.key, 'parameter', ins.line);
178
+ if (p.value && SECRET_NAME.test(p.key) && !hasVar(p.value)) fact('secret-in-plain-env', `ARG ${p.key} has a default value written in the Dockerfile.`, ins.line);
179
+ steps.push(step(`Takes the setting ${p.key}${p.value != null && !SECRET_NAME.test(p.key) ? ` (${p.value === '' ? 'empty' : p.value} unless told otherwise)` : ''}`, 'set'));
180
+ } break;
181
+ case 'EXPOSE': steps.push(step(`Opens ${portWords(rest.split(/\s+/).filter(Boolean))}`)); break;
182
+ case 'USER': steps.push(step(`Runs as ${userWords(rest)}`)); break;
183
+ case 'VOLUME': { const ex = execForm(rest); const v = ex.exec ? ex.parts : rest.split(/\s+/).filter(Boolean); steps.push(step(`Keeps ${listWords(v)} in a volume (saved outside the image)`)); break; }
184
+ case 'HEALTHCHECK': {
185
+ if (/^NONE$/i.test(rest)) { steps.push(step('Turns off health checks')); break; }
186
+ const c = /^CMD\s+(.*)$/i.exec(rest);
187
+ const how = c ? execForm(c[1]).text.replace(/\s*\|\|\s*exit\s+1\s*$/, '') : rest;
188
+ steps.push(step(`Checks its health with ${how}${f.interval ? ` every ${f.interval}` : ''}`, 'check'));
189
+ break;
190
+ }
191
+ case 'CMD': cmd = { ins, text: execForm(rest).text }; break;
192
+ case 'ENTRYPOINT': entry = { ins, text: execForm(rest).text }; break;
193
+ case 'LABEL': steps.push(step(`Labels the image with ${listWords(pairs(ins.args).map((p) => p.key))}`)); break;
194
+ case 'SHELL': steps.push(step(`Uses ${execForm(rest).text} to run later commands`)); break;
195
+ case 'STOPSIGNAL': steps.push(step(`Stops when it gets the signal ${rest}`)); break;
196
+ case 'MAINTAINER': steps.push(step(`Names its maintainer: ${rest}`)); break;
197
+ case 'ONBUILD': { const inner = /^(\w+)\s*(.*)$/.exec(rest); steps.push(step(`When another image is built from this one, it will ${inner ? lc(onbuildWords(inner[1], inner[2])) : rest}`)); break; }
198
+ default: steps.push({ kind: 'other', says: code, code, line: ins.line });
199
+ }
200
+ }
201
+ // How it starts is the last thing a stage says, wherever the line is.
202
+ if (entry || cmd) {
203
+ const says = entry && cmd ? `Starts with ${entry.text}, given ${cmd.text}` : `Starts with ${(entry ?? cmd).text}`;
204
+ last.push({ kind: 'call', says, code: [entry, cmd].filter(Boolean).map((x) => `${x.ins.op} ${x.ins.args}`).join('\n'), line: (entry ?? cmd).ins.line });
205
+ }
206
+ steps.push(...last);
207
+ const name = itemName(s, i);
208
+ const end = Math.max(s.line, ...s.ins.map((x) => x.endLine));
209
+ const readable = steps.filter((x) => x.kind !== 'other').length;
210
+ items.push({
211
+ id: `${name}:${s.line}`, name, label: stageLabel(s, i), title: `What ${single && !s.name ? 'the image build' : lc(stageLabel(s, i))} does`, line: s.line, endLine: end,
212
+ inputs: [], returns: null, ...(s.doc ? { doc: s.doc } : {}), provenance: 'inferred-from-code', kind: 'function', status: 'signature-only', steps, stepsMore: 0,
213
+ stepsReadable: steps.length ? Math.round((readable / steps.length) * 100) / 100 : 0,
214
+ says: `${stageLabel(s, i)} starts from ${prev != null && prev < i ? `the ${words(stages[prev].name ?? `stage ${prev + 1}`)} stage` : s.from} and has ${steps.length} step${steps.length === 1 ? '' : 's'}.`,
215
+ headline: `${stageLabel(s, i)}: starts from ${prev != null && prev < i ? `the ${words(stages[prev].name ?? `stage ${prev + 1}`)} stage` : s.from}.`, guards: [], unread: [],
216
+ });
217
+ });
218
+
219
+ // The image this file makes: the last stage, with what it inherits from the stages it starts from.
220
+ const things = [];
221
+ if (stages.length) {
222
+ const chain = [];
223
+ for (let k = stages.length - 1; k != null;) { chain.unshift(k); const p = stageOf(stages[k].from); k = p != null && p < k ? p : null; }
224
+ const base = stages[chain[0]];
225
+ const knows = [];
226
+ const know = (name, label, kind, line, extra = {}) => knows.push({ name, label, kind, start: null, line, ...extra });
227
+ know('starts-from', 'Starts from', imageWords(base.from), base.line, hasVar(base.from) ? { computed: true } : {});
228
+ let user = null, workdir = null, cmd = null, entry = null, health = null;
229
+ const ports = [], env = new Map(), volumes = [];
230
+ for (const k of chain) for (const ins of stages[k].ins) {
231
+ const { rest } = flags(ins.args);
232
+ if (ins.op === 'USER') user = { v: rest, line: ins.line };
233
+ else if (ins.op === 'WORKDIR') workdir = { v: rest, line: ins.line };
234
+ else if (ins.op === 'EXPOSE') for (const p of rest.split(/\s+/).filter(Boolean)) ports.push({ v: p, line: ins.line });
235
+ else if (ins.op === 'CMD') cmd = { v: execForm(rest).text, line: ins.line };
236
+ else if (ins.op === 'ENTRYPOINT') entry = { v: execForm(rest).text, line: ins.line };
237
+ else if (ins.op === 'HEALTHCHECK') health = { v: rest, line: ins.line };
238
+ else if (ins.op === 'VOLUME') volumes.push({ v: execForm(rest).exec ? execForm(rest).parts.join(', ') : rest, line: ins.line });
239
+ else if (ins.op === 'ENV') for (const p of pairs(ins.args)) env.set(p.key, { v: p.value, line: ins.line });
240
+ }
241
+ if (workdir) know('works-in', 'Works in', workdir.v, workdir.line);
242
+ if (ports.length) know('opens', ports.length === 1 ? 'Opens port' : 'Opens ports', listWords(ports.map((p) => p.v.replace(/\/tcp$/i, ''))), ports[0].line);
243
+ know('runs-as', 'Runs as', user ? userWords(user.v) : 'root, the user that can do anything (it has no USER line)', user?.line ?? null);
244
+ if (!user || /^(root|0)(:.*)?$/.test(user.v)) fact('runs-as-root', user ? `The image runs as ${user.v}, the user that can do anything.` : 'The image runs as root, the user that can do anything: its last stage has no USER line.', user?.line ?? stages.at(-1).line);
245
+ if (entry || cmd) know('starts-with', 'Starts with', entry && cmd ? `${entry.v}, given ${cmd.v}` : (entry ?? cmd).v, (entry ?? cmd).line);
246
+ if (health && !/^NONE$/i.test(health.v)) know('health', 'Checks its health with', (/^CMD\s+(.*)$/i.exec(health.v)?.[1] ?? health.v).replace(/\s*\|\|\s*exit\s+1\s*$/, ''), health.line);
247
+ for (const v of volumes) know('volume', 'Keeps in a volume', v.v, v.line);
248
+ for (const [k, v] of env) {
249
+ const secret = SECRET_NAME.test(k);
250
+ const computed = hasVar(v.v ?? '');
251
+ know(k, k, secret ? 'a secret setting (its value is not shown)' : computed ? `a setting, ${BUILT}` : `a setting: ${v.v ?? 'nothing'}`, v.line, { setting: true, ...(computed ? { computed: true } : {}), ...(secret ? { secret: true } : {}) });
252
+ }
253
+ const path = String(file).replace(/\\/g, '/');
254
+ const folder = path.includes('/') ? path.slice(0, path.lastIndexOf('/')).split('/').pop() : '';
255
+ things.push({ kind: 'resource', resourceType: 'docker-image', address: `image:${path}`, name: folder ? `${folder} image` : 'image', file, lines: [stages[0].line, Math.max(...all.map((x) => x.endLine))], knows, choices: [] });
256
+ }
257
+ return { items, things, settings, facts, links, permissions: [] };
258
+ }
259
+
260
+ function onbuildWords(op, args) {
261
+ const u = op.toUpperCase();
262
+ if (u === 'RUN') return shellSteps(args, 0)[0]?.says ?? `Run ${args}`;
263
+ if (u === 'COPY' || u === 'ADD') return `Copy ${args}`;
264
+ return cap(`${u.toLowerCase()} ${args}`);
265
+ }
266
+
267
+ export { commandSays };