markit-ai 0.1.1 → 0.2.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.
Files changed (59) hide show
  1. package/dist/commands/config.js +12 -6
  2. package/dist/commands/convert.js +3 -4
  3. package/dist/commands/formats.js +21 -5
  4. package/dist/commands/init.js +1 -1
  5. package/dist/commands/plugin.js +2 -2
  6. package/dist/converters/audio.d.ts +1 -1
  7. package/dist/converters/audio.js +23 -6
  8. package/dist/converters/csv.d.ts +1 -1
  9. package/dist/converters/csv.js +1 -1
  10. package/dist/converters/docx.d.ts +1 -1
  11. package/dist/converters/docx.js +4 -7
  12. package/dist/converters/epub.d.ts +1 -1
  13. package/dist/converters/epub.js +27 -10
  14. package/dist/converters/html.d.ts +1 -1
  15. package/dist/converters/html.js +4 -7
  16. package/dist/converters/image.d.ts +1 -1
  17. package/dist/converters/image.js +40 -10
  18. package/dist/converters/ipynb.d.ts +1 -1
  19. package/dist/converters/ipynb.js +6 -3
  20. package/dist/converters/json.d.ts +1 -1
  21. package/dist/converters/json.js +1 -1
  22. package/dist/converters/pdf.d.ts +1 -1
  23. package/dist/converters/pdf.js +1 -1
  24. package/dist/converters/plain-text.d.ts +1 -1
  25. package/dist/converters/plain-text.js +56 -10
  26. package/dist/converters/pptx.d.ts +1 -1
  27. package/dist/converters/pptx.js +39 -12
  28. package/dist/converters/rss.d.ts +1 -1
  29. package/dist/converters/rss.js +18 -14
  30. package/dist/converters/wikipedia.d.ts +1 -1
  31. package/dist/converters/wikipedia.js +6 -8
  32. package/dist/converters/xlsx.d.ts +1 -1
  33. package/dist/converters/xlsx.js +12 -5
  34. package/dist/converters/xml.d.ts +1 -1
  35. package/dist/converters/xml.js +2 -1
  36. package/dist/converters/yaml.d.ts +1 -1
  37. package/dist/converters/yaml.js +2 -1
  38. package/dist/converters/zip.d.ts +1 -1
  39. package/dist/converters/zip.js +3 -2
  40. package/dist/index.d.ts +20 -20
  41. package/dist/index.js +17 -17
  42. package/dist/main.js +13 -7
  43. package/dist/markit.d.ts +1 -1
  44. package/dist/markit.js +13 -16
  45. package/dist/plugins/api.js +1 -3
  46. package/dist/plugins/index.d.ts +3 -3
  47. package/dist/plugins/index.js +2 -2
  48. package/dist/plugins/installer.js +2 -2
  49. package/dist/plugins/types.d.ts +1 -1
  50. package/dist/providers/index.d.ts +2 -2
  51. package/dist/providers/index.js +2 -4
  52. package/dist/providers/openai.js +15 -4
  53. package/dist/utils/turndown.d.ts +8 -0
  54. package/dist/utils/turndown.js +64 -0
  55. package/package.json +4 -2
  56. package/dist/llm.d.ts +0 -10
  57. package/dist/llm.js +0 -139
  58. package/dist/mill.d.ts +0 -18
  59. package/dist/mill.js +0 -123
@@ -1,5 +1,5 @@
1
- import JSZip from "jszip";
2
1
  import { XMLParser } from "fast-xml-parser";
2
+ import JSZip from "jszip";
3
3
  const EXTENSIONS = [".pptx"];
