Skill 资源参考
这是 Agent Skill 附带的 references/resources.md(英文原文,随仓库更新),Agent 在收到工作空间资源地址或 AI 修改提示词时读取它。中文的完整接口约定见 本机资源 API。
Default origin: http://127.0.0.1:8772; use the origin supplied by the user when different. GET /api/resources lists registered IDs, type, file, page URL and API URL. GET does not register or edit anything.
For a chosen resource, GET /api/resources/ID returns revision, the resource-only Markdown source, and document.blocks[0]. Indices are zero-based and valid only for that snapshot. /?resource=ID opens the standalone UI. GET /api/resources/ID/prompt returns type-specific instructions without embedding stale indices or revisions.
Send JSON to POST /api/resources/ID/preview for a diff, then the same payload to POST /api/resources/ID to save. Both need the latest revision. Save returns the new snapshot and revision; use that new revision for subsequent actions and recheck indices. HTTP 409 means the whole source file changed, including changes to another block: reread and reassess. Do not fall back to a broader document write or another resource. HTTP 422 is invalid input; 404 is a missing resource.
Lists and tasks
Read items: each entry has text, body and done. The write field for the title is title, not text. done: null is an ordinary entry or memo, false an open task and true a completed task. A list may contain both notes and tasks. Nested lists stay read-only.
| action | Additional JSON fields |
|---|---|
| item_add | title, body, done |
| item_set | index, title, body, done |
| item_delete | index |
| toggle | index, done (boolean, existing task only) |
Example body: {"action":"item_add","revision":"SHA256_FROM_GET","title":"Review release","body":"Check the package in a clean directory.","done":false}. The title is one line, 1–300 characters; body may be empty or multiline, at most 20000 characters. Deleting the final entry preserves an empty resource at the same address.
Tables
Read columns and rows. Values are complete scalar arrays in current column order; preserve primary keys and explicit types.
| action | Additional JSON fields |
|---|---|
| row_add | values |
| row_set | index, values |
| row_delete | index |
| column_add | name |
Only add fields when requested. Empty string becomes NULL on the next read. Raw edit(content) is available to restore the same kind of resource; use structured operations for routine edits.
Register an existing block
Registration adds a stable <!-- mddb:block id=... --> comment to Markdown. When authorized to manage an unregistered block, GET /api/document?name=FILE.md, then POST /api/resources with file, its latest revision, and optionally a block ID to register only that block. Omitting block registers all supported blocks in the file. Newly added blocks already have IDs. Existing IDs follow their blocks through preceding insertions or file renames; copied duplicate IDs are rejected.
POST uses Content-Type: application/json. Resource actions must not include file, block, paths or SQL. Registration is the separate endpoint described above. The local service has no account permissions or network sharing contract.