从官方 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.7 KiB
Tasks — v0.2.0: Skills + Smart Curation
Workflow: When you start a task, change
[ ]to[~]. When done, change to[x]and note the commit hash.Implementation order: Epic 2 → Epic 3 → Epic 4 → Epic 1 → Epic 5 (quick wins first, then the largest piece)
Plan: See
docs/0.2/PLAN.mdfor full implementation details and architectural decisions.
Epic 2: Auto-Consolidation
Done when: memory full no longer returns an error — it triggers automatic consolidation and retries the add.
Shared Config (Epics 2-4 touch these files — do once, extend per epic)
src/types.ts— addautoConsolidate: booleantoMemoryConfig; addConsolidationResultinterface (c6317dd)src/config.ts— addautoConsolidate: truedefault + parsing (c6317dd)src/constants.ts— addCONSOLIDATION_PROMPT(c6317dd)
Implementation
src/store/memory-store.ts— makeadd()async, addsetConsolidator()injection method; after consolidation:await this.loadFromDisk()before retry (c6317dd)src/tools/memory-tool.ts—await store.add(target, content)(c6317dd)src/handlers/auto-consolidate.ts—triggerConsolidation()usingpi.exec()pattern (c6317dd)src/handlers/consolidate-command.ts—/memory-consolidatecommand (c6317dd— combined intoauto-consolidate.ts)src/index.ts— wire consolidator viastore.setConsolidator()+ register command (c6317dd)
Tests
tests/handlers/auto-consolidate.test.ts— consolidation trigger, pi.exec call, success/failure paths (83e7c46)tests/store/memory-store.test.ts— migrate allstore.add()calls toawait store.add(); consolidator tests (83e7c46)
Epic 3: Correction Detection + Immediate Save
Done when: user corrections are detected in real-time and trigger an immediate memory save.
Config
src/types.ts— addcorrectionDetection: booleantoMemoryConfig(c6317dd)src/config.ts— addcorrectionDetection: truedefault + parsing (c6317dd)src/constants.ts— addCORRECTION_SAVE_PROMPT, strong/weak/negative pattern arrays (c6317dd)
Implementation
src/handlers/correction-detector.ts— two-pass filter: strong/weak/negative patterns (c6317dd)- Rate limiting —
turnsSinceLastCorrection >= 3and!correctionInProgressguard (c6317dd) src/index.ts— wiresetupCorrectionDetector()(c6317dd)
Tests
tests/handlers/correction-detector.test.ts— 35 tests: strong/weak/negative patterns, rate limiting, false positives (83e7c46)
Epic 4: Tool-Call-Aware Nudge
Done when: background review triggers based on EITHER turn count OR tool call count.
Config
src/types.ts— addnudgeToolCalls: numbertoMemoryConfig(c6317dd)src/config.ts— addnudgeToolCalls: 15default + parsing (c6317dd)
Implementation
src/handlers/background-review.ts— count toolCall entries from branch; OR trigger logic; reset both counters (c6317dd)
Tests
tests/handlers/background-review.test.ts— 6 new tests: tool-call trigger, combined trigger, counter reset, text-only, crash recovery (83e7c46)
Epic 1: Skill Tool + Procedural Memory
Done when: the agent can create/update/delete skill documents, skills appear in a progressive index in the system prompt, and skills are auto-created after complex tasks.
Research & Design
- Read Pi's skill discovery API — Pi uses
~/.pi/agent/skills/with SKILL.md frontmatter format (c6317dd) - Decide: write to
~/.pi/agent/memory/skills/— isolated from user skills (c6317dd) - Read Hermes
skill_managetool source for reference patterns (c6317dd)
Store
src/store/skill-store.ts—SkillStoreclass with full CRUD +formatIndexForSystemPrompt()(c6317dd)- SKILL.md format — frontmatter (name, description, version, created, updated) + markdown body (
c6317dd) - File naming —
slugify(name) + ".md"(c6317dd) - Frontmatter parsing — regex-based, no yaml dependency (
c6317dd) - Content scanning — all writes go through
scanContent()(c6317dd) - Atomic writes — temp+rename pattern (
c6317dd)
Tool
src/tools/skill-tool.ts—registerSkillTool()with actions:create,view,patch,edit,delete(c6317dd)src/constants.ts— addSKILL_TOOL_DESCRIPTIONandDEFAULT_SKILL_TRIGGER_TOOL_CALLS(= 8) (c6317dd)- Rewrite
COMBINED_REVIEW_PROMPT— references skill tool with create/patch actions (c6317dd)
Progressive Disclosure
- Skill index (name + description only) injected into system prompt at
before_agent_start(c6317dd) viewaction loads full skill content on demand (c6317dd)- Frozen snapshot — index captured at
session_start, consistent throughout session (c6317dd)
Auto-Trigger
src/handlers/skill-auto-trigger.ts— 8+ tool calls with 2+ distinct tool types (c6317dd)- Rate limit — max 1 auto-trigger per session (
c6317dd)
Command
src/handlers/skills-command.ts—/memory-skillscommand (c6317dd)
Wiring
src/index.ts— wire SkillStore, registerSkillTool, setupSkillAutoTrigger, registerSkillsCommand (c6317dd)
Tests
tests/store/skill-store.test.ts— 27 tests: CRUD, frontmatter, progressive disclosure, atomic writes (83e7c46)tests/tools/skill-tool.test.ts— 10 tests: registration, action dispatch, validation (83e7c46)tests/handlers/skill-auto-trigger.test.ts— 6 tests: threshold, distinct types, session limit (83e7c46)
Epic 5: Documentation & Release
Done when: v0.2.0 is tagged and released with updated docs.
- Update
README.md— skill tool, auto-consolidation, correction detection, new config, new commands (4658529) - Update
src/constants.ts— verify all new prompts are finalized (c6317dd) - Update
docs/ROADMAP.md— v0.2 roadmap documented (d5b7518) npm run checkpasses with zero errors (c6317dd)npm test— all 218 tests pass (83e7c46)- Bump
package.jsonversion to0.2.0 - Tag v0.2.0 release
Summary
| Epic | Priority | Est. Complexity | New Files | Modified Files |
|---|---|---|---|---|
| 2: Auto-Consolidation | HIGH | Low | 3 (src + test) | 5 (types, config, constants, memory-store, memory-tool, index) |
| 3: Correction Detection | HIGH | Low | 2 (src + test) | 3 (types, config, constants, index) |
| 4: Tool-Call Nudge | MEDIUM | Low | 0 | 3 (types, config, background-review, test) |
| 1: Skill Tool | CRITICAL | High | 8 (4 src + 4 test) | 3 (constants, index, memory-store) |
| 5: Documentation | NORMAL | Low | 0 | 4 (README, constants, ROADMAP, package.json) |