prjct-cli 0.4.9 → 0.5.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/CHANGELOG.md +316 -0
- package/CLAUDE.md +109 -3
- package/README.md +228 -93
- package/core/agent-detector.js +55 -122
- package/core/agent-generator.js +516 -0
- package/core/command-installer.js +104 -890
- package/core/commands.js +3 -18
- package/core/editors-config.js +9 -57
- package/core/git-integration.js +401 -0
- package/package.json +10 -7
- package/scripts/install.sh +0 -1
- package/templates/agents/be.template.md +42 -0
- package/templates/agents/data.template.md +41 -0
- package/templates/agents/devops.template.md +41 -0
- package/templates/agents/fe.template.md +42 -0
- package/templates/agents/mobile.template.md +41 -0
- package/templates/agents/pm.template.md +84 -0
- package/templates/agents/qa.template.md +54 -0
- package/templates/agents/scribe.template.md +95 -0
- package/templates/agents/security.template.md +41 -0
- package/templates/agents/ux.template.md +49 -0
- package/templates/commands/analyze.md +137 -3
- package/templates/commands/done.md +154 -5
- package/templates/commands/init.md +61 -3
- package/templates/commands/ship.md +146 -6
- package/templates/commands/sync.md +220 -0
- package/templates/examples/natural-language-examples.md +234 -22
- package/core/agents/codex-agent.js +0 -256
- package/core/agents/terminal-agent.js +0 -465
- package/templates/workflows/analyze.md +0 -159
- package/templates/workflows/cleanup.md +0 -73
- package/templates/workflows/context.md +0 -72
- package/templates/workflows/design.md +0 -88
- package/templates/workflows/done.md +0 -20
- package/templates/workflows/fix.md +0 -201
- package/templates/workflows/git.md +0 -192
- package/templates/workflows/help.md +0 -13
- package/templates/workflows/idea.md +0 -22
- package/templates/workflows/init.md +0 -80
- package/templates/workflows/natural-language-handler.md +0 -183
- package/templates/workflows/next.md +0 -44
- package/templates/workflows/now.md +0 -19
- package/templates/workflows/progress.md +0 -113
- package/templates/workflows/recap.md +0 -66
- package/templates/workflows/roadmap.md +0 -95
- package/templates/workflows/ship.md +0 -18
- package/templates/workflows/stuck.md +0 -25
- package/templates/workflows/task.md +0 -109
- package/templates/workflows/test.md +0 -243
|
@@ -5,6 +5,26 @@ description: "Complete task, clear focus"
|
|
|
5
5
|
|
|
6
6
|
# /p:done
|
|
7
7
|
|
|
8
|
+
## Context Validation
|
|
9
|
+
|
|
10
|
+
**Prerequisites:**
|
|
11
|
+
- Project must be initialized (`.prjct/prjct.config.json` exists)
|
|
12
|
+
- Active task must exist (`core/now.md` has content)
|
|
13
|
+
|
|
14
|
+
**If context is missing, Claude provides conversational response:**
|
|
15
|
+
```
|
|
16
|
+
✨ You're not working on anything right now!
|
|
17
|
+
|
|
18
|
+
Want to start something?
|
|
19
|
+
• Tell me what you want to build
|
|
20
|
+
• Say "show me what's next"
|
|
21
|
+
• Or use: /p:now | /p:next
|
|
22
|
+
|
|
23
|
+
Let's ship something!
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Validation happens automatically through CLAUDE.md instructions - Claude checks context before executing!**
|
|
27
|
+
|
|
8
28
|
## Usage
|
|
9
29
|
```
|
|
10
30
|
/p:done
|
|
@@ -12,14 +32,22 @@ description: "Complete task, clear focus"
|
|
|
12
32
|
|
|
13
33
|
## Execution
|
|
14
34
|
|
|
35
|
+
**Only runs if context validation passes ✅**
|
|
36
|
+
|
|
15
37
|
1. Read task from `~/.prjct-cli/projects/{id}/core/now.md`, calculate duration
|
|
16
38
|
2. Clear `core/now.md`
|
|
17
|
-
3.
|
|
18
|
-
|
|
39
|
+
3. **Trigger Scribe Agent** (Documentation):
|
|
40
|
+
- Get git changes since task started: `git diff --name-only`
|
|
41
|
+
- Invoke Scribe agent to document changes
|
|
42
|
+
- Show documentation draft to user
|
|
43
|
+
- **Request confirmation** before saving
|
|
44
|
+
- Save to `analysis/task-docs/[task-id].md` if confirmed
|
|
45
|
+
4. Update `progress/metrics.md`, `core/context.md`
|
|
46
|
+
5. Log to `memory/context.jsonl`:
|
|
19
47
|
```json
|
|
20
|
-
{"action":"done","task":"[task]","started":"[t1]","completed":"[t2]","duration":"[min]","layer":"core"}
|
|
48
|
+
{"action":"done","task":"[task]","started":"[t1]","completed":"[t2]","duration":"[min]","documented":true,"layer":"core"}
|
|
21
49
|
```
|
|
22
|
-
|
|
50
|
+
6. Response:
|
|
23
51
|
```
|
|
24
52
|
✅ [task description] ([duration])
|
|
25
53
|
|
|
@@ -41,4 +69,125 @@ description: "Complete task, clear focus"
|
|
|
41
69
|
• "see my progress" → View achievements
|
|
42
70
|
|
|
43
71
|
Or: /p:idea | /p:next | /p:recap
|
|
44
|
-
```
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Scribe Agent Workflow
|
|
75
|
+
|
|
76
|
+
When a task is completed, the Scribe agent is automatically invoked to document changes:
|
|
77
|
+
|
|
78
|
+
### Step 1: Detect Changes
|
|
79
|
+
```javascript
|
|
80
|
+
const gitIntegration = require('../core/git-integration')
|
|
81
|
+
const taskStartTime = readTaskStartTime()
|
|
82
|
+
|
|
83
|
+
// Get files changed since task started
|
|
84
|
+
const changes = await gitIntegration.getChangesSince(taskStartTime)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Step 2: Generate Documentation
|
|
88
|
+
Invoke Scribe agent with prompt:
|
|
89
|
+
```
|
|
90
|
+
Document the following task completion:
|
|
91
|
+
|
|
92
|
+
Task: "[task description]"
|
|
93
|
+
Duration: [duration]
|
|
94
|
+
Files changed:
|
|
95
|
+
${changes.files.join('\n')}
|
|
96
|
+
|
|
97
|
+
Generate documentation including:
|
|
98
|
+
1. Brief summary of what was implemented
|
|
99
|
+
2. Key technical decisions
|
|
100
|
+
3. Files affected and their purpose
|
|
101
|
+
4. Any breaking changes or important notes
|
|
102
|
+
|
|
103
|
+
Keep it concise (< 200 words).
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Step 3: Show Draft & Request Confirmation
|
|
107
|
+
```
|
|
108
|
+
📝 Scribe Agent Documentation Draft
|
|
109
|
+
|
|
110
|
+
## Task: [task description]
|
|
111
|
+
|
|
112
|
+
**Implemented**: [date]
|
|
113
|
+
**Duration**: [duration]
|
|
114
|
+
|
|
115
|
+
**Summary**:
|
|
116
|
+
[AI-generated summary]
|
|
117
|
+
|
|
118
|
+
**Technical Details**:
|
|
119
|
+
- [Key decisions]
|
|
120
|
+
- [Files modified]
|
|
121
|
+
|
|
122
|
+
**Usage**:
|
|
123
|
+
[Examples if applicable]
|
|
124
|
+
|
|
125
|
+
─────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
Save this documentation? (y/n): _
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Step 4: Save if Confirmed
|
|
131
|
+
```javascript
|
|
132
|
+
if (userConfirms) {
|
|
133
|
+
const docPath = `~/.prjct-cli/projects/{id}/analysis/task-docs/${taskId}.md`
|
|
134
|
+
await saveDocumentation(docPath, documentation)
|
|
135
|
+
console.log('✅ Documentation saved!')
|
|
136
|
+
} else {
|
|
137
|
+
console.log('ℹ️ Documentation discarded')
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Example with Scribe
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
/p:done
|
|
145
|
+
|
|
146
|
+
✅ implement login authentication (2h 15m)
|
|
147
|
+
|
|
148
|
+
📝 Scribe Agent is documenting your changes...
|
|
149
|
+
|
|
150
|
+
─────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
## Task: implement login authentication
|
|
153
|
+
|
|
154
|
+
**Implemented**: 2025-10-02
|
|
155
|
+
**Duration**: 2h 15m
|
|
156
|
+
|
|
157
|
+
**Summary**:
|
|
158
|
+
Implemented JWT-based authentication system with login and registration endpoints. Added middleware for protected routes and session management.
|
|
159
|
+
|
|
160
|
+
**Technical Details**:
|
|
161
|
+
- Added auth service with bcrypt password hashing
|
|
162
|
+
- Created login/register API endpoints in auth.controller.ts
|
|
163
|
+
- Implemented JWT middleware for route protection
|
|
164
|
+
- Added user session management with Redis
|
|
165
|
+
|
|
166
|
+
**Files Modified**:
|
|
167
|
+
- src/features/auth/auth.service.ts (new)
|
|
168
|
+
- src/features/auth/auth.controller.ts (new)
|
|
169
|
+
- src/middleware/jwt.middleware.ts (new)
|
|
170
|
+
- src/config/redis.config.ts (modified)
|
|
171
|
+
|
|
172
|
+
**Breaking Changes**: None
|
|
173
|
+
|
|
174
|
+
─────────────────────────────────────────────
|
|
175
|
+
|
|
176
|
+
Save this documentation? (y/n): y
|
|
177
|
+
|
|
178
|
+
✅ Documentation saved to task-docs!
|
|
179
|
+
|
|
180
|
+
What's next?
|
|
181
|
+
• "start next task" → Begin working
|
|
182
|
+
• "ship authentication" → Track & celebrate
|
|
183
|
+
|
|
184
|
+
Or use: /p:now | /p:ship
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Notes
|
|
188
|
+
|
|
189
|
+
- Scribe agent uses git history to understand changes
|
|
190
|
+
- Documentation is saved per-task for reference
|
|
191
|
+
- User confirmation prevents unwanted docs
|
|
192
|
+
- Can skip documentation by saying "no"
|
|
193
|
+
- Documentation helps with onboarding and code reviews
|
|
@@ -151,20 +151,78 @@ Create empty JSONL files for historical tracking:
|
|
|
151
151
|
- **memory/context.jsonl**: Activity log with timestamps
|
|
152
152
|
- **memory/decisions.jsonl**: Decision history (not used yet)
|
|
153
153
|
|
|
154
|
-
### 8.
|
|
154
|
+
### 8. Run Project Analysis
|
|
155
|
+
|
|
156
|
+
Execute `/p:analyze` to understand the project:
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
// This should execute the analyze command internally
|
|
160
|
+
// The AI will:
|
|
161
|
+
// 1. Scan project structure
|
|
162
|
+
// 2. Detect stack and frameworks
|
|
163
|
+
// 3. Check git status
|
|
164
|
+
// 4. Determine which agents are needed
|
|
165
|
+
// 5. Save analysis to .prjct/analysis/repo-summary.md
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 9. Generate AI Agents
|
|
169
|
+
|
|
170
|
+
Based on the analysis, generate specialized AI agents:
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
const agentGenerator = require('../core/agent-generator')
|
|
174
|
+
const analysis = await readAnalysisFile('.prjct/analysis/repo-summary.md')
|
|
175
|
+
|
|
176
|
+
// Generate all required agents
|
|
177
|
+
const generatedAgents = await agentGenerator.generateAll(analysis)
|
|
178
|
+
|
|
179
|
+
// Agents are created in ~/.claude/agents/
|
|
180
|
+
// They are immediately available in Claude Code and Claude Desktop
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Generated Agents**:
|
|
184
|
+
- **Base** (always): PM, UX, FE, BE, QA, Scribe (6 agents)
|
|
185
|
+
- **Conditional** (based on project):
|
|
186
|
+
- Security (if web app or has auth)
|
|
187
|
+
- DevOps (if Docker/CI/CD detected)
|
|
188
|
+
- Mobile (if React Native/Flutter detected)
|
|
189
|
+
- Data (if ML/data science detected)
|
|
190
|
+
|
|
191
|
+
### 10. Log Initialization
|
|
155
192
|
|
|
156
193
|
Add initialization record to memory:
|
|
157
194
|
```jsonl
|
|
158
|
-
{"timestamp":"2025-10-01T09:00:00Z","action":"init","author":"Name","projectPath":"/path/to/project","projectId":"abc123def456"}
|
|
195
|
+
{"timestamp":"2025-10-01T09:00:00Z","action":"init","author":"Name","projectPath":"/path/to/project","projectId":"abc123def456","agents":["pm","ux","fe","be","qa","scribe","security"]}
|
|
159
196
|
```
|
|
160
197
|
|
|
161
|
-
###
|
|
198
|
+
### 11. Success Message (Conversational Onboarding)
|
|
162
199
|
|
|
163
200
|
```
|
|
164
201
|
✅ Your project is ready!
|
|
165
202
|
|
|
166
203
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
167
204
|
|
|
205
|
+
📦 Project Analysis Complete
|
|
206
|
+
|
|
207
|
+
Project: [PROJECT_NAME]
|
|
208
|
+
Type: [PROJECT_TYPE]
|
|
209
|
+
Stack: [DETECTED_STACK]
|
|
210
|
+
|
|
211
|
+
🤖 AI Agents Generated ([COUNT] specialists)
|
|
212
|
+
|
|
213
|
+
✅ PM - Project coordination
|
|
214
|
+
✅ UX - Design & user experience
|
|
215
|
+
✅ FE - Frontend development
|
|
216
|
+
✅ BE - Backend development
|
|
217
|
+
✅ QA - Testing & quality
|
|
218
|
+
✅ Scribe - Documentation
|
|
219
|
+
[+ conditional agents if detected]
|
|
220
|
+
|
|
221
|
+
These agents are now available in Claude and will provide
|
|
222
|
+
specialized expertise for your project tasks.
|
|
223
|
+
|
|
224
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
225
|
+
|
|
168
226
|
💬 Let me show you around...
|
|
169
227
|
|
|
170
228
|
You don't need to memorize commands.
|
|
@@ -18,14 +18,21 @@ description: "Ship a feature"
|
|
|
18
18
|
- ✅ [feature] ([timestamp])
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
2.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
2. **Trigger Scribe Agent** (Documentation):
|
|
22
|
+
- Get git changes for the feature: `git diff --name-only`
|
|
23
|
+
- Invoke Scribe agent to document the shipped feature
|
|
24
|
+
- Show documentation draft to user
|
|
25
|
+
- **Request confirmation** before saving
|
|
26
|
+
- Save to `analysis/feature-docs/[feature-id].md` if confirmed
|
|
27
|
+
|
|
28
|
+
3. Update `progress/metrics.md` (count, velocity, streak)
|
|
29
|
+
4. Update `core/context.md`
|
|
30
|
+
5. Log to `memory/context.jsonl`:
|
|
24
31
|
```json
|
|
25
|
-
{"action":"ship","feature":"[desc]","timestamp":"[ISO]","week":"[w]","layer":"progress","total":[n]}
|
|
32
|
+
{"action":"ship","feature":"[desc]","timestamp":"[ISO]","week":"[w]","layer":"progress","total":[n],"documented":true}
|
|
26
33
|
```
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
6. Response:
|
|
29
36
|
```
|
|
30
37
|
🚀 [feature name] shipped!
|
|
31
38
|
|
|
@@ -38,4 +45,137 @@ description: "Ship a feature"
|
|
|
38
45
|
• "plan ahead" → Strategic thinking
|
|
39
46
|
|
|
40
47
|
Or: /p:now | /p:recap | /p:roadmap
|
|
41
|
-
```
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Scribe Agent Workflow
|
|
51
|
+
|
|
52
|
+
When a feature is shipped, the Scribe agent is automatically invoked to document changes:
|
|
53
|
+
|
|
54
|
+
### Step 1: Detect Changes
|
|
55
|
+
```javascript
|
|
56
|
+
const gitIntegration = require('../core/git-integration')
|
|
57
|
+
|
|
58
|
+
// Get files changed for this feature
|
|
59
|
+
const changes = await gitIntegration.getChangesSince(featureStartTime)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Step 2: Generate Documentation
|
|
63
|
+
Invoke Scribe agent with prompt:
|
|
64
|
+
```
|
|
65
|
+
Document the following shipped feature:
|
|
66
|
+
|
|
67
|
+
Feature: "[feature description]"
|
|
68
|
+
Shipped: [timestamp]
|
|
69
|
+
Files changed:
|
|
70
|
+
${changes.files.join('\n')}
|
|
71
|
+
|
|
72
|
+
Generate release documentation including:
|
|
73
|
+
1. Feature overview and user impact
|
|
74
|
+
2. Technical implementation summary
|
|
75
|
+
3. Key files and components affected
|
|
76
|
+
4. Breaking changes or migration notes (if any)
|
|
77
|
+
5. Usage examples
|
|
78
|
+
|
|
79
|
+
Keep it concise and user-focused (< 300 words).
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Step 3: Show Draft & Request Confirmation
|
|
83
|
+
```
|
|
84
|
+
📝 Scribe Agent Feature Documentation
|
|
85
|
+
|
|
86
|
+
## Feature: [feature description]
|
|
87
|
+
|
|
88
|
+
**Shipped**: [date]
|
|
89
|
+
**Impact**: [user-facing impact]
|
|
90
|
+
|
|
91
|
+
**Overview**:
|
|
92
|
+
[AI-generated feature summary]
|
|
93
|
+
|
|
94
|
+
**Technical Details**:
|
|
95
|
+
- [Implementation highlights]
|
|
96
|
+
- [Key components]
|
|
97
|
+
|
|
98
|
+
**Usage**:
|
|
99
|
+
[Examples if applicable]
|
|
100
|
+
|
|
101
|
+
**Breaking Changes**: [None / List]
|
|
102
|
+
|
|
103
|
+
─────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
Save this documentation? (y/n): _
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Step 4: Save if Confirmed
|
|
109
|
+
```javascript
|
|
110
|
+
if (userConfirms) {
|
|
111
|
+
const docPath = `~/.prjct-cli/projects/{id}/analysis/feature-docs/${featureId}.md`
|
|
112
|
+
await saveDocumentation(docPath, documentation)
|
|
113
|
+
console.log('✅ Feature documentation saved!')
|
|
114
|
+
} else {
|
|
115
|
+
console.log('ℹ️ Documentation discarded')
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Example with Scribe
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
/p:ship "authentication system"
|
|
123
|
+
|
|
124
|
+
🚀 authentication system shipped!
|
|
125
|
+
|
|
126
|
+
📝 Scribe Agent is documenting your feature...
|
|
127
|
+
|
|
128
|
+
─────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
## Feature: authentication system
|
|
131
|
+
|
|
132
|
+
**Shipped**: 2025-10-02
|
|
133
|
+
**Impact**: Users can now securely log in and manage sessions
|
|
134
|
+
|
|
135
|
+
**Overview**:
|
|
136
|
+
Implemented JWT-based authentication with login, registration, and password reset. Added middleware for protected routes and session management with automatic token refresh.
|
|
137
|
+
|
|
138
|
+
**Technical Details**:
|
|
139
|
+
- JWT authentication with bcrypt password hashing
|
|
140
|
+
- Login/register/reset endpoints in auth.controller.ts
|
|
141
|
+
- JWT middleware for route protection
|
|
142
|
+
- Redis-based session management with 7-day expiry
|
|
143
|
+
- Email verification workflow
|
|
144
|
+
|
|
145
|
+
**Files Modified**:
|
|
146
|
+
- src/features/auth/auth.service.ts (new)
|
|
147
|
+
- src/features/auth/auth.controller.ts (new)
|
|
148
|
+
- src/middleware/jwt.middleware.ts (new)
|
|
149
|
+
- src/config/redis.config.ts (modified)
|
|
150
|
+
|
|
151
|
+
**Breaking Changes**: None
|
|
152
|
+
|
|
153
|
+
**Usage**:
|
|
154
|
+
```javascript
|
|
155
|
+
// Protected route example
|
|
156
|
+
app.get('/api/profile', jwtMiddleware, profileController.get)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
─────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
Save this documentation? (y/n): y
|
|
162
|
+
|
|
163
|
+
✅ Feature documentation saved to analysis/feature-docs/!
|
|
164
|
+
|
|
165
|
+
📈 This week: 3 | Total: 15
|
|
166
|
+
Velocity: 2.1 features/day
|
|
167
|
+
|
|
168
|
+
Keep the momentum!
|
|
169
|
+
• "start next task" → Keep building
|
|
170
|
+
• "see my progress" → View stats
|
|
171
|
+
|
|
172
|
+
Or: /p:now | /p:recap
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Notes
|
|
176
|
+
|
|
177
|
+
- Scribe agent uses git history to understand feature scope
|
|
178
|
+
- Documentation is saved per-feature for release notes
|
|
179
|
+
- User confirmation prevents unwanted documentation
|
|
180
|
+
- Can skip documentation by saying "no"
|
|
181
|
+
- Feature docs help with changelog generation and onboarding
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
allowed-tools: [Read, Write, Bash, Glob, Grep, TodoWrite]
|
|
3
|
+
description: "Sync project state and update AI agents based on latest analysis"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /p:sync - Sync Project State
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
Re-analyze the project and update all AI agents with current project state, stack changes, and new requirements.
|
|
10
|
+
|
|
11
|
+
## Global Architecture
|
|
12
|
+
This command uses the global prjct architecture:
|
|
13
|
+
- Data stored in: `~/.prjct-cli/projects/{id}/`
|
|
14
|
+
- Config stored in: `{project}/.prjct/prjct.config.json`
|
|
15
|
+
- Agents updated in: `~/.claude/agents/`
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
```
|
|
19
|
+
/p:sync
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## When to Run
|
|
23
|
+
- After major dependency changes
|
|
24
|
+
- When adding new frameworks or tools
|
|
25
|
+
- After significant architecture changes
|
|
26
|
+
- When project type changes (e.g., adding mobile support)
|
|
27
|
+
- Periodically to keep agents up-to-date
|
|
28
|
+
|
|
29
|
+
## Execution Flow
|
|
30
|
+
|
|
31
|
+
### 1. Re-run Project Analysis
|
|
32
|
+
|
|
33
|
+
Execute `/p:analyze` to get current project state:
|
|
34
|
+
```javascript
|
|
35
|
+
// This will:
|
|
36
|
+
// 1. Scan all files and directories
|
|
37
|
+
// 2. Detect current stack and frameworks
|
|
38
|
+
// 3. Check git status
|
|
39
|
+
// 4. Compare with previous analysis
|
|
40
|
+
// 5. Identify what changed
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Detect Changes
|
|
44
|
+
|
|
45
|
+
Compare new analysis with previous:
|
|
46
|
+
```javascript
|
|
47
|
+
const previousAnalysis = await readFile('.prjct/analysis/repo-summary.md')
|
|
48
|
+
const currentAnalysis = await runAnalyze()
|
|
49
|
+
|
|
50
|
+
const changes = {
|
|
51
|
+
newDependencies: [],
|
|
52
|
+
removedDependencies: [],
|
|
53
|
+
newFrameworks: [],
|
|
54
|
+
stackChanges: [],
|
|
55
|
+
structureChanges: []
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Detect what changed
|
|
59
|
+
if (currentAnalysis.frameworks !== previousAnalysis.frameworks) {
|
|
60
|
+
changes.newFrameworks = difference(current, previous)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Update Existing Agents
|
|
65
|
+
|
|
66
|
+
Regenerate all current agents with new context:
|
|
67
|
+
```javascript
|
|
68
|
+
const agentGenerator = require('../core/agent-generator')
|
|
69
|
+
|
|
70
|
+
// Update all existing agents
|
|
71
|
+
const updated = await agentGenerator.updateExistingAgents(currentAnalysis)
|
|
72
|
+
|
|
73
|
+
console.log(`↻ Updated ${updated.length} agents with new context`)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 4. Add New Agents
|
|
77
|
+
|
|
78
|
+
Generate any newly required agents:
|
|
79
|
+
```javascript
|
|
80
|
+
// Detect newly required agents
|
|
81
|
+
const existingAgents = await listAgentFiles()
|
|
82
|
+
const requiredAgents = detectRequiredAgents(currentAnalysis)
|
|
83
|
+
const newAgents = requiredAgents.filter(a => !existingAgents.includes(a))
|
|
84
|
+
|
|
85
|
+
if (newAgents.length > 0) {
|
|
86
|
+
for (const agentType of newAgents) {
|
|
87
|
+
await agentGenerator.generateAgent(agentType, currentAnalysis)
|
|
88
|
+
console.log(`✅ Added ${agentType} agent`)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 5. Remove Obsolete Agents (Optional)
|
|
94
|
+
|
|
95
|
+
Ask user if agents should be removed:
|
|
96
|
+
```javascript
|
|
97
|
+
const obsoleteAgents = existingAgents.filter(a => !requiredAgents.includes(a))
|
|
98
|
+
|
|
99
|
+
if (obsoleteAgents.length > 0) {
|
|
100
|
+
console.log(`\n⚠️ The following agents may no longer be needed:`)
|
|
101
|
+
obsoleteAgents.forEach(a => console.log(` - ${a}`))
|
|
102
|
+
|
|
103
|
+
const shouldRemove = await confirmWithUser('\nRemove these agents? (y/n): ')
|
|
104
|
+
|
|
105
|
+
if (shouldRemove) {
|
|
106
|
+
await agentGenerator.cleanupObsoleteAgents(requiredAgents)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 6. Update Analysis File
|
|
112
|
+
|
|
113
|
+
Save new analysis:
|
|
114
|
+
```bash
|
|
115
|
+
# Backup previous analysis
|
|
116
|
+
cp .prjct/analysis/repo-summary.md .prjct/analysis/repo-summary.backup.md
|
|
117
|
+
|
|
118
|
+
# Save new analysis
|
|
119
|
+
# (already saved by /p:analyze)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 7. Update Memory Log
|
|
123
|
+
|
|
124
|
+
Log sync action:
|
|
125
|
+
```jsonl
|
|
126
|
+
{"timestamp":"2025-10-02T14:30:00Z","action":"sync","author":"Name","changes":{"addedAgents":["mobile"],"updatedAgents":["fe","be"],"removedAgents":[],"stackChanges":["added react-native"]}}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Output Examples
|
|
130
|
+
|
|
131
|
+
### No Changes
|
|
132
|
+
```
|
|
133
|
+
🔄 Syncing project state...
|
|
134
|
+
|
|
135
|
+
📊 Analysis Complete
|
|
136
|
+
No significant changes detected
|
|
137
|
+
|
|
138
|
+
🤖 Agents Status
|
|
139
|
+
✓ All 7 agents are up-to-date
|
|
140
|
+
|
|
141
|
+
✅ Sync complete! Everything is current.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### With Changes
|
|
145
|
+
```
|
|
146
|
+
🔄 Syncing project state...
|
|
147
|
+
|
|
148
|
+
📊 Changes Detected
|
|
149
|
+
✅ New dependency: @tanstack/react-query
|
|
150
|
+
✅ New framework: Expo (React Native)
|
|
151
|
+
ℹ️ Architecture: Still feature-based
|
|
152
|
+
|
|
153
|
+
🤖 Agent Updates
|
|
154
|
+
↻ FE agent - Added React Query patterns
|
|
155
|
+
↻ BE agent - Updated API integration context
|
|
156
|
+
✅ Mobile agent - ADDED (React Native detected)
|
|
157
|
+
✓ Other agents - No changes needed
|
|
158
|
+
|
|
159
|
+
⚠️ Obsolete Agents
|
|
160
|
+
- devops (Docker removed from project)
|
|
161
|
+
|
|
162
|
+
Remove obsolete agents? (y/n): _
|
|
163
|
+
|
|
164
|
+
✅ Sync complete!
|
|
165
|
+
- 2 agents updated
|
|
166
|
+
- 1 agent added
|
|
167
|
+
- 1 agent removed
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Stack Migration
|
|
171
|
+
```
|
|
172
|
+
🔄 Syncing project state...
|
|
173
|
+
|
|
174
|
+
📊 Major Changes Detected
|
|
175
|
+
⚠️ Framework changed: Vue → React
|
|
176
|
+
⚠️ Build tool changed: Webpack → Vite
|
|
177
|
+
✅ New: TypeScript added
|
|
178
|
+
|
|
179
|
+
🤖 Full Agent Regeneration
|
|
180
|
+
↻ PM - Updated with React patterns
|
|
181
|
+
↻ UX - Updated component guidelines
|
|
182
|
+
↻ FE - COMPLETELY REGENERATED for React + TS
|
|
183
|
+
↻ BE - Updated API patterns
|
|
184
|
+
↻ QA - Updated test framework context
|
|
185
|
+
↻ Scribe - Updated documentation style
|
|
186
|
+
|
|
187
|
+
✅ Sync complete! All agents updated for new stack.
|
|
188
|
+
|
|
189
|
+
💡 Tip: Review agent descriptions to see new capabilities.
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Error Handling
|
|
193
|
+
|
|
194
|
+
- **No .prjct/**: Error - Project not initialized, run `/p:init` first
|
|
195
|
+
- **No analysis file**: Warning - Running first-time analysis
|
|
196
|
+
- **Agent generation fails**: Warn but continue with others
|
|
197
|
+
- **Permission issues**: Suggest checking `~/.claude/agents/` permissions
|
|
198
|
+
|
|
199
|
+
## Notes
|
|
200
|
+
|
|
201
|
+
- Sync is safe to run anytime
|
|
202
|
+
- Existing agents are updated, not deleted (unless confirmed)
|
|
203
|
+
- Git status is refreshed during sync
|
|
204
|
+
- Analysis diff helps track project evolution
|
|
205
|
+
- Agents get project-specific context from analysis
|
|
206
|
+
|
|
207
|
+
## Related Commands
|
|
208
|
+
|
|
209
|
+
- `/p:analyze` - Just analyze without updating agents
|
|
210
|
+
- `/p:init` - Initialize project (first-time setup)
|
|
211
|
+
- `/p:context` - View current project context
|
|
212
|
+
|
|
213
|
+
## Implementation Notes
|
|
214
|
+
|
|
215
|
+
The sync command should:
|
|
216
|
+
1. Be idempotent (safe to run multiple times)
|
|
217
|
+
2. Preserve manual agent customizations (warn if detected)
|
|
218
|
+
3. Create backups before major changes
|
|
219
|
+
4. Provide clear diff of what changed
|
|
220
|
+
5. Allow granular control (which agents to update)
|