@1agh/maude 1.6.13 → 1.8.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.
Files changed (60) hide show
  1. package/apps/studio/acp/bridge.ts +1 -0
  2. package/apps/studio/acp/login-state.ts +1 -0
  3. package/apps/studio/acp/probe.ts +1 -0
  4. package/apps/studio/annotations/ai-read.ts +3 -0
  5. package/apps/studio/annotations/ai-write.ts +15 -1
  6. package/apps/studio/annotations/lock.ts +174 -0
  7. package/apps/studio/annotations/migrate-v1.ts +1 -0
  8. package/apps/studio/annotations/registry.ts +3 -0
  9. package/apps/studio/annotations/v1-adapter.ts +1 -0
  10. package/apps/studio/annotations-context-toolbar.tsx +39 -0
  11. package/apps/studio/annotations-layer.tsx +167 -17
  12. package/apps/studio/annotations-model.ts +9 -0
  13. package/apps/studio/api.ts +412 -35
  14. package/apps/studio/asset-upload.ts +174 -0
  15. package/apps/studio/assets-s3.ts +37 -2
  16. package/apps/studio/bin/_pdf-playwright.mjs +22 -1
  17. package/apps/studio/bin/_png-playwright.mjs +20 -1
  18. package/apps/studio/bin/_region.mjs +92 -0
  19. package/apps/studio/canvas-build.ts +59 -4
  20. package/apps/studio/canvas-icons.tsx +18 -0
  21. package/apps/studio/canvas-lib.tsx +48 -1
  22. package/apps/studio/canvas-shell.tsx +28 -4
  23. package/apps/studio/client/app.jsx +109 -22
  24. package/apps/studio/client/canvas-url.js +9 -0
  25. package/apps/studio/client/embed-view.jsx +284 -0
  26. package/apps/studio/client/embed.js +101 -0
  27. package/apps/studio/client/export-center.jsx +2 -0
  28. package/apps/studio/client/github.js +36 -3
  29. package/apps/studio/client/report-bug.jsx +8 -2
  30. package/apps/studio/context.ts +7 -0
  31. package/apps/studio/dist/client.bundle.js +2682 -2682
  32. package/apps/studio/dist/comment-mount.js +2 -2
  33. package/apps/studio/embed-origins.ts +52 -0
  34. package/apps/studio/export-dialog.tsx +55 -3
  35. package/apps/studio/exporters/format-scopes.ts +11 -3
  36. package/apps/studio/exporters/index.ts +17 -2
  37. package/apps/studio/exporters/jobs.ts +16 -8
  38. package/apps/studio/exporters/pdf.ts +10 -2
  39. package/apps/studio/exporters/png.ts +10 -2
  40. package/apps/studio/exporters/scope.ts +74 -3
  41. package/apps/studio/generation/runtime-probe.ts +1 -1
  42. package/apps/studio/git/service.ts +1 -0
  43. package/apps/studio/http.ts +186 -13
  44. package/apps/studio/input-router.tsx +7 -1
  45. package/apps/studio/path-containment.ts +72 -0
  46. package/apps/studio/paths.ts +14 -1
  47. package/apps/studio/read-only-mode.ts +53 -0
  48. package/apps/studio/server.ts +9 -0
  49. package/apps/studio/sync/index.ts +74 -13
  50. package/apps/studio/sync/park.ts +39 -0
  51. package/apps/studio/sync/presentation.ts +9 -3
  52. package/apps/studio/sync/writer-registry.ts +5 -0
  53. package/apps/studio/use-annotation-resize.tsx +4 -1
  54. package/apps/studio/use-canvas-media-drop.tsx +8 -28
  55. package/apps/studio/whats-new.json +36 -0
  56. package/cli/commands/design.mjs +9 -2
  57. package/cli/commands/hub-workspace.mjs +25 -0
  58. package/cli/lib/workspace-plan.mjs +51 -0
  59. package/package.json +9 -9
  60. package/plugins/design/templates/_shell.html +58 -0
