@merittdev/horus 0.1.4 → 0.1.6

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 +49 -36
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -50314,7 +50314,7 @@ init_cjs_shims();
50314
50314
 
50315
50315
  // ../../packages/core/src/version.ts
50316
50316
  init_cjs_shims();
50317
- var HORUS_VERSION = true ? "0.1.4" : "dev";
50317
+ var HORUS_VERSION = true ? "0.1.6" : "dev";
50318
50318
  var PINNED_AXON_VERSION = "1.0.0";
50319
50319
  var PINNED_SOURCE_VERSION = PINNED_AXON_VERSION;
50320
50320
 
@@ -54494,6 +54494,19 @@ function ensureCredentialGitignore(root) {
54494
54494
  function readLocalConfig(path) {
54495
54495
  return JSON.parse((0, import_node_fs.readFileSync)(path, "utf8"));
54496
54496
  }
54497
+ function ensureProjectGitignore(root) {
54498
+ if (!(0, import_node_fs.existsSync)((0, import_node_path.join)(root, ".git"))) return;
54499
+ const gitignorePath = (0, import_node_path.join)(root, ".gitignore");
54500
+ const entry2 = ".horus/";
54501
+ if (!(0, import_node_fs.existsSync)(gitignorePath)) {
54502
+ (0, import_node_fs.writeFileSync)(gitignorePath, entry2 + "\n");
54503
+ return;
54504
+ }
54505
+ const existing = (0, import_node_fs.readFileSync)(gitignorePath, "utf8");
54506
+ const alreadyIgnored = existing.split("\n").map((l) => l.trim()).some((l) => l === ".horus" || l === ".horus/" || l === "/.horus" || l === "/.horus/");
54507
+ if (alreadyIgnored) return;
54508
+ (0, import_node_fs.writeFileSync)(gitignorePath, existing.trimEnd() + "\n" + entry2 + "\n");
54509
+ }
54497
54510
  function patchLocalConnector(configPath, connectorType, patch, envName) {
54498
54511
  const file = readLocalConfig(configPath);
54499
54512
  const project = file.project;
@@ -55086,16 +55099,6 @@ async function analyzeRepo(root) {
55086
55099
  maxBuffer: 64 * 1024 * 1024
55087
55100
  });
55088
55101
  }
