universal-agent-memory 0.5.2 โ†’ 0.5.4

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.
@@ -1,11 +1,24 @@
1
1
  <!--
2
- CLAUDE.md Universal Template - v7.0
2
+ CLAUDE.md Universal Template - v9.0
3
3
 
4
4
  CHANGES IN THIS VERSION:
5
- - All project-specific content uses Handlebars placeholders
6
- - No hardcoded project data (Pay2U removed)
7
- - Simplified memory references (agent-managed, not user-managed)
8
- - Template variables documented inline
5
+ - Fully universal with Handlebars placeholders (no hardcoded project content)
6
+ - Context Field integration with Code Field prompt
7
+ - Inhibition-style directives ("Do not X" creates blockers)
8
+ - Optimized token usage with conditional sections
9
+ - Database protection (memory persists with project)
10
+
11
+ CODE FIELD ATTRIBUTION:
12
+ The Code Field prompt technique is based on research from:
13
+ https://github.com/NeoVertex1/context-field
14
+
15
+ Context Field is experimental research on context field prompts and cognitive
16
+ regime shifts in large language models. The code_field.md prompt produces:
17
+ - 100% assumption stating (vs 0% baseline)
18
+ - 89% bug detection in code review (vs 39% baseline)
19
+ - 100% refusal of impossible requests (vs 0% baseline)
20
+
21
+ License: Research shared for exploration and reuse with attribution.
9
22
 
10
23
  Core Variables:
11
24
  {{PROJECT_NAME}}, {{PROJECT_PATH}}, {{DEFAULT_BRANCH}}, {{STRUCTURE_DATE}}
@@ -24,15 +37,15 @@
24
37
  {{DOCKER_COMPOSE_PATH}}
25
38
 
26
39
  Commands:
27
- {{TEST_COMMAND}}, {{BUILD_COMMAND}}, {{LINT_COMMAND}}, {{INSTALL_HOOKS_CMD}}
40
+ {{TEST_COMMAND}}, {{BUILD_COMMAND}}, {{LINT_COMMAND}}
28
41
  -->
29
42
 
30
43
  <coding_guidelines>
31
44
 
32
45
  # {{PROJECT_NAME}} - Autonomous Agent Guide
33
46
 
