@qilin-agent/tool-skill 0.0.0-stage → 3.1.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 kkutysllb
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.
@@ -0,0 +1,136 @@
1
+ # Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
2
+ # section, a hash of its English and Chinese blocks outside code blocks and generated regions.
3
+ # After editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/skill/tool-skill/README.md
5
+ /:
6
+ en: e1bb629bc25d7d51
7
+ zh: 0018e221e28ddcff
8
+ /qilin-tool-skill:
9
+ en: c0e7b6c680d7e631
10
+ zh: c482d0246bdb576d
11
+ /qilin-tool-skill/summary:
12
+ en: 399399741476179c
13
+ zh: 074ec6657481d320
14
+ /qilin-tool-skill/table-of-contents:
15
+ en: d152484eb41ac6b4
16
+ zh: 09388d293f9be9cb
17
+ /qilin-tool-skill/use-this-package:
18
+ en: 5c21d1ba71c1c3e1
19
+ zh: 3e2505d4625b57b4
20
+ /qilin-tool-skill/use-this-package/when-to-choose-it:
21
+ en: b7d33bd969826ee3
22
+ zh: 4e155a0f14b41541
23
+ /qilin-tool-skill/use-this-package/mount-and-configure:
24
+ en: 16b55a6bcff86e62
25
+ zh: 4cfc947f684bde99
26
+ /qilin-tool-skill/use-this-package/what-the-model-gets:
27
+ en: cf02796bd3f8877e
28
+ zh: 81b93b1eb7f74690
29
+ /qilin-tool-skill/use-this-package/observable-success-and-failures:
30
+ en: 813f1a7ab04d283e
31
+ zh: 4adfcffcbb131d54
32
+ /qilin-tool-skill/understand-the-implementation:
33
+ en: 1aa627255c35178f
34
+ zh: 44d8633ea56765d3
35
+ /qilin-tool-skill/understand-the-implementation/design-concept:
36
+ en: a1a90d97c05bf124
37
+ zh: 80c5d2a05c2168dc
38
+ /qilin-tool-skill/understand-the-implementation/source-map:
39
+ en: 509699e3a467df41
40
+ zh: ff7fc30ec4998e5a
41
+ /qilin-tool-skill/understand-the-implementation/catalog-lifecycle:
42
+ en: 847745cf78860904
43
+ zh: 55137ebef224ad48
44
+ /qilin-tool-skill/understand-the-implementation/invocation-boundary:
45
+ en: bb8543ea29cbc451
46
+ zh: b1124fa489bf9ea4
47
+ /qilin-tool-skill/further-exploration:
48
+ en: 9dd0a826481d5903
49
+ zh: dcd1c4a40518eb7d
50
+ /qilin-tool-skill/model-experience:
51
+ en: 215e7ba838619b7b
52
+ zh: a311da3843709f90
53
+ /qilin-tool-skill/model-experience/session-catalog:
54
+ en: ed929c61dd301a56
55
+ zh: 376c8d69b6fa7df6
56
+ /qilin-tool-skill/model-experience/session-catalog/what-the-model-sees:
57
+ en: 8d2a9b439fad4c1b
58
+ zh: 4a64df685a06cbec
59
+ /qilin-tool-skill/model-experience/session-catalog/what-the-model-sees/skill-catalog-template:
60
+ en: 8ca9241e26124ce3
61
+ zh: d083f87eaae40e15
62
+ /qilin-tool-skill/model-experience/session-catalog/token-effect:
63
+ en: c05d3d46e5139c4d
64
+ zh: 8acfa475cddaeb18
65
+ /qilin-tool-skill/model-experience/session-catalog/kv-cache-effect:
66
+ en: e6e6758c96527e19
67
+ zh: 8f95e36da658c95a
68
+ /qilin-tool-skill/model-experience/tool-schema:
69
+ en: e4c7376d4f29dbd5
70
+ zh: 6b7a9eaf69c9ea53
71
+ /qilin-tool-skill/model-experience/tool-schema/what-the-model-sees:
72
+ en: b473819ceed489b1
73
+ zh: 169aef7191ee94da
74
+ /qilin-tool-skill/model-experience/tool-schema/token-effect:
75
+ en: 4a8881f7a361cb7f
76
+ zh: cba76f0578a36953
77
+ /qilin-tool-skill/model-experience/tool-schema/kv-cache-effect:
78
+ en: 77f9b9513ed7692d
79
+ zh: 249f6b975a2db718
80
+ /qilin-tool-skill/model-experience/tool-result:
81
+ en: f8ffc2b983f05ffc
82
+ zh: 8573891441963be4
83
+ /qilin-tool-skill/model-experience/tool-result/what-the-model-sees:
84
+ en: a1bc95abf3a7493c
85
+ zh: e3d200040493c0a7
86
+ /qilin-tool-skill/model-experience/tool-result/what-the-model-sees/skill-result-template:
87
+ en: 66220f8d7628e5cc
88
+ zh: d8469e173485a5ca
89
+ /qilin-tool-skill/model-experience/tool-result/what-the-model-sees/provider-managed-resource-guidance:
90
+ en: 80107e79cb15b0d0
91
+ zh: c53f14bb87aa8395
92
+ /qilin-tool-skill/model-experience/tool-result/what-the-model-sees/directory-resource-guidance:
93
+ en: 9a060c44c0d00e06
94
+ zh: 13ccf1d8b8e3d865
95
+ /qilin-tool-skill/model-experience/tool-result/what-the-model-sees/url-resource-guidance:
96
+ en: 6f4bc625155f73e3
97
+ zh: 4bc8641df028caed
98
+ /qilin-tool-skill/model-experience/tool-result/what-the-model-sees/opaque-resource-guidance:
99
+ en: 958b9c46d9785397
100
+ zh: 34f053e4ab8296c2
101
+ /qilin-tool-skill/model-experience/tool-result/token-effect:
102
+ en: 8604cca6caa413a0
103
+ zh: 1b0412b8008e76c8
104
+ /qilin-tool-skill/model-experience/tool-result/kv-cache-effect:
105
+ en: f5d5f97a153f7c70
106
+ zh: bee82b41983a66a0
107
+ /qilin-tool-skill/model-experience/tool-errors:
108
+ en: 2d4f2c8605eccab3
109
+ zh: 67f1f0218f73c6bf
110
+ /qilin-tool-skill/model-experience/tool-errors/what-the-model-sees:
111
+ en: 3e70742d93164968
112
+ zh: 63fd2159c9cc5c8c
113
+ /qilin-tool-skill/model-experience/tool-errors/token-effect:
114
+ en: 681cadd5be7b8ac1
115
+ zh: 5e169acfd30b2931
116
+ /qilin-tool-skill/model-experience/tool-errors/kv-cache-effect:
117
+ en: f5d5f97a153f7c70
118
+ zh: bee82b41983a66a0
119
+ /qilin-tool-skill/model-experience/user-explicit-invocation-injection:
120
+ en: 657124bac34aba61
121
+ zh: 00aae3514ab12676
122
+ /qilin-tool-skill/model-experience/user-explicit-invocation-injection/what-the-model-sees:
123
+ en: f9c7b7c6cb042d2f
124
+ zh: ba3372515505f413
125
+ /qilin-tool-skill/model-experience/user-explicit-invocation-injection/token-effect:
126
+ en: d1068ea431fb768f
127
+ zh: acacd161731c27c6
128
+ /qilin-tool-skill/model-experience/user-explicit-invocation-injection/kv-cache-effect:
129
+ en: 127c0139472bfaab
130
+ zh: 805dc2f730c47f40
131
+ /qilin-tool-skill/known-limitations-and-deferred-work:
132
+ en: 6017a1dc04618288
133
+ zh: d613164f0e9258f9
134
+ /qilin-tool-skill/known-limitations-and-deferred-work/dev-note:
135
+ en: e67f633dc6fe7773
136
+ zh: 3bb0c20c93f16f98
package/README.md CHANGED
@@ -1,3 +1,257 @@
1
- # Temporary Holding Version
1
+ ---
2
+ description: "The model-facing skill catalog and loader tool for users and maintainers understanding what agents see, or configuring the session skill catalog."
3
+ kind: "package-reference"
4
+ ---
2
5
 
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.
6
+ # @qilin-agent/tool-skill
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ Agents can discover and load skills during a session. Before the first request, when model-invocable skills exist and the `skill` tool is visible, they receive a durable catalog of available skill names and capped descriptions, and can use the `skill` tool to load full instructions. Users can invoke a user-invocable skill with `/name`, which injects the same instructions into that step. Catalog changes append a complete replacement, including an empty catalog that retires old names; configure `catalogDescriptionMaxLength` to limit each description.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ Mount the plugin alongside the skill registry to give agents a session skill catalog and the `skill` loader tool. It requires `ctx.agents`, `ctx.tools`, and `ctx.skills`.
29
+
30
+ ### When to choose it
31
+
32
+ Use it when agents should discover and load skills during a session. Skip it when skill loading is handled by another consumer or not needed at all — without it, providers and the registry still work, but nothing renders a catalog or a tool for the model.
33
+
34
+ ### Mount and configure
35
+
36
+ Load the plugin together with the skill registry and at least one provider. The only configuration caps the normalized description length rendered in the catalog.
37
+
38
+ ```yaml
39
+ - name: '@qilin-agent/skill'
40
+ - name: '@qilin-agent/skill-filesystem'
41
+ - name: '@qilin-agent/tool-skill'
42
+ ```
43
+
44
+ | Field | Default | Meaning |
45
+ |---|---|---|
46
+ | `catalogDescriptionMaxLength` | `500` | Maximum normalized description length rendered in the session catalog; minimum 3 |
47
+
48
+ The generated [configuration catalog](../../../docs/config-catalog.md#qilin-agenttool-skill) is the exhaustive source for every accepted field.
49
+
50
+ ### What the model gets
51
+
52
+ - **A session catalog.** When model-invocable skills exist and the `skill` tool is visible, the agent receives a durable user-role message before its first request, listing each skill's name and a capped description; the message tells the model to load a skill with the tool before acting on it, and never to infer instructions from the summary alone.
53
+ - **A loader tool.** The model calls `skill` with the exact skill name and receives the full instruction body plus resource guidance in a canonical `<skill_content>` block; the result is retained as ordinary tool history.
54
+ - **Explicit user invocation.** A `/name` token in direct user input that names a user-invocable skill injects that skill's instructions into the step, without the model having to load it.
55
+ - **Live catalog updates.** Later membership, description, or visibility changes append a complete replacement catalog; removing every skill appends an empty catalog that retires older names.
56
+
57
+ ### Observable success and failures
58
+
59
+ Loading a listed skill returns its full instructions; the model sees one canonical shape whether the load came from the tool or from a user's explicit invocation. An invalid name reports `Error: invalid skill name "<name>"`, an unknown name reports the skill is unknown or no longer available, and a skill disabled for model invocation reports it is not available for model invocation. The catalog is omitted entirely when no catalog was ever published and either no model-invocable skills exist or the `skill` tool is hidden or shadowed; after a catalog has been published, either visibility loss — the `skill` tool hidden or shadowed by a same-name scoped tool — or removal of every skill instead appends an empty catalog that retires older names.
60
+
61
+ -----
62
+
63
+ <a id="understand-the-implementation"></a>
64
+ ## Understand the implementation
65
+
66
+ <details>
67
+ <summary>Implementation internals — click to expand</summary>
68
+
69
+ This section explains how the catalog and the invocation boundary are built; the observable behavior is fully covered in [Use this package](#use-this-package) and the Model Experience section below.
70
+
71
+ ### Design concept
72
+
73
+ The package is built on two ideas. First, the catalog is a durable projection, diffed by a digest over the published entries rather than the rendered prose, so the `<system-reminder>` framing can never force a republish and consumers never re-parse the `<available_skills>` block. Second, one canonical rendering serves both load paths — the tool result and the user-explicit injection — through `renderSkillContent` shared from `qilin-skill`, so the model sees the same `<skill_content>` shape regardless of who initiated the load.
74
+
75
+ ### Source map
76
+
77
+ | File | Role |
78
+ |---|---|
79
+ | [`src/index.ts`](src/index.ts) | Plugin entry: tool registration, catalog and gesture pre-step listeners, rendering and digest |
80
+
81
+ ### Catalog lifecycle
82
+
83
+ At each eligible `agent/pre-step`, the plugin snapshots the calling session's skill catalog, applies exact `skill` tool visibility, filters to model-invocable skills, and compares a digest of the entries against the newest visible `skill-catalog` message in the session log. When the digest changed, it hands the `enter` decision a durable user-role message containing the complete replacement catalog; an empty replacement explicitly retires earlier names. An incomplete provider snapshot emits nothing and preserves the last-good view for the next pre-step. The visibility check compares against the exact tool definition this plugin registered, so a scoped same-name shadow removes both the schema and its guidance; the plugin works mounted globally or inside one agent's composition.
84
+
85
+ ### Invocation boundary
86
+
87
+ The `/name` gesture listener scans only claimed user messages: a whitespace-bounded token naming a user-invocable skill in the workspace catalog injects the same `<skill_content>` rendering as a `user`-role instructions context appended after every other injection. Unknown names and user-disabled skills stay ordinary prose. This is the only entry point for `disable-model-invocation` skills, which the catalog and the `skill` tool never expose.
88
+
89
+ </details>
90
+
91
+ -----
92
+
93
+ <a id="further-exploration"></a>
94
+ ## Further Exploration
95
+
96
+ Read these pages when the package-level contract is not enough. They move from the registry vocabulary behind the catalog to the exact tool schema and the design rationale.
97
+
98
+ - [Skill subsystem reference](../../../docs/subsystems/skills.md) — the registry and provider vocabulary behind the catalog.
99
+ - [skill package](../skill/README.md) — the registry and the shared `renderSkillContent` rendering.
100
+ - [Generated tool catalog](../../../docs/tool-catalog.md#qilin-agenttool-skill) — the exact `skill` schema the model receives.
101
+ - [User-explicit skill invocation Agent Note](../../../.agents/notes/archived/feature/2026-08-08-user-explicit-skill-invocation.md) — the `/name` gesture design.
102
+
103
+ -----
104
+
105
+ <a id="model-experience"></a>
106
+ ## Model Experience
107
+
108
+ ### Session catalog
109
+
110
+ #### What the model sees
111
+
112
+ If model-invocable skills exist and this exact `skill` tool is visible, the agent receives the catalog template below as a durable user-role message before the first request, with one data-dependent entry per sorted skill. Later membership, description, or visibility changes append a complete replacement using the same `<available_skills>` envelope; deleting every skill appends an empty envelope with an explicit instruction not to use older names. The template's closing sentence is the rule against double-loading: the user-explicit gesture boundary (the pre-step listener below) injects the same `renderSkillContent` output (shared from `@qilin-agent/skill`) inline, and the catalog tells the model to follow that block instead of re-loading the skill through the tool; the replacement-catalog template carries the same anti-double-loading rule in both arms, including the emptied catalog.
113
+
114
+ ##### Skill catalog template
115
+
116
+ ```markdown
117
+ <system-reminder>
118
+ A skill is a reusable set of task-specific instructions. The following skills are available in this session:
119
+
120
+ <available_skills>
121
+ - `<name>`: <normalized-and-capped-description>
122
+ </available_skills>
123
+
124
+ If the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.
125
+ A user may also invoke a skill directly; its <skill_content> block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.
126
+ </system-reminder>
127
+ ```
128
+
129
+ #### Token effect
130
+
131
+ Repeated input cost scales with skill count and `catalogDescriptionMaxLength`; no initial catalog tokens are sent when the list is empty or the tool is hidden or shadowed. Each actual catalog change adds one retained complete replacement message.
132
+
133
+ #### KV Cache effect
134
+
135
+ The initial durable catalog is appended after the existing reusable prefix. Dynamic changes are append-only history after that catalog, so earlier reusable tokens stay intact while each newly appended catalog and later turns form a new suffix. A new or resumed instance with a changed digest may affect cache reuse from the newly appended catalog position.
136
+
137
+ ### Tool schema
138
+
139
+ #### What the model sees
140
+
141
+ The model sees the generated [`skill` schema](../../../docs/tool-catalog.md#qilin-agenttool-skill).
142
+
143
+ #### Token effect
144
+
145
+ Fixed schema cost per request where the tool is visible.
146
+
147
+ #### KV Cache effect
148
+
149
+ Prefix-stable while the tool definition and visibility are unchanged. Shadowing, restrictions, or plugin lifecycle changes may invalidate reuse from this schema.
150
+
151
+ ### Tool result
152
+
153
+ #### What the model sees
154
+
155
+ A successful call uses the result template and the provider-managed, directory, URL, or opaque resource guidance below.
156
+
157
+ ##### Skill result template
158
+
159
+ ```markdown
160
+ <skill_content name="<escaped-name>">
161
+ <skill_resources>
162
+ <resource-guidance>
163
+ </skill_resources>
164
+
165
+ <skill_instructions>
166
+ <provider-owned-instruction-body>
167
+ </skill_instructions>
168
+ </skill_content>
169
+ ```
170
+
171
+ ##### Provider-managed resource guidance
172
+
173
+ ```markdown
174
+ Resources for this skill are managed by provider "<provider>".
175
+ Load referenced resources only as needed.
176
+ ```
177
+
178
+ ##### Directory resource guidance
179
+
180
+ ```markdown
181
+ Base directory for this skill: <path>
182
+ Resolve relative paths mentioned by this skill against the base directory before using them. Load referenced resources only as needed.
183
+ ```
184
+
185
+ ##### URL resource guidance
186
+
187
+ ```markdown
188
+ Base URL for this skill: <url>
189
+ Resolve relative URLs mentioned by this skill against the base URL before using them. Load referenced resources only as needed.
190
+ ```
191
+
192
+ ##### Opaque resource guidance
193
+
194
+ ```markdown
195
+ Resources for this skill: <description>
196
+ Load referenced resources only as needed.
197
+ ```
198
+
199
+ #### Token effect
200
+
201
+ Loaded instructions are data-dependent tool-result tokens, resent on later steps until compaction; no duplicate `agent.inject()` copy is made.
202
+
203
+ #### KV Cache effect
204
+
205
+ Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
206
+
207
+ ### Tool errors
208
+
209
+ #### What the model sees
210
+
211
+ Invalid or stale selections return exactly `Error: invalid skill name "<name>"`, `Error: skill "<name>" is unknown or no longer available`, or `Error: skill "<name>" is not available for model invocation`. Provider-thrown lookup text is data-dependent and receives the same `Error: <message>` wrapper.
212
+
213
+ #### Token effect
214
+
215
+ Only a failing call adds these retained tokens.
216
+
217
+ #### KV Cache effect
218
+
219
+ Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
220
+
221
+ ### User-explicit invocation injection
222
+
223
+ #### What the model sees
224
+
225
+ A whitespace-bounded `/name` token anywhere in a claimed user message, naming a user-invocable skill in the workspace catalog, injects that skill's full `<skill_content>` rendering (the exact result-template shape above) as a `user`-role instructions context appended after every other injection of that step — background first, the material to act on last. Only direct user input is scanned, the check runs on the loaded definition, and unknown or user-disabled names stay ordinary prose. This is the sole entry point for `disable-model-invocation` skills, which the catalog and the `skill` tool never expose; the catalog's closing sentence tells the model to follow the injected block instead of re-loading it.
226
+
227
+ #### Token effect
228
+
229
+ Each gesture adds one rendered skill body to that turn as injected context — the same size as the tool result for the same skill, paid deterministically at the user's request instead of at the model's discretion. Repeated gestures for one skill within one step inject once.
230
+
231
+ #### KV Cache effect
232
+
233
+ Append-only; the injection lands after the reusable request prefix inside the step's message batch and does not invalidate existing KV-cache entries.
234
+
235
+ ## Known Limitations and Deferred Work
236
+
237
+ <a id="known-limitations-and-deferred-work"></a>
238
+
239
+
240
+ These limits define when the catalog or the loader is a poor fit. They are current package constraints, not a task backlog.
241
+
242
+ - **The catalog omits `whenToUse`, source, and provider metadata** — routing is based only on name and a capped description; `whenToUse` remains provider metadata and is not rendered by the loaded wrapper either.
243
+ - **Loaded instruction bodies have no size cap** — a provider can return a skill large enough to consume substantial next-step context; only catalog descriptions are truncated.
244
+ - **Resources are guidance, not attachments** — the tool reports a base directory/URL/opaque hint but neither enumerates nor fetches referenced files for the model.
245
+ - **Loading is one-shot text** — there is no partial, streaming, or cached-content handle when a remote provider is slow or a skill body is large.
246
+ - **Catalog replacement is whole-list** — one changed name or description appends every visible summary; this keeps stale-name retirement explicit but costs tokens proportional to the catalog.
247
+ - **Bodies are not versioned** — body-only edits do not change the catalog digest or notify the model; a later tool call reads the current provider content while earlier tool results remain historical facts.
248
+
249
+ <a id="dev-note"></a>
250
+ ### Dev Note
251
+
252
+ <details>
253
+ <summary>Working context for maintainers — click to expand</summary>
254
+
255
+ None.
256
+
257
+ </details>