@letta-ai/letta-code 0.16.12 → 0.16.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.16.12",
3
+ "version": "0.16.13",
4
4
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@letta-ai/letta-client": "^1.7.8",
36
+ "@letta-ai/letta-client": "^1.7.9",
37
37
  "glob": "^13.0.0",
38
38
  "ink-link": "^5.0.0",
39
39
  "open": "^10.2.0",
@@ -70,7 +70,7 @@
70
70
  "test:update-chain:manual": "bun run src/tests/update-chain-smoke.ts --mode manual",
71
71
  "test:update-chain:startup": "bun run src/tests/update-chain-smoke.ts --mode startup",
72
72
  "prepublishOnly": "bun run build",
73
- "postinstall": "node scripts/postinstall-patches.js"
73
+ "postinstall": "node scripts/postinstall-patches.js || echo letta: vendor patches skipped"
74
74
  },
75
75
  "lint-staged": {
76
76
  "*.{ts,tsx,js,jsx,json}": [
@@ -1,261 +0,0 @@
1
- ---
2
- name: defragmenting-memory
3
- description: Decomposes and reorganizes agent memory blocks into focused, single-purpose components. Use when memory has large multi-topic blocks, redundancy, or poor organization.
4
- ---
5
-
6
- # Memory Defragmentation Skill
7
-
8
- > **Requires Memory Filesystem (memfs)**
9
- >
10
- > This skill works by directly editing memory files on disk. It requires the memory filesystem feature to be enabled.
11
- >
12
- > **To check:** Look for a `memory_filesystem` block in your system prompt. If it shows a tree structure starting with `/memory/` including a `system/` directory, memfs is enabled.
13
- >
14
- > **To enable:** Ask the user to run `/memfs enable`, then reload the CLI.
15
-
16
- This skill helps you maintain clean, well-organized memory blocks by spawning a subagent to decompose and reorganize memory files in-place.
17
-
18
- The focus is on **decomposition**—splitting large, multi-purpose blocks into focused, single-purpose components—rather than consolidation.
19
-
20
- Memory files live at `~/.letta/agents/$LETTA_AGENT_ID/memory/` and are synced to API blocks automatically by **memfs sync** on CLI startup.
21
-
22
- ## When to Use
23
-
24
- - Memory blocks have redundant information
25
- - Memory lacks structure (walls of text)
26
- - Memory contains contradictions
27
- - Memory has grown stale or outdated
28
- - After major project milestones
29
- - Every 50-100 conversation turns
30
-
31
- ## Workflow
32
-
33
- ### Step 1: Commit Current State (Safety Net)
34
-
35
- The memory directory is a git repo. Commit the current state so you can rollback if needed:
36
-
37
- ```bash
38
- cd ~/.letta/agents/$LETTA_AGENT_ID/memory
39
- git add -A
40
- git commit -m "chore: pre-defrag snapshot" || echo "No changes to commit"
41
- ```
42
-
43
- ⚠️ **CRITICAL**: You MUST commit before proceeding. This is your rollback point.
44
-
45
- ### Step 2: Spawn Subagent to Edit Memory Files
46
-
47
- The memory subagent works directly on the memfs `system/` directory. After it finishes, memfs sync will propagate changes to the API on next CLI startup.
48
-
49
- ```typescript
50
- Task({
51
- subagent_type: "memory",
52
- run_in_background: true,
53
- description: "Decompose and reorganize memory files",
54
- prompt: `You are decomposing and reorganizing memory files in ~/.letta/agents/${LETTA_AGENT_ID}/memory/system/ to improve clarity and focus.
55
-
56
- These files ARE the agent's memory — they sync directly to API memory blocks via memfs. Changes you make here will be picked up automatically.
57
-
58
- ## Directory Structure
59
-
60
- ~/.letta/agents/<agent-id>/memory/
61
- ├── system/ ← Attached blocks (always loaded in system prompt) — EDIT THESE
62
- ├── notes.md ← Detached blocks at root level (on-demand) — can create here
63
- ├── archive/ ← Detached blocks can be nested too
64
- └── .sync-state.json ← DO NOT EDIT (internal sync tracking)
65
-
66
- ## Files to Skip (DO NOT edit)
67
- - memory_filesystem.md (auto-generated tree view)
68
- - .sync-state.json (internal)
69
-
70
- ## What to Edit
71
- - persona.md → Consider splitting into: persona/identity.md, persona/values.md, persona/approach.md
72
- - project.md → Consider splitting into: project/overview.md, project/architecture.md, project/conventions.md, etc.
73
- - human.md → Consider splitting into: human/identity.md, human/preferences.md, etc.
74
- - Any other non-system blocks present
75
-
76
- ## How Memfs File ↔ Block Mapping Works
77
- - File path relative to memory root becomes the block label (system/ prefix for attached, root level for detached)
78
- - Example: system/project/tooling/bun.md → block label "project/tooling/bun"
79
- - New files you create will become new memory blocks on next sync
80
- - Files you delete will cause the corresponding blocks to be deleted on next sync
81
- - YAML frontmatter is supported for metadata (label, description, limit, read_only)
82
-
83
- ## Evaluation Criteria
84
-
85
- 1. **DECOMPOSITION** - Split large, multi-purpose blocks into focused, single-purpose components
86
- - Example: A "persona" block mixing identity, values, AND approach should become persona/identity.md, persona/values.md, persona/approach.md
87
- - Example: A "project" block with overview, architecture, conventions, and gotchas should split into project/overview.md, project/architecture.md, project/conventions.md, project/gotchas.md
88
- - Goal: Each block should have ONE clear purpose described by its filename
89
- - Use hierarchical / naming (e.g., project/tooling/bun.md, not project-tooling-bun.md)
90
-
91
- 2. **STRUCTURE** - Organize content with clear markdown formatting
92
- - Use headers (##, ###) for subsections
93
- - Use bullet points for lists
94
- - Make content scannable at a glance
95
-
96
- 3. **CONCISENESS** - Remove redundancy and unnecessary detail
97
- - Eliminate duplicate information across blocks
98
- - Remove speculation ("probably", "maybe", "I think")
99
- - Keep only what adds unique value
100
-
101
- 4. **CLARITY** - Resolve contradictions and improve readability
102
- - If blocks contradict, clarify or choose the better guidance
103
- - Use plain language, avoid jargon
104
- - Ensure each statement is concrete and actionable
105
-
106
- 5. **ORGANIZATION** - Group related information logically
107
- - Within each block, organize content from general to specific
108
- - Order sections by importance
109
-
110
- ## Workflow
111
-
112
- 1. **Analyze** - Read each file and identify its purpose(s)
113
- - If a block serves 2+ distinct purposes, it needs decomposition
114
- - Flag blocks where subtopics could be their own focused blocks
115
-
116
- 2. **Decompose** - Split multi-purpose blocks into specialized files
117
- - Create new files using hierarchical paths (e.g., project/tooling/bun.md)
118
- - Ensure each new block has ONE primary purpose
119
-
120
- 3. **Clean Up** - For remaining blocks (or new focused blocks):
121
- - Add markdown structure with headers and bullets
122
- - Remove redundancy
123
- - Resolve contradictions
124
- - Improve clarity
125
-
126
- 4. **Delete** - Remove files only when appropriate
127
- - After moving all content to new decomposed files
128
- - Never delete a focused, single-purpose block
129
- - Only delete if a block contains junk/irrelevant data with no value
130
-
131
- ## Success Indicators
132
- - No block tries to cover 2+ distinct topics
133
- - Each block title clearly describes its single purpose
134
- - Content within each block is focused and relevant to its title
135
- - Well-organized with markdown structure
136
- - Clear reduction in confusion/overlap across blocks
137
-
138
- Provide a detailed report including:
139
- - Files created (new decomposed blocks)
140
- - Files modified (what changed)
141
- - Files deleted (if any, explain why)
142
- - Before/after character counts
143
- - Rationale for how decomposition improves the memory structure`
144
- })
145
- ```
146
-
147
- The subagent will:
148
- - Read files from `~/.letta/agents/<agent-id>/memory/system/` (and root level for detached)
149
- - Edit them to reorganize and decompose large blocks
150
- - Create new hierarchically-named files (e.g., `project/overview.md`)
151
- - Add clear structure with markdown formatting
152
- - Delete source files after decomposing their content into focused children
153
- - Provide a detailed report of changes
154
-
155
- After the subagent finishes, **memfs sync will automatically propagate changes** to API blocks on the next CLI startup. No manual restore step is needed.
156
-
157
- ### Step 3: Commit Changes
158
-
159
- After the subagent finishes, commit the changes:
160
-
161
- ```bash
162
- cd ~/.letta/agents/$LETTA_AGENT_ID/memory
163
- git add -A
164
- git commit -m "chore: defragment memory blocks"
165
- git push
166
- ```
167
-
168
- ## Example Complete Flow
169
-
170
- ```typescript
171
- // Step 1: Commit current state (MANDATORY)
172
- Bash({
173
- command: "cd ~/.letta/agents/$LETTA_AGENT_ID/memory && git add -A && git commit -m 'chore: pre-defrag snapshot' || echo 'No changes'",
174
- description: "Commit current memory state as rollback point"
175
- })
176
-
177
- // Step 2: Spawn subagent to decompose and reorganize (runs async in background)
178
- Task({
179
- subagent_type: "memory",
180
- run_in_background: true,
181
- description: "Decompose and reorganize memory files",
182
- prompt: "Decompose and reorganize memory files in ~/.letta/agents/$LETTA_AGENT_ID/memory/system/. These files sync directly to API blocks via memfs. Be aggressive about splitting large multi-section blocks into many smaller, single-purpose blocks using hierarchical / naming. Skip memory_filesystem.md and .sync-state.json. Structure with markdown headers and bullets. Remove redundancy and speculation. Resolve contradictions. Organize logically. Each block should have ONE clear purpose. Report files created, modified, deleted, before/after character counts, and rationale for changes."
183
- })
184
-
185
- // Step 3: After subagent completes, commit and push
186
- // Check progress with /task <task_id>, restart CLI to sync when done
187
- ```
188
-
189
- ## Rollback
190
-
191
- If something goes wrong, use git to revert:
192
-
193
- ```bash
194
- cd ~/.letta/agents/$LETTA_AGENT_ID/memory
195
-
196
- # Option 1: Reset to last commit (discard all uncommitted changes)
197
- git reset --hard HEAD~1
198
-
199
- # Option 2: View history and reset to specific commit
200
- git log --oneline -5
201
- git reset --hard <commit-hash>
202
-
203
- # Push the rollback
204
- git push --force
205
- ```
206
-
207
- On next CLI startup, memfs sync will detect the changes and update API blocks accordingly.
208
-
209
- ## What the Subagent Does
210
-
211
- The subagent focuses on decomposing and cleaning up files. It has full tool access (including Bash) and:
212
- - Discovers `.md` files in `~/.letta/agents/<agent-id>/memory/system/` (via Glob or Bash)
213
- - Reads and examines each file's content
214
- - Identifies multi-purpose blocks that serve 2+ distinct purposes
215
- - Splits large blocks into focused, single-purpose components with hierarchical naming
216
- - Modifies/creates .md files for decomposed blocks
217
- - Improves structure with headers and bullet points
218
- - Removes redundancy and speculation across blocks
219
- - Resolves contradictions with clear, concrete guidance
220
- - Organizes content logically (general to specific, by importance)
221
- - Provides detailed before/after reports including decomposition rationale
222
- - Does NOT run any git commands (parent agent handles that)
223
-
224
- The focus is on decomposition—breaking apart large monolithic blocks into focused, specialized components rather than consolidating them together.
225
-
226
- ## Tips
227
-
228
- **What to clean up:**
229
- - Duplicate information (consolidate into one well-organized section)
230
- - Walls of text without structure (add headers and bullets)
231
- - Contradictions (resolve by clarifying or choosing the better guidance)
232
- - Speculation ("probably", "maybe" - make it concrete or remove)
233
- - Transient details that won't matter in a week
234
-
235
- **Decomposition Strategy:**
236
- - Split blocks that serve 2+ distinct purposes into focused components
237
- - Use hierarchical `/` naming: `project/tooling/bun.md`, not `project-bun.md`
238
- - Create parent index files that reference children
239
- - Example: A "persona" mixing identity + values + approach → split into `persona/identity.md`, `persona/values.md`, `persona/approach.md`
240
- - Example: A "project" with overview + architecture + conventions → split into `project/overview.md`, `project/architecture.md`, `project/conventions.md`
241
- - Add clear headers and bullet points for scannability
242
- - Group similar information together within focused blocks
243
-
244
- **When to DELETE a file:**
245
- - Only delete if file contains junk/irrelevant data with no project value
246
- - Delete source files after fully decomposing content into child files
247
- - Don't delete unique information just to reduce file count
248
-
249
- **What to preserve:**
250
- - User preferences (sacred - never delete)
251
- - Project conventions discovered through experience
252
- - Important context for future sessions
253
- - Learnings from past mistakes
254
- - Any information that has unique value
255
-
256
- **Good memory structure:**
257
- - Use markdown headers (##, ###)
258
- - Organize with bullet points
259
- - Keep related information together
260
- - Make it scannable at a glance
261
- - Use `/` hierarchy for discoverability