updated AGENTS.md with don't cause freezes, hangs requirement Closes: https://github.com/damus-io/damus/pull/3486 Signed-off-by: William Casarin <jb55@jb55.com>
3.7 KiB
3.7 KiB
Agents
Damus Overview
Damus is an iOS client built around a local relay model (damus-io/damus#3204) to keep interactions snappy and resilient. The app operates on nostrdb (source), and agents working on Damus should maximize usage of nostrdb facilities whenever possible.
Codebase Layout
damus/contains the SwiftUI app. Key subdirectories:Core(protocol, storage, networking, nostr primitives),Features(feature-specific flows like Timeline, Wallet, Purple),Shared(reusable UI components and utilities),Models, and localized resources (*.lproj,en-US.xcloc).nostrdb/hosts the embedded database. Swift bindings (Ndb.swift, iterators) wrap a C/LMDB core; prefer these abstractions when working with persistence or queries.damus-c/bridges C helpers (e.g., WASM runner) into Swift; checkdamus-Bridging-Header.hbefore adding new bridges.nostrscript/contains AssemblyScript sources compiled to WASM via the top-levelMakefile.- Tests live in
damusTests/(unit/snapshot coverage) anddamusUITests/(UI smoke tests). Keep them running before submitting changes.
Development Workflow
- Use
just build/just testfor simulator builds and the primary test suite (requiresxcbeautify). Update or addjustrecipes if new repeatable workflows emerge. - Xcode project is
damus.xcodeproj; the main scheme isdamus. Ensure new targets or resources integrate cleanly with this scheme. - Rebuild WASM helpers with
makewhen touchingnostrscript/sources. - Follow
docs/DEV_TIPS.mdfor debugging (enabling Info logging, staging push notification settings) and keep tips updated when discovering new workflows.
Testing Expectations
- Provide a concrete test report in each PR (see
.github/pull_request_template.md). Document devices, OS versions, and scenarios exercised. - Add or update unit tests in
damusTests/alongside feature changes, especially when touching parsing, storage, or replay logic. - UI regressions should include
damusUITests/coverage or rationale when automation is impractical. - Snapshot fixtures under
damusTests/__Snapshots__must be regenerated deliberately; explain updates in commit messages.
Contribution Standards
- Sign all commits (
git commit -s) and include appropriateChangelog-*,Closes:, orFixes:tags as described indocs/CONTRIBUTING.md. - Keep patches scoped: one logical change per commit, ensuring the app builds and runs after each step.
- Favor Swift-first solutions that lean on
nostrdbtypes (Ndb,NdbNote, iterators) before introducing new storage mechanisms. - Update documentation when workflows change, especially this file,
README.md, or developer notes.
Agent Requirements
- Code should tend toward simplicity.
- Commits should be logically distinct.
- Commits should be standalone.
- Code should be human readable.
- Code should be human reviewable.
- Ensure docstring coverage for any code added, or modified.
- Review and follow
pull_request_template.mdwhen creating PRs for iOS Damus. - Ensure nevernesting: favor early returns and guard clauses over deeply nested conditionals; simplify control flow by exiting early instead of wrapping logic in multiple layers of
ifstatements. - Before proposing changes, please review and analyze if a change or upgrade to nostrdb is beneficial to the change at hand.
- Never block the main thread: All network requests, database queries, and expensive computations must run on background threads/queues. Use
Task { },DispatchQueue.global(), or Swift concurrency (async/await) appropriately. UI updates must dispatch back to@MainActor. Test for hangs and freezes before submitting.