Skip to content
English

TextSkillLoaderDefinition ​

KIT · interface · 类型合同

Loader limits, parsing hooks and rejection wording.

导入 ​

ts
import type { TextSkillLoaderDefinition } from '@jangts/agent-core/kits/text-skills';
js
/** @typedef {import('@jangts/agent-core/kits/text-skills').TextSkillLoaderDefinition} TextSkillLoaderDefinition */

其他公开入口:@jangts/agent-core、@jangts/agent-core/types、@jangts/agent-core/structs、@jangts/agent-core/kits/text-skills、@jangts/agent-core/kits。

定义 ​

ts
interface TextSkillLoaderDefinition

字段结构 ​

字段类型必需说明
maxInstructionCharsnumber必需只读。Maximum characters of the instruction body; larger documents are rejected.
maxDescriptionCharsnumber必需只读。Maximum characters of the description header.
maxIdCharsnumber | undefined可省略只读。Maximum id length; defaults to 64.
entryFor((id: string) => string) | undefined可省略只读。Maps an id to its expected document path; defaults to <id>/SKILL.md.
parseHeader((instructions: string) => TextSkillHeader | undefined) | undefined可省略只读。Default parser accepts the strict name/description header; hosts can inject a YAML parser.
tagsreadonly string[] | undefined可省略只读。Diagnostic tags attached to loader rejections.
errors{ readonly catalog?: BreakReason; readonly registration?: BreakReason; readonly document?: BreakReason; } | undefined可省略只读。见类型定义及调用场景。

使用示例 ​

从明确来源读取一份文本 Skill ​

入门 · 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);

同一 loader 增加应用自己的入口约定 ​

配置 · Node.js

入口规则和工具引用只做登记校验;实际工具仍需应用注册和授权。

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);

相关策略源码 ​

相关定义 ​

接口参考、使用示例与开发指南。