Skip to content

Commit 37efee4

Browse files
feat: AI skills indexes
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
1 parent ceb3cf3 commit 37efee4

4 files changed

Lines changed: 115 additions & 0 deletions

File tree

.github/workflows/update-ai.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Update AI indexes
2+
3+
on:
4+
schedule:
5+
- cron: "30 8 1 * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update-subnets:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Prepare
20+
uses: ./.github/actions/prepare
21+
22+
- name: Update
23+
run: npm run docs:ai
24+
25+
- name: Check for Changes
26+
run: |
27+
if ! git diff --quiet; then
28+
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
29+
fi
30+
31+
# This action creates a PR only if there are changes.
32+
- name: Create Pull Request
33+
if: env.CHANGES_DETECTED == 'true'
34+
uses: ./.github/actions/create-pr
35+
with:
36+
branch: bot-cli-docs-update
37+
title: "docs: Update AI indexes"
38+
body: |
39+
Modifications have been made to the AI skills.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"dev": "npm run start",
1717
"start": "docusaurus start",
1818
"build": "docusaurus build",
19+
"docs:ai": "./scripts/ai.mjs && npm run format",
1920
"docs:cli": "scripts/cli-to-md.sh",
2021
"docs:subnets": "./scripts/subnets.mjs && npm run format",
2122
"swizzle": "docusaurus swizzle",

scripts/ai.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env node
2+
3+
import { mkdir, writeFile } from "node:fs/promises";
4+
import { join } from "node:path";
5+
6+
// Generate /.well-known/agent-skills/index.json for AI discovery as defined by Cloudflare
7+
// @see https://github.com/cloudflare/agent-skills-discovery-rfc
8+
// @see https://isitagentready.com/.well-known/agent-skills/agent-skills/SKILL.md
9+
// test: https://isitagentready.com/juno.build
10+
11+
const TEMPLATE_SKILL_WITHOUT_DIGEST = {
12+
name: "juno",
13+
type: "skill-md",
14+
description:
15+
"Up-to-date knowledge about Juno's CLI, SDK, and serverless functions for AI coding agents.",
16+
url: "https://raw.githubusercontent.com/junobuild/skills/main/SKILL.md"
17+
};
18+
19+
const TEMPLATE = {
20+
$schema: "https://schemas.agentskills.io/discovery/0.2.0/schema.json",
21+
skills: []
22+
};
23+
24+
const OUTPUT_DIR = join("static", ".well-known", "agent-skills");
25+
const OUTPUT_FILE_PATH = join(OUTPUT_DIR, "index.json");
26+
27+
await mkdir(OUTPUT_DIR, { recursive: true });
28+
29+
const computeSkillSha256 = async () => {
30+
const response = await fetch(
31+
"https://raw.githubusercontent.com/junobuild/skills/main/SKILL.md"
32+
);
33+
34+
if (!response.ok) {
35+
throw new Error("Fetching the current SKILL.md failed!");
36+
}
37+
38+
const md = await response.text();
39+
40+
const encoder = new TextEncoder();
41+
const hash = await crypto.subtle.digest("SHA-256", encoder.encode(md));
42+
43+
const sha256ToHex = (hashBuffer) => {
44+
const hashArray = Array.from(new Uint8Array(hashBuffer));
45+
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
46+
};
47+
48+
return sha256ToHex(hash);
49+
};
50+
51+
const sha256 = await computeSkillSha256();
52+
53+
const skill = {
54+
...TEMPLATE_SKILL_WITHOUT_DIGEST,
55+
digest: `sha256:${sha256}`
56+
};
57+
58+
const json = {
59+
...TEMPLATE,
60+
skills: [skill]
61+
};
62+
63+
await writeFile(OUTPUT_FILE_PATH, JSON.stringify(json, null, 2), "utf8");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://schemas.agentskills.io/discovery/0.2.0/schema.json",
3+
"skills": [
4+
{
5+
"name": "juno",
6+
"type": "skill-md",
7+
"description": "Up-to-date knowledge about Juno's CLI, SDK, and serverless functions for AI coding agents.",
8+
"url": "https://raw.githubusercontent.com/junobuild/skills/main/SKILL.md",
9+
"digest": "sha256:18b7fec3e46664b67bdf5bd66f4f36fd9fca138a8749ddc2638f61fed4c23483"
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)