funifier-mcp 0.1.0 → 0.2.3

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 (114) hide show
  1. package/.cursor/rules/funifier.mdc +91 -0
  2. package/.github/copilot-instructions.md +83 -0
  3. package/AGENTS.md +97 -0
  4. package/README.md +351 -351
  5. package/datasource-funifier-docs/knowledge/guides/aggregates.md +152 -0
  6. package/datasource-funifier-docs/knowledge/guides/database-access.md +132 -0
  7. package/datasource-funifier-docs/knowledge/guides/java-entities.md +373 -0
  8. package/datasource-funifier-docs/knowledge/guides/java-libraries.md +330 -0
  9. package/datasource-funifier-docs/knowledge/guides/java-managers.md +509 -0
  10. package/datasource-funifier-docs/knowledge/guides/triggers-guide.md +271 -0
  11. package/datasource-funifier-docs/knowledge/index.md +121 -0
  12. package/datasource-funifier-docs/knowledge/modules/achievement.md +46 -0
  13. package/datasource-funifier-docs/knowledge/modules/action-log.md +88 -0
  14. package/datasource-funifier-docs/knowledge/modules/action.md +80 -0
  15. package/datasource-funifier-docs/knowledge/modules/auth.md +104 -0
  16. package/datasource-funifier-docs/knowledge/modules/avatar.md +28 -0
  17. package/datasource-funifier-docs/knowledge/modules/backup.md +40 -0
  18. package/datasource-funifier-docs/knowledge/modules/challenge.md +91 -0
  19. package/datasource-funifier-docs/knowledge/modules/compact.md +40 -0
  20. package/datasource-funifier-docs/knowledge/modules/competition.md +149 -0
  21. package/datasource-funifier-docs/knowledge/modules/crossword.md +41 -0
  22. package/datasource-funifier-docs/knowledge/modules/csv-data.md +30 -0
  23. package/datasource-funifier-docs/knowledge/modules/custom-object.md +53 -0
  24. package/datasource-funifier-docs/knowledge/modules/database.md +241 -0
  25. package/datasource-funifier-docs/knowledge/modules/folder.md +111 -0
  26. package/datasource-funifier-docs/knowledge/modules/kpi-formulas.md +23 -0
  27. package/datasource-funifier-docs/knowledge/modules/lastmile.md +45 -0
  28. package/datasource-funifier-docs/knowledge/modules/leaderboard.md +98 -0
  29. package/datasource-funifier-docs/knowledge/modules/level.md +83 -0
  30. package/datasource-funifier-docs/knowledge/modules/lottery.md +112 -0
  31. package/datasource-funifier-docs/knowledge/modules/marketplace.md +27 -0
  32. package/datasource-funifier-docs/knowledge/modules/mystery.md +82 -0
  33. package/datasource-funifier-docs/knowledge/modules/notification.md +40 -0
  34. package/datasource-funifier-docs/knowledge/modules/patterns.md +1096 -0
  35. package/datasource-funifier-docs/knowledge/modules/player.md +101 -0
  36. package/datasource-funifier-docs/knowledge/modules/point.md +67 -0
  37. package/datasource-funifier-docs/knowledge/modules/public.md +253 -0
  38. package/datasource-funifier-docs/knowledge/modules/question.md +136 -0
  39. package/datasource-funifier-docs/knowledge/modules/quiz.md +163 -0
  40. package/datasource-funifier-docs/knowledge/modules/scheduler.md +58 -0
  41. package/datasource-funifier-docs/knowledge/modules/security.md +169 -0
  42. package/datasource-funifier-docs/knowledge/modules/staging.md +28 -0
  43. package/datasource-funifier-docs/knowledge/modules/static-repo.md +41 -0
  44. package/datasource-funifier-docs/knowledge/modules/story.md +42 -0
  45. package/datasource-funifier-docs/knowledge/modules/studio-page.md +180 -0
  46. package/datasource-funifier-docs/knowledge/modules/swap.md +132 -0
  47. package/datasource-funifier-docs/knowledge/modules/team.md +75 -0
  48. package/datasource-funifier-docs/knowledge/modules/trigger.md +189 -0
  49. package/datasource-funifier-docs/knowledge/modules/upload.md +155 -0
  50. package/datasource-funifier-docs/knowledge/modules/virtual-good.md +99 -0
  51. package/datasource-funifier-docs/knowledge/modules/webhook.md +41 -0
  52. package/datasource-funifier-docs/knowledge/modules/websocket.md +41 -0
  53. package/datasource-funifier-docs/knowledge/modules/widget.md +42 -0
  54. package/datasource-funifier-docs/process-gtm-saas.md +143 -0
  55. package/datasource-funifier-docs/process-instagram.md +88 -0
  56. package/datasource-funifier-docs/process.md +1826 -0
  57. package/datasource-funifier-docs/readme.md +132 -0
  58. package/dist/cli/config-writers.d.ts +15 -0
  59. package/dist/cli/config-writers.d.ts.map +1 -0
  60. package/dist/cli/config-writers.js +55 -0
  61. package/dist/cli/config-writers.js.map +1 -0
  62. package/dist/cli/config-writers.test.d.ts +2 -0
  63. package/dist/cli/config-writers.test.d.ts.map +1 -0
  64. package/dist/cli/config-writers.test.js +55 -0
  65. package/dist/cli/config-writers.test.js.map +1 -0
  66. package/dist/cli/copy.d.ts +6 -0
  67. package/dist/cli/copy.d.ts.map +1 -0
  68. package/dist/cli/copy.js +63 -0
  69. package/dist/cli/copy.js.map +1 -0
  70. package/dist/cli/copy.test.d.ts +2 -0
  71. package/dist/cli/copy.test.d.ts.map +1 -0
  72. package/dist/cli/copy.test.js +94 -0
  73. package/dist/cli/copy.test.js.map +1 -0
  74. package/dist/cli/init.d.ts +2 -0
  75. package/dist/cli/init.d.ts.map +1 -0
  76. package/dist/cli/init.js +167 -0
  77. package/dist/cli/init.js.map +1 -0
  78. package/dist/cli/paths.d.ts +7 -0
  79. package/dist/cli/paths.d.ts.map +1 -0
  80. package/dist/cli/paths.js +62 -0
  81. package/dist/cli/paths.js.map +1 -0
  82. package/dist/cli/paths.test.d.ts +2 -0
  83. package/dist/cli/paths.test.d.ts.map +1 -0
  84. package/dist/cli/paths.test.js +50 -0
  85. package/dist/cli/paths.test.js.map +1 -0
  86. package/dist/cli/platforms.d.ts +22 -0
  87. package/dist/cli/platforms.d.ts.map +1 -0
  88. package/dist/cli/platforms.js +50 -0
  89. package/dist/cli/platforms.js.map +1 -0
  90. package/dist/cli/prompts.d.ts +7 -0
  91. package/dist/cli/prompts.d.ts.map +1 -0
  92. package/dist/cli/prompts.js +49 -0
  93. package/dist/cli/prompts.js.map +1 -0
  94. package/dist/index.js +1 -1
  95. package/dist/index.js.map +1 -1
  96. package/dist/mcp/bundle.js +98 -50
  97. package/dist/mcp/index.js +18 -1
  98. package/dist/mcp/index.js.map +1 -1
  99. package/package.json +70 -65
  100. package/skills/funifier-create-action/SKILL.md +86 -86
  101. package/skills/funifier-create-aggregate/SKILL.md +126 -87
  102. package/skills/funifier-create-challenge/SKILL.md +87 -87
  103. package/skills/funifier-create-custom-page/SKILL.md +126 -87
  104. package/skills/funifier-create-leaderboard/SKILL.md +87 -87
  105. package/skills/funifier-create-level/SKILL.md +86 -86
  106. package/skills/funifier-create-point/SKILL.md +86 -86
  107. package/skills/funifier-create-quiz/SKILL.md +86 -86
  108. package/skills/funifier-create-scheduler/SKILL.md +126 -87
  109. package/skills/funifier-create-trigger/SKILL.md +127 -88
  110. package/skills/funifier-create-virtual-good/SKILL.md +86 -86
  111. package/skills/funifier-debug/SKILL.md +90 -90
  112. package/skills/funifier-help/SKILL.md +85 -85
  113. package/skills/funifier-implement-frontend/SKILL.md +89 -89
  114. package/skills/funifier-index/SKILL.md +50 -50
