KineX · 开发者文档 · 02

Plugin API v1.2 开发规范手册

面向插件开发者与 AI Coding Agent 的完整参考手册:覆盖 manifest.json 清单规范、已接入主界面的 8 个可运行扩展域、预留字段说明、stdio / local-http 通信协议、configSchema 配置表单、全部 25 项权限枚举,以及可直接复制运行的插件模板。

适用于 Plugin API 1.2(向下兼容 1.0 / 1.1 · 宿主:KineX 0.1.0-beta.8+ · 分发包格式:.kxplugin ZIP) 如需单文件精简版直接喂给 AI Coding Agent,请参阅 /developers/llms.txt。

章节导航 · 02 Plugin API v1.2 接口手册
  1. 01插件生态与开放能力总览
  2. 02Plugin API v1.2 接口手册
  3. 03本机 MCP 与研究工作流
← 返回用户手册

01清单结构与归档边界(manifest.json)

插件根目录必须包含合法的 manifest.json(<= 256 KiB);.kxplugin 解压上限为 128 个文件 / 32 MiB,严格禁止软链接、绝对路径与 .. 目录穿越。

{
  "manifestVersion": 1,
  "apiVersion": "1.2",
  "id": "com.example.my-kinex-plugin",
  "name": "我的扩展插件",
  "version": "1.0.0",
  "description": "一句话说明该插件的作用",
  "author": "Developer Name",
  "license": "MIT",
  "minKinexVersion": "0.1.0-beta.8",
  "platforms": ["windows", "macos"],
  "runtime": {
    "kind": "stdio",
    "command": "node",
    "args": ["${pluginDir}/adapter.mjs"],
    "timeoutMs": 15000
  },
  "contributes": {},
  "permissions": ["network.loopback", "secrets.own"],
  "allowedHosts": ["127.0.0.1", "localhost"],
  "configSchema": { "type": "object", "properties": {} }
}

清单校验硬规则

字段 规则
id 必须匹配 /^[a-z0-9][a-z0-9.-]{2,78}[a-z0-9]$/(4~80 字符,仅小写字母、数字、点、连字符)
runtime.kind "declarative"(纯 JSON 皮肤等)、"local-http"(本地/局域网 HTTP 端点)或 "stdio"(无 Shell 子进程);超时限 1000..25000 ms
禁止 Shell stdio 严禁调用 cmd / cmd.exe / powershell / pwsh / sh / bash / zsh / fish / wscript / cscript
allowedHosts 禁全网通配符 * / *.*;支持精确主机(如 127.0.0.1)与单级通配(如 *.example.com)
iOS 边界 使用 reader.webview.partition 或 reader.webview.bridge 时 platforms 不可包含 "ios"

02进程通信帧协议与配置表单(stdio / local-http / configSchema)

stdio 与 local-http 传输约定

  1. 请求与响应帧:KineX 向插件进程的标准输入(stdin)写入单个 JSON 字符串并关闭输入流(EOF),然后读取标准输出(stdout);若使用 local-http,宿主向 endpointUrl 发送 POST 请求并携带 Content-Type: application/json 与 X-KineX-Plugin-Api: 1.2。
  2. 换行与诊断日志:stdout 兼容 JSON.stringify(obj) 单行输出,也兼容多行格式化 JSON;调试信息请输出到 stderr(仅在进程非零退出时截取作为诊断报错)。
  3. 响应体积上限:readAloudProviders 为 12 MiB,contentImporters 与 contentExporters 为 8 MiB,mediaSubtitles 为 4 MiB,其余查询接口(searchProviders、lookupProviders、mediaSources)为 512 KiB。
  4. Windows stdin 重要注意事项:在 Windows 上由宿主拉起的无窗口管道为非阻塞句柄,Node.js 插件 严禁使用 fs.readFileSync(0, 'utf8')(会抛出 EAGAIN),请务必使用异步事件读取:
function readStdin() {
  return new Promise((resolve) => {
    let raw = '';
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', (chunk) => { raw += chunk; });
    process.stdin.on('end', () => resolve(raw.trim()));
  });
}

configSchema 用户配置与密钥注入

在 设置 → 插件与扩展 → 配置 中,KineX 会根据 configSchema.properties 自动生成可视化表单。用户保存的普通项随每次请求的 req.config 下发;标记 "format": "secret" 的字段由宿主加密存入 OS Keychain(命名空间 kinex.secret.plugin.<pluginId>.*),运行时解密注入 req.secrets:

