@merittdev/horus 0.8.12 → 0.8.14

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 +132 -41
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -43846,7 +43846,7 @@ var require_pg_pool = __commonJS({
43846
43846
  function throwOnDoubleRelease() {
43847
43847
  throw new Error("Release called on client which has already been released to the pool.");
43848
43848
  }
43849
- function promisify5(Promise2, callback) {
43849
+ function promisify6(Promise2, callback) {
43850
43850
  if (callback) {
43851
43851
  return { callback, result: void 0 };
43852
43852
  }
@@ -43984,7 +43984,7 @@ var require_pg_pool = __commonJS({
43984
43984
  const err2 = new Error("Cannot use a pool after calling end on the pool");
43985
43985
  return cb ? cb(err2) : this.Promise.reject(err2);
43986
43986
  }
43987
- const response = promisify5(this.Promise, cb);
43987
+ const response = promisify6(this.Promise, cb);
43988
43988
  const result = response.result;
43989
43989
  if (this._isFull() || this._idle.length) {
43990
43990
  if (this._idle.length) {
@@ -44169,7 +44169,7 @@ var require_pg_pool = __commonJS({
44169
44169
  }
44170
44170
  query(text2, values2, cb) {
44171
44171
  if (typeof text2 === "function") {
44172
- const response2 = promisify5(this.Promise, text2);
44172
+ const response2 = promisify6(this.Promise, text2);
44173
44173
  setImmediate(function() {
44174
44174
  return response2.callback(new Error("Passing a function as the first parameter to pool.query is not supported"));
44175
44175
  });
@@ -44179,7 +44179,7 @@ var require_pg_pool = __commonJS({
44179
44179
  cb = values2;
44180
44180
  values2 = void 0;
44181
44181
  }
44182
- const response = promisify5(this.Promise, cb);
44182
+ const response = promisify6(this.Promise, cb);
44183
44183
  cb = response.callback;
44184
44184
  this.connect((err2, client) => {
44185
44185
  if (err2) {
@@ -44224,7 +44224,7 @@ var require_pg_pool = __commonJS({
44224
44224
  return cb ? cb(err2) : this.Promise.reject(err2);
44225
44225
  }
44226
44226
  this.ending = true;
44227
- const promised = promisify5(this.Promise, cb);
44227
+ const promised = promisify6(this.Promise, cb);
44228
44228
  this._endCallback = promised.callback;
44229
44229
  this._pulseQueue();
44230
44230
  return promised.result;
@@ -65880,8 +65880,8 @@ init_cjs_shims();
65880
65880
 
65881
65881
  // ../../packages/core/src/version.ts
65882
65882
  init_cjs_shims();
65883
- var HORUS_VERSION = true ? "0.8.12" : "dev";
65884
- var PINNED_SOURCE_VERSION = "1.5.1";
65883
+ var HORUS_VERSION = true ? "0.8.14" : "dev";
65884
+ var PINNED_SOURCE_VERSION = "1.5.2";
65885
65885
 
65886
65886
  // ../../packages/core/src/evidence.ts
65887
65887
  init_cjs_shims();
@@ -70987,7 +70987,7 @@ async function getSourceVersion() {
70987
70987
  var SourceVersionMismatchError = class extends Error {
70988
70988
  constructor(installed, pinned) {
70989
70989
  super(
70990
- `horus-source ${installed} is installed but Horus is pinned to ${pinned}. A drifted backend builds a graph this CLI cannot map and can corrupt the index (e.g. duplicate-primary-key failures during "Running initial index"). Install the pinned version: pip install 'horus-source==${pinned}'`
70990
+ `horus-source ${installed} is installed but Horus is pinned to ${pinned}. A drifted backend builds a graph this CLI cannot map and can corrupt the index (e.g. duplicate-primary-key failures during "Running initial index"). Run \`horus update\` to sync the backend, or re-run the installer: curl -fsSL https://horus.sh/install.sh | bash`
70991
70991
  );
70992
70992
  this.installed = installed;
70993
70993
  this.pinned = pinned;
@@ -71007,7 +71007,7 @@ function isAnalyzed(root) {
71007
71007
  }
71008
71008
  async function analyzeRepo(root) {
71009
71009
  const bin = await resolveSourceBin();
71010
- if (!bin) throw new Error("horus-source not found on PATH. Install it: pip install horus-source");
71010
+ if (!bin) throw new Error("horus-source not found on PATH. Install it: curl -fsSL https://horus.sh/install.sh | bash");
71011
71011
  await exec(bin, ["analyze", "."], {
71012
71012
  cwd: root,
71013
71013
  timeout: 9e5,
@@ -71083,7 +71083,7 @@ function startHost(root, port) {
71083
71083
  child.on("error", (err2) => {
71084
71084
  if (err2.code === "ENOENT") {
71085
71085
  process.stderr.write(
71086
- "\nhorus-source not found on PATH. Install it: pip install horus-source\n"
71086
+ "\nhorus-source not found on PATH. Install it: curl -fsSL https://horus.sh/install.sh | bash\n"
71087
71087
  );
71088
71088
  }
71089
71089
  });
@@ -71159,7 +71159,14 @@ var SourceCodeProvider = class {
71159
71159
  };
71160
71160
  }
71161
71161
  async rows(query) {
71162
- return (await this.client.cypher(query)).rows;
71162
+ try {
71163
+ return (await this.client.cypher(query)).rows;
71164
+ } catch (err2) {
71165
+ if (err2 instanceof SourceHttpError && err2.status >= 400 && err2.status < 500) {
71166
+ return [];
71167
+ }
71168
+ throw err2;
71169
+ }
71163
71170
  }
71164
71171
  cypherRowToSymbol(row, idIdx, nameIdx, fileIdx, lineIdx, classNameIdx) {
71165
71172
  const startLine = lineIdx != null && row[lineIdx] != null ? Number(row[lineIdx]) : void 0;
@@ -74284,6 +74291,14 @@ function parseGitLog(stdout) {
74284
74291
  }
74285
74292
  return commits;
74286
74293
  }
74294
+ async function resolvesToCommit(repoPath, rev) {
74295
+ try {
74296
+ await exec2("git", ["-C", repoPath, "rev-parse", "--verify", "--quiet", `${rev}^{commit}`]);
74297
+ return true;
74298
+ } catch {
74299
+ return false;
74300
+ }
74301
+ }
74287
74302
  async function gitLog(repoPath, opts = {}) {
74288
74303
  const args2 = [
74289
74304
  "-C",
@@ -74293,11 +74308,16 @@ async function gitLog(repoPath, opts = {}) {
74293
74308
  "--pretty=format:%H%h%an%aI%s",
74294
74309
  "--name-only"
74295
74310
  ];
74296
- if (opts.since !== void 0) {
74297
- args2.push("--since=" + opts.since);
74298
- }
74299
- if (opts.until !== void 0) {
74300
- args2.push("--until=" + opts.until);
74311
+ if (opts.since !== void 0 && await resolvesToCommit(repoPath, opts.since)) {
74312
+ const end = opts.until !== void 0 && await resolvesToCommit(repoPath, opts.until) ? opts.until : "HEAD";
74313
+ args2.push(`${opts.since}..${end}`);
74314
+ } else {
74315
+ if (opts.since !== void 0) {
74316
+ args2.push("--since=" + opts.since);
74317
+ }
74318
+ if (opts.until !== void 0) {
74319
+ args2.push("--until=" + opts.until);
74320
+ }
74301
74321
  }
74302
74322
  args2.push("--max-count=" + (opts.maxCount ?? 200));
74303
74323
  const { stdout } = await exec2("git", args2, { maxBuffer: 10 * 1024 * 1024 });
@@ -93869,7 +93889,7 @@ async function investigate(input, deps) {
93869
93889
  const headlineLinked = headlineCause !== void 0 && isLinkedToSeed(headlineCause.sourceEvidenceIds);
93870
93890
  if (headlineCause && !headlineLinked) confidence = Math.min(confidence, 0.6);
93871
93891
  const banner2 = degradedNoSource ? "Runtime-only (source intelligence unavailable). " : "";
93872
- const scope = top ? `resolved to ${label} (${area})` : `over runtime evidence (${area})`;
93892
+ const scope = top ? seedIsLowConfidence ? "could not be confidently localized from source alone" : `resolved to ${label} (${area})` : `over runtime evidence (${area})`;
93873
93893
  const seedDisclaimer = seedIsLowConfidence && top ? `\u26A0 No symbol closely matched "${hint}" \u2014 "${top.name}" is a low-confidence closest match (semantic). Refine with an exact symbol or error code to target precisely. ` : "";
93874
93894
  let summary = headlineCause ? headlineLinked ? `${seedDisclaimer}${banner2}Investigation of "${hint}" ${scope}. Top suspected cause: ${headlineCause.title}.` : `${seedDisclaimer}${banner2}Investigation of "${hint}" ${scope}. No cause is structurally linked to the seed; the strongest co-occurring signal (a lead to verify, not a diagnosis) is: ${headlineCause.title}.` : `${seedDisclaimer}${banner2}Investigation of "${hint}" ${scope}. No dominant suspected cause emerged from the available ${degradedNoSource ? "runtime" : "structural"} evidence.`;
93875
93895
  const hasIncidentSignal = directLogEvIds.length > 0 || latencyMetricEvIds.length > 0 || queueMetricEvIds.length > 0 || dataAnomalyEvIds.length > 0 || queueFailureSignals.length > 0 || findings2.some((f5) => f5.kind === "anomaly") || headlineCause !== void 0;
@@ -94389,7 +94409,30 @@ var EXTERNAL_MARKERS = [
94389
94409
  "elasticsearch",
94390
94410
  "prometheus",
94391
94411
  "mongo",
94392
- "graphql"
94412
+ "graphql",
94413
+ // Python ecosystem (HOR-356): the markers above are Node-centric, so Python backends'
94414
+ // DB/queue/web stacks went undetected (e.g. redash's Postgres + Celery). 'mongo'/'redis'
94415
+ // already cover pymongo/redis-py by substring.
94416
+ "sqlalchemy",
94417
+ "sqlmodel",
94418
+ "psycopg",
94419
+ "celery",
94420
+ "fastapi",
94421
+ "flask",
94422
+ "django",
94423
+ "kafka",
94424
+ "boto3",
94425
+ // Node ORMs/DB drivers (HOR-359): markers above had only prisma/mongo/redis, so a
94426
+ // TypeORM/Sequelize/Knex backend's database layer went undetected (e.g. vendure on
94427
+ // Postgres). Names chosen to be unambiguous in file content (bare 'pg' would false-match).
94428
+ "typeorm",
94429
+ "sequelize",
94430
+ "knex",
94431
+ "drizzle-orm",
94432
+ "postgres",
94433
+ "mariadb",
94434
+ "mysql2",
94435
+ "mssql"
94393
94436
  ];
94394
94437
  async function discoverArchitecture(deps) {
94395
94438
  const nodeStats = await (async () => {
@@ -97310,7 +97353,7 @@ function parseHostPort(hostUrl) {
97310
97353
  function ensureHostReasonHint(reason) {
97311
97354
  switch (reason) {
97312
97355
  case "source-unavailable":
97313
- return "horus-source is not installed \u2014 install it: pip install horus-source";
97356
+ return "horus-source is not installed \u2014 install it: curl -fsSL https://horus.sh/install.sh | bash";
97314
97357
  case "version-mismatch":
97315
97358
  return "the installed horus-source backend does not match the version Horus is pinned to \u2014 reinstall the pinned version (run `horus status` to see it)";
97316
97359
  case "not-analyzed":
@@ -97459,7 +97502,7 @@ async function runIndex(opts) {
97459
97502
  spawned = true;
97460
97503
  console.log(import_picocolors3.default.bold(`Indexing ${label}`) + import_picocolors3.default.dim(` (${root})`));
97461
97504
  if (!await sourceAvailable()) {
97462
- console.error(import_picocolors3.default.red("horus-source not found on PATH. Install it: pip install horus-source"));
97505
+ console.error(import_picocolors3.default.red("horus-source not found on PATH. Install it: curl -fsSL https://horus.sh/install.sh | bash"));
97463
97506
  return 1;
97464
97507
  }
97465
97508
  try {
@@ -97480,28 +97523,41 @@ async function runIndex(opts) {
97480
97523
  console.log(import_picocolors3.default.dim(" already analyzed"));
97481
97524
  }
97482
97525
  const priorPort = parseHostPort(configuredHost ?? "") ?? parseHostPort(readSourceHostUrl(root) ?? "");
97483
- let port;
97484
- if (priorPort !== null) {
97485
- try {
97486
- port = await findFreePort(priorPort, priorPort);
97487
- } catch {
97526
+ const MAX_PORT_ATTEMPTS = 4;
97527
+ let started = false;
97528
+ for (let attempt = 0; attempt < MAX_PORT_ATTEMPTS && !started; attempt += 1) {
97529
+ let port;
97530
+ if (attempt === 0 && priorPort !== null) {
97531
+ try {
97532
+ port = await findFreePort(priorPort, priorPort);
97533
+ } catch {
97534
+ port = await findFreePort();
97535
+ }
97536
+ } else {
97488
97537
  port = await findFreePort();
97489
97538
  }
97490
- } else {
97491
- port = await findFreePort();
97539
+ hostUrl = `http://127.0.0.1:${port}`;
97540
+ console.log(
97541
+ import_picocolors3.default.dim(
97542
+ attempt === 0 ? ` starting source-intelligence host on port ${port}\u2026` : ` port contended \u2014 retrying on ${port}\u2026`
97543
+ )
97544
+ );
97545
+ startHost(root, port);
97546
+ if (await waitForHost(hostUrl)) {
97547
+ reconcileSpawnedHostPid(root, port);
97548
+ started = true;
97549
+ } else {
97550
+ removeSpawnedHostRecord(root);
97551
+ }
97492
97552
  }
97493
- hostUrl = `http://127.0.0.1:${port}`;
97494
- console.log(import_picocolors3.default.dim(` starting source-intelligence host on port ${port}\u2026`));
97495
- startHost(root, port);
97496
- if (!await waitForHost(hostUrl)) {
97497
- removeSpawnedHostRecord(root);
97553
+ if (!started) {
97498
97554
  console.error(
97499
97555
  import_picocolors3.default.red(` Source-intelligence host did not become healthy \u2014 see ${root}/.horus/source-host.log`)
97500
97556
  );
97501
97557
  return 1;
97502
97558
  }
97503
- reconcileSpawnedHostPid(root, port);
97504
97559
  }
97560
+ if (!hostUrl) return 1;
97505
97561
  await stitchQueueMap(hostUrl, dbUrl, label);
97506
97562
  buildKnowledgeIndex(root, config2, label, configuredProject, opts);
97507
97563
  const hasLocalConfig = discoverLocalConfig(root) !== null;
@@ -112897,7 +112953,7 @@ async function runSetup(opts) {
112897
112953
  write(
112898
112954
  import_picocolors32.default.dim(
112899
112955
  ` install it (Python 3.11+ required):
112900
- pip install horus-source
112956
+ curl -fsSL https://horus.sh/install.sh | bash
112901
112957
  ensure ~/.local/bin is on your PATH`
112902
112958
  )
112903
112959
  );
@@ -112909,7 +112965,7 @@ async function runSetup(opts) {
112909
112965
  write(
112910
112966
  import_picocolors32.default.dim(
112911
112967
  ` update it:
112912
- pip install --upgrade horus-source`
112968
+ horus update`
112913
112969
  )
112914
112970
  );
112915
112971
  } else {
@@ -114851,7 +114907,7 @@ async function runReadiness(opts) {
114851
114907
  status: "warn",
114852
114908
  blocking: false,
114853
114909
  detail: "not installed \u2014 source intelligence unavailable",
114854
- next: `pip install horus-source`
114910
+ next: `curl -fsSL https://horus.sh/install.sh | bash`
114855
114911
  });
114856
114912
  } else if (sourceVersion !== PINNED_SOURCE_VERSION) {
114857
114913
  checks.push({
@@ -114859,7 +114915,7 @@ async function runReadiness(opts) {
114859
114915
  status: "warn",
114860
114916
  blocking: false,
114861
114917
  detail: `version mismatch (installed: ${sourceVersion}, required: ${PINNED_SOURCE_VERSION})`,
114862
- next: `pip install horus-source`
114918
+ next: `horus update`
114863
114919
  });
114864
114920
  } else {
114865
114921
  checks.push({
@@ -115449,7 +115505,40 @@ var import_node_fs19 = require("fs");
115449
115505
  var import_node_path21 = require("path");
115450
115506
  var import_node_os6 = require("os");
115451
115507
  var import_node_crypto7 = require("crypto");
115508
+ var import_node_child_process9 = require("child_process");
115509
+ var import_node_util5 = require("util");
115452
115510
  var import_picocolors43 = __toESM(require_picocolors(), 1);
115511
+ var execFileAsync2 = (0, import_node_util5.promisify)(import_node_child_process9.execFile);
115512
+ async function ensureBackendPinned(write) {
115513
+ let installed = null;
115514
+ try {
115515
+ installed = await getSourceVersion();
115516
+ } catch {
115517
+ installed = null;
115518
+ }
115519
+ if (installed === PINNED_SOURCE_VERSION) {
115520
+ write(` ${import_picocolors43.default.green("\u2713")} Source backend already on pinned ${PINNED_SOURCE_VERSION}.`);
115521
+ return;
115522
+ }
115523
+ if (installed === null) {
115524
+ write(
115525
+ ` ${import_picocolors43.default.dim("Source backend not installed \u2014 install it: curl -fsSL https://horus.sh/install.sh | bash")}`
115526
+ );
115527
+ return;
115528
+ }
115529
+ write(` Upgrading source backend ${installed} \u2192 ${PINNED_SOURCE_VERSION}\u2026`);
115530
+ try {
115531
+ await execFileAsync2(
115532
+ "uv",
115533
+ ["tool", "install", "--force", `horus-source==${PINNED_SOURCE_VERSION}`],
115534
+ { timeout: 3e5 }
115535
+ );
115536
+ write(` ${import_picocolors43.default.green("\u2713")} Source backend upgraded to ${PINNED_SOURCE_VERSION}.`);
115537
+ } catch {
115538
+ write(` ${import_picocolors43.default.yellow("!")} Couldn't auto-upgrade the source backend. Re-run the installer:`);
115539
+ write(` ${import_picocolors43.default.dim("curl -fsSL https://horus.sh/install.sh | bash")}`);
115540
+ }
115541
+ }
115453
115542
  var RELEASES_API = "https://api.github.com/repos/meritt-dev/horus/releases/latest";
115454
115543
  function parseVersion(v4) {
115455
115544
  const m5 = v4.replace(/^v/, "").match(/^(\d+)\.(\d+)\.(\d+)/);
@@ -115517,6 +115606,7 @@ ${import_picocolors43.default.bold("Horus update")}
115517
115606
  if (!newer && !opts.force) {
115518
115607
  write(`
115519
115608
  ${import_picocolors43.default.green("\u2713")} Already on the latest version.`);
115609
+ await ensureBackendPinned(write);
115520
115610
  return 0;
115521
115611
  }
115522
115612
  const tag = release.tag_name;
@@ -115612,19 +115702,20 @@ ${import_picocolors43.default.bold("Horus update")}
115612
115702
  }
115613
115703
  write(` ${import_picocolors43.default.green("\u2713")} Updated: ${import_picocolors43.default.bold(currentVersion)} \u2192 ${import_picocolors43.default.bold(latest)}`);
115614
115704
  write(` ${import_picocolors43.default.dim(binaryPath)}`);
115705
+ await ensureBackendPinned(write);
115615
115706
  return 0;
115616
115707
  }
115617
115708
 
115618
115709
  // ../../packages/cli/src/commands/login.ts
115619
115710
  init_cjs_shims();
115620
- var import_node_child_process9 = require("child_process");
115711
+ var import_node_child_process10 = require("child_process");
115621
115712
  var import_picocolors44 = __toESM(require_picocolors(), 1);
115622
115713
  var sleep2 = (ms) => new Promise((resolve9) => setTimeout(resolve9, ms));
115623
115714
  function openBrowser(url) {
115624
115715
  const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
115625
115716
  const args2 = process.platform === "win32" ? ["/c", "start", "", url] : [url];
115626
115717
  try {
115627
- (0, import_node_child_process9.execFile)(cmd, args2, () => {
115718
+ (0, import_node_child_process10.execFile)(cmd, args2, () => {
115628
115719
  });
115629
115720
  } catch {
115630
115721
  }
@@ -115763,7 +115854,7 @@ var import_promises3 = require("readline/promises");
115763
115854
 
115764
115855
  // ../../packages/cli/src/lib/cloud/git.ts
115765
115856
  init_cjs_shims();
115766
- var import_node_child_process10 = require("child_process");
115857
+ var import_node_child_process11 = require("child_process");
115767
115858
  function parseRepoName(remoteUrl) {
115768
115859
  const cleaned = remoteUrl.trim().replace(/\.git$/, "");
115769
115860
  const lastSegment = cleaned.split(/[/:]/).filter(Boolean).pop() ?? "";
@@ -115787,7 +115878,7 @@ function inferProvider(remoteUrl) {
115787
115878
  }
115788
115879
  function detectGitRemote(root) {
115789
115880
  try {
115790
- const remoteUrl = (0, import_node_child_process10.execFileSync)("git", ["-C", root, "remote", "get-url", "origin"], {
115881
+ const remoteUrl = (0, import_node_child_process11.execFileSync)("git", ["-C", root, "remote", "get-url", "origin"], {
115791
115882
  encoding: "utf8",
115792
115883
  stdio: ["ignore", "pipe", "ignore"]
115793
115884
  }).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merittdev/horus",
3
- "version": "0.8.12",
3
+ "version": "0.8.14",
4
4
  "description": "Local-first, source-aware production-incident investigation engine",
5
5
  "type": "module",
6
6
  "bin": {