TextSkillLoader
KIT · interface · Type contract
Compiled loader.
Import
ts
import type { TextSkillLoader } from '@jangts/agent-core/kits/text-skills';js
/** @typedef {import('@jangts/agent-core/kits/text-skills').TextSkillLoader} TextSkillLoader */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/kits/text-skills, @jangts/agent-core/kits.
Definition
ts
interface TextSkillLoaderField structure
| Field | Type | Required | Description |
|---|---|---|---|
load | (request: { readonly entries: unknown; }, ports: TextSkillReadPorts) => readonly TextSkill[] | Required | Reads and validates every registered skill. |
Member index
| Member | Purpose |
|---|---|
load | Reads and validates every registered skill. |
Member details
load
Reads and validates every registered skill.
ts
TextSkillLoader.load(request: { readonly entries: unknown; }, ports: TextSkillReadPorts): readonly TextSkill[]Reads and validates every registered skill.
| Parameter | Type | Passing | Description |
|---|---|---|---|
request | { readonly entries: unknown; } | Required | — |
ports | TextSkillReadPorts | Required | — |
Fields of request
| Field | Type | Required | Description |
|---|---|---|---|
entries | unknown | Required | Read-only. See the type definition and usage context. |
Fields of ports
| Field | Type | Required | Description |
|---|---|---|---|
read | (entry: string) => string | Required | Returns the document text; throwing aborts the load. |
Returns: readonly TextSkill[].
Examples
- TextSkills: read-only text Skills: Validate registered text work instructions that the App reads; code inside the files is never executed.
Read one text Skill from an explicit source
Beginner · Node.js
ts
import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['summarize/SKILL.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120 });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'summarize/SKILL.md', kind: 'text-workflow', toolIds: [] }] }, {
read(entry) { const text = documents.get(entry); if (!text) throw new Error('来源未登记'); return text; },
});
console.log(skills[0].description);js
import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['summarize/SKILL.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120 });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'summarize/SKILL.md', kind: 'text-workflow', toolIds: [] }] }, {
read(entry) { const text = documents.get(entry); if (!text)
throw new Error('来源未登记'); return text; },
});
console.log(skills[0].description);Add the application's own entry convention to the same loader
Configuration · Node.js
Entry rules and tool references are only registration checks; the actual tools still need to be registered and authorized by the application.
ts
import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['skills/summarize.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120, maxIdChars: 32, entryFor: id => 'skills/' + id + '.md' });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'skills/summarize.md', kind: 'text-workflow', toolIds: ['read-source'] }] }, {
read(entry) { const text = documents.get(entry); if (!text) throw new Error('来源未登记'); return text; },
});
console.log(skills[0].toolIds);js
import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['skills/summarize.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120, maxIdChars: 32, entryFor: id => 'skills/' + id + '.md' });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'skills/summarize.md', kind: 'text-workflow', toolIds: ['read-source'] }] }, {
read(entry) { const text = documents.get(entry); if (!text)
throw new Error('来源未登记'); return text; },
});
console.log(skills[0].toolIds);