|
| 1 | +# Canary Prompts - Hierarchical Structure |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Canary prompts package provides a hierarchical organization of prompts for all CLI commands. Each command has its own dedicated prompt file describing its purpose, behavior, and standards. |
| 6 | + |
| 7 | +## Directory Structure |
| 8 | + |
| 9 | +``` |
| 10 | +prompts/ |
| 11 | +??? commands/ # Command-specific prompts |
| 12 | +? ??? scan/ |
| 13 | +? ? ??? scan.md # Scan command prompt |
| 14 | +? ??? list/ |
| 15 | +? ? ??? list.md # List command prompt |
| 16 | +? ??? show/ |
| 17 | +? ? ??? show.md # Show command prompt |
| 18 | +? ??? create/ |
| 19 | +? ? ??? create.md # Create command prompt |
| 20 | +? ??? status/ |
| 21 | +? ? ??? status.md # Status command prompt |
| 22 | +? ??? search/ |
| 23 | +? ? ??? search.md # Search command prompt |
| 24 | +? ??? next/ |
| 25 | +? ? ??? next.md # Next command prompt |
| 26 | +? ??? specify/ |
| 27 | +? ? ??? specify.md # Specify command prompt |
| 28 | +? ??? plan/ |
| 29 | +? ? ??? plan.md # Plan command prompt |
| 30 | +? ??? implement/ |
| 31 | +? ? ??? implement.md # Implement command prompt |
| 32 | +? ??? index/ |
| 33 | +? ? ??? index.md # Index command prompt |
| 34 | +? ??? files/ |
| 35 | +? ? ??? files.md # Files command prompt |
| 36 | +? ??? grep/ |
| 37 | +? ? ??? grep.md # Grep command prompt |
| 38 | +? ??? prioritize/ |
| 39 | +? ? ??? prioritize.md # Prioritize command prompt |
| 40 | +? ??? bug/ |
| 41 | +? ? ??? bug.md # Bug command prompt |
| 42 | +? ??? gap/ |
| 43 | +? ? ??? gap.md # Gap command prompt |
| 44 | +? ??? checkpoint/ |
| 45 | +? ? ??? checkpoint.md # Checkpoint command prompt |
| 46 | +? ??? constitution/ |
| 47 | +? ? ??? constitution.md # Constitution command prompt |
| 48 | +? ??? deps/ |
| 49 | +? ? ??? deps.md # Dependencies command prompt |
| 50 | +? ??? doc/ |
| 51 | +? ? ??? doc.md # Documentation command prompt |
| 52 | +? ??? migrate/ |
| 53 | +? ? ??? migrate.md # Migration command prompt |
| 54 | +? ??? project/ |
| 55 | +? ? ??? project.md # Project command prompt |
| 56 | +? ??? specs/ |
| 57 | +? ? ??? specs.md # Specs command prompt |
| 58 | +? ??? db/ |
| 59 | +? ? ??? db.md # Database command prompt |
| 60 | +? ??? mcp/ |
| 61 | +? ??? mcp.md # MCP server command prompt |
| 62 | +??? sys/ # System-level prompts (legacy) |
| 63 | +? ??? init.md # Initialization prompt |
| 64 | +? ??? policy.md # Policy prompt |
| 65 | +? ??? requirements.md # Requirements prompt |
| 66 | +? ??? evaluate.md # Evaluation prompt |
| 67 | +??? prompts.go # Go API for accessing prompts |
| 68 | +??? prompts_test.go # Tests for prompt API |
| 69 | +??? README.md # This file |
| 70 | +``` |
| 71 | + |
| 72 | +## Usage |
| 73 | + |
| 74 | +### Go API |
| 75 | + |
| 76 | +```go |
| 77 | +import "go.devnw.com/canary/prompts" |
| 78 | + |
| 79 | +// Get a specific command prompt |
| 80 | +content, err := prompts.GetCommand("scan") |
| 81 | +if err != nil { |
| 82 | + log.Fatal(err) |
| 83 | +} |
| 84 | +fmt.Println(content) |
| 85 | + |
| 86 | +// List all available commands |
| 87 | +commands, err := prompts.ListCommands() |
| 88 | +if err != nil { |
| 89 | + log.Fatal(err) |
| 90 | +} |
| 91 | +fmt.Printf("Available commands: %v\n", commands) |
| 92 | + |
| 93 | +// Get all command prompts as a map |
| 94 | +allPrompts, err := prompts.GetAllCommands() |
| 95 | +if err != nil { |
| 96 | + log.Fatal(err) |
| 97 | +} |
| 98 | + |
| 99 | +// Parse a command prompt into structured data |
| 100 | +prompt, err := prompts.ParseCommandPrompt("scan") |
| 101 | +if err != nil { |
| 102 | + log.Fatal(err) |
| 103 | +} |
| 104 | +fmt.Printf("Command: %s\n", prompt.Command) |
| 105 | +fmt.Printf("Full content: %s\n", prompt.FullContent) |
| 106 | +``` |
| 107 | + |
| 108 | +### Legacy System Prompts |
| 109 | + |
| 110 | +```go |
| 111 | +// Legacy API still supported |
| 112 | +all := prompts.All() |
| 113 | +fmt.Println(all["init"]) |
| 114 | +fmt.Println(all["policy"]) |
| 115 | + |
| 116 | +// Or use individual variables |
| 117 | +fmt.Println(prompts.Init) |
| 118 | +fmt.Println(prompts.Policy) |
| 119 | +fmt.Println(prompts.Requirements) |
| 120 | +fmt.Println(prompts.Evaluate) |
| 121 | +``` |
| 122 | + |
| 123 | +## Command Prompt Structure |
| 124 | + |
| 125 | +Each command prompt file follows this structure: |
| 126 | + |
| 127 | +### Header |
| 128 | +```markdown |
| 129 | +# [Command Name] Command Prompt |
| 130 | + |
| 131 | +## Purpose |
| 132 | +Brief description of what the command does. |
| 133 | +``` |
| 134 | + |
| 135 | +### Task Description |
| 136 | +```markdown |
| 137 | +## Task |
| 138 | +Detailed description of what needs to be implemented. |
| 139 | +``` |
| 140 | + |
| 141 | +### Expected Behavior |
| 142 | +```markdown |
| 143 | +## Expected Behavior |
| 144 | +Examples of how the command should work: |
| 145 | + |
| 146 | +\`\`\`bash |
| 147 | +canary command --flag value |
| 148 | +\`\`\` |
| 149 | +``` |
| 150 | + |
| 151 | +### Output Format |
| 152 | +```markdown |
| 153 | +## Output Format |
| 154 | +Description and examples of command output. |
| 155 | +``` |
| 156 | + |
| 157 | +### Standards |
| 158 | +```markdown |
| 159 | +## Standards |
| 160 | +- Implementation guidelines |
| 161 | +- Best practices |
| 162 | +- Performance requirements |
| 163 | +- Error handling expectations |
| 164 | +``` |
| 165 | + |
| 166 | +## Categories |
| 167 | + |
| 168 | +### Core Token Management |
| 169 | +Commands that deal with CANARY tokens directly: |
| 170 | +- **list** - List/filter tokens |
| 171 | +- **show** - Show requirement details |
| 172 | +- **create** - Generate token template |
| 173 | +- **status** - Show progress stats |
| 174 | +- **search** - Search by keywords |
| 175 | +- **next** - Get next priority requirement |
| 176 | + |
| 177 | +### Workflow & Development |
| 178 | +Commands for the development workflow: |
| 179 | +- **scan** - Scan codebase for tokens |
| 180 | +- **specify** - Create requirement specification |
| 181 | +- **plan** - Generate implementation plan |
| 182 | +- **implement** - Get implementation guidance |
| 183 | +- **index** - Index tokens to database |
| 184 | + |
| 185 | +### Query & Navigation |
| 186 | +Commands for exploring the codebase: |
| 187 | +- **files** - Find files for requirement |
| 188 | +- **grep** - Search by pattern in fields |
| 189 | + |
| 190 | +### Management |
| 191 | +Commands for project management: |
| 192 | +- **prioritize** - Set requirement priority |
| 193 | +- **checkpoint** - Create state snapshots |
| 194 | +- **constitution** - Manage project principles |
| 195 | +- **deps** - Manage dependencies |
| 196 | +- **project** - Manage project configuration |
| 197 | + |
| 198 | +### Bug Tracking |
| 199 | +Commands for bug management: |
| 200 | +- **bug** - Bug lifecycle management (list, create, show, update) |
| 201 | +- **gap** - Gap analysis feedback |
| 202 | + |
| 203 | +### Documentation |
| 204 | +Commands for documentation: |
| 205 | +- **doc** - Generate documentation |
| 206 | +- **specs** - Manage specifications |
| 207 | + |
| 208 | +### Infrastructure |
| 209 | +Commands for system management: |
| 210 | +- **db** - Database operations |
| 211 | +- **migrate** - Schema migrations |
| 212 | +- **mcp** - MCP server for AI assistants |
| 213 | + |
| 214 | +## Adding New Commands |
| 215 | + |
| 216 | +To add a new command prompt: |
| 217 | + |
| 218 | +1. Create a new directory: `commands/yourcommand/` |
| 219 | +2. Create the prompt file: `commands/yourcommand/yourcommand.md` |
| 220 | +3. Follow the standard prompt structure |
| 221 | +4. The prompt will be automatically embedded and available via the API |
| 222 | + |
| 223 | +Example: |
| 224 | +```bash |
| 225 | +mkdir -p prompts/commands/newcmd |
| 226 | +cat > prompts/commands/newcmd/newcmd.md << 'EOF' |
| 227 | +# New Command Prompt |
| 228 | +
|
| 229 | +## Purpose |
| 230 | +Description of the new command. |
| 231 | +
|
| 232 | +## Task |
| 233 | +Implementation details. |
| 234 | +
|
| 235 | +## Expected Behavior |
| 236 | +Usage examples. |
| 237 | +
|
| 238 | +## Standards |
| 239 | +Guidelines and requirements. |
| 240 | +EOF |
| 241 | +``` |
| 242 | + |
| 243 | +The new prompt will be automatically available: |
| 244 | +```go |
| 245 | +content, err := prompts.GetCommand("newcmd") |
| 246 | +``` |
| 247 | + |
| 248 | +## Testing |
| 249 | + |
| 250 | +Run tests to verify all prompts are accessible: |
| 251 | + |
| 252 | +```bash |
| 253 | +go test ./prompts/... |
| 254 | +``` |
| 255 | + |
| 256 | +## Embedding |
| 257 | + |
| 258 | +All prompts are embedded into the binary using Go's `embed` directive. This means: |
| 259 | +- No external files needed at runtime |
| 260 | +- Fast access (no disk I/O) |
| 261 | +- Version-controlled with code |
| 262 | +- Single binary distribution |
| 263 | + |
| 264 | +## Benefits |
| 265 | + |
| 266 | +### For Developers |
| 267 | +- Clear guidelines for each command |
| 268 | +- Consistent command behavior |
| 269 | +- Easy to reference during implementation |
| 270 | + |
| 271 | +### For AI Assistants |
| 272 | +- Structured prompts for each tool |
| 273 | +- Clear expectations and standards |
| 274 | +- Examples and formats |
| 275 | + |
| 276 | +### For Documentation |
| 277 | +- Single source of truth |
| 278 | +- Auto-generated docs possible |
| 279 | +- Version-controlled |
| 280 | + |
| 281 | +## Future Enhancements |
| 282 | + |
| 283 | +Potential improvements: |
| 284 | +- [ ] Structured parsing of prompt sections |
| 285 | +- [ ] Validation of prompt completeness |
| 286 | +- [ ] Generation of command documentation from prompts |
| 287 | +- [ ] Template variable substitution |
| 288 | +- [ ] Multi-language prompt support |
| 289 | +- [ ] Prompt versioning system |
| 290 | + |
| 291 | +## Related Files |
| 292 | + |
| 293 | +- `cli/` - CLI command implementations |
| 294 | +- `mcp/` - MCP server that exposes commands to AI |
| 295 | +- `internal/storage/` - Database layer used by commands |
| 296 | +- `.canary/templates/` - User-facing templates |
| 297 | + |
| 298 | +## License |
| 299 | + |
| 300 | +Copyright (c) 2025 by Developer Network. |
| 301 | + |
| 302 | +For more details, see the LICENSE file in the root directory of this |
| 303 | +source code repository or contact Developer Network at info@devnw.com. |
0 commit comments