@gethmy/mcp 2.3.1 → 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.
- package/dist/lib/active-learning.js +939 -787
- package/dist/lib/api-client.js +2527 -644
- package/dist/lib/auto-session.js +177 -196
- package/dist/lib/cli.js +34954 -128
- package/dist/lib/config.js +235 -201
- package/dist/lib/consolidation.js +374 -289
- package/dist/lib/context-assembly.js +1265 -838
- package/dist/lib/graph-expansion.js +139 -155
- package/dist/lib/http.js +1917 -130
- package/dist/lib/index.js +29525 -5
- package/dist/lib/lifecycle-maintenance.js +663 -79
- package/dist/lib/memory-cleanup.js +1315 -409
- package/dist/lib/onboard.js +2588 -32
- package/dist/lib/prompt-builder.js +438 -445
- package/dist/lib/remote.js +31733 -143
- package/dist/lib/server.js +29388 -3229
- package/dist/lib/skills.js +315 -132
- package/dist/lib/tui/agents.js +128 -107
- package/dist/lib/tui/docs.js +1590 -687
- package/dist/lib/tui/setup.js +5698 -804
- package/dist/lib/tui/theme.js +183 -86
- package/dist/lib/tui/writer.js +1149 -176
- package/package.json +2 -2
- package/src/memory-cleanup.ts +2 -4
- package/dist/lib/__tests__/active-learning.test.js +0 -386
- package/dist/lib/__tests__/agent-performance-profiles.test.js +0 -325
- package/dist/lib/__tests__/auto-session.test.js +0 -661
- package/dist/lib/__tests__/context-assembly.test.js +0 -362
- package/dist/lib/__tests__/graph-expansion.test.js +0 -150
- package/dist/lib/__tests__/integration-memory-crud.test.js +0 -797
- package/dist/lib/__tests__/integration-memory-system.test.js +0 -281
- package/dist/lib/__tests__/lifecycle-maintenance.test.js +0 -207
- package/dist/lib/__tests__/pattern-detection.test.js +0 -295
- package/dist/lib/__tests__/prompt-builder.test.js +0 -418
package/dist/lib/config.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
+
};
|