@mean-weasel/lineage 0.1.8 → 0.1.9

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.9
4
+
5
+ - Add runtime identity diagnostics in Settings so operators can see the active channel, version, Git SHA when available, SQLite path, and database counts.
6
+ - Add `lineage db info` for CLI and agent checks before touching a local Lineage database.
7
+ - Document the stable, preview, and dev channel data policy, keeping explicit database overrides available with `--db` and `LINEAGE_DB`.
8
+ - Add browser coverage to ensure Settings keeps surfacing the active runtime and SQLite identity.
9
+
3
10
  ## 0.1.8
4
11
 
5
12
  - 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}=`;
@@ -3644,7 +3712,7 @@ function resolveStartOptions(config, args) {
3644
3712
  throw new Error(`Invalid port: ${rawPort}`);
3645
3713
  }
3646
3714
  return {
3647
- dbPath: readOption(args, "--db") || process.env.LINEAGE_DB || join6(runtimeDir, `${config.binName}.sqlite`),
3715
+ dbPath: readOption(args, "--db") || process.env.LINEAGE_DB || join7(runtimeDir, `${config.binName}.sqlite`),
3648
3716
  host: readOption(args, "--host") || process.env.HOST || config.defaultHost,
3649
3717
  json: args.includes("--json"),
3650
3718
  open: args.includes("--open"),
@@ -3674,6 +3742,7 @@ Usage:
3674
3742
  ${config.binName} tasks cancel --task <task-id> [--confirm-write] [--override] [--project <project>] [--db <path>] [--json]
3675
3743
  ${config.binName} tasks override --task <task-id> --reason <text> [--instructions <text>] [--project <project>] [--db <path>] [--json]
3676
3744
  ${config.binName} tasks instructions --task <task-id> --instructions <text> [--project <project>] [--db <path>] [--json]
3745
+ ${config.binName} db info [--db <path>] [--json]
3677
3746
  ${config.binName} agent claim --project <project> --scope <scope> --target <target-id> --agent-name <name> [--channel <channel>] [--ttl 20m] [--json]
3678
3747
  ${config.binName} agent graph --root <asset-id> [--project <project>] [--db <path>] [--json]
3679
3748
  ${config.binName} agent status [--project <project>] [--json]
@@ -3958,6 +4027,34 @@ function printDataResult(command, result, json) {
3958
4027
  }
3959
4028
  console.log(String(result));
3960
4029
  }
4030
+ function runLineageDbCommand(config, command, args) {
4031
+ const dbPath = readOption(args, "--db");
4032
+ if (dbPath) process.env.LINEAGE_DB = dbPath;
4033
+ if (command === "info") return getLineageRuntimeInfo({ channel: config.channel, dbPath });
4034
+ throw new Error(`Unknown db command: ${command}`);
4035
+ }
4036
+ function printDbResult(command, result, json) {
4037
+ if (json) {
4038
+ console.log(JSON.stringify(result, null, 2));
4039
+ return;
4040
+ }
4041
+ if (command === "info" && result && typeof result === "object" && "database" in result) {
4042
+ const runtime = result;
4043
+ console.log(`Channel: ${runtime.channel}`);
4044
+ console.log(`Version: ${runtime.version}`);
4045
+ if (runtime.git_sha) console.log(`Git: ${runtime.git_sha}`);
4046
+ if (runtime.node_env) console.log(`Node env: ${runtime.node_env}`);
4047
+ console.log(`SQLite: ${runtime.database.path}`);
4048
+ console.log(`Exists: ${runtime.database.exists ? "yes" : "no"}`);
4049
+ if (runtime.database.size_bytes !== void 0) console.log(`Size: ${runtime.database.size_bytes} bytes`);
4050
+ if (runtime.database.modified_at) console.log(`Modified: ${runtime.database.modified_at}`);
4051
+ if (runtime.database.projects !== void 0) console.log(`Projects: ${runtime.database.projects}`);
4052
+ if (runtime.database.workspaces !== void 0) console.log(`Workspaces: ${runtime.database.workspaces}`);
4053
+ if (runtime.database.error) console.log(`Warning: ${runtime.database.error}`);
4054
+ return;
4055
+ }
4056
+ console.log(String(result));
4057
+ }
3961
4058
  function runLineageAgentCommand(command, args) {
3962
4059
  const dbPath = readOption(args, "--db");
3963
4060
  if (dbPath) process.env.LINEAGE_DB = dbPath;
@@ -4084,8 +4181,8 @@ function start(config, args) {
4084
4181
  else console.error(`${config.binName}: ${message}`);
4085
4182
  process.exit(1);
4086
4183
  }
4087
- const serverPath = join6(packageRoot(), "dist", "server.js");
4088
- if (!existsSync6(serverPath)) {
4184
+ const serverPath = join7(packageRoot(), "dist", "server.js");
4185
+ if (!existsSync7(serverPath)) {
4089
4186
  const message = `Missing bundled server at ${serverPath}. Run npm run build before using ${config.binName} start from a source checkout.`;
4090
4187
  if (options.json) console.error(JSON.stringify({ ok: false, error: message }, null, 2));
4091
4188
  else console.error(`${config.binName}: ${message}`);
@@ -4154,6 +4251,20 @@ function runLineageCli(config, args = process.argv.slice(2)) {
4154
4251
  }
4155
4252
  process.exit(0);
4156
4253
  }
4254
+ if (command === "db") {
4255
+ const commandArgs = normalizedArgs.slice(2);
4256
+ const dbCommand = normalizedArgs[1] || "";
4257
+ const json2 = commandArgs.includes("--json");
4258
+ try {
4259
+ printDbResult(dbCommand, runLineageDbCommand(config, dbCommand, commandArgs), json2);
4260
+ } catch (error) {
4261
+ const message2 = error instanceof Error ? error.message : String(error);
4262
+ if (json2) console.error(JSON.stringify({ ok: false, command: `db ${dbCommand}`, error: message2 }, null, 2));
4263
+ else console.error(`${config.binName}: ${message2}`);
4264
+ process.exit(1);
4265
+ }
4266
+ process.exit(0);
4267
+ }
4157
4268
  if (command === "agent") {
4158
4269
  const commandArgs = normalizedArgs.slice(2);
4159
4270
  const agentCommand = normalizedArgs[1] || "";
@@ -4180,5 +4291,5 @@ function runLineageCli(config, args = process.argv.slice(2)) {
4180
4291
  }
4181
4292
 
4182
4293
  // src/cli/lineage-dev.ts
4183
- runLineageCli({ binName: "lineage-dev", channel: "development", defaultHost: "lineage-dev.localhost", defaultPort: 5198, displayName: "Lineage Dev" });
4294
+ runLineageCli({ binName: "lineage-dev", channel: "dev", defaultHost: "lineage-dev.localhost", defaultPort: 5198, displayName: "Lineage Dev" });
4184
4295
  //# sourceMappingURL=lineage-dev.js.map