oleander-cli 0.21.0 → 0.24.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 (2) hide show
  1. package/dist/index.cjs +195 -45
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -17494,7 +17494,7 @@ var require_buffer_list = __commonJS({
17494
17494
  }
17495
17495
  }, {
17496
17496
  key: "join",
17497
- value: function join7(s) {
17497
+ value: function join8(s) {
17498
17498
  if (this.length === 0) return "";
17499
17499
  var p2 = this.head;
17500
17500
  var ret = "" + p2.data;
@@ -45416,7 +45416,117 @@ var import_node_child_process2 = require("child_process");
45416
45416
  var import_fs5 = require("fs");
45417
45417
  var import_node_os4 = require("os");
45418
45418
  var import_path5 = require("path");
45419
+ var import_node_fs4 = require("fs");
45420
+
45421
+ // src/utils/duckdb-runtime.ts
45422
+ var import_node_crypto2 = require("crypto");
45419
45423
  var import_node_fs3 = require("fs");
45424
+ var import_node_path4 = require("path");
45425
+ var import_node_zlib = require("zlib");
45426
+ var DUCKDB_VERSION = "v1.5.3";
45427
+ var OLEANDER_EXTENSION_RELEASE = "v0.3.1";
45428
+ var OLEANDER_EXTENSION_REPOSITORY = `https://oleander-cli-releases.s3.amazonaws.com/duckdb/${OLEANDER_EXTENSION_RELEASE}`;
45429
+ var CLI_JOB_NAMESPACE = "oleander.cli";
45430
+ var DUCKDB_BINARIES = {
45431
+ "darwin-arm64": {
45432
+ asset: "duckdb_cli-osx-arm64.gz",
45433
+ sha256: "fe3dcc3822c72147ca7b5fa56eeedd3b7d30e09cb268f056cf3355289773d8f0",
45434
+ extensionPlatform: "osx_arm64"
45435
+ },
45436
+ "darwin-x64": {
45437
+ asset: "duckdb_cli-osx-amd64.gz",
45438
+ sha256: "e14bbce5356e5398d67155c4147cb7e85288c0308636d6e034215dcd74302ec3",
45439
+ extensionPlatform: "osx_amd64"
45440
+ },
45441
+ "linux-x64": {
45442
+ asset: "duckdb_cli-linux-amd64.gz",
45443
+ sha256: "f05f3b448a9a1bc6e7ac27ff14dfe67bf5761b153c2002723365a456618ef35b",
45444
+ extensionPlatform: "linux_amd64"
45445
+ },
45446
+ "linux-arm64": {
45447
+ asset: "duckdb_cli-linux-arm64.gz",
45448
+ sha256: "65b3135fb25d9a46cb4752c0638dd688819e64cb1c96bc71ffb8cca04083509f",
45449
+ extensionPlatform: "linux_arm64"
45450
+ }
45451
+ };
45452
+ function duckdbPlatform(platform = process.platform, arch = process.arch, glibc = hasGlibc()) {
45453
+ if (platform === "linux" && !glibc) return null;
45454
+ return DUCKDB_BINARIES[`${platform}-${arch}`] ?? null;
45455
+ }
45456
+ function hasGlibc() {
45457
+ const report = process.report?.getReport();
45458
+ return Boolean(report?.header?.glibcVersionRuntime);
45459
+ }
45460
+ function runtimeDir() {
45461
+ return (0, import_node_path4.join)(configDir(), "duckdb", DUCKDB_VERSION);
45462
+ }
45463
+ function extensionDirectory() {
45464
+ return (0, import_node_path4.join)(runtimeDir(), "extensions");
45465
+ }
45466
+ async function ensureDuckdb(target) {
45467
+ const binary = (0, import_node_path4.join)(runtimeDir(), "duckdb");
45468
+ if ((0, import_node_fs3.existsSync)(binary)) return binary;
45469
+ const url = `https://github.com/duckdb/duckdb/releases/download/${DUCKDB_VERSION}/${target.asset}`;
45470
+ const response = await fetch(url);
45471
+ if (!response.ok) {
45472
+ throw new Error(
45473
+ `Downloading DuckDB ${DUCKDB_VERSION} failed: HTTP ${response.status}`
45474
+ );
45475
+ }
45476
+ const archive = Buffer.from(await response.arrayBuffer());
45477
+ const digest = (0, import_node_crypto2.createHash)("sha256").update(archive).digest("hex");
45478
+ if (digest !== target.sha256) {
45479
+ throw new Error(
45480
+ `DuckDB ${DUCKDB_VERSION} download did not match its checksum`
45481
+ );
45482
+ }
45483
+ (0, import_node_fs3.mkdirSync)(runtimeDir(), { recursive: true });
45484
+ const partial = `${binary}.partial`;
45485
+ (0, import_node_fs3.writeFileSync)(partial, (0, import_node_zlib.gunzipSync)(archive), { mode: 493 });
45486
+ (0, import_node_fs3.chmodSync)(partial, 493);
45487
+ (0, import_node_fs3.renameSync)(partial, binary);
45488
+ return binary;
45489
+ }
45490
+ function installedExtensionRelease(path2) {
45491
+ if (!(0, import_node_fs3.existsSync)(path2)) return null;
45492
+ const fd = (0, import_node_fs3.openSync)(path2, "r");
45493
+ try {
45494
+ const size = (0, import_node_fs3.fstatSync)(fd).size;
45495
+ const end = size - 256 - 3 * 32;
45496
+ if (end < 32) return null;
45497
+ const field = Buffer.alloc(32);
45498
+ (0, import_node_fs3.readSync)(fd, field, 0, 32, end - 32);
45499
+ const nul = field.indexOf(0);
45500
+ return field.toString("utf8", 0, nul === -1 ? 32 : nul) || null;
45501
+ } finally {
45502
+ (0, import_node_fs3.closeSync)(fd);
45503
+ }
45504
+ }
45505
+ function installedExtensionPath(target) {
45506
+ return (0, import_node_path4.join)(
45507
+ extensionDirectory(),
45508
+ DUCKDB_VERSION,
45509
+ target.extensionPlatform,
45510
+ "oleander.duckdb_extension"
45511
+ );
45512
+ }
45513
+ function catalogAliases(catalogNames) {
45514
+ return catalogNames.map(
45515
+ (name) => name.toLowerCase() === "oleander" ? `${name}=oleander.lake` : `${name}=oleander.lake#${name}`
45516
+ ).join(";");
45517
+ }
45518
+ var sqlString = (value) => `'${value.replace(/'/g, "''")}'`;
45519
+ function lineageInitSql(target, catalogNames) {
45520
+ const install = installedExtensionRelease(installedExtensionPath(target)) === OLEANDER_EXTENSION_RELEASE ? "" : `FORCE INSTALL oleander FROM ${sqlString(OLEANDER_EXTENSION_REPOSITORY)};
45521
+ `;
45522
+ return install + `LOAD oleander;
45523
+ SET openlineage_namespace = ${sqlString(CLI_JOB_NAMESPACE)};
45524
+ SET openlineage_batch_size = 100;
45525
+ SET openlineage_catalog_aliases = ${sqlString(catalogAliases(catalogNames))};
45526
+ `;
45527
+ }
45528
+
45529
+ // src/commands/duckdb.ts
45420
45530
  var HORIZON_CATALOG_PATH = "/polaris/api/catalog";
45421
45531
  function getHorizonCatalogBaseUrl(catalogUri) {
45422
45532
  const url = new URL(catalogUri);
@@ -45493,7 +45603,7 @@ function catalogAttachSql(catalog, credJson) {
45493
45603
  }
45494
45604
  return null;
45495
45605
  }
45496
- async function duckdbTerminal() {
45606
+ async function duckdbTerminal(options) {
45497
45607
  let apiKey;
45498
45608
  try {
45499
45609
  const cfg = await config.load();
@@ -45520,7 +45630,29 @@ async function duckdbTerminal() {
45520
45630
  spinner.fail("Failed to load catalogs.");
45521
45631
  return;
45522
45632
  }
45523
- let initSql = `
45633
+ const target = duckdbPlatform();
45634
+ let duckdb = "duckdb";
45635
+ let lineage = options.lineage !== false;
45636
+ const notices = [];
45637
+ if (target) {
45638
+ spinner.text = `Preparing DuckDB ${DUCKDB_VERSION}...`;
45639
+ try {
45640
+ duckdb = await ensureDuckdb(target);
45641
+ } catch (error) {
45642
+ notices.push(
45643
+ `${error instanceof Error ? error.message : String(error)}; starting your own duckdb without lineage.`
45644
+ );
45645
+ lineage = false;
45646
+ }
45647
+ } else if (lineage) {
45648
+ notices.push(
45649
+ `Lineage needs DuckDB ${DUCKDB_VERSION} on macOS or glibc Linux; starting your own duckdb without it.`
45650
+ );
45651
+ lineage = false;
45652
+ }
45653
+ let initSql = duckdb === "duckdb" ? "" : `SET extension_directory = ${sqlString(extensionDirectory())};
45654
+ `;
45655
+ initSql += `
45524
45656
  INSTALL httpfs; LOAD httpfs;
45525
45657
  INSTALL iceberg; LOAD iceberg;
45526
45658
  INSTALL aws; LOAD aws;
@@ -45528,6 +45660,7 @@ async function duckdbTerminal() {
45528
45660
  const catalogsJson = await catalogResp.json();
45529
45661
  const catalogs = catalogsJson.registeredCatalogs ?? [];
45530
45662
  const skipped = [];
45663
+ const attached = [];
45531
45664
  for (const catalog of catalogs) {
45532
45665
  spinner.text = `Loading catalog: ${catalog.name}`;
45533
45666
  const credResp = await fetch(
@@ -45554,21 +45687,35 @@ async function duckdbTerminal() {
45554
45687
  continue;
45555
45688
  }
45556
45689
  initSql += attachSql;
45690
+ attached.push(catalog.name);
45557
45691
  }
45558
45692
  if (catalogs.length > 0 && skipped.length === catalogs.length) {
45559
45693
  spinner.fail("Failed to load any catalog.");
45560
45694
  for (const message of skipped) logger.warn(message);
45561
45695
  process.exit(1);
45562
45696
  }
45697
+ if (lineage && target) {
45698
+ initSql += lineageInitSql(target, attached);
45699
+ }
45563
45700
  const tempDir = (0, import_fs5.mkdtempSync)((0, import_path5.join)((0, import_node_os4.tmpdir)(), "oleander-duckdb-init-"));
45564
45701
  const initPath = (0, import_path5.join)(tempDir, "init.sql");
45565
- (0, import_node_fs3.writeFileSync)(initPath, initSql.trimStart(), { encoding: "utf-8" });
45566
- spinner.succeed("Starting duckdb terminal for oleander lake.");
45567
- for (const message of skipped) logger.warn(message);
45568
- const p2 = (0, import_node_child_process2.spawn)("duckdb", ["-init", initPath], {
45569
- stdio: "inherit",
45570
- env: process.env
45571
- });
45702
+ (0, import_node_fs4.writeFileSync)(initPath, initSql.trimStart(), { encoding: "utf-8" });
45703
+ spinner.succeed(
45704
+ lineage ? `Starting DuckDB ${DUCKDB_VERSION} for oleander lake, reporting lineage.` : "Starting duckdb terminal for oleander lake."
45705
+ );
45706
+ for (const message of [...skipped, ...notices]) logger.warn(message);
45707
+ const p2 = (0, import_node_child_process2.spawn)(
45708
+ duckdb,
45709
+ lineage ? ["-unsigned", "-init", initPath] : ["-init", initPath],
45710
+ {
45711
+ stdio: "inherit",
45712
+ env: lineage ? {
45713
+ ...process.env,
45714
+ OPENLINEAGE_URL: getEndpoint(),
45715
+ OPENLINEAGE_API_KEY: apiKey
45716
+ } : process.env
45717
+ }
45718
+ );
45572
45719
  p2.on("exit", (code, signal) => {
45573
45720
  if (signal) {
45574
45721
  process.kill(process.pid, signal);
@@ -45595,7 +45742,7 @@ var import_fs7 = require("fs");
45595
45742
  // package.json
45596
45743
  var package_default = {
45597
45744
  name: "oleander-cli",
45598
- version: "0.21.0",
45745
+ version: "0.24.0",
45599
45746
  description: "oleander CLI",
45600
45747
  keywords: [
45601
45748
  "cli",
@@ -46440,8 +46587,8 @@ function registerQueriesCommands(program3) {
46440
46587
  // src/utils/skills.ts
46441
46588
  var import_node_child_process3 = require("child_process");
46442
46589
  var import_node_os5 = require("os");
46443
- var import_node_fs4 = require("fs");
46444
- var import_node_path4 = require("path");
46590
+ var import_node_fs5 = require("fs");
46591
+ var import_node_path5 = require("path");
46445
46592
  var SKILLS_REPO = "OleanderHQ/skills";
46446
46593
  var OLEANDER_SKILLS_DIR = ".oleander/skills";
46447
46594
  var OLEANDER_SKILL_NAMES = [
@@ -46474,12 +46621,12 @@ var SkillsInstallError = class extends Error {
46474
46621
  }
46475
46622
  };
46476
46623
  function oleanderSkillsDir(homeDir = (0, import_node_os5.homedir)()) {
46477
- return (0, import_node_path4.join)(homeDir, OLEANDER_SKILLS_DIR);
46624
+ return (0, import_node_path5.join)(homeDir, OLEANDER_SKILLS_DIR);
46478
46625
  }
46479
46626
  function readSkillVersion(skillDir) {
46480
46627
  try {
46481
46628
  const parsed = JSON.parse(
46482
- (0, import_node_fs4.readFileSync)((0, import_node_path4.join)(skillDir, "metadata.json"), "utf8")
46629
+ (0, import_node_fs5.readFileSync)((0, import_node_path5.join)(skillDir, "metadata.json"), "utf8")
46483
46630
  );
46484
46631
  return typeof parsed.version === "string" ? parsed.version : null;
46485
46632
  } catch {
@@ -46488,7 +46635,7 @@ function readSkillVersion(skillDir) {
46488
46635
  }
46489
46636
  function skillPresent(skillDir) {
46490
46637
  try {
46491
- (0, import_node_fs4.lstatSync)((0, import_node_path4.join)(skillDir, "SKILL.md"));
46638
+ (0, import_node_fs5.lstatSync)((0, import_node_path5.join)(skillDir, "SKILL.md"));
46492
46639
  return true;
46493
46640
  } catch {
46494
46641
  return false;
@@ -46496,19 +46643,19 @@ function skillPresent(skillDir) {
46496
46643
  }
46497
46644
  function isSymlink(path2) {
46498
46645
  try {
46499
- return (0, import_node_fs4.lstatSync)(path2).isSymbolicLink();
46646
+ return (0, import_node_fs5.lstatSync)(path2).isSymbolicLink();
46500
46647
  } catch {
46501
46648
  return false;
46502
46649
  }
46503
46650
  }
46504
46651
  function presentSkillNames(skillsDir) {
46505
46652
  return OLEANDER_SKILL_NAMES.filter(
46506
- (name) => skillPresent((0, import_node_path4.join)(skillsDir, name))
46653
+ (name) => skillPresent((0, import_node_path5.join)(skillsDir, name))
46507
46654
  );
46508
46655
  }
46509
46656
  function versionFromSkillsDir(skillsDir) {
46510
46657
  for (const name of presentSkillNames(skillsDir)) {
46511
- const version = readSkillVersion((0, import_node_path4.join)(skillsDir, name));
46658
+ const version = readSkillVersion((0, import_node_path5.join)(skillsDir, name));
46512
46659
  if (version) {
46513
46660
  return version;
46514
46661
  }
@@ -46516,25 +46663,25 @@ function versionFromSkillsDir(skillsDir) {
46516
46663
  return null;
46517
46664
  }
46518
46665
  function isInside(path2, dir) {
46519
- const rel = (0, import_node_path4.relative)(dir, path2);
46520
- return rel === "" || !rel.startsWith("..") && !(0, import_node_path4.isAbsolute)(rel);
46666
+ const rel = (0, import_node_path5.relative)(dir, path2);
46667
+ return rel === "" || !rel.startsWith("..") && !(0, import_node_path5.isAbsolute)(rel);
46521
46668
  }
46522
46669
  function samePath(left2, right2) {
46523
46670
  try {
46524
- return (0, import_node_fs4.realpathSync)(left2) === (0, import_node_fs4.realpathSync)(right2);
46671
+ return (0, import_node_fs5.realpathSync)(left2) === (0, import_node_fs5.realpathSync)(right2);
46525
46672
  } catch {
46526
- return (0, import_node_path4.resolve)(left2) === (0, import_node_path4.resolve)(right2);
46673
+ return (0, import_node_path5.resolve)(left2) === (0, import_node_path5.resolve)(right2);
46527
46674
  }
46528
46675
  }
46529
46676
  function findRealSkillSource(home, name, storeDir, agentRoots) {
46530
46677
  for (const root of agentRoots) {
46531
- const candidate = (0, import_node_path4.join)(home, root.relativeDir, name);
46678
+ const candidate = (0, import_node_path5.join)(home, root.relativeDir, name);
46532
46679
  if (!skillPresent(candidate)) {
46533
46680
  continue;
46534
46681
  }
46535
46682
  try {
46536
- if ((0, import_node_fs4.lstatSync)(candidate).isSymbolicLink()) {
46537
- const real = (0, import_node_fs4.realpathSync)(candidate);
46683
+ if ((0, import_node_fs5.lstatSync)(candidate).isSymbolicLink()) {
46684
+ const real = (0, import_node_fs5.realpathSync)(candidate);
46538
46685
  if (isInside(real, storeDir)) {
46539
46686
  continue;
46540
46687
  }
@@ -46548,46 +46695,46 @@ function findRealSkillSource(home, name, storeDir, agentRoots) {
46548
46695
  continue;
46549
46696
  }
46550
46697
  }
46551
- const stored = (0, import_node_path4.join)(storeDir, name);
46698
+ const stored = (0, import_node_path5.join)(storeDir, name);
46552
46699
  return skillPresent(stored) ? stored : null;
46553
46700
  }
46554
46701
  function ensureSymlink(linkPath, dest) {
46555
- const resolvedDest = (0, import_node_path4.resolve)(dest);
46702
+ const resolvedDest = (0, import_node_path5.resolve)(dest);
46556
46703
  try {
46557
- const stat2 = (0, import_node_fs4.lstatSync)(linkPath);
46704
+ const stat2 = (0, import_node_fs5.lstatSync)(linkPath);
46558
46705
  if (stat2.isSymbolicLink()) {
46559
- const current = (0, import_node_path4.resolve)((0, import_node_path4.dirname)(linkPath), (0, import_node_fs4.readlinkSync)(linkPath));
46706
+ const current = (0, import_node_path5.resolve)((0, import_node_path5.dirname)(linkPath), (0, import_node_fs5.readlinkSync)(linkPath));
46560
46707
  if (current === resolvedDest) {
46561
46708
  return;
46562
46709
  }
46563
- (0, import_node_fs4.unlinkSync)(linkPath);
46710
+ (0, import_node_fs5.unlinkSync)(linkPath);
46564
46711
  } else {
46565
- (0, import_node_fs4.rmSync)(linkPath, { recursive: true, force: true });
46712
+ (0, import_node_fs5.rmSync)(linkPath, { recursive: true, force: true });
46566
46713
  }
46567
46714
  } catch {
46568
46715
  }
46569
- (0, import_node_fs4.symlinkSync)(resolvedDest, linkPath, "junction");
46716
+ (0, import_node_fs5.symlinkSync)(resolvedDest, linkPath, "junction");
46570
46717
  }
46571
46718
  function syncOleanderSkillStore(homeDir, agentRoots = AGENT_SKILL_ROOTS) {
46572
46719
  const storeDir = oleanderSkillsDir(homeDir);
46573
46720
  for (const name of OLEANDER_SKILL_NAMES) {
46574
- const dest = (0, import_node_path4.join)(storeDir, name);
46721
+ const dest = (0, import_node_path5.join)(storeDir, name);
46575
46722
  const source = findRealSkillSource(homeDir, name, storeDir, agentRoots);
46576
46723
  if (!source) {
46577
46724
  continue;
46578
46725
  }
46579
- (0, import_node_fs4.mkdirSync)(storeDir, { recursive: true });
46726
+ (0, import_node_fs5.mkdirSync)(storeDir, { recursive: true });
46580
46727
  if (!samePath(source, dest)) {
46581
- (0, import_node_fs4.rmSync)(dest, { recursive: true, force: true });
46582
- (0, import_node_fs4.cpSync)(source, dest, { recursive: true, dereference: true });
46728
+ (0, import_node_fs5.rmSync)(dest, { recursive: true, force: true });
46729
+ (0, import_node_fs5.cpSync)(source, dest, { recursive: true, dereference: true });
46583
46730
  }
46584
46731
  }
46585
46732
  for (const name of presentSkillNames(storeDir)) {
46586
- const dest = (0, import_node_path4.join)(storeDir, name);
46733
+ const dest = (0, import_node_path5.join)(storeDir, name);
46587
46734
  for (const root of agentRoots) {
46588
- const agentDir = (0, import_node_path4.join)(homeDir, root.relativeDir);
46589
- (0, import_node_fs4.mkdirSync)(agentDir, { recursive: true });
46590
- ensureSymlink((0, import_node_path4.join)(agentDir, name), dest);
46735
+ const agentDir = (0, import_node_path5.join)(homeDir, root.relativeDir);
46736
+ (0, import_node_fs5.mkdirSync)(agentDir, { recursive: true });
46737
+ ensureSymlink((0, import_node_path5.join)(agentDir, name), dest);
46591
46738
  }
46592
46739
  }
46593
46740
  }
@@ -46606,13 +46753,13 @@ function getSkillsStatus(options = {}) {
46606
46753
  const agentRoots = options.agentRoots ?? AGENT_SKILL_ROOTS;
46607
46754
  const storeNames = presentSkillNames(storeDir);
46608
46755
  const agents = agentRoots.map((root) => {
46609
- const path2 = (0, import_node_path4.join)(home, root.relativeDir);
46756
+ const path2 = (0, import_node_path5.join)(home, root.relativeDir);
46610
46757
  const names = presentSkillNames(path2);
46611
46758
  return {
46612
46759
  label: root.label,
46613
46760
  path: path2,
46614
46761
  present: names.length > 0,
46615
- symlinked: names.length > 0 && names.every((name) => isSymlink((0, import_node_path4.join)(path2, name)))
46762
+ symlinked: names.length > 0 && names.every((name) => isSymlink((0, import_node_path5.join)(path2, name)))
46616
46763
  };
46617
46764
  });
46618
46765
  return {
@@ -46901,10 +47048,13 @@ Examples:
46901
47048
  `
46902
47049
  ).action(polarsCommand);
46903
47050
  addOutputOption(polars, { formats: TABLE_JSON_CSV_FORMATS });
46904
- program2.command("duckdb").description("Starts a local DuckDB shell").addHelpText(
47051
+ program2.command("duckdb").description("Starts a local DuckDB shell").option("--no-lineage", "Do not report the shell's lineage to oleander").addHelpText(
46905
47052
  "after",
46906
47053
  `
46907
- Requires a local duckdb binary. For one-shot SQL on DuckDB, use oleander query --engine duckdb.
47054
+ Runs DuckDB ${DUCKDB_VERSION}, downloaded to ~/.oleander on first use, with every catalog attached. Each
47055
+ statement that reads or writes a table reports its lineage to oleander (the oleander DuckDB extension,
47056
+ which DuckDB loads as an unsigned extension). Where no build is published (Windows, musl Linux) your
47057
+ own duckdb starts, without lineage. For one-shot SQL on DuckDB, use oleander query --engine duckdb.
46908
47058
  `
46909
47059
  ).action(duckdbTerminal);
46910
47060
  registerSparkCommands(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oleander-cli",
3
- "version": "0.21.0",
3
+ "version": "0.24.0",
4
4
  "description": "oleander CLI",
5
5
  "keywords": [
6
6
  "cli",