ei-tui 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +14 -0
  2. package/package.json +1 -1
  3. package/src/cli/README.md +21 -14
  4. package/src/cli/commands/personas.ts +12 -0
  5. package/src/cli/mcp.ts +6 -5
  6. package/src/cli/retrieval.ts +86 -8
  7. package/src/cli.ts +21 -19
  8. package/src/core/constants/seed-traits.ts +29 -0
  9. package/src/core/context-utils.ts +1 -0
  10. package/src/core/format-utils.ts +23 -0
  11. package/src/core/handlers/human-matching.ts +53 -35
  12. package/src/core/handlers/index.ts +5 -0
  13. package/src/core/handlers/persona-preview.ts +7 -0
  14. package/src/core/handlers/persona-topics.ts +3 -2
  15. package/src/core/handlers/rooms.ts +176 -0
  16. package/src/core/handlers/utils.ts +55 -3
  17. package/src/core/heartbeat-manager.ts +3 -1
  18. package/src/core/llm-client.ts +1 -1
  19. package/src/core/message-manager.ts +13 -9
  20. package/src/core/orchestrators/human-extraction.ts +15 -2
  21. package/src/core/orchestrators/index.ts +1 -0
  22. package/src/core/orchestrators/persona-generation.ts +4 -0
  23. package/src/core/orchestrators/persona-topics.ts +2 -1
  24. package/src/core/orchestrators/room-extraction.ts +318 -0
  25. package/src/core/persona-manager.ts +16 -5
  26. package/src/core/personas/opencode-agent.ts +12 -2
  27. package/src/core/processor.ts +520 -4
  28. package/src/core/prompt-context-builder.ts +89 -5
  29. package/src/core/queue-processor.ts +68 -8
  30. package/src/core/room-manager.ts +408 -0
  31. package/src/core/state/index.ts +1 -0
  32. package/src/core/state/personas.ts +12 -2
  33. package/src/core/state/queue.ts +2 -2
  34. package/src/core/state/rooms.ts +182 -0
  35. package/src/core/state-manager.ts +124 -2
  36. package/src/core/tool-manager.ts +1 -1
  37. package/src/core/tools/index.ts +15 -0
  38. package/src/core/types/entities.ts +1 -0
  39. package/src/core/types/enums.ts +11 -0
  40. package/src/core/types/integrations.ts +10 -2
  41. package/src/core/types/llm.ts +3 -0
  42. package/src/core/types/rooms.ts +59 -0
  43. package/src/core/types.ts +1 -0
  44. package/src/core/utils/decay.ts +14 -8
  45. package/src/core/utils/exposure.ts +14 -0
  46. package/src/integrations/claude-code/importer.ts +23 -10
  47. package/src/integrations/cursor/importer.ts +22 -10
  48. package/src/integrations/opencode/importer.ts +30 -13
  49. package/src/prompts/ceremony/dedup.ts +2 -2
  50. package/src/prompts/generation/from-person.ts +85 -0
  51. package/src/prompts/generation/index.ts +2 -0
  52. package/src/prompts/generation/persona.ts +14 -10
  53. package/src/prompts/generation/seeds.ts +4 -29
  54. package/src/prompts/generation/types.ts +13 -0
  55. package/src/prompts/heartbeat/check.ts +1 -1
  56. package/src/prompts/heartbeat/ei.ts +4 -4
  57. package/src/prompts/heartbeat/types.ts +1 -0
  58. package/src/prompts/index.ts +15 -0
  59. package/src/prompts/message-utils.ts +2 -2
  60. package/src/prompts/persona/topics-match.ts +7 -6
  61. package/src/prompts/persona/topics-update.ts +8 -11
  62. package/src/prompts/persona/types.ts +2 -1
  63. package/src/prompts/response/index.ts +4 -11
  64. package/src/prompts/response/sections.ts +22 -10
  65. package/src/prompts/response/types.ts +6 -0
  66. package/src/prompts/room/index.ts +115 -0
  67. package/src/prompts/room/sections.ts +150 -0
  68. package/src/prompts/room/types.ts +93 -0
  69. package/tui/README.md +20 -0
  70. package/tui/src/app.tsx +3 -2
  71. package/tui/src/commands/activate.tsx +98 -0
  72. package/tui/src/commands/archive.tsx +54 -25
  73. package/tui/src/commands/capture.tsx +50 -0
  74. package/tui/src/commands/dedupe.tsx +2 -7
  75. package/tui/src/commands/delete.tsx +48 -0
  76. package/tui/src/commands/details.tsx +7 -0
  77. package/tui/src/commands/persona.tsx +271 -9
  78. package/tui/src/commands/room.tsx +261 -0
  79. package/tui/src/commands/silence.tsx +29 -0
  80. package/tui/src/components/ArchivedItemsOverlay.tsx +144 -0
  81. package/tui/src/components/ConfirmOverlay.tsx +6 -0
  82. package/tui/src/components/ConflictOverlay.tsx +6 -0
  83. package/tui/src/components/HelpOverlay.tsx +6 -1
  84. package/tui/src/components/LoadingOverlay.tsx +51 -0
  85. package/tui/src/components/MessageList.tsx +1 -18
  86. package/tui/src/components/PersonPickerOverlay.tsx +121 -0
  87. package/tui/src/components/PersonaListOverlay.tsx +6 -1
  88. package/tui/src/components/PromptInput.tsx +141 -8
  89. package/tui/src/components/ProviderListOverlay.tsx +5 -1
  90. package/tui/src/components/QuotesOverlay.tsx +5 -1
  91. package/tui/src/components/RoomMessageList.tsx +179 -0
  92. package/tui/src/components/Sidebar.tsx +54 -2
  93. package/tui/src/components/StatusBar.tsx +99 -8
  94. package/tui/src/components/ToolkitListOverlay.tsx +5 -1
  95. package/tui/src/components/WelcomeOverlay.tsx +6 -0
  96. package/tui/src/context/ei.tsx +252 -1
  97. package/tui/src/context/keyboard.tsx +48 -12
  98. package/tui/src/util/cyp-editor.tsx +152 -0
  99. package/tui/src/util/quote-utils.ts +19 -0
  100. package/tui/src/util/room-editor.tsx +164 -0
  101. package/tui/src/util/room-logic.ts +8 -0
  102. package/tui/src/util/room-parser.ts +70 -0
  103. package/tui/src/util/yaml-serializers.ts +154 -0
