nuxt-ai-ready 0.0.0 → 0.0.2

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "0.0.0",
7
+ "version": "0.0.2",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -11,51 +11,13 @@ import { readPackageJSON } from 'pkg-types';
11
11
  import { estimateTokenCount } from 'tokenx';
12
12
  import { writeFile } from 'node:fs/promises';
13
13
  import { join } from 'node:path';
14
- import { consola } from 'consola';
15
14
  import { generateLlmsTxtArtifacts } from 'mdream/llms-txt';
15
+ import { normalizeLlmsTxtConfig } from '../dist/runtime/llms-txt.js';
16
16
 
17
- const logger$1 = useLogger("nuxt-ai-ready");
17
+ const logger = useLogger("nuxt-ai-ready");
18
18
 
19
- function normalizeLink(link) {
20
- const parts = [];
21
- parts.push(`- [${link.title}](${link.href})`);
22
- if (link.description) {
23
- parts.push(` ${link.description}`);
24
- }
25
- return parts.join("\n");
26
- }
27
- function normalizeSection(section) {
28
- const parts = [];
29
- parts.push(`## ${section.title}`);
30
- parts.push("");
31
- if (section.description) {
32
- const descriptions = Array.isArray(section.description) ? section.description : [section.description];
33
- parts.push(...descriptions);
34
- parts.push("");
35
- }
36
- if (section.links?.length) {
37
- parts.push(...section.links.map(normalizeLink));
38
- }
39
- return parts.join("\n");
40
- }
41
- function normalizeLlmsTxtConfig(config) {
42
- const parts = [];
43
- if (config.sections?.length) {
44
- parts.push(...config.sections.map(normalizeSection));
45
- }
46
- if (config.notes) {
47
- parts.push("## Notes");
48
- parts.push("");
49
- const notes = Array.isArray(config.notes) ? config.notes : [config.notes];
50
- parts.push(...notes);
51
- }
52
- return parts.join("\n\n");
53
- }
54
-
55
- const logger = consola.withTag("nuxt-mdream");
56
19
  function setupPrerenderHandler() {
57
20
  const nuxt = useNuxt();
58
- nuxt.options.aiReady || {};
59
21
  const pages = [];
60
22
  nuxt.hooks.hook("nitro:init", async (nitro) => {
61
23
  nitro.hooks.hook("prerender:generate", async (route) => {
@@ -189,9 +151,9 @@ const module = defineNuxtModule({
189
151
  async setup(config, nuxt) {
190
152
  const { resolve: resolve$1 } = createResolver(import.meta.url);
191
153
  const { version } = await readPackageJSON(resolve$1("../package.json"));
192
- logger$1.level = config.debug || nuxt.options.debug ? 4 : 3;
154
+ logger.level = config.debug || nuxt.options.debug ? 4 : 3;
193
155
  if (config.enabled === false) {
194
- logger$1.debug("Module is disabled, skipping setup.");
156
+ logger.debug("Module is disabled, skipping setup.");
195
157
  return;
196
158
  }
197
159
  await installNuxtSiteConfig();
@@ -315,11 +277,11 @@ Returns JSONL (newline-delimited JSON) with all indexed content.`
315
277
  nuxt.hooks.hook("modules:done", () => {
316
278
  nuxt.hook("nitro:init", async (nitro) => {
317
279
  if (!isBuildMode) {
318
- logger$1.debug("Dev mode: skipping llms.txt generation");
280
+ logger.debug("Dev mode: skipping llms.txt generation");
319
281
  return;
320
282
  }
321
283
  if (config.bulkRoute === false) {
322
- logger$1.debug("Bulk route disabled, skipping bulk generation");
284
+ logger.debug("Bulk route disabled, skipping bulk generation");
323
285
  return;
324
286
  }
325
287
  const bulkPath = resolve(nitro.options.output.dir, `public${config.bulkRoute}`);
@@ -365,7 +327,7 @@ Returns JSONL (newline-delimited JSON) with all indexed content.`
365
327
  if (!bulkStream) {
366
328
  mkdirSync(dirname(bulkPath), { recursive: true });
367
329
  bulkStream = createWriteStream(bulkPath);
368
- logger$1.info(`Bulk JSONL stream created at ${relative(nuxt.options.rootDir, bulkPath)}`);
330
+ logger.info(`Bulk JSONL stream created at ${relative(nuxt.options.rootDir, bulkPath)}`);
369
331
  }
370
332
  let idx = 0;
371
333
  for (const chunk of chunksStream) {
@@ -395,7 +357,7 @@ Returns JSONL (newline-delimited JSON) with all indexed content.`
395
357
  nitro.hooks.hook("prerender:done", () => {
396
358
  if (bulkStream) {
397
359
  bulkStream.end();
398
- logger$1.success(`Bulk JSONL exported ${bulkStreamEntries} entries.`);
360
+ logger.success(`Bulk JSONL exported ${bulkStreamEntries} entries.`);
399
361
  }
400
362
  });
401
363
  });
@@ -0,0 +1,5 @@
1
+ import type { LlmsTxtConfig } from './types.js';
2
+ /**
3
+ * Normalize llms.txt structured configuration to markdown string
4
+ */
5
+ export declare function normalizeLlmsTxtConfig(config: LlmsTxtConfig): string;
@@ -0,0 +1,35 @@
1
+ function normalizeLink(link) {
2
+ const parts = [];
3
+ parts.push(`- [${link.title}](${link.href})`);
4
+ if (link.description) {
5
+ parts.push(` ${link.description}`);
6
+ }
7
+ return parts.join("\n");
8
+ }
9
+ function normalizeSection(section) {
10
+ const parts = [];
11
+ parts.push(`## ${section.title}`);
12
+ parts.push("");
13
+ if (section.description) {
14
+ const descriptions = Array.isArray(section.description) ? section.description : [section.description];
15
+ parts.push(...descriptions);
16
+ parts.push("");
17
+ }
18
+ if (section.links?.length) {
19
+ parts.push(...section.links.map(normalizeLink));
20
+ }
21
+ return parts.join("\n");
22
+ }
23
+ export function normalizeLlmsTxtConfig(config) {
24
+ const parts = [];
25
+ if (config.sections?.length) {
26
+ parts.push(...config.sections.map(normalizeSection));
27
+ }
28
+ if (config.notes) {
29
+ parts.push("## Notes");
30
+ parts.push("");
31
+ const notes = Array.isArray(config.notes) ? config.notes : [config.notes];
32
+ parts.push(...notes);
33
+ }
34
+ return parts.join("\n\n");
35
+ }
@@ -15,6 +15,7 @@ export default defineMcpPrompt({
15
15
  required: false
16
16
  }
17
17
  ],
18
+ // @ts-expect-error untyped
18
19
  handler: async ({ concept, level = "intermediate" }) => {
19
20
  const searchLower = concept.toLowerCase();
20
21
  const seenRoutes = /* @__PURE__ */ new Set();
@@ -15,6 +15,7 @@ export default defineMcpPrompt({
15
15
  required: false
16
16
  }
17
17
  ],
18
+ // @ts-expect-error untyped
18
19
  handler: async ({ topic, detail = "detailed" }) => {
19
20
  const searchLower = topic.toLowerCase();
20
21
  const seenRoutes = /* @__PURE__ */ new Set();
@@ -15,6 +15,7 @@ export default defineMcpPrompt({
15
15
  required: false
16
16
  }
17
17
  ],
18
+ // @ts-expect-error untyped
18
19
  handler: async ({ topic, maxResults = 10 }) => {
19
20
  const searchLower = topic.toLowerCase();
20
21
  const seenRoutes = /* @__PURE__ */ new Set();
@@ -29,6 +29,7 @@ OUTPUT: Returns complete page data including:
29
29
  },
30
30
  required: ["route"]
31
31
  },
32
+ // @ts-expect-error untyped
32
33
  handler: async ({ route }) => {
33
34
  const normalizedRoute = route.startsWith("/") ? route : `/${route}`;
34
35
  const cleanRoute = normalizedRoute.replace(/\/$/, "") || "/";
@@ -47,6 +47,7 @@ FIELD OPTIONS: Control which fields to include in the output:
47
47
  }
48
48
  }
49
49
  },
50
+ // @ts-expect-error untyped
50
51
  handler: async ({ fields = ["route", "title", "description"], search, limit = 100 }) => {
51
52
  const searchLower = search?.toLowerCase();
52
53
  const result = [];
@@ -1,7 +1,7 @@
1
1
  import { getSiteConfig } from "#site-config/server/composables/getSiteConfig";
2
2
  import { eventHandler, setHeader } from "h3";
3
3
  import { useRuntimeConfig } from "nitropack/runtime";
4
- import { normalizeLlmsTxtConfig } from "../../../utils";
4
+ import { normalizeLlmsTxtConfig } from "../../llms-txt.js";
5
5
  export default eventHandler(async (event) => {
6
6
  const runtimeConfig = useRuntimeConfig(event)["nuxt-ai-ready"];
7
7
  const siteConfig = getSiteConfig(event);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "0.0.0",
4
+ "version": "0.0.2",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -67,6 +67,7 @@
67
67
  "happy-dom": "^20.0.11",
68
68
  "nuxt": "^4.2.1",
69
69
  "nuxt-site-config": "^3.2.11",
70
+ "playwright": "^1.57.0",
70
71
  "playwright-core": "^1.57.0",
71
72
  "postgres": "^3.4.7",
72
73
  "typescript": "^5.9.3",
@@ -93,7 +94,7 @@
93
94
  "test": "pnpm run prepare:fixtures && vitest",
94
95
  "test:unit": "vitest run --project=unit",
95
96
  "test:e2e": "pnpm run prepare:fixtures && vitest run --project=e2e",
96
- "typecheck": "tsc --noEmit",
97
+ "typecheck": "nuxt typecheck",
97
98
  "test:attw": "attw --pack"
98
99
  }
99
100
  }