haansi 0.1.27 → 0.1.29

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/haansi.js +68 -8
  2. package/package.json +1 -1
package/dist/haansi.js CHANGED
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  "package.json"(exports2, module2) {
40
40
  module2.exports = {
41
41
  name: "haansi",
42
- version: "0.1.27",
42
+ version: "0.1.29",
43
43
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
44
44
  bin: {
45
45
  haansi: "./dist/haansi.js"
@@ -945,25 +945,55 @@ function edgeScrub(content) {
945
945
  }
946
946
  return result;
947
947
  }
948
+ function resolveGitBin() {
949
+ if (resolvedGitBin !== void 0) return resolvedGitBin;
950
+ for (const bin of GIT_BIN_CANDIDATES) {
951
+ try {
952
+ (0, import_child_process.execFileSync)(bin, ["--version"], { timeout: 5e3, stdio: "pipe" });
953
+ resolvedGitBin = bin;
954
+ return bin;
955
+ } catch {
956
+ }
957
+ }
958
+ resolvedGitBin = null;
959
+ return null;
960
+ }
961
+ function effectiveGitDir(cwd) {
962
+ if ((0, import_fs3.existsSync)(cwd)) return cwd;
963
+ const m = cwd.match(/^(.*)\/\.claude\/worktrees\/[^/]+/);
964
+ if (m && (0, import_fs3.existsSync)(m[1])) return m[1];
965
+ return cwd;
966
+ }
948
967
  function extractGitInfo(projectDir, sessionTimestamp, sessionBranch) {
949
968
  const empty = {
950
969
  gitRemoteUrl: null,
951
970
  gitCommit: null,
952
971
  gitBranch: null
953
972
  };
973
+ const gitBin = resolveGitBin();
974
+ if (!gitBin) {
975
+ logger.warn("Git metadata skipped \u2014 git binary not found", {
976
+ projectDir,
977
+ reason: "git-not-on-path",
978
+ tried: GIT_BIN_CANDIDATES
979
+ });
980
+ return empty;
981
+ }
982
+ const dir = effectiveGitDir(projectDir);
954
983
  const opts = {
955
- cwd: projectDir,
984
+ cwd: dir,
956
985
  timeout: 5e3,
957
986
  encoding: "utf-8",
958
987
  stdio: "pipe"
959
988
  };
960
- const git = (args) => (0, import_child_process.execFileSync)("git", args, opts).trim();
989
+ const git = (args) => (0, import_child_process.execFileSync)(gitBin, args, opts).trim();
961
990
  try {
962
991
  git(["rev-parse", "--is-inside-work-tree"]);
963
992
  } catch (err) {
964
- logger.warn("Git metadata skipped \u2014 not a resolvable git repo", {
993
+ logger.warn("Git metadata skipped \u2014 cwd not a resolvable git repo", {
965
994
  projectDir,
966
- reason: err?.code === "ENOENT" ? "git-not-on-path" : err?.status === 128 ? "not-a-git-repo-or-missing-dir" : "git-check-failed",
995
+ resolvedDir: dir,
996
+ reason: err?.code === "ENOENT" ? "cwd-missing" : err?.status === 128 ? "not-a-git-repo" : "git-check-failed",
967
997
  error: err?.message?.slice(0, 200)
968
998
  });
969
999
  return empty;
@@ -1205,7 +1235,7 @@ async function main() {
1205
1235
  });
1206
1236
  if (errors > 0) process.exit(1);
1207
1237
  }
1208
- var import_dotenv, import_path3, import_fs3, import_os3, import_zlib, import_child_process, logger, DEFAULT_API_URL3, CREDENTIALS_FILE3, MIN_LINES, EDGE_SCRUB_PATTERNS;
1238
+ var import_dotenv, import_path3, import_fs3, import_os3, import_zlib, import_child_process, logger, DEFAULT_API_URL3, CREDENTIALS_FILE3, MIN_LINES, EDGE_SCRUB_PATTERNS, GIT_BIN_CANDIDATES, resolvedGitBin;
1209
1239
  var init_collector = __esm({
1210
1240
  "../service-capture/claude-sessions/collector.ts"() {
1211
1241
  "use strict";
@@ -1261,6 +1291,12 @@ var init_collector = __esm({
1261
1291
  replacement: "[REDACTED:API_KEY]"
1262
1292
  }
1263
1293
  ];
1294
+ GIT_BIN_CANDIDATES = [
1295
+ "git",
1296
+ "/opt/homebrew/bin/git",
1297
+ "/usr/local/bin/git",
1298
+ "/usr/bin/git"
1299
+ ];
1264
1300
  if (require.main === module) {
1265
1301
  main().catch((err) => {
1266
1302
  logger.error("Collector failed", err);
@@ -51219,7 +51255,7 @@ var require_view = __commonJS({
51219
51255
  var debug = require_src()("express:view");
51220
51256
  var path = require("node:path");
51221
51257
  var fs = require("node:fs");
51222
- var dirname2 = path.dirname;
51258
+ var dirname3 = path.dirname;
51223
51259
  var basename3 = path.basename;
51224
51260
  var extname = path.extname;
51225
51261
  var join12 = path.join;
@@ -51258,7 +51294,7 @@ var require_view = __commonJS({
51258
51294
  for (var i = 0; i < roots.length && !path2; i++) {
51259
51295
  var root = roots[i];
51260
51296
  var loc = resolve4(root, name);
51261
- var dir = dirname2(loc);
51297
+ var dir = dirname3(loc);
51262
51298
  var file2 = basename3(loc);
51263
51299
  path2 = this.resolve(dir, file2);
51264
51300
  }
@@ -57930,6 +57966,29 @@ function findHaansiBin() {
57930
57966
  );
57931
57967
  }
57932
57968
  }
57969
+ function warnIfStaleDevBundle(haansiPath) {
57970
+ try {
57971
+ const bundle = (0, import_node_fs6.realpathSync)(haansiPath);
57972
+ const repoRoot = (0, import_node_path5.dirname)((0, import_node_path5.dirname)((0, import_node_path5.dirname)((0, import_node_path5.dirname)(bundle))));
57973
+ const sources = [
57974
+ "apps/service-capture/claude-sessions/collector.ts",
57975
+ "apps/service-capture/claude-sessions/collector-daemon.ts",
57976
+ "apps/service-capture/common/agents/codex.ts",
57977
+ "apps/service-capture/common/agents/claude-code.ts"
57978
+ ].map((p) => (0, import_node_path5.join)(repoRoot, p));
57979
+ if (!(0, import_node_fs6.existsSync)(sources[0])) return;
57980
+ const bundleMtime = (0, import_node_fs6.statSync)(bundle).mtimeMs;
57981
+ const newestSrc = Math.max(
57982
+ ...sources.filter(import_node_fs6.existsSync).map((p) => (0, import_node_fs6.statSync)(p).mtimeMs)
57983
+ );
57984
+ if (newestSrc > bundleMtime) {
57985
+ console.warn(
57986
+ "\n\u26A0\uFE0F The compiled CLI bundle is OLDER than the collector source.\n The daemon runs the bundle, so it would start with stale code.\n Rebuild first: npm run build --workspace apps/cli\n then re-run: haansi setup-daemon\n"
57987
+ );
57988
+ }
57989
+ } catch {
57990
+ }
57991
+ }
57933
57992
  function buildPlist(haansiPath) {
57934
57993
  const binDir = haansiPath.replace(/\/[^/]+$/, "");
57935
57994
  const path = `${binDir}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`;
@@ -57976,6 +58035,7 @@ async function setupDaemon(uninstall) {
57976
58035
  return;
57977
58036
  }
57978
58037
  const haansiPath = findHaansiBin();
58038
+ warnIfStaleDevBundle(haansiPath);
57979
58039
  (0, import_node_fs6.mkdirSync)((0, import_node_path5.join)((0, import_node_os5.homedir)(), ".haansi"), { recursive: true });
57980
58040
  (0, import_node_fs6.writeFileSync)(PLIST_PATH, buildPlist(haansiPath), "utf-8");
57981
58041
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"