@wgx-plugins/core
v0.1.1
Published
Shared runtime for @wgx-plugins OpenCode plugins (V1 + V2)
Readme
@wgx-plugins/core
@wgx-plugins 插件的共享运行时。提供内容解析、注入器与模式状态机,同时适配 OpenCode V1(1.x)与 V2(2.x)。
安装
npm i @wgx-plugins/core能力
| 导出 | 作用 |
|---|---|
| readSkills(dir) / readCommands(dir) | 读取包内内容,BOM/CRLF 安全,支持 > 与 \| 折叠块 |
| injectSkills / injectCommands | V2 skill.transform / command.transform 注册 |
| injectRules | 同时挂 context 与 compaction 两个 hook |
| v1ConfigHook / v1SystemHook | V1 config 与 experimental.chat.system.transform |
| createModeRuntime | 模式状态(读写/fail-off/off/persist) |
| filterRulesForMode | 按模式过滤规则表格与示例行 |
| createPlugin | 输出 { id, setup, server } 三合一插件对象 |
最小用法
import { createPlugin } from "@wgx-plugins/core";
export default createPlugin({
id: "my-plugin",
skillsDir: new URL("../skills", import.meta.url).pathname,
commandsDir: new URL("../commands", import.meta.url).pathname
});约束
- 一个模块只导出一个插件形状,工具函数放独立模块。
.md允许带 UTF-8 BOM,解析前统一 strip。context与compaction必须同时注入。- 状态读取失败按关闭处理(fail-off)。
