npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fuxi-ailabs/crowdmemory-codex-plugin

v0.1.1

Published

Codex hooks and MCP adapter for the local Crowd Memory Runtime

Readme

Crowd Memory Codex 插件

把 Codex 的会话和工具 hooks 接到本机 Crowd Memory Runtime,提供 memory_search、memory_read、memory_note。 插件只做宿主事件映射和引用资料投递,复用 memory-adapter-core 的协议、端点信任、脱敏、记忆工具和私有路由状态; 不依赖其它 Agent framework 或业务工作流。

要求 Node.js ≥22.18、Unix socket、Codex CLI 0.164.0(本次验证版本)。npm 包为 @fuxi-ailabs/[email protected]。 Runtime 可继续使用已发布的 0.1.1。桌面端与企业托管策略需要单独验收;云编排环境不支持本地插件 command hooks。

独立安装与试用

在独立目录下载并解包 npm 发行包,无需全局安装、克隆源码或安装开发依赖:

mkdir CMLocalCodex
cd CMLocalCodex
npm pack @fuxi-ailabs/[email protected] --registry=https://registry.npmjs.org
mkdir -p plugin
tar -xzf fuxi-ailabs-crowdmemory-codex-plugin-0.1.1.tgz -C plugin

可使用独立的 Codex 配置目录。以下命令只影响该目录,不覆盖现有的全局插件配置:

export CODEX_HOME="$PWD/.codex-crowdmemory"
codex plugin marketplace add "$PWD/plugin/package" --json
codex plugin add crowdmemory@crowdmemory-codex --json
codex plugin list
codex login
export CROWDMEMORY_ENDPOINT_FILE="/absolute/runtime/state/endpoint.json"
export CROWDMEMORY_PROJECT="my-repository"
codex

先按 Runtime 文档启动记忆服务。安装后,在 Codex 的 hooks 信任提示中检查并信任本插件的 hook 定义;安装或启用插件不等于信任 hooks。 正常使用不需要绕过 hooks 信任或沙箱。未信任时,记忆工具不能取得可靠的会话绑定,会返回不可用。 保留 Codex 对 MCP 工具的审批策略:PreToolUse 只对本插件三个工具补会话字段(Codex 要求 updatedInput 与 allow 一起返回), 不替其它工具放行,也不覆盖 MCP 自身的审批要求。不要同时注册另一个同名 crowdmemory MCP server。

会话 A 修复问题并完成测试后,用 memory_note 写现象、原因、位置和实际修法;正常结束会话。 会话 B 用 memory_search 查找、memory_read 核对来源;相关 shell 输出也可触发检索和读取,在下一次模型请求前交付引用资料。 历史记录只是参考,当前代码仍需测试。

Codex 的接入范围

| Codex 事件 | 行为 | |---|---| | SessionStart | 绑定 Runtime 会话;resume / fork 使用宿主给出的身份,已结束绑定重开 | | UserPromptSubmit | 首次提交调用 step.before,查询文本先脱敏 | | PreToolUse(三个记忆工具) | 覆盖调用参数中的会话身份,保留其它字段;MCP 工具使用该绑定调用 Runtime | | PostToolUse / Bash | 当前 CLI 只给 stdout:按输出检索并读取相关记录,保留出处与命中理由,不推断退出码 | | PostToolUse / apply_patch | 明确成功时只记录修改路径,不上传补丁或文件内容 | | SubagentStart / SubagentStop | 独立子会话绑定、召回及结束,保留父子关系;不按 FIFO 猜子任务 prompt | | SessionStart / compact | 重新交付上一次引用资料;不读取不稳定的 transcript 来伪造压缩摘要 | | SessionEnd | 同步结束父子会话,最长按 Codex 的 3 秒上限;Stop 不等于 SessionEnd |

不把 stdout 当作退出状态

在真实 Codex CLI 0.164.0 上,printf 'error'; exit 2 的 PostToolUse 也只收到字符串 error,没有退出码。 所以普通字符串不能用来生成 tool.result.ok、机械成功率或失败签名;即使 stdout 含有“Process exited with code 2”,也不会信任它。 若其它宿主明确给出结构化 exit_code,适配器才会上报该状态;当前 CLI 的路径仍用无成败断言的 query / read。 这也意味着它不能提供与 DSH 完全相同的失败配对统计。没有 workflow / goal 事件、工作区快照或压缩摘要采集能力。

配置

| 环境变量 | 默认 / 用途 | |---|---| | CROWDMEMORY_ENDPOINT_FILE | ~/.crowdmemory/state/endpoint.json,必须为可信绝对路径 | | CROWDMEMORY_PROJECT | 默认工作目录名;推荐显式使用稳定仓库名 | | CROWDMEMORY_PROFILE | session-default | | CROWDMEMORY_CODEX_STATE | 私有路由状态目录;默认 $CODEX_HOME/crowdmemory/sessions(未设置 CODEX_HOME 则为 ~/.codex/crowdmemory/sessions),hooks 与 MCP 共用 | | CROWDMEMORY_INJECT | 0 / false / off / no 关闭自动投递,记忆工具仍可使用 | | CROWDMEMORY_NOTES | 同上,关闭 memory_note | | CROWDMEMORY_DEBUG | 1 只报告 hook 降级,不打印输入或令牌 |

MCP 通过 .mcp.json 的相对 cwd 启动,不能套用 OpenClaude 的 ${PLUGIN_ROOT} 参数插值;配置变量通过显式 env_vars 传递。 会话状态使用 0700 目录、0600 文件、锁和原子替换。会话字段是本机合作式路由,不是对恶意同用户进程的强认证。 project 也是相关性约定,不是多租户安全边界。Runtime 失联时 hooks 无输出并退出 0,工具返回不可用;笔记失败需调用方重试。

开发与验证

在仓库本包目录安装开发依赖;源码验证也可用 npm pack 打包,再解包交给下面的 CLI 测试。

pnpm install --frozen-lockfile
pnpm typecheck
pnpm test
pnpm build
node e2e/run.mjs
CROWDMEMORY_E2E_PLUGIN_DIR=/absolute/unpacked/package node e2e/run.mjs
# 已有测试专用 Runtime 时,额外运行真实服务测试:
CROWDMEMORY_TEST_REAL_ENDPOINT_FILE=/absolute/runtime/state/endpoint.json pnpm test

单测覆盖合同、跨进程绑定、字段保留、父子会话、降级和 stdout 无状态场景。真实 Runtime 测试需显式给测试端点,否则跳过。 CLI e2e 使用真实 Codex、隔离 CODEX_HOME、本地脚本化 Responses 服务和假 Runtime,验证打包安装、写笔记、下一会话召回与读取。 仅这个受控离线测试会绕过 hook 信任及审批;它不使用真实模型、服务密钥或生产工作区,也不代表设备或生产模型验收。

公共源码改动请在 ../memory-adapter-core 修改并执行 npm run update,不要直接编辑 src/core/、contract/ 或测试夹具副本。 官方合同依据:Hooks、插件打包。