Add preview_playground tool and fix build system detection - #38
Merged
Conversation
Add a playground feature for quick SwiftUI prototyping without any project setup: - preview_playground MCP tool: creates a temp file with provided code (or default skeleton), starts a preview session, returns file path for editing with hot-reload - `previewsmcp playground` CLI command: creates temp file, prints path, starts live preview with file watching - Fix build system detection false positive: fileExists now rejects directories, preventing case-insensitive matches (e.g., ~/workspace/ directory matching Bazel's WORKSPACE marker) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion tests Extract shared helpers (launchMacOSPreview, launchIOSPreview, createPlaygroundFile, defaultPlaygroundCode) into BuildHelpers.swift, eliminating duplicated compile→load→watch logic across MCPServer, RunCommand, and PlaygroundCommand. Extract startMacOSPreview in MCPServer.swift shared by handlePreviewStart and handlePreviewPlayground. Add 3 tests verifying that directories named Package.swift or MODULE.bazel are correctly ignored by SPMBuildSystem and BuildSystemDetector (covers the isDirectory fix). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
playground now accepts an optional file path to use an existing Swift file instead of creating a temp one. Path is printed to stdout for piping to editors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
obj-p
force-pushed
the
playground-and-detection-fix
branch
from
March 22, 2026 00:43
ad11768 to
6004e43
Compare
Co-Authored-By: Claude Opus 4.6 (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
Closes #27. Adds a playground feature for quick SwiftUI prototyping — no project setup needed. Also fixes a build system detection bug found during development.
Playground
preview_playground: Creates a temp Swift file (with provided code or default skeleton), starts a preview session, returns the file path so the agent can edit it for hot-reloadpreviewsmcp playground: Creates a temp file, prints its path, starts a live preview with file watchingBug fix: build system detection false positive
BazelBuildSystem.detectusedFileManager.fileExistswhich returnstruefor directories. On macOS's case-insensitive filesystem, a~/workspace/directory matched Bazel'sWORKSPACEmarker, causing standalone files under~/to fail with a Bazel detection false positive. Fixed in all three detectors (Bazel, SPM, BuildSystemDetector) to reject directories.Test plan
preview_playgroundwith no code — creates default skeleton, renderspreview_playgroundwith custom code — login form renders correctlypreview_starton~/.previewsmcp/playground/no longer falsely detects Bazelswift buildpassesswift test --filter BuildSystem— 37/37 tests pass🤖 Generated with Claude Code