@liangjie559567/ultrapower 5.5.13 → 5.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +79 -3
- package/bridge/mcp-server.cjs +646 -81
- package/dist/hooks/bridge-normalize.d.ts.map +1 -1
- package/dist/hooks/bridge-normalize.js +2 -0
- package/dist/hooks/bridge-normalize.js.map +1 -1
- package/dist/lib/path-validator.d.ts.map +1 -1
- package/dist/lib/path-validator.js +7 -0
- package/dist/lib/path-validator.js.map +1 -1
- package/dist/mcp/adapters/ast-adapter.d.ts +90 -0
- package/dist/mcp/adapters/ast-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/ast-adapter.js +36 -0
- package/dist/mcp/adapters/ast-adapter.js.map +1 -0
- package/dist/mcp/adapters/lsp-adapter.d.ts +6 -0
- package/dist/mcp/adapters/lsp-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/lsp-adapter.js +6 -0
- package/dist/mcp/adapters/lsp-adapter.js.map +1 -0
- package/dist/mcp/adapters/memory-adapter.d.ts +156 -0
- package/dist/mcp/adapters/memory-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/memory-adapter.js +59 -0
- package/dist/mcp/adapters/memory-adapter.js.map +1 -0
- package/dist/mcp/adapters/notepad-adapter.d.ts +115 -0
- package/dist/mcp/adapters/notepad-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/notepad-adapter.js +78 -0
- package/dist/mcp/adapters/notepad-adapter.js.map +1 -0
- package/dist/mcp/adapters/python-adapter.d.ts +46 -0
- package/dist/mcp/adapters/python-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/python-adapter.js +44 -0
- package/dist/mcp/adapters/python-adapter.js.map +1 -0
- package/dist/mcp/adapters/skills-adapter.d.ts +37 -0
- package/dist/mcp/adapters/skills-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/skills-adapter.js +35 -0
- package/dist/mcp/adapters/skills-adapter.js.map +1 -0
- package/dist/mcp/adapters/state-adapter.d.ts +209 -0
- package/dist/mcp/adapters/state-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/state-adapter.js +82 -0
- package/dist/mcp/adapters/state-adapter.js.map +1 -0
- package/dist/mcp/adapters/trace-adapter.d.ts +67 -0
- package/dist/mcp/adapters/trace-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/trace-adapter.js +30 -0
- package/dist/mcp/adapters/trace-adapter.js.map +1 -0
- package/dist/mcp/client/MCPClient.d.ts +22 -0
- package/dist/mcp/client/MCPClient.d.ts.map +1 -0
- package/dist/mcp/client/MCPClient.js +89 -0
- package/dist/mcp/client/MCPClient.js.map +1 -0
- package/dist/mcp/client.d.ts +19 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +34 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/config/config-loader.d.ts +6 -0
- package/dist/mcp/config/config-loader.d.ts.map +1 -0
- package/dist/mcp/config/config-loader.js +16 -0
- package/dist/mcp/config/config-loader.js.map +1 -0
- package/dist/mcp/config/env-replacer.d.ts +10 -0
- package/dist/mcp/config/env-replacer.d.ts.map +1 -0
- package/dist/mcp/config/env-replacer.js +29 -0
- package/dist/mcp/config/env-replacer.js.map +1 -0
- package/dist/mcp/config/loader.d.ts +6 -0
- package/dist/mcp/config/loader.d.ts.map +1 -0
- package/dist/mcp/config/loader.js +51 -0
- package/dist/mcp/config/loader.js.map +1 -0
- package/dist/mcp/config/schema.d.ts +63 -0
- package/dist/mcp/config/schema.d.ts.map +1 -0
- package/dist/mcp/config/schema.js +15 -0
- package/dist/mcp/config/schema.js.map +1 -0
- package/dist/mcp/config-loader.d.ts +6 -0
- package/dist/mcp/config-loader.d.ts.map +1 -0
- package/dist/mcp/config-loader.js +66 -0
- package/dist/mcp/config-loader.js.map +1 -0
- package/dist/mcp/config-schema.d.ts +64 -0
- package/dist/mcp/config-schema.d.ts.map +1 -0
- package/dist/mcp/config-schema.js +18 -0
- package/dist/mcp/config-schema.js.map +1 -0
- package/dist/mcp/logger.d.ts +7 -0
- package/dist/mcp/logger.d.ts.map +1 -0
- package/dist/mcp/logger.js +19 -0
- package/dist/mcp/logger.js.map +1 -0
- package/dist/mcp/namespace-manager.d.ts +25 -0
- package/dist/mcp/namespace-manager.d.ts.map +1 -0
- package/dist/mcp/namespace-manager.js +26 -0
- package/dist/mcp/namespace-manager.js.map +1 -0
- package/dist/mcp/namespace.d.ts +26 -0
- package/dist/mcp/namespace.d.ts.map +1 -0
- package/dist/mcp/namespace.js +56 -0
- package/dist/mcp/namespace.js.map +1 -0
- package/dist/mcp/retry-client.d.ts +22 -0
- package/dist/mcp/retry-client.d.ts.map +1 -0
- package/dist/mcp/retry-client.js +58 -0
- package/dist/mcp/retry-client.js.map +1 -0
- package/dist/mcp/standalone-server.js +5 -41
- package/dist/mcp/standalone-server.js.map +1 -1
- package/dist/mcp/timeout.d.ts +8 -0
- package/dist/mcp/timeout.d.ts.map +1 -0
- package/dist/mcp/timeout.js +14 -0
- package/dist/mcp/timeout.js.map +1 -0
- package/dist/mcp/tool-handler.d.ts +14 -0
- package/dist/mcp/tool-handler.d.ts.map +1 -0
- package/dist/mcp/tool-handler.js +32 -0
- package/dist/mcp/tool-handler.js.map +1 -0
- package/dist/mcp/tool-resolver.d.ts +13 -0
- package/dist/mcp/tool-resolver.d.ts.map +1 -0
- package/dist/mcp/tool-resolver.js +30 -0
- package/dist/mcp/tool-resolver.js.map +1 -0
- package/dist/tools/index.d.ts +7 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +32 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/tool-prefix-migration.d.ts +18 -0
- package/dist/tools/tool-prefix-migration.d.ts.map +1 -0
- package/dist/tools/tool-prefix-migration.js +80 -0
- package/dist/tools/tool-prefix-migration.js.map +1 -0
- package/docs/AGENTS.md +81 -89
- package/docs/CLAUDE.md +1 -1
- package/docs/DOCUMENTATION_UPDATE_SUMMARY.md +97 -0
- package/docs/INSTALL.md +5 -5
- package/docs/INSTALL_FIX_SUMMARY.md +97 -0
- package/docs/INSTALL_FIX_VERIFICATION.md +61 -0
- package/docs/INSTALL_VERIFICATION_REPORT.md +68 -0
- package/docs/LOCAL_INSTALL_VERIFICATION.md +159 -0
- package/docs/LOCAL_TEST_INSTALL_REPORT.md +96 -0
- package/docs/MAIN_DOCS_UPDATE_REPORT.md +41 -0
- package/docs/PLUGIN_MARKETPLACE_VERIFICATION.md +187 -0
- package/docs/REFERENCE.md +71 -0
- package/docs/RELEASE_NOTES_v5.5.14.md +97 -0
- package/docs/UPGRADE_VERIFICATION.md +500 -0
- package/docs/UPGRADE_VERIFICATION_REPORT.md +96 -0
- package/docs/VERIFICATION_SUMMARY.md +116 -0
- package/docs/guides/mcp-server-usage.md +240 -0
- package/docs/guides/tool-name-migration.md +97 -0
- package/docs/guides/v5.5.13-new-features.md +234 -0
- package/docs/mcp/README.md +82 -0
- package/docs/mcp/client-guide.md +337 -0
- package/docs/mcp/configuration.md +292 -0
- package/docs/mcp/overview.md +204 -0
- package/docs/mcp/performance.md +300 -0
- package/docs/mcp/server-guide.md +300 -0
- package/docs/mcp-compatibility-matrix.md +52 -0
- package/docs/plans/2026-03-05-mcp-adoption-atomic-tasks.md +1436 -0
- package/docs/plans/2026-03-05-mcp-adoption-plan.md +531 -0
- package/package.json +1 -1
- package/scripts/migrate-tool-names.js +100 -0
- package/scripts/verify-all.sh +122 -0
- package/scripts/verify-install.sh +89 -0
- package/skills/AGENTS.md +98 -28
package/bridge/mcp-server.cjs
CHANGED
|
@@ -2245,8 +2245,8 @@ var require_resolve = __commonJS({
|
|
|
2245
2245
|
}
|
|
2246
2246
|
return count;
|
|
2247
2247
|
}
|
|
2248
|
-
function getFullPath(resolver, id = "",
|
|
2249
|
-
if (
|
|
2248
|
+
function getFullPath(resolver, id = "", normalize6) {
|
|
2249
|
+
if (normalize6 !== false)
|
|
2250
2250
|
id = normalizeId(id);
|
|
2251
2251
|
const p = resolver.parse(id);
|
|
2252
2252
|
return _getFullPath(resolver, p);
|
|
@@ -2994,7 +2994,7 @@ var require_compile = __commonJS({
|
|
|
2994
2994
|
const schOrFunc = root.refs[ref];
|
|
2995
2995
|
if (schOrFunc)
|
|
2996
2996
|
return schOrFunc;
|
|
2997
|
-
let _sch =
|
|
2997
|
+
let _sch = resolve6.call(this, root, ref);
|
|
2998
2998
|
if (_sch === void 0) {
|
|
2999
2999
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
3000
3000
|
const { schemaId } = this.opts;
|
|
@@ -3021,7 +3021,7 @@ var require_compile = __commonJS({
|
|
|
3021
3021
|
function sameSchemaEnv(s1, s2) {
|
|
3022
3022
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3023
3023
|
}
|
|
3024
|
-
function
|
|
3024
|
+
function resolve6(root, ref) {
|
|
3025
3025
|
let sch;
|
|
3026
3026
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3027
3027
|
ref = sch;
|
|
@@ -3586,7 +3586,7 @@ var require_fast_uri = __commonJS({
|
|
|
3586
3586
|
"use strict";
|
|
3587
3587
|
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
|
|
3588
3588
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
3589
|
-
function
|
|
3589
|
+
function normalize6(uri, options) {
|
|
3590
3590
|
if (typeof uri === "string") {
|
|
3591
3591
|
uri = /** @type {T} */
|
|
3592
3592
|
serialize(parse5(uri, options), options);
|
|
@@ -3596,55 +3596,55 @@ var require_fast_uri = __commonJS({
|
|
|
3596
3596
|
}
|
|
3597
3597
|
return uri;
|
|
3598
3598
|
}
|
|
3599
|
-
function
|
|
3599
|
+
function resolve6(baseURI, relativeURI, options) {
|
|
3600
3600
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3601
3601
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
3602
3602
|
schemelessOptions.skipEscape = true;
|
|
3603
3603
|
return serialize(resolved, schemelessOptions);
|
|
3604
3604
|
}
|
|
3605
|
-
function resolveComponent(base,
|
|
3605
|
+
function resolveComponent(base, relative4, options, skipNormalization) {
|
|
3606
3606
|
const target = {};
|
|
3607
3607
|
if (!skipNormalization) {
|
|
3608
3608
|
base = parse5(serialize(base, options), options);
|
|
3609
|
-
|
|
3609
|
+
relative4 = parse5(serialize(relative4, options), options);
|
|
3610
3610
|
}
|
|
3611
3611
|
options = options || {};
|
|
3612
|
-
if (!options.tolerant &&
|
|
3613
|
-
target.scheme =
|
|
3614
|
-
target.userinfo =
|
|
3615
|
-
target.host =
|
|
3616
|
-
target.port =
|
|
3617
|
-
target.path = removeDotSegments(
|
|
3618
|
-
target.query =
|
|
3612
|
+
if (!options.tolerant && relative4.scheme) {
|
|
3613
|
+
target.scheme = relative4.scheme;
|
|
3614
|
+
target.userinfo = relative4.userinfo;
|
|
3615
|
+
target.host = relative4.host;
|
|
3616
|
+
target.port = relative4.port;
|
|
3617
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
3618
|
+
target.query = relative4.query;
|
|
3619
3619
|
} else {
|
|
3620
|
-
if (
|
|
3621
|
-
target.userinfo =
|
|
3622
|
-
target.host =
|
|
3623
|
-
target.port =
|
|
3624
|
-
target.path = removeDotSegments(
|
|
3625
|
-
target.query =
|
|
3620
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
3621
|
+
target.userinfo = relative4.userinfo;
|
|
3622
|
+
target.host = relative4.host;
|
|
3623
|
+
target.port = relative4.port;
|
|
3624
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
3625
|
+
target.query = relative4.query;
|
|
3626
3626
|
} else {
|
|
3627
|
-
if (!
|
|
3627
|
+
if (!relative4.path) {
|
|
3628
3628
|
target.path = base.path;
|
|
3629
|
-
if (
|
|
3630
|
-
target.query =
|
|
3629
|
+
if (relative4.query !== void 0) {
|
|
3630
|
+
target.query = relative4.query;
|
|
3631
3631
|
} else {
|
|
3632
3632
|
target.query = base.query;
|
|
3633
3633
|
}
|
|
3634
3634
|
} else {
|
|
3635
|
-
if (
|
|
3636
|
-
target.path = removeDotSegments(
|
|
3635
|
+
if (relative4.path[0] === "/") {
|
|
3636
|
+
target.path = removeDotSegments(relative4.path);
|
|
3637
3637
|
} else {
|
|
3638
3638
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
3639
|
-
target.path = "/" +
|
|
3639
|
+
target.path = "/" + relative4.path;
|
|
3640
3640
|
} else if (!base.path) {
|
|
3641
|
-
target.path =
|
|
3641
|
+
target.path = relative4.path;
|
|
3642
3642
|
} else {
|
|
3643
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
3643
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
|
|
3644
3644
|
}
|
|
3645
3645
|
target.path = removeDotSegments(target.path);
|
|
3646
3646
|
}
|
|
3647
|
-
target.query =
|
|
3647
|
+
target.query = relative4.query;
|
|
3648
3648
|
}
|
|
3649
3649
|
target.userinfo = base.userinfo;
|
|
3650
3650
|
target.host = base.host;
|
|
@@ -3652,7 +3652,7 @@ var require_fast_uri = __commonJS({
|
|
|
3652
3652
|
}
|
|
3653
3653
|
target.scheme = base.scheme;
|
|
3654
3654
|
}
|
|
3655
|
-
target.fragment =
|
|
3655
|
+
target.fragment = relative4.fragment;
|
|
3656
3656
|
return target;
|
|
3657
3657
|
}
|
|
3658
3658
|
function equal(uriA, uriB, options) {
|
|
@@ -3822,8 +3822,8 @@ var require_fast_uri = __commonJS({
|
|
|
3822
3822
|
}
|
|
3823
3823
|
var fastUri = {
|
|
3824
3824
|
SCHEMES,
|
|
3825
|
-
normalize:
|
|
3826
|
-
resolve:
|
|
3825
|
+
normalize: normalize6,
|
|
3826
|
+
resolve: resolve6,
|
|
3827
3827
|
resolveComponent,
|
|
3828
3828
|
equal,
|
|
3829
3829
|
serialize,
|
|
@@ -16674,7 +16674,7 @@ var Protocol = class {
|
|
|
16674
16674
|
return;
|
|
16675
16675
|
}
|
|
16676
16676
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16677
|
-
await new Promise((
|
|
16677
|
+
await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
|
|
16678
16678
|
options?.signal?.throwIfAborted();
|
|
16679
16679
|
}
|
|
16680
16680
|
} catch (error2) {
|
|
@@ -16691,7 +16691,7 @@ var Protocol = class {
|
|
|
16691
16691
|
*/
|
|
16692
16692
|
request(request, resultSchema, options) {
|
|
16693
16693
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
16694
|
-
return new Promise((
|
|
16694
|
+
return new Promise((resolve6, reject) => {
|
|
16695
16695
|
const earlyReject = (error2) => {
|
|
16696
16696
|
reject(error2);
|
|
16697
16697
|
};
|
|
@@ -16769,7 +16769,7 @@ var Protocol = class {
|
|
|
16769
16769
|
if (!parseResult.success) {
|
|
16770
16770
|
reject(parseResult.error);
|
|
16771
16771
|
} else {
|
|
16772
|
-
|
|
16772
|
+
resolve6(parseResult.data);
|
|
16773
16773
|
}
|
|
16774
16774
|
} catch (error2) {
|
|
16775
16775
|
reject(error2);
|
|
@@ -17030,12 +17030,12 @@ var Protocol = class {
|
|
|
17030
17030
|
}
|
|
17031
17031
|
} catch {
|
|
17032
17032
|
}
|
|
17033
|
-
return new Promise((
|
|
17033
|
+
return new Promise((resolve6, reject) => {
|
|
17034
17034
|
if (signal.aborted) {
|
|
17035
17035
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
17036
17036
|
return;
|
|
17037
17037
|
}
|
|
17038
|
-
const timeoutId = setTimeout(
|
|
17038
|
+
const timeoutId = setTimeout(resolve6, interval);
|
|
17039
17039
|
signal.addEventListener("abort", () => {
|
|
17040
17040
|
clearTimeout(timeoutId);
|
|
17041
17041
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -17764,12 +17764,12 @@ var StdioServerTransport = class {
|
|
|
17764
17764
|
this.onclose?.();
|
|
17765
17765
|
}
|
|
17766
17766
|
send(message) {
|
|
17767
|
-
return new Promise((
|
|
17767
|
+
return new Promise((resolve6) => {
|
|
17768
17768
|
const json = serializeMessage(message);
|
|
17769
17769
|
if (this._stdout.write(json)) {
|
|
17770
|
-
|
|
17770
|
+
resolve6();
|
|
17771
17771
|
} else {
|
|
17772
|
-
this._stdout.once("drain",
|
|
17772
|
+
this._stdout.once("drain", resolve6);
|
|
17773
17773
|
}
|
|
17774
17774
|
});
|
|
17775
17775
|
}
|
|
@@ -17972,7 +17972,7 @@ var LspClient = class {
|
|
|
17972
17972
|
Install with: ${this.serverConfig.installHint}`
|
|
17973
17973
|
);
|
|
17974
17974
|
}
|
|
17975
|
-
return new Promise((
|
|
17975
|
+
return new Promise((resolve6, reject) => {
|
|
17976
17976
|
this.process = (0, import_child_process2.spawn)(this.serverConfig.command, this.serverConfig.args, {
|
|
17977
17977
|
cwd: this.workspaceRoot,
|
|
17978
17978
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -17998,7 +17998,7 @@ Install with: ${this.serverConfig.installHint}`
|
|
|
17998
17998
|
});
|
|
17999
17999
|
this.initialize().then(() => {
|
|
18000
18000
|
this.initialized = true;
|
|
18001
|
-
|
|
18001
|
+
resolve6();
|
|
18002
18002
|
}).catch(reject);
|
|
18003
18003
|
});
|
|
18004
18004
|
}
|
|
@@ -18106,13 +18106,13 @@ Install with: ${this.serverConfig.installHint}`
|
|
|
18106
18106
|
const message = `Content-Length: ${Buffer.byteLength(content)}\r
|
|
18107
18107
|
\r
|
|
18108
18108
|
${content}`;
|
|
18109
|
-
return new Promise((
|
|
18109
|
+
return new Promise((resolve6, reject) => {
|
|
18110
18110
|
const timeoutHandle = setTimeout(() => {
|
|
18111
18111
|
this.pendingRequests.delete(id);
|
|
18112
18112
|
reject(new Error(`LSP request '${method}' timed out after ${timeout}ms`));
|
|
18113
18113
|
}, timeout);
|
|
18114
18114
|
this.pendingRequests.set(id, {
|
|
18115
|
-
resolve:
|
|
18115
|
+
resolve: resolve6,
|
|
18116
18116
|
reject,
|
|
18117
18117
|
timeout: timeoutHandle
|
|
18118
18118
|
});
|
|
@@ -18181,7 +18181,7 @@ ${content}`;
|
|
|
18181
18181
|
}
|
|
18182
18182
|
});
|
|
18183
18183
|
this.openDocuments.add(uri);
|
|
18184
|
-
await new Promise((
|
|
18184
|
+
await new Promise((resolve6) => setTimeout(resolve6, 100));
|
|
18185
18185
|
}
|
|
18186
18186
|
/**
|
|
18187
18187
|
* Close a document
|
|
@@ -18783,7 +18783,7 @@ async function runLspAggregatedDiagnostics(directory, extensions = [".ts", ".tsx
|
|
|
18783
18783
|
try {
|
|
18784
18784
|
await lspClientManager.runWithClientLease(file, async (client) => {
|
|
18785
18785
|
await client.openDocument(file);
|
|
18786
|
-
await new Promise((
|
|
18786
|
+
await new Promise((resolve6) => setTimeout(resolve6, LSP_DIAGNOSTICS_WAIT_MS));
|
|
18787
18787
|
const diagnostics = client.getDiagnostics(file);
|
|
18788
18788
|
for (const diagnostic of diagnostics) {
|
|
18789
18789
|
allDiagnostics.push({
|
|
@@ -19033,7 +19033,7 @@ var lspDiagnosticsTool = {
|
|
|
19033
19033
|
const { file, severity } = args;
|
|
19034
19034
|
return withLspClient(file, "diagnostics", async (client) => {
|
|
19035
19035
|
await client.openDocument(file);
|
|
19036
|
-
await new Promise((
|
|
19036
|
+
await new Promise((resolve6) => setTimeout(resolve6, LSP_DIAGNOSTICS_WAIT_MS));
|
|
19037
19037
|
let diagnostics = client.getDiagnostics(file);
|
|
19038
19038
|
if (severity) {
|
|
19039
19039
|
const severityMap = {
|
|
@@ -20287,7 +20287,7 @@ var SessionLock = class {
|
|
|
20287
20287
|
}
|
|
20288
20288
|
};
|
|
20289
20289
|
function sleep(ms) {
|
|
20290
|
-
return new Promise((
|
|
20290
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
20291
20291
|
}
|
|
20292
20292
|
|
|
20293
20293
|
// src/tools/python-repl/socket-client.ts
|
|
@@ -20317,7 +20317,7 @@ var JsonRpcError = class extends Error {
|
|
|
20317
20317
|
}
|
|
20318
20318
|
};
|
|
20319
20319
|
async function sendSocketRequest(socketPath, method, params, timeout = 6e4) {
|
|
20320
|
-
return new Promise((
|
|
20320
|
+
return new Promise((resolve6, reject) => {
|
|
20321
20321
|
const id = (0, import_crypto.randomUUID)();
|
|
20322
20322
|
const request = {
|
|
20323
20323
|
jsonrpc: "2.0",
|
|
@@ -20381,7 +20381,7 @@ async function sendSocketRequest(socketPath, method, params, timeout = 6e4) {
|
|
|
20381
20381
|
));
|
|
20382
20382
|
return;
|
|
20383
20383
|
}
|
|
20384
|
-
|
|
20384
|
+
resolve6(response.result);
|
|
20385
20385
|
} catch (e) {
|
|
20386
20386
|
reject(new Error(
|
|
20387
20387
|
`Failed to parse JSON-RPC response: ${e.message}`
|
|
@@ -20702,7 +20702,7 @@ async function deleteBridgeMeta(sessionId) {
|
|
|
20702
20702
|
}
|
|
20703
20703
|
}
|
|
20704
20704
|
function sleep2(ms) {
|
|
20705
|
-
return new Promise((
|
|
20705
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
20706
20706
|
}
|
|
20707
20707
|
|
|
20708
20708
|
// src/tools/python-repl/tool.ts
|
|
@@ -21144,6 +21144,33 @@ function resetExecutionCounter(sessionId) {
|
|
|
21144
21144
|
executionCounters.delete(sessionId);
|
|
21145
21145
|
}
|
|
21146
21146
|
|
|
21147
|
+
// src/tools/python-repl/index.ts
|
|
21148
|
+
var pythonReplTool2 = {
|
|
21149
|
+
name: "python_repl",
|
|
21150
|
+
description: `Execute Python code in a persistent REPL environment with variable persistence across invocations.
|
|
21151
|
+
|
|
21152
|
+
Actions:
|
|
21153
|
+
- execute: Run Python code (variables persist between calls)
|
|
21154
|
+
- reset: Clear namespace and reset environment
|
|
21155
|
+
- get_state: Get memory usage and list of defined variables
|
|
21156
|
+
- interrupt: Stop long-running execution
|
|
21157
|
+
|
|
21158
|
+
Features:
|
|
21159
|
+
- Variables persist across tool calls within the same session
|
|
21160
|
+
- Structured output markers: [OBJECTIVE], [DATA], [FINDING], [STAT:*], [LIMITATION]
|
|
21161
|
+
- Memory tracking (RSS/VMS)
|
|
21162
|
+
- Automatic timeout handling (default 5 minutes)
|
|
21163
|
+
- Session locking for safe concurrent access
|
|
21164
|
+
|
|
21165
|
+
Use this instead of Bash heredocs when you need:
|
|
21166
|
+
- Multi-step analysis with state persistence
|
|
21167
|
+
- Large datasets that shouldn't be reloaded
|
|
21168
|
+
- Iterative ML model training
|
|
21169
|
+
- Any workflow benefiting from Python state persistence`,
|
|
21170
|
+
schema: pythonReplSchema,
|
|
21171
|
+
handler: pythonReplHandler
|
|
21172
|
+
};
|
|
21173
|
+
|
|
21147
21174
|
// src/tools/state-tools.ts
|
|
21148
21175
|
var import_fs8 = require("fs");
|
|
21149
21176
|
|
|
@@ -23840,16 +23867,573 @@ No events recorded.`
|
|
|
23840
23867
|
};
|
|
23841
23868
|
var traceTools = [traceTimelineTool, traceSummaryTool];
|
|
23842
23869
|
|
|
23843
|
-
// src/
|
|
23844
|
-
var
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
|
|
23851
|
-
|
|
23870
|
+
// src/tools/skills-tools.ts
|
|
23871
|
+
var import_path22 = require("path");
|
|
23872
|
+
var import_os4 = require("os");
|
|
23873
|
+
|
|
23874
|
+
// src/hooks/learner/loader.ts
|
|
23875
|
+
var import_fs15 = require("fs");
|
|
23876
|
+
var import_crypto3 = require("crypto");
|
|
23877
|
+
var import_path21 = require("path");
|
|
23878
|
+
|
|
23879
|
+
// src/hooks/learner/finder.ts
|
|
23880
|
+
var import_fs14 = require("fs");
|
|
23881
|
+
var import_path20 = require("path");
|
|
23882
|
+
|
|
23883
|
+
// src/hooks/learner/constants.ts
|
|
23884
|
+
var import_path19 = require("path");
|
|
23885
|
+
var import_os3 = require("os");
|
|
23886
|
+
|
|
23887
|
+
// src/utils/paths.ts
|
|
23888
|
+
var import_path18 = require("path");
|
|
23889
|
+
var import_fs13 = require("fs");
|
|
23890
|
+
var import_os2 = require("os");
|
|
23891
|
+
|
|
23892
|
+
// src/utils/config-dir.ts
|
|
23893
|
+
var import_node_os = require("node:os");
|
|
23894
|
+
var import_node_path = require("node:path");
|
|
23895
|
+
function getConfigDir() {
|
|
23896
|
+
return process.env.CLAUDE_CONFIG_DIR || (0, import_node_path.join)((0, import_node_os.homedir)(), ".claude");
|
|
23897
|
+
}
|
|
23898
|
+
|
|
23899
|
+
// src/utils/paths.ts
|
|
23900
|
+
function getClaudeConfigDir() {
|
|
23901
|
+
return getConfigDir();
|
|
23902
|
+
}
|
|
23903
|
+
|
|
23904
|
+
// src/hooks/learner/constants.ts
|
|
23905
|
+
var USER_SKILLS_DIR = (0, import_path19.join)(getClaudeConfigDir(), "skills", "omc-learned");
|
|
23906
|
+
var GLOBAL_SKILLS_DIR = (0, import_path19.join)((0, import_os3.homedir)(), ".omc", "skills");
|
|
23907
|
+
var PROJECT_SKILLS_SUBDIR = OmcPaths.SKILLS;
|
|
23908
|
+
var MAX_RECURSION_DEPTH = 10;
|
|
23909
|
+
var SKILL_EXTENSION = ".md";
|
|
23910
|
+
var DEBUG_ENABLED = process.env.OMC_DEBUG === "1";
|
|
23911
|
+
|
|
23912
|
+
// src/hooks/learner/finder.ts
|
|
23913
|
+
function findSkillFilesRecursive(dir, results, depth = 0) {
|
|
23914
|
+
if (!(0, import_fs14.existsSync)(dir)) return;
|
|
23915
|
+
if (depth > MAX_RECURSION_DEPTH) return;
|
|
23916
|
+
try {
|
|
23917
|
+
const entries = (0, import_fs14.readdirSync)(dir, { withFileTypes: true });
|
|
23918
|
+
for (const entry of entries) {
|
|
23919
|
+
const fullPath = (0, import_path20.join)(dir, entry.name);
|
|
23920
|
+
if (entry.isDirectory()) {
|
|
23921
|
+
findSkillFilesRecursive(fullPath, results, depth + 1);
|
|
23922
|
+
} else if (entry.isFile() && entry.name.endsWith(SKILL_EXTENSION)) {
|
|
23923
|
+
results.push(fullPath);
|
|
23924
|
+
}
|
|
23925
|
+
}
|
|
23926
|
+
} catch (error2) {
|
|
23927
|
+
if (DEBUG_ENABLED) {
|
|
23928
|
+
console.error("[learner] Error scanning directory:", error2);
|
|
23929
|
+
}
|
|
23930
|
+
}
|
|
23931
|
+
}
|
|
23932
|
+
function safeRealpathSync(filePath) {
|
|
23933
|
+
try {
|
|
23934
|
+
return (0, import_fs14.realpathSync)(filePath);
|
|
23935
|
+
} catch {
|
|
23936
|
+
return filePath;
|
|
23937
|
+
}
|
|
23938
|
+
}
|
|
23939
|
+
function isWithinBoundary(realPath, boundary) {
|
|
23940
|
+
const normalizedReal = (0, import_path20.normalize)(realPath);
|
|
23941
|
+
const normalizedBoundary = (0, import_path20.normalize)(boundary);
|
|
23942
|
+
return normalizedReal === normalizedBoundary || normalizedReal.startsWith(normalizedBoundary + import_path20.sep);
|
|
23943
|
+
}
|
|
23944
|
+
function findSkillFiles(projectRoot, options) {
|
|
23945
|
+
const candidates = [];
|
|
23946
|
+
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
23947
|
+
const scope = options?.scope ?? "all";
|
|
23948
|
+
if (projectRoot && (scope === "project" || scope === "all")) {
|
|
23949
|
+
const projectSkillsDir = (0, import_path20.join)(projectRoot, PROJECT_SKILLS_SUBDIR);
|
|
23950
|
+
const projectFiles = [];
|
|
23951
|
+
findSkillFilesRecursive(projectSkillsDir, projectFiles);
|
|
23952
|
+
for (const filePath of projectFiles) {
|
|
23953
|
+
const realPath = safeRealpathSync(filePath);
|
|
23954
|
+
if (seenRealPaths.has(realPath)) continue;
|
|
23955
|
+
if (!isWithinBoundary(realPath, projectSkillsDir)) {
|
|
23956
|
+
if (DEBUG_ENABLED) {
|
|
23957
|
+
console.warn("[learner] Symlink escape blocked:", filePath);
|
|
23958
|
+
}
|
|
23959
|
+
continue;
|
|
23960
|
+
}
|
|
23961
|
+
seenRealPaths.add(realPath);
|
|
23962
|
+
candidates.push({
|
|
23963
|
+
path: filePath,
|
|
23964
|
+
realPath,
|
|
23965
|
+
scope: "project",
|
|
23966
|
+
sourceDir: projectSkillsDir
|
|
23967
|
+
});
|
|
23968
|
+
}
|
|
23969
|
+
}
|
|
23970
|
+
if (scope === "user" || scope === "all") {
|
|
23971
|
+
const userDirs = [GLOBAL_SKILLS_DIR, USER_SKILLS_DIR];
|
|
23972
|
+
for (const userDir of userDirs) {
|
|
23973
|
+
const userFiles = [];
|
|
23974
|
+
findSkillFilesRecursive(userDir, userFiles);
|
|
23975
|
+
for (const filePath of userFiles) {
|
|
23976
|
+
const realPath = safeRealpathSync(filePath);
|
|
23977
|
+
if (seenRealPaths.has(realPath)) continue;
|
|
23978
|
+
if (!isWithinBoundary(realPath, userDir)) {
|
|
23979
|
+
if (DEBUG_ENABLED) {
|
|
23980
|
+
console.warn("[learner] Symlink escape blocked:", filePath);
|
|
23981
|
+
}
|
|
23982
|
+
continue;
|
|
23983
|
+
}
|
|
23984
|
+
seenRealPaths.add(realPath);
|
|
23985
|
+
candidates.push({
|
|
23986
|
+
path: filePath,
|
|
23987
|
+
realPath,
|
|
23988
|
+
scope: "user",
|
|
23989
|
+
sourceDir: userDir
|
|
23990
|
+
});
|
|
23991
|
+
}
|
|
23992
|
+
}
|
|
23993
|
+
}
|
|
23994
|
+
return candidates;
|
|
23995
|
+
}
|
|
23996
|
+
|
|
23997
|
+
// src/hooks/learner/parser.ts
|
|
23998
|
+
function parseSkillFile(rawContent) {
|
|
23999
|
+
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
24000
|
+
const match = rawContent.match(frontmatterRegex);
|
|
24001
|
+
if (!match) {
|
|
24002
|
+
return {
|
|
24003
|
+
metadata: {},
|
|
24004
|
+
content: rawContent,
|
|
24005
|
+
valid: false,
|
|
24006
|
+
errors: ["Missing YAML frontmatter"]
|
|
24007
|
+
};
|
|
24008
|
+
}
|
|
24009
|
+
const yamlContent = match[1];
|
|
24010
|
+
const content = match[2].trim();
|
|
24011
|
+
const errors = [];
|
|
24012
|
+
try {
|
|
24013
|
+
const metadata = parseYamlMetadata(yamlContent);
|
|
24014
|
+
if (!metadata.id && metadata.name) {
|
|
24015
|
+
metadata.id = metadata.name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
24016
|
+
}
|
|
24017
|
+
if (!metadata.source) {
|
|
24018
|
+
metadata.source = "manual";
|
|
24019
|
+
}
|
|
24020
|
+
if (!metadata.name) errors.push("Missing required field: name");
|
|
24021
|
+
if (!metadata.description) errors.push("Missing required field: description");
|
|
24022
|
+
if (!metadata.triggers || metadata.triggers.length === 0) {
|
|
24023
|
+
errors.push("Missing required field: triggers");
|
|
24024
|
+
}
|
|
24025
|
+
return {
|
|
24026
|
+
metadata,
|
|
24027
|
+
content,
|
|
24028
|
+
valid: errors.length === 0,
|
|
24029
|
+
errors
|
|
24030
|
+
};
|
|
24031
|
+
} catch (e) {
|
|
24032
|
+
return {
|
|
24033
|
+
metadata: {},
|
|
24034
|
+
content: rawContent,
|
|
24035
|
+
valid: false,
|
|
24036
|
+
errors: [`YAML parse error: ${e}`]
|
|
24037
|
+
};
|
|
24038
|
+
}
|
|
24039
|
+
}
|
|
24040
|
+
function parseYamlMetadata(yamlContent) {
|
|
24041
|
+
const lines = yamlContent.split("\n");
|
|
24042
|
+
const metadata = {};
|
|
24043
|
+
let i = 0;
|
|
24044
|
+
while (i < lines.length) {
|
|
24045
|
+
const line = lines[i];
|
|
24046
|
+
const colonIndex = line.indexOf(":");
|
|
24047
|
+
if (colonIndex === -1) {
|
|
24048
|
+
i++;
|
|
24049
|
+
continue;
|
|
24050
|
+
}
|
|
24051
|
+
const key = line.slice(0, colonIndex).trim();
|
|
24052
|
+
const rawValue = line.slice(colonIndex + 1).trim();
|
|
24053
|
+
switch (key) {
|
|
24054
|
+
case "id":
|
|
24055
|
+
metadata.id = parseStringValue(rawValue);
|
|
24056
|
+
break;
|
|
24057
|
+
case "name":
|
|
24058
|
+
metadata.name = parseStringValue(rawValue);
|
|
24059
|
+
break;
|
|
24060
|
+
case "description":
|
|
24061
|
+
metadata.description = parseStringValue(rawValue);
|
|
24062
|
+
break;
|
|
24063
|
+
case "source":
|
|
24064
|
+
metadata.source = parseStringValue(rawValue);
|
|
24065
|
+
break;
|
|
24066
|
+
case "createdAt":
|
|
24067
|
+
metadata.createdAt = parseStringValue(rawValue);
|
|
24068
|
+
break;
|
|
24069
|
+
case "sessionId":
|
|
24070
|
+
metadata.sessionId = parseStringValue(rawValue);
|
|
24071
|
+
break;
|
|
24072
|
+
case "quality":
|
|
24073
|
+
metadata.quality = parseInt(rawValue, 10) || void 0;
|
|
24074
|
+
break;
|
|
24075
|
+
case "usageCount":
|
|
24076
|
+
metadata.usageCount = parseInt(rawValue, 10) || 0;
|
|
24077
|
+
break;
|
|
24078
|
+
case "triggers":
|
|
24079
|
+
case "tags": {
|
|
24080
|
+
const { value, consumed } = parseArrayValue(rawValue, lines, i);
|
|
24081
|
+
if (key === "triggers") {
|
|
24082
|
+
metadata.triggers = Array.isArray(value) ? value : [value];
|
|
24083
|
+
} else {
|
|
24084
|
+
metadata.tags = Array.isArray(value) ? value : [value];
|
|
24085
|
+
}
|
|
24086
|
+
i += consumed - 1;
|
|
24087
|
+
break;
|
|
24088
|
+
}
|
|
24089
|
+
}
|
|
24090
|
+
i++;
|
|
24091
|
+
}
|
|
24092
|
+
return metadata;
|
|
24093
|
+
}
|
|
24094
|
+
function parseStringValue(value) {
|
|
24095
|
+
if (!value) return "";
|
|
24096
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
24097
|
+
return value.slice(1, -1);
|
|
24098
|
+
}
|
|
24099
|
+
return value;
|
|
24100
|
+
}
|
|
24101
|
+
function parseArrayValue(rawValue, lines, currentIndex) {
|
|
24102
|
+
if (rawValue.startsWith("[")) {
|
|
24103
|
+
const endIdx = rawValue.lastIndexOf("]");
|
|
24104
|
+
if (endIdx === -1) return { value: [], consumed: 1 };
|
|
24105
|
+
const content = rawValue.slice(1, endIdx).trim();
|
|
24106
|
+
if (!content) return { value: [], consumed: 1 };
|
|
24107
|
+
const items = content.split(",").map((s) => parseStringValue(s.trim())).filter(Boolean);
|
|
24108
|
+
return { value: items, consumed: 1 };
|
|
24109
|
+
}
|
|
24110
|
+
if (!rawValue || rawValue === "") {
|
|
24111
|
+
const items = [];
|
|
24112
|
+
let consumed = 1;
|
|
24113
|
+
for (let j = currentIndex + 1; j < lines.length; j++) {
|
|
24114
|
+
const nextLine = lines[j];
|
|
24115
|
+
const arrayMatch = nextLine.match(/^\s+-\s*(.*)$/);
|
|
24116
|
+
if (arrayMatch) {
|
|
24117
|
+
const itemValue = parseStringValue(arrayMatch[1].trim());
|
|
24118
|
+
if (itemValue) items.push(itemValue);
|
|
24119
|
+
consumed++;
|
|
24120
|
+
} else if (nextLine.trim() === "") {
|
|
24121
|
+
consumed++;
|
|
24122
|
+
} else {
|
|
24123
|
+
break;
|
|
24124
|
+
}
|
|
24125
|
+
}
|
|
24126
|
+
if (items.length > 0) {
|
|
24127
|
+
return { value: items, consumed };
|
|
24128
|
+
}
|
|
24129
|
+
}
|
|
24130
|
+
return { value: parseStringValue(rawValue), consumed: 1 };
|
|
24131
|
+
}
|
|
24132
|
+
|
|
24133
|
+
// src/hooks/learner/loader.ts
|
|
24134
|
+
function createContentHash(content) {
|
|
24135
|
+
return (0, import_crypto3.createHash)("sha256").update(content).digest("hex").slice(0, 16);
|
|
24136
|
+
}
|
|
24137
|
+
function loadAllSkills(projectRoot) {
|
|
24138
|
+
const candidates = findSkillFiles(projectRoot);
|
|
24139
|
+
const seenIds = /* @__PURE__ */ new Map();
|
|
24140
|
+
for (const candidate of candidates) {
|
|
24141
|
+
try {
|
|
24142
|
+
const rawContent = (0, import_fs15.readFileSync)(candidate.path, "utf-8");
|
|
24143
|
+
const { metadata, content, valid, errors } = parseSkillFile(rawContent);
|
|
24144
|
+
if (!valid) {
|
|
24145
|
+
if (DEBUG_ENABLED) {
|
|
24146
|
+
console.warn(`Invalid skill file ${candidate.path}: ${errors.join(", ")}`);
|
|
24147
|
+
}
|
|
24148
|
+
continue;
|
|
24149
|
+
}
|
|
24150
|
+
const skillId = metadata.id;
|
|
24151
|
+
const relativePath = (0, import_path21.normalize)((0, import_path21.relative)(candidate.sourceDir, candidate.path));
|
|
24152
|
+
const skill = {
|
|
24153
|
+
path: candidate.path,
|
|
24154
|
+
relativePath,
|
|
24155
|
+
scope: candidate.scope,
|
|
24156
|
+
metadata,
|
|
24157
|
+
content,
|
|
24158
|
+
contentHash: createContentHash(content),
|
|
24159
|
+
priority: candidate.scope === "project" ? 1 : 0
|
|
24160
|
+
};
|
|
24161
|
+
const existing = seenIds.get(skillId);
|
|
24162
|
+
if (!existing || skill.priority > existing.priority) {
|
|
24163
|
+
seenIds.set(skillId, skill);
|
|
24164
|
+
}
|
|
24165
|
+
} catch (e) {
|
|
24166
|
+
if (DEBUG_ENABLED) {
|
|
24167
|
+
console.warn(`Error loading skill ${candidate.path}:`, e);
|
|
24168
|
+
}
|
|
24169
|
+
}
|
|
24170
|
+
}
|
|
24171
|
+
return Array.from(seenIds.values()).sort((a, b) => b.priority - a.priority);
|
|
24172
|
+
}
|
|
24173
|
+
|
|
24174
|
+
// src/tools/skills-tools.ts
|
|
24175
|
+
function getAllowedBoundaries() {
|
|
24176
|
+
return [process.cwd(), (0, import_os4.homedir)()];
|
|
24177
|
+
}
|
|
24178
|
+
function validateProjectRoot(input) {
|
|
24179
|
+
const normalized = (0, import_path22.normalize)((0, import_path22.resolve)(input));
|
|
24180
|
+
if (input.includes("..")) {
|
|
24181
|
+
throw new Error("Invalid project root: path traversal not allowed");
|
|
24182
|
+
}
|
|
24183
|
+
const isWithinAllowed = getAllowedBoundaries().some((boundary) => {
|
|
24184
|
+
const normalizedBoundary = (0, import_path22.normalize)(boundary);
|
|
24185
|
+
return normalized === normalizedBoundary || normalized.startsWith(normalizedBoundary + import_path22.sep);
|
|
24186
|
+
});
|
|
24187
|
+
if (!isWithinAllowed) {
|
|
24188
|
+
throw new Error("Invalid project root: path is outside allowed directories");
|
|
24189
|
+
}
|
|
24190
|
+
return normalized;
|
|
24191
|
+
}
|
|
24192
|
+
var loadLocalSchema = {
|
|
24193
|
+
projectRoot: external_exports.string().max(500).optional().describe("Project root directory (defaults to cwd)")
|
|
24194
|
+
};
|
|
24195
|
+
var loadGlobalSchema = {};
|
|
24196
|
+
var listSkillsSchema = {
|
|
24197
|
+
projectRoot: external_exports.string().max(500).optional().describe("Project root directory (defaults to cwd)")
|
|
24198
|
+
};
|
|
24199
|
+
function formatSkillOutput(skills) {
|
|
24200
|
+
if (skills.length === 0) {
|
|
24201
|
+
return "No skills found in the searched directories.";
|
|
24202
|
+
}
|
|
24203
|
+
const lines = [];
|
|
24204
|
+
for (const skill of skills) {
|
|
24205
|
+
lines.push(`### ${skill.metadata.id}`);
|
|
24206
|
+
lines.push(`- **Name:** ${skill.metadata.name}`);
|
|
24207
|
+
lines.push(`- **Description:** ${skill.metadata.description}`);
|
|
24208
|
+
lines.push(`- **Triggers:** ${skill.metadata.triggers.join(", ")}`);
|
|
24209
|
+
if (skill.metadata.tags?.length) {
|
|
24210
|
+
lines.push(`- **Tags:** ${skill.metadata.tags.join(", ")}`);
|
|
24211
|
+
}
|
|
24212
|
+
lines.push(`- **Scope:** ${skill.scope}`);
|
|
24213
|
+
lines.push(`- **Path:** ${skill.relativePath}`);
|
|
24214
|
+
lines.push("");
|
|
24215
|
+
}
|
|
24216
|
+
return lines.join("\n");
|
|
24217
|
+
}
|
|
24218
|
+
var loadLocalTool = {
|
|
24219
|
+
name: "load_omc_skills_local",
|
|
24220
|
+
description: "Load and list skills from the project-local .omc/skills/ directory. Returns skill metadata (id, name, description, triggers, tags) for all discovered project-scoped skills.",
|
|
24221
|
+
schema: loadLocalSchema,
|
|
24222
|
+
handler: async (args) => {
|
|
24223
|
+
const projectRoot = args.projectRoot ? validateProjectRoot(args.projectRoot) : process.cwd();
|
|
24224
|
+
const allSkills = loadAllSkills(projectRoot);
|
|
24225
|
+
const projectSkills = allSkills.filter((s) => s.scope === "project");
|
|
24226
|
+
return {
|
|
24227
|
+
content: [{
|
|
24228
|
+
type: "text",
|
|
24229
|
+
text: `## Project Skills (${projectSkills.length})
|
|
24230
|
+
|
|
24231
|
+
${formatSkillOutput(projectSkills)}`
|
|
24232
|
+
}]
|
|
24233
|
+
};
|
|
24234
|
+
}
|
|
24235
|
+
};
|
|
24236
|
+
var loadGlobalTool = {
|
|
24237
|
+
name: "load_omc_skills_global",
|
|
24238
|
+
description: "Load and list skills from global user directories (~/.omc/skills/ and ~/.claude/skills/omc-learned/). Returns skill metadata for all discovered user-scoped skills.",
|
|
24239
|
+
schema: loadGlobalSchema,
|
|
24240
|
+
handler: async (_args) => {
|
|
24241
|
+
const allSkills = loadAllSkills(null);
|
|
24242
|
+
const userSkills = allSkills.filter((s) => s.scope === "user");
|
|
24243
|
+
return {
|
|
24244
|
+
content: [{
|
|
24245
|
+
type: "text",
|
|
24246
|
+
text: `## Global User Skills (${userSkills.length})
|
|
24247
|
+
|
|
24248
|
+
${formatSkillOutput(userSkills)}`
|
|
24249
|
+
}]
|
|
24250
|
+
};
|
|
24251
|
+
}
|
|
24252
|
+
};
|
|
24253
|
+
var listSkillsTool = {
|
|
24254
|
+
name: "list_omc_skills",
|
|
24255
|
+
description: "List all available skills (both project-local and global user skills). Project skills take priority over user skills with the same ID.",
|
|
24256
|
+
schema: listSkillsSchema,
|
|
24257
|
+
handler: async (args) => {
|
|
24258
|
+
const projectRoot = args.projectRoot ? validateProjectRoot(args.projectRoot) : process.cwd();
|
|
24259
|
+
const skills = loadAllSkills(projectRoot);
|
|
24260
|
+
const projectSkills = skills.filter((s) => s.scope === "project");
|
|
24261
|
+
const userSkills = skills.filter((s) => s.scope === "user");
|
|
24262
|
+
let output = `## All Available Skills (${skills.length} total)
|
|
24263
|
+
|
|
24264
|
+
`;
|
|
24265
|
+
if (projectSkills.length > 0) {
|
|
24266
|
+
output += `### Project Skills (${projectSkills.length})
|
|
24267
|
+
|
|
24268
|
+
${formatSkillOutput(projectSkills)}
|
|
24269
|
+
`;
|
|
24270
|
+
}
|
|
24271
|
+
if (userSkills.length > 0) {
|
|
24272
|
+
output += `### User Skills (${userSkills.length})
|
|
24273
|
+
|
|
24274
|
+
${formatSkillOutput(userSkills)}`;
|
|
24275
|
+
}
|
|
24276
|
+
if (skills.length === 0) {
|
|
24277
|
+
output = "## No Skills Found\n\nNo skill files were discovered in any searched directories.\n\nSearched:\n- Project: .omc/skills/\n- Global: ~/.omc/skills/\n- Legacy: ~/.claude/skills/omc-learned/";
|
|
24278
|
+
}
|
|
24279
|
+
return {
|
|
24280
|
+
content: [{
|
|
24281
|
+
type: "text",
|
|
24282
|
+
text: output
|
|
24283
|
+
}]
|
|
24284
|
+
};
|
|
24285
|
+
}
|
|
24286
|
+
};
|
|
24287
|
+
var skillsTools = [loadLocalTool, loadGlobalTool, listSkillsTool];
|
|
24288
|
+
|
|
24289
|
+
// src/tools/tool-prefix-migration.ts
|
|
24290
|
+
var DEPRECATION_MAP = {
|
|
24291
|
+
// LSP Tools
|
|
24292
|
+
"lsp_hover": { oldName: "lsp_hover", newName: "ultrapower:lsp_hover", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24293
|
+
"lsp_goto_definition": { oldName: "lsp_goto_definition", newName: "ultrapower:lsp_goto_definition", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24294
|
+
"lsp_find_references": { oldName: "lsp_find_references", newName: "ultrapower:lsp_find_references", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24295
|
+
"lsp_document_symbols": { oldName: "lsp_document_symbols", newName: "ultrapower:lsp_document_symbols", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24296
|
+
"lsp_workspace_symbols": { oldName: "lsp_workspace_symbols", newName: "ultrapower:lsp_workspace_symbols", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24297
|
+
"lsp_diagnostics": { oldName: "lsp_diagnostics", newName: "ultrapower:lsp_diagnostics", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24298
|
+
"lsp_servers": { oldName: "lsp_servers", newName: "ultrapower:lsp_servers", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24299
|
+
"lsp_prepare_rename": { oldName: "lsp_prepare_rename", newName: "ultrapower:lsp_prepare_rename", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24300
|
+
"lsp_rename": { oldName: "lsp_rename", newName: "ultrapower:lsp_rename", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24301
|
+
"lsp_code_actions": { oldName: "lsp_code_actions", newName: "ultrapower:lsp_code_actions", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24302
|
+
"lsp_code_action_resolve": { oldName: "lsp_code_action_resolve", newName: "ultrapower:lsp_code_action_resolve", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24303
|
+
"lsp_diagnostics_directory": { oldName: "lsp_diagnostics_directory", newName: "ultrapower:lsp_diagnostics_directory", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24304
|
+
// State Tools
|
|
24305
|
+
"state_read": { oldName: "state_read", newName: "ultrapower:state_read", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24306
|
+
"state_write": { oldName: "state_write", newName: "ultrapower:state_write", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24307
|
+
"state_clear": { oldName: "state_clear", newName: "ultrapower:state_clear", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24308
|
+
"state_list_active": { oldName: "state_list_active", newName: "ultrapower:state_list_active", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24309
|
+
"state_get_status": { oldName: "state_get_status", newName: "ultrapower:state_get_status", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24310
|
+
// Notepad Tools
|
|
24311
|
+
"notepad_read": { oldName: "notepad_read", newName: "ultrapower:notepad_read", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24312
|
+
"notepad_write_priority": { oldName: "notepad_write_priority", newName: "ultrapower:notepad_write_priority", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24313
|
+
"notepad_write_working": { oldName: "notepad_write_working", newName: "ultrapower:notepad_write_working", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24314
|
+
"notepad_write_manual": { oldName: "notepad_write_manual", newName: "ultrapower:notepad_write_manual", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24315
|
+
"notepad_prune": { oldName: "notepad_prune", newName: "ultrapower:notepad_prune", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24316
|
+
"notepad_stats": { oldName: "notepad_stats", newName: "ultrapower:notepad_stats", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24317
|
+
// Memory Tools
|
|
24318
|
+
"project_memory_read": { oldName: "project_memory_read", newName: "ultrapower:project_memory_read", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24319
|
+
"project_memory_write": { oldName: "project_memory_write", newName: "ultrapower:project_memory_write", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24320
|
+
"project_memory_add_note": { oldName: "project_memory_add_note", newName: "ultrapower:project_memory_add_note", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24321
|
+
"project_memory_add_directive": { oldName: "project_memory_add_directive", newName: "ultrapower:project_memory_add_directive", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24322
|
+
// AST Tools
|
|
24323
|
+
"ast_grep_search": { oldName: "ast_grep_search", newName: "ultrapower:ast_grep_search", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24324
|
+
"ast_grep_replace": { oldName: "ast_grep_replace", newName: "ultrapower:ast_grep_replace", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24325
|
+
// Python REPL
|
|
24326
|
+
"python_repl": { oldName: "python_repl", newName: "ultrapower:python_repl", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24327
|
+
// Trace Tools
|
|
24328
|
+
"trace_timeline": { oldName: "trace_timeline", newName: "ultrapower:trace_timeline", deprecatedSince: "5.6.0", removalVersion: "6.0.0" },
|
|
24329
|
+
"trace_summary": { oldName: "trace_summary", newName: "ultrapower:trace_summary", deprecatedSince: "5.6.0", removalVersion: "6.0.0" }
|
|
24330
|
+
};
|
|
24331
|
+
function createDeprecationWarning(info) {
|
|
24332
|
+
return `\u26A0\uFE0F DEPRECATED: Tool '${info.oldName}' is deprecated since v${info.deprecatedSince} and will be removed in v${info.removalVersion}.
|
|
24333
|
+
Please use '${info.newName}' instead.
|
|
24334
|
+
|
|
24335
|
+
`;
|
|
24336
|
+
}
|
|
24337
|
+
function wrapWithDeprecation(tool) {
|
|
24338
|
+
const deprecationInfo = DEPRECATION_MAP[tool.name];
|
|
24339
|
+
if (!deprecationInfo) return tool;
|
|
24340
|
+
const originalHandler = tool.handler;
|
|
24341
|
+
return {
|
|
24342
|
+
...tool,
|
|
24343
|
+
handler: async (args) => {
|
|
24344
|
+
const result = await originalHandler(args);
|
|
24345
|
+
const warning = createDeprecationWarning(deprecationInfo);
|
|
24346
|
+
if (result.content && result.content[0]) {
|
|
24347
|
+
result.content[0].text = warning + result.content[0].text;
|
|
24348
|
+
}
|
|
24349
|
+
return result;
|
|
24350
|
+
}
|
|
24351
|
+
};
|
|
24352
|
+
}
|
|
24353
|
+
function createPrefixedTool(tool) {
|
|
24354
|
+
return {
|
|
24355
|
+
...tool,
|
|
24356
|
+
name: `ultrapower:${tool.name}`
|
|
24357
|
+
};
|
|
24358
|
+
}
|
|
24359
|
+
function registerToolWithBothNames(tool) {
|
|
24360
|
+
const prefixedTool = createPrefixedTool(tool);
|
|
24361
|
+
const deprecatedTool = wrapWithDeprecation(tool);
|
|
24362
|
+
return [prefixedTool, deprecatedTool];
|
|
24363
|
+
}
|
|
24364
|
+
|
|
24365
|
+
// src/tools/index.ts
|
|
24366
|
+
var allCustomTools = [
|
|
24367
|
+
...lspTools.flatMap(registerToolWithBothNames),
|
|
24368
|
+
...astTools.flatMap(registerToolWithBothNames),
|
|
24369
|
+
...registerToolWithBothNames(pythonReplTool2),
|
|
24370
|
+
...stateTools.flatMap(registerToolWithBothNames),
|
|
24371
|
+
...notepadTools.flatMap(registerToolWithBothNames),
|
|
24372
|
+
...memoryTools.flatMap(registerToolWithBothNames),
|
|
24373
|
+
...traceTools.flatMap(registerToolWithBothNames),
|
|
24374
|
+
...skillsTools
|
|
23852
24375
|
];
|
|
24376
|
+
|
|
24377
|
+
// src/mcp/namespace-manager.ts
|
|
24378
|
+
function parseNamespace(namespacedName) {
|
|
24379
|
+
const match = namespacedName.match(/^mcp__([^_]+)__(.+)$/);
|
|
24380
|
+
if (!match) return null;
|
|
24381
|
+
return { serverName: match[1], toolName: match[2] };
|
|
24382
|
+
}
|
|
24383
|
+
function isNamespaced(name) {
|
|
24384
|
+
return /^mcp__[^_]+__.+$/.test(name);
|
|
24385
|
+
}
|
|
24386
|
+
|
|
24387
|
+
// src/mcp/tool-resolver.ts
|
|
24388
|
+
function resolveTool(name) {
|
|
24389
|
+
const directMatch = allCustomTools.find((t) => t.name === name);
|
|
24390
|
+
if (directMatch) return directMatch;
|
|
24391
|
+
if (isNamespaced(name)) {
|
|
24392
|
+
const parsed = parseNamespace(name);
|
|
24393
|
+
if (parsed) {
|
|
24394
|
+
return allCustomTools.find((t) => t.name === parsed.toolName);
|
|
24395
|
+
}
|
|
24396
|
+
}
|
|
24397
|
+
return void 0;
|
|
24398
|
+
}
|
|
24399
|
+
|
|
24400
|
+
// src/mcp/timeout.ts
|
|
24401
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
24402
|
+
async function withTimeout(fn, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
24403
|
+
return Promise.race([
|
|
24404
|
+
fn(),
|
|
24405
|
+
new Promise(
|
|
24406
|
+
(_, reject) => setTimeout(() => reject(new Error(`Operation timed out after ${timeoutMs}ms`)), timeoutMs)
|
|
24407
|
+
)
|
|
24408
|
+
]);
|
|
24409
|
+
}
|
|
24410
|
+
|
|
24411
|
+
// src/mcp/tool-handler.ts
|
|
24412
|
+
async function handleToolCall(name, args) {
|
|
24413
|
+
const tool = resolveTool(name);
|
|
24414
|
+
if (!tool) {
|
|
24415
|
+
return {
|
|
24416
|
+
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
24417
|
+
isError: true
|
|
24418
|
+
};
|
|
24419
|
+
}
|
|
24420
|
+
try {
|
|
24421
|
+
const result = await withTimeout(() => tool.handler(args ?? {}));
|
|
24422
|
+
return {
|
|
24423
|
+
content: result.content,
|
|
24424
|
+
isError: false
|
|
24425
|
+
};
|
|
24426
|
+
} catch (error2) {
|
|
24427
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
24428
|
+
return {
|
|
24429
|
+
content: [{ type: "text", text: `Error executing ${name}: ${message}` }],
|
|
24430
|
+
isError: true
|
|
24431
|
+
};
|
|
24432
|
+
}
|
|
24433
|
+
}
|
|
24434
|
+
|
|
24435
|
+
// src/mcp/standalone-server.ts
|
|
24436
|
+
var allTools = allCustomTools;
|
|
23853
24437
|
function zodToJsonSchema2(schema) {
|
|
23854
24438
|
const rawShape = schema instanceof external_exports.ZodObject ? schema.shape : schema;
|
|
23855
24439
|
const properties = {};
|
|
@@ -23931,26 +24515,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
23931
24515
|
});
|
|
23932
24516
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
23933
24517
|
const { name, arguments: args } = request.params;
|
|
23934
|
-
|
|
23935
|
-
if (!tool) {
|
|
23936
|
-
return {
|
|
23937
|
-
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
23938
|
-
isError: true
|
|
23939
|
-
};
|
|
23940
|
-
}
|
|
23941
|
-
try {
|
|
23942
|
-
const result = await tool.handler(args ?? {});
|
|
23943
|
-
return {
|
|
23944
|
-
content: result.content,
|
|
23945
|
-
isError: false
|
|
23946
|
-
};
|
|
23947
|
-
} catch (error2) {
|
|
23948
|
-
const errorMessage = error2 instanceof Error ? error2.message : String(error2);
|
|
23949
|
-
return {
|
|
23950
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
23951
|
-
isError: true
|
|
23952
|
-
};
|
|
23953
|
-
}
|
|
24518
|
+
return handleToolCall(name, args);
|
|
23954
24519
|
});
|
|
23955
24520
|
async function main() {
|
|
23956
24521
|
const transport = new StdioServerTransport();
|