farseer-cli 1.3.0 → 1.5.0

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 (63) hide show
  1. package/README.md +102 -30
  2. package/dist/commands/checkout.js +3 -8
  3. package/dist/commands/checkout.js.map +2 -2
  4. package/dist/commands/dimensions.js +8 -8
  5. package/dist/commands/dimensions.js.map +2 -2
  6. package/dist/commands/model.js +29 -13
  7. package/dist/commands/model.js.map +2 -2
  8. package/dist/commands/pull.js +159 -46
  9. package/dist/commands/pull.js.map +2 -2
  10. package/dist/commands/push.js +185 -75
  11. package/dist/commands/push.js.map +2 -2
  12. package/dist/commands/run.js +31 -30
  13. package/dist/commands/run.js.map +2 -2
  14. package/dist/commands/status.js +26 -33
  15. package/dist/commands/status.js.map +2 -2
  16. package/dist/commands/variables.js +2 -2
  17. package/dist/commands/variables.js.map +2 -2
  18. package/dist/index.js +5 -3
  19. package/dist/index.js.map +2 -2
  20. package/dist/mcp/tools/appTools.js +6 -20
  21. package/dist/mcp/tools/appTools.js.map +2 -2
  22. package/dist/mcp/tools/authTools.js +2 -1
  23. package/dist/mcp/tools/authTools.js.map +2 -2
  24. package/dist/mcp/tools/cellTools.js +2 -10
  25. package/dist/mcp/tools/cellTools.js.map +2 -2
  26. package/dist/mcp/tools/dashboardTools.js +12 -23
  27. package/dist/mcp/tools/dashboardTools.js.map +2 -2
  28. package/dist/mcp/tools/dataTools.js +5 -16
  29. package/dist/mcp/tools/dataTools.js.map +2 -2
  30. package/dist/mcp/tools/folderTools.js +3 -11
  31. package/dist/mcp/tools/folderTools.js.map +2 -2
  32. package/dist/mcp/tools/modelTools.js +61 -69
  33. package/dist/mcp/tools/modelTools.js.map +2 -2
  34. package/dist/mcp/tools/runTools.js +3 -8
  35. package/dist/mcp/tools/runTools.js.map +2 -2
  36. package/dist/mcp/tools/sheetTools.js +11 -22
  37. package/dist/mcp/tools/sheetTools.js.map +2 -2
  38. package/dist/mcp/tools/syncTools.js +132 -47
  39. package/dist/mcp/tools/syncTools.js.map +2 -2
  40. package/dist/mcp/utils/helpers.js +2 -2
  41. package/dist/mcp/utils/helpers.js.map +2 -2
  42. package/dist/services/appSyncService.js +3 -2
  43. package/dist/services/appSyncService.js.map +2 -2
  44. package/dist/services/farseerApi.js +120 -72
  45. package/dist/services/farseerApi.js.map +2 -2
  46. package/dist/services/farseerFactory.js +1 -1
  47. package/dist/services/farseerFactory.js.map +2 -2
  48. package/dist/services/farseerService.js +87 -47
  49. package/dist/services/farseerService.js.map +2 -2
  50. package/dist/services/syncService.js +322 -182
  51. package/dist/services/syncService.js.map +3 -3
  52. package/dist/utils/cliOptions.js +36 -0
  53. package/dist/utils/cliOptions.js.map +7 -0
  54. package/dist/utils/errorFormatter.js +152 -0
  55. package/dist/utils/errorFormatter.js.map +7 -0
  56. package/dist/utils/fileLogger.js +13 -0
  57. package/dist/utils/fileLogger.js.map +2 -2
  58. package/dist/utils/fileValidation.js +180 -0
  59. package/dist/utils/fileValidation.js.map +7 -0
  60. package/dist/utils/helpers.js +85 -14
  61. package/dist/utils/helpers.js.map +2 -2
  62. package/docs/cli-guide.md +49 -4
  63. package/package.json +1 -1
@@ -27,23 +27,49 @@ var import_syncService = require("../../services/syncService");
27
27
  var import_appSyncService = require("../../services/appSyncService");
28
28
  var import_farseerFactory = require("../../services/farseerFactory");
29
29
  var import_helpers = require("../utils/helpers");
30
+ var import_errorFormatter = require("../../utils/errorFormatter");
31
+ const includeExtensionsSchema = import_zod.z.array(import_zod.z.string()).optional().describe(
32
+ `Extra file extensions to include alongside the default .ts / .js scripts. Supply with or without leading dot (".csv" or "csv"). Mirrors the CLI's --include-ext flag.`
33
+ );
34
+ const includeFoldersSchema = import_zod.z.array(import_zod.z.string()).optional().describe(
35
+ `Extra folder paths whose files (any extension) are included alongside the default scripts. Each path is interpreted relative to the tenant root, e.g. "Data" or "Config/local". Mirrors the CLI's --include-folder flag.`
36
+ );
30
37
  const pullSchema = {
31
38
  organisation: import_zod.z.string().optional().describe(
32
39
  'Farseer organisation (subdomain, e.g. "salvus-2"). If omitted, uses checked-out org or saved mapping.'
33
40
  ),
34
41
  tenant: import_zod.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
35
42
  all: import_zod.z.boolean().optional().describe("Download all files, not just scripts (.ts, .js)"),
36
- force: import_zod.z.boolean().optional().describe("Force pull, overwriting local changes on conflicts")
43
+ force: import_zod.z.boolean().optional().describe(
44
+ "DESTRUCTIVE \u2014 overwrites EVERY locally-modified file with the remote version, including local edits that have no remote conflict (e.g. a file you've been editing but the remote is still on the baseline version). Use only when the user has explicitly asked to discard local changes. Does NOT delete local-only files (that destructive wipe stays on the CLI side behind the interactive confirm prompt)."
45
+ ),
46
+ includeExtensions: includeExtensionsSchema,
47
+ includeFolders: includeFoldersSchema
37
48
  };
38
49
  const pushSchema = {
39
50
  organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
40
51
  tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
41
- force: import_zod.z.boolean().optional().describe("Skip remote changes check (may overwrite remote changes)")
52
+ force: import_zod.z.boolean().optional().describe(
53
+ "Skip the drift check and overwrite remote even if it diverged from baseline. Does NOT delete remote-only files; pass mirror=true for that."
54
+ ),
55
+ mirror: import_zod.z.boolean().optional().describe(
56
+ `Also delete remote files that have no local counterpart \u2014 destructive "make remote = local" semantics. Implies the upload step still respects the user's local presence, so this only fires for files genuinely missing locally. Combine with force=true if the drift check would otherwise refuse the push.`
57
+ ),
58
+ all: import_zod.z.boolean().optional().describe(
59
+ "Push all files, not just scripts (.ts, .js). Excludes hidden files unless includeFolders names them."
60
+ ),
61
+ includeExtensions: includeExtensionsSchema,
62
+ includeFolders: includeFoldersSchema
42
63
  };
43
64
  const statusSchema = {
44
65
  organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
45
66
  tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
46
- all: import_zod.z.boolean().optional().describe("Show all files, not just scripts")
67
+ all: import_zod.z.boolean().optional().describe("Show all files, not just scripts"),
68
+ deep: import_zod.z.boolean().optional().describe(
69
+ "Hash every remote file to also detect remote-side content edits. Slow on big tenants. Default is fast mode (list-only) which can miss edits made by other users since last pull."
70
+ ),
71
+ includeExtensions: includeExtensionsSchema,
72
+ includeFolders: includeFoldersSchema
47
73
  };
48
74
  const diffSchema = {
49
75
  organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain)."),
@@ -68,8 +94,22 @@ What gets pulled:
68
94
  Files are saved to: farseer-apps/<tenant>/files/
69
95
  Apps are saved to: farseer-apps/<tenant>/apps/
70
96
 
71
- By default only script files (.ts, .js, .mjs, .cjs) are pulled.
97
+ By default only script files (.ts, .js) are pulled.
72
98
  Use all=true to pull all files including images, data files, etc.
99
+ Use includeExtensions / includeFolders to broaden the scope without pulling everything
100
+ (e.g. includeExtensions=["csv"] adds CSV files; includeFolders=["Data"] adds the Data
101
+ folder regardless of extension). These mirror the CLI's --include-ext / --include-folder
102
+ flags and are additive on top of the default scripts.
103
+
104
+ Conflict handling:
105
+ - Per-file conflict resolution (keep_local / keep_remote / keep_both / merge_markers)
106
+ is CLI-only \u2014 it requires an interactive prompt and the MCP can't answer one.
107
+ - The MCP path returns conflicts in response.conflicts[] so the agent can re-pull
108
+ with force=true once the user has confirmed they want to discard their edits.
109
+ - force=true is DESTRUCTIVE: it overwrites every locally-modified file with the
110
+ remote version (even local edits that don't conflict with remote). It does NOT
111
+ wipe local-only files (that destructive step lives behind the CLI's confirm prompt).
112
+ Only pass force=true when the user has explicitly accepted losing local changes.
73
113
 
74
114
  Sync includes (middle ground between scripts-only and all):
75
115
  - Users can configure extra extensions and folders via "farseer config include" CLI command
@@ -96,7 +136,12 @@ Organisation and tenant:
96
136
  }
97
137
  try {
98
138
  const syncService = new import_syncService.SyncService(tenant, clientResult.client);
99
- const fileResult = await syncService.pull({ all: params.all, force: params.force });
139
+ const fileResult = await syncService.pull({
140
+ all: params.all,
141
+ force: params.force,
142
+ includeExtensions: params.includeExtensions,
143
+ includeFolders: params.includeFolders
144
+ });
100
145
  let appResult = null;
101
146
  if (clientResult.authType === "jwt") {
102
147
  const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
@@ -132,10 +177,7 @@ Organisation and tenant:
132
177
  }
133
178
  return (0, import_helpers.successResponse)(response);
134
179
  } catch (error) {
135
- return (0, import_helpers.errorResponse)(
136
- `Pull failed: ${error instanceof Error ? error.message : "Unknown error"}`,
137
- "NETWORK_ERROR"
138
- );
180
+ return (0, import_helpers.errorResponse)(`Pull failed: ${await (0, import_errorFormatter.formatClientError)(error)}`, "NETWORK_ERROR");
139
181
  }
140
182
  }
