@1agh/maude 2.1.1 → 2.2.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 (71) hide show
  1. package/apps/studio/actions/agents.ts +18 -42
  2. package/apps/studio/actions/verbs.ts +49 -0
  3. package/apps/studio/actions.manifest.json +103 -19
  4. package/apps/studio/ai/create-claim.ts +1 -1
  5. package/apps/studio/bin/_asset-file.mjs +117 -0
  6. package/apps/studio/bin/_canvas-file.mjs +146 -0
  7. package/apps/studio/bin/_footage.mjs +123 -0
  8. package/apps/studio/bin/_pdf-playwright.mjs +14 -0
  9. package/apps/studio/bin/_png-playwright.mjs +15 -1
  10. package/apps/studio/bin/_pw-launch.mjs +98 -0
  11. package/apps/studio/bin/_retry-save.mjs +49 -0
  12. package/apps/studio/bin/_sync.mjs +145 -2
  13. package/apps/studio/bin/asset-rename.sh +12 -0
  14. package/apps/studio/bin/asset-trash.sh +12 -0
  15. package/apps/studio/bin/canvas-move.sh +12 -0
  16. package/apps/studio/bin/canvas-new.sh +12 -0
  17. package/apps/studio/bin/footage.sh +12 -0
  18. package/apps/studio/bin/generate.sh +7 -0
  19. package/apps/studio/bin/retry-save.sh +13 -0
  20. package/apps/studio/bridge/canvas-mode-store.ts +11 -2
  21. package/apps/studio/bridge/dgn-protocol.ts +8 -3
  22. package/apps/studio/bridge/occlusion.ts +45 -0
  23. package/apps/studio/canvas-theme-pill.tsx +182 -38
  24. package/apps/studio/client/export-center.jsx +32 -3
  25. package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
  26. package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
  27. package/apps/studio/client/home/HomeConnection.jsx +4 -3
  28. package/apps/studio/client/home/ProjectRows.jsx +514 -0
  29. package/apps/studio/client/home/home-accounts-model.js +148 -99
  30. package/apps/studio/client/home/home-api.js +4 -0
  31. package/apps/studio/client/home/home-app.jsx +127 -432
  32. package/apps/studio/client/home/home-icons.jsx +8 -0
  33. package/apps/studio/client/home/home-model.js +109 -0
  34. package/apps/studio/client/home/home.css +447 -111
  35. package/apps/studio/client/home/use-account-fix.js +123 -0
  36. package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
  37. package/apps/studio/client/v2/export/done-toast.jsx +2 -5
  38. package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
  39. package/apps/studio/client/v2/export/export.css +9 -0
  40. package/apps/studio/client/v2/export/exports-model.js +16 -3
  41. package/apps/studio/client/v2/export/file-rows.jsx +81 -5
  42. package/apps/studio/client/v2/export/native-save.js +33 -0
  43. package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
  44. package/apps/studio/client/v2/export/sections/print.jsx +37 -20
  45. package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
  46. package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
  47. package/apps/studio/collab/room.ts +21 -7
  48. package/apps/studio/dist/client.bundle.js +692 -692
  49. package/apps/studio/dist/comment-mount.js +2 -2
  50. package/apps/studio/dist/styles.css +1 -1
  51. package/apps/studio/exporters/ghostscript.ts +78 -1
  52. package/apps/studio/exporters/pdf-fonts.ts +31 -4
  53. package/apps/studio/generation/jobs.ts +6 -0
  54. package/apps/studio/http.ts +6 -2
  55. package/apps/studio/routes/agent.ts +6 -2
  56. package/apps/studio/routes/project-undo.ts +10 -0
  57. package/apps/studio/server.ts +25 -0
  58. package/apps/studio/shell/cli-yield.ts +48 -11
  59. package/apps/studio/whats-new.json +18 -0
  60. package/cli/commands/design.mjs +74 -16
  61. package/cli/lib/bash-guard.mjs +4 -4
  62. package/cli/lib/confine-read.mjs +2 -0
  63. package/cli/lib/design-help.gen.mjs +15 -2
  64. package/cli/lib/design-hook.mjs +1 -1
  65. package/cli/lib/desktop-locate.mjs +36 -8
  66. package/cli/lib/studio-locate.mjs +8 -2
  67. package/cli/lib/sub-verbs.mjs +13 -1
  68. package/package.json +8 -8
  69. package/plugins/flow/.claude-plugin/config.schema.json +11 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +0 -262
  71. package/apps/studio/client/home/HomeAccountsRow.jsx +0 -221
