farseer-cli 1.1.2 → 1.2.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 (52) hide show
  1. package/README.md +21 -10
  2. package/dist/commands/dimensions.js +10 -3
  3. package/dist/commands/dimensions.js.map +2 -2
  4. package/dist/commands/install.js +5 -6
  5. package/dist/commands/install.js.map +2 -2
  6. package/dist/commands/pull.js +7 -1
  7. package/dist/commands/pull.js.map +2 -2
  8. package/dist/commands/push.js +12 -1
  9. package/dist/commands/push.js.map +2 -2
  10. package/dist/commands/run.js +96 -0
  11. package/dist/commands/run.js.map +2 -2
  12. package/dist/index.js +3 -0
  13. package/dist/index.js.map +2 -2
  14. package/dist/mcp/index.js +6 -0
  15. package/dist/mcp/index.js.map +2 -2
  16. package/dist/mcp/server.js +2 -0
  17. package/dist/mcp/server.js.map +2 -2
  18. package/dist/mcp/tools/appTools.js +22 -6
  19. package/dist/mcp/tools/appTools.js.map +2 -2
  20. package/dist/mcp/tools/cellTools.js +3 -54
  21. package/dist/mcp/tools/cellTools.js.map +2 -2
  22. package/dist/mcp/tools/dashboardTools.js +646 -9
  23. package/dist/mcp/tools/dashboardTools.js.map +3 -3
  24. package/dist/mcp/tools/folderTools.js +154 -0
  25. package/dist/mcp/tools/folderTools.js.map +7 -0
  26. package/dist/mcp/tools/modelTools.js +356 -30
  27. package/dist/mcp/tools/modelTools.js.map +2 -2
  28. package/dist/mcp/tools/runTools.js +182 -3
  29. package/dist/mcp/tools/runTools.js.map +2 -2
  30. package/dist/mcp/tools/sheetTools.js +419 -11
  31. package/dist/mcp/tools/sheetTools.js.map +2 -2
  32. package/dist/mcp/utils/helpers.js +2 -0
  33. package/dist/mcp/utils/helpers.js.map +2 -2
  34. package/dist/services/appSyncService.js +4 -2
  35. package/dist/services/appSyncService.js.map +2 -2
  36. package/dist/services/farseerApi.js +46 -12
  37. package/dist/services/farseerApi.js.map +2 -2
  38. package/dist/services/farseerService.js +28 -5
  39. package/dist/services/farseerService.js.map +2 -2
  40. package/dist/services/syncService.js +4 -2
  41. package/dist/services/syncService.js.map +2 -2
  42. package/dist/utils/entityResolver.js +6 -8
  43. package/dist/utils/entityResolver.js.map +2 -2
  44. package/dist/utils/fileLogger.js +225 -0
  45. package/dist/utils/fileLogger.js.map +7 -0
  46. package/dist/utils/logger.js +18 -11
  47. package/dist/utils/logger.js.map +2 -2
  48. package/dist/utils/packageManager.js +78 -0
  49. package/dist/utils/packageManager.js.map +7 -0
  50. package/docs/cli-guide.md +2 -0
  51. package/docs/model-export.md +1 -1
  52. package/package.json +7 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/logger.ts"],
4
- "sourcesContent": ["import chalk from 'chalk';\n\nexport const logger = {\n info: (message: string) => {\n console.log(chalk.blue('\u2139'), message);\n },\n\n success: (message: string) => {\n console.log(chalk.green('\u2713'), message);\n },\n\n warning: (message: string) => {\n console.log(chalk.yellow('\u26A0'), message);\n },\n\n error: (message: string) => {\n console.log(chalk.red('\u2717'), message);\n },\n\n log: (message: string) => {\n console.log(message);\n },\n\n dim: (message: string) => {\n console.log(chalk.dim(message));\n },\n\n header: (message: string) => {\n console.log();\n console.log(chalk.bold.underline(message));\n console.log();\n },\n\n list: (items: string[], indent: number = 2) => {\n const prefix = ' '.repeat(indent);\n items.forEach((item) => {\n console.log(`${prefix}${item}`);\n });\n },\n\n table: (rows: { label: string; value: string }[]) => {\n const maxLabelLength = Math.max(...rows.map((r) => r.label.length));\n rows.forEach((row) => {\n const paddedLabel = row.label.padEnd(maxLabelLength);\n console.log(` ${chalk.dim(paddedLabel)} ${row.value}`);\n });\n },\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAEX,MAAM,SAAS;AAAA,EAClB,MAAM,CAAC,YAAoB;AACvB,YAAQ,IAAI,aAAAA,QAAM,KAAK,QAA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n console.log(...args);\n }\n}\n\nexport const logger = {\n info: (message: string) => {\n log(chalk.blue('\u2139'), message);\n },\n\n success: (message: string) => {\n log(chalk.green('\u2713'), message);\n },\n\n warning: (message: string) => {\n log(chalk.yellow('\u26A0'), message);\n },\n\n error: (message: string) => {\n log(chalk.red('\u2717'), message);\n },\n\n log: (message: string) => {\n log(message);\n },\n\n dim: (message: string) => {\n log(chalk.dim(message));\n },\n\n header: (message: string) => {\n log();\n log(chalk.bold.underline(message));\n log();\n },\n\n list: (items: string[], indent: number = 2) => {\n const prefix = ' '.repeat(indent);\n items.forEach((item) => {\n log(`${prefix}${item}`);\n });\n },\n\n table: (rows: { label: string; value: string }[]) => {\n const maxLabelLength = Math.max(...rows.map((r) => r.label.length));\n rows.forEach((row) => {\n const paddedLabel = row.label.padEnd(maxLabelLength);\n log(` ${chalk.dim(paddedLabel)} ${row.value}`);\n });\n },\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,SAAS,OAAO,MAAiB;AAC7B,MAAI,QAAQ,IAAI,gBAAgB,KAAK;AACjC,YAAQ,MAAM,GAAG,IAAI;AAAA,EACzB,OAAO;AACH,YAAQ,IAAI,GAAG,IAAI;AAAA,EACvB;AACJ;AAEO,MAAM,SAAS;AAAA,EAClB,MAAM,CAAC,YAAoB;AACvB,QAAI,aAAAA,QAAM,KAAK,QAAG,GAAG,OAAO;AAAA,EAChC;AAAA,EAEA,SAAS,CAAC,YAAoB;AAC1B,QAAI,aAAAA,QAAM,MAAM,QAAG,GAAG,OAAO;AAAA,EACjC;AAAA,EAEA,SAAS,CAAC,YAAoB;AAC1B,QAAI,aAAAA,QAAM,OAAO,QAAG,GAAG,OAAO;AAAA,EAClC;AAAA,EAEA,OAAO,CAAC,YAAoB;AACxB,QAAI,aAAAA,QAAM,IAAI,QAAG,GAAG,OAAO;AAAA,EAC/B;AAAA,EAEA,KAAK,CAAC,YAAoB;AACtB,QAAI,OAAO;AAAA,EACf;AAAA,EAEA,KAAK,CAAC,YAAoB;AACtB,QAAI,aAAAA,QAAM,IAAI,OAAO,CAAC;AAAA,EAC1B;AAAA,EAEA,QAAQ,CAAC,YAAoB;AACzB,QAAI;AACJ,QAAI,aAAAA,QAAM,KAAK,UAAU,OAAO,CAAC;AACjC,QAAI;AAAA,EACR;AAAA,EAEA,MAAM,CAAC,OAAiB,SAAiB,MAAM;AAC3C,UAAM,SAAS,IAAI,OAAO,MAAM;AAChC,UAAM,QAAQ,CAAC,SAAS;AACpB,UAAI,GAAG,MAAM,GAAG,IAAI,EAAE;AAAA,IAC1B,CAAC;AAAA,EACL;AAAA,EAEA,OAAO,CAAC,SAA6C;AACjD,UAAM,iBAAiB,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC;AAClE,SAAK,QAAQ,CAAC,QAAQ;AAClB,YAAM,cAAc,IAAI,MAAM,OAAO,cAAc;AACnD,UAAI,KAAK,aAAAA,QAAM,IAAI,WAAW,CAAC,KAAK,IAAI,KAAK,EAAE;AAAA,IACnD,CAAC;AAAA,EACL;AACJ;",
6
6
  "names": ["chalk"]
7
7
  }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var packageManager_exports = {};
