@hailer/mcp 0.0.1
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/.claude/commands/tool-builder.md +37 -0
- package/.claude/commands/ws-pull.md +44 -0
- package/.claude/settings.json +8 -0
- package/.claude/settings.local.json +49 -0
- package/.claude/skills/activity-api/SKILL.md +96 -0
- package/.claude/skills/activity-api/references/activity-endpoints.md +845 -0
- package/.claude/skills/add-app-member-skill/SKILL.md +977 -0
- package/.claude/skills/agent-building/SKILL.md +243 -0
- package/.claude/skills/agent-building/references/architecture-patterns.md +446 -0
- package/.claude/skills/agent-building/references/code-examples.md +587 -0
- package/.claude/skills/agent-building/references/implementation-guide.md +619 -0
- package/.claude/skills/app-api/SKILL.md +219 -0
- package/.claude/skills/app-api/references/app-endpoints.md +759 -0
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +548 -0
- package/.claude/skills/create-app-skill/SKILL.md +1101 -0
- package/.claude/skills/create-insight-skill/SKILL.md +1317 -0
- package/.claude/skills/get-insight-data-skill/SKILL.md +1053 -0
- package/.claude/skills/hailer-api/SKILL.md +283 -0
- package/.claude/skills/hailer-api/references/activities.md +620 -0
- package/.claude/skills/hailer-api/references/authentication.md +216 -0
- package/.claude/skills/hailer-api/references/datasets.md +437 -0
- package/.claude/skills/hailer-api/references/files.md +301 -0
- package/.claude/skills/hailer-api/references/insights.md +469 -0
- package/.claude/skills/hailer-api/references/workflows.md +720 -0
- package/.claude/skills/hailer-api/references/workspaces-users.md +445 -0
- package/.claude/skills/insight-api/SKILL.md +185 -0
- package/.claude/skills/insight-api/references/insight-endpoints.md +514 -0
- package/.claude/skills/install-workflow-skill/SKILL.md +1056 -0
- package/.claude/skills/list-apps-skill/SKILL.md +1010 -0
- package/.claude/skills/list-workflows-minimal-skill/SKILL.md +992 -0
- package/.claude/skills/local-first-skill/SKILL.md +570 -0
- package/.claude/skills/mcp-tools/SKILL.md +419 -0
- package/.claude/skills/mcp-tools/references/api-endpoints.md +499 -0
- package/.claude/skills/mcp-tools/references/data-structures.md +554 -0
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +717 -0
- package/.claude/skills/preview-insight-skill/SKILL.md +1290 -0
- package/.claude/skills/publish-hailer-app-skill/SKILL.md +453 -0
- package/.claude/skills/remove-app-member-skill/SKILL.md +671 -0
- package/.claude/skills/remove-app-skill/SKILL.md +985 -0
- package/.claude/skills/remove-insight-skill/SKILL.md +1011 -0
- package/.claude/skills/remove-workflow-skill/SKILL.md +920 -0
- package/.claude/skills/scaffold-hailer-app-skill/SKILL.md +1034 -0
- package/.claude/skills/skill-testing/README.md +137 -0
- package/.claude/skills/skill-testing/SKILL.md +348 -0
- package/.claude/skills/skill-testing/references/test-patterns.md +705 -0
- package/.claude/skills/skill-testing/references/testing-guide.md +603 -0
- package/.claude/skills/skill-testing/references/validation-checklist.md +537 -0
- package/.claude/skills/tool-builder/SKILL.md +328 -0
- package/.claude/skills/update-app-skill/SKILL.md +970 -0
- package/.claude/skills/update-workflow-field-skill/SKILL.md +1098 -0
- package/.env.example +81 -0
- package/.mcp.json +13 -0
- package/README.md +297 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +74 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +5 -0
- package/dist/client/adaptive-documentation-bot.d.ts +108 -0
- package/dist/client/adaptive-documentation-bot.js +475 -0
- package/dist/client/adaptive-documentation-types.d.ts +66 -0
- package/dist/client/adaptive-documentation-types.js +9 -0
- package/dist/client/agent-activity-bot.d.ts +51 -0
- package/dist/client/agent-activity-bot.js +166 -0
- package/dist/client/agent-tracker.d.ts +499 -0
- package/dist/client/agent-tracker.js +659 -0
- package/dist/client/description-updater.d.ts +56 -0
- package/dist/client/description-updater.js +259 -0
- package/dist/client/log-parser.d.ts +72 -0
- package/dist/client/log-parser.js +387 -0
- package/dist/client/mcp-client.d.ts +50 -0
- package/dist/client/mcp-client.js +532 -0
- package/dist/client/message-processor.d.ts +35 -0
- package/dist/client/message-processor.js +352 -0
- package/dist/client/multi-bot-manager.d.ts +24 -0
- package/dist/client/multi-bot-manager.js +74 -0
- package/dist/client/providers/anthropic-provider.d.ts +19 -0
- package/dist/client/providers/anthropic-provider.js +631 -0
- package/dist/client/providers/llm-provider.d.ts +47 -0
- package/dist/client/providers/llm-provider.js +367 -0
- package/dist/client/providers/openai-provider.d.ts +23 -0
- package/dist/client/providers/openai-provider.js +621 -0
- package/dist/client/simple-llm-caller.d.ts +19 -0
- package/dist/client/simple-llm-caller.js +100 -0
- package/dist/client/skill-generator.d.ts +81 -0
- package/dist/client/skill-generator.js +386 -0
- package/dist/client/test-adaptive-bot.d.ts +9 -0
- package/dist/client/test-adaptive-bot.js +82 -0
- package/dist/client/token-pricing.d.ts +38 -0
- package/dist/client/token-pricing.js +127 -0
- package/dist/client/token-tracker.d.ts +232 -0
- package/dist/client/token-tracker.js +457 -0
- package/dist/client/token-usage-bot.d.ts +53 -0
- package/dist/client/token-usage-bot.js +153 -0
- package/dist/client/tool-executor.d.ts +69 -0
- package/dist/client/tool-executor.js +159 -0
- package/dist/client/tool-schema-loader.d.ts +60 -0
- package/dist/client/tool-schema-loader.js +178 -0
- package/dist/client/types.d.ts +69 -0
- package/dist/client/types.js +7 -0
- package/dist/config.d.ts +162 -0
- package/dist/config.js +296 -0
- package/dist/core.d.ts +26 -0
- package/dist/core.js +147 -0
- package/dist/lib/context-manager.d.ts +111 -0
- package/dist/lib/context-manager.js +431 -0
- package/dist/lib/logger.d.ts +74 -0
- package/dist/lib/logger.js +277 -0
- package/dist/lib/materialize.d.ts +3 -0
- package/dist/lib/materialize.js +101 -0
- package/dist/lib/normalizedName.d.ts +7 -0
- package/dist/lib/normalizedName.js +48 -0
- package/dist/lib/prompt-length-manager.d.ts +81 -0
- package/dist/lib/prompt-length-manager.js +457 -0
- package/dist/lib/terminal-prompt.d.ts +9 -0
- package/dist/lib/terminal-prompt.js +108 -0
- package/dist/mcp/UserContextCache.d.ts +56 -0
- package/dist/mcp/UserContextCache.js +163 -0
- package/dist/mcp/auth.d.ts +2 -0
- package/dist/mcp/auth.js +29 -0
- package/dist/mcp/hailer-clients.d.ts +42 -0
- package/dist/mcp/hailer-clients.js +246 -0
- package/dist/mcp/signal-handler.d.ts +45 -0
- package/dist/mcp/signal-handler.js +317 -0
- package/dist/mcp/tool-registry.d.ts +100 -0
- package/dist/mcp/tool-registry.js +306 -0
- package/dist/mcp/tools/activity.d.ts +15 -0
- package/dist/mcp/tools/activity.js +955 -0
- package/dist/mcp/tools/app.d.ts +20 -0
- package/dist/mcp/tools/app.js +1488 -0
- package/dist/mcp/tools/discussion.d.ts +19 -0
- package/dist/mcp/tools/discussion.js +950 -0
- package/dist/mcp/tools/file.d.ts +15 -0
- package/dist/mcp/tools/file.js +119 -0
- package/dist/mcp/tools/insight.d.ts +17 -0
- package/dist/mcp/tools/insight.js +806 -0
- package/dist/mcp/tools/skill.d.ts +10 -0
- package/dist/mcp/tools/skill.js +279 -0
- package/dist/mcp/tools/user.d.ts +10 -0
- package/dist/mcp/tools/user.js +108 -0
- package/dist/mcp/tools/workflow-template.d.ts +19 -0
- package/dist/mcp/tools/workflow-template.js +822 -0
- package/dist/mcp/tools/workflow.d.ts +18 -0
- package/dist/mcp/tools/workflow.js +1362 -0
- package/dist/mcp/utils/api-errors.d.ts +45 -0
- package/dist/mcp/utils/api-errors.js +160 -0
- package/dist/mcp/utils/data-transformers.d.ts +102 -0
- package/dist/mcp/utils/data-transformers.js +194 -0
- package/dist/mcp/utils/file-upload.d.ts +33 -0
- package/dist/mcp/utils/file-upload.js +148 -0
- package/dist/mcp/utils/hailer-api-client.d.ts +120 -0
- package/dist/mcp/utils/hailer-api-client.js +323 -0
- package/dist/mcp/utils/index.d.ts +13 -0
- package/dist/mcp/utils/index.js +39 -0
- package/dist/mcp/utils/logger.d.ts +42 -0
- package/dist/mcp/utils/logger.js +103 -0
- package/dist/mcp/utils/types.d.ts +286 -0
- package/dist/mcp/utils/types.js +7 -0
- package/dist/mcp/workspace-cache.d.ts +42 -0
- package/dist/mcp/workspace-cache.js +97 -0
- package/dist/mcp-server.d.ts +42 -0
- package/dist/mcp-server.js +280 -0
- package/package.json +56 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Skill Testing
|
|
2
|
+
|
|
3
|
+
Quick reference for using the skill-testing skill system.
|
|
4
|
+
|
|
5
|
+
## What This Skill Provides
|
|
6
|
+
|
|
7
|
+
This skill helps you test, validate, and ensure quality of skills in the Hailer MCP skill-based agent system. It provides:
|
|
8
|
+
|
|
9
|
+
- **Testing Patterns**: Reusable test templates and scripts
|
|
10
|
+
- **Validation Checklists**: Comprehensive quality checks
|
|
11
|
+
- **Testing Guide**: Step-by-step testing procedures
|
|
12
|
+
- **Best Practices**: Do's and don'ts for skill testing
|
|
13
|
+
|
|
14
|
+
## When to Use This Skill
|
|
15
|
+
|
|
16
|
+
Ask the agent about skill testing when you:
|
|
17
|
+
- Create a new skill and need to test it
|
|
18
|
+
- Want to validate skill quality before deployment
|
|
19
|
+
- Need testing patterns or templates
|
|
20
|
+
- Want to benchmark skill performance
|
|
21
|
+
- Need guidance on testing best practices
|
|
22
|
+
- Want to set up automated testing
|
|
23
|
+
|
|
24
|
+
## Trigger Keywords
|
|
25
|
+
|
|
26
|
+
This skill activates when you mention:
|
|
27
|
+
- "test skill" / "test a skill"
|
|
28
|
+
- "validate skill"
|
|
29
|
+
- "skill testing"
|
|
30
|
+
- "test pattern"
|
|
31
|
+
- "benchmark"
|
|
32
|
+
- "quality check"
|
|
33
|
+
- "validation checklist"
|
|
34
|
+
- "unit test" / "integration test"
|
|
35
|
+
- "how to test"
|
|
36
|
+
|
|
37
|
+
## What You'll Get
|
|
38
|
+
|
|
39
|
+
When this skill is loaded, the agent receives:
|
|
40
|
+
- Complete testing methodology (unit, integration, E2E, performance)
|
|
41
|
+
- Copy-paste test script templates
|
|
42
|
+
- Validation checklists for pre-deployment
|
|
43
|
+
- Performance benchmarking patterns
|
|
44
|
+
- CI/CD integration examples
|
|
45
|
+
- Quality scoring matrices
|
|
46
|
+
- Troubleshooting guides
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
### Test a Single Skill
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Create quick test script
|
|
54
|
+
npx tsx test-my-skill.ts
|
|
55
|
+
|
|
56
|
+
# Or ask the agent:
|
|
57
|
+
# "How do I test my new skill called 'my-skill'?"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Test All Skills
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Run comprehensive test suite
|
|
64
|
+
npx tsx test-all-skills.ts
|
|
65
|
+
|
|
66
|
+
# Or ask the agent:
|
|
67
|
+
# "Create a script to test all skills"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Validate Before Deployment
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Run validation checks
|
|
74
|
+
npx tsx validate-skill.ts my-skill
|
|
75
|
+
|
|
76
|
+
# Or ask the agent:
|
|
77
|
+
# "What validation checks should I run before deploying my-skill?"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Files Included
|
|
81
|
+
|
|
82
|
+
### Main Skill
|
|
83
|
+
- **SKILL.md**: Overview, principles, quick start, patterns
|
|
84
|
+
|
|
85
|
+
### References
|
|
86
|
+
- **testing-guide.md**: Comprehensive step-by-step testing procedures
|
|
87
|
+
- **test-patterns.md**: Reusable test templates and scripts
|
|
88
|
+
- **validation-checklist.md**: Quality assurance checklists
|
|
89
|
+
|
|
90
|
+
## Example Usage
|
|
91
|
+
|
|
92
|
+
**User**: "I created a new skill called 'data-export'. How should I test it?"
|
|
93
|
+
|
|
94
|
+
**Agent** (with skill-testing loaded):
|
|
95
|
+
- Provides specific testing steps for the new skill
|
|
96
|
+
- Suggests test patterns for the skill's functionality
|
|
97
|
+
- Recommends validation checks
|
|
98
|
+
- Offers performance benchmarking guidance
|
|
99
|
+
- Provides copy-paste test scripts
|
|
100
|
+
|
|
101
|
+
## Integration with Development Workflow
|
|
102
|
+
|
|
103
|
+
1. **Create Skill** โ Document functionality
|
|
104
|
+
2. **Test Locally** โ Use quick test scripts
|
|
105
|
+
3. **Validate** โ Run validation checklist
|
|
106
|
+
4. **Benchmark** โ Measure performance
|
|
107
|
+
5. **Deploy** โ With confidence!
|
|
108
|
+
|
|
109
|
+
## Quality Standards
|
|
110
|
+
|
|
111
|
+
Skills should meet:
|
|
112
|
+
- โ
All automated tests pass
|
|
113
|
+
- โ
Load time < 100ms (first load)
|
|
114
|
+
- โ
Cache time < 10ms
|
|
115
|
+
- โ
Content quality score โฅ 3.5/5
|
|
116
|
+
- โ
All validation checks pass
|
|
117
|
+
|
|
118
|
+
## Getting Help
|
|
119
|
+
|
|
120
|
+
Ask the agent:
|
|
121
|
+
- "Show me test patterns for skills"
|
|
122
|
+
- "What's in the validation checklist?"
|
|
123
|
+
- "How do I benchmark skill performance?"
|
|
124
|
+
- "Create a test script for my skill"
|
|
125
|
+
- "What are the quality standards for skills?"
|
|
126
|
+
|
|
127
|
+
## Tips
|
|
128
|
+
|
|
129
|
+
- Start with quick test scripts for fast feedback
|
|
130
|
+
- Use validation checklist before every deployment
|
|
131
|
+
- Benchmark regularly to catch performance regressions
|
|
132
|
+
- Integrate tests into CI/CD pipeline
|
|
133
|
+
- Test with real user queries
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
*This skill was created using the agent-building skill patterns and is itself an example of a well-tested skill.*
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# Skill Testing
|
|
2
|
+
|
|
3
|
+
A comprehensive guide for testing skills in the Hailer MCP skill-based agent system. Provides generic, reusable patterns for validating skill content, structure, integration, and performance.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Testing skills ensures they:
|
|
8
|
+
- Load correctly from disk
|
|
9
|
+
- Match the right user requests (keyword matching works)
|
|
10
|
+
- Provide useful content to the LLM
|
|
11
|
+
- Don't break the system under various conditions
|
|
12
|
+
- Perform efficiently (caching, load times)
|
|
13
|
+
- Follow consistent structure and quality standards
|
|
14
|
+
|
|
15
|
+
## Core Testing Principles
|
|
16
|
+
|
|
17
|
+
### 1. Test Isolation
|
|
18
|
+
Each skill should be testable in isolation without dependencies on:
|
|
19
|
+
- Live MCP server
|
|
20
|
+
- External APIs
|
|
21
|
+
- Other skills
|
|
22
|
+
- Specific LLM providers
|
|
23
|
+
|
|
24
|
+
### 2. Test Coverage Levels
|
|
25
|
+
```
|
|
26
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
27
|
+
โ Unit Tests (Individual Skill) โ <- Fast, isolated
|
|
28
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
29
|
+
โ Integration Tests (Skill System) โ <- Real skill loading
|
|
30
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
31
|
+
โ E2E Tests (Full Agent Flow) โ <- Complete workflow
|
|
32
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 3. Testing Dimensions
|
|
36
|
+
|
|
37
|
+
**Functional Tests:**
|
|
38
|
+
- โ
Skill loads without errors
|
|
39
|
+
- โ
Content is valid and complete
|
|
40
|
+
- โ
References load correctly
|
|
41
|
+
- โ
Keyword matching works as expected
|
|
42
|
+
|
|
43
|
+
**Performance Tests:**
|
|
44
|
+
- โก First load time < 100ms
|
|
45
|
+
- โก Cached load time < 10ms
|
|
46
|
+
- โก Skill content size reasonable (< 100KB recommended)
|
|
47
|
+
|
|
48
|
+
**Quality Tests:**
|
|
49
|
+
- ๐ Content is clear and actionable
|
|
50
|
+
- ๐ Examples are relevant and working
|
|
51
|
+
- ๐ No broken references or links
|
|
52
|
+
- ๐ Consistent formatting and structure
|
|
53
|
+
|
|
54
|
+
**Integration Tests:**
|
|
55
|
+
- ๐ Works with SkillLoader
|
|
56
|
+
- ๐ Works with SkillManager
|
|
57
|
+
- ๐ Keyword mappings are accurate
|
|
58
|
+
- ๐ Graceful degradation on errors
|
|
59
|
+
|
|
60
|
+
## Quick Start: Testing a New Skill
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// 1. Create test file: test-my-skill.ts
|
|
64
|
+
import { SkillLoader } from './src/client/skill-loader';
|
|
65
|
+
import { SkillManager } from './src/client/skill-manager';
|
|
66
|
+
import * as path from 'path';
|
|
67
|
+
|
|
68
|
+
async function testMySkill() {
|
|
69
|
+
const loader = new SkillLoader(path.join(process.cwd(), '.claude', 'skills'));
|
|
70
|
+
const manager = new SkillManager(loader);
|
|
71
|
+
|
|
72
|
+
// Test 1: Skill loads
|
|
73
|
+
const skill = await loader.load('my-skill');
|
|
74
|
+
console.assert(skill.content.length > 0, 'Skill content should not be empty');
|
|
75
|
+
|
|
76
|
+
// Test 2: Keyword matching
|
|
77
|
+
const guidance = await manager.analyzeRequest('my skill trigger phrase');
|
|
78
|
+
console.assert(guidance.skills.includes('my-skill'), 'Should match my-skill');
|
|
79
|
+
|
|
80
|
+
// Test 3: Performance
|
|
81
|
+
const start = Date.now();
|
|
82
|
+
await loader.load('my-skill'); // Should use cache
|
|
83
|
+
const duration = Date.now() - start;
|
|
84
|
+
console.assert(duration < 10, `Cached load should be fast (${duration}ms)`);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Test File Structure
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
server/
|
|
92
|
+
โโโ tests/
|
|
93
|
+
โ โโโ skills/
|
|
94
|
+
โ โ โโโ skill-loader.test.ts # Unit tests for SkillLoader
|
|
95
|
+
โ โ โโโ skill-manager.test.ts # Unit tests for SkillManager
|
|
96
|
+
โ โ โโโ integration.test.ts # Integration tests
|
|
97
|
+
โ โ โโโ performance.test.ts # Performance benchmarks
|
|
98
|
+
โ โโโ fixtures/
|
|
99
|
+
โ โโโ test-skill/ # Mock skill for testing
|
|
100
|
+
โ โโโ SKILL.md
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Common Testing Patterns
|
|
104
|
+
|
|
105
|
+
### Pattern 1: Test Skill Loading
|
|
106
|
+
```typescript
|
|
107
|
+
describe('SkillLoader', () => {
|
|
108
|
+
it('should load skill with content', async () => {
|
|
109
|
+
const loader = new SkillLoader(skillsPath);
|
|
110
|
+
const skill = await loader.load('my-skill');
|
|
111
|
+
|
|
112
|
+
expect(skill.name).toBe('my-skill');
|
|
113
|
+
expect(skill.content).toBeTruthy();
|
|
114
|
+
expect(skill.description).toBeTruthy();
|
|
115
|
+
expect(skill.loadedAt).toBeGreaterThan(0);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Pattern 2: Test Keyword Matching
|
|
121
|
+
```typescript
|
|
122
|
+
describe('SkillManager', () => {
|
|
123
|
+
it('should match skill by keywords', async () => {
|
|
124
|
+
const manager = new SkillManager(loader);
|
|
125
|
+
const testCases = [
|
|
126
|
+
{ message: 'create a workflow', expectedSkill: 'mcp-tools' },
|
|
127
|
+
{ message: 'list activities', expectedSkill: 'hailer-api' },
|
|
128
|
+
{ message: 'build an agent', expectedSkill: 'agent-building' },
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
for (const { message, expectedSkill } of testCases) {
|
|
132
|
+
const guidance = await manager.analyzeRequest(message);
|
|
133
|
+
expect(guidance.skills).toContain(expectedSkill);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Pattern 3: Test Caching
|
|
140
|
+
```typescript
|
|
141
|
+
describe('Skill Caching', () => {
|
|
142
|
+
it('should cache skills after first load', async () => {
|
|
143
|
+
const loader = new SkillLoader(skillsPath);
|
|
144
|
+
|
|
145
|
+
// First load (from disk)
|
|
146
|
+
const start1 = Date.now();
|
|
147
|
+
await loader.load('my-skill');
|
|
148
|
+
const firstLoad = Date.now() - start1;
|
|
149
|
+
|
|
150
|
+
// Second load (from cache)
|
|
151
|
+
const start2 = Date.now();
|
|
152
|
+
await loader.load('my-skill');
|
|
153
|
+
const cachedLoad = Date.now() - start2;
|
|
154
|
+
|
|
155
|
+
expect(cachedLoad).toBeLessThan(firstLoad / 5); // At least 5x faster
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Pattern 4: Test Error Handling
|
|
161
|
+
```typescript
|
|
162
|
+
describe('Error Handling', () => {
|
|
163
|
+
it('should handle missing skills gracefully', async () => {
|
|
164
|
+
const loader = new SkillLoader(skillsPath);
|
|
165
|
+
|
|
166
|
+
await expect(
|
|
167
|
+
loader.load('non-existent-skill')
|
|
168
|
+
).rejects.toThrow(/Failed to load skill/);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('should return default guidance when no skill matches', async () => {
|
|
172
|
+
const manager = new SkillManager(loader);
|
|
173
|
+
const guidance = await manager.analyzeRequest('random gibberish xyz123');
|
|
174
|
+
|
|
175
|
+
expect(guidance.skills).toHaveLength(0);
|
|
176
|
+
expect(guidance.confidence).toBeLessThan(0.5);
|
|
177
|
+
expect(guidance.guidance).toContain('General assistance');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Testing Checklist
|
|
183
|
+
|
|
184
|
+
Before deploying a new skill, verify:
|
|
185
|
+
|
|
186
|
+
- [ ] **Structure**: SKILL.md exists and is valid markdown
|
|
187
|
+
- [ ] **Content**: Contains clear, actionable information
|
|
188
|
+
- [ ] **References**: All references/*.md files load correctly
|
|
189
|
+
- [ ] **Keywords**: Added to SkillManager.buildSkillMappings()
|
|
190
|
+
- [ ] **Loading**: Skill loads without errors
|
|
191
|
+
- [ ] **Matching**: Keywords trigger the skill correctly
|
|
192
|
+
- [ ] **Performance**: First load < 100ms, cached load < 10ms
|
|
193
|
+
- [ ] **Size**: Total content < 100KB (or justified if larger)
|
|
194
|
+
- [ ] **Examples**: All code examples are valid and tested
|
|
195
|
+
- [ ] **Tools**: Recommended tools are accurate and available
|
|
196
|
+
- [ ] **Integration**: Works with both OpenAI and Anthropic providers
|
|
197
|
+
- [ ] **Graceful Failure**: Handles errors without crashing
|
|
198
|
+
|
|
199
|
+
## Automated Testing
|
|
200
|
+
|
|
201
|
+
### Quick Test Script
|
|
202
|
+
Create `test-skill.ts` in server directory:
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { SkillLoader } from './src/client/skill-loader';
|
|
206
|
+
import { SkillManager } from './src/client/skill-manager';
|
|
207
|
+
import * as path from 'path';
|
|
208
|
+
import * as fs from 'fs/promises';
|
|
209
|
+
|
|
210
|
+
async function validateSkill(skillName: string) {
|
|
211
|
+
console.log(`\n๐งช Testing skill: ${skillName}`);
|
|
212
|
+
|
|
213
|
+
const skillsPath = path.join(process.cwd(), '..', '.claude', 'skills');
|
|
214
|
+
const loader = new SkillLoader(skillsPath);
|
|
215
|
+
const manager = new SkillManager(loader);
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
// 1. Structure validation
|
|
219
|
+
const skillPath = path.join(skillsPath, skillName);
|
|
220
|
+
const skillMdExists = await fs.stat(path.join(skillPath, 'SKILL.md'))
|
|
221
|
+
.then(() => true).catch(() => false);
|
|
222
|
+
console.log(` ${skillMdExists ? 'โ
' : 'โ'} SKILL.md exists`);
|
|
223
|
+
|
|
224
|
+
// 2. Loading test
|
|
225
|
+
const start = Date.now();
|
|
226
|
+
const skill = await loader.load(skillName);
|
|
227
|
+
const loadTime = Date.now() - start;
|
|
228
|
+
console.log(` ${loadTime < 100 ? 'โ
' : 'โ ๏ธ'} First load: ${loadTime}ms`);
|
|
229
|
+
console.log(` โ
Content loaded: ${skill.content.length} chars`);
|
|
230
|
+
|
|
231
|
+
// 3. Caching test
|
|
232
|
+
const start2 = Date.now();
|
|
233
|
+
await loader.load(skillName);
|
|
234
|
+
const cacheTime = Date.now() - start2;
|
|
235
|
+
console.log(` ${cacheTime < 10 ? 'โ
' : 'โ ๏ธ'} Cached load: ${cacheTime}ms`);
|
|
236
|
+
|
|
237
|
+
// 4. Size check
|
|
238
|
+
const sizeKB = skill.content.length / 1024;
|
|
239
|
+
console.log(` ${sizeKB < 100 ? 'โ
' : 'โ ๏ธ'} Size: ${sizeKB.toFixed(1)} KB`);
|
|
240
|
+
|
|
241
|
+
// 5. Content validation
|
|
242
|
+
const hasExamples = skill.content.includes('```');
|
|
243
|
+
const hasStructure = skill.content.includes('#');
|
|
244
|
+
console.log(` ${hasExamples ? 'โ
' : 'โ ๏ธ'} Contains code examples`);
|
|
245
|
+
console.log(` ${hasStructure ? 'โ
' : 'โ ๏ธ'} Has structured headings`);
|
|
246
|
+
|
|
247
|
+
console.log(`\nโ
${skillName} passed validation!`);
|
|
248
|
+
return true;
|
|
249
|
+
} catch (error) {
|
|
250
|
+
console.error(`\nโ ${skillName} failed:`, error);
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Test all skills
|
|
256
|
+
async function testAllSkills() {
|
|
257
|
+
const skillsPath = path.join(process.cwd(), '..', '.claude', 'skills');
|
|
258
|
+
const loader = new SkillLoader(skillsPath);
|
|
259
|
+
const allSkills = await loader.getAvailableSkills();
|
|
260
|
+
|
|
261
|
+
console.log(`Found ${allSkills.length} skills to test\n`);
|
|
262
|
+
|
|
263
|
+
const results = await Promise.all(
|
|
264
|
+
allSkills.map(skill => validateSkill(skill))
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
const passed = results.filter(r => r).length;
|
|
268
|
+
console.log(`\n${'='.repeat(50)}`);
|
|
269
|
+
console.log(`Results: ${passed}/${allSkills.length} skills passed`);
|
|
270
|
+
console.log(`${'='.repeat(50)}\n`);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
testAllSkills().catch(console.error);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Run with: `npx tsx test-skill.ts`
|
|
277
|
+
|
|
278
|
+
## Best Practices
|
|
279
|
+
|
|
280
|
+
### DO โ
|
|
281
|
+
- Write tests before creating the skill (TDD)
|
|
282
|
+
- Test both success and failure cases
|
|
283
|
+
- Validate skill content quality, not just structure
|
|
284
|
+
- Test performance with realistic data sizes
|
|
285
|
+
- Use fixtures for reproducible tests
|
|
286
|
+
- Mock external dependencies
|
|
287
|
+
- Test keyword matching with real user queries
|
|
288
|
+
- Verify graceful degradation
|
|
289
|
+
|
|
290
|
+
### DON'T โ
|
|
291
|
+
- Don't test against live APIs in unit tests
|
|
292
|
+
- Don't skip error handling tests
|
|
293
|
+
- Don't ignore performance regressions
|
|
294
|
+
- Don't forget to test cache behavior
|
|
295
|
+
- Don't assume keywords will match perfectly
|
|
296
|
+
- Don't test implementation details
|
|
297
|
+
- Don't create brittle tests that break on minor changes
|
|
298
|
+
|
|
299
|
+
## Troubleshooting
|
|
300
|
+
|
|
301
|
+
### Skill Doesn't Load
|
|
302
|
+
1. Check file path: `skills/{skill-name}/SKILL.md`
|
|
303
|
+
2. Verify file permissions
|
|
304
|
+
3. Check for syntax errors in markdown
|
|
305
|
+
4. Look at loader error logs
|
|
306
|
+
|
|
307
|
+
### Keywords Don't Match
|
|
308
|
+
1. Review keyword list in SkillManager
|
|
309
|
+
2. Test with actual user messages
|
|
310
|
+
3. Add more specific keywords
|
|
311
|
+
4. Check for typos in keyword mappings
|
|
312
|
+
|
|
313
|
+
### Performance Issues
|
|
314
|
+
1. Check skill size (should be < 100KB)
|
|
315
|
+
2. Verify caching is working
|
|
316
|
+
3. Profile with real-world queries
|
|
317
|
+
4. Consider splitting large skills
|
|
318
|
+
|
|
319
|
+
### Content Quality Issues
|
|
320
|
+
1. Have others review the content
|
|
321
|
+
2. Test with the actual LLM
|
|
322
|
+
3. Check if examples are clear
|
|
323
|
+
4. Verify technical accuracy
|
|
324
|
+
|
|
325
|
+
## Integration with CI/CD
|
|
326
|
+
|
|
327
|
+
```yaml
|
|
328
|
+
# .github/workflows/test-skills.yml
|
|
329
|
+
name: Test Skills
|
|
330
|
+
|
|
331
|
+
on: [push, pull_request]
|
|
332
|
+
|
|
333
|
+
jobs:
|
|
334
|
+
test:
|
|
335
|
+
runs-on: ubuntu-latest
|
|
336
|
+
steps:
|
|
337
|
+
- uses: actions/checkout@v3
|
|
338
|
+
- uses: actions/setup-node@v3
|
|
339
|
+
- run: npm install
|
|
340
|
+
- run: npx tsx test-skill.ts
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Further Reading
|
|
344
|
+
|
|
345
|
+
See reference files for detailed guides:
|
|
346
|
+
- `testing-guide.md` - Comprehensive testing procedures
|
|
347
|
+
- `test-patterns.md` - Reusable test patterns and templates
|
|
348
|
+
- `validation-checklist.md` - Quality assurance checklist
|