@sortedyuan/plugin-skills 0.0.0-stage → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @sortedyuan/plugin-skills
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `createSkillsPlugin({ id?, create })` creates a `SkillSession` from the real
4
+ `SkillRegistry` returned by `create(context)`. It provides `services.skills` and
5
+ contributes the `skill_read` tool and dynamic instructions through the shared
6
+ registries. Each Application has an independent activation state.
7
+ Its instruction contribution uses `order: 0`. The initial catalog contains only
8
+ names, descriptions and optional compatibility requirements; `skill_read` loads
9
+ selected instructions and referenced resources progressively. Active documents
10
+ remain available in subsequent instruction snapshots.
11
+ Typed `config`, `configSchema`, dependency declarations, `requiresHooks`, and
12
+ `version` follow [`PluginFactoryMetadata`](../../plugin-services/README.md).
13
+ The factory owns its activation state declaration.
14
+
15
+ Activated documents are restored before setup completes. Activations await
16
+ `context.state.set()` before becoming visible, so Application persistence and state
17
+ migration use the plugin host. Application also reads legacy `may.skills.active.v1`
18
+ Session records when resuming existing data. New records use the versioned plugin
19
+ state snapshot. Activating a skill retains its saved content across resume even
20
+ when the original file changes.
21
+
22
+ Closing the plugin removes its tool and instruction contributions. The registry is
23
+ an immutable discovery snapshot with no resource disposal API.
24
+
25
+ Tests discover, activate and restore actual `SKILL.md` files in the ignored
26
+ `plugin-verification` directory: `pnpm --filter @sortedyuan/plugin-skills test`.
@@ -0,0 +1,20 @@
1
+ # @sortedyuan/plugin-skills
2
+
3
+ `createSkillsPlugin({ id?, create })` 使用 `create(context)` 返回的实际 `SkillRegistry`
4
+ 创建 `SkillSession`,提供 `services.skills`,并通过共享注册表贡献 `skill_read` 和动态指令。
5
+ 每个 Application 分别管理激活状态。
6
+ 指令贡献使用 `order: 0`。初始目录包含名称、描述及适用时的兼容要求;`skill_read`
7
+ 按需读取选定的指导和引用资源。已激活的文档持续出现在后续指令快照中。
8
+ 支持 [`PluginFactoryMetadata`](../../plugin-services/README.zh-CN.md) 中带类型的
9
+ `config`、`configSchema`、依赖声明、`requiresHooks` 和 `version`。
10
+ 激活状态由工厂声明和管理。
11
+
12
+ 插件 setup 完成之前恢复激活文档,激活过程等待 `context.state.set()` 完成之后公开状态。
13
+ Application 保存和状态迁移使用 PluginHost;恢复已有 Session 时也读取旧的
14
+ `may.skills.active.v1` 记录。新的记录使用带版本的插件状态快照。
15
+ 恢复 Session 时保留已经激活的文档内容,即使原始文件已经改变。
16
+
17
+ 插件关闭时移除工具和指令贡献。SkillRegistry 是不可变的发现快照,没有资源关闭接口。
18
+
19
+ 测试在被忽略的 `plugin-verification` 目录中发现、激活和恢复实际 `SKILL.md` 文件。
20
+ 执行 `pnpm --filter @sortedyuan/plugin-skills test`。
@@ -0,0 +1,9 @@
1
+ import { type SkillRegistry } from "@sortedyuan/skills";
2
+ import { type PluginDefinition, type PluginContext } from "@sortedyuan/plugin";
3
+ import { type PluginFactoryMetadata } from "@sortedyuan/plugin-services";
4
+ export interface SkillsPluginOptions<C = unknown> extends Omit<PluginFactoryMetadata<C>, "state"> {
5
+ readonly id?: string;
6
+ readonly create: (context: PluginContext<C>) => SkillRegistry | Promise<SkillRegistry>;
7
+ }
8
+ export declare function createSkillsPlugin<C = unknown>(options: SkillsPluginOptions<C>): PluginDefinition<C>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAgB,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpG,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;IAC/F,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACxF;AACD,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAYpG"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import { SkillSession } from "@sortedyuan/skills";
2
+ import { definePlugin } from "@sortedyuan/plugin";
3
+ import { services, factoryMetadata } from "@sortedyuan/plugin-services";
4
+ export function createSkillsPlugin(options) {
5
+ return definePlugin({ ...factoryMetadata(options, [{ service: services.toolSources }, { service: services.instructionSources }]), id: options.id ?? "may.skills", provides: [services.skills],
6
+ state: { version: 1, initial: [] }, async setup(context) {
7
+ const skills = new SkillSession(await options.create(context));
8
+ skills.restore(context.state.get());
9
+ skills.setSink((documents) => context.state.set(documents));
10
+ context.provide(services.skills, skills);
11
+ const registration = { id: context.pluginId, pluginOrder: context.pluginOrder };
12
+ context.defer(context.get(services.toolSources).add(() => [skills.readTool()], registration));
13
+ context.defer(context.get(services.instructionSources).add(() => skills.instructions(), { ...registration, order: 0 }));
14
+ },
15
+ });
16
+ }
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,YAAY,EAA6C,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,eAAe,EAA8B,MAAM,6BAA6B,CAAC;AAMpG,MAAM,UAAU,kBAAkB,CAAc,OAA+B;IAC7E,OAAO,YAAY,CAAC,EAAE,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,YAAY,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC3L,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;YACrD,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YAC/D,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACpC,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACzC,MAAM,YAAY,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;YAChF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;YAC9F,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1H,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@sortedyuan/plugin-skills",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.3",
4
+ "description": "Session skill state, instructions and tool plugin factory.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "!dist/.tsbuildinfo"
17
+ ],
18
+ "dependencies": {
19
+ "@sortedyuan/skills": "0.2.0",
20
+ "@sortedyuan/plugin": "0.2.0",
21
+ "@sortedyuan/plugin-services": "0.2.3"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^22.0.0"
25
+ },
26
+ "engines": {
27
+ "node": ">=22"
28
+ },
29
+ "license": "MIT",
30
+ "scripts": {
31
+ "build": "tsc -b",
32
+ "clean": "tsc -b --clean",
33
+ "test": "pnpm run build && node --test test/*.test.mjs",
34
+ "test:coverage": "pnpm run build && node --test --experimental-test-coverage test/*.test.mjs"
35
+ }
6
36
  }