farseer-cli 1.0.10 → 1.1.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 (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 +405 -400
  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 +453 -487
  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,53 +1,69 @@
1
1
  "use strict";
2
- /**
3
- * Workflow Prompts
4
- *
5
- * Reusable prompt templates for common Farseer workflows.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.registerWorkflowPrompts = registerWorkflowPrompts;
9
- const zod_1 = require("zod");
10
- // Define schemas outside of prompt 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 workflows_exports = {};
20
+ __export(workflows_exports, {
21
+ registerWorkflowPrompts: () => registerWorkflowPrompts
22
+ });
23
+ module.exports = __toCommonJS(workflows_exports);
24
+ var import_zod = require("zod");
11
25
  const setupTenantSchema = {
12
- tenant: zod_1.z.string().describe('Tenant name to setup'),
26
+ tenant: import_zod.z.string().describe("Tenant name to setup")
13
27
  };
14
28
  const createAppSchema = {
15
- tenant: zod_1.z.string().describe('Tenant name'),
16
- appName: zod_1.z.string().describe('Name for the new app'),
17
- scriptName: zod_1.z.string().optional().describe('Main script filename (default: index.ts)'),
29
+ tenant: import_zod.z.string().describe("Tenant name"),
30
+ appName: import_zod.z.string().describe("Name for the new app"),
31
+ scriptName: import_zod.z.string().optional().describe("Main script filename (default: index.ts)")
18
32
  };
19
33
  const understandModelSchema = {
20
- tenant: zod_1.z.string().describe('Tenant name'),
34
+ tenant: import_zod.z.string().describe("Tenant name")
21
35
  };
22
36
  const writeImportScriptSchema = {
23
- tenant: zod_1.z.string().describe('Tenant name'),
24
- variableName: zod_1.z.string().describe('Target variable to import into'),
37
+ tenant: import_zod.z.string().describe("Tenant name"),
38
+ variableName: import_zod.z.string().describe("Target variable to import into")
25
39
  };
26
40
  const copyAppSchema = {
27
- tenant: zod_1.z.string().describe('Tenant name'),
28
- sourceApp: zod_1.z.string().describe('Name of app to copy'),
29
- newAppName: zod_1.z.string().describe('Name for the new app'),
41
+ tenant: import_zod.z.string().describe("Tenant name"),
42
+ sourceApp: import_zod.z.string().describe("Name of app to copy"),
43
+ newAppName: import_zod.z.string().describe("Name for the new app")
30
44
  };
31
45
  const exportDataSchema = {
32
- tenant: zod_1.z.string().describe('Tenant name'),
33
- variableName: zod_1.z.string().describe('Variable to export'),
46
+ tenant: import_zod.z.string().describe("Tenant name"),
47
+ variableName: import_zod.z.string().describe("Variable to export")
34
48
  };
35
49
  const debugSyncSchema = {
36
- tenant: zod_1.z.string().describe('Tenant name'),
50
+ tenant: import_zod.z.string().describe("Tenant name")
37
51
  };
38
52
  function registerWorkflowPrompts(server) {
39
- // Cast to any to avoid very deep generic type instantiation from the MCP SDK
40
- const anyServer = server;
41
- // Setup new tenant
42
- anyServer.prompt('setup_new_tenant', 'Guide for setting up a new Farseer tenant: login, checkout, pull, install dependencies.', setupTenantSchema, async (params) => {
43
- const { tenant } = params;
44
- return {
45
- messages: [
46
- {
47
- role: 'user',
48
- content: {
49
- type: 'text',
50
- text: `You are setting up a new Farseer tenant "${tenant}".
53
+ const anyServer = server;
54
+ anyServer.prompt(
55
+ "setup_new_tenant",
56
+ "Guide for setting up a new Farseer tenant: login, checkout, pull, install dependencies.",
57
+ setupTenantSchema,
58
+ async (params) => {
59
+ const { tenant } = params;
60
+ return {
61
+ messages: [
62
+ {
63
+ role: "user",
64
+ content: {
65
+ type: "text",
66
+ text: `You are setting up a new Farseer tenant "${tenant}".
51
67
 
52
68
  Steps to follow:
53
69
 
@@ -62,23 +78,27 @@ After setup, the user can:
62
78
  - Run apps with farseer_run_app
63
79
  - Edit scripts in apps/${tenant}/files/Scripts/
64
80
  - Push changes with farseer_push
65
- - Check model with farseer_get_variable or farseer_get_table`,
66
- },
67
- },
68
- ],
69
- };
70
- });
71
- // Create new app
72
- anyServer.prompt('create_new_app', 'Guide for creating a new Farseer app from scratch.', createAppSchema, async (params) => {
73
- const { tenant, appName, scriptName } = params;
74
- const script = scriptName || 'index.ts';
75
- return {
76
- messages: [
77
- {
78
- role: 'user',
79
- content: {
80
- type: 'text',
81
- text: `Creating a new Farseer app "${appName}" for tenant "${tenant}".
81
+ - Check model with farseer_get_variable or farseer_get_table`
82
+ }
83
+ }
84
+ ]
85
+ };
86
+ }
87
+ );
88
+ anyServer.prompt(
89
+ "create_new_app",
90
+ "Guide for creating a new Farseer app from scratch.",
91
+ createAppSchema,
92
+ async (params) => {
93
+ const { tenant, appName, scriptName } = params;
94
+ const script = scriptName || "index.ts";
95
+ return {
96
+ messages: [
97
+ {
98
+ role: "user",
99
+ content: {
100
+ type: "text",
101
+ text: `Creating a new Farseer app "${appName}" for tenant "${tenant}".
82
102
 
83
103
  IMPORTANT: A Farseer App = a TypeScript script + an app config that tells Farseer which script to run and with what arguments.
84
104
  The script uses \`farseer-client\` to interact with the Farseer API.
@@ -123,22 +143,26 @@ async function main() {
123
143
  }
124
144
 
125
145
  main().catch(farseer.handleUnknownError);
126
- \`\`\``,
127
- },
128
- },
129
- ],
130
- };
131
- });
132
- // Understand model
133
- anyServer.prompt('understand_model', 'Explore and understand the data model of a Farseer tenant.', understandModelSchema, async (params) => {
134
- const { tenant } = params;
135
- return {
136
- messages: [
137
- {
138
- role: 'user',
139
- content: {
140
- type: 'text',
141
- text: `Analyzing the data model for tenant "${tenant}".
146
+ \`\`\``
147
+ }
148
+ }
149
+ ]
150
+ };
151
+ }
152
+ );
153
+ anyServer.prompt(
154
+ "understand_model",
155
+ "Explore and understand the data model of a Farseer tenant.",
156
+ understandModelSchema,
157
+ async (params) => {
158
+ const { tenant } = params;
159
+ return {
160
+ messages: [
161
+ {
162
+ role: "user",
163
+ content: {
164
+ type: "text",
165
+ text: `Analyzing the data model for tenant "${tenant}".
142
166
 
143
167
  Steps to follow:
144
168
 
@@ -169,22 +193,26 @@ Common dimension tables:
169
193
  - Months, Years (time)
170
194
  - Versions (Plan, Actual, Forecast)
171
195
  - Products, Categories, Brands
172
- - Regions, Entities, Cost Centers`,
173
- },
174
- },
175
- ],
176
- };
177
- });
178
- // Write import script
179
- anyServer.prompt('write_import_script', 'Guide for writing a data import script.', writeImportScriptSchema, async (params) => {
180
- const { tenant, variableName } = params;
181
- return {
182
- messages: [
183
- {
184
- role: 'user',
185
- content: {
186
- type: 'text',
187
- text: `Writing an import script for variable "${variableName}" in tenant "${tenant}".
196
+ - Regions, Entities, Cost Centers`
197
+ }
198
+ }
199
+ ]
200
+ };
201
+ }
202
+ );
203
+ anyServer.prompt(
204
+ "write_import_script",
205
+ "Guide for writing a data import script.",
206
+ writeImportScriptSchema,
207
+ async (params) => {
208
+ const { tenant, variableName } = params;
209
+ return {
210
+ messages: [
211
+ {
212
+ role: "user",
213
+ content: {
214
+ type: "text",
215
+ text: `Writing an import script for variable "${variableName}" in tenant "${tenant}".
188
216
 
189
217
  Steps to follow:
190
218
 
@@ -214,7 +242,7 @@ async function main() {
214
242
  { type: 'DIMENSION_TABLE', dimensionTableName: 'Versions' },
215
243
  { type: 'VARIABLE', variableName: '${variableName}' },
216
244
  ],
217
- labels: ['auto', 'import-${variableName.toLowerCase().replace(/\s+/g, '-')}']
245
+ labels: ['auto', 'import-${variableName.toLowerCase().replace(/\s+/g, "-")}']
218
246
  });
219
247
 
220
248
  // Add rows - each row matches column order
@@ -250,22 +278,26 @@ Use farseer_create_import_job when:
250
278
  Use a script when:
251
279
  - Data comes from external sources (APIs, databases, files)
252
280
  - Complex data transformation is needed
253
- - The import runs on a schedule as an App`,
254
- },
255
- },
256
- ],
257
- };
258
- });
259
- // Copy existing app
260
- anyServer.prompt('copy_app', 'Guide for copying an existing app to create a new one.', copyAppSchema, async (params) => {
261
- const { tenant, sourceApp, newAppName } = params;
262
- return {
263
- messages: [
264
- {
265
- role: 'user',
266
- content: {
267
- type: 'text',
268
- text: `Copying app "${sourceApp}" to create "${newAppName}" for tenant "${tenant}".
281
+ - The import runs on a schedule as an App`
282
+ }
283
+ }
284
+ ]
285
+ };
286
+ }
287
+ );
288
+ anyServer.prompt(
289
+ "copy_app",
290
+ "Guide for copying an existing app to create a new one.",
291
+ copyAppSchema,
292
+ async (params) => {
293
+ const { tenant, sourceApp, newAppName } = params;
294
+ return {
295
+ messages: [
296
+ {
297
+ role: "user",
298
+ content: {
299
+ type: "text",
300
+ text: `Copying app "${sourceApp}" to create "${newAppName}" for tenant "${tenant}".
269
301
 
270
302
  Steps to follow:
271
303
 
@@ -297,22 +329,26 @@ Note: Do NOT include "_remote" for new apps - CLI adds it after first push.
297
329
 
298
330
  5. Push with farseer_push to create the new app
299
331
 
300
- 6. Test with farseer_run_app`,
301
- },
302
- },
303
- ],
304
- };
305
- });
306
- // Export data
307
- anyServer.prompt('export_data', 'Guide for exporting variable data from Farseer.', exportDataSchema, async (params) => {
308
- const { tenant, variableName } = params;
309
- return {
310
- messages: [
311
- {
312
- role: 'user',
313
- content: {
314
- type: 'text',
315
- text: `Exporting data for variable "${variableName}" from tenant "${tenant}".
332
+ 6. Test with farseer_run_app`
333
+ }
334
+ }
335
+ ]
336
+ };
337
+ }
338
+ );
339
+ anyServer.prompt(
340
+ "export_data",
341
+ "Guide for exporting variable data from Farseer.",
342
+ exportDataSchema,
343
+ async (params) => {
344
+ const { tenant, variableName } = params;
345
+ return {
346
+ messages: [
347
+ {
348
+ role: "user",
349
+ content: {
350
+ type: "text",
351
+ text: `Exporting data for variable "${variableName}" from tenant "${tenant}".
316
352
 
317
353
  Steps to follow:
318
354
 
@@ -340,22 +376,26 @@ Steps to follow:
340
376
 
341
377
  3. For analysis:
342
378
  - Parse the CSV data returned by the tools
343
- - Summarize, filter, or transform as needed`,
344
- },
345
- },
346
- ],
347
- };
348
- });
349
- // Debug sync issues
350
- anyServer.prompt('debug_sync_issues', 'Troubleshoot synchronization problems between local and remote.', debugSyncSchema, async (params) => {
351
- const { tenant } = params;
352
- return {
353
- messages: [
354
- {
355
- role: 'user',
356
- content: {
357
- type: 'text',
358
- text: `Debugging sync issues for tenant "${tenant}".
379
+ - Summarize, filter, or transform as needed`
380
+ }
381
+ }
382
+ ]
383
+ };
384
+ }
385
+ );
386
+ anyServer.prompt(
387
+ "debug_sync_issues",
388
+ "Troubleshoot synchronization problems between local and remote.",
389
+ debugSyncSchema,
390
+ async (params) => {
391
+ const { tenant } = params;
392
+ return {
393
+ messages: [
394
+ {
395
+ role: "user",
396
+ content: {
397
+ type: "text",
398
+ text: `Debugging sync issues for tenant "${tenant}".
359
399
 
360
400
  Steps to follow:
361
401
 
@@ -374,19 +414,19 @@ Steps to follow:
374
414
  4. Common issues and solutions:
375
415
 
376
416
  **"No credentials found"**
377
- → User needs to run "farseer login" in terminal
378
- → Or configure API key: "farseer config set ${tenant} --api-key KEY"
417
+ \u2192 User needs to run "farseer login" in terminal
418
+ \u2192 Or configure API key: "farseer config set ${tenant} --api-key KEY"
379
419
 
380
420
  **"Remote has changes"**
381
- → Pull first with farseer_pull
382
- → Then push with farseer_push
421
+ \u2192 Pull first with farseer_pull
422
+ \u2192 Then push with farseer_push
383
423
 
384
424
  **"Token expired"**
385
- → User needs to run "farseer login" again
425
+ \u2192 User needs to run "farseer login" again
386
426
 
387
427
  **Apps not syncing**
388
- → Need JWT login (browser), not API key
389
- → API key only syncs files, not apps
428
+ \u2192 Need JWT login (browser), not API key
429
+ \u2192 API key only syncs files, not apps
390
430
 
391
431
  5. Force resolution:
392
432
  - To accept all remote changes: farseer_pull with force=true (overwrites local)
@@ -394,10 +434,16 @@ Steps to follow:
394
434
  - For selective resolution: farseer_pull without force will skip conflicts (resolve via CLI)
395
435
 
396
436
  6. Check specific file diff:
397
- - Use farseer_diff with file parameter to see exact changes`,
398
- },
399
- },
400
- ],
401
- };
402
- });
437
+ - Use farseer_diff with file parameter to see exact changes`
438
+ }
439
+ }
440
+ ]
441
+ };
442
+ }
443
+ );
403
444
  }
445
+ // Annotate the CommonJS export names for ESM import in node:
446
+ 0 && (module.exports = {
447
+ registerWorkflowPrompts
448
+ });
449
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/prompts/workflows.ts"],
4
+ "sourcesContent": ["/**\n * Workflow Prompts\n *\n * Reusable prompt templates for common Farseer workflows.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\n\n// Define schemas outside of prompt registration to avoid deep type instantiation\nconst setupTenantSchema = {\n tenant: z.string().describe('Tenant name to setup'),\n};\n\nconst createAppSchema = {\n tenant: z.string().describe('Tenant name'),\n appName: z.string().describe('Name for the new app'),\n scriptName: z.string().optional().describe('Main script filename (default: index.ts)'),\n};\n\nconst understandModelSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nconst writeImportScriptSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Target variable to import into'),\n};\n\nconst copyAppSchema = {\n tenant: z.string().describe('Tenant name'),\n sourceApp: z.string().describe('Name of app to copy'),\n newAppName: z.string().describe('Name for the new app'),\n};\n\nconst exportDataSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Variable to export'),\n};\n\nconst debugSyncSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nexport function registerWorkflowPrompts(server: McpServer): void {\n // Cast to any to avoid very deep generic type instantiation from the MCP SDK\n const anyServer = server as any;\n // Setup new tenant\n anyServer.prompt(\n 'setup_new_tenant',\n 'Guide for setting up a new Farseer tenant: login, checkout, pull, install dependencies.',\n setupTenantSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are setting up a new Farseer tenant \"${tenant}\".\n\nSteps to follow:\n\n1. First, check authentication status with farseer_whoami\n2. If not logged in, inform the user to run \"farseer login\" in terminal (MCP cannot do browser login)\n3. Use farseer_checkout to set \"${tenant}\" as the default tenant (this also pulls files and apps)\n4. Tell user to run \"farseer install ${tenant}\" in terminal to install npm dependencies\n5. Use farseer_list_apps to show available apps\n6. Use farseer_export_model to understand the data structure\n\nAfter setup, the user can:\n- Run apps with farseer_run_app\n- Edit scripts in apps/${tenant}/files/Scripts/\n- Push changes with farseer_push\n- Check model with farseer_get_variable or farseer_get_table`,\n },\n },\n ],\n };\n },\n );\n\n // Create new app\n anyServer.prompt(\n 'create_new_app',\n 'Guide for creating a new Farseer app from scratch.',\n createAppSchema,\n async (params: { tenant: string; appName: string; scriptName?: string }) => {\n const { tenant, appName, scriptName } = params;\n const script = scriptName || 'index.ts';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Creating a new Farseer app \"${appName}\" for tenant \"${tenant}\".\n\nIMPORTANT: A Farseer App = a TypeScript script + an app config that tells Farseer which script to run and with what arguments.\nThe script uses \\`farseer-client\\` to interact with the Farseer API.\nAuthentication is automatic - \\`new FarseerClient()\\` reads credentials from environment variables injected by the CLI.\nYou NEVER hardcode credentials in scripts.\n\nSteps to follow:\n\n1. Write the script file at farseer-apps/${tenant}/files/Scripts/${script}\n Use the template below as a starting point.\n\n2. Push the script to remote with farseer_push\n (Scripts must exist on remote before they can be assigned to an app)\n\n3. Create the app with farseer_create_app (name: \"${appName}\")\n\n4. Configure the app with farseer_configure_app:\n - entrypoint: \"${script}\"\n - scripts: [\"${script}\"]\n - arguments: Add any arguments the script expects (they arrive via process.argv)\n\n5. Test with farseer_run_app\n The CLI injects auth credentials as env vars and runs the script with npx tsx.\n\nScript template:\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\n// FarseerClient auto-configures from env vars injected by \"farseer run\"\n// NEVER hardcode credentials - just use the empty constructor\nconst client = new farseer.FarseerClient();\n\n// Arguments come via process.argv in the order defined by app config\nconst args = process.argv.slice(2);\n\nasync function main() {\n // Load dimension/variable metadata\n await client.initTagMap();\n\n // Your code here\n console.log('App running successfully');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\``,\n },\n },\n ],\n };\n },\n );\n\n // Understand model\n anyServer.prompt(\n 'understand_model',\n 'Explore and understand the data model of a Farseer tenant.',\n understandModelSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Analyzing the data model for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_export_model to get the full model structure\n\n2. Review dimension tables:\n - Use farseer_list_tables for overview\n - Key dimensions usually include: Products, Regions, Time (Months, Years), Versions\n - Check foreign key relationships between tables\n\n3. Review variables:\n - Use farseer_list_variables for overview\n - Use farseer_get_variable for specific variable details\n - Note which dimensions each variable has\n\n4. For import scripts, you need to know:\n - Target variable name\n - All dimensions the variable has\n - Valid members for each dimension\n\nKey concepts:\n- Dimensions structure the data (Product, Region, Month, Year, Version)\n- Variables store values at dimension intersections\n- Formulas calculate values automatically\n- Roll-up types determine aggregation (SUM, AVERAGE, etc.)\n\nCommon dimension tables:\n- Months, Years (time)\n- Versions (Plan, Actual, Forecast)\n- Products, Categories, Brands\n- Regions, Entities, Cost Centers`,\n },\n },\n ],\n };\n },\n );\n\n // Write import script\n anyServer.prompt(\n 'write_import_script',\n 'Guide for writing a data import script.',\n writeImportScriptSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Writing an import script for variable \"${variableName}\" in tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the target variable:\n - What dimensions does it have?\n - What is the roll-up type?\n\n2. Use farseer_get_table for each dimension to see valid members\n\n3. Create the import script with this pattern:\n\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Create import job with column definitions\n const importJob = await client.createImportJob({\n title: 'Import ${variableName}',\n columns: [\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Product' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Years' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Months' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Versions' },\n { type: 'VARIABLE', variableName: '${variableName}' },\n ],\n labels: ['auto', 'import-${variableName.toLowerCase().replace(/\\s+/g, '-')}']\n });\n\n // Add rows - each row matches column order\n const rows = [\n ['ProductA', 'Y2025', 'M1', 'Plan', 1000],\n ['ProductB', 'Y2025', 'M1', 'Plan', 2000],\n ];\n\n await importJob.addRows(rows);\n await importJob.flushRows();\n await importJob.undoPrevious(); // Remove previous import\n await importJob.commit();\n\n console.log('Import completed!');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\`\n\n4. Save script to apps/${tenant}/files/Scripts/\n5. Push with farseer_push\n6. Create app with farseer_create_app\n7. Configure with farseer_configure_app\n8. Test with farseer_run_app\n\nALTERNATIVE: For simple imports without a script, use the farseer_create_import_job tool directly.\nIt handles the full workflow (create metadata, add rows, undo previous, commit) in a single call.\nUse farseer_create_import_job when:\n- Data is already available (no need to fetch from external source)\n- The import is a one-time or simple operation\n- You want to quickly import without creating a full script\n\nUse a script when:\n- Data comes from external sources (APIs, databases, files)\n- Complex data transformation is needed\n- The import runs on a schedule as an App`,\n },\n },\n ],\n };\n },\n );\n\n // Copy existing app\n anyServer.prompt(\n 'copy_app',\n 'Guide for copying an existing app to create a new one.',\n copyAppSchema,\n async (params: { tenant: string; sourceApp: string; newAppName: string }) => {\n const { tenant, sourceApp, newAppName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Copying app \"${sourceApp}\" to create \"${newAppName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Pull latest with farseer_pull to get current app JSON\n\n2. Use farseer_get_app to see the source app configuration\n\n3. The app JSON files are in apps/${tenant}/apps/\n\n Copy the source JSON file and modify:\n - Change \"name\" to \"${newAppName}\"\n - **IMPORTANT: Remove \"_remote\" field** (this makes it a new app)\n - Modify arguments, description as needed\n\n4. JSON format for new app:\n\\`\\`\\`json\n{\n \"name\": \"${newAppName}\",\n \"description\": \"Copied from ${sourceApp}\",\n \"entrypoint\": \"script.ts\",\n \"scripts\": [\"script.ts\"],\n \"arguments\": [\n { \"name\": \"Year\", \"defaultValue\": \"2025\" }\n ]\n}\n\\`\\`\\`\n\nNote: Do NOT include \"_remote\" for new apps - CLI adds it after first push.\n\n5. Push with farseer_push to create the new app\n\n6. Test with farseer_run_app`,\n },\n },\n ],\n };\n },\n );\n\n // Export data\n anyServer.prompt(\n 'export_data',\n 'Guide for exporting variable data from Farseer.',\n exportDataSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Exporting data for variable \"${variableName}\" from tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the variable:\n - What dimensions does it span?\n - What is its data type?\n\n2. Choose export method:\n\n **Option A: Quick export (farseer_export_variable_data)**\n - Uses ExportApi.exportFormula() internally\n - Returns CSV/JSON data inline\n - Good for quick inspection or small datasets\n - Use 'limit' parameter for large datasets\n\n **Option B: Structured export (farseer_load_variable_data)**\n - Uses data.loadFarseerVariable() internally\n - Can specify which dimensions to include as columns\n - Returns structured CSV data\n - Good when you need specific dimension breakdowns\n\n **Option C: CLI export (farseer variable export)**\n - Saves CSV/JSON/XLSX to a local file\n - Best for saving data locally for analysis\n\n3. For analysis:\n - Parse the CSV data returned by the tools\n - Summarize, filter, or transform as needed`,\n },\n },\n ],\n };\n },\n );\n\n // Debug sync issues\n anyServer.prompt(\n 'debug_sync_issues',\n 'Troubleshoot synchronization problems between local and remote.',\n debugSyncSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Debugging sync issues for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication: farseer_whoami\n - Is JWT valid?\n - Is tenant checked out?\n\n2. Check sync status: farseer_status\n - Are there modified files?\n - Are there only-local or only-remote files?\n\n3. If files show as modified:\n - Use farseer_diff to see differences\n - Decide: pull (accept remote) or push (upload local)\n\n4. Common issues and solutions:\n\n **\"No credentials found\"**\n \u2192 User needs to run \"farseer login\" in terminal\n \u2192 Or configure API key: \"farseer config set ${tenant} --api-key KEY\"\n\n **\"Remote has changes\"**\n \u2192 Pull first with farseer_pull\n \u2192 Then push with farseer_push\n\n **\"Token expired\"**\n \u2192 User needs to run \"farseer login\" again\n\n **Apps not syncing**\n \u2192 Need JWT login (browser), not API key\n \u2192 API key only syncs files, not apps\n\n5. Force resolution:\n - To accept all remote changes: farseer_pull with force=true (overwrites local)\n - To accept all local changes: farseer_push with force=true (overwrites remote)\n - For selective resolution: farseer_pull without force will skip conflicts (resolve via CLI)\n\n6. Check specific file diff:\n - Use farseer_diff with file parameter to see exact changes`,\n },\n },\n ],\n };\n },\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;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