Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## Unreleased

### Changed

- Migrate the package to the OpenCode v2 plugin API. The default export now has
the stable `sema` ID and registers the Sema MCP server through the v2 MCP
transform.
- Preserve the OpenCode v1 configuration hook through the documented combined
entrypoint for OpenCode v1.18.29 and later.
- Inject the bundled Sema guide through the v2 session context hook. V2 does not
resolve `instructions` configuration entries.
- Document that OpenCode v2 has no LSP runtime and no plugin formatter transform.
Users must configure the formatter manually; LSP configuration is inactive until
OpenCode provides an LSP runtime.

### Fixed

- Preserve an explicit global `"lsp": false` setting instead of registering the Sema
Expand Down
50 changes: 40 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

</div>

An [OpenCode](https://opencode.ai) plugin that wires Sema's language server, MCP server, and editor theme into the agent — so OpenCode can lint, navigate, evaluate, and build `.sema` code.
An [OpenCode](https://opencode.ai) plugin that wires Sema's MCP server, agent guidance, and editor theme into the agent.

## Install

Add the plugin to your `opencode.json`:

```json
{
"plugin": ["@sema-lang/opencode-sema"]
"plugins": ["@sema-lang/opencode-sema"]
}
```

Expand All @@ -33,9 +33,7 @@ npm i -D @sema-lang/opencode-sema

## Features

- **Language server** (`sema lsp`) — completions, hover docs, go-to-definition, references, rename, semantic tokens, and formatting for `.sema` files.
- **MCP server** (`sema mcp`) — exposes Sema's eval, build, compile, docs, and notebook tools to the agent as MCP tools.
- **Auto-formatting** (`sema fmt`) — every `.sema` file the agent writes or edits is formatted automatically. Opt out with the `formatter: false` option or `SEMA_DISABLE_FORMATTER=1`.
- **Agent guidance** — injects a concise "Sema for LLM agents" cheat sheet into every session so the agent writes idiomatic Sema (slash-namespaced builtins, LLM primitives, the semantics that bite). Opt out with the `instructions: false` option or `SEMA_DISABLE_INSTRUCTIONS=1`.
- **Theme** — a dark, gold-accented Sema editor theme (optional — see [Theme](#theme)).

Expand All @@ -55,36 +53,68 @@ The plugin can be configured two ways: **plugin options** in `opencode.json` (co

### Plugin options

Pass options using the tuple form of the `plugin` array in `opencode.json`:
Pass options using the object form of the `plugins` array in `opencode.json`:

```json
{
"plugin": [["@sema-lang/opencode-sema", { "path": "~/bin/sema", "formatter": false }]]
"plugins": [
{
"package": "@sema-lang/opencode-sema",
"options": { "path": "~/bin/sema", "instructions": false }
}
]
}
```

| Option | Type | Effect |
| -------------- | --------- | ------------------------------------------------------------------------------------------------------------------- |
| `path` | `string` | Path to the `sema` binary. A leading `~` is expanded; a bare name is resolved on `PATH`. Overridden by `SEMA_PATH`. |
| `formatter` | `boolean` | Set to `false` to skip registering `sema fmt` as the `.sema` formatter. Default `true`. |
| `formatter` | `boolean` | OpenCode v1 compatibility only. It has no effect in v2; configure the formatter in `opencode.json`. |
| `instructions` | `boolean` | Set to `false` to skip injecting the Sema agent cheat sheet. Default `true`. |

### Environment variables

| Variable | Effect |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SEMA_PATH` | Path to the `sema` binary. A leading `~` is expanded; a bare name is resolved on `PATH` (so `sema` / `sema.exe` both work). Takes precedence over the `path` option. Defaults to `sema`. |
| `SEMA_DISABLE_FORMATTER` | Set to `1` to skip registering `sema fmt` as the `.sema` formatter. |
| `SEMA_DISABLE_FORMATTER` | OpenCode v1 compatibility only. It has no effect in v2; configure the formatter in `opencode.json`. |
| `SEMA_DISABLE_INSTRUCTIONS` | Set to `1` to skip injecting the Sema agent cheat sheet. |
| `OPENCODE_NO_THEME_COPY` | Set to `1` to skip the `postinstall` theme copy. |

```bash
export SEMA_PATH=~/bin/sema
```

### Your own settings win
### OpenCode v2 limits and manual configuration

The LSP, MCP, and formatter registrations only apply if you haven't already defined `lsp.sema` / `mcp.sema` / `formatter.sema` yourself in `opencode.json` — your own settings always win (e.g. add `"formatter": { "sema": { "disabled": true } }`, or a global `"formatter": false`, to disable formatting from config instead of the env var or plugin option).
The v2 plugin adds the `sema` MCP server only when the project does not already define one. Your `mcp.servers.sema` configuration always wins.

OpenCode v2 does not yet have an LSP runtime. It accepts LSP configuration, but does not start language servers or add diagnostics. The plugin cannot register an LSP server until OpenCode exposes that API.

OpenCode v2 supports formatters in project configuration, but its plugin API has no formatter transform. Add Sema formatting yourself:

```jsonc
{
"formatter": {
"sema": {
"command": ["sema", "fmt", "$FILE"],
"extensions": [".sema"],
},
},
"lsp": {
"sema": {
"command": ["sema", "lsp"],
"extensions": [".sema"],
},
},
}
```

The `lsp` entry is forward-compatible configuration only. It does not enable LSP behavior in current OpenCode v2 releases.

### OpenCode v1 compatibility

The package also supports OpenCode v1.18.29 and later through its documented combined entrypoint. The v1 path retains automatic LSP, formatter, MCP, and instruction configuration. Earlier v1 releases are not supported by this package version.

## Theme

Expand Down
Loading