-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-template.sh
More file actions
executable file
·283 lines (240 loc) · 9.68 KB
/
Copy pathsetup-template.sh
File metadata and controls
executable file
·283 lines (240 loc) · 9.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/bash
# Organized Codebase Template Setup Script
# This script helps set up the template structure for a new project
set -e # Exit on any error
echo "🚀 Setting up Organized Codebase Template..."
# Get project name from user
if [ -z "$1" ]; then
read -p "Enter your project name: " PROJECT_NAME
else
PROJECT_NAME="$1"
fi
# Validate project name
if [ -z "$PROJECT_NAME" ]; then
echo "❌ Error: Project name cannot be empty"
exit 1
fi
echo "📁 Creating project directory: $PROJECT_NAME"
# Get the script's directory (Organized Codebase location)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Set target directory to parent Windsurf directory
TARGET_DIR="$(dirname "$SCRIPT_DIR")/$PROJECT_NAME"
# Create project directory in the Windsurf parent directory
mkdir -p "$TARGET_DIR"
cd "$TARGET_DIR"
echo "📋 Creating directory structure..."
# Create all necessary directories
mkdir -p PLANNING
mkdir -p ARCHITECTURE
mkdir -p DOCUMENTATION
mkdir -p SPECIFICATIONS
mkdir -p AGENT-HANDOFF
mkdir -p PROJECT-FILES
mkdir -p ITERATIONS/v1-mvp
mkdir -p ITERATIONS/v2-enhancements
mkdir -p ITERATIONS/v3-scaling
echo "📝 Copying template files..."
# Copy template files from the organized-codebase repository
# Note: This assumes you have the organized-codebase template available
# Use the Organized Codebase directory as the template source
TEMPLATE_DIR="$SCRIPT_DIR"
# Copy all template files
cp -r "$TEMPLATE_DIR"/PLANNING/* PLANNING/ 2>/dev/null || echo "⚠️ Planning templates not found"
cp -r "$TEMPLATE_DIR"/ARCHITECTURE/* ARCHITECTURE/ 2>/dev/null || echo "⚠️ Architecture templates not found"
cp -r "$TEMPLATE_DIR"/DOCUMENTATION/* DOCUMENTATION/ 2>/dev/null || echo "⚠️ Documentation templates not found"
cp -r "$TEMPLATE_DIR"/SPECIFICATIONS/* SPECIFICATIONS/ 2>/dev/null || echo "⚠️ Specifications templates not found"
cp -r "$TEMPLATE_DIR"/AGENT-HANDOFF/* AGENT-HANDOFF/ 2>/dev/null || echo "⚠️ Agent handoff templates not found"
cp -r "$TEMPLATE_DIR"/PROJECT-FILES/* PROJECT-FILES/ 2>/dev/null || echo "⚠️ Project files not found"
# Copy DevContainer configuration
cp -r "$TEMPLATE_DIR"/.devcontainer . 2>/dev/null && echo "✅ Copied DevContainer configuration" || echo "⚠️ DevContainer not found"
# Copy automation scripts
mkdir -p scripts
cp -r "$TEMPLATE_DIR"/scripts/* scripts/ 2>/dev/null && echo "✅ Copied automation scripts" || echo "⚠️ Scripts not found"
# Copy CONFIG documentation (optional - for reference)
cp -r "$TEMPLATE_DIR"/CONFIG . 2>/dev/null && echo "✅ Copied CONFIG documentation" || echo "⚠️ CONFIG not found"
# Copy .ai directory (token tracking and AI assistance tools)
cp -r "$TEMPLATE_DIR"/.ai . 2>/dev/null && echo "✅ Copied AI token tracking system" || echo "⚠️ .ai directory not found"
# Copy .claude directory (hooks and configurations)
cp -r "$TEMPLATE_DIR"/.claude . 2>/dev/null && echo "✅ Copied Claude hooks directory" || echo "⚠️ .claude directory not found"
# Copy README and other root files
cp "$TEMPLATE_DIR"/README.md . 2>/dev/null || echo "⚠️ README template not found"
echo "🔧 Customizing templates with project name..."
# Replace placeholder project names in files
find . -name "*.md" -type f -exec sed -i.bak "s/\[Your Project Name\]/$PROJECT_NAME/g" {} \;
find . -name "*.md" -type f -exec sed -i.bak "s/your-project-name/$PROJECT_NAME/g" {} \;
# Clean up backup files created by sed
find . -name "*.bak" -delete
echo "📦 Setting up environment file..."
# Copy .env.example from template root
if [ -f "$TEMPLATE_DIR/.env.example" ]; then
cp "$TEMPLATE_DIR/.env.example" .env.example
cp "$TEMPLATE_DIR/.env.example" .env
echo "✅ Created .env.example and .env files"
echo "⚠️ Remember to update .env with your ANTHROPIC_API_KEY and other values"
else
echo "⚠️ No .env.example found in template"
fi
echo "📄 Creating additional project files..."
# Create package.json if it doesn't exist
if [ ! -f "package.json" ]; then
cat > package.json << EOL
{
"name": "$(echo $PROJECT_NAME | tr '[:upper:]' '[:lower:]' | tr ' ' '-')",
"version": "1.0.0",
"description": "$PROJECT_NAME - Built with Organized Codebase Template",
"main": "index.js",
"scripts": {
"dev": "echo 'Add your development server command here'",
"build": "echo 'Add your build command here'",
"test": "echo 'Add your test command here'",
"start": "echo 'Add your start command here'",
"agent:setup": "node scripts/setup-agent.js"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.30.1"
},
"devDependencies": {
"@codevibesmatter/kata": "^0.3.0"
},
"keywords": [],
"author": "",
"license": "MIT"
}
EOL
echo "✅ Created package.json template with Claude Agent SDK"
fi
# Create .gitignore if it doesn't exist
if [ ! -f ".gitignore" ]; then
cat > .gitignore << EOL
# Dependencies
node_modules/
*/node_modules/
# Environment variables
.env
.env.local
.env.*.local
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Coverage directory used by tools like istanbul
coverage/
*.lcov
# Build outputs
dist/
build/
*.tgz
*.tar.gz
# IDE files
.vscode/
.idea/
*.swp
*.swo
*~
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Database
*.sqlite
*.db
# Temporary files
tmp/
temp/
EOL
echo "✅ Created .gitignore file"
fi
echo "🎯 Initializing git repository..."
# Initialize git repository if not already initialized
if [ ! -d ".git" ]; then
git init
git add .
git commit -m "Initial commit: Add Organized Codebase Template structure
- Added planning documents (project brief, requirements, architecture, user stories, roadmap)
- Added architecture documentation (system design, data models, tech stack)
- Added specifications (functional specs, technical specs, testing strategy)
- Added agent handoff instructions (coding instructions, file structure, dependencies, completion checklist)
- Added project configuration files and templates
- Set up development environment structure
Ready for feature development and AI agent handoff."
echo "✅ Git repository initialized with initial commit"
else
echo "ℹ️ Git repository already exists"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🎉 Template setup complete for: $PROJECT_NAME"
echo "📁 Project location: $(pwd)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "🚀 QUICK START OPTIONS:"
echo ""
echo "Option 1: Manual Setup (Traditional)"
echo " 1. 📝 Fill out PLANNING/01-project-brief.md"
echo " 2. 📋 Complete PLANNING/02-requirements.md"
echo " 3. 🏗️ Define PLANNING/03-architecture.md"
echo " 4. 🔧 Update .env with your API keys"
echo " 5. 📦 Run: npm install"
echo ""
echo "Option 2: 🤖 AI-POWERED SETUP (Recommended!)"
echo " 1. 📝 Fill out PLANNING/01-project-brief.md (basic info)"
echo " 2. Set your API key: export ANTHROPIC_API_KEY='your-key'"
echo " 3. Run: npm install"
echo " 4. Run: npx kata setup --batteries --strict"
echo " 5. Run: npm run agent:setup"
echo " 6. ✨ Let Claude Agent SDK configure everything!"
echo ""
echo "Option 3: DevContainer (Isolated Environment)"
echo " 1. Open folder in VS Code"
echo " 2. Click 'Reopen in Container'"
echo " 3. Container auto-configures with Node 20, Python 3.11"
echo " 4. Run: npm run agent:setup"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "💡 OPTIONAL: Automated Token Tracking"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📊 Track token usage across all projects (one-time setup):"
echo ""
echo " bash scripts/setup-cron.sh"
echo ""
echo "This installs a system-wide hourly cron job that:"
echo " • Tracks Opus 4, Sonnet 4, Haiku 4 usage"
echo " • Updates ~/.claude/token-tracker.json hourly"
echo " • Works across ALL your Claude Code projects"
echo " • Only needs to be run ONCE per system"
echo ""
echo "📝 Manual tracking (without cron):"
echo " node scripts/update-token-tracker.js"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🎯 PRESERVE OPUS BUDGET - Use this workflow:"
echo ""
echo " Planning Phase (Use Sonnet 4.5):"
echo " • Initial brainstorming: 10-15k tokens"
echo " • Architecture drafting: 15-20k tokens"
echo " • Roadmap creation: 10-15k tokens"
echo " Cost: ~\$0.15-0.20"
echo ""
echo " Review Phase (Use Opus 4 strategically):"
echo " • Security validation: 5-10k tokens"
echo " • Architecture approval: 5-10k tokens"
echo " Cost: ~\$0.15-0.25"
echo ""
echo " 💰 Total planning: \$0.30-0.45 vs \$1-2 with all-Opus!"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "💡 Pro tip: Option 2 (AI-powered) can save 30-60 minutes!"
echo "📚 For help: https://github.com/Organized-AI/organized-codebase"
echo "📊 Token tracking docs: scripts/README.md"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"