@v1nvn/readability 0.38.0 → 0.39.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-BinaCiz4.js → cli-UFEt8y9B.js} +2 -2
- package/dist/assets/{cli-BinaCiz4.js.map → cli-UFEt8y9B.js.map} +1 -1
- package/dist/assets/{extract-CynDqy1w.js → extract-DKEm_UeW.js} +2 -2
- package/dist/assets/{extract-CynDqy1w.js.map → extract-DKEm_UeW.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.39.0
|
|
14
14
|
# or run on demand:
|
|
15
|
-
npx @v1nvn/readability@0.
|
|
15
|
+
npx @v1nvn/readability@0.39.0
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Requires Node >= 22. 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.39.0"],
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ft as describeError, j as readHtmlFile, mt as parseQuietly, t as extractArticleFromHtml } from "./extract-
|
|
1
|
+
import { ft as describeError, j as readHtmlFile, mt as parseQuietly, t as extractArticleFromHtml } from "./extract-DKEm_UeW.js";
|
|
2
2
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
var FORMATS = [
|
|
@@ -68,4 +68,4 @@ async function runCli(argv) {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
export { runCli };
|
|
70
70
|
|
|
71
|
-
//# sourceMappingURL=cli-
|
|
71
|
+
//# sourceMappingURL=cli-UFEt8y9B.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-
|
|
1
|
+
{"version":3,"file":"cli-UFEt8y9B.js","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["import { 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(argv: readonly string[]): ParsedArgs | undefined {\n const program = parseQuietly(buildProgram(), argv.slice(1));\n if (program === undefined) {\n return undefined;\n }\n const { format, maxChars } = program.opts<{\n format: CliFormat;\n maxChars: number | undefined;\n }>();\n return { file: program.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 === 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,QAAQ,qBAAqB,CAAC,CACtC,SAAS,UAAU,+BAA+B,CAAC,CACnD,UACC,IAAI,OAAO,kBAAkB,eAAe,CAAC,CAC1C,QAAQ,OAAO,CAAC,CAChB,QAAQ,IAAI,CACjB,CAAC,CACA,OAAO,mBAAmB,uB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AAY,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"}
|
|
@@ -102,7 +102,7 @@ function toErrorResult(err) {
|
|
|
102
102
|
}
|
|
103
103
|
var package_default = {
|
|
104
104
|
name: "@v1nvn/readability",
|
|
105
|
-
version: "0.
|
|
105
|
+
version: "0.39.0",
|
|
106
106
|
description: "MCP server that turns rendered (post-JS) HTML into clean Markdown + metadata via Readability, Turndown, and DOMPurify.",
|
|
107
107
|
type: "module",
|
|
108
108
|
main: "dist/index.js",
|
|
@@ -2863,4 +2863,4 @@ function registerExtractTool(server) {
|
|
|
2863
2863
|
//#endregion
|
|
2864
2864
|
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, extractLinksInputSchema as h, shutdownOnSignals as ht, extractGridOutputShape as i, addPreset as it, readHtmlFile as j, outlineInputShape as k, outlineOutputShape as l, logger as lt, extractGridInputShape as m, parseQuietly 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 };
|
|
2865
2865
|
|
|
2866
|
-
//# sourceMappingURL=extract-
|
|
2866
|
+
//# sourceMappingURL=extract-DKEm_UeW.js.map
|