peaks-cli 1.3.4 → 1.3.6
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/dist/src/cli/commands/hook-handle.d.ts +2 -2
- package/dist/src/cli/commands/hook-handle.js +5 -10
- package/dist/src/cli/commands/hooks-commands.js +44 -29
- package/dist/src/cli/commands/project-commands.js +7 -1
- package/dist/src/cli/commands/workspace-commands.js +1 -2
- package/dist/src/cli/program.js +3 -4
- package/dist/src/services/dashboard/project-dashboard-service.d.ts +0 -7
- package/dist/src/services/dashboard/project-dashboard-service.js +1 -8
- package/dist/src/services/dispatch/sub-agent-dispatcher.d.ts +45 -40
- package/dist/src/services/dispatch/sub-agent-dispatcher.js +25 -20
- package/dist/src/services/ide/adapters/claude-code-adapter.js +0 -3
- package/dist/src/services/ide/adapters/trae-adapter.js +2 -17
- package/dist/src/services/ide/ide-types.d.ts +1 -18
- package/dist/src/services/progress/progress-service.d.ts +23 -103
- package/dist/src/services/progress/progress-service.js +24 -137
- package/dist/src/services/scan/file-size-scan.d.ts +4 -0
- package/dist/src/services/scan/file-size-scan.js +32 -3
- package/dist/src/services/skills/hooks-settings-service.d.ts +57 -5
- package/dist/src/services/skills/hooks-settings-service.js +153 -28
- package/dist/src/shared/incrementing-number.d.ts +0 -8
- package/dist/src/shared/incrementing-number.js +11 -1
- package/dist/src/shared/version.d.ts +1 -1
- package/dist/src/shared/version.js +1 -1
- package/package.json +1 -1
- package/skills/peaks-prd/SKILL.md +16 -16
- package/skills/peaks-prd/references/workflow.md +4 -4
- package/skills/peaks-qa/SKILL.md +25 -32
- package/skills/peaks-qa/references/qa-fanout-contract.md +6 -6
- package/skills/peaks-qa/references/regression-gates.md +1 -1
- package/skills/peaks-rd/SKILL.md +8 -21
- package/skills/peaks-rd/references/{openspec-mcp-cli.md → openspec-cli.md} +11 -14
- package/skills/peaks-solo/SKILL.md +1 -1
- package/skills/peaks-solo/references/a2a-artifact-mapping.md +1 -1
- package/skills/peaks-solo/references/browser-workflow.md +49 -38
- package/skills/peaks-solo/references/external-skill-invocation.md +9 -7
- package/skills/peaks-solo/references/{openspec-mcp-workflow.md → openspec-workflow.md} +5 -20
- package/skills/peaks-solo/references/runbook.md +21 -21
- package/skills/peaks-solo/references/sub-agent-dispatch.md +16 -35
- package/skills/peaks-solo/references/swarm-dispatch-contract.md +9 -9
- package/skills/peaks-ui/SKILL.md +22 -24
- package/skills/peaks-ui/references/workflow.md +2 -2
- package/dist/src/cli/commands/mcp-commands.d.ts +0 -3
- package/dist/src/cli/commands/mcp-commands.js +0 -144
- package/dist/src/cli/commands/progress-close-kill.d.ts +0 -51
- package/dist/src/cli/commands/progress-close-kill.js +0 -152
- package/dist/src/cli/commands/progress-commands.d.ts +0 -3
- package/dist/src/cli/commands/progress-commands.js +0 -379
- package/dist/src/cli/commands/progress-start-spawn.d.ts +0 -59
- package/dist/src/cli/commands/progress-start-spawn.js +0 -140
- package/dist/src/cli/commands/progress-watch-render.d.ts +0 -80
- package/dist/src/cli/commands/progress-watch-render.js +0 -308
- package/dist/src/services/mcp/mcp-apply-service.d.ts +0 -31
- package/dist/src/services/mcp/mcp-apply-service.js +0 -112
- package/dist/src/services/mcp/mcp-call-service.d.ts +0 -17
- package/dist/src/services/mcp/mcp-call-service.js +0 -34
- package/dist/src/services/mcp/mcp-client-service.d.ts +0 -14
- package/dist/src/services/mcp/mcp-client-service.js +0 -49
- package/dist/src/services/mcp/mcp-install-registry.d.ts +0 -11
- package/dist/src/services/mcp/mcp-install-registry.js +0 -38
- package/dist/src/services/mcp/mcp-plan-service.d.ts +0 -29
- package/dist/src/services/mcp/mcp-plan-service.js +0 -109
- package/dist/src/services/mcp/mcp-protocol.d.ts +0 -24
- package/dist/src/services/mcp/mcp-protocol.js +0 -41
- package/dist/src/services/mcp/mcp-scan-service.d.ts +0 -8
- package/dist/src/services/mcp/mcp-scan-service.js +0 -214
- package/dist/src/services/mcp/mcp-stdio-transport.d.ts +0 -10
- package/dist/src/services/mcp/mcp-stdio-transport.js +0 -50
- package/dist/src/services/mcp/mcp-types.d.ts +0 -31
- package/dist/src/services/mcp/mcp-types.js +0 -1
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { scanMcpServers } from './mcp-scan-service.js';
|
|
2
|
-
import { findMcpInstallSpec } from './mcp-install-registry.js';
|
|
3
|
-
function arraysEqual(a, b) {
|
|
4
|
-
if (a.length !== b.length) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
return a.every((value, index) => value === b[index]);
|
|
8
|
-
}
|
|
9
|
-
function buildEnvCheck(spec, env) {
|
|
10
|
-
const missing = spec.envKeys.filter((key) => {
|
|
11
|
-
const value = env[key];
|
|
12
|
-
return value === undefined || value.length === 0;
|
|
13
|
-
});
|
|
14
|
-
return { missing };
|
|
15
|
-
}
|
|
16
|
-
function buildDiff(spec, current) {
|
|
17
|
-
const diff = {};
|
|
18
|
-
if (current.command !== spec.command) {
|
|
19
|
-
diff.command = { before: current.command, after: spec.command };
|
|
20
|
-
}
|
|
21
|
-
if (!arraysEqual(current.args, spec.args)) {
|
|
22
|
-
diff.args = { before: current.args, after: spec.args };
|
|
23
|
-
}
|
|
24
|
-
if (!arraysEqual(current.envKeys, spec.envKeys)) {
|
|
25
|
-
diff.envKeys = { before: current.envKeys, after: spec.envKeys };
|
|
26
|
-
}
|
|
27
|
-
return Object.keys(diff).length === 0 ? null : diff;
|
|
28
|
-
}
|
|
29
|
-
function buildNextActions(action, capabilityId, envMissing) {
|
|
30
|
-
const actions = [];
|
|
31
|
-
if (action === 'unknown-capability') {
|
|
32
|
-
actions.push(`No MCP install spec registered for capability ${capabilityId}`);
|
|
33
|
-
return actions;
|
|
34
|
-
}
|
|
35
|
-
if (envMissing.length > 0) {
|
|
36
|
-
actions.push(`Set required env vars before apply: ${envMissing.join(', ')}`);
|
|
37
|
-
}
|
|
38
|
-
if (action === 'add') {
|
|
39
|
-
actions.push(`Run peaks mcp apply --capability ${capabilityId} --yes to write the new server`);
|
|
40
|
-
}
|
|
41
|
-
else if (action === 'update') {
|
|
42
|
-
actions.push(`Run peaks mcp apply --capability ${capabilityId} --yes to update the existing peaks-managed server`);
|
|
43
|
-
}
|
|
44
|
-
else if (action === 'conflict') {
|
|
45
|
-
actions.push(`Re-run with --claim to take ownership of the existing non-peaks-managed entry, or rename the conflicting server`);
|
|
46
|
-
}
|
|
47
|
-
else if (action === 'noop') {
|
|
48
|
-
actions.push(`Server already matches the install spec; nothing to apply`);
|
|
49
|
-
}
|
|
50
|
-
return actions;
|
|
51
|
-
}
|
|
52
|
-
export async function planMcpInstall(capabilityId, options = {}) {
|
|
53
|
-
const spec = findMcpInstallSpec(capabilityId);
|
|
54
|
-
if (spec === null) {
|
|
55
|
-
return {
|
|
56
|
-
capabilityId,
|
|
57
|
-
action: 'unknown-capability',
|
|
58
|
-
spec: null,
|
|
59
|
-
current: null,
|
|
60
|
-
envCheck: { missing: [] },
|
|
61
|
-
diff: null,
|
|
62
|
-
nextActions: buildNextActions('unknown-capability', capabilityId, [])
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const env = options.env ?? process.env;
|
|
66
|
-
const envCheck = buildEnvCheck(spec, env);
|
|
67
|
-
const scanOptions = {};
|
|
68
|
-
if (options.globalSettingsPath !== undefined) {
|
|
69
|
-
scanOptions.globalSettingsPath = options.globalSettingsPath;
|
|
70
|
-
}
|
|
71
|
-
if (options.projectRoot !== undefined) {
|
|
72
|
-
scanOptions.projectRoot = options.projectRoot;
|
|
73
|
-
}
|
|
74
|
-
if (options.managedMarkerPath !== undefined) {
|
|
75
|
-
scanOptions.managedMarkerPath = options.managedMarkerPath;
|
|
76
|
-
}
|
|
77
|
-
if (options.pluginsRegistryPath !== undefined) {
|
|
78
|
-
scanOptions.pluginsRegistryPath = options.pluginsRegistryPath;
|
|
79
|
-
}
|
|
80
|
-
const report = await scanMcpServers(scanOptions);
|
|
81
|
-
const current = report.servers.find((server) => server.name === spec.name && server.scope === spec.scope) ?? null;
|
|
82
|
-
const pluginDuplicate = report.servers.find((server) => server.source === 'plugin' && server.name === spec.name) ?? null;
|
|
83
|
-
let action;
|
|
84
|
-
let diff = null;
|
|
85
|
-
if (current === null) {
|
|
86
|
-
action = 'add';
|
|
87
|
-
}
|
|
88
|
-
else if (current.source !== 'peaks') {
|
|
89
|
-
action = 'conflict';
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
diff = buildDiff(spec, current);
|
|
93
|
-
action = diff === null ? 'noop' : 'update';
|
|
94
|
-
}
|
|
95
|
-
const nextActions = buildNextActions(action, capabilityId, envCheck.missing);
|
|
96
|
-
if (pluginDuplicate !== null) {
|
|
97
|
-
const pluginLabel = pluginDuplicate.pluginName ?? 'a Claude Code plugin';
|
|
98
|
-
nextActions.push(`An MCP server named "${spec.name}" is already loaded by plugin ${pluginLabel}; installing via peaks would duplicate it`);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
capabilityId,
|
|
102
|
-
action,
|
|
103
|
-
spec,
|
|
104
|
-
current,
|
|
105
|
-
envCheck,
|
|
106
|
-
diff,
|
|
107
|
-
nextActions
|
|
108
|
-
};
|
|
109
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type McpJsonRpcRequest = {
|
|
2
|
-
jsonrpc: '2.0';
|
|
3
|
-
id: number;
|
|
4
|
-
method: string;
|
|
5
|
-
params?: unknown;
|
|
6
|
-
};
|
|
7
|
-
export type McpJsonRpcError = {
|
|
8
|
-
code: number;
|
|
9
|
-
message: string;
|
|
10
|
-
data?: unknown;
|
|
11
|
-
};
|
|
12
|
-
export type McpJsonRpcResponse = {
|
|
13
|
-
jsonrpc: '2.0';
|
|
14
|
-
id: number;
|
|
15
|
-
result?: unknown;
|
|
16
|
-
error?: McpJsonRpcError;
|
|
17
|
-
};
|
|
18
|
-
export type ParsedMessages = {
|
|
19
|
-
messages: McpJsonRpcResponse[];
|
|
20
|
-
remainder: string;
|
|
21
|
-
};
|
|
22
|
-
export declare function buildRequest(id: number, method: string, params?: unknown): McpJsonRpcRequest;
|
|
23
|
-
export declare function serializeMessage(message: McpJsonRpcRequest | McpJsonRpcResponse): string;
|
|
24
|
-
export declare function parseMessages(buffer: string): ParsedMessages;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export function buildRequest(id, method, params) {
|
|
2
|
-
if (params === undefined) {
|
|
3
|
-
return { jsonrpc: '2.0', id, method };
|
|
4
|
-
}
|
|
5
|
-
return { jsonrpc: '2.0', id, method, params };
|
|
6
|
-
}
|
|
7
|
-
export function serializeMessage(message) {
|
|
8
|
-
return `${JSON.stringify(message)}\n`;
|
|
9
|
-
}
|
|
10
|
-
function isJsonRpcResponse(value) {
|
|
11
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
const record = value;
|
|
15
|
-
if (record.jsonrpc !== '2.0') {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return typeof record.id === 'number';
|
|
19
|
-
}
|
|
20
|
-
export function parseMessages(buffer) {
|
|
21
|
-
const lastNewline = buffer.lastIndexOf('\n');
|
|
22
|
-
const remainder = lastNewline === -1 ? buffer : buffer.slice(lastNewline + 1);
|
|
23
|
-
const completePart = lastNewline === -1 ? '' : buffer.slice(0, lastNewline);
|
|
24
|
-
const messages = [];
|
|
25
|
-
for (const line of completePart.split('\n')) {
|
|
26
|
-
if (line.length === 0) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
let parsed;
|
|
30
|
-
try {
|
|
31
|
-
parsed = JSON.parse(line);
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (isJsonRpcResponse(parsed)) {
|
|
37
|
-
messages.push(parsed);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return { messages, remainder };
|
|
41
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { McpScanReport } from './mcp-types.js';
|
|
2
|
-
export type McpScanOptions = {
|
|
3
|
-
globalSettingsPath?: string;
|
|
4
|
-
projectRoot?: string;
|
|
5
|
-
managedMarkerPath?: string;
|
|
6
|
-
pluginsRegistryPath?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function scanMcpServers(options?: McpScanOptions): Promise<McpScanReport>;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { pathExists, readText } from '../../shared/fs.js';
|
|
4
|
-
import { getErrorMessage } from '../../shared/result.js';
|
|
5
|
-
function defaultGlobalSettingsPath() {
|
|
6
|
-
return join(homedir(), '.claude', 'settings.json');
|
|
7
|
-
}
|
|
8
|
-
function defaultManagedMarkerPath() {
|
|
9
|
-
return join(homedir(), '.peaks', 'mcp-managed.json');
|
|
10
|
-
}
|
|
11
|
-
function defaultPluginsRegistryPath() {
|
|
12
|
-
return join(homedir(), '.claude', 'plugins', 'installed_plugins.json');
|
|
13
|
-
}
|
|
14
|
-
function projectSettingsPath(projectRoot) {
|
|
15
|
-
return join(projectRoot, '.claude', 'settings.json');
|
|
16
|
-
}
|
|
17
|
-
async function readSettings(path) {
|
|
18
|
-
if (!(await pathExists(path))) {
|
|
19
|
-
return { exists: false, parsed: { parsed: null } };
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const raw = await readText(path);
|
|
23
|
-
const value = JSON.parse(raw);
|
|
24
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
25
|
-
return { exists: true, parsed: { parsed: null } };
|
|
26
|
-
}
|
|
27
|
-
return { exists: true, parsed: { parsed: value } };
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
return { exists: true, parsed: { parsed: null, parseError: getErrorMessage(error) } };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function loadManagedNames(path) {
|
|
34
|
-
if (!(await pathExists(path))) {
|
|
35
|
-
return new Set();
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const value = JSON.parse(await readText(path));
|
|
39
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
40
|
-
return new Set();
|
|
41
|
-
}
|
|
42
|
-
const servers = value.servers;
|
|
43
|
-
if (!Array.isArray(servers)) {
|
|
44
|
-
return new Set();
|
|
45
|
-
}
|
|
46
|
-
return new Set(servers.filter((entry) => typeof entry === 'string'));
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return new Set();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function toStringArray(value) {
|
|
53
|
-
if (!Array.isArray(value)) {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
return value.filter((entry) => typeof entry === 'string');
|
|
57
|
-
}
|
|
58
|
-
function toEnvKeys(value) {
|
|
59
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
return Object.keys(value);
|
|
63
|
-
}
|
|
64
|
-
function buildServerConfig(name, raw, scope, source, pluginName) {
|
|
65
|
-
const command = raw.command;
|
|
66
|
-
if (typeof command !== 'string' || command.length === 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const config = {
|
|
70
|
-
name,
|
|
71
|
-
command,
|
|
72
|
-
args: toStringArray(raw.args),
|
|
73
|
-
envKeys: toEnvKeys(raw.env),
|
|
74
|
-
scope,
|
|
75
|
-
source
|
|
76
|
-
};
|
|
77
|
-
if (pluginName !== undefined && pluginName.length > 0) {
|
|
78
|
-
config.pluginName = pluginName;
|
|
79
|
-
}
|
|
80
|
-
return config;
|
|
81
|
-
}
|
|
82
|
-
function resolveServers(settings, scope, managedNames) {
|
|
83
|
-
if (settings === null) {
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
const mcpServers = settings.mcpServers;
|
|
87
|
-
if (mcpServers === null || typeof mcpServers !== 'object' || Array.isArray(mcpServers)) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
const servers = [];
|
|
91
|
-
for (const [name, raw] of Object.entries(mcpServers)) {
|
|
92
|
-
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
const source = managedNames.has(name) ? 'peaks' : 'unknown';
|
|
96
|
-
const config = buildServerConfig(name, raw, scope, source);
|
|
97
|
-
if (config !== null) {
|
|
98
|
-
servers.push(config);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return servers;
|
|
102
|
-
}
|
|
103
|
-
function toScopeReport(path, exists, parseError) {
|
|
104
|
-
return parseError === undefined ? { path, exists } : { path, exists, parseError };
|
|
105
|
-
}
|
|
106
|
-
function extractMcpServersBlock(parsed) {
|
|
107
|
-
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
const wrapped = parsed.mcpServers;
|
|
111
|
-
if (wrapped !== undefined && wrapped !== null && typeof wrapped === 'object' && !Array.isArray(wrapped)) {
|
|
112
|
-
return wrapped;
|
|
113
|
-
}
|
|
114
|
-
return parsed;
|
|
115
|
-
}
|
|
116
|
-
async function readPluginMcpServers(installPath, pluginName) {
|
|
117
|
-
const mcpFilePath = join(installPath, '.mcp.json');
|
|
118
|
-
if (!(await pathExists(mcpFilePath))) {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
let parsed;
|
|
122
|
-
try {
|
|
123
|
-
parsed = JSON.parse(await readText(mcpFilePath));
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
const block = extractMcpServersBlock(parsed);
|
|
129
|
-
if (block === null) {
|
|
130
|
-
return [];
|
|
131
|
-
}
|
|
132
|
-
const servers = [];
|
|
133
|
-
for (const [name, raw] of Object.entries(block)) {
|
|
134
|
-
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
const config = buildServerConfig(name, raw, 'plugin', 'plugin', pluginName);
|
|
138
|
-
if (config !== null) {
|
|
139
|
-
servers.push(config);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return servers;
|
|
143
|
-
}
|
|
144
|
-
async function scanPluginMcpServers(registryPath) {
|
|
145
|
-
const exists = await pathExists(registryPath);
|
|
146
|
-
const baseReport = {
|
|
147
|
-
path: registryPath,
|
|
148
|
-
exists,
|
|
149
|
-
pluginsScanned: 0,
|
|
150
|
-
pluginsWithMcp: 0
|
|
151
|
-
};
|
|
152
|
-
if (!exists) {
|
|
153
|
-
return { servers: [], report: baseReport };
|
|
154
|
-
}
|
|
155
|
-
let parsed;
|
|
156
|
-
try {
|
|
157
|
-
parsed = JSON.parse(await readText(registryPath));
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
return { servers: [], report: { ...baseReport, parseError: getErrorMessage(error) } };
|
|
161
|
-
}
|
|
162
|
-
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
163
|
-
return { servers: [], report: baseReport };
|
|
164
|
-
}
|
|
165
|
-
const pluginsField = parsed.plugins;
|
|
166
|
-
if (pluginsField === null || typeof pluginsField !== 'object' || Array.isArray(pluginsField)) {
|
|
167
|
-
return { servers: [], report: baseReport };
|
|
168
|
-
}
|
|
169
|
-
const servers = [];
|
|
170
|
-
let pluginsScanned = 0;
|
|
171
|
-
let pluginsWithMcp = 0;
|
|
172
|
-
for (const [pluginId, entries] of Object.entries(pluginsField)) {
|
|
173
|
-
if (!Array.isArray(entries) || entries.length === 0) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
const first = entries[0];
|
|
177
|
-
if (first === null || typeof first !== 'object' || Array.isArray(first)) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
const installPath = first.installPath;
|
|
181
|
-
if (typeof installPath !== 'string' || installPath.length === 0) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
pluginsScanned += 1;
|
|
185
|
-
const found = await readPluginMcpServers(installPath, pluginId);
|
|
186
|
-
if (found.length > 0) {
|
|
187
|
-
pluginsWithMcp += 1;
|
|
188
|
-
servers.push(...found);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return { servers, report: { ...baseReport, pluginsScanned, pluginsWithMcp } };
|
|
192
|
-
}
|
|
193
|
-
export async function scanMcpServers(options = {}) {
|
|
194
|
-
const globalPath = options.globalSettingsPath ?? defaultGlobalSettingsPath();
|
|
195
|
-
const managedMarkerPath = options.managedMarkerPath ?? defaultManagedMarkerPath();
|
|
196
|
-
const pluginsRegistryPath = options.pluginsRegistryPath ?? defaultPluginsRegistryPath();
|
|
197
|
-
const managedNames = await loadManagedNames(managedMarkerPath);
|
|
198
|
-
const globalSettings = await readSettings(globalPath);
|
|
199
|
-
const globalScope = toScopeReport(globalPath, globalSettings.exists, globalSettings.parsed.parseError);
|
|
200
|
-
const globalServers = resolveServers(globalSettings.parsed.parsed, 'global', managedNames);
|
|
201
|
-
let projectScope = null;
|
|
202
|
-
const projectServers = [];
|
|
203
|
-
if (options.projectRoot !== undefined) {
|
|
204
|
-
const projectPath = projectSettingsPath(options.projectRoot);
|
|
205
|
-
const projectSettings = await readSettings(projectPath);
|
|
206
|
-
projectScope = toScopeReport(projectPath, projectSettings.exists, projectSettings.parsed.parseError);
|
|
207
|
-
projectServers.push(...resolveServers(projectSettings.parsed.parsed, 'project', managedNames));
|
|
208
|
-
}
|
|
209
|
-
const plugins = await scanPluginMcpServers(pluginsRegistryPath);
|
|
210
|
-
return {
|
|
211
|
-
servers: [...globalServers, ...projectServers, ...plugins.servers],
|
|
212
|
-
scopes: { global: globalScope, project: projectScope, plugins: plugins.report }
|
|
213
|
-
};
|
|
214
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { McpClientTransport } from './mcp-client-service.js';
|
|
2
|
-
import type { McpInstallSpec } from './mcp-install-registry.js';
|
|
3
|
-
export type StdioTransportOptions = {
|
|
4
|
-
command: string;
|
|
5
|
-
args?: string[];
|
|
6
|
-
env?: Record<string, string | undefined>;
|
|
7
|
-
cwd?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function createStdioTransport(options: StdioTransportOptions): McpClientTransport;
|
|
10
|
-
export declare function createStdioTransportFromSpec(spec: McpInstallSpec, env: Record<string, string | undefined>): McpClientTransport;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
export function createStdioTransport(options) {
|
|
3
|
-
const env = {};
|
|
4
|
-
for (const [key, value] of Object.entries({ ...process.env, ...(options.env ?? {}) })) {
|
|
5
|
-
if (typeof value === 'string') {
|
|
6
|
-
env[key] = value;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
const child = spawn(options.command, options.args ?? [], {
|
|
10
|
-
env,
|
|
11
|
-
cwd: options.cwd,
|
|
12
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
13
|
-
});
|
|
14
|
-
let lineHandler = null;
|
|
15
|
-
child.stdout.setEncoding('utf8');
|
|
16
|
-
child.stdout.on('data', (chunk) => {
|
|
17
|
-
if (lineHandler !== null) {
|
|
18
|
-
lineHandler(chunk);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
send: (line) => new Promise((resolve, reject) => {
|
|
23
|
-
child.stdin.write(line, (error) => {
|
|
24
|
-
if (error !== null && error !== undefined) {
|
|
25
|
-
reject(error);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
resolve();
|
|
29
|
-
});
|
|
30
|
-
}),
|
|
31
|
-
onLine: (handler) => {
|
|
32
|
-
lineHandler = handler;
|
|
33
|
-
},
|
|
34
|
-
close: () => new Promise((resolve) => {
|
|
35
|
-
if (child.exitCode !== null || child.signalCode !== null) {
|
|
36
|
-
resolve();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
child.once('exit', () => resolve());
|
|
40
|
-
child.kill();
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export function createStdioTransportFromSpec(spec, env) {
|
|
45
|
-
const transportEnv = {};
|
|
46
|
-
for (const key of spec.envKeys) {
|
|
47
|
-
transportEnv[key] = env[key];
|
|
48
|
-
}
|
|
49
|
-
return createStdioTransport({ command: spec.command, args: spec.args, env: transportEnv });
|
|
50
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type McpServerSource = 'peaks' | 'cc-switch' | 'user' | 'plugin' | 'unknown';
|
|
2
|
-
export type McpServerScope = 'global' | 'project' | 'plugin';
|
|
3
|
-
export type McpServerConfig = {
|
|
4
|
-
name: string;
|
|
5
|
-
command: string;
|
|
6
|
-
args: string[];
|
|
7
|
-
envKeys: string[];
|
|
8
|
-
source: McpServerSource;
|
|
9
|
-
scope: McpServerScope;
|
|
10
|
-
pluginName?: string;
|
|
11
|
-
};
|
|
12
|
-
export type McpSettingsScopeReport = {
|
|
13
|
-
path: string;
|
|
14
|
-
exists: boolean;
|
|
15
|
-
parseError?: string;
|
|
16
|
-
};
|
|
17
|
-
export type McpPluginsReport = {
|
|
18
|
-
path: string;
|
|
19
|
-
exists: boolean;
|
|
20
|
-
parseError?: string;
|
|
21
|
-
pluginsScanned: number;
|
|
22
|
-
pluginsWithMcp: number;
|
|
23
|
-
};
|
|
24
|
-
export type McpScanReport = {
|
|
25
|
-
servers: McpServerConfig[];
|
|
26
|
-
scopes: {
|
|
27
|
-
global: McpSettingsScopeReport;
|
|
28
|
-
project: McpSettingsScopeReport | null;
|
|
29
|
-
plugins: McpPluginsReport;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|