funifier-mcp 0.2.0 → 0.2.4

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 (64) 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 +247 -78
  5. package/datasource-funifier-docs/knowledge/guides/aggregates.md +152 -152
  6. package/datasource-funifier-docs/knowledge/guides/database-access.md +132 -132
  7. package/datasource-funifier-docs/knowledge/guides/java-entities.md +373 -373
  8. package/datasource-funifier-docs/knowledge/guides/java-libraries.md +330 -330
  9. package/datasource-funifier-docs/knowledge/guides/java-managers.md +509 -509
  10. package/datasource-funifier-docs/knowledge/guides/triggers-guide.md +271 -271
  11. package/datasource-funifier-docs/knowledge/index.md +121 -121
  12. package/datasource-funifier-docs/knowledge/modules/achievement.md +46 -46
  13. package/datasource-funifier-docs/knowledge/modules/action-log.md +88 -88
  14. package/datasource-funifier-docs/knowledge/modules/action.md +80 -80
  15. package/datasource-funifier-docs/knowledge/modules/auth.md +104 -104
  16. package/datasource-funifier-docs/knowledge/modules/avatar.md +28 -28
  17. package/datasource-funifier-docs/knowledge/modules/backup.md +40 -40
  18. package/datasource-funifier-docs/knowledge/modules/challenge.md +91 -91
  19. package/datasource-funifier-docs/knowledge/modules/compact.md +40 -40
  20. package/datasource-funifier-docs/knowledge/modules/competition.md +149 -149
  21. package/datasource-funifier-docs/knowledge/modules/crossword.md +41 -41
  22. package/datasource-funifier-docs/knowledge/modules/csv-data.md +30 -30
  23. package/datasource-funifier-docs/knowledge/modules/custom-object.md +53 -53
  24. package/datasource-funifier-docs/knowledge/modules/database.md +241 -241
  25. package/datasource-funifier-docs/knowledge/modules/folder.md +111 -111
  26. package/datasource-funifier-docs/knowledge/modules/kpi-formulas.md +23 -23
  27. package/datasource-funifier-docs/knowledge/modules/lastmile.md +45 -45
  28. package/datasource-funifier-docs/knowledge/modules/leaderboard.md +98 -98
  29. package/datasource-funifier-docs/knowledge/modules/level.md +83 -83
  30. package/datasource-funifier-docs/knowledge/modules/lottery.md +112 -112
  31. package/datasource-funifier-docs/knowledge/modules/marketplace.md +27 -27
  32. package/datasource-funifier-docs/knowledge/modules/mystery.md +82 -82
  33. package/datasource-funifier-docs/knowledge/modules/notification.md +40 -40
  34. package/datasource-funifier-docs/knowledge/modules/patterns.md +1096 -1096
  35. package/datasource-funifier-docs/knowledge/modules/player.md +101 -101
  36. package/datasource-funifier-docs/knowledge/modules/point.md +67 -67
  37. package/datasource-funifier-docs/knowledge/modules/public.md +253 -253
  38. package/datasource-funifier-docs/knowledge/modules/question.md +136 -136
  39. package/datasource-funifier-docs/knowledge/modules/quiz.md +163 -163
  40. package/datasource-funifier-docs/knowledge/modules/scheduler.md +58 -58
  41. package/datasource-funifier-docs/knowledge/modules/security.md +169 -169
  42. package/datasource-funifier-docs/knowledge/modules/staging.md +28 -28
  43. package/datasource-funifier-docs/knowledge/modules/static-repo.md +41 -41
  44. package/datasource-funifier-docs/knowledge/modules/story.md +42 -42
  45. package/datasource-funifier-docs/knowledge/modules/studio-page.md +180 -180
  46. package/datasource-funifier-docs/knowledge/modules/swap.md +132 -132
  47. package/datasource-funifier-docs/knowledge/modules/team.md +75 -75
  48. package/datasource-funifier-docs/knowledge/modules/trigger.md +189 -189
  49. package/datasource-funifier-docs/knowledge/modules/upload.md +155 -155
  50. package/datasource-funifier-docs/knowledge/modules/virtual-good.md +99 -99
  51. package/datasource-funifier-docs/knowledge/modules/webhook.md +41 -41
  52. package/datasource-funifier-docs/knowledge/modules/websocket.md +41 -41
  53. package/datasource-funifier-docs/knowledge/modules/widget.md +42 -42
  54. package/datasource-funifier-docs/process-gtm-saas.md +143 -143
  55. package/datasource-funifier-docs/process-instagram.md +88 -88
  56. package/datasource-funifier-docs/process.md +1826 -1826
  57. package/datasource-funifier-docs/readme.md +132 -132
  58. package/dist/cli/config-writers.js +11 -11
  59. package/dist/mcp/bundle.js +82 -77
  60. package/package.json +70 -67
  61. package/skills/funifier-create-aggregate/SKILL.md +126 -126
  62. package/skills/funifier-create-custom-page/SKILL.md +126 -126
  63. package/skills/funifier-create-scheduler/SKILL.md +126 -126
  64. package/skills/funifier-create-trigger/SKILL.md +127 -127
