HomeiOS DevelopmentJSON All of the Approach Down

JSON All of the Approach Down


All the things that occurred on github.com/Cocoanetics because the SwiftText publish — and it’s greater than I anticipated to suit into three weeks: a basis bundle that didn’t exist on June 23 and now carries three protocols, SwiftMCP turned inside out, two brand-new initiatives, releases throughout the entire mail stack — and a really welcome comeback doing the ultimate polish.

The third time you vendor a JSON sort, it desires to be a basis

Final month I wrote that the third time you copy one thing, it desires to be a bundle. It seems the rule applies one stage additional down. SwiftMCP carried its personal JSON worth sort, its personal JSON Schema mannequin for describing instruments to LLMs, and its personal JSON-RPC envelope. SwiftAgents had grown a JSONValue of its personal, full with subscripts and literal builders. And the second I began eyeing different JSON-RPC protocols, I may see myself copying all of it a 3rd time.

So on June 24 I extracted JSONValue from SwiftMCP as a dependency-free bundle. By the tip of that very same day it had absorbed the JSON Schema mannequin and the JSON-RPC 2.0 varieties — and a greater title: JSONFoundation.

What adopted was ten days of essentially the most satisfying form of work: instructing one bundle to do correctly what three packages had every achieved roughly. A spec-complete JSON-RPC envelope — params and outcomes may be any JSON worth now, not simply objects, as a result of ACP friends actually do return naked null. A transport-agnostic peer that owns correlation and dispatch. And a complete household of transports: stdio, a zero-dependency POSIX TCP consumer, HTTP+SSE in each instructions, and an in-memory loopback pair for exams that by no means contact a pipe. 9 opt-in merchandise, zero third-party dependencies within the core, constructing on macOS, iOS, Linux, Home windows, and Android. Fourteen releases, 1.0.0 by way of 2.5.0.

The perception that makes all of it click on: MCP, ACP, and LSP are the identical protocol carrying totally different garments. Identical envelope, identical request/response correlation, identical notification semantics. They differ on precisely one axis — how messages are framed on the wire. MCP over stdio desires newline-delimited JSON. LSP desires HTTP-style Content material-Size headers. Streamable HTTP desires SSE occasions. So the framing grew to become a pluggable codec, and the whole lot above it’s shared.

The onerous half was HTTP+SSE

SwiftMCP is the place all of this got here from, and SwiftMCP is the place it needed to show itself. 4 releases went out on July 1 — 1.7.0 by way of 1.9.0 — and collectively they flip the framework inside out.

The stdio and TCP transports moved onto JSONFoundation’s shared runtime with out a lot drama; no extra hand-rolled correlation or framing, and the in-process transport doesn’t even open OS pipes anymore. The HTTP+SSE server was the onerous half. It at all times is. Classes, replay buffers, resume-after-disconnect, and Swift NIO’s tendrils reaching into the whole lot. The 1.9.0 reply: a brand new MCPHTTPEngine seam that owns routing, classes, and SSE — with NIO demoted to only one adapter behind it. There’s an in-memory adapter now that drives the entire HTTP stack in exams with out opening a socket, and the SSE replay/resume equipment lives in JSONFoundation the place ACP and LSP can use it too. The purpose of the train: NIO is now swappable. Community.framework, or one other Swift HTTP server, can slot in behind the identical engine — that’s the door this refactor opens.

With the structure settled, SwiftMCP promptly acquired forward of its personal protocol: the phases of the upcoming MCP 2026-07-28 spec revision — server/uncover, sessionless Streamable HTTP, Origin allowlisting in opposition to DNS rebinding — are already applied, unadvertised till the ultimate flip.

As a result of the muse held, I acquired grasping: ACP

With the JSON-RPC runtime feeling this strong, I went on the lookout for different protocols to level it at. The apparent first goal: the Agent Shopper Protocol — the protocol editors like Zed use to speak to coding brokers. SwiftACP covers all three roles in a single import: drive an ACP agent from Swift, expose your individual app or CLI as an agent, or discuss to the bundled acpxd daemon remotely. That final one nonetheless makes me grin: an iPhone holding a dwell coding-agent session that’s really working on the Mac.

The proof-of-concept got here full circle in SwiftAgents: the bundled Coder instance now serves ACP with a single subcommand — coder acp — full with slash instructions and a local mannequin menu, so Zed reveals a dropdown that hot-switches between OpenAI, Anthropic, and Google mid-session.

