@milesroxas/design-hub 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -68,7 +68,7 @@ A speculation rule in `shell/index.html` prefetches a prototype's page when its
68
68
 
69
69
  ## Deploying, and the password
70
70
 
71
- `miles-deploy` owns the steps; this is what they rest on. Pushing `main` deploys the project to the linked Vercel project (`design-hub bootstrap --vercel <project>` links it and sets the env). Every path on the deployed site sits behind one password, enforced on the server by Vercel Routing Middleware (`vercel/proxy.ts`, exported as `createProxy` and default-exported by the project's one-line `proxy.ts`, which `vercel.json` names as `proxy.entrypoint`): a visitor who opens a deep link, `/sample-list/#/items` included, sees the password page first and lands on that link after. A client-side gate was rejected because the bundle and the state behind it would still download.
71
+ `miles-deploy` owns the steps; this is what they rest on. `design-hub signin` starts `vercel login`'s device sign-in in the background and returns its link, so the user clicks instead of typing. `design-hub bootstrap --vercel <project>` links the project, connects it to the `origin` repo when Vercel can reach it, turns Vercel Authentication off and sets the env. `design-hub share` runs the pre-flight, then deploys: a push of a clean production branch when the project is connected to the repo (following the build for that commit), else `vercel deploy --prod`; then it requests the production URL signed out and fails unless the password page answers with `noindex`. Every path on the deployed site sits behind one password, enforced on the server by Vercel Routing Middleware (`vercel/proxy.ts`, exported as `createProxy` and default-exported by the project's one-line `proxy.ts`, which `vercel.json` names as `proxy.entrypoint`): a visitor who opens a deep link, `/sample-list/#/items` included, sees the password page first and lands on that link after. A client-side gate was rejected because the bundle and the state behind it would still download.
72
72
 
73
73
  The middleware reads two environment variables, set in the Vercel project for Production and Preview and never committed (`.env.example` names them): `GATE_PASSWORD`, the word a reviewer types, and `GATE_SECRET`, at least 32 random characters (`openssl rand -base64 32`) that sign the session cookie. With either missing the gate answers 503 on every path, so a misconfigured deploy never serves the prototypes open. The cookie is `__Host-`-prefixed, `HttpOnly`, `Secure`, `SameSite=Lax`, lasts 30 days, and its signature covers the password, so changing `GATE_PASSWORD` signs every visitor out. A wrong password waits 800ms before answering; add a Vercel Firewall rate-limit rule on `POST` for anything stronger. The password page ships a hash-based Content Security Policy with no `unsafe-inline`, plus `font-src 'self'` and `img-src 'self'`. It wears the hub's neutral look in Geist, so two files pass the gate without a session: `/_gate/geist.woff2` (the latin subset, emitted by `vite/plugin.ts` at that fixed path) and `/favicon.svg`. Nothing else does. Every response carries `X-Robots-Tag: noindex`, so no search engine lists the site. The page's title is the `siteName` the project's `proxy.ts` passes to `createProxy`.
74
74
 
@@ -42,7 +42,7 @@ export declare const spec: {
42
42
  readonly description: 'Provision the review store (Upstash Redis) on the Vercel project.';
43
43
  };
44
44
  };
45
- readonly output: '{ ok, node, port, install, typesafe, conductor?, vercel?, share?, review?, warnings }';
45
+ readonly output: '{ ok, node, port, install, typesafe, conductor?, vercel: { project, linked, git, protection, env }?, share?, review?, warnings }';
46
46
  };
47
47
  /**
48
48
  * What `design-hub dev`, `open` and `preview` run first, so a fresh clone or
@@ -11,8 +11,9 @@ import { join } from 'node:path';
11
11
  import { harnessPort, readEnv, writeEnv } from '../server/env.js';
12
12
  import { ROOT, TEMPLATES } from '../server/paths.js';
13
13
  import { CliError } from './lib/cli.js';
14
+ import { gitConnected } from './lib/deploy.js';
14
15
  import { holderOf, pickPort, readClaims, writeClaim } from './lib/ports.js';
15
- import { ENVIRONMENTS, envNames, linkedOrg, linkedProject, STORE_ENV, setEnv, vercel, } from './lib/vercel.js';
16
+ import { ENVIRONMENTS, envNames, linkedOrg, linkedProject, projectInfo, STORE_ENV, setEnv, vercel, whoami, } from './lib/vercel.js';
16
17
  export const spec = {
17
18
  name: 'bootstrap',
18
19
  summary: 'Set the project up on this machine, and optionally on Vercel. Safe to run again.',
@@ -39,7 +40,7 @@ export const spec = {
39
40
  description: 'Provision the review store (Upstash Redis) on the Vercel project.',
40
41
  },
41
42
  },
42
- output: '{ ok, node, port, install, typesafe, conductor?, vercel?, share?, review?, warnings }',
43
+ output: '{ ok, node, port, install, typesafe, conductor?, vercel: { project, linked, git, protection, env }?, share?, review?, warnings }',
43
44
  };
44
45
  const MIN_NODE = [22, 18];
45
46
  const UPSTASH = 'upstash/upstash-kv';
@@ -164,7 +165,7 @@ function cli(args, input) {
164
165
  throw new CliError(`vercel ${args.slice(0, 2).join(' ')} failed.`, {
165
166
  stderr: out.stderr.trim().slice(-600),
166
167
  fix: /log ?in|credentials|token/i.test(out.stderr)
167
- ? 'Ask the user to run `vercel login` in their terminal.'
168
+ ? 'design-hub signin, send the user its url, then run this again.'
168
169
  : undefined,
169
170
  });
170
171
  return out.stdout;
@@ -180,13 +181,39 @@ function link(project, team, warnings) {
180
181
  cli(['link', '--yes', '--project', project, ...(team ? ['--scope', team] : [])]);
181
182
  return 'ran';
182
183
  }
184
+ /** The `origin` remote, or null when the project has none. */
185
+ function origin() {
186
+ const out = spawnSync('git', ['-C', ROOT, 'remote', 'get-url', 'origin'], { encoding: 'utf8' });
187
+ return out.status === 0 ? out.stdout.trim() || null : null;
188
+ }
189
+ /**
190
+ * Connects the Vercel project to the repo, so pushing the production branch
191
+ * deploys it. Without a remote, or when Vercel cannot reach the repo, it stays
192
+ * unconnected and `design-hub share` uploads the folder instead.
193
+ */
194
+ function connectGit(project, team, warnings) {
195
+ const remote = origin();
196
+ if (!remote)
197
+ return 'none';
198
+ if (gitConnected(projectInfo(ROOT, project, team ?? linkedOrg(ROOT))))
199
+ return 'kept';
200
+ const out = vercel(ROOT, ['git', 'connect', remote, '--yes']);
201
+ if (out?.status === 0)
202
+ return 'connected';
203
+ warnings.push(`Could not connect ${remote} to the Vercel project, so design-hub share will upload the folder instead of deploying on push. ` +
204
+ 'To deploy on push, the user gives Vercel access to the repo at https://github.com/apps/vercel/installations/new, then run this again. ' +
205
+ (out?.stderr.trim().split('\n').pop() ?? ''));
206
+ return 'none';
207
+ }
183
208
  /** Sets each value where it is missing; `rotate` names the ones given again, which replace what is there. */