@@ -1092,6 +1092,7 @@ export class AcpBridge {
1092
1092
  if (runtime.bunBeBun) env.BUN_BE_BUN = '1';
1093
1093
  const proc = Bun.spawn([runtime.bin, adapterEntry], {
1094
1094
  cwd: this.opts.repoRoot,
1095
+ windowsHide: true, // #141 — never a console window for the adapter on Windows
1095
1096
  env,
1096
1097
  stdin: 'pipe',
1097
1098
  stdout: 'pipe',
@@ -47,6 +47,7 @@ export function startSignin(): { ok: boolean; reason?: string } {
47
47
  if (!bin) return { ok: false, reason: 'Claude Code is not installed.' };
48
48
  const child = Bun.spawn([bin, 'auth', 'login', '--claudeai'], {
49
49
  env: scrubAgentEnv(),
50
+ windowsHide: true, // #141
50
51
  stdout: 'ignore',
51
52
  stderr: 'ignore',
52
53
  });
@@ -481,6 +481,7 @@ export async function getClaudeAuthStatus(): Promise<ClaudeAuthStatus | null> {
481
481
  async function readAuthStatusStdout(bin: string): Promise<string> {
482
482
  const proc = Bun.spawn([bin, 'auth', 'status', '--json'], {
483
483
  env: scrubAgentEnv(),
484
+ windowsHide: true, // #141
484
485
  // A wrapper that prompts would otherwise block forever on a tty-less read.
485
486
  stdin: 'ignore',
486
487
  stdout: 'pipe',
@@ -56,6 +56,7 @@ const STRUCTURAL = new Set([
56
56
  'end',
57
57
  'groups',
58
58
  'author',
59
+ 'locked',
59
60
  'kind',
60
61
  'href',
61
62
  'alt',
@@ -163,6 +164,8 @@ function projectOne(scene: Scene, el: AnnotationElement, full: boolean): Project
163
164
  const author = el.author as { kind?: string; name?: string } | undefined;
164
165
  if (author?.kind === 'ai') out.author = 'ai';
165
166
  else if (author?.name) out.authorName = author.name;
167
+ // #137 — an agent must see the lock before it tries to move the element.
168
+ if (el.locked === true) out.locked = true;
166
169
  // Style of KNOWN types only: an unknown type's keys are arbitrary peer data.
167
170
  const known = defOf(el.type);
168
171
  if (full && known) {
@@ -20,6 +20,7 @@
20
20
 
21
21
  import { anchorPoint, facingAnchor } from './elements/arrow.model.ts';
22
22
  import { compareOrder, keyBetween } from './fractional-index.ts';
23
+ import { guardLockedOps, isLocked } from './lock.ts';
23
24
  import { type ApplyResult, applyOps, type Op } from './ops.ts';
24
25
  import './ops-merge.ts';
25
26
  import { defOf, REGISTRY, specOf } from './registry.ts';
@@ -125,6 +126,18 @@ export class AiBatch {
125
126
 
126
127
  /** Apply ops to the local copy; any rejection fails the whole batch loudly. */
127
128
  private apply(ops: Op[], what: string): ApplyResult {
129
+ // #137 — a locked element is the user's "don't touch": the agent gets a
130
+ // clear refusal (and how to unlock), never a silent partial edit.
131
+ if (guardLockedOps(this.state, ops).blocked) {
132
+ const hit =
133
+ ops.find((o) => isLocked(this.state.get(o.op === 'put' ? o.el.id : o.id))) ??
134
+ ops.find((o) => o.op === 'delete');
135
+ const id = hit ? (hit.op === 'put' ? hit.el.id : hit.id) : '?';
136
+ throw new AiOpError(
137
+ `${what}: "${id}" is locked (or holds a locked element) — the user pinned it; ` +
138
+ `unlock it first with {"op":"update","id":"${id}","locked":false} only if the user asked`
139
+ );
140
+ }
128
141
  const r = applyOps(this.state, ops);
129
142
  if (r.rejected.length) {
130
143
  const x = r.rejected[0] as ApplyResult['rejected'][number];
@@ -223,7 +236,8 @@ export class AiBatch {
223
236
  `${what}: "${k}" can't be set here${k === 'parent' ? ' — use reparent' : ''}`
224
237
  );
225
238
  }
226
- if (!Object.hasOwn(def.fields, k)) {
239
+ // `locked` is a tail field every type carries (#137).
240
+ if (!Object.hasOwn(def.fields, k) && k !== 'locked') {
227
241
  throw new AiOpError(
228
242
  `${what}: ${type} has no field "${k0}" (fields: ${Object.keys(def.fields).join(', ')})`
229
243
  );
@@ -0,0 +1,174 @@
1
+ /**
2
+ * @file annotations/lock.ts — the element lock guard (#137)
3
+ * @scope apps/studio/annotations/lock.ts
4
+ * @purpose A locked element can be selected but not moved, resized,
5
+ * rotated, deleted or re-texted from the UI. The UI gates its
6
+ * gestures; `guardLockedOps` is the safety net every UI commit
7
+ * passes through (`commitStrokes`), so a tool path the gating
8
+ * misses still can't change a locked element.
9
+ *
10
+ * A UX guard, NOT a permission: anyone can unlock, and the
11
+ * server op API, sync and undo don't enforce it (an undo batch
12
+ * recorded before the lock, or a pre-lock peer, must still
13
+ * apply). React-free, DOM-free.
14
+ */
15
+
16
+ import { expandIdsToGroups } from '../annotations-groups.ts';
17
+ import type { Stroke } from '../annotations-model.ts';
18
+ import { jsonEq } from './fields.ts';
19
+ import type { Op } from './ops.ts';
20
+ import type { AnnotationElement } from './types.ts';
21
+
22
+ /**
23
+ * Fields a locked element may still change. Allow-listed (not a deny-list of
24
+ * geometry) so a field added later is guarded by default.
25
+ * - `index` — z-order is not a move;
26
+ * - `groups` — grouping a locked element doesn't move it;
27
+ * - `locked` — the unlock itself.
28
+ */
29
+ export const LOCK_EXEMPT_FIELDS: ReadonlySet<string> = new Set(['index', 'groups', 'locked']);
30
+
31
+ export function isLocked(el: AnnotationElement | undefined | null): boolean {
32
+ return el?.locked === true;
33
+ }
34
+
35
+ /** True when the op clears the lock (then the rest of the patch may apply). */
36
+ function unlocks(op: Op): boolean {
37
+ if (op.op === 'put') return op.el.locked !== true;
38
+ if (op.op !== 'patch') return false;
39
+ return op.unset?.includes('locked') === true || (op.set !== undefined && op.set.locked === false);
40
+ }
41
+
42
+ /**
43
+ * Ids whose deletion would take a locked element with it: the locked elements
44
+ * themselves plus every ancestor container of one.
45
+ */
46
+ function protectedFromDelete(
47
+ prev: ReadonlyMap<string, AnnotationElement>,
48
+ lockedIds: ReadonlySet<string>
49
+ ): Set<string> {
50
+ const out = new Set<string>();
51
+ for (const id of lockedIds) {
52
+ out.add(id);
53
+ const seen = new Set<string>([id]);
54
+ let p = prev.get(id)?.parent;
55
+ while (p && !seen.has(p)) {
56
+ seen.add(p);
57
+ out.add(p);
58
+ p = prev.get(p)?.parent;
59
+ }
60
+ }
61
+ return out;
62
+ }
63
+
64
+ function pick(rec: Record<string, unknown> | undefined, keep: (k: string) => boolean) {
65
+ if (!rec) return undefined;
66
+ const out: Record<string, unknown> = {};
67
+ for (const [k, v] of Object.entries(rec)) if (keep(k)) out[k] = v;
68
+ return Object.keys(out).length ? out : undefined;
69
+ }
70
+
71
+ /**
72
+ * Drop what a batch would do to a locked element (as of `prev`): deletes,
73
+ * and every patched field outside `LOCK_EXEMPT_FIELDS`. A batch that unlocks
74
+ * the element passes untouched. The delete of a container holding a locked
75
+ * descendant is dropped too (it would take the locked element with it).
76
+ */
77
+ export function guardLockedOps(
78
+ prev: ReadonlyMap<string, AnnotationElement>,
79
+ ops: readonly Op[]
80
+ ): { ops: Op[]; blocked: number } {
81
+ const lockedIds = new Set<string>();
82
+ for (const el of prev.values()) if (isLocked(el)) lockedIds.add(el.id);
83
+ if (!lockedIds.size) return { ops: [...ops], blocked: 0 };
84
+ // An element unlocked anywhere in this batch is fair game for the whole batch.
85
+ for (const op of ops) {
86
+ const id = op.op === 'put' ? op.el.id : op.id;
87
+ if (lockedIds.has(id) && unlocks(op)) lockedIds.delete(id);
88
+ }
89
+ if (!lockedIds.size) return { ops: [...ops], blocked: 0 };
90
+ const noDelete = protectedFromDelete(prev, lockedIds);
91
+ const out: Op[] = [];
92
+ let blocked = 0;
93
+ for (const op of ops) {
94
+ if (op.op === 'delete') {
95
+ if (noDelete.has(op.id)) {
96
+ blocked++;
97
+ continue;
98
+ }
99
+ out.push(op);
100
+ continue;
101
+ }
102
+ const id = op.op === 'put' ? op.el.id : op.id;
103
+ if (!lockedIds.has(id)) {
104
+ out.push(op);
105
+ continue;
106
+ }
107
+ const before = prev.get(id) as AnnotationElement;
108
+ if (op.op === 'put') {
109
+ // A replace of a locked record keeps only its exempt fields' changes.
110
+ const set: Record<string, unknown> = {};
111
+ const unset: string[] = [];
112
+ for (const k of LOCK_EXEMPT_FIELDS) {
113
+ if (jsonEq(op.el[k], before[k])) continue;
114
+ if (op.el[k] === undefined) unset.push(k);
115
+ else set[k] = op.el[k];
116
+ }
117
+ const keys = new Set([...Object.keys(op.el), ...Object.keys(before)]);
118
+ if ([...keys].some((k) => !LOCK_EXEMPT_FIELDS.has(k) && !jsonEq(op.el[k], before[k]))) {
119
+ blocked++;
120
+ }
121
+ if (Object.keys(set).length || unset.length) {
122
+ out.push({
123
+ op: 'patch',
124
+ id,
125
+ ...(Object.keys(set).length ? { set } : {}),
126
+ ...(unset.length ? { unset } : {}),
127
+ });
128
+ }
129
+ continue;
130
+ }
131
+ const keep = (k: string) => LOCK_EXEMPT_FIELDS.has(k);
132
+ const set = pick(op.set, keep);
133
+ const unset = op.unset?.filter(keep);
134
+ const touched = Object.keys(op.set ?? {}).length + (op.unset?.length ?? 0);
135
+ const kept = Object.keys(set ?? {}).length + (unset?.length ?? 0);
136
+ if (kept < touched) blocked++;
137
+ if (!kept) continue;
138
+ const expect = pick(op.expect, keep);
139
+ out.push({
140
+ op: 'patch',
141
+ id,
142
+ ...(set ? { set } : {}),
143
+ ...(unset?.length ? { unset } : {}),
144
+ ...(expect ? { expect } : {}),
145
+ ...(op.strict ? { strict: true } : {}),
146
+ });
147
+ }
148
+ return { ops: out, blocked };
149
+ }
150
+
151
+ /**
152
+ * Ids of locked strokes in the Stroke view, including a locked shape's
153
+ * anchored label stroke (`anchorId` → host), which inherits its host's lock.
154
+ */
155
+ export function lockedStrokeIds(strokes: readonly Stroke[]): Set<string> {
156
+ const out = new Set<string>();
157
+ for (const s of strokes) if (s.locked) out.add(s.id);
158
+ if (!out.size) return out;
159
+ for (const s of strokes) {
160
+ const a = (s as { anchorId?: string }).anchorId;
161
+ if (a && out.has(a)) out.add(s.id);
162
+ }
163
+ return out;
164
+ }
165
+
166
+ /**
167
+ * True when every (group-expanded) selected element is locked. A mixed
168
+ * selection reads as unlocked, so the Lock / Unlock toggle locks all of it.
169
+ */
170
+ export function isAllLocked(ids: readonly string[], strokes: readonly Stroke[]): boolean {
171
+ if (!ids.length) return false;
172
+ const locked = lockedStrokeIds(strokes);
173
+ return expandIdsToGroups(ids, strokes).every((id) => locked.has(id));
174
+ }
@@ -220,6 +220,7 @@ export function v1ToV2(strokes: readonly Stroke[], opts: V1ToV2Opts = {}): Migra
220
220
  index: indexOf.get(s.id),
221
221
  groups: s.groupIds,
222
222
  author: author(s),
223
+ locked: s.locked === true ? true : undefined,
223
224
  } as Record<string, unknown>,
224
225
  };
225
226
  };
@@ -20,6 +20,7 @@ import { shape } from './elements/shape.model.ts';
20
20
  import { sticky } from './elements/sticky.model.ts';
21
21
  import { textEl } from './elements/text.model.ts';
22
22
  import {
23
+ bool,
23
24
  DANGEROUS_KEYS,
24
25
  type FieldSpecMap,
25
26
  INDEX_RE,
@@ -81,6 +82,8 @@ export const TAIL_FIELDS: FieldSpecMap = {
81
82
  name: str({ max: 64, plain: true }),
82
83
  id: str({ max: 64, plain: true }),
83
84
  }),
85
+ /** Protected against accidental edits in the UI (a UX guard, not a permission). */
86
+ locked: bool(),
84
87
  };
85
88
 
86
89
  const specCache = new Map<string, FieldSpecMap>();
@@ -76,6 +76,7 @@ function shared(el: AnnotationElement): Partial<Stroke> {
76
76
  if (a.id) out.authorId = a.id;
77
77
  }
78
78
  if (num(el.rot) !== 0) out.rotation = num(el.rot);
79
+ if (el.locked === true) out.locked = true;
79
80
  return out as Partial<Stroke>;
80
81
  }
81
82
 
@@ -21,6 +21,7 @@
21
21
  */
22
22
 
23
23
  import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';
24
+ import { isAllLocked, lockedStrokeIds } from './annotations/lock.ts';
24
25
  import { type FormatKey, formatCommands, formatState } from './annotations/ui/editor-channel.ts';
25
26
  import type { AlignEdge } from './annotations-align.ts';
26
27
  import {
@@ -62,6 +63,8 @@ import {
62
63
  IconLink,
63
64
  IconListBullet,
64
65
  IconListOrdered,
66
+ IconLock,
67
+ IconLockOpen,
65
68
  IconObjAlignBottom,
66
69
  IconObjAlignHCenter,
67
70
  IconObjAlignLeft,
@@ -815,6 +818,40 @@ export function AnnotationContextToolbar({
815
818
 
816
819
  if (!annotSel || !store || selectedStrokes.length === 0) return null;
817
820
 
821
+ // #137 — lock. A selection holding a locked element collapses to the one
822
+ // control that matters (nothing else on it may change); a fully locked
823
+ // selection offers Unlock, a mixed one Lock (locks the rest too).
824
+ const lockedIds = lockedStrokeIds(store.strokes);
825
+ const anyLocked = selectedStrokes.some((s) => lockedIds.has(s.id));
826
+ const allLocked = isAllLocked(annotSel.selectedIds, store.strokes);
827
+ const lockBtn = (
828
+ <button
829
+ type="button"
830
+ className="dc-annot-ctx-ibtn"
831
+ data-testid={allLocked ? 'annot-ctx-unlock' : 'annot-ctx-lock'}
832
+ aria-label={allLocked ? 'Unlock selection' : 'Lock selection'}
833
+ aria-pressed={allLocked}
834
+ title={allLocked ? 'Unlock (⌘⇧L)' : 'Lock (⌘⇧L)'}
835
+ onClick={() => store.setLocked(annotSel.selectedIds, !allLocked)}
836
+ >
837
+ {allLocked ? <IconLockOpen /> : <IconLock />}
838
+ </button>
839
+ );
840
+ if (anyLocked) {
841
+ return (
842
+ <div
843
+ ref={ref}
844
+ className="dc-annot-ctx"
845
+ role="toolbar"
846
+ aria-label="Locked selection"
847
+ style={{ display: 'flex', top: -9999, left: -9999 }}
848
+ onPointerDown={(e) => e.stopPropagation()}
849
+ >
850
+ {lockBtn}
851
+ </div>
852
+ );
853
+ }
854
+
818
855
  // ── Phase 23 — dedicated panel for a single image / link selection. ─────────
819
856
  // Image / link carry no color / fill / thickness, so the generic swatch bar is
820
857
  // meaningless for them; render a focused panel instead (image alt for a11y;
@@ -1372,6 +1409,8 @@ export function AnnotationContextToolbar({
1372
1409
  </button>
1373
1410
  </>
1374
1411
  ) : null}
1412
+ <div className="dc-annot-ctx-sep" />
1413
+ {lockBtn}
1375
1414
  {canGroup || canUngroup || canAlign ? (
1376
1415
  <>
1377
1416
  <div className="dc-annot-ctx-sep" />