@h-ai/datapipe 1.0.0-beta.19 → 1.0.0-beta.20

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.en.md CHANGED
@@ -4,25 +4,9 @@
4
4
 
5
5
  [Framework home](../../README.en.md) · Related modules: [@h-ai/core](../core/README.en.md)
6
6
 
7
- ## Introduction
8
-
9
7
  A data processing pipeline module for text cleaning (`clean`), chunking (`chunk`), and composable pipelines (`pipeline`). Pure functions; no initialization required.
10
8
 
11
- ## Core features
12
-
13
- HTML removal extracts text; it is not an HTML security sanitizer. Use the UI's safe rendering mechanism before rendering HTML. Built-in tag and email cleaning avoids repeated backtracking on long malformed input. Custom regular expressions must come from trusted configuration, not external user-supplied patterns.
14
-
15
- | Feature | Description |
16
- | -------------------- | ----------------------------------------------------------------------------------------------------- |
17
- | Text cleaning | Remove HTML tags, URLs, and emails; normalize whitespace; apply custom regex replacements |
18
- | Text chunking | Sentences, paragraphs, Markdown headings, page breaks, word counts, characters, and custom separators |
19
- | Pipeline composition | Chain cleaning → transformation → chunking → postprocessing in a single execution |
20
-
21
- > Security: `customReplacements` and `separator` in `mode: 'custom'` are used as regular expressions. Only provide trusted, reviewed patterns; do not interpolate user input directly into regexes, to avoid ReDoS or unintended broad replacements.
22
-
23
- ## Getting started
24
-
25
- ### Quick start
9
+ ## Quick Start
26
10
 
27
11
  ```ts
28
12
  import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'
@@ -51,6 +35,18 @@ if (!result.success)
51
35
  throw new Error(result.error.message)
52
36
  ```
53
37
 
38
+ ## Features
39
+
40
+ HTML removal extracts text; it is not an HTML security sanitizer. Use the UI's safe rendering mechanism before rendering HTML. Built-in tag and email cleaning avoids repeated backtracking on long malformed input. Custom regular expressions must come from trusted configuration, not external user-supplied patterns.
41
+
42
+ | Feature | Description |
43
+ | -------------------- | ----------------------------------------------------------------------------------------------------- |
44
+ | Text cleaning | Remove HTML tags, URLs, and emails; normalize whitespace; apply custom regex replacements |
45
+ | Text chunking | Sentences, paragraphs, Markdown headings, page breaks, word counts, characters, and custom separators |
46
+ | Pipeline composition | Chain cleaning → transformation → chunking → postprocessing in a single execution |
47
+
48
+ > Security: `customReplacements` and `separator` in `mode: 'custom'` are used as regular expressions. Only provide trusted, reviewed patterns; do not interpolate user input directly into regexes, to avoid ReDoS or unintended broad replacements.
49
+
54
50
  ### Chunking modes
55
51
 
56
52
  | Mode | Description |
@@ -65,7 +61,15 @@ if (!result.success)
65
61
 
66
62
  Chunk `maxSize` defaults to 1500; `overlap` defaults to 0 and must satisfy `0 <= overlap < maxSize`. Both use non-whitespace words in word mode (continuous Chinese can be one long word), and Unicode code points in every other mode, rather than UTF-16 length, bytes or model tokens. The limit includes overlap and separators. Natural sentence/paragraph/page/custom boundaries only guide split positions; oversized segments use a `maxSize-overlap` sliding window. Original whitespace, punctuation, page markers and custom separators are preserved, so removing overlap reconstructs the source. Chunks are not trimmed or joined with added newlines. Markdown overlaps only within each section, uses the same hard limit and ignores headings inside fenced code. Only `markdownKeepTitle=false` explicitly removes heading lines. Empty or entirely whitespace input returns no chunks. Custom regular expressions must come from trusted configuration; invalid expressions return CHUNK_FAILED.
67
63
 
68
- ### Error handling
64
+ ## Configuration
65
+
66
+ This module has no init, global YAML or persistent connection. Pass clean/chunk options per call; pipeline options belong to that pipeline. Choose mode, maxSize and overlap for the source structure; custom regex patterns must come from trusted configuration.
67
+
68
+ [Per-option purpose, use cases and examples](../../docs/usage/configuration/ai.md).
69
+
70
+ ## Error Handling
71
+
72
+ Check result.success for domain operations. Handle failures with the module error definitions and safe messages; retain codes, correlation IDs and sanitized causes in server logs. Synchronous tools, factories, stream iteration and lifecycle calls follow their own signatures. A completed Promise alone is not business success. See each feature for recovery limits.
69
73
 
