Lines 7-48javascript
7 * event name as argv[2]:
9 * node remnic-codex-hook.cjs <event>
11 * Events: session-start | user-prompt-recall | post-tool-observe | session-end
13 * This is a faithful port of the original four bash scripts — same endpoints,
14 * env vars, token resolution, cursor/lock hardening, engram→remnic migration,
15 * daemon health/auto-start, git coding-context projectId derivation, and
16 * session-end memory materialization. Node replaces the per-script `node -e`
17 * one-liners and Unix tools (curl/git/sed/mktemp/…) so the exact same logic
18 * runs on Windows, macOS, and Linux.
20 * Fail-open everywhere: any unexpected error degrades to `{"continue":true}`.
25const fs = require("fs");
26const os = require("os");
27const path = require("path");
28const http = require("http");
29const { execFileSync, spawn, spawnSync } = require("child_process");
30
HighChild Process
Package source references child process execution.
hooks/bin/remnic-codex-hook.cjsView on unpkg · L28 31const HOME = process.env.HOME || process.env.USERPROFILE || os.homedir();
32const HOST = process.env.REMNIC_HOST || process.env.ENGRAM_HOST || "127.0.0.1";
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
hooks/bin/remnic-codex-hook.cjsView on unpkg · L27 33const PORT = process.env.REMNIC_PORT || process.env.ENGRAM_PORT || "4318";
35// Internal re-entrant mode: post-tool-observe spawns a detached copy of itself
36// so the (slow) observe runs in the background and never blocks Codex past the
37// short PostToolUse timeout — mirroring the original `( … ) & disown`.
38const OBSERVE_WORKER = "__observe-worker__";
41 "session-start": "remnic-session-recall.log",
42 "user-prompt-recall": "remnic-user-prompt-recall.log",
43 "post-tool-observe": "remnic-post-tool-observe.log",
44 "session-end": "remnic-codex-session-end.log",
47 "session-start": "codex-session-start",
48 "user-prompt-recall": "codex-user-prompt",