@adkinn/astro-ai-readiness 0.0.7
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/LICENSE +21 -0
- package/README.md +285 -0
- package/dist/chunk-36CGBNB5.js +104 -0
- package/dist/chunk-BDGAXJOB.js +42 -0
- package/dist/chunk-CADNETPK.js +48 -0
- package/dist/chunk-CO2DB4IE.js +141 -0
- package/dist/chunk-THSVWYUX.js +42 -0
- package/dist/chunk-V22PCH7G.js +26 -0
- package/dist/chunk-WP6D4L7O.js +48 -0
- package/dist/components/BreadcrumbSchema.astro +22 -0
- package/dist/components/CollectionSchema.astro +24 -0
- package/dist/components/FAQPageSchema.astro +24 -0
- package/dist/components/OrganizationSchema.astro +33 -0
- package/dist/components/TechArticleSchema.astro +88 -0
- package/dist/components/WebSiteSchema.astro +16 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +15 -0
- package/dist/components/types.d.ts +55 -0
- package/dist/components/types.js +0 -0
- package/dist/config.d.ts +1044 -0
- package/dist/config.js +6 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +103 -0
- package/dist/outputs/agents-md.d.ts +19 -0
- package/dist/outputs/agents-md.js +9 -0
- package/dist/outputs/llms-full.d.ts +18 -0
- package/dist/outputs/llms-full.js +9 -0
- package/dist/outputs/llms-txt.d.ts +19 -0
- package/dist/outputs/llms-txt.js +9 -0
- package/dist/outputs/mcp-json.d.ts +21 -0
- package/dist/outputs/mcp-json.js +9 -0
- package/dist/outputs/robots-txt.d.ts +20 -0
- package/dist/outputs/robots-txt.js +9 -0
- package/dist/utils/json-ld.d.ts +26 -0
- package/dist/utils/json-ld.js +7 -0
- package/package.json +76 -0
- package/schemas/mcp/v1.json +63 -0
package/dist/config.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AstroIntegration } from 'astro';
|
|
2
|
+
import { AiReadinessConfig } from './config.js';
|
|
3
|
+
export { AgentsMdConfig, FounderConfig, LlmsFullConfig, LlmsTxtConfig, McpConfig, OrganizationConfig, RobotsTxtConfig, WebSiteConfig } from './config.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
declare function aiReadiness(options: AiReadinessConfig): AstroIntegration;
|
|
7
|
+
|
|
8
|
+
export { AiReadinessConfig, aiReadiness as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeMcpJson
|
|
3
|
+
} from "./chunk-BDGAXJOB.js";
|
|
4
|
+
import {
|
|
5
|
+
writeRobotsTxt
|
|
6
|
+
} from "./chunk-36CGBNB5.js";
|
|
7
|
+
import {
|
|
8
|
+
aiReadinessConfigSchema
|
|
9
|
+
} from "./chunk-CO2DB4IE.js";
|
|
10
|
+
import {
|
|
11
|
+
writeLlmsTxt
|
|
12
|
+
} from "./chunk-WP6D4L7O.js";
|
|
13
|
+
import {
|
|
14
|
+
writeLlmsFullTxt
|
|
15
|
+
} from "./chunk-THSVWYUX.js";
|
|
16
|
+
import {
|
|
17
|
+
writeAgentsMd
|
|
18
|
+
} from "./chunk-CADNETPK.js";
|
|
19
|
+
import "./chunk-V22PCH7G.js";
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
import { ZodError } from "zod";
|
|
23
|
+
var VIRTUAL_ID = "virtual:ai-readiness-config";
|
|
24
|
+
var RESOLVED_VIRTUAL_ID = "\0" + VIRTUAL_ID;
|
|
25
|
+
function parseConfigOrThrow(options) {
|
|
26
|
+
try {
|
|
27
|
+
return aiReadinessConfigSchema.parse(options);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (err instanceof ZodError) {
|
|
30
|
+
const lines = err.issues.map((issue) => {
|
|
31
|
+
const path = issue.path.length > 0 ? issue.path.join(".") : "<root>";
|
|
32
|
+
return ` \u2022 ${path}: ${issue.message}`;
|
|
33
|
+
});
|
|
34
|
+
throw new Error(
|
|
35
|
+
`aiReadiness: invalid config in aiReadiness({...}):
|
|
36
|
+
${lines.join("\n")}`,
|
|
37
|
+
{ cause: err }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function aiReadiness(options) {
|
|
44
|
+
const config = parseConfigOrThrow(options);
|
|
45
|
+
const serialized = JSON.stringify(config);
|
|
46
|
+
return {
|
|
47
|
+
name: "@adkinn/astro-ai-readiness",
|
|
48
|
+
hooks: {
|
|
49
|
+
"astro:config:setup": ({ updateConfig, logger, config: astroConfig }) => {
|
|
50
|
+
updateConfig({
|
|
51
|
+
vite: {
|
|
52
|
+
plugins: [
|
|
53
|
+
{
|
|
54
|
+
name: "ai-readiness-virtual-config",
|
|
55
|
+
resolveId(id) {
|
|
56
|
+
if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID;
|
|
57
|
+
return null;
|
|
58
|
+
},
|
|
59
|
+
load(id) {
|
|
60
|
+
if (id === RESOLVED_VIRTUAL_ID) {
|
|
61
|
+
return `export const config = ${serialized}
|
|
62
|
+
export default config
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const hasSitemap = astroConfig.integrations.some(
|
|
72
|
+
(i) => i.name === "@astrojs/sitemap"
|
|
73
|
+
);
|
|
74
|
+
if (!hasSitemap) {
|
|
75
|
+
logger.warn(
|
|
76
|
+
"@astrojs/sitemap not detected. Install it (`npm install @astrojs/sitemap`) so AI agents can discover your sitemap.xml \u2014 sitemap is an AI Readiness baseline (per D-8). See https://docs.astro.build/en/guides/integrations-guide/sitemap/"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
logger.info("aiReadiness integration registered");
|
|
80
|
+
},
|
|
81
|
+
"astro:build:done": async ({ dir, logger }) => {
|
|
82
|
+
if (config.llmsTxt) {
|
|
83
|
+
await writeLlmsTxt(config, dir, logger);
|
|
84
|
+
}
|
|
85
|
+
if (config.llmsFull) {
|
|
86
|
+
await writeLlmsFullTxt(config, dir, logger);
|
|
87
|
+
}
|
|
88
|
+
if (config.agentsMd) {
|
|
89
|
+
await writeAgentsMd(config, dir, logger);
|
|
90
|
+
}
|
|
91
|
+
if (config.mcp) {
|
|
92
|
+
await writeMcpJson(config, dir, logger);
|
|
93
|
+
}
|
|
94
|
+
if (config.robotsTxt) {
|
|
95
|
+
await writeRobotsTxt(config, dir, logger);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
aiReadiness as default
|
|
103
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AiReadinessConfig, AgentsMdConfig } from '../config.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pure composer — returns the agents.md content string. Testable without filesystem.
|
|
6
|
+
* Format: H1 (org name) / blockquote summary / fixed H2 sections.
|
|
7
|
+
*
|
|
8
|
+
* Like llms.txt, agents.md string fields are emitted as raw markdown — consumers
|
|
9
|
+
* responsible for escaping their own punctuation when shipping user-generated content.
|
|
10
|
+
*/
|
|
11
|
+
declare function composeAgentsMd(config: AiReadinessConfig & {
|
|
12
|
+
agentsMd: AgentsMdConfig;
|
|
13
|
+
}): string;
|
|
14
|
+
declare function writeAgentsMd(config: AiReadinessConfig, dir: URL, logger: {
|
|
15
|
+
info: (msg: string) => void;
|
|
16
|
+
warn: (msg: string) => void;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
|
|
19
|
+
export { composeAgentsMd, writeAgentsMd };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AiReadinessConfig, LlmsFullConfig } from '../config.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pure composer for llms-full.txt.
|
|
6
|
+
*
|
|
7
|
+
* This is intentionally config-driven for v0.0.7. Content-collection
|
|
8
|
+
* introspection can layer on later without reintroducing inert config.
|
|
9
|
+
*/
|
|
10
|
+
declare function composeLlmsFullTxt(config: AiReadinessConfig & {
|
|
11
|
+
llmsFull: LlmsFullConfig;
|
|
12
|
+
}): string;
|
|
13
|
+
declare function writeLlmsFullTxt(config: AiReadinessConfig, dir: URL, logger: {
|
|
14
|
+
info: (msg: string) => void;
|
|
15
|
+
warn: (msg: string) => void;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
|
|
18
|
+
export { composeLlmsFullTxt, writeLlmsFullTxt };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AiReadinessConfig, LlmsTxtConfig } from '../config.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pure composer — returns the llms.txt content string. Testable without filesystem.
|
|
6
|
+
*
|
|
7
|
+
* Format follows llmstxt.org: H1 / blockquote / free-form markdown body /
|
|
8
|
+
* H2 sections with bulleted links / optional defer-to footer. No sitemap section
|
|
9
|
+
* per the matrix — sitemap reference lives in robots.txt (Plan 12).
|
|
10
|
+
*/
|
|
11
|
+
declare function composeLlmsTxt(config: AiReadinessConfig & {
|
|
12
|
+
llmsTxt: LlmsTxtConfig;
|
|
13
|
+
}): string;
|
|
14
|
+
declare function writeLlmsTxt(config: AiReadinessConfig, dir: URL, logger: {
|
|
15
|
+
info: (msg: string) => void;
|
|
16
|
+
warn: (msg: string) => void;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
|
|
19
|
+
export { composeLlmsTxt, writeLlmsTxt };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AiReadinessConfig, McpConfig } from '../config.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pure composer — returns the mcp.json content string. Testable without filesystem.
|
|
6
|
+
* Pretty-printed (2-space indent) + single trailing newline (POSIX).
|
|
7
|
+
*/
|
|
8
|
+
declare function composeMcpJson(config: AiReadinessConfig & {
|
|
9
|
+
mcp: McpConfig;
|
|
10
|
+
}): string;
|
|
11
|
+
/**
|
|
12
|
+
* Filesystem writer — composes content + writes to dist/.well-known/mcp.json.
|
|
13
|
+
* Creates the .well-known/ subdirectory first (idempotent via { recursive: true }).
|
|
14
|
+
* Skips (and warns) if the consumer already ships the file. See writeOutput.
|
|
15
|
+
*/
|
|
16
|
+
declare function writeMcpJson(config: AiReadinessConfig, dir: URL, logger: {
|
|
17
|
+
info: (msg: string) => void;
|
|
18
|
+
warn: (msg: string) => void;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
|
|
21
|
+
export { composeMcpJson, writeMcpJson };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AiReadinessConfig, RobotsTxtConfig } from '../config.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pure composer for robots.txt.
|
|
6
|
+
*
|
|
7
|
+
* Presets are intentionally conservative: `training-opt-out` keeps ordinary
|
|
8
|
+
* search discovery open and opts out of common model-training tokens. Some
|
|
9
|
+
* vendors bundle training and grounding under one token, so consumers can
|
|
10
|
+
* override the rules when answer-engine inclusion matters more than opt-out.
|
|
11
|
+
*/
|
|
12
|
+
declare function composeRobotsTxt(config: AiReadinessConfig & {
|
|
13
|
+
robotsTxt: RobotsTxtConfig;
|
|
14
|
+
}): string;
|
|
15
|
+
declare function writeRobotsTxt(config: AiReadinessConfig, dir: URL, logger: {
|
|
16
|
+
info: (msg: string) => void;
|
|
17
|
+
warn: (msg: string) => void;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
|
|
20
|
+
export { composeRobotsTxt, writeRobotsTxt };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize a JSON-LD payload for safe embedding inside an inline
|
|
3
|
+
* `<script type="application/ld+json">` block.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
* Used by the toolkit's components via relative import (`../utils/json-ld`)
|
|
7
|
+
* from `dist/components/*.astro`. Not part of the public API; intentionally
|
|
8
|
+
* excluded from `package.json.exports`. The file ships as a build artifact
|
|
9
|
+
* so the relative-import resolution works at consumer build time, but no
|
|
10
|
+
* subpath like `@adkinn/astro-ai-readiness/utils/json-ld` is exposed.
|
|
11
|
+
* If you find yourself wanting to import this directly, file an issue —
|
|
12
|
+
* we'll consider promoting it to a public subpath.
|
|
13
|
+
*
|
|
14
|
+
* Three escapes:
|
|
15
|
+
* - `<` -> `\u003c` so a literal `</script>` in any string cannot break
|
|
16
|
+
* the host HTML parser (XSS / parser confusion vector).
|
|
17
|
+
* - U+2028 line separator and U+2029 paragraph separator: legal in JSON
|
|
18
|
+
* strings but illegal in pre-ES2019 JS string literals; consumer
|
|
19
|
+
* toolchains vary. Cheap insurance.
|
|
20
|
+
*
|
|
21
|
+
* The escaped form is canonical JSON-LD; validator.schema.org and every
|
|
22
|
+
* search-engine consumer decode the escapes transparently.
|
|
23
|
+
*/
|
|
24
|
+
declare function jsonLd(obj: Record<string, unknown>): string;
|
|
25
|
+
|
|
26
|
+
export { jsonLd };
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adkinn/astro-ai-readiness",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"description": "AI Readiness toolkit for Astro — six JSON-LD components plus llms.txt, llms-full.txt, agents.md, robots.txt, and .well-known/mcp.json outputs.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./components": {
|
|
14
|
+
"types": "./dist/components/index.d.ts",
|
|
15
|
+
"import": "./dist/components/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"schemas",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup && cp src/components/*.astro dist/components/",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
28
|
+
"lint": "npm run typecheck && npm run build && node scripts/lint-package.mjs"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"zod": "^3.23.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.6.0",
|
|
35
|
+
"astro": "^6.1.9",
|
|
36
|
+
"tsup": "^8.3.0",
|
|
37
|
+
"typescript": "^5.6.0"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"ai-readiness",
|
|
41
|
+
"aeo",
|
|
42
|
+
"agent-readable",
|
|
43
|
+
"llms-txt",
|
|
44
|
+
"llms-full-txt",
|
|
45
|
+
"agents-md",
|
|
46
|
+
"mcp",
|
|
47
|
+
"robots-txt",
|
|
48
|
+
"schema-org",
|
|
49
|
+
"json-ld",
|
|
50
|
+
"astro-integration",
|
|
51
|
+
"astro-component",
|
|
52
|
+
"withastro"
|
|
53
|
+
],
|
|
54
|
+
"author": {
|
|
55
|
+
"name": "Adam Kinney",
|
|
56
|
+
"url": "https://adamkinney.com"
|
|
57
|
+
},
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+https://github.com/adkinn/astro-ai-readiness.git"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/adkinn/astro-ai-readiness#readme",
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/adkinn/astro-ai-readiness/issues"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"astro": "^5.0.0 || ^6.0.0"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=22.12.0"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/adkinn/astro-ai-readiness/v0.0.7/schemas/mcp/v1.json",
|
|
4
|
+
"title": "astro-ai-readiness MCP Discovery v1",
|
|
5
|
+
"description": "Discovery file shape emitted by @adkinn/astro-ai-readiness for /.well-known/mcp.json. Per D-22, includes a toolkit-specific status: 'active' | 'planned' field gating tools (active) vs planned_tools (planned).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["version", "servers"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": { "type": "string", "format": "uri" },
|
|
11
|
+
"version": { "type": "string" },
|
|
12
|
+
"servers": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"minItems": 1,
|
|
15
|
+
"items": {
|
|
16
|
+
"oneOf": [
|
|
17
|
+
{
|
|
18
|
+
"type": "object",
|
|
19
|
+
"required": ["status", "name", "url", "description", "tools"],
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"status": { "const": "active" },
|
|
23
|
+
"name": { "type": "string", "minLength": 1 },
|
|
24
|
+
"url": { "type": "string", "format": "uri" },
|
|
25
|
+
"description": { "type": "string", "minLength": 1 },
|
|
26
|
+
"tools": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"minItems": 1,
|
|
29
|
+
"items": { "$ref": "#/definitions/tool" }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "object",
|
|
35
|
+
"required": ["status", "name", "description", "planned_tools"],
|
|
36
|
+
"additionalProperties": false,
|
|
37
|
+
"properties": {
|
|
38
|
+
"status": { "const": "planned" },
|
|
39
|
+
"name": { "type": "string", "minLength": 1 },
|
|
40
|
+
"description": { "type": "string", "minLength": 1 },
|
|
41
|
+
"planned_tools": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"minItems": 1,
|
|
44
|
+
"items": { "$ref": "#/definitions/tool" }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"definitions": {
|
|
53
|
+
"tool": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"required": ["name", "description"],
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"properties": {
|
|
58
|
+
"name": { "type": "string", "minLength": 1 },
|
|
59
|
+
"description": { "type": "string", "minLength": 1 }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|