Hopet AGENTS.md

A project instruction document for AI coding agents working on Hopet, a macOS desktop AI-pet application written in Swift.

In plain words
What is it for?
Use it to guide changes in the Hopet app and its command-line tool, including state management, interprocess communication, hooks, interface components, themes, and Swift package structure.
Why use it?
It gives agents a shared source of rules for the project’s architecture, documentation, code organization, naming, and visibility.

Instructions file for CodexOpenCode

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 instructions/binaryfroggy/hopet/agents-md
Clone the repo
git clone --depth 1 https://github.com/BinaryFroggy/Hopet

Made for: Codex, OpenCode.

Per session 3,103 This file is loaded in full into every session.
When invoked 3,103 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.03103 $0.03103
Opus 5 $0.01551 $0.01551
Sonnet 5 $0.00621 $0.00621
Haiku 4.5 $0.00310 $0.00310

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

Security

Grade A, and why

Hopet AGENTS.md 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.

AGENTS.md · 212 lines

How it starts

The opening of the file, as written. The whole thing — 212 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Hopet · Agent 协作规范

本文件是 Hopet 仓库面向 AI 编码 agent(Claude Code / Codex CLI 等)的唯一权威规范。CLAUDE.md 通过 @AGENTS.md 引用本文件,规则改动只在本文件进行。

0. 项目

macOS 桌面 AI 宠物,将 Claude Code / Codex CLI 的会话生命周期映射到桌面状态。Swift 5.10 / macOS 14+ / SwiftPM。两个 executable target:Hopet(App)与 hopet-emit(hook 投递 CLI)。

1. 文档

  • 架构、状态机、优先级、hook 协议的事实之源在 DevDocs/。注释引用使用章节级指引,例如 See architecture.md §7.1
  • 注释解释意图与约束,不复述代码。
  • README 仅描述已实现能力。未实现项需明确标注。

2. Swift 代码风格

2.1 模块组织

源码位于 Sources/Hopet/,按职责分目录:

目录 职责
App/ NSApplication 入口、AppDelegate、菜单栏、SceneRouter
Core/ 状态机、聚合器、Session 注册表、日志、路径、计时器(纯逻辑、可单测)
Models/ 值类型、enum、Codable 数据结构
IPC/ Unix Domain Socket、长度前缀帧、hook 同步通道
HookKit/ Claude / Codex hook settings 的 merge 安装与卸载
Pet/ 桌面宠物 NSPanel、气泡布局与渲染、权限 / AskUser 交互
Notch/ 刘海条三态渲染与降级顶条
Panel/ 偏好面板 Tab 骨架
Theme/ 主题包、color token

新增文件应归入贴切的现有目录,不另起新层级。Sources/hopet-emit/ 为独立 CLI target,禁止反向依赖主 App 符号。

2.2 命名与可见性

  • 公共类型与 API 显式声明 public;模块内部默认 internal,省略关键字。
  • 工具与算法集合优先使用 caseless enum 作为命名空间,参考 HopetLogSessionStateMachineHopetPaths。不使用空 struct 或全局函数。
  • @MainActor 标注于面向 UI 的聚合器与控制器,参考 PetAggregator
  • 跨模块的异步状态使用 Combine PassthroughSubject / CurrentValueSubject,避免直接暴露 @Published

2.3 实现取舍

  • 不实现做不完整的功能,宁可移除。
  • 不为假想的未来需求引入抽象。三段相似代码优于一个早产的 protocol。
  • 错误处理仅在系统边界进行(用户输入、socket 解码、外部 settings 文件)。模块内部信任调用方,不写防御性 guard
  • 日志统一走 HopetLog。终端事件流追踪使用 HopetLog.trace(tag:_:),结构化日志使用 .info / .warn / .error。禁止使用 print

2.4 IPC 与 Hook 协议

  • 跨进程消息统一使用长度前缀 JSON 帧,编解码集中在 IPC/。业务代码不得自行拼装字节。
  • 新增 hook 字段需先更新 DevDocs/hooks-and-priority.md 字段表,再修改 hopet-emit 的 flag 解析与 HookKit 的 settings merge。代码与文档同 PR 提交。
  • Permission Allow/Deny 与 AskUserQuestion 同步回包是协议级承诺。修改这两条路径需保留跨终端宿主兼容性。

Read the full file on GitHub · 212 lines

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 · 212 lines · 3,103 tokens per session scan A 6c387c501f01

Subscribe to this mod's changes

Hopet AGENTS.md is an instructions file published in the GitHub repository BinaryFroggy/Hopet (63 stars, last pushed 1mo ago), licensed MIT. It adds 3,103 tokens to every session, about $0.0155 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.