@1agh/maude 2.0.1 → 2.0.3

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 (42) hide show
  1. package/apps/studio/access/filters.ts +24 -2
  2. package/apps/studio/access/frame.ts +38 -0
  3. package/apps/studio/access/request.ts +81 -2
  4. package/apps/studio/asset-placeholder.tsx +157 -62
  5. package/apps/studio/bridge/dgn-protocol.ts +34 -4
  6. package/apps/studio/client/app.jsx +3 -0
  7. package/apps/studio/client/hooks/use-palette-and-panels.jsx +2 -0
  8. package/apps/studio/client/styles/_index.css +2 -0
  9. package/apps/studio/client/v2/assets/asset-state-lane.js +170 -5
  10. package/apps/studio/client/v2/assets/ds-library-view.jsx +263 -0
  11. package/apps/studio/client/v2/assets/ds-library.css +123 -0
  12. package/apps/studio/client/v2/assets/ds-library.js +175 -0
  13. package/apps/studio/client/v2/assets/missing-frame.jsx +8 -4
  14. package/apps/studio/client/v2/export/native-save.js +44 -0
  15. package/apps/studio/client/v2/left-panel/assets-panel.jsx +60 -1
  16. package/apps/studio/dist/client.bundle.js +524 -523
  17. package/apps/studio/dist/comment-mount.js +2 -2
  18. package/apps/studio/dist/styles.css +1 -1
  19. package/apps/studio/ds-assets.ts +407 -0
  20. package/apps/studio/edit-ops/image-fit.ts +19 -2
  21. package/apps/studio/edit-ops/types.ts +5 -0
  22. package/apps/studio/editing/asset-drag.ts +8 -2
  23. package/apps/studio/editing/ds-asset-ref.ts +66 -0
  24. package/apps/studio/http.ts +17 -2
  25. package/apps/studio/materialize-client.ts +11 -0
  26. package/apps/studio/routes/asset-state.ts +12 -0
  27. package/apps/studio/routes/ds-assets.ts +78 -0
  28. package/apps/studio/routes/edit.ts +1 -0
  29. package/apps/studio/routes/index.ts +4 -0
  30. package/apps/studio/sync/accepted-link.ts +28 -6
  31. package/apps/studio/sync/asset-push.ts +8 -1
  32. package/apps/studio/sync/asset-state.ts +27 -2
  33. package/apps/studio/sync/availability.ts +5 -0
  34. package/apps/studio/sync/create-collision.ts +96 -19
  35. package/apps/studio/sync/file-plane.ts +36 -7
  36. package/apps/studio/sync/index.ts +10 -2
  37. package/apps/studio/sync/lfs-pointer.ts +137 -0
  38. package/apps/studio/sync/project-config-push.ts +8 -1
  39. package/apps/studio/sync/transaction-client.ts +54 -11
  40. package/apps/studio/sync/writer-registry.ts +2 -0
  41. package/apps/studio/whats-new.json +9 -0
  42. package/package.json +8 -8
