prjct-cli 0.13.3 → 0.15.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 (193) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/bin/prjct +10 -13
  3. package/core/agentic/memory-system/semantic-memories.ts +2 -1
  4. package/core/agentic/plan-mode/plan-mode.ts +2 -1
  5. package/core/agentic/prompt-builder.ts +22 -43
  6. package/core/agentic/services.ts +5 -5
  7. package/core/agentic/smart-context.ts +7 -2
  8. package/core/command-registry/core-commands.ts +54 -29
  9. package/core/command-registry/optional-commands.ts +64 -0
  10. package/core/command-registry/setup-commands.ts +18 -3
  11. package/core/commands/analysis.ts +21 -68
  12. package/core/commands/analytics.ts +247 -213
  13. package/core/commands/base.ts +1 -1
  14. package/core/commands/index.ts +41 -36
  15. package/core/commands/maintenance.ts +300 -31
  16. package/core/commands/planning.ts +233 -22
  17. package/core/commands/setup.ts +3 -8
  18. package/core/commands/shipping.ts +14 -18
  19. package/core/commands/types.ts +8 -6
  20. package/core/commands/workflow.ts +105 -100
  21. package/core/context/generator.ts +317 -0
  22. package/core/context-sync.ts +7 -350
  23. package/core/data/index.ts +13 -32
  24. package/core/data/md-ideas-manager.ts +155 -0
  25. package/core/data/md-queue-manager.ts +4 -3
  26. package/core/data/md-shipped-manager.ts +90 -0
  27. package/core/data/md-state-manager.ts +11 -7
  28. package/core/domain/agent-generator.ts +23 -63
  29. package/core/events/index.ts +143 -0
  30. package/core/index.ts +17 -14
  31. package/core/infrastructure/capability-installer.ts +13 -149
  32. package/core/infrastructure/migrator/project-scanner.ts +2 -1
  33. package/core/infrastructure/path-manager.ts +4 -6
  34. package/core/infrastructure/setup.ts +3 -0
  35. package/core/infrastructure/uuid-migration.ts +750 -0
  36. package/core/outcomes/recorder.ts +2 -1
  37. package/core/plugin/loader.ts +4 -7
  38. package/core/plugin/registry.ts +3 -3
  39. package/core/schemas/index.ts +23 -25
  40. package/core/schemas/state.ts +1 -0
  41. package/core/serializers/ideas-serializer.ts +187 -0
  42. package/core/serializers/index.ts +16 -0
  43. package/core/serializers/shipped-serializer.ts +108 -0
  44. package/core/session/utils.ts +3 -9
  45. package/core/storage/ideas-storage.ts +273 -0
  46. package/core/storage/index.ts +204 -0
  47. package/core/storage/queue-storage.ts +297 -0
  48. package/core/storage/shipped-storage.ts +223 -0
  49. package/core/storage/state-storage.ts +235 -0
  50. package/core/storage/storage-manager.ts +175 -0
  51. package/package.json +1 -1
  52. package/packages/web/app/api/projects/[id]/momentum/route.ts +257 -0
  53. package/packages/web/app/api/sessions/current/route.ts +132 -0
  54. package/packages/web/app/api/sessions/history/route.ts +96 -14
  55. package/packages/web/app/globals.css +5 -0
  56. package/packages/web/app/layout.tsx +2 -0
  57. package/packages/web/app/project/[id]/code/layout.tsx +18 -0
  58. package/packages/web/app/project/[id]/code/page.tsx +408 -0
  59. package/packages/web/app/project/[id]/page.tsx +359 -389
  60. package/packages/web/app/project/[id]/reports/page.tsx +59 -0
  61. package/packages/web/app/project/[id]/reports/print/page.tsx +58 -0
  62. package/packages/web/components/ActivityTimeline/ActivityTimeline.tsx +0 -1
  63. package/packages/web/components/AgentsCard/AgentsCard.tsx +64 -34
  64. package/packages/web/components/AgentsCard/AgentsCard.types.ts +1 -0
  65. package/packages/web/components/AppSidebar/AppSidebar.tsx +135 -11
  66. package/packages/web/components/BentoCard/BentoCard.constants.ts +3 -3
  67. package/packages/web/components/BentoCard/BentoCard.tsx +2 -1
  68. package/packages/web/components/BentoGrid/BentoGrid.tsx +2 -2
  69. package/packages/web/components/BlockersCard/BlockersCard.tsx +65 -57
  70. package/packages/web/components/BlockersCard/BlockersCard.types.ts +1 -0
  71. package/packages/web/components/CommandBar/CommandBar.tsx +67 -0
  72. package/packages/web/components/CommandBar/index.ts +1 -0
  73. package/packages/web/components/DashboardContent/DashboardContent.tsx +35 -5
  74. package/packages/web/components/DateGroup/DateGroup.tsx +1 -1
  75. package/packages/web/components/EmptyState/EmptyState.tsx +39 -21
  76. package/packages/web/components/EmptyState/EmptyState.types.ts +1 -0
  77. package/packages/web/components/EventRow/EventRow.tsx +4 -4
  78. package/packages/web/components/EventRow/EventRow.utils.ts +3 -3
  79. package/packages/web/components/HeroSection/HeroSection.tsx +52 -15
  80. package/packages/web/components/HeroSection/HeroSection.types.ts +4 -4
  81. package/packages/web/components/HeroSection/HeroSection.utils.ts +7 -3
  82. package/packages/web/components/IdeasCard/IdeasCard.tsx +94 -27
  83. package/packages/web/components/IdeasCard/IdeasCard.types.ts +1 -0
  84. package/packages/web/components/MasonryGrid/MasonryGrid.tsx +18 -0
  85. package/packages/web/components/MasonryGrid/index.ts +1 -0
  86. package/packages/web/components/MomentumWidget/MomentumWidget.tsx +119 -0
  87. package/packages/web/components/MomentumWidget/MomentumWidget.types.ts +16 -0
  88. package/packages/web/components/MomentumWidget/index.ts +2 -0
  89. package/packages/web/components/NowCard/NowCard.tsx +81 -56
  90. package/packages/web/components/NowCard/NowCard.types.ts +1 -0
  91. package/packages/web/components/PageHeader/PageHeader.tsx +24 -0
  92. package/packages/web/components/PageHeader/index.ts +1 -0
  93. package/packages/web/components/ProgressRing/ProgressRing.constants.ts +2 -2
  94. package/packages/web/components/ProjectAvatar/ProjectAvatar.tsx +2 -2
  95. package/packages/web/components/ProjectColorDot/ProjectColorDot.tsx +37 -0
  96. package/packages/web/components/ProjectColorDot/index.ts +1 -0
  97. package/packages/web/components/ProjectSelectorModal/ProjectSelectorModal.tsx +104 -0
  98. package/packages/web/components/ProjectSelectorModal/index.ts +1 -0
  99. package/packages/web/components/Providers/Providers.tsx +4 -1
  100. package/packages/web/components/QueueCard/QueueCard.tsx +78 -25
  101. package/packages/web/components/QueueCard/QueueCard.types.ts +1 -0
  102. package/packages/web/components/QueueCard/QueueCard.utils.ts +3 -3
  103. package/packages/web/components/RecoverCard/RecoverCard.tsx +72 -0
  104. package/packages/web/components/RecoverCard/RecoverCard.types.ts +16 -0
  105. package/packages/web/components/RecoverCard/index.ts +2 -0
  106. package/packages/web/components/RoadmapCard/RoadmapCard.tsx +101 -33
  107. package/packages/web/components/RoadmapCard/RoadmapCard.types.ts +1 -0
  108. package/packages/web/components/ShipsCard/ShipsCard.tsx +71 -28
  109. package/packages/web/components/ShipsCard/ShipsCard.types.ts +2 -0
  110. package/packages/web/components/SparklineChart/SparklineChart.tsx +20 -18
  111. package/packages/web/components/StatsMasonry/StatsMasonry.tsx +95 -0
  112. package/packages/web/components/StatsMasonry/index.ts +1 -0
  113. package/packages/web/components/StreakCard/StreakCard.tsx +37 -35
  114. package/packages/web/components/TasksCounter/TasksCounter.tsx +1 -1
  115. package/packages/web/components/TechStackBadges/TechStackBadges.tsx +12 -4
  116. package/packages/web/components/TerminalDock/DockToggleTab.tsx +29 -0
  117. package/packages/web/components/TerminalDock/TerminalDock.tsx +386 -0
  118. package/packages/web/components/TerminalDock/TerminalDockTab.tsx +130 -0
  119. package/packages/web/components/TerminalDock/TerminalTabBar.tsx +142 -0
  120. package/packages/web/components/TerminalDock/index.ts +2 -0
  121. package/packages/web/components/VelocityBadge/VelocityBadge.tsx +8 -3
  122. package/packages/web/components/VelocityCard/VelocityCard.tsx +49 -47
  123. package/packages/web/components/WeeklyReports/PrintableReport.tsx +259 -0
  124. package/packages/web/components/WeeklyReports/ReportPreviewCard.tsx +187 -0
  125. package/packages/web/components/WeeklyReports/WeekCalendar.tsx +288 -0
  126. package/packages/web/components/WeeklyReports/WeeklyReports.tsx +149 -0
  127. package/packages/web/components/WeeklyReports/index.ts +4 -0
  128. package/packages/web/components/WeeklySparkline/WeeklySparkline.tsx +16 -4
  129. package/packages/web/components/WeeklySparkline/WeeklySparkline.types.ts +1 -0
  130. package/packages/web/components/charts/SessionsChart.tsx +6 -3
  131. package/packages/web/components/ui/dialog.tsx +143 -0
  132. package/packages/web/components/ui/drawer.tsx +135 -0
  133. package/packages/web/components/ui/select.tsx +187 -0
  134. package/packages/web/context/GlobalTerminalContext.tsx +538 -0
  135. package/packages/web/lib/commands.ts +81 -0
  136. package/packages/web/lib/generate-week-report.ts +285 -0
  137. package/packages/web/lib/parse-prjct-files.ts +56 -55
  138. package/packages/web/lib/project-colors.ts +58 -0
  139. package/packages/web/lib/projects.ts +58 -5
  140. package/packages/web/lib/services/projects.server.ts +11 -1
  141. package/packages/web/next-env.d.ts +1 -1
  142. package/packages/web/package.json +5 -1
  143. package/templates/commands/analyze.md +39 -3
  144. package/templates/commands/ask.md +58 -3
  145. package/templates/commands/bug.md +117 -26
  146. package/templates/commands/dash.md +95 -158
  147. package/templates/commands/done.md +130 -148
  148. package/templates/commands/feature.md +125 -103
  149. package/templates/commands/git.md +18 -3
  150. package/templates/commands/idea.md +121 -38
  151. package/templates/commands/init.md +124 -20
  152. package/templates/commands/migrate-all.md +63 -28
  153. package/templates/commands/migrate.md +140 -0
  154. package/templates/commands/next.md +115 -5
  155. package/templates/commands/now.md +146 -82
  156. package/templates/commands/pause.md +89 -74
  157. package/templates/commands/redo.md +6 -4
  158. package/templates/commands/resume.md +141 -59
  159. package/templates/commands/ship.md +103 -231
  160. package/templates/commands/spec.md +98 -8
  161. package/templates/commands/suggest.md +22 -2
  162. package/templates/commands/sync.md +192 -203
  163. package/templates/commands/undo.md +6 -4
  164. package/core/data/agents-manager.ts +0 -76
  165. package/core/data/analysis-manager.ts +0 -83
  166. package/core/data/base-manager.ts +0 -156
  167. package/core/data/ideas-manager.ts +0 -81
  168. package/core/data/outcomes-manager.ts +0 -96
  169. package/core/data/project-manager.ts +0 -75
  170. package/core/data/roadmap-manager.ts +0 -118
  171. package/core/data/shipped-manager.ts +0 -65
  172. package/core/data/state-manager.ts +0 -214
  173. package/core/state/index.ts +0 -25
  174. package/core/state/manager.ts +0 -376
  175. package/core/state/types.ts +0 -185
  176. package/core/utils/project-capabilities.ts +0 -156
  177. package/core/view-generator.ts +0 -536
  178. package/packages/web/app/project/[id]/stats/loading.tsx +0 -43
  179. package/packages/web/app/project/[id]/stats/page.tsx +0 -253
  180. package/templates/agent-assignment.md +0 -72
  181. package/templates/analysis/project-analysis.md +0 -78
  182. package/templates/checklists/accessibility.md +0 -33
  183. package/templates/commands/build.md +0 -17
  184. package/templates/commands/decision.md +0 -226
  185. package/templates/commands/fix.md +0 -79
  186. package/templates/commands/help.md +0 -61
  187. package/templates/commands/progress.md +0 -14
  188. package/templates/commands/recap.md +0 -14
  189. package/templates/commands/roadmap.md +0 -52
  190. package/templates/commands/status.md +0 -17
  191. package/templates/commands/task.md +0 -63
  192. package/templates/commands/work.md +0 -44
  193. package/templates/commands/workflow.md +0 -12
