@solidnumber/cli 2.24.11 → 2.25.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 (47) hide show
  1. package/CHANGELOG.md +1638 -0
  2. package/README.md +16 -4
  3. package/dist/commands/agent.js +5 -10
  4. package/dist/commands/agent.js.map +1 -1
  5. package/dist/commands/app.d.ts +59 -0
  6. package/dist/commands/app.d.ts.map +1 -0
  7. package/dist/commands/app.js +637 -0
  8. package/dist/commands/app.js.map +1 -0
  9. package/dist/commands/completion.d.ts +10 -0
  10. package/dist/commands/completion.d.ts.map +1 -1
  11. package/dist/commands/completion.js +41 -0
  12. package/dist/commands/completion.js.map +1 -1
  13. package/dist/commands/inbox.js +10 -3
  14. package/dist/commands/inbox.js.map +1 -1
  15. package/dist/commands/install.d.ts.map +1 -1
  16. package/dist/commands/install.js +6 -138
  17. package/dist/commands/install.js.map +1 -1
  18. package/dist/commands/update.d.ts +42 -0
  19. package/dist/commands/update.d.ts.map +1 -1
  20. package/dist/commands/update.js +317 -63
  21. package/dist/commands/update.js.map +1 -1
  22. package/dist/commands/verbs.js +23 -8
  23. package/dist/commands/verbs.js.map +1 -1
  24. package/dist/index.js +2 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/lib/browser-install.d.ts +16 -0
  27. package/dist/lib/browser-install.d.ts.map +1 -1
  28. package/dist/lib/browser-install.js +55 -0
  29. package/dist/lib/browser-install.js.map +1 -1
  30. package/dist/lib/claude-hook.d.ts +16 -0
  31. package/dist/lib/claude-hook.d.ts.map +1 -0
  32. package/dist/lib/claude-hook.js +179 -0
  33. package/dist/lib/claude-hook.js.map +1 -0
  34. package/dist/lib/project-kits.d.ts +19 -0
  35. package/dist/lib/project-kits.d.ts.map +1 -0
  36. package/dist/lib/project-kits.js +180 -0
  37. package/dist/lib/project-kits.js.map +1 -0
  38. package/dist/lib/schema-validate.d.ts +17 -1
  39. package/dist/lib/schema-validate.d.ts.map +1 -1
  40. package/dist/lib/schema-validate.js +91 -38
  41. package/dist/lib/schema-validate.js.map +1 -1
  42. package/dist/lib/skills/plugin.d.ts +12 -0
  43. package/dist/lib/skills/plugin.d.ts.map +1 -1
  44. package/dist/lib/skills/plugin.js +29 -9
  45. package/dist/lib/skills/plugin.js.map +1 -1
  46. package/package.json +7 -4
  47. package/platform-docs/llms.txt +6 -5
