从官方 Git 仓库导入 chandra447/pi-hermes-memory 在 tag v0.9.10 (df624056a2e8c68bc89ba0a81e1c120856ec9665,2026-10-02)的源码快照。 本次仅导入源码,尚未接入组合包:package.json、加载顺序、依赖与权限策略 均未改动。 - 原样导入 src/、tests/、docs/、scripts/、README、CHANGELOG、PLAN、 AGENTS 与 LICENSE;该快照共 156 个上游文件。 - 剔除嵌套 .git、上游 .github 工作流、.ralph/、.claude/、node_modules、 覆盖率与构建产物。 - 新增中文 UPSTREAM.md,记录来源,以及启用前必须完成的待决事项: 在 pi-compaction 之前注册加载顺序、better-sqlite3 版本与根 allowScripts 对齐、strip-ansi 解析确认。 - 说明选择 tag 而非 main 的原因:导入时上游 main 已领先至 24fcd8ad26fc27badb8d7dbaf8034645de07b893(2026-10-11),选 tag 是为 对应一个已发布、可复现的版本。 尚未接线。启用前还需反转 tests/extension-load.test.ts 中"不得加载 Hermes"的断言,并同步 pi-tool-search 分组、权限策略与文档。 验证:快照 156 个上游文件全部导入,目录内仅多出 UPSTREAM.md 一份; 已确认与上游 main 内容存在差异,证明取的是 tag 而非 main。
6.5 KiB
Tasks — v0.3.0: Interview + Hardening
Workflow: When you start a task, change
[ ]to[~]. When done, change to[x]and note the commit hash.Implementation order: Epic 1 → Epic 2 → Epic 3 → Epic 4 → Epic 5
Plan: See
docs/0.3/PLAN.mdfor full implementation details and architectural decisions.
Epic 1: /memory-interview Command
Done when: a new user can type /memory-interview, answer 5-7 questions, and have USER.md pre-filled with their preferences.
Constants
src/constants.ts— addINTERVIEW_PROMPTwith structured question flow (one-at-a-time, conversational, aware of existing entries)
Implementation
src/handlers/interview.ts—registerInterviewCommand()viapi.registerCommand()- Handler sends interview prompt via
ctx.sendUserMessage()as a steering message - Agent acknowledges existing entries if USER.md is not empty (offers update/skip)
- Interview uses existing
memorytool for writes (goes through content scanner) src/index.ts— wireregisterInterviewCommand(pi, store)
Tests
tests/handlers/interview.test.ts— command registered, prompt contains key questions, existing entries check, sends user message
Epic 2: Context Fencing
Done when: all memory blocks in the system prompt are wrapped in <memory-context> XML tags with a guard note.
Implementation
src/store/memory-store.ts— updaterenderBlock()to wrap output in<memory-context>+ guard note + closing tagsrc/store/memory-store.ts— updaterenderProjectBlock()same treatmentsrc/store/memory-store.ts— updateformatForSystemPrompt()if needed (the blocks come fromrenderBlock, so this may be automatic)src/store/skill-store.ts— updateformatIndexForSystemPrompt()to use same fencing pattern
Tests
tests/store/memory-store.test.ts— updateformatForSystemPrompt()assertions to check for<memory-context>tags and guard notetests/store/skill-store.test.ts— updateformatIndexForSystemPrompt()assertions for fencingtests/handlers/system-prompt.test.ts— update system prompt block format assertions
Epic 3: Memory Aging
Done when: entries carry created_at and last_referenced timestamps, consolidation prompt uses age to identify stale entries, and old entries without metadata load correctly.
Metadata Encoding
src/store/memory-store.ts— addencodeEntry(text, created, lastReferenced)helpersrc/store/memory-store.ts— adddecodeEntry(raw)helper with backward-compatible fallback for legacy entriessrc/store/memory-store.ts—add()encodes metadata on new entries (both dates = today)src/store/memory-store.ts—readFile()decodes entries on load, strips metadata for displaysrc/store/memory-store.ts—formatForSystemPrompt()strips metadata comments from rendered output (clean display)src/store/memory-store.ts—replace()preserves originalcreateddate, updateslast_referencedto todaysrc/store/memory-store.ts— addtouchEntry(target, text)method that updateslast_referencedtimestamp
Consolidation Prompt
src/constants.ts— updateCONSOLIDATION_PROMPTto mention entry age and staleness heuristics ("entries older than 30 days without recent references are candidates")
Tests
tests/store/memory-store.test.ts— metadata encode/decode round-triptests/store/memory-store.test.ts— backward compatibility: legacy entry (no metadata) loads with today's datetests/store/memory-store.test.ts—formatForSystemPrompt()output does NOT contain metadata commentstests/store/memory-store.test.ts—replace()preservescreateddate, updateslast_referencedtests/store/memory-store.test.ts—add()sets both dates to today
Epic 4: Project Memory Polish
Done when: project-scoped memory is tested, documented, has a visible /memory-insights section, and has a /memory-switch-project command.
Insights Command
src/handlers/insights.ts— add separator between global and project sectionssrc/handlers/insights.ts— show per-section usage stats and file pathssrc/handlers/insights.ts— handleprojectStore === nullgracefully (hide section, don't show "empty")
Switch Project Command
src/handlers/switch-project.ts— register/memory-switch-projectcommand- Handler accepts project name argument, switches active project directory
- Command shows current project and available projects (list subdirectories of
~/.pi/agent/that have MEMORY.md)
Index Cleanup
src/index.ts— extract project detection intodetectProject(cwd, homeDir)helper function- Handle edge cases: cwd === homeDir, cwd === "/", empty cwd, missing directory
Tests
tests/handlers/insights.test.ts— project section shown when projectStore availabletests/handlers/insights.test.ts— project section hidden when projectStore is nulltests/handlers/insights.test.ts— usage stats shown in project sectiontests/handlers/system-prompt.test.ts— project block injected when availabletests/handlers/system-prompt.test.ts— project block NOT injected when projectStore is null
Docs
README.md— add "Two-Tier Memory Architecture" section explaining global vs project memoryREADME.md— document/memory-switch-projectcommand
Epic 5: Documentation & Release
Done when: v0.3.0 is tagged and released with updated docs.
- Update
README.md— interview command usage, context fencing note, two-tier memory diagram - Update
docs/ROADMAP.md— mark v0.3 complete, restructure v0.4 (Session Search + MemoryBackend interface) npm run checkpasses with zero errorsnpm test— all tests pass (per-file runner)- Bump
package.jsonversion to0.3.0 - Tag v0.3.0 release
npm publish
Summary
| Epic | Priority | Est. Complexity | New Files | Modified Files |
|---|---|---|---|---|
| 1: Interview | 🔴 HIGH | Low | 2 (src + test) | 2 (constants, index) |
| 2: Fencing | 🟡 MEDIUM | Low | 0 | 5 (memory-store, skill-store, 3 test files) |
| 3: Aging | 🟡 MEDIUM | Medium | 0 | 4 (memory-store, constants, memory-tool, test) |
| 4: Project Polish | 🟢 LOW | Low | 2 (src + test) | 4 (insights, index, system-prompt test, README) |
| 5: Docs + Release | 🟢 LOW | Low | 0 | 3 (README, ROADMAP, package.json) |