farseer-cli 1.0.10 → 1.1.1

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 (98) hide show
  1. package/README.md +19 -0
  2. package/dist/commands/app.js +348 -344
  3. package/dist/commands/app.js.map +7 -0
  4. package/dist/commands/apps.js +110 -82
  5. package/dist/commands/apps.js.map +7 -0
  6. package/dist/commands/cells.js +161 -0
  7. package/dist/commands/cells.js.map +7 -0
  8. package/dist/commands/checkout.js +140 -155
  9. package/dist/commands/checkout.js.map +7 -0
  10. package/dist/commands/config.js +128 -126
  11. package/dist/commands/config.js.map +7 -0
  12. package/dist/commands/dashboards.js +130 -0
  13. package/dist/commands/dashboards.js.map +7 -0
  14. package/dist/commands/diff.js +171 -193
  15. package/dist/commands/diff.js.map +7 -0
  16. package/dist/commands/dimensions.js +222 -119
  17. package/dist/commands/dimensions.js.map +7 -0
  18. package/dist/commands/files.js +96 -77
  19. package/dist/commands/files.js.map +7 -0
  20. package/dist/commands/formula.js +116 -0
  21. package/dist/commands/formula.js.map +7 -0
  22. package/dist/commands/install.js +74 -76
  23. package/dist/commands/install.js.map +7 -0
  24. package/dist/commands/list.js +91 -73
  25. package/dist/commands/list.js.map +7 -0
  26. package/dist/commands/login.js +137 -98
  27. package/dist/commands/login.js.map +7 -0
  28. package/dist/commands/logout.js +59 -41
  29. package/dist/commands/logout.js.map +7 -0
  30. package/dist/commands/mcp-server.js +36 -23
  31. package/dist/commands/mcp-server.js.map +7 -0
  32. package/dist/commands/model.js +186 -175
  33. package/dist/commands/model.js.map +7 -0
  34. package/dist/commands/pull.js +264 -274
  35. package/dist/commands/pull.js.map +7 -0
  36. package/dist/commands/push.js +209 -221
  37. package/dist/commands/push.js.map +7 -0
  38. package/dist/commands/run.js +276 -321
  39. package/dist/commands/run.js.map +7 -0
  40. package/dist/commands/sheets.js +200 -0
  41. package/dist/commands/sheets.js.map +7 -0
  42. package/dist/commands/status.js +149 -169
  43. package/dist/commands/status.js.map +7 -0
  44. package/dist/commands/variables.js +247 -188
  45. package/dist/commands/variables.js.map +7 -0
  46. package/dist/commands/whoami.js +65 -44
  47. package/dist/commands/whoami.js.map +7 -0
  48. package/dist/index.js +179 -115
  49. package/dist/index.js.map +7 -0
  50. package/dist/mcp/index.js +33 -16
  51. package/dist/mcp/index.js.map +7 -0
  52. package/dist/mcp/prompts/workflows.js +191 -145
  53. package/dist/mcp/prompts/workflows.js.map +7 -0
  54. package/dist/mcp/resources/documentation.js +158 -148
  55. package/dist/mcp/resources/documentation.js.map +7 -0
  56. package/dist/mcp/server.js +56 -33
  57. package/dist/mcp/server.js.map +7 -0
  58. package/dist/mcp/tools/appTools.js +309 -277
  59. package/dist/mcp/tools/appTools.js.map +7 -0
  60. package/dist/mcp/tools/authTools.js +130 -121
  61. package/dist/mcp/tools/authTools.js.map +7 -0
  62. package/dist/mcp/tools/cellTools.js +148 -0
  63. package/dist/mcp/tools/cellTools.js.map +7 -0
  64. package/dist/mcp/tools/dashboardTools.js +133 -0
  65. package/dist/mcp/tools/dashboardTools.js.map +7 -0
  66. package/dist/mcp/tools/dataTools.js +270 -267
  67. package/dist/mcp/tools/dataTools.js.map +7 -0
  68. package/dist/mcp/tools/modelTools.js +575 -229
  69. package/dist/mcp/tools/modelTools.js.map +7 -0
  70. package/dist/mcp/tools/runTools.js +201 -203
  71. package/dist/mcp/tools/runTools.js.map +7 -0
  72. package/dist/mcp/tools/sheetTools.js +240 -0
  73. package/dist/mcp/tools/sheetTools.js.map +7 -0
  74. package/dist/mcp/tools/syncTools.js +335 -314
  75. package/dist/mcp/tools/syncTools.js.map +7 -0
  76. package/dist/mcp/utils/helpers.js +117 -123
  77. package/dist/mcp/utils/helpers.js.map +7 -0
  78. package/dist/services/appSyncService.js +381 -437
  79. package/dist/services/appSyncService.js.map +7 -0
  80. package/dist/services/configService.js +154 -143
  81. package/dist/services/configService.js.map +7 -0
  82. package/dist/services/farseerApi.js +422 -399
  83. package/dist/services/farseerApi.js.map +7 -0
  84. package/dist/services/farseerFactory.js +208 -273
  85. package/dist/services/farseerFactory.js.map +7 -0
  86. package/dist/services/farseerService.js +467 -486
  87. package/dist/services/farseerService.js.map +7 -0
  88. package/dist/services/syncService.js +661 -731
  89. package/dist/services/syncService.js.map +7 -0
  90. package/dist/utils/constants.js +52 -19
  91. package/dist/utils/constants.js.map +7 -0
  92. package/dist/utils/entityResolver.js +78 -0
  93. package/dist/utils/entityResolver.js.map +7 -0
  94. package/dist/utils/helpers.js +331 -365
  95. package/dist/utils/helpers.js.map +7 -0
  96. package/dist/utils/logger.js +74 -42
  97. package/dist/utils/logger.js.map +7 -0
  98. package/package.json +3 -2
@@ -1,57 +1,65 @@
1
1
  "use strict";
2
- /**
3
- * File Synchronization Tools
4
- *
5
- * Tools for syncing files between local repository and Farseer instance.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.registerSyncTools = registerSyncTools;
9
- const zod_1 = require("zod");
10
- const diff_1 = require("diff");
11
- const syncService_1 = require("../../services/syncService");
12
- const appSyncService_1 = require("../../services/appSyncService");
13
- const farseerFactory_1 = require("../../services/farseerFactory");
14
- const helpers_1 = require("../utils/helpers");
15
- // Define schemas outside of tool registration to avoid deep type instantiation
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var syncTools_exports = {};
20
+ __export(syncTools_exports, {
21
+ registerSyncTools: () => registerSyncTools
22
+ });
23
+ module.exports = __toCommonJS(syncTools_exports);
24
+ var import_zod = require("zod");
25
+ var import_diff = require("diff");
26
+ var import_syncService = require("../../services/syncService");
27
+ var import_appSyncService = require("../../services/appSyncService");
28
+ var import_farseerFactory = require("../../services/farseerFactory");
29
+ var import_helpers = require("../utils/helpers");
16
30
  const pullSchema = {
17
- organisation: zod_1.z
18
- .string()
19
- .optional()
20
- .describe('Farseer organisation (subdomain, e.g. "salvus-2"). If omitted, uses checked-out org or saved mapping.'),
21
- tenant: zod_1.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
22
- all: zod_1.z.boolean().optional().describe('Download all files, not just scripts (.ts, .js)'),
23
- force: zod_1.z.boolean().optional().describe('Force pull, overwriting local changes on conflicts'),
31
+ organisation: import_zod.z.string().optional().describe(
32
+ 'Farseer organisation (subdomain, e.g. "salvus-2"). If omitted, uses checked-out org or saved mapping.'
33
+ ),
34
+ tenant: import_zod.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
35
+ 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")
24
37
  };
25
38
  const pushSchema = {
26
- organisation: zod_1.z
27
- .string()
28
- .optional()
29
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
30
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
31
- force: zod_1.z.boolean().optional().describe('Skip remote changes check (may overwrite remote changes)'),
39
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
40
+ 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)")
32
42
  };
33
43
  const statusSchema = {
34
- organisation: zod_1.z
35
- .string()
36
- .optional()
37
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
38
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
39
- all: zod_1.z.boolean().optional().describe('Show all files, not just scripts'),
44
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
45
+ 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")
40
47
  };
41
48
  const diffSchema = {
42
- organisation: zod_1.z.string().optional().describe('Farseer organisation (subdomain).'),
43
- tenant: zod_1.z.string().optional().describe('Tenant ID'),
44
- file: zod_1.z.string().optional().describe('Specific file path to diff. If omitted, shows all differences.'),
45
- showRemote: zod_1.z.boolean().optional().describe('Show only the remote content instead of diff'),
49
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain)."),
50
+ tenant: import_zod.z.string().optional().describe("Tenant ID"),
51
+ file: import_zod.z.string().optional().describe("Specific file path to diff. If omitted, shows all differences."),
52
+ showRemote: import_zod.z.boolean().optional().describe("Show only the remote content instead of diff")
46
53
  };
47
54
  const listFilesSchema = {
48
- organisation: zod_1.z.string().optional().describe('Farseer organisation (subdomain).'),
49
- tenant: zod_1.z.string().optional().describe('Tenant ID'),
50
- all: zod_1.z.boolean().optional().describe('Show all files, not just scripts'),
55
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain)."),
56
+ tenant: import_zod.z.string().optional().describe("Tenant ID"),
57
+ all: import_zod.z.boolean().optional().describe("Show all files, not just scripts")
51
58
  };
52
59
  function registerSyncTools(server) {
53
- // farseer_pull - Download files from remote
54
- server.tool('farseer_pull', `Pull (download) files and app configurations from a Farseer instance to the local repository.
60
+ server.tool(
61
+ "farseer_pull",
62
+ `Pull (download) files and app configurations from a Farseer instance to the local repository.
55
63
 
56
64
  What gets pulled:
57
65
  - TypeScript/JavaScript scripts from Files/ folder (searched recursively)
@@ -67,65 +75,66 @@ Organisation and tenant:
67
75
  - Organisation = subdomain (e.g. "salvus-2" for salvus-2.farseer.io)
68
76
  - Tenant = workspace ID (e.g. "salvus-prodaja")
69
77
  - Often they are the same. Only specify organisation when it differs from tenant.
70
- - If checked out, both are resolved automatically.`, pullSchema, async (params) => {
71
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
72
- if (!resolved) {
73
- return (0, helpers_1.tenantRequiredResponse)();
74
- }
75
- const { organisation, tenant } = resolved;
76
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
77
- if (!clientResult) {
78
- return (0, helpers_1.authRequiredResponse)(tenant);
78
+ - If checked out, both are resolved automatically.`,
79
+ pullSchema,
80
+ async (params) => {
81
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
82
+ if (!resolved) {
83
+ return (0, import_helpers.tenantRequiredResponse)();
84
+ }
85
+ const { organisation, tenant } = resolved;
86
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
87
+ if (!clientResult) {
88
+ return (0, import_helpers.authRequiredResponse)(tenant);
89
+ }
90
+ try {
91
+ const syncService = new import_syncService.SyncService(tenant, clientResult.client);
92
+ const fileResult = await syncService.pull({ all: params.all, force: params.force });
93
+ let appResult = null;
94
+ if (clientResult.authType === "jwt") {
95
+ const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
96
+ appResult = await appSyncService.pull();
79
97
  }
80
- try {
81
- // Pull files (use tenant for folder path)
82
- const syncService = new syncService_1.SyncService(tenant, clientResult.client);
83
- const fileResult = await syncService.pull({ all: params.all, force: params.force });
84
- // Pull apps (only with JWT auth)
85
- let appResult = null;
86
- if (clientResult.authType === 'jwt') {
87
- const appSyncService = new appSyncService_1.AppSyncService(tenant, clientResult.client);
88
- appResult = await appSyncService.pull();
89
- }
90
- const response = {
91
- tenant,
92
- organisation,
93
- files: {
94
- downloaded: fileResult.downloaded,
95
- deleted: fileResult.deleted,
96
- unchanged: fileResult.unchanged.length,
97
- },
98
- apps: appResult
99
- ? {
100
- created: appResult.created,
101
- updated: appResult.updated,
102
- deleted: appResult.deleted,
103
- unchanged: appResult.unchanged.length,
104
- }
105
- : { note: 'App sync requires browser login (JWT)' },
106
- message: `Pulled ${fileResult.downloaded.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,
107
- };
108
- if (fileResult.conflicts.length > 0) {
109
- response.conflicts = fileResult.conflicts.map((c) => ({
110
- file: c.filePath,
111
- type: c.type,
112
- description: c.description,
113
- }));
114
- response.message = `Pulled ${fileResult.downloaded.length} files but ${fileResult.conflicts.length} conflict(s) need resolution`;
115
- response.hint =
116
- 'Use force=true to overwrite local changes, or resolve conflicts via CLI: farseer pull <tenant>';
117
- }
118
- if (fileResult.conflictFilesWritten.length > 0) {
119
- response.conflictFilesWritten = fileResult.conflictFilesWritten;
120
- }
121
- return (0, helpers_1.successResponse)(response);
98
+ const response = {
99
+ tenant,
100
+ organisation,
101
+ files: {
102
+ downloaded: fileResult.downloaded,
103
+ deleted: fileResult.deleted,
104
+ unchanged: fileResult.unchanged.length
105
+ },
106
+ apps: appResult ? {
107
+ created: appResult.created,
108
+ updated: appResult.updated,
109
+ deleted: appResult.deleted,
110
+ unchanged: appResult.unchanged.length
111
+ } : { note: "App sync requires browser login (JWT)" },
112
+ message: `Pulled ${fileResult.downloaded.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ""}`
113
+ };
114
+ if (fileResult.conflicts.length > 0) {
115
+ response.conflicts = fileResult.conflicts.map((c) => ({
116
+ file: c.filePath,
117
+ type: c.type,
118
+ description: c.description
119
+ }));
120
+ response.message = `Pulled ${fileResult.downloaded.length} files but ${fileResult.conflicts.length} conflict(s) need resolution`;
121
+ response.hint = "Use force=true to overwrite local changes, or resolve conflicts via CLI: farseer pull <tenant>";
122
122
  }
123
- catch (error) {
124
- return (0, helpers_1.errorResponse)(`Pull failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
123
+ if (fileResult.conflictFilesWritten.length > 0) {
124
+ response.conflictFilesWritten = fileResult.conflictFilesWritten;
125
125
  }
126
- });
127
- // farseer_push - Upload files to remote
128
- server.tool('farseer_push', `Push (upload) local file and app changes to a Farseer instance.
126
+ return (0, import_helpers.successResponse)(response);
127
+ } catch (error) {
128
+ return (0, import_helpers.errorResponse)(
129
+ `Pull failed: ${error instanceof Error ? error.message : "Unknown error"}`,
130
+ "NETWORK_ERROR"
131
+ );
132
+ }
133
+ }
134
+ );
135
+ server.tool(
136
+ "farseer_push",
137
+ `Push (upload) local file and app changes to a Farseer instance.
129
138
 
130
139
  What gets pushed:
131
140
  - New/modified scripts from farseer-apps/<tenant>/files/
@@ -136,62 +145,71 @@ Important:
136
145
  - Checks for unpulled remote changes first to prevent conflicts
137
146
  - Use force=true to skip this check (may overwrite remote changes)
138
147
 
139
- If no tenant is specified, uses the currently checked-out tenant.`, pushSchema, async (params) => {
140
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
141
- if (!resolved) {
142
- return (0, helpers_1.tenantRequiredResponse)();
148
+ If no tenant is specified, uses the currently checked-out tenant.`,
149
+ pushSchema,
150
+ async (params) => {
151
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
152
+ if (!resolved) {
153
+ return (0, import_helpers.tenantRequiredResponse)();
154
+ }
155
+ const { organisation, tenant } = resolved;
156
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
157
+ if (!clientResult) {
158
+ return (0, import_helpers.authRequiredResponse)(tenant);
159
+ }
160
+ try {
161
+ const syncService = new import_syncService.SyncService(tenant, clientResult.client);
162
+ if (!params.force) {
163
+ const hasRemoteChanges = await syncService.checkRemoteChanges();
164
+ if (hasRemoteChanges) {
165
+ return (0, import_helpers.errorResponse)(
166
+ "Remote has unpulled changes. Pull first or use force=true to overwrite.",
167
+ "VALIDATION_ERROR"
168
+ );
169
+ }
143
170
  }
144
- const { organisation, tenant } = resolved;
145
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
146
- if (!clientResult) {
147
- return (0, helpers_1.authRequiredResponse)(tenant);
148
- }
149
- try {
150
- const syncService = new syncService_1.SyncService(tenant, clientResult.client);
151
- // Check for remote changes unless force is true
152
- if (!params.force) {
153
- const hasRemoteChanges = await syncService.checkRemoteChanges();
154
- if (hasRemoteChanges) {
155
- return (0, helpers_1.errorResponse)('Remote has unpulled changes. Pull first or use force=true to overwrite.', 'VALIDATION_ERROR');
156
- }
157
- }
158
- // Push files
159
- const fileResult = await syncService.push({ force: params.force });
160
- // Check for conflicts
161
- if (fileResult.conflicts.length > 0) {
162
- return (0, helpers_1.errorResponse)(`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.`, 'VALIDATION_ERROR');
163
- }
164
- // Push apps (only with JWT auth)
165
- let appResult = null;
166
- if (clientResult.authType === 'jwt') {
167
- const appSyncService = new appSyncService_1.AppSyncService(tenant, clientResult.client);
168
- appResult = await appSyncService.push();
169
- }
170
- return (0, helpers_1.successResponse)({
171
- tenant,
172
- organisation,
173
- files: {
174
- uploaded: fileResult.uploaded,
175
- updated: fileResult.updated,
176
- deleted: fileResult.deleted,
177
- unchanged: fileResult.unchanged.length,
178
- },
179
- apps: appResult
180
- ? {
181
- created: appResult.created,
182
- updated: appResult.updated,
183
- unchanged: appResult.unchanged.length,
184
- }
185
- : { note: 'App sync requires browser login (JWT)' },
186
- summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,
187
- });
171
+ const fileResult = await syncService.push({ force: params.force });
172
+ if (fileResult.conflicts.length > 0) {
173
+ return (0, import_helpers.errorResponse)(
174
+ `Push blocked by ${fileResult.conflicts.length} conflict(s):
175
+ ${fileResult.conflicts.map((c) => ` - ${c.filePath}: ${c.description}`).join("\n")}
176
+
177
+ Pull first or use force=true.`,
178
+ "VALIDATION_ERROR"
179
+ );
188
180
  }
189
- catch (error) {
190
- return (0, helpers_1.errorResponse)(`Push failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
181
+ let appResult = null;
182
+ if (clientResult.authType === "jwt") {
183
+ const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
184
+ appResult = await appSyncService.push();
191
185
  }
192
- });
193
- // farseer_status - Check sync status
194
- server.tool('farseer_status', `Check the synchronization status between local files and the remote Farseer instance.
186
+ return (0, import_helpers.successResponse)({
187
+ tenant,
188
+ organisation,
189
+ files: {
190
+ uploaded: fileResult.uploaded,
191
+ updated: fileResult.updated,
192
+ deleted: fileResult.deleted,
193
+ unchanged: fileResult.unchanged.length
194
+ },
195
+ apps: appResult ? {
196
+ created: appResult.created,
197
+ updated: appResult.updated,
198
+ unchanged: appResult.unchanged.length
199
+ } : { note: "App sync requires browser login (JWT)" },
200
+ summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ""}`
201
+ });
202
+ } catch (error) {
203
+ return (0, import_helpers.errorResponse)(
204
+ `Push failed: ${error instanceof Error ? error.message : "Unknown error"}`,
205
+ "NETWORK_ERROR"
206
+ );
207
+ }
208
+ }
209
+ );
210
+ server.tool(
211
+ "farseer_status",
212
+ `Check the synchronization status between local files and the remote Farseer instance.
195
213
 
196
214
  Shows which files are:
197
215
  - Modified locally (changed since last sync)
@@ -202,66 +220,61 @@ Shows which files are:
202
220
 
203
221
  Also shows app sync status if using JWT authentication.
204
222
 
205
- If no tenant is specified, uses the currently checked-out tenant.`, statusSchema, async (params) => {
206
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
207
- if (!resolved) {
208
- return (0, helpers_1.tenantRequiredResponse)();
209
- }
210
- const { organisation, tenant } = resolved;
211
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
212
- if (!clientResult) {
213
- return (0, helpers_1.authRequiredResponse)(tenant);
214
- }
215
- try {
216
- const syncService = new syncService_1.SyncService(tenant, clientResult.client);
217
- const fileStatus = await syncService.getStatus({ all: params.all });
218
- // Get app status (only with JWT auth)
219
- let appStatus = null;
220
- if (clientResult.authType === 'jwt') {
221
- const appSyncService = new appSyncService_1.AppSyncService(tenant, clientResult.client);
222
- appStatus = await appSyncService.getStatus();
223
- }
224
- const hasChanges = fileStatus.modifiedLocally.length > 0 ||
225
- fileStatus.modifiedRemotely.length > 0 ||
226
- fileStatus.onlyLocal.length > 0 ||
227
- fileStatus.onlyRemote.length > 0 ||
228
- (fileStatus.conflicts && fileStatus.conflicts.length > 0);
229
- return (0, helpers_1.successResponse)({
230
- tenant,
231
- organisation,
232
- files: {
233
- modifiedLocally: fileStatus.modifiedLocally,
234
- modifiedRemotely: fileStatus.modifiedRemotely,
235
- onlyLocal: fileStatus.onlyLocal,
236
- onlyRemote: fileStatus.onlyRemote,
237
- inSync: fileStatus.inSync.length,
238
- conflicts: fileStatus.conflicts?.map((c) => ({
239
- file: c.filePath,
240
- type: c.type,
241
- description: c.description,
242
- })) ?? [],
243
- },
244
- apps: appStatus
245
- ? {
246
- newLocal: appStatus.newLocal,
247
- newRemote: appStatus.newRemote,
248
- modified: appStatus.modified,
249
- synced: appStatus.synced.length,
250
- }
251
- : { note: 'App sync requires browser login (JWT)' },
252
- summary: fileStatus.conflicts?.length
253
- ? `${fileStatus.conflicts.length} conflict(s) detected`
254
- : hasChanges
255
- ? 'Changes detected'
256
- : 'Everything is in sync',
257
- });
223
+ If no tenant is specified, uses the currently checked-out tenant.`,
224
+ statusSchema,
225
+ async (params) => {
226
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
227
+ if (!resolved) {
228
+ return (0, import_helpers.tenantRequiredResponse)();
229
+ }
230
+ const { organisation, tenant } = resolved;
231
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
232
+ if (!clientResult) {
233
+ return (0, import_helpers.authRequiredResponse)(tenant);
234
+ }
235
+ try {
236
+ const syncService = new import_syncService.SyncService(tenant, clientResult.client);
237
+ const fileStatus = await syncService.getStatus({ all: params.all });
238
+ let appStatus = null;
239
+ if (clientResult.authType === "jwt") {
240
+ const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
241
+ appStatus = await appSyncService.getStatus();
258
242
  }
259
- catch (error) {
260
- return (0, helpers_1.errorResponse)(`Status check failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
261
- }
262
- });
263
- // farseer_diff - Show file differences
264
- server.tool('farseer_diff', `Show the differences between local and remote versions of files.
243
+ const hasChanges = fileStatus.modifiedLocally.length > 0 || fileStatus.modifiedRemotely.length > 0 || fileStatus.onlyLocal.length > 0 || fileStatus.onlyRemote.length > 0 || fileStatus.conflicts && fileStatus.conflicts.length > 0;
244
+ return (0, import_helpers.successResponse)({
245
+ tenant,
246
+ organisation,
247
+ files: {
248
+ modifiedLocally: fileStatus.modifiedLocally,
249
+ modifiedRemotely: fileStatus.modifiedRemotely,
250
+ onlyLocal: fileStatus.onlyLocal,
251
+ onlyRemote: fileStatus.onlyRemote,
252
+ inSync: fileStatus.inSync.length,
253
+ conflicts: fileStatus.conflicts?.map((c) => ({
254
+ file: c.filePath,
255
+ type: c.type,
256
+ description: c.description
257
+ })) ?? []
258
+ },
259
+ apps: appStatus ? {
260
+ newLocal: appStatus.newLocal,
261
+ newRemote: appStatus.newRemote,
262
+ modified: appStatus.modified,
263
+ synced: appStatus.synced.length
264
+ } : { note: "App sync requires browser login (JWT)" },
265
+ summary: fileStatus.conflicts?.length ? `${fileStatus.conflicts.length} conflict(s) detected` : hasChanges ? "Changes detected" : "Everything is in sync"
266
+ });
267
+ } catch (error) {
268
+ return (0, import_helpers.errorResponse)(
269
+ `Status check failed: ${error instanceof Error ? error.message : "Unknown error"}`,
270
+ "NETWORK_ERROR"
271
+ );
272
+ }
273
+ }
274
+ );
275
+ server.tool(
276
+ "farseer_diff",
277
+ `Show the differences between local and remote versions of files.
265
278
 
266
279
  Can show:
267
280
  - Unified diff format (default)
@@ -269,115 +282,123 @@ Can show:
269
282
 
270
283
  Useful for reviewing changes before pull or push.
271
284
 
272
- If no file is specified, shows diffs for all changed files.`, diffSchema, async (params) => {
273
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
274
- if (!resolved) {
275
- return (0, helpers_1.tenantRequiredResponse)();
276
- }
277
- const { organisation, tenant } = resolved;
278
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
279
- if (!clientResult) {
280
- return (0, helpers_1.authRequiredResponse)(tenant);
281
- }
282
- try {
283
- const syncService = new syncService_1.SyncService(tenant, clientResult.client);
284
- if (params.file) {
285
- // Single file diff
286
- const { localContent, remoteContent } = await syncService.getFileDiff(params.file);
287
- if (params.showRemote) {
288
- return (0, helpers_1.successResponse)({
289
- file: params.file,
290
- remoteContent: remoteContent || '(file does not exist on remote)',
291
- });
292
- }
293
- const diff = (0, diff_1.createPatch)(params.file, remoteContent || '', localContent || '', 'remote', 'local');
294
- return (0, helpers_1.successResponse)({
295
- file: params.file,
296
- localExists: localContent !== null,
297
- remoteExists: remoteContent !== null,
298
- diff,
299
- });
300
- }
301
- else {
302
- // All changed files
303
- const status = await syncService.getStatus();
304
- const changedFiles = [
305
- ...status.modifiedLocally,
306
- ...status.modifiedRemotely,
307
- ...status.onlyLocal,
308
- ...status.onlyRemote,
309
- ];
310
- const diffs = [];
311
- for (const f of changedFiles.slice(0, 10)) {
312
- // Limit to 10 files
313
- const { localContent, remoteContent } = await syncService.getFileDiff(f);
314
- const diff = (0, diff_1.createPatch)(f, remoteContent || '', localContent || '', 'remote', 'local');
315
- diffs.push({
316
- file: f,
317
- localExists: localContent !== null,
318
- remoteExists: remoteContent !== null,
319
- diff,
320
- });
321
- }
322
- return (0, helpers_1.successResponse)({
323
- totalChangedFiles: changedFiles.length,
324
- diffs,
325
- note: changedFiles.length > 10
326
- ? `Showing first 10 of ${changedFiles.length} changed files`
327
- : undefined,
328
- });
329
- }
330
- }
331
- catch (error) {
332
- return (0, helpers_1.errorResponse)(`Diff failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
285
+ If no file is specified, shows diffs for all changed files.`,
286
+ diffSchema,
287
+ async (params) => {
288
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
289
+ if (!resolved) {
290
+ return (0, import_helpers.tenantRequiredResponse)();
291
+ }
292
+ const { organisation, tenant } = resolved;
293
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
294
+ if (!clientResult) {
295
+ return (0, import_helpers.authRequiredResponse)(tenant);
296
+ }
297
+ try {
298
+ const syncService = new import_syncService.SyncService(tenant, clientResult.client);
299
+ if (params.file) {
300
+ const { localContent, remoteContent } = await syncService.getFileDiff(params.file);
301
+ if (params.showRemote) {
302
+ return (0, import_helpers.successResponse)({
303
+ file: params.file,
304
+ remoteContent: remoteContent || "(file does not exist on remote)"
305
+ });
306
+ }
307
+ const diff = (0, import_diff.createPatch)(params.file, remoteContent || "", localContent || "", "remote", "local");
308
+ return (0, import_helpers.successResponse)({
309
+ file: params.file,
310
+ localExists: localContent !== null,
311
+ remoteExists: remoteContent !== null,
312
+ diff
313
+ });
314
+ } else {
315
+ const status = await syncService.getStatus();
316
+ const changedFiles = [
317
+ ...status.modifiedLocally,
318
+ ...status.modifiedRemotely,
319
+ ...status.onlyLocal,
320
+ ...status.onlyRemote
321
+ ];
322
+ const diffs = [];
323
+ for (const f of changedFiles.slice(0, 10)) {
324
+ const { localContent, remoteContent } = await syncService.getFileDiff(f);
325
+ const diff = (0, import_diff.createPatch)(f, remoteContent || "", localContent || "", "remote", "local");
326
+ diffs.push({
327
+ file: f,
328
+ localExists: localContent !== null,
329
+ remoteExists: remoteContent !== null,
330
+ diff
331
+ });
332
+ }
333
+ return (0, import_helpers.successResponse)({
334
+ totalChangedFiles: changedFiles.length,
335
+ diffs,
336
+ note: changedFiles.length > 10 ? `Showing first 10 of ${changedFiles.length} changed files` : void 0
337
+ });
333
338
  }
334
- });
335
- // farseer_list_files - List remote files
336
- server.tool('farseer_list_files', `List all files stored on the remote Farseer instance in the Files/ folder.
339
+ } catch (error) {
340
+ return (0, import_helpers.errorResponse)(
341
+ `Diff failed: ${error instanceof Error ? error.message : "Unknown error"}`,
342
+ "NETWORK_ERROR"
343
+ );
344
+ }
345
+ }
346
+ );
347
+ server.tool(
348
+ "farseer_list_files",
349
+ `List all files stored on the remote Farseer instance in the Files/ folder.
337
350
 
338
351
  By default shows only script files (.ts, .js, .mjs, .cjs).
339
352
  Use all=true to show all files including images, data files, etc.
340
353
 
341
- Returns file paths relative to the Files/ folder.`, listFilesSchema, async (params) => {
342
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
343
- if (!resolved) {
344
- return (0, helpers_1.tenantRequiredResponse)();
345
- }
346
- const { organisation, tenant } = resolved;
347
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
348
- if (!clientResult) {
349
- return (0, helpers_1.authRequiredResponse)(tenant);
350
- }
351
- try {
352
- let files = await clientResult.client.listFiles();
353
- // Filter to scripts unless --all
354
- if (!params.all) {
355
- const scriptExtensions = ['.ts', '.js', '.mjs', '.cjs'];
356
- files = files.filter((f) => scriptExtensions.some((ext) => f.name.toLowerCase().endsWith(ext)));
357
- }
358
- // Group by directory
359
- const byDirectory = {};
360
- for (const file of files) {
361
- const dir = file.path.includes('/') ? file.path.split('/').slice(0, -1).join('/') : '.';
362
- if (!byDirectory[dir]) {
363
- byDirectory[dir] = [];
364
- }
365
- byDirectory[dir].push(file.name);
366
- }
367
- return (0, helpers_1.successResponse)({
368
- tenant,
369
- organisation,
370
- totalFiles: files.length,
371
- files: files.map((f) => ({
372
- name: f.name,
373
- path: f.path,
374
- reference: f.reference,
375
- })),
376
- byDirectory,
377
- });
354
+ Returns file paths relative to the Files/ folder.`,
355
+ listFilesSchema,
356
+ async (params) => {
357
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
358
+ if (!resolved) {
359
+ return (0, import_helpers.tenantRequiredResponse)();
360
+ }
361
+ const { organisation, tenant } = resolved;
362
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
363
+ if (!clientResult) {
364
+ return (0, import_helpers.authRequiredResponse)(tenant);
365
+ }
366
+ try {
367
+ let files = await clientResult.client.listFiles();
368
+ if (!params.all) {
369
+ const scriptExtensions = [".ts", ".js", ".mjs", ".cjs"];
370
+ files = files.filter((f) => scriptExtensions.some((ext) => f.name.toLowerCase().endsWith(ext)));
378
371
  }
379
- catch (error) {
380
- return (0, helpers_1.errorResponse)(`List files failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
372
+ const byDirectory = {};
373
+ for (const file of files) {
374
+ const dir = file.path.includes("/") ? file.path.split("/").slice(0, -1).join("/") : ".";
375
+ if (!byDirectory[dir]) {
376
+ byDirectory[dir] = [];
377
+ }
378
+ byDirectory[dir].push(file.name);
381
379
  }
382
- });
380
+ return (0, import_helpers.successResponse)({
381
+ tenant,
382
+ organisation,
383
+ totalFiles: files.length,
384
+ files: files.map((f) => ({
385
+ name: f.name,
386
+ path: f.path,
387
+ reference: f.reference
388
+ })),
389
+ byDirectory
390
+ });
391
+ } catch (error) {
392
+ return (0, import_helpers.errorResponse)(
393
+ `List files failed: ${error instanceof Error ? error.message : "Unknown error"}`,
394
+ "NETWORK_ERROR"
395
+ );
396
+ }
397
+ }
398
+ );
383
399
  }
400
+ // Annotate the CommonJS export names for ESM import in node:
401
+ 0 && (module.exports = {
402
+ registerSyncTools
403
+ });
404
+ //# sourceMappingURL=syncTools.js.map