@gethmy/mcp 2.3.0 → 2.3.2

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.
Files changed (38) hide show
  1. package/dist/cli.js +80 -23
  2. package/dist/index.js +80 -23
  3. package/dist/lib/active-learning.js +939 -787
  4. package/dist/lib/api-client.js +2527 -638
  5. package/dist/lib/auto-session.js +177 -196
  6. package/dist/lib/cli.js +34954 -128
  7. package/dist/lib/config.js +235 -201
  8. package/dist/lib/consolidation.js +374 -289
  9. package/dist/lib/context-assembly.js +1265 -838
  10. package/dist/lib/graph-expansion.js +139 -155
  11. package/dist/lib/http.js +1917 -130
  12. package/dist/lib/index.js +29525 -5
  13. package/dist/lib/lifecycle-maintenance.js +663 -79
  14. package/dist/lib/memory-cleanup.js +1316 -381
  15. package/dist/lib/onboard.js +2588 -32
  16. package/dist/lib/prompt-builder.js +438 -445
  17. package/dist/lib/remote.js +31733 -143
  18. package/dist/lib/server.js +29389 -3216
  19. package/dist/lib/skills.js +315 -132
  20. package/dist/lib/tui/agents.js +128 -107
  21. package/dist/lib/tui/docs.js +1590 -687
  22. package/dist/lib/tui/setup.js +5698 -804
  23. package/dist/lib/tui/theme.js +183 -86
  24. package/dist/lib/tui/writer.js +1149 -176
  25. package/package.json +2 -2
  26. package/src/api-client.ts +37 -1
  27. package/src/memory-cleanup.ts +92 -52
  28. package/src/server.ts +16 -1
  29. package/dist/lib/__tests__/active-learning.test.js +0 -386
  30. package/dist/lib/__tests__/agent-performance-profiles.test.js +0 -325
  31. package/dist/lib/__tests__/auto-session.test.js +0 -661
  32. package/dist/lib/__tests__/context-assembly.test.js +0 -362
  33. package/dist/lib/__tests__/graph-expansion.test.js +0 -150
  34. package/dist/lib/__tests__/integration-memory-crud.test.js +0 -797
  35. package/dist/lib/__tests__/integration-memory-system.test.js +0 -281
  36. package/dist/lib/__tests__/lifecycle-maintenance.test.js +0 -207
  37. package/dist/lib/__tests__/pattern-detection.test.js +0 -295
  38. package/dist/lib/__tests__/prompt-builder.test.js +0 -418
@@ -1,205 +1,239 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
29
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
+
31
+ // src/config.ts
1
32
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
33
  import { homedir } from "node:os";
3
34
  import { join } from "node:path";
