Cross-platform sugarfree CLI + shared SugarCore + build pipeline - #7
Merged
Conversation
Extract the formatting-stripping and table-transform logic into a SwiftPM SugarCore library (single source of truth) and add a cross-platform `sugarfree` CLI, plus CI/release workflows and AI-harness hook examples. - Sources/SugarCore: Sugar/Transform/TransformOutputFormat enums, stripHTML/ stripPlainText (pure), stripRTF (#if canImport(AppKit), macOS only), and TableConverter (moved from the app). Logic byte-for-byte preserved. - macOS app now links SugarCore (project.yml packages/dependencies) instead of defining the logic itself, so app + CLI never drift. - Sources/sugarfree: swift-argument-parser CLI, a stdin->stdout filter mirroring the app defaults (bold+italic on); --all/--none, per-sugar flags, --tables, --table-format, --clipboard (best-effort cross-platform), --check. - Tests moved to SwiftPM (Tests/SugarCoreTests) + new StripTests; replaces the Xcode SugarfreeTests target. - .github/workflows: ci.yml (build+test macOS/Linux) and release.yml (binaries for macOS-universal, Linux x86_64/arm64, Windows x86_64, with checksums). - hooks/: Claude Code + generic harness + build-gate recipes. - Docs: cli/README.md, hooks/README.md, README + CLAUDE.md updates. https://claude.ai/code/session_01EXHssRUv7jTr6gShE8Yi2o
macOS users who install the .dmg now also get the sugarfree CLI: - release.sh builds the universal CLI, embeds it at Contents/Resources/sugarfree, signs it (hardened runtime), and re-signs the app so notarization covers it. - CLIInstaller symlinks the bundled binary into /usr/local/bin on first launch (direct symlink when writable, admin prompt only as a fallback), tracked once in UserDefaults. Wired into AppDelegate for both first-run (after onboarding) and the first launch after an update. - Linux/Windows are unchanged: CLI-only downloads, no app. Docs updated (README, RELEASING, CLAUDE) to describe the per-platform delivery. https://claude.ai/code/session_01EXHssRUv7jTr6gShE8Yi2o
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.
What
Adds a cross-platform
sugarfreeCLI for use in shell pipelines, AI-harness hooks, and build workflows — reusing the macOS app's stripping logic rather than duplicating it, per the project's single-source-of-truth contract.How it's structured
SugarCoreSwiftPM library (Sources/SugarCore/) is now the single source of truth:Sugar/Transform/TransformOutputFormatenums (moved out ofPasteboardMonitor.swift)stripHTML/stripPlainText— pure Foundation, byte-for-byte preservedstripRTF— gated#if canImport(AppKit), so it's macOS-only and the rest still compiles on Linux/WindowsTableConverter— moved from the app (unchanged logic)SugarCore(project.ymlpackages:/dependencies:) instead of defining the logic itself, so the app and CLI can never drift. The old XcodeSugarfreeTeststarget is replaced by SwiftPM tests.sugarfreeCLI (Sources/sugarfree/,swift-argument-parser): a stdin→stdout filter mirroring the app's defaults (bold+italic on). Flags:--all/--none, per-sugar--bold/--no-bold…,--format auto|text|html|rtf,--tables+--table-format yaml|toml,--clipboard(best-effort cross-platform),--check(exit 3 if content would change).Pipeline / binaries
.github/workflows/ci.yml—swift build+swift test+ CLI smoke test on macOS and Linux..github/workflows/release.yml— onv*tags, builds CLI binaries with SHA256 checksums for:--static-swift-stdlib)ubuntu-24.04-armrunner)continue-on-error, since Swift-on-Windows CI is the least stable leg)release.sh) is untouched — this is purely additive.AI-harness hooks & docs
hooks/— Claude CodeStop/UserPromptSubmitexamples, astrip-clipboard.shwrapper, a generic-harness recipe, and a--check-based build gate.cli/README.md,hooks/README.md, and updates toREADME.md/CLAUDE.md.Tests
Tests/SugarCoreTests/— the existingTableConvertertests (relocated) plus newStripTestscovering the HTML/plain-text strippers.This was developed in a Linux container without a Swift toolchain, so I could not compile or run
swift build/swift testlocally. Correctness of the build is gated on CI (theci.ymlworkflow). The macOS-app rewire (linkingSugarCorevia XcodeGen) and the Windows release leg in particular need a CI run to confirm. Reviewers should let CI run before merging; I'm happy to fix anything it surfaces.https://claude.ai/code/session_01EXHssRUv7jTr6gShE8Yi2o
Generated by Claude Code