persyst-mcp 2.2.6 → 2.2.7
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/README.md +94 -128
- package/bin/export.js +4 -4
- package/bin/extract.js +8 -8
- package/bin/import.js +15 -15
- package/bin/init.js +44 -33
- package/bin/mcp.js +1 -5
- package/bin/monitor.js +511 -0
- package/bin/setup.js +9 -9
- package/package.json +12 -8
- package/src/cache.js +3 -1
- package/src/database.js +4 -2
- package/src/embeddings.js +4 -2
- package/src/events.js +2 -0
- package/src/search.js +2 -2
- package/src/server.js +179 -151
- package/src/text-utils.js +11 -0
- package/src/tools.js +49 -8
- package/src/watcher.js +12 -13
package/bin/init.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync } from 'fs';
|
|
19
|
-
import { join, resolve, dirname } from 'path';
|
|
19
|
+
import { join, resolve, dirname, basename } from 'path';
|
|
20
20
|
import { homedir } from 'os';
|
|
21
21
|
import { fileURLToPath } from 'url';
|
|
22
22
|
import { execSync } from 'child_process';
|
|
@@ -99,7 +99,7 @@ function setupRuleFile(filePath, fileName) {
|
|
|
99
99
|
if (existsSync(filePath)) {
|
|
100
100
|
const existing = readFileSync(filePath, 'utf8');
|
|
101
101
|
if (existing.includes(INSTRUCTION_HEADER)) {
|
|
102
|
-
console.log(`
|
|
102
|
+
console.log(` [SKIP] ${fileName} already has Persyst rules configured.`);
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
content = existing + '\n' + RULE_CONTENT;
|
|
@@ -107,7 +107,7 @@ function setupRuleFile(filePath, fileName) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
writeFileSync(filePath, content.trim() + '\n', 'utf8');
|
|
110
|
-
console.log(`
|
|
110
|
+
console.log(` [OK] ${action} ${fileName}`);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// ============================================================
|
|
@@ -146,7 +146,7 @@ function detectEditors() {
|
|
|
146
146
|
return editors;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
function writeCursorConfig() {
|
|
149
|
+
function writeCursorConfig(projectName) {
|
|
150
150
|
const cursorMcp = join(homedir(), '.cursor', 'mcp.json');
|
|
151
151
|
try {
|
|
152
152
|
const config = existsSync(cursorMcp) ? JSON.parse(readFileSync(cursorMcp, 'utf8')) : {};
|
|
@@ -154,17 +154,20 @@ function writeCursorConfig() {
|
|
|
154
154
|
config.mcpServers.persyst = {
|
|
155
155
|
"command": "npx",
|
|
156
156
|
"args": ["-y", "persyst-mcp"],
|
|
157
|
-
"env": {
|
|
157
|
+
"env": {
|
|
158
|
+
"PERSYST_DB": PERSYST_DB,
|
|
159
|
+
"PERSYST_PROJECT": projectName
|
|
160
|
+
}
|
|
158
161
|
};
|
|
159
162
|
mkdirSync(dirname(cursorMcp), { recursive: true });
|
|
160
163
|
writeFileSync(cursorMcp, JSON.stringify(config, null, 2));
|
|
161
|
-
console.log('
|
|
164
|
+
console.log(' [OK] Cursor MCP config written to ~/.cursor/mcp.json');
|
|
162
165
|
} catch (err) {
|
|
163
|
-
console.error(`
|
|
166
|
+
console.error(` [ERROR] Failed to configure Cursor: ${err.message}`);
|
|
164
167
|
}
|
|
165
168
|
}
|
|
166
169
|
|
|
167
|
-
function writeAiderConfig() {
|
|
170
|
+
function writeAiderConfig(projectName) {
|
|
168
171
|
const aiderYml = join(homedir(), '.aider.conf.yml');
|
|
169
172
|
try {
|
|
170
173
|
let content = '';
|
|
@@ -172,18 +175,18 @@ function writeAiderConfig() {
|
|
|
172
175
|
content = readFileSync(aiderYml, 'utf8');
|
|
173
176
|
}
|
|
174
177
|
if (!content.includes('persyst')) {
|
|
175
|
-
content += `\n# Persyst MCP integration\nmcp:\n - name: persyst\n cmd: npx\n args: ["-y", "persyst-mcp"]\n env:\n PERSYST_DB: ${PERSYST_DB}\n`;
|
|
178
|
+
content += `\n# Persyst MCP integration\nmcp:\n - name: persyst\n cmd: npx\n args: ["-y", "persyst-mcp"]\n env:\n PERSYST_DB: ${PERSYST_DB}\n PERSYST_PROJECT: ${projectName}\n`;
|
|
176
179
|
writeFileSync(aiderYml, content);
|
|
177
|
-
console.log('
|
|
180
|
+
console.log(' [OK] Aider MCP config appended to ~/.aider.conf.yml');
|
|
178
181
|
} else {
|
|
179
|
-
console.log('
|
|
182
|
+
console.log(' [SKIP] Aider already has Persyst configured.');
|
|
180
183
|
}
|
|
181
184
|
} catch (err) {
|
|
182
|
-
console.error(`
|
|
185
|
+
console.error(` [ERROR] Failed to configure Aider: ${err.message}`);
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
|
|
186
|
-
function writeClaudeCodeConfig() {
|
|
189
|
+
function writeClaudeCodeConfig(projectName) {
|
|
187
190
|
const claudeJson = join(homedir(), '.claude.json');
|
|
188
191
|
try {
|
|
189
192
|
const config = existsSync(claudeJson) ? JSON.parse(readFileSync(claudeJson, 'utf8')) : {};
|
|
@@ -191,16 +194,19 @@ function writeClaudeCodeConfig() {
|
|
|
191
194
|
config.mcpServers.persyst = {
|
|
192
195
|
"command": "npx",
|
|
193
196
|
"args": ["-y", "persyst-mcp"],
|
|
194
|
-
"env": {
|
|
197
|
+
"env": {
|
|
198
|
+
"PERSYST_DB": PERSYST_DB,
|
|
199
|
+
"PERSYST_PROJECT": projectName
|
|
200
|
+
}
|
|
195
201
|
};
|
|
196
202
|
writeFileSync(claudeJson, JSON.stringify(config, null, 2));
|
|
197
|
-
console.log('
|
|
203
|
+
console.log(' [OK] Claude Code MCP config written to ~/.claude.json');
|
|
198
204
|
} catch (err) {
|
|
199
|
-
console.error(`
|
|
205
|
+
console.error(` [ERROR] Failed to configure Claude Code: ${err.message}`);
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
|
|
203
|
-
function writeContinueConfig() {
|
|
209
|
+
function writeContinueConfig(projectName) {
|
|
204
210
|
const continueConfig = join(homedir(), '.continue', 'config.json');
|
|
205
211
|
try {
|
|
206
212
|
const config = existsSync(continueConfig) ? JSON.parse(readFileSync(continueConfig, 'utf8')) : {};
|
|
@@ -211,13 +217,16 @@ function writeContinueConfig() {
|
|
|
211
217
|
"name": "persyst",
|
|
212
218
|
"command": "npx",
|
|
213
219
|
"args": ["-y", "persyst-mcp"],
|
|
214
|
-
"env": {
|
|
220
|
+
"env": {
|
|
221
|
+
"PERSYST_DB": PERSYST_DB,
|
|
222
|
+
"PERSYST_PROJECT": projectName
|
|
223
|
+
}
|
|
215
224
|
});
|
|
216
225
|
mkdirSync(dirname(continueConfig), { recursive: true });
|
|
217
226
|
writeFileSync(continueConfig, JSON.stringify(config, null, 2));
|
|
218
|
-
console.log('
|
|
227
|
+
console.log(' [OK] Continue.dev MCP config written to ~/.continue/config.json');
|
|
219
228
|
} catch (err) {
|
|
220
|
-
console.error(`
|
|
229
|
+
console.error(` [ERROR] Failed to configure Continue.dev: ${err.message}`);
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
|
|
@@ -227,22 +236,22 @@ function writeContinueConfig() {
|
|
|
227
236
|
|
|
228
237
|
function run() {
|
|
229
238
|
console.log('');
|
|
230
|
-
console.log('
|
|
239
|
+
console.log(' Persyst — Workspace & Editor Setup');
|
|
231
240
|
console.log(' ══════════════════════════════════════');
|
|
232
241
|
console.log('');
|
|
233
242
|
|
|
234
243
|
const cwd = process.cwd();
|
|
235
|
-
console.log(`
|
|
244
|
+
console.log(` Target workspace: ${cwd}`);
|
|
236
245
|
|
|
237
246
|
// 1. Initialize local configuration folder and attestations
|
|
238
|
-
console.log('
|
|
247
|
+
console.log(' [1/4] Initializing keypairs & DB folders...');
|
|
239
248
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
240
249
|
initializeKeys();
|
|
241
|
-
console.log('
|
|
250
|
+
console.log(' [OK] Cryptographic keypairs generated');
|
|
242
251
|
|
|
243
252
|
// 2. Local workspace configurations
|
|
244
253
|
console.log('');
|
|
245
|
-
console.log('
|
|
254
|
+
console.log(' [2/4] Initializing workspace rule files...');
|
|
246
255
|
|
|
247
256
|
const cursorRulesPath = join(cwd, '.cursorrules');
|
|
248
257
|
setupRuleFile(cursorRulesPath, '.cursorrules');
|
|
@@ -255,7 +264,7 @@ function run() {
|
|
|
255
264
|
|
|
256
265
|
const generalGuidePath = join(cwd, '.persystrules.md');
|
|
257
266
|
writeFileSync(generalGuidePath, GENERAL_GUIDE.trim() + '\n', 'utf8');
|
|
258
|
-
console.log('
|
|
267
|
+
console.log(' [OK] Created .persystrules.md (General Guide)');
|
|
259
268
|
|
|
260
269
|
// 3. Git post-commit hook
|
|
261
270
|
const gitDir = join(cwd, '.git');
|
|
@@ -283,12 +292,12 @@ fi
|
|
|
283
292
|
try {
|
|
284
293
|
chmodSync(postCommitPath, 0o755);
|
|
285
294
|
} catch (_) {}
|
|
286
|
-
console.log('
|
|
295
|
+
console.log(' [OK] Configured Git post-commit hook for auto-ingestion');
|
|
287
296
|
}
|
|
288
297
|
|
|
289
298
|
// 4. Global editor configurations
|
|
290
299
|
console.log('');
|
|
291
|
-
console.log('
|
|
300
|
+
console.log(' [3/4] Initializing global IDE configurations...');
|
|
292
301
|
|
|
293
302
|
const args = process.argv.slice(2);
|
|
294
303
|
const mcpFlag = args.find(a => a.startsWith('--mcp='));
|
|
@@ -297,15 +306,17 @@ fi
|
|
|
297
306
|
const editors = requestedEditors.length > 0 ? requestedEditors : detectEditors();
|
|
298
307
|
console.log(` Detected editors/environments: ${editors.join(', ') || 'none'}`);
|
|
299
308
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (editors.includes('
|
|
303
|
-
if (editors.includes('
|
|
309
|
+
const projectName = basename(cwd);
|
|
310
|
+
|
|
311
|
+
if (editors.includes('cursor')) writeCursorConfig(projectName);
|
|
312
|
+
if (editors.includes('aider')) writeAiderConfig(projectName);
|
|
313
|
+
if (editors.includes('claude-code')) writeClaudeCodeConfig(projectName);
|
|
314
|
+
if (editors.includes('continue')) writeContinueConfig(projectName);
|
|
304
315
|
|
|
305
316
|
// 5. Final self-test and notes
|
|
306
317
|
console.log('');
|
|
307
318
|
console.log(' ══════════════════════════════════════');
|
|
308
|
-
console.log('
|
|
319
|
+
console.log(' Setup complete: Persyst is successfully configured.');
|
|
309
320
|
console.log('');
|
|
310
321
|
console.log(' Next steps:');
|
|
311
322
|
console.log(' 1. Restart your editor to load the new MCP configurations.');
|