Skip to content

feat: write OMO config into ~/.omo/omo.jsonc [opencode] block and slim to .jsonc - #2

Merged
itsmylife44 merged 2 commits into
mainfrom
sync-omo-jsonc
Oct 15, 2026
Merged

itsmylife44 merged 2 commits into
mainfrom
sync-omo-jsonc

Conversation

@itsmylife44

Copy link
Copy Markdown
Owner

Closes #1 · Parent spec: itsmylife44/cliproxyapi-dashboard#285

Why

OMO ≥ 4.19.3 only reads ~/.omo/omo.jsonc, so dashboard settings synced to oh-my-opencode.json have been ignored since ~2026-07-28. Slim configs could also be shadowed by an installer-created oh-my-opencode-slim.jsonc.

What

  • All file writes moved into applyBundle(bundle, dirs) (src/writer.ts); index.ts keeps version check, fetch, logging and the toast.
  • OMO: replaces only the "[opencode]" property of ~/.omo/omo.jsonc via jsonc-parser (modify + applyEdits), so comments, formatting and other blocks ([native], [codex], …) are byte-preserved. Creates ~/.omo/ and the file if missing.
  • Slim: writes oh-my-opencode-slim.jsonc.
  • Legacy oh-my-opencode.json / oh-my-opencode-slim.json are never touched.
  • Change detection compares old vs new content for every written path; the toast still fires only when the OpenCode config changes.

Beyond the ticket (deliberate)

  • If only ~/.omo/omo.json exists, the plugin writes there, mirroring upstream's detectUserOmoJsonPath (jsonc first, then json).
  • A corrupt or non-object omo.jsonc aborts the sync before any file is written (clear error, retried on next start), instead of writing back garbage.
  • jsonc-parser is imported from its ESM build: bundling the default UMD entry left a broken require("./impl/format") in dist. Verified dist/index.js loads in Node.

Known limit

All OCX profiles share one ~/.omo/omo.jsonc (OMO profiles are out of scope per the spec). Documented in the README.

Tests

bun test 12 pass (temp dirs): comments/other blocks preserved, missing ~/.omo/ created, omo.json fallback, slim .jsonc, legacy files untouched, changed-path reporting, 3 corrupt-file cases. bun run typecheck clean.

Release note

Bump version before merging: CI skips publishing a version already on npm, and this must ship before the dashboard's affected-user banner (cliproxyapi-dashboard#295).

…m to .jsonc

OMO >= 4.19.3 only reads ~/.omo/omo.jsonc, so synced settings were ignored.
All file writes now go through applyBundle(bundle, dirs):

- OMO: replace only the "[opencode]" property via jsonc-parser so comments
  and other blocks survive; create ~/.omo/ if missing; write omo.json
  instead when that is the file OMO reads. A corrupt or non-object file
  aborts the sync before anything is written.
- Slim: write oh-my-opencode-slim.jsonc so an installer .jsonc can't shadow it.
- Legacy oh-my-opencode(-slim).json files are never touched.

Closes #1
@itsmylife44
itsmylife44 merged commit 5e2da6d into main Oct 15, 2026
4 checks passed
@itsmylife44
itsmylife44 deleted the sync-omo-jsonc branch October 15, 2026 15:05
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.

Write OMO config into ~/.omo/omo.jsonc "[opencode]" block and slim config to .jsonc

1 participant