You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ed3140f
Browse filesBrowse the repository at this point in the historyBrowse files
feat(config): MCP server editing -- split Patch to make secret loss inexpressible
Foundational piece for MCP config editing (TKT-323, operator priority):
adds add/edit/remove for MCP servers through the existing typed config-
document Patch mechanism. Caught before any consumer existed: the obvious
shape (mcp.server.set takes a full ConfigMCP.Server, whole-value write)
would have silently destroyed a server's credentials on every connection-
detail edit that didn't also resupply them -- and the client structurally
cannot resupply them, since every read response redacts secret fields by
design (the anomalyco#191 fix). Verified directly: modify()'s whole-value replace
at ["mcp","servers",name] discards any field absent from the incoming
value, and there is no way for an editor working from a redacted view to
correctly round-trip a value it never held.
THE FIX (lead ruling): split the op at the schema level rather than merge
at write time from client-supplied data.
- mcp.server.set's value narrows to ConfigMCP.ServerNonSecret -- a type
that structurally cannot mention environment/headers/oauth.client_secret,
so a connection-detail edit cannot destroy what it cannot carry. Applied
server-side via mergeNonSecretPatch: the EXISTING secret fields (read
fresh from the current on-disk text, never from the patch) are carried
forward onto the merged write, but only when the server's own `type` is
unchanged (local's environment and remote's headers/oauth are different
shapes -- a type change has nothing compatible to carry over).
- New mcp.server.credential.set(name, key, value) / .credential.remove
write or delete exactly one named secret slot, never reading the old
value back. CredentialKey reuses the same three-location allowlist
mcpSecretPaths already enumerates for redaction, so read-side and
write-side allowlists cannot drift into naming different fields.
- patchWritesRedactedSentinel narrows to credential.set only -- the other
three ops cannot carry a secret value at all post-split, so there's
nothing left for the sentinel-rejection check to catch on them.
Delete-the-fix proof, as required: "applyPatch: editing a server's command
preserves its existing secret fields" confirmed RED against a temporarily
reverted whole-value-replace write (the secret came back as `undefined`
after an unrelated command edit -- concrete, not hypothetical), GREEN under
the split. Also covers: type-change doesn't carry over incompatible secret
shapes, credential.set/.remove work standalone, and the sentinel-rejection
test moved onto credential.set.
Client: mcp-catalog-client.ts renamed mcp-client.ts and widened in place
(lead ruling: same file, not a 5th bounded importer, since MCP editing is
the same feature this file already serves) to add configDocument.target
Read/Validate/Apply. All three sibling headers + FORK.md's ledger updated
to describe the widened scope; the boundary is stated explicitly (MCP tab
only -- skills/plugins/profiles editing gets its own widen-or-new decision
when a second real consumer exists, not before).
Wire change: packages/client regenerated (Patch's mcp.server.set payload
narrowed, two new ops added) -- drift guard verified clean in the same
commit. Full monorepo typecheck 32/32, core suite 1199/1199, app suite
754+41/0 fail, httpapi-exercise effect mode 236/0.
App UI (add/edit/remove forms on the MCP tab) follows in a subsequent
commit on this branch.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
Copy file name to clipboardExpand all lines: FORK.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ retires it without reading every PR.
61
61
| Temporary `@opencode-ai/client-next` alias in `packages/app`, reaching the workspace client for **six** session-lifecycle calls: four mutations (`restore`, `trash`, `restoreFromTrash`, `purge`) plus `list` (lifecycle-aware, index-summary shape) and `get` (TKT-314, session-entities feed) ([#11](https://github.com/Draugur-AI/opencode/pull/11)) | `packages/app` pins `@opencode-ai/client` to a vendored tarball generated before session lifecycle existed, so those routes are absent from it — including a lifecycle-filterable list, which the normalized entity store's snapshot feed needs (`lifecycle: "all"`) and the vendored client cannot express at all. Archive is deliberately NOT on the alias: it still goes through the V1 route, which the slice-1 server adapter drives into the same lifecycle service. Migrating the app off the vendored client is 42 files and its own ticket | n/a — fork-only packaging workaround | none | none | **remove** — deleted together with the vendored tarball by **TKT-328** (app + session-ui onto one client, amended to cover all four importers below). Bounded by construction: `packages/app/src/utils/session-lifecycle-client.ts` is this alias's only importer for session-lifecycle calls and says so in its header — see the next three rows for the project-calls, goal/ledger-calls, and mcp-catalog-calls siblings, each added by ruling rather than by drift. **Four** importers total as of the Integrations page's 2026-08-12 re-scope (was three, was two before TKT-328's 2026-08-11 re-scope); none may accrete further without another re-scope |
62
62
| Second `@opencode-ai/client-next` importer, `packages/app/src/utils/project-client.ts`, reaching the workspace client for **five** project calls (`list`, `get`, `updateMetadata`, preference `read`, preference `write`) (TKT-315) | Same vendored-tarball gap as the row above, for project data instead of session lifecycle: the vendored client predates PR #8's project/preference endpoints entirely, so TKT-315's app half (favorites that persist server-side — the entire point of "two browsers converge on the same favorites") cannot be built against it. Ruled rather than assumed: extending `session-lifecycle-client.ts` itself was rejected because that file is Henry's, under active use by his views work, and editing it mid-flight would manufacture the exact collision the one-importer discipline exists to prevent. A second, equally narrow, equally bounded file was the correct shape instead of either widening the first file or blocking the ticket on a vendored client with no preference support at all | n/a — fork-only packaging workaround | none | none | **remove** — deleted together with the vendored tarball and the row above by **TKT-328**, now covering all three importers by amendment. Bounded by construction, same discipline as the row above: `project-client.ts` is this half's only importer and says so in its own header |
63
63
| Third `@opencode-ai/client-next` importer, `packages/app/src/utils/goal-ledger-client.ts`, reaching the workspace client for **six** session goal/ledger calls: `serverGoal.get`/`update`/`status` plus `serverLedger.list`/`add`/`supersede` (TKT-335) | Same vendored-tarball gap as the two rows above, for the durable session goal and working ledger (TKT-317, design post "Durable agent intent must survive compaction") instead of session lifecycle or project data: the vendored client predates PR #7's goal/ledger routes entirely, so TKT-335's goal side panel and ledger panel (objective, acceptance criteria, constraints, supersede) cannot be built against it. Re-scoped rather than assumed: TKT-328 was originally bounded to two importers ("neither accretes further"); the lead re-scoped it 2026-08-11 after a mechanical-migration attempt measured 534 semantic type errors, explicitly admitting a third bounded importer as part of TKT-328's own interim state rather than blocking TKT-335 on a vendored client with no goal/ledger support at all | n/a — fork-only packaging workaround | none | none | **remove** — deleted together with the vendored tarball and the two rows above by **TKT-328**. Bounded by construction, same discipline as the rows above: `goal-ledger-client.ts` is this half's only importer and says so in its own header |
64
-
| Fourth `@opencode-ai/client-next` importer, `packages/app/src/utils/mcp-catalog-client.ts`, reaching the workspace client for **two** calls: `mcp.list` (static catalog) and `mcp.status` (live per-server connection status) (TKT-323 chunk 3) | Re-scoped, not assumed: the Integrations page cannot exist on either other client — the vendored tarball's `mcp.list` is a stale, differently-shaped `McpServer` type (a `pending` status this domain's union does not have) with no `status` method at all, and `@opencode-ai/sdk` v2 (`useServerSDK()`) only has the legacy `/mcp` surface, no `/api/mcp` or `/api/mcp/status` — so this page exists via client-next or not at all | n/a — fork-only packaging workaround | none | none |**remove** — deleted together with the vendored tarball and the three rows above by **TKT-328**. Bounded by construction, same discipline as the rows above: `mcp-catalog-client.ts` is this half's only importer and says so in its own header |
64
+
| Fourth `@opencode-ai/client-next` importer, `packages/app/src/utils/mcp-client.ts` (named `mcp-catalog-client.ts` at first, renamed the same day it widened), reaching the workspace client for **five** calls: `mcp.list`/`mcp.status` (the catalog + live status) and config-document's `targetRead`/`targetValidate`/`targetApply` (editing an MCP server through the same tab, TKT-323 MCP config editing) | Re-scoped twice, not assumed, both times: (1) the Integrations page cannot exist on either other client — the vendored tarball's `mcp.list` is a stale, differently-shaped `McpServer` type (a `pending` status this domain's union does not have) with no `status` method at all, and `@opencode-ai/sdk` v2 (`useServerSDK()`) only has the legacy `/mcp` surface, no `/api/mcp` or `/api/mcp/status`; (2) widening the SAME file (not a fifth) for config-document's three verbs, since MCP editing is the same feature this file already serves and needs them for the identical UI surface — a fifth file for the identical purpose would add nothing the bound exists to prevent. Scope explicitly bounded to what the MCP tab needs; skills/plugins/profiles editing gets its own widen-or-new decision when a second real consumer of config-document read/validate/apply exists, not before | n/a — fork-only packaging workaround | none | none | **remove** — deleted together with the vendored tarball and the three rows above by **TKT-328**. Bounded by construction, same discipline as the rows above: `mcp-client.ts` is this half's only importer and says so in its own header |
65
65
| Session profiles: `Profile.Definition`/`Profile.Snapshot` schemas, immutable `session_profile_snapshot` table + `session.profile_snapshot_id`, `SessionEvent.ProfileSwitched` (event-sourced, carries the full resolved snapshot so the projector needs no second read), `SessionProfile` core service (`resolve`/`get`/`context`/`toolDenyRuleset`), `PermissionV2.configured` merging a profile's deny-only ruleset into every leaf `assert`/`ask` call, `ToolRegistry.materialize` widened from `materialize(permissions)` to `materialize({permissions, profileToolRules})`, `SkillGuidance.load` widened with an optional `skillRules` filter, built-in `coding`/`chat` definitions (core code constants, not DB rows), and a contained V1 hook-identity refactor (`packages/opencode/src/plugin/index.ts`'s flat `Hooks[]` → `LoadedHooks{pluginID, origin, hooks}[]`) (TKT-321) | Upstream has no durable per-session policy overlay at all — a "chat vs. coding" toggle would have to hide UI without touching what the model can actually invoke, exactly the "profiles produce security theater" risk the validation post names. Design post, "Session profiles solve chat versus coding behavior"; build post, "Profiles: persist behavior, not just a label" | not yet filed | Adds `session_profile_snapshot` (append-only, FK cascade to `session`) and a nullable `session.profile_snapshot_id`; one new durable event type, additive. `MaterializeRequest`/`SkillGuidance.load`'s new param are both additive/optional — no existing caller signature became invalid without a corresponding call-site fix in the same PR | `20260811182549_session_profile_snapshot`: additive DDL only, no backfill (pre-migration sessions simply read as "no profile resolved yet," per `SessionProfile.get`'s documented undefined case) | **upstream** for the schema/policy/skill-filtering half — exactly what the design/build posts argue upstream needs. **Deferred, not upstream, not fork-only**: (1) resolve-on-session-create wiring (a session does not yet get a profile automatically; the demo test in `test/permission.test.ts` resolves one explicitly), (2) MCP tool materialization filtering (`mcpRules` exists in the schema, but `packages/core/src/tool` has no MCP tool registration path to filter yet — the comment in `tool/builtins.ts` says as much), (3) the app-side composer UI (current profile display, switch diff) — coordinate-with-Henry per the ticket, not attempted this PR, (4) threading `TriggerContext` (sessionID + resolved profile) through `Plugin.Service.trigger` for session-aware hook filtering — `trigger()` has 20+ call sites across `packages/opencode/src`, too large a blast radius for this PR; `LoadedHooks` preserves the identity a follow-up needs without touching any of them |
66
66
| Config document writer, chunk 1: `packages/core/src/config/document.ts` (`listTargets`/`readTarget`/`effective`-with-provenance/`validatePatch`/`applyPatch`, allowlisted typed `Patch` union, atomic temp-file-then-rename write, sha256 optimistic hash check, opaque server-derived `TargetID` — never a browser-supplied path), `McpCatalog` core read model (declared servers only), two new Protocol groups (`config-document`: generic patch-apply surface every future catalog reuses; `mcp`: read-only `mcp.list`), wire types relocated `packages/core/src/config/mcp.ts` → `packages/schema/src/config-mcp.ts` (protocol cannot depend on core; core now re-exports, same pattern as Integration/SessionProfile) plus two new schema modules (`config-document.ts`, `mcp-catalog.ts`) (TKT-323) | Upstream has no editable-config surface at all — `Config.Info` is read-oriented and merges global/project silently; a settings UI serializing the merged result back to one file would destroy comments, provenance, and overrides. Build post, "Configuration UI: edit a source document, never the merged result" | not yet filed | No table changes — config lives in files, not the DB. Two new durable-free schema modules (config-document.ts, mcp-catalog.ts); `ConfigMCP.Server`/`Local`/`Remote`/`OAuth`/`Timeout` moved from core to schema, core re-exports — no consumer signature changed | none | **upstream** for `document.ts`'s patch-apply model and the config-document/mcp protocol groups — exactly the "edit a source document" pattern the build post argues for. **Deferred, not upstream, not fork-only**: live MCP connection/tool/resource status (`McpCatalog.Status` is `"configured"\|"disabled"` only — no core service can reach the live runtime in `packages/opencode/src/mcp/index.ts` yet; chunk 2 adds a core `McpRuntime` service TAG with the live implementation supplied as a layer at `packages/opencode`'s httpapi-assembly time, preserving the dependency direction rather than relocating the runtime), skills/plugins/profiles catalogs and their settings-v2 UI routes (chunks 2-3), `.opencode`-directory supplementary files are not yet listed as patchable targets (MCP servers live in the top-level file only) |
0 commit comments