Skip to content

[FEATURE] Support file:// with ~ expansion in *ApiKey config fields #34

Description

@boyxil

title: '[FEATURE] Support file:// with ~ expansion in *ApiKey config fields'
labels: enhancement

Is your feature request related to a problem?

The *ApiKey config fields (embeddingApiKey, memoryApiKey) currently accept only the key as a plain string:

{ "embeddingApiKey": "nvapi-..." }

For users who prefer to keep the key in a separate file (managed outside the config, shared across machines, rotated via CI, etc.), there's no built-in way to reference a file.

file:// is partially supported — "file:///abs/path" works — but the convenient portable form "file://~/.config/..." throws on Linux:

ERROR error=File URL host must be "localhost" or empty on linux failed to load plugin

Proposed solution

Support file:// references with ~ expansion in *ApiKey fields:

{ "embeddingApiKey": "file://~/.config/opencode/nvidia-key" }

Root cause of the current failure is in src/services/secret-resolver.ts:33, where new URL(value) validates the URL before ~ is expanded, so ~ ends up as the URL host.

Upstream opencode-mem (tickernelz) handles this in one line (dist/services/secret-resolver.js:33):

const filePath = expandPath(value.slice(7));

The same approach should work here.

Additional context

Discovered while migrating from upstream opencode-mem, where the file://~/... pattern works out of the box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions