ima_skills_yc

v1.0.0

IMA 个人笔记服务 API skill,用于管理用户的 IMA 笔记。支持搜索笔记、浏览笔记本、获取笔记内容、新建笔记和追加内容。 当用户提到笔记、备忘录、记事、知识库,或者想要查找、阅读、创建、编辑笔记内容时,使用此 skill。 即使用户没有明确说"笔记",只要意图涉及个人文档的存取(如"帮我记一下"、"我...

1· 1.3k·49 current·50 all-time
bychang yang@laineyboy

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for laineyboy/ima.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "ima_skills_yc" (laineyboy/ima) from ClawHub.
Skill page: https://clawhub.ai/laineyboy/ima
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Required env vars: IMA_OPENAPI_CLIENTID, IMA_OPENAPI_APIKEY
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install ima

ClawHub CLI

Package manager switcher

npx clawhub@latest install ima
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description map cleanly to the requested env vars (IMA_OPENAPI_CLIENTID, IMA_OPENAPI_APIKEY) and the documented ima.qq.com OpenAPI endpoints. Nothing required by the skill appears unrelated to managing IMA notes.
Instruction Scope
SKILL.md contains explicit runtime instructions (curl wrapper, env-var precheck, workflows for search/list/get/import/append). It also shows examples for reading and re-encoding local files using python3/node/iconv; those are reasonable for importing external text but do mean the agent's runtime may read local temporary files when the user asks to import content. Instructions limit external endpoints to ima.qq.com and include a privacy rule about not exposing full note bodies in group contexts.
Install Mechanism
No install spec and no code files — instruction-only skill. This minimizes the disk/write footprint and there is no download of third-party code or archives.
Credentials
Only two environment variables are required (clientid and apikey), which match the API's authentication scheme and are appropriate for the described functionality. The primaryEnv is set correctly. Note: SKILL.md suggests adding exports to ~/.bashrc or ~/.zshrc which persists keys on the host — a usability suggestion but not a technical requirement of the skill.
Persistence & Privilege
always is false and the skill does not request permanent system privileges or modify other skills. It can be invoked by the agent (normal behavior) but has no elevated persistence mechanisms.
Assessment
This skill appears to do what it says: call the IMA note OpenAPI using two API credentials. Before installing, consider: 1) Only provide IMA_OPENAPI_CLIENTID and IMA_OPENAPI_APIKEY if you trust the ima.qq.com service and the environment running the agent. 2) Avoid storing long-lived API keys in shell rc files on shared machines; consider using a secure secrets store or ephemeral credentials if available. 3) The skill's examples run local commands (python3/node/iconv) to normalize text files for import — if you import files, be aware the agent may read those temporary files. 4) Confirm the Base URL (https://ima.qq.com/openapi/note/v1) is the correct official endpoint for your account. 5) Rotate and revoke the API key if you stop using the skill. If you want extra assurance, request an official SDK or signed release from the service rather than running ad-hoc curl commands.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

📝 Clawdis
EnvIMA_OPENAPI_CLIENTID, IMA_OPENAPI_APIKEY
Primary envIMA_OPENAPI_CLIENTID
latestvk971mj3t2gq04kaq5d12r0qy4n835v2a
1.3kdownloads
1stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

ima-note

通过 IMA OpenAPI 管理用户个人笔记,支持读取(搜索、列表、获取内容)和写入(新建、追加)。

完整的数据结构和接口参数详见 references/api.md

Setup

  1. 请打开 https://ima.qq.com/agent-interface 获取 Client IDApi Key
  2. 配置环境变量:
export IMA_OPENAPI_CLIENTID="your_client_id"
export IMA_OPENAPI_APIKEY="your_api_key"

建议将上述 export 语句写入 ~/.zshrc~/.bashrc,避免每次重开终端失效。

凭证预检

每次调用 API 前,先确认凭证可用。如果环境变量未设置,停止操作并提示用户按 Setup 步骤配置。

if [ -z "$IMA_OPENAPI_CLIENTID" ] || [ -z "$IMA_OPENAPI_APIKEY" ]; then
  echo "缺少 IMA 凭证,请按 Setup 步骤配置环境变量 IMA_OPENAPI_CLIENTID 和 IMA_OPENAPI_APIKEY"
  exit 1
fi

API 调用模板

所有请求统一为 HTTP POST + JSON Body,Base URL 为 https://ima.qq.com/openapi/note/v1

