@deepseek-ai/dsh-tool-skill 0.2.2-rc.1 → 0.2.2-rc.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/lib/index.js CHANGED
@@ -708,6 +708,7 @@ new Set([
708
708
  "team/member",
709
709
  "team/message/delivered",
710
710
  "team/message/queued",
711
+ "team/mode",
711
712
  "team/task",
712
713
  "todo/write",
713
714
  "tool-workflow/agent-end",
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAexC,eAAO,MAAM,IAAI,eAAe,CAAA;AAChC,eAAO,MAAM,MAAM,UAAoD,CAAA;AAGvE;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAA;IACtB,4GAA4G;IAC5G,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAA;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACrF;AAED,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,gBAAgB;QACxB,eAAe,EAAE,kBAAkB,CAAA;KACpC;CACF;AAaD,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,wFAAwF;IACxF,2BAA2B,CAAC,EAAE,MAAM,CAAA;CACrC;AAED,yEAAyE;AACzE,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAA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AQ;YACnC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;gBACvD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;gBACrB,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-skill",
3
3
  "description": "Model-facing skill loading tool for the DeepSeek Harness",
4
- "version": "0.2.2-rc.1",
4
+ "version": "0.2.2-rc.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,32 +25,35 @@
25
25
  "files": [
26
26
  "locale/*.json",
27
27
  "lib/index.js",
28
- "lib/types/**/*.d.ts"
28
+ "lib/types/**/*.d.ts",
29
+ "lib/types/**/*.d.ts.map",
30
+ "lib/**/*.js.map",
31
+ "src"
29
32
  ],
30
33
  "license": "MIT",
31
34
  "peerDependencies": {
32
- "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
33
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
34
- "@deepseek-ai/dsh-skill": "0.2.2-rc.1",
35
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
35
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.3",
36
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
37
+ "@deepseek-ai/dsh-skill": "0.2.2-rc.3",
38
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.3",
36
39
  "@deepseek-ai/cordis": "~4.1.0",
37
- "@deepseek-ai/dsh-working-directory": "0.2.2-rc.1"
40
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.3"
38
41
  },
39
42
  "dependencies": {
40
43
  "@deepseek-ai/schemastery": "~3.19.0"
41
44
  },
42
45
  "devDependencies": {
43
- "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
44
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.1",
45
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
46
- "@deepseek-ai/dsh-scope": "0.2.2-rc.1",
47
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
48
- "@deepseek-ai/dsh-skill": "0.2.2-rc.1",
49
- "@deepseek-ai/dsh-skill-filesystem": "0.2.2-rc.1",
50
- "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.1",
51
- "@deepseek-ai/dsh-tool-testkit": "0.2.2-rc.1",
52
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
46
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.3",
47
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.3",
48
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
49
+ "@deepseek-ai/dsh-scope": "0.2.2-rc.3",
50
+ "@deepseek-ai/dsh-session": "0.2.2-rc.3",
51
+ "@deepseek-ai/dsh-skill": "0.2.2-rc.3",
52
+ "@deepseek-ai/dsh-skill-filesystem": "0.2.2-rc.3",
53
+ "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.3",
54
+ "@deepseek-ai/dsh-tool-testkit": "0.2.2-rc.3",
55
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.3",
53
56
  "@deepseek-ai/cordis": "~4.1.0",
54
- "@deepseek-ai/dsh-working-directory": "0.2.2-rc.1"
57
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.3"
55
58
  }
56
59
  }
package/src/index.ts ADDED
@@ -0,0 +1,451 @@
1
+ /**
2
+ * Durable session skill catalog and model-facing `skill` loader tool.
3
+ *
4
+ * @module @deepseek-ai/dsh-tool-skill
5
+ */
6
+
7
+ import type {} from '@deepseek-ai/dsh-working-directory'
8
+ import { createHash } from 'node:crypto'
9
+ import type { Context } from '@deepseek-ai/cordis'
10
+ import z from '@deepseek-ai/schemastery'
11
+ import type { Agent, PreStepDecision } from '@deepseek-ai/dsh-agent'
12
+ import { defineTool } from '@deepseek-ai/dsh-tools'
13
+ import { createUserMessage } from '@deepseek-ai/dsh-llm'
14
+ import { SessionSeq, type UserMessage } from '@deepseek-ai/dsh-session'
15
+ import {
16
+ escapeText,
17
+ isModelInvocable,
18
+ isSkillName,
19
+ isUserInvocable,
20
+ renderSkillContent,
21
+ type SkillInvocationSource,
22
+ type SkillSummary,
23
+ } from '@deepseek-ai/dsh-skill'
24
+
25
+ export const name = 'tool-skill'
26
+ export const inject = ['agents', 'tools', 'skills', 'workingDirectory']
27
+
28
+ const DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH = 500
29
+ /**
30
+ * Durable provider and item records for one published session skill catalog. The catalog is a
31
+ * `catalog`-form context, so it records the entries it published beside the
32
+ * model-facing prose: a consumer presenting the list must not re-parse the
33
+ * `<available_skills>` block, whose framing exists for the model.
34
+ */
35
+ export interface SkillCatalogSource {
36
+ readonly kind: 'skill-catalog'
37
+ readonly form: 'catalog'
38
+ /** Marks a replacement catalog rather than this session's first publication. */
39
+ readonly update?: true
40
+ /** Some discovery failed; entries contain only skills found in this observation. Absence means complete. */
41
+ readonly incomplete?: true
42
+ /** Exactly the entries this message published, in catalog order. */
43
+ readonly entries: readonly { readonly name: string; readonly description: string }[]
44
+ }
45
+
46
+ declare module '@deepseek-ai/dsh-llm' {
47
+ interface MessageSourceMap {
48
+ 'skill-catalog': SkillCatalogSource
49
+ }
50
+ }
51
+
52
+ /** Durable entry list mirroring the rendered catalog lines, for non-model consumers. */
53
+ function catalogSourceEntries(
54
+ skills: SkillSummary[],
55
+ descriptionMaxLength: number,
56
+ ): SkillCatalogSource['entries'] {
57
+ return skills.map(skill => ({
58
+ name: skill.name,
59
+ description: catalogDescription(skill.description, descriptionMaxLength),
60
+ }))
61
+ }
62
+
63
+ /** Model-facing skill catalog configuration. */
64
+ export interface Config {
65
+ /** Maximum normalized description length rendered in the session catalog; minimum 3. */
66
+ catalogDescriptionMaxLength?: number
67
+ }
68
+
69
+ /** Validate and default the model-facing skill catalog configuration. */
70
+ export const Config: z<Config> = z.object({
71
+ catalogDescriptionMaxLength: z.number().default(DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH),
72
+ })
73
+
74
+ /**
75
+ * Register the model-facing skill loader and its visibility-matched
76
+ * durable session catalog. The catalog is emitted only when the calling agent
77
+ * resolves this plugin's exact tool registration; a restriction or scoped
78
+ * same-name shadow therefore removes both the schema and its call guidance.
79
+ */
80
+ export function apply(ctx: Context, config: Config = {}): void {
81
+ const catalogDescriptionMaxLength = config.catalogDescriptionMaxLength ?? DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH
82
+ assertPositiveInteger('catalogDescriptionMaxLength', catalogDescriptionMaxLength, 3)
83
+
84
+ const skillTool = defineTool({
85
+ name: 'skill',
86
+ description: 'Load the full instructions for a skill. Call it before acting on a task that names or clearly matches a skill in the session skill catalog.',
87
+ parameters: {
88
+ name: { type: 'string', required: true, description: 'The exact skill name from the available skills list.' },
89
+ },
90
+ output: {
91
+ schema: {
92
+ type: 'object',
93
+ additionalProperties: false,
94
+ properties: {
95
+ name: { type: 'string', required: true },
96
+ provider: { type: 'string', required: true },
97
+ resourceBase: {
98
+ oneOf: [
99
+ {
100
+ type: 'object',
101
+ additionalProperties: false,
102
+ properties: {
103
+ kind: { type: 'string', required: true, const: 'directory' },
104
+ path: { type: 'string', required: true },
105
+ },
106
+ },
107
+ {
108
+ type: 'object',
109
+ additionalProperties: false,
110
+ properties: {
111
+ kind: { type: 'string', required: true, const: 'url' },
112
+ url: { type: 'string', required: true },
113
+ },
114
+ },
115
+ {
116
+ type: 'object',
117
+ additionalProperties: false,
118
+ properties: {
119
+ kind: { type: 'string', required: true, const: 'opaque' },
120
+ description: { type: 'string', required: true },
121
+ },
122
+ },
123
+ ],
124
+ },
125
+ content: { type: 'string', required: true },
126
+ },
127
+ },
128
+ render: (_args, value) => [{ type: 'text', text: renderSkillContent(value) }],
129
+ },
130
+ async execute(args, exec) {
131
+ if (!isSkillName(args.name)) {
132
+ throw new Error(`invalid skill name "${args.name}"`)
133
+ }
134
+ // The agent is its own scope key, so the lookup resolves the layered
135
+ // registry exactly as this agent's composition sees it.
136
+ const cwd = exec.agent === undefined ? undefined : await ctx.workingDirectory.ensure(exec.agent, exec.signal)
137
+ const lookup = { cwd, signal: exec.signal, scope: exec.agent }
138
+ const summary = (await ctx.skills.list(lookup)).find(skill => skill.name === args.name)
139
+ if (!summary) {
140
+ throw new Error(`skill "${args.name}" is unknown or no longer available`)
141
+ }
142
+ if (!isModelInvocable(summary)) {
143
+ throw new Error(`skill "${args.name}" is not available for model invocation`)
144
+ }
145
+ const skill = await ctx.skills.get(args.name, lookup)
146
+ if (!skill) {
147
+ throw new Error(`skill "${args.name}" is unknown or no longer available`)
148
+ }
149
+ if (!isModelInvocable(skill)) {
150
+ throw new Error(`skill "${args.name}" is not available for model invocation`)
151
+ }
152
+ return {
153
+ name: skill.name,
154
+ provider: skill.provider,
155
+ ...skill.resourceBase !== undefined ? {
156
+ resourceBase: { ...skill.resourceBase },
157
+ } : {},
158
+ content: skill.content,
159
+ }
160
+ },
161
+ presentCall(args) {
162
+ return { card: 'generic', title: `Load skill ${args.name}`, kind: 'read', rawInput: args.name }
163
+ },
164
+ })
165
+ ctx.tools.register(skillTool)
166
+
167
+ // User-explicit skill invocation: a claimed user message whose first line
168
+ // starts with `/<name>` naming a user-invocable skill is a deterministic
169
+ // load gesture. The rendered body enters this step as injected
170
+ // instructions context appended after every other injection — background
171
+ // first (workspace rules, runtime policy, the catalog), the material the
172
+ // model must act on last, closest to its answer. Registration order makes
173
+ // that placement deterministic: this listener registers before the catalog
174
+ // listener, so the waterfall hands it the catalog-bearing list to extend.
175
+ // Only `source.kind === 'user'` messages are scanned — external text
176
+ // cannot forge the gesture — and a token naming no user-invocable skill
177
+ // stays ordinary prose (the command registry is a different closed
178
+ // namespace, resolved client-side before a line ever becomes a prompt).
179
+ // This is the only entry point for `disable-model-invocation` skills; the
180
+ // catalog and the `skill` tool below never see them.
181
+ ctx.on('agent/pre-step', async (
182
+ { agent, messages, signal },
183
+ next,
184
+ ): Promise<PreStepDecision> => {
185
+ const decision = await next()
186
+ if (decision.kind === 'reject') return decision
187
+ const names = invokedSkillNames(messages)
188
+ if (names.length === 0) return decision
189
+ signal.throwIfAborted()
190
+ const lookup = { cwd: await ctx.workingDirectory.ensure(agent, signal), signal, scope: agent }
191
+ const injections: UserMessage[] = []
192
+ for (const name of names) {
193
+ const skill = await ctx.skills.get(name, lookup)
194
+ signal.throwIfAborted()
195
+ // Unknown names and user-disabled skills stay plain prose: the
196
+ // gesture was never a claim this boundary recognizes. The check sits
197
+ // on the loaded definition — the single lookup that produces what is
198
+ // actually injected.
199
+ if (skill === undefined || !isUserInvocable(skill)) continue
200
+ const source: SkillInvocationSource = { kind: 'skill-invocation', name, form: 'instructions' }
201
+ injections.push(createUserMessage({
202
+ content: [{ type: 'text', text: renderSkillContent(skill) }],
203
+ source,
204
+ }))
205
+ }
206
+ if (injections.length === 0) return decision
207
+ return { ...decision, messages: [...decision.messages, ...injections] }
208
+ })
209
+
210
+ // Register after the tool so reverse teardown removes guidance first. Exact definition
211
+ // identity prevents a scoped shadow merely named `skill` from inheriting this catalog.
212
+ //
213
+ // The comparison is against the definition this plugin registered, not against
214
+ // a lookup of its own name: `register()` files into the CALLING context's
215
+ // scope, so a plugin mounted inside an agent preset registers for that agent
216
+ // alone and an unscoped lookup correctly finds nothing.
217
+ ctx.on('agent/pre-step', async (
218
+ { agent, signal },
219
+ next,
220
+ ): Promise<PreStepDecision> => {
221
+ const decision = await next()
222
+ if (decision.kind === 'reject') return decision
223
+ signal.throwIfAborted()
224
+ const toolVisible = ctx.tools.get(skillTool.name, agent) === skillTool
225
+ const snapshot = toolVisible
226
+ ? await ctx.skills.snapshot({ cwd: await ctx.workingDirectory.ensure(agent, signal), signal, scope: agent })
227
+ : { skills: [], complete: true }
228
+ signal.throwIfAborted()
229
+ const skills = snapshot.skills.filter(isModelInvocable)
230
+ const entries = catalogSourceEntries(skills, catalogDescriptionMaxLength)
231
+ const incomplete = !snapshot.complete
232
+ const digest = digestCatalogEntries(entries, incomplete)
233
+ const history = catalogHistory(agent)
234
+ const existing = catalogMessage(decision.messages)
235
+ if (history.visibleDigest === digest) {
236
+ return existing === undefined
237
+ ? decision
238
+ : { ...decision, messages: decision.messages.filter(message => message.id !== existing.message.id) }
239
+ }
240
+ if (existing !== undefined && digestCatalogEntries(existing.entries, existing.incomplete) === digest) return decision
241
+ if (!history.published && skills.length === 0 && !incomplete) {
242
+ return existing === undefined
243
+ ? decision
244
+ : { ...decision, messages: decision.messages.filter(message => message.id !== existing.message.id) }
245
+ }
246
+ const catalog = history.published
247
+ ? renderCatalogUpdate(entries, incomplete)
248
+ : renderCatalogMessage(entries, incomplete)
249
+ return {
250
+ ...decision,
251
+ messages: existing === undefined
252
+ ? [...decision.messages, catalog]
253
+ : decision.messages.map(message => message.id === existing.message.id ? catalog : message),
254
+ }
255
+ })
256
+ }
257
+
258
+ function renderCatalogMessage(entries: SkillCatalogSource['entries'], incomplete: boolean): UserMessage {
259
+ return createUserMessage({
260
+ content: [{
261
+ type: 'text',
262
+ text: [
263
+ '<system-reminder>',
264
+ entries.length === 0
265
+ ? 'No skills could be confirmed in this discovery attempt.'
266
+ : 'A skill is a reusable set of task-specific instructions. The following skills are available in this session:',
267
+ '',
268
+ '<available_skills>',
269
+ ...renderCatalogEntries(entries),
270
+ '</available_skills>',
271
+ '',
272
+ ...incomplete ? [incompleteCatalogNotice(), ''] : [],
273
+ entries.length === 0
274
+ ? 'Wait for an updated catalog before calling the `skill` tool. Do not infer skill instructions from an empty catalog.'
275
+ : "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.",
276
+ '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.',
277
+ '</system-reminder>',
278
+ ].join('\n'),
279
+ }],
280
+ source: {
281
+ kind: 'skill-catalog',
282
+ form: 'catalog',
283
+ entries,
284
+ ...incomplete ? { incomplete: true } : {},
285
+ },
286
+ })
287
+ }
288
+
289
+ function renderCatalogUpdate(entries: SkillCatalogSource['entries'], incomplete: boolean): UserMessage {
290
+ const availability = entries.length === 0
291
+ ? [
292
+ incomplete
293
+ ? 'No skills could be confirmed in this discovery attempt. Do not use names from earlier skill catalogs.'
294
+ : 'No skills are currently available through the `skill` tool. Do not use names from earlier skill catalogs.',
295
+ 'A user may still invoke a skill directly; its <skill_content> block then appears in this conversation. Follow it, and do not call the `skill` tool for it.',
296
+ ]
297
+ : [
298
+ 'Use only names in this replacement catalog. If the user names a listed skill, or the task clearly matches its description, call the `skill` tool with the exact name before acting.',
299
+ '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.',
300
+ ]
301
+ return createUserMessage({
302
+ content: [{
303
+ type: 'text',
304
+ text: [
305
+ '<system-reminder>',
306
+ incomplete
307
+ ? 'Skill discovery is incomplete. This catalog of currently available skills replaces every earlier available-skills list in this session:'
308
+ : 'The available skill catalog changed. This complete catalog replaces every earlier available-skills list in this session:',
309
+ '',
310
+ '<available_skills>',
311
+ ...renderCatalogEntries(entries),
312
+ '</available_skills>',
313
+ '',
314
+ ...incomplete ? [incompleteCatalogNotice(), ''] : [],
315
+ ...availability,
316
+ '</system-reminder>',
317
+ ].join('\n'),
318
+ }],
319
+ source: {
320
+ kind: 'skill-catalog',
321
+ form: 'catalog',
322
+ update: true,
323
+ entries,
324
+ ...incomplete ? { incomplete: true } : {},
325
+ },
326
+ })
327
+ }
328
+
329
+ function incompleteCatalogNotice(): string {
330
+ return 'Some skills could not be checked. Only confirmed skills are listed; a lower-priority definition of the same name may be selected when a preferred source is unavailable. Discovery will be retried on the next request.'
331
+ }
332
+
333
+ /**
334
+ * Model-facing catalog lines, projected from the same entries the source records.
335
+ * The pseudo-XML escaping belongs to this frame, not to the published fact, so it
336
+ * is applied here and never stored. Names are `isSkillName`-validated and carry
337
+ * no escapable character.
338
+ */
339
+ function renderCatalogEntries(entries: SkillCatalogSource['entries']): string[] {
340
+ return entries.map(entry => `- \`${entry.name}\`: ${escapeText(entry.description)}`)
341
+ }
342
+
343
+ /**
344
+ * Catalog identity includes durable entries and completeness so recovery clears
345
+ * a discovery warning even when the entries are unchanged.
346
+ */
347
+ function digestCatalogEntries(entries: SkillCatalogSource['entries'], incomplete = false): string {
348
+ // JSON per entry rather than a separator character: every separator is itself
349
+ // a legal description character, so only quoting makes the boundary exact.
350
+ const canonical = entries.map(entry => JSON.stringify([entry.name, entry.description])).join('\n')
351
+ return createHash('sha256')
352
+ .update(incomplete ? 'incomplete\n' : '')
353
+ .update(canonical)
354
+ .digest('hex')
355
+ }
356
+
357
+ /**
358
+ * Entries of one durable catalog message, or undefined when the record is not a
359
+ * usable catalog.
360
+ *
361
+ * `agent.session.snapshotEvents()` may contain a resumed, forked, or externally written seed,
362
+ * and seed validation only guarantees a source object with a non-empty `kind`;
363
+ * no per-kind field is checked there. An unreadable record is therefore treated
364
+ * as "not this plugin's catalog" — the posture the replaced content digest had —
365
+ * rather than throwing inside the step listener, which would fail every
366
+ * subsequent turn of that session.
367
+ */
368
+ function readCatalogEntries(source: unknown): SkillCatalogSource['entries'] | undefined {
369
+ const entries = (source as { entries?: unknown }).entries
370
+ if (!Array.isArray(entries)) return undefined
371
+ const readable: { name: string; description: string }[] = []
372
+ for (const entry of entries as readonly unknown[]) {
373
+ if (typeof entry !== 'object' || entry === null) return undefined
374
+ const { name, description } = entry as { name?: unknown; description?: unknown }
375
+ if (typeof name !== 'string' || name === '' || typeof description !== 'string') return undefined
376
+ readable.push({ name, description })
377
+ }
378
+ return readable
379
+ }
380
+
381
+ function catalogHistory(agent: Agent): { visibleDigest?: string; published: boolean } {
382
+ const visible = new Set(agent.session.surface.nodes)
383
+ let published = false
384
+ for (let index = agent.session.seq - 1; index >= 0; index -= 1) {
385
+ // oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
386
+ const event = agent.session.eventAt(SessionSeq(index))
387
+ if (event === undefined) {
388
+ throw new Error(`skill catalog cannot read seq ${String(index)} below the current Session length`)
389
+ }
390
+ if (event.type !== 'user/message' || event.data.source.kind !== 'skill-catalog') continue
391
+ const entries = readCatalogEntries(event.data.source)
392
+ if (entries === undefined) continue
393
+ const digest = digestCatalogEntries(entries, event.data.source.incomplete === true)
394
+ published = true
395
+ if (visible.has(event.seq)) return { visibleDigest: digest, published }
396
+ }
397
+ return { published }
398
+ }
399
+
400
+ function catalogMessage(
401
+ messages: readonly UserMessage[],
402
+ ): { message: UserMessage; entries: SkillCatalogSource['entries']; incomplete: boolean } | undefined {
403
+ for (const message of messages) {
404
+ if (message.source.kind !== 'skill-catalog') continue
405
+ const entries = readCatalogEntries(message.source)
406
+ if (entries !== undefined) return { message, entries, incomplete: message.source.incomplete === true }
407
+ }
408
+ return undefined
409
+ }
410
+
411
+ function catalogDescription(value: string, maxLength: number): string {
412
+ const normalized = value.replaceAll(/\s+/g, ' ').trim()
413
+ return normalized.length <= maxLength ? normalized : `${normalized.slice(0, maxLength - 3)}...`
414
+ }
415
+
416
+ function assertPositiveInteger(name: string, value: number, minimum = 1): void {
417
+ if (!Number.isInteger(value) || value < minimum) {
418
+ throw new Error(`tool-skill: ${name} must be an integer greater than or equal to ${minimum}`)
419
+ }
420
+ }
421
+
422
+ /**
423
+ * A whitespace-bounded `/name` token (the public skill-name grammar) anywhere
424
+ * in the text — the same word-boundary shape the transcript chip decoration
425
+ * uses, so a gesture reads as one wherever it sits in the sentence. A second
426
+ * `/` or any non-boundary character breaks the match, which keeps file paths
427
+ * (`/usr/bin`) and fractions (`5/8`) out.
428
+ */
429
+ const SKILL_GESTURE = /(^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/g
430
+
431
+ /**
432
+ * `/name` gesture tokens from the claimed user messages, deduplicated in
433
+ * first-seen order. Every text block of direct user input is scanned; no
434
+ * other source can forge a gesture.
435
+ * @param messages - the step's claimed batch.
436
+ * @returns candidate skill names, unvalidated against the registry.
437
+ */
438
+ function invokedSkillNames(messages: readonly UserMessage[]): string[] {
439
+ const names: string[] = []
440
+ for (const message of messages) {
441
+ if ((message.source as { kind?: unknown }).kind !== 'user') continue
442
+ for (const block of message.content) {
443
+ if (block.type !== 'text') continue
444
+ for (const match of block.text.matchAll(SKILL_GESTURE)) {
445
+ const name = match[2]
446
+ if (name !== undefined && !names.includes(name)) names.push(name)
447
+ }
448
+ }
449
+ }
450
+ return names
451
+ }