Wangyq Wiki

开发者指南

如何开发插件并扩展 Command+ API 的功能。

Command+ API uses a context-isolated, dynamically loaded plugin architecture. Create a .js file in the lib/ folder to extend the software instantly.

Command+ API 采用上下文隔离与动态加载的插件架构。只需在 lib/ 目录下创建一个 .js 文件,即可无缝扩展软件功能。

Command+ API usa una arquitectura de plugins con aislamiento de contexto. Crea un archivo .js en lib/.

Command+ API использует архитектуру плагинов с изоляцией контекста. Создайте .js файл в lib/.

1. Context API (ctx) / 上下文 API / API de Contexto / Контекстный API

Use the injected ctx object instead of raw require to ensure cross-platform compatibility and context isolation.

请使用注入的 ctx 对象而不是直接 require,以确保跨平台兼容性和上下文隔离。

Usa el objeto ctx inyectado en lugar de require directo.

Используйте внедренный объект ctx вместо прямого require.

Security Warning

Plugins run in the same Node.js process. While the ctx object provides context isolation, it is NOT a strict security sandbox. Loading untrusted third-party plugins may pose security risks. Only install plugins from trusted sources.

安全警告

插件与主程序运行在同一个 Node.js 进程中。虽然 ctx 对象提供了上下文隔离,但它并非严格的安全沙箱。加载不可信的第三方插件可能存在安全风险(如任意代码执行)。请仅安装来自可信来源的插件。

Advertencia de Seguridad

Los plugins se ejecutan en el mismo proceso. El objeto ctx NO es un sandbox estricto. Cargar plugins no confiables supone riesgos de seguridad.

Предупреждение о безопасности

Плагины выполняются в том же процессе. Объект ctx НЕ является строгой песочницей. Загрузка недоверенных плагинов может представлять угрозу.

2. Error Handling / 错误处理 / Manejo de Errores / Обработка ошибок

⚠️ Rule: Output business errors to stderr and call process.exit(1).

⚠️ 规范: 将业务错误输出到 stderr 并调用 process.exit(1)

⚠️ Regla: Envía errores a stderr y llama a process.exit(1).

⚠️ Правило: Выводите ошибки в stderr и вызывайте process.exit(1).

if (!args[0]) {
  console.error('Error: Missing argument');
  process.exit(1);
}

On this page