@codehourra/llm-iwiki 0.2.1 → 0.3.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.
package/README.md CHANGED
@@ -1,77 +1,146 @@
1
1
  # llm-iwiki
2
2
 
3
- 面向 AI Agent 的本地知识库 CLI。
3
+ [简体中文](./README.zh-CN.md)
4
4
 
5
- `llm-iwiki` 会采集 Claude Code、Cursor、Codex、CodeBuddy 等 AI 编程工具的本地会话记录,按项目归一化到 SQLite,再通过 AI 工具生成结构化 YAML 摘要和经验候选,最终导出到 Obsidian。
5
+ [![npm version](https://img.shields.io/npm/v/@codehourra/llm-iwiki.svg)](https://www.npmjs.com/package/@codehourra/llm-iwiki)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@codehourra/llm-iwiki.svg)](https://www.npmjs.com/package/@codehourra/llm-iwiki)
7
+ [![Node.js](https://img.shields.io/node/v/@codehourra/llm-iwiki.svg)](https://www.npmjs.com/package/@codehourra/llm-iwiki)
8
+ [![Release](https://github.com/CodeHourra/llm-iwiki/actions/workflows/release.yml/badge.svg)](https://github.com/CodeHourra/llm-iwiki/actions/workflows/release.yml)
9
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
10
+ [![Changelog](https://img.shields.io/badge/changelog-CHANGELOG.md-blue)](./CHANGELOG.md)
6
11
 
7
- ## 安装
12
+ Turn local AI coding sessions into a searchable Obsidian knowledge base.
8
13
 
9
- > 运行时只需 [Node.js](https://nodejs.org) 20(无需 Bun)。SQLite 通过原生模块 `better-sqlite3` 提供,`npm install` 时自动下载预编译二进制。
14
+ `llm-iwiki` collects sessions from Claude Code, Cursor, Codex, Gemini, and CodeBuddy, normalizes them by project in SQLite, prepares AI-friendly summarization tasks, stores accepted project learnings, and exports navigable Markdown notes to Obsidian.
15
+
16
+ ## Features
17
+
18
+ - Collect local AI coding sessions across multiple tools.
19
+ - Resolve sessions by project, repository, path, or slug.
20
+ - Generate summarization and experience-extraction task files for AI assistants.
21
+ - Review and accept reusable engineering experiences before publishing them.
22
+ - Export project summaries, session notes, and project-scoped experiences to Obsidian.
23
+ - Preserve user-written note sections while updating managed content blocks.
24
+ - Search session summaries and accepted experiences from the CLI.
25
+
26
+ ## Requirements
27
+
28
+ - Node.js 20 or newer at runtime.
29
+ - Bun for local development, testing, and building.
30
+
31
+ SQLite is provided by `better-sqlite3`; prebuilt binaries are installed automatically by npm where available.
32
+
33
+ ## Installation
10
34
 
11
35
  ```bash
12
- # 全局安装
13
36
  npm install -g @codehourra/llm-iwiki
14
-
15
- llm-iwiki init # 初始化配置与状态库
16
- llm-iwiki doctor # 自检
17
37
  ```
18
38
 
19
- 也可以免安装、用 `npx` 直接运行:
39
+ You can also run it without installing globally:
20
40
 
21
41
  ```bash
22
- npx @codehourra/llm-iwiki init
23
- npx @codehourra/llm-iwiki sync
42
+ npx @codehourra/llm-iwiki --help
24
43
  ```
25
44
 
26
- ## 当前状态
45
+ ## Quick Start
27
46
 
28
- - Milestone 1(CLI 骨架与状态库)已完成:`init` / `doctor` / `projects resolve` / `projects rename`。
29
- - Milestone 2(Collectors)基本完成:已实现 **Claude Code / Codex / Cursor / Gemini / CodeBuddy** 五个 collector 与 `sync`,可把本地会话按项目归一化入库,并通过 `projects list` / `projects inspect` 按项目维度跨工具聚合查看。
30
- - Milestone 4(AI 协作总结)已完成:`summarize prepare` / `experiences prepare` 生成压缩后的 AI 任务,`summarize apply` / `experiences propose` 把外部 AI 产出的 YAML 落库到 `session_summaries` / `experience_candidates`。
31
- - Milestone 5(Obsidian 导出)已完成:`config set obsidian.vault <dir>` 配置库路径,`obsidian export` 将会话总结、已 accept 的经验和项目索引写成带 frontmatter + managed block 的 Markdown 笔记。更新采用非破坏式协议——保留用户手写区,托管块被手动改动时标记冲突并跳过,`--force` 才覆盖;`obsidian check` 只读扫描 vault 报告 drift/missing。
32
- - 经验生命周期:`experiences propose` 落库为候选(`experience_candidates`),`experiences candidates` 列出待审,`experiences accept/reject` 决定去留;accept 会把候选提升为正式 `experiences` 并建立 `session_experience_links`,再由 `obsidian export` 写出。
33
- - AI 助手集成:`skills init` 把一个中文 skill(`aiwiki-knowledge`)写入当前项目的 `.agents/skills/`,让 Claude Code / Codex / Cursor 读了即可自驱动「采集 → 总结 → 经验 → 导出」全流程,并内置了 YAML 输出规则避免格式错误。
47
+ ```bash
48
+ llm-iwiki init
49
+ llm-iwiki sync
50
+ llm-iwiki projects list
51
+ llm-iwiki projects inspect .
52
+ ```
53
+
54
+ Configure an Obsidian vault and export notes:
34
55
 
35
56
  ```bash
36
- llm-iwiki sync # 采集本地 AI 工具会话
37
- llm-iwiki projects list # 按项目查看会话数
38
- llm-iwiki projects inspect . # 查看某项目下各工具的会话
39
- llm-iwiki summarize prepare changed --project . # 生成会话总结任务
40
- llm-iwiki summarize apply --project . --file summaries.yaml
57
+ llm-iwiki config set obsidian.vault ~/Obsidian/Vault
58
+ llm-iwiki summarize prepare changed --project .
59
+ llm-iwiki summarize apply --project . --file .llm-iwiki/exchange/summaries.yaml
41
60
  llm-iwiki experiences prepare --project . --from changed-summaries
42
- llm-iwiki experiences propose --project . --file experiences.yaml
43
- llm-iwiki experiences candidates --project . # 查看经验候选
44
- llm-iwiki experiences accept <candidate-id> # 采纳为正式经验
45
- llm-iwiki config set obsidian.vault ~/Obsidian/Vault # 配置 Obsidian 库
46
- llm-iwiki obsidian export --project . # 导出为 Markdown 笔记
47
- llm-iwiki obsidian check # 检查笔记是否漂移
48
- llm-iwiki skills init # 写入 AI 助手 skill 模板
61
+ llm-iwiki experiences propose --project . --file .llm-iwiki/exchange/experiences.yaml
62
+ llm-iwiki experiences candidates --project .
63
+ llm-iwiki experiences accept <candidate-id>
64
+ llm-iwiki obsidian export --project .
49
65
  ```
50
66
 
51
- ### `skills init`
67
+ The `prepare` commands generate task files for an AI assistant. Write the corresponding YAML files from those task files, then apply/propose them with the commands above.
52
68
 
53
- 把中文 skill `aiwiki-knowledge` 写入当前项目的 `.agents/skills/`,让 Claude Code / Codex / Cursor 读了就能自驱动 `sync` → `summarize` → `experiences` → `obsidian export` 全流程。该 skill 内置了 YAML 输出规则(纯 YAML、不要代码围栏、不要占位符、`value` 四选一等),避免常见的格式错误。
69
+ ## Common Commands
70
+
71
+ ```bash
72
+ llm-iwiki sync [--project <path>]
73
+ llm-iwiki projects list
74
+ llm-iwiki projects inspect <project>
75
+ llm-iwiki projects dedupe
76
+ llm-iwiki sessions list --project <project>
77
+ llm-iwiki sessions read <session-id>
78
+ llm-iwiki summarize prepare [changed|all] --project <project>
79
+ llm-iwiki summarize apply --project <project> --file <summaries.yaml>
80
+ llm-iwiki experiences prepare --project <project> [--since 30d]
81
+ llm-iwiki experiences propose --project <project> --file <experiences.yaml>
82
+ llm-iwiki experiences accept <candidate-id>
83
+ llm-iwiki search <sessions|experiences> <query>
84
+ llm-iwiki obsidian export [--project <project>|--all]
85
+ llm-iwiki obsidian check
86
+ ```
87
+
88
+ `<project>` can be a local path, a `proj_xxx` id, a display name, or a slug. If multiple projects match, use `projects list` to pick the exact project id.
89
+
90
+ ## Obsidian Output
91
+
92
+ Exports are written under `LLM-iWiki/` in your configured vault:
93
+
94
+ ```text
95
+ LLM-iWiki/
96
+ ├── README.md
97
+ ├── Projects/
98
+ │ └── <project-slug>/
99
+ │ ├── Project Summary.md
100
+ │ ├── sessions/
101
+ │ └── experiences/
102
+ └── Topics/
103
+ ```
104
+
105
+ Generated notes use frontmatter plus an `aiwiki:managed` block. You can write your own notes outside the managed block; re-exporting preserves those sections unless `--force` is used.
106
+
107
+ ## AI Assistant Skill
108
+
109
+ Install the bundled `aiwiki-knowledge` skill into the current project:
54
110
 
55
111
  ```bash
56
- llm-iwiki skills # 列出可用 target 与将写入的 skill(等同 skills list)
57
112
  llm-iwiki skills init [--target codex|claude-code|cursor] [--force] [--dry-run]
58
113
  ```
59
114
 
60
- - `skills` / `skills list`:只读列出可用 target 和将写入 `.agents/skills/` 的 skill,不落盘。
61
- - `--target`:在 skill 末尾附上对应助手(Codex / Claude Code / Cursor)的适配说明;省略则不附加。
62
- - `--force`:覆盖已存在的同名文件(默认跳过)。
63
- - `--dry-run`:只预演将写入/跳过的文件,不落盘。
115
+ The skill teaches compatible assistants how to run the `sync -> summarize -> experiences -> export` workflow and how to produce valid YAML for `summarize apply` and `experiences propose`.
116
+
117
+ ## Development
118
+
119
+ ```bash
120
+ bun install
121
+ bun run typecheck
122
+ bun test
123
+ bun run build
124
+ ```
125
+
126
+ This project uses Changesets for versioning, changelog generation, and npm publishing:
127
+
128
+ ```bash
129
+ bun run changeset
130
+ bun run version-packages
131
+ bun run release
132
+ ```
133
+
134
+ User-facing changes should include a `.changeset/*.md` file. GitHub Actions creates the release PR and publishes to npm after the release PR is merged.
135
+
136
+ ## Changelog
137
+
138
+ See [CHANGELOG.md](./CHANGELOG.md).
139
+
140
+ ## Roadmap
64
141
 
65
- ## 待完成能力地图
142
+ See [docs/roadmap.md](./docs/roadmap.md).
66
143
 
67
- 以下为已在设计文档中规划、但尚未实现的进阶能力(按优先级粗排):
144
+ ## License
68
145
 
69
- | 能力 | 命令 | 说明 | 状态 |
70
- | --- | --- | --- | --- |
71
- | 经验融合 | `experiences merge <candidate-id> <experience-id>` | 人工确认后把候选正文融合进已有经验,先生成 `merge-preview-*.md` 预览,确认后改写 managed block,合并 `source_sessions` / `evidence`,保留用户手写区 | 待开发 |
72
- | 项目目录迁移 | `obsidian move-project <project-id>` | `projects rename` 后按 `obsidian_notes` 映射与 frontmatter 中的 `aiwiki_project_id` 迁移 vault 目录,目标已存在时先做冲突检查 | 待开发 |
73
- | 结构化检索 | `search [sessions\|experiences] <query>` | SQLite FTS5 为主检索(projects / sessions / messages / summaries / experiences),可选 ripgrep 检索已导出 Markdown,`--index sqlite\|obsidian\|all` 切换 | 待开发 |
74
- | 打开笔记 | `obsidian open <note-id>` | 在 Obsidian 中直接打开对应笔记 | 待开发 |
75
- | 路径冲突批处理 | `obsidian export --overwrite-conflicts \| --skip-conflicts` | 目录迁移 / 导出时对路径冲突批量选择,跳过的标记 `conflict_status=path_conflict` 供 `obsidian check` 持续报告 | 待开发 |
76
- | 增量范围导出 | `obsidian export --changed \| --all` | 按变更范围而非单项目导出 | 待开发 |
77
- | 时间窗筛选 | `experiences prepare --since 30d` | 经验提炼任务按时间窗口限定来源摘要 | 待开发 |
146
+ [MIT](./LICENSE)
@@ -0,0 +1,146 @@
1
+ # llm-iwiki
2
+
3
+ [English](./README.md)
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@codehourra/llm-iwiki.svg)](https://www.npmjs.com/package/@codehourra/llm-iwiki)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@codehourra/llm-iwiki.svg)](https://www.npmjs.com/package/@codehourra/llm-iwiki)
7
+ [![Node.js](https://img.shields.io/node/v/@codehourra/llm-iwiki.svg)](https://www.npmjs.com/package/@codehourra/llm-iwiki)
8
+ [![Release](https://github.com/CodeHourra/llm-iwiki/actions/workflows/release.yml/badge.svg)](https://github.com/CodeHourra/llm-iwiki/actions/workflows/release.yml)
9
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
10
+ [![Changelog](https://img.shields.io/badge/changelog-CHANGELOG.md-blue)](./CHANGELOG.md)
11
+
12
+ 把本地 AI 编程会话沉淀为可检索的 Obsidian 知识库。
13
+
14
+ `llm-iwiki` 会采集 Claude Code、Cursor、Codex、Gemini 和 CodeBuddy 的本地会话记录,按项目归一化到 SQLite,生成适合 AI 助手处理的总结任务,保存经过确认的项目经验,并导出为可导航的 Obsidian Markdown 笔记。
15
+
16
+ ## 功能特性
17
+
18
+ - 采集多个 AI 编程工具的本地会话记录。
19
+ - 按项目、仓库、路径或 slug 解析和归类会话。
20
+ - 为 AI 助手生成会话总结和经验提取任务文件。
21
+ - 在发布到知识库前审核并采纳可复用的工程经验。
22
+ - 导出项目摘要、会话笔记和项目经验到 Obsidian。
23
+ - 更新托管内容块时保留用户手写区域。
24
+ - 通过 CLI 检索会话摘要和已采纳经验。
25
+
26
+ ## 环境要求
27
+
28
+ - 运行时需要 Node.js 20 或更高版本。
29
+ - 本地开发、测试和构建需要 Bun。
30
+
31
+ SQLite 由 `better-sqlite3` 提供;npm 安装时会自动下载可用的预编译二进制。
32
+
33
+ ## 安装
34
+
35
+ ```bash
36
+ npm install -g @codehourra/llm-iwiki
37
+ ```
38
+
39
+ 也可以不全局安装,直接使用 `npx`:
40
+
41
+ ```bash
42
+ npx @codehourra/llm-iwiki --help
43
+ ```
44
+
45
+ ## 快速开始
46
+
47
+ ```bash
48
+ llm-iwiki init
49
+ llm-iwiki sync
50
+ llm-iwiki projects list
51
+ llm-iwiki projects inspect .
52
+ ```
53
+
54
+ 配置 Obsidian 库并导出笔记:
55
+
56
+ ```bash
57
+ llm-iwiki config set obsidian.vault ~/Obsidian/Vault
58
+ llm-iwiki summarize prepare changed --project .
59
+ llm-iwiki summarize apply --project . --file .llm-iwiki/exchange/summaries.yaml
60
+ llm-iwiki experiences prepare --project . --from changed-summaries
61
+ llm-iwiki experiences propose --project . --file .llm-iwiki/exchange/experiences.yaml
62
+ llm-iwiki experiences candidates --project .
63
+ llm-iwiki experiences accept <candidate-id>
64
+ llm-iwiki obsidian export --project .
65
+ ```
66
+
67
+ `prepare` 命令会生成供 AI 助手阅读的任务文件。根据任务文件编写对应 YAML 后,再用上面的 `apply` / `propose` 命令落库。
68
+
69
+ ## 常用命令
70
+
71
+ ```bash
72
+ llm-iwiki sync [--project <path>]
73
+ llm-iwiki projects list
74
+ llm-iwiki projects inspect <project>
75
+ llm-iwiki projects dedupe
76
+ llm-iwiki sessions list --project <project>
77
+ llm-iwiki sessions read <session-id>
78
+ llm-iwiki summarize prepare [changed|all] --project <project>
79
+ llm-iwiki summarize apply --project <project> --file <summaries.yaml>
80
+ llm-iwiki experiences prepare --project <project> [--since 30d]
81
+ llm-iwiki experiences propose --project <project> --file <experiences.yaml>
82
+ llm-iwiki experiences accept <candidate-id>
83
+ llm-iwiki search <sessions|experiences> <query>
84
+ llm-iwiki obsidian export [--project <project>|--all]
85
+ llm-iwiki obsidian check
86
+ ```
87
+
88
+ `<project>` 可以是本地路径、`proj_xxx` 项目 id、展示名或 slug。如果匹配到多个项目,请先用 `projects list` 找到准确的项目 id。
89
+
90
+ ## Obsidian 输出结构
91
+
92
+ 导出内容会写入已配置 vault 下的 `LLM-iWiki/` 目录:
93
+
94
+ ```text
95
+ LLM-iWiki/
96
+ ├── README.md
97
+ ├── Projects/
98
+ │ └── <project-slug>/
99
+ │ ├── Project Summary.md
100
+ │ ├── sessions/
101
+ │ └── experiences/
102
+ └── Topics/
103
+ ```
104
+
105
+ 生成的笔记包含 frontmatter 和 `aiwiki:managed` 托管内容块。你可以在托管块之外自由补充内容;重新导出时会保留这些手写内容,除非显式使用 `--force`。
106
+
107
+ ## AI 助手 Skill
108
+
109
+ 将内置的 `aiwiki-knowledge` skill 安装到当前项目:
110
+
111
+ ```bash
112
+ llm-iwiki skills init [--target codex|claude-code|cursor] [--force] [--dry-run]
113
+ ```
114
+
115
+ 这个 skill 会教兼容的 AI 助手如何执行 `sync -> summarize -> experiences -> export` 流程,以及如何为 `summarize apply` 和 `experiences propose` 生成合法 YAML。
116
+
117
+ ## 开发
118
+
119
+ ```bash
120
+ bun install
121
+ bun run typecheck
122
+ bun test
123
+ bun run build
124
+ ```
125
+
126
+ 项目使用 Changesets 管理版本号、变更记录和 npm 发布:
127
+
128
+ ```bash
129
+ bun run changeset
130
+ bun run version-packages
131
+ bun run release
132
+ ```
133
+
134
+ 面向用户的变更应包含一个 `.changeset/*.md` 文件。GitHub Actions 会创建发布 PR,并在发布 PR 合并后发布到 npm。
135
+
136
+ ## 变更记录
137
+
138
+ 见 [CHANGELOG.md](./CHANGELOG.md)。
139
+
140
+ ## 路线图
141
+
142
+ 见 [docs/roadmap.zh-CN.md](./docs/roadmap.zh-CN.md)。
143
+
144
+ ## 许可证
145
+
146
+ [MIT](./LICENSE)