Skip to content

Commit 4e4f7fb

Browse files
committed
fix: handle Codex exec command hook input
Jieli-Thread: http://127.0.0.1:8080/threads/T-019ec058-99fd-75e0-b0fa-104e33f49a5c
1 parent 340dbce commit 4e4f7fb

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

plugins/codex/.codex-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jieli",
3-
"version": "0.1.16",
3+
"version": "0.1.17",
44
"description": "Sync Codex sessions to Jieli threads and attach Jieli thread trailers to Codex-created commits.",
55
"author": {
66
"name": "Jieli"

plugins/codex/scripts/jieli_node.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ function commitTrailerMain(args) {
12041204

12051205
function buildHookResponse(hookData) {
12061206
if (!["Bash", "Shell", "shell_command", "exec_command"].includes(hookData.tool_name)) return {};
1207-
const command = hookData.tool_input?.command;
1207+
const commandKey = typeof hookData.tool_input?.cmd === "string" ? "cmd" : "command";
1208+
const command = hookData.tool_input?.[commandKey];
12081209
if (typeof command !== "string" || !command) return {};
12091210
let updated = updatedHandoffCommand(command, hookData);
12101211
if (!updated) updated = updatedCommitCommand(command, hookData.session_id || "");
@@ -1213,7 +1214,7 @@ function buildHookResponse(hookData) {
12131214
hookSpecificOutput: {
12141215
hookEventName: "PreToolUse",
12151216
permissionDecision: "allow",
1216-
updatedInput: { command: updated },
1217+
updatedInput: { [commandKey]: updated },
12171218
},
12181219
};
12191220
}

plugins/codex/tests/runtime-node.test.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ test("handoff info and commit trailer helpers support Codex shell aliases and No
476476
assert.match(updated, /node .*jieli_node\.mjs handoff-info --context-b64 /);
477477
assert.deepEqual(decodeHandoffContext(updated), { session_id: "codex-handoff", transcript_path: "/tmp/codex-session.jsonl", cwd: "/repo" });
478478
}
479+
const codexExecResponse = runtime.buildHookResponse({ session_id: "codex-exec", transcript_path: "/tmp/codex-exec.jsonl", cwd: "/repo", tool_name: "exec_command", tool_input: { cmd: "jieli-handoff-info" } });
480+
const codexExecCommand = codexExecResponse.hookSpecificOutput.updatedInput.cmd;
481+
assert.match(codexExecCommand, /node .*jieli_node\.mjs handoff-info --context-b64 /);
482+
assert.equal(codexExecResponse.hookSpecificOutput.updatedInput.command, undefined);
483+
assert.deepEqual(decodeHandoffContext(codexExecCommand), { session_id: "codex-exec", transcript_path: "/tmp/codex-exec.jsonl", cwd: "/repo" });
479484
for (const command of [
480485
"jieli-handoff-info.cmd",
481486
"jieli-handoff-info.exe",

0 commit comments

Comments
 (0)