4
4
  const MIMETYPES = [
5
5
  "application/vnd.openxmlformats-officedocument.presentationml.presentation",
@@ -9,7 +9,8 @@ export class PptxConverter {
9
9
  accepts(streamInfo) {
10
10
  if (streamInfo.extension && EXTENSIONS.includes(streamInfo.extension))
11
11
  return true;
12
- if (streamInfo.mimetype && MIMETYPES.some((m) => streamInfo.mimetype.startsWith(m)))
12
+ if (streamInfo.mimetype &&
13
+ MIMETYPES.some((m) => streamInfo.mimetype?.startsWith(m)))
13
14
  return true;
14
15
  return false;
15
16
  }
@@ -26,12 +27,22 @@ export class PptxConverter {
26
27
  throw new Error("Invalid PPTX: missing presentation.xml");
27
28
  const pres = parser.parse(presXml);
28
29
  const sldIdList = pres["p:presentation"]?.["p:sldIdLst"]?.["p:sldId"];
29
- const sldIds = Array.isArray(sldIdList) ? sldIdList : sldIdList ? [sldIdList] : [];
30
+ const sldIds = Array.isArray(sldIdList)
31
+ ? sldIdList
32
+ : sldIdList
33
+ ? [sldIdList]
34
+ : [];
30
35
  // Get relationship mappings
31
- const relsXml = await zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
36
+ const relsXml = await zip
37
+ .file("ppt/_rels/presentation.xml.rels")
38
+ ?.async("string");
32
39
  const rels = relsXml ? parser.parse(relsXml) : null;
33
- const relList = rels?.["Relationships"]?.["Relationship"];
34
- const relArray = Array.isArray(relList) ? relList : relList ? [relList] : [];
40
+ const relList = rels?.Relationships?.Relationship;
41
+ const relArray = Array.isArray(relList)
42
+ ? relList
43
+ : relList
44
+ ? [relList]
45
+ : [];
35
46
  const relMap = new Map();
36
47
  for (const r of relArray) {
37
48
  relMap.set(r["@_Id"], r["@_Target"]);
@@ -49,8 +60,8 @@ export class PptxConverter {
49
60
  const slideFiles = Object.keys(zip.files)
50
61
  .filter((f) => /^ppt\/slides\/slide\d+\.xml$/.test(f))
51
62
  .sort((a, b) => {
52
- const na = parseInt(a.match(/slide(\d+)/)?.[1] || "0");
53
- const nb = parseInt(b.match(/slide(\d+)/)?.[1] || "0");
63
+ const na = parseInt(a.match(/slide(\d+)/)?.[1] || "0", 10);
64
+ const nb = parseInt(b.match(/slide(\d+)/)?.[1] || "0", 10);
54
65
  return na - nb;
55
66
  });
56
67
  slidePaths.push(...slideFiles);
@@ -82,7 +93,11 @@ export class PptxConverter {
82
93
  }
83
94
  // Tables
84
95
  const graphicFrames = spTree["p:graphicFrame"];
85
- const gfList = Array.isArray(graphicFrames) ? graphicFrames : graphicFrames ? [graphicFrames] : [];
96
+ const gfList = Array.isArray(graphicFrames)
97
+ ? graphicFrames
98
+ : graphicFrames
99
+ ? [graphicFrames]
100
+ : [];
86
101
  for (const gf of gfList) {
87
102
  const table = this.extractTable(gf);
88
103
  if (table)
@@ -96,7 +111,11 @@ export class PptxConverter {
96
111
  const noteSpTree = note["p:notes"]?.["p:cSld"]?.["p:spTree"];
97
112
  if (noteSpTree) {
98
113
  const noteShapes = noteSpTree["p:sp"];
99
- const noteList = Array.isArray(noteShapes) ? noteShapes : noteShapes ? [noteShapes] : [];
114
+ const noteList = Array.isArray(noteShapes)
115
+ ? noteShapes
116
+ : noteShapes
117
+ ? [noteShapes]
118
+ : [];
100
119
  const noteTexts = [];
101
120
  for (const ns of noteList) {
102
121
  // Skip slide image placeholder
@@ -122,7 +141,11 @@ export class PptxConverter {
122
141
  if (!txBody)
123
142
  return "";
124
143
  const paragraphs = txBody["a:p"];
125
- const pList = Array.isArray(paragraphs) ? paragraphs : paragraphs ? [paragraphs] : [];
144
+ const pList = Array.isArray(paragraphs)
145
+ ? paragraphs
146
+ : paragraphs
147
+ ? [paragraphs]
148
+ : [];
126
149
  const lines = [];
127
150
  for (const p of pList) {
128
151
  const runs = p["a:r"];
@@ -158,7 +181,11 @@ export class PptxConverter {
158
181
  continue;
159
182
  }
160
183
  const paragraphs = txBody["a:p"];
161
- const pList = Array.isArray(paragraphs) ? paragraphs : paragraphs ? [paragraphs] : [];
184
+ const pList = Array.isArray(paragraphs)
185
+ ? paragraphs
186
+ : paragraphs
187
+ ? [paragraphs]
188
+ : [];
162
189
  const parts = [];
163
190
  for (const p of pList) {
164
191
  const runs = p["a:r"];
@@ -1,4 +1,4 @@
1
- import type { Converter, ConversionResult, StreamInfo } from "../types.js";
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types.js";
2
2
  export declare class RssConverter implements Converter {
3
3
  name: string;
4
4
  accepts(streamInfo: StreamInfo): boolean;
@@ -1,20 +1,25 @@
1
- import TurndownService from "turndown";
2
- const EXTENSIONS = [".rss", ".atom", ".xml"];
1
+ import { createTurndown } from "../utils/turndown.js";
2
+ const _EXTENSIONS = [".rss", ".atom", ".xml"];
3
3
  const MIMETYPES = [
4
- "application/rss+xml", "application/rss",
5
- "application/atom+xml", "application/atom",
6
- "text/xml", "application/xml",
4
+ "application/rss+xml",
5
+ "application/rss",
6
+ "application/atom+xml",
7
+ "application/atom",
8
+ "text/xml",
9
+ "application/xml",
7
10
  ];
8
11
  export class RssConverter {
9
12
  name = "rss";
10
13
  accepts(streamInfo) {
11
14
  // Only accept known RSS/Atom extensions directly
12
- if (streamInfo.extension && [".rss", ".atom"].includes(streamInfo.extension))
15
+ if (streamInfo.extension &&
16
+ [".rss", ".atom"].includes(streamInfo.extension))
13
17
  return true;
14
18
  // For .xml, we'll try and fail gracefully
15
19
  if (streamInfo.extension === ".xml")
16
20
  return true;
17
- if (streamInfo.mimetype && MIMETYPES.some((m) => streamInfo.mimetype.startsWith(m)))
21
+ if (streamInfo.mimetype &&
22
+ MIMETYPES.some((m) => streamInfo.mimetype?.startsWith(m)))
18
23
  return true;
19
24
  return false;
20
25
  }
@@ -31,7 +36,7 @@ export class RssConverter {
31
36
  throw new Error("Not an RSS or Atom feed");
32
37
  }
33
38
  parseRss(xml) {
34
- const turndown = new TurndownService({ headingStyle: "atx" });
39
+ const turndown = createTurndown();
35
40
  const sections = [];
36
41
  // Extract from the <channel> block specifically
37
42
  const channelMatch = xml.match(/<channel>([\s\S]*?)<\/channel>/i);
@@ -69,7 +74,7 @@ export class RssConverter {
69
74
  return { markdown: sections.join("\n\n").trim(), title: channelTitle };
70
75
  }
71
76
  parseAtom(xml) {
72
- const turndown = new TurndownService({ headingStyle: "atx" });
77
+ const turndown = createTurndown();
73
78
  const sections = [];
74
79
  const feedTitle = this.extract(xml, "title");
75
80
  const subtitle = this.extract(xml, "subtitle");
@@ -118,16 +123,15 @@ export class RssConverter {
118
123
  const match = xml.match(re);
119
124
  if (!match)
120
125
  return undefined;
121
- return match[1]
122
- .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1")
123
- .trim() || undefined;
126
+ return (match[1].replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1").trim() || undefined);
124
127
  }
125
128
  extractAll(xml, tag) {
126
129
  const results = [];
127
130
  const re = new RegExp(`<${tag}[^>]*>[\\s\\S]*?</${tag}>`, "gi");
128
- let match;
129
- while ((match = re.exec(xml)) !== null) {
131
+ let match = re.exec(xml);
132
+ while (match !== null) {
130
133
  results.push(match[0]);
134
+ match = re.exec(xml);
131
135
  }
132
136
  return results;
133
137
  }
@@ -1,4 +1,4 @@
1
- import type { Converter, ConversionResult, StreamInfo } from "../types.js";
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types.js";
2
2
  export declare class WikipediaConverter implements Converter {
3
3
  name: string;
4
4
  accepts(streamInfo: StreamInfo): boolean;
@@ -1,4 +1,4 @@
1
- import TurndownService from "turndown";
1
+ import { createTurndown } from "../utils/turndown.js";
2
2
  const WIKIPEDIA_RE = /^https?:\/\/[a-zA-Z]{2,3}\.wikipedia\.org\//;
3
3
  export class WikipediaConverter {
4
4
  name = "wikipedia";
@@ -12,13 +12,11 @@ export class WikipediaConverter {
12
12
  // Extract the main content div
13
13
  const contentMatch = html.match(/<div[^>]*id="mw-content-text"[^>]*>([\s\S]*?)<\/div>\s*(?:<\/div>|$)/i);
14
14
  // Extract title
15
- const titleMatch = html.match(/<span[^>]*class="mw-page-title-main"[^>]*>([\s\S]*?)<\/span>/i) ||
16
- html.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
17
- const title = titleMatch ? titleMatch[1].replace(/ - Wikipedia$/, "").trim() : undefined;
18
- const turndown = new TurndownService({
19
- headingStyle: "atx",
20
- codeBlockStyle: "fenced",
21
- });
15
+ const titleMatch = html.match(/<span[^>]*class="mw-page-title-main"[^>]*>([\s\S]*?)<\/span>/i) || html.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
16
+ const title = titleMatch
17
+ ? titleMatch[1].replace(/ - Wikipedia$/, "").trim()
18
+ : undefined;
19
+ const turndown = createTurndown();
22
20
  // Clean up Wikipedia-specific elements
23
21
  let content = contentMatch ? contentMatch[1] : html;
24
22
  content = content
@@ -1,4 +1,4 @@
1
- import type { Converter, ConversionResult, StreamInfo } from "../types.js";
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types.js";
2
2
  export declare class XlsxConverter implements Converter {
3
3
  name: string;
4
4
  accepts(streamInfo: StreamInfo): boolean;
@@ -1,5 +1,5 @@
1
- import JSZip from "jszip";
2
1
  import { XMLParser } from "fast-xml-parser";
2
+ import JSZip from "jszip";
3
3
  const EXTENSIONS = [".xlsx"];
4
4
  const MIMETYPES = [
5
5
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -9,7 +9,8 @@ export class XlsxConverter {
9
9
  accepts(streamInfo) {
10
10
  if (streamInfo.extension && EXTENSIONS.includes(streamInfo.extension))
11
11
  return true;
12
- if (streamInfo.mimetype && MIMETYPES.some((m) => streamInfo.mimetype.startsWith(m)))
12
+ if (streamInfo.mimetype &&
13
+ MIMETYPES.some((m) => streamInfo.mimetype?.startsWith(m)))
13
14
  return true;
14
15
  return false;
15
16
  }
@@ -32,7 +33,9 @@ export class XlsxConverter {
32
33
  const wb = parser.parse(wbXml);
33
34
  const sheets = toArray(wb.workbook?.sheets?.sheet);
34
35
  // Parse workbook rels to map rIds to sheet files
35
- const relsXml = await zip.file("xl/_rels/workbook.xml.rels")?.async("string");
36
+ const relsXml = await zip
37
+ .file("xl/_rels/workbook.xml.rels")
38
+ ?.async("string");
36
39
  const rels = relsXml ? parser.parse(relsXml) : null;
37
40
  const relList = toArray(rels?.Relationships?.Relationship);
38
41
  const relMap = new Map();
@@ -46,7 +49,9 @@ export class XlsxConverter {
46
49
  const target = relMap.get(rId);
47
50
  if (!target)
48
51
  continue;
49
- const sheetPath = target.startsWith("/") ? target.slice(1) : `xl/${target}`;
52
+ const sheetPath = target.startsWith("/")
53
+ ? target.slice(1)
54
+ : `xl/${target}`;
50
55
  const sheetXml = await zip.file(sheetPath)?.async("string");
51
56
  if (!sheetXml)
52
57
  continue;
@@ -97,7 +102,9 @@ export class XlsxConverter {
97
102
  if (is.t != null)
98
103
  return textValue(is.t);
99
104
  if (is.r)
100
- return toArray(is.r).map((r) => textValue(r.t)).join("");
105
+ return toArray(is.r)
106
+ .map((r) => textValue(r.t))
107
+ .join("");
101
108
  return "";
102
109
  }
103
110
  // Boolean
@@ -1,4 +1,4 @@
1
- import type { Converter, ConversionResult, StreamInfo } from "../types.js";
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types.js";
2
2
  export declare class XmlConverter implements Converter {
3
3
  name: string;
4
4
  accepts(streamInfo: StreamInfo): boolean;
@@ -5,7 +5,8 @@ export class XmlConverter {
5
5
  accepts(streamInfo) {
6
6
  if (streamInfo.extension && EXTENSIONS.includes(streamInfo.extension))
7
7
  return true;
8
- if (streamInfo.mimetype && MIMETYPES.some((m) => streamInfo.mimetype.startsWith(m)))
8
+ if (streamInfo.mimetype &&
9
+ MIMETYPES.some((m) => streamInfo.mimetype?.startsWith(m)))
9
10
  return true;
10
11
  return false;
11
12
  }
@@ -1,4 +1,4 @@
1
- import type { Converter, ConversionResult, StreamInfo } from "../types.js";
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types.js";
2
2
  export declare class YamlConverter implements Converter {
3
3
  name: string;
4
4
  accepts(streamInfo: StreamInfo): boolean;
@@ -5,7 +5,8 @@ export class YamlConverter {
5
5
  accepts(streamInfo) {
6
6
  if (streamInfo.extension && EXTENSIONS.includes(streamInfo.extension))
7
7
  return true;
8
- if (streamInfo.mimetype && MIMETYPES.some((m) => streamInfo.mimetype.startsWith(m)))
8
+ if (streamInfo.mimetype &&
9
+ MIMETYPES.some((m) => streamInfo.mimetype?.startsWith(m)))
9
10
  return true;
10
11
  return false;
11
12
  }
@@ -1,4 +1,4 @@
1
- import type { Converter, ConversionResult, StreamInfo } from "../types.js";
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types.js";
2
2
  export declare class ZipConverter implements Converter {
3
3
  name: string;
4
4
  private parentConverters;
@@ -1,5 +1,5 @@
1
+ import { basename, extname } from "node:path";
1
2
  import JSZip from "jszip";
2
- import { extname, basename } from "node:path";
3
3
  const EXTENSIONS = [".zip"];
4
4
  const MIMETYPES = ["application/zip", "application/x-zip-compressed"];
5
5
  export class ZipConverter {
@@ -11,7 +11,8 @@ export class ZipConverter {
11
11
  accepts(streamInfo) {
12
12
  if (streamInfo.extension && EXTENSIONS.includes(streamInfo.extension))
13
13
  return true;
14
- if (streamInfo.mimetype && MIMETYPES.some((m) => streamInfo.mimetype.startsWith(m)))
14
+ if (streamInfo.mimetype &&
15
+ MIMETYPES.some((m) => streamInfo.mimetype?.startsWith(m)))
15
16
  return true;
16
17
  return false;
17
18
  }
package/dist/index.d.ts CHANGED
@@ -1,28 +1,28 @@
1
- export { Markit } from "./markit.js";
2
- export type { Converter, ConversionResult, StreamInfo, MarkitOptions } from "./types.js";
3
1
  export type { MarkitConfig } from "./config.js";
4
- export { createLlmFunctions, registerProvider, getProvider, listProviders, } from "./providers/index.js";
5
- export type { Provider, ProviderConfig, ResolvedConfig } from "./providers/types.js";
6
- export { openai } from "./providers/openai.js";
7
- export { anthropic } from "./providers/anthropic.js";
8
- export { PdfConverter } from "./converters/pdf.js";
2
+ export { AudioConverter } from "./converters/audio.js";
3
+ export { CsvConverter } from "./converters/csv.js";
9
4
  export { DocxConverter } from "./converters/docx.js";
10
- export { PptxConverter } from "./converters/pptx.js";
11
- export { XlsxConverter } from "./converters/xlsx.js";
12
5
  export { EpubConverter } from "./converters/epub.js";
13
- export { IpynbConverter } from "./converters/ipynb.js";
14
6
  export { HtmlConverter } from "./converters/html.js";
15
- export { WikipediaConverter } from "./converters/wikipedia.js";
16
- export { RssConverter } from "./converters/rss.js";
17
- export { CsvConverter } from "./converters/csv.js";
7
+ export { ImageConverter } from "./converters/image.js";
8
+ export { IpynbConverter } from "./converters/ipynb.js";
18
9
  export { JsonConverter } from "./converters/json.js";
19
- export { YamlConverter } from "./converters/yaml.js";
10
+ export { PdfConverter } from "./converters/pdf.js";
11
+ export { PlainTextConverter } from "./converters/plain-text.js";
12
+ export { PptxConverter } from "./converters/pptx.js";
13
+ export { RssConverter } from "./converters/rss.js";
14
+ export { WikipediaConverter } from "./converters/wikipedia.js";
15
+ export { XlsxConverter } from "./converters/xlsx.js";
20
16
  export { XmlConverter } from "./converters/xml.js";
17
+ export { YamlConverter } from "./converters/yaml.js";
21
18
  export { ZipConverter } from "./converters/zip.js";
22
- export { ImageConverter } from "./converters/image.js";
23
- export { AudioConverter } from "./converters/audio.js";
24
- export { PlainTextConverter } from "./converters/plain-text.js";
25
- export type { MarkitPluginAPI, PluginFunction, PluginDef } from "./plugins/types.js";
19
+ export { Markit } from "./markit.js";
26
20
  export { createPluginAPI, resolvePluginExport } from "./plugins/api.js";
27
- export { loadPluginFromPath, loadAllPlugins } from "./plugins/loader.js";
28
- export { installPlugin, removePlugin, listInstalled, } from "./plugins/installer.js";
21
+ export { installPlugin, listInstalled, removePlugin, } from "./plugins/installer.js";
22
+ export { loadAllPlugins, loadPluginFromPath } from "./plugins/loader.js";
23
+ export type { MarkitPluginAPI, PluginDef, PluginFunction, } from "./plugins/types.js";
24
+ export { anthropic } from "./providers/anthropic.js";
25
+ export { createLlmFunctions, getProvider, listProviders, registerProvider, } from "./providers/index.js";
26
+ export { openai } from "./providers/openai.js";
27
+ export type { Provider, ProviderConfig, ResolvedConfig, } from "./providers/types.js";
28
+ export type { ConversionResult, Converter, MarkitOptions, StreamInfo, } from "./types.js";
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
- export { Markit } from "./markit.js";
2
- export { createLlmFunctions, registerProvider, getProvider, listProviders, } from "./providers/index.js";
3
- export { openai } from "./providers/openai.js";
4
- export { anthropic } from "./providers/anthropic.js";
5
- export { PdfConverter } from "./converters/pdf.js";
1
+ export { AudioConverter } from "./converters/audio.js";
2
+ export { CsvConverter } from "./converters/csv.js";
6
3
  export { DocxConverter } from "./converters/docx.js";
7
- export { PptxConverter } from "./converters/pptx.js";
8
- export { XlsxConverter } from "./converters/xlsx.js";
9
4
  export { EpubConverter } from "./converters/epub.js";
10
- export { IpynbConverter } from "./converters/ipynb.js";
11
5
  export { HtmlConverter } from "./converters/html.js";
12
- export { WikipediaConverter } from "./converters/wikipedia.js";
13
- export { RssConverter } from "./converters/rss.js";
14
- export { CsvConverter } from "./converters/csv.js";
6
+ export { ImageConverter } from "./converters/image.js";
7
+ export { IpynbConverter } from "./converters/ipynb.js";
15
8
  export { JsonConverter } from "./converters/json.js";
16
- export { YamlConverter } from "./converters/yaml.js";
9
+ export { PdfConverter } from "./converters/pdf.js";
10
+ export { PlainTextConverter } from "./converters/plain-text.js";
11
+ export { PptxConverter } from "./converters/pptx.js";
12
+ export { RssConverter } from "./converters/rss.js";
13
+ export { WikipediaConverter } from "./converters/wikipedia.js";
14
+ export { XlsxConverter } from "./converters/xlsx.js";
17
15
  export { XmlConverter } from "./converters/xml.js";
16
+ export { YamlConverter } from "./converters/yaml.js";
18
17
  export { ZipConverter } from "./converters/zip.js";
19
- export { ImageConverter } from "./converters/image.js";
20
- export { AudioConverter } from "./converters/audio.js";
21
- export { PlainTextConverter } from "./converters/plain-text.js";
18
+ export { Markit } from "./markit.js";
22
19
  export { createPluginAPI, resolvePluginExport } from "./plugins/api.js";
23
- export { loadPluginFromPath, loadAllPlugins } from "./plugins/loader.js";
24
- export { installPlugin, removePlugin, listInstalled, } from "./plugins/installer.js";
20
+ export { installPlugin, listInstalled, removePlugin, } from "./plugins/installer.js";
21
+ export { loadAllPlugins, loadPluginFromPath } from "./plugins/loader.js";
22
+ export { anthropic } from "./providers/anthropic.js";
23
+ export { createLlmFunctions, getProvider, listProviders, registerProvider, } from "./providers/index.js";
24
+ export { openai } from "./providers/openai.js";
package/dist/main.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
3
  import { Command } from "commander";
4
+ import { configGet, configSet, configShow } from "./commands/config.js";
4
5
  import { convert } from "./commands/convert.js";
5
- import { onboard } from "./commands/onboard.js";
6
6
  import { formats } from "./commands/formats.js";
7
7
  import { init } from "./commands/init.js";
8
- import { configShow, configGet, configSet } from "./commands/config.js";
9
- import { pluginInstall, pluginRemove, pluginList } from "./commands/plugin.js";
8
+ import { onboard } from "./commands/onboard.js";
9
+ import { pluginInstall, pluginList, pluginRemove } from "./commands/plugin.js";
10
10
  const require = createRequire(import.meta.url);
11
11
  const { version } = require("../package.json");
12
12
  const program = new Command();
@@ -76,9 +76,7 @@ configCmd
76
76
  const globals = cmd.optsWithGlobals();
77
77
  await configSet(key, value, { json: globals.json, quiet: globals.quiet });
78
78
  });
79
- const pluginCmd = program
80
- .command("plugin")
81
- .description("Manage plugins");
79
+ const pluginCmd = program.command("plugin").description("Manage plugins");
82
80
  pluginCmd
83
81
  .command("install <source>")
84
82
  .description("Install a plugin (npm:pkg, git:url, or local path)")
@@ -122,7 +120,15 @@ program.on("command:*", async (args) => {
122
120
  return;
123
121
  }
124
122
  // Check for typos against known subcommands
125
- const commands = ["convert", "formats", "onboard", "help", "init", "config", "plugin"];
123
+ const commands = [
124
+ "convert",
125
+ "formats",
126
+ "onboard",
127
+ "help",
128
+ "init",
129
+ "config",
130
+ "plugin",
131
+ ];
126
132
  const close = commands.filter((c) => levenshtein(source, c) <= 2 && source !== c);
127
133
  if (close.length > 0 &&
128
134
  !source.includes("/") &&
package/dist/markit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ConversionResult, StreamInfo, MarkitOptions } from "./types.js";
2
1
  import type { PluginDef } from "./plugins/types.js";
2
+ import type { ConversionResult, MarkitOptions, StreamInfo } from "./types.js";
3
3
  export declare class Markit {
4
4
  private converters;
5
5
  private options;
package/dist/markit.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { readFileSync } from "node:fs";
2
- import { extname, basename } from "node:path";
3
- import { PdfConverter } from "./converters/pdf.js";
2
+ import { basename, extname } from "node:path";
3
+ import { AudioConverter } from "./converters/audio.js";
4
+ import { CsvConverter } from "./converters/csv.js";
4
5
  import { DocxConverter } from "./converters/docx.js";
5
- import { PptxConverter } from "./converters/pptx.js";
6
- import { XlsxConverter } from "./converters/xlsx.js";
7
6
  import { EpubConverter } from "./converters/epub.js";
8
- import { IpynbConverter } from "./converters/ipynb.js";
9
7
  import { HtmlConverter } from "./converters/html.js";
10
- import { WikipediaConverter } from "./converters/wikipedia.js";
11
- import { RssConverter } from "./converters/rss.js";
12
- import { CsvConverter } from "./converters/csv.js";
8
+ import { ImageConverter } from "./converters/image.js";
9
+ import { IpynbConverter } from "./converters/ipynb.js";
13
10
  import { JsonConverter } from "./converters/json.js";
14
- import { YamlConverter } from "./converters/yaml.js";
11
+ import { PdfConverter } from "./converters/pdf.js";
12
+ import { PlainTextConverter } from "./converters/plain-text.js";
13
+ import { PptxConverter } from "./converters/pptx.js";
14
+ import { RssConverter } from "./converters/rss.js";
15
+ import { WikipediaConverter } from "./converters/wikipedia.js";
16
+ import { XlsxConverter } from "./converters/xlsx.js";
15
17
  import { XmlConverter } from "./converters/xml.js";
18
+ import { YamlConverter } from "./converters/yaml.js";
16
19
  import { ZipConverter } from "./converters/zip.js";
17
- import { ImageConverter } from "./converters/image.js";
18
- import { AudioConverter } from "./converters/audio.js";
19
- import { PlainTextConverter } from "./converters/plain-text.js";
20
20
  export class Markit {
21
21
  converters = [];
22
22
  options;
@@ -40,10 +40,7 @@ export class Markit {
40
40
  new ImageConverter(),
41
41
  new AudioConverter(),
42
42
  ];
43
- const generic = [
44
- new XmlConverter(),
45
- new HtmlConverter(),
46
- ];
43
+ const generic = [new XmlConverter(), new HtmlConverter()];
47
44
  // ZIP gets all converters (plugin + builtin) for recursive extraction
48
45
  const allNonZip = [...pluginConverters, ...specific, ...generic];
49
46
  const zipConverter = new ZipConverter(allNonZip);
@@ -35,9 +35,7 @@ export function resolvePluginExport(exported, pluginId) {
35
35
  exported(api);
36
36
  return resolve();
37
37
  }
38
- if (exported &&
39
- typeof exported === "object" &&
40
- "converters" in exported) {
38
+ if (exported && typeof exported === "object" && "converters" in exported) {
41
39
  return exported;
42
40
  }
43
41
  throw new Error(`Invalid plugin export from "${pluginId}": expected a function or { name, converters } object`);
@@ -1,4 +1,4 @@
1
- export type { MarkitPluginAPI, PluginFunction, PluginDef } from "./types.js";
2
1
  export { createPluginAPI, resolvePluginExport } from "./api.js";
3
- export { loadPluginFromPath, loadAllPlugins } from "./loader.js";
4
- export { installPlugin, removePlugin, listInstalled, parsePluginSource, } from "./installer.js";
2
+ export { installPlugin, listInstalled, parsePluginSource, removePlugin, } from "./installer.js";
3
+ export { loadAllPlugins, loadPluginFromPath } from "./loader.js";
4
+ export type { MarkitPluginAPI, PluginDef, PluginFunction } from "./types.js";
@@ -1,3 +1,3 @@
1
1
  export { createPluginAPI, resolvePluginExport } from "./api.js";
2
- export { loadPluginFromPath, loadAllPlugins } from "./loader.js";
3
- export { installPlugin, removePlugin, listInstalled, parsePluginSource, } from "./installer.js";
2
+ export { installPlugin, listInstalled, parsePluginSource, removePlugin, } from "./installer.js";
3
+ export { loadAllPlugins, loadPluginFromPath } from "./loader.js";
@@ -106,7 +106,7 @@ export async function installPlugin(source) {
106
106
  break;
107
107
  }
108
108
  case "git": {
109
- const url = new URL(parsed.url);
109
+ const url = new URL(parsed.url || "");
110
110
  const gitDir = join(pluginsDir, "git", url.hostname, url.pathname.replace(/\.git$/, ""));
111
111
  if (existsSync(gitDir)) {
112
112
  execSync("git pull", { cwd: gitDir, stdio: "pipe" });
@@ -125,7 +125,7 @@ export async function installPlugin(source) {
125
125
  break;
126
126
  }
127
127
  case "local": {
128
- if (!existsSync(parsed.path)) {
128
+ if (!parsed.path || !existsSync(parsed.path)) {
129
129
  throw new Error(`Path does not exist: ${parsed.path}`);
130
130
  }
131
131
  installPath = parsed.path;
@@ -1,5 +1,5 @@
1
- import type { Converter } from "../types.js";
2
1
  import type { Provider } from "../providers/types.js";
2
+ import type { Converter } from "../types.js";
3
3
  export interface FormatDef {
4
4
  name: string;
5
5
  extensions: string[];
@@ -1,6 +1,6 @@
1
- import type { Provider } from "./types.js";
2
- import type { MarkitOptions } from "../types.js";
3
1
  import type { MarkitConfig } from "../config.js";
2
+ import type { MarkitOptions } from "../types.js";
3
+ import type { Provider } from "./types.js";
4
4
  export type { Provider, ProviderConfig, ResolvedConfig } from "./types.js";
5
5
  /**
6
6
  * Register a custom provider.
@@ -1,5 +1,5 @@
1
- import { openai } from "./openai.js";
2
1
  import { anthropic } from "./anthropic.js";
2
+ import { openai } from "./openai.js";
3
3
  const providers = {
4
4
  openai,
5
5
  anthropic,
@@ -51,8 +51,6 @@ export function createLlmFunctions(config, prompt) {
51
51
  const resolved = resolve(provider, config);
52
52
  if (!resolved)
53
53
  return {};
54
- const fullPrompt = prompt
55
- ? `${BASE_PROMPT}\n\n${prompt}`
56
- : BASE_PROMPT;
54
+ const fullPrompt = prompt ? `${BASE_PROMPT}\n\n${prompt}` : BASE_PROMPT;
57
55
  return provider.create(resolved, fullPrompt);
58
56
  }