fix(code-queue): harden codex submit prompt input

Host commander merge after read-only audit and post-#72 mergeability refresh. PR #71 is CLEAN/MERGEABLE and limited to UniDesk Code Queue CLI prompt input hardening, help/check docs, and submit prompt contract test. It does not touch HWLAB business code.
This commit is contained in:
Lyon
2026-05-23 00:36:45 +08:00
committed by GitHub
parent 2a8e9a5cd3
commit 77b577a2cc
6 changed files with 184 additions and 4 deletions
+37 -1
View File
@@ -30,11 +30,47 @@ const commandName = displayCommandName(args);
function displayCommandName(parts: string[]): string {
if (parts.length === 0) return "help";
if (parts[0] === "codex" && (parts[1] === "submit" || parts[1] === "enqueue")) {
const shown = ["codex", parts[1]];
const shownValueOptions = new Set([
"--prompt-file",
"--file",
"--queue",
"--queue-id",
"--provider",
"--provider-id",
"--cwd",
"--workdir",
"--model",
"--reasoning-effort",
"--execution-mode",
"--mode",
"--max-attempts",
"--reference-task-id",
"--reference",
"--ref",
]);
const hasPromptFile = parts.includes("--prompt-file") || parts.includes("--file");
const hasPromptStdin = parts.includes("--prompt-stdin") || parts.includes("--stdin");
const hasHelp = parts.slice(2).some(isHelpToken);
if (!hasPromptFile && !hasPromptStdin && !hasHelp) shown.push("<prompt:redacted>");
for (let index = 2; index < parts.length; index += 1) {
const part = parts[index] ?? "";
if (!part.startsWith("--")) continue;
shown.push(part);
if (shownValueOptions.has(part)) {
shown.push(parts[index + 1] ?? "<missing>");
index += 1;
}
}
return shown.join(" ");
}
if (parts[0] === "codex" && parts[1] === "steer" && parts[2] !== undefined) {
const shown = ["codex", "steer", parts[2]];
const hasPromptFile = parts.includes("--prompt-file") || parts.includes("--file");
const hasPromptStdin = parts.includes("--prompt-stdin") || parts.includes("--stdin");
if (!hasPromptFile && !hasPromptStdin) shown.push("<prompt:redacted>");
const hasHelp = parts.slice(3).some(isHelpToken);
if (!hasPromptFile && !hasPromptStdin && !hasHelp) shown.push("<prompt:redacted>");
for (let index = 3; index < parts.length; index += 1) {
const part = parts[index] ?? "";
if (!part.startsWith("--")) continue;