@paretools/shared 0.12.0 → 0.13.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/dist/ansi.js +1 -1
- package/dist/ansi.js.map +1 -1
- package/dist/discover-tool.d.ts +19 -0
- package/dist/discover-tool.d.ts.map +1 -0
- package/dist/discover-tool.js +70 -0
- package/dist/discover-tool.js.map +1 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/lazy-tools.d.ts +44 -0
- package/dist/lazy-tools.d.ts.map +1 -0
- package/dist/lazy-tools.js +54 -0
- package/dist/lazy-tools.js.map +1 -0
- package/dist/output.d.ts +27 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +43 -0
- package/dist/output.js.map +1 -1
- package/dist/profiles.d.ts +16 -0
- package/dist/profiles.d.ts.map +1 -1
- package/dist/profiles.js +58 -0
- package/dist/profiles.js.map +1 -1
- package/dist/runner.d.ts +31 -5
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +140 -12
- package/dist/runner.js.map +1 -1
- package/dist/server.d.ts +10 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -1
- package/dist/server.js.map +1 -1
- package/dist/strict-input.d.ts +19 -0
- package/dist/strict-input.d.ts.map +1 -0
- package/dist/strict-input.js +59 -0
- package/dist/strict-input.js.map +1 -0
- package/dist/tool-filter.d.ts +12 -0
- package/dist/tool-filter.d.ts.map +1 -1
- package/dist/tool-filter.js +24 -0
- package/dist/tool-filter.js.map +1 -1
- package/dist/validation.d.ts +8 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +17 -0
- package/dist/validation.js.map +1 -1
- package/dist/version.d.ts +16 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +42 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -3
package/dist/ansi.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Strips ANSI escape codes from a string.
|
|
3
3
|
* Handles SGR (colors/styles), cursor movement, and other terminal sequences.
|
|
4
4
|
*/
|
|
5
|
-
const ANSI_REGEX = /\x1B(?:\][^\x07]
|
|
5
|
+
const ANSI_REGEX = /\x1B(?:\][^\x07]{0,256}\x07|\[[\d;?]{0,64}[A-Za-z]|[@-Z\\-_])/g;
|
|
6
6
|
export function stripAnsi(str) {
|
|
7
7
|
return str.replace(ANSI_REGEX, "");
|
|
8
8
|
}
|
package/dist/ansi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,GAAG,gEAAgE,CAAC;AAEpF,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `discover-tools` meta-tool — allows LLM clients to discover and load
|
|
3
|
+
* tools that were deferred at startup for token efficiency.
|
|
4
|
+
*
|
|
5
|
+
* Each server registers this tool when lazy mode is active and at least one
|
|
6
|
+
* tool was deferred. Calling it with no arguments lists available tools;
|
|
7
|
+
* passing tool names in `load` immediately registers them.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import type { LazyToolManager } from "./lazy-tools.js";
|
|
11
|
+
/**
|
|
12
|
+
* Registers the `discover-tools` meta-tool on the given server.
|
|
13
|
+
*
|
|
14
|
+
* @param server - The MCP server to register on.
|
|
15
|
+
* @param manager - The lazy tool manager tracking deferred tools.
|
|
16
|
+
* @param serverName - Human-readable server name for the tool description.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerDiscoverTool(server: McpServer, manager: LazyToolManager, serverName: string): void;
|
|
19
|
+
//# sourceMappingURL=discover-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-tool.d.ts","sourceRoot":"","sources":["../src/discover-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAsCvD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,GACjB,IAAI,CA+BN"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `discover-tools` meta-tool — allows LLM clients to discover and load
|
|
3
|
+
* tools that were deferred at startup for token efficiency.
|
|
4
|
+
*
|
|
5
|
+
* Each server registers this tool when lazy mode is active and at least one
|
|
6
|
+
* tool was deferred. Calling it with no arguments lists available tools;
|
|
7
|
+
* passing tool names in `load` immediately registers them.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { dualOutput } from "./output.js";
|
|
11
|
+
/** Zod schema for the discover-tools output. */
|
|
12
|
+
const DiscoverToolsOutputSchema = {
|
|
13
|
+
available: z.array(z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
description: z.string(),
|
|
16
|
+
})),
|
|
17
|
+
loaded: z.array(z.string()),
|
|
18
|
+
totalAvailable: z.number(),
|
|
19
|
+
};
|
|
20
|
+
function formatDiscoverTools(data) {
|
|
21
|
+
const lines = [];
|
|
22
|
+
if (data.loaded.length > 0) {
|
|
23
|
+
lines.push(`Loaded ${data.loaded.length} tool(s): ${data.loaded.join(", ")}`);
|
|
24
|
+
lines.push("");
|
|
25
|
+
}
|
|
26
|
+
if (data.available.length > 0) {
|
|
27
|
+
lines.push(`${data.totalAvailable} additional tool(s) available:`);
|
|
28
|
+
for (const tool of data.available) {
|
|
29
|
+
lines.push(` - ${tool.name}: ${tool.description}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
lines.push("All tools are loaded.");
|
|
34
|
+
}
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Registers the `discover-tools` meta-tool on the given server.
|
|
39
|
+
*
|
|
40
|
+
* @param server - The MCP server to register on.
|
|
41
|
+
* @param manager - The lazy tool manager tracking deferred tools.
|
|
42
|
+
* @param serverName - Human-readable server name for the tool description.
|
|
43
|
+
*/
|
|
44
|
+
export function registerDiscoverTool(server, manager, serverName) {
|
|
45
|
+
server.registerTool("discover-tools", {
|
|
46
|
+
title: "Discover Available Tools",
|
|
47
|
+
description: `List and load additional ${serverName} tools that aren't loaded by default. Use this to find tools for less common operations.`,
|
|
48
|
+
inputSchema: {
|
|
49
|
+
load: z.array(z.string()).optional().describe("Tool names to load immediately"),
|
|
50
|
+
},
|
|
51
|
+
outputSchema: DiscoverToolsOutputSchema,
|
|
52
|
+
}, async (args) => {
|
|
53
|
+
const loaded = [];
|
|
54
|
+
if (args.load) {
|
|
55
|
+
for (const name of args.load) {
|
|
56
|
+
if (manager.loadTool(name)) {
|
|
57
|
+
loaded.push(name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const available = manager.listLazy();
|
|
62
|
+
const result = {
|
|
63
|
+
available,
|
|
64
|
+
loaded,
|
|
65
|
+
totalAvailable: available.length,
|
|
66
|
+
};
|
|
67
|
+
return dualOutput(result, formatDiscoverTools);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=discover-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-tool.js","sourceRoot":"","sources":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C,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAiB,EACjB,OAAwB,EACxB,UAAkB;IAElB,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,4BAA4B,UAAU,0FAA0F;QAC7I,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;SAChF;QACD,YAAY,EAAE,yBAAyB;KACxC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBAC7B,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC3B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG;YACb,SAAS;YACT,MAAM;YACN,cAAc,EAAE,SAAS,CAAC,MAAM;SACjC,CAAC;QAEF,OAAO,UAAU,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
export { dualOutput, estimateTokens, compactDualOutput } from "./output.js";
|
|
2
|
-
export { run, escapeCmdArg, type RunResult, type RunOptions } from "./runner.js";
|
|
1
|
+
export { dualOutput, estimateTokens, compactDualOutput, strippedDualOutput, strippedCompactDualOutput, } from "./output.js";
|
|
2
|
+
export { run, escapeCmdArg, _buildSpawnConfig, type RunResult, type RunOptions, type SpawnConfig, } from "./runner.js";
|
|
3
3
|
export { stripAnsi } from "./ansi.js";
|
|
4
|
-
export { assertNoFlagInjection, assertValidSortKey, assertValidLogOpts, assertAllowedCommand, } from "./validation.js";
|
|
4
|
+
export { coerceJsonArray, assertNoFlagInjection, assertValidSortKey, assertValidLogOpts, assertAllowedCommand, } from "./validation.js";
|
|
5
5
|
export { INPUT_LIMITS } from "./limits.js";
|
|
6
6
|
export { compactInput, projectPathInput, repoPathInput, cwdPathInput, fixInput, pathInput, configInput, filePatternsInput, } from "./input-schemas.js";
|
|
7
7
|
export { sanitizeErrorOutput } from "./sanitize.js";
|
|
8
|
-
export { shouldRegisterTool, _resetProfileCache } from "./tool-filter.js";
|
|
9
|
-
export { PROFILES, resolveProfile } from "./profiles.js";
|
|
8
|
+
export { shouldRegisterTool, isLazyEnabled, _resetProfileCache } from "./tool-filter.js";
|
|
9
|
+
export { PROFILES, CORE_TOOLS, resolveProfile, isCoreToolForServer } from "./profiles.js";
|
|
10
10
|
export type { ProfileName } from "./profiles.js";
|
|
11
|
+
export { createLazyToolManager, type LazyToolDefinition, type LazyToolManager, } from "./lazy-tools.js";
|
|
12
|
+
export { registerDiscoverTool } from "./discover-tool.js";
|
|
11
13
|
export { assertAllowedByPolicy, assertAllowedRoot, assertNoPathQualifiedCommand, } from "./policy.js";
|
|
12
14
|
export type { ToolOutput } from "./types.js";
|
|
13
15
|
export { PareErrorCategory, PareErrorSchema, classifyError, errorOutput, invalidInputError, isCommandNotFound, isPermissionDenied, isTimeout, isNetworkError, isAuthError, isConflict, isNotFound, isAlreadyExists, isConfigurationError, } from "./errors.js";
|
|
14
16
|
export type { PareErrorCategoryType, PareError } from "./errors.js";
|
|
15
17
|
export { createServer } from "./server.js";
|
|
16
18
|
export type { CreateServerOptions } from "./server.js";
|
|
19
|
+
export { readPackageVersion } from "./version.js";
|
|
17
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,GAAG,EACH,YAAY,EACZ,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,WAAW,EACX,UAAU,EACV,UAAU,EACV,eAAe,EACf,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
export { dualOutput, estimateTokens, compactDualOutput } from "./output.js";
|
|
2
|
-
export { run, escapeCmdArg } from "./runner.js";
|
|
1
|
+
export { dualOutput, estimateTokens, compactDualOutput, strippedDualOutput, strippedCompactDualOutput, } from "./output.js";
|
|
2
|
+
export { run, escapeCmdArg, _buildSpawnConfig, } from "./runner.js";
|
|
3
3
|
export { stripAnsi } from "./ansi.js";
|
|
4
|
-
export { assertNoFlagInjection, assertValidSortKey, assertValidLogOpts, assertAllowedCommand, } from "./validation.js";
|
|
4
|
+
export { coerceJsonArray, assertNoFlagInjection, assertValidSortKey, assertValidLogOpts, assertAllowedCommand, } from "./validation.js";
|
|
5
5
|
export { INPUT_LIMITS } from "./limits.js";
|
|
6
6
|
export { compactInput, projectPathInput, repoPathInput, cwdPathInput, fixInput, pathInput, configInput, filePatternsInput, } from "./input-schemas.js";
|
|
7
7
|
export { sanitizeErrorOutput } from "./sanitize.js";
|
|
8
|
-
export { shouldRegisterTool, _resetProfileCache } from "./tool-filter.js";
|
|
9
|
-
export { PROFILES, resolveProfile } from "./profiles.js";
|
|
8
|
+
export { shouldRegisterTool, isLazyEnabled, _resetProfileCache } from "./tool-filter.js";
|
|
9
|
+
export { PROFILES, CORE_TOOLS, resolveProfile, isCoreToolForServer } from "./profiles.js";
|
|
10
|
+
export { createLazyToolManager, } from "./lazy-tools.js";
|
|
11
|
+
export { registerDiscoverTool } from "./discover-tool.js";
|
|
10
12
|
export { assertAllowedByPolicy, assertAllowedRoot, assertNoPathQualifiedCommand, } from "./policy.js";
|
|
11
13
|
export { PareErrorCategory, PareErrorSchema, classifyError, errorOutput, invalidInputError, isCommandNotFound, isPermissionDenied, isTimeout, isNetworkError, isAuthError, isConflict, isNotFound, isAlreadyExists, isConfigurationError, } from "./errors.js";
|
|
12
14
|
export { createServer } from "./server.js";
|
|
15
|
+
export { readPackageVersion } from "./version.js";
|
|
13
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,GAAG,EACH,YAAY,EACZ,iBAAiB,GAIlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EACL,qBAAqB,GAGtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,WAAW,EACX,UAAU,EACV,UAAU,EACV,eAAe,EACf,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy tool registration — allows servers to defer loading of non-core tools
|
|
3
|
+
* until they are explicitly requested via the `discover-tools` meta-tool.
|
|
4
|
+
*
|
|
5
|
+
* When `PARE_LAZY=true`, only core tools are registered at startup.
|
|
6
|
+
* Extended tools are stored as lazy definitions and can be loaded on demand,
|
|
7
|
+
* reducing the token cost of tool schemas in LLM prompts.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
/** Definition of a tool that can be lazily loaded on demand. */
|
|
11
|
+
export interface LazyToolDefinition {
|
|
12
|
+
/** Tool name as registered with the MCP server. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Short description shown in discover-tools output. */
|
|
15
|
+
description: string;
|
|
16
|
+
/** Callback that registers the full tool on the server when invoked. */
|
|
17
|
+
register: (server: McpServer) => void;
|
|
18
|
+
}
|
|
19
|
+
/** Manager for lazy/deferred tool registration. */
|
|
20
|
+
export interface LazyToolManager {
|
|
21
|
+
/** Register a tool as lazy (deferred — not yet loaded). */
|
|
22
|
+
registerLazy(def: LazyToolDefinition): void;
|
|
23
|
+
/** Get list of all lazy (not yet loaded) tools. */
|
|
24
|
+
listLazy(): Array<{
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}>;
|
|
28
|
+
/** Load a specific lazy tool by name. Returns true if the tool was found and loaded. */
|
|
29
|
+
loadTool(name: string): boolean;
|
|
30
|
+
/** Load all remaining lazy tools. Returns the count of tools loaded. */
|
|
31
|
+
loadAll(): number;
|
|
32
|
+
/** Check if any tools were deferred. */
|
|
33
|
+
hasDeferredTools(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a lazy tool manager bound to the given MCP server.
|
|
37
|
+
*
|
|
38
|
+
* The manager stores deferred tool definitions and registers them on the
|
|
39
|
+
* server when explicitly loaded. After loading, it sends the
|
|
40
|
+
* `notifications/tools/list_changed` notification so clients re-fetch the
|
|
41
|
+
* tool list.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createLazyToolManager(server: McpServer): LazyToolManager;
|
|
44
|
+
//# sourceMappingURL=lazy-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-tools.d.ts","sourceRoot":"","sources":["../src/lazy-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,gEAAgE;AAChE,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;CACvC;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5C,mDAAmD;IACnD,QAAQ,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,wEAAwE;IACxE,OAAO,IAAI,MAAM,CAAC;IAClB,wCAAwC;IACxC,gBAAgB,IAAI,OAAO,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,eAAe,CAyCxE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy tool registration — allows servers to defer loading of non-core tools
|
|
3
|
+
* until they are explicitly requested via the `discover-tools` meta-tool.
|
|
4
|
+
*
|
|
5
|
+
* When `PARE_LAZY=true`, only core tools are registered at startup.
|
|
6
|
+
* Extended tools are stored as lazy definitions and can be loaded on demand,
|
|
7
|
+
* reducing the token cost of tool schemas in LLM prompts.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Creates a lazy tool manager bound to the given MCP server.
|
|
11
|
+
*
|
|
12
|
+
* The manager stores deferred tool definitions and registers them on the
|
|
13
|
+
* server when explicitly loaded. After loading, it sends the
|
|
14
|
+
* `notifications/tools/list_changed` notification so clients re-fetch the
|
|
15
|
+
* tool list.
|
|
16
|
+
*/
|
|
17
|
+
export function createLazyToolManager(server) {
|
|
18
|
+
const pending = new Map();
|
|
19
|
+
return {
|
|
20
|
+
registerLazy(def) {
|
|
21
|
+
pending.set(def.name, def);
|
|
22
|
+
},
|
|
23
|
+
listLazy() {
|
|
24
|
+
return Array.from(pending.values()).map((d) => ({
|
|
25
|
+
name: d.name,
|
|
26
|
+
description: d.description,
|
|
27
|
+
}));
|
|
28
|
+
},
|
|
29
|
+
loadTool(name) {
|
|
30
|
+
const def = pending.get(name);
|
|
31
|
+
if (!def)
|
|
32
|
+
return false;
|
|
33
|
+
def.register(server);
|
|
34
|
+
pending.delete(name);
|
|
35
|
+
server.sendToolListChanged();
|
|
36
|
+
return true;
|
|
37
|
+
},
|
|
38
|
+
loadAll() {
|
|
39
|
+
const count = pending.size;
|
|
40
|
+
if (count === 0)
|
|
41
|
+
return 0;
|
|
42
|
+
for (const def of Array.from(pending.values())) {
|
|
43
|
+
def.register(server);
|
|
44
|
+
}
|
|
45
|
+
pending.clear();
|
|
46
|
+
server.sendToolListChanged();
|
|
47
|
+
return count;
|
|
48
|
+
},
|
|
49
|
+
hasDeferredTools() {
|
|
50
|
+
return pending.size > 0;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=lazy-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-tools.js","sourceRoot":"","sources":["../src/lazy-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA4BH;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEtD,OAAO;QACL,YAAY,CAAC,GAAuB;YAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;QAED,QAAQ;YACN,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9C,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,WAAW,EAAE,CAAC,CAAC,WAAW;aAC3B,CAAC,CAAC,CAAC;QACN,CAAC;QAED,QAAQ,CAAC,IAAY;YACnB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG;gBAAE,OAAO,KAAK,CAAC;YAEvB,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrB,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;YAC3B,IAAI,KAAK,KAAK,CAAC;gBAAE,OAAO,CAAC,CAAC;YAE1B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;gBAC/C,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,gBAAgB;YACd,OAAO,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/output.d.ts
CHANGED
|
@@ -29,4 +29,31 @@ export declare function estimateTokens(text: string): number;
|
|
|
29
29
|
* @param forceFullSchema - When true, skip auto-detection and return full data.
|
|
30
30
|
*/
|
|
31
31
|
export declare function compactDualOutput<T, C>(data: T, rawStdout: string, humanFormat: (d: T) => string, compactMap: (d: T) => C, compactFormat: (d: C) => string, forceFullSchema: boolean): ToolOutput<T | C>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a dual-output response where the formatter receives the full internal
|
|
34
|
+
* data (with extra fields for human-readable output) while structuredContent
|
|
35
|
+
* receives a clean projection that matches the output schema.
|
|
36
|
+
*
|
|
37
|
+
* Use this instead of `dualOutput` when your parsed data has Internal-only fields
|
|
38
|
+
* that should appear in human text but NOT in structuredContent.
|
|
39
|
+
*
|
|
40
|
+
* @param data - The full internal data (may contain extra fields for formatters).
|
|
41
|
+
* @param humanFormat - Formatter that receives the full internal data.
|
|
42
|
+
* @param schemaMap - Projects internal data into the clean schema shape for structuredContent.
|
|
43
|
+
*/
|
|
44
|
+
export declare function strippedDualOutput<T, S>(data: T, humanFormat: (d: T) => string, schemaMap: (d: T) => S): ToolOutput<S>;
|
|
45
|
+
/**
|
|
46
|
+
* Like `compactDualOutput` but strips Internal-only fields from the full data path
|
|
47
|
+
* using a schema projection function. This ensures structuredContent only contains
|
|
48
|
+
* fields defined in the output schema, while formatters still receive all fields.
|
|
49
|
+
*
|
|
50
|
+
* @param data - The full internal data parsed from CLI output.
|
|
51
|
+
* @param rawStdout - The ANSI-stripped stdout from the CLI command.
|
|
52
|
+
* @param humanFormat - Formatter for full data (used when not compacting).
|
|
53
|
+
* @param schemaMap - Projects internal data into clean schema shape (for non-compact mode).
|
|
54
|
+
* @param compactMap - Projects full data into a compact shape (for compact mode).
|
|
55
|
+
* @param compactFormat - Formatter for compact data.
|
|
56
|
+
* @param forceFullSchema - When true, skip auto-detection and return full data.
|
|
57
|
+
*/
|
|
58
|
+
export declare function strippedCompactDualOutput<T, S, C>(data: T, rawStdout: string, humanFormat: (d: T) => string, schemaMap: (d: T) => S, compactMap: (d: T) => C, compactFormat: (d: C) => string, forceFullSchema: boolean): ToolOutput<S | C>;
|
|
32
59
|
//# sourceMappingURL=output.d.ts.map
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAKnF;AAED;;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AI,EAAE,CAAC,EACP,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EAC7B,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GACrB,UAAU,CAAC,CAAC,CAAC,CAKf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/C,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EAC7B,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EACtB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EACvB,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EAC/B,eAAe,EAAE,OAAO,GACvB,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAcnB"}
|
package/dist/output.js
CHANGED
|
@@ -46,4 +46,47 @@ export function compactDualOutput(data, rawStdout, humanFormat, compactMap, comp
|
|
|
46
46
|
}
|
|
47
47
|
return dualOutput(data, humanFormat);
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a dual-output response where the formatter receives the full internal
|
|
51
|
+
* data (with extra fields for human-readable output) while structuredContent
|
|
52
|
+
* receives a clean projection that matches the output schema.
|
|
53
|
+
*
|
|
54
|
+
* Use this instead of `dualOutput` when your parsed data has Internal-only fields
|
|
55
|
+
* that should appear in human text but NOT in structuredContent.
|
|
56
|
+
*
|
|
57
|
+
* @param data - The full internal data (may contain extra fields for formatters).
|
|
58
|
+
* @param humanFormat - Formatter that receives the full internal data.
|
|
59
|
+
* @param schemaMap - Projects internal data into the clean schema shape for structuredContent.
|
|
60
|
+
*/
|
|
61
|
+
export function strippedDualOutput(data, humanFormat, schemaMap) {
|
|
62
|
+
return {
|
|
63
|
+
content: [{ type: "text", text: humanFormat(data) }],
|
|
64
|
+
structuredContent: schemaMap(data),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Like `compactDualOutput` but strips Internal-only fields from the full data path
|
|
69
|
+
* using a schema projection function. This ensures structuredContent only contains
|
|
70
|
+
* fields defined in the output schema, while formatters still receive all fields.
|
|
71
|
+
*
|
|
72
|
+
* @param data - The full internal data parsed from CLI output.
|
|
73
|
+
* @param rawStdout - The ANSI-stripped stdout from the CLI command.
|
|
74
|
+
* @param humanFormat - Formatter for full data (used when not compacting).
|
|
75
|
+
* @param schemaMap - Projects internal data into clean schema shape (for non-compact mode).
|
|
76
|
+
* @param compactMap - Projects full data into a compact shape (for compact mode).
|
|
77
|
+
* @param compactFormat - Formatter for compact data.
|
|
78
|
+
* @param forceFullSchema - When true, skip auto-detection and return full data.
|
|
79
|
+
*/
|
|
80
|
+
export function strippedCompactDualOutput(data, rawStdout, humanFormat, schemaMap, compactMap, compactFormat, forceFullSchema) {
|
|
81
|
+
if (forceFullSchema) {
|
|
82
|
+
return strippedDualOutput(data, humanFormat, schemaMap);
|
|
83
|
+
}
|
|
84
|
+
const structuredTokens = estimateTokens(JSON.stringify(data));
|
|
85
|
+
const rawTokens = estimateTokens(rawStdout);
|
|
86
|
+
if (structuredTokens >= rawTokens) {
|
|
87
|
+
const compact = compactMap(data);
|
|
88
|
+
return dualOutput(compact, compactFormat);
|
|
89
|
+
}
|
|
90
|
+
return strippedDualOutput(data, humanFormat, schemaMap);
|
|
91
|
+
}
|
|
49
92
|
//# sourceMappingURL=output.js.map
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAI,IAAO,EAAE,WAA6B;IAClE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,C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AAM,SAAS,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAE5C,IAAI,gBAAgB,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC,OAAO,EAAE,aAAa,CAAsB,CAAC;IACjE,CAAC;IAED,OAAO,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,CAAsB,CAAC;AAC/E,CAAC"}
|
package/dist/profiles.d.ts
CHANGED
|
@@ -14,6 +14,22 @@ export type ProfileName = "minimal" | "web" | "python" | "devops" | "rust" | "go
|
|
|
14
14
|
* for the "full" profile (no filtering).
|
|
15
15
|
*/
|
|
16
16
|
export declare const PROFILES: Record<ProfileName, readonly string[] | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Core tools per server — the most commonly used tools that should always
|
|
19
|
+
* load immediately, even when lazy mode (`PARE_LAZY=true`) is active.
|
|
20
|
+
*
|
|
21
|
+
* Tools not listed here will be deferred and discoverable via the
|
|
22
|
+
* `discover-tools` meta-tool.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CORE_TOOLS: Record<string, readonly string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether a tool is in the core set for a given server.
|
|
27
|
+
*
|
|
28
|
+
* @param serverName - The server identifier (e.g., "git", "npm").
|
|
29
|
+
* @param toolName - The tool name (e.g., "status", "install").
|
|
30
|
+
* @returns `true` if the tool is a core tool, `false` otherwise.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isCoreToolForServer(serverName: string, toolName: string): boolean;
|
|
17
33
|
/**
|
|
18
34
|
* Reads `PARE_PROFILE` and returns a `Set<string>` of allowed `server:tool`
|
|
19
35
|
* entries, or `null` if all tools should be enabled.
|
package/dist/profiles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2BAA2B;AAC3B,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAgTlE,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2BAA2B;AAC3B,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAgTlE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAqCxD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAIjF;AAKD;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CA6BnD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|
package/dist/profiles.js
CHANGED
|
@@ -310,6 +310,64 @@ export const PROFILES = {
|
|
|
310
310
|
],
|
|
311
311
|
full: null,
|
|
312
312
|
};
|
|
313
|
+
/**
|
|
314
|
+
* Core tools per server — the most commonly used tools that should always
|
|
315
|
+
* load immediately, even when lazy mode (`PARE_LAZY=true`) is active.
|
|
316
|
+
*
|
|
317
|
+
* Tools not listed here will be deferred and discoverable via the
|
|
318
|
+
* `discover-tools` meta-tool.
|
|
319
|
+
*/
|
|
320
|
+
export const CORE_TOOLS = {
|
|
321
|
+
git: ["status", "log", "diff", "commit", "push", "pull", "checkout", "branch", "add"],
|
|
322
|
+
github: [
|
|
323
|
+
"pr-view",
|
|
324
|
+
"pr-list",
|
|
325
|
+
"pr-create",
|
|
326
|
+
"pr-checks",
|
|
327
|
+
"issue-view",
|
|
328
|
+
"issue-list",
|
|
329
|
+
"issue-create",
|
|
330
|
+
],
|
|
331
|
+
npm: ["install", "run", "test", "audit", "list"],
|
|
332
|
+
docker: ["ps", "build", "logs", "images", "compose-up", "compose-down"],
|
|
333
|
+
build: ["tsc", "build"],
|
|
334
|
+
test: ["run", "coverage"],
|
|
335
|
+
lint: ["lint", "format-check", "prettier-format"],
|
|
336
|
+
search: ["search", "find", "count"],
|
|
337
|
+
cargo: ["build", "test", "clippy", "run", "check"],
|
|
338
|
+
go: ["build", "test", "vet", "run", "mod-tidy", "fmt"],
|
|
339
|
+
python: ["pip-install", "pip-list", "pytest", "ruff-check", "uv-run"],
|
|
340
|
+
k8s: ["get", "describe", "logs"],
|
|
341
|
+
http: ["get", "post", "request"],
|
|
342
|
+
security: ["trivy", "semgrep"],
|
|
343
|
+
make: ["run", "list"],
|
|
344
|
+
process: ["run"],
|
|
345
|
+
bun: ["run", "test", "build", "install"],
|
|
346
|
+
deno: ["run", "test", "fmt", "lint"],
|
|
347
|
+
dotnet: ["build", "test", "run"],
|
|
348
|
+
infra: ["plan", "validate", "init"],
|
|
349
|
+
jvm: ["gradle-build", "gradle-test", "maven-build", "maven-test"],
|
|
350
|
+
nix: ["build", "run", "develop"],
|
|
351
|
+
remote: ["ssh-run", "ssh-test"],
|
|
352
|
+
ruby: ["run", "check", "bundle-install", "bundle-exec"],
|
|
353
|
+
swift: ["build", "test", "run"],
|
|
354
|
+
db: ["psql-query", "psql-list-databases", "mysql-query", "mysql-list-databases"],
|
|
355
|
+
bazel: ["bazel"],
|
|
356
|
+
cmake: ["cmake"],
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Checks whether a tool is in the core set for a given server.
|
|
360
|
+
*
|
|
361
|
+
* @param serverName - The server identifier (e.g., "git", "npm").
|
|
362
|
+
* @param toolName - The tool name (e.g., "status", "install").
|
|
363
|
+
* @returns `true` if the tool is a core tool, `false` otherwise.
|
|
364
|
+
*/
|
|
365
|
+
export function isCoreToolForServer(serverName, toolName) {
|
|
366
|
+
const core = CORE_TOOLS[serverName];
|
|
367
|
+
if (!core)
|
|
368
|
+
return true; // Unknown server — treat all as core.
|
|
369
|
+
return core.includes(toolName);
|
|
370
|
+
}
|
|
313
371
|
/** Module-level cache for the resolved profile Set. */
|
|
314
372
|
let profileCache;
|
|
315
373
|
/**
|
package/dist/profiles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkD;IACrE,OAAO,EAAE;QACP,YAAY;QACZ,SAAS;QACT,UAAU;QACV,SAAS;QACT,YAAY;QACZ,UAAU;QACV,UAAU;QACV,cAAc;QACd,YAAY;QACZ,UAAU;QACV,aAAa;QACb,WAAW;QACX,eAAe;QACf,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,aAAa;KACd;IAED,GAAG,EAAE;QACH,YAAY;QACZ,SAAS;QACT,eAAe;QACf,UAAU;QACV,YAAY;QACZ,UAAU;QACV,SAAS;QACT,YAAY;QACZ,UAAU;QACV,UAAU;QACV,cAAc;QACd,WAAW;QACX,YAAY;QACZ,WAAW;QACX,gBAAgB;QAChB,WAAW;QACX,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,iBAAiB;QACjB,mBAAmB;QACnB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,gBAAgB;QAChB,mBAAmB;QACnB,m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,CACzG,CAAC;QACF,YAAY,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,iCAAiC;QACjC,YAAY,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,YAAY,GAAG,SAAS,CAAC;AAC3B,CAAC"}
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkD;IACrE,OAAO,EAAE;QACP,YAAY;QACZ,SAAS;QACT,UAAU;QACV,SAAS;QACT,YAAY;QACZ,UAAU;QACV,UAAU;QACV,cAAc;QACd,YAAY;QACZ,UAAU;QACV,aAAa;QACb,WAAW;QACX,eAAe;QACf,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,aAAa;KACd;IAED,GAAG,EAAE;QACH,YAAY;QACZ,SAAS;QACT,eAAe;QACf,UAAU;QACV,YAAY;QACZ,UAAU;QACV,SAAS;QACT,YAAY;QACZ,UAAU;QACV,UAAU;QACV,cAAc;QACd,WAAW;QACX,YAAY;QACZ,WAAW;QACX,gBAAgB;QAChB,WAAW;QACX,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,iBAAiB;QACjB,mBAAmB;QACnB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,gBAAgB;QAChB,mBAAmB;QACnB,mBAAmB;QACnB,qBAAqB;QACrB,oBAAoB;QACpB,sBAAsB;QACtB,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;QACb,WAAW;QACX,cAAc;QACd,UAAU;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package/dist/runner.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export interface RunOptions {
|
|
|
7
7
|
* (e.g., `git commit --file -`) instead of passing it as a command arg,
|
|
8
8
|
* which avoids cmd.exe argument-length and newline limitations on Windows. */
|
|
9
9
|
stdin?: string;
|
|
10
|
-
/** Override shell mode. Defaults to `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
/** Override shell mode. Defaults to `false` on all platforms. On Windows,
|
|
11
|
+
* .cmd/.bat wrappers are automatically handled via cmd.exe invocation without
|
|
12
|
+
* shell mode. Set to `true` only when you need shell features (pipes, globs). */
|
|
13
13
|
shell?: boolean;
|
|
14
14
|
/** Maximum combined stdout+stderr buffer size in bytes. Defaults to 10 MB. */
|
|
15
15
|
maxBuffer?: number;
|
|
@@ -45,14 +45,40 @@ export interface RunResult {
|
|
|
45
45
|
* they are literal, and outside quotes they rarely appear in tool args.
|
|
46
46
|
*/
|
|
47
47
|
export declare function escapeCmdArg(arg: string): string;
|
|
48
|
+
/** Configuration for how to invoke `spawn()`. @internal — exported for testing only. */
|
|
49
|
+
export interface SpawnConfig {
|
|
50
|
+
command: string;
|
|
51
|
+
args: string[];
|
|
52
|
+
shell: boolean;
|
|
53
|
+
windowsVerbatimArguments: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Determines how to spawn a command, handling Windows .cmd/.bat wrappers
|
|
57
|
+
* without using `shell: true` (which triggers CodeQL alert #16).
|
|
58
|
+
*
|
|
59
|
+
* @internal — Exported for unit testing only. Use `run()` instead.
|
|
60
|
+
*
|
|
61
|
+
* Branches:
|
|
62
|
+
* 1. Explicit `shell: true` — pass cmd directly, don't resolve (caller wants shell features)
|
|
63
|
+
* 2. Windows native .exe/.com — spawn resolved path directly
|
|
64
|
+
* 3. Windows non-exe (cmd/bat/extensionless/bare) — cmd.exe /d /s /c with windowsVerbatimArguments
|
|
65
|
+
* 4. Unix — spawn cmd directly, execvp handles PATH
|
|
66
|
+
*/
|
|
67
|
+
export declare function _buildSpawnConfig(cmd: string, args: string[], opts?: {
|
|
68
|
+
shell?: boolean;
|
|
69
|
+
}, platform?: string, resolver?: (cmd: string) => string): SpawnConfig;
|
|
48
70
|
/**
|
|
49
71
|
* Executes a command and returns cleaned output with ANSI codes stripped.
|
|
50
72
|
* Uses spawn (not exec) to avoid shell injection. The child is spawned in its
|
|
51
73
|
* own process group (`detached: true` on Unix) so that on timeout we can kill
|
|
52
74
|
* the entire group — preventing orphaned grandchild processes.
|
|
53
75
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
76
|
+
* Shell mode defaults to `false` on all platforms. On Windows, .cmd/.bat
|
|
77
|
+
* wrappers (like npm, npx) are automatically handled via cmd.exe invocation
|
|
78
|
+
* with windowsVerbatimArguments (cross-spawn pattern), avoiding shell injection.
|
|
79
|
+
*
|
|
80
|
+
* Callers can opt in to `shell: true` for shell features (pipes, globs),
|
|
81
|
+
* but this bypasses security protections — use only with trusted input.
|
|
56
82
|
*
|
|
57
83
|
* Throws on system-level errors (command not found, permission denied, timeout).
|
|
58
84
|
* Normal non-zero exit codes are returned in the result, not thrown.
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAiDA,uGAAuG;AACvG,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;mFAE+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;sFAEkF;IAClF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB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