prjct-cli 0.10.13 → 0.11.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/CLAUDE.md +47 -2
  3. package/bin/dev.js +217 -0
  4. package/bin/prjct +10 -0
  5. package/bin/serve.js +78 -0
  6. package/core/agentic/command-executor.js +38 -112
  7. package/core/agentic/prompt-builder.js +72 -0
  8. package/core/bus/index.js +322 -0
  9. package/core/command-registry.js +65 -0
  10. package/core/domain/snapshot-manager.js +375 -0
  11. package/core/plugin/hooks.js +313 -0
  12. package/core/plugin/index.js +52 -0
  13. package/core/plugin/loader.js +331 -0
  14. package/core/plugin/registry.js +325 -0
  15. package/core/plugins/webhook.js +143 -0
  16. package/core/session/index.js +449 -0
  17. package/core/session/metrics.js +293 -0
  18. package/package.json +18 -4
  19. package/templates/agentic/agent-routing.md +42 -9
  20. package/templates/agentic/checklist-routing.md +98 -0
  21. package/templates/checklists/accessibility.md +33 -0
  22. package/templates/checklists/architecture.md +28 -0
  23. package/templates/checklists/code-quality.md +28 -0
  24. package/templates/checklists/data.md +33 -0
  25. package/templates/checklists/documentation.md +33 -0
  26. package/templates/checklists/infrastructure.md +33 -0
  27. package/templates/checklists/performance.md +33 -0
  28. package/templates/checklists/security.md +33 -0
  29. package/templates/checklists/testing.md +33 -0
  30. package/templates/checklists/ux-ui.md +37 -0
  31. package/templates/commands/bug.md +27 -1
  32. package/templates/commands/done.md +176 -54
  33. package/templates/commands/feature.md +38 -1
  34. package/templates/commands/history.md +176 -0
  35. package/templates/commands/init.md +28 -1
  36. package/templates/commands/now.md +191 -9
  37. package/templates/commands/pause.md +176 -12
  38. package/templates/commands/redo.md +142 -0
  39. package/templates/commands/resume.md +166 -62
  40. package/templates/commands/serve.md +121 -0
  41. package/templates/commands/ship.md +45 -1
  42. package/templates/commands/sync.md +34 -1
  43. package/templates/commands/task.md +27 -1
  44. package/templates/commands/undo.md +152 -0