30
+ __export(packageManager_exports, {
31
+ FARSEER_CLIENT_URL: () => FARSEER_CLIENT_URL,
32
+ ensurePackageJson: () => ensurePackageJson,
33
+ parsePackageSpec: () => parsePackageSpec
34
+ });
35
+ module.exports = __toCommonJS(packageManager_exports);
36
+ var fs = __toESM(require("fs"));
37
+ var path = __toESM(require("path"));
38
+ const FARSEER_CLIENT_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar";
39
+ function ensurePackageJson(tenantDir, tenant) {
40
+ const packageJsonPath = path.join(tenantDir, "package.json");
41
+ const addedPackages = [];
42
+ let pkg;
43
+ if (fs.existsSync(packageJsonPath)) {
44
+ pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
45
+ } else {
46
+ pkg = {
47
+ name: `farseer-apps-${tenant}`,
48
+ version: "1.0.0",
49
+ private: true,
50
+ description: `Farseer scripts for tenant ${tenant}`,
51
+ dependencies: {}
52
+ };
53
+ addedPackages.push("package.json (created)");
54
+ }
55
+ pkg.dependencies = pkg.dependencies || {};
56
+ if (!pkg.dependencies["farseer-client"]) {
57
+ pkg.dependencies["farseer-client"] = FARSEER_CLIENT_URL;
58
+ addedPackages.push("farseer-client");
59
+ }
60
+ fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + "\n");
61
+ return addedPackages;
62
+ }
63
+ function parsePackageSpec(spec) {
64
+ const isScoped = spec.startsWith("@");
65
+ const lastAt = spec.lastIndexOf("@");
66
+ const hasVersion = lastAt > 0 && (!isScoped || lastAt > spec.indexOf("/"));
67
+ return {
68
+ name: hasVersion ? spec.substring(0, lastAt) : spec,
69
+ version: hasVersion ? spec.substring(lastAt + 1) : "*"
70
+ };
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ FARSEER_CLIENT_URL,
75
+ ensurePackageJson,
76
+ parsePackageSpec
77
+ });
78
+ //# sourceMappingURL=packageManager.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/packageManager.ts"],
4
+ "sourcesContent": ["/**\n * Package Manager Utilities\n *\n * Shared logic for managing tenant package.json files and farseer-client dependency.\n * Used by both CLI install command and MCP farseer_install tool.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n// farseer-client tarball URL \u2014 single source of truth.\n// Update this when publishing a new farseer-client version.\nexport const FARSEER_CLIENT_URL =\n 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar';\n\n/**\n * Ensure the tenant directory has a package.json with farseer-client.\n * Creates package.json if it doesn't exist, adds farseer-client if missing.\n * Returns list of packages that were added.\n */\nexport function ensurePackageJson(tenantDir: string, tenant: string): string[] {\n const packageJsonPath = path.join(tenantDir, 'package.json');\n const addedPackages: string[] = [];\n\n let pkg: any;\n if (fs.existsSync(packageJsonPath)) {\n pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n } else {\n pkg = {\n name: `farseer-apps-${tenant}`,\n version: '1.0.0',\n private: true,\n description: `Farseer scripts for tenant ${tenant}`,\n dependencies: {},\n };\n addedPackages.push('package.json (created)');\n }\n\n pkg.dependencies = pkg.dependencies || {};\n\n if (!pkg.dependencies['farseer-client']) {\n pkg.dependencies['farseer-client'] = FARSEER_CLIENT_URL;\n addedPackages.push('farseer-client');\n }\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + '\\n');\n return addedPackages;\n}\n\n/**\n * Parse an npm package specifier into name and version.\n * Handles scoped packages: @scope/name@version \u2192 { name: \"@scope/name\", version: \"version\" }\n */\nexport function parsePackageSpec(spec: string): { name: string; version: string } {\n const isScoped = spec.startsWith('@');\n const lastAt = spec.lastIndexOf('@');\n const hasVersion = lastAt > 0 && (!isScoped || lastAt > spec.indexOf('/'));\n\n return {\n name: hasVersion ? spec.substring(0, lastAt) : spec,\n version: hasVersion ? spec.substring(lastAt + 1) : '*',\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,SAAoB;AACpB,WAAsB;AAIf,MAAM,qBACT;AAOG,SAAS,kBAAkB,WAAmB,QAA0B;AAC3E,QAAM,kBAAkB,KAAK,KAAK,WAAW,cAAc;AAC3D,QAAM,gBAA0B,CAAC;AAEjC,MAAI;AACJ,MAAI,GAAG,WAAW,eAAe,GAAG;AAChC,UAAM,KAAK,MAAM,GAAG,aAAa,iBAAiB,OAAO,CAAC;AAAA,EAC9D,OAAO;AACH,UAAM;AAAA,MACF,MAAM,gBAAgB,MAAM;AAAA,MAC5B,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa,8BAA8B,MAAM;AAAA,MACjD,cAAc,CAAC;AAAA,IACnB;AACA,kBAAc,KAAK,wBAAwB;AAAA,EAC/C;AAEA,MAAI,eAAe,IAAI,gBAAgB,CAAC;AAExC,MAAI,CAAC,IAAI,aAAa,gBAAgB,GAAG;AACrC,QAAI,aAAa,gBAAgB,IAAI;AACrC,kBAAc,KAAK,gBAAgB;AAAA,EACvC;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,KAAK,MAAM,CAAC,IAAI,IAAI;AACrE,SAAO;AACX;AAMO,SAAS,iBAAiB,MAAiD;AAC9E,QAAM,WAAW,KAAK,WAAW,GAAG;AACpC,QAAM,SAAS,KAAK,YAAY,GAAG;AACnC,QAAM,aAAa,SAAS,MAAM,CAAC,YAAY,SAAS,KAAK,QAAQ,GAAG;AAExE,SAAO;AAAA,IACH,MAAM,aAAa,KAAK,UAAU,GAAG,MAAM,IAAI;AAAA,IAC/C,SAAS,aAAa,KAAK,UAAU,SAAS,CAAC,IAAI;AAAA,EACvD;AACJ;",
6
+ "names": []
7
+ }
package/docs/cli-guide.md CHANGED
@@ -49,6 +49,8 @@ farseer install
49
49
 
50
50
  This runs `npm install` in the tenant directory (`farseer-apps/<tenant>/`).
51
51
 
52
+ > **Important:** All CLI commands must be run from the **repository root** (the directory containing `farseer-apps/`). The CLI resolves paths relative to `process.cwd()`. Running from inside `farseer-apps/<tenant>/` will fail.
53
+
52
54
  ### 5. Work with Files
53
55
 
54
56
  Edit scripts in `farseer-apps/<tenant>/files/Scripts/`. Check status and push:
@@ -15,7 +15,7 @@ farseer model --variable "Revenue" # Show dimensions for a variable
15
15
 
16
16
  ### Via MCP
17
17
 
18
- Use `farseer_export_model` to get the full model as JSON.
18
+ Use `farseer_export_model` to get the full model as JSON. For large models (20KB+), the result is automatically saved to a temp file and a summary is returned — use the Read tool to inspect the file.
19
19
 
20
20
  ### Via farseer-client
21
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "farseer-cli",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "CLI tool for syncing Farseer App scripts between local folder and Farseer instances",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -20,7 +20,9 @@
20
20
  "format:check": "prettier --check src",
21
21
  "format": "prettier --write src",
22
22
  "dev": "ts-node src/index.ts",
23
- "start": "node dist/index.js"
23
+ "start": "node dist/index.js",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest"
24
26
  },
25
27
  "keywords": [
26
28
  "farseer",
@@ -42,7 +44,7 @@
42
44
  "url": "https://github.com/farseerdev/farseer/issues"
43
45
  },
44
46
  "engines": {
45
- "node": ">=18.0.0"
47
+ "node": ">=20.0.0"
46
48
  },
47
49
  "dependencies": {
48
50
  "@modelcontextprotocol/sdk": "^1.0.0",
@@ -65,6 +67,7 @@
65
67
  "prettier": "^3.3.0",
66
68
  "ts-node": "^10.9.2",
67
69
  "tsx": "^4.21.0",
68
- "typescript": "^5.3.2"
70
+ "typescript": "^5.3.2",
71
+ "vitest": "^4.1.0"
69
72
  }
70
73
  }