-
Notifications
You must be signed in to change notification settings - Fork 0
memory: restore Claude basic_memory capture/injection; add Codex/OMP capture + bounded reindex #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Codex and OMP/Pi memory capture | ||
|
|
||
| Claude Code capture is wired automatically by `dotagents setup`. Codex and | ||
| OMP/Pi have no session-end hook that dotagents installs for them, so their | ||
| automatic capture is opt-in and wired manually. Both route through the same | ||
| `session-end.sh` dispatcher, which classifies a Codex/OMP payload and writes the | ||
| local `basic_memory` digest — the same digest Claude produces. | ||
|
|
||
| Reminder for both harnesses: automatic digests are a safety net, not a | ||
| substitute for deliberate capture. Record durable cross-harness facts explicitly | ||
| with `rem add -src codex "<fact>"` / `rem add -src omp "<fact>"`. | ||
|
|
||
| ## Codex | ||
|
|
||
| Codex emits Claude-compatible Stop/SessionEnd payloads (with `transcript_path` | ||
| and `model`). Add a hook to `~/.codex/hooks.json` on `SessionEnd` (preferred) or | ||
| `Stop`, setting `DOTAGENTS_MEMORY_SOURCE=codex` so the digest is labelled and so | ||
| the `Stop`-wired path captures rather than passing through: | ||
|
|
||
| ```json | ||
| { | ||
| "type": "command", | ||
| "command": "DOTAGENTS_MEMORY_SOURCE=codex ~/.agents/memory/hooks/session-end.sh", | ||
| "timeout": 30 | ||
| } | ||
| ``` | ||
|
|
||
| Reminder: also `rem add -src codex "<fact>"` for facts worth promoting. | ||
|
|
||
| ## OMP / Pi | ||
|
|
||
| OMP/Pi has no session-end hook but supports extensions that fire on | ||
| `agent_end`. Install the shipped extension: | ||
|
|
||
| ```sh | ||
| cp ~/.agents/memory/hooks/omp-memory.ts ~/.omp/agent/extensions/ | ||
| ``` | ||
|
|
||
| It pipes an `agent: "omp"` payload into `session-end.sh` on every `agent_end`. | ||
| Set `DOTAGENTS_MEMORY_HOOKS` if your dotagents checkout is not at `~/.agents`. | ||
|
|
||
| Reminder: also `rem add -src omp "<fact>"` for facts worth promoting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // dotagents OMP/Pi memory extension. | ||
| // | ||
| // OMP/Pi exposes no session-end hook of its own, so this extension captures a | ||
| // basic_memory digest on `agent_end` by piping an OMP-tagged payload into the | ||
| // shared session-end dispatch (memory/hooks/session-end.sh), which classifies | ||
| // `agent: "omp"` and writes the same local digest Claude and Codex use. | ||
| // | ||
| // Manual wiring (dotagents does not install OMP extensions automatically): | ||
| // cp ~/.agents/memory/hooks/omp-memory.ts ~/.omp/agent/extensions/ | ||
| // Override the hook location with DOTAGENTS_MEMORY_HOOKS if your dotagents | ||
| // checkout is not at ~/.agents. | ||
| // | ||
| // Reminder: automatic digests are a net, not a replacement. Capture deliberate | ||
| // cross-harness facts explicitly with: rem add -src omp "<fact>" | ||
| import { spawn } from "node:child_process"; | ||
| import * as os from "node:os"; | ||
| import * as path from "node:path"; | ||
| import type { AgentEndEvent, ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent"; | ||
|
|
||
| function hooksDir(): string { | ||
| return process.env.DOTAGENTS_MEMORY_HOOKS || path.join(os.homedir(), ".agents", "memory", "hooks"); | ||
| } | ||
|
|
||
| function digestMessages(event: AgentEndEvent): Array<{ role: string; content: unknown }> { | ||
| const messages: Array<{ role: string; content: unknown }> = []; | ||
| for (const message of event.messages || []) { | ||
| if (!message || typeof message !== "object") continue; | ||
| const typed = message as { role?: unknown; content?: unknown }; | ||
| if (typeof typed.role !== "string" || typed.content == null) continue; | ||
| messages.push({ role: typed.role, content: typed.content }); | ||
| } | ||
| return messages; | ||
| } | ||
|
|
||
| function captureDigest(ctx: ExtensionContext, event: AgentEndEvent): void { | ||
| const sessionId = ctx.sessionManager.getSessionId(); | ||
| if (!sessionId) return; | ||
| const cwd = ctx.cwd || process.cwd(); | ||
| const payload = JSON.stringify({ | ||
| agent: "omp", | ||
| hook_event_name: "SessionEnd", | ||
| session_id: sessionId, | ||
| cwd, | ||
| messages: digestMessages(event), | ||
| }); | ||
| try { | ||
| const child = spawn(path.join(hooksDir(), "session-end.sh"), [], { | ||
| env: { ...process.env, DOTAGENTS_MEMORY_SOURCE: "omp" }, | ||
| stdio: ["pipe", "ignore", "ignore"], | ||
| detached: true, | ||
| }); | ||
| child.on("error", () => {}); | ||
| child.unref(); | ||
| child.stdin.on("error", () => {}); | ||
| child.stdin.end(payload); | ||
| } catch (_) { | ||
| // Best-effort: never let memory capture break the session. | ||
| } | ||
| } | ||
|
|
||
| export default function dotagentsOmpMemoryExtension(api: ExtensionAPI) { | ||
| api.on("agent_end", async (event, ctx) => { | ||
| captureDigest(ctx, event); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.