Summary
swift build is in the hook rewrite registry (src/discover/registry.rs), but swift test is not. This means the PreToolUse hook rewrites swift build → rtk swift build automatically, but swift test passes through unfiltered.
Since swift-build.toml already exists as a built-in TOML filter, and swift test output is structurally similar (build noise + test results), adding swift test to the rewrite registry would allow project-local or user-global TOML filters to handle it.
Context
swift test produces very verbose output (~76KB for ~580 tests using Swift Testing framework)
- A custom TOML filter achieves 99.4% token savings (76KB → ~200 bytes)
- But without a rewrite rule, the hook doesn't intercept
swift test, so the filter never runs automatically
- Currently requires manually patching
rtk-rewrite.sh, which breaks integrity verification
Proposed Change
Add swift test to the rewrite registry in src/discover/registry.rs, similar to how swift build is already registered.
Optionally, a built-in swift-test.toml filter would be valuable — Swift Testing framework output follows a consistent pattern:
◇ Test/Suite ... started. (noise)
✔ Test ... passed after N seconds. (noise)
✘ Test ... failed/skipped (keep)
✔/✘ Test run with N tests passed/failed (summary, keep)
Environment
- macOS, Swift 6.x, SPM (no Xcode)
- Swift Testing framework (not XCTest)
- rtk v0.31.0
Summary
swift buildis in the hook rewrite registry (src/discover/registry.rs), butswift testis not. This means the PreToolUse hook rewritesswift build→rtk swift buildautomatically, butswift testpasses through unfiltered.Since
swift-build.tomlalready exists as a built-in TOML filter, andswift testoutput is structurally similar (build noise + test results), addingswift testto the rewrite registry would allow project-local or user-global TOML filters to handle it.Context
swift testproduces very verbose output (~76KB for ~580 tests using Swift Testing framework)swift test, so the filter never runs automaticallyrtk-rewrite.sh, which breaks integrity verificationProposed Change
Add
swift testto the rewrite registry insrc/discover/registry.rs, similar to howswift buildis already registered.Optionally, a built-in
swift-test.tomlfilter would be valuable — Swift Testing framework output follows a consistent pattern:◇ Test/Suite ... started.(noise)✔ Test ... passed after N seconds.(noise)✘ Test ... failed/skipped(keep)✔/✘ Test run with N tests passed/failed(summary, keep)Environment