From 063b6be2b1ac64d54a31f4304d3361be5a53641d Mon Sep 17 00:00:00 2001 From: Dream Hunter Date: Wed, 22 Apr 2026 00:35:04 +0800 Subject: [PATCH] Refactor delete setting helper and link skills (#994) * refactor: add deleteSetting helper and link skills * chore: reorganize project skills layout * docs: update skill paths * chore: add AGENTS link and prune skill links * chore: localize agent skill links --- .agents/skills/cf-temp-mail-agent-mail | 1 + .agents/skills/cf-temp-mail-upgrade-dependencies | 1 + .agents/skills/cf-temp-mail-version-upgrade | 1 + .claude/skills/cf-temp-mail-agent-mail | 1 + AGENTS.md | 1 + CHANGELOG.md | 2 +- CHANGELOG_EN.md | 2 +- README.md | 2 +- README_EN.md | 2 +- .../skills => skills}/cf-temp-mail-agent-mail/SKILL.md | 0 vitepress-docs/docs/en/guide/feature/agent-email.md | 8 ++++---- vitepress-docs/docs/zh/guide/feature/agent-email.md | 8 ++++---- worker/src/admin_api/account_settings_api.ts | 6 ++---- worker/src/utils.ts | 10 ++++++++++ 14 files changed, 29 insertions(+), 16 deletions(-) create mode 120000 .agents/skills/cf-temp-mail-agent-mail create mode 120000 .agents/skills/cf-temp-mail-upgrade-dependencies create mode 120000 .agents/skills/cf-temp-mail-version-upgrade create mode 120000 .claude/skills/cf-temp-mail-agent-mail create mode 120000 AGENTS.md rename {.claude/skills => skills}/cf-temp-mail-agent-mail/SKILL.md (100%) diff --git a/.agents/skills/cf-temp-mail-agent-mail b/.agents/skills/cf-temp-mail-agent-mail new file mode 120000 index 00000000..8ef3a7f9 --- /dev/null +++ b/.agents/skills/cf-temp-mail-agent-mail @@ -0,0 +1 @@ +../../skills/cf-temp-mail-agent-mail \ No newline at end of file diff --git a/.agents/skills/cf-temp-mail-upgrade-dependencies b/.agents/skills/cf-temp-mail-upgrade-dependencies new file mode 120000 index 00000000..42fd711b --- /dev/null +++ b/.agents/skills/cf-temp-mail-upgrade-dependencies @@ -0,0 +1 @@ +../../.claude/skills/cf-temp-mail-upgrade-dependencies \ No newline at end of file diff --git a/.agents/skills/cf-temp-mail-version-upgrade b/.agents/skills/cf-temp-mail-version-upgrade new file mode 120000 index 00000000..c9824a15 --- /dev/null +++ b/.agents/skills/cf-temp-mail-version-upgrade @@ -0,0 +1 @@ +../../.claude/skills/cf-temp-mail-version-upgrade \ No newline at end of file diff --git a/.claude/skills/cf-temp-mail-agent-mail b/.claude/skills/cf-temp-mail-agent-mail new file mode 120000 index 00000000..8ef3a7f9 --- /dev/null +++ b/.claude/skills/cf-temp-mail-agent-mail @@ -0,0 +1 @@ +../../skills/cf-temp-mail-agent-mail \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 120000 index 00000000..681311eb --- /dev/null +++ b/AGENTS.md @@ -0,0 +1 @@ +CLAUDE.md \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b03c02d7..8fac25f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ ### Features - feat: |API| 新增服务端解析邮件接口 `/api/parsed_mails` 与 `/api/parsed_mail/:id`,直接返回 `sender` / `subject` / `text` / `html` / `attachments` 元信息(复用 `commonParseMail`),AI agent 侧不再需要引入 MIME 解析器 -- feat: |Skill| 新增仓库内置只读 skill `cf-temp-mail-agent-mail`(`.claude/skills/cf-temp-mail-agent-mail/`),让 OpenClaw / Codex / Cursor 等 AI agent 凭用户提供的 Address JWT + API 地址读取邮箱、轮询验证码,绕开创建邮箱时的 Turnstile 人机验证;可通过 `npx degit dreamhunter2333/cloudflare_temp_email/.claude/skills/cf-temp-mail-agent-mail` 安装 +- feat: |Skill| 新增仓库内置只读 skill `cf-temp-mail-agent-mail`(`skills/cf-temp-mail-agent-mail/`),让 OpenClaw / Codex / Cursor 等 AI agent 凭用户提供的 Address JWT + API 地址读取邮箱、轮询验证码,绕开创建邮箱时的 Turnstile 人机验证;可通过 `npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail` 安装 - docs: |文档| 新增"AI Agent 使用邮箱"文档(`guide/feature/agent-email`),说明 `parsed_mail` API 用法,并在 parsed API 不可用时给出对齐前端的 `mail-parser-wasm` + `postal-mime` 本地解析回退方案 ### Bug Fixes diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index b8dfca16..c6d831e1 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -11,7 +11,7 @@ ### Features - feat: |API| Add server-side parsed-mail endpoints `/api/parsed_mails` and `/api/parsed_mail/:id` that return `sender` / `subject` / `text` / `html` / `attachments` metadata directly (reuses `commonParseMail`), so AI agents no longer need a client-side MIME parser -- feat: |Skill| Bundle a read-only skill `cf-temp-mail-agent-mail` (`.claude/skills/cf-temp-mail-agent-mail/`) so AI agents like OpenClaw / Codex / Cursor can consume a mailbox with a user-supplied Address JWT + API base URL — list mails, poll verification codes, etc. — sidestepping the Turnstile challenge required to create a mailbox. Install via `npx degit dreamhunter2333/cloudflare_temp_email/.claude/skills/cf-temp-mail-agent-mail` +- feat: |Skill| Bundle a read-only skill `cf-temp-mail-agent-mail` (`skills/cf-temp-mail-agent-mail/`) so AI agents like OpenClaw / Codex / Cursor can consume a mailbox with a user-supplied Address JWT + API base URL — list mails, poll verification codes, etc. — sidestepping the Turnstile challenge required to create a mailbox. Install via `npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail` - docs: |Docs| Add "AI Agent Mailbox Usage" doc (`guide/feature/agent-email`) covering the `parsed_mail` API and a local-parse fallback using `mail-parser-wasm` + `postal-mime` (mirrors the frontend) when parsed endpoints are unavailable ### Bug Fixes diff --git a/README.md b/README.md index a58900c5..4b3d35c8 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ - [x] Webhook 支持,消息推送集成 - [x] 支持 `CF Turnstile` 人机验证 - [x] 限流配置,防止滥用 -- [x] **Agent 友好**:内置 [`cf-temp-mail-agent-mail`](.claude/skills/cf-temp-mail-agent-mail/SKILL.md) skill,AI agent 可直接消费邮箱,详见 [文档](vitepress-docs/docs/zh/guide/feature/agent-email.md) +- [x] **Agent 友好**:内置 [`cf-temp-mail-agent-mail`](skills/cf-temp-mail-agent-mail/SKILL.md) skill,AI agent 可直接消费邮箱,详见 [文档](vitepress-docs/docs/zh/guide/feature/agent-email.md) diff --git a/README_EN.md b/README_EN.md index b598cd7b..5468ea4e 100644 --- a/README_EN.md +++ b/README_EN.md @@ -150,7 +150,7 @@ Try it now → [https://mail.awsl.uk/](https://mail.awsl.uk/) - [x] Webhook support and message push integration - [x] Support `CF Turnstile` CAPTCHA verification - [x] Rate limiting configuration to prevent abuse -- [x] **Agent-friendly**: bundled [`cf-temp-mail-agent-mail`](.claude/skills/cf-temp-mail-agent-mail/SKILL.md) skill lets AI agents consume a mailbox directly, see [docs](vitepress-docs/docs/en/guide/feature/agent-email.md) +- [x] **Agent-friendly**: bundled [`cf-temp-mail-agent-mail`](skills/cf-temp-mail-agent-mail/SKILL.md) skill lets AI agents consume a mailbox directly, see [docs](vitepress-docs/docs/en/guide/feature/agent-email.md) diff --git a/.claude/skills/cf-temp-mail-agent-mail/SKILL.md b/skills/cf-temp-mail-agent-mail/SKILL.md similarity index 100% rename from .claude/skills/cf-temp-mail-agent-mail/SKILL.md rename to skills/cf-temp-mail-agent-mail/SKILL.md diff --git a/vitepress-docs/docs/en/guide/feature/agent-email.md b/vitepress-docs/docs/en/guide/feature/agent-email.md index 19a38a9e..4a88d760 100644 --- a/vitepress-docs/docs/en/guide/feature/agent-email.md +++ b/vitepress-docs/docs/en/guide/feature/agent-email.md @@ -184,7 +184,7 @@ For attachment bytes, use `postal-mime` directly — `parsed.attachments[i].cont ## `cf-temp-mail-agent-mail` Skill -The repo ships an agent skill at `.claude/skills/cf-temp-mail-agent-mail/` that wraps the flow above. Works with Claude Code / Cursor / Codex / OpenClaw and other agents. +The repo ships an agent skill at `skills/cf-temp-mail-agent-mail/` that wraps the flow above. Works with Claude Code / Cursor / Codex / OpenClaw and other agents. Pick any install method: @@ -195,14 +195,14 @@ npx skills add dreamhunter2333/cloudflare_temp_email --skill cf-temp-mail-agent- npx skills add dreamhunter2333/cloudflare_temp_email --skill cf-temp-mail-agent-mail -g # Option 2: npx degit to copy into your agent's skills folder -npx degit dreamhunter2333/cloudflare_temp_email/.claude/skills/cf-temp-mail-agent-mail /cf-temp-mail-agent-mail +npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail /cf-temp-mail-agent-mail # Option 3: clone and copy git clone --depth 1 https://github.com/dreamhunter2333/cloudflare_temp_email.git /tmp/cf-temp-mail -cp -r /tmp/cf-temp-mail/.claude/skills/cf-temp-mail-agent-mail / +cp -r /tmp/cf-temp-mail/skills/cf-temp-mail-agent-mail / ``` -See [SKILL.md](https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/.claude/skills/cf-temp-mail-agent-mail/SKILL.md) for details. +See [SKILL.md](https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/skills/cf-temp-mail-agent-mail/SKILL.md) for details. ## Common errors diff --git a/vitepress-docs/docs/zh/guide/feature/agent-email.md b/vitepress-docs/docs/zh/guide/feature/agent-email.md index a2bdf1f1..bf1d3353 100644 --- a/vitepress-docs/docs/zh/guide/feature/agent-email.md +++ b/vitepress-docs/docs/zh/guide/feature/agent-email.md @@ -184,7 +184,7 @@ const parsed = await parseRaw(row.raw); ## `cf-temp-mail-agent-mail` Skill -仓库内置了 Agent 技能:`.claude/skills/cf-temp-mail-agent-mail/`,把上述流程封装成 AI Agent 可直接调用的形式,支持 Claude Code / Cursor / Codex / OpenClaw 等。 +仓库内置了 Agent 技能:`skills/cf-temp-mail-agent-mail/`,把上述流程封装成 AI Agent 可直接调用的形式,支持 Claude Code / Cursor / Codex / OpenClaw 等。 安装方式任选其一: @@ -195,14 +195,14 @@ npx skills add dreamhunter2333/cloudflare_temp_email --skill cf-temp-mail-agent- npx skills add dreamhunter2333/cloudflare_temp_email --skill cf-temp-mail-agent-mail -g # 方式 2:npx degit 拷贝到你的 agent skills 目录 -npx degit dreamhunter2333/cloudflare_temp_email/.claude/skills/cf-temp-mail-agent-mail /cf-temp-mail-agent-mail +npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail /cf-temp-mail-agent-mail # 方式 3:克隆后复制 git clone --depth 1 https://github.com/dreamhunter2333/cloudflare_temp_email.git /tmp/cf-temp-mail -cp -r /tmp/cf-temp-mail/.claude/skills/cf-temp-mail-agent-mail / +cp -r /tmp/cf-temp-mail/skills/cf-temp-mail-agent-mail / ``` -详情见 [SKILL.md](https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/.claude/skills/cf-temp-mail-agent-mail/SKILL.md)。 +详情见 [SKILL.md](https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/skills/cf-temp-mail-agent-mail/SKILL.md)。 ## 常见错误 diff --git a/worker/src/admin_api/account_settings_api.ts b/worker/src/admin_api/account_settings_api.ts index cf7acdc2..c340f8c0 100644 --- a/worker/src/admin_api/account_settings_api.ts +++ b/worker/src/admin_api/account_settings_api.ts @@ -1,7 +1,7 @@ import { Context } from 'hono' import i18n from '../i18n' -import { getJsonSetting, saveSetting } from '../utils' +import { deleteSetting, getJsonSetting, saveSetting } from '../utils' import { getAddressCreationSettings, getAddressCreationSubdomainMatchStatus } from '../common' import { CONSTANTS } from '../constants' import { @@ -109,9 +109,7 @@ const save = async (c: Context) => { await saveSetting(c, CONSTANTS.EMAIL_RULE_SETTINGS_KEY, JSON.stringify(emailRuleSettings || {})); if (addressCreationSettingsUpdate.shouldUpdate) { if (addressCreationSettingsUpdate.shouldClear) { - await c.env.DB.prepare( - `DELETE FROM settings WHERE key = ?` - ).bind(CONSTANTS.ADDRESS_CREATION_SETTINGS_KEY).run(); + await deleteSetting(c, CONSTANTS.ADDRESS_CREATION_SETTINGS_KEY); } else { await saveSetting( c, CONSTANTS.ADDRESS_CREATION_SETTINGS_KEY, diff --git a/worker/src/utils.ts b/worker/src/utils.ts index 5759961b..9cd278bf 100644 --- a/worker/src/utils.ts +++ b/worker/src/utils.ts @@ -64,6 +64,16 @@ export const saveSetting = async ( return true; } +export const deleteSetting = async ( + c: Context, + key: string +) => { + await c.env.DB.prepare( + `DELETE FROM settings WHERE key = ?` + ).bind(key).run(); + return true; +} + export const getStringValue = (value: any): string => { if (typeof value === "string") { return value;