haansi 0.1.11 → 0.1.13

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 +56 -12
  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.11",
42
+ version: "0.1.13",
43
43
  description: "Haansi CLI - Session collector and MCP server for Claude Code",
44
44
  bin: {
45
45
  haansi: "./dist/haansi.js"
@@ -557,7 +557,7 @@ function edgeScrub(content) {
557
557
  }
558
558
  return result;
559
559
  }
560
- function extractGitInfo(projectDir) {
560
+ function extractGitInfo(projectDir, sessionTimestamp, sessionBranch) {
561
561
  const empty = {
562
562
  gitRemoteUrl: null,
563
563
  gitCommit: null,
@@ -567,6 +567,7 @@ function extractGitInfo(projectDir) {
567
567
  try {
568
568
  (0, import_child_process.execSync)("git rev-parse --is-inside-work-tree", { ...opts, stdio: "pipe" });
569
569
  } catch {
570
+ console.warn(`[collector] Not a git repo: ${projectDir}`);
570
571
  return empty;
571
572
  }
572
573
  const result = { ...empty };
@@ -576,10 +577,24 @@ function extractGitInfo(projectDir) {
576
577
  stdio: "pipe"
577
578
  }).trim() || null;
578
579
  } catch {
580
+ console.warn(`[collector] No git remote for: ${projectDir}`);
579
581
  }
580
- try {
581
- result.gitCommit = (0, import_child_process.execSync)("git rev-parse HEAD", { ...opts, stdio: "pipe" }).trim() || null;
582
- } catch {
582
+ if (sessionTimestamp) {
583
+ const branch = sessionBranch ?? "HEAD";
584
+ try {
585
+ result.gitCommit = (0, import_child_process.execSync)(
586
+ `git log --before="${sessionTimestamp}" -1 --format=%H ${branch}`,
587
+ { ...opts, stdio: "pipe" }
588
+ ).trim() || null;
589
+ } catch {
590
+ }
591
+ }
592
+ if (!result.gitCommit) {
593
+ try {
594
+ result.gitCommit = (0, import_child_process.execSync)("git rev-parse HEAD", { ...opts, stdio: "pipe" }).trim() || null;
595
+ } catch {
596
+ console.warn(`[collector] No git commits in: ${projectDir}`);
597
+ }
583
598
  }
584
599
  try {
585
600
  result.gitBranch = (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
@@ -588,24 +603,39 @@ function extractGitInfo(projectDir) {
588
603
  }).trim() || null;
589
604
  } catch {
590
605
  }
606
+ if (!result.gitBranch && sessionBranch) {
607
+ result.gitBranch = sessionBranch;
608
+ }
591
609
  return result;
592
610
  }
593
- function extractCwdFromJsonl(filePath) {
611
+ function extractSessionMeta(filePath) {
612
+ const result = {
613
+ cwd: null,
614
+ timestamp: null,
615
+ gitBranch: null
616
+ };
594
617
  try {
595
618
  const content = (0, import_fs.readFileSync)(filePath, "utf-8");
596
- const lines = content.split("\n").filter((l) => l.trim()).slice(0, 10);
619
+ const lines = content.split("\n").filter((l) => l.trim()).slice(0, 50);
597
620
  for (const line of lines) {
598
621
  try {
599
622
  const entry = JSON.parse(line);
600
- if (entry.cwd && typeof entry.cwd === "string") {
601
- return entry.cwd;
623
+ if (!result.cwd && entry.cwd && typeof entry.cwd === "string") {
624
+ result.cwd = entry.cwd;
625
+ }
626
+ if (!result.timestamp && entry.timestamp && typeof entry.timestamp === "string") {
627
+ result.timestamp = entry.timestamp;
628
+ }
629
+ if (!result.gitBranch && entry.gitBranch && typeof entry.gitBranch === "string") {
630
+ result.gitBranch = entry.gitBranch;
602
631
  }
632
+ if (result.cwd && result.timestamp && result.gitBranch) break;
603
633
  } catch {
604
634
  }
605
635
  }
606
636
  } catch {
607
637
  }
608
- return null;
638
+ return result;
609
639
  }
610
640
  function resolveToken() {
611
641
  if (process.env.HAANSI_TOKEN) return process.env.HAANSI_TOKEN;
@@ -736,8 +766,16 @@ async function collect(options) {
736
766
  try {
737
767
  const rawContent = (0, import_fs.readFileSync)(session.filePath, "utf-8");
738
768
  const scrubbed = edgeScrub(rawContent);
739
- const cwd = extractCwdFromJsonl(session.filePath);
740
- const gitInfo = cwd ? extractGitInfo(cwd) : { gitRemoteUrl: null, gitCommit: null, gitBranch: null };
769
+ const sessionMeta = extractSessionMeta(session.filePath);
770
+ const gitInfo = sessionMeta.cwd ? extractGitInfo(
771
+ sessionMeta.cwd,
772
+ sessionMeta.timestamp ?? void 0,
773
+ sessionMeta.gitBranch ?? void 0
774
+ ) : {
775
+ gitRemoteUrl: null,
776
+ gitCommit: null,
777
+ gitBranch: sessionMeta.gitBranch
778
+ };
741
779
  if (options.dryRun) {
742
780
  logger.info(
743
781
  `[dry-run] Would upload ${shortId} (${session.lineCount} lines)`,
@@ -56877,6 +56915,10 @@ var init_mcp_server2 = __esm({
56877
56915
  type: "string",
56878
56916
  description: "Git remote origin URL (e.g. github.com/org/repo)"
56879
56917
  },
56918
+ git_commit: {
56919
+ type: "string",
56920
+ description: "Git commit hash for the code changes"
56921
+ },
56880
56922
  tags: {
56881
56923
  type: "array",
56882
56924
  items: { type: "string" },
@@ -56974,6 +57016,7 @@ var init_mcp_server2 = __esm({
56974
57016
  project_path,
56975
57017
  git_branch,
56976
57018
  git_remote_url,
57019
+ git_commit,
56977
57020
  tags,
56978
57021
  model,
56979
57022
  source_tool,
@@ -56999,6 +57042,7 @@ var init_mcp_server2 = __esm({
56999
57042
  project_path,
57000
57043
  git_branch,
57001
57044
  git_remote_url,
57045
+ git_commit,
57002
57046
  tags,
57003
57047
  model,
57004
57048
  source_tool
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"