@1agh/maude 0.30.0 → 0.31.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 (90) hide show
  1. package/README.md +5 -5
  2. package/apps/studio/acp/bridge.ts +285 -0
  3. package/apps/studio/acp/env.ts +48 -0
  4. package/apps/studio/acp/index.ts +132 -0
  5. package/apps/studio/acp/probe.ts +112 -0
  6. package/apps/studio/acp/transcript.ts +149 -0
  7. package/apps/studio/annotations-layer.tsx +6 -1
  8. package/apps/studio/api.ts +225 -66
  9. package/apps/studio/bin/chat-open.sh +44 -0
  10. package/apps/studio/canvas-lib.tsx +112 -19
  11. package/apps/studio/canvas-list-watch.ts +177 -0
  12. package/apps/studio/canvas-shell.tsx +22 -2
  13. package/apps/studio/client/app.jsx +781 -26
  14. package/apps/studio/client/canvas-url.js +5 -0
  15. package/apps/studio/client/github.js +99 -0
  16. package/apps/studio/client/panels/ChatPanel.jsx +770 -0
  17. package/apps/studio/client/panels/CollabModelInfographic.jsx +71 -0
  18. package/apps/studio/client/panels/CreateProject.jsx +334 -0
  19. package/apps/studio/client/panels/DiffView.jsx +590 -0
  20. package/apps/studio/client/panels/GitPanel.jsx +767 -0
  21. package/apps/studio/client/panels/IdentityBar.jsx +294 -0
  22. package/apps/studio/client/panels/OnboardingWizard.jsx +563 -0
  23. package/apps/studio/client/panels/RepoBranchSwitcher.jsx +349 -0
  24. package/apps/studio/client/panels/acp-runtime.js +286 -0
  25. package/apps/studio/client/panels/chat-markdown.jsx +138 -0
  26. package/apps/studio/client/panels/git-grouping.js +86 -0
  27. package/apps/studio/client/styles/0-reset.css +4 -0
  28. package/apps/studio/client/styles/3-shell-maude.css +613 -3
  29. package/apps/studio/client/styles/5-maude-overrides.css +25 -0
  30. package/apps/studio/client/styles/6-acp-chat.css +771 -0
  31. package/apps/studio/client/styles/_index.css +2 -0
  32. package/apps/studio/client/tour/collab-tour.js +61 -0
  33. package/apps/studio/client/tour/overlay.jsx +11 -1
  34. package/apps/studio/client/whats-new.jsx +25 -10
  35. package/apps/studio/collab/registry.ts +13 -0
  36. package/apps/studio/collab/room.ts +36 -0
  37. package/apps/studio/cursors-overlay.tsx +17 -1
  38. package/apps/studio/dist/client.bundle.js +28780 -1534
  39. package/apps/studio/dist/comment-mount.js +4 -2
  40. package/apps/studio/dist/styles.css +5633 -1617
  41. package/apps/studio/git/endpoints.ts +338 -0
  42. package/apps/studio/git/service.ts +1334 -0
  43. package/apps/studio/git/watch.ts +97 -0
  44. package/apps/studio/github/endpoints.ts +358 -0
  45. package/apps/studio/github/service.ts +231 -0
  46. package/apps/studio/github/token.ts +53 -0
  47. package/apps/studio/hmr-broadcast.ts +9 -2
  48. package/apps/studio/http.ts +384 -1
  49. package/apps/studio/participants-chrome.tsx +69 -9
  50. package/apps/studio/paths.ts +12 -0
  51. package/apps/studio/scaffold-design.ts +57 -0
  52. package/apps/studio/server.ts +65 -2
  53. package/apps/studio/sync/agent.ts +81 -1
  54. package/apps/studio/sync/codec.ts +24 -0
  55. package/apps/studio/sync/cold-start.ts +40 -0
  56. package/apps/studio/sync/hub-link.ts +137 -0
  57. package/apps/studio/test/acp-bridge.test.ts +127 -0
  58. package/apps/studio/test/acp-env.test.ts +65 -0
  59. package/apps/studio/test/acp-origin-gate.test.ts +78 -0
  60. package/apps/studio/test/acp-transcript.test.ts +112 -0
  61. package/apps/studio/test/canvas-create-api.test.ts +72 -0
  62. package/apps/studio/test/canvas-list-watch.test.ts +322 -0
  63. package/apps/studio/test/canvas-meta-api.test.ts +161 -27
  64. package/apps/studio/test/canvas-origin-gate.test.ts +35 -0
  65. package/apps/studio/test/chat-markdown.test.tsx +58 -0
  66. package/apps/studio/test/collab-session-survival.test.tsx +176 -0
  67. package/apps/studio/test/csrf-write-guard.test.ts +26 -0
  68. package/apps/studio/test/editing-presence.test.ts +103 -0
  69. package/apps/studio/test/fixtures/mock-acp-agent.mjs +45 -0
  70. package/apps/studio/test/git-api.test.ts +0 -0
  71. package/apps/studio/test/git-branches.test.ts +106 -0
  72. package/apps/studio/test/git-grouping.test.ts +106 -0
  73. package/apps/studio/test/git-watch.test.ts +97 -0
  74. package/apps/studio/test/github-api.test.ts +465 -0
  75. package/apps/studio/test/hub-link.test.ts +69 -0
  76. package/apps/studio/test/participants-chrome.test.ts +36 -1
  77. package/apps/studio/test/sync-cold-seed-dedup.test.ts +187 -0
  78. package/apps/studio/test/sync-cold-start.test.ts +61 -1
  79. package/apps/studio/test/tour-overlay.test.tsx +18 -0
  80. package/apps/studio/tool-palette.tsx +18 -9
  81. package/apps/studio/use-chrome-visibility.tsx +66 -0
  82. package/apps/studio/use-collab.tsx +414 -187
  83. package/apps/studio/whats-new.json +73 -0
  84. package/apps/studio/ws.ts +44 -1
  85. package/cli/commands/design.mjs +1 -0
  86. package/cli/lib/gitignore-block.mjs +16 -3
  87. package/cli/lib/gitignore-block.test.mjs +13 -1
  88. package/package.json +11 -9
  89. package/plugins/design/dependencies.json +17 -0
  90. package/plugins/design/templates/_shell.html +30 -8