After which the frustration. Neither Codex nor Claude really communicate ACP natively — not like so many different coding brokers. What acpx claude actually launches is a wrapper, and in Claude’s case that wrapper sits on the Claude Agent SDK (previously the Claude Code SDK), which trails the CLI: no reminiscence, and no ultracode — the brand new mode the place Claude authors a large workflow with resumable elements and supervises it. So I hold pondering constructing my very own harness immediately across the claude CLI to get at these options. The constructing blocks are all sitting proper there.

LSP, as a result of brokers deserve a compiler’s eyes

The second new protocol goal began as 100 strains of Python — a throwaway probe to crack how sourcekit-lsp frames its messages (Content material-Size headers, because it seems, not the newline-delimited JSON of MCP and ACP). As soon as the framing was understood, the Swift model virtually wrote itself, as a result of LSP accommodates no transport code in any respect: the peer, the framing codecs, the method transport — all JSONFoundation. It’s the proof that the unified runtime generalizes.

What you get is compiler-grade Swift code intelligence, packaged two methods: a CLI with 9 subcommands (the place finds an emblem project-wide off the index, examine reviews syntax and semantic errors with out a construct, plus declarations, references, hover) and lsp mcp, an MCP server exposing seven instruments an agent can name — backed by one long-lived sourcekit-lsp whose index stays heat throughout calls. It’s constructed for brokers within the small ways in which matter: it trims the trailing newlines brokers like to ship, streams indexing progress so a chilly name doesn’t block silently, and respawns sourcekit-lsp if it dies.

After which we acquired Fable again

I pointed it — with ultracode — at JSONFoundation for a polish cross: ten overview passes over the entire venture, each discovering adversarially verified earlier than being accepted. 82 findings survived. Eight have been real bugs: TCP writes that might SIGPIPE-kill the host course of, JSON-RPC batches silently truncated to their first message, the @Schema macro stripping umlauts and emoji out of descriptions. The check suite grew from 60 to 137 exams, and a pair of.5.0 went out as we speak because the polish launch. LSP acquired the identical therapy — two multi-agent overview rounds, 56 verified findings, from leaked processes to a 30-second stall that grew to become a bounded 3-second wait.

A activity like this runs for hours and consumes tens of millions of tokens. However this mannequin, coupled with ultracode, considers situations different brokers merely miss — the proof is everywhere in the current commit historical past. My job in it was studying verdicts and saying sure.

In the meantime, elsewhere within the org

  • SwiftText 2.0.0 (July 1) — the follow-up to “studying to write down” is escaping the Mac: the swifttext CLI now builds and runs on macOS, Linux, and Home windows, defaulting to the pure-Swift render engine off macOS. Numbers and Keynote readers full the iWork household. brew set up cocoanetics/faucet/swifttext.
  • SwiftMail 1.8.0 (July 2) — calendar invitations now exit inline per RFC 6047, so Apple Mail, Outlook, and Gmail present precise Settle for/Decline buttons as an alternative of a naked .ics attachment. Non-ASCII topics and names lastly get correct RFC 2047 encoding. IMAP acquired harder: verified IDLE teardown, coalesced authentication, configurable parser buffers.
  • Publish 1.6.8 (July 2) — the payoff launch the place the entire stack lands directly: SwiftMail 1.8, SwiftText 2.0, SwiftMCP 1.9. Working calendar invitations, right worldwide headers, and an MCP daemon that survives disconnects. Getting there required pinning dependencies to actual launch commits, as a result of SwiftPM refuses to resolve revision-pinned transitive dependencies by way of a model requirement — a conflict story of its personal. brew set up cocoanetics/faucet/publish
  • SwiftPorts — porting gh to Swift means porting its entire platform floor: gh auth login now really persists tokens on Linux (Secret Service), Home windows (Credential Supervisor), and Android (encrypted file retailer).
  • GitKit and QMDKit settled into upkeep: warning-free umbrella headers downstream, and a two-file migration to SwiftAgents’ new Credential abstraction.

The actual narrowing

Final month I stated my remaining job is noticing {that a} factor desires to be a equipment and saying so. This cycle narrowed it additional. The kits now share one wire mannequin, and the sample for a brand new protocol has grow to be nearly mechanical: decide the framing, write the typed strategies, achieved — LSP went from Python probe to printed bundle in per week that method. The people set the what; the brokers deal with the how; and more and more, the muse handles the once more.

In the event you’re constructing a coding agent: please communicate ACP natively. I’ve a bundle for you now.


Classes: Updates

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments