cups-web AGENTS.md

A developer guide for CUPS Web, a web application that manages printing through CUPS, the common Unix printing system. It documents the Go backend, Vue frontend, APIs, deployment options, and supporting tools.

In plain words
What is it for?
Use it when changing the web interface, print management backend, PDF or document conversion, Docker setup, printer drivers, or CUPS and IPP integration.
Why use it?
It gives agents the project's architecture and development rules in one place, while directing deeper explanations and historical decisions to the documentation folder.

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/hanxi/cups-web/agents-md
Clone the repo
git clone --depth 1 https://github.com/hanxi/cups-web

Made for: Codex, OpenCode.

Per session 10,141 This file is loaded in full into every session.
When invoked 10,141 The same file — it is already loaded in full.
Security scan C 2 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.10141 $0.10141
Opus 5 $0.05071 $0.05071
Sonnet 5 $0.02028 $0.02028
Haiku 4.5 $0.01014 $0.01014

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

Security

Grade C, and why

cups-web AGENTS.md scanned grade C with 2 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

> ⚠️ 编译型脚本**只允许一个 `trap _cleanup EXIT`**(bash 同信号只保留最后注册的 handler)。AIO 模式下只 `apt-get clean`,**绝不 `rm -rf /var/lib/apt/lists/*`**。详见 [docs/driver-management.md](docs/driver-management.md#-aio-编译脚本的单一-exit-trap约定)。

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

> 🚨 `cups-builder` 的 `ca-certificates` 请勿删除(wget TLS 校验,删了 CI 直接崩)。
AGENTS.md · 494 lines

How it starts

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

CUPS Web 开发者指南

本文档面向开发者,介绍项目架构、API、开发流程与扩展方式。用户文档请参阅 README.md

📚 深度文档:原理说明、故障案例与历史决策已移至 docs/,本文件只保留可快速扫读的规则与契约。

📦 项目概述

  • 项目定位:基于 CUPS 的 Web 打印管理工具,前后端分离
  • 技术栈:Go 1.26(后端)+ Vue 3(前端)+ SQLite(存储)+ IPP(打印协议)
  • 部署形态:单二进制(前端 go:embed)连接外部 CUPS;单容器(AIO)Docker 镜像cupsd + cups-web 同容器,内置 LibreOffice + Java 21 + OFD 转换器 + Ghostscript + 打印驱动生态)

⚠️ 历史形态提示:仓库曾经是「cups 镜像 + cups-web 镜像」双容器(cups/ 目录),已在合并提交里删除。现在只有根目录的一份 Dockerfile / entrypoint.sh,构建脚本在 scripts/build/、驱动脚本在 scripts/driver/

🛠️ 技术栈

后端

组件 说明
Go 1.26 go.mod
gorilla/mux HTTP 路由
gorilla/securecookie 会话管理
modernc.org/sqlite 纯 Go SQLite,无 CGO
OpenPrinting/goipp IPP 协议
rsc.io/pdf + phpdave11/gofpdf PDF 解析 / 生成
golang.org/x/image/draw 大图下采样(CatmullRom)
golang.org/x/crypto/bcrypt 密码哈希

前端

组件 说明
Vue 3.5 + Vue Router hash 模式
Vite 7 构建
@nuxt/ui v4 + Tailwind CSS v4 UI / 样式
pdfjs-dist 预览(PDF 生成由后端 /api/convert 负责)
Bun(本地)/ npm(CI + Docker) 包管理。npm 用于覆盖 linux/arm/v7(Bun 不支持 32-bit ARM)

外部依赖

CUPS(IPP 通信)、LibreOffice(Office → PDF)、Java 21 + ofd-converter.jar(OFD → PDF)、Ghostscript(PDF 标准化)、dpkg/apt-get(运行时驱动安装)。

各依赖的坑位说明(LibreOffice 可写 HOME、gs 字体破坏性改造、runtime 无 dpkg-dev)见 docs/architecture.md

📁 项目结构

cups-web/
├── cmd/server/                    # 后端主程序
│   ├── main.go                    # 入口与路由注册
│   ├── app.go                     # 全局变量
│   ├── bootstrap.go               # 默认 admin 初始化
│   ├── auth_handlers.go           # 登录 / 登出 / session / csrf
│   ├── login_limiter.go           # 登录失败限流
│   ├── admin_handlers.go          # 管理员:用户 / 设置 / 清理
│   ├── user_handlers.go           # /api/me
│   ├── print_handlers.go          # /api/print(主打印入口)
│   ├── print_records_handlers.go  # 打印记录查询 / 下载 / 重打
│   ├── printer_info_handler.go    # 打印机属性查询
│   ├── convert_handler.go         # /api/convert
│   ├── convert_utils.go           # LibreOffice / OFD 转换工具
│   ├── compose_handler.go         # /api/compose(多页拼版)
│   ├── estimate_handler.go        # /api/estimate(预估页数)
│   ├── driver_handlers.go         # /api/admin/drivers/* + 后台任务
│   ├── driver_registry.go         # 驱动注册表
│   ├── file_utils.go              # 文件保存 / 类型识别 / 页数
│   ├── pdf_utils.go               # 图片 / 文本 → PDF
│   ├── pdf_compose.go             # 多页拼版
│   ├── pdf_reorder.go             # 页序重排 + 测试
│   ├── watermark.go               # 水印
│   ├── pdf_normalize.go           # PDF 标准化管线
│   ├── fonts.go                   # 中文字体加载
│   ├── maintenance.go             # 后台维护任务
│   └── version.go                 # 构建期版本号
├── internal/
│   ├── auth/session.go            # securecookie 会话 + CSRF
│   ├── middleware/                 # csrf / security 中间件
│   ├── ipp/                       # IPP 客户端 + URI 校验
│   ├── server/static.go           # 静态资源嵌入(SPA fallback)
│   └── store/                     # 数据层(users / prints / settings)
├── frontend/                      # Vue 3 前端(go:embed dist)
├── ofd-converter/                 # Java OFD → PDF
├── scripts/
│   ├── build/install-cups.sh      # 源码编译 CUPS
│   └── driver/                    # 驱动管理命令 + 安装脚本 + capture-debs.sh(apt 钩子)
├── docker-fonts/                  # 构建期字体与 gs/fontconfig 配置
├── entrypoint.sh                  # AIO 容器启动脚本
├── Dockerfile                     # 五阶段构建
├── docker-compose.yml             # 单服务 AIO
└── Makefile                       # 构建脚本

Read the full file on GitHub · 494 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. 3d ago First seen · 494 lines · 10,141 tokens per session scan C 8bb1b79d72d6

Subscribe to this mod's changes

cups-web AGENTS.md is an instructions file published in the GitHub repository hanxi/cups-web (1,253 stars, last pushed 8d ago), licensed MIT. It adds 10,141 tokens to every session, about $0.0507 per session on Opus 5. A static security scan graded it C with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.