{
  "type": "object",
  "properties": {
    "endpointUrl": {
      "type": "string",
      "title": "本机服务地址",
      "description": "填写本地监听端点 URL",
      "default": "http://127.0.0.1:8765/lookup",
      "placeholder": "http://127.0.0.1:8765/lookup",
      "format": "url",
      "section": "连接设置",
      "advanced": false
    },
    "outputFormat": {
      "type": "string",
      "title": "默认格式",
      "enum": ["obsidian", "anki"],
      "enumLabels": { "obsidian": "Obsidian Markdown", "anki": "Anki TSV 牌组" },
      "default": "obsidian"
    },
    "apiToken": {
      "type": "string",
      "title": "访问令牌",
      "format": "secret",
      "description": "加密保存在本机系统钥匙串中,绝不会明文落盘"
    }
  }
}

03已接入主界面的 8 个扩展域与预留字段

扩展字段 协议版本 必选权限 宿主界面的出现位置
themes v1.0 / v1.2 ui.theme 顶部外观切换菜单(ThemeQuickMenu)与 设置 → 外观
readAloudProviders v1.2 readaloud.provider.register 阅读器朗读设置中的引擎选择器与音色下拉列表
contentExporters v1.2 content.export 阅读侧栏 笔记 右上角 导出 按钮、闪卡管理树 工具栏 导出图标
contentImporters v1.0 / v1.2 content.import 素材管理面板顶部 + 导入菜单 列表项
lookupProviders v1.2 reader.lookup.register 阅读器划词浮动栏点击 查词(多插件可卡片内切换,并保留网页词典入口)
searchProviders v1.1 ai.search.register AI 对话 联网搜索多轨检索引擎(受全局隐私锁控制)
mediaSources v1.1 media.source.register 音视频 URL 导入识别、主题封面解析与播放源
mediaSubtitles v1.1 media.subtitles.register 音视频播放器外挂字幕与时间轴转写

其他与预留字段说明:

  • oauth(权限 auth.oauth):用于配置标准 OAuth 2.0 + PKCE 授权跳转,系统浏览器授权后回调至 kinex://plugin-auth/<pluginId>,临时授权码存入插件独立密钥链。
  • pricingSources(ai.pricing.register)、relayEndpoints(ai.relay.register)与 studyPresets(ai.study.preset)当前仅作为 预留清单字段 进行格式校验与注册表存储,主界面暂未挂载对应交互入口。
  • providers / quotaProviders 属底层高级通道扩展字段,建议优先基于上述 8 个学习工作流扩展域构建稳定插件。

04全部 8 个可运行扩展域完整 Schema

A. 声明式明/暗主题(themes · v1.2)

CSS 变量名必须匹配 --[a-z0-9-]+,值严禁包含 [;{}<>]、url(...)、expression(...)与@import`。

KineX 会将 lightCssVars 编译到 html body.light-theme, html body .light-theme, html[data-kinex-light] body.light-theme, html[data-kinex-light] .kinex-app-engine.light-theme,将 darkCssVars 编译到对应 .dark-theme 选择器,同时让 --kinex-paper-bg 自动接管阅读器默认纸张底色:

{
  "manifestVersion": 1,
  "apiVersion": "1.2",
  "id": "com.kinex.example.warm-paper-theme",
  "name": "暖纸护眼主题",
  "version": "1.2.0",
  "platforms": ["windows", "macos", "android", "ios"],
  "runtime": { "kind": "declarative" },
  "permissions": ["ui.theme"],
  "contributes": {
    "themes": [
      {
        "id": "warm-study-paper",
        "title": "暖纸护眼",
        "appearance": "both",
        "previewSwatches": ["#efe5cf", "#9a5b25", "#241e18", "#e0a458"],
        "cssVars": { "--color-accent": "#9a5b25" },
        "lightCssVars": {
          "--bg-main": "#efe5cf",
          "--bg-workspace": "#e3d6ba",
          "--bg-sidebar": "#e9dec5",
          "--bg-panel": "#f7f0df",
          "--border-color": "#d6c5a3",
          "--text-main": "#33271a",
          "--text-sub": "#66533e",
          "--color-accent": "#9a5b25",
          "--on-accent": "#fffaf0",
          "--title": "#3f2b16",
          "--kinex-paper-bg": "#f5edd9"
        },
        "darkCssVars": {
          "--bg-main": "#241e18",
          "--bg-workspace": "#1b1611",
          "--bg-sidebar": "#201a15",
          "--bg-panel": "#2d251e",
          "--border-color": "#463a2e",
          "--text-main": "#f3e8d8",
          "--text-sub": "#c6b6a0",
          "--color-accent": "#e0a458",
          "--on-accent": "#1d160f",
          "--title": "#f6ecd9",
          "--kinex-paper-bg": "#2a221b"
        }
      }
    ]
  }
}

B. 语音朗读 TTS 接口(readAloudProviders · v1.2)

  • openai-speech-http:无需编写脚本,宿主直接向 endpointUrl(如 http://127.0.0.1:8880/v1/audio/speech)发送 POST { model, input, voice, speed, response_format: "mp3" } 并读取音频流;
  • stdio-json / local-http-json:接收 kinex.read-aloud-request.v1(action 为 "listVoices" 或 "synthesize"),返回 kinex.read-aloud-response.v1(上限 12 MiB):
// 请求
{
  "schemaVersion": "kinex.read-aloud-request.v1",
  "requestId": "tts_m1abc",
  "providerId": "local-tts",
  "action": "synthesize",
  "text": "KineX 将长上下文与主动提取结合。",
  "voice": "zf_xiaobei",
  "rate": 1.0,
  "pitch": 1.0,
  "format": "wav",
  "privacyLockEnabled": false,
  "config": { "defaultVoice": "zf_xiaobei" },
  "secrets": {}
}

// 响应(listVoices 返回 voices 数组;synthesize 返回 audioBase64 + mimeType)
{
  "schemaVersion": "kinex.read-aloud-response.v1",
  "ok": true,
  "voices": [
    { "id": "zf_xiaobei", "name": "小贝(自然中文)", "locale": "zh-CN", "offline": true }
  ],
  "audioBase64": "<RIFF WAVE / MP3 Base64>",
  "mimeType": "audio/wav",
  "durationMs": 920
}

C. 笔记与闪卡导出接口(contentExporters · v1.2)

在阅读侧栏 笔记 或 闪卡管理树 触发导出时,插件接收 kinex.content-exporter-request.v1 并返回文本或 Base64 文件内容(上限 8 MiB):

// 请求
{
  "schemaVersion": "kinex.content-exporter-request.v1",
  "requestId": "exp_123",
  "exporterId": "obsidian-callout",
  "scope": "notes",
  "themeTitle": "认知科学精读",
  "materialTitle": "Thinking Fast",
  "items": [
    { "id": "n1", "title": "System 1 vs 2", "text": "直觉反应快速但易受启发式偏误影响", "note": "对比双过程理论", "anchorLabel": "P.24", "tags": ["highlight"] }
  ],
  "config": {}
}

// 响应
{
  "schemaVersion": "kinex.content-exporter-response.v1",
  "ok": true,
  "fileName": "Thinking-Fast-obsidian.md",
  "mimeType": "text/markdown; charset=utf-8",
  "contentText": "---\ntitle: \"Thinking Fast\"\n---\n\n> [!quote] (P.24)\n> 直觉反应快速但易受启发式偏误影响\n",
  "itemCount": 1
}

D. 内容导入接口(contentImporters · v1.2)

在素材管理栏 + 导入菜单 触发导入,支持 inputKind: "url" | "file" | "text",返回最多 50 篇素材写入当前阅读主题(上限 8 MiB):

// 请求
{
  "schemaVersion": "kinex.content-importer-request.v1",
  "requestId": "imp_123",
  "importerId": "podcast-shownotes",
  "inputKind": "url",
  "source": "https://feeds.transistor.fm/example-show",
  "privacyLockEnabled": false,
  "config": {},
  "secrets": {}
}

// 响应
{
  "schemaVersion": "kinex.content-importer-response.v1",
  "ok": true,
  "items": [
    {
      "title": "Episode 01: Spaced Repetition",
      "format": "markdown",
      "content": "# Episode 01\n\n...",
      "canonicalUrl": "https://feeds.transistor.fm/example-show/ep1",
      "author": "Host Name",
      "publishedAt": "2026-10-20",
      "folderPath": ["Podcasts", "Show Notes"]
    }
  ]
}

E. 划词词典查词接口(lookupProviders · v1.2)

在阅读器选中文本点击 查词 时触发,宿主自动剥离响应中的 HTML 标签并验证 sourceUrl 是否位于声明的 allowedHosts 内(上限 512 KiB):

// 请求
{
  "schemaVersion": "kinex.lookup-request.v1",
  "requestId": "lkp_123",
  "providerId": "term-glossary",
  "term": "spaced repetition",
  "contextSentence": "Spaced repetition reduces total study time.",
  "config": {},
  "secrets": {}
}

// 响应
{
  "schemaVersion": "kinex.lookup-response.v1",
  "ok": true,
  "headword": "Spaced Repetition(间隔重复)",
  "phonetic": "/speɪst ˌrepɪˈtɪʃən/",
  "entries": [
    {
      "partOfSpeech": "认知科学",
      "definition": "按照记忆衰退曲线动态拉开复习间隔的学习调度方法。",
      "examples": ["KineX 使用 FSRS 算法调度每张闪卡。"],
      "sourceUrl": "https://docs.example.com/fsrs"
    }
  ]
}

F. AI 对话联网搜索(searchProviders · v1.1)

// 请求
{ "schemaVersion": "kinex.search-request.v1", "requestId": "src_1", "providerId": "searxng", "query": "FSRS algorithm", "maxResults": 6, "privacyLockEnabled": false, "config": {}, "secrets": {} }

// 响应
{
  "schemaVersion": "kinex.search-response.v1",
  "ok": true,
  "results": [
    { "title": "FSRS Benchmark", "url": "https://arxiv.org/abs/2401.00001", "snippet": "Empirical comparison...", "publishedAt": "2026-01-15", "quotes": [{ "exact": "Empirical comparison..." }] }
  ]
}

G. 私有音视频源解析(mediaSources · v1.1)

// 请求(action: "resolveMetadata" | "resolvePlayback")
{ "schemaVersion": "kinex.media-source-request.v1", "requestId": "med_1", "action": "resolvePlayback", "sourceId": "jellyfin-lan", "url": "http://127.0.0.1:8096/web/index.html#!/details?id=demo", "privacyLockEnabled": false, "config": {}, "secrets": {} }

// 响应(playback.kind 可选 stream | embed-iframe | webview-page)
{
  "schemaVersion": "kinex.media-source.v1",
  "ok": true,
  "title": "Lecture 04",
  "mediaType": "video",
  "durationSec": 1840,
  "coverUrl": "http://127.0.0.1:8096/Items/demo/Images/Primary",
  "playback": { "kind": "stream", "streamUrl": "http://127.0.0.1:8096/Videos/demo/stream.mp4?static=true", "mimeType": "video/mp4" }
}

H. 外挂字幕生成与 OAuth PKCE(mediaSubtitles / oauth · v1.1)

// 字幕请求(mode: "local-transcribe" | "url-lookup" | "file-import")
{ "schemaVersion": "kinex.media-subtitles-request.v1", "requestId": "sub_1", "providerId": "local-whisper-http", "mode": "local-transcribe", "mediaPathOrUrl": "C:\\Videos\\lesson1.mp4", "language": "zh", "config": {}, "secrets": {} }

// 字幕响应(<= 4 MiB)
{
  "schemaVersion": "kinex.media-subtitles.v1",
  "ok": true,
  "language": "zh",
  "cues": [{ "startMs": 200, "endMs": 2400, "text": "欢迎来到主动提取专题课" }]
}

05运行边界与数据访问方式

  • 无隐藏 JS 全局对象:.kxplugin 的 stdio 适配器运行在独立子进程中,脚本内部不存在 kinex.storage 或 kinex.inbox 等注入全局对象;
  • 配置与密钥如何进入脚本:用户保存的设置与 Keychain 凭据(命名空间 kinex.secret.plugin.<pluginId>.*)由 KineX 自动随每次请求放入 req.config 与 req.secrets;
  • 如需读写当前阅读工作区:请连接 KineX 内置的 本机 MCP 服务端(http://127.0.0.1:45129/mcp),通过标准 JSON-RPC 工具读取笔记、检索材料或投递调研资料包到 AI 收件箱。

06全部 25 项权限枚举表

权限分组 精确权限字符串(写入 permissions[]) 说明
AI 与研学 (7) ai.provider.register, ai.quota.register, ai.usage.read, ai.pricing.register, ai.relay.register, ai.study.preset, ai.search.register 注册推理通道、配额显示、只读用量、价目表、中继、研学预设、联网检索
媒体、朗读与阅读 (6) media.source.register, media.subtitles.register, readaloud.provider.register, reader.lookup.register, reader.webview.partition, reader.webview.bridge 影音源、外挂字幕、TTS 朗读引擎、划词查词、隔离网页分区、只读进度桥接
内容与工作区 (4) content.import, content.export, workspace.read, workspace.propose 素材导入、自定义格式导出、只读工作区正文、向 AI 收件箱提交提案
网络、进程与系统 (8) auth.oauth, network.loopback, network.internet, process.external, secrets.own, storage.own, ui.slots, ui.theme 标准 OAuth PKCE、本机/局域网访问、声明外网域名、无 Shell 子进程、密钥链、16MB 存储、UI 插槽与主题

07可直接运行的最小 stdio 插件模板

新建目录 my-lookup-plugin/,放入以下两份文件即可在 设置 → 插件与扩展 → 开发者本地调试 直接加载:

manifest.json

{
  "manifestVersion": 1,
  "apiVersion": "1.2",
  "id": "com.example.hello-lookup",
  "name": "最小词典查词示例",
  "version": "1.0.0",
  "description": "演示异步 stdin 读取并响应划词查词请求",
  "platforms": ["windows", "macos"],
  "runtime": { "kind": "stdio", "command": "node", "args": ["${pluginDir}/adapter.mjs"], "timeoutMs": 8000 },
  "contributes": { "lookupProviders": [{ "id": "hello-dict", "title": "示例词典", "languages": ["zh", "en"] }] },
  "permissions": ["reader.lookup.register", "process.external"]
}

adapter.mjs

function readStdin() {
  return new Promise((resolve) => {
    let raw = '';
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', (chunk) => { raw += chunk; });
    process.stdin.on('end', () => resolve(raw.trim()));
  });
}

async function main() {
  const raw = await readStdin();
  const req = raw ? JSON.parse(raw) : {};
  const term = String(req?.term || '').trim();
  process.stdout.write(`${JSON.stringify({
    schemaVersion: 'kinex.lookup-response.v1',
    ok: true,
    headword: term,
    entries: [{ partOfSpeech: 'note', definition: `已收到查词请求:${term}` }],
  })}\n`);
}

main().catch((err) => {
  process.stdout.write(`${JSON.stringify({ schemaVersion: 'kinex.lookup-response.v1', ok: false, headword: '', entries: [], error: String(err?.message || err) })}\n`);
});

本地命令行单步调试

# macOS / Linux
echo '{"schemaVersion":"kinex.lookup-request.v1","requestId":"t1","providerId":"hello-dict","term":"epistemic","config":{}}' | node adapter.mjs

# Windows PowerShell
'{"schemaVersion":"kinex.lookup-request.v1","requestId":"t1","providerId":"hello-dict","term":"epistemic","config":{}}' | node adapter.mjs

也可直接下载 term-dictionary-lookup.kxplugin 或 local-tts-bridge.kxplugin,将后缀改为 .zip 后解压查看完整源码。

KineX · Developers · 02

Plugin API v1.2 Complete Specification

Complete reference for plugin authors and AI coding agents: manifest.json rules, all 8 active runnable contribution domains, reserved manifest fields, stdio / local-http wire framing, configSchema, all 25 exact permission keys, and a minimal copy-pasteable plugin template.

Applies to Plugin API 1.2 (backward-compatible with 1.0 & 1.1 · KineX 0.1.0-beta.8+ · Package: .kxplugin ZIP) Single-file machine-dense spec for AI Coding Agents: /developers/llms.txt.

Chapters · 02 Plugin API v1.2 Reference
  1. 01Plugins & Ecosystem Overview
  2. 02Plugin API v1.2 Reference
  3. 03Local MCP & Study Workflows
← Back to User Guide

01Manifest Structure (manifest.json)

Every .kxplugin archive must place manifest.json (<= 256 KiB) at the root. Extracted archives cap at 128 files / 32 MiB with symlinks and .. path traversal strictly rejected.

{
  "manifestVersion": 1,
  "apiVersion": "1.2",
  "id": "com.example.my-kinex-plugin",
  "name": "My KineX Extension",
  "version": "1.0.0",
  "description": "One-sentence summary of what this plugin does",
  "author": "Developer Name",
  "license": "MIT",
  "minKinexVersion": "0.1.0-beta.8",
  "platforms": ["windows", "macos"],
  "runtime": {
    "kind": "stdio",
    "command": "node",
    "args": ["${pluginDir}/adapter.mjs"],
    "timeoutMs": 15000
  },
  "contributes": {},
  "permissions": ["network.loopback", "secrets.own"],
  "allowedHosts": ["127.0.0.1", "localhost"],
  "configSchema": { "type": "object", "properties": {} }
}

Strict Validation Rules

Field Rule
id Regex /^[a-z0-9][a-z0-9.-]{2,78}[a-z0-9]$/ (4–80 chars, lowercase alphanumeric, dots, hyphens)
runtime.kind "declarative", "local-http", or "stdio" (timeoutMs clamped to 1000..25000)
Shell Prohibition stdio forbids cmd, cmd.exe, powershell, pwsh, sh, bash, zsh, fish, wscript, cscript
allowedHosts Forbids * / *.*; supports exact hostnames and single-level wildcards *.example.com
iOS Guardrail Plugins requesting reader.webview.partition or reader.webview.bridge must omit "ios" from platforms

02Wire Framing & Config Schema (stdio / local-http / configSchema)

stdio & local-http Wire Framing

  1. Request / Response: KineX writes one JSON object to stdin and closes the stream (EOF), then reads stdout. For local-http, KineX sends HTTP POST with Content-Type: application/json and X-KineX-Plugin-Api: 1.2.
  2. Formatting & Logs: stdout accepts both single-line compact JSON and pretty-printed multi-line JSON. Write debug logs to stderr (only surfaced on non-zero exit).
  3. Response Byte Caps: readAloudProviders up to 12 MiB, contentImporters & contentExporters up to 8 MiB, mediaSubtitles up to 4 MiB, and all other JSON queries (searchProviders, lookupProviders, mediaSources) up to 512 KiB.
  4. Windows stdin Warning: Child process pipes on Windows are non-blocking. NEVER call fs.readFileSync(0, 'utf8') in Node.js adapters (it fails with EAGAIN). Always read asynchronously:
function readStdin() {
  return new Promise((resolve) => {
    let raw = '';
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', (chunk) => { raw += chunk; });
    process.stdin.on('end', () => resolve(raw.trim()));
  });
}

configSchema Settings & Keychain Secrets

KineX renders a native settings form from configSchema.properties under Settings → Plugins & Extensions → Configure. Saved fields pass into every request via req.config, while "format": "secret" fields are stored in OS Keychain (kinex.secret.plugin.<pluginId>.*) and delivered cleanly inside req.secrets:

{
  "type": "object",
  "properties": {
    "endpointUrl": {
      "type": "string",
      "title": "Local Endpoint URL",
      "description": "HTTP address for your local helper daemon",
      "default": "http://127.0.0.1:8765/lookup",
      "placeholder": "http://127.0.0.1:8765/lookup",
      "format": "url",
      "section": "Connection",
      "advanced": false
    },
    "outputFormat": {
      "type": "string",
      "title": "Default Format",
      "enum": ["obsidian", "anki"],
      "enumLabels": { "obsidian": "Obsidian Markdown", "anki": "Anki TSV" },
      "default": "obsidian"
    },
    "apiToken": {
      "type": "string",
      "title": "API Token",
      "format": "secret",
      "description": "Encrypted in your OS Keychain"
    }
  }
}

03Eight Active Contribution Domains & Reserved Fields

Field API Required Permission Where It Appears in KineX UI
themes v1.0 / v1.2 ui.theme Top-bar ThemeQuickMenu & Settings → Appearance
readAloudProviders v1.2 readaloud.provider.register Reader top-bar Read-Aloud Engine & voice selector
contentExporters v1.2 content.export Sidebar Notes tab Export button & Flashcard Management toolbar Export button
contentImporters v1.0 / v1.2 content.import Material Sidebar + Import menu
lookupProviders v1.2 reader.lookup.register Reader selection popup Look Up action (inline card with provider switcher + Web Dictionary button)
searchProviders v1.1 ai.search.register AI Chat multi-track web search
mediaSources v1.1 media.source.register Course URL import & native media playback
mediaSubtitles v1.1 media.subtitles.register Media Player external subtitles & transcription panel

Other & Reserved Manifest Fields:

  • oauth (auth.oauth): Configures standard OAuth 2.0 + PKCE browser login returning to kinex://plugin-auth/<pluginId>.
  • pricingSources (ai.pricing.register), relayEndpoints (ai.relay.register), and studyPresets (ai.study.preset) are reserved manifest fields (validated and stored in registry; no host UI integration in this release).

04Complete Schemas for All 8 Active Domains

A. Dual-Mode Declarative Themes (themes · v1.2)

CSS variables must match --[a-z0-9-]+; values reject [;{}<>], url(...), expression(...), and @import`.

