@mapomodule/mcp 0.0.0-stage → 1.0.0-beta.2

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 (166) hide show
  1. package/README.md +509 -2
  2. package/bin/mapo-mcp.mjs +3 -0
  3. package/dist/build.d.mts +18 -0
  4. package/dist/build.d.ts +18 -0
  5. package/dist/build.mjs +351 -0
  6. package/dist/cli.d.mts +7 -0
  7. package/dist/cli.d.ts +7 -0
  8. package/dist/cli.mjs +274 -0
  9. package/dist/index.d.mts +68 -0
  10. package/dist/index.d.ts +68 -0
  11. package/dist/index.mjs +1 -0
  12. package/dist/knowledge/api.json +1 -0
  13. package/dist/knowledge/docs.json +1 -0
  14. package/dist/module.d.mts +16 -0
  15. package/dist/module.d.ts +16 -0
  16. package/dist/module.json +9 -0
  17. package/dist/module.mjs +124 -0
  18. package/dist/runtime/core/doctor.d.ts +0 -0
  19. package/dist/runtime/core/doctor.js +128 -0
  20. package/dist/runtime/core/endpoint.d.ts +0 -0
  21. package/dist/runtime/core/endpoint.js +8 -0
  22. package/dist/runtime/core/indexer.d.ts +0 -0
  23. package/dist/runtime/core/indexer.js +194 -0
  24. package/dist/runtime/core/instructions.d.ts +0 -0
  25. package/dist/runtime/core/instructions.js +10 -0
  26. package/dist/runtime/core/knowledge.d.ts +0 -0
  27. package/dist/runtime/core/knowledge.js +76 -0
  28. package/dist/runtime/core/openapi.d.ts +0 -0
  29. package/dist/runtime/core/openapi.js +229 -0
  30. package/dist/runtime/core/overview.d.ts +0 -0
  31. package/dist/runtime/core/overview.js +15 -0
  32. package/dist/runtime/core/prompts.d.ts +0 -0
  33. package/dist/runtime/core/prompts.js +108 -0
  34. package/dist/runtime/core/recipes.d.ts +0 -0
  35. package/dist/runtime/core/recipes.js +496 -0
  36. package/dist/runtime/core/resources.d.ts +0 -0
  37. package/dist/runtime/core/resources.js +92 -0
  38. package/dist/runtime/core/scaffold/fields.d.ts +0 -0
  39. package/dist/runtime/core/scaffold/fields.js +64 -0
  40. package/dist/runtime/core/scaffold/index.d.ts +0 -0
  41. package/dist/runtime/core/scaffold/index.js +74 -0
  42. package/dist/runtime/core/scaffold/templates.d.ts +0 -0
  43. package/dist/runtime/core/scaffold/templates.js +349 -0
  44. package/dist/runtime/core/schema-source.d.ts +0 -0
  45. package/dist/runtime/core/schema-source.js +70 -0
  46. package/dist/runtime/core/search.d.ts +0 -0
  47. package/dist/runtime/core/search.js +173 -0
  48. package/dist/runtime/core/tokenize.d.ts +0 -0
  49. package/dist/runtime/core/tokenize.js +96 -0
  50. package/dist/runtime/core/tool-spec.d.ts +0 -0
  51. package/dist/runtime/core/tool-spec.js +3 -0
  52. package/dist/runtime/core/tools/api.d.ts +0 -0
  53. package/dist/runtime/core/tools/api.js +192 -0
  54. package/dist/runtime/core/tools/app.d.ts +0 -0
  55. package/dist/runtime/core/tools/app.js +141 -0
  56. package/dist/runtime/core/tools/backend.d.ts +0 -0
  57. package/dist/runtime/core/tools/backend.js +143 -0
  58. package/dist/runtime/core/tools/docs.d.ts +0 -0
  59. package/dist/runtime/core/tools/docs.js +154 -0
  60. package/dist/runtime/core/tools/scaffold.d.ts +0 -0
  61. package/dist/runtime/core/tools/scaffold.js +127 -0
  62. package/dist/runtime/core/types.d.ts +0 -0
  63. package/dist/runtime/core/types.js +0 -0
  64. package/dist/runtime/core/write.d.ts +0 -0
  65. package/dist/runtime/core/write.js +53 -0
  66. package/dist/runtime/mcp/handlers/mapo/index.js +7 -0
  67. package/dist/runtime/mcp/handlers/mapo/prompts/crud-page.js +3 -0
  68. package/dist/runtime/mcp/handlers/mapo/prompts/custom-field.js +3 -0
  69. package/dist/runtime/mcp/handlers/mapo/prompts/debug-form.js +3 -0
  70. package/dist/runtime/mcp/handlers/mapo/prompts/migrate-v1.js +3 -0
  71. package/dist/runtime/mcp/handlers/mapo/prompts/theme.js +3 -0
  72. package/dist/runtime/mcp/handlers/mapo/resources/app-manifest.js +19 -0
  73. package/dist/runtime/mcp/handlers/mapo/resources/docs.js +34 -0
  74. package/dist/runtime/mcp/handlers/mapo/resources/fields.js +34 -0
  75. package/dist/runtime/mcp/handlers/mapo/resources/knowledge-index.js +22 -0
  76. package/dist/runtime/mcp/handlers/mapo/resources/overview.js +20 -0
  77. package/dist/runtime/mcp/handlers/mapo/tools/backend-schema.js +3 -0
  78. package/dist/runtime/mcp/handlers/mapo/tools/component-api.js +3 -0
  79. package/dist/runtime/mcp/handlers/mapo/tools/composable-api.js +3 -0
  80. package/dist/runtime/mcp/handlers/mapo/tools/doctor.js +3 -0
  81. package/dist/runtime/mcp/handlers/mapo/tools/get-doc.js +3 -0
  82. package/dist/runtime/mcp/handlers/mapo/tools/inspect-app.js +3 -0
  83. package/dist/runtime/mcp/handlers/mapo/tools/list-field-types.js +3 -0
  84. package/dist/runtime/mcp/handlers/mapo/tools/list-recipes.js +3 -0
  85. package/dist/runtime/mcp/handlers/mapo/tools/scaffold.js +3 -0
  86. package/dist/runtime/mcp/handlers/mapo/tools/search-docs.js +3 -0
  87. package/dist/runtime/nitro/context.d.ts +0 -0
  88. package/dist/runtime/nitro/context.js +21 -0
  89. package/dist/runtime/nitro/to-mcp-prompt.d.ts +0 -0
  90. package/dist/runtime/nitro/to-mcp-prompt.js +23 -0
  91. package/dist/runtime/nitro/to-mcp-tool.d.ts +0 -0
  92. package/dist/runtime/nitro/to-mcp-tool.js +28 -0
  93. package/dist/runtime/types/virtual-modules.d.ts +6 -0
  94. package/dist/types.d.mts +9 -0
  95. package/package.json +73 -4
  96. package/src/__tests__/cli.test.ts +137 -0
  97. package/src/__tests__/doctor.test.ts +145 -0
  98. package/src/__tests__/endpoint.test.ts +31 -0
  99. package/src/__tests__/fixtures/drf-schema.json +142 -0
  100. package/src/__tests__/fixtures.ts +198 -0
  101. package/src/__tests__/indexer.test.ts +114 -0
  102. package/src/__tests__/knowledge.test.ts +225 -0
  103. package/src/__tests__/openapi.test.ts +256 -0
  104. package/src/__tests__/overview.test.ts +105 -0
  105. package/src/__tests__/recipes.test.ts +55 -0
  106. package/src/__tests__/resources.test.ts +69 -0
  107. package/src/__tests__/scaffold.test.ts +153 -0
  108. package/src/__tests__/search.test.ts +105 -0
  109. package/src/__tests__/tools.test.ts +226 -0
  110. package/src/__tests__/write.test.ts +134 -0
  111. package/src/build/extract-components.ts +135 -0
  112. package/src/build/extract-composables.ts +125 -0
  113. package/src/build/extract-fields.ts +250 -0
  114. package/src/build/index.ts +103 -0
  115. package/src/cli.ts +375 -0
  116. package/src/index.ts +65 -0
  117. package/src/module.ts +213 -0
  118. package/src/runtime/core/doctor.ts +204 -0
  119. package/src/runtime/core/endpoint.ts +27 -0
  120. package/src/runtime/core/indexer.ts +285 -0
  121. package/src/runtime/core/instructions.ts +18 -0
  122. package/src/runtime/core/knowledge.ts +121 -0
  123. package/src/runtime/core/openapi.ts +417 -0
  124. package/src/runtime/core/overview.ts +44 -0
  125. package/src/runtime/core/prompts.ts +150 -0
  126. package/src/runtime/core/recipes.ts +574 -0
  127. package/src/runtime/core/resources.ts +150 -0
  128. package/src/runtime/core/scaffold/fields.ts +127 -0
  129. package/src/runtime/core/scaffold/index.ts +120 -0
  130. package/src/runtime/core/scaffold/templates.ts +394 -0
  131. package/src/runtime/core/schema-source.ts +123 -0
  132. package/src/runtime/core/search.ts +282 -0
  133. package/src/runtime/core/tokenize.ts +146 -0
  134. package/src/runtime/core/tool-spec.ts +74 -0
  135. package/src/runtime/core/tools/api.ts +300 -0
  136. package/src/runtime/core/tools/app.ts +201 -0
  137. package/src/runtime/core/tools/backend.ts +197 -0
  138. package/src/runtime/core/tools/docs.ts +218 -0
  139. package/src/runtime/core/tools/scaffold.ts +176 -0
  140. package/src/runtime/core/types.ts +133 -0
  141. package/src/runtime/core/write.ts +119 -0
  142. package/src/runtime/mcp/handlers/mapo/index.ts +16 -0
  143. package/src/runtime/mcp/handlers/mapo/prompts/crud-page.ts +4 -0
  144. package/src/runtime/mcp/handlers/mapo/prompts/custom-field.ts +4 -0
  145. package/src/runtime/mcp/handlers/mapo/prompts/debug-form.ts +4 -0
  146. package/src/runtime/mcp/handlers/mapo/prompts/migrate-v1.ts +4 -0
  147. package/src/runtime/mcp/handlers/mapo/prompts/theme.ts +4 -0
  148. package/src/runtime/mcp/handlers/mapo/resources/app-manifest.ts +28 -0
  149. package/src/runtime/mcp/handlers/mapo/resources/docs.ts +41 -0
  150. package/src/runtime/mcp/handlers/mapo/resources/fields.ts +37 -0
  151. package/src/runtime/mcp/handlers/mapo/resources/knowledge-index.ts +24 -0
  152. package/src/runtime/mcp/handlers/mapo/resources/overview.ts +22 -0
  153. package/src/runtime/mcp/handlers/mapo/tools/backend-schema.ts +4 -0
  154. package/src/runtime/mcp/handlers/mapo/tools/component-api.ts +4 -0
  155. package/src/runtime/mcp/handlers/mapo/tools/composable-api.ts +4 -0
  156. package/src/runtime/mcp/handlers/mapo/tools/doctor.ts +4 -0
  157. package/src/runtime/mcp/handlers/mapo/tools/get-doc.ts +4 -0
  158. package/src/runtime/mcp/handlers/mapo/tools/inspect-app.ts +4 -0
  159. package/src/runtime/mcp/handlers/mapo/tools/list-field-types.ts +4 -0
  160. package/src/runtime/mcp/handlers/mapo/tools/list-recipes.ts +4 -0
  161. package/src/runtime/mcp/handlers/mapo/tools/scaffold.ts +4 -0
  162. package/src/runtime/mcp/handlers/mapo/tools/search-docs.ts +4 -0
  163. package/src/runtime/nitro/context.ts +41 -0
  164. package/src/runtime/nitro/to-mcp-prompt.ts +30 -0
  165. package/src/runtime/nitro/to-mcp-tool.ts +35 -0
  166. package/src/runtime/types/virtual-modules.d.ts +6 -0
@@ -0,0 +1,496 @@
1
+ import { tokenize } from "./tokenize.js";
2
+ export const RECIPES = [
3
+ {
4
+ id: "concepts",
5
+ task: "Understand how Mapo fits together",
6
+ keywords: [
7
+ "overview",
8
+ "architecture",
9
+ "packages",
10
+ "concepts",
11
+ "mental model",
12
+ "how it works"
13
+ ],
14
+ doc: "guide/concepts.md",
15
+ seeAlso: ["guide/architecture-flows.md", "guide/getting-started.md"],
16
+ summary: "The packages, the backend contract, declarative pages, the form engine and the customization layers."
17
+ },
18
+ {
19
+ id: "first-admin-page",
20
+ task: "Create the first admin page",
21
+ keywords: [
22
+ "scaffold",
23
+ "start",
24
+ "setup",
25
+ "layout",
26
+ "definePageMeta",
27
+ "dashboard",
28
+ "sidebar entry",
29
+ "install"
30
+ ],
31
+ doc: "howto/first-admin-page.md",
32
+ seeAlso: ["guide/getting-started.md"],
33
+ summary: "Page meta, mapo-default layout, auth middleware and sidebar registration."
34
+ },
35
+ {
36
+ id: "crud-list",
37
+ task: "Build a CRUD list page",
38
+ keywords: [
39
+ "MapoList",
40
+ "table",
41
+ "columns",
42
+ "pagination",
43
+ "filters",
44
+ "tabs",
45
+ "bulk",
46
+ "quick edit",
47
+ "search",
48
+ "sorting"
49
+ ],
50
+ doc: "howto/crud-list.md",
51
+ seeAlso: ["uikit/list.md"],
52
+ summary: "MapoList with server-side pagination, filters, tabs, bulk actions and quick edit."
53
+ },
54
+ {
55
+ id: "crud-detail",
56
+ task: "Build a CRUD detail or edit page",
57
+ keywords: [
58
+ "MapoDetail",
59
+ "form",
60
+ "save",
61
+ "delete",
62
+ "translations",
63
+ "sidebar fields",
64
+ "patch"
65
+ ],
66
+ doc: "howto/crud-detail.md",
67
+ seeAlso: ["uikit/detail.md", "uikit/form/index.md"],
68
+ summary: "MapoDetail wired to useCrud, with body/sidebar field descriptors and save flow."
69
+ },
70
+ {
71
+ id: "standalone-form",
72
+ task: "Use the form engine outside a detail page",
73
+ keywords: [
74
+ "MapoForm",
75
+ "useMapoForm",
76
+ "standalone",
77
+ "modal",
78
+ "wizard",
79
+ "custom submit"
80
+ ],
81
+ doc: "howto/form-standalone.md",
82
+ seeAlso: ["uikit/form/composable.md"],
83
+ summary: "MapoForm / useMapoForm driven by your own state and submit handler."
84
+ },
85
+ {
86
+ id: "field-types",
87
+ task: "Pick a form field type",
88
+ keywords: [
89
+ "descriptor",
90
+ "field type",
91
+ "text",
92
+ "select",
93
+ "editor",
94
+ "repeater",
95
+ "seo",
96
+ "map",
97
+ "fks",
98
+ "m2m",
99
+ "datetime"
100
+ ],
101
+ doc: "uikit/form/add-fields.md",
102
+ seeAlso: ["uikit/form/index.md"],
103
+ summary: "Every built-in field type, the component behind it and its attrs."
104
+ },
105
+ {
106
+ id: "custom-field",
107
+ task: "Create and register a custom field type",
108
+ keywords: [
109
+ "defineFormField",
110
+ "registry",
111
+ "custom component",
112
+ "mapping",
113
+ "own field",
114
+ "extend fields"
115
+ ],
116
+ doc: "uikit/form/registry.md",
117
+ heading: "Add types globally \u2014 `defineFormField()` (recommended)",
118
+ seeAlso: ["uikit/form/custom-fields.md", "uikit/form/reusable-fields.md"],
119
+ summary: "Register a component in the field registry, then use it through descriptor.type."
120
+ },
121
+ {
122
+ id: "form-validation",
123
+ task: "Validate form fields",
124
+ keywords: [
125
+ "validate",
126
+ "validateAsync",
127
+ "required",
128
+ "errors",
129
+ "rules",
130
+ "async validation"
131
+ ],
132
+ doc: "uikit/form/validation.md",
133
+ summary: "Sync and debounced async validation on descriptors, plus error display."
134
+ },
135
+ {
136
+ id: "form-i18n",
137
+ task: "Make form fields translatable",
138
+ keywords: [
139
+ "translatable",
140
+ "synci18n",
141
+ "translations",
142
+ "languages",
143
+ "lang switch"
144
+ ],
145
+ doc: "uikit/form/i18n.md",
146
+ seeAlso: ["howto/i18n.md"],
147
+ summary: "translatable descriptors, per-language models and the detail language switcher."
148
+ },
149
+ {
150
+ id: "media-manager",
151
+ task: "Use the media manager and media fields",
152
+ keywords: [
153
+ "upload",
154
+ "image",
155
+ "gallery",
156
+ "folders",
157
+ "MapoMediaManager",
158
+ "enhanced-media",
159
+ "MapoDropArea"
160
+ ],
161
+ doc: "howto/media-manager.md",
162
+ seeAlso: ["uikit/media.md"],
163
+ summary: "Media endpoints configuration, media fields and the picker dialog."
164
+ },
165
+ {
166
+ id: "menu-manager",
167
+ task: "Build a navigation menu editor",
168
+ keywords: [
169
+ "MapoMenuManager",
170
+ "tree",
171
+ "drag and drop",
172
+ "nodes",
173
+ "navigation"
174
+ ],
175
+ doc: "howto/menu-manager.md",
176
+ seeAlso: ["uikit/menu-manager.md"],
177
+ summary: "Tree editor for menus with drag-and-drop nodes and per-node forms."
178
+ },
179
+ {
180
+ id: "i18n",
181
+ task: "Translate the admin UI",
182
+ keywords: [
183
+ "locale",
184
+ "language",
185
+ "vue-i18n",
186
+ "catalog",
187
+ "useMapoT",
188
+ "messages"
189
+ ],
190
+ doc: "howto/i18n.md",
191
+ seeAlso: ["modules/i18n.md"],
192
+ summary: "Locale setup, overriding Mapo strings and adding your own catalogs."
193
+ },
194
+ {
195
+ id: "auth-permissions",
196
+ task: "Protect routes with auth and permissions",
197
+ keywords: [
198
+ "login",
199
+ "middleware",
200
+ "roles",
201
+ "useCanAccessRoute",
202
+ "session",
203
+ "logout",
204
+ "django permissions"
205
+ ],
206
+ doc: "howto/auth-permissions.md",
207
+ seeAlso: ["uikit/login.md"],
208
+ summary: "Auth middleware, permission route meta and the Django-backed permission model."
209
+ },
210
+ {
211
+ id: "feedback",
212
+ task: "Show toasts and confirm dialogs",
213
+ keywords: [
214
+ "snackbar",
215
+ "toast",
216
+ "notification",
217
+ "confirm",
218
+ "dialog",
219
+ "alert"
220
+ ],
221
+ doc: "howto/feedback.md",
222
+ seeAlso: ["uikit/feedback.md"],
223
+ summary: "Snackbar and confirm stores, plus their root components."
224
+ },
225
+ {
226
+ id: "theming",
227
+ task: "Theme and restyle the admin",
228
+ keywords: [
229
+ "css variables",
230
+ "tailwind",
231
+ "nuxt ui",
232
+ "colors",
233
+ "dark mode",
234
+ "tokens",
235
+ "design",
236
+ "primary color"
237
+ ],
238
+ doc: "howto/theming.md",
239
+ seeAlso: ["uikit/theming.md"],
240
+ summary: "CSS tokens, Nuxt UI defaults and where to put the override stylesheet."
241
+ },
242
+ {
243
+ id: "override-components",
244
+ task: "Replace or extend a Mapo component",
245
+ keywords: [
246
+ "MapoOverride",
247
+ "slots",
248
+ "swap component",
249
+ "customize layout",
250
+ "topbar",
251
+ "sidebar"
252
+ ],
253
+ doc: "uikit/mapoverride.md",
254
+ seeAlso: ["uikit/layout.md"],
255
+ summary: "The MapoOverride system and the layout slots that avoid full replacements."
256
+ },
257
+ {
258
+ id: "backend-integration",
259
+ task: "Connect a custom or Django backend",
260
+ keywords: [
261
+ "api",
262
+ "endpoints",
263
+ "csrf",
264
+ "camomilla",
265
+ "drf",
266
+ "proxy",
267
+ "useCrud",
268
+ "rest",
269
+ "fastapi",
270
+ "laravel",
271
+ "jwt"
272
+ ],
273
+ doc: "howto/backend-integration.md",
274
+ seeAlso: ["modules/camomilla.md", "modules/api.md"],
275
+ summary: "Endpoint conventions, CSRF/session handling and the camomilla integration."
276
+ },
277
+ {
278
+ id: "migration",
279
+ task: "Migrate a v1 project to v2",
280
+ keywords: ["v1", "upgrade", "legacy", "vuex", "axios", "breaking changes"],
281
+ doc: "migration/v1-to-v2.md",
282
+ summary: "What changed between Mapo v1 and v2 and how to port each piece."
283
+ },
284
+ {
285
+ id: "conditional-fields",
286
+ task: "Show or hide form fields based on other values",
287
+ keywords: [
288
+ "visible",
289
+ "conditional",
290
+ "whenAny",
291
+ "matchesField",
292
+ "depends on",
293
+ "progressive disclosure"
294
+ ],
295
+ doc: "uikit/form/progressive-disclosure.md",
296
+ seeAlso: ["howto/form-advanced.md"],
297
+ summary: "visible and show predicates built with the when/matchesField matcher helpers."
298
+ },
299
+ {
300
+ id: "form-draft",
301
+ task: "Autosave form drafts",
302
+ keywords: ["draft", "autosave", "useFormDraft", "restore", "unsaved"],
303
+ doc: "uikit/form/draft.md",
304
+ seeAlso: ["howto/crud-detail.md"],
305
+ summary: "useFormDraft keeps unsaved edits in localStorage and offers to restore them on the next visit."
306
+ },
307
+ {
308
+ id: "schema-to-form",
309
+ task: "Generate form fields from a JSON Schema",
310
+ keywords: [
311
+ "json schema",
312
+ "useFormFromSchema",
313
+ "openapi",
314
+ "drf-spectacular",
315
+ "pydantic",
316
+ "serializer"
317
+ ],
318
+ doc: "uikit/form/schema-to-form.md",
319
+ seeAlso: ["howto/form-advanced.md"],
320
+ summary: "useFormFromSchema turns a JSON Schema (DRF, Pydantic) into field descriptors you can extend."
321
+ },
322
+ {
323
+ id: "form-slots",
324
+ task: "Customize how a form field renders with slots",
325
+ keywords: [
326
+ "field slot",
327
+ "hint",
328
+ "above",
329
+ "below",
330
+ "replace a field",
331
+ "group slot"
332
+ ],
333
+ doc: "uikit/form/slots.md",
334
+ summary: "Per-field, per-group and global slots that wrap, extend or replace how fields render."
335
+ },
336
+ {
337
+ id: "focus-mode",
338
+ task: "Focus mode for repeater items and long fields",
339
+ keywords: [
340
+ "focus mode",
341
+ "useFocusMode",
342
+ "fullscreen",
343
+ "field expand",
344
+ "MapoFocusPortal",
345
+ "breadcrumb"
346
+ ],
347
+ doc: "uikit/form/focus-mode.md",
348
+ seeAlso: ["uikit/form/field-expand.md"],
349
+ summary: "Open a repeater item in a fullscreen view, or expand a single field in place."
350
+ },
351
+ {
352
+ id: "sidebar-navigation",
353
+ task: "Build the sidebar navigation",
354
+ keywords: [
355
+ "sidebar",
356
+ "nested menu",
357
+ "parent",
358
+ "icon",
359
+ "label",
360
+ "sidebarFooter",
361
+ "route meta"
362
+ ],
363
+ doc: "uikit/sidebar.md",
364
+ seeAlso: ["howto/first-admin-page.md"],
365
+ summary: "Route metadata (label, icon, parent, sidebarFooter) builds the sidebar tree, with no menu config."
366
+ },
367
+ {
368
+ id: "login-page",
369
+ task: "Customize the login page",
370
+ keywords: [
371
+ "MapoLogin",
372
+ "sign in",
373
+ "login form",
374
+ "login redirect",
375
+ "branding"
376
+ ],
377
+ doc: "uikit/login.md",
378
+ seeAlso: ["howto/auth-permissions.md"],
379
+ summary: "The built-in /login page: its slots, the redirect after login and error handling."
380
+ },
381
+ {
382
+ id: "imports",
383
+ task: "Know what to import and from where",
384
+ keywords: [
385
+ "import",
386
+ "auto-import",
387
+ "import type",
388
+ "mapomodule/types",
389
+ "TS2307",
390
+ "cannot find module"
391
+ ],
392
+ doc: "guide/imports.md",
393
+ seeAlso: ["guide/known-limitations.md"],
394
+ summary: "Composables and components are auto-imported, types come from mapomodule/types, utils are imported explicitly."
395
+ },
396
+ {
397
+ id: "troubleshooting",
398
+ task: "Troubleshoot compatibility and version problems",
399
+ keywords: [
400
+ "module order",
401
+ "nuxt ui first",
402
+ "error",
403
+ "tested versions",
404
+ "peer dependencies",
405
+ "dedupe",
406
+ "duplicate vue"
407
+ ],
408
+ doc: "guide/compatibility.md",
409
+ seeAlso: ["guide/known-limitations.md"],
410
+ summary: "Tested versions, what to declare in the app, module order and the common problems."
411
+ },
412
+ {
413
+ id: "utils",
414
+ task: "Merge, diff and format with the utility helpers",
415
+ keywords: [
416
+ "deepMerge",
417
+ "objectDiff",
418
+ "slugify",
419
+ "formatDate",
420
+ "humanFileSize",
421
+ "normalizeEndpoint",
422
+ "debounce"
423
+ ],
424
+ doc: "modules/utils.md",
425
+ seeAlso: ["modules/api.md"],
426
+ summary: "Typed helpers from @mapomodule/utils: merging, diffing, formatting, slugs and endpoints."
427
+ },
428
+ {
429
+ id: "camomilla",
430
+ task: "Use the Camomilla CMS integration",
431
+ keywords: [
432
+ "camomilla",
433
+ "path rewrite",
434
+ "session cookie",
435
+ "django cms",
436
+ "media adapter"
437
+ ],
438
+ doc: "modules/camomilla.md",
439
+ seeAlso: ["howto/backend-integration.md"],
440
+ summary: "The Camomilla integration: proxy options, path rewriting, the media adapter and session cookies."
441
+ },
442
+ {
443
+ id: "ai-assistant",
444
+ task: "Set up an AI coding assistant",
445
+ keywords: ["mcp", "claude", "copilot", "cursor", "agent", "mapo-mcp"],
446
+ doc: "howto/ai-assistant.md",
447
+ seeAlso: ["modules/mcp.md"],
448
+ summary: "Connect Claude Code, Copilot or Cursor to the Mapo MCP server over stdio or HTTP."
449
+ },
450
+ {
451
+ id: "form-devtools",
452
+ task: "Inspect forms in Nuxt DevTools",
453
+ keywords: [
454
+ "devtools",
455
+ "debug form",
456
+ "registry warning",
457
+ "inspect",
458
+ "_mapo"
459
+ ],
460
+ doc: "uikit/form/devtools.md",
461
+ summary: "The Mapo Forms tab: the module config and the live field registry your forms read."
462
+ }
463
+ ];
464
+ const TASK_WEIGHT = 1.5;
465
+ const KEYWORD_WEIGHT = 1;
466
+ const MATCH_THRESHOLD = 3;
467
+ const RECIPE_TERMS = RECIPES.map((recipe) => ({
468
+ recipe,
469
+ task: new Set(tokenize(recipe.task)),
470
+ keywords: new Set(tokenize(recipe.keywords.join(" ")))
471
+ }));
472
+ const DOCUMENT_FREQUENCY = /* @__PURE__ */ new Map();
473
+ for (const entry of RECIPE_TERMS) {
474
+ for (const term of /* @__PURE__ */ new Set([...entry.task, ...entry.keywords])) {
475
+ DOCUMENT_FREQUENCY.set(term, (DOCUMENT_FREQUENCY.get(term) ?? 0) + 1);
476
+ }
477
+ }
478
+ function idf(term) {
479
+ const frequency = DOCUMENT_FREQUENCY.get(term);
480
+ return frequency ? Math.log(1 + RECIPES.length / frequency) : 0;
481
+ }
482
+ export function matchRecipes(query, limit = 2) {
483
+ const queryTerms = new Set(tokenize(query));
484
+ if (!queryTerms.size) return [];
485
+ const matches = [];
486
+ for (const { recipe, task, keywords } of RECIPE_TERMS) {
487
+ let score = 0;
488
+ for (const term of queryTerms) {
489
+ if (task.has(term)) score += TASK_WEIGHT * idf(term);
490
+ else if (keywords.has(term)) score += KEYWORD_WEIGHT * idf(term);
491
+ }
492
+ if (score >= MATCH_THRESHOLD)
493
+ matches.push({ ...recipe, score: Number(score.toFixed(2)) });
494
+ }
495
+ return matches.sort((a, b) => b.score - a.score).slice(0, limit);
496
+ }
File without changes
@@ -0,0 +1,92 @@
1
+ import { RECIPES } from "./recipes.js";
2
+ import { getDoc, listDocs } from "./search.js";
3
+ export const DOCS_URI_PREFIX = "mapo://docs/";
4
+ export const FIELD_URI_PREFIX = "mapo://fields/";
5
+ export const INDEX_URI = "mapo://knowledge/index";
6
+ export const MANIFEST_URI = "mapo://app/manifest";
7
+ export const OVERVIEW_URI = "mapo://overview";
8
+ export const OVERVIEW_DOC = "guide/concepts.md";
9
+ export function renderKnowledgeIndex(knowledge, api) {
10
+ const pages = listDocs(knowledge).map(
11
+ (doc) => `- \`${doc.path}\` \u2014 ${doc.title} (${doc.headings.length} sections)`
12
+ ).join("\n");
13
+ const recipes = RECIPES.map(
14
+ (recipe) => `- ${recipe.task} \u2192 \`${recipe.doc}\``
15
+ ).join("\n");
16
+ const components = api.components.map((component) => component.name).join(", ");
17
+ const fields = api.fieldTypes.map((field) => field.type).join(", ");
18
+ const composables = api.composables.map((composable) => composable.name).join(", ");
19
+ return [
20
+ "# Mapo knowledge base",
21
+ "",
22
+ `Generated ${knowledge.generatedAt}.`,
23
+ "",
24
+ `Start with the overview: the \`${OVERVIEW_URI}\` resource (\`${OVERVIEW_DOC}\`).`,
25
+ "",
26
+ "## Recipes",
27
+ recipes,
28
+ "",
29
+ "## Documentation pages",
30
+ pages,
31
+ "",
32
+ "## Components",
33
+ components,
34
+ "",
35
+ "## Field types",
36
+ fields,
37
+ "",
38
+ "## Auto-imported composables",
39
+ composables
40
+ ].join("\n");
41
+ }
42
+ export function renderDocResource(knowledge, path) {
43
+ const doc = getDoc(knowledge, path, { maxChars: 1e5 });
44
+ if (!doc) return null;
45
+ return `# ${doc.title}
46
+
47
+ source: \`${doc.path}\`
48
+
49
+ ${doc.content}`;
50
+ }
51
+ export function renderFieldResource(api, type) {
52
+ const field = api.fieldTypes.find((entry) => entry.type === type);
53
+ if (!field) return null;
54
+ const attrs = field.attrs.length ? field.attrs.map(
55
+ (attr) => `- \`${attr.name}\`${attr.type ? `: ${attr.type}` : ""}${attr.required ? " (required)" : ""}${attr.description ? ` \u2014 ${attr.description}` : ""}`
56
+ ).join("\n") : "_none_";
57
+ const common = api.fieldCommon.map((member) => `\`${member.name}\``).join(", ");
58
+ return [
59
+ `# Field type \`${field.type}\``,
60
+ "",
61
+ field.description ?? "",
62
+ "",
63
+ `- component: ${field.component ?? "(unmapped)"}`,
64
+ `- descriptor: ${field.descriptor ?? "(none)"}`,
65
+ field.defaultAttrs ? `- registry default attrs: \`${JSON.stringify(field.defaultAttrs)}\`` : "",
66
+ "",
67
+ "## attrs",
68
+ attrs,
69
+ "",
70
+ "## Shared descriptor properties",
71
+ common,
72
+ "",
73
+ field.docs.length ? `## Docs
74
+ ${field.docs.map((doc) => `- \`${doc}\``).join("\n")}` : ""
75
+ ].filter(Boolean).join("\n");
76
+ }
77
+ export function docResourceList(knowledge) {
78
+ return listDocs(knowledge).map((doc) => ({
79
+ uri: `${DOCS_URI_PREFIX}${doc.path}`,
80
+ name: doc.title,
81
+ description: `${doc.section} \xB7 ${doc.headings.slice(0, 5).join(", ")}`,
82
+ mimeType: "text/markdown"
83
+ }));
84
+ }
85
+ export function fieldResourceList(api) {
86
+ return api.fieldTypes.map((field) => ({
87
+ uri: `${FIELD_URI_PREFIX}${field.type}`,
88
+ name: `Field type: ${field.type}`,
89
+ description: field.description ?? `Rendered by ${field.component ?? "a custom component"}`,
90
+ mimeType: "text/markdown"
91
+ }));
92
+ }
File without changes
@@ -0,0 +1,64 @@
1
+ export class UnknownFieldTypeError extends Error {
2
+ constructor(type, available) {
3
+ super(
4
+ `Unknown field type "${type}". Registered types: ${available.join(", ")}. Custom types are added with defineFormField() \u2014 see uikit/form/registry.md.`
5
+ );
6
+ this.type = type;
7
+ this.available = available;
8
+ this.name = "UnknownFieldTypeError";
9
+ }
10
+ }
11
+ export function humanise(key) {
12
+ return key.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().toLowerCase().replace(/^./, (char) => char.toUpperCase());
13
+ }
14
+ export function parseFields(specs, api) {
15
+ const known = api ? new Set(api.fieldTypes.map((field) => field.type)) : null;
16
+ return specs.map((spec) => {
17
+ const [key = "", type = "text", ...rest] = spec.split(":");
18
+ if (!key.trim()) throw new Error(`Empty field key in "${spec}".`);
19
+ if (known && !known.has(type)) {
20
+ throw new UnknownFieldTypeError(type, [...known].sort());
21
+ }
22
+ return {
23
+ key: key.trim(),
24
+ type: type.trim(),
25
+ label: rest.join(":").trim() || humanise(key.trim())
26
+ };
27
+ });
28
+ }
29
+ function requiredAttrs(type, api) {
30
+ const field = api?.fieldTypes.find((entry) => entry.type === type);
31
+ return (field?.attrs ?? []).filter((attr) => attr.required).map((attr) => attr.name);
32
+ }
33
+ export function renderDescriptors(fields, api, indent = " ") {
34
+ return fields.map((field) => {
35
+ const attrs = requiredAttrs(field.type, api);
36
+ const attrsLine = attrs.length ? `
37
+ ${indent} attrs: { ${attrs.map((name) => `${name}: undefined /* TODO */`).join(", ")} },` : "";
38
+ return `${indent}{
39
+ ${indent} key: "${field.key}",
40
+ ${indent} type: "${field.type}",
41
+ ${indent} label: "${field.label}",${attrsLine}
42
+ ${indent}},`;
43
+ }).join("\n");
44
+ }
45
+ export function renderModel(fields) {
46
+ const tsType = (type) => {
47
+ if (["number", "slider"].includes(type)) return "number";
48
+ if (["boolean", "switch"].includes(type)) return "boolean";
49
+ if ([
50
+ "fks",
51
+ "m2m",
52
+ "media",
53
+ "media-m2m",
54
+ "enhanced-media",
55
+ "repeater",
56
+ "seo",
57
+ "map"
58
+ ].includes(type)) {
59
+ return "unknown";
60
+ }
61
+ return "string";
62
+ };
63
+ return fields.map((field) => ` ${field.key}: ${tsType(field.type)};`).join("\n");
64
+ }
File without changes