Skip to content

Commit 0f85f74

Browse files
committed
docs(core): standardize ticket workflow
- Update WORKFLOW.md with Epic and Task templates - Add scripts/gh-issue-add-subs.sh helper utility - Mandate ticket creation before implementation
1 parent 2e72ddc commit 0f85f74

File tree

2 files changed

+211
-7
lines changed

2 files changed

+211
-7
lines changed

WORKFLOW.md

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,57 @@ Standard workflow for implementing features in doc-agent.
44

55
## The Drill™
66

7-
### 1. Find Next Work (Dogfooding! 🐕🍽️)
7+
### 1. Ticket Creation (Required)
8+
9+
Before writing any code, ensure a ticket exists for the work.
10+
11+
- **Small Changes**: A simple Issue is sufficient.
12+
- **Large Features**: Create an **Epic** and break it down into **Implementation Tasks**.
13+
- **No Ticket?**: Create one using the templates below.
14+
15+
#### Epic Ticket Template
16+
```markdown
17+
# Epic: [Name]
18+
19+
## 🎯 Overview
20+
High-level goal and key insights. "Why are we doing this?"
21+
22+
## 🏗️ Architecture
23+
Core components and user flow.
24+
25+
## 📋 Sub-Issues
26+
Breakdown of work into implementation tasks.
27+
- Task 1: Foundation
28+
- Task 2: Feature
29+
- Task 3: Integration
30+
31+
*(Note: Use `scripts/gh-issue-add-subs.sh` to link child tasks to the Epic)*
32+
33+
## ✅ Success Criteria
34+
- [ ] Checklist of deliverables
35+
```
36+
37+
#### Implementation Ticket Template
38+
```markdown
39+
## Title: [Task/Feature] Name
40+
41+
**Context**
42+
Why is this specific piece needed?
43+
44+
**Architecture Decisions**
45+
- Package: e.g., `packages/storage`
46+
- Tech: e.g., `better-sqlite3`
47+
- Patterns: e.g., Repository Pattern, Lazy Init
48+
49+
**Requirements**
50+
- [ ] Requirement 1
51+
- [ ] Requirement 2
52+
53+
**References**
54+
- Epic: #1
55+
```
56+
57+
### 2. Find Next Work (Dogfooding! 🐕🍽️)
858

959
```bash
1060
# Update main branch
@@ -15,7 +65,7 @@ git pull origin main
1565
# (Coming soon: doc-agent issue search)
1666
```
1767

18-
### 2. Start New Feature
68+
### 3. Start New Feature
1969

2070
```bash
2171
# Create feature branch (use feat/, fix/, docs/, etc.)
@@ -25,7 +75,7 @@ git checkout -b feat/feature-name
2575
# Done via todo_write tool
2676
```
2777

28-
### 3. Planning Phase
78+
### 4. Planning Phase
2979

3080
```bash
3181
# Read the issue requirements
@@ -41,15 +91,15 @@ git checkout -b feat/feature-name
4191
- [ ] Create README if new module
4292
- [ ] Update related documentation
4393

44-
### 4. Implementation Phase
94+
### 5. Implementation Phase
4595

4696
```bash
4797
# Design interfaces first (in comments or types)
4898
# Implement with test-driven development
4999
# Document with examples as you go
50100
```
51101

52-
### 5. Quality Checks
102+
### 6. Quality Checks
53103

54104
```bash
55105
# Build all packages
@@ -77,7 +127,7 @@ pnpm typecheck
77127
- ✅ No TypeScript errors
78128
- ✅ Documentation with examples
79129

80-
### 6. Commit & PR
130+
### 7. Commit & PR
81131

82132
```bash
83133
# Stage all changes
@@ -137,6 +187,7 @@ Issue: #<number>
137187
- `cli`: Command-line interface
138188
- `core`: Core functionality
139189
- `extract`: Extraction logic
190+
- `storage`: Database & Persistence
140191
- `vector`: Vector storage
141192
- `mcp`: MCP Server integration
142193

@@ -176,4 +227,3 @@ Issue: #<number>
176227
- ❌ Type definitions (TypeScript handles this)
177228
- ❌ External library behavior
178229
- ❌ Private implementation details (test through public API)
179-

scripts/gh-issue-add-subs.sh

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/bin/bash
2+
#
3+
# gh-issue-add-subs - Add multiple sub-issues to a parent issue
4+
#
5+
# Usage:
6+
# gh-issue-add-subs <parent-issue-number> <child-issue-number>...
7+
#
8+
# Description:
9+
# This script adds multiple existing issues as sub-issues to a parent issue
10+
# using GitHub's GraphQL API. All relationships are created in a single
11+
# batched GraphQL request for efficiency.
12+
#
13+
# Examples:
14+
# # Add issues #52, #53, #54 as sub-issues of #31
15+
# gh-issue-add-subs 31 52 53 54
16+
#
17+
# # Add a single sub-issue
18+
# gh-issue-add-subs 31 52
19+
#
20+
# Requirements:
21+
# - GitHub CLI (gh) installed and authenticated
22+
# - Issues must exist in the current repository
23+
#
24+
# Exit codes:
25+
# 0 - Success
26+
# 1 - Missing required arguments
27+
# 2 - Failed to get parent issue ID
28+
# 3 - Failed to get child issue ID
29+
# 4 - GraphQL mutation failed
30+
31+
set -euo pipefail
32+
33+
# Colors for output
34+
RED='\033[0;31m'
35+
GREEN='\033[0;32m'
36+
YELLOW='\033[1;33m'
37+
NC='\033[0m' # No Color
38+
39+
# Print usage
40+
usage() {
41+
cat << EOF
42+
Usage: $0 <parent-issue-number> <child-issue-number>...
43+
44+
Add multiple sub-issues to a parent issue using GitHub's GraphQL API.
45+
46+
Arguments:
47+
parent-issue-number The issue number of the parent issue
48+
child-issue-number... One or more issue numbers to add as sub-issues
49+
50+
Examples:
51+
$0 31 52 53 54
52+
$0 31 52
53+
54+
EOF
55+
}
56+
57+
# Check if GitHub CLI is available
58+
if ! command -v gh &> /dev/null; then
59+
echo -e "${RED}Error: GitHub CLI (gh) is not installed${NC}" >&2
60+
echo "Install it from https://cli.github.com/" >&2
61+
exit 1
62+
fi
63+
64+
# Check arguments
65+
if [ $# -lt 2 ]; then
66+
echo -e "${RED}Error: Missing required arguments${NC}" >&2
67+
usage
68+
exit 1
69+
fi
70+
71+
parent=$1
72+
shift
73+
children=("$@")
74+
75+
echo -e "${YELLOW}Adding ${#children[@]} sub-issue(s) to issue #${parent}...${NC}"
76+
77+
# Get parent issue ID
78+
echo "Fetching parent issue #${parent}..."
79+
parent_id=$(gh issue view "$parent" --json id -q .id 2>/dev/null || true)
80+
81+
if [ -z "$parent_id" ]; then
82+
echo -e "${RED}Error: Failed to get parent issue #${parent}${NC}" >&2
83+
echo "Make sure the issue exists and you have access to it." >&2
84+
exit 2
85+
fi
86+
87+
# Build GraphQL mutation with aliases for each child
88+
mutation="mutation {"
89+
i=1
90+
child_ids=()
91+
92+
for child in "${children[@]}"; do
93+
echo "Fetching child issue #${child}..."
94+
child_id=$(gh issue view "$child" --json id -q .id 2>/dev/null || true)
95+
96+
if [ -z "$child_id" ]; then
97+
echo -e "${RED}Error: Failed to get child issue #${child}${NC}" >&2
98+
echo "Make sure the issue exists and you have access to it." >&2
99+
exit 3
100+
fi
101+
102+
child_ids+=("$child_id")
103+
104+
# Add mutation with unique alias
105+
mutation+="
106+
add$i: addSubIssue(input: {
107+
issueId: \"$parent_id\"
108+
subIssueId: \"$child_id\"
109+
}) {
110+
issue {
111+
number
112+
title
113+
}
114+
subIssue {
115+
number
116+
title
117+
}
118+
}"
119+
((i++))
120+
done
121+
122+
mutation+="
123+
}"
124+
125+
# Execute GraphQL mutation
126+
echo -e "${YELLOW}Creating relationships...${NC}"
127+
response=$(gh api graphql -f query="$mutation" 2>&1)
128+
129+
# Check for errors in response
130+
if echo "$response" | grep -q '"errors"'; then
131+
echo -e "${RED}Error: GraphQL mutation failed${NC}" >&2
132+
echo "$response" | jq '.' >&2 || echo "$response" >&2
133+
exit 4
134+
fi
135+
136+
# Parse and display results
137+
echo -e "${GREEN}✓ Successfully added sub-issues:${NC}"
138+
i=1
139+
for child in "${children[@]}"; do
140+
result=$(echo "$response" | jq -r ".data.add$i.subIssue.number // empty" 2>/dev/null || echo "")
141+
if [ -n "$result" ]; then
142+
title=$(echo "$response" | jq -r ".data.add$i.subIssue.title // \"\"" 2>/dev/null || echo "")
143+
echo -e " ${GREEN}${NC} Issue #${child} → Sub-issue of #${parent}"
144+
if [ -n "$title" ]; then
145+
echo " \"$title\""
146+
fi
147+
else
148+
echo -e " ${YELLOW}${NC} Issue #${child} (may already be a sub-issue)"
149+
fi
150+
((i++))
151+
done
152+
153+
echo -e "\n${GREEN}Done!${NC} View issue #${parent} on GitHub to see the relationships."
154+

0 commit comments

Comments
 (0)