@claude-flow/cli 3.0.0-alpha.2 → 3.0.0-alpha.21
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 +172 -6
- package/bin/cli.js +0 -0
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +43 -27
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.d.ts +19 -0
- package/dist/src/commands/analyze.d.ts.map +1 -0
- package/dist/src/commands/analyze.js +1823 -0
- package/dist/src/commands/analyze.js.map +1 -0
- package/dist/src/commands/claims.d.ts +10 -0
- package/dist/src/commands/claims.d.ts.map +1 -0
- package/dist/src/commands/claims.js +288 -0
- package/dist/src/commands/claims.js.map +1 -0
- package/dist/src/commands/completions.d.ts +10 -0
- package/dist/src/commands/completions.d.ts.map +1 -0
- package/dist/src/commands/completions.js +539 -0
- package/dist/src/commands/completions.js.map +1 -0
- package/dist/src/commands/config.js +2 -2
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts +8 -0
- package/dist/src/commands/daemon.d.ts.map +1 -0
- package/dist/src/commands/daemon.js +545 -0
- package/dist/src/commands/daemon.js.map +1 -0
- package/dist/src/commands/deployment.d.ts +10 -0
- package/dist/src/commands/deployment.d.ts.map +1 -0
- package/dist/src/commands/deployment.js +289 -0
- package/dist/src/commands/deployment.js.map +1 -0
- package/dist/src/commands/doctor.d.ts +10 -0
- package/dist/src/commands/doctor.d.ts.map +1 -0
- package/dist/src/commands/doctor.js +429 -0
- package/dist/src/commands/doctor.js.map +1 -0
- package/dist/src/commands/embeddings.d.ts +18 -0
- package/dist/src/commands/embeddings.d.ts.map +1 -0
- package/dist/src/commands/embeddings.js +616 -0
- package/dist/src/commands/embeddings.js.map +1 -0
- package/dist/src/commands/hive-mind.d.ts.map +1 -1
- package/dist/src/commands/hive-mind.js +252 -35
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +326 -2
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +13 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +52 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp.js +4 -4
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +236 -170
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +1 -1
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.d.ts +10 -0
- package/dist/src/commands/neural.d.ts.map +1 -0
- package/dist/src/commands/neural.js +224 -0
- package/dist/src/commands/neural.js.map +1 -0
- package/dist/src/commands/performance.d.ts +10 -0
- package/dist/src/commands/performance.d.ts.map +1 -0
- package/dist/src/commands/performance.js +262 -0
- package/dist/src/commands/performance.js.map +1 -0
- package/dist/src/commands/plugins.d.ts +10 -0
- package/dist/src/commands/plugins.d.ts.map +1 -0
- package/dist/src/commands/plugins.js +280 -0
- package/dist/src/commands/plugins.js.map +1 -0
- package/dist/src/commands/process.d.ts.map +1 -1
- package/dist/src/commands/process.js +95 -20
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/providers.d.ts +10 -0
- package/dist/src/commands/providers.d.ts.map +1 -0
- package/dist/src/commands/providers.js +232 -0
- package/dist/src/commands/providers.js.map +1 -0
- package/dist/src/commands/route.d.ts +16 -0
- package/dist/src/commands/route.d.ts.map +1 -0
- package/dist/src/commands/route.js +603 -0
- package/dist/src/commands/route.js.map +1 -0
- package/dist/src/commands/security.d.ts +10 -0
- package/dist/src/commands/security.d.ts.map +1 -0
- package/dist/src/commands/security.js +261 -0
- package/dist/src/commands/security.js.map +1 -0
- package/dist/src/commands/start.js +2 -2
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +26 -2
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +6 -6
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +63 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +218 -362
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +5 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +22 -12
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +17 -1
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +5 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +350 -14
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +317 -0
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -0
- package/dist/src/mcp-tools/config-tools.d.ts +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +262 -15
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +80 -15
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +6 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +6 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +157 -9
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.d.ts +8 -0
- package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/session-tools.js +315 -0
- package/dist/src/mcp-tools/session-tools.js.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +37 -2
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts +8 -0
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/task-tools.js +302 -0
- package/dist/src/mcp-tools/task-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.js +481 -0
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
- package/dist/src/output.d.ts +16 -0
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +42 -0
- package/dist/src/output.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +277 -0
- package/dist/src/ruvector/ast-analyzer.js.map +1 -0
- package/dist/src/ruvector/coverage-router.d.ts +145 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +451 -0
- package/dist/src/ruvector/coverage-router.js.map +1 -0
- package/dist/src/ruvector/coverage-tools.d.ts +33 -0
- package/dist/src/ruvector/coverage-tools.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-tools.js +157 -0
- package/dist/src/ruvector/coverage-tools.js.map +1 -0
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +662 -0
- package/dist/src/ruvector/diff-classifier.js.map +1 -0
- package/dist/src/ruvector/graph-analyzer.d.ts +174 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +878 -0
- package/dist/src/ruvector/graph-analyzer.js.map +1 -0
- package/dist/src/ruvector/index.d.ts +27 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +49 -0
- package/dist/src/ruvector/index.js.map +1 -0
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +681 -0
- package/dist/src/ruvector/q-learning-router.js.map +1 -0
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +243 -0
- package/dist/src/ruvector/vector-db.js.map +1 -0
- package/dist/src/services/index.d.ts +7 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +6 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/worker-daemon.d.ts +153 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +567 -0
- package/dist/src/services/worker-daemon.js.map +1 -0
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +200 -0
- package/dist/src/suggest.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -6
- package/.agentic-flow/intelligence.json +0 -16
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -87
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/__tests__/README.md +0 -140
- package/__tests__/TEST_SUMMARY.md +0 -144
- package/__tests__/cli.test.ts +0 -558
- package/__tests__/commands.test.ts +0 -726
- package/__tests__/config-adapter.test.ts +0 -362
- package/__tests__/config-loading.test.ts +0 -106
- package/__tests__/coverage/.tmp/coverage-0.json +0 -1
- package/__tests__/coverage/.tmp/coverage-1.json +0 -1
- package/__tests__/coverage/.tmp/coverage-2.json +0 -1
- package/__tests__/coverage/.tmp/coverage-3.json +0 -1
- package/__tests__/coverage/.tmp/coverage-4.json +0 -1
- package/__tests__/coverage/.tmp/coverage-5.json +0 -1
- package/__tests__/mcp-client.test.ts +0 -480
- package/__tests__/p1-commands.test.ts +0 -1064
- package/docs/CONFIG_LOADING.md +0 -236
- package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
- package/docs/MCP_CLIENT_GUIDE.md +0 -620
- package/docs/REFACTORING_SUMMARY.md +0 -247
- package/src/commands/agent.ts +0 -941
- package/src/commands/config.ts +0 -452
- package/src/commands/hive-mind.ts +0 -762
- package/src/commands/hooks.ts +0 -2603
- package/src/commands/index.ts +0 -115
- package/src/commands/init.ts +0 -597
- package/src/commands/mcp.ts +0 -753
- package/src/commands/memory.ts +0 -1063
- package/src/commands/migrate.ts +0 -447
- package/src/commands/process.ts +0 -617
- package/src/commands/session.ts +0 -891
- package/src/commands/start.ts +0 -457
- package/src/commands/status.ts +0 -705
- package/src/commands/swarm.ts +0 -648
- package/src/commands/task.ts +0 -792
- package/src/commands/workflow.ts +0 -742
- package/src/config-adapter.ts +0 -210
- package/src/index.ts +0 -383
- package/src/infrastructure/in-memory-repositories.ts +0 -310
- package/src/init/claudemd-generator.ts +0 -631
- package/src/init/executor.ts +0 -756
- package/src/init/helpers-generator.ts +0 -628
- package/src/init/index.ts +0 -60
- package/src/init/mcp-generator.ts +0 -83
- package/src/init/settings-generator.ts +0 -274
- package/src/init/statusline-generator.ts +0 -211
- package/src/init/types.ts +0 -447
- package/src/mcp-client.ts +0 -227
- package/src/mcp-server.ts +0 -571
- package/src/mcp-tools/agent-tools.ts +0 -92
- package/src/mcp-tools/config-tools.ts +0 -88
- package/src/mcp-tools/hooks-tools.ts +0 -1819
- package/src/mcp-tools/index.ts +0 -12
- package/src/mcp-tools/memory-tools.ts +0 -89
- package/src/mcp-tools/swarm-tools.ts +0 -69
- package/src/mcp-tools/types.ts +0 -33
- package/src/output.ts +0 -593
- package/src/parser.ts +0 -417
- package/src/prompt.ts +0 -619
- package/src/types.ts +0 -287
- package/tmp.json +0 -0
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -13
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analyze MCP Tools
|
|
3
|
+
* Provides diff analysis and classification via MCP protocol
|
|
4
|
+
*/
|
|
5
|
+
import { analyzeDiff, assessFileRisk, assessOverallRisk, classifyDiff, suggestReviewers, getGitDiffNumstat, } from '../ruvector/diff-classifier.js';
|
|
6
|
+
/**
|
|
7
|
+
* Diff Analysis Tool
|
|
8
|
+
* Analyzes git diffs for change risk assessment and classification
|
|
9
|
+
*/
|
|
10
|
+
export const analyzeDiffTool = {
|
|
11
|
+
name: 'analyze/diff',
|
|
12
|
+
description: 'Analyze git diff for change risk assessment and classification',
|
|
13
|
+
category: 'analyze',
|
|
14
|
+
tags: ['diff', 'risk', 'classification', 'git'],
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
ref: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'Git ref to compare against (e.g., HEAD~1, main..feature, commit hash)',
|
|
21
|
+
default: 'HEAD',
|
|
22
|
+
},
|
|
23
|
+
includeFileRisks: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
description: 'Include detailed file-level risk analysis',
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
includeReviewers: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Include recommended reviewers',
|
|
31
|
+
default: true,
|
|
32
|
+
},
|
|
33
|
+
useRuVector: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Attempt to use ruvector for analysis (graceful fallback if unavailable)',
|
|
36
|
+
default: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
handler: async (params) => {
|
|
41
|
+
const ref = params.ref || 'HEAD';
|
|
42
|
+
const includeFileRisks = params.includeFileRisks !== false;
|
|
43
|
+
const includeReviewers = params.includeReviewers !== false;
|
|
44
|
+
const useRuVector = params.useRuVector !== false;
|
|
45
|
+
try {
|
|
46
|
+
const result = await analyzeDiff({
|
|
47
|
+
ref,
|
|
48
|
+
useRuVector,
|
|
49
|
+
});
|
|
50
|
+
// Build response
|
|
51
|
+
const response = {
|
|
52
|
+
ref: result.ref,
|
|
53
|
+
timestamp: result.timestamp,
|
|
54
|
+
files: result.files,
|
|
55
|
+
risk: result.risk,
|
|
56
|
+
classification: result.classification,
|
|
57
|
+
summary: result.summary,
|
|
58
|
+
};
|
|
59
|
+
if (includeFileRisks) {
|
|
60
|
+
response.fileRisks = result.fileRisks;
|
|
61
|
+
}
|
|
62
|
+
if (includeReviewers) {
|
|
63
|
+
response.recommendedReviewers = result.recommendedReviewers;
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return {
|
|
69
|
+
error: true,
|
|
70
|
+
message: error instanceof Error ? error.message : String(error),
|
|
71
|
+
ref,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Diff Risk Assessment Tool
|
|
78
|
+
* Focused risk assessment without full analysis
|
|
79
|
+
*/
|
|
80
|
+
export const diffRiskTool = {
|
|
81
|
+
name: 'analyze/diff-risk',
|
|
82
|
+
description: 'Quick risk assessment for git diff',
|
|
83
|
+
category: 'analyze',
|
|
84
|
+
tags: ['diff', 'risk', 'git'],
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
ref: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'Git ref to compare against',
|
|
91
|
+
default: 'HEAD',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
handler: async (params) => {
|
|
96
|
+
const ref = params.ref || 'HEAD';
|
|
97
|
+
try {
|
|
98
|
+
const files = getGitDiffNumstat(ref);
|
|
99
|
+
const fileRisks = files.map(assessFileRisk);
|
|
100
|
+
const risk = assessOverallRisk(files, fileRisks);
|
|
101
|
+
return {
|
|
102
|
+
ref,
|
|
103
|
+
risk,
|
|
104
|
+
summary: `${risk.overall} risk (score: ${risk.score}/100) - ${files.length} files changed`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return {
|
|
109
|
+
error: true,
|
|
110
|
+
message: error instanceof Error ? error.message : String(error),
|
|
111
|
+
ref,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Diff Classification Tool
|
|
118
|
+
* Classify change type without full analysis
|
|
119
|
+
*/
|
|
120
|
+
export const diffClassifyTool = {
|
|
121
|
+
name: 'analyze/diff-classify',
|
|
122
|
+
description: 'Classify git diff change type',
|
|
123
|
+
category: 'analyze',
|
|
124
|
+
tags: ['diff', 'classification', 'git'],
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
ref: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
description: 'Git ref to compare against',
|
|
131
|
+
default: 'HEAD',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
handler: async (params) => {
|
|
136
|
+
const ref = params.ref || 'HEAD';
|
|
137
|
+
try {
|
|
138
|
+
const files = getGitDiffNumstat(ref);
|
|
139
|
+
const classification = classifyDiff(files);
|
|
140
|
+
return {
|
|
141
|
+
ref,
|
|
142
|
+
classification,
|
|
143
|
+
files: files.length,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return {
|
|
148
|
+
error: true,
|
|
149
|
+
message: error instanceof Error ? error.message : String(error),
|
|
150
|
+
ref,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Diff Reviewers Tool
|
|
157
|
+
* Suggest reviewers for changes
|
|
158
|
+
*/
|
|
159
|
+
export const diffReviewersTool = {
|
|
160
|
+
name: 'analyze/diff-reviewers',
|
|
161
|
+
description: 'Suggest reviewers for git diff changes',
|
|
162
|
+
category: 'analyze',
|
|
163
|
+
tags: ['diff', 'reviewers', 'git'],
|
|
164
|
+
inputSchema: {
|
|
165
|
+
type: 'object',
|
|
166
|
+
properties: {
|
|
167
|
+
ref: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
description: 'Git ref to compare against',
|
|
170
|
+
default: 'HEAD',
|
|
171
|
+
},
|
|
172
|
+
limit: {
|
|
173
|
+
type: 'number',
|
|
174
|
+
description: 'Maximum number of reviewers to suggest',
|
|
175
|
+
default: 5,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
handler: async (params) => {
|
|
180
|
+
const ref = params.ref || 'HEAD';
|
|
181
|
+
const limit = params.limit || 5;
|
|
182
|
+
try {
|
|
183
|
+
const files = getGitDiffNumstat(ref);
|
|
184
|
+
const fileRisks = files.map(assessFileRisk);
|
|
185
|
+
const reviewers = suggestReviewers(files, fileRisks);
|
|
186
|
+
return {
|
|
187
|
+
ref,
|
|
188
|
+
recommendedReviewers: reviewers.slice(0, limit),
|
|
189
|
+
filesAnalyzed: files.length,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return {
|
|
194
|
+
error: true,
|
|
195
|
+
message: error instanceof Error ? error.message : String(error),
|
|
196
|
+
ref,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* File Risk Tool
|
|
203
|
+
* Assess risk for a specific file path
|
|
204
|
+
*/
|
|
205
|
+
export const fileRiskTool = {
|
|
206
|
+
name: 'analyze/file-risk',
|
|
207
|
+
description: 'Assess risk for a specific file change',
|
|
208
|
+
category: 'analyze',
|
|
209
|
+
tags: ['file', 'risk'],
|
|
210
|
+
inputSchema: {
|
|
211
|
+
type: 'object',
|
|
212
|
+
properties: {
|
|
213
|
+
path: {
|
|
214
|
+
type: 'string',
|
|
215
|
+
description: 'File path to assess',
|
|
216
|
+
},
|
|
217
|
+
additions: {
|
|
218
|
+
type: 'number',
|
|
219
|
+
description: 'Number of lines added',
|
|
220
|
+
default: 0,
|
|
221
|
+
},
|
|
222
|
+
deletions: {
|
|
223
|
+
type: 'number',
|
|
224
|
+
description: 'Number of lines deleted',
|
|
225
|
+
default: 0,
|
|
226
|
+
},
|
|
227
|
+
status: {
|
|
228
|
+
type: 'string',
|
|
229
|
+
description: 'File status: added, modified, deleted, renamed',
|
|
230
|
+
default: 'modified',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
required: ['path'],
|
|
234
|
+
},
|
|
235
|
+
handler: async (params) => {
|
|
236
|
+
const file = {
|
|
237
|
+
path: params.path,
|
|
238
|
+
status: params.status || 'modified',
|
|
239
|
+
additions: params.additions || 0,
|
|
240
|
+
deletions: params.deletions || 0,
|
|
241
|
+
hunks: 1,
|
|
242
|
+
binary: false,
|
|
243
|
+
};
|
|
244
|
+
const risk = assessFileRisk(file);
|
|
245
|
+
return {
|
|
246
|
+
file: file.path,
|
|
247
|
+
risk: risk.risk,
|
|
248
|
+
score: risk.score,
|
|
249
|
+
reasons: risk.reasons,
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Diff Stats Tool
|
|
255
|
+
* Get quick diff statistics
|
|
256
|
+
*/
|
|
257
|
+
export const diffStatsTool = {
|
|
258
|
+
name: 'analyze/diff-stats',
|
|
259
|
+
description: 'Get quick statistics for git diff',
|
|
260
|
+
category: 'analyze',
|
|
261
|
+
tags: ['diff', 'stats', 'git'],
|
|
262
|
+
inputSchema: {
|
|
263
|
+
type: 'object',
|
|
264
|
+
properties: {
|
|
265
|
+
ref: {
|
|
266
|
+
type: 'string',
|
|
267
|
+
description: 'Git ref to compare against',
|
|
268
|
+
default: 'HEAD',
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
handler: async (params) => {
|
|
273
|
+
const ref = params.ref || 'HEAD';
|
|
274
|
+
try {
|
|
275
|
+
const files = getGitDiffNumstat(ref);
|
|
276
|
+
const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0);
|
|
277
|
+
const totalDeletions = files.reduce((sum, f) => sum + f.deletions, 0);
|
|
278
|
+
const addedFiles = files.filter(f => f.status === 'added').length;
|
|
279
|
+
const modifiedFiles = files.filter(f => f.status === 'modified').length;
|
|
280
|
+
const deletedFiles = files.filter(f => f.status === 'deleted').length;
|
|
281
|
+
const renamedFiles = files.filter(f => f.status === 'renamed').length;
|
|
282
|
+
const binaryFiles = files.filter(f => f.binary).length;
|
|
283
|
+
return {
|
|
284
|
+
ref,
|
|
285
|
+
totalFiles: files.length,
|
|
286
|
+
totalAdditions,
|
|
287
|
+
totalDeletions,
|
|
288
|
+
totalChanges: totalAdditions + totalDeletions,
|
|
289
|
+
byStatus: {
|
|
290
|
+
added: addedFiles,
|
|
291
|
+
modified: modifiedFiles,
|
|
292
|
+
deleted: deletedFiles,
|
|
293
|
+
renamed: renamedFiles,
|
|
294
|
+
},
|
|
295
|
+
binaryFiles,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
return {
|
|
300
|
+
error: true,
|
|
301
|
+
message: error instanceof Error ? error.message : String(error),
|
|
302
|
+
ref,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
// Export all analyze tools
|
|
308
|
+
export const analyzeTools = [
|
|
309
|
+
analyzeDiffTool,
|
|
310
|
+
diffRiskTool,
|
|
311
|
+
diffClassifyTool,
|
|
312
|
+
diffReviewersTool,
|
|
313
|
+
fileRiskTool,
|
|
314
|
+
diffStatsTool,
|
|
315
|
+
];
|
|
316
|
+
export default analyzeTools;
|
|
317
|
+
//# sourceMappingURL=analyze-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-tools.js","sourceRoot":"","sources":["../../../src/mcp-tools/analyze-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAGlB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAY;IACtC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,gEAAgE;IAC7E,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,CAAC;IAC/C,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uEAAuE;gBACpF,OAAO,EAAE,MAAM;aAChB;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,2CAA2C;gBACxD,OAAO,EAAE,KAAK;aACf;YACD,gBAAgB,EAAE;gBA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c;gBAC7C,QAAQ,EAAE;oBACR,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,aAAa;oBACvB,OAAO,EAAE,YAAY;oBACrB,OAAO,EAAE,YAAY;iBACtB;gBACD,WAAW;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/D,GAAG;aACJ,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF,2BAA2B;AAC3B,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,eAAe;IACf,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;IACjB,YAAY;IACZ,aAAa;CACd,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/config-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"config-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/config-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA4F1C,eAAO,MAAM,WAAW,EAAE,OAAO,EA6QhC,CAAC"}
|
|
@@ -1,8 +1,86 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Config MCP Tools for CLI
|
|
3
3
|
*
|
|
4
|
-
* Tool definitions for configuration management.
|
|
4
|
+
* Tool definitions for configuration management with file persistence.
|
|
5
5
|
*/
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
// Storage paths
|
|
9
|
+
const STORAGE_DIR = '.claude-flow';
|
|
10
|
+
const CONFIG_FILE = 'config.json';
|
|
11
|
+
const DEFAULT_CONFIG = {
|
|
12
|
+
'swarm.topology': 'mesh',
|
|
13
|
+
'swarm.maxAgents': 10,
|
|
14
|
+
'swarm.autoScale': true,
|
|
15
|
+
'memory.persistInterval': 60000,
|
|
16
|
+
'memory.maxEntries': 10000,
|
|
17
|
+
'session.autoSave': true,
|
|
18
|
+
'session.saveInterval': 300000,
|
|
19
|
+
'logging.level': 'info',
|
|
20
|
+
'logging.format': 'json',
|
|
21
|
+
'security.sandboxEnabled': true,
|
|
22
|
+
'security.pathValidation': true,
|
|
23
|
+
};
|
|
24
|
+
function getConfigDir() {
|
|
25
|
+
return join(process.cwd(), STORAGE_DIR);
|
|
26
|
+
}
|
|
27
|
+
function getConfigPath() {
|
|
28
|
+
return join(getConfigDir(), CONFIG_FILE);
|
|
29
|
+
}
|
|
30
|
+
function ensureConfigDir() {
|
|
31
|
+
const dir = getConfigDir();
|
|
32
|
+
if (!existsSync(dir)) {
|
|
33
|
+
mkdirSync(dir, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function loadConfigStore() {
|
|
37
|
+
try {
|
|
38
|
+
const path = getConfigPath();
|
|
39
|
+
if (existsSync(path)) {
|
|
40
|
+
const data = readFileSync(path, 'utf-8');
|
|
41
|
+
return JSON.parse(data);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Return default store on error
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
values: { ...DEFAULT_CONFIG },
|
|
49
|
+
scopes: {},
|
|
50
|
+
version: '3.0.0',
|
|
51
|
+
updatedAt: new Date().toISOString(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function saveConfigStore(store) {
|
|
55
|
+
ensureConfigDir();
|
|
56
|
+
store.updatedAt = new Date().toISOString();
|
|
57
|
+
writeFileSync(getConfigPath(), JSON.stringify(store, null, 2), 'utf-8');
|
|
58
|
+
}
|
|
59
|
+
function getNestedValue(obj, key) {
|
|
60
|
+
const parts = key.split('.');
|
|
61
|
+
let current = obj;
|
|
62
|
+
for (const part of parts) {
|
|
63
|
+
if (current && typeof current === 'object' && part in current) {
|
|
64
|
+
current = current[part];
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return current;
|
|
71
|
+
}
|
|
72
|
+
function setNestedValue(obj, key, value) {
|
|
73
|
+
const parts = key.split('.');
|
|
74
|
+
let current = obj;
|
|
75
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
76
|
+
const part = parts[i];
|
|
77
|
+
if (!(part in current) || typeof current[part] !== 'object') {
|
|
78
|
+
current[part] = {};
|
|
79
|
+
}
|
|
80
|
+
current = current[part];
|
|
81
|
+
}
|
|
82
|
+
current[parts[parts.length - 1]] = value;
|
|
83
|
+
}
|
|
6
84
|
export const configTools = [
|
|
7
85
|
{
|
|
8
86
|
name: 'config/get',
|
|
@@ -11,16 +89,32 @@ export const configTools = [
|
|
|
11
89
|
inputSchema: {
|
|
12
90
|
type: 'object',
|
|
13
91
|
properties: {
|
|
14
|
-
key: { type: 'string', description: 'Configuration key' },
|
|
15
|
-
scope: { type: 'string', description: 'Configuration scope' },
|
|
92
|
+
key: { type: 'string', description: 'Configuration key (dot notation supported)' },
|
|
93
|
+
scope: { type: 'string', description: 'Configuration scope (project, user, system)' },
|
|
16
94
|
},
|
|
17
95
|
required: ['key'],
|
|
18
96
|
},
|
|
19
97
|
handler: async (input) => {
|
|
98
|
+
const store = loadConfigStore();
|
|
99
|
+
const key = input.key;
|
|
100
|
+
const scope = input.scope || 'default';
|
|
101
|
+
let value;
|
|
102
|
+
// Check scope first, then default values
|
|
103
|
+
if (scope !== 'default' && store.scopes[scope]) {
|
|
104
|
+
value = store.scopes[scope][key];
|
|
105
|
+
}
|
|
106
|
+
if (value === undefined) {
|
|
107
|
+
value = store.values[key];
|
|
108
|
+
}
|
|
109
|
+
if (value === undefined) {
|
|
110
|
+
value = DEFAULT_CONFIG[key];
|
|
111
|
+
}
|
|
20
112
|
return {
|
|
21
|
-
key
|
|
22
|
-
value
|
|
23
|
-
scope
|
|
113
|
+
key,
|
|
114
|
+
value,
|
|
115
|
+
scope,
|
|
116
|
+
exists: value !== undefined,
|
|
117
|
+
source: value !== undefined ? (store.values[key] !== undefined ? 'stored' : 'default') : 'none',
|
|
24
118
|
};
|
|
25
119
|
},
|
|
26
120
|
},
|
|
@@ -31,17 +125,35 @@ export const configTools = [
|
|
|
31
125
|
inputSchema: {
|
|
32
126
|
type: 'object',
|
|
33
127
|
properties: {
|
|
34
|
-
key: { type: 'string', description: 'Configuration key' },
|
|
128
|
+
key: { type: 'string', description: 'Configuration key (dot notation supported)' },
|
|
35
129
|
value: { description: 'Configuration value' },
|
|
36
|
-
scope: { type: 'string', description: 'Configuration scope' },
|
|
130
|
+
scope: { type: 'string', description: 'Configuration scope (project, user, system)' },
|
|
37
131
|
},
|
|
38
132
|
required: ['key', 'value'],
|
|
39
133
|
},
|
|
40
134
|
handler: async (input) => {
|
|
135
|
+
const store = loadConfigStore();
|
|
136
|
+
const key = input.key;
|
|
137
|
+
const value = input.value;
|
|
138
|
+
const scope = input.scope || 'default';
|
|
139
|
+
const previousValue = store.values[key];
|
|
140
|
+
if (scope === 'default') {
|
|
141
|
+
store.values[key] = value;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
if (!store.scopes[scope]) {
|
|
145
|
+
store.scopes[scope] = {};
|
|
146
|
+
}
|
|
147
|
+
store.scopes[scope][key] = value;
|
|
148
|
+
}
|
|
149
|
+
saveConfigStore(store);
|
|
41
150
|
return {
|
|
42
151
|
success: true,
|
|
43
|
-
key
|
|
44
|
-
|
|
152
|
+
key,
|
|
153
|
+
value,
|
|
154
|
+
previousValue,
|
|
155
|
+
scope,
|
|
156
|
+
path: getConfigPath(),
|
|
45
157
|
};
|
|
46
158
|
},
|
|
47
159
|
},
|
|
@@ -54,12 +166,41 @@ export const configTools = [
|
|
|
54
166
|
properties: {
|
|
55
167
|
scope: { type: 'string', description: 'Configuration scope' },
|
|
56
168
|
prefix: { type: 'string', description: 'Key prefix filter' },
|
|
169
|
+
includeDefaults: { type: 'boolean', description: 'Include default values' },
|
|
57
170
|
},
|
|
58
171
|
},
|
|
59
172
|
handler: async (input) => {
|
|
173
|
+
const store = loadConfigStore();
|
|
174
|
+
const scope = input.scope || 'default';
|
|
175
|
+
const prefix = input.prefix;
|
|
176
|
+
const includeDefaults = input.includeDefaults !== false;
|
|
177
|
+
// Merge stored values with defaults
|
|
178
|
+
let configs = {};
|
|
179
|
+
if (includeDefaults) {
|
|
180
|
+
configs = { ...DEFAULT_CONFIG };
|
|
181
|
+
}
|
|
182
|
+
// Add stored values
|
|
183
|
+
Object.assign(configs, store.values);
|
|
184
|
+
// Add scope-specific values
|
|
185
|
+
if (scope !== 'default' && store.scopes[scope]) {
|
|
186
|
+
Object.assign(configs, store.scopes[scope]);
|
|
187
|
+
}
|
|
188
|
+
// Filter by prefix
|
|
189
|
+
let entries = Object.entries(configs);
|
|
190
|
+
if (prefix) {
|
|
191
|
+
entries = entries.filter(([key]) => key.startsWith(prefix));
|
|
192
|
+
}
|
|
193
|
+
// Sort by key
|
|
194
|
+
entries.sort(([a], [b]) => a.localeCompare(b));
|
|
60
195
|
return {
|
|
61
|
-
configs: []
|
|
62
|
-
|
|
196
|
+
configs: entries.map(([key, value]) => ({
|
|
197
|
+
key,
|
|
198
|
+
value,
|
|
199
|
+
source: store.values[key] !== undefined ? 'stored' : 'default',
|
|
200
|
+
})),
|
|
201
|
+
total: entries.length,
|
|
202
|
+
scope,
|
|
203
|
+
updatedAt: store.updatedAt,
|
|
63
204
|
};
|
|
64
205
|
},
|
|
65
206
|
},
|
|
@@ -71,14 +212,120 @@ export const configTools = [
|
|
|
71
212
|
type: 'object',
|
|
72
213
|
properties: {
|
|
73
214
|
scope: { type: 'string', description: 'Configuration scope' },
|
|
74
|
-
key: { type: 'string', description: 'Specific key to reset' },
|
|
215
|
+
key: { type: 'string', description: 'Specific key to reset (omit to reset all)' },
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
handler: async (input) => {
|
|
219
|
+
const store = loadConfigStore();
|
|
220
|
+
const scope = input.scope || 'default';
|
|
221
|
+
const key = input.key;
|
|
222
|
+
let resetKeys = [];
|
|
223
|
+
if (key) {
|
|
224
|
+
// Reset specific key
|
|
225
|
+
if (scope === 'default') {
|
|
226
|
+
if (key in store.values) {
|
|
227
|
+
delete store.values[key];
|
|
228
|
+
resetKeys.push(key);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (store.scopes[scope] && key in store.scopes[scope]) {
|
|
232
|
+
delete store.scopes[scope][key];
|
|
233
|
+
resetKeys.push(key);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Reset all keys in scope
|
|
238
|
+
if (scope === 'default') {
|
|
239
|
+
resetKeys = Object.keys(store.values);
|
|
240
|
+
store.values = { ...DEFAULT_CONFIG };
|
|
241
|
+
}
|
|
242
|
+
else if (store.scopes[scope]) {
|
|
243
|
+
resetKeys = Object.keys(store.scopes[scope]);
|
|
244
|
+
delete store.scopes[scope];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
saveConfigStore(store);
|
|
248
|
+
return {
|
|
249
|
+
success: true,
|
|
250
|
+
scope,
|
|
251
|
+
reset: key || 'all',
|
|
252
|
+
resetKeys,
|
|
253
|
+
count: resetKeys.length,
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'config/export',
|
|
259
|
+
description: 'Export configuration to JSON',
|
|
260
|
+
category: 'config',
|
|
261
|
+
inputSchema: {
|
|
262
|
+
type: 'object',
|
|
263
|
+
properties: {
|
|
264
|
+
scope: { type: 'string', description: 'Configuration scope' },
|
|
265
|
+
includeDefaults: { type: 'boolean', description: 'Include default values' },
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
handler: async (input) => {
|
|
269
|
+
const store = loadConfigStore();
|
|
270
|
+
const scope = input.scope || 'default';
|
|
271
|
+
const includeDefaults = input.includeDefaults !== false;
|
|
272
|
+
let exportData = {};
|
|
273
|
+
if (includeDefaults) {
|
|
274
|
+
exportData = { ...DEFAULT_CONFIG };
|
|
275
|
+
}
|
|
276
|
+
Object.assign(exportData, store.values);
|
|
277
|
+
if (scope !== 'default' && store.scopes[scope]) {
|
|
278
|
+
Object.assign(exportData, store.scopes[scope]);
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
config: exportData,
|
|
282
|
+
scope,
|
|
283
|
+
version: store.version,
|
|
284
|
+
exportedAt: new Date().toISOString(),
|
|
285
|
+
count: Object.keys(exportData).length,
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'config/import',
|
|
291
|
+
description: 'Import configuration from JSON',
|
|
292
|
+
category: 'config',
|
|
293
|
+
inputSchema: {
|
|
294
|
+
type: 'object',
|
|
295
|
+
properties: {
|
|
296
|
+
config: { type: 'object', description: 'Configuration object to import' },
|
|
297
|
+
scope: { type: 'string', description: 'Configuration scope' },
|
|
298
|
+
merge: { type: 'boolean', description: 'Merge with existing (true) or replace (false)' },
|
|
75
299
|
},
|
|
300
|
+
required: ['config'],
|
|
76
301
|
},
|
|
77
302
|
handler: async (input) => {
|
|
303
|
+
const store = loadConfigStore();
|
|
304
|
+
const config = input.config;
|
|
305
|
+
const scope = input.scope || 'default';
|
|
306
|
+
const merge = input.merge !== false;
|
|
307
|
+
const importedKeys = Object.keys(config);
|
|
308
|
+
if (scope === 'default') {
|
|
309
|
+
if (merge) {
|
|
310
|
+
Object.assign(store.values, config);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
store.values = { ...DEFAULT_CONFIG, ...config };
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
if (!store.scopes[scope] || !merge) {
|
|
318
|
+
store.scopes[scope] = {};
|
|
319
|
+
}
|
|
320
|
+
Object.assign(store.scopes[scope], config);
|
|
321
|
+
}
|
|
322
|
+
saveConfigStore(store);
|
|
78
323
|
return {
|
|
79
324
|
success: true,
|
|
80
|
-
scope
|
|
81
|
-
|
|
325
|
+
scope,
|
|
326
|
+
imported: importedKeys.length,
|
|
327
|
+
keys: importedKeys,
|
|
328
|
+
merge,
|
|
82
329
|
};
|
|
83
330
|
},
|
|
84
331
|
},
|