fimo 0.9.0-experimental.1 → 0.9.0

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 (205) hide show
  1. package/assets/skills/fimo/SKILL.md +17 -54
  2. package/assets/skills/fimo-cli/SKILL.md +15 -15
  3. package/assets/skills/fimo-cli/references/agent-setup.md +36 -53
  4. package/assets/skills/fimo-cli/references/agents.md +4 -4
  5. package/assets/skills/fimo-cli/references/content.md +2 -2
  6. package/assets/skills/fimo-cli/references/deploy.md +1 -1
  7. package/assets/skills/fimo-cli/references/forms.md +1 -1
  8. package/assets/skills/fimo-cli/references/init.md +16 -24
  9. package/assets/skills/fimo-cli/references/project-vars-and-secrets.md +14 -11
  10. package/assets/skills/fimo-cli/references/projects.md +1 -1
  11. package/assets/skills/fimo-cli/references/support.md +11 -9
  12. package/assets/skills/fimo-cli/references/webhooks.md +3 -1
  13. package/assets/skills/fimo-code/SKILL.md +67 -0
  14. package/assets/skills/fimo-migration/SKILL.md +2 -22
  15. package/assets/skills/fimo-migration/references/content.md +0 -24
  16. package/assets/skills/fimo-migration/references/manifest.md +0 -35
  17. package/assets/skills/fimo-migration/references/qa.md +2 -24
  18. package/assets/skills/fimo-migration/references/workflow.md +1 -12
  19. package/assets/skills/fimo-studio/references/visual-editing.md +3 -5
  20. package/assets/skills/fimo-studio/references/webhooks.md +1 -1
  21. package/dist/build/vite/plugins/translations.d.ts +8 -2
  22. package/dist/build/vite/plugins/translations.js +121 -3
  23. package/dist/cli/bundle.json +2 -2
  24. package/dist/cli/index.js +311 -1209
  25. package/dist/runtime/app/FimoProviders.d.ts +11 -1
  26. package/dist/runtime/app/FimoProviders.js +23 -2
  27. package/dist/runtime/content/client/createContentClient.js +2 -1
  28. package/dist/runtime/i18n/FimoLocaleContext.js +0 -1
  29. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts +3 -5
  30. package/dist/runtime/primitives/lib/useFimoLiveValue.js +4 -11
  31. package/dist/runtime/primitives/translations.d.ts +27 -1
  32. package/dist/runtime/primitives/translations.js +85 -7
  33. package/dist/runtime/shared/fimo-config.server.js +0 -1
  34. package/dist/runtime/shared/fimo-config.types.d.ts +0 -2
  35. package/dist/scripts/extract-translations.js +11 -16
  36. package/dist/scripts/lib/validation-report.d.ts +0 -1
  37. package/dist/scripts/lib/validation-report.js +0 -3
  38. package/dist/scripts/validate-route-metadata.js +0 -11
  39. package/package.json +4 -84
  40. package/release.json +2 -2
  41. package/scripts/postinstall.mjs +11 -65
  42. package/templates/react-router/AGENTS.md +44 -0
  43. package/templates/react-router/CLAUDE.md +5 -0
  44. package/templates/react-router/package.json +1 -1
  45. package/assets/agents-starter/AGENTS.md +0 -66
  46. package/assets/skills/fimo-migration/references/wrap.md +0 -617
  47. package/dist/runtime/astro/index.d.ts +0 -2
  48. package/dist/runtime/astro/index.js +0 -3
  49. package/dist/runtime/astro/server.d.ts +0 -3
  50. package/dist/runtime/astro/server.js +0 -6
  51. package/dist/runtime/next/FimoNextProviders.d.ts +0 -24
  52. package/dist/runtime/next/FimoNextProviders.js +0 -20
  53. package/dist/runtime/next/FimoNextScripts.d.ts +0 -10
  54. package/dist/runtime/next/FimoNextScripts.js +0 -19
  55. package/dist/runtime/next/index.d.ts +0 -14
  56. package/dist/runtime/next/index.js +0 -14
  57. package/dist/runtime/next/server.d.ts +0 -2
  58. package/dist/runtime/next/server.js +0 -4
  59. package/dist/runtime/nuxt/composables.d.ts +0 -9
  60. package/dist/runtime/nuxt/composables.js +0 -57
  61. package/dist/runtime/nuxt/index.d.ts +0 -3
  62. package/dist/runtime/nuxt/index.js +0 -6
  63. package/dist/runtime/nuxt/server.d.ts +0 -3
  64. package/dist/runtime/nuxt/server.js +0 -6
  65. package/dist/runtime/primitives/labels-hook.d.ts +0 -33
  66. package/dist/runtime/primitives/labels-hook.js +0 -41
  67. package/dist/runtime/primitives/labels-store.d.ts +0 -12
  68. package/dist/runtime/primitives/labels-store.js +0 -60
  69. package/dist/runtime/react/FimoSpaProviders.d.ts +0 -36
  70. package/dist/runtime/react/FimoSpaProviders.js +0 -63
  71. package/dist/runtime/react/index.d.ts +0 -33
  72. package/dist/runtime/react/index.js +0 -39
  73. package/dist/runtime/remix/FimoRemixProviders.d.ts +0 -16
  74. package/dist/runtime/remix/FimoRemixProviders.js +0 -12
  75. package/dist/runtime/remix/FimoRemixScripts.d.ts +0 -10
  76. package/dist/runtime/remix/FimoRemixScripts.js +0 -19
  77. package/dist/runtime/remix/index.d.ts +0 -12
  78. package/dist/runtime/remix/index.js +0 -11
  79. package/dist/runtime/remix/server.d.ts +0 -2
  80. package/dist/runtime/remix/server.js +0 -2
  81. package/dist/runtime/shared/display-routes.d.ts +0 -14
  82. package/dist/runtime/shared/display-routes.js +0 -25
  83. package/dist/runtime/shared/i18n-messages.d.ts +0 -29
  84. package/dist/runtime/shared/i18n-messages.js +0 -79
  85. package/dist/runtime/shared/labels-fetch.pure.d.ts +0 -17
  86. package/dist/runtime/shared/labels-fetch.pure.js +0 -71
  87. package/dist/runtime/shared/labels-fetch.server.d.ts +0 -7
  88. package/dist/runtime/shared/labels-fetch.server.js +0 -97
  89. package/dist/runtime/shared/labels-t.pure.d.ts +0 -2
  90. package/dist/runtime/shared/labels-t.pure.js +0 -10
  91. package/dist/runtime/strapi/client.d.ts +0 -30
  92. package/dist/runtime/strapi/client.js +0 -89
  93. package/dist/runtime/strapi/index.d.ts +0 -5
  94. package/dist/runtime/strapi/index.js +0 -6
  95. package/dist/runtime/strapi/reshape.d.ts +0 -46
  96. package/dist/runtime/strapi/reshape.js +0 -114
  97. package/dist/runtime/svelte/index.d.ts +0 -3
  98. package/dist/runtime/svelte/index.js +0 -7
  99. package/dist/runtime/svelte/server.d.ts +0 -3
  100. package/dist/runtime/svelte/server.js +0 -6
  101. package/dist/runtime/vue/index.d.ts +0 -3
  102. package/dist/runtime/vue/index.js +0 -5
  103. package/dist/runtime/vue/server.d.ts +0 -3
  104. package/dist/runtime/vue/server.js +0 -6
  105. package/dist/runtime/wrapped/FimoFileLink.d.ts +0 -17
  106. package/dist/runtime/wrapped/FimoFileLink.js +0 -19
  107. package/dist/runtime/wrapped/FimoMediaImage.d.ts +0 -14
  108. package/dist/runtime/wrapped/FimoMediaImage.js +0 -20
  109. package/dist/runtime/wrapped/FimoMediaVideo.d.ts +0 -14
  110. package/dist/runtime/wrapped/FimoMediaVideo.js +0 -20
  111. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts +0 -23
  112. package/dist/runtime/wrapped/FimoRichTextBlock.js +0 -22
  113. package/dist/runtime/wrapped/FimoText.d.ts +0 -22
  114. package/dist/runtime/wrapped/FimoText.js +0 -20
  115. package/dist/runtime/wrapped/WrappedContentContext.d.ts +0 -28
  116. package/dist/runtime/wrapped/WrappedContentContext.js +0 -30
  117. package/dist/runtime/wrapped/WrappedProviders.d.ts +0 -33
  118. package/dist/runtime/wrapped/WrappedProviders.js +0 -101
  119. package/dist/runtime/wrapped/dom.d.ts +0 -4
  120. package/dist/runtime/wrapped/dom.js +0 -23
  121. package/dist/runtime/wrapped/server.d.ts +0 -77
  122. package/dist/runtime/wrapped/server.js +0 -237
  123. package/dist/scripts/apply-wrap-templates.d.ts +0 -61
  124. package/dist/scripts/apply-wrap-templates.js +0 -132
  125. package/dist/scripts/apply-wrap.d.ts +0 -46
  126. package/dist/scripts/apply-wrap.js +0 -278
  127. package/dist/scripts/cms/discover.d.ts +0 -2
  128. package/dist/scripts/cms/discover.js +0 -17
  129. package/dist/scripts/cms/example-content.d.ts +0 -33
  130. package/dist/scripts/cms/example-content.js +0 -162
  131. package/dist/scripts/cms/strapi/detect.d.ts +0 -2
  132. package/dist/scripts/cms/strapi/detect.js +0 -186
  133. package/dist/scripts/cms/strapi/index.d.ts +0 -3
  134. package/dist/scripts/cms/strapi/index.js +0 -25
  135. package/dist/scripts/cms/strapi/list-source.d.ts +0 -17
  136. package/dist/scripts/cms/strapi/list-source.js +0 -90
  137. package/dist/scripts/cms/strapi/schema-map.d.ts +0 -9
  138. package/dist/scripts/cms/strapi/schema-map.js +0 -277
  139. package/dist/scripts/cms/strapi/shapes.d.ts +0 -23
  140. package/dist/scripts/cms/strapi/shapes.js +0 -38
  141. package/dist/scripts/cms/strapi/touchpoints.d.ts +0 -31
  142. package/dist/scripts/cms/strapi/touchpoints.js +0 -145
  143. package/dist/scripts/cms/strapi/wire-client.d.ts +0 -15
  144. package/dist/scripts/cms/strapi/wire-client.js +0 -107
  145. package/dist/scripts/cms/strapi/wiring.d.ts +0 -17
  146. package/dist/scripts/cms/strapi/wiring.js +0 -46
  147. package/dist/scripts/cms/types.d.ts +0 -145
  148. package/dist/scripts/cms/types.js +0 -11
  149. package/dist/scripts/detect-framework.d.ts +0 -39
  150. package/dist/scripts/detect-framework.js +0 -133
  151. package/dist/scripts/draft-rows.d.ts +0 -19
  152. package/dist/scripts/draft-rows.js +0 -135
  153. package/dist/scripts/draft-schemas.d.ts +0 -27
  154. package/dist/scripts/draft-schemas.js +0 -188
  155. package/dist/scripts/frameworks/astro/routes.d.ts +0 -3
  156. package/dist/scripts/frameworks/astro/routes.js +0 -55
  157. package/dist/scripts/frameworks/astro/template-style.d.ts +0 -7
  158. package/dist/scripts/frameworks/astro/template-style.js +0 -19
  159. package/dist/scripts/frameworks/discover.d.ts +0 -70
  160. package/dist/scripts/frameworks/discover.js +0 -178
  161. package/dist/scripts/frameworks/next/rewire.d.ts +0 -30
  162. package/dist/scripts/frameworks/next/rewire.js +0 -258
  163. package/dist/scripts/frameworks/next/routes.d.ts +0 -17
  164. package/dist/scripts/frameworks/next/routes.js +0 -134
  165. package/dist/scripts/frameworks/next/wiring.d.ts +0 -33
  166. package/dist/scripts/frameworks/next/wiring.js +0 -186
  167. package/dist/scripts/frameworks/nuxt/routes.d.ts +0 -3
  168. package/dist/scripts/frameworks/nuxt/routes.js +0 -54
  169. package/dist/scripts/frameworks/nuxt/template-style.d.ts +0 -9
  170. package/dist/scripts/frameworks/nuxt/template-style.js +0 -27
  171. package/dist/scripts/frameworks/remix/routes.d.ts +0 -3
  172. package/dist/scripts/frameworks/remix/routes.js +0 -50
  173. package/dist/scripts/frameworks/support.d.ts +0 -75
  174. package/dist/scripts/frameworks/support.js +0 -165
  175. package/dist/scripts/frameworks/sveltekit/routes.d.ts +0 -3
  176. package/dist/scripts/frameworks/sveltekit/routes.js +0 -50
  177. package/dist/scripts/frameworks/sveltekit/template-style.d.ts +0 -9
  178. package/dist/scripts/frameworks/sveltekit/template-style.js +0 -54
  179. package/dist/scripts/frameworks/vite/routes.d.ts +0 -15
  180. package/dist/scripts/frameworks/vite/routes.js +0 -93
  181. package/dist/scripts/frameworks/vite/wiring.d.ts +0 -10
  182. package/dist/scripts/frameworks/vite/wiring.js +0 -99
  183. package/dist/scripts/i18n-namespace.d.ts +0 -27
  184. package/dist/scripts/i18n-namespace.js +0 -155
  185. package/dist/scripts/render-parity/capture.d.ts +0 -56
  186. package/dist/scripts/render-parity/capture.js +0 -366
  187. package/dist/scripts/render-parity/compare.d.ts +0 -59
  188. package/dist/scripts/render-parity/compare.js +0 -0
  189. package/dist/scripts/render-parity/normalize-html.d.ts +0 -13
  190. package/dist/scripts/render-parity/normalize-html.js +0 -223
  191. package/dist/scripts/render-parity/types.d.ts +0 -41
  192. package/dist/scripts/render-parity/types.js +0 -1
  193. package/dist/scripts/scan-wrappable.d.ts +0 -196
  194. package/dist/scripts/scan-wrappable.js +0 -1232
  195. /package/assets/skills/{fimo → fimo-code}/assets/react-router-locales/navigation.tsx +0 -0
  196. /package/assets/skills/{fimo → fimo-code}/assets/react-router-locales/routes.ts +0 -0
  197. /package/assets/skills/{fimo → fimo-code}/references/assets.md +0 -0
  198. /package/assets/skills/{fimo → fimo-code}/references/content.md +0 -0
  199. /package/assets/skills/{fimo → fimo-code}/references/design.md +0 -0
  200. /package/assets/skills/{fimo → fimo-code}/references/forms.md +0 -0
  201. /package/assets/skills/{fimo → fimo-code}/references/labels.md +0 -0
  202. /package/assets/skills/{fimo → fimo-code}/references/locales.md +0 -0
  203. /package/assets/skills/{fimo → fimo-code}/references/setup-plain-vite.md +0 -0
  204. /package/assets/skills/{fimo → fimo-code}/references/setup-react-router.md +0 -0
  205. /package/assets/skills/{fimo → fimo-code}/references/ui.md +0 -0
@@ -1,15 +0,0 @@
1
- import type { CmsCollectionSchema } from '../types.js';
2
- /**
3
- * Machine-wire a Strapi frontend to read from Fimo: emit the `fimo-strapi`
4
- * module in the CMS client dir, then swap every bare `fetch(...)` in that dir
5
- * to `fimoStrapiFetch(...)`. Because every Strapi client funnels through one
6
- * `fetch`, this makes the WHOLE site read scaffolded content from Fimo — no
7
- * per-method or per-call-site knowledge, no agent step. Unscaffolded types fall
8
- * through to the live CMS inside the shim.
9
- */
10
- export interface StrapiWireResult {
11
- changes: string[];
12
- warnings: string[];
13
- wired: boolean;
14
- }
15
- export declare function wireStrapiClient(cwd: string, clientDir: string, schemas: CmsCollectionSchema[]): StrapiWireResult;
@@ -1,107 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { parseSync } from 'oxc-parser';
4
- import { renderFimoStrapiModule } from './wiring.js';
5
- function walk(node, visit) {
6
- if (!node || typeof node !== 'object') {
7
- return;
8
- }
9
- if (Array.isArray(node)) {
10
- for (const child of node) {
11
- walk(child, visit);
12
- }
13
- return;
14
- }
15
- const record = node;
16
- if (typeof record.type === 'string') {
17
- visit(record);
18
- }
19
- for (const [key, value] of Object.entries(record)) {
20
- if (key !== 'type' && value && typeof value === 'object') {
21
- walk(value, visit);
22
- }
23
- }
24
- }
25
- /** Callee spans of bare `fetch(...)` calls (not `x.fetch()` / `this.fetch()`). */
26
- function bareFetchCallees(filePath, code) {
27
- let program;
28
- try {
29
- program = parseSync(filePath, code).program;
30
- }
31
- catch {
32
- return [];
33
- }
34
- const spans = [];
35
- walk(program, (n) => {
36
- if (n.type === 'CallExpression' && n.callee?.type === 'Identifier' && n.callee.name === 'fetch') {
37
- spans.push({ start: n.callee.start, end: n.callee.end });
38
- }
39
- });
40
- return spans;
41
- }
42
- function applyReplacements(code, edits) {
43
- let next = code;
44
- for (const edit of [...edits].sort((a, b) => b.start - a.start)) {
45
- next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);
46
- }
47
- return next;
48
- }
49
- function relativeImport(fromFile, toFile) {
50
- const rel = path
51
- .relative(path.dirname(fromFile), toFile)
52
- .replace(/\.tsx?$/, '')
53
- .split(path.sep)
54
- .join('/');
55
- return rel.startsWith('.') ? rel : `./${rel}`;
56
- }
57
- function sourceFiles(dir) {
58
- const out = [];
59
- const walkDir = (current) => {
60
- for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
61
- if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
62
- continue;
63
- }
64
- const full = path.join(current, entry.name);
65
- if (entry.isDirectory()) {
66
- walkDir(full);
67
- }
68
- else if (/\.(tsx?|jsx?|mjs)$/.test(entry.name)) {
69
- out.push(full);
70
- }
71
- }
72
- };
73
- if (fs.existsSync(dir)) {
74
- walkDir(dir);
75
- }
76
- return out;
77
- }
78
- export function wireStrapiClient(cwd, clientDir, schemas) {
79
- const changes = [];
80
- const warnings = [];
81
- if (!fs.existsSync(clientDir)) {
82
- return { changes, warnings: [`CMS client directory not found: ${path.relative(cwd, clientDir)}`], wired: false };
83
- }
84
- const modulePath = path.join(clientDir, 'fimo-strapi.ts');
85
- fs.writeFileSync(modulePath, renderFimoStrapiModule(schemas));
86
- changes.push(`generated ${path.relative(cwd, modulePath)}`);
87
- let swapped = 0;
88
- for (const file of sourceFiles(clientDir)) {
89
- if (path.resolve(file) === path.resolve(modulePath)) {
90
- continue;
91
- }
92
- const code = fs.readFileSync(file, 'utf8');
93
- const spans = bareFetchCallees(file, code);
94
- if (spans.length === 0) {
95
- continue;
96
- }
97
- let next = applyReplacements(code, spans.map((span) => ({ ...span, text: 'fimoStrapiFetch' })));
98
- next = `import { fimoStrapiFetch } from '${relativeImport(file, modulePath)}';\n${next}`;
99
- fs.writeFileSync(file, next);
100
- swapped += spans.length;
101
- changes.push(`rewired ${path.relative(cwd, file)}: ${spans.length} fetch call(s) → fimoStrapiFetch`);
102
- }
103
- if (swapped === 0) {
104
- warnings.push(`No bare fetch() call found under ${path.relative(cwd, clientDir)} — wire fimoStrapiFetch into the client manually.`);
105
- }
106
- return { changes, warnings, wired: swapped > 0 };
107
- }
@@ -1,17 +0,0 @@
1
- import type { CmsCollectionSchema } from '../types.js';
2
- /**
3
- * Machine-wiring for the native `fimo/strapi` read adapter. From the scaffolded
4
- * schemas it derives the Strapi-path → Fimo-type map (+ the singletons) and
5
- * emits a tiny repo module that instantiates the Fimo-backed fetch. The
6
- * migration then swaps the CMS client's `fetch` for `fimoStrapiFetch` — after
7
- * which the whole site reads scaffolded content from Fimo, deterministically.
8
- */
9
- export interface StrapiWiring {
10
- /** Strapi REST path segment (pluralName) → Fimo type name. */
11
- types: Record<string, string>;
12
- /** Fimo type names that are single types. */
13
- singletons: string[];
14
- }
15
- export declare function strapiWiring(schemas: CmsCollectionSchema[]): StrapiWiring;
16
- /** Emit the repo module (`fimo-strapi.ts`) that wires the fetch to Fimo. */
17
- export declare function renderFimoStrapiModule(schemas: CmsCollectionSchema[]): string;
@@ -1,46 +0,0 @@
1
- import { computeFieldShapes } from './shapes.js';
2
- export function strapiWiring(schemas) {
3
- const types = {};
4
- const singletons = [];
5
- for (const schema of schemas) {
6
- const pluralName = schema.sourcePath.replace(/^\/+/, '');
7
- if (pluralName) {
8
- types[pluralName] = schema.name;
9
- }
10
- if (schema.isSingleton) {
11
- singletons.push(schema.name);
12
- }
13
- }
14
- return { types, singletons };
15
- }
16
- /** Emit the repo module (`fimo-strapi.ts`) that wires the fetch to Fimo. */
17
- export function renderFimoStrapiModule(schemas) {
18
- const { types, singletons } = strapiWiring(schemas);
19
- const typeEntries = Object.entries(types)
20
- .map(([pluralName, typeName]) => ` '${pluralName}': '${typeName}',`)
21
- .join('\n');
22
- const fieldShapes = JSON.stringify(computeFieldShapes(schemas), null, 2);
23
- return `// AUTO-GENERATED by \`fimo migrate --scaffold-cms\`. Serves this site's Strapi
24
- // content reads from Fimo (scaffolded example content) through fimo/strapi.
25
- // The migration points the CMS client's fetch at \`fimoStrapiFetch\`; reads for
26
- // scaffolded types resolve from Fimo, everything else falls through to Strapi.
27
- import { createFimoStrapiFetch } from 'fimo/strapi';
28
-
29
- // Strapi REST path (pluralName) -> Fimo type name.
30
- const TYPES: Record<string, string> = {
31
- ${typeEntries}
32
- };
33
-
34
- const SINGLETONS = [${singletons.map((name) => `'${name}'`).join(', ')}];
35
-
36
- // Structural field shapes (single components read as objects; block items and
37
- // dynamic zones reshape into the Strapi shape the components expect).
38
- const FIELD_SHAPES = ${fieldShapes};
39
-
40
- export const fimoStrapiFetch = createFimoStrapiFetch({
41
- types: TYPES,
42
- singletons: SINGLETONS,
43
- fieldShapes: FIELD_SHAPES,
44
- });
45
- `;
46
- }
@@ -1,145 +0,0 @@
1
- /**
2
- * CMS-connector contract. A connector recognizes an external headless CMS
3
- * behind a wrapped frontend and reads its content-type definitions into the
4
- * neutral Fimo schema shape — WITHOUT connecting to the CMS at runtime.
5
- *
6
- * The connector seam mirrors the framework-adapter contract: a CMS's name and
7
- * quirks live ONLY under `scripts/cms/<cms>/`. Everything above (the registry,
8
- * the example-content generator, the orchestrator wiring) is CMS-neutral. A
9
- * CMS name appearing in neutral code is a review finding.
10
- */
11
- /** Scalar Fimo field types (see `FieldTypeSchema` in api-contracts). */
12
- export type FimoScalarType = 'string' | 'richtext' | 'media' | 'number' | 'boolean' | 'date' | 'json';
13
- export interface FimoScalarField {
14
- readonly type: FimoScalarType;
15
- /** Default applied when an entry omits the field (e.g. a baked block discriminator). */
16
- readonly default?: unknown;
17
- /** False hides the field from Studio editing (internal discriminators like `__component`). */
18
- readonly editable?: boolean;
19
- }
20
- export interface FimoReferenceField {
21
- readonly type: 'reference';
22
- /** Single-target reference (Fimo type name). */
23
- readonly target?: string;
24
- /** Poly-target reference (Fimo type names). */
25
- readonly targets?: string[];
26
- /** True for to-many relations. */
27
- readonly many?: boolean;
28
- }
29
- /** One variant a `blocks` item may take — the Fimo shape of a source CMS
30
- * component. `uid` becomes the served block's `_type` (PascalCase, matches
31
- * `CONTENT_TYPE_NAME_PATTERN`). */
32
- export interface FimoBlockVariant {
33
- readonly uid: string;
34
- readonly label: string;
35
- readonly fields: Record<string, FimoFieldDef>;
36
- }
37
- /** A blocks field's shape: one fixed shape (`fields`, a single/repeatable
38
- * component) or a discriminated union of variants (`oneOf`, a dynamic zone). */
39
- export type FimoBlocksSchema = {
40
- readonly fields: Record<string, FimoFieldDef>;
41
- } | {
42
- readonly oneOf: FimoBlockVariant[];
43
- };
44
- /** Ordered, Studio-editable structured content — the Fimo representation of a
45
- * CMS component (fixed) or dynamic zone (`oneOf`). The stored value is always
46
- * an array of `{ _key, [_type], ...fields }` items. */
47
- export interface FimoBlocksField {
48
- readonly type: 'blocks';
49
- readonly schema: FimoBlocksSchema;
50
- readonly min?: number;
51
- readonly max?: number;
52
- }
53
- export type FimoFieldDef = FimoScalarField | FimoReferenceField | FimoBlocksField;
54
- /**
55
- * One CMS content type mapped to the Fimo schema shape. `fields` is the exact
56
- * pushable `contentType.fields` payload; `name`/`label`/`isSingleton` complete
57
- * the `api.createSchema` call.
58
- */
59
- export interface CmsCollectionSchema {
60
- /** Fimo type name (PascalCase — deterministic from the CMS singular name). */
61
- readonly name: string;
62
- /** Human display label. */
63
- readonly label: string;
64
- /** A single-document type (e.g. a Strapi singleType) → true; a collection → false. */
65
- readonly isSingleton: boolean;
66
- /** The CMS marks this type as localized → seed per configured locale. */
67
- readonly localized: boolean;
68
- readonly fields: Record<string, FimoFieldDef>;
69
- /** Pre-computed example values for fields the generic generator can't shape
70
- * from the Fimo field type alone (dynamic zones must be arrays, components
71
- * objects). Keyed by field name; the generator uses these verbatim. */
72
- readonly examples?: Record<string, unknown>;
73
- /** Source CMS uid for provenance (e.g. `api::blog-post.blog-post`). */
74
- readonly sourceUid: string;
75
- /** Source REST path (e.g. `/blog-posts`) — informational for later rewire. */
76
- readonly sourcePath: string;
77
- }
78
- /** What a connector reports about a detected CMS. */
79
- export interface CmsDetection {
80
- /** Connector name, capitalized for the data-source prompt (e.g. `Strapi`). */
81
- readonly cms: string;
82
- /** Host label recorded in the data-source decision. */
83
- readonly host: string;
84
- /** Absolute path to the CMS app root when co-located (monorepo), else null. */
85
- readonly appDir: string | null;
86
- /** Absolute path to the frontend's CMS client module dir (where the fetch
87
- * lives), for machine-wiring the reads to Fimo. Null if not found. */
88
- readonly clientDir: string | null;
89
- /** Repo-relative files/signals that evidenced the detection. */
90
- readonly evidence: string[];
91
- /** Locales configured in the CMS, when discoverable (may be empty). */
92
- readonly locales: string[];
93
- }
94
- export interface CmsConnector {
95
- readonly detection: CmsDetection;
96
- /**
97
- * Read every content-type definition into the Fimo schema shape. Returns an
98
- * empty array when the schemas are not locally available (decoupled CMS with
99
- * no co-located source) — detection can still surface the source for a
100
- * keep-live decision even when schema import is impossible.
101
- */
102
- readSchemas(): CmsCollectionSchema[];
103
- /**
104
- * Emit a generic list-read helper (as source text) the agent wires into the
105
- * site's LIST views so they render the scaffolded example content from Fimo.
106
- * Returns null when the CMS has no such helper. `serverImport` is the
107
- * framework's Fimo server subpath (e.g. `fimo/next/server`) the helper imports
108
- * `fetchEntries` from.
109
- */
110
- renderListSource?(schemas: CmsCollectionSchema[], serverImport: string): string | null;
111
- /**
112
- * Machine-wire the frontend's CMS reads to Fimo: emit the adapter module and
113
- * swap the client's fetch, so the whole site reads scaffolded content from
114
- * Fimo. Deterministic — no agent step.
115
- */
116
- wireClient?(cwd: string, schemas: CmsCollectionSchema[]): CmsWireResult;
117
- /**
118
- * Enumerate the frontend's remaining couplings to this CMS — the unwire
119
- * worklist and the cutover gate (`clean`). Keys on actual CMS references, not
120
- * filenames, so a client module rewritten to call Fimo reads as clean.
121
- * Returns undefined for a connector without touchpoint detection.
122
- */
123
- detectTouchpoints?(cwd: string): CmsTouchpoints;
124
- }
125
- export interface CmsWireResult {
126
- changes: string[];
127
- warnings: string[];
128
- wired: boolean;
129
- }
130
- export interface CmsTouchpointSite {
131
- file: string;
132
- line: number;
133
- reason: string;
134
- snippet: string;
135
- }
136
- export interface CmsTouchpoints {
137
- /** SDK/client/type packages still declared in the frontend's package.json. */
138
- dependencies: string[];
139
- /** Source lines that still reach the CMS at runtime. */
140
- callSites: CmsTouchpointSite[];
141
- /** CMS base-URL / token env keys still present in dotenv files. */
142
- envVars: string[];
143
- /** No runtime coupling remains — the cutover is complete. */
144
- clean: boolean;
145
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * CMS-connector contract. A connector recognizes an external headless CMS
3
- * behind a wrapped frontend and reads its content-type definitions into the
4
- * neutral Fimo schema shape — WITHOUT connecting to the CMS at runtime.
5
- *
6
- * The connector seam mirrors the framework-adapter contract: a CMS's name and
7
- * quirks live ONLY under `scripts/cms/<cms>/`. Everything above (the registry,
8
- * the example-content generator, the orchestrator wiring) is CMS-neutral. A
9
- * CMS name appearing in neutral code is a review finding.
10
- */
11
- export {};
@@ -1,39 +0,0 @@
1
- export type DetectedFramework = 'next' | 'react-router' | 'remix' | 'astro' | 'nuxt' | 'sveltekit' | 'vue' | 'vite';
2
- export interface FrameworkDetection {
3
- framework: DetectedFramework | null;
4
- /** For Next.js: the app-router directory (`app` or `src/app`) when present. */
5
- appDir?: string;
6
- /** For Next.js: the pages-router directory (`pages` or `src/pages`) when present. */
7
- pagesDir?: string;
8
- /** A recognized framework that wrap migration does not support yet. */
9
- unsupported?: string;
10
- /** For bare Vite: the project depends on react, so .jsx/.tsx is React JSX. */
11
- react?: boolean;
12
- }
13
- /**
14
- * Detect the framework of an existing site from its package.json and layout.
15
- * Used by `fimo init` (adopt-existing-site) and the wrap migration to decide
16
- * how routes are discovered and which env flavor to write.
17
- */
18
- export declare function detectFramework(cwd: string): FrameworkDetection;
19
- /** A frontend app found inside a workspace, adoptable by `fimo init`. */
20
- export interface AdoptableApp {
21
- /** Absolute directory of the app. */
22
- dir: string;
23
- /** Directory relative to the scan root (for display + as the init dirArg). */
24
- relDir: string;
25
- detection: FrameworkDetection;
26
- }
27
- /**
28
- * Find frontend apps to adopt anywhere inside a directory tree. Most real
29
- * sites are monorepos where the framework app is NOT at the root and NOT
30
- * necessarily under `apps/` (`frontend/`, `sites/web`, `packages/marketing`,
31
- * …) — `detectFramework(root)` returns null and `fimo init` would wrongly
32
- * scaffold a new project. This walks the tree up to a bounded depth, running
33
- * `detectFramework` on every directory that has a package.json and pruning
34
- * `node_modules`/build output, so it finds the app wherever it lives without
35
- * relying on a naming convention or a workspace manifest. The root itself is
36
- * excluded (the caller checks it directly); descent stops at the first
37
- * framework match in a subtree (an app's own subdirs are not separate apps).
38
- */
39
- export declare function findAdoptableApps(rootDir: string): AdoptableApp[];
@@ -1,133 +0,0 @@
1
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
- import { join, relative } from 'node:path';
3
- /**
4
- * Detect the framework of an existing site from its package.json and layout.
5
- * Used by `fimo init` (adopt-existing-site) and the wrap migration to decide
6
- * how routes are discovered and which env flavor to write.
7
- */
8
- export function detectFramework(cwd) {
9
- const pkgPath = join(cwd, 'package.json');
10
- if (!existsSync(pkgPath)) {
11
- return { framework: null };
12
- }
13
- let pkg;
14
- try {
15
- pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
16
- }
17
- catch {
18
- return { framework: null };
19
- }
20
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
21
- if (deps.next) {
22
- const appDir = ['app', 'src/app'].find((dir) => existsSync(join(cwd, dir)));
23
- const pagesDir = ['pages', 'src/pages'].find((dir) => existsSync(join(cwd, dir)));
24
- return { framework: 'next', appDir, pagesDir };
25
- }
26
- if (deps['react-router'] || deps['@react-router/dev']) {
27
- return { framework: 'react-router' };
28
- }
29
- if (deps['@remix-run/react']) {
30
- const pagesDir = ['app/routes'].find((dir) => existsSync(join(cwd, dir)));
31
- return { framework: 'remix', pagesDir };
32
- }
33
- if (deps.astro) {
34
- const pagesDir = ['src/pages'].find((dir) => existsSync(join(cwd, dir)));
35
- return { framework: 'astro', pagesDir };
36
- }
37
- if (deps.nuxt) {
38
- // 'src/pages' covers the common custom srcDir (nuxt.config `srcDir: './src'`).
39
- const pagesDir = ['pages', 'app/pages', 'src/pages'].find((dir) => existsSync(join(cwd, dir)));
40
- return { framework: 'nuxt', pagesDir };
41
- }
42
- if (deps['@sveltejs/kit']) {
43
- const pagesDir = ['src/routes'].find((dir) => existsSync(join(cwd, dir)));
44
- return { framework: 'sveltekit', pagesDir };
45
- }
46
- if (deps.vue && deps.vite) {
47
- return { framework: 'vue' };
48
- }
49
- if (deps.vite) {
50
- // A react dependency guarantees the JSX runtime: the --apply codemod and
51
- // react-router route discovery are safe. Bare vite (Solid, Preact, lit)
52
- // stays hands-off.
53
- return { framework: 'vite', react: Boolean(deps.react) };
54
- }
55
- // Known frameworks we can NAME but not wrap yet — lets `fimo init` route
56
- // honestly instead of silently falling through to create-new.
57
- const unsupportedByDep = [
58
- ['gatsby', 'Gatsby'],
59
- ['@angular/core', 'Angular'],
60
- ['@docusaurus/core', 'Docusaurus'],
61
- ['@11ty/eleventy', 'Eleventy'],
62
- ];
63
- for (const [dep, name] of unsupportedByDep) {
64
- if (deps[dep]) {
65
- return { framework: null, unsupported: name };
66
- }
67
- }
68
- return { framework: null };
69
- }
70
- const WORKSPACE_SKIP = new Set([
71
- 'node_modules',
72
- '.git',
73
- 'dist',
74
- 'build',
75
- 'out',
76
- '.next',
77
- '.nuxt',
78
- '.svelte-kit',
79
- '.turbo',
80
- '.vercel',
81
- 'coverage',
82
- ]);
83
- /** How deep below the root the scan looks for a framework app (`apps/ui` is
84
- * depth 2, `packages/frontend/web` is depth 3). */
85
- const MAX_SCAN_DEPTH = 3;
86
- /**
87
- * Find frontend apps to adopt anywhere inside a directory tree. Most real
88
- * sites are monorepos where the framework app is NOT at the root and NOT
89
- * necessarily under `apps/` (`frontend/`, `sites/web`, `packages/marketing`,
90
- * …) — `detectFramework(root)` returns null and `fimo init` would wrongly
91
- * scaffold a new project. This walks the tree up to a bounded depth, running
92
- * `detectFramework` on every directory that has a package.json and pruning
93
- * `node_modules`/build output, so it finds the app wherever it lives without
94
- * relying on a naming convention or a workspace manifest. The root itself is
95
- * excluded (the caller checks it directly); descent stops at the first
96
- * framework match in a subtree (an app's own subdirs are not separate apps).
97
- */
98
- export function findAdoptableApps(rootDir) {
99
- const apps = [];
100
- const walk = (dir, depth) => {
101
- if (depth > MAX_SCAN_DEPTH) {
102
- return;
103
- }
104
- if (dir !== rootDir && existsSync(join(dir, 'package.json'))) {
105
- const detection = detectFramework(dir);
106
- if (detection.framework) {
107
- apps.push({ dir, relDir: relative(rootDir, dir), detection });
108
- return; // don't descend into an app's own subtree
109
- }
110
- }
111
- let entries;
112
- try {
113
- entries = readdirSync(dir, { withFileTypes: true });
114
- }
115
- catch {
116
- return;
117
- }
118
- for (const entry of entries) {
119
- if (entry.isDirectory() && !WORKSPACE_SKIP.has(entry.name) && !entry.name.startsWith('.')) {
120
- walk(join(dir, entry.name), depth + 1);
121
- }
122
- }
123
- };
124
- walk(rootDir, 0);
125
- // Shallower + apps/-conventional first (the most likely primary site), then
126
- // alphabetical — the order the interactive picker presents them in.
127
- return apps.sort((a, b) => {
128
- const depthA = a.relDir.split('/').length;
129
- const depthB = b.relDir.split('/').length;
130
- const rank = (relDir) => (relDir.startsWith('apps/') ? 0 : 1);
131
- return rank(a.relDir) - rank(b.relDir) || depthA - depthB || a.relDir.localeCompare(b.relDir);
132
- });
133
- }
@@ -1,19 +0,0 @@
1
- import type { SchemaDraft } from './draft-schemas.js';
2
- import type { WrapScanResult } from './scan-wrappable.js';
3
- export interface RowsFile {
4
- draftUid: string;
5
- source: string;
6
- references: Record<string, {
7
- target?: string;
8
- targets?: string[];
9
- by: 'slug';
10
- many?: boolean;
11
- }>;
12
- rows: Array<Record<string, unknown>>;
13
- }
14
- /**
15
- * Stage rows for every draft. Drafts carry the inferred field types, the
16
- * scan carries the raw rows (typedRows for in-code candidates; data files
17
- * are re-read from disk for the full, untruncated dataset).
18
- */
19
- export declare function writeRowsStaging(rootDir: string, scan: WrapScanResult, drafts: SchemaDraft[]): number;
@@ -1,135 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import YAML from 'yaml';
4
- /**
5
- * Machine-staged entry ROWS for every drafted collection: the deterministic
6
- * transformation agents kept re-implementing by hand (media envelopes,
7
- * richtext docs, slugs inside data), applied once by the machine. Reference
8
- * fields keep their SOURCE values (slugs/names) and each file carries a
9
- * references descriptor — the resolution to documentIds happens at seed
10
- * time (agent-side maps today; server-side via the batch endpoint next).
11
- *
12
- * Output: `.fimo/migration/rows/<ProvisionalUid>.rows.json`
13
- * { draftUid, source, references: { field: { target, by, many? } }, rows }
14
- *
15
- * Regenerated on every migrate run; `schemas adopt-drafts` rewrites
16
- * draftUid and reference targets through the same renames it applies to the
17
- * schema files.
18
- */
19
- const MEDIA_PATH = /^\/(images|img|videos|video|media|assets|files|docs|documents)\//i;
20
- const MEDIA_EXT = /\.(png|jpe?g|gif|webp|avif|svg|mp4|webm|mov|mp3|wav|pdf|zip|docx?)$/i;
21
- function toRichTextDoc(text) {
22
- const paragraphs = text
23
- .split(/\n\n+/)
24
- .map((paragraph) => paragraph.trim())
25
- .filter(Boolean);
26
- return {
27
- type: 'doc',
28
- content: paragraphs.map((paragraph) => ({
29
- type: 'paragraph',
30
- content: [{ type: 'text', text: paragraph }],
31
- })),
32
- };
33
- }
34
- function transformValue(fieldType, value) {
35
- if (value == null) {
36
- return value;
37
- }
38
- if (fieldType === 'media' && typeof value === 'string' && (MEDIA_PATH.test(value) || MEDIA_EXT.test(value))) {
39
- return { source: 'local', url: value, alt: '' };
40
- }
41
- if (fieldType === 'richtext' && typeof value === 'string') {
42
- return toRichTextDoc(value);
43
- }
44
- return value;
45
- }
46
- function loadSourceRows(rootDir, source) {
47
- const filePath = join(rootDir, source);
48
- if (!existsSync(filePath)) {
49
- return null;
50
- }
51
- try {
52
- const raw = readFileSync(filePath, 'utf8');
53
- const parsed = /\.ya?ml$/.test(source) ? YAML.parse(raw) : JSON.parse(raw);
54
- return Array.isArray(parsed) ? parsed : null;
55
- }
56
- catch {
57
- return null;
58
- }
59
- }
60
- /**
61
- * Stage rows for every draft. Drafts carry the inferred field types, the
62
- * scan carries the raw rows (typedRows for in-code candidates; data files
63
- * are re-read from disk for the full, untruncated dataset).
64
- */
65
- export function writeRowsStaging(rootDir, scan, drafts) {
66
- const rowsDir = join(rootDir, '.fimo', 'migration', 'rows');
67
- rmSync(rowsDir, { recursive: true, force: true });
68
- if (drafts.length === 0) {
69
- return 0;
70
- }
71
- const bySourceLabel = new Map(drafts.map((draft) => [draft.source, draft]));
72
- const provisionalByName = new Map(drafts.map((draft) => [draft.sourceName, draft.uid]));
73
- const toProvisional = (name) => provisionalByName.get(name) ?? name;
74
- let written = 0;
75
- const stage = (draft, source, rawRows, references) => {
76
- const fieldTypes = new Map(Object.entries(draft.fields).map(([name, def]) => [
77
- name,
78
- def && typeof def === 'object' ? (def.type ?? 'string') : 'string',
79
- ]));
80
- const referenceFields = new Set(references.map((reference) => reference.field));
81
- const rows = rawRows.map((row) => {
82
- const out = {};
83
- for (const [key, value] of Object.entries(row)) {
84
- // Reference values stay as SOURCE values for later resolution.
85
- out[key] = referenceFields.has(key) ? value : transformValue(fieldTypes.get(key), value);
86
- }
87
- return out;
88
- });
89
- const descriptor = {};
90
- for (const reference of references) {
91
- const targets = reference.targets.map(toProvisional);
92
- descriptor[reference.field] = {
93
- ...(targets.length > 1 ? { targets } : { target: targets[0] }),
94
- by: 'slug',
95
- ...(reference.many ? { many: true } : {}),
96
- };
97
- }
98
- mkdirSync(rowsDir, { recursive: true });
99
- writeFileSync(join(rowsDir, `${draft.uid}.rows.json`), `${JSON.stringify({ draftUid: draft.uid, source, references: descriptor, rows }, null, 1)}\n`);
100
- written += 1;
101
- };
102
- for (const candidate of scan.collections) {
103
- const label = `${candidate.file}:${candidate.line}`;
104
- const draft = bySourceLabel.get(label);
105
- if (!draft || !candidate.typedRows || candidate.typedRows.length === 0) {
106
- continue;
107
- }
108
- stage(draft, label, candidate.typedRows, (candidate.references ?? []).map((reference) => ({
109
- field: reference.field,
110
- targets: reference.targets,
111
- many: reference.many,
112
- })));
113
- }
114
- for (const dataFile of scan.dataFiles) {
115
- const draft = bySourceLabel.get(dataFile.file);
116
- if (!draft) {
117
- continue;
118
- }
119
- // Markdown groups can't be re-read from a single path (`<dir>/*.md`) — the
120
- // scanner already parsed every document into the collection's typedRows.
121
- const rawRows = dataFile.kind === 'markdown'
122
- ? (dataFile.collections[0]?.typedRows ?? null)
123
- : loadSourceRows(rootDir, dataFile.file);
124
- if (!rawRows) {
125
- continue;
126
- }
127
- const references = dataFile.collections.flatMap((collection) => (collection.references ?? []).map((reference) => ({
128
- field: reference.field,
129
- targets: reference.targets,
130
- many: reference.many,
131
- })));
132
- stage(draft, dataFile.file, rawRows, references);
133
- }
134
- return written;
135
- }