ai-contextify 0.1.0 → 0.1.1

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/cli.js CHANGED
@@ -10,7 +10,7 @@ const program = new Command();
10
10
  program
11
11
  .name("ai-contextify")
12
12
  .description("Convert files and entire projects into optimized context for LLMs (Claude, ChatGPT, Gemini).")
13
- .version("0.1.0")
13
+ .version("0.1.1")
14
14
  .argument("<input>", "File or directory to convert into LLM context")
15
15
  .option("-o, --output <dir>", "Output directory", "context-output")
16
16
  .option("-i, --include <patterns...>", "Glob patterns to include (default: everything)")
@@ -1 +1 @@
1
- {"version":3,"file":"docx.d.ts","sourceRoot":"","sources":["../../src/parsers/docx.ts"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBrE"}
1
+ {"version":3,"file":"docx.d.ts","sourceRoot":"","sources":["../../src/parsers/docx.ts"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCrE"}
@@ -4,13 +4,34 @@ export async function parseDocx(absolutePath) {
4
4
  // so we narrow the shape ourselves and fall back to plain text on failure.
5
5
  const mammothAny = mammoth;
6
6
  if (typeof mammothAny.convertToMarkdown === "function") {
7
- const { value } = await mammothAny.convertToMarkdown({ path: absolutePath });
8
- return value
9
- .replace(/\r\n/g, "\n")
10
- .replace(/\n{3,}/g, "\n\n")
11
- .trim();
7
+ // Tell mammoth to drop images entirely instead of inlining them as
8
+ // base64 data URIs, which would explode the output size and waste tokens.
9
+ const options = mammothAny.images?.imgElement
10
+ ? {
11
+ convertImage: mammothAny.images.imgElement(async () => ({
12
+ src: "",
13
+ })),
14
+ }
15
+ : undefined;
16
+ const { value } = await mammothAny.convertToMarkdown({ path: absolutePath }, options);
17
+ return stripImageNoise(value);
12
18
  }
13
19
  const { value } = await mammoth.extractRawText({ path: absolutePath });
14
20
  return value.replace(/\r\n/g, "\n").trim();
15
21
  }
22
+ /**
23
+ * Belt-and-suspenders: even with `convertImage` set to empty src, older
24
+ * mammoth versions still emit base64 data URIs. Strip them out, along with
25
+ * any leftover empty image links, then collapse the resulting whitespace.
26
+ */
27
+ function stripImageNoise(markdown) {
28
+ return markdown
29
+ .replace(/\r\n/g, "\n")
30
+ .replace(/!\[[^\]]*\]\(data:[^)]+\)/g, "")
31
+ .replace(/!\[[^\]]*\]\([^)]*\)/g, "")
32
+ .replace(/!\[\]\(\)/g, "")
33
+ .replace(/[ \t]+\n/g, "\n")
34
+ .replace(/\n{3,}/g, "\n\n")
35
+ .trim();
36
+ }
16
37
  //# sourceMappingURL=docx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"docx.js","sourceRoot":"","sources":["../../src/parsers/docx.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,YAAoB;IAClD,6EAA6E;IAC7E,2EAA2E;IAC3E,MAAM,UAAU,GAAG,OAIlB,CAAC;IAEF,IAAI,OAAO,UAAU,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QACvD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,UAAU,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QAC7E,OAAO,KAAK;aACT,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;aACtB,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;aAC1B,IAAI,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;IACvE,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC"}
1
+ {"version":3,"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M,CAAC;SAC1B,IAAI,EAAE,CAAC;AACZ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-contextify",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Convert files and entire projects into optimized context for LLMs like Claude, ChatGPT and Gemini.",
5
5
  "keywords": [
6
6
  "ai",