141
183
  );
@@ -144,16 +186,31 @@ Organisation and tenant:
144
186
  `Push (upload) local file and app changes to a Farseer instance.
145
187
 
146
188
  What gets pushed:
147
- - New/modified scripts from farseer-apps/<tenant>/files/
148
- - New/modified app configurations from farseer-apps/<tenant>/apps/
149
- - Deleted files (if they were previously synced)
189
+ - New/modified scripts from farseer-apps/<tenant>/files/ (filtered by sync scope \u2014
190
+ default is .ts/.js; broaden via includeExtensions / includeFolders / all on this
191
+ tool, or via persistent sync includes set with the CLI's "farseer config include").
192
+ - New/modified app configurations from farseer-apps/<tenant>/apps/.
193
+ - Deleted files (when they were previously synced \u2014 preserves "I rm'd this" semantics).
194
+
195
+ Pre-flight (runs before any HTTP call):
196
+ - Refuses files the backend would refuse anyway: extension not on whitelist,
197
+ filename longer than 256 chars, empty body, unresolved git-style merge markers
198
+ (<<<<<<< LOCAL / ======= / >>>>>>> REMOTE) left over from a merge_markers pull.
199
+ - Returns rejected files in the response. If every candidate is rejected (and
200
+ no deletes/updates either), the tool call returns VALIDATION_ERROR.
150
201
 
151
- Important:
152
- - Checks for unpulled remote changes first to prevent conflicts
153
- - Use force=true to skip this check (may overwrite remote changes)
202
+ Drift / mirror semantics:
203
+ - force=true skips the drift check (push over remote-side adds/deletes).
204
+ - mirror=true (separate param) also deletes remote files that have no local
205
+ counterpart, within the current sync scope. Combine with force when both are
206
+ needed.
154
207
 
155
- Note: If the user has configured sync includes (via "farseer config include"),
156
- the remote change check respects those settings automatically.
208
+ Out-of-scope files (e.g. a hidden .vscode/settings.json next to scripts) are
209
+ INVISIBLE to push \u2014 never uploaded, never deleted. Hidden paths require explicit
210
+ opt-in via --include-folder.
211
+
212
+ Sync includes: if user configured via "farseer config include", drift and scope
213
+ checks respect those settings automatically.
157
214
 
158
215
  If no tenant is specified, uses the currently checked-out tenant.`,
159
216
  pushSchema,
@@ -170,15 +227,21 @@ If no tenant is specified, uses the currently checked-out tenant.`,
170
227
  try {
171
228
  const syncService = new import_syncService.SyncService(tenant, clientResult.client);
172
229
  if (!params.force) {
173
- const hasRemoteChanges = await syncService.checkRemoteChanges();
174
- if (hasRemoteChanges) {
230
+ const drift = await syncService.checkRemoteChanges();
231
+ if (drift.drift) {
175
232
  return (0, import_helpers.errorResponse)(
176
- "Remote has unpulled changes. Pull first or use force=true to overwrite.",
233
+ `Remote has unpulled changes (added: ${drift.addedRemotely.length}, deleted: ${drift.deletedRemotely.length}). Pull first or use force=true to overwrite.`,
177
234
  "VALIDATION_ERROR"
178
235
  );
179
236
  }
180
237
  }
181
- const fileResult = await syncService.push({ force: params.force });
238
+ const fileResult = await syncService.push({
239
+ force: params.force,
240
+ mirror: params.mirror,
241
+ all: params.all,
242
+ includeExtensions: params.includeExtensions,
243
+ includeFolders: params.includeFolders
244
+ });
182
245
  if (fileResult.conflicts.length > 0) {
183
246
  return (0, import_helpers.errorResponse)(
184
247
  `Push blocked by ${fileResult.conflicts.length} conflict(s):
@@ -188,6 +251,28 @@ Pull first or use force=true.`,
188
251
  "VALIDATION_ERROR"
189
252
  );
190
253
  }
254
+ if (fileResult.rejected && fileResult.rejected.length > 0) {
255
+ const summary = fileResult.rejected.map((r) => ` - ${r.filePath}: ${r.detail}`).join("\n");
256
+ const appliedAny = fileResult.uploaded.length + fileResult.updated.length + fileResult.deleted.length > 0;
257
+ if (!appliedAny) {
258
+ return (0, import_helpers.errorResponse)(
259
+ `Push rejected \u2014 backend would refuse every candidate file:
260
+ ${summary}`,
261
+ "VALIDATION_ERROR"
262
+ );
263
+ }
264
+ }
265
+ if (fileResult.failed && fileResult.failed.length > 0) {
266
+ const failureSummary = fileResult.failed.map((f) => ` - ${f.filePath} (${f.operation}): ${f.reason}`).join("\n");
267
+ const appliedAny = fileResult.uploaded.length + fileResult.updated.length + fileResult.deleted.length > 0;
268
+ if (!appliedAny) {
269
+ return (0, import_helpers.errorResponse)(
270
+ `Push failed mid-flight \u2014 every attempted file errored:
271
+ ${failureSummary}`,
272
+ "NETWORK_ERROR"
273
+ );
274
+ }
275
+ }
191
276
  let appResult = null;
192
277
  if (clientResult.authType === "jwt") {
193
278
  const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
@@ -200,20 +285,19 @@ Pull first or use force=true.`,
200
285
  uploaded: fileResult.uploaded,
201
286
  updated: fileResult.updated,
202
287
  deleted: fileResult.deleted,
203
- unchanged: fileResult.unchanged.length
288
+ unchanged: fileResult.unchanged.length,
289
+ rejected: fileResult.rejected ?? [],
290
+ failed: fileResult.failed ?? []
204
291
  },
205
292
  apps: appResult ? {
206
293
  created: appResult.created,
207
294
  updated: appResult.updated,
208
295
  unchanged: appResult.unchanged.length
209
296
  } : { note: "App sync requires browser login (JWT)" },
210
- summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ""}`
297
+ summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ""}${fileResult.rejected && fileResult.rejected.length > 0 ? ` (${fileResult.rejected.length} skipped \u2014 see files.rejected)` : ""}${fileResult.failed && fileResult.failed.length > 0 ? ` (${fileResult.failed.length} failed mid-push \u2014 see files.failed)` : ""}`
211
298
  });
212
299
  } catch (error) {
213
- return (0, import_helpers.errorResponse)(
214
- `Push failed: ${error instanceof Error ? error.message : "Unknown error"}`,
215
- "NETWORK_ERROR"
216
- );
300
+ return (0, import_helpers.errorResponse)(`Push failed: ${await (0, import_errorFormatter.formatClientError)(error)}`, "NETWORK_ERROR");
217
301
  }
218
302
  }
219
303
  );
@@ -248,27 +332,35 @@ If no tenant is specified, uses the currently checked-out tenant.`,
248
332
  }
249
333
  try {
250
334
  const syncService = new import_syncService.SyncService(tenant, clientResult.client);
251
- const fileStatus = await syncService.getStatus({ all: params.all });
335
+ const fileStatus = await syncService.getStatus({
336
+ all: params.all,
337
+ deep: params.deep,
338
+ includeExtensions: params.includeExtensions,
339
+ includeFolders: params.includeFolders
340
+ });
252
341
  let appStatus = null;
253
342
  if (clientResult.authType === "jwt") {
254
343
  const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
255
344
  appStatus = await appSyncService.getStatus();
256
345
  }
257
- const hasChanges = fileStatus.modifiedLocally.length > 0 || fileStatus.modifiedRemotely.length > 0 || fileStatus.onlyLocal.length > 0 || fileStatus.onlyRemote.length > 0 || fileStatus.conflicts && fileStatus.conflicts.length > 0;
346
+ const hasChanges = fileStatus.modifiedLocally.length > 0 || fileStatus.modifiedRemotely.length > 0 || fileStatus.addedLocally.length > 0 || fileStatus.addedRemotely.length > 0 || fileStatus.deletedLocally.length > 0 || fileStatus.deletedRemotely.length > 0 || fileStatus.conflicts.length > 0;
258
347
  return (0, import_helpers.successResponse)({
259
348
  tenant,
260
349
  organisation,
261
350
  files: {
351
+ addedLocally: fileStatus.addedLocally,
262
352
  modifiedLocally: fileStatus.modifiedLocally,
353
+ deletedLocally: fileStatus.deletedLocally,
354
+ addedRemotely: fileStatus.addedRemotely,
263
355
  modifiedRemotely: fileStatus.modifiedRemotely,
264
- onlyLocal: fileStatus.onlyLocal,
265
- onlyRemote: fileStatus.onlyRemote,
356
+ deletedRemotely: fileStatus.deletedRemotely,
266
357
  inSync: fileStatus.inSync.length,
267
- conflicts: fileStatus.conflicts?.map((c) => ({
358
+ deepCompare: fileStatus.deepCompare,
359
+ conflicts: fileStatus.conflicts.map((c) => ({
268
360
  file: c.filePath,
269
361
  type: c.type,
270
362
  description: c.description
271
- })) ?? []
363
+ }))
272
364
  },
273
365
  apps: appStatus ? {
274
366
  newLocal: appStatus.newLocal,
@@ -279,10 +371,7 @@ If no tenant is specified, uses the currently checked-out tenant.`,
279
371
  summary: fileStatus.conflicts?.length ? `${fileStatus.conflicts.length} conflict(s) detected` : hasChanges ? "Changes detected" : "Everything is in sync"
