haansi 0.1.26 → 0.1.28
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 +90 -32
- 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.28",
|
|
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
|
|
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 = {
|
|
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
|
-
(
|
|
946
|
-
} catch {
|
|
962
|
+
git(["rev-parse", "--is-inside-work-tree"]);
|
|
963
|
+
} catch (err) {
|
|
964
|
+
logger.warn("Git metadata skipped \u2014 cwd not a resolvable git repo", {
|
|
965
|
+
projectDir,
|
|
966
|
+
reason: err?.code === "ENOENT" ? "cwd-missing" : err?.status === 128 ? "not-a-git-repo" : "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 = (
|
|
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 = (
|
|
961
|
-
|
|
962
|
-
{
|
|
963
|
-
|
|
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 = (
|
|
991
|
+
result.gitCommit = git(["rev-parse", "HEAD"]) || null;
|
|
970
992
|
} catch {
|
|
971
993
|
}
|
|
972
994
|
}
|
|
973
995
|
try {
|
|
974
|
-
result.gitBranch = (
|
|
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
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
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)`,
|
|
@@ -51185,7 +51219,7 @@ var require_view = __commonJS({
|
|
|
51185
51219
|
var debug = require_src()("express:view");
|
|
51186
51220
|
var path = require("node:path");
|
|
51187
51221
|
var fs = require("node:fs");
|
|
51188
|
-
var
|
|
51222
|
+
var dirname3 = path.dirname;
|
|
51189
51223
|
var basename3 = path.basename;
|
|
51190
51224
|
var extname = path.extname;
|
|
51191
51225
|
var join12 = path.join;
|
|
@@ -51224,7 +51258,7 @@ var require_view = __commonJS({
|
|
|
51224
51258
|
for (var i = 0; i < roots.length && !path2; i++) {
|
|
51225
51259
|
var root = roots[i];
|
|
51226
51260
|
var loc = resolve4(root, name);
|
|
51227
|
-
var dir =
|
|
51261
|
+
var dir = dirname3(loc);
|
|
51228
51262
|
var file2 = basename3(loc);
|
|
51229
51263
|
path2 = this.resolve(dir, file2);
|
|
51230
51264
|
}
|
|
@@ -57896,6 +57930,29 @@ function findHaansiBin() {
|
|
|
57896
57930
|
);
|
|
57897
57931
|
}
|
|
57898
57932
|
}
|
|
57933
|
+
function warnIfStaleDevBundle(haansiPath) {
|
|
57934
|
+
try {
|
|
57935
|
+
const bundle = (0, import_node_fs6.realpathSync)(haansiPath);
|
|
57936
|
+
const repoRoot = (0, import_node_path5.dirname)((0, import_node_path5.dirname)((0, import_node_path5.dirname)((0, import_node_path5.dirname)(bundle))));
|
|
57937
|
+
const sources = [
|
|
57938
|
+
"apps/service-capture/claude-sessions/collector.ts",
|
|
57939
|
+
"apps/service-capture/claude-sessions/collector-daemon.ts",
|
|
57940
|
+
"apps/service-capture/common/agents/codex.ts",
|
|
57941
|
+
"apps/service-capture/common/agents/claude-code.ts"
|
|
57942
|
+
].map((p) => (0, import_node_path5.join)(repoRoot, p));
|
|
57943
|
+
if (!(0, import_node_fs6.existsSync)(sources[0])) return;
|
|
57944
|
+
const bundleMtime = (0, import_node_fs6.statSync)(bundle).mtimeMs;
|
|
57945
|
+
const newestSrc = Math.max(
|
|
57946
|
+
...sources.filter(import_node_fs6.existsSync).map((p) => (0, import_node_fs6.statSync)(p).mtimeMs)
|
|
57947
|
+
);
|
|
57948
|
+
if (newestSrc > bundleMtime) {
|
|
57949
|
+
console.warn(
|
|
57950
|
+
"\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"
|
|
57951
|
+
);
|
|
57952
|
+
}
|
|
57953
|
+
} catch {
|
|
57954
|
+
}
|
|
57955
|
+
}
|
|
57899
57956
|
function buildPlist(haansiPath) {
|
|
57900
57957
|
const binDir = haansiPath.replace(/\/[^/]+$/, "");
|
|
57901
57958
|
const path = `${binDir}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`;
|
|
@@ -57942,6 +57999,7 @@ async function setupDaemon(uninstall) {
|
|
|
57942
57999
|
return;
|
|
57943
58000
|
}
|
|
57944
58001
|
const haansiPath = findHaansiBin();
|
|
58002
|
+
warnIfStaleDevBundle(haansiPath);
|
|
57945
58003
|
(0, import_node_fs6.mkdirSync)((0, import_node_path5.join)((0, import_node_os5.homedir)(), ".haansi"), { recursive: true });
|
|
57946
58004
|
(0, import_node_fs6.writeFileSync)(PLIST_PATH, buildPlist(haansiPath), "utf-8");
|
|
57947
58005
|
try {
|