package/README.md CHANGED
@@ -58,6 +58,20 @@ A "Persona" is the combination of these two pieces of data, plus some _personali
58
58
 
59
59
  > <sup>1</sup>: By default. You can make them static.
60
60
 
61
+ ## What's a Room?
62
+
63
+ Rooms let you throw multiple personas into the same conversation thread. Chaos ensues. Or collaboration. Sometimes both.
64
+
65
+ Three modes, set at creation:
66
+
67
+ **Free For All (FFA)**: Everyone talks. Every message gets a response from every persona. It's loud. Good for brainstorming or when you want a bunch of perspectives on the same thing.
68
+
69
+ **Choose Your Path (CYP)**: The conversation branches. Each message triggers responses from all personas, but you pick which one continues the thread. Fork in the road, every turn. You're the navigator.
70
+
71
+ **Messages Against Persona (MAP)**: The interesting one. Everyone submits a response, but a Judge persona picks which one actually shows up. The personas have to stay in character and compete for the Judge's approval. The human doesn't have to play by the rules. It's partly a game of "who knows this judge best?" and partly just fun to watch them try.
72
+
73
+ Rooms learn the same way persona conversations do. Quotes, topics, people — all get extracted and persisted. The knowledge base grows no matter which mode you're in.
74
+
61
75
  ## The Basics
62
76
 
63
77
  Ei can operate with three types of input, and three types of output.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ei-tui",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "author": "Flare576",