55089
- function readAxonHostUrl(root) {
55090
- const p = (0, import_node_path3.join)(root, ".axon", "host.json");
55091
- if (!(0, import_node_fs3.existsSync)(p)) return null;
55092
- try {
55093
- const j = JSON.parse((0, import_node_fs3.readFileSync)(p, "utf8"));
55094
- return typeof j.host_url === "string" ? j.host_url : null;
55095
- } catch {
55096
- return null;
55097
- }
55098
- }
55099
55102
  async function isHostHealthy(hostUrl) {
55100
55103
  try {
55101
55104
  const res = await fetch(`${hostUrl}/api/health`, {
@@ -55377,9 +55380,10 @@ function readSourceHostUrl(root) {
55377
55380
  const j = JSON.parse((0, import_node_fs4.readFileSync)(horusPath, "utf8"));
55378
55381
  if (typeof j.host_url === "string") return j.host_url;
55379
55382
  } catch {
55383
+ return null;
55380
55384
  }
55381
55385
  }
55382
- return readAxonHostUrl(root);
55386
+ return null;
55383
55387
  }
55384
55388
 
55385
55389
  // ../../packages/connectors/src/contract.ts
@@ -67299,6 +67303,7 @@ async function runIndex(opts) {
67299
67303
  };
67300
67304
  const configPath = writeLocalConfig(root, file);
67301
67305
  registerProject(name, root, configPath);
67306
+ ensureProjectGitignore(root);
67302
67307
  console.log(`${import_picocolors3.default.green("\u2713")} Indexed ${import_picocolors3.default.bold(name)} \u2014 host ${hostUrl}`);
67303
67308
  console.log(import_picocolors3.default.dim(` ${configPath}`));
67304
67309
  console.log(
@@ -67306,7 +67311,7 @@ async function runIndex(opts) {
67306
67311
  ` investigate: horus investigate --name ${name} "<hint>" (or from this repo: horus investigate "<hint>")`
67307
67312
  )
67308
67313
  );
67309
- } else if (spawned && !configuredHost) {
67314
+ } else if (!configuredHost) {
67310
67315
  const existingPath = discoverLocalConfig(root);
67311
67316
  if (existingPath) {
67312
67317
  const file = readLocalConfig(existingPath);
@@ -67317,6 +67322,7 @@ async function runIndex(opts) {
67317
67322
  }
67318
67323
  writeLocalConfig(root, file);
67319
67324
  registerProject(label, root, existingPath);
67325
+ ensureProjectGitignore(root);
67320
67326
  console.log(`${import_picocolors3.default.green("\u2713")} Indexed ${import_picocolors3.default.bold(label)} \u2014 source host registered at ${hostUrl}`);
67321
67327
  console.log(import_picocolors3.default.dim(` ${existingPath}`));
67322
67328
  } else {
@@ -73419,10 +73425,21 @@ function formatDateTime(date2) {
73419
73425
  return `${y}-${m}-${day} ${h}:${min} (UTC${sign}${offsetHours}:${offsetMins})`;
73420
73426
  }
73421
73427
 
73428
+ // ../../packages/cli/src/lib/db-url.ts
73429
+ init_cjs_shims();
73430
+ var DEFAULT_DB_URL2 = "postgresql://horus:horus@localhost:5433/horus";
73431
+ async function resolveDbUrl(configPath) {
73432
+ try {
73433
+ const config = await loadConfig(configPath);
73434
+ return config.database.url;
73435
+ } catch {
73436
+ return process.env["DATABASE_URL"] ?? DEFAULT_DB_URL2;
73437
+ }
73438
+ }
73439
+
73422
73440
  // ../../packages/cli/src/commands/investigations.ts
73423
73441
  async function runInvestigations(opts) {
73424
- const config = await loadConfig(opts.config);
73425
- const { db, sql: sql2 } = createDb(config.database.url);
73442
+ const { db, sql: sql2 } = createDb(await resolveDbUrl(opts.config));
73426
73443
  try {
73427
73444
  const rows = await listInvestigations(db, opts.limit ?? 20);
73428
73445
  if (rows.length === 0) {
@@ -73444,8 +73461,7 @@ async function runInvestigations(opts) {
73444
73461
  init_cjs_shims();
73445
73462
  var import_picocolors13 = __toESM(require_picocolors(), 1);
73446
73463
  async function runReplay(id, opts) {
73447
- const config = await loadConfig(opts.config);
73448
- const { db, sql: sql2 } = createDb(config.database.url);
73464
+ const { db, sql: sql2 } = createDb(await resolveDbUrl(opts.config));
73449
73465
  try {
73450
73466
  const row = await getInvestigation(db, id);
73451
73467
  if (!row) {
@@ -73530,8 +73546,7 @@ async function runPostmortem(id, opts) {
73530
73546
  if (opts._report !== void 0) {
73531
73547
  report = opts._report;
73532
73548
  } else {
73533
- const config = await loadConfig(opts.config);
73534
- const conn = createDb(config.database.url);
73549
+ const conn = createDb(await resolveDbUrl(opts.config));
73535
73550
  sql2 = conn.sql;
73536
73551
  const { db } = conn;
73537
73552
  const row = await getInvestigation(db, id);
@@ -73651,8 +73666,7 @@ _AI summary unavailable: ${validationErrors?.[0] ?? "provider error"}_
73651
73666
  init_cjs_shims();
73652
73667
  var import_picocolors16 = __toESM(require_picocolors(), 1);
73653
73668
  async function runScore(id, opts) {
73654
- const config = await loadConfig(opts.config);
73655
- const { db, sql: sql2 } = createDb(config.database.url);
73669
+ const { db, sql: sql2 } = createDb(await resolveDbUrl(opts.config));
73656
73670
  try {
73657
73671
  const row = await getInvestigation(db, id);
73658
73672
  if (!row) {
@@ -73671,8 +73685,7 @@ async function runScore(id, opts) {
73671
73685
  return 0;
73672
73686
  }
73673
73687
  async function runScores(opts) {
73674
- const config = await loadConfig(opts.config);
73675
- const { db, sql: sql2 } = createDb(config.database.url);
73688
+ const { db, sql: sql2 } = createDb(await resolveDbUrl(opts.config));
73676
73689
  try {
73677
73690
  const rows = await listInvestigationsWithReports(db, opts.limit ?? 15);
73678
73691
  const scored = rows.filter((r) => r.report).map((r) => ({
@@ -73704,8 +73717,7 @@ async function runScores(opts) {
73704
73717
  init_cjs_shims();
73705
73718
  var import_picocolors17 = __toESM(require_picocolors(), 1);
73706
73719
  async function runAsk(id, directive, opts) {
73707
- const config = await loadConfig(opts.config);
73708
- const { db, sql: sql2 } = createDb(config.database.url);
73720
+ const { db, sql: sql2 } = createDb(await resolveDbUrl(opts.config));
73709
73721
  try {
73710
73722
  const row = await getInvestigation(db, id);
73711
73723
  if (!row) {
@@ -74242,6 +74254,7 @@ async function runInit(opts) {
74242
74254
  };
74243
74255
  const configPath = writeLocalConfig(root, file);
74244
74256
  registerProject(name, root, configPath);
74257
+ ensureProjectGitignore(root);
74245
74258
  console.log(`${import_picocolors23.default.green("\u2713")} Initialized Horus project ${import_picocolors23.default.bold(name)}`);
74246
74259
  console.log(import_picocolors23.default.dim(` config: ${configPath}`));
74247
74260
  console.log(import_picocolors23.default.dim(` registered: horus investigate --name ${name} "<hint>"`));
@@ -74254,7 +74267,7 @@ async function runInit(opts) {
74254
74267
  import_picocolors23.default.dim(" add runtime connectors (elasticsearch/mongodb/grafana) to .horus/config.json")
74255
74268
  );
74256
74269
  console.log(
74257
- import_picocolors23.default.dim(" safe to commit .horus/config.json \u2014 no secrets stored (keep credentials in environment variables)")
74270
+ import_picocolors23.default.dim(" .horus/ is gitignored \u2014 local config and runtime state stay out of version control")
74258
74271
  );
74259
74272
  return 0;
74260
74273
  } catch (err) {
@@ -74290,7 +74303,7 @@ async function runProjects() {
74290
74303
  // ../../packages/cli/src/commands/setup.ts
74291
74304
  init_cjs_shims();
74292
74305
  var import_picocolors25 = __toESM(require_picocolors(), 1);
74293
- var DEFAULT_DB_URL2 = "postgresql://horus:horus@localhost:5433/horus";
74306
+ var DEFAULT_DB_URL3 = "postgresql://horus:horus@localhost:5433/horus";
74294
74307
  async function runSetup(opts) {
74295
74308
  const write = opts.write ?? ((line2) => console.log(line2));
74296
74309
  let ok = true;
@@ -74322,7 +74335,7 @@ async function runSetup(opts) {
74322
74335
  ` ${import_picocolors25.default.green("\u25CF")} Horus source-intelligence backend ` + import_picocolors25.default.dim(`(${backendVersion})`)
74323
74336
  );
74324
74337
  }
74325
- let dbUrl = process.env["DATABASE_URL"] ?? DEFAULT_DB_URL2;
74338
+ let dbUrl = process.env["DATABASE_URL"] ?? DEFAULT_DB_URL3;
74326
74339
  let config = null;
74327
74340
  try {
74328
74341
  config = await loadConfig(opts.config);
@@ -75381,7 +75394,7 @@ function extractPort2(hostUrl) {
75381
75394
  // ../../packages/cli/src/commands/doctor.ts
75382
75395
  init_cjs_shims();
75383
75396
  var import_picocolors30 = __toESM(require_picocolors(), 1);
75384
- var DEFAULT_DB_URL3 = "postgresql://horus:horus@localhost:5433/horus";
75397
+ var DEFAULT_DB_URL4 = "postgresql://horus:horus@localhost:5433/horus";
75385
75398
  function mark2(status) {
75386
75399
  if (status === "pass") return import_picocolors30.default.green("\u2713");
75387
75400
  if (status === "warn") return import_picocolors30.default.yellow("~");
@@ -75414,11 +75427,11 @@ async function runDoctor(opts) {
75414
75427
  const file = readLocalConfig(configPath);
75415
75428
  const project = file.project;
75416
75429
  const repos = project["repositories"];
75417
- const hasHost = repos?.some(
75430
+ const hostUrl = repos?.map(
75418
75431
  (r) => r["source"]?.["hostUrl"] ?? r["axon"]?.["hostUrl"]
75419
- );
75420
- if (hasHost) {
75421
- checks.push({ label: "Source-intelligence host", status: "pass", detail: "configured" });
75432
+ ).find(Boolean);
75433
+ if (hostUrl) {
75434
+ checks.push({ label: "Source-intelligence host", status: "pass", detail: hostUrl });
75422
75435
  } else {
75423
75436
  checks.push({
75424
75437
  label: "Source-intelligence host",
@@ -75451,7 +75464,7 @@ async function runDoctor(opts) {
75451
75464
  }
75452
75465
  {
75453
75466
  const dbChecker = opts?._dbCheck ?? checkDatabase;
75454
- let dbUrl = process.env["DATABASE_URL"] ?? DEFAULT_DB_URL3;
75467
+ let dbUrl = process.env["DATABASE_URL"] ?? DEFAULT_DB_URL4;
75455
75468
  let globalConfig = null;
75456
75469
  try {
75457
75470
  globalConfig = await loadConfig(opts?.config, { cwd });
@@ -75767,7 +75780,7 @@ async function runGenerateConfig(opts) {
75767
75780
  // ../../packages/cli/src/commands/readiness.ts
75768
75781
  init_cjs_shims();
75769
75782
  var import_picocolors33 = __toESM(require_picocolors(), 1);
75770
- var DEFAULT_DB_URL4 = "postgresql://horus:horus@localhost:5433/horus";
75783
+ var DEFAULT_DB_URL5 = "postgresql://horus:horus@localhost:5433/horus";
75771
75784
  function mark3(status) {
75772
75785
  if (status === "pass") return import_picocolors33.default.green("\u2713");
75773
75786
  if (status === "warn") return import_picocolors33.default.yellow("~");
@@ -75791,7 +75804,7 @@ async function runReadiness(opts) {
75791
75804
  globalConfig = await configLoader(opts?.config, { cwd });
75792
75805
  } catch {
75793
75806
  }
75794
- const dbUrl = globalConfig?.database.url ?? process.env["DATABASE_URL"] ?? DEFAULT_DB_URL4;
75807
+ const dbUrl = globalConfig?.database.url ?? process.env["DATABASE_URL"] ?? DEFAULT_DB_URL5;
75795
75808
  const db = await dbChecker(dbUrl);
75796
75809
  if (!db.reachable) {
75797
75810
  checks.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merittdev/horus",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Local-first, source-aware production-incident investigation engine",
5
5
  "type": "module",
6
6
  "bin": {