@riconext/hermes-repo 0.13.0 → 0.13.2
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/cli.js +45 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -201,10 +201,36 @@ function serializeLlmConfig(cfg) {
|
|
|
201
201
|
import { readFileSync as readFileSync3 } from "fs";
|
|
202
202
|
import { basename } from "path";
|
|
203
203
|
var FILE_CHANGE_TOOLS = /^(Write|Edit|MultiEdit|NotebookEdit|write|edit)$/i;
|
|
204
|
+
var SKIP_LINE_TYPES = /* @__PURE__ */ new Set([
|
|
205
|
+
"file-history-snapshot",
|
|
206
|
+
"summary",
|
|
207
|
+
"function_call_result"
|
|
208
|
+
]);
|
|
209
|
+
function textFromContentParts(content) {
|
|
210
|
+
if (!Array.isArray(content)) {
|
|
211
|
+
return "";
|
|
212
|
+
}
|
|
213
|
+
return content.map((part) => {
|
|
214
|
+
if (!part || typeof part !== "object") {
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
217
|
+
const p = part;
|
|
218
|
+
if (typeof p.text === "string") {
|
|
219
|
+
return p.text;
|
|
220
|
+
}
|
|
221
|
+
return "";
|
|
222
|
+
}).filter(Boolean).join("\n");
|
|
223
|
+
}
|
|
204
224
|
function extractText(record) {
|
|
205
225
|
if (typeof record.content === "string") {
|
|
206
226
|
return record.content;
|
|
207
227
|
}
|
|
228
|
+
if (Array.isArray(record.content)) {
|
|
229
|
+
const top = textFromContentParts(record.content);
|
|
230
|
+
if (top) {
|
|
231
|
+
return top;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
208
234
|
const message = record.message;
|
|
209
235
|
if (message && typeof message === "object") {
|
|
210
236
|
const msg = message;
|
|
@@ -212,12 +238,7 @@ function extractText(record) {
|
|
|
212
238
|
return msg.content;
|
|
213
239
|
}
|
|
214
240
|
if (Array.isArray(msg.content)) {
|
|
215
|
-
return msg.content
|
|
216
|
-
if (part && typeof part === "object" && "text" in part) {
|
|
217
|
-
return String(part.text);
|
|
218
|
-
}
|
|
219
|
-
return "";
|
|
220
|
-
}).join("\n");
|
|
241
|
+
return textFromContentParts(msg.content);
|
|
221
242
|
}
|
|
222
243
|
}
|
|
223
244
|
return "";
|
|
@@ -233,9 +254,13 @@ function inferRole(record) {
|
|
|
233
254
|
}
|
|
234
255
|
return "unknown";
|
|
235
256
|
}
|
|
257
|
+
function isSkippedLine(record) {
|
|
258
|
+
const t = String(record.type ?? "").toLowerCase();
|
|
259
|
+
return SKIP_LINE_TYPES.has(t);
|
|
260
|
+
}
|
|
236
261
|
function isToolUse(record) {
|
|
237
262
|
const t = String(record.type ?? "").toLowerCase();
|
|
238
|
-
return t === "tool_use" || t === "tool";
|
|
263
|
+
return t === "tool_use" || t === "tool" || t === "function_call";
|
|
239
264
|
}
|
|
240
265
|
function toolName(record) {
|
|
241
266
|
if (typeof record.name === "string") return record.name;
|
|
@@ -284,6 +309,9 @@ function parseJsonlFile(jsonlPath) {
|
|
|
284
309
|
if (!trimmed) continue;
|
|
285
310
|
try {
|
|
286
311
|
const record = JSON.parse(trimmed);
|
|
312
|
+
if (isSkippedLine(record)) {
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
287
315
|
if (isToolUse(record)) {
|
|
288
316
|
toolCalls += 1;
|
|
289
317
|
const name = toolName(record);
|
|
@@ -907,6 +935,7 @@ function parseHookInputJson(raw) {
|
|
|
907
935
|
const transcriptPath = transcriptRaw && existsSync6(transcriptRaw) ? resolve2(transcriptRaw) : void 0;
|
|
908
936
|
return {
|
|
909
937
|
transcriptPath,
|
|
938
|
+
transcriptPathRaw: transcriptRaw,
|
|
910
939
|
hookEventName: pickString(parsed, "hook_event_name", "hookEventName"),
|
|
911
940
|
sessionId: pickString(parsed, "session_id", "sessionId"),
|
|
912
941
|
conversationId: pickString(parsed, "conversation_id", "conversationId"),
|
|
@@ -932,7 +961,7 @@ function isCodebuddyCaptureHook(hook) {
|
|
|
932
961
|
if (!hook) {
|
|
933
962
|
return false;
|
|
934
963
|
}
|
|
935
|
-
return isTranscriptUnderAssistant(hook.transcriptPath, ".codebuddy");
|
|
964
|
+
return isTranscriptUnderAssistant(hook.transcriptPath, ".codebuddy") || isTranscriptUnderAssistant(hook.transcriptPathRaw, ".codebuddy");
|
|
936
965
|
}
|
|
937
966
|
function isClaudeCaptureHook(hook) {
|
|
938
967
|
if (!hook) {
|
|
@@ -3498,6 +3527,14 @@ function runCaptureCommand(opts) {
|
|
|
3498
3527
|
const debug = ctx?.config.debug === true;
|
|
3499
3528
|
configureDebugLogging(ctx?.repoRoot ?? null, debug);
|
|
3500
3529
|
const hookInput = readHookInputSync();
|
|
3530
|
+
if (hookInput && isCodebuddyCaptureHook(hookInput)) {
|
|
3531
|
+
const stdinPath = hookInput.transcriptPathRaw ?? hookInput.transcriptPath ?? "(missing)";
|
|
3532
|
+
debugLog(
|
|
3533
|
+
debug,
|
|
3534
|
+
"capture",
|
|
3535
|
+
`codebuddy stop stdin transcript_path=${stdinPath}`
|
|
3536
|
+
);
|
|
3537
|
+
}
|
|
3501
3538
|
finalizeHookCommand(async () => {
|
|
3502
3539
|
await runCapture({
|
|
3503
3540
|
cwd: opts.cwd,
|