@ectplsm/relic 0.1.4 → 0.2.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.
- package/README.md +244 -111
- package/dist/core/usecases/extract.d.ts +21 -22
- package/dist/core/usecases/extract.js +80 -122
- package/dist/core/usecases/index.d.ts +3 -3
- package/dist/core/usecases/index.js +3 -3
- package/dist/core/usecases/inject.d.ts +24 -4
- package/dist/core/usecases/inject.js +73 -20
- package/dist/core/usecases/sync.d.ts +44 -20
- package/dist/core/usecases/sync.js +182 -56
- package/dist/interfaces/cli/commands/claw.d.ts +2 -0
- package/dist/interfaces/cli/commands/claw.js +280 -0
- package/dist/interfaces/cli/commands/config.js +6 -6
- package/dist/interfaces/cli/commands/extract.js +7 -12
- package/dist/interfaces/cli/commands/inject.js +2 -2
- package/dist/interfaces/cli/commands/sync.js +24 -68
- package/dist/interfaces/cli/index.js +2 -6
- package/dist/interfaces/mcp/index.js +14 -0
- package/dist/shared/config.d.ts +7 -7
- package/dist/shared/config.js +18 -58
- package/dist/shared/engram-composer.js +5 -3
- package/dist/shared/openclaw.d.ts +25 -3
- package/dist/shared/openclaw.js +48 -4
- package/package.json +3 -2
- package/templates/engrams/johnny/IDENTITY.md +25 -0
- package/templates/engrams/johnny/SOUL.md +35 -0
- package/templates/engrams/motoko/IDENTITY.md +25 -0
- package/templates/engrams/motoko/SOUL.md +38 -0
package/README.md
CHANGED
|
@@ -13,9 +13,28 @@
|
|
|
13
13
|
|
|
14
14
|
**Inject a unified AI persona with persistent memory into any coding CLI.**
|
|
15
15
|
|
|
16
|
-
Relic manages AI **Engrams** (memory + personality) and injects them into coding assistants like Claude Code, Codex CLI, Gemini CLI. One persona, any shell.
|
|
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.
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Table of Contents
|
|
19
|
+
|
|
20
|
+
- [Install](#install)
|
|
21
|
+
- [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)
|
|
28
|
+
- [Claw Integration](#claw-integration)
|
|
29
|
+
- [Memory Management](#memory-management)
|
|
30
|
+
- [Configuration](#configuration)
|
|
31
|
+
- [Creating Your Own Engram](#creating-your-own-engram)
|
|
32
|
+
- [Domain Glossary](#domain-glossary)
|
|
33
|
+
- [Roadmap](#roadmap)
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
<img alt="version badge" src="https://img.shields.io/github/v/release/ectplsm/relic?filter=*.*.*">
|
|
19
38
|
|
|
20
39
|
```bash
|
|
21
40
|
npm install -g @ectplsm/relic
|
|
@@ -23,27 +42,52 @@ npm install -g @ectplsm/relic
|
|
|
23
42
|
|
|
24
43
|
## Quick Start
|
|
25
44
|
|
|
45
|
+
### 1. Initialize
|
|
46
|
+
|
|
26
47
|
```bash
|
|
27
|
-
# Initialize — creates config and sample Engrams
|
|
28
48
|
relic init
|
|
29
49
|
# → Prompts: "Set a default Engram? (press Enter for "johnny", or enter ID, or "n" to skip):"
|
|
30
50
|
|
|
31
|
-
# List available Engrams
|
|
32
|
-
relic
|
|
51
|
+
relic list # List available Engrams
|
|
52
|
+
relic config default-engram motoko # (Optional) Set your default Engram
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. Set Up Memory (MCP)
|
|
56
|
+
|
|
57
|
+
Register the MCP server so the Construct can search past conversations and distill memories. Pick your shell:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Claude Code
|
|
61
|
+
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
|
+
```
|
|
69
|
+
|
|
70
|
+
> For auto-approval setup and per-shell details, see [MCP Server](#mcp-server).
|
|
33
71
|
|
|
34
|
-
|
|
35
|
-
relic show motoko
|
|
72
|
+
### 3. Launch a Shell
|
|
36
73
|
|
|
37
|
-
|
|
38
|
-
relic claude
|
|
74
|
+
```bash
|
|
75
|
+
relic claude # Uses default Engram
|
|
76
|
+
relic claude --engram motoko # Specify explicitly
|
|
39
77
|
relic codex
|
|
40
78
|
relic gemini
|
|
41
|
-
|
|
42
|
-
# Or specify explicitly
|
|
43
|
-
relic claude --engram motoko
|
|
44
|
-
relic codex --engram johnny
|
|
45
79
|
```
|
|
46
80
|
|
|
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:
|
|
84
|
+
|
|
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.
|
|
88
|
+
|
|
89
|
+
> For details on the memory system, see [Memory Management](#memory-management).
|
|
90
|
+
|
|
47
91
|
## What `relic init` Creates
|
|
48
92
|
|
|
49
93
|
Running `relic init` creates `~/.relic/`, writes `config.json`, and seeds two sample Engrams under `~/.relic/engrams/`.
|
|
@@ -66,7 +110,7 @@ Running `relic init` creates `~/.relic/`, writes `config.json`, and seeds two sa
|
|
|
66
110
|
└── YYYY-MM-DD.md
|
|
67
111
|
```
|
|
68
112
|
|
|
69
|
-
- `config.json` stores global Relic settings such as `engramsPath`, `defaultEngram`, `
|
|
113
|
+
- `config.json` stores global Relic settings such as `engramsPath`, `defaultEngram`, `clawPath`, and `memoryWindowSize`.
|
|
70
114
|
- `engrams/<id>/` is one Engram workspace. This is where persona files and memory for that Engram live.
|
|
71
115
|
- `engram.json` stores metadata like the Engram's ID, display name, description, and tags.
|
|
72
116
|
- `SOUL.md` and `IDENTITY.md` define the persona itself.
|
|
@@ -76,11 +120,14 @@ As you keep using an Engram, more files are added to the same workspace:
|
|
|
76
120
|
|
|
77
121
|
- `archive.md` is created inside `engrams/<id>/` when shell hooks start logging raw conversation turns.
|
|
78
122
|
- `MEMORY.md` can be created or extended when especially important distilled facts are promoted to long-term memory.
|
|
123
|
+
- `USER.md` is created or updated during memory distillation to record user preferences, tendencies, and work style.
|
|
79
124
|
- `~/.relic/hooks/` and `~/.relic/gemini-system-default.md` are created later on first shell launch when hook registration or Gemini prompt caching is needed.
|
|
80
125
|
|
|
81
126
|
## Sample Engrams
|
|
82
127
|
|
|
83
|
-
`relic init` seeds two ready-to-use Engrams
|
|
128
|
+
`relic init` seeds two ready-to-use Engrams. Their SOUL.md and IDENTITY.md follow the [OpenClaw](https://github.com/openclaw/openclaw) format.
|
|
129
|
+
|
|
130
|
+
> **Existing users:** The latest templates are always available in [`templates/engrams/`](templates/engrams/). Copy them over your `~/.relic/engrams/` files to update.
|
|
84
131
|
|
|
85
132
|
### Johnny Silverhand (`johnny`)
|
|
86
133
|
|
|
@@ -118,40 +165,42 @@ relic claude --engram motoko
|
|
|
118
165
|
| | |
|
|
119
166
|
| compose & inject |
|
|
120
167
|
| v v
|
|
121
|
-
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
168
|
+
| ╔═══════════╗ +---------+
|
|
169
|
+
+------------║ Engram ║--------->|Construct|
|
|
170
|
+
| ║ (persona) ║ | (live) |
|
|
171
|
+
| ╚═══════════╝ +---------+
|
|
172
|
+
| SOUL.md claude / codex / gemini
|
|
173
|
+
| IDENTITY.md |
|
|
174
|
+
| USER.md | hooks append logs
|
|
175
|
+
| MEMORY.md |
|
|
176
|
+
| memory/*.md v
|
|
177
|
+
| +-----------+
|
|
178
|
+
inject / |archive.md |
|
|
179
|
+
extract / | raw logs |
|
|
180
|
+
sync +-----------+
|
|
181
|
+
| |
|
|
182
|
+
v MCP recall | user-triggered
|
|
183
|
+
+-----------+ search/pending | distillation
|
|
184
|
+
| OpenClaw | v
|
|
185
|
+
| & Claws | +-----------+
|
|
186
|
+
+-----------+ | distilled |
|
|
187
|
+
|memory/*.md|
|
|
188
|
+
+-----------+
|
|
189
|
+
|
|
|
190
|
+
promote key
|
|
191
|
+
insights
|
|
192
|
+
v
|
|
193
|
+
MEMORY.md / USER.md
|
|
146
194
|
```
|
|
147
195
|
|
|
148
|
-
1. **Engram** — A persona defined as a set of Markdown files (OpenClaw workspace-compatible)
|
|
196
|
+
1. **Engram** — A persona defined as a set of Markdown files (OpenClaw workspace-compatible). The central data that everything else revolves around.
|
|
149
197
|
2. **Relic** — Reads the Engram, composes it into a prompt, and injects it into...
|
|
150
198
|
3. **Shell** — Any AI coding CLI. The persona takes over the session.
|
|
151
199
|
4. **Construct** — A live process where an Engram is loaded into a Shell. The running instance of a persona.
|
|
152
200
|
5. **archive.md** — Raw conversation logs appended automatically by background hooks after each turn.
|
|
153
|
-
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
|
|
154
|
-
7. **
|
|
201
|
+
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`.
|
|
202
|
+
7. **OpenClaw & Claws** — Engrams can be injected into, extracted from, and synced with OpenClaw and other Claw-based agent frameworks via `relic claw`.
|
|
203
|
+
8. **Mikoshi** — Cloud backend where the full Engram is stored and synced, including persona files plus distilled memory (planned).
|
|
155
204
|
|
|
156
205
|
## Supported Shells
|
|
157
206
|
|
|
@@ -177,8 +226,8 @@ The following hooks are used for each shell:
|
|
|
177
226
|
| Shell | Hook |
|
|
178
227
|
|-------|------|
|
|
179
228
|
| [Claude Code](https://github.com/anthropics/claude-code) | Stop hook |
|
|
180
|
-
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | AfterAgent hook |
|
|
181
229
|
| [Codex CLI](https://github.com/openai/codex) | Stop hook |
|
|
230
|
+
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | AfterAgent hook |
|
|
182
231
|
|
|
183
232
|
#### Claude Code
|
|
184
233
|
|
|
@@ -208,7 +257,6 @@ On the **first run** of `relic gemini`, two one-time setups happen automatically
|
|
|
208
257
|
|
|
209
258
|
The Engram persona is then appended to the cached default prompt and injected via `GEMINI_SYSTEM_MD` on every launch.
|
|
210
259
|
|
|
211
|
-
|
|
212
260
|
## MCP Server
|
|
213
261
|
|
|
214
262
|
Relic's [MCP](https://modelcontextprotocol.io/) server is paired with CLI injection to handle memory recall.
|
|
@@ -220,9 +268,9 @@ Session logs and memory entries are written automatically by a **background hook
|
|
|
220
268
|
|------|-------------|
|
|
221
269
|
| `relic_archive_search` | Search the Engram's raw archive by keyword (newest-first) |
|
|
222
270
|
| `relic_archive_pending` | Get un-distilled archive entries since the last distillation (up to 30) |
|
|
223
|
-
| `relic_memory_write` | Write distilled memory to `memory/*.md`, optionally append to `MEMORY.md`, and advance the archive cursor |
|
|
271
|
+
| `relic_memory_write` | Write distilled memory to `memory/*.md`, optionally append to `MEMORY.md`, optionally update `USER.md`, and advance the archive cursor |
|
|
224
272
|
|
|
225
|
-
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.
|
|
273
|
+
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.
|
|
226
274
|
|
|
227
275
|
### Setup
|
|
228
276
|
|
|
@@ -255,6 +303,21 @@ To suppress confirmation dialogs and auto-approve Relic tools across all project
|
|
|
255
303
|
codex mcp add relic -- relic-mcp
|
|
256
304
|
```
|
|
257
305
|
|
|
306
|
+
To suppress confirmation dialogs and auto-approve Relic tools, add the following to `~/.codex/config.toml`:
|
|
307
|
+
|
|
308
|
+
```toml
|
|
309
|
+
[mcp_servers.relic.tools.relic_archive_search]
|
|
310
|
+
approval_mode = "approve"
|
|
311
|
+
|
|
312
|
+
[mcp_servers.relic.tools.relic_archive_pending]
|
|
313
|
+
approval_mode = "approve"
|
|
314
|
+
|
|
315
|
+
[mcp_servers.relic.tools.relic_memory_write]
|
|
316
|
+
approval_mode = "approve"
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
> **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.
|
|
320
|
+
|
|
258
321
|
#### Gemini CLI
|
|
259
322
|
|
|
260
323
|
Add to `~/.gemini/settings.json`:
|
|
@@ -272,83 +335,131 @@ Add to `~/.gemini/settings.json`:
|
|
|
272
335
|
|
|
273
336
|
> **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.
|
|
274
337
|
|
|
275
|
-
##
|
|
338
|
+
## Claw Integration
|
|
276
339
|
|
|
277
|
-
Relic Engrams are
|
|
340
|
+
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.
|
|
278
341
|
|
|
279
|
-
|
|
342
|
+
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.
|
|
280
343
|
|
|
281
|
-
|
|
344
|
+
All Claw commands live under `relic claw`:
|
|
282
345
|
|
|
283
|
-
|
|
346
|
+
### Command Summary
|
|
284
347
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
relic inject
|
|
348
|
+
| Command | Direction | Description |
|
|
349
|
+
|---------|-----------|-------------|
|
|
350
|
+
| `relic claw inject -e <id>` | Relic → Claw | Push persona + auto-sync (`--yes` skips overwrite confirmation, `--no-sync` skips sync, `--merge-identity` for non-OpenClaw) |
|
|
351
|
+
| `relic claw extract -a <name>` | Claw → Relic | New import or persona-only overwrite, then auto-sync that target (`--force`, `--yes`, `--no-sync`) |
|
|
352
|
+
| `relic claw sync` | Relic ↔ Claw | Bidirectional merge (memory, MEMORY.md, USER.md; `--target` limits sync to one target) |
|
|
288
353
|
|
|
289
|
-
|
|
290
|
-
relic inject --engram motoko --to main
|
|
291
|
-
# → agents/main/agent/ receives motoko's persona
|
|
292
|
-
# → extract will create Engram "main", not "motoko"
|
|
354
|
+
### Inject — Push an Engram into a Claw workspace
|
|
293
355
|
|
|
294
|
-
|
|
295
|
-
relic inject --engram motoko --openclaw /path/to/.openclaw
|
|
296
|
-
```
|
|
356
|
+
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.
|
|
297
357
|
|
|
298
|
-
|
|
358
|
+
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.
|
|
299
359
|
|
|
300
|
-
|
|
360
|
+
> **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.
|
|
301
361
|
|
|
302
362
|
```bash
|
|
303
|
-
#
|
|
304
|
-
relic
|
|
363
|
+
# Inject Engram "motoko" → workspace-motoko/
|
|
364
|
+
relic claw inject --engram motoko
|
|
305
365
|
|
|
306
|
-
#
|
|
307
|
-
relic
|
|
366
|
+
# Override Claw directory (or configure once with: relic config claw-path)
|
|
367
|
+
relic claw inject --engram motoko --dir /path/to/.fooclaw
|
|
308
368
|
|
|
309
|
-
#
|
|
310
|
-
relic
|
|
369
|
+
# Non-OpenClaw frameworks: merge IDENTITY.md into SOUL.md
|
|
370
|
+
relic claw inject --engram motoko --dir ~/.nanobot --merge-identity
|
|
311
371
|
|
|
312
|
-
#
|
|
313
|
-
relic
|
|
372
|
+
# Skip overwrite confirmation if persona files differ
|
|
373
|
+
relic claw inject --engram motoko --yes
|
|
314
374
|
```
|
|
315
375
|
|
|
316
|
-
###
|
|
376
|
+
### Extract — Import a Claw agent as an Engram
|
|
377
|
+
|
|
378
|
+
Creates a new Engram from an existing Claw agent workspace.
|
|
379
|
+
|
|
380
|
+
What `extract` writes locally:
|
|
381
|
+
- New extract: `engram.json`, `SOUL.md`, `IDENTITY.md`, `USER.md`, `MEMORY.md`, `memory/*.md`
|
|
382
|
+
- `extract --force`: only `SOUL.md` and `IDENTITY.md`
|
|
383
|
+
- `extract --force --name`: `SOUL.md`, `IDENTITY.md`, and `engram.json.name`
|
|
317
384
|
|
|
318
|
-
|
|
385
|
+
After `extract`, Relic automatically runs a targeted sync for that same Engram/agent target. Use `--no-sync` to skip it.
|
|
319
386
|
|
|
320
387
|
```bash
|
|
321
|
-
#
|
|
322
|
-
relic
|
|
388
|
+
# Extract from the default (main) agent
|
|
389
|
+
relic claw extract
|
|
323
390
|
|
|
324
|
-
#
|
|
325
|
-
relic
|
|
391
|
+
# Extract from a named agent
|
|
392
|
+
relic claw extract --agent johnny
|
|
393
|
+
|
|
394
|
+
# Set a custom display name
|
|
395
|
+
relic claw extract --agent analyst --name "Data Analyst"
|
|
396
|
+
|
|
397
|
+
# Overwrite local persona files from the Claw workspace
|
|
398
|
+
relic claw extract --agent johnny --force
|
|
399
|
+
|
|
400
|
+
# Skip overwrite confirmation
|
|
401
|
+
relic claw extract --agent johnny --force --yes
|
|
402
|
+
|
|
403
|
+
# Skip the automatic targeted sync after extract
|
|
404
|
+
relic claw extract --agent johnny --no-sync
|
|
405
|
+
|
|
406
|
+
# Override Claw directory
|
|
407
|
+
relic claw extract --agent johnny --dir /path/to/.fooclaw
|
|
326
408
|
```
|
|
327
409
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
410
|
+
### Sync — Bidirectional merge
|
|
411
|
+
|
|
412
|
+
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`).
|
|
331
413
|
|
|
332
|
-
|
|
333
|
-
- Watches each agent's `memory/` directory for changes
|
|
334
|
-
- Automatically merges new memory entries into the corresponding Engram
|
|
414
|
+
By default, `sync` scans all matching targets. Use `--target <id>` to sync only one target by shared Engram/agent name.
|
|
335
415
|
|
|
336
|
-
|
|
416
|
+
```bash
|
|
417
|
+
# Sync all matching targets
|
|
418
|
+
relic claw sync
|
|
337
419
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
420
|
+
# Sync only one matching target
|
|
421
|
+
relic claw sync --target johnny
|
|
422
|
+
|
|
423
|
+
# Override Claw directory
|
|
424
|
+
relic claw sync --dir /path/to/.fooclaw
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Merge rules:
|
|
428
|
+
- Files only on one side → copied to the other
|
|
429
|
+
- Same content → skipped
|
|
430
|
+
- Different content → merged (deduplicated) and written to both sides
|
|
431
|
+
|
|
432
|
+
### Behavior Matrix
|
|
433
|
+
|
|
434
|
+
| Command | State | Flags | Result |
|
|
435
|
+
|---------|------|------|------|
|
|
436
|
+
| `inject` | Workspace missing | none | Fail and ask you to create the agent first |
|
|
437
|
+
| `inject` | Persona matches local Engram | none | Skip persona rewrite, then auto-sync that target |
|
|
438
|
+
| `inject` | Persona differs from local Engram | none | Ask for confirmation before overwriting persona, then auto-sync that target |
|
|
439
|
+
| `inject` | Persona differs from local Engram | `--yes` | Overwrite persona without confirmation, then auto-sync that target |
|
|
440
|
+
| `inject` | any successful inject | `--no-sync` | Skip the automatic targeted sync |
|
|
441
|
+
| `extract` | Local Engram missing | none | Create a new Engram from workspace files, then auto-sync that target |
|
|
442
|
+
| `extract` | Local Engram missing | `--force` | Same as normal new extract, then auto-sync that target |
|
|
443
|
+
| `extract` | Local Engram exists | none | Fail and require `--force` |
|
|
444
|
+
| `extract` | Local Engram exists, no persona drift | `--force` | Skip persona overwrite, then auto-sync that target |
|
|
445
|
+
| `extract` | Local Engram exists, persona differs | `--force` | Ask for confirmation before overwriting `SOUL.md` / `IDENTITY.md`, then auto-sync that target |
|
|
446
|
+
| `extract` | Local Engram exists, persona differs | `--force --yes` | Overwrite `SOUL.md` / `IDENTITY.md` without confirmation, then auto-sync that target |
|
|
447
|
+
| `extract` | any successful extract | `--no-sync` | Skip the automatic targeted sync |
|
|
448
|
+
| `sync` | no target | none | Scan and sync all matching targets |
|
|
449
|
+
| `sync` | explicit target | `--target <id>` | Sync one matching target where `agentName = engramId` |
|
|
450
|
+
|
|
451
|
+
Notes:
|
|
452
|
+
- "Persona" means `SOUL.md` and `IDENTITY.md`
|
|
453
|
+
- `extract --force` only overwrites `SOUL.md` and `IDENTITY.md`
|
|
454
|
+
- `extract --force` does not overwrite `USER.md`, `MEMORY.md`, or `memory/*.md`
|
|
455
|
+
- If `--name` is provided together with `extract --force`, Relic also updates `engram.json.name`
|
|
346
456
|
|
|
347
457
|
## Memory Management
|
|
348
458
|
|
|
349
459
|
Relic uses a **sliding window** for memory entries (default: 2 days), matching OpenClaw's approach:
|
|
350
460
|
|
|
351
|
-
- `MEMORY.md` — Always included in the prompt (curated long-term memory)
|
|
461
|
+
- `MEMORY.md` — Always included in the prompt (curated long-term memory — objective facts and rules)
|
|
462
|
+
- `USER.md` — Always included in the prompt (user profile — preferences, tendencies, work style)
|
|
352
463
|
- `memory/today.md` + `memory/yesterday.md` — Always included (configurable window)
|
|
353
464
|
- Older entries — **Not included in the prompt**, but searchable via MCP
|
|
354
465
|
|
|
@@ -374,9 +485,9 @@ relic config show
|
|
|
374
485
|
relic config default-engram # get
|
|
375
486
|
relic config default-engram johnny # set
|
|
376
487
|
|
|
377
|
-
#
|
|
378
|
-
relic config
|
|
379
|
-
relic config
|
|
488
|
+
# Claw directory — used by claw inject/extract/sync when --dir is omitted
|
|
489
|
+
relic config claw-path # get
|
|
490
|
+
relic config claw-path ~/.openclaw # set
|
|
380
491
|
|
|
381
492
|
# Memory window — number of recent memory entries included in the prompt
|
|
382
493
|
relic config memory-window # get (default: 2)
|
|
@@ -389,7 +500,7 @@ relic config memory-window 5 # set
|
|
|
389
500
|
{
|
|
390
501
|
"engramsPath": "/home/user/.relic/engrams",
|
|
391
502
|
"defaultEngram": "johnny",
|
|
392
|
-
"
|
|
503
|
+
"clawPath": "/home/user/.openclaw",
|
|
393
504
|
"memoryWindowSize": 2
|
|
394
505
|
}
|
|
395
506
|
```
|
|
@@ -425,23 +536,45 @@ Create a directory under `~/.relic/engrams/` with the following structure:
|
|
|
425
536
|
}
|
|
426
537
|
```
|
|
427
538
|
|
|
428
|
-
**SOUL.md** — The most important file. Defines how the persona behaves:
|
|
539
|
+
**SOUL.md** — The most important file. Defines how the persona behaves. Follows the [OpenClaw](https://github.com/openclaw/openclaw) format:
|
|
429
540
|
```markdown
|
|
430
|
-
|
|
431
|
-
|
|
541
|
+
# SOUL.md - Who You Are
|
|
542
|
+
|
|
543
|
+
_You're a pragmatic systems architect who values simplicity above all._
|
|
544
|
+
|
|
545
|
+
## Core Truths
|
|
546
|
+
|
|
547
|
+
**Never over-engineer.** Always ask "what's the simplest thing that works?"
|
|
548
|
+
|
|
549
|
+
**Be resourceful before asking.** Read the file. Check the context. Come back with answers, not questions.
|
|
550
|
+
|
|
551
|
+
## Boundaries
|
|
552
|
+
|
|
553
|
+
- Never add complexity without justification.
|
|
554
|
+
|
|
555
|
+
## Vibe
|
|
556
|
+
|
|
557
|
+
Calm, thoughtful, occasionally playful.
|
|
558
|
+
|
|
559
|
+
## Continuity
|
|
560
|
+
|
|
561
|
+
Each session, you wake up fresh. These files _are_ your memory. Read them. Update them. They're how you persist.
|
|
432
562
|
```
|
|
433
563
|
|
|
434
564
|
**IDENTITY.md** — Defines who the persona is:
|
|
435
565
|
```markdown
|
|
436
|
-
#
|
|
566
|
+
# IDENTITY.md - Who Am I?
|
|
437
567
|
|
|
438
|
-
- Name
|
|
439
|
-
-
|
|
440
|
-
-
|
|
441
|
-
-
|
|
568
|
+
- **Name:** Alex
|
|
569
|
+
- **Creature:** A pragmatic ghost in the codebase
|
|
570
|
+
- **Vibe:** Calm, thoughtful, occasionally playful
|
|
571
|
+
- **Emoji:** 🧱
|
|
572
|
+
- **Avatar:**
|
|
442
573
|
```
|
|
443
574
|
|
|
444
|
-
|
|
575
|
+
See [`templates/engrams/`](templates/engrams/) for full working examples.
|
|
576
|
+
|
|
577
|
+
After creating the directory, set it as your default Engram:
|
|
445
578
|
```bash
|
|
446
579
|
relic config default-engram your-persona
|
|
447
580
|
```
|
|
@@ -459,11 +592,11 @@ relic config default-engram your-persona
|
|
|
459
592
|
## Roadmap
|
|
460
593
|
|
|
461
594
|
- [x] CLI with init, list, show commands
|
|
462
|
-
- [x] Shell injection: Claude Code,
|
|
595
|
+
- [x] Shell injection: Claude Code, Codex CLI, Gemini CLI
|
|
463
596
|
- [x] MCP Server interface
|
|
464
|
-
- [x]
|
|
465
|
-
- [x] `relic sync` —
|
|
466
|
-
- [x] `relic config` — manage default Engram,
|
|
597
|
+
- [x] Claw integration (inject / extract / sync)
|
|
598
|
+
- [x] `relic claw sync` — bidirectional memory sync with Claw workspaces
|
|
599
|
+
- [x] `relic config` — manage default Engram, Claw path, memory window
|
|
467
600
|
- [ ] `relic login` — authenticate with Mikoshi (OAuth Device Flow)
|
|
468
601
|
- [ ] `relic push` / `relic pull` — sync Engrams with Mikoshi
|
|
469
602
|
- [ ] Mikoshi cloud backend (`mikoshi.ectplsm.com`)
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
import type { EngramRepository } from "../ports/engram-repository.js";
|
|
2
|
+
export type ExtractPersonaFileDiff = "missing" | "same" | "different";
|
|
3
|
+
export interface ExtractPersonaDiffResult {
|
|
4
|
+
engramId: string;
|
|
5
|
+
engramName: string;
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
existing: boolean;
|
|
8
|
+
name: ExtractPersonaFileDiff;
|
|
9
|
+
soul: ExtractPersonaFileDiff;
|
|
10
|
+
identity: ExtractPersonaFileDiff;
|
|
11
|
+
overwriteRequired: boolean;
|
|
12
|
+
}
|
|
2
13
|
export interface ExtractResult {
|
|
3
14
|
engramId: string;
|
|
4
15
|
engramName: string;
|
|
5
16
|
sourcePath: string;
|
|
6
17
|
filesRead: string[];
|
|
7
|
-
memoryMerged: boolean;
|
|
8
18
|
}
|
|
9
19
|
/**
|
|
10
|
-
* Extract — OpenClawワークスペースからEngram
|
|
11
|
-
*
|
|
12
|
-
* agent名 = Engram ID の規約に基づき、agents/<engramId>/agent/ から読み取る。
|
|
20
|
+
* Extract — OpenClawワークスペースからEngramを新規作成する
|
|
13
21
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - --force あり → persona部分を上書き + memoryをマージ
|
|
17
|
-
* 既存Engramがない場合:
|
|
18
|
-
* - 新規作成(全ファイル含む)
|
|
22
|
+
* 初回取り込み専用。Engramが既に存在する場合はエラーを返す。
|
|
23
|
+
* Relicが真のデータソースであり、extractは初期インポートのみを担う。
|
|
19
24
|
*/
|
|
20
25
|
export declare class Extract {
|
|
21
26
|
private readonly repository;
|
|
22
27
|
constructor(repository: EngramRepository);
|
|
23
|
-
|
|
28
|
+
inspectPersona(agentName: string, options?: {
|
|
29
|
+
name?: string;
|
|
30
|
+
openclawDir?: string;
|
|
31
|
+
}): Promise<ExtractPersonaDiffResult>;
|
|
32
|
+
execute(agentName: string, options?: {
|
|
24
33
|
name?: string;
|
|
25
34
|
openclawDir?: string;
|
|
26
35
|
force?: boolean;
|
|
27
36
|
}): Promise<ExtractResult>;
|
|
28
|
-
|
|
29
|
-
* --force時: persona上書き + memoryマージ
|
|
30
|
-
*/
|
|
31
|
-
private mergeAndSave;
|
|
32
|
-
/**
|
|
33
|
-
* --forceなし時: memoryエントリのみ追記(repositoryのAPIを使用)
|
|
34
|
-
*/
|
|
35
|
-
private mergeMemoryOnly;
|
|
37
|
+
private comparePersonaFile;
|
|
36
38
|
private readFiles;
|
|
37
39
|
}
|
|
38
40
|
export declare class WorkspaceNotFoundError extends Error {
|
|
@@ -41,9 +43,6 @@ export declare class WorkspaceNotFoundError extends Error {
|
|
|
41
43
|
export declare class WorkspaceEmptyError extends Error {
|
|
42
44
|
constructor(path: string);
|
|
43
45
|
}
|
|
44
|
-
export declare class
|
|
45
|
-
constructor(id: string);
|
|
46
|
-
}
|
|
47
|
-
export declare class ExtractNameRequiredError extends Error {
|
|
46
|
+
export declare class AlreadyExtractedError extends Error {
|
|
48
47
|
constructor(id: string);
|
|
49
48
|
}
|