touchpad-shield-code

Code-maintenance rules for the Touchpad Shield Windows application. They list deliberate structures that must stay separate and older patterns that must not be brought back without a new requirement.

In plain words
What is it for?
Use them when reviewing or modifying Touchpad Shield code, especially its event handlers, window sizing, startup behavior, services, assets, and WebView2 dependency.
Why use it?
They prevent reviewers or coding agents from proposing refactors that would remove intentional behavior or restore previously removed problems.

Cursor rule for Cursor

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/zimiaoworkshop/touchpad-shield/touchpad-shield-code
Clone the repo
git clone --depth 1 https://github.com/ZiMiaoWorkshop/Touchpad-Shield

Made for: Cursor.

Per session 743 This file is loaded in full into every session.
When invoked 743 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.00743 $0.00743
Opus 5 $0.00371 $0.00371
Sonnet 5 $0.00149 $0.00149
Haiku 4.5 $0.00074 $0.00074

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

Security

Grade A, and why

touchpad-shield-code 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.

.cursor/rules/touchpad-shield-code.mdc · 44 lines

What it actually says

Touchpad Shield 代码维护约定

完整说明见 PRD/Touchpad_Shield_开发指导.md §6.1。以下为 AI 与审查者必须遵守的摘要。

禁止再提议的「优化」

除非用户明确新需求,不得建议或实施:

  1. 合并 Curtain / SuperCurtain 事件 handlerSmartAreaSwitch_ToggledSmartEdgeSwitch_ToggledCurtainValueChangedSuperCurtainValueChanged)——有意保留四个独立 handler。
  2. 抽象 WindowBoundsHelper 与 TrayIconService 的 SetWindowSubclass 样板——两处处理的消息语义不同,保持独立。
  3. 合并 TouchpadParametersService 进 RegistryService——SPI 封装层,保持独立文件。
  4. 删除 Assets/TouchpadShieldLogo.png 的 CopyAssets——PNG 供图标生成脚本使用。
  5. 移除 WebView2 依赖——WinAppSDK C++/WinRT 构建需要。

禁止恢复的反模式(v1.1.1 已移除)

除非用户明确新需求,不得建议或实施:

  1. RootLayoutGrid 构造函数 / XAML 设置 MinWidth/MinHeight 1560×900——窗口最小尺寸仅由 WindowBoundsHelper::ApplyInitialClientBounds + WM_GETMINMAXINFO 约束。
  2. AutostartHandledSessionId / ShouldSkipStartupLaunch / defer 尺寸到 ShowFromTray——自启重复判定用 Session Mutex;尺寸在 CompletePlatformSetupEnsureInitialWindowSize 应用。
  3. ActivateExistingInstanceShowWindow 回退——二次打开必须 PostMessage(ShowMainWindow)ShowFromTray
  4. WindowBoundsHelper 分离的 Apply + ResizeClientToLogicalSize 对外 API——统一为 ApplyInitialClientBounds
  5. LaunchToTrayOnly 内重复 m_trayIcon.Create——托盘由 UpdateTrayIconState 统一创建。

已完成清理(勿重复)

  • HID 源文件已移除;注册表键为 InputAutoTouchpadEnabled / MonitoredInputDevices HID 实验键迁移
  • PnP watcher 在关闭自动启停时仍运行(仅 reconcile 关闭);见开发指导 §3.3.1(1)
  • pch 已瘦身;XamlLocalTypes.h 仅服务 XamlTypeInfo.g.cpp
  • BuildContainerPropertyNamesList()BuildInputDeviceListRow() 已提取共用
  • ShouldMinimizeToTrayOnClose 已删除
  • v1.1.1:Local\TouchpadShield_SingleInstance_v2、计划任务自启、ApplyInitialClientBounds、遗留 AutostartHandledSessionId 启动清理

需求变更

有疑问必须与用户确认,不可自行决定解决方案(与 build 规则一致)。

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 · 44 lines · 743 tokens per session scan A 2ba031e9e4cb

Subscribe to this mod's changes

touchpad-shield-code is a cursor rule published in the GitHub repository ZiMiaoWorkshop/Touchpad-Shield (8 stars, last pushed 9d ago), licensed Apache-2.0. It adds 743 tokens to every session, about $0.0037 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.