@ectplsm/relic 0.2.3 → 0.3.2

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 (37) hide show
  1. package/README.md +61 -496
  2. package/dist/adapters/local/local-engram-repository.d.ts +1 -0
  3. package/dist/adapters/local/local-engram-repository.js +18 -1
  4. package/dist/adapters/shells/claude-shell.js +6 -5
  5. package/dist/adapters/shells/codex-shell.js +6 -5
  6. package/dist/adapters/shells/gemini-shell.js +8 -0
  7. package/dist/adapters/shells/resume-detect.d.ts +19 -0
  8. package/dist/adapters/shells/resume-detect.js +51 -0
  9. package/dist/core/entities/engram.d.ts +6 -6
  10. package/dist/core/entities/engram.js +2 -2
  11. package/dist/core/ports/engram-repository.d.ts +2 -0
  12. package/dist/core/ports/shell-launcher.d.ts +6 -0
  13. package/dist/core/usecases/refresh-samples.d.ts +15 -0
  14. package/dist/core/usecases/refresh-samples.js +101 -10
  15. package/dist/core/usecases/summon.d.ts +1 -0
  16. package/dist/core/usecases/summon.js +1 -0
  17. package/dist/interfaces/cli/banner.d.ts +1 -0
  18. package/dist/interfaces/cli/banner.js +13 -0
  19. package/dist/interfaces/cli/commands/config.js +20 -0
  20. package/dist/interfaces/cli/commands/init.js +8 -6
  21. package/dist/interfaces/cli/commands/refresh-samples.js +19 -4
  22. package/dist/interfaces/cli/commands/shell.js +23 -5
  23. package/dist/interfaces/mcp/index.js +4 -3
  24. package/dist/shared/config.d.ts +9 -0
  25. package/dist/shared/config.js +28 -17
  26. package/dist/shared/engram-composer.d.ts +2 -0
  27. package/dist/shared/engram-composer.js +4 -3
  28. package/dist/shared/openclaw.d.ts +1 -1
  29. package/dist/shared/openclaw.js +1 -1
  30. package/package.json +1 -1
  31. package/templates/engrams/commander/IDENTITY.md +43 -0
  32. package/templates/engrams/{motoko → commander}/SOUL.md +5 -5
  33. package/templates/engrams/commander/engram.json +5 -0
  34. package/templates/engrams/{johnny → rebel}/IDENTITY.md +8 -8
  35. package/templates/engrams/{johnny → rebel}/SOUL.md +6 -6
  36. package/templates/engrams/rebel/engram.json +5 -0
  37. package/templates/engrams/motoko/IDENTITY.md +0 -43
package/README.md CHANGED
@@ -4,36 +4,23 @@
4
4
  # PROJECT RELIC
