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