@milesroxas/design-hub 0.6.2 → 0.7.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 (46) hide show
  1. package/README.md +16 -6
  2. package/core/review/model.ts +82 -6
  3. package/core/review/policy.test.ts +2 -0
  4. package/core/review/policy.ts +2 -2
  5. package/core/review/service.test.ts +397 -27
  6. package/core/review/service.ts +168 -36
  7. package/core/review/store.ts +22 -4
  8. package/dist/core/review/model.d.ts +35 -4
  9. package/dist/core/review/model.js +66 -4
  10. package/dist/core/review/service.d.ts +24 -6
  11. package/dist/core/review/service.js +155 -36
  12. package/dist/core/review/store.d.ts +15 -4
  13. package/dist/core/review/store.js +19 -3
  14. package/dist/scripts/bootstrap.d.ts +16 -14
  15. package/dist/scripts/bootstrap.js +56 -39
  16. package/dist/scripts/lib/deploy.d.ts +12 -4
  17. package/dist/scripts/lib/deploy.js +47 -13
  18. package/dist/scripts/lib/vercel.d.ts +8 -2
  19. package/dist/scripts/lib/vercel.js +23 -9
  20. package/dist/scripts/people.d.ts +13 -26
  21. package/dist/scripts/people.js +68 -35
  22. package/dist/scripts/preflight.js +2 -2
  23. package/dist/scripts/share.d.ts +2 -3
  24. package/dist/scripts/share.js +18 -10
  25. package/dist/server/api.d.ts +6 -2
  26. package/dist/server/api.js +53 -22
  27. package/dist/server/fake-upstash.js +3 -2
  28. package/dist/server/local.js +2 -0
  29. package/dist/server/session.d.ts +25 -10
  30. package/dist/server/session.js +69 -52
  31. package/dist/server/upstash.js +4 -3
  32. package/dist/vercel/proxy.d.ts +5 -3
  33. package/dist/vercel/proxy.js +183 -157
  34. package/dist/vite/plugin.js +5 -5
  35. package/package.json +2 -2
  36. package/shell/review/People.tsx +178 -45
  37. package/shell/review/Review.tsx +7 -7
  38. package/shell/review/client.ts +36 -17
  39. package/shell/review/review.css +2 -0
  40. package/skills/miles-deploy/SKILL.md +44 -16
  41. package/skills/miles-design-hub/SKILL.md +5 -5
  42. package/skills/miles-new-feature/SKILL.md +1 -1
  43. package/skills/miles-review/SKILL.md +7 -5
  44. package/skills/miles-worktrees/SKILL.md +1 -1
  45. package/templates/conductor/settings.toml +1 -1
  46. package/templates/guide.md +1 -1
@@ -1,8 +1,11 @@
1
- // The People card, for Studio: invite someone, hand over their link, and see
2
- // who can comment.
1
+ // The People card, for Studio: add someone, hand over their one-time link,
2
+ // and see who can comment and until when. A link signs in one device, then
3
+ // stops working, so each row offers another link for another device, a sign
4
+ // out everywhere, a change of access length, and Revoke.
5
+ import { fmtDate } from '@kit/format';
3
6
  import { Button, Select } from '@kit/ui';
4
- import { type FormEvent, useId, useRef, useState } from 'react';
5
- import { INVITE_DAYS, LIMITS, type PersonKind } from '../../core/review/model';
7
+ import { type FormEvent, type ReactNode, useId, useRef, useState } from 'react';
8
+ import { type Access, LIMITS, LINK_DAYS, type PersonKind } from '../../core/review/model';
6
9
  import { Action } from './Card';
7
10
  import { act, type Me, type ReviewStore } from './client';
8
11
 
@@ -15,15 +18,40 @@ const KIND_OPTIONS: { value: PersonKind; label: string; desc: string }[] = [
15
18
  {
16
19
  value: 'studio',
17
20
  label: KIND_NAMES.studio,
18
- desc: 'Also sorts, deletes any comment and invites',
21
+ desc: 'Also sorts, deletes any comment and manages people',
19
22
  },
20
23
  ];
21
24
 
