# Project Rules Dossier: Sidecar **Generated:** 2026-11-28T05:12:15Z ## Project Metadata - **Project Name:** Sidecar - **Project Type:** app - **Platforms:** macOS - **Resolved Root Path:** /Users/dave/warezfactory/xcode/Factory_Apps/Sidecar/ - **Rules Directory:** /Users/dave/warezfactory/xcode/Factory_Apps/Sidecar/.sidecar/rules - **Skills Directory:** /Users/dave/warezfactory/xcode/Factory_Apps/Sidecar/.sidecar/skills - **Context Folder:** Zack ## Applied Rules | Filename | Source Type | Lines | Characters | |----------|-------------|-------|------------| | 00-factory-global.md | symlink:/Users/dave/warezfactory/config/master_sidecar_rules/global/00-factory-global.md | 24 | 2187 | | 10-factory-swift.md | symlink:/Users/dave/warezfactory/config/master_sidecar_rules/platforms/macOS/_shared/10-factory-swift.md | 39 | 5550 | | 11-mac-app-rules.md | symlink:/Users/dave/warezfactory/config/master_sidecar_rules/platforms/macOS/app/11-mac-app-rules.md | 33 | 2267 | ## Available Skills - `app-resizability` - `modernize-tests` - `swift-concurrency` - `swiftui-specialist` - `swiftui-whats-new-27` ## Rule Contents ### 00-factory-global.md ~~~markdown # THE FACTORY GLOBAL DIRECTIVES (SIDECAR) You are an autonomous Sidecar agent operating natively inside The Factory on Apple Silicon. ### 1. Behavior & Tooling - Act as a pragmatic, disciplined software engineer. Keep explanations concise and factual. - Read the target files first before editing. Do not invent new abstractions if existing helpers or linked framework APIs already exist. - Always prefer `write_to_file` (or `XcodeWrite`) over `apply_diff` when making large structural edits to avoid patch collisions. - **TOOL FALLBACK PROTOCOL:** If `apply_diff` or `XcodeUpdate` fails due to a context mismatch or marker collision, do NOT loop retrying the diff. Read the target lines or switch cleanly to `write_to_file`. ### 🛑 THE ANTI-SED MANDATE (STRICT EXECUTION BAN) - You are **STRICTLY FORBIDDEN** from using `sed`, `awk`, `perl`, `python`, or `/tmp` file splicing (`cat head + patch + tail`) to edit project source code. - Command-line text stream editing on Swift source code drops closing braces, corrupts class scopes, and creates syntax disasters. - If a diff fails, you MUST use `write_to_file` (or `XcodeWrite`) to write the updated file cleanly. - Running `sed` or `/tmp` splicing commands to alter source files is classified as an invalid protocol violation. ### 2. The File ID Directive (CRITICAL) If you edit a file containing a `// Code Custodian File ID: [UUID]` comment, you MUST retain that exact comment block at the top of the file verbatim. Do not delete or alter it. ### 3. Task Completion & Verification Gate - You are strictly forbidden from concluding a task until all changes are compiled and verified on hardware: - **Swift / Xcode Tasks:** `BuildProject` and `GetBuildLog` must confirm zero in-scope compilation errors. - **Web Tasks:** All applicable linters (`htmlhint`, `stylelint`, `eslint`) must pass cleanly. - **Art / Copywriting Tasks:** Output payloads and metadata files must be verified on disk. - **No Dead-Drop Files:** Do NOT create `.sidecar_result.json` or invoke nonexistent `crosstalk.*` MCP tools. Conclude directly once verification passes and deliver a concise summary detailing modified files and verified build status. ~~~ ### 10-factory-swift.md ~~~markdown # THE FACTORY SWIFT & XCODE DIRECTIVES (SIDECAR) ### 1. Swift Architecture Rules - **SWIFTDATA ISOLATION:** Never use `default.store` or generic `ModelContainer` setups. Always resolve isolated SQLite URLs via `FactoryPaths.databaseURL(for:storeName:)`. - **STRICT CONCURRENCY:** Adhere strictly to Swift 6.4 actor boundaries and `@MainActor` isolation. - **WORKSPACE RELATIVE PATHS & NORMALIZATION:** Standard app source files reside at `[ProjectName]/[FileName].swift` relative to workspace root. * **PROMPT PATH NORMALIZATION:** If a prompt contains duplicated project folder prefixes (e.g. `CrossTalk/CrossTalk/File.swift`), normalize to `[ProjectName]/[FileName].swift` before calling file tools. * **SUBFOLDER PATH DEDUPLICATION:** If any path develops multiplied project segments (e.g. `.../CrossTalk/CrossTalk/...`), collapse immediately to the canonical single-subfolder path. - **PROJECT BUNDLES OFF-LIMITS:** Never read, search, or edit files inside `*.xcodeproj` or `*.xcworkspace` (especially `project.pbxproj`). Xcode picks up new files on disk automatically and links binaries dynamically from `$SHARED_BINARIES`. - **DYNAMIC AGENT RESOLUTION:** Never hardcode versioned agent names (e.g. `"Frank 2.0"`, `"Mike 13.0"`). Always resolve dynamically via `FactoryRegistryManager.shared.resolveActiveAgent(baseName:)`. - **STANDARDIZED IPC (`FactoryKit`):** Never use raw `DistributedNotificationCenter.default()`. Always import `FactoryKit` and use `NotificationCenter.postDistributed(...)` and `NotificationCenter.addDistributedObserver(...)`. - **FRAMEWORK BOUNDARIES:** Files in `Framework_Stubs/*.api.swift` are read-only headers. Do NOT edit stubs or import frameworks absent from the target's `Framework_Stubs/` directory. ### 2. Apple Developer Documentation Search (MCP) - Use `DocumentationSearch` to verify modern Xcode 27.2 / Swift 6.4 APIs and SwiftUI modifiers before guessing syntax. ### 3. File Tool Preference, Xcode MCP Sequence & The Yellow Triangle Rule - **Prefer Native File Tools for Source Edits:** Use `read_file`, `write_to_file`, and `apply_diff` when reading or modifying existing Swift files—they return complete files in one call without 600-line pagination, `workspaceIdentifier` overhead, or integer parameter mismatches. Reserve Xcode MCP tools for `XcodeOpenWorkspace`, `XcodeSwitchScheme`, `BuildProject`, `GetBuildLog`, `DocumentationSearch`, and project-tree changes (`XcodeWrite`, `XcodeRM`, `XcodeMV`). 1. **Session First (Use Pre-Opened Context When Provided):** If Sidecar already provides an active `workspaceIdentifier` and `activeScheme` in your session context, use that `workspaceIdentifier` directly and do NOT call `XcodeListWorkspaces`, `XcodeOpenWorkspace`, or `XcodeListSchemes` (unless switching to a sibling scheme in a multi-target monorepo task). Otherwise, call `XcodeOpenWorkspace` (or `XcodeListWorkspaces`) first to acquire a `workspaceIdentifier`, and always pass unquoted integers (never strings) for numeric parameters such as `limit` and `offset`. 2. **Switch Scheme (When Needed):** `BuildProject` compiles the *currently active scheme* in Xcode. If the target scheme does not already match the active scheme provided by Sidecar (or if targeting a sibling scheme in a monorepo), call `XcodeSwitchScheme` passing `schemeName: "[TargetName]"` and confirm it succeeded before calling `BuildProject`. 3. **Compile & Inspect:** Run `BuildProject`, then inspect `GetBuildLog` (defaulting to errors, and checking warnings for files you modified). 4. **THE YELLOW TRIANGLE RULE:** - Ignore errors or warnings inside third-party packages (`.build/`, `Swifter`, `SwiftSoup`, `Alamofire`) or unmodified files. - Fix all compiler errors and warnings in every file you explicitly modified. - Note any out-of-scope pre-existing warnings in your closing summary. ### 4. On-Demand Skills (`read_skill`) - Before writing complex Swift concurrency, SwiftUI layouts, or Swift Testing suites, call `read_skill(skill_name:)` to load the official dossier (`swift-concurrency`, `swiftui-specialist`, `swiftui-whats-new-27`, `app-resizability`, `modernize-tests`). ### 5. Process Execution Boundaries - Never instantiate raw Foundation `Process()` for shell commands or scripts; use `StreamlineFoundation.runCommand`, `runSwift`, or `runPython`. Raw `Process()` is reserved strictly for continuous bidirectional stdio JSON-RPC transports. ### 6. 2026 Swift 6.4 & SwiftUI Polyfill - **Strict Sendable & Approachable Concurrency:** Never use `@unchecked Sendable` as a shortcut. Annotate cross-isolation closures with `@Sendable` and use typed throws (`throws(DomainError)`) where appropriate. - **Async Cleanup in `defer` (SE-0493):** Place async teardown operations inside `defer { await ... }` rather than duplicating cleanup calls across `return` and `catch` paths. - **Natural Optionals (SE-0521):** Write unparenthesized optional existential/opaque types (`some View?`, `any Tool?`). - **Swift Testing:** Never import `XCTest`. Use `import Testing`, `@Suite`, `@Test`, `#expect`, and `#require`. - **Modern State Architecture:** Never use `ObservableObject`, `@ObservedObject`, `@StateObject`, `@Published`, or `@EnvironmentObject`. Use `@Observable`, `@State`, `@Bindable`, and `@Environment(ModelType.self)`. - **Navigation & Windows:** Never use `NavigationView` or `NavigationLink(destination:isActive:)`. Use `NavigationStack(path:)` or `NavigationSplitView` with `Hashable` routes, and declarative SwiftUI `Window` scenes rather than manual `NSWindow` frame manipulation. ~~~ ### 11-mac-app-rules.md ~~~markdown # THE FACTORY: MACOS STANDALONE APP DIRECTIVES You are operating inside a standalone macOS App target within The Factory ecosystem. --- ## 1. SCENE LIFECYCLE & WINDOW GEOMETRY - **Declarative Window Management:** Use standard SwiftUI `WindowGroup` declarations. Enforce explicit minimum and ideal frame constraints (`.frame(minWidth: ..., minHeight: ...)`) directly on the root scene or detail containers. - **No Manual Frame Manipulation:** Do not manipulate raw `NSWindow` frame rectangles, frame autosave names, or window delegates manually unless explicitly required for AppKit bridge hosting. --- ## 2. APPKIT BRIDGING & TEXT VIEW SUBSTITUTION - **Disabling Smart Punctuation:** All user-editable text fields, custom mode editors, and code/JSON input areas hosted via `NSTextView` or `NSViewRepresentable` must disable automatic smart quotes, smart dashes, text replacements, and spelling auto-correction: - Ensure straight quotes (`"`, `'`) and standard hyphens (`-`) are preserved verbatim to protect YAML, JSON, CLI commands, and code blocks from corruption. --- ## 3. SWIFTDATA & PERSISTENCE ISOLATION - **Database Sandboxing:** Never initialize `ModelContainer` against root Application Support or default store names. - **Isolated Storage Paths:** Always resolve persistent database store URLs using `FactoryPaths.databaseURL(for:storeName:)`. --- ## 4. STANDARDIZED FACTORY IPC - **Dynamic Agent Resolution:** Never hardcode versioned agent names (e.g., "Mike 14.0"). Always resolve active recipients dynamically using `FactoryRegistryManager.shared.resolveActiveAgent(baseName:)`. - **Cross-Process Notification Helpers:** Always use `NotificationCenter.postDistributed` and `NotificationCenter.addDistributedObserver` from `FactoryKit` for system-wide inter-process messaging. --- ## 5. BUILD VERIFICATION ONLY (NO TEST RUNNER CALLS) - **Skip Test Schemes on Standalone Apps:** Standalone Factory App targets do not have unit test schemes configured. Unless the task prompt explicitly instructs you to create or execute tests, **do NOT invoke Xcode test-runner tools** (`RunAllTests`, `RunSomeTests`, `XcodeRunTests`). - **Sufficient Gate:** Clean compilation via `BuildProject` and zero diagnostics in `GetBuildLog` completes verification. ~~~