@@ -2,16 +2,24 @@
2
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
- architecture: 'MD-first - MD files are source of truth'
5
+ architecture: 'Write-Through (JSON MD Events)'
6
+ storage-layer: true
7
+ source-of-truth: 'storage/queue.json'
8
+ claude-context: 'context/next.md'
9
+ backend-sync: 'sync/pending.json'
6
10
  ---
7
11
 
8
12
  # /p:feature - Add Feature to Roadmap
9
13
 
10
- ## Architecture: MD-First
14
+ ## Architecture: Write-Through Pattern
11
15
 
12
- **Source of Truth**: `planning/roadmap.md`, `core/next.md`, `core/now.md`
16
+ ```
17
+ User Action → Storage (JSON) → Context (MD) → Sync Events
18
+ ```
13
19
 
14
- MD files are the source of truth. Write directly to MD files.
20
+ **Source of Truth**: `storage/queue.json` (tasks), `storage/roadmap.json` (features)
21
+ **Claude Context**: `context/next.md`, `context/roadmap.md` (generated)
22
+ **Backend Sync**: `sync/pending.json` (events)
15
23
 
16
24
  ## Agent Delegation (REQUIRED)
17
25
 
@@ -53,10 +61,11 @@ Task(
53
61
  ## Context Variables
54
62
  - `{projectId}`: From `.prjct/prjct.config.json`
55
63
  - `{globalPath}`: `~/.prjct-cli/projects/{projectId}`
56
- - `{roadmapPath}`: `{globalPath}/planning/roadmap.md`
57
- - `{nextPath}`: `{globalPath}/core/next.md`
58
- - `{nowPath}`: `{globalPath}/core/now.md`
59
- - `{memoryPath}`: `{globalPath}/memory/context.jsonl`
64
+ - `{queuePath}`: `{globalPath}/storage/queue.json`
65
+ - `{statePath}`: `{globalPath}/storage/state.json`
66
+ - `{nextContextPath}`: `{globalPath}/context/next.md`
67
+ - `{syncPath}`: `{globalPath}/sync/pending.json`
68
+ - `{memoryPath}`: `{globalPath}/memory/events.jsonl`
60
69
  - `{feature}`: User-provided feature description
61
70
 
62
71
  ## Step 1: Read Config
@@ -148,96 +157,54 @@ For feature "add user authentication":
148
157
  ```
149
158
 
150
159
  GENERATE: {tasks} = list of task descriptions
151
-
152
- ## Step 5: Update Roadmap (MD)
153
-
154
- READ: `{roadmapPath}` (or create default if not exists)
155
-
156
- Default structure:
157
- ```markdown
158
- # Roadmap
159
-
160
- ## Active
161
-
162
- _No active features_
163
-
164
- ## Planned
165
-
166
- _No planned features_
167
-
168
- ## Shipped
169
-
170
- _Nothing shipped yet_
171
- ```
172
-
173
- ### Generate Feature ID
174
- GENERATE: {featureId} = "feat_" + 8 random alphanumeric chars
160
+ GENERATE: {featureId} = UUID v4
175
161
  SET: {now} = GetTimestamp()
176
162
 
177
- ### Update roadmap.md
178
-
179
- Parse existing content and add new feature under "## Active" section:
180
-
181
- ```markdown
182
- # Roadmap
183
-
184
- ## Active
163
+ ## Step 5: Update Storage (SOURCE OF TRUTH)
185
164
 
186
- ### {feature}
187
- - **ID**: {featureId}
188
- - **Impact**: {impact}
189
- - **Effort**: {effort}
190
- - **Started**: {now}
191
- - **Tasks**:
192
- - [ ] {task1}
193
- - [ ] {task2}
194
- - [ ] {task3}
195
- ...
196
-
197
- {...existing active features}
198
-
199
- ## Planned
200
-
201
- {...existing planned features}
202
-
203
- ## Shipped
204
-
205
- {...existing shipped features}
206
- ```
165
+ ### Update queue.json
207
166
 
208
- WRITE: `{roadmapPath}`
209
-
210
- ## Step 6: Update Priority Queue (MD)
211
-
212
- READ: `{nextPath}` (or create default if not exists)
167
+ READ: `{queuePath}` (or create default if not exists)
213
168
 
214
169
  Default structure:
215
- ```markdown
216
- # Next
217
-
218
- ## High Priority
219
-
220
- _No high priority tasks_
221
-
222
- ## Normal Priority
170
+ ```json
171
+ {
172
+ "tasks": [],
173
+ "lastUpdated": null
174
+ }
175
+ ```
223
176
 
224
- _No tasks in queue_
177
+ For each task in {tasks}, create task object:
178
+ ```json
179
+ {
180
+ "id": "{taskId}",
181
+ "description": "{taskDescription}",
182
+ "type": "feature",
183
+ "priority": "normal",
184
+ "section": "active",
185
+ "featureId": "{featureId}",
186
+ "featureName": "{feature}",
187
+ "createdAt": "{now}"
188
+ }
189
+ ```
225
190
 
226
- ## Low Priority
191
+ APPEND all tasks to `tasks` array
192
+ SET: `lastUpdated` = {now}
193
+ WRITE: `{queuePath}`
227
194
 
228
- _No low priority tasks_
229
- ```
195
+ ## Step 6: Generate Context (FOR CLAUDE)
230
196
 
231
- ### Add Tasks to Queue
197
+ ### Generate context/next.md
232
198
 
233
- For each task in {tasks}, add to appropriate priority section:
199
+ READ: `{queuePath}`
200
+ TRANSFORM to markdown:
234
201
 
235
202
  ```markdown
236
203
  # Next
237
204
 
238
205
  ## High Priority
239
206
 
240
- {if high priority tasks}
207
+ {high priority tasks from queue}
241
208
 
242
209
  ## Normal Priority
243
210
 
@@ -245,58 +212,113 @@ For each task in {tasks}, add to appropriate priority section:
245
212
  - [ ] {task2} @{featureId}
246
213
  ...
247
214
 
248
- {...existing tasks}
249
-
250
215
  ## Low Priority
251
216
 
252
- {...existing low priority tasks}
217
+ {low priority tasks}
253
218
  ```
254
219
 
255
- WRITE: `{nextPath}`
220
+ WRITE: `{nextContextPath}`
256
221
 
257
- ## Step 7: Auto-Start First Task (MD)
222
+ ## Step 7: Auto-Start First Task
258
223
 
259
- READ: `{nowPath}`
224
+ READ: `{statePath}`
260
225
 
261
- IF file is empty OR contains "_No active task_":
226
+ IF no currentTask:
262
227
  ### Start First Task
263
228
  {firstTask} = first item from {tasks}
264
- GENERATE: {sessionId} = "sess_" + 8 random alphanumeric chars
229
+ GENERATE: {sessionId} = UUID v4
230
+
231
+ ### Update state.json
232
+ ```json
233
+ {
234
+ "currentTask": {
235
+ "id": "{firstTask.id}",
236
+ "description": "{firstTask.description}",
237
+ "sessionId": "{sessionId}",
238
+ "featureId": "{featureId}",
239
+ "startedAt": "{now}",
240
+ "status": "active"
241
+ },
242
+ "pausedTask": null,
243
+ "lastUpdated": "{now}"
244
+ }
245
+ ```
246
+ WRITE: `{statePath}`
265
247
 
266
- ### Update now.md
248
+ ### Generate context/now.md
267
249
  ```markdown
268
250
  # NOW
269
251
 
270
- **{firstTask}**
252
+ **{firstTask.description}**
271
253
 
272
254
  Started: {now}
273
255
  Session: {sessionId}
274
256
  Feature: {featureId}
275
257
  ```
258
+ WRITE: `{globalPath}/context/now.md`
276
259
 
277
- WRITE: `{nowPath}`
278
260
  {autoStarted} = true
279
261
  ELSE:
280
262
  {autoStarted} = false
281
263
 
282
- ## Step 8: Log to Memory
264
+ ## Step 8: Queue Sync Events
283
265
 
284
- GET: {date} = GetDate()
285
- EXTRACT: {yearMonth} = YYYY-MM from {date}
266
+ READ: `{syncPath}` or create empty array
286
267
 
287
- ENSURE directory:
288
- BASH: `mkdir -p {globalPath}/memory/sessions/{yearMonth}`
268
+ ### Feature created event
269
+ APPEND:
270
+ ```json
271
+ {
272
+ "type": "feature.created",
273
+ "path": ["queue"],
274
+ "data": {
275
+ "featureId": "{featureId}",
276
+ "name": "{feature}",
277
+ "impact": "{impact}",
278
+ "effort": "{effort}",
279
+ "taskCount": {taskCount}
280
+ },
281
+ "timestamp": "{now}",
282
+ "projectId": "{projectId}"
283
+ }
284
+ ```
289
285
 
290
- APPEND to: `{globalPath}/memory/sessions/{yearMonth}/{date}.jsonl`
286
+ ### Tasks added events (one per task)
287
+ For each task:
288
+ ```json
289
+ {
290
+ "type": "queue.task_added",
291
+ "path": ["queue"],
292
+ "data": {
293
+ "taskId": "{taskId}",
294
+ "description": "{taskDescription}",
295
+ "featureId": "{featureId}"
296
+ },
297
+ "timestamp": "{now}",
298
+ "projectId": "{projectId}"
299
+ }
300
+ ```
291
301
 
292
- Single line (JSONL):
302
+ IF {autoStarted}:
293
303
  ```json
294
- {"ts":"{now}","type":"feature_add","featureId":"{featureId}","name":"{feature}","tasks":{taskCount},"impact":"{impact}","effort":"{effort}"}
304
+ {
305
+ "type": "task.started",
306
+ "path": ["state"],
307
+ "data": {
308
+ "taskId": "{firstTask.id}",
309
+ "sessionId": "{sessionId}",
310
+ "featureId": "{featureId}"
311
+ },
312
+ "timestamp": "{now}",
313
+ "projectId": "{projectId}"
314
+ }
295
315
  ```
296
316
 
297
- APPEND to: `{memoryPath}`
317
+ WRITE: `{syncPath}`
318
+
319
+ ## Step 9: Log to Memory
298
320
 
299
- Single line (JSONL):
321
+ APPEND to: `{memoryPath}`
300
322
  ```json
301
323
  {"timestamp":"{now}","action":"feature_added","featureId":"{featureId}","feature":"{feature}","tasks":{taskCount}}
302
324
  ```
@@ -310,7 +332,7 @@ SUCCESS (with auto-start):
310
332
  Impact: {impact} | Effort: {effort}
311
333
  Tasks: {taskCount}
312
334
 
313
- 🎯 Started: {firstTask}
335
+ 🎯 Started: {firstTask.description}
314
336
 
315
337
  Next:
316
338
  • Work on the task
@@ -1,9 +1,18 @@
1
1
  ---
2
2
  allowed-tools: [Bash, Read, Write]
3
3
  description: 'Smart git operations with context'
4
+ architecture: 'Write-Through (JSON → MD → Events)'
5
+ storage-layer: true
6
+ source-of-truth: 'storage/state.json'
4
7
  ---
5
8
 
6
- # /p:git
9
+ # /p:git - Smart Git Operations
10
+
11
+ ## Architecture: Write-Through Pattern
12
+
13
+ Reads from **Storage (JSON)** as source of truth.
14
+
15
+ **Source of Truth**: `storage/state.json`
7
16
 
8
17
  ## Usage
9
18
 
@@ -14,13 +23,19 @@ description: 'Smart git operations with context'
14
23
  /p:git undo # Undo last commit
15
24
  ```
16
25
 
26
+ ## Context Variables
27
+ - `{projectId}`: From `.prjct/prjct.config.json`
28
+ - `{globalPath}`: `~/.prjct-cli/projects/{projectId}`
29
+ - `{statePath}`: `{globalPath}/storage/state.json`
30
+ - `{memoryPath}`: `{globalPath}/memory/events.jsonl`
31
+
17
32
  ## Flow: commit
18
33
 
19
- 1. Read: `core/now.md` → get task context
34
+ 1. Read: `storage/state.json` → get task context
20
35
  2. Git: `add .` → stage changes
21
36
  3. Create: commit message with prjct metadata
22
37
  4. Commit: with message
23
- 5. Log: `memory/context.jsonl`
38
+ 5. Log: `memory/events.jsonl`
24
39
 
25
40
  ## Flow: push
26
41
 
@@ -2,22 +2,32 @@
2
2
  allowed-tools: [Read, Write, Bash, GetTimestamp, GetDate]
3
3
  description: 'Quick idea capture'
4
4
  timestamp-rule: 'GetTimestamp() and GetDate() for timestamps'
5
- architecture: 'MD-first - MD files are source of truth'
5
+ architecture: 'Write-Through (JSON MD Events)'
6
+ storage-layer: true
7
+ source-of-truth: 'storage/ideas.json'
8
+ claude-context: 'context/ideas.md'
9
+ backend-sync: 'sync/pending.json'
6
10
  ---
7
11
 
8
12
  # /p:idea - Quick Idea Capture
9
13
 
10
- ## Architecture: MD-First
14
+ ## Architecture: Write-Through Pattern
11
15
 
12
- **Source of Truth**: `planning/ideas.md`
16
+ ```
17
+ User Action → Storage (JSON) → Context (MD) → Sync Events
18
+ ```
13
19
 
14
- MD files are the source of truth. Write directly to MD files.
20
+ **Source of Truth**: `storage/ideas.json`
21
+ **Claude Context**: `context/ideas.md` (generated)
22
+ **Backend Sync**: `sync/pending.json` (events)
15
23
 
16
24
  ## Context Variables
17
25
  - `{projectId}`: From `.prjct/prjct.config.json`
18
26
  - `{globalPath}`: `~/.prjct-cli/projects/{projectId}`
19
- - `{ideasPath}`: `{globalPath}/planning/ideas.md`
20
- - `{memoryPath}`: `{globalPath}/memory/context.jsonl`
27
+ - `{ideasStoragePath}`: `{globalPath}/storage/ideas.json`
28
+ - `{ideasContextPath}`: `{globalPath}/context/ideas.md`
29
+ - `{syncPath}`: `{globalPath}/sync/pending.json`
30
+ - `{memoryPath}`: `{globalPath}/memory/events.jsonl`
21
31
  - `{text}`: User-provided idea text
22
32
 
23
33
  ## Step 1: Read Config
@@ -29,64 +39,137 @@ IF file not found:
29
39
  OUTPUT: "No prjct project. Run /p:init first."
30
40
  STOP
31
41
 
32
- ## Step 2: Read Current Ideas
42
+ ## Step 2: Analyze Idea
33
43
 
34
- READ: `{ideasPath}` (or create default if not exists)
44
+ Based on {text}, detect:
35
45
 
36
- Default structure:
37
- ```markdown
38
- # Ideas
46
+ ### Priority Detection
47
+ - If mentions "urgent", "critical", "asap" → priority = "high"
48
+ - If mentions "later", "maybe", "nice to have" → priority = "low"
49
+ - Default → priority = "medium"
39
50
 
40
- ## Pending
51
+ ### Tag Detection
52
+ - If mentions UI/design → add `#ui` tag
53
+ - If mentions performance → add `#perf` tag
54
+ - If mentions bug/fix → add `#bug` tag
55
+ - If mentions API/backend → add `#api` tag
56
+ - If mentions security → add `#security` tag
57
+ - If mentions docs → add `#docs` tag
41
58
 
42
- _No ideas yet_
59
+ ## Step 3: Update Storage (SOURCE OF TRUTH)
43
60
 
44
- ## Implemented
61
+ GENERATE: {ideaId} = UUID v4
62
+ SET: {now} = GetTimestamp()
45
63
 
46
- _Nothing implemented yet_
64
+ ### Read existing ideas
65
+ READ: `{ideasStoragePath}` or create default:
66
+ ```json
67
+ {
68
+ "ideas": [],
69
+ "lastUpdated": null
70
+ }
47
71
  ```
48
72
 
49
- ## Step 3: Add New Idea (MD)
73
+ ### Create idea object
74
+ ```json
75
+ {
76
+ "id": "{ideaId}",
77
+ "text": "{text}",
78
+ "priority": "{priority}",
79
+ "tags": ["{detected_tags}"],
80
+ "status": "pending",
81
+ "createdAt": "{now}"
82
+ }
83
+ ```
50
84
 
51
- GENERATE: {ideaId} = "idea_" + 8 random alphanumeric chars
52
- SET: {now} = GetTimestamp()
85
+ ### Update ideas.json
86
+ PREPEND new idea to ideas array
87
+ SET: lastUpdated = {now}
88
+ WRITE: `{ideasStoragePath}`
53
89
 
54
- ### Analyze idea for tags
55
- Based on {text}, detect tags:
56
- - If mentions UI/design → add `#ui` tag
57
- - If mentions performance → add `#perf` tag
58
- - If mentions bug/fix → add `#bug` tag
59
- - If mentions API/backend → add `#api` tag
90
+ ## Step 4: Generate Context (FOR CLAUDE)
60
91
 
61
- ### Update ideas.md
62
-
63
- Parse existing content and add new idea under "## Pending" section:
92
+ WRITE: `{ideasContextPath}`
64
93
 
65
94
  ```markdown
66
- # Ideas
95
+ # IDEAS
67
96
 
68
97
  ## Pending
69
98
 
70
- - **{text}** #{detected_tags}
71
- - ID: {ideaId}
72
- - Added: {now}
73
-
74
- {...existing pending ideas}
99
+ {FOR EACH idea in ideas WHERE status == "pending":}
100
+ - **{idea.text}** {idea.tags.join(' ')}
101
+ - Priority: {idea.priority}
102
+ - Added: {idea.createdAt}
103
+ {END FOR}
75
104
 
76
- ## Implemented
105
+ ## Converted
77
106
 
78
- {...existing implemented ideas}
107
+ {FOR EACH idea in ideas WHERE status == "converted":}
108
+ - ~~{idea.text}~~ → Feature: {idea.convertedTo}
109
+ {END FOR}
79
110
  ```
80
111
 
81
- WRITE: `{ideasPath}`
112
+ ## Step 5: Queue Sync Event (FOR BACKEND)
82
113
 
83
- ## Step 4: Log to Memory
114
+ READ: `{syncPath}` or create empty array
115
+ APPEND event:
116
+ ```json
117
+ {
118
+ "type": "idea.created",
119
+ "path": ["ideas"],
120
+ "data": {
121
+ "ideaId": "{ideaId}",
122
+ "text": "{text}",
123
+ "priority": "{priority}",
124
+ "tags": ["{detected_tags}"]
125
+ },
126
+ "timestamp": "{now}",
127
+ "projectId": "{projectId}"
128
+ }
129
+ ```
130
+ WRITE: `{syncPath}`
131
+
132
+ ## Step 6: Log to Memory (AUDIT TRAIL)
84
133
 
85
134
  APPEND to: `{memoryPath}`
86
135
  ```json
87
- {"timestamp":"{now}","action":"idea_added","ideaId":"{ideaId}","text":"{text}"}
136
+ {"timestamp":"{now}","action":"idea_added","ideaId":"{ideaId}","text":"{text}","priority":"{priority}"}
88
137
  ```
89
138
 
90
139
  ## Response
91
140
 
92
141
  `💡 {text} | Saved | Start: /p:feature "{text}"`
142
+
143
+ ## Error Handling
144
+
145
+ | Error | Response | Action |
146
+ |-------|----------|--------|
147
+ | No project | "No prjct project" | STOP |
148
+ | No text | "What's your idea?" | ASK |
149
+ | Write fails | Log warning | CONTINUE |
150
+
151
+ ## Examples
152
+
153
+ ### Example 1: Simple Idea
154
+ **Input:** `/p:idea add dark mode support`
155
+
156
+ **Output:**
157
+ ```
158
+ 💡 add dark mode support | Saved | Start: /p:feature "add dark mode support"
159
+ ```
160
+
161
+ ### Example 2: Idea with Priority
162
+ **Input:** `/p:idea urgent fix login bug`
163
+
164
+ **Output:**
165
+ ```
166
+ 💡 urgent fix login bug [high] | Saved | Start: /p:feature "fix login bug"
167
+ ```
168
+
169
+ ### Example 3: Idea with Tags
170
+ **Input:** `/p:idea improve API performance`
171
+
172
+ **Output:**
173
+ ```
174
+ 💡 improve API performance #api #perf | Saved
175
+ ```