@kalera/munin-claude 1.0.6 → 1.2.5
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/.turbo/turbo-build.log +1 -1
- package/dist/cli.js +29 -3
- package/package.json +3 -3
- package/src/cli.ts +33 -5
package/.turbo/turbo-build.log
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { executeWithRetry, loadCliEnv, parseCliArgs, safeError, startMcpServer, } from "@kalera/munin-runtime";
|
|
2
|
+
import { executeWithRetry, loadCliEnv, parseCliArgs, safeError, startMcpServer, writeEnvFile, } from "@kalera/munin-runtime";
|
|
3
3
|
import { createClaudeCodeMuninAdapter } from "./index.js";
|
|
4
4
|
async function main() {
|
|
5
5
|
try {
|
|
6
6
|
const args = process.argv.slice(2);
|
|
7
7
|
// Start MCP server if requested or empty args
|
|
8
|
-
if (args.length === 0 || args[0] ===
|
|
8
|
+
if (args.length === 0 || args[0] === "mcp") {
|
|
9
9
|
await startMcpServer();
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
// Handle env subcommands: munin-claude env <set|get> <key> [value]
|
|
13
|
+
if (args[0] === "env") {
|
|
14
|
+
const [, subcmd, key, ...rest] = args;
|
|
15
|
+
if (subcmd === "set") {
|
|
16
|
+
if (!key)
|
|
17
|
+
throw new Error("Usage: munin-claude env set <key> <value>");
|
|
18
|
+
const value = rest.join(" ");
|
|
19
|
+
if (!value)
|
|
20
|
+
throw new Error("Usage: munin-claude env set <key> <value>");
|
|
21
|
+
writeEnvFile(".env", [{ key, value }]);
|
|
22
|
+
console.log(JSON.stringify({ ok: true, message: `Set ${key} in .env` }));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (subcmd === "get") {
|
|
26
|
+
if (!key)
|
|
27
|
+
throw new Error("Usage: munin-claude env get <key>");
|
|
28
|
+
// Only support MUNIN_PROJECT for now
|
|
29
|
+
if (key !== "MUNIN_PROJECT")
|
|
30
|
+
throw new Error("Only MUNIN_PROJECT is supported");
|
|
31
|
+
const { resolveProjectId } = await import("@kalera/munin-runtime");
|
|
32
|
+
const projectId = resolveProjectId();
|
|
33
|
+
console.log(JSON.stringify({ ok: true, key, value: projectId ?? null }));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
throw new Error("Usage: munin-claude env <set|get> <key> [value]");
|
|
37
|
+
}
|
|
38
|
+
const { action, payload } = parseCliArgs(args, "Usage: munin-claude <action> [payload-json] OR munin-claude mcp OR munin-claude env <set|get>");
|
|
13
39
|
const env = loadCliEnv();
|
|
14
40
|
const adapter = createClaudeCodeMuninAdapter({
|
|
15
41
|
baseUrl: env.baseUrl,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kalera/munin-claude",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"munin-claude": "dist/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@kalera/munin-sdk": "1.
|
|
10
|
-
"@kalera/munin-runtime": "1.
|
|
9
|
+
"@kalera/munin-sdk": "1.2.5",
|
|
10
|
+
"@kalera/munin-runtime": "1.2.5"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"typescript": "^5.9.2"
|
package/src/cli.ts
CHANGED
|
@@ -5,29 +5,55 @@ import {
|
|
|
5
5
|
parseCliArgs,
|
|
6
6
|
safeError,
|
|
7
7
|
startMcpServer,
|
|
8
|
+
writeEnvFile,
|
|
8
9
|
} from "@kalera/munin-runtime";
|
|
9
10
|
import { createClaudeCodeMuninAdapter } from "./index.js";
|
|
10
11
|
|
|
11
12
|
async function main() {
|
|
12
13
|
try {
|
|
13
14
|
const args = process.argv.slice(2);
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
// Start MCP server if requested or empty args
|
|
16
|
-
if (args.length === 0 || args[0] ===
|
|
17
|
+
if (args.length === 0 || args[0] === "mcp") {
|
|
17
18
|
await startMcpServer();
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
// Handle env subcommands: munin-claude env <set|get> <key> [value]
|
|
23
|
+
if (args[0] === "env") {
|
|
24
|
+
const [, subcmd, key, ...rest] = args;
|
|
25
|
+
|
|
26
|
+
if (subcmd === "set") {
|
|
27
|
+
if (!key) throw new Error("Usage: munin-claude env set <key> <value>");
|
|
28
|
+
const value = rest.join(" ");
|
|
29
|
+
if (!value) throw new Error("Usage: munin-claude env set <key> <value>");
|
|
30
|
+
writeEnvFile(".env", [{ key, value }]);
|
|
31
|
+
console.log(JSON.stringify({ ok: true, message: `Set ${key} in .env` }));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (subcmd === "get") {
|
|
36
|
+
if (!key) throw new Error("Usage: munin-claude env get <key>");
|
|
37
|
+
// Only support MUNIN_PROJECT for now
|
|
38
|
+
if (key !== "MUNIN_PROJECT") throw new Error("Only MUNIN_PROJECT is supported");
|
|
39
|
+
const { resolveProjectId } = await import("@kalera/munin-runtime");
|
|
40
|
+
const projectId = resolveProjectId();
|
|
41
|
+
console.log(JSON.stringify({ ok: true, key, value: projectId ?? null }));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error("Usage: munin-claude env <set|get> <key> [value]");
|
|
46
|
+
}
|
|
47
|
+
|
|
21
48
|
const { action, payload } = parseCliArgs(
|
|
22
49
|
args,
|
|
23
|
-
"Usage: munin-claude <action> [payload-json] OR munin-claude mcp",
|
|
50
|
+
"Usage: munin-claude <action> [payload-json] OR munin-claude mcp OR munin-claude env <set|get>",
|
|
24
51
|
);
|
|
25
52
|
const env = loadCliEnv();
|
|
26
53
|
|
|
27
54
|
const adapter = createClaudeCodeMuninAdapter({
|
|
28
55
|
baseUrl: env.baseUrl,
|
|
29
56
|
apiKey: env.apiKey,
|
|
30
|
-
|
|
31
57
|
timeoutMs: env.timeoutMs,
|
|
32
58
|
});
|
|
33
59
|
|
|
@@ -35,7 +61,9 @@ async function main() {
|
|
|
35
61
|
if (action === "capabilities") {
|
|
36
62
|
return { ok: true, data: await adapter.capabilities() };
|
|
37
63
|
}
|
|
38
|
-
const { projectId, ...p } = payload;
|
|
64
|
+
const { projectId, ...p } = payload;
|
|
65
|
+
if (!projectId) throw new Error("projectId required in payload");
|
|
66
|
+
return adapter.execute(projectId as string, action, p);
|
|
39
67
|
}, env.retries, env.backoffMs);
|
|
40
68
|
|
|
41
69
|
console.log(JSON.stringify(result, null, 2));
|