Xiao Yi: Integrating IMA Notes and Knowledge Base OpenAPI via Agent Skill

Introduction

When handling requests like “note this down,” “put this PDF into the knowledge base,” or “search the knowledge base for a specific document” within an Agent, the common approach is to write temporary scripts or manually open the IMA client. Operations such as note writing, knowledge base uploads, COS step-by-step uploads, and encoding validation are scattered across different interfaces, making it difficult for the Agent to complete the full workflow reliably.

Below is an introduction to “Xiaoyi” (Coordinates @user_2d38631d/27585e2da461584da9ba13574571ab56), a community Skill on SkillHub. It wraps Tencent IMA’s OpenAPI into a unified SKILL.md workflow, routing between the notes and knowledge-base sub-modules based on user intent, and includes ima_api.cjs along with upload pre-check scripts.

What is this

One-sentence positioning: An IMA OpenAPI skill package for Agents, currently covering note management and knowledge base operations; the official homepage is ima.qq.com.

Source and Version: Categorized under knowledge-management on SkillHub, source community, published by user_2d38631d. Page version is v1.0.0 (SkillHub description: “My Personal Assistant”; the description in the package’s SKILL.md specifies unified IMA OpenAPI capabilities and triggering intents). SkillHub statistics (based on page scraping): Rating 100000, Downloads 1030; tags include requires_api_key=false (coexisting with the IMA credential configuration below; refer to the skill documentation for details).

Problem solved: Enables Agents supporting Skills to invoke the corresponding APIs based on the decision tables in the documentation when users mention knowledge bases, databases, notes, memos, or intend to upload files, bookmark web pages, search knowledge bases, or read/write personal documents, rather than constructing requests from scratch every time.

Core Features

The skill root directory splits capabilities into two sub-modules. Agents should first read the module decision table in the root SKILL.md before entering sub-documents.

Notes (notes/)

Supported via openapi/note/v1:

  • Read: Search by title or content (search_note), list notebooks (list_notebook), list notes (list_note), get content (get_doc_content).
  • Write: Create new note (import_doc), append to existing note (append_doc).

The documentation emphasizes: All string fields must be valid UTF-8 before writing; append_doc modifies existing notes, so if the target is unclear, confirm with the user first; note content interfaces do not support local image paths.

Knowledge Base (knowledge-base/)

Supported via openapi/wiki/v1:

  • Upload files to knowledge base: (check_repeated_names → create_media → COS upload → add_knowledge), including steps like preflight-check.cjs, cos-upload.cjs.
  • Import web/WeChat articles: (import_urls), associate existing notes to the knowledge base (add_knowledge, media_type=11).
  • Query: Knowledge base info, directory browsing, content search, search knowledge base by name, list of available knowledge bases, media original text (get_media_info; note types will cross-module to notes to read content).

Limitations are clearly stated in the documentation: Unsupported videos, Bilibili/YouTube, file:// etc. (users should be guided to use the IMA desktop client); when uploading files, title must match file_name (including extension).

Unified Invocation and Updates

  • Requests are sent to https://ima.qq.com, wrapped by the package’s ima_api.cjs; credentials are provided via environment variables or client_id, api_key under ~/.config/ima/.
  • Runtime dependency: Node.js ≥ 18.0.0 (see required_binaries in the package’s meta.json).
  • Built-in daily Skill update check; error code -200 indicates that you need to update first according to the instructions before retrying the original request.

Installation and Activation

1. Install SkillHub CLI (if not already installed)

command -v skillhub && skillhub --version

If not installed, execute a full installation or just the CLI according to the SkillHub installation documentation:

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

2. Install “Xiaoyi” to the current Agent’s skills directory

The installation prompt provided on the SkillHub page is: Refer to skillhub.md to install the coordinates @user_2d38631d/27585e2da461584da9ba13574571ab56. Command line example (--dir must point to the skills directory actually recognized by your Agent):

skillhub install '@user_2d38631d/27585e2da461584da9ba13574571ab56' --dir ~/.cursor/skills/

Common paths (from SkillHub installation documentation, choose one based on your client):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

Usually, you need to restart or refresh the Agent after installation to load the new Skill.

3. Configure IMA OpenAPI Credentials

Before calling any API, obtain the Client ID and API Key from https://ima.qq.com/agent-interface.

Method A — Config File (Recommended by skill docs):

mkdir -p ~/.config/ima
echo "your_client_id" > ~/.config/ima/client_id
echo "your_api_key" > ~/.config/ima/api_key

Method B — Environment Variables:

export IMA_OPENAPI_CLIENTID="your_client_id"
export IMA_OPENAPI_APIKEY="your_api_key"

The Agent reads environment variables first, followed by the config file; if missing, ima_api.cjs will exit with code: -100. Credentials are sent only as HTTP headers to ima.qq.com; the file upload flow also uses temporary COS credentials returned by IMA to access *.myqcloud.com.

Typical Usage

The following examples are excerpted from the skill package documentation, showing the invocation form for the Agent or for you to reproduce in the terminal. SKILL_DIR in the actual path should be replaced with the installed skill directory.

List Notes (Excerpt)

SKILL_DIR="/path/to/@user_2d38631d/27585e2da461584da9ba13574571ab56"
OPTS=$(printf '{"clientId":"%s","apiKey":"%s"}' "$IMA_OPENAPI_CLIENTID" "$IMA_OPENAPI_APIKEY")
node "$SKILL_DIR/ima_api.cjs" "openapi/note/v1/list_note" '{"folder_id":"","sort_type":0,"cursor":"","limit":20}' "$OPTS"

Search in Knowledge Base

node "$SKILL_DIR/ima_api.cjs" "openapi/wiki/v1/search_knowledge" '{"query":"keyword","knowledge_base_id":"<kb_id>","cursor":""}' "$OPTS"

Type Check Before File Upload

Before uploading files like PDFs, run the pre-check (if pass=false, terminate and explain the reason to the user):

node "$SKILL_DIR/knowledge-base/scripts/preflight-check.cjs" --file "/path/to/report.pdf"

For the complete upload chain (duplicate name check, create_media, COS, add_knowledge), refer to the “Upload File to Knowledge Base” section in knowledge-base/SKILL.md.

Trigger Intents (Agent Side)

The package description stipulates: When users mention knowledge bases, notes, memos, or intend to upload files, add web pages, search materials, or access personal documents (e.g., “note this down,” “search the knowledge base for XX”), this Skill should be enabled; when notes and knowledge bases are mixed, read both sub-modules according to the “Cross-module Task” table in the root SKILL.md before executing.

Applicable Scenarios & Notes

Who it’s for: Developers already using Tencent IMA to store notes and knowledge bases, and who want Cursor, Claude Code, Codex, etc. agents to complete searches, create/append notes, upload files, or import links within conversations.

Things to note:

  • Must have an IMA account and OpenAPI credentials; requires_api_key=false on the SkillHub page refers to store metadata and does not mean IMA keys are not required.
  • On Windows, if making HTTP requests manually in PowerShell 5.1, use UTF-8 byte arrays as per the root SKILL.md, otherwise Chinese characters may garble; prioritize calling via ima_api.cjs.
  • Community source (community); capabilities and interfaces are subject to the IMA official OpenAPI and the package’s references/api.md; the package’s ima_api may prompt for version updates (the SkillHub list version and the version field in the package’s meta.json may differ; prioritize the installed package content).

Conclusion

“Xiaoyi” converges IMA notes and knowledge base OpenAPIs into a routable Agent Skill: First select notes or knowledge-base based on intent, then follow the documentation’s gates (encoding, file type, duplicate name, COS upload result) and unified ima_api.cjs calls.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye