Skip to content

Commit c4fa771

Browse files
committed
Inject update instructions into SKILL.md at zip-packaging time
Appends a standard "Updating this skill" section to SKILL.md inside each zip (both individual and fat), pointing agents to .version for the registry URL and commit to compare. Source files are not modified. This lets an agent with the skill installed know how to check for and apply updates on a cold start, without any prior context.
1 parent 8ebd50d commit c4fa771

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

.github/scripts/build_site.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ def parse_frontmatter(path: Path) -> tuple[str, str]:
5050
return name, desc
5151

5252

53+
UPDATE_SECTION = """
54+
## Updating this skill
55+
56+
This skill was installed from the OGC LLM Skills registry. To check for
57+
updates, read `.version` in this directory — it contains `commit`, `date`,
58+
`zip_url`, and `llms_txt`. Compare `commit` against the registry manifest
59+
and follow the update instructions at the `llms_txt` URL.
60+
"""
61+
5362
skills = []
5463
repo_root = Path(".")
5564
# Collect (skill_dir, zip_stem, files) for the fat zip
@@ -74,21 +83,30 @@ def parse_frontmatter(path: Path) -> tuple[str, str]:
7483

7584
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
7685
for f in skill_files:
77-
zf.write(f, f.relative_to(skill_dir))
86+
if f == skill_md:
87+
zf.writestr(str(f.relative_to(skill_dir)),
88+
f.read_text(encoding="utf-8") + UPDATE_SECTION)
89+
else:
90+
zf.write(f, f.relative_to(skill_dir))
7891
zf.writestr(".version", json.dumps(version_obj, indent=2))
7992

8093
name, desc = parse_frontmatter(skill_md)
8194
skills.append({"name": name, "description": desc, "zip": zip_name,
8295
"commit": commit, "date": date})
83-
all_skill_entries.append((zip_stem, skill_dir, skill_files, version_obj))
96+
all_skill_entries.append((zip_stem, skill_dir, skill_md, skill_files, version_obj))
8497
print(f" packaged: {zip_name} ({name})")
8598

8699
# Fat zip: all skills with their zip-stem as the directory prefix
87100
fat_zip_name = "all-skills.zip"
88101
with zipfile.ZipFile(out_dir / fat_zip_name, "w", zipfile.ZIP_DEFLATED) as zf:
89-
for zip_stem, skill_dir, skill_files, version_obj in all_skill_entries:
102+
for zip_stem, skill_dir, skill_md, skill_files, version_obj in all_skill_entries:
90103
for f in skill_files:
91-
zf.write(f, Path(zip_stem) / f.relative_to(skill_dir))
104+
arc_path = Path(zip_stem) / f.relative_to(skill_dir)
105+
if f == skill_md:
106+
zf.writestr(str(arc_path),
107+
f.read_text(encoding="utf-8") + UPDATE_SECTION)
108+
else:
109+
zf.write(f, arc_path)
92110
zf.writestr(str(Path(zip_stem) / ".version"), json.dumps(version_obj, indent=2))
93111
print(f" packaged: {fat_zip_name} (all skills)")
94112

0 commit comments

Comments
 (0)