280
372
  });
281
373
  } catch (error) {
282
- return (0, import_helpers.errorResponse)(
283
- `Status check failed: ${error instanceof Error ? error.message : "Unknown error"}`,
284
- "NETWORK_ERROR"
285
- );
374
+ return (0, import_helpers.errorResponse)(`Status check failed: ${await (0, import_errorFormatter.formatClientError)(error)}`, "NETWORK_ERROR");
286
375
  }
287
376
  }
288
377
  );
@@ -328,10 +417,12 @@ If no file is specified, shows diffs for all changed files.`,
328
417
  } else {
329
418
  const status = await syncService.getStatus();
330
419
  const changedFiles = [
420
+ ...status.addedLocally,
331
421
  ...status.modifiedLocally,
422
+ ...status.deletedLocally,
423
+ ...status.addedRemotely,
332
424
  ...status.modifiedRemotely,
333
- ...status.onlyLocal,
334
- ...status.onlyRemote
425
+ ...status.deletedRemotely
335
426
  ];
336
427
  const diffs = [];
337
428
  for (const f of changedFiles.slice(0, 10)) {
@@ -351,10 +442,7 @@ If no file is specified, shows diffs for all changed files.`,
351
442
  });
352
443
  }
353
444
  } catch (error) {
354
- return (0, import_helpers.errorResponse)(
355
- `Diff failed: ${error instanceof Error ? error.message : "Unknown error"}`,
356
- "NETWORK_ERROR"
357
- );
445
+ return (0, import_helpers.errorResponse)(`Diff failed: ${await (0, import_errorFormatter.formatClientError)(error)}`, "NETWORK_ERROR");
358
446
  }
359
447
  }
360
448
  );