@@ -1,20 +1,19 @@
1
- // client/home/home-accounts-model.js — 2.0.5 W4b: what Home's avatar lists. PURE.
1
+ // client/home/home-accounts-model.js — what Home's accounts chip lists (2.1.2 HB1, canvas 17
2
+ // artboards 15–18; the cards came with 2.1.1 B4, the sign-outs with 2.0.5 W4b). PURE.
2
3
  //
3
- // Every profile on this Mac by its label (`shell_state.profiles`), each with the accounts it is
4
- // signed in with:
5
- // cloud the profile's Maude Cloud listing says signed in → its e-mail; Sign out =
6
- // POST /_home/cloud/signout {profile} (that profile's cloud.json only)
7
- // team each team server in that profile's hubs.json (`GET /_home/accounts`) → host + the
8
- // account it vouched for; Sign out = POST /_home/hub/signout {profile, url}
9
- // github the login last signed in on the profile (profiles.json). Home has no GitHub sign-out
10
- // path of its own — it lives in the project's account card — so no button here
11
- // (Michal's rule: no dead buttons). A profile without a login offers "Sign in with GitHub…"
12
- // (the existing `home_github_sign_in`).
4
+ // One card per account: a Maude Cloud account by its e-mail, a server of your own by its account or
5
+ // host; never a Maude Cloud cell (its projects are the Maude Cloud account's).
6
+ // Sign out cloud → POST /_home/cloud/signout {profile} (that profile's cloud.json only)
7
+ // server → POST /_home/hub/signout {profile, url}; asks first
8
+ // GitHub the login last signed in on the profile (profiles.json). Home has no GitHub sign-out
9
+ // of its own — it lives in the project's account card — so no button for it (Michal's
10
+ // rule: no dead buttons). A profile without a login offers "Sign in with GitHub…".
11
+ // Forget an old server (no answer, no project) — the same hub sign-out, on the person's click.
13
12
  // Add / switch: "Add a Maude Cloud account…" is Home's own sign-in, which never re-signs a profile
14
13
  // that holds a credential (`home_cloud_sign_in_prepare` makes a fresh one — that IS the switch);
15
- // "Connect to a team server…" is the Advanced › hub sheet. A browser has no shell: facts only.
14
+ // "Connect to a team server…" is the team-server sheet. A browser has no shell: facts only.
16
15
 
17
- import { accountFace, normHubUrl } from './home-model.js';
16
+ import { accountFace, isCloudHubUrl, normHubUrl } from './home-model.js';
18
17
  import { CONN_WORDS, cloudState } from './home-where-model.js';
19
18
 
20
19
  const hostOf = (url) => {
@@ -43,84 +42,6 @@ function signOutSpec(path, name, extra) {
43
42
  };
44
43
  }
45
44
 
46
- /**
47
- * @param in.native the desktop app
48
- * @param in.shell `shell_state` (profiles: [{ id, label, email?, github? }])
49
- * @param in.clouds one `GET /_home/cloud` answer per profile
50
- * @param in.hubProfiles `GET /_home/accounts` `profiles`
51
- */
52
- export function homeAccounts({ native = false, shell = null, clouds = null, hubProfiles = null }) {
53
- const known = (shell?.profiles ?? []).filter((p) => p && typeof p.id === 'string');
54
- const ids = [
55
- ...known.map((p) => p.id),
56
- ...(clouds ?? [])
57
- .filter((c) => c?.signedIn && typeof c.profile === 'string')
58
- .map((c) => c.profile),
59
- ].filter((id, i, all) => all.indexOf(id) === i);
60
-
61
- const profiles = ids.map((id) => {
62
- const p = known.find((x) => x.id === id) ?? null;
63
- const label = str(p?.label) || (id === 'default' ? 'Default' : id);
64
- const cloud = (clouds ?? []).find((c) => c?.profile === id) ?? null;
65
- const accounts = [];
66
- if (cloud?.signedIn) {
67
- const email = str(cloud.account?.email) || str(p?.email);
68
- accounts.push({
69
- kind: 'cloud',
70
- key: 'cloud',
71
- title: 'Maude Cloud',
72
- host: null,
73
- who: email,
74
- signOut: native
75
- ? signOutSpec('cloud-signout', email || 'Maude Cloud', { profile: id })
76
- : null,
77
- });
78
- }
79
- for (const h of (hubProfiles ?? []).find((x) => x?.id === id)?.hubs ?? []) {
80
- if (!h || typeof h.url !== 'string') continue;
81
- const host = hostOf(h.url);
82
- accounts.push({
83
- kind: 'team',
84
- key: `team:${h.url}`,
85
- title: 'Team server',
86
- host,
87
- who: str(h.account),
88
- signOut: native ? signOutSpec('hub-signout', host, { profile: id, url: h.url }) : null,
89
- });
90
- }
91
- const gh = str(p?.github);
92
- if (gh)
93
- accounts.push({
94
- kind: 'github',
95
- key: 'github',
96
- title: 'GitHub',
97
- host: null,
98
- who: `@${gh.replace(/^@/, '')}`,
99
- signOut: null,
100
- });
101
- return {
102
- id,
103
- label,
104
- face: accountFace({ id, label, email: accounts[0]?.who?.replace(/^@/, '') || '' }),
105
- accounts,
106
- githubSignIn: native && !gh,
107
- };
108
- });
109
-
110
- const first = profiles.find((p) => p.accounts.length) ?? profiles[0] ?? null;
111
- const face = first
112
- ? {
113
- ...first.face,
114
- title: [first.label, first.accounts[0]?.who].filter(Boolean).join(' · ') || 'Your accounts',
115
- }
116
- : null;
117
- return {
118
- profiles,
119
- face,
120
- add: native ? { cloud: 'Add a Maude Cloud account…', team: 'Connect to a team server…' } : null,
121
- };
122
- }
123
-
124
45
  const projectsWord = (n) => (n === 0 ? 'No projects' : `${n} ${n === 1 ? 'project' : 'projects'}`);
125
46
 
126
47
  /**
@@ -134,13 +55,23 @@ const projectsWord = (n) => (n === 0 ? 'No projects' : `${n} ${n === 1 ? 'projec
134
55
  * `fix`: `{ path: 'cloud-signin', profile }` (Home's own Maude Cloud sign-in) or
135
56
  * `{ path: 'hub-signin', profile, url }` (the team-server sign-in, address prefilled) — only for a
136
57
  * sign-in that is missing or stopped working; a server that does not answer has nothing to fix here.
58
+ * 2.1.2 HB1: `stale` = a server that does not answer and holds no project (folded, `forget` offered);
59
+ * `projects` = the names whose changes wait on this account; `signOut` = the confirm spec, or null
60
+ * when no credential is saved on this Mac.
137
61
  *
138
62
  * @param in.shell `shell_state`
139
63
  * @param in.clouds one `GET /_home/cloud` answer per profile
140
64
  * @param in.hubProfiles `GET /_home/accounts` `profiles` (each hub with its `state`)
141
65
  * @param in.groups `buildHomeModel().groups` (rows carry `where` / `connection`)
66
+ * @param in.cloudUrl the control plane (`/_config.cloudOrigin`); null ⇒ no server card at all
142
67
  */
143
- export function homeAccountCards({ shell = null, clouds = null, hubProfiles = null, groups = [] }) {
68
+ export function homeAccountCards({
69
+ shell = null,
70
+ clouds = null,
71
+ hubProfiles = null,
72
+ groups = [],
73
+ cloudUrl = null,
74
+ }) {
144
75
  const profiles = (shell?.profiles ?? []).filter((p) => p && typeof p.id === 'string');
145
76
  const ids = [...profiles.map((p) => p.id), ...groups.map((g) => g.profile?.id)].filter(
146
77
  (id, i, all) => typeof id === 'string' && all.indexOf(id) === i
@@ -167,6 +98,14 @@ export function homeAccountCards({ shell = null, clouds = null, hubProfiles = nu
167
98
  sub: `Maude Cloud · ${projectsWord(onCloud.length)}`,
168
99
  state,
169
100
  word: CONN_WORDS[state],
101
+ projects: onCloud.map((r) => r.name),
102
+ stale: false,
103
+ forget: null,
104
+ // a sign-out needs a credential on this Mac: signed in, or one that stopped working
105
+ signOut:
106
+ listing?.signedIn || listing?.rejected
107
+ ? signOutSpec('cloud-signout', email || 'Maude Cloud', { profile: id })
108
+ : null,
170
109
  fix:
171
110
  state === 'rejected' || state === 'missing'
172
111
  ? {
@@ -178,14 +117,24 @@ export function homeAccountCards({ shell = null, clouds = null, hubProfiles = nu
178
117
  });
179
118
  }
180
119
 
181
- const saved = (hubProfiles ?? []).find((x) => x?.id === id)?.hubs ?? [];
120
+ // 2.1.2 HB1: a server card only once the control plane is known — until then a saved sign-in to
121
+ // a Maude Cloud cell cannot be told from a server of your own, and nothing is guessed. A cell is
122
+ // never a server: its projects already count under the Maude Cloud account above, whose own
123
+ // sign-in is the state (the cell's token is re-made from it).
124
+ const saved = cloudUrl ? ((hubProfiles ?? []).find((x) => x?.id === id)?.hubs ?? []) : [];
182
125
  const servers = new Map();
183
126
  for (const h of saved)
184
- if (h && typeof h.url === 'string' && normHubUrl(h.url))
185
- servers.set(normHubUrl(h.url), { url: h.url, account: str(h.account), state: h.state });
127
+ if (h && typeof h.url === 'string' && normHubUrl(h.url) && !isCloudHubUrl(h.url, cloudUrl))
128
+ servers.set(normHubUrl(h.url), {
129
+ url: h.url,
130
+ account: str(h.account),
131
+ state: h.state,
132
+ saved: true,
133
+ });
186
134
  for (const r of rows) {
187
135
  const url = r.connection?.kind === 'team' ? r.boundHub || r.hub : null;
188
- if (url && !servers.has(url)) servers.set(url, { url, account: null, state: 'missing' });
136
+ if (url && !servers.has(url))
137
+ servers.set(url, { url, account: null, state: 'missing', saved: false });
189
138
  }
190
139
  for (const [norm, h] of servers) {
191
140
  const state =
@@ -193,9 +142,10 @@ export function homeAccountCards({ shell = null, clouds = null, hubProfiles = nu
193
142
  ? h.state
194
143
  : 'ok';
195
144
  const host = hostOf(h.url);
196
- const n = rows.filter(
197
- (r) => r.where?.kind === 'server' && (r.boundHub || r.hub) === norm
198
- ).length;
145
+ const mine = rows.filter((r) => r.where?.kind === 'server' && (r.boundHub || r.hub) === norm);
146
+ const n = mine.length;
147
+ // an old server: it does not answer and no project is on it — folded, offered Forget…
148
+ const stale = state === 'unreachable' && n === 0;
199
149
  out.push({
200
150
  key: `server:${id}:${norm}`,
201
151
  kind: 'server',
@@ -206,6 +156,10 @@ export function homeAccountCards({ shell = null, clouds = null, hubProfiles = nu
206
156
  sub: `${h.account ? host : 'Your server'} · ${projectsWord(n)}`,
207
157
  state,
208
158
  word: CONN_WORDS[state],
159
+ projects: mine.map((r) => r.name),
160
+ stale,
161
+ forget: stale && h.saved ? { profile: id, url: h.url, host } : null,
162
+ signOut: h.saved ? signOutSpec('hub-signout', host, { profile: id, url: h.url }) : null,
209
163
  fix:
210
164
  state === 'rejected' || state === 'missing'
211
165
  ? {
@@ -228,3 +182,98 @@ export const slugOf = (card) =>
228
182
  : `${card.profile}-${hostOf(card.url)
229
183
  .toLowerCase()
230
184
  .replace(/[^a-z0-9]+/g, '-')}`;
185
+
186
+ const isBad = (c) => c.state === 'rejected' || c.state === 'missing';
187
+ const countOf = (n, one, many) => `${n} ${n === 1 ? one : many}`;
188
+
189
+ /**
190
+ * 2.1.2 HB1 (canvas 17, artboards 15–17) — the chip at the top right of Home: "3 accounts", plus
191
+ * "1 needs sign-in" (with its dot) while a sign-in is missing or stopped working. Old servers (no
192
+ * answer, no project) are not counted: they fold at the foot of the accounts list (artboard 18).
193
+ */
194
+ export function homeAccountsSummary(cards) {
195
+ const live = cards.filter((c) => !c.stale);
196
+ const old = cards.filter((c) => c.stale);
197
+ const needs = live.filter(isBad).length;
198
+ return {
199
+ live,
200
+ old,
201
+ word: live.length ? countOf(live.length, 'account', 'accounts') : 'Accounts',
202
+ needs,
203
+ needsWord: needs ? `${needs} ${needs === 1 ? 'needs' : 'need'} sign-in` : null,
204
+ oldWord: old.length ? countOf(old.length, 'old server', 'old servers') : null,
205
+ };
206
+ }
207
+
208
+ const namesWord = (names) =>
209
+ names.length <= 2
210
+ ? names.join(' and ')
211
+ : `${names.slice(0, 2).join(', ')} and ${names.length - 2} more`;
212
+
213
+ /**
214
+ * 2.1.2 HB1 (artboard 16) — the one banner on top of Home: only a sign-in the person can fix (missing
215
+ * or stopped working). One → it names the place, the projects whose changes wait, and the card's own
216
+ * fix. Two or more → a count and Review (the accounts list). A server that does not answer never
217
+ * raises it. null = nothing needs the person.
218
+ */
219
+ export function homeAccountBanner(cards) {
220
+ const bad = cards.filter((c) => !c.stale && isBad(c) && c.fix);
221
+ if (!bad.length) return null;
222
+ if (bad.length > 1)
223
+ return {
224
+ kind: 'many',
225
+ key: bad.map((c) => c.key).join('|'),
226
+ card: null,
227
+ title: bad.every((c) => c.state === 'rejected')
228
+ ? `${bad.length} sign-ins stopped working`
229
+ : `${bad.length} sign-ins need you`,
230
+ body: null,
231
+ action: 'Review',
232
+ };
233
+ const card = bad[0];
234
+ const place = card.kind === 'cloud' ? 'Maude Cloud' : hostOf(card.url);
235
+ const names = (card.projects ?? []).filter(Boolean);
236
+ return {
237
+ kind: 'one',
238
+ key: card.key,
239
+ card,
240
+ title:
241
+ card.state === 'rejected'
242
+ ? `Your sign-in to ${place} stopped working.`
243
+ : `Your sign-in to ${place} is missing.`,
244
+ body: names.length ? `Changes to ${namesWord(names)} wait on this Mac.` : null,
245
+ action: card.fix.label,
246
+ };
247
+ }
248
+
249
+ /**
250
+ * The GitHub login of a profile, for its first card's "…" menu: `{ login }` when signed in,
251
+ * `{ signIn: true }` when not (Home's `home_github_sign_in`). Home has no GitHub sign-out of its own.
252
+ */
253
+ export function githubOf(shell, profile) {
254
+ const p = (shell?.profiles ?? []).find((x) => x?.id === profile);
255
+ const gh = str(p?.github);
256
+ return gh ? { login: `@${gh.replace(/^@/, '')}`, signIn: false } : { login: null, signIn: true };
257
+ }
258
+
259
+ /** The confirm for Forget… on one old server, or on all of them (artboard 18). */
260
+ export function forgetSpec(servers) {
261
+ if (servers.length === 1)
262
+ return {
263
+ id: 'forget',
264
+ servers,
265
+ title: 'Forget this server?',
266
+ body: `The saved sign-in for ${servers[0].host} is removed from this Mac. Nothing on the server or in your projects is deleted.`,
267
+ primary: 'Forget this server',
268
+ cancel: 'Cancel',
269
+ };
270
+ const n = servers.length;
271
+ return {
272
+ id: 'forget-all',
273
+ servers,
274
+ title: `Forget ${n} old servers?`,
275
+ body: `The saved sign-ins for these ${n} servers are removed from this Mac. Nothing on the servers or in your projects is deleted.`,
276
+ primary: `Forget ${n} old servers`,
277
+ cancel: 'Cancel',
278
+ };
279
+ }
@@ -280,6 +280,10 @@ export const openProjectFolder = () => shellInvoke('open_project_folder');
280
280
  * (Rust resolves the folder from its own list; Home never names a path). → `{label, opened}`. */
281
281
  export const openWorktree = (pid) => shellInvoke('open_worktree', { pid });
282
282
  export const relinkProject = (pid) => shellInvoke('relink_project', { pid });
283
+ /** 2.1.2 — "Remove from list": the pid off this Mac's list (Rust `forget_project`); files untouched. */
284
+ export const forgetProject = (pid) => shellInvoke('forget_project', { pid });
285
+ /** 2.1.2 — a project row's "Show in Finder": Rust resolves the folder by pid (Home never names a path). */
286
+ export const revealProjectFolder = (pid) => shellInvoke('reveal_project_folder', { pid });
283
287
  /** The existing command (github.js `managedProjectOpen`): resolves the managed copy's folder. */
284
288
  export const managedProjectOpen = (p) =>
285
289
  shellInvoke('managed_project_open', {