Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add Hao-xl/zemax-python-connect --skill zemax-python-connectgit clone --depth 1 https://github.com/Hao-xl/zemax-python-connectWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/hao-xl/zemax-python-connect/zemax-python-connect)<a href="https://agentmods.dev/skills/hao-xl/zemax-python-connect/zemax-python-connect"><img src="https://agentmods.dev/badge/skills/hao-xl/zemax-python-connect/zemax-python-connect/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/hao-xl/zemax-python-connect/zemax-python-connect"><img src="https://agentmods.dev/badge/skills/hao-xl/zemax-python-connect/zemax-python-connect.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00077 | $0.03264 |
| Opus 5.5 | $0.00031 | $0.01306 |
| Sonnet 5.5 | $0.00015 | $0.00653 |
| Haiku 4.5 | $0.00008 | $0.00326 |
Grade A, and why
zemax-python-connect scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 265 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Zemax Python 连接
范围
本 skill 只负责建立和验证 Python 与 Zemax OpticStudio 的 ZOS-API 连接。
当连接状态不确定时,先使用本 skill。连接验证完成后,再使用 zemax-python 进行模型操作、评价函数、优化、分析和容差等后续工作。
本 skill 不负责光学系统设计,也不负责具体优化策略。
Agent 执行契约(必须遵守)
- 不假设 Python、Zemax 数据目录、OpticStudio 安装目录或版本与其他电脑相同。
- 先运行
doctor.py --mode locator。只有已经验证ZOSAPI_NetHelper.dll存在,才允许初始化ZOSAPI_NetHelper。 - 初始化后必须读取
GetZemaxDirectory(),并再次确认实际安装目录中存在ZOSAPI.dll和ZOSAPI_Interfaces.dll。 - 独立模式必须满足
APP_MODE=Server;交互模式必须满足APP_MODE=Plugin。仅有非空app不代表成功。 - 两种模式都必须确认有效许可证和非空
PrimarySystem。 - 独立模式只关闭 Python 自己创建的实例;即使连接中途失败,也必须清理已创建的应用。
- 交互模式永远不调用
CloseApplication()。 - 不自动结束用户已有的 OpticStudio 进程。需要结束进程时,先解释原因并取得用户同意。
- 每次报告解析到的数据根目录、实际安装目录、NetHelper 路径、版本、许可证、应用模式和
PrimarySystem状态。 - 路径发现必须按顺序执行:Windows 快速来源 → 自动有限深度磁盘搜索 → 经用户明确允许的全盘搜索。禁止跳过授权直接全盘搜索。
- 全盘搜索前必须告知用户:通常约 2–15 分钟,文件很多或磁盘较慢时可能超过 30 分钟;只有用户明确允许后,才可传入
--exhaustive-search --confirm-long-scan。 - 磁盘搜索必须汇报已扫描目录数、权限拒绝目录数、其他扫描错误数和耗时,不得静默忽略权限失败。
Codex/Agent 沙箱重要规则
OpticStudio ZOS-API 使用 .NET Remoting IPC。某些 Agent 沙箱允许读取 DLL,却会阻止 IPC 连接。典型错误包括:
System.Runtime.Remoting.RemotingException
连接到 IPC 端口失败: 拒绝访问
Access denied
出现 ERROR_CODE=IPC_ACCESS_DENIED 时,不要继续猜测 DLL、许可证或实例编号,也不要反复重启 Zemax。应向用户说明原因并请求批准,在 Agent 沙箱外重新运行完全相同的 Zemax Python 命令。沙箱外执行仍必须限制为本 skill 的诊断或连接脚本。
连接模式选择
| 用户目标 | 推荐模式 | API |
|---|---|---|
| 批量自动化、创建/打开/保存文件,不需要观察 GUI 实时变化 | 独立应用程序 | CreateNewApplication() |
| 用户希望在已经打开的 OpticStudio GUI 中看到实时修改 | 交互扩展 | ConnectAsExtension(instance) |
| 用户明确说 Python 应实时修改可见的 LDE 或 Layout | 交互扩展 | ConnectAsExtension(instance) |
用户只需要生成 .zos / .zmx 输出文件 |
独立应用程序 | CreateNewApplication() |
第一原则:先定位,再初始化,再验证实际安装目录
优先运行统一诊断:
python scripts\doctor.py --mode locator
它会输出 Python 位数、pythonnet 版本、候选目录、已验证的 ZOSAPI_NetHelper.dll、初始化器解析出的实际 OpticStudio 安装目录,以及 ZOSAPI.dll / ZOSAPI_Interfaces.dll 的完整路径。
也可以只运行定位脚本:
python scripts\zosapi_locator.py --list-candidates
What ships with it
10 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- examples/interactive_minimal.py 1.2 KB runs code
- examples/standalone_minimal.py 1.1 KB runs code
- scripts/connection_diagnose.py 4.2 KB runs code
- scripts/doctor.py 7.7 KB runs code
- scripts/interactive_comment_test.py 2.6 KB runs code
- scripts/interactive_ping.py 3.0 KB runs code
- scripts/standalone_ping.py 2.9 KB runs code
- scripts/zemax_connection.py 14 KB runs code
- scripts/zemax_discovery.py 25 KB runs code
- scripts/zosapi_locator.py 4.5 KB runs code
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 265 lines · 77 tokens per session scan A 77db6b9438b9
zemax-python-connect is a skill published in the GitHub repository Hao-xl/zemax-python-connect (9 stars, last pushed 4mo ago), licensed MIT. It adds 77 tokens to every session and 3,264 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
zemax-python-connect compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| zemax-python-connectHao-xl/zemax-python-connect | Skill | 9 | 4mo ago | MIT | A | 77 | Claude Code, Codex |
| jupyter-notebookNousResearch/hermes-agent | Skill | 268k | today | MIT | A | 18 | Claude Code, Codex |
| matlabK-Dense-AI/scientific-agent-skills | Skill | 59k | 3d ago | MIT | A | 44 | Claude Code |
| pennylaneK-Dense-AI/scientific-agent-skills | Skill | 59k | 3d ago | MIT | A | 74 | Claude Code |
| cuequivariance-jaxNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 38 | Claude Code, Codex |
| cuequivariance-torchNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 37 | Claude Code, Codex |
| cuopt-numerical-optimization-apiNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 51 | Claude Code, Codex |