Skip to content

Preset composition: no mode for extending arrays at the same @path #7

Description

@trick77

Problem

Two presets cannot both contribute to the same array-valued config path. Existing modes:

  • replace — last writer wins; second install clobbers the first
  • merge — object key-merge only; doesn't apply to arrays

Concrete scenario

Today jdtls-lombok writes to `lsp.jdtls.command`:

```json
["jdtls", "--jvm-arg=-javaagent:{{cache}}/lombok.jar"]
```

If a future `jdtls-heap` preset also wanted to extend that command (e.g. `--jvm-arg=-Xmx4g`), there's no clean way to install both. Installing the second overwrites the first.

Same shape would hit any future preset that wants to add a JVM arg, classpath entry, or CLI flag to an LSP that's already configured by another preset.

Workarounds today

  1. Bundle into one preset (loses modularity)
  2. Hand-edit opencode.json after install (breaks remove, breaks idempotency)
  3. Ship a personal preset via OPENCODE_PRESETS_PATH that shadows the bundled one

Proposed direction (not committing to it)

A third mode — append / extend — that concatenates into the array at @path, deduping by exact element match. remove would strip exactly the elements the preset added.

Open questions:

  • Dedup semantics (exact match? structural? by key prefix like `--jvm-arg=-javaagent:`?)
  • Order guarantees across multiple appenders
  • How remove interacts with user-added entries that happen to match

Why file now

No real second use case yet. Filing so it's not lost when one shows up — don't implement speculatively.

Activity

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

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