worktrees 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.claude/commands/plan.md +42 -0
- data/.claude/commands/specify.md +12 -0
- data/.claude/commands/tasks.md +60 -0
- data/.cursor/commands/plan.md +42 -0
- data/.cursor/commands/specify.md +12 -0
- data/.cursor/commands/tasks.md +60 -0
- data/.cursor/rules +81 -0
- data/.specify/memory/constitution-v1.0.1-formal.md +90 -0
- data/.specify/memory/constitution.md +153 -0
- data/.specify/memory/constitution_update_checklist.md +88 -0
- data/.specify/scripts/bash/check-task-prerequisites.sh +15 -0
- data/.specify/scripts/bash/common.sh +37 -0
- data/.specify/scripts/bash/create-new-feature.sh +58 -0
- data/.specify/scripts/bash/get-feature-paths.sh +7 -0
- data/.specify/scripts/bash/setup-plan.sh +17 -0
- data/.specify/scripts/bash/update-agent-context.sh +57 -0
- data/.specify/templates/agent-file-template.md +23 -0
- data/.specify/templates/plan-template.md +254 -0
- data/.specify/templates/spec-template.md +116 -0
- data/.specify/templates/tasks-template.md +152 -0
- data/CLAUDE.md +145 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +150 -0
- data/README.md +163 -0
- data/Rakefile +52 -0
- data/exe/worktrees +52 -0
- data/lib/worktrees/cli.rb +36 -0
- data/lib/worktrees/commands/create.rb +74 -0
- data/lib/worktrees/commands/list.rb +87 -0
- data/lib/worktrees/commands/remove.rb +62 -0
- data/lib/worktrees/commands/status.rb +95 -0
- data/lib/worktrees/commands/switch.rb +57 -0
- data/lib/worktrees/git_operations.rb +106 -0
- data/lib/worktrees/models/feature_worktree.rb +92 -0
- data/lib/worktrees/models/repository.rb +75 -0
- data/lib/worktrees/models/worktree_config.rb +74 -0
- data/lib/worktrees/version.rb +5 -0
- data/lib/worktrees/worktree_manager.rb +238 -0
- data/lib/worktrees.rb +27 -0
- data/specs/001-build-a-tool/GEMINI.md +20 -0
- data/specs/001-build-a-tool/contracts/cli-contracts.md +43 -0
- data/specs/001-build-a-tool/contracts/openapi.yaml +135 -0
- data/specs/001-build-a-tool/data-model.md +51 -0
- data/specs/001-build-a-tool/plan.md +241 -0
- data/specs/001-build-a-tool/quickstart.md +67 -0
- data/specs/001-build-a-tool/research.md +76 -0
- data/specs/001-build-a-tool/spec.md +153 -0
- data/specs/001-build-a-tool/tasks.md +209 -0
- metadata +138 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
JSON_MODE=false
|
|
4
|
+
for arg in "$@"; do case "$arg" in --json) JSON_MODE=true ;; --help|-h) echo "Usage: $0 [--json]"; exit 0 ;; esac; done
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
source "$SCRIPT_DIR/common.sh"
|
|
7
|
+
eval $(get_feature_paths)
|
|
8
|
+
check_feature_branch "$CURRENT_BRANCH" || exit 1
|
|
9
|
+
if [[ ! -d "$FEATURE_DIR" ]]; then echo "ERROR: Feature directory not found: $FEATURE_DIR"; echo "Run /specify first."; exit 1; fi
|
|
10
|
+
if [[ ! -f "$IMPL_PLAN" ]]; then echo "ERROR: plan.md not found in $FEATURE_DIR"; echo "Run /plan first."; exit 1; fi
|
|
11
|
+
if $JSON_MODE; then
|
|
12
|
+
docs=(); [[ -f "$RESEARCH" ]] && docs+=("research.md"); [[ -f "$DATA_MODEL" ]] && docs+=("data-model.md"); ([[ -d "$CONTRACTS_DIR" ]] && [[ -n "$(ls -A "$CONTRACTS_DIR" 2>/dev/null)" ]]) && docs+=("contracts/"); [[ -f "$QUICKSTART" ]] && docs+=("quickstart.md");
|
|
13
|
+
json_docs=$(printf '"%s",' "${docs[@]}"); json_docs="[${json_docs%,}]"; printf '{"FEATURE_DIR":"%s","AVAILABLE_DOCS":%s}\n' "$FEATURE_DIR" "$json_docs"
|
|
14
|
+
else
|
|
15
|
+
echo "FEATURE_DIR:$FEATURE_DIR"; echo "AVAILABLE_DOCS:"; check_file "$RESEARCH" "research.md"; check_file "$DATA_MODEL" "data-model.md"; check_dir "$CONTRACTS_DIR" "contracts/"; check_file "$QUICKSTART" "quickstart.md"; fi
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# (Moved to scripts/bash/) Common functions and variables for all scripts
|
|
3
|
+
|
|
4
|
+
get_repo_root() { git rev-parse --show-toplevel; }
|
|
5
|
+
get_current_branch() { git rev-parse --abbrev-ref HEAD; }
|
|
6
|
+
|
|
7
|
+
check_feature_branch() {
|
|
8
|
+
local branch="$1"
|
|
9
|
+
if [[ ! "$branch" =~ ^[0-9]{3}- ]]; then
|
|
10
|
+
echo "ERROR: Not on a feature branch. Current branch: $branch" >&2
|
|
11
|
+
echo "Feature branches should be named like: 001-feature-name" >&2
|
|
12
|
+
return 1
|
|
13
|
+
fi; return 0
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get_feature_dir() { echo "$1/specs/$2"; }
|
|
17
|
+
|
|
18
|
+
get_feature_paths() {
|
|
19
|
+
local repo_root=$(get_repo_root)
|
|
20
|
+
local current_branch=$(get_current_branch)
|
|
21
|
+
local feature_dir=$(get_feature_dir "$repo_root" "$current_branch")
|
|
22
|
+
cat <<EOF
|
|
23
|
+
REPO_ROOT='$repo_root'
|
|
24
|
+
CURRENT_BRANCH='$current_branch'
|
|
25
|
+
FEATURE_DIR='$feature_dir'
|
|
26
|
+
FEATURE_SPEC='$feature_dir/spec.md'
|
|
27
|
+
IMPL_PLAN='$feature_dir/plan.md'
|
|
28
|
+
TASKS='$feature_dir/tasks.md'
|
|
29
|
+
RESEARCH='$feature_dir/research.md'
|
|
30
|
+
DATA_MODEL='$feature_dir/data-model.md'
|
|
31
|
+
QUICKSTART='$feature_dir/quickstart.md'
|
|
32
|
+
CONTRACTS_DIR='$feature_dir/contracts'
|
|
33
|
+
EOF
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
check_file() { [[ -f "$1" ]] && echo " ✓ $2" || echo " ✗ $2"; }
|
|
37
|
+
check_dir() { [[ -d "$1" && -n $(ls -A "$1" 2>/dev/null) ]] && echo " ✓ $2" || echo " ✗ $2"; }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# (Moved to scripts/bash/) Create a new feature with branch, directory structure, and template
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
JSON_MODE=false
|
|
6
|
+
ARGS=()
|
|
7
|
+
for arg in "$@"; do
|
|
8
|
+
case "$arg" in
|
|
9
|
+
--json) JSON_MODE=true ;;
|
|
10
|
+
--help|-h) echo "Usage: $0 [--json] <feature_description>"; exit 0 ;;
|
|
11
|
+
*) ARGS+=("$arg") ;;
|
|
12
|
+
esac
|
|
13
|
+
done
|
|
14
|
+
|
|
15
|
+
FEATURE_DESCRIPTION="${ARGS[*]}"
|
|
16
|
+
if [ -z "$FEATURE_DESCRIPTION" ]; then
|
|
17
|
+
echo "Usage: $0 [--json] <feature_description>" >&2
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
22
|
+
SPECS_DIR="$REPO_ROOT/specs"
|
|
23
|
+
mkdir -p "$SPECS_DIR"
|
|
24
|
+
|
|
25
|
+
HIGHEST=0
|
|
26
|
+
if [ -d "$SPECS_DIR" ]; then
|
|
27
|
+
for dir in "$SPECS_DIR"/*; do
|
|
28
|
+
[ -d "$dir" ] || continue
|
|
29
|
+
dirname=$(basename "$dir")
|
|
30
|
+
number=$(echo "$dirname" | grep -o '^[0-9]\+' || echo "0")
|
|
31
|
+
number=$((10#$number))
|
|
32
|
+
if [ "$number" -gt "$HIGHEST" ]; then HIGHEST=$number; fi
|
|
33
|
+
done
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
NEXT=$((HIGHEST + 1))
|
|
37
|
+
FEATURE_NUM=$(printf "%03d" "$NEXT")
|
|
38
|
+
|
|
39
|
+
BRANCH_NAME=$(echo "$FEATURE_DESCRIPTION" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//')
|
|
40
|
+
WORDS=$(echo "$BRANCH_NAME" | tr '-' '\n' | grep -v '^$' | head -3 | tr '\n' '-' | sed 's/-$//')
|
|
41
|
+
BRANCH_NAME="${FEATURE_NUM}-${WORDS}"
|
|
42
|
+
|
|
43
|
+
git checkout -b "$BRANCH_NAME"
|
|
44
|
+
|
|
45
|
+
FEATURE_DIR="$SPECS_DIR/$BRANCH_NAME"
|
|
46
|
+
mkdir -p "$FEATURE_DIR"
|
|
47
|
+
|
|
48
|
+
TEMPLATE="$REPO_ROOT/templates/spec-template.md"
|
|
49
|
+
SPEC_FILE="$FEATURE_DIR/spec.md"
|
|
50
|
+
if [ -f "$TEMPLATE" ]; then cp "$TEMPLATE" "$SPEC_FILE"; else touch "$SPEC_FILE"; fi
|
|
51
|
+
|
|
52
|
+
if $JSON_MODE; then
|
|
53
|
+
printf '{"BRANCH_NAME":"%s","SPEC_FILE":"%s","FEATURE_NUM":"%s"}\n' "$BRANCH_NAME" "$SPEC_FILE" "$FEATURE_NUM"
|
|
54
|
+
else
|
|
55
|
+
echo "BRANCH_NAME: $BRANCH_NAME"
|
|
56
|
+
echo "SPEC_FILE: $SPEC_FILE"
|
|
57
|
+
echo "FEATURE_NUM: $FEATURE_NUM"
|
|
58
|
+
fi
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
4
|
+
source "$SCRIPT_DIR/common.sh"
|
|
5
|
+
eval $(get_feature_paths)
|
|
6
|
+
check_feature_branch "$CURRENT_BRANCH" || exit 1
|
|
7
|
+
echo "REPO_ROOT: $REPO_ROOT"; echo "BRANCH: $CURRENT_BRANCH"; echo "FEATURE_DIR: $FEATURE_DIR"; echo "FEATURE_SPEC: $FEATURE_SPEC"; echo "IMPL_PLAN: $IMPL_PLAN"; echo "TASKS: $TASKS"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
JSON_MODE=false
|
|
4
|
+
for arg in "$@"; do case "$arg" in --json) JSON_MODE=true ;; --help|-h) echo "Usage: $0 [--json]"; exit 0 ;; esac; done
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
source "$SCRIPT_DIR/common.sh"
|
|
7
|
+
eval $(get_feature_paths)
|
|
8
|
+
check_feature_branch "$CURRENT_BRANCH" || exit 1
|
|
9
|
+
mkdir -p "$FEATURE_DIR"
|
|
10
|
+
TEMPLATE="$REPO_ROOT/.specify/templates/plan-template.md"
|
|
11
|
+
[[ -f "$TEMPLATE" ]] && cp "$TEMPLATE" "$IMPL_PLAN"
|
|
12
|
+
if $JSON_MODE; then
|
|
13
|
+
printf '{"FEATURE_SPEC":"%s","IMPL_PLAN":"%s","SPECS_DIR":"%s","BRANCH":"%s"}\n' \
|
|
14
|
+
"$FEATURE_SPEC" "$IMPL_PLAN" "$FEATURE_DIR" "$CURRENT_BRANCH"
|
|
15
|
+
else
|
|
16
|
+
echo "FEATURE_SPEC: $FEATURE_SPEC"; echo "IMPL_PLAN: $IMPL_PLAN"; echo "SPECS_DIR: $FEATURE_DIR"; echo "BRANCH: $CURRENT_BRANCH"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
4
|
+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
5
|
+
FEATURE_DIR="$REPO_ROOT/specs/$CURRENT_BRANCH"
|
|
6
|
+
NEW_PLAN="$FEATURE_DIR/plan.md"
|
|
7
|
+
CLAUDE_FILE="$REPO_ROOT/CLAUDE.md"; GEMINI_FILE="$REPO_ROOT/GEMINI.md"; COPILOT_FILE="$REPO_ROOT/.github/copilot-instructions.md"
|
|
8
|
+
AGENT_TYPE="$1"
|
|
9
|
+
[ -f "$NEW_PLAN" ] || { echo "ERROR: No plan.md found at $NEW_PLAN"; exit 1; }
|
|
10
|
+
echo "=== Updating agent context files for feature $CURRENT_BRANCH ==="
|
|
11
|
+
NEW_LANG=$(grep "^**Language/Version**: " "$NEW_PLAN" 2>/dev/null | head -1 | sed 's/^**Language\/Version**: //' | grep -v "NEEDS CLARIFICATION" || echo "")
|
|
12
|
+
NEW_FRAMEWORK=$(grep "^**Primary Dependencies**: " "$NEW_PLAN" 2>/dev/null | head -1 | sed 's/^**Primary Dependencies**: //' | grep -v "NEEDS CLARIFICATION" || echo "")
|
|
13
|
+
NEW_DB=$(grep "^**Storage**: " "$NEW_PLAN" 2>/dev/null | head -1 | sed 's/^**Storage**: //' | grep -v "N/A" | grep -v "NEEDS CLARIFICATION" || echo "")
|
|
14
|
+
NEW_PROJECT_TYPE=$(grep "^**Project Type**: " "$NEW_PLAN" 2>/dev/null | head -1 | sed 's/^**Project Type**: //' || echo "")
|
|
15
|
+
update_agent_file() { local target_file="$1" agent_name="$2"; echo "Updating $agent_name context file: $target_file"; local temp_file=$(mktemp); if [ ! -f "$target_file" ]; then
|
|
16
|
+
echo "Creating new $agent_name context file..."; if [ -f "$REPO_ROOT/templates/agent-file-template.md" ]; then cp "$REPO_ROOT/templates/agent-file-template.md" "$temp_file"; else echo "ERROR: Template not found"; return 1; fi;
|
|
17
|
+
sed -i.bak "s/\[PROJECT NAME\]/$(basename $REPO_ROOT)/" "$temp_file"; sed -i.bak "s/\[DATE\]/$(date +%Y-%m-%d)/" "$temp_file"; sed -i.bak "s/\[EXTRACTED FROM ALL PLAN.MD FILES\]/- $NEW_LANG + $NEW_FRAMEWORK ($CURRENT_BRANCH)/" "$temp_file";
|
|
18
|
+
if [[ "$NEW_PROJECT_TYPE" == *"web"* ]]; then sed -i.bak "s|\[ACTUAL STRUCTURE FROM PLANS\]|backend/\nfrontend/\ntests/|" "$temp_file"; else sed -i.bak "s|\[ACTUAL STRUCTURE FROM PLANS\]|src/\ntests/|" "$temp_file"; fi;
|
|
19
|
+
if [[ "$NEW_LANG" == *"Python"* ]]; then COMMANDS="cd src && pytest && ruff check ."; elif [[ "$NEW_LANG" == *"Rust"* ]]; then COMMANDS="cargo test && cargo clippy"; elif [[ "$NEW_LANG" == *"JavaScript"* ]] || [[ "$NEW_LANG" == *"TypeScript"* ]]; then COMMANDS="npm test && npm run lint"; else COMMANDS="# Add commands for $NEW_LANG"; fi; sed -i.bak "s|\[ONLY COMMANDS FOR ACTIVE TECHNOLOGIES\]|$COMMANDS|" "$temp_file";
|
|
20
|
+
sed -i.bak "s|\[LANGUAGE-SPECIFIC, ONLY FOR LANGUAGES IN USE\]|$NEW_LANG: Follow standard conventions|" "$temp_file"; sed -i.bak "s|\[LAST 3 FEATURES AND WHAT THEY ADDED\]|- $CURRENT_BRANCH: Added $NEW_LANG + $NEW_FRAMEWORK|" "$temp_file"; rm "$temp_file.bak";
|
|
21
|
+
else
|
|
22
|
+
echo "Updating existing $agent_name context file..."; manual_start=$(grep -n "<!-- MANUAL ADDITIONS START -->" "$target_file" | cut -d: -f1); manual_end=$(grep -n "<!-- MANUAL ADDITIONS END -->" "$target_file" | cut -d: -f1); if [ -n "$manual_start" ] && [ -n "$manual_end" ]; then sed -n "${manual_start},${manual_end}p" "$target_file" > /tmp/manual_additions.txt; fi;
|
|
23
|
+
python3 - "$target_file" <<'EOF'
|
|
24
|
+
import re,sys,datetime
|
|
25
|
+
target=sys.argv[1]
|
|
26
|
+
with open(target) as f: content=f.read()
|
|
27
|
+
NEW_LANG="'$NEW_LANG'";NEW_FRAMEWORK="'$NEW_FRAMEWORK'";CURRENT_BRANCH="'$CURRENT_BRANCH'";NEW_DB="'$NEW_DB'";NEW_PROJECT_TYPE="'$NEW_PROJECT_TYPE'"
|
|
28
|
+
# Tech section
|
|
29
|
+
m=re.search(r'## Active Technologies\n(.*?)\n\n',content, re.DOTALL)
|
|
30
|
+
if m:
|
|
31
|
+
existing=m.group(1)
|
|
32
|
+
additions=[]
|
|
33
|
+
if '$NEW_LANG' and '$NEW_LANG' not in existing: additions.append(f"- $NEW_LANG + $NEW_FRAMEWORK ($CURRENT_BRANCH)")
|
|
34
|
+
if '$NEW_DB' and '$NEW_DB' not in existing and '$NEW_DB'!='N/A': additions.append(f"- $NEW_DB ($CURRENT_BRANCH)")
|
|
35
|
+
if additions:
|
|
36
|
+
new_block=existing+"\n"+"\n".join(additions)
|
|
37
|
+
content=content.replace(m.group(0),f"## Active Technologies\n{new_block}\n\n")
|
|
38
|
+
# Recent changes
|
|
39
|
+
m2=re.search(r'## Recent Changes\n(.*?)(\n\n|$)',content, re.DOTALL)
|
|
40
|
+
if m2:
|
|
41
|
+
lines=[l for l in m2.group(1).strip().split('\n') if l]
|
|
42
|
+
lines.insert(0,f"- $CURRENT_BRANCH: Added $NEW_LANG + $NEW_FRAMEWORK")
|
|
43
|
+
lines=lines[:3]
|
|
44
|
+
content=re.sub(r'## Recent Changes\n.*?(\n\n|$)', '## Recent Changes\n'+"\n".join(lines)+'\n\n', content, flags=re.DOTALL)
|
|
45
|
+
content=re.sub(r'Last updated: \d{4}-\d{2}-\d{2}', 'Last updated: '+datetime.datetime.now().strftime('%Y-%m-%d'), content)
|
|
46
|
+
open(target+'.tmp','w').write(content)
|
|
47
|
+
EOF
|
|
48
|
+
mv "$target_file.tmp" "$target_file"; if [ -f /tmp/manual_additions.txt ]; then sed -i.bak '/<!-- MANUAL ADDITIONS START -->/,/<!-- MANUAL ADDITIONS END -->/d' "$target_file"; cat /tmp/manual_additions.txt >> "$target_file"; rm /tmp/manual_additions.txt "$target_file.bak"; fi;
|
|
49
|
+
fi; mv "$temp_file" "$target_file" 2>/dev/null || true; echo "✅ $agent_name context file updated successfully"; }
|
|
50
|
+
case "$AGENT_TYPE" in
|
|
51
|
+
claude) update_agent_file "$CLAUDE_FILE" "Claude Code" ;;
|
|
52
|
+
gemini) update_agent_file "$GEMINI_FILE" "Gemini CLI" ;;
|
|
53
|
+
copilot) update_agent_file "$COPILOT_FILE" "GitHub Copilot" ;;
|
|
54
|
+
"") [ -f "$CLAUDE_FILE" ] && update_agent_file "$CLAUDE_FILE" "Claude Code"; [ -f "$GEMINI_FILE" ] && update_agent_file "$GEMINI_FILE" "Gemini CLI"; [ -f "$COPILOT_FILE" ] && update_agent_file "$COPILOT_FILE" "GitHub Copilot"; if [ ! -f "$CLAUDE_FILE" ] && [ ! -f "$GEMINI_FILE" ] && [ ! -f "$COPILOT_FILE" ]; then update_agent_file "$CLAUDE_FILE" "Claude Code"; fi ;;
|
|
55
|
+
*) echo "ERROR: Unknown agent type '$AGENT_TYPE'"; exit 1 ;;
|
|
56
|
+
esac
|
|
57
|
+
echo; echo "Summary of changes:"; [ -n "$NEW_LANG" ] && echo "- Added language: $NEW_LANG"; [ -n "$NEW_FRAMEWORK" ] && echo "- Added framework: $NEW_FRAMEWORK"; [ -n "$NEW_DB" ] && [ "$NEW_DB" != "N/A" ] && echo "- Added database: $NEW_DB"; echo; echo "Usage: $0 [claude|gemini|copilot]"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# [PROJECT NAME] Development Guidelines
|
|
2
|
+
|
|
3
|
+
Auto-generated from all feature plans. Last updated: [DATE]
|
|
4
|
+
|
|
5
|
+
## Active Technologies
|
|
6
|
+
[EXTRACTED FROM ALL PLAN.MD FILES]
|
|
7
|
+
|
|
8
|
+
## Project Structure
|
|
9
|
+
```
|
|
10
|
+
[ACTUAL STRUCTURE FROM PLANS]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
[ONLY COMMANDS FOR ACTIVE TECHNOLOGIES]
|
|
15
|
+
|
|
16
|
+
## Code Style
|
|
17
|
+
[LANGUAGE-SPECIFIC, ONLY FOR LANGUAGES IN USE]
|
|
18
|
+
|
|
19
|
+
## Recent Changes
|
|
20
|
+
[LAST 3 FEATURES AND WHAT THEY ADDED]
|
|
21
|
+
|
|
22
|
+
<!-- MANUAL ADDITIONS START -->
|
|
23
|
+
<!-- MANUAL ADDITIONS END -->
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Implementation Plan: [FEATURE]
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
**Branch**: `[###-feature-name]` | **Date**: [DATE] | **Spec**: [link]
|
|
5
|
+
**Input**: Feature specification from `/specs/[###-feature-name]/spec.md`
|
|
6
|
+
|
|
7
|
+
## Execution Flow (/plan command scope)
|
|
8
|
+
```
|
|
9
|
+
1. Load feature spec from Input path
|
|
10
|
+
→ If not found: ERROR "No feature spec at {path}"
|
|
11
|
+
2. Fill Technical Context (scan for NEEDS CLARIFICATION)
|
|
12
|
+
→ Detect Project Type from context (web=frontend+backend, mobile=app+api)
|
|
13
|
+
→ Set Structure Decision based on project type
|
|
14
|
+
3. Evaluate Constitution Check section below
|
|
15
|
+
→ If violations exist: Document in Complexity Tracking
|
|
16
|
+
→ If no justification possible: ERROR "Simplify approach first"
|
|
17
|
+
→ Update Progress Tracking: Initial Constitution Check
|
|
18
|
+
4. Execute Phase 0 → research.md
|
|
19
|
+
→ If NEEDS CLARIFICATION remain: ERROR "Resolve unknowns"
|
|
20
|
+
5. Execute Phase 1 → contracts, data-model.md, quickstart.md, agent-specific template file (e.g., `CLAUDE.md` for Claude Code, `.github/copilot-instructions.md` for GitHub Copilot, or `GEMINI.md` for Gemini CLI).
|
|
21
|
+
6. Re-evaluate Constitution Check section
|
|
22
|
+
→ If new violations: Refactor design, return to Phase 1
|
|
23
|
+
→ Update Progress Tracking: Post-Design Constitution Check
|
|
24
|
+
7. Plan Phase 2 → Describe task generation approach (DO NOT create tasks.md)
|
|
25
|
+
8. STOP - Ready for /tasks command
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**IMPORTANT**: The /plan command STOPS at step 7. Phases 2-4 are executed by other commands:
|
|
29
|
+
- Phase 2: /tasks command creates tasks.md
|
|
30
|
+
- Phase 3-4: Implementation execution (manual or via tools)
|
|
31
|
+
|
|
32
|
+
## Summary
|
|
33
|
+
[Extract from feature spec: primary requirement + technical approach from research]
|
|
34
|
+
|
|
35
|
+
## Technical Context
|
|
36
|
+
**Language/Version**: [Ruby 3.2+ for CLIs (Ruby First principle), or NEEDS CLARIFICATION]
|
|
37
|
+
**Primary Dependencies**: [e.g., dry-cli for Ruby CLIs, FastAPI, UIKit, LLVM or NEEDS CLARIFICATION]
|
|
38
|
+
**Storage**: [if applicable, e.g., PostgreSQL, CoreData, files or N/A]
|
|
39
|
+
**Testing**: [RSpec+Aruba for Ruby CLIs, pytest, XCTest, cargo test or NEEDS CLARIFICATION]
|
|
40
|
+
**Target Platform**: [e.g., Linux server, iOS 15+, WASM or NEEDS CLARIFICATION]
|
|
41
|
+
**Project Type**: [single/web/mobile - determines source structure]
|
|
42
|
+
**Performance Goals**: [domain-specific, e.g., 1000 req/s, 10k lines/sec, 60 fps or NEEDS CLARIFICATION]
|
|
43
|
+
**Constraints**: [domain-specific, e.g., <200ms p95, <100MB memory, offline-capable or NEEDS CLARIFICATION]
|
|
44
|
+
**Scale/Scope**: [domain-specific, e.g., 10k users, 1M LOC, 50 screens or NEEDS CLARIFICATION]
|
|
45
|
+
|
|
46
|
+
💡 **Technology Check** (following "Ruby First" and "Simple Over Clever"):
|
|
47
|
+
- CLI tools: Start with Ruby + dry-cli unless there's a specific reason not to
|
|
48
|
+
- If choosing something else: Explain why in Complexity Tracking
|
|
49
|
+
- Remember: "Life's too short for verbose languages when building personal tools"
|
|
50
|
+
|
|
51
|
+
## Development Principles Check
|
|
52
|
+
*Check before proceeding. Re-evaluate after design phase.*
|
|
53
|
+
|
|
54
|
+
**"Start Simple, Grow Thoughtfully"**:
|
|
55
|
+
- Starting as simple as possible? (avoid unnecessary complexity)
|
|
56
|
+
- Only adding what's actually needed? (not what might be needed)
|
|
57
|
+
- Clear focused purpose? (one thing well)
|
|
58
|
+
|
|
59
|
+
**"Ruby First" (for CLI tools)**:
|
|
60
|
+
- Using Ruby + proven libraries? (dry-cli, etc.)
|
|
61
|
+
- Leveraging Ruby ecosystem instead of reinventing?
|
|
62
|
+
- Language choice matches tool complexity?
|
|
63
|
+
|
|
64
|
+
**"Test-Driven Development is Fundamental"**:
|
|
65
|
+
- Planning to write tests first? (Red-Green-Refactor cycle)
|
|
66
|
+
- Testing real behavior? (actual files, services, edge cases)
|
|
67
|
+
- Using appropriate tools? (RSpec for logic, Aruba for CLI integration)
|
|
68
|
+
- Integration tests prioritized? (where CLI tools actually break)
|
|
69
|
+
|
|
70
|
+
**"Write It Like I'll Maintain It"**:
|
|
71
|
+
- Clear naming and structure planned?
|
|
72
|
+
- Reasonable documentation approach?
|
|
73
|
+
- Capturing why, not just what?
|
|
74
|
+
|
|
75
|
+
**"Fail Gracefully"**:
|
|
76
|
+
- Good error messages planned? (help debug faster)
|
|
77
|
+
- Reasonable defaults? (work without fiddling)
|
|
78
|
+
- Input validation? (catch problems early)
|
|
79
|
+
|
|
80
|
+
**"Help That Actually Helps"**:
|
|
81
|
+
- Clear help text planned? (--help should be useful)
|
|
82
|
+
- Good examples for common usage?
|
|
83
|
+
- Standard CLI conventions? (consistent with expectations)
|
|
84
|
+
|
|
85
|
+
## Project Structure
|
|
86
|
+
|
|
87
|
+
### Documentation (this feature)
|
|
88
|
+
```
|
|
89
|
+
specs/[###-feature]/
|
|
90
|
+
├── plan.md # This file (/plan command output)
|
|
91
|
+
├── research.md # Phase 0 output (/plan command)
|
|
92
|
+
├── data-model.md # Phase 1 output (/plan command)
|
|
93
|
+
├── quickstart.md # Phase 1 output (/plan command)
|
|
94
|
+
├── contracts/ # Phase 1 output (/plan command)
|
|
95
|
+
└── tasks.md # Phase 2 output (/tasks command - NOT created by /plan)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Source Code (repository root)
|
|
99
|
+
```
|
|
100
|
+
# Option 1: Single project (DEFAULT)
|
|
101
|
+
# For Ruby CLIs (following "Simple Over Clever"):
|
|
102
|
+
lib/
|
|
103
|
+
├── [project_name]/
|
|
104
|
+
│ ├── commands/ # CLI command classes
|
|
105
|
+
│ └── [domain_logic]/ # Core logic modules
|
|
106
|
+
exe/
|
|
107
|
+
└── [project_name] # CLI entry point
|
|
108
|
+
spec/
|
|
109
|
+
├── lib/ # Unit tests
|
|
110
|
+
└── features/ # Aruba integration tests
|
|
111
|
+
|
|
112
|
+
# For other languages:
|
|
113
|
+
src/
|
|
114
|
+
├── cli/
|
|
115
|
+
└── lib/
|
|
116
|
+
|
|
117
|
+
tests/
|
|
118
|
+
├── contract/
|
|
119
|
+
├── integration/
|
|
120
|
+
└── unit/
|
|
121
|
+
|
|
122
|
+
# Option 2: Web application (when "frontend" + "backend" detected)
|
|
123
|
+
backend/
|
|
124
|
+
├── src/
|
|
125
|
+
│ ├── models/
|
|
126
|
+
│ ├── services/
|
|
127
|
+
│ └── api/
|
|
128
|
+
└── tests/
|
|
129
|
+
|
|
130
|
+
frontend/
|
|
131
|
+
├── src/
|
|
132
|
+
│ ├── components/
|
|
133
|
+
│ ├── pages/
|
|
134
|
+
│ └── services/
|
|
135
|
+
└── tests/
|
|
136
|
+
|
|
137
|
+
# Option 3: Mobile + API (when "iOS/Android" detected)
|
|
138
|
+
api/
|
|
139
|
+
└── [same as backend above]
|
|
140
|
+
|
|
141
|
+
ios/ or android/
|
|
142
|
+
└── [platform-specific structure]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Structure Decision**: [DEFAULT to Option 1 unless Technical Context indicates web/mobile app]
|
|
146
|
+
|
|
147
|
+
## Phase 0: Outline & Research
|
|
148
|
+
1. **Extract unknowns from Technical Context** above:
|
|
149
|
+
- For each NEEDS CLARIFICATION → research task
|
|
150
|
+
- For each dependency → best practices task
|
|
151
|
+
- For each integration → patterns task
|
|
152
|
+
|
|
153
|
+
2. **Generate and dispatch research agents**:
|
|
154
|
+
```
|
|
155
|
+
For each unknown in Technical Context:
|
|
156
|
+
Task: "Research {unknown} for {feature context}"
|
|
157
|
+
For each technology choice:
|
|
158
|
+
Task: "Find best practices for {tech} in {domain}"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
3. **Consolidate findings** in `research.md` using format:
|
|
162
|
+
- Decision: [what was chosen]
|
|
163
|
+
- Rationale: [why chosen]
|
|
164
|
+
- Alternatives considered: [what else evaluated]
|
|
165
|
+
|
|
166
|
+
**Output**: research.md with all NEEDS CLARIFICATION resolved
|
|
167
|
+
|
|
168
|
+
## Phase 1: Design & Contracts
|
|
169
|
+
*Prerequisites: research.md complete*
|
|
170
|
+
|
|
171
|
+
1. **Extract entities from feature spec** → `data-model.md`:
|
|
172
|
+
- Entity name, fields, relationships
|
|
173
|
+
- Validation rules from requirements
|
|
174
|
+
- State transitions if applicable
|
|
175
|
+
|
|
176
|
+
2. **Generate API contracts** from functional requirements:
|
|
177
|
+
- For each user action → endpoint
|
|
178
|
+
- Use standard REST/GraphQL patterns
|
|
179
|
+
- Output OpenAPI/GraphQL schema to `/contracts/`
|
|
180
|
+
|
|
181
|
+
3. **Generate contract tests** from contracts:
|
|
182
|
+
- One test file per endpoint
|
|
183
|
+
- Assert request/response schemas
|
|
184
|
+
- Tests must fail (no implementation yet)
|
|
185
|
+
|
|
186
|
+
4. **Extract test scenarios** from user stories:
|
|
187
|
+
- Each story → integration test scenario
|
|
188
|
+
- Quickstart test = story validation steps
|
|
189
|
+
|
|
190
|
+
5. **Update agent file incrementally** (O(1) operation):
|
|
191
|
+
- Run `/scripts/bash/update-agent-context.sh cursor` for your AI assistant
|
|
192
|
+
- If exists: Add only NEW tech from current plan
|
|
193
|
+
- Preserve manual additions between markers
|
|
194
|
+
- Update recent changes (keep last 3)
|
|
195
|
+
- Keep under 150 lines for token efficiency
|
|
196
|
+
- Output to repository root
|
|
197
|
+
|
|
198
|
+
**Output**: data-model.md, /contracts/*, failing tests, quickstart.md, agent-specific file
|
|
199
|
+
|
|
200
|
+
## Phase 2: Task Planning Approach
|
|
201
|
+
*This section describes what the /tasks command will do - DO NOT execute during /plan*
|
|
202
|
+
|
|
203
|
+
**Task Generation Strategy**:
|
|
204
|
+
- Load `/templates/tasks-template.md` as base
|
|
205
|
+
- Generate tasks from Phase 1 design docs (contracts, data model, quickstart)
|
|
206
|
+
- Each contract → contract test task [P]
|
|
207
|
+
- Each entity → model creation task [P]
|
|
208
|
+
- Each user story → integration test task
|
|
209
|
+
- Implementation tasks to make tests pass
|
|
210
|
+
|
|
211
|
+
**Ordering Strategy**:
|
|
212
|
+
- TDD order: Tests before implementation
|
|
213
|
+
- Dependency order: Models before services before UI
|
|
214
|
+
- Mark [P] for parallel execution (independent files)
|
|
215
|
+
|
|
216
|
+
**Estimated Output**: 25-30 numbered, ordered tasks in tasks.md
|
|
217
|
+
|
|
218
|
+
**IMPORTANT**: This phase is executed by the /tasks command, NOT by /plan
|
|
219
|
+
|
|
220
|
+
## Phase 3+: Future Implementation
|
|
221
|
+
*These phases are beyond the scope of the /plan command*
|
|
222
|
+
|
|
223
|
+
**Phase 3**: Task execution (/tasks command creates tasks.md)
|
|
224
|
+
**Phase 4**: Implementation (execute tasks.md following constitutional principles)
|
|
225
|
+
**Phase 5**: Validation (run tests, execute quickstart.md, performance validation)
|
|
226
|
+
|
|
227
|
+
## Complexity Tracking
|
|
228
|
+
*Fill ONLY if Constitution Check has violations that must be justified*
|
|
229
|
+
|
|
230
|
+
| Violation | Why Needed | Simpler Alternative Rejected Because |
|
|
231
|
+
|-----------|------------|-------------------------------------|
|
|
232
|
+
| [e.g., 4th project] | [current need] | [why 3 projects insufficient] |
|
|
233
|
+
| [e.g., Repository pattern] | [specific problem] | [why direct DB access insufficient] |
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Progress Tracking
|
|
237
|
+
*This checklist is updated during execution flow*
|
|
238
|
+
|
|
239
|
+
**Phase Status**:
|
|
240
|
+
- [ ] Phase 0: Research complete (/plan command)
|
|
241
|
+
- [ ] Phase 1: Design complete (/plan command)
|
|
242
|
+
- [ ] Phase 2: Task planning complete (/plan command - describe approach only)
|
|
243
|
+
- [ ] Phase 3: Tasks generated (/tasks command)
|
|
244
|
+
- [ ] Phase 4: Implementation complete
|
|
245
|
+
- [ ] Phase 5: Validation passed
|
|
246
|
+
|
|
247
|
+
**Gate Status**:
|
|
248
|
+
- [ ] Initial Constitution Check: PASS
|
|
249
|
+
- [ ] Post-Design Constitution Check: PASS
|
|
250
|
+
- [ ] All NEEDS CLARIFICATION resolved
|
|
251
|
+
- [ ] Complexity deviations documented
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
*Based on Constitution v2.1.1 - See `/memory/constitution.md`*
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Feature Specification: [FEATURE NAME]
|
|
2
|
+
|
|
3
|
+
**Feature Branch**: `[###-feature-name]`
|
|
4
|
+
**Created**: [DATE]
|
|
5
|
+
**Status**: Draft
|
|
6
|
+
**Input**: User description: "$ARGUMENTS"
|
|
7
|
+
|
|
8
|
+
## Execution Flow (main)
|
|
9
|
+
```
|
|
10
|
+
1. Parse user description from Input
|
|
11
|
+
→ If empty: ERROR "No feature description provided"
|
|
12
|
+
2. Extract key concepts from description
|
|
13
|
+
→ Identify: actors, actions, data, constraints
|
|
14
|
+
3. For each unclear aspect:
|
|
15
|
+
→ Mark with [NEEDS CLARIFICATION: specific question]
|
|
16
|
+
4. Fill User Scenarios & Testing section
|
|
17
|
+
→ If no clear user flow: ERROR "Cannot determine user scenarios"
|
|
18
|
+
5. Generate Functional Requirements
|
|
19
|
+
→ Each requirement must be testable
|
|
20
|
+
→ Mark ambiguous requirements
|
|
21
|
+
6. Identify Key Entities (if data involved)
|
|
22
|
+
7. Run Review Checklist
|
|
23
|
+
→ If any [NEEDS CLARIFICATION]: WARN "Spec has uncertainties"
|
|
24
|
+
→ If implementation details found: ERROR "Remove tech details"
|
|
25
|
+
8. Return: SUCCESS (spec ready for planning)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ⚡ Quick Guidelines
|
|
31
|
+
- ✅ Focus on WHAT users need and WHY
|
|
32
|
+
- ❌ Avoid HOW to implement (no tech stack, APIs, code structure)
|
|
33
|
+
- 👥 Written for business stakeholders, not developers
|
|
34
|
+
|
|
35
|
+
### Section Requirements
|
|
36
|
+
- **Mandatory sections**: Must be completed for every feature
|
|
37
|
+
- **Optional sections**: Include only when relevant to the feature
|
|
38
|
+
- When a section doesn't apply, remove it entirely (don't leave as "N/A")
|
|
39
|
+
|
|
40
|
+
### For AI Generation
|
|
41
|
+
When creating this spec from a user prompt:
|
|
42
|
+
1. **Mark all ambiguities**: Use [NEEDS CLARIFICATION: specific question] for any assumption you'd need to make
|
|
43
|
+
2. **Don't guess**: If the prompt doesn't specify something (e.g., "login system" without auth method), mark it
|
|
44
|
+
3. **Think like a tester**: Every vague requirement should fail the "testable and unambiguous" checklist item
|
|
45
|
+
4. **Common underspecified areas**:
|
|
46
|
+
- User types and permissions
|
|
47
|
+
- Data retention/deletion policies
|
|
48
|
+
- Performance targets and scale
|
|
49
|
+
- Error handling behaviors
|
|
50
|
+
- Integration requirements
|
|
51
|
+
- Security/compliance needs
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## User Scenarios & Testing *(mandatory)*
|
|
56
|
+
|
|
57
|
+
### Primary User Story
|
|
58
|
+
[Describe the main user journey in plain language]
|
|
59
|
+
|
|
60
|
+
### Acceptance Scenarios
|
|
61
|
+
1. **Given** [initial state], **When** [action], **Then** [expected outcome]
|
|
62
|
+
2. **Given** [initial state], **When** [action], **Then** [expected outcome]
|
|
63
|
+
|
|
64
|
+
### Edge Cases
|
|
65
|
+
- What happens when [boundary condition]?
|
|
66
|
+
- How does system handle [error scenario]?
|
|
67
|
+
|
|
68
|
+
## Requirements *(mandatory)*
|
|
69
|
+
|
|
70
|
+
### Functional Requirements
|
|
71
|
+
- **FR-001**: System MUST [specific capability, e.g., "allow users to create accounts"]
|
|
72
|
+
- **FR-002**: System MUST [specific capability, e.g., "validate email addresses"]
|
|
73
|
+
- **FR-003**: Users MUST be able to [key interaction, e.g., "reset their password"]
|
|
74
|
+
- **FR-004**: System MUST [data requirement, e.g., "persist user preferences"]
|
|
75
|
+
- **FR-005**: System MUST [behavior, e.g., "log all security events"]
|
|
76
|
+
|
|
77
|
+
*Example of marking unclear requirements:*
|
|
78
|
+
- **FR-006**: System MUST authenticate users via [NEEDS CLARIFICATION: auth method not specified - email/password, SSO, OAuth?]
|
|
79
|
+
- **FR-007**: System MUST retain user data for [NEEDS CLARIFICATION: retention period not specified]
|
|
80
|
+
|
|
81
|
+
### Key Entities *(include if feature involves data)*
|
|
82
|
+
- **[Entity 1]**: [What it represents, key attributes without implementation]
|
|
83
|
+
- **[Entity 2]**: [What it represents, relationships to other entities]
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Review & Acceptance Checklist
|
|
88
|
+
*GATE: Automated checks run during main() execution*
|
|
89
|
+
|
|
90
|
+
### Content Quality
|
|
91
|
+
- [ ] No implementation details (languages, frameworks, APIs)
|
|
92
|
+
- [ ] Focused on user value and business needs
|
|
93
|
+
- [ ] Written for non-technical stakeholders
|
|
94
|
+
- [ ] All mandatory sections completed
|
|
95
|
+
|
|
96
|
+
### Requirement Completeness
|
|
97
|
+
- [ ] No [NEEDS CLARIFICATION] markers remain
|
|
98
|
+
- [ ] Requirements are testable and unambiguous
|
|
99
|
+
- [ ] Success criteria are measurable
|
|
100
|
+
- [ ] Scope is clearly bounded
|
|
101
|
+
- [ ] Dependencies and assumptions identified
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Execution Status
|
|
106
|
+
*Updated by main() during processing*
|
|
107
|
+
|
|
108
|
+
- [ ] User description parsed
|
|
109
|
+
- [ ] Key concepts extracted
|
|
110
|
+
- [ ] Ambiguities marked
|
|
111
|
+
- [ ] User scenarios defined
|
|
112
|
+
- [ ] Requirements generated
|
|
113
|
+
- [ ] Entities identified
|
|
114
|
+
- [ ] Review checklist passed
|
|
115
|
+
|
|
116
|
+
---
|