Repository navigation
fix(ocm-cli): detect the OpenCode service in ocm link - #449
Merged
Merged
Conversation
Read the service registration then config for the base URL and password, warn when the service is loopback only, substitute LAN addresses for wildcard hosts, and use the Windows default port. Clarify that explicit URLs require explicit credentials.
Contributor
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
ocm linknow finds the OpenCode background service on its own instead of requiringOPENCODE_SERVER_PASSWORD=... ocm link. It reads the service registration ($XDG_STATE_HOME/opencode/service.json) first, then theopencode serviceconfig ($XDG_CONFIG_HOME/opencode/service.json), and pairs with that URL and password.Service discovery (
ocm-cli/src/link.ts)discoverOpenCodeServicereads the registration, then the config, and returns the base URL, password, source and loopback flag. It never throws and returnsnullwhen neither file yields a usable service.0.0.0.0,::) is replaced with this machine's first non-internal IPv4 address, falling back to127.0.0.1when there is none.loopbackOnlyis classified from the final hostname, so the fallback is reported as loopback and the remote-access warning still fires.Platform default port
45278on Windows and49374elsewhere, matching the OpenCode docs.CLI wiring (
ocm-cli/bin/ocm.ts)cmdLinkreports which source the URL came from and warns when the service only listens on loopback, since a remote Manager cannot reach it.--urlor$OPENCODE_SERVER_URLstill skips detection, so a discovered password is never sent to an unrelated URL; that case requires an explicit password.Docs (
ocm-cli/README.md)--passwordor$OPENCODE_SERVER_PASSWORD.Tests (
ocm-cli/test/link.test.ts)process.platformmock.Known gaps
Summary by CodeRabbit
New Features
ocm linknow automatically detects configured OpenCode services when no URL is provided.Documentation
ocm linkdocumentation to describe service detection, defaults, credentials, and warnings.