cmp-standards 2.4.0 → 2.6.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/README.md +633 -611
- package/dist/db/drizzle-client.d.ts +3 -3
- package/dist/db/drizzle-client.d.ts.map +1 -1
- package/dist/db/drizzle-client.js +57 -58
- package/dist/db/drizzle-client.js.map +1 -1
- package/dist/db/turso-client.js +11 -11
- package/dist/eslint/rules/no-async-useeffect.js +6 -6
- package/dist/hooks/cloud-pre-tool-use.js +20 -20
- package/dist/hooks/cloud-session-start.d.ts +15 -3
- package/dist/hooks/cloud-session-start.d.ts.map +1 -1
- package/dist/hooks/cloud-session-start.js +135 -8
- package/dist/hooks/cloud-session-start.js.map +1 -1
- package/dist/hooks/session-start.d.ts +2 -1
- package/dist/hooks/session-start.d.ts.map +1 -1
- package/dist/hooks/session-start.js +99 -74
- package/dist/hooks/session-start.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/schema/plans.d.ts +194 -0
- package/dist/schema/plans.d.ts.map +1 -0
- package/dist/schema/plans.js +180 -0
- package/dist/schema/plans.js.map +1 -0
- package/dist/services/ContextGenerator.d.ts +16 -0
- package/dist/services/ContextGenerator.d.ts.map +1 -0
- package/dist/services/ContextGenerator.js +62 -0
- package/dist/services/ContextGenerator.js.map +1 -0
- package/dist/services/PlanManager.d.ts +99 -0
- package/dist/services/PlanManager.d.ts.map +1 -0
- package/dist/services/PlanManager.js +372 -0
- package/dist/services/PlanManager.js.map +1 -0
- package/dist/services/ProjectScaffold.js +76 -76
- package/dist/services/context-injector.d.ts +105 -0
- package/dist/services/context-injector.d.ts.map +1 -0
- package/dist/services/context-injector.js +357 -0
- package/dist/services/context-injector.js.map +1 -0
- package/dist/services/index.d.ts +15 -15
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +18 -20
- package/dist/services/index.js.map +1 -1
- package/dist/services/memory-router.d.ts +98 -0
- package/dist/services/memory-router.d.ts.map +1 -0
- package/dist/services/memory-router.js +373 -0
- package/dist/services/memory-router.js.map +1 -0
- package/dist/services/pattern-tracker.d.ts +93 -0
- package/dist/services/pattern-tracker.d.ts.map +1 -0
- package/dist/services/pattern-tracker.js +347 -0
- package/dist/services/pattern-tracker.js.map +1 -0
- package/dist/services/semantic-search.d.ts +33 -35
- package/dist/services/semantic-search.d.ts.map +1 -1
- package/dist/services/semantic-search.js +207 -165
- package/dist/services/semantic-search.js.map +1 -1
- package/package.json +100 -100
- package/standards/README.md +50 -50
- package/standards/experts/expert-routing.md +215 -215
- package/standards/general/code-quality.md +86 -86
- package/standards/general/memory-usage.md +205 -205
- package/standards/general/sync-workflow.md +235 -235
- package/standards/general/workflow.md +82 -82
- package/standards/hooks/mandatory-tracking.md +446 -446
- package/standards/infrastructure/cloud-database.md +287 -287
- package/standards/mcp/server-design.md +243 -243
- package/standards/mcp/tool-patterns.md +354 -354
- package/standards/skills/skill-structure.md +286 -286
- package/standards/skills/workflow-design.md +323 -323
- package/standards/tools/tool-design.md +297 -297
- package/templates/agents/architecture-expert.md +61 -61
- package/templates/agents/database-expert.md +62 -62
- package/templates/agents/documentation-expert.md +57 -57
- package/templates/agents/memory-expert.md +88 -88
- package/templates/agents/performance-expert.md +61 -61
- package/templates/agents/security-expert.md +59 -59
- package/templates/agents/ux-expert.md +63 -63
- package/templates/agents/worker.md +75 -75
- package/templates/ai-skills/SKILL_TEMPLATE.md +55 -55
- package/templates/claude-settings.json +72 -72
- package/templates/commands/experts.md +138 -138
- package/templates/hooks/README.md +158 -158
- package/templates/hooks/project.config.json.template +77 -77
- package/templates/hooks/settings.local.json.template +57 -57
- package/templates/memory-config.json +56 -56
- package/templates/memory-config.schema.json +212 -212
- package/templates/settings.json +58 -58
- package/templates/skills/continue.md +205 -205
- package/templates/workflows/business-improvement.md +264 -264
- package/templates/workflows/expert-review.md +153 -153
- package/templates/workflows/internal-app.md +245 -245
- package/templates/workflows/sync-docs.md +187 -187
package/README.md
CHANGED
|
@@ -1,611 +1,633 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
##
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Show
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### `cmp-standards
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
cmp-standards
|
|
248
|
-
|
|
249
|
-
Options:
|
|
250
|
-
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
│
|
|
283
|
-
│ ├──
|
|
284
|
-
│ │
|
|
285
|
-
│ ├──
|
|
286
|
-
│ │
|
|
287
|
-
│
|
|
288
|
-
│ ├──
|
|
289
|
-
│ │ ├──
|
|
290
|
-
│ │
|
|
291
|
-
│
|
|
292
|
-
│ ├──
|
|
293
|
-
│ │
|
|
294
|
-
│ ├──
|
|
295
|
-
│ │ └──
|
|
296
|
-
│
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
###
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
#
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
-
|
|
595
|
-
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
1
|
+
# CMP - Collective Memory Protocol
|
|
2
|
+
|
|
3
|
+
> **The Development Intelligence Layer** - Persistent memory, cross-project learning, and multi-agent collaboration for AI-assisted development.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/cmp-standards)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Philosophy
|
|
11
|
+
|
|
12
|
+
| Principle | Meaning |
|
|
13
|
+
|-----------|---------|
|
|
14
|
+
| **Evidence > Assumptions** | Never assume. Always verify. Read before writing. |
|
|
15
|
+
| **Cloud > Local** | Memory lives in the cloud. Sessions are ephemeral, knowledge is permanent. |
|
|
16
|
+
| **Collective > Individual** | One project's learnings benefit all projects. |
|
|
17
|
+
| **Continuity > Restarts** | Work survives IDE restarts, machine changes, and agent switches. |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
### Core
|
|
24
|
+
- **Plans with Checkpoints** - Persistent objectives with semantic matching and multi-agent handoffs
|
|
25
|
+
- **ESLint Plugin** - 11+ custom rules for code quality
|
|
26
|
+
- **Task Tracking** - Automatic task registration in database
|
|
27
|
+
- **Idea Capture** - Collect ideas and improvements during work
|
|
28
|
+
- **Memory System** - Session context and memory management
|
|
29
|
+
- **Auto-Improvement** - Pattern detection and ESLint rule generation
|
|
30
|
+
- **Dashboard** - Web UI for visualization
|
|
31
|
+
- **MCP Server** - Model Context Protocol integration
|
|
32
|
+
- **Analytics** - Usage tracking and insights
|
|
33
|
+
|
|
34
|
+
### Cloud Infrastructure
|
|
35
|
+
- **Turso** (SQLite Edge) - Plans, tasks, improvements, memories
|
|
36
|
+
- **Upstash Redis** - Session cache, rate limiting, real-time sync
|
|
37
|
+
- **Upstash Vector** - Semantic search with embeddings
|
|
38
|
+
- **Cloud Hooks** - Session continuity across IDE restarts
|
|
39
|
+
|
|
40
|
+
### Multi-Agent Continuity (v2.5.0+)
|
|
41
|
+
- **Plan Detection** - Semantic matching finds related plans at session start
|
|
42
|
+
- **Checkpoints** - Save points that record progress, decisions, and next steps
|
|
43
|
+
- **Agent Handoffs** - One agent can resume where another left off
|
|
44
|
+
- **Cross-Session** - Plans persist across IDE restarts and machine changes
|
|
45
|
+
|
|
46
|
+
## Cloud Quick Start
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { cloud } from 'cmp-standards'
|
|
50
|
+
|
|
51
|
+
// Initialize cloud services
|
|
52
|
+
await cloud.init()
|
|
53
|
+
|
|
54
|
+
// Start work session
|
|
55
|
+
const session = await cloud.startWorkSession('MYPROJECT')
|
|
56
|
+
console.log(`Active tasks: ${session.activeTasks.length}`)
|
|
57
|
+
|
|
58
|
+
// Start task
|
|
59
|
+
const taskId = await cloud.startTask('MYPROJECT', session.sessionId, {
|
|
60
|
+
title: 'Implement feature X',
|
|
61
|
+
plan: ['Step 1', 'Step 2'],
|
|
62
|
+
domain: 'features'
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// Complete task (requires at least 1 improvement)
|
|
66
|
+
await cloud.completeTask(taskId, {
|
|
67
|
+
result: 'success',
|
|
68
|
+
improvements: [{
|
|
69
|
+
area: 'features',
|
|
70
|
+
title: 'Add caching',
|
|
71
|
+
description: 'Could cache API responses',
|
|
72
|
+
priority: 'medium'
|
|
73
|
+
}],
|
|
74
|
+
lessons: ['Pattern X works better']
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Environment Variables
|
|
79
|
+
|
|
80
|
+
```env
|
|
81
|
+
# Turso (SQLite Edge)
|
|
82
|
+
TURSO_DATABASE_URL=libsql://your-db.turso.io
|
|
83
|
+
TURSO_AUTH_TOKEN=your-token
|
|
84
|
+
|
|
85
|
+
# Upstash Redis
|
|
86
|
+
UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
|
|
87
|
+
UPSTASH_REDIS_REST_TOKEN=your-token
|
|
88
|
+
|
|
89
|
+
# Upstash Vector
|
|
90
|
+
UPSTASH_VECTOR_REST_URL=https://your-vector.upstash.io
|
|
91
|
+
UPSTASH_VECTOR_REST_TOKEN=your-token
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install cmp-standards
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Initialize in project
|
|
104
|
+
cmp-standards init --system MYPROJECT --name "My Project"
|
|
105
|
+
|
|
106
|
+
# Check status
|
|
107
|
+
cmp-standards status
|
|
108
|
+
|
|
109
|
+
# Start dashboard
|
|
110
|
+
cmp-standards dashboard
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## CLI Commands
|
|
114
|
+
|
|
115
|
+
### `cmp-standards init`
|
|
116
|
+
|
|
117
|
+
Initialize the system in current project.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
cmp-standards init [options]
|
|
121
|
+
|
|
122
|
+
Options:
|
|
123
|
+
-s, --system <system> System identifier (SWARMSCALE, PANEL)
|
|
124
|
+
-n, --name <name> Project name
|
|
125
|
+
-f, --force Overwrite existing configuration
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `cmp-standards generate`
|
|
129
|
+
|
|
130
|
+
Generate embedding registry from documentation.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
cmp-standards generate [options]
|
|
134
|
+
|
|
135
|
+
Options:
|
|
136
|
+
-i, --incremental Only update changed files
|
|
137
|
+
--files <files> Specific files (comma-separated)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### `cmp-standards scan`
|
|
141
|
+
|
|
142
|
+
Scan codebase for patterns.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
cmp-standards scan [options]
|
|
146
|
+
|
|
147
|
+
Options:
|
|
148
|
+
-d, --dir <directory> Directory to scan (default: src)
|
|
149
|
+
-t, --threshold <n> Pattern threshold (default: 3)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### `cmp-standards improve`
|
|
153
|
+
|
|
154
|
+
Run auto-improvement for triggered patterns.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cmp-standards improve [options]
|
|
158
|
+
|
|
159
|
+
Options:
|
|
160
|
+
--dry-run Show without making changes
|
|
161
|
+
-p, --pattern <id> Specific pattern to improve
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `cmp-standards status`
|
|
165
|
+
|
|
166
|
+
Show memory system status.
|
|
167
|
+
|
|
168
|
+
### `cmp-standards dashboard`
|
|
169
|
+
|
|
170
|
+
Start the memory dashboard web UI.
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
cmp-standards dashboard [options]
|
|
174
|
+
|
|
175
|
+
Options:
|
|
176
|
+
-p, --port <port> Port to run on (default: 3847)
|
|
177
|
+
--no-open Don't open browser automatically
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `cmp-standards analytics`
|
|
181
|
+
|
|
182
|
+
Show analytics and system health.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
cmp-standards analytics [options]
|
|
186
|
+
|
|
187
|
+
Options:
|
|
188
|
+
-p, --period <period> Time period (day, week, month)
|
|
189
|
+
--json Output as JSON
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### `cmp-standards feedback`
|
|
193
|
+
|
|
194
|
+
View feedback statistics.
|
|
195
|
+
|
|
196
|
+
### `cmp-standards mcp`
|
|
197
|
+
|
|
198
|
+
Start the MCP server for Claude integration.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Workflow Commands
|
|
203
|
+
|
|
204
|
+
### `cmp-standards tasks`
|
|
205
|
+
|
|
206
|
+
View and manage tasks.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
cmp-standards tasks [options]
|
|
210
|
+
|
|
211
|
+
Options:
|
|
212
|
+
-a, --all Show all tasks including completed
|
|
213
|
+
-l, --limit <number> Limit number of tasks (default: 10)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `cmp-standards ideas`
|
|
217
|
+
|
|
218
|
+
View captured ideas.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
cmp-standards ideas [options]
|
|
222
|
+
|
|
223
|
+
Options:
|
|
224
|
+
-c, --category <cat> Filter by category (feature, refactor, bug, optimization, documentation)
|
|
225
|
+
-p, --priority <pri> Filter by priority (high, medium, low)
|
|
226
|
+
-l, --limit <number> Limit number of ideas (default: 20)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### `cmp-standards improvements`
|
|
230
|
+
|
|
231
|
+
View suggested improvements.
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
cmp-standards improvements [options]
|
|
235
|
+
|
|
236
|
+
Options:
|
|
237
|
+
-t, --type <type> Filter by type (code_quality, performance, security, ux, architecture)
|
|
238
|
+
-e, --effort <effort> Filter by effort (small, medium, large)
|
|
239
|
+
-l, --limit <number> Limit number (default: 20)
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `cmp-standards plan`
|
|
243
|
+
|
|
244
|
+
Manage work plans.
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
cmp-standards plan [options]
|
|
248
|
+
|
|
249
|
+
Options:
|
|
250
|
+
-s, --status Show current plan status
|
|
251
|
+
-c, --complete Complete current task
|
|
252
|
+
-n, --next Move to next task
|
|
253
|
+
-h, --history Show plan history
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### `cmp-standards capture <text>`
|
|
257
|
+
|
|
258
|
+
Quick capture an idea or improvement. Auto-categorizes based on content.
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
cmp-standards capture "Consider adding caching to API calls"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### `cmp-standards export`
|
|
265
|
+
|
|
266
|
+
Export ideas and improvements as markdown.
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
cmp-standards export [options]
|
|
270
|
+
|
|
271
|
+
Options:
|
|
272
|
+
-o, --output <file> Output file (default: IDEAS_AND_IMPROVEMENTS.md)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Architecture
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
cmp-standards
|
|
281
|
+
├── src/
|
|
282
|
+
│ ├── hooks/
|
|
283
|
+
│ │ ├── session-start.ts # Context loader on session start
|
|
284
|
+
│ │ ├── pre-tool-use.ts # Guards + embedding injection
|
|
285
|
+
│ │ ├── post-tool-use.ts # Record changes after Edit/Write
|
|
286
|
+
│ │ └── memory-checkpoint.ts # Record learnings after changes
|
|
287
|
+
│ ├── eslint/
|
|
288
|
+
│ │ ├── index.ts # ESLint plugin entry
|
|
289
|
+
│ │ ├── rules/ # Custom ESLint rules
|
|
290
|
+
│ │ └── config-builder.ts # Dynamic config generation
|
|
291
|
+
│ ├── services/
|
|
292
|
+
│ │ ├── TaskTracker.ts # Task tracking
|
|
293
|
+
│ │ ├── IdeaCollector.ts # Idea/improvement capture
|
|
294
|
+
│ │ ├── WorkPlanManager.ts # Work plan management
|
|
295
|
+
│ │ └── ... # Other services
|
|
296
|
+
│ ├── registry/
|
|
297
|
+
│ │ ├── generator.ts # Parse docs → embeddings
|
|
298
|
+
│ │ └── embeddings.ts # OpenAI/Gemini embedding service
|
|
299
|
+
│ ├── auto-improve/
|
|
300
|
+
│ │ ├── pattern-detector.ts # Detect repeated violations
|
|
301
|
+
│ │ └── eslint-generator.ts # Generate ESLint rules
|
|
302
|
+
│ ├── db/
|
|
303
|
+
│ │ ├── client.ts # DEV_Items database client (mock)
|
|
304
|
+
│ │ └── drizzle-client.ts # Real Drizzle ORM client
|
|
305
|
+
│ ├── mcp/
|
|
306
|
+
│ │ └── server.ts # MCP server for Claude tools
|
|
307
|
+
│ ├── dashboard/
|
|
308
|
+
│ │ ├── server.ts # Express dashboard server
|
|
309
|
+
│ │ └── ui.ts # React UI generator
|
|
310
|
+
│ ├── utils/
|
|
311
|
+
│ │ ├── config.ts # Configuration management
|
|
312
|
+
│ │ ├── paths.ts # Path utilities with traversal protection
|
|
313
|
+
│ │ └── git.ts # Safe git operations (simple-git)
|
|
314
|
+
│ ├── types/
|
|
315
|
+
│ │ └── index.ts # Type definitions
|
|
316
|
+
│ ├── cli/
|
|
317
|
+
│ │ └── index.ts # CLI commands
|
|
318
|
+
│ └── index.ts # Main exports
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Configuration
|
|
322
|
+
|
|
323
|
+
### `.claude/memory-config.json`
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"system": "SWARMSCALE",
|
|
328
|
+
"projectName": "SwarmScale",
|
|
329
|
+
"domains": ["video-studio", "avatars", "campaigns"],
|
|
330
|
+
"guards": {
|
|
331
|
+
"enabled": true,
|
|
332
|
+
"rules": [
|
|
333
|
+
{
|
|
334
|
+
"id": "schema-protection",
|
|
335
|
+
"type": "block",
|
|
336
|
+
"filePattern": "src/server/schema/auth.ts",
|
|
337
|
+
"message": "PANEL_* tables are READ-ONLY"
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
},
|
|
341
|
+
"embedding": {
|
|
342
|
+
"enabled": true,
|
|
343
|
+
"threshold": 0.60,
|
|
344
|
+
"maxSections": 3
|
|
345
|
+
},
|
|
346
|
+
"autoImprovement": {
|
|
347
|
+
"enabled": true,
|
|
348
|
+
"violationThreshold": 3,
|
|
349
|
+
"generateEslintRules": true
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### `.claude/settings.json`
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
"hooks": {
|
|
359
|
+
"PreToolUse": [
|
|
360
|
+
{
|
|
361
|
+
"matcher": "Task",
|
|
362
|
+
"hooks": [{
|
|
363
|
+
"type": "command",
|
|
364
|
+
"command": "npx tsx node_modules/cmp-standards/dist/hooks/pre-tool-use.js"
|
|
365
|
+
}]
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
"SessionStart": [
|
|
369
|
+
{
|
|
370
|
+
"matcher": "",
|
|
371
|
+
"hooks": [{
|
|
372
|
+
"type": "command",
|
|
373
|
+
"command": "npx tsx node_modules/cmp-standards/dist/hooks/session-start.js"
|
|
374
|
+
}]
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
"plugins": {
|
|
379
|
+
"cmp-standards": {
|
|
380
|
+
"version": "2.0.0",
|
|
381
|
+
"enabled": true
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Hooks
|
|
388
|
+
|
|
389
|
+
### SessionStart Hook
|
|
390
|
+
|
|
391
|
+
Executes on session start:
|
|
392
|
+
1. Detects module from `git diff` (last 24h)
|
|
393
|
+
2. Queries DEV_Items for relevant memories
|
|
394
|
+
3. Returns formatted context
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
import { SessionStartHook } from 'cmp-standards/hooks'
|
|
398
|
+
|
|
399
|
+
const hook = new SessionStartHook()
|
|
400
|
+
const result = await hook.execute()
|
|
401
|
+
// result.context contains session context
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### PreToolUse Hook
|
|
405
|
+
|
|
406
|
+
Executes before Edit/Write/Task tools:
|
|
407
|
+
1. **Edit/Write**: Validates against guard rules
|
|
408
|
+
2. **Task**: Injects relevant knowledge via embeddings
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
import { PreToolUseHook } from 'cmp-standards/hooks'
|
|
412
|
+
|
|
413
|
+
const hook = new PreToolUseHook()
|
|
414
|
+
const result = await hook.execute({
|
|
415
|
+
tool_name: 'Edit',
|
|
416
|
+
parameters: { file_path: 'src/file.ts', new_string: '...' }
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
if (result.mode === 'block') {
|
|
420
|
+
// Guard violation - block operation
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## ESLint Plugin
|
|
425
|
+
|
|
426
|
+
The package includes a custom ESLint plugin with 11+ rules.
|
|
427
|
+
|
|
428
|
+
### Using the ESLint Plugin
|
|
429
|
+
|
|
430
|
+
```javascript
|
|
431
|
+
// eslint.config.mjs
|
|
432
|
+
import cmpStandards from 'cmp-standards/eslint'
|
|
433
|
+
|
|
434
|
+
export default [
|
|
435
|
+
...cmpStandards.configs.recommended,
|
|
436
|
+
]
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Dynamic Configuration
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
import { generateConfig } from 'cmp-standards/eslint'
|
|
443
|
+
|
|
444
|
+
// Generate config based on project structure
|
|
445
|
+
const config = await generateConfig(process.cwd())
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
## Auto-Improvement
|
|
449
|
+
|
|
450
|
+
### Pattern Detection
|
|
451
|
+
|
|
452
|
+
Built-in patterns detected:
|
|
453
|
+
- `any-type` - Using `any` type
|
|
454
|
+
- `console-log` - Console.log in production
|
|
455
|
+
- `eslint-disable` - ESLint disable comments
|
|
456
|
+
- `hardcoded-string` - UI strings not using i18n
|
|
457
|
+
- `direct-db-query` - Database queries in components
|
|
458
|
+
- `inline-style` - Inline styles instead of Tailwind
|
|
459
|
+
|
|
460
|
+
### ESLint Rule Generation
|
|
461
|
+
|
|
462
|
+
When a pattern is detected 3+ times:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
# Scan for patterns
|
|
466
|
+
cmp-standards scan
|
|
467
|
+
|
|
468
|
+
# Output:
|
|
469
|
+
# any-type [high]
|
|
470
|
+
# Count: 5, Files: 3
|
|
471
|
+
# Patterns ready for auto-improvement
|
|
472
|
+
|
|
473
|
+
# Generate ESLint rule
|
|
474
|
+
cmp-standards improve
|
|
475
|
+
|
|
476
|
+
# Creates: eslint-plugin-charter/rules/no-any-type.js
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Programmatic Usage
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
import {
|
|
483
|
+
loadConfig,
|
|
484
|
+
PatternDetector,
|
|
485
|
+
ESLintGenerator,
|
|
486
|
+
RegistryGenerator
|
|
487
|
+
} from 'cmp-standards'
|
|
488
|
+
|
|
489
|
+
// Load config
|
|
490
|
+
const config = await loadConfig(process.cwd())
|
|
491
|
+
|
|
492
|
+
// Detect patterns
|
|
493
|
+
const detector = new PatternDetector(config)
|
|
494
|
+
const patterns = detector.scan(fileContent, filePath)
|
|
495
|
+
const results = detector.getResults()
|
|
496
|
+
|
|
497
|
+
// Generate ESLint rules
|
|
498
|
+
const generator = new ESLintGenerator()
|
|
499
|
+
await generator.generateAllRules(results.triggered)
|
|
500
|
+
|
|
501
|
+
// Generate registry
|
|
502
|
+
const registry = new RegistryGenerator()
|
|
503
|
+
await registry.generate()
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## System Isolation
|
|
507
|
+
|
|
508
|
+
Data is isolated by `system` field in DEV_Items:
|
|
509
|
+
|
|
510
|
+
| System | Project |
|
|
511
|
+
|--------|---------|
|
|
512
|
+
| `SWARMSCALE` | SwarmScale |
|
|
513
|
+
| `PANEL` | TheCharterPanel |
|
|
514
|
+
| `ECOSYSTEM` | Cross-project |
|
|
515
|
+
|
|
516
|
+
Always filter by system:
|
|
517
|
+
|
|
518
|
+
```typescript
|
|
519
|
+
// Correct
|
|
520
|
+
db.select().from(devItems).where(eq(devItems.system, 'SWARMSCALE'))
|
|
521
|
+
|
|
522
|
+
// Wrong - returns ALL projects' data
|
|
523
|
+
db.select().from(devItems)
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
## Security Features
|
|
527
|
+
|
|
528
|
+
### Path Traversal Protection
|
|
529
|
+
|
|
530
|
+
All path operations are validated to prevent directory traversal attacks:
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
import { validateSafePath, safeJoin } from 'cmp-standards'
|
|
534
|
+
|
|
535
|
+
// Throws PathTraversalError if path escapes base
|
|
536
|
+
validateSafePath(projectRoot, userPath)
|
|
537
|
+
|
|
538
|
+
// Safe path joining with validation
|
|
539
|
+
const safePath = safeJoin(projectRoot, 'subdir', filename)
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### Safe Git Operations
|
|
543
|
+
|
|
544
|
+
Git operations use `simple-git` instead of shell commands to prevent command injection:
|
|
545
|
+
|
|
546
|
+
```typescript
|
|
547
|
+
import { getCurrentBranch, getRecentChanges } from 'cmp-standards'
|
|
548
|
+
|
|
549
|
+
// Safe - uses simple-git internally
|
|
550
|
+
const branch = await getCurrentBranch(projectRoot)
|
|
551
|
+
const changes = await getRecentChanges(projectRoot, { commits: 10 })
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
## Environment Variables
|
|
555
|
+
|
|
556
|
+
```bash
|
|
557
|
+
# Required for embedding generation
|
|
558
|
+
OPENAI_API_KEY=sk-... # Preferred
|
|
559
|
+
GEMINI_API_KEY=... # Fallback
|
|
560
|
+
|
|
561
|
+
# Optional
|
|
562
|
+
MEMORY_DEBUG=true # Enable debug logging
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
## Development
|
|
566
|
+
|
|
567
|
+
```bash
|
|
568
|
+
# Install dependencies
|
|
569
|
+
npm install
|
|
570
|
+
|
|
571
|
+
# Build
|
|
572
|
+
npm run build
|
|
573
|
+
|
|
574
|
+
# Watch mode
|
|
575
|
+
npm run dev
|
|
576
|
+
|
|
577
|
+
# Run tests
|
|
578
|
+
npm test
|
|
579
|
+
|
|
580
|
+
# Link for local development
|
|
581
|
+
npm link
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
## MCP Server
|
|
585
|
+
|
|
586
|
+
The MCP (Model Context Protocol) server exposes memory tools that Claude can use directly:
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
# Start MCP server
|
|
590
|
+
cmp-standards mcp
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
**Available Tools:**
|
|
594
|
+
- `memory_search` - Search memories by query
|
|
595
|
+
- `memory_write` - Write new memory/learning
|
|
596
|
+
- `memory_list` - List recent memories
|
|
597
|
+
- `pattern_check` - Check for detected patterns
|
|
598
|
+
- `pattern_report` - Report a new pattern occurrence
|
|
599
|
+
- `session_context` - Get current session context
|
|
600
|
+
- `feedback_submit` - Submit feedback on a memory
|
|
601
|
+
|
|
602
|
+
## Dashboard
|
|
603
|
+
|
|
604
|
+
Start the standalone web dashboard:
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
cmp-standards dashboard
|
|
608
|
+
# Opens http://localhost:3847
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
**Features:**
|
|
612
|
+
- View all memories with search and filtering
|
|
613
|
+
- Browse detected patterns
|
|
614
|
+
- See session history
|
|
615
|
+
- Submit feedback on memories
|
|
616
|
+
- Create new memories
|
|
617
|
+
- View analytics and system health
|
|
618
|
+
|
|
619
|
+
## Database Configuration
|
|
620
|
+
|
|
621
|
+
Set environment variables for database connection:
|
|
622
|
+
|
|
623
|
+
```bash
|
|
624
|
+
DATABASE_HOST=localhost
|
|
625
|
+
DATABASE_PORT=3306
|
|
626
|
+
DATABASE_USER=root
|
|
627
|
+
DATABASE_PASSWORD=your-password
|
|
628
|
+
DATABASE_NAME=metanautical
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
## License
|
|
632
|
+
|
|
633
|
+
MIT - Carlos Martin Pavon
|