@ddtcorex/dsh-maestro-core 0.14.0 → 0.15.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 (51) hide show
  1. package/lib/client.js +4 -125
  2. package/lib/debug-agent.js +2 -1
  3. package/lib/plugin.d.ts +1 -0
  4. package/lib/plugin.js +17 -4
  5. package/lib/resume.js +9 -1
  6. package/lib/sync/backup-service.d.ts +13 -0
  7. package/lib/sync/backup-service.js +60 -14
  8. package/lib/sync/hashing.d.ts +13 -0
  9. package/lib/sync/hashing.js +30 -0
  10. package/lib/sync/merge.d.ts +1 -1
  11. package/lib/sync/merge.js +1 -1
  12. package/lib/sync/remote-agent.js +12 -1
  13. package/lib/sync/remote-cache.js +1 -1
  14. package/lib/sync/remote-manifest.d.ts +25 -0
  15. package/lib/sync/remote-manifest.js +49 -2
  16. package/lib/sync/store-root.d.ts +44 -0
  17. package/lib/sync/store-root.js +67 -0
  18. package/lib/sync/sync-service.d.ts +25 -1
  19. package/lib/sync/sync-service.js +117 -12
  20. package/lib/sync/sync-types.d.ts +1 -1
  21. package/lib/sync/validation.d.ts +2 -0
  22. package/lib/sync/validation.js +15 -2
  23. package/lib/types/client/config/components/BrandMark.d.ts +1 -1
  24. package/lib/types/client/config/components/BrandMark.d.ts.map +1 -1
  25. package/lib/types/client/config/index.d.ts +0 -1
  26. package/lib/types/client/config/index.d.ts.map +1 -1
  27. package/lib/types/client/config/maestro-mark.d.ts +6 -16
  28. package/lib/types/client/config/maestro-mark.d.ts.map +1 -1
  29. package/lib/types/client/sync/index.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/src/client/config/components/BrandMark.tsx +0 -1
  32. package/src/client/config/index.tsx +5 -44
  33. package/src/client/config/maestro-mark.ts +6 -23
  34. package/src/client/sync/index.tsx +0 -50
  35. package/src/client/sync/ui.tsx +4 -4
  36. package/src/host/debug-agent.ts +2 -1
  37. package/src/host/plugin.ts +19 -5
  38. package/src/host/resume.ts +10 -1
  39. package/src/host/sync/backup-service.ts +67 -14
  40. package/src/host/sync/hashing.ts +34 -1
  41. package/src/host/sync/merge.ts +1 -1
  42. package/src/host/sync/remote-agent.ts +12 -1
  43. package/src/host/sync/remote-cache.ts +1 -1
  44. package/src/host/sync/remote-manifest.ts +49 -2
  45. package/src/host/sync/store-root.ts +83 -0
  46. package/src/host/sync/sync-service.ts +131 -12
  47. package/src/host/sync/sync-types.ts +1 -1
  48. package/src/host/sync/validation.ts +15 -2
  49. package/lib/types/client/config/settings-nav-icon.d.ts +0 -21
  50. package/lib/types/client/config/settings-nav-icon.d.ts.map +0 -1
  51. package/src/client/config/settings-nav-icon.ts +0 -68