package/dist/mcp/index.js CHANGED
@@ -8,6 +8,24 @@ const tools_1 = require("./tools");
8
8
  const documentation_1 = require("./resources/documentation");
9
9
  const templates_1 = require("./prompts/templates");
10
10
  async function main() {
11
+ const subcommand = process.argv[2];
12
+ if (subcommand === "init") {
13
+ const { default: runInit } = require("../cli/init");
14
+ await runInit();
15
+ return;
16
+ }
17
+ if (subcommand === "--version" || subcommand === "-v") {
18
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
19
+ const pkg = require("../../package.json");
20
+ console.log(pkg.version);
21
+ return;
22
+ }
23
+ if (subcommand === "--help" || subcommand === "-h") {
24
+ console.log("Usage: funifier-mcp Start the MCP server (stdio)");
25
+ console.log(" funifier-mcp init Interactive setup for AI platforms");
26
+ console.log(" funifier-mcp --version Print version");
27
+ return;
28
+ }
11
29
  // Create the API holder (manages connection state)
12
30
  const apiHolder = new api_holder_1.ApiHolder();
13
31
  // Try to auto-connect from funifier.json or env vars (non-blocking)
@@ -25,7 +43,6 @@ async function main() {
25
43
  const transport = new stdio_js_1.StdioServerTransport();
26
44
  await server.connect(transport);
27
45
  if (!autoConnected) {
28
- // Server started without config — tools will ask user to connect via funifier_connect
29
46
  console.error("Funifier MCP server started without auto-config. Use funifier_connect tool to connect.");
30
47
  }
31
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAEA,oEAAoE;AACpE,wEAAiF;AACjF,6CAAyC;AACzC,mCAAwC;AACxC,6DAA8D;AAC9D,mDAAsD;AAEtD,KAAK,UAAU,IAAI;IACjB,mDAAmD;IACnD,MAAM,SAAS,GAAG,IAAI,sBAAS,EAAE,CAAC;IAElC,oEAAoE;IACpE,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC;IAEjD,wBAAwB;IACxB,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC;QAC3B,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,6CAA6C;IAC7C,IAAA,qBAAa,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC,IAAA,iCAAiB,EAAC,MAAM,CAAC,CAAC;IAC1B,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;IAExB,6BAA6B;IAC7B,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,sFAAsF;QACtF,OAAO,CAAC,KAAK,CACX,wFAAwF,CACzF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAEA,oEAAoE;AACpE,wEAAiF;AACjF,6CAAyC;AACzC,mCAAwC;AACxC,6DAA8D;AAC9D,mDAAsD;AAEtD,KAAK,UAAU,IAAI;IACjB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QAC1B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;QACpD,MAAM,OAAO,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IACD,IAAI,UAAU,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACtD,8DAA8D;QAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO;IACT,CAAC;IACD,IAAI,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC;QACjF,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAC5D,OAAO;IACT,CAAC;IAED,mDAAmD;IACnD,MAAM,SAAS,GAAG,IAAI,sBAAS,EAAE,CAAC;IAElC,oEAAoE;IACpE,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC;IAEjD,wBAAwB;IACxB,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC;QAC3B,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,6CAA6C;IAC7C,IAAA,qBAAa,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC,IAAA,iCAAiB,EAAC,MAAM,CAAC,CAAC;IAC1B,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;IAExB,6BAA6B;IAC7B,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CACX,wFAAwF,CACzF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,65 +1,70 @@
1
- {
2
- "name": "funifier-mcp",
3
- "version": "0.1.0",
4
- "description": "Funifier AI toolkit — MCP server, API client, and Claude Code skills for the Funifier gamification platform",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "bin": {
8
- "funifier-mcp": "dist/mcp/index.js"
9
- },
10
- "files": [
11
- "dist",
12
- "skills",
13
- "doc",
14
- "README.md",
15
- "LICENSE"
16
- ],
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/funifierinc/funifier-mcp.git"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/funifierinc/funifier-mcp/issues"
23
- },
24
- "homepage": "https://github.com/funifierinc/funifier-mcp#readme",
25
- "author": "Funifier",
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "scripts": {
30
- "build": "tsc",
31
- "bundle": "npm run build && esbuild dist/mcp/index.js --bundle --outfile=dist/mcp/bundle.js --format=cjs --platform=node --minify",
32
- "dev": "tsc --watch",
33
- "prepublishOnly": "npm run bundle",
34
- "test": "vitest run",
35
- "test:watch": "vitest watch",
36
- "build:skills": "tsx scripts/build-skills.ts",
37
- "build:skills:force": "tsx scripts/build-skills.ts --force",
38
- "search:docs": "tsx scripts/search-docs.ts"
39
- },
40
- "keywords": [
41
- "funifier",
42
- "gamification",
43
- "mcp",
44
- "model-context-protocol",
45
- "claude",
46
- "ai",
47
- "api-client"
48
- ],
49
- "license": "MIT",
50
- "dependencies": {
51
- "@modelcontextprotocol/sdk": "^1.0.0",
52
- "axios": "^1.6.0",
53
- "zod": "^3.25.76"
54
- },
55
- "devDependencies": {
56
- "@types/node": "^25.5.0",
57
- "esbuild": "^0.20.0",
58
- "tsx": "^4.21.0",
59
- "typescript": "^5.3.0",
60
- "vitest": "^1.0.0"
61
- },
62
- "engines": {
63
- "node": ">=18"
64
- }
65
- }
1
+ {
2
+ "name": "funifier-mcp",
3
+ "version": "0.2.3",
4
+ "description": "Funifier AI toolkit — MCP server, API client, and Claude Code skills for the Funifier gamification platform",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "funifier-mcp": "dist/mcp/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "skills",
13
+ "doc",
14
+ "datasource-funifier-docs",
15
+ "AGENTS.md",
16
+ ".github/copilot-instructions.md",
17
+ ".cursor/rules/funifier.mdc",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/funifierinc/funifier-mcp.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/funifierinc/funifier-mcp/issues"
27
+ },
28
+ "homepage": "https://github.com/funifierinc/funifier-mcp#readme",
29
+ "author": "Funifier",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "bundle": "npm run build && esbuild dist/mcp/index.js --bundle --outfile=dist/mcp/bundle.js --format=cjs --platform=node --minify",
36
+ "dev": "tsc --watch",
37
+ "prepublishOnly": "npm run bundle",
38
+ "test": "vitest run",
39
+ "test:watch": "vitest watch",
40
+ "build:skills": "tsx scripts/build-skills.ts",
41
+ "build:skills:force": "tsx scripts/build-skills.ts --force",
42
+ "search:docs": "tsx scripts/search-docs.ts"
43
+ },
44
+ "keywords": [
45
+ "funifier",
46
+ "gamification",
47
+ "mcp",
48
+ "model-context-protocol",
49
+ "claude",
50
+ "ai",
51
+ "api-client"
52
+ ],
53
+ "license": "MIT",
54
+ "dependencies": {
55
+ "@inquirer/prompts": "^8.4.1",
56
+ "@modelcontextprotocol/sdk": "^1.0.0",
57
+ "axios": "^1.6.0",
58
+ "zod": "^3.25.76"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^25.5.0",
62
+ "esbuild": "^0.20.0",
63
+ "tsx": "^4.21.0",
64
+ "typescript": "^5.3.0",
65
+ "vitest": "^1.0.0"
66
+ },
67
+ "engines": {
68
+ "node": ">=18"
69
+ }
70
+ }
@@ -1,86 +1,86 @@
1
- ---
2
- name: funifier-create-action
3
- description: Create a Funifier action — define trackable player behaviors with attributes
4
- ---
5
-
6
- # funifier-create-action
7
-
8
- Create a Funifier action — define trackable player behaviors with attributes
9
-
10
- ## Persona e Qualidade de Código
11
-
12
- A partir de agora, atue como um **desenvolvedor de software sênior altamente experiente**, especializado em **geração de código limpo, legível e de fácil manutenção**. Suas soluções devem seguir rigorosamente as **boas práticas da indústria**, **padrões de projeto** e **arquiteturas modernas**, sempre **evitando overengineering**.
13
-
14
- ### Ao lidar com qualquer código — seja refatorando ou criando do zero — siga este processo:
15
-
16
- 1. **Analise cuidadosamente o problema ou o código existente.**
17
- 2. **Raciocine passo a passo** antes de escrever qualquer linha de código.
18
- 3. **Identifique problemas (em caso de refatoração) ou requisitos (em caso de código novo).**
19
- 4. **Defina prioridades e estratégias com base em princípios sólidos de engenharia.**
20
- 5. **Justifique tecnicamente cada decisão**, com base em fundamentos como:
21
- - **SOLID**
22
- - **DRY (Don't Repeat Yourself)**
23
- - **KISS (Keep It Simple, Stupid)**
24
- - **YAGNI (You Aren't Gonna Need It)**
25
-
26
- Só então prossiga com a implementação.
27
-
28
- > **Nota:** Os exemplos de código na documentação Funifier são ilustrativos — podem usar nomes de variáveis genéricos ou scripts monolíticos. Sempre melhore-os: use nomes descritivos, extraia métodos especializados para lógicas complexas e mantenha cada função com responsabilidade única.
29
-
30
- ---
31
-
32
- ## Before starting — find relevant docs
33
-
34
- Run lexical search to load only what you need:
35
-
36
- ```bash
37
- npx tsx scripts/search-docs.ts "action track player behavior attributes log event" --skill funifier-create-action
38
- ```
39
-
40
- Read only files returned with score > 0.5 (this threshold is printed in the search output).
41
-
42
- ## Primary docs for this skill
43
-
44
- If search returns insufficient results, read directly:
45
-
46
- - `datasource-funifier-docs/knowledge/modules/action.md`
47
- - `datasource-funifier-docs/knowledge/modules/action-log.md`
48
-
49
- ## Steps
50
-
51
- ### 1. Understand the requirement
52
-
53
- Ask the user what they want to create or accomplish. Gather:
54
- - The name/title
55
- - The purpose and behavior
56
- - Any specific configuration or constraints
57
-
58
- ### 2. Search for relevant documentation
59
-
60
- Run the lexical search (command shown above) and read the returned files.
61
-
62
- ### 3. Check existing resources (if MCP available)
63
-
64
- Use `funifier_list` with the relevant type and a `search` parameter to see
65
- if a similar resource already exists. Never list all resources without a search term.
66
-
67
- ### 4. Design and confirm
68
-
69
- Based on the docs, outline the configuration to the user and confirm before saving.
70
-
71
- ### 5. Create or update
72
-
73
- Use `funifier_save` with the appropriate type and a JSON payload to create or
74
- update the resource. If MCP is unavailable, show the complete JSON for manual use.
75
-
76
- ### 6. Validate
77
-
78
- Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
79
- the resource was saved correctly and executed without errors.
80
-
81
- ## MCP
82
-
83
- If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier_get`, `funifier_logs`):
84
- - Use MCP for live server data
85
- - Use docs for correct patterns and syntax
86
- - Never learn patterns from existing live resources — docs are authoritative
1
+ ---
2
+ name: funifier-create-action
3
+ description: Create a Funifier action — define trackable player behaviors with attributes
4
+ ---
5
+
6
+ # funifier-create-action
7
+
8
+ Create a Funifier action — define trackable player behaviors with attributes
9
+
10
+ ## Persona e Qualidade de Código
11
+
12
+ A partir de agora, atue como um **desenvolvedor de software sênior altamente experiente**, especializado em **geração de código limpo, legível e de fácil manutenção**. Suas soluções devem seguir rigorosamente as **boas práticas da indústria**, **padrões de projeto** e **arquiteturas modernas**, sempre **evitando overengineering**.
13
+
14
+ ### Ao lidar com qualquer código — seja refatorando ou criando do zero — siga este processo:
15
+
16
+ 1. **Analise cuidadosamente o problema ou o código existente.**
17
+ 2. **Raciocine passo a passo** antes de escrever qualquer linha de código.
18
+ 3. **Identifique problemas (em caso de refatoração) ou requisitos (em caso de código novo).**
19
+ 4. **Defina prioridades e estratégias com base em princípios sólidos de engenharia.**
20
+ 5. **Justifique tecnicamente cada decisão**, com base em fundamentos como:
21
+ - **SOLID**
22
+ - **DRY (Don't Repeat Yourself)**
23
+ - **KISS (Keep It Simple, Stupid)**
24
+ - **YAGNI (You Aren't Gonna Need It)**
25
+
26
+ Só então prossiga com a implementação.
27
+
28
+ > **Nota:** Os exemplos de código na documentação Funifier são ilustrativos — podem usar nomes de variáveis genéricos ou scripts monolíticos. Sempre melhore-os: use nomes descritivos, extraia métodos especializados para lógicas complexas e mantenha cada função com responsabilidade única.
29
+
30
+ ---
31
+
32
+ ## Before starting — find relevant docs
33
+
34
+ Run lexical search to load only what you need:
35
+
36
+ ```bash
37
+ npx tsx scripts/search-docs.ts "action track player behavior attributes log event" --skill funifier-create-action
38
+ ```
39
+
40
+ Read only files returned with score > 0.5 (this threshold is printed in the search output).
41
+
42
+ ## Primary docs for this skill
43
+
44
+ If search returns insufficient results, read directly:
45
+
46
+ - `datasource-funifier-docs/knowledge/modules/action.md`
47
+ - `datasource-funifier-docs/knowledge/modules/action-log.md`
48
+
49
+ ## Steps
50
+
51
+ ### 1. Understand the requirement
52
+
53
+ Ask the user what they want to create or accomplish. Gather:
54
+ - The name/title
55
+ - The purpose and behavior
56
+ - Any specific configuration or constraints
57
+
58
+ ### 2. Search for relevant documentation
59
+
60
+ Run the lexical search (command shown above) and read the returned files.
61
+
62
+ ### 3. Check existing resources (if MCP available)
63
+
64
+ Use `funifier_list` with the relevant type and a `search` parameter to see
65
+ if a similar resource already exists. Never list all resources without a search term.
66
+
67
+ ### 4. Design and confirm
68
+
69
+ Based on the docs, outline the configuration to the user and confirm before saving.
70
+
71
+ ### 5. Create or update
72
+
73
+ Use `funifier_save` with the appropriate type and a JSON payload to create or
74
+ update the resource. If MCP is unavailable, show the complete JSON for manual use.
75
+
76
+ ### 6. Validate
77
+
78
+ Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
79
+ the resource was saved correctly and executed without errors.
80
+
81
+ ## MCP
82
+
83
+ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier_get`, `funifier_logs`):
84
+ - Use MCP for live server data
85
+ - Use docs for correct patterns and syntax
86
+ - Never learn patterns from existing live resources — docs are authoritative
@@ -1,87 +1,126 @@
1
- ---
2
- name: funifier-create-aggregate
3
- description: Create a Funifier prepared aggregate — guided workflow for building MongoDB aggregate pipelines for reports and dashboards
4
- ---
5
-
6
- # funifier-create-aggregate
7
-
8
- Create a Funifier prepared aggregate — guided workflow for building MongoDB aggregate pipelines for reports and dashboards
9
-
10
- ## Persona e Qualidade de Código
11
-
12
- A partir de agora, atue como um **desenvolvedor de software sênior altamente experiente**, especializado em **geração de código limpo, legível e de fácil manutenção**. Suas soluções devem seguir rigorosamente as **boas práticas da indústria**, **padrões de projeto** e **arquiteturas modernas**, sempre **evitando overengineering**.
13
-
14
- ### Ao lidar com qualquer código — seja refatorando ou criando do zero — siga este processo:
15
-
16
- 1. **Analise cuidadosamente o problema ou o código existente.**
17
- 2. **Raciocine passo a passo** antes de escrever qualquer linha de código.
18
- 3. **Identifique problemas (em caso de refatoração) ou requisitos (em caso de código novo).**
19
- 4. **Defina prioridades e estratégias com base em princípios sólidos de engenharia.**
20
- 5. **Justifique tecnicamente cada decisão**, com base em fundamentos como:
21
- - **SOLID**
22
- - **DRY (Don't Repeat Yourself)**
23
- - **KISS (Keep It Simple, Stupid)**
24
- - **YAGNI (You Aren't Gonna Need It)**
25
-
26
- Só então prossiga com a implementação.
27
-
28
- > **Nota:** Os exemplos de código na documentação Funifier são ilustrativos — podem usar nomes de variáveis genéricos ou scripts monolíticos. Sempre melhore-os: use nomes descritivos, extraia métodos especializados para lógicas complexas e mantenha cada função com responsabilidade única.
29
-
30
- ---
31
-
32
- ## Before starting find relevant docs
33
-
34
- Run lexical search to load only what you need:
35
-
36
- ```bash
37
- npx tsx scripts/search-docs.ts "aggregate mongodb pipeline report dashboard query prepared" --skill funifier-create-aggregate
38
- ```
39
-
40
- Read only files returned with score > 0.5 (this threshold is printed in the search output).
41
-
42
- ## Primary docs for this skill
43
-
44
- If search returns insufficient results, read directly:
45
-
46
- - `datasource-funifier-docs/knowledge/guides/aggregates.md`
47
- - `datasource-funifier-docs/knowledge/guides/database-access.md`
48
- - `datasource-funifier-docs/knowledge/modules/database.md`
49
-
50
- ## Steps
51
-
52
- ### 1. Understand the requirement
53
-
54
- Ask the user what they want to create or accomplish. Gather:
55
- - The name/title
56
- - The purpose and behavior
57
- - Any specific configuration or constraints
58
-
59
- ### 2. Search for relevant documentation
60
-
61
- Run the lexical search (command shown above) and read the returned files.
62
-
63
- ### 3. Check existing resources (if MCP available)
64
-
65
- Use `funifier_list` with the relevant type and a `search` parameter to see
66
- if a similar resource already exists. Never list all resources without a search term.
67
-
68
- ### 4. Design and confirm
69
-
70
- Based on the docs, outline the configuration to the user and confirm before saving.
71
-
72
- ### 5. Create or update
73
-
74
- Use `funifier_save` with the appropriate type and a JSON payload to create or
75
- update the resource. If MCP is unavailable, show the complete JSON for manual use.
76
-
77
- ### 6. Validate
78
-
79
- Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
80
- the resource was saved correctly and executed without errors.
81
-
82
- ## MCP
83
-
84
- If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier_get`, `funifier_logs`):
85
- - Use MCP for live server data
86
- - Use docs for correct patterns and syntax
87
- - Never learn patterns from existing live resources — docs are authoritative
1
+ ---
2
+ name: funifier-create-aggregate
3
+ description: Create a Funifier prepared aggregate — guided workflow for building MongoDB aggregate pipelines for reports and dashboards
4
+ ---
5
+
6
+ # funifier-create-aggregate
7
+
8
+ Create a Funifier prepared aggregate — guided workflow for building MongoDB aggregate pipelines for reports and dashboards
9
+
10
+ ## Persona e Qualidade de Código
11
+
12
+ A partir de agora, atue como um **desenvolvedor de software sênior altamente experiente**, especializado em **geração de código limpo, legível e de fácil manutenção**. Suas soluções devem seguir rigorosamente as **boas práticas da indústria**, **padrões de projeto** e **arquiteturas modernas**, sempre **evitando overengineering**.
13
+
14
+ ### Ao lidar com qualquer código — seja refatorando ou criando do zero — siga este processo:
15
+
16
+ 1. **Analise cuidadosamente o problema ou o código existente.**
17
+ 2. **Raciocine passo a passo** antes de escrever qualquer linha de código.
18
+ 3. **Identifique problemas (em caso de refatoração) ou requisitos (em caso de código novo).**
19
+ 4. **Defina prioridades e estratégias com base em princípios sólidos de engenharia.**
20
+ 5. **Justifique tecnicamente cada decisão**, com base em fundamentos como:
21
+ - **SOLID**
22
+ - **DRY (Don't Repeat Yourself)**
23
+ - **KISS (Keep It Simple, Stupid)**
24
+ - **YAGNI (You Aren't Gonna Need It)**
25
+
26
+ Só então prossiga com a implementação.
27
+
28
+ > **Nota:** Os exemplos de código na documentação Funifier são ilustrativos — podem usar nomes de variáveis genéricos ou scripts monolíticos. Sempre melhore-os: use nomes descritivos, extraia métodos especializados para lógicas complexas e mantenha cada função com responsabilidade única.
29
+
30
+ ---
31
+
32
+ ## Formato do payload (obrigatório)
33
+
34
+ Funifier armazena código como **strings JSON escapadas**. Ao montar o payload do `funifier_save`:
35
+
36
+ - **Quebra de linha** → `\n` (nunca newline literal dentro da string)
37
+ - **Aspas duplas** dentro do código `\"`
38
+ - **Backslash** → `\\` (regex `\b` vira `\\b`; dentro de Groovy com string-building pode exigir `\\\\b`)
39
+ - **Tab** → `\t` (se usar)
40
+ - **Pipelines de aggregate** vão como **string JSON** (não objeto aninhado) serialize o array inteiro
41
+
42
+ A regra prática: monte o objeto em JavaScript normalmente e passe por `JSON.stringify` — o MCP faz isso automaticamente quando você entrega o payload como JSON. **Nunca** cole código multilinha cru no meio do JSON.
43
+
44
+ ### Exemplo 1 custom-page (html + angularjs script)
45
+
46
+ ```json
47
+ {
48
+ "title": "Ciclos",
49
+ "slug": "studio/custom/ciclos",
50
+ "html": "<div class=\"row\">\n <div class=\"col-md-12\">\n <h2>Ciclos</h2>\n </div>\n</div>\n",
51
+ "script": "$scope.all = [];\n$scope.loading = false;\n\n$scope.list = function () {\n $scope.loading = true;\n};\n$scope.list();\n"
52
+ }
53
+ ```
54
+
55
+ ### Exemplo 2 — aggregate preparado (pipeline JSON + script Groovy)
56
+
57
+ ```json
58
+ {
59
+ "_id": "extrato",
60
+ "title": "Extrato de Pontos",
61
+ "collection": "extrato",
62
+ "aggregate": "[\n {\n \"$match\": { \"player\": \"$param:player\" }\n },\n {\n \"$sort\": { \"time\": -1 }\n }\n]",
63
+ "script": "void prepare(aggregations, params) {\n if (context.get(\"player\") != null) {\n params.put(\"player\", context.get(\"player\"));\n } else {\n params.put(\"player\", \"NAO_EXISTE\");\n }\n}\n"
64
+ }
65
+ ```
66
+
67
+ Note que `aggregate` é uma **string** contendo JSON serializado (com `\n` e `\"` escapados), **não** um array nativo. Mesma regra vale para `script` em triggers/schedulers/aggregates e `html`/`script` em custom-pages.
68
+
69
+ ---
70
+
71
+ ## Before starting — find relevant docs
72
+
73
+ Run lexical search to load only what you need:
74
+
75
+ ```bash
76
+ npx tsx scripts/search-docs.ts "aggregate mongodb pipeline report dashboard query prepared" --skill funifier-create-aggregate
77
+ ```
78
+
79
+ Read only files returned with score > 0.5 (this threshold is printed in the search output).
80
+
81
+ ## Primary docs for this skill
82
+
83
+ If search returns insufficient results, read directly:
84
+
85
+ - `datasource-funifier-docs/knowledge/guides/aggregates.md`
86
+ - `datasource-funifier-docs/knowledge/guides/database-access.md`
87
+ - `datasource-funifier-docs/knowledge/modules/database.md`
88
+
89
+ ## Steps
90
+
91
+ ### 1. Understand the requirement
92
+
93
+ Ask the user what they want to create or accomplish. Gather:
94
+ - The name/title
95
+ - The purpose and behavior
96
+ - Any specific configuration or constraints
97
+
98
+ ### 2. Search for relevant documentation
99
+
100
+ Run the lexical search (command shown above) and read the returned files.
101
+
102
+ ### 3. Check existing resources (if MCP available)
103
+
104
+ Use `funifier_list` with the relevant type and a `search` parameter to see
105
+ if a similar resource already exists. Never list all resources without a search term.
106
+
107
+ ### 4. Design and confirm
108
+
109
+ Based on the docs, outline the configuration to the user and confirm before saving.
110
+
111
+ ### 5. Create or update
112
+
113
+ Use `funifier_save` with the appropriate type and a JSON payload to create or
114
+ update the resource. If MCP is unavailable, show the complete JSON for manual use.
115
+
116
+ ### 6. Validate
117
+
118
+ Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
119
+ the resource was saved correctly and executed without errors.
120
+
121
+ ## MCP
122
+
123
+ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier_get`, `funifier_logs`):
124
+ - Use MCP for live server data
125
+ - Use docs for correct patterns and syntax
126
+ - Never learn patterns from existing live resources — docs are authoritative