22
- function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link) => void }) {
25
+ const ACCESS_NAMES: Record<Access, string> = { '3m': '3 months', '6m': '6 months', open: 'Open-ended' };
26
+
27
+ const LENGTH_OPTIONS: { value: Access; label: string }[] = [
28
+ { value: '3m', label: ACCESS_NAMES['3m'] },
29
+ { value: '6m', label: ACCESS_NAMES['6m'] },
30
+ { value: 'open', label: ACCESS_NAMES.open },
31
+ ];
32
+
33
+ /** The add form's choices: the default for this kind first, then each length. */
34
+ function accessOptions(kind: PersonKind, projectDefault: Access | null) {
35
+ const fallback =
36
+ kind === 'studio' ? 'Open-ended for Studio' : `Project default: ${ACCESS_NAMES[projectDefault ?? '3m']}`;
37
+ return [{ value: 'default', label: 'Default', desc: fallback }, ...LENGTH_OPTIONS];
38
+ }
39
+
40
+ function AddForm({
41
+ store,
42
+ projectDefault,
43
+ onLink,
44
+ }: {
45
+ store: ReviewStore;
46
+ projectDefault: Access | null;
47
+ onLink: (link: Link) => void;
48
+ }) {
23
49
  const [kind, setKind] = useState<PersonKind>('client');
50
+ const [access, setAccess] = useState('default');
24
51
  const [busy, setBusy] = useState(false);
25
52
  const kindLabel = useId();
26
- const invite = (e: FormEvent<HTMLFormElement>) => {
53
+ const accessLabel = useId();
54
+ const add = (e: FormEvent<HTMLFormElement>) => {
27
55
  e.preventDefault();
28
56
  const form = e.currentTarget;
29
57
  const f = new FormData(form);
@@ -31,7 +59,7 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
31
59
  setBusy(true);
32
60
  act(
33
61
  store
34
- .invite(name, String(f.get('team') ?? ''), kind)
62
+ .addPerson(name, String(f.get('team') ?? ''), kind, access === 'default' ? null : (access as Access))
35
63
  .then((href) => {
36
64
  onLink({ name, href });
37
65
  form.reset();
@@ -40,7 +68,7 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
40
68
  );
41
69
  };
42
70
  return (
43
- <form className="rv-invite" onSubmit={invite}>
71
+ <form className="rv-invite" onSubmit={add}>
44
72
  <label className="field">
45
73
  <span className="field-label">Name</span>
46
74
  <input
@@ -75,7 +103,19 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
75
103
  onChange={(next) => setKind(next as PersonKind)}
76
104
  />
77
105
  </div>
78
- <Button type="submit" kind="primary" size={null} label="Create invite link" busy={busy} />
106
+ <div className="field">
107
+ <span id={accessLabel} className="field-label">
108
+ Access
109
+ </span>
110
+ <Select
111
+ labelId={accessLabel}
112
+ menuClassName="rv-menu"
113
+ value={access}
114
+ options={accessOptions(kind, projectDefault)}
115
+ onChange={setAccess}
116
+ />
117
+ </div>
118
+ <Button type="submit" kind="primary" size={null} label="Create link" busy={busy} />
79
119
  </form>
80
120
  );
81
121
  }
@@ -92,7 +132,8 @@ function ShareLink({ link }: { link: Link }) {
92
132
  return (
93
133
  <div className="rv-share" role="status">
94
134
  <p>
95
- Send this link to {link.name}. It works for {INVITE_DAYS} days, and a new link replaces it.
135
+ Send this link to {link.name} only. It signs in one device, then stops working. Unused, it lasts{' '}
136
+ {LINK_DAYS} days.
96
137
  </p>
97
138
  <div className="rv-share-row">
98
139
  <input
@@ -100,7 +141,7 @@ function ShareLink({ link }: { link: Link }) {
100
141
  className="input"
101
142
  readOnly
102
143
  value={link.href}
103
- aria-label={`Invite link for ${link.name}`}
144
+ aria-label={`Sign-in link for ${link.name}`}
104
145
  onFocus={(e) => e.currentTarget.select()}
105
146
  />
106
147
  <Button size={null} className="rv-copy" label={copied ? 'Copied' : 'Copy'} onClick={copy} />
@@ -109,48 +150,141 @@ function ShareLink({ link }: { link: Link }) {
109
150
  );
110
151
  }
111
152
 
112
- function PersonRow({
113
- person,
114
- store,
115
- onLink,
153
+ /** How links behave, said once where Studio shares them. */
154
+ function HowLinksWork() {
155
+ return (
156
+ <p className="rv-muted rv-disclosure">
157
+ Each person gets their own link. A link signs in one device, then stops working, so a second device
158
+ needs a new link. An unused link lasts {LINK_DAYS} days. Revoking someone ends their access everywhere.
159
+ </p>
160
+ );
161
+ }
162
+
163
+ const ended = (p: Me) => p.accessEndsAt !== null && p.accessEndsAt <= new Date().toISOString();
164
+
165
+ /** When someone's access ends, as the row says it. */
166
+ function accessText(p: Me): string {
167
+ if (p.accessEndsAt === null) return 'open-ended';
168
+ const day = fmtDate(p.accessEndsAt.slice(0, 10));
169
+ return ended(p) ? `access ended ${day}` : `until ${day}`;
170
+ }
171
+
172
+ type Mode = 'idle' | 'signOut' | 'revoke' | 'access';
173
+
174
+ function Confirm({
175
+ text,
176
+ label,
177
+ onYes,
178
+ onNo,
116
179
  }: {
117
- person: Me;
118
- store: ReviewStore;
119
- onLink: (link: Link) => void;
180
+ text: string;
181
+ label: string;
182
+ onYes: () => void;
183
+ onNo: () => void;
120
184
  }) {
121
- const [confirming, setConfirming] = useState(false);
122
185
  return (
123
- <div className="rv-row rv-acts">
124
- {confirming ? (
125
- <>
126
- <span className="rv-confirm">Remove {person.name}’s access?</span>
127
- <Action
128
- label="Revoke"
129
- danger
130
- onClick={() => act(store.revoke(person.id).then(() => setConfirming(false)))}
131
- />
132
- <Action label="Keep" onClick={() => setConfirming(false)} />
133
- </>
134
- ) : (
135
- <>
136
- <Action
137
- label="New link"
138
- onClick={() => act(store.reissue(person.id).then((href) => onLink({ name: person.name, href })))}
139
- />
140
- <Action label="Revoke" onClick={() => setConfirming(true)} />
141
- </>
142
- )}
143
- </div>
186
+ <>
187
+ <span className="rv-confirm">{text}</span>
188
+ <Action label={label} danger onClick={onYes} />
189
+ <Action label="Keep" onClick={onNo} />
190
+ </>
191
+ );
192
+ }
193
+
194
+ function AccessPicker({ person, store, onDone }: { person: Me; store: ReviewStore; onDone: () => void }) {
195
+ const label = useId();
196
+ return (
197
+ <>
198
+ <span id={label} className="rv-confirm">
199
+ Access from today
200
+ </span>
201
+ <Select
202
+ labelId={label}
203
+ menuClassName="rv-menu"
204
+ value={null}
205
+ placeholder="Choose"
206
+ options={LENGTH_OPTIONS}
207
+ onChange={(next) => act(store.setAccess(person.id, next as Access).then(onDone))}
208
+ />
209
+ <Action label="Cancel" onClick={onDone} />
210
+ </>
211
+ );
212
+ }
213
+
214
+ type RowProps = { person: Me; store: ReviewStore; onLink: (link: Link) => void };
215
+
216
+ function PersonActions({ person, store, onLink, setMode }: RowProps & { setMode: (m: Mode) => void }) {
217
+ const linked = (pending: Promise<string>) =>
218
+ act(pending.then((href) => onLink({ name: person.name, href })));
219
+ // A link would open nothing once access has ended, so the row offers the fix instead.
220
+ if (ended(person))
221
+ return (
222
+ <>
223
+ <Action label="Change access" onClick={() => setMode('access')} />
224
+ <Action label="Revoke" onClick={() => setMode('revoke')} />
225
+ </>
226
+ );
227
+ return (
228
+ <>
229
+ <Action label="New link" onClick={() => linked(store.newLink(person.id))} />
230
+ <Action label="Sign out everywhere" onClick={() => setMode('signOut')} />
231
+ <Action label="Access" onClick={() => setMode('access')} />
232
+ <Action label="Revoke" onClick={() => setMode('revoke')} />
233
+ </>
144
234
  );
145
235
  }
146
236
 
147
- export function People({ store, me, people }: { store: ReviewStore; me: Me | null; people: Me[] | null }) {
237
+ function PersonRow({ person, store, onLink }: RowProps) {
238
+ const [mode, setMode] = useState<Mode>('idle');
239
+ const idle = () => setMode('idle');
240
+ const views: Record<Mode, () => ReactNode> = {
241
+ idle: () => <PersonActions person={person} store={store} onLink={onLink} setMode={setMode} />,
242
+ access: () => <AccessPicker person={person} store={store} onDone={idle} />,
243
+ revoke: () => (
244
+ <Confirm
245
+ text={`Remove ${person.name}’s access everywhere?`}
246
+ label="Revoke"
247
+ onYes={() => act(store.revoke(person.id).then(idle))}
248
+ onNo={idle}
249
+ />
250
+ ),
251
+ signOut: () => (
252
+ <Confirm
253
+ text={`Sign ${person.name} out of every device? They get one new link.`}
254
+ label="Sign out"
255
+ onYes={() =>
256
+ act(
257
+ store.signOut(person.id).then((href) => {
258
+ onLink({ name: person.name, href });
259
+ idle();
260
+ }),
261
+ )
262
+ }
263
+ onNo={idle}
264
+ />
265
+ ),
266
+ };
267
+ return <div className="rv-row rv-acts">{views[mode]()}</div>;
268
+ }
269
+
270
+ export function People({
271
+ store,
272
+ me,
273
+ people,
274
+ access,
275
+ }: {
276
+ store: ReviewStore;
277
+ me: Me | null;
278
+ people: Me[] | null;
279
+ access: Access | null;
280
+ }) {
148
281
  const [link, setLink] = useState<Link | null>(null);
149
282
  return (
150
283
  <div className="rv-body">
151
- <InviteForm store={store} onLink={setLink} />
284
+ <AddForm store={store} projectDefault={access} onLink={setLink} />
152
285
  {/* Keyed by the link, so a second one starts on Copy again. */}
153
286
  {link && <ShareLink key={link.href} link={link} />}
287
+ <HowLinksWork />
154
288
  {people === null ? (
155
289
  <p className="rv-muted">Loading people…</p>
156
290
  ) : (
@@ -160,8 +294,7 @@ export function People({ store, me, people }: { store: ReviewStore; me: Me | nul
160
294
  <div className="rv-person">
161
295
  <strong>{p.name}</strong>
162
296
  <span className="rv-muted">
163
- {p.team} · {KIND_NAMES[p.kind]}
164
- {p.revokedAt && ' · revoked'}
297
+ {p.team} · {KIND_NAMES[p.kind]} · {p.revokedAt ? 'revoked' : accessText(p)}
165
298
  </span>
166
299
  </div>
167
300
  {p.id !== me?.id && !p.revokedAt && <PersonRow person={p} store={store} onLink={setLink} />}
@@ -129,16 +129,16 @@ export function Review({ prototype, feature, states }: Props) {
129
129
  );
130
130
  }
131
131
 
132
- /** With no person behind the session, comment mode is this card and nothing else. */
132
+ /**
133
+ * The session ended after the page loaded (a revoke, a sign out everywhere,
134
+ * or the end of their access): comment mode is this card and nothing else.
135
+ */
133
136
  function GuestCard({ onClose }: { onClose: () => void }) {
134
137
  return (
135
138
  <Card at={null} label="Comments" onDismiss={onClose}>
136
139
  <div className="rv-note">
137
- <strong>Comments need an invite</strong>
138
- <p>
139
- You are viewing with the shared password. Ask the team for an invite link to read and leave
140
- comments.
141
- </p>
140
+ <strong>You are signed out</strong>
141
+ <p>Ask the studio for a new link to read and leave comments.</p>
142
142
  </div>
143
143
  </Card>
144
144
  );
@@ -230,7 +230,7 @@ function PeopleCard({ store, s, onClose }: { store: ReviewStore; s: State; onClo
230
230
  onClick={onClose}
231
231
  />
232
232
  </header>
233
- <People store={store} me={s.me} people={s.people} />
233
+ <People store={store} me={s.me} people={s.people} access={s.access} />
234
234
  </Card>
235
235
  );
236
236
  }
@@ -3,10 +3,10 @@
3
3
  // call its actions; every call goes to /api/review (server/api.ts), and each
4
4
  // answer is merged in place, so a write never refetches the list.
5
5
  import { useSyncExternalStore } from 'react';
6
- import type { Anchor, Comment, Person, PersonKind } from '../../core/review/model';
6
+ import type { Access, Anchor, Comment, Person, PersonKind } from '../../core/review/model';
7
7
 
8
8
  export type Me = Omit<Person, 'epoch'>;
9
- /** off: this site has no review store, so the UI stays out of the way. */
9
+ /** off: this site has no review store, so the UI stays out of the way. guest: the session ended since the page loaded. */
10
10
  type Status = 'loading' | 'ready' | 'guest' | 'off';
11
11
 
12
12
  type State = {
@@ -14,16 +14,21 @@ type State = {
14
14
  me: Me | null;
15
15
  comments: Comment[];
16
16
  people: Me[] | null;
17
+ /** The project default access length, loaded with the people. */
18
+ access: Access | null;
17
19
  error: string | null;
18
20
  };
19
21
 
20
22
  class ApiError extends Error {
21
23
  status: number;
22
24
  problems: string[];
23
- constructor(status: number, message: string, problems: string[] = []) {
25
+ /** A 503 with Retry-After: the store did not answer, and review is on. */
26
+ retry: boolean;
27
+ constructor(status: number, message: string, problems: string[] = [], retry = false) {
24
28
  super(message);
25
29
  this.status = status;
26
30
  this.problems = problems;
31
+ this.retry = retry;
27
32
  }
28
33
  }
29
34
 
@@ -48,6 +53,8 @@ async function call<T>(
48
53
  const json = (await response.json().catch(() => null)) as
49
54
  | ({ error?: string; problems?: string[] } & T)
50
55
  | null;
56
+ if (response.status === 503 && response.headers.has('retry-after'))
57
+ throw new ApiError(503, 'The review store did not answer. Reload in a minute.', [], true);
51
58
  if (!json)
52
59
  throw new ApiError(response.status, `The review API did not answer with JSON (${response.status}).`);
53
60
  if (!response.ok)
@@ -56,7 +63,7 @@ async function call<T>(
56
63
  }
57
64
 
58
65
  export function createReviewStore(prototype: string) {
59
- let state: State = { status: 'loading', me: null, comments: [], people: null, error: null };
66
+ let state: State = { status: 'loading', me: null, comments: [], people: null, access: null, error: null };
60
67
  const listeners = new Set<() => void>();
61
68
  const set = (patch: Partial<State>) => {
62
69
  state = { ...state, ...patch };
@@ -93,6 +100,13 @@ export function createReviewStore(prototype: string) {
93
100
  throw error;
94
101
  }
95
102
  };
103
+ /** A command that answers with a person and their link: merges the person, resolves to the whole URL. */
104
+ const linkOf = (pending: Promise<{ person: Me; link: string }>) =>
105
+ attempt(async () => {
106
+ const r = await pending;
107
+ mergePerson(r.person);
108
+ return new URL(r.link, location.origin).href;
109
+ });
96
110
 
97
111
  return {
98
112
  subscribe(listener: () => void) {
@@ -108,8 +122,9 @@ export function createReviewStore(prototype: string) {
108
122
  const { comments } = await call<{ comments: Comment[] }>('comments', undefined, { prototype });
109
123
  set({ status: 'ready', me: person, comments, error: null });
110
124
  } catch (error) {
111
- // 503 is a site without a review store; 404 is a static preview with no API at all.
112
- if (error instanceof ApiError && (error.status === 503 || error.status === 404))
125
+ // 503 is a site without a review store; 404 is a static preview with no API at all. A 503 with
126
+ // Retry-After is a store that did not answer: review stays on and shows the error.
127
+ if (error instanceof ApiError && !error.retry && (error.status === 503 || error.status === 404))
113
128
  set({ status: 'off' });
114
129
  else set({ status: 'ready', error: String((error as Error).message) });
115
130
  }
@@ -143,19 +158,23 @@ export function createReviewStore(prototype: string) {
143
158
  set({ comments: state.comments.filter((c) => !removed.includes(c.id)) });
144
159
  }),
145
160
 
146
- loadPeople: () => attempt(async () => set({ people: (await call<{ people: Me[] }>('people')).people })),
147
- invite: (name: string, team: string, kind: PersonKind) =>
148
- attempt(async () => {
149
- const r = await call<{ person: Me; link: string }>('people.invite', { name, team, kind });
150
- mergePerson(r.person);
151
- return new URL(r.link, location.origin).href;
152
- }),
153
- reissue: (id: string) =>
161
+ loadPeople: () =>
154
162
  attempt(async () => {
155
- const r = await call<{ person: Me; link: string }>('people.reissue', { id });
156
- mergePerson(r.person);
157
- return new URL(r.link, location.origin).href;
163
+ const [{ people }, { access }] = await Promise.all([
164
+ call<{ people: Me[] }>('people'),
165
+ call<{ access: Access }>('access'),
166
+ ]);
167
+ set({ people, access });
158
168
  }),
169
+ /** A new person; `access` null takes the default for their kind. Resolves to their link. */
170
+ addPerson: (name: string, team: string, kind: PersonKind, access: Access | null) =>
171
+ linkOf(call('people.add', { name, team, kind, ...(access ? { access } : {}) })),
172
+ /** Another one-time link, for another device. */
173
+ newLink: (id: string) => linkOf(call('people.link', { id })),
174
+ /** Ends every session and unused link; resolves to the one new link. */
175
+ signOut: (id: string) => linkOf(call('people.signOut', { id })),
176
+ setAccess: (id: string, access: Access) =>
177
+ attempt(async () => mergePerson((await call<{ person: Me }>('people.access', { id, access })).person)),
159
178
  revoke: (id: string) =>
160
179
  attempt(async () => mergePerson((await call<{ person: Me }>('people.revoke', { id })).person)),
161
180
  clearError: () => set({ error: null }),
@@ -524,6 +524,8 @@
524
524
  .rv-share-row .input { flex: 1; min-width: 0; }
525
525
  /* Copy and Copied are one width, so the row holds still when the word changes. */
526
526
  .rv .btn.rv-copy { flex: none; width: 68px; padding: 0; }
527
+ /* How links behave: one quiet line of small print under the form. */
528
+ .rv-disclosure { font-size: 12px; line-height: 16px; }
527
529
  .rv-people { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
528
530
  .rv-people li { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--harness-border); }
529
531
  .rv-people li:last-child { border-bottom: 0; }
@@ -1,11 +1,11 @@
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, 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."
3
+ description: "Deploy the prototypes to Vercel behind the gate and hand out sign-in links: the pre-flight (pnpm preflight), GATE_SECRET, the review store that keeps people and their links, the handover message, adding people, a second device, signing someone out, how long access lasts. Load when the user asks to deploy, share, send a link, add or remove someone, give someone access on another device, change how long access lasts, 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, gate, GATE_SECRET, sign-in link, one-time link, new link, another device, link stopped working, sign out everywhere, access length, 3 months, 6 months, open-ended, password, production, preview URL, pre-flight, preflight, ready to send, turn on comments, review store, add someone, invite someone, remove someone."
4
4
  ---
5
5
 
6
6
  # Deploy
7
7
 
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.
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`. There is no password: each person is named, and signs in with their own one-time link. A link signs in one device, then stops working, so a used link opens nothing. An unused link signs in whoever opens it first, so it goes only to its person. 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
 
@@ -23,7 +23,8 @@ step failed?
23
23
  │ or, only after the user says it is a business contact:
24
24
  │ pnpm preflight --allow-contact <value>
25
25
  ├── states → add the missing rows to that README's States table (miles-prototype), then rerun
26
- ├── gate → pnpm bootstrap --vercel <project> sets GATE_PASSWORD and GATE_SECRET
26
+ ├── gate → pnpm bootstrap --vercel <project> --review sets GATE_SECRET and adds the review store
27
+ │ (KV_REST_API_URL, KV_REST_API_TOKEN): without the store nobody can sign in
27
28
  └── any other → fix what `detail` names; `fix` says how
28
29
  ```
29
30
 
@@ -44,32 +45,59 @@ Signed in, it prints `signedIn: true` and the account. Signed out, it starts the
44
45
  1. `pnpm signin` (above).
45
46
  2. Ask which Vercel team the project goes in when `vercel teams ls` lists more than one. Then, from the project root:
46
47
  ```bash
47
- pnpm bootstrap --vercel <project-name> --team <team-slug> [--review]
48
+ pnpm bootstrap --vercel <project-name> --team <team-slug> --review [--access 3m|6m|open]
48
49
  ```
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
+ `--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), and writes a fresh `GATE_SECRET` to `.env` and to Production and Preview. `--review` adds the review store, which keeps the people and their links (see The review store). Without it nobody can sign in. `--access` sets how long a new client keeps access by default (see Access). A second run keeps what is set.
50
51
  3. Deploy:
51
52
  ```bash
52
53
  pnpm share
53
54
  ```
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`.
55
+ It runs the pre-flight, deploys, waits for the build, and requests the production URL as a signed-out browser, which must answer with the sign-in page, and then a made-up sign-in link, which must answer 404: that proves the review store is wired, since nobody signs in without it. 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.
56
+ 4. Add the first Studio person, the user, and send them their link (see People).
57
+ 5. The handover message, from the JSON's `share`, one per person: their own link, which prototype to open (`share.open`: its path and its walkthrough), that Controls is the round button at the top of the page, and that the link signs in one device, then stops working, so for another device they ask for a new one. A reviewer who is not told about Controls reviews one state. Never send `GATE_SECRET`, and never send one person's link to another.
56
58
 
57
- ## Comments
59
+ ## The review store
58
60
 
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 message in its `fix` as written: it links that team's terms page, names the one product to pick (**Upstash for Redis**, Redis Compatible Database) when Vercel lists several, and tells them not to create a database there, since the rerun creates the store and connects it. Rerun when they say it is done; if `stderr` shows another cause, show it to them instead. 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 Studio person:
61
+ Every share needs it: it keeps the people, their links and their comments. Ask once whether comments should be sorted by TypeSafe; `--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 message in its `fix` as written: it links that team's terms page, names the one product to pick (**Upstash for Redis**, Redis Compatible Database) when Vercel lists several, and tells them not to create a database there, since the rerun creates the store and connects it. Rerun when they say it is done; if `stderr` shows another cause, show it to them instead. With TypeSafe on, comments are sorted by kind and state as they arrive. `pnpm share` after it, so the env reaches the site. `miles-review` owns working from the comments.
62
+
63
+ ## People
64
+
65
+ Every person is named, and each gets their own link. Add the first Studio person, the user, from here:
60
66
 
61
67
  ```bash
62
- pnpm people invite --name "<user>" --team "<studio>" --kind studio --site <share.url>
68
+ pnpm people add --name "<user>" --team "<studio>" --kind studio --site <share.url>
63
69
  ```
64
70
 
65
- Send them the link; from then on, Studio invites everyone else from the People tab. `miles-review` owns working from the comments.
71
+ Send them the `link`; from then on, Studio adds everyone else in the People tab (the round comments button, then **⋯**, **People**), or ask for it here with `pnpm people add --name "<name>" --team "<company>" --site <share.url>`. A Client is the default kind.
72
+
73
+ - **A link signs in one device, then stops working.** Opening it shows who it is for and a Continue button; Continue uses it up. Why: a mail or chat preview opens links too, and must not use one up. An unused link lasts 14 days.
74
+ - **Another device, or a link that stopped working:** `pnpm people link <id> --site <url>` gives one more link. Their other devices stay signed in.
75
+ - **A lost or shared device:** `pnpm people sign-out <id> --site <url>` ends every session (within five minutes) and every unused link (at once) they hold, and gives one new link.
76
+ - **Someone leaves:** `pnpm people revoke <id>`, or Revoke in the People tab. Their access ends on every device within five minutes, and their links stop working at once.
77
+ - `pnpm people` lists everyone, with their id and when their access ends.
78
+ - Never paste a link into a commit, a document, a ticket or a comment, and never send one to anyone but its person. Why: until it is used, whoever opens it first signs in as that person.
79
+
80
+ ## Access
81
+
82
+ A signed-in device stays signed in until the person's access ends: 3 months, 6 months, or open-ended. A new client gets the project default; a new Studio person is open-ended.
83
+
84
+ - The project default: `pnpm people access` reads it, `pnpm people access --access 6m` sets it. Absent, it is 3 months. Ask the user at the first deploy how long the engagement runs.
85
+ - One person: `pnpm people access <id> --access 3m|6m|open`, counted from today, or `--access` on `pnpm people add`.
86
+ - When someone's access ends their links stop working at once, and every device signs out within five minutes. A changed access length reaches their signed-in devices within five minutes too. Change their access to let them back in, then send a new link.
87
+
88
+ ## A project that shared before one-time links
66
89
 
67
- ## Rotating access
90
+ A project that shared with a password (before one-time links) needs this once, before its next `pnpm share`. The pre-flight `gate` step stops the share until the store is there, so production is never replaced by a gate nobody can pass.
68
91
 
69
- - **Someone leaves:** revoke them in the People tab, or `pnpm people revoke <id>`. Their sessions end on their next page load.
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.
92
+ 1. The review store is now required: `pnpm bootstrap --vercel <project> --review`. Why: people and their links live in it, so without it nobody can sign in.
93
+ 2. People, links and comments from before are not carried over. Add everyone again with `pnpm people add`, and send each person their own link. Tell the user once that the old comments stay in the old store and in any `comments.md` already pulled, and are not on the new site.
94
+ 3. The old password variable (the `GATE_` one that is not `GATE_SECRET`) is no longer read. Remove it from `.env`, and from the Vercel project: `vercel env ls` names it, then `vercel env rm <name> production` and `preview`.
95
+ 4. Earlier deployments still serve the old password page at their own URLs. Remove them: `vercel ls <project>` lists them; `vercel rm <url>` each one older than the new production deployment, with the user's word.
71
96
 
72
97
  ## Security, never weakened for a prototype
73
98
 
74
- - `vercel.json` sets `noindex`, `X-Frame-Options: DENY`, `nosniff`, HSTS and a same-origin referrer on every path. The gate and invite pages add a hash CSP and send no referrer.
75
- - A wrong password waits 800ms. For a link going to a large client list, add a Vercel Firewall rate-limit rule on `POST` before it goes out.
99
+ - `vercel.json` sets `noindex`, `X-Frame-Options: DENY`, `nosniff`, HSTS and a same-origin referrer on every path. The gate pages add a hash CSP, run no script and send no referrer.
100
+ - A link is 32 random bytes, and the store keeps only its hash. Using one is atomic: of two requests with the same link, only one signs in.
101
+ - The session cookie carries when the store last said yes. After five minutes the gate asks the store again on the next request of any kind and issues a fresh cookie, so a revoke, a sign out everywhere or a changed access length reaches every device within five minutes. A store that does not answer gives 503 and signs nobody out.
102
+ - `--site` needs the deployed store's credentials in `.env`; with only the local store, `people` refuses rather than print a link the site does not know.
103
+ - `GATE_SECRET` signs every session, together with the review store's URL, so two projects that share a secret (a copied folder) never accept each other's cookies. Never send it, never commit it. Replacing it on Vercel signs everyone out.
@@ -52,7 +52,7 @@ The tracks decide everything a shell question used to: product draws `AppShell`,
52
52
 
53
53
  | Header | Question | Options |
54
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. |
55
+ | Share | Put the prototypes on a private link now? Each person signs in with their own link. | Yes (Recommended) · 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
56
  | Front end | Which front end will the site use? | Astro (Recommended) · Next.js |
57
57
 
58
58
  **Round 4: typed answers, one short chat message each, only for what was chosen.**
@@ -88,11 +88,11 @@ The user does nothing in a terminal here; each step that needs them is one link
88
88
 
89
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
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 message in `fix` as written (it names **Upstash for Redis** as the product to pick), then rerun.
91
+ 3. `pnpm --dir <path> bootstrap --vercel <name> --team <team-slug> --review`. It links the project, connects the GitHub repo, sets the gate's secret, turns Vercel's own login off and adds the review store, which keeps the people and their sign-in links. A first `--review` on a team can stop on the Marketplace terms: send the user the message in `fix` as written (it names **Upstash for Redis** as the product to pick), then rerun.
92
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>" --kind studio --site <share.url>`.
93
+ 5. `pnpm --dir <path> people add --name "<user>" --team "<studio>" --kind studio --site <share.url>`.
94
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.
95
+ Give the user `share.url` and their own `link` in the closing message, say the link signs in one device and then stops working, and say the link shows the samples until the first feature replaces them.
96
96
 
97
97
  ## 5. Record what was answered
98
98
 
@@ -111,4 +111,4 @@ Write the shell of each track under `DESIGN.md`, Shell: product is `AppShell`, w
111
111
 
112
112
  The next step is `miles-new-feature`.
113
113
 
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.
114
+ Close with the path, the port, the repo URL when there is one, the share link and the user's own sign-in link 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.
@@ -34,7 +34,7 @@ One feature is one slug used in two places: `docs/sprints/<slug>/` and the `feat
34
34
 
35
35
  ## The walkthrough
36
36
 
37
- `docs/sprints/<feature>/guide.md` is for the reviewer who has the password and not the repo. It is written from the States table: one section per workflow, then "Every state, and how to reach it" copied from the README, then what the prototype does not do, then what the review must settle. Screenshots go in `assets/guide/` beside it, named in order (`01-list.jpg`); a missing file fails the build. Write it before the share link goes out (`miles-deploy` checks it exists for a sprint).
37
+ `docs/sprints/<feature>/guide.md` is for the reviewer who has a sign-in link and not the repo. It is written from the States table: one section per workflow, then "Every state, and how to reach it" copied from the README, then what the prototype does not do, then what the review must settle. Screenshots go in `assets/guide/` beside it, named in order (`01-list.jpg`); a missing file fails the build. Write it before the share link goes out (`miles-deploy` checks it exists for a sprint).
38
38
 
39
39
  ## When done means decided
40
40