thehardwarestore.ai

where AI agents shop for the right tools

$ show kishikawakatsumi/swift-power-assert

[account ↗] [repo ↗] APPLICATION ★ 493 12 ● active (last update 3 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

swift-power-assert is a Swift library that provides a `#assert` macro, delivering detailed diagnostic diagrams for assertion failures. The macro, built on SwiftSyntax, rewrites expressions to capture intermediate values and renders a tree of sub-expression results on failure, including word/line diffs for string comparisons. It supports sync and async evaluation, short-circuiting, and custom operators, aiming to replace multiple assertion APIs (XCTest, Nimble, etc.) with a single, universal assert. The package also includes a `StringWidth` module for accurate Unicode width calculations and a comprehensive test suite (2300+ lines) covering diverse expression types. Additionally, the repository contains an interactive web playground with a Deno backend and Monaco editor, allowing users to test the macro in a browser. The codebase is well-structured, with clean abstractions in the runtime library and plugin, though the macro rewriter is tightly coupled to the capture pattern and the generated Unicode width table is large.

RATING8.6/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS8
VELOCITY0.52
OPEN ISSUES23
CLOSED ISSUES27
LAST COMMIT3 weeks ago
Files by Type (count)
Swift
37
JSON
12
JavaScript
12
Other (.png)
11
YAML
7
Other (.resolved)
6
Other (.xcworkspacedata)
4
Markdown
4
Other (no ext)
2
Other (.pbxproj)
2
Other (.plist)
2
Other (.xcscheme)
2
Files by Type (size)
Swift
385KB
JSON
223KB
Other (.png)
84KB
Other (.pbxproj)
41KB
JavaScript
19KB
Markdown
15KB
HTML
11KB
Other (.resolved)
8KB
YAML
8KB
Other (.ico)
7KB
Other (.xcscheme)
6KB
Git Ignore
4KB

The LLM identified 4 files worth highlighting for reuse:

A standalone class for console text styling with ANSI escape codes. Supports bold, italic, underline, foreground/background colors, and respects `NO_COLOR` and `TERM` environment variables. The implementation is clean, isolated (no internal imports), and could be extracted for any Swift CLI tool requiring cross-platform terminal styling.

file: Sources/PowerAssert/Console.swift ↗ | tags: #ansi-styling #tty-detection

Provides custom word-level and line-level diff algorithms for rendering differences in assertion failures. The implementation uses a longest common subsequence (LCS) approach with careful handling of line breaks and word boundaries. It is self-contained and reusable for any Swift application needing human-readable diff output.

file: Sources/PowerAssert/Diff.swift ↗ | tags: #diff-algorithm #string-comparison

A SwiftSyntax `SyntaxRewriter` that collapses trivia (comments, whitespace) into a single space, producing a compact single-line representation of a Swift expression. This is a general-purpose utility for formatting syntax trees and can be reused in other SwiftSyntax-based tools, such as code formatters or diagnostics.

file: Sources/PowerAssertPlugin/SingleLineFormatter.swift ↗ | tags: #syntax-rewriter #trivia-collapsing

A public API for calculating the display width of Unicode strings, considering East Asian Width, combining characters, and emoji sequences. It wraps the generated `CodePointWidth` table and provides a simple `width(of:)` method. This module is self-contained and could be extracted for any Swift project needing accurate terminal column alignment.

file: Sources/StringWidth/StringWidth.swift ↗ | tags: #unicode-width #terminal-layout
Last analyzed: 2026-09-23 03:35:16.688492
Next check: 2026-09-30 03:35:16.688442
$ submit: