latitude-mcp-server 3.2.2 → 3.2.3
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/PROMPT_GUIDE.md +1 -1
- package/dist/api.d.ts +9 -0
- package/dist/api.js +26 -8
- package/dist/tools.js +6 -3
- package/package.json +1 -1
package/PROMPT_GUIDE.md
CHANGED
|
@@ -377,4 +377,4 @@ run_prompt(name: "email-extractor", parameters: { text: "John at john@example.co
|
|
|
377
377
|
|
|
378
378
|
**Dynamic:** "Tool descriptions show prompts + params. No listing needed."
|
|
379
379
|
|
|
380
|
-
**Validate:** "Client-side validation catches errors before API calls."
|
|
380
|
+
**Validate:** "Client-side validation catches errors before API calls."
|
package/dist/api.d.ts
CHANGED
|
@@ -46,9 +46,18 @@ interface PushResponse {
|
|
|
46
46
|
* This is the CLI-style push that sends all changes at once
|
|
47
47
|
*/
|
|
48
48
|
export declare function pushChanges(versionUuid: string, changes: DocumentChange[]): Promise<PushResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Normalize document path for consistent comparison.
|
|
51
|
+
* Handles leading/trailing slashes, whitespace, and ensures consistent format.
|
|
52
|
+
* API may return paths with or without leading slash - this normalizes them.
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizePath(path: string): string;
|
|
49
55
|
/**
|
|
50
56
|
* Compute diff between incoming prompts and existing prompts
|
|
51
57
|
* Returns only the changes that need to be made
|
|
58
|
+
*
|
|
59
|
+
* IMPORTANT: Uses normalized paths to handle API inconsistencies where
|
|
60
|
+
* paths may be returned with or without leading slashes.
|
|
52
61
|
*/
|
|
53
62
|
export declare function computeDiff(incoming: Array<{
|
|
54
63
|
path: string;
|
package/dist/api.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.getProjectId = getProjectId;
|
|
|
18
18
|
exports.listDocuments = listDocuments;
|
|
19
19
|
exports.getDocument = getDocument;
|
|
20
20
|
exports.pushChanges = pushChanges;
|
|
21
|
+
exports.normalizePath = normalizePath;
|
|
21
22
|
exports.computeDiff = computeDiff;
|
|
22
23
|
exports.runDocument = runDocument;
|
|
23
24
|
exports.validatePromptLContent = validatePromptLContent;
|
|
@@ -301,17 +302,34 @@ async function pushChanges(versionUuid, changes) {
|
|
|
301
302
|
body: { changes: apiChanges },
|
|
302
303
|
});
|
|
303
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Normalize document path for consistent comparison.
|
|
307
|
+
* Handles leading/trailing slashes, whitespace, and ensures consistent format.
|
|
308
|
+
* API may return paths with or without leading slash - this normalizes them.
|
|
309
|
+
*/
|
|
310
|
+
function normalizePath(path) {
|
|
311
|
+
return path
|
|
312
|
+
.trim()
|
|
313
|
+
.replace(/^\/+/, '') // Remove leading slashes
|
|
314
|
+
.replace(/\/+$/, '') // Remove trailing slashes
|
|
315
|
+
.replace(/\/+/g, '/'); // Collapse multiple slashes
|
|
316
|
+
}
|
|
304
317
|
/**
|
|
305
318
|
* Compute diff between incoming prompts and existing prompts
|
|
306
319
|
* Returns only the changes that need to be made
|
|
320
|
+
*
|
|
321
|
+
* IMPORTANT: Uses normalized paths to handle API inconsistencies where
|
|
322
|
+
* paths may be returned with or without leading slashes.
|
|
307
323
|
*/
|
|
308
324
|
function computeDiff(incoming, existing) {
|
|
309
325
|
const changes = [];
|
|
310
|
-
|
|
311
|
-
const
|
|
326
|
+
// Build map with NORMALIZED paths as keys for reliable matching
|
|
327
|
+
const existingMap = new Map(existing.map((d) => [normalizePath(d.path), d]));
|
|
328
|
+
const incomingPaths = new Set(incoming.map((p) => normalizePath(p.path)));
|
|
312
329
|
// Check each incoming prompt
|
|
313
330
|
for (const prompt of incoming) {
|
|
314
|
-
const
|
|
331
|
+
const normalizedPath = normalizePath(prompt.path);
|
|
332
|
+
const existingDoc = existingMap.get(normalizedPath);
|
|
315
333
|
if (!existingDoc) {
|
|
316
334
|
// New prompt
|
|
317
335
|
changes.push({
|
|
@@ -321,9 +339,9 @@ function computeDiff(incoming, existing) {
|
|
|
321
339
|
});
|
|
322
340
|
}
|
|
323
341
|
else if (existingDoc.content !== prompt.content) {
|
|
324
|
-
// Modified prompt
|
|
342
|
+
// Modified prompt - use the EXISTING path to ensure API compatibility
|
|
325
343
|
changes.push({
|
|
326
|
-
path:
|
|
344
|
+
path: existingDoc.path,
|
|
327
345
|
content: prompt.content,
|
|
328
346
|
status: 'modified',
|
|
329
347
|
});
|
|
@@ -331,10 +349,10 @@ function computeDiff(incoming, existing) {
|
|
|
331
349
|
// If content is same, no change needed (don't include in changes)
|
|
332
350
|
}
|
|
333
351
|
// Check for deleted prompts (exist remotely but not in incoming)
|
|
334
|
-
for (const
|
|
335
|
-
if (!incomingPaths.has(
|
|
352
|
+
for (const [normalizedExistingPath, doc] of existingMap.entries()) {
|
|
353
|
+
if (!incomingPaths.has(normalizedExistingPath)) {
|
|
336
354
|
changes.push({
|
|
337
|
-
path,
|
|
355
|
+
path: doc.path,
|
|
338
356
|
content: '',
|
|
339
357
|
status: 'deleted',
|
|
340
358
|
});
|
package/dist/tools.js
CHANGED
|
@@ -417,16 +417,19 @@ async function handleAddPrompt(args) {
|
|
|
417
417
|
logger.info(`All ${prompts.length} prompt(s) passed validation`);
|
|
418
418
|
// Get existing prompts
|
|
419
419
|
const existingDocs = await (0, api_js_1.listDocuments)('live');
|
|
420
|
-
|
|
420
|
+
// Use NORMALIZED paths as keys for reliable matching (handles /path vs path inconsistencies)
|
|
421
|
+
const existingMap = new Map(existingDocs.map((d) => [(0, api_js_1.normalizePath)(d.path), d]));
|
|
421
422
|
// Build changes - ALWAYS overwrite if exists, add if new, NEVER delete
|
|
422
423
|
const changes = [];
|
|
423
424
|
for (const prompt of prompts) {
|
|
424
|
-
const
|
|
425
|
+
const normalizedName = (0, api_js_1.normalizePath)(prompt.name);
|
|
426
|
+
const existingDoc = existingMap.get(normalizedName);
|
|
425
427
|
if (existingDoc) {
|
|
426
428
|
// Only include if content is different
|
|
427
429
|
if (existingDoc.content !== prompt.content) {
|
|
430
|
+
// Use the EXISTING path from API to ensure compatibility
|
|
428
431
|
changes.push({
|
|
429
|
-
path:
|
|
432
|
+
path: existingDoc.path,
|
|
430
433
|
content: prompt.content,
|
|
431
434
|
status: 'modified',
|
|
432
435
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "latitude-mcp-server",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "Simplified MCP server for Latitude.so prompt management - 8 focused tools for push, pull, run, and manage prompts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|