@@ -0,0 +1,83 @@
1
+ /**
2
+ * sync/store-root.ts — where the memory store lives, resolved the same way the plugin
3
+ * resolves it.
4
+ *
5
+ * Core cannot import the plugin (separate package, separate release), so this is a
6
+ * deliberate second implementation. `tests/sync/store-root-parity.spec.ts` runs the
7
+ * shared fixture against it, and the plugin runs the same fixture against its own
8
+ * copy, so a rule change on one side fails on that side instead of drifting silently.
9
+ *
10
+ * The rules, in order:
11
+ * 1. `memoryDir` (explicit config) wins.
12
+ * 2. `MAESTRO_MEMORY_DIR` wins next.
13
+ * 3. A `DSH_HOME` that realpaths somewhere other than `<home>/.dsh` is an isolated run
14
+ * (dry-boot, test, second profile): the store stays inside it.
15
+ * 4. Otherwise the neutral root, `<home>/.maestro-memory`.
16
+ */
17
+
18
+ import { realpathSync } from 'node:fs';
19
+ import { homedir } from 'node:os';
20
+ import { join } from 'node:path';
21
+
22
+ export type StoreRootMode = 'configured' | 'env' | 'isolated' | 'default';
23
+
24
+ export interface StoreRoot {
25
+ root: string;
26
+ mode: StoreRootMode;
27
+ }
28
+
29
+ function realpathOr(value: string): string {
30
+ try {
31
+ return realpathSync.native(value);
32
+ } catch {
33
+ return value;
34
+ }
35
+ }
36
+
37
+ export function resolveStoreRoot(
38
+ opts: { memoryDir?: string | null; env?: NodeJS.ProcessEnv; home?: string } = {},
39
+ ): StoreRoot {
40
+ if (opts.memoryDir) return { root: opts.memoryDir, mode: 'configured' };
41
+ const env = opts.env ?? process.env;
42
+ const envDir = typeof env.MAESTRO_MEMORY_DIR === 'string' ? env.MAESTRO_MEMORY_DIR.trim() : '';
43
+ if (envDir) return { root: envDir, mode: 'env' };
44
+
45
+ const home = realpathOr(opts.home ?? homedir());
46
+ const dshDefault = join(home, '.dsh');
47
+ const rawDsh = typeof env.DSH_HOME === 'string' && env.DSH_HOME.trim() ? env.DSH_HOME.trim() : '';
48
+ if (rawDsh && realpathOr(rawDsh) !== dshDefault) {
49
+ return { root: join(rawDsh, 'maestro-memory'), mode: 'isolated' };
50
+ }
51
+ return { root: join(home, '.maestro-memory'), mode: 'default' };
52
+ }
53
+
54
+ /** Map a wire path onto the local filesystem. Wire paths never change; roots do. */
55
+ export function localPathForWirePath(
56
+ wirePath: string,
57
+ roots: { storeRoot: string; localDsh: string },
58
+ ): string {
59
+ if (wirePath.startsWith('maestro-memory/')) {
60
+ return join(roots.storeRoot, wirePath.slice('maestro-memory/'.length));
61
+ }
62
+ return join(roots.localDsh, wirePath);
63
+ }
64
+
65
+ /**
66
+ * Group wire paths by the local root they resolve to, so a caller that hashes or stats
67
+ * many paths at once hashes each group against its own root instead of assuming the
68
+ * DSH home. After the store move, `maestro-memory/...` and `sessions/...` live in two
69
+ * different trees.
70
+ */
71
+ export function partitionByWireRoot(
72
+ wirePaths: string[],
73
+ roots: { storeRoot: string; localDsh: string },
74
+ ): Array<{ root: string; paths: string[] }> {
75
+ const groups = new Map<string, string[]>();
76
+ for (const wire of wirePaths) {
77
+ const root = wire.startsWith('maestro-memory/') ? roots.storeRoot : roots.localDsh;
78
+ const bucket = groups.get(root);
79
+ if (bucket) bucket.push(wire);
80
+ else groups.set(root, [wire]);
81
+ }
82
+ return [...groups.entries()].map(([root, paths]) => ({ root, paths }));
83
+ }
@@ -18,9 +18,17 @@ import * as path from 'node:path';
18
18
  import * as os from 'node:os';
19
19
  import { randomBytes } from 'node:crypto';
20
20
  import { mergeDelimited } from './merge.js';
21
+
22
+ /**
23
+ * Hash a mixed list of wire paths, each group against the root it lives under.
24
+ * Before the store moved, one root covered everything; it no longer does, and hashing
25
+ * `maestro-memory/...` under the DSH home fails with ENOENT on the first memory file.
26
+ */
27
+
28
+ import { localPathForWirePath, resolveStoreRoot } from './store-root.js';
21
29
  import { mergeSessionBuffers } from './session-plan.js';
22
30
  import { kindForPath } from './snapshot.js';
23
- import { hashFiles } from './hashing.js';
31
+ import { hashFiles, hashWirePaths } from './hashing.js';
24
32
  import { loadIndex, saveIndex, probeIndex, matchesStat, statFingerprint } from './fingerprint.js';
25
33
  import type { RemoteManifestEntry } from './remote-manifest.js';
26
34
  import { buildPlan, buildPreview, getPreview, getPreviewDirection, deletePreview, storePreview } from './sync-plan.js';
@@ -86,6 +94,8 @@ export interface PreviewResult extends SyncPreview {
86
94
 
87
95
  export interface SyncServiceOpts {
88
96
  localDsh?: string;
97
+ /** Resolved memory store root; defaults to the same rules the plugin uses. */
98
+ storeRoot?: string;
89
99
  remote?: string;
90
100
  remoteDsh?: string;
91
101
  previewDir?: string;
@@ -101,6 +111,7 @@ function syncFailure(phase: SyncFailure['phase'], code: string, detail: string,
101
111
 
102
112
  export class SyncService {
103
113
  localDsh: string;
114
+ storeRoot: string;
104
115
  remote: string;
105
116
  remoteDsh: string;
106
117
  previewDir: string;
@@ -111,6 +122,14 @@ export class SyncService {
111
122
 
112
123
  constructor(opts: SyncServiceOpts = {}) {
113
124
  this.localDsh = opts.localDsh || process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
125
+ // The store can live outside the DSH home. Wire paths stay `maestro-memory/...`,
126
+ // so every site that touches disk maps through this root, never through localDsh.
127
+ // A caller that pins `localDsh` pins the whole machine state, so the store is
128
+ // resolved against it: a temp home is isolated by construction, and production's
129
+ // own home is not, which is exactly the plugin's rule.
130
+ this.storeRoot =
131
+ opts.storeRoot ??
132
+ resolveStoreRoot({ env: { ...process.env, DSH_HOME: opts.localDsh ?? process.env.DSH_HOME } }).root;
114
133
  this.remote = opts.remote || process.env.REMOTE_HOST || process.env.REMOTE || 'kai@ssh.ddtcorex.com';
115
134
  this.remoteDsh = opts.remoteDsh || process.env.REMOTE_DSH_PATH || '~/.dsh';
116
135
  // Sidecar preview store shared by every CLI process (preview -> separate apply run).
@@ -171,12 +190,26 @@ export class SyncService {
171
190
  }
172
191
 
173
192
  /**
174
- * Local eligible files (dsh-maestro-memory/*.md, dsh-maestro-memory/SUGGESTIONS.jsonl,
193
+ * Local eligible files (maestro-memory/*.md, maestro-memory/SUGGESTIONS.jsonl,
175
194
  * sessions/<cwd-hash>/<id>/session.jsonl.zstd) as relative paths, sorted.
176
195
  * Only content that matches the eligible contract is ever read or hashed.
177
196
  */
197
+ /** The two roots a wire path can resolve to. */
198
+ hashRoots(): { storeRoot: string; localDsh: string } {
199
+ return { storeRoot: this.storeRoot, localDsh: this.localDsh };
200
+ }
201
+
202
+ /** Map a wire path to its local file, through the resolved store root. */
203
+ localPathForWirePath(wirePath: string): string {
204
+ return localPathForWirePath(wirePath, { storeRoot: this.storeRoot, localDsh: this.localDsh });
205
+ }
206
+
178
207
  listLocalFiles(): string[] {
179
208
  const root = this.localDsh;
209
+ // The store may live outside the DSH home, so its files are collected from the
210
+ // resolved root and labelled with the wire prefix. Sessions stay under the DSH
211
+ // home; they are harness data by definition.
212
+ const storeRootDiffers = this.storeRoot !== path.join(this.localDsh, 'maestro-memory');
180
213
  const result: string[] = [];
181
214
  const fsMod = this.fs;
182
215
  const walk = (dir: string, base: string) => {
@@ -214,7 +247,24 @@ export class SyncService {
214
247
  } catch {
215
248
  return [];
216
249
  }
217
- walk(root, '');
250
+ if (!storeRootDiffers) {
251
+ // Store inside the DSH home: one walk covers everything, exactly as before.
252
+ walk(root, '');
253
+ } else {
254
+ // Store elsewhere: walk the DSH home for sessions and harness state, skipping the
255
+ // path the store would occupy, then walk the store itself under its wire prefix.
256
+ const harnessOwned: string[] = [];
257
+ const push = result.push.bind(result);
258
+ result.push = (...items: string[]) => harnessOwned.push(...items) as unknown as number;
259
+ walk(root, '');
260
+ result.push = push;
261
+ for (const wire of harnessOwned) {
262
+ const normalised = wire.split(path.sep).join('/');
263
+ if (normalised === 'maestro-memory' || normalised.startsWith('maestro-memory/')) continue;
264
+ result.push(wire);
265
+ }
266
+ walk(this.storeRoot, 'maestro-memory');
267
+ }
218
268
  return [...new Set(
219
269
  result
220
270
  .map((p) => p.split(path.sep).join('/'))
@@ -242,6 +292,73 @@ export class SyncService {
242
292
  * re-hashed at write time (see apply), so a stale cache can never publish a
243
293
  * wrong mutation target.
244
294
  */
295
+ /**
296
+ * The 4.0 rename moved the store root. A machine still on the old root would
297
+ * inventory zero memory files, which reads exactly like "nothing to sync".
298
+ * Refuse instead: the marker is written by the plugin's boot migration.
299
+ */
300
+ private assertLocalStoreMigrated(): void {
301
+ const probe = (this.fs as any)?.existsSync;
302
+ if (typeof probe !== 'function') return;
303
+ const current = this.storeRoot;
304
+ const legacy = path.join(this.localDsh, 'dsh-maestro-memory');
305
+ const v4 = path.join(this.localDsh, 'maestro-memory');
306
+ let currentExists = false;
307
+ let legacyExists = false;
308
+ try {
309
+ currentExists = probe.call(this.fs, current);
310
+ legacyExists = probe.call(this.fs, legacy);
311
+ } catch {
312
+ return;
313
+ }
314
+ // Only the half-migrated shape is refused: the old root is still there and
315
+ // the new one is absent. A fresh DSH_HOME has neither, and a migrated one
316
+ // has the new root, so both stay usable.
317
+ // A store still at a legacy root would inventory zero files through the new root,
318
+ // which reads exactly like "nothing to sync". Refuse instead.
319
+ let v4Exists = false;
320
+ try {
321
+ v4Exists = current !== v4 && probe.call(this.fs, v4);
322
+ } catch {}
323
+ if (!currentExists && legacyExists) {
324
+ throw syncFailure(
325
+ 'snapshot',
326
+ 'STORE_NOT_MIGRATED',
327
+ `local store is still at ${legacy}; run the current build on this machine (its boot migration moves it) before syncing`,
328
+ );
329
+ }
330
+ if (!currentExists && v4Exists) {
331
+ throw syncFailure(
332
+ 'snapshot',
333
+ 'STORE_NOT_MIGRATED',
334
+ `local store is still at ${v4}; install the current build (its boot migration moves it to ${current}) before syncing`,
335
+ );
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Refuse a peer that still keeps its store inside the DSH home.
341
+ *
342
+ * The wire paths are the same on both sides, so a mixed pair writes into a directory
343
+ * the upgraded machine no longer reads: the transfer succeeds and the memories are
344
+ * invisible. The marker is the only signal available before the transfer starts.
345
+ */
346
+ assertPeerMoved(remotePaths: string[]): void {
347
+ // Only meaningful once this machine has moved: while our own store still sits inside
348
+ // the DSH home, the peer's layout is the one that matches and there is nothing to
349
+ // protect against.
350
+ if (this.storeRoot === path.join(this.localDsh, 'maestro-memory')) return;
351
+ const hasMemory = remotePaths.some((p) => p.startsWith('maestro-memory/'));
352
+ const hasMarker = remotePaths.includes('maestro-memory/.maestro-memory/migrated-v5.json');
353
+ if (hasMemory && !hasMarker) {
354
+ throw syncFailure(
355
+ 'snapshot',
356
+ 'PEER_NOT_MOVED',
357
+ `the peer ${this.remote ?? 'unknown'} still keeps its store inside its DSH home (memory files present, no migrated-v5.json marker); upgrade maestro-memory on that machine and restart it before syncing`,
358
+ );
359
+ }
360
+ }
361
+
245
362
  private async snapshotBoth(opts: { scope?: SyncScope; sessionsCountOnly?: boolean; onProgress?: (p: SyncProgress) => void; shouldStop?: () => boolean } = {}): Promise<{
246
363
  target: RemoteTarget;
247
364
  localSnapshots: FileSnapshot[];
@@ -250,6 +367,7 @@ export class SyncService {
250
367
  remoteContents: Map<string, Buffer>;
251
368
  cleanup: () => void;
252
369
  }> {
370
+ this.assertLocalStoreMigrated();
253
371
  const progress = (phase: SyncProgress['phase'], current: number, total: number, file?: string) => opts.onProgress?.({ phase, current, total, file });
254
372
  const stop = () => {
255
373
  if (opts.shouldStop?.()) throw syncFailure('snapshot', 'CANCELLED', 'preview cancelled');
@@ -258,11 +376,12 @@ export class SyncService {
258
376
  const fsMod = this.fs;
259
377
  const target = await this.requireTarget();
260
378
  stop();
261
- // Scope filter: 'memory' covers dsh-maestro-memory only and skips the
379
+ // Scope filter: 'memory' covers maestro-memory only and skips the
262
380
  // live session logs; undefined/'all' preserves the legacy full inventory.
263
381
  const inScope = (p: string): boolean => opts.scope !== 'memory' || !p.startsWith('sessions/');
264
382
  const localPaths = this.listLocalFiles().filter(inScope);
265
383
  const remoteManifest = (await this.transport.manifest(target)).filter((e) => inScope(e.path));
384
+ this.assertPeerMoved(remoteManifest.map((e) => e.path));
266
385
  stop();
267
386
  const remoteSnapshots = remoteManifest.map((e) => ({ path: e.path, sha256: e.sha256, size: e.size, kind: kindForPath(e.path) }));
268
387
  const remoteSet = new Set(remoteManifest.map((e) => e.path));
@@ -275,7 +394,7 @@ export class SyncService {
275
394
  const entry = probeIndex(p, index);
276
395
  let st: any = null;
277
396
  try {
278
- st = typeof fsMod.statSync === 'function' ? fsMod.statSync(path.join(this.localDsh, p), { bigint: true } as any) : null;
397
+ st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(p), { bigint: true } as any) : null;
279
398
  } catch {
280
399
  st = null;
281
400
  }
@@ -286,7 +405,7 @@ export class SyncService {
286
405
  }
287
406
  }
288
407
  let hashedCount = 0;
289
- const staleHashes = await hashFiles(fsMod, this.localDsh, stale, {
408
+ const staleHashes = await hashWirePaths(fsMod, this.hashRoots(), stale, {
290
409
  onFile: (h) => {
291
410
  hashedCount++;
292
411
  progress('hashing', hashedCount, stale.length, h.path);
@@ -296,7 +415,7 @@ export class SyncService {
296
415
  for (const h of staleHashes) {
297
416
  localSnapshots.push({ path: h.path, sha256: h.sha256, size: h.size, kind: kindForPath(h.path) });
298
417
  try {
299
- const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(path.join(this.localDsh, h.path), { bigint: true } as any) : null;
418
+ const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(h.path), { bigint: true } as any) : null;
300
419
  if (st) index.entries[h.path] = { ...statFingerprint(st), sha256: h.sha256 };
301
420
  } catch {
302
421
  // stat races are tolerable — the entry simply misses next run
@@ -322,7 +441,7 @@ export class SyncService {
322
441
  const localBufferOf = (rel: string): Buffer | undefined => {
323
442
  if (localContents.has(rel)) return localContents.get(rel);
324
443
  try {
325
- const d = fsMod.readFileSync(path.join(this.localDsh, rel));
444
+ const d = fsMod.readFileSync(this.localPathForWirePath(rel));
326
445
  const buf = Buffer.isBuffer(d) ? Buffer.from(d) : Buffer.from(String(d), 'utf-8');
327
446
  localContents.set(rel, buf);
328
447
  return buf;
@@ -612,7 +731,7 @@ export class SyncService {
612
731
  } else {
613
732
  buf = this.mergeBuffer(act, localContents, remoteContents, 'pull');
614
733
  }
615
- await this.atomicWriteWithBackup(path.join(this.localDsh, act.path), buf);
734
+ await this.atomicWriteWithBackup(this.localPathForWirePath(act.path), buf);
616
735
  committed.push(act.path);
617
736
  } catch (e: any) {
618
737
  failures.push(syncFailure('publish', e?.code ?? 'PUBLISH_FAILED', String(e?.message ?? e), act.path) as SyncFailure);
@@ -728,7 +847,7 @@ export class SyncService {
728
847
  const entry = probeIndex(p, index);
729
848
  let st: any = null;
730
849
  try {
731
- st = typeof fsMod.statSync === 'function' ? fsMod.statSync(path.join(this.localDsh, p), { bigint: true } as any) : null;
850
+ st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(p), { bigint: true } as any) : null;
732
851
  } catch {
733
852
  st = null;
734
853
  }
@@ -737,7 +856,7 @@ export class SyncService {
737
856
  }
738
857
  if (stale.length > 0) {
739
858
  let i = 0;
740
- const hashed = await hashFiles(fsMod, this.localDsh, stale, {
859
+ const hashed = await hashWirePaths(fsMod, this.hashRoots(), stale, {
741
860
  onFile: (h) => {
742
861
  i++;
743
862
  onProgress?.(i, stale.length, h.path);
@@ -746,7 +865,7 @@ export class SyncService {
746
865
  for (const h of hashed) {
747
866
  out.set(h.path, h.sha256);
748
867
  try {
749
- const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(path.join(this.localDsh, h.path), { bigint: true } as any) : null;
868
+ const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(h.path), { bigint: true } as any) : null;
750
869
  if (st) index.entries[h.path] = { ...statFingerprint(st), sha256: h.sha256 };
751
870
  } catch {}
752
871
  }
@@ -98,5 +98,5 @@ export interface ApplyRequest {
98
98
  confirm: true;
99
99
  }
100
100
 
101
- /** Inventory scope: 'memory' covers dsh-maestro-memory only, 'all' adds sessions/. */
101
+ /** Inventory scope: 'memory' covers maestro-memory only, 'all' adds sessions/. */
102
102
  export type SyncScope = 'memory' | 'all';
@@ -2,8 +2,21 @@ import type { RemoteTarget } from './sync-types.js';
2
2
 
3
3
  export const HOST_RE = /^(?!-)[A-Za-z0-9._@:-]+$/;
4
4
  export const ABSOLUTE_RE = /^\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+$/;
5
+ // `migrated-v5.json` is the store-move marker: a peer that carries it has moved its
6
+ // store out of the DSH home. Sync needs to see it to refuse a half-upgraded pair instead
7
+ // of publishing into a directory the peer no longer reads.
5
8
  export const ELIGIBLE_RE =
6
- /^(?:dsh-maestro-memory\/(?!.*\.bak\.)[A-Za-z0-9._\/-]+\.md|dsh-maestro-memory\/SUGGESTIONS\.jsonl|sessions\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/session\.jsonl\.zstd|sessions\/[A-Za-z0-9._\/-]+\.jsonl\.zstd)$/;
9
+ /^(?:maestro-memory\/(?!.*\.bak\.)[A-Za-z0-9._\/-]+\.md|maestro-memory\/SUGGESTIONS\.jsonl|maestro-memory\/\.maestro-memory\/migrated-v5\.json|sessions\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/session\.jsonl\.zstd|sessions\/[A-Za-z0-9._\/-]+\.jsonl\.zstd)$/;
10
+
11
+ /** True when a wire path is eligible, without throwing at the caller. */
12
+ export function isEligiblePath(value: string): boolean {
13
+ try {
14
+ normalizeEligiblePath(value);
15
+ return true;
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
7
20
 
8
21
  // Backwards-compatible aliases required by spec
9
22
  export const HOST = HOST_RE;
@@ -73,7 +86,7 @@ export function normalizeEligiblePath(value: string): string {
73
86
  throw new Error(`ineligible path: contains control characters: ${JSON.stringify(value)}`);
74
87
  }
75
88
  if (value.includes('..')) {
76
- // traversal not allowed at all; eligible paths are strictly under dsh-maestro-memory/ or sessions/
89
+ // traversal not allowed at all; eligible paths are strictly under maestro-memory/ or sessions/
77
90
  // The ELIGIBLE regex would reject it anyway, but be explicit
78
91
  throw new Error(`ineligible path: traversal: ${JSON.stringify(value)}`);
79
92
  }
@@ -1,21 +0,0 @@
1
- /**
2
- * Mark this plugin's row in the DSH settings navigation so a style block can
3
- * replace the shell's fallback gear with the maestro glyph.
4
- *
5
- * DSH 0.1.x projects only `id`, `order`, and `label` from a `settings.section`
6
- * registration and picks icons from a closed built-in list, so each external
7
- * plugin identifies its own localized row by visible text after the dialog
8
- * mounts. The marker owns no shell structure and is removed on disposal.
9
- */
10
- export declare const SETTINGS_NAV_MARKER = "data-maestro-settings-nav";
11
- /** Minimal DOM surface used here; tests inject a stub instead of `document`. */
12
- /** The two DOM iteration shapes this module touches (querySelector results). */
13
- type NodeSeq = Iterable<Element> & {
14
- forEach(fn: (el: Element) => void): unknown;
15
- };
16
- interface DomScope {
17
- querySelectorAll(selector: string): NodeSeq;
18
- }
19
- export declare function registerSettingsNavIcon(label: () => string, root?: DomScope): () => void;
20
- export {};
21
- //# sourceMappingURL=settings-nav-icon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings-nav-icon.d.ts","sourceRoot":"","sources":["../../../../src/client/config/settings-nav-icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,mBAAmB,8BAA8B,CAAA;AAE9D,gFAAgF;AAChF,gFAAgF;AAChF,KAAK,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAA;CAAE,CAAA;AAElF,UAAU,QAAQ;IAChB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAC5C;AAOD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,MAAM,EACnB,IAAI,CAAC,EAAE,QAAQ,GACd,MAAM,IAAI,CAuCZ"}
@@ -1,68 +0,0 @@
1
- /**
2
- * Mark this plugin's row in the DSH settings navigation so a style block can
3
- * replace the shell's fallback gear with the maestro glyph.
4
- *
5
- * DSH 0.1.x projects only `id`, `order`, and `label` from a `settings.section`
6
- * registration and picks icons from a closed built-in list, so each external
7
- * plugin identifies its own localized row by visible text after the dialog
8
- * mounts. The marker owns no shell structure and is removed on disposal.
9
- */
10
-
11
- export const SETTINGS_NAV_MARKER = 'data-maestro-settings-nav'
12
-
13
- /** Minimal DOM surface used here; tests inject a stub instead of `document`. */
14
- /** The two DOM iteration shapes this module touches (querySelector results). */
15
- type NodeSeq = Iterable<Element> & { forEach(fn: (el: Element) => void): unknown }
16
-
17
- interface DomScope {
18
- querySelectorAll(selector: string): NodeSeq
19
- }
20
-
21
- type ElementLike = Element & {
22
- setAttribute(name: string, value: string): void
23
- removeAttribute(name: string): void
24
- }
25
-
26
- export function registerSettingsNavIcon(
27
- label: () => string,
28
- root?: DomScope,
29
- ): () => void {
30
- if (typeof document === 'undefined' && root === undefined) {
31
- // Node-side import safety (tests inject a stub root instead).
32
- return () => {}
33
- }
34
- const scope = (root ?? document) as DomScope
35
-
36
- let disposed = false
37
-
38
- const sync = () => {
39
- if (disposed) return
40
- const currentLabel = label().trim()
41
- const buttons = scope.querySelectorAll('[role="dialog"] nav button')
42
- for (const button of Array.from(buttons)) {
43
- const el = button as ElementLike
44
- const matches =
45
- currentLabel.length > 0 &&
46
- button.textContent != null &&
47
- button.textContent.trim() === currentLabel
48
- if (matches) el.setAttribute(SETTINGS_NAV_MARKER, '')
49
- else el.removeAttribute(SETTINGS_NAV_MARKER)
50
- }
51
- }
52
-
53
- sync()
54
-
55
- let observer: MutationObserver | null = null
56
- if (typeof MutationObserver !== 'undefined') {
57
- observer = new MutationObserver(sync)
58
- observer.observe(document.body, { childList: true, subtree: true, characterData: true })
59
- }
60
-
61
- return () => {
62
- disposed = true
63
- if (observer !== null) observer.disconnect()
64
- for (const element of Array.from(scope.querySelectorAll(`[${SETTINGS_NAV_MARKER}]`))) {
65
- ;(element as ElementLike).removeAttribute(SETTINGS_NAV_MARKER)
66
- }
67
- }
68
- }