@skaile/workspaces 0.13.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 (146) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/dist/asset-manager/index.js +4 -4
  3. package/dist/asset-manager/installer.js +3 -3
  4. package/dist/base-assets/connectors/deploy.js +4 -4
  5. package/dist/base-assets/connectors/devserver.js +4 -4
  6. package/dist/base-assets/connectors/flow/adapter.js +4 -4
  7. package/dist/base-assets/connectors/flow/run-flow.js +5 -5
  8. package/dist/base-assets/connectors/flow.js +4 -4
  9. package/dist/base-assets/connectors/git.js +4 -4
  10. package/dist/base-assets/connectors/gmail.js +4 -4
  11. package/dist/base-assets/connectors/googledrive/driver.d.ts +47 -0
  12. package/dist/base-assets/connectors/googledrive/driver.d.ts.map +1 -0
  13. package/dist/base-assets/connectors/googledrive.js +20 -0
  14. package/dist/base-assets/connectors/googledrive.js.map +1 -0
  15. package/dist/base-assets/connectors/local.js +4 -4
  16. package/dist/base-assets/connectors/mattermost.js +4 -4
  17. package/dist/base-assets/connectors/memory.js +4 -4
  18. package/dist/base-assets/connectors/minio.js +4 -4
  19. package/dist/base-assets/connectors/postgres.js +4 -4
  20. package/dist/base-assets/connectors/redis.js +4 -4
  21. package/dist/base-assets/connectors/s3.js +4 -4
  22. package/dist/base-assets/connectors/sharepoint/driver.d.ts.map +1 -1
  23. package/dist/base-assets/connectors/sharepoint.js +4 -4
  24. package/dist/base-assets/connectors/sqlite.js +4 -4
  25. package/dist/base-assets/connectors/static-server.js +4 -4
  26. package/dist/base-assets/connectors/tunnel.js +4 -4
  27. package/dist/base-assets/connectors/webdav/driver.d.ts.map +1 -1
  28. package/dist/base-assets/connectors/webdav.js +4 -4
  29. package/dist/base-assets/connectors/xstate-store.js +4 -4
  30. package/dist/base-assets/connectors/xstate.js +4 -4
  31. package/dist/base-assets/connectors/yjs.js +4 -4
  32. package/dist/{chunk-42OQF7UU.js → chunk-2NIOMFSQ.js} +305 -225
  33. package/dist/chunk-2NIOMFSQ.js.map +1 -0
  34. package/dist/{chunk-DZG3JD4Y.js → chunk-4GEVGRWB.js} +3 -3
  35. package/dist/{chunk-DZG3JD4Y.js.map → chunk-4GEVGRWB.js.map} +1 -1
  36. package/dist/{chunk-VAJB2UJ5.js → chunk-6EN5IJ2Y.js} +13 -13
  37. package/dist/chunk-6EN5IJ2Y.js.map +1 -0
  38. package/dist/{chunk-QG4X77V3.js → chunk-7R4WLTZW.js} +4 -4
  39. package/dist/{chunk-QG4X77V3.js.map → chunk-7R4WLTZW.js.map} +1 -1
  40. package/dist/{chunk-GN6IYVJN.js → chunk-G7O7WDXX.js} +2 -2
  41. package/dist/{chunk-GN6IYVJN.js.map → chunk-G7O7WDXX.js.map} +1 -1
  42. package/dist/{chunk-EAJKY27M.js → chunk-HSOEX3TA.js} +250 -92
  43. package/dist/chunk-HSOEX3TA.js.map +1 -0
  44. package/dist/chunk-QAVZOJCV.js +72 -0
  45. package/dist/chunk-QAVZOJCV.js.map +1 -0
  46. package/dist/{chunk-CYRCPFZ2.js → chunk-SO43XRWF.js} +3 -3
  47. package/dist/{chunk-CYRCPFZ2.js.map → chunk-SO43XRWF.js.map} +1 -1
  48. package/dist/{chunk-4DDQKKWX.js → chunk-Z24KPZKU.js} +20 -13
  49. package/dist/chunk-Z24KPZKU.js.map +1 -0
  50. package/dist/cli/index.js +685 -527
  51. package/dist/cli/index.js.map +1 -1
  52. package/dist/cli/src/commands/asset-cmd.d.ts +4 -1
  53. package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
  54. package/dist/cli/src/commands/library-cmd.d.ts +6 -4
  55. package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
  56. package/dist/cli/src/commands/npx.d.ts.map +1 -1
  57. package/dist/cli/src/commands/project.d.ts +2 -2
  58. package/dist/cli/src/commands/source-manifest.d.ts +19 -0
  59. package/dist/cli/src/commands/source-manifest.d.ts.map +1 -0
  60. package/dist/cli/src/commands/source.d.ts +6 -2
  61. package/dist/cli/src/commands/source.d.ts.map +1 -1
  62. package/dist/cli/src/commands/store.d.ts.map +1 -1
  63. package/dist/cli/src/open-library.d.ts +18 -18
  64. package/dist/cli/src/open-library.d.ts.map +1 -1
  65. package/dist/connectors/config.js +2 -2
  66. package/dist/connectors/index.js +4 -4
  67. package/dist/connectors/rclone-config.js +1 -1
  68. package/dist/connectors/src/connector-registry.d.ts.map +1 -1
  69. package/dist/connectors/src/fleet-utils.d.ts +35 -0
  70. package/dist/connectors/src/fleet-utils.d.ts.map +1 -0
  71. package/dist/connectors/src/index.d.ts +2 -1
  72. package/dist/connectors/src/index.d.ts.map +1 -1
  73. package/dist/connectors/src/rclone-config/googledrive.d.ts +59 -0
  74. package/dist/connectors/src/rclone-config/googledrive.d.ts.map +1 -0
  75. package/dist/connectors/src/rclone-config/index.d.ts +1 -0
  76. package/dist/connectors/src/rclone-config/index.d.ts.map +1 -1
  77. package/dist/connectors/src/rclone-config/onedrive.d.ts +1 -0
  78. package/dist/connectors/src/rclone-config/onedrive.d.ts.map +1 -1
  79. package/dist/connectors/src/rclone-config/sanitize.d.ts +9 -0
  80. package/dist/connectors/src/rclone-config/sanitize.d.ts.map +1 -0
  81. package/dist/connectors/src/rclone-config/webdav.d.ts +1 -0
  82. package/dist/connectors/src/rclone-config/webdav.d.ts.map +1 -1
  83. package/dist/core/index.js +2 -2
  84. package/dist/library/index.js +1 -1
  85. package/dist/library/src/config.d.ts +12 -3
  86. package/dist/library/src/config.d.ts.map +1 -1
  87. package/dist/library/src/index.d.ts +7 -8
  88. package/dist/library/src/index.d.ts.map +1 -1
  89. package/dist/library/src/library.d.ts +24 -77
  90. package/dist/library/src/library.d.ts.map +1 -1
  91. package/dist/library/src/local/db.d.ts +3 -2
  92. package/dist/library/src/local/db.d.ts.map +1 -1
  93. package/dist/library/src/local/{user-library-manager.d.ts → library-manager.d.ts} +15 -16
  94. package/dist/library/src/local/library-manager.d.ts.map +1 -0
  95. package/dist/library/src/local/library.d.ts +27 -23
  96. package/dist/library/src/local/library.d.ts.map +1 -1
  97. package/dist/library/src/local/local-catalog-source.d.ts +5 -5
  98. package/dist/library/src/local/local-catalog-source.d.ts.map +1 -1
  99. package/dist/library/src/local/sidecar-paths.d.ts +3 -3
  100. package/dist/library/src/local/store-paths.d.ts +42 -0
  101. package/dist/library/src/local/store-paths.d.ts.map +1 -0
  102. package/dist/library/src/preset/apply.d.ts +2 -2
  103. package/dist/library/src/preset/apply.d.ts.map +1 -1
  104. package/dist/library/src/preset/placeholders.d.ts +3 -3
  105. package/dist/library/src/preset/placeholders.d.ts.map +1 -1
  106. package/dist/library/src/preset/resolve-item.d.ts +3 -3
  107. package/dist/library/src/preset/resolve-item.d.ts.map +1 -1
  108. package/dist/library/src/sync/driver.d.ts +6 -6
  109. package/dist/library/src/sync/driver.d.ts.map +1 -1
  110. package/dist/library/src/sync/git-driver.d.ts +6 -6
  111. package/dist/library/src/sync/git-driver.d.ts.map +1 -1
  112. package/dist/library/src/sync/local-driver.d.ts +6 -6
  113. package/dist/library/src/sync/local-driver.d.ts.map +1 -1
  114. package/dist/library/src/user-library.d.ts +12 -17
  115. package/dist/library/src/user-library.d.ts.map +1 -1
  116. package/dist/{open-library-S6FK4N4S.js → open-library-XD7QYLMW.js} +4 -4
  117. package/dist/{open-library-S6FK4N4S.js.map → open-library-XD7QYLMW.js.map} +1 -1
  118. package/dist/runner/index.js +8 -8
  119. package/dist/runner/src/composition/resolve.d.ts +3 -3
  120. package/dist/runner/src/composition/resolve.d.ts.map +1 -1
  121. package/dist/sdk/asset-manager.js +4 -4
  122. package/dist/sdk/core.js +2 -2
  123. package/dist/sdk/index.js +9 -9
  124. package/dist/sdk/runner.js +8 -8
  125. package/dist/{setup-BQEST4RD.js → setup-WZFCLQ2J.js} +4 -4
  126. package/dist/{setup-BQEST4RD.js.map → setup-WZFCLQ2J.js.map} +1 -1
  127. package/dist/{store-client-CB6CYFXB.js → store-client-BM3IBDPT.js} +4 -4
  128. package/dist/{store-client-CB6CYFXB.js.map → store-client-BM3IBDPT.js.map} +1 -1
  129. package/dist/tui/index.js +8 -8
  130. package/dist/types/src/install-manifest.d.ts +1 -1
  131. package/dist/workspace-plugin/adapters/mcp.js +2 -2
  132. package/dist/workspace-plugin/index.js +1 -1
  133. package/package.json +7 -1
  134. package/dist/chunk-42OQF7UU.js.map +0 -1
  135. package/dist/chunk-4DDQKKWX.js.map +0 -1
  136. package/dist/chunk-EAJKY27M.js.map +0 -1
  137. package/dist/chunk-GCRKAFH7.js +0 -40
  138. package/dist/chunk-GCRKAFH7.js.map +0 -1
  139. package/dist/chunk-VAJB2UJ5.js.map +0 -1
  140. package/dist/cli/src/commands/library-status.d.ts +0 -19
  141. package/dist/cli/src/commands/library-status.d.ts.map +0 -1
  142. package/dist/cli/src/commands/source-sidecar.d.ts +0 -6
  143. package/dist/cli/src/commands/source-sidecar.d.ts.map +0 -1
  144. package/dist/library/src/local/user-library-manager.d.ts.map +0 -1
  145. package/dist/library/src/sync/store-driver.d.ts +0 -21
  146. package/dist/library/src/sync/store-driver.d.ts.map +0 -1
@@ -3,8 +3,8 @@ import { PresetManifestSchema } from './chunk-NELZIQ2E.js';
3
3
  import { __export, __require } from './chunk-NSBPE2FW.js';
4
4
  import * as crypto from 'crypto';
5
5
  import { createHash } from 'crypto';
6
- import * as fs10 from 'fs';
7
- import * as path5 from 'path';
6
+ import * as fs11 from 'fs';
7
+ import * as path4 from 'path';
8
8
  import { resolve, join, sep, dirname, isAbsolute } from 'path';
9
9
  import { eq, like, and } from 'drizzle-orm';
10
10
  import * as z2 from 'zod';
@@ -41,7 +41,7 @@ var LibraryError = class extends Error {
41
41
  };
42
42
  var SourceNotFoundError = class extends LibraryError {
43
43
  constructor(id) {
44
- super(`Source not found: ${id}`, "SOURCE_NOT_FOUND");
44
+ super(`Library not found: ${id}`, "LIBRARY_NOT_FOUND");
45
45
  this.name = "SourceNotFoundError";
46
46
  }
47
47
  };
@@ -107,19 +107,23 @@ var SkaileConfigSchema = z2.object({
107
107
  catalog: CatalogConfigSchema.optional(),
108
108
  library: LibraryConfigSchema.optional()
109
109
  });
110
+ function skaileHomeDir() {
111
+ return path4.join(os.homedir(), ".skaile");
112
+ }
110
113
  function defaultLibraryDir() {
111
- return path5.join(os.homedir(), ".skaile", "libraries");
114
+ return path4.join(skaileHomeDir(), "libraries");
115
+ }
116
+ function defaultIndexPath() {
117
+ return path4.join(skaileHomeDir(), "index.db");
112
118
  }
113
119
  function resolveLibraryDir() {
114
120
  if (process.env.SKAILE_LIBRARIES_DIR) return process.env.SKAILE_LIBRARIES_DIR;
115
- if (process.env.SKAILE_LIBRARY_DIR) {
116
- process.stderr.write(
117
- "[skaile/library] SKAILE_LIBRARY_DIR is deprecated \u2014 use SKAILE_LIBRARIES_DIR.\n"
118
- );
119
- return process.env.SKAILE_LIBRARY_DIR;
120
- }
121
121
  return defaultLibraryDir();
122
122
  }