@@ -0,0 +1,33 @@
1
+ # Infrastructure Checklist
2
+
3
+ > Applies to: Cloud, On-prem, Hybrid, Edge
4
+
5
+ ## Deployment
6
+ - [ ] Infrastructure as Code (Terraform, Pulumi, CloudFormation, etc.)
7
+ - [ ] Reproducible environments
8
+ - [ ] Rollback strategy defined
9
+ - [ ] Blue-green or canary deployment option
10
+
11
+ ## Observability
12
+ - [ ] Logging strategy defined
13
+ - [ ] Metrics collection configured
14
+ - [ ] Alerting thresholds set
15
+ - [ ] Distributed tracing (if applicable)
16
+
17
+ ## Security
18
+ - [ ] Secrets management (not in code)
19
+ - [ ] Network segmentation
20
+ - [ ] Least privilege access
21
+ - [ ] Encryption at rest and in transit
22
+
23
+ ## Reliability
24
+ - [ ] Backup strategy defined
25
+ - [ ] Disaster recovery plan
26
+ - [ ] Health checks configured
27
+ - [ ] Auto-scaling rules (if applicable)
28
+
29
+ ## Cost Management
30
+ - [ ] Resource sizing appropriate
31
+ - [ ] Unused resources identified
32
+ - [ ] Cost monitoring in place
33
+ - [ ] Budget alerts configured
@@ -0,0 +1,33 @@
1
+ # Performance Checklist
2
+
3
+ > Applies to: Backend, Frontend, Mobile, Database
4
+
5
+ ## Analysis
6
+ - [ ] Bottlenecks identified with profiling
7
+ - [ ] Baseline metrics established
8
+ - [ ] Performance budgets defined
9
+ - [ ] Benchmarks before/after changes
10
+
11
+ ## Optimization Strategies
12
+ - [ ] Algorithmic complexity reviewed (O(n) vs O(n²))
13
+ - [ ] Appropriate data structures used
14
+ - [ ] Caching implemented where beneficial
15
+ - [ ] Lazy loading for expensive operations
16
+
17
+ ## Resource Management
18
+ - [ ] Memory usage optimized
19
+ - [ ] Connection pooling used
20
+ - [ ] Batch operations where applicable
21
+ - [ ] Async/parallel processing considered
22
+
23
+ ## Frontend Specific
24
+ - [ ] Bundle size optimized
25
+ - [ ] Images optimized
26
+ - [ ] Critical rendering path optimized
27
+ - [ ] Network requests minimized
28
+
29
+ ## Backend Specific
30
+ - [ ] Database queries optimized
31
+ - [ ] Response compression enabled
32
+ - [ ] Proper indexing in place
33
+ - [ ] Connection limits configured
@@ -0,0 +1,33 @@
1
+ # Security Checklist
2
+
3
+ > ALWAYS ON - Applies to ALL applications
4
+
5
+ ## Input/Output
6
+ - [ ] All user input validated and sanitized
7
+ - [ ] Output encoded appropriately (prevent injection)
8
+ - [ ] File uploads restricted and scanned
9
+ - [ ] No sensitive data in logs or error messages
10
+
11
+ ## Authentication & Authorization
12
+ - [ ] Strong authentication mechanism
13
+ - [ ] Proper session management
14
+ - [ ] Authorization checked at every access point
15
+ - [ ] Principle of least privilege applied
16
+
17
+ ## Data Protection
18
+ - [ ] Sensitive data encrypted at rest
19
+ - [ ] Secure transmission (TLS/HTTPS)
20
+ - [ ] PII handled according to regulations
21
+ - [ ] Data retention policies followed
22
+
23
+ ## Dependencies
24
+ - [ ] Dependencies from trusted sources
25
+ - [ ] Known vulnerabilities checked
26
+ - [ ] Minimal dependency surface
27
+ - [ ] Regular security updates planned
28
+
29
+ ## API Security
30
+ - [ ] Rate limiting implemented
31
+ - [ ] Authentication required for sensitive endpoints
32
+ - [ ] CORS properly configured
33
+ - [ ] API keys/tokens secured
@@ -0,0 +1,33 @@
1
+ # Testing Checklist
2
+
3
+ > Applies to: Unit, Integration, E2E, Performance testing
4
+
5
+ ## Coverage Strategy
6
+ - [ ] Critical paths have high coverage
7
+ - [ ] Happy path tested
8
+ - [ ] Error paths tested
9
+ - [ ] Edge cases covered
10
+
11
+ ## Test Quality
12
+ - [ ] Tests are deterministic (no flaky tests)
13
+ - [ ] Tests are independent (no order dependency)
14
+ - [ ] Tests are fast (optimize slow tests)
15
+ - [ ] Tests are readable (clear intent)
16
+
17
+ ## Test Types
18
+ - [ ] Unit tests for business logic
19
+ - [ ] Integration tests for boundaries
20
+ - [ ] E2E tests for critical flows
21
+ - [ ] Performance tests for bottlenecks
22
+
23
+ ## Mocking Strategy
24
+ - [ ] External services mocked
25
+ - [ ] Database isolated or mocked
26
+ - [ ] Time-dependent code controlled
27
+ - [ ] Random values seeded
28
+
29
+ ## Test Maintenance
30
+ - [ ] Tests updated with code changes
31
+ - [ ] Dead tests removed
32
+ - [ ] Test data managed properly
33
+ - [ ] CI/CD integration working
@@ -0,0 +1,37 @@
1
+ # UX/UI Checklist
2
+
3
+ > Applies to: Web, Mobile, CLI, Desktop, API DX
4
+
5
+ ## User Experience
6
+ - [ ] Clear user journey/flow
7
+ - [ ] Feedback for every action
8
+ - [ ] Loading states shown
9
+ - [ ] Error states handled gracefully
10
+ - [ ] Success confirmation provided
11
+
12
+ ## Interface Design
13
+ - [ ] Consistent visual language
14
+ - [ ] Intuitive navigation
15
+ - [ ] Responsive/adaptive layout (if applicable)
16
+ - [ ] Touch targets adequate (mobile)
17
+ - [ ] Keyboard navigation (web/desktop)
18
+
19
+ ## CLI Specific
20
+ - [ ] Help text for all commands
21
+ - [ ] Clear error messages with suggestions
22
+ - [ ] Progress indicators for long operations
23
+ - [ ] Consistent flag naming conventions
24
+ - [ ] Exit codes meaningful
25
+
26
+ ## API DX (Developer Experience)
27
+ - [ ] Intuitive endpoint/function naming
28
+ - [ ] Consistent response format
29
+ - [ ] Helpful error messages with codes
30
+ - [ ] Good documentation with examples
31
+ - [ ] Predictable behavior
32
+
33
+ ## Information Architecture
34
+ - [ ] Content hierarchy clear
35
+ - [ ] Important actions prominent
36
+ - [ ] Related items grouped
37
+ - [ ] Search/filter for large datasets
@@ -1,10 +1,36 @@
1
1
  ---
2
- allowed-tools: [Read, Write]
2
+ allowed-tools: [Read, Write, Task, Glob]
3
3
  description: 'Report bug with auto-priority'
4
4
  ---
5
5
 
6
6
  # /p:bug
7
7
 
8
+ ## Agent Delegation (REQUIRED)
9
+
10
+ Before fixing a bug, delegate to specialist agent:
11
+
12
+ 1. **List agents**: `Glob("~/.prjct-cli/projects/{projectId}/agents/*.md")`
13
+ 2. **Analyze bug domain**: frontend, backend, database, etc.
14
+ 3. **Delegate via Task tool**:
15
+
16
+ ```
17
+ Task(
18
+ subagent_type: 'general-purpose',
19
+ prompt: '
20
+ ## Agent
21
+ Read: ~/.prjct-cli/projects/{projectId}/agents/{agent}.md
22
+
23
+ ## Bug
24
+ {bug description}
25
+
26
+ ## Flow
27
+ 1. Read agent file
28
+ 2. Apply expertise to fix bug
29
+ 3. Return fix
30
+ '
31
+ )
32
+ ```
33
+
8
34
  ## Severity Keywords
9
35
  - **Critical**: crash, down, broken, production
10
36
  - **High**: error, fail, issue
@@ -1,15 +1,17 @@
1
1
  ---
2
- allowed-tools: [Read, Write]
3
- description: 'Complete current task'
2
+ allowed-tools: [Read, Write, Bash]
3
+ description: 'Complete current task with session metrics'
4
4
  timestamp-rule: 'GetTimestamp() for all timestamps'
5
5
  ---
6
6
 
7
- # /p:done - Complete Current Task
7
+ # /p:done - Complete Current Task with Session Metrics
8
8
 
9
9
  ## Context Variables
10
10
  - `{projectId}`: From `.prjct/prjct.config.json`
11
11
  - `{globalPath}`: `~/.prjct-cli/projects/{projectId}`
12
12
  - `{nowPath}`: `{globalPath}/core/now.md`
13
+ - `{sessionPath}`: `{globalPath}/sessions/current.json`
14
+ - `{archiveDir}`: `{globalPath}/sessions/archive`
13
15
  - `{memoryPath}`: `{globalPath}/memory/context.jsonl`
14
16
  - `{metricsPath}`: `{globalPath}/progress/metrics.md`
15
17
 
@@ -22,116 +24,236 @@ IF file not found:
22
24
  OUTPUT: "No prjct project. Run /p:init first."
23
25
  STOP
24
26
 
25
- ## Step 2: Validate Active Task
27
+ ## Step 2: Check Session State
26
28
 
29
+ ### Try structured session first
30
+ READ: `{sessionPath}`
31
+
32
+ IF file exists:
33
+ PARSE as JSON
34
+ EXTRACT: {session} object
35
+ GOTO Step 3 (Session Completion)
36
+
37
+ ### Fallback to legacy now.md
27
38
  READ: `{nowPath}`
28
39
 
29
40
  IF empty OR contains "No current task":
30
41
  OUTPUT: "⚠️ No active task to complete. Use /p:now to start one."
31
42
  STOP
32
43
 
33
- ## Step 3: Extract Task Data
44
+ ## Step 3: Session Completion
34
45
 
35
- From NOW file content, extract:
46
+ ### Calculate Final Duration
47
+ SET: {now} = GetTimestamp()
36
48
 
37
- 1. **Task name**: Text between `**` markers
38
- - Pattern: `**(.+?)**`
39
- - Example: `**implement auth**` → "implement auth"
49
+ For each event in {session.timeline}:
50
+ Track start/resume/pause/complete times
51
+ Calculate total active time
40
52
 
41
- 2. **Start time**: Text after "Started:"
42
- - Pattern: `Started: (.+)`
43
- - Example: `Started: 11/28/2025, 2:30:00 PM`
53
+ SET: {duration} = total active seconds
54
+ SET: {durationFormatted} = format as "Xh Ym" or "Xm"
44
55
 
45
- 3. **Calculate duration**:
46
- - Current: GetTimestamp()
47
- - Duration: current - started
48
- - Format: "Xh Ym" (e.g., "2h 15m")
49
- - If < 1 hour: "Xm"
50
- - If < 1 minute: "< 1m"
56
+ ### Calculate Git Metrics
57
+ BASH: `git rev-list --count --since="{session.startedAt}" HEAD 2>/dev/null || echo "0"`
58
+ CAPTURE as {commits}
51
59
 
52
- ## Step 4: Clear Task File
60
+ BASH: `git diff --stat HEAD~{commits} 2>/dev/null || git diff --stat`
61
+ PARSE output for:
62
+ - {filesChanged}: number of files
63
+ - {linesAdded}: insertions
64
+ - {linesRemoved}: deletions
53
65
 
54
- WRITE: `{nowPath}`
66
+ ### Update Session Object
67
+ ```json
68
+ {
69
+ "id": "{session.id}",
70
+ "projectId": "{projectId}",
71
+ "task": "{session.task}",
72
+ "status": "completed",
73
+ "startedAt": "{session.startedAt}",
74
+ "pausedAt": null,
75
+ "completedAt": "{now}",
76
+ "duration": {duration},
77
+ "metrics": {
78
+ "filesChanged": {filesChanged},
79
+ "linesAdded": {linesAdded},
80
+ "linesRemoved": {linesRemoved},
81
+ "commits": {commits},
82
+ "snapshots": {session.metrics.snapshots}
83
+ },
84
+ "timeline": [
85
+ ...{session.timeline},
86
+ {"type": "complete", "at": "{now}"}
87
+ ]
88
+ }
89
+ ```
90
+
91
+ ## Step 4: Archive Session
92
+
93
+ ### Create Archive Directory
94
+ GET: {yearMonth} = YYYY-MM from {now}
95
+ ENSURE: `{archiveDir}/{yearMonth}` exists
96
+
97
+ BASH: `mkdir -p {archiveDir}/{yearMonth}`
98
+
99
+ ### Write Archived Session
100
+ WRITE: `{archiveDir}/{yearMonth}/{session.id}.json`
101
+ Content: Updated session object from Step 3
102
+
103
+ ## Step 5: Clear Current Session
104
+
105
+ DELETE: `{sessionPath}`
55
106
 
56
- Content (exact):
107
+ OR WRITE empty state:
108
+ WRITE: `{sessionPath}`
109
+ Content:
110
+ ```json
111
+ {}
112
+ ```
113
+
114
+ ## Step 6: Update Legacy now.md
115
+
116
+ WRITE: `{nowPath}`
117
+ Content:
57
118
  ```markdown
58
119
  # NOW
59
120
 
60
121
  No current task. Use `/p:now` to set focus.
61
122
  ```
62
123
 
63
- ## Step 5: Log to Memory
124
+ ## Step 7: Log to Memory
64
125
 
65
126
  APPEND to: `{memoryPath}`
66
127
 
67
128
  Single line (JSONL format):