184
209
  function ensureEnv(values, rotate) {
185
210
  const state = {};
186
211
  for (const target of ENVIRONMENTS) {
187
212
  const names = envNames(ROOT, target);
188
213
  if (!names)
189
- throw new CliError(`vercel env ls ${target} failed.`, { fix: 'vercel login, then run this again.' });
214
+ throw new CliError(`vercel env ls ${target} failed.`, {
215
+ fix: 'design-hub signin, then run this again.',
216
+ });
190
217
  for (const [name, value] of Object.entries(values)) {
191
218
  const key = `${name}:${target}`;
192
219
  const exists = names.has(name);
@@ -257,7 +284,7 @@ function provisionReview(project, team, warnings) {
257
284
  if (out?.status !== 0)
258
285
  throw new CliError('Could not add the Upstash for Redis store.', {
259
286
  stderr: out?.stderr.trim().slice(-600),
260
- fix: `Ask the user to run \`vercel integration add ${UPSTASH}\` once in their terminal (it accepts the Marketplace terms), then run this again.`,
287
+ fix: `The Marketplace terms need accepting once per team: send the user https://vercel.com/marketplace/upstash to choose Install and accept for this team, then run this again.`,
261
288
  });
262
289
  store = 'created';
263
290
  }
@@ -293,6 +320,10 @@ export function gateValues(given, env) {
293
320
  return { password, secret, rotated: given !== undefined && given !== env.GATE_PASSWORD };
294
321
  }
295
322
  function setUpVercel(project, flags, env, typesafeKey, warnings) {
323
+ if (!whoami(ROOT))
324
+ throw new CliError('The Vercel CLI is not installed or not signed in.', {
325
+ fix: 'design-hub signin, send the user its url, then run this again.',
326
+ });
296
327
  const linked = link(project, flags.team, warnings);
297
328
  const { password, secret, rotated } = gateValues(flags['gate-password'], env);
298
329
  writeEnv(ROOT, { GATE_PASSWORD: password, GATE_SECRET: secret });
@@ -306,6 +337,7 @@ function setUpVercel(project, flags, env, typesafeKey, warnings) {
306
337
  vercel: {
307
338
  project,
308
339
  linked,
340
+ git: connectGit(project, flags.team, warnings),
309
341
  protection: protection(project, flags.team),
310
342
  env: ensureEnv(values, new Set(rotated ? ['GATE_PASSWORD'] : [])),
311
343
  },
@@ -313,7 +345,7 @@ function setUpVercel(project, flags, env, typesafeKey, warnings) {
313
345
  };
314
346
  if (!flags.review)
315
347
  return result;
316
- warnings.push('Redeploy so the new env reaches the site; then design-hub people invite --name "<you>" --role editor.');
348
+ warnings.push('Run design-hub share so the new env reaches the site; then design-hub people invite --name "<you>" --role editor --site <url>.');
317
349
  return { ...result, review: provisionReview(project, flags.team, warnings) };
318
350
  }
319
351
  function envIgnored(warnings) {
@@ -22,6 +22,8 @@ import * as create from './new.js';
22
22
  import * as people from './people.js';
23
23
  import * as preflight from './preflight.js';
24
24
  import * as releaseCheck from './release-check.js';
25
+ import * as share from './share.js';
26
+ import * as signin from './signin.js';
25
27
  import * as skillHint from './skill-hint.js';
26
28
  import * as skills from './skills.js';
27
29
  import * as tracks from './tracks.js';
@@ -41,6 +43,8 @@ const COMMANDS = {
41
43
  check,
42
44
  guard,
43
45
  preflight,
46
+ signin,
47
+ share,
44
48
  people,
45
49
  comments,
46
50
  calibrate,
@@ -17,6 +17,8 @@ import * as create from './new.js';
17
17
  import * as people from './people.js';
18
18
  import * as preflight from './preflight.js';
19
19
  import * as releaseCheck from './release-check.js';
20
+ import * as share from './share.js';
21
+ import * as signin from './signin.js';
20
22
  import * as skillHint from './skill-hint.js';
21
23
  import * as skills from './skills.js';
22
24
  import * as tracks from './tracks.js';
@@ -37,6 +39,8 @@ export const COMMANDS = [
37
39
  check.spec,
38
40
  guard.spec,
39
41
  preflight.spec,
42
+ signin.spec,
43
+ share.spec,
40
44
  people.spec,
41
45
  comments.spec,
42
46
  calibrate.spec,
@@ -0,0 +1,76 @@
1
+ /** The device sign-in `vercel login` prints and then waits on. */
2
+ export declare function deviceLink(log: string): {
3
+ url: string;
4
+ code: string;
5
+ } | null;
6
+ /** The parts of `GET /v9/projects/<name>` a deploy reads. */
7
+ export type ProjectInfo = {
8
+ link?: {
9
+ type?: string;
10
+ repo?: string;
11
+ org?: string;
12
+ productionBranch?: string;
13
+ } | null;
14
+ targets?: {
15
+ production?: {
16
+ alias?: string[];
17
+ } | null;
18
+ } | null;
19
+ };
20
+ export declare const gitConnected: (info: ProjectInfo | null) => boolean;
21
+ /** The address a reviewer is sent: the first production alias (a custom domain when there is one). */
22
+ export declare function productionUrl(info: ProjectInfo | null, project: string): string;
23
+ export type Repo = {
24
+ connected: boolean;
25
+ branch: string | null;
26
+ productionBranch: string;
27
+ dirty: string[];
28
+ };
29
+ export type Plan = {
30
+ via: 'git';
31
+ branch: string;
32
+ } | {
33
+ via: 'cli';
34
+ reason: string;
35
+ } | {
36
+ error: string;
37
+ fix: string;
38
+ detail?: unknown;
39
+ };
40
+ /**
41
+ * A project connected to its repo deploys by pushing the production branch, so
42
+ * the deployment matches a commit; otherwise the CLI uploads the folder.
43
+ * Pushing is refused from another branch or with uncommitted changes, since
44
+ * neither would deploy what is on disk.
45
+ */
46
+ export declare function plan(repo: Repo, forceCli: boolean): Plan;
47
+ export type Answer = {
48
+ status: number;
49
+ location: string | null;
50
+ robots: string | null;
51
+ body: string;
52
+ };
53
+ export type Verdict = {
54
+ ok: true;
55
+ } | {
56
+ ok: false;
57
+ problem: string;
58
+ fix: string;
59
+ };
60
+ /** Whether the production URL answers a signed-out visitor with the hub's password page. */
61
+ export declare function gateVerdict(answer: Answer): Verdict;
62
+ export type Seen = {
63
+ url: string;
64
+ state: string;
65
+ } | null;
66
+ export type Next = {
67
+ done: string;
68
+ } | {
69
+ wait: true;
70
+ } | {
71
+ error: string;
72
+ fix: string;
73
+ deployment?: string;
74
+ };
75
+ /** One look at the deployment Vercel started for a pushed commit: done, keep waiting, or stop. */
76
+ export declare function nextStep(seen: Seen, sha: string, waitedMs: number): Next;
@@ -0,0 +1,94 @@
1
+ /// <reference types="node" />
2
+ // What `design-hub signin` and `design-hub share` decide, kept apart from the
3
+ // vercel and git calls that feed them so every branch is tested: the sign-in
4
+ // link in the CLI's log, which way a deploy goes, the production URL, and
5
+ // whether the deployed site answers with the gate.
6
+ /** The device sign-in `vercel login` prints and then waits on. */
7
+ export function deviceLink(log) {
8
+ const m = log.match(/https:\/\/vercel\.com\/oauth\/device\?user_code=([A-Z0-9-]+)/);
9
+ return m ? { url: m[0], code: m[1] } : null;
10
+ }
11
+ export const gitConnected = (info) => Boolean(info?.link?.repo);
12
+ /** The address a reviewer is sent: the first production alias (a custom domain when there is one). */
13
+ export function productionUrl(info, project) {
14
+ const alias = info?.targets?.production?.alias?.find((a) => !a.includes('-git-')) ?? `${project}.vercel.app`;
15
+ return `https://${alias}`;
16
+ }
17
+ /**
18
+ * A project connected to its repo deploys by pushing the production branch, so
19
+ * the deployment matches a commit; otherwise the CLI uploads the folder.
20
+ * Pushing is refused from another branch or with uncommitted changes, since
21
+ * neither would deploy what is on disk.
22
+ */
23
+ export function plan(repo, forceCli) {
24
+ if (forceCli)
25
+ return { via: 'cli', reason: '--cli' };
26
+ if (!repo.connected)
27
+ return { via: 'cli', reason: 'the Vercel project is not connected to a Git repo' };
28
+ if (repo.branch !== repo.productionBranch)
29
+ return {
30
+ error: `On ${repo.branch ?? 'a detached HEAD'}; production deploys from ${repo.productionBranch}.`,
31
+ fix: `Merge into ${repo.productionBranch} and run this from there, or pass --cli to upload this folder as production.`,
32
+ };
33
+ if (repo.dirty.length)
34
+ return {
35
+ error: 'Uncommitted changes would not deploy.',
36
+ fix: 'Commit them (ask the user first), then run this again.',
37
+ detail: { dirty: repo.dirty.slice(0, 20) },
38
+ };
39
+ return { via: 'git', branch: repo.productionBranch };
40
+ }
41
+ /** Whether the production URL answers a signed-out visitor with the hub's password page. */
42
+ export function gateVerdict(answer) {
43
+ if (answer.status >= 300 && answer.status < 400 && /vercel\.com/.test(answer.location ?? ''))
44
+ return {
45
+ ok: false,
46
+ problem: 'Visitors are sent to a Vercel login before the password page.',
47
+ fix: 'design-hub bootstrap --vercel <project> turns Vercel Authentication off; run it, then deploy again.',
48
+ };
49
+ if (answer.status === 503)
50
+ return {
51
+ ok: false,
52
+ problem: 'The gate answers 503: GATE_PASSWORD or GATE_SECRET is missing on the deployment.',
53
+ fix: 'design-hub bootstrap --vercel <project>, then deploy again so the env reaches the site.',
54
+ };
55
+ if (answer.status !== 401 || !/name="password"/.test(answer.body))
56
+ return {
57
+ ok: false,
58
+ problem: `Expected the password page (401), got ${answer.status}.`,
59
+ fix: 'Check that proxy.ts and vercel.json are the template’s, then deploy again.',
60
+ };
61
+ if (!/noindex/.test(answer.robots ?? ''))
62
+ return {
63
+ ok: false,
64
+ problem: 'X-Robots-Tag: noindex is missing.',
65
+ fix: 'Restore vercel.json from the template.',
66
+ };
67
+ return { ok: true };
68
+ }
69
+ const APPEAR_MS = 2 * 60_000;
70
+ const BUILD_MS = 10 * 60_000;
71
+ /** One look at the deployment Vercel started for a pushed commit: done, keep waiting, or stop. */
72
+ export function nextStep(seen, sha, waitedMs) {
73
+ const deployment = seen ? `https://${seen.url}` : undefined;
74
+ if (seen?.state === 'READY')
75
+ return { done: `https://${seen.url}` };
76
+ if (seen && ['ERROR', 'CANCELED'].includes(seen.state))
77
+ return {
78
+ error: `The deployment of ${sha.slice(0, 7)} ended ${seen.state}.`,
79
+ fix: `vercel inspect ${deployment} --logs shows the build log.`,
80
+ deployment,
81
+ };
82
+ if (!seen && waitedMs > APPEAR_MS)
83
+ return {
84
+ error: `Vercel started no deployment for ${sha.slice(0, 7)}.`,
85
+ fix: 'Check the Git connection under Project Settings, Git, or run design-hub share --cli.',
86
+ };
87
+ if (waitedMs > BUILD_MS)
88
+ return {
89
+ error: 'The build is still running after 10 minutes.',
90
+ fix: 'Run design-hub share again once it finishes; nothing is pushed twice.',
91
+ deployment,
92
+ };
93
+ return { wait: true };
94
+ }
@@ -1,3 +1,4 @@
1
+ import type { ProjectInfo } from './deploy.ts';
1
2
  export declare const ENVIRONMENTS: readonly ['production', 'preview'];
2
3
  export type Target = (typeof ENVIRONMENTS)[number] | 'development';
3
4
  /** What the Upstash for Redis integration injects (Vercel Marketplace). */
@@ -17,3 +18,7 @@ export declare function envNames(cwd: string, target: Target): Set<string> | nul
17
18
  export declare function setEnv(cwd: string, name: string, target: Target, value: string, force: boolean): Run | null;
18
19
  /** The gate variables missing from production or preview, or null when the CLI cannot say. */
19
20
  export declare function gateEnvMissing(cwd: string): string[] | null;
21
+ /** The signed-in account, or null when the CLI is missing or signed out. */
22
+ export declare function whoami(cwd: string): string | null;
23
+ /** `GET /v9/projects/<name>` through the CLI's own credentials, or null when it fails. */
24
+ export declare function projectInfo(cwd: string, project: string, scope: string | null): ProjectInfo | null;
@@ -54,3 +54,27 @@ export function gateEnvMissing(cwd) {
54
54
  }
55
55
  return missing;
56
56
  }
57
+ /** The signed-in account, or null when the CLI is missing or signed out. */
58
+ export function whoami(cwd) {
59
+ const out = vercel(cwd, ['whoami']);
60
+ if (out?.status !== 0)
61
+ return null;
62
+ return out.stdout.trim().split('\n').pop()?.trim() || null;
63
+ }
64
+ /** `GET /v9/projects/<name>` through the CLI's own credentials, or null when it fails. */
65
+ export function projectInfo(cwd, project, scope) {
66
+ const out = vercel(cwd, [
67
+ 'api',
68
+ `/v9/projects/${encodeURIComponent(project)}`,
69
+ '--raw',
70
+ ...(scope ? ['--scope', scope] : []),
71
+ ]);
72
+ if (out?.status !== 0)
73
+ return null;
74
+ try {
75
+ return JSON.parse(out.stdout);
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import { type Args } from './lib/cli.ts';
3
+ export declare const spec: {
4
+ readonly name: 'share';
5
+ readonly summary: 'Pre-flight, deploy to production, wait for the build, and check the live URL shows the password page. Returns the share details.';
6
+ readonly flags: {
7
+ readonly skip: {
8
+ readonly type: 'list';
9
+ readonly description: 'A pre-flight step to skip, only with the user’s word (design-hub preflight --help lists them).';
10
+ };
11
+ readonly cli: {
12
+ readonly type: 'boolean';
13
+ readonly description: 'Upload this folder with the Vercel CLI even when the project deploys on push.';
14
+ };
15
+ };
16
+ readonly output: '{ ok, via, deployment, url, gate, share: { url, password, open: [{ title, path, guide? }] }, review, next } or { ok: false, stage, ... }';
17
+ };
18
+ export declare function main({ flags }: Args<typeof spec>): Promise<{
19
+ ok: boolean;
20
+ stage: string;
21
+ error: string;
22
+ steps: {
23
+ step: "build" | "checks" | "contacts" | "elyx" | "gate" | "guides" | "lint" | "secrets" | "states" | "types";
24
+ ok: boolean;
25
+ skipped?: string;
26
+ detail?: unknown;
27
+ fix?: string;
28
+ }[];
29
+ fix: string;
30
+ via?: undefined;
31
+ deployment?: undefined;
32
+ url?: undefined;
33
+ } | {
34
+ steps?: undefined;
35
+ ok: boolean;
36
+ stage: string;
37
+ via: "cli" | "git";
38
+ deployment: string;
39
+ url: string;
40
+ error: string;
41
+ fix: string;
42
+ } | {
43
+ share: {
44
+ url: string;
45
+ password: string;
46
+ open: {
47
+ title: string;
48
+ path: string;
49
+ guide?: string | undefined;
50
+ }[];
51
+ };
52
+ review: string;
53
+ next: string;
54
+ steps?: undefined;
55
+ ok?: undefined;
56
+ stage?: undefined;
57
+ error?: undefined;
58
+ fix?: undefined;
59
+ via: "cli" | "git";
60
+ deployment: string;
61
+ url: string;
62
+ gate: string;
63
+ }>;
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+ /// <reference types="node" />
3
+ // One command from a passing project to a link that works: the pre-flight,
4
+ // the deploy (a push when the Vercel project is connected to the repo, an
5
+ // upload otherwise), the wait for the build, and a signed-out request that
6
+ // must come back as the password page. It ends with what the handover needs.
7
+ import { spawnSync } from 'node:child_process';
8
+ import { existsSync } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import { isLive } from '../core/catalog.js';
11
+ import { readEnv } from '../server/env.js';
12
+ import { DOCS, ROOT } from '../server/paths.js';
13
+ import { prototypes } from './lib/catalog.js';
14
+ import { CliError } from './lib/cli.js';
15
+ import { gateVerdict, gitConnected, nextStep, plan, productionUrl, } from './lib/deploy.js';
16
+ import { linkedOrg, linkedProject, projectInfo, STORE_ENV, vercel, whoami } from './lib/vercel.js';
17
+ import * as preflight from './preflight.js';
18
+ export const spec = {
19
+ name: 'share',
20
+ summary: 'Pre-flight, deploy to production, wait for the build, and check the live URL shows the password page. Returns the share details.',
21
+ flags: {
22
+ skip: {
23
+ type: 'list',
24
+ description: 'A pre-flight step to skip, only with the user’s word (design-hub preflight --help lists them).',
25
+ },
26
+ cli: {
27
+ type: 'boolean',
28
+ description: 'Upload this folder with the Vercel CLI even when the project deploys on push.',
29
+ },
30
+ },
31
+ output: '{ ok, via, deployment, url, gate, share: { url, password, open: [{ title, path, guide? }] }, review, next } or { ok: false, stage, ... }',
32
+ };
33
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
34
+ function git(args) {
35
+ const r = spawnSync('git', ['-C', ROOT, ...args], { encoding: 'utf8' });
36
+ return { ok: r.status === 0, out: (r.stdout ?? '').trim(), err: (r.stderr ?? '').trim() };
37
+ }
38
+ function deploymentFor(project, scope, sha) {
39
+ const out = vercel(ROOT, [
40
+ 'list',
41
+ project,
42
+ '--json',
43
+ '--limit',
44
+ '1',
45
+ '--environment',
46
+ 'production',
47
+ '-m',
48
+ `githubCommitSha=${sha}`,
49
+ ...(scope ? ['--scope', scope] : []),
50
+ ]);
51
+ if (out?.status !== 0)
52
+ return null;
53
+ try {
54
+ return JSON.parse(out.stdout).deployments[0] ?? null;
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
60
+ /** Pushes the branch and follows the deployment Vercel starts for that commit. */
61
+ async function viaGit(project, scope, branch) {
62
+ const sha = git(['rev-parse', 'HEAD']).out;
63
+ const push = git(['push', 'origin', branch]);
64
+ if (!push.ok)
65
+ throw new CliError(`git push origin ${branch} failed.`, { stderr: push.err.slice(-600) });
66
+ const start = Date.now();
67
+ for (;;) {
68
+ const step = nextStep(deploymentFor(project, scope, sha), sha, Date.now() - start);
69
+ if ('done' in step)
70
+ return step.done;
71
+ if ('error' in step)
72
+ throw new CliError(step.error, { fix: step.fix, deployment: step.deployment });
73
+ await sleep(5000);
74
+ }
75
+ }
76
+ function viaCli() {
77
+ const out = vercel(ROOT, ['deploy', '--prod', '--yes']);
78
+ if (!out)
79
+ throw new CliError('The Vercel CLI is not installed.', { fix: 'npm i -g vercel' });
80
+ const url = `${out.stdout}\n${out.stderr}`.match(/https:\/\/[\w.-]+\.vercel\.app/)?.[0];
81
+ if (out.status !== 0 || !url)
82
+ throw new CliError('vercel deploy --prod failed.', { stderr: out.stderr.trim().slice(-600) });
83
+ return url;
84
+ }
85
+ /** A signed-out request for the home page, the way a reviewer first meets the link. */
86
+ async function smoke(url) {
87
+ try {
88
+ const res = await fetch(`${url}/`, { redirect: 'manual' });
89
+ return gateVerdict({
90
+ status: res.status,
91
+ location: res.headers.get('location'),
92
+ robots: res.headers.get('x-robots-tag'),
93
+ body: await res.text(),
94
+ });
95
+ }
96
+ catch (error) {
97
+ return {
98
+ ok: false,
99
+ problem: `Could not reach ${url}: ${error instanceof Error ? error.message : error}`,
100
+ fix: 'Open the URL in a private window; a new domain can take a minute to resolve.',
101
+ };
102
+ }
103
+ }
104
+ /** What a reviewer is sent to open: each live sprint and its walkthrough. */
105
+ function opens() {
106
+ return prototypes()
107
+ .filter((p) => isLive(p) && p.kind === 'sprint')
108
+ .map((p) => ({
109
+ title: p.title,
110
+ path: `/${p.slug}/`,
111
+ ...(p.feature && existsSync(join(DOCS, 'sprints', p.feature, 'guide.md'))
112
+ ? { guide: `/guide/${p.feature}/` }
113
+ : {}),
114
+ }));
115
+ }
116
+ /** The signed-in CLI and the linked project, or the fix for whichever is missing. */
117
+ function target() {
118
+ if (!whoami(ROOT))
119
+ throw new CliError('The Vercel CLI is not installed or not signed in.', {
120
+ fix: 'design-hub signin, send the user its url, then run this again.',
121
+ });
122
+ const project = linkedProject(ROOT);
123
+ if (!project)
124
+ throw new CliError('This folder is not linked to a Vercel project.', {
125
+ fix: 'design-hub bootstrap --vercel <project> --team <team>',
126
+ });
127
+ return { project, scope: linkedOrg(ROOT) };
128
+ }
129
+ function repo(info) {
130
+ const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']).out;
131
+ const status = git(['status', '--porcelain']).out;
132
+ return {
133
+ connected: gitConnected(info) && git(['remote', 'get-url', 'origin']).ok,
134
+ branch: branch && branch !== 'HEAD' ? branch : null,
135
+ productionBranch: info?.link?.productionBranch ?? 'main',
136
+ dirty: status ? status.split('\n') : [],
137
+ };
138
+ }
139
+ /**
140
+ * Deploys by the route the plan chose. A push the remote already has starts no
141
+ * build, but a deploy after an env change still needs one, so that uploads.
142
+ */
143
+ async function deploy(route, project, scope) {
144
+ if ('error' in route)
145
+ throw new CliError(route.error, { stage: 'deploy', fix: route.fix, ...(route.detail ?? {}) });
146
+ const head = git(['rev-parse', 'HEAD']).out;
147
+ const remote = route.via === 'git' ? git(['ls-remote', 'origin', `refs/heads/${route.branch}`]).out.split(/\s/)[0] : '';
148
+ if (route.via === 'git' && remote !== head)
149
+ return { via: 'git', deployment: await viaGit(project, scope, route.branch) };
150
+ return { via: 'cli', deployment: viaCli() };
151
+ }
152
+ function handover(url) {
153
+ const env = readEnv(ROOT);
154
+ const review = STORE_ENV.every((n) => env[n]) ? 'on' : 'off';
155
+ return {
156
+ share: { url, password: env.GATE_PASSWORD ?? null, open: opens() },
157
+ review,
158
+ next: review === 'on'
159
+ ? `Send the handover (miles-deploy). First share with comments: design-hub people invite --name "<user>" --role editor --site ${url}.`
160
+ : 'Send the handover (miles-deploy). Never send GATE_SECRET.',
161
+ };
162
+ }
163
+ export async function main({ flags }) {
164
+ const { project, scope } = target();
165
+ const checked = await preflight.main({ flags: { skip: flags.skip, 'allow-contact': [] }, positionals: [] });
166
+ if (!checked.ok)
167
+ return {
168
+ ok: false,
169
+ stage: 'preflight',
170
+ error: 'The pre-flight failed; nothing was deployed.',
171
+ steps: checked.steps.filter((s) => !s.ok),
172
+ fix: 'Fix each step (miles-deploy says how), then run this again.',
173
+ };
174
+ const info = projectInfo(ROOT, project, scope);
175
+ const { via, deployment } = await deploy(plan(repo(info), flags.cli), project, scope);
176
+ const url = productionUrl(projectInfo(ROOT, project, scope) ?? info, project);
177
+ const gate = await smoke(url);
178
+ if (!gate.ok)
179
+ return { ok: false, stage: 'gate', via, deployment, url, error: gate.problem, fix: gate.fix };
180
+ return { via, deployment, url, gate: 'ok', ...handover(url) };
181
+ }
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import { type Args } from './lib/cli.ts';
3
+ export declare const spec: {
4
+ readonly name: 'signin';
5
+ readonly summary: 'Sign the Vercel CLI in from a link the user clicks. Returns the link at once; --wait blocks until signed in.';
6
+ readonly flags: {
7
+ readonly wait: {
8
+ readonly type: 'number';
9
+ readonly description: 'Seconds to wait for the user to approve the link. Absent, return the link without waiting.';
10
+ };
11
+ };
12
+ readonly output: '{ ok, signedIn, user? } or { ok, signedIn: false, url, code, next }';
13
+ };
14
+ export declare function main({ flags }: Args<typeof spec>): Promise<{
15
+ signedIn: boolean;
16
+ user: string;
17
+ } | {
18
+ user?: undefined;
19
+ url: string;
20
+ code: string;
21
+ signedIn: boolean;
22
+ next: string;
23
+ } | {
24
+ user?: undefined;
25
+ url: string;
26
+ code: string;
27
+ ok: boolean;
28
+ signedIn: boolean;
29
+ error: string;
30
+ fix: string;
31
+ }>;
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ /// <reference types="node" />
3
+ // Signing in to Vercel without a terminal. `vercel login` is a device sign-in:
4
+ // it prints a link, then waits until someone approves it in a browser. This
5
+ // starts it in the background and returns the link at once, so the agent sends
6
+ // it to the user as one click; `--wait` then blocks until the CLI is signed in.
7
+ import { spawn } from 'node:child_process';
8
+ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, writeFileSync } from 'node:fs';
9
+ import { homedir } from 'node:os';
10
+ import { dirname, join } from 'node:path';
11
+ import { ROOT } from '../server/paths.js';
12
+ import { CliError } from './lib/cli.js';
13
+ import { deviceLink } from './lib/deploy.js';
14
+ import { whoami } from './lib/vercel.js';
15
+ export const spec = {
16
+ name: 'signin',
17
+ summary: 'Sign the Vercel CLI in from a link the user clicks. Returns the link at once; --wait blocks until signed in.',
18
+ flags: {
19
+ wait: {
20
+ type: 'number',
21
+ description: 'Seconds to wait for the user to approve the link. Absent, return the link without waiting.',
22
+ },
23
+ },
24
+ output: '{ ok, signedIn, user? } or { ok, signedIn: false, url, code, next }',
25
+ };
26
+ // A device code lasts about fifteen minutes; reuse a pending one for less than that.
27
+ const PENDING_MS = 10 * 60_000;
28
+ const LINK_TIMEOUT_MS = 20_000;
29
+ function stateDir() {
30
+ const config = process.env.XDG_CONFIG_HOME || join(homedir(), '.config');
31
+ return join(config, 'design-hub');
32
+ }
33
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
34
+ function alive(pid) {
35
+ try {
36
+ process.kill(pid, 0);
37
+ return true;
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ }
43
+ function readPending(file) {
44
+ if (!existsSync(file))
45
+ return null;
46
+ try {
47
+ const p = JSON.parse(readFileSync(file, 'utf8'));
48
+ return Date.now() - p.at < PENDING_MS && alive(p.pid) ? p : null;
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ /** Starts `vercel login` detached, its output in a log, and reads the link back from the log. */
55
+ async function start() {
56
+ const dir = stateDir();
57
+ mkdirSync(dir, { recursive: true });
58
+ const log = join(dir, 'vercel-login.log');
59
+ const fd = openSync(log, 'w');
60
+ const child = spawn('vercel', ['login'], { cwd: ROOT, detached: true, stdio: ['ignore', fd, fd] });
61
+ closeSync(fd);
62
+ const failed = new Promise((resolve) => child.once('error', resolve));
63
+ child.unref();
64
+ const deadline = Date.now() + LINK_TIMEOUT_MS;
65
+ while (Date.now() < deadline) {
66
+ const error = await Promise.race([failed, sleep(250).then(() => null)]);
67
+ if (error)
68
+ throw new CliError('The Vercel CLI is not installed.', {
69
+ fix: 'npm i -g vercel, then run this again.',
70
+ });
71
+ const link = deviceLink(readFileSync(log, 'utf8'));
72
+ if (link)
73
+ return { pid: child.pid ?? 0, ...link, at: Date.now() };
74
+ if (child.exitCode !== null)
75
+ break;
76
+ }
77
+ throw new CliError('vercel login printed no sign-in link.', {
78
+ log: readFileSync(log, 'utf8').slice(-600),
79
+ fix: 'Ask the user to run `vercel login` in their terminal.',
80
+ });
81
+ }
82
+ async function waitFor(seconds) {
83
+ const deadline = Date.now() + seconds * 1000;
84
+ for (;;) {
85
+ const user = whoami(ROOT);
86
+ if (user || Date.now() >= deadline)
87
+ return user;
88
+ await sleep(2000);
89
+ }
90
+ }
91
+ export async function main({ flags }) {
92
+ const user = whoami(ROOT);
93
+ if (user)
94
+ return { signedIn: true, user };
95
+ const file = join(stateDir(), 'vercel-login.json');
96
+ let pending = readPending(file);
97
+ if (!pending) {
98
+ pending = await start();
99
+ mkdirSync(dirname(file), { recursive: true });
100
+ writeFileSync(file, `${JSON.stringify(pending)}\n`);
101
+ }
102
+ const link = { url: pending.url, code: pending.code };
103
+ if (flags.wait === undefined)
104
+ return {
105
+ signedIn: false,
106
+ ...link,
107
+ next: 'Send the user the url to approve in their browser, then run design-hub signin --wait 300.',
108
+ };
109
+ const after = await waitFor(flags.wait);
110
+ if (after)
111
+ return { signedIn: true, user: after };
112
+ return {
113
+ ok: false,
114
+ signedIn: false,
115
+ ...link,
116
+ error: `Not approved within ${flags.wait}s.`,
117
+ fix: 'Check the user opened the url and chose Allow; run design-hub signin --wait again.',
118
+ };
119
+ }
@@ -2,12 +2,19 @@
2
2
  import type { Args } from './lib/cli.ts';
3
3
  export declare const spec: {
4
4
  readonly name: 'skills';
5
- readonly summary: "Install or update the project's miles-* skills from this package into .claude/skills/.";
5
+ readonly summary: "Install or update the project's miles-* skills from this package into .claude/skills/, and add any package.json script they call that the project lacks.";
6
6
  readonly flags: {};
7
- readonly output: '{ ok, installed: [name], into }';
7
+ readonly output: '{ ok, installed: [name], into, scripts: { added: [name] } }';
8
8
  };
9
9
  export declare function installSkills(from?: string, into?: string): string[];
10
+ /** The scripts a project's package.json carries, as the template writes them. The skills call them by these names. */
11
+ export declare const SCRIPTS: Record<string, string>;
12
+ /** Adds each missing script to the project's package.json; a script the project already has is never changed. */
13
+ export declare function addScripts(file?: string): string[];
10
14
  export declare function main(_args: Args<typeof spec>): {
11
15
  installed: string[];
12
16
  into: string;
17
+ scripts: {
18
+ added: string[];
19
+ };
13
20
  };
@@ -4,15 +4,17 @@
4
4
  // into the project's .claude/skills/, replacing what is there. The skills
5
5
  // ship with the package so a version bump updates them; a project never
6
6
  // edits its copies. `miles-design-hub` stays out: it starts a project from
7
- // outside one and is installed globally.
8
- import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
7
+ // outside one and is installed globally. It also adds the package.json
8
+ // scripts a newer version's skills call, since an upgrade never touches the
9
+ // project's own files and a skill that runs `pnpm share` needs the script.
10
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
9
11
  import { join } from 'node:path';
10
- import { PACKAGE_SKILLS, SKILLS } from '../server/paths.js';
12
+ import { PACKAGE_SKILLS, ROOT, SKILLS } from '../server/paths.js';
11
13
  export const spec = {
12
14
  name: 'skills',
13
- summary: "Install or update the project's miles-* skills from this package into .claude/skills/.",
15
+ summary: "Install or update the project's miles-* skills from this package into .claude/skills/, and add any package.json script they call that the project lacks.",
14
16
  flags: {},
15
- output: '{ ok, installed: [name], into }',
17
+ output: '{ ok, installed: [name], into, scripts: { added: [name] } }',
16
18
  };
17
19
  const GLOBAL_ONLY = new Set(['miles-design-hub']);
18
20
  /** Skills the package no longer ships, removed from a project on update. miles-conductor became miles-worktrees in 0.2.0. */
@@ -33,6 +35,46 @@ export function installSkills(from = PACKAGE_SKILLS, into = SKILLS) {
33
35
  }
34
36
  return names;
35
37
  }
38
+ /** The scripts a project's package.json carries, as the template writes them. The skills call them by these names. */
39
+ export const SCRIPTS = {
40
+ dev: 'design-hub dev',
41
+ build: 'design-hub build',
42
+ preview: 'design-hub preview',
43
+ export: 'design-hub export',
44
+ bootstrap: 'design-hub bootstrap',
45
+ new: 'design-hub new',
46
+ tracks: 'design-hub tracks',
47
+ guide: 'design-hub guide',
48
+ check: 'design-hub check',
49
+ fix: 'design-hub check --fix',
50
+ guard: 'design-hub guard',
51
+ preflight: 'design-hub preflight',
52
+ signin: 'design-hub signin',
53
+ share: 'design-hub share',
54
+ comments: 'design-hub comments',
55
+ people: 'design-hub people',
56
+ calibrate: 'design-hub calibrate',
57
+ 'fixtures-pull': 'design-hub fixtures-pull',
58
+ 'visual-match': 'design-hub visual-match',
59
+ elyx: 'design-hub elyx',
60
+ skills: 'design-hub skills',
61
+ commands: 'design-hub commands',
62
+ };
63
+ /** Adds each missing script to the project's package.json; a script the project already has is never changed. */
64
+ export function addScripts(file = join(ROOT, 'package.json')) {
65
+ if (!existsSync(file))
66
+ return [];
67
+ const pkg = JSON.parse(readFileSync(file, 'utf8'));
68
+ const scripts = pkg.scripts ?? {};
69
+ const added = Object.keys(SCRIPTS).filter((name) => !(name in scripts));
70
+ if (!added.length)
71
+ return [];
72
+ for (const name of added)
73
+ scripts[name] = SCRIPTS[name];
74
+ pkg.scripts = scripts;
75
+ writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
76
+ return added;
77
+ }
36
78
  export function main(_args) {
37
- return { installed: installSkills(), into: SKILLS };
79
+ return { installed: installSkills(), into: SKILLS, scripts: { added: addScripts() } };
38
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milesroxas/design-hub",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the password gate, the kit, and the design-hub CLI. A project installs it and keeps only its prototypes, kit materials and docs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  name: miles-deploy
3
- description: "Deploy the prototypes to Vercel behind the password gate and hand out the share link: the pre-flight (pnpm preflight), the GATE_* env, the review store for comments, the handover message. Load when the user asks to deploy, share, send a link, set or rotate the password, turn on comments, or check the work before any of those. Triggers on: deploy, share, share link, send to the client, Vercel, password, gate, GATE_PASSWORD, production, preview URL, pre-flight, preflight, ready to send, turn on comments, review store."
3
+ description: "Deploy the prototypes to Vercel behind the password gate and hand out the share link: the pre-flight (pnpm preflight), the GATE_* env, the review store for comments, the handover message. Load when the user asks to deploy, share, send a link, set or rotate the password, turn on comments, or check the work before any of those. Triggers on: deploy, share, share link, send to the client, send it to the team, put it online, publish, go live, update the link, push the latest, Vercel, sign in to Vercel, vercel login, password, gate, GATE_PASSWORD, production, preview URL, pre-flight, preflight, ready to send, turn on comments, review store, invite someone."
4
4
  ---
5
5
 
6
6
  # Deploy
7
7
 
8
- Pushing `main` deploys the project to the linked Vercel project. Every path sits behind the gate in `proxy.ts`: the shared password opens it to view, and an invite link opens it to one named person who can comment. The mechanics are scripts; this skill decides when they run and what the user is told.
8
+ `pnpm share` deploys the project to the linked Vercel project and checks the live link; the user never types a command. Every path sits behind the gate in `proxy.ts`: the shared password opens it to view, and an invite link opens it to one named person who can comment. The mechanics are scripts; this skill decides when they run and what the user is told.
9
9
 
10
10
  ## Before every link goes out
11
11
 
12
- Run from the project root:
12
+ `pnpm share` runs this first and stops on a failure; run it alone to check without deploying:
13
13
 
14
14
  ```bash
15
15
  pnpm preflight
@@ -29,30 +29,37 @@ step failed?
29
29
 
30
30
  Never send the link with a failed step, and never skip one with `--skip` without the user's word. Why: the link is what the client signs off on, and every step guards something they would see (a private phone number, a state nobody listed, a page that will not load).
31
31
 
32
+ ## Signing in
33
+
34
+ Every Vercel step needs the CLI signed in. The user never opens a terminal for it:
35
+
36
+ ```bash
37
+ pnpm signin
38
+ ```
39
+
40
+ Signed in, it prints `signedIn: true` and the account. Signed out, it starts the sign-in in the background and prints a `url` at once. Send the user that link to open and approve, then run `pnpm signin --wait 300`, which returns when they have. Why a link: `vercel login` is a device sign-in that waits for a browser click, so a terminal adds nothing but a step the user can get wrong. Any command below that answers "not signed in" gets the same treatment.
41
+
32
42
  ## First deploy
33
43
 
34
- 1. The user signs in once, in their own terminal: `vercel login`. It is interactive; never run it for them.
35
- 2. From the project root:
44
+ 1. `pnpm signin` (above).
45
+ 2. Ask which Vercel team the project goes in when `vercel teams ls` lists more than one. Then, from the project root:
36
46
  ```bash
37
- pnpm bootstrap --vercel <project-name> --team <team-slug>
47
+ pnpm bootstrap --vercel <project-name> --team <team-slug> [--review]
38
48
  ```
39
- `--team` is the Vercel team the project is created in (`vercel teams ls` lists them); without it the CLI's current team wins, which is often not the one the user means. It links the project, writes `GATE_PASSWORD` (12 readable characters, or `--gate-password <word>`) and a fresh `GATE_SECRET` to `.env` and to Production and Preview, and prints the password in `share.password`. A second run keeps what is set.
40
- 3. `pnpm preflight`, then push `main` (or `vercel --prod` from the project root).
41
- 4. On a Pro team Vercel turns Vercel Authentication on for every new project, which sends each visitor to a Vercel login before the gate. Turn it off for Production once: Project Settings, Deployment Protection, Vercel Authentication, set to Only Preview Deployments or Disabled. The hub's gate is the protection. Test by opening the production URL in a private window: the password page must appear, not vercel.com.
42
- 5. The handover message, in one message: the URL, the password, which prototype to open (the sprint's slug), the walkthrough at `/guide/<feature>/`, and that Controls is the round button at the top of the page. A reviewer who is not told about Controls reviews one state. Never send `GATE_SECRET`.
49
+ `--team` is the team the project is created in; without it the CLI's current team wins, which is often not the one the user means. It links the project, connects it to the GitHub repo (`vercel.git`: `connected`, `kept`, or `none` with a warning), turns Vercel Authentication off (the hub's gate is the protection), writes `GATE_PASSWORD` (12 readable characters, or `--gate-password <word>`) and a fresh `GATE_SECRET` to `.env` and to Production and Preview, and prints the password in `share.password`. `--review` also adds the comment store (see Comments). A second run keeps what is set.
50
+ 3. Deploy:
51
+ ```bash
52
+ pnpm share
53
+ ```
54
+ It runs the pre-flight, deploys, waits for the build, and requests the production URL signed out, which must answer with the password page. Connected to the repo and on a clean `main`, it pushes and follows the build for that commit; otherwise it uploads the folder with the Vercel CLI. It refuses uncommitted changes rather than deploy something other than the commit: ask the user before committing. `ok: false` names the `stage` (`preflight`, `deploy` or `gate`) and the fix; a failed pre-flight step is walked as above, and nothing deploys until it passes.
55
+ 4. The handover message, from the JSON's `share`, in one message: the `url`, the `password`, which prototype to open (`share.open`: its path and its walkthrough), and that Controls is the round button at the top of the page. A reviewer who is not told about Controls reviews one state. Never send `GATE_SECRET`.
43
56
 
44
57
  ## Comments
45
58
 
46
- Ask the user once whether reviewers should comment on the link. If yes:
47
-
48
- ```bash
49
- pnpm bootstrap --vercel <project> --review [--typesafe-key <key>]
50
- ```
51
-
52
- It adds Upstash Redis to the project through the Vercel Marketplace and copies the store's credentials into `.env`. If it stops on the Marketplace terms, the user runs `vercel integration add upstash/upstash-kv` once in their terminal, then you rerun. With TypeSafe on, comments are sorted by kind and state as they arrive. Redeploy so the env reaches the site, then invite the first editor:
59
+ Ask the user once whether reviewers should comment on the link; ask before the first deploy, so one `bootstrap` carries `--review`. If yes, `--review [--typesafe-key <key>]` adds Upstash Redis to the project through the Vercel Marketplace and copies the store's credentials into `.env`. The first time on a team it can stop on the Marketplace terms: send the user the link in its `fix` to accept, then rerun. With TypeSafe on, comments are sorted by kind and state as they arrive. `pnpm share` after it, so the env reaches the site, then invite the first editor:
53
60
 
54
61
  ```bash
55
- pnpm people invite --name "<user>" --team "<studio>" --role editor --site https://<deployment>
62
+ pnpm people invite --name "<user>" --team "<studio>" --role editor --site <share.url>
56
63
  ```
57
64
 
58
65
  Send them the link; from then on, editors invite reviewers from the People tab. `miles-review` owns working from the comments.
@@ -60,7 +67,7 @@ Send them the link; from then on, editors invite reviewers from the People tab.
60
67
  ## Rotating access
61
68
 
62
69
  - **A reviewer leaves:** revoke them in the People tab, or `pnpm people revoke <id>`. Their sessions end on their next page load.
63
- - **The shared password leaked:** `pnpm bootstrap --vercel <project> --gate-password <new>`, then redeploy. Every password visitor signs in again; invited people are not affected.
70
+ - **The shared password leaked:** `pnpm bootstrap --vercel <project> --gate-password <new>`, then `pnpm share`. Every password visitor signs in again; invited people are not affected.
64
71
 
65
72
  ## Security, never weakened for a prototype
66
73
 
@@ -48,7 +48,12 @@ The tracks decide everything a shell question used to: product draws `AppShell`,
48
48
  | TypeSafe | Turn on TypeSafe's Jev checks? | Off (Recommended) · On: I have an API key. Why opt-in: a template anyone can use cannot require a paid account. |
49
49
  | Conductor | Will the project run in Conductor workspaces? | No (Recommended) · Yes, landing on `main` · Yes, on another branch (they type it in "Other") |
50
50
 
51
- **Round 3: the front end, only for Payload or WordPress.** One question: Astro (Recommended) · Next.js. Webflow renders its own pages and EmDash is always Astro, so neither is asked.
51
+ **Round 3: the share link, and the front end.** Ask Front end only for Payload or WordPress: Webflow renders its own pages and EmDash is always Astro.
52
+
53
+ | Header | Question | Options |
54
+ |---|---|---|
55
+ | Share | Put the prototypes on a password-protected link now? | Yes, with comments (Recommended) · Yes, view only · Later. Why now: everything it needs is answered in one sitting, and the first link proves the deploy works before there is client work on it. |
56
+ | Front end | Which front end will the site use? | Astro (Recommended) · Next.js |
52
57
 
53
58
  **Round 4: typed answers, one short chat message each, only for what was chosen.**
54
59
 
@@ -58,7 +63,7 @@ The tracks decide everything a shell question used to: product draws `AppShell`,
58
63
 
59
64
  Without a question tool (another agent, or a host that lacks one), ask everything in one message with defaults in brackets, and wait for every answer. Nothing in steps 3 to 6 runs until every round is answered.
60
65
 
61
- Comments and the share link come later, with `miles-deploy`, because they need a Vercel project.
66
+ With Share answered Later, comments and the share link come later, with `miles-deploy`.
62
67
 
63
68
  ## 3. Create the project
64
69
 
@@ -77,6 +82,18 @@ pnpm --dir <path> bootstrap [--typesafe-key <key>] [--conductor --branch <branch
77
82
 
78
83
  It picks a port nothing holds and no other project claims, writes it to `.env` and `.claude/launch.json`, and applies the flags. Read the JSON's `warnings`. With the skills answered globally: `npx skills add milesroxas/design-hub -g -y`.
79
84
 
85
+ ## 4b. Put it on a link, when Share was a yes
86
+
87
+ The user does nothing in a terminal here; each step that needs them is one link to click.
88
+
89
+ 1. `pnpm --dir <path> signin`. Signed out, it prints a `url`: send it to the user to approve, then `pnpm --dir <path> signin --wait 300`.
90
+ 2. `vercel teams ls`; with more than one team, ask which with the question tool (personal account first when it is listed).
91
+ 3. `pnpm --dir <path> bootstrap --vercel <name> --team <team-slug>`, plus `--review` for comments. It links the project, connects the GitHub repo, sets the password and turns Vercel's own login off. A first `--review` on a team can stop on the Marketplace terms: send the user the link in `fix`, then rerun.
92
+ 4. `pnpm --dir <path> share --cli`. `--cli` uploads the folder, since the setup may have left files uncommitted; later deploys push `main`. On `ok: false`, follow `stage` and `fix` (the pre-flight steps are in `miles-deploy`).
93
+ 5. With comments: `pnpm --dir <path> people invite --name "<user>" --role editor --site <share.url>`.
94
+
95
+ Give the user `share.url`, `share.password` and the invite link in the closing message, and say the link shows the samples until the first feature replaces them.
96
+
80
97
  ## 5. Record what was answered
81
98
 
82
99
  Write the shell of each track under `DESIGN.md`, Shell: product is `AppShell`, website is `SiteShell`, brand has none; add the Paper frames that hold each, or "from the sample" without Paper. It is built once and every later session reads it instead of asking. The tracks themselves live in `.design-hub/project.json`; never copy them into prose that could drift from it. Fill `PRODUCT.md` from what the user said about the product; leave a section empty only when they said nothing about it, and say so.
@@ -94,4 +111,4 @@ Write the shell of each track under `DESIGN.md`, Shell: product is `AppShell`, w
94
111
 
95
112
  The next step is `miles-new-feature`.
96
113
 
97
- Close with the path, the port, the repo URL when there is one, the tracks and the website platform, whether TypeSafe is on, and the one command that starts the server. Nothing is committed unless the user asks.
114
+ Close with the path, the port, the repo URL when there is one, the share link, password and invite when Share was a yes, the tracks and the website platform, whether TypeSafe is on, and the one command that starts the server. Nothing is committed unless the user asks.