ai-text-cleaner 0.1.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 ADDED
@@ -0,0 +1,33 @@
1
+ # ai-text-cleaner
2
+
3
+ LLMが生成したMarkdown形式の文章から「AIっぽさ」を取り除くためのテキスト加工ライブラリです。
4
+
5
+ 現時点では、Markdownの太字(`**...**`)をASTベースで除去します(正規表現ではなく `remark` でパースして加工)。
6
+
7
+ ## 使い方
8
+
9
+ ```bash
10
+ npm i ai-text-cleaner
11
+ ```
12
+
13
+ ```ts
14
+ import { cleanMarkdown } from "ai-text-cleaner";
15
+
16
+ const output = cleanMarkdown("これは**太字**です。");
17
+ // => "これは太字です。\n"
18
+ ```
19
+
20
+ ### オプション
21
+
22
+ ```ts
23
+ import { cleanMarkdown } from "ai-text-cleaner";
24
+
25
+ const output = cleanMarkdown("これは**太字**です。", { removeBold: false });
26
+ // => "これは**太字**です。\n"
27
+ ```
28
+
29
+ ## 開発
30
+
31
+ ```bash
32
+ npm test
33
+ ```
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/cleanMarkdown.ts
21
+ var cleanMarkdown_exports = {};
22
+ __export(cleanMarkdown_exports, {
23
+ cleanMarkdown: () => cleanMarkdown
24
+ });
25
+ module.exports = __toCommonJS(cleanMarkdown_exports);
26
+ var import_remark = require("remark");
27
+
28
+ // src/remark-plugins/removeBold.ts
29
+ var import_unist_util_visit = require("unist-util-visit");
30
+ var remarkRemoveBold = () => {
31
+ return (tree) => {
32
+ (0, import_unist_util_visit.visit)(tree, "strong", (node, index, parent) => {
33
+ if (typeof index !== "number") return;
34
+ if (!parent) return;
35
+ parent.children.splice(index, 1, ...node.children);
36
+ });
37
+ };
38
+ };
39
+
40
+ // src/cleanMarkdown.ts
41
+ var defaultOptions = {
42
+ removeBold: true
43
+ };
44
+ var cleanMarkdown = (markdown, options = {}) => {
45
+ const resolvedOptions = {
46
+ ...defaultOptions,
47
+ ...options
48
+ };
49
+ const processor = (0, import_remark.remark)().data("settings", { bullet: "-" });
50
+ if (resolvedOptions.removeBold) {
51
+ processor.use(remarkRemoveBold);
52
+ }
53
+ const file = processor.processSync(markdown);
54
+ return String(file);
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ cleanMarkdown
59
+ });
package/dist/index.cjs ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ cleanMarkdown: () => cleanMarkdown
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/cleanMarkdown.ts
28
+ var import_remark = require("remark");
29
+
30
+ // src/remark-plugins/removeBold.ts
31
+ var import_unist_util_visit = require("unist-util-visit");
32
+ var remarkRemoveBold = () => {
33
+ return (tree) => {
34
+ (0, import_unist_util_visit.visit)(tree, "strong", (node, index, parent) => {
35
+ if (typeof index !== "number") return;
36
+ if (!parent) return;
37
+ parent.children.splice(index, 1, ...node.children);
38
+ });
39
+ };
40
+ };
41
+
42
+ // src/cleanMarkdown.ts
43
+ var defaultOptions = {
44
+ removeBold: true
45
+ };
46
+ var cleanMarkdown = (markdown, options = {}) => {
47
+ const resolvedOptions = {
48
+ ...defaultOptions,
49
+ ...options
50
+ };
51
+ const processor = (0, import_remark.remark)().data("settings", { bullet: "-" });
52
+ if (resolvedOptions.removeBold) {
53
+ processor.use(remarkRemoveBold);
54
+ }
55
+ const file = processor.processSync(markdown);
56
+ return String(file);
57
+ };
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ cleanMarkdown
61
+ });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/remark-plugins/removeBold.ts
21
+ var removeBold_exports = {};
22
+ __export(removeBold_exports, {
23
+ remarkRemoveBold: () => remarkRemoveBold
24
+ });
25
+ module.exports = __toCommonJS(removeBold_exports);
26
+ var import_unist_util_visit = require("unist-util-visit");
27
+ var remarkRemoveBold = () => {
28
+ return (tree) => {
29
+ (0, import_unist_util_visit.visit)(tree, "strong", (node, index, parent) => {
30
+ if (typeof index !== "number") return;
31
+ if (!parent) return;
32
+ parent.children.splice(index, 1, ...node.children);
33
+ });
34
+ };
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ remarkRemoveBold
39
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ // src/scripts/hello.ts
4
+ var message = "Hello, World!";
5
+ console.log(message);
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "ai-text-cleaner",
3
+ "version": "0.1.0",
4
+ "description": "LLMが生成したMarkdownから「AIっぽさ」を取り除くためのテキスト加工ライブラリ",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "markdown",
8
+ "remark",
9
+ "llm",
10
+ "text",
11
+ "cleanup"
12
+ ],
13
+ "type": "module",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "lint": "biome check --write ./src ./test && npx tsc --noEmit",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest",
29
+ "build": "npx tsup ./src",
30
+ "prepublishOnly": "npm run build"
31
+ },
32
+ "dependencies": {
33
+ "remark": "^15.0.1",
34
+ "unist-util-visit": "^5.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@biomejs/biome": "^2.4.4",
38
+ "@types/node": "^25.3.0",
39
+ "tsup": "^8.5.1",
40
+ "tsx": "^4.21.0",
41
+ "typescript": "^5.9.3",
42
+ "vitest": "^4.0.18"
43
+ }
44
+ }