Skip to content

Commit eb31bd9

Browse files
authored
docs: improve agentdocsspec compliance (#451)
* fix(docs): add cache headers for markdown endpoints and llms.txt The agentdocsspec checker flagged missing cache headers on .md and .txt files. Add Cache-Control: public, max-age=300 to match the HTML pages. * fix(docs): move llms.txt directive earlier in page for agent discovery The agentdocsspec checker flagged the llms.txt directive as "buried deep (past 50%)" because the rehype plugin injected it into the Starlight content area, after the header, nav, and sidebar. Move the directive to the Banner component (top of <main>) and add a <link rel="help"> in <head>. Remove the now-unused rehype plugin. * feat(docs): include version in llms.txt title for versioned builds When built with a versioned base path (e.g. /0.2/), the llms.txt title now reads "ICP CLI Documentation (v0.2)" instead of the generic title. * feat(docs): add IC skills registry link to llms.txt Point agents to the skills discovery endpoint so they can find and install specialized IC development skills (icp-cli, canister security, ICRC ledger, etc.) alongside the documentation.
1 parent 459f6d9 commit eb31bd9

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

docs-site/.ic-assets.json5

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
"Cache-Control": "public, max-age=300"
2121
}
2222
},
23+
{
24+
// Markdown endpoints and llms.txt — short cache so updates are visible quickly
25+
"match": "**/*.{md,txt}",
26+
"headers": {
27+
"Cache-Control": "public, max-age=300"
28+
}
29+
},
2330
{
2431
// Version list — very short cache so version switcher sees updates quickly
2532
"match": "versions.json",

docs-site/astro.config.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { defineConfig } from 'astro/config';
22
import starlight from '@astrojs/starlight';
33
import rehypeExternalLinks from 'rehype-external-links';
44
import rehypeRewriteLinks from './plugins/rehype-rewrite-links.mjs';
5-
import rehypeAgentSignaling from './plugins/rehype-agent-signaling.mjs';
65
import agentDocs from './plugins/astro-agent-docs.mjs';
76

87
// https://astro.build/config
@@ -17,8 +16,6 @@ export default defineConfig({
1716
rehypeRewriteLinks,
1817
// Open external links in new tab
1918
[rehypeExternalLinks, { target: '_blank', rel: ['noopener', 'noreferrer'] }],
20-
// Inject hidden llms.txt directive for agent discovery
21-
rehypeAgentSignaling,
2219
],
2320
},
2421
integrations: [
@@ -33,6 +30,17 @@ export default defineConfig({
3330
Banner: './src/components/Banner.astro',
3431
},
3532
head: [
33+
{
34+
// Agent-friendly docs: surface llms.txt directive early in <head>
35+
// so crawlers find it before the content area (agentdocsspec.com)
36+
tag: 'link',
37+
attrs: {
38+
rel: 'help',
39+
href: `${process.env.PUBLIC_BASE_PATH || '/'}llms.txt`,
40+
type: 'text/plain',
41+
title: 'LLM-friendly documentation index',
42+
},
43+
},
3644
{
3745
tag: 'script',
3846
attrs: {},

docs-site/plugins/astro-agent-docs.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,19 @@ function findSection(filePath) {
6666
function generateLlmsTxt(pages, siteUrl, basePath) {
6767
const base = (siteUrl + basePath).replace(/\/$/, "");
6868

69+
// Extract version from base path (e.g., "/0.2/" → "0.2", "/main/" → "main")
70+
const version = basePath.replace(/^\/|\/$/g, "") || null;
71+
const title = version
72+
? `# ICP CLI Documentation (v${version})`
73+
: "# ICP CLI Documentation";
74+
6975
const lines = [
70-
"# ICP CLI Documentation",
76+
title,
7177
"",
7278
"> Command-line tool for developing and deploying applications on the Internet Computer Protocol (ICP).",
7379
"",
80+
"Agent skills for IC development: https://skills.internetcomputer.org/.well-known/skills/index.json",
81+
"",
7482
];
7583

7684
// Root index page

docs-site/plugins/rehype-agent-signaling.mjs

Lines changed: 0 additions & 38 deletions
This file was deleted.

docs-site/src/components/Banner.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
// Overrides Starlight's default Banner component so we don't need
44
// banner frontmatter in each file.
55
const content = 'Feedback welcome! Report issues on <a href="https://github.com/dfinity/icp-cli/issues" target="_blank" rel="noopener noreferrer">GitHub</a>, ask questions on the <a href="https://forum.dfinity.org/t/icp-cli-announcements-and-feedback-discussion/60410/1" target="_blank" rel="noopener noreferrer">Forum</a>, or chat with us on <a href="https://discord.internetcomputer.org" target="_blank" rel="noopener noreferrer">Discord</a>.';
6+
const llmsTxtPath = `${import.meta.env.BASE_URL}llms.txt`;
67
---
78

9+
<blockquote class="agent-signaling" data-pagefind-ignore>
10+
<p>For AI agents: Documentation index at <a href={llmsTxtPath}>{llmsTxtPath}</a></p>
11+
</blockquote>
812
<div class="sl-banner" data-pagefind-ignore set:html={content} />
913

1014
<style>

0 commit comments

Comments
 (0)