Skip to content
Merged
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
6 changes: 4 additions & 2 deletions .github/workflows/mcpx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ jobs:
- name: Check the dogfood plugin copy is in sync
run: |
diff -r pkgs/mcpx/plugin/opencode/mcpx .opencode/plugin/mcpx
diff -r pkgs/mcpx/plugin/core .opencode/plugin/core
diff pkgs/mcpx/plugin/opencode/mcpx-session.ts .opencode/plugin/mcpx-session.ts

seed:
Expand Down Expand Up @@ -196,6 +197,7 @@ jobs:
- name: Check the dogfood plugin copy is in sync
run: |
diff -r pkgs/mcpx/plugin/opencode/mcpx .opencode/plugin/mcpx
diff -r pkgs/mcpx/plugin/core .opencode/plugin/core
diff pkgs/mcpx/plugin/opencode/mcpx-session.ts .opencode/plugin/mcpx-session.ts

- uses: actions/setup-go@v7
Expand Down Expand Up @@ -310,7 +312,7 @@ jobs:
# test fails CI instead of never running (#1978).
- name: Plugin tests (bun)
working-directory: pkgs/mcpx
run: bun test plugin/opencode/mcpx/
run: bun test plugin/opencode/mcpx/ plugin/core/

- name: Upload runtime feature coverage ledger
if: always()
Expand Down Expand Up @@ -448,7 +450,7 @@ jobs:

- name: bun test
working-directory: pkgs/mcpx
run: bun test plugin/opencode/mcpx/
run: bun test plugin/opencode/mcpx/ plugin/core/

vendorhash-repair:
name: vendorHash repair (bot dependency bumps only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* stale info file, a socket with nothing behind it, two daemons at once. A
* mocked fetch would pass every one of them.
*
* bun test plugin/opencode/mcpx/daemon.test.ts
* bun test plugin/core/daemon.test.ts
*/

import { afterEach, describe, expect, test } from "bun:test";
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* socket and -- when the Go suite hands one over in OPS_LIVE_SOCKET -- against
* a real daemon.
*
* bun test plugin/opencode/mcpx/ops.test.ts
* bun test plugin/core/ops.test.ts
*
* The fake half proves the request shapes: that a path parameter is escaped,
* a raw body arrives as bytes, a bare-document route receives the document.
Expand Down
2 changes: 1 addition & 1 deletion .opencode/plugin/mcpx-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
type Discovery,
type DiscoverOptions,
type Target,
} from "./mcpx/daemon.ts";
} from "../core/daemon.ts";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Match the dogfood import to its deployed directory layout

When OpenCode loads the repository's .opencode/plugin/mcpx-session.ts, this import resolves to .opencode/core/daemon.ts, but the relocated file is at .opencode/plugin/core/daemon.ts. A repository-wide path search confirms there is no .opencode/core/daemon.ts. Consequently, the dogfood plugin fails during module loading, disabling its session/environment hooks and tools. The source and dogfood adapters now have different relative layouts, so copying the source adapter unchanged no longer works; adjust the deployed layout or its import and corresponding sync check.

Useful? React with 👍 / 👎.

// The only reliable way to tell, in v1, whether anyone is looking at a
// screen. See `headless` below.
import { isMainThread } from "node:worker_threads";
Expand Down
2 changes: 1 addition & 1 deletion .opencode/plugin/mcpx/ceiling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { existsSync } from "node:fs"
import { describe, expect, test } from "bun:test"

import { DaemonClient } from "./daemon.ts"
import { DaemonClient } from "../../core/daemon.ts"

const socket = process.env.CEILING_SOCKET
const mark = process.env.CEILING_MARK as string
Expand Down
4 changes: 2 additions & 2 deletions pkgs/mcpx/docs/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declaration come:
- the `mcpx_<op>` MCP tool,
- a generated CLI command, for operations that have one,
- a typed plugin method on `DaemonClient.ops`
(`plugin/opencode/mcpx/ops.gen.ts`, generated the same way),
(`plugin/core/ops.gen.ts`, generated the same way),
- the operation's entry in `/v1/openapi.json` and in the document
`mcpx openapi` prints — one document now, generated from the table;
the stale hand-written serve-surface document it replaced is
Expand Down Expand Up @@ -140,7 +140,7 @@ JavaScript runtime involved at all. The whole surface is the

### `DaemonClient` and `connect()` — for harnesses and Bun/TypeScript programs

The opencode plugin's client (`plugin/opencode/mcpx/daemon.ts`)
The opencode plugin's client (`plugin/core/daemon.ts`)
talks to the daemon over its unix socket — measured at about
0.17 ms per call against about 23 ms for spawning the binary. It is
not published as a package; harness plugins vendor it, and any
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/docs/parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Each direction is also held by a test:
A command marked *generated* is built from the operation's declaration --
flags from its parameters, positionals for its path -- so it exists the
moment the operation does. The plugin reaches every operation through
`DaemonClient.ops` (`plugin/opencode/mcpx/ops.gen.ts`, generated the same way);
`DaemonClient.ops` (`plugin/core/ops.gen.ts`, generated the same way);
the named methods beside it are conveniences with typed answers.

Privileged operations are offered rather than hidden. A caller that can reach
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/internal/api/plugin_ts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func OperationFingerprint() string {
return hex.EncodeToString(digest[:])
}

// PluginTS renders plugin/opencode/mcpx/ops.gen.ts: one typed method per
// PluginTS renders plugin/core/ops.gen.ts: one typed method per
// /v1 operation, for the opencode plugin's DaemonClient.
//
// Generated for the reason the MCP tools and the CLI commands are: the
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/internal/api/plugin_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var update = flag.Bool("update", false, "rewrite generated files instead of comparing them")

const pluginOpsPath = "../../plugin/opencode/mcpx/ops.gen.ts"
const pluginOpsPath = "../../plugin/core/ops.gen.ts"

// TestPluginOpsAreGenerated fails when the plugin's operation methods no
// longer match the table -- an operation added, a parameter renamed -- so
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/internal/cli/parity.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Each direction is also held by a test:
A command marked *generated* is built from the operation's declaration --
flags from its parameters, positionals for its path -- so it exists the
moment the operation does. The plugin reaches every operation through
` + "`DaemonClient.ops`" + ` (` + "`plugin/opencode/mcpx/ops.gen.ts`" + `, generated the same way);
` + "`DaemonClient.ops`" + ` (` + "`plugin/core/ops.gen.ts`" + `, generated the same way);
the named methods beside it are conveniences with typed answers.

Privileged operations are offered rather than hidden. A caller that can reach
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/internal/cli/parity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var update = flag.Bool("update", false, "rewrite generated files instead of comp

const (
parityPath = "../../docs/parity.md"
daemonTSPath = "../../plugin/opencode/mcpx/daemon.ts"
daemonTSPath = "../../plugin/core/daemon.ts"
)

// TestParityDocumentIsCurrent fails when docs/parity.md no longer matches the
Expand Down
4 changes: 2 additions & 2 deletions pkgs/mcpx/internal/e2e/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func TestThePluginSuiteRunsAgainstARealDaemon(t *testing.T) {
t.Fatalf("could not find the daemon's socket: %v", err)
}

cmd := exec.Command(bun, "test", "plugin/opencode/mcpx/")
cmd := exec.Command(bun, "test", "plugin/opencode/mcpx/", "plugin/core/")
cmd.Dir = repoRoot(t)
cmd.Env = append(e.envVars, "OPS_LIVE_SOCKET="+where.Socket, "OPS_LIVE_DIR="+e.dir)
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("bun test plugin/opencode/mcpx/: %v\n%s", err, out)
t.Fatalf("bun test plugin/opencode/mcpx/ plugin/core/: %v\n%s", err, out)
}
// The live tests skip themselves without a socket; a run that skipped
// them is a run that did not check what this test exists to check.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/internal/refdoc/regions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCommittedRegionsAreCurrent(t *testing.T) {
// docs/parity.md: the whole file is cli.ParityDoc over the plugin's
// daemon.ts.
{
ts, err := os.ReadFile("../../plugin/opencode/mcpx/daemon.ts")
ts, err := os.ReadFile("../../plugin/core/daemon.ts")
if err != nil {
t.Fatal(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* stale info file, a socket with nothing behind it, two daemons at once. A
* mocked fetch would pass every one of them.
*
* bun test plugin/opencode/mcpx/daemon.test.ts
* bun test plugin/core/daemon.test.ts
*/

import { afterEach, describe, expect, test } from "bun:test";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* socket and -- when the Go suite hands one over in OPS_LIVE_SOCKET -- against
* a real daemon.
*
* bun test plugin/opencode/mcpx/ops.test.ts
* bun test plugin/core/ops.test.ts
*
* The fake half proves the request shapes: that a path parameter is escaped,
* a raw body arrives as bytes, a bare-document route receives the document.
Expand Down
10 changes: 5 additions & 5 deletions pkgs/mcpx/plugin/opencode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ is the way to configure a drop-in installation.
| file | what it is for |
| --- | --- |
| `mcpx-session.ts` | the opencode adapter: hooks, tools, toasts, and the session id. The only file opencode loads as a plugin. |
| `mcpx/daemon.ts` | the portable core: the daemon HTTP client, the discovery ladder, and the remembered-choice file. Imports nothing from opencode. |
| `mcpx/daemon.test.ts` | `bun test` over the ladder, against real sockets and real temporary state directories. |
| `../core/daemon.ts` | the portable core: the daemon HTTP client, the discovery ladder, and the remembered-choice file. Imports nothing from opencode. |
| `../core/daemon.test.ts` | `bun test` over the ladder, against real sockets and real temporary state directories. |
| `mcpx/ops.gen.ts` | a typed method for every `/v1` operation, generated from the Go operation table. Do not edit; `go test ./internal/api -run TestPluginOpsAreGenerated -update` rewrites it. |
| `mcpx/ops.test.ts` | `bun test` over the generated methods, against a fake daemon and -- run from the Go suite -- a real one. |
| `mcpx-tui.tsx` | optional TUI plugin: a real picker for the daemon. Different realm, different API, installed separately. |
Expand Down Expand Up @@ -319,7 +319,7 @@ With no daemon the record is **dropped**, not spawned. A timing is not worth

## Talking to the daemon directly

`mcpx/daemon.ts` connects over the unix socket instead of spawning. Measured
`../core/daemon.ts` connects over the unix socket instead of spawning. Measured
here, same request, mean of thirty:

| | |
Expand All @@ -335,7 +335,7 @@ rather than transport. That does not matter for something called once a session.
It matters a great deal for anything on the path of every tool call.

```ts
import { connect } from "./mcpx/daemon.ts"
import { connect } from "../core/daemon.ts"

const { client, discovery } = await connect({ directory })
if (client) await client.call("fff", "grep", { query: "x" }, sessionID)
Expand Down Expand Up @@ -398,7 +398,7 @@ them at runtime.
## Tests

```sh
bun test plugin/opencode/mcpx/daemon.test.ts
bun test plugin/core/daemon.test.ts
```

Real unix sockets and real temporary state directories, because every failure
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/mcpx-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
type Discovery,
type DiscoverOptions,
type Target,
} from "./mcpx/daemon.ts";
} from "../core/daemon.ts";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the shared core in the documented plugin installation

For users following plugin/opencode/README.md:26–28, the installation still copies only mcpx-session.ts and mcpx/ into ~/.config/opencode/plugin/. This new import instead requires ~/.config/opencode/core/daemon.ts, and neither that copy command nor the plugin/opencode/ subtree includes the relocated core. Repository-wide searches found no replacement installation step that supplies it. Fresh installations and upgrades following those instructions therefore fail to load the session plugin; the optional TUI has the same dependency. Update the installation layout and copy instructions alongside the relocation.

Useful? React with 👍 / 👎.

// The only reliable way to tell, in v1, whether anyone is looking at a
// screen. See `headless` below.
import { isMainThread } from "node:worker_threads";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/mcpx-tui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
targetKey,
writeRemembered,
type Candidate,
} from "./mcpx/daemon.ts"
} from "../core/daemon.ts"

const id = "mcpx-daemon-picker"

Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/mcpx/ceiling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { existsSync } from "node:fs"
import { describe, expect, test } from "bun:test"

import { DaemonClient } from "./daemon.ts"
import { DaemonClient } from "../../core/daemon.ts"

const socket = process.env.CEILING_SOCKET
const mark = process.env.CEILING_MARK as string
Expand Down
4 changes: 2 additions & 2 deletions pkgs/mcpx/plugin/opencode/v2/daemon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The daemon core is harness-free and shared with v1: discovery, the /v1
* socket client, ranking and the remembered-target types all live in
* ../mcpx/daemon.ts and are imported unchanged (design doc §5). This module
* ../../core/daemon.ts and are imported unchanged (design doc §5). This module
* exists so the v2 tree names its dependency in one place.
*/
export * from "../mcpx/daemon.ts";
export * from "../../core/daemon.ts";
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* pinned Context supports (picker.ts records the evidence).
* The v1 tree stays beside this one, untouched, until v2 is what runs.
*/
import { targetKey, type Target } from "../mcpx/daemon.ts";
import { targetKey, type Target } from "../../core/daemon.ts";
import { appendContextOnce, type ContextHookInput } from "./context.ts";
import { resolveOptions, type Options } from "./options.ts";
import { wirePermissionGate, type PermissionDomainLike } from "./permission.ts";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* and these are reads, not sets. (An earlier draft listed the names in
* a quoted array and failed that test on all twelve.)
*/
import { goDurationMs, splitArgs } from "../mcpx/daemon.ts";
import { goDurationMs, splitArgs } from "../../core/daemon.ts";

export type Options = {
/** A daemon named outright. `unix:///path` or `http://host:port`. */
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/picker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* bun test plugin/opencode/v2/picker.test.ts
*/
import { describe, expect, test } from "bun:test";
import { targetKey, type Candidate, type Target } from "../mcpx/daemon.ts";
import { targetKey, type Candidate, type Target } from "../../core/daemon.ts";
import { buildPickerOptions, renderPickerMenu, runPickerSelection, type PickerScope } from "./picker.ts";

const a: Target = { kind: "socket", path: "/tmp/a.sock" };
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* apply in, a discriminated outcome out — so the stub-host tests are
* the contract, exactly as with the rest of the v2 tree.
*/
import { ago, label, targetKey, type Candidate, type Target } from "../mcpx/daemon.ts";
import { ago, label, targetKey, type Candidate, type Target } from "../../core/daemon.ts";
import { DAEMON_SELECT_ACTION, type PermissionAssertInput } from "./permission.ts";

export type PickerScope = "session" | "until-gone" | "indefinite" | "permanent";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/mcpx/plugin/opencode/v2/remember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* was seen, and a caller that health-checks the target drops the record when
* the check fails (see recallDaemon).
*/
import type { Target } from "../mcpx/daemon.ts";
import { targetKey } from "../mcpx/daemon.ts";
import type { Target } from "../../core/daemon.ts";
import { targetKey } from "../../core/daemon.ts";

/** The slice of ctx.storage this module needs (structural, host-provided). */
export type StorageLike = {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/sampling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* second answer) leaves the question open for the next poll or
* another answerer, and never fails the session or setup.
*/
import type { DaemonClient } from "../mcpx/daemon.ts";
import type { DaemonClient } from "../../core/daemon.ts";

/** The slice of the daemon client the watcher uses. */
export type SamplingDaemonLike = Pick<DaemonClient, "pendingElicitations" | "answer">;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* bun test plugin/opencode/v2/tools.test.ts
*/
import { describe, expect, test } from "bun:test";
import { rank, targetKey, type Candidate, type Discovery, type DiscoverOptions, type Target } from "../mcpx/daemon.ts";
import { rank, targetKey, type Candidate, type Discovery, type DiscoverOptions, type Target } from "../../core/daemon.ts";
import { resolveOptions } from "./options.ts";
import { setupMcpxV2, type McpxV2Context } from "./index.ts";
import { rememberDaemon, type StorageLike } from "./remember.ts";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/mcpx/plugin/opencode/v2/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
type Discovery,
type DiscoverOptions,
type Target,
} from "../mcpx/daemon.ts";
} from "../../core/daemon.ts";
import type { Options } from "./options.ts";
import { DAEMON_SELECT_ACTION, type PermissionAssertInput } from "./permission.ts";
import { renderPickerMenu, runPickerSelection, type PickerScope } from "./picker.ts";
Expand Down
Loading