Skip to content

Commit 02184a9

Browse files
feat: Restructure prompts to hierarchical command structure
Co-authored-by: benji <benji@codepros.org>
1 parent e2d6c24 commit 02184a9

File tree

29 files changed

+2303
-10
lines changed

29 files changed

+2303
-10
lines changed

PROMPTS_RESTRUCTURE_SUMMARY.md

Lines changed: 437 additions & 0 deletions
Large diffs are not rendered by default.

prompts/README.md

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
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.

prompts/commands/bug/bug.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Bug Command Prompt
2+
3+
## Purpose
4+
Manage bug tracking with CANARY tokens.
5+
6+
## Task
7+
Implement `canary bug` subcommands for bug lifecycle management.
8+
9+
## Subcommands
10+
11+
### bug list
12+
```bash
13+
# List all bugs
14+
canary bug list
15+
16+
# Filter by status
17+
canary bug list --status OPEN
18+
19+
# Filter by severity
20+
canary bug list --severity HIGH
21+
```
22+
23+
### bug create
24+
```bash
25+
canary bug create "Memory leak in auth module" --severity HIGH --owner backend
26+
```
27+
28+
### bug show
29+
```bash
30+
canary bug show BUG-001
31+
```
32+
33+
### bug update
34+
```bash
35+
canary bug update BUG-001 --status FIXED --resolution "Fixed memory leak"
36+
```
37+
38+
## Bug Token Format
39+
```
40+
// BUG: ID=BUG-###; TITLE="Description"; SEVERITY=HIGH; STATUS=OPEN; OWNER=team; CREATED=YYYY-MM-DD; UPDATED=YYYY-MM-DD
41+
```
42+
43+
## Bug Status Progression
44+
- **OPEN**: New bug reported
45+
- **IN_PROGRESS**: Being worked on
46+
- **FIXED**: Fix implemented
47+
- **VERIFIED**: Fix tested and verified
48+
- **CLOSED**: Completed
49+
50+
## Severity Levels
51+
- **CRITICAL**: System down, data loss
52+
- **HIGH**: Major functionality broken
53+
- **MEDIUM**: Feature partially working
54+
- **LOW**: Minor issue, cosmetic
55+
56+
## Standards
57+
- Separate BUG-XXX numbering from REQ-XXX
58+
- Track bug lifecycle with status updates
59+
- Link bugs to requirements when relevant
60+
- Store in same database as requirements

0 commit comments

Comments
 (0)