Skip to content

Cross-platform sugarfree CLI + shared SugarCore + build pipeline - #7

Merged
donny-son merged 2 commits into
mainfrom
claude/sugarfree-cli-pipeline-pqMom
Jun 8, 2026
Merged

Cross-platform sugarfree CLI + shared SugarCore + build pipeline#7
donny-son merged 2 commits into
mainfrom
claude/sugarfree-cli-pipeline-pqMom

Conversation

@donny-son

Copy link
Copy Markdown
Owner

What

Adds a cross-platform sugarfree CLI 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

  • SugarCore SwiftPM library (Sources/SugarCore/) is now the single source of truth:
    • Sugar / Transform / TransformOutputFormat enums (moved out of PasteboardMonitor.swift)
    • stripHTML / stripPlainText — pure Foundation, byte-for-byte preserved
    • stripRTF — gated #if canImport(AppKit), so it's macOS-only and the rest still compiles on Linux/Windows
    • TableConverter — moved from the app (unchanged logic)
  • macOS app links SugarCore (project.yml packages:/dependencies:) instead of defining the logic itself, so the app and CLI can never drift. The old Xcode SugarfreeTests target is replaced by SwiftPM tests.
  • sugarfree CLI (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.ymlswift build + swift test + CLI smoke test on macOS and Linux.
  • .github/workflows/release.yml — on v* tags, builds CLI binaries with SHA256 checksums for:
    • macOS universal (arm64 + x86_64)
    • Linux x86_64 (--static-swift-stdlib)
    • Linux arm64 (native ubuntu-24.04-arm runner)
    • Windows x86_64 (continue-on-error, since Swift-on-Windows CI is the least stable leg)
  • The macOS app DMG (release.sh) is untouched — this is purely additive.

AI-harness hooks & docs

  • hooks/ — Claude Code Stop / UserPromptSubmit examples, a strip-clipboard.sh wrapper, a generic-harness recipe, and a --check-based build gate.
  • cli/README.md, hooks/README.md, and updates to README.md / CLAUDE.md.

Tests

  • Tests/SugarCoreTests/ — the existing TableConverter tests (relocated) plus new StripTests covering the HTML/plain-text strippers.

⚠️ Verification note

This was developed in a Linux container without a Swift toolchain, so I could not compile or run swift build / swift test locally. Correctness of the build is gated on CI (the ci.yml workflow). The macOS-app rewire (linking SugarCore via 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

claude added 2 commits June 7, 2026 09:14
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
@donny-son
donny-son merged commit d44a3a6 into main Jun 8, 2026
2 checks passed
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.

2 participants