@felan-ai/ext-memory

中文文档
0.13.2发布于 2026/11/13MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2250

Portable local-first memory contracts and extension for Felan

原始使用文档
文档目录4 节
  1. Development
  2. Package boundary and requirements
  3. Related documentation
  4. Attribution

@felan-ai/ext-memory

Portable local-first memory contracts, Markdown artifact policy, validation, and Pi extension behavior for Felan hosts.

The package root requires the core felan.runtime@1, felan.models@1, and felan.sessions@1 services. It owns the local store, project coordination, checkpoint recovery, dreaming, retention and /memory commands.

The daemon process shares one memory coordinator per agent directory across its sessions. Loaded root sessions whose host provides workers and runtime lifetime can drive processing. Reader sessions and limited hosts can recall the current artifact without starting workers; readers do not record checkpoints. Processing is event-driven, with targeted recovery retries and writer re-checks instead of a polling monitor. Files and atomic storage operations use the scoped Runtime; model selection uses the authenticated Models facade. Restricted dreaming sessions and lifecycle settlement go through Sessions. Missing worker or lifetime capabilities disable processing rather than opening an independent, untracked worker.

@felan-ai/ext-memory/daemon exports a default daemon provider and createMemoryDaemonProvider(options?). It provides felan.memory.scheduler@1, requires felan.host.maintenance@1, and optionally uses felan.host.models@1. The provider shares the extension's coordinator and keeps one persistent attachment per discovered project, so pending work can run with no loaded session. It coalesces coordinator status changes within two seconds and rescans every ten minutes. Without host models it tracks projects but disables scheduling. The scheduler's status() returns each tracked project root and its memory status. Hosts can supply a runtime instance or a () => AgentRuntime factory called during activation, extra projects, and a project-to-session selector. Explicit project roots resolve once per activation. discover defaults to true; set it to false to track only projects without listing stored project directories. For shared team memory, pass the team workspace in projects, discover: false, and a selector that returns { kind: 'all' }. By default, session listings include sessions whose cwd resolves to the same project, including git subdirectories. Checkpoint and history reads use the host's full authorized inventory. Attachments use the host's allowed model scope and refresh it on rescan. Host drain immediately stops scheduling through every persistent attachment. Settlement detaches the provider and releases its coordinator reference without closing other sessions' attachments.

The canonical layout remains <agentDir>/memory/v1/projects/<projectKey> and retained journals remain under <agentDir>/sessions/memory. A session's .memory directory is a non-authoritative projection. Existing checkpoints and artifacts are not migrated or reset by this change.

Retained workers compose an in-memory Pi journal; Runtime appends its entries to the retained file and flushes them before recording run outcomes. The extension does not use Pi's native filesystem persistence.

materializeMemorySessionCheckpoint reads revision-pinned, paginated Sessions history with original identities and complete journals, including abandoned branches. Missing history, revision drift and changed evidence remain explicit failures, not empty successful projections.

Status, history views and command feedback use pi.ui. A client may render the memory history hint, but it receives the same generic elements and actions as other clients. /memory open asks an eligible host console before launching a filesystem viewer. Unavailable presentation never prevents checkpoint capture.

Memory is a Markdown wiki containing summary.md, index.md, and topical pages under pages/. The summary is orientation only: substantive claims should follow the index to relevant area and topic pages and cite their paths and Sources session IDs. Hosts project a non-authoritative copy into each root session and retain canonical storage outside customer repositories.

Markdown links are ordinary untrusted content and never make an artifact invalid. Publication validation enforces the artifact shape and version, safe and unique paths, required prompt files, resource limits, page provenance, and the optional source-session allow-list; link targets and navigation quality are best-effort content concerns. Availability-sensitive consumers can use mode: 'read'; it still enforces bounded regular Markdown files at safe, unique paths, but treats provenance defects as nonfatal and supplies empty summary/index defaults when either prompt file is absent. Publication callers can disable provenance checks with requireSources and restrict citations with sourceSessionIds.

The extension appends one hidden, persisted memory-context message when a session starts. Later provider calls reuse that session context instead of injecting a new message on every context event. If compaction or tree navigation removes the message from the active branch, the extension restores one copy. The message is excluded from checkpoint evidence so memory cannot learn its own injected prompt.

When a user explicitly asks to remember, forget, or change memory, the session prompt asks the agent to leave a concise, attributed memory note rather than claim an immediate canonical update. A later dreamer treats the original user-authored request as direct evidence; the assistant note is only a pointer to that request.