定义辅助函数避免重复 header:

ima_api() {
  local endpoint="$1" body="$2"
  curl -s -X POST "https://ima.qq.com/openapi/note/v1/$endpoint" \
    -H "ima-openapi-clientid: $IMA_OPENAPI_CLIENTID" \
    -H "ima-openapi-apikey: $IMA_OPENAPI_APIKEY" \
    -H "Content-Type: application/json" \
    -d "$body"
}

隐私规则: 笔记内容属于用户隐私,在群聊场景中只展示标题和摘要,禁止展示笔记正文。

接口决策表

用户意图调用接口关键参数
搜索/查找笔记search_note_bookquery_info(QueryInfo 对象)
查看笔记本列表list_note_folder_by_cursorcursor(必填,首页传"0") + limit(必填)
浏览某笔记本里的笔记,当用户表述"最新"、"最近"之类的通用限定,没有指明笔记本时,都应该直接在全部笔记里去拉list_note_by_folder_idfolder_id(选填,空为全部笔记本) + cursor(必填,首次传"") + limit(必填)
读取笔记正文get_doc_contentdoc_id + target_content_format(必填,推荐0纯文本)
新建一篇笔记import_doccontent + content_format(必填,固定1) + 可选 folder_id
往已有笔记追加内容append_docdoc_id + content + content_format(必填,固定1)

常用工作流

查找并阅读笔记

先搜索获取 docid,再用 get_doc_content 读取正文:

# 1. 按标题搜索
ima_api "search_note_book" '{"search_type": 0, "query_info": {"title": "会议纪要"}, "start": 0, "end": 20}'
# 从返回的 docs[].doc.basic_info.docid 中取目标笔记 ID

# 2. 读取正文(纯文本格式,Markdown 格式目前不支持)
ima_api "get_doc_content" '{"doc_id": "目标docid", "target_content_format": 0}'

浏览笔记本里的笔记

先拉笔记本列表获取 folder_id,再拉该笔记本下的笔记:

# 1. 列出笔记本(首页 cursor 传 "0")
ima_api "list_note_folder_by_cursor" '{"cursor": "0", "limit": 20}'

# 2. 拉取指定笔记本的笔记(首页 cursor 传 "")
ima_api "list_note_by_folder_id" '{"folder_id": "user_list_xxx", "cursor": "", "limit": 20}'

新建笔记

# 新建到默认位置
ima_api "import_doc" '{"content_format": 1, "content": "# 标题\n\n正文内容"}'

# 新建到指定笔记本
ima_api "import_doc" '{"content_format": 1, "content": "# 标题\n\n正文内容", "folder_id": "笔记本ID"}'
# 返回 doc_id,后续可用于 append_doc

追加内容到已有笔记

ima_api "append_doc" '{"doc_id": "笔记ID", "content_format": 1, "content": "\n## 补充内容\n\n追加的文本"}'

按正文搜索

ima_api "search_note_book" '{"search_type": 1, "query_info": {"content": "项目排期"}, "start": 0, "end": 20}'

核心响应字段

搜索结果SearchedDoc):笔记信息路径为 doc.basic_info(DocBasic),关键字段:docidtitlesummaryfolder_idfolder_namecreate_time(Unix 毫秒)、modify_timestatus。额外包含 highlight_info(高亮匹配,key 为 doc_title,value 含 <em>高亮词</em>)。

笔记本条目NoteBookFolder):信息路径为 folder.basic_info(NoteBookFolderBasic),关键字段:folder_idnamenote_numbercreate_timemodify_timefolder_type0=用户自建,1=全部笔记,2=未分类)、status

笔记列表条目NoteBookInfo):信息路径为 basic_info.basic_info(DocBasicInfo → DocBasic),关键字段:docidtitlesummaryfolder_idfolder_namecreate_timemodify_timestatus

写入结果import_doc/append_doc):返回 doc_id(新建或目标笔记的唯一 ID)。

完整字段定义见 references/api.md

分页

  • 游标分页 — 笔记本列表list_note_folder_by_cursor):首次 cursor: "0",后续用 next_cursoris_end=true 时停止。
  • 游标分页 — 笔记列表list_note_by_folder_id):首次 cursor: "",后续用 next_cursoris_end=true 时停止。
  • 偏移量分页search_note_book):首次 start: 0, end: 20,翻页时递增,is_end=true 时停止。

枚举值

  • content_format 0=纯文本,1=Markdown,2=JSON。写入(import_doc/append_doc)目前仅支持 1(Markdown)。读取(get_doc_content)推荐 0(纯文本),Markdown 格式不支持。
  • search_type 0=标题检索(默认),1=正文检索
  • sort_type 0=更新时间(默认),1=创建时间,2=标题,3=大小(仅 search_note_book 使用)
  • folder_type 0=用户自建,1=全部笔记(根目录),2=未分类

注意事项

  • folder_id 不可为 "0",根目录 ID 格式为 user_list_{userid}(从 folder_type=1 的笔记本条目获取)

  • 笔记内容有大小上限,超过时返回 100009,可拆分为多次 append_doc 写入

  • 展示笔记列表时只展示标题、摘要和修改时间,不要主动展示正文

  • 时间字段是 Unix 毫秒时间戳,展示时转为可读格式

  • 返回数据为嵌套结构:搜索结果取 docs[].doc.basic_info.docid,笔记本取 note_book_folders[].folder.basic_info.folder_id,笔记列表取 note_book_list[].basic_info.basic_info.docid,注意按层级解析

  • UTF-8 编码:内容写入前必须确保为 UTF-8 编码。当内容来自临时文件、WebFetch 或外部来源时,按运行环境选择合适的方式转码:

    Python(推荐,几乎所有环境都有):

    # 读取文件,自动检测编码并转为 UTF-8
    content=$(python3 -c "
    import sys
    data = open('tmpfile', 'rb').read()
    for enc in ['utf-8', 'gbk', 'gb2312', 'big5', 'latin-1']:
        try:
            sys.stdout.write(data.decode(enc))
            break
        except (UnicodeDecodeError, LookupError):
            continue
    " 2>/dev/null)
    
    # 如果内容已在变量中,清洗非法 UTF-8 字节
    content=$(printf '%s' "$content" | python3 -c "import sys; sys.stdout.write(sys.stdin.buffer.read().decode('utf-8','ignore'))")
    

    Node.js:

    content=$(node -e "const fs=require('fs');const buf=fs.readFileSync('tmpfile');process.stdout.write(buf.toString('utf8'))")
    # 已知编码(如 GBK):
    content=$(node -e "const fs=require('fs');process.stdout.write(new TextDecoder('gbk').decode(fs.readFileSync('tmpfile')))")
    

    Unix (macOS/Linux):

    content=$(iconv -f "$(file -b --mime-encoding tmpfile)" -t UTF-8 tmpfile 2>/dev/null || cat tmpfile)
    

    Windows PowerShell:

    # 读取非 UTF-8 文件并转码
    $content = [System.IO.File]::ReadAllText('tmpfile', [System.Text.Encoding]::Default)
    [System.IO.File]::WriteAllText('tmpfile.utf8', $content, [System.Text.Encoding]::UTF8)
    

    PowerShell 5.1 发送请求注意事项: Invoke-RestMethod 传入字符串 Body 时,默认使用系统 ANSI 编码(中文 Windows 为 GBK),而非 UTF-8,即使设置了 Content-Type: charset=utf-8 也无效。必须显式转为 UTF-8 字节数组再传入 -Body,同时使用 ConvertTo-Json 构建 JSON 以避免手动拼接的转义风险:

    $body = @{ title = "标题"; content = $content; content_format = 1 } | ConvertTo-Json -Depth 10
    $utf8Bytes = [System.Text.Encoding]::UTF8.GetBytes($body)
    Invoke-RestMethod -Uri $url -Method Post -Body $utf8Bytes -ContentType "application/json; charset=utf-8" -Headers $headers
    

    PowerShell 7+ 默认使用 UTF-8,无需额外处理。

    标题同理,确保传入 API 的所有字符串字段均为合法 UTF-8。

错误处理

错误码含义建议处理
0成功
100001参数错误检查请求参数格式和必填字段
100002无效 ID检查凭证配置
100003服务器内部错误等待后重试
100004size 不合法 / 空间不够检查参数范围
100005无权限确认操作的是用户自己的笔记
100006笔记已删除告知用户该笔记不存在
100008版本冲突重新获取内容后再操作
100009超过大小限制拆分为多次 append_doc 写入
310001笔记本不存在检查 folder_id 是否正确
20002apiKey超过最大限频
20004apikey 鉴权失败检查凭证配置是否正确
110037apikey 过期请获取最新apikey:https://ima.qq.com/agent-interface

Comments

Loading comments...