Skip to content

Commit fcfca3b

Browse files
committed
Add Gemini live sessions, mentor skill installer, and a C++ example
- google/gemini now has a real live-session runtime (build_google_payload, stream_google), wired into run/review/cards alongside anthropic/openai/ ollama/llamacpp. Default model updated from the retired gemini-2.5-pro to the rolling gemini-flash-latest alias. - mentor skill installs the Claude Code / opencode skill from the CLI itself (symlinks the repo from a git checkout, copies SKILL.md+templates+ references from a pip/pipx install) so that install path is not exclusive to install.sh, which now delegates to it instead of duplicating the logic. - examples/cpp.google.transcript.md: a live Gemini tutoring session transcript on C++ (smart pointers vs raw pointers), demonstrating the new provider. Docs (README, docs/commands.md, docs/providers.md, docs/skill.md, references/providers.md) and CHANGELOG updated to match. 107/107 self-tests passing.
1 parent aecb7d4 commit fcfca3b

12 files changed

Lines changed: 277 additions & 37 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
88

9+
### Added
10+
- Live sessions for Google/Gemini (`mentor run --provider google`), on par with
11+
Anthropic, OpenAI, Ollama, and llama.cpp.
12+
- `mentor skill` — install the Claude Code / opencode skill from the CLI
13+
itself, so a `pip`/`pipx` install gets it too, not just a git checkout.
14+
- `examples/cpp.google.transcript.md` — a live Gemini tutoring transcript.
15+
16+
### Fixed
17+
- `google`'s default model was the retired `gemini-2.5-pro`; now the rolling
18+
`gemini-flash-latest` alias.
19+
20+
### Changed
21+
- `install.sh` now calls `mentor skill` instead of duplicating its symlink logic.
22+
923
## [0.6.1] - 2026-09-12
1024

1125
### Changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Profiles, transcripts, prompts, and cards live under
120120
| `mentor cards` / `quiz` | spaced-repetition flashcards |
121121
| `mentor config` | saved defaults |
122122
| `mentor doctor` | health check |
123+
| `mentor skill` | install the Claude Code / opencode skill (pip/pipx installs included) |
123124
| `mentor interactive` | build a profile by answering prompts |
124125

125126
Full reference: [docs/commands.md](docs/commands.md).

‎docs/commands.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ mentor config --set provider=claude --set level=intermediate --set style=coachin
126126
mentor config --unset style
127127
mentor config --reset
128128
mentor doctor
129+
mentor skill [--dir PATH] [--force] # install the Claude Code / opencode skill
129130
mentor version
130131
mentor interactive
131132
```

‎docs/providers.md‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| `generic` | — | any capable model | prompt text only |
99
| `anthropic` | `claude` | `claude-sonnet-5` | live sessions + JSON |
1010
| `openai` | `chatgpt`, `gpt`, `oai` | `gpt-5.6` | live sessions + JSON |
11-
| `google` | `gemini` | `gemini-2.5-pro` | prompt JSON |
11+
| `google` | `gemini` | `gemini-flash-latest` | live sessions + JSON |
1212
| `ollama` | `local` | `llama3.1:8b` | live sessions + Modelfile |
1313
| `llamacpp` | — | your loaded GGUF | live sessions |
1414

@@ -24,11 +24,12 @@ directory or `~/.config/expert-mentor/.env` (existing env vars win):
2424
|----------|-----------|
2525
| Anthropic | `ANTHROPIC_API_KEY` (or `CLAUDE_API_KEY`) |
2626
| OpenAI | `OPENAI_API_KEY` (or `CHATGPT_API_KEY`) |
27+
| Google (Gemini) | `GEMINI_API_KEY` (or `GOOGLE_API_KEY`) |
2728
| llama.cpp / LM Studio | `LLAMACPP_API_KEY` (optional) |
2829
| Ollama | none |
2930

30-
Endpoint overrides: `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`, `OLLAMA_HOST`,
31-
`LLAMACPP_HOST`.
31+
Endpoint overrides: `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`, `GOOGLE_BASE_URL`,
32+
`OLLAMA_HOST`, `LLAMACPP_HOST`.
3233

3334
## Claude (Anthropic)
3435

@@ -66,10 +67,18 @@ mentor run --field "Rust" --provider chatgpt --model gpt-5.6 --reasoning-effort
6667

6768
## Gemini (Google)
6869

69-
`--emit json` produces a `systemInstruction` + `contents` payload. Live sessions
70-
are not currently implemented for Gemini.
70+
`--emit json` produces a `systemInstruction` + `contents` payload for the
71+
Gemini API. Live sessions are supported: requests go to
72+
`v1beta/models/{model}:streamGenerateContent`, authenticated with the
73+
`x-goog-api-key` header, and stream back `text` and usage events.
74+
75+
Google's model names churn fast and older dated snapshots get retired; prefer
76+
the rolling aliases (`gemini-flash-latest`, `gemini-flash-lite-latest`,
77+
`gemini-pro-latest`) over a pinned version. Note the free tier currently grants
78+
`gemini-pro-latest` zero quota — use a flash model unless billing is enabled.
7179

7280
```bash
81+
mentor run --field "Rust" --provider gemini --model gemini-flash-latest
7382
mentor --field "macroeconomics" --provider gemini --emit json
7483
```
7584

‎docs/skill.md‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@ usable inside Claude Code and opencode, not just as a CLI.
66

77
## Install
88

9-
`./install.sh` links the skill into the standard locations automatically:
9+
```bash
10+
mentor skill
11+
```
12+
13+
Works whether `mentor` came from a git checkout or from `pip install`/`pipx
14+
install`. From a checkout it symlinks the whole repo into the standard
15+
locations (so it stays live as you edit the repo):
1016

1117
```
1218
~/.claude/skills/expert-mentor -> <repo>
1319
~/.config/opencode/skills/expert-mentor -> <repo>
1420
```
1521

16-
Manual equivalent:
17-
18-
```bash
19-
ln -sfn ~/projects/expert-mentor ~/.claude/skills/expert-mentor
20-
ln -sfn ~/projects/expert-mentor ~/.config/opencode/skills/expert-mentor
21-
```
22+
From a pip/pipx install (no repo to point at) it copies the bundled
23+
`SKILL.md`, `templates/`, and `references/` into the same locations instead.
24+
Add `--dir PATH` to install elsewhere, or `--force` to replace a directory
25+
that already exists there for another reason. `./install.sh` still does the
26+
same thing as part of its full one-shot setup (launcher + PATH + skill).
2227

2328
Restart the host (opencode loads skills at startup) so it picks up the new skill.
2429

‎examples/cpp.google.transcript.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Session — cpp-demo — 20260912T223011681837
2+
3+
- Field: C++
4+
- Provider: google · Model: gemini-flash-latest
5+
- Turns: 2
6+
7+
**you:** I know C already, pointers and structs, want to learn modern C++ for a small game engine hobby project.
8+
9+
**mentor:** Welcome. I am Prof. Idris Ibrahim. It is a pleasure to meet you.
10+
11+
Coming from C gives you a tremendous head start: you already understand memory layout, pointers, and the cost of indirection. That said, C++ is not merely "C with classes." In fact, your biggest challenge will likely be unlearning several manual C habits in favor of modern C++ idiom—letting the type system and lifetime rules do the heavy lifting for you so your game engine doesn't become a swamp of manual memory tracking and silent bugs.
12+
13+
Before we chart our path toward your engine, I have three quick questions to calibrate our starting point:
14+
15+
1. **Diagnostic:** In your C work, when you allocate a dynamic array or manage a resource (like a file handle or a texture), how do you typically ensure it gets cleaned up safely? Have you ever encountered the concept of **RAII** (Resource Acquisition Is Initialization)?
16+
2. **Scope:** What kind of engine are you planning to build (e.g., a simple 2D engine using a library like SDL, a software rasterizer, a 3D OpenGL/Vulkan engine, or primarily a core system like an Entity Component System)?
17+
3. **Pace:** Roughly how many hours a week do you plan to invest in writing code and discussing it here?
18+
19+
Tell me about these three, and we will map out a concrete syllabus.
20+
21+
**you:** Can you explain what a smart pointer is compared to a raw pointer, with a tiny example?
22+
23+
**mentor:** In C, a pointer is just an integer holding a memory address. It has no brain: it does not know if it owns the memory, how large the allocation is, or when it should be freed.
24+
25+
A **smart pointer** in modern C++ is a small object (usually a lightweight struct/class template) that wraps that raw address. It behaves syntactically like a pointer—you can still use `*p` and `p->`—but it has an automated destructor. When the smart pointer leaves its scope (such as hitting a `return` statement or the closing curly brace `}`), it automatically frees the memory it points to.
26+
27+
Here is the contrast:
28+
29+
### The C / Raw Pointer Way
30+
```cpp
31+
void run_c_style() {
32+
int* data = (int*)malloc(sizeof(int));
33+
*data = 42;
34+
35+
if (some_error_condition()) {
36+
// Danger: If you exit early here and forget to free,
37+
// you have leaked memory.
38+
return;
39+
}
40+
41+
free(data); // Must manually remember this every time
42+
}
43+
```
44+
45+
### The Modern C++ Way (`std::unique_ptr`)
46+
```cpp
47+
#include <memory>
48+
49+
void run_modern_cpp() {
50+
// Allocates an int on the heap and wraps it in a smart pointer:
51+
std::unique_ptr<int> data = std::make_unique<int>(42);
52+
53+
if (some_error_condition()) {
54+
return; // Safe! 'data' falls out of scope, memory is freed automatically.
55+
}
56+
57+
// No free() or delete!
58+
// When the function ends, 'data' goes out of scope and frees the memory.
59+
}
60+
```
61+
62+
Notice what is missing in the second example: there is no manual cleanup call.
63+
64+
Now, to make sure this clicks before we look deeper:
65+
66+
**If `data` is allocated inside an `if` block:**
67+
```cpp
68+
{
69+
std::unique_ptr<int> data = std::make_unique<int>(100);
70+
}
71+
// <-- Right here
72+
```
73+
**In your own words, what happens to that heap memory the exact moment execution passes that closing brace `}`?**

‎install.sh‎

100755100644
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ OPENCODE_SKILLS=${OPENCODE_SKILLS:-$HOME/.config/opencode/skills}
1919
MARKER="# >>> expert-mentor setup >>>"
2020

2121
say() { printf '%s\n' "$*"; }
22-
warn() { printf 'warning: %s\n' "$*" >&2; }
2322

2423
say "expert-mentor installer"
2524
say " source: $ROOT"
@@ -36,20 +35,11 @@ chmod +x "$ROOT/bin/mentor" "$ROOT/scripts/expert_mentor.py" "$ROOT/scripts/self
3635
ln -sf "$ROOT/bin/mentor" "$BIN_DIR/mentor"
3736
say "[1/4] installed launcher: $BIN_DIR/mentor"
3837

39-
# 2. Skill symlinks (opencode auto-loads ~/.claude/skills too)
40-
link_skill() {
41-
local target="$1"
42-
mkdir -p "$(dirname "$target")"
43-
if [ -e "$target" ] && [ ! -L "$target" ]; then
44-
warn "$target exists and is not a symlink; leaving it alone"
45-
else
46-
ln -sfn "$ROOT" "$target"
47-
say " linked skill: $target"
48-
fi
49-
}
50-
say "[2/4] linking skill"
51-
link_skill "$CLAUDE_SKILLS/expert-mentor"
52-
link_skill "$OPENCODE_SKILLS/expert-mentor"
38+
# 2. Skill (opencode auto-loads ~/.claude/skills too)
39+
say "[2/4] installing skill"
40+
"$PYTHON" "$ROOT/scripts/expert_mentor.py" skill \
41+
--dir "$CLAUDE_SKILLS" --dir "$OPENCODE_SKILLS" \
42+
| sed 's/^/ /'
5343

5444
# 3. Ensure ~/.local/bin is on PATH
5545
case ":$PATH:" in

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ py-modules = ["expert_mentor", "mentor_runtime", "mentor_memory", "mentor_cards"
4747
version = { attr = "expert_mentor.__version__" }
4848

4949
[tool.setuptools.data-files]
50+
"share/expert-mentor" = ["SKILL.md"]
5051
"share/expert-mentor/templates" = ["templates/*.md"]
5152
"share/expert-mentor/references" = ["references/*.md", "references/*.json"]
5253

‎references/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Run `mentor providers` to see defaults, or `mentor models` for the model catalog
1313
| `generic` | — | 0.6 | any capable model | cloud notes |
1414
| `anthropic` | `claude` | 0.7 | `claude-sonnet-5` | Claude notes + XML shaping |
1515
| `openai` | `chatgpt`, `gpt`, `oai` | 0.7 | `gpt-5.6` | ChatGPT notes + markdown |
16-
| `google` | `gemini` | 0.8 | `gemini-2.5-pro` | cloud notes |
16+
| `google` | `gemini` | 0.8 | `gemini-flash-latest` | cloud notes |
1717
| `ollama` | `local` | 0.4 | `llama3.1:8b` | local notes |
1818
| `llamacpp` | — | 0.4 | local-gguf | local notes |
1919

‎scripts/expert_mentor.py‎

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,25 @@ def _resource_dir(*parts: str) -> Path:
5757
return candidates[0]
5858

5959

60+
def _resource_file(name: str) -> Path:
61+
"""Locate a single bundled file (e.g. SKILL.md) in both repo and installed layouts."""
62+
here = Path(__file__).resolve().parent
63+
candidates = [
64+
here.parent / name, # <repo>/SKILL.md
65+
here / name, # packaged next to module
66+
Path(sys.prefix) / "share" / APP_NAME / name,
67+
Path(sys.prefix) / "local" / "share" / APP_NAME / name,
68+
]
69+
for candidate in candidates:
70+
if candidate.exists():
71+
return candidate
72+
return candidates[0]
73+
74+
6075
ROOT = Path(__file__).resolve().parent.parent
6176
TEMPLATES_DIR = _resource_dir("templates")
6277
REFERENCES_DIR = _resource_dir("references")
78+
SKILL_MD = _resource_file("SKILL.md")
6379

6480
CONFIG_DIR = Path(os.environ.get("EXPERT_MENTOR_HOME", str(Path.home() / ".config" / "expert-mentor")))
6581
PROMPTS_DIR = CONFIG_DIR / "prompts"
@@ -716,7 +732,7 @@ def line(status: str, msg: str) -> None:
716732

717733
linked = next((p for p in SKILL_LINK_DIRS if p.exists()), None)
718734
line("ok" if linked else "warn",
719-
f"skill linked: {linked}" if linked else "skill not linked yet — run ./install.sh")
735+
f"skill linked: {linked}" if linked else "skill not installed yet — run 'mentor skill'")
720736

721737
try:
722738
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
@@ -843,6 +859,57 @@ def run_ollama_command(rest: List[str]) -> int:
843859
return 0
844860

845861

862+
def run_skill_command(rest: List[str]) -> int:
863+
parser = argparse.ArgumentParser(prog="mentor skill", add_help=True,
864+
description="Install the Claude Code / opencode agent skill "
865+
"(works for pip/pipx installs, not just git checkouts).")
866+
parser.add_argument("--dir", action="append", metavar="PATH",
867+
help="install into PATH/expert-mentor instead of the default locations "
868+
"(repeatable)")
869+
parser.add_argument("--force", action="store_true",
870+
help="overwrite an existing skill directory that isn't already ours")
871+
opts = parser.parse_args(rest)
872+
873+
if not SKILL_MD.exists():
874+
print(f"SKILL.md not found (looked near {SKILL_MD}); nothing to install", file=sys.stderr)
875+
return 1
876+
877+
# Git checkout: symlink the whole repo, same as install.sh (stays live as the repo changes).
878+
# Installed package (pip/pipx): no repo to point at, so copy the bundled files instead.
879+
is_checkout = (ROOT / "install.sh").exists()
880+
targets = ([Path(d).expanduser() / "expert-mentor" for d in opts.dir] if opts.dir
881+
else list(SKILL_LINK_DIRS[:2]))
882+
883+
installed = 0
884+
for target in targets:
885+
already_ours = target.is_symlink() or (target / "SKILL.md").exists()
886+
if target.exists() or target.is_symlink():
887+
if not already_ours and not opts.force:
888+
print(f"skip {target} (exists; pass --force to overwrite)", file=sys.stderr)
889+
continue
890+
if target.is_symlink() or target.is_file():
891+
target.unlink()
892+
elif target.is_dir():
893+
shutil.rmtree(target)
894+
895+
if is_checkout:
896+
target.parent.mkdir(parents=True, exist_ok=True)
897+
target.symlink_to(ROOT, target_is_directory=True)
898+
else:
899+
target.mkdir(parents=True, exist_ok=True)
900+
shutil.copy2(SKILL_MD, target / "SKILL.md")
901+
for name, resolved in (("templates", TEMPLATES_DIR), ("references", REFERENCES_DIR)):
902+
if resolved.exists():
903+
shutil.copytree(resolved, target / name, dirs_exist_ok=True)
904+
print(f"installed skill: {target}")
905+
installed += 1
906+
907+
if not installed:
908+
return 1
909+
print("\nRestart Claude Code / opencode (or start a new session) to pick it up.")
910+
return 0
911+
912+
846913
def run_models_command(rest: List[str]) -> int:
847914
parser = argparse.ArgumentParser(prog="mentor models", add_help=True)
848915
parser.add_argument("--provider", choices=sorted(set(PROVIDERS) | set(PROVIDER_ALIASES)))
@@ -1085,7 +1152,7 @@ def run_review_command(rest: List[str]) -> int:
10851152
field_name = (learner.field if learner else "") or meta.get("field", "")
10861153

10871154
provider = canonical_provider(opts.provider or meta.get("provider") or "ollama")
1088-
if provider not in ("ollama", "llamacpp", "openai", "anthropic"):
1155+
if provider not in ("ollama", "llamacpp", "openai", "anthropic", "google"):
10891156
print(f"provider '{provider}' has no runtime backend; pass --provider", file=sys.stderr)
10901157
return 2
10911158
model = opts.model or meta.get("model") or mentor_runtime.DEFAULT_MODELS.get(provider, "")
@@ -1232,7 +1299,7 @@ def _generate_cards(opts: argparse.Namespace, store: "mentor_cards.CardStore") -
12321299
field_name = (learner.field if learner else "") or meta.get("field", "")
12331300

12341301
provider = canonical_provider(opts.provider or meta.get("provider") or "ollama")
1235-
if provider not in ("ollama", "llamacpp", "openai", "anthropic"):
1302+
if provider not in ("ollama", "llamacpp", "openai", "anthropic", "google"):
12361303
print(f"provider '{provider}' has no runtime backend; pass --provider", file=sys.stderr)
12371304
return 2
12381305
model = opts.model or meta.get("model") or mentor_runtime.DEFAULT_MODELS.get(provider, "")
@@ -1411,7 +1478,7 @@ def run_run_command(rest: List[str]) -> int:
14111478
provider = args.provider
14121479
label = args._profile.key
14131480

1414-
runtime_providers = {"ollama", "llamacpp", "openai", "anthropic"}
1481+
runtime_providers = {"ollama", "llamacpp", "openai", "anthropic", "google"}
14151482
if provider not in runtime_providers:
14161483
print(
14171484
f"provider '{provider}' cannot run a live session.\n"
@@ -1463,6 +1530,9 @@ def run_run_command(rest: List[str]) -> int:
14631530
payload = mentor_runtime.build_openai_payload(
14641531
model, system_prompt, sample_messages, temperature, stream=True,
14651532
max_tokens=args.max_tokens)
1533+
elif provider == "google":
1534+
payload = mentor_runtime.build_google_payload(
1535+
model, system_prompt, sample_messages, temperature, max_tokens=args.max_tokens)
14661536
else:
14671537
payload = mentor_runtime.build_ollama_payload(
14681538
model, system_prompt, sample_messages, temperature, max_tokens=args.max_tokens)
@@ -1554,7 +1624,7 @@ def save_progress(session_messages: List[Dict]) -> None:
15541624
COMMANDS = ("version", "fields", "providers", "doctor", "interactive", "prompt",
15551625
"save", "show", "saved", "ollama", "curriculum", "run", "models",
15561626
"learners", "progress", "sessions", "transcript", "review", "config",
1557-
"cards", "quiz")
1627+
"cards", "quiz", "skill")
15581628

15591629

15601630
# --------------------------------------------------------------------------- #
@@ -1678,6 +1748,8 @@ def main(argv: Optional[List[str]] = None) -> int:
16781748
return run_saved_command(rest)
16791749
elif command == "ollama":
16801750
return run_ollama_command(rest)
1751+
elif command == "skill":
1752+
return run_skill_command(rest)
16811753
elif command == "models":
16821754
return run_models_command(rest)
16831755
elif command == "learners":

0 commit comments

Comments
 (0)