@v1nvn/readability 0.42.0 → 0.43.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 +3 -3
- package/dist/assets/{cli-D1FP26g3.js → cli-BE_Ml3rh.js} +2 -2
- package/dist/assets/{cli-D1FP26g3.js.map → cli-BE_Ml3rh.js.map} +1 -1
- package/dist/assets/{extract-CKIYHNCa.js → extract-Cyv5qfGN.js} +2 -2
- package/dist/assets/{extract-CKIYHNCa.js.map → extract-Cyv5qfGN.js.map} +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ User-facing docs: [root README](../../README.md).
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm install @v1nvn/readability@0.
|
|
13
|
+
npm install @v1nvn/readability@0.43.0
|
|
14
14
|
# or run on demand:
|
|
15
|
-
npx @v1nvn/readability@0.
|
|
15
|
+
npx @v1nvn/readability@0.43.0
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Requires Node >= 22.22.2 (jsdom 30's floor). Build from source:
|
|
@@ -58,7 +58,7 @@ Add to your MCP client config (Claude Code, Claude Desktop, etc.):
|
|
|
58
58
|
"mcpServers": {
|
|
59
59
|
"readability": {
|
|
60
60
|
"command": "npx",
|
|
61
|
-
"args": ["-y", "@v1nvn/readability@0.
|
|
61
|
+
"args": ["-y", "@v1nvn/readability@0.43.0"],
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ft as describeError, ht as parseQuietly, j as readHtmlFile, mt as HelpRequested, t as extractArticleFromHtml } from "./extract-
|
|
1
|
+
import { ft as describeError, ht as parseQuietly, j as readHtmlFile, mt as HelpRequested, t as extractArticleFromHtml } from "./extract-Cyv5qfGN.js";
|
|
2
2
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
var FORMATS = [
|
|
@@ -73,4 +73,4 @@ async function runCli(argv) {
|
|
|
73
73
|
//#endregion
|
|
74
74
|
export { runCli };
|
|
75
75
|
|
|
76
|
-
//# sourceMappingURL=cli-
|
|
76
|
+
//# sourceMappingURL=cli-BE_Ml3rh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-
|
|
1
|
+
{"version":3,"file":"cli-BE_Ml3rh.js","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["import { HelpRequested, parseQuietly } from '@v1nvn/agentic-core';\nimport { Command, InvalidArgumentError, Option } from 'commander';\n\nimport { describeError } from './errors.js';\nimport { extractArticleFromHtml } from './tools/extract.js';\nimport { readHtmlFile } from './tools/html-source.js';\n\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { Readable } from 'node:stream';\n\ntype CliFormat = 'html' | 'json' | 'md';\n\nexport interface ParsedArgs {\n readonly file: string | undefined;\n readonly format: CliFormat;\n readonly maxChars: number | undefined;\n}\n\nconst FORMATS: readonly CliFormat[] = ['html', 'json', 'md'];\n\nfunction parseMaxChars(value: string): number {\n const n = Number(value);\n if (!Number.isInteger(n)) {\n throw new InvalidArgumentError('must be an integer');\n }\n return n;\n}\n\nexport function buildProgram(): Command {\n return new Command('readability extract')\n .argument('[file]', 'HTML file; stdin when omitted')\n .addOption(\n new Option('--format <fmt>', 'output format')\n .choices(FORMATS)\n .default('md'),\n )\n .option('--max-chars <n>', 'truncate the output', parseMaxChars);\n}\n\nexport function parseArgs(\n argv: readonly string[],\n): HelpRequested | ParsedArgs | undefined {\n const program = buildProgram();\n const parsed = parseQuietly(program, argv.slice(1));\n if (parsed === undefined || parsed instanceof HelpRequested) {\n return parsed;\n }\n const { format, maxChars } = parsed.opts<{\n format: CliFormat;\n maxChars: number | undefined;\n }>();\n return { file: parsed.args.at(0), format, maxChars };\n}\n\n// The stream is injected rather than reading process.stdin directly so the\n// path is testable. Chunks may be Buffer (process.stdin) or string\n// (Readable.from), so both are handled.\nexport async function readHtml(\n file: string | undefined,\n stream: Readable,\n): Promise<string> {\n if (file !== undefined) {\n return readHtmlFile(file);\n }\n const chunks: string[] = [];\n for await (const chunk of stream) {\n if (typeof chunk === 'string') {\n chunks.push(chunk);\n } else {\n chunks.push(Buffer.from(chunk as Uint8Array).toString('utf8'));\n }\n }\n return chunks.join('');\n}\n\nfunction payloadText(result: CallToolResult): string {\n const first = result.content.at(0);\n return first !== undefined && 'text' in first ? first.text : '';\n}\n\nexport async function runCli(argv: readonly string[]): Promise<number> {\n if (argv[0] !== 'extract') {\n process.stderr.write(buildProgram().helpInformation());\n return 2;\n }\n\n const parsed = parseArgs(argv);\n if (parsed instanceof HelpRequested) {\n process.stdout.write(`${parsed.command.helpInformation()}\\n`);\n return 0;\n }\n if (parsed === undefined) {\n process.stderr.write(buildProgram().helpInformation());\n return 2;\n }\n\n try {\n const html = await readHtml(parsed.file, process.stdin);\n // json reuses the markdown pipeline; the structured object is serialized below.\n const pipelineFormat = parsed.format === 'html' ? 'html' : 'markdown';\n const result = extractArticleFromHtml({\n html,\n format: pipelineFormat,\n ...(parsed.maxChars !== undefined ? { maxChars: parsed.maxChars } : {}),\n });\n\n if (result.isError) {\n process.stderr.write(`${payloadText(result)}\\n`);\n return 1;\n }\n\n if (parsed.format === 'json') {\n process.stdout.write(\n `${JSON.stringify(result.structuredContent, null, 2)}\\n`,\n );\n } else {\n process.stdout.write(`${payloadText(result)}\\n`);\n }\n return 0;\n } catch (err) {\n process.stderr.write(`${describeError(err)}\\n`);\n return 1;\n }\n}\n"],"mappings":";;;AAkBA,IAAM,UAAgC;CAAC;CAAQ;CAAQ;AAAI;AAE3D,SAAS,cAAc,OAAuB;CAC5C,MAAM,IAAI,OAAO,KAAK;CACtB,IAAI,CAAC,OAAO,UAAU,CAAC,GACrB,MAAM,IAAI,qBAAqB,oBAAoB;CAErD,OAAO;AACT;AAEA,SAAgB,eAAwB;CACtC,OAAO,IAAI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B,CAAC;EACrD,OAAO;CACT;CAEA,IAAI;EACF,MAAM,OAAO,MAAM,SAAS,OAAO,MAAM,QAAQ,KAAK;EAEtD,MAAM,iBAAiB,OAAO,WAAW,SAAS,SAAS;EAC3D,MAAM,SAAS,uBAAuB;GACpC;GACA,QAAQ;GACR,GAAI,OAAO,aAAa,KAAA,IAAY,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EACvE,CAAC;EAED,IAAI,OAAO,SAAS;GAClB,QAAQ,OAAO,MAAM,GAAG,YAAY,MAAM,EAAE,GAAG;GAC/C,OAAO;EACT;EAEA,IAAI,OAAO,WAAW,QACpB,QAAQ,OAAO,MACb,GAAG,KAAK,UAAU,OAAO,mBAAmB,MAAM,CAAC,EAAE,GACvD;OAEA,QAAQ,OAAO,MAAM,GAAG,YAAY,MAAM,EAAE,GAAG;EAEjD,OAAO;CACT,SAAS,KAAK;EACZ,QAAQ,OAAO,MAAM,GAAG,cAAc,GAAG,EAAE,GAAG;EAC9C,OAAO;CACT;AACF"}
|
|
@@ -116,7 +116,7 @@ function toErrorResult(err) {
|
|
|
116
116
|
}
|
|
117
117
|
var package_default = {
|
|
118
118
|
name: "@v1nvn/readability",
|
|
119
|
-
version: "0.
|
|
119
|
+
version: "0.43.0",
|
|
120
120
|
description: "MCP server that turns rendered (post-JS) HTML into clean Markdown + metadata via Readability, Turndown, and DOMPurify.",
|
|
121
121
|
type: "module",
|
|
122
122
|
main: "dist/index.js",
|
|
@@ -2877,4 +2877,4 @@ function registerExtractTool(server) {
|
|
|
2877
2877
|
//#endregion
|
|
2878
2878
|
export { resolveLazyImages as $, selectorsSchema as A, absolutize as B, extractTablesInputSchema as C, localPathField as D, htmlToMarkdownInputShape as E, detectGating as F, sanitizeHtml as G, renderTable as H, TraceCollector as I, computeTextMetrics as J, isReaderable as K, assembleDiagnostics as L, truncateMarkdown as M, detectPagination as N, outlineInputSchema as O, resolveMetadata as P, normalizeDocument as Q, chunkMarkdown as R, extractSectionInputShape as S, htmlToMarkdownInputSchema as T, resolveHeaderKeys as U, parseTableMatrix as V, resolveCellText as W, nonEmpty as X, countWords as Y, applySelectors as Z, extractListInputSchema as _, extractLinksOutputShape as a, normalizeSiteKey as at, extractMetadataInputShape as b, extractTablesOutputShape as c, selectorMisses as ct, chunkTextInputSchema as d, ExtractionError as dt, resolveReadabilityOptions as et, chunkTextInputShape as f, describeError as ft, extractLinksInputShape as g, shutdownOnSignals as gt, extractLinksInputSchema as h, parseQuietly as ht, extractGridOutputShape as i, addPreset as it, readHtmlFile as j, outlineInputShape as k, outlineOutputShape as l, logger as lt, extractGridInputShape as m, HelpRequested as mt, registerExtractTool as n, isElement as nt, extractListOutputShape as o, presetForSite as ot, extractGridInputSchema as p, toErrorResult as pt, formatPayload as q, chunkTextOutputShape as r, registerResources as rt, extractMetadataOutputShape as s, removePreset as st, extractArticleFromHtml as t, buildDocument as tt, outputSchemaShape as u, loadConfig as ut, extractListInputShape as v, extractTablesInputShape as w, extractSectionInputSchema as x, extractMetadataInputSchema as y, toMarkdown as z };
|
|
2879
2879
|
|
|
2880
|
-
//# sourceMappingURL=extract-
|
|
2880
|
+
//# sourceMappingURL=extract-Cyv5qfGN.js.map
|