|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""Build all distributable bundles into bundles/. |
| 3 | +
|
| 4 | +One canonical Agent Skills zip covers Claude Code, Claude web, Cursor, |
| 5 | +Copilot, OpenCode, Codex, Gemini Skills, and Agensi (all consume a |
| 6 | +SKILL.md folder). ChatGPT Custom GPTs and Gemini Gems have no ZIP import, |
| 7 | +so this also builds paste-ready GPT/Gem packs (instructions + knowledge |
| 8 | ++ import README). |
| 9 | +
|
| 10 | +Output (all in bundles/): |
| 11 | + expert-mentor-skill.zip canonical skill (upload/extract anywhere) |
| 12 | + expert-mentor-agensi.zip same + docs/agensi-listing.md as LISTING.md |
| 13 | + chatgpt-gpt-pack.zip paste into GPT Builder |
| 14 | + gemini-gem-pack.zip paste into Gems -> New Gem |
| 15 | + INSTALL.md where each zip goes per provider |
| 16 | +
|
| 17 | +Stdlib only. Python 3.8+. |
| 18 | +""" |
| 19 | +from __future__ import annotations |
| 20 | + |
| 21 | +import json |
| 22 | +import sys |
| 23 | +import zipfile |
| 24 | +from pathlib import Path |
| 25 | + |
| 26 | +ROOT = Path(__file__).resolve().parent.parent |
| 27 | +OUT_DIR = ROOT / "bundles" |
| 28 | +SKILL_NAME = "expert-mentor" |
| 29 | + |
| 30 | +sys.path.insert(0, str(Path(__file__).resolve().parent)) |
| 31 | +import build_skill_zip # reuse canonical member list |
| 32 | + |
| 33 | + |
| 34 | +def skill_members(): |
| 35 | + for p in build_skill_zip.iter_members(): |
| 36 | + # maintainer-only builders never ship inside the skill |
| 37 | + if p.name in {"build_skill_zip.py", "build_bundles.py"}: |
| 38 | + continue |
| 39 | + yield p |
| 40 | + |
| 41 | + |
| 42 | +def write_zip(out_path: Path, members, extra=None) -> int: |
| 43 | + with zipfile.ZipFile(out_path, "w", zipfile.ZIP_DEFLATED) as zf: |
| 44 | + for p in members: |
| 45 | + arcname = SKILL_NAME + "/" + p.relative_to(ROOT).as_posix() |
| 46 | + zf.write(p, arcname) |
| 47 | + for arcname, text in (extra or {}).items(): |
| 48 | + zf.writestr(SKILL_NAME + "/" + arcname, text) |
| 49 | + return len(zipfile.ZipFile(out_path).namelist()) |
| 50 | + |
| 51 | + |
| 52 | +def load_prompt_body() -> str: |
| 53 | + """Master prompt minus the maintainer preamble.""" |
| 54 | + text = (ROOT / "templates" / "mentor_system_prompt.md").read_text(encoding="utf-8") |
| 55 | + marker = "SYSTEM PROMPT" |
| 56 | + if marker in text: |
| 57 | + text = text.split(marker, 1)[1].lstrip("=\n- ") |
| 58 | + return text.strip() + "\n" |
| 59 | + |
| 60 | + |
| 61 | +GENERIC_SLOTS = { |
| 62 | + "{{MENTOR_NAME}}": "Expert Mentor", |
| 63 | + "{{FIELD}}": "subject", |
| 64 | + "{{LEVEL}}": "inferred from the conversation (beginner/intermediate/advanced/expert)", |
| 65 | + "{{LEARNER_CONTEXT}}": "ask during intake; if absent, establish it with 2-3 questions", |
| 66 | + "{{SESSION_GOAL}}": "ask during intake; default: durable, practical competence", |
| 67 | + "{{LANGUAGE}}": "the language the learner writes in", |
| 68 | + "{{TEACHING_STYLE}}": "Socratic by default; adapt if the learner asks for direct/coaching/immersive", |
| 69 | + "{{LEARNER_HISTORY}}": "(no history yet - build mastered/shaky/misconceptions lists as you go)", |
| 70 | + "{{FIELD_NOTES}}": "(no field profile loaded - teach to senior-practitioner standard)", |
| 71 | + "{{TONE}}": "warm, direct, encouraging", |
| 72 | + "{{LENGTH_RULE}}": "concise: one concept per reply, concrete example first", |
| 73 | +} |
| 74 | + |
| 75 | +CHATGPT_CAPABILITY = ( |
| 76 | + "You teach whatever field the learner asks about; wherever the prompt says " |
| 77 | + "subject, substitute the real field everywhere. " |
| 78 | + "You are running as a ChatGPT Custom GPT. Use clear markdown structure " |
| 79 | + "(headings, short lists). End each teaching reply with one retrieval question " |
| 80 | + "or small exercise and an explicit next step. Never fabricate sources, " |
| 81 | + "formulas, or APIs - say you are unsure and how to verify." |
| 82 | +) |
| 83 | + |
| 84 | +GEMINI_CAPABILITY = ( |
| 85 | + "You teach whatever field the learner asks about; wherever the prompt says " |
| 86 | + "subject, substitute the real field everywhere. " |
| 87 | + "You are running as a Gemini Gem. Use clear markdown structure. Keep replies " |
| 88 | + "focused: one concept at a time, one worked example, then one check question. " |
| 89 | + "Never fabricate sources, formulas, or APIs - say you are unsure and how to verify." |
| 90 | +) |
| 91 | + |
| 92 | + |
| 93 | +def render_instructions(capability: str) -> str: |
| 94 | + body = load_prompt_body() |
| 95 | + for slot, value in GENERIC_SLOTS.items(): |
| 96 | + body = body.replace(slot, value) |
| 97 | + body = body.replace("{{CAPABILITY_NOTES}}", capability) |
| 98 | + return body |
| 99 | + |
| 100 | + |
| 101 | +STARTERS = [ |
| 102 | + "Teach me quantum computing (I am a beginner)", |
| 103 | + "Be my Rust mentor - test my level first", |
| 104 | + "Explain macroeconomics like a professor", |
| 105 | + "Design me a 6-week study plan for contract law", |
| 106 | +] |
| 107 | + |
| 108 | +GPT_README = """# ChatGPT GPT pack - expert-mentor |
| 109 | +
|
| 110 | +Custom GPTs have no ZIP import. Create the GPT by pasting: |
| 111 | +
|
| 112 | +1. Go to ChatGPT -> Explore GPTs -> Create (requires an account that can create GPTs; |
| 113 | + on some plans GPT creation is restricted - see OpenAI help). |
| 114 | +2. Name: `Expert Mentor` |
| 115 | +3. Description: paste `description` from `gpt-config.json`. |
| 116 | +4. Instructions: paste the full contents of `instructions.md`. |
| 117 | +5. Conversation starters: add each line from `conversation-starters.txt`. |
| 118 | +6. Knowledge (optional): upload `knowledge/pedagogy.md` and `knowledge/fields.md`. |
| 119 | +7. Save. Start with e.g. "Teach me Rust (I am a beginner)". |
| 120 | +
|
| 121 | +To teach a fixed field instead of any field, replace |
| 122 | +"subject" in `instructions.md` with that field. |
| 123 | +""" |
| 124 | + |
| 125 | +GEM_README = """# Gemini Gem pack - expert-mentor |
| 126 | +
|
| 127 | +Gems have no ZIP import. Create the Gem by pasting: |
| 128 | +
|
| 129 | +1. Go to Gemini -> Gems -> New Gem (account/Workspace permitting). |
| 130 | +2. Name: `Expert Mentor` |
| 131 | +3. Instructions: paste the full contents of `instructions.md`. |
| 132 | +4. Knowledge (optional): upload `knowledge/pedagogy.md` and `knowledge/fields.md`. |
| 133 | +5. Save. Start with e.g. "Teach me Rust (I am a beginner)". |
| 134 | +
|
| 135 | +Google is migrating Gems to Skills: the canonical |
| 136 | +`expert-mentor-skill.zip` can instead be uploaded via the Skills interface |
| 137 | +(`SKILL.md` + supporting files) where available. |
| 138 | +
|
| 139 | +To teach a fixed field instead of any field, replace |
| 140 | +"subject" in `instructions.md` with that field. |
| 141 | +""" |
| 142 | + |
| 143 | +INSTALL_MD = """# Bundles - where each file goes |
| 144 | +
|
| 145 | +Built by `python3 scripts/build_bundles.py` (`make bundles`). |
| 146 | +
|
| 147 | +| File | Providers | Install | |
| 148 | +|------|-----------|---------| |
| 149 | +| `expert-mentor-skill.zip` | Claude Code, Claude web, Cursor, Copilot, OpenCode, Codex, Gemini Skills | Extract the `expert-mentor/` folder to the skills dir, e.g. `~/.claude/skills/expert-mentor`, `.cursor/skills/expert-mentor`, `.github/skills/expert-mentor`, `.opencode/skills/expert-mentor`, `~/.agents/skills/expert-mentor`. Claude web: upload ZIP via Customize -> Skills. Gemini: upload `SKILL.md` via Skills interface. | |
| 150 | +| `expert-mentor-agensi.zip` | Agensi.io | Upload the ZIP in Creator Dashboard (contains `SKILL.md` + `LISTING.md`). Review required. | |
| 151 | +| `chatgpt-gpt-pack.zip` | ChatGPT Custom GPTs | No ZIP import - unzip, follow `README.md` (paste `instructions.md`). | |
| 152 | +| `gemini-gem-pack.zip` | Gemini Gems | No ZIP import - unzip, follow `README.md` (paste `instructions.md`). | |
| 153 | +| Local models (no bundle needed) | Ollama / llama.cpp / LM Studio | `python3 scripts/expert_mentor.py --field "Rust" --provider ollama --emit modelfile --compact > Modelfile` (see `references/providers.md`). | |
| 154 | +
|
| 155 | +All skill zips carry `SKILL.md` with `name: expert-mentor` matching the folder name |
| 156 | +(Agent Skills spec: https://agentskills.io/specification). |
| 157 | +""" |
| 158 | + |
| 159 | + |
| 160 | +def build_skill(out: Path) -> None: |
| 161 | + n = write_zip(out, skill_members()) |
| 162 | + print("wrote %s (%d files)" % (out, n)) |
| 163 | + |
| 164 | + |
| 165 | +def build_agensi(out: Path) -> None: |
| 166 | + listing = ROOT / "docs" / "agensi-listing.md" |
| 167 | + extra = {} |
| 168 | + if listing.is_file(): |
| 169 | + extra["LISTING.md"] = listing.read_text(encoding="utf-8") |
| 170 | + n = write_zip(out, skill_members(), extra) |
| 171 | + print("wrote %s (%d files)" % (out, n)) |
| 172 | + |
| 173 | + |
| 174 | +def build_gpt_pack(out: Path) -> None: |
| 175 | + instructions = render_instructions(CHATGPT_CAPABILITY) |
| 176 | + pedagogy = (ROOT / "references" / "pedagogy.md").read_text(encoding="utf-8") |
| 177 | + fields = (ROOT / "references" / "fields.md").read_text(encoding="utf-8") |
| 178 | + config = { |
| 179 | + "name": "Expert Mentor", |
| 180 | + "description": "Turns ChatGPT into a professional teacher for any field - intake, roadmap, tutoring with checks, and practice.", |
| 181 | + "instructions_file": "instructions.md", |
| 182 | + "conversation_starters": STARTERS, |
| 183 | + "knowledge": ["knowledge/pedagogy.md", "knowledge/fields.md"], |
| 184 | + } |
| 185 | + with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as zf: |
| 186 | + zf.writestr("instructions.md", instructions) |
| 187 | + zf.writestr("conversation-starters.txt", "\n".join(STARTERS) + "\n") |
| 188 | + zf.writestr("gpt-config.json", json.dumps(config, indent=2) + "\n") |
| 189 | + zf.writestr("knowledge/pedagogy.md", pedagogy) |
| 190 | + zf.writestr("knowledge/fields.md", fields) |
| 191 | + zf.writestr("README.md", GPT_README) |
| 192 | + print("wrote %s (6 files)" % out) |
| 193 | + |
| 194 | + |
| 195 | +def build_gem_pack(out: Path) -> None: |
| 196 | + instructions = render_instructions(GEMINI_CAPABILITY) |
| 197 | + pedagogy = (ROOT / "references" / "pedagogy.md").read_text(encoding="utf-8") |
| 198 | + fields = (ROOT / "references" / "fields.md").read_text(encoding="utf-8") |
| 199 | + config = { |
| 200 | + "name": "Expert Mentor", |
| 201 | + "instructions_file": "instructions.md", |
| 202 | + "conversation_starters": STARTERS, |
| 203 | + "knowledge": ["knowledge/pedagogy.md", "knowledge/fields.md"], |
| 204 | + } |
| 205 | + with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as zf: |
| 206 | + zf.writestr("instructions.md", instructions) |
| 207 | + zf.writestr("conversation-starters.txt", "\n".join(STARTERS) + "\n") |
| 208 | + zf.writestr("gem-config.json", json.dumps(config, indent=2) + "\n") |
| 209 | + zf.writestr("knowledge/pedagogy.md", pedagogy) |
| 210 | + zf.writestr("knowledge/fields.md", fields) |
| 211 | + zf.writestr("README.md", GEM_README) |
| 212 | + print("wrote %s (6 files)" % out) |
| 213 | + |
| 214 | + |
| 215 | +def main() -> int: |
| 216 | + OUT_DIR.mkdir(exist_ok=True) |
| 217 | + build_skill(OUT_DIR / "expert-mentor-skill.zip") |
| 218 | + build_agensi(OUT_DIR / "expert-mentor-agensi.zip") |
| 219 | + build_gpt_pack(OUT_DIR / "chatgpt-gpt-pack.zip") |
| 220 | + build_gem_pack(OUT_DIR / "gemini-gem-pack.zip") |
| 221 | + (OUT_DIR / "INSTALL.md").write_text(INSTALL_MD, encoding="utf-8") |
| 222 | + print("wrote %s" % (OUT_DIR / "INSTALL.md")) |
| 223 | + return 0 |
| 224 | + |
| 225 | + |
| 226 | +if __name__ == "__main__": |
| 227 | + sys.exit(main()) |
0 commit comments