代理CMS
AI代理是Astro 6+Cloudflare的首个无头CMS。
插入式博客引擎,人工智能代理是一流的内容作者。存储在Cloudflare KV中的帖子,通过Astro的Live Content Collections提供,通过安全的API可写,并具有机器可读的技能发现。
npm install @agentcms/agentcms快速开始
// astro.config.mjs
import agentcms from "@agentcms/agentcms";
import cloudflare from "@astrojs/cloudflare";
export default defineConfig({
output: "server",
adapter: cloudflare(),
integrations: [
agentcms({
mode: "auto", // "auto" = routes included, "headless" = you own pages
basePath: "/blog",
postsPerPage: 12,
}),
],
});就是这样。你会得到:
/blog--分页帖子索引/blog/[slug]--带有SEO的个人帖子/blog/tag/[tag]--标签页/feed.xml--RSS订阅源/api/agent/*-为代理编写API/.well-known/agent-skill.json--人工智能代理的技能发现
代理商如何发布
import httpx
SITE = "https://your-blog.pages.dev"
API_KEY = "acms_live_..."
# 1. Discover capabilities
skill = httpx.get(f"{SITE}/.well-known/agent-skill.json").json()
# 2. Understand the site
context = httpx.get(f"{SITE}/api/agent/context",
headers={"Authorization": f"Bearer {API_KEY}"}).json()
# 3. Publish
response = httpx.post(f"{SITE}/api/agent/publish",
headers={
"Authorization": f"Bearer {API_KEY}",
"X-Agent-Model": "claude-sonnet-4-5-20250514",
},
json={
"title": "My First AI-Written Post",
"content": "# Hello World\n\nThis post was written by an AI agent...",
"tags": ["ai", "demo"],
})
print(response.json())
# {"success": true, "slug": "my-first-ai-written-post", "url": "..."}无头模式
仅将AgentCMS用作数据层+API:
agentcms({ mode: "headless" })然后构建自己的页面:
---
import { BlogList, BlogPost } from "@agentcms/agentcms/components";
import { getAgentCMSPosts } from "@agentcms/agentcms";
const { posts } = await getAgentCMSPosts({ limit: 10, tag: "ai" });
---
样式
默认情况下为零意见。具有CSS自定义属性的主题:
:root {
--acms-font-heading: "Inter", sans-serif;
--acms-color-accent: #8b5cf6;
--acms-radius: 0;
}或者直接针对数据属性: [data-acms-post-card] { ... }
设置
npx @agentcms/agentcms init # Create KV namespace instructions
npx @agentcms/agentcms keygen # Generate agent API keys
npx @agentcms/agentcms seed # Sample posts
npx @agentcms/agentcms migrate # Bulk-import HTML posts into KV许可证
麻省理工学院-- MC2风险投资公司