lightCssVars compiles onto html body.light-theme, html body .light-theme, html[data-kinex-light] body.light-theme, html[data-kinex-light] .kinex-app-engine.light-theme and darkCssVars onto matching .dark-theme selectors, while --kinex-paper-bg drives the default reader background tint:

{
  "manifestVersion": 1,
  "apiVersion": "1.2",
  "id": "com.kinex.example.warm-paper-theme",
  "name": "Warm Study Paper Theme",
  "version": "1.2.0",
  "platforms": ["windows", "macos", "android", "ios"],
  "runtime": { "kind": "declarative" },
  "permissions": ["ui.theme"],
  "contributes": {
    "themes": [
      {
        "id": "warm-study-paper",
        "title": "Warm Study Paper",
        "appearance": "both",
        "previewSwatches": ["#efe5cf", "#9a5b25", "#241e18", "#e0a458"],
        "cssVars": { "--color-accent": "#9a5b25" },
        "lightCssVars": { "--bg-main": "#efe5cf", "--bg-panel": "#f7f0df", "--text-main": "#33271a", "--kinex-paper-bg": "#f5edd9" },
        "darkCssVars": { "--bg-main": "#241e18", "--bg-panel": "#2d251e", "--text-main": "#f3e8d8", "--kinex-paper-bg": "#2a221b" }
      }
    ]
  }
}

B. Read-Aloud / TTS Provider (readAloudProviders · v1.2)

  • openai-speech-http: Host directly POSTs { model, input, voice, speed, response_format: "mp3" } to endpointUrl.
  • stdio-json / local-http-json: Handles kinex.read-aloud-request.v1 (action: "listVoices" | "synthesize") and returns kinex.read-aloud-response.v1 (<= 12 MiB):
// Request
{
  "schemaVersion": "kinex.read-aloud-request.v1",
  "requestId": "tts_m1abc",
  "providerId": "local-tts",
  "action": "synthesize",
  "text": "KineX pairs deep reading with spaced repetition.",
  "voice": "af_heart",
  "rate": 1.0,
  "pitch": 1.0,
  "format": "wav",
  "privacyLockEnabled": false,
  "config": { "defaultVoice": "af_heart" },
  "secrets": {}
}

// Response
{
  "schemaVersion": "kinex.read-aloud-response.v1",
  "ok": true,
  "voices": [{ "id": "af_heart", "name": "Heart (Natural)", "locale": "en-US", "offline": true }],
  "audioBase64": "<RIFF WAVE / MP3 base64>",
  "mimeType": "audio/wav",
  "durationMs": 920
}

C. Note & Flashcard Exporters (contentExporters · v1.2)

// Request
{
  "schemaVersion": "kinex.content-exporter-request.v1",
  "requestId": "exp_123",
  "exporterId": "obsidian-callout",
  "scope": "notes",
  "themeTitle": "Cognitive Science",
  "materialTitle": "Thinking Fast",
  "items": [{ "id": "n1", "title": "System 1", "text": "Fast automatic heuristics", "note": "Compare with System 2", "anchorLabel": "p.24", "tags": ["highlight"] }],
  "config": {}
}

// Response (<= 8 MiB; returns contentText or contentBase64)
{
  "schemaVersion": "kinex.content-exporter-response.v1",
  "ok": true,
  "fileName": "Thinking-Fast-obsidian.md",
  "mimeType": "text/markdown; charset=utf-8",
  "contentText": "---\ntitle: \"Thinking Fast\"\n---\n\n> [!quote] (p.24)\n> Fast automatic heuristics\n",
  "itemCount": 1
}

D. Structured Content Importers (contentImporters · v1.2)

// Request (inputKind: "url" | "file" | "text")
{ "schemaVersion": "kinex.content-importer-request.v1", "requestId": "imp_1", "importerId": "podcast-shownotes", "inputKind": "url", "source": "https://feeds.transistor.fm/show", "privacyLockEnabled": false, "config": {}, "secrets": {} }

