Skip to content

The agent that grows with you

feat(skills): ${HERMES_PYTHON} template token for SKILL.md

alt-glitchc2ee893e7c0f
diff --git a/agent/skill_preprocessing.py b/agent/skill_preprocessing.py
index 2e3f66b0f26..35a9e574d58 100644
--- a/agent/skill_preprocessing.py
+++ b/agent/skill_preprocessing.py
@@ -4,6 +4,7 @@ inline ``!`cmd``` shell expansion."""
import logging
import re
import subprocess
+import sys
from pathlib import Path
from agent.compression_marker import elide
@@ -13,7 +14,7 @@ logger = logging.getLogger(__name__)
# ${HERMES_SKILL_DIR} / ${HERMES_SESSION_ID} tokens. Unresolvable ones (e.g. no
# session) are left as-is so the author can spot them.
-_SKILL_TEMPLATE_RE = re.compile(r"\$\{(HERMES_SKILL_DIR|HERMES_SESSION_ID)\}")
+_SKILL_TEMPLATE_RE = re.compile(r"\$\{(HERMES_SKILL_DIR|HERMES_SESSION_ID|HERMES_PYTHON)\}")
# Inline shell snippets like !`date +%Y-%m-%d` — single-line only.
_INLINE_SHELL_RE = re.compile(r"!`([^`\n]+)`")
# Cap inline-shell output so a runaway command can't blow out the context.
@@ -39,6 +40,7 @@ def substitute_template_vars(content: str, skill_dir: Path | None, session_id: s
values = {
"HERMES_SKILL_DIR": str(skill_dir) if skill_dir else None,
"HERMES_SESSION_ID": str(session_id) if session_id else None,
+ "HERMES_PYTHON": sys.executable or None,
}
return _SKILL_TEMPLATE_RE.sub(lambda m: values[m.group(1)] or m.group(0), content)
diff --git a/website/docs/developer-guide/creating-skills.md b/website/docs/developer-guide/creating-skills.md
index 51219596e47..6a6dff0cdc1 100644
--- a/website/docs/developer-guide/creating-skills.md
+++ b/website/docs/developer-guide/creating-skills.md
@@ -283,12 +283,13 @@ If your skill produces a high-resolution screenshot, chart, or any image where l
#### Referencing bundled scripts from SKILL.md
-When a skill is loaded, the activation message exposes the absolute skill directory as `[Skill directory: /abs/path]` and also substitutes two template tokens anywhere in the SKILL.md body:
+When a skill is loaded, the activation message exposes the absolute skill directory as `[Skill directory: /abs/path]` and also substitutes three template tokens anywhere in the SKILL.md body:
| Token | Replaced with |
|---|---|
| `${HERMES_SKILL_DIR}` | Absolute path to the skill's directory |
| `${HERMES_SESSION_ID}` | The active session id (left in place if there is no session) |
+| `${HERMES_PYTHON}` | Absolute path to the Python interpreter running Hermes |
So a SKILL.md can tell the agent to run a bundled script directly with:
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/creating-skills.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/creating-skills.md
index 05f94d421cd..fcc0fed2f4d 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/creating-skills.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/creating-skills.md
@@ -278,12 +278,13 @@ required_credential_files:
#### 在 SKILL.md 中引用内置脚本
-Skill 加载时,激活消息会将 skill 目录的绝对路径以 `[Skill directory: /abs/path]` 的形式暴露,同时在 SKILL.md 正文中替换两个模板 token:
+Skill 加载时,激活消息会将 skill 目录的绝对路径以 `[Skill directory: /abs/path]` 的形式暴露,同时在 SKILL.md 正文中替换三个模板 token:
| Token | 替换为 |
|---|---|
| `${HERMES_SKILL_DIR}` | skill 目录的绝对路径 |
| `${HERMES_SESSION_ID}` | 当前会话 ID(若无会话则保留原样) |
+| `${HERMES_PYTHON}` | 运行 Hermes 的 Python 解释器的绝对路径 |
因此,SKILL.md 可以直接告知 agent 运行内置脚本: