Skip to content

fix(cli): improve init diagnostics and starter output - #776

Open
mldangelo wants to merge 1 commit into
openai:mdangelo/codex/project-configurationfrom
mldangelo:mdangelo/codex/init-polish
Open

fix(cli): improve init diagnostics and starter output#776
mldangelo wants to merge 1 commit into
openai:mdangelo/codex/project-configurationfrom
mldangelo:mdangelo/codex/init-polish

Conversation

@mldangelo

Copy link
Copy Markdown
Contributor

Summary

Stacked on #742 (base mdangelo/codex/project-configuration), so it can be reviewed in parallel and will retarget to main when that lands. Four follow-ups to the init command added in #742, all cosmetic except the last.

  • Refusing to overwrite is init's advertised behavior, so it now reads as a sentence naming the file rather than a raw errno. Before: codex-security: EEXIST: file already exists, open '/…/codex-security.yaml'. After: codex-security: /…/codex-security.yaml already exists. Edit it, or select it with --config codex-security.yaml.
  • Write the starter with default permissions instead of 0o600. The file holds no credentials and is meant to be committed; the private mode only broke shared checkouts and containers running as another user.
  • JSON starters cannot carry the commented settings a YAML starter shows, so init file.json previously produced a file whose entire content was a $schema key. It now prints that guidance to stderr and points at the YAML template. The file itself is unchanged.
  • Search upward from the starter for an installed @openai/codex-security so hoisted workspaces get an editor hint that resolves, falling back to the invocation directory when nothing is installed yet. This is the one behavioral change; the docs previously recorded the old behavior as a limitation and are updated to match.

projectConfigStarter now returns { contents, notes } so the "what guidance does this format need" decision stays next to the YAML comment block. It has one call site and is not exported from index.ts.

Testing

  • bun test ./tests-ts/cli-project-config.test.ts: 52 passed, no failures. Three new cases cover the umask permissions (compared against a reference write, so the assertion holds under any umask), the JSON guidance, and the hoisted-workspace $schema. The existing overwrite case now also asserts the message and that EEXIST no longer appears.
  • bun test across cli-project-config, project-config, sdk-project-config, deep-config, cli, skeleton: 279 passed, 1 failed. The failure is skeleton.test.ts "keeps machine-wide policy changes out of parallel and experimental runs", which fails identically on main in this environment (Bun.YAML.parse on bun 1.3.3 mis-parsing the workflow on: key) and is unrelated to this change.
  • pnpm run types and prettier --check: pass.
  • Verified against a built CLI in a scratch workspace with node_modules hoisted to the root and the starter written to packages/app/: the second init prints the new sentence and exits 2, the file is -rw-r--r--, the JSON starter prints both guidance lines to stderr, and the nested starter emits $schema: ../../node_modules/@openai/codex-security/schemas/project-config.schema.json.

Risk and rollout

No shared types, resolution logic, or precedence rules change, and nothing in #742 depends on projectConfigStarter's shape. The permissions change makes a previously owner-only file world-readable subject to umask; that matches how tracked configuration is normally created and the file is documented as never holding credential values.

The $schema search reads the filesystem during init only. Existing behavior is preserved when nothing is installed, which is the common case for a first run before npm install.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.
Refusing to overwrite is init's advertised behavior, so surface it as a
sentence naming the file instead of a raw EEXIST errno.

Write the starter with default permissions. The file holds no credentials
and is meant to be committed, so 0600 only broke shared checkouts and
containers running as another user.

JSON starters cannot carry the commented settings a YAML starter shows.
Print that guidance instead of leaving the file's only content a $schema
key, and point at the YAML template.

Search upward from the starter for an installed @openai/codex-security so
hoisted workspaces get an editor hint that resolves, falling back to the
invocation directory when nothing is installed yet.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T07:20:11.051966Z 9226185 PR opened
🔒 Security Review Completed 2026-09-01T07:21:09.360748Z 9226185 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant