haansi 0.1.26 → 0.1.27

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 +64 -30
  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.26",
42
+ version: "0.1.27",
43
43
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
44
44
  bin: {
45
45
  haansi: "./dist/haansi.js"
@@ -807,6 +807,8 @@ function readRolloutMeta(filePath, content) {
807
807
  let cwd = null;
808
808
  let timestamp = null;
809
809
  let gitBranch = null;
810
+ let gitRemoteUrl = null;
811
+ let gitCommit = null;
810
812
  let metaId = null;
811
813
  const lines = content.split("\n").filter((l) => l.trim()).slice(0, 50);
812
814
  for (const line of lines) {
@@ -819,10 +821,15 @@ function readRolloutMeta(filePath, content) {
819
821
  if (entry.type === "session_meta") {
820
822
  if (typeof p.cwd === "string") cwd = p.cwd;
821
823
  if (typeof p.id === "string") metaId = p.id;
822
- const branch = p.git?.branch ?? p.git_branch;
824
+ const g = p.git ?? {};
825
+ const branch = g.branch ?? p.git_branch;
823
826
  if (typeof branch === "string") gitBranch = branch;
827
+ const remote = g.repository_url ?? g.remote_url;
828
+ if (typeof remote === "string") gitRemoteUrl = remote;
829
+ const commit = g.commit_hash ?? g.commit;
830
+ if (typeof commit === "string") gitCommit = commit;
824
831
  }
825
- if (cwd && gitBranch && timestamp && metaId) break;
832
+ if (cwd && gitBranch && gitCommit && timestamp && metaId) break;
826
833
  } catch {
827
834
  }
828
835
  }
@@ -830,7 +837,9 @@ function readRolloutMeta(filePath, content) {
830
837
  sessionId: fromName ?? metaId ?? fileName,
831
838
  cwd,
832
839
  timestamp,
833
- gitBranch
840
+ gitBranch,
841
+ gitRemoteUrl,
842
+ gitCommit
834
843
  };
835
844
  }
836
845
  var import_fs2, import_path2, import_os2, UUID_RE, codexAgent;
@@ -869,7 +878,9 @@ var init_codex = __esm({
869
878
  sizeBytes: stat.size,
870
879
  cwd: meta3.cwd,
871
880
  timestamp: meta3.timestamp,
872
- gitBranch: meta3.gitBranch
881
+ gitBranch: meta3.gitBranch,
882
+ gitRemoteUrl: meta3.gitRemoteUrl,
883
+ gitCommit: meta3.gitCommit
873
884
  });
874
885
  } catch {
875
886
  }
@@ -940,41 +951,49 @@ function extractGitInfo(projectDir, sessionTimestamp, sessionBranch) {
940
951
  gitCommit: null,
941
952
  gitBranch: null
942
953
  };
943
- const opts = { cwd: projectDir, timeout: 5e3, encoding: "utf-8" };
954
+ const opts = {
955
+ cwd: projectDir,
956
+ timeout: 5e3,
957
+ encoding: "utf-8",
958
+ stdio: "pipe"
959
+ };
960
+ const git = (args) => (0, import_child_process.execFileSync)("git", args, opts).trim();
944
961
  try {
945
- (0, import_child_process.execSync)("git rev-parse --is-inside-work-tree", { ...opts, stdio: "pipe" });
946
- } catch {
962
+ git(["rev-parse", "--is-inside-work-tree"]);
963
+ } catch (err) {
964
+ logger.warn("Git metadata skipped \u2014 not a resolvable git repo", {
965
+ projectDir,
966
+ reason: err?.code === "ENOENT" ? "git-not-on-path" : err?.status === 128 ? "not-a-git-repo-or-missing-dir" : "git-check-failed",
967
+ error: err?.message?.slice(0, 200)
968
+ });
947
969
  return empty;
948
970
  }
949
971
  const result = { ...empty };
950
972
  try {
951
- result.gitRemoteUrl = (0, import_child_process.execSync)("git remote get-url origin", {
952
- ...opts,
953
- stdio: "pipe"
954
- }).trim() || null;
973
+ result.gitRemoteUrl = git(["remote", "get-url", "origin"]) || null;
955
974
  } catch {
956
975
  }
957
976
  if (sessionTimestamp) {
958
977
  const branch = sessionBranch ?? "HEAD";
959
978
  try {
960
- result.gitCommit = (0, import_child_process.execSync)(
961
- `git log --before="${sessionTimestamp}" -1 --format=%H ${branch}`,
962
- { ...opts, stdio: "pipe" }
963
- ).trim() || null;
979
+ result.gitCommit = git([
980
+ "log",
981
+ `--before=${sessionTimestamp}`,
982
+ "-1",
983
+ "--format=%H",
984
+ branch
985
+ ]) || null;
964
986
  } catch {
965
987
  }
966
988
  }
967
989
  if (!result.gitCommit) {
968
990
  try {
969
- result.gitCommit = (0, import_child_process.execSync)("git rev-parse HEAD", { ...opts, stdio: "pipe" }).trim() || null;
991
+ result.gitCommit = git(["rev-parse", "HEAD"]) || null;
970
992
  } catch {
971
993
  }
972
994
  }
973
995
  try {
974
- result.gitBranch = (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
975
- ...opts,
976
- stdio: "pipe"
977
- }).trim() || null;
996
+ result.gitBranch = git(["rev-parse", "--abbrev-ref", "HEAD"]) || null;
978
997
  } catch {
979
998
  }
980
999
  if (!result.gitBranch && sessionBranch) {
@@ -1113,15 +1132,30 @@ async function collect(options) {
1113
1132
  try {
1114
1133
  const rawContent = (0, import_fs3.readFileSync)(session.filePath, "utf-8");
1115
1134
  const scrubbed = edgeScrub(rawContent);
1116
- const gitInfo = session.cwd ? extractGitInfo(
1117
- session.cwd,
1118
- session.timestamp ?? void 0,
1119
- session.gitBranch ?? void 0
1120
- ) : {
1121
- gitRemoteUrl: null,
1122
- gitCommit: null,
1123
- gitBranch: session.gitBranch
1124
- };
1135
+ let gitInfo;
1136
+ if (session.gitRemoteUrl || session.gitCommit) {
1137
+ gitInfo = {
1138
+ gitRemoteUrl: session.gitRemoteUrl ?? null,
1139
+ gitCommit: session.gitCommit ?? null,
1140
+ gitBranch: session.gitBranch
1141
+ };
1142
+ } else if (session.cwd) {
1143
+ gitInfo = extractGitInfo(
1144
+ session.cwd,
1145
+ session.timestamp ?? void 0,
1146
+ session.gitBranch ?? void 0
1147
+ );
1148
+ } else {
1149
+ logger.warn("Git metadata skipped \u2014 no cwd resolved for session", {
1150
+ sessionId: shortId,
1151
+ agentSource: session.agentId
1152
+ });
1153
+ gitInfo = {
1154
+ gitRemoteUrl: null,
1155
+ gitCommit: null,
1156
+ gitBranch: session.gitBranch
1157
+ };
1158
+ }
1125
1159
  if (options.dryRun) {
1126
1160
  logger.info(
1127
1161
  `[dry-run] Would upload ${shortId} (${session.agentId}, ${session.lineCount} lines)`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"