|
| 1 | +# AGENTS.md - Plugin Documentation Guidelines |
| 2 | + |
| 3 | +This file provides guidelines for AI agents working with the Cortex CLI plugin documentation. |
| 4 | + |
| 5 | +## Documentation Structure |
| 6 | + |
| 7 | +``` |
| 8 | +plugins-docs/ |
| 9 | +├── README.md # Main index with links |
| 10 | +├── AGENTS.md # This file |
| 11 | +├── getting-started/ |
| 12 | +│ ├── overview.md # Plugin system overview |
| 13 | +│ ├── quick-start.md # Create first plugin |
| 14 | +│ └── plugin-structure.md # Directory layout |
| 15 | +├── reference/ |
| 16 | +│ ├── manifest.md # plugin.toml reference |
| 17 | +│ ├── capabilities.md # Capability types |
| 18 | +│ ├── permissions.md # Permission types |
| 19 | +│ ├── commands.md # Custom commands |
| 20 | +│ ├── hooks.md # Hook types |
| 21 | +│ ├── events.md # Event types |
| 22 | +│ ├── api.md # Plugin API |
| 23 | +│ ├── configuration.md # System config |
| 24 | +│ └── cli-commands.md # CLI usage |
| 25 | +├── guides/ |
| 26 | +│ ├── development.md # Building plugins |
| 27 | +│ ├── best-practices.md # Security, performance |
| 28 | +│ └── troubleshooting.md # Common issues |
| 29 | +└── examples/ |
| 30 | + └── README.md # Example plugins |
| 31 | +``` |
| 32 | + |
| 33 | +## Key Concepts |
| 34 | + |
| 35 | +### Plugin System |
| 36 | + |
| 37 | +- Plugins are WASM-based for security and portability |
| 38 | +- Run in isolated sandboxes |
| 39 | +- Must declare capabilities and permissions |
| 40 | +- Can add commands, hooks, and event handlers |
| 41 | + |
| 42 | +### Core Files |
| 43 | + |
| 44 | +- `plugin.toml` - Plugin manifest (required) |
| 45 | +- `plugin.wasm` - Compiled WASM module |
| 46 | + |
| 47 | +### Plugin Locations |
| 48 | + |
| 49 | +1. `~/.cortex/plugins/` - Global plugins |
| 50 | +2. `~/.config/cortex/plugins/` - Config directory |
| 51 | +3. `./.cortex/plugins/` - Project-local |
| 52 | + |
| 53 | +## Documentation Guidelines |
| 54 | + |
| 55 | +### When Adding Documentation |
| 56 | + |
| 57 | +1. **Keep files focused** - One topic per file |
| 58 | +2. **Use consistent headers** - H1 for title, H2 for sections |
| 59 | +3. **Include examples** - Code samples for all features |
| 60 | +4. **Link related docs** - Cross-reference other pages |
| 61 | +5. **Update README.md** - Add new pages to index |
| 62 | + |
| 63 | +### Code Examples |
| 64 | + |
| 65 | +Always provide complete, working examples: |
| 66 | + |
| 67 | +```toml |
| 68 | +# Good: Complete manifest example |
| 69 | +[plugin] |
| 70 | +id = "example" |
| 71 | +name = "Example" |
| 72 | +version = "1.0.0" |
| 73 | + |
| 74 | +capabilities = ["commands"] |
| 75 | + |
| 76 | +[[commands]] |
| 77 | +name = "example" |
| 78 | +description = "Example command" |
| 79 | +``` |
| 80 | + |
| 81 | +### Tables |
| 82 | + |
| 83 | +Use tables for reference material: |
| 84 | + |
| 85 | +| Field | Type | Required | Description | |
| 86 | +|-------|------|----------|-------------| |
| 87 | +| `id` | string | ✅ | Unique identifier | |
| 88 | +| `name` | string | ✅ | Display name | |
| 89 | + |
| 90 | +## Common Tasks |
| 91 | + |
| 92 | +### Adding a New Hook Type |
| 93 | + |
| 94 | +1. Document in `reference/hooks.md` |
| 95 | +2. Add to hook types table |
| 96 | +3. Include input/output fields |
| 97 | +4. Provide example |
| 98 | + |
| 99 | +### Adding a New Permission |
| 100 | + |
| 101 | +1. Document in `reference/permissions.md` |
| 102 | +2. Add to permission types section |
| 103 | +3. Include TOML syntax example |
| 104 | +4. Note required capabilities |
| 105 | + |
| 106 | +### Adding a New Event |
| 107 | + |
| 108 | +1. Document in `reference/events.md` |
| 109 | +2. Add JSON example |
| 110 | +3. List event fields |
| 111 | + |
| 112 | +## Related Code |
| 113 | + |
| 114 | +The plugin system implementation is in: |
| 115 | + |
| 116 | +- `cortex-plugins/src/` - Plugin system crate |
| 117 | +- `cortex-plugins/src/manifest.rs` - Manifest parsing |
| 118 | +- `cortex-plugins/src/hooks.rs` - Hook types |
| 119 | +- `cortex-plugins/src/events.rs` - Event types |
| 120 | +- `cortex-plugins/src/api.rs` - Plugin API |
| 121 | +- `cortex-cli/src/plugin_cmd.rs` - CLI commands |
| 122 | + |
| 123 | +## Verification |
| 124 | + |
| 125 | +When updating documentation: |
| 126 | + |
| 127 | +1. Verify code examples compile/work |
| 128 | +2. Check all links are valid |
| 129 | +3. Ensure consistency with implementation |
| 130 | +4. Test CLI commands mentioned |
| 131 | + |
| 132 | +## Style Guide |
| 133 | + |
| 134 | +- Use backticks for `code`, commands, and file names |
| 135 | +- Use **bold** for important terms on first use |
| 136 | +- Use bullet points for lists |
| 137 | +- Keep paragraphs short (3-5 sentences max) |
| 138 | +- Include "Next Steps" sections |
| 139 | + |
| 140 | +## Notes for AI Agents |
| 141 | + |
| 142 | +- The plugin documentation is separate from main AGENTS.md |
| 143 | +- Plugin source is in `cortex-plugins/` crate |
| 144 | +- CLI plugin commands are in `cortex-cli/src/plugin_cmd.rs` |
| 145 | +- Always check implementation matches documentation |
| 146 | +- Update docs when plugin system changes |
0 commit comments