From b24fff85c71a0b79ab289125c584e0ad26aaa5d0 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 10 Nov 2026 18:06:25 -0800 Subject: [PATCH 1/2] Restore Unicode CLI messages after main integration --- sdk/typescript/src/cli.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.ts index da0258092..714f3df0f 100644 --- a/sdk/typescript/src/cli.ts +++ b/sdk/typescript/src/cli.ts @@ -726,7 +726,7 @@ function fitProgressLine(line: string, width: number): string { for (const { index, segment } of graphemes.segment(plain)) { used += stringWidth(segment.toWellFormed()); if (used > width) - return width > 0 ? `${plain.slice(0, ellipsisIndex)}…` : ""; + return width > 0 ? `${plain.slice(0, ellipsisIndex)}…` : ""; if (used < width) ellipsisIndex = index + segment.length; } return line; @@ -826,7 +826,7 @@ function renderExternalPublicationSummary( result.privateJob ? `Private inbox import ${result.privateJob.status}. Job: ${diagnosticValue(result.privateJob.id)}` : `Import ${result.status}.`, - `Submission totals — Created: ${result.counts.created} Updated: ${result.counts.updated} Unchanged: ${result.counts.unchanged} Failed: ${result.counts.error}`, + `Submission totals — Created: ${result.counts.created} Updated: ${result.counts.updated} Unchanged: ${result.counts.unchanged} Failed: ${result.counts.error}`, result.privateJob ? `Excluded: ${result.excluded.length} Unprocessed: ${result.privateJob.counts.unprocessed}` : `Excluded: ${result.excluded.length} Awaiting acknowledgement: ${result.unacknowledged} Verified: ${result.verified}`, @@ -864,7 +864,7 @@ function renderPublicationSummary( ): string { const created = result.created.length; const failed = result.failed.length; - const marker = failed === 0 ? "✓" : "!"; + const marker = failed === 0 ? "✓" : "!"; const title = failed === 0 ? "Linear publication complete" @@ -949,7 +949,7 @@ class PublicationProgressPresenter { if (event.type === "started") { if (this.#dashboard !== null) { this.#dashboard.setPublicationProgress(0, event.total); - this.#dashboard.setStage(`Publishing findings · 0/${event.total}`); + this.#dashboard.setStage(`Publishing findings · 0/${event.total}`); } else { this.#write( `Publishing ${formatItemCount(event.total, "finding")} to Linear.`, @@ -1012,7 +1012,7 @@ class PublicationProgressPresenter { if (this.#dashboard !== null) { this.#dashboard.setPublicationProgress(event.completed, event.total); this.#dashboard.setStage( - `Publishing findings · ${event.completed}/${event.total}`, + `Publishing findings · ${event.completed}/${event.total}`, ); this.#dashboard.note(detail); } else { @@ -1084,7 +1084,7 @@ class FindingProgressPresenter { color: this.#dependencies.environment["NO_COLOR"] === undefined, }); dashboard.setPublicationProgress(0, this.#total); - dashboard.setStage(`Verifying findings · 0/${this.#total}`); + dashboard.setStage(`Verifying findings · 0/${this.#total}`); try { dashboard.start(); this.#dashboard = dashboard; @@ -1100,7 +1100,7 @@ class FindingProgressPresenter { public startPatch(finding: Finding, index: number): void { try { this.#progress.startTimer( - `Patching ${index + 1}/${this.#total} · ${safePatchText(finding.title)}`, + `Patching ${index + 1}/${this.#total} · ${safePatchText(finding.title)}`, ); } catch { this.stop(); @@ -1183,7 +1183,7 @@ class FindingProgressPresenter { if (this.#dashboard === null) return; this.#dashboard.setPublicationProgress(results.length, this.#total); this.#dashboard.setStage( - `Verification complete · ${results.length}/${this.#total}`, + `Verification complete · ${results.length}/${this.#total}`, ); for (const result of results) { this.#dashboard.note(`${result.status.toUpperCase()} ${result.id}`); @@ -4421,7 +4421,7 @@ export async function main( fitCell(row.age, ageWidth), row.scanId, ].join(" "), - short: `${repository} · ${row.scanId}`, + short: `${repository} · ${row.scanId}`, value: row.value, }; }); @@ -5350,7 +5350,7 @@ export async function main( sonarProject: optionValue("--sonar-project") .optional() .describe( - "Sonar project key (defaults to the checkout’s project binding).", + "Sonar project key (defaults to the checkout’s project binding).", ), sonarBranch: optionValue("--sonar-branch") .optional() @@ -5464,7 +5464,7 @@ export async function main( `Cloud account: ${diagnosticValue(cloud.accountId)} on ${diagnosticValue(cloud.cloudApiUrl)}`, ); note( - `Cloud repository: ${diagnosticValue(cloud.destination.url)} · ${cloud.privateImport ? `Private inbox · ${cloud.privateImport.format} (${cloud.privateImport.bytes} bytes)` : `Environments: ${[...environments].map(diagnosticValue).join(", ")}`}`, + `Cloud repository: ${diagnosticValue(cloud.destination.url)} · ${cloud.privateImport ? `Private inbox · ${cloud.privateImport.format} (${cloud.privateImport.bytes} bytes)` : `Environments: ${[...environments].map(diagnosticValue).join(", ")}`}`, ); note( `Cloud: ${cloud.findings.length} ready, ${cloud.excluded.length} excluded.`, @@ -5829,7 +5829,7 @@ export async function main( safetyIdentifier: optionValue("--safety-identifier") .optional() .describe( - "Stable hashed end-user ID for this scan's model requests (1–64 characters).", + "Stable hashed end-user ID for this scan's model requests (1–64 characters).", ), path: z .array(optionValue("--path")) @@ -6241,7 +6241,7 @@ export async function main( destructive: true, options: z.object({ runs: reviewRunsOption.describe( - `Number of independent classification runs (1–10; default: ${DEFAULT_REVIEW_RUNS}).`, + `Number of independent classification runs (1–10; default: ${DEFAULT_REVIEW_RUNS}).`, ), records: z .boolean() @@ -6769,7 +6769,7 @@ export async function main( dashboard?.finishComponents(result); stopDashboard(); errorOutput.write( - `Component scans: ${result.completed} complete, ${result.failed} failed.\n${result.sourceFindingCount} findings → ${result.findingCount} groups${result.deduplication?.status === "failed" ? " (matching failed)" : ""}.\nReport: ${errorMessage(result.reportPath)}\n`, + `Component scans: ${result.completed} complete, ${result.failed} failed.\n${result.sourceFindingCount} findings → ${result.findingCount} groups${result.deduplication?.status === "failed" ? " (matching failed)" : ""}.\nReport: ${errorMessage(result.reportPath)}\n`, ); if (result.retryPlanPath !== undefined) errorOutput.write( @@ -14936,7 +14936,7 @@ async function executeScan( onTrustedAccessStatus: (status) => { if (status === "granted") { errorOutput.write( - "codex-security: ✓ Your account has Trusted Access for Cyber.\n", + "codex-security: ✓ Your account has Trusted Access for Cyber.\n", ); } }, @@ -15430,7 +15430,7 @@ async function executeScan( }; } progress?.stage( - `Scan ${result.manifest.scan.status === "completed" ? "complete" : result.manifest.scan.status} · ${result.manifest.scan.id.slice(0, 8)}`, + `Scan ${result.manifest.scan.status === "completed" ? "complete" : result.manifest.scan.status} · ${result.manifest.scan.id.slice(0, 8)}`, ); printScanSummary( result, @@ -15946,7 +15946,7 @@ function printScanReference( ]; const argument = quoteCliPath(diagnosticValue(scanId)); output.write( - `\n${detail.join(" · ")}\n` + + `\n${detail.join(" · ")}\n` + (selection === undefined ? "" : `Selected ${selection}.\n`) + `Inspect${cliShellLabel(argument)}: codex-security scans show ${argument}\n` + (showLogs From a500288b9211382b01f1a6e7fd0e88c7328f8c36 Mon Sep 17 00:00:00 2001 From: Michael D'Angelo Date: Tue, 10 Nov 2026 18:14:09 -0800 Subject: [PATCH 2/2] Use verified directory-entry names for saved patch publication --- sdk/typescript/src/cli.ts | 20 ++++++++++++---- .../cli-patch-snapshot-environment.test.ts | 12 +--------- ...patch-untracked-repository-content.test.ts | 24 ++++++++++++------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.ts index 714f3df0f..55be0b183 100644 --- a/sdk/typescript/src/cli.ts +++ b/sdk/typescript/src/cli.ts @@ -1590,7 +1590,7 @@ interface CliDependencies { // Apply coordinator-owned Git bindings after native shell environment filtering. const snapshotCredentialName = /(?:^|_)(?:TOKEN|PASSWORD|SECRET|CREDENTIALS?|AUTHORIZATION|(?:API|ACCESS|SECRET|PRIVATE)_KEY|AUTH_SOCK)(?:_FILE)?$/iu; -const PATCH_GIT_ENVIRONMENT_RUNNER = ` +export const PATCH_GIT_ENVIRONMENT_RUNNER = ` const { spawn } = require("node:child_process"); const { readSync, writeSync } = require("node:fs"); const [headerLength, command, ...args] = process.argv.slice(1); @@ -9797,14 +9797,20 @@ async function prepareSavedPatchPublication( before: SavedPatchTrees, after: SavedPatchTrees, ) { - const changes = paths.length - ? await diff(before.tree, after.tree, paths) - : new Map(); // A move may be reported under its new name. Include its deleted source // only if the full turn contains exactly one removal and one addition // of the same mode and object. Never select neighboring directory leaves. const previous = new Map(); const turn = await diff(before.tree, after.tree, ["."], previous); + // Git emits root-relative byte paths. Use the exact directory-entry names + // accepted by finding verification, including descendants of a selected directory. + const changes = new Map( + [...turn].filter(([path]) => + paths.some( + (selected) => path === selected || path.startsWith(selected + "/"), + ), + ), + ); const filtered = (path: string) => before.filteredInputs?.has(path) || after.filteredInputs?.has(path); for (const path of turn.keys()) { @@ -13085,7 +13091,11 @@ async function runFindingPatches( !(base instanceof Map) ) { const reason = await options.publication.verified.record( - verifiedPatchFiles(selected, [patch]), + files.map((file) => + relativePatchPath(rootKey, resolve(repositoryKey, file)) + .split(sep) + .join("/"), + ), base, observed, ); diff --git a/sdk/typescript/tests-ts/cli-patch-snapshot-environment.test.ts b/sdk/typescript/tests-ts/cli-patch-snapshot-environment.test.ts index ed15df9d2..eba7d03e5 100644 --- a/sdk/typescript/tests-ts/cli-patch-snapshot-environment.test.ts +++ b/sdk/typescript/tests-ts/cli-patch-snapshot-environment.test.ts @@ -1,22 +1,12 @@ import { afterEach, expect, test } from "bun:test"; import { spawn } from "node:child_process"; -import { readFile } from "node:fs/promises"; import { join } from "node:path"; +import { PATCH_GIT_ENVIRONMENT_RUNNER as runner } from "../src/cli.js"; import { createTemporaryDirectories } from "./support/temporary-directories.js"; const fixtures = createTemporaryDirectories(true); afterEach(fixtures.cleanup); -const source = await readFile( - new URL("../src/cli.ts", import.meta.url), - "utf8", -); -const declaration = source.match( - /const PATCH_GIT_ENVIRONMENT_RUNNER = (`[\s\S]*?`);/u, -); -expect(declaration).not.toBeNull(); -const runner = new Function(`return ${declaration![1]};`)() as string; - function bindingFrame(environment: Record = {}): Buffer { return Buffer.from(JSON.stringify({ bindings: Object.entries(environment) })); } diff --git a/sdk/typescript/tests-ts/cli-patch-untracked-repository-content.test.ts b/sdk/typescript/tests-ts/cli-patch-untracked-repository-content.test.ts index 2d5e38623..605355f1f 100644 --- a/sdk/typescript/tests-ts/cli-patch-untracked-repository-content.test.ts +++ b/sdk/typescript/tests-ts/cli-patch-untracked-repository-content.test.ts @@ -75,7 +75,10 @@ for (const kind of [ nestedGit("add", "-f", "local.txt"); nestedGit("commit", "-m", "Synthetic nested content"); } - const blocked = copied && kind !== "directory link"; + const copiedPrivateContent = copied && kind !== "directory link"; + const blocked = copiedPrivateContent || kind === "scrubbed"; + const assessed = + kind === "scrubbed" || (kind === "untracked" && !copied); expect(git("status", "--porcelain=v1", "--untracked-files=all")).toBe( kind.startsWith("ignored") ? "" : "?? nested/", ); @@ -92,7 +95,7 @@ for (const kind of [ "patch", "--scan", "scan-1", - ...(kind === "scrubbed" ? ["--assess-patch-risk"] : []), + ...(assessed ? ["--assess-patch-risk"] : []), "--create-pr", "--json", ], @@ -115,10 +118,11 @@ for (const kind of [ output!.appServer!.prompt.includes("immutable patch artifact") ) { assessments++; - await writeFile( - join(directory, "selected.txt"), - "Synthetic scrubbed working copy\n", - ); + if (kind === "scrubbed") + await writeFile( + join(directory, "selected.txt"), + "Synthetic scrubbed working copy\n", + ); output!.stdout.write(patchRiskAssessment().report); return 0; } @@ -150,7 +154,11 @@ for (const kind of [ blocked ? { pushes: 0, creations: 0 } : { pushes: 1, creations: 1 }, ); if (blocked) { - expect(outcome.stderr).toContain("pre-existing"); + expect(outcome.stderr).toContain( + copiedPrivateContent + ? "pre-existing" + : "working tree differs from the verified changes", + ); expect(git("rev-parse", "HEAD")).toBe(head); expect(await readFile(join(directory, ".git", "index"))).toEqual( index!, @@ -170,7 +178,7 @@ for (const kind of [ configuration, ); expect(await readFile(source, "utf8")).toBe(content); - expect(assessments).toBe(kind === "scrubbed" ? 1 : 0); + expect(assessments).toBe(assessed ? 1 : 0); expect(await readFile(join(directory, "selected.txt"), "utf8")).toBe( kind === "scrubbed" ? "Synthetic scrubbed working copy\n"