Skip to content
CAI
Software that uses CAICheck a score

mxcl/swift-sh

55.4

Adequate · 1 October 2026

1.6k

lines of production code

Swift

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

swift-sh is a command-line tool that enables the execution of Swift scripts with third-party dependencies by automatically parsing import comments and fetching packages. It provides a unified interface for running scripts, managing local and remote dependencies via version constraints, and converting scripts into standalone Swift Packages. The system also supports an integrated development workflow by generating Xcode projects with auto-complete capabilities and offers utilities for cache management and cross-platform process execution.

Features

Initial release of swift-sh with public domain license and CI support

This change introduces the initial version of swift-sh, a tool that allows users to write Swift scripts with third-party dependencies by parsing import comments and automatically fetching packages. The release includes a Public Domain (Unlicense) license, a .gitignore file to exclude build artifacts, and a Travis CI configuration to test the tool on macOS versions 10.14.6 through 11.3. It also adds a Swift 5.3-specific package manifest defining the core executable and library targets, along with comprehensive documentation in the README covering installation via Homebrew, usage with various dependency specifications (including local paths and SSH URLs), Xcode editing support, and CI integration.

(repo-wide) · high confidence

New example scripts for async commands, markdown rendering, and terminal colors

Added three new executable Swift scripts to the Examples directory: \async-main-count-lines\ demonstrates using the \@main\ attribute with \AsyncParsableCommand\ to count lines in a file; \ink\ shows how to parse Markdown and render it to HTML using the Ink library; and \terminal-rainbow\ displays a color palette using the Chalk library. The Examples README has also been updated to list these new resources.

Examples · high confidence

New utility modules for path hashing, process execution, and temporary directories

The Sources/Utility area introduces several new helper modules: Path+ResolvedHash provides a resolvedHash property that computes an MD5 hash of a path's real location; Process+1up adds cross-platform process execution helpers (go, runSync, launchAndWaitForSuccessfulExit) with improved stderr handling on Linux and structured error reporting; TemporaryDirectory offers a cross-platform temporary directory manager with volume-aware creation on macOS and mktemp support; etc.swift adds collection, string error, regex, and PATH resolution helpers; and exec().swift provides a safe execv wrapper with POSIX error handling.

Sources/Utility · high confidence

Support for local, SSH, and GitHub dependency imports with version constraints

The Script tool now parses import lines to automatically resolve and manage dependencies from local file paths (including relative and home-directory prefixed paths), SSH URLs (git@), and GitHub repositories (@user/repo). It supports version constraints such as exact versions (==), major version ranges (\~\>), specific references (@ref), and the latest version (latest). This allows users to import local modules and remote packages directly via comments in their scripts, with the tool generating the necessary Swift Package Manager manifest and handling caching based on file modification times.

Sources/Script · high confidence

Swift-sh edit now generates Xcode projects with auto-complete support

The \swift-sh edit\ command now creates an Xcode project that includes a dedicated completion target. This addition enables code completion (auto-complete) for the script being edited within Xcode, improving the development experience for users writing Swift scripts.

Sources/swift-sh-edit · high confidence

Behavioural changes

Introduce unified command-line interface with dedicated error handling

The application now uses a single entry point (Sources/main.swift) that dispatches to specific commands (run, eject, edit, editor, clean) based on the mode detected from command-line arguments. Invalid usage now prints a specific error message followed by the usage help text to stderr and exits with code 3, while other errors print a legible localized description and exit with code 2, improving user feedback for incorrect invocations.

Sources · high confidence

New command-line modes for editing, ejecting, and cleaning scripts

The command-line interface now supports dedicated subcommands for managing Swift scripts beyond simple execution. Users can run \swift sh edit \<script\>\ to open a script in Xcode (macOS only), \swift sh editor \<script\>\ to open it in any editor specified by the $EDITOR environment variable, and \swift sh eject \<script\>\ to convert a script into a standalone Swift Package. Additionally, \swift sh --clean-cache\ allows users to clear the build cache for specific scripts or all scripts. These changes also introduce support for running scripts via named pipes and ensure line numbers remain synchronized when shebangs are stripped during execution.

Sources/Command · high confidence

Test coverage

Added Linux test entry point; Added comprehensive test suite for import parsing, local dependencies, and CLI modes.

Dependencies

Initial Swift Package Manager configuration and dependency resolution

The project now uses Swift Package Manager for dependency management, introducing a new Package.swift manifest and a Package.resolved lock file. This establishes the build structure for the 'swift-sh' executable and its internal libraries (Script, Utility, Command), while pinning specific versions for dependencies including Path.swift (1.4.0), CryptoSwift (1.4.2), LegibleError (1.0.5), Version (2.0.1), and XcodeProj (8.3.1).

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 62 → 55 (-6.4)
  • Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 91 → 93 (+1.4)
  • Architecture 100 → 99 (-1.5)
  • Maturity 59 → 59 (+0.0)
  • Readiness 55 → 43 (-11.7)
  • Security 57 → 57 (+0.0)

Resolved (2)

  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)

New (10)

  • Coverage not measured — Swift suite
  • Duplicated block (9 lines × 2) (Sources/Command/edit().swift)
  • Off the main sequence: Utility
  • Outdated: cryptoswift
  • Outdated: legibleerror
  • Outdated: path.swift
  • Outdated: version
  • Outdated: xcodeproj
  • Redundant operations with nearly identical signatures and intent. Both methods accept a path and return Never, suggesting they perform the same action of opening a file in an editor.
  • Script.scriptChanged (cognitive 23) (Sources/Script/Script.swift)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

mxcl/swift-sh was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 1 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 1e8423f0aac152bebcaf3af446ab590b237fe9f4 — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.