@mean-weasel/lineage 0.1.18 → 0.1.21-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,6 @@ function requireEdgeSummary(value) {
38
38
  import { createHash as createHash4, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
39
39
 
40
40
  // src/server/assetLineageDb.ts
41
- import { createRequire as createRequire2 } from "node:module";
42
41
  import { existsSync as existsSync6, mkdirSync as mkdirSync5 } from "node:fs";
43
42
  import { join as join6 } from "node:path";
44
43
 
@@ -621,7 +620,6 @@ import { dirname as dirname4, join as join5, resolve as resolve4 } from "node:pa
621
620
 
622
621
  // src/server/lineageProfiles.ts
623
622
  import { createHash as createHash2, randomUUID } from "node:crypto";
624
- import { createRequire } from "node:module";
625
623
  import {
626
624
  chmodSync as chmodSync2,
627
625
  closeSync,
@@ -651,8 +649,26 @@ var lineageProfileCloneReceiptSchemaVersion = "lineage.profile_clone_receipt.v1"
651
649
  var lineageProfileAssetsCloneReceiptSchemaVersion = "lineage.profile_assets_clone_receipt.v1";
652
650
  var lineageProfileRuntimeRepinReceiptSchemaVersion = "lineage.profile_runtime_repin_receipt.v1";
653
651
 
654
- // src/server/lineageProfiles.ts
652
+ // src/server/nodeSqlite.ts
653
+ import { createRequire } from "node:module";
655
654
  var require2 = createRequire(import.meta.url);
655
+ var sqliteExperimentalWarning = "SQLite is an experimental feature and might change at any time";
656
+ function loadNodeSqlite() {
657
+ const emitWarning = process.emitWarning;
658
+ process.emitWarning = ((warning, ...args) => {
659
+ const message = warning instanceof Error ? warning.message : warning;
660
+ const type = typeof args[0] === "string" ? args[0] : warning instanceof Error ? warning.name : void 0;
661
+ if (message === sqliteExperimentalWarning && type === "ExperimentalWarning") return;
662
+ return Reflect.apply(emitWarning, process, [warning, ...args]);
663
+ });
664
+ try {
665
+ return require2("node:sqlite");
666
+ } finally {
667
+ process.emitWarning = emitWarning;
668
+ }
669
+ }
670
+
671
+ // src/server/lineageProfiles.ts
656
672
  var profileIdPattern = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
657
673
  function lineageDataRoot() {
658
674
  if (process.env.LINEAGE_HOME) return resolve3(process.env.LINEAGE_HOME);
@@ -850,7 +866,7 @@ function initializeLineageProfile(profileId, serviceOrigin, runtime, confirmWrit
850
866
  mkdirSync3(assetRoot, { mode: 448 });
851
867
  const databaseFd = openSync(databasePath, fsConstants.O_CREAT | fsConstants.O_EXCL | fsConstants.O_RDWR, 384);
852
868
  closeSync(databaseFd);
853
- const { DatabaseSync } = require2("node:sqlite");
869
+ const { DatabaseSync } = loadNodeSqlite();
854
870
  const database = new DatabaseSync(databasePath);
855
871
  let boundIdentity;
856
872
  try {
@@ -1068,7 +1084,7 @@ function inspectDatabase(profile) {
1068
1084
  };
1069
1085
  if (!result.exists) return result;
1070
1086
  try {
1071
- const { DatabaseSync } = require2("node:sqlite");
1087
+ const { DatabaseSync } = loadNodeSqlite();
1072
1088
  const database = new DatabaseSync(profile.database_path, { readOnly: true });
1073
1089
  try {
1074
1090
  if (tableExists(database, "lineage_profile_identity")) {
@@ -1287,7 +1303,7 @@ function bindLineageProfileDatabase(selector, runtime, confirmWrite) {
1287
1303
  assertProfileChannel(profile, runtime.channel);
1288
1304
  assertProfileRuntimePin(profile, runtime);
1289
1305
  if (!existsSync4(profile.database_path)) throw new Error(`Profile database does not exist: ${profile.database_path}`);
1290
- const { DatabaseSync } = require2("node:sqlite");
1306
+ const { DatabaseSync } = loadNodeSqlite();
1291
1307
  const database = new DatabaseSync(profile.database_path);
1292
1308
  try {
1293
1309
  const before = inspectDatabase(profile).identity;
@@ -1317,7 +1333,7 @@ async function cloneLineageProfileDatabase(sourceDatabasePath, targetSelector, r
1317
1333
  const temporaryPath = `${targetPath}.clone-${randomUUID()}.tmp`;
1318
1334
  const receiptDirectory = join4(dirname3(profile.manifest_path), "clone-receipts");
1319
1335
  let targetCreated = false;
1320
- const { DatabaseSync, backup } = require2("node:sqlite");
1336
+ const { DatabaseSync, backup } = loadNodeSqlite();
1321
1337
  const source = new DatabaseSync(sourcePath, { readOnly: true });
1322
1338
  try {
1323
1339
  const pagesCopied = await backup(source, temporaryPath);
@@ -1408,7 +1424,7 @@ function cloneLineageProfileAssets(sourceAssetRoot, targetSelector, runtime, con
1408
1424
  if (databaseIdentity && (databaseIdentity.profile_id !== profile.profile_id || databaseIdentity.environment !== profile.environment || databaseIdentity.profile_fingerprint && databaseIdentity.profile_fingerprint !== profile.profile_fingerprint)) {
1409
1425
  throw new Error(`Profile database is already bound to ${databaseIdentity.profile_id}/${databaseIdentity.environment}`);
1410
1426
  }
1411
- const { DatabaseSync } = require2("node:sqlite");
1427
+ const { DatabaseSync } = loadNodeSqlite();
1412
1428
  const database = new DatabaseSync(profile.database_path, { readOnly: true });
1413
1429
  let references;
1414
1430
  try {
@@ -1701,7 +1717,6 @@ function getProfileWriterDelegation(profile) {
1701
1717
  }
1702
1718
 
1703
1719
  // src/server/assetLineageDb.ts
1704
- var require3 = createRequire2(import.meta.url);
1705
1720
  function nowIso() {
1706
1721
  return (/* @__PURE__ */ new Date()).toISOString();
1707
1722
  }
@@ -1715,7 +1730,7 @@ function lineageDb() {
1715
1730
  throw new Error(`Refusing writable open of missing profile database ${lineageDbPath()}; bind an existing database or create a non-production clone first`);
1716
1731
  }
1717
1732
  if (!readOnly) mkdirSync5(join6(lineageDbPath(), ".."), { recursive: true });
1718
- const { DatabaseSync } = require3("node:sqlite");
1733
+ const { DatabaseSync } = loadNodeSqlite();
1719
1734
  const database = readOnly ? new DatabaseSync(lineageDbPath(), { readOnly: true }) : new DatabaseSync(lineageDbPath());
1720
1735
  if (process.env.LINEAGE_PROFILE) assertSelectedProfileDatabaseIdentity(database);
1721
1736
  database.exec("PRAGMA foreign_keys = ON");
@@ -4217,32 +4232,38 @@ function clearLineageRerollRequest(project, fields) {
4217
4232
 
4218
4233
  // src/server/lineageRuntimeCommand.ts
4219
4234
  import { existsSync as existsSync7 } from "node:fs";
4220
- import { createRequire as createRequire3 } from "node:module";
4235
+ import { createRequire as createRequire2 } from "node:module";
4221
4236
  import { join as join8 } from "node:path";
4222
- var require4 = createRequire3(import.meta.url);
4223
- function lineagePublicPackageCommand() {
4224
- if (process.env.LINEAGE_CHANNEL === "dev") {
4237
+ var require3 = createRequire2(import.meta.url);
4238
+ function lineageCliLauncher(channel = process.env.LINEAGE_CHANNEL) {
4239
+ if (channel === "dev") {
4225
4240
  const sourceCli = join8(packageRoot, "src", "cli", "lineage-dev.ts");
4226
4241
  const builtCli = join8(packageRoot, "dist", "cli", "lineage-dev.js");
4227
- return existsSync7(sourceCli) ? `${shellQuote(process.execPath)} --import ${shellQuote(require4.resolve("tsx"))} ${shellQuote(sourceCli)}` : `${shellQuote(process.execPath)} ${shellQuote(builtCli)}`;
4242
+ return existsSync7(sourceCli) ? `${shellQuote(process.execPath)} --import ${shellQuote(require3.resolve("tsx"))} ${shellQuote(sourceCli)}` : `${shellQuote(process.execPath)} ${shellQuote(builtCli)}`;
4228
4243
  }
4229
- if (process.env.LINEAGE_CHANNEL === "preview") return "LINEAGE_CHANNEL=preview npx --package @mean-weasel/lineage@next lineage-dev";
4230
- return "npx @mean-weasel/lineage";
4244
+ if (channel === "preview") return "lineage-preview";
4245
+ if (channel === "stable") return "lineage-stable";
4246
+ throw new Error("LINEAGE_CHANNEL must be stable, preview, or dev before generating a Lineage command");
4231
4247
  }
4232
4248
  function shellQuote(value) {
4233
4249
  return `'${value.replace(/'/g, "'\\''")}'`;
4234
4250
  }
4235
- function lineageRuntimeSelector() {
4251
+ function lineageRuntimeSelector(databasePath) {
4236
4252
  const manifest = process.env.LINEAGE_PROFILE_MANIFEST?.trim();
4237
- return manifest ? `--profile ${shellQuote(manifest)}` : `--db ${shellQuote(lineageDbPath())}`;
4253
+ const database = databasePath || process.env.LINEAGE_DB || join8(packageRoot, ".lineage", "asset-lineage.sqlite");
4254
+ return manifest ? `--profile ${shellQuote(manifest)}` : `--db ${shellQuote(database)}`;
4255
+ }
4256
+ function lineageCliCommand(command) {
4257
+ const normalized = command.trim().replace(/\s+--json$/, "");
4258
+ return `${lineageCliLauncher()} ${normalized} ${lineageRuntimeSelector()} --json`;
4238
4259
  }
4239
4260
 
4240
4261
  // src/server/assetLineageHandoff.ts
4241
4262
  function lineageCommand(command, project, rootAssetId) {
4242
- return `${lineagePublicPackageCommand()} ${command} --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} ${lineageRuntimeSelector()} --json`;
4263
+ return lineageCliCommand(`${command} --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)}`);
4243
4264
  }
4244
4265
  function linkChildCommand(project, rootAssetId) {
4245
- return `${lineagePublicPackageCommand()} link-child --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} --child <asset-id> --summary "<one-or-two-words>" --confirm-write ${lineageRuntimeSelector()} --json`;
4266
+ return lineageCliCommand(`link-child --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} --child <asset-id> --summary "<one-or-two-words>" --confirm-write`);
4246
4267
  }
4247
4268
  function rerollImportGuidance(rootAssetId, targetAssetId) {
4248
4269
  return `Use lineage reroll plan --root ${rootAssetId} --target ${targetAssetId} and lineage reroll import instead.`;
@@ -4284,7 +4305,7 @@ function getLineageBrief(project, rootAssetId) {
4284
4305
  },
4285
4306
  handoff: {
4286
4307
  next_command: lineageCommand("next", project, next.root_asset_id),
4287
- inspect_command: asset ? `${lineagePublicPackageCommand()} inspect --project ${shellQuote(project)} --asset-id ${shellQuote(asset.asset_id)} ${lineageRuntimeSelector()} --json` : void 0,
4308
+ inspect_command: asset ? lineageCliCommand(`inspect --project ${shellQuote(project)} --asset-id ${shellQuote(asset.asset_id)}`) : void 0,
4288
4309
  link_child_command: asset ? linkChildCommand(project, next.root_asset_id) : void 0
4289
4310
  },
4290
4311
  fetchedAt: nowIso()
@@ -4523,7 +4544,7 @@ function buildHandoff(project, id, prompt, count, perBaseCount, next, inputs) {
4523
4544
  if (!parent) throw new GenerationReceiptError("Missing lineage next base");
4524
4545
  const parents = parentMappings(next, perBaseCount);
4525
4546
  const outputManifest = createGenerationOutputManifestDraft({ id, expected_output_count: count, inputs });
4526
- const importCommand = `${lineagePublicPackageCommand()} generate image import --project ${quote(project)} --job-id ${quote(id)} --manifest ${quote(".asset-scratch/generation-output-manifest.json")} --confirm-write ${lineageRuntimeSelector()} --json`;
4547
+ const importCommand = lineageCliCommand(`generate image import --project ${quote(project)} --job-id ${quote(id)} --manifest ${quote(".asset-scratch/generation-output-manifest.json")} --confirm-write`);
4527
4548
  return {
4528
4549
  schema_version: "lineage.generation_handoff.v2",
4529
4550
  provider,
@@ -4560,7 +4581,7 @@ function buildHandoff(project, id, prompt, count, perBaseCount, next, inputs) {
4560
4581
  };
4561
4582
  }
4562
4583
  function buildRerollHandoff(project, id, prompt, rootAssetId, target, request) {
4563
- const importCommand = `${lineagePublicPackageCommand()} reroll import --project ${quote(project)} --job-id ${quote(id)} --file <.asset-scratch-file> --confirm-write ${lineageRuntimeSelector()} --json`;
4584
+ const importCommand = lineageCliCommand(`reroll import --project ${quote(project)} --job-id ${quote(id)} --file <.asset-scratch-file> --confirm-write`);
4564
4585
  return {
4565
4586
  schema_version: "lineage.generation_handoff.v1",
4566
4587
  provider,
@@ -5634,7 +5655,6 @@ function getLineageSelectionPacket(project, options = {}) {
5634
5655
  // src/server/runtimeInfo.ts
5635
5656
  import { createHash as createHash6 } from "node:crypto";
5636
5657
  import { spawnSync as spawnSync2 } from "node:child_process";
5637
- import { createRequire as createRequire4 } from "node:module";
5638
5658
  import { existsSync as existsSync10, lstatSync as lstatSync3, readFileSync as readFileSync5, readdirSync as readdirSync3, readlinkSync, realpathSync as realpathSync3, statSync as statSync6 } from "node:fs";
5639
5659
  import { dirname as dirname5, isAbsolute as isAbsolute3, join as join9, resolve as resolve7 } from "node:path";
5640
5660
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -5644,7 +5664,6 @@ var lineageRuntimeBuildSchemaVersion = "lineage.runtime_build.v1";
5644
5664
  var lineageRuntimeInstallSchemaVersion = "lineage.runtime_install.v1";
5645
5665
 
5646
5666
  // src/server/runtimeInfo.ts
5647
- var require5 = createRequire4(import.meta.url);
5648
5667
  var processStartedAt = (/* @__PURE__ */ new Date()).toISOString();
5649
5668
  function isLineagePackageRoot(root) {
5650
5669
  try {
@@ -5908,7 +5927,7 @@ function getLineageRuntimeInfo(options = {}) {
5908
5927
  const stat = statSync6(dbPath);
5909
5928
  databaseInfo.modified_at = stat.mtime.toISOString();
5910
5929
  databaseInfo.size_bytes = stat.size;
5911
- const { DatabaseSync } = require5("node:sqlite");
5930
+ const { DatabaseSync } = loadNodeSqlite();
5912
5931
  const database = new DatabaseSync(dbPath, { readOnly: true });
5913
5932
  try {
5914
5933
  databaseInfo.projects = tableCount(database, "projects");
@@ -5934,6 +5953,10 @@ function getLineageRuntimeInfo(options = {}) {
5934
5953
  return {
5935
5954
  asset_root: repoRoot,
5936
5955
  channel,
5956
+ cli: {
5957
+ launcher: lineageCliLauncher(channel),
5958
+ runtime_selector: lineageRuntimeSelector(dbPath)
5959
+ },
5937
5960
  code,
5938
5961
  database: databaseInfo,
5939
5962
  fetchedAt: nowIso(),