@riconext/hermes-repo 0.15.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,119 +1,6 @@
1
- ## 记忆系统
1
+ # 项目指令
2
2
 
3
- 本项目使用 @riconext/hermes-repo 管理 AI 助手记忆。
4
3
 
5
- 核心文件:
6
-
7
- - `.memory/MEMORY.md` — 注入到每次会话的摘要
8
- - `.memory/captures/` — 按类型(semantic / episodic / procedural)归档的原始捕获
9
- - `.memory/topics/` — 整理后的主题记忆
10
-
11
- ## 使用记忆
12
-
13
- - 开始新任务前,先读取 `.memory/MEMORY.md`
14
- - 如需查找历史经验: `npx @riconext/hermes-repo search <关键词>`
15
- - 查看特定捕获: `cat .memory/captures/<type>/<文件名>.md`
16
- - 查看主题: `cat .memory/topics/<主题>.md`
17
- - 查看可用技能: `cat .memory/skills/*/SKILL.md`
18
-
19
- ## 技能使用
20
-
21
- 项目自动从重复的流程记忆中生成技能(SKILL.md),存在 `.memory/skills/`。
22
-
23
- ### 何时加载技能
24
-
25
- 当你需要执行以下操作时,先查看是否有对应的技能:
26
-
27
- 1. 部署 / 发布 / 回滚
28
- 2. 数据库迁移
29
- 3. 新模块 / 新页面创建
30
- 4. 重复性配置操作
31
- 5. 调试已知类型的问题
32
-
33
- ### 如何使用
34
-
35
- 1. 查看技能目录: `ls .memory/skills/`
36
- 2. 匹配到任务后: `cat .memory/skills/<name>/SKILL.md`
37
- 3. 按步骤执行
38
- 4. 执行结束后,在捕获中引用技能名(帮助 consolidate 追踪技能有效性)
39
-
40
- ## 何时搜索过去经验
41
-
42
- 当你遇到以下情况,应主动搜索 `.memory/` 中的历史记忆:
43
-
44
- 1. 处理你之前解决过类似问题的模块
45
- 2. 需要进行与上次类似的技术选型
46
- 3. 用户说「之前不是这样」或「上次讨论过」
47
- 4. 需要了解项目的历史架构决策
48
-
49
- ## 记录新经验
50
-
51
- 当你遇到以下情况,在 `.memory/captures/` 创建捕获文件:
52
-
53
- 1. 你犯了错误并被用户纠正
54
- 2. 你发现代码与已有约定不一致
55
- 3. 你了解到项目特有的架构决策(包括被否决的方案)
56
- 4. 你做出了非平凡的设计选择(包括为什么选 A 不选 B)
57
- 5. 你重复遇到了类似问题(说明前一次的经验没有被记住)
58
- 6. 你完成了复杂的多步操作流程
59
-
60
- ### 分类参考
61
-
62
- - **语义记忆**: 事实、约定、决策原则 → type: semantic
63
- - **情景记忆**: 具体事件经过 → type: episodic
64
- - **流程记忆**: 操作步骤 → type: procedural
65
-
66
- ### scope 选择
67
-
68
- - 这个经验适用于整个项目吗?→ scope: all
69
- - 只适用于前端 / 后端 / 基础设施?→ 对应 scope
70
-
71
- ## 团队协作(多人仓库)
72
-
73
- 本项目由多人维护。记忆分两层:
74
-
75
- ### 个人层(仅你自己可见,不提交 git)
76
-
77
- - `.memory/captures/` — 你这次的 AI 捕获
78
- - `.memory/refs/` — 你的引用记录
79
- - 不需要审批,直接写入
80
-
81
- ### 团队层(所有人可见,提交 git)
82
-
83
- - `.memory/topics/` — 团队认同的约定
84
- - `.memory/skills/` — 团队可复用的技能
85
- - `.memory/MEMORY.md` — 团队记忆摘要
86
-
87
- ### 晋升团队层
88
-
89
- 当你觉得某条个人捕获对团队有价值:
90
-
91
- 1. 标记晋升: `touch .memory/captures/<type>/xxx.promote`
92
- 2. 使用 PR 模板 `.memory/templates/PROMOTE_PR.md` 创建晋升 PR
93
- 3. 等团队 review 后合并;`promote --pr` 生成草案,`promote --apply --manifest` 落盘(v0.13+)
94
-
95
- ### 冲突处理
96
-
97
- 如果发现团队层记忆与你的经验矛盾:
98
-
99
- 1. 在 `.memory/team/conflict-resolutions/` 创建冲突记录
100
- 2. 不要直接修改团队层文件
101
- 3. 在 PR 或周会上提出讨论
102
-
103
- ## 引用记录
104
-
105
- 当你读取某条捕获或技能后,记录引用(供 flush 聚合 `use_count`):
106
-
107
- ```bash
108
- npx @riconext/hermes-repo ref --capture captures/semantic/<文件>.md --reason "为何查看"
109
- npx @riconext/hermes-repo ref --skill <slug> --reason "执行前加载技能"
110
- ```
111
-
112
- 也可在 `.memory/refs/` 手写 JSON(`target` 为相对 `.memory/` 的路径)。
113
-
114
- ## 禁止
115
-
116
- - 不要写入代码的具体实现细节(代码本身是自文档的)
117
- - 不要写入敏感信息(密钥、密码、个人数据)
118
- - 不要重复写入已存在的内容(先搜索再写)
119
- - 不要在没有用户交互的会话中创建捕获(纯自动化操作不产生经验)
4
+ <!-- >>> hermes-repo agents (do not edit this block manually) -->
5
+ __HERMES_AGENTS_BLOCK__
6
+ <!-- <<< hermes-repo agents -->
@@ -1,6 +1,130 @@
1
- # 项目指令
1
+ # Hermes 记忆系统指南
2
2
 
