@mkterswingman/5mghost-yonder 0.0.38 → 0.0.40

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.
@@ -0,0 +1,62 @@
1
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { dirname, join } from "node:path";
4
+ export function getWorkBuddyConfigPath(homeDir = homedir()) {
5
+ return join(homeDir, ".workbuddy", "mcp.json");
6
+ }
7
+ export function getWorkBuddySkillsDir(homeDir = homedir()) {
8
+ return join(homeDir, ".workbuddy", "skills");
9
+ }
10
+ function parseConfig(raw) {
11
+ const parsed = JSON.parse(raw);
12
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
13
+ return parsed;
14
+ }
15
+ throw new Error("WorkBuddy config must be a JSON object");
16
+ }
17
+ export function isWorkBuddyInstallLikelyInstalled(configPath = getWorkBuddyConfigPath()) {
18
+ return existsSync(configPath) || existsSync(dirname(configPath));
19
+ }
20
+ export function writeWorkBuddyConfig(serverName, launcherCommand, configPath = getWorkBuddyConfigPath()) {
21
+ const existingText = existsSync(configPath) ? readFileSync(configPath, "utf8") : null;
22
+ const created = existingText === null;
23
+ const config = existingText ? parseConfig(existingText) : {};
24
+ const mcpServers = config.mcpServers && typeof config.mcpServers === "object"
25
+ ? { ...config.mcpServers }
26
+ : {};
27
+ mcpServers[serverName] = {
28
+ command: launcherCommand.command,
29
+ args: [...launcherCommand.args],
30
+ };
31
+ const nextConfig = {
32
+ ...config,
33
+ mcpServers,
34
+ };
35
+ mkdirSync(dirname(configPath), { recursive: true });
36
+ writeFileSync(configPath, `${JSON.stringify(nextConfig, null, 2)}\n`, "utf8");
37
+ return created ? "created" : "updated";
38
+ }
39
+ export function removeWorkBuddyConfig(serverName, configPath = getWorkBuddyConfigPath()) {
40
+ if (!existsSync(configPath)) {
41
+ return "missing";
42
+ }
43
+ const config = parseConfig(readFileSync(configPath, "utf8"));
44
+ if (!config.mcpServers || typeof config.mcpServers !== "object" || !(serverName in config.mcpServers)) {
45
+ return "missing";
46
+ }
47
+ const nextMcpServers = { ...config.mcpServers };
48
+ delete nextMcpServers[serverName];
49
+ const nextConfig = { ...config };
50
+ if (Object.keys(nextMcpServers).length === 0) {
51
+ delete nextConfig.mcpServers;
52
+ }
53
+ else {
54
+ nextConfig.mcpServers = nextMcpServers;
55
+ }
56
+ if (Object.keys(nextConfig).length === 0) {
57
+ rmSync(configPath, { force: true });
58
+ return "removed";
59
+ }
60
+ writeFileSync(configPath, `${JSON.stringify(nextConfig, null, 2)}\n`, "utf8");
61
+ return "removed";
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkterswingman/5mghost-yonder",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "Internal MCP client with local data tools and remote API proxy",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,11 @@
12
12
  "scripts": {
13
13
  "build": "tsc -p tsconfig.json",
14
14
  "test": "npm run build && node --test tests/*.test.mjs",
15
+ "test:unit": "npm test",
16
+ "test:tool": "npm run build && node --test tests/smoke.test.mjs tests/subtitleTools.test.mjs tests/downloadTools.test.mjs",
17
+ "test:mcp": "npm run test:tool",
18
+ "test:smoke": "npm run build && node dist/cli/index.js --help && node dist/cli/index.js doctor",
19
+ "test:clean-install": "npm run build && node scripts/clean-install-smoke.mjs",
15
20
  "prepublishOnly": "npm run build",
16
21
  "dev": "tsx src/cli/index.ts",
17
22
  "start": "node dist/cli/index.js"