@mean-weasel/lineage 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.10
4
+
5
+ - Fix `lineage db info` so installed CLI checks use the same stable/dev runtime SQLite defaults as `lineage start`.
6
+
7
+ ## 0.1.9
8
+
9
+ - Add runtime identity diagnostics in Settings so operators can see the active channel, version, Git SHA when available, SQLite path, and database counts.
10
+ - Add `lineage db info` for CLI and agent checks before touching a local Lineage database.
11
+ - Document the stable, preview, and dev channel data policy, keeping explicit database overrides available with `--db` and `LINEAGE_DB`.
12
+ - Add browser coverage to ensure Settings keeps surfacing the active runtime and SQLite identity.
13
+
3
14
  ## 0.1.8
4
15
 
5
16
  - Add durable selection packet export so agents can hand selected Lineage assets to GrowthOps without scraping UI state or copying local paths.
package/README.md CHANGED
@@ -4,19 +4,20 @@ Lineage is a local-first workspace for reviewing creative assets, branching vari
4
4
 
5
5
  ## Package Channels
6
6
 
7
- Lineage is packaged as `@mean-weasel/lineage`. Use `latest` for the stable dogfood or production install, and use `next` when you intentionally want the development or release-candidate channel:
7
+ Lineage is packaged as `@mean-weasel/lineage`. Use `latest` for the stable dogfood or production install, and use `next` when you intentionally want the published preview candidate:
8
8
 
9
9
  ```bash
10
10
  npm install -g @mean-weasel/lineage@latest
11
11
  npm install -g @mean-weasel/lineage@next
12
12
  ```
13
13
 
14
- The stable and development channels are intended to coexist conceptually:
14
+ The stable, preview, and dev channels are intended to coexist conceptually:
15
15
 
16
16
  - `latest` is the version you should trust for day-to-day dogfooding.
17
- - `next` is the version to test before promotion.
17
+ - `next` is the published preview version to test before promotion.
18
+ - `dev` is the local GitHub checkout or branch before publication.
18
19
  - `lineage` runs with stable runtime defaults.
19
- - `lineage-dev` runs with development runtime defaults.
20
+ - `lineage-dev` runs with dev runtime defaults.
20
21
 
21
22
  The package includes both CLI bridge bins for help and version checks:
22
23
 
@@ -40,6 +41,30 @@ By default, `lineage start` listens on `lineage.localhost:5197` and stores SQLit
40
41
  lineage start --port 6123 --db ~/.lineage/lineage.sqlite
41
42
  ```
42
43
 
44
+ ## Runtime Channels and SQLite
45
+
46
+ Lineage treats app code channels and local SQLite data as separate concerns:
47
+
48
+ - `stable` is npm `latest` and is the daily-use channel.
49
+ - `preview` is the published candidate channel, normally npm `next`.
50
+ - `dev` is a GitHub checkout or local branch before publication.
51
+
52
+ Each channel should use its own default runtime directory and SQLite database.
53
+ Do not point preview or dev code at the stable database unless you are doing an
54
+ intentional, explicit test. Prefer copying a stable snapshot forward when a
55
+ realistic preview/dev dataset is needed. `--db` and `LINEAGE_DB` remain the
56
+ escape hatches for intentionally choosing a database.
57
+
58
+ Check the active runtime before making changes:
59
+
60
+ ```bash
61
+ lineage db info --json
62
+ lineage-dev db info --json
63
+ ```
64
+
65
+ The app also shows channel, version, Git SHA when available, and SQLite path in
66
+ Settings.
67
+
43
68
  ## Agent Claims
44
69
 
45
70
  Mutating agent writes use target-scoped claim tokens. Read-only inspection stays
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli/lineageCli.ts
4
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
4
+ import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
5
5
  import { homedir, platform } from "node:os";
6
- import { dirname as dirname3, join as join6, resolve as resolve5 } from "node:path";
6
+ import { dirname as dirname3, join as join7, resolve as resolve5 } from "node:path";
7
7
  import { spawn } from "node:child_process";
8
8
  import { fileURLToPath as fileURLToPath2 } from "node:url";
9
9
 
@@ -283,8 +283,8 @@ function isPackageRoot(path) {
283
283
  const packageJson = join3(path, "package.json");
284
284
  if (!existsSync3(packageJson)) return false;
285
285
  try {
286
- const packageInfo = JSON.parse(readFileSync2(packageJson, "utf8"));
287
- return packageInfo.name === "@mean-weasel/lineage";
286
+ const packageInfo2 = JSON.parse(readFileSync2(packageJson, "utf8"));
287
+ return packageInfo2.name === "@mean-weasel/lineage";
288
288
  } catch {
289
289
  return false;
290
290
  }
@@ -3593,6 +3593,74 @@ function getLineageSelectionPacket(project, options = {}) {
3593
3593
  };
3594
3594
  }
3595
3595
 
3596
+ // src/server/runtimeInfo.ts
3597
+ import { spawnSync as spawnSync2 } from "node:child_process";
3598
+ import { createRequire as createRequire2 } from "node:module";
3599
+ import { existsSync as existsSync6, readFileSync as readFileSync3, statSync as statSync5 } from "node:fs";
3600
+ import { join as join6 } from "node:path";
3601
+ var require3 = createRequire2(import.meta.url);
3602
+ function packageInfo() {
3603
+ try {
3604
+ const info = JSON.parse(readFileSync3(join6(repoRoot, "package.json"), "utf8"));
3605
+ return { name: info.name || "@mean-weasel/lineage", version: info.version || "0.0.0" };
3606
+ } catch {
3607
+ return { name: "@mean-weasel/lineage", version: "0.0.0" };
3608
+ }
3609
+ }
3610
+ function normalizeRuntimeChannel(value) {
3611
+ if (value === "stable" || value === "preview" || value === "dev") return value;
3612
+ if (value === "production") return "stable";
3613
+ if (value === "next") return "preview";
3614
+ if (value === "development") return "dev";
3615
+ return process.env.NODE_ENV === "production" ? "stable" : "dev";
3616
+ }
3617
+ function gitSha() {
3618
+ const envSha = process.env.LINEAGE_GIT_SHA || process.env.GITHUB_SHA;
3619
+ if (envSha) return envSha.slice(0, 40);
3620
+ if (!existsSync6(join6(repoRoot, ".git"))) return void 0;
3621
+ const result = spawnSync2("git", ["rev-parse", "--short=12", "HEAD"], { cwd: repoRoot, encoding: "utf8" });
3622
+ return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
3623
+ }
3624
+ function tableExists(database, table) {
3625
+ return Boolean(database.prepare("select name from sqlite_master where type = 'table' and name = ?").get(table));
3626
+ }
3627
+ function tableCount(database, table) {
3628
+ if (!tableExists(database, table)) return void 0;
3629
+ const row = database.prepare(`select count(*) count from ${table}`).get();
3630
+ return typeof row?.count === "number" ? row.count : void 0;
3631
+ }
3632
+ function getLineageRuntimeInfo(options = {}) {
3633
+ const info = packageInfo();
3634
+ const dbPath = options.dbPath || lineageDbPath();
3635
+ const databaseInfo = { exists: existsSync6(dbPath), path: dbPath };
3636
+ if (databaseInfo.exists) {
3637
+ try {
3638
+ const stat = statSync5(dbPath);
3639
+ databaseInfo.modified_at = stat.mtime.toISOString();
3640
+ databaseInfo.size_bytes = stat.size;
3641
+ const { DatabaseSync } = require3("node:sqlite");
3642
+ const database = new DatabaseSync(dbPath, { readOnly: true });
3643
+ try {
3644
+ databaseInfo.projects = tableCount(database, "projects");
3645
+ databaseInfo.workspaces = tableCount(database, "lineage_workspaces");
3646
+ } finally {
3647
+ database.close();
3648
+ }
3649
+ } catch (error) {
3650
+ databaseInfo.error = error instanceof Error ? error.message : String(error);
3651
+ }
3652
+ }
3653
+ return {
3654
+ channel: normalizeRuntimeChannel(options.channel || process.env.LINEAGE_CHANNEL || process.env.LINEAGE_RELEASE_CHANNEL),
3655
+ database: databaseInfo,
3656
+ fetchedAt: nowIso(),
3657
+ git_sha: gitSha(),
3658
+ node_env: process.env.NODE_ENV,
3659
+ package_name: info.name,
3660
+ version: info.version
3661
+ };
3662
+ }
3663
+
3596
3664
  // src/cli/lineageCli.ts
3597
3665
  var signalExitCodes = {
3598
3666
  SIGINT: 130,
@@ -3603,17 +3671,17 @@ function packageRoot() {
3603
3671
  }
3604
3672
  function packageVersion() {
3605
3673
  try {
3606
- const packageInfo = JSON.parse(readFileSync3(join6(packageRoot(), "package.json"), "utf8"));
3607
- return packageInfo.version || "0.0.0";
3674
+ const packageInfo2 = JSON.parse(readFileSync4(join7(packageRoot(), "package.json"), "utf8"));
3675
+ return packageInfo2.version || "0.0.0";
3608
3676
  } catch {
3609
3677
  return "0.0.0";
3610
3678
  }
3611
3679
  }
3612
3680
  function dataRoot(displayName) {
3613
3681
  if (process.env.LINEAGE_HOME) return process.env.LINEAGE_HOME;
3614
- if (platform() === "darwin") return join6(homedir(), "Library", "Application Support", displayName);
3615
- if (platform() === "win32") return join6(process.env.APPDATA || join6(homedir(), "AppData", "Roaming"), displayName);
3616
- return join6(process.env.XDG_DATA_HOME || join6(homedir(), ".local", "share"), displayName.toLowerCase().replace(/\s+/g, "-"));
3682
+ if (platform() === "darwin") return join7(homedir(), "Library", "Application Support", displayName);
3683
+ if (platform() === "win32") return join7(process.env.APPDATA || join7(homedir(), "AppData", "Roaming"), displayName);
3684
+ return join7(process.env.XDG_DATA_HOME || join7(homedir(), ".local", "share"), displayName.toLowerCase().replace(/\s+/g, "-"));
3617
3685
  }
3618
3686
  function readOption(args, name) {
3619
3687
  const prefix = `${name}=`;
@@ -3637,20 +3705,22 @@ function readOptions(args, name) {
3637
3705
  return values;
3638
3706
  }
3639
3707
  function resolveStartOptions(config, args) {
3640
- const runtimeDir = dataRoot(config.displayName);
3641
3708
  const rawPort = readOption(args, "--port") || process.env.PORT || String(config.defaultPort);
3642
3709
  const port = Number(rawPort);
3643
3710
  if (!Number.isInteger(port) || port < 1 || port > 65535) {
3644
3711
  throw new Error(`Invalid port: ${rawPort}`);
3645
3712
  }
3646
3713
  return {
3647
- dbPath: readOption(args, "--db") || process.env.LINEAGE_DB || join6(runtimeDir, `${config.binName}.sqlite`),
3714
+ dbPath: resolveCliDbPath(config, args),
3648
3715
  host: readOption(args, "--host") || process.env.HOST || config.defaultHost,
3649
3716
  json: args.includes("--json"),
3650
3717
  open: args.includes("--open"),
3651
3718
  port
3652
3719
  };
3653
3720
  }
3721
+ function resolveCliDbPath(config, args) {
3722
+ return readOption(args, "--db") || process.env.LINEAGE_DB || join7(dataRoot(config.displayName), `${config.binName}.sqlite`);
3723
+ }
3654
3724
  function formatLineageHelp(config) {
3655
3725
  return `${config.binName} ${packageVersion()}
3656
3726
 
@@ -3674,6 +3744,7 @@ Usage:
3674
3744
  ${config.binName} tasks cancel --task <task-id> [--confirm-write] [--override] [--project <project>] [--db <path>] [--json]
3675
3745
  ${config.binName} tasks override --task <task-id> --reason <text> [--instructions <text>] [--project <project>] [--db <path>] [--json]
3676
3746
  ${config.binName} tasks instructions --task <task-id> --instructions <text> [--project <project>] [--db <path>] [--json]
3747
+ ${config.binName} db info [--db <path>] [--json]
3677
3748
  ${config.binName} agent claim --project <project> --scope <scope> --target <target-id> --agent-name <name> [--channel <channel>] [--ttl 20m] [--json]
3678
3749
  ${config.binName} agent graph --root <asset-id> [--project <project>] [--db <path>] [--json]
3679
3750
  ${config.binName} agent status [--project <project>] [--json]
@@ -3958,6 +4029,34 @@ function printDataResult(command, result, json) {
3958
4029
  }
3959
4030
  console.log(String(result));
3960
4031
  }
4032
+ function runLineageDbCommand(config, command, args) {
4033
+ const dbPath = resolveCliDbPath(config, args);
4034
+ process.env.LINEAGE_DB = dbPath;
4035
+ if (command === "info") return getLineageRuntimeInfo({ channel: config.channel, dbPath });
4036
+ throw new Error(`Unknown db command: ${command}`);
4037
+ }
4038
+ function printDbResult(command, result, json) {
4039
+ if (json) {
4040
+ console.log(JSON.stringify(result, null, 2));
4041
+ return;
4042
+ }
4043
+ if (command === "info" && result && typeof result === "object" && "database" in result) {
4044
+ const runtime = result;
4045
+ console.log(`Channel: ${runtime.channel}`);
4046
+ console.log(`Version: ${runtime.version}`);
4047
+ if (runtime.git_sha) console.log(`Git: ${runtime.git_sha}`);
4048
+ if (runtime.node_env) console.log(`Node env: ${runtime.node_env}`);
4049
+ console.log(`SQLite: ${runtime.database.path}`);
4050
+ console.log(`Exists: ${runtime.database.exists ? "yes" : "no"}`);
4051
+ if (runtime.database.size_bytes !== void 0) console.log(`Size: ${runtime.database.size_bytes} bytes`);
4052
+ if (runtime.database.modified_at) console.log(`Modified: ${runtime.database.modified_at}`);
4053
+ if (runtime.database.projects !== void 0) console.log(`Projects: ${runtime.database.projects}`);
4054
+ if (runtime.database.workspaces !== void 0) console.log(`Workspaces: ${runtime.database.workspaces}`);
4055
+ if (runtime.database.error) console.log(`Warning: ${runtime.database.error}`);
4056
+ return;
4057
+ }
4058
+ console.log(String(result));
4059
+ }
3961
4060
  function runLineageAgentCommand(command, args) {
3962
4061
  const dbPath = readOption(args, "--db");
3963
4062
  if (dbPath) process.env.LINEAGE_DB = dbPath;
@@ -4084,8 +4183,8 @@ function start(config, args) {
4084
4183
  else console.error(`${config.binName}: ${message}`);
4085
4184
  process.exit(1);
4086
4185
  }
4087
- const serverPath = join6(packageRoot(), "dist", "server.js");
4088
- if (!existsSync6(serverPath)) {
4186
+ const serverPath = join7(packageRoot(), "dist", "server.js");
4187
+ if (!existsSync7(serverPath)) {
4089
4188
  const message = `Missing bundled server at ${serverPath}. Run npm run build before using ${config.binName} start from a source checkout.`;
4090
4189
  if (options.json) console.error(JSON.stringify({ ok: false, error: message }, null, 2));
4091
4190
  else console.error(`${config.binName}: ${message}`);
@@ -4154,6 +4253,20 @@ function runLineageCli(config, args = process.argv.slice(2)) {
4154
4253
  }
4155
4254
  process.exit(0);
4156
4255
  }
4256
+ if (command === "db") {
4257
+ const commandArgs = normalizedArgs.slice(2);
4258
+ const dbCommand = normalizedArgs[1] || "";
4259
+ const json2 = commandArgs.includes("--json");
4260
+ try {
4261
+ printDbResult(dbCommand, runLineageDbCommand(config, dbCommand, commandArgs), json2);
4262
+ } catch (error) {
4263
+ const message2 = error instanceof Error ? error.message : String(error);
4264
+ if (json2) console.error(JSON.stringify({ ok: false, command: `db ${dbCommand}`, error: message2 }, null, 2));
4265
+ else console.error(`${config.binName}: ${message2}`);
4266
+ process.exit(1);
4267
+ }
4268
+ process.exit(0);
4269
+ }
4157
4270
  if (command === "agent") {
4158
4271
  const commandArgs = normalizedArgs.slice(2);
4159
4272
  const agentCommand = normalizedArgs[1] || "";
@@ -4180,5 +4293,5 @@ function runLineageCli(config, args = process.argv.slice(2)) {
4180
4293
  }
4181
4294
 
4182
4295
  // src/cli/lineage-dev.ts
4183
- runLineageCli({ binName: "lineage-dev", channel: "development", defaultHost: "lineage-dev.localhost", defaultPort: 5198, displayName: "Lineage Dev" });
4296
+ runLineageCli({ binName: "lineage-dev", channel: "dev", defaultHost: "lineage-dev.localhost", defaultPort: 5198, displayName: "Lineage Dev" });
4184
4297
  //# sourceMappingURL=lineage-dev.js.map