Fix invalid triple-quote delimiter in generated Swift plugin scaffold#1701
Open
jax-0n-git wants to merge 1 commit into
Open
Fix invalid triple-quote delimiter in generated Swift plugin scaffold#1701jax-0n-git wants to merge 1 commit into
jax-0n-git wants to merge 1 commit into
Conversation
`osaurus tools create <name>` (default language `swift`) emits a `Sources/<module>/Plugin.swift` whose `get_manifest` body opens a multiline string with `\"\"\"` instead of a bare `"""`. The scaffold template (`pluginSwift`) is itself a Swift `"""..."""` literal. The manifest delimiters were written as `\\"\\"\\"`; inside the outer literal `\\` collapses to one backslash and `\"` to one quote, so the generated file gets the literal text `\"\"\"` (`let manifest = \"\"\"`) — a stray backslash outside any string literal, which is a Swift syntax error. The scaffolded plugin does not compile out of the box. Drop one backslash per quote (`\\"\\"\\"` -> `\"\"\"`) at both the opening and closing manifest delimiter so the generated file gets a valid bare `"""`. The Rust path is unaffected (it uses an `r#"..."#` raw string). Adds a regression test asserting the generated Plugin.swift opens the manifest with a bare triple-quote and not an escaped-quote triple. Co-Authored-By: Claude Opus 4.8 <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
osaurus tools create <name>with the default language (swift) scaffolds aSources/<module>/Plugin.swiftthat does not compile.The scaffold template (
ToolsCreate.createSwiftPlugin'spluginSwift) is itself a Swift"""..."""literal. Theget_manifestbody opens its manifest with the delimiter written as\\"\\"\\"(ToolsCreate.swift:415, and the matching close at:446). Inside the outer multiline literal,\\collapses to one backslash and\"to one quote, so the generated file receives the literal text\"\"\":That is a stray backslash outside any string literal — a Swift syntax error. Every Swift plugin scaffolded by the CLI fails to build out of the box.
The fix drops one backslash per quote (
\\"\\"\\"->\"\"\") at both the opening and closing manifest delimiter, so the generated file gets a valid bare""". The Rust path is unaffected — it uses anr#"..."#raw string.Changes
Test Plan
swift testinPackages/OsaurusCLI(89 tests green, +1 new) +swift-format lint --strictclean. The new test (testSwiftManifestUsesValidTripleQuoteDelimiter) reads the generatedPlugin.swiftand asserts it opens the manifest with a bare"""and not an escaped-quote triple; it fails on the pre-fix template and passes after. No MLX/GUI dependency.