specweave 0.3.13 → 0.4.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.md +506 -17
- package/README.md +100 -58
- package/bin/install-all.sh +9 -2
- package/bin/install-hooks.sh +57 -0
- package/bin/specweave.js +16 -0
- package/dist/adapters/adapter-base.d.ts +21 -0
- package/dist/adapters/adapter-base.d.ts.map +1 -1
- package/dist/adapters/adapter-base.js +28 -0
- package/dist/adapters/adapter-base.js.map +1 -1
- package/dist/adapters/adapter-interface.d.ts +41 -0
- package/dist/adapters/adapter-interface.d.ts.map +1 -1
- package/dist/adapters/claude/adapter.d.ts +36 -0
- package/dist/adapters/claude/adapter.d.ts.map +1 -1
- package/dist/adapters/claude/adapter.js +135 -0
- package/dist/adapters/claude/adapter.js.map +1 -1
- package/dist/adapters/copilot/adapter.d.ts +25 -0
- package/dist/adapters/copilot/adapter.d.ts.map +1 -1
- package/dist/adapters/copilot/adapter.js +112 -0
- package/dist/adapters/copilot/adapter.js.map +1 -1
- package/dist/adapters/cursor/adapter.d.ts +36 -0
- package/dist/adapters/cursor/adapter.d.ts.map +1 -1
- package/dist/adapters/cursor/adapter.js +140 -0
- package/dist/adapters/cursor/adapter.js.map +1 -1
- package/dist/adapters/generic/adapter.d.ts +25 -0
- package/dist/adapters/generic/adapter.d.ts.map +1 -1
- package/dist/adapters/generic/adapter.js +111 -0
- package/dist/adapters/generic/adapter.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +103 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/plugin.d.ts +37 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +296 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/core/agent-model-manager.d.ts +52 -0
- package/dist/core/agent-model-manager.d.ts.map +1 -0
- package/dist/core/agent-model-manager.js +120 -0
- package/dist/core/agent-model-manager.js.map +1 -0
- package/dist/core/cost-tracker.d.ts +108 -0
- package/dist/core/cost-tracker.d.ts.map +1 -0
- package/dist/core/cost-tracker.js +281 -0
- package/dist/core/cost-tracker.js.map +1 -0
- package/dist/core/model-selector.d.ts +57 -0
- package/dist/core/model-selector.d.ts.map +1 -0
- package/dist/core/model-selector.js +115 -0
- package/dist/core/model-selector.js.map +1 -0
- package/dist/core/phase-detector.d.ts +62 -0
- package/dist/core/phase-detector.d.ts.map +1 -0
- package/dist/core/phase-detector.js +229 -0
- package/dist/core/phase-detector.js.map +1 -0
- package/dist/core/plugin-detector.d.ts +96 -0
- package/dist/core/plugin-detector.d.ts.map +1 -0
- package/dist/core/plugin-detector.js +349 -0
- package/dist/core/plugin-detector.js.map +1 -0
- package/dist/core/plugin-loader.d.ts +111 -0
- package/dist/core/plugin-loader.d.ts.map +1 -0
- package/dist/core/plugin-loader.js +319 -0
- package/dist/core/plugin-loader.js.map +1 -0
- package/dist/core/plugin-manager.d.ts +144 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +393 -0
- package/dist/core/plugin-manager.js.map +1 -0
- package/dist/core/schemas/plugin-manifest.schema.json +253 -0
- package/dist/core/types/plugin.d.ts +252 -0
- package/dist/core/types/plugin.d.ts.map +1 -0
- package/dist/core/types/plugin.js +48 -0
- package/dist/core/types/plugin.js.map +1 -0
- package/dist/integrations/jira/jira-mapper.d.ts +2 -2
- package/dist/integrations/jira/jira-mapper.js +2 -2
- package/dist/types/cost-tracking.d.ts +43 -0
- package/dist/types/cost-tracking.d.ts.map +1 -0
- package/dist/types/cost-tracking.js +8 -0
- package/dist/types/cost-tracking.js.map +1 -0
- package/dist/types/model-selection.d.ts +53 -0
- package/dist/types/model-selection.d.ts.map +1 -0
- package/dist/types/model-selection.js +12 -0
- package/dist/types/model-selection.js.map +1 -0
- package/dist/utils/cost-reporter.d.ts +58 -0
- package/dist/utils/cost-reporter.d.ts.map +1 -0
- package/dist/utils/cost-reporter.js +224 -0
- package/dist/utils/cost-reporter.js.map +1 -0
- package/dist/utils/pricing-constants.d.ts +70 -0
- package/dist/utils/pricing-constants.d.ts.map +1 -0
- package/dist/utils/pricing-constants.js +71 -0
- package/dist/utils/pricing-constants.js.map +1 -0
- package/package.json +13 -9
- package/src/adapters/adapter-base.ts +33 -0
- package/src/adapters/adapter-interface.ts +46 -0
- package/src/adapters/claude/adapter.ts +164 -0
- package/src/adapters/copilot/adapter.ts +138 -0
- package/src/adapters/cursor/adapter.ts +170 -0
- package/src/adapters/generic/adapter.ts +137 -0
- package/src/agents/architect/AGENT.md +3 -0
- package/src/agents/code-reviewer.md +156 -0
- package/src/agents/data-scientist/AGENT.md +181 -0
- package/src/agents/database-optimizer/AGENT.md +147 -0
- package/src/agents/devops/AGENT.md +3 -0
- package/src/agents/diagrams-architect/AGENT.md +3 -0
- package/src/agents/docs-writer/AGENT.md +3 -0
- package/src/agents/kubernetes-architect/AGENT.md +142 -0
- package/src/agents/ml-engineer/AGENT.md +150 -0
- package/src/agents/mlops-engineer/AGENT.md +201 -0
- package/src/agents/network-engineer/AGENT.md +149 -0
- package/src/agents/observability-engineer/AGENT.md +213 -0
- package/src/agents/payment-integration/AGENT.md +35 -0
- package/src/agents/performance/AGENT.md +3 -0
- package/src/agents/performance-engineer/AGENT.md +153 -0
- package/src/agents/pm/AGENT.md +3 -0
- package/src/agents/qa-lead/AGENT.md +3 -0
- package/src/agents/security/AGENT.md +3 -0
- package/src/agents/sre/AGENT.md +3 -0
- package/src/agents/tdd-orchestrator/AGENT.md +169 -0
- package/src/agents/tech-lead/AGENT.md +3 -0
- package/src/commands/specweave.costs.md +261 -0
- package/src/commands/specweave.increment.md +48 -4
- package/src/commands/specweave.ml-pipeline.md +292 -0
- package/src/commands/specweave.monitor-setup.md +501 -0
- package/src/commands/specweave.slo-implement.md +1055 -0
- package/src/commands/specweave.sync-github.md +1 -1
- package/src/commands/specweave.tdd-cycle.md +199 -0
- package/src/commands/specweave.tdd-green.md +842 -0
- package/src/commands/specweave.tdd-red.md +135 -0
- package/src/commands/specweave.tdd-refactor.md +165 -0
- package/src/hooks/post-increment-plugin-detect.sh +142 -0
- package/src/hooks/post-task-completion.sh +53 -11
- package/src/hooks/pre-task-plugin-detect.sh +96 -0
- package/src/skills/SKILLS-INDEX.md +18 -10
- package/src/skills/billing-automation/SKILL.md +559 -0
- package/src/skills/distributed-tracing/SKILL.md +438 -0
- package/src/skills/e2e-playwright/README.md +1 -1
- package/src/skills/e2e-playwright/package.json +1 -1
- package/src/skills/gitops-workflow/SKILL.md +285 -0
- package/src/skills/gitops-workflow/references/argocd-setup.md +134 -0
- package/src/skills/gitops-workflow/references/sync-policies.md +131 -0
- package/src/skills/grafana-dashboards/SKILL.md +369 -0
- package/src/skills/helm-chart-scaffolding/SKILL.md +544 -0
- package/src/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/src/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/src/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/src/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/src/skills/k8s-manifest-generator/SKILL.md +511 -0
- package/src/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
- package/src/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
- package/src/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
- package/src/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
- package/src/skills/k8s-manifest-generator/references/service-spec.md +724 -0
- package/src/skills/k8s-security-policies/SKILL.md +334 -0
- package/src/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
- package/src/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
- package/src/skills/ml-pipeline-workflow/SKILL.md +245 -0
- package/src/skills/paypal-integration/SKILL.md +467 -0
- package/src/skills/pci-compliance/SKILL.md +466 -0
- package/src/skills/prometheus-configuration/SKILL.md +392 -0
- package/src/skills/slo-implementation/SKILL.md +329 -0
- package/src/skills/stripe-integration/SKILL.md +442 -0
- package/src/skills/tdd-workflow/SKILL.md +378 -0
- package/src/templates/README.md.template +1 -1
- package/src/skills/bmad-method-expert/SKILL.md +0 -626
- package/src/skills/bmad-method-expert/scripts/analyze-project.js +0 -318
- package/src/skills/bmad-method-expert/scripts/check-setup.js +0 -208
- package/src/skills/bmad-method-expert/scripts/generate-template.js +0 -1149
- package/src/skills/bmad-method-expert/scripts/validate-documents.js +0 -340
- package/src/skills/context-optimizer/SKILL.md +0 -588
- package/src/skills/figma-designer/SKILL.md +0 -149
- package/src/skills/figma-implementer/SKILL.md +0 -148
- package/src/skills/figma-mcp-connector/SKILL.md +0 -136
- package/src/skills/figma-to-code/SKILL.md +0 -128
- package/src/skills/spec-kit-expert/SKILL.md +0 -1010
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Detector
|
|
3
|
+
*
|
|
4
|
+
* Automatically detects which plugins should be enabled based on:
|
|
5
|
+
* 1. Project structure (package.json, directories, env vars, git remote)
|
|
6
|
+
* 2. Spec content (keywords, domain analysis)
|
|
7
|
+
* 3. Task descriptions (pre-task hook)
|
|
8
|
+
* 4. Git changes (post-increment hook)
|
|
9
|
+
*
|
|
10
|
+
* @module core/plugin-detector
|
|
11
|
+
* @version 0.4.0
|
|
12
|
+
*/
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import * as fs from 'fs-extra';
|
|
15
|
+
import { PluginLoader } from './plugin-loader.js';
|
|
16
|
+
/**
|
|
17
|
+
* PluginDetector - Auto-detects relevant plugins for a project
|
|
18
|
+
*/
|
|
19
|
+
export class PluginDetector {
|
|
20
|
+
/**
|
|
21
|
+
* Create a new PluginDetector
|
|
22
|
+
*
|
|
23
|
+
* @param pluginsDir - Path to plugins directory (default: src/plugins)
|
|
24
|
+
*/
|
|
25
|
+
constructor(pluginsDir) {
|
|
26
|
+
this.availablePlugins = [];
|
|
27
|
+
this.loader = new PluginLoader();
|
|
28
|
+
this.pluginsDir = pluginsDir || path.join(process.cwd(), 'src', 'plugins');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load available plugins for detection
|
|
32
|
+
*
|
|
33
|
+
* Scans plugins directory and loads all plugin manifests
|
|
34
|
+
*/
|
|
35
|
+
async loadAvailablePlugins() {
|
|
36
|
+
this.availablePlugins = [];
|
|
37
|
+
if (!(await fs.pathExists(this.pluginsDir))) {
|
|
38
|
+
return; // No plugins available
|
|
39
|
+
}
|
|
40
|
+
const dirs = await fs.readdir(this.pluginsDir);
|
|
41
|
+
for (const dir of dirs) {
|
|
42
|
+
const pluginPath = path.join(this.pluginsDir, dir);
|
|
43
|
+
const stat = await fs.stat(pluginPath);
|
|
44
|
+
if (stat.isDirectory()) {
|
|
45
|
+
try {
|
|
46
|
+
const plugin = await this.loader.loadFromDirectory(pluginPath);
|
|
47
|
+
this.availablePlugins.push(plugin);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.warn(`⚠️ Failed to load plugin ${dir}: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Phase 1: Init-time detection
|
|
57
|
+
*
|
|
58
|
+
* Detects plugins based on project structure during `specweave init`
|
|
59
|
+
*
|
|
60
|
+
* @param projectPath - Path to project root
|
|
61
|
+
* @returns Array of detection results with confidence scores
|
|
62
|
+
*/
|
|
63
|
+
async detectFromProject(projectPath) {
|
|
64
|
+
const results = [];
|
|
65
|
+
// Ensure plugins are loaded
|
|
66
|
+
if (this.availablePlugins.length === 0) {
|
|
67
|
+
await this.loadAvailablePlugins();
|
|
68
|
+
}
|
|
69
|
+
// Check each plugin's auto_detect rules
|
|
70
|
+
for (const plugin of this.availablePlugins) {
|
|
71
|
+
const { auto_detect } = plugin.manifest;
|
|
72
|
+
if (!auto_detect)
|
|
73
|
+
continue;
|
|
74
|
+
let confidence = 0;
|
|
75
|
+
const reasons = [];
|
|
76
|
+
// Check files/directories
|
|
77
|
+
if (auto_detect.files) {
|
|
78
|
+
for (const pattern of auto_detect.files) {
|
|
79
|
+
const filePath = path.join(projectPath, pattern);
|
|
80
|
+
if (await fs.pathExists(filePath)) {
|
|
81
|
+
confidence += 0.3;
|
|
82
|
+
reasons.push(`Found ${pattern}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Check package.json dependencies
|
|
87
|
+
if (auto_detect.packages) {
|
|
88
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
89
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
90
|
+
const packageJson = await fs.readJSON(packageJsonPath);
|
|
91
|
+
const allDeps = {
|
|
92
|
+
...packageJson.dependencies,
|
|
93
|
+
...packageJson.devDependencies
|
|
94
|
+
};
|
|
95
|
+
for (const pkg of auto_detect.packages) {
|
|
96
|
+
if (allDeps[pkg]) {
|
|
97
|
+
confidence += 0.25;
|
|
98
|
+
reasons.push(`Uses ${pkg}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Check environment variables
|
|
104
|
+
if (auto_detect.env_vars) {
|
|
105
|
+
for (const envVar of auto_detect.env_vars) {
|
|
106
|
+
if (process.env[envVar]) {
|
|
107
|
+
confidence += 0.2;
|
|
108
|
+
reasons.push(`Env var ${envVar} set`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Check git remote pattern
|
|
113
|
+
if (auto_detect.git_remote_pattern) {
|
|
114
|
+
const gitConfigPath = path.join(projectPath, '.git', 'config');
|
|
115
|
+
if (await fs.pathExists(gitConfigPath)) {
|
|
116
|
+
const gitConfig = await fs.readFile(gitConfigPath, 'utf-8');
|
|
117
|
+
const regex = new RegExp(auto_detect.git_remote_pattern);
|
|
118
|
+
if (regex.test(gitConfig)) {
|
|
119
|
+
confidence += 0.25;
|
|
120
|
+
reasons.push(`Git remote matches ${auto_detect.git_remote_pattern}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Add to results if confidence > 0
|
|
125
|
+
if (confidence > 0) {
|
|
126
|
+
results.push({
|
|
127
|
+
pluginName: plugin.manifest.name,
|
|
128
|
+
confidence: Math.min(confidence, 1.0), // Cap at 1.0
|
|
129
|
+
reason: reasons.join(', '),
|
|
130
|
+
trigger: 'project-structure'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Sort by confidence (highest first)
|
|
135
|
+
return results.sort((a, b) => b.confidence - a.confidence);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Phase 2: Spec-based detection
|
|
139
|
+
*
|
|
140
|
+
* Detects plugins based on increment spec content during `/specweave.inc`
|
|
141
|
+
*
|
|
142
|
+
* @param specContent - Content of spec.md
|
|
143
|
+
* @returns Array of detection results
|
|
144
|
+
*/
|
|
145
|
+
async detectFromSpec(specContent) {
|
|
146
|
+
const results = [];
|
|
147
|
+
// Ensure plugins are loaded
|
|
148
|
+
if (this.availablePlugins.length === 0) {
|
|
149
|
+
await this.loadAvailablePlugins();
|
|
150
|
+
}
|
|
151
|
+
const normalizedContent = specContent.toLowerCase();
|
|
152
|
+
// Check each plugin's trigger keywords
|
|
153
|
+
for (const plugin of this.availablePlugins) {
|
|
154
|
+
const { triggers } = plugin.manifest;
|
|
155
|
+
if (!triggers || triggers.length === 0)
|
|
156
|
+
continue;
|
|
157
|
+
let matchCount = 0;
|
|
158
|
+
const matchedTriggers = [];
|
|
159
|
+
for (const trigger of triggers) {
|
|
160
|
+
const regex = new RegExp(`\\b${trigger.toLowerCase()}\\b`, 'gi');
|
|
161
|
+
const matches = normalizedContent.match(regex);
|
|
162
|
+
if (matches) {
|
|
163
|
+
matchCount += matches.length;
|
|
164
|
+
matchedTriggers.push(trigger);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (matchCount > 0) {
|
|
168
|
+
// Confidence based on frequency (capped at 1.0)
|
|
169
|
+
const confidence = Math.min(matchCount * 0.1, 1.0);
|
|
170
|
+
results.push({
|
|
171
|
+
pluginName: plugin.manifest.name,
|
|
172
|
+
confidence,
|
|
173
|
+
reason: `Spec mentions: ${matchedTriggers.join(', ')}`,
|
|
174
|
+
trigger: 'spec-keywords'
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Sort by confidence
|
|
179
|
+
return results.sort((a, b) => b.confidence - a.confidence);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Phase 3: Task-based detection
|
|
183
|
+
*
|
|
184
|
+
* Detects plugins based on task description (pre-task hook)
|
|
185
|
+
*
|
|
186
|
+
* @param taskContent - Content of task description
|
|
187
|
+
* @returns Array of detection results
|
|
188
|
+
*/
|
|
189
|
+
async detectFromTask(taskContent) {
|
|
190
|
+
const results = [];
|
|
191
|
+
// Ensure plugins are loaded
|
|
192
|
+
if (this.availablePlugins.length === 0) {
|
|
193
|
+
await this.loadAvailablePlugins();
|
|
194
|
+
}
|
|
195
|
+
const normalizedContent = taskContent.toLowerCase();
|
|
196
|
+
// Check each plugin's trigger keywords
|
|
197
|
+
for (const plugin of this.availablePlugins) {
|
|
198
|
+
const { triggers } = plugin.manifest;
|
|
199
|
+
if (!triggers || triggers.length === 0)
|
|
200
|
+
continue;
|
|
201
|
+
const matchedTriggers = [];
|
|
202
|
+
for (const trigger of triggers) {
|
|
203
|
+
const regex = new RegExp(`\\b${trigger.toLowerCase()}\\b`, 'i');
|
|
204
|
+
if (regex.test(normalizedContent)) {
|
|
205
|
+
matchedTriggers.push(trigger);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (matchedTriggers.length > 0) {
|
|
209
|
+
// Task-based detection has moderate confidence
|
|
210
|
+
const confidence = 0.6;
|
|
211
|
+
results.push({
|
|
212
|
+
pluginName: plugin.manifest.name,
|
|
213
|
+
confidence,
|
|
214
|
+
reason: `Task mentions: ${matchedTriggers.join(', ')}`,
|
|
215
|
+
trigger: 'task-keywords'
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Sort by confidence
|
|
220
|
+
return results.sort((a, b) => b.confidence - a.confidence);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Phase 4: Git diff detection
|
|
224
|
+
*
|
|
225
|
+
* Detects plugins based on recent git changes (post-increment hook)
|
|
226
|
+
*
|
|
227
|
+
* @param diff - Git diff output
|
|
228
|
+
* @returns Array of detection results
|
|
229
|
+
*/
|
|
230
|
+
async detectFromChanges(diff) {
|
|
231
|
+
const results = [];
|
|
232
|
+
// Ensure plugins are loaded
|
|
233
|
+
if (this.availablePlugins.length === 0) {
|
|
234
|
+
await this.loadAvailablePlugins();
|
|
235
|
+
}
|
|
236
|
+
const normalizedDiff = diff.toLowerCase();
|
|
237
|
+
// Check for new file patterns
|
|
238
|
+
for (const plugin of this.availablePlugins) {
|
|
239
|
+
const { auto_detect } = plugin.manifest;
|
|
240
|
+
if (!auto_detect?.files)
|
|
241
|
+
continue;
|
|
242
|
+
const matchedFiles = [];
|
|
243
|
+
for (const pattern of auto_detect.files) {
|
|
244
|
+
// Check if diff contains new files matching pattern
|
|
245
|
+
const regex = new RegExp(`\\+\\+\\+.*${pattern}`, 'i');
|
|
246
|
+
if (regex.test(normalizedDiff)) {
|
|
247
|
+
matchedFiles.push(pattern);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (matchedFiles.length > 0) {
|
|
251
|
+
results.push({
|
|
252
|
+
pluginName: plugin.manifest.name,
|
|
253
|
+
confidence: 0.7,
|
|
254
|
+
reason: `Added files: ${matchedFiles.join(', ')}`,
|
|
255
|
+
trigger: 'git-changes'
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Check for new package.json dependencies
|
|
260
|
+
const packageJsonMatch = diff.match(/\+\+\+ b\/package\.json([\s\S]+?)(?=\+\+\+|$)/);
|
|
261
|
+
if (packageJsonMatch) {
|
|
262
|
+
const addedLines = packageJsonMatch[1]
|
|
263
|
+
.split('\n')
|
|
264
|
+
.filter(line => line.startsWith('+') && !line.startsWith('+++'));
|
|
265
|
+
for (const plugin of this.availablePlugins) {
|
|
266
|
+
const { auto_detect } = plugin.manifest;
|
|
267
|
+
if (!auto_detect?.packages)
|
|
268
|
+
continue;
|
|
269
|
+
const matchedPackages = [];
|
|
270
|
+
for (const pkg of auto_detect.packages) {
|
|
271
|
+
if (addedLines.some(line => line.includes(`"${pkg}"`))) {
|
|
272
|
+
matchedPackages.push(pkg);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (matchedPackages.length > 0) {
|
|
276
|
+
results.push({
|
|
277
|
+
pluginName: plugin.manifest.name,
|
|
278
|
+
confidence: 0.8,
|
|
279
|
+
reason: `Added dependencies: ${matchedPackages.join(', ')}`,
|
|
280
|
+
trigger: 'package-json-changes'
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// Sort by confidence
|
|
286
|
+
return results.sort((a, b) => b.confidence - a.confidence);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Combine detection results from multiple sources
|
|
290
|
+
*
|
|
291
|
+
* Merges results and adjusts confidence scores
|
|
292
|
+
*
|
|
293
|
+
* @param results - Array of detection result arrays
|
|
294
|
+
* @returns Merged and deduplicated results
|
|
295
|
+
*/
|
|
296
|
+
combineResults(...results) {
|
|
297
|
+
const combined = new Map();
|
|
298
|
+
for (const resultArray of results) {
|
|
299
|
+
for (const result of resultArray) {
|
|
300
|
+
const existing = combined.get(result.pluginName);
|
|
301
|
+
if (existing) {
|
|
302
|
+
// Boost confidence if detected from multiple sources
|
|
303
|
+
existing.confidence = Math.min(existing.confidence + result.confidence * 0.3, 1.0);
|
|
304
|
+
existing.reason += `; ${result.reason}`;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
combined.set(result.pluginName, { ...result });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// Convert to array and sort
|
|
312
|
+
return Array.from(combined.values()).sort((a, b) => b.confidence - a.confidence);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get high-confidence suggestions
|
|
316
|
+
*
|
|
317
|
+
* Filters detection results by confidence threshold
|
|
318
|
+
*
|
|
319
|
+
* @param results - Detection results
|
|
320
|
+
* @param threshold - Minimum confidence (default: 0.6)
|
|
321
|
+
* @returns High-confidence plugin suggestions
|
|
322
|
+
*/
|
|
323
|
+
getHighConfidenceSuggestions(results, threshold = 0.6) {
|
|
324
|
+
return results
|
|
325
|
+
.filter(r => r.confidence >= threshold)
|
|
326
|
+
.map(r => r.pluginName);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Format detection results for display
|
|
330
|
+
*
|
|
331
|
+
* @param results - Detection results
|
|
332
|
+
* @returns Formatted string for CLI output
|
|
333
|
+
*/
|
|
334
|
+
formatResults(results) {
|
|
335
|
+
if (results.length === 0) {
|
|
336
|
+
return 'No plugins detected for this project.';
|
|
337
|
+
}
|
|
338
|
+
let output = '\n📦 Detected plugins:\n\n';
|
|
339
|
+
for (const result of results) {
|
|
340
|
+
const confidenceBar = '█'.repeat(Math.floor(result.confidence * 10));
|
|
341
|
+
const confidencePercent = Math.floor(result.confidence * 100);
|
|
342
|
+
output += ` ${result.pluginName}\n`;
|
|
343
|
+
output += ` Confidence: ${confidenceBar} ${confidencePercent}%\n`;
|
|
344
|
+
output += ` Reason: ${result.reason}\n\n`;
|
|
345
|
+
}
|
|
346
|
+
return output;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=plugin-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-detector.js","sourceRoot":"","sources":["../../src/core/plugin-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,IAAI,MAA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IAAI,CAAC;YACrC,MAAM,IAAI,mBAAmB,aAAa,IAAI,iBAAiB,KAAK,CAAC;YACrE,MAAM,IAAI,eAAe,MAAM,CAAC,MAAM,MAAM,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Loader
|
|
3
|
+
*
|
|
4
|
+
* Reads plugin directories, validates manifests, and loads skills/agents/commands.
|
|
5
|
+
* Provides plugin discovery and integrity checking.
|
|
6
|
+
*
|
|
7
|
+
* @module core/plugin-loader
|
|
8
|
+
* @version 0.4.0
|
|
9
|
+
*/
|
|
10
|
+
import type { Plugin, PluginManifest, ValidationResult } from './types/plugin.js';
|
|
11
|
+
/**
|
|
12
|
+
* PluginLoader - Loads and validates plugins from filesystem
|
|
13
|
+
*/
|
|
14
|
+
export declare class PluginLoader {
|
|
15
|
+
private ajv;
|
|
16
|
+
private validateManifestSchema;
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Load a plugin from directory
|
|
20
|
+
*
|
|
21
|
+
* @param pluginPath - Absolute path to plugin directory
|
|
22
|
+
* @returns Loaded plugin with all components
|
|
23
|
+
* @throws PluginNotFoundError if directory doesn't exist
|
|
24
|
+
* @throws ManifestValidationError if manifest is invalid
|
|
25
|
+
*/
|
|
26
|
+
loadFromDirectory(pluginPath: string): Promise<Plugin>;
|
|
27
|
+
/**
|
|
28
|
+
* Load plugin manifest from .claude-plugin/manifest.json
|
|
29
|
+
*
|
|
30
|
+
* @param pluginPath - Path to plugin directory
|
|
31
|
+
* @returns Validated plugin manifest
|
|
32
|
+
* @throws ManifestValidationError if manifest is invalid
|
|
33
|
+
*/
|
|
34
|
+
loadManifest(pluginPath: string): Promise<PluginManifest>;
|
|
35
|
+
/**
|
|
36
|
+
* Validate manifest against JSON schema
|
|
37
|
+
*
|
|
38
|
+
* @param manifest - Manifest object to validate
|
|
39
|
+
* @returns Validation result with errors/warnings
|
|
40
|
+
*/
|
|
41
|
+
validateManifest(manifest: any): ValidationResult;
|
|
42
|
+
/**
|
|
43
|
+
* Load skills from plugin
|
|
44
|
+
*
|
|
45
|
+
* @param pluginPath - Path to plugin directory
|
|
46
|
+
* @param skillNames - Skill names from manifest
|
|
47
|
+
* @returns Array of loaded skills
|
|
48
|
+
*/
|
|
49
|
+
private loadSkills;
|
|
50
|
+
/**
|
|
51
|
+
* Load agents from plugin
|
|
52
|
+
*
|
|
53
|
+
* @param pluginPath - Path to plugin directory
|
|
54
|
+
* @param agentNames - Agent names from manifest
|
|
55
|
+
* @returns Array of loaded agents
|
|
56
|
+
*/
|
|
57
|
+
private loadAgents;
|
|
58
|
+
/**
|
|
59
|
+
* Load commands from plugin
|
|
60
|
+
*
|
|
61
|
+
* @param pluginPath - Path to plugin directory
|
|
62
|
+
* @param commandNames - Command names from manifest
|
|
63
|
+
* @returns Array of loaded commands
|
|
64
|
+
*/
|
|
65
|
+
private loadCommands;
|
|
66
|
+
/**
|
|
67
|
+
* Load test cases from skill directory
|
|
68
|
+
*
|
|
69
|
+
* @param skillPath - Path to skill directory
|
|
70
|
+
* @returns Array of test cases
|
|
71
|
+
*/
|
|
72
|
+
private loadTestCases;
|
|
73
|
+
/**
|
|
74
|
+
* Extract description from SKILL.md or AGENT.md frontmatter
|
|
75
|
+
*
|
|
76
|
+
* @param content - File content
|
|
77
|
+
* @returns Extracted description
|
|
78
|
+
*/
|
|
79
|
+
private extractDescription;
|
|
80
|
+
/**
|
|
81
|
+
* Extract capabilities from agent content
|
|
82
|
+
*
|
|
83
|
+
* @param content - Agent file content
|
|
84
|
+
* @returns Array of capability strings
|
|
85
|
+
*/
|
|
86
|
+
private extractCapabilities;
|
|
87
|
+
/**
|
|
88
|
+
* Verify plugin integrity
|
|
89
|
+
*
|
|
90
|
+
* Checks that all declared skills/agents/commands exist
|
|
91
|
+
*
|
|
92
|
+
* @param plugin - Plugin to verify
|
|
93
|
+
* @returns True if plugin is intact
|
|
94
|
+
*/
|
|
95
|
+
verifyPlugin(plugin: Plugin): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* Get plugin metadata (lightweight, without loading full plugin)
|
|
98
|
+
*
|
|
99
|
+
* @param pluginPath - Path to plugin directory
|
|
100
|
+
* @returns Plugin metadata
|
|
101
|
+
*/
|
|
102
|
+
getMetadata(pluginPath: string): Promise<{
|
|
103
|
+
name: string;
|
|
104
|
+
version: string;
|
|
105
|
+
description: string;
|
|
106
|
+
skillCount: number;
|
|
107
|
+
agentCount: number;
|
|
108
|
+
commandCount: number;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=plugin-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../../src/core/plugin-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EAKd,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAS3B;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,sBAAsB,CAAM;;IAQpC;;;;;;;OAOG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyB5D;;;;;;OAMG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAkC/D;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB;IAyBjD;;;;;;OAMG;YACW,UAAU;IA6BxB;;;;;;OAMG;YACW,UAAU;IA2BxB;;;;;;OAMG;YACW,YAAY;IA2B1B;;;;;OAKG;YACW,aAAa;IA2B3B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;;;;;;OAOG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBpD;;;;;OAKG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7C,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CAYH"}
|