123
+ function resolveIndexPath() {
124
+ if (process.env.SKAILE_INDEX_PATH) return process.env.SKAILE_INDEX_PATH;
125
+ return defaultIndexPath();
126
+ }
123
127
  function getConfigDefaults() {
124
128
  return {
125
129
  catalog: { url: "https://skaile.store", cache_ttl: 86400, framing: "trpc" },
@@ -128,15 +132,15 @@ function getConfigDefaults() {
128
132
  }
129
133
  var CONFIG_FILENAME = "config.yaml";
130
134
  function userConfigPath() {
131
- return path5.join(os.homedir(), ".skaile", CONFIG_FILENAME);
135
+ return path4.join(os.homedir(), ".skaile", CONFIG_FILENAME);
132
136
  }
133
137
  function projectConfigPath(projectDir) {
134
- return path5.join(projectDir, ".skaile", CONFIG_FILENAME);
138
+ return path4.join(projectDir, ".skaile", CONFIG_FILENAME);
135
139
  }
136
140
  function loadConfigFile(filePath) {
137
- if (!fs10.existsSync(filePath)) return null;
141
+ if (!fs11.existsSync(filePath)) return null;
138
142
  try {
139
- const content = fs10.readFileSync(filePath, "utf-8");
143
+ const content = fs11.readFileSync(filePath, "utf-8");
140
144
  const raw = parse(content);
141
145
  if (!raw || typeof raw !== "object") return null;
142
146
  return SkaileConfigSchema.partial().parse(raw);
@@ -184,11 +188,11 @@ function resolveConfig(opts) {
184
188
  return resolved;
185
189
  }
186
190
  function saveConfig(filePath, config) {
187
- const dir = path5.dirname(filePath);
188
- if (!fs10.existsSync(dir)) {
189
- fs10.mkdirSync(dir, { recursive: true });
191
+ const dir = path4.dirname(filePath);
192
+ if (!fs11.existsSync(dir)) {
193
+ fs11.mkdirSync(dir, { recursive: true });
190
194
  }
191
- fs10.writeFileSync(filePath, stringify(config, { indent: 2 }), "utf-8");
195
+ fs11.writeFileSync(filePath, stringify(config, { indent: 2 }), "utf-8");
192
196
  }
193
197
 
194
198
  // library/src/local/schema.ts
@@ -260,6 +264,104 @@ var subscriptions = sqliteTable("subscriptions", {
260
264
  pinPolicy: text("pin_policy").notNull(),
261
265
  subscribedAt: text("subscribed_at").notNull()
262
266
  });
267
+ var SKAILE_HOME_ENV = "SKAILE_HOME";
268
+ function getSidecarRoot() {
269
+ const home = process.env[SKAILE_HOME_ENV] ?? path4.join(os.homedir(), ".skaile");
270
+ return path4.join(home, "sources");
271
+ }
272
+ function resolveSidecarPaths(slug) {
273
+ const rootDir = getSidecarRoot();
274
+ const sidecarDir = path4.join(rootDir, slug);
275
+ return {
276
+ rootDir,
277
+ sidecarDir,
278
+ manifestFile: path4.join(sidecarDir, ".skaile-source.yaml"),
279
+ readmeFile: path4.join(sidecarDir, "README.md"),
280
+ lockFile: path4.join(sidecarDir, ".skaile-source.lock.json")
281
+ };
282
+ }
283
+ function deriveSlug(sourceConfig, sourcePath, existingSlugs) {
284
+ const fromConfig = sourceConfig && typeof sourceConfig.name === "string" ? sourceConfig.name : void 0;
285
+ const base = fromConfig && fromConfig.length > 0 ? slugify(fromConfig) : slugify(path4.basename(sourcePath || "")) || "unnamed-source";
286
+ const taken = new Set(existingSlugs);
287
+ if (!taken.has(base)) return base;
288
+ for (let i = 2; i < 1e3; i++) {
289
+ const candidate = `${base}-${i}`;
290
+ if (!taken.has(candidate)) return candidate;
291
+ }
292
+ return `${base}-${Math.random().toString(36).slice(2, 8)}`;
293
+ }
294
+ function listSidecarSlugsOnDisk() {
295
+ const root = getSidecarRoot();
296
+ if (!fs11.existsSync(root)) return [];
297
+ const out = [];
298
+ for (const entry of fs11.readdirSync(root, { withFileTypes: true })) {
299
+ if (!entry.isDirectory()) continue;
300
+ if (entry.name.startsWith(".")) continue;
301
+ out.push(entry.name);
302
+ }
303
+ return out.sort();
304
+ }
305
+ function slugify(input) {
306
+ return input.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "");
307
+ }
308
+
309
+ // library/src/local/store-paths.ts
310
+ function getStoreRoot() {
311
+ const home = process.env.SKAILE_HOME ?? path4.join(os.homedir(), ".skaile");
312
+ return path4.join(home, "store");
313
+ }
314
+ function getStoreManifestsDir() {
315
+ return path4.join(getStoreRoot(), "manifests");
316
+ }
317
+ function migratedMarkerPath() {
318
+ return path4.join(getStoreRoot(), ".migrated");
319
+ }
320
+ function migrateSidecarsToStoreIfNeeded() {
321
+ const storeRoot = getStoreRoot();
322
+ const marker = migratedMarkerPath();
323
+ if (fs11.existsSync(marker)) return { migrated: 0, storeRoot };
324
+ const sidecarRoot = getSidecarRoot();
325
+ const manifestsDir = getStoreManifestsDir();
326
+ const candidates = [];
327
+ if (fs11.existsSync(sidecarRoot)) {
328
+ for (const entry of fs11.readdirSync(sidecarRoot, { withFileTypes: true })) {
329
+ if (!entry.isDirectory()) continue;
330
+ if (entry.name.startsWith(".")) continue;
331
+ const src = path4.join(sidecarRoot, entry.name, ".skaile-source.yaml");
332
+ if (fs11.existsSync(src)) candidates.push({ src, slug: entry.name });
333
+ }
334
+ }
335
+ fs11.mkdirSync(manifestsDir, { recursive: true });
336
+ let migrated = 0;
337
+ for (const { src, slug } of candidates) {
338
+ const dest = path4.join(manifestsDir, `${slug}.yaml`);
339
+ if (fs11.existsSync(dest)) continue;
340
+ try {
341
+ fs11.renameSync(src, dest);
342
+ migrated++;
343
+ } catch (err) {
344
+ process.stderr.write(
345
+ `[skaile/store] Failed to migrate sidecar ${slug}: ${err instanceof Error ? err.message : String(err)}
346
+ `
347
+ );
348
+ }
349
+ }
350
+ if (!fs11.existsSync(path4.join(storeRoot, ".git"))) {
351
+ try {
352
+ const { spawnSync: spawnSync3 } = __require("child_process");
353
+ spawnSync3("git", ["init", "--quiet"], { cwd: storeRoot, stdio: "ignore" });
354
+ fs11.writeFileSync(
355
+ path4.join(storeRoot, ".gitignore"),
356
+ "# Remote-store cache \u2014 local to this machine.\nremote-cache/\n",
357
+ "utf8"
358
+ );
359
+ } catch {
360
+ }
361
+ }
362
+ fs11.writeFileSync(marker, (/* @__PURE__ */ new Date()).toISOString(), "utf8");
363
+ return { migrated, storeRoot };
364
+ }
263
365
 
264
366
  // library/src/local/db.ts
265
367
  var DDL = `
@@ -337,8 +439,8 @@ async function librariesPresent(client) {
337
439
  );
338
440
  return rs.rows.length > 0;
339
441
  }
340
- function slugify(p) {
341
- const base = path5.basename(p) || "lib";
442
+ function slugify2(p) {
443
+ const base = path4.basename(p) || "lib";
342
444
  return base.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-|-$/g, "") || "lib";
343
445
  }
344
446
  async function runLibrariesMigration(client) {
@@ -364,14 +466,14 @@ async function runLibrariesMigration(client) {
364
466
  });
365
467
  const usedNames = /* @__PURE__ */ new Set();
366
468
  for (const row of oldRows) {
367
- const backend = row.type === "github" ? "git" : row.type === "catalog" ? "store" : "local";
469
+ const backend = row.type === "github" || row.type === "catalog" ? "git" : "local";
368
470
  const ownership = backend === "local" ? "owner" : "reader";
369
- const baseSlug = slugify(row.path ?? row.url);
471
+ const baseSlug = slugify2(row.path ?? row.url);
370
472
  let name = baseSlug;
371
473
  let i = 2;
372
474
  while (usedNames.has(name)) name = `${baseSlug}-${i++}`;
373
475
  usedNames.add(name);
374
- const cfg = backend === "git" ? { url: row.url, branch: row.ref ?? "main", authHint: "ssh" } : backend === "store" ? { url: row.url, publisher: "", tokenRef: "" } : {};
476
+ const cfg = backend === "git" ? { url: row.url, branch: row.ref ?? "main", authHint: "ssh" } : {};
375
477
  const now = (/* @__PURE__ */ new Date()).toISOString();
376
478
  stmts.push({
377
479
  sql: `INSERT INTO libraries
@@ -403,21 +505,41 @@ async function runLibrariesMigration(client) {
403
505
  stmts.push({ sql: `DROP TABLE sources;` });
404
506
  await client.batch(stmts);
405
507
  }
406
- function relocateLegacyFileIfPresent(newDbPath) {
407
- const fs12 = __require("fs");
408
- const parent = path5.dirname(newDbPath);
409
- if (path5.basename(parent) !== "libraries") return;
410
- const legacy = path5.join(path5.dirname(parent), "library", "lib.db");
411
- if (!fs12.existsSync(legacy) || fs12.existsSync(newDbPath)) return;
412
- fs12.mkdirSync(parent, { recursive: true });
413
- fs12.renameSync(legacy, newDbPath);
414
- for (const ext of ["-wal", "-shm"]) {
415
- const src = legacy + ext;
416
- if (fs12.existsSync(src)) fs12.renameSync(src, newDbPath + ext);
508
+ function assertNoLegacyLibDb(newDbPath) {
509
+ const fs13 = __require("fs");
510
+ const os5 = __require("os");
511
+ if (fs13.existsSync(newDbPath)) return;
512
+ const parent = path4.dirname(newDbPath);
513
+ const skaileHome = path4.join(os5.homedir(), ".skaile");
514
+ const defaultIndexPath2 = path4.join(skaileHome, "index.db");
515
+ const candidates = [];
516
+ if (path4.basename(newDbPath) === "index.db") {
517
+ candidates.push(path4.join(parent, "lib.db"));
518
+ }
519
+ if (newDbPath === defaultIndexPath2) {
520
+ candidates.push(path4.join(skaileHome, "libraries", "lib.db"));
521
+ candidates.push(path4.join(skaileHome, "library", "lib.db"));
522
+ }
523
+ if (path4.basename(parent) === "libraries") {
524
+ candidates.push(path4.join(path4.dirname(parent), "library", "lib.db"));
525
+ }
526
+ for (const legacy of candidates) {
527
+ if (!fs13.existsSync(legacy)) continue;
528
+ throw new Error(
529
+ `Found legacy index database at ${legacy}. The lib.db \u2192 index.db relocation ran for one release and has been removed. Move the file manually to ${newDbPath} (and any -wal / -shm siblings), then retry.`
530
+ );
417
531
  }
418
532
  }
419
533
  async function createLibraryDb(dbPath) {
420
- relocateLegacyFileIfPresent(dbPath);
534
+ assertNoLegacyLibDb(dbPath);
535
+ try {
536
+ migrateSidecarsToStoreIfNeeded();
537
+ } catch (err) {
538
+ process.stderr.write(
539
+ `[skaile/store] sidecar migration skipped: ${err instanceof Error ? err.message : String(err)}
540
+ `
541
+ );
542
+ }
421
543
  const client = createClient({ url: `file:${dbPath}` });
422
544
  await client.execute("PRAGMA journal_mode = WAL");
423
545
  await client.execute("PRAGMA foreign_keys = ON");
@@ -425,6 +547,19 @@ async function createLibraryDb(dbPath) {
425
547
  await runLibrariesMigration(client);
426
548
  }
427
549
  await client.executeMultiple(DDL);
550
+ if (await librariesPresent(client)) {
551
+ const storeRows = await client.execute({
552
+ sql: "SELECT id, name FROM libraries WHERE backend = ?",
553
+ args: ["store"]
554
+ });
555
+ if (storeRows.rows.length > 0) {
556
+ const names = storeRows.rows.map((r) => String(r.name)).join(", ");
557
+ client.close();
558
+ throw new Error(
559
+ `The 'store' library backend was removed in the 2026-05-27 vocabulary cleanup. Found rows still using it: ${names}. Run \`skaile library link <git-url>\` to convert each, or remove them with \`skaile library remove <name>\`.`
560
+ );
561
+ }
562
+ }
428
563
  try {
429
564
  await client.execute("ALTER TABLE instances ADD COLUMN source_commit_sha TEXT");
430
565
  } catch (err) {
@@ -511,7 +646,7 @@ async function installFromManifest(opts) {
511
646
  function escapeLikePrefix(prefix) {
512
647
  return prefix.replace(/[%_]/g, "\\$&");
513
648
  }
514
- function rowToSource(row) {
649
+ function rowToLibrary(row) {
515
650
  const cfg = (() => {
516
651
  try {
517
652
  return JSON.parse(row.backendConfig);
@@ -521,19 +656,17 @@ function rowToSource(row) {
521
656
  })();
522
657
  return {
523
658
  id: row.id,
524
- type: row.backend,
525
659
  name: row.name,
526
660
  path: row.path,
527
- ownership: row.ownership,
528
- isDefault: row.isDefault,
661
+ backend: row.backend,
529
662
  backendConfig: cfg,
663
+ ownership: row.ownership,
530
664
  structure: row.structure ?? void 0,
665
+ isDefault: row.isDefault,
531
666
  manifestGenerated: row.manifestGenerated,
532
- lastSyncedAt: row.lastSyncAt ? new Date(row.lastSyncAt) : void 0,
667
+ lastSyncAt: row.lastSyncAt ? new Date(row.lastSyncAt) : void 0,
533
668
  createdAt: new Date(row.createdAt),
534
- updatedAt: new Date(row.updatedAt),
535
- url: typeof cfg.url === "string" ? cfg.url : void 0,
536
- ref: typeof cfg.branch === "string" ? cfg.branch : void 0
669
+ updatedAt: new Date(row.updatedAt)
537
670
  };
538
671
  }
539
672
  function rowToAssetDef(row) {
@@ -548,7 +681,7 @@ function rowToAssetDef(row) {
548
681
  license: row.license ?? void 0,
549
682
  category: row.category ?? void 0,
550
683
  manifest: JSON.parse(row.manifest),
551
- sourceId: row.libraryId ?? void 0,
684
+ libraryId: row.libraryId ?? void 0,
552
685
  kindProviderVersion: row.kindProviderVersion ?? void 0,
553
686
  cachedAt: new Date(row.cachedAt),
554
687
  updatedAt: new Date(row.updatedAt)
@@ -576,32 +709,48 @@ function rowToSubscription(row) {
576
709
  subscribedAt: new Date(row.subscribedAt)
577
710
  };
578
711
  }
579
- var LocalLibrary = class {
712
+ var LocalIndex = class {
580
713
  dbPath;
581
714
  dbHandleRef = null;
582
715
  dbPromise = null;
583
716
  _kindRegistry;
584
- /** Absolute path to the library storage directory. */
717
+ /** Absolute path to the library checkouts directory. */
585
718
  libraryDir;
586
719
  /**
587
- * Construct a LocalLibrary. Synchronous — does not open the DB.
720
+ * Construct a LocalIndex. Synchronous — does not open the DB.
588
721
  *
589
- * @param optionsOrDir - Either a `LocalLibraryOptions` object or a string
590
- * path (legacy signature, kept for backward compat).
722
+ * @param optionsOrDir - Either a `LocalIndexOptions` object or a string
723
+ * path (legacy signature: treated as the libraryDir, with the index file
724
+ * landing at `<dir>/index.db`).
591
725
  */
592
726
  constructor(optionsOrDir) {
593
727
  let dir;
728
+ let dbPath;
594
729
  if (typeof optionsOrDir === "string") {
595
730
  dir = optionsOrDir;
731
+ dbPath = path4.join(dir, "index.db");
732
+ } else if (optionsOrDir?.indexPath) {
733
+ dbPath = optionsOrDir.indexPath;
734
+ dir = optionsOrDir.libraryDir ?? resolveLibraryDir();
735
+ this._kindRegistry = optionsOrDir.kindRegistry;
736
+ } else if (optionsOrDir?.libraryDir) {
737
+ dir = optionsOrDir.libraryDir;
738
+ dbPath = path4.join(dir, "index.db");
739
+ this._kindRegistry = optionsOrDir.kindRegistry;
596
740
  } else {
597
- dir = optionsOrDir?.libraryDir ?? resolveLibraryDir();
741
+ dir = resolveLibraryDir();
742
+ dbPath = resolveIndexPath();
598
743
  this._kindRegistry = optionsOrDir?.kindRegistry;
599
744
  }
600
- if (!fs10.existsSync(dir)) {
601
- fs10.mkdirSync(dir, { recursive: true });
745
+ if (!fs11.existsSync(dir)) {
746
+ fs11.mkdirSync(dir, { recursive: true });
747
+ }
748
+ const dbParent = path4.dirname(dbPath);
749
+ if (!fs11.existsSync(dbParent)) {
750
+ fs11.mkdirSync(dbParent, { recursive: true });
602
751
  }
603
752
  this.libraryDir = dir;
604
- this.dbPath = path5.join(dir, "lib.db");
753
+ this.dbPath = dbPath;
605
754
  }
606
755
  /**
607
756
  * Lazily open the SQLite DB on first use. The `??=` dedupes concurrent
@@ -623,15 +772,15 @@ var LocalLibrary = class {
623
772
  this.dbHandleRef = null;
624
773
  this.dbPromise = null;
625
774
  }
626
- /** Internal access for UserLibraryManager. Do not call from user code. */
775
+ /** Internal access for LibraryManager. Do not call from user code. */
627
776
  async dbHandle() {
628
777
  return this.ensureDb();
629
778
  }
630
- // -- Sources -------------------------------------------------------------
779
+ // -- Libraries (formerly "Sources") --------------------------------------
631
780
  async listSources() {
632
781
  const db = await this.ensureDb();
633
782
  const rows = await db.select().from(libraries).all();
634
- return rows.map(rowToSource);
783
+ return rows.map(rowToLibrary);
635
784
  }
636
785
  async addSource(input) {
637
786
  const db = await this.ensureDb();
@@ -641,16 +790,17 @@ var LocalLibrary = class {
641
790
  id,
642
791
  name: input.name,
643
792
  path: input.path,
644
- backend: input.type,
793
+ backend: input.backend,
645
794
  backendConfig: JSON.stringify(input.backendConfig ?? {}),
646
- ownership: input.ownership ?? (input.type === "local" ? "owner" : "reader"),
795
+ ownership: input.ownership ?? (input.backend === "local" ? "owner" : "reader"),
647
796
  isDefault: input.isDefault ?? false,
648
- manifestGenerated: false,
797
+ manifestGenerated: input.manifestGenerated ?? false,
798
+ structure: input.structure ?? null,
649
799
  createdAt: now,
650
800
  updatedAt: now
651
801
  }).run();
652
802
  const row = await db.select().from(libraries).where(eq(libraries.id, id)).get();
653
- return rowToSource(row);
803
+ return rowToLibrary(row);
654
804
  }
655
805
  async removeSource(id) {
656
806
  const db = await this.ensureDb();
@@ -664,7 +814,7 @@ var LocalLibrary = class {
664
814
  if (!existing) throw new SourceNotFoundError(id);
665
815
  const now = (/* @__PURE__ */ new Date()).toISOString();
666
816
  await db.update(libraries).set({ lastSyncAt: now, updatedAt: now }).where(eq(libraries.id, id)).run();
667
- return { sourceId: id, assetsFound: 0, assetsUpdated: 0, errors: [] };
817
+ return { libraryId: id, assetsFound: 0, assetsUpdated: 0, errors: [] };
668
818
  }
669
819
  // -- Asset definitions ---------------------------------------------------
670
820
  /**
@@ -694,7 +844,7 @@ var LocalLibrary = class {
694
844
  license: def.license ?? null,
695
845
  category: def.category ?? null,
696
846
  manifest: JSON.stringify(def.manifest),
697
- libraryId: def.sourceId ?? null,
847
+ libraryId: def.libraryId ?? null,
698
848
  kindProviderVersion: providerVersion,
699
849
  cachedAt: def.cachedAt?.toISOString() ?? now,
700
850
  updatedAt: now
@@ -710,7 +860,7 @@ var LocalLibrary = class {
710
860
  license: def.license ?? null,
711
861
  category: def.category ?? null,
712
862
  manifest: JSON.stringify(def.manifest),
713
- libraryId: def.sourceId ?? null,
863
+ libraryId: def.libraryId ?? null,
714
864
  kindProviderVersion: providerVersion,
715
865
  updatedAt: now
716
866
  }
@@ -731,7 +881,7 @@ var LocalLibrary = class {
731
881
  if (filter.publisher) conditions.push(eq(assetDefinitions.publisher, filter.publisher));
732
882
  if (filter.prefix)
733
883
  conditions.push(like(assetDefinitions.id, `${escapeLikePrefix(filter.prefix)}%`));
734
- if (filter.sourceId) conditions.push(eq(assetDefinitions.libraryId, filter.sourceId));
884
+ if (filter.libraryId) conditions.push(eq(assetDefinitions.libraryId, filter.libraryId));
735
885
  const where = conditions.length > 0 ? and(...conditions) : void 0;
736
886
  let rows = where ? await db.select().from(assetDefinitions).where(where).all() : await db.select().from(assetDefinitions).all();
737
887
  if (filter.offset) rows = rows.slice(filter.offset);
@@ -781,7 +931,7 @@ var LocalLibrary = class {
781
931
  * 2. records an {@link Instance} row carrying `sourceCommitSha` so the
782
932
  * install is auditable and re-verifiable.
783
933
  *
784
- * Not part of the {@link ILibrary} interface — `LocalLibrary`-only, since
934
+ * Not part of the {@link IAssetIndex} interface — `LocalIndex`-only, since
785
935
  * the platform variant resolves install bytes differently.
786
936
  *
787
937
  * @param manifest - The pointer-only install manifest from the Catalog.
@@ -795,7 +945,7 @@ var LocalLibrary = class {
795
945
  * @returns The created Instance plus its on-disk install path.
796
946
  */
797
947
  async install(manifest, opts) {
798
- const libraryRoot = opts?.libraryRoot ?? path5.join(this.libraryDir, "installed");
948
+ const libraryRoot = opts?.libraryRoot ?? path4.join(this.libraryDir, "installed");
799
949
  const { installPath } = await installFromManifest({
800
950
  manifest,
801
951
  libraryRoot,
@@ -907,7 +1057,7 @@ var LocalLibrary = class {
907
1057
  };
908
1058
 
909
1059
  // library/src/user-library.ts
910
- var LIBRARY_BACKENDS = ["local", "git", "store"];
1060
+ var LIBRARY_BACKENDS = ["local", "git"];
911
1061
  var LIBRARY_OWNERSHIPS = ["owner", "contributor", "reader"];
912
1062
  var LIBRARY_STRUCTURES = ["flat", "domain"];
913
1063
  var LibrarySyncError = class extends Error {
@@ -1101,35 +1251,8 @@ var LocalSyncDriver = class {
1101
1251
  }
1102
1252
  };
1103
1253
 
1104
- // library/src/sync/store-driver.ts
1105
- var StoreSyncDriver = class {
1106
- backend = "store";
1107
- async status(_lib) {
1108
- return {
1109
- reachable: true,
1110
- localChanges: { added: [], modified: [], deleted: [] },
1111
- notes: ["catalog refresh only \u2014 store write path is a stub in MVP"]
1112
- };
1113
- }
1114
- async pull(_lib, _opts) {
1115
- return { applied: 0, conflicts: [] };
1116
- }
1117
- async push(_lib, _opts) {
1118
- throw new OperationNotPermittedError("push", "store libraries publish via `publish`");
1119
- }
1120
- async propose(_lib, _opts) {
1121
- throw new OperationNotPermittedError("propose", "store libraries publish via `publish`");
1122
- }
1123
- async publish(_lib, _refs, _opts) {
1124
- throw new LibrarySyncError(
1125
- "store backend write path is not yet wired (MVP stub)",
1126
- "remote_error"
1127
- );
1128
- }
1129
- };
1130
-
1131
- // library/src/local/user-library-manager.ts
1132
- function rowToUserLibrary(row) {
1254
+ // library/src/local/library-manager.ts
1255
+ function rowToLibrary2(row) {
1133
1256
  const cfg = (() => {
1134
1257
  try {
1135
1258
  return JSON.parse(row.backendConfig);
@@ -1152,14 +1275,13 @@ function rowToUserLibrary(row) {
1152
1275
  updatedAt: new Date(row.updatedAt)
1153
1276
  };
1154
1277
  }
1155
- var UserLibraryManager = class {
1278
+ var LibraryManager = class {
1156
1279
  constructor(lib) {
1157
1280
  this.lib = lib;
1158
1281
  }
1159
1282
  lib;
1160
1283
  localDrv = new LocalSyncDriver();
1161
1284
  gitDrv = new GitSyncDriver();
1162
- storeDrv = new StoreSyncDriver();
1163
1285
  /** Resolve the sync driver for a given backend. */
1164
1286
  driverFor(backend) {
1165
1287
  switch (backend) {
@@ -1167,8 +1289,6 @@ var UserLibraryManager = class {
1167
1289
  return this.localDrv;
1168
1290
  case "git":
1169
1291
  return this.gitDrv;
1170
- case "store":
1171
- return this.storeDrv;
1172
1292
  }
1173
1293
  }
1174
1294
  async addLibrary(input) {
@@ -1198,7 +1318,7 @@ var UserLibraryManager = class {
1198
1318
  async listLibraries() {
1199
1319
  const db = await this.lib.dbHandle();
1200
1320
  const rows = await db.select().from(libraries).all();
1201
- return rows.map(rowToUserLibrary).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
1321
+ return rows.map(rowToLibrary2).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
1202
1322
  }
1203
1323
  async getLibrary(nameOrId) {
1204
1324
  const db = await this.lib.dbHandle();
@@ -1206,7 +1326,7 @@ var UserLibraryManager = class {
1206
1326
  if (!row) {
1207
1327
  row = await db.select().from(libraries).where(eq(libraries.id, nameOrId)).get();
1208
1328
  }
1209
- return row ? rowToUserLibrary(row) : null;
1329
+ return row ? rowToLibrary2(row) : null;
1210
1330
  }
1211
1331
  async requireLibrary(nameOrId) {
1212
1332
  const lib = await this.getLibrary(nameOrId);
@@ -1221,6 +1341,7 @@ var UserLibraryManager = class {
1221
1341
  };
1222
1342
  if (patch.name !== void 0) updates.name = patch.name;
1223
1343
  if (patch.path !== void 0) updates.path = patch.path;
1344
+ if (patch.backend !== void 0) updates.backend = patch.backend;
1224
1345
  if (patch.backendConfig !== void 0)
1225
1346
  updates.backendConfig = JSON.stringify(patch.backendConfig);
1226
1347
  if (patch.ownership !== void 0) updates.ownership = patch.ownership;
@@ -1242,8 +1363,8 @@ var UserLibraryManager = class {
1242
1363
  const lib = await this.requireLibrary(nameOrId);
1243
1364
  const db = await this.lib.dbHandle();
1244
1365
  await db.delete(libraries).where(eq(libraries.id, lib.id)).run();
1245
- if (opts.purge && fs10.existsSync(lib.path)) {
1246
- fs10.rmSync(lib.path, { recursive: true, force: true });
1366
+ if (opts.purge && fs11.existsSync(lib.path)) {
1367
+ fs11.rmSync(lib.path, { recursive: true, force: true });
1247
1368
  }
1248
1369
  }
1249
1370
  /**
@@ -1259,8 +1380,8 @@ var UserLibraryManager = class {
1259
1380
  (l) => l.isDefault && (l.ownership === "owner" || l.ownership === "contributor")
1260
1381
  );
1261
1382
  if (writableDefault) return { library: writableDefault, created: false };
1262
- const personalPath = path5.join(librariesDir, "personal");
1263
- fs10.mkdirSync(personalPath, { recursive: true });
1383
+ const personalPath = path4.join(librariesDir, "personal");
1384
+ fs11.mkdirSync(personalPath, { recursive: true });
1264
1385
  const lib = await this.addLibrary({
1265
1386
  name: "personal",
1266
1387
  path: personalPath,
@@ -1278,54 +1399,13 @@ var UserLibraryManager = class {
1278
1399
  return { library: lib, created: true };
1279
1400
  }
1280
1401
  };
1281
- var SKAILE_HOME_ENV = "SKAILE_HOME";
1282
- function getSidecarRoot() {
1283
- const home = process.env[SKAILE_HOME_ENV] ?? path5.join(os.homedir(), ".skaile");
1284
- return path5.join(home, "sources");
1285
- }
1286
- function resolveSidecarPaths(slug) {
1287
- const rootDir = getSidecarRoot();
1288
- const sidecarDir = path5.join(rootDir, slug);
1289
- return {
1290
- rootDir,
1291
- sidecarDir,
1292
- manifestFile: path5.join(sidecarDir, ".skaile-source.yaml"),
1293
- readmeFile: path5.join(sidecarDir, "README.md"),
1294
- lockFile: path5.join(sidecarDir, ".skaile-source.lock.json")
1295
- };
1296
- }
1297
- function deriveSlug(sourceConfig, sourcePath, existingSlugs) {
1298
- const fromConfig = sourceConfig && typeof sourceConfig.name === "string" ? sourceConfig.name : void 0;
1299
- const base = fromConfig && fromConfig.length > 0 ? slugify2(fromConfig) : slugify2(path5.basename(sourcePath || "")) || "unnamed-source";
1300
- const taken = new Set(existingSlugs);
1301
- if (!taken.has(base)) return base;
1302
- for (let i = 2; i < 1e3; i++) {
1303
- const candidate = `${base}-${i}`;
1304
- if (!taken.has(candidate)) return candidate;
1305
- }
1306
- return `${base}-${Math.random().toString(36).slice(2, 8)}`;
1307
- }
1308
- function listSidecarSlugsOnDisk() {
1309
- const root = getSidecarRoot();
1310
- if (!fs10.existsSync(root)) return [];
1311
- const out = [];
1312
- for (const entry of fs10.readdirSync(root, { withFileTypes: true })) {
1313
- if (!entry.isDirectory()) continue;
1314
- if (entry.name.startsWith(".")) continue;
1315
- out.push(entry.name);
1316
- }
1317
- return out.sort();
1318
- }
1319
- function slugify2(input) {
1320
- return input.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "");
1321
- }
1322
1402
  var FALLBACK_USER_NAME = "Skaile CLI";
1323
1403
  var FALLBACK_USER_EMAIL = "skaile-cli@local";
1324
1404
  var ROOT_README = `# Skaile Sidecar Manifests
1325
1405
 
1326
1406
  This directory is managed by \`skaile source sidecar\` commands. Each
1327
1407
  subdirectory is a curated local-overlay manifest for an asset source
1328
- registered in your LocalLibrary at \`~/.skaile/library/lib.db\`.
1408
+ registered in your LocalIndex at \`~/.skaile/index.db\`.
1329
1409
 
1330
1410
  You can push this repo to your own remote (e.g. a private dotfiles repo)
1331
1411
  to share or back up your sidecars across machines:
@@ -1363,21 +1443,21 @@ var SidecarGit = class {
1363
1443
  * @docLink packages/library/concepts#sidecar-git
1364
1444
  */
1365
1445
  async ensureInitialized() {
1366
- if (!fs10.existsSync(this.rootDir)) {
1367
- fs10.mkdirSync(this.rootDir, { recursive: true });
1446
+ if (!fs11.existsSync(this.rootDir)) {
1447
+ fs11.mkdirSync(this.rootDir, { recursive: true });
1368
1448
  }
1369
- const gitDir = path5.join(this.rootDir, ".git");
1370
- const freshRepo = !fs10.existsSync(gitDir);
1449
+ const gitDir = path4.join(this.rootDir, ".git");
1450
+ const freshRepo = !fs11.existsSync(gitDir);
1371
1451
  if (freshRepo) {
1372
1452
  const init = this.spawn(["init", "-b", "main"]);
1373
1453
  if (init.exitCode !== 0) {
1374
1454
  throw new Error(`git init failed: ${init.stderr || init.stdout}`);
1375
1455
  }
1376
1456
  }
1377
- const attrsPath = path5.join(this.rootDir, ".gitattributes");
1378
- if (!fs10.existsSync(attrsPath)) fs10.writeFileSync(attrsPath, GITATTRIBUTES, "utf-8");
1379
- const readmePath = path5.join(this.rootDir, "README.md");
1380
- if (!fs10.existsSync(readmePath)) fs10.writeFileSync(readmePath, ROOT_README, "utf-8");
1457
+ const attrsPath = path4.join(this.rootDir, ".gitattributes");
1458
+ if (!fs11.existsSync(attrsPath)) fs11.writeFileSync(attrsPath, GITATTRIBUTES, "utf-8");
1459
+ const readmePath = path4.join(this.rootDir, "README.md");
1460
+ if (!fs11.existsSync(readmePath)) fs11.writeFileSync(readmePath, ROOT_README, "utf-8");
1381
1461
  if (!this.hasGlobalGitConfig("user.name")) {
1382
1462
  this.spawn(["config", "user.name", FALLBACK_USER_NAME]);
1383
1463
  }
@@ -1402,8 +1482,8 @@ var SidecarGit = class {
1402
1482
  */
1403
1483
  async commit(slug, message, opts) {
1404
1484
  if (opts?.skip) return;
1405
- const slugDir = path5.join(this.rootDir, slug);
1406
- if (fs10.existsSync(slugDir)) {
1485
+ const slugDir = path4.join(this.rootDir, slug);
1486
+ if (fs11.existsSync(slugDir)) {
1407
1487
  this.spawn(["add", "--", slug]);
1408
1488
  } else {
1409
1489
  this.spawn(["add", "-A"]);
@@ -1513,42 +1593,42 @@ function parseWorkspaceV2(raw) {
1513
1593
  return WorkspaceConfigV2Schema.parse(raw);
1514
1594
  }
1515
1595
  function loadWorkspaceV2(dir, filename = "skaile.yaml") {
1516
- const filePath = path5.join(dir, filename);
1517
- if (!fs10.existsSync(filePath)) return null;
1518
- const content = fs10.readFileSync(filePath, "utf-8");
1596
+ const filePath = path4.join(dir, filename);
1597
+ if (!fs11.existsSync(filePath)) return null;
1598
+ const content = fs11.readFileSync(filePath, "utf-8");
1519
1599
  const raw = parse(content);
1520
1600
  if (!raw || typeof raw !== "object") return null;
1521
1601
  return parseWorkspaceV2(raw);
1522
1602
  }
1523
1603
  function saveWorkspaceV2(dir, v2, filename = "skaile.yaml") {
1524
- const filePath = path5.join(dir, filename);
1604
+ const filePath = path4.join(dir, filename);
1525
1605
  let existing = {};
1526
- if (fs10.existsSync(filePath)) {
1527
- const content = fs10.readFileSync(filePath, "utf-8");
1606
+ if (fs11.existsSync(filePath)) {
1607
+ const content = fs11.readFileSync(filePath, "utf-8");
1528
1608
  existing = parse(content) ?? {};
1529
1609
  }
1530
1610
  existing.version = 2;
1531
1611
  if (v2.library !== void 0) existing.library = v2.library;
1532
1612
  if (v2.presets_applied !== void 0) existing.presets_applied = v2.presets_applied;
1533
- if (!fs10.existsSync(dir)) {
1534
- fs10.mkdirSync(dir, { recursive: true });
1613
+ if (!fs11.existsSync(dir)) {
1614
+ fs11.mkdirSync(dir, { recursive: true });
1535
1615
  }
1536
- fs10.writeFileSync(filePath, stringify(existing, { indent: 2 }), "utf-8");
1616
+ fs11.writeFileSync(filePath, stringify(existing, { indent: 2 }), "utf-8");
1537
1617
  }
1538
1618
  var LOCK_FILENAME = "skaile.lock.yaml";
1539
1619
  function loadLockFile(dir) {
1540
- const filePath = path5.join(dir, LOCK_FILENAME);
1541
- if (!fs10.existsSync(filePath)) return null;
1542
- const content = fs10.readFileSync(filePath, "utf-8");
1620
+ const filePath = path4.join(dir, LOCK_FILENAME);
1621
+ if (!fs11.existsSync(filePath)) return null;
1622
+ const content = fs11.readFileSync(filePath, "utf-8");
1543
1623
  const raw = parse(content);
1544
1624
  return LockFileSchema.parse(raw);
1545
1625
  }
1546
1626
  function saveLockFile(dir, lock) {
1547
- const filePath = path5.join(dir, LOCK_FILENAME);
1548
- if (!fs10.existsSync(dir)) {
1549
- fs10.mkdirSync(dir, { recursive: true });
1627
+ const filePath = path4.join(dir, LOCK_FILENAME);
1628
+ if (!fs11.existsSync(dir)) {
1629
+ fs11.mkdirSync(dir, { recursive: true });
1550
1630
  }
1551
- fs10.writeFileSync(
1631
+ fs11.writeFileSync(
1552
1632
  filePath,
1553
1633
  `# Auto-generated by skaile. Do not edit manually.
1554
1634
  ${stringify(lock, { indent: 2 })}`,
@@ -1565,17 +1645,17 @@ function createEmptyLockFile() {
1565
1645
  };
1566
1646
  }
1567
1647
  function detectWorkspaceVersion(dir, filename = "skaile.yaml") {
1568
- const filePath = path5.join(dir, filename);
1569
- if (!fs10.existsSync(filePath)) return null;
1570
- const content = fs10.readFileSync(filePath, "utf-8");
1648
+ const filePath = path4.join(dir, filename);
1649
+ if (!fs11.existsSync(filePath)) return null;
1650
+ const content = fs11.readFileSync(filePath, "utf-8");
1571
1651
  const raw = parse(content);
1572
1652
  if (!raw || typeof raw !== "object") return null;
1573
1653
  return raw.version === 2 ? 2 : 1;
1574
1654
  }
1575
1655
  var MANIFEST_FILENAME = ".skaile-source.yaml";
1576
1656
  async function writeManifestIfMissing(input) {
1577
- const manifestPath = path5.join(input.libraryPath, MANIFEST_FILENAME);
1578
- if (fs10.existsSync(manifestPath)) return { wrote: false, manifestPath };
1657
+ const manifestPath = path4.join(input.libraryPath, MANIFEST_FILENAME);
1658
+ if (fs11.existsSync(manifestPath)) return { wrote: false, manifestPath };
1579
1659
  const now = (/* @__PURE__ */ new Date()).toISOString();
1580
1660
  const yaml = `# Generated by skaile library add on ${now}
1581
1661
  # Edit by hand to inline discovered assets; or run \`skaile library refresh-manifest\`.
@@ -1584,13 +1664,13 @@ structure: ${input.structure}
1584
1664
  publisher: ""
1585
1665
  assets: []
1586
1666
  `;
1587
- fs10.writeFileSync(manifestPath, yaml, "utf-8");
1667
+ fs11.writeFileSync(manifestPath, yaml, "utf-8");
1588
1668
  if (input.ownership !== "owner") {
1589
- const excludePath = path5.join(input.libraryPath, ".git", "info", "exclude");
1590
- if (fs10.existsSync(path5.dirname(excludePath))) {
1591
- const current = fs10.existsSync(excludePath) ? fs10.readFileSync(excludePath, "utf-8") : "";
1669
+ const excludePath = path4.join(input.libraryPath, ".git", "info", "exclude");
1670
+ if (fs11.existsSync(path4.dirname(excludePath))) {
1671
+ const current = fs11.existsSync(excludePath) ? fs11.readFileSync(excludePath, "utf-8") : "";
1592
1672
  if (!current.includes(MANIFEST_FILENAME)) {
1593
- fs10.writeFileSync(
1673
+ fs11.writeFileSync(
1594
1674
  excludePath,
1595
1675
  (current.endsWith("\n") || current === "" ? current : `${current}
1596
1676
  `) + `# skaile-managed local-overlay manifest
@@ -1605,11 +1685,11 @@ ${MANIFEST_FILENAME}
1605
1685
  }
1606
1686
  function migrateWorkspaceConfig(dir, opts) {
1607
1687
  const filename = opts?.filename ?? "skaile.yaml";
1608
- const filePath = path5.join(dir, filename);
1609
- if (!fs10.existsSync(filePath)) {
1688
+ const filePath = path4.join(dir, filename);
1689
+ if (!fs11.existsSync(filePath)) {
1610
1690
  return { migrated: false, version: 1, warnings: ["No skaile.yaml found"] };
1611
1691
  }
1612
- const content = fs10.readFileSync(filePath, "utf-8");
1692
+ const content = fs11.readFileSync(filePath, "utf-8");
1613
1693
  const raw = parse(content);
1614
1694
  if (!raw || typeof raw !== "object") {
1615
1695
  return { migrated: false, version: 1, warnings: ["Invalid YAML content"] };
@@ -1641,7 +1721,7 @@ function migrateWorkspaceConfig(dir, opts) {
1641
1721
  } else {
1642
1722
  doc.set("version", 2);
1643
1723
  }
1644
- fs10.writeFileSync(filePath, doc.toString(), "utf-8");
1724
+ fs11.writeFileSync(filePath, doc.toString(), "utf-8");
1645
1725
  }
1646
1726
  return {
1647
1727
  migrated: !opts?.dryRun,
@@ -1741,11 +1821,11 @@ var LocalCatalogSource = class {
1741
1821
  sidecarPath;
1742
1822
  async resolve(ref) {
1743
1823
  const def = await this.library.getAssetDef(ref);
1744
- if (!def || def.sourceId !== this.sourceId) return null;
1824
+ if (!def || def.libraryId !== this.sourceId) return null;
1745
1825
  return defToCatalogAsset(def);
1746
1826
  }
1747
1827
  async listAssets(filter) {
1748
- const libraryFilter = { sourceId: this.sourceId };
1828
+ const libraryFilter = { libraryId: this.sourceId };
1749
1829
  if (filter?.kind) libraryFilter.kind = filter.kind;
1750
1830
  if (filter?.publisher) libraryFilter.publisher = filter.publisher;
1751
1831
  if (filter?.prefix) libraryFilter.prefix = filter.prefix;
@@ -1764,7 +1844,7 @@ var LocalCatalogSource = class {
1764
1844
  * Sync: discover assets in the source directory and cache them in the library.
1765
1845
  *
1766
1846
  * Runs the discovery pipeline (glob -> parse -> filter -> hash -> requires)
1767
- * and upserts each discovered asset into the LocalLibrary cache.
1847
+ * and upserts each discovered asset into the LocalIndex cache.
1768
1848
  *
1769
1849
  * @returns Discovery statistics and any errors encountered.
1770
1850
  */
@@ -1793,7 +1873,7 @@ var LocalCatalogSource = class {
1793
1873
  license: typeof asset.manifest.license === "string" ? asset.manifest.license : void 0,
1794
1874
  category: typeof asset.manifest.category === "string" ? asset.manifest.category : void 0,
1795
1875
  manifest: asset.manifest,
1796
- sourceId: this.sourceId,
1876
+ libraryId: this.sourceId,
1797
1877
  cachedAt: /* @__PURE__ */ new Date(),
1798
1878
  updatedAt: /* @__PURE__ */ new Date()
1799
1879
  });
@@ -1823,10 +1903,10 @@ function defToCatalogAsset(def) {
1823
1903
  };
1824
1904
  }
1825
1905
  function loadSourceConfigIfPresent(rootPath) {
1826
- const configPath = path5.join(rootPath, ".skaile-source.yaml");
1827
- if (!fs10.existsSync(configPath)) return void 0;
1906
+ const configPath = path4.join(rootPath, ".skaile-source.yaml");
1907
+ if (!fs11.existsSync(configPath)) return void 0;
1828
1908
  try {
1829
- const content = fs10.readFileSync(configPath, "utf-8");
1909
+ const content = fs11.readFileSync(configPath, "utf-8");
1830
1910
  const result = loadSourceConfig(content);
1831
1911
  if (!result.ok) return void 0;
1832
1912
  return result.config;
@@ -1835,7 +1915,7 @@ function loadSourceConfigIfPresent(rootPath) {
1835
1915
  }
1836
1916
  }
1837
1917
  function defaultCacheDir() {
1838
- return path5.join(os.homedir(), ".skaile", "catalog-cache");
1918
+ return path4.join(os.homedir(), ".skaile", "catalog-cache");
1839
1919
  }
1840
1920
  var INDEX_FILE = "index.json";
1841
1921
  var TARBALL_DIR = "tarballs";
@@ -1907,22 +1987,22 @@ var CatalogCache = class {
1907
1987
  // ── public: tarball cache ───────────────────────────────────────────────
1908
1988
  /** Absolute path where a tarball with `sha256` would be cached. */
1909
1989
  tarballPath(sha256) {
1910
- return path5.join(this.dir, TARBALL_DIR, `${sha256}.tgz`);
1990
+ return path4.join(this.dir, TARBALL_DIR, `${sha256}.tgz`);
1911
1991
  }
1912
1992
  /** Read a cached tarball from disk if present, otherwise `null`. */
1913
1993
  readTarball(sha256) {
1914
1994
  const p = this.tarballPath(sha256);
1915
- if (!fs10.existsSync(p)) return null;
1916
- return fs10.readFileSync(p);
1995
+ if (!fs11.existsSync(p)) return null;
1996
+ return fs11.readFileSync(p);
1917
1997
  }
1918
1998
  /** Persist a tarball blob to disk (atomic write). */
1919
1999
  writeTarball(sha256, bytes) {
1920
- const dir = path5.join(this.dir, TARBALL_DIR);
1921
- if (!fs10.existsSync(dir)) fs10.mkdirSync(dir, { recursive: true });
2000
+ const dir = path4.join(this.dir, TARBALL_DIR);
2001
+ if (!fs11.existsSync(dir)) fs11.mkdirSync(dir, { recursive: true });
1922
2002
  const finalPath = this.tarballPath(sha256);
1923
2003
  const tmpPath = `${finalPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
1924
- fs10.writeFileSync(tmpPath, bytes);
1925
- fs10.renameSync(tmpPath, finalPath);
2004
+ fs11.writeFileSync(tmpPath, bytes);
2005
+ fs11.renameSync(tmpPath, finalPath);
1926
2006
  }
1927
2007
  // ── public: invalidation ────────────────────────────────────────────────
1928
2008
  /**
@@ -1941,9 +2021,9 @@ var CatalogCache = class {
1941
2021
  */
1942
2022
  invalidateEverything() {
1943
2023
  this.invalidateAll();
1944
- const tarballDir = path5.join(this.dir, TARBALL_DIR);
1945
- if (fs10.existsSync(tarballDir)) {
1946
- fs10.rmSync(tarballDir, { recursive: true, force: true });
2024
+ const tarballDir = path4.join(this.dir, TARBALL_DIR);
2025
+ if (fs11.existsSync(tarballDir)) {
2026
+ fs11.rmSync(tarballDir, { recursive: true, force: true });
1947
2027
  }
1948
2028
  }
1949
2029
  /** Return whether `ttlMs` is zero (air-gapped mode). */
@@ -1952,22 +2032,22 @@ var CatalogCache = class {
1952
2032
  }
1953
2033
  // ── private ─────────────────────────────────────────────────────────────
1954
2034
  ensureDir() {
1955
- if (!fs10.existsSync(this.dir)) fs10.mkdirSync(this.dir, { recursive: true });
1956
- const tarballDir = path5.join(this.dir, TARBALL_DIR);
1957
- if (!fs10.existsSync(tarballDir)) fs10.mkdirSync(tarballDir, { recursive: true });
2035
+ if (!fs11.existsSync(this.dir)) fs11.mkdirSync(this.dir, { recursive: true });
2036
+ const tarballDir = path4.join(this.dir, TARBALL_DIR);
2037
+ if (!fs11.existsSync(tarballDir)) fs11.mkdirSync(tarballDir, { recursive: true });
1958
2038
  }
1959
2039
  indexPath() {
1960
- return path5.join(this.dir, INDEX_FILE);
2040
+ return path4.join(this.dir, INDEX_FILE);
1961
2041
  }
1962
2042
  loadIndex() {
1963
2043
  if (this.index) return this.index;
1964
2044
  const p = this.indexPath();
1965
- if (!fs10.existsSync(p)) {
2045
+ if (!fs11.existsSync(p)) {
1966
2046
  this.index = { version: 1, resolve: {}, list: {} };
1967
2047
  return this.index;
1968
2048
  }
1969
2049
  try {
1970
- const raw = JSON.parse(fs10.readFileSync(p, "utf-8"));
2050
+ const raw = JSON.parse(fs11.readFileSync(p, "utf-8"));
1971
2051
  if (raw && typeof raw === "object" && raw.version === 1) {
1972
2052
  this.index = {
1973
2053
  version: 1,
@@ -1985,8 +2065,8 @@ var CatalogCache = class {
1985
2065
  this.index = idx;
1986
2066
  const p = this.indexPath();
1987
2067
  const tmp = `${p}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
1988
- fs10.writeFileSync(tmp, JSON.stringify(idx, null, 2), "utf-8");
1989
- fs10.renameSync(tmp, p);
2068
+ fs11.writeFileSync(tmp, JSON.stringify(idx, null, 2), "utf-8");
2069
+ fs11.renameSync(tmp, p);
1990
2070
  }
1991
2071
  };
1992
2072
  function filterKey(filter) {
@@ -2718,11 +2798,11 @@ function validateKnowledge(data) {
2718
2798
  };
2719
2799
  }
2720
2800
  function collectDirRecursive(baseDir, relativeDir) {
2721
- const full = path5.join(baseDir, relativeDir);
2722
- if (!fs10.existsSync(full) || !fs10.statSync(full).isDirectory()) return [];
2801
+ const full = path4.join(baseDir, relativeDir);
2802
+ if (!fs11.existsSync(full) || !fs11.statSync(full).isDirectory()) return [];
2723
2803
  const results = [];
2724
- for (const entry of fs10.readdirSync(full, { withFileTypes: true })) {
2725
- const rel = path5.posix.join(relativeDir, entry.name);
2804
+ for (const entry of fs11.readdirSync(full, { withFileTypes: true })) {
2805
+ const rel = path4.posix.join(relativeDir, entry.name);
2726
2806
  if (entry.isDirectory()) {
2727
2807
  results.push(...collectDirRecursive(baseDir, rel));
2728
2808
  } else if (entry.isFile()) {
@@ -2749,8 +2829,8 @@ var knowledgeKindProvider = {
2749
2829
  return validateKnowledge(data);
2750
2830
  },
2751
2831
  defaultFileFilter(manifestPath) {
2752
- const dir = path5.dirname(manifestPath);
2753
- const manifestName = path5.basename(manifestPath);
2832
+ const dir = path4.dirname(manifestPath);
2833
+ const manifestName = path4.basename(manifestPath);
2754
2834
  const files = [manifestName];
2755
2835
  files.push(...collectDirRecursive(dir, "documents"));
2756
2836
  files.sort();
@@ -3128,8 +3208,8 @@ function resolveTemplate(template, context) {
3128
3208
  });
3129
3209
  return { value: result, hasSecret: false };
3130
3210
  }
3131
- function setNestedValue(obj, path13, value) {
3132
- const parts = path13.split(".");
3211
+ function setNestedValue(obj, path14, value) {
3212
+ const parts = path14.split(".");
3133
3213
  let current = obj;
3134
3214
  for (let i = 0; i < parts.length - 1; i++) {
3135
3215
  const key = parts[i];
@@ -3430,6 +3510,6 @@ function deepEqual(a, b) {
3430
3510
  return JSON.stringify(a) === JSON.stringify(b);
3431
3511
  }
3432
3512
 
3433
- export { CatalogCache, CatalogConfigSchema, CatalogHttpError, DuplicateLibraryNameError, DuplicateSubscriptionError, GitSyncDriver, InstanceHasConsumersError, InstanceNotFoundError, InterpolationError, KNOWN_ASSET_KINDS, KnowledgeManifestSchema, LIBRARY_BACKENDS, LIBRARY_OWNERSHIPS, LIBRARY_STRUCTURES, LOCAL_CATALOG_URL, LibraryConfigSchema, LibraryError, LibraryInstanceRefSchema, LibrarySectionSchema, LibrarySyncError, LocalCatalogSource, LocalLibrary, LocalSyncDriver, LockFileSchema, LockSubscriptionSchema, OfflineError, OperationNotPermittedError, PIN_POLICIES, PinPolicySchema, PresetAppliedSchema, PresetExpandedSchema, RemoteCatalogSource, RequiresEdgeSchema, RestCatalogSource, SidecarGit, SkaileConfigSchema, SourceNotFoundError, StoreSyncDriver, SubscriptionNotFoundError, TarballHashMismatchError, UserLibraryManager, UserLibraryNotFoundError, WorkspaceConfigV2Schema, applyNonStructuralUpgrade, applyPreset, applyPresetFromData, classifyRef, createEmptyLockFile, deriveSlug, detectChanges, detectNestedPresetRefs, detectWorkspaceVersion, evaluateUpgrade, extractLibraryInstanceId, extractReferencedKeys, filterKey, getConfigDefaults, getDefaultValue, getSidecarRoot, hasInterpolationTokens, installFromManifest, interpolate, isLocalCatalogUrl, isSecretPlaceholder, knowledgeKindProvider, listSidecarSlugsOnDisk, loadLockFile, loadWorkspaceV2, migrateWorkspaceConfig, parsePreset, parsePresetYaml, parseWorkspaceV2, projectConfigPath, queryInstancePickerChoices, resolveAllItems, resolveConfig, resolveItem, resolveLibraryDir, resolvePin, resolveSidecarPaths, saveConfig, saveLockFile, saveWorkspaceV2, sha256Hex, storeSecrets, trpcGetUrl, userConfigPath, validateAllPlaceholders, validateKnowledge, validateNestingDepth, validatePlaceholder, writeManifestIfMissing };
3434
- //# sourceMappingURL=chunk-42OQF7UU.js.map
3435
- //# sourceMappingURL=chunk-42OQF7UU.js.map
3513
+ export { CatalogCache, CatalogConfigSchema, CatalogHttpError, DuplicateLibraryNameError, DuplicateSubscriptionError, GitSyncDriver, InstanceHasConsumersError, InstanceNotFoundError, InterpolationError, KNOWN_ASSET_KINDS, KnowledgeManifestSchema, LIBRARY_BACKENDS, LIBRARY_OWNERSHIPS, LIBRARY_STRUCTURES, LOCAL_CATALOG_URL, LibraryConfigSchema, LibraryError, LibraryInstanceRefSchema, LibraryManager, LibrarySectionSchema, LibrarySyncError, LocalCatalogSource, LocalIndex, LocalSyncDriver, LockFileSchema, LockSubscriptionSchema, OfflineError, OperationNotPermittedError, PIN_POLICIES, PinPolicySchema, PresetAppliedSchema, PresetExpandedSchema, RemoteCatalogSource, RequiresEdgeSchema, RestCatalogSource, SidecarGit, SkaileConfigSchema, SourceNotFoundError, SubscriptionNotFoundError, TarballHashMismatchError, UserLibraryNotFoundError, WorkspaceConfigV2Schema, applyNonStructuralUpgrade, applyPreset, applyPresetFromData, classifyRef, createEmptyLockFile, deriveSlug, detectChanges, detectNestedPresetRefs, detectWorkspaceVersion, evaluateUpgrade, extractLibraryInstanceId, extractReferencedKeys, filterKey, getConfigDefaults, getDefaultValue, getSidecarRoot, getStoreManifestsDir, getStoreRoot, hasInterpolationTokens, installFromManifest, interpolate, isLocalCatalogUrl, isSecretPlaceholder, knowledgeKindProvider, listSidecarSlugsOnDisk, loadLockFile, loadWorkspaceV2, migrateSidecarsToStoreIfNeeded, migrateWorkspaceConfig, parsePreset, parsePresetYaml, parseWorkspaceV2, projectConfigPath, queryInstancePickerChoices, resolveAllItems, resolveConfig, resolveIndexPath, resolveItem, resolveLibraryDir, resolvePin, resolveSidecarPaths, saveConfig, saveLockFile, saveWorkspaceV2, sha256Hex, skaileHomeDir, storeSecrets, trpcGetUrl, userConfigPath, validateAllPlaceholders, validateKnowledge, validateNestingDepth, validatePlaceholder, writeManifestIfMissing };
3514
+ //# sourceMappingURL=chunk-2NIOMFSQ.js.map
3515
+ //# sourceMappingURL=chunk-2NIOMFSQ.js.map