// Response (<= 8 MiB, max 50 items)
{
  "schemaVersion": "kinex.content-importer-response.v1",
  "ok": true,
  "items": [{ "title": "Episode 1", "format": "markdown", "content": "# Notes...", "canonicalUrl": "https://feeds.transistor.fm/ep1", "folderPath": ["Podcasts"] }]
}

E. Selection Lookup (lookupProviders · v1.2)

// Request
{ "schemaVersion": "kinex.lookup-request.v1", "requestId": "lkp_1", "providerId": "term-glossary", "term": "spaced repetition", "contextSentence": "Spaced repetition improves retention.", "config": {}, "secrets": {} }

// Response (<= 512 KiB; HTML stripped, sourceUrl verified against allowedHosts)
{
  "schemaVersion": "kinex.lookup-response.v1",
  "ok": true,
  "headword": "Spaced Repetition",
  "phonetic": "/speɪst ˌrepɪˈtɪʃən/",
  "entries": [{ "partOfSpeech": "noun", "definition": "Reviewing intervals adapted to memory stability.", "examples": ["FSRS schedules cards at optimal intervals."] }]
}

F. AI Chat Web Search (searchProviders · v1.1)

// Request
{ "schemaVersion": "kinex.search-request.v1", "requestId": "src_1", "providerId": "searxng", "query": "FSRS algorithm", "maxResults": 6, "privacyLockEnabled": false, "config": {}, "secrets": {} }

// Response
{
  "schemaVersion": "kinex.search-response.v1",
  "ok": true,
  "results": [{ "title": "FSRS Paper", "url": "https://arxiv.org/abs/2401.00001", "snippet": "Empirical comparison...", "publishedAt": "2026-01-15" }]
}

G. Private Media Connectors (mediaSources · v1.1)

