funifier-mcp 0.2.24 → 0.2.26

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 (96) hide show
  1. package/.cursor/rules/funifier.mdc +1 -0
  2. package/.github/copilot-instructions.md +1 -0
  3. package/AGENTS.md +1 -0
  4. package/datasource-funifier-docs/knowledge/guides/trigger-examples.md +511 -0
  5. package/datasource-funifier-docs/knowledge/guides/triggers-guide.md +1 -1
  6. package/datasource-funifier-docs/knowledge/index.md +1 -1
  7. package/datasource-funifier-docs/knowledge/modules/action.md +96 -39
  8. package/datasource-funifier-docs/knowledge/modules/challenge.md +285 -48
  9. package/datasource-funifier-docs/knowledge/modules/folder.md +347 -68
  10. package/datasource-funifier-docs/knowledge/modules/leaderboard.md +173 -71
  11. package/datasource-funifier-docs/knowledge/modules/point.md +108 -37
  12. package/datasource-funifier-docs/knowledge/modules/trigger.md +1 -1
  13. package/dist/cli/init.d.ts +1 -1
  14. package/dist/cli/init.d.ts.map +1 -1
  15. package/dist/cli/init.js +11 -4
  16. package/dist/cli/init.js.map +1 -1
  17. package/dist/core/api-client.d.ts +21 -1
  18. package/dist/core/api-client.d.ts.map +1 -1
  19. package/dist/core/api-client.js +155 -2
  20. package/dist/core/api-client.js.map +1 -1
  21. package/dist/core/constants.d.ts +15 -0
  22. package/dist/core/constants.d.ts.map +1 -1
  23. package/dist/core/constants.js +15 -0
  24. package/dist/core/constants.js.map +1 -1
  25. package/dist/core/types/Folder.d.ts +16 -0
  26. package/dist/core/types/Folder.d.ts.map +1 -0
  27. package/dist/core/types/Folder.js +3 -0
  28. package/dist/core/types/Folder.js.map +1 -0
  29. package/dist/core/types/FolderContent.d.ts +10 -0
  30. package/dist/core/types/FolderContent.d.ts.map +1 -0
  31. package/dist/core/types/FolderContent.js +3 -0
  32. package/dist/core/types/FolderContent.js.map +1 -0
  33. package/dist/core/types/FolderContentType.d.ts +10 -0
  34. package/dist/core/types/FolderContentType.d.ts.map +1 -0
  35. package/dist/core/types/FolderContentType.js +3 -0
  36. package/dist/core/types/FolderContentType.js.map +1 -0
  37. package/dist/core/types/FolderLog.d.ts +11 -0
  38. package/dist/core/types/FolderLog.d.ts.map +1 -0
  39. package/dist/core/types/FolderLog.js +3 -0
  40. package/dist/core/types/FolderLog.js.map +1 -0
  41. package/dist/core/types/index.d.ts +4 -0
  42. package/dist/core/types/index.d.ts.map +1 -1
  43. package/dist/core/types/index.js +4 -0
  44. package/dist/core/types/index.js.map +1 -1
  45. package/dist/mcp/bundle.js +101 -92
  46. package/dist/mcp/check-update.d.ts +2 -0
  47. package/dist/mcp/check-update.d.ts.map +1 -0
  48. package/dist/mcp/check-update.js +44 -0
  49. package/dist/mcp/check-update.js.map +1 -0
  50. package/dist/mcp/index.js +5 -1
  51. package/dist/mcp/index.js.map +1 -1
  52. package/dist/mcp/tools/_char-guard.js +1 -1
  53. package/dist/mcp/tools/_char-guard.js.map +1 -1
  54. package/dist/mcp/tools/_fetch-current.d.ts +1 -1
  55. package/dist/mcp/tools/_fetch-current.d.ts.map +1 -1
  56. package/dist/mcp/tools/_fetch-current.js +12 -0
  57. package/dist/mcp/tools/_fetch-current.js.map +1 -1
  58. package/dist/mcp/tools/delete.d.ts.map +1 -1
  59. package/dist/mcp/tools/delete.js +20 -0
  60. package/dist/mcp/tools/delete.js.map +1 -1
  61. package/dist/mcp/tools/folder.d.ts +4 -0
  62. package/dist/mcp/tools/folder.d.ts.map +1 -0
  63. package/dist/mcp/tools/folder.js +58 -0
  64. package/dist/mcp/tools/folder.js.map +1 -0
  65. package/dist/mcp/tools/get.d.ts.map +1 -1
  66. package/dist/mcp/tools/get.js +22 -8
  67. package/dist/mcp/tools/get.js.map +1 -1
  68. package/dist/mcp/tools/index.d.ts.map +1 -1
  69. package/dist/mcp/tools/index.js +2 -0
  70. package/dist/mcp/tools/index.js.map +1 -1
  71. package/dist/mcp/tools/list.d.ts.map +1 -1
  72. package/dist/mcp/tools/list.js +9 -2
  73. package/dist/mcp/tools/list.js.map +1 -1
  74. package/dist/mcp/tools/save.d.ts.map +1 -1
  75. package/dist/mcp/tools/save.js +100 -7
  76. package/dist/mcp/tools/save.js.map +1 -1
  77. package/dist/mcp/tools/save.test.js +191 -0
  78. package/dist/mcp/tools/save.test.js.map +1 -1
  79. package/package.json +3 -2
  80. package/skills/funifier-create-action/SKILL.md +58 -18
  81. package/skills/funifier-create-aggregate/SKILL.md +1 -0
  82. package/skills/funifier-create-challenge/SKILL.md +1 -0
  83. package/skills/funifier-create-custom-page/SKILL.md +1 -0
  84. package/skills/funifier-create-leaderboard/SKILL.md +90 -18
  85. package/skills/funifier-create-level/SKILL.md +1 -0
  86. package/skills/funifier-create-point/SKILL.md +60 -18
  87. package/skills/funifier-create-quiz/SKILL.md +1 -0
  88. package/skills/funifier-create-scheduler/SKILL.md +1 -0
  89. package/skills/funifier-create-trigger/SKILL.md +110 -19
  90. package/skills/funifier-create-virtual-good/SKILL.md +1 -0
  91. package/skills/funifier-debug/SKILL.md +2 -0
  92. package/skills/funifier-help/SKILL.md +1 -0
  93. package/skills/funifier-implement-frontend/SKILL.md +1 -0
  94. package/skills/funifier-index/SKILL.md +9 -1
  95. package/datasource-funifier-docs/.search-index.json +0 -16205
  96. package/datasource-funifier-docs/.skills-map.json +0 -71
@@ -48,35 +48,76 @@ If search returns insufficient results, read directly:
48
48
 
49
49
  ## Steps
50
50
 
51
- ### 1. Understand the requirement
51
+ ### Rules follow exactly, no exceptions
52
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
53
+ **The single most important decision: which technique?**
57
54
 
58
- ### 2. Search for relevant documentation
55
+ | Point type | `techniques` | When to use |
56
+ |---|---|---|
57
+ | Normal (XP, score, karma) | `["GT01"]` | Progresso/ranking — jogador acumula, não transfere |
58
+ | Trocável entre jogadores | `["GT75"]` | Jogadores podem transferir/enviar este ponto uns para os outros |
59
59
 
60
- Run the lexical search (command shown above) and read the returned files.
60
+ Se jogadores podem trocar ou enviar este ponto entre si **GT75**.
61
+ Tudo o mais → **GT01**.
62
+ Qualquer tipo de ponto pode ser usado na loja virtual — isso não influencia a escolha da técnica.
61
63
 
62
- ### 3. Check existing resources (if MCP available)
64
+ **_id format:** lowercase, no spaces (`xp`, `coin`, `karma`) — never `"Experience Points"` or `"XP Points"`.
63
65
 
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
+ **Upsert:** POST with existing `_id` updates the point never errors on duplicate.
66
67
 
67
- ### 4. Design and confirm
68
+ **Create points BEFORE challenges and leaderboards that reference them.**
68
69
 
69
- Based on the docs, outline the configuration to the user and confirm before saving.
70
+ ---
71
+
72
+ ### 1. Determine the type
73
+
74
+ Ask (or infer from context): is this point spendable in a store?
75
+ - Yes → `GT75`
76
+ - No → `GT01`
77
+
78
+ ### 2. Check if it already exists
79
+
80
+ ```
81
+ funifier_list type=point search=<name or _id>
82
+ ```
83
+
84
+ If it exists and has the correct technique, stop.
85
+
86
+ ### 3. Build the payload
70
87
 
71
- ### 5. Create or update
88
+ Normal point (GT01):
89
+ ```json
90
+ {
91
+ "_id": "xp",
92
+ "category": "Experience Points",
93
+ "shortName": "XP",
94
+ "techniques": ["GT01"]
95
+ }
96
+ ```
97
+
98
+ Exchangeable point (GT75):
99
+ ```json
100
+ {
101
+ "_id": "coin",
102
+ "category": "Coins",
103
+ "shortName": "Coins",
104
+ "techniques": ["GT75"]
105
+ }
106
+ ```
72
107
 
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.
108
+ ### 4. Save
75
109
 
76
- ### 6. Validate
110
+ ```
111
+ funifier_save type=point payload=<json>
112
+ ```
113
+
114
+ ### 5. Validate
115
+
116
+ ```
117
+ funifier_list type=point search=<_id>
118
+ ```
77
119
 
78
- Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
79
- the resource was saved correctly and executed without errors.
120
+ Do NOT use `funifier_logs` — that is only for triggers and schedulers.
80
121
 
81
122
  ## MCP
82
123
 
@@ -84,3 +125,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
84
125
  - Use MCP for live server data
85
126
  - Use docs for correct patterns and syntax
86
127
  - Never learn patterns from existing live resources — docs are authoritative
128
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -84,3 +84,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
84
84
  - Use MCP for live server data
85
85
  - Use docs for correct patterns and syntax
86
86
  - Never learn patterns from existing live resources — docs are authoritative
87
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -124,3 +124,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
124
124
  - Use MCP for live server data
125
125
  - Use docs for correct patterns and syntax
126
126
  - Never learn patterns from existing live resources — docs are authoritative
127
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -73,7 +73,7 @@ Note que `aggregate` é uma **string** contendo JSON serializado (com `\n` e `\"
73
73
  Run lexical search to load only what you need:
74
74
 
75
75
  ```bash
76
- npx funifier-mcp search "trigger event groovy java before_create after_win entity script" --skill funifier-create-trigger
76
+ npx funifier-mcp search "trigger event groovy java before_create after_win entity script achievement_type context_extra bulk csv after_bulk before_bulk" --skill funifier-create-trigger
77
77
  ```
78
78
 
79
79
  Read only files returned with score > 0.5 (this threshold is printed in the search output).
@@ -86,38 +86,128 @@ If search returns insufficient results, read directly:
86
86
  - `datasource-funifier-docs/knowledge/guides/triggers-guide.md`
87
87
  - `datasource-funifier-docs/knowledge/guides/java-entities.md`
88
88
  - `datasource-funifier-docs/knowledge/guides/java-managers.md`
89
+ - `datasource-funifier-docs/knowledge/guides/trigger-examples.md`
89
90
 
90
91
  ## Steps
91
92
 
92
- ### 1. Understand the requirement
93
+ ## Regra crítica: triggers não impedem persistência via throw
93
94
 
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
95
+ O Funifier **sempre salva o documento** antes de executar o trigger.
98
96
 
99
- ### 2. Search for relevant documentation
97
+ - `before_create` enriquecimento apenas (normalizar, preencher defaults)
98
+ - Rejeitar criação → usar `after_create`: validar → se inválido:
99
+ ```java
100
+ database.delete(entity._id, "collection__c");
101
+ entity.clear();
102
+ entity.put("message", "motivo");
103
+ return;
104
+ ```
105
+ - Para lógica complexa, use `BusinessException` interna (capturada dentro do trigger, não propaga para a plataforma).
100
106
 
101
- Run the lexical search (command shown above) and read the returned files.
107
+ ---
108
+
109
+ ## Referência rápida — constantes e campos
110
+
111
+ | Constante | Valor | Uso |
112
+ |-----------|-------|-----|
113
+ | `Achievement.TYPE_POINT` | `0` | Ponto acumulado |
114
+ | `Achievement.TYPE_CHALLENGE` | `1` | Desafio completado |
115
+ | `Achievement.TYPE_VIRTUAL_GOOD` | `2` | Item de catálogo |
116
+ | `Achievement.TYPE_LEVEL` | `3` | Nível alcançado |
117
+
118
+ **ActionLog** (entity em triggers de `action`):
119
+ `entity.actionId`, `entity.userId`, `entity.attributes` (Map), `entity.time`, `entity.id`
120
+
121
+ **Player** (entity em triggers de `player`):
122
+ `entity._id`, `entity.name`, `entity.email`, `entity.extra` (Map), `entity.teams`
102
123
 
103
- ### 3. Check existing resources (if MCP available)
124
+ **context.extra** (disponível em `before_win` / `before_create` / `after_create`):
125
+ - `context.extra.parentAchievement.id` / `.type` / `.item` / `.player`
126
+ - `context.extra.parentActionLog.id` / `.actionId` / `.userId` / `.attributes`
127
+ - `context.extra.originActionLog` — action log raiz da cadeia
104
128
 
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.
129
+ ---
107
130
 
108
- ### 4. Design and confirm
131
+ ## Leituras obrigatórias (não condicionais — leia antes de escrever qualquer Groovy)
109
132
 
110
- Based on the docs, outline the configuration to the user and confirm before saving.
133
+ - `datasource-funifier-docs/knowledge/guides/java-entities.md`
134
+ - `datasource-funifier-docs/knowledge/guides/java-managers.md`
135
+ - `datasource-funifier-docs/knowledge/guides/trigger-examples.md`
136
+
137
+ ---
111
138
 
112
- ### 5. Create or update
139
+ ## Steps
140
+
141
+ ### 1. Entender o requisito
142
+
143
+ Perguntar (ou inferir do contexto):
144
+ - Nome/descrição da trigger
145
+ - Qual entidade e evento? (ver tabela abaixo)
146
+ - Qual comportamento esperado?
147
+
148
+ **Combinações mais comuns:**
149
+
150
+ | entity | event | Quando usar |
151
+ |--------|-------|-------------|
152
+ | `action` | `before_win` | Reagir a uma ação antes de registrar a conquista |
153
+ | `action` | `after_win` | Efeito colateral após ação (ex: creditar pontos para outro jogador) |
154
+ | `achievement` | `before_create` | Enriquecer conquista com dados de origem (`context.extra`) |
155
+ | `player` | `after_create` | Inicializar campos customizados ao criar jogador |
156
+ | `player` | `before_update` | Normalizar campos antes de salvar atualização |
157
+ | `custom__c` | `before_create` | Normalizar/enriquecer documento customizado |
158
+ | `custom__c` | `after_create` | Validar e rejeitar se inválido (delete + message) |
159
+ | `custom__c` | `after_bulk` | Processar import em lote (entity é uma List) |
160
+
161
+ ### 2. Verificar se já existe
162
+
163
+ ```
164
+ funifier_list type=trigger search=<nome>
165
+ ```
113
166
 
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.
167
+ Se existir e estiver correto, parar não recriar.
116
168
 
117
- ### 6. Validate
169
+ ### 3. Ler documentação obrigatória
170
+
171
+ Leia os três arquivos listados acima antes de escrever qualquer código.
172
+ Use também `datasource-funifier-docs/knowledge/guides/trigger-examples.md` para encontrar o padrão mais próximo do requisito.
173
+
174
+ ### 4. Escrever o script Groovy
175
+
176
+ - Use os exemplos de `trigger-examples.md` como base
177
+ - Prefira funções auxiliares para lógica reutilizável
178
+ - Use `println` para debug (aparece nos logs)
179
+ - Sempre verifique nulos antes de acessar campos
180
+
181
+ ### 5. Montar e salvar o payload
182
+
183
+ O campo `script` deve ser uma string JSON escapada. Exemplo completo:
184
+
185
+ ```json
186
+ {
187
+ "name": "Update Task Status",
188
+ "entity": "action",
189
+ "event": "before_win",
190
+ "active": true,
191
+ "script": "void trigger(event, entity, player, database) {\n String taskId = entity.attributes.get(\"taskId\");\n if (taskId != null) {\n HashMap<String, Object> task = manager.getJongoConnection().getCollection(\"task__c\").findOne(\"{_id:#}\", taskId).as(HashMap.class);\n if (task != null) {\n task.put(\"status\", \"done\");\n manager.getJongoConnection().getCollection(\"task__c\").save(task);\n }\n }\n}\n"
192
+ }
193
+ ```
194
+
195
+ Regras de escape no campo `script`:
196
+ - Quebra de linha → `\n`
197
+ - Aspas duplas → `\"`
198
+ - Nunca cole código multilinha cru no JSON
199
+
200
+ ```
201
+ funifier_save type=trigger payload=<json>
202
+ ```
203
+
204
+ ### 6. Validar via logs
205
+
206
+ ```
207
+ funifier_logs type=trigger id=<_id>
208
+ ```
118
209
 
119
- Use `funifier_logs` (for triggers/schedulers) or `funifier_get` to confirm
120
- the resource was saved correctly and executed without errors.
210
+ Confirme que não erros de compilação ou execução. Se houver, leia o stack trace e corrija o script.
121
211
 
122
212
  ## MCP
123
213
 
@@ -125,3 +215,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
125
215
  - Use MCP for live server data
126
216
  - Use docs for correct patterns and syntax
127
217
  - Never learn patterns from existing live resources — docs are authoritative
218
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -84,3 +84,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
84
84
  - Use MCP for live server data
85
85
  - Use docs for correct patterns and syntax
86
86
  - Never learn patterns from existing live resources — docs are authoritative
87
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -46,6 +46,7 @@ If search returns insufficient results, read directly:
46
46
  - `datasource-funifier-docs/knowledge/guides/java-libraries.md`
47
47
  - `datasource-funifier-docs/knowledge/modules/trigger.md`
48
48
  - `datasource-funifier-docs/knowledge/guides/triggers-guide.md`
49
+ - `datasource-funifier-docs/knowledge/guides/trigger-examples.md`
49
50
  - `datasource-funifier-docs/knowledge/modules/scheduler.md`
50
51
  - `datasource-funifier-docs/knowledge/guides/aggregates.md`
51
52
  - `datasource-funifier-docs/knowledge/modules/public.md`
@@ -88,3 +89,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
88
89
  - Use MCP for live server data
89
90
  - Use docs for correct patterns and syntax
90
91
  - Never learn patterns from existing live resources — docs are authoritative
92
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -83,3 +83,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
83
83
  - Use MCP for live server data
84
84
  - Use docs for correct patterns and syntax
85
85
  - Never learn patterns from existing live resources — docs are authoritative
86
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -87,3 +87,4 @@ If Funifier MCP tools are available (`funifier_list`, `funifier_save`, `funifier
87
87
  - Use MCP for live server data
88
88
  - Use docs for correct patterns and syntax
89
89
  - Never learn patterns from existing live resources — docs are authoritative
90
+ - **For any new Funifier task, check `/funifier-index` first** — there may be a skill with the correct enums, examples, and workflow already defined
@@ -1,10 +1,18 @@
1
1
  ---
2
2
  name: funifier-index
3
- description: Entry point for all Funifier skills — routes to the right skill for any intent
3
+ description: >
4
+ REQUIRED before any funifier_* MCP tool call — check this index first to find the matching skill.
5
+ Routes to the right skill for creating actions, challenges, points, leaderboards, triggers, schedulers, aggregates, quizzes, virtual goods, custom pages, and frontend implementation.
4
6
  ---
5
7
 
6
8
  # Funifier Index
7
9
 
10
+ ## ⚠ Rule
11
+
12
+ **Before using any `funifier_*` MCP tool, check this list first.**
13
+ If a skill matches the task, invoke it — skills contain the correct field values, enum tables, and examples that prevent common errors.
14
+ Only proceed directly with MCP tools when no skill matches.
15
+
8
16
  ## Usage
9
17
 
10
18
  1. Identify what the user wants to do