Guidelines for AI agents working on the Chau7 codebase.
- When asking questions, number them for easier back-and-forth.
Chau7/
├── apps/
│ ├── chau7-macos/ # SwiftUI + AppKit macOS app (SwiftPM)
│ └── chau7-ios/ # Native iOS app + remote UX docs
├── services/
│ ├── chau7-relay/ # Cloudflare relay (Workers + Durable Objects)
│ └── chau7-remote/ # Go relay client for macOS + protocol docs
└── docs/ # Shared top-level docs only when truly cross-cutting
- Run tests:
swift test- All tests must pass - Build check:
swift build- Must compile without errors - Add tests for new logic: Any new pure functions should have tests
Run these from apps/chau7-macos.
- Chau7Core module: Contains testable pure functions
- Tests location:
apps/chau7-macos/Tests/Chau7Tests/ - Test framework: XCTest (requires Xcode)
Add tests when:
- Adding new AI CLI detection (update
CommandDetection.swiftandCommandDetectionTests.swift) - Adding new event types (update
EventParsingandEventParsingTests.swift) - Adding any pure function that can be tested in isolation
// Good: Pure function in Chau7Core
public static func detectApp(from commandLine: String) -> String?
// Test it:
func testDetectClaude() {
XCTAssertEqual(CommandDetection.detectApp(from: "claude"), "Claude")
}Use the debug console to inspect runtime state:
- Tab states and active apps
- Claude Code sessions and events
- Live logs with filtering
- Generate bug reports
Use DebugContext for operations that need tracing:
let ctx = DebugContext(operation: "my-operation", metadata: ["key": value])
ctx.log("Step completed", metadata: ["result": result])
ctx.complete(success: true)Capture full app state for debugging:
let snapshot = StateSnapshot.capture(from: appModel, overlayModel: overlayModel)
_ = snapshot.save() // Saves to ~/.chau7/snapshots/When adding complex logic:
- Extract pure functions to
apps/chau7-macos/Sources/Chau7Core/ - Keep UI/state management in
apps/chau7-macos/Sources/Chau7/ - Add corresponding tests
Example:
// In apps/chau7-macos/Sources/Chau7Core/CommandDetection.swift
public static func tokenize(_ line: String) -> [String]
// In apps/chau7-macos/Sources/Chau7/TerminalSessionModel.swift
let tokens = CommandDetection.tokenize(commandLine)When adding support for new AI CLIs:
-
Add entries to
CommandDetection.appNameMap:"new-cli": "NewCLI", "new-cli-variant": "NewCLI"
-
Add output detection patterns if the CLI has identifiable banners:
("New CLI Banner", "NewCLI")
-
Add tab icon in
Chau7OverlayView.swift:case "NewCLI": return "sf.symbol.name"
-
Add tests:
func testDetectNewCLI() { XCTAssertEqual(CommandDetection.detectApp(from: "new-cli"), "NewCLI") }
-
Run
swift testto verify
| Purpose | Location |
|---|---|
| Main app entry | apps/chau7-macos/Sources/Chau7/Chau7App.swift |
| App delegate | apps/chau7-macos/Sources/Chau7/AppDelegate.swift |
| Terminal session | apps/chau7-macos/Sources/Chau7/TerminalSessionModel.swift |
| AI detection (testable) | apps/chau7-macos/Sources/Chau7Core/CommandDetection.swift |
| Debug tools | apps/chau7-macos/Sources/Chau7/DebugContext.swift, apps/chau7-macos/Sources/Chau7/DebugConsoleView.swift |
| Tests | apps/chau7-macos/Tests/Chau7Tests/CommandDetectionTests.swift |
| Logs | ~/Library/Logs/Chau7.log |
| Bug reports | ~/.chau7/reports/ |
| State snapshots | ~/.chau7/snapshots/ |
- Plan the implementation
- Extract testable logic to Chau7Core if applicable
- Write tests first (TDD) or alongside implementation
- Implement in Chau7
- Run
swift test - Run
swift build - Test manually with Debug Console (Cmd+Shift+D)
- Open Debug Console (Cmd+Shift+D)
- Check State tab for current app state
- Check Events tab for recent Claude Code activity
- Check Logs tab for errors
- Generate bug report if needed
- Check
~/Library/Logs/Chau7.logfor full history
- Reproduce the issue
- Add a failing test that demonstrates the bug
- Fix the code
- Verify test passes
- Run full test suite:
swift test