@theglitchking/persistent-planning 1.0.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.
- package/.claude/commands/start-planning.md +65 -0
- package/.claude/settings.local.json +13 -0
- package/.claude-plugin/plugin.json +21 -0
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/bin/persistent-planning.js +241 -0
- package/docs/examples.md +221 -0
- package/docs/reference.md +110 -0
- package/package.json +55 -0
- package/postinstall.js +34 -0
- package/scripts/init-planning.sh +233 -0
- package/skills/SKILL.md +267 -0
package/docs/examples.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Examples: Persistent Planning in Action
|
|
2
|
+
|
|
3
|
+
## Example 1: Research Task
|
|
4
|
+
|
|
5
|
+
**User Request:** "Research the benefits of morning exercise and write a summary"
|
|
6
|
+
|
|
7
|
+
### Loop 0: Setup
|
|
8
|
+
```bash
|
|
9
|
+
/start-planning "Morning exercise benefits research"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Loop 1: Create Plan
|
|
13
|
+
```bash
|
|
14
|
+
Write .planning/morning-exercise-benefits-research/task_plan.md
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```markdown
|
|
18
|
+
# Task Plan: Morning Exercise Benefits Research
|
|
19
|
+
|
|
20
|
+
## Goal
|
|
21
|
+
Create a research summary on the benefits of morning exercise.
|
|
22
|
+
|
|
23
|
+
## Phases
|
|
24
|
+
- [ ] Phase 1: Create this plan
|
|
25
|
+
- [ ] Phase 2: Search and gather sources
|
|
26
|
+
- [ ] Phase 3: Synthesize findings
|
|
27
|
+
- [ ] Phase 4: Deliver summary
|
|
28
|
+
|
|
29
|
+
## Key Questions
|
|
30
|
+
1. What are the physical health benefits?
|
|
31
|
+
2. What are the mental health benefits?
|
|
32
|
+
3. What scientific studies support this?
|
|
33
|
+
|
|
34
|
+
## Status
|
|
35
|
+
**Currently in Phase 1** - Creating plan
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Loop 2: Research
|
|
39
|
+
```bash
|
|
40
|
+
Read .planning/morning-exercise-benefits-research/task_plan.md # Refresh goals
|
|
41
|
+
WebSearch "morning exercise benefits"
|
|
42
|
+
Write .planning/morning-exercise-benefits-research/notes.md # Store findings
|
|
43
|
+
Edit .planning/morning-exercise-benefits-research/task_plan.md # Mark Phase 2 complete
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Loop 3: Synthesize
|
|
47
|
+
```bash
|
|
48
|
+
Read .planning/morning-exercise-benefits-research/task_plan.md # Refresh goals
|
|
49
|
+
Read .planning/morning-exercise-benefits-research/notes.md # Get findings
|
|
50
|
+
Write morning_exercise_summary.md # Deliverable
|
|
51
|
+
Edit .planning/morning-exercise-benefits-research/task_plan.md # Mark Phase 3 complete
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Loop 4: Deliver
|
|
55
|
+
```bash
|
|
56
|
+
Read .planning/morning-exercise-benefits-research/task_plan.md # Verify complete
|
|
57
|
+
Deliver morning_exercise_summary.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Example 2: Bug Fix Task
|
|
63
|
+
|
|
64
|
+
**User Request:** "Fix the login bug in the authentication module"
|
|
65
|
+
|
|
66
|
+
### .planning/fix-login-bug/task_plan.md
|
|
67
|
+
```markdown
|
|
68
|
+
# Task Plan: Fix Login Bug
|
|
69
|
+
|
|
70
|
+
## Goal
|
|
71
|
+
Identify and fix the bug preventing successful login.
|
|
72
|
+
|
|
73
|
+
## Phases
|
|
74
|
+
- [x] Phase 1: Understand the bug report
|
|
75
|
+
- [x] Phase 2: Locate relevant code
|
|
76
|
+
- [ ] Phase 3: Identify root cause (CURRENT)
|
|
77
|
+
- [ ] Phase 4: Implement fix
|
|
78
|
+
- [ ] Phase 5: Test and verify
|
|
79
|
+
|
|
80
|
+
## Key Questions
|
|
81
|
+
1. What error message appears?
|
|
82
|
+
2. Which file handles authentication?
|
|
83
|
+
3. What changed recently?
|
|
84
|
+
|
|
85
|
+
## Decisions Made
|
|
86
|
+
- Auth handler is in src/auth/login.ts
|
|
87
|
+
- Error occurs in validateToken() function
|
|
88
|
+
|
|
89
|
+
## Errors Encountered
|
|
90
|
+
- [Initial] TypeError: Cannot read property 'token' of undefined
|
|
91
|
+
-> Root cause: user object not awaited properly
|
|
92
|
+
|
|
93
|
+
## Status
|
|
94
|
+
**Currently in Phase 3** - Found root cause, preparing fix
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Example 3: Feature Development
|
|
100
|
+
|
|
101
|
+
**User Request:** "Add a dark mode toggle to the settings page"
|
|
102
|
+
|
|
103
|
+
### The 3-File Pattern in Action
|
|
104
|
+
|
|
105
|
+
**.planning/add-dark-mode/task_plan.md:**
|
|
106
|
+
```markdown
|
|
107
|
+
# Task Plan: Dark Mode Toggle
|
|
108
|
+
|
|
109
|
+
## Goal
|
|
110
|
+
Add functional dark mode toggle to settings.
|
|
111
|
+
|
|
112
|
+
## Phases
|
|
113
|
+
- [x] Phase 1: Research existing theme system
|
|
114
|
+
- [x] Phase 2: Design implementation approach
|
|
115
|
+
- [ ] Phase 3: Implement toggle component (CURRENT)
|
|
116
|
+
- [ ] Phase 4: Add theme switching logic
|
|
117
|
+
- [ ] Phase 5: Test and polish
|
|
118
|
+
|
|
119
|
+
## Decisions Made
|
|
120
|
+
- Using CSS custom properties for theme
|
|
121
|
+
- Storing preference in localStorage
|
|
122
|
+
- Toggle component in SettingsPage.tsx
|
|
123
|
+
|
|
124
|
+
## Status
|
|
125
|
+
**Currently in Phase 3** - Building toggle component
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**.planning/add-dark-mode/notes.md:**
|
|
129
|
+
```markdown
|
|
130
|
+
# Notes: Dark Mode Implementation
|
|
131
|
+
|
|
132
|
+
## Existing Theme System
|
|
133
|
+
- Located in: src/styles/theme.ts
|
|
134
|
+
- Uses: CSS custom properties
|
|
135
|
+
- Current themes: light only
|
|
136
|
+
|
|
137
|
+
## Files to Modify
|
|
138
|
+
1. src/styles/theme.ts - Add dark theme colors
|
|
139
|
+
2. src/components/SettingsPage.tsx - Add toggle
|
|
140
|
+
3. src/hooks/useTheme.ts - Create new hook
|
|
141
|
+
4. src/App.tsx - Wrap with ThemeProvider
|
|
142
|
+
|
|
143
|
+
## Color Decisions
|
|
144
|
+
- Dark background: #1a1a2e
|
|
145
|
+
- Dark surface: #16213e
|
|
146
|
+
- Dark text: #eaeaea
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**dark_mode_implementation.md:** (deliverable)
|
|
150
|
+
```markdown
|
|
151
|
+
# Dark Mode Implementation
|
|
152
|
+
|
|
153
|
+
## Changes Made
|
|
154
|
+
|
|
155
|
+
### 1. Added dark theme colors
|
|
156
|
+
File: src/styles/theme.ts
|
|
157
|
+
...
|
|
158
|
+
|
|
159
|
+
### 2. Created useTheme hook
|
|
160
|
+
File: src/hooks/useTheme.ts
|
|
161
|
+
...
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Example 4: Error Recovery Pattern
|
|
167
|
+
|
|
168
|
+
When something fails, don't hide it:
|
|
169
|
+
|
|
170
|
+
### Wrong
|
|
171
|
+
```
|
|
172
|
+
Action: Read config.json
|
|
173
|
+
Error: File not found
|
|
174
|
+
Action: Read config.json # Silent retry
|
|
175
|
+
Action: Read config.json # Another retry
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Correct
|
|
179
|
+
```
|
|
180
|
+
Action: Read config.json
|
|
181
|
+
Error: File not found
|
|
182
|
+
|
|
183
|
+
# Update .planning/[task]/task_plan.md:
|
|
184
|
+
## Errors Encountered
|
|
185
|
+
- config.json not found -> Will create default config
|
|
186
|
+
|
|
187
|
+
Action: Write config.json (default config)
|
|
188
|
+
Action: Read config.json
|
|
189
|
+
Success!
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## The Read-Before-Decide Pattern
|
|
195
|
+
|
|
196
|
+
Always read your plan before major decisions:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
[Many tool calls have happened...]
|
|
200
|
+
[Context is getting long...]
|
|
201
|
+
[Original goal might be forgotten...]
|
|
202
|
+
|
|
203
|
+
-> Read .planning/[task]/task_plan.md # Brings goals back into attention
|
|
204
|
+
-> Now make the decision # Goals are fresh in context
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
This is why Manus can handle ~50 tool calls without losing track. The plan file acts as a "goal refresh" mechanism.
|
|
208
|
+
|
|
209
|
+
## Cleanup After Task Completion
|
|
210
|
+
|
|
211
|
+
When your task is complete, clean up the planning files:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Remove a single task
|
|
215
|
+
rm -rf .planning/[task-name]/
|
|
216
|
+
|
|
217
|
+
# Remove all planning files
|
|
218
|
+
rm -rf .planning/
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
This removes planning files while keeping your deliverables in the project directory.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Reference: Manus Context Engineering Principles
|
|
2
|
+
|
|
3
|
+
Based on the context engineering principles from Manus, the AI agent company acquired by Meta for $2 billion in December 2025.
|
|
4
|
+
|
|
5
|
+
## The 6 Manus Principles
|
|
6
|
+
|
|
7
|
+
### 1. Filesystem as External Memory
|
|
8
|
+
|
|
9
|
+
> "Markdown is my 'working memory' on disk."
|
|
10
|
+
|
|
11
|
+
**Problem:** Context windows have limits. Stuffing everything in context degrades performance and increases costs.
|
|
12
|
+
|
|
13
|
+
**Solution:** Treat the filesystem as unlimited memory:
|
|
14
|
+
- Store large content in files
|
|
15
|
+
- Keep only paths in context
|
|
16
|
+
- Agent can "look up" information when needed
|
|
17
|
+
- Compression must be reversible
|
|
18
|
+
|
|
19
|
+
### 2. Attention Manipulation Through Repetition
|
|
20
|
+
|
|
21
|
+
**Problem:** After ~50 tool calls, models forget original goals ("lost in the middle" effect).
|
|
22
|
+
|
|
23
|
+
**Solution:** Keep a `task_plan.md` file that gets re-read throughout execution:
|
|
24
|
+
```
|
|
25
|
+
Start of context: [Original goal - far away, forgotten]
|
|
26
|
+
...many tool calls...
|
|
27
|
+
End of context: [Recently read task_plan.md - gets ATTENTION]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
By reading the plan file before each decision, goals appear in the attention window.
|
|
31
|
+
|
|
32
|
+
### 3. Keep Failure Traces
|
|
33
|
+
|
|
34
|
+
> "Error recovery is one of the clearest signals of true agentic behavior."
|
|
35
|
+
|
|
36
|
+
**Problem:** Instinct says hide errors, retry silently. This wastes tokens and loses learning.
|
|
37
|
+
|
|
38
|
+
**Solution:** Keep failed actions in the plan file:
|
|
39
|
+
```markdown
|
|
40
|
+
## Errors Encountered
|
|
41
|
+
- [2025-01-03] FileNotFoundError: config.json not found -> Created default config
|
|
42
|
+
- [2025-01-03] API timeout -> Retried with exponential backoff, succeeded
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The model updates its internal understanding when seeing failures.
|
|
46
|
+
|
|
47
|
+
### 4. Avoid Few-Shot Overfitting
|
|
48
|
+
|
|
49
|
+
> "Uniformity breeds fragility."
|
|
50
|
+
|
|
51
|
+
**Problem:** Repetitive action-observation pairs cause drift and hallucination.
|
|
52
|
+
|
|
53
|
+
**Solution:** Introduce controlled variation:
|
|
54
|
+
- Vary phrasings slightly
|
|
55
|
+
- Don't copy-paste patterns blindly
|
|
56
|
+
- Recalibrate on repetitive tasks
|
|
57
|
+
|
|
58
|
+
### 5. Stable Prefixes for Cache Optimization
|
|
59
|
+
|
|
60
|
+
**Problem:** Agents are input-heavy (100:1 ratio). Every token costs money.
|
|
61
|
+
|
|
62
|
+
**Solution:** Structure for cache hits:
|
|
63
|
+
- Put static content first
|
|
64
|
+
- Append-only context (never modify history)
|
|
65
|
+
- Consistent serialization
|
|
66
|
+
|
|
67
|
+
### 6. Append-Only Context
|
|
68
|
+
|
|
69
|
+
**Problem:** Modifying previous messages invalidates KV-cache.
|
|
70
|
+
|
|
71
|
+
**Solution:** Never modify previous messages. Always append new information.
|
|
72
|
+
|
|
73
|
+
## The Agent Loop
|
|
74
|
+
|
|
75
|
+
Manus operates in a continuous loop:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
1. Analyze -> 2. Think -> 3. Select Tool -> 4. Execute -> 5. Observe -> 6. Iterate -> 7. Deliver
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### File Operations in the Loop
|
|
82
|
+
|
|
83
|
+
| Operation | When to Use |
|
|
84
|
+
|-----------|-------------|
|
|
85
|
+
| `write` | New files or complete rewrites |
|
|
86
|
+
| `append` | Adding sections incrementally |
|
|
87
|
+
| `edit` | Updating specific parts (checkboxes, status) |
|
|
88
|
+
| `read` | Reviewing before decisions |
|
|
89
|
+
|
|
90
|
+
## Manus Statistics
|
|
91
|
+
|
|
92
|
+
| Metric | Value |
|
|
93
|
+
|--------|-------|
|
|
94
|
+
| Average tool calls per task | ~50 |
|
|
95
|
+
| Input-to-output ratio | 100:1 |
|
|
96
|
+
| Acquisition price | $2 billion |
|
|
97
|
+
| Time to $100M revenue | 8 months |
|
|
98
|
+
|
|
99
|
+
## Key Quotes
|
|
100
|
+
|
|
101
|
+
> "If the model improvement is the rising tide, we want Manus to be the boat, not the piling stuck on the seafloor."
|
|
102
|
+
|
|
103
|
+
> "For complex tasks, I save notes, code, and findings to files so I can reference them as I work."
|
|
104
|
+
|
|
105
|
+
> "I used file.edit to update checkboxes in my plan as I progressed, rather than rewriting the whole file."
|
|
106
|
+
|
|
107
|
+
## Source
|
|
108
|
+
|
|
109
|
+
Based on Manus's official context engineering documentation:
|
|
110
|
+
https://manus.im/de/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theglitchking/persistent-planning",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Persistent markdown-based planning with task directories, progress tracking, and context engineering for multi-step Claude Code workflows",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"persistent-planning": "./bin/persistent-planning.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node postinstall.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"skills/",
|
|
15
|
+
"scripts/",
|
|
16
|
+
"docs/",
|
|
17
|
+
".claude/",
|
|
18
|
+
".claude-plugin/",
|
|
19
|
+
"postinstall.js",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=16.0.0"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"claude-code",
|
|
32
|
+
"planning",
|
|
33
|
+
"persistent",
|
|
34
|
+
"markdown",
|
|
35
|
+
"context-engineering",
|
|
36
|
+
"task-tracking",
|
|
37
|
+
"working-memory",
|
|
38
|
+
"goal-tracking",
|
|
39
|
+
"manus",
|
|
40
|
+
"plugin"
|
|
41
|
+
],
|
|
42
|
+
"author": {
|
|
43
|
+
"name": "TheGlitchKing",
|
|
44
|
+
"email": "theglitchking@users.noreply.github.com"
|
|
45
|
+
},
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/TheGlitchKing/persistent-planning.git"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/TheGlitchKing/persistent-planning/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/TheGlitchKing/persistent-planning#readme"
|
|
55
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const colors = {
|
|
4
|
+
reset: '\x1b[0m',
|
|
5
|
+
green: '\x1b[32m',
|
|
6
|
+
blue: '\x1b[34m',
|
|
7
|
+
yellow: '\x1b[33m',
|
|
8
|
+
cyan: '\x1b[36m'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
console.log(`
|
|
12
|
+
${colors.cyan}persistent-planning installed successfully!${colors.reset}
|
|
13
|
+
|
|
14
|
+
${colors.green}+${colors.reset} Package installed: ${colors.blue}@theglitchking/persistent-planning${colors.reset}
|
|
15
|
+
|
|
16
|
+
${colors.yellow}Next Steps:${colors.reset}
|
|
17
|
+
|
|
18
|
+
1. Run the installer to set up the plugin:
|
|
19
|
+
${colors.cyan}persistent-planning install --scope user${colors.reset}
|
|
20
|
+
|
|
21
|
+
${colors.blue}Scopes:${colors.reset}
|
|
22
|
+
user - Install globally (~/.claude/) for all projects
|
|
23
|
+
project - Install locally (./.claude/) for this project only
|
|
24
|
+
|
|
25
|
+
2. Check installation status:
|
|
26
|
+
${colors.cyan}persistent-planning status${colors.reset}
|
|
27
|
+
|
|
28
|
+
3. After installation, use this Claude Code command:
|
|
29
|
+
${colors.cyan}/start-planning "Your task name"${colors.reset}
|
|
30
|
+
|
|
31
|
+
${colors.yellow}Documentation:${colors.reset}
|
|
32
|
+
${colors.blue}https://github.com/TheGlitchKing/persistent-planning${colors.reset}
|
|
33
|
+
|
|
34
|
+
`);
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
###############################################################################
|
|
4
|
+
# init-planning.sh - Persistent Planning Directory Setup
|
|
5
|
+
#
|
|
6
|
+
# Part of the persistent-planning plugin by TheGlitchKing
|
|
7
|
+
# https://github.com/TheGlitchKing/persistent-planning
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# bash scripts/init-planning.sh [task-name]
|
|
11
|
+
# bash scripts/init-planning.sh "Refactor database layer"
|
|
12
|
+
#
|
|
13
|
+
# What it does:
|
|
14
|
+
# 1. Creates .planning/[task-slug]/ directory (separate per task)
|
|
15
|
+
# 2. Creates task_plan.md with templates
|
|
16
|
+
# 3. Creates notes.md with templates
|
|
17
|
+
# 4. Adds .planning/ to .gitignore (optional)
|
|
18
|
+
# 5. Confirms creation and provides next steps
|
|
19
|
+
#
|
|
20
|
+
# Multiple tasks example:
|
|
21
|
+
# /start-planning "Refactor auth" -> .planning/refactor-auth/
|
|
22
|
+
# /start-planning "Debug memory leak" -> .planning/debug-memory-leak/
|
|
23
|
+
# Both plans coexist without conflicts!
|
|
24
|
+
###############################################################################
|
|
25
|
+
|
|
26
|
+
set -e
|
|
27
|
+
|
|
28
|
+
# Validate that task name was provided
|
|
29
|
+
if [ -z "$1" ]; then
|
|
30
|
+
echo "Error: Task name required"
|
|
31
|
+
echo ""
|
|
32
|
+
echo "Usage: bash scripts/init-planning.sh \"Your Task Name\""
|
|
33
|
+
echo ""
|
|
34
|
+
echo "Examples:"
|
|
35
|
+
echo " bash scripts/init-planning.sh \"Refactor authentication\""
|
|
36
|
+
echo " bash scripts/init-planning.sh \"Debug API performance\""
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
TASK_NAME="$1"
|
|
41
|
+
|
|
42
|
+
# Convert task name to slug
|
|
43
|
+
# "Refactor Authentication" -> "refactor-authentication"
|
|
44
|
+
task_name_to_slug() {
|
|
45
|
+
local name="$1"
|
|
46
|
+
name=$(echo "$name" | tr '[:upper:]' '[:lower:]')
|
|
47
|
+
name=$(echo "$name" | sed 's/[[:space:]_]\+/-/g')
|
|
48
|
+
name=$(echo "$name" | sed 's/[^a-z0-9-]//g')
|
|
49
|
+
name=$(echo "$name" | sed 's/^-\+\|-\+$//g')
|
|
50
|
+
name=$(echo "$name" | sed 's/-\+/-/g')
|
|
51
|
+
echo "$name"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
TASK_SLUG=$(task_name_to_slug "$TASK_NAME")
|
|
55
|
+
|
|
56
|
+
# Validate slug
|
|
57
|
+
if [ -z "$TASK_SLUG" ]; then
|
|
58
|
+
echo "Error: Task name must contain at least one alphanumeric character"
|
|
59
|
+
echo "Provided: $TASK_NAME"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Determine project root
|
|
64
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
65
|
+
PLANNING_DIR="${PROJECT_ROOT}/.planning"
|
|
66
|
+
TASK_DIR="${PLANNING_DIR}/${TASK_SLUG}"
|
|
67
|
+
|
|
68
|
+
# Color codes
|
|
69
|
+
GREEN='\033[0;32m'
|
|
70
|
+
BLUE='\033[0;34m'
|
|
71
|
+
YELLOW='\033[1;33m'
|
|
72
|
+
CYAN='\033[0;36m'
|
|
73
|
+
NC='\033[0m'
|
|
74
|
+
|
|
75
|
+
echo -e "${BLUE}Initializing Planning Structure${NC}"
|
|
76
|
+
echo ""
|
|
77
|
+
|
|
78
|
+
# Step 1: Create .planning directory
|
|
79
|
+
if [ ! -d "$PLANNING_DIR" ]; then
|
|
80
|
+
mkdir -p "$PLANNING_DIR"
|
|
81
|
+
echo -e "${GREEN}+${NC} Created .planning/ directory"
|
|
82
|
+
else
|
|
83
|
+
echo -e "${YELLOW}*${NC} .planning/ directory exists"
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# Step 2: Create task directory
|
|
87
|
+
if [ ! -d "$TASK_DIR" ]; then
|
|
88
|
+
mkdir -p "$TASK_DIR"
|
|
89
|
+
echo -e "${GREEN}+${NC} Created task directory: ${CYAN}.planning/${TASK_SLUG}/${NC}"
|
|
90
|
+
else
|
|
91
|
+
echo -e "${YELLOW}*${NC} Task directory already exists: ${CYAN}.planning/${TASK_SLUG}/${NC}"
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# Step 3: Create task_plan.md
|
|
95
|
+
TASK_PLAN_FILE="${TASK_DIR}/task_plan.md"
|
|
96
|
+
if [ ! -f "$TASK_PLAN_FILE" ]; then
|
|
97
|
+
cat > "$TASK_PLAN_FILE" << 'EOF'
|
|
98
|
+
# Task Plan: TASK_NAME_PLACEHOLDER
|
|
99
|
+
|
|
100
|
+
## Goal
|
|
101
|
+
[One sentence describing the end state]
|
|
102
|
+
|
|
103
|
+
## Phases
|
|
104
|
+
- [ ] Phase 1: Plan and setup
|
|
105
|
+
- [ ] Phase 2: Research/gather information
|
|
106
|
+
- [ ] Phase 3: Execute/build
|
|
107
|
+
- [ ] Phase 4: Review and deliver
|
|
108
|
+
|
|
109
|
+
## Key Questions
|
|
110
|
+
1. [Question to answer]
|
|
111
|
+
2. [Question to answer]
|
|
112
|
+
|
|
113
|
+
## Decisions Made
|
|
114
|
+
- [Decision]: [Rationale]
|
|
115
|
+
|
|
116
|
+
## Errors Encountered
|
|
117
|
+
- [Error]: [Resolution]
|
|
118
|
+
|
|
119
|
+
## Status
|
|
120
|
+
**Currently in Phase 1** - Setting up planning structure
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Notes
|
|
125
|
+
- This file persists across sessions
|
|
126
|
+
- Update status after each phase
|
|
127
|
+
- Mark completed phases with [x]
|
|
128
|
+
- Save research to notes.md instead of stuffing context
|
|
129
|
+
EOF
|
|
130
|
+
|
|
131
|
+
sed -i "s/TASK_NAME_PLACEHOLDER/${TASK_NAME}/g" "$TASK_PLAN_FILE"
|
|
132
|
+
echo -e "${GREEN}+${NC} Created task_plan.md"
|
|
133
|
+
else
|
|
134
|
+
echo -e "${YELLOW}*${NC} task_plan.md already exists (not overwritten)"
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
# Step 4: Create notes.md
|
|
138
|
+
NOTES_FILE="${TASK_DIR}/notes.md"
|
|
139
|
+
if [ ! -f "$NOTES_FILE" ]; then
|
|
140
|
+
cat > "$NOTES_FILE" << 'EOF'
|
|
141
|
+
# Notes: TASK_NAME_PLACEHOLDER
|
|
142
|
+
|
|
143
|
+
## Key Findings
|
|
144
|
+
- [Finding 1]
|
|
145
|
+
- [Finding 2]
|
|
146
|
+
|
|
147
|
+
## Research Sources
|
|
148
|
+
- [Source 1]: [URL or reference]
|
|
149
|
+
- [Source 2]: [URL or reference]
|
|
150
|
+
|
|
151
|
+
## Synthesized Findings
|
|
152
|
+
|
|
153
|
+
### [Category/Topic 1]
|
|
154
|
+
- [Finding]
|
|
155
|
+
- [Finding]
|
|
156
|
+
|
|
157
|
+
### [Category/Topic 2]
|
|
158
|
+
- [Finding]
|
|
159
|
+
- [Finding]
|
|
160
|
+
|
|
161
|
+
## Decisions Made
|
|
162
|
+
- [Decision]: [Rationale]
|
|
163
|
+
- [Decision]: [Rationale]
|
|
164
|
+
|
|
165
|
+
## Errors & Solutions
|
|
166
|
+
- [Error]: [Resolution]
|
|
167
|
+
- [Error]: [Resolution]
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Append-Only Log
|
|
172
|
+
Store findings here as you discover them. This builds a searchable history.
|
|
173
|
+
|
|
174
|
+
### [Date/Time]
|
|
175
|
+
- [What I found/did]
|
|
176
|
+
EOF
|
|
177
|
+
|
|
178
|
+
sed -i "s/TASK_NAME_PLACEHOLDER/${TASK_NAME}/g" "$NOTES_FILE"
|
|
179
|
+
echo -e "${GREEN}+${NC} Created notes.md"
|
|
180
|
+
else
|
|
181
|
+
echo -e "${YELLOW}*${NC} notes.md already exists (not overwritten)"
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# Step 5: Update .gitignore
|
|
185
|
+
if [ -f "${PROJECT_ROOT}/.gitignore" ]; then
|
|
186
|
+
if ! grep -q "^\.planning/" "${PROJECT_ROOT}/.gitignore"; then
|
|
187
|
+
echo ".planning/" >> "${PROJECT_ROOT}/.gitignore"
|
|
188
|
+
echo -e "${GREEN}+${NC} Added .planning/ to .gitignore"
|
|
189
|
+
else
|
|
190
|
+
echo -e "${YELLOW}*${NC} .planning/ already in .gitignore"
|
|
191
|
+
fi
|
|
192
|
+
else
|
|
193
|
+
echo -e "${YELLOW}*${NC} No .gitignore found (not added)"
|
|
194
|
+
fi
|
|
195
|
+
|
|
196
|
+
# Step 6: List other active tasks
|
|
197
|
+
OTHER_TASKS=$(find "$PLANNING_DIR" -maxdepth 1 -type d -not -name ".planning" -not -path "$TASK_DIR" 2>/dev/null | wc -l)
|
|
198
|
+
if [ "$OTHER_TASKS" -gt 0 ]; then
|
|
199
|
+
echo ""
|
|
200
|
+
echo -e "${CYAN}Other active tasks:${NC}"
|
|
201
|
+
find "$PLANNING_DIR" -maxdepth 1 -type d -not -name ".planning" -not -path "$TASK_DIR" | sort | while read dir; do
|
|
202
|
+
task_slug=$(basename "$dir")
|
|
203
|
+
echo " .planning/${task_slug}/"
|
|
204
|
+
done
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
# Step 7: Confirmation
|
|
208
|
+
echo ""
|
|
209
|
+
echo -e "${GREEN}=====================================${NC}"
|
|
210
|
+
echo -e "${GREEN}Task Plan Ready${NC}"
|
|
211
|
+
echo -e "${GREEN}=====================================${NC}"
|
|
212
|
+
echo ""
|
|
213
|
+
|
|
214
|
+
echo -e "${BLUE}Task:${NC} ${TASK_NAME}"
|
|
215
|
+
echo -e "${BLUE}Location:${NC} .planning/${TASK_SLUG}/"
|
|
216
|
+
echo ""
|
|
217
|
+
|
|
218
|
+
echo -e "${BLUE}Files:${NC}"
|
|
219
|
+
echo " task_plan.md (your task plan)"
|
|
220
|
+
echo " notes.md (research & findings)"
|
|
221
|
+
echo ""
|
|
222
|
+
|
|
223
|
+
echo -e "${BLUE}Next steps:${NC}"
|
|
224
|
+
echo " 1. Edit .planning/${TASK_SLUG}/task_plan.md to define your phases"
|
|
225
|
+
echo " 2. As you work, update the Status section"
|
|
226
|
+
echo " 3. Save findings to .planning/${TASK_SLUG}/notes.md"
|
|
227
|
+
echo " 4. Re-read task_plan.md before major decisions"
|
|
228
|
+
echo ""
|
|
229
|
+
|
|
230
|
+
echo -e "${BLUE}Cleanup:${NC}"
|
|
231
|
+
echo " rm -rf .planning/${TASK_SLUG}/ # Remove this task"
|
|
232
|
+
echo " rm -rf .planning/ # Remove all tasks"
|
|
233
|
+
echo ""
|