3
+ > 本文档由 `hermes init` 自动生成。如需更新记忆结构,运行 `hermes init --force`。
3
4
 
4
- <!-- >>> hermes-repo agents (do not edit this block manually) -->
5
- __HERMES_AGENTS_BLOCK__
6
- <!-- <<< hermes-repo agents -->
5
+ ## 核心概念
6
+
7
+ 本项目使用 **hermes-repo** 管理 AI 编程助手的项目级记忆系统。
8
+
9
+ **设计原则:**
10
+ - **Captures 是 raw evidence** — 对话记录自动保存到 `captures/raw/`,不等于知识
11
+ - **LLM 提炼后进入知识库** — 手动 `hermes flush` 触发 consolidate,由 LLM 整理成结构化知识
12
+ - **按业务域组织** — 改库存读 `domains/inventory/`,改报价读 `domains/quoted/`
13
+ - **两阶段注入** — 启动时先加载导航+规则全文,AI 按需读取具体域知识
14
+
15
+ ## 目录结构
16
+
17
+ ```
18
+ .memory/
19
+ ├── MEMORY.md # ← 导航中心(自动生成 + 可手动编辑)
20
+ ├── config.json # 配置(含 LLM 设置)
21
+
22
+ ├── rules/ # 必读规则(编码规范、约定)
23
+ ├── domains/{domain}/ # 业务域知识(LLM 自动分类)
24
+ │ └── general/ # 兜底域
25
+ ├── workflows/ # 可复用操作流程
26
+ ├── decisions/ # 历史决策记录
27
+ ├── incidents/ # 踩坑记录
28
+
29
+ └── captures/
30
+ ├── raw/ # 原始对话记录(gitignored)
31
+ └── archived/ # 已归档的旧记录
32
+ ```
33
+
34
+ ## Inject(启动时自动加载)
35
+
36
+ 每次 AI 会话开始时,hook 会自动调用 `hermes inject`:
37
+
38
+ **注入内容:**
39
+ 1. `MEMORY.md` 导航摘要(所有知识的索引)
40
+ 2. `rules/` 目录下全部文件的完整内容(必读规则)
41
+
42
+ **AI 应该怎么做:**
43
+ - 先阅读 MEMORY.md 了解项目全貌和可用知识
44
+ - 遵守 rules/ 中列出的所有编码规范
45
+ - 根据任务判断需要哪个业务域的知识 → 用工具读取对应文件:
46
+ ```bash
47
+ cat .memory/domains/{domain}/{file}.md
48
+ cat .memory/workflows/{file}.md
49
+ ```
50
+
51
+ ## Capture(结束时自动保存)
52
+
53
+ 对话结束时,hook 会自动调用 `hermes capture`:
54
+
55
+ - 所有对话内容保存到 `captures/raw/session-{id}.md`
56
+ - 一个对话一个文件,支持追加
57
+ - **无需手动创建捕获** — 系统自动处理
58
+
59
+ ## Consolidate(手动触发提炼)
60
+
61
+ 当积累了足够的对话记录后,手动执行:
62
+
63
+ ```bash
64
+ npx @riconext/hermes-repo flush
65
+ ```
66
+
67
+ 这会:
68
+ 1. 扫描所有待处理的 session 文件(pending / stale)
69
+ 2. 单次 LLM 调用完成完整提炼:
70
+ - 域提取 → 分类判定 → 内容提炼 → 导航生成
71
+ 3. 输出写入 `rules/`, `domains/`, `workflows/`, `decisions/`, `incidents/`
72
+ 4. 更新 `MEMORY.md` 导航
73
+ 5. 将已处理的 session 标记为 done
74
+
75
+ **前提条件:**
76
+ - 需要配置 LLM(见下方配置说明)
77
+
78
+ ## 配置 LLM
79
+
80
+ 在 `.memory/config.json` 中配置:
81
+
82
+ ```json
83
+ {
84
+ "llm": {
85
+ "enabled": true,
86
+ "baseUrl": "https://api.openai.com/v1",
87
+ "model": "gpt-4o"
88
+ }
89
+ }
90
+ ```
91
+
92
+ API Key 通过环境变量设置:
93
+ ```bash
94
+ export HERMES_LLM_API_KEY="sk-..."
95
+ ```
96
+
97
+ ## 常用命令
98
+
99
+ | 命令 | 用途 |
100
+ |------|------|
101
+ | `hermes init` | 初始化记忆脚手架 |
102
+ | `hermes inject` | 注入上下文(通常由 hook 自动调用) |
103
+ | `hermes capture` | 保存对话记录(通常由 hook 自动调用) |
104
+ | `hermes flush` | 触发 LLM consolidate(手动) |
105
+
106
+ ## 知识类型
107
+
108
+ consolidate 时 LLM 会将内容分为 5 类:
109
+
110
+ | 类型 | 存放位置 | 说明 |
111
+ |------|---------|------|
112
+ | rule | `rules/` | 编码规范、团队约定、禁令 |
113
+ | domain-knowledge | `domains/{domain}/` | 业务事实、数据模型、领域逻辑 |
114
+ | workflow | `workflows/` | 可复用操作步骤流程 |
115
+ | decision | `decisions/` | 架构选型及原因 |
116
+ | incident | `incidents/` | 踩坑记录、问题根因、修复方式 |
117
+
118
+ 每条知识都有状态字段:`active` | `implemented` | `superseded` | `needs_review` | `archived`
119
+
120
+ ## 编辑约定
121
+
122
+ - **MEMORY.md 可以手动编辑** — 用 `<!-- user-edit-start --> ... <!-- user-edit-end -->` 包裹自定义区域,flush 时保留
123
+ - **Knowledge 文件可以手动编辑** — 直接修改 markdown 内容即可
124
+ - **不要直接编辑 captures/raw/ 中的文件** — 这些是自动生成的原始记录
125
+
126
+ ## 禁止事项
127
+
128
+ - 不要写入代码的具体实现细节(代码本身是自文档的)
129
+ - 不要写入敏感信息(密钥、密码、个人数据)
130
+ - 不要重复写入已存在的内容(先搜索再写)
@@ -1,25 +1,43 @@
1
- # 项目记忆
1
+ # 项目知识库
2
2
 
3
- 最后更新: — | 总计: 0 条捕获(0 语义 + 0 情景 + 0 流程)
3
+ 最后更新: — | 域: 0 | 规则: 0 | 工作流: 0 | 决策: 0 | 踩坑: 0
4
4
 
5
- ## 活跃主题
5
+ > 此文件由 `hermes flush` 后 LLM 自动生成,也可手动编辑。
6
+ > 编辑时请保留 <!-- user-edit-start --> ... <!-- user-edit-end --> 标记。
6
7
 
7
- (consolidate 后自动填充)
8
+ ## 必读规则
8
9
 
9
- ## 最近经验
10
+ > 每次会话都应加载的编码规范和项目约定
10
11
 
11
12
  (consolidate 后自动填充)
12
13
 
13
- ## 项目约定
14
+ ## 业务域
14
15
 
15
- (consolidate 后自动填充)
16
+ > 根据任务选择相关域读取
17
+
18
+ | 域 | 文件 | 摘要 |
19
+ |----|------|------|
20
+ | — | — | — |
21
+
22
+ (首次 `hermes flush` 后自动生成)
23
+
24
+ ## 工作流
25
+
26
+ > 可复用的执行流程
27
+
28
+ (consolidate 后从 procedural captures 晋升填充)
29
+
30
+ ## 决策 & 踩坑
31
+
32
+ > 需要了解背景时按需查看
16
33
 
