@devflow-tools/knowledge-engine 0.17.5 → 0.17.7

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.
Files changed (2) hide show
  1. package/README.md +20 -62
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,87 +1,45 @@
1
1
  # @devflow-tools/knowledge-engine
2
2
 
3
- DevFlow 知识引擎 — 从技术文档站同步内容,BM25 搜索,支持 SPA 页面和静态 HTML。
3
+ > 同步官方文档并进行结构化切分、BM25/混合检索和知识质量评估。(v0.17.7)
4
4
 
5
- ## Installation
5
+ [![npm version](https://img.shields.io/npm/v/%40devflow-tools%2Fknowledge-engine.svg)](https://www.npmjs.com/package/@devflow-tools/knowledge-engine)
6
+
7
+ ## 安装
6
8
 
7
9
  ```bash
8
10
  npm install @devflow-tools/knowledge-engine
9
11
  ```
10
12
 
11
- ## Usage
12
-
13
- ```typescript
14
- import { KnowledgeEngine } from '@devflow-tools/knowledge-engine';
15
-
16
- const engine = new KnowledgeEngine({ projectRoot: '/path/to/project' });
17
-
18
- // 注册知识源
19
- await engine.registerSource({
20
- name: 'react',
21
- urls: ['https://react.dev/reference'],
22
- pluginName: 'react',
23
- version: '19.0.0',
24
- renderJs: true, // SPA 页面需要 Playwright 渲染
25
- });
26
-
27
- // 同步文档
28
- const results = await engine.syncDocs('react');
29
-
30
- // 搜索知识库
31
- const entries = await engine.search('useEffect cleanup');
32
- ```
33
-
34
- The standalone constructor uses lexical, entity, and BM25 retrieval without loading
35
- the embedding runtime. Vector search and vector backfill require explicit injection:
13
+ ## 快速开始
36
14
 
37
15
  ```typescript
38
16
  import { KnowledgeEngine } from '@devflow-tools/knowledge-engine';
39
- import { EmbeddingProvider } from '@devflow-tools/memory-engine';
40
17
 
41
- const engine = new KnowledgeEngine({
42
- projectRoot: '/path/to/project',
43
- embedder: new EmbeddingProvider(),
44
- });
18
+ const engine = new KnowledgeEngine({ projectRoot: process.cwd() });
19
+ await engine.registerSource({ name: 'react', urls: ['https://react.dev/reference'], pluginName: 'react', version: '19' });
20
+ await engine.syncDocs('react');
21
+ console.log(await engine.search('useEffect cleanup'));
45
22
  ```
46
23
 
47
- Use the injected form when synchronizing or backfilling vectors; the standalone form
48
- is intentionally lexical-only and reports vector degradation in search status.
49
-
50
- ## Features
24
+ ## 公共 API / 命令
51
25
 
52
- - **智能抓取** — 自动检测页面内容量:静态内容充足则用 HTTP fetch,SPA 页面自动升级到 Playwright 浏览器渲染
53
- - **`renderJs` 标记** — 在 `KnowledgeSource` 中设置 `renderJs: true` 直达 Playwright 模式,跳过自动检测
54
- - **BM25 搜索** — 基于关键词的文档搜索,支持 scope 过滤(react/vue/nest 等)
55
- - **HTML → Markdown** — 使用 turndown 转换,标题级 chunk 分块保留文档结构
56
- - **多源同步** — 从官方文档、GitHub 等 URL 列表批量抓取和更新
26
+ `KnowledgeEngine`、`KnowledgeStore`、`KnowledgeHybridSearch`、`fetchHtmlSmart`、`bm25Search`、`compileKnowledgeSource`、`evaluateKnowledgeQuality`。
57
27
 
58
- ## Fetcher API
59
28
 
60
- | 函数 | 说明 |
61
- |------|------|
62
- | `fetchHtml(url)` | HTTP fetch + 重试(最多 2 次),支持 429 限流处理 |
63
- | `fetchHtmlBrowser(url)` | Playwright Chromium 浏览器渲染(用于 SPA 页面) |
64
- | `fetchHtmlSmart(url)` | 智能模式:先 fetch → 内容 < 500 字符 → 自动升级到浏览器 |
65
- | `closeBrowser()` | 关闭 Playwright 浏览器实例,释放资源 |
29
+ ## 配置与运行时
66
30
 
67
- ## Engine API
31
+ 默认构造函数是 lexical-only,避免与 memory-engine 形成依赖环;注入 SDK 的 `EmbeddingProviderContract` 实现后才启用向量检索/回填。SPA 抓取需要 `npx playwright install chromium`。
68
32
 
69
- - `new KnowledgeEngine({ projectRoot })` — 构造函数
70
- - `.registerSource(source)` — 注册/合并知识源(已存在则合并 URL 列表)
71
- - `.syncDocs(pluginName?)` — 同步指定(或全部)知识源的文档
72
- - `.search(query, options?)` — BM25 搜索知识库,支持 `scope` 过滤
73
- - `.lookup(symbol, scope?)` — 精确匹配知识条目
74
- - `.getSources()` — 列出所有知识源及其状态(chunk 数、最后同步时间)
33
+ ## 版本与兼容性
75
34
 
76
- ## Environment
35
+ - 当前包版本:`0.17.7`
36
+ - Node.js:未在 package manifest 声明更高版本时,使用 Node.js 18+;原生 SQLite/Playwright 能力请按对应依赖安装
37
+ - workspace 内部包应使用同一 DevFlow minor/patch 版本,避免类型和数据库 schema 不一致
77
38
 
78
- 需要安装 Playwright Chromium:
79
-
80
- ```bash
81
- npx playwright install chromium
82
- ```
39
+ ## 相关链接
83
40
 
84
- 或是使用 `postinstall` 脚本(已在 package.json 中配置)。
41
+ - [DevFlow 仓库](https://github.com/shilongfeicool/dev-flow)
42
+ - [问题反馈](https://github.com/shilongfeicool/dev-flow/issues)
85
43
 
86
44
  ## License
87
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devflow-tools/knowledge-engine",
3
- "version": "0.17.5",
3
+ "version": "0.17.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "postinstall": "playwright install chromium || true"
19
19
  },
20
20
  "dependencies": {
21
- "@devflow-tools/sdk": "0.17.5",
22
- "@devflow-tools/telemetry": "0.17.5",
21
+ "@devflow-tools/sdk": "0.17.7",
22
+ "@devflow-tools/telemetry": "0.17.7",
23
23
  "playwright": "^1.52.0",
24
24
  "turndown": "^7.2.4"
25
25
  },
@@ -31,5 +31,5 @@
31
31
  "files": [
32
32
  "dist"
33
33
  ],
34
- "gitHead": "817b0286c249eed9c2bd27d3974ee3b3d6ded4bb"
34
+ "gitHead": "560fe8a097aa9d398fdcfec409134cc94d26f92f"
35
35
  }