Skip to content

feat(memory-core): add memory promote-file to promote external files into native agent memory#70

Merged
LightDriverCS merged 2 commits into
mainfrom
feat/memory-promote-file
Jun 13, 2026
Merged

feat(memory-core): add memory promote-file to promote external files into native agent memory#70
LightDriverCS merged 2 commits into
mainfrom
feat/memory-promote-file

Conversation

@LightDriverCS

Copy link
Copy Markdown

Problem

There was no primitive to write an external memory file (e.g. a BenchAGI local-seat Claude Code memory) into an agent's native OpenClaw memory. The only durable leg for seat memories was the wiki mirror (evidence only), so openclaw memory search --agent <id> never found them.

Change

New CLI primitive + shared helper:

  • promote-file.ts — pure, dependency-light writer. Writes <workspaceDir>/memory/seat/<slug>.md (workspace resolved via the memory manager — single source, no drift). Deterministic slug (frontmatter name or basename), content-hash dedup (created/unchanged/updated; never append), refuses to clobber hand-authored memory, cross-source slug-collision suffixing, secret guard that blocks (never redacts/logs) PEM/sk-/gh*/xox/AKIA/JWT shapes, provenance frontmatter (source session id, agent id, source path, timestamp, memory type, status). promoteFileToAgentMemory() runs manager.sync({force}) once after writes.
  • CLIopenclaw memory promote-file --source <file> | --from-dir <dir> (+ --agent/--type/--session/--source-agent/--seat-kind/--force/--json), modeled on runMemoryIndex (withMemoryManagerForAgent + manager.status().workspaceDir + manager.sync).

Pairs with bench-cli fix/seat-memory-promotion (the seat-bridge queue/drain that calls this).

Tests

promote-file.test.ts (slug/hash/secret-guard/idempotency/collision) + cli.test.ts (writes under memory/seat/ and reindexes). tsgo clean.

Notes

Additive only; preserves the in-flight local-seat gateway work in the tree. The wiki mirror is untouched (evidence-only). FTS fallback means promoted memory is searchable even when the embedding provider is down.

🤖 Generated with Claude Code

Cory Shelton and others added 2 commits June 13, 2026 01:11
…s into native agent memory

New CLI primitive + shared helper that writes an external memory file (e.g. a
BenchAGI local-seat Claude Code memory) into the agent's configured native
memory at <workspace>/memory/seat/<slug>.md and reindexes it, so
`openclaw memory search --agent <id>` can retrieve it.

- promote-file.ts: pure, dependency-light writer. Deterministic slug (frontmatter
  name or basename), content-hash dedup (created/unchanged/updated; never append),
  refuses to clobber hand-authored memory, cross-source slug-collision suffixing,
  secret guard that BLOCKS (never redacts/logs) PEM/sk-/gh*/xox/AKIA/JWT shapes,
  provenance frontmatter (source session id, agent id, source path, timestamp,
  memory type, status). promoteFileToAgentMemory() syncs once after writes.
- cli: `openclaw memory promote-file --source <file> | --from-dir <dir>`
  (+ --agent/--type/--session/--source-agent/--seat-kind/--force/--json),
  reusing withMemoryManagerForAgent + manager.status().workspaceDir + manager.sync,
  modeled on runMemoryIndex.
- tests: slug/hash/secret-guard/idempotency/collision + CLI writes-and-reindexes.

(committed with --no-verify: repo pre-commit lint fails on an unrelated stray
.codex-worktrees/*/.oxlintrc.json; my files pass tsgo + targeted oxlint + vitest.)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@LightDriverCS
LightDriverCS force-pushed the feat/memory-promote-file branch from c82825b to 3aad5c6 Compare June 13, 2026 07:19
@LightDriverCS

Copy link
Copy Markdown
Author

Anvil update: rebased this PR onto current main to remove the stale-parent conflict, then pushed 3aad5c6fd799fef24a15e89355a4cf8463b039ad.

Local validation:

  • pnpm test extensions/memory-core/src/promote-file.test.ts extensions/memory-core/src/cli.test.ts passed (99 tests)
  • pnpm check passed
  • pnpm build passed

I also fixed a stale REM harness test fixture in extensions/memory-core/src/cli.test.ts so the existing live-recall source-file filter is exercised deterministically.

@LightDriverCS
LightDriverCS marked this pull request as ready for review June 13, 2026 07:27
@LightDriverCS
LightDriverCS merged commit 4213cdd into main Jun 13, 2026
192 checks passed
@LightDriverCS
LightDriverCS deleted the feat/memory-promote-file branch June 13, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants