@cloudstreamsoftware/claude-tools 1.0.0 → 1.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/README.md +152 -37
- package/agents/INDEX.md +183 -0
- package/agents/architect.md +247 -0
- package/agents/build-error-resolver.md +555 -0
- package/agents/catalyst-deployer.md +132 -0
- package/agents/code-reviewer.md +121 -0
- package/agents/compliance-auditor.md +148 -0
- package/agents/creator-architect.md +395 -0
- package/agents/deluge-reviewer.md +98 -0
- package/agents/doc-updater.md +471 -0
- package/agents/e2e-runner.md +711 -0
- package/agents/planner.md +122 -0
- package/agents/refactor-cleaner.md +309 -0
- package/agents/security-reviewer.md +582 -0
- package/agents/tdd-guide.md +302 -0
- package/config/versions.json +63 -0
- package/dist/hooks/hooks.json +209 -0
- package/dist/index.js +47 -0
- package/dist/lib/asset-value.js +609 -0
- package/dist/lib/client-manager.js +300 -0
- package/dist/lib/command-matcher.js +242 -0
- package/dist/lib/cross-session-patterns.js +754 -0
- package/dist/lib/intent-classifier.js +1075 -0
- package/dist/lib/package-manager.js +374 -0
- package/dist/lib/recommendation-engine.js +597 -0
- package/dist/lib/session-memory.js +489 -0
- package/dist/lib/skill-effectiveness.js +486 -0
- package/dist/lib/skill-matcher.js +595 -0
- package/dist/lib/tutorial-metrics.js +242 -0
- package/dist/lib/tutorial-progress.js +209 -0
- package/dist/lib/tutorial-renderer.js +431 -0
- package/dist/lib/utils.js +380 -0
- package/dist/lib/verify-formatter.js +143 -0
- package/dist/lib/workflow-state.js +249 -0
- package/hooks/hooks.json +209 -0
- package/package.json +5 -1
- package/scripts/aggregate-sessions.js +290 -0
- package/scripts/branch-name-validator.js +291 -0
- package/scripts/build.js +101 -0
- package/scripts/commands/client-switch.js +231 -0
- package/scripts/deprecate-skill.js +610 -0
- package/scripts/diagnose.js +324 -0
- package/scripts/doc-freshness.js +168 -0
- package/scripts/generate-weekly-digest.js +393 -0
- package/scripts/health-check.js +270 -0
- package/scripts/hooks/credential-check.js +101 -0
- package/scripts/hooks/evaluate-session.js +81 -0
- package/scripts/hooks/pre-compact.js +66 -0
- package/scripts/hooks/prompt-analyzer.js +276 -0
- package/scripts/hooks/prompt-router.js +422 -0
- package/scripts/hooks/quality-gate-enforcer.js +371 -0
- package/scripts/hooks/session-end.js +156 -0
- package/scripts/hooks/session-start.js +195 -0
- package/scripts/hooks/skill-injector.js +333 -0
- package/scripts/hooks/suggest-compact.js +58 -0
- package/scripts/lib/asset-value.js +609 -0
- package/scripts/lib/client-manager.js +300 -0
- package/scripts/lib/command-matcher.js +242 -0
- package/scripts/lib/cross-session-patterns.js +754 -0
- package/scripts/lib/intent-classifier.js +1075 -0
- package/scripts/lib/package-manager.js +374 -0
- package/scripts/lib/recommendation-engine.js +597 -0
- package/scripts/lib/session-memory.js +489 -0
- package/scripts/lib/skill-effectiveness.js +486 -0
- package/scripts/lib/skill-matcher.js +595 -0
- package/scripts/lib/tutorial-metrics.js +242 -0
- package/scripts/lib/tutorial-progress.js +209 -0
- package/scripts/lib/tutorial-renderer.js +431 -0
- package/scripts/lib/utils.js +380 -0
- package/scripts/lib/verify-formatter.js +143 -0
- package/scripts/lib/workflow-state.js +249 -0
- package/scripts/onboard.js +363 -0
- package/scripts/quarterly-report.js +692 -0
- package/scripts/setup-package-manager.js +204 -0
- package/scripts/sync-upstream.js +391 -0
- package/scripts/test.js +108 -0
- package/scripts/tutorial-runner.js +351 -0
- package/scripts/validate-all.js +201 -0
- package/scripts/verifiers/agents.js +245 -0
- package/scripts/verifiers/config.js +186 -0
- package/scripts/verifiers/environment.js +123 -0
- package/scripts/verifiers/hooks.js +188 -0
- package/scripts/verifiers/index.js +38 -0
- package/scripts/verifiers/persistence.js +140 -0
- package/scripts/verifiers/plugin.js +215 -0
- package/scripts/verifiers/skills.js +209 -0
- package/scripts/verify-setup.js +164 -0
- package/skills/INDEX.md +157 -0
- package/skills/backend-patterns/SKILL.md +586 -0
- package/skills/backend-patterns/catalyst-patterns.md +128 -0
- package/skills/bigquery-patterns/SKILL.md +27 -0
- package/skills/bigquery-patterns/performance-optimization.md +518 -0
- package/skills/bigquery-patterns/query-patterns.md +372 -0
- package/skills/bigquery-patterns/schema-design.md +78 -0
- package/skills/cloudstream-project-template/SKILL.md +20 -0
- package/skills/cloudstream-project-template/structure.md +65 -0
- package/skills/coding-standards/SKILL.md +524 -0
- package/skills/coding-standards/deluge-standards.md +83 -0
- package/skills/compliance-patterns/SKILL.md +28 -0
- package/skills/compliance-patterns/hipaa/audit-requirements.md +251 -0
- package/skills/compliance-patterns/hipaa/baa-process.md +298 -0
- package/skills/compliance-patterns/hipaa/data-archival-strategy.md +387 -0
- package/skills/compliance-patterns/hipaa/phi-handling.md +52 -0
- package/skills/compliance-patterns/pci-dss/saq-a-requirements.md +307 -0
- package/skills/compliance-patterns/pci-dss/tokenization-patterns.md +382 -0
- package/skills/compliance-patterns/pci-dss/zoho-checkout-patterns.md +56 -0
- package/skills/compliance-patterns/soc2/access-controls.md +344 -0
- package/skills/compliance-patterns/soc2/audit-logging.md +458 -0
- package/skills/compliance-patterns/soc2/change-management.md +403 -0
- package/skills/compliance-patterns/soc2/deluge-execution-logging.md +407 -0
- package/skills/consultancy-workflows/SKILL.md +19 -0
- package/skills/consultancy-workflows/client-isolation.md +21 -0
- package/skills/consultancy-workflows/documentation-automation.md +454 -0
- package/skills/consultancy-workflows/handoff-procedures.md +257 -0
- package/skills/consultancy-workflows/knowledge-capture.md +513 -0
- package/skills/consultancy-workflows/time-tracking.md +26 -0
- package/skills/continuous-learning/SKILL.md +84 -0
- package/skills/continuous-learning/config.json +18 -0
- package/skills/continuous-learning/evaluate-session.sh +60 -0
- package/skills/continuous-learning-v2/SKILL.md +126 -0
- package/skills/continuous-learning-v2/config.json +61 -0
- package/skills/frontend-patterns/SKILL.md +635 -0
- package/skills/frontend-patterns/zoho-widget-patterns.md +103 -0
- package/skills/gcp-data-engineering/SKILL.md +36 -0
- package/skills/gcp-data-engineering/bigquery/performance-optimization.md +337 -0
- package/skills/gcp-data-engineering/dataflow/error-handling.md +496 -0
- package/skills/gcp-data-engineering/dataflow/pipeline-patterns.md +444 -0
- package/skills/gcp-data-engineering/dbt/model-organization.md +63 -0
- package/skills/gcp-data-engineering/dbt/testing-patterns.md +503 -0
- package/skills/gcp-data-engineering/medallion-architecture/bronze-layer.md +60 -0
- package/skills/gcp-data-engineering/medallion-architecture/gold-layer.md +311 -0
- package/skills/gcp-data-engineering/medallion-architecture/layer-transitions.md +517 -0
- package/skills/gcp-data-engineering/medallion-architecture/silver-layer.md +305 -0
- package/skills/gcp-data-engineering/zoho-to-gcp/data-extraction.md +543 -0
- package/skills/gcp-data-engineering/zoho-to-gcp/real-time-vs-batch.md +337 -0
- package/skills/security-review/SKILL.md +498 -0
- package/skills/security-review/compliance-checklist.md +53 -0
- package/skills/strategic-compact/SKILL.md +67 -0
- package/skills/tdd-workflow/SKILL.md +413 -0
- package/skills/tdd-workflow/zoho-testing.md +124 -0
- package/skills/tutorial/SKILL.md +249 -0
- package/skills/tutorial/docs/ACCESSIBILITY.md +169 -0
- package/skills/tutorial/lessons/00-philosophy-and-workflow.md +198 -0
- package/skills/tutorial/lessons/01-basics.md +81 -0
- package/skills/tutorial/lessons/02-training.md +86 -0
- package/skills/tutorial/lessons/03-commands.md +109 -0
- package/skills/tutorial/lessons/04-workflows.md +115 -0
- package/skills/tutorial/lessons/05-compliance.md +116 -0
- package/skills/tutorial/lessons/06-zoho.md +121 -0
- package/skills/tutorial/lessons/07-hooks-system.md +277 -0
- package/skills/tutorial/lessons/08-mcp-servers.md +316 -0
- package/skills/tutorial/lessons/09-client-management.md +215 -0
- package/skills/tutorial/lessons/10-testing-e2e.md +260 -0
- package/skills/tutorial/lessons/11-skills-deep-dive.md +272 -0
- package/skills/tutorial/lessons/12-rules-system.md +326 -0
- package/skills/tutorial/lessons/13-golden-standard-graduation.md +213 -0
- package/skills/tutorial/lessons/14-fork-setup-and-sync.md +312 -0
- package/skills/tutorial/lessons/15-living-examples-system.md +221 -0
- package/skills/tutorial/tracks/accelerated/README.md +134 -0
- package/skills/tutorial/tracks/accelerated/assessment/checkpoint-1.md +161 -0
- package/skills/tutorial/tracks/accelerated/assessment/checkpoint-2.md +175 -0
- package/skills/tutorial/tracks/accelerated/day-1-core-concepts.md +234 -0
- package/skills/tutorial/tracks/accelerated/day-2-essential-commands.md +270 -0
- package/skills/tutorial/tracks/accelerated/day-3-workflow-mastery.md +305 -0
- package/skills/tutorial/tracks/accelerated/day-4-compliance-zoho.md +304 -0
- package/skills/tutorial/tracks/accelerated/day-5-hooks-skills.md +344 -0
- package/skills/tutorial/tracks/accelerated/day-6-client-testing.md +386 -0
- package/skills/tutorial/tracks/accelerated/day-7-graduation.md +369 -0
- package/skills/zoho-patterns/CHANGELOG.md +108 -0
- package/skills/zoho-patterns/SKILL.md +446 -0
- package/skills/zoho-patterns/analytics/dashboard-patterns.md +352 -0
- package/skills/zoho-patterns/analytics/zoho-to-bigquery-pipeline.md +427 -0
- package/skills/zoho-patterns/catalyst/appsail-deployment.md +349 -0
- package/skills/zoho-patterns/catalyst/context-close-patterns.md +354 -0
- package/skills/zoho-patterns/catalyst/cron-batch-processing.md +374 -0
- package/skills/zoho-patterns/catalyst/function-patterns.md +439 -0
- package/skills/zoho-patterns/creator/form-design.md +304 -0
- package/skills/zoho-patterns/creator/publish-api-patterns.md +313 -0
- package/skills/zoho-patterns/creator/widget-integration.md +306 -0
- package/skills/zoho-patterns/creator/workflow-automation.md +253 -0
- package/skills/zoho-patterns/deluge/api-patterns.md +468 -0
- package/skills/zoho-patterns/deluge/batch-processing.md +403 -0
- package/skills/zoho-patterns/deluge/cross-app-integration.md +356 -0
- package/skills/zoho-patterns/deluge/error-handling.md +423 -0
- package/skills/zoho-patterns/deluge/syntax-reference.md +65 -0
- package/skills/zoho-patterns/integration/cors-proxy-architecture.md +426 -0
- package/skills/zoho-patterns/integration/crm-books-native-sync.md +277 -0
- package/skills/zoho-patterns/integration/oauth-token-management.md +461 -0
- package/skills/zoho-patterns/integration/zoho-flow-patterns.md +334 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Matcher - Context-Aware Skill Matching Engine
|
|
3
|
+
*
|
|
4
|
+
* Matches current task context to relevant skills from:
|
|
5
|
+
* 1. Built-in skills (skills/ directory)
|
|
6
|
+
* 2. Learned skills (~/.claude/skills/learned/)
|
|
7
|
+
* 3. Session-specific effective patterns
|
|
8
|
+
*
|
|
9
|
+
* Used by skill-injector hook to auto-apply relevant knowledge.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { getLearnedSkillsDir, ensureDir, readFile } = require('./utils');
|
|
15
|
+
|
|
16
|
+
// Skill directories
|
|
17
|
+
const PLUGIN_ROOT = path.join(__dirname, '..', '..');
|
|
18
|
+
const BUILTIN_SKILLS_DIR = path.join(PLUGIN_ROOT, 'skills');
|
|
19
|
+
const LEARNED_SKILLS_DIR = getLearnedSkillsDir();
|
|
20
|
+
const VERSIONS_FILE = path.join(PLUGIN_ROOT, 'config', 'versions.json');
|
|
21
|
+
|
|
22
|
+
// Confidence threshold for matching
|
|
23
|
+
const CONFIDENCE_THRESHOLD = 0.5;
|
|
24
|
+
|
|
25
|
+
// Cache for version registry
|
|
26
|
+
let versionRegistryCache = null;
|
|
27
|
+
let versionRegistryCacheTime = 0;
|
|
28
|
+
const VERSION_CACHE_TTL = 60000; // 1 minute
|
|
29
|
+
|
|
30
|
+
// Maximum skills to return
|
|
31
|
+
const MAX_MATCHED_SKILLS = 3;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Skill activation patterns
|
|
35
|
+
* Maps skill names to trigger patterns
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Load version registry from config
|
|
39
|
+
* Cached for performance
|
|
40
|
+
*/
|
|
41
|
+
function loadVersionRegistry() {
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
|
|
44
|
+
// Return cached if still valid
|
|
45
|
+
if (versionRegistryCache && now - versionRegistryCacheTime < VERSION_CACHE_TTL) {
|
|
46
|
+
return versionRegistryCache;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
if (fs.existsSync(VERSIONS_FILE)) {
|
|
51
|
+
const content = fs.readFileSync(VERSIONS_FILE, 'utf8');
|
|
52
|
+
versionRegistryCache = JSON.parse(content);
|
|
53
|
+
versionRegistryCacheTime = now;
|
|
54
|
+
return versionRegistryCache;
|
|
55
|
+
}
|
|
56
|
+
} catch (err) {
|
|
57
|
+
// Ignore parse errors
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { skills: {}, agents: {} };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get deprecation info for a skill
|
|
65
|
+
* @param {string} skillName - Name of the skill
|
|
66
|
+
* @returns {object|null} - Deprecation info or null if not deprecated
|
|
67
|
+
*/
|
|
68
|
+
function getDeprecationInfo(skillName) {
|
|
69
|
+
const registry = loadVersionRegistry();
|
|
70
|
+
const skillInfo = registry.skills?.[skillName];
|
|
71
|
+
|
|
72
|
+
if (!skillInfo) return null;
|
|
73
|
+
|
|
74
|
+
if (skillInfo.status === 'deprecated' || skillInfo.deprecationInfo) {
|
|
75
|
+
return {
|
|
76
|
+
deprecated: true,
|
|
77
|
+
version: skillInfo.version || '0.0.0',
|
|
78
|
+
status: skillInfo.status,
|
|
79
|
+
deprecatedIn: skillInfo.deprecationInfo?.deprecatedIn || skillInfo.deprecatedIn,
|
|
80
|
+
supersededBy: skillInfo.deprecationInfo?.supersededBy || skillInfo.supersededBy,
|
|
81
|
+
migrationGuide: skillInfo.deprecationInfo?.migrationGuide || skillInfo.migrationGuide,
|
|
82
|
+
removalTarget: skillInfo.deprecationInfo?.removalTarget || skillInfo.removalTarget,
|
|
83
|
+
reason: skillInfo.deprecationInfo?.reason,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get version info for a skill
|
|
92
|
+
* @param {string} skillName - Name of the skill
|
|
93
|
+
* @returns {object} - Version info
|
|
94
|
+
*/
|
|
95
|
+
function getSkillVersionInfo(skillName) {
|
|
96
|
+
const registry = loadVersionRegistry();
|
|
97
|
+
const skillInfo = registry.skills?.[skillName];
|
|
98
|
+
|
|
99
|
+
if (!skillInfo) {
|
|
100
|
+
return { version: '1.0.0', status: 'active' };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
version: skillInfo.version || '1.0.0',
|
|
105
|
+
status: skillInfo.status || 'active',
|
|
106
|
+
introduced: skillInfo.introduced,
|
|
107
|
+
lastUpdated: skillInfo.lastUpdated,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Skill activation patterns
|
|
113
|
+
* Maps skill names to trigger patterns
|
|
114
|
+
*/
|
|
115
|
+
const SKILL_TRIGGERS = {
|
|
116
|
+
// Platform skills
|
|
117
|
+
'zoho-patterns': {
|
|
118
|
+
patterns: [/zoho/i, /creator/i, /catalyst/i, /deluge/i, /crm/i, /books/i, /analytics/i],
|
|
119
|
+
filePatterns: [/\.ds$/],
|
|
120
|
+
priority: 3,
|
|
121
|
+
},
|
|
122
|
+
'gcp-data-engineering': {
|
|
123
|
+
patterns: [
|
|
124
|
+
/bigquery/i,
|
|
125
|
+
/dataflow/i,
|
|
126
|
+
/gcp/i,
|
|
127
|
+
/google cloud/i,
|
|
128
|
+
/medallion/i,
|
|
129
|
+
/bronze|silver|gold/i,
|
|
130
|
+
],
|
|
131
|
+
filePatterns: [/\.sql$/, /dbt/],
|
|
132
|
+
priority: 2,
|
|
133
|
+
},
|
|
134
|
+
'bigquery-patterns': {
|
|
135
|
+
patterns: [/bigquery/i, /bq\b/i, /partition/i, /cluster/i, /query optim/i],
|
|
136
|
+
filePatterns: [/\.sql$/],
|
|
137
|
+
priority: 2,
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
// Compliance skills
|
|
141
|
+
'compliance-patterns': {
|
|
142
|
+
patterns: [/hipaa/i, /soc2/i, /pci/i, /compliance/i, /audit/i, /phi\b/i, /ephi/i],
|
|
143
|
+
complianceModes: ['hipaa', 'soc2', 'pci-dss'],
|
|
144
|
+
priority: 4,
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
// Development workflow skills
|
|
148
|
+
'tdd-workflow': {
|
|
149
|
+
patterns: [/test/i, /tdd/i, /coverage/i, /jest/i, /vitest/i, /mocha/i],
|
|
150
|
+
filePatterns: [/\.test\.(ts|tsx|js|jsx)$/, /\.spec\.(ts|tsx|js|jsx)$/],
|
|
151
|
+
priority: 2,
|
|
152
|
+
},
|
|
153
|
+
'security-review': {
|
|
154
|
+
patterns: [/security/i, /auth/i, /password/i, /credential/i, /owasp/i, /xss/i, /injection/i],
|
|
155
|
+
priority: 3,
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// Frontend skills
|
|
159
|
+
'frontend-patterns': {
|
|
160
|
+
patterns: [/react/i, /component/i, /hook/i, /state/i, /redux/i, /context/i],
|
|
161
|
+
filePatterns: [/\.(tsx|jsx)$/],
|
|
162
|
+
priority: 2,
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// Backend skills
|
|
166
|
+
'backend-patterns': {
|
|
167
|
+
patterns: [/api/i, /endpoint/i, /server/i, /express/i, /node/i, /rest/i],
|
|
168
|
+
filePatterns: [/server|api|route/i],
|
|
169
|
+
priority: 2,
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
// Standards skills
|
|
173
|
+
'coding-standards': {
|
|
174
|
+
patterns: [/standard/i, /convention/i, /style/i, /lint/i, /format/i],
|
|
175
|
+
priority: 1,
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
// Consultancy skills
|
|
179
|
+
'consultancy-workflows': {
|
|
180
|
+
patterns: [/client/i, /handoff/i, /billing/i, /time track/i, /documentation/i],
|
|
181
|
+
priority: 1,
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
// System/utility skills
|
|
185
|
+
'cloudstream-project-template': {
|
|
186
|
+
patterns: [/project template/i, /scaffold/i, /new project/i, /client setup/i, /project structure/i],
|
|
187
|
+
priority: 1,
|
|
188
|
+
},
|
|
189
|
+
'continuous-learning': {
|
|
190
|
+
patterns: [/learn/i, /pattern/i, /extract/i, /capture/i, /reusable/i],
|
|
191
|
+
priority: 1,
|
|
192
|
+
},
|
|
193
|
+
'continuous-learning-v2': {
|
|
194
|
+
patterns: [/instinct/i, /evolve/i, /homunculus/i, /observation/i],
|
|
195
|
+
priority: 1,
|
|
196
|
+
},
|
|
197
|
+
'strategic-compact': {
|
|
198
|
+
patterns: [/compact/i, /context window/i, /token/i, /summarize context/i],
|
|
199
|
+
priority: 1,
|
|
200
|
+
},
|
|
201
|
+
'tutorial': {
|
|
202
|
+
patterns: [/tutorial/i, /lesson/i, /onboard/i, /learn system/i, /getting started/i],
|
|
203
|
+
priority: 1,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Build context from file path and content
|
|
209
|
+
*/
|
|
210
|
+
function buildContext(filePath, content = '', additionalContext = {}) {
|
|
211
|
+
const context = {
|
|
212
|
+
filePath: filePath || '',
|
|
213
|
+
fileExtension: filePath ? path.extname(filePath) : '',
|
|
214
|
+
fileName: filePath ? path.basename(filePath) : '',
|
|
215
|
+
directory: filePath ? path.dirname(filePath) : '',
|
|
216
|
+
content: content || '',
|
|
217
|
+
technologies: new Set(),
|
|
218
|
+
complianceMode: additionalContext.complianceMode || null,
|
|
219
|
+
keywords: new Set(),
|
|
220
|
+
...additionalContext,
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// Extract technologies from file path
|
|
224
|
+
if (/\.ds$/.test(filePath)) context.technologies.add('deluge');
|
|
225
|
+
if (/\.(ts|tsx)$/.test(filePath)) context.technologies.add('typescript');
|
|
226
|
+
if (/\.(js|jsx)$/.test(filePath)) context.technologies.add('javascript');
|
|
227
|
+
if (/\.sql$/.test(filePath)) context.technologies.add('sql');
|
|
228
|
+
if (/\.py$/.test(filePath)) context.technologies.add('python');
|
|
229
|
+
|
|
230
|
+
// Extract technologies from directory path
|
|
231
|
+
if (/catalyst/i.test(filePath)) context.technologies.add('catalyst');
|
|
232
|
+
if (/creator/i.test(filePath)) context.technologies.add('creator');
|
|
233
|
+
if (/zoho/i.test(filePath)) context.technologies.add('zoho');
|
|
234
|
+
if (/bigquery|bq/i.test(filePath)) context.technologies.add('bigquery');
|
|
235
|
+
|
|
236
|
+
// Extract keywords from content
|
|
237
|
+
if (content) {
|
|
238
|
+
const contentSample = content.substring(0, 2000); // First 2000 chars
|
|
239
|
+
|
|
240
|
+
// Technology keywords
|
|
241
|
+
if (/invokeurl/i.test(contentSample)) context.technologies.add('zoho');
|
|
242
|
+
if (/zoho\./i.test(contentSample)) context.technologies.add('zoho');
|
|
243
|
+
if (/BigQuery|BIGQUERY/i.test(contentSample)) context.technologies.add('bigquery');
|
|
244
|
+
if (/useState|useEffect|React/i.test(contentSample)) context.technologies.add('react');
|
|
245
|
+
if (/express|app\.(get|post|put|delete)/i.test(contentSample))
|
|
246
|
+
context.technologies.add('express');
|
|
247
|
+
|
|
248
|
+
// Compliance keywords
|
|
249
|
+
if (/hipaa|phi|patient/i.test(contentSample))
|
|
250
|
+
context.complianceMode = context.complianceMode || 'hipaa';
|
|
251
|
+
if (/audit.*log|soc2/i.test(contentSample))
|
|
252
|
+
context.complianceMode = context.complianceMode || 'soc2';
|
|
253
|
+
if (/payment|card|pci/i.test(contentSample))
|
|
254
|
+
context.complianceMode = context.complianceMode || 'pci-dss';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return context;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Calculate match score for a skill against context
|
|
262
|
+
*/
|
|
263
|
+
function calculateMatchScore(skillName, skillConfig, context) {
|
|
264
|
+
let score = 0;
|
|
265
|
+
let matchReasons = [];
|
|
266
|
+
|
|
267
|
+
// Check pattern matches
|
|
268
|
+
if (skillConfig.patterns) {
|
|
269
|
+
for (const pattern of skillConfig.patterns) {
|
|
270
|
+
// Check against file path
|
|
271
|
+
if (pattern.test(context.filePath)) {
|
|
272
|
+
score += 0.3;
|
|
273
|
+
matchReasons.push(`path:${pattern}`);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Check against content
|
|
277
|
+
if (pattern.test(context.content)) {
|
|
278
|
+
score += 0.4;
|
|
279
|
+
matchReasons.push(`content:${pattern}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Check against technologies
|
|
283
|
+
for (const tech of context.technologies) {
|
|
284
|
+
if (pattern.test(tech)) {
|
|
285
|
+
score += 0.3;
|
|
286
|
+
matchReasons.push(`tech:${tech}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Check file pattern matches
|
|
293
|
+
if (skillConfig.filePatterns) {
|
|
294
|
+
for (const pattern of skillConfig.filePatterns) {
|
|
295
|
+
if (pattern.test(context.filePath)) {
|
|
296
|
+
score += 0.5;
|
|
297
|
+
matchReasons.push(`file:${pattern}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Check compliance mode match
|
|
303
|
+
if (skillConfig.complianceModes && context.complianceMode) {
|
|
304
|
+
if (skillConfig.complianceModes.includes(context.complianceMode)) {
|
|
305
|
+
score += 0.6;
|
|
306
|
+
matchReasons.push(`compliance:${context.complianceMode}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Apply priority weight
|
|
311
|
+
const priority = skillConfig.priority || 1;
|
|
312
|
+
score *= priority;
|
|
313
|
+
|
|
314
|
+
// Normalize score to 0-1 range
|
|
315
|
+
const normalizedScore = Math.min(score / 3, 1);
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
skill: skillName,
|
|
319
|
+
score: normalizedScore,
|
|
320
|
+
reasons: matchReasons,
|
|
321
|
+
priority,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Load learned skills from disk
|
|
327
|
+
*/
|
|
328
|
+
function loadLearnedSkills() {
|
|
329
|
+
ensureDir(LEARNED_SKILLS_DIR);
|
|
330
|
+
|
|
331
|
+
const skills = [];
|
|
332
|
+
|
|
333
|
+
try {
|
|
334
|
+
const files = fs.readdirSync(LEARNED_SKILLS_DIR);
|
|
335
|
+
|
|
336
|
+
for (const file of files) {
|
|
337
|
+
if (!file.endsWith('.md')) continue;
|
|
338
|
+
|
|
339
|
+
const filePath = path.join(LEARNED_SKILLS_DIR, file);
|
|
340
|
+
const content = readFile(filePath);
|
|
341
|
+
|
|
342
|
+
if (!content) continue;
|
|
343
|
+
|
|
344
|
+
// Extract metadata from frontmatter
|
|
345
|
+
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
346
|
+
let metadata = {};
|
|
347
|
+
|
|
348
|
+
if (frontmatterMatch) {
|
|
349
|
+
// Simple YAML-like parsing
|
|
350
|
+
const lines = frontmatterMatch[1].split('\n');
|
|
351
|
+
for (const line of lines) {
|
|
352
|
+
const [key, ...valueParts] = line.split(':');
|
|
353
|
+
if (key && valueParts.length) {
|
|
354
|
+
metadata[key.trim()] = valueParts
|
|
355
|
+
.join(':')
|
|
356
|
+
.trim()
|
|
357
|
+
.replace(/^["']|["']$/g, '');
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
skills.push({
|
|
363
|
+
name: file.replace('.md', ''),
|
|
364
|
+
path: filePath,
|
|
365
|
+
content: content.substring(0, 500), // Preview
|
|
366
|
+
metadata,
|
|
367
|
+
type: 'learned',
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
} catch (err) {
|
|
371
|
+
// Ignore errors
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return skills;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Load builtin skill summaries
|
|
379
|
+
*/
|
|
380
|
+
function loadBuiltinSkillSummaries() {
|
|
381
|
+
const skills = [];
|
|
382
|
+
|
|
383
|
+
try {
|
|
384
|
+
const skillDirs = fs
|
|
385
|
+
.readdirSync(BUILTIN_SKILLS_DIR, { withFileTypes: true })
|
|
386
|
+
.filter((d) => d.isDirectory())
|
|
387
|
+
.map((d) => d.name);
|
|
388
|
+
|
|
389
|
+
for (const skillName of skillDirs) {
|
|
390
|
+
const skillPath = path.join(BUILTIN_SKILLS_DIR, skillName, 'SKILL.md');
|
|
391
|
+
|
|
392
|
+
if (!fs.existsSync(skillPath)) continue;
|
|
393
|
+
|
|
394
|
+
const content = readFile(skillPath);
|
|
395
|
+
if (!content) continue;
|
|
396
|
+
|
|
397
|
+
// Extract description from frontmatter
|
|
398
|
+
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
399
|
+
let description = '';
|
|
400
|
+
|
|
401
|
+
if (frontmatterMatch) {
|
|
402
|
+
const descMatch = frontmatterMatch[1].match(/description:\s*(.+)/);
|
|
403
|
+
if (descMatch) {
|
|
404
|
+
description = descMatch[1].trim();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
skills.push({
|
|
409
|
+
name: skillName,
|
|
410
|
+
path: skillPath,
|
|
411
|
+
description,
|
|
412
|
+
type: 'builtin',
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
} catch (err) {
|
|
416
|
+
// Ignore errors
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return skills;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Match skills to context
|
|
424
|
+
* @param {object} context - Context from buildContext
|
|
425
|
+
* @returns {array} Matched skills sorted by relevance
|
|
426
|
+
*/
|
|
427
|
+
function matchSkills(context) {
|
|
428
|
+
const matches = [];
|
|
429
|
+
|
|
430
|
+
// Match against builtin skill triggers
|
|
431
|
+
for (const [skillName, skillConfig] of Object.entries(SKILL_TRIGGERS)) {
|
|
432
|
+
const match = calculateMatchScore(skillName, skillConfig, context);
|
|
433
|
+
|
|
434
|
+
if (match.score >= CONFIDENCE_THRESHOLD) {
|
|
435
|
+
match.type = 'builtin';
|
|
436
|
+
match.path = path.join(BUILTIN_SKILLS_DIR, skillName, 'SKILL.md');
|
|
437
|
+
|
|
438
|
+
// Add version and deprecation info
|
|
439
|
+
const versionInfo = getSkillVersionInfo(skillName);
|
|
440
|
+
match.version = versionInfo.version;
|
|
441
|
+
match.status = versionInfo.status;
|
|
442
|
+
match.deprecation = getDeprecationInfo(skillName);
|
|
443
|
+
|
|
444
|
+
matches.push(match);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Match against learned skills (simpler matching)
|
|
449
|
+
const learnedSkills = loadLearnedSkills();
|
|
450
|
+
|
|
451
|
+
for (const learned of learnedSkills) {
|
|
452
|
+
let score = 0;
|
|
453
|
+
const reasons = [];
|
|
454
|
+
|
|
455
|
+
// Check if any technology in context matches skill metadata
|
|
456
|
+
if (learned.metadata.activation) {
|
|
457
|
+
const activationKeywords = learned.metadata.activation.split(',').map((s) => s.trim());
|
|
458
|
+
|
|
459
|
+
for (const keyword of activationKeywords) {
|
|
460
|
+
const regex = new RegExp(keyword, 'i');
|
|
461
|
+
|
|
462
|
+
if (regex.test(context.filePath)) {
|
|
463
|
+
score += 0.4;
|
|
464
|
+
reasons.push(`learned:path:${keyword}`);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (regex.test(context.content)) {
|
|
468
|
+
score += 0.5;
|
|
469
|
+
reasons.push(`learned:content:${keyword}`);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
for (const tech of context.technologies) {
|
|
473
|
+
if (regex.test(tech)) {
|
|
474
|
+
score += 0.3;
|
|
475
|
+
reasons.push(`learned:tech:${tech}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Check skill name against context
|
|
482
|
+
const nameRegex = new RegExp(learned.name.replace(/-/g, '[ -]'), 'i');
|
|
483
|
+
if (nameRegex.test(context.content)) {
|
|
484
|
+
score += 0.3;
|
|
485
|
+
reasons.push('learned:name-match');
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (score >= CONFIDENCE_THRESHOLD) {
|
|
489
|
+
// Learned skills can also be in version registry
|
|
490
|
+
const versionInfo = getSkillVersionInfo(learned.name);
|
|
491
|
+
|
|
492
|
+
matches.push({
|
|
493
|
+
skill: learned.name,
|
|
494
|
+
score,
|
|
495
|
+
reasons,
|
|
496
|
+
type: 'learned',
|
|
497
|
+
path: learned.path,
|
|
498
|
+
priority: 2,
|
|
499
|
+
version: learned.metadata.version || versionInfo.version,
|
|
500
|
+
status: learned.metadata.status || versionInfo.status,
|
|
501
|
+
deprecation: getDeprecationInfo(learned.name),
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Sort by score (descending)
|
|
507
|
+
matches.sort((a, b) => b.score - a.score);
|
|
508
|
+
|
|
509
|
+
// Return top matches
|
|
510
|
+
return matches.slice(0, MAX_MATCHED_SKILLS);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Get skill content for injection
|
|
515
|
+
*/
|
|
516
|
+
function getSkillContent(skillMatch) {
|
|
517
|
+
if (!skillMatch.path || !fs.existsSync(skillMatch.path)) {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const content = readFile(skillMatch.path);
|
|
522
|
+
if (!content) return null;
|
|
523
|
+
|
|
524
|
+
// Remove frontmatter for injection
|
|
525
|
+
const cleaned = content.replace(/^---\n[\s\S]*?\n---\n*/, '');
|
|
526
|
+
|
|
527
|
+
// Truncate if too long (for context efficiency)
|
|
528
|
+
const MAX_SKILL_LENGTH = 2000;
|
|
529
|
+
if (cleaned.length > MAX_SKILL_LENGTH) {
|
|
530
|
+
return cleaned.substring(0, MAX_SKILL_LENGTH) + '\n\n[... truncated for context efficiency]';
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return cleaned;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Format matched skills for injection
|
|
538
|
+
*/
|
|
539
|
+
function formatMatchedSkills(matches) {
|
|
540
|
+
if (matches.length === 0) return null;
|
|
541
|
+
|
|
542
|
+
let output = '[Skill Match] Relevant skills detected:\n';
|
|
543
|
+
|
|
544
|
+
for (const match of matches) {
|
|
545
|
+
output += ` - ${match.skill} (${Math.round(match.score * 100)}% match, ${match.type})\n`;
|
|
546
|
+
output += ` Reasons: ${match.reasons.slice(0, 3).join(', ')}\n`;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return output;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Get matched skills with content for full injection
|
|
554
|
+
*/
|
|
555
|
+
function getMatchedSkillsWithContent(context) {
|
|
556
|
+
const matches = matchSkills(context);
|
|
557
|
+
|
|
558
|
+
return matches
|
|
559
|
+
.map((match) => ({
|
|
560
|
+
...match,
|
|
561
|
+
content: getSkillContent(match),
|
|
562
|
+
}))
|
|
563
|
+
.filter((m) => m.content !== null);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
module.exports = {
|
|
567
|
+
// Core functions
|
|
568
|
+
buildContext,
|
|
569
|
+
matchSkills,
|
|
570
|
+
calculateMatchScore,
|
|
571
|
+
|
|
572
|
+
// Version and deprecation
|
|
573
|
+
loadVersionRegistry,
|
|
574
|
+
getDeprecationInfo,
|
|
575
|
+
getSkillVersionInfo,
|
|
576
|
+
|
|
577
|
+
// Content retrieval
|
|
578
|
+
getSkillContent,
|
|
579
|
+
getMatchedSkillsWithContent,
|
|
580
|
+
|
|
581
|
+
// Formatting
|
|
582
|
+
formatMatchedSkills,
|
|
583
|
+
|
|
584
|
+
// Skill loading
|
|
585
|
+
loadLearnedSkills,
|
|
586
|
+
loadBuiltinSkillSummaries,
|
|
587
|
+
|
|
588
|
+
// Configuration
|
|
589
|
+
SKILL_TRIGGERS,
|
|
590
|
+
CONFIDENCE_THRESHOLD,
|
|
591
|
+
MAX_MATCHED_SKILLS,
|
|
592
|
+
BUILTIN_SKILLS_DIR,
|
|
593
|
+
LEARNED_SKILLS_DIR,
|
|
594
|
+
VERSIONS_FILE,
|
|
595
|
+
};
|