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 agentmods add skills/hao-xl/zemax-python-connect/zemax-python-connectnpx skills add Hao-xl/zemax-python-connect --skill zemax-python-connectgit clone --depth 1 https://github.com/Hao-xl/zemax-python-connectWhat 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 | $0.00077 | $0.03264 |
| Opus 5 | $0.00039 | $0.01632 |
| Sonnet 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 3d 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 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.
- 3d 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 (10 stars, last pushed 1mo ago), licensed MIT. It adds 77 tokens to every session and 3,264 once invoked, about $0.0004 per session on Opus 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.
Other skills, from other repositories
jupyter-notebook
Use when the user asks to create, scaffold, or edit Jupyter notebooks (.ipynb) for experiments, explorations, or tutorials; prefer the bundled templates and run the helper script newnotebook.py to generate a clean starting notebook.
biopython
Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use…
esm
Use when working directly with the esm Python SDK, ESM3 or ESMC model IDs, Forge/Biohub inference clients, or ESMFold2 folding workflows.
benchling-integration
Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.
marimo-pair
Work inside the user's live marimo notebook from the code editor: run Python in the same kernel the user does, inspect live notebook state, and commit durable notebook changes through code mode. Use whenever you create, analyze, or improve the user's marimo notebook.
quantum-qiskit
Reference qiskit 2.x patterns for variational quantum machine learning. Covers data-encoding feature maps, variational quantum classifier (VQC) training, variational quantum eigensolver (VQE) for chemistry, matrix-product-state circuits, and noise model integration. Use when writing Python code that imports qiskit…