70
74
  All operations return `HaiResult<T>`; check `result.success` for success or failure. Error codes use the string format `hai:datapipe:NNN`.
71
75
 
@@ -86,7 +90,7 @@ if (!result.success) {
86
90
  }
87
91
  ```
88
92
 
89
- ## Development and testing
93
+ ## Development
90
94
 
91
95
  ```bash
92
96
  pnpm --filter @h-ai/datapipe test
package/README.ja.md CHANGED
@@ -4,25 +4,9 @@
4
4
 
5
5
  [フレームワークのホーム](../../README.ja.md) · 関連モジュール:[@h-ai/core](../core/README.ja.md)
6
6
 
7
- ## 概要
8
-
9
7
  テキストのクリーニング(clean)、分割(chunk)、パイプラインの合成(pipeline)を提供するデータ処理モジュールです。純粋関数で構成され、初期化は不要です。
10
8
 
11
- ## 主な機能
12
-
13
- HTML 除去はテキスト抽出であり、安全な HTML 消毒ではありません。HTML として表示する際は UI の安全な描画機構を使用してください。組み込みのタグ・メール処理は長い不正入力での反復バックトラックを避けます。独自正規表現は信頼できる設定から与え、外部ユーザーの任意パターンを直接使用しないでください。
14
-
15
- | 機能 | 説明 |
16
- | ---------------------- | --------------------------------------------------------------------- |
17
- | テキストのクリーニング | HTML タグ・URL・Email の除去、空白の正規化、独自の正規表現による置換 |
18
- | テキストの分割 | 文、段落、Markdown 見出し、改ページ、単語数、文字数、独自の区切り文字 |
19
- | パイプラインの合成 | クリーニング → 変換 → 分割 → 後処理を連結し、一度に実行 |
20
-
21
- > セキュリティ:`customReplacements` と `mode: 'custom'` の `separator` は正規表現として使用されます。信頼できる検証済みのパターンのみを渡し、ReDoS や意図しない広範囲の置換を防ぐため、ユーザー入力を直接正規表現に組み込まないでください。
22
-
23
- ## 使い始める
24
-
25
- ### クイックスタート
9
+ ## クイックスタート
26
10
 
27
11
  ```ts
28
12
  import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'
@@ -51,6 +35,18 @@ if (!result.success)
51
35
  throw new Error(result.error.message)
52
36
  ```
53
37
 
38
+ ## 機能
39
+
40
+ HTML 除去はテキスト抽出であり、安全な HTML 消毒ではありません。HTML として表示する際は UI の安全な描画機構を使用してください。組み込みのタグ・メール処理は長い不正入力での反復バックトラックを避けます。独自正規表現は信頼できる設定から与え、外部ユーザーの任意パターンを直接使用しないでください。
41
+
42
+ | 機能 | 説明 |
43
+ | ---------------------- | --------------------------------------------------------------------- |
44
+ | テキストのクリーニング | HTML タグ・URL・Email の除去、空白の正規化、独自の正規表現による置換 |
45
+ | テキストの分割 | 文、段落、Markdown 見出し、改ページ、単語数、文字数、独自の区切り文字 |
46
+ | パイプラインの合成 | クリーニング → 変換 → 分割 → 後処理を連結し、一度に実行 |
47
+
48
+ > セキュリティ:`customReplacements` と `mode: 'custom'` の `separator` は正規表現として使用されます。信頼できる検証済みのパターンのみを渡し、ReDoS や意図しない広範囲の置換を防ぐため、ユーザー入力を直接正規表現に組み込まないでください。
49
+
54
50
  ### 分割モード
55
51
 
56
52
  | モード | 説明 |
@@ -65,7 +61,15 @@ if (!result.success)
65
61
 
66
62
  分割の `maxSize` は既定1500、`overlap` は既定0で `0 <= overlap < maxSize` が必要です。word モードは非空白の語数(連続する中国語は1語になる場合があります)、その他は Unicode code point を単位とし、UTF-16 length・バイト・モデル token ではありません。重複と区切り文字も上限に含みます。自然な文・段落・ページ・独自境界は切点の優先度だけを決め、長い部分は `maxSize-overlap` で進みます。元の空白、句読点、改ページ、独自区切りを維持し、重複を除けば原文を復元できます。trim や改行の追加はしません。Markdown の重複は section 内だけで同じ上限を使い、コードフェンス内の見出しを本文として扱います。`markdownKeepTitle=false` の場合だけ見出し行を除きます。空または全空白の入力は空配列です。独自正規表現は信頼済み設定に限定し、不正な式は CHUNK_FAILED を返します。
67
63
 
68
- ### エラー処理
64
+ ## 設定
65
+
66
+ init・グローバル YAML・永続接続はありません。clean/chunk の指定は呼出しごと、pipeline の指定はそのパイプラインに属します。元文書の構造に応じ mode・maxSize・overlap を選び、独自正規表現は信頼する設定のみを使ってください。
67
+
68
+ [項目別の用途・適用場面・例](../../docs/usage/configuration/ai.md).
69
+
70
+ ## エラー処理
71
+
72
+ 領域操作は result.success を確認し、失敗時はモジュールのエラー定義と安全な説明を使います。コード・関連 ID・秘匿した原因をサーバーログに残します。同期ツール・ファクトリー・ストリーム反復・ライフサイクルは各署名に従い、Promise 完了だけで成功と判断しません。回復条件は各機能を参照してください。
69
73
 
70
74
  すべての操作は `HaiResult<T>` を返します。`result.success` で成功・失敗を判定します。エラーコードは文字列形式 `hai:datapipe:NNN` です。
71
75
 
package/README.md CHANGED
@@ -4,25 +4,9 @@
4
4
 
5
5
  [框架首页](../../README.md) · 相关模块:[@h-ai/core](../core/README.md)
6
6
 
7
- ## 简介
8
-
9
7
  数据处理管线模块,提供文本清洗(clean)、分块(chunk)和可组合管线(pipeline)功能。纯函数模块,无需初始化。
10
8
 
11
- ## 核心功能清单
12
-
13
- HTML 清洗用于提取文本,不是安全消毒;结果用于 HTML 渲染时仍需使用 UI 的安全渲染机制。内置标签与邮箱清洗处理长异常输入时避免重复回溯;自定义正则来自可信配置,不直接接收外部用户提交的模式。
14
-
15
- | 功能 | 说明 |
16
- | -------- | ----------------------------------------------------------- |
17
- | 文本清洗 | 移除 HTML 标签、URL、Email,标准化空白,自定义正则替换 |
18
- | 文本分块 | 句子、段落、Markdown 标题、分页符、字数、字符、自定义分隔符 |
19
- | 管线组合 | 链式组合清洗 → 转换 → 分块 → 分块后处理,一次执行 |
20
-
21
- > 安全提示:`customReplacements` 与 `mode: 'custom'` 的 `separator` 会作为正则使用。仅传入受信任、已审查的模式;不要把用户输入直接拼进正则,避免 ReDoS 或意外大范围替换。
22
-
23
- ## 使用入门
24
-
25
- ### 快速开始
9
+ ## 快速开始
26
10
 
27
11
  ```ts
28
12
  import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'
@@ -51,6 +35,18 @@ if (!result.success)
51
35
  throw new Error(result.error.message)
52
36
  ```
53
37
 
38
+ ## 功能
39
+
40
+ HTML 清洗用于提取文本,不是安全消毒;结果用于 HTML 渲染时仍需使用 UI 的安全渲染机制。内置标签与邮箱清洗处理长异常输入时避免重复回溯;自定义正则来自可信配置,不直接接收外部用户提交的模式。
41
+
42
+ | 功能 | 说明 |
43
+ | -------- | ----------------------------------------------------------- |
44
+ | 文本清洗 | 移除 HTML 标签、URL、Email,标准化空白,自定义正则替换 |
45
+ | 文本分块 | 句子、段落、Markdown 标题、分页符、字数、字符、自定义分隔符 |
46
+ | 管线组合 | 链式组合清洗 → 转换 → 分块 → 分块后处理,一次执行 |
47
+
48
+ > 安全提示:`customReplacements` 与 `mode: 'custom'` 的 `separator` 会作为正则使用。仅传入受信任、已审查的模式;不要把用户输入直接拼进正则,避免 ReDoS 或意外大范围替换。
49
+
54
50
  ### 分块模式
55
51
 
56
52
  | 模式 | 说明 |
@@ -63,9 +59,17 @@ if (!result.success)
63
59
  | character | 按字符数分块 |
64
60
  | custom | 自定义分隔符(需提供 separator) |
65
61
 
66
- 分块 `maxSize` 默认 1500,`overlap` 默认 0 且必须满足 `0 <= overlap < maxSize`。word 模式两者均按非空白词计量(连续中文可视为一个长词),其余模式均按 Unicode code point 计量,不是 UTF-16 length、字节或模型 token。上限包含重叠与分隔符;自然句/段/页/自定义边界只影响优先切点,超长段统一按 `maxSize-overlap` 滑窗。保留原始空白、标点、分页符及自定义分隔符,移除重叠后可还原全文;不再 split/join 或 trim 分块。Markdown section 之间不重叠,section 内使用相同硬上限,代码围栏内的标题保留为正文;仅 `markdownKeepTitle=false` 明确移除标题行。空/全空白的整体输入返回空数组。自定义正则须由可信配置提供,非法表达式返回 CHUNK_FAILED。
62
+ 分块 `maxSize` 默认 1500,`overlap` 默认 0 且必须满足 `0 <= overlap < maxSize`。word 模式两者均按非空白词计量(连续中文可视为一个长词),其余模式均按 Unicode code point 计量,不是 UTF-16 length、字节或模型 token。上限包含重叠与分隔符;自然句/段/页/自定义边界只影响优先切点,超长段统一按 `maxSize-overlap` 滑窗。保留原始空白、标点、分页符及自定义分隔符,移除重叠后可还原全文;分块保留原始文本,不做 split/join 或 trim。Markdown section 之间不重叠,section 内使用相同硬上限,代码围栏内的标题保留为正文;仅 `markdownKeepTitle=false` 明确移除标题行。空/全空白的整体输入返回空数组。自定义正则须由可信配置提供,非法表达式返回 CHUNK_FAILED。
63
+
64
+ ## 配置
65
+
66
+ 本模块没有 init、全局 YAML 或持久连接;clean/chunk 的选项按每次调用传入,pipeline 的步骤选项属于当前管线。按文本结构选择 mode、maxSize、overlap;自定义正则仅来自可信配置。
67
+
68
+ [逐项配置说明、适用场景和示例](../../docs/usage/configuration/ai.md).
69
+
70
+ ## 错误处理
67
71
 
68
- ### 错误处理
72
+ 领域操作先判断 `result.success`,失败按本模块错误定义与安全提示处理,服务端保留错误码、关联编号和脱敏原因。同步工具、工厂、流迭代及生命周期按各自签名处理,不把 Promise 完成视为业务成功。具体失败与恢复边界见对应功能。
69
73
 
70
74
  所有操作返回 `HaiResult<T>`,通过 `result.success` 判断成功或失败。错误码为字符串格式 `hai:datapipe:NNN`。
71
75
 
@@ -92,7 +96,7 @@ if (!result.success) {
92
96
  pnpm --filter @h-ai/datapipe test
93
97
  ```
94
98
 
95
- 源码示例区分无需生命周期的纯函数、同步 HaiResult 与异步管线;类型检查方法见[模块 JSDoc 约定](../../.agents/instructions/module-conventions.md#jsdoc-与示例验证)。
99
+ 源码示例区分无需生命周期的纯函数、同步 HaiResult 与异步管线;类型检查方法见[模块 JSDoc 约定](../../.agents/instructions/module-conventions.md#jsdoc-与示例验证).
96
100
 
97
101
  ## 许可证
98
102
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@h-ai/datapipe",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.19",
4
+ "version": "1.0.0-beta.20",
5
5
  "description": "Data processing pipeline module for hai-framework: clean, chunk, transform",
6
6
  "exports": {
7
7
  ".": {
@@ -21,7 +21,7 @@
21
21
  "node": "^22.23.4 || ^24.22.1 || ^26.12.1"
22
22
  },
23
23
  "dependencies": {
24
- "@h-ai/core": "1.0.0-beta.19",
24
+ "@h-ai/core": "1.0.0-beta.20",
25
25
  "zod": "^4.6.7"
26
26
  },
27
27
  "devDependencies": {