@mcpc-tech/core 0.3.38 → 0.3.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/core",
3
- "version": "0.3.38",
3
+ "version": "0.3.39",
4
4
  "homepage": "https://jsr.io/@mcpc/core",
5
5
  "dependencies": {
6
6
  "@ai-sdk/provider": "^2.0.0",
@@ -105,7 +105,7 @@ Usage:
105
105
  - ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
106
106
  - ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
107
107
 
108
- Note: For scripts/ and assets/, use appropriate tools directly.`;
108
+ Note: For scripts/, use the bash tool with the script path to execute.`;
109
109
  }
110
110
  function createSkillsPlugin(options) {
111
111
  const { paths } = options;
@@ -205,7 +205,13 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
205
205
  "utf-8"
206
206
  );
207
207
  const body = extractBody(content);
208
- return { content: [{ type: "text", text: body }] };
208
+ const skillPathInfo = `
209
+ ---
210
+ Skill path: ${meta.basePath}
211
+ `;
212
+ return {
213
+ content: [{ type: "text", text: body + skillPathInfo }]
214
+ };
209
215
  } catch {
210
216
  return {
211
217
  content: [
@@ -83,7 +83,7 @@ Usage:
83
83
  - ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
84
84
  - ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
85
85
 
86
- Note: For scripts/ and assets/, use appropriate tools directly.`;
86
+ Note: For scripts/, use the bash tool with the script path to execute.`;
87
87
  }
88
88
  function createSkillsPlugin(options) {
89
89
  const { paths } = options;
@@ -183,7 +183,13 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
183
183
  "utf-8"
184
184
  );
185
185
  const body = extractBody(content);
186
- return { content: [{ type: "text", text: body }] };
186
+ const skillPathInfo = `
187
+ ---
188
+ Skill path: ${meta.basePath}
189
+ `;
190
+ return {
191
+ content: [{ type: "text", text: body + skillPathInfo }]
192
+ };
187
193
  } catch {
188
194
  return {
189
195
  content: [
package/plugins.cjs CHANGED
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // __mcpc__core_latest/node_modules/@mcpc/core/plugins.ts
30
30
  var plugins_exports = {};
31
31
  __export(plugins_exports, {
32
+ createBashPlugin: () => createBashPlugin,
32
33
  createLargeResultPlugin: () => createLargeResultPlugin,
33
34
  createSearchPlugin: () => createSearchPlugin,
34
35
  createSkillsPlugin: () => createSkillsPlugin,
@@ -447,7 +448,7 @@ Usage:
447
448
  - ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
448
449
  - ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
449
450
 
450
- Note: For scripts/ and assets/, use appropriate tools directly.`;
451
+ Note: For scripts/, use the bash tool with the script path to execute.`;
451
452
  }
452
453
  function createSkillsPlugin(options) {
453
454
  const { paths } = options;
@@ -555,11 +556,15 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
555
556
  try {
556
557
  const content = await (0, import_promises2.readFile)((0, import_node_path4.join)(meta.basePath, "SKILL.md"), "utf-8");
557
558
  const body = extractBody(content);
559
+ const skillPathInfo = `
560
+ ---
561
+ Skill path: ${meta.basePath}
562
+ `;
558
563
  return {
559
564
  content: [
560
565
  {
561
566
  type: "text",
562
- text: body
567
+ text: body + skillPathInfo
563
568
  }
564
569
  ]
565
570
  };
@@ -585,8 +590,147 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
585
590
  }
586
591
  };
587
592
  }
593
+
594
+ // __mcpc__core_latest/node_modules/@mcpc/core/src/plugins/bash.js
595
+ var import_node_child_process = require("node:child_process");
596
+ var import_node_process = __toESM(require("node:process"), 1);
597
+ var DEFAULT_MAX_BYTES = 1e5;
598
+ var DEFAULT_MAX_LINES = 2e3;
599
+ var DEFAULT_TIMEOUT_MS = 6e4;
600
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
601
+ const fullOutput = (stderr ? `STDERR:
602
+ ${stderr}
603
+
604
+ STDOUT:
605
+ ` : "") + stdout;
606
+ const lines = fullOutput.split("\n");
607
+ if (lines.length > maxLines) {
608
+ const truncatedLines = lines.slice(-maxLines);
609
+ return {
610
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
611
+
612
+ ` + truncatedLines.join("\n"),
613
+ truncated: true
614
+ };
615
+ }
616
+ if (fullOutput.length > maxBytes) {
617
+ const truncatedBytes = fullOutput.slice(-maxBytes);
618
+ return {
619
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
620
+
621
+ ` + truncatedBytes,
622
+ truncated: true
623
+ };
624
+ }
625
+ return {
626
+ output: fullOutput,
627
+ truncated: false
628
+ };
629
+ }
630
+ function executeBash(command, cwd, timeoutMs) {
631
+ return new Promise((resolve3) => {
632
+ const stdout = [];
633
+ const stderr = [];
634
+ const proc = (0, import_node_child_process.spawn)("bash", [
635
+ "-c",
636
+ command
637
+ ], {
638
+ cwd,
639
+ stdio: [
640
+ "ignore",
641
+ "pipe",
642
+ "pipe"
643
+ ]
644
+ });
645
+ proc.stdout?.on("data", (data) => {
646
+ stdout.push(data.toString());
647
+ });
648
+ proc.stderr?.on("data", (data) => {
649
+ stderr.push(data.toString());
650
+ });
651
+ proc.on("close", (code) => {
652
+ resolve3({
653
+ stdout: stdout.join(""),
654
+ stderr: stderr.join(""),
655
+ exitCode: code
656
+ });
657
+ });
658
+ proc.on("error", (err) => {
659
+ resolve3({
660
+ stdout: "",
661
+ stderr: err.message,
662
+ exitCode: null
663
+ });
664
+ });
665
+ setTimeout(() => {
666
+ proc.kill("SIGTERM");
667
+ resolve3({
668
+ stdout: stdout.join(""),
669
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
670
+ exitCode: null
671
+ });
672
+ }, timeoutMs);
673
+ });
674
+ }
675
+ function createBashPlugin(options = {}) {
676
+ const { maxBytes, maxLines, timeoutMs } = {
677
+ maxBytes: DEFAULT_MAX_BYTES,
678
+ maxLines: DEFAULT_MAX_LINES,
679
+ timeoutMs: DEFAULT_TIMEOUT_MS,
680
+ ...options
681
+ };
682
+ return {
683
+ name: "plugin-bash",
684
+ version: "1.0.0",
685
+ // Store server reference for tool registration
686
+ configureServer: (server) => {
687
+ server.tool("bash", "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
688
+ type: "object",
689
+ properties: {
690
+ command: {
691
+ type: "string",
692
+ description: "The bash command to execute"
693
+ },
694
+ cwd: {
695
+ type: "string",
696
+ description: "Optional: Working directory for the command (defaults to current directory)"
697
+ }
698
+ },
699
+ required: [
700
+ "command"
701
+ ]
702
+ }, async (args) => {
703
+ const cwd = args.cwd || import_node_process.default.cwd();
704
+ const result = await executeBash(args.command, cwd, timeoutMs);
705
+ const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
706
+ let finalOutput = output;
707
+ if (result.exitCode !== null && result.exitCode !== 0) {
708
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
709
+ ` + finalOutput;
710
+ }
711
+ if (truncated) {
712
+ finalOutput += `
713
+
714
+ [Note: Output was truncated]`;
715
+ }
716
+ return {
717
+ content: [
718
+ {
719
+ type: "text",
720
+ text: finalOutput
721
+ }
722
+ ],
723
+ isError: result.exitCode !== null && result.exitCode !== 0
724
+ };
725
+ }, {
726
+ internal: true
727
+ });
728
+ }
729
+ };
730
+ }
588
731
  // Annotate the CommonJS export names for ESM import in node:
589
732
  0 && (module.exports = {
733
+ createBashPlugin,
590
734
  createLargeResultPlugin,
591
735
  createSearchPlugin,
592
736
  createSkillsPlugin,
package/plugins.mjs CHANGED
@@ -411,7 +411,7 @@ Usage:
411
411
  - ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
412
412
  - ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
413
413
 
414
- Note: For scripts/ and assets/, use appropriate tools directly.`;
414
+ Note: For scripts/, use the bash tool with the script path to execute.`;
415
415
  }
416
416
  function createSkillsPlugin(options) {
417
417
  const { paths } = options;
@@ -519,11 +519,15 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
519
519
  try {
520
520
  const content = await readFile(join2(meta.basePath, "SKILL.md"), "utf-8");
521
521
  const body = extractBody(content);
522
+ const skillPathInfo = `
523
+ ---
524
+ Skill path: ${meta.basePath}
525
+ `;
522
526
  return {
523
527
  content: [
524
528
  {
525
529
  type: "text",
526
- text: body
530
+ text: body + skillPathInfo
527
531
  }
528
532
  ]
529
533
  };
@@ -549,7 +553,146 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
549
553
  }
550
554
  };
551
555
  }
556
+
557
+ // __mcpc__core_latest/node_modules/@mcpc/core/src/plugins/bash.js
558
+ import { spawn } from "node:child_process";
559
+ import process from "node:process";
560
+ var DEFAULT_MAX_BYTES = 1e5;
561
+ var DEFAULT_MAX_LINES = 2e3;
562
+ var DEFAULT_TIMEOUT_MS = 6e4;
563
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
564
+ const fullOutput = (stderr ? `STDERR:
565
+ ${stderr}
566
+
567
+ STDOUT:
568
+ ` : "") + stdout;
569
+ const lines = fullOutput.split("\n");
570
+ if (lines.length > maxLines) {
571
+ const truncatedLines = lines.slice(-maxLines);
572
+ return {
573
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
574
+
575
+ ` + truncatedLines.join("\n"),
576
+ truncated: true
577
+ };
578
+ }
579
+ if (fullOutput.length > maxBytes) {
580
+ const truncatedBytes = fullOutput.slice(-maxBytes);
581
+ return {
582
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
583
+
584
+ ` + truncatedBytes,
585
+ truncated: true
586
+ };
587
+ }
588
+ return {
589
+ output: fullOutput,
590
+ truncated: false
591
+ };
592
+ }
593
+ function executeBash(command, cwd, timeoutMs) {
594
+ return new Promise((resolve3) => {
595
+ const stdout = [];
596
+ const stderr = [];
597
+ const proc = spawn("bash", [
598
+ "-c",
599
+ command
600
+ ], {
601
+ cwd,
602
+ stdio: [
603
+ "ignore",
604
+ "pipe",
605
+ "pipe"
606
+ ]
607
+ });
608
+ proc.stdout?.on("data", (data) => {
609
+ stdout.push(data.toString());
610
+ });
611
+ proc.stderr?.on("data", (data) => {
612
+ stderr.push(data.toString());
613
+ });
614
+ proc.on("close", (code) => {
615
+ resolve3({
616
+ stdout: stdout.join(""),
617
+ stderr: stderr.join(""),
618
+ exitCode: code
619
+ });
620
+ });
621
+ proc.on("error", (err) => {
622
+ resolve3({
623
+ stdout: "",
624
+ stderr: err.message,
625
+ exitCode: null
626
+ });
627
+ });
628
+ setTimeout(() => {
629
+ proc.kill("SIGTERM");
630
+ resolve3({
631
+ stdout: stdout.join(""),
632
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
633
+ exitCode: null
634
+ });
635
+ }, timeoutMs);
636
+ });
637
+ }
638
+ function createBashPlugin(options = {}) {
639
+ const { maxBytes, maxLines, timeoutMs } = {
640
+ maxBytes: DEFAULT_MAX_BYTES,
641
+ maxLines: DEFAULT_MAX_LINES,
642
+ timeoutMs: DEFAULT_TIMEOUT_MS,
643
+ ...options
644
+ };
645
+ return {
646
+ name: "plugin-bash",
647
+ version: "1.0.0",
648
+ // Store server reference for tool registration
649
+ configureServer: (server) => {
650
+ server.tool("bash", "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
651
+ type: "object",
652
+ properties: {
653
+ command: {
654
+ type: "string",
655
+ description: "The bash command to execute"
656
+ },
657
+ cwd: {
658
+ type: "string",
659
+ description: "Optional: Working directory for the command (defaults to current directory)"
660
+ }
661
+ },
662
+ required: [
663
+ "command"
664
+ ]
665
+ }, async (args) => {
666
+ const cwd = args.cwd || process.cwd();
667
+ const result = await executeBash(args.command, cwd, timeoutMs);
668
+ const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
669
+ let finalOutput = output;
670
+ if (result.exitCode !== null && result.exitCode !== 0) {
671
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
672
+ ` + finalOutput;
673
+ }
674
+ if (truncated) {
675
+ finalOutput += `
676
+
677
+ [Note: Output was truncated]`;
678
+ }
679
+ return {
680
+ content: [
681
+ {
682
+ type: "text",
683
+ text: finalOutput
684
+ }
685
+ ],
686
+ isError: result.exitCode !== null && result.exitCode !== 0
687
+ };
688
+ }, {
689
+ internal: true
690
+ });
691
+ }
692
+ };
693
+ }
552
694
  export {
695
+ createBashPlugin,
553
696
  createLargeResultPlugin,
554
697
  createSearchPlugin,
555
698
  createSkillsPlugin,
@@ -38,6 +38,7 @@
38
38
  */ export { createSearchPlugin } from "./src/plugins/search-tool.js";
39
39
  export { createLargeResultPlugin } from "./src/plugins/large-result.js";
40
40
  export { createSkillsPlugin } from "./src/plugins/skills.js";
41
+ export { createBashPlugin } from "./src/plugins/bash.js";
41
42
  export { default as defaultSearchPlugin } from "./src/plugins/search-tool.js";
42
43
  export { default as defaultLargeResultPlugin } from "./src/plugins/large-result.js";
43
44
  export type { SearchOptions } from "./src/plugins/search-tool.js";
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sources":["../plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GAGD,SAAS,kBAAkB,uCAAuC;AAClE,SAAS,uBAAuB,wCAAwC;AACxE,SAAS,kBAAkB,kCAAkC;AAG7D,SAAS,WAAW,mBAAmB,uCAAuC;AAC9E,SAAS,WAAW,wBAAwB,wCAAwC;AAGpF,cAAc,aAAa,uCAAuC"}
1
+ {"version":3,"file":"plugins.d.ts","sources":["../plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GAGD,SAAS,kBAAkB,uCAAuC;AAClE,SAAS,uBAAuB,wCAAwC;AACxE,SAAS,kBAAkB,kCAAkC;AAC7D,SAAS,gBAAgB,gCAAgC;AAGzD,SAAS,WAAW,mBAAmB,uCAAuC;AAC9E,SAAS,WAAW,wBAAwB,wCAAwC;AAGpF,cAAc,aAAa,uCAAuC"}
@@ -0,0 +1,10 @@
1
+ import type { ToolPlugin } from "../plugin-types.js";
2
+ export interface BashPluginOptions {
3
+ /** Maximum output bytes to return */ maxBytes?: number;
4
+ /** Maximum output lines to return */ maxLines?: number;
5
+ /** Command execution timeout in ms */ timeoutMs?: number;
6
+ }
7
+ /**
8
+ * Create a bash plugin that provides command execution capability
9
+ */ export declare function createBashPlugin(options?: BashPluginOptions): ToolPlugin;
10
+ //# sourceMappingURL=bash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash.d.ts","sources":["../../../src/plugins/bash.ts"],"names":[],"mappings":"AAWA,cAAc,UAAU,6BAA6B;AASrD,iBAAiB;EACf,mCAAmC,GACnC,WAAW,MAAM;EACjB,mCAAmC,GACnC,WAAW,MAAM;EACjB,oCAAoC,GACpC,YAAY,MAAM;;AA8FpB;;CAEC,GACD,OAAO,iBAAS,iBAAiB,UAAS,iBAAsB,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sources":["../../../src/plugins/skills.ts"],"names":[],"mappings":"AAOA,cAAmC,UAAU,6BAA6B;UAWhE;EACR,mCAAmC,GACnC,OAAO,MAAM;;AAoGf;;CAEC,GACD,OAAO,iBAAS,mBAAmB,SAAS,mBAAmB,GAAG;AA8IlE;;;;;;;;;;;;;CAaC,GACD,OAAO,iBAAS,aAAa,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC,GAAG;AAM9D,eAAe,mBAAmB"}
1
+ {"version":3,"file":"skills.d.ts","sources":["../../../src/plugins/skills.ts"],"names":[],"mappings":"AAOA,cAAmC,UAAU,6BAA6B;UAWhE;EACR,mCAAmC,GACnC,OAAO,MAAM;;AAoGf;;CAEC,GACD,OAAO,iBAAS,mBAAmB,SAAS,mBAAmB,GAAG;AAkJlE;;;;;;;;;;;;;CAaC,GACD,OAAO,iBAAS,aAAa,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC,GAAG;AAM9D,eAAe,mBAAmB"}