apple-notes
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseapple-notes — manage Apple Notes locally via AppleScript
apple-notes — 通过 AppleScript 本地管理 Apple Notes
Drives the user's real Apple Notes through on macOS. Apple never
shipped a cloud API for Notes, so there is nothing to OAuth into and no token to
inject — this skill runs on the user's own Mac and talks to Notes.app with
AppleScript (). It works wherever an agent runs on macOS: the
AceDataCloud desktop app (which executes local tools / local MCP on the
user's Mac), Claude Code on macOS, or a CodingBridge node on the user's Mac.
Notes.apposascriptin the frontmatter marks this skill as macOS-desktop only — it cannot run on the web / iOS / Android / Windows surfaces (there is no localsurfaces: [mac]there). The skill/connector directory UI reads this to badge the card ("macOS desktop") and steer users to install it from the macOS desktop app. AbsentNotes.app, a skill is assumed available everywhere.surfaces
The skill ships — self-contained, Python
standard library only (it shells out to ; no , no
). Dynamic values are passed as environment variables, never interpolated
into the AppleScript source, so note content can't break the script or inject
commands.
scripts/notes.pyosascriptpip installbrew通过 macOS 上的 操作用户的真实Apple Notes。苹果从未为 Notes 推出云 API,因此无需进行 OAuth 授权,也无需注入令牌 —— 该技能在用户自己的 Mac上运行,通过 AppleScript()与 Notes.app 交互。只要 Agent 在 macOS 上运行,它就能正常工作:比如AceDataCloud 桌面应用(在用户 Mac 上执行本地工具/本地 MCP)、macOS 版 Claude Code,或是用户 Mac 上的 CodingBridge 节点。
Notes.apposascript在前置元数据中标记此技能为仅支持 macOS 桌面端 —— 无法在网页/iOS/Android/Windows 平台运行(这些平台没有本地surfaces: [mac])。技能/连接器目录 UI 会读取此标记,为卡片添加“macOS 桌面端”标识,并引导用户从 macOS 桌面应用安装该技能。如果没有Notes.app标记,则默认该技能可在所有平台使用。surfaces
该技能附带 —— 一个独立的 Python 脚本,仅依赖 Python 标准库(它通过调用 执行操作;无需 ,无需 安装依赖)。动态值通过环境变量传递,绝不会直接插入到 AppleScript 源码中,因此笔记内容不会破坏脚本或注入恶意命令。
scripts/notes.pyosascriptpip installbrewRequirements
要求
- macOS with the Notes app. (system Python is fine).
python3 - Automation permission. The first call triggers a macOS prompt: "Terminal wants to control Notes." Approve it, or enable it under System Settings › Privacy & Security › Automation › (your terminal / agent) › Notes. On an authorization error the CLI tells the user exactly this — do not loop-retry.
- Referencing Notes launches the app in the background (no window is forced open).
sh
NOTES="${SKILL_DIR:-.}/scripts/notes.py" # run from this skill's directory
python3 "$NOTES" folders # smoke-test the connection- macOS 系统,且已安装 Notes 应用。需具备 (系统自带的 Python 即可)。
python3 - 自动化权限。首次调用时会触发 macOS 提示:“终端想要控制 Notes。” 请批准该请求,或在系统设置 › 隐私与安全性 › 自动化 ›(你的终端/Agent)› Notes中启用权限。如果出现授权错误,CLI 会明确告知用户上述操作步骤 —— 请勿循环重试。
- 调用相关操作时会在后台启动 Notes 应用(不会强制打开应用窗口)。
sh
NOTES="${SKILL_DIR:-.}/scripts/notes.py" # 从该技能的目录运行
python3 "$NOTES" folders # 测试连接是否正常Commands
命令
| Command | Read/Write | Purpose |
|---|---|---|
| read | List folders with note counts |
| read | List notes (newest first): id, title, folder, dates |
| read | Case-insensitive substring match on title + body |
| read | Show one note (metadata + body) |
| read | Export one note to Markdown/HTML/text |
| write | Create a note |
| write | Append text to an existing note |
| write | Move a note to another folder |
| write | Create a folder |
| write | Move a note to Recently Deleted (recoverable) |
Most commands print JSON (and errors are always JSON: ). The
exceptions print raw note content to stdout: and
without . is the opaque id returned by
/ — always fetch a fresh id first; do not guess one.
{"error": ...}view --format text|htmlexport-oNOTE_IDx-coredata://…listsearch| 命令 | 读写权限 | 用途 |
|---|---|---|
| 只读 | 列出所有文件夹及其中的笔记数量 |
| 只读 | 列出笔记(按最新排序):ID、标题、文件夹、日期 |
| 只读 | 对标题和正文进行不区分大小写的子串匹配搜索 |
| 只读 | 查看单条笔记(元数据 + 正文) |
| 只读 | 将单条笔记导出为 Markdown/HTML/纯文本格式 |
| 可写 | 创建一条笔记 |
| 可写 | 向现有笔记追加文本 |
| 可写 | 将笔记移动到另一个文件夹 |
| 可写 | 创建新文件夹 |
| 可写 | 将笔记移动到“最近删除”文件夹(可恢复) |
大多数命令会输出 JSON 格式内容(错误信息始终为 JSON 格式:)。例外情况是: 和不带 参数的 命令会将笔记原始内容输出到标准输出。 是 / 命令返回的不透明格式 ID —— 请始终先获取最新的 ID;切勿猜测。
{"error": ...}view --format text|html-oexportNOTE_IDlistsearchx-coredata://…Read examples
读取操作示例
sh
python3 "$NOTES" folders
python3 "$NOTES" list --limit 20
python3 "$NOTES" list --folder "Work" --limit 50
python3 "$NOTES" search "invoice" --limit 20
python3 "$NOTES" view "x-coredata://…/p42"
python3 "$NOTES" export "x-coredata://…/p42" --format md -o note.mdsh
python3 "$NOTES" folders
python3 "$NOTES" list --limit 20
python3 "$NOTES" list --folder "Work" --limit 50
python3 "$NOTES" search "invoice" --limit 20
python3 "$NOTES" view "x-coredata://…/p42"
python3 "$NOTES" export "x-coredata://…/p42" --format md -o note.mdWrites are GATED (dry-run unless trailing --confirm
)
--confirm写入操作需确认(未添加 --confirm
则为试运行)
--confirmcreateappendmovenew-folderdelete--confirm--confirm--confirmsh
undefinedcreateappendmovenew-folderdelete--confirm--confirm--confirmsh
undefinedCreate — dry-run, then confirm
创建笔记 —— 先试运行,再确认
python3 "$NOTES" create --title "Groceries" --body "milk\neggs" # preview
python3 "$NOTES" create --title "Groceries" --body "milk\neggs" --confirm # writes
python3 "$NOTES" create --title "Groceries" --body "milk\neggs" # 预览操作
python3 "$NOTES" create --title "Groceries" --body "milk\neggs" --confirm # 执行写入
Create in a folder, body from a file
在指定文件夹创建笔记,正文来自文件
python3 "$NOTES" create --title "Spec" --body-file draft.md --folder "Work" --confirm
python3 "$NOTES" create --title "Spec" --body-file draft.md --folder "Work" --confirm
Append to an existing note
向现有笔记追加内容
python3 "$NOTES" append "x-coredata://…/p42" --body "one more line" --confirm
python3 "$NOTES" append "x-coredata://…/p42" --body "one more line" --confirm
Move / organize
移动/整理笔记
python3 "$NOTES" new-folder "Archive" --confirm
python3 "$NOTES" move "x-coredata://…/p42" --folder "Archive" --confirm
python3 "$NOTES" new-folder "Archive" --confirm
python3 "$NOTES" move "x-coredata://…/p42" --folder "Archive" --confirm
Delete → goes to Recently Deleted (recoverable ~30 days)
删除笔记 → 移至“最近删除”文件夹(约30天内可恢复)
python3 "$NOTES" delete "x-coredata://…/p42" --confirm
Content is treated as **plain text** (each line becomes a paragraph; the
`--title` is the note's first line, which Notes shows as the title). HTML in the
input is escaped, so it can't inject markup. Use `\n` for line breaks in
`--body`, or pass a file with `--body-file`.python3 "$NOTES" delete "x-coredata://…/p42" --confirm
内容会被视为**纯文本**(每一行会成为一个段落;`--title` 参数指定的内容会作为笔记的第一行,Notes 应用会将其显示为标题)。输入中的 HTML 会被转义,因此无法注入标记。在 `--body` 参数中使用 `\n` 表示换行,或通过 `--body-file` 参数传入文件内容。Gotchas
注意事项
- This is the user's real Notes account. Confirm before any write.
- scans the whole library — for large accounts it can take a few seconds. Narrow with
list, and cap with--folder(default 50).--limitfilters inside Notes and is faster.search - Attachments / images: notes containing images or attachments can be read
and exported as text, but may not preserve embedded attachments — avoid editing attachment notes here; open them in Notes instead.
append - Export → Markdown converts common Notes formatting (headings, bold/italic, lists, links, line breaks). Rich objects (tables, drawings, scanned docs) degrade to plain text.
- stays within one account (e.g. iCloud). Cross-account moves fail.
move - Never assume a — ids are store-specific; always get them from
NOTE_ID/listfirst.search - On a persistent authorization error, the Automation permission is missing — tell the user to grant it (see Requirements) and stop; do not retry in a loop.
- 操作的是用户真实的 Notes 账户。执行任何写入操作前请确认。
- 命令会扫描整个笔记库 —— 对于笔记数量较多的账户,可能需要几秒时间。可通过
list参数缩小范围,并通过--folder参数限制结果数量(默认50条)。--limit命令在 Notes 内部进行过滤,速度更快。search - 附件/图片:包含图片或附件的笔记可以被读取并导出为文本,但 操作可能无法保留嵌入式附件 —— 请避免在此处编辑包含附件的笔记;建议直接在 Notes 应用中打开编辑。
append - 导出为 Markdown:会转换 Notes 中的常见格式(标题、粗体/斜体、列表、链接、换行)。复杂对象(表格、绘图、扫描文档)会降级为纯文本。
- 命令仅支持同一账户内移动(例如 iCloud 账户内)。跨账户移动会失败。
move - 切勿假设 固定不变 —— ID 与存储位置相关;请始终通过
NOTE_ID/list命令获取最新的 ID。search - 如果持续出现授权错误,说明缺少自动化权限 —— 告知用户授予权限(参见“要求”部分)并停止操作;请勿循环重试。