nuxt-ai-ready 0.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 (34) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +63 -0
  3. package/dist/module.d.mts +62 -0
  4. package/dist/module.json +12 -0
  5. package/dist/module.mjs +406 -0
  6. package/dist/runtime/nuxt/plugins/prerender.d.ts +2 -0
  7. package/dist/runtime/nuxt/plugins/prerender.js +20 -0
  8. package/dist/runtime/server/logger.d.ts +1 -0
  9. package/dist/runtime/server/logger.js +4 -0
  10. package/dist/runtime/server/mcp/prompts/explain-concept.d.ts +2 -0
  11. package/dist/runtime/server/mcp/prompts/explain-concept.js +62 -0
  12. package/dist/runtime/server/mcp/prompts/find-information.d.ts +2 -0
  13. package/dist/runtime/server/mcp/prompts/find-information.js +57 -0
  14. package/dist/runtime/server/mcp/prompts/search-content.d.ts +2 -0
  15. package/dist/runtime/server/mcp/prompts/search-content.js +58 -0
  16. package/dist/runtime/server/mcp/resources/all-content.d.ts +2 -0
  17. package/dist/runtime/server/mcp/resources/all-content.js +14 -0
  18. package/dist/runtime/server/mcp/resources/pages.d.ts +2 -0
  19. package/dist/runtime/server/mcp/resources/pages.js +23 -0
  20. package/dist/runtime/server/mcp/tools/get-page.d.ts +2 -0
  21. package/dist/runtime/server/mcp/tools/get-page.js +42 -0
  22. package/dist/runtime/server/mcp/tools/list-pages.d.ts +2 -0
  23. package/dist/runtime/server/mcp/tools/list-pages.js +78 -0
  24. package/dist/runtime/server/middleware/mdream.d.ts +2 -0
  25. package/dist/runtime/server/middleware/mdream.js +132 -0
  26. package/dist/runtime/server/routes/llms.txt.get.d.ts +2 -0
  27. package/dist/runtime/server/routes/llms.txt.get.js +23 -0
  28. package/dist/runtime/server/tsconfig.json +3 -0
  29. package/dist/runtime/server/utils/db.d.ts +8 -0
  30. package/dist/runtime/server/utils/db.js +48 -0
  31. package/dist/runtime/types.d.ts +166 -0
  32. package/dist/runtime/types.js +0 -0
  33. package/dist/types.d.mts +12 -0
  34. package/package.json +99 -0