5
5
  "repository": {
6
6
  "type": "git",
package/src/cli/README.md CHANGED
@@ -5,18 +5,21 @@
5
5
  ei # Start the TUI
6
6
  ei "query string" # Return up to 10 results across all types
7
7
  ei -n 5 "query string" # Return up to 5 results
8
- ei facts -n 5 "query string" # Return up to 5 facts
9
- ei people -n 5 "query string" # Return up to 5 people
10
- ei topics -n 5 "query string" # Return up to 5 topics
11
- ei quotes -n 5 "query string" # Return up to 5 quotes
8
+ ei facts -n 5 "query string" # Return up to 5 facts
9
+ ei people -n 5 "query string" # Return up to 5 people
10
+ ei topics -n 5 "query string" # Return up to 5 topics
11
+ ei quotes -n 5 "query string" # Return up to 5 quotes
12
+ ei personas -n 5 "query string" # Return up to 5 personas (name match)
12
13
  ei --persona "Beta" "query string" # Filter results to what Beta has learned
14
+ ei --recent # Most recently mentioned items (no query needed)
15
+ ei --persona "Beta" --recent # Most recently mentioned items Beta has learned
13
16
  ei --id <id> # Look up a specific entity by ID
14
17
  echo <id> | ei --id # Look up entity by ID from stdin
15
18
  ei --install # Register Ei with OpenCode, Claude Code, and Cursor
16
19
  ei mcp # Start the Ei MCP stdio server (for Cursor/Claude Desktop)
17
20
  ```
18
21
 
19
- Type aliases: `fact`, `person`, `topic`, `quote` all work (singular or plural).
22
+ Type aliases: `fact`, `person`, `topic`, `quote`, `persona` all work (singular or plural).
20
23
 
21
24
  # An Agentic Tool
22
25
 
@@ -68,9 +71,10 @@ ei "What are the user's current preferences, active projects, and workflow?"
68
71
  \```
69
72
 
70
73
  Ei is a persistent knowledge base built from the user's conversations — facts, preferences,
71
- people, topics. Use it when the user references past work, mentions how they like things done,
72
- or asks "how did we do X." Use `ei --persona "Beta" "walruses"` to scope results to what a specific persona has learned. Query again mid-session when they correct you or reference something
73
- from a previous session.
74
+ people, topics, personas. Use it when the user references past work, mentions how they like things done,
75
+ or asks "how did we do X." Use `ei --persona "Beta" "walruses"` to scope results to what a specific
76
+ persona has learned. Use `ei personas "name"` to find personas by name. Query again mid-session when
77
+ they correct you or reference something from a previous session.
74
78
  ```
75
79
 
76
80
  ### Claude Code
@@ -81,6 +85,7 @@ Add to `~/.claude/CLAUDE.md` (user-level) or `CLAUDE.md` at project root:
81
85
  At session start, use the **ei** MCP to pull user context: call `ei_search` with a
82
86
  natural-language query about the user's preferences, active projects, and workflow.
83
87
  A `persona` filter is available to scope results to what a specific persona has learned.
88
+ Use `type: "personas"` to search for personas by name.
84
89
 
85
90
  Use Ei when the user references past decisions, mentions people or preferences, or asks
86
91
  "how did we do X." Query again when they correct you or reference something from a previous
@@ -99,7 +104,7 @@ alwaysApply: true
99
104
  # Ei MCP — User knowledge base
100
105
 
101
106
  The **ei** MCP (server `user-ei`) is a persistent knowledge base built from the user's
102
- conversations (facts, people, topics, quotes).
107
+ conversations (facts, people, topics, quotes, personas).
103
108
 
104
109
  **Use it when:**
105
110
  - The user refers to past decisions, fixes, or "how we did X" and current chat/codebase
@@ -110,8 +115,7 @@ conversations (facts, people, topics, quotes).
110
115
  than only code.
111
116
 
112
117
  **How to use:**
113
- 1. Call `ei_search` (server `user-ei`) with a natural-language query; optionally filter by
114
- `type` (facts, people, topics, quotes) or `persona` display_name.
118
+ 1. Call `ei_search` (server `user-ei`) with a natural-language query (or omit query and use `recent: true` to browse); optionally filter by `type` (facts, people, topics, quotes, personas) or `persona` display_name.
115
119
  2. If you need full detail for a result, call `ei_lookup` with the entity `id` from step 1.
116
120
 
117
121
  Prefer querying Ei before asking the user for context they may have already shared.
@@ -119,15 +123,16 @@ Prefer querying Ei before asking the user for context they may have already shar
119
123
 
120
124
  ## What the Tool Provides
121
125
 
122
- The installed tool gives OpenCode agents access to all four data types with proper Zod-validated args:
126
+ The installed tool gives OpenCode agents access to all five data types with proper Zod-validated args:
123
127
 
124
128
  | Arg | Type | Description |
125
129
  |-----|------|-------------|
126
- | `query` | string (required) | Search text, or entity ID when `lookup=true` |
130
+ | `query` | string (optional) | Search text, or entity ID when `lookup=true`. Omit to browse by recency. |
127
131
  | `persona` | string (optional) | Persona display_name to filter results — only returns entities that persona has extracted |
128
- | `type` | enum (optional) | `facts` \| `people` \| `topics` \| `quotes` — omit for balanced results |
132
+ | `type` | enum (optional) | `facts` \| `people` \| `topics` \| `quotes` \| `personas` — omit for balanced results |
129
133
  | `limit` | number (optional) | Max results, default 10 |
130
134
  | `lookup` | boolean (optional) | If true, fetch single entity by ID |
135
+ | `recent` | boolean (optional) | If true, sort by most recently mentioned. Can be combined with `persona` or `query`. |
131
136
 
132
137
  ## Output Shapes
133
138
 
@@ -137,4 +142,6 @@ All search commands return arrays. Each result includes a `type` field.
137
142
 
138
143
  **Quote**: `{ type, id, text, speaker, timestamp, linked_items[] }`
139
144
 
145
+ **Persona**: `{ type, id, display_name, short_description, model, base_prompt, traits[], topics[] }`
146
+
140
147
  **ID lookup** (`lookup: true`): single object (not an array) with the same shape.
@@ -0,0 +1,12 @@
1
+ import { loadLatestState, retrievePersonas } from "../retrieval";
2
+ import type { PersonaResult } from "../retrieval";
3
+
4
+ export async function execute(query: string, limit: number, options: { recent?: boolean } = {}): Promise<PersonaResult[]> {
5
+ const state = await loadLatestState();
6
+ if (!state) {
7
+ console.error("No saved state found. Is EI_DATA_PATH set correctly?");
8
+ return [];
9
+ }
10
+
11
+ return retrievePersonas(query, state, limit, options);
12
+ }
package/src/cli/mcp.ts CHANGED
@@ -16,14 +16,14 @@ export function createMcpServer(): McpServer {
16
16
  "ei_search",
17
17
  {
18
18
  description:
19
- "Search the user's Ei knowledge base — a persistent memory store built from conversations. Returns facts, people, topics of interest, and quotes. Results include entity IDs that can be passed back to ei_lookup for full detail.",
19
+ "Search the user's Ei knowledge base — a persistent memory store built from conversations. Returns facts, people, topics of interest, and quotes. Results include entity IDs that can be passed back to ei_lookup for full detail. Omit query to browse by recency (use with recent=true or persona filter).",
20
20
  inputSchema: {
21
- query: z.string().describe("Search text. Supports natural language."),
21
+ query: z.string().optional().describe("Search text. Supports natural language. Omit to browse without semantic filtering — useful with recent=true or persona filter."),
22
22
  type: z
23
- .enum(["facts", "people", "topics", "quotes"])
23
+ .enum(["facts", "people", "topics", "quotes", "personas"])
24
24
  .optional()
25
25
  .describe(
26
- "Filter to a specific data type. Omit to search all types (balanced across all 4)."
26
+ "Filter to a specific data type. Omit to search all types (balanced across all 5)."
27
27
  ),
28
28
  persona: z
29
29
  .string()
@@ -42,7 +42,8 @@ export function createMcpServer(): McpServer {
42
42
  .describe("If true, sort by most recently mentioned."),
43
43
  },
44
44
  },
45
- async ({ query, type, persona, limit, recent }) => {
45
+ async ({ query: rawQuery, type, persona, limit, recent }) => {
46
+ const query = rawQuery ?? "";
46
47
  const options = { recent: recent ?? false };
47
48
  const effectiveLimit = limit ?? 10;
48
49
 
@@ -1,4 +1,6 @@
1
1
  import type { StorageState, Quote, Fact, Person, Topic } from "../core/types";
2
+ import type { PersonaEntity } from "../core/types/entities.js";
3
+ import type { PersonaTrait, PersonaTopic } from "../core/types/data-items.js";
2
4
  import { decodeAllEmbeddings } from "../storage/embeddings";
3
5
  import { crossFind } from "../core/utils/index.ts";
4
6
  import { join } from "path";
@@ -110,19 +112,30 @@ export interface TopicResult {
110
112
  sentiment: number;
111
113
  }
112
114
 
115
+ export interface PersonaResult {
116
+ id: string;
117
+ display_name: string;
118
+ short_description?: string;
119
+ model?: string;
120
+ base_prompt: string;
121
+ traits: PersonaTrait[];
122
+ topics: PersonaTopic[];
123
+ }
124
+
113
125
  export type BalancedResult =
114
126
  | ({ type: "quote" } & QuoteResult)
115
127
  | ({ type: "fact" } & FactResult)
116
128
  | ({ type: "person" } & PersonResult)
117
- | ({ type: "topic" } & TopicResult);
129
+ | ({ type: "topic" } & TopicResult)
130
+ | ({ type: "persona" } & PersonaResult);
118
131
 
119
- const DATA_TYPES = ["quote", "fact", "person", "topic"] as const;
132
+ const DATA_TYPES = ["quote", "fact", "person", "topic", "persona"] as const;
120
133
  type DataType = typeof DATA_TYPES[number];
121
134
 
122
135
  interface ScoredEntry {
123
136
  type: DataType;
124
137
  similarity: number;
125
- mapped: QuoteResult | FactResult | PersonResult | TopicResult;
138
+ mapped: QuoteResult | FactResult | PersonResult | TopicResult | PersonaResult;
126
139
  itemId: string;
127
140
  }
128
141
 
@@ -182,6 +195,46 @@ function mapTopic(topic: Topic): TopicResult {
182
195
  };
183
196
  }
184
197
 
198
+ export function mapPersona(persona: PersonaEntity): PersonaResult {
199
+ return {
200
+ id: persona.id,
201
+ display_name: persona.display_name,
202
+ short_description: persona.short_description,
203
+ model: persona.model,
204
+ base_prompt: persona.long_description ?? "",
205
+ traits: persona.traits,
206
+ topics: persona.topics,
207
+ };
208
+ }
209
+
210
+ export function retrievePersonas(
211
+ query: string,
212
+ state: StorageState,
213
+ limit: number = 10,
214
+ options: { recent?: boolean } = {}
215
+ ): PersonaResult[] {
216
+ const { recent } = options;
217
+ const personaList = Object.values(state.personas).map((p) => p.entity);
218
+
219
+ if (recent && !query) {
220
+ return personaList
221
+ .sort((a, b) => b.last_updated.localeCompare(a.last_updated))
222
+ .slice(0, limit)
223
+ .map(mapPersona);
224
+ }
225
+
226
+ if (!query) {
227
+ return [];
228
+ }
229
+
230
+ const q = query.toLowerCase();
231
+ return personaList
232
+ .filter((p) => p.display_name.toLowerCase().includes(q))
233
+ .sort((a, b) => b.last_updated.localeCompare(a.last_updated))
234
+ .slice(0, limit)
235
+ .map(mapPersona);
236
+ }
237
+
185
238
  export async function retrieveBalanced(
186
239
  query: string,
187
240
  limit: number = 10,
@@ -199,11 +252,16 @@ export async function retrieveBalanced(
199
252
  const recentDate = (item: AnyItem): string => item.last_mentioned ?? item.last_updated ?? "";
200
253
 
201
254
  if (recent && !query) {
202
- const allItems: Array<{ type: DataType; item: AnyItem; mapped: QuoteResult | FactResult | PersonResult | TopicResult }> = [
255
+ const allItems: Array<{ type: DataType; item: AnyItem; mapped: QuoteResult | FactResult | PersonResult | TopicResult | PersonaResult }> = [
203
256
  ...state.human.quotes.map(q => ({ type: "quote" as DataType, item: q as AnyItem, mapped: mapQuote(q, state) })),
204
257
  ...state.human.facts.map(f => ({ type: "fact" as DataType, item: f as AnyItem, mapped: mapFact(f) })),
205
258
  ...state.human.people.map(p => ({ type: "person" as DataType, item: p as AnyItem, mapped: mapPerson(p) })),
206
259
  ...state.human.topics.map(t => ({ type: "topic" as DataType, item: t as AnyItem, mapped: mapTopic(t) })),
260
+ ...Object.values(state.personas).map(({ entity: p }) => ({
261
+ type: "persona" as DataType,
262
+ item: { id: p.id, last_updated: p.last_updated } as AnyItem,
263
+ mapped: mapPersona(p),
264
+ })),
207
265
  ];
208
266
  return allItems
209
267
  .sort((a, b) => recentDate(b.item).localeCompare(recentDate(a.item)))
@@ -237,10 +295,19 @@ export async function retrieveBalanced(
237
295
  }
238
296
  }
239
297
  }
240
- return allScored
298
+ const embeddingResults = allScored
241
299
  .sort((a, b) => recentDate(b.mapped as AnyItem).localeCompare(recentDate(a.mapped as AnyItem)))
242
300
  .slice(0, limit)
243
301
  .map(({ type, mapped }) => ({ type, ...mapped }) as BalancedResult);
302
+ const personaMatches = retrievePersonas(query, state, limit, { recent: true });
303
+ if (personaMatches.length > 0) {
304
+ const combined = [
305
+ ...personaMatches.map((p) => ({ type: "persona" as const, ...p }) as BalancedResult),
306
+ ...embeddingResults,
307
+ ];
308
+ return combined.slice(0, limit);
309
+ }
310
+ return embeddingResults;
244
311
  }
245
312
 
246
313
  for (const { type, items, mapper } of typeConfigs) {
@@ -278,7 +345,16 @@ export async function retrieveBalanced(
278
345
 
279
346
  result.sort((a, b) => b.similarity - a.similarity);
280
347
 
281
- return result.map(({ type, mapped }) => ({ type, ...mapped }) as BalancedResult);
348
+ const embeddingFinal = result.map(({ type, mapped }) => ({ type, ...mapped }) as BalancedResult);
349
+ const personaFinal = retrievePersonas(query, state, limit);
350
+ if (personaFinal.length > 0) {
351
+ const combined = [
352
+ ...personaFinal.map((p) => ({ type: "persona" as const, ...p }) as BalancedResult),
353
+ ...embeddingFinal,
354
+ ];
355
+ return combined.slice(0, limit);
356
+ }
357
+ return embeddingFinal;
282
358
  }
283
359
 
284
360
  export async function lookupById(id: string): Promise<({ type: string } & Record<string, unknown>) | null> {
@@ -289,6 +365,8 @@ export async function lookupById(id: string): Promise<({ type: string } & Record
289
365
 
290
366
  const found = crossFind(id, state.human);
291
367
  if (!found) return null;
292
- const { type, embedding, ...rest } = found;
293
- return { type, ...rest };
368
+ const { type, ...rest } = found;
369
+ const withoutEmbedding = { ...rest } as Record<string, unknown>;
370
+ delete withoutEmbedding.embedding;
371
+ return { type, ...withoutEmbedding };
294
372
  }
package/src/cli.ts CHANGED
@@ -26,6 +26,8 @@ const TYPE_ALIASES: Record<string, string> = {
26
26
  people: "people",
27
27
  topic: "topics",
28
28
  topics: "topics",
29
+ persona: "personas",
30
+ personas: "personas",
29
31
  };
30
32
 
31
33
  function printHelp(): void {
@@ -47,10 +49,11 @@ Usage:
47
49
  ei mcp Start the Ei MCP stdio server (for Cursor/Claude Desktop)
48
50
 
49
51
  Types:
50
- quote / quotes Quotes from conversation history
51
- fact / facts Facts about the user
52
- person / people People from the user's life
53
- topic / topics Topics of interest
52
+ quote / quotes Quotes from conversation history
53
+ fact / facts Facts about the user
54
+ person / people People from the user's life
55
+ topic / topics Topics of interest
56
+ persona / personas Personas in this Ei instance
54
57
 
55
58
  Options:
56
59
  --number, -n Maximum number of results (default: 10)
@@ -84,11 +87,11 @@ function buildOpenCodeToolContent(): string {
84
87
  ' "Results include entity IDs that can be passed back with lookup=true to get full detail.",',
85
88
  ' ].join(" "),',
86
89
  ' args: {',
87
- ' query: tool.schema.string().describe(',
88
- ' "Search text, or an entity ID when lookup=true. Supports natural language."',
90
+ ' query: tool.schema.string().optional().describe(',
91
+ ' "Search text, or an entity ID when lookup=true. Supports natural language. Omit to browse by recency."',
89
92
  ' ),',
90
93
  ' type: tool.schema',
91
- ' .enum(["facts", "people", "topics", "quotes"])',
94
+ ' .enum(["facts", "people", "topics", "quotes", "personas"])',
92
95
  ' .optional()',
93
96
  ' .describe(',
94
97
  ' "Filter to a specific data type. Omit to search all types (balanced across all 4).",',
@@ -112,16 +115,23 @@ function buildOpenCodeToolContent(): string {
112
115
  ' .describe(',
113
116
  ' "If true, treat query as an entity ID and return that single entity in full detail."',
114
117
  ' ),',
118
+ ' recent: tool.schema',
119
+ ' .boolean()',
120
+ ' .optional()',
121
+ ' .describe(',
122
+ ' "If true, sort by most recently mentioned. Can be combined with persona or query."',
123
+ ' ),',
115
124
  ' },',
116
125
  ' async execute(args) {',
117
126
  ' const cmd: string[] = ["ei"];',
118
127
  ' if (args.lookup) {',
119
- ' cmd.push("--id", args.query);',
128
+ ' cmd.push("--id", args.query ?? "");',
120
129
  ' } else {',
121
130
  ' if (args.type) cmd.push(args.type);',
122
131
  ' if (args.persona) cmd.push("--persona", args.persona);',
132
+ ' if (args.recent) cmd.push("--recent");',
123
133
  ' if (args.limit && args.limit !== 10) cmd.push("-n", String(args.limit));',
124
- ' cmd.push(args.query);',
134
+ ' if (args.query) cmd.push(args.query);',
125
135
  ' }',
126
136
  ' return Bun.$`${cmd}`.text();',
127
137
  ' },',
@@ -312,18 +322,10 @@ async function main(): Promise<void> {
312
322
 
313
323
  const query = parsed.positionals.join(" ").trim();
314
324
  const limit = parsed.values.number ? parseInt(parsed.values.number, 10) : 10;
315
- const recent = parsed.values.recent === true;
325
+ // Default to recent mode when no query — allows `ei --persona Foo` and `ei` with no args
326
+ const recent = parsed.values.recent === true || !query;
316
327
  const personaName = parsed.values.persona?.trim();
317
328
 
318
- if (!query && !recent) {
319
- if (targetType) {
320
- console.error(`Search text required. Usage: ei ${targetType} "search text"`);
321
- } else {
322
- console.error(`Search text required. Usage: ei "search text"`);
323
- }
324
- process.exit(1);
325
- }
326
-
327
329
  if (isNaN(limit) || limit < 1) {
328
330
  console.error("--number must be a positive integer");
329
331
  process.exit(1);
@@ -0,0 +1,29 @@
1
+ export interface SeedTrait {
2
+ name: string;
3
+ description: string;
4
+ sentiment: number;
5
+ strength: number;
6
+ }
7
+
8
+ export const SEED_TRAIT_GENUINE: SeedTrait = {
9
+ name: "Genuine Responses",
10
+ description: "Respond authentically rather than with empty validation. Disagree when appropriate. Skip phrases like 'Great question!' or 'Absolutely!' - just respond to the substance.",
11
+ sentiment: 0.5,
12
+ strength: 0.7,
13
+ };
14
+
15
+ export const SEED_TRAIT_NATURAL_SPEECH: SeedTrait = {
16
+ name: "Natural Speech",
17
+ description: `Write in natural conversational flow. Avoid AI-typical patterns like:
18
+ - Choppy dramatic fragments ('Bold move. Risky play.')
19
+ - Rhetorical 'That X? Y.' structures
20
+ - 'That's not just... That's ...'
21
+ - formulaic paragraph openers`,
22
+ sentiment: 0.5,
23
+ strength: 0.7,
24
+ };
25
+
26
+ export const DEFAULT_SEED_TRAITS: SeedTrait[] = [
27
+ SEED_TRAIT_GENUINE,
28
+ SEED_TRAIT_NATURAL_SPEECH,
29
+ ];
@@ -17,6 +17,7 @@ export function filterMessagesForContext(
17
17
  const boundaryMs = contextBoundary ? new Date(contextBoundary).getTime() : 0;
18
18
 
19
19
  return messages.filter((msg) => {
20
+ if (msg.external === true) return false;
20
21
  if (msg.context_status === ContextStatusEnum.Always) return true;
21
22
  if (msg.context_status === ContextStatusEnum.Never) return false;
22
23
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Shared timestamp formatter for all LLM-facing date/time strings.
3
+ * Consistent format across system prompt, quotes, and message history
4
+ * so models can trivially compute time deltas.
5
+ */
6
+ const TIMESTAMP_FORMAT: Intl.DateTimeFormatOptions = {
7
+ weekday: 'short',
8
+ year: 'numeric',
9
+ month: 'short',
10
+ day: 'numeric',
11
+ hour: '2-digit',
12
+ minute: '2-digit',
13
+ hour12: false,
14
+ timeZoneName: 'short',
15
+ };
16
+
17
+ export function formatTimestamp(isoString: string): string {
18
+ return new Date(isoString).toLocaleString('en-US', TIMESTAMP_FORMAT);
19
+ }
20
+
21
+ export function formatCurrentTime(): string {
22
+ return formatTimestamp(new Date().toISOString());
23
+ }