agent-skills-cli 1.1.3 → 1.1.4
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/README.md +29 -10
- package/dist/cli/commands/bench.d.ts +7 -0
- package/dist/cli/commands/bench.d.ts.map +1 -0
- package/dist/cli/commands/bench.js +158 -0
- package/dist/cli/commands/bench.js.map +1 -0
- package/dist/cli/commands/compose.d.ts +7 -0
- package/dist/cli/commands/compose.d.ts.map +1 -0
- package/dist/cli/commands/compose.js +71 -0
- package/dist/cli/commands/compose.js.map +1 -0
- package/dist/cli/commands/context.d.ts +7 -0
- package/dist/cli/commands/context.d.ts.map +1 -0
- package/dist/cli/commands/context.js +119 -0
- package/dist/cli/commands/context.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +7 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +101 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/frozen.d.ts +7 -0
- package/dist/cli/commands/frozen.d.ts.map +1 -0
- package/dist/cli/commands/frozen.js +133 -0
- package/dist/cli/commands/frozen.js.map +1 -0
- package/dist/cli/commands/sandbox.d.ts +7 -0
- package/dist/cli/commands/sandbox.d.ts.map +1 -0
- package/dist/cli/commands/sandbox.js +174 -0
- package/dist/cli/commands/sandbox.js.map +1 -0
- package/dist/cli/commands/split.d.ts +7 -0
- package/dist/cli/commands/split.d.ts.map +1 -0
- package/dist/cli/commands/split.js +80 -0
- package/dist/cli/commands/split.js.map +1 -0
- package/dist/cli/commands/test.d.ts +7 -0
- package/dist/cli/commands/test.d.ts.map +1 -0
- package/dist/cli/commands/test.js +121 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/commands/utils-commands.d.ts.map +1 -1
- package/dist/cli/commands/utils-commands.js +72 -4
- package/dist/cli/commands/utils-commands.js.map +1 -1
- package/dist/cli/commands/watch.d.ts +7 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +85 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/index.js +20 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/composer.d.ts +41 -0
- package/dist/core/composer.d.ts.map +1 -0
- package/dist/core/composer.js +230 -0
- package/dist/core/composer.js.map +1 -0
- package/dist/core/conflict-detector.d.ts +55 -0
- package/dist/core/conflict-detector.d.ts.map +1 -0
- package/dist/core/conflict-detector.js +339 -0
- package/dist/core/conflict-detector.js.map +1 -0
- package/dist/core/context-budget.d.ts +63 -0
- package/dist/core/context-budget.d.ts.map +1 -0
- package/dist/core/context-budget.js +310 -0
- package/dist/core/context-budget.js.map +1 -0
- package/dist/core/differ.d.ts +42 -0
- package/dist/core/differ.d.ts.map +1 -0
- package/dist/core/differ.js +117 -0
- package/dist/core/differ.js.map +1 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/skill-tester.d.ts +54 -0
- package/dist/core/skill-tester.d.ts.map +1 -0
- package/dist/core/skill-tester.js +201 -0
- package/dist/core/skill-tester.js.map +1 -0
- package/dist/core/splitter.d.ts +36 -0
- package/dist/core/splitter.d.ts.map +1 -0
- package/dist/core/splitter.js +186 -0
- package/dist/core/splitter.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Composer Module
|
|
3
|
+
* Merges multiple skills into a single coherent super-skill.
|
|
4
|
+
*
|
|
5
|
+
* Strategies:
|
|
6
|
+
* merge — combine sections, deduplicate bullets
|
|
7
|
+
* chain — sequential application ("first do A, then B")
|
|
8
|
+
* conditional — context-dependent ("for React use A, for Vue use B")
|
|
9
|
+
*/
|
|
10
|
+
import { readFile } from 'fs/promises';
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
import { join, basename } from 'path';
|
|
13
|
+
import matter from 'gray-matter';
|
|
14
|
+
// ── Main Entry ───────────────────────────────────────────────────────────
|
|
15
|
+
/**
|
|
16
|
+
* Compose multiple skills into one.
|
|
17
|
+
*/
|
|
18
|
+
export async function composeSkills(options) {
|
|
19
|
+
const { skills: paths, output, strategy, dedup } = options;
|
|
20
|
+
// Load all skills
|
|
21
|
+
const skills = [];
|
|
22
|
+
for (const p of paths) {
|
|
23
|
+
const skill = await loadAndParse(p);
|
|
24
|
+
if (skill)
|
|
25
|
+
skills.push(skill);
|
|
26
|
+
}
|
|
27
|
+
if (skills.length === 0) {
|
|
28
|
+
throw new Error('No valid skills found to compose');
|
|
29
|
+
}
|
|
30
|
+
if (skills.length === 1) {
|
|
31
|
+
// Just return the single skill with new name
|
|
32
|
+
const s = skills[0];
|
|
33
|
+
const fullContent = buildFrontmatter(output, s.description, [s.name]) + '\n' + s.body;
|
|
34
|
+
return {
|
|
35
|
+
name: output,
|
|
36
|
+
description: s.description,
|
|
37
|
+
body: s.body,
|
|
38
|
+
sourceSkills: [s.name],
|
|
39
|
+
tokenCount: Math.ceil(fullContent.length / 4),
|
|
40
|
+
deduplicatedCount: 0,
|
|
41
|
+
fullContent,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let body;
|
|
45
|
+
let dedupCount = 0;
|
|
46
|
+
switch (strategy) {
|
|
47
|
+
case 'chain':
|
|
48
|
+
body = composeChain(skills);
|
|
49
|
+
break;
|
|
50
|
+
case 'conditional':
|
|
51
|
+
body = composeConditional(skills);
|
|
52
|
+
break;
|
|
53
|
+
case 'merge':
|
|
54
|
+
default:
|
|
55
|
+
const result = composeMerge(skills, dedup);
|
|
56
|
+
body = result.body;
|
|
57
|
+
dedupCount = result.deduplicatedCount;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
const descriptions = skills.map(s => s.description).filter(Boolean);
|
|
61
|
+
const description = `Composed skill combining: ${skills.map(s => s.name).join(', ')}. ${descriptions[0] || ''}`;
|
|
62
|
+
const sourceSkills = skills.map(s => s.name);
|
|
63
|
+
const fullContent = buildFrontmatter(output, description, sourceSkills) + '\n' + body;
|
|
64
|
+
return {
|
|
65
|
+
name: output,
|
|
66
|
+
description,
|
|
67
|
+
body,
|
|
68
|
+
sourceSkills,
|
|
69
|
+
tokenCount: Math.ceil(fullContent.length / 4),
|
|
70
|
+
deduplicatedCount: dedupCount,
|
|
71
|
+
fullContent,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// ── Strategy: Merge ──────────────────────────────────────────────────────
|
|
75
|
+
function composeMerge(skills, dedup) {
|
|
76
|
+
// Group all sections by similar headings
|
|
77
|
+
const groups = new Map();
|
|
78
|
+
let dedupCount = 0;
|
|
79
|
+
for (const skill of skills) {
|
|
80
|
+
for (const section of skill.sections) {
|
|
81
|
+
const key = normalizeHeading(section.heading);
|
|
82
|
+
if (!groups.has(key))
|
|
83
|
+
groups.set(key, []);
|
|
84
|
+
groups.get(key).push({ skill: skill.name, content: section.content });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const lines = [];
|
|
88
|
+
for (const [heading, entries] of groups) {
|
|
89
|
+
// Use the most descriptive heading
|
|
90
|
+
const displayHeading = heading === '(intro)'
|
|
91
|
+
? ''
|
|
92
|
+
: `## ${heading.charAt(0).toUpperCase() + heading.slice(1)}`;
|
|
93
|
+
if (displayHeading)
|
|
94
|
+
lines.push(displayHeading);
|
|
95
|
+
if (dedup && entries.length > 1) {
|
|
96
|
+
// Merge and deduplicate bullets
|
|
97
|
+
const allBullets = new Set();
|
|
98
|
+
const merged = [];
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
const entryLines = entry.content.split('\n');
|
|
101
|
+
for (const line of entryLines) {
|
|
102
|
+
const normalized = line.trim().toLowerCase().replace(/[^a-z0-9\s]/g, '');
|
|
103
|
+
if (normalized.length < 3) {
|
|
104
|
+
merged.push(line);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (allBullets.has(normalized)) {
|
|
108
|
+
dedupCount++;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
allBullets.add(normalized);
|
|
112
|
+
merged.push(line);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
lines.push(merged.join('\n'));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Just concatenate
|
|
119
|
+
for (const entry of entries) {
|
|
120
|
+
lines.push(entry.content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
lines.push('');
|
|
124
|
+
}
|
|
125
|
+
return { body: lines.join('\n').trim(), deduplicatedCount: dedupCount };
|
|
126
|
+
}
|
|
127
|
+
// ── Strategy: Chain ──────────────────────────────────────────────────────
|
|
128
|
+
function composeChain(skills) {
|
|
129
|
+
const lines = [];
|
|
130
|
+
lines.push('This is a composed skill. Apply the following sections in order:\n');
|
|
131
|
+
for (let i = 0; i < skills.length; i++) {
|
|
132
|
+
const skill = skills[i];
|
|
133
|
+
lines.push(`## Step ${i + 1}: ${skill.name}`);
|
|
134
|
+
lines.push(`> ${skill.description}`);
|
|
135
|
+
lines.push('');
|
|
136
|
+
lines.push(skill.body);
|
|
137
|
+
lines.push('');
|
|
138
|
+
lines.push('---');
|
|
139
|
+
lines.push('');
|
|
140
|
+
}
|
|
141
|
+
return lines.join('\n').trim();
|
|
142
|
+
}
|
|
143
|
+
// ── Strategy: Conditional ────────────────────────────────────────────────
|
|
144
|
+
function composeConditional(skills) {
|
|
145
|
+
const lines = [];
|
|
146
|
+
lines.push('This is a composed skill with conditional sections. Choose the appropriate section based on your context:\n');
|
|
147
|
+
for (const skill of skills) {
|
|
148
|
+
lines.push(`## When working with: ${skill.name}`);
|
|
149
|
+
lines.push(`> ${skill.description}`);
|
|
150
|
+
lines.push('');
|
|
151
|
+
lines.push(skill.body);
|
|
152
|
+
lines.push('');
|
|
153
|
+
lines.push('---');
|
|
154
|
+
lines.push('');
|
|
155
|
+
}
|
|
156
|
+
return lines.join('\n').trim();
|
|
157
|
+
}
|
|
158
|
+
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
159
|
+
async function loadAndParse(path) {
|
|
160
|
+
const skillMd = path.endsWith('SKILL.md') ? path : join(path, 'SKILL.md');
|
|
161
|
+
if (!existsSync(skillMd))
|
|
162
|
+
return null;
|
|
163
|
+
try {
|
|
164
|
+
const raw = await readFile(skillMd, 'utf-8');
|
|
165
|
+
const { data, content } = matter(raw);
|
|
166
|
+
const name = data.name || basename(path);
|
|
167
|
+
const description = data.description || '';
|
|
168
|
+
return {
|
|
169
|
+
name,
|
|
170
|
+
description,
|
|
171
|
+
sections: parseSections(content),
|
|
172
|
+
body: content.trim(),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function parseSections(body) {
|
|
180
|
+
const lines = body.split('\n');
|
|
181
|
+
const sections = [];
|
|
182
|
+
let currentHeading = '(intro)';
|
|
183
|
+
let currentLevel = 0;
|
|
184
|
+
let currentLines = [];
|
|
185
|
+
for (const line of lines) {
|
|
186
|
+
const match = line.match(/^(#{1,4})\s+(.+)/);
|
|
187
|
+
if (match) {
|
|
188
|
+
if (currentLines.length > 0) {
|
|
189
|
+
sections.push({ heading: currentHeading, level: currentLevel, content: currentLines.join('\n') });
|
|
190
|
+
}
|
|
191
|
+
currentHeading = match[2].trim();
|
|
192
|
+
currentLevel = match[1].length;
|
|
193
|
+
currentLines = [];
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
currentLines.push(line);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (currentLines.length > 0) {
|
|
200
|
+
sections.push({ heading: currentHeading, level: currentLevel, content: currentLines.join('\n') });
|
|
201
|
+
}
|
|
202
|
+
return sections;
|
|
203
|
+
}
|
|
204
|
+
function normalizeHeading(heading) {
|
|
205
|
+
const normalized = heading.toLowerCase().trim();
|
|
206
|
+
// Group similar headings
|
|
207
|
+
const aliases = {
|
|
208
|
+
'when to use': ['usage', 'use cases', 'scenarios', 'when to apply'],
|
|
209
|
+
'steps': ['instructions', 'how to', 'process', 'workflow'],
|
|
210
|
+
'examples': ['code examples', 'usage examples', 'sample'],
|
|
211
|
+
'best practices': ['guidelines', 'recommendations', 'tips'],
|
|
212
|
+
'setup': ['installation', 'getting started', 'prerequisites'],
|
|
213
|
+
};
|
|
214
|
+
for (const [canonical, alts] of Object.entries(aliases)) {
|
|
215
|
+
if (normalized === canonical || alts.includes(normalized))
|
|
216
|
+
return canonical;
|
|
217
|
+
}
|
|
218
|
+
return normalized;
|
|
219
|
+
}
|
|
220
|
+
function buildFrontmatter(name, description, sources) {
|
|
221
|
+
return [
|
|
222
|
+
'---',
|
|
223
|
+
`name: ${name}`,
|
|
224
|
+
`description: "${description.replace(/"/g, '\\"')}"`,
|
|
225
|
+
`composed_from: [${sources.map(s => `"${s}"`).join(', ')}]`,
|
|
226
|
+
'---',
|
|
227
|
+
'',
|
|
228
|
+
].join('\n');
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=composer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.js","sourceRoot":"","sources":["../../src/core/composer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,MAAM,MAAM,aAAa,CAAC;AAiDjC,4EAA4E;AAE5E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAuB;IACvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE3D,kBAAkB;IAClB,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;Q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AO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC3D,KAAK;QACL,EAAE;KACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Conflict Detector Module
|
|
3
|
+
* Detects contradictory instructions and overlapping topics across installed skills.
|
|
4
|
+
*
|
|
5
|
+
* 3 detection strategies (no LLM required):
|
|
6
|
+
* 1. Keyword Contradiction — imperative statements that oppose each other
|
|
7
|
+
* 2. Topic Overlap — skills covering identical topics (token waste)
|
|
8
|
+
* 3. Rule Extraction — Do/Don't lists with conflicting directives
|
|
9
|
+
*/
|
|
10
|
+
export interface Conflict {
|
|
11
|
+
/** critical = opposing instructions, warning = potential ambiguity */
|
|
12
|
+
severity: 'critical' | 'warning';
|
|
13
|
+
/** Skill A name */
|
|
14
|
+
skillA: string;
|
|
15
|
+
/** Skill B name */
|
|
16
|
+
skillB: string;
|
|
17
|
+
/** Conflict category */
|
|
18
|
+
category: string;
|
|
19
|
+
/** Human-readable description */
|
|
20
|
+
description: string;
|
|
21
|
+
/** The conflicting line from skill A */
|
|
22
|
+
lineA: string;
|
|
23
|
+
/** The conflicting line from skill B */
|
|
24
|
+
lineB: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Overlap {
|
|
27
|
+
/** Skills sharing the topic */
|
|
28
|
+
skills: string[];
|
|
29
|
+
/** Topic description */
|
|
30
|
+
topic: string;
|
|
31
|
+
/** Estimated duplicate tokens */
|
|
32
|
+
tokenWaste: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ConflictResult {
|
|
35
|
+
/** Direct contradictions found */
|
|
36
|
+
conflicts: Conflict[];
|
|
37
|
+
/** Topic overlaps found */
|
|
38
|
+
overlaps: Overlap[];
|
|
39
|
+
/** Summary counts */
|
|
40
|
+
summary: {
|
|
41
|
+
total: number;
|
|
42
|
+
critical: number;
|
|
43
|
+
warnings: number;
|
|
44
|
+
overlapCount: number;
|
|
45
|
+
estimatedTokenWaste: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Detect conflicts and overlaps across a set of installed skills.
|
|
50
|
+
*
|
|
51
|
+
* @param skillPaths — array of absolute paths to skill directories
|
|
52
|
+
* (each should contain a SKILL.md)
|
|
53
|
+
*/
|
|
54
|
+
export declare function detectConflicts(skillPaths: string[]): Promise<ConflictResult>;
|
|
55
|
+
//# sourceMappingURL=conflict-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-detector.d.ts","sourceRoot":"","sources":["../../src/core/conflict-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,MAAM,WAAW,QAAQ;IACrB,sEAAsE;IACtE,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACpB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC3B,kCAAkC;IAClC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,2BAA2B;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,qBAAqB;IACrB,OAAO,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,mBAAmB,EAAE,MAAM,CAAC;KAC/B,CAAC;CACL;AAoED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA4BnF"}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Conflict Detector Module
|
|
3
|
+
* Detects contradictory instructions and overlapping topics across installed skills.
|
|
4
|
+
*
|
|
5
|
+
* 3 detection strategies (no LLM required):
|
|
6
|
+
* 1. Keyword Contradiction — imperative statements that oppose each other
|
|
7
|
+
* 2. Topic Overlap — skills covering identical topics (token waste)
|
|
8
|
+
* 3. Rule Extraction — Do/Don't lists with conflicting directives
|
|
9
|
+
*/
|
|
10
|
+
import { readFile } from 'fs/promises';
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
import { join, basename } from 'path';
|
|
13
|
+
import matter from 'gray-matter';
|
|
14
|
+
// ── Patterns ─────────────────────────────────────────────────────────────
|
|
15
|
+
/** Patterns for extracting imperative directives */
|
|
16
|
+
const DIRECTIVE_PATTERNS = [
|
|
17
|
+
{ regex: /^\s*[-*]?\s*(?:always\s+)use\s+(.+)/i, verb: 'use' },
|
|
18
|
+
{ regex: /^\s*[-*]?\s*always\s+(.+)/i, verb: 'always' },
|
|
19
|
+
{ regex: /^\s*[-*]?\s*never\s+(.+)/i, verb: 'never' },
|
|
20
|
+
{ regex: /^\s*[-*]?\s*avoid\s+(.+)/i, verb: 'avoid' },
|
|
21
|
+
{ regex: /^\s*[-*]?\s*prefer\s+(.+)/i, verb: 'prefer' },
|
|
22
|
+
{ regex: /^\s*[-*]?\s*(?:do\s+not|don'?t)\s+(.+)/i, verb: 'dont' },
|
|
23
|
+
{ regex: /^\s*[-*]?\s*do\s+(.+)/i, verb: 'do' },
|
|
24
|
+
];
|
|
25
|
+
/** Verbs that oppose each other */
|
|
26
|
+
const OPPOSING_VERBS = [
|
|
27
|
+
['use', 'avoid'],
|
|
28
|
+
['always', 'never'],
|
|
29
|
+
['prefer', 'avoid'],
|
|
30
|
+
['do', 'dont'],
|
|
31
|
+
['use', 'dont'],
|
|
32
|
+
['always', 'dont'],
|
|
33
|
+
['use', 'never'],
|
|
34
|
+
];
|
|
35
|
+
/** Code fence language regex */
|
|
36
|
+
const CODE_FENCE_RE = /```(\w+)/g;
|
|
37
|
+
/** Common stop words to ignore in topic matching */
|
|
38
|
+
const STOP_WORDS = new Set([
|
|
39
|
+
'the', 'a', 'an', 'and', 'or', 'but', 'in', 'on', 'at', 'to', 'for',
|
|
40
|
+
'of', 'with', 'by', 'from', 'is', 'are', 'was', 'were', 'be', 'been',
|
|
41
|
+
'being', 'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would',
|
|
42
|
+
'should', 'could', 'may', 'might', 'shall', 'can', 'need', 'must',
|
|
43
|
+
'this', 'that', 'these', 'those', 'it', 'its', 'you', 'your', 'we',
|
|
44
|
+
'our', 'they', 'their', 'when', 'where', 'how', 'what', 'which',
|
|
45
|
+
'who', 'whom', 'if', 'then', 'else', 'not', 'no', 'as', 'so',
|
|
46
|
+
'than', 'too', 'very', 'just', 'about', 'up', 'out', 'all', 'also',
|
|
47
|
+
'each', 'every', 'any', 'some', 'such', 'only', 'own', 'same',
|
|
48
|
+
'use', 'using', 'used', 'make', 'sure', 'file', 'code', 'skill',
|
|
49
|
+
]);
|
|
50
|
+
// ── Main Entry ───────────────────────────────────────────────────────────
|
|
51
|
+
/**
|
|
52
|
+
* Detect conflicts and overlaps across a set of installed skills.
|
|
53
|
+
*
|
|
54
|
+
* @param skillPaths — array of absolute paths to skill directories
|
|
55
|
+
* (each should contain a SKILL.md)
|
|
56
|
+
*/
|
|
57
|
+
export async function detectConflicts(skillPaths) {
|
|
58
|
+
// 1. Load all skills
|
|
59
|
+
const skills = [];
|
|
60
|
+
for (const p of skillPaths) {
|
|
61
|
+
const skill = await loadSkillContent(p);
|
|
62
|
+
if (skill)
|
|
63
|
+
skills.push(skill);
|
|
64
|
+
}
|
|
65
|
+
// 2. Run detection strategies
|
|
66
|
+
const conflicts = detectContradictions(skills);
|
|
67
|
+
const overlaps = detectOverlaps(skills);
|
|
68
|
+
// 3. Build summary
|
|
69
|
+
const critical = conflicts.filter(c => c.severity === 'critical').length;
|
|
70
|
+
const warnings = conflicts.filter(c => c.severity === 'warning').length;
|
|
71
|
+
const estimatedTokenWaste = overlaps.reduce((sum, o) => sum + o.tokenWaste, 0);
|
|
72
|
+
return {
|
|
73
|
+
conflicts,
|
|
74
|
+
overlaps,
|
|
75
|
+
summary: {
|
|
76
|
+
total: conflicts.length + overlaps.length,
|
|
77
|
+
critical,
|
|
78
|
+
warnings,
|
|
79
|
+
overlapCount: overlaps.length,
|
|
80
|
+
estimatedTokenWaste,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// ── Strategy 1: Keyword Contradiction ────────────────────────────────────
|
|
85
|
+
/**
|
|
86
|
+
* Extract directives from all skills, then cross-compare for contradictions.
|
|
87
|
+
*/
|
|
88
|
+
function detectContradictions(skills) {
|
|
89
|
+
const conflicts = [];
|
|
90
|
+
for (let i = 0; i < skills.length; i++) {
|
|
91
|
+
for (let j = i + 1; j < skills.length; j++) {
|
|
92
|
+
const a = skills[i];
|
|
93
|
+
const b = skills[j];
|
|
94
|
+
for (const da of a.directives) {
|
|
95
|
+
for (const db of b.directives) {
|
|
96
|
+
const opposition = checkOpposition(da, db);
|
|
97
|
+
if (opposition) {
|
|
98
|
+
conflicts.push({
|
|
99
|
+
severity: opposition.confidence > 0.7 ? 'critical' : 'warning',
|
|
100
|
+
skillA: a.name,
|
|
101
|
+
skillB: b.name,
|
|
102
|
+
category: opposition.category,
|
|
103
|
+
description: opposition.description,
|
|
104
|
+
lineA: da.original,
|
|
105
|
+
lineB: db.original,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return conflicts;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if two directives oppose each other.
|
|
116
|
+
*/
|
|
117
|
+
function checkOpposition(a, b) {
|
|
118
|
+
// Check if verbs are opposing
|
|
119
|
+
const isOpposing = OPPOSING_VERBS.some(([v1, v2]) => (a.verb === v1 && b.verb === v2) || (a.verb === v2 && b.verb === v1));
|
|
120
|
+
if (!isOpposing)
|
|
121
|
+
return null;
|
|
122
|
+
// Check if subjects are similar (normalized comparison)
|
|
123
|
+
const similarity = subjectSimilarity(a.subject, b.subject);
|
|
124
|
+
if (similarity < 0.4)
|
|
125
|
+
return null;
|
|
126
|
+
// Determine category from subject keywords
|
|
127
|
+
const category = categorizeSubject(a.subject + ' ' + b.subject);
|
|
128
|
+
return {
|
|
129
|
+
confidence: similarity,
|
|
130
|
+
category,
|
|
131
|
+
description: `"${a.verb} ${a.subject}" conflicts with "${b.verb} ${b.subject}"`,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Compute similarity between two subjects (0-1).
|
|
136
|
+
* Uses normalized word overlap (Jaccard-like).
|
|
137
|
+
*/
|
|
138
|
+
function subjectSimilarity(a, b) {
|
|
139
|
+
const wordsA = extractWords(a);
|
|
140
|
+
const wordsB = extractWords(b);
|
|
141
|
+
if (wordsA.length === 0 || wordsB.length === 0)
|
|
142
|
+
return 0;
|
|
143
|
+
const setA = new Set(wordsA);
|
|
144
|
+
const setB = new Set(wordsB);
|
|
145
|
+
let intersection = 0;
|
|
146
|
+
for (const word of setA) {
|
|
147
|
+
if (setB.has(word))
|
|
148
|
+
intersection++;
|
|
149
|
+
}
|
|
150
|
+
const union = new Set([...setA, ...setB]).size;
|
|
151
|
+
return union === 0 ? 0 : intersection / union;
|
|
152
|
+
}
|
|
153
|
+
// ── Strategy 2: Topic Overlap ────────────────────────────────────────────
|
|
154
|
+
/**
|
|
155
|
+
* Detect skills that cover the same topic (duplicate instructions).
|
|
156
|
+
*/
|
|
157
|
+
function detectOverlaps(skills) {
|
|
158
|
+
const overlaps = [];
|
|
159
|
+
const seen = new Set();
|
|
160
|
+
for (let i = 0; i < skills.length; i++) {
|
|
161
|
+
for (let j = i + 1; j < skills.length; j++) {
|
|
162
|
+
const a = skills[i];
|
|
163
|
+
const b = skills[j];
|
|
164
|
+
const key = [a.name, b.name].sort().join('::');
|
|
165
|
+
if (seen.has(key))
|
|
166
|
+
continue;
|
|
167
|
+
// Check heading overlap
|
|
168
|
+
const headingOverlap = arrayOverlap(a.topics.headings, b.topics.headings);
|
|
169
|
+
// Check keyword overlap
|
|
170
|
+
const keywordOverlap = arrayOverlap(a.topics.keywords, b.topics.keywords);
|
|
171
|
+
// Check language overlap
|
|
172
|
+
const langOverlap = arrayOverlap(a.topics.codeLanguages, b.topics.codeLanguages);
|
|
173
|
+
// Weighted score
|
|
174
|
+
const score = headingOverlap * 0.5 + keywordOverlap * 0.35 + langOverlap * 0.15;
|
|
175
|
+
if (score > 0.35) {
|
|
176
|
+
seen.add(key);
|
|
177
|
+
// Estimate token waste: smaller skill's token count × overlap ratio
|
|
178
|
+
const tokensA = Math.ceil(a.body.length / 4);
|
|
179
|
+
const tokensB = Math.ceil(b.body.length / 4);
|
|
180
|
+
const waste = Math.round(Math.min(tokensA, tokensB) * score);
|
|
181
|
+
// Find the common topic
|
|
182
|
+
const commonHeadings = a.topics.headings.filter(h => b.topics.headings.includes(h));
|
|
183
|
+
const commonKeywords = a.topics.keywords.filter(k => b.topics.keywords.includes(k));
|
|
184
|
+
const topic = commonHeadings.length > 0
|
|
185
|
+
? commonHeadings.slice(0, 3).join(', ')
|
|
186
|
+
: commonKeywords.slice(0, 5).join(', ');
|
|
187
|
+
overlaps.push({
|
|
188
|
+
skills: [a.name, b.name],
|
|
189
|
+
topic: topic || 'general instructions',
|
|
190
|
+
tokenWaste: waste,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return overlaps;
|
|
196
|
+
}
|
|
197
|
+
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
198
|
+
/**
|
|
199
|
+
* Load a skill's content and extract directives + topics.
|
|
200
|
+
*/
|
|
201
|
+
async function loadSkillContent(skillPath) {
|
|
202
|
+
const skillMd = skillPath.endsWith('SKILL.md')
|
|
203
|
+
? skillPath
|
|
204
|
+
: join(skillPath, 'SKILL.md');
|
|
205
|
+
if (!existsSync(skillMd))
|
|
206
|
+
return null;
|
|
207
|
+
try {
|
|
208
|
+
const raw = await readFile(skillMd, 'utf-8');
|
|
209
|
+
const { data, content } = matter(raw);
|
|
210
|
+
const name = data.name || basename(skillPath);
|
|
211
|
+
const directives = extractDirectives(content);
|
|
212
|
+
const topics = extractTopics(content);
|
|
213
|
+
return { name, path: skillPath, body: content, directives, topics };
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Extract imperative directives from skill body.
|
|
221
|
+
*/
|
|
222
|
+
function extractDirectives(body) {
|
|
223
|
+
const directives = [];
|
|
224
|
+
const lines = body.split('\n');
|
|
225
|
+
for (const line of lines) {
|
|
226
|
+
const trimmed = line.trim();
|
|
227
|
+
if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith('```'))
|
|
228
|
+
continue;
|
|
229
|
+
for (const { regex, verb } of DIRECTIVE_PATTERNS) {
|
|
230
|
+
const match = trimmed.match(regex);
|
|
231
|
+
if (match) {
|
|
232
|
+
const subject = match[1].replace(/[.!,;:]+$/, '').trim().toLowerCase();
|
|
233
|
+
if (subject.length > 2 && subject.length < 200) {
|
|
234
|
+
directives.push({ line: trimmed, verb, subject, original: trimmed });
|
|
235
|
+
}
|
|
236
|
+
break; // only match first pattern per line
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return directives;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Extract topic signals from skill body: headings, keywords, code languages.
|
|
244
|
+
*/
|
|
245
|
+
function extractTopics(body) {
|
|
246
|
+
const lines = body.split('\n');
|
|
247
|
+
const headings = [];
|
|
248
|
+
const allWords = [];
|
|
249
|
+
const codeLanguages = [];
|
|
250
|
+
let inCodeBlock = false;
|
|
251
|
+
for (const line of lines) {
|
|
252
|
+
if (line.trim().startsWith('```')) {
|
|
253
|
+
inCodeBlock = !inCodeBlock;
|
|
254
|
+
// Extract language from opening fence
|
|
255
|
+
if (inCodeBlock) {
|
|
256
|
+
const match = line.match(/```(\w+)/);
|
|
257
|
+
if (match && match[1]) {
|
|
258
|
+
codeLanguages.push(match[1].toLowerCase());
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (inCodeBlock)
|
|
264
|
+
continue;
|
|
265
|
+
// Extract headings (## or ###)
|
|
266
|
+
const headingMatch = line.match(/^#{2,4}\s+(.+)/);
|
|
267
|
+
if (headingMatch) {
|
|
268
|
+
headings.push(headingMatch[1].toLowerCase().trim());
|
|
269
|
+
}
|
|
270
|
+
// Extract significant words
|
|
271
|
+
const words = extractWords(line);
|
|
272
|
+
allWords.push(...words);
|
|
273
|
+
}
|
|
274
|
+
// Get top keywords by frequency (skip stop words)
|
|
275
|
+
const freq = new Map();
|
|
276
|
+
for (const word of allWords) {
|
|
277
|
+
freq.set(word, (freq.get(word) || 0) + 1);
|
|
278
|
+
}
|
|
279
|
+
const keywords = [...freq.entries()]
|
|
280
|
+
.filter(([, count]) => count >= 2)
|
|
281
|
+
.sort((a, b) => b[1] - a[1])
|
|
282
|
+
.slice(0, 30)
|
|
283
|
+
.map(([word]) => word);
|
|
284
|
+
return {
|
|
285
|
+
keywords,
|
|
286
|
+
headings: [...new Set(headings)],
|
|
287
|
+
codeLanguages: [...new Set(codeLanguages)],
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Extract significant words from a line (lowercase, no stop words, min length 3).
|
|
292
|
+
*/
|
|
293
|
+
function extractWords(text) {
|
|
294
|
+
return text
|
|
295
|
+
.toLowerCase()
|
|
296
|
+
.replace(/[^a-z0-9\s-]/g, ' ')
|
|
297
|
+
.split(/\s+/)
|
|
298
|
+
.filter(w => w.length >= 3 && !STOP_WORDS.has(w));
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Compute overlap ratio between two arrays (Jaccard index).
|
|
302
|
+
*/
|
|
303
|
+
function arrayOverlap(a, b) {
|
|
304
|
+
if (a.length === 0 || b.length === 0)
|
|
305
|
+
return 0;
|
|
306
|
+
const setA = new Set(a);
|
|
307
|
+
const setB = new Set(b);
|
|
308
|
+
let intersection = 0;
|
|
309
|
+
for (const item of setA) {
|
|
310
|
+
if (setB.has(item))
|
|
311
|
+
intersection++;
|
|
312
|
+
}
|
|
313
|
+
const union = new Set([...setA, ...setB]).size;
|
|
314
|
+
return union === 0 ? 0 : intersection / union;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Categorize a subject string into a conflict category.
|
|
318
|
+
*/
|
|
319
|
+
function categorizeSubject(text) {
|
|
320
|
+
const lower = text.toLowerCase();
|
|
321
|
+
const categories = [
|
|
322
|
+
['formatting', ['format', 'indent', 'tab', 'space', 'semicolon', 'quote', 'lint', 'prettier', 'eslint']],
|
|
323
|
+
['architecture', ['component', 'class', 'function', 'functional', 'module', 'pattern', 'architecture', 'structure']],
|
|
324
|
+
['testing', ['test', 'spec', 'jest', 'vitest', 'mocha', 'assert', 'mock', 'stub']],
|
|
325
|
+
['styling', ['css', 'style', 'tailwind', 'sass', 'scss', 'styled', 'theme', 'color']],
|
|
326
|
+
['state management', ['state', 'redux', 'zustand', 'context', 'store', 'signal', 'observable']],
|
|
327
|
+
['dependencies', ['import', 'require', 'dependency', 'package', 'library', 'framework']],
|
|
328
|
+
['language', ['typescript', 'javascript', 'python', 'rust', 'go', 'java', 'type', 'interface']],
|
|
329
|
+
['security', ['auth', 'token', 'password', 'secret', 'encrypt', 'cors', 'xss', 'csrf']],
|
|
330
|
+
['deployment', ['deploy', 'build', 'ci', 'cd', 'docker', 'kubernetes', 'vercel', 'aws']],
|
|
331
|
+
['api', ['api', 'rest', 'graphql', 'endpoint', 'route', 'fetch', 'request', 'response']],
|
|
332
|
+
];
|
|
333
|
+
for (const [category, keywords] of categories) {
|
|
334
|
+
if (keywords.some(kw => lower.includes(kw)))
|
|
335
|
+
return category;
|
|
336
|
+
}
|
|
337
|
+
return 'general';
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=conflict-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-detector.js","sourceRoot":"","sources":["../../src/core/conflict-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,MAAM,MAAM,aAAa,CAAC;AAoEjC,4EAA4E;AAE5E,oDAAoD;AACpD,MAAM,kBAAkB,GAAsD;IAC1E,EAAE,KAAK,EAAE,sCAAsC,EAAE,IAAI,EAAE,KAAK,EAAE;IAC9D,EAAE,KAAK,EAAE,4BAA4B,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvD,EAAE,KAAK,EAAE,2BAA2B,EAAE,IAAI,EAAE,OAAO,EAAE;IACrD,EAAE,KAAK,EAAE,2BAA2B,EAAE,IAAI,EAAE,OAAO,EAAE;IACrD,EAAE,KAAK,EAAE,4BAA4B,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvD,EAAE,KAAK,EAAE,yCAAyC,EAAE,IAAI,EAAE,MAAM,EAAE;IAClE,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,I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