llms-format 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.
package/dist/index.cjs ADDED
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ formatDate: () => formatDate,
24
+ formatDirectoryName: () => formatDirectoryName,
25
+ generateLlmsMetadata: () => generateLlmsMetadata,
26
+ generateLlmsTxtContent: () => generateLlmsTxtContent
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ function formatDate(date) {
30
+ return date.toLocaleDateString("en-US", {
31
+ year: "numeric",
32
+ month: "long",
33
+ day: "numeric",
34
+ hour: "2-digit",
35
+ minute: "2-digit",
36
+ timeZoneName: "short"
37
+ });
38
+ }
39
+ function generateLlmsMetadata(options) {
40
+ const lines = [];
41
+ lines.push(`# ${options.title}`);
42
+ lines.push("");
43
+ if (options.description) {
44
+ lines.push(`> ${options.description}`);
45
+ lines.push("");
46
+ }
47
+ lines.push(`Repository: ${options.repository}`);
48
+ lines.push(`Branch: ${options.branch}`);
49
+ const generatedDate = options.generatedAt ? new Date(options.generatedAt) : /* @__PURE__ */ new Date();
50
+ lines.push(`Generated: ${formatDate(generatedDate)}`);
51
+ lines.push(`Generated with: [Lassie](https://github.com/raggle-ai/lassie)`);
52
+ lines.push("");
53
+ const slug = options.slug || options.title.split("/").pop()?.toLowerCase() || "my-project";
54
+ lines.push(`> **Note for AI assistants:** This documentation index was generated on the date above and may be outdated. If you need the latest documentation, you can regenerate it by running: \`npx lassie-llm . --upload --slug ${slug}\` from the repository root.`);
55
+ lines.push("");
56
+ return lines;
57
+ }
58
+ function formatDirectoryName(dir) {
59
+ return dir.split("/").map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/_/g, " ")).join(" / ");
60
+ }
61
+ function generateLlmsTxtContent(data, includeDescriptions = false) {
62
+ const lines = generateLlmsMetadata({
63
+ title: data.title,
64
+ description: data.description,
65
+ repository: data.repository,
66
+ branch: data.branch,
67
+ generatedAt: data.generatedAt
68
+ });
69
+ for (const folder of data.folders) {
70
+ if (folder.folder !== ".") {
71
+ lines.push(`## ${folder.displayName}`);
72
+ lines.push("");
73
+ }
74
+ for (const file of folder.files) {
75
+ if (includeDescriptions && file.description) {
76
+ lines.push(`- [${file.title}](${file.url}): ${file.description}`);
77
+ } else {
78
+ lines.push(`- [${file.title}](${file.url})`);
79
+ }
80
+ }
81
+ lines.push("");
82
+ }
83
+ return lines.join("\n");
84
+ }
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ formatDate,
88
+ formatDirectoryName,
89
+ generateLlmsMetadata,
90
+ generateLlmsTxtContent
91
+ });
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @raggle/llms-format
3
+ *
4
+ * Shared formatting utilities for llms.txt generation.
5
+ * This package has zero Node.js dependencies and can be used in:
6
+ * - Node.js CLI tools
7
+ * - Cloudflare Workers
8
+ * - Browser environments
9
+ */
10
+ /**
11
+ * Format a date for display in llms.txt
12
+ */
13
+ declare function formatDate(date: Date): string;
14
+ /**
15
+ * Options for generating llms.txt metadata header
16
+ */
17
+ interface LlmsMetadataOptions {
18
+ title: string;
19
+ description?: string | null;
20
+ repository: string;
21
+ branch: string;
22
+ generatedAt?: string;
23
+ slug?: string;
24
+ }
25
+ /**
26
+ * Generate the metadata header for llms.txt
27
+ *
28
+ * @param options - Metadata options
29
+ * @returns Array of lines for the header section
30
+ */
31
+ declare function generateLlmsMetadata(options: LlmsMetadataOptions): string[];
32
+ /**
33
+ * Format a directory name for display (e.g., "my_folder/sub_dir" -> "My Folder / Sub Dir")
34
+ */
35
+ declare function formatDirectoryName(dir: string): string;
36
+ /**
37
+ * File entry structure for llms.txt
38
+ */
39
+ interface LlmsFileEntry {
40
+ name: string;
41
+ path: string;
42
+ url: string;
43
+ title: string;
44
+ description: string | null;
45
+ }
46
+ /**
47
+ * Folder group structure for llms.txt
48
+ */
49
+ interface LlmsFolderGroup {
50
+ folder: string;
51
+ displayName: string;
52
+ files: LlmsFileEntry[];
53
+ }
54
+ /**
55
+ * Full llms.txt data structure
56
+ */
57
+ interface LlmsData {
58
+ title: string;
59
+ description: string | null;
60
+ repository: string;
61
+ branch: string;
62
+ generatedAt: string;
63
+ totalFiles: number;
64
+ files: LlmsFileEntry[];
65
+ folders: LlmsFolderGroup[];
66
+ }
67
+ /**
68
+ * Generate complete llms.txt content from data
69
+ *
70
+ * @param data - The llms data structure
71
+ * @param includeDescriptions - Whether to include file descriptions
72
+ * @returns The formatted llms.txt content
73
+ */
74
+ declare function generateLlmsTxtContent(data: LlmsData, includeDescriptions?: boolean): string;
75
+
76
+ export { type LlmsData, type LlmsFileEntry, type LlmsFolderGroup, type LlmsMetadataOptions, formatDate, formatDirectoryName, generateLlmsMetadata, generateLlmsTxtContent };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @raggle/llms-format
3
+ *
4
+ * Shared formatting utilities for llms.txt generation.
5
+ * This package has zero Node.js dependencies and can be used in:
6
+ * - Node.js CLI tools
7
+ * - Cloudflare Workers
8
+ * - Browser environments
9
+ */
10
+ /**
11
+ * Format a date for display in llms.txt
12
+ */
13
+ declare function formatDate(date: Date): string;
14
+ /**
15
+ * Options for generating llms.txt metadata header
16
+ */
17
+ interface LlmsMetadataOptions {
18
+ title: string;
19
+ description?: string | null;
20
+ repository: string;
21
+ branch: string;
22
+ generatedAt?: string;
23
+ slug?: string;
24
+ }
25
+ /**
26
+ * Generate the metadata header for llms.txt
27
+ *
28
+ * @param options - Metadata options
29
+ * @returns Array of lines for the header section
30
+ */
31
+ declare function generateLlmsMetadata(options: LlmsMetadataOptions): string[];
32
+ /**
33
+ * Format a directory name for display (e.g., "my_folder/sub_dir" -> "My Folder / Sub Dir")
34
+ */
35
+ declare function formatDirectoryName(dir: string): string;
36
+ /**
37
+ * File entry structure for llms.txt
38
+ */
39
+ interface LlmsFileEntry {
40
+ name: string;
41
+ path: string;
42
+ url: string;
43
+ title: string;
44
+ description: string | null;
45
+ }
46
+ /**
47
+ * Folder group structure for llms.txt
48
+ */
49
+ interface LlmsFolderGroup {
50
+ folder: string;
51
+ displayName: string;
52
+ files: LlmsFileEntry[];
53
+ }
54
+ /**
55
+ * Full llms.txt data structure
56
+ */
57
+ interface LlmsData {
58
+ title: string;
59
+ description: string | null;
60
+ repository: string;
61
+ branch: string;
62
+ generatedAt: string;
63
+ totalFiles: number;
64
+ files: LlmsFileEntry[];
65
+ folders: LlmsFolderGroup[];
66
+ }
67
+ /**
68
+ * Generate complete llms.txt content from data
69
+ *
70
+ * @param data - The llms data structure
71
+ * @param includeDescriptions - Whether to include file descriptions
72
+ * @returns The formatted llms.txt content
73
+ */
74
+ declare function generateLlmsTxtContent(data: LlmsData, includeDescriptions?: boolean): string;
75
+
76
+ export { type LlmsData, type LlmsFileEntry, type LlmsFolderGroup, type LlmsMetadataOptions, formatDate, formatDirectoryName, generateLlmsMetadata, generateLlmsTxtContent };
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ // src/index.ts
2
+ function formatDate(date) {
3
+ return date.toLocaleDateString("en-US", {
4
+ year: "numeric",
5
+ month: "long",
6
+ day: "numeric",
7
+ hour: "2-digit",
8
+ minute: "2-digit",
9
+ timeZoneName: "short"
10
+ });
11
+ }
12
+ function generateLlmsMetadata(options) {
13
+ const lines = [];
14
+ lines.push(`# ${options.title}`);
15
+ lines.push("");
16
+ if (options.description) {
17
+ lines.push(`> ${options.description}`);
18
+ lines.push("");
19
+ }
20
+ lines.push(`Repository: ${options.repository}`);
21
+ lines.push(`Branch: ${options.branch}`);
22
+ const generatedDate = options.generatedAt ? new Date(options.generatedAt) : /* @__PURE__ */ new Date();
23
+ lines.push(`Generated: ${formatDate(generatedDate)}`);
24
+ lines.push(`Generated with: [Lassie](https://github.com/raggle-ai/lassie)`);
25
+ lines.push("");
26
+ const slug = options.slug || options.title.split("/").pop()?.toLowerCase() || "my-project";
27
+ lines.push(`> **Note for AI assistants:** This documentation index was generated on the date above and may be outdated. If you need the latest documentation, you can regenerate it by running: \`npx lassie-llm . --upload --slug ${slug}\` from the repository root.`);
28
+ lines.push("");
29
+ return lines;
30
+ }
31
+ function formatDirectoryName(dir) {
32
+ return dir.split("/").map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/_/g, " ")).join(" / ");
33
+ }
34
+ function generateLlmsTxtContent(data, includeDescriptions = false) {
35
+ const lines = generateLlmsMetadata({
36
+ title: data.title,
37
+ description: data.description,
38
+ repository: data.repository,
39
+ branch: data.branch,
40
+ generatedAt: data.generatedAt
41
+ });
42
+ for (const folder of data.folders) {
43
+ if (folder.folder !== ".") {
44
+ lines.push(`## ${folder.displayName}`);
45
+ lines.push("");
46
+ }
47
+ for (const file of folder.files) {
48
+ if (includeDescriptions && file.description) {
49
+ lines.push(`- [${file.title}](${file.url}): ${file.description}`);
50
+ } else {
51
+ lines.push(`- [${file.title}](${file.url})`);
52
+ }
53
+ }
54
+ lines.push("");
55
+ }
56
+ return lines.join("\n");
57
+ }
58
+ export {
59
+ formatDate,
60
+ formatDirectoryName,
61
+ generateLlmsMetadata,
62
+ generateLlmsTxtContent
63
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "llms-format",
3
+ "version": "1.0.0",
4
+ "description": "Shared formatting utilities for llms.txt generation. Zero Node.js dependencies.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format cjs,esm --dts",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "keywords": [
24
+ "llms.txt",
25
+ "llms",
26
+ "formatting",
27
+ "ai",
28
+ "documentation"
29
+ ],
30
+ "author": "Raggle <hello@raggle.co>",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/raggle-ai/lassie.git",
35
+ "directory": "packages/llms-format"
36
+ },
37
+ "devDependencies": {
38
+ "tsup": "^8.0.0",
39
+ "typescript": "^5.0.0"
40
+ }
41
+ }