upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/AGENTS.md
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-04 09:31:57 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-04 09:31:57 +0000
commit22557f15d6a7b77f72d4597fc05aa06346495a33 (patch)
treee31e0cdecfc4cb1e28246227a7ef295b71687b09 /AGENTS.md
parentb3031800cd95601c2d9cd2d24034364d1496b073 (diff)
docs: major cleanup and reorganization
- Archive 30 completed session documents to docs/archive/ - Extract learnings to docs/learnings/ (nix-flakes, nostr-sdk, grasp-audit) - Create CURRENT_STATUS.md as single source of truth - Create AGENTS.md with documentation guidelines - Create docs/archive/README.md for archive organization - Clean root directory: 32 files → 4 files Root directory now contains only: - README.md (project overview) - AGENTS.md (documentation guidelines) - CURRENT_STATUS.md (current state) - CLEANUP_SUMMARY.md (cleanup report) All historical documents preserved in docs/archive/ with proper dating. All reusable knowledge extracted to docs/learnings/. Benefits: - Easy to find current information - Clear document lifecycle - No more documentation sprawl - Learnings are accessible and reusable - Better onboarding for new developers/agents File counts: - Root: 4 (was 32) - Permanent docs: 7 - Learnings: 3 (new) - Archive: 32 (new) - Total: 49 well-organized docs
Diffstat (limited to 'AGENTS.md')
-rw-r--r--AGENTS.md560
1 files changed, 560 insertions, 0 deletions
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..c063f68
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,560 @@
1# AI Agent Guidelines for ngit-grasp
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
13We maintain a **clean, hierarchical documentation structure** to avoid documentation sprawl. All working documents have a defined lifecycle and location.
14
15```
16ngit-grasp/
17├── README.md # Project overview (keep updated)
18├── AGENTS.md # This file - agent guidelines
19├── CHANGELOG.md # User-facing changes (semver)
20
21├── docs/ # Permanent technical documentation
22│ ├── README.md # Docs navigation guide
23│ ├── ARCHITECTURE.md # System architecture
24│ ├── TEST_STRATEGY.md # Testing approach
25│ ├── GIT_PROTOCOL.md # Git protocol reference
26│ ├── COMPARISON.md # vs other implementations
27│ ├── GETTING_STARTED.md # Setup guide
28│ └── DECISION_SUMMARY.md # Key architectural decisions
29
30├── docs/archive/ # Completed session/phase docs
31│ ├── 2025-11-04-tag-migration.md
32│ ├── 2025-11-04-flake-migration.md
33│ └── 2025-11-03-architecture-investigation.md
34
35├── docs/learnings/ # Extracted knowledge (permanent)
36│ ├── nix-flakes.md # Flake gotchas and patterns
37│ ├── nostr-sdk.md # nostr-sdk patterns and upgrades
38│ └── git-http-backend.md # Git protocol learnings
39
40├── grasp-audit/ # Audit tool subproject
41│ ├── README.md # Main audit docs
42│ ├── QUICK_START.md # Getting started
43│ └── docs/
44│ └── archive/ # Audit-specific archives
45
46└── .ai/ # AI assistant context (ignored in git)
47 └── history/ # Conversation history
48```
49
50---
51
52## 📋 Document Lifecycle
53
54### 1. Working Documents (Root Level)
55
56**Purpose:** Active development, session notes, status reports
57**Location:** Project root
58**Lifecycle:** Created → Updated → Archived
59**Retention:** Archive after completion, delete if obsolete
60
61**Examples:**
62- `TAG_MIGRATION_COMPLETE.md` → Archive when next phase starts
63- `SESSION_2025_11_04_SUMMARY.md` → Archive at session end
64- `NEXT_STEPS.md` → Update continuously, archive when complete
65
66**Rules:**
67- ✅ Use descriptive names with dates: `YYYY-MM-DD-description.md`
68- ✅ Mark status clearly: `[WIP]`, `[COMPLETE]`, `[ARCHIVED]`
69- ✅ Include date and context at top
70- ❌ Don't let root accumulate more than 5-10 working docs
71- ❌ Don't create duplicates (merge or link instead)
72
73### 2. Permanent Documentation (docs/)
74
75**Purpose:** Long-term reference, architecture, guides
76**Location:** `docs/`
77**Lifecycle:** Created → Maintained → Updated
78**Retention:** Permanent (version controlled)
79
80**Examples:**
81- `docs/ARCHITECTURE.md` - System design
82- `docs/TEST_STRATEGY.md` - Testing approach
83- `docs/learnings/nix-flakes.md` - Extracted knowledge
84
85**Rules:**
86- ✅ Keep updated as project evolves
87- ✅ Use clear structure and headings
88- ✅ Link between related docs
89- ❌ Don't duplicate information (use links)
90- ❌ Don't include session-specific details
91
92### 3. Archive (docs/archive/)
93
94**Purpose:** Historical record, completed phases
95**Location:** `docs/archive/`
96**Lifecycle:** Moved from root → Archived
97**Retention:** Permanent (for reference)
98
99**Examples:**
100- `docs/archive/2025-11-04-tag-migration.md`
101- `docs/archive/2025-11-03-architecture-investigation.md`
102
103**Rules:**
104- ✅ Rename with date prefix when archiving
105- ✅ Add "ARCHIVED" marker at top
106- ✅ Extract learnings to docs/learnings/ first
107- ❌ Don't modify after archiving
108- ❌ Don't reference in active documentation
109
110### 4. Learnings (docs/learnings/)
111
112**Purpose:** Reusable knowledge, gotchas, patterns
113**Location:** `docs/learnings/`
114**Lifecycle:** Extracted → Maintained → Updated
115**Retention:** Permanent (living documents)
116
117**Examples:**
118- `docs/learnings/nix-flakes.md` - Flake patterns and gotchas
119- `docs/learnings/nostr-sdk.md` - SDK upgrade notes
120- `docs/learnings/git-http-backend.md` - Git protocol tips
121
122**Rules:**
123- ✅ Extract from session docs before archiving
124- ✅ Organize by topic, not by session
125- ✅ Include code examples
126- ✅ Update as we learn more
127- ❌ Don't duplicate official docs (link instead)
128
129---
130
131## 🔄 Cleanup Process
132
133### When to Clean Up
134
135**Trigger:** Root directory has >10 markdown files
136**Frequency:** End of each major phase or weekly
137**Responsibility:** AI agents should proactively suggest cleanup
138
139### Cleanup Steps
140
1411. **Identify Completed Documents**
142 ```bash
143 # Find old working docs
144 ls -lt *.md | head -20
145 ```
146
1472. **Extract Learnings**
148 - Review each completed doc
149 - Extract gotchas, patterns, solutions
150 - Add to appropriate `docs/learnings/*.md`
151
1523. **Archive Completed Work**
153 ```bash
154 # Move to archive with date prefix
155 mv TAG_MIGRATION_COMPLETE.md docs/archive/2025-11-04-tag-migration.md
156 ```
157
1584. **Delete Obsolete Documents**
159 - Duplicates (keep most recent/complete)
160 - Superseded documents
161 - Pure status reports (no learnings)
162
1635. **Update References**
164 - Update links in active docs
165 - Update README.md if needed
166 - Commit changes
167
168### Example Cleanup
169
170```bash
171# Before cleanup (36 files in root!)
172ls *.md | wc -l
173# 36
174
175# After cleanup (5-8 files in root)
176ls *.md
177# README.md
178# AGENTS.md
179# CHANGELOG.md
180# CURRENT_STATUS.md
181# NEXT_STEPS.md
182
183# Archived
184ls docs/archive/
185# 2025-11-04-tag-migration.md
186# 2025-11-04-flake-migration.md
187# 2025-11-03-architecture-investigation.md
188# ...
189
190# Learnings extracted
191ls docs/learnings/
192# nix-flakes.md
193# nostr-sdk.md
194# git-http-backend.md
195```
196
197---
198
199## 🚨 Common Gotchas
200
201### Nix Flakes
202
203**Always use `nix develop`, not `nix-shell`**
204
205```bash
206# ✅ Correct
207cd grasp-audit
208nix develop
209nix develop -c cargo build
210
211# ❌ Wrong
212nix-shell
213nix-shell --run "cargo build"
214```
215
216**Why:** We use `flake.nix`, not `shell.nix`. See `docs/learnings/nix-flakes.md`.
217
218**Flake Commands:**
219```bash
220# Show flake outputs
221nix flake show
222
223# Update flake inputs
224nix flake update
225
226# Build package
227nix build
228
229# Run package
230nix run
231```
232
233### Git Subprojects
234
235**grasp-audit is a subproject with its own flake**
236
237```bash
238# ✅ Correct - enter grasp-audit environment
239cd grasp-audit
240nix develop
241cargo build
242
243# ❌ Wrong - can't build from root
244cd ngit-grasp
245cargo build # This won't find grasp-audit
246```
247
248**Why:** `grasp-audit/` has its own `Cargo.toml` and `flake.nix`.
249
250### nostr-sdk Versions
251
252**We use nostr-sdk 0.43.x (latest stable)**
253
254```toml
255# ✅ Correct
256[dependencies]
257nostr-sdk = "0.43"
258
259# ❌ Wrong
260nostr-sdk = "0.35" # Old version, breaking changes
261```
262
263**Why:** We upgraded from 0.35 to 0.43. See `docs/learnings/nostr-sdk.md` for migration notes.
264
265**Common Breaking Changes:**
266- `EventBuilder::new()` signature changed
267- Tag API changed to `Tag::custom()`
268- Filter API changed
269- See archived upgrade docs for details
270
271### Testing Patterns
272
273**Integration tests require relay**
274
275```bash
276# ✅ Correct - start relay first
277docker run --rm -p 7000:7000 scsibug/nostr-rs-relay
278
279# Then run tests
280cd grasp-audit
281nix develop -c cargo test --ignored
282
283# ❌ Wrong - integration tests will fail
284cargo test --ignored # No relay running
285```
286
287**Test Organization:**
288```rust
289// Unit tests (no relay needed)
290#[cfg(test)]
291mod tests {
292 #[test]
293 fn test_something() { }
294}
295
296// Integration tests (relay required)
297#[cfg(test)]
298mod tests {
299 #[test]
300 #[ignore] // Requires relay
301 fn test_against_relay() { }
302}
303```
304
305### Documentation Updates
306
307**Keep README.md synchronized**
308
309When you:
310- Complete a major feature → Update README.md status
311- Change architecture → Update docs/ARCHITECTURE.md
312- Add dependencies → Update README.md tech stack
313- Change workflow → Update docs/GETTING_STARTED.md
314
315**Don't:**
316- Create duplicate documentation
317- Leave stale status markers
318- Forget to update CHANGELOG.md for user-facing changes
319
320---
321
322## 📝 Writing Guidelines
323
324### Markdown Style
325
326```markdown
327# Title (H1 - only one per file)
328
329**Date:** YYYY-MM-DD
330**Status:** [WIP|COMPLETE|ARCHIVED]
331
332## Section (H2)
333
334### Subsection (H3)
335
336**Bold** for emphasis, `code` for commands/code.
337
338- Bullet lists for items
339- Keep consistent style
340
3411. Numbered lists for sequences
3422. Use when order matters
343
344✅ Use emoji for status (sparingly)
345❌ Don't overuse emoji
346
347\`\`\`bash
348# Code blocks with language
349cargo build
350\`\`\`
351```
352
353### Status Markers
354
355- `[WIP]` - Work in progress
356- `[COMPLETE]` - Finished, may be archived
357- `[ARCHIVED]` - Moved to archive, historical only
358- `✅` - Success/complete
359- `❌` - Failure/incorrect
360- `⏳` - In progress
361- `🔜` - Planned/next
362
363### Document Headers
364
365```markdown
366# Document Title
367
368**Purpose:** One-line purpose
369**Date:** YYYY-MM-DD
370**Status:** [WIP|COMPLETE|ARCHIVED]
371**Related:** Links to related docs
372
373---
374
375## Content starts here
376```
377
378---
379
380## 🤖 AI Agent Responsibilities
381
382### Before Creating New Documents
383
3841. **Check if document already exists**
385 ```bash
386 find . -name "*keyword*.md"
387 ```
388
3892. **Check if information can be added to existing doc**
390 - Prefer updating over creating
391 - Use sections/subsections
392
3933. **Determine correct location**
394 - Working doc → Root
395 - Permanent → docs/
396 - Learning → docs/learnings/
397 - Historical → docs/archive/
398
3994. **Use descriptive names with dates**
400 - `YYYY-MM-DD-description.md` for working docs
401 - `topic-name.md` for permanent docs
402
403### During Development
404
4051. **Update status markers**
406 - Mark WIP → COMPLETE when done
407 - Update README.md status section
408
4092. **Extract learnings as you go**
410 - Add gotchas to docs/learnings/
411 - Don't wait until cleanup
412
4133. **Keep documentation DRY**
414 - Link to existing docs
415 - Don't duplicate information
416
417### End of Session
418
4191. **Suggest cleanup if needed**
420 - Count root .md files
421 - Suggest archiving completed docs
422
4232. **Create session summary**
424 - What was accomplished
425 - What's next
426 - Any blockers
427
4283. **Update permanent docs**
429 - Sync README.md with reality
430 - Update relevant docs/ files
431
432### Cleanup Time
433
4341. **Review all root .md files**
4352. **Extract learnings to docs/learnings/**
4363. **Archive completed work to docs/archive/**
4374. **Delete obsolete duplicates**
4385. **Update links in active docs**
4396. **Commit with clear message**
440
441---
442
443## 🎯 Quality Checklist
444
445### For Every Document
446
447- [ ] Clear purpose stated at top
448- [ ] Date included
449- [ ] Status marker present
450- [ ] Proper heading hierarchy (H1 → H2 → H3)
451- [ ] Code blocks have language specified
452- [ ] Links are valid and relative
453- [ ] No duplicate information
454- [ ] Spell-checked and readable
455
456### For Working Documents
457
458- [ ] Descriptive filename with date
459- [ ] Will be archived or deleted when done
460- [ ] Not duplicating permanent docs
461- [ ] Learnings extracted to docs/learnings/
462
463### For Permanent Documents
464
465- [ ] In correct docs/ subdirectory
466- [ ] Linked from docs/README.md
467- [ ] Updated as project evolves
468- [ ] No session-specific details
469- [ ] Serves long-term purpose
470
471### For Archived Documents
472
473- [ ] Moved to docs/archive/
474- [ ] Renamed with date prefix
475- [ ] ARCHIVED marker at top
476- [ ] Learnings extracted first
477- [ ] Not referenced in active docs
478
479---
480
481## 📚 Reference Documents
482
483### Must Read
484- **This file (AGENTS.md)** - Guidelines for documentation
485- **README.md** - Project overview
486- **docs/README.md** - Documentation navigation
487
488### Key Technical Docs
489- **docs/ARCHITECTURE.md** - System design
490- **docs/TEST_STRATEGY.md** - Testing approach
491- **docs/GETTING_STARTED.md** - Setup guide
492
493### Learnings (Gotchas)
494- **docs/learnings/nix-flakes.md** - Nix flake patterns
495- **docs/learnings/nostr-sdk.md** - nostr-sdk notes
496- **docs/learnings/git-http-backend.md** - Git protocol tips
497
498---
499
500## 🔗 Quick Links
501
502- [Project README](README.md)
503- [Documentation Index](docs/README.md)
504- [Architecture](docs/ARCHITECTURE.md)
505- [Learnings](docs/learnings/)
506- [Archive](docs/archive/)
507
508---
509
510## 💡 Tips for Success
511
5121. **Less is more** - Prefer updating over creating
5132. **Archive often** - Keep root clean
5143. **Extract learnings** - Make knowledge reusable
5154. **Link, don't duplicate** - DRY applies to docs too
5165. **Date everything** - Context is important
5176. **Use descriptive names** - Future you will thank you
5187. **Check before creating** - Document might already exist
5198. **Update as you go** - Don't wait for cleanup time
520
521---
522
523## 🚀 Next Steps
524
525After reading this:
526
5271. **Review current documentation structure**
528 ```bash
529 ls -la *.md
530 ls -la docs/
531 ```
532
5332. **Identify cleanup candidates**
534 - Completed working docs
535 - Obsolete duplicates
536 - Session summaries
537
5383. **Extract learnings**
539 - Review completed docs
540 - Add to docs/learnings/
541
5424. **Archive and clean**
543 - Move to docs/archive/
544 - Delete obsolete files
545 - Update links
546
5475. **Commit changes**
548 ```bash
549 git add .
550 git commit -m "docs: cleanup and reorganization"
551 ```
552
553---
554
555**Remember:** Good documentation structure is like good code structure - it makes everything easier.
556
557---
558
559*Last updated: November 4, 2025*
560*Status: ✅ Active guidelines*