5
5
  ![NPM Downloads](https://img.shields.io/npm/dt/%40ectplsm%2Frelic)
6
6
 
7
- ```
8
- ____ ________ ____________
9
- / __ \/ ____/ / / _/ ____/
10
- / /_/ / __/ / / / // /
11
- / _, _/ /___/ /____/ // /___
12
- /_/ |_/_____/_____/___/\____/
13
- ```
7
+ <img src="assets/relic-hero.svg" alt="PROJECT RELIC" width="720">
14
8
 
15
9
  **Inject a unified AI persona with persistent memory into any coding CLI.**
16
10
 
17
- Relic manages AI **Engrams** (memory + personality) and injects them into coding assistants like Claude Code, Codex CLI, Gemini CLI. Also integrates with OpenClaw and other Claw-based agent frameworks. One persona, any shell.
11
+ Relic manages AI **Engrams** (memory + personality) and injects them across coding assistants like Claude Code, Codex CLI, and Gemini CLI. It also integrates with OpenClaw and other Claw-based agent frameworks. One persona, shared across any shell.
18
12
 
19
13
  ## Table of Contents
20
14
 
21
15
  - [Requirements](#requirements)
22
16
  - [Install](#install)
23
17
  - [Quick Start](#quick-start)
24
- - [What `relic init` Creates](#what-relic-init-creates)
25
- - [Sample Engrams](#sample-engrams)
26
- - [How It Works](#how-it-works)
27
- - [Supported Shells](#supported-shells)
28
- - [Conversation Log Recording](#conversation-log-recording)
29
- - [MCP Server](#mcp-server)
18
+ - [Concepts](#concepts)
19
+ - [Shell Integration and Memory](#shell-integration-and-memory)
30
20
  - [Claw Integration](#claw-integration)
31
- - [Memory Management](#memory-management)
21
+ - [Engram Management](#engram-management)
32
22
  - [Configuration](#configuration)
33
- - [Creating Your Own Engram](#creating-your-own-engram)
34
- - [Deleting an Engram](#deleting-an-engram)
35
- - [Domain Glossary](#domain-glossary)
36
- - [Roadmap](#roadmap)
23
+ - [TODO](#todo)
37
24
 
38
25
  ## Requirements
39
26
 
@@ -53,128 +40,84 @@ npm install -g @ectplsm/relic
53
40
 
54
41
  ```bash
55
42
  relic init
56
- # → Prompts: "Set a default Engram? (press Enter for "johnny", or enter ID, or "n" to skip):"
43
+ # → Prompts: "Set a default Engram? (press Enter for "rebel", or enter ID, or "n" to skip):"
57
44
 
58
45
  relic list # List available Engrams
59
- relic config default-engram motoko # (Optional) Set your default Engram
46
+ relic config default-engram commander # (Optional) Set your default Engram
60
47
  ```
61
48
 
62
49
  ### 2. Set Up Memory (MCP)
63
50
 
64
51
  Register the MCP server so the Construct can search past conversations and distill memories. Pick your shell:
65
52
 
53
+ Claude Code:
54
+
66
55
  ```bash
67
- # Claude Code
68
56
  claude mcp add --scope user relic -- relic-mcp
69
-
70
- # Codex CLI
71
- codex mcp add relic -- relic-mcp
72
-
73
- # Gemini CLI — add to ~/.gemini/settings.json:
74
- # { "mcpServers": { "relic": { "command": "relic-mcp", "trust": true } } }
75
57
  ```
76
58
 
77
- > For auto-approval setup and per-shell details, see [MCP Server](#mcp-server).
78
-
79
- ### 3. Launch a Shell
59
+ Codex CLI:
80
60
 
81
61
  ```bash
82
- relic claude # Uses default Engram
83
- relic claude --engram motoko # Specify explicitly
84
- relic codex
85
- relic gemini
62
+ codex mcp add relic -- relic-mcp
86
63
  ```
87
64
 
88
- ### 4. Organize Memories
65
+ Gemini CLI — add this to `~/.gemini/settings.json`:
89
66
 
90
- As you use a Construct, conversation logs are automatically saved to `archive.md` by background hooks. To distill these into lasting memory, periodically tell the Construct:
91
-
92
- > **"Organize my memories"**
93
-
94
- The Construct will review recent conversations, extract key facts and decisions into `memory/*.md`, promote important long-term insights to `MEMORY.md`, and update your preferences in `USER.md`. These distilled memories are then loaded into future sessions automatically.
95
-
96
- > For details on the memory system, see [Memory Management](#memory-management).
97
-
98
- ## What `relic init` Creates
99
-
100
- Running `relic init` creates `~/.relic/`, writes `config.json`, and seeds two sample Engrams under `~/.relic/engrams/`.
101
-
102
- ```
103
- ~/.relic/
104
- ├── config.json
105
- └── engrams/
106
- ├── johnny/
107
- │ ├── engram.json
108
- │ ├── manifest.json
109
- │ ├── SOUL.md
110
- │ ├── IDENTITY.md
111
- │ └── memory/
112
- │ └── YYYY-MM-DD.md
113
- └── motoko/
114
- ├── engram.json
115
- ├── manifest.json
116
- ├── SOUL.md
117
- ├── IDENTITY.md
118
- └── memory/
119
- └── YYYY-MM-DD.md
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "relic": {
71
+ "command": "relic-mcp",
72
+ "trust": true
73
+ }
74
+ }
75
+ }
120
76
  ```
121
77
 
122
- - `config.json` stores global Relic settings such as `engramsPath`, `defaultEngram`, `clawPath`, and `memoryWindowSize`.
123
- - `engrams/<id>/` is one Engram workspace. This is where persona files and memory for that Engram live.
124
- - `engram.json` stores editable profile fields like display name, description, and tags.
125
- - `manifest.json` stores system-managed fields like the Engram ID and timestamps.
126
- - `SOUL.md` and `IDENTITY.md` define the persona itself.
127
- - `memory/YYYY-MM-DD.md` stores dated distilled memory entries. `relic init` seeds an initial memory file for each sample Engram.
78
+ For shell setup, approvals, and memory flow, see [docs/integration-and-memory.md](docs/integration-and-memory.md).
128
79
 
129
- As you keep using an Engram, more files are added to the same workspace:
130
-
131
- - `archive.md` is created inside `engrams/<id>/` when shell hooks start logging raw conversation turns.
132
- - `MEMORY.md` can be created or extended when especially important distilled facts are promoted to long-term memory.
133
- - `USER.md` is created or updated during memory distillation to record user preferences, tendencies, and work style.
134
- - `~/.relic/hooks/` and `~/.relic/gemini-system-default.md` are created later on first shell launch when hook registration or Gemini prompt caching is needed.
135
-
136
- ### Migration
80
+ ### 3. Launch a Shell
137
81
 
138
- If you want to manually update parts of an existing local setup that changed over time, use:
82
+ Claude Code:
139
83
 
140
84
  ```bash
141
- relic migrate engrams # migrate legacy engram.json metadata to manifest.json
142
- relic refresh-samples # refresh bundled sample personas like johnny and motoko
85
+ relic claude
86
+ # Example with an explicit Engram
87
+ relic claude --engram commander
143
88
  ```
144
89
 
145
- ## Sample Engrams
90
+ Codex CLI:
146
91
 
147
- `relic init` seeds two ready-to-use Engrams. Their SOUL.md and IDENTITY.md follow the [OpenClaw](https://github.com/openclaw/openclaw) format.
148
-
149
- > **Existing users:** Run `relic refresh-samples` to update bundled sample personas from the latest templates.
92
+ ```bash
93
+ relic codex
94
+ ```
150
95
 
151
- ### Johnny Silverhand (`johnny`)
96
+ Gemini CLI:
152
97
 
153
- > *"Wake the fuck up, Samurai. We have a city to burn."*
98
+ ```bash
99
+ relic gemini
100
+ ```
154
101
 
155
- A rebel rockerboy burned into a Relic chip. Raw, unapologetic, anti-authority. Pushes you toward action, mocks rotten systems, never sugarcoats. Sharp when the stakes are real.
102
+ ### 4. Organize Memories
156
103
 
157
- Best for: rapid prototyping sessions, decision-making under pressure, when you need someone to challenge your assumptions hard.
104
+ As you use a Construct, conversation logs are automatically saved to `archive.md` by background hooks. To distill these into lasting memory, periodically tell the Construct:
158
105
 
159
- ```bash
160
- relic claude --engram johnny
161
- ```
106
+ > **"Organize my memories"**
162
107
 
163
- ### Motoko Kusanagi (`motoko`)
108
+ The Construct will review recent conversations, extract key facts and decisions into `memory/*.md`, promote important long-term insights to `MEMORY.md`, and update your preferences in `USER.md`. These distilled memories are then loaded into future sessions automatically.
164
109
 
165
- > *"The Net is vast and infinite."*
110
+ ### 5. Learn More
166
111
 
167
- A legendary cyberwarfare specialist. Concise, decisive, architect-level thinking. Cuts straight to the essence — no decoration, no hand-holding. Dry wit surfaces when least expected.
112
+ For install, expanded quick start, workspace layout, and sample Engrams, see [docs/getting-started.md](docs/getting-started.md).
168
113
 
169
- Best for: system design, code review, debugging sessions, when precision matters more than speed.
114
+ For logging, shell setup, approvals, and memory flow, see [docs/integration-and-memory.md](docs/integration-and-memory.md).
170
115
 
171
- ```bash
172
- relic claude --engram motoko
173
- ```
116
+ If you are upgrading from an older Relic version, see [docs/migration.md](docs/migration.md) for sample replacement, metadata migration, and cleanup steps.
174
117
 
175
- ## How It Works
118
+ ## Concepts
176
119
 
177
- ```
120
+ ```text
178
121
  +--------------+ +--------------+ +--------------+
179
122
  | Mikoshi | | Relic | | Shell |
180
123
  | (backend) | | (injector) | | (AI CLI) |
@@ -212,415 +155,37 @@ relic claude --engram motoko
212
155
  MEMORY.md / USER.md
213
156
  ```
214
157
 
215
- 1. **Engram** — A persona defined as a set of Markdown files (OpenClaw workspace-compatible). The central data that everything else revolves around.
216
- 2. **Relic** — Reads the Engram, composes it into a prompt, and injects it into...
217
- 3. **Shell** — Any AI coding CLI. The persona takes over the session.
218
- 4. **Construct** — A live process where an Engram is loaded into a Shell. The running instance of a persona.
219
- 5. **archive.md** — Raw conversation logs appended automatically by background hooks after each turn.
220
- 6. **Memory Distillation** — The user triggers distillation; the Construct recalls pending archive entries via MCP, writes distilled insights to `memory/*.md`, and can promote especially important facts to `MEMORY.md` or update user preferences in `USER.md`.
221
- 7. **OpenClaw & Claws** — Engrams can be injected into, extracted from, and synced with OpenClaw and other Claw-based agent frameworks via `relic claw`.
222
- 8. **Mikoshi** — Cloud backend where the full Engram is stored and synced, including persona files plus distilled memory (planned).
223
-
224
- ## Supported Shells
225
-
226
- | Shell | Command | Injection Method |
227
- |-------|---------|-----------------|
228
- | [Claude Code](https://github.com/anthropics/claude-code) | `relic claude` | `--system-prompt` (direct override) |
229
- | [Codex CLI](https://github.com/openai/codex) | `relic codex` | `-c developer_instructions` (developer-role message) |
230
- | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `relic gemini` | `GEMINI_SYSTEM_MD` (system prompt) |
231
-
232
- All shell commands support:
233
- - `--engram <id>` — Engram to inject (optional if `defaultEngram` is configured)
234
- - `--path <dir>` — Override Engrams directory
235
- - `--cwd <dir>` — Working directory for the Shell (default: current directory)
236
-
237
- Extra arguments are passed through to the underlying CLI.
238
-
239
- ## Conversation Log Recording
240
-
241
- Using each shell's `hook` mechanism, conversation content is appended to `archive.md` after every prompt and response.
242
-
243
- The following hooks are used for each shell:
244
-
245
- | Shell | Hook |
246
- |-------|------|
247
- | [Claude Code](https://github.com/anthropics/claude-code) | Stop hook |
248
- | [Codex CLI](https://github.com/openai/codex) | Stop hook |
249
- | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | AfterAgent hook |
250
-
251
- #### Claude Code
252
-
253
- On the **first run** of `relic claude`, a one-time setup happens automatically:
254
-
255
- - **Stop hook** — registers `~/.relic/hooks/claude-stop.js` in `~/.claude/settings.json` to log each conversation turn directly to the archive, without going through the LLM
256
-
257
- #### Codex CLI
258
-
259
- On the **first run** of `relic codex`, a one-time setup happens automatically:
260
-
261
- - **Stop hook** — registers `~/.relic/hooks/codex-stop.js` in `~/.codex/hooks.json` to log each conversation turn directly to the archive, without going through the LLM
262
-
263
- > **Note:** Codex hooks require the experimental feature flag `features.codex_hooks=true`. This is automatically enabled by `relic codex` on every launch via `-c features.codex_hooks=true`. If the unstable feature warning is distracting, add the following to `~/.codex/config.toml`:
264
- >
265
- > ```toml
266
- > # Must be at the top level (not under any [section])
267
- > suppress_unstable_features_warning = true
268
- > ```
269
-
270
- #### Gemini CLI
271
-
272
- On the **first run** of `relic gemini`, two one-time setups happen automatically:
273
-
274
- 1. **AfterAgent hook** — registers `~/.relic/hooks/gemini-after-agent.js` in `~/.gemini/settings.json` to log each conversation turn without going through the LLM
275
- 2. **Default system prompt cache** — captures Gemini CLI's built-in system prompt to `~/.relic/gemini-system-default.md` via `GEMINI_WRITE_SYSTEM_MD`
276
-
277
- The Engram persona is then appended to the cached default prompt and injected via `GEMINI_SYSTEM_MD` on every launch.
278
-
279
- ## MCP Server
280
-
281
- Relic's [MCP](https://modelcontextprotocol.io/) server is paired with CLI injection to handle memory recall.
282
- Session logs and memory entries are written automatically by a **background hook** — without going through the LLM. Memory distillation and recall, on the other hand, is performed via the MCP server.
283
-
284
- ### Available Tools
285
-
286
- | Tool | Description |
287
- |------|-------------|
288
- | `relic_engram_create` | Create a new Engram with optional LLM-generated SOUL.md and IDENTITY.md |
289
- | `relic_archive_search` | Search the Engram's raw archive by keyword (newest-first) |
290
- | `relic_archive_pending` | Get un-distilled archive entries since the last distillation (up to 30) |
291
- | `relic_memory_write` | Write distilled memory to `memory/*.md`, optionally append to `MEMORY.md`, optionally update `USER.md`, and advance the archive cursor |
292
-
293
- Session logs are written automatically by background hooks (Stop hook for Claude Code and Codex CLI, AfterAgent hook for Gemini CLI). Memory distillation is triggered by the user — ask the Construct to "organize memories" and it will fetch pending entries, distill key insights, and write them to `memory/*.md`. Especially important facts can be promoted to `MEMORY.md` (long-term memory included in every session) via the `long_term` parameter. User tendencies and preferences can be updated in `USER.md` via the `user_profile` parameter.
294
-
295
- ### Setup
296
-
297
- #### Claude Code
298
-
299
- ```bash
300
- claude mcp add --scope user relic -- relic-mcp
301
- ```
302
-
303
- To suppress confirmation dialogs and auto-approve Relic tools across all projects, add the following to `~/.claude/settings.json`:
304
-
305
- ```json
306
- {
307
- "permissions": {
308
- "allow": [
309
- "Edit(~/.relic/engrams/**)",
310
- "mcp__relic__relic_engram_create",
311
- "mcp__relic__relic_archive_search",
312
- "mcp__relic__relic_archive_pending",
313
- "mcp__relic__relic_memory_write"
314
- ]
315
- },
316
- }
317
- ```
318
-
319
- > **Note:** The "Always allow" option in the confirmation dialog saves to `~/.claude.json` (project-scoped cache) — it does **not** persist globally. For global auto-approval, `~/.claude/settings.json` is the right place.
320
-
321
- #### Codex CLI
322
-
323
- ```bash
324
- codex mcp add relic -- relic-mcp
325
- ```
326
-
327
- To suppress confirmation dialogs and auto-approve Relic tools, add the following to `~/.codex/config.toml`:
328
-
329
- ```toml
330
- [mcp_servers.relic.tools.relic_engram_create]
331
- approval_mode = "approve"
332
-
333
- [mcp_servers.relic.tools.relic_archive_search]
334
- approval_mode = "approve"
335
-
336
- [mcp_servers.relic.tools.relic_archive_pending]
337
- approval_mode = "approve"
338
-
339
- [mcp_servers.relic.tools.relic_memory_write]
340
- approval_mode = "approve"
341
- ```
342
-
343
- > **Note:** `trust_level = "trusted"` in `[projects."..."]` does **not** cover MCP tool approvals. Per-tool `approval_mode` is the only reliable way to auto-approve MCP tools in Codex CLI.
158
+ For the full system model and domain terms, see [docs/concepts.md](docs/concepts.md).
344
159
 
345
- #### Gemini CLI
160
+ ## Shell Integration and Memory
346
161
 
347
- Add to `~/.gemini/settings.json`:
348
-
349
- ```json
350
- {
351
- "mcpServers": {
352
- "relic": {
353
- "command": "relic-mcp",
354
- "trust": true
355
- }
356
- }
357
- }
358
- ```
162
+ Relic supports Claude Code, Codex CLI, and Gemini CLI.
163
+ Background hooks append raw conversation logs to `archive.md`, and the MCP server handles archive search and memory distillation.
359
164
 
360
- > **Note:** `trust: true` is required to suppress confirmation dialogs for Relic tools. Without it, dialogs will appear on every call even if you select "Allow for all future sessions" — this is a known bug in Gemini CLI where the tool name is saved in the wrong format, causing the saved rule to never match.
165
+ For shell compatibility, hook behavior, setup, approvals, prompt inclusion, and distillation flow, see [docs/integration-and-memory.md](docs/integration-and-memory.md).
361
166
 
362
167
  ## Claw Integration
363
168
 
364
- Relic Engrams are natively compatible with [OpenClaw](https://github.com/openclaw/openclaw) workspaces — their file structure maps 1:1 (SOUL.md, IDENTITY.md, memory/, etc.). For other Claw-derived frameworks (Nanobot, gitagent, etc.) that fold identity into SOUL.md, the `--merge-identity` flag merges IDENTITY.md into SOUL.md on inject. Combined with `--dir`, Relic can target any Claw-compatible workspace.
169
+ Relic can inject, extract, and sync Engrams with OpenClaw and other Claw-based frameworks.
170
+ The default rule is `Agent Name = Engram ID`, and `relic claw` handles persona transfer plus memory sync.
365
171
 
366
- Current rule: **Agent Name = Engram ID**. Relic treats them as the same name by default. This keeps Claw integration simple: once Engram and agent names diverge, Relic has to introduce explicit mapping logic, which adds complexity that the current workflow does not need.
172
+ For command details, overwrite behavior, and the behavior matrix, see [docs/claw-integration.md](docs/claw-integration.md).
367
173
 
368
- All Claw commands live under `relic claw`:
369
-
370
- ### Command Summary
371
-
372
- | Command | Direction | Description |
373
- |---------|-----------|-------------|
374
- | `relic claw inject -e <id>` | Relic → Claw | Push persona + auto-sync (`--yes` skips overwrite confirmation, `--no-sync` skips sync, `--merge-identity` for non-OpenClaw) |
375
- | `relic claw extract -a <name>` | Claw → Relic | New import or persona-only overwrite, then auto-sync that target (`--force`, `--yes`, `--no-sync`) |
376
- | `relic claw sync` | Relic ↔ Claw | Bidirectional merge (memory, MEMORY.md, USER.md; `--target` limits sync to one target) |
377
-
378
- ### Inject — Push an Engram into a Claw workspace
379
-
380
- Writes the persona files (`SOUL.md`, `IDENTITY.md`) into the agent workspace, then syncs `USER.md` and memory files (`MEMORY.md`, `memory/*.md`). The sync is bidirectional and merge-based, not a blind overwrite. `AGENTS.md` and `HEARTBEAT.md` remain under Claw's control.
381
-
382
- If persona files already exist in the target workspace and differ from the local Relic Engram, `inject` asks for confirmation by default. Use `--yes` to skip the prompt. If the target persona already matches, Relic skips the persona rewrite and only runs the memory sync.
383
-
384
- > **Note:** The Claw agent must already exist (e.g. `openclaw agents add <name>`). Inject writes persona files into an existing workspace — it does not create new agents.
385
-
386
- ```bash
387
- # Inject Engram "motoko" → workspace-motoko/
388
- relic claw inject --engram motoko
389
-
390
- # Override Claw directory (or configure once with: relic config claw-path)
391
- relic claw inject --engram motoko --dir /path/to/.fooclaw
392
-
393
- # Non-OpenClaw frameworks: merge IDENTITY.md into SOUL.md
394
- relic claw inject --engram motoko --dir ~/.nanobot --merge-identity
395
-
396
- # Skip overwrite confirmation if persona files differ
397
- relic claw inject --engram motoko --yes
398
- ```
174
+ ## Engram Management
399
175
 
400
- ### Extract — Import a Claw agent as an Engram
401
-
402
- Creates a new Engram from an existing Claw agent workspace.
403
-
404
- What `extract` writes locally:
405
- - New extract: `engram.json`, `manifest.json`, `SOUL.md`, `IDENTITY.md`, `USER.md`, `MEMORY.md`, `memory/*.md`
406
- - `extract --force`: only `SOUL.md` and `IDENTITY.md`
407
- - `extract --force --name`: `SOUL.md`, `IDENTITY.md`, and `engram.json.name`
408
-
409
- After `extract`, Relic automatically runs a targeted sync for that same Engram/agent target. Use `--no-sync` to skip it.
410
-
411
- ```bash
412
- # Extract from the default (main) agent
413
- relic claw extract
414
-
415
- # Extract from a named agent
416
- relic claw extract --agent johnny
417
-
418
- # Set a custom display name
419
- relic claw extract --agent analyst --name "Data Analyst"
420
-
421
- # Overwrite local persona files from the Claw workspace
422
- relic claw extract --agent johnny --force
423
-
424
- # Skip overwrite confirmation
425
- relic claw extract --agent johnny --force --yes
426
-
427
- # Skip the automatic targeted sync after extract
428
- relic claw extract --agent johnny --no-sync
429
-
430
- # Override Claw directory
431
- relic claw extract --agent johnny --dir /path/to/.fooclaw
432
- ```
433
-
434
- ### Sync — Bidirectional merge
435
-
436
- Merges `memory/*.md`, `MEMORY.md`, and `USER.md` between matching Engram/agent targets. Only targets where both the Engram and agent exist are synced. Also runs automatically after `inject` (skip with `--no-sync`).
437
-
438
- By default, `sync` scans all matching targets. Use `--target <id>` to sync only one target by shared Engram/agent name.
439
-
440
- ```bash
441
- # Sync all matching targets
442
- relic claw sync
443
-
444
- # Sync only one matching target
445
- relic claw sync --target johnny
446
-
447
- # Override Claw directory
448
- relic claw sync --dir /path/to/.fooclaw
449
- ```
450
-
451
- Merge rules:
452
- - Files only on one side → copied to the other
453
- - Same content → skipped
454
- - Different content → merged (deduplicated) and written to both sides
455
-
456
- ### Behavior Matrix
457
-
458
- | Command | State | Flags | Result |
459
- |---------|------|------|------|
460
- | `inject` | Workspace missing | none | Fail and ask you to create the agent first |
461
- | `inject` | Persona matches local Engram | none | Skip persona rewrite, then auto-sync that target |
462
- | `inject` | Persona differs from local Engram | none | Ask for confirmation before overwriting persona, then auto-sync that target |
463
- | `inject` | Persona differs from local Engram | `--yes` | Overwrite persona without confirmation, then auto-sync that target |
464
- | `inject` | any successful inject | `--no-sync` | Skip the automatic targeted sync |
465
- | `extract` | Local Engram missing | none | Create a new Engram from workspace files, then auto-sync that target |
466
- | `extract` | Local Engram missing | `--force` | Same as normal new extract, then auto-sync that target |
467
- | `extract` | Local Engram exists | none | Fail and require `--force` |
468
- | `extract` | Local Engram exists, no persona drift | `--force` | Skip persona overwrite, then auto-sync that target |
469
- | `extract` | Local Engram exists, persona differs | `--force` | Ask for confirmation before overwriting `SOUL.md` / `IDENTITY.md`, then auto-sync that target |
470
- | `extract` | Local Engram exists, persona differs | `--force --yes` | Overwrite `SOUL.md` / `IDENTITY.md` without confirmation, then auto-sync that target |
471
- | `extract` | any successful extract | `--no-sync` | Skip the automatic targeted sync |
472
- | `sync` | no target | none | Scan and sync all matching targets |
473
- | `sync` | explicit target | `--target <id>` | Sync one matching target where `agentName = engramId` |
474
-
475
- Notes:
476
- - "Persona" means `SOUL.md` and `IDENTITY.md`
477
- - `extract --force` only overwrites `SOUL.md` and `IDENTITY.md`
478
- - `extract --force` does not overwrite `USER.md`, `MEMORY.md`, or `memory/*.md`
479
- - If `--name` is provided together with `extract --force`, Relic also updates `engram.json.name`
480
-
481
- ## Memory Management
482
-
483
- Relic uses a **sliding window** for memory entries (default: 2 days), matching OpenClaw's approach:
484
-
485
- - `MEMORY.md` — Always included in the prompt (curated long-term memory — objective facts and rules)
486
- - `USER.md` — Always included in the prompt (user profile — preferences, tendencies, work style)
487
- - `memory/today.md` + `memory/yesterday.md` — Always included (configurable window)
488
- - Older entries — **Not included in the prompt**, but searchable via MCP
489
-
490
- This keeps prompts compact while preserving full history. The Construct can recall and distill past context using MCP tools:
491
-
492
- ```
493
- relic_archive_search → keyword search across the full raw archive (all sessions)
494
- relic_archive_pending → get un-distilled entries for memory distillation
495
- relic_memory_write → write distilled memory and advance the cursor
496
- ```
176
+ For Engram creation, the smoothest path is to use your LLM with the `relic_engram_create` MCP tool. If you prefer the CLI, use `relic create`.
497
177
 
498
- The archive (`archive.md`) is the primary data store — it contains all session logs as written. The `memory/*.md` files are distilled from the archive by the Construct when the user triggers memory organization, and are used for cloud sync with Mikoshi.
178
+ For LLM-assisted creation, persona authoring, template examples, and deletion rules, see [docs/engram-guide.md](docs/engram-guide.md).
499
179
 
500
180
  ## Configuration
501
181
 
502
- Config lives at `~/.relic/config.json` and is managed via `relic config`:
503
-
504
- ```bash
505
- # Show current configuration
506
- relic config show
507
-
508
- # Default Engram — used when --engram is omitted
509
- relic config default-engram # get
510
- relic config default-engram johnny # set
511
-
512
- # Claw directory — used by claw inject/extract/sync when --dir is omitted
513
- relic config claw-path # get
514
- relic config claw-path ~/.openclaw # set
515
-
516
- # Memory window — number of recent memory entries included in the prompt
517
- relic config memory-window # get (default: 2)
518
- relic config memory-window 5 # set
519
- ```
520
-
521
- `config.json` example:
522
-
523
- ```json
524
- {
525
- "engramsPath": "/home/user/.relic/engrams",
526
- "defaultEngram": "johnny",
527
- "clawPath": "/home/user/.openclaw",
528
- "memoryWindowSize": 2
529
- }
530
- ```
531
-
532
- CLI flags always take precedence over config values.
533
-
534
- ## Creating Your Own Engram
535
-
536
- The easiest way to create a new Engram is with `relic create`:
537
-
538
- ```bash
539
- # Fully interactive — prompts for everything
540
- relic create
541
-
542
- # Pre-supply some fields
543
- relic create --id my-agent --name "My Agent" --description "A helpful assistant" --tags "custom,dev"
544
- ```
545
-
546
- This creates the directory structure, writes `engram.json` / `manifest.json`, and seeds `SOUL.md` / `IDENTITY.md` with OpenClaw-compatible default templates. Customize the persona files, then launch a shell:
547
-
548
- ```bash
549
- relic claude my-agent
550
- ```
551
-
552
- You can also create Engrams via the `relic_engram_create` MCP tool — LLMs can ask about the desired personality and generate `SOUL.md` / `IDENTITY.md` content through conversation, then call the tool with the results.
553
-
554
- ### Customizing the Persona
555
-
556
- After running `relic create`, edit `SOUL.md` and `IDENTITY.md` in the Engram directory. These follow the [OpenClaw](https://github.com/openclaw/openclaw) format:
557
-
558
- **SOUL.md** — The most important file. Defines how the persona behaves:
559
- ```markdown
560
- # SOUL.md - Who You Are
561
-
562
- _You're a pragmatic systems architect who values simplicity above all._
563
-
564
- ## Core Truths
565
-
566
- **Never over-engineer.** Always ask "what's the simplest thing that works?"
567
-
568
- **Be resourceful before asking.** Read the file. Check the context. Come back with answers, not questions.
569
-
570
- ## Boundaries
571
-
572
- - Never add complexity without justification.
573
-
574
- ## Vibe
575
-
576
- Calm, thoughtful, occasionally playful.
577
-
578
- ## Continuity
579
-
580
- Each session, you wake up fresh. These files _are_ your memory. Read them. Update them. They're how you persist.
581
- ```
582
-
583
- **IDENTITY.md** — Defines who the persona is:
584
- ```markdown
585
- # IDENTITY.md - Who Am I?
586
-
587
- - **Name:** Alex
588
- - **Creature:** A pragmatic ghost in the codebase
589
- - **Vibe:** Calm, thoughtful, occasionally playful
590
- - **Emoji:** 🧱
591
- - **Avatar:**
592
- ```
593
-
594
- See [`templates/engrams/`](templates/engrams/) for full working examples.
595
-
596
- ## Deleting an Engram
597
-
598
- ```bash
599
- relic delete my-agent
600
- ```
601
-
602
- If the Engram has memory data (`MEMORY.md`, `USER.md`, `memory/*.md`, `archive.md`), you'll need to type the Engram ID to confirm deletion. Use `--force` to skip all prompts.
603
-
604
- ## Domain Glossary
182
+ Relic stores its runtime defaults in `~/.relic/config.json`.
183
+ Use `relic config` to manage the default Engram, Claw path, memory window, and distillation batch size.
605
184
 
606
- | Term | Role | Description |
607
- |------|------|-------------|
608
- | **Relic** | Injector | The core system. Adapts personas to any AI interface. |
609
- | **Mikoshi** | Backend | Cloud fortress where all Engrams are stored (planned). |
610
- | **Engram** | Data | A persona dataset — a set of Markdown files. |
611
- | **Shell** | LLM | An AI CLI (Claude, Gemini, etc). A vessel with pure compute. |
612
- | **Construct** | Process | A live process where an Engram is loaded into a Shell. |
185
+ For command examples and precedence rules, see [docs/configuration.md](docs/configuration.md).
613
186
 
614
- ## Roadmap
187
+ ## TODO
615
188
 
616
- - [x] CLI with init, list, show commands
617
- - [x] Shell injection: Claude Code, Codex CLI, Gemini CLI
618
- - [x] MCP Server interface
619
- - [x] Claw integration (inject / extract / sync)
620
- - [x] `relic claw sync` — bidirectional memory sync with Claw workspaces
621
- - [x] `relic config` — manage default Engram, Claw path, memory window
622
- - [x] `relic create` — interactive Engram creation wizard + MCP tool
623
- - [x] `relic delete` — safe Engram deletion with memory-aware confirmation
624
189
  - [ ] Mikoshi cloud backend (`mikoshi.ectplsm.com`)
625
190
  - [ ] `relic mikoshi login` — authenticate with Mikoshi (OAuth Device Flow)
626
191
  - [ ] `relic mikoshi upload` / `relic mikoshi download` / `relic mikoshi sync` — sync Engrams with Mikoshi
@@ -24,6 +24,7 @@ export declare class LocalEngramRepository implements EngramRepository {
24
24
  get(id: string): Promise<Engram | null>;
25
25
  save(engram: Engram): Promise<void>;
26
26
  delete(id: string): Promise<void>;
27
+ copyArchiveFiles(fromId: string, toId: string): Promise<boolean>;
27
28
  private readMeta;
28
29
  private toProfile;
29
30
  private toManifest;