68
129
  ```json
69
- {"timestamp":"{GetTimestamp()}","action":"task_completed","task":"{task}","duration":"{duration}"}
130
+ {"timestamp":"{now}","action":"session_completed","sessionId":"{session.id}","task":"{session.task}","duration":{duration},"metrics":{"files":{filesChanged},"added":{linesAdded},"removed":{linesRemoved},"commits":{commits}}}
70
131
  ```
71
132
 
72
- ## Step 6: Update Metrics (Optional)
133
+ ## Step 8: Update Metrics Summary
134
+
135
+ READ: `{metricsPath}` (create if not exists)
73
136
 
74
- IF `{metricsPath}` exists:
75
- READ current content
76
- APPEND new entry with task and duration
137
+ ### Append Daily Entry
138
+ GET: {date} = YYYY-MM-DD from {now}
139
+
140
+ INSERT or UPDATE entry for {date}:
141
+ ```markdown
142
+ ### {date}
143
+ - **{session.task}** ({durationFormatted})
144
+ - Files: {filesChanged} | +{linesAdded}/-{linesRemoved} | Commits: {commits}
145
+ ```
77
146
 
78
147
  ## Output
79
148
 
80
149
  SUCCESS:
81
150
  ```
82
- ✅ {task} ({duration})
151
+ ✅ {session.task} ({durationFormatted})
152
+
153
+ Session: {session.id}
154
+ Files: {filesChanged} | +{linesAdded}/-{linesRemoved}
155
+ Commits: {commits}
83
156
 
84
157
  Next:
85
158
  • /p:now - Start next task
86
159
  • /p:ship - Ship completed work
87
- • /p:next - See priority queue
160
+ • /p:progress - View metrics
88
161
  ```
89
162
 
90
163
  ## Error Handling
91
164
 
92
- | Error | Response |
93
- |-------|----------|
94
- | Config not found | "No prjct project. Run /p:init first." |
95
- | Now.md empty | "⚠️ No active task. Use /p:now to start." |
96
- | Parse fails | Use task = "task", duration = "unknown", continue |
97
- | Write fails | Log warning, continue (non-critical) |
165
+ | Error | Response | Action |
166
+ |-------|----------|--------|
167
+ | Config not found | "No prjct project" | STOP |
168
+ | No session/task | "No active task" | STOP |
169
+ | Git fails | Use zeros for metrics | CONTINUE |
170
+ | Archive fails | Log warning | CONTINUE |
171
+ | Write fails | Log warning | CONTINUE |
98
172
 
99
173
  ## Examples
100
174
 
101
- ### Example 1: Success
102
- **now.md content:**
175
+ ### Example 1: Full Session Completion
176
+ **Session:**
177
+ ```json
178
+ {
179
+ "id": "sess_abc12345",
180
+ "task": "implement authentication",
181
+ "status": "active",
182
+ "startedAt": "2025-12-07T10:00:00.000Z",
183
+ "timeline": [
184
+ {"type": "start", "at": "2025-12-07T10:00:00.000Z"}
185
+ ]
186
+ }
103
187
  ```
104
- # NOW
105
188
 
106
- **implement authentication**
189
+ **Git activity:**
190
+ - 3 commits
191
+ - 5 files changed
192
+ - +120/-30 lines
107
193
 
108
- Started: 11/28/2025, 12:15:00 PM
194
+ **Output:**
109
195
  ```
196
+ ✅ implement authentication (2h 15m)
110
197
 
111
- **Current time:** 11/28/2025, 2:30:00 PM
112
- **Duration:** 2h 15m
113
- **Output:** `✅ implement authentication (2h 15m)`
198
+ Session: sess_abc12345
199
+ Files: 5 | +120/-30
200
+ Commits: 3
114
201
 
115
- ### Example 2: No Task
116
- **now.md content:**
202
+ Next:
203
+ • /p:now - Start next task
204
+ • /p:ship - Ship completed work
205
+ • /p:progress - View metrics
117
206
  ```
118
- # NOW
119
207
 
