Repository navigation
feat: shorten CLI to ocs and add opencode.jsonc support - #17
Merged
Merged
Conversation
Part A - opencode.jsonc support: - Add JSONC loading via github.com/tailscale/hujson. The new decodeConfig helper standardizes comments (// and /* */) and trailing commas to standard JSON before unmarshalling, so valid .json configs are unaffected. - LoadConfig now accepts both opencode.json and opencode.jsonc. - GetConfigPath probes opencode.jsonc first, then opencode.json (jsonc > json precedence). If neither exists it defaults to the conventional opencode.json path so first-time Save writes standard JSON. - Backup naming is now derived dynamically from filepath.Base(configPath), so opencode.jsonc produces opencode.jsonc.backup.* while legacy opencode.json behavior is byte-for-byte preserved. - Documented limitation: .jsonc comments are supported on LOAD but are NOT preserved when the tool saves the config (it writes standard JSON). - Tests: jsonc fixture, load-equality vs json fixture, hermetic GetConfigPath probe-order table, jsonc-aware backup naming/scope tests, fixture validator. Part B - binary renamed to ocs: - Binary/program name centralized in internal/appname (const Name = ocs). - FlagSet (main.go), TUI header banner, and goreleaser/Makefile use appname. - Module path github.com/lleontor705/opencode-model-selector is UNCHANGED; only the installed binary is named ocs. Dependency note: hujson has no tagged release, so it is pinned to a pseudo-version (v0.0.0-20260727124030-b80ff77dac4f). go mod tidy also promoted charmbracelet/x/ansi from indirect to direct, reflecting the pre-existing direct import in internal/tui/header.go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two coordinated changes on this branch.
A — Support
opencode.jsonc+opencode.jsongithub.com/tailscale/hujson;LoadConfignow standardizes JSONC (comments//+/* */, trailing commas) before unmarshalling. Plain.jsonfiles pass through unchanged.GetConfigPathnow probesopencode.jsonc→opencode.json(first existing wins; default-create is.jsonwhen neither exists)..json→opencode.json.backup.*(backward compatible),.jsonc→opencode.jsonc.backup.*..jsonccomments are not preserved on write.B — Shorten the CLI binary name to
ocsinternal/appnamepackage (const Name = "ocs") as the single source of truth formain.go, the TUI banner, error strings, and integration-test markers.Makefile,.goreleaser.yaml,.gitignore,main.go,internal/tui/*, README,docs/INSTALLATION.md,CONTRIBUTING.md, logo inner text,package.json.go.modis unchanged (github.com/lleontor705/opencode-model-selector) — only the compiled binary name changed.Verification
go vet ./...cleango test ./...all green (5 packages, 0 failures), incl. new tests: probe-order precedence, JSONC-equals-JSON load, jsonc backup basename, jsonc cleanup glob scope, jsonc fixture standardizationgo buildproducesocs/ocs.exe; headless modes run and the FlagSet is titledocsopencode-model-selectorcommand invocations (residual matches are all sanctioned: module path, repo URLs, logo filename, project-title prose,.gitignorelegacy entry)opencode.jsoncloads via--configwithout parse errorsKnown non-blocking note
hujsonrejects a leading UTF-8 BOM (pre-existing library behavior). Optional future hardening: strip\xef\xbb\xbfinLoadConfig.Branch:
feat/ocs-cli-jsonc(commit8d010c4)