@letta-ai/letta-code 0.27.7 → 0.27.9
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 +2 -2
- package/dist/app-server-client.js +387 -0
- package/dist/app-server-client.js.map +10 -0
- package/dist/types/app-server-client.d.ts +99 -0
- package/dist/types/app-server-client.d.ts.map +1 -0
- package/dist/types/types/app-server-protocol.d.ts +3 -0
- package/dist/types/types/app-server-protocol.d.ts.map +1 -0
- package/dist/types/types/protocol.d.ts.map +1 -0
- package/dist/types/types/protocol_v2.d.ts +2277 -0
- package/dist/types/types/protocol_v2.d.ts.map +1 -0
- package/letta.js +22835 -19810
- package/package.json +12 -2
- package/scripts/check-bundled-skill-scripts.js +169 -0
- package/scripts/check-test-coverage.cjs +1 -1
- package/scripts/check.js +1 -0
- package/scripts/run-unit-tests.cjs +1 -1
- package/skills/converting-mcps-to-skills/SKILL.md +1 -12
- package/skills/converting-mcps-to-skills/scripts/mcp-stdio.ts +192 -57
- package/skills/{creating-extensions → creating-mods}/SKILL.md +29 -29
- package/skills/{creating-extensions → creating-mods}/references/architecture.md +9 -9
- package/skills/{creating-extensions → creating-mods}/references/commands.md +10 -10
- package/skills/{creating-extensions → creating-mods}/references/events.md +10 -10
- package/skills/{creating-extensions → creating-mods}/references/permissions.md +3 -3
- package/skills/{creating-extensions → creating-mods}/references/plan-mode.md +72 -31
- package/skills/{creating-extensions → creating-mods}/references/providers.md +7 -7
- package/skills/{creating-extensions → creating-mods}/references/tools.md +20 -2
- package/skills/{creating-extensions → creating-mods}/references/ui.md +4 -4
- package/skills/creating-skills/scripts/validate-skill.ts +129 -5
- package/skills/customizing-commands/SKILL.md +18 -18
- package/skills/customizing-statusline/SKILL.md +11 -11
- package/skills/customizing-statusline/references/api.md +8 -8
- package/skills/customizing-statusline/references/examples.md +1 -1
- package/skills/customizing-statusline/references/migration.md +1 -1
- package/skills/editing-letta-code-desktop-preferences/SKILL.md +67 -0
- package/skills/image-generation/SKILL.md +120 -0
- package/skills/modifying-the-harness/SKILL.md +21 -2
- package/skills/modifying-the-harness/scripts/add_permission.py +2 -1
- package/skills/modifying-the-harness/scripts/show_config.py +4 -3
- package/dist/types/protocol.d.ts.map +0 -1
- package/skills/converting-mcps-to-skills/scripts/package.json +0 -13
- /package/dist/types/{protocol.d.ts → types/protocol.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mod UI recipes
|
|
2
2
|
|
|
3
|
-
UI capabilities are optional. Always guard UI work with `letta.capabilities.ui.*` when writing portable
|
|
3
|
+
UI capabilities are optional. Always guard UI work with `letta.capabilities.ui.*` when writing portable mods.
|
|
4
4
|
|
|
5
|
-
For UI that belongs to a larger command/event
|
|
5
|
+
For UI that belongs to a larger command/event mod, also read `architecture.md` for cleanup and composition patterns.
|
|
6
6
|
|
|
7
7
|
## Capabilities
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ letta.capabilities.ui.customStatuslineRenderer
|
|
|
21
21
|
```ts
|
|
22
22
|
if (letta.capabilities.ui.panels) {
|
|
23
23
|
const panel = letta.ui.openPanel({
|
|
24
|
-
id: "my-
|
|
24
|
+
id: "my-mod",
|
|
25
25
|
content: ["Working…"],
|
|
26
26
|
order: 100,
|
|
27
27
|
});
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import { basename, join, resolve } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
|
-
import { parse as parseYaml } from "yaml";
|
|
16
15
|
|
|
17
16
|
interface ValidationResult {
|
|
18
17
|
valid: boolean;
|
|
@@ -29,6 +28,131 @@ const ALLOWED_PROPERTIES = new Set([
|
|
|
29
28
|
"allowed-tools",
|
|
30
29
|
]);
|
|
31
30
|
|
|
31
|
+
export const MAX_SKILL_NAME_LENGTH = 64;
|
|
32
|
+
|
|
33
|
+
type BunYamlRuntime = {
|
|
34
|
+
Bun?: {
|
|
35
|
+
YAML?: {
|
|
36
|
+
parse?: (source: string) => unknown;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function parseQuotedScalar(value: string): string {
|
|
42
|
+
if (value.startsWith('"')) {
|
|
43
|
+
if (!value.endsWith('"') || value.length === 1) {
|
|
44
|
+
throw new Error("Unterminated double-quoted scalar");
|
|
45
|
+
}
|
|
46
|
+
return JSON.parse(value) as string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (value.startsWith("'")) {
|
|
50
|
+
if (!value.endsWith("'") || value.length === 1) {
|
|
51
|
+
throw new Error("Unterminated single-quoted scalar");
|
|
52
|
+
}
|
|
53
|
+
return value.slice(1, -1).replace(/''/g, "'");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function parseScalar(value: string): unknown {
|
|
60
|
+
const trimmed = value.trim();
|
|
61
|
+
if (!trimmed) return "";
|
|
62
|
+
|
|
63
|
+
if (trimmed === "true") return true;
|
|
64
|
+
if (trimmed === "false") return false;
|
|
65
|
+
if (trimmed === "null" || trimmed === "~") return null;
|
|
66
|
+
|
|
67
|
+
if (trimmed.startsWith('"') || trimmed.startsWith("'")) {
|
|
68
|
+
return parseQuotedScalar(trimmed);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// The fallback parser intentionally accepts only the frontmatter subset this
|
|
72
|
+
// validator needs. Unquoted ": " inside a scalar is the most common YAML
|
|
73
|
+
// authoring mistake; reject it instead of silently producing a bad value.
|
|
74
|
+
if (trimmed.includes(": ")) {
|
|
75
|
+
throw new Error(`Unexpected ':' in unquoted scalar: ${trimmed}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (/^-?\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
79
|
+
return Number(trimmed);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return trimmed;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function parseFrontmatterFallback(source: string): Record<string, unknown> {
|
|
86
|
+
const result: Record<string, unknown> = {};
|
|
87
|
+
const lines = source.split(/\r?\n/);
|
|
88
|
+
|
|
89
|
+
for (let i = 0; i < lines.length; i++) {
|
|
90
|
+
const line = lines[i];
|
|
91
|
+
if (line === undefined) continue;
|
|
92
|
+
const trimmed = line.trim();
|
|
93
|
+
|
|
94
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (/^\s/.test(line)) {
|
|
99
|
+
// Nested data belongs to the previous top-level key. The validator only
|
|
100
|
+
// checks top-level field names plus name/description scalar values.
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const colonIndex = line.indexOf(":");
|
|
105
|
+
if (colonIndex <= 0) {
|
|
106
|
+
throw new Error(`Invalid frontmatter line: ${line}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const key = line.slice(0, colonIndex).trim();
|
|
110
|
+
const rawValue = line.slice(colonIndex + 1).trim();
|
|
111
|
+
if (!key) {
|
|
112
|
+
throw new Error(`Invalid frontmatter line: ${line}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!rawValue) {
|
|
116
|
+
result[key] = {};
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (rawValue === "|" || rawValue === ">") {
|
|
121
|
+
const blockLines: string[] = [];
|
|
122
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
123
|
+
const nextLine = lines[j];
|
|
124
|
+
if (nextLine === undefined) continue;
|
|
125
|
+
if (nextLine.trim() && !/^\s/.test(nextLine)) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
blockLines.push(nextLine.replace(/^\s{2}/, ""));
|
|
129
|
+
i = j;
|
|
130
|
+
}
|
|
131
|
+
result[key] =
|
|
132
|
+
rawValue === ">" ? blockLines.join(" ").trim() : blockLines.join("\n");
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
result[key] = parseScalar(rawValue);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function parseFrontmatter(source: string): Record<string, unknown> {
|
|
143
|
+
const bunParse = (globalThis as typeof globalThis & BunYamlRuntime).Bun?.YAML
|
|
144
|
+
?.parse;
|
|
145
|
+
if (bunParse) {
|
|
146
|
+
const parsed = bunParse(source);
|
|
147
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
148
|
+
throw new Error("Frontmatter must be a YAML dictionary");
|
|
149
|
+
}
|
|
150
|
+
return parsed as Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return parseFrontmatterFallback(source);
|
|
154
|
+
}
|
|
155
|
+
|
|
32
156
|
export function validateSkill(skillPath: string): ValidationResult {
|
|
33
157
|
// Check SKILL.md exists
|
|
34
158
|
const skillMdPath = join(skillPath, "SKILL.md");
|
|
@@ -55,7 +179,7 @@ export function validateSkill(skillPath: string): ValidationResult {
|
|
|
55
179
|
// Parse YAML frontmatter
|
|
56
180
|
let frontmatter: Record<string, unknown>;
|
|
57
181
|
try {
|
|
58
|
-
frontmatter =
|
|
182
|
+
frontmatter = parseFrontmatter(frontmatterText);
|
|
59
183
|
if (typeof frontmatter !== "object" || frontmatter === null) {
|
|
60
184
|
return { valid: false, message: "Frontmatter must be a YAML dictionary" };
|
|
61
185
|
}
|
|
@@ -112,11 +236,11 @@ export function validateSkill(skillPath: string): ValidationResult {
|
|
|
112
236
|
message: `Name '${trimmedName}' cannot start/end with hyphen or contain consecutive hyphens`,
|
|
113
237
|
};
|
|
114
238
|
}
|
|
115
|
-
// Check name length
|
|
116
|
-
if (trimmedName.length >
|
|
239
|
+
// Check name length
|
|
240
|
+
if (trimmedName.length > MAX_SKILL_NAME_LENGTH) {
|
|
117
241
|
return {
|
|
118
242
|
valid: false,
|
|
119
|
-
message: `Name is too long (${trimmedName.length} characters). Maximum is
|
|
243
|
+
message: `Name is too long (${trimmedName.length} characters). Maximum is ${MAX_SKILL_NAME_LENGTH} characters.`,
|
|
120
244
|
};
|
|
121
245
|
}
|
|
122
246
|
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: customizing-commands
|
|
3
|
-
description: Creates, edits, and enables Letta Code
|
|
3
|
+
description: Creates, edits, and enables Letta Code mod-provided slash commands. Use when the user asks to add a custom /command, slash command, command shortcut, scoped conversation-backed command, or command-driven panel behavior.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Customizing Commands
|
|
7
7
|
|
|
8
|
-
Use this as the command-specific entrypoint for local
|
|
8
|
+
Use this as the command-specific entrypoint for local mod slash commands. For broader mod work, recipes live in `../creating-mods/references/commands.md`, `../creating-mods/references/architecture.md`, `../creating-mods/references/ui.md`, and `../creating-mods/references/plan-mode.md`.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Mod files live in:
|
|
11
11
|
|
|
12
12
|
```text
|
|
13
|
-
~/.letta/
|
|
13
|
+
~/.letta/mods/
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Use a focused file name, e.g. `~/.letta/
|
|
16
|
+
Use a focused file name, e.g. `~/.letta/mods/review.ts` or `~/.letta/mods/commands.ts`.
|
|
17
17
|
|
|
18
18
|
## First decide whether a command is right
|
|
19
19
|
|
|
20
20
|
| User wants | Build |
|
|
21
21
|
| --- | --- |
|
|
22
|
-
| `/foo` sends a prompt or shows local output |
|
|
23
|
-
| `/foo` starts a reusable agent workflow | Skill + thin
|
|
24
|
-
| Agent/model should autonomously call the capability |
|
|
25
|
-
| Command shows transient progress/results |
|
|
22
|
+
| `/foo` sends a prompt or shows local output | Mod command |
|
|
23
|
+
| `/foo` starts a reusable agent workflow | Skill + thin mod command |
|
|
24
|
+
| Agent/model should autonomously call the capability | Mod tool, not a command |
|
|
25
|
+
| Command shows transient progress/results | Mod command + panel |
|
|
26
26
|
| Command needs model output while the main agent is busy | `runWhenBusy: true` command + forked `ctx.conversation` |
|
|
27
27
|
|
|
28
|
-
If the command is a durable workflow like `/goal`, put the workflow instructions in a skill and keep the
|
|
28
|
+
If the command is a durable workflow like `/goal`, put the workflow instructions in a skill and keep the mod command as a small launcher/prompt.
|
|
29
29
|
|
|
30
30
|
## Workflow
|
|
31
31
|
|
|
32
|
-
1. Inspect `~/.letta/
|
|
33
|
-
2. Preserve unrelated
|
|
32
|
+
1. Inspect `~/.letta/mods/` for related command files.
|
|
33
|
+
2. Preserve unrelated mod code; create a focused new file if merging is messy.
|
|
34
34
|
3. Register with `letta.commands.register()` and guard with `letta.capabilities.commands`.
|
|
35
35
|
4. Return the unregister function, or a disposer that calls it plus any timer/panel cleanup.
|
|
36
36
|
5. Tell the user the exact file path changed and to run `/reload`.
|
|
@@ -62,7 +62,7 @@ export default function activate(letta) {
|
|
|
62
62
|
## Command result types
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
|
-
type
|
|
65
|
+
type ModCommandResult =
|
|
66
66
|
| { type: "prompt"; content: string; systemReminder?: boolean }
|
|
67
67
|
| { type: "output"; output: string; success?: boolean }
|
|
68
68
|
| { type: "handled" };
|
|
@@ -80,11 +80,11 @@ type ExtensionCommandResult =
|
|
|
80
80
|
- `runWhenBusy: true` commands must not return `prompt` while the main agent is busy; use scoped conversation helpers/panels and return `handled`.
|
|
81
81
|
- `showInTranscript: false` commands should usually return `handled`, not `prompt`.
|
|
82
82
|
- Do not import Letta Code app internals.
|
|
83
|
-
- Do not do surprising side effects on startup;
|
|
83
|
+
- Do not do surprising side effects on startup; mods activate on app start and `/reload`.
|
|
84
84
|
|
|
85
85
|
## More recipes
|
|
86
86
|
|
|
87
|
-
- Simple output command, panel command, busy-safe conversation command: `../creating-
|
|
88
|
-
- Complex command architecture, state, cleanup: `../creating-
|
|
89
|
-
- Panel/status UI patterns: `../creating-
|
|
90
|
-
- Worked plan-mode command/tool composition: `../creating-
|
|
87
|
+
- Simple output command, panel command, busy-safe conversation command: `../creating-mods/references/commands.md`
|
|
88
|
+
- Complex command architecture, state, cleanup: `../creating-mods/references/architecture.md`
|
|
89
|
+
- Panel/status UI patterns: `../creating-mods/references/ui.md`
|
|
90
|
+
- Worked plan-mode command/tool composition: `../creating-mods/references/plan-mode.md`
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: customizing-statusline
|
|
3
|
-
description: Creates, edits, and migrates Letta Code statusline
|
|
3
|
+
description: Creates, edits, and migrates Letta Code statusline mods. Use when handling the /statusline command or continuing work started by /statusline.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Customizing Statusline
|
|
7
7
|
|
|
8
|
-
Use this skill to create or update the global Letta Code statusline
|
|
8
|
+
Use this skill to create or update the global Letta Code statusline mod:
|
|
9
9
|
|
|
10
10
|
```text
|
|
11
|
-
~/.letta/
|
|
11
|
+
~/.letta/mods/statusline.tsx
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
The statusline is a full-row idle renderer. Host UI can still temporarily preempt it for safety confirmations and transient hints.
|
|
@@ -18,7 +18,7 @@ The statusline is a full-row idle renderer. Host UI can still temporarily preemp
|
|
|
18
18
|
```text
|
|
19
19
|
safety preemption
|
|
20
20
|
else transient host hint
|
|
21
|
-
else custom statusline
|
|
21
|
+
else custom statusline mod
|
|
22
22
|
else built-in default statusline
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -26,14 +26,14 @@ A custom statusline owns the whole idle row. Do not preserve legacy left/right s
|
|
|
26
26
|
|
|
27
27
|
## Workflow
|
|
28
28
|
|
|
29
|
-
1. Check whether `~/.letta/
|
|
29
|
+
1. Check whether `~/.letta/mods/statusline.tsx` exists.
|
|
30
30
|
2. If it exists, read it before editing and preserve unrelated code.
|
|
31
31
|
3. If it does not exist, start from the built-in default template or synthesize a focused starter for the user's request.
|
|
32
32
|
4. If the user asks to migrate, import a `.sh` file, or match a shell prompt, read `references/migration.md`.
|
|
33
33
|
5. If API details or concrete patterns are needed, read `references/api.md` and `references/examples.md`.
|
|
34
|
-
6. If the request combines statusline work with commands, tools, events, panels, or stateful
|
|
34
|
+
6. If the request combines statusline work with commands, tools, events, panels, or stateful mod behavior, also use `creating-mods` and its `references/architecture.md`.
|
|
35
35
|
7. Guard statusline-specific behavior with `letta.capabilities.ui.customStatuslineRenderer` when writing new files.
|
|
36
|
-
8. Edit `~/.letta/
|
|
36
|
+
8. Edit `~/.letta/mods/statusline.tsx`.
|
|
37
37
|
9. Summarize the absolute file path changed and tell the user to run `/reload` unless the command can reload automatically.
|
|
38
38
|
|
|
39
39
|
## Bare `/statusline` behavior
|
|
@@ -52,8 +52,8 @@ Keep this conversational. Do not build a menu UI unless the product command expl
|
|
|
52
52
|
|
|
53
53
|
## Rules
|
|
54
54
|
|
|
55
|
-
- Global-only for now. Do not create project
|
|
56
|
-
- Keep the
|
|
55
|
+
- Global-only for now. Do not create project mods.
|
|
56
|
+
- Keep the mod single-file for MVP.
|
|
57
57
|
- Do not assume extra npm packages are available.
|
|
58
58
|
- Do not use relative multi-file imports yet.
|
|
59
59
|
- Keep renderers synchronous. Do not shell, fetch, or await inside render.
|
|
@@ -61,11 +61,11 @@ Keep this conversational. Do not build a menu UI unless the product command expl
|
|
|
61
61
|
- Use `letta.ui.setStatus` for data and `setStatuslineRenderer` for drawing that data.
|
|
62
62
|
- Guard optional APIs with `letta.capabilities.ui.statusValues` and `letta.capabilities.ui.customStatuslineRenderer` in new files.
|
|
63
63
|
- Return a disposer that clears timers/subscriptions.
|
|
64
|
-
- Preserve existing
|
|
64
|
+
- Preserve existing mod code unless the user asks to reset.
|
|
65
65
|
- Do not delete legacy command statusline files or settings unless the user explicitly asks.
|
|
66
66
|
|
|
67
67
|
## Useful references
|
|
68
68
|
|
|
69
|
-
- `references/api.md` -
|
|
69
|
+
- `references/api.md` - mod API, render context, lifecycle rules
|
|
70
70
|
- `references/examples.md` - common statusline patterns
|
|
71
71
|
- `references/migration.md` - legacy command `.sh` and PS1 migration
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Statusline
|
|
1
|
+
# Statusline Mod API
|
|
2
2
|
|
|
3
|
-
Use this reference when creating or editing `~/.letta/
|
|
3
|
+
Use this reference when creating or editing `~/.letta/mods/statusline.tsx`.
|
|
4
4
|
|
|
5
5
|
## Location
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
|
-
~/.letta/
|
|
8
|
+
~/.letta/mods/statusline.tsx
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
This is a trusted, user-owned global
|
|
11
|
+
This is a trusted, user-owned global mod file. Project mods are intentionally unsupported for now.
|
|
12
12
|
|
|
13
13
|
## Activation
|
|
14
14
|
|
|
@@ -59,7 +59,7 @@ letta.ui.setStatuslineRenderer((context) => {
|
|
|
59
59
|
|
|
60
60
|
## Async state pattern
|
|
61
61
|
|
|
62
|
-
Use Node/Bun APIs directly from the trusted
|
|
62
|
+
Use Node/Bun APIs directly from the trusted mod file. Do not assume helper methods like `letta.shell` exist.
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
65
|
import { execFile } from "node:child_process";
|
|
@@ -117,7 +117,7 @@ Common fields:
|
|
|
117
117
|
|
|
118
118
|
```ts
|
|
119
119
|
context.components // Display components such as Text, Box, Spacer
|
|
120
|
-
context.statuses // evaluated
|
|
120
|
+
context.statuses // evaluated mod status strings
|
|
121
121
|
context.app.version
|
|
122
122
|
context.workspace.cwd
|
|
123
123
|
context.workspace.currentDir
|
|
@@ -159,10 +159,10 @@ return (
|
|
|
159
159
|
|
|
160
160
|
## Reload behavior
|
|
161
161
|
|
|
162
|
-
After editing `~/.letta/
|
|
162
|
+
After editing `~/.letta/mods/statusline.tsx`, tell the user to run:
|
|
163
163
|
|
|
164
164
|
```text
|
|
165
165
|
/reload
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
The runtime tracks
|
|
168
|
+
The runtime tracks mod loading separately from “no custom statusline,” so a custom statusline should not flash back to the built-in default during reload.
|
|
@@ -39,7 +39,7 @@ Look for either shape:
|
|
|
39
39
|
When migrating:
|
|
40
40
|
|
|
41
41
|
- Preserve old config and referenced files unless the user explicitly asks to delete them.
|
|
42
|
-
- If `command` references a `.sh` file, read it before writing the new
|
|
42
|
+
- If `command` references a `.sh` file, read it before writing the new mod.
|
|
43
43
|
- Translate polling (`refreshIntervalMs`) to `setInterval`.
|
|
44
44
|
- Translate direct command output into cached status plus synchronous rendering.
|
|
45
45
|
- If the command output used `\x1e` to split left/right output, convert it to internal full-row layout with `Box`; do not create a new left/right API.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: editing-letta-code-desktop-preferences
|
|
3
|
+
description: Edits Letta Code Desktop (LCD) preferences by safely reading and updating ~/.letta/desktop_preferences.json. Use only when the user asks to change current Desktop/LCD settings such as theme, default working directory, remote access preference, or remote environment name via the preferences JSON.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Editing Letta Code Desktop Preferences
|
|
7
|
+
|
|
8
|
+
Use this skill only to edit the active Letta Code Desktop preferences JSON file. Do not use it for Desktop product-code changes, Electron IPC work, UI changes, or general Letta Cloud Desktop implementation tasks.
|
|
9
|
+
|
|
10
|
+
## Preferences file
|
|
11
|
+
|
|
12
|
+
The Desktop preferences file is:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
~/.letta/desktop_preferences.json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Known preference keys:
|
|
19
|
+
|
|
20
|
+
- `defaultWorkingDirectory`: default folder for new local sessions.
|
|
21
|
+
- `theme`: `auto`, `light`, or `dark`.
|
|
22
|
+
- `allowRemoteAccess`: boolean for whether remote access should be enabled in preferences.
|
|
23
|
+
- `remoteEnvName`: environment name shown for remote access.
|
|
24
|
+
|
|
25
|
+
## Workflow
|
|
26
|
+
|
|
27
|
+
1. Read the existing JSON first.
|
|
28
|
+
2. Preserve unknown keys.
|
|
29
|
+
3. Merge only the requested preference updates.
|
|
30
|
+
4. Write pretty JSON with a trailing newline.
|
|
31
|
+
5. Do not edit token, provider, secret, agent, conversation, memory, or unrelated state files.
|
|
32
|
+
6. Tell the user that the change applies live only if their Desktop build watches preference-file changes; otherwise they should reload/restart Desktop or use Preferences → General.
|
|
33
|
+
|
|
34
|
+
## Safe edit command
|
|
35
|
+
|
|
36
|
+
Use a merge-style edit like this, changing only the requested keys:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
node - <<'NODE'
|
|
40
|
+
const fs = require('fs');
|
|
41
|
+
const os = require('os');
|
|
42
|
+
const path = require('path');
|
|
43
|
+
|
|
44
|
+
const file = path.join(os.homedir(), '.letta', 'desktop_preferences.json');
|
|
45
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
46
|
+
|
|
47
|
+
const current = fs.existsSync(file)
|
|
48
|
+
? JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
49
|
+
: {};
|
|
50
|
+
|
|
51
|
+
const next = {
|
|
52
|
+
...current,
|
|
53
|
+
// Example update. Replace this with the user's requested setting.
|
|
54
|
+
theme: 'dark',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
fs.writeFileSync(file, JSON.stringify(next, null, 2) + '\n');
|
|
58
|
+
NODE
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Validation
|
|
62
|
+
|
|
63
|
+
After editing, read the file back or parse it to confirm valid JSON:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
node -e "JSON.parse(require('fs').readFileSync(require('os').homedir() + '/.letta/desktop_preferences.json', 'utf8')); console.log('desktop_preferences.json is valid')"
|
|
67
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: image-generation
|
|
3
|
+
description: Generate images from text prompts (and optionally edit/remix input images). Use when the user asks to create, generate, draw, render, or edit an image, illustration, logo, icon, diagram, or photo.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Image Generation
|
|
7
|
+
|
|
8
|
+
Generate images via Letta's hosted endpoint `POST /v1/images/generations`. The API
|
|
9
|
+
usually returns base64 image bytes, but some providers return signed image URLs;
|
|
10
|
+
save either form to a local image file before replying.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
Generate the image, save it locally, then show it inline:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
curl -sS -X POST "https://api.letta.com/v1/images/generations" \
|
|
18
|
+
-H "Authorization: Bearer $LETTA_API_KEY" \
|
|
19
|
+
-H "Content-Type: application/json" \
|
|
20
|
+
-d '{"provider":"gemini","prompt":"a friendly robot mascot waving, flat vector logo, mint green background","n":1}' \
|
|
21
|
+
> image-response.json
|
|
22
|
+
|
|
23
|
+
python3 - <<'PY'
|
|
24
|
+
import base64, json, urllib.request
|
|
25
|
+
|
|
26
|
+
with open("image-response.json") as f:
|
|
27
|
+
response = json.load(f)
|
|
28
|
+
|
|
29
|
+
image = response["images"][0]
|
|
30
|
+
if image.get("b64_json"):
|
|
31
|
+
data = base64.b64decode(image["b64_json"])
|
|
32
|
+
else:
|
|
33
|
+
data = urllib.request.urlopen(image["url"]).read()
|
|
34
|
+
|
|
35
|
+
with open("robot-mascot.png", "wb") as f:
|
|
36
|
+
f.write(data)
|
|
37
|
+
|
|
38
|
+
print("saved robot-mascot.png; credits:", response["billing"]["credits_charged"])
|
|
39
|
+
PY
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
In Bash tools launched by Letta Code, the current Letta credential is available
|
|
43
|
+
as `$LETTA_API_KEY`. This works for both Letta auth modes: it may be a normal
|
|
44
|
+
Letta API key, or the OAuth access token from a Letta Cloud OAuth login. Reference
|
|
45
|
+
it directly. If it is missing, the user needs to authenticate with Letta Cloud (or
|
|
46
|
+
provide a Letta API key); do **not** ask for a Flux/OpenAI/Gemini provider key. This
|
|
47
|
+
endpoint also does not use `/connect` BYOK providers — the only `provider` values
|
|
48
|
+
supported here are `flux`, `gemini`, and `openai`.
|
|
49
|
+
|
|
50
|
+
Then **show the image to the user** by embedding the saved file in your reply:
|
|
51
|
+
|
|
52
|
+
```markdown
|
|
53
|
+
Here's the mascot:
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The Letta Code UI renders local file paths in markdown image tags, so the image
|
|
59
|
+
appears inline. **Always display generated images this way** — don't just report
|
|
60
|
+
the path, and never paste the raw base64 / a `data:` URI. The markdown path must
|
|
61
|
+
match where you saved the file. For `n > 1`, save each image to its own file and
|
|
62
|
+
embed each on its own line. Also tell the user the `credits_charged`.
|
|
63
|
+
|
|
64
|
+
## Request body
|
|
65
|
+
|
|
66
|
+
| Field | Type | Notes |
|
|
67
|
+
|-------|------|-------|
|
|
68
|
+
| `provider` | `"flux"` \| `"gemini"` \| `"openai"` | Required. |
|
|
69
|
+
| `prompt` | string | Required, 1–32000 chars. |
|
|
70
|
+
| `model` | string | Optional; defaults per provider (below). |
|
|
71
|
+
| `n` | int 1–4 | Optional, default 1. Request variations in one call. |
|
|
72
|
+
| `size` | string | Optional, e.g. `"1024x1024"` (OpenAI). |
|
|
73
|
+
| `quality` | `low`\|`medium`\|`high`\|`auto` | Optional (OpenAI; higher = more credits). |
|
|
74
|
+
| `output_format` | `png`\|`jpeg`\|`webp` | Optional (OpenAI). |
|
|
75
|
+
| `input_images` | string[] (max 14) | Optional. Base64 **data URLs** for edit/remix. |
|
|
76
|
+
| `seed` | int | Optional. |
|
|
77
|
+
|
|
78
|
+
| Provider | Default model | Use for |
|
|
79
|
+
|----------|---------------|---------|
|
|
80
|
+
| `flux` | `flux-2-pro` | Default for normal text-to-image. High-quality general image generation; commonly returns signed URLs. |
|
|
81
|
+
| `gemini` | `gemini-3-pro-image` | Strong prompt adherence, image editing/remix. |
|
|
82
|
+
| `openai` | `gpt-image-2` | Photoreal output, explicit `size`/`quality`/`output_format`. |
|
|
83
|
+
|
|
84
|
+
Default to `flux` for normal text-to-image requests. Use `gemini` when the user
|
|
85
|
+
provides input images or wants image editing/remix. Use `openai` when the user
|
|
86
|
+
wants photoreal output or a specific size/quality.
|
|
87
|
+
|
|
88
|
+
## Response
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"provider": "gemini",
|
|
93
|
+
"model": "gemini-3-pro-image",
|
|
94
|
+
"images": [{ "b64_json": "<base64>", "mime_type": "image/png" }],
|
|
95
|
+
"billing": { "credits_charged": 12, "...": "..." }
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Each `images[]` entry has either `b64_json` or `url`, plus `mime_type`. Gemini
|
|
100
|
+
always returns `b64_json`. Flux commonly returns a signed `url`; download it to
|
|
101
|
+
your local image file immediately because signed URLs expire. If OpenAI returns a
|
|
102
|
+
`url`, download that URL instead of base64-decoding.
|
|
103
|
+
|
|
104
|
+
## Editing / remixing images
|
|
105
|
+
|
|
106
|
+
Pass source images in `input_images` as base64 **data URLs**
|
|
107
|
+
(`data:<mime>;base64,<data>`) and describe the edit in `prompt`. Gemini handles
|
|
108
|
+
multi-image edits well. To build a data URL from a local file:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
DATA_URL="data:image/png;base64,$(base64 < input.png | tr -d '\n')"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Notes
|
|
115
|
+
|
|
116
|
+
- **Billing**: every success charges credits; don't loop needlessly, and report
|
|
117
|
+
`credits_charged`.
|
|
118
|
+
- **Errors**: `402` = insufficient credits (`credits_required` in body); `400`/`500`
|
|
119
|
+
return `{ "message": "..." }` — surface it to the user.
|
|
120
|
+
- Only `flux`, `gemini`, and `openai` are supported here.
|
|
@@ -75,6 +75,14 @@ Load the `letta-api-client` skill for richer SDK examples.
|
|
|
75
75
|
## 1. Change permissions
|
|
76
76
|
|
|
77
77
|
Permissions decide which tool calls are allowed, denied, or require approval.
|
|
78
|
+
Use `alwaysAsk` when a rule should request human approval even in
|
|
79
|
+
`unrestricted`/yolo mode.
|
|
80
|
+
|
|
81
|
+
Settings `ask` rules request approval in normal permission modes, but they do
|
|
82
|
+
not override `unrestricted`/yolo mode. For a mod tool that must pause for human
|
|
83
|
+
approval even in unrestricted mode, set `approvalPolicy: "alwaysAsk"` in the
|
|
84
|
+
tool registration. For broader dynamic policy, use a mod permission overlay or
|
|
85
|
+
a blocking hook.
|
|
78
86
|
|
|
79
87
|
### Rule syntax
|
|
80
88
|
|
|
@@ -91,6 +99,15 @@ python3 <skill-dir>/scripts/add_permission.py \
|
|
|
91
99
|
--scope user
|
|
92
100
|
```
|
|
93
101
|
|
|
102
|
+
Force approval even in yolo mode:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python3 <skill-dir>/scripts/add_permission.py \
|
|
106
|
+
--rule "Bash(git push:*)" \
|
|
107
|
+
--type alwaysAsk \
|
|
108
|
+
--scope user
|
|
109
|
+
```
|
|
110
|
+
|
|
94
111
|
### Edit directly
|
|
95
112
|
|
|
96
113
|
```json
|
|
@@ -98,7 +115,8 @@ python3 <skill-dir>/scripts/add_permission.py \
|
|
|
98
115
|
"permissions": {
|
|
99
116
|
"allow": ["Bash(npm:*)", "Read(src/**)"],
|
|
100
117
|
"deny": ["Bash(rm -rf:*)"],
|
|
101
|
-
"ask": []
|
|
118
|
+
"ask": [],
|
|
119
|
+
"alwaysAsk": ["Bash(git push:*)"]
|
|
102
120
|
}
|
|
103
121
|
}
|
|
104
122
|
```
|
|
@@ -215,6 +233,7 @@ Find your own entry by matching `agentId === $LETTA_AGENT_ID`, then edit the fie
|
|
|
215
233
|
|------|----------------|
|
|
216
234
|
| Auto-approve curl | `add_permission.py --rule "Bash(curl:*)" --type allow --scope user` |
|
|
217
235
|
| Block `rm -rf` | Add `"Bash(rm -rf:*)"` to `permissions.deny`, or add a `PreToolUse` hook |
|
|
236
|
+
| Always ask before git push | `add_permission.py --rule "Bash(git push:*)" --type alwaysAsk --scope user` |
|
|
218
237
|
| Log all Bash calls | `add_hook.py --event PreToolUse --matcher Bash --type command --command '...' --scope user` |
|
|
219
238
|
| Auto-format after edits | `add_hook.py --event PostToolUse --matcher "Edit|Write" --type command --command '...' --scope project` |
|
|
220
239
|
| Gate edits with LLM | `add_hook.py --event PreToolUse --matcher "Edit|Write" --type prompt --prompt '...' --scope user` |
|
|
@@ -237,7 +256,7 @@ Find your own entry by matching `agentId === $LETTA_AGENT_ID`, then edit the fie
|
|
|
237
256
|
|
|
238
257
|
| Script | Purpose |
|
|
239
258
|
|--------|---------|
|
|
240
|
-
| `scripts/add_permission.py` | Add an allow/deny/ask rule to any scope |
|
|
259
|
+
| `scripts/add_permission.py` | Add an allow/deny/ask/alwaysAsk rule to any scope |
|
|
241
260
|
| `scripts/add_hook.py` | Add a command or prompt hook to any event |
|
|
242
261
|
| `scripts/show_config.py` | Show merged permissions, hooks, and per-agent settings across all scopes |
|
|
243
262
|
|
|
@@ -5,6 +5,7 @@ Add a permission rule to Letta Code settings.
|
|
|
5
5
|
Usage:
|
|
6
6
|
python3 add_permission.py --rule "Bash(npm run:*)" --type allow --scope user
|
|
7
7
|
python3 add_permission.py --rule "Read(src/**)" --type allow --scope project
|
|
8
|
+
python3 add_permission.py --rule "Bash(git push:*)" --type alwaysAsk --scope user
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
import argparse
|
|
@@ -99,7 +100,7 @@ def main():
|
|
|
99
100
|
parser.add_argument(
|
|
100
101
|
"--type",
|
|
101
102
|
required=True,
|
|
102
|
-
choices=["allow", "deny", "ask"],
|
|
103
|
+
choices=["allow", "deny", "ask", "alwaysAsk"],
|
|
103
104
|
help="Type of permission rule",
|
|
104
105
|
)
|
|
105
106
|
parser.add_argument(
|