120
- No current task.
208
+ ### Example 2: Session with Pauses
209
+ **Session with multiple pause/resume:**
210
+ ```json
211
+ {
212
+ "id": "sess_xyz98765",
213
+ "task": "fix login bug",
214
+ "timeline": [
215
+ {"type": "start", "at": "2025-12-07T09:00:00.000Z"},
216
+ {"type": "pause", "at": "2025-12-07T10:00:00.000Z"},
217
+ {"type": "resume", "at": "2025-12-07T14:00:00.000Z"},
218
+ {"type": "pause", "at": "2025-12-07T15:30:00.000Z"},
219
+ {"type": "resume", "at": "2025-12-07T16:00:00.000Z"}
220
+ ]
221
+ }
222
+ ```
223
+
224
+ **Completion at 17:00:**
225
+ - Active time: 1h + 1.5h + 1h = 3.5h
226
+ - Duration: 3h 30m
227
+
228
+ **Output:**
121
229
  ```
230
+ ✅ fix login bug (3h 30m)
122
231
 
123
- **Output:** `⚠️ No active task to complete. Use /p:now to start one.`
232
+ Session: sess_xyz98765
233
+ Files: 2 | +45/-12
234
+ Commits: 1
124
235
 
125
- ### Example 3: Quick Task
236
+ Next:
237
+ • /p:now - Start next task
238
+ • /p:ship - Ship completed work
239
+ • /p:progress - View metrics
240
+ ```
241
+
242
+ ### Example 3: Legacy Fallback (No Session)
126
243
  **now.md content:**
127
244
  ```
128
245
  # NOW
129
246
 
130
- **fix typo in readme**
247
+ **quick fix**
131
248
 
132
- Started: 11/28/2025, 2:25:00 PM
249
+ Started: 2025-12-07T16:45:00.000Z
133
250
  ```
134
251
 
135
- **Current time:** 11/28/2025, 2:30:00 PM
136
- **Duration:** 5m
137
- **Output:** `✅ fix typo in readme (5m)`
252
+ **Output:**
253
+ ```
254
+ quick fix (15m)
255
+
256
+ Next:
257
+ • /p:now - Start next task
258
+ • /p:ship - Ship completed work
259
+ ```
@@ -1,11 +1,48 @@
1
1
  ---
2
- allowed-tools: [Read, Write, Bash]
2
+ allowed-tools: [Read, Write, Bash, Task, Glob]
3
3
  description: 'Value analysis + roadmap + task breakdown + auto-start'
4
4
  timestamp-rule: 'GetTimestamp() and GetDate() for ALL timestamps'
5
5
  ---
6
6
 
7
7
  # /p:feature - Add Feature to Roadmap
8
8
 
9
+ ## Agent Delegation (REQUIRED)
10
+
11
+ Before executing any code-related task, delegate to a specialist agent:
12
+
13
+ ### Step 0: Assign Agent
14
+
15
+ 1. **List agents**: `Glob("~/.prjct-cli/projects/{projectId}/agents/*.md")`
16
+ 2. **Read routing**: `Read("templates/agentic/agent-routing.md")`
17
+ 3. **Analyze task**: Determine domain (frontend, backend, testing, etc.)
18
+ 4. **Select agent**: Match task to best agent
19
+ 5. **Delegate via Task tool** (pass reference, NOT content):
20
+
21
+ ```
22
+ Task(
23
+ subagent_type: 'general-purpose',
24
+ prompt: '
25
+ ## Agent Assignment
26
+ Read and apply: ~/.prjct-cli/projects/{projectId}/agents/{agent-name}.md
27
+
28
+ ## Task
29
+ {feature description}
30
+
31
+ ## Context
32
+ - Project: {projectPath}
33
+ - Feature: {feature}
34
+
35
+ ## Flow
36
+ 1. Read agent file FIRST
37
+ 2. Apply agent expertise
38
+ 3. Execute task
39
+ 4. Return results
40
+ '
41
+ )
42
+ ```
43
+
44
+ **CRITICAL:** Pass file PATH, not content. Subagent reads it (~200 bytes vs 3-5KB).
45
+
9
46
  ## Context Variables
10
47
  - `{projectId}`: From `.prjct/prjct.config.json`
11
48
  - `{globalPath}`: `~/.prjct-cli/projects/{projectId}`