@letta-ai/letta-code 0.5.1 → 0.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 +19 -339
- package/letta.js +4602 -1429
- package/package.json +2 -2
- package/vendor/ink-text-input/build/index.js +65 -18
package/README.md
CHANGED
|
@@ -1,364 +1,44 @@
|
|
|
1
|
-
# Letta Code
|
|
1
|
+
# Letta Code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@letta-ai/letta-code) [](https://discord.gg/letta)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Letta Code is a memory-first coding harness, built on top of the Letta API. Instead of working in independent sessions, you work with a persisted agent that learns over time and is portable across models (Claude Sonnet/Opus, GPT-5, Gemini 3 Pro, GLM-4.6, and more).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## What is Letta Code?
|
|
10
|
-
|
|
11
|
-
Letta Code is a command-line harness around the stateful [Letta API](https://docs.letta.com/api-reference/overview). You can use Letta Code to create and connect with any Letta agent (even non-coding agents!) - Letta Code simply gives your agents the ability to interact with your local dev environment, directly in your terminal.
|
|
12
|
-
|
|
13
|
-
Letta Code is model agnostic, and supports Sonnet 4.5, GPT-5, Gemini 2.5, GLM-4.6, and more.
|
|
7
|
+
**Read more about how to use Letta Code on the [official docs page](https://docs.letta.com/letta-code).**
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
> Letta Code is a **research preview** in active development, and may have bugs or unexpected issues. To learn more about the roadmap and chat with the dev team, visit our [Discord](https://discord.gg/letta). Contributions welcome, join the fun.
|
|
9
|
+

|
|
17
10
|
|
|
18
|
-
##
|
|
11
|
+
## Get started
|
|
19
12
|
|
|
20
|
-
|
|
13
|
+
Requirements:
|
|
14
|
+
* [Node.js](https://nodejs.org/en/download) (version 18+)
|
|
15
|
+
* A [Letta Developer Platform](https://app.letta.com/) account (or a [self-hosted Letta server](https://docs.letta.com/letta-code/configuration#self-hosted-server))
|
|
21
16
|
|
|
22
17
|
Install the package via [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm):
|
|
23
18
|
```bash
|
|
24
19
|
npm install -g @letta-ai/letta-code
|
|
25
20
|
```
|
|
21
|
+
Navigate to your project directory and run `letta` (see various command-line options [on the docs](https://docs.letta.com/letta-code/commands)):
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
export LETTA_API_KEY=...
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Then run `letta` to start Letta Code (see various command-line options below):
|
|
33
|
-
```
|
|
34
|
-
letta
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Any of the agents you create in Letta Code will be viewable (and fully interactable!) inside the [Agent Development Environment](https://app.letta.com).
|
|
38
|
-
|
|
39
|
-
## Persistence
|
|
40
|
-
|
|
41
|
-
All agents in Letta are **stateful**: they maintain context forever and can self-edit their own [memory blocks](https://www.letta.com/blog/memory-blocks).
|
|
42
|
-
|
|
43
|
-
### Project-Level Agent Persistence
|
|
44
|
-
|
|
45
|
-
**Letta Code automatically remembers the last agent used in each directory.**
|
|
46
|
-
When you run `letta` in a project, it resumes where you left off with the same agent.
|
|
23
|
+
## Memory and Skill Learning
|
|
47
24
|
|
|
48
|
-
**
|
|
49
|
-
- First time running `letta` in a directory → creates new agent (with shared memory blocks across all Letta Code agents)
|
|
50
|
-
- Subsequent runs → automatically resumes that agent
|
|
51
|
-
- Agent ID stored in `.letta/settings.local.json` (gitignored, personal to you)
|
|
25
|
+
All agents in Letta are **stateful**: they maintain context forever and can self-edit their own [memory blocks](https://www.letta.com/blog/memory-blocks).
|
|
52
26
|
|
|
27
|
+
If you’re using Letta Code for the first time, you will likely want to run the `/init` command to initialize the agent’s memory system:
|
|
53
28
|
```bash
|
|
54
|
-
|
|
55
|
-
letta --new # Create new agent with new memory blocks
|
|
56
|
-
letta --agent <id> # Use specific agent ID
|
|
29
|
+
> /init
|
|
57
30
|
```
|
|
58
31
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Letta Code uses a hierarchical memory system:
|
|
62
|
-
|
|
63
|
-
**Global** (`~/.letta/settings.json`)
|
|
64
|
-
- API keys and credentials
|
|
65
|
-
- `persona` block - defines agent behavior
|
|
66
|
-
- `human` block - stores user coding preferences
|
|
67
|
-
|
|
68
|
-
**Project** (`./.letta/settings.local.json`)
|
|
69
|
-
- Last agent ID for this directory (auto-resumes)
|
|
70
|
-
- Gitignored - personal to you, not shared with your team
|
|
71
|
-
|
|
72
|
-
**Project Shared** (`./.letta/settings.json`)
|
|
73
|
-
- `project` block - stores project-specific context
|
|
74
|
-
- Can be committed - shared with team
|
|
75
|
-
|
|
76
|
-
Memory blocks are highly configurable — see our [docs](https://docs.letta.com/guides/agents/memory-blocks) for advanced configuration options.
|
|
77
|
-
Join our [Discord](https://discord.gg/letta) to share feedback on persistence patterns for coding agents.
|
|
78
|
-
|
|
79
|
-
## Skills
|
|
80
|
-
|
|
81
|
-
**Skills are automatically discovered from a `.skills` directory in your project.**
|
|
82
|
-
|
|
83
|
-
Skills allow you to define custom capabilities that the agent can reference and use. When you start a new session, Letta Code recursively scans for `SKILL.MD` files and loads any skill definitions found.
|
|
84
|
-
|
|
85
|
-
### Creating Skills
|
|
86
|
-
|
|
87
|
-
Create a `.skills` directory in your project root and organize skills in subdirectories:
|
|
88
|
-
|
|
32
|
+
Over time, the agent will update its memory as it learns. To actively guide your agents memory, you can use the `/remember` command:
|
|
89
33
|
```bash
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Each skill is defined in a file named `SKILL.MD`. The directory structure determines the skill ID:
|
|
94
|
-
|
|
34
|
+
> /remember [optional instructions on what to remember]
|
|
95
35
|
```
|
|
96
|
-
.
|
|
97
|
-
├── data-analysis/
|
|
98
|
-
│ └── SKILL.MD # skill id: "data-analysis"
|
|
99
|
-
└── web/
|
|
100
|
-
└── scraper/
|
|
101
|
-
└── SKILL.MD # skill id: "web/scraper"
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Create a skill file (`.skills/data-analysis/SKILL.MD`):
|
|
105
|
-
|
|
106
|
-
```markdown
|
|
107
|
-
---
|
|
108
|
-
name: Data Analysis Skill
|
|
109
|
-
description: Analyzes CSV files and generates statistical reports
|
|
110
|
-
category: Data Processing
|
|
111
|
-
tags:
|
|
112
|
-
- analytics
|
|
113
|
-
- statistics
|
|
114
|
-
- csv
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
# Data Analysis Skill
|
|
118
|
-
|
|
119
|
-
This skill analyzes data files and generates comprehensive reports.
|
|
120
|
-
|
|
121
|
-
## Usage
|
|
122
|
-
|
|
123
|
-
Use this skill to analyze CSV files and generate statistical summaries...
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Skill File Format:**
|
|
127
|
-
|
|
128
|
-
- **File name:** Must be named `SKILL.MD` (case-insensitive)
|
|
129
|
-
- **Required frontmatter:**
|
|
130
|
-
- `name` - Display name for the skill
|
|
131
|
-
- `description` - Brief description of what the skill does
|
|
132
|
-
- **Optional frontmatter:**
|
|
133
|
-
- `category` - Category for organizing skills (skills are grouped by category in the agent's memory)
|
|
134
|
-
- `tags` - Array of tags for filtering/searching
|
|
135
|
-
- **Body:** Additional details and documentation about the skill
|
|
136
|
-
|
|
137
|
-
Skills are automatically loaded into the agent's memory on startup, making them available for reference throughout your session.
|
|
138
|
-
|
|
139
|
-
### Custom Skills Directory
|
|
140
|
-
|
|
141
|
-
You can specify a custom skills directory using the `--skills` flag:
|
|
142
|
-
|
|
36
|
+
Letta Code works with skills (reusable modules that teach your agent new capabilities in a `.skills` directory), but additionally supports [skill learning](https://www.letta.com/blog/skill-learning). You can ask your agent to learn a skill from it's current trajectory with the command:
|
|
143
37
|
```bash
|
|
144
|
-
|
|
145
|
-
letta -p "Use the custom skills" --skills ~/my-skills
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Usage
|
|
149
|
-
|
|
150
|
-
### Interactive Mode
|
|
151
|
-
```bash
|
|
152
|
-
letta # Auto-resume project agent (or create new if first time)
|
|
153
|
-
letta --new # Create new agent with new memory blocks
|
|
154
|
-
letta --agent <id> # Use specific agent ID
|
|
155
|
-
letta --model <model> # Specify model (e.g., claude-opus-4.5, claude-sonnet-4.5, gpt-4o)
|
|
156
|
-
letta -m <model> # Short form of --model
|
|
157
|
-
letta --continue # Resume global last agent (deprecated, use project-based)
|
|
158
|
-
|
|
159
|
-
# Managing tools (requires --agent flag)
|
|
160
|
-
letta --agent <id> --link # Attach Letta Code tools to agent, then start session
|
|
161
|
-
letta --agent <id> --unlink # Remove Letta Code tools from agent, then start session
|
|
38
|
+
> /skill [optional instructions on what skill to learn]
|
|
162
39
|
```
|
|
163
40
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
#### Interactive Commands
|
|
167
|
-
|
|
168
|
-
While in a session, you can use these commands:
|
|
169
|
-
- `/agent` - Show current agent link
|
|
170
|
-
- `/model` - Switch models
|
|
171
|
-
- `/toolset` - Switch toolsets (codex/default)
|
|
172
|
-
- `/rename` - Rename the current agent
|
|
173
|
-
- `/stream` - Toggle token streaming on/off
|
|
174
|
-
- `/link` - Attach Letta Code tools to current agent (enables Read, Write, Edit, Bash, etc.)
|
|
175
|
-
- `/unlink` - Remove Letta Code tools from current agent
|
|
176
|
-
- `/clear` - Clear conversation history
|
|
177
|
-
- `/exit` - Exit and show session stats
|
|
178
|
-
- `/logout` - Clear credentials and exit
|
|
179
|
-
|
|
180
|
-
#### Managing Letta Code Tools
|
|
181
|
-
|
|
182
|
-
Letta Code provides tools like `Bash`, `Read`, `Write`, `Edit`, `Grep`, `Glob`, and more. You can attach or remove these tools from any agent:
|
|
183
|
-
|
|
184
|
-
**Via CLI flags** (before starting session):
|
|
185
|
-
```bash
|
|
186
|
-
letta --agent <id> --link # Attach Letta Code tools
|
|
187
|
-
letta --agent <id> --unlink # Remove Letta Code tools
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
**Via interactive commands** (during session):
|
|
191
|
-
```bash
|
|
192
|
-
/link # Attach Letta Code tools to current agent
|
|
193
|
-
/unlink # Remove Letta Code tools from current agent
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
When you attach tools with `/link` or `--link`, they are added to the agent with approval rules enabled (human-in-the-loop). This means the agent can use these tools, but you'll be prompted to approve each tool call. Use permission modes to control approval behavior (see Permissions section below).
|
|
197
|
-
|
|
198
|
-
### Toolsets
|
|
199
|
-
|
|
200
|
-
Letta Code includes different toolsets optimized for different model providers:
|
|
201
|
-
|
|
202
|
-
1. **Default Toolset** (Anthropic-optimized, best for Claude models)
|
|
203
|
-
2. **Codex Toolset** (OpenAI-optimized, best for GPT models)
|
|
204
|
-
3. **Gemini Toolset** (Google-optimized, best for Gemini models)
|
|
205
|
-
|
|
206
|
-
**Automatic Selection:**
|
|
207
|
-
When you specify a model, Letta Code automatically selects the appropriate toolset:
|
|
208
|
-
```bash
|
|
209
|
-
letta --model haiku # Loads default toolset
|
|
210
|
-
letta --model gpt-5-codex # Loads codex toolset
|
|
211
|
-
letta --model gemini-3-pro # Loads gemini toolset
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**Manual Override:**
|
|
215
|
-
You can force a specific toolset regardless of model:
|
|
216
|
-
```bash
|
|
217
|
-
# CLI flag (at startup)
|
|
218
|
-
letta --model haiku --toolset codex # Use Codex-style tools with Claude Haiku
|
|
219
|
-
letta --model gpt-5-codex --toolset gemini # Use Gemini-style tools with GPT-5-Codex
|
|
220
|
-
letta --toolset gemini # Use Gemini tools with default model
|
|
221
|
-
|
|
222
|
-
# Interactive command (during session)
|
|
223
|
-
/toolset # Opens toolset selector
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
The `/model` command automatically switches toolsets when you change models. Use `/toolset` if you want to manually override the automatic selection.
|
|
227
|
-
|
|
228
|
-
### Headless Mode
|
|
229
|
-
```bash
|
|
230
|
-
letta -p "Run bun lint and correct errors" # Auto-resumes project agent
|
|
231
|
-
letta -p "Pick up where you left off" # Same - auto-resumes by default
|
|
232
|
-
letta -p "Start fresh" --new # Create new agent with new memory blocks
|
|
233
|
-
letta -p "Run all the test" --allowedTools "Bash" # Control tool permissions
|
|
234
|
-
letta -p "Just read the code" --disallowedTools "Bash" # Control tool permissions
|
|
235
|
-
letta -p "Explain this code" -m gpt-4o # Use specific model
|
|
236
|
-
|
|
237
|
-
# Pipe input from stdin
|
|
238
|
-
echo "Explain this code" | letta -p
|
|
239
|
-
cat file.txt | letta -p
|
|
240
|
-
gh pr diff 123 | letta -p --yolo
|
|
241
|
-
|
|
242
|
-
# Output formats
|
|
243
|
-
letta -p "Analyze this codebase" --output-format json # Structured JSON at end
|
|
244
|
-
letta -p "Analyze this codebase" --output-format stream-json # JSONL stream (one event per line)
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
You can also use the `--tools` flag to control the underlying *attachment* of tools (not just the permissions).
|
|
248
|
-
Compared to disallowing the tool, this will additionally remove the tool schema from the agent's context window.
|
|
249
|
-
```bash
|
|
250
|
-
letta -p "Run all tests" --tools "Bash,Read" # Only load specific tools
|
|
251
|
-
letta -p "Just analyze the code" --tools "" # No tools (analysis only)
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Use `--output-format json` to get structured output with metadata:
|
|
255
|
-
```bash
|
|
256
|
-
# regular text output
|
|
257
|
-
$ letta -p "hi there"
|
|
258
|
-
Hi! How can I help you today?
|
|
259
|
-
|
|
260
|
-
# structured output (single JSON object at end)
|
|
261
|
-
$ letta -p "hi there" --output-format json
|
|
262
|
-
{
|
|
263
|
-
"type": "result",
|
|
264
|
-
"subtype": "success",
|
|
265
|
-
"is_error": false,
|
|
266
|
-
"duration_ms": 5454,
|
|
267
|
-
"duration_api_ms": 2098,
|
|
268
|
-
"num_turns": 1,
|
|
269
|
-
"result": "Hi! How can I help you today?",
|
|
270
|
-
"agent_id": "agent-8ab431ca-63e0-4ca1-ba83-b64d66d95a0f",
|
|
271
|
-
"usage": {
|
|
272
|
-
"prompt_tokens": 294,
|
|
273
|
-
"completion_tokens": 97,
|
|
274
|
-
"total_tokens": 391
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
Use `--output-format stream-json` to get streaming outputs, in addition to a final JSON response.
|
|
280
|
-
This is useful if you need to have data flowing to prevent automatic timeouts:
|
|
281
|
-
```bash
|
|
282
|
-
# streaming JSON output (JSONL - one event per line, token-level streaming)
|
|
283
|
-
# Note: Messages are streamed at the token level - each chunk has the same otid and incrementing seqId.
|
|
284
|
-
$ letta -p "hi there" --output-format stream-json
|
|
285
|
-
{"type":"init","agent_id":"agent-...","model":"claude-sonnet-4-5-20250929","tools":[...]}
|
|
286
|
-
{"type":"message","messageType":"reasoning_message","reasoning":"The user is asking","otid":"...","seqId":1}
|
|
287
|
-
{"type":"message","messageType":"reasoning_message","reasoning":" me to say hello","otid":"...","seqId":2}
|
|
288
|
-
{"type":"message","messageType":"reasoning_message","reasoning":". This is a simple","otid":"...","seqId":3}
|
|
289
|
-
{"type":"message","messageType":"reasoning_message","reasoning":" greeting.","otid":"...","seqId":4}
|
|
290
|
-
{"type":"message","messageType":"assistant_message","content":"Hi! How can I help you today?","otid":"...","seqId":5}
|
|
291
|
-
{"type":"message","messageType":"stop_reason","stopReason":"end_turn"}
|
|
292
|
-
{"type":"message","messageType":"usage_statistics","promptTokens":294,"completionTokens":97,"totalTokens":391}
|
|
293
|
-
{"type":"result","subtype":"success","result":"Hi! How can I help you today?","agent_id":"agent-...","usage":{...}}
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### Permissions
|
|
297
|
-
|
|
298
|
-
**Tool selection** (controls which tools are loaded):
|
|
299
|
-
```bash
|
|
300
|
-
--tools "Bash,Read,Write" # Only load these tools
|
|
301
|
-
--tools "" # No tools (conversation only)
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
**Permission overrides** (controls tool access, applies to loaded tools):
|
|
305
|
-
```bash
|
|
306
|
-
--allowedTools "Bash,Read,Write" # Allow specific tools
|
|
307
|
-
--allowedTools "Bash(npm run test:*)" # Allow specific commands
|
|
308
|
-
--disallowedTools "Bash(curl:*)" # Block specific patterns
|
|
309
|
-
--permission-mode acceptEdits # Auto-allow Write/Edit tools
|
|
310
|
-
--permission-mode plan # Read-only mode
|
|
311
|
-
--permission-mode bypassPermissions # Allow all tools (use carefully!)
|
|
312
|
-
--yolo # Alias for --permission-mode bypassPermissions
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Permission modes:
|
|
316
|
-
- `default` - Standard behavior, prompts for approval
|
|
317
|
-
- `acceptEdits` - Auto-allows Write/Edit/NotebookEdit
|
|
318
|
-
- `plan` - Read-only, allows analysis but blocks modifications
|
|
319
|
-
- `bypassPermissions` - Auto-allows all tools (for trusted environments)
|
|
320
|
-
|
|
321
|
-
Permissions are also configured in `.letta/settings.json`:
|
|
322
|
-
```json
|
|
323
|
-
{
|
|
324
|
-
"permissions": {
|
|
325
|
-
"allow": ["Bash(npm run lint)", "Read(src/**)"],
|
|
326
|
-
"deny": ["Bash(rm -rf:*)", "Read(.env)"]
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
## Self-hosting
|
|
332
|
-
|
|
333
|
-
To use Letta Code with a self-hosted server, set `LETTA_BASE_URL` to your server IP, e.g. `export LETTA_BASE_URL="http://localhost:8283"`.
|
|
334
|
-
See our [self-hosting guide](https://docs.letta.com/guides/selfhosting) for more information.
|
|
335
|
-
|
|
336
|
-
## Installing from source
|
|
337
|
-
|
|
338
|
-
First, install Bun if you don't have it yet: [https://bun.com/docs/installation](https://bun.com/docs/installation)
|
|
339
|
-
|
|
340
|
-
### Run directly from source (dev workflow)
|
|
341
|
-
```bash
|
|
342
|
-
# install deps
|
|
343
|
-
bun install
|
|
344
|
-
|
|
345
|
-
# run the CLI from TypeScript sources (pick up changes immediately)
|
|
346
|
-
bun run dev
|
|
347
|
-
bun run dev -- -p "Hello world" # example with args
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
### Build + link the standalone binary
|
|
351
|
-
```bash
|
|
352
|
-
# build bin/letta (includes prompts + schemas)
|
|
353
|
-
bun run build
|
|
354
|
-
|
|
355
|
-
# expose the binary globally (adjust to your preference)
|
|
356
|
-
bun link
|
|
357
|
-
|
|
358
|
-
# now you can run the compiled CLI
|
|
359
|
-
letta
|
|
360
|
-
```
|
|
361
|
-
> Whenever you change source files, rerun `bun run build` before using the linked `letta` binary so it picks up your edits.
|
|
41
|
+
Read the docs to learn more about [skills and skill learning](https://docs.letta.com/letta-code/skills).
|
|
362
42
|
|
|
363
43
|
---
|
|
364
44
|
|