@ectplsm/relic 0.2.2 → 0.3.1

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