17
- ## 可用技能
34
+ - decisions/: 0 条记录
35
+ - incidents/: 0 条记录
18
36
 
19
- (consolidate 后从 procedural 晋升填充)
37
+ ---
20
38
 
21
- ## 检索提示
39
+ ## 使用说明
22
40
 
23
- - 手动整理记忆: `npx @riconext/hermes-repo flush`
24
- - 查看捕获: `ls .memory/captures/` 或 `cat .memory/captures/<type>/<文件>.md`
25
- - 查看主题: `ls .memory/topics/`
41
+ - 整理记忆(触发 consolidate): `npx @riconext/hermes-repo flush`
42
+ - 查看原始捕获: `ls .memory/captures/raw/`
43
+ - 查看业务域: `ls .memory/domains/`
@@ -0,0 +1,26 @@
1
+ ---
2
+ sessionId: example-session-id
3
+ source: session
4
+ status: pending
5
+ domain: null
6
+ createdAt: 2026-06-23T16:00:00
7
+ lastModifiedAt: 2026-06-23T16:00:00
8
+ consolidatedAt: null
9
+ captureCount: 2
10
+ ---
11
+
12
+ ## Capture #1 — 16:00:00
13
+ ### type: semantic
14
+ ### tags: ["discount","quoted"]
15
+
16
+ 讨论了报价单的 discount 显示逻辑:
17
+ - 折扣字段来自后端 API `/api/quoted/discount`
18
+ - 前端展示需要乘以汇率
19
+ - 注意:折扣百分比需要除以 100 后展示
20
+
21
+ ## Capture #2 — 16:15:00
22
+ ### type: episodic
23
+ ### tags: ["bug-fix"]
24
+
25
+ 因为 discount 字段没有做空值判断,导致部分报价单页面白屏。
26
+ 修复方案:在渲染前加 `?? 0` 兜底。
@@ -1,8 +1 @@
1
- {
2
- "version": 1,
3
- "storage": {
4
- "backend": "file"
5
- },
6
- "assistants": ["claude-code"],
7
- "debug": false
8
- }
1
+ {"version": 2, "storage": {"backend": "file"}, "assistants": ["claude-code"], "debug": false, "llm": {"enabled": false, "baseUrl": "https://api.openai.com/v1", "model": "gpt-4o"}, "consolidate": {"autoArchiveDays": 30}}
@@ -1,22 +1,15 @@
1
1
  # >>> hermes-repo memory (do not edit this block manually)
2
- # 个人层 不提交
2
+ # 不提交(个人数据 / 运行时状态)
3
3
  .memory/captures/
4
- .memory/llm.json
5
- .memory/sessions/
6
- .memory/refs/
7
- .memory/personal/
8
- .memory/hermes-debug.log
9
4
  .memory/consolidate-state.json
10
5
  .memory/.consolidate.lock
11
- .memory/skill-usage.json
12
- .memory/promote/
13
6
 
14
- # 团队层 — 提交
15
- !.memory/topics/
16
- !.memory/skills/
7
+ # 提交到 Git(团队共享的知识)
17
8
  !.memory/MEMORY.md
18
- !.memory/MEMORY-*.md
19
- !.memory/team/
20
9
  !.memory/config.json
21
- !.memory/templates/
10
+ !.memory/rules/
11
+ !.memory/domains/
12
+ !.memory/workflows/
13
+ !.memory/decisions/
14
+ !.memory/incidents/
22
15
  # <<< hermes-repo memory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riconext/hermes-repo",
3
- "version": "0.15.1",
3
+ "version": "1.0.0",
4
4
  "description": "跨编程助手的项目级记忆系统",
5
5
  "packageManager": "bun@1.3.12",
6
6
  "type": "module",
@@ -1,21 +0,0 @@
1
- ## 记忆晋升申请
2
-
3
- ### 自动扫描结果
4
-
5
- 本次检测到 {total_count} 条 promoted capture,建议晋升 {ai_approve_count} 条到团队层。
6
-
7
- ---
8
-
9
- <!-- 由 `npx @riconext/hermes-repo promote --pr` 自动填充每条捕获 -->
10
-
11
- ### 操作说明
12
-
13
- 1. 每一条勾选一个选项
14
- 2. 如需说明,在对应项后附言
15
- 3. 提交 review → 根据勾选结果执行 `promote --apply`
16
-
17
- ### 本次晋升总览
18
-
19
- | 序号 | 摘要 | AI 建议 | scope |
20
- |------|------|---------|-------|
21
- | — | — | — | — |
@@ -1,23 +0,0 @@
1
- ---
2
- name: example-skill
3
- description: >
4
- (技能简短描述:何时激活、解决什么问题)
5
- version: 1.0.0
6
- author: @riconext/hermes-repo
7
- platforms: [linux, macos]
8
- trigger-tags: [workflow]
9
- created-from:
10
- - captures/procedural/capture-example.md
11
- ---
12
-
13
- ## 步骤
14
-
15
- 1. (步骤一)
16
-
17
- ## 常见陷阱
18
-
19
- - (易错点)
20
-
21
- ## 验证
22
-
23
- - (如何确认成功)
@@ -1,20 +0,0 @@
1
- ---
2
- type: episodic
3
- date: 2026-05-20
4
- session: example-session-id
5
- tags: [debugging, incident]
6
- scope: all
7
- confidence: pending
8
- ---
9
-
10
- ## 上下文
11
-
12
- (具体事件背景)
13
-
14
- ## 经过
15
-
16
- (发生了什么、采取了什么措施)
17
-
18
- ## 结果
19
-
20
- (最终结果与教训)
@@ -1,27 +0,0 @@
1
- ---
2
- type: procedural
3
- date: 2026-05-20
4
- session: example-session-id
5
- tags: [deploy, workflow]
6
- scope: all
7
- step_count: 0
8
- repeat_count: 1
9
- confidence: pending
10
- ---
11
-
12
- ## 目标
13
-
14
- (要完成什么)
15
-
16
- ## 步骤
17
-
18
- 1. (步骤一)
19
- 2. (步骤二)
20
-
21
- ## 注意
22
-
23
- (易错点、前置条件)
24
-
25
- ## 验证
26
-
27
- (如何确认成功)
@@ -1,20 +0,0 @@
1
- ---
2
- type: semantic
3
- date: 2026-05-20
4
- session: example-session-id
5
- tags: [auth, token, security]
6
- scope: all
7
- confidence: pending
8
- ---
9
-
10
- ## 上下文
11
-
12
- (描述当时正在做什么)
13
-
14
- ## 发现
15
-
16
- (项目事实、约定或架构决策)
17
-
18
- ## 影响
19
-
20
- (对后续开发的影响,可选)
@@ -1,10 +0,0 @@
1
- {
2
- "enabled": false,
3
- "provider": "openai",
4
- "baseUrl": "https://api.deepseek.com",
5
- "model": "deepseek-v4-flash",
6
- "apiKey": "",
7
- "timeoutMs": 60000,
8
- "maxInputChars": 24000,
9
- "mode": "async"
10
- }
@@ -1,6 +0,0 @@
1
- # Memory Steward 日志
2
-
3
- 记录团队记忆维护轮值与重要操作。
4
-
5
- | 日期 | 负责人 | 操作 |
6
- |------|--------|------|