@yugoo-design/dsh-design-studio 0.0.0-stage → 0.1.0-beta.2

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.
package/lib/index.d.ts ADDED
@@ -0,0 +1,738 @@
1
+ import { DesignKit, DesignSkill, KitResourceContent } from "@yugoo-design/dsh-design-core";
2
+ //#region src/types.d.ts
3
+ /**
4
+ * Host-neutral Design Studio ports and read-model vocabulary.
5
+ *
6
+ * The Studio is a pure domain library: every filesystem operation goes through
7
+ * an injected port so each Agent Host adapter (DSH, Codex, Claude Code, SDK
8
+ * Pilot) supplies its own native file operations. Nothing here imports an
9
+ * Agent Host runtime, Cordis, or `node:fs`. Installed content remains read-only;
10
+ * editable drafts use separate injected snapshot and persistence ports.
11
+ */
12
+ /**
13
+ * Read-only filesystem surface the Studio needs to enumerate and validate
14
+ * Kits. Structurally compatible with the Design Core `KitFsLike` loader port.
15
+ */
16
+ interface StudioReadFs {
17
+ /** Read one UTF-8 text file; `undefined` when absent. */
18
+ readText(path: string): Promise<string | undefined>;
19
+ /** Optional attached-resource text/opaque projection; never used for definition slots. */
20
+ readResource?(path: string): Promise<KitResourceContent | undefined>;
21
+ /** List one directory's entry names. */
22
+ listDir(path: string): Promise<string[]>;
23
+ /** Whether a path is a directory; adapters without it fall back to read probes. */
24
+ isDirectory?(path: string): Promise<boolean>;
25
+ /** Resolve symlinks for confinement checks. */
26
+ realPath?(path: string): Promise<string>;
27
+ }
28
+ /** One explicit Studio diagnostic (a stable code plus a locatable message). */
29
+ interface StudioDiagnostic {
30
+ /** Stable diagnostic code, e.g. `kit.load`. */
31
+ readonly code: string;
32
+ /** Human-readable, locatable message. */
33
+ readonly message: string;
34
+ /** The Kit or Bundle the diagnostic is about, when known. */
35
+ readonly subject?: string;
36
+ }
37
+ /** The outcome of validating one Kit or Bundle definition. */
38
+ interface StudioValidationReport {
39
+ /** True when the definition loaded with no diagnostics. */
40
+ readonly valid: boolean;
41
+ /** Explicit diagnostics; empty exactly when {@link valid} is true. */
42
+ readonly diagnostics: readonly StudioDiagnostic[];
43
+ }
44
+ /** Exact identity of one published Kit version. */
45
+ interface DesignKitVersionPin {
46
+ /** Published Kit name. */
47
+ readonly name: string;
48
+ /** Exact declared Kit version (`major.minor`). */
49
+ readonly version: string;
50
+ }
51
+ /** Exact identity of one published Bundle version. */
52
+ interface DesignBundleVersionPin {
53
+ /** Published Bundle name. */
54
+ readonly name: string;
55
+ /** Explicit declared Bundle version (`major.minor`). */
56
+ readonly version: string;
57
+ }
58
+ /**
59
+ * Thrown by a Bundle source port when a file exists but is not decodable
60
+ * UTF-8 text. The Studio surfaces binary content as an explicit diagnostic
61
+ * instead of lossy-decoding it into a text viewer.
62
+ */
63
+ declare class StudioBinaryContentError extends Error {
64
+ /** The path whose content is not UTF-8 text. */
65
+ readonly path: string;
66
+ /** @param path - absolute path of the non-text file. */
67
+ constructor(path: string);
68
+ }
69
+ //#endregion
70
+ //#region src/snapshot.d.ts
71
+ /** One Bundle addressed by its declared version. */
72
+ interface DesignBundleSnapshot {
73
+ /** Bundle id, unique within its Kit. */
74
+ readonly name: string;
75
+ /** Explicit declared Bundle version (`major.minor`). */
76
+ readonly version: string;
77
+ /**
78
+ * The Core-compiled, frozen in-process Bundle definition. This is a live
79
+ * object for in-process read-back, not a persistable catalog record; it must
80
+ * not be serialized as catalog JSON, and the Design Core loader remains the
81
+ * authority for producing it.
82
+ */
83
+ readonly definition: DesignSkill;
84
+ }
85
+ /** One Kit addressed by its declared version. */
86
+ interface DesignKitSnapshot {
87
+ /** Kit / mindset id, unique across the installation. */
88
+ readonly name: string;
89
+ /** Explicit declared Kit version (`major.minor`). */
90
+ readonly version: string;
91
+ /**
92
+ * The Core-compiled, frozen in-process Kit definition. This is a live object
93
+ * for in-process read-back, not a persistable catalog record; it must not be
94
+ * serialized as catalog JSON (runtime pack and compiled functions included),
95
+ * and the Design Core loader remains the authority for producing it.
96
+ */
97
+ readonly definition: DesignKit;
98
+ /** The Bundles this Kit exposes, in catalog order. */
99
+ readonly bundles: readonly DesignBundleSnapshot[];
100
+ }
101
+ /** An immutable, version-addressed view of the installed Kits. */
102
+ interface DesignCatalogSnapshot {
103
+ /** The installed Kits, sorted by name. */
104
+ readonly kits: readonly DesignKitSnapshot[];
105
+ /**
106
+ * Independent compiled Bundle versions, including versions with no Kit mounts.
107
+ * When supplied, this is the complete Bundle catalog; Kit membership only
108
+ * contributes reverse references. Omission supports directory-loader adapters
109
+ * while they are migrated to independent content resolution.
110
+ */
111
+ readonly bundles?: readonly DesignBundleSnapshot[];
112
+ }
113
+ /** Supplies a current Core-compiled catalog snapshot to Studio read models. */
114
+ interface StudioCatalogSnapshotPort {
115
+ /** @returns the current immutable installed Kit snapshot. */
116
+ snapshot(): Promise<DesignCatalogSnapshot>;
117
+ }
118
+ /**
119
+ * Project one Core-compiled Kit into its version-addressed snapshot form.
120
+ * @param kit - compiled Kit from the host catalog authority.
121
+ * @returns the frozen snapshot entry retaining the definition by reference.
122
+ */
123
+ declare function snapshotKit(kit: DesignKit): DesignKitSnapshot;
124
+ //#endregion
125
+ //#region src/load.d.ts
126
+ /**
127
+ * Load a Kit with authority derived from the Studio-controlled directory.
128
+ * @param fs - Studio file-ops port.
129
+ * @param kitRoot - absolute Kit directory.
130
+ * @returns the assembled Kit.
131
+ */
132
+ interface StudioKitLoadOptions {
133
+ readonly sourceId?: string;
134
+ readonly bundles?: readonly {
135
+ name: string;
136
+ version: string;
137
+ rootDir: string;
138
+ sourceId: string;
139
+ }[];
140
+ }
141
+ declare function loadStudioKit(fs: StudioReadFs, kitRoot: string, options?: StudioKitLoadOptions): Promise<DesignKit>;
142
+ //#endregion
143
+ //#region src/validate.d.ts
144
+ /**
145
+ * Validate one Kit definition at `kitRoot`.
146
+ * @param fs - injected read file-ops port.
147
+ * @param kitRoot - absolute directory holding the Kit.
148
+ * @returns a report; empty diagnostics exactly when the Kit loads.
149
+ */
150
+ declare function validateKit(fs: StudioReadFs, kitRoot: string): Promise<StudioValidationReport>;
151
+ /**
152
+ * Validate one Bundle definition inside an existing Kit.
153
+ *
154
+ * Reports missing required slots, then loads the Kit and attributes any loader
155
+ * content error or a missing Mindset-catalog reference to the Bundle.
156
+ * @param fs - injected read file-ops port.
157
+ * @param kitRoot - absolute directory of the containing Kit.
158
+ * @param name - the Bundle id (its `skills/<name>/` directory).
159
+ * @returns a report; empty diagnostics exactly when the Bundle loads as part of the Kit.
160
+ */
161
+ declare function validateBundle(fs: StudioReadFs, kitRoot: string, name: string): Promise<StudioValidationReport>;
162
+ //#endregion
163
+ //#region src/panel-preview.d.ts
164
+ /** One editor revision and its isolated sample, not a runtime publication. */
165
+ interface StudioPanelPreviewRequest {
166
+ readonly kit: DesignKitVersionPin;
167
+ readonly bundle: DesignBundleVersionPin;
168
+ readonly revision: number;
169
+ readonly panelSource: string;
170
+ readonly sampleSource: string;
171
+ }
172
+ /** Runtime-interpreter input derived from a validated draft revision. */
173
+ interface StudioPanelPreview {
174
+ readonly revision: number;
175
+ /** Absent only for a real independently loaded Bundle preview. */
176
+ readonly kit?: DesignKitVersionPin;
177
+ readonly bundle: DesignBundleVersionPin;
178
+ /** Loader-resolved YAML, including the installed Bundle's translations. */
179
+ readonly panelYaml: string;
180
+ readonly sample: Readonly<Record<string, unknown>>;
181
+ }
182
+ interface StudioPanelPreviewResult {
183
+ readonly preview?: StudioPanelPreview;
184
+ readonly diagnostics: readonly StudioDiagnostic[];
185
+ }
186
+ /**
187
+ * Compile one Panel edit against an exact, host-resolved Kit snapshot.
188
+ *
189
+ * The host must supply an immutable/read-confined source port and root for the
190
+ * selected pin, not arbitrary browser paths or a mutable production project.
191
+ * Only panel.yaml is overlaid. All schemas, methods, locales and renderer
192
+ * contracts still come from that snapshot and pass through the runtime loader.
193
+ * The returned sample is fresh JSON and can be edited in a sandboxed preview;
194
+ * this function grants no artifact, filesystem, model or publication authority.
195
+ * A preview consumer must discard a result if its editor revision has changed.
196
+ */
197
+ declare function prepareStudioPanelPreview(source: StudioReadFs, kitRoot: string, request: StudioPanelPreviewRequest, loadOptions?: StudioKitLoadOptions): Promise<StudioPanelPreviewResult>;
198
+ //#endregion
199
+ //#region src/panel-drafts.d.ts
200
+ interface StudioPanelDraftContent {
201
+ readonly kit: DesignKitVersionPin;
202
+ readonly bundle: DesignBundleVersionPin;
203
+ readonly baseSnapshot: string;
204
+ readonly panelSource: string;
205
+ readonly sampleSource: string;
206
+ /** A confirmed snapshot is locked, but is NOT published into the Kit catalog. */
207
+ readonly confirmed: boolean;
208
+ }
209
+ interface StudioPanelDraftRecord extends StudioPanelDraftContent {
210
+ readonly id: string;
211
+ readonly revision: number;
212
+ }
213
+ type StudioPanelDraftSummary = Pick<StudioPanelDraftRecord, 'id' | 'revision' | 'kit' | 'bundle' | 'confirmed'>;
214
+ interface StudioPanelDraftRepository {
215
+ create(content: StudioPanelDraftContent): Promise<StudioPanelDraftRecord>;
216
+ read(id: string): Promise<StudioPanelDraftRecord>;
217
+ list(): Promise<readonly StudioPanelDraftRecord[]>;
218
+ /** Atomic, cross-process CAS: must fail without writing if revision differs. */
219
+ replace(id: string, expectedRevision: number, content: StudioPanelDraftContent): Promise<StudioPanelDraftRecord>;
220
+ }
221
+ interface StudioSourceSnapshot {
222
+ readonly id: string;
223
+ readonly fs: StudioReadFs;
224
+ readonly root: string;
225
+ /** Bounded closure root; the Kit and independently retained Bundles may be siblings. */
226
+ readonly storageRoot?: string;
227
+ readonly loadOptions?: StudioKitLoadOptions;
228
+ }
229
+ interface StudioDraftSources {
230
+ /** Host resolves exact installed pin, captures all source bytes and retains them. */
231
+ capture(kit: DesignKitVersionPin): Promise<StudioSourceSnapshot>;
232
+ open(id: string): Promise<StudioSourceSnapshot>;
233
+ }
234
+ interface StudioPanelDraftEdit {
235
+ readonly id: string;
236
+ readonly expectedRevision: number;
237
+ readonly panelSource: string;
238
+ readonly sampleSource: string;
239
+ }
240
+ /** Shared semantics used by host adapters; no filesystem or runtime tool access. */
241
+ declare class StudioPanelDraftService {
242
+ private readonly repository;
243
+ private readonly sources;
244
+ constructor(repository: StudioPanelDraftRepository, sources: StudioDraftSources);
245
+ list(): Promise<readonly StudioPanelDraftSummary[]>;
246
+ read(id: string): Promise<StudioPanelDraftRecord>;
247
+ create(input: {
248
+ kit: DesignKitVersionPin;
249
+ bundle: DesignBundleVersionPin;
250
+ sampleSource?: string;
251
+ }): Promise<StudioPanelDraftRecord>;
252
+ /** Open only the retained snapshot; imported/template pins need not be installed. */
253
+ createFromSnapshot(input: {
254
+ snapshotId: string;
255
+ kit: DesignKitVersionPin;
256
+ bundle: DesignBundleVersionPin;
257
+ sampleSource?: string;
258
+ }): Promise<StudioPanelDraftRecord>;
259
+ private createRetained;
260
+ /** Saving incomplete source is allowed; confirmation requires successful compilation. */
261
+ save(input: StudioPanelDraftEdit): Promise<StudioPanelDraftRecord>;
262
+ /** Compile an unsaved editor revision without persisting or touching any project. */
263
+ preview(input: StudioPanelDraftEdit & {
264
+ revision: number;
265
+ }): Promise<StudioPanelPreviewResult>;
266
+ confirm(input: {
267
+ id: string;
268
+ expectedRevision: number;
269
+ }): Promise<{
270
+ draft?: StudioPanelDraftRecord;
271
+ } & StudioPanelPreviewResult>;
272
+ /** Start another editable revision, sharing the immutable base bytes. */
273
+ fork(id: string): Promise<StudioPanelDraftRecord>;
274
+ }
275
+ //#endregion
276
+ //#region src/kit-drafts.d.ts
277
+ interface StudioKitDraftContent {
278
+ readonly baseKit: DesignKitVersionPin;
279
+ readonly baseSnapshot: string;
280
+ /** Exact immutable mounts. Bundle working copies are edited independently. */
281
+ readonly mounts: readonly DesignBundleVersionPin[];
282
+ readonly mindsetSource: string;
283
+ /** null removes the optional Kit-owned relation vocabulary. */
284
+ readonly relationsSource: string | null;
285
+ readonly confirmed: boolean;
286
+ }
287
+ interface StudioKitDraftRecord extends StudioKitDraftContent {
288
+ readonly id: string;
289
+ readonly revision: number;
290
+ }
291
+ interface StudioKitDraftRepository {
292
+ create(content: StudioKitDraftContent): Promise<StudioKitDraftRecord>;
293
+ read(id: string): Promise<StudioKitDraftRecord>;
294
+ list(): Promise<readonly StudioKitDraftRecord[]>;
295
+ /** Atomic CAS across writers; conflicts and confirmed records must not be overwritten. */
296
+ replace(id: string, expectedRevision: number, content: StudioKitDraftContent): Promise<StudioKitDraftRecord>;
297
+ }
298
+ interface StudioKitDraftEdit {
299
+ readonly id: string;
300
+ readonly expectedRevision: number;
301
+ readonly mindsetSource: string;
302
+ readonly relationsSource: string | null;
303
+ }
304
+ interface StudioKitDraftValidation extends StudioValidationReport {
305
+ readonly revision: number;
306
+ /** A candidate identity, not a published/catalog-resolvable version. */
307
+ readonly candidateKit?: DesignKitVersionPin;
308
+ }
309
+ declare class StudioKitDraftService {
310
+ private readonly repository;
311
+ private readonly sources;
312
+ constructor(repository: StudioKitDraftRepository, sources: StudioDraftSources);
313
+ list(): Promise<readonly Pick<StudioKitDraftRecord, 'id' | 'revision' | 'baseKit' | 'confirmed'>[]>;
314
+ read(id: string): Promise<StudioKitDraftRecord>;
315
+ create(input: {
316
+ kit: DesignKitVersionPin;
317
+ }): Promise<StudioKitDraftRecord>;
318
+ /** Adopt retained, independently validated content; never resolve an installed pin. */
319
+ createFromSnapshot(input: {
320
+ snapshotId: string;
321
+ kit: DesignKitVersionPin;
322
+ }): Promise<StudioKitDraftRecord>;
323
+ private createRetained;
324
+ /** Invalid intermediate edits can be retained, but cannot be confirmed. */
325
+ save(input: StudioKitDraftEdit): Promise<StudioKitDraftRecord>;
326
+ private compile;
327
+ validate(input: {
328
+ id: string;
329
+ expectedRevision: number;
330
+ }): Promise<StudioKitDraftValidation>;
331
+ preview(input: {
332
+ id: string;
333
+ expectedRevision: number;
334
+ bundle: DesignBundleVersionPin;
335
+ sampleSource: string;
336
+ }): Promise<StudioPanelPreviewResult>;
337
+ confirm(input: {
338
+ id: string;
339
+ expectedRevision: number;
340
+ }): Promise<StudioKitDraftValidation & {
341
+ draft?: StudioKitDraftRecord;
342
+ }>;
343
+ fork(id: string): Promise<StudioKitDraftRecord>;
344
+ }
345
+ //#endregion
346
+ //#region src/content-archive.d.ts
347
+ interface StudioArchivePin {
348
+ readonly name: string;
349
+ readonly version: string;
350
+ }
351
+ interface StudioArchiveFile {
352
+ readonly path: string;
353
+ readonly base64: string;
354
+ readonly bytes: number;
355
+ readonly sha256: string;
356
+ }
357
+ interface StudioContentArchive {
358
+ readonly format: 'studio-content-archive/v1';
359
+ readonly kind: 'kit' | 'bundle';
360
+ readonly pin: StudioArchivePin;
361
+ /** Declared provenance, not verified authorship or redistribution permission. */
362
+ readonly provenance: {
363
+ readonly source: string;
364
+ readonly license: string;
365
+ };
366
+ /** Kit membership pins in catalog order; Bundle explicitly declared requirements. */
367
+ readonly dependencies: readonly DesignBundleVersionPin[];
368
+ readonly files: readonly StudioArchiveFile[];
369
+ /** SHA-256 of the canonical envelope excluding this field; not a signature. */
370
+ readonly sha256: string;
371
+ }
372
+ interface StudioArchiveBundleSource extends StudioArchivePin {
373
+ readonly sourceId: string;
374
+ readonly snapshot: StudioArchiveSource;
375
+ }
376
+ interface StudioArchiveSource {
377
+ readonly sourceId?: string;
378
+ /** Trusted immutable Bundle snapshots, never paths supplied by an archive. */
379
+ readonly bundles?: readonly StudioArchiveBundleSource[];
380
+ readonly root: string;
381
+ readonly fs: StudioReadFs;
382
+ /** Host supplies a complete, immutable regular-file snapshot; no live fallback. */
383
+ listFiles(): Promise<readonly string[]>;
384
+ /** Byte-preserving read. Host rejects links and non-regular files before reading. */
385
+ readBytes(path: string): Promise<Uint8Array>;
386
+ }
387
+ interface StudioPreparedContentImport {
388
+ readonly archive: StudioContentArchive;
389
+ /** Files relative to Kit root, or standalone Bundle root, respectively. */
390
+ readonly files: readonly StudioArchiveFile[];
391
+ /** Independently retainable content, only populated after definition validation. */
392
+ readonly contents: readonly {
393
+ readonly kind: 'kit' | 'bundle';
394
+ readonly pin: StudioArchivePin;
395
+ readonly files: readonly StudioArchiveFile[];
396
+ }[];
397
+ readonly executionGranted: false;
398
+ /** Includes scripts and provider/driver references; host approval is separate. */
399
+ readonly requiresTrustReview: boolean;
400
+ readonly validation: {
401
+ readonly valid: boolean;
402
+ readonly diagnostics: readonly StudioDiagnostic[];
403
+ };
404
+ }
405
+ /** Parse a bounded JSON envelope; hashes include metadata and every original byte. */
406
+ declare function readStudioContentArchive(source: string): StudioContentArchive;
407
+ /** No writes, extraction, permission restoration, script execution, installation or publication. */
408
+ declare function prepareStudioContentImport(source: string, options?: {
409
+ validationContext?: StudioArchiveSource | {
410
+ root: string;
411
+ fs: StudioReadFs;
412
+ };
413
+ }): Promise<StudioPreparedContentImport>;
414
+ /** Capture only immutable host snapshots, preserving full exact referenced trees. */
415
+ declare function exportStudioContentArchive(snapshot: StudioArchiveSource, input: {
416
+ kind: 'kit' | 'bundle';
417
+ pin: StudioArchivePin;
418
+ provenance: StudioContentArchive['provenance'];
419
+ dependencies?: readonly DesignBundleVersionPin[];
420
+ }): Promise<string>;
421
+ //#endregion
422
+ //#region src/management.d.ts
423
+ /** One browser-safe published Kit pin. */
424
+ interface StudioKitView {
425
+ /** Published Kit identity. */
426
+ readonly name: string;
427
+ /** Exact declared Kit version. */
428
+ readonly version: string;
429
+ /** Optional display copy, projected from the exact Kit definition. */
430
+ readonly description?: string;
431
+ readonly displayDescription?: Readonly<{
432
+ zh: string;
433
+ en: string;
434
+ }>;
435
+ }
436
+ /** One browser-safe Bundle catalog entry with exact reverse dependencies. */
437
+ interface StudioBundleView extends DesignBundleVersionPin {
438
+ readonly title?: Readonly<{
439
+ zh: string;
440
+ en: string;
441
+ }>;
442
+ readonly displayDescription?: Readonly<{
443
+ zh: string;
444
+ en: string;
445
+ }>;
446
+ /** Human routing description. */
447
+ readonly description: string;
448
+ /** Exact published Kit versions selecting this Bundle version. */
449
+ readonly usedBy: readonly StudioKitView[];
450
+ }
451
+ /** Complete JSON-only view model for the Studio management surface. */
452
+ interface StudioWorkspaceView {
453
+ /** Trimmed catalog query applied to {@link bundles}. */
454
+ readonly query: string;
455
+ /** Published Kit version pins. */
456
+ readonly kits: readonly StudioKitView[];
457
+ /** Flat Bundle version results, including reverse Kit dependencies. */
458
+ readonly bundles: readonly StudioBundleView[];
459
+ }
460
+ /** Structured management failure safe to serialize through any host transport. */
461
+ interface StudioManagementFailure {
462
+ /** Stable failure category rendered by shared Studio clients. */
463
+ readonly code: 'request_failed';
464
+ /** User-facing diagnostic. */
465
+ readonly message: string;
466
+ }
467
+ /** One read-only Bundle mount with exact reverse Kit references. */
468
+ interface StudioBundleMountView {
469
+ readonly title?: Readonly<{
470
+ zh: string;
471
+ en: string;
472
+ }>;
473
+ readonly displayDescription?: Readonly<{
474
+ zh: string;
475
+ en: string;
476
+ }>;
477
+ /** Mounted Bundle name. */
478
+ readonly name: string;
479
+ /** Exact mounted Bundle version. */
480
+ readonly version: string;
481
+ /** One-line Bundle description. */
482
+ readonly description: string;
483
+ /** Every installed Kit version mounting this exact Bundle version. */
484
+ readonly mountedBy: readonly StudioKitView[];
485
+ }
486
+ /** One Core-loader-compiled auxiliary resource of a Kit version, by exact path. */
487
+ interface StudioResourceRefView {
488
+ /** Exact compiled resource path (loader authority; never guessed). */
489
+ readonly path: string;
490
+ /** UTF-8 byte length of the compiled resource content. */
491
+ readonly bytes: number;
492
+ }
493
+ /** One validated Kit relation extension exposed for initial Studio inspection. */
494
+ interface StudioRelationView {
495
+ readonly type: string;
496
+ readonly meaning: string;
497
+ readonly direction: 'forward' | 'symmetric';
498
+ readonly label: {
499
+ readonly zh: string;
500
+ readonly en: string;
501
+ };
502
+ readonly description: {
503
+ readonly zh: string;
504
+ readonly en: string;
505
+ };
506
+ readonly domain?: readonly string[];
507
+ readonly range?: readonly string[];
508
+ readonly inverse?: string;
509
+ readonly cardinality?: Readonly<{
510
+ from: 'one' | 'many';
511
+ to: 'one' | 'many';
512
+ }>;
513
+ readonly reasoning?: Readonly<{
514
+ impact?: boolean;
515
+ causal?: boolean;
516
+ transitive?: boolean;
517
+ }>;
518
+ readonly evidence?: Readonly<{
519
+ minimum: 'explicit' | 'inferred';
520
+ }>;
521
+ }
522
+ /** Exact version-pinned relation extension summary compiled by Design Core. */
523
+ interface StudioRelationVocabularyView {
524
+ readonly schemaVersion: 1;
525
+ readonly pin: string;
526
+ readonly relations: readonly StudioRelationView[];
527
+ }
528
+ /** Read-only installed-Kit workspace: exact source plus catalog facts. */
529
+ interface StudioKitWorkspaceView {
530
+ /** Kit identity. */
531
+ readonly name: string;
532
+ /** Exact installed Kit version. */
533
+ readonly version: string;
534
+ /** Human description from the mindset frontmatter; empty when absent. */
535
+ readonly description: string;
536
+ readonly displayDescription?: Readonly<{
537
+ zh: string;
538
+ en: string;
539
+ }>;
540
+ /** Complete raw mindset.md source, including frontmatter, byte-identical to the installation. */
541
+ readonly mindsetSource: string;
542
+ /** Mounted Bundles in catalog order with reverse Kit references. */
543
+ readonly mounts: readonly StudioBundleMountView[];
544
+ /** Loader-compiled auxiliary resources, sorted by path. */
545
+ readonly resources: readonly StudioResourceRefView[];
546
+ /** Optional extension entry. Editing remains disabled until Studio gains versioned drafts. */
547
+ readonly relationVocabulary: StudioRelationVocabularyView;
548
+ }
549
+ /** Read result for one installed Kit workspace: a view or actionable diagnostics. */
550
+ interface StudioKitWorkspaceResult {
551
+ /** Frozen workspace view; present exactly when diagnostics are empty. */
552
+ readonly workspace?: StudioKitWorkspaceView;
553
+ /** Frozen resolution diagnostics. */
554
+ readonly diagnostics: readonly StudioDiagnostic[];
555
+ }
556
+ /**
557
+ * JSON-facing read-only Kit catalog and workspace inspection over the
558
+ * authoritative Core-compiled catalog. The Studio never mutates installed
559
+ * content: source files and the Design Core loader remain the only authorities.
560
+ */
561
+ declare class StudioManagementService {
562
+ #private;
563
+ /** @param catalog - current authoritative installed Kit snapshot provider. */
564
+ constructor(catalog: StudioCatalogSnapshotPort);
565
+ /**
566
+ * Build a detached, frozen, JSON-only browser view.
567
+ * @param query - optional Bundle name/description search.
568
+ * @returns current published Kit pins and the searched Bundle catalog.
569
+ */
570
+ workspace(query?: string): Promise<StudioWorkspaceView>;
571
+ /**
572
+ * Read the Kit workspace view model for one exact installed Kit version.
573
+ *
574
+ * The view is JSON-only: the complete raw mindset.md source is exposed for
575
+ * reading, mounts carry exact version pins plus their reverse Kit
576
+ * references, and resources project only the paths the Core loader compiled
577
+ * into the version. No Core-compiled definition object crosses into the view.
578
+ * @param name - the Kit id.
579
+ * @param version - exact installed Kit version.
580
+ * @returns the frozen workspace view, or resolution diagnostics.
581
+ */
582
+ readKitWorkspace(name: string, version: string): Promise<StudioKitWorkspaceResult>;
583
+ }
584
+ //#endregion
585
+ //#region src/composition.d.ts
586
+ /** One immutable Bundle version with exact reverse Kit dependencies. */
587
+ interface StudioBundleVersionEntry extends DesignBundleVersionPin {
588
+ /** Core-compiled definition retained by reference; source is never copied. */
589
+ readonly definition: DesignSkill;
590
+ /** Exact published Kit versions that select this Bundle version. */
591
+ readonly usedBy: readonly DesignKitVersionPin[];
592
+ }
593
+ /** Frozen flat Bundle catalog plus the published Kit versions it derives from. */
594
+ interface StudioCompositionCatalog {
595
+ /** Bundle versions sorted by name then version. */
596
+ readonly bundles: readonly StudioBundleVersionEntry[];
597
+ /** Published Kit version pins sorted by name then version. */
598
+ readonly kits: readonly DesignKitVersionPin[];
599
+ }
600
+ /**
601
+ * Derive the flat searchable Bundle catalog and reverse dependencies.
602
+ * @param snapshot - authoritative Core-compiled installed catalog snapshot.
603
+ * @returns a frozen derived catalog; identical Bundle pins are coalesced.
604
+ */
605
+ declare function buildStudioCompositionCatalog(snapshot: DesignCatalogSnapshot): StudioCompositionCatalog;
606
+ /**
607
+ * Search Bundle name and description in deterministic catalog order.
608
+ * @param catalog - derived flat catalog.
609
+ * @param query - case-insensitive trimmed text; empty returns the full catalog.
610
+ * @returns matching immutable catalog entries.
611
+ */
612
+ declare function searchStudioBundles(catalog: StudioCompositionCatalog, query: string): readonly StudioBundleVersionEntry[];
613
+ //#endregion
614
+ //#region src/bundle-source.d.ts
615
+ /**
616
+ * Read-only physical source operations the Bundle workspace needs from its
617
+ * Agent Host. The members are structurally compatible with {@link StudioReadFs}
618
+ * so the Design Core loader runs directly against the port. Path confinement
619
+ * (traversal, `.git`, symlink escape, regular files only) is the adapter's
620
+ * responsibility; the service independently rejects unsafe path shapes.
621
+ */
622
+ interface StudioBundleSourcePort {
623
+ /** Resolve an exact independent source; never infer ownership from a Kit. */
624
+ resolveBundleRoot?(pin: {
625
+ name: string;
626
+ version: string;
627
+ }): Promise<string | undefined>;
628
+ /** Every authored Kit source root; each holds `mindset.md` and `skills/`. */
629
+ listKitRoots(): Promise<readonly string[]>;
630
+ /** Read one UTF-8 text file; `undefined` when absent. Throws {@link StudioBinaryContentError} for non-text content. */
631
+ readText(path: string): Promise<string | undefined>;
632
+ /** List one directory's entry names; empty when absent. */
633
+ listDir(path: string): Promise<string[]>;
634
+ /** Whether one path is a directory. */
635
+ isDirectory(path: string): Promise<boolean>;
636
+ /** Every regular file below one directory, as sorted slash-separated relative paths. */
637
+ listFiles(path: string): Promise<readonly string[]>;
638
+ }
639
+ /** One readable UTF-8 file in a Bundle workspace file tree. */
640
+ interface StudioBundleFileRefView {
641
+ /** Slash-separated path relative to the Bundle root. */
642
+ readonly path: string;
643
+ /** UTF-8 byte length of the file content. */
644
+ readonly bytes: number;
645
+ }
646
+ /** Panel classification of one Bundle's presentation declaration. */
647
+ interface StudioBundlePanelView {
648
+ /** `native` Panels are provider-owned code, read-only in the Studio; `declarative` Panels are Bundle-authored data. */
649
+ readonly kind: 'native' | 'declarative';
650
+ /** Declared renderer identity. */
651
+ readonly renderer?: string;
652
+ }
653
+ /** Validator summary derived from the compiled validation document. */
654
+ interface StudioBundleValidationSummary {
655
+ /** Number of declared validation rules. */
656
+ readonly rules: number;
657
+ /** Sorted unique runtime validation driver identities referenced by rules; empty for driver-free rules. */
658
+ readonly drivers: readonly string[];
659
+ }
660
+ /** Read model of one authored Bundle: physical files plus compiled summaries. */
661
+ interface StudioBundleWorkspaceView {
662
+ /** Bundle id (its `skills/<name>/` directory name). */
663
+ readonly name: string;
664
+ /** Declared Bundle version, reconciled against the compiled catalog. */
665
+ readonly version: string;
666
+ /** Kit name declaring this Bundle in its catalog. */
667
+ readonly kit?: string;
668
+ /** One-line Bundle description. */
669
+ readonly description: string;
670
+ readonly displayDescription?: Readonly<{
671
+ zh: string;
672
+ en: string;
673
+ }>;
674
+ /** Every readable UTF-8 file below the Bundle root, sorted by path. */
675
+ readonly files: readonly StudioBundleFileRefView[];
676
+ /** Parsed skill.yaml manifest, JSON-projected. */
677
+ readonly manifest?: Readonly<Record<string, unknown>>;
678
+ /** Parsed schema.yaml document, JSON-projected. */
679
+ readonly schema?: Readonly<Record<string, unknown>>;
680
+ /** Validation rule and driver summary. */
681
+ readonly validation?: StudioBundleValidationSummary;
682
+ /** Panel classification; absent when the Bundle declares no presentation. */
683
+ readonly panel?: StudioBundlePanelView;
684
+ }
685
+ /** The read result of one Bundle workspace. */
686
+ interface StudioBundleWorkspaceResult {
687
+ /** The workspace view; undefined when resolution or reconciliation fails. */
688
+ readonly workspace?: StudioBundleWorkspaceView;
689
+ /** Resolution, reconciliation, or load diagnostics. */
690
+ readonly diagnostics: readonly StudioDiagnostic[];
691
+ }
692
+ /** One complete Bundle file read byte-exactly as UTF-8 text. */
693
+ interface StudioBundleFileView {
694
+ /** Slash-separated path relative to the Bundle root. */
695
+ readonly path: string;
696
+ /** Complete UTF-8 file content. */
697
+ readonly content: string;
698
+ }
699
+ /** The read result of one Bundle file. */
700
+ interface StudioBundleFileResult {
701
+ /** The file; undefined when it is missing, unsafe, or not text. */
702
+ readonly file?: StudioBundleFileView;
703
+ /** Resolution diagnostics. */
704
+ readonly diagnostics: readonly StudioDiagnostic[];
705
+ }
706
+ /**
707
+ * Read-only Bundle inspection over real Kit source files, reconciled against
708
+ * the host's Core-compiled catalog. The injected port owns the physical
709
+ * filesystem; this service owns resolution, path safety, identity
710
+ * reconciliation, and the JSON-only read models.
711
+ */
712
+ declare class StudioBundleSourceService {
713
+ #private;
714
+ /**
715
+ * @param catalog - current authoritative installed Kit snapshot provider.
716
+ * @param source - host-supplied read-only physical source operations.
717
+ */
718
+ constructor(catalog: StudioCatalogSnapshotPort, source: StudioBundleSourcePort);
719
+ /**
720
+ * Read one Bundle's workspace: physical file tree, loader-compiled
721
+ * manifest/schema/validation summaries, and Panel classification.
722
+ * @param name - the Bundle id.
723
+ * @returns the workspace, or resolution/reconciliation diagnostics.
724
+ */
725
+ readBundleWorkspace(name: string, version?: string): Promise<StudioBundleWorkspaceResult>;
726
+ /**
727
+ * Read one complete Bundle file byte-exactly as UTF-8 text.
728
+ * @param input - Bundle id and Bundle-relative path.
729
+ * @returns the file content, or resolution diagnostics.
730
+ */
731
+ readBundleFile(input: {
732
+ name: string;
733
+ path: string;
734
+ version?: string;
735
+ }): Promise<StudioBundleFileResult>;
736
+ }
737
+ //#endregion
738
+ export { type DesignBundleSnapshot, type DesignBundleVersionPin, type DesignCatalogSnapshot, type DesignKitSnapshot, type DesignKitVersionPin, type StudioArchiveFile, type StudioArchivePin, type StudioArchiveSource, StudioBinaryContentError, type StudioBundleFileRefView, type StudioBundleFileResult, type StudioBundleFileView, type StudioBundleMountView, type StudioBundlePanelView, type StudioBundleSourcePort, StudioBundleSourceService, type StudioBundleValidationSummary, type StudioBundleVersionEntry, type StudioBundleView, type StudioBundleWorkspaceResult, type StudioBundleWorkspaceView, type StudioCatalogSnapshotPort, type StudioCompositionCatalog, type StudioContentArchive, type StudioDiagnostic, type StudioDraftSources, type StudioKitDraftContent, type StudioKitDraftEdit, type StudioKitDraftRecord, type StudioKitDraftRepository, StudioKitDraftService, type StudioKitDraftValidation, type StudioKitView, type StudioKitWorkspaceResult, type StudioKitWorkspaceView, type StudioManagementFailure, StudioManagementService, type StudioPanelDraftContent, type StudioPanelDraftEdit, type StudioPanelDraftRecord, type StudioPanelDraftRepository, StudioPanelDraftService, type StudioPanelDraftSummary, type StudioPanelPreview, type StudioPanelPreviewRequest, type StudioPanelPreviewResult, type StudioPreparedContentImport, type StudioReadFs, type StudioRelationView, type StudioRelationVocabularyView, type StudioResourceRefView, type StudioSourceSnapshot, type StudioValidationReport, type StudioWorkspaceView, buildStudioCompositionCatalog, exportStudioContentArchive, loadStudioKit, prepareStudioContentImport, prepareStudioPanelPreview, readStudioContentArchive, searchStudioBundles, snapshotKit, validateBundle, validateKit };