Skip to content

fix: separate plugin updates from config install - #207

Open
lubshad wants to merge 5 commits into
ndycode:mainfrom
lubshad:fix/config-safe-plugin-updates
Open

fix: separate plugin updates from config install#207
lubshad wants to merge 5 commits into
ndycode:mainfrom
lubshad:fix/config-safe-plugin-updates

Conversation

@lubshad

@lubshad lubshad commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make default install manage only OpenCode/TUI plugin entries while preserving provider.openai
  • require explicit --modern, --full, or --legacy for model catalog installation
  • add a cache-only update command that never reads or writes OpenCode config
  • skip semantically unchanged config writes/backups and cover bare plus @latest cache layouts
  • reject malformed and structurally invalid config in provider-preserving mode
  • report dry-run changed paths without logging configuration values
  • retry transient Windows EPERM and EBUSY cache locks

Verification

  • npm test (2,836 passed)
  • npm run typecheck
  • npm run lint

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

this pr separates cache updates from configuration installation.

  • adds a cache-only update command and redirects update notifications to it.
  • makes plugin-only installation preserve provider.openai.
  • skips semantically unchanged config writes and backups.
  • expands managed cache cleanup to bare and @latest package layouts.
  • updates installer and auto-update vitest coverage plus user documentation.

Confidence Score: 3/5

this pr is not yet safe to merge because a persistent windows filesystem lock can still abort an update after partially clearing the cache.

cache removals run sequentially, exhausted EPERM or EBUSY retries propagate out of the update command, and dependency metadata cleanup is skipped after earlier deletions have already completed; vitest covers only a lock released after one failed attempt.

Files Needing Attention: scripts/install-oc-codex-multi-auth-core.js, test/install-oc-codex-multi-auth.test.ts

Important Files Changed

Filename Overview
scripts/install-oc-codex-multi-auth-core.js adds command routing, plugin-only config merging, redacted dry-run output, unchanged-write detection, and windows cache-removal retries.
lib/auto-update-checker.ts points manual updates at the config-safe command and includes bare managed package cache paths.
test/install-oc-codex-multi-auth.test.ts expands installer coverage for update routing, config preservation, semantic no-op writes, cache layouts, and transient windows locks.
test/auto-update-checker.test.ts updates notification assertions for the new cache-only update command.

Reviews (4): Last reviewed commit: "fix: preserve provider config in default..." | Re-trigger Greptile

@lubshad
lubshad requested a review from ndycode as a code owner July 27, 2026 08:42
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The CLI adds cache-only update and provider-preserving install --plugin-only modes. Installer writes and backups now occur only for changed configuration, malformed configs are protected in plugin-only mode, and managed cache cleanup supports bare and @latest layouts.

Changes

Installer modes and cache management

Layer / File(s) Summary
Update command and cache clearing
scripts/install-oc-codex-multi-auth-core.js, lib/auto-update-checker.ts, test/*, README.md, docs/..., skills/..., CHANGELOG.md
The CLI adds update [--dry-run], clears managed package caches before configuration parsing, retries transient Windows lock failures, and documents cache-only behavior.
Plugin-only configuration and conditional writes
scripts/install-oc-codex-multi-auth-core.js, test/install-oc-codex-multi-auth.test.ts, README.md, docs/..., skills/...
install --plugin-only preserves provider.openai, rejects malformed existing configuration, and skips writes and backups when formatted configuration is unchanged.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as oc-codex-multi-auth
  participant Cache as OpenCode managed cache
  participant Config as OpenCode config files
  User->>CLI: Run update
  CLI->>Cache: Clear managed package directories
  CLI-->>User: Return without reading or writing config
  User->>CLI: Run install --plugin-only
  CLI->>Config: Read and merge plugin/TUI entries
  CLI-->>Config: Write only changed configuration
Loading

Possibly related PRs

Suggested reviewers: ndycode

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the main changes, but it does not follow the required template with Testing checkboxes and the Compliance Confirmation section. Rewrite the description using the repo template, including the required Testing checkbox list, Compliance Confirmation checklist, and Notes fields.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the PR’s main change: separating plugin updates from config installation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread scripts/install-oc-codex-multi-auth-core.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/install-oc-codex-multi-auth.test.ts (1)

574-592: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing test for malformed tui.json in --plugin-only mode.

The core script's plugin-only path now also throws when tui.json fails to parse (mirrors the opencode.json case), but only the opencode.json malformed scenario is covered here. Consider adding a parallel test asserting the TUI-config throw and that the malformed tui.json content is left untouched.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/install-oc-codex-multi-auth.test.ts` around lines 574 - 592, Add a
parallel test for malformed tui.json in the install --plugin-only flow, using
runInstaller with a temporary HOME and invalid TUI configuration content. Assert
that installation rejects with the TUI-specific refusal error and that tui.json
remains unchanged, with no unexpected files added to its directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/install-oc-codex-multi-auth.test.ts`:
- Around line 574-592: Add a parallel test for malformed tui.json in the install
--plugin-only flow, using runInstaller with a temporary HOME and invalid TUI
configuration content. Assert that installation rejects with the TUI-specific
refusal error and that tui.json remains unchanged, with no unexpected files
added to its directory.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 87935198-3c0a-43f2-95cc-d6abdcb8afa1

📥 Commits

Reviewing files that changed from the base of the PR and between 7e2396b and bfae3f6.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • README.md
  • docs/development/ARCHITECTURE.md
  • docs/development/CONFIG_FLOW.md
  • docs/getting-started.md
  • docs/tools-and-cli.md
  • lib/auto-update-checker.ts
  • scripts/install-oc-codex-multi-auth-core.js
  • skills/oc-codex-setup/SKILL.md
  • test/auto-update-checker.test.ts
  • test/install-oc-codex-multi-auth.test.ts

Comment thread scripts/install-oc-codex-multi-auth-core.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
scripts/install-oc-codex-multi-auth-core.js (2)

908-923: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Reject structurally invalid JSON in plugin-only mode.

readJson can successfully parse arrays, scalars, or null, but plugin-only mode then spreads or coerces them into an object and writes a replacement configuration. This can overwrite malformed user configuration instead of refusing the operation. Validate isPlainObject(existing) before merging both the main and TUI configs.

This conflicts with the PR objective that plugin-only mode rejects malformed configuration.

Suggested guard
 const existing = await readJson(paths.configPath);
+if (pluginOnly && !isPlainObject(existing)) {
+	throw new Error("Refusing to replace structurally invalid config in --plugin-only mode.");
+}
 existingConfig = existing;

Also applies to: 940-950

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/install-oc-codex-multi-auth-core.js` around lines 908 - 923, Validate
that each parsed configuration is a plain object before merging, including the
main config flow around existingConfig/nextConfig and the corresponding TUI
config flow. In plugin-only mode, reject arrays, scalars, null, and other
structurally invalid values instead of spreading or coercing them into
replacement configurations; preserve the existing handling for valid objects.

962-968: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Redact configuration values before logging dry-run diffs.

formatConfigDiff prints the complete existing and proposed JSON. Arbitrary plugin settings may contain account emails, access tokens, refresh tokens, or other secrets, exposing them in normal CLI diagnostics. Redact sensitive fields or limit the diff to managed keys.

As per coding guidelines, normal diagnostics must not expose account emails, access tokens, refresh tokens, or raw prompt/response bodies.

Suggested direction
-		log(formatConfigDiff(existingConfig, nextConfig));
+		log(formatRedactedConfigDiff(existingConfig, nextConfig));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/install-oc-codex-multi-auth-core.js` around lines 962 - 968, Update
the dryRun logging in the configuration flow to sanitize values before passing
existingConfig, nextConfig, existingTuiConfig, or nextTuiConfig to
formatConfigDiff. Redact account emails, access tokens, refresh tokens, and raw
prompt/response bodies, or restrict the output to managed keys, while preserving
the existing diff and change-status messages.

Source: Coding guidelines

🧹 Nitpick comments (1)
test/install-oc-codex-multi-auth.test.ts (1)

854-859: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Cover both Windows transient lock codes.

The regression test exercises EPERM only, while the updater contract includes both EPERM and EBUSY. Add a second case or parameterize the test so either code cannot regress unnoticed.

The PR objective explicitly calls out EPERM/EBUSY retry handling.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/install-oc-codex-multi-auth.test.ts` around lines 854 - 859, Extend the
“retries update cache removal after transient Windows lock errors” test to cover
both transient error codes, EPERM and EBUSY, preferably by parameterizing the
cases. Preserve the existing first-failure retry and successful removal
assertions for each code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/install-oc-codex-multi-auth-core.js`:
- Around line 908-923: Validate that each parsed configuration is a plain object
before merging, including the main config flow around existingConfig/nextConfig
and the corresponding TUI config flow. In plugin-only mode, reject arrays,
scalars, null, and other structurally invalid values instead of spreading or
coercing them into replacement configurations; preserve the existing handling
for valid objects.
- Around line 962-968: Update the dryRun logging in the configuration flow to
sanitize values before passing existingConfig, nextConfig, existingTuiConfig, or
nextTuiConfig to formatConfigDiff. Redact account emails, access tokens, refresh
tokens, and raw prompt/response bodies, or restrict the output to managed keys,
while preserving the existing diff and change-status messages.

---

Nitpick comments:
In `@test/install-oc-codex-multi-auth.test.ts`:
- Around line 854-859: Extend the “retries update cache removal after transient
Windows lock errors” test to cover both transient error codes, EPERM and EBUSY,
preferably by parameterizing the cases. Preserve the existing first-failure
retry and successful removal assertions for each code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c05b3bb4-8d06-4d98-95e9-17ffdde34ebc

📥 Commits

Reviewing files that changed from the base of the PR and between bfae3f6 and 9fbcc82.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • scripts/install-oc-codex-multi-auth-core.js
  • test/install-oc-codex-multi-auth.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

@lubshad

lubshad commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai Addressed the malformed tui.json coverage suggestion in 7297c2e. The new plugin-only regression asserts the TUI-specific parse refusal, preserves both config files byte-for-byte, and confirms no backup or unexpected files are created. Full suite: 2,829 tests passed; typecheck and lint passed.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@lubshad Thanks for addressing this. The TUI-specific malformed-config regression and the preservation/no-artifact assertions cover the requested failure mode well. Great to see the full suite, typecheck, and lint passing.

🐇 ✅


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@lubshad

lubshad commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai Addressed all remaining findings in f4a938d. Default install now preserves provider.openai; --modern is explicit. Both OpenCode config roots are validated as plain objects in provider-preserving mode, dry-run output contains changed paths only and no configuration values, and the cache-lock regression covers both EPERM and EBUSY. Full suite: 2,836 tests passed; typecheck and lint passed.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@lubshad Thanks for addressing the remaining findings. The explicit --modern behavior, provider-preserving default install, plain-object validation, value-safe dry-run output, and dual EPERM/EBUSY retry coverage resolve the concerns. Great to see the expanded suite, typecheck, and lint all passing.

🐇 ✅


✏️ Learnings added
Learnt from: lubshad
URL: https://github.com/ndycode/oc-codex-multi-auth/pull/207

Timestamp: 2026-07-27T09:24:34.922Z
Learning: In `scripts/install-oc-codex-multi-auth-core.js`, the default `install` mode preserves an existing `provider.openai`; replacing it requires the explicit `--modern` mode. In provider-preserving mode, both OpenCode configuration roots must be plain objects, and dry-run output must report only changed paths without exposing configuration values.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@lubshad

lubshad commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Rationale for changing default install behavior

OpenCode configuration is user-owned and often carefully customized. The previous default installation wrote the complete model catalog into provider.openai, producing a large and potentially surprising configuration change. Even when unrelated settings are preserved, developers may not want an installer managing such a broad section of their configuration.

The default installation now makes only the minimum changes required to register the plugin:

  • registers or normalizes the plugin entry in opencode.json
  • registers the TUI plugin entry in tui.json
  • leaves provider.openai unchanged

Model catalog installation is explicitly opt-in:

  • --modern installs the compact catalog
  • --full installs compact and explicit model entries
  • --legacy installs the legacy explicit catalog

The update command remains config-free and only clears the managed package cache.

This makes the safe, least-invasive behavior the default while retaining explicit options for users who want the package to manage their OpenAI model catalog. The README, getting-started guide, CLI documentation, configuration guide, FAQ, setup skill, and architecture documentation have been updated accordingly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant