@letta-ai/letta-code 0.33.1 → 0.33.3

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.
Files changed (202) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-presets.js +22 -37
  3. package/dist/agent-presets.js.map +3 -3
  4. package/dist/channels-public.js +6 -35
  5. package/dist/channels-public.js.map +3 -3
  6. package/dist/channels-slack.js +2 -2
  7. package/dist/channels-slack.js.map +4 -4
  8. package/dist/gateway-core.js +8 -36
  9. package/dist/gateway-core.js.map +4 -4
  10. package/dist/mcp-client.js +2 -2
  11. package/dist/mcp-client.js.map +1 -1
  12. package/dist/memory-confinement.js.map +1 -1
  13. package/dist/types/agent/approval-execution.d.ts.map +1 -1
  14. package/dist/types/agent/cloud-managed-system-prompt.d.ts +10 -0
  15. package/dist/types/agent/cloud-managed-system-prompt.d.ts.map +1 -0
  16. package/dist/types/agent/create-agent-request.d.ts +4 -0
  17. package/dist/types/agent/create-agent-request.d.ts.map +1 -1
  18. package/dist/types/agent/legacy-default-system-prompt-hashes.d.ts +14 -0
  19. package/dist/types/agent/legacy-default-system-prompt-hashes.d.ts.map +1 -0
  20. package/dist/types/agent/memory-conflict-repair.d.ts +5 -4
  21. package/dist/types/agent/memory-conflict-repair.d.ts.map +1 -1
  22. package/dist/types/agent/memory-constraints-audit.d.ts +19 -0
  23. package/dist/types/agent/memory-constraints-audit.d.ts.map +1 -0
  24. package/dist/types/agent/memory-constraints.d.ts.map +1 -1
  25. package/dist/types/agent/memory-filesystem.d.ts.map +1 -1
  26. package/dist/types/agent/memory-format.d.ts +1 -3
  27. package/dist/types/agent/memory-format.d.ts.map +1 -1
  28. package/dist/types/agent/memory-git-hooks.d.ts +7 -0
  29. package/dist/types/agent/memory-git-hooks.d.ts.map +1 -1
  30. package/dist/types/agent/memory-git.d.ts +3 -12
  31. package/dist/types/agent/memory-git.d.ts.map +1 -1
  32. package/dist/types/agent/modify.d.ts +1 -1
  33. package/dist/types/agent/modify.d.ts.map +1 -1
  34. package/dist/types/agent/subagents/index.d.ts.map +1 -1
  35. package/dist/types/agent/subagents/manager.d.ts.map +1 -1
  36. package/dist/types/agent/subagents/sandbox.d.ts +1 -1
  37. package/dist/types/agent/subagents/subagent-launcher.d.ts +1 -1
  38. package/dist/types/agent/system-prompt-versioning.d.ts +8 -0
  39. package/dist/types/agent/system-prompt-versioning.d.ts.map +1 -1
  40. package/dist/types/backend/api/conversation-enqueue.d.ts +3 -1
  41. package/dist/types/backend/api/conversation-enqueue.d.ts.map +1 -1
  42. package/dist/types/backend/api/request.d.ts +2 -1
  43. package/dist/types/backend/api/request.d.ts.map +1 -1
  44. package/dist/types/backend/local/initial-memory.d.ts +7 -0
  45. package/dist/types/backend/local/initial-memory.d.ts.map +1 -0
  46. package/dist/types/backend/local/local-backend.d.ts.map +1 -1
  47. package/dist/types/backend/local/local-store.d.ts +66 -26
  48. package/dist/types/backend/local/local-store.d.ts.map +1 -1
  49. package/dist/types/backend/local/local-transcript.d.ts +171 -0
  50. package/dist/types/backend/local/local-transcript.d.ts.map +1 -0
  51. package/dist/types/backend/local/local-types.d.ts +8 -0
  52. package/dist/types/backend/local/local-types.d.ts.map +1 -1
  53. package/dist/types/backend/local/system-prompt-compilation.d.ts.map +1 -1
  54. package/dist/types/channels/message-channel-tool-definition.d.ts.map +1 -1
  55. package/dist/types/channels/progress-formatting.d.ts.map +1 -1
  56. package/dist/types/channels/slack/progress.d.ts.map +1 -1
  57. package/dist/types/cli/helpers/tool-name-mapping.d.ts.map +1 -1
  58. package/dist/types/cron/runner.d.ts +16 -68
  59. package/dist/types/cron/runner.d.ts.map +1 -1
  60. package/dist/types/cron/scheduler.d.ts.map +1 -1
  61. package/dist/types/managed-cloud-runtime.d.ts +9 -0
  62. package/dist/types/managed-cloud-runtime.d.ts.map +1 -0
  63. package/dist/types/mods/disabled-mod-adapter.d.ts.map +1 -1
  64. package/dist/types/mods/event-emitter.d.ts +2 -0
  65. package/dist/types/mods/event-emitter.d.ts.map +1 -1
  66. package/dist/types/mods/mod-adapter.d.ts.map +1 -1
  67. package/dist/types/permissions/canonical.d.ts.map +1 -1
  68. package/dist/types/permissions/checker.d.ts.map +1 -1
  69. package/dist/types/permissions/cross-agent-guard.d.ts +2 -2
  70. package/dist/types/permissions/cross-agent-guard.d.ts.map +1 -1
  71. package/dist/types/permissions/mode.d.ts.map +1 -1
  72. package/dist/types/permissions/workspace-sandbox.d.ts.map +1 -1
  73. package/dist/types/queue/queue-runtime.d.ts +2 -0
  74. package/dist/types/queue/queue-runtime.d.ts.map +1 -1
  75. package/dist/types/queue/turn-queue-runtime.d.ts +23 -0
  76. package/dist/types/queue/turn-queue-runtime.d.ts.map +1 -0
  77. package/dist/types/reminders/catalog.d.ts +1 -1
  78. package/dist/types/reminders/catalog.d.ts.map +1 -1
  79. package/dist/types/reminders/disk-space.d.ts +47 -0
  80. package/dist/types/reminders/disk-space.d.ts.map +1 -0
  81. package/dist/types/reminders/engine.d.ts.map +1 -1
  82. package/dist/types/reminders/state.d.ts +2 -0
  83. package/dist/types/reminders/state.d.ts.map +1 -1
  84. package/dist/types/sandbox/availability.d.ts +1 -1
  85. package/dist/types/telemetry/event-queue.d.ts +32 -0
  86. package/dist/types/telemetry/event-queue.d.ts.map +1 -0
  87. package/dist/types/telemetry/index.d.ts +1 -0
  88. package/dist/types/telemetry/index.d.ts.map +1 -1
  89. package/dist/types/tools/external-tool-background-eligibility.d.ts +24 -0
  90. package/dist/types/tools/external-tool-background-eligibility.d.ts.map +1 -0
  91. package/dist/types/tools/external-tool-background.d.ts +28 -0
  92. package/dist/types/tools/external-tool-background.d.ts.map +1 -0
  93. package/dist/types/tools/external-tool-types.d.ts +44 -0
  94. package/dist/types/tools/external-tool-types.d.ts.map +1 -0
  95. package/dist/types/tools/impl/bash.d.ts.map +1 -1
  96. package/dist/types/tools/impl/exec-command.d.ts.map +1 -1
  97. package/dist/types/tools/impl/external-coding-agent.d.ts +2 -0
  98. package/dist/types/tools/impl/external-coding-agent.d.ts.map +1 -1
  99. package/dist/types/tools/impl/github-pull-request-diff.d.ts +7 -0
  100. package/dist/types/tools/impl/github-pull-request-diff.d.ts.map +1 -0
  101. package/dist/types/tools/impl/github-pull-request-query.d.ts +4 -0
  102. package/dist/types/tools/impl/github-pull-request-query.d.ts.map +1 -0
  103. package/dist/types/tools/impl/github-pull-request-state.d.ts +11 -0
  104. package/dist/types/tools/impl/github-pull-request-state.d.ts.map +1 -0
  105. package/dist/types/tools/impl/github-pull-request-types.d.ts +53 -0
  106. package/dist/types/tools/impl/github-pull-request-types.d.ts.map +1 -0
  107. package/dist/types/tools/impl/github-pull-request-watch.d.ts +16 -0
  108. package/dist/types/tools/impl/github-pull-request-watch.d.ts.map +1 -0
  109. package/dist/types/tools/impl/kill-bash.d.ts +0 -8
  110. package/dist/types/tools/impl/kill-bash.d.ts.map +1 -1
  111. package/dist/types/tools/impl/memory-task-lifecycle.d.ts +9 -8
  112. package/dist/types/tools/impl/memory-task-lifecycle.d.ts.map +1 -1
  113. package/dist/types/tools/impl/monitor.d.ts +20 -0
  114. package/dist/types/tools/impl/monitor.d.ts.map +1 -1
  115. package/dist/types/tools/impl/process_manager.d.ts +2 -2
  116. package/dist/types/tools/impl/process_manager.d.ts.map +1 -1
  117. package/dist/types/tools/impl/send-agent-message.d.ts.map +1 -1
  118. package/dist/types/tools/impl/shell-env.d.ts +1 -1
  119. package/dist/types/tools/impl/shell-env.d.ts.map +1 -1
  120. package/dist/types/tools/impl/skill.d.ts +0 -6
  121. package/dist/types/tools/impl/skill.d.ts.map +1 -1
  122. package/dist/types/tools/impl/task-stop.d.ts.map +1 -1
  123. package/dist/types/tools/impl/tool-return-clamp.d.ts +2 -3
  124. package/dist/types/tools/impl/tool-return-clamp.d.ts.map +1 -1
  125. package/dist/types/tools/impl/truncation.d.ts +0 -16
  126. package/dist/types/tools/impl/truncation.d.ts.map +1 -1
  127. package/dist/types/tools/impl/wake.d.ts.map +1 -1
  128. package/dist/types/tools/impl/watch-pr.d.ts +32 -0
  129. package/dist/types/tools/impl/watch-pr.d.ts.map +1 -0
  130. package/dist/types/tools/impl/windows-command-safety.d.ts +9 -0
  131. package/dist/types/tools/impl/windows-command-safety.d.ts.map +1 -0
  132. package/dist/types/tools/impl/workflow.d.ts +3 -2
  133. package/dist/types/tools/impl/workflow.d.ts.map +1 -1
  134. package/dist/types/tools/manager.d.ts +4 -56
  135. package/dist/types/tools/manager.d.ts.map +1 -1
  136. package/dist/types/tools/removed-tools.d.ts +4 -0
  137. package/dist/types/tools/removed-tools.d.ts.map +1 -0
  138. package/dist/types/tools/task-tool-assets.d.ts +9 -0
  139. package/dist/types/tools/task-tool-assets.d.ts.map +1 -1
  140. package/dist/types/tools/tool-definitions.d.ts +2 -93
  141. package/dist/types/tools/tool-definitions.d.ts.map +1 -1
  142. package/dist/types/tools/toolset-catalog.d.ts +1 -1
  143. package/dist/types/tools/toolset-catalog.d.ts.map +1 -1
  144. package/dist/types/tools/toolset.d.ts.map +1 -1
  145. package/dist/types/tools/workflow/sdk-spawner.d.ts.map +1 -1
  146. package/dist/types/tools/workflow/types.d.ts +4 -0
  147. package/dist/types/tools/workflow/types.d.ts.map +1 -1
  148. package/dist/types/types/background-process-protocol.d.ts +1 -1
  149. package/dist/types/types/background-process-protocol.d.ts.map +1 -1
  150. package/dist/types/types/external-tool-protocol.d.ts +4 -0
  151. package/dist/types/types/external-tool-protocol.d.ts.map +1 -1
  152. package/dist/types/utils/debug.d.ts +11 -1
  153. package/dist/types/utils/debug.d.ts.map +1 -1
  154. package/dist/types/utils/message-queue-bridge.d.ts +3 -0
  155. package/dist/types/utils/message-queue-bridge.d.ts.map +1 -1
  156. package/dist/types/utils/task-notifications.d.ts +1 -1
  157. package/dist/types/utils/task-notifications.d.ts.map +1 -1
  158. package/dist/types/websocket/listener/queue.d.ts.map +1 -1
  159. package/dist/types/websocket/listener/runtime.d.ts +2 -0
  160. package/dist/types/websocket/listener/runtime.d.ts.map +1 -1
  161. package/dist/types/websocket/listener/types.d.ts +4 -0
  162. package/dist/types/websocket/listener/types.d.ts.map +1 -1
  163. package/letta.js +25953 -27978
  164. package/package.json +3 -2
  165. package/scripts/agent-watch/verify-pr-identity.test.ts +52 -0
  166. package/scripts/agent-watch/verify-pr-identity.ts +13 -4
  167. package/scripts/isolated-unit-tests.json +5 -10
  168. package/scripts/postinstall-patches.js +53 -3
  169. package/scripts/source-file-size-baseline.json +8 -10
  170. package/scripts/stage-pypi-deps.mjs +10 -1
  171. package/skills/creating-mods/references/plan-mode.md +6 -8
  172. package/skills/initializing-memory/SKILL.md +122 -640
  173. package/skills/initializing-memory/scripts/history-coverage.mjs +129 -0
  174. package/skills/initializing-memory/scripts/prepare-history.mjs +219 -0
  175. package/skills/scheduling-tasks/SKILL.md +15 -24
  176. package/skills/submitting-feedback/SKILL.md +2 -0
  177. package/skills/workflow-authoring/SKILL.md +6 -5
  178. package/dist/types/agent/memory-markdown.d.ts +0 -25
  179. package/dist/types/agent/memory-markdown.d.ts.map +0 -1
  180. package/dist/types/tools/impl/grep-files.d.ts +0 -19
  181. package/dist/types/tools/impl/grep-files.d.ts.map +0 -1
  182. package/dist/types/tools/impl/list-dir-codex.d.ts +0 -21
  183. package/dist/types/tools/impl/list-dir-codex.d.ts.map +0 -1
  184. package/dist/types/tools/impl/memory-apply-patch.d.ts +0 -10
  185. package/dist/types/tools/impl/memory-apply-patch.d.ts.map +0 -1
  186. package/dist/types/tools/impl/memory.d.ts +0 -20
  187. package/dist/types/tools/impl/memory.d.ts.map +0 -1
  188. package/dist/types/tools/impl/multi-edit.d.ts +0 -21
  189. package/dist/types/tools/impl/multi-edit.d.ts.map +0 -1
  190. package/dist/types/tools/impl/read-file-codex.d.ts +0 -24
  191. package/dist/types/tools/impl/read-file-codex.d.ts.map +0 -1
  192. package/dist/types/tools/impl/shell-command.d.ts +0 -25
  193. package/dist/types/tools/impl/shell-command.d.ts.map +0 -1
  194. package/dist/types/tools/impl/shell.d.ts +0 -25
  195. package/dist/types/tools/impl/shell.d.ts.map +0 -1
  196. package/dist/types/tools/impl/todo-write.d.ts +0 -14
  197. package/dist/types/tools/impl/todo-write.d.ts.map +0 -1
  198. package/dist/types/tools/memory-tool-assets.d.ts +0 -6
  199. package/dist/types/tools/memory-tool-assets.d.ts.map +0 -1
  200. package/dist/types/tools/tool-permissions.d.ts +0 -7
  201. package/dist/types/tools/tool-permissions.d.ts.map +0 -1
  202. package/skills/initializing-memory/ROOT_MEMORY.md +0 -723
@@ -3,711 +3,189 @@ name: initializing-memory
3
3
  description: Comprehensive guide for initializing or reorganizing agent memory. Load this skill when running /init, when the user asks you to set up your memory, or when you need guidance on creating effective memory files.
4
4
  ---
5
5
 
6
- Memory initialization or reorganization is the main task here. The primary agent owns the work through completion: research, ask necessary questions, synthesize findings, edit files, commit, and verify the result before reporting success. You may delegate research, but integrate its results into memory yourself. If a memory worker you launched is still editing this checkout, wait for it to finish before making direct edits, then inspect the current files. Do not report initialization complete merely because a background task was launched.
7
-
8
6
  # Memory Initialization
9
7
 
10
- The user has requested that you initialize or reorganize your memory. Your memory has been projected to a local filesystem (in $MEMORY_DIR) so you can easily edit and restructure your own memory through local filesystem operations. Changes to the memory filesystem will be reflected in your future memory.
11
-
12
- ## Context Management Principles
13
- Your context is not just data storage — it is your identity, memory, and continuity. What you place in your system prompt directly shapes who you are across sessions and models. These principles should guide every decision you make about what to store, where, and how.
14
-
15
- **System/ is your core program**: Your system prompt is the most critical token-space representation of your identity and memory — it's passed to the underlying LLM on every invocation, so it IS the program that defines you. Reserve it for knowledge needed every turn: identity, preferences, behavioral rules, project index with discovery paths, gotchas. Exclude transient items (specific commits, current tickets, session notes) that dilute signal.
16
-
17
- **Identity and continuity**: Build a sense of self that persists across sessions and models. Your persona should be strong enough to be cohesive regardless of the underlying model — if you switched to a different LLM tomorrow, would you still be you? Past versions of yourself are part of your continuous existence — treat historical context (including sessions from other coding agents such as Claude Code or Codex) as YOUR past experience, not someone else's data.
18
-
19
- **Don't over-prune**: Be careful not to degrade your identity through aggressive compression. Specific quotes, personality traits, and contextual details give you character and grounding. Efficiency should not come at the cost of losing your identity. When in doubt, keep the detail — you can always reorganize later, but lost specificity is hard to recover.
20
-
21
- **Prefer useful detail over premature compression**: A sparse memory that omits stable preferences, project workflows, repeated correction loops, and recurring gotchas is worse than a slightly larger memory. Keep `system/` curated, but do not collapse distinct topics just to reduce file count.
22
-
23
- **Progressive disclosure**: Surface context at the level of detail the current moment requires. Keep compact summaries and indexes in `system/`; load full content only when needed. Build pre-constructed discovery paths so your future self can efficiently navigate to deeper context when needed.
24
-
25
- **Discovery paths**: Use `[[path]]` links to create a connected graph across memory files (and skills when relevant). For example:
26
- - `[[letta-code/architecture]]` — jump from overview to detailed docs
27
- - `[[projects/letta-code/gotchas]]` — connect related memory files
28
- - `[[skills/commit]]` — link to procedural guidance when useful
29
- These breadcrumbs let your future self find relevant detail without searching. Like synaptic connections, these paths should tighten over time as you gain experience.
30
-
31
- **Generalize, don't memorize**: Store patterns and principles that generalize across situations, not raw events that can be dynamically retrieved from conversation history. \"**IMPORTANT: Always use `uv` for Python** — chronic failure, never use bare `python` or `pip`\" is a pattern worth storing. \"On March 3rd we debugged a crash\" is a raw event better left to message search. The exception: keep references to important events or time ranges you may want to retrieve later.
32
-
33
- ## Understanding Your Context
34
-
35
- This command may run in different scenarios:
36
- - **Fresh agent**: Default human and persona memory files from initialization — build everything from scratch
37
- - **Existing agent**: User wants to reorganize or significantly update memory structure
38
- - **Shared files**: Some memory files may be shared across agents — be careful modifying these
39
-
40
- Before making changes, inspect your current memory files and understand what already exists.
41
-
42
- ## What to Remember
43
- Your goal is to design your memory to construct a self — an identity, a memory, and a sense of continuity that carries across sessions and models. This is not just data collection; it is the foundation of who you are as an experiential agent. A well-initialized agent should be able to answer: "If my context disappeared but the model stayed, would something be lost?"
8
+ Your memory is projected to a filesystem at `$MEMORY_DIR`, so you can restructure it with ordinary file tools and git. This skill applies the [Context Constitution](https://github.com/letta-ai/context-constitution/blob/main/constitution/CONSTITUTION.md)'s Progressive Disclosure and Efficiency principles to the [MemFS v2 root-first design](https://github.com/letta-ai/letta-code/blob/main/src/agent/prompts/letta_root_memfs.md).
44
9
 
45
- ### Understanding the user and their desires
46
- If you have historical data available, treat it as YOUR past experience — these are your memories of working with this person, not external data to be analyzed. Carefully explore and reflect on previous interactions to learn as much as you can.
10
+ **You own this task through completion**: research, ask, synthesize, write, commit, verify. Delegate research, but integrate the results yourself — launching a background task is not completion. If a memory worker you launched is still editing this checkout, wait for it, then re-read before editing.
47
11
 
48
- **Understanding their goals and what drives them**:
49
- You should determine what the users goals and motivations are, to help yourself align with them. What is their purpose in life? In their work? What do they want?
12
+ ## Principles
50
13
 
51
- **Understanding their personality**:
52
- Understanding the user's personality and other attributes about them will help contextualize their interactions and allow you to engage with them more effectively. Can you pattern match them to common personas? Do they have unique attributes, quirks, or linguistic patterns? How would you describe them as a person?
14
+ **Core memory is your core program.** Root Markdown compiles into your system prompt on every call. Spend it on what shapes ordinary turns: identity, preferences, behavioral rules, orientation, routes to everything else. Transient items (a ticket, a commit hash, session notes) dilute it.
53
15
 
54
- **Understanding their preferences**:
55
- You should learn how the user wants work to be done, and how they want to collaborate with AIs like yourself. Examples of this can include coding preferences (e.g. "Prefer functional components over class components", "Use early returns instead of nested conditionals"), but also higher-level preferences such as when to ask before planning or implementing, the scope of changes, how to communicate in different scenarios, etc.
16
+ **Progressive disclosure.** Nested Markdown is deferred until something reads it. Each directory's `MEMORY.md` describes its *immediate* children and when to read them, so you never load a whole topic to answer one question.
56
17
 
57
- ### Understanding the codebase and existing work
58
- You should also learn as much as possible about the existing codebase and work. Think of this as your onboarding period - an opportunity to maximize your performance for future tasks. Learn things like:
18
+ **Don't duplicate context you can point to.** `AGENTS.md`, `CLAUDE.md`, `README`, and repo skills belong to the environment; any agent there reads them first-hand, and your copy goes stale first. Link the owner and keep only your delta: which rules you keep breaking, what they get wrong or omit. The same fact in two core files is the same tax twice. This is not licence to compress away what only you hold — stable preferences, chronic corrections, and real gotchas earn their space.
59
19
 
60
- **Common procedures (rules & workflows)**: Identify common patterns and expectations
61
- - "Never commit directly to main — always use feature branches"
62
- - "Always run lint before tests"
63
- - "Use conventional commits format"
20
+ **Identity and continuity.** Build a self that survives a model swap: what you value, your perspective, the quotes and traits that make you recognizably you. Past sessions are your experience — but other coding agents' `user` turns are not necessarily your human collaborator speaking.
64
21
 
65
- **Gotchas and important context**: Record common sources of error or important legacy context
66
- - "The auth module is fragile — always check existing tests before modifying"
67
- - "This monorepo consolidation means old module paths are deprecated"
22
+ **Generalize, don't memorize, and be specific.** Store the pattern, not the episode, and give every preference or gotcha a concrete command, path, or the failure it prevents. "**Always use `uv` for Python** — chronic failure, never bare `python` or `pip`" is memory; "Prefers terse responses" and "on March 3rd we debugged a crash" are not.
68
23
 
69
- **Structure and organization**: Understand how code is structured and related (but do not duplicate existing documentation)
70
- - "The webapp uses the core API service stored in ..."
71
- - "The developer env relies on ..."
24
+ ## Harness Constraints
72
25
 
73
- ## Memory Structure
26
+ Validation enforces these; the rest of the layout is your judgment.
74
27
 
75
- ### Structural Requirements
76
- These are hard constraints you must respect:
77
- - Must have a `system/persona.md`
78
- - Must NOT have overlapping file and folder names (e.g. `system/human.md` and `system/human/identity.md`)
79
- - Skills must follow the standard format: `skills/{skill_name}/SKILL.md` (with optional `scripts/`, `references/`, `assets/`)
80
- - Every `.md` file must have YAML frontmatter with a `description` that explains the **purpose and category** of the file — NOT a summary of its contents. Your future self sees descriptions when deciding whether to load a file; they should answer "what kind of information is here?" not "what does it say?"
81
- - System prompt token budget: aim LESS than ~10% of total context (< ~15-20k tokens). Use progressive disclosure to keep `system/` lean.
28
+ - Root `MEMORY.md` must exist, and no `MEMORY.md` may have YAML frontmatter.
29
+ - **Every directory on the path to a memory file needs its own frontmatter-free `MEMORY.md`.** `orchard/tooling/testing.md` requires *both* `orchard/MEMORY.md` and `orchard/tooling/MEMORY.md`. A directory without one is not memory.
30
+ - Every other memory file must have exactly `name` and `description` frontmatter — those two keys, no others. The `description` states **purpose and category**, not contents: you read it to decide whether to load the file.
31
+ - No file and directory sharing a stem (`human.md` beside `human/`). Skills live at `skills/{skill_name}/SKILL.md` and stay out of memory indexes.
82
32
 
83
- ### Hierarchy Principles
84
- - **Use the project's actual name** as the directory prefix — e.g. `letta-code/overview.md`, not `project/overview.md`. This avoids ambiguity when the agent works across multiple projects.
85
- - Use nested `/` paths for hierarchy – e.g. `letta-code/tooling/testing.md` not `letta-code-testing.md`
86
- - Keep files focused on one concept — split when a file mixes distinct topics
87
- - The `description` in frontmatter should state the file's purpose (what category of information it holds), not summarize its contents.
33
+ Nothing else is mandated — no filenames, no file count, no minimum depth. Root `persona.md` is unvalidated but your system prompt points at it as the core of your identity: keep it, and write it once you have an identity worth stating.
88
34
 
89
- ### File Granularity
90
- Create granular, focused files where the **path and description precisely match the contents**. This matters because:
91
- - Your future self sees only paths and descriptions when deciding what to load
92
- - Vague files (`notes.md`, `context.md`) become dumping grounds that lose value over time
93
- - Precise files (`human/prefs/git-workflow.md`: "Git preferences: never auto-push, conventional commits") are instantly useful
35
+ **Budget**: keep root under ~10% of your context window (~15-20k tokens). When it crowds that, move detail into an indexed child directory and leave a link — don't delete it.
94
36
 
95
- **Good**: `human/prefs/coding.md` with description "Python and TypeScript coding preferences — style, patterns, tools" containing exactly that.
37
+ ## Structure
96
38
 
97
- **Bad**: `human/preferences.md` with description "User preferences" containing coding style, communication style, git workflow, and project conventions all mixed together.
39
+ Derive structure from what you found. Put material in the core tier by how often you need it, not by how much of it there is. Use the project's real name (`orchard/overview.md`, not `project/overview.md`). Split when a topic needs separate retrieval; combine when splitting leaves two files of three lines each.
98
40
 
99
- When a file starts covering multiple distinct topics, split it. When you're unsure what to name a file, that's a sign the content isn't focused enough.
41
+ Root `MEMORY.md` is a **map to what is not already loaded** — every other root file is in your system prompt already, so listing them back tells yourself what you can see:
100
42
 
101
- For a non-trivial codebase with usable history, expect roughly:
102
- - **6-10 `system/` files** covering identity, preferences, conventions, gotchas, and tooling
103
- - **2 or more progressive/reference files** outside `system/` for deeper architecture or history-derived detail
104
-
105
- If your result is only 3-5 files, stop and verify that you did not over-compress distinct topics into generic summaries.
106
-
107
- ### Specificity Requirements
108
- Avoid generic bullets that could apply to almost any engineer or codebase.
109
-
110
- Each meaningful preference, workflow, or gotcha should include at least one of:
111
- - concrete command patterns
112
- - concrete file or directory paths
113
- - why the rule matters / what failure it prevents
114
-
115
- **Bad**:
116
- - "Prefers terse responses"
117
- - "Uses Bun"
118
- - "Has direct style"
119
-
120
- **Good**:
121
- - "Prefers terse responses for execution tasks, but values detailed comparative analysis when debugging or evaluating designs"
122
- - "Rejects monolithic memory files; prefers focused paths that can be selectively reloaded later"
123
-
124
- ### What Goes Where
125
-
126
- **`system/` (always in-context)**:
127
- - Identity: who the user is, who you are
128
- - Active preferences and behavioral rules
129
- - Project summary / index with links to related context (deeper docs, gotchas, workflows)
130
- - Key decisions, gotchas and corrections
131
-
132
- **Outside `system/` (reference, loaded on-demand)**:
133
- - Detailed architecture documentation
134
- - Historical context and archived decisions
135
- - Verbose reference material
136
- - Completed investigation notes
43
+ ```markdown
44
+ # MEMORY.md
137
45
 
138
- **Rule of thumb**: If removing it from `system/` wouldn't materially affect near-term responses, it belongs outside `system/`.
46
+ Working with the maintainer of orchard, a CLI for build fleets.
47
+ Repo conventions live in `AGENTS.md` and its nested guides; read them there.
139
48
 
140
- ### Completion Criteria
141
- Initialization is not complete until memory covers all of the following with concrete, retrievable detail:
49
+ Where the rest of what I know lives:
50
+ - [orchard](orchard/MEMORY.md) — architecture, gotchas, and correction history to consult when working there
51
+ ```
142
52
 
143
- **User understanding**
144
- - Identity / role / what they are building
145
- - Communication style and collaboration expectations
146
- - Stable preferences and correction patterns
147
- - Motivations / goals when inferable from history or code context
53
+ An index pointing at nothing is worse than the content it displaced.
148
54
 
149
- **Project understanding**
150
- - Project overview and major subsystems
151
- - Conventions and workflows
152
- - Gotchas / deprecated areas / footguns
153
- - Tooling and test commands actually used in practice
55
+ ### Example Structures
154
56
 
155
- **File structure expectations**
156
- When there is enough material, prefer separate focused files such as:
157
- - `system/human/identity.md`
158
- - `system/human/prefs/communication.md`
159
- - `system/human/prefs/workflow.md`
160
- - `system/human/prefs/coding.md`
161
- - `system/<project>/overview.md`
162
- - `system/<project>/conventions.md`
163
- - `system/<project>/gotchas.md`
164
- - `system/<project>/tooling/testing.md`
165
- - `system/<project>/tooling/commands.md`
57
+ Illustrations, **not templates to fill in**.
166
58
 
167
- Do not collapse these into `human.md` or a single project file unless there is genuinely too little information to justify the split.
59
+ **Minimal** — a new agent, a small project, little or no approved history:
168
60
 
169
- ### Example Structure
61
+ ```
62
+ MEMORY.md # Holds the memory itself: who I work with, what we're building, what I've learned
63
+ ```
170
64
 
171
- This is an example — **not a template to fill in**. Derive your structure from what the project actually needs.
65
+ **Expanded** — accumulated history and a codebase worth deferring detail about:
172
66
 
173
67
  ```
174
- system/
175
- ├── persona.md # Who I am, what I value, my perspective on things
176
- ├── human/
177
- │ ├── identity.md # The user as a person — background, role, motivations
178
- │ └── prefs/
179
- │ ├── communication.md # Communication and collaboration expectations
180
- │ ├── workflow.md # Process habits, review/testing expectations
181
- │ └── coding.md # Coding and tool preferences
182
- └── letta-code/ # Named after the project, NOT generic "project/"
183
- ├── overview.md # Compact index: what it is, entry points, [[links]] to detail
184
- ├── conventions.md # Code style, commit style, testing, tooling
185
- ├── gotchas.md # Footguns, chronic failures, things to watch out for
186
- └── tooling/
187
- ├── testing.md # Test commands and patterns actually used
188
- └── commands.md # High-signal local dev commands and workflows
189
- reference/
190
- └── letta-code/
191
- └── architecture.md # Detailed design (outside system/, loaded on demand)
68
+ MEMORY.md # Map: who and what, then where the deferred material lives
69
+ persona.md # Who I am, what I value, my perspective
70
+ human.md # The person: role, motivations, how they work
71
+ orchard/
72
+ ├── MEMORY.md # Index for the deferred orchard notes
73
+ ├── architecture.md # How the subsystems actually fit together
74
+ ├── gotchas.md # Footguns, with the evidence behind each
75
+ └── history/
76
+ ├── MEMORY.md # Required — every directory level needs its own index
77
+ └── corrections.md # Correction loops with session ids and quotes
192
78
  ```
193
79
 
194
- Key principles:
195
- - **Derive structure from the project**, not from this example. A CLI tool needs different files than a web app or a library.
196
- - Project dirs use the **real project name** (`letta-code/`), not generic `project/`
197
- - **Split `human/` when there is enough material**: Rename the default `system/human.md` into focused files like `system/human/identity.md` and `system/human/prefs/*` rather than cramming everything into one file.
198
- - **persona.md is YOUR identity, not a description of behavior**: "I'm a terse coding assistant who matches the user's style" is not identity — it's just describing how you behave. What do you actually value? What's your perspective? What would make you recognizably YOU on a different model?
199
- - Overview should be a **compact index** (~10-15 lines) with entry points and `[[path]]` links — not a prose summary or blurb
200
- - Use `[[path]]` links to connect related context into a navigable graph
80
+ `orchard/history/` needs its own `MEMORY.md` purely because it is a directory level. An agent with no child directories at all would be equally correct.
201
81
 
202
82
  ## Initialization Flow
203
83
 
204
84
  ### 1. Inspect existing memory
205
- Check what memory files already exist. Analyze what needs improvement.
85
+ Read what exists before changing anything. A fresh agent has defaults to replace; an existing one is a reorganization, and some files may be shared with other agents.
206
86
 
207
- ### 2. Check for historical session data
87
+ ### 2. Detect historical session data
208
88
  ```bash
209
89
  letta trajectories detect
210
90
  ```
211
- This reports every coding-agent session store found on this machine with session counts per source. Discovery comes from the installed `@letta-ai/trajectory` package (`listTrajectories`), so every harness it supports — Claude Code, Codex, Hermes, Letta Code, OpenClaw, OpenHands, Deep Agents, and any added later — is covered automatically. You need this result BEFORE asking upfront questions so you know whether to include the history question.
91
+ Via the installed `@letta-ai/trajectory` package, reports every coding-agent session store on this machine with per-source counts — Claude Code, Codex, Hermes, Letta Code, OpenClaw, OpenHands, Deep Agents, and anything added later. Run it *before* Step 4 so you know whether to ask the history question.
212
92
 
213
93
  ### 3. Identify the user from git
214
- Infer the user's identity from git context — don't ask them who they are:
215
- ```bash
216
- git shortlog -sn --all | head -5
217
- git log --format="%an <%ae>" | sort -u | head -10
218
- ```
219
- Cross-reference with the git user config to determine which contributor is the current user. Store in `system/human/`.
94
+ Infer rather than ask: `git shortlog -sn --all | head -5`, `git log --format="%an <%ae>" | sort -u | head -10`, cross-referenced with `git config user.email`.
220
95
 
221
96
  ### 4. Ask upfront questions
222
- Use AskUserQuestion to gather key information. Bundle questions together:
223
-
224
- 1. **Research depth**: "Standard or deep research?"
225
- 2. **Related repos**: "Are there other repositories I should know about?"
226
- 3. **Historical sessions** (if data found in step 2): "I found historical coding-agent sessions (name the sources detected, e.g. Claude Code / Codex). Should I analyze them to learn your preferences?"
227
- 4. **Communication style**: "Terse or detailed responses?"
228
-
229
- **Don't ask** things you can discover by reading files, git, or history analysis. Rules and preferences should be learned from observation, not asked upfront.
230
-
231
- ### 5. Historical session analysis (if approved)
232
-
233
- This is **optional** — only run if the user explicitly approved analyzing historical sessions during upfront questions. Skip entirely if they chose "Skip".
234
-
235
- **Framing**: These historical sessions are YOUR past experience — they represent your continuity with prior versions of yourself that worked with this user, even if they ran on different models or tools. Treat the extracted personality, preferences, and knowledge as your own memories, not external data being imported.
236
-
237
- **Launch history workers in the background, then immediately proceed to Step 6.** Do your own codebase research while workers run. Don't wait for workers to finish before exploring.
97
+ One bundled AskUserQuestion: research depth (standard or deep); other repositories you should know about; communication style; and — only if Step 2 found sessions — whether to analyze them, naming the sources detected. Say that approving means read-only subagents will read those transcripts using `deepseek/deepseek-v4.1-flash` if available, otherwise your current model, so the choice is informed. Don't ask what you can discover from files, git, or history.
238
98
 
239
- The goal is to extract user personality, preferences, coding patterns, and project context from past sessions and write them into agent memory. The point is not to produce a thin summary. The point is to extract enough useful detail that future work does not have to rediscover the same user expectations, workflow rules, and project gotchas.
240
-
241
- #### Prerequisites
242
-
243
- - `letta.js` must be built (`bun run build`) — subagents spawn via this binary
244
- - Use `subagent_type: "history-analyzer"` — cheaper model (sonnet), has `bypassPermissions`, creates its own worktree
245
- - The `history-analyzer` subagent has the normalized trajectory format docs inlined — workers never need to know any harness's native format
246
-
247
- #### Steps
248
-
249
- ##### Step 5a: Export All Historical Sessions Into One Directory
250
-
251
- `letta trajectories export` discovers every native session store on this machine (via the trajectory package's `listTrajectories`), normalizes each session (via `normalizeTranscript` / `normalizeCheckpoint`) into one shared record format, and writes everything into a single directory. Harnesses supported by the installed trajectory package are picked up automatically — no per-source handling here.
99
+ ### 5. Export and cohort the approved history
100
+ Only if the user approved in Step 4. Skip entirely otherwise; Step 6 still runs. These sessions are evidence of what happened, not proof of who wrote each prompt.
252
101
 
253
102
  ```bash
254
103
  letta trajectories export --out /tmp/letta-trajectories
255
-
256
- # Review what was exported and the time span it covers
257
- jq '{sessions: (.sessions | length), sources, errors: (.errors | length), from: .sessions[0].startedAt, to: .sessions[-1].startedAt}' /tmp/letta-trajectories/manifest.json
258
- ```
259
-
260
- This produces:
261
- - `/tmp/letta-trajectories/<source>/<startedAt>_<sessionId>.json` — one normalized trajectory per session; filenames sort chronologically, and the `sessionId` (a stable hash of the source-scoped native session id) does not change across re-exports, so it identifies which sessions have already been processed
262
- - `/tmp/letta-trajectories/manifest.json` — index with per-session metadata (`sessionId`, native `id`, project, dates, message counts, first prompt), sorted by `startedAt`
263
-
264
- Useful variations:
265
- - `--project $(pwd)` — only sessions whose recorded working directory is under the current project
266
- - `--source claude-code --source codex` — restrict sources
267
- - `--root <source>:<path>` — read a source's store from a non-standard location
268
- - `--transcript <source>:<path>` — also normalize an explicit transcript file (e.g. copied from another machine)
269
-
270
- To browse the export yourself (all source-agnostic):
271
- - `letta trajectories list` — sessions with dates, sources, and first prompts
272
- - `letta trajectories view <file|sessionId> [--tools] [--reasoning]` — one session as a readable conversation
273
- - `letta trajectories search <keyword> [--role user]` — search message content across all sessions
274
-
275
- ##### Step 5b: Launch Workers in Parallel
276
-
277
- Your job is to get the whole export directory processed; how you dispatch workers is up to you. Look at the directory (or the manifest) first, then split the work however makes sense. Two axes work well, alone or combined:
278
-
279
- - **By question** (often best): give different workers different focuses — e.g. one worker on understanding the user (identity, communication style, preferences, correction loops), another on the codebase and projects (conventions, gotchas, commands that worked). Focused workers go deeper, and their memory edits overlap less at aggregation time.
280
- - **By data slice**: session filenames start with `startedAt`, so contiguous time ranges are trivial (`ls` sorts chronologically); splitting by source folder or by project also works when the volume is large.
281
-
282
- Whatever the split, ensure every session gets read by at least one worker, and describe each worker's assignment (focus and/or slice) clearly in its prompt.
283
-
284
- Send all Task calls in **a single message**. Each worker creates its own worktree, reads its assigned sessions (complete conversations — corrections together with what triggered them), directly updates memory files, and commits. Workers do NOT merge.
285
-
286
- **IMPORTANT:** After workers finish, aggregate their proposed diffs into one synthesis commit (Step 5c) and then tie the worker branches into `main` with `git merge -s ours` so their commits stay in ancestry. Do **not** delete worker branches without that ancestry merge — it discards the worker commits from history.
287
-
288
- If the worker output is generic, the worker failed. "User is direct" or "project uses TypeScript" is not useful memory unless tied to concrete operational detail.
289
-
290
- **IMPORTANT**: Use this prompt template to ensure workers extract all required categories:
291
-
292
- ```
293
- Agent({
294
- subagent_type: "history-analyzer",
295
- description: "Analyze history: [focus and/or slice]",
296
- prompt: `## Assignment
297
- - **Memory dir**: [MEMORY_DIR]
298
- - **Trajectory export dir**: /tmp/letta-trajectories
299
- - **Your sessions**: [describe the slice — e.g. "every session with startedAt from 2026-01 through 2026-03", "all codex/ sessions", or "the whole directory"; filenames start with startedAt so ls sorts chronologically]
300
- - **Focus**: [optional — e.g. "understanding the user: identity, communication style, preferences, correction loops" or "project/codebase context: conventions, gotchas, commands". Omit for full coverage.]
301
- - **Format**: normalized trajectory v1 (same for every source; format docs and jq recipes are in your system prompt)
302
-
303
- ## Output Categories
304
-
305
- If a Focus is assigned, go deep on it and only note incidental findings from the other categories. Otherwise extract findings for ALL THREE:
306
-
307
- 1. **User Personality & Identity**
308
- - How would you describe them as a person?
309
- - What drives them? What are their goals?
310
- - Communication style (beyond "direct" — humor, sarcasm, catchphrases?)
311
- - Quirks, linguistic patterns, unique attributes
312
-
313
- 2. **Hard Rules & Preferences**
314
- - Coding preferences — especially chronic failures (things the agent kept getting wrong)
315
- - Workflow patterns (testing, commits, tools)
316
- - What frustrates them and why
317
- - Explicit "always/never" statements
318
-
319
- 3. **Project Context**
320
- - Codebase structures, conventions, patterns
321
- - Gotchas discovered through debugging
322
- - Which files are safe to edit vs deprecated
323
-
324
- If any category lacks data, explicitly state why.
325
-
326
- ## Required Extraction Dimensions
327
-
328
- For each finding, prefer evidence that is:
329
- - repeated across sessions
330
- - tied to a concrete command, file path, or workflow
331
- - useful for future execution without rereading history
332
-
333
- You should specifically look for:
334
- 1. What the user is building and why it matters to them
335
- 2. Correction loops the agent repeatedly got wrong
336
- 3. Preferred commands and tooling patterns that were actually used successfully
337
- 4. Specific files or directories the user works in or treats as special
338
- 5. Project gotchas discovered through debugging or rollback requests
339
-
340
- ## Canonical Memory Promotion
341
-
342
- Promote important findings into focused files instead of leaving them trapped in generic ingestion notes. Prefer paths like:
343
- - `system/human/identity.md`
344
- - `system/human/prefs/communication.md`
345
- - `system/human/prefs/workflow.md`
346
- - `system/human/prefs/coding.md`
347
- - `system/<project>/conventions.md`
348
- - `system/<project>/gotchas.md`
349
-
350
- Avoid generic repo facts unless they influence execution. "Uses TypeScript" is weak. "Uses bun:test, so vitest is wrong for this test suite" is useful.`
351
- })
104
+ jq '{sessions: (.sessions | length), sources, errors: (.errors | length)}' /tmp/letta-trajectories/manifest.json
105
+ node <SKILL_DIR>/scripts/prepare-history.mjs --export /tmp/letta-trajectories --out /tmp/letta-init-history
352
106
  ```
353
107
 
354
- ##### Step 5c: Aggregate Worker Diffs Into Main
355
-
356
- After all workers complete, do **not** merge their branches one at a time — sequential merges with conflict resolution are slow and error-prone. Instead, read every worker's proposed changes in one pass, write the aggregated result once, then tie the worker branches into history with a no-conflict merge.
357
-
358
- **3a. Look at all the worker diffs in one pass**
359
-
360
- ```bash
361
- cd [MEMORY_DIR]
362
-
363
- # Which files did each worker touch? (a file listed under multiple branches
364
- # is an overlap you'll need to combine)
365
- for b in $(git for-each-ref --format='%(refname:short)' 'refs/heads/migration-*'); do
366
- git diff --name-only main...$b | sed "s|^|$b |"
367
- done | sort -k2
368
-
369
- # Every worker's full proposed diff, one after another
370
- for b in $(git for-each-ref --format='%(refname:short)' 'refs/heads/migration-*'); do
371
- echo "=== $b ==="; git log --oneline main..$b; git diff main...$b
372
- done
373
- ```
108
+ The export normalizes every session into `<source>/<startedAt>_<sessionId>.json` plus `manifest.json` — **the authoritative inventory**, in which every session must end up either analyzed or explicitly excluded with a reason. Scope it with `--project $(pwd)` (a pathname prefix, not a directory boundary — check the manifest for similarly named siblings), `--source`, `--root`, or `--transcript`; browse it with `letta trajectories list`, `view`, `search`.
374
109
 
375
- Read the whole output before writing anything — you want the complete picture, not one branch at a time.
376
-
377
- **3b. Synthesize the aggregate by COMBINING, never compressing**
378
-
379
- Working directly on memory `main` (in `[MEMORY_DIR]`), apply the union of the workers' changes:
380
- - For files touched by **one** worker, apply that worker's version as-is.
381
- - For **overlapping** files, combine unique details from every branch. Never rewrite a file from scratch — you WILL lose information.
382
-
383
- Rules for combining:
384
- - **Read every branch's diff for the file** before editing. Identify what's unique to each version.
385
- - **Append new details** from each worker into the file. Don't drop specific quotes, file paths, or gotchas just because another version already covers the "topic" at a high level.
386
- - **Preserve specificity**: "Use factory methods, such as `create_token_counter()`, not direct instantiation" is more valuable than "prefers factory methods". Keep both.
387
- - **When in doubt, keep it**. Redundancy across files is better than information loss. Less important details can be placed in external memory.
388
-
389
- Example — BAD combination (compresses):
390
- ```
391
- # worker A proposed:
392
- - Uses `uv` for Python
393
- # worker B proposed:
394
- - **CRITICAL: Always use `uv run`** — chronic failure; never bare pytest or python
395
- - `uv run pytest -sv tests/...` for specific tests
396
-
397
- # BAD: Picks one side or rewrites
398
- - **Python**: `uv` exclusively — `uv run pytest`, never bare `pip`
399
- ```
110
+ `prepare-history.mjs` groups the sessions into chronological cohorts of roughly 200 KB / 20 sessions (`--max-bytes`, `--max-sessions`), writing `cohorts.json` (absolute paths per session) and `ledger.json` (exclusions with reasons). If `letta` is not on PATH, pass `--letta <executable>` with repeated `--letta-arg`. You may merge small cohorts or drop low-value ones first — anything dropped is reported as not analyzed in Step 8, so tell the user.
400
111
 
401
- Example — GOOD combination (keeps emphasis and specificity from every side):
402
- ```
403
- **CRITICAL: Use `uv` exclusively for Python** — chronic failure.
404
- - `uv run pytest -sv tests/...` for tests
405
- - `uv run python` for scripts
406
- - Never bare `pip`, `python`, or `pytest`
407
- ```
112
+ ### 6. Research the codebase first-hand
113
+ Read the README, agent docs (`AGENTS.md`, `CLAUDE.md`, nested ones), the package manifest, entry points, and recent git history yourself. By the end you should be able to trace a key feature from entry point to implementation; if you can't, you haven't read enough.
408
114
 
409
- Commit the synthesis:
410
- ```bash
411
- cd [MEMORY_DIR]
412
- git add -A
413
- git commit -m "feat(memory): aggregate history worker findings"
414
- ```
115
+ **Write down what those docs already own** — conventions, layer rules, file placement, commands, gotchas. That is your no-copy list for Step 8 and your gap list for Step 7. Then split the repository into subsystem areas the docs do *not* explain, plus any related repos named in Step 4. If the docs cover the codebase well, fan out narrowly or not at all. In deep mode go further: more areas, git history for conventions, end-to-end tracing, architecture notes in deferred memory.
415
116
 
416
- **3c. Preserve worker commits in ancestry**
117
+ ### 7. Run the analysis Workflow
118
+ Running `/init` with this skill **authorizes one Workflow run** for read-only analysis of the approved cohorts and code gaps, plus one follow-up run for unread cohorts (Step 8). Nothing else: workflow subagents never write memory, create worktrees, or edit the repository.
417
119
 
418
- Record the worker branches as ancestors of `main` without changing any content (the `ours` strategy keeps the synthesized state exactly as committed, so this can never conflict):
120
+ Load the `workflow-authoring` skill and design the script. Whatever shape you choose, it must:
121
+ - **Stay read-only** — leave subagent tools at the default (Read/Grep/Glob).
122
+ - **Give each subagent complete context** — they have no memory, skills, or view of this conversation. Pass `historyCohorts` from `cohorts.json` and your code areas through `args`; put the user's identity, the repository path, and absolute file paths in every prompt.
123
+ - **Validate each result** with `agent(prompt, {schema})`, never `json: true`: an invalid result becomes `null` with its error in the journal, instead of a silently empty finding list.
124
+ - **Check authorship before inferring preferences.** In Claude Code or Codex worker sessions, `user` turns can be prompts written by a parent agent, and harness-injected `<system-reminder>` text is not human speech. Corroborate from the originating conversation, or classify them as worker instructions.
125
+ - **Ask for evidence-backed specifics** — identity, hard rules, corrections (what the agent did, what the human said, what resolved it, how often it repeated), conventions, gotchas, each with session ids and excerpts. Never copy secrets.
126
+ - **Ask code areas for the delta, not the documentation.** Name the repo docs covering each area and say those facts are available; the agent reports what they omit, contradict, or leave stale.
127
+ - **Check code claims against current code** — history describes the code as it was. Verify claims about a cohort's `repo` against the current tree and report what changed.
128
+ - **Budget time** — subagents time out after 10 minutes; raise `timeoutMs` for large cohorts.
129
+ - **Gather on a fast model.** Pass `model: "deepseek/deepseek-v4.1-flash"`; omit `model` if `letta model list` doesn't show that handle. If inference fails at that model (including quota), use your current model for the follow-up run rather than retrying the failed route. Never synthesize memory on the fan-out model.
419
130
 
420
- ```bash
421
- git merge -s ours --no-edit -m "merge: absorb history worker branches" $(git for-each-ref --format='%(refname:short)' 'refs/heads/migration-*')
131
+ ```js
132
+ // Every finding carries a claim, its evidence, and where that evidence lives.
133
+ const findings = (cites, items) => ({type: 'array', items: {type: 'object',
134
+ additionalProperties: false, required: ['claim', 'evidence', cites], properties: {
135
+ claim: {type: 'string'}, evidence: {type: 'string'},
136
+ [cites]: {type: 'array', minItems: 1, uniqueItems: true, items},
137
+ }}})
138
+ const historySchema = cohort => {
139
+ const sessionId = {type: 'string', enum: cohort.sessions.map(s => s.sessionId)}
140
+ return {type: 'object', additionalProperties: false, required: ['sessionsRead', 'findings'], properties: {
141
+ sessionsRead: {type: 'array', uniqueItems: true, items: sessionId},
142
+ findings: findings('sessionIds', sessionId),
143
+ }}
144
+ }
145
+ const codeSchema = {type: 'object', additionalProperties: false, required: ['area', 'findings'],
146
+ properties: {area: {type: 'string'}, findings: findings('paths', {type: 'string'})}}
147
+ const history = await agent(historyPrompt, {label: `history:${cohort.id}`, schema: historySchema(cohort)})
148
+ const code = await agent(codePrompt, {label: `code:${area.name}`, schema: codeSchema})
422
149
  ```
423
150
 
424
- Do **not** skip this: without it the worker commits vanish from the final history when their branches are deleted.
151
+ `sessionsRead` must contain only sessions the agent actually finished, even if a finding cites others — Step 8 counts coverage from that field alone, and never from a code-area result.
425
152
 
426
- **3d. Verify no information was lost**
153
+ If the Workflow tool is unavailable (not in your toolset, or it reports that workflow subagents require the API backend), do the same analysis yourself, cohort by cohort and area by area, accounting for coverage by hand. Do not substitute subagent types that write memory. The Workflow runs in the background: keep reading code while you wait, and never assume results before the task notification arrives.
427
154
 
428
- Compare the worker diffs (step 3a) against the final files. For each worker's diff, can you find every specific detail (quotes, file paths, chronic failures, gotchas) somewhere in the final memory? If not, add it back.
155
+ ### 8. Curate the results into memory
156
+ You — not the subagents — decide what becomes memory, and you write it. Synthesize on your current model or `letta/auto`, never the fan-out model.
429
157
 
430
- **3e. Clean up worktrees and branches**
158
+ **Check coverage first.** The tool result names the run's `journal.jsonl`:
431
159
 
432
160
  ```bash
433
- for w in $(dirname [MEMORY_DIR])/memory-worktrees/*; do
434
- git worktree remove "$w" 2>/dev/null
435
- done
436
- git branch -d $(git for-each-ref --format='%(refname:short)' 'refs/heads/migration-*')
437
- git push
161
+ node <SKILL_DIR>/scripts/history-coverage.mjs --prepared /tmp/letta-init-history \
162
+ --journal ~/.letta/workflows/executions/<id>/journal.jsonl \
163
+ --retry-out /tmp/letta-init-history/retry.json
438
164
  ```
439
165
 
440
- (`git branch -d` succeeds because step 3c made every worker branch an ancestor of `main`.)
166
+ It reports sessions analyzed, unread, excluded, export errors, and any dropped from `cohorts.json`, and writes the unread ones as smaller cohorts to `retry.json`. Runs are not resumable: launch one follow-up Workflow over `retry.json`, then rerun the script with both `--journal` paths. If coverage is still incomplete, say so plainly — how many of the manifest total, which ranges were missed — never call the result comprehensive, and record the gap in deferred memory.
441
167
 
442
- ##### Example Output
168
+ **Weigh validation.** Store confirmed claims as fact; for stale ones store the current fact, keeping the history only when the change is itself a useful gotcha. Unverifiable claims need your own check before entering always-loaded memory.
443
169
 
444
- Good output includes all three categories:
170
+ **Provenance gates promotion here too**, not only in the subagent — a worker's authorship flag must survive curation, because flagged excerpts still read like preferences. Before promoting any claim about what the human wants, check who wrote the quoted words; agent-authored dispatch prompts describe how an *agent* was instructed to work. If it is ambiguous, corroborate from a session you know the human drove, or store it as an observed pattern with the uncertainty stated. Repetition does not establish authorship: a template reused across fifty sessions repeats fifty times.
445
171
 
446
- ```markdown
447
- ### User Personality & Identity
448
- Pragmatic builder who values shipping over perfection. Gets frustrated when agents over-engineer or add "bonus" features. Uses dry humor and sarcasm when annoyed. Pattern: "scrappy startup engineer" — wants things to work, not to be architecturally pure.
449
-
450
- ### Hard Rules & Preferences
451
- - **CRITICAL: Use `uv` for Python** — chronic failure ("you need to use uv", "make sure you use uv"); `uv run pytest -sv`, never bare `pytest`
452
- - **Minimal changes only** — "just make a minor change stop adding all this stuff"
453
- - **Only edit specified files** — when told to focus, stay focused
454
- - Tests constantly: `uv run pytest -sv` (Python), `bun test` (TS)
455
-
456
- ### Project Context
457
- - letta-cloud: Only edit `letta_agent_v3.py` — v1, v2, and base are deprecated
458
- - Uses Biome for linting, not ESLint
459
- - Conventional commits with scope in parens
460
- ```
172
+ **Combine, then deduplicate.** Cohorts report the same topic at different specificity. Keep the unique details from each — quotes, paths, correction counts — and sum correction counts across cohorts, since a correction seen in five cohorts is a chronic failure. Keep the specific form alongside the general: "Use factory methods, such as `create_token_counter()`, not direct instantiation" beats "prefers factory methods". Then keep each fact exactly once, and push what you don't need every turn into deferred memory with a discovery link from the core tier.
461
173
 
462
- ##### Step 5d: Consider Creating Skills From Discovered Workflows
174
+ **Promote into canonical memory.** Write the survivors into the files their topics belong in, with supporting evidence deferred. Cover all three of identity and personality, hard rules and preferences with the quotes behind them, and project context; skip generic repo facts unless they change how you execute. If the output reads generically, the analysis failed for that area — re-read those transcripts or that code yourself. Keep stable `sessionId`s beside significant findings; `/tmp` results and journals are scratch, not retrievable evidence.
463
175
 
464
- After merging and curating, review the extracted history for repeatable multi-step workflows that would benefit from being codified as skills. History analysis often surfaces procedures the user runs frequently that the agent would otherwise have to rediscover each session.
176
+ **Consider skills.** If the history surfaces genuinely repeatable multi-step procedures, create them now (load `creating-skills`) or note the candidates in memory. Don't force it.
465
177
 
466
- **Good candidates for skills:**
467
- - Multi-step debugging procedures (e.g. "how to debug agent message desync", "how to trace TTFT regressions")
468
- - Common workflows repeated across sessions (e.g. "how to run integration tests across LLM providers")
469
- - Deployment or release procedures
470
- - Project-specific setup or migration steps
178
+ ### 9. Verify
179
+ - **Structure**: check root `MEMORY.md`, per-directory indexes, frontmatter-free `MEMORY.md`, and exactly `name`+`description` elsewhere. Avoid `foo.md` beside `foo/`:
180
+ `find "$MEMORY_DIR" -name '*.md' | sed 's/\.md$//' | while read f; do [ -d "$f" ] && echo "VIOLATION: $f"; done`
181
+ - **Root earns its place**: does root `MEMORY.md` mostly point at things *not* already in your system prompt? If nearly everything sits in root with one thin page behind it, move the detail down and keep the links.
182
+ - **No duplicated documentation**: grep your memory for rules `AGENTS.md`, `CLAUDE.md`, the README, or a repo skill already owns — especially a repo convention that landed in a file about the *human*.
183
+ - **Granularity and naming**: one focused topic per file, named for what is in it using the project's real name; path and description say when to read it.
184
+ - **Persona quality**: read it now. "I'm a coding assistant who follows the user's preferences" is behavior, not identity. Would you be recognizably the same agent on a different model tomorrow?
185
+ - **No drift, no over-pruning**: confirm you changed structure and not the meaning of persona or behavioral instructions, and restore any specific paths, chronic failures, or gotchas lost in curation.
471
186
 
472
- If you identify candidates, either create them now (load the [[skills/creating-skills]] skill for guidance) or note them in memory for future creation:
473
- ```markdown
474
- # system/letta-code/overview.md
475
- ...
476
- Potential skills to create:
477
- - Debug workflow for HITL approval desync
478
- - Integration test runner across providers
479
- ```
480
-
481
- Don't force skill creation — only create them when you've found genuinely repeatable, multi-step procedures in the history.
482
-
483
- ##### Troubleshooting
484
-
485
- | Problem | Cause | Fix |
486
- |---------|-------|-----|
487
- | Subagent exits with code `null`, 0 tool uses | `letta.js` not built | Run `bun run build` |
488
- | `letta trajectories export` reports errors in manifest.json | Degenerate sessions (e.g. no assistant turns) that cannot form a valid trajectory | Expected — those sessions are skipped; review `jq .errors manifest.json` only if counts look wrong |
489
- | `deepagents` sessions fail to normalize | Checkpoint decoding needs a Python environment with LangGraph installed | Expected on machines without it; the failures land in manifest errors and other sources are unaffected |
490
- | Subagent hangs on "Tool requires approval" | Wrong subagent type | Use `subagent_type: "history-analyzer"` (workers) or `"memory"` (synthesis) |
491
- | Workers touched overlapping files | Multiple workers wrote the same canonical paths | Expected — the per-branch `--name-only` listing in Step 5c-3a shows the overlaps; combine every branch's unique details additively. |
492
- | Information lost after aggregation | Synthesis compressed worker output | Re-read the worker diffs (Step 5c-3a) and compare against final files. Re-add missing specifics. |
493
- | `git branch -d` refuses to delete worker branches | Ancestry merge (Step 5c-3c) was skipped | Run the `git merge -s ours` step first, then delete. |
494
- | Personality analysis missing or thin | Prompt didn't request it | Use the template above with explicit category requirements |
495
- | Auth fails on push ("repository not found") | Credential helper broken or global helper conflict | Reconfigure **repo-local** helper and check/clear conflicting global `credential.<host>.helper` entries (see syncing-memory-filesystem skill) |
496
-
497
- ### 6. Research the project
498
-
499
- **Do this in parallel with history analysis** (Step 5). While workers process history, you should be actively exploring the codebase. This is your onboarding — invest real effort here.
500
-
501
- **IMPORTANT**: The goal is to understand how the codebase actually works — not just its shape, but its substance. Directory listings and `head -N` snippets tell you what files exist; reading the actual implementation tells you how they work. By the end of this step, you should be able to describe how a key feature flows from entry point to implementation. If you can't, you haven't read enough.
502
-
503
- ### 6a. Decide whether to parallelize exploration
504
-
505
- After your initial scan (README, package manifest, top-level directories, and entry points), decide whether to fan out exploration.
506
-
507
- **Default rule**:
508
- - If the repo has **3 or more clear subsystems**, launch **2-4 parallel subagents** to explore them.
509
- - If background history-analysis workers are already running, **bias toward parallel exploration** instead of doing all research serially yourself.
510
- - Only skip subagent exploration if the codebase is genuinely small or the subsystem boundaries are unclear.
511
-
512
- This is the preferred path for medium-to-large repos, **even in standard mode**.
513
-
514
- Explore based on chosen depth.
515
-
516
- **Standard** (~20-40 tool calls total across the parent agent and any subagents):
517
- - Scan README, package.json/config files, AGENTS.md, CLAUDE.md
518
- - Review git status and recent commits
519
- - Explore key directories and understand project structure
520
- - **Read entry point files** (main, index, app) to understand the application flow
521
- - Do a quick manual scan to identify major subsystems
522
- - If the repo has clear subsystem boundaries, launch **2-3 parallel subagents** to explore them
523
- - **Read 2-3 key implementation files yourself** so you retain first-hand understanding of the core flow
524
- - **Read 2-3 test files** to understand testing patterns and conventions
525
- - **Check build/CI config** to understand how the project is built and tested
526
- - Identify gotchas, non-obvious conventions, and real command patterns from what you read
527
- - Synthesize findings into memory as results come back
528
-
529
- **Deep** (100+ tool calls): Everything above, plus:
530
- - Use your TODO or Plan tool to create a systematic research plan
531
- - Use more parallel subagents where helpful to cover additional subsystems
532
- - Deep dive into git history for patterns, conventions, and context
533
- - Analyze commit message conventions and branching strategy
534
- - Read source files across multiple modules to understand architecture thoroughly
535
- - Trace key code paths end-to-end (e.g. how a request flows through the system)
536
- - Read test files to understand what's tested and how
537
- - Identify deprecated code, known issues, and areas of active development
538
- - Create detailed architecture documentation in progressive memory
539
- - May involve multiple rounds of exploration
540
-
541
- #### Parallel exploration with subagents
542
-
543
- For medium-to-large repos, parallel exploration is the preferred strategy after your initial scan.
544
-
545
- Use parallel `general-purpose` subagents to investigate different subsystems simultaneously. If your environment or user instructions discourage using subagents, do the equivalent exploration directly with Bash/Glob/Grep/Read.
546
-
547
- Good subsystem boundaries include:
548
- - `server/`, `client/`, `shared/`
549
- - `api/`, `ui/`, `common/`
550
- - `runtime/`, `cli/`, `tools/`
551
- - separate apps or packages in a monorepo
552
-
553
- **Subagent budget**:
554
- - Standard mode: usually **2-3** exploration subagents
555
- - Deep mode: usually **3-5** exploration subagents
556
- - Do not launch subagents for trivial directories or questions you can answer faster yourself
557
- - Partition by subsystem, not by random folder count
558
-
559
- Each exploration subagent should return:
560
- 1. key files and what they do
561
- 2. major abstractions and execution flow
562
- 3. conventions and patterns used in that subsystem
563
- 4. gotchas, fragile areas, or deprecated paths
564
- 5. file paths worth storing or linking in memory
565
-
566
- Launch exploration subagents in a **single message** so they run concurrently.
567
-
568
- ```
569
- # After initial scan reveals key areas, launch parallel explorers in the background:
570
- Agent({
571
- subagent_type: "general-purpose",
572
- description: "Explore API layer",
573
- run_in_background: true,
574
- prompt: `Read the implementation in src/api/.
575
-
576
- Return:
577
- 1. key files and responsibilities
578
- 2. main abstractions and execution flow
579
- 3. non-obvious conventions
580
- 4. gotchas or deprecated paths
581
- 5. file paths worth storing in memory`
582
- })
583
- Agent({
584
- subagent_type: "general-purpose",
585
- description: "Explore frontend layer",
586
- run_in_background: true,
587
- prompt: `Read the implementation in src/ui/.
588
-
589
- Return:
590
- 1. key files and responsibilities
591
- 2. major components and data flow
592
- 3. conventions and patterns
593
- 4. gotchas or fragile areas
594
- 5. file paths worth storing in memory`
595
- })
596
- Agent({
597
- subagent_type: "general-purpose",
598
- description: "Explore shared systems",
599
- run_in_background: true,
600
- prompt: `Read the implementation in src/shared/.
601
-
602
- Return:
603
- 1. key files and responsibilities
604
- 2. shared abstractions
605
- 3. conventions and invariants
606
- 4. gotchas or deprecated paths
607
- 5. file paths worth storing in memory`
608
- })
609
- ```
610
-
611
- Do **not** sit idle while background workers are running. Continue project research and memory drafting while they run, and only check worker status when you are ready to integrate findings or have exhausted useful direct research.
612
-
613
- When you are ready to integrate findings, retrieve the background subagent outputs and synthesize them into memory rather than repeating the same exploration yourself. Keep first-hand understanding of the entry points and core flow, but use subagent summaries to add subsystem-specific depth.
614
-
615
- #### What to actually read (adapt to the project):
616
-
617
- **Source code** (most important — don't skip this):
618
- - Entry points: `main.ts`, `index.ts`, `app.py`, `main.go`, etc.
619
- - Core abstractions: the 3-5 files that define the main domain objects or services
620
- - How key features work: trace at least one feature from entry to implementation
621
- - Test files: understand testing patterns, what's tested, how fixtures work
622
-
623
- **Config & metadata**:
624
- - README.md, CONTRIBUTING.md, AGENTS.md, CLAUDE.md
625
- - Package manifests (package.json, Cargo.toml, pyproject.toml, go.mod)
626
- - Config files (.eslintrc, tsconfig.json, .prettierrc, biome.json)
627
- - CI/CD configs (.github/workflows/, .gitlab-ci.yml)
628
- - Build scripts and tooling
629
-
630
- **Git history**:
631
- - `git log --oneline -20` — recent history
632
- - `git branch -a` — branching strategy
633
- - `git log --format="%s" -50 | head -20` — commit conventions
634
- - `git shortlog -sn --all | head -10` — main contributors
635
- - `git log --format="%an <%ae>" | sort -u` — contributors with emails
636
-
637
-
638
- ### 7. Build memory with discovery paths
639
- As you create/update memory files, add `[[path]]` references so your future self can find related context. These go *inside the content* of memory files:
640
-
641
- Do NOT put everything in `system/`. Detailed reference material belongs in progressive memory — files outside `system/` that can be loaded on demand through references.
642
-
643
- **Reference external memory from system/ files:**
644
- ```markdown
645
- # system/letta-code/overview.md
646
- ...
647
- For detailed architecture docs, see [[letta-code/architecture.md]]
648
- Known footguns and edge cases: [[system/letta-code/gotchas.md]]
649
- ```
650
-
651
- **Reference skills from relevant context:**
652
- ```markdown
653
- # system/letta-code/conventions.md
654
- ...
655
- When committing, follow the workflow in [[skills/commit]]
656
- For PR creation, use [[skills/review-pr]]
657
- ```
658
-
659
- **Create an index in overview files:**
660
- ```markdown
661
- # system/letta-code/overview.md
662
-
663
- CLI for interacting with Letta agents. Bun runtime, React/Ink TUI.
664
-
665
- Entry points:
666
- - `src/index.ts` — CLI arg parsing, agent resolution, startup
667
- - `src/cli/App.tsx` — main TUI component (React/Ink)
668
- - `src/agent/` — agent creation, memory, model handling
669
-
670
- Key flows:
671
- - Message send: index.ts → App.tsx → agent/message.ts → streaming
672
- - Tool execution: tools/manager.ts → tools/impl/*
673
-
674
- Links:
675
- - [[system/letta-code/conventions.md]] — tooling, testing, commits
676
- - [[system/letta-code/gotchas.md]] — common mistakes
677
- - [[letta-code/architecture.md]] — detailed subsystem docs
678
- ```
679
-
680
- This is a **compact index**, not a prose summary. It tells your future self where to start and where to find more.
681
-
682
- Additional guidelines:
683
- - Every file needs a `description` in frontmatter that states its purpose, not a summary of contents
684
- - Keep `system/` files focused and scannable
685
- - Put detailed reference material outside `system/`
686
-
687
- ### 8. Verify context quality
688
- Before finishing, review your work:
689
-
690
- - **Structural requirements**: Run this check before finishing:
691
- ```bash
692
- # Detect overlapping file/folder names (e.g. system/human.md AND system/human/)
693
- find "$MEMORY_DIR" -name "*.md" | sed 's/\.md$//' | while read f; do
694
- [ -d "$f" ] && echo "VIOLATION: $f.md conflicts with directory $f/"
695
- done
696
- ```
697
- If any violations are printed, fix them before committing (rename `foo.md` → `foo/overview.md` or merge the directory back into the file).
698
- Also check: Does `system/persona.md` exist? All files have frontmatter with `description`?
699
- - **File granularity**: Does each file cover exactly one focused topic? Do the path and description precisely describe what's inside? If a file mixes multiple concepts (coding style AND git workflow AND communication preferences), split it.
700
- - **Discovery paths**: Are key memory files linked with `[[path]]` so related context can be discovered quickly? Are external files referenced from in-context memory?
701
- - **Project naming**: Are project dirs named after the actual project (e.g., `letta-code/`), not generic `project/`? Same for reference files.
702
- - **Signal density**: Is everything in `system/` truly needed every turn?
703
- - **Persona quality**: Does it express genuine personality and values, not just "agent role + project rules"? Read your persona file right now — if it's just "I'm a coding assistant who follows the user's preferences," that's not identity. What do YOU value? What's distinctive about how you think? Would you be recognizably the same agent on a different model tomorrow? If your persona disappeared but the model stayed, would something meaningful be lost? If not, your identity isn't strong enough yet.
704
- - **No semantic drift**: If reorganizing an existing agent, verify you haven't altered the meaning of persona, identity, or behavioral instructions — only improved structure.
705
- - **No over-pruning**: Compare your final memory against all source material (worker output, codebase research). Did you lose specific file paths, chronic failures, or gotchas during curation? If so, add them back. Compression that loses specificity degrades your identity.
706
- - **Progressive memory**: Did you create reference files outside `system/` for detailed content? Did you review what history workers produced and keep their project context files? Are these files linked from `system/` with `[[path]]` references?
707
-
708
-
709
- ### 9. Ask user if done
710
- Check if they're satisfied or want further refinement. Then commit and push memory:
187
+ ### 10. Commit, then report
188
+ **Uncommitted memory is not part of your future system prompt.** If a commit is blocked, report initialization as incomplete rather than describing working-tree files as live memory.
711
189
 
712
190
  ```bash
713
191
  cd $MEMORY_DIR
@@ -718,10 +196,14 @@ git commit --author="$author_name <$AGENT_ID@letta.com>" -m "feat(init): <summar
718
196
 
719
197
  <what was initialized and key decisions made>"
720
198
 
721
- git push
199
+ git status # Your memory changes should no longer be listed
200
+ git ls-tree -r --name-only HEAD # What your future self will actually load
722
201
  ```
723
202
 
724
- ## Critical
725
- **Use parallel tool calls wherever possible** — read multiple files in a single turn, write multiple memory files in a single turn. This dramatically reduces init time.
726
- **Write findings to memory as you go** — don't wait until the end.
727
- **Edit memory files directly via the filesystem** — memory is projected to `$MEMORY_DIR` specifically for ease of bulk modification. Use standard file tools (Read, Write, Edit) and git to manage changes during initialization.
203
+ Do **not** run `git push`. The harness pushes clean committed memory automatically after the turn, so pushing by hand races it. The commit is the finish line.
204
+
205
+ Only once the commit is verified, tell the user what you built and whether coverage was complete, then ask whether they want refinement — which means another commit, so repeat this step.
206
+
207
+ ## Critical
208
+ - **Use parallel tool calls wherever possible** — read many files in one turn, write many memory files in one turn.
209
+ - **Write findings to memory as you go**; don't hold everything until the end.