@@ -403,10 +491,7 @@ Returns file paths relative to the Files/ folder.`,
403
491
  byDirectory
404
492
  });
405
493
  } catch (error) {
406
- return (0, import_helpers.errorResponse)(
407
- `List files failed: ${error instanceof Error ? error.message : "Unknown error"}`,
408
- "NETWORK_ERROR"
409
- );
494
+ return (0, import_helpers.errorResponse)(`List files failed: ${await (0, import_errorFormatter.formatClientError)(error)}`, "NETWORK_ERROR");
410
495
  }
411
496
  }
412
497
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/tools/syncTools.ts"],
4
- "sourcesContent": ["/**\n * File Synchronization Tools\n *\n * Tools for syncing files between local repository and Farseer instance.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { createPatch } from 'diff';\nimport { SyncService } from '../../services/syncService';\nimport { AppSyncService } from '../../services/appSyncService';\nimport { getFarseerClientWithFallback } from '../../services/farseerFactory';\nimport {\n resolveOrgAndTenant,\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst pullSchema = {\n organisation: z\n .string()\n .optional()\n .describe(\n 'Farseer organisation (subdomain, e.g. \"salvus-2\"). If omitted, uses checked-out org or saved mapping.',\n ),\n tenant: z.string().optional().describe('Tenant ID (e.g. \"salvus-prodaja\"). Uses checked-out tenant if omitted.'),\n all: z.boolean().optional().describe('Download all files, not just scripts (.ts, .js)'),\n force: z.boolean().optional().describe('Force pull, overwriting local changes on conflicts'),\n};\n\nconst pushSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n force: z.boolean().optional().describe('Skip remote changes check (may overwrite remote changes)'),\n};\n\nconst statusSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n all: z.boolean().optional().describe('Show all files, not just scripts'),\n};\n\nconst diffSchema = {\n organisation: z.string().optional().describe('Farseer organisation (subdomain).'),\n tenant: z.string().optional().describe('Tenant ID'),\n file: z.string().optional().describe('Specific file path to diff. If omitted, shows all differences.'),\n showRemote: z.boolean().optional().describe('Show only the remote content instead of diff'),\n};\n\nconst listFilesSchema = {\n organisation: z.string().optional().describe('Farseer organisation (subdomain).'),\n tenant: z.string().optional().describe('Tenant ID'),\n all: z.boolean().optional().describe('Show all files, not just scripts'),\n};\n\nexport function registerSyncTools(server: McpServer): void {\n // farseer_pull - Download files from remote\n server.tool(\n 'farseer_pull',\n `Pull (download) files and app configurations from a Farseer instance to the local repository.\n\nWhat gets pulled:\n- TypeScript/JavaScript scripts from Files/ folder (searched recursively)\n- App configurations (saved as JSON in apps/ folder)\n\nFiles are saved to: farseer-apps/<tenant>/files/\nApps are saved to: farseer-apps/<tenant>/apps/\n\nBy default only script files (.ts, .js, .mjs, .cjs) are pulled.\nUse all=true to pull all files including images, data files, etc.\n\nSync includes (middle ground between scripts-only and all):\n- Users can configure extra extensions and folders via \"farseer config include\" CLI command\n- These are stored per-tenant in ~/.farseer/config.json under \"syncIncludes\"\n- When configured, pull/push/status automatically include those files alongside default scripts\n- Example: syncIncludes may add .json files or entire folders like \"Config\" or \"App Logs\"\n- The sync includes are respected automatically \u2014 no extra parameters needed here\n\nOrganisation and tenant:\n- Organisation = subdomain (e.g. \"salvus-2\" for salvus-2.farseer.io)\n- Tenant = workspace ID (e.g. \"salvus-prodaja\")\n- Often they are the same. Only specify organisation when it differs from tenant.\n- If checked out, both are resolved automatically.`,\n pullSchema,\n async (params: { organisation?: string; tenant?: string; all?: boolean; force?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n // Pull files (use tenant for folder path)\n const syncService = new SyncService(tenant, clientResult.client);\n const fileResult = await syncService.pull({ all: params.all, force: params.force });\n\n // Pull apps (only with JWT auth)\n let appResult = null;\n if (clientResult.authType === 'jwt') {\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appResult = await appSyncService.pull();\n }\n\n const response: Record<string, any> = {\n tenant,\n organisation,\n files: {\n downloaded: fileResult.downloaded,\n deleted: fileResult.deleted,\n unchanged: fileResult.unchanged.length,\n },\n apps: appResult\n ? {\n created: appResult.created,\n updated: appResult.updated,\n deleted: appResult.deleted,\n unchanged: appResult.unchanged.length,\n }\n : { note: 'App sync requires browser login (JWT)' },\n message: `Pulled ${fileResult.downloaded.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,\n };\n\n if (fileResult.conflicts.length > 0) {\n response.conflicts = fileResult.conflicts.map((c) => ({\n file: c.filePath,\n type: c.type,\n description: c.description,\n }));\n response.message = `Pulled ${fileResult.downloaded.length} files but ${fileResult.conflicts.length} conflict(s) need resolution`;\n response.hint =\n 'Use force=true to overwrite local changes, or resolve conflicts via CLI: farseer pull <tenant>';\n }\n\n if (fileResult.conflictFilesWritten.length > 0) {\n response.conflictFilesWritten = fileResult.conflictFilesWritten;\n }\n\n return successResponse(response);\n } catch (error) {\n return errorResponse(\n `Pull failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'NETWORK_ERROR',\n );\n }\n },\n );\n\n // farseer_push - Upload files to remote\n server.tool(\n 'farseer_push',\n `Push (upload) local file and app changes to a Farseer instance.\n\nWhat gets pushed:\n- New/modified scripts from farseer-apps/<tenant>/files/\n- New/modified app configurations from farseer-apps/<tenant>/apps/\n- Deleted files (if they were previously synced)\n\nImportant:\n- Checks for unpulled remote changes first to prevent conflicts\n- Use force=true to skip this check (may overwrite remote changes)\n\nNote: If the user has configured sync includes (via \"farseer config include\"),\nthe remote change check respects those settings automatically.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n pushSchema,\n async (params: { organisation?: string; tenant?: string; force?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Check for remote changes unless force is true\n if (!params.force) {\n const hasRemoteChanges = await syncService.checkRemoteChanges();\n if (hasRemoteChanges) {\n return errorResponse(\n 'Remote has unpulled changes. Pull first or use force=true to overwrite.',\n 'VALIDATION_ERROR',\n );\n }\n }\n\n // Push files\n const fileResult = await syncService.push({ force: params.force });\n\n // Check for conflicts\n if (fileResult.conflicts.length > 0) {\n return errorResponse(\n `Push blocked by ${fileResult.conflicts.length} conflict(s):\\n${fileResult.conflicts.map((c) => ` - ${c.filePath}: ${c.description}`).join('\\n')}\\n\\nPull first or use force=true.`,\n 'VALIDATION_ERROR',\n );\n }\n\n // Push apps (only with JWT auth)\n let appResult = null;\n if (clientResult.authType === 'jwt') {\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appResult = await appSyncService.push();\n }\n\n return successResponse({\n tenant,\n organisation,\n files: {\n uploaded: fileResult.uploaded,\n updated: fileResult.updated,\n deleted: fileResult.deleted,\n unchanged: fileResult.unchanged.length,\n },\n apps: appResult\n ? {\n created: appResult.created,\n updated: appResult.updated,\n unchanged: appResult.unchanged.length,\n }\n : { note: 'App sync requires browser login (JWT)' },\n summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,\n });\n } catch (error) {\n return errorResponse(\n `Push failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'NETWORK_ERROR',\n );\n }\n },\n );\n\n // farseer_status - Check sync status\n server.tool(\n 'farseer_status',\n `Check the synchronization status between local files and the remote Farseer instance.\n\nShows which files are:\n- Modified locally (changed since last sync)\n- Modified remotely (changed on server since last sync)\n- Only local (new files not yet pushed)\n- Only remote (files not yet pulled)\n- In sync (no changes)\n\nAlso shows app sync status if using JWT authentication.\n\nSync includes: If the user has configured extra file types via \"farseer config include\"\n(e.g., .json extensions or specific folders like \"Config\"), those files are automatically\nincluded in the status check alongside default script files.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n statusSchema,\n async (params: { organisation?: string; tenant?: string; all?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n const fileStatus = await syncService.getStatus({ all: params.all });\n\n // Get app status (only with JWT auth)\n let appStatus = null;\n if (clientResult.authType === 'jwt') {\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n }\n\n const hasChanges =\n fileStatus.modifiedLocally.length > 0 ||\n fileStatus.modifiedRemotely.length > 0 ||\n fileStatus.onlyLocal.length > 0 ||\n fileStatus.onlyRemote.length > 0 ||\n (fileStatus.conflicts && fileStatus.conflicts.length > 0);\n\n return successResponse({\n tenant,\n organisation,\n files: {\n modifiedLocally: fileStatus.modifiedLocally,\n modifiedRemotely: fileStatus.modifiedRemotely,\n onlyLocal: fileStatus.onlyLocal,\n onlyRemote: fileStatus.onlyRemote,\n inSync: fileStatus.inSync.length,\n conflicts:\n fileStatus.conflicts?.map((c) => ({\n file: c.filePath,\n type: c.type,\n description: c.description,\n })) ?? [],\n },\n apps: appStatus\n ? {\n newLocal: appStatus.newLocal,\n newRemote: appStatus.newRemote,\n modified: appStatus.modified,\n synced: appStatus.synced.length,\n }\n : { note: 'App sync requires browser login (JWT)' },\n summary: fileStatus.conflicts?.length\n ? `${fileStatus.conflicts.length} conflict(s) detected`\n : hasChanges\n ? 'Changes detected'\n : 'Everything is in sync',\n });\n } catch (error) {\n return errorResponse(\n `Status check failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'NETWORK_ERROR',\n );\n }\n },\n );\n\n // farseer_diff - Show file differences\n server.tool(\n 'farseer_diff',\n `Show the differences between local and remote versions of files.\n\nCan show:\n- Unified diff format (default)\n- Just the remote content (showRemote=true)\n\nUseful for reviewing changes before pull or push.\n\nIf no file is specified, shows diffs for all changed files.`,\n diffSchema,\n async (params: { organisation?: string; tenant?: string; file?: string; showRemote?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n\n if (params.file) {\n // Single file diff\n const { localContent, remoteContent } = await syncService.getFileDiff(params.file);\n\n if (params.showRemote) {\n return successResponse({\n file: params.file,\n remoteContent: remoteContent || '(file does not exist on remote)',\n });\n }\n\n const diff = createPatch(params.file, remoteContent || '', localContent || '', 'remote', 'local');\n\n return successResponse({\n file: params.file,\n localExists: localContent !== null,\n remoteExists: remoteContent !== null,\n diff,\n });\n } else {\n // All changed files\n const status = await syncService.getStatus();\n const changedFiles = [\n ...status.modifiedLocally,\n ...status.modifiedRemotely,\n ...status.onlyLocal,\n ...status.onlyRemote,\n ];\n\n const diffs: Array<{\n file: string;\n localExists: boolean;\n remoteExists: boolean;\n diff: string;\n }> = [];\n\n for (const f of changedFiles.slice(0, 10)) {\n // Limit to 10 files\n const { localContent, remoteContent } = await syncService.getFileDiff(f);\n const diff = createPatch(f, remoteContent || '', localContent || '', 'remote', 'local');\n diffs.push({\n file: f,\n localExists: localContent !== null,\n remoteExists: remoteContent !== null,\n diff,\n });\n }\n\n return successResponse({\n totalChangedFiles: changedFiles.length,\n diffs,\n note:\n changedFiles.length > 10\n ? `Showing first 10 of ${changedFiles.length} changed files`\n : undefined,\n });\n }\n } catch (error) {\n return errorResponse(\n `Diff failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'NETWORK_ERROR',\n );\n }\n },\n );\n\n // farseer_list_files - List remote files\n server.tool(\n 'farseer_list_files',\n `List all files stored on the remote Farseer instance in the Files/ folder.\n\nBy default shows only script files (.ts, .js, .mjs, .cjs).\nUse all=true to show all files including images, data files, etc.\n\nReturns file paths relative to the Files/ folder.`,\n listFilesSchema,\n async (params: { organisation?: string; tenant?: string; all?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n let files = await clientResult.client.listFiles();\n\n // Filter to scripts unless --all\n if (!params.all) {\n const scriptExtensions = ['.ts', '.js', '.mjs', '.cjs'];\n files = files.filter((f) => scriptExtensions.some((ext) => f.name.toLowerCase().endsWith(ext)));\n }\n\n // Group by directory\n const byDirectory: Record<string, string[]> = {};\n for (const file of files) {\n const dir = file.path.includes('/') ? file.path.split('/').slice(0, -1).join('/') : '.';\n if (!byDirectory[dir]) {\n byDirectory[dir] = [];\n }\n byDirectory[dir].push(file.name);\n }\n\n return successResponse({\n tenant,\n organisation,\n totalFiles: files.length,\n files: files.map((f) => ({\n name: f.name,\n path: f.path,\n reference: f.reference,\n })),\n byDirectory,\n });\n } catch (error) {\n return errorResponse(\n `List files failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'NETWORK_ERROR',\n );\n }\n },\n );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAClB,kBAA4B;AAC5B,yBAA4B;AAC5B,4BAA+B;AAC/B,4BAA6C;AAC7C,qBAMO;AAGP,MAAM,aAAa;AAAA,EACf,cAAc,aACT,OAAO,EACP,SAAS,EACT;AAAA,IACG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CAAC;AAAA,UACxB;AACA,sBAAY,GAAG,EAAE,KAAK,KAAK,IAAI;AAAA,QACnC;AAEA,mBAAO,gCAAgB;AAAA,UACnB;AAAA,UACA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,OAAO,MAAM,IAAI,CAAC,OAAO;AAAA,YACrB,MAAM,EAAE;AAAA,YACR,MAAM,EAAE;AAAA,YACR,WAAW,EAAE;AAAA,UACjB,EAAE;AAAA,UACF;AAAA,QACJ,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO;AAAA,UACH,sBAAsB,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAAA,UAC9E;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
4
+ "sourcesContent": ["/**\n * File Synchronization Tools\n *\n * Tools for syncing files between local repository and Farseer instance.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { createPatch } from 'diff';\nimport { SyncService } from '../../services/syncService';\nimport { AppSyncService } from '../../services/appSyncService';\nimport { getFarseerClientWithFallback } from '../../services/farseerFactory';\nimport {\n resolveOrgAndTenant,\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\n//\n// `includeExtensions` and `includeFolders` mirror the CLI's `--include-ext` /\n// `--include-folder` flags. Without them on the MCP surface, an agent could\n// only choose between scripts-only and \"all\" \u2014 there was no way to scope a\n// pull/push/status to \"scripts plus this one folder\" the way a CLI user can.\nconst includeExtensionsSchema = z\n .array(z.string())\n .optional()\n .describe(\n 'Extra file extensions to include alongside the default .ts / .js scripts. ' +\n 'Supply with or without leading dot (\".csv\" or \"csv\"). Mirrors the CLI\\'s --include-ext flag.',\n );\nconst includeFoldersSchema = z\n .array(z.string())\n .optional()\n .describe(\n 'Extra folder paths whose files (any extension) are included alongside the default scripts. ' +\n 'Each path is interpreted relative to the tenant root, e.g. \"Data\" or \"Config/local\". ' +\n \"Mirrors the CLI's --include-folder flag.\",\n );\n\nconst pullSchema = {\n organisation: z\n .string()\n .optional()\n .describe(\n 'Farseer organisation (subdomain, e.g. \"salvus-2\"). If omitted, uses checked-out org or saved mapping.',\n ),\n tenant: z.string().optional().describe('Tenant ID (e.g. \"salvus-prodaja\"). Uses checked-out tenant if omitted.'),\n all: z.boolean().optional().describe('Download all files, not just scripts (.ts, .js)'),\n force: z\n .boolean()\n .optional()\n .describe(\n 'DESTRUCTIVE \u2014 overwrites EVERY locally-modified file with the remote version, including ' +\n \"local edits that have no remote conflict (e.g. a file you've been editing but the remote \" +\n 'is still on the baseline version). Use only when the user has explicitly asked to ' +\n 'discard local changes. Does NOT delete local-only files (that destructive wipe stays ' +\n 'on the CLI side behind the interactive confirm prompt).',\n ),\n includeExtensions: includeExtensionsSchema,\n includeFolders: includeFoldersSchema,\n};\n\nconst pushSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n force: z\n .boolean()\n .optional()\n .describe(\n 'Skip the drift check and overwrite remote even if it diverged from baseline. ' +\n 'Does NOT delete remote-only files; pass mirror=true for that.',\n ),\n mirror: z\n .boolean()\n .optional()\n .describe(\n 'Also delete remote files that have no local counterpart \u2014 destructive \"make remote = local\" semantics. ' +\n \"Implies the upload step still respects the user's local presence, so this only fires for files \" +\n 'genuinely missing locally. Combine with force=true if the drift check would otherwise refuse the push.',\n ),\n all: z\n .boolean()\n .optional()\n .describe(\n 'Push all files, not just scripts (.ts, .js). Excludes hidden files unless includeFolders names them.',\n ),\n includeExtensions: includeExtensionsSchema,\n includeFolders: includeFoldersSchema,\n};\n\nconst statusSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n all: z.boolean().optional().describe('Show all files, not just scripts'),\n deep: z\n .boolean()\n .optional()\n .describe(\n 'Hash every remote file to also detect remote-side content edits. Slow on big tenants. Default is fast ' +\n 'mode (list-only) which can miss edits made by other users since last pull.',\n ),\n includeExtensions: includeExtensionsSchema,\n includeFolders: includeFoldersSchema,\n};\n\nconst diffSchema = {\n organisation: z.string().optional().describe('Farseer organisation (subdomain).'),\n tenant: z.string().optional().describe('Tenant ID'),\n file: z.string().optional().describe('Specific file path to diff. If omitted, shows all differences.'),\n showRemote: z.boolean().optional().describe('Show only the remote content instead of diff'),\n};\n\nconst listFilesSchema = {\n organisation: z.string().optional().describe('Farseer organisation (subdomain).'),\n tenant: z.string().optional().describe('Tenant ID'),\n all: z.boolean().optional().describe('Show all files, not just scripts'),\n};\n\nexport function registerSyncTools(server: McpServer): void {\n // farseer_pull - Download files from remote\n server.tool(\n 'farseer_pull',\n `Pull (download) files and app configurations from a Farseer instance to the local repository.\n\nWhat gets pulled:\n- TypeScript/JavaScript scripts from Files/ folder (searched recursively)\n- App configurations (saved as JSON in apps/ folder)\n\nFiles are saved to: farseer-apps/<tenant>/files/\nApps are saved to: farseer-apps/<tenant>/apps/\n\nBy default only script files (.ts, .js) are pulled.\nUse all=true to pull all files including images, data files, etc.\nUse includeExtensions / includeFolders to broaden the scope without pulling everything\n(e.g. includeExtensions=[\"csv\"] adds CSV files; includeFolders=[\"Data\"] adds the Data\nfolder regardless of extension). These mirror the CLI's --include-ext / --include-folder\nflags and are additive on top of the default scripts.\n\nConflict handling:\n- Per-file conflict resolution (keep_local / keep_remote / keep_both / merge_markers)\n is CLI-only \u2014 it requires an interactive prompt and the MCP can't answer one.\n- The MCP path returns conflicts in response.conflicts[] so the agent can re-pull\n with force=true once the user has confirmed they want to discard their edits.\n- force=true is DESTRUCTIVE: it overwrites every locally-modified file with the\n remote version (even local edits that don't conflict with remote). It does NOT\n wipe local-only files (that destructive step lives behind the CLI's confirm prompt).\n Only pass force=true when the user has explicitly accepted losing local changes.\n\nSync includes (middle ground between scripts-only and all):\n- Users can configure extra extensions and folders via \"farseer config include\" CLI command\n- These are stored per-tenant in ~/.farseer/config.json under \"syncIncludes\"\n- When configured, pull/push/status automatically include those files alongside default scripts\n- Example: syncIncludes may add .json files or entire folders like \"Config\" or \"App Logs\"\n- The sync includes are respected automatically \u2014 no extra parameters needed here\n\nOrganisation and tenant:\n- Organisation = subdomain (e.g. \"salvus-2\" for salvus-2.farseer.io)\n- Tenant = workspace ID (e.g. \"salvus-prodaja\")\n- Often they are the same. Only specify organisation when it differs from tenant.\n- If checked out, both are resolved automatically.`,\n pullSchema,\n async (params: {\n organisation?: string;\n tenant?: string;\n all?: boolean;\n force?: boolean;\n includeExtensions?: string[];\n includeFolders?: string[];\n }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n // Pull files (use tenant for folder path)\n const syncService = new SyncService(tenant, clientResult.client);\n const fileResult = await syncService.pull({\n all: params.all,\n force: params.force,\n includeExtensions: params.includeExtensions,\n includeFolders: params.includeFolders,\n });\n\n // Pull apps (only with JWT auth)\n let appResult = null;\n if (clientResult.authType === 'jwt') {\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appResult = await appSyncService.pull();\n }\n\n const response: Record<string, any> = {\n tenant,\n organisation,\n files: {\n downloaded: fileResult.downloaded,\n deleted: fileResult.deleted,\n unchanged: fileResult.unchanged.length,\n },\n apps: appResult\n ? {\n created: appResult.created,\n updated: appResult.updated,\n deleted: appResult.deleted,\n unchanged: appResult.unchanged.length,\n }\n : { note: 'App sync requires browser login (JWT)' },\n message: `Pulled ${fileResult.downloaded.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,\n };\n\n if (fileResult.conflicts.length > 0) {\n response.conflicts = fileResult.conflicts.map((c) => ({\n file: c.filePath,\n type: c.type,\n description: c.description,\n }));\n response.message = `Pulled ${fileResult.downloaded.length} files but ${fileResult.conflicts.length} conflict(s) need resolution`;\n response.hint =\n 'Use force=true to overwrite local changes, or resolve conflicts via CLI: farseer pull <tenant>';\n }\n\n if (fileResult.conflictFilesWritten.length > 0) {\n response.conflictFilesWritten = fileResult.conflictFilesWritten;\n }\n\n return successResponse(response);\n } catch (error) {\n return errorResponse(`Pull failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_push - Upload files to remote\n server.tool(\n 'farseer_push',\n `Push (upload) local file and app changes to a Farseer instance.\n\nWhat gets pushed:\n- New/modified scripts from farseer-apps/<tenant>/files/ (filtered by sync scope \u2014\n default is .ts/.js; broaden via includeExtensions / includeFolders / all on this\n tool, or via persistent sync includes set with the CLI's \"farseer config include\").\n- New/modified app configurations from farseer-apps/<tenant>/apps/.\n- Deleted files (when they were previously synced \u2014 preserves \"I rm'd this\" semantics).\n\nPre-flight (runs before any HTTP call):\n- Refuses files the backend would refuse anyway: extension not on whitelist,\n filename longer than 256 chars, empty body, unresolved git-style merge markers\n (<<<<<<< LOCAL / ======= / >>>>>>> REMOTE) left over from a merge_markers pull.\n- Returns rejected files in the response. If every candidate is rejected (and\n no deletes/updates either), the tool call returns VALIDATION_ERROR.\n\nDrift / mirror semantics:\n- force=true skips the drift check (push over remote-side adds/deletes).\n- mirror=true (separate param) also deletes remote files that have no local\n counterpart, within the current sync scope. Combine with force when both are\n needed.\n\nOut-of-scope files (e.g. a hidden .vscode/settings.json next to scripts) are\nINVISIBLE to push \u2014 never uploaded, never deleted. Hidden paths require explicit\nopt-in via --include-folder.\n\nSync includes: if user configured via \"farseer config include\", drift and scope\nchecks respect those settings automatically.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n pushSchema,\n async (params: {\n organisation?: string;\n tenant?: string;\n force?: boolean;\n mirror?: boolean;\n all?: boolean;\n includeExtensions?: string[];\n includeFolders?: string[];\n }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Check for remote changes unless force is true. Surface\n // the actual diverging paths so the agent (or its caller)\n // can decide what to do without another round-trip.\n if (!params.force) {\n const drift = await syncService.checkRemoteChanges();\n if (drift.drift) {\n return errorResponse(\n `Remote has unpulled changes (added: ${drift.addedRemotely.length}, deleted: ${drift.deletedRemotely.length}). ` +\n 'Pull first or use force=true to overwrite.',\n 'VALIDATION_ERROR',\n );\n }\n }\n\n // Push files. Pass `mirror` separately from `force` so an\n // agent must opt in explicitly to remote-side deletes \u2014 the\n // CLI gates this behind a confirm prompt, the MCP can't, so\n // we make it a separate parameter the caller has to set.\n const fileResult = await syncService.push({\n force: params.force,\n mirror: params.mirror,\n all: params.all,\n includeExtensions: params.includeExtensions,\n includeFolders: params.includeFolders,\n });\n\n // Check for conflicts\n if (fileResult.conflicts.length > 0) {\n return errorResponse(\n `Push blocked by ${fileResult.conflicts.length} conflict(s):\\n${fileResult.conflicts.map((c) => ` - ${c.filePath}: ${c.description}`).join('\\n')}\\n\\nPull first or use force=true.`,\n 'VALIDATION_ERROR',\n );\n }\n\n // Pre-flight rejected files. A push that produced zero side\n // effects (no upload, no update, no delete) because every\n // candidate was rejected is a failure from the agent's\n // perspective \u2014 surface it as VALIDATION_ERROR so the tool\n // call doesn't quietly look like a success.\n //\n // Note `appliedAny` includes deletes: a mirror push that\n // removed remote-only files BUT had every upload candidate\n // rejected has still mutated remote state, so the response\n // must show the deletes (treated as a partial success), not\n // an error that hides them.\n if (fileResult.rejected && fileResult.rejected.length > 0) {\n const summary = fileResult.rejected.map((r) => ` - ${r.filePath}: ${r.detail}`).join('\\n');\n const appliedAny =\n fileResult.uploaded.length + fileResult.updated.length + fileResult.deleted.length > 0;\n if (!appliedAny) {\n return errorResponse(\n `Push rejected \u2014 backend would refuse every candidate file:\\n${summary}`,\n 'VALIDATION_ERROR',\n );\n }\n // Partial success: at least some side effects applied.\n // Fall through to successResponse below so the caller\n // sees the full files.{uploaded,updated,deleted,rejected}\n // breakdown and can decide how strict to be.\n }\n\n // Per-file mid-push failures (5xx, transient errors). These\n // reach the agent as a separate signal from `rejected`\n // (pre-flight). We always surface them \u2014 if the entire push\n // failed mid-flight with no side effects, return error so\n // the agent retries; otherwise let the partial success\n // through so the agent can see what stuck.\n if (fileResult.failed && fileResult.failed.length > 0) {\n const failureSummary = fileResult.failed\n .map((f) => ` - ${f.filePath} (${f.operation}): ${f.reason}`)\n .join('\\n');\n const appliedAny =\n fileResult.uploaded.length + fileResult.updated.length + fileResult.deleted.length > 0;\n if (!appliedAny) {\n return errorResponse(\n `Push failed mid-flight \u2014 every attempted file errored:\\n${failureSummary}`,\n 'NETWORK_ERROR',\n );\n }\n }\n\n // Push apps (only with JWT auth)\n let appResult = null;\n if (clientResult.authType === 'jwt') {\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appResult = await appSyncService.push();\n }\n\n return successResponse({\n tenant,\n organisation,\n files: {\n uploaded: fileResult.uploaded,\n updated: fileResult.updated,\n deleted: fileResult.deleted,\n unchanged: fileResult.unchanged.length,\n rejected: fileResult.rejected ?? [],\n failed: fileResult.failed ?? [],\n },\n apps: appResult\n ? {\n created: appResult.created,\n updated: appResult.updated,\n unchanged: appResult.unchanged.length,\n }\n : { note: 'App sync requires browser login (JWT)' },\n summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}${fileResult.rejected && fileResult.rejected.length > 0 ? ` (${fileResult.rejected.length} skipped \u2014 see files.rejected)` : ''}${fileResult.failed && fileResult.failed.length > 0 ? ` (${fileResult.failed.length} failed mid-push \u2014 see files.failed)` : ''}`,\n });\n } catch (error) {\n return errorResponse(`Push failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_status - Check sync status\n server.tool(\n 'farseer_status',\n `Check the synchronization status between local files and the remote Farseer instance.\n\nShows which files are:\n- Modified locally (changed since last sync)\n- Modified remotely (changed on server since last sync)\n- Only local (new files not yet pushed)\n- Only remote (files not yet pulled)\n- In sync (no changes)\n\nAlso shows app sync status if using JWT authentication.\n\nSync includes: If the user has configured extra file types via \"farseer config include\"\n(e.g., .json extensions or specific folders like \"Config\"), those files are automatically\nincluded in the status check alongside default script files.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n statusSchema,\n async (params: {\n organisation?: string;\n tenant?: string;\n all?: boolean;\n deep?: boolean;\n includeExtensions?: string[];\n includeFolders?: string[];\n }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n const fileStatus = await syncService.getStatus({\n all: params.all,\n deep: params.deep,\n includeExtensions: params.includeExtensions,\n includeFolders: params.includeFolders,\n });\n\n // Get app status (only with JWT auth)\n let appStatus = null;\n if (clientResult.authType === 'jwt') {\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n }\n\n const hasChanges =\n fileStatus.modifiedLocally.length > 0 ||\n fileStatus.modifiedRemotely.length > 0 ||\n fileStatus.addedLocally.length > 0 ||\n fileStatus.addedRemotely.length > 0 ||\n fileStatus.deletedLocally.length > 0 ||\n fileStatus.deletedRemotely.length > 0 ||\n fileStatus.conflicts.length > 0;\n\n return successResponse({\n tenant,\n organisation,\n files: {\n addedLocally: fileStatus.addedLocally,\n modifiedLocally: fileStatus.modifiedLocally,\n deletedLocally: fileStatus.deletedLocally,\n addedRemotely: fileStatus.addedRemotely,\n modifiedRemotely: fileStatus.modifiedRemotely,\n deletedRemotely: fileStatus.deletedRemotely,\n inSync: fileStatus.inSync.length,\n deepCompare: fileStatus.deepCompare,\n conflicts: fileStatus.conflicts.map((c) => ({\n file: c.filePath,\n type: c.type,\n description: c.description,\n })),\n },\n apps: appStatus\n ? {\n newLocal: appStatus.newLocal,\n newRemote: appStatus.newRemote,\n modified: appStatus.modified,\n synced: appStatus.synced.length,\n }\n : { note: 'App sync requires browser login (JWT)' },\n summary: fileStatus.conflicts?.length\n ? `${fileStatus.conflicts.length} conflict(s) detected`\n : hasChanges\n ? 'Changes detected'\n : 'Everything is in sync',\n });\n } catch (error) {\n return errorResponse(`Status check failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_diff - Show file differences\n server.tool(\n 'farseer_diff',\n `Show the differences between local and remote versions of files.\n\nCan show:\n- Unified diff format (default)\n- Just the remote content (showRemote=true)\n\nUseful for reviewing changes before pull or push.\n\nIf no file is specified, shows diffs for all changed files.`,\n diffSchema,\n async (params: { organisation?: string; tenant?: string; file?: string; showRemote?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n\n if (params.file) {\n // Single file diff\n const { localContent, remoteContent } = await syncService.getFileDiff(params.file);\n\n if (params.showRemote) {\n return successResponse({\n file: params.file,\n remoteContent: remoteContent || '(file does not exist on remote)',\n });\n }\n\n const diff = createPatch(params.file, remoteContent || '', localContent || '', 'remote', 'local');\n\n return successResponse({\n file: params.file,\n localExists: localContent !== null,\n remoteExists: remoteContent !== null,\n diff,\n });\n } else {\n // All changed files\n const status = await syncService.getStatus();\n const changedFiles = [\n ...status.addedLocally,\n ...status.modifiedLocally,\n ...status.deletedLocally,\n ...status.addedRemotely,\n ...status.modifiedRemotely,\n ...status.deletedRemotely,\n ];\n\n const diffs: Array<{\n file: string;\n localExists: boolean;\n remoteExists: boolean;\n diff: string;\n }> = [];\n\n for (const f of changedFiles.slice(0, 10)) {\n // Limit to 10 files\n const { localContent, remoteContent } = await syncService.getFileDiff(f);\n const diff = createPatch(f, remoteContent || '', localContent || '', 'remote', 'local');\n diffs.push({\n file: f,\n localExists: localContent !== null,\n remoteExists: remoteContent !== null,\n diff,\n });\n }\n\n return successResponse({\n totalChangedFiles: changedFiles.length,\n diffs,\n note:\n changedFiles.length > 10\n ? `Showing first 10 of ${changedFiles.length} changed files`\n : undefined,\n });\n }\n } catch (error) {\n return errorResponse(`Diff failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_list_files - List remote files\n server.tool(\n 'farseer_list_files',\n `List all files stored on the remote Farseer instance in the Files/ folder.\n\nBy default shows only script files (.ts, .js, .mjs, .cjs).\nUse all=true to show all files including images, data files, etc.\n\nReturns file paths relative to the Files/ folder.`,\n listFilesSchema,\n async (params: { organisation?: string; tenant?: string; all?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n let files = await clientResult.client.listFiles();\n\n // Filter to scripts unless --all\n if (!params.all) {\n const scriptExtensions = ['.ts', '.js', '.mjs', '.cjs'];\n files = files.filter((f) => scriptExtensions.some((ext) => f.name.toLowerCase().endsWith(ext)));\n }\n\n // Group by directory\n const byDirectory: Record<string, string[]> = {};\n for (const file of files) {\n const dir = file.path.includes('/') ? file.path.split('/').slice(0, -1).join('/') : '.';\n if (!byDirectory[dir]) {\n byDirectory[dir] = [];\n }\n byDirectory[dir].push(file.name);\n }\n\n return successResponse({\n tenant,\n organisation,\n totalFiles: files.length,\n files: files.map((f) => ({\n name: f.name,\n path: f.path,\n reference: f.reference,\n })),\n byDirectory,\n });\n } catch (error) {\n return errorResponse(`List files failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAClB,kBAA4B;AAC5B,yBAA4B;AAC5B,4BAA+B;AAC/B,4BAA6C;AAC7C,qBAMO;AACP,4BAAkC;AAQlC,MAAM,0BAA0B,aAC3B,MAAM,aAAE,OAAO,CAAC,EAChB,SAAS,EACT;AAAA,EACG;AAEJ;AACJ,MAAM,uBAAuB,aACxB,MAAM,aAAE,OAAO,CAAC,EAChB,SAAS,EACT;AAAA,EACG;AAGJ;AAEJ,MAAM,aAAa;AAAA,EACf,cAAc,aACT,OAAO,EACP,SAAS,EACT;AAAA,IACG;AAAA,EACJ;AAAA,EACJ,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,wEAAwE;AAAA,EAC/G,KAAK,aAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,iDAAiD;AAAA,EACtF,OAAO,aACF,QAAQ,EACR,SAAS,EACT;AAAA,IACG;AAAA,EAKJ;AAAA,EACJ,mBAAmB;AAAA,EACnB,gBAAgB;AACpB;AAEA,MAAM,aAAa;AAAA,EACf,cAAc,aACT,OAAO,EACP,SAAS,EACT,SAAS,sFAAsF;AAAA,EACpG,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gDAAgD;AAAA,EACvF,OAAO,aACF,QAAQ,EACR,SAAS,EACT;AAAA,IACG;AAAA,EAEJ;AAAA,EACJ,QAAQ,aACH,QAAQ,EACR,SAAS,EACT;AAAA,IACG;AAAA,EAGJ;AAAA,EACJ,KAAK,aACA,QAAQ,EACR,SAAS,EACT;AAAA,IACG;AAAA,EACJ;AAAA,EACJ,mBAAmB;AAAA,EACnB,gBAAgB;AACpB;AAEA,MAAM,eAAe;AAAA,EACjB,cAAc,aACT,OAAO,EACP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CAAgB;AAAA,UACnB;AAAA,UACA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,OAAO,MAAM,IAAI,CAAC,OAAO;AAAA,YACrB,MAAM,EAAE;AAAA,YACR,MAAM,EAAE;AAAA,YACR,WAAW,EAAE;AAAA,UACjB,EAAE;AAAA,UACF;AAAA,QACJ,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,sBAAsB,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MAChG;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -68,8 +68,8 @@ function resolveOrganisation(orgArg, tenantArg) {
68
68
  const checkout = (0, import_configService.getCurrentCheckout)();
69
69
  return checkout?.organisation || null;
70
70
  }
71
- async function getClient(tenant, tenantId) {
72
- const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(tenant, tenantId ?? tenant);
71
+ async function getClient(organisation, tenant) {
72
+ const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
73
73
  return result?.client || null;
74
74
  }
75
75
  function successResponse(data) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/utils/helpers.ts"],
4
- "sourcesContent": ["/**\n * MCP Utility Functions\n *\n * Helper functions for MCP tools including tenant resolution and response formatting.\n */\n\nimport {\n getCurrentCheckout,\n getCurrentTenant,\n getUserAuth,\n isUserAuthValid,\n listCredentials,\n getTenantOrg,\n} from '../../services/configService';\nimport { getFarseerClientWithFallback, IFarseerClient } from '../../services/farseerFactory';\nimport { fileLogger } from '../../utils/fileLogger';\n\n/**\n * Resolve organisation and tenant from MCP tool parameters.\n *\n * Resolution order:\n * 1. Explicit org/tenant params\n * 2. Tenant param + saved org mapping (from previous checkout)\n * 3. Current checkout\n *\n * Returns null if no tenant can be resolved.\n */\nexport function resolveOrgAndTenant(params: {\n organisation?: string;\n tenant?: string;\n}): { organisation: string; tenant: string } | null {\n const checkout = getCurrentCheckout();\n const { organisation: orgArg, tenant: tenantArg } = params;\n\n // Case 1: Both provided explicitly\n if (orgArg && tenantArg) {\n return { organisation: orgArg, tenant: tenantArg };\n }\n\n // Case 2: Only tenant provided - look up org from saved mapping or assume org=tenant\n if (tenantArg) {\n const savedOrg = getTenantOrg(tenantArg);\n return { organisation: savedOrg || orgArg || tenantArg, tenant: tenantArg };\n }\n\n // Case 3: Only org provided (unusual, but treat as org=tenant)\n if (orgArg) {\n return { organisation: orgArg, tenant: orgArg };\n }\n\n // Case 4: No args - use checkout\n if (checkout) {\n return { organisation: checkout.organisation, tenant: checkout.tenant };\n }\n\n return null;\n}\n\n/**\n * Resolve tenant from argument or checkout state\n */\nexport function resolveTenant(tenantArg?: string): string | null {\n if (tenantArg) {\n return tenantArg;\n }\n return getCurrentTenant() || null;\n}\n\n/**\n * Resolve organisation from argument or checkout state\n */\nexport function resolveOrganisation(orgArg?: string, tenantArg?: string): string | null {\n if (orgArg) {\n return orgArg;\n }\n if (tenantArg) {\n const savedOrg = getTenantOrg(tenantArg);\n if (savedOrg) return savedOrg;\n return tenantArg;\n }\n const checkout = getCurrentCheckout();\n return checkout?.organisation || null;\n}\n\n/**\n * Get authenticated Farseer client\n */\nexport async function getClient(tenant: string, tenantId?: string): Promise<IFarseerClient | null> {\n const result = await getFarseerClientWithFallback(tenant, tenantId ?? tenant);\n return result?.client || null;\n}\n\n/**\n * Create a success response\n */\nexport function successResponse(data: Record<string, unknown>): { content: Array<{ type: 'text'; text: string }> } {\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({ success: true, ...data }, null, 2),\n },\n ],\n };\n}\n\n/**\n * Create an error response. Also logs to file for diagnostics.\n */\nexport function errorResponse(\n message: string,\n errorCode?: 'AUTH_REQUIRED' | 'NOT_FOUND' | 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN',\n): { content: Array<{ type: 'text'; text: string }>; isError: true } {\n // Log MCP tool errors to file for diagnostics\n fileLogger.error('mcp-tool', message, { errorCode: errorCode || 'UNKNOWN' });\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n success: false,\n error: message,\n errorCode: errorCode || 'UNKNOWN',\n },\n null,\n 2,\n ),\n },\n ],\n isError: true,\n };\n}\n\n/**\n * Create auth required error response\n */\nexport function authRequiredResponse(tenant?: string): {\n content: Array<{ type: 'text'; text: string }>;\n isError: true;\n} {\n const message = tenant\n ? `Authentication required for tenant \"${tenant}\". Run \"farseer login\" to authenticate.`\n : 'Authentication required. Run \"farseer login\" to authenticate.';\n\n return errorResponse(message, 'AUTH_REQUIRED');\n}\n\n/**\n * Create tenant required error response\n */\nexport function tenantRequiredResponse(): { content: Array<{ type: 'text'; text: string }>; isError: true } {\n return errorResponse(\n 'No tenant specified. Either provide tenant parameter or run \"farseer checkout <tenant>\" first.',\n 'VALIDATION_ERROR',\n );\n}\n\n/**\n * Get auth status info\n */\nexport function getAuthStatus(): {\n jwtValid: boolean;\n jwtExpiresAt?: string;\n currentCheckout?: { organisation: string; tenant: string };\n configuredTenants: string[];\n} {\n const auth = getUserAuth();\n const checkout = getCurrentCheckout();\n const credentials = listCredentials();\n\n return {\n jwtValid: isUserAuthValid(),\n jwtExpiresAt: auth?.expiresAt,\n currentCheckout: checkout,\n configuredTenants: Object.keys(credentials),\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,2BAOO;AACP,4BAA6D;AAC7D,wBAA2B;AAYpB,SAAS,oBAAoB,QAGgB;AAChD,QAAM,eAAW,yCAAmB;AACpC,QAAM,EAAE,cAAc,QAAQ,QAAQ,UAAU,IAAI;AAGpD,MAAI,UAAU,WAAW;AACrB,WAAO,EAAE,cAAc,QAAQ,QAAQ,UAAU;AAAA,EACrD;AAGA,MAAI,WAAW;AACX,UAAM,eAAW,mCAAa,SAAS;AACvC,WAAO,EAAE,cAAc,YAA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,QAGnC;AACE,QAAM,UAAU,SACV,uCAAuC,MAAM,4CAC7C;AAEN,SAAO,cAAc,SAAS,eAAe;AACjD;AAKO,SAAS,yBAA4F;AACxG,SAAO;AAAA,IACH;AAAA,IACA;AAAA,EACJ;AACJ;AAKO,SAAS,gBAKd;AACE,QAAM,WAAO,kCAAY;AACzB,QAAM,eAAW,yCAAmB;AACpC,QAAM,kBAAc,sCAAgB;AAEpC,SAAO;AAAA,IACH,cAAU,sCAAgB;AAAA,IAC1B,cAAc,MAAM;AAAA,IACpB,iBAAiB;AAAA,IACjB,mBAAmB,OAAO,KAAK,WAAW;AAAA,EAC9C;AACJ;",
4
+ "sourcesContent": ["/**\n * MCP Utility Functions\n *\n * Helper functions for MCP tools including tenant resolution and response formatting.\n */\n\nimport {\n getCurrentCheckout,\n getCurrentTenant,\n getUserAuth,\n isUserAuthValid,\n listCredentials,\n getTenantOrg,\n} from '../../services/configService';\nimport { getFarseerClientWithFallback, IFarseerClient } from '../../services/farseerFactory';\nimport { fileLogger } from '../../utils/fileLogger';\n\n/**\n * Resolve organisation and tenant from MCP tool parameters.\n *\n * Resolution order:\n * 1. Explicit org/tenant params\n * 2. Tenant param + saved org mapping (from previous checkout)\n * 3. Current checkout\n *\n * Returns null if no tenant can be resolved.\n */\nexport function resolveOrgAndTenant(params: {\n organisation?: string;\n tenant?: string;\n}): { organisation: string; tenant: string } | null {\n const checkout = getCurrentCheckout();\n const { organisation: orgArg, tenant: tenantArg } = params;\n\n // Case 1: Both provided explicitly\n if (orgArg && tenantArg) {\n return { organisation: orgArg, tenant: tenantArg };\n }\n\n // Case 2: Only tenant provided - look up org from saved mapping or assume org=tenant\n if (tenantArg) {\n const savedOrg = getTenantOrg(tenantArg);\n return { organisation: savedOrg || orgArg || tenantArg, tenant: tenantArg };\n }\n\n // Case 3: Only org provided (unusual, but treat as org=tenant)\n if (orgArg) {\n return { organisation: orgArg, tenant: orgArg };\n }\n\n // Case 4: No args - use checkout\n if (checkout) {\n return { organisation: checkout.organisation, tenant: checkout.tenant };\n }\n\n return null;\n}\n\n/**\n * Resolve tenant from argument or checkout state\n */\nexport function resolveTenant(tenantArg?: string): string | null {\n if (tenantArg) {\n return tenantArg;\n }\n return getCurrentTenant() || null;\n}\n\n/**\n * Resolve organisation from argument or checkout state\n */\nexport function resolveOrganisation(orgArg?: string, tenantArg?: string): string | null {\n if (orgArg) {\n return orgArg;\n }\n if (tenantArg) {\n const savedOrg = getTenantOrg(tenantArg);\n if (savedOrg) return savedOrg;\n return tenantArg;\n }\n const checkout = getCurrentCheckout();\n return checkout?.organisation || null;\n}\n\n/**\n * Get authenticated Farseer client.\n * The factory takes (organisation, tenant) \u2014 organisation is the subdomain\n * used to build the base URL, tenant is the X-TENANT-ID header value.\n */\nexport async function getClient(organisation: string, tenant: string): Promise<IFarseerClient | null> {\n const result = await getFarseerClientWithFallback(organisation, tenant);\n return result?.client || null;\n}\n\n/**\n * Create a success response\n */\nexport function successResponse(data: Record<string, unknown>): { content: Array<{ type: 'text'; text: string }> } {\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({ success: true, ...data }, null, 2),\n },\n ],\n };\n}\n\n/**\n * Create an error response. Also logs to file for diagnostics.\n */\nexport function errorResponse(\n message: string,\n errorCode?: 'AUTH_REQUIRED' | 'NOT_FOUND' | 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN',\n): { content: Array<{ type: 'text'; text: string }>; isError: true } {\n // Log MCP tool errors to file for diagnostics\n fileLogger.error('mcp-tool', message, { errorCode: errorCode || 'UNKNOWN' });\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n success: false,\n error: message,\n errorCode: errorCode || 'UNKNOWN',\n },\n null,\n 2,\n ),\n },\n ],\n isError: true,\n };\n}\n\n/**\n * Create auth required error response\n */\nexport function authRequiredResponse(tenant?: string): {\n content: Array<{ type: 'text'; text: string }>;\n isError: true;\n} {\n const message = tenant\n ? `Authentication required for tenant \"${tenant}\". Run \"farseer login\" to authenticate.`\n : 'Authentication required. Run \"farseer login\" to authenticate.';\n\n return errorResponse(message, 'AUTH_REQUIRED');\n}\n\n/**\n * Create tenant required error response\n */\nexport function tenantRequiredResponse(): { content: Array<{ type: 'text'; text: string }>; isError: true } {\n return errorResponse(\n 'No tenant specified. Either provide tenant parameter or run \"farseer checkout <tenant>\" first.',\n 'VALIDATION_ERROR',\n );\n}\n\n/**\n * Get auth status info\n */\nexport function getAuthStatus(): {\n jwtValid: boolean;\n jwtExpiresAt?: string;\n currentCheckout?: { organisation: string; tenant: string };\n configuredTenants: string[];\n} {\n const auth = getUserAuth();\n const checkout = getCurrentCheckout();\n const credentials = listCredentials();\n\n return {\n jwtValid: isUserAuthValid(),\n jwtExpiresAt: auth?.expiresAt,\n currentCheckout: checkout,\n configuredTenants: Object.keys(credentials),\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,2BAOO;AACP,4BAA6D;AAC7D,wBAA2B;AAYpB,SAAS,oBAAoB,QAGgB;AAChD,QAAM,eAAW,yCAAmB;AACpC,QAAM,EAAE,cAAc,QAAQ,QAAQ,UAAU,IAAI;AAGpD,MAAI,UAAU,WAAW;AACrB,WAAO,EAAE,cAAc,QAAQ,QAAQ,UAAU;AAAA,EACrD;AAGA,MAAI,WAAW;AACX,UAAM,eAAW,mCAAa,SAAS;AACvC,WAAO,EAAE,cAAc,YAAY,UAAU,WAAW,QAAQ,UAAU;AAAA,EAC9E;AAGA,MAAI,QAAQ;AACR,WAAO,EAAE,cAAc,QAAQ,QAAQ,OAAO;AAAA,EAClD;AAGA,MAAI,UAAU;AACV,WAAO,EAAE,cAAc,SAAS,cAAc,QAAQ,SAAS,OAAO;AAAA,EAC1E;AAEA,SAAO;AACX;AAKO,SAAS,cAAc,WAAmC;AAC7D,MAAI,WAAW;AACX,WAAO;AAAA,EACX;AACA,aAAO,u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C1B,cAAc,MAAM;AAAA,IACpB,iBAAiB;AAAA,IACjB,mBAAmB,OAAO,KAAK,WAAW;AAAA,EAC9C;AACJ;",
6
6
  "names": []
7
7
  }
@@ -35,6 +35,7 @@ var fs = __toESM(require("fs"));
35
35
  var path = __toESM(require("path"));
36
36
  var import_helpers = require("../utils/helpers");
37
37
  var import_logger = require("../utils/logger");
38
+ var import_errorFormatter = require("../utils/errorFormatter");
38
39
  function sanitizeDiacritics(text) {
39
40
  const diacriticMap = {
40
41
  // Croatian
@@ -303,7 +304,7 @@ class AppSyncService {
303
304
  this.saveLocalApp(local);
304
305
  result.created.push(local.name);
305
306
  } catch (error) {
306
- console.error(`Failed to create app ${local.name}:`, error);
307
+ import_logger.logger.error(`Failed to create app ${local.name}: ${await (0, import_errorFormatter.formatClientError)(error)}`);
307
308
  }
308
309
  } else if (!this.areAppsEqual(local, remote.app)) {
309
310
  try {
@@ -313,7 +314,7 @@ class AppSyncService {
313
314
  await this.api.updateApp(remote.reference, update);
314
315
  result.updated.push(local.name);
315
316
  } catch (error) {
316
- console.error(`Failed to update app ${local.name}:`, error);
317
+ import_logger.logger.error(`Failed to update app ${local.name}: ${await (0, import_errorFormatter.formatClientError)(error)}`);
317
318
  }
318
319
  } else {
319
320
  result.unchanged.push(local.name);