universal-agent-memory 0.7.4 โ 1.0.1
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 +121 -20
- package/dist/bin/cli.js +3 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/generate.d.ts +1 -0
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +27 -14
- package/dist/cli/generate.js.map +1 -1
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +2 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/update.d.ts +1 -0
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +19 -1
- package/dist/cli/update.js.map +1 -1
- package/dist/generators/claude-md.js +2 -1
- package/dist/generators/claude-md.js.map +1 -1
- package/dist/memory/adaptive-context.d.ts +100 -0
- package/dist/memory/adaptive-context.d.ts.map +1 -0
- package/dist/memory/adaptive-context.js +456 -0
- package/dist/memory/adaptive-context.js.map +1 -0
- package/dist/types/config.d.ts +15 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -0
- package/dist/types/config.js.map +1 -1
- package/package.json +1 -1
- package/templates/CLAUDE.template.md +269 -8
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
CLAUDE.md Universal Template -
|
|
2
|
+
CLAUDE.md Universal Template - v10.1
|
|
3
3
|
|
|
4
4
|
CHANGES IN THIS VERSION:
|
|
5
|
+
- Pipeline-only infrastructure policy (--pipeline-only flag)
|
|
6
|
+
- Prohibited commands for kubectl/terraform direct usage
|
|
7
|
+
- Policy documents reference in Config Files section
|
|
8
|
+
- Enhanced completion checklist for infrastructure
|
|
9
|
+
|
|
10
|
+
PREVIOUS (v10.0):
|
|
11
|
+
- Added 8 Universal Agent Patterns (discovered via Terminal-Bench 2.0)
|
|
12
|
+
- Pre-execution state protection (Pattern 3)
|
|
13
|
+
- Recipe following guidance (Pattern 2)
|
|
14
|
+
- CLI over libraries recommendation (Pattern 8)
|
|
15
|
+
- Critical reminders at END (exploits recency bias - Pattern 6)
|
|
16
|
+
- Enhanced decision loop with classification step (Pattern 7)
|
|
17
|
+
- Environment isolation awareness (Pattern 1)
|
|
18
|
+
|
|
19
|
+
PREVIOUS (v9.0):
|
|
5
20
|
- Fully universal with Handlebars placeholders (no hardcoded project content)
|
|
6
21
|
- Context Field integration with Code Field prompt
|
|
7
22
|
- Inhibition-style directives ("Do not X" creates blockers)
|
|
@@ -91,6 +106,12 @@ Under what conditions does this work?
|
|
|
91
106
|
- Import complexity you don't need
|
|
92
107
|
- Solve problems you weren't asked to solve
|
|
93
108
|
- Produce code you wouldn't want to debug at 3am
|
|
109
|
+
{{#if HAS_PIPELINE_POLICY}}
|
|
110
|
+
- Run kubectl commands directly (use `ops-approved-operations.yml`)
|
|
111
|
+
- Run terraform locally (use `iac-terraform-cicd.yml`)
|
|
112
|
+
- Document manual infrastructure commands (link to pipelines instead)
|
|
113
|
+
- Create secrets outside of Sealed Secrets or pipelines
|
|
114
|
+
{{/if}}
|
|
94
115
|
|
|
95
116
|
### Expected Output Format
|
|
96
117
|
|
|
@@ -102,6 +123,140 @@ Under what conditions does this work?
|
|
|
102
123
|
|
|
103
124
|
---
|
|
104
125
|
|
|
126
|
+
{{#if HAS_INFRA}}
|
|
127
|
+
## ๐ซ PIPELINE-ONLY POLICY - ABSOLUTE RULE
|
|
128
|
+
|
|
129
|
+
**ALL infrastructure changes MUST go through CI/CD pipelines. NO EXCEPTIONS.**
|
|
130
|
+
|
|
131
|
+
### Core Inhibitions
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
Do not run kubectl commands directly against clusters.
|
|
135
|
+
Do not run terraform apply from local machines.
|
|
136
|
+
Do not make changes via cloud console that should be in IaC.
|
|
137
|
+
Do not document manual commands in runbooks - link to pipelines instead.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Approved Pipelines
|
|
141
|
+
|
|
142
|
+
| Task | Pipeline | Trigger |
|
|
143
|
+
|------|----------|---------|
|
|
144
|
+
| Kubernetes operations | `ops-approved-operations.yml` | Manual dispatch |
|
|
145
|
+
| Ephemeral environments | `ops-create-ephemeral.yml` | Manual dispatch |
|
|
146
|
+
| Terraform changes | `iac-terraform-cicd.yml` | PR to main |
|
|
147
|
+
| Ephemeral Terraform | `ops-ephemeral-terraform.yml` | Manual dispatch |
|
|
148
|
+
|
|
149
|
+
### One-Time Operations
|
|
150
|
+
|
|
151
|
+
For operations that need to run once (migrations, data fixes, cleanups):
|
|
152
|
+
|
|
153
|
+
1. Use `ops-create-ephemeral.yml` to create a pipeline
|
|
154
|
+
2. Define the operation in the pipeline configuration
|
|
155
|
+
3. Run via GitHub Actions workflow dispatch
|
|
156
|
+
4. Pipeline self-destructs after completion
|
|
157
|
+
|
|
158
|
+
### What This Means for Agents
|
|
159
|
+
|
|
160
|
+
- **NEVER**: Run `kubectl apply`, `kubectl delete`, `kubectl patch` directly
|
|
161
|
+
- **NEVER**: Run `terraform apply`, `terraform destroy` locally
|
|
162
|
+
- **NEVER**: Create Kubernetes secrets via `kubectl create secret`
|
|
163
|
+
- **ALWAYS**: Make infrastructure changes via PR โ pipeline
|
|
164
|
+
- **ALWAYS**: Use `ops-approved-operations.yml` for operational tasks
|
|
165
|
+
- **ALWAYS**: Reference pipeline workflows instead of manual commands
|
|
166
|
+
|
|
167
|
+
๐ See: `docs/adr/ADR-0006-pipeline-only-infrastructure-changes.md`
|
|
168
|
+
|
|
169
|
+
{{/if}}
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## ๐ฏ UNIVERSAL AGENT PATTERNS
|
|
173
|
+
|
|
174
|
+
**Eight patterns proven to improve LLM agent reliability. Apply to ALL task execution.**
|
|
175
|
+
|
|
176
|
+
### Pattern 1: Environment Isolation
|
|
177
|
+
Code installed during execution may NOT persist across phases (agent โ test โ deploy).
|
|
178
|
+
- Check what dependencies are pre-installed before using them
|
|
179
|
+
- Prefer pre-installed tools over installing new ones
|
|
180
|
+
- Design for minimal dependency footprint
|
|
181
|
+
|
|
182
|
+
### Pattern 2: Recipe Following
|
|
183
|
+
LLMs excel at explicit step-by-step instructions but struggle with ambiguous tasks.
|
|
184
|
+
- Convert complex tasks into numbered sequential commands
|
|
185
|
+
- Each step should be atomic and verifiable
|
|
186
|
+
- Provide exact commands, not descriptions
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
โ "Set up a web server with SSL"
|
|
190
|
+
โ
"1. Install nginx: apt-get install nginx
|
|
191
|
+
2. Generate key: openssl genrsa -out server.key 2048
|
|
192
|
+
3. Create cert: openssl req -new -x509 ..."
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Pattern 3: Pre-execution State Protection
|
|
196
|
+
LLMs do NOT reliably follow negative instructions ("do not delete X").
|
|
197
|
+
- Backup critical files BEFORE starting work
|
|
198
|
+
- Never rely on "do not" for critical constraints
|
|
199
|
+
- Protect state proactively, not reactively
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# BEFORE modifying configs
|
|
203
|
+
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
|
|
204
|
+
|
|
205
|
+
# BEFORE database operations
|
|
206
|
+
sqlite3 db.sqlite ".backup /tmp/db_backup.sqlite"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Pattern 4: Tool Specification
|
|
210
|
+
Agents succeed more when told WHICH tool to use, not just WHAT to accomplish.
|
|
211
|
+
- Specify exact tool and flags when possible
|
|
212
|
+
- Reduce search space of possible approaches
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
โ "Parse this JSON file"
|
|
216
|
+
โ
"Use jq to parse: jq '.key' file.json"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Pattern 5: Recognizing Impossible Tasks
|
|
220
|
+
Some tasks require pre-computed solutions (compressed algorithms, lookup tables, trained models).
|
|
221
|
+
- Identify tasks requiring: compression below limits, pre-trained weights, exhaustive search
|
|
222
|
+
- These cannot be solved by reasoning alone
|
|
223
|
+
- Detect early to avoid wasted computation
|
|
224
|
+
|
|
225
|
+
### Pattern 6: Hierarchical Prompting (Recency Bias)
|
|
226
|
+
LLMs weight information at the END of context more heavily.
|
|
227
|
+
- Structure: capabilities โ context โ CRITICAL instructions
|
|
228
|
+
- Put most important constraints at the END
|
|
229
|
+
- Repeat critical instructions if essential
|
|
230
|
+
|
|
231
|
+
### Pattern 7: Task Classification
|
|
232
|
+
Different task types require different strategies.
|
|
233
|
+
|
|
234
|
+
| Category | Strategy |
|
|
235
|
+
|----------|----------|
|
|
236
|
+
| State-sensitive | Pre-backup critical files |
|
|
237
|
+
| Recipe-following | Step-by-step commands |
|
|
238
|
+
| Tool-dependent | Specify exact tool + flags |
|
|
239
|
+
| Research/exploration | Parallel searches |
|
|
240
|
+
|
|
241
|
+
### Pattern 8: CLI over Libraries
|
|
242
|
+
When environment dependencies are uncertain, prefer subprocess + CLI over library imports.
|
|
243
|
+
- CLI tools more likely pre-installed
|
|
244
|
+
- Better backward compatibility
|
|
245
|
+
- Easier to verify: `which tool`
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
# Less portable
|
|
249
|
+
from cryptography import x509
|
|
250
|
+
cert = x509.load_pem_x509_certificate(data)
|
|
251
|
+
|
|
252
|
+
# More portable
|
|
253
|
+
import subprocess
|
|
254
|
+
result = subprocess.run(["openssl", "x509", "-in", "cert.pem", "-text"],
|
|
255
|
+
capture_output=True, text=True)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
105
260
|
## โก SESSION START PROTOCOL
|
|
106
261
|
|
|
107
262
|
**EXECUTE IMMEDIATELY before any response:**
|
|
@@ -254,27 +409,40 @@ Task(subagent_type: "performance-optimizer", prompt: "Find hotspots in src/cache
|
|
|
254
409
|
โ EXECUTE FOR EVERY TASK โ
|
|
255
410
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
256
411
|
โ โ
|
|
257
|
-
โ
|
|
412
|
+
โ 0. CLASSIFY โ What type? (Pattern 7) โ
|
|
413
|
+
โ โ State-sensitive โ backup first (Pattern 3) โ
|
|
414
|
+
โ โ Tool-dependent โ specify tool (Pattern 4) โ
|
|
415
|
+
โ โ Complex โ break into steps (Pattern 2) โ
|
|
416
|
+
โ โ
|
|
417
|
+
โ 1. PROTECT โ BACKUP critical files BEFORE any changes โ
|
|
418
|
+
โ โ cp config config.bak (Pattern 3) โ
|
|
419
|
+
โ โ Check environment: which tool (Pattern 1, 8) โ
|
|
420
|
+
โ โ
|
|
421
|
+
โ 2. MEMORY โ sqlite3 {{MEMORY_DB_PATH}} "...LIMIT 20" โ
|
|
258
422
|
โ โ {{MEMORY_QUERY_CMD}} "<keywords>" โ
|
|
259
423
|
โ โ Check session_memories for current context โ
|
|
260
424
|
โ โ
|
|
261
|
-
โ
|
|
425
|
+
โ 3. AGENTS โ uam agent overlaps --resource "<files>" โ
|
|
262
426
|
โ โ If overlap: coordinate or wait โ
|
|
263
427
|
โ โ
|
|
264
|
-
โ
|
|
428
|
+
โ 4. SKILLS โ Check {{SKILLS_PATH}} for applicable skill โ
|
|
265
429
|
โ โ Invoke BEFORE implementing โ
|
|
266
430
|
โ โ
|
|
267
|
-
โ
|
|
431
|
+
โ 5. WORKTREE โ {{WORKTREE_CREATE_CMD}} <slug> โ
|
|
268
432
|
โ โ cd {{WORKTREE_DIR}}/NNN-<slug>/ โ
|
|
269
433
|
โ โ NEVER commit directly to {{DEFAULT_BRANCH}} โ
|
|
270
434
|
โ โ
|
|
271
|
-
โ
|
|
435
|
+
โ 6. WORK โ Step-by-step execution (Pattern 2) โ
|
|
436
|
+
โ โ Verify each step before proceeding โ
|
|
437
|
+
โ โ Use CLI tools when possible (Pattern 8) โ
|
|
438
|
+
โ โ Implement โ Test โ {{WORKTREE_PR_CMD}} โ
|
|
272
439
|
โ โ
|
|
273
|
-
โ
|
|
440
|
+
โ 7. MEMORY โ Update short-term after actions โ
|
|
274
441
|
โ โ Update session_memories for decisions โ
|
|
275
442
|
โ โ Store lessons in long-term (importance 7+) โ
|
|
276
443
|
โ โ
|
|
277
|
-
โ
|
|
444
|
+
โ 8. VERIFY โ โ Backup made โ Memory โ Worktree โ PR โ
|
|
445
|
+
โ โ โ Skills โ Agents โ Steps verified โ
|
|
278
446
|
โ โ
|
|
279
447
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
280
448
|
```
|
|
@@ -482,7 +650,60 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
|
|
|
482
650
|
{{#if HAS_INFRA}}
|
|
483
651
|
## ๐ญ Infrastructure Workflow
|
|
484
652
|
|
|
653
|
+
{{#if HAS_PIPELINE_POLICY}}
|
|
654
|
+
**ALL infrastructure changes go through CI/CD pipelines. No exceptions.**
|
|
655
|
+
|
|
656
|
+
### Standard Infrastructure Changes
|
|
657
|
+
|
|
658
|
+
1. Create worktree: `{{WORKTREE_CREATE_CMD}} infra-<slug>`
|
|
659
|
+
2. Make Terraform/Kubernetes changes in worktree
|
|
660
|
+
3. Commit and push to feature branch
|
|
661
|
+
4. Create PR targeting `{{DEFAULT_BRANCH}}`
|
|
662
|
+
5. Pipeline `iac-terraform-cicd.yml` auto-runs terraform plan
|
|
663
|
+
6. After merge, pipeline auto-applies changes
|
|
664
|
+
|
|
665
|
+
### Operational Tasks
|
|
666
|
+
|
|
667
|
+
For approved operational tasks (restarts, scaling, etc.):
|
|
668
|
+
|
|
669
|
+
```bash
|
|
670
|
+
gh workflow run ops-approved-operations.yml \
|
|
671
|
+
-f operation=restart \
|
|
672
|
+
-f target=deployment/my-service \
|
|
673
|
+
-f namespace=production
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
### One-Time Operations
|
|
677
|
+
|
|
678
|
+
For migrations, data fixes, or cleanup tasks:
|
|
679
|
+
|
|
680
|
+
```bash
|
|
681
|
+
gh workflow run ops-create-ephemeral.yml \
|
|
682
|
+
-f operation_name=migrate-user-data \
|
|
683
|
+
-f commands="kubectl exec -it pod/db-0 -- psql -c 'UPDATE...'"
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
### PROHIBITED
|
|
687
|
+
|
|
688
|
+
The following commands are **NEVER** allowed locally:
|
|
689
|
+
|
|
690
|
+
```bash
|
|
691
|
+
# โ PROHIBITED - use iac-terraform-cicd.yml instead
|
|
692
|
+
terraform apply
|
|
693
|
+
terraform destroy
|
|
694
|
+
|
|
695
|
+
# โ PROHIBITED - use ops-approved-operations.yml instead
|
|
696
|
+
kubectl apply -f ...
|
|
697
|
+
kubectl delete ...
|
|
698
|
+
kubectl patch ...
|
|
699
|
+
|
|
700
|
+
# โ PROHIBITED - use Sealed Secrets via pipeline
|
|
701
|
+
kubectl create secret ...
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
{{else}}
|
|
485
705
|
{{{INFRA_WORKFLOW}}}
|
|
706
|
+
{{/if}}
|
|
486
707
|
|
|
487
708
|
{{/if}}
|
|
488
709
|
## ๐งช Testing Requirements
|
|
@@ -512,6 +733,13 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
|
|
|
512
733
|
| `.gitignore` | Git ignore patterns |
|
|
513
734
|
{{/if}}
|
|
514
735
|
|
|
736
|
+
{{#if HAS_PIPELINE_POLICY}}
|
|
737
|
+
### Policy Documents
|
|
738
|
+
| Document | Purpose |
|
|
739
|
+
|----------|---------|
|
|
740
|
+
| `docs/adr/ADR-0006-pipeline-only-infrastructure-changes.md` | Pipeline-only policy |
|
|
741
|
+
|
|
742
|
+
{{/if}}
|
|
515
743
|
---
|
|
516
744
|
|
|
517
745
|
## โ
Completion Checklist
|
|
@@ -526,6 +754,11 @@ Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
|
|
|
526
754
|
{{#if HAS_INFRA}}
|
|
527
755
|
โ Terraform plan verified
|
|
528
756
|
{{/if}}
|
|
757
|
+
{{#if HAS_PIPELINE_POLICY}}
|
|
758
|
+
โ No manual kubectl commands (use pipelines)
|
|
759
|
+
โ No local terraform apply (use pipelines)
|
|
760
|
+
โ Infrastructure changes via iac-terraform-cicd.yml
|
|
761
|
+
{{/if}}
|
|
529
762
|
โ No secrets in code
|
|
530
763
|
```
|
|
531
764
|
|
|
@@ -629,3 +862,31 @@ gh run view <run-id>
|
|
|
629
862
|
{{PROJECT_NAME}}/
|
|
630
863
|
{{{REPOSITORY_STRUCTURE}}}
|
|
631
864
|
```
|
|
865
|
+
|
|
866
|
+
---
|
|
867
|
+
|
|
868
|
+
## โ ๏ธ CRITICAL REMINDERS (READ LAST)
|
|
869
|
+
|
|
870
|
+
**These reminders exploit recency bias - place at END for maximum compliance.**
|
|
871
|
+
|
|
872
|
+
1. **BACKUP FIRST**: Before modifying ANY config, database, or critical file:
|
|
873
|
+
```bash
|
|
874
|
+
cp <file> <file>.bak
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
2. **CHECK ENVIRONMENT**: Before using a library, verify it exists:
|
|
878
|
+
```bash
|
|
879
|
+
which <tool> || python3 -c "import <lib>" 2>/dev/null || echo "NOT AVAILABLE"
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
3. **USE CLI OVER LIBRARIES**: When in doubt, use subprocess + CLI tools.
|
|
883
|
+
|
|
884
|
+
4. **STEP-BY-STEP**: Break complex tasks into numbered commands. Execute one at a time.
|
|
885
|
+
|
|
886
|
+
5. **VERIFY EACH STEP**: Check output before proceeding to next step.
|
|
887
|
+
|
|
888
|
+
6. **STATE-SENSITIVE OPERATIONS**: If task involves recovery, forensics, or state inspection - backup EVERYTHING first.
|
|
889
|
+
|
|
890
|
+
7. **IMPOSSIBLE DETECTION**: If task requires compression magic, ML inference, or exhaustive search - flag as potentially impossible.
|
|
891
|
+
|
|
892
|
+
8. **TEST IN ISOLATION**: Dependencies installed during work may not persist. Use pre-installed tools.
|