feat: route Codex hook commands through projection seam (#3444)

* feat: route Codex hook commands through projection seam

* docs: add changeset for Codex hook projection slice

* docs: set changeset pr for #3444

* fix(codex): decode toml-escaped legacy hook path

* test(codex): use structured assertion for hook projection
This commit is contained in:
Tom Boucher
2026-05-12 18:16:36 -04:00
committed by GitHub
parent 98cc1a84c0
commit 589318ce0a
4 changed files with 105 additions and 16 deletions

View File

@@ -45,8 +45,34 @@ function formatManagedHookScriptToken(scriptPath, opts = {}) {
return JSON.stringify(scriptPath.replace(/\\/g, '/'));
}
function projectManagedHookCommand({ absoluteRunner, scriptPath, runtime = 'generic', platform = process.platform }) {
if (!absoluteRunner || !scriptPath) return null;
const normalizedScriptPath = platform === 'win32' ? scriptPath.replace(/\\/g, '/') : scriptPath;
return formatHookCommandForRuntime(`${absoluteRunner} ${JSON.stringify(normalizedScriptPath)}`, {
platform,
runtime,
});
}
function escapeTomlDoubleQuotedString(value) {
return String(value).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
}
function projectCodexHookTomlCommand({ absoluteRunner, scriptPath, platform = process.platform }) {
const command = projectManagedHookCommand({
absoluteRunner,
scriptPath,
runtime: 'codex',
platform,
});
return command === null ? null : escapeTomlDoubleQuotedString(command);
}
module.exports = {
hookCommandNeedsPowerShellCallOperator,
formatHookCommandForRuntime,
formatManagedHookScriptToken,
projectManagedHookCommand,
escapeTomlDoubleQuotedString,
projectCodexHookTomlCommand,
};