@skill-tools/core 0.1.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/LICENSE +190 -0
- package/dist/index.cjs +379 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +278 -0
- package/dist/index.d.ts +278 -0
- package/dist/index.js +370 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity levels for diagnostic messages.
|
|
3
|
+
* Follows the same hierarchy as LSP diagnostics.
|
|
4
|
+
*/
|
|
5
|
+
type DiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
6
|
+
/**
|
|
7
|
+
* A diagnostic message produced by validation or linting.
|
|
8
|
+
* Contains the location, severity, and suggested fix for an issue.
|
|
9
|
+
*/
|
|
10
|
+
interface Diagnostic {
|
|
11
|
+
/** Unique rule identifier, e.g. "frontmatter-required" or "description-specificity" */
|
|
12
|
+
readonly ruleId: string;
|
|
13
|
+
/** Severity of the diagnostic */
|
|
14
|
+
readonly severity: DiagnosticSeverity;
|
|
15
|
+
/** Human-readable message describing the issue */
|
|
16
|
+
readonly message: string;
|
|
17
|
+
/** Optional file path where the issue was found */
|
|
18
|
+
readonly file?: string;
|
|
19
|
+
/** Optional 1-based line number in the file */
|
|
20
|
+
readonly line?: number;
|
|
21
|
+
/** Optional 1-based column number in the file */
|
|
22
|
+
readonly column?: number;
|
|
23
|
+
/** Optional suggestion for how to fix the issue */
|
|
24
|
+
readonly fix?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* YAML frontmatter metadata for a SKILL.md file.
|
|
28
|
+
*
|
|
29
|
+
* Based on the Agent Skills specification:
|
|
30
|
+
* - Claude Code: https://code.claude.com/docs/en/skills
|
|
31
|
+
* - Codex: https://developers.openai.com/codex/skills/
|
|
32
|
+
*
|
|
33
|
+
* Both `name` and `description` are strongly recommended.
|
|
34
|
+
* All other fields are optional platform-specific extensions.
|
|
35
|
+
*/
|
|
36
|
+
interface SkillMetadata {
|
|
37
|
+
/**
|
|
38
|
+
* Skill name identifier. Becomes the /slash-command.
|
|
39
|
+
* Lowercase letters, numbers, and hyphens only (max 64 characters).
|
|
40
|
+
* If omitted, the directory name is used as fallback.
|
|
41
|
+
*/
|
|
42
|
+
readonly name?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Description used for agent discovery and routing.
|
|
45
|
+
* Should explain what the skill does AND when to use it.
|
|
46
|
+
* If omitted, the first paragraph of markdown content may be used.
|
|
47
|
+
*/
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
/** Semantic version of the skill */
|
|
50
|
+
readonly version?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Hint shown during autocomplete for expected arguments.
|
|
53
|
+
* Example: "[issue-number]" or "[filename] [format]"
|
|
54
|
+
*/
|
|
55
|
+
readonly 'argument-hint'?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Set to true to prevent the agent from automatically loading this skill.
|
|
58
|
+
* Use for workflows you want to trigger manually with /name.
|
|
59
|
+
*/
|
|
60
|
+
readonly 'disable-model-invocation'?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Set to false to hide from the / menu.
|
|
63
|
+
* Use for background knowledge users shouldn't invoke directly.
|
|
64
|
+
*/
|
|
65
|
+
readonly 'user-invocable'?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tools the agent can use without permission when this skill is active.
|
|
68
|
+
* Comma-separated tool names, e.g. "Read, Grep, Glob"
|
|
69
|
+
*/
|
|
70
|
+
readonly 'allowed-tools'?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Model to use when this skill is active.
|
|
73
|
+
*/
|
|
74
|
+
readonly model?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Set to "fork" to run in a forked subagent context.
|
|
77
|
+
*/
|
|
78
|
+
readonly context?: 'fork' | string;
|
|
79
|
+
/**
|
|
80
|
+
* Which subagent type to use when context: fork is set.
|
|
81
|
+
* Options: "Explore", "Plan", "general-purpose", or a custom agent name.
|
|
82
|
+
*/
|
|
83
|
+
readonly agent?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Hooks scoped to this skill's lifecycle.
|
|
86
|
+
*/
|
|
87
|
+
readonly hooks?: Record<string, unknown>;
|
|
88
|
+
/** Arbitrary additional metadata key-value pairs */
|
|
89
|
+
readonly [key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A parsed section of a SKILL.md file's markdown body.
|
|
93
|
+
* Represents a heading and its content.
|
|
94
|
+
*/
|
|
95
|
+
interface SkillSection {
|
|
96
|
+
/** Heading text (without the # prefix) */
|
|
97
|
+
readonly heading: string;
|
|
98
|
+
/** Heading depth (1-6) */
|
|
99
|
+
readonly depth: number;
|
|
100
|
+
/** Raw markdown content under this heading */
|
|
101
|
+
readonly content: string;
|
|
102
|
+
/** 1-based line number where this section starts */
|
|
103
|
+
readonly line: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A file referenced from within the skill directory.
|
|
107
|
+
* Used for tracking file reference integrity.
|
|
108
|
+
*/
|
|
109
|
+
interface SkillFileReference {
|
|
110
|
+
/** The path as written in the SKILL.md (relative) */
|
|
111
|
+
readonly path: string;
|
|
112
|
+
/** 1-based line number where this reference appears */
|
|
113
|
+
readonly line: number;
|
|
114
|
+
/** Whether the referenced file actually exists on disk */
|
|
115
|
+
readonly exists: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Complete parsed representation of a SKILL.md file.
|
|
119
|
+
* This is the primary data structure that all tools operate on.
|
|
120
|
+
*/
|
|
121
|
+
interface Skill {
|
|
122
|
+
/** Parsed YAML frontmatter metadata */
|
|
123
|
+
readonly metadata: SkillMetadata;
|
|
124
|
+
/** Raw markdown body (everything after frontmatter) */
|
|
125
|
+
readonly body: string;
|
|
126
|
+
/** Parsed sections from the markdown body */
|
|
127
|
+
readonly sections: readonly SkillSection[];
|
|
128
|
+
/** File references found in the markdown body */
|
|
129
|
+
readonly fileReferences: readonly SkillFileReference[];
|
|
130
|
+
/** Absolute path to the SKILL.md file */
|
|
131
|
+
readonly filePath: string;
|
|
132
|
+
/** Absolute path to the skill directory (parent of SKILL.md) */
|
|
133
|
+
readonly dirPath: string;
|
|
134
|
+
/** Token count of the full SKILL.md content */
|
|
135
|
+
readonly tokenCount: number;
|
|
136
|
+
/** Line count of the SKILL.md body (excluding frontmatter) */
|
|
137
|
+
readonly lineCount: number;
|
|
138
|
+
/** Raw content of the entire SKILL.md file */
|
|
139
|
+
readonly rawContent: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Result of parsing a SKILL.md file.
|
|
143
|
+
* Either succeeds with a Skill object or fails with diagnostics.
|
|
144
|
+
*/
|
|
145
|
+
type ParseResult = {
|
|
146
|
+
readonly ok: true;
|
|
147
|
+
readonly skill: Skill;
|
|
148
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
149
|
+
} | {
|
|
150
|
+
readonly ok: false;
|
|
151
|
+
readonly skill: null;
|
|
152
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Quality score for a single dimension.
|
|
156
|
+
*/
|
|
157
|
+
interface DimensionScore {
|
|
158
|
+
/** Points earned in this dimension */
|
|
159
|
+
readonly score: number;
|
|
160
|
+
/** Maximum points possible for this dimension */
|
|
161
|
+
readonly max: number;
|
|
162
|
+
/** Human-readable label for this dimension */
|
|
163
|
+
readonly label: string;
|
|
164
|
+
/** Details about what contributed to the score */
|
|
165
|
+
readonly details?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Complete quality score breakdown.
|
|
169
|
+
*/
|
|
170
|
+
interface QualityScore {
|
|
171
|
+
/** Overall score (0-100) */
|
|
172
|
+
readonly score: number;
|
|
173
|
+
/** Per-dimension breakdowns */
|
|
174
|
+
readonly dimensions: Record<string, DimensionScore>;
|
|
175
|
+
/** Actionable suggestions for improvement */
|
|
176
|
+
readonly suggestions: readonly ScoreSuggestion[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A suggestion for improving a quality score.
|
|
180
|
+
*/
|
|
181
|
+
interface ScoreSuggestion {
|
|
182
|
+
/** Human-readable suggestion */
|
|
183
|
+
readonly message: string;
|
|
184
|
+
/** Estimated point improvement if implemented */
|
|
185
|
+
readonly pointsGain: number;
|
|
186
|
+
/** Which dimension this suggestion applies to */
|
|
187
|
+
readonly dimension: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Parse a SKILL.md file from a file path.
|
|
192
|
+
*
|
|
193
|
+
* Reads the file, parses frontmatter and markdown body, extracts sections,
|
|
194
|
+
* resolves file references, and counts tokens. Returns either a successful
|
|
195
|
+
* parse result with the Skill object, or a failed result with diagnostics
|
|
196
|
+
* explaining what went wrong.
|
|
197
|
+
*
|
|
198
|
+
* @param filePath - Absolute or relative path to a SKILL.md file
|
|
199
|
+
* @returns ParseResult with either a Skill object or error diagnostics
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const result = await parseSkill('./my-skill/SKILL.md');
|
|
204
|
+
* if (result.ok) {
|
|
205
|
+
* console.log(result.skill.metadata.name);
|
|
206
|
+
* } else {
|
|
207
|
+
* console.error(result.diagnostics);
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
declare function parseSkill(filePath: string): Promise<ParseResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Parse SKILL.md content from a raw string.
|
|
214
|
+
* Useful when you already have the content in memory.
|
|
215
|
+
*
|
|
216
|
+
* @param rawContent - The raw SKILL.md file content
|
|
217
|
+
* @param filePath - The file path (used for diagnostics and file reference resolution)
|
|
218
|
+
* @param dirPath - The skill directory path (used for file reference resolution)
|
|
219
|
+
* @returns ParseResult with either a Skill object or error diagnostics
|
|
220
|
+
*/
|
|
221
|
+
declare function parseSkillContent(rawContent: string, filePath: string, dirPath: string): ParseResult;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Information about a discovered skill in the filesystem.
|
|
225
|
+
*/
|
|
226
|
+
interface SkillLocation {
|
|
227
|
+
/** Absolute path to the SKILL.md file */
|
|
228
|
+
readonly skillFile: string;
|
|
229
|
+
/** Absolute path to the skill directory */
|
|
230
|
+
readonly directory: string;
|
|
231
|
+
/** The directory name (used as a fallback identifier) */
|
|
232
|
+
readonly dirName: string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Resolve all SKILL.md files in a directory tree.
|
|
236
|
+
*
|
|
237
|
+
* Searches for SKILL.md files in the given path. If the path itself
|
|
238
|
+
* contains a SKILL.md, returns just that one. If the path is a directory,
|
|
239
|
+
* searches one level deep for subdirectories containing SKILL.md files.
|
|
240
|
+
*
|
|
241
|
+
* @param searchPath - Absolute or relative path to search
|
|
242
|
+
* @returns Array of discovered skill locations
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* // Single skill directory
|
|
247
|
+
* const skills = await resolveSkillFiles('./my-skill/');
|
|
248
|
+
* // => [{ skillFile: '/abs/path/my-skill/SKILL.md', ... }]
|
|
249
|
+
*
|
|
250
|
+
* // Directory of skills
|
|
251
|
+
* const skills = await resolveSkillFiles('./skills/');
|
|
252
|
+
* // => [
|
|
253
|
+
* // { skillFile: '/abs/path/skills/deploy/SKILL.md', ... },
|
|
254
|
+
* // { skillFile: '/abs/path/skills/test-runner/SKILL.md', ... },
|
|
255
|
+
* // ]
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function resolveSkillFiles(searchPath: string): Promise<SkillLocation[]>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Count the number of tokens in a string.
|
|
262
|
+
*
|
|
263
|
+
* Uses the cl100k_base tokenizer (GPT-4o compatible), which provides
|
|
264
|
+
* a reasonable approximation for both OpenAI and Anthropic models.
|
|
265
|
+
* Actual token counts may vary slightly between providers.
|
|
266
|
+
*
|
|
267
|
+
* @param text - The text to count tokens for
|
|
268
|
+
* @returns The number of tokens
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const count = countTokens('Hello, world!');
|
|
273
|
+
* // => 4
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
declare function countTokens(text: string): number;
|
|
277
|
+
|
|
278
|
+
export { type Diagnostic, type DiagnosticSeverity, type DimensionScore, type ParseResult, type QualityScore, type ScoreSuggestion, type Skill, type SkillFileReference, type SkillLocation, type SkillMetadata, type SkillSection, countTokens, parseSkill, parseSkillContent, resolveSkillFiles };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity levels for diagnostic messages.
|
|
3
|
+
* Follows the same hierarchy as LSP diagnostics.
|
|
4
|
+
*/
|
|
5
|
+
type DiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
6
|
+
/**
|
|
7
|
+
* A diagnostic message produced by validation or linting.
|
|
8
|
+
* Contains the location, severity, and suggested fix for an issue.
|
|
9
|
+
*/
|
|
10
|
+
interface Diagnostic {
|
|
11
|
+
/** Unique rule identifier, e.g. "frontmatter-required" or "description-specificity" */
|
|
12
|
+
readonly ruleId: string;
|
|
13
|
+
/** Severity of the diagnostic */
|
|
14
|
+
readonly severity: DiagnosticSeverity;
|
|
15
|
+
/** Human-readable message describing the issue */
|
|
16
|
+
readonly message: string;
|
|
17
|
+
/** Optional file path where the issue was found */
|
|
18
|
+
readonly file?: string;
|
|
19
|
+
/** Optional 1-based line number in the file */
|
|
20
|
+
readonly line?: number;
|
|
21
|
+
/** Optional 1-based column number in the file */
|
|
22
|
+
readonly column?: number;
|
|
23
|
+
/** Optional suggestion for how to fix the issue */
|
|
24
|
+
readonly fix?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* YAML frontmatter metadata for a SKILL.md file.
|
|
28
|
+
*
|
|
29
|
+
* Based on the Agent Skills specification:
|
|
30
|
+
* - Claude Code: https://code.claude.com/docs/en/skills
|
|
31
|
+
* - Codex: https://developers.openai.com/codex/skills/
|
|
32
|
+
*
|
|
33
|
+
* Both `name` and `description` are strongly recommended.
|
|
34
|
+
* All other fields are optional platform-specific extensions.
|
|
35
|
+
*/
|
|
36
|
+
interface SkillMetadata {
|
|
37
|
+
/**
|
|
38
|
+
* Skill name identifier. Becomes the /slash-command.
|
|
39
|
+
* Lowercase letters, numbers, and hyphens only (max 64 characters).
|
|
40
|
+
* If omitted, the directory name is used as fallback.
|
|
41
|
+
*/
|
|
42
|
+
readonly name?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Description used for agent discovery and routing.
|
|
45
|
+
* Should explain what the skill does AND when to use it.
|
|
46
|
+
* If omitted, the first paragraph of markdown content may be used.
|
|
47
|
+
*/
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
/** Semantic version of the skill */
|
|
50
|
+
readonly version?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Hint shown during autocomplete for expected arguments.
|
|
53
|
+
* Example: "[issue-number]" or "[filename] [format]"
|
|
54
|
+
*/
|
|
55
|
+
readonly 'argument-hint'?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Set to true to prevent the agent from automatically loading this skill.
|
|
58
|
+
* Use for workflows you want to trigger manually with /name.
|
|
59
|
+
*/
|
|
60
|
+
readonly 'disable-model-invocation'?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Set to false to hide from the / menu.
|
|
63
|
+
* Use for background knowledge users shouldn't invoke directly.
|
|
64
|
+
*/
|
|
65
|
+
readonly 'user-invocable'?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tools the agent can use without permission when this skill is active.
|
|
68
|
+
* Comma-separated tool names, e.g. "Read, Grep, Glob"
|
|
69
|
+
*/
|
|
70
|
+
readonly 'allowed-tools'?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Model to use when this skill is active.
|
|
73
|
+
*/
|
|
74
|
+
readonly model?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Set to "fork" to run in a forked subagent context.
|
|
77
|
+
*/
|
|
78
|
+
readonly context?: 'fork' | string;
|
|
79
|
+
/**
|
|
80
|
+
* Which subagent type to use when context: fork is set.
|
|
81
|
+
* Options: "Explore", "Plan", "general-purpose", or a custom agent name.
|
|
82
|
+
*/
|
|
83
|
+
readonly agent?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Hooks scoped to this skill's lifecycle.
|
|
86
|
+
*/
|
|
87
|
+
readonly hooks?: Record<string, unknown>;
|
|
88
|
+
/** Arbitrary additional metadata key-value pairs */
|
|
89
|
+
readonly [key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A parsed section of a SKILL.md file's markdown body.
|
|
93
|
+
* Represents a heading and its content.
|
|
94
|
+
*/
|
|
95
|
+
interface SkillSection {
|
|
96
|
+
/** Heading text (without the # prefix) */
|
|
97
|
+
readonly heading: string;
|
|
98
|
+
/** Heading depth (1-6) */
|
|
99
|
+
readonly depth: number;
|
|
100
|
+
/** Raw markdown content under this heading */
|
|
101
|
+
readonly content: string;
|
|
102
|
+
/** 1-based line number where this section starts */
|
|
103
|
+
readonly line: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A file referenced from within the skill directory.
|
|
107
|
+
* Used for tracking file reference integrity.
|
|
108
|
+
*/
|
|
109
|
+
interface SkillFileReference {
|
|
110
|
+
/** The path as written in the SKILL.md (relative) */
|
|
111
|
+
readonly path: string;
|
|
112
|
+
/** 1-based line number where this reference appears */
|
|
113
|
+
readonly line: number;
|
|
114
|
+
/** Whether the referenced file actually exists on disk */
|
|
115
|
+
readonly exists: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Complete parsed representation of a SKILL.md file.
|
|
119
|
+
* This is the primary data structure that all tools operate on.
|
|
120
|
+
*/
|
|
121
|
+
interface Skill {
|
|
122
|
+
/** Parsed YAML frontmatter metadata */
|
|
123
|
+
readonly metadata: SkillMetadata;
|
|
124
|
+
/** Raw markdown body (everything after frontmatter) */
|
|
125
|
+
readonly body: string;
|
|
126
|
+
/** Parsed sections from the markdown body */
|
|
127
|
+
readonly sections: readonly SkillSection[];
|
|
128
|
+
/** File references found in the markdown body */
|
|
129
|
+
readonly fileReferences: readonly SkillFileReference[];
|
|
130
|
+
/** Absolute path to the SKILL.md file */
|
|
131
|
+
readonly filePath: string;
|
|
132
|
+
/** Absolute path to the skill directory (parent of SKILL.md) */
|
|
133
|
+
readonly dirPath: string;
|
|
134
|
+
/** Token count of the full SKILL.md content */
|
|
135
|
+
readonly tokenCount: number;
|
|
136
|
+
/** Line count of the SKILL.md body (excluding frontmatter) */
|
|
137
|
+
readonly lineCount: number;
|
|
138
|
+
/** Raw content of the entire SKILL.md file */
|
|
139
|
+
readonly rawContent: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Result of parsing a SKILL.md file.
|
|
143
|
+
* Either succeeds with a Skill object or fails with diagnostics.
|
|
144
|
+
*/
|
|
145
|
+
type ParseResult = {
|
|
146
|
+
readonly ok: true;
|
|
147
|
+
readonly skill: Skill;
|
|
148
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
149
|
+
} | {
|
|
150
|
+
readonly ok: false;
|
|
151
|
+
readonly skill: null;
|
|
152
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Quality score for a single dimension.
|
|
156
|
+
*/
|
|
157
|
+
interface DimensionScore {
|
|
158
|
+
/** Points earned in this dimension */
|
|
159
|
+
readonly score: number;
|
|
160
|
+
/** Maximum points possible for this dimension */
|
|
161
|
+
readonly max: number;
|
|
162
|
+
/** Human-readable label for this dimension */
|
|
163
|
+
readonly label: string;
|
|
164
|
+
/** Details about what contributed to the score */
|
|
165
|
+
readonly details?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Complete quality score breakdown.
|
|
169
|
+
*/
|
|
170
|
+
interface QualityScore {
|
|
171
|
+
/** Overall score (0-100) */
|
|
172
|
+
readonly score: number;
|
|
173
|
+
/** Per-dimension breakdowns */
|
|
174
|
+
readonly dimensions: Record<string, DimensionScore>;
|
|
175
|
+
/** Actionable suggestions for improvement */
|
|
176
|
+
readonly suggestions: readonly ScoreSuggestion[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A suggestion for improving a quality score.
|
|
180
|
+
*/
|
|
181
|
+
interface ScoreSuggestion {
|
|
182
|
+
/** Human-readable suggestion */
|
|
183
|
+
readonly message: string;
|
|
184
|
+
/** Estimated point improvement if implemented */
|
|
185
|
+
readonly pointsGain: number;
|
|
186
|
+
/** Which dimension this suggestion applies to */
|
|
187
|
+
readonly dimension: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Parse a SKILL.md file from a file path.
|
|
192
|
+
*
|
|
193
|
+
* Reads the file, parses frontmatter and markdown body, extracts sections,
|
|
194
|
+
* resolves file references, and counts tokens. Returns either a successful
|
|
195
|
+
* parse result with the Skill object, or a failed result with diagnostics
|
|
196
|
+
* explaining what went wrong.
|
|
197
|
+
*
|
|
198
|
+
* @param filePath - Absolute or relative path to a SKILL.md file
|
|
199
|
+
* @returns ParseResult with either a Skill object or error diagnostics
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const result = await parseSkill('./my-skill/SKILL.md');
|
|
204
|
+
* if (result.ok) {
|
|
205
|
+
* console.log(result.skill.metadata.name);
|
|
206
|
+
* } else {
|
|
207
|
+
* console.error(result.diagnostics);
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
declare function parseSkill(filePath: string): Promise<ParseResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Parse SKILL.md content from a raw string.
|
|
214
|
+
* Useful when you already have the content in memory.
|
|
215
|
+
*
|
|
216
|
+
* @param rawContent - The raw SKILL.md file content
|
|
217
|
+
* @param filePath - The file path (used for diagnostics and file reference resolution)
|
|
218
|
+
* @param dirPath - The skill directory path (used for file reference resolution)
|
|
219
|
+
* @returns ParseResult with either a Skill object or error diagnostics
|
|
220
|
+
*/
|
|
221
|
+
declare function parseSkillContent(rawContent: string, filePath: string, dirPath: string): ParseResult;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Information about a discovered skill in the filesystem.
|
|
225
|
+
*/
|
|
226
|
+
interface SkillLocation {
|
|
227
|
+
/** Absolute path to the SKILL.md file */
|
|
228
|
+
readonly skillFile: string;
|
|
229
|
+
/** Absolute path to the skill directory */
|
|
230
|
+
readonly directory: string;
|
|
231
|
+
/** The directory name (used as a fallback identifier) */
|
|
232
|
+
readonly dirName: string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Resolve all SKILL.md files in a directory tree.
|
|
236
|
+
*
|
|
237
|
+
* Searches for SKILL.md files in the given path. If the path itself
|
|
238
|
+
* contains a SKILL.md, returns just that one. If the path is a directory,
|
|
239
|
+
* searches one level deep for subdirectories containing SKILL.md files.
|
|
240
|
+
*
|
|
241
|
+
* @param searchPath - Absolute or relative path to search
|
|
242
|
+
* @returns Array of discovered skill locations
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* // Single skill directory
|
|
247
|
+
* const skills = await resolveSkillFiles('./my-skill/');
|
|
248
|
+
* // => [{ skillFile: '/abs/path/my-skill/SKILL.md', ... }]
|
|
249
|
+
*
|
|
250
|
+
* // Directory of skills
|
|
251
|
+
* const skills = await resolveSkillFiles('./skills/');
|
|
252
|
+
* // => [
|
|
253
|
+
* // { skillFile: '/abs/path/skills/deploy/SKILL.md', ... },
|
|
254
|
+
* // { skillFile: '/abs/path/skills/test-runner/SKILL.md', ... },
|
|
255
|
+
* // ]
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function resolveSkillFiles(searchPath: string): Promise<SkillLocation[]>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Count the number of tokens in a string.
|
|
262
|
+
*
|
|
263
|
+
* Uses the cl100k_base tokenizer (GPT-4o compatible), which provides
|
|
264
|
+
* a reasonable approximation for both OpenAI and Anthropic models.
|
|
265
|
+
* Actual token counts may vary slightly between providers.
|
|
266
|
+
*
|
|
267
|
+
* @param text - The text to count tokens for
|
|
268
|
+
* @returns The number of tokens
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const count = countTokens('Hello, world!');
|
|
273
|
+
* // => 4
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
declare function countTokens(text: string): number;
|
|
277
|
+
|
|
278
|
+
export { type Diagnostic, type DiagnosticSeverity, type DimensionScore, type ParseResult, type QualityScore, type ScoreSuggestion, type Skill, type SkillFileReference, type SkillLocation, type SkillMetadata, type SkillSection, countTokens, parseSkill, parseSkillContent, resolveSkillFiles };
|