// Request (action: "resolveMetadata" | "resolvePlayback")
{ "schemaVersion": "kinex.media-source-request.v1", "requestId": "med_1", "action": "resolvePlayback", "sourceId": "jellyfin-lan", "url": "http://127.0.0.1:8096/web/index.html#!/details?id=demo", "privacyLockEnabled": false, "config": {}, "secrets": {} }

// Response
{
  "schemaVersion": "kinex.media-source.v1",
  "ok": true,
  "title": "Lecture 04",
  "mediaType": "video",
  "durationSec": 1840,
  "playback": { "kind": "stream", "streamUrl": "http://127.0.0.1:8096/Videos/demo/stream.mp4?static=true", "mimeType": "video/mp4" }
}

H. External Subtitles & OAuth PKCE (mediaSubtitles / oauth · v1.1)

// Request
{ "schemaVersion": "kinex.media-subtitles-request.v1", "requestId": "sub_1", "providerId": "local-whisper-http", "mode": "local-transcribe", "mediaPathOrUrl": "C:\\Videos\\lesson1.mp4", "language": "en", "config": {}, "secrets": {} }

// Response (<= 4 MiB)
{ "schemaVersion": "kinex.media-subtitles.v1", "ok": true, "language": "en", "cues": [{ "startMs": 200, "endMs": 2400, "text": "Welcome to active recall." }] }

05Execution Boundary & Data Access

  • Out-of-process model: .kxplugin scripts run as isolated child processes (stdio) or local HTTP servers — there is NO kinex.storage or kinex.inbox global injected inside adapter.mjs.
  • Settings & Keychain: User configuration arrives on every request in req.config, and encrypted secrets arrive in req.secrets (from kinex.secret.plugin.<pluginId>.* in OS Keychain).
  • Reading/writing workspace content: Use the built-in Local MCP Server at http://127.0.0.1:45129/mcp to read highlights, materials, or propose flashcards/study packs into AI Inbox.

06Complete 25-Permission Catalog

Group Exact Permission Strings Granted Scope
AI & Study (7) ai.provider.register, ai.quota.register, ai.usage.read, ai.pricing.register, ai.relay.register, ai.study.preset, ai.search.register Custom models, quota display, usage reads, pricing, LAN relays, presets, search
Media, TTS & Reader (6) media.source.register, media.subtitles.register, readaloud.provider.register, reader.lookup.register, reader.webview.partition, reader.webview.bridge Media resolvers, external subtitles, Read-Aloud TTS, lookup dictionaries, isolated webviews
Content & Workspace (4) content.import, content.export, workspace.read, workspace.propose Material import, note/card export, scoped reads, AI Inbox proposals
System & Security (8) auth.oauth, network.loopback, network.internet, process.external, secrets.own, storage.own, ui.slots, ui.theme PKCE OAuth, loopback/LAN HTTP, declared internet hosts, stdio spawn, keychain, storage, UI slots, CSS themes

07Copy-Pasteable Minimal Runnable Plugin Template

manifest.json

{
  "manifestVersion": 1,
  "apiVersion": "1.2",
  "id": "com.example.hello-lookup",
  "name": "Minimal Lookup Example",
  "version": "1.0.0",
  "description": "Reads async stdin and answers selection lookup requests",
  "platforms": ["windows", "macos"],
  "runtime": { "kind": "stdio", "command": "node", "args": ["${pluginDir}/adapter.mjs"], "timeoutMs": 8000 },
  "contributes": { "lookupProviders": [{ "id": "hello-dict", "title": "Hello Dictionary", "languages": ["en", "zh"] }] },
  "permissions": ["reader.lookup.register", "process.external"]
}

adapter.mjs

function readStdin() {
  return new Promise((resolve) => {
    let raw = '';
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', (chunk) => { raw += chunk; });
    process.stdin.on('end', () => resolve(raw.trim()));
  });
}

async function main() {
  const raw = await readStdin();
  const req = raw ? JSON.parse(raw) : {};
  const term = String(req?.term || '').trim();
  process.stdout.write(`${JSON.stringify({
    schemaVersion: 'kinex.lookup-response.v1',
    ok: true,
    headword: term,
    entries: [{ partOfSpeech: 'note', definition: `Received lookup term: ${term}` }],
  })}\n`);
}

main().catch((err) => {
  process.stdout.write(`${JSON.stringify({ schemaVersion: 'kinex.lookup-response.v1', ok: false, headword: '', entries: [], error: String(err?.message || err) })}\n`);
});

Local CLI Smoke Test

'{"schemaVersion":"kinex.lookup-request.v1","requestId":"t1","providerId":"hello-dict","term":"epistemic","config":{}}' | node adapter.mjs

You can also download term-dictionary-lookup.kxplugin or local-tts-bridge.kxplugin, rename it to .zip, and extract its full source.