@yottameta/yotta-logs 0.1.0 → 0.2.1
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.
- package/CHANGELOG.md +22 -0
- package/README.md +100 -81
- package/README.zh-CN.md +182 -0
- package/SKILL.md +35 -25
- package/package.json +4 -3
- package/references/agent-formats.md +127 -0
- package/references/cli.md +23 -11
- package/references/format.md +60 -25
- package/references/security.md +8 -7
- package/scripts/test_yotta_logs.py +353 -0
- package/scripts/yotta_logs.py +1419 -337
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yottameta/yotta-logs",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Yuanshi — a skill for retrieving historical session / memory logs across AI agents: zero-dependency search and analysis of JSONL, JSON, SQLite and Markdown session & memory files (unified Record + field-alias normalization + config fallback), with full source discovery to recall past conversations and parent-session context. Triggers when the user asks about previously discussed content / a parent session / historical context, wants to look up an earlier conclusion, traces a past discussion across sessions, or needs to locate a decision in session logs or memory files. Boundaries: reads only the local agent's own session logs / memory files; never modifies or deletes records; local-only, never uploaded.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"agent-skills",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"assets",
|
|
18
18
|
"bin",
|
|
19
19
|
"NOTICE",
|
|
20
|
-
"CHANGELOG.md"
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"README.zh-CN.md"
|
|
21
22
|
],
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# AI 智能体会话 / 记忆存储格式普查登记表(agent-formats)
|
|
2
|
+
|
|
3
|
+
> v0.2.0 通用化依据:元史(yotta-logs)不再只认 JSONL,按「格式族 × 字段别名归一 + 配置兜底」适配一切格式。
|
|
4
|
+
> 本表是普查结论:6 大格式族、统一记录模型、字段别名映射、已知根与配置兜底。引擎行为见 `cli.md` / `format.md`。
|
|
5
|
+
|
|
6
|
+
## 一、总览:6 大格式族
|
|
7
|
+
|
|
8
|
+
| # | 格式族 | format | 代表智能体 / 存储 | 特征 |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| 1 | JSONL | jsonl | Claude Code / Codex CLI / Gemini 新版 / Copilot / Qwen / 多数会话 | 每行一个 JSON 对象,追加写入 |
|
|
11
|
+
| 2 | 单文件 JSON | json | Cline / Roo / Continue / Gemini 旧版 | 一个文件存整个会话 / 会话集(数组或对象) |
|
|
12
|
+
| 3 | SQLite | sqlite | opencode / Cursor state.vscdb / Trae / Copilot CLI session-store / CodeBuddy | 关系表存会话 / 消息 / 片段,字段多为 JSON 字符串 |
|
|
13
|
+
| 4 | Markdown | markdown | Aider .aider.chat.history.md / 各类自由笔记 | # 标题 + 正文 |
|
|
14
|
+
| 5 | 结构化 Markdown(YAML frontmatter) | markdown | yotta-memory / agent-code / opencode-agent-memory | --- frontmatter 元数据 + 正文 |
|
|
15
|
+
| 6 | 二进制 / 专有 / 加密 | binary | Windsurf pbtxt / Cascade / JetBrains Nitrite | 只降级读标题,不崩 |
|
|
16
|
+
|
|
17
|
+
## 二、统一记录模型 Record
|
|
18
|
+
|
|
19
|
+
所有 reader 产同构记录:`{source, format, kind, session, time, role, text, path, meta}`。
|
|
20
|
+
|
|
21
|
+
| 字段 | 说明 | 字段别名(按序取首个命中) |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| source | 来源名(如 codex-sessions / opencode-db / yottamemory-facts / codex-notes) | 来源登记名 |
|
|
24
|
+
| format | jsonl / json / sqlite / markdown / binary | 文件嗅探 / 配置 |
|
|
25
|
+
| kind | session / memory / note / log | 来源登记或逐记录判定 |
|
|
26
|
+
| session | 会话 ID / 文件名主干 / 相对路径 | session_id / thread_id / sessionId / session / conversation_id / threadId;缺省取文件主干 |
|
|
27
|
+
| time | 归一化 ISO 时间戳(秒 / 毫秒自动推断) | timestamp / time_created / created / time / ts / date / created_at / mtime / updated |
|
|
28
|
+
| role | user / assistant / tool / system / developer;结构化 md 的 type=FACT/PREF/BOUND/COMMIT → role | role / type / kind(message 内或 payload 内均可) |
|
|
29
|
+
| text | 人类可读文本 | text / content / body / message / statement;content 列表取 type=text / input_text / output_text |
|
|
30
|
+
| path | 绝对路径 | 文件路径 |
|
|
31
|
+
| meta | 额外字段(title / tags / tools / cost / tokens…) | title←title / subject / name / # 一级标题 |
|
|
32
|
+
|
|
33
|
+
## 三、各格式族详情
|
|
34
|
+
|
|
35
|
+
### 3.1 JSONL(jsonl)
|
|
36
|
+
|
|
37
|
+
- 代表:Claude Code(~/.claude/projects/*)、Codex CLI(~/.codex/sessions,CODEX_HOME 可覆盖;嵌套子目录)、Clawdbot(~/.clawdbot/agents/*/sessions)、opencode sessions 目录、Gemini 新版、Copilot、Qwen。
|
|
38
|
+
- 每行一个 JSON 对象:`type=session/message`;`message.role`;`message.content` 字符串或列表(type=text/toolCall/toolResult);`message.usage`。
|
|
39
|
+
- Codex rollout 形态(本机实测 2026-08-27):`{timestamp, type, payload:{type, role, content, usage}}`——`payload.type=message` 取 role / content;`payload.type=function_call / function_call_output / local_shell_call` 归一为 tool 并提取工具名;reasoning / event_msg 不进文本。
|
|
40
|
+
- 可选 `sessions.json` 索引(别名 → 会话 ID)。
|
|
41
|
+
- 容错:坏行跳过并计数,不中断。
|
|
42
|
+
|
|
43
|
+
### 3.2 单文件 JSON(json)
|
|
44
|
+
|
|
45
|
+
- 代表:Cline / Roo / Continue(~/.continue/sessions/*.json)、Gemini 旧版。
|
|
46
|
+
- 形态:JSON 数组(每条一个消息);对象 {会话ID: [消息...]};对象 {会话ID: 单消息}。
|
|
47
|
+
- 归一:数组逐条;对象遍历值。
|
|
48
|
+
|
|
49
|
+
### 3.3 SQLite(sqlite)
|
|
50
|
+
|
|
51
|
+
- 代表:opencode(~/.local/share/opencode/opencode.db;本机实测 D:\AI_WorkDir\.OpenCodeData\data\opencode\opencode.db,走 XDG_DATA_HOME / OPENCODE_DATA)、Cursor state.vscdb、Trae、Copilot CLI session-store、CodeBuddy。
|
|
52
|
+
- opencode 实测 schema(2026-08-27,D:\AI_WorkDir\.OpenCodeData\data\opencode\opencode.db):
|
|
53
|
+
- `session(id, project_id, title, cost, tokens_input, tokens_output, time_created[毫秒], ...)`
|
|
54
|
+
- `message(id, session_id, time_created[毫秒], data[JSON: role, time, agent, model, ...])`
|
|
55
|
+
- `part(id, message_id, session_id, time_created[毫秒], data[JSON: type=text/tool/reasoning/step-start...])`——text 部分取 `text` 字段;tool 部分取 `tool` 字段为工具名。
|
|
56
|
+
- 只读连接:`sqlite3.connect("file:<path>?mode=ro", uri=True)`,绝不写库。
|
|
57
|
+
- 通用兜底:配置指定 `table / col_time / col_role / col_text / col_session / col_title`;未指定则按字段别名嗅探「消息类」表。
|
|
58
|
+
|
|
59
|
+
### 3.4 Markdown(markdown)
|
|
60
|
+
|
|
61
|
+
- 代表:Aider(repo 下 *.aider.chat.history.md)、各类自由笔记(Codex memories)。
|
|
62
|
+
- 无 frontmatter:`# 一级标题` → title,正文 → text,文件 mtime → time,kind=note。
|
|
63
|
+
|
|
64
|
+
### 3.5 结构化 Markdown(markdown + YAML frontmatter)
|
|
65
|
+
|
|
66
|
+
- 代表:yotta-memory(记忆库 facts / private / archive 下的 *.md)、agent-code、opencode-agent-memory。
|
|
67
|
+
- frontmatter:`type`(FACT/PREF/BOUND/COMMIT → role)、`subject` → title、`statement` → text、`created / updated / date` → time、`tags / confidence / scope / owner / immutable` → meta。
|
|
68
|
+
- 本机实测样本(2026-08-27):D:\AI_WorkDir\.yottamemory\facts\2026-08-25-0002.md(记忆库位置由 ~/.yottamemory/config.json 的 `memory_home` 决定)。
|
|
69
|
+
- frontmatter 解析为零依赖 YAML 子集(key: value / key: [a, b] / 引号),非完整 YAML。
|
|
70
|
+
|
|
71
|
+
### 3.6 二进制 / 专有 / 加密(binary)
|
|
72
|
+
|
|
73
|
+
- 代表:Windsurf pbtxt(~/.codeium/windsurf/**/*.pbtxt)、Cascade、JetBrains Nitrite。
|
|
74
|
+
- 只降级读 title(文件名 / 首个可读片段),不崩;kind=log,默认关。
|
|
75
|
+
|
|
76
|
+
## 四、已知根(discover 全源登记)
|
|
77
|
+
|
|
78
|
+
| 来源名 | 根路径 | format | kind | 默认范围 |
|
|
79
|
+
|---|---|---|---|---|
|
|
80
|
+
| codex-sessions | ~/.codex/sessions(CODEX_HOME 覆盖,支持嵌套子目录) | jsonl | session | 开 |
|
|
81
|
+
| claude-projects | ~/.claude/projects/* | jsonl | session | 开 |
|
|
82
|
+
| clawdbot-sessions | ~/.clawdbot/agents/*/sessions | jsonl | session | 开 |
|
|
83
|
+
| opencode-sessions | ~/.config/opencode/sessions | jsonl | session | 开 |
|
|
84
|
+
| gemini-sessions | ~/.gemini/sessions | jsonl | session | 开 |
|
|
85
|
+
| agents-sessions | ~/.agents/sessions | jsonl | session | 开 |
|
|
86
|
+
| opencode-db | ~/.local/share/opencode/opencode.db;$XDG_DATA_HOME/opencode/opencode.db;$OPENCODE_DATA;~/.OpenCodeData/data/opencode/opencode.db | sqlite | session | 开 |
|
|
87
|
+
| cursor-state / code-state | VS Code / Cursor globalStorage 下 state.vscdb(Windows / Linux / macOS) | sqlite | session | 开 |
|
|
88
|
+
| continue-sessions | ~/.continue/sessions、~/.config/continue/sessions | json | session | 开 |
|
|
89
|
+
| yottamemory-facts | 记忆库 facts(memory_home 配置) | markdown | memory | 开 |
|
|
90
|
+
| yottamemory-private | 记忆库 private(memory_home 配置) | markdown | memory | 开 |
|
|
91
|
+
| yottamemory-archive | 记忆库 archive(memory_home 配置) | markdown | memory | 开 |
|
|
92
|
+
| codex-notes | $CODEX_HOME/memories、~/.CodexData/memories | markdown | note | 关(显式开) |
|
|
93
|
+
| aider-history | 当前目录 *.aider.*.md | markdown | session | 开 |
|
|
94
|
+
| windsurf-conv | ~/.codeium/windsurf、~/.windsurf 下 *.pbtxt | binary | log | 关 |
|
|
95
|
+
| 自定义 sources | 配置 sources[](见下) | 任意 | 任意 | 配置 default_scope |
|
|
96
|
+
|
|
97
|
+
## 五、配置兜底(config.json)
|
|
98
|
+
|
|
99
|
+
路径:`$YOTTA_LOGS_CONFIG` 或 `~/.config/yotta-logs/config.json`。
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"default_scope": ["session", "memory"],
|
|
104
|
+
"sources": [
|
|
105
|
+
{
|
|
106
|
+
"name": "myapp",
|
|
107
|
+
"path": "/path/to/logs",
|
|
108
|
+
"format": "sqlite",
|
|
109
|
+
"kind": "session",
|
|
110
|
+
"table": "messages",
|
|
111
|
+
"col_time": "created_at",
|
|
112
|
+
"col_role": "role",
|
|
113
|
+
"col_text": "content",
|
|
114
|
+
"col_session": "session_id",
|
|
115
|
+
"col_title": "title"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
引擎零改动即可接入怪格式(个别 agent 私有 schema 用列映射接入)。
|
|
122
|
+
|
|
123
|
+
## 六、默认检索范围(2026-08-27 老张拍板)
|
|
124
|
+
|
|
125
|
+
- 会话源(kind=session)+ 结构化记忆源(kind=memory)**默认开**;
|
|
126
|
+
- 自由笔记(kind=note)与二进制日志(kind=log)**默认关**,可 `--kind note` / `--kind log` 显式开;
|
|
127
|
+
- 显式指定 `--dir / --source / --format / --kind` 时以显式条件为准。
|
package/references/cli.md
CHANGED
|
@@ -6,45 +6,50 @@
|
|
|
6
6
|
|
|
7
7
|
| 选项 | 说明 |
|
|
8
8
|
|---|---|
|
|
9
|
-
| --dir PATH |
|
|
9
|
+
| --dir PATH | 日志 / 记忆目录或文件;目录自动嗅探格式族(jsonl / json / sqlite / markdown),也支持单文件(含 .db / .md / .jsonl) |
|
|
10
|
+
| --source NAME | 只检索指定来源(可多次;名称见 locate 登记,如 codex-sessions / opencode-db / yottamemory-facts / codex-notes) |
|
|
11
|
+
| --kind KIND | 只检索指定类型:session / memory / note / log |
|
|
12
|
+
| --format FMT | 只检索指定格式:jsonl / json / sqlite / markdown / binary |
|
|
10
13
|
| --json | 输出纯净 JSON(stdout 无其它噪音) |
|
|
11
14
|
| --no-redact | 关闭默认脱敏 |
|
|
12
15
|
| --limit N | 最多返回 N 条(默认 50) |
|
|
13
16
|
| --version | 打印版本 |
|
|
14
17
|
|
|
18
|
+
未指定 --dir 时:依次尝试 YOTTA_LOGS_DIR → discover 全源登记(locate 逻辑),并按默认检索范围(会话 + 结构化记忆开、自由笔记 / 二进制日志关)过滤;显式 --source / --kind / --format 可覆盖默认范围。
|
|
19
|
+
|
|
15
20
|
## 子命令
|
|
16
21
|
|
|
17
22
|
### locate
|
|
18
|
-
|
|
23
|
+
全源登记:遍历所有 reader 的 discover(),登记本机存在的日志 / 记忆源(来源 / 格式 / 类型 / 路径 / 默认开关)。`--json` 输出 `{tool, version, default_scope, sources[]}`。无源退出码 1。
|
|
19
24
|
|
|
20
25
|
### scan
|
|
21
|
-
|
|
26
|
+
列出所有会话(跨源):来源 / 会话 ID / 日期(首条消息)/ 消息数 / 大小 / 别名。支持 `--source/--kind/--format`、`--limit`(全局截断)、`--json`。空结果退出码 1。
|
|
22
27
|
|
|
23
28
|
### search <query>
|
|
24
|
-
|
|
29
|
+
跨源检索,输出时间线命中(来源 / 会话 / 时间 / 角色 / 原文片段)。
|
|
25
30
|
|
|
26
31
|
| 选项 | 说明 |
|
|
27
32
|
|---|---|
|
|
28
33
|
| --regex | 把 query 当正则(默认不区分大小写) |
|
|
29
34
|
| --date YYYY-MM-DD | 只检索指定日期(也支持 YYYY-MM) |
|
|
30
35
|
| -s / --session SID | 只检索指定会话 ID / 别名(可多次) |
|
|
31
|
-
| --role ROLE | user / assistant / tool / system |
|
|
36
|
+
| --role ROLE | user / assistant / tool / system / developer |
|
|
32
37
|
| --context N | 命中上下文半径字符数(默认 40) |
|
|
33
38
|
| --limit N | 最多返回 N 条(默认 50) |
|
|
34
39
|
|
|
35
|
-
--json 输出:`{command, tool, version, query, regex,
|
|
40
|
+
--json 输出:`{command, tool, version, query, regex, sources[], total_matches, sessions_hit, truncated, matches[]}`,每条命中含 `source / format / kind / session / timestamp / role / line / match / text`。
|
|
36
41
|
|
|
37
42
|
### session <sid>
|
|
38
|
-
提取单个会话原文(时间线 + 角色 + 文本)。`--role` 过滤、`--tools` 标注工具调用、`--limit`、`--json`。未知会话退出码 4
|
|
43
|
+
提取单个会话原文(时间线 + 角色 + 文本)。`--role` 过滤、`--tools` 标注工具调用、`--source/--kind/--format`、`--limit`、`--json`。未知会话退出码 4。跨源同名会话取第一个,可用 `--source` 消歧。
|
|
39
44
|
|
|
40
45
|
### stats
|
|
41
|
-
|
|
46
|
+
会话统计(跨源):会话 / 消息 / 角色分布 / token / 成本 / 时间范围 / 分源(by_source);`--daily` 输出每日汇总;`-s/--session` 限定单会话。空结果退出码 1。
|
|
42
47
|
|
|
43
48
|
### tools
|
|
44
|
-
|
|
49
|
+
工具调用次数排行(toolCall / toolResult / payload function_call 的工具名计数),`-s/--session` 限定单会话。
|
|
45
50
|
|
|
46
51
|
### version
|
|
47
|
-
打印 `yotta-logs 0.
|
|
52
|
+
打印 `yotta-logs 0.2.0`。
|
|
48
53
|
|
|
49
54
|
## 退出码
|
|
50
55
|
|
|
@@ -52,9 +57,16 @@
|
|
|
52
57
|
|---|---|
|
|
53
58
|
| 0 | 成功(检索到结果 / 操作完成) |
|
|
54
59
|
| 1 | 无匹配 / 空结果集 |
|
|
55
|
-
| 4 | 用法错误 /
|
|
60
|
+
| 4 | 用法错误 / 路径不存在 / 未知会话 / 致命异常 |
|
|
56
61
|
|
|
57
62
|
## JSON 输出约定
|
|
58
63
|
|
|
59
64
|
- stdout 只输出 JSON,进度 / 提示走 stderr;
|
|
60
65
|
- `ensure_ascii=False`,中文原样输出;stdout 已重配 UTF-8(GBK 控制台不炸)。
|
|
66
|
+
|
|
67
|
+
## 配置(配置兜底)
|
|
68
|
+
|
|
69
|
+
- 配置文件:`$YOTTA_LOGS_CONFIG` 或 `~/.config/yotta-logs/config.json`;
|
|
70
|
+
- `default_scope`:默认检索范围(默认 `["session", "memory"]`);
|
|
71
|
+
- `sources[]`:自定义源(path / format / kind / name / table / col_time / col_role / col_text / col_session / col_title),引擎零改动接入怪格式。
|
|
72
|
+
- 示例见 `agent-formats.md` 第五节。
|
package/references/format.md
CHANGED
|
@@ -1,40 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 日志 / 记忆格式(format)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
元史 v0.2.0 起按「格式族 × 字段别名归一 + 配置兜底」适配一切格式,统一产出 Record。
|
|
4
|
+
格式普查与各智能体存储位置见 `agent-formats.md`。
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## 统一记录模型 Record
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
所有 reader 产同构记录:
|
|
8
9
|
|
|
9
10
|
| 字段 | 说明 |
|
|
10
11
|
|---|---|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
12
|
+
| source | 来源名(codex-sessions / opencode-db / yottamemory-facts / codex-notes …) |
|
|
13
|
+
| format | jsonl / json / sqlite / markdown / binary |
|
|
14
|
+
| kind | session / memory / note / log |
|
|
15
|
+
| session | 会话 ID / 文件名主干 |
|
|
16
|
+
| time | 归一化 ISO 时间戳(秒 / 毫秒自动推断,Z 转 +00:00) |
|
|
17
|
+
| role | user / assistant / tool / system / developer;结构化 md 为 FACT/PREF/BOUND/COMMIT |
|
|
18
|
+
| text | 人类可读文本 |
|
|
19
|
+
| path | 绝对路径 |
|
|
20
|
+
| meta | 额外字段(title / tags / tools / cost / tokens_in / tokens_out / line …) |
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
## 字段别名归一(适配一切关键字段)
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
| 语义 | 别名(按序取首个命中) |
|
|
25
|
+
|---|---|
|
|
26
|
+
| time | timestamp / time_created / created / time / ts / date / created_at / mtime / updated |
|
|
27
|
+
| role | role / type / kind(message 内或 payload 内均可) |
|
|
28
|
+
| text | text / content / body / message / statement / text_content |
|
|
29
|
+
| session | session_id / thread_id / sessionId / session / conversation_id / threadId |
|
|
30
|
+
| title | title / subject / name / heading;md 无 frontmatter 时取 # 一级标题 |
|
|
31
|
+
|
|
32
|
+
- content 为列表时取 `type=text / input_text / output_text` 项;
|
|
33
|
+
- JSON 字符串字段自动解包一层;
|
|
34
|
+
- 秒 / 毫秒时间戳自动推断(13 位及以上按毫秒)。
|
|
35
|
+
|
|
36
|
+
## 各格式族读取规则
|
|
37
|
+
|
|
38
|
+
### JSONL(jsonl)
|
|
39
|
+
|
|
40
|
+
- 目录 = 会话集(支持嵌套子目录,如 Codex `sessions/2026/08/27/xxx.jsonl`);可选 `sessions.json` 索引(别名 → 会话 ID)。
|
|
41
|
+
- 每行一个 JSON 对象;`message` / `payload` 内取 role / content / usage。
|
|
42
|
+
- Codex rollout 形态:`payload.type=message` 取 role / content;`function_call / function_call_output / local_shell_call` 归一为 tool 并提取工具名;reasoning / event_msg 不进文本。
|
|
43
|
+
- 坏行跳过并计入 invalid。
|
|
44
|
+
|
|
45
|
+
### 单文件 JSON(json)
|
|
46
|
+
|
|
47
|
+
- 数组 = 一条条消息;对象 = {会话ID: [消息...]} 或 {会话ID: 单消息}。
|
|
48
|
+
|
|
49
|
+
### SQLite(sqlite)
|
|
50
|
+
|
|
51
|
+
- 只读连接 `file:<path>?mode=ro`(uri=True),绝不写库。
|
|
52
|
+
- opencode schema 实测:session(id, title, cost, tokens_input, tokens_output, time_created[毫秒]) + message(id, session_id, data[JSON role]) + part(message_id, data[JSON type=text/tool/reasoning])。text 部分取 text 字段;tool 部分取 tool 字段为工具名;reasoning 不进文本。
|
|
53
|
+
- 通用兜底:配置指定 table / col_time / col_role / col_text / col_session / col_title;未指定则按字段别名嗅探消息类表。
|
|
54
|
+
|
|
55
|
+
### Markdown(markdown)
|
|
56
|
+
|
|
57
|
+
- 有 YAML frontmatter(`---` 开头):type→role、subject→title、statement→text、created/updated/date→time、tags/confidence/scope/owner/immutable→meta;kind=memory。
|
|
58
|
+
- 无 frontmatter:# 一级标题→title,正文→text,mtime→time;kind=note。
|
|
59
|
+
- frontmatter 解析为零依赖 YAML 子集(key: value / key: [a, b] / 引号包裹)。
|
|
21
60
|
|
|
22
|
-
|
|
61
|
+
### 二进制 / 专有 / 加密(binary)
|
|
23
62
|
|
|
24
|
-
|
|
25
|
-
{ "微信-部署": "a1", "ci-排查": "b2" }
|
|
26
|
-
```
|
|
63
|
+
- 只降级读 title(文件名 / 首个可读片段),不崩;kind=log。
|
|
27
64
|
|
|
28
|
-
|
|
29
|
-
[ { "key": "微信-部署", "sessionId": "a1" } ]
|
|
30
|
-
```
|
|
65
|
+
## 会话 ID 规则
|
|
31
66
|
|
|
32
|
-
|
|
67
|
+
- JSONL / Markdown / Binary:文件名主干(去掉扩展名);
|
|
68
|
+
- 单文件 JSON 数组:文件主干;对象:键名(会话 ID);
|
|
69
|
+
- SQLite:session 表 id(opencode)或 col_session 列值;无会话列时取文件主干。
|
|
33
70
|
|
|
34
71
|
## 容错规则
|
|
35
72
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- 坏行(非法 JSON / 非对象)跳过并计入 `invalid`,不中断检索;
|
|
40
|
-
- 非 `.jsonl` 文件(如 `sessions.json`、`notes.txt`)不会被当作会话。
|
|
73
|
+
- 坏行 / 坏 JSON 字段跳过并计数(invalid),不中断检索;
|
|
74
|
+
- 二进制 / 加密文件只回退标题,不抛错;
|
|
75
|
+
- 所有读取均为只读,绝不修改 / 删除 / 写入。
|
package/references/security.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 只读保证
|
|
4
4
|
|
|
5
|
-
- 引擎只调用读取类操作(`open(path, "r")
|
|
5
|
+
- 引擎只调用读取类操作(`open(path, "r")`、SQLite `file:<path>?mode=ro` 只读 URI),对任何日志 / 记忆文件与数据库不做写入 / 修改 / 删除;
|
|
6
6
|
- 检索、提取、统计全程无网络请求;不把日志内容上传到任何服务;
|
|
7
7
|
- 测试含只读回归:跑完 scan / search / session / stats / tools 后目录文件清单与大小不变。
|
|
8
8
|
|
|
@@ -26,17 +26,18 @@ URL 路径(非凭据)原文保留,方便回溯链接。
|
|
|
26
26
|
|
|
27
27
|
## 边界
|
|
28
28
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
29
|
+
- 只检索显式传入的 `--dir`(或环境变量 / discover 登记的来源),不主动扫描整盘;
|
|
30
|
+
- 默认检索范围只含会话源 + 结构化记忆源;自由笔记(kind=note)与二进制日志(kind=log)默认不读,需显式 `--kind note / --kind log` 或配置 default_scope 开启;
|
|
31
|
+
- discover 只登记已知根(见 agent-formats.md 第四节),命中即登记来源,不展开内容;
|
|
32
|
+
- 输出可能包含会话 / 记忆原文中的隐私,默认脱敏且仅用于本机回溯,请勿外传。
|
|
32
33
|
|
|
33
34
|
## 与元忆(yotta-memory)的分工
|
|
34
35
|
|
|
35
36
|
| 维度 | yotta-logs(元史) | yotta-memory(元忆) |
|
|
36
37
|
|---|---|---|
|
|
37
|
-
| 定位 |
|
|
38
|
-
| 输出 | 原文片段 + 行号 + 时间戳 | 记忆条目 + 权限边界 + 画像 |
|
|
38
|
+
| 定位 | 原始会话日志 / 记忆文件(JSONL / JSON / SQLite / Markdown 事实) | 语义记忆(结构化条目 + 权限边界) |
|
|
39
|
+
| 输出 | 原文片段 + 行号 + 时间戳 + 来源 | 记忆条目 + 权限边界 + 画像 |
|
|
39
40
|
| 写操作 | 无(只读) | 支持(remember / forget / archive) |
|
|
40
|
-
| 权限 |
|
|
41
|
+
| 权限 | 目录 / 来源级只读 | 类型 / 属主级权限边界 |
|
|
41
42
|
|
|
42
43
|
回溯「原文」用元史;沉淀「长期知识 / 偏好 / 承诺」用元忆,二者互补。
|