Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix(hooks): quote plugin script paths (#487)

이민재48bf700f62e6
diff --git a/plugin/hooks/hooks.codex.json b/plugin/hooks/hooks.codex.json
index 73e43c66..d2c3a3b6 100644
--- a/plugin/hooks/hooks.codex.json
+++ b/plugin/hooks/hooks.codex.json
@@ -5,7 +5,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs",
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs\"",
"statusMessage": "agentmemory: loading session context"
}
]
@@ -16,7 +16,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/prompt-submit.mjs",
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/prompt-submit.mjs\"",
"statusMessage": "agentmemory: recalling relevant memories"
}
]
@@ -28,7 +28,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/pre-tool-use.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/pre-tool-use.mjs\""
}
]
}
@@ -38,7 +38,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.mjs\""
}
]
}
@@ -48,7 +48,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/pre-compact.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/pre-compact.mjs\""
}
]
}
@@ -58,7 +58,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs\""
}
]
}
diff --git a/plugin/hooks/hooks.json b/plugin/hooks/hooks.json
index d60d664a..a13c9973 100644
--- a/plugin/hooks/hooks.json
+++ b/plugin/hooks/hooks.json
@@ -5,7 +5,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs\""
}
]
}
@@ -15,7 +15,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/prompt-submit.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/prompt-submit.mjs\""
}
]
}
@@ -26,7 +26,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/pre-tool-use.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/pre-tool-use.mjs\""
}
]
}
@@ -36,7 +36,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.mjs\""
}
]
}
@@ -46,7 +46,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-failure.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-failure.mjs\""
}
]
}
@@ -56,7 +56,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/pre-compact.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/pre-compact.mjs\""
}
]
}
@@ -66,7 +66,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/subagent-start.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/subagent-start.mjs\""
}
]
}
@@ -76,7 +76,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/subagent-stop.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/subagent-stop.mjs\""
}
]
}
@@ -86,7 +86,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/notification.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/notification.mjs\""
}
]
}
@@ -96,7 +96,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/task-completed.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/task-completed.mjs\""
}
]
}
@@ -106,7 +106,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs\""
}
]
}
@@ -116,7 +116,7 @@
"hooks": [
{
"type": "command",
- "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/session-end.mjs"
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/session-end.mjs\""
}
]
}
diff --git a/test/codex-plugin.test.ts b/test/codex-plugin.test.ts
index bb380876..bbbd88db 100644
--- a/test/codex-plugin.test.ts
+++ b/test/codex-plugin.test.ts
@@ -9,6 +9,29 @@ function readJson<T = unknown>(path: string): T {
return JSON.parse(readFileSync(path, "utf-8")) as T;
}
+type HookHandler = { type: string; command: string };
+type HookEntry = { hooks: HookHandler[] };
+
+function hookCommands(path: string): string[] {
+ const manifest = readJson<{ hooks: Record<string, HookEntry[]> }>(path);
+ return Object.values(manifest.hooks).flatMap((entries) =>
+ entries.flatMap((entry) => entry.hooks.map((handler) => handler.command)),
+ );
+}
+
+describe("Plugin hook manifests", () => {
+ it("quote plugin script paths so roots with spaces stay intact", () => {
+ for (const manifest of ["hooks.json", "hooks.codex.json"]) {
+ const commands = hookCommands(join(pluginRoot, "hooks", manifest));
+ expect(commands.length, `${manifest} should contain hook commands`).toBeGreaterThan(0);
+
+ for (const command of commands) {
+ expect(command).toMatch(/^node "\$\{CLAUDE_PLUGIN_ROOT\}\/scripts\/[^\s"]+\.mjs"$/);
+ }
+ }
+ });
+});
+
describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => {
it("ships .codex-plugin/plugin.json with kebab-case name + version + references", () => {
const manifestPath = join(pluginRoot, ".codex-plugin/plugin.json");
@@ -72,8 +95,6 @@ describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => {
});
it("hook command scripts referenced in hooks.codex.json exist on disk", () => {
- type HookHandler = { type: string; command: string };
- type HookEntry = { hooks: HookHandler[] };
const hooks = readJson<{ hooks: Record<string, HookEntry[]> }>(
join(pluginRoot, "hooks/hooks.codex.json"),
);
@@ -81,7 +102,7 @@ describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => {
for (const entries of Object.values(hooks.hooks)) {
for (const entry of entries) {
for (const handler of entry.hooks) {
- const match = handler.command.match(/\$\{CLAUDE_PLUGIN_ROOT\}\/(scripts\/[^\s]+)/);
+ const match = handler.command.match(/\$\{CLAUDE_PLUGIN_ROOT\}\/(scripts\/[^\s"]+)/);
if (match) scriptRefs.add(match[1]);
}
}