diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 10:10:19 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 10:10:19 +0000 |
| commit | 53b926427fa6b65abcf680dd1c19eebfd3e85f65 (patch) | |
| tree | 870f14bcd71c8e2c0db788469f3578d40ee575ee /AGENTS.md | |
| parent | fa9753e020afaefea96d106259770b6c836d1111 (diff) | |
docs: roo code /init stripped down AGENTS.md
Diffstat (limited to 'AGENTS.md')
| -rw-r--r-- | AGENTS.md | 829 |
1 files changed, 79 insertions, 750 deletions
| @@ -1,802 +1,131 @@ | |||
| 1 | # AI Agent Guidelines for ngit-grasp | 1 | # AGENTS.md |
| 2 | |||
| 3 | **Purpose:** Ensure AI agents (and humans) maintain consistent documentation practices and avoid common pitfalls. | ||
| 4 | |||
| 5 | **Last Updated:** November 4, 2025 | ||
| 6 | |||
| 7 | --- | ||
| 8 | |||
| 9 | ## π Documentation Structure | ||
| 10 | |||
| 11 | ### Overview | ||
| 12 | |||
| 13 | We use the **[DiΓ‘taxis](https://diataxis.fr/) framework** for all documentation. This prevents documentation sprawl by organizing content into four clear categories based on purpose and audience. | ||
| 14 | |||
| 15 | ``` | ||
| 16 | ngit-grasp/ | ||
| 17 | βββ README.md # Project overview (keep updated) | ||
| 18 | βββ AGENTS.md # This file - agent guidelines | ||
| 19 | βββ CHANGELOG.md # User-facing changes (semver) | ||
| 20 | β | ||
| 21 | βββ work/ # Temporary session files (.gitignore'd) | ||
| 22 | β βββ README.md # Only file committed to git | ||
| 23 | β βββ *.md # Session notes, status, plans (temporary) | ||
| 24 | β | ||
| 25 | βββ docs/ # All documentation (DiΓ‘taxis structure) | ||
| 26 | β βββ README.md # Navigation guide with quadrant diagram | ||
| 27 | β β | ||
| 28 | β βββ tutorials/ # Learning-oriented (practical + learning) | ||
| 29 | β β βββ getting-started.md # First-time setup | ||
| 30 | β β βββ first-audit.md # Running your first audit | ||
| 31 | β β | ||
| 32 | β βββ how-to/ # Task-oriented (practical + working) | ||
| 33 | β β βββ deploy.md # Production deployment | ||
| 34 | β β βββ nix-flakes.md # Nix environment setup | ||
| 35 | β β βββ test-compliance.md # Running compliance tests | ||
| 36 | β β βββ upgrade-nostr-sdk.md # SDK upgrade guide | ||
| 37 | β β | ||
| 38 | β βββ reference/ # Information-oriented (theoretical + working) | ||
| 39 | β β βββ git-protocol.md # Git Smart HTTP protocol | ||
| 40 | β β βββ grasp-protocol.md # GRASP specification | ||
| 41 | β β βββ configuration.md # All config options | ||
| 42 | β β βββ test-strategy.md # Testing reference | ||
| 43 | β β βββ api.md # Internal API docs | ||
| 44 | β β | ||
| 45 | β βββ explanation/ # Understanding-oriented (theoretical + learning) | ||
| 46 | β β βββ architecture.md # System design overview | ||
| 47 | β β βββ inline-authorization.md # Why inline auth? | ||
| 48 | β β βββ comparison.md # vs ngit-relay | ||
| 49 | β β βββ decisions.md # Design decisions | ||
| 50 | β β | ||
| 51 | β βββ archive/ # Historical session notes | ||
| 52 | β β βββ YYYY-MM-DD-*.md # Completed work | ||
| 53 | β β | ||
| 54 | β βββ learnings/ # DEPRECATED - migrated to DiΓ‘taxis | ||
| 55 | β βββ README.md # Migration notice | ||
| 56 | β | ||
| 57 | βββ grasp-audit/ # Audit tool subproject | ||
| 58 | β βββ README.md # Main audit docs | ||
| 59 | β βββ docs/ # Follows same DiΓ‘taxis structure | ||
| 60 | β βββ tutorials/ | ||
| 61 | β βββ how-to/ | ||
| 62 | β βββ reference/ | ||
| 63 | β βββ explanation/ | ||
| 64 | β | ||
| 65 | βββ .ai/ # AI assistant context (ignored in git) | ||
| 66 | βββ history/ # Conversation history | ||
| 67 | ``` | ||
| 68 | 2 | ||
| 69 | ### DiΓ‘taxis Framework | 3 | This file provides guidance to agents when working with code in this repository. |
| 70 | |||
| 71 | All documentation MUST fit into one of four categories: | ||
| 72 | |||
| 73 | **π Tutorials** (`docs/tutorials/`) | ||
| 74 | - **Purpose:** Learning-oriented, teach by doing | ||
| 75 | - **Audience:** Newcomers, beginners | ||
| 76 | - **Style:** Step-by-step lessons with guaranteed outcomes | ||
| 77 | - **Examples:** Getting Started, First Audit | ||
| 78 | - **Question:** "Can you teach me to...?" | ||
| 79 | |||
| 80 | **π§ How-To Guides** (`docs/how-to/`) | ||
| 81 | - **Purpose:** Task-oriented, solve problems | ||
| 82 | - **Audience:** Users with basic knowledge | ||
| 83 | - **Style:** Practical recipes and solutions | ||
| 84 | - **Examples:** Deploy, Configure, Troubleshoot | ||
| 85 | - **Question:** "How do I...?" | ||
| 86 | |||
| 87 | **π Reference** (`docs/reference/`) | ||
| 88 | - **Purpose:** Information-oriented, technical facts | ||
| 89 | - **Audience:** Users looking up specific information | ||
| 90 | - **Style:** Dry, factual, comprehensive | ||
| 91 | - **Examples:** API docs, Config options, Protocols | ||
| 92 | - **Question:** "What is...?" | ||
| 93 | |||
| 94 | **π‘ Explanation** (`docs/explanation/`) | ||
| 95 | - **Purpose:** Understanding-oriented, clarify concepts | ||
| 96 | - **Audience:** Users wanting deeper understanding | ||
| 97 | - **Style:** Discussion, context, alternatives | ||
| 98 | - **Examples:** Architecture, Design Decisions, Comparisons | ||
| 99 | - **Question:** "Why...?" | ||
| 100 | |||
| 101 | **See:** [DiΓ‘taxis documentation](https://diataxis.fr/) for detailed guidance. | ||
| 102 | |||
| 103 | ### File Type Guidelines | ||
| 104 | |||
| 105 | **Markdown (.md):** | ||
| 106 | - Primary format for all documentation | ||
| 107 | - Easy to read in plain text and rendered | ||
| 108 | - Supports code blocks, links, tables | ||
| 109 | - Version control friendly | ||
| 110 | |||
| 111 | **Text (.txt):** | ||
| 112 | - Only for visual ASCII art summaries | ||
| 113 | - Must be archived after session (never permanent) | ||
| 114 | - Examples: status boxes, visual diagrams | ||
| 115 | - Archive to `docs/archive/YYYY-MM-DD-name.txt` | ||
| 116 | |||
| 117 | **Other formats:** | ||
| 118 | - Avoid unless absolutely necessary | ||
| 119 | - If needed, document in README.md why | ||
| 120 | |||
| 121 | --- | ||
| 122 | |||
| 123 | ## π Document Lifecycle | ||
| 124 | |||
| 125 | ### 1. Working Documents (work/ Directory) | ||
| 126 | |||
| 127 | **Purpose:** Session-specific temporary files | ||
| 128 | **Location:** `work/` directory (.gitignore'd) | ||
| 129 | **Lifecycle:** Created β Used β Archived or Deleted | ||
| 130 | **Retention:** Archive valuable content, delete rest at session end | ||
| 131 | |||
| 132 | **Examples:** | ||
| 133 | - `work/session-notes.md` β Session notes and progress | ||
| 134 | - `work/status.md` β Current status report | ||
| 135 | - `work/migration-plan.md` β Planning document | ||
| 136 | - `work/visual-summary.txt` β ASCII art summaries | ||
| 137 | |||
| 138 | **Rules:** | ||
| 139 | - β Create ALL session-specific docs in `work/` | ||
| 140 | - β Use descriptive names (no date prefix needed) | ||
| 141 | - β Archive valuable content to `docs/archive/YYYY-MM-DD-name.md` | ||
| 142 | - β Delete obsolete files at session end | ||
| 143 | - β Keep `work/` clean (empty except README.md when not in session) | ||
| 144 | - β Don't commit `work/` contents to git (except README.md) | ||
| 145 | - β Don't reference `work/` docs from permanent documentation | ||
| 146 | - β Don't let `work/` accumulate files between sessions | ||
| 147 | |||
| 148 | **Why work/ instead of root:** | ||
| 149 | - Keeps root clean (only README.md, AGENTS.md, CHANGELOG.md) | ||
| 150 | - Clear separation: permanent vs. temporary | ||
| 151 | - Not committed to git (reduces noise) | ||
| 152 | - Easy to clean up (just `rm -rf work/*`) | ||
| 153 | |||
| 154 | ### 2. Permanent Documentation (docs/) | ||
| 155 | |||
| 156 | **Purpose:** Long-term reference, architecture, guides | ||
| 157 | **Location:** `docs/` (organized by DiΓ‘taxis category) | ||
| 158 | **Lifecycle:** Created β Maintained β Updated | ||
| 159 | **Retention:** Permanent (version controlled) | ||
| 160 | |||
| 161 | **Structure:** | ||
| 162 | - `docs/tutorials/` - Learning-oriented lessons | ||
| 163 | - `docs/how-to/` - Task-oriented guides | ||
| 164 | - `docs/reference/` - Information-oriented facts | ||
| 165 | - `docs/explanation/` - Understanding-oriented discussion | ||
| 166 | |||
| 167 | **Examples:** | ||
| 168 | - `docs/tutorials/getting-started.md` - First-time setup | ||
| 169 | - `docs/how-to/deploy.md` - Deployment guide | ||
| 170 | - `docs/reference/configuration.md` - Config options | ||
| 171 | - `docs/explanation/architecture.md` - System design | ||
| 172 | |||
| 173 | **Rules:** | ||
| 174 | - β Categorize by DiΓ‘taxis framework (tutorial/how-to/reference/explanation) | ||
| 175 | - β Keep updated as project evolves | ||
| 176 | - β Use clear structure and headings | ||
| 177 | - β Link between related docs | ||
| 178 | - β Don't duplicate information (use links) | ||
| 179 | - β Don't include session-specific details | ||
| 180 | - β Don't put docs in wrong category (see DiΓ‘taxis guide) | ||
| 181 | |||
| 182 | ### 3. Archive (docs/archive/) | ||
| 183 | |||
| 184 | **Purpose:** Historical record, completed phases | ||
| 185 | **Location:** `docs/archive/` | ||
| 186 | **Lifecycle:** Moved from root β Archived | ||
| 187 | **Retention:** Permanent (for reference) | ||
| 188 | |||
| 189 | **Examples:** | ||
| 190 | - `docs/archive/2025-11-04-tag-migration.md` | ||
| 191 | - `docs/archive/2025-11-03-architecture-investigation.md` | ||
| 192 | |||
| 193 | **Rules:** | ||
| 194 | - β Rename with date prefix when archiving | ||
| 195 | - β Add "ARCHIVED" marker at top | ||
| 196 | - β Extract learnings to docs/learnings/ first | ||
| 197 | - β Don't modify after archiving | ||
| 198 | - β Don't reference in active documentation | ||
| 199 | |||
| 200 | ### 4. Learnings (DEPRECATED) | ||
| 201 | |||
| 202 | **Status:** `docs/learnings/` is deprecated - content migrated to DiΓ‘taxis structure | ||
| 203 | |||
| 204 | **Migration:** | ||
| 205 | - Gotchas and patterns β `docs/how-to/` | ||
| 206 | - Technical details β `docs/reference/` | ||
| 207 | - Understanding concepts β `docs/explanation/` | ||
| 208 | |||
| 209 | **Examples:** | ||
| 210 | - `learnings/nix-flakes.md` β `how-to/nix-flakes.md` | ||
| 211 | - `learnings/nostr-sdk.md` β `reference/nostr-sdk-upgrade.md` | ||
| 212 | - `learnings/git-http-backend.md` β `reference/git-protocol.md` | ||
| 213 | |||
| 214 | **Rules:** | ||
| 215 | - β Don't create new files in `docs/learnings/` | ||
| 216 | - β Migrate existing content to appropriate DiΓ‘taxis category | ||
| 217 | - β Add redirect notice in old location | ||
| 218 | |||
| 219 | --- | ||
| 220 | |||
| 221 | ## π Cleanup Process | ||
| 222 | |||
| 223 | ### When to Clean Up | ||
| 224 | |||
| 225 | **Trigger:** End of session OR `work/` has >5 files | ||
| 226 | **Frequency:** End of each session (mandatory) | ||
| 227 | **Responsibility:** AI agents should proactively clean up before session end | ||
| 228 | |||
| 229 | ### Cleanup Steps | ||
| 230 | |||
| 231 | 1. **Review work/ Directory** | ||
| 232 | ```bash | ||
| 233 | # List all working docs | ||
| 234 | ls -la work/ | ||
| 235 | ``` | ||
| 236 | |||
| 237 | 2. **Extract to DiΓ‘taxis Categories** | ||
| 238 | - Review each doc in `work/` | ||
| 239 | - Extract valuable content to appropriate category: | ||
| 240 | - Gotchas/solutions β `docs/how-to/` | ||
| 241 | - Technical facts β `docs/reference/` | ||
| 242 | - Concepts/design β `docs/explanation/` | ||
| 243 | - Lessons β `docs/tutorials/` | ||
| 244 | |||
| 245 | 3. **Archive Important Session Docs** | ||
| 246 | ```bash | ||
| 247 | # Archive valuable session docs with date prefix | ||
| 248 | mv work/migration-complete.md docs/archive/2025-11-04-migration-complete.md | ||
| 249 | mv work/visual-summary.txt docs/archive/2025-11-04-visual-summary.txt | ||
| 250 | ``` | ||
| 251 | |||
| 252 | 4. **Delete Temporary Files** | ||
| 253 | ```bash | ||
| 254 | # Delete obsolete working docs | ||
| 255 | rm work/status.md | ||
| 256 | rm work/notes.md | ||
| 257 | |||
| 258 | # Or clean everything | ||
| 259 | rm -rf work/* | ||
| 260 | # (work/README.md is safe - in .gitignore exception) | ||
| 261 | ``` | ||
| 262 | |||
| 263 | 5. **Verify Clean State** | ||
| 264 | ```bash | ||
| 265 | # Root should only have these: | ||
| 266 | ls *.md | ||
| 267 | # README.md | ||
| 268 | # AGENTS.md | ||
| 269 | # (CHANGELOG.md when created) | ||
| 270 | |||
| 271 | # work/ should be empty (except README.md) | ||
| 272 | ls work/ | ||
| 273 | # README.md | ||
| 274 | ``` | ||
| 275 | |||
| 276 | 6. **Commit Changes** | ||
| 277 | - Commit new permanent docs | ||
| 278 | - Commit archived docs | ||
| 279 | - Note: work/ contents not committed (gitignored) | ||
| 280 | |||
| 281 | ### Example Cleanup | ||
| 282 | 4 | ||
| 283 | ```bash | 5 | ## Project Structure |
| 284 | # Before cleanup (messy root!) | ||
| 285 | ls *.md | ||
| 286 | # README.md | ||
| 287 | # AGENTS.md | ||
| 288 | # CURRENT_STATUS.md | ||
| 289 | # DIATAXIS_MIGRATION.md | ||
| 290 | # SUMMARY.md | ||
| 291 | # SESSION_NOTES.md | ||
| 292 | # ... (many more) | ||
| 293 | |||
| 294 | # After cleanup (clean root!) | ||
| 295 | ls *.md | ||
| 296 | # README.md | ||
| 297 | # AGENTS.md | ||
| 298 | 6 | ||
| 299 | # Working files in work/ during session | 7 | **Workspace with Two Rust Projects:** |
| 300 | ls work/ | 8 | - Root: `ngit-grasp` (main GRASP relay implementation) |
| 301 | # README.md | 9 | - `grasp-audit/`: Separate subproject with own `Cargo.toml` and `flake.nix` |
| 302 | # session-notes.md | ||
| 303 | # status.md | ||
| 304 | |||
| 305 | # After session cleanup | ||
| 306 | ls work/ | ||
| 307 | # README.md | ||
| 308 | # (all session files archived or deleted) | ||
| 309 | |||
| 310 | # Archived | ||
| 311 | ls docs/archive/ | tail -5 | ||
| 312 | # 2025-11-04-diataxis-migration.md | ||
| 313 | # 2025-11-04-diataxis-complete.md | ||
| 314 | # 2025-11-04-diataxis-migration-visual.txt | ||
| 315 | # 2025-11-04-session-summary.md | ||
| 316 | # ... | ||
| 317 | |||
| 318 | # Permanent docs in DiΓ‘taxis structure | ||
| 319 | ls docs/tutorials/ | ||
| 320 | # getting-started.md | ||
| 321 | # first-audit.md | ||
| 322 | |||
| 323 | ls docs/how-to/ | ||
| 324 | # nix-flakes.md | ||
| 325 | # deploy.md | ||
| 326 | ``` | ||
| 327 | 10 | ||
| 328 | --- | 11 | Cannot build grasp-audit from root - must `cd grasp-audit` first. |
| 329 | 12 | ||
| 330 | ## π¨ Common Gotchas | 13 | ## Build & Test |
| 331 | 14 | ||
| 332 | ### Nix Flakes | 15 | ### Nix Flakes (Non-Standard) |
| 333 | 16 | ||
| 334 | **Always use `nix develop`, not `nix-shell`** | 17 | **CRITICAL:** Use `nix develop`, NOT `nix-shell` (we use flake.nix, not shell.nix) |
| 335 | 18 | ||
| 336 | ```bash | 19 | ```bash |
| 337 | # β Correct | 20 | # β Correct |
| 338 | cd grasp-audit | 21 | cd grasp-audit |
| 339 | nix develop | ||
| 340 | nix develop -c cargo build | 22 | nix develop -c cargo build |
| 23 | nix develop -c cargo test | ||
| 341 | 24 | ||
| 342 | # β Wrong | 25 | # β Wrong |
| 343 | nix-shell | 26 | nix-shell |
| 344 | nix-shell --run "cargo build" | 27 | nix-shell --run "cargo build" |
| 345 | ``` | 28 | ``` |
| 346 | 29 | ||
| 347 | **Why:** We use `flake.nix`, not `shell.nix`. See `docs/learnings/nix-flakes.md`. | 30 | ### Running Tests |
| 348 | |||
| 349 | **Flake Commands:** | ||
| 350 | ```bash | ||
| 351 | # Show flake outputs | ||
| 352 | nix flake show | ||
| 353 | |||
| 354 | # Update flake inputs | ||
| 355 | nix flake update | ||
| 356 | |||
| 357 | # Build package | ||
| 358 | nix build | ||
| 359 | |||
| 360 | # Run package | ||
| 361 | nix run | ||
| 362 | ``` | ||
| 363 | |||
| 364 | ### Git Subprojects | ||
| 365 | 31 | ||
| 366 | **grasp-audit is a subproject with its own flake** | 32 | **Integration tests require relay running:** |
| 367 | 33 | ||
| 368 | ```bash | 34 | ```bash |
| 369 | # β Correct - enter grasp-audit environment | 35 | # Start ngit-relay first (tests run on port 18081) |
| 370 | cd grasp-audit | 36 | docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/decentralizedclimate/ngit-relay:latest |
| 371 | nix develop | ||
| 372 | cargo build | ||
| 373 | |||
| 374 | # β Wrong - can't build from root | ||
| 375 | cd ngit-grasp | ||
| 376 | cargo build # This won't find grasp-audit | ||
| 377 | ``` | ||
| 378 | |||
| 379 | **Why:** `grasp-audit/` has its own `Cargo.toml` and `flake.nix`. | ||
| 380 | 37 | ||
| 381 | ### nostr-sdk Versions | 38 | # From grasp-audit directory |
| 382 | 39 | nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture | |
| 383 | **We use nostr-sdk 0.43.x (latest stable)** | ||
| 384 | |||
| 385 | ```toml | ||
| 386 | # β Correct | ||
| 387 | [dependencies] | ||
| 388 | nostr-sdk = "0.43" | ||
| 389 | |||
| 390 | # β Wrong | ||
| 391 | nostr-sdk = "0.35" # Old version, breaking changes | ||
| 392 | ``` | 40 | ``` |
| 393 | 41 | ||
| 394 | **Why:** We upgraded from 0.35 to 0.43. See `docs/learnings/nostr-sdk.md` for migration notes. | 42 | Tests marked `#[ignore]` need relay - unit tests don't. |
| 395 | 43 | ||
| 396 | **Common Breaking Changes:** | 44 | ### Running Single Test |
| 397 | - `EventBuilder::new()` signature changed | ||
| 398 | - Tag API changed to `Tag::custom()` | ||
| 399 | - Filter API changed | ||
| 400 | - See archived upgrade docs for details | ||
| 401 | |||
| 402 | ### Testing Patterns | ||
| 403 | |||
| 404 | **Integration tests require relay** | ||
| 405 | 45 | ||
| 406 | ```bash | 46 | ```bash |
| 407 | # β Correct - start relay first | 47 | # From grasp-audit/ |
| 408 | docker run --rm -p 7000:7000 scsibug/nostr-rs-relay | 48 | nix develop -c cargo test --lib specific_test_name -- --nocapture |
| 409 | |||
| 410 | # Then run tests | ||
| 411 | cd grasp-audit | ||
| 412 | nix develop -c cargo test --ignored | ||
| 413 | |||
| 414 | # β Wrong - integration tests will fail | ||
| 415 | cargo test --ignored # No relay running | ||
| 416 | ``` | 49 | ``` |
| 417 | 50 | ||
| 418 | **Test Organization:** | 51 | ## Code Patterns |
| 419 | ```rust | ||
| 420 | // Unit tests (no relay needed) | ||
| 421 | #[cfg(test)] | ||
| 422 | mod tests { | ||
| 423 | #[test] | ||
| 424 | fn test_something() { } | ||
| 425 | } | ||
| 426 | |||
| 427 | // Integration tests (relay required) | ||
| 428 | #[cfg(test)] | ||
| 429 | mod tests { | ||
| 430 | #[test] | ||
| 431 | #[ignore] // Requires relay | ||
| 432 | fn test_against_relay() { } | ||
| 433 | } | ||
| 434 | ``` | ||
| 435 | |||
| 436 | ### Documentation Updates | ||
| 437 | |||
| 438 | **Keep README.md synchronized** | ||
| 439 | |||
| 440 | When you: | ||
| 441 | - Complete a major feature β Update README.md status | ||
| 442 | - Change architecture β Update docs/ARCHITECTURE.md | ||
| 443 | - Add dependencies β Update README.md tech stack | ||
| 444 | - Change workflow β Update docs/GETTING_STARTED.md | ||
| 445 | 52 | ||
| 446 | **Don't:** | 53 | ### nostr-sdk 0.43 Breaking Changes (vs 0.35) |
| 447 | - Create duplicate documentation | ||
| 448 | - Leave stale status markers | ||
| 449 | - Forget to update CHANGELOG.md for user-facing changes | ||
| 450 | 54 | ||
| 451 | --- | 55 | **Field access, not method calls:** |
| 452 | 56 | ||
| 453 | ## π File Format Guidelines | 57 | ```rust |
| 454 | 58 | // β WRONG (0.35 API) | |
| 455 | ### When to Use .txt Files | 59 | event.id() |
| 456 | 60 | event.tags() | |
| 457 | **Use .txt ONLY for:** | 61 | for tag in &event.tags { } |
| 458 | - ASCII art visual summaries | 62 | |
| 459 | - Box diagrams with Unicode characters | 63 | // β CORRECT (0.43 API) |
| 460 | - Terminal-style status displays | 64 | event.id // Direct field access |
| 461 | 65 | event.tags // Direct field access | |
| 462 | **Examples of appropriate .txt content:** | 66 | event.tags.iter() // Iterator method |
| 463 | ``` | ||
| 464 | ββββββββββββββββββββββββββββββββββββββββββ | ||
| 465 | β STATUS: β COMPLETE β | ||
| 466 | ββββββββββββββββββββββββββββββββββββββββββ | ||
| 467 | ``` | ||
| 468 | |||
| 469 | **Rules:** | ||
| 470 | - β Create in root during session for visual impact | ||
| 471 | - β Archive immediately after session ends | ||
| 472 | - β Use descriptive names: `CLEANUP_VISUAL_SUMMARY.txt` | ||
| 473 | - β Never keep .txt files in root long-term | ||
| 474 | - β Don't use .txt for regular documentation | ||
| 475 | - β Don't duplicate information (use .md instead) | ||
| 476 | |||
| 477 | **Lifecycle:** | ||
| 478 | ``` | ||
| 479 | Create .txt β Use in session β Archive immediately | ||
| 480 | ``` | 67 | ``` |
| 481 | 68 | ||
| 482 | ### When to Use .md Files | 69 | **Tag API changed:** |
| 483 | 70 | ```rust | |
| 484 | **Use .md for ALL documentation:** | 71 | // β WRONG (0.35) |
| 485 | - Architecture docs | 72 | Tag::Generic(TagKind::Custom("clone".into()), vec![...]) |
| 486 | - Session summaries | ||
| 487 | - Status reports | ||
| 488 | - Learnings | ||
| 489 | - Planning documents | ||
| 490 | - API documentation | ||
| 491 | - User guides | ||
| 492 | |||
| 493 | **Why markdown is preferred:** | ||
| 494 | - Renders nicely on GitHub/GitLab | ||
| 495 | - Supports code blocks with syntax highlighting | ||
| 496 | - Easy to link between documents | ||
| 497 | - Better for long-form content | ||
| 498 | - Version control friendly | ||
| 499 | |||
| 500 | --- | ||
| 501 | |||
| 502 | ## π Writing Guidelines | ||
| 503 | |||
| 504 | ### Markdown Style | ||
| 505 | |||
| 506 | ```markdown | ||
| 507 | # Title (H1 - only one per file) | ||
| 508 | |||
| 509 | **Date:** YYYY-MM-DD | ||
| 510 | **Status:** [WIP|COMPLETE|ARCHIVED] | ||
| 511 | |||
| 512 | ## Section (H2) | ||
| 513 | |||
| 514 | ### Subsection (H3) | ||
| 515 | |||
| 516 | **Bold** for emphasis, `code` for commands/code. | ||
| 517 | |||
| 518 | - Bullet lists for items | ||
| 519 | - Keep consistent style | ||
| 520 | |||
| 521 | 1. Numbered lists for sequences | ||
| 522 | 2. Use when order matters | ||
| 523 | |||
| 524 | β Use emoji for status (sparingly) | ||
| 525 | β Don't overuse emoji | ||
| 526 | 73 | ||
| 527 | \`\`\`bash | 74 | // β CORRECT (0.43) |
| 528 | # Code blocks with language | 75 | Tag::custom(TagKind::custom("clone"), vec![...]) |
| 529 | cargo build | ||
| 530 | \`\`\` | ||
| 531 | ``` | 76 | ``` |
| 532 | 77 | ||
| 533 | ### Status Markers | 78 | **EventBuilder signature changed:** |
| 534 | 79 | ```rust | |
| 535 | - `[WIP]` - Work in progress | 80 | // β WRONG (0.35) |
| 536 | - `[COMPLETE]` - Finished, may be archived | 81 | EventBuilder::new(kind, content, &[tags]) |
| 537 | - `[ARCHIVED]` - Moved to archive, historical only | ||
| 538 | - `β ` - Success/complete | ||
| 539 | - `β` - Failure/incorrect | ||
| 540 | - `β³` - In progress | ||
| 541 | - `π` - Planned/next | ||
| 542 | |||
| 543 | ### Document Headers | ||
| 544 | |||
| 545 | ```markdown | ||
| 546 | # Document Title | ||
| 547 | |||
| 548 | **Purpose:** One-line purpose | ||
| 549 | **Date:** YYYY-MM-DD | ||
| 550 | **Status:** [WIP|COMPLETE|ARCHIVED] | ||
| 551 | **Related:** Links to related docs | ||
| 552 | |||
| 553 | --- | ||
| 554 | 82 | ||
| 555 | ## Content starts here | 83 | // β CORRECT (0.43) |
| 84 | EventBuilder::new(kind, content).tags(tags) | ||
| 556 | ``` | 85 | ``` |
| 557 | 86 | ||
| 558 | --- | 87 | See `docs/archive/2025-11-04-nostr-sdk-upgrade.md` for full migration. |
| 559 | |||
| 560 | ## π€ AI Agent Responsibilities | ||
| 561 | |||
| 562 | ### Before Creating New Documents | ||
| 563 | |||
| 564 | 1. **Check if document already exists** | ||
| 565 | ```bash | ||
| 566 | find . -name "*keyword*.md" | ||
| 567 | ``` | ||
| 568 | |||
| 569 | 2. **Check if information can be added to existing doc** | ||
| 570 | - Prefer updating over creating | ||
| 571 | - Use sections/subsections | ||
| 572 | |||
| 573 | 3. **Determine correct location** | ||
| 574 | - Session-specific? β `work/` (temporary, gitignored) | ||
| 575 | - Teaching beginners? β `docs/tutorials/` | ||
| 576 | - Solving a problem? β `docs/how-to/` | ||
| 577 | - Technical reference? β `docs/reference/` | ||
| 578 | - Explaining concepts? β `docs/explanation/` | ||
| 579 | - Historical? β `docs/archive/` | ||
| 580 | |||
| 581 | 4. **Ask the DiΓ‘taxis questions:** | ||
| 582 | - "Can you teach me to...?" β Tutorial | ||
| 583 | - "How do I...?" β How-To | ||
| 584 | - "What is...?" β Reference | ||
| 585 | - "Why...?" β Explanation | ||
| 586 | |||
| 587 | 5. **Use descriptive names** | ||
| 588 | - Working docs: `session-notes.md`, `status.md` (in `work/`) | ||
| 589 | - Archived docs: `YYYY-MM-DD-description.md` (in `docs/archive/`) | ||
| 590 | - Tutorials: `getting-started.md`, `first-audit.md` | ||
| 591 | - How-To: `deploy.md`, `nix-flakes.md` | ||
| 592 | - Reference: `configuration.md`, `api.md` | ||
| 593 | - Explanation: `architecture.md`, `decisions.md` | ||
| 594 | |||
| 595 | 6. **Choose correct file format** | ||
| 596 | - Use `.md` for all documentation (default) | ||
| 597 | - Use `.txt` ONLY for ASCII art visual summaries | ||
| 598 | - Archive `.txt` files immediately after session | ||
| 599 | |||
| 600 | ### During Development | ||
| 601 | |||
| 602 | 1. **Update status markers** | ||
| 603 | - Mark WIP β COMPLETE when done | ||
| 604 | - Update README.md status section | ||
| 605 | |||
| 606 | 2. **Extract learnings as you go** | ||
| 607 | - Add gotchas to docs/learnings/ | ||
| 608 | - Don't wait until cleanup | ||
| 609 | |||
| 610 | 3. **Keep documentation DRY** | ||
| 611 | - Link to existing docs | ||
| 612 | - Don't duplicate information | ||
| 613 | |||
| 614 | ### End of Session | ||
| 615 | |||
| 616 | 1. **Clean up work/ directory (MANDATORY)** | ||
| 617 | - Archive valuable session docs to `docs/archive/YYYY-MM-DD-*.md` | ||
| 618 | - Delete temporary status reports | ||
| 619 | - Extract content to DiΓ‘taxis categories if needed | ||
| 620 | - Verify `work/` is empty (except README.md) | ||
| 621 | |||
| 622 | 2. **Create session summary (if valuable)** | ||
| 623 | - Archive to `docs/archive/YYYY-MM-DD-session-summary.md` | ||
| 624 | - Include: accomplishments, next steps, blockers | ||
| 625 | |||
| 626 | 3. **Update permanent docs** | ||
| 627 | - Sync README.md with reality | ||
| 628 | - Update relevant docs/ files | ||
| 629 | - Commit changes | ||
| 630 | |||
| 631 | 4. **Verify clean state** | ||
| 632 | ```bash | ||
| 633 | ls *.md # Should only show README.md, AGENTS.md | ||
| 634 | ls work/ # Should only show README.md | ||
| 635 | ``` | ||
| 636 | |||
| 637 | ### Cleanup Time (End of Session) | ||
| 638 | |||
| 639 | 1. **Review work/ directory** | ||
| 640 | ```bash | ||
| 641 | ls -la work/ | ||
| 642 | ``` | ||
| 643 | |||
| 644 | 2. **Extract content to appropriate DiΓ‘taxis category:** | ||
| 645 | - Gotchas/solutions β `docs/how-to/` | ||
| 646 | - Technical facts β `docs/reference/` | ||
| 647 | - Concepts/design β `docs/explanation/` | ||
| 648 | - Lessons β `docs/tutorials/` | ||
| 649 | |||
| 650 | 3. **Archive valuable session docs** | ||
| 651 | ```bash | ||
| 652 | mv work/important-notes.md docs/archive/2025-11-04-session-notes.md | ||
| 653 | mv work/visual-summary.txt docs/archive/2025-11-04-visual-summary.txt | ||
| 654 | ``` | ||
| 655 | |||
| 656 | 4. **Delete temporary files** | ||
| 657 | ```bash | ||
| 658 | rm work/status.md | ||
| 659 | rm work/temp-notes.md | ||
| 660 | ``` | ||
| 661 | |||
| 662 | 5. **Verify clean state** | ||
| 663 | ```bash | ||
| 664 | ls *.md # Only README.md, AGENTS.md | ||
| 665 | ls work/ # Only README.md | ||
| 666 | ``` | ||
| 667 | |||
| 668 | 6. **Commit permanent changes** | ||
| 669 | - Commit new/updated permanent docs | ||
| 670 | - Commit archived docs | ||
| 671 | - Note: work/ not committed (gitignored) | ||
| 672 | |||
| 673 | --- | ||
| 674 | |||
| 675 | ## π― Quality Checklist | ||
| 676 | |||
| 677 | ### For Every Document | ||
| 678 | |||
| 679 | - [ ] Clear purpose stated at top | ||
| 680 | - [ ] Date included | ||
| 681 | - [ ] Status marker present | ||
| 682 | - [ ] Proper heading hierarchy (H1 β H2 β H3) | ||
| 683 | - [ ] Code blocks have language specified | ||
| 684 | - [ ] Links are valid and relative | ||
| 685 | - [ ] No duplicate information | ||
| 686 | - [ ] Spell-checked and readable | ||
| 687 | |||
| 688 | ### For Working Documents | ||
| 689 | |||
| 690 | - [ ] Descriptive filename with date | ||
| 691 | - [ ] Will be archived or deleted when done | ||
| 692 | - [ ] Not duplicating permanent docs | ||
| 693 | - [ ] Learnings extracted to docs/learnings/ | ||
| 694 | |||
| 695 | ### For Permanent Documents | ||
| 696 | |||
| 697 | - [ ] In correct docs/ subdirectory | ||
| 698 | - [ ] Linked from docs/README.md | ||
| 699 | - [ ] Updated as project evolves | ||
| 700 | - [ ] No session-specific details | ||
| 701 | - [ ] Serves long-term purpose | ||
| 702 | |||
| 703 | ### For Archived Documents | ||
| 704 | |||
| 705 | - [ ] Moved to docs/archive/ | ||
| 706 | - [ ] Renamed with date prefix | ||
| 707 | - [ ] ARCHIVED marker at top (for .md files) | ||
| 708 | - [ ] Learnings extracted first (for .md files) | ||
| 709 | - [ ] Not referenced in active docs | ||
| 710 | |||
| 711 | ### For .txt Files | ||
| 712 | 88 | ||
| 713 | - [ ] Contains only ASCII art/visual summaries | 89 | ## Documentation |
| 714 | - [ ] Created in root for session use | ||
| 715 | - [ ] Archived immediately after session | ||
| 716 | - [ ] Not used for regular documentation | ||
| 717 | - [ ] Descriptive filename with purpose clear | ||
| 718 | |||
| 719 | --- | ||
| 720 | 90 | ||
| 721 | ## π Reference Documents | 91 | **DiΓ‘taxis Framework Used:** |
| 722 | 92 | - `docs/tutorials/` - Learning-oriented | |
| 723 | ### Must Read | 93 | - `docs/how-to/` - Task-oriented |
| 724 | - **This file (AGENTS.md)** - Guidelines for documentation | 94 | - `docs/reference/` - Information-oriented |
| 725 | - **README.md** - Project overview | 95 | - `docs/explanation/` - Understanding-oriented |
| 726 | - **docs/README.md** - Documentation navigation | ||
| 727 | |||
| 728 | ### Key Technical Docs | ||
| 729 | - **docs/ARCHITECTURE.md** - System design | ||
| 730 | - **docs/TEST_STRATEGY.md** - Testing approach | ||
| 731 | - **docs/GETTING_STARTED.md** - Setup guide | ||
| 732 | 96 | ||
| 733 | ### Learnings (Gotchas) | 97 | **Session files go in `work/` (gitignored except README.md)** |
| 734 | - **docs/learnings/nix-flakes.md** - Nix flake patterns | 98 | - Archive valuable content to `docs/archive/YYYY-MM-DD-*.md` at session end |
| 735 | - **docs/learnings/nostr-sdk.md** - nostr-sdk notes | 99 | - Delete temporary files |
| 736 | - **docs/learnings/git-http-backend.md** - Git protocol tips | 100 | - Keep root clean (only README.md, AGENTS.md) |
| 737 | 101 | ||
| 738 | --- | 102 | ## Critical Gotchas |
| 739 | |||
| 740 | ## π Quick Links | ||
| 741 | 103 | ||
| 742 | - [Project README](README.md) | 104 | 1. **Workspace compilation:** Can't `cargo build` from root for grasp-audit |
| 743 | - [Documentation Index](docs/README.md) | 105 | 2. **Nix environment:** Must use `nix develop`, not `nix-shell` |
| 744 | - [Architecture](docs/ARCHITECTURE.md) | 106 | 3. **nostr-sdk API:** Fields not methods in 0.43 |
| 745 | - [Learnings](docs/learnings/) | 107 | 4. **Test isolation:** Integration tests need relay, marked with `#[ignore]` |
| 746 | - [Archive](docs/archive/) | 108 | 5. **Work directory:** All session docs go in `work/`, NOT root |
| 109 | 6. **Archive naming:** Use `YYYY-MM-DD-description.md` format | ||
| 747 | 110 | ||
| 748 | --- | 111 | ## File Restrictions by Mode |
| 749 | 112 | ||
| 750 | ## π‘ Tips for Success | 113 | Code mode can only edit files matching specific patterns (enforced by system): |
| 114 | - Example: Architect mode restricted to `\.md$` files only | ||
| 115 | - Attempting to edit restricted files causes FileRestrictionError | ||
| 116 | - Check mode configuration if edit attempts fail unexpectedly | ||
| 751 | 117 | ||
| 752 | 1. **Less is more** - Prefer updating over creating | 118 | ## Quick Reference |
| 753 | 2. **Archive often** - Keep root clean | ||
| 754 | 3. **Extract learnings** - Make knowledge reusable | ||
| 755 | 4. **Link, don't duplicate** - DRY applies to docs too | ||
| 756 | 5. **Date everything** - Context is important | ||
| 757 | 6. **Use descriptive names** - Future you will thank you | ||
| 758 | 7. **Check before creating** - Document might already exist | ||
| 759 | 8. **Update as you go** - Don't wait for cleanup time | ||
| 760 | 9. **Use .md by default** - Only use .txt for ASCII art | ||
| 761 | 10. **Archive .txt immediately** - Don't let them linger | ||
| 762 | 119 | ||
| 763 | --- | 120 | ```bash |
| 764 | 121 | # Build grasp-audit | |
| 765 | ## π Next Steps | 122 | cd grasp-audit && nix develop -c cargo build |
| 766 | |||
| 767 | After reading this: | ||
| 768 | |||
| 769 | 1. **Review current documentation structure** | ||
| 770 | ```bash | ||
| 771 | ls -la *.md | ||
| 772 | ls -la docs/ | ||
| 773 | ``` | ||
| 774 | |||
| 775 | 2. **Identify cleanup candidates** | ||
| 776 | - Completed working docs | ||
| 777 | - Obsolete duplicates | ||
| 778 | - Session summaries | ||
| 779 | |||
| 780 | 3. **Extract learnings** | ||
| 781 | - Review completed docs | ||
| 782 | - Add to docs/learnings/ | ||
| 783 | |||
| 784 | 4. **Archive and clean** | ||
| 785 | - Move to docs/archive/ | ||
| 786 | - Delete obsolete files | ||
| 787 | - Update links | ||
| 788 | |||
| 789 | 5. **Commit changes** | ||
| 790 | ```bash | ||
| 791 | git add . | ||
| 792 | git commit -m "docs: cleanup and reorganization" | ||
| 793 | ``` | ||
| 794 | |||
| 795 | --- | ||
| 796 | 123 | ||
| 797 | **Remember:** Good documentation structure is like good code structure - it makes everything easier. | 124 | # Run all tests (requires relay on 18081) |
| 125 | cd grasp-audit && nix develop -c cargo test --ignored | ||
| 798 | 126 | ||
| 799 | --- | 127 | # Run single test |
| 128 | cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture | ||
| 800 | 129 | ||
| 801 | *Last updated: November 4, 2025* | 130 | # Check session files |
| 802 | *Status: β Active guidelines* | 131 | ls work/ # Should only have README.md when clean \ No newline at end of file |