[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6H4AAW2TNXQB654GAVMT1DJ":3,"skill-same:01M6H4AAW2TNXQB654GAVMT1DJ":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":6,"updatedAt":52,"install":53,"resources":66},"01M6H4AAW2TNXQB654GAVMT1DJ","swiftui-lang",null,"SwiftUI architecture and testing - ViewModel-first extraction, protocol-based DI, coverage targets by layer, ViewInspector, snapshot testing, how to safely pass closures to Apple SDK APIs inside @MainActor types, and common anti-patterns. Use for SwiftUI views, view models and their tests, and for SwiftUI bugs such as a sheet that shows a blank pill before its data loads.","eyelock\u002Fassistants","eyelock","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1277325?v=4","01M6H423MGYJ0P316VZ2MMH75N","David Collie","01M6H423RR18QA9N8S2F3J8S8X",1,"MIT","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Ftech\u002Fskills\u002Fswiftui-lang\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"swiftui lang","swiftui","patterns","bugs","for","layer","types","snapshot testing","how to","as","apple","testing","anti-patterns","snapshot","coverage","view","common","how","data","architecture","2026-11-10 10:12:30",false,"---\nname: swiftui-lang\ndescription: SwiftUI architecture and testing - ViewModel-first extraction, protocol-based DI, coverage targets by layer, ViewInspector, snapshot testing, how to safely pass closures to Apple SDK APIs inside @MainActor types, and common anti-patterns. Use for SwiftUI views, view models and their tests, and for SwiftUI bugs such as a sheet that shows a blank pill before its data loads.\n---\n\n# SwiftUI Architecture & Testing\n\nSwiftUI `View` types are inherently resistant to unit testing — `body` is opaque, state is owned by the framework, and rendering needs a runtime. The solution is not \"test the view\"; it is to push logic *out* of the view so the view has nothing left to test that isn't a render detail.\n\n## Coverage targets by layer\n\nA healthy SwiftUI app coverage profile:\n\n| Layer | Target line coverage |\n|---|---|\n| Services (network, disk, process, shell) | **80–95%** |\n| ViewModels (`@Observable` \u002F `ObservableObject`) | **80–95%** |\n| Pure utility types (parsers, escapers, filters, tokenizers) | **95–100%** |\n| Views (SwiftUI `body`, conditionals, small local state) | **10–20%** |\n| **Overall** | **60–75%** |\n\nIf overall is under 40%, the problem is almost never the View layer — it is uncovered Services and ViewModels masquerading as a View problem. Audit before blaming SwiftUI.\n\n## ViewModel-first architecture\n\nEvery screen or sheet has **one** `@Observable` (Swift 5.9+) or `@MainActor ObservableObject` ViewModel that owns all state and logic. The View is a declarative projection. Errors land in ViewModel state the View shows — never `try?` in a button action (see `swift-lang`).\n\n```swift\n@Observable\n@MainActor\nfinal class CardEditorViewModel {\n    var title: String = \"\"\n    var selectedColumnId: UUID?\n    var isSubmitting = false\n    var errorMessage: String?\n\n    var isValid: Bool {\n        !title.trimmingCharacters(in: .whitespaces).isEmpty\n    }\n\n    func loadFrom(card: Card) { \u002F* ... *\u002F }\n\n    func save(to card: inout Card) {\n        do {\n            try applyChanges(to: &card)\n            errorMessage = nil\n        } catch {\n            errorMessage = \"Couldn't save: \\(error.localizedDescription)\"  \u002F\u002F surfaced, not swallowed\n        }\n    }\n\n    private func applyChanges(to card: inout Card) throws { \u002F* ... *\u002F }\n}\n\nstruct CardEditorView: View {\n    @Binding var card: Card\n    @State private var viewModel = CardEditorViewModel()\n\n    var body: some View {\n        Form {\n            TextField(\"Title\", text: $viewModel.title)\n            if let errorMessage = viewModel.errorMessage {\n                Text(errorMessage).foregroundStyle(.red)\n            }\n            Button(\"Save\") { viewModel.save(to: &card) }\n                .disabled(!viewModel.isValid)\n        }\n        .onAppear { viewModel.loadFrom(card: card) }\n    }\n}\n```\n\n### Form state vs. presentation state\n\nNot every `@State` needs extraction. Use this discriminator:\n\n- **Form state \u002F business state** → ViewModel. Examples: field values, validation flags, submission state, filter selections, selected IDs, loading flags, error messages.\n- **Presentation state** → View. Examples: animation progress, focus ring tracking, hover highlights, disclosure expansion that has no downstream effect.\n\nRule of thumb: if the same state would need to exist to *test* the behaviour without a View, it belongs in the ViewModel.\n\n### Business state leaking into the View is a regression\n\nWatch for business state that migrated into `@State` *because the ViewModel was untestable*. Example: a set of \"deleting IDs\" used to drive a spinner — that is business state (lifecycle of a user operation), not presentation state. Move it back to the ViewModel as soon as the ViewModel is testable.\n\n## Pure extraction patterns\n\nBefore touching protocols or DI, identify logic that is already pure and just buried inside the wrong file. Extract it to a standalone type in the same module. This is **pure refactoring** — zero behaviour change — and is the highest-ROI step because it unlocks tests without any seam work.\n\nCommon categories:\n\n| Category | Extract to | Example types |\n|---|---|---|\n| URL \u002F query parameter parsing | Struct with getters | `QueryItemExtractor` |\n| Filter \u002F sort \u002F search scoring | Stateless struct or `enum` namespace | `CardFilterEngine` |\n| String escaping (security-sensitive) | `enum` namespace | `ShellEscaper` |\n| Template \u002F token substitution | Struct with `replace(...)` | `CommandTemplateTokenizer` |\n| Line \u002F wire-format parser | `enum Event` + `struct Parser` returning events | `LogLineParser` |\n| Alert \u002F dialog builder | `enum` with config struct + `confirm(...)` | `AlertBuilder` |\n\nSignals the logic is ready for extraction:\n- It is `private` or `internal` inside a larger type that is hard to instantiate in a test\n- It does not touch `self` except to read constants\n- A test file would need to redefine the types locally to test it (that is a red flag — the real types are too coupled)\n\nCommit these as `test: extract Xxx to enable ...` — the intent is test-enablement with no production behaviour change.\n\n## Protocol + DI for services\n\nOnce pure extraction is exhausted, the remaining untestable code is usually hard-wired to singletons. The fix is a small, repeatable pattern.\n\n### The singleton replacement recipe\n\n1. **Enumerate all call sites** — grep for `X.shared` in the consumer. The *actual* call surface is your protocol; do not invent methods that are not called.\n2. **Extract a protocol** covering that minimum surface.\n3. **Conform the concrete type** — usually just `extension X: XProtocol {}`.\n4. **Inject via init default**:\n   ```swift\n   init(_ x: any XProtocol = X.shared) {\n       self.x = x\n   }\n   ```\n   Production callers using `X.shared` keep working unchanged. Tests inject a mock.\n5. **Replace internal uses**: `self.x` instead of `X.shared`.\n6. **Write a Mock** in tests: records calls, can throw on demand, holds configurable results.\n7. **Commit as `refactor:`** (not `test:`) — this changes the production call path, even if behaviour is identical.\n\n### Persistence singletons are a priority\n\nPersistence singletons (`DocumentPersistence`, `PreferencesPersistence`, anything that writes to `Application Support`) are the single biggest risk. Without DI, tests that create documents, settings, or user preferences will write real files — test state leaks into the user's running app. If you ever see fake test data in a running debug build's `.json` files, you need a `PersistenceProtocol` injection before adding another test.\n\n### Circular singleton chains\n\nWatch for `A.shared` → `B.shared` → `A.shared`. Breaking one link often does not unblock tests — the consumer still reaches back through the other side. Before starting, **map the chain end to end** so you know which order of extractions unblocks which tests.\n\n### Document known constraints after each DI pass\n\nOne injection rarely unlocks the whole call path. After extracting `SessionManagerProtocol`, for example, tests may still be blocked by direct `Process()` instantiation or an undocumented `SomeOtherManager.shared` reference deeper in the method. Record these explicitly:\n\n```swift\n\u002F\u002F TODO: testable after EnvironmentManager \u002F ProcessRunner DI\n```\n\nList them in the plan's \"known constraints\" section so the next phase has a clear target.\n\n## Testing tools\n\n### ViewInspector (primary for View-level assertions)\n\n[ViewInspector](https:\u002F\u002Fgithub.com\u002Fnalexn\u002FViewInspector) inspects SwiftUI view trees in `XCTest`. Use it for the residue after ViewModel extraction: \"Is this button enabled when `isValid` is false?\", \"Does this conditional render the error banner?\".\n\nAdd as a Swift Package dependency. Minimal example:\n\n```swift\nimport ViewInspector\nimport XCTest\n@testable import MyApp\n\nfinal class LoginViewTests: XCTestCase {\n    func testSubmitButton_WhenEmailEmpty_IsDisabled() throws {\n        let view = LoginView(viewModel: LoginViewModel(email: \"\"))\n        let button = try view.inspect().find(button: \"Submit\")\n        XCTAssertTrue(try button.isDisabled())\n    }\n}\n```\n\nPrefer ViewInspector over snapshot testing for logic assertions — it fails fast with readable diffs, no reference image diffing.\n\n### swift-snapshot-testing (for visual regression)\n\n[PointFree's swift-snapshot-testing](https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fswift-snapshot-testing) renders views and diffs against committed reference images or text serializations. Use for:\n\n- Visual regression on layout-critical views (toolbars, sheets, dense grids)\n- Detecting accidental dark\u002Flight mode breakage\n- Catching `.padding` \u002F `.frame` changes that would otherwise slip through\n\nDo **not** use for logic — image diffs are noisy, slow to iterate on, and don't explain *why* something changed.\n\n### XCTest + Mocks (for Services and ViewModels)\n\nStandard unit tests. ViewModels are `@MainActor`, so test classes that hold them should also be `@MainActor`. Async tests use `async throws` — never `XCTestExpectation` for async\u002Fawait work.\n\n```swift\n@MainActor\nfinal class BoardViewModelTests: XCTestCase {\n    func testDeleteCard_InPopulatedColumn_DecrementsCardCount() async throws {\n        let mockPersistence = MockBoardPersistence()\n        let vm = BoardViewModel(persistence: mockPersistence)\n        try await vm.deleteCard(id: cardID)\n        XCTAssertEqual(vm.columns[0].cardCount, expected)\n    }\n}\n```\n\n## Swift 6: closures passed to Apple APIs inside `@MainActor` types\n\nWhen you are writing a closure argument to an Apple SDK function **inside a `@MainActor` class, struct, or enum**, you must decide whether to mark it `@Sendable` before you finish writing it — not after.\n\n### Why this matters at write time\n\nSwift 6 allows a non-`@Sendable` closure to inherit the actor isolation of its surrounding context. If the surrounding function is `@MainActor`, the closure is inferred as `@MainActor` too. Most Objective-C–origin Apple APIs accept closures without `@Sendable` in their Swift overlay, so they will silently take on your actor's isolation.\n\nThe problem: the API calls the closure on a background thread. At runtime, Swift checks the isolation on entry and terminates the app instantly — no alert, no recovery, no log entry visible to the user. The crash is total and silent.\n\nThe inner `Task { @MainActor in }` pattern does **not** protect against this. The check fires when the outer closure is entered, before any of its body runs.\n\n### The rule\n\n**Any time you write a closure argument to an Apple SDK API while inside a `@MainActor` context, ask: does this API call my closure on the main thread?**\n\nIf you are not certain the answer is yes, add `@Sendable` to the closure.\n\nAPIs that are known to call back on background threads (non-exhaustive):\n\n| API | Thread |\n|---|---|\n| `NSWorkspace.open(_:withApplicationAt:configuration:completionHandler:)` | `com.apple.launchservices.open-queue` |\n| `NSWorkspace.open(_:configuration:completionHandler:)` | `com.apple.launchservices.open-queue` |\n| `FileHandle.readabilityHandler` | System read queue |\n| `Process.terminationHandler` | System process queue |\n\nAny Obj-C–origin completion block not annotated `@Sendable` in the Swift overlay is a candidate. When in doubt, add `@Sendable`.\n\n### How to write it correctly\n\n```swift\n@MainActor\nenum MyService {\n    static func openFile(_ url: URL, handler: URL) {\n        let config = NSWorkspace.OpenConfiguration()\n        NSWorkspace.shared.open([url], withApplicationAt: handler, configuration: config) {\n            @Sendable [url] _, error in          \u002F\u002F ← always required here\n            guard let error else { return }\n            Task { @MainActor in\n                Self.presentAlert(error: error)  \u002F\u002F Self. required — no implicit scope\n            }\n        }\n    }\n}\n```\n\n```swift\n\u002F\u002F In a @MainActor class:\npipe.fileHandleForReading.readabilityHandler = { @Sendable [weak self] handle in\n    let data = handle.availableData\n    Task { @MainActor [weak self] in\n        self?.process(data)\n    }\n}\n```\n\n`@Sendable` opts the closure out of actor isolation inheritance. The closure then runs uncontested on whatever thread the API uses, and the `Task { @MainActor in }` hop re-enters the main actor for any state access.\n\n### Already-safe pattern: register the callback from a `nonisolated` function\n\nA closure written inside a `nonisolated` function does not inherit `@MainActor` — there is no actor context to inherit — so it does not need `@Sendable` to escape isolation. Only closures written *directly* in a `@MainActor` scope need the annotation.\n\nBridging the callback into an `AsyncStream` from a `nonisolated` helper does both jobs: it breaks the inheritance, and it replaces the callback-plus-`Task` hop with a plain `for await` loop that runs on the main actor.\n\n```swift\n@MainActor\nfinal class LogViewModel {\n    private(set) var output = \"\"\n\n    func startReading(_ handle: FileHandle) {\n        Task {  \u002F\u002F inherits @MainActor\n            for await chunk in Self.chunks(from: handle) {\n                output += chunk  \u002F\u002F on the main actor, no hop needed\n            }\n        }\n    }\n\n    \u002F\u002F Safe — nonisolated, so the closures below do not inherit @MainActor\n    nonisolated private static func chunks(from handle: FileHandle) -> AsyncStream\u003CString> {\n        AsyncStream { continuation in\n            handle.readabilityHandler = { fh in  \u002F\u002F not @MainActor, no annotation needed\n                let data = fh.availableData\n                if data.isEmpty {\n                    continuation.finish()\n                } else {\n                    continuation.yield(String(decoding: data, as: UTF8.self))\n                }\n            }\n            continuation.onTermination = { _ in handle.readabilityHandler = nil }\n        }\n    }\n}\n```\n\n## Async stores need a readiness signal\n\nA store that exposes `items: [T] = []` and flips an `isLoading` flag during refresh leaks a state ambiguity: consumers cannot tell *never loaded* from *loaded empty* from *loading*. Any UI gated on \"is there a selected item?\" or \"is the list non-empty?\" will render a wrong empty state during the cold-launch window before `refresh()` resolves. This is a load-bearing class of bug — every new sheet, list, or detail view added against the store inherits it.\n\nModel the lifecycle explicitly:\n\n```swift\nenum LoadState\u003CT> {\n    case idle           \u002F\u002F never loaded\n    case loading\n    case loaded(T)\n    case failed(Error)\n}\n\n@Observable\n@MainActor\nfinal class ProjectRepository {\n    private(set) var state: LoadState\u003C[Project]> = .idle\n    var projects: [Project] { if case .loaded(let xs) = state { return xs } else { return [] } }\n    var isReady: Bool { if case .loaded = state { return true } else { return false } }\n}\n```\n\nConsumers gate on `isReady`, not on `projects.isEmpty`. A sheet that depends on a record from the store should not present until `isReady` is true — see the sheet pattern rule below.\n\n## Sheet presentation: prefer `.sheet(item:)` over `.sheet(isPresented:)`\n\n`.sheet(isPresented:)` with a content closure that conditionally renders nothing is a SwiftUI footgun:\n\n```swift\n\u002F\u002F Footgun — presents an unsized empty view as a tiny white \"pill\" if the lookup fails\n.sheet(isPresented: $showDetailSheet) {\n    if let project = repo.selectedProject {\n        ProjectDetailSheet(project: project)\n    }\n}\n```\n\nIf the lookup returns `nil` (e.g. the store has not finished loading), SwiftUI presents the sheet with an `EmptyView`, which sizes to its intrinsic zero size and renders as a blank rounded rectangle on a dimmed window. The user has no signal that anything is wrong; sometimes a restart \"fixes it\" because by then the data has loaded.\n\nUse `.sheet(item:)` with an `Identifiable` model. SwiftUI does not present at all while the item is `nil`:\n\n```swift\n.sheet(item: $detailTarget) { project in\n    ProjectDetailSheet(project: project)\n}\n```\n\nSet `detailTarget` only once you know the data is ready (see `isReady` above). Apply this rule project-wide — mixing the two patterns guarantees the next sheet to be added will reproduce the bug.\n\n## One canonical identity per domain entity\n\nWhen a model type has two equally-valid string forms — `id` vs `name`, namespaced vs bare, slug vs UUID — and different call sites lift different forms off the model, you have an identity seam. Each new consumer (sidebar tag, persisted preference, deep-link URL, log line, exposed API) has roughly a 50\u002F50 chance of picking the wrong form. Fallbacks like `repo.first(where: { $0.id == key || $0.name == key })` paper over the symptom and let the seam keep leaking.\n\nRules:\n\n- Pick one form as canonical. Almost always: the most-qualified form (`namespace\u002Fname`, full UUID).\n- Persistence, runtime keys, and view tags all use the canonical form. No exceptions.\n- The non-canonical form, if it must exist, is read-only and derived (`project.shortName` as a computed property).\n- New code that lifts a string off a model and passes it across a seam is a review red flag — verify it is the canonical form.\n\n## Settings need a single source of truth\n\nA codebase that reads `UserDefaults.standard.string(forKey:)` from Views, uses `@AppStorage` in other Views, and adds per-instance overrides on top has no owner for the layering. Settings changes do not propagate reliably; overrides drift; tests cannot fake a setting without polluting global state.\n\nIntroduce a `SettingsStore` (`@Observable`, `@MainActor`) that owns the read\u002Fwrite surface and the override layering. Views observe the store; tests inject a fake. `@AppStorage` is fine for one-off, non-overridden, view-local toggles — not for any setting that has per-instance overrides or cross-view consumers.\n\n## Testing — smells specific to SwiftUI\u002FSwift codebases\n\nThe coverage targets above are necessary but not sufficient. A test suite can hit 70% line coverage and still catch zero release-worthy bugs if the tests are at the wrong boundary. Watch for:\n\n| Smell | What it really means |\n|---|---|\n| Type-only assertions (`XCTAssertEqual(pane.id, \"1\")` on a struct you just constructed) | Test passes if the struct compiles — proves nothing |\n| Mocks that record call arrays, tests assert the mock recorded a call | You are testing the mock, not the production type |\n| Subprocess\u002Fsystem services mocked at the top (`MockToolDetector` never runs the real tool) | Cannot detect arg errors, env misconfig, or output-parse drift — the seam where bugs actually live is bypassed |\n| `Task.sleep(for: .milliseconds(50))` to \"wait for debounce\" | CI-load flake risk; use a clock abstraction or signal |\n| Codable round-trip tests (encode → decode → compare) | Passes whenever the codec is symmetric, regardless of whether the JSON shape matches what consumers actually emit |\n| No test reads a store *while* `isLoading == true` or *before* the first `refresh()` | Async\u002Frace coverage is zero — the load-bearing bug class is invisible to the suite |\n\nIf recent hotfixes touched integration seams (subprocess, NSWorkspace, Sparkle, FileManager) and no existing test would have caught them, the suite is documenting current behaviour rather than preventing regressions. Add a thin integration-seam protocol (`CommandRunner`, `WorkspaceProvider`, `UpdaterProvider`) and test through it with a fake that can return realistic outputs and errors.\n\n### Concurrent-access tests, not just state-transition tests\n\nProperty-state-transition tests (set X, assert Y) do not exercise the cold-launch window. Add tests that:\n\n1. Construct the store\n2. Trigger `refresh()` but do **not** await it\n3. Read the consumer-facing property and assert the consumer receives a \"not ready\" signal (not `nil`, not an empty list misinterpreted as \"loaded empty\")\n4. Then await refresh and assert the loaded state\n\nThis is the test that would catch an async-readiness regression before it ships.\n\n## Cross-cutting bug patterns to watch for\n\nWhen a codebase produces repeated late-cycle hotfixes, the patterns are almost always one of three:\n\n1. **Async state read before it is ready** — fix with the `LoadState` \u002F `isReady` pattern above.\n2. **Identity ambiguity at a seam** — fix with one canonical form, no fallbacks.\n3. **System callback isolation** — closures handed to Apple SDKs from a `@MainActor` scope without `@Sendable`; fix per the rule earlier in this skill, enforced by `StrictConcurrency=complete` (see `swift-lang`).\n\nSymptom-only fixes (another fallback in the lookup, another guard in the consumer) leave the pattern in place and the next instance ships in the next release.\n\n## Anti-patterns and smells\n\n| Smell | What it usually means |\n|---|---|\n| View file over ~500 lines | Logic is inline — extract a ViewModel and pure types |\n| Tests redefining types locally | The real types are too coupled to import — extract pure types |\n| Business state (loading flags, selected IDs) in `@State` | ViewModel is untestable or missing — fix the ViewModel, move state back |\n| `private init()` on every service | Singleton-only codebase — introduce protocols and DI |\n| Fake test data appearing in app-visible `.json` files | Persistence singleton needs protocol + mock injection |\n| `@State` properties doing validation | Validation is business logic — move to ViewModel |\n| Methods taking 10+ parameters to avoid instantiating a service | Extract the service behind a protocol instead |\n| `.sheet(isPresented:)` whose content closure can render nothing | Blank-pill bug waiting to happen — switch to `.sheet(item:)` |\n| Store exposes `items: [T] = []` with `isLoading` flag | Conflates never-loaded \u002F loading \u002F loaded-empty — model `LoadState` instead |\n| `repo.first(where: { $0.id == key \\|\\| $0.name == key })` | Identity seam being papered over — pick a canonical form |\n| `try?` on git\u002Fsubprocess\u002Fnetwork calls | Loud bugs converted to silent ones — see `swift-lang` |\n\n## Planning structure\n\nTwo complementary plan types — keep them separate.\n\n1. **Refactor plan** — structural changes that make code testable. Each phase is a self-contained PR. Commit types: `test:` for pure extract, `refactor:` for protocol\u002FDI introduction. Example phases: extract `QueryItemExtractor`, extract `ShellEscaper`, introduce `GitServiceProtocol`.\n2. **Coverage plan** — adds tests to code that is already testable. Commit type: `test:`. Example: \"write unit tests for `ProjectSearchService` filtering logic.\"\n\nDo **not** mix them. A single PR should either restructure code *or* add tests, not both. Mixed PRs are hard to review because you cannot tell whether a change is structural or behavioural.\n\n### Phase discipline\n\nEach phase is one PR into the integration branch. A phase is complete when:\n\n1. `make test` passes\n2. Build, lint, format-check all pass\n3. No observable behaviour changes for users\n4. PR is reviewed and merged\n5. Next phase rebases on the updated integration branch before starting\n\nUse a dedicated branch or worktree for the plan so in-flight work does not disturb the main checkout.\n\n## Order of operations\n\nWhen attacking a low-coverage SwiftUI codebase, work in this order:\n\n1. **Audit** — split the 0%-coverage files into \"no UI dependency\" (services, utilities, models) vs. \"UI-coupled\" (Views, View-hosted logic). The first group is where all the quick wins are.\n2. **Services and utilities first** — write tests; no architecture change needed for most.\n3. **Pure extractions** — pull parsers, filters, escapers out of big files into their own types. Test the new types. Commit as `test:`.\n4. **Protocol + DI** — one service at a time, starting with persistence (highest risk). Commit as `refactor:`, add ViewModel tests using the mock in the next PR.\n5. **ViewModel extractions** — for each large View, move form state and business logic to a ViewModel. Test the ViewModel.\n6. **ViewInspector residue** — for the thin views that remain, write ViewInspector tests for conditional rendering and button enablement.\n7. **Snapshot tests last** — only on visually stable, layout-critical views.\n\nFollowing this order, the overall coverage number climbs steadily and the biggest jumps come before you ever touch a `body`.\n","# SwiftUI Architecture & Testing\n\nSwiftUI `View` types are inherently resistant to unit testing — `body` is opaque, state is owned by the framework, and rendering needs a runtime. The solution is not \"test the view\"; it is to push logic *out* of the view so the view has nothing left to test that isn't a render detail.\n\n## Coverage targets by layer\n\nA healthy SwiftUI app coverage profile:\n\n| Layer | Target line coverage |\n|---|---|\n| Services (network, disk, process, shell) | **80–95%** |\n| ViewModels (`@Observable` \u002F `ObservableObject`) | **80–95%** |\n| Pure utility types (parsers, escapers, filters, tokenizers) | **95–100%** |\n| Views (SwiftUI `body`, conditionals, small local state) | **10–20%** |\n| **Overall** | **60–75%** |\n\nIf overall is under 40%, the problem is almost never the View layer — it is uncovered Services and ViewModels masquerading as a View problem. Audit before blaming SwiftUI.\n\n## ViewModel-first architecture\n\nEvery screen or sheet has **one** `@Observable` (Swift 5.9+) or `@MainActor ObservableObject` ViewModel that owns all state and logic. The View is a declarative projection. Errors land in ViewModel state the View shows — never `try?` in a button action (see `swift-lang`).\n\n```swift\n@Observable\n@MainActor\nfinal class CardEditorViewModel {\n    var title: String = \"\"\n    var selectedColumnId: UUID?\n    var isSubmitting = false\n    var errorMessage: String?\n\n    var isValid: Bool {\n        !title.trimmingCharacters(in: .whitespaces).isEmpty\n    }\n\n    func loadFrom(card: Card) { \u002F* ... *\u002F }\n\n    func save(to card: inout Card) {\n        do {\n            try applyChanges(to: &card)\n            errorMessage = nil\n        } catch {\n            errorMessage = \"Couldn't save: \\(error.localizedDescription)\"  \u002F\u002F surfaced, not swallowed\n        }\n    }\n\n    private func applyChanges(to card: inout Card) throws { \u002F* ... *\u002F }\n}\n\nstruct CardEditorView: View {\n    @Binding var card: Card\n    @State private var viewModel = CardEditorViewModel()\n\n    var body: some View {\n        Form {\n            TextField(\"Title\", text: $viewModel.title)\n            if let errorMessage = viewModel.errorMessage {\n                Text(errorMessage).foregroundStyle(.red)\n            }\n            Button(\"Save\") { viewModel.save(to: &card) }\n                .disabled(!viewModel.isValid)\n        }\n        .onAppear { viewModel.loadFrom(card: card) }\n    }\n}\n```\n\n### Form state vs. presentation state\n\nNot every `@State` needs extraction. Use this discriminator:\n\n- **Form state \u002F business state** → ViewModel. Examples: field values, validation flags, submission state, filter selections, selected IDs, loading flags, error messages.\n- **Presentation state** → View. Examples: animation progress, focus ring tracking, hover highlights, disclosure expansion that has no downstream effect.\n\nRule of thumb: if the same state would need to exist to *test* the behaviour without a View, it belongs in the ViewModel.\n\n### Business state leaking into the View is a regression\n\nWatch for business state that migrated into `@State` *because the ViewModel was untestable*. Example: a set of \"deleting IDs\" used to drive a spinner — that is business state (lifecycle of a user operation), not presentation state. Move it back to the ViewModel as soon as the ViewModel is testable.\n\n## Pure extraction patterns\n\nBefore touching protocols or DI, identify logic that is already pure and just buried inside the wrong file. Extract it to a standalone type in the same module. This is **pure refactoring** — zero behaviour change — and is the highest-ROI step because it unlocks tests without any seam work.\n\nCommon categories:\n\n| Category | Extract to | Example types |\n|---|---|---|\n| URL \u002F query parameter parsing | Struct with getters | `QueryItemExtractor` |\n| Filter \u002F sort \u002F search scoring | Stateless struct or `enum` namespace | `CardFilterEngine` |\n| String escaping (security-sensitive) | `enum` namespace | `ShellEscaper` |\n| Template \u002F token substitution | Struct with `replace(...)` | `CommandTemplateTokenizer` |\n| Line \u002F wire-format parser | `enum Event` + `struct Parser` returning events | `LogLineParser` |\n| Alert \u002F dialog builder | `enum` with config struct + `confirm(...)` | `AlertBuilder` |\n\nSignals the logic is ready for extraction:\n- It is `private` or `internal` inside a larger type that is hard to instantiate in a test\n- It does not touch `self` except to read constants\n- A test file would need to redefine the types locally to test it (that is a red flag — the real types are too coupled)\n\nCommit these as `test: extract Xxx to enable ...` — the intent is test-enablement with no production behaviour change.\n\n## Protocol + DI for services\n\nOnce pure extraction is exhausted, the remaining untestable code is usually hard-wired to singletons. The fix is a small, repeatable pattern.\n\n### The singleton replacement recipe\n\n1. **Enumerate all call sites** — grep for `X.shared` in the consumer. The *actual* call surface is your protocol; do not invent methods that are not called.\n2. **Extract a protocol** covering that minimum surface.\n3. **Conform the concrete type** — usually just `extension X: XProtocol {}`.\n4. **Inject via init default**:\n   ```swift\n   init(_ x: any XProtocol = X.shared) {\n       self.x = x\n   }\n   ```\n   Production callers using `X.shared` keep working unchanged. Tests inject a mock.\n5. **Replace internal uses**: `self.x` instead of `X.shared`.\n6. **Write a Mock** in tests: records calls, can throw on demand, holds configurable results.\n7. **Commit as `refactor:`** (not `test:`) — this changes the production call path, even if behaviour is identical.\n\n### Persistence singletons are a priority\n\nPersistence singletons (`DocumentPersistence`, `PreferencesPersistence`, anything that writes to `Application Support`) are the single biggest risk. Without DI, tests that create documents, settings, or user preferences will write real files — test state leaks into the user's running app. If you ever see fake test data in a running debug build's `.json` files, you need a `PersistenceProtocol` injection before adding another test.\n\n### Circular singleton chains\n\nWatch for `A.shared` → `B.shared` → `A.shared`. Breaking one link often does not unblock tests — the consumer still reaches back through the other side. Before starting, **map the chain end to end** so you know which order of extractions unblocks which tests.\n\n### Document known constraints after each DI pass\n\nOne injection rarely unlocks the whole call path. After extracting `SessionManagerProtocol`, for example, tests may still be blocked by direct `Process()` instantiation or an undocumented `SomeOtherManager.shared` reference deeper in the method. Record these explicitly:\n\n```swift\n\u002F\u002F TODO: testable after EnvironmentManager \u002F ProcessRunner DI\n```\n\nList them in the plan's \"known constraints\" section so the next phase has a clear target.\n\n## Testing tools\n\n### ViewInspector (primary for View-level assertions)\n\n[ViewInspector](https:\u002F\u002Fgithub.com\u002Fnalexn\u002FViewInspector) inspects SwiftUI view trees in `XCTest`. Use it for the residue after ViewModel extraction: \"Is this button enabled when `isValid` is false?\", \"Does this conditional render the error banner?\".\n\nAdd as a Swift Package dependency. Minimal example:\n\n```swift\nimport ViewInspector\nimport XCTest\n@testable import MyApp\n\nfinal class LoginViewTests: XCTestCase {\n    func testSubmitButton_WhenEmailEmpty_IsDisabled() throws {\n        let view = LoginView(viewModel: LoginViewModel(email: \"\"))\n        let button = try view.inspect().find(button: \"Submit\")\n        XCTAssertTrue(try button.isDisabled())\n    }\n}\n```\n\nPrefer ViewInspector over snapshot testing for logic assertions — it fails fast with readable diffs, no reference image diffing.\n\n### swift-snapshot-testing (for visual regression)\n\n[PointFree's swift-snapshot-testing](https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fswift-snapshot-testing) renders views and diffs against committed reference images or text serializations. Use for:\n\n- Visual regression on layout-critical views (toolbars, sheets, dense grids)\n- Detecting accidental dark\u002Flight mode breakage\n- Catching `.padding` \u002F `.frame` changes that would otherwise slip through\n\nDo **not** use for logic — image diffs are noisy, slow to iterate on, and don't explain *why* something changed.\n\n### XCTest + Mocks (for Services and ViewModels)\n\nStandard unit tests. ViewModels are `@MainActor`, so test classes that hold them should also be `@MainActor`. Async tests use `async throws` — never `XCTestExpectation` for async\u002Fawait work.\n\n```swift\n@MainActor\nfinal class BoardViewModelTests: XCTestCase {\n    func testDeleteCard_InPopulatedColumn_DecrementsCardCount() async throws {\n        let mockPersistence = MockBoardPersistence()\n        let vm = BoardViewModel(persistence: mockPersistence)\n        try await vm.deleteCard(id: cardID)\n        XCTAssertEqual(vm.columns[0].cardCount, expected)\n    }\n}\n```\n\n## Swift 6: closures passed to Apple APIs inside `@MainActor` types\n\nWhen you are writing a closure argument to an Apple SDK function **inside a `@MainActor` class, struct, or enum**, you must decide whether to mark it `@Sendable` before you finish writing it — not after.\n\n### Why this matters at write time\n\nSwift 6 allows a non-`@Sendable` closure to inherit the actor isolation of its surrounding context. If the surrounding function is `@MainActor`, the closure is inferred as `@MainActor` too. Most Objective-C–origin Apple APIs accept closures without `@Sendable` in their Swift overlay, so they will silently take on your actor's isolation.\n\nThe problem: the API calls the closure on a background thread. At runtime, Swift checks the isolation on entry and terminates the app instantly — no alert, no recovery, no log entry visible to the user. The crash is total and silent.\n\nThe inner `Task { @MainActor in }` pattern does **not** protect against this. The check fires when the outer closure is entered, before any of its body runs.\n\n### The rule\n\n**Any time you write a closure argument to an Apple SDK API while inside a `@MainActor` context, ask: does this API call my closure on the main thread?**\n\nIf you are not certain the answer is yes, add `@Sendable` to the closure.\n\nAPIs that are known to call back on background threads (non-exhaustive):\n\n| API | Thread |\n|---|---|\n| `NSWorkspace.open(_:withApplicationAt:configuration:completionHandler:)` | `com.apple.launchservices.open-queue` |\n| `NSWorkspace.open(_:configuration:completionHandler:)` | `com.apple.launchservices.open-queue` |\n| `FileHandle.readabilityHandler` | System read queue |\n| `Process.terminationHandler` | System process queue |\n\nAny Obj-C–origin completion block not annotated `@Sendable` in the Swift overlay is a candidate. When in doubt, add `@Sendable`.\n\n### How to write it correctly\n\n```swift\n@MainActor\nenum MyService {\n    static func openFile(_ url: URL, handler: URL) {\n        let config = NSWorkspace.OpenConfiguration()\n        NSWorkspace.shared.open([url], withApplicationAt: handler, configuration: config) {\n            @Sendable [url] _, error in          \u002F\u002F ← always required here\n            guard let error else { return }\n            Task { @MainActor in\n                Self.presentAlert(error: error)  \u002F\u002F Self. required — no implicit scope\n            }\n        }\n    }\n}\n```\n\n```swift\n\u002F\u002F In a @MainActor class:\npipe.fileHandleForReading.readabilityHandler = { @Sendable [weak self] handle in\n    let data = handle.availableData\n    Task { @MainActor [weak self] in\n        self?.process(data)\n    }\n}\n```\n\n`@Sendable` opts the closure out of actor isolation inheritance. The closure then runs uncontested on whatever thread the API uses, and the `Task { @MainActor in }` hop re-enters the main actor for any state access.\n\n### Already-safe pattern: register the callback from a `nonisolated` function\n\nA closure written inside a `nonisolated` function does not inherit `@MainActor` — there is no actor context to inherit — so it does not need `@Sendable` to escape isolation. Only closures written *directly* in a `@MainActor` scope need the annotation.\n\nBridging the callback into an `AsyncStream` from a `nonisolated` helper does both jobs: it breaks the inheritance, and it replaces the callback-plus-`Task` hop with a plain `for await` loop that runs on the main actor.\n\n```swift\n@MainActor\nfinal class LogViewModel {\n    private(set) var output = \"\"\n\n    func startReading(_ handle: FileHandle) {\n        Task {  \u002F\u002F inherits @MainActor\n            for await chunk in Self.chunks(from: handle) {\n                output += chunk  \u002F\u002F on the main actor, no hop needed\n            }\n        }\n    }\n\n    \u002F\u002F Safe — nonisolated, so the closures below do not inherit @MainActor\n    nonisolated private static func chunks(from handle: FileHandle) -> AsyncStream\u003CString> {\n        AsyncStream { continuation in\n            handle.readabilityHandler = { fh in  \u002F\u002F not @MainActor, no annotation needed\n                let data = fh.availableData\n                if data.isEmpty {\n                    continuation.finish()\n                } else {\n                    continuation.yield(String(decoding: data, as: UTF8.self))\n                }\n            }\n            continuation.onTermination = { _ in handle.readabilityHandler = nil }\n        }\n    }\n}\n```\n\n## Async stores need a readiness signal\n\nA store that exposes `items: [T] = []` and flips an `isLoading` flag during refresh leaks a state ambiguity: consumers cannot tell *never loaded* from *loaded empty* from *loading*. Any UI gated on \"is there a selected item?\" or \"is the list non-empty?\" will render a wrong empty state during the cold-launch window before `refresh()` resolves. This is a load-bearing class of bug — every new sheet, list, or detail view added against the store inherits it.\n\nModel the lifecycle explicitly:\n\n```swift\nenum LoadState\u003CT> {\n    case idle           \u002F\u002F never loaded\n    case loading\n    case loaded(T)\n    case failed(Error)\n}\n\n@Observable\n@MainActor\nfinal class ProjectRepository {\n    private(set) var state: LoadState\u003C[Project]> = .idle\n    var projects: [Project] { if case .loaded(let xs) = state { return xs } else { return [] } }\n    var isReady: Bool { if case .loaded = state { return true } else { return false } }\n}\n```\n\nConsumers gate on `isReady`, not on `projects.isEmpty`. A sheet that depends on a record from the store should not present until `isReady` is true — see the sheet pattern rule below.\n\n## Sheet presentation: prefer `.sheet(item:)` over `.sheet(isPresented:)`\n\n`.sheet(isPresented:)` with a content closure that conditionally renders nothing is a SwiftUI footgun:\n\n```swift\n\u002F\u002F Footgun — presents an unsized empty view as a tiny white \"pill\" if the lookup fails\n.sheet(isPresented: $showDetailSheet) {\n    if let project = repo.selectedProject {\n        ProjectDetailSheet(project: project)\n    }\n}\n```\n\nIf the lookup returns `nil` (e.g. the store has not finished loading), SwiftUI presents the sheet with an `EmptyView`, which sizes to its intrinsic zero size and renders as a blank rounded rectangle on a dimmed window. The user has no signal that anything is wrong; sometimes a restart \"fixes it\" because by then the data has loaded.\n\nUse `.sheet(item:)` with an `Identifiable` model. SwiftUI does not present at all while the item is `nil`:\n\n```swift\n.sheet(item: $detailTarget) { project in\n    ProjectDetailSheet(project: project)\n}\n```\n\nSet `detailTarget` only once you know the data is ready (see `isReady` above). Apply this rule project-wide — mixing the two patterns guarantees the next sheet to be added will reproduce the bug.\n\n## One canonical identity per domain entity\n\nWhen a model type has two equally-valid string forms — `id` vs `name`, namespaced vs bare, slug vs UUID — and different call sites lift different forms off the model, you have an identity seam. Each new consumer (sidebar tag, persisted preference, deep-link URL, log line, exposed API) has roughly a 50\u002F50 chance of picking the wrong form. Fallbacks like `repo.first(where: { $0.id == key || $0.name == key })` paper over the symptom and let the seam keep leaking.\n\nRules:\n\n- Pick one form as canonical. Almost always: the most-qualified form (`namespace\u002Fname`, full UUID).\n- Persistence, runtime keys, and view tags all use the canonical form. No exceptions.\n- The non-canonical form, if it must exist, is read-only and derived (`project.shortName` as a computed property).\n- New code that lifts a string off a model and passes it across a seam is a review red flag — verify it is the canonical form.\n\n## Settings need a single source of truth\n\nA codebase that reads `UserDefaults.standard.string(forKey:)` from Views, uses `@AppStorage` in other Views, and adds per-instance overrides on top has no owner for the layering. Settings changes do not propagate reliably; overrides drift; tests cannot fake a setting without polluting global state.\n\nIntroduce a `SettingsStore` (`@Observable`, `@MainActor`) that owns the read\u002Fwrite surface and the override layering. Views observe the store; tests inject a fake. `@AppStorage` is fine for one-off, non-overridden, view-local toggles — not for any setting that has per-instance overrides or cross-view consumers.\n\n## Testing — smells specific to SwiftUI\u002FSwift codebases\n\nThe coverage targets above are necessary but not sufficient. A test suite can hit 70% line coverage and still catch zero release-worthy bugs if the tests are at the wrong boundary. Watch for:\n\n| Smell | What it really means |\n|---|---|\n| Type-only assertions (`XCTAssertEqual(pane.id, \"1\")` on a struct you just constructed) | Test passes if the struct compiles — proves nothing |\n| Mocks that record call arrays, tests assert the mock recorded a call | You are testing the mock, not the production type |\n| Subprocess\u002Fsystem services mocked at the top (`MockToolDetector` never runs the real tool) | Cannot detect arg errors, env misconfig, or output-parse drift — the seam where bugs actually live is bypassed |\n| `Task.sleep(for: .milliseconds(50))` to \"wait for debounce\" | CI-load flake risk; use a clock abstraction or signal |\n| Codable round-trip tests (encode → decode → compare) | Passes whenever the codec is symmetric, regardless of whether the JSON shape matches what consumers actually emit |\n| No test reads a store *while* `isLoading == true` or *before* the first `refresh()` | Async\u002Frace coverage is zero — the load-bearing bug class is invisible to the suite |\n\nIf recent hotfixes touched integration seams (subprocess, NSWorkspace, Sparkle, FileManager) and no existing test would have caught them, the suite is documenting current behaviour rather than preventing regressions. Add a thin integration-seam protocol (`CommandRunner`, `WorkspaceProvider`, `UpdaterProvider`) and test through it with a fake that can return realistic outputs and errors.\n\n### Concurrent-access tests, not just state-transition tests\n\nProperty-state-transition tests (set X, assert Y) do not exercise the cold-launch window. Add tests that:\n\n1. Construct the store\n2. Trigger `refresh()` but do **not** await it\n3. Read the consumer-facing property and assert the consumer receives a \"not ready\" signal (not `nil`, not an empty list misinterpreted as \"loaded empty\")\n4. Then await refresh and assert the loaded state\n\nThis is the test that would catch an async-readiness regression before it ships.\n\n## Cross-cutting bug patterns to watch for\n\nWhen a codebase produces repeated late-cycle hotfixes, the patterns are almost always one of three:\n\n1. **Async state read before it is ready** — fix with the `LoadState` \u002F `isReady` pattern above.\n2. **Identity ambiguity at a seam** — fix with one canonical form, no fallbacks.\n3. **System callback isolation** — closures handed to Apple SDKs from a `@MainActor` scope without `@Sendable`; fix per the rule earlier in this skill, enforced by `StrictConcurrency=complete` (see `swift-lang`).\n\nSymptom-only fixes (another fallback in the lookup, another guard in the consumer) leave the pattern in place and the next instance ships in the next release.\n\n## Anti-patterns and smells\n\n| Smell | What it usually means |\n|---|---|\n| View file over ~500 lines | Logic is inline — extract a ViewModel and pure types |\n| Tests redefining types locally | The real types are too coupled to import — extract pure types |\n| Business state (loading flags, selected IDs) in `@State` | ViewModel is untestable or missing — fix the ViewModel, move state back |\n| `private init()` on every service | Singleton-only codebase — introduce protocols and DI |\n| Fake test data appearing in app-visible `.json` files | Persistence singleton needs protocol + mock injection |\n| `@State` properties doing validation | Validation is business logic — move to ViewModel |\n| Methods taking 10+ parameters to avoid instantiating a service | Extract the service behind a protocol instead |\n| `.sheet(isPresented:)` whose content closure can render nothing | Blank-pill bug waiting to happen — switch to `.sheet(item:)` |\n| Store exposes `items: [T] = []` with `isLoading` flag | Conflates never-loaded \u002F loading \u002F loaded-empty — model `LoadState` instead |\n| `repo.first(where: { $0.id == key \\|\\| $0.name == key })` | Identity seam being papered over — pick a canonical form |\n| `try?` on git\u002Fsubprocess\u002Fnetwork calls | Loud bugs converted to silent ones — see `swift-lang` |\n\n## Planning structure\n\nTwo complementary plan types — keep them separate.\n\n1. **Refactor plan** — structural changes that make code testable. Each phase is a self-contained PR. Commit types: `test:` for pure extract, `refactor:` for protocol\u002FDI introduction. Example phases: extract `QueryItemExtractor`, extract `ShellEscaper`, introduce `GitServiceProtocol`.\n2. **Coverage plan** — adds tests to code that is already testable. Commit type: `test:`. Example: \"write unit tests for `ProjectSearchService` filtering logic.\"\n\nDo **not** mix them. A single PR should either restructure code *or* add tests, not both. Mixed PRs are hard to review because you cannot tell whether a change is structural or behavioural.\n\n### Phase discipline\n\nEach phase is one PR into the integration branch. A phase is complete when:\n\n1. `make test` passes\n2. Build, lint, format-check all pass\n3. No observable behaviour changes for users\n4. PR is reviewed and merged\n5. Next phase rebases on the updated integration branch before starting\n\nUse a dedicated branch or worktree for the plan so in-flight work does not disturb the main checkout.\n\n## Order of operations\n\nWhen attacking a low-coverage SwiftUI codebase, work in this order:\n\n1. **Audit** — split the 0%-coverage files into \"no UI dependency\" (services, utilities, models) vs. \"UI-coupled\" (Views, View-hosted logic). The first group is where all the quick wins are.\n2. **Services and utilities first** — write tests; no architecture change needed for most.\n3. **Pure extractions** — pull parsers, filters, escapers out of big files into their own types. Test the new types. Commit as `test:`.\n4. **Protocol + DI** — one service at a time, starting with persistence (highest risk). Commit as `refactor:`, add ViewModel tests using the mock in the next PR.\n5. **ViewModel extractions** — for each large View, move form state and business logic to a ViewModel. Test the ViewModel.\n6. **ViewInspector residue** — for the thin views that remain, write ViewInspector tests for conditional rendering and button enablement.\n7. **Snapshot tests last** — only on visually stable, layout-critical views.\n\nFollowing this order, the overall coverage number climbs steadily and the biggest jumps come before you ever touch a `body`.\n",{"name":5,"description":7},"develop","5f79513fe27520bf03af784e8df568a04931c48d","skills\u002Ftech\u002Fskills\u002Fswiftui-lang",0,"https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants","https:\u002F\u002Feyelock.github.io\u002Fassistants\u002F","https:\u002F\u002Fgithub.com\u002Feyelock","http:\u002F\u002Fwww.eyelock.net\u002Fblog","2026-11-15 02:19:21",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add eyelock\u002Fassistants --skill swiftui-lang",{"tool":59,"command":60},"bunx","bunx skills add eyelock\u002Fassistants --skill swiftui-lang",{"tool":62,"command":63},"pnpm","pnpm dlx skills add eyelock\u002Fassistants --skill swiftui-lang","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Ftech\u002Fskills\u002Fswiftui-lang\u002FSKILL.md",true,[67,73],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"evals\u002Feval_queries.json","REFERENCE","参考文档",1115,"https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Ftech\u002Fskills\u002Fswiftui-lang\u002Fevals\u002Feval_queries.json",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"evals\u002Fevals.json",5988,"https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Ftech\u002Fskills\u002Fswiftui-lang\u002Fevals\u002Fevals.json",[78,84,110,125,137,150],{"skillNo":79,"name":80,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":39},"01M6H46CHAJFE20J3Q118P9PW9","doctor","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fplugins\u002Fwheelhouse\u002Fskills\u002Fdoctor\u002FSKILL.md",[],[80],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":39},"01M6H45X8QJZTQAPN56WZ8V111","add-seat","Add a named seat to a Wheelhouse - a crew member, a standing role (such as a dispatcher) or a worker - as a ynh harness with its charter, standing orders and only the tools its job needs, named from the Wheelhouse's roster. Use when asked to add, create or set up a seat, role, worker or agent in a Wheelhouse (a release manager, a PR watcher, a dispatcher, a designer, more workers), or to give a role a name, or to start on a Wheelhouse's team (its starter team), one role at a time. Also use to trial, make official or drop a seat.","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fplugins\u002Fwheelhouse\u002Fskills\u002Fadd-seat\u002FSKILL.md",[],[91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,28],"add","add seat","harness","SET","roster","use","release manager","workers","team","with","create","watcher","starter","when","more","worker","up","only","pr",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":39},"01M6H4BWCVR2YJVP8RW878NYDP","voice","How voices work - what a voice skill contains, how to write a new one, and how several voices compose into one reply. Use whenever drafting a reply in a named voice, or when asked to create or change a voice.","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Fvoice\u002Fskills\u002Fvoice\u002FSKILL.md",[],[112,101,27,117,118,119,96,120,36,121,122,123,104,124],"work","change","voice skill","compose","write","reply","new","drafting",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":39},"01M6H4BRVA87C6T495HCFNDQ7Z","voice-warm","A friendly voice that acknowledges the person and their effort. Compose with direct for friendly but brief.","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Fvoice\u002Fskills\u002Fvoice-warm\u002FSKILL.md",[],[132,112,133,100,134,120,135,23,136],"voice warm","person","brief","direct","but",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":39},"01M6H4BNFQ64X65YZDM9QMD61B","voice-formal","A careful, complete voice for people outside the team - customers, partners, senior stakeholders.","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Fvoice\u002Fskills\u002Fvoice-formal\u002FSKILL.md",[],[144,112,99,145,146,147,148,149,23],"voice formal","complete","senior","careful","partners","people",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":39},"01M6H4BHXE6KSNBY92TBFZY7QD","voice-direct","A plain, brief voice that leads with the answer. The default when no voice is named.","https:\u002F\u002Fgithub.com\u002Feyelock\u002Fassistants\u002Fblob\u002Fdevelop\u002Fskills\u002Fvoice\u002Fskills\u002Fvoice-direct\u002FSKILL.md",[],[157,135,112,100,134,158,159,160,104,161],"voice direct","leads","answer","default","plain"]