@@ -30,6 +30,11 @@ export function canvasUrl(p, cfg, opts) {
30
30
  // so previews stay non-interactive; opening the same canvas as a real tab
31
31
  // omits the flag and gets comments. See canvas-comment-mount.tsx.
32
32
  if (opts?.thumbnail) params.set('comments', '0');
33
+ // Phase 27 (E2) — DiffView "before" pane renders the canvas at a past version.
34
+ if (opts?.sha) params.set('sha', opts.sha);
35
+ // Phase 27 (E2) — DiffView renders a CLEAN canvas (no editor chrome: toolbar,
36
+ // world minimap, devtools) so the before/after is just the design.
37
+ if (opts?.hideChrome) params.set('hide-chrome', '1');
33
38
  const ds0 = cfg?.designSystems?.[0];
34
39
  // Specimen detection: anything under `system/<ds>/preview/` belongs to that
35
40
  // specific DS, so it must render with *that* DS's tokens — not always the
@@ -0,0 +1,99 @@
1
+ // client/github.js — thin bridge from the React client to (a) the Tauri shell's
2
+ // GitHub commands and (b) the dev-server's /_api/github/* endpoints. Phase 28 (E3).
3
+ //
4
+ // Sign-in / sign-out / keychain live in the Tauri shell (oauth.rs / keychain.rs),
5
+ // reached via `window.__TAURI__` (withGlobalTauri). The profile + create-repo +
6
+ // invite + repos go through the dev-server endpoints (which read the token from
7
+ // the loopback bridge). In a plain browser (no Tauri) `isNativeApp()` is false and
8
+ // the IdentityBar shows the "open the desktop app" state instead of sign-in.
9
+
10
+ export function isNativeApp() {
11
+ return typeof window !== 'undefined' && !!window.__TAURI__;
12
+ }
13
+
14
+ function tauri() {
15
+ const t = typeof window !== 'undefined' ? window.__TAURI__ : null;
16
+ if (!t) throw new Error('GitHub sign-in is only available in the Maude desktop app.');
17
+ return t;
18
+ }
19
+
20
+ /** Invoke a Tauri command (throws outside the app). */
21
+ export function invoke(cmd, args) {
22
+ return tauri().core.invoke(cmd, args);
23
+ }
24
+
25
+ /** Subscribe to a Tauri event; resolves to an async unlisten fn. */
26
+ export function listen(event, handler) {
27
+ return tauri().event.listen(event, (e) => handler(e.payload));
28
+ }
29
+
30
+ // ── Tauri shell commands ──────────────────────────────────────────────────────
31
+ /** Run the device flow; resolves to the login (public handle) on success. */
32
+ export const signIn = () => invoke('github_sign_in');
33
+ export const signOut = () => invoke('github_sign_out');
34
+ /** Whether a token is in the keychain (boolean). Safe to call on launch. */
35
+ export const isSignedIn = () => invoke('github_is_signed_in');
36
+ export const openVerification = () =>
37
+ invoke('github_open_verification', { url: 'https://github.com/login/device' });
38
+ /** Show the device code as soon as the shell has it. Returns an unlisten promise. */
39
+ export const onDeviceCode = (cb) => listen('github://device-code', cb);
40
+
41
+ // ── dev-server endpoints ────────────────────────────────────────────────────────
42
+ async function api(path, opts = {}) {
43
+ const headers = { ...(opts.headers || {}) };
44
+ if (opts.body) headers['Content-Type'] = 'application/json';
45
+ let res;
46
+ try {
47
+ res = await fetch(path, { ...opts, headers });
48
+ } catch {
49
+ return { ok: false, status: 0, json: { error: 'Maude isn’t reachable right now.' } };
50
+ }
51
+ let json = null;
52
+ try {
53
+ json = await res.json();
54
+ } catch {
55
+ json = null;
56
+ }
57
+ return { ok: res.ok, status: res.status, json };
58
+ }
59
+
60
+ export const fetchIdentity = () => api('/_api/github/identity');
61
+ export const listRepos = () => api('/_api/github/repos');
62
+ export const createRepo = (body) => api('/_api/github/create-repo', { method: 'POST', body: JSON.stringify(body) });
63
+ export const invite = (username) => api('/_api/github/invite', { method: 'POST', body: JSON.stringify({ username }) });
64
+ export const cloneRepo = (body) => api('/_api/github/clone', { method: 'POST', body: JSON.stringify(body) });
65
+ export const createProject = (body) => api('/_api/github/create-project', { method: 'POST', body: JSON.stringify(body) });
66
+ export const initDesign = (dir) => api('/_api/design/init', { method: 'POST', body: JSON.stringify({ dir }) });
67
+ /** Phase 29 (E4) Door C — connect to a team hub (saves the global hub credential). */
68
+ export const hubLink = (body) => api('/_api/hub/link', { method: 'POST', body: JSON.stringify(body) });
69
+
70
+ // ── Tauri shell: app-state (first-run / last-project / recent) — Phase 29 (E4) ──
71
+ // In a plain browser these throw via tauri(); the wizard only mounts in the native
72
+ // app (isNativeApp()), so call sites guard accordingly.
73
+ /** True on a fresh install with no usable last project → show the onboarding wizard. */
74
+ export const appIsFirstRun = () => invoke('app_is_first_run');
75
+ export const appGetLastProject = () => invoke('app_get_last_project');
76
+ export const appSetLastProject = (path) => invoke('app_set_last_project', { path });
77
+ export const appRecentProjects = () => invoke('app_recent_projects');
78
+
79
+ // ── Tauri shell commands for "pull a local copy" ────────────────────────────────
80
+ /** Native folder picker → chosen parent dir, or null if cancelled. */
81
+ export const pickDirectory = () => invoke('pick_directory');
82
+ /** Switch the app to a local project folder (the freshly cloned copy). */
83
+ export const openLocalProject = (path) => invoke('open_local_project', { path });
84
+
85
+ // ── Tauri shell: auto-update (Phase 32 / Task 1) ────────────────────────────────
86
+ // The shell downloads + stages a newer build in the background and emits
87
+ // `update-ready` with { version, notes }. The client shows a banner; clicking
88
+ // "Restart now" applies the staged update.
89
+ /** Subscribe to the staged-update notice. Returns an unlisten promise. cb({version,notes}). */
90
+ export const onUpdateReady = (cb) => listen('update-ready', cb);
91
+ /** Apply the staged update by relaunching the app (kills the sidecar first). */
92
+ export const restartToUpdate = () => invoke('restart_to_update');
93
+
94
+ // ── Tauri shell: opt-in crash reporting (Phase 32 / Task 4) ─────────────────────
95
+ // Local-file-only, default OFF. The first-run wizard's opt-in checkbox flips it.
96
+ /** Current opt-in state (boolean). */
97
+ export const getCrashReporting = () => invoke('prefs_get_crash_reporting');
98
+ /** Set the opt-in state. */
99
+ export const setCrashReporting = (enabled) => invoke('prefs_set_crash_reporting', { enabled });