4
- const DEFAULT_API_URL = "https://app.gethmy.com/api";
5
- const LOCAL_CONFIG_FILENAME = ".harmony-mcp.json";
6
- export function getConfigDir() {
7
- return join(homedir(), ".harmony-mcp");
8
- }
9
- export function getConfigPath() {
10
- return join(getConfigDir(), "config.json");
11
- }
12
- export function getLocalConfigPath(cwd) {
13
- return join(cwd || process.cwd(), LOCAL_CONFIG_FILENAME);
14
- }
15
- export function loadConfig() {
16
- const configPath = getConfigPath();
17
- if (!existsSync(configPath)) {
18
- return {
19
- apiKey: null,
20
- apiUrl: DEFAULT_API_URL,
21
- activeWorkspaceId: null,
22
- activeProjectId: null,
23
- userEmail: null,
24
- memoryDir: null,
25
- };
26
- }
27
- try {
28
- const data = readFileSync(configPath, "utf-8");
29
- const config = JSON.parse(data);
30
- return {
31
- apiKey: config.apiKey || null,
32
- apiUrl: config.apiUrl || DEFAULT_API_URL,
33
- activeWorkspaceId: config.activeWorkspaceId || null,
34
- activeProjectId: config.activeProjectId || null,
35
- userEmail: config.userEmail || null,
36
- memoryDir: config.memoryDir || null,
37
- };
38
- }
39
- catch {
40
- return {
41
- apiKey: null,
42
- apiUrl: DEFAULT_API_URL,
43
- activeWorkspaceId: null,
44
- activeProjectId: null,
45
- userEmail: null,
46
- memoryDir: null,
47
- };
48
- }
49
- }
50
- export function saveConfig(config) {
51
- const configDir = getConfigDir();
52
- const configPath = getConfigPath();
53
- if (!existsSync(configDir)) {
54
- mkdirSync(configDir, { recursive: true, mode: 0o700 });
55
- }
56
- const existingConfig = loadConfig();
57
- const newConfig = { ...existingConfig, ...config };
58
- writeFileSync(configPath, JSON.stringify(newConfig, null, 2), {
59
- mode: 0o600,
60
- });
61
- }
62
- export function loadLocalConfig(cwd) {
63
- const localConfigPath = getLocalConfigPath(cwd);
64
- if (!existsSync(localConfigPath)) {
65
- return null;
66
- }
67
- try {
68
- const data = readFileSync(localConfigPath, "utf-8");
69
- const config = JSON.parse(data);
70
- return {
71
- workspaceId: config.workspaceId || null,
72
- projectId: config.projectId || null,
73
- };
74
- }
75
- catch {
76
- return null;
77
- }
78
- }
79
- export function saveLocalConfig(config, cwd) {
80
- const localConfigPath = getLocalConfigPath(cwd);
81
- const existingConfig = loadLocalConfig(cwd) || {
82
- workspaceId: null,
83
- projectId: null,
35
+ var DEFAULT_API_URL = "https://app.gethmy.com/api";
36
+ var LOCAL_CONFIG_FILENAME = ".harmony-mcp.json";
37
+ function getConfigDir() {
38
+ return join(homedir(), ".harmony-mcp");
39
+ }
40
+ function getConfigPath() {
41
+ return join(getConfigDir(), "config.json");
42
+ }
43
+ function getLocalConfigPath(cwd) {
44
+ return join(cwd || process.cwd(), LOCAL_CONFIG_FILENAME);
45
+ }
46
+ function loadConfig() {
47
+ const configPath = getConfigPath();
48
+ if (!existsSync(configPath)) {
49
+ return {
50
+ apiKey: null,
51
+ apiUrl: DEFAULT_API_URL,
52
+ activeWorkspaceId: null,
53
+ activeProjectId: null,
54
+ userEmail: null,
55
+ memoryDir: null
84
56
  };
85
- const newConfig = { ...existingConfig, ...config };
86
- // Remove null values from the saved config for cleaner output
87
- const cleanConfig = {};
88
- if (newConfig.workspaceId)
89
- cleanConfig.workspaceId = newConfig.workspaceId;
90
- if (newConfig.projectId)
91
- cleanConfig.projectId = newConfig.projectId;
92
- writeFileSync(localConfigPath, JSON.stringify(cleanConfig, null, 2));
93
- }
94
- export function hasLocalConfig(cwd) {
95
- return existsSync(getLocalConfigPath(cwd));
96
- }
97
- export function getApiKey() {
98
- const config = loadConfig();
99
- if (!config.apiKey) {
100
- throw new Error('Not configured. Run "npx @gethmy/mcp setup" to set your API key.\n' +
101
- "You can generate an API key at https://gethmy.com → Settings → API Keys.");
102
- }
103
- return config.apiKey;
104
- }
105
- export function getApiUrl() {
106
- const config = loadConfig();
107
- return config.apiUrl;
108
- }
109
- export function getUserEmail() {
110
- const config = loadConfig();
111
- return config.userEmail;
112
- }
113
- export function setUserEmail(email) {
114
- saveConfig({ userEmail: email });
115
- }
116
- export function setActiveWorkspace(workspaceId, options) {
117
- if (options?.local) {
118
- saveLocalConfig({ workspaceId }, options.cwd);
119
- }
120
- else {
121
- saveConfig({ activeWorkspaceId: workspaceId });
122
- }
123
- }
124
- export function setActiveProject(projectId, options) {
125
- if (options?.local) {
126
- saveLocalConfig({ projectId }, options.cwd);
127
- }
128
- else {
129
- saveConfig({ activeProjectId: projectId });
130
- }
131
- }
132
- export function getActiveWorkspaceId(cwd) {
133
- // Local config takes precedence over global
134
- const localConfig = loadLocalConfig(cwd);
135
- if (localConfig?.workspaceId) {
136
- return localConfig.workspaceId;
137
- }
138
- return loadConfig().activeWorkspaceId;
139
- }
140
- export function getActiveProjectId(cwd) {
141
- // Local config takes precedence over global
142
- const localConfig = loadLocalConfig(cwd);
143
- if (localConfig?.projectId) {
144
- return localConfig.projectId;
145
- }
146
- return loadConfig().activeProjectId;
147
- }
148
- export function isConfigured() {
149
- const config = loadConfig();
150
- return !!config.apiKey;
151
- }
152
- /**
153
- * Check if skills are already installed (globally or locally).
154
- * Returns installation status and location.
155
- */
156
- export function areSkillsInstalled(cwd) {
157
- const home = homedir();
158
- const workingDir = cwd || process.cwd();
159
- const foundPaths = [];
160
- // Check global skills directory
161
- const globalSkillsDir = join(home, ".agents", "skills");
162
- const globalSkillPath = join(globalSkillsDir, "hmy", "SKILL.md");
163
- if (existsSync(globalSkillPath)) {
164
- foundPaths.push(globalSkillPath);
165
- return { installed: true, location: "global", paths: foundPaths };
166
- }
167
- // Check Claude global skills (symlinked from global skills)
168
- const claudeGlobalSkill = join(home, ".claude", "skills", "hmy.md");
169
- if (existsSync(claudeGlobalSkill)) {
170
- foundPaths.push(claudeGlobalSkill);
171
- return { installed: true, location: "global", paths: foundPaths };
172
- }
173
- // Check Claude global skills (alternate SKILL.md format)
174
- const claudeGlobalSkillAlt = join(home, ".claude", "skills", "hmy", "SKILL.md");
175
- if (existsSync(claudeGlobalSkillAlt)) {
176
- foundPaths.push(claudeGlobalSkillAlt);
177
- return { installed: true, location: "global", paths: foundPaths };
178
- }
179
- // Check local skills in project directory
180
- const localSkillPath = join(workingDir, ".claude", "skills", "hmy.md");
181
- if (existsSync(localSkillPath)) {
182
- foundPaths.push(localSkillPath);
183
- return { installed: true, location: "local", paths: foundPaths };
184
- }
185
- // Check local skills in project directory (alternate SKILL.md format)
186
- const localSkillPathAlt = join(workingDir, ".claude", "skills", "hmy", "SKILL.md");
187
- if (existsSync(localSkillPathAlt)) {
188
- foundPaths.push(localSkillPathAlt);
189
- return { installed: true, location: "local", paths: foundPaths };
190
- }
191
- return { installed: false, location: null, paths: [] };
192
- }
193
- /**
194
- * Check if project context is configured in the local directory.
195
- */
196
- export function hasProjectContext(cwd) {
197
- const localConfig = loadLocalConfig(cwd);
198
- return !!(localConfig?.workspaceId || localConfig?.projectId);
199
- }
200
- export function getMemoryDir() {
201
- const config = loadConfig();
202
- if (config.memoryDir)
203
- return config.memoryDir;
204
- return join(homedir(), ".harmony", "memory");
205
- }
57
+ }
58
+ try {
59
+ const data = readFileSync(configPath, "utf-8");
60
+ const config = JSON.parse(data);
61
+ return {
62
+ apiKey: config.apiKey || null,
63
+ apiUrl: config.apiUrl || DEFAULT_API_URL,
64
+ activeWorkspaceId: config.activeWorkspaceId || null,
65
+ activeProjectId: config.activeProjectId || null,
66
+ userEmail: config.userEmail || null,
67
+ memoryDir: config.memoryDir || null
68
+ };
69
+ } catch {
70
+ return {
71
+ apiKey: null,
72
+ apiUrl: DEFAULT_API_URL,
73
+ activeWorkspaceId: null,
74
+ activeProjectId: null,
75
+ userEmail: null,
76
+ memoryDir: null
77
+ };
78
+ }
79
+ }
80
+ function saveConfig(config) {
81
+ const configDir = getConfigDir();
82
+ const configPath = getConfigPath();
83
+ if (!existsSync(configDir)) {
84
+ mkdirSync(configDir, { recursive: true, mode: 448 });
85
+ }
86
+ const existingConfig = loadConfig();
87
+ const newConfig = { ...existingConfig, ...config };
88
+ writeFileSync(configPath, JSON.stringify(newConfig, null, 2), {
89
+ mode: 384
90
+ });
91
+ }
92
+ function loadLocalConfig(cwd) {
93
+ const localConfigPath = getLocalConfigPath(cwd);
94
+ if (!existsSync(localConfigPath)) {
95
+ return null;
96
+ }
97
+ try {
98
+ const data = readFileSync(localConfigPath, "utf-8");
99
+ const config = JSON.parse(data);
100
+ return {
101
+ workspaceId: config.workspaceId || null,
102
+ projectId: config.projectId || null
103
+ };
104
+ } catch {
105
+ return null;
106
+ }
107
+ }
108
+ function saveLocalConfig(config, cwd) {
109
+ const localConfigPath = getLocalConfigPath(cwd);
110
+ const existingConfig = loadLocalConfig(cwd) || {
111
+ workspaceId: null,
112
+ projectId: null
113
+ };
114
+ const newConfig = { ...existingConfig, ...config };
115
+ const cleanConfig = {};
116
+ if (newConfig.workspaceId)
117
+ cleanConfig.workspaceId = newConfig.workspaceId;
118
+ if (newConfig.projectId)
119
+ cleanConfig.projectId = newConfig.projectId;
120
+ writeFileSync(localConfigPath, JSON.stringify(cleanConfig, null, 2));
121
+ }
122
+ function hasLocalConfig(cwd) {
123
+ return existsSync(getLocalConfigPath(cwd));
124
+ }
125
+ function getApiKey() {
126
+ const config = loadConfig();
127
+ if (!config.apiKey) {
128
+ throw new Error(`Not configured. Run "npx @gethmy/mcp setup" to set your API key.
129
+ ` + "You can generate an API key at https://gethmy.com → Settings → API Keys.");
130
+ }
131
+ return config.apiKey;
132
+ }
133
+ function getApiUrl() {
134
+ const config = loadConfig();
135
+ return config.apiUrl;
136
+ }
137
+ function getUserEmail() {
138
+ const config = loadConfig();
139
+ return config.userEmail;
140
+ }
141
+ function setUserEmail(email) {
142
+ saveConfig({ userEmail: email });
143
+ }
144
+ function setActiveWorkspace(workspaceId, options) {
145
+ if (options?.local) {
146
+ saveLocalConfig({ workspaceId }, options.cwd);
147
+ } else {
148
+ saveConfig({ activeWorkspaceId: workspaceId });
149
+ }
150
+ }
151
+ function setActiveProject(projectId, options) {
152
+ if (options?.local) {
153
+ saveLocalConfig({ projectId }, options.cwd);
154
+ } else {
155
+ saveConfig({ activeProjectId: projectId });
156
+ }
157
+ }
158
+ function getActiveWorkspaceId(cwd) {
159
+ const localConfig = loadLocalConfig(cwd);
160
+ if (localConfig?.workspaceId) {
161
+ return localConfig.workspaceId;
162
+ }
163
+ return loadConfig().activeWorkspaceId;
164
+ }
165
+ function getActiveProjectId(cwd) {
166
+ const localConfig = loadLocalConfig(cwd);
167
+ if (localConfig?.projectId) {
168
+ return localConfig.projectId;
169
+ }
170
+ return loadConfig().activeProjectId;
171
+ }
172
+ function isConfigured() {
173
+ const config = loadConfig();
174
+ return !!config.apiKey;
175
+ }
176
+ function areSkillsInstalled(cwd) {
177
+ const home = homedir();
178
+ const workingDir = cwd || process.cwd();
179
+ const foundPaths = [];
180
+ const globalSkillsDir = join(home, ".agents", "skills");
181
+ const globalSkillPath = join(globalSkillsDir, "hmy", "SKILL.md");
182
+ if (existsSync(globalSkillPath)) {
183
+ foundPaths.push(globalSkillPath);
184
+ return { installed: true, location: "global", paths: foundPaths };
185
+ }
186
+ const claudeGlobalSkill = join(home, ".claude", "skills", "hmy.md");
187
+ if (existsSync(claudeGlobalSkill)) {
188
+ foundPaths.push(claudeGlobalSkill);
189
+ return { installed: true, location: "global", paths: foundPaths };
190
+ }
191
+ const claudeGlobalSkillAlt = join(home, ".claude", "skills", "hmy", "SKILL.md");
192
+ if (existsSync(claudeGlobalSkillAlt)) {
193
+ foundPaths.push(claudeGlobalSkillAlt);
194
+ return { installed: true, location: "global", paths: foundPaths };
195
+ }
196
+ const localSkillPath = join(workingDir, ".claude", "skills", "hmy.md");
197
+ if (existsSync(localSkillPath)) {
198
+ foundPaths.push(localSkillPath);
199
+ return { installed: true, location: "local", paths: foundPaths };
200
+ }
201
+ const localSkillPathAlt = join(workingDir, ".claude", "skills", "hmy", "SKILL.md");
202
+ if (existsSync(localSkillPathAlt)) {
203
+ foundPaths.push(localSkillPathAlt);
204
+ return { installed: true, location: "local", paths: foundPaths };
205
+ }
206
+ return { installed: false, location: null, paths: [] };
207
+ }
208
+ function hasProjectContext(cwd) {
209
+ const localConfig = loadLocalConfig(cwd);
210
+ return !!(localConfig?.workspaceId || localConfig?.projectId);
211
+ }
212
+ function getMemoryDir() {
213
+ const config = loadConfig();
214
+ if (config.memoryDir)
215
+ return config.memoryDir;
216
+ return join(homedir(), ".harmony", "memory");
217
+ }
218
+ export {
219
+ setUserEmail,
220
+ setActiveWorkspace,
221
+ setActiveProject,
222
+ saveLocalConfig,
223
+ saveConfig,
224
+ loadLocalConfig,
225
+ loadConfig,
226
+ isConfigured,
227
+ hasProjectContext,
228
+ hasLocalConfig,
229
+ getUserEmail,
230
+ getMemoryDir,
231
+ getLocalConfigPath,
232
+ getConfigPath,
233
+ getConfigDir,
234
+ getApiUrl,
235
+ getApiKey,
236
+ getActiveWorkspaceId,
237
+ getActiveProjectId,
238
+ areSkillsInstalled
239
+ };