06-python-api

A Cursor rule describing how AuroraView connects Python code with a web interface. AuroraView can run on its own or inside a digital-content-creation application, and it can pass calls and events between Python and JavaScript.

In plain words
What is it for?
Use it when creating AuroraView windows, exposing Python methods to JavaScript, handling show, hide, close, or ready events, and sending events from Python to the web interface.
Why use it?
It documents the window setup, lifecycle callbacks, event delivery, and method mapping needed for the two sides to communicate. This reduces guesswork when building an AuroraView-based interface.

Cursor rule

Install

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.

agentmods
npx agentmods add rules/loonghao/auroraview/06-python-api
Clone the repo
git clone --depth 1 https://github.com/loonghao/auroraview
Per session 802 This file is loaded in full into every session.
When invoked 802 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00802 $0.00802
Opus 5 $0.00401 $0.00401
Sonnet 5 $0.00160 $0.00160
Haiku 4.5 $0.00080 $0.00080

Measured 2d ago against content hash eddaa4d5760d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

06-python-api 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 2d 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.

.codebuddy/rules/06-python-api.mdc · 58 lines

What it actually says

Python 抽象:AuroraView 基类

  • 导入约定:from auroraview import AuroraView
  • 构造参数(简化版):
    • parent: Any | None = None
      • None → Standalone 模式(Rust Shell / WebView 壳)
      • Qt 对象 → DCC 模式(PySide 宿主,作为 parent dock/panel)
    • url: str | None = None / html: str | None = None
    • title: str = "AuroraView"
    • width: int = 800, height: int = 600
    • fullscreen: bool = False
    • debug: bool = False
    • api: Any | None = None → 暴露到 auroraview.api.*
  • 生命周期钩子(可覆写):
    • def on_show(self) -> None: ...
    • def on_hide(self) -> None: ...
    • def on_close(self) -> None: ...
    • def on_ready(self) -> None: ... (WebView & JS bridge 就绪)
  • 事件推送:
    • self.emit(event_name: str, payload: Any) -> None
      • Python → JS:触发前端 auroraview.on(event_name, handler)

JS → Python 映射机制

  1. auroraview.api.* 风格

    • Python 在构造 AuroraView 时传入 api 对象,例如 api=self
    • 规则:auroraview.api.export_scene(*args) → Python api.export_scene(*args)
    • 实现:
      • JS:auroraview.api.foo(...args)auroraview.call("api.foo", args)
      • Python:解析 method 前缀 "api.",以 getattr(api, name) 查找方法
      • params 为 list → 调用 func(*params);为 dict → 调用 func(**params)
  2. 通用 auroraview.call(method, params)

    • AuroraView 提供注册接口:bind_call(method: str, func: Callable)
    • 使用示例:
      • JS:auroraview.call("tool.apply", {"strength": 0.8})
      • Python:
        • self.bind_call("tool.apply", self.apply_tool)
        • def apply_tool(self, strength: float, mode: str = "preview"): ...
    • 调用规则:
      • params 是 dict → func(**params)
      • params 是 list → func(*params)
      • 其它 → 单一位置参数

Standalone / DCC 双模式

  • Standalone:
    • 不依赖 Qt/PySide,仅使用 Rust 壳 + WebView(现有 wry/tao,可逐步演进到 Win32 + WebView2)
    • parent=None,AuroraView 负责创建顶层窗口并托管事件循环
  • DCC:
    • 仅在 Python 层使用 Qt/PySide 作为宿主壳(通过 parent 注入)
    • Rust/Python core 不直接依赖 Qt;Qt 逻辑集中在 auroraview.dcc.qt_shell 类模块
    • 通过 parent 将 WebView 子窗口嵌入 DCC 主窗口(Dock/Pane),保持原生体验
Changes

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.

  1. 2d ago First seen · 58 lines · 802 tokens per session scan A eddaa4d5760d

Subscribe to this mod's changes

06-python-api is a cursor rule published in the GitHub repository loonghao/auroraview (44 stars, last pushed 1mo ago), licensed MIT. It adds 802 tokens to every session, about $0.0040 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-30.