@lagoon-protocol/lagoon-mcp 0.1.2 → 0.2.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/README.md +54 -0
- package/dist/server.js +1 -1
- package/dist/skills/curator-evaluation.d.ts +15 -0
- package/dist/skills/curator-evaluation.d.ts.map +1 -0
- package/dist/skills/curator-evaluation.js +424 -0
- package/dist/skills/curator-evaluation.js.map +1 -0
- package/dist/skills/customer-support.d.ts +15 -0
- package/dist/skills/customer-support.d.ts.map +1 -0
- package/dist/skills/customer-support.js +512 -0
- package/dist/skills/customer-support.js.map +1 -0
- package/dist/skills/index.d.ts +91 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +100 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/loader.d.ts +120 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +263 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/onboarding.d.ts +15 -0
- package/dist/skills/onboarding.d.ts.map +1 -0
- package/dist/skills/onboarding.js +383 -0
- package/dist/skills/onboarding.js.map +1 -0
- package/dist/skills/portfolio-review.d.ts +15 -0
- package/dist/skills/portfolio-review.d.ts.map +1 -0
- package/dist/skills/portfolio-review.js +464 -0
- package/dist/skills/portfolio-review.js.map +1 -0
- package/dist/skills/protocol-health.d.ts +15 -0
- package/dist/skills/protocol-health.d.ts.map +1 -0
- package/dist/skills/protocol-health.js +451 -0
- package/dist/skills/protocol-health.js.map +1 -0
- package/dist/skills/risk-expert.d.ts +15 -0
- package/dist/skills/risk-expert.d.ts.map +1 -0
- package/dist/skills/risk-expert.js +456 -0
- package/dist/skills/risk-expert.js.map +1 -0
- package/dist/skills/shared.d.ts +82 -0
- package/dist/skills/shared.d.ts.map +1 -0
- package/dist/skills/shared.js +136 -0
- package/dist/skills/shared.js.map +1 -0
- package/dist/skills/types.d.ts +137 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +11 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tools/discover-tools.d.ts +44 -0
- package/dist/tools/discover-tools.d.ts.map +1 -0
- package/dist/tools/discover-tools.js +108 -0
- package/dist/tools/discover-tools.js.map +1 -0
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +12 -2
- package/dist/tools/registry.js.map +1 -1
- package/dist/utils/validators.d.ts +2 -2
- package/dist/utils/validators.d.ts.map +1 -1
- package/dist/utils/validators.js +2 -1
- package/dist/utils/validators.js.map +1 -1
- package/package.json +14 -1
- package/skills/README.md +141 -0
- package/skills/lagoon-curator-evaluation/SKILL.md +281 -0
- package/skills/lagoon-curator-evaluation/scoring-rubric.md +121 -0
- package/skills/lagoon-customer-support/SKILL.md +95 -0
- package/skills/lagoon-customer-support/response-templates.md +196 -0
- package/skills/lagoon-onboarding/SKILL.md +251 -0
- package/skills/lagoon-onboarding/risk-interpretation.md +188 -0
- package/skills/lagoon-onboarding/tool-sequences.md +217 -0
- package/skills/lagoon-portfolio-review/SKILL.md +156 -0
- package/skills/lagoon-portfolio-review/rebalancing-criteria.md +85 -0
- package/skills/lagoon-portfolio-review/review-framework.md +70 -0
- package/skills/lagoon-protocol-health/SKILL.md +171 -0
- package/skills/lagoon-protocol-health/kpi-thresholds.md +50 -0
- package/skills/lagoon-protocol-health/report-templates.md +149 -0
- package/skills/lagoon-risk-expert/SKILL.md +131 -0
- package/skills/lagoon-risk-expert/risk-frameworks.md +124 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAgBH,oBAAoB;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,mBAAmB;AACnB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,mBAAmB;AACnB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,eAAe,EACf,aAAa,EACb,cAAc,EACd,SAAS,EACT,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,sDAAsD;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,UAAU,EAAE,qBAAqB;IACjC,cAAc,EAAE,yBAAyB;IACzC,eAAe,EAAE,0BAA0B;IAC3C,iBAAiB,EAAE,4BAA4B;IAC/C,UAAU,EAAE,qBAAqB;IACjC,eAAe,EAAE,0BAA0B;CACnC,CAAC;AAEX;;GAEG;AACH,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Loader and Detection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for loading skills programmatically and detecting
|
|
5
|
+
* which skill is relevant for a given user message.
|
|
6
|
+
*
|
|
7
|
+
* @module skills/loader
|
|
8
|
+
*/
|
|
9
|
+
import type { BuildPromptOptions, BuildPromptResult, LagoonSkill, SkillDetectionResult, SkillLoadOptions, SkillRegistry } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Detect which skill is most relevant for a user message
|
|
12
|
+
*
|
|
13
|
+
* @param message - User message to analyze
|
|
14
|
+
* @returns Detection result with skill, confidence, and matched triggers
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const result = detectSkill("I'm new to DeFi, where should I start?");
|
|
19
|
+
* if (result.skill && result.confidence > 0.5) {
|
|
20
|
+
* systemPrompt += result.skill.instructions;
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function detectSkill(message: string): SkillDetectionResult;
|
|
25
|
+
/**
|
|
26
|
+
* Get a skill by name
|
|
27
|
+
*
|
|
28
|
+
* @param name - Skill name (e.g., 'lagoon-onboarding')
|
|
29
|
+
* @returns The skill or undefined if not found
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSkill(name: string): LagoonSkill | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Get all skills, optionally filtered by options
|
|
34
|
+
*
|
|
35
|
+
* @param options - Filter options
|
|
36
|
+
* @returns Array of matching skills
|
|
37
|
+
*/
|
|
38
|
+
export declare function getSkills(options?: SkillLoadOptions): LagoonSkill[];
|
|
39
|
+
/**
|
|
40
|
+
* Get skill content formatted for system prompt injection
|
|
41
|
+
*
|
|
42
|
+
* @param name - Skill name
|
|
43
|
+
* @param options - Load options
|
|
44
|
+
* @returns Formatted skill content or empty string if not found
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const skillPrompt = getSkillPrompt('lagoon-onboarding', {
|
|
49
|
+
* includeResources: true
|
|
50
|
+
* });
|
|
51
|
+
* const systemPrompt = basePrompt + skillPrompt;
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function getSkillPrompt(name: string, options?: SkillLoadOptions): string;
|
|
55
|
+
/**
|
|
56
|
+
* Get all skill names
|
|
57
|
+
*
|
|
58
|
+
* @returns Array of skill names
|
|
59
|
+
*/
|
|
60
|
+
export declare function getSkillNames(): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Get skill metadata for all skills (lightweight)
|
|
63
|
+
*
|
|
64
|
+
* @returns Array of skill metadata with name and description
|
|
65
|
+
*/
|
|
66
|
+
export declare function getSkillCatalog(): Array<{
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
audience: string;
|
|
70
|
+
category: string;
|
|
71
|
+
estimatedTokens: number;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Create a skill registry instance
|
|
75
|
+
*
|
|
76
|
+
* @returns SkillRegistry implementation
|
|
77
|
+
*/
|
|
78
|
+
export declare function createSkillRegistry(): SkillRegistry;
|
|
79
|
+
/**
|
|
80
|
+
* Default skill registry instance
|
|
81
|
+
*/
|
|
82
|
+
export declare const skillRegistry: SkillRegistry;
|
|
83
|
+
/**
|
|
84
|
+
* Build a skill-aware system prompt for Claude API integration
|
|
85
|
+
*
|
|
86
|
+
* This is the main helper function for backend integrations. It automatically
|
|
87
|
+
* detects relevant skills based on user message and injects them into the
|
|
88
|
+
* system prompt.
|
|
89
|
+
*
|
|
90
|
+
* @param baseSystemPrompt - Your base system prompt
|
|
91
|
+
* @param userMessage - The user's message to analyze for skill triggers
|
|
92
|
+
* @param options - Configuration options
|
|
93
|
+
* @returns Result with complete system prompt and detection metadata
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* import { buildSkillAwarePrompt } from '@lagoon-protocol/lagoon-mcp/skills';
|
|
98
|
+
*
|
|
99
|
+
* // In your Claude API handler:
|
|
100
|
+
* const { systemPrompt, detectedSkill, tokensAdded } = buildSkillAwarePrompt(
|
|
101
|
+
* "You are a Lagoon vault assistant...",
|
|
102
|
+
* userMessage,
|
|
103
|
+
* { confidenceThreshold: 0.5 }
|
|
104
|
+
* );
|
|
105
|
+
*
|
|
106
|
+
* const response = await claude.messages.create({
|
|
107
|
+
* model: 'claude-sonnet-4-20250514',
|
|
108
|
+
* system: systemPrompt,
|
|
109
|
+
* tools: mcpTools,
|
|
110
|
+
* messages: [{ role: 'user', content: userMessage }]
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* // Log skill usage for analytics
|
|
114
|
+
* if (detectedSkill) {
|
|
115
|
+
* console.log(`Skill activated: ${detectedSkill} (+${tokensAdded} tokens)`);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function buildSkillAwarePrompt(baseSystemPrompt: string, userMessage: string, options?: BuildPromptOptions): BuildPromptResult;
|
|
120
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/skills/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACd,MAAM,YAAY,CAAC;AAqBpB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CA+BjE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,WAAW,EAAE,CAYnE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAwC/E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAExC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,KAAK,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAQD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAQnD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,eAAwB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CA+CnB"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Loader and Detection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for loading skills programmatically and detecting
|
|
5
|
+
* which skill is relevant for a given user message.
|
|
6
|
+
*
|
|
7
|
+
* @module skills/loader
|
|
8
|
+
*/
|
|
9
|
+
import { lagoonOnboardingSkill } from './onboarding.js';
|
|
10
|
+
import { lagoonProtocolHealthSkill } from './protocol-health.js';
|
|
11
|
+
import { lagoonPortfolioReviewSkill } from './portfolio-review.js';
|
|
12
|
+
import { lagoonCuratorEvaluationSkill } from './curator-evaluation.js';
|
|
13
|
+
import { lagoonRiskExpertSkill } from './risk-expert.js';
|
|
14
|
+
import { lagoonCustomerSupportSkill } from './customer-support.js';
|
|
15
|
+
/**
|
|
16
|
+
* All registered skills
|
|
17
|
+
* Add new skills here as they are implemented
|
|
18
|
+
*/
|
|
19
|
+
const ALL_SKILLS = [
|
|
20
|
+
lagoonOnboardingSkill,
|
|
21
|
+
lagoonProtocolHealthSkill,
|
|
22
|
+
lagoonPortfolioReviewSkill,
|
|
23
|
+
lagoonCuratorEvaluationSkill,
|
|
24
|
+
lagoonRiskExpertSkill,
|
|
25
|
+
lagoonCustomerSupportSkill,
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Detect which skill is most relevant for a user message
|
|
29
|
+
*
|
|
30
|
+
* @param message - User message to analyze
|
|
31
|
+
* @returns Detection result with skill, confidence, and matched triggers
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const result = detectSkill("I'm new to DeFi, where should I start?");
|
|
36
|
+
* if (result.skill && result.confidence > 0.5) {
|
|
37
|
+
* systemPrompt += result.skill.instructions;
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function detectSkill(message) {
|
|
42
|
+
const normalizedMessage = message.toLowerCase().trim();
|
|
43
|
+
let bestMatch = null;
|
|
44
|
+
let bestConfidence = 0;
|
|
45
|
+
let bestTriggers = [];
|
|
46
|
+
for (const skill of ALL_SKILLS) {
|
|
47
|
+
const matchedTriggers = skill.triggers.filter((trigger) => normalizedMessage.includes(trigger.toLowerCase()));
|
|
48
|
+
if (matchedTriggers.length > 0) {
|
|
49
|
+
// Confidence based on number of matched triggers and their specificity
|
|
50
|
+
const triggerScore = matchedTriggers.length / skill.triggers.length;
|
|
51
|
+
const specificityBonus = matchedTriggers.some((t) => t.length > 10) ? 0.2 : 0;
|
|
52
|
+
const confidence = Math.min(triggerScore + specificityBonus, 1);
|
|
53
|
+
if (confidence > bestConfidence) {
|
|
54
|
+
bestMatch = skill;
|
|
55
|
+
bestConfidence = confidence;
|
|
56
|
+
bestTriggers = matchedTriggers;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
skill: bestMatch,
|
|
62
|
+
confidence: bestConfidence,
|
|
63
|
+
matchedTriggers: bestTriggers,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get a skill by name
|
|
68
|
+
*
|
|
69
|
+
* @param name - Skill name (e.g., 'lagoon-onboarding')
|
|
70
|
+
* @returns The skill or undefined if not found
|
|
71
|
+
*/
|
|
72
|
+
export function getSkill(name) {
|
|
73
|
+
return ALL_SKILLS.find((skill) => skill.name === name);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get all skills, optionally filtered by options
|
|
77
|
+
*
|
|
78
|
+
* @param options - Filter options
|
|
79
|
+
* @returns Array of matching skills
|
|
80
|
+
*/
|
|
81
|
+
export function getSkills(options) {
|
|
82
|
+
let skills = [...ALL_SKILLS];
|
|
83
|
+
if (options?.audience) {
|
|
84
|
+
skills = skills.filter((s) => options.audience.includes(s.audience));
|
|
85
|
+
}
|
|
86
|
+
if (options?.category) {
|
|
87
|
+
skills = skills.filter((s) => options.category.includes(s.metadata.category));
|
|
88
|
+
}
|
|
89
|
+
return skills;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get skill content formatted for system prompt injection
|
|
93
|
+
*
|
|
94
|
+
* @param name - Skill name
|
|
95
|
+
* @param options - Load options
|
|
96
|
+
* @returns Formatted skill content or empty string if not found
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const skillPrompt = getSkillPrompt('lagoon-onboarding', {
|
|
101
|
+
* includeResources: true
|
|
102
|
+
* });
|
|
103
|
+
* const systemPrompt = basePrompt + skillPrompt;
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export function getSkillPrompt(name, options) {
|
|
107
|
+
const skill = getSkill(name);
|
|
108
|
+
if (!skill)
|
|
109
|
+
return '';
|
|
110
|
+
let content = skill.instructions;
|
|
111
|
+
// Optionally include resources
|
|
112
|
+
if (options?.includeResources && skill.resources) {
|
|
113
|
+
const resourceContent = Object.entries(skill.resources)
|
|
114
|
+
.filter(([_, value]) => value !== undefined)
|
|
115
|
+
.map(([key, value]) => `\n\n## Resource: ${key}\n\n${value}`)
|
|
116
|
+
.join('');
|
|
117
|
+
content += resourceContent;
|
|
118
|
+
}
|
|
119
|
+
// Token budget check (using 3.5 chars/token for Lagoon's dense technical content)
|
|
120
|
+
if (options?.maxTokens) {
|
|
121
|
+
const estimatedTokens = Math.ceil(content.length / 3.5);
|
|
122
|
+
if (estimatedTokens > options.maxTokens) {
|
|
123
|
+
const maxChars = Math.floor(options.maxTokens * 3.5);
|
|
124
|
+
// Try to truncate at semantic boundaries (resource sections first)
|
|
125
|
+
const lastResourceBreak = content.lastIndexOf('\n\n## Resource:', maxChars);
|
|
126
|
+
if (lastResourceBreak > maxChars * 0.7) {
|
|
127
|
+
content =
|
|
128
|
+
content.slice(0, lastResourceBreak) +
|
|
129
|
+
'\n\n[Resources truncated - core instructions included]';
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// Fall back to paragraph boundary
|
|
133
|
+
const lastParagraph = content.lastIndexOf('\n\n', maxChars);
|
|
134
|
+
if (lastParagraph > maxChars * 0.8) {
|
|
135
|
+
content = content.slice(0, lastParagraph) + '\n\n[Content truncated]';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
content = content.slice(0, maxChars) + '\n\n[Content truncated]';
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return content;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get all skill names
|
|
147
|
+
*
|
|
148
|
+
* @returns Array of skill names
|
|
149
|
+
*/
|
|
150
|
+
export function getSkillNames() {
|
|
151
|
+
return ALL_SKILLS.map((skill) => skill.name);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get skill metadata for all skills (lightweight)
|
|
155
|
+
*
|
|
156
|
+
* @returns Array of skill metadata with name and description
|
|
157
|
+
*/
|
|
158
|
+
export function getSkillCatalog() {
|
|
159
|
+
return ALL_SKILLS.map((skill) => ({
|
|
160
|
+
name: skill.name,
|
|
161
|
+
description: skill.description,
|
|
162
|
+
audience: skill.audience,
|
|
163
|
+
category: skill.metadata.category,
|
|
164
|
+
estimatedTokens: skill.metadata.estimatedTokens,
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Create a skill registry instance
|
|
169
|
+
*
|
|
170
|
+
* @returns SkillRegistry implementation
|
|
171
|
+
*/
|
|
172
|
+
export function createSkillRegistry() {
|
|
173
|
+
return {
|
|
174
|
+
skills: ALL_SKILLS,
|
|
175
|
+
getSkill,
|
|
176
|
+
detectSkill,
|
|
177
|
+
getSkills,
|
|
178
|
+
getSkillPrompt,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Default skill registry instance
|
|
183
|
+
*/
|
|
184
|
+
export const skillRegistry = createSkillRegistry();
|
|
185
|
+
/**
|
|
186
|
+
* Build a skill-aware system prompt for Claude API integration
|
|
187
|
+
*
|
|
188
|
+
* This is the main helper function for backend integrations. It automatically
|
|
189
|
+
* detects relevant skills based on user message and injects them into the
|
|
190
|
+
* system prompt.
|
|
191
|
+
*
|
|
192
|
+
* @param baseSystemPrompt - Your base system prompt
|
|
193
|
+
* @param userMessage - The user's message to analyze for skill triggers
|
|
194
|
+
* @param options - Configuration options
|
|
195
|
+
* @returns Result with complete system prompt and detection metadata
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* import { buildSkillAwarePrompt } from '@lagoon-protocol/lagoon-mcp/skills';
|
|
200
|
+
*
|
|
201
|
+
* // In your Claude API handler:
|
|
202
|
+
* const { systemPrompt, detectedSkill, tokensAdded } = buildSkillAwarePrompt(
|
|
203
|
+
* "You are a Lagoon vault assistant...",
|
|
204
|
+
* userMessage,
|
|
205
|
+
* { confidenceThreshold: 0.5 }
|
|
206
|
+
* );
|
|
207
|
+
*
|
|
208
|
+
* const response = await claude.messages.create({
|
|
209
|
+
* model: 'claude-sonnet-4-20250514',
|
|
210
|
+
* system: systemPrompt,
|
|
211
|
+
* tools: mcpTools,
|
|
212
|
+
* messages: [{ role: 'user', content: userMessage }]
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* // Log skill usage for analytics
|
|
216
|
+
* if (detectedSkill) {
|
|
217
|
+
* console.log(`Skill activated: ${detectedSkill} (+${tokensAdded} tokens)`);
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export function buildSkillAwarePrompt(baseSystemPrompt, userMessage, options = {}) {
|
|
222
|
+
// Conservative defaults for token efficiency
|
|
223
|
+
// - includeResources: false saves ~500 tokens (use true for rich guidance)
|
|
224
|
+
// - maxTokens: 1000 prevents runaway costs (use undefined for no limit)
|
|
225
|
+
const confidenceThreshold = options.confidenceThreshold ?? 0.5;
|
|
226
|
+
const includeResources = options.includeResources ?? false;
|
|
227
|
+
const separator = options.separator ?? '\n\n---\n\n';
|
|
228
|
+
// Use hasOwnProperty to distinguish between omitted and explicitly set to undefined
|
|
229
|
+
let maxTokens = 1000;
|
|
230
|
+
if (Object.prototype.hasOwnProperty.call(options, 'maxTokens')) {
|
|
231
|
+
maxTokens = options.maxTokens;
|
|
232
|
+
}
|
|
233
|
+
// Detect relevant skill
|
|
234
|
+
const detection = detectSkill(userMessage);
|
|
235
|
+
// No skill matched or below threshold
|
|
236
|
+
if (!detection.skill || detection.confidence < confidenceThreshold) {
|
|
237
|
+
return {
|
|
238
|
+
systemPrompt: baseSystemPrompt,
|
|
239
|
+
detectedSkill: null,
|
|
240
|
+
confidence: 0,
|
|
241
|
+
matchedTriggers: [],
|
|
242
|
+
tokensAdded: 0,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
// Get skill content
|
|
246
|
+
const loadOptions = {
|
|
247
|
+
includeResources,
|
|
248
|
+
maxTokens,
|
|
249
|
+
};
|
|
250
|
+
const skillContent = getSkillPrompt(detection.skill.name, loadOptions);
|
|
251
|
+
// Estimate tokens added (using 3.5 chars/token for Lagoon's dense technical content)
|
|
252
|
+
const tokensAdded = Math.ceil(skillContent.length / 3.5);
|
|
253
|
+
// Build complete prompt
|
|
254
|
+
const systemPrompt = baseSystemPrompt + separator + skillContent;
|
|
255
|
+
return {
|
|
256
|
+
systemPrompt,
|
|
257
|
+
detectedSkill: detection.skill.name,
|
|
258
|
+
confidence: detection.confidence,
|
|
259
|
+
matchedTriggers: detection.matchedTriggers,
|
|
260
|
+
tokensAdded,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/skills/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,GAAkB;IAChC,qBAAqB;IACrB,yBAAyB;IACzB,0BAA0B;IAC1B,4BAA4B;IAC5B,qBAAqB;IACrB,0BAA0B;CAC3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAEvD,IAAI,SAAS,GAAuB,IAAI,CAAC;IACzC,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,YAAY,GAAa,EAAE,CAAC;IAEhC,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,eAAe,GAAG,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AAC;IACF,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEvE,qFAAqF;IACrF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;IAEzD,wBAAwB;IACxB,MAAM,YAAY,GAAG,gBAAgB,GAAG,SAAS,GAAG,YAAY,CAAC;IAEjE,OAAO;QACL,YAAY;QACZ,aAAa,EAAE,SAAS,CAAC,KAAK,CAAC,IAAI;QACnC,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,eAAe,EAAE,SAAS,CAAC,eAAe;QAC1C,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lagoon Onboarding Skill
|
|
3
|
+
*
|
|
4
|
+
* Guides new users through their first vault selection with risk-appropriate
|
|
5
|
+
* recommendations, systematic analysis workflows, and educational support.
|
|
6
|
+
*
|
|
7
|
+
* @module skills/onboarding
|
|
8
|
+
*/
|
|
9
|
+
import type { LagoonSkill } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Lagoon Onboarding Skill Definition
|
|
12
|
+
*/
|
|
13
|
+
export declare const lagoonOnboardingSkill: LagoonSkill;
|
|
14
|
+
export default lagoonOnboardingSkill;
|
|
15
|
+
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/skills/onboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAsV9C;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAiCnC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|