@@ -1,126 +1,126 @@
1
- ---
2
- name: funifier-create-scheduler
3
- description: Create a Funifier scheduler — guided workflow from naming and cron expression to Groovy code generation
4
- ---
5
-
6
- # funifier-create-scheduler
7
-
8
- Create a Funifier scheduler — guided workflow from naming and cron expression to Groovy code generation
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 "scheduler cron groovy java scheduled job periodic" --skill funifier-create-scheduler
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/modules/scheduler.md`
86
- - `datasource-funifier-docs/knowledge/guides/java-managers.md`
87
- - `datasource-funifier-docs/knowledge/guides/java-libraries.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
1
+ ---
2
+ name: funifier-create-scheduler
3
+ description: Create a Funifier scheduler — guided workflow from naming and cron expression to Groovy code generation
4
+ ---
5
+
6
+ # funifier-create-scheduler
7
+
8
+ Create a Funifier scheduler — guided workflow from naming and cron expression to Groovy code generation
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 "scheduler cron groovy java scheduled job periodic" --skill funifier-create-scheduler
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/modules/scheduler.md`
86
+ - `datasource-funifier-docs/knowledge/guides/java-managers.md`
87
+ - `datasource-funifier-docs/knowledge/guides/java-libraries.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
@@ -1,127 +1,127 @@
1
- ---
2
- name: funifier-create-trigger
3
- description: Create a Funifier trigger — guided workflow from entity/event selection to Groovy code generation
4
- ---
5
-
6
- # funifier-create-trigger
7
-
8
- Create a Funifier trigger — guided workflow from entity/event selection to Groovy code generation
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 "trigger event groovy java before_create after_win entity script" --skill funifier-create-trigger
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/modules/trigger.md`
86
- - `datasource-funifier-docs/knowledge/guides/triggers-guide.md`
87
- - `datasource-funifier-docs/knowledge/guides/java-entities.md`
88
- - `datasource-funifier-docs/knowledge/guides/java-managers.md`
89
-
90
- ## Steps
91
-
92
- ### 1. Understand the requirement
93
-
94
- Ask the user what they want to create or accomplish. Gather:
95
- - The name/title
96
- - The purpose and behavior
97
- - Any specific configuration or constraints
98
-
99
- ### 2. Search for relevant documentation
100
-
101
- Run the lexical search (command shown above) and read the returned files.
102
-
103
- ### 3. Check existing resources (if MCP available)
104
-
105
- Use `funifier_list` with the relevant type and a `search` parameter to see
106
- if a similar resource already exists. Never list all resources without a search term.
107
-
108
- ### 4. Design and confirm
109
-
110
- Based on the docs, outline the configuration to the user and confirm before saving.
111
-
112
- ### 5. Create or update
113
-
114
- Use `funifier_save` with the appropriate type and a JSON payload to create or
115
- update the resource. If MCP is unavailable, show the complete JSON for manual use.
116
-
117
- ### 6. Validate
118
-
119
- Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
120
- the resource was saved correctly and executed without errors.
121
-
122
- ## MCP
123
-
124
- If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier_get`, `funifier_logs`):
125
- - Use MCP for live server data
126
- - Use docs for correct patterns and syntax
127
- - Never learn patterns from existing live resources — docs are authoritative
1
+ ---
2
+ name: funifier-create-trigger
3
+ description: Create a Funifier trigger — guided workflow from entity/event selection to Groovy code generation
4
+ ---
5
+
6
+ # funifier-create-trigger
7
+
8
+ Create a Funifier trigger — guided workflow from entity/event selection to Groovy code generation
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 "trigger event groovy java before_create after_win entity script" --skill funifier-create-trigger
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/modules/trigger.md`
86
+ - `datasource-funifier-docs/knowledge/guides/triggers-guide.md`
87
+ - `datasource-funifier-docs/knowledge/guides/java-entities.md`
88
+ - `datasource-funifier-docs/knowledge/guides/java-managers.md`
89
+
90
+ ## Steps
91
+
92
+ ### 1. Understand the requirement
93
+
94
+ Ask the user what they want to create or accomplish. Gather:
95
+ - The name/title
96
+ - The purpose and behavior
97
+ - Any specific configuration or constraints
98
+
99
+ ### 2. Search for relevant documentation
100
+
101
+ Run the lexical search (command shown above) and read the returned files.
102
+
103
+ ### 3. Check existing resources (if MCP available)
104
+
105
+ Use `funifier_list` with the relevant type and a `search` parameter to see
106
+ if a similar resource already exists. Never list all resources without a search term.
107
+
108
+ ### 4. Design and confirm
109
+
110
+ Based on the docs, outline the configuration to the user and confirm before saving.
111
+
112
+ ### 5. Create or update
113
+
114
+ Use `funifier_save` with the appropriate type and a JSON payload to create or
115
+ update the resource. If MCP is unavailable, show the complete JSON for manual use.
116
+
117
+ ### 6. Validate
118
+
119
+ Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
120
+ the resource was saved correctly and executed without errors.
121
+
122
+ ## MCP
123
+
124
+ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier_get`, `funifier_logs`):
125
+ - Use MCP for live server data
126
+ - Use docs for correct patterns and syntax
127
+ - Never learn patterns from existing live resources — docs are authoritative