@@ -0,0 +1,137 @@
1
+ // A Git LFS pointer file standing where a picture or clip should be (2.0.3).
2
+ //
3
+ // A project committed with Git LFS but cloned without `git lfs pull` keeps a ~130-byte text file in
4
+ // place of each media file:
5
+ //
6
+ // version https://git-lfs.github.com/spec/v1
7
+ // oid sha256:<64 hex>
8
+ // size <n>
9
+ //
10
+ // The canvas cannot draw it, and the sync must not send it up as if it were the media. This module
11
+ // only RECOGNISES one: a regular file of at most 1 KB whose first line is exactly the spec line. It
12
+ // never reads more than the first 1 KB and never reads a bigger file at all.
13
+
14
+ import {
15
+ closeSync,
16
+ existsSync,
17
+ lstatSync,
18
+ openSync,
19
+ readFileSync,
20
+ readSync,
21
+ statSync,
22
+ } from 'node:fs';
23
+ import path from 'node:path';
24
+
25
+ /** What the sync says about a pointer it will not upload (the Sync panel shows it). */
26
+ export const LFS_POINTER_REASON =
27
+ 'A Git LFS placeholder, not the file. Run git lfs pull (or Fix with AI on the picture).';
28
+
29
+ /** The pointer spec allows ≤ 1024 bytes; anything bigger is the real file. */
30
+ export const LFS_POINTER_MAX_BYTES = 1024;
31
+ export const LFS_SPEC_LINE = 'version https://git-lfs.github.com/spec/v1';
32
+
33
+ export interface LfsPointer {
34
+ /** The sha256 of the real file, when the pointer carries a well-formed one. */
35
+ oid: string | null;
36
+ /** The real file's size in bytes, when the pointer says it. */
37
+ size: number | null;
38
+ }
39
+
40
+ /** Parse pointer TEXT (pure). Null when it is not a pointer. */
41
+ export function parseLfsPointer(text: string): LfsPointer | null {
42
+ if (text.length > LFS_POINTER_MAX_BYTES) return null;
43
+ const nl = text.indexOf('\n');
44
+ const first = (nl === -1 ? text : text.slice(0, nl)).replace(/\r$/, '');
45
+ if (first !== LFS_SPEC_LINE) return null;
46
+ const oid = /^oid sha256:([0-9a-f]{64})\r?$/m.exec(text)?.[1] ?? null;
47
+ const sizeRaw = /^size (\d{1,15})\r?$/m.exec(text)?.[1];
48
+ return { oid, size: sizeRaw === undefined ? null : Number(sizeRaw) };
49
+ }
50
+
51
+ /**
52
+ * Read a file and say whether it is a pointer. A symlink, a directory, a missing file or anything
53
+ * over 1 KB is not one (and is never opened).
54
+ */
55
+ export function readLfsPointer(abs: string): LfsPointer | null {
56
+ let fd: number | null = null;
57
+ try {
58
+ const st = lstatSync(abs);
59
+ if (!st.isFile() || st.size > LFS_POINTER_MAX_BYTES || st.size < LFS_SPEC_LINE.length)
60
+ return null;
61
+ fd = openSync(abs, 'r');
62
+ const buf = Buffer.alloc(LFS_POINTER_MAX_BYTES);
63
+ const n = readSync(fd, buf, 0, LFS_POINTER_MAX_BYTES, 0);
64
+ return parseLfsPointer(buf.subarray(0, n).toString('utf8'));
65
+ } catch {
66
+ return null;
67
+ } finally {
68
+ if (fd !== null) {
69
+ try {
70
+ closeSync(fd);
71
+ } catch {
72
+ /* already gone */
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ /** True when the bytes already in hand (≤ 1 KB) are a pointer. */
79
+ export function isLfsPointerBytes(bytes: Uint8Array): boolean {
80
+ if (bytes.byteLength > LFS_POINTER_MAX_BYTES) return false;
81
+ return parseLfsPointer(Buffer.from(bytes).toString('utf8')) !== null;
82
+ }
83
+
84
+ /**
85
+ * The LFS object store of the git repository that holds `projectRoot`: `<git common dir>/lfs/objects`.
86
+ * Walks UP from the server's own project root (never from a request) at most `maxUp` levels to the
87
+ * first `.git`; a `.git` FILE (a worktree, a submodule) is followed to its `gitdir:` and that dir's
88
+ * `commondir`. Null when there is no repository or no LFS store.
89
+ */
90
+ export function lfsObjectsDir(projectRoot: string, maxUp = 8): string | null {
91
+ let dir = path.resolve(projectRoot);
92
+ for (let i = 0; i <= maxUp; i++) {
93
+ const dotGit = path.join(dir, '.git');
94
+ const gitDir = resolveGitDir(dotGit);
95
+ if (gitDir) {
96
+ const store = path.join(gitDir, 'lfs', 'objects');
97
+ try {
98
+ return statSync(store).isDirectory() ? store : null;
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
103
+ const up = path.dirname(dir);
104
+ if (up === dir) break;
105
+ dir = up;
106
+ }
107
+ return null;
108
+ }
109
+
110
+ function resolveGitDir(dotGit: string): string | null {
111
+ try {
112
+ const st = lstatSync(dotGit);
113
+ if (st.isDirectory()) return dotGit;
114
+ if (!st.isFile() || st.size > 4096) return null;
115
+ const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync(dotGit, 'utf8'));
116
+ if (!m?.[1]) return null;
117
+ const gitDir = path.resolve(path.dirname(dotGit), m[1]);
118
+ const commonFile = path.join(gitDir, 'commondir');
119
+ if (existsSync(commonFile)) {
120
+ const common = readFileSync(commonFile, 'utf8').trim();
121
+ if (common) return path.resolve(gitDir, common);
122
+ }
123
+ return gitDir;
124
+ } catch {
125
+ return null;
126
+ }
127
+ }
128
+
129
+ /** Does the store hold the object for `oid`? The oid must be 64 lowercase hex, or the answer is false. */
130
+ export function hasLfsObject(objectsDir: string | null, oid: string | null): boolean {
131
+ if (!objectsDir || !oid || !/^[0-9a-f]{64}$/.test(oid)) return false;
132
+ try {
133
+ return statSync(path.join(objectsDir, oid.slice(0, 2), oid.slice(2, 4), oid)).isFile();
134
+ } catch {
135
+ return false;
136
+ }
137
+ }
@@ -142,7 +142,14 @@ export function createProjectConfigPusher({
142
142
  lastAccepted = body;
143
143
  return 'refused' as const;
144
144
  }
145
- if (res.status === 401 || res.status === 403) {
145
+ // 401 is the CREDENTIAL, not the answer: the runtime renews it and pushes again (2.0.1 field —
146
+ // recording it as answered left a cell without its config.json until the next restart). 403 is
147
+ // the hub saying this account is not the owner: final, not retried on every event.
148
+ if (res.status === 401) {
149
+ log.warn("[sync] the workspace did not take this project's config yet (401) — will retry.");
150
+ return 'refused' as const;
151
+ }
152
+ if (res.status === 403) {
146
153
  lastAccepted = body;
147
154
  log.warn(`[sync] the workspace did not take this project's config (${res.status}).`);
148
155
  return 'refused' as const;
@@ -189,8 +189,19 @@ export interface CreateRename {
189
189
  toPath: string;
190
190
  }
191
191
 
192
+ /**
193
+ * 2.0.2 — a refused create that is taken OUT of the proposal instead of renamed: the project
194
+ * already holds this very file (`same`), the file is a module that keeps its name (`module`), or
195
+ * the canvas is no longer on this Mac (`gone`). What queued behind it names the same document.
196
+ */
197
+ export interface CreateWithdrawal {
198
+ doc: string;
199
+ why: 'same' | 'module' | 'gone';
200
+ }
201
+
192
202
  export interface CreateConflictAnswer {
193
203
  renames: CreateRename[];
204
+ withdrawn?: CreateWithdrawal[];
194
205
  /** The renamed create has its FINAL answer (the refused entry is gone). */
195
206
  settled: (result: ProposalResult) => void;
196
207
  }
@@ -688,16 +699,18 @@ export function createTransactionClient(opts: TransactionClientOptions) {
688
699
  function rewriteQueued(
689
700
  by: Map<string, CreateRename>,
690
701
  oldTx: string,
691
- newTx: string,
702
+ /** null — nothing is sent in its place (every create was withdrawn): the dependency goes. */
703
+ newTx: string | null,
692
704
  after: number
693
705
  ): void {
694
706
  for (const { file, entry } of readOutbox()) {
695
707
  if (entry.createdAt <= after || !entry.action) continue;
696
708
  const before = entry.action;
697
709
  const operations = before.operations.map((o) => renamedOp(o, by));
698
- const deps = before.dependsOn?.map((d) => (d === oldTx ? newTx : d));
710
+ const deps = before.dependsOn?.flatMap((d) => (d !== oldTx ? [d] : newTx ? [newTx] : []));
699
711
  const changed =
700
712
  operations.some((o, i) => o !== before.operations[i]) ||
713
+ deps?.length !== before.dependsOn?.length ||
701
714
  !!deps?.some((d, i) => d !== before.dependsOn?.[i]);
702
715
  if (!changed) continue;
703
716
  const action = { ...before, operations, ...(deps ? { dependsOn: deps } : {}) };
@@ -723,7 +736,11 @@ export function createTransactionClient(opts: TransactionClientOptions) {
723
736
  file: string,
724
737
  entry: OutboxEntry,
725
738
  result: ProposalResult
726
- ): Promise<{ file: string; entry: OutboxEntry; answer: CreateConflictAnswer } | null> {
739
+ ): Promise<
740
+ | { file: string; entry: OutboxEntry; answer: CreateConflictAnswer }
741
+ | { file: null; entry: null; answer: CreateConflictAnswer }
742
+ | null
743
+ > {
727
744
  if (!opts.onCreateConflict || !entry.action) return null;
728
745
  let answer: CreateConflictAnswer | null = null;
729
746
  try {
@@ -733,18 +750,24 @@ export function createTransactionClient(opts: TransactionClientOptions) {
733
750
  `[sync/tx] ${entry.label}: could not move it to a free name (${(err as Error).message})`
734
751
  );
735
752
  }
736
- if (!answer?.renames.length) return null;
753
+ if (!answer || (!answer.renames.length && !answer.withdrawn?.length)) return null;
737
754
  const by = new Map(answer.renames.map((r) => [r.fromDoc, r]));
755
+ // 2.0.2 — a withdrawn create leaves the proposal; nothing else changes for it.
756
+ const out = new Set((answer.withdrawn ?? []).map((w) => w.doc));
757
+ const operations = entry.action.operations
758
+ .filter((o) => !(o.op === 'doc.create' && typeof o.doc === 'string' && out.has(o.doc)))
759
+ .map((o) => (o.op === 'doc.create' ? renamedOp(o, by) : o));
760
+ if (!operations.length) {
761
+ // Nothing left to send: what waited on it no longer depends on it.
762
+ rewriteQueued(by, entry.transactionId, null, entry.createdAt);
763
+ rmSync(file, { force: true });
764
+ return { file: null, entry: null, answer };
765
+ }
738
766
  // Derived, not drawn: a replay that rewrites the queue again names the
739
767
  // same transaction (it is only ever written once, so never sent twice).
740
768
  const transactionId = `tx_${sha256(`${entry.transactionId}:renamed`).slice(0, 32)}`;
741
769
  rewriteQueued(by, entry.transactionId, transactionId, entry.createdAt);
742
- const action = {
743
- ...entry.action,
744
- operations: entry.action.operations.map((o) =>
745
- o.op === 'doc.create' ? renamedOp(o, by) : o
746
- ),
747
- };
770
+ const action = { ...entry.action, operations };
748
771
  const next: OutboxEntry = {
749
772
  ...makeEntry(action, transactionId, {
750
773
  transactionId,
@@ -818,14 +841,33 @@ export function createTransactionClient(opts: TransactionClientOptions) {
818
841
  // S6.13b — the name was taken while this Mac was away: the canvas moves to
819
842
  // the next free one and its create goes again (bounded: a name taken again
820
843
  // meanwhile moves on once more).
844
+ // 2.0.2 — the creates taken out on the way (the same file; a module; a canvas gone).
845
+ const withdrawn: CreateWithdrawal[] = [];
846
+ let operations = entry.action?.operations ?? [];
821
847
  for (let round = 0; isCreateConflict(entry, result); round++) {
822
848
  const renamed = round < 5 ? await renameRefusedCreate(file, entry, result) : null;
823
849
  if (!renamed) {
824
850
  rmSync(file, { force: true });
825
851
  break;
826
852
  }
853
+ withdrawn.push(...(renamed.answer.withdrawn ?? []));
854
+ if (renamed.file === null) {
855
+ // Every create left the proposal: nothing was sent. When the project already holds each
856
+ // of them as it is here, that is the answer this change wanted; otherwise the refusal stands.
857
+ operations = [];
858
+ if (withdrawn.every((w) => w.why === 'same'))
859
+ result = {
860
+ protocol: result.protocol,
861
+ status: 'accepted',
862
+ code: 'withdrawn',
863
+ transactionId: entry.transactionId,
864
+ };
865
+ renamed.answer.settled(result);
866
+ break;
867
+ }
827
868
  file = renamed.file;
828
869
  entry = renamed.entry;
870
+ operations = entry.action?.operations ?? [];
829
871
  const current = entry;
830
872
  owned.add(file);
831
873
  try {
@@ -835,11 +877,12 @@ export function createTransactionClient(opts: TransactionClientOptions) {
835
877
  }
836
878
  renamed.answer.settled(result);
837
879
  }
880
+ // The caller of a withdrawn create learns it was not sent (accepted-link `createDoc`).
881
+ if (withdrawn.length) result = { ...result, withdrawn };
838
882
  if (result.status === 'accepted') {
839
883
  acks.push(Math.max(0, now() - madeAt));
840
884
  if (acks.length > 200) acks.shift();
841
885
  } else rejectedCount++;
842
- const operations = entry.action?.operations ?? [];
843
886
  opts.onResult?.(result, { label: entry.label, operations });
844
887
  return { result, operations };
845
888
  }
@@ -563,6 +563,8 @@ export const WRITER_REGISTRY: Record<string, WriterEntry> = {
563
563
  '/_api/asset-state': { class: 'read' }, // routes/asset-state.ts (S8.19): disk + queue + hub presence, no effect
564
564
  // routes/asset-details.ts (S8.21): the details of one asset and the Generated runs — reads of the project's own sidecars
565
565
  '/_api/asset-details': { class: 'read' },
566
+ // routes/ds-assets.ts (2.0.2): a design system's own asset library, one folder per page — a read of versioned media
567
+ '/_api/ds/assets': { class: 'read' },
566
568
  '/_api/asset-generated': { class: 'read' },
567
569
  // routes/generate.ts (S8.16): the consent quote is this process's memory; `of` reads a take's `.gen.json`
568
570
  '/_api/generate-takes/quote': { class: 'local' },
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "$schema": "./whats-new.schema.json",
3
3
  "entries": [
4
+ {
5
+ "id": "lfs-placeholder-fix",
6
+ "version": "2.0.3",
7
+ "date": "2026-11-04",
8
+ "kind": "fix",
9
+ "title": "Pictures that were never downloaded say so",
10
+ "summary": "A picture or video that is still a Git LFS placeholder now says \"Not downloaded — Git LFS placeholder\" instead of \"not found\". In the desktop app, Fix with AI puts a restore prompt in the chat, and Copy prompt copies it. Sync no longer uploads the placeholder as if it were the picture.",
11
+ "surface": "design-ui"
12
+ },
4
13
  {
5
14
  "id": "maude-v2-canvas-window",
6
15
  "version": "2.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1agh/maude",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Marketplace of Claude Code plugins by Michal Dovrtěl: `design` (canvas-first design iteration) + `flow` (generic agentic workflow loop with .ai second brain). Ships the `maude` CLI (with `mdcc` legacy alias) to scaffold workspace, run the design dev server, and manage configs.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -65,13 +65,13 @@
65
65
  "test:e2e:desktop:parity:cloud": "pnpm --filter @maude/desktop-e2e e2e:parity:cloud"
66
66
  },
67
67
  "optionalDependencies": {
68
- "@1agh/maude-darwin-arm64": "2.0.1",
69
- "@1agh/maude-darwin-x64": "2.0.1",
70
- "@1agh/maude-linux-arm64": "2.0.1",
71
- "@1agh/maude-linux-arm64-musl": "2.0.1",
72
- "@1agh/maude-linux-x64": "2.0.1",
73
- "@1agh/maude-linux-x64-musl": "2.0.1",
74
- "@1agh/maude-win32-x64": "2.0.1"
68
+ "@1agh/maude-darwin-arm64": "2.0.3",
69
+ "@1agh/maude-darwin-x64": "2.0.3",
70
+ "@1agh/maude-linux-arm64": "2.0.3",
71
+ "@1agh/maude-linux-arm64-musl": "2.0.3",
72
+ "@1agh/maude-linux-x64": "2.0.3",
73
+ "@1agh/maude-linux-x64-musl": "2.0.3",
74
+ "@1agh/maude-win32-x64": "2.0.3"
75
75
  },
76
76
  "files": [
77
77
  "cli",