@yuaone/core 0.3.3 → 0.4.0
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/dist/agent-loop.d.ts +62 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +705 -18
- package/dist/agent-loop.js.map +1 -1
- package/dist/background-agent.d.ts +110 -0
- package/dist/background-agent.d.ts.map +1 -0
- package/dist/background-agent.js +255 -0
- package/dist/background-agent.js.map +1 -0
- package/dist/coding-standards.d.ts +45 -0
- package/dist/coding-standards.d.ts.map +1 -0
- package/dist/coding-standards.js +1152 -0
- package/dist/coding-standards.js.map +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -6
- package/dist/constants.js.map +1 -1
- package/dist/context-manager.d.ts +6 -0
- package/dist/context-manager.d.ts.map +1 -1
- package/dist/context-manager.js +23 -4
- package/dist/context-manager.js.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/llm-client.d.ts +8 -3
- package/dist/llm-client.d.ts.map +1 -1
- package/dist/llm-client.js +64 -13
- package/dist/llm-client.js.map +1 -1
- package/dist/plugin-auto-loader.d.ts +108 -0
- package/dist/plugin-auto-loader.d.ts.map +1 -0
- package/dist/plugin-auto-loader.js +743 -0
- package/dist/plugin-auto-loader.js.map +1 -0
- package/dist/plugin-registry.d.ts +112 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +319 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/plugin-types.d.ts +388 -0
- package/dist/plugin-types.d.ts.map +1 -0
- package/dist/plugin-types.js +8 -0
- package/dist/plugin-types.js.map +1 -0
- package/dist/plugin-validator.d.ts +54 -0
- package/dist/plugin-validator.d.ts.map +1 -0
- package/dist/plugin-validator.js +129 -0
- package/dist/plugin-validator.js.map +1 -0
- package/dist/repo-knowledge-graph.d.ts +112 -0
- package/dist/repo-knowledge-graph.d.ts.map +1 -0
- package/dist/repo-knowledge-graph.js +561 -0
- package/dist/repo-knowledge-graph.js.map +1 -0
- package/dist/role-registry.js +1 -1
- package/dist/role-registry.js.map +1 -1
- package/dist/self-debug-loop.d.ts +257 -0
- package/dist/self-debug-loop.d.ts.map +1 -0
- package/dist/self-debug-loop.js +870 -0
- package/dist/self-debug-loop.js.map +1 -0
- package/dist/skill-learner.d.ts +136 -0
- package/dist/skill-learner.d.ts.map +1 -0
- package/dist/skill-learner.js +382 -0
- package/dist/skill-learner.js.map +1 -0
- package/dist/skill-loader.d.ts +90 -0
- package/dist/skill-loader.d.ts.map +1 -0
- package/dist/skill-loader.js +309 -0
- package/dist/skill-loader.js.map +1 -0
- package/dist/specialist-registry.d.ts +132 -0
- package/dist/specialist-registry.d.ts.map +1 -0
- package/dist/specialist-registry.js +413 -0
- package/dist/specialist-registry.js.map +1 -0
- package/dist/sub-agent-prompts.d.ts +45 -0
- package/dist/sub-agent-prompts.d.ts.map +1 -0
- package/dist/sub-agent-prompts.js +177 -0
- package/dist/sub-agent-prompts.js.map +1 -0
- package/dist/sub-agent-router.d.ts +75 -0
- package/dist/sub-agent-router.d.ts.map +1 -0
- package/dist/sub-agent-router.js +174 -0
- package/dist/sub-agent-router.js.map +1 -0
- package/dist/sub-agent.d.ts +48 -0
- package/dist/sub-agent.d.ts.map +1 -1
- package/dist/sub-agent.js +108 -5
- package/dist/sub-agent.js.map +1 -1
- package/dist/system-prompt.d.ts +26 -0
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +177 -7
- package/dist/system-prompt.js.map +1 -1
- package/dist/task-classifier.d.ts +25 -1
- package/dist/task-classifier.d.ts.map +1 -1
- package/dist/task-classifier.js +171 -1
- package/dist/task-classifier.js.map +1 -1
- package/dist/tool-planner.d.ts +160 -0
- package/dist/tool-planner.d.ts.map +1 -0
- package/dist/tool-planner.js +501 -0
- package/dist/tool-planner.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/plugins/git/patterns/branch-patterns.json +101 -0
- package/plugins/git/patterns/commit-patterns.json +186 -0
- package/plugins/git/plugin.yaml +128 -0
- package/plugins/git/skills/branch-strategy.md +172 -0
- package/plugins/git/skills/commit-conv.md +178 -0
- package/plugins/git/skills/conflict-resolve.md +159 -0
- package/plugins/git/skills/history-clean.md +199 -0
- package/plugins/git/skills/pr-review.md +196 -0
- package/plugins/git/strategies/conflict-resolve.json +244 -0
- package/plugins/git/strategies/release-flow.json +292 -0
- package/plugins/git/validators/rules.json +348 -0
- package/plugins/react/patterns/anti-patterns.json +88 -0
- package/plugins/react/patterns/components.json +80 -0
- package/plugins/react/patterns/hooks.json +72 -0
- package/plugins/react/plugin.yaml +229 -0
- package/plugins/react/skills/bugfix.md +208 -0
- package/plugins/react/skills/component-gen.md +206 -0
- package/plugins/react/skills/hook-extract.md +208 -0
- package/plugins/react/skills/ssr.md +256 -0
- package/plugins/react/skills/test.md +273 -0
- package/plugins/react/strategies/build-fix.json +43 -0
- package/plugins/react/strategies/hook-loop-fix.json +36 -0
- package/plugins/react/strategies/hydration-fix.json +42 -0
- package/plugins/react/validators/rules.json +92 -0
- package/plugins/typescript/patterns/best-practices.json +25 -0
- package/plugins/typescript/patterns/common-errors.json +32 -0
- package/plugins/typescript/plugin.yaml +74 -0
- package/plugins/typescript/skills/debug.md +23 -0
- package/plugins/typescript/skills/migration.md +24 -0
- package/plugins/typescript/skills/refactor.md +22 -0
- package/plugins/typescript/skills/strict-mode.md +23 -0
- package/plugins/typescript/strategies/strict-migration.json +37 -0
- package/plugins/typescript/strategies/type-error-fix.json +37 -0
- package/plugins/typescript/validators/rules.json +28 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillLoader — Loads and resolves skill templates from plugins
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Parse skill markdown into structured ParsedSkill objects
|
|
6
|
+
* - Resolve template variables with context
|
|
7
|
+
* - Match skill triggers against runtime context
|
|
8
|
+
* - Load local skills from .yuan/skills/ directory
|
|
9
|
+
*/
|
|
10
|
+
import type { SkillDefinition, SkillContext, ParsedSkill } from "./plugin-types.js";
|
|
11
|
+
export declare class SkillLoader {
|
|
12
|
+
/**
|
|
13
|
+
* Load and parse a skill's markdown template into a ParsedSkill.
|
|
14
|
+
* The template can be inline content or a file path — this method
|
|
15
|
+
* accepts the raw template string (caller is responsible for reading files).
|
|
16
|
+
*/
|
|
17
|
+
loadTemplate(skill: SkillDefinition, templateContent?: string): ParsedSkill;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve template variables in a skill template string.
|
|
20
|
+
* Variables use {{variable}} syntax.
|
|
21
|
+
*
|
|
22
|
+
* @param template - Template string with {{variable}} placeholders
|
|
23
|
+
* @param context - Key-value pairs to substitute
|
|
24
|
+
* @returns Resolved template string
|
|
25
|
+
*/
|
|
26
|
+
resolveTemplate(template: string, context: Record<string, unknown>): string;
|
|
27
|
+
/**
|
|
28
|
+
* Match skill triggers against the current context.
|
|
29
|
+
* Returns skills whose triggers match, sorted by confidence (highest first).
|
|
30
|
+
*/
|
|
31
|
+
matchTriggers(skills: SkillDefinition[], context: SkillContext): SkillDefinition[];
|
|
32
|
+
/**
|
|
33
|
+
* Parse the ## Identity section from skill markdown.
|
|
34
|
+
*
|
|
35
|
+
* Expected format:
|
|
36
|
+
* ```
|
|
37
|
+
* ## Identity
|
|
38
|
+
* - domain: react
|
|
39
|
+
* - type: bugfix
|
|
40
|
+
* - confidence: 0.85
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
private parseIdentity;
|
|
44
|
+
/**
|
|
45
|
+
* Parse ### Known Error Patterns subsections.
|
|
46
|
+
*
|
|
47
|
+
* Expected format:
|
|
48
|
+
* ```
|
|
49
|
+
* ### Pattern Name
|
|
50
|
+
* - **증상**: "..."
|
|
51
|
+
* - **원인**: ...
|
|
52
|
+
* - **전략**: 1. ... 2. ...
|
|
53
|
+
* - **도구 시퀀스**: grep → file_read → ...
|
|
54
|
+
* - **함정**: ...
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
private parseKnownPatterns;
|
|
58
|
+
/**
|
|
59
|
+
* Parse ## Validation Checklist section.
|
|
60
|
+
* Extracts - [ ] items.
|
|
61
|
+
*/
|
|
62
|
+
private parseValidationChecklist;
|
|
63
|
+
/**
|
|
64
|
+
* Parse tool sequence from content.
|
|
65
|
+
* Looks for patterns like: "도구 시퀀스: grep → file_read → file_edit"
|
|
66
|
+
*/
|
|
67
|
+
private parseToolSequence;
|
|
68
|
+
/**
|
|
69
|
+
* Score how well a skill matches the given context.
|
|
70
|
+
* Returns 0 for no match, higher for better match.
|
|
71
|
+
*/
|
|
72
|
+
private scoreTriggerMatch;
|
|
73
|
+
/**
|
|
74
|
+
* Extract list items following a marker pattern.
|
|
75
|
+
*/
|
|
76
|
+
private extractListItems;
|
|
77
|
+
/**
|
|
78
|
+
* Extract numbered items (1. ... 2. ... 3. ...).
|
|
79
|
+
*/
|
|
80
|
+
private extractNumberedItems;
|
|
81
|
+
/**
|
|
82
|
+
* Extract tool sequence from a pattern section.
|
|
83
|
+
*/
|
|
84
|
+
private extractToolSequence;
|
|
85
|
+
/**
|
|
86
|
+
* Simple glob matching for file patterns.
|
|
87
|
+
*/
|
|
88
|
+
private globMatch;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=skill-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-loader.d.ts","sourceRoot":"","sources":["../src/skill-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAS3B,qBAAa,WAAW;IACtB;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW;IAiC3E;;;;;;;OAOG;IACH,eAAe,CACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM;IAoBT;;;OAGG;IACH,aAAa,CACX,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,EAAE,YAAY,GACpB,eAAe,EAAE;IAoBpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,aAAa;IAuBrB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,kBAAkB;IAoC1B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAkBhC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAczB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA8DzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoB5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;OAEG;IACH,OAAO,CAAC,SAAS;CAclB"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillLoader — Loads and resolves skill templates from plugins
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Parse skill markdown into structured ParsedSkill objects
|
|
6
|
+
* - Resolve template variables with context
|
|
7
|
+
* - Match skill triggers against runtime context
|
|
8
|
+
* - Load local skills from .yuan/skills/ directory
|
|
9
|
+
*/
|
|
10
|
+
export class SkillLoader {
|
|
11
|
+
/**
|
|
12
|
+
* Load and parse a skill's markdown template into a ParsedSkill.
|
|
13
|
+
* The template can be inline content or a file path — this method
|
|
14
|
+
* accepts the raw template string (caller is responsible for reading files).
|
|
15
|
+
*/
|
|
16
|
+
loadTemplate(skill, templateContent) {
|
|
17
|
+
const content = templateContent ?? skill.template;
|
|
18
|
+
// Warn if content looks like a file path rather than markdown
|
|
19
|
+
if (content && /^\.?\/[\w\-./]+\.\w{1,5}$/.test(content.trim())) {
|
|
20
|
+
// Content is likely a file path, not markdown — return minimal ParsedSkill
|
|
21
|
+
return {
|
|
22
|
+
definition: skill,
|
|
23
|
+
content,
|
|
24
|
+
knownPatterns: [],
|
|
25
|
+
validationChecklist: [],
|
|
26
|
+
toolSequence: [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const identity = this.parseIdentity(content);
|
|
30
|
+
const knownPatterns = this.parseKnownPatterns(content);
|
|
31
|
+
const validationChecklist = this.parseValidationChecklist(content);
|
|
32
|
+
const toolSequence = this.parseToolSequence(content);
|
|
33
|
+
return {
|
|
34
|
+
definition: skill,
|
|
35
|
+
content,
|
|
36
|
+
domain: identity.domain,
|
|
37
|
+
type: identity.type,
|
|
38
|
+
confidence: identity.confidence,
|
|
39
|
+
knownPatterns: knownPatterns.length > 0 ? knownPatterns : undefined,
|
|
40
|
+
validationChecklist: validationChecklist.length > 0 ? validationChecklist : undefined,
|
|
41
|
+
toolSequence: toolSequence.length > 0 ? toolSequence : undefined,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve template variables in a skill template string.
|
|
46
|
+
* Variables use {{variable}} syntax.
|
|
47
|
+
*
|
|
48
|
+
* @param template - Template string with {{variable}} placeholders
|
|
49
|
+
* @param context - Key-value pairs to substitute
|
|
50
|
+
* @returns Resolved template string
|
|
51
|
+
*/
|
|
52
|
+
resolveTemplate(template, context) {
|
|
53
|
+
return template.replace(/\{\{(\w+(?:\.\w+)*)\}\}/g, (_match, key) => {
|
|
54
|
+
// Support dotted paths like "project.name"
|
|
55
|
+
const parts = key.split(".");
|
|
56
|
+
let value = context;
|
|
57
|
+
for (const part of parts) {
|
|
58
|
+
if (value === null || value === undefined)
|
|
59
|
+
return `{{${key}}}`;
|
|
60
|
+
if (typeof value === "object") {
|
|
61
|
+
value = value[part];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return `{{${key}}}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (value === null || value === undefined)
|
|
68
|
+
return `{{${key}}}`;
|
|
69
|
+
return String(value);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Match skill triggers against the current context.
|
|
74
|
+
* Returns skills whose triggers match, sorted by confidence (highest first).
|
|
75
|
+
*/
|
|
76
|
+
matchTriggers(skills, context) {
|
|
77
|
+
const matched = [];
|
|
78
|
+
for (const skill of skills) {
|
|
79
|
+
if (!skill.enabled)
|
|
80
|
+
continue;
|
|
81
|
+
const score = this.scoreTriggerMatch(skill, context);
|
|
82
|
+
if (score > 0) {
|
|
83
|
+
matched.push({ skill, score });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Sort by score descending
|
|
87
|
+
matched.sort((a, b) => b.score - a.score);
|
|
88
|
+
return matched.map((m) => m.skill);
|
|
89
|
+
}
|
|
90
|
+
// ─── Markdown Parsing ───
|
|
91
|
+
/**
|
|
92
|
+
* Parse the ## Identity section from skill markdown.
|
|
93
|
+
*
|
|
94
|
+
* Expected format:
|
|
95
|
+
* ```
|
|
96
|
+
* ## Identity
|
|
97
|
+
* - domain: react
|
|
98
|
+
* - type: bugfix
|
|
99
|
+
* - confidence: 0.85
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
parseIdentity(content) {
|
|
103
|
+
const result = {};
|
|
104
|
+
// Find ## Identity section
|
|
105
|
+
const identityMatch = content.match(/## Identity\s*\n([\s\S]*?)(?=\n## |\n---|$)/);
|
|
106
|
+
if (!identityMatch)
|
|
107
|
+
return result;
|
|
108
|
+
const section = identityMatch[1];
|
|
109
|
+
const domainMatch = section.match(/-\s*domain:\s*(.+)/i);
|
|
110
|
+
if (domainMatch)
|
|
111
|
+
result.domain = domainMatch[1].trim();
|
|
112
|
+
const typeMatch = section.match(/-\s*type:\s*(.+)/i);
|
|
113
|
+
if (typeMatch)
|
|
114
|
+
result.type = typeMatch[1].trim();
|
|
115
|
+
const confidenceMatch = section.match(/-\s*confidence:\s*([\d.]+)/i);
|
|
116
|
+
if (confidenceMatch)
|
|
117
|
+
result.confidence = parseFloat(confidenceMatch[1]);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Parse ### Known Error Patterns subsections.
|
|
122
|
+
*
|
|
123
|
+
* Expected format:
|
|
124
|
+
* ```
|
|
125
|
+
* ### Pattern Name
|
|
126
|
+
* - **증상**: "..."
|
|
127
|
+
* - **원인**: ...
|
|
128
|
+
* - **전략**: 1. ... 2. ...
|
|
129
|
+
* - **도구 시퀀스**: grep → file_read → ...
|
|
130
|
+
* - **함정**: ...
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
parseKnownPatterns(content) {
|
|
134
|
+
const patterns = [];
|
|
135
|
+
// Find sections that start with ### under ## Known Error Patterns
|
|
136
|
+
const knownSection = content.match(/## Known (?:Error )?Patterns\s*\n([\s\S]*?)(?=\n## |\n---|$)/);
|
|
137
|
+
if (!knownSection)
|
|
138
|
+
return patterns;
|
|
139
|
+
const sectionContent = knownSection[1];
|
|
140
|
+
// Split by ### headers
|
|
141
|
+
const subsections = sectionContent.split(/\n### /).filter(Boolean);
|
|
142
|
+
for (const sub of subsections) {
|
|
143
|
+
const lines = sub.trim().split("\n");
|
|
144
|
+
const name = lines[0]?.trim() ?? "";
|
|
145
|
+
if (!name)
|
|
146
|
+
continue;
|
|
147
|
+
const body = lines.slice(1).join("\n");
|
|
148
|
+
const pattern = {
|
|
149
|
+
name,
|
|
150
|
+
symptoms: this.extractListItems(body, /\*\*증상\*\*[:\s]*/i),
|
|
151
|
+
causes: this.extractListItems(body, /\*\*원인\*\*[:\s]*/i),
|
|
152
|
+
strategy: this.extractNumberedItems(body, /\*\*전략\*\*[:\s]*/i),
|
|
153
|
+
tools: this.extractToolSequence(body),
|
|
154
|
+
pitfalls: this.extractListItems(body, /\*\*함정\*\*[:\s]*/i),
|
|
155
|
+
};
|
|
156
|
+
patterns.push(pattern);
|
|
157
|
+
}
|
|
158
|
+
return patterns;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parse ## Validation Checklist section.
|
|
162
|
+
* Extracts - [ ] items.
|
|
163
|
+
*/
|
|
164
|
+
parseValidationChecklist(content) {
|
|
165
|
+
const items = [];
|
|
166
|
+
const checklistMatch = content.match(/## Validation Checklist\s*\n([\s\S]*?)(?=\n## |\n---|$)/);
|
|
167
|
+
if (!checklistMatch)
|
|
168
|
+
return items;
|
|
169
|
+
const section = checklistMatch[1];
|
|
170
|
+
const matches = section.matchAll(/- \[[ x]?\]\s*(.+)/gi);
|
|
171
|
+
for (const match of matches) {
|
|
172
|
+
items.push(match[1].trim());
|
|
173
|
+
}
|
|
174
|
+
return items;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Parse tool sequence from content.
|
|
178
|
+
* Looks for patterns like: "도구 시퀀스: grep → file_read → file_edit"
|
|
179
|
+
*/
|
|
180
|
+
parseToolSequence(content) {
|
|
181
|
+
const match = content.match(/(?:\*\*도구 시퀀스\*\*|tool.?sequence)[:\s]*(.+)/i);
|
|
182
|
+
if (!match)
|
|
183
|
+
return [];
|
|
184
|
+
return match[1]
|
|
185
|
+
.split(/→|->|,/)
|
|
186
|
+
.map((t) => t.trim())
|
|
187
|
+
.filter(Boolean);
|
|
188
|
+
}
|
|
189
|
+
// ─── Trigger Matching ───
|
|
190
|
+
/**
|
|
191
|
+
* Score how well a skill matches the given context.
|
|
192
|
+
* Returns 0 for no match, higher for better match.
|
|
193
|
+
*/
|
|
194
|
+
scoreTriggerMatch(skill, context) {
|
|
195
|
+
const trigger = skill.trigger;
|
|
196
|
+
switch (trigger.kind) {
|
|
197
|
+
case "file_pattern": {
|
|
198
|
+
if (!context.filePath || !trigger.pattern)
|
|
199
|
+
return 0;
|
|
200
|
+
return this.globMatch(trigger.pattern, context.filePath) ? 1 : 0;
|
|
201
|
+
}
|
|
202
|
+
case "command": {
|
|
203
|
+
if (!context.command || !trigger.command)
|
|
204
|
+
return 0;
|
|
205
|
+
const cmd = context.command.replace(/^\//, "");
|
|
206
|
+
return cmd === trigger.command ? 10 : 0; // High score for exact command match
|
|
207
|
+
}
|
|
208
|
+
case "auto": {
|
|
209
|
+
let score = 0;
|
|
210
|
+
if (trigger.pattern) {
|
|
211
|
+
try {
|
|
212
|
+
const regex = new RegExp(trigger.pattern, "i");
|
|
213
|
+
if (context.filePath && regex.test(context.filePath))
|
|
214
|
+
score += 1;
|
|
215
|
+
if (context.errorMessage && regex.test(context.errorMessage))
|
|
216
|
+
score += 2; // Errors are higher signal
|
|
217
|
+
if (context.taskDescription && regex.test(context.taskDescription))
|
|
218
|
+
score += 1;
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Apply confidence threshold
|
|
225
|
+
if (trigger.confidence && score > 0) {
|
|
226
|
+
score *= trigger.confidence;
|
|
227
|
+
}
|
|
228
|
+
// Check tag matches against task description
|
|
229
|
+
if (skill.tags && context.taskDescription) {
|
|
230
|
+
const taskLower = context.taskDescription.toLowerCase();
|
|
231
|
+
for (const tag of skill.tags) {
|
|
232
|
+
if (taskLower.includes(tag.toLowerCase())) {
|
|
233
|
+
score += 0.5;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return score;
|
|
238
|
+
}
|
|
239
|
+
case "manual":
|
|
240
|
+
return 0;
|
|
241
|
+
default:
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// ─── Utility Helpers ───
|
|
246
|
+
/**
|
|
247
|
+
* Extract list items following a marker pattern.
|
|
248
|
+
*/
|
|
249
|
+
extractListItems(content, markerPattern) {
|
|
250
|
+
const match = content.match(new RegExp(markerPattern.source + "(.+)", "i"));
|
|
251
|
+
if (!match)
|
|
252
|
+
return [];
|
|
253
|
+
const text = match[1].trim();
|
|
254
|
+
// Handle quoted content
|
|
255
|
+
const quoted = text.match(/"([^"]+)"/);
|
|
256
|
+
if (quoted)
|
|
257
|
+
return [quoted[1]];
|
|
258
|
+
// Handle comma-separated
|
|
259
|
+
return text
|
|
260
|
+
.split(/,|;/)
|
|
261
|
+
.map((s) => s.trim())
|
|
262
|
+
.filter(Boolean);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Extract numbered items (1. ... 2. ... 3. ...).
|
|
266
|
+
*/
|
|
267
|
+
extractNumberedItems(content, markerPattern) {
|
|
268
|
+
const markerMatch = content.match(new RegExp(markerPattern.source + "[\\s\\S]*?(?=\\n- \\*\\*|$)", "i"));
|
|
269
|
+
if (!markerMatch)
|
|
270
|
+
return [];
|
|
271
|
+
const section = markerMatch[0];
|
|
272
|
+
const items = [];
|
|
273
|
+
const matches = section.matchAll(/\d+\.\s*(.+)/g);
|
|
274
|
+
for (const match of matches) {
|
|
275
|
+
items.push(match[1].trim());
|
|
276
|
+
}
|
|
277
|
+
return items;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Extract tool sequence from a pattern section.
|
|
281
|
+
*/
|
|
282
|
+
extractToolSequence(content) {
|
|
283
|
+
const match = content.match(/(?:\*\*도구 시퀀스\*\*|tool.?sequence)[:\s]*(.+)/i);
|
|
284
|
+
if (!match)
|
|
285
|
+
return [];
|
|
286
|
+
return match[1]
|
|
287
|
+
.split(/→|->|,/)
|
|
288
|
+
.map((t) => t.trim())
|
|
289
|
+
.filter(Boolean);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Simple glob matching for file patterns.
|
|
293
|
+
*/
|
|
294
|
+
globMatch(pattern, filePath) {
|
|
295
|
+
const regexStr = pattern
|
|
296
|
+
.replace(/\./g, "\\.")
|
|
297
|
+
.replace(/\*\*/g, "<<GLOBSTAR>>")
|
|
298
|
+
.replace(/\*/g, "[^/]*")
|
|
299
|
+
.replace(/<<GLOBSTAR>>/g, ".*");
|
|
300
|
+
try {
|
|
301
|
+
const regex = new RegExp(`^${regexStr}$`);
|
|
302
|
+
return regex.test(filePath);
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=skill-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-loader.js","sourceRoot":"","sources":["../src/skill-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,MAAM,OAAO,WAAW;IACtB;;;;OAIG;IACH,YAAY,CAAC,KAAsB,EAAE,eAAwB;QAC3D,MAAM,OAAO,GAAG,eAAe,IAAI,KAAK,CAAC,QAAQ,CAAC;QAElD,8DAA8D;QAC9D,IAAI,OAAO,IAAI,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAChE,2EAA2E;YAC3E,OAAO;gBACL,UAAU,EAAE,KAAK;gBACjB,OAAO;gBACP,aAAa,EAAE,EAAE;gBACjB,mBAAmB,EAAE,EAAE;gBACvB,YAAY,EAAE,EAAE;aACjB,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACnE,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAErD,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,OAAO;YACP,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,aAAa,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YACnE,mB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QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module specialist-registry
|
|
3
|
+
* @description Specialist Agent Registry — Domain-specific agent configurations.
|
|
4
|
+
*
|
|
5
|
+
* Each specialist has pre-loaded expertise, preferred tools, and quality thresholds.
|
|
6
|
+
* Routing: TaskClassifier -> SpecialistRegistry -> specialist config -> SubAgent
|
|
7
|
+
*/
|
|
8
|
+
/** Configuration for a domain specialist agent */
|
|
9
|
+
export interface SpecialistConfig {
|
|
10
|
+
/** Unique specialist ID */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Display name */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Domain description */
|
|
15
|
+
domain: string;
|
|
16
|
+
/** System prompt prefix for this specialist */
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
/** Preferred tools (ordered by priority) */
|
|
19
|
+
preferredTools: string[];
|
|
20
|
+
/** Plugin skills to auto-activate */
|
|
21
|
+
preferredSkills: string[];
|
|
22
|
+
/** Minimum quality threshold for output (0–1) */
|
|
23
|
+
qualityThreshold: number;
|
|
24
|
+
/** Languages this specialist handles */
|
|
25
|
+
languages?: string[];
|
|
26
|
+
/** Frameworks this specialist handles */
|
|
27
|
+
frameworks?: string[];
|
|
28
|
+
/** Can delegate to these other specialists */
|
|
29
|
+
canDelegateTo?: string[];
|
|
30
|
+
}
|
|
31
|
+
/** Result of matching a specialist to a task */
|
|
32
|
+
export interface SpecialistMatch {
|
|
33
|
+
/** The matched specialist configuration */
|
|
34
|
+
specialist: SpecialistConfig;
|
|
35
|
+
/** Confidence of the match (0–1) */
|
|
36
|
+
confidence: number;
|
|
37
|
+
/** Reason for the match */
|
|
38
|
+
reason: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Registry for domain-specific specialist agent configurations.
|
|
42
|
+
*
|
|
43
|
+
* Manages built-in and custom specialists that can be matched to tasks
|
|
44
|
+
* based on type, language, framework, and error context.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const registry = new SpecialistRegistry();
|
|
49
|
+
*
|
|
50
|
+
* // Find best specialist for a TypeScript security task
|
|
51
|
+
* const match = registry.findSpecialist("security", {
|
|
52
|
+
* language: "typescript",
|
|
53
|
+
* });
|
|
54
|
+
* if (match) {
|
|
55
|
+
* console.log(match.specialist.name); // "Security Specialist"
|
|
56
|
+
* console.log(match.confidence); // 0.9
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* // Register a custom specialist
|
|
60
|
+
* registry.register({
|
|
61
|
+
* id: "rust-specialist",
|
|
62
|
+
* name: "Rust Specialist",
|
|
63
|
+
* domain: "Rust systems programming",
|
|
64
|
+
* systemPrompt: "You are a Rust expert...",
|
|
65
|
+
* preferredTools: ["file_read", "file_edit", "shell_exec"],
|
|
66
|
+
* preferredSkills: ["cargo-check", "clippy-lint"],
|
|
67
|
+
* qualityThreshold: 0.85,
|
|
68
|
+
* languages: ["rust"],
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class SpecialistRegistry {
|
|
73
|
+
private specialists;
|
|
74
|
+
constructor();
|
|
75
|
+
/**
|
|
76
|
+
* Register a specialist configuration.
|
|
77
|
+
* If a specialist with the same ID exists, it is replaced.
|
|
78
|
+
*
|
|
79
|
+
* @param config - Specialist configuration to register
|
|
80
|
+
*/
|
|
81
|
+
register(config: SpecialistConfig): void;
|
|
82
|
+
/**
|
|
83
|
+
* Find the best specialist for a given task type and context.
|
|
84
|
+
*
|
|
85
|
+
* Matching priority:
|
|
86
|
+
* 1. Exact task type match
|
|
87
|
+
* 2. Language/framework affinity bonus
|
|
88
|
+
* 3. Error message pattern match
|
|
89
|
+
*
|
|
90
|
+
* @param taskType - Task type string (from TaskClassifier)
|
|
91
|
+
* @param context - Optional context for better matching
|
|
92
|
+
* @returns Best matching specialist or null if none found
|
|
93
|
+
*/
|
|
94
|
+
findSpecialist(taskType: string, context?: {
|
|
95
|
+
language?: string;
|
|
96
|
+
framework?: string;
|
|
97
|
+
errorMessage?: string;
|
|
98
|
+
}): SpecialistMatch | null;
|
|
99
|
+
/**
|
|
100
|
+
* Get a specialist by its unique ID.
|
|
101
|
+
*
|
|
102
|
+
* @param id - Specialist ID
|
|
103
|
+
* @returns Specialist config or undefined if not found
|
|
104
|
+
*/
|
|
105
|
+
get(id: string): SpecialistConfig | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* List all registered specialists.
|
|
108
|
+
*
|
|
109
|
+
* @returns Array of all specialist configurations
|
|
110
|
+
*/
|
|
111
|
+
list(): SpecialistConfig[];
|
|
112
|
+
/**
|
|
113
|
+
* Remove a specialist by ID.
|
|
114
|
+
*
|
|
115
|
+
* @param id - Specialist ID to remove
|
|
116
|
+
* @returns true if removed, false if not found
|
|
117
|
+
*/
|
|
118
|
+
remove(id: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Get the total number of registered specialists.
|
|
121
|
+
*/
|
|
122
|
+
get size(): number;
|
|
123
|
+
/**
|
|
124
|
+
* Check if a specialist's domain matches the given task type.
|
|
125
|
+
*/
|
|
126
|
+
private matchesDomain;
|
|
127
|
+
/**
|
|
128
|
+
* Register all built-in specialist configurations.
|
|
129
|
+
*/
|
|
130
|
+
private registerBuiltins;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=specialist-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specialist-registry.d.ts","sourceRoot":"","sources":["../src/specialist-registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,+CAA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