Add CI, release workflow, and Homebrew distribution#1
Merged
Conversation
- GitHub Actions CI: build + test on push/PR to main - Release workflow: build binary, create GitHub Release, update Homebrew tap - Homebrew formula generator script (obj-p/homebrew-tap) - README: add brew install instructions - Fix --help printing raw error by routing HelpCommand through non-NSApp path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 30, 2026
obj-p
added a commit
that referenced
this pull request
May 6, 2026
…ndle (#159) * Collapse iOS/macOS dual paths in MCP handlers behind PreviewSessionHandle Every multi-platform MCP tool handler hand-coded `if let iosSession = ... / else macOS ...`, with `preview_variants` carrying ~95 nearly-identical lines per branch and the still-registered guard duplicated at MCPServer.swift:1049 and :1137. Introduce a `PreviewSessionHandle` protocol with iOS and macOS adapters, plus a `SessionRouter` that resolves a session ID to whichever backend owns it. Handler dispatch becomes single-path; the macOS-specific `host.loadPreview` after `setTraits` and the 300ms layout-settle pause move into `MacOSPreviewHandle.setTraits`. MCPServer.swift drops 194 lines (1325 → 1131); the new abstractions add 214. Net +20 LOC for the collapse, but `handlePreviewVariants` shrinks 195 → 100, `handlePreviewSwitch` 84 → 47, `handlePreviewConfigure` 50 → 28, `handlePreviewStop` 41 → 23, `handlePreviewSnapshot` 51 → 22, and `configQualityForSession` 9 → 4. Step #2 of the architectural roadmap. Handler-per-file split (#1) is the follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Move 300ms layout-settle out of setTraits into explicit awaitLayoutSettle The previous commit folded the post-loadPreview pause into MacOSPreviewHandle.setTraits, which meant the variants restore step (which doesn't snapshot) also paid 300ms per call. That was negligible in isolation but compounded with CI's slower compile times — the preview_variants test on build-and-test wedged past its 60s callTool budget (44s on main → timeout on PR). Add an explicit `awaitLayoutSettle()` to PreviewSessionHandle. macOS sleeps 300ms; iOS no-ops. The variants handler calls it between setTraits and snapshot inside the loop only — restore reverts to original zero-sleep behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7 tasks
obj-p
added a commit
that referenced
this pull request
May 6, 2026
…162) * Split MCPServer.swift into per-tool handler files behind ToolHandler Step #1 of the architectural roadmap. The previous shape had three sources of truth that had to stay in lockstep: the `ToolName` enum, the `mcpToolSchemas()` array in MCPToolSchemas.swift, and the `switch tool` dispatch in `configureMCPServer`. Adding a tool meant touching three places. Introduce a `ToolHandler` protocol with `static var name`, `static var schema`, and `static func handle(_:ctx:)`. Each of the 12 tools moves to its own file under `Sources/PreviewsCLI/Handlers/`, carrying the schema next to the implementation. `configureMCPServer` derives both the `ListTools` response and the `CallTool` dispatch from a single `handlerRegistry` array — the array IS the inventory. `HandlerContext` bundles the engine-layer dependencies (host, iosState, configCache, router, macCompiler, server) so handlers receive deps via parameter rather than reaching for file-private vars. Static handler types are `Sendable`-trivially since they have no instance state. `MCPServer.swift` shrinks from 1131 to 92 lines (target was <200); shared infrastructure moves to `MCPServerSupport.swift` (heartbeat, progress reporter, version advertisement, `parseTraits`, `configQualityForSession`); `MCPToolSchemas.swift` is deleted. The acceptance gate from the architectural plan — "ListTools response bytes are identical pre/post" — is enforced by a new `ListToolsSnapshotTests` snapshot that pins the JSON-encoded schemas against a fixture file. The pre-refactor bytes were captured on the prior commit, and the test passes against the post-refactor registry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address #162 review nits: comments on uniqueKeysWithValues + bless-mode Two small comment additions from the code-reviewer pass: - Document why `Dictionary(uniqueKeysWithValues:)` is the right fail-fast for a future contributor who copies a handler and forgets to update `static let name` — the trap fires at server construction (visible in tests) rather than on the first call. - Explain the bless-mode early-return in `ListToolsSnapshotTests` — we deliberately skip the equality check after writing the snapshot because it would tautologically pass; the issue-record is the signal to commit the new fixture. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PreviewsCoreTestson push/PR to mainv*), builds release binary, creates GitHub Release, updatesobj-p/homebrew-tapformulabrew tap obj-p/tap && brew install previewsmcp--helpwas printing rawCommandErrorinstead of formatted help text (HelpCommand returned byparseAsRoot()was routed through NSApplication path)Test plan
swift test --filter PreviewsCoreTests— 26/26 passpreviewsmcp --help— prints formatted helppreviewsmcp run --help— prints subcommand helpv0.1.0, verify release + Homebrew formula update🤖 Generated with Claude Code