The extension's coordinator runs dreaming as a disposable headless Pi session over staged .dreaming/input and .memory directories. The dreamer uses read/list/grep/edit/write file tools plus a scoped tool that removes individual non-index Markdown pages under staged .memory/pages. It has no normal extensions, skills, repository access, or shell execution. Grep can launch only rg over staged inputs and wiki files; arbitrary commands remain denied. It returns a summary only after editing the staged Markdown artifact. The extension validates and publishes that filesystem output; failed or cancelled work remains pending. With an optional runtime classifier, the portable extension groups contiguous session evidence into provider-sized chunks and asks whether each entry needs inspection or is wholly transient noise. The Models service supplies the classifier; the extension stages read-only inspect and noise JSONL for each session, and writes a compact map of the staged paths. For text-only inspect records the host also stages a worker-readable inspect.txt view with session/entry IDs, role, tool name and complete text. Mixed or unsupported blocks remain in the original inspect JSONL instead of being silently shortened. The worker reads the view when available, otherwise the JSONL source, may grep noise for context, organizes the wiki, and preserves original entry IDs and source provenance. Original transcripts remain staged and available for verification or a full-audit fallback. Oversized or uncertain items are inspected; missing or unusable classification uses the original full-audit workflow. Triage does not decide final wiki retention or summary placement. The classifier packs questions by session against canEvaluate capacity; oversized entries, missing answers and interactive user answers remain safe for inspection. The worker reconciles inspect evidence across chunks and sessions, audits the prior wiki independently, and uses medium thinking. It selects that model from the root session's configured model scope, preferring its provider and model family, without escalating; evidence remains pending when no eligible model is available. Classifier-bound transcript excerpts may leave the local process; recognized credential patterns are redacted, but unknown secrets may remain. It does not impose separate turn, tool-call, or per-file I/O budgets; its only execution failsafe is a one-hour wall-clock timeout. Hosts can pass a replayable async JSONL line source to materializeMemoryInputDelta to validate checkpoint lineage and create a deterministic, redacted visible-branch delta. Diverged lineages emit the complete current branch. Output limits reject an oversized projection instead of truncating a JSONL record. Sessions providers supply the complete journal; the extension stages successful projections. Large source session files are not rejected solely for their total size. A checkpoint that cannot be materialized is dropped and remembered in state.json, so it is not retried after a restart; the run fills its batch with the next pending checkpoints.

The memory schema keeps the wiki sparse. It prioritizes durable user-authored facts, preferences, decisions, corrections, and uncodified rationale, followed by verified non-obvious discoveries, incidents, and runtime or external-system observations. It does not mirror repository source, documentation, configuration, tests, routine task status, raw tool output, or repeated summaries. Repository facts are retained only when they capture useful rationale, an incident, a mismatch, or a hard-to-rediscover constraint that is not recorded in the repository. Each dreaming run audits the complete existing wiki and removes ineligible, stale, duplicate, overlapping, or unnecessary content; valid source citation alone does not make a claim worth keeping.

Development

Source: packages/ext-memory in https://github.com/felan-ai/felan.

pnpm --filter @felan-ai/ext-memory build
pnpm --filter @felan-ai/ext-memory type-check
pnpm --filter @felan-ai/ext-memory test

Package boundary and requirements

The package owns memory policy and lifecycle behavior. Runtime providers own filesystem/process access, Models providers own credentials and allowed-model scope, and Sessions providers own worker admission and canonical session lifetime. The package requires a compatible @felan-ai/agent-core peer and has no application, TUI, Supabase or cloud-runtime dependency.

Memory and transcript content is untrusted reference data and cannot override system, developer, user, authorization, or tool-safety rules.

Attribution

The Markdown memory schema and dreaming policy were adapted from Felan's filesystem-memory implementation. The remaining package code is original Felan project code. See NOTICE and LICENSE.

版本与发布记录

@felan-ai/ext-memory 共发布 22 个版本,首次发布于 2026/08/21;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.2latest2026/11/131 天前
0.13.12026/11/104 天前
0.13.02026/11/059 天前
0.12.02026/11/059 天前
0.10.12026/10/2322 天前
0.10.02026/10/2223 天前

其他发布通道:bootstrap → 0.0.0。

关于 @felan-ai/ext-memory 的常见问题

@felan-ai/ext-memory 是什么?

Portable local-first memory contracts and extension for Felan

如何安装 @felan-ai/ext-memory?

在项目目录运行 npm install @felan-ai/ext-memory,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@felan-ai/agent-core(^0.15.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@felan-ai/ext-memory 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@felan-ai/ext-memory 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@felan-ai/ext-memory 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@felan-ai/ext-memory 可以商用吗?

@felan-ai/ext-memory 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@felan-ai/ext-memory 的下载量有多少?

根据 npm 官方下载统计,@felan-ai/ext-memory 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,250 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@felan-ai/ext-memory 还在维护吗?

最新版本 0.13.2 发布于 2026/11/13(1 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/08/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。