| … | … | @@ -0,0 +1,561 @@ |
| 1 | # Building P2P Apps with AI: Workflow Guide | |
| 2 | ||
| 3 | **Last Updated**: 2026-01-16 | |
| 4 | ||
| 5 | This guide shows how human developers can collaborate with AI assistants (like Claude) to build peer-to-peer applications using the holepunchto ecosystem. | |
| 6 | ||
| 7 | --- | |
| 8 | ||
| 9 | ## Overview: The Human + AI Workflow | |
| 10 | ||
| 11 | ``` | |
| 12 | ┌─────────────────────────────────────────────────────────┐ | |
| 13 | │ 1. HUMAN: Describes what they want to build │ | |
| 14 | │ ↓ │ | |
| 15 | │ 2. DESIGNER AGENT: Recommends repos & architecture │ | |
| 16 | │ ↓ │ | |
| 17 | │ 3. ARCHITECT AGENT: Designs system architecture │ | |
| 18 | │ ↓ │ | |
| 19 | │ 4. AI ASSISTANT: Implements actual code │ | |
| 20 | │ ↓ │ | |
| 21 | │ 5. HUMAN + AI: Iterate, debug, and enhance │ | |
| 22 | └─────────────────────────────────────────────────────────┘ | |
| 23 | ``` | |
| 24 | ||
| 25 | --- | |
| 26 | ||
| 27 | ## Step 1: Discovery - What Do You Want to Build? | |
| 28 | ||
| 29 | ### Human Provides Requirements | |
| 30 | ||
| 31 | Start by describing your P2P application idea in natural language: | |
| 32 | ||
| 33 | **Examples:** | |
| 34 | - "I want to build a distributed database for storing sensor data" | |
| 35 | - "I need a P2P file sharing app for my team" | |
| 36 | - "I want to create a real-time chat application" | |
| 37 | - "I need a distributed append-only log for event sourcing" | |
| 38 | ||
| 39 | ### Use Designer Agent | |
| 40 | ||
| 41 | Run the designer agent with your description: | |
| 42 | ||
| 43 | ```bash | |
| 44 | node designer-agent.js "I want to build a distributed database" | |
| 45 | ``` | |
| 46 | ||
| 47 | **Output:** | |
| 48 | - Use case match (e.g., "distributed-database") | |
| 49 | - Required repositories (e.g., hypercore, hyperbee) | |
| 50 | - Optional repositories (e.g., autobase, corestore) | |
| 51 | - Stability, platform, and pattern information | |
| 52 | ||
| 53 | ### Share Results with AI | |
| 54 | ||
| 55 | Copy the designer agent output and share with your AI assistant: | |
| 56 | ||
| 57 | ``` | |
| 58 | I want to build a distributed database. The designer agent recommended: | |
| 59 | ||
| 60 | Required: hypercore, hyperbee | |
| 61 | Optional: autobase, corestore, hypercore-crypto | |
| 62 | Use case: distributed-database | |
| 63 | Patterns: append-only-log, b-tree-index, replication | |
| 64 | ``` | |
| 65 | ||
| 66 | --- | |
| 67 | ||
| 68 | ## Step 2: Architecture - Design Your System | |
| 69 | ||
| 70 | ### Use Architect Agent | |
| 71 | ||
| 72 | Run the architect agent with recommended repos: | |
| 73 | ||
| 74 | ```bash | |
| 75 | node architect-agent.js hypercore hyperbee autobase | |
| 76 | ``` | |
| 77 | ||
| 78 | **Output:** | |
| 79 | - Architectural layers (Foundation, Core, Integration, Application) | |
| 80 | - P2P patterns in use | |
| 81 | - Dependency graph | |
| 82 | - Integration points | |
| 83 | - Recommendations for missing dependencies | |
| 84 | ||
| 85 | ### AI Analysis | |
| 86 | ||
| 87 | Share architect output with AI and ask: | |
| 88 | ||
| 89 | ``` | |
| 90 | Here's the architecture analysis for my distributed database. | |
| 91 | Based on this, can you: | |
| 92 | 1. Explain how these repos work together | |
| 93 | 2. Identify any missing pieces I need | |
| 94 | 3. Suggest a good starting point for implementation | |
| 95 | ``` | |
| 96 | ||
| 97 | The AI can: | |
| 98 | - Explain the architectural layers | |
| 99 | - Clarify how repos integrate | |
| 100 | - Recommend implementation order | |
| 101 | - Suggest additional utilities from the dependency warnings | |
| 102 | ||
| 103 | --- | |
| 104 | ||
| 105 | ## Step 3: Deep Dive - Understanding the APIs | |
| 106 | ||
| 107 | ### Point AI to Skills Documentation | |
| 108 | ||
| 109 | The AI can read the detailed API documentation: | |
| 110 | ||
| 111 | ``` | |
| 112 | Can you read skills/hypercore/skills.md and explain: | |
| 113 | - How do I create a new hypercore? | |
| 114 | - How do I append data? | |
| 115 | - How do I replicate between peers? | |
| 116 | ``` | |
| 117 | ||
| 118 | ### Review API Extracts | |
| 119 | ||
| 120 | For deeply analyzed repos (133 total), point AI to api-extract.json: | |
| 121 | ||
| 122 | ``` | |
| 123 | Read skills/hypercore/api-extract.json and show me: | |
| 124 | - All exported classes | |
| 125 | - Key methods for appending and reading data | |
| 126 | - Code examples from the README | |
| 127 | ``` | |
| 128 | ||
| 129 | --- | |
| 130 | ||
| 131 | ## Step 4: Implementation - AI Writes Code | |
| 132 | ||
| 133 | ### Start Simple - Basic Setup | |
| 134 | ||
| 135 | Ask AI to create initial setup: | |
| 136 | ||
| 137 | ``` | |
| 138 | Using hypercore and hyperbee, create a basic Node.js app that: | |
| 139 | 1. Initializes a hypercore storage | |
| 140 | 2. Creates a hyperbee database | |
| 141 | 3. Writes a few key-value pairs | |
| 142 | 4. Reads them back | |
| 143 | ||
| 144 | Use the API information from skills/hypercore/skills.md | |
| 145 | and skills/hyperbee/skills.md | |
| 146 | ``` | |
| 147 | ||
| 148 | AI generates initial code based on documented APIs. | |
| 149 | ||
| 150 | ### Iterate - Add Features | |
| 151 | ||
| 152 | Build features incrementally: | |
| 153 | ||
| 154 | ``` | |
| 155 | Now add: | |
| 156 | - P2P replication using hyperswarm | |
| 157 | - Ability to sync database between two peers | |
| 158 | - Connection event logging | |
| 159 | ||
| 160 | Check skills/hyperswarm/skills.md for the API | |
| 161 | ``` | |
| 162 | ||
| 163 | ### Debug with Context | |
| 164 | ||
| 165 | When issues arise: | |
| 166 | ||
| 167 | ``` | |
| 168 | I'm getting this error: [paste error] | |
| 169 | ||
| 170 | My code: [paste code] | |
| 171 | ||
| 172 | Can you check: | |
| 173 | 1. If I'm using the hypercore API correctly (skills/hypercore/skills.md) | |
| 174 | 2. Common patterns from the dependency graph | |
| 175 | 3. If I'm missing required dependencies | |
| 176 | ``` | |
| 177 | ||
| 178 | AI can cross-reference: | |
| 179 | - API documentation in skills/*.md | |
| 180 | - Dependency requirements from dependency-graph.json | |
| 181 | - Common patterns from pattern-map.json | |
| 182 | ||
| 183 | --- | |
| 184 | ||
| 185 | ## Step 5: Enhancement - Add Advanced Features | |
| 186 | ||
| 187 | ### Multi-Writer Support | |
| 188 | ||
| 189 | ``` | |
| 190 | I want to add multi-writer support to my database. | |
| 191 | The architect agent suggested 'autobase' for this. | |
| 192 | ||
| 193 | Can you: | |
| 194 | 1. Read skills/autobase/skills.md | |
| 195 | 2. Show me how to integrate autobase with my existing hypercore/hyperbee setup | |
| 196 | 3. Implement a simple multi-writer example | |
| 197 | ``` | |
| 198 | ||
| 199 | ### Platform Portability | |
| 200 | ||
| 201 | Check platform support: | |
| 202 | ||
| 203 | ``` | |
| 204 | I want to run this in the browser. | |
| 205 | Can you check platform-support.json to see: | |
| 206 | - Which of my dependencies support browsers? | |
| 207 | - What alternatives exist for ones that don't? | |
| 208 | - How to adapt my code for browser use? | |
| 209 | ``` | |
| 210 | ||
| 211 | --- | |
| 212 | ||
| 213 | ## Complete Example Workflow | |
| 214 | ||
| 215 | ### Scenario: Building a P2P Chat App | |
| 216 | ||
| 217 | #### 1. Discovery Phase | |
| 218 | ||
| 219 | ```bash | |
| 220 | # Human runs: | |
| 221 | node designer-agent.js "real-time P2P chat application" | |
| 222 | ||
| 223 | # Designer recommends: | |
| 224 | # Required: hyperswarm, hyperswarm-secret-stream | |
| 225 | # Optional: protomux, compact-encoding | |
| 226 | # Use case: real-time-messaging | |
| 227 | # Patterns: peer-discovery, streaming, cryptography | |
| 228 | ``` | |
| 229 | ||
| 230 | #### 2. Architecture Phase | |
| 231 | ||
| 232 | ```bash | |
| 233 | # Human runs: | |
| 234 | node architect-agent.js hyperswarm hyperswarm-secret-stream protomux | |
| 235 | ||
| 236 | # Architect shows: | |
| 237 | # Foundation: hyperswarm | |
| 238 | # Integration: hyperswarm-secret-stream, protomux | |
| 239 | # Patterns: peer-discovery, dht-discovery, streaming | |
| 240 | # Dependencies: Shows how they connect | |
| 241 | ``` | |
| 242 | ||
| 243 | #### 3. AI Consultation | |
| 244 | ||
| 245 | **Human to AI:** | |
| 246 | ``` | |
| 247 | I want to build a P2P chat app. Here's what the agents recommended: | |
| 248 | [paste designer + architect output] | |
| 249 | ||
| 250 | Can you read: | |
| 251 | - skills/hyperswarm/skills.md | |
| 252 | - skills/hyperswarm-secret-stream/skills.md | |
| 253 | - skills/protomux/skills.md | |
| 254 | ||
| 255 | And create a simple chat app with: | |
| 256 | 1. Peer discovery via DHT | |
| 257 | 2. Encrypted connections | |
| 258 | 3. Message broadcasting | |
| 259 | ``` | |
| 260 | ||
| 261 | #### 4. AI Implementation | |
| 262 | ||
| 263 | AI reads the skills.md files and generates: | |
| 264 | ||
| 265 | ```javascript | |
| 266 | // chat-app.js | |
| 267 | const Hyperswarm = require('hyperswarm') | |
| 268 | const SecretStream = require('hyperswarm-secret-stream') | |
| 269 | const crypto = require('crypto') | |
| 270 | ||
| 271 | // [AI generates complete working code based on API docs] | |
| 272 | ``` | |
| 273 | ||
| 274 | #### 5. Iteration | |
| 275 | ||
| 276 | **Human to AI:** | |
| 277 | ``` | |
| 278 | Great! Now let's add: | |
| 279 | - Message history (use hypercore from dependency-graph.json) | |
| 280 | - User nicknames | |
| 281 | - Typing indicators | |
| 282 | ||
| 283 | Also check if there are any missing dependencies the architect warned about. | |
| 284 | ``` | |
| 285 | ||
| 286 | AI iterates on the code, adding features based on: | |
| 287 | - Additional API documentation | |
| 288 | - Dependency recommendations | |
| 289 | - Pattern implementations | |
| 290 | ||
| 291 | --- | |
| 292 | ||
| 293 | ## AI Assistant Capabilities with This Knowledge Base | |
| 294 | ||
| 295 | ### What AI Can Do: | |
| 296 | ||
| 297 | ✅ **Read Documentation** | |
| 298 | - All 529 skills.md files | |
| 299 | - 133 deep api-extract.json files | |
| 300 | - README content and code examples | |
| 301 | ||
| 302 | ✅ **Analyze Architecture** | |
| 303 | - Parse dependency-graph.json to understand relationships | |
| 304 | - Explain pattern-map.json patterns | |
| 305 | - Recommend repos from semantic-categories.json | |
| 306 | ||
| 307 | ✅ **Generate Code** | |
| 308 | - Use documented APIs from skills/*.md | |
| 309 | - Follow patterns from api-extract.json | |
| 310 | - Implement examples from README sections | |
| 311 | ||
| 312 | ✅ **Debug Issues** | |
| 313 | - Cross-reference API usage with documentation | |
| 314 | - Check dependency compatibility | |
| 315 | - Suggest alternatives from use-case-map.json | |
| 316 | ||
| 317 | ✅ **Plan Implementation** | |
| 318 | - Break down features into steps | |
| 319 | - Identify required vs optional dependencies | |
| 320 | - Suggest architectural layers | |
| 321 | ||
| 322 | ### What AI Cannot Do (Human Needed): | |
| 323 | ||
| 324 | ❌ Run the designer/architect agents (human runs these) | |
| 325 | ❌ Test network conditions in real P2P environments | |
| 326 | ❌ Make architectural decisions (AI advises, human decides) | |
| 327 | ❌ Clone git submodules (human does this when needed) | |
| 328 | ||
| 329 | --- | |
| 330 | ||
| 331 | ## Tips for Effective Human + AI Collaboration | |
| 332 | ||
| 333 | ### 1. **Start with Agents, Then AI** | |
| 334 | - Run designer-agent first to get recommendations | |
| 335 | - Run architect-agent to understand system design | |
| 336 | - Then bring AI in for implementation | |
| 337 | ||
| 338 | ### 2. **Point AI to Specific Files** | |
| 339 | - "Read skills/hypercore/skills.md" is better than "tell me about hypercore" | |
| 340 | - AI has access to real, accurate API documentation | |
| 341 | ||
| 342 | ### 3. **Share Context Progressively** | |
| 343 | - Start with designer/architect output | |
| 344 | - Add skills.md as needed | |
| 345 | - Include api-extract.json for deep dives | |
| 346 | - Reference dependency-graph.json for dependencies | |
| 347 | ||
| 348 | ### 4. **Use AI for Code, Agents for Discovery** | |
| 349 | - Designer agent → discovers WHAT to use | |
| 350 | - Architect agent → designs HOW they fit together | |
| 351 | - AI assistant → implements the actual code | |
| 352 | ||
| 353 | ### 5. **Iterate in Small Steps** | |
| 354 | - Get basic version working first | |
| 355 | - Add features incrementally | |
| 356 | - Test each addition before proceeding | |
| 357 | ||
| 358 | ### 6. **Leverage the Full Knowledge Base** | |
| 359 | - 529 repos documented | |
| 360 | - 133 with deep API analysis | |
| 361 | - 11 use cases pre-defined | |
| 362 | - 10 patterns documented | |
| 363 | ||
| 364 | --- | |
| 365 | ||
| 366 | ## Common Workflows | |
| 367 | ||
| 368 | ### Workflow A: "I know what I want to build" | |
| 369 | ||
| 370 | ``` | |
| 371 | 1. Human: node designer-agent.js "my idea" | |
| 372 | 2. Human: Review recommendations, pick repos | |
| 373 | 3. Human: node architect-agent.js repo1 repo2 repo3 | |
| 374 | 4. Human to AI: "Here's the architecture, implement [feature]" | |
| 375 | 5. AI: Generates code using skills/*.md | |
| 376 | 6. Human: Tests, provides feedback | |
| 377 | 7. AI: Iterates based on feedback | |
| 378 | ``` | |
| 379 | ||
| 380 | ### Workflow B: "I have a use case in mind" | |
| 381 | ||
| 382 | ``` | |
| 383 | 1. Human: node designer-agent.js --list-use-cases | |
| 384 | 2. Human: node designer-agent.js --use-case distributed-database | |
| 385 | 3. Human: node architect-agent.js --use-case distributed-database | |
| 386 | 4. Human to AI: "Implement this use case with [specific requirements]" | |
| 387 | 5. AI: Reads relevant skills.md files | |
| 388 | 6. AI: Generates implementation | |
| 389 | 7. Human + AI: Iterate and enhance | |
| 390 | ``` | |
| 391 | ||
| 392 | ### Workflow C: "I want to explore patterns" | |
| 393 | ||
| 394 | ``` | |
| 395 | 1. Human to AI: "Read pattern-map.json and explain the replication pattern" | |
| 396 | 2. AI: Explains pattern, shows which repos implement it | |
| 397 | 3. Human: node architect-agent.js [pattern repos] | |
| 398 | 4. Human to AI: "Show me example code for this pattern" | |
| 399 | 5. AI: Reads api-extract.json and skills.md | |
| 400 | 6. AI: Generates pattern implementation | |
| 401 | 7. Human: Adapts to specific use case | |
| 402 | ``` | |
| 403 | ||
| 404 | --- | |
| 405 | ||
| 406 | ## File Access Guide for AI | |
| 407 | ||
| 408 | When working with AI, these files are available: | |
| 409 | ||
| 410 | ### High-Level Discovery | |
| 411 | - `repo_map.json` - All 529 repos with descriptions | |
| 412 | - `semantic-categories.json` - Repos organized by category | |
| 413 | - `use-case-map.json` - 11 use cases with repo recommendations | |
| 414 | - `stability-index.json` - Maturity and stability info | |
| 415 | ||
| 416 | ### Architecture & Patterns | |
| 417 | - `dependency-graph.json` - Complete dependency relationships | |
| 418 | - `pattern-map.json` - 10 P2P patterns mapped to repos | |
| 419 | - `platform-support.json` - Platform compatibility | |
| 420 | ||
| 421 | ### Deep Documentation (per repo) | |
| 422 | - `skills/{repo-name}/skills.md` - API docs, usage, examples (529 files) | |
| 423 | - `skills/{repo-name}/api-extract.json` - Structured API data (133 files) | |
| 424 | ||
| 425 | ### Tools | |
| 426 | - `designer-agent.js` - Human runs, shares output with AI | |
| 427 | - `architect-agent.js` - Human runs, shares output with AI | |
| 428 | ||
| 429 | --- | |
| 430 | ||
| 431 | ## Example AI Prompts | |
| 432 | ||
| 433 | ### Getting Started | |
| 434 | ``` | |
| 435 | I want to build [description]. | |
| 436 | ||
| 437 | Run this command and tell me the results: | |
| 438 | 1. What repos are recommended? | |
| 439 | 2. Which are required vs optional? | |
| 440 | 3. What patterns will I be using? | |
| 441 | ||
| 442 | Then let's plan the implementation together. | |
| 443 | ``` | |
| 444 | ||
| 445 | ### Implementation | |
| 446 | ``` | |
| 447 | Based on the architect agent output, implement a basic version using: | |
| 448 | - Read skills/[repo1]/skills.md for API reference | |
| 449 | - Read skills/[repo2]/skills.md for API reference | |
| 450 | - Follow the architectural layers shown | |
| 451 | - Start with the Foundation layer repos first | |
| 452 | ``` | |
| 453 | ||
| 454 | ### Debugging | |
| 455 | ``` | |
| 456 | I'm getting this error: [error] | |
| 457 | ||
| 458 | My code: [code] | |
| 459 | ||
| 460 | Can you: | |
| 461 | 1. Check if I'm using the API correctly (skills/[repo]/skills.md) | |
| 462 | 2. Verify my dependencies match dependency-graph.json | |
| 463 | 3. See if I'm missing any patterns from pattern-map.json | |
| 464 | ``` | |
| 465 | ||
| 466 | ### Enhancement | |
| 467 | ``` | |
| 468 | I want to add [feature] to my app. | |
| 469 | ||
| 470 | Can you: | |
| 471 | 1. Check if any repos in use-case-map.json support this | |
| 472 | 2. Read the relevant skills.md files | |
| 473 | 3. Show how to integrate with my existing code | |
| 474 | 4. Check for any new dependencies needed | |
| 475 | ``` | |
| 476 | ||
| 477 | --- | |
| 478 | ||
| 479 | ## Best Practices | |
| 480 | ||
| 481 | ### ✅ Do: | |
| 482 | - Run designer/architect agents before asking AI to code | |
| 483 | - Point AI to specific skills.md files | |
| 484 | - Share architectural context from agents | |
| 485 | - Iterate in small, testable increments | |
| 486 | - Ask AI to explain patterns before implementing | |
| 487 | - Use dependency-graph.json to understand relationships | |
| 488 | ||
| 489 | ### ❌ Don't: | |
| 490 | - Ask AI to implement without architectural context | |
| 491 | - Skip the discovery phase (designer agent) | |
| 492 | - Implement all features at once | |
| 493 | - Ignore stability warnings from stability-index.json | |
| 494 | - Forget to check platform-support.json for target platform | |
| 495 | - Assume AI knows holepunchto APIs without documentation | |
| 496 | ||
| 497 | --- | |
| 498 | ||
| 499 | ## Success Metrics | |
| 500 | ||
| 501 | You're on the right track when: | |
| 502 | ||
| 503 | ✅ Designer agent matches your requirements to appropriate repos | |
| 504 | ✅ Architect agent shows clear architectural layers | |
| 505 | ✅ AI generates code that uses documented APIs correctly | |
| 506 | ✅ You can iterate and add features incrementally | |
| 507 | ✅ AI can debug issues by referencing documentation | |
| 508 | ✅ Your app follows P2P patterns from pattern-map.json | |
| 509 | ||
| 510 | --- | |
| 511 | ||
| 512 | ## Getting Help | |
| 513 | ||
| 514 | ### When Stuck: | |
| 515 | ||
| 516 | 1. **Re-run architect agent** with different repo combinations | |
| 517 | 2. **Ask AI to read** skills.md files for clarification | |
| 518 | 3. **Check dependency-graph.json** for missing dependencies | |
| 519 | 4. **Review pattern-map.json** to ensure you're using the right pattern | |
| 520 | 5. **Look at api-extract.json** for 133 deeply analyzed repos | |
| 521 | ||
| 522 | ### Common Issues: | |
| 523 | ||
| 524 | **"AI suggests wrong API"** | |
| 525 | → Point AI to correct skills.md: "Read skills/hypercore/skills.md section on [topic]" | |
| 526 | ||
| 527 | **"Dependencies not working together"** | |
| 528 | → Share dependency-graph.json: "Check if these repos are compatible" | |
| 529 | ||
| 530 | **"Don't know which repo to use"** | |
| 531 | → Re-run designer-agent with clearer requirements | |
| 532 | ||
| 533 | **"Architecture seems off"** | |
| 534 | → Run architect-agent with different repo combinations | |
| 535 | ||
| 536 | --- | |
| 537 | ||
| 538 | ## Next Steps | |
| 539 | ||
| 540 | After building your first app: | |
| 541 | ||
| 542 | 1. **Contribute back** - Document your learnings | |
| 543 | 2. **Explore patterns** - Try different P2P patterns | |
| 544 | 3. **Build more** - Use different use cases | |
| 545 | 4. **Optimize** - Check performance patterns in Phase 4 (when available) | |
| 546 | ||
| 547 | --- | |
| 548 | ||
| 549 | ## Summary | |
| 550 | ||
| 551 | The **Human + AI workflow** for building P2P apps: | |
| 552 | ||
| 553 | 1. 🧑 **Human** describes requirements | |
| 554 | 2. 🤖 **Designer Agent** recommends repos | |
| 555 | 3. 🏗️ **Architect Agent** designs architecture | |
| 556 | 4. 🤖 **AI Assistant** implements code using skills.md | |
| 557 | 5. 🧑🤖 **Human + AI** iterate and enhance together | |
| 558 | ||
| 559 | This knowledge base provides **529 repos** of documentation, **133 deep API analyses**, **11 use cases**, and **10 patterns** - all accessible to both humans and AI assistants. | |
| 560 | ||
| 561 | **Start building P2P apps today!** 🚀 |
| … | … | @@ -0,0 +1,283 @@ |
| 1 | # Quick Start: Build P2P Apps with AI | |
| 2 | ||
| 3 | **Time to first app: ~15 minutes** | |
| 4 | ||
| 5 | --- | |
| 6 | ||
| 7 | ## Prerequisites | |
| 8 | ||
| 9 | - Node.js installed | |
| 10 | - This repository cloned | |
| 11 | - An AI assistant (Claude, ChatGPT, etc.) - optional but recommended | |
| 12 | ||
| 13 | --- | |
| 14 | ||
| 15 | ## 3-Step Process | |
| 16 | ||
| 17 | ### Step 1: Discover (2 min) | |
| 18 | ||
| 19 | Tell the designer agent what you want to build: | |
| 20 | ||
| 21 | ```bash | |
| 22 | node designer-agent.js "I want to build a distributed database" | |
| 23 | ``` | |
| 24 | ||
| 25 | **You get:** | |
| 26 | - ✅ Required repos (e.g., hypercore, hyperbee) | |
| 27 | - ✅ Optional repos (e.g., autobase, corestore) | |
| 28 | - ✅ Stability info | |
| 29 | - ✅ Use case match | |
| 30 | ||
| 31 | ### Step 2: Design (2 min) | |
| 32 | ||
| 33 | Feed recommended repos to the architect agent: | |
| 34 | ||
| 35 | ```bash | |
| 36 | node architect-agent.js hypercore hyperbee | |
| 37 | ``` | |
| 38 | ||
| 39 | **You get:** | |
| 40 | - ✅ Architectural layers | |
| 41 | - ✅ Dependencies between repos | |
| 42 | - ✅ P2P patterns you'll use | |
| 43 | - ✅ Missing dependency warnings | |
| 44 | ||
| 45 | ### Step 3: Build (10+ min) | |
| 46 | ||
| 47 | **Option A: With AI Assistant** | |
| 48 | ||
| 49 | Share designer + architect output with your AI: | |
| 50 | ||
| 51 | ``` | |
| 52 | I want to build a distributed database. Here's what the agents recommended: | |
| 53 | ||
| 54 | [paste designer output] | |
| 55 | [paste architect output] | |
| 56 | ||
| 57 | Can you implement a basic version? Read these docs: | |
| 58 | - skills/hypercore/skills.md | |
| 59 | - skills/hyperbee/skills.md | |
| 60 | ``` | |
| 61 | ||
| 62 | AI generates working code using the documented APIs. | |
| 63 | ||
| 64 | **Option B: Without AI** | |
| 65 | ||
| 66 | Read the documentation yourself: | |
| 67 | ||
| 68 | ```bash | |
| 69 | cat skills/hypercore/skills.md | |
| 70 | cat skills/hyperbee/skills.md | |
| 71 | ``` | |
| 72 | ||
| 73 | Implement using the API examples and code snippets. | |
| 74 | ||
| 75 | --- | |
| 76 | ||
| 77 | ## Example Session | |
| 78 | ||
| 79 | ```bash | |
| 80 | # 1. What should I build with? | |
| 81 | $ node designer-agent.js "P2P file sharing" | |
| 82 | # Output: hypercore, hyperdrive, hyperswarm | |
| 83 | ||
| 84 | # 2. How do they fit together? | |
| 85 | $ node architect-agent.js hypercore hyperdrive hyperswarm | |
| 86 | # Output: Architecture with 3 layers, 8 patterns, integration points | |
| 87 | ||
| 88 | # 3. Show me the APIs | |
| 89 | $ cat skills/hypercore/skills.md | |
| 90 | $ cat skills/hyperdrive/skills.md | |
| 91 | $ cat skills/hyperswarm/skills.md | |
| 92 | ||
| 93 | # 4. Build it! (with or without AI assistance) | |
| 94 | ``` | |
| 95 | ||
| 96 | --- | |
| 97 | ||
| 98 | ## Available Use Cases | |
| 99 | ||
| 100 | Run this to see all pre-defined use cases: | |
| 101 | ||
| 102 | ```bash | |
| 103 | node designer-agent.js --list-use-cases | |
| 104 | ``` | |
| 105 | ||
| 106 | **11 Use Cases:** | |
| 107 | - distributed-database | |
| 108 | - p2p-file-sharing | |
| 109 | - real-time-messaging | |
| 110 | - distributed-log | |
| 111 | - p2p-networking | |
| 112 | - multi-writer-collab | |
| 113 | - encrypted-storage | |
| 114 | - p2p-streaming | |
| 115 | - dht-application | |
| 116 | - bare-runtime-app | |
| 117 | - pear-application | |
| 118 | ||
| 119 | Pick one: | |
| 120 | ||
| 121 | ```bash | |
| 122 | node designer-agent.js --use-case p2p-file-sharing | |
| 123 | node architect-agent.js --use-case p2p-file-sharing | |
| 124 | ``` | |
| 125 | ||
| 126 | --- | |
| 127 | ||
| 128 | ## Using with AI Assistants | |
| 129 | ||
| 130 | ### Best Prompt Template | |
| 131 | ||
| 132 | ``` | |
| 133 | I want to build: [YOUR IDEA] | |
| 134 | ||
| 135 | Step 1 - Discovery: | |
| 136 | [paste: node designer-agent.js "YOUR IDEA" output] | |
| 137 | ||
| 138 | Step 2 - Architecture: | |
| 139 | [paste: node architect-agent.js [repos] output] | |
| 140 | ||
| 141 | Step 3 - Implementation: | |
| 142 | Please implement this using the API docs in: | |
| 143 | - skills/[repo1]/skills.md | |
| 144 | - skills/[repo2]/skills.md | |
| 145 | ||
| 146 | Start with a basic working version. | |
| 147 | ``` | |
| 148 | ||
| 149 | ### AI Can Access | |
| 150 | ||
| 151 | - ✅ All 529 skills.md files (API docs) | |
| 152 | - ✅ 133 deep api-extract.json files (structured data) | |
| 153 | - ✅ dependency-graph.json (relationships) | |
| 154 | - ✅ pattern-map.json (P2P patterns) | |
| 155 | - ✅ All semantic mapping data | |
| 156 | ||
| 157 | ### AI Cannot Do | |
| 158 | ||
| 159 | - ❌ Run the designer/architect agents (you do this) | |
| 160 | - ❌ Install npm packages (you do this) | |
| 161 | - ❌ Test your code (you do this) | |
| 162 | ||
| 163 | --- | |
| 164 | ||
| 165 | ## File Quick Reference | |
| 166 | ||
| 167 | ### For Discovery | |
| 168 | - `designer-agent.js` - What repos to use? | |
| 169 | - `use-case-map.json` - 11 pre-defined use cases | |
| 170 | - `semantic-categories.json` - 529 repos categorized | |
| 171 | ||
| 172 | ### For Architecture | |
| 173 | - `architect-agent.js` - How do repos fit together? | |
| 174 | - `dependency-graph.json` - Dependencies between all repos | |
| 175 | - `pattern-map.json` - 10 P2P patterns | |
| 176 | ||
| 177 | ### For Implementation | |
| 178 | - `skills/{repo-name}/skills.md` - API docs for each repo (529 files) | |
| 179 | - `skills/{repo-name}/api-extract.json` - Structured API data (133 files) | |
| 180 | - `stability-index.json` - Which repos are production-ready? | |
| 181 | - `platform-support.json` - What platforms are supported? | |
| 182 | ||
| 183 | --- | |
| 184 | ||
| 185 | ## Tips | |
| 186 | ||
| 187 | ✅ **DO:** | |
| 188 | - Start with designer-agent | |
| 189 | - Use architect-agent before coding | |
| 190 | - Read skills.md for APIs | |
| 191 | - Point AI to specific documentation files | |
| 192 | - Build incrementally | |
| 193 | ||
| 194 | ❌ **DON'T:** | |
| 195 | - Skip the discovery phase | |
| 196 | - Implement everything at once | |
| 197 | - Guess at APIs (read skills.md instead) | |
| 198 | - Use unstable repos for production (check stability-index.json) | |
| 199 | ||
| 200 | --- | |
| 201 | ||
| 202 | ## Next Steps | |
| 203 | ||
| 204 | 1. ✅ Run designer-agent with your idea | |
| 205 | 2. ✅ Run architect-agent with recommendations | |
| 206 | 3. ✅ Read skills.md for your repos | |
| 207 | 4. ✅ Build your first P2P app! | |
| 208 | ||
| 209 | **For detailed workflows, see:** [AI_WORKFLOW_GUIDE.md](AI_WORKFLOW_GUIDE.md) | |
| 210 | ||
| 211 | --- | |
| 212 | ||
| 213 | ## Examples | |
| 214 | ||
| 215 | ### "Hello World" - Distributed Database | |
| 216 | ||
| 217 | ```bash | |
| 218 | # Discover | |
| 219 | node designer-agent.js "distributed database" | |
| 220 | # → hypercore, hyperbee | |
| 221 | ||
| 222 | # Design | |
| 223 | node architect-agent.js hypercore hyperbee | |
| 224 | # → 2 foundation repos, 6 patterns | |
| 225 | ||
| 226 | # Read docs | |
| 227 | cat skills/hypercore/skills.md | |
| 228 | cat skills/hyperbee/skills.md | |
| 229 | ||
| 230 | # Build (example code in skills.md files) | |
| 231 | ``` | |
| 232 | ||
| 233 | ### P2P Chat | |
| 234 | ||
| 235 | ```bash | |
| 236 | # Discover | |
| 237 | node designer-agent.js "real-time chat" | |
| 238 | # → hyperswarm, hyperswarm-secret-stream | |
| 239 | ||
| 240 | # Design | |
| 241 | node architect-agent.js hyperswarm hyperswarm-secret-stream | |
| 242 | ||
| 243 | # Read docs & build | |
| 244 | cat skills/hyperswarm/skills.md | |
| 245 | ``` | |
| 246 | ||
| 247 | ### File Sharing | |
| 248 | ||
| 249 | ```bash | |
| 250 | # Use pre-defined use case | |
| 251 | node designer-agent.js --use-case p2p-file-sharing | |
| 252 | node architect-agent.js --use-case p2p-file-sharing | |
| 253 | ||
| 254 | # Read docs | |
| 255 | cat skills/hypercore/skills.md | |
| 256 | cat skills/hyperdrive/skills.md | |
| 257 | cat skills/hyperswarm/skills.md | |
| 258 | ``` | |
| 259 | ||
| 260 | --- | |
| 261 | ||
| 262 | ## Getting Help | |
| 263 | ||
| 264 | **Problem:** "Don't know what to build" | |
| 265 | → `node designer-agent.js --list-use-cases` | |
| 266 | ||
| 267 | **Problem:** "AI suggests wrong API" | |
| 268 | → Point AI to: `skills/{repo}/skills.md` | |
| 269 | ||
| 270 | **Problem:** "Repos don't work together" | |
| 271 | → Check: `dependency-graph.json` | |
| 272 | ||
| 273 | **Problem:** "Code doesn't work" | |
| 274 | → Check API examples in `skills.md` files | |
| 275 | ||
| 276 | **Problem:** "Which repo is stable?" | |
| 277 | → Check: `stability-index.json` | |
| 278 | ||
| 279 | --- | |
| 280 | ||
| 281 | **Ready? Start with:** `node designer-agent.js "YOUR IDEA HERE"` | |
| 282 | ||
| 283 | 🚀 Happy building! |
| … | … | @@ -12,8 +12,41 @@ This repository provides: |
| 12 | 12 | - **P2P pattern detection** across the ecosystem |
| 13 | 13 | - **Runtime classification** (bare, pear, node, universal) |
| 14 | 14 | - **Maturity metrics** (stars, activity, status) |
| 15 | - **Designer & Architect sub-agents** for guided P2P app development | |
| 15 | 16 | |
| 16 | ## Quick Start | |
| 17 | ## 🚀 Getting Started | |
| 18 | ||
| 19 | ### New to Building P2P Apps? | |
| 20 | ||
| 21 | **→ Start here: [QUICK_START.md](QUICK_START.md)** (5 minutes) | |
| 22 | ||
| 23 | Learn how to use the designer and architect agents to build your first P2P application. | |
| 24 | ||
| 25 | ### Want to Build with AI? | |
| 26 | ||
| 27 | **→ See: [AI_WORKFLOW_GUIDE.md](AI_WORKFLOW_GUIDE.md)** (Complete workflow) | |
| 28 | ||
| 29 | Detailed guide on collaborating with AI assistants (Claude, ChatGPT, etc.) to build P2P applications using this knowledge base. | |
| 30 | ||
| 31 | ### Example: Build a Distributed Database | |
| 32 | ||
| 33 | ```bash | |
| 34 | # 1. Discover what repos to use | |
| 35 | node designer-agent.js "distributed database" | |
| 36 | # → Recommends: hypercore, hyperbee | |
| 37 | ||
| 38 | # 2. Design the architecture | |
| 39 | node architect-agent.js hypercore hyperbee | |
| 40 | # → Shows: layers, patterns, dependencies | |
| 41 | ||
| 42 | # 3. Read the API docs | |
| 43 | cat skills/hypercore/skills.md | |
| 44 | cat skills/hyperbee/skills.md | |
| 45 | ||
| 46 | # 4. Build! (with or without AI assistance) | |
| 47 | ``` | |
| 48 | ||
| 49 | ## Installation | |
| 17 | 50 | |
| 18 | 51 | ### Clone Without Submodules (Lightweight) |
| 19 | 52 | |
| … | … | @@ -82,8 +115,18 @@ git submodule update --init pear-docs |
| 82 | 115 | ├── repo_map.json # All 529 repos with metadata |
| 83 | 116 | ├── tiers.json # Analysis tier definitions |
| 84 | 117 | │ |
| 118 | ├── semantic-categories.json # 529 repos categorized by function | |
| 119 | ├── use-case-map.json # 11 P2P use cases with repo recommendations | |
| 120 | ├── pattern-map.json # 10 P2P patterns mapped to repos | |
| 121 | ├── platform-support.json # Platform compatibility matrix | |
| 122 | ├── stability-index.json # Maturity and stability classification | |
| 123 | │ | |
| 124 | ├── designer-agent.js # CLI tool: requirements → repo recommendations | |
| 125 | ├── architect-agent.js # CLI tool: repos → system architecture | |
| 126 | │ | |
| 85 | 127 | ├── process_repos.js # Phase 1A automation script |
| 86 | 128 | ├── clone_and_analyze_tier.js # Phase 1B automation script |
| 129 | ├── build_semantic_maps.js # Phase 2 automation script | |
| 87 | 130 | │ |
| 88 | 131 | └── docs/ # Project documentation |
| 89 | 132 | ├── PEAR_DOCS_DEEP_DIVE.md |
| … | … | @@ -193,17 +236,20 @@ The 12 core repositories have enhanced documentation with: |
| 193 | 236 | - Dependency graph: 100% coverage with deduplicated reverse deps |
| 194 | 237 | - Skills documentation: 529 repos documented |
| 195 | 238 | |
| 196 | ### ✅ Phase 1B: Deep Code Analysis (Tier 1 & 2 Complete) | |
| 197 | - Cloned and analyzed 12 core repos (Tier 1 & 2) | |
| 239 | ### ✅ Phase 1B: Deep Code Analysis (Selective - Complete) | |
| 240 | - Cloned and analyzed 133 repos (selective strategy) | |
| 198 | 241 | - Extracted API surfaces from code |
| 199 | 242 | - Detected P2P patterns |
| 200 | 243 | - Enhanced skills.md with usage examples |
| 201 | 244 | - Generated api-extract.json for structured API data |
| 202 | 245 | |
| 203 | 246 | **Coverage**: |
| 204 | - Building blocks: 6/6 (100%) ✅ | |
| 205 | - Helpers: 6/6 (100%) ✅ | |
| 206 | - Disk usage: ~16MB for 12 repos | |
| 247 | - Tier 1 (Building blocks): 6/6 (100%) ✅ | |
| 248 | - Tier 2 (Helpers): 6/6 (100%) ✅ | |
| 249 | - Tier 3 (Top 50 popular): 45/50 (90%) ✅ | |
| 250 | - Tier 4 (Selective 150): 76/150 (51%) ✅ | |
| 251 | - Total: 133/529 repos (25.1%) | |
| 252 | - Disk usage: ~116MB for 213 submodules | |
| 207 | 253 | |
| 208 | 254 | **Patterns Detected**: |
| 209 | 255 | - append-only-log (8 repos) |
| … | … | @@ -214,25 +260,73 @@ The 12 core repositories have enhanced documentation with: |
| 214 | 260 | - binary-encoding (5 repos) |
| 215 | 261 | - stream-multiplexing (4 repos) |
| 216 | 262 | - dht-discovery (2 repos) |
| 217 | ||
| 218 | ### 🔄 Phase 2: Semantic Mapping (Next) | |
| 219 | - Create semantic-categories.json mapping all 529 repos | |
| 220 | - Build use-case-map.json for Designer sub-agent | |
| 221 | - Build pattern-map.json for Architect sub-agent | |
| 222 | - Create platform-support.json | |
| 223 | - Create stability-index.json | |
| 224 | - Build interoperability matrix | |
| 263 | - b-tree-index | |
| 264 | - file-system | |
| 265 | ||
| 266 | ### ✅ Phase 2: Semantic Mapping (Complete) | |
| 267 | - Created semantic-categories.json mapping all 529 repos | |
| 268 | - Built use-case-map.json with 11 P2P use cases | |
| 269 | - Built pattern-map.json with 10 P2P patterns | |
| 270 | - Created platform-support.json | |
| 271 | - Created stability-index.json | |
| 272 | ||
| 273 | **Results**: | |
| 274 | - 529 repos categorized into 7 categories | |
| 275 | - 11 use cases defined (distributed-database, p2p-file-sharing, etc.) | |
| 276 | - 10 P2P patterns mapped | |
| 277 | - 48 stable/production-ready repos identified | |
| 278 | - Platform compatibility for all 529 repos | |
| 279 | ||
| 280 | ### ✅ Phase 3: Sub-Agent Development (Complete) | |
| 281 | - Built Designer sub-agent (requirements → repo recommendations) | |
| 282 | - Built Architect sub-agent (repos → system architecture) | |
| 283 | - Both agents tested and functional | |
| 284 | ||
| 285 | **Features**: | |
| 286 | - Designer: Natural language query matching to 11 use cases | |
| 287 | - Architect: 4-layer architecture design with pattern detection | |
| 288 | - Full integration with all semantic mapping data | |
| 289 | - CLI tools ready for production use | |
| 225 | 290 | |
| 226 | 291 | ### 🔮 Future Phases |
| 227 | - Designer sub-agent development | |
| 228 | - Architect sub-agent development | |
| 229 | 292 | - Pattern library creation |
| 230 | 293 | - Testing & validation sub-agent |
| 231 | 294 | - Security & key management sub-agent |
| 295 | - Performance & optimization guidance | |
| 232 | 296 | - Deployment & operations sub-agent |
| 297 | - Code template/scaffolding generator | |
| 233 | 298 | |
| 234 | 299 | ## Usage |
| 235 | 300 | |
| 301 | ### Building P2P Apps (Recommended) | |
| 302 | ||
| 303 | Use the designer and architect agents for guided development: | |
| 304 | ||
| 305 | ```bash | |
| 306 | # Step 1: Get repo recommendations for your use case | |
| 307 | node designer-agent.js "I want to build a distributed database" | |
| 308 | # → Shows: required repos, optional repos, patterns, stability info | |
| 309 | ||
| 310 | # Step 2: Design system architecture | |
| 311 | node architect-agent.js hypercore hyperbee | |
| 312 | # → Shows: layers, dependencies, integration points, recommendations | |
| 313 | ||
| 314 | # Step 3: Read API documentation | |
| 315 | cat skills/hypercore/skills.md | |
| 316 | cat skills/hyperbee/skills.md | |
| 317 | ||
| 318 | # Step 4: Build! (optionally with AI assistance - see AI_WORKFLOW_GUIDE.md) | |
| 319 | ``` | |
| 320 | ||
| 321 | **Available use cases:** | |
| 322 | ```bash | |
| 323 | node designer-agent.js --list-use-cases | |
| 324 | # Shows: distributed-database, p2p-file-sharing, real-time-messaging, | |
| 325 | # distributed-log, p2p-networking, multi-writer-collab, | |
| 326 | # encrypted-storage, p2p-streaming, dht-application, | |
| 327 | # bare-runtime-app, pear-application | |
| 328 | ``` | |
| 329 | ||
| 236 | 330 | ### Exploring the Ecosystem |
| 237 | 331 | |
| 238 | 332 | ```bash |
| … | … | @@ -247,6 +341,12 @@ jq '.[] | select(.stars > 100)' maturity-index.json |
| 247 | 341 | |
| 248 | 342 | # Get reverse dependencies for a package |
| 249 | 343 | jq '.hypercore.reverseDependencies' dependency-graph.json |
| 344 | ||
| 345 | # Check which repos implement a pattern | |
| 346 | jq '.patterns["append-only-log"].implementedBy' pattern-map.json | |
| 347 | ||
| 348 | # See all repos in a category | |
| 349 | jq 'to_entries[] | select(.value.category == "Building Blocks")' semantic-categories.json | |
| 250 | 350 | ``` |
| 251 | 351 | |
| 252 | 352 | ### Reading Skills Documentation |
| … | … | @@ -279,12 +379,15 @@ git submodule deinit repos/tier1/hypercore |
| 279 | 379 | |
| 280 | 380 | - **Total repos analyzed**: 529 |
| 281 | 381 | - **Skills.md files**: 529 |
| 282 | - **Deep analysis**: 12 repos (tier 1 & 2) | |
| 283 | - **API extract files**: 12 | |
| 284 | - **Patterns detected**: 8 types | |
| 285 | - **Runtime detection**: 49.5% success rate | |
| 382 | - **Deep analysis**: 133 repos (tiers 1-4 selective) | |
| 383 | - **API extract files**: 133 | |
| 384 | - **Patterns detected**: 10 types | |
| 385 | - **Use cases defined**: 11 | |
| 386 | - **Semantic categories**: 7 | |
| 387 | - **Stable repos identified**: 48 | |
| 388 | - **Runtime detection**: 49.5% success rate (262/529) | |
| 286 | 389 | - **Disk usage (without submodules)**: ~5MB |
| 287 | - **Disk usage (with submodules)**: ~20MB | |
| 390 | - **Disk usage (with all 213 submodules)**: ~121MB | |
| 288 | 391 | |
| 289 | 392 | ## Development |
| 290 | 393 | |
| … | … | @@ -336,6 +439,12 @@ This analysis project is for educational and reference purposes. Individual repo |
| 336 | 439 | |
| 337 | 440 | ## Resources |
| 338 | 441 | |
| 442 | ### Documentation | |
| 443 | - [QUICK_START.md](QUICK_START.md) - Get started building P2P apps (5 minutes) | |
| 444 | - [AI_WORKFLOW_GUIDE.md](AI_WORKFLOW_GUIDE.md) - Build with AI assistance (complete guide) | |
| 445 | - [PHASE_3_COMPLETE.md](PHASE_3_COMPLETE.md) - Sub-agent documentation | |
| 446 | ||
| 447 | ### External Links | |
| 339 | 448 | - [Holepunchto GitHub Organization](https://github.com/holepunchto) |
| 340 | 449 | - [Official Pear Documentation](https://github.com/holepunchto/pear-docs) |
| 341 | 450 | - [Hypercore Protocol](https://hypercore-protocol.org/) |
| … | … | @@ -352,4 +461,5 @@ Built with: |
| 352 | 461 | --- |
| 353 | 462 | |
| 354 | 463 | **Generated**: 2026-01-16 |
| 355 | **Status**: Phase 1A & 1B (Tier 1 & 2) Complete, Phase 2 Ready | |
| 464 | **Status**: Phases 1-3 Complete - Designer & Architect agents ready for production use | |
| 465 | **Next**: Phase 4 - Additional skills development (testing, security, performance, etc.) |