@mean-weasel/lineage 0.1.18 → 0.1.20

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.
@@ -1,9 +1,9 @@
1
1
  {
2
- "build_fingerprint": "06b247a5facc91f5229fcc17b7ae8bb22a2d3e663f4fd1520bb50152254669fe",
2
+ "build_fingerprint": "de1fd2e2ce5b6d3ac17b832c06fe62e8780bf94bdc5d5d07221dde3392452510",
3
3
  "package_name": "@mean-weasel/lineage",
4
- "package_version": "0.1.18",
4
+ "package_version": "0.1.20",
5
5
  "schema_version": "lineage.runtime_build.v1",
6
6
  "source_dirty": false,
7
- "source_fingerprint": "f57dfbc56b806bf349bab7a5a4431c014e76cdb04321e610178a8b85707679b0",
8
- "source_git_sha": "7b7a0ba3166359522a78bf918bf3e88e471bf933"
7
+ "source_fingerprint": "c7f120476e5880d644e3da2ac1b46ff26964935e9dcca490a79b461d4726cae5",
8
+ "source_git_sha": "9b3e36ba2e2752b4f9dd414ffdade8dd946b69b4"
9
9
  }
package/dist/server.js CHANGED
@@ -282,7 +282,6 @@ function createS3StorageAdapter(deps) {
282
282
  }
283
283
 
284
284
  // src/server/assetLineageDb.ts
285
- import { createRequire as createRequire2 } from "node:module";
286
285
  import { existsSync as existsSync5, mkdirSync as mkdirSync4 } from "node:fs";
287
286
  import { join as join5 } from "node:path";
288
287
 
@@ -293,7 +292,6 @@ import { dirname as dirname3, join as join4, resolve as resolve3 } from "node:pa
293
292
 
294
293
  // src/server/lineageProfiles.ts
295
294
  import { createHash as createHash2, randomUUID } from "node:crypto";
