haansi 0.1.11 → 0.1.12
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.
- package/dist/haansi.js +50 -12
- 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.
|
|
42
|
+
version: "0.1.12",
|
|
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
|
-
|
|
581
|
-
|
|
582
|
-
|
|
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
|
|
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,
|
|
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
|
-
|
|
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;
|
|
602
628
|
}
|
|
629
|
+
if (!result.gitBranch && entry.gitBranch && typeof entry.gitBranch === "string") {
|
|
630
|
+
result.gitBranch = entry.gitBranch;
|
|
631
|
+
}
|
|
632
|
+
if (result.cwd && result.timestamp && result.gitBranch) break;
|
|
603
633
|
} catch {
|
|
604
634
|
}
|
|
605
635
|
}
|
|
606
636
|
} catch {
|
|
607
637
|
}
|
|
608
|
-
return
|
|
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
|
|
740
|
-
const gitInfo = cwd ? extractGitInfo(
|
|
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)`,
|