llms-generator-cli 1.0.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 (4) hide show
  1. package/index.js +59 -0
  2. package/llms-full.txt +1774 -0
  3. package/llms.txt +235 -0
  4. package/package.json +16 -0
package/index.js ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import axios from 'axios';
5
+ import * as cheerio from 'cheerio';
6
+ import TurndownService from 'turndown';
7
+ import fs from 'fs';
8
+ import path from 'path';
9
+
10
+ const program = new Command();
11
+ const turndownService = new TurndownService();
12
+
13
+ program
14
+ .name('llms-gen')
15
+ .description('Generate llms.txt and advanced context from a URL')
16
+ .version('1.0.0')
17
+ .argument('<url>', 'The target website URL')
18
+ .option('-a, --advanced', 'Generate extended llms-full.txt with deep context')
19
+ .action(async (url, options) => {
20
+ try {
21
+ console.log(`🔍 Fetching and analyzing: ${url}...`);
22
+
23
+ // ā§§. āĻ“ā§Ÿā§‡āĻŦāϏāĻžāχāĻŸā§‡āϰ HTML āĻĄā§‡āϟāĻž āĻĄāĻžāωāύāϞ⧋āĻĄ āĻ•āϰāĻž
24
+ const { data } = await axios.get(url);
25
+
26
+ // ⧍. HTML āĻĄā§‡āϟāĻž āϰāĻŋāĻĄ (Parse) āĻ•āϰāĻž
27
+ const $ = cheerio.load(data);
28
+
29
+ // āĻŽā§‡āϟāĻžāĻĄā§‡āϟāĻž (āϟāĻžāχāĻŸā§‡āϞ āĻ“ āĻĄā§‡āϏāĻ•ā§āϰāĻŋāĻĒāĻļāύ) āϖ⧁āρāĻœā§‡ āĻŦ⧇āϰ āĻ•āϰāĻž
30
+ const title = $('title').text() || 'Documentation';
31
+ const description = $('meta[name="description"]').attr('content') || 'No description available.';
32
+
33
+ // āĻŽā§‡āχāύ āĻ•āĻ¨ā§āĻŸā§‡āĻ¨ā§āϟ āϰāĻŋāĻĄ āĻ•āϰāĻž (āĻ…āĻĒā§āĻ°ā§Ÿā§‹āϜāĻ¨ā§€ā§Ÿ āĻšā§‡āĻĄāĻžāϰ/āĻĢ⧁āϟāĻžāϰ āĻŦāĻžāĻĻ āĻĻ⧇āĻ“ā§ŸāĻžāϰ āϜāĻ¨ā§āϝ)
34
+ const mainContentHtml = $('main').html() || $('body').html();
35
+
36
+ // ā§Š. HTML-āϕ⧇ āĻ•ā§āϞāĻŋāύ Markdown-āĻ āϰ⧂āĻĒāĻžāĻ¨ā§āϤāϰ āĻ•āϰāĻž
37
+ const markdownContent = turndownService.turndown(mainContentHtml);
38
+
39
+ // ā§Ē. āĻ¸ā§āĻŸā§āϝāĻžāĻ¨ā§āĻĄāĻžāĻ°ā§āĻĄ llms.txt āĻĢāϰāĻŽā§āϝāĻžāϟ āϤ⧈āϰāĻŋ āĻ•āϰāĻž
40
+ const llmsTxtContent = `# ${title}\n\n> ${description}\n\n## Info\n- URL: ${url}\n\n## Core Content\n${markdownContent.substring(0, 2000)}`;
41
+
42
+ // ā§Ģ. āĻĢāĻžāχāϞāϟāĻŋ āχāωāϜāĻžāϰ⧇āϰ āĻ•āĻžāϰ⧇āĻ¨ā§āϟ āĻĢā§‹āĻ˛ā§āĻĄāĻžāϰ⧇ āϏ⧇āĻ­ āĻ•āϰāĻž
43
+ fs.writeFileSync(path.join(process.cwd(), 'llms.txt'), llmsTxtContent);
44
+ console.log(`✅ Successfully generated llms.txt!`);
45
+
46
+ // ā§Ŧ. āχāωāϜāĻžāϰ āϝāĻĻāĻŋ āĻ…ā§āϝāĻžāĻĄāĻ­āĻžāĻ¨ā§āϏāĻĄ āĻĢā§āĻ˛ā§āϝāĻžāĻ— (-a) āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇
47
+ if (options.advanced) {
48
+ console.log(`🚀 Generating advanced llms-full.txt...`);
49
+ const advancedContent = `# Full Context: ${title}\n\n${markdownContent}`;
50
+ fs.writeFileSync(path.join(process.cwd(), 'llms-full.txt'), advancedContent);
51
+ console.log(`✅ Successfully generated llms-full.txt!`);
52
+ }
53
+
54
+ } catch (error) {
55
+ console.error(`❌ Error: ${error.message}`);
56
+ }
57
+ });
58
+
59
+ program.parse();