@@ -0,0 +1,637 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.appCommand = void 0;
40
+ exports.zipFolder = zipFolder;
41
+ exports.buildSource = buildSource;
42
+ exports.findAppDir = findAppDir;
43
+ exports.findManager = findManager;
44
+ exports.inspectRepo = inspectRepo;
45
+ exports.workflowYaml = workflowYaml;
46
+ /**
47
+ * solid app — put a designer's interactive app live for this company.
48
+ *
49
+ * solid app publish ./dist --slug sell --confirm the BUILT folder (with index.html)
50
+ * solid app list what this company has published
51
+ * solid app get sell url, live version, kept versions
52
+ * solid app rollback sell 2 --confirm put an earlier version live
53
+ * solid app unpublish sell --confirm take it offline (versions kept)
54
+ * solid app github --slug sell --folder dist publish on every push (private repos too)
55
+ *
56
+ * The verbs are app.publish / app.list / app.get / app.rollback / app.unpublish
57
+ * (backend services/hosted_apps.py); this command only reads the folder and
58
+ * calls them. The app runs WITH its JavaScript at its own address — never a
59
+ * solidnumber.com host — so a site page links to the url it returns.
60
+ * Owners-Manual/26-Public-Site/HOSTED-APPS.md.
61
+ */
62
+ const child_process_1 = require("child_process");
63
+ const fs = __importStar(require("fs"));
64
+ const path = __importStar(require("path"));
65
+ const chalk_1 = __importDefault(require("chalk"));
66
+ const commander_1 = require("commander");
67
+ const fflate_1 = require("fflate");
68
+ const api_client_1 = require("../lib/api-client");
69
+ const json_output_1 = require("../lib/json-output");
70
+ const nest_helpers_1 = require("./nest-helpers");
71
+ async function call(verb, body) {
72
+ const res = await api_client_1.apiClient.post(`/api/v1/agent/app/${verb}`, body);
73
+ return res.data;
74
+ }
75
+ /** The folder as one zip, paths kept. Pure — the tests read it back. */
76
+ function zipFolder(files) {
77
+ const entries = {};
78
+ for (const f of files) {
79
+ entries[f.path] = f.encoding === 'base64'
80
+ ? new Uint8Array(Buffer.from(f.content, 'base64'))
81
+ : new Uint8Array(Buffer.from(f.content, 'utf8'));
82
+ }
83
+ return (0, fflate_1.zipSync)(entries, { level: 6 });
84
+ }
85
+ /** Which commit of which repository a folder is, when it can be known. Pure but for git. */
86
+ function buildSource(cwd, env = process.env) {
87
+ // In GitHub Actions both are given; they name the commit the workflow checked out.
88
+ let commit = env.GITHUB_SHA;
89
+ let repo = env.GITHUB_REPOSITORY;
90
+ if (!commit) {
91
+ const head = (0, child_process_1.spawnSync)('git', ['rev-parse', 'HEAD'], { cwd, encoding: 'utf8' });
92
+ // Only when the folder's tree is clean: a commit that is not what was built would be a lie.
93
+ const dirty = (0, child_process_1.spawnSync)('git', ['status', '--porcelain'], { cwd, encoding: 'utf8' });
94
+ if (head.status === 0 && dirty.status === 0 && !dirty.stdout.trim())
95
+ commit = head.stdout.trim();
96
+ }
97
+ if (!repo) {
98
+ const url = (0, child_process_1.spawnSync)('git', ['remote', 'get-url', 'origin'], { cwd, encoding: 'utf8' });
99
+ const m = url.status === 0 ? url.stdout.trim().match(/[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?$/) : null;
100
+ if (m)
101
+ repo = m[1];
102
+ }
103
+ return {
104
+ ...(commit && /^[0-9a-f]{7,40}$/i.test(commit) ? { commit: commit.toLowerCase() } : {}),
105
+ ...(repo && /^[\w.-]+\/[\w.-]+$/.test(repo) ? { repo } : {}),
106
+ };
107
+ }
108
+ function done(json, out, render) {
109
+ if (out && out.ok === false) {
110
+ if (json)
111
+ (0, json_output_1.printJson)(out);
112
+ else {
113
+ console.error(chalk_1.default.red(`✗ ${out.error || out.reason || 'refused'}`));
114
+ if (out.next)
115
+ console.error(chalk_1.default.dim(` ${out.next}`));
116
+ }
117
+ process.exitCode = 1;
118
+ return;
119
+ }
120
+ if (json)
121
+ (0, json_output_1.printJson)(out);
122
+ else
123
+ render();
124
+ }
125
+ function fail(json, message, extra = {}) {
126
+ if (json)
127
+ (0, json_output_1.printJson)({ ok: false, error: message, ...extra });
128
+ else
129
+ console.error(chalk_1.default.red(`✗ ${message}`));
130
+ process.exitCode = 1;
131
+ }
132
+ exports.appCommand = new commander_1.Command('app')
133
+ .description("Put an interactive app (Figma Make, Lovable, v0, Bolt, React…) live for this company");
134
+ exports.appCommand
135
+ .command('publish <folder>')
136
+ .description('Publish the BUILT app folder (the one with index.html: dist/, build/, docs/)')
137
+ .requiredOption('--slug <slug>', "The app's name in its address, e.g. sell")
138
+ .option('--name <name>', 'Display name')
139
+ .option('--root <folder>', 'Inside <folder>, the sub-folder that holds index.html')
140
+ .option('--confirm', 'Consent to publish (without it, shows what would be published)')
141
+ .option('--hold', 'Keep this build as a version but do NOT make it live — the owner makes it live after a look')
142
+ .option('--json', 'Output JSON')
143
+ .action(async (folder, opts) => {
144
+ const json = (0, json_output_1.isJsonOutput)(opts);
145
+ const abs = path.resolve(folder);
146
+ if (!fs.existsSync(abs) || !fs.statSync(abs).isDirectory())
147
+ return fail(json, `Not a folder: ${folder}`);
148
+ const read = (0, nest_helpers_1.readFolder)(abs);
149
+ const hasIndex = read.files.some((f) => f.path === 'index.html' || f.path.endsWith('/index.html'));
150
+ if (!hasIndex) {
151
+ return fail(json, 'No index.html in that folder — publish the BUILT app (run its build first; '
152
+ + 'Vite/React write dist/, Create React App writes build/).', { skipped: read.skipped });
153
+ }
154
+ if (!opts.confirm) {
155
+ const bytes = read.files.reduce((n, f) => n + Buffer.byteLength(f.content, f.encoding === 'base64' ? 'base64' : 'utf8'), 0);
156
+ const plan = { would_publish: read.files.length, bytes, slug: opts.slug, skipped: read.skipped,
157
+ next: `solid app publish ${folder} --slug ${opts.slug} --confirm` };
158
+ if (json)
159
+ return (0, json_output_1.printJson)(plan);
160
+ console.log(`Would publish ${read.files.length} file(s), ${(bytes / 1024).toFixed(0)} KB, as '${opts.slug}'.`);
161
+ for (const s of read.skipped.slice(0, 5))
162
+ console.log(chalk_1.default.dim(` left out: ${s.path} (${s.why})`));
163
+ console.log(chalk_1.default.dim(`Re-run with --confirm to publish.`));
164
+ return;
165
+ }
166
+ // Zip locally, PUT it straight to storage, publish by reference: the bytes never
167
+ // ride inside the API call (a write's arguments are stored on its proposal row and
168
+ // cut off at 10 MB — a big inline publish failed on every door).
169
+ let out;
170
+ try {
171
+ const zip = zipFolder(read.files);
172
+ const up = await call('upload_url', {});
173
+ if (up.ok === false)
174
+ return done(json, up, () => undefined);
175
+ const put = await fetch(up.upload_url, { method: 'PUT', headers: up.headers, body: zip });
176
+ if (!put.ok)
177
+ return fail(json, `Upload failed (${put.status}). Run it again — the link is good for an hour.`);
178
+ out = await call('publish', {
179
+ slug: opts.slug, upload_id: up.upload_id, confirm: true,
180
+ ...(opts.root ? { root: opts.root } : {}), ...(opts.name ? { name: opts.name } : {}),
181
+ ...(opts.hold ? { hold: true } : {}),
182
+ ...buildSource(abs),
183
+ });
184
+ }
185
+ catch (error) {
186
+ return fail(json, (0, api_client_1.handleApiError)(error).message);
187
+ }
188
+ done(json, out, () => {
189
+ if (out.held) {
190
+ console.log(chalk_1.default.green(`✓ Kept as version ${out.held_version} — not live yet`));
191
+ console.log(` ${out.make_it_live}`);
192
+ }
193
+ else {
194
+ console.log(chalk_1.default.green(`✓ Live: ${out.url}`));
195
+ console.log(chalk_1.default.dim(` version ${out.published_version ?? out.live_version} · link it from a site page with a button`));
196
+ }
197
+ for (const w of out.warnings || [])
198
+ console.log(chalk_1.default.yellow(` ⚠ ${w}`));
199
+ // What nobody should have to ask us: how a change reaches the live app, and how
200
+ // the app sends a lead. Both come from the server, worded for this app.
201
+ if (out.keep_it_current)
202
+ console.log(`\n${out.keep_it_current}`);
203
+ if (out.send_a_lead)
204
+ console.log(`\n${out.send_a_lead}`);
205
+ });
206
+ });
207
+ exports.appCommand
208
+ .command('list')
209
+ .description('Apps this company has published')
210
+ .option('--json', 'Output JSON')
211
+ .action(async (opts) => {
212
+ const json = (0, json_output_1.isJsonOutput)(opts);
213
+ try {
214
+ const out = await call('list', {});
215
+ done(json, out, () => {
216
+ if (!out.apps?.length)
217
+ return console.log('No apps published yet — solid app publish <build-folder> --slug <name>');
218
+ for (const a of out.apps)
219
+ console.log(`${a.slug} ${a.status} v${a.live_version} ${a.url ?? ''}`);
220
+ });
221
+ }
222
+ catch (error) {
223
+ fail(json, (0, api_client_1.handleApiError)(error).message);
224
+ }
225
+ });
226
+ exports.appCommand
227
+ .command('get <slug>')
228
+ .description('One app: url, live version, kept versions, build warnings')
229
+ .option('--json', 'Output JSON')
230
+ .action(async (slug, opts) => {
231
+ const json = (0, json_output_1.isJsonOutput)(opts);
232
+ try {
233
+ const out = await call('get', { slug });
234
+ done(json, out, () => {
235
+ console.log(`${out.slug} ${out.status} ${out.url ?? '(offline)'}`);
236
+ for (const v of out.versions || []) {
237
+ const mark = v.n === out.live_version ? ' (live)' : v.held ? ' (held — not live)' : '';
238
+ const from = v.commit ? ` commit ${String(v.commit).slice(0, 12)}${v.repo ? ` of ${v.repo}` : ''}` : '';
239
+ console.log(` v${v.n}${mark} ${v.published_at} ${v.files} files ${v.source}${from}`);
240
+ }
241
+ for (const w of out.warnings || [])
242
+ console.log(chalk_1.default.yellow(` ⚠ ${w}`));
243
+ for (const h of out.outside_hosts || []) {
244
+ if (h.kind !== 'solid')
245
+ console.log(chalk_1.default.dim(` depends on ${h.host} (${h.kind}, ${h.times}×)`));
246
+ }
247
+ if (out.how_updates_work)
248
+ console.log(`\n${out.how_updates_work}`);
249
+ if (out.send_a_lead)
250
+ console.log(`\n${out.send_a_lead}`);
251
+ });
252
+ }
253
+ catch (error) {
254
+ fail(json, (0, api_client_1.handleApiError)(error).message);
255
+ }
256
+ });
257
+ exports.appCommand
258
+ .command('rollback <slug> <version>')
259
+ .description('Put an earlier version live again (also brings an unpublished app back)')
260
+ .option('--confirm', 'Consent to change what is live')
261
+ .option('--json', 'Output JSON')
262
+ .action(async (slug, version, opts) => {
263
+ const json = (0, json_output_1.isJsonOutput)(opts);
264
+ if (!opts.confirm)
265
+ return fail(json, `Re-run with --confirm: solid app rollback ${slug} ${version} --confirm`);
266
+ try {
267
+ const out = await call('rollback', { slug, version: Number(version), confirm: true });
268
+ done(json, out, () => console.log(chalk_1.default.green(`✓ ${slug} v${out.live_version} is live: ${out.url}`)));
269
+ }
270
+ catch (error) {
271
+ fail(json, (0, api_client_1.handleApiError)(error).message);
272
+ }
273
+ });
274
+ exports.appCommand
275
+ .command('unpublish <slug>')
276
+ .description('Take an app offline — every version is kept')
277
+ .option('--confirm', 'Consent to take it offline')
278
+ .option('--json', 'Output JSON')
279
+ .action(async (slug, opts) => {
280
+ const json = (0, json_output_1.isJsonOutput)(opts);
281
+ if (!opts.confirm)
282
+ return fail(json, `Re-run with --confirm: solid app unpublish ${slug} --confirm`);
283
+ try {
284
+ const out = await call('unpublish', { slug, confirm: true });
285
+ done(json, out, () => console.log(chalk_1.default.green(`✓ ${slug} is offline. solid app rollback ${slug} <version> --confirm brings it back.`)));
286
+ }
287
+ catch (error) {
288
+ fail(json, (0, api_client_1.handleApiError)(error).message);
289
+ }
290
+ });
291
+ const SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'out', 'docs', 'public', 'coverage']);
292
+ const LIKELY_APP_DIRS = ['app', 'web', 'frontend', 'client', 'site', 'www'];
293
+ function readJson(file) {
294
+ try {
295
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
296
+ }
297
+ catch {
298
+ return null;
299
+ }
300
+ }
301
+ function hasBuildScript(dir) {
302
+ return Boolean(readJson(path.join(dir, 'package.json'))?.scripts?.build);
303
+ }
304
+ /** The folder holding the app's package.json: the root, else one level down. */
305
+ function findAppDir(repoRoot) {
306
+ if (hasBuildScript(repoRoot))
307
+ return '';
308
+ let names = [];
309
+ try {
310
+ names = fs.readdirSync(repoRoot, { withFileTypes: true })
311
+ .filter((d) => d.isDirectory() && !d.name.startsWith('.') && !SKIP_DIRS.has(d.name))
312
+ .map((d) => d.name).sort();
313
+ }
314
+ catch {
315
+ return null;
316
+ }
317
+ const with_build = names.filter((n) => hasBuildScript(path.join(repoRoot, n)));
318
+ if (!with_build.length)
319
+ return null;
320
+ return LIKELY_APP_DIRS.find((n) => with_build.includes(n)) ?? with_build[0];
321
+ }
322
+ function findManager(repoRoot, appDir) {
323
+ for (const dir of [path.join(repoRoot, appDir), repoRoot]) {
324
+ if (fs.existsSync(path.join(dir, 'pnpm-lock.yaml')))
325
+ return 'pnpm';
326
+ if (fs.existsSync(path.join(dir, 'yarn.lock')))
327
+ return 'yarn';
328
+ if (fs.existsSync(path.join(dir, 'bun.lockb')) || fs.existsSync(path.join(dir, 'bun.lock')))
329
+ return 'bun';
330
+ if (fs.existsSync(path.join(dir, 'package-lock.json')))
331
+ return 'npm';
332
+ }
333
+ return 'npm';
334
+ }
335
+ function installCommand(m, repoRoot, appDir) {
336
+ if (m === 'pnpm')
337
+ return 'pnpm install --frozen-lockfile';
338
+ if (m === 'yarn')
339
+ return 'yarn install --frozen-lockfile';
340
+ if (m === 'bun')
341
+ return 'bun install --frozen-lockfile';
342
+ return fs.existsSync(path.join(repoRoot, appDir, 'package-lock.json')) ? 'npm ci' : 'npm install';
343
+ }
344
+ /** Vite's `outDir`, when the config sets one. */
345
+ function viteOutDir(dir) {
346
+ for (const f of ['vite.config.ts', 'vite.config.js', 'vite.config.mts', 'vite.config.mjs']) {
347
+ try {
348
+ const m = fs.readFileSync(path.join(dir, f), 'utf8').match(/outDir\s*:\s*["'`]([^"'`]+)["'`]/);
349
+ if (m)
350
+ return m[1];
351
+ }
352
+ catch { /* no such config */ }
353
+ }
354
+ return null;
355
+ }
356
+ function gitTracked(repoRoot, rel) {
357
+ return (0, child_process_1.spawnSync)('git', ['ls-files', '--error-unmatch', rel], { cwd: repoRoot, encoding: 'utf8' }).status === 0;
358
+ }
359
+ /** A workflow of THEIRS that rebuilds `folder` and commits it back. */
360
+ function rebuildingWorkflow(repoRoot, folder) {
361
+ const dir = path.join(repoRoot, '.github', 'workflows');
362
+ let files = [];
363
+ try {
364
+ files = fs.readdirSync(dir).filter((f) => /\.ya?ml$/.test(f) && !f.startsWith('solid-app-')).sort();
365
+ }
366
+ catch {
367
+ return null;
368
+ }
369
+ const top = folder.split('/')[0];
370
+ const names = new RegExp(`(^|[\\s"'/])${top.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\s"'/]|$)`, 'm');
371
+ for (const f of files) {
372
+ const text = fs.readFileSync(path.join(dir, f), 'utf8');
373
+ if (!/git\s+push/.test(text) || !names.test(text))
374
+ continue;
375
+ const name = text.match(/^name:\s*["']?(.+?)["']?\s*$/m)?.[1];
376
+ // GitHub names an unnamed workflow by its path.
377
+ return { name: name || `.github/workflows/${f}`, file: `.github/workflows/${f}` };
378
+ }
379
+ return null;
380
+ }
381
+ /** Read the repo's shape. Pure but for the disk and `tracked` (git by default). */
382
+ function inspectRepo(repoRoot, opts = {}) {
383
+ const tracked = opts.tracked ?? ((rel) => gitTracked(repoRoot, rel));
384
+ const found = [];
385
+ const problems = [];
386
+ const appDir = findAppDir(repoRoot);
387
+ const at = appDir === null ? repoRoot : path.join(repoRoot, appDir);
388
+ const pkg = appDir === null ? null : readJson(path.join(at, 'package.json'));
389
+ const manager = appDir === null ? null : findManager(repoRoot, appDir);
390
+ if (appDir !== null) {
391
+ found.push(`the app's package.json is at ${appDir || 'the repo root'} (build script: ${pkg?.scripts?.build})`);
392
+ found.push(`it installs with ${manager}`);
393
+ }
394
+ else {
395
+ found.push('no package.json with a build script, so nothing is built here');
396
+ }
397
+ // The BUILT folder: given, else the first place an index.html already sits.
398
+ let folder = (opts.folder || '').replace(/^\.\//, '').replace(/\/+$/, '');
399
+ if (!folder) {
400
+ const out = appDir !== null ? viteOutDir(at) : null;
401
+ const rel = (d) => (appDir ? path.posix.join(appDir, d) : d);
402
+ const candidates = [
403
+ ...(out ? [path.posix.normalize(rel(out))] : []),
404
+ 'docs', rel('dist'), rel('build'), rel('out'), 'dist', 'build', 'out',
405
+ ].filter((c, n, all) => !c.startsWith('..') && all.indexOf(c) === n);
406
+ const built = candidates.filter((c) => fs.existsSync(path.join(repoRoot, c, 'index.html')));
407
+ folder = built.find((c) => tracked(`${c}/index.html`)) ?? built[0] ?? '';
408
+ if (folder)
409
+ found.push(`the built app (index.html) is in ${folder}/`);
410
+ else if (appDir !== null) {
411
+ folder = out ? path.posix.normalize(rel(out)) : rel('dist');
412
+ found.push(`no built folder on disk yet; the build writes ${folder}/ `
413
+ + `(${out ? 'vite.config outDir' : 'Vite\'s default — pass --folder if yours differs'})`);
414
+ }
415
+ else {
416
+ problems.push('No built app found: no folder with an index.html (looked in docs, dist, build, out) '
417
+ + 'and no package.json to build one. Pass --folder <the folder with index.html>.');
418
+ }
419
+ }
420
+ const committed = Boolean(folder) && tracked(`${folder}/index.html`);
421
+ const after = committed ? rebuildingWorkflow(repoRoot, folder) : null;
422
+ let mode = 'build';
423
+ if (opts.build) {
424
+ found.push(`builds with the command you gave: ${opts.build}`);
425
+ }
426
+ else if (after) {
427
+ mode = 'after_workflow';
428
+ found.push(`${folder}/ is committed, and your workflow "${after.name}" (${after.file}) rebuilds it and pushes it back`);
429
+ found.push('so the publish runs when that workflow finishes — publishing on push would send the previous build');
430
+ }
431
+ else if (committed) {
432
+ mode = 'committed';
433
+ found.push(`${folder}/ is committed and nothing rebuilds it, so it is published as it is whenever it changes`);
434
+ }
435
+ else if (appDir === null && folder) {
436
+ mode = 'committed';
437
+ problems.push(`${folder}/ is not committed and there is nothing to build it. Commit it, or pass --build <command>.`);
438
+ }
439
+ const builds = mode === 'build' && !opts.build && appDir !== null && manager !== null;
440
+ return {
441
+ mode, folder, appDir: appDir ?? '', manager,
442
+ managerPinned: Boolean(pkg?.packageManager),
443
+ install: builds ? installCommand(manager, repoRoot, appDir) : null,
444
+ build: builds ? `${manager} run build` : null,
445
+ customBuild: opts.build ?? null,
446
+ after, found, problems,
447
+ };
448
+ }
449
+ /** The workflow `solid app github` writes. Pure — the tests read it back. */
450
+ function workflowYaml(o) {
451
+ const { plan } = o;
452
+ const file = `solid-app-${o.slug}.yml`;
453
+ const trigger = plan.mode === 'after_workflow'
454
+ ? ` workflow_run:\n workflows: [${JSON.stringify(plan.after.name)}]\n types: [completed]\n branches: [${o.branch}]\n`
455
+ : plan.mode === 'committed'
456
+ ? ` push:\n branches: [${o.branch}]\n paths: ["${plan.folder}/**", ".github/workflows/${file}"]\n`
457
+ : ` push:\n branches: [${o.branch}]\n`;
458
+ const gate = plan.mode === 'after_workflow'
459
+ ? " if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}\n"
460
+ : '';
461
+ // After their workflow: the branch HEAD, which now holds the rebuilt folder.
462
+ const checkout = plan.mode === 'after_workflow'
463
+ ? ` - uses: actions/checkout@v4\n with:\n ref: ${o.branch}\n`
464
+ : ' - uses: actions/checkout@v4\n';
465
+ const node = ' - uses: actions/setup-node@v4\n with:\n node-version: 22\n';
466
+ let build = '';
467
+ if (plan.customBuild) {
468
+ build = `${node} - run: ${plan.customBuild}\n`;
469
+ }
470
+ else if (plan.build) {
471
+ const wd = plan.appDir ? ` working-directory: ${plan.appDir}\n` : '';
472
+ const pm = plan.manager === 'pnpm'
473
+ ? ' - uses: pnpm/action-setup@v4\n with:\n'
474
+ + (plan.managerPinned
475
+ ? ` package_json_file: ${plan.appDir ? `${plan.appDir}/` : ''}package.json\n`
476
+ : ' version: latest\n')
477
+ : plan.manager === 'bun' ? ' - uses: oven-sh/setup-bun@v2\n' : '';
478
+ build = `${pm}${node} - run: ${plan.install}\n${wd} - run: ${plan.build}\n${wd}`;
479
+ }
480
+ const when = plan.mode === 'after_workflow' ? `each time "${plan.after.name}" finishes on ${o.branch}`
481
+ : plan.mode === 'committed' ? `each time ${plan.folder}/ changes on ${o.branch}`
482
+ : `on every push to ${o.branch}`;
483
+ const held = o.review
484
+ ? '\n# REVIEW MODE: each build is kept as a version and is NOT live until the owner makes it live\n'
485
+ + `# (Apps → Hosted → Make live, or: solid app rollback ${o.slug} <version> --confirm).`
486
+ : '';
487
+ return `# Publishes ${plan.folder}/ to Solid# as the app "${o.slug}" ${when}.${held}
488
+ # Written by \`solid app github\`. The key (secret SOLID_API_KEY) can only publish apps.
489
+ #
490
+ # For whoever (or whichever AI) reads this file later:
491
+ # - Solid# never pulls from this repository. THIS workflow is the only thing that
492
+ # updates the live app. If the live app is behind, check this workflow's last run.
493
+ # - Which build is live, and from which commit: npx -y @solidnumber/cli@latest app get ${o.slug}
494
+ # - Put an earlier version back: npx -y @solidnumber/cli@latest app rollback ${o.slug} <version> --confirm
495
+ # - This repository can be private. GitHub Pages is not needed.
496
+ # - Everything else: npx -y @solidnumber/cli@latest app --help
497
+ name: Publish ${o.slug} to Solid#
498
+ on:
499
+ ${trigger} workflow_dispatch:
500
+ concurrency:
501
+ group: solid-app-${o.slug}
502
+ cancel-in-progress: false
503
+ jobs:
504
+ publish:
505
+ ${gate} runs-on: ubuntu-latest
506
+ steps:
507
+ ${checkout}${build} - run: npx -y @solidnumber/cli@latest app publish ${plan.folder} --slug ${o.slug} --confirm${o.review ? ' --hold' : ''}
508
+ env:
509
+ SOLID_API_KEY: \${{ secrets.SOLID_API_KEY }}
510
+ NO_UPDATE_NOTIFIER: '1'
511
+ `;
512
+ }
513
+ exports.appCommand
514
+ .command('github')
515
+ .description('Publish this repo\'s app on every change — private repos too. Run once, in the repo. Reads the repo itself: no flags needed but --slug.')
516
+ .requiredOption('--slug <slug>', "The app's name in its address, e.g. sell")
517
+ .option('--folder <folder>', 'The BUILT folder, relative to the repo root. Found for you when left out (docs, dist, build, out, or <app>/dist)')
518
+ .option('--build <command>', 'Build command to run instead of the one found (run at the repo root)')
519
+ .option('--branch <branch>', 'Branch to publish from', 'main')
520
+ .option('--review', 'Each build waits for the owner: it is kept as a version and goes live only when they make it live')
521
+ .option('--plan', 'Only show what was found and what would be written. Creates no key, writes no file')
522
+ .option('--json', 'Output JSON')
523
+ .action(async (opts) => {
524
+ const json = (0, json_output_1.isJsonOutput)(opts);
525
+ const top = (0, child_process_1.spawnSync)('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' });
526
+ if (top.status !== 0)
527
+ return fail(json, 'Run this inside the app\'s git repository.');
528
+ const repoRoot = top.stdout.trim();
529
+ const plan = inspectRepo(repoRoot, { folder: opts.folder, build: opts.build });
530
+ const rel = path.posix.join('.github', 'workflows', `solid-app-${opts.slug}.yml`);
531
+ if (plan.problems.length) {
532
+ return fail(json, plan.problems[0], { found: plan.found, problems: plan.problems });
533
+ }
534
+ const yaml = workflowYaml({ slug: opts.slug, branch: opts.branch, plan, review: Boolean(opts.review) });
535
+ const when = plan.mode === 'after_workflow' ? `each time "${plan.after.name}" finishes`
536
+ : plan.mode === 'committed' ? `each time ${plan.folder}/ changes` : `on every push to ${opts.branch}`;
537
+ if (opts.plan) {
538
+ const out = { ok: true, plan_only: true, mode: plan.mode, folder: plan.folder, app_dir: plan.appDir || '.',
539
+ manager: plan.manager, publishes: when, review: Boolean(opts.review), found: plan.found,
540
+ workflow: rel, workflow_yaml: yaml,
541
+ next: `solid app github --slug ${opts.slug}${opts.folder ? ` --folder ${opts.folder}` : ''}` };
542
+ if (json)
543
+ return (0, json_output_1.printJson)(out);
544
+ for (const f of plan.found)
545
+ console.log(chalk_1.default.dim(` · ${f}`));
546
+ console.log(`Would write ${rel}: publishes ${plan.folder}/ ${when}.`);
547
+ console.log(chalk_1.default.dim(`Run it for real: ${out.next}`));
548
+ return;
549
+ }
550
+ // 1. a key that can only publish apps
551
+ let key;
552
+ let keyId;
553
+ try {
554
+ const repoName = path.basename(repoRoot);
555
+ const res = await api_client_1.apiClient.apiKeyCreate(`github: ${repoName} → app ${opts.slug}`, ['apps:write']);
556
+ key = res.data.key;
557
+ keyId = res.data.api_key?.id;
558
+ }
559
+ catch (error) {
560
+ return fail(json, `Could not create the publish key: ${(0, api_client_1.handleApiError)(error).message}`);
561
+ }
562
+ // 2. the key into the repo's secrets — straight from us to GitHub, never printed
563
+ const gh = (0, child_process_1.spawnSync)('gh', ['secret', 'set', 'SOLID_API_KEY', '--body', key], { cwd: repoRoot, encoding: 'utf8' });
564
+ const secretSet = gh.status === 0;
565
+ // 3. the workflow
566
+ const file = path.join(repoRoot, rel);
567
+ fs.mkdirSync(path.dirname(file), { recursive: true });
568
+ fs.writeFileSync(file, yaml);
569
+ // The exact commands, in order. An agent runs them as written; nobody is asked anything.
570
+ const steps = [
571
+ ...(secretSet ? [] : ['gh secret set SOLID_API_KEY # paste the key below when asked (or: repo Settings → Secrets and variables → Actions)']),
572
+ `git add ${rel} && git commit -m "Publish ${opts.slug} to Solid# automatically" && git push`,
573
+ `gh workflow run solid-app-${opts.slug}.yml # publish the current build now`,
574
+ `solid app get ${opts.slug} # the live address, the version, the commit it came from`,
575
+ ...(opts.review ? [`solid app rollback ${opts.slug} <version> --confirm # the owner's yes: makes a held version live`] : []),
576
+ ];
577
+ const out = {
578
+ ok: true, workflow: rel, mode: plan.mode, folder: plan.folder, app_dir: plan.appDir || '.',
579
+ manager: plan.manager, publishes: when, review: Boolean(opts.review), found: plan.found,
580
+ key_id: keyId, key_scope: 'apps:write', secret_set: secretSet, steps,
581
+ next: steps[0],
582
+ ...(secretSet ? {} : { key }),
583
+ };
584
+ if (json)
585
+ return (0, json_output_1.printJson)(out);
586
+ for (const f of plan.found)
587
+ console.log(chalk_1.default.dim(` · ${f}`));
588
+ console.log(chalk_1.default.green(`✓ Wrote ${rel}`) + chalk_1.default.dim(` (publishes ${plan.folder}/ ${when})`));
589
+ console.log(chalk_1.default.green(`✓ Created key ${keyId} — it can only publish apps`));
590
+ if (secretSet)
591
+ console.log(chalk_1.default.green('✓ Saved it as the repo secret SOLID_API_KEY'));
592
+ else {
593
+ console.log(chalk_1.default.yellow(' GitHub CLI not available — add this as the repo secret SOLID_API_KEY (shown once):'));
594
+ console.log(` ${key}`);
595
+ }
596
+ console.log('Now run, in order:');
597
+ steps.forEach((st, n) => console.log(` ${n + 1}. ${st}`));
598
+ });
599
+ exports.appCommand.addHelpText('after', `
600
+ PAGE OR APP — the one question: does it need its OWN JavaScript to do its job?
601
+ NO → a PAGE. Import it (solid verbs invoke design.intake names the door). It lives on
602
+ <company>.solidnumber.com as editable blocks; the owner, their AI and Solid# can change
603
+ every word and image, and it follows the brand (logo, colours).
604
+ YES → an APP. Publish its built files with the commands below. It lives at
605
+ <company>.solidhost.app/<name>/, runs exactly as built, and only its developer can
606
+ change it. A brand change in Solid# does not reach it.
607
+ How to tell: picture it with JavaScript off. Only polish lost (animation, menus) → page.
608
+ It stops doing its job (steps, camera, calculator) → app.
609
+ Why two addresses: every solidnumber.com address shares the dashboard's sign-in, so outside
610
+ script never runs there. solidhost.app is a separate domain where it can.
611
+ Most businesses have both: pages, plus a button that opens the app. A business can have many
612
+ apps (/sell/, /quote/). ".app" is a domain ending, not the App Store.
613
+
614
+ For an AI agent — do this in order and ask the person nothing:
615
+ 1. solid app github --slug <name> --plan --json reads the repo: the built folder, how it builds, when to publish
616
+ 2. solid app github --slug <name> --json writes the workflow and a publish-only key
617
+ 3. run the "steps" it returns, exactly as written
618
+ Publish once by hand instead: solid app publish <built folder> --slug <name> --confirm
619
+
620
+ What is always true:
621
+ · Publish the BUILT folder (index.html inside), never the source.
622
+ · Solid# never pulls from GitHub. A change reaches the live app only when a publish runs.
623
+ · The live address is https://<company>.solidhost.app/<name>/ — "solid app get <name>" prints it.
624
+ · A private repository works; nothing has to be made public and GitHub Pages is not needed.
625
+ · Static files only. Asset paths must be relative (Vite: base: './').
626
+ · The app does not run on a *.solidnumber.com page. Link to its address with a button.
627
+ · Every version is kept: solid app rollback <name> <version> --confirm
628
+ · "solid app get <name>" says which commit is live. Compare commits, never file names.
629
+ · The publish reply names every outside address the build depends on. Fix the personal
630
+ and preview ones (github.io, figma.site, vercel.app…) before calling it done.
631
+ · To send what a visitor enters into the business's CRM, use the code under "send_a_lead"
632
+ in the publish reply exactly. It needs no key and works only from the app's own address.
633
+ · The owner wants to look first: add --hold (one publish) or --review (every push). The
634
+ build is kept, not live, until: solid app rollback <name> <version> --confirm
635
+ · Never write to Solid# to ask how this works. Run the command; the reply says what to do next.
636
+ `);
637
+ //# sourceMappingURL=app.js.map