metheus-governance-mcp-cli 0.2.55 → 0.2.57
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
|
@@ -56,6 +56,50 @@ function resolveWorkspaceDir(rawValue) {
|
|
|
56
56
|
return process.cwd();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function resolveLocalCliCommand(commandName) {
|
|
60
|
+
const name = String(commandName || "").trim();
|
|
61
|
+
if (!name) {
|
|
62
|
+
throw new Error("command name is required");
|
|
63
|
+
}
|
|
64
|
+
if (process.platform === "win32") {
|
|
65
|
+
const candidates = [
|
|
66
|
+
path.join(process.env.APPDATA || "", "npm", `${name}.cmd`),
|
|
67
|
+
path.join(process.env.APPDATA || "", "npm", `${name}.ps1`),
|
|
68
|
+
path.join(process.env.APPDATA || "", "npm", name),
|
|
69
|
+
].filter(Boolean);
|
|
70
|
+
for (const candidate of candidates) {
|
|
71
|
+
if (candidate && fs.existsSync(candidate)) {
|
|
72
|
+
return candidate;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return name;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function quoteWindowsShellArg(value) {
|
|
80
|
+
const text = String(value ?? "");
|
|
81
|
+
if (!text) return '""';
|
|
82
|
+
if (!/[\s"&|<>^()]/.test(text)) return text;
|
|
83
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function spawnCli(commandPath, args, options) {
|
|
87
|
+
const executable = String(commandPath || "").trim();
|
|
88
|
+
if (!executable) {
|
|
89
|
+
throw new Error("command path is required");
|
|
90
|
+
}
|
|
91
|
+
const normalizedArgs = Array.isArray(args) ? args.map((item) => String(item)) : [];
|
|
92
|
+
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(executable)) {
|
|
93
|
+
const commandLine = [quoteWindowsShellArg(executable), ...normalizedArgs.map(quoteWindowsShellArg)].join(" ");
|
|
94
|
+
return spawnSync(
|
|
95
|
+
process.env.ComSpec || "cmd.exe",
|
|
96
|
+
["/d", "/s", "/c", commandLine],
|
|
97
|
+
options,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return spawnSync(executable, normalizedArgs, options);
|
|
101
|
+
}
|
|
102
|
+
|
|
59
103
|
function buildPrompt(payload, { terse = true } = {}) {
|
|
60
104
|
const safePayload = payload && typeof payload === "object" ? payload : {};
|
|
61
105
|
const trigger = safePayload.trigger && typeof safePayload.trigger === "object" ? safePayload.trigger : {};
|
|
@@ -117,8 +161,9 @@ function normalizeCliResponse(rawText) {
|
|
|
117
161
|
|
|
118
162
|
function runCodex(promptText, workspaceDir) {
|
|
119
163
|
const outputPath = path.join(os.tmpdir(), `metheus-runner-codex-${Date.now()}.txt`);
|
|
120
|
-
const
|
|
121
|
-
|
|
164
|
+
const codexCommand = resolveLocalCliCommand("codex");
|
|
165
|
+
const result = spawnCli(
|
|
166
|
+
codexCommand,
|
|
122
167
|
[
|
|
123
168
|
"exec",
|
|
124
169
|
"-",
|
|
@@ -148,8 +193,9 @@ function runCodex(promptText, workspaceDir) {
|
|
|
148
193
|
}
|
|
149
194
|
|
|
150
195
|
function runClaude(promptText) {
|
|
151
|
-
const
|
|
152
|
-
|
|
196
|
+
const claudeCommand = resolveLocalCliCommand("claude");
|
|
197
|
+
const result = spawnCli(
|
|
198
|
+
claudeCommand,
|
|
153
199
|
[
|
|
154
200
|
"-p",
|
|
155
201
|
promptText,
|
|
@@ -175,8 +221,9 @@ function runClaude(promptText) {
|
|
|
175
221
|
}
|
|
176
222
|
|
|
177
223
|
function runGemini(promptText) {
|
|
178
|
-
const
|
|
179
|
-
|
|
224
|
+
const geminiCommand = resolveLocalCliCommand("gemini");
|
|
225
|
+
const result = spawnCli(
|
|
226
|
+
geminiCommand,
|
|
180
227
|
[
|
|
181
228
|
"-p",
|
|
182
229
|
promptText,
|