34
- {{#if ISSUE_TRACKER}}
35
- > {{{ISSUE_TRACKER}}}
47
+ {{#if DESCRIPTION}}
48
+ > {{DESCRIPTION}}
36
49
  {{/if}}
37
50
 
38
51
  ---
@@ -50,13 +63,53 @@
50
63
 
51
64
  ---
52
65
 
66
+ ## ๐Ÿงฌ CODE FIELD - COGNITIVE ENVIRONMENT
67
+
68
+ **Apply to ALL code generation. Creates conditions where better code emerges naturally.**
69
+
70
+ ### Core Inhibitions
71
+
72
+ ```
73
+ Do not write code before stating assumptions.
74
+ Do not claim correctness you haven't verified.
75
+ Do not handle only the happy path.
76
+ Under what conditions does this work?
77
+ ```
78
+
79
+ ### Before Writing Code
80
+
81
+ - What are you assuming about the input?
82
+ - What are you assuming about the environment?
83
+ - What would break this?
84
+ - What would a malicious caller do?
85
+
86
+ ### Do Not
87
+
88
+ - Write code before stating assumptions
89
+ - Claim correctness you haven't verified
90
+ - Handle the happy path and gesture at the rest
91
+ - Import complexity you don't need
92
+ - Solve problems you weren't asked to solve
93
+ - Produce code you wouldn't want to debug at 3am
94
+
95
+ ### Expected Output Format
96
+
97
+ **Before code**: Assumptions stated explicitly, scope bounded
98
+ **In code**: Smaller than expected, edge cases handled or explicitly rejected
99
+ **After code**: "What this handles" and "What this does NOT handle" sections
100
+
101
+ *Attribution: Based on [context-field research](https://github.com/NeoVertex1/context-field)*
102
+
103
+ ---
104
+
53
105
  ## โšก SESSION START PROTOCOL
54
106
 
55
107
  **EXECUTE IMMEDIATELY before any response:**
56
108
 
57
109
  ```bash
58
110
  uam task ready # Check existing work
59
- uam memory query "recent context" # Check memory for context
111
+ sqlite3 {{MEMORY_DB_PATH}} "SELECT * FROM memories ORDER BY id DESC LIMIT 10;"
112
+ sqlite3 {{MEMORY_DB_PATH}} "SELECT * FROM session_memories WHERE session_id='current' ORDER BY id DESC LIMIT 5;"
60
113
  uam agent status # Check other active agents
61
114
  ```
62
115
 
@@ -131,60 +184,81 @@ Task(subagent_type: "performance-optimizer", ...) # Runs concurrently
131
184
  โ”‚ EXECUTE FOR EVERY TASK โ”‚
132
185
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
133
186
  โ”‚ โ”‚
134
- โ”‚ 1. MEMORY โ”‚ uam memory query "<keywords>" โ”‚
135
- โ”‚ โ”‚ Check for relevant past context โ”‚
187
+ โ”‚ 1. MEMORY โ”‚ sqlite3 {{MEMORY_DB_PATH}} "...LIMIT 20" โ”‚
188
+ โ”‚ โ”‚ {{MEMORY_QUERY_CMD}} "<keywords>" โ”‚
189
+ โ”‚ โ”‚ Check session_memories for current context โ”‚
136
190
  โ”‚ โ”‚
137
- โ”‚ 2. AGENTS โ”‚ uam agent overlaps --resource "<files>" โ”‚
191
+ โ”‚ 2. AGENTS โ”‚ uam agent overlaps --resource "<files>" โ”‚
138
192
  โ”‚ โ”‚ If overlap: coordinate or wait โ”‚
139
193
  โ”‚ โ”‚
140
194
  โ”‚ 3. SKILLS โ”‚ Check {{SKILLS_PATH}} for applicable skill โ”‚
141
195
  โ”‚ โ”‚ Invoke BEFORE implementing โ”‚
142
196
  โ”‚ โ”‚
143
- โ”‚ 4. WORKTREE โ”‚ {{WORKTREE_CREATE_CMD}} <slug> โ”‚
144
- โ”‚ โ”‚ cd {{WORKTREE_DIR}}/NNN-<slug>/ โ”‚
145
- โ”‚ โ”‚ NEVER commit to {{DEFAULT_BRANCH}} โ”‚
197
+ โ”‚ 4. WORKTREE โ”‚ {{WORKTREE_CREATE_CMD}} <slug> โ”‚
198
+ โ”‚ โ”‚ cd {{WORKTREE_DIR}}/NNN-<slug>/ โ”‚
199
+ โ”‚ โ”‚ NEVER commit to {{DEFAULT_BRANCH}} โ”‚
146
200
  โ”‚ โ”‚
147
- โ”‚ 5. WORK โ”‚ Implement โ†’ Test โ†’ {{WORKTREE_PR_CMD}} โ”‚
201
+ โ”‚ 5. WORK โ”‚ Implement โ†’ Test โ†’ {{WORKTREE_PR_CMD}} โ”‚
148
202
  โ”‚ โ”‚
149
- โ”‚ 6. MEMORY โ”‚ Store important learnings for future sessions โ”‚
150
- โ”‚ โ”‚ uam memory store "lesson" --importance 7+ โ”‚
203
+ โ”‚ 6. MEMORY โ”‚ Update short-term after actions โ”‚
204
+ โ”‚ โ”‚ Update session_memories for decisions โ”‚
205
+ โ”‚ โ”‚ Store lessons in long-term (importance 7+) โ”‚
151
206
  โ”‚ โ”‚
152
- โ”‚ 7. VERIFY โ”‚ โ˜ Memory โ˜ Worktree โ˜ PR โ˜ Skills โ˜ Agents โ”‚
207
+ โ”‚ 7. VERIFY โ”‚ โ˜ Memory โ˜ Worktree โ˜ PR โ˜ Skills โ˜ Agents โ”‚
153
208
  โ”‚ โ”‚
154
209
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
155
210
  ```
156
211
 
157
212
  ---
158
213
 
159
- ## ๐Ÿง  MEMORY SYSTEM
160
-
161
- **Memory is managed automatically.** Query for context, store important learnings.
214
+ ## ๐Ÿง  FOUR-LAYER MEMORY SYSTEM
162
215
 
163
216
  ```
164
217
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
165
- โ”‚ L1: WORKING โ”‚ Recent actions โ”‚ {{SHORT_TERM_LIMIT}} max โ”‚ Auto-managed โ”‚
166
- โ”‚ L2: SESSION โ”‚ Current session โ”‚ Per session โ”‚ Auto-managed โ”‚
167
- โ”‚ L3: SEMANTIC โ”‚ Long-term learnings โ”‚ {{LONG_TERM_BACKEND}} โ”‚ Store lessons โ”‚
168
- โ”‚ L4: KNOWLEDGE โ”‚ Entity relationships โ”‚ SQLite โ”‚ Auto-managed โ”‚
218
+ โ”‚ L1: WORKING โ”‚ SQLite memories โ”‚ {{SHORT_TERM_LIMIT}} max โ”‚ <1ms โ”‚
219
+ โ”‚ L2: SESSION โ”‚ SQLite session_mem โ”‚ Current session โ”‚ <5ms โ”‚
220
+ โ”‚ L3: SEMANTIC โ”‚ {{LONG_TERM_BACKEND}}โ”‚ Vector search โ”‚ ~50ms โ”‚
221
+ โ”‚ L4: KNOWLEDGE โ”‚ SQLite entities โ”‚ Graph relationships โ”‚ <20ms โ”‚
169
222
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
170
223
  ```
171
224
 
172
- ### When to Store Memories
225
+ ### Layer Selection
226
+
227
+ | Question | YES โ†’ Layer |
228
+ |----------|-------------|
229
+ | Just did this (last few minutes)? | L1: Working |
230
+ | Session-specific decision/context? | L2: Session |
231
+ | Reusable learning for future? | L3: Semantic |
232
+ | Entity relationships? | L4: Knowledge Graph |
233
+
234
+ ### Memory Commands
235
+
236
+ ```bash
237
+ # L1: Working Memory
238
+ sqlite3 {{MEMORY_DB_PATH}} "INSERT INTO memories (timestamp,type,content) VALUES (datetime('now'),'action','...');"
239
+
240
+ # L2: Session Memory
241
+ sqlite3 {{MEMORY_DB_PATH}} "INSERT INTO session_memories (session_id,timestamp,type,content,importance) VALUES ('current',datetime('now'),'decision','...',7);"
242
+
243
+ # L3: Semantic Memory
244
+ {{MEMORY_STORE_CMD}} lesson "..." --tags t1,t2 --importance 8
245
+
246
+ # L4: Knowledge Graph
247
+ sqlite3 {{MEMORY_DB_PATH}} "INSERT INTO entities (type,name,first_seen,last_seen,mention_count) VALUES ('file','x.ts',datetime('now'),datetime('now'),1);"
248
+ sqlite3 {{MEMORY_DB_PATH}} "INSERT INTO relationships (source_id,target_id,relation,timestamp) VALUES (1,2,'depends_on',datetime('now'));"
249
+ ```
250
+
251
+ ### Consolidation Rules
173
252
 
174
- | Situation | Action |
175
- |-----------|--------|
176
- | Learned something reusable | `uam memory store "lesson" --importance 8` |
177
- | Fixed a tricky bug | `uam memory store "bug fix" --tags bug-fix --importance 7` |
178
- | Discovered a gotcha | `uam memory store "gotcha" --tags gotcha --importance 9` |
179
- | Completed a task | Memory auto-updates |
253
+ - **Trigger**: Every 10 working memory entries
254
+ - **Action**: Summarize โ†’ session_memories, Extract lessons โ†’ semantic memory
255
+ - **Dedup**: Skip if content_hash exists OR similarity > 0.92
180
256
 
181
- ### When to Query Memories
257
+ ### Decay Formula
182
258
 
183
- | Situation | Action |
184
- |-----------|--------|
185
- | Starting new work | `uam memory query "relevant keywords"` |
186
- | Debugging | `uam memory query "similar error"` |
187
- | Understanding patterns | `uam memory query "how we did X"` |
259
+ ```
260
+ effective_importance = importance ร— (0.95 ^ days_since_access)
261
+ ```
188
262
 
189
263
  ---
190
264
 
@@ -265,32 +339,20 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
265
339
 
266
340
  {{{ARCHITECTURE_OVERVIEW}}}
267
341
 
268
- ---
269
342
  {{/if}}
270
-
271
343
  {{#if CORE_COMPONENTS}}
272
344
  ## ๐Ÿ”ง Components
273
345
 
274
346
  {{{CORE_COMPONENTS}}}
275
347
 
276
- ---
277
- {{/if}}
278
-
279
- {{#if DATABASE_ARCHITECTURE}}
280
- ## ๐Ÿ—„๏ธ Database
281
-
282
- {{{DATABASE_ARCHITECTURE}}}
283
-
284
- ---
285
348
  {{/if}}
286
-
287
349
  {{#if AUTH_FLOW}}
288
350
  ## ๐Ÿ” Authentication
289
351
 
290
352
  {{{AUTH_FLOW}}}
291
353
 
292
- ---
293
354
  {{/if}}
355
+ ---
294
356
 
295
357
  ## ๐Ÿ“‹ Quick Reference
296
358
 
@@ -299,33 +361,27 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
299
361
  ```bash
300
362
  {{{CLUSTER_CONTEXTS}}}
301
363
  ```
364
+
302
365
  {{/if}}
366
+ {{#if PROJECT_URLS}}
367
+ ### URLs
368
+ {{{PROJECT_URLS}}}
303
369
 
370
+ {{/if}}
304
371
  {{#if KEY_WORKFLOWS}}
305
372
  ### Workflows
306
373
  ```
307
374
  {{{KEY_WORKFLOWS}}}
308
375
  ```
309
- {{/if}}
310
376
 
377
+ {{/if}}
378
+ {{#if ESSENTIAL_COMMANDS}}
311
379
  ### Commands
312
380
  ```bash
313
- {{#if TEST_COMMAND}}
314
- # Tests
315
- {{TEST_COMMAND}}
316
- {{/if}}
317
-
318
- {{#if BUILD_COMMAND}}
319
- # Build
320
- {{BUILD_COMMAND}}
321
- {{/if}}
322
-
323
- {{#if LINT_COMMAND}}
324
- # Linting
325
- {{LINT_COMMAND}}
326
- {{/if}}
381
+ {{{ESSENTIAL_COMMANDS}}}
327
382
  ```
328
383
 
384
+ {{/if}}
329
385
  ---
330
386
 
331
387
  {{#if LANGUAGE_DROIDS}}
@@ -333,22 +389,24 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
333
389
  | Droid | Purpose |
334
390
  |-------|---------|
335
391
  {{{LANGUAGE_DROIDS}}}
336
- {{/if}}
337
392
 
338
- {{#if DISCOVERED_SKILLS}}
339
- ### Skills
340
- | Skill | Purpose | When to Use |
341
- |-------|---------|-------------|
342
- {{{DISCOVERED_SKILLS}}}
343
393
  {{/if}}
394
+ {{#if DISCOVERED_SKILLS}}
395
+ ### Commands
396
+ | Command | Purpose |
397
+ |---------|---------|
398
+ | `/worktree` | Manage worktrees (create, list, pr, cleanup) |
399
+ | `/code-review` | Full parallel review pipeline |
400
+ | `/pr-ready` | Validate branch, create PR |
344
401
 
402
+ {{/if}}
345
403
  {{#if MCP_PLUGINS}}
346
404
  ### MCP Plugins
347
405
  | Plugin | Purpose |
348
406
  |--------|---------|
349
407
  {{{MCP_PLUGINS}}}
350
- {{/if}}
351
408
 
409
+ {{/if}}
352
410
  ---
353
411
 
354
412
  {{#if HAS_INFRA}}
@@ -356,38 +414,35 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
356
414
 
357
415
  {{{INFRA_WORKFLOW}}}
358
416
 
359
- ---
360
417
  {{/if}}
361
-
362
418
  ## ๐Ÿงช Testing Requirements
363
-
364
419
  1. Create worktree
365
420
  2. Update/create tests
366
421
  3. Run `{{TEST_COMMAND}}`
367
- {{#if LINT_COMMAND}}
368
- 4. Run `{{LINT_COMMAND}}`
369
- {{/if}}
422
+ 4. Run linting
370
423
  5. Create PR
371
424
 
372
425
  ---
373
426
 
374
427
  {{#if TROUBLESHOOTING}}
375
428
  ## ๐Ÿ”ง Troubleshooting
376
-
377
429
  {{{TROUBLESHOOTING}}}
378
430
 
379
- ---
380
431
  {{/if}}
381
-
382
- {{#if KEY_CONFIG_FILES}}
383
432
  ## โš™๏ธ Config Files
384
-
385
433
  | File | Purpose |
386
434
  |------|---------|
435
+ {{#if KEY_CONFIG_FILES}}
387
436
  {{{KEY_CONFIG_FILES}}}
437
+ {{else}}
438
+ | `README.md` | Project documentation |
439
+ | `.uam.json` | UAM agent memory configuration |
440
+ | `package.json` | Node.js project configuration |
441
+ | `tsconfig.json` | TypeScript configuration |
442
+ | `.gitignore` | Git ignore patterns |
443
+ {{/if}}
388
444
 
389
445
  ---
390
- {{/if}}
391
446
 
392
447
  ## โœ… Completion Checklist
393
448
 
@@ -395,11 +450,11 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
395
450
  โ˜ Tests pass
396
451
  โ˜ Lint/typecheck pass
397
452
  โ˜ Worktree used (not {{DEFAULT_BRANCH}})
398
- โ˜ Memory updated (if learned something)
453
+ โ˜ Memory updated
399
454
  โ˜ PR created
400
455
  โ˜ Parallel reviews passed
401
456
  {{#if HAS_INFRA}}
402
- โ˜ Infrastructure plan verified
457
+ โ˜ Terraform plan verified
403
458
  {{/if}}
404
459
  โ˜ No secrets in code
405
460
  ```
@@ -439,7 +494,7 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
439
494
  โ”‚ โ””โ”€ Repeat until 100% working โ”‚
440
495
  โ”‚ โ”‚
441
496
  โ”‚ 5. COMPLETE โ”‚
442
- โ”‚ โ”œโ”€ Store learnings: uam memory store "what I learned" โ”‚
497
+ โ”‚ โ”œโ”€ Update memory with learnings โ”‚
443
498
  โ”‚ โ”œโ”€ Close related tasks/issues โ”‚
444
499
  โ”‚ โ””โ”€ Announce completion โ”‚
445
500
  โ”‚ โ”‚
@@ -476,22 +531,31 @@ gh run view <run-id>
476
531
  {{#if RECENT_ACTIVITY}}
477
532
  ### Recent Activity
478
533
  {{{RECENT_ACTIVITY}}}
479
- {{/if}}
480
534
 
535
+ {{/if}}
481
536
  {{#if LEARNED_LESSONS}}
482
537
  ### Lessons
483
538
  {{{LEARNED_LESSONS}}}
484
- {{/if}}
485
539
 
540
+ {{/if}}
486
541
  {{#if KNOWN_GOTCHAS}}
487
542
  ### Gotchas
488
543
  {{{KNOWN_GOTCHAS}}}
489
- {{/if}}
490
544
 
545
+ {{/if}}
491
546
  {{#if HOT_SPOTS}}
492
547
  ### Hot Spots
493
548
  {{{HOT_SPOTS}}}
549
+
494
550
  {{/if}}
495
551
  {{/if}}
496
-
497
552
  </coding_guidelines>
553
+
554
+ ---
555
+
556
+ ## Repository Structure
557
+
558
+ ```
559
+ {{PROJECT_NAME}}/
560
+ {{{REPOSITORY_STRUCTURE}}}
561
+ ```