296
- import { createRequire } from "node:module";
297
295
  import {
298
296
  chmodSync,
299
297
  closeSync,
@@ -319,8 +317,26 @@ import { dirname as dirname2, isAbsolute, join as join3, relative as relative2,
319
317
  var lineageProfileSchemaVersion = "lineage.profile.v1";
320
318
  var lineageProfileDoctorSchemaVersion = "lineage.profile_doctor.v1";
321
319
 
322
- // src/server/lineageProfiles.ts
320
+ // src/server/nodeSqlite.ts
321
+ import { createRequire } from "node:module";
323
322
  var require2 = createRequire(import.meta.url);
323
+ var sqliteExperimentalWarning = "SQLite is an experimental feature and might change at any time";
324
+ function loadNodeSqlite() {
325
+ const emitWarning = process.emitWarning;
326
+ process.emitWarning = ((warning, ...args) => {
327
+ const message = warning instanceof Error ? warning.message : warning;
328
+ const type = typeof args[0] === "string" ? args[0] : warning instanceof Error ? warning.name : void 0;
329
+ if (message === sqliteExperimentalWarning && type === "ExperimentalWarning") return;
330
+ return Reflect.apply(emitWarning, process, [warning, ...args]);
331
+ });
332
+ try {
333
+ return require2("node:sqlite");
334
+ } finally {
335
+ process.emitWarning = emitWarning;
336
+ }
337
+ }
338
+
339
+ // src/server/lineageProfiles.ts
324
340
  var profileIdPattern = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
325
341
  function lineageDataRoot() {
326
342
  if (process.env.LINEAGE_HOME) return resolve2(process.env.LINEAGE_HOME);
@@ -499,7 +515,7 @@ function inspectDatabase(profile) {
499
515
  };
500
516
  if (!result.exists) return result;
501
517
  try {
502
- const { DatabaseSync } = require2("node:sqlite");
518
+ const { DatabaseSync } = loadNodeSqlite();
503
519
  const database = new DatabaseSync(profile.database_path, { readOnly: true });
504
520
  try {
505
521
  if (tableExists(database, "lineage_profile_identity")) {
@@ -857,7 +873,6 @@ function assertSelectedProfileDatabaseIdentity(database) {
857
873
  }
858
874
 
859
875
  // src/server/assetLineageDb.ts
860
- var require3 = createRequire2(import.meta.url);
861
876
  function nowIso() {
862
877
  return (/* @__PURE__ */ new Date()).toISOString();
863
878
  }
@@ -871,7 +886,7 @@ function lineageDb() {
871
886
  throw new Error(`Refusing writable open of missing profile database ${lineageDbPath()}; bind an existing database or create a non-production clone first`);
872
887
  }
873
888
  if (!readOnly) mkdirSync4(join5(lineageDbPath(), ".."), { recursive: true });
874
- const { DatabaseSync } = require3("node:sqlite");
889
+ const { DatabaseSync } = loadNodeSqlite();
875
890
  const database = readOnly ? new DatabaseSync(lineageDbPath(), { readOnly: true }) : new DatabaseSync(lineageDbPath());
876
891
  if (process.env.LINEAGE_PROFILE) assertSelectedProfileDatabaseIdentity(database);
877
892
  database.exec("PRAGMA foreign_keys = ON");
@@ -4504,32 +4519,38 @@ function updateAssetReview(project, fields) {
4504
4519
 
4505
4520
  // src/server/lineageRuntimeCommand.ts
4506
4521
  import { existsSync as existsSync7 } from "node:fs";
4507
- import { createRequire as createRequire3 } from "node:module";
4522
+ import { createRequire as createRequire2 } from "node:module";
4508
4523
  import { join as join8 } from "node:path";
4509
- var require4 = createRequire3(import.meta.url);
4510
- function lineagePublicPackageCommand() {
4511
- if (process.env.LINEAGE_CHANNEL === "dev") {
4524
+ var require3 = createRequire2(import.meta.url);
4525
+ function lineageCliLauncher(channel = process.env.LINEAGE_CHANNEL) {
4526
+ if (channel === "dev") {
4512
4527
  const sourceCli = join8(packageRoot, "src", "cli", "lineage-dev.ts");
4513
4528
  const builtCli = join8(packageRoot, "dist", "cli", "lineage-dev.js");
4514
- return existsSync7(sourceCli) ? `${shellQuote(process.execPath)} --import ${shellQuote(require4.resolve("tsx"))} ${shellQuote(sourceCli)}` : `${shellQuote(process.execPath)} ${shellQuote(builtCli)}`;
4529
+ return existsSync7(sourceCli) ? `${shellQuote(process.execPath)} --import ${shellQuote(require3.resolve("tsx"))} ${shellQuote(sourceCli)}` : `${shellQuote(process.execPath)} ${shellQuote(builtCli)}`;
4515
4530
  }
4516
- if (process.env.LINEAGE_CHANNEL === "preview") return "LINEAGE_CHANNEL=preview npx --package @mean-weasel/lineage@next lineage-dev";
4517
- return "npx @mean-weasel/lineage";
4531
+ if (channel === "preview") return "lineage-preview";
4532
+ if (channel === "stable") return "lineage-stable";
4533
+ throw new Error("LINEAGE_CHANNEL must be stable, preview, or dev before generating a Lineage command");
4518
4534
  }
4519
4535
  function shellQuote(value) {
4520
4536
  return `'${value.replace(/'/g, "'\\''")}'`;
4521
4537
  }
4522
- function lineageRuntimeSelector() {
4538
+ function lineageRuntimeSelector(databasePath) {
4523
4539
  const manifest = process.env.LINEAGE_PROFILE_MANIFEST?.trim();
4524
- return manifest ? `--profile ${shellQuote(manifest)}` : `--db ${shellQuote(lineageDbPath())}`;
4540
+ const database = databasePath || process.env.LINEAGE_DB || join8(packageRoot, ".lineage", "asset-lineage.sqlite");
4541
+ return manifest ? `--profile ${shellQuote(manifest)}` : `--db ${shellQuote(database)}`;
4542
+ }
4543
+ function lineageCliCommand(command) {
4544
+ const normalized = command.trim().replace(/\s+--json$/, "");
4545
+ return `${lineageCliLauncher()} ${normalized} ${lineageRuntimeSelector()} --json`;
4525
4546
  }
4526
4547
 
4527
4548
  // src/server/assetLineageHandoff.ts
4528
4549
  function lineageCommand(command, project, rootAssetId) {
4529
- return `${lineagePublicPackageCommand()} ${command} --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} ${lineageRuntimeSelector()} --json`;
4550
+ return lineageCliCommand(`${command} --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)}`);
4530
4551
  }
4531
4552
  function linkChildCommand(project, rootAssetId) {
4532
- return `${lineagePublicPackageCommand()} link-child --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} --child <asset-id> --summary "<one-or-two-words>" --confirm-write ${lineageRuntimeSelector()} --json`;
4553
+ return lineageCliCommand(`link-child --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} --child <asset-id> --summary "<one-or-two-words>" --confirm-write`);
4533
4554
  }
4534
4555
  function rerollImportGuidance(rootAssetId, targetAssetId) {
4535
4556
  return `Use lineage reroll plan --root ${rootAssetId} --target ${targetAssetId} and lineage reroll import instead.`;
@@ -4571,7 +4592,7 @@ function getLineageBrief(project, rootAssetId) {
4571
4592
  },
4572
4593
  handoff: {
4573
4594
  next_command: lineageCommand("next", project, next.root_asset_id),
4574
- inspect_command: asset ? `${lineagePublicPackageCommand()} inspect --project ${shellQuote(project)} --asset-id ${shellQuote(asset.asset_id)} ${lineageRuntimeSelector()} --json` : void 0,
4595
+ inspect_command: asset ? lineageCliCommand(`inspect --project ${shellQuote(project)} --asset-id ${shellQuote(asset.asset_id)}`) : void 0,
4575
4596
  link_child_command: asset ? linkChildCommand(project, next.root_asset_id) : void 0
4576
4597
  },
4577
4598
  fetchedAt: nowIso()
@@ -5379,13 +5400,13 @@ function laneFor(channel, localAssets2, catalogAssets, limit) {
5379
5400
  };
5380
5401
  }
5381
5402
  function handoff(project) {
5382
- const prefix = `npx @mean-weasel/lineage`;
5403
+ const quotedProject = shellQuote(project);
5383
5404
  return {
5384
- backupTemplate: `${prefix} local backup --project ${project} --asset-id <local-id> --dry-run --json`,
5385
- lineageNextTemplate: `${prefix} lineage next --project ${project} --root <root-id> --json`,
5386
- localListCommand: `${prefix} local list --project ${project} --json`,
5387
- queueCommand: `${prefix} review queue --project ${project} --json`,
5388
- scheduleTemplate: `${prefix} placement mark-scheduled --project ${project} --asset-id <asset-id> --channel <channel> --scheduled-at <iso> --dry-run --json`
5405
+ backupTemplate: lineageCliCommand(`local backup --project ${quotedProject} --asset-id <local-id> --dry-run`),
5406
+ lineageNextTemplate: lineageCliCommand(`lineage next --project ${quotedProject} --root <root-id>`),
5407
+ localListCommand: lineageCliCommand(`local list --project ${quotedProject}`),
5408
+ queueCommand: lineageCliCommand(`review queue --project ${quotedProject}`),
5409
+ scheduleTemplate: lineageCliCommand(`placement mark-scheduled --project ${quotedProject} --asset-id <asset-id> --channel <channel> --scheduled-at <iso> --dry-run`)
5389
5410
  };
5390
5411
  }
5391
5412
  function getReviewQueue(project = defaultProject, options = {}) {
@@ -6197,19 +6218,19 @@ function readinessForPost(post) {
6197
6218
  return post.assets.length === 0 ? "needs_asset" : "draft_ready";
6198
6219
  }
6199
6220
  function contentPostHandoff(project, post) {
6200
- const prefix = "npx lineage content";
6201
- const postId = post?.id || "<post-id>";
6202
- const batchId = post?.batch_id;
6221
+ const quotedProject = shellQuote(project);
6222
+ const postId = post ? shellQuote(post.id) : "<post-id>";
6223
+ const batchId = post?.batch_id ? shellQuote(post.batch_id) : void 0;
6203
6224
  return {
6204
6225
  agentPrompt: post ? `Continue content iterations for ${post.title} (${post.id}) on ${post.channel}. Inspect the target, generate or choose assets, attach approved candidates, then move the post through review before scheduling.` : "Inspect or set a content target before generating content or asset variations.",
6205
- attachAssetTemplate: `${prefix} post attach-asset --project ${project} --post-id ${postId} --asset-id <asset-id> --role primary --confirm-write --json`,
6206
- clearTargetCommand: `${prefix} target clear --project ${project} --confirm-write --json`,
6207
- ...batchId ? { inspectBatchCommand: `${prefix} batch inspect --project ${project} --batch-id ${batchId} --json` } : {},
6208
- inspectTargetCommand: `${prefix} target inspect --project ${project} --json`,
6209
- markPostedTemplate: `${prefix} post phase --project ${project} --post-id ${postId} --phase posted --posted-at <iso> --url <url> --confirm-write --json`,
6210
- moveToReviewCommand: `${prefix} post phase --project ${project} --post-id ${postId} --phase review --confirm-write --json`,
6211
- scheduleTemplate: `${prefix} post phase --project ${project} --post-id ${postId} --phase scheduled --scheduled-at <iso> --confirm-write --json`,
6212
- setTargetTemplate: `${prefix} target set --project ${project} --post-id ${postId} --notes <notes> --confirm-write --json`
6226
+ attachAssetTemplate: lineageCliCommand(`content post attach-asset --project ${quotedProject} --post-id ${postId} --asset-id <asset-id> --role primary --confirm-write`),
6227
+ clearTargetCommand: lineageCliCommand(`content target clear --project ${quotedProject} --confirm-write`),
6228
+ ...batchId ? { inspectBatchCommand: lineageCliCommand(`content batch inspect --project ${quotedProject} --batch-id ${batchId}`) } : {},
6229
+ inspectTargetCommand: lineageCliCommand(`content target inspect --project ${quotedProject}`),
6230
+ markPostedTemplate: lineageCliCommand(`content post phase --project ${quotedProject} --post-id ${postId} --phase posted --posted-at <iso> --url <url> --confirm-write`),
6231
+ moveToReviewCommand: lineageCliCommand(`content post phase --project ${quotedProject} --post-id ${postId} --phase review --confirm-write`),
6232
+ scheduleTemplate: lineageCliCommand(`content post phase --project ${quotedProject} --post-id ${postId} --phase scheduled --scheduled-at <iso> --confirm-write`),
6233
+ setTargetTemplate: lineageCliCommand(`content target set --project ${quotedProject} --post-id ${postId} --notes <notes> --confirm-write`)
6213
6234
  };
6214
6235
  }
6215
6236
 
@@ -6309,12 +6330,13 @@ function phaseCounts(posts) {
6309
6330
  return Object.fromEntries([...phases].map((phase) => [phase, posts.filter((post) => post.phase === phase).length]));
6310
6331
  }
6311
6332
  function handoff2(project, batchId) {
6312
- const prefix = `npx lineage content`;
6333
+ const quotedProject = shellQuote(project);
6334
+ const quotedBatch = shellQuote(batchId);
6313
6335
  return {
6314
- inspectCommand: `${prefix} batch inspect --project ${project} --batch-id ${batchId} --json`,
6315
- createPostTemplate: `${prefix} post create --project ${project} --batch-id ${batchId} --post-id <post-id> --channel <channel> --title <title> --confirm-write --json`,
6316
- attachAssetTemplate: `${prefix} post attach-asset --project ${project} --post-id <post-id> --asset-id <asset-id> --role primary --confirm-write --json`,
6317
- phaseTemplate: `${prefix} post phase --project ${project} --post-id <post-id> --phase scheduled --scheduled-at <iso> --confirm-write --json`
6336
+ inspectCommand: lineageCliCommand(`content batch inspect --project ${quotedProject} --batch-id ${quotedBatch}`),
6337
+ createPostTemplate: lineageCliCommand(`content post create --project ${quotedProject} --batch-id ${quotedBatch} --post-id <post-id> --channel <channel> --title <title> --confirm-write`),
6338
+ attachAssetTemplate: lineageCliCommand(`content post attach-asset --project ${quotedProject} --post-id <post-id> --asset-id <asset-id> --role primary --confirm-write`),
6339
+ phaseTemplate: lineageCliCommand(`content post phase --project ${quotedProject} --post-id <post-id> --phase scheduled --scheduled-at <iso> --confirm-write`)
6318
6340
  };
6319
6341
  }
6320
6342
  function listContentBatches(project) {
@@ -6991,10 +7013,10 @@ function backupCueForPost(project, post, sources) {
6991
7013
  approved_local: approvedLocal,
6992
7014
  label,
6993
7015
  local_and_s3: localAndS3,
6994
- local_backup_command: firstLocalOnly ? `npx lineage local backup --project ${project} --asset-id ${firstLocalOnly} --dry-run --json` : void 0,
7016
+ local_backup_command: firstLocalOnly ? lineageCliCommand(`local backup --project ${shellQuote(project)} --asset-id ${shellQuote(firstLocalOnly)} --dry-run`) : void 0,
6995
7017
  local_only: localOnly,
6996
- local_queue_command: firstLocalOnly ? `npx lineage local queue --project ${project} --json` : void 0,
6997
- local_review_command: firstLocalOnly ? `npx lineage local review --project ${project} --asset-id ${firstLocalOnly} --state approved --dry-run --json` : void 0,
7018
+ local_queue_command: firstLocalOnly ? lineageCliCommand(`local queue --project ${shellQuote(project)}`) : void 0,
7019
+ local_review_command: firstLocalOnly ? lineageCliCommand(`local review --project ${shellQuote(project)} --asset-id ${shellQuote(firstLocalOnly)} --state approved --dry-run`) : void 0,
6998
7020
  needs_review: needsReview,
6999
7021
  s3_backed: s3Backed,
7000
7022
  unresolved
@@ -7040,13 +7062,13 @@ function getContentOpsQueue(project) {
7040
7062
  const nextAction = firstLaneItem(queueLanes, actionableLaneOrder);
7041
7063
  const storage = items.reduce((total, item) => addStorage(total, item.asset_storage), emptyStorage());
7042
7064
  const laneTotals = Object.fromEntries(queueLanes.map((lane) => [lane.id, lane.total]));
7043
- const contentPrefix = `npx lineage content`;
7065
+ const quotedProject = shellQuote(project);
7044
7066
  return {
7045
7067
  fetchedAt: nowIso(),
7046
7068
  handoff: {
7047
- inspectQueueCommand: `${contentPrefix} queue inspect --project ${project} --json`,
7048
- inspectTargetCommand: `${contentPrefix} target inspect --project ${project} --json`,
7049
- listPostsCommand: `${contentPrefix} post list --project ${project} --json`
7069
+ inspectQueueCommand: lineageCliCommand(`content queue inspect --project ${quotedProject}`),
7070
+ inspectTargetCommand: lineageCliCommand(`content target inspect --project ${quotedProject}`),
7071
+ listPostsCommand: lineageCliCommand(`content post list --project ${quotedProject}`)
7050
7072
  },
7051
7073
  lanes: queueLanes,
7052
7074
  next_action: nextAction?.item || null,
@@ -7377,7 +7399,7 @@ function buildHandoff(project, id, prompt, count, perBaseCount, next, inputs) {
7377
7399
  if (!parent) throw new GenerationReceiptError("Missing lineage next base");
7378
7400
  const parents = parentMappings(next, perBaseCount);
7379
7401
  const outputManifest = createGenerationOutputManifestDraft({ id, expected_output_count: count, inputs });
7380
- 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`;
7402
+ const importCommand = lineageCliCommand(`generate image import --project ${quote(project)} --job-id ${quote(id)} --manifest ${quote(".asset-scratch/generation-output-manifest.json")} --confirm-write`);
7381
7403
  return {
7382
7404
  schema_version: "lineage.generation_handoff.v2",
7383
7405
  provider,
@@ -7414,7 +7436,7 @@ function buildHandoff(project, id, prompt, count, perBaseCount, next, inputs) {
7414
7436
  };
7415
7437
  }
7416
7438
  function buildRerollHandoff(project, id, prompt, rootAssetId, target, request) {
7417
- const importCommand = `${lineagePublicPackageCommand()} reroll import --project ${quote(project)} --job-id ${quote(id)} --file <.asset-scratch-file> --confirm-write ${lineageRuntimeSelector()} --json`;
7439
+ const importCommand = lineageCliCommand(`reroll import --project ${quote(project)} --job-id ${quote(id)} --file <.asset-scratch-file> --confirm-write`);
7418
7440
  return {
7419
7441
  schema_version: "lineage.generation_handoff.v1",
7420
7442
  provider,
@@ -8864,7 +8886,6 @@ function registerLineageWorkspaceRoutes(app2, projectFrom2, asyncRoute2) {
8864
8886
  // src/server/runtimeInfo.ts
8865
8887
  import { createHash as createHash6 } from "node:crypto";
8866
8888
  import { spawnSync as spawnSync2 } from "node:child_process";
8867
- import { createRequire as createRequire4 } from "node:module";
8868
8889
  import { existsSync as existsSync11, lstatSync as lstatSync3, readFileSync as readFileSync7, readdirSync as readdirSync4, readlinkSync, realpathSync as realpathSync3, statSync as statSync5 } from "node:fs";
8869
8890
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join12, resolve as resolve6 } from "node:path";
8870
8891
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -8874,7 +8895,6 @@ var lineageRuntimeBuildSchemaVersion = "lineage.runtime_build.v1";
8874
8895
  var lineageRuntimeInstallSchemaVersion = "lineage.runtime_install.v1";
8875
8896
 
8876
8897
  // src/server/runtimeInfo.ts
8877
- var require5 = createRequire4(import.meta.url);
8878
8898
  var processStartedAt = (/* @__PURE__ */ new Date()).toISOString();
8879
8899
  function isLineagePackageRoot(root) {
8880
8900
  try {
@@ -9138,7 +9158,7 @@ function getLineageRuntimeInfo(options = {}) {
9138
9158
  const stat = statSync5(dbPath);
9139
9159
  databaseInfo.modified_at = stat.mtime.toISOString();
9140
9160
  databaseInfo.size_bytes = stat.size;
9141
- const { DatabaseSync } = require5("node:sqlite");
9161
+ const { DatabaseSync } = loadNodeSqlite();
9142
9162
  const database = new DatabaseSync(dbPath, { readOnly: true });
9143
9163
  try {
9144
9164
  databaseInfo.projects = tableCount(database, "projects");
@@ -9164,6 +9184,10 @@ function getLineageRuntimeInfo(options = {}) {
9164
9184
  return {
9165
9185
  asset_root: repoRoot,
9166
9186
  channel,
9187
+ cli: {
9188
+ launcher: lineageCliLauncher(channel),
9189
+ runtime_selector: lineageRuntimeSelector(dbPath)
9190
+ },
9167
9191
  code,
9168
9192
  database: databaseInfo,
9169
9193
  fetchedAt: nowIso(),