Skip to content

Add CI, release workflow, and Homebrew distribution#1

Merged
obj-p merged 2 commits intomainfrom
homebrew-ci
Mar 19, 2026
Merged

Add CI, release workflow, and Homebrew distribution#1
obj-p merged 2 commits intomainfrom
homebrew-ci

Conversation

@obj-p
Copy link
Copy Markdown
Owner

@obj-p obj-p commented Mar 19, 2026

Summary

  • GitHub Actions CI: build + run PreviewsCoreTests on push/PR to main
  • Release workflow: on tag push (v*), builds release binary, creates GitHub Release, updates obj-p/homebrew-tap formula
  • Homebrew: brew tap obj-p/tap && brew install previewsmcp
  • Bug fix: --help was printing raw CommandError instead of formatted help text (HelpCommand returned by parseAsRoot() was routed through NSApplication path)

Test plan

  • swift test --filter PreviewsCoreTests — 26/26 pass
  • previewsmcp --help — prints formatted help
  • previewsmcp run --help — prints subcommand help
  • CI workflow runs on this PR
  • After merge: tag v0.1.0, verify release + Homebrew formula update

🤖 Generated with Claude Code

obj-p and others added 2 commits March 18, 2026 22:25
- 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>
@obj-p obj-p merged commit c0e5c10 into main Mar 19, 2026
1 check passed
@obj-p obj-p deleted the homebrew-ci branch March 19, 2026 02:30
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant