@v1nvn/readability 0.41.1 → 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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as resolveLazyImages, A as selectorsSchema, B as absolutize, C as extractTablesInputSchema, D as localPathField, E as htmlToMarkdownInputShape, F as detectGating, G as sanitizeHtml, H as renderTable, I as TraceCollector, J as computeTextMetrics, K as isReaderable, L as assembleDiagnostics, M as truncateMarkdown, N as detectPagination, O as outlineInputSchema, P as resolveMetadata, Q as normalizeDocument, R as chunkMarkdown, S as extractSectionInputShape, T as htmlToMarkdownInputSchema, U as resolveHeaderKeys, V as parseTableMatrix, W as resolveCellText, X as nonEmpty, Y as countWords, Z as applySelectors, _ as extractListInputSchema, a as extractLinksOutputShape, at as normalizeSiteKey, b as extractMetadataInputShape, c as extractTablesOutputShape, ct as selectorMisses, d as chunkTextInputSchema, dt as ExtractionError, et as resolveReadabilityOptions, f as chunkTextInputShape, ft as describeError, g as extractLinksInputShape, h as extractLinksInputSchema, ht as shutdownOnSignals, i as extractGridOutputShape, it as addPreset, j as readHtmlFile, k as outlineInputShape, l as outlineOutputShape, lt as logger, m as extractGridInputShape, n as registerExtractTool, nt as isElement, o as extractListOutputShape, ot as presetForSite, p as extractGridInputSchema, pt as toErrorResult, q as formatPayload, r as chunkTextOutputShape, rt as registerResources, s as extractMetadataOutputShape, st as removePreset, t as extractArticleFromHtml, tt as buildDocument, u as outputSchemaShape, ut as loadConfig, v as extractListInputShape, w as extractTablesInputShape, x as extractSectionInputSchema, y as extractMetadataInputSchema, z as toMarkdown } from "./assets/extract-Cn_gf58d.js";
2
+ import { $ as resolveLazyImages, A as selectorsSchema, B as absolutize, C as extractTablesInputSchema, D as localPathField, E as htmlToMarkdownInputShape, F as detectGating, G as sanitizeHtml, H as renderTable, I as TraceCollector, J as computeTextMetrics, K as isReaderable, L as assembleDiagnostics, M as truncateMarkdown, N as detectPagination, O as outlineInputSchema, P as resolveMetadata, Q as normalizeDocument, R as chunkMarkdown, S as extractSectionInputShape, T as htmlToMarkdownInputSchema, U as resolveHeaderKeys, V as parseTableMatrix, W as resolveCellText, X as nonEmpty, Y as countWords, Z as applySelectors, _ as extractListInputSchema, a as extractLinksOutputShape, at as normalizeSiteKey, b as extractMetadataInputShape, c as extractTablesOutputShape, ct as selectorMisses, d as chunkTextInputSchema, dt as ExtractionError, et as resolveReadabilityOptions, f as chunkTextInputShape, ft as describeError, g as extractLinksInputShape, gt as shutdownOnSignals, h as extractLinksInputSchema, i as extractGridOutputShape, it as addPreset, j as readHtmlFile, k as outlineInputShape, l as outlineOutputShape, lt as logger, m as extractGridInputShape, n as registerExtractTool, nt as isElement, o as extractListOutputShape, ot as presetForSite, p as extractGridInputSchema, pt as toErrorResult, q as formatPayload, r as chunkTextOutputShape, rt as registerResources, s as extractMetadataOutputShape, st as removePreset, t as extractArticleFromHtml, tt as buildDocument, u as outputSchemaShape, ut as loadConfig, v as extractListInputShape, w as extractTablesInputShape, x as extractSectionInputSchema, y as extractMetadataInputSchema, z as toMarkdown } from "./assets/extract-Cyv5qfGN.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -2249,7 +2249,7 @@ function createServer() {
2249
2249
  }
2250
2250
  //#endregion
2251
2251
  //#region src/index.ts
2252
- if (process.argv[2] === "extract") import("./assets/cli-B7SX_CrL.js").then((m) => m.runCli(process.argv.slice(2))).then((code) => {
2252
+ if (process.argv[2] === "extract") import("./assets/cli-BE_Ml3rh.js").then((m) => m.runCli(process.argv.slice(2))).then((code) => {
2253
2253
  process.exit(code);
2254
2254
  }).catch((err) => {
2255
2255
  process.stderr.write(`${describeError(err)}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v1nvn/readability",
3
- "version": "0.41.1",
3
+ "version": "0.43.0",
4
4
  "description": "MCP server that turns rendered (post-JS) HTML into clean Markdown + metadata via Readability, Turndown, and DOMPurify.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@modelcontextprotocol/sdk": "^1.29.0",
46
46
  "@mozilla/readability": "^0.6.0",
47
- "@v1nvn/agentic-core": "^0.41.1",
47
+ "@v1nvn/agentic-core": "^0.43.0",
48
48
  "commander": "^15.0.0",
49
49
  "dompurify": "^3.4.12",
50
50
  "jsdom": "^30.0.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-B7SX_CrL.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,SAA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