@@ -0,0 +1,166 @@
1
+ import type { H3Event } from 'h3';
2
+ import type { HTMLToMarkdownOptions } from 'mdream';
3
+ export interface ModuleOptions {
4
+ /**
5
+ * Enable/disable module
6
+ * @default true
7
+ */
8
+ enabled?: boolean;
9
+ /**
10
+ * Debug mode
11
+ * @default false
12
+ */
13
+ debug?: boolean;
14
+ /**
15
+ * Bulk data API (JSONL streaming)
16
+ * @default '/_ai-ready/bulk'
17
+ */
18
+ bulkRoute: string | false;
19
+ /**
20
+ * Options to pass to mdream htmlToMarkdown function
21
+ */
22
+ mdreamOptions?: HTMLToMarkdownOptions & {
23
+ /**
24
+ * Preset to apply to the htmlToMarkdown function
25
+ */
26
+ preset?: 'minimal';
27
+ };
28
+ /**
29
+ * Cache configuration
30
+ */
31
+ markdownCacheHeaders?: {
32
+ /**
33
+ * Cache duration in seconds
34
+ * @default 3600 (1 hour)
35
+ */
36
+ maxAge?: number;
37
+ /**
38
+ * Enable stale-while-revalidate
39
+ * @default true
40
+ */
41
+ swr?: boolean;
42
+ };
43
+ /**
44
+ * Structured llms.txt configuration
45
+ */
46
+ llmsTxt?: LlmsTxtConfig;
47
+ }
48
+ /**
49
+ * Individual chunk entry in bulk.jsonl (one per chunk)
50
+ * Consumers can reassemble by route if needed
51
+ */
52
+ export interface BulkChunk {
53
+ id: string;
54
+ route: string;
55
+ chunkIndex: number;
56
+ content: string;
57
+ headers?: Record<string, string>;
58
+ loc?: {
59
+ lines: {
60
+ from: number;
61
+ to: number;
62
+ };
63
+ };
64
+ title: string;
65
+ description: string;
66
+ }
67
+ /**
68
+ * Hook context for markdown processing (Nitro runtime hook)
69
+ *
70
+ * This hook is called during HTML→Markdown conversion in the runtime middleware.
71
+ * You can modify the markdown content before it's returned to the client.
72
+ *
73
+ * @example Modify markdown content
74
+ * nitroApp.hooks.hook('mdream:markdown', async (context) => {
75
+ * // Add a footer to all markdown
76
+ * context.markdown += '\n\n---\n*Generated with mdream*'
77
+ * })
78
+ *
79
+ * @example Track conversions and add headers
80
+ * nitroApp.hooks.hook('mdream:markdown', async (context) => {
81
+ * console.log(`Converted ${context.route} (${context.title})`)
82
+ *
83
+ * // Add custom headers
84
+ * if (context.event) {
85
+ * setHeader(context.event, 'X-Markdown-Title', context.title)
86
+ * }
87
+ * })
88
+ */
89
+ export interface MarkdownContext {
90
+ /** The original HTML content */
91
+ html: string;
92
+ /** The generated markdown content - modify this to change output */
93
+ markdown: string;
94
+ /** The route being processed (e.g., '/about') */
95
+ route: string;
96
+ /** The page title extracted from HTML */
97
+ title: string;
98
+ /** Page description extracted from meta tags or content */
99
+ description: string;
100
+ /** Whether this is during prerendering (true) or runtime (false) */
101
+ isPrerender: boolean;
102
+ /** The H3 event object for accessing request/response */
103
+ event: H3Event;
104
+ }
105
+ /**
106
+ * Link in llms.txt section
107
+ */
108
+ export interface LlmsTxtLink {
109
+ /** The title of the link */
110
+ title: string;
111
+ /** The description of the link */
112
+ description?: string;
113
+ /** The href of the link */
114
+ href: string;
115
+ }
116
+ /**
117
+ * Section in llms.txt
118
+ */
119
+ export interface LlmsTxtSection {
120
+ /** The title of the section */
121
+ title: string;
122
+ /** The description of the section (can be array for multiple paragraphs) */
123
+ description?: string | string[];
124
+ /** The links of the section */
125
+ links?: LlmsTxtLink[];
126
+ }
127
+ /**
128
+ * Structured llms.txt configuration
129
+ */
130
+ export interface LlmsTxtConfig {
131
+ /** The sections of the documentation */
132
+ sections?: LlmsTxtSection[];
133
+ /** Notes section (always appears at the end) */
134
+ notes?: string | string[];
135
+ }
136
+ /**
137
+ * Hook context for chunk processing (Nitro build-time hook)
138
+ *
139
+ * Called during prerender for each generated chunk, allowing modules
140
+ * to implement RAG tooling (e.g., vector embeddings, search indexing)
141
+ *
142
+ * @example Process chunks for vector search
143
+ * nitro.hooks.hook('ai-ready:chunk', async (context) => {
144
+ * const embedding = await generateEmbedding(context.chunk.content)
145
+ * await vectorDb.insert({
146
+ * id: context.chunk.id,
147
+ * embedding,
148
+ * metadata: {
149
+ * route: context.route,
150
+ * title: context.title,
151
+ * }
152
+ * })
153
+ * })
154
+ */
155
+ export interface ChunkContext {
156
+ /** The chunk data that will be written to bulk JSONL */
157
+ chunk: BulkChunk;
158
+ /** The route being processed (e.g., '/about') */
159
+ route: string;
160
+ /** Page title extracted from HTML */
161
+ title: string;
162
+ /** Page description from meta tags */
163
+ description: string;
164
+ /** Headings extracted from the page */
165
+ headings: Array<Record<string, string>>;
166
+ }
File without changes
@@ -0,0 +1,12 @@
1
+ import type { ModuleHooks, ModulePublicRuntimeConfig } from './module.mjs'
2
+
3
+ declare module '@nuxt/schema' {
4
+ interface NuxtHooks extends ModuleHooks {}
5
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
6
+ }
7
+
8
+ export { type BulkChunk, type ModuleOptions } from '../dist/runtime/types.js'
9
+
10
+ export { default } from './module.mjs'
11
+
12
+ export { type ModuleHooks, type ModulePublicRuntimeConfig } from './module.mjs'
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "nuxt-ai-ready",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
+ "author": {
7
+ "name": "Harlan Wilton",
8
+ "email": "harlan@harlanzw.com",
9
+ "url": "https://harlanzw.com/"
10
+ },
11
+ "contributors": [
12
+ "Harlan Wilton <harlan@harlanzw.com>"
13
+ ],
14
+ "license": "MIT",
15
+ "funding": "https://github.com/sponsors/harlan-zw",
16
+ "homepage": "https://nuxtseo.com/ai-ready",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/nuxt-seo-pro/nuxt-ai-ready.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/nuxt-seo-pro/nuxt-ai-ready/issues"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/types.d.mts",
27
+ "import": "./dist/module.mjs"
28
+ }
29
+ },
30
+ "main": "./dist/module.mjs",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "dependencies": {
35
+ "@nuxt/kit": "4.2.1",
36
+ "consola": "^3.4.2",
37
+ "defu": "^6.1.4",
38
+ "mdream": "^0.14.0",
39
+ "minimatch": "^10.1.1",
40
+ "nuxt-site-config": "^3.2.11",
41
+ "pathe": "^2.0.3",
42
+ "pkg-types": "^2.3.0",
43
+ "std-env": "^3.10.0",
44
+ "tokenx": "^1.2.1",
45
+ "ufo": "^1.6.1"
46
+ },
47
+ "devDependencies": {
48
+ "@antfu/eslint-config": "^6.2.0",
49
+ "@arethetypeswrong/cli": "^0.18.2",
50
+ "@headlessui/vue": "^1.7.23",
51
+ "@nuxt/content": "^3.8.2",
52
+ "@nuxt/devtools-ui-kit": "^3.1.1",
53
+ "@nuxt/module-builder": "^1.0.2",
54
+ "@nuxt/test-utils": "^3.20.1",
55
+ "@nuxtjs/color-mode": "^4.0.0",
56
+ "@nuxtjs/eslint-config-typescript": "^12.1.0",
57
+ "@nuxtjs/i18n": "^10.2.1",
58
+ "@nuxtjs/mcp-toolkit": "^0.4.1",
59
+ "@nuxtjs/robots": "^5.6.0",
60
+ "@nuxtjs/sitemap": "^7.4.7",
61
+ "@vitest/coverage-v8": "^4.0.14",
62
+ "@vueuse/nuxt": "^14.1.0",
63
+ "better-sqlite3": "^12.5.0",
64
+ "bumpp": "^10.3.2",
65
+ "eslint": "^9.39.1",
66
+ "execa": "^9.6.1",
67
+ "happy-dom": "^20.0.11",
68
+ "nuxt": "^4.2.1",
69
+ "nuxt-site-config": "^3.2.11",
70
+ "playwright-core": "^1.57.0",
71
+ "postgres": "^3.4.7",
72
+ "typescript": "^5.9.3",
73
+ "vitest": "^4.0.14",
74
+ "vue": "^3.5.25",
75
+ "vue-router": "^4.6.3",
76
+ "vue-tsc": "^3.1.5",
77
+ "zod": "^4.1.13"
78
+ },
79
+ "resolutions": {
80
+ "nuxt-ai-ready": "workspace:*"
81
+ },
82
+ "scripts": {
83
+ "lint": "eslint . --fix",
84
+ "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build",
85
+ "dev": "nuxi dev playground",
86
+ "dev:minimal": "nuxi dev playground",
87
+ "prepare:fixtures": "nuxi prepare playground && nuxi prepare playground && nuxi prepare test/fixtures/basic",
88
+ "dev:build": "nuxi build playground",
89
+ "dev:build:minimal": "nuxi build playground",
90
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && nuxi prepare playground",
91
+ "dev:prepare:minimal": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && nuxi prepare playground",
92
+ "release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\"",
93
+ "test": "pnpm run prepare:fixtures && vitest",
94
+ "test:unit": "vitest run --project=unit",
95
+ "test:e2e": "pnpm run prepare:fixtures && vitest run --project=e2e",
96
+ "typecheck": "tsc --noEmit",
97
+ "test:attw": "attw --pack"
98
+ }
99
+ }