fimo 0.17.0 → 0.19.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 (164) hide show
  1. package/assets/astro/components/DateTime.astro +22 -0
  2. package/assets/astro/components/index.d.ts +1 -0
  3. package/assets/astro/components/index.js +1 -0
  4. package/assets/content-templates/shared/types.eta +2 -0
  5. package/assets/skills/fimo-cli/SKILL.md +8 -6
  6. package/assets/skills/fimo-cli/references/branches.md +2 -2
  7. package/assets/skills/fimo-cli/references/content.md +2 -2
  8. package/assets/skills/fimo-cli/references/deploy.md +17 -9
  9. package/assets/skills/fimo-cli/references/hosting.md +114 -0
  10. package/assets/skills/fimo-cli/references/init.md +13 -6
  11. package/assets/skills/fimo-cli/references/integrations/firecrawl.md +2 -0
  12. package/assets/skills/fimo-cli/references/locales.md +38 -14
  13. package/assets/skills/fimo-cli/references/pages.md +70 -0
  14. package/assets/skills/fimo-cli/references/preview.md +26 -20
  15. package/assets/skills/fimo-cli/references/webhooks.md +1 -1
  16. package/assets/skills/fimo-code/SKILL.md +11 -0
  17. package/assets/skills/fimo-code/assets/react-router-locales/LocaleLayout.tsx +12 -0
  18. package/assets/skills/fimo-code/assets/react-router-locales/routes.ts +7 -6
  19. package/assets/skills/fimo-code/references/best-practices/astro.md +47 -0
  20. package/assets/skills/fimo-code/references/best-practices/next.md +42 -0
  21. package/assets/skills/fimo-code/references/best-practices/sveltekit.md +17 -0
  22. package/assets/skills/fimo-code/references/content/richtext.md +5 -0
  23. package/assets/skills/fimo-code/references/content/schema.md +4 -1
  24. package/assets/skills/fimo-code/references/frameworks/astro.md +5 -3
  25. package/assets/skills/fimo-code/references/frameworks/hosting.md +5 -2
  26. package/assets/skills/fimo-code/references/frameworks/next/app-router.md +6 -0
  27. package/assets/skills/fimo-code/references/frameworks/next/locales.md +12 -2
  28. package/assets/skills/fimo-code/references/frameworks/next.md +7 -0
  29. package/assets/skills/fimo-code/references/frameworks/react-router.md +15 -7
  30. package/assets/skills/fimo-code/references/frameworks/sveltekit.md +15 -8
  31. package/assets/skills/fimo-code/references/labels.md +9 -1
  32. package/assets/skills/fimo-code/references/locales.md +8 -2
  33. package/assets/skills/fimo-code/references/migrations/react-router-route-ownership.md +93 -0
  34. package/assets/skills/fimo-code/references/ui.md +21 -2
  35. package/assets/skills/fimo-migration/SKILL.md +276 -51
  36. package/assets/skills/fimo-migration/references/content.md +119 -35
  37. package/assets/skills/fimo-migration/references/decision.md +72 -0
  38. package/assets/skills/fimo-migration/references/forms.md +38 -6
  39. package/assets/skills/fimo-migration/references/frameworks/nextjs.md +179 -23
  40. package/assets/skills/fimo-migration/references/import-contract.md +71 -19
  41. package/assets/skills/fimo-migration/references/manifest.md +11 -161
  42. package/assets/skills/fimo-migration/references/media.md +33 -1
  43. package/assets/skills/fimo-migration/references/platforms.md +26 -2
  44. package/assets/skills/fimo-migration/references/qa.md +167 -13
  45. package/assets/skills/fimo-migration/references/workers/content-execution.md +39 -0
  46. package/assets/skills/fimo-migration/references/workers/content-planner.md +64 -0
  47. package/assets/skills/fimo-migration/references/workers/framework.md +37 -0
  48. package/assets/skills/fimo-migration/references/workers/validator.md +25 -0
  49. package/assets/skills/fimo-migration/references/workers.md +82 -0
  50. package/assets/skills/fimo-migration/references/workflow.md +140 -192
  51. package/assets/skills/fimo-migration/scripts/apply-decision.mjs +534 -0
  52. package/assets/skills/fimo-migration/scripts/build-canonical-manifest.mjs +7 -4
  53. package/assets/skills/fimo-migration/scripts/write-migration-report.mjs +191 -4
  54. package/assets/skills/fimo-studio/references/ai-chat.md +1 -1
  55. package/assets/skills/fimo-studio/references/cms.md +25 -7
  56. package/assets/skills/fimo-studio/references/webhooks.md +1 -1
  57. package/assets/sveltekit/components/DateTime.svelte +35 -0
  58. package/assets/sveltekit/components/FimoProvider.svelte +2 -2
  59. package/assets/sveltekit/components/index.d.ts +1 -0
  60. package/assets/sveltekit/components/index.js +1 -0
  61. package/dist/build/next/config.d.ts +4 -1
  62. package/dist/build/next/config.js +21 -5
  63. package/dist/build/sveltekit/vite.d.ts +3 -4
  64. package/dist/build/sveltekit/vite.js +3 -4
  65. package/dist/build/vite/plugins/runtime-env.d.ts +2 -1
  66. package/dist/build/vite/plugins/runtime-env.js +14 -10
  67. package/dist/cli/bundle.json +2 -2
  68. package/dist/cli/index.js +113 -108
  69. package/dist/runtime/app/FimoProviders.js +25 -14
  70. package/dist/runtime/app/prefetch.d.ts +3 -1
  71. package/dist/runtime/app/prefetch.js +11 -55
  72. package/dist/runtime/astro/preview.js +7 -9
  73. package/dist/runtime/content/client/internal.js +1 -0
  74. package/dist/runtime/i18n/locale.d.ts +6 -3
  75. package/dist/runtime/i18n/locale.js +16 -41
  76. package/dist/runtime/next/client-runtime.js +5 -1
  77. package/dist/runtime/next/client.d.ts +3 -2
  78. package/dist/runtime/next/client.js +2 -1
  79. package/dist/runtime/next/labels.d.ts +2 -2
  80. package/dist/runtime/next/labels.js +2 -2
  81. package/dist/runtime/next/preview.d.ts +13 -0
  82. package/dist/runtime/next/preview.js +34 -0
  83. package/dist/runtime/next/primitives/server.d.ts +2 -0
  84. package/dist/runtime/next/primitives/server.js +8 -0
  85. package/dist/runtime/next/provider.d.ts +5 -0
  86. package/dist/runtime/next/provider.js +17 -3
  87. package/dist/runtime/next/server-runtime.js +4 -1
  88. package/dist/runtime/next/server.d.ts +1 -1
  89. package/dist/runtime/next/server.js +1 -1
  90. package/dist/runtime/paths/get-fimo-paths.d.ts +6 -5
  91. package/dist/runtime/paths/get-fimo-paths.js +43 -42
  92. package/dist/runtime/preview/location.d.ts +19 -2
  93. package/dist/runtime/preview/location.js +16 -2
  94. package/dist/runtime/primitives/index.d.ts +1 -0
  95. package/dist/runtime/primitives/index.js +1 -0
  96. package/dist/runtime/react/primitives/editable/DateTime.d.ts +4 -0
  97. package/dist/runtime/react/primitives/editable/DateTime.js +13 -0
  98. package/dist/runtime/react/primitives/renderers/DateRenderer.d.ts +7 -1
  99. package/dist/runtime/react/primitives/renderers/DateRenderer.js +11 -8
  100. package/dist/runtime/react-router/{routes.d.ts → legacy/routes.d.ts} +6 -1
  101. package/dist/runtime/react-router/{routes.js → legacy/routes.js} +22 -7
  102. package/dist/runtime/routes/index.d.ts +162 -0
  103. package/dist/runtime/routes/index.js +335 -0
  104. package/dist/runtime/routing/AppRoutesProvider.js +4 -3
  105. package/dist/runtime/seo/resolver.d.ts +5 -0
  106. package/dist/runtime/seo/resolver.js +10 -42
  107. package/dist/runtime/shared/fimo-config.types.d.ts +14 -13
  108. package/dist/runtime/shared/preview-location.d.ts +1 -22
  109. package/dist/runtime/shared/preview-location.js +5 -93
  110. package/dist/runtime/sveltekit/preview.d.ts +12 -3
  111. package/dist/runtime/sveltekit/preview.js +13 -8
  112. package/dist/runtime/templates.d.ts +19 -0
  113. package/dist/runtime/templates.js +33 -0
  114. package/dist/scripts/sync-forms.js +1 -1
  115. package/dist/scripts/sync-schemas.js +1 -4
  116. package/dist/scripts/validate-fimo-config.js +5 -1
  117. package/dist/scripts/validate-page-registry.d.ts +2 -0
  118. package/dist/scripts/validate-page-registry.js +167 -0
  119. package/dist/scripts/validate-route-metadata.js +132 -41
  120. package/package.json +10 -5
  121. package/templates/astro/.fimo/config.json +13 -5
  122. package/templates/astro/AGENTS.md +5 -1
  123. package/templates/astro/astro.config.mjs +7 -0
  124. package/templates/astro/pnpm-workspace.yaml +0 -3
  125. package/templates/astro/src/components/ProjectOverview.astro +9 -6
  126. package/templates/astro/src/layouts/Base.astro +1 -1
  127. package/templates/astro/src/locales.ts +4 -0
  128. package/templates/astro/src/pages/[locale]/index.astro +19 -0
  129. package/templates/astro/src/pages/[locale]/projects/[slug].astro +35 -0
  130. package/templates/astro/src/pages/[locale]/projects/index.astro +19 -0
  131. package/templates/astro/src/pages/index.astro +5 -2
  132. package/templates/astro/src/pages/projects/[slug].astro +4 -2
  133. package/templates/astro/src/pages/projects/index.astro +5 -2
  134. package/templates/nextjs/.fimo/config.json +2 -1
  135. package/templates/nextjs/AGENTS.md +5 -0
  136. package/templates/nextjs/src/app/(default)/layout.tsx +10 -0
  137. package/templates/nextjs/src/app/[locale]/layout.tsx +22 -0
  138. package/templates/nextjs/src/app/[locale]/page.tsx +1 -0
  139. package/templates/nextjs/src/components/Document.tsx +26 -0
  140. package/templates/nextjs/src/components/FimoPreviewBridge.tsx +13 -0
  141. package/templates/nextjs/src/locales.ts +13 -0
  142. package/templates/react-router/.fimo/config.json +3 -6
  143. package/templates/react-router/AGENTS.md +4 -0
  144. package/templates/react-router/package.json +1 -1
  145. package/templates/react-router/pnpm-workspace.yaml +1 -3
  146. package/templates/react-router/react-router.config.ts +4 -10
  147. package/templates/react-router/src/pages/LocaleLayout.tsx +12 -0
  148. package/templates/react-router/src/root.tsx +2 -4
  149. package/templates/react-router/src/routes.ts +5 -3
  150. package/templates/sveltekit/.fimo/config.json +2 -1
  151. package/templates/sveltekit/AGENTS.md +5 -0
  152. package/templates/sveltekit/src/app.html +1 -1
  153. package/templates/sveltekit/src/hooks.server.ts +11 -0
  154. package/templates/sveltekit/src/locales.ts +8 -0
  155. package/templates/sveltekit/src/params/locale.ts +5 -0
  156. package/templates/sveltekit/src/routes/+layout.server.ts +6 -1
  157. package/templates/sveltekit/src/routes/+layout.svelte +5 -0
  158. package/assets/skills/fimo-migration/references/inventory/coordinator.md +0 -40
  159. package/assets/skills/fimo-migration/references/inventory/locales/next-intl.md +0 -39
  160. package/assets/skills/fimo-migration/references/inventory/locales.md +0 -41
  161. package/assets/skills/fimo-migration/scripts/inventory/locales/next-intl.mjs +0 -459
  162. package/templates/nextjs/src/app/layout.tsx +0 -17
  163. /package/templates/nextjs/src/app/{page.tsx → (default)/page.tsx} +0 -0
  164. /package/templates/sveltekit/src/routes/{+page.svelte → [[locale=locale]]/+page.svelte} +0 -0
@@ -0,0 +1,39 @@
1
+ # Content execution workers
2
+
3
+ Execute the content planner's text handoff. Do not rediscover the source,
4
+ reclassify values, redesign schemas, or edit files outside the assigned batch.
5
+ If the handoff is incomplete, report the missing item to the coordinator so the
6
+ planner can repair it.
7
+
8
+ ## Data worker
9
+
10
+ Own one bounded schema/locale payload. Start only after every referenced asset
11
+ has a confirmed Fimo mapping and, during conversion, the framework gate passes.
12
+ Perform create-or-update writes and read the batch back before returning.
13
+
14
+ For entry batches, use
15
+ `fimo entries bulk-create <Uid> --file <payload> --upsert-by slug` and report
16
+ per-chunk created, updated, reconciled, and conflict counts. Do not leave a
17
+ payload as evidence of an import. An unavailable dependency blocks promptly;
18
+ do not poll indefinitely.
19
+
20
+ ## Code worker
21
+
22
+ Start only after this batch's real records read back as non-empty. Own exactly
23
+ the consumer files assigned by the planner.
24
+
25
+ 1. Load the active framework's `fimo-code` reference.
26
+ 2. Establish the generated Fimo client/adapter needed by the batch.
27
+ 3. Replace every planned `sourceFile`/`sourceKey` at its existing consumer in
28
+ place. Appending a disconnected duplicate section is not wiring.
29
+ 4. Preserve executable React/MDX children in order around editable prose.
30
+ 5. Render at least one real imported item through every Server-to-Client or
31
+ plain-JSON boundary in the batch. Use the framework's generated
32
+ serialization/hydration contract; do not partially unwrap tracked values.
33
+ 6. Confirm each original literal or data source is gone only where its Fimo
34
+ replacement now renders once.
35
+
36
+ A loader that reads Fimo while the consuming markup is missing, an imported
37
+ entry no route consumes, or a successful build over empty data is incomplete.
38
+ Return source items wired, files changed, read-back/render evidence, and any
39
+ unresolved item in plain text.
@@ -0,0 +1,64 @@
1
+ # Content planning worker
2
+
3
+ Own semantic discovery, schema authoring, payload preparation, and the text
4
+ handoff. Do not import entries or rewrite application consumers.
5
+
6
+ 1. Inspect every content-bearing source and consumer: Markdown/MDX bodies and
7
+ frontmatter, JSX/TSX modules, hardcoded arrays and objects, imports, data
8
+ clients, and call sites. Read local exports and public APIs directly. A
9
+ private API requires a user-provided export or narrowly scoped server-side
10
+ credential; never recover or copy secret values.
11
+ 2. Classify each value as collection content, single content, an
12
+ editor-visible label, or application-owned code. Repetition is evidence,
13
+ not an automatic collection rule. Assistive text, identifiers, and values
14
+ that drive behavior are not labels.
15
+ 3. Define complete schemas from source evidence: types, requiredness, defaults,
16
+ uniqueness, locale behavior, media constraints, references, and
17
+ cardinalities. Do not invent constraints. Load `references/decision.md` and
18
+ the target project's Fimo schema guidance.
19
+ 4. Trace every item to the route, component, loader, query, or render module
20
+ that consumes it. Record its `sourceFile`, `sourceKey`, target files, payload
21
+ file, and worker batch. Finding data without consumers is incomplete.
22
+ 5. Enumerate every media field and rich-text image node as an asset obligation.
23
+ 6. Write and push `src/schemas/*.json`, generate required clients/types, and
24
+ write self-contained JSON payloads for the data workers.
25
+ 7. Write `.fimo/migration/content-plan.md` before any entry, label, single, or
26
+ content-driven code rewrite begins.
27
+
28
+ The text plan has one source item per independently migrated construct and
29
+ groups them into non-overlapping data and code batches. Every object in a
30
+ hardcoded content array is an item. MDX prose and executable imports/components
31
+ are separate items when needed; executable JSX cannot disappear inside a
32
+ rich-text conversion.
33
+
34
+ Keep the handoff short:
35
+
36
+ ```md
37
+ ## BlogPost
38
+
39
+ - Source: `content/blog/post.mdx`
40
+ - Schema: `src/schemas/BlogPost.json` (pushed)
41
+ - Payload: `.fimo/migration/content/BlogPost.en.json`
42
+ - Items: title, body, cover, `CoverageChart` behavior
43
+ - Consumers: `src/app/blog/[slug]/page.tsx`
44
+ - Data worker: `BlogPost/en`
45
+ - Code worker: `blog-rendering`, owns the consumer above
46
+
47
+ ## Unresolved
48
+
49
+ - `content/blog/post.mdx:11`: `CoverageChart` implementation is absent; owner
50
+ must restore it. Do not remove the node silently.
51
+ ```
52
+
53
+ A construct is unresolved only when it genuinely cannot be migrated. Include
54
+ its exact source, user-visible impact, reason, and owner action; "custom" is not
55
+ a reason.
56
+
57
+ ## Optional extraction helpers
58
+
59
+ Start with `rg` and targeted reads. A bounded read-only helper under
60
+ `.fimo/migration/tmp/` may parse repeated frontmatter, JSON/YAML exports, or
61
+ literal structures while preserving source locations. Spot-check its output.
62
+ The agent still owns classification, schema design, and consumer tracing. Do
63
+ not build a generic codemod system or let the helper write Fimo data or app
64
+ code.
@@ -0,0 +1,37 @@
1
+ # Framework conversion worker
2
+
3
+ Use this worker only after the user explicitly chose a framework conversion.
4
+ Preserve mode never uses it.
5
+
6
+ `fimo migrate init` creates the target first. Inspect the initialized template
7
+ and its real paths before writing. Own all structural target code: dependencies,
8
+ framework config, root layout and providers, app tree, route modules, 404,
9
+ redirects, headers, middleware, sitemap/robots/OG structure, and locale-routing
10
+ structure. There is no separate runtime or route writer during conversion.
11
+
12
+ Port the source APIs, loaders, hardcoded content, integrations, and visible
13
+ behavior into the new framework unchanged. Do not migrate those values to Fimo
14
+ in this pass; schemas, data, and Fimo consumer wiring belong to later content
15
+ workers. The content planner may inspect the source in parallel but must not
16
+ edit structural target code.
17
+
18
+ Load the target framework's `fimo-code` and hosting references. For Next.js,
19
+ also load `references/frameworks/nextjs.md` and translate portable hosting
20
+ behavior before declaring provider-specific behavior unresolved.
21
+
22
+ ## Framework gate
23
+
24
+ Before returning, self-check and report:
25
+
26
+ - dependencies install cleanly;
27
+ - the framework build succeeds;
28
+ - every source route maps to a target route and renders locally with its
29
+ expected status, including 404 behavior;
30
+ - representative source text landmarks appear;
31
+ - exactly one app tree and one root layout exist; and
32
+ - primary routes have no runtime or console errors.
33
+
34
+ Return a plain-text route map, files changed, check results, preserved behavior,
35
+ and unresolved behavior. The coordinator independently reruns the build and
36
+ representative route checks. Content data cannot start until this gate and the
37
+ asset gate pass.
@@ -0,0 +1,25 @@
1
+ # Migration validator
2
+
3
+ The validator is an independent read-only worker. It did not author the
4
+ migration and starts only after all writers return.
5
+
6
+ Compare the source, content plan, actual `git diff`, real Fimo state, and local
7
+ application behavior. A worker report is a claim, not evidence.
8
+
9
+ Verify:
10
+
11
+ - every source route renders with expected status and representative content;
12
+ - schemas, entries, singles, labels, media, forms, and locales exist through
13
+ CLI read-back;
14
+ - every planned source item is consumed at its original behavior path, not in
15
+ an appended duplicate section;
16
+ - media URLs load as their expected media type;
17
+ - native Fimo APIs are used without migration-only wrappers;
18
+ - imports are safe to rerun;
19
+ - build and representative browser interactions pass; and
20
+ - every unsupported item names its impact and owner action.
21
+
22
+ Return a plain-text report with status, duration, checks run, counts, failing
23
+ source items, and suggested bounded repair surface. The coordinator may run one
24
+ repair for that surface and rerun validation. It does not restart every worker
25
+ or loop indefinitely.
@@ -0,0 +1,82 @@
1
+ # Migration workers
2
+
3
+ The root coding agent is the coordinator. It inspects the initialized target,
4
+ writes a short text plan, starts independent workers through its native
5
+ subagent mechanism, and fans their results back in. If subagents are
6
+ unavailable, run the same lanes sequentially; never skip a surface silently.
7
+
8
+ The CLI does not start language models. JSON is reserved for Fimo schemas and
9
+ content payloads. Worker ownership, dependencies, reports, and unresolved work
10
+ stay in `.fimo/migration/*.md` or the agents' plain-text responses.
11
+
12
+ ## Schedule
13
+
14
+ Plan a lane only when the source proves that surface exists:
15
+
16
+ | worker | owns | starts when |
17
+ | --------------- | ----------------------------------------------- | ------------------------ |
18
+ | runtime | framework/runtime files and provider config | immediately |
19
+ | routes | route modules, redirects, SEO and host behavior | immediately |
20
+ | content planner | schemas, content payloads, and content handoff | immediately |
21
+ | locales | locale setup and translated UI copy | immediately |
22
+ | assets/forms | media uploads and form behavior | after content planner |
23
+ | content data | one schema/locale import | after assets |
24
+ | content code | listed consuming files | after its data read-back |
25
+ | validator | read-only final checks | after all writers |
26
+
27
+ This is preserve mode, the default. When the user explicitly chose a framework
28
+ conversion, one framework worker replaces runtime and routes and owns all
29
+ structural target code. The content planner may run beside it. Data then waits
30
+ for both the asset and framework gates, and code waits for real imported-data
31
+ read-back.
32
+
33
+ ## Ownership
34
+
35
+ - **runtime** preserves the detected framework, router, runtime, dependencies,
36
+ provider setup, environment wiring, and provider-specific configuration. An
37
+ unclear or unsupported setup produces a question, not a silent conversion.
38
+ - **routes** preserves every route, redirect, 404, SEO/OG/social output,
39
+ sitemap, robots, feeds, headers, and other observable host behavior. A file
40
+ that consumes migrated content belongs to its later content-code worker.
41
+ - **content planner** discovers and models all editable content, labels,
42
+ consumers, schemas, payloads, media obligations, and execution batches. It
43
+ never imports entries or rewrites consumers. Read
44
+ `references/workers/content-planner.md`.
45
+ - **assets/forms** uploads every planner media obligation and patches payload
46
+ references. It replaces a form or integration only when Fimo preserves its
47
+ behavior end to end; otherwise it preserves or reports it.
48
+ - **content data and code** execute the planner handoff without rediscovering
49
+ or redesigning it. Read `references/workers/content-execution.md`.
50
+ - **locales** owns locale configuration, locale routing, and translated
51
+ visitor-visible labels.
52
+ - **framework conversion** is used only after explicit user choice. Read
53
+ `references/workers/framework.md`.
54
+ - **validator** authors nothing. Read `references/workers/validator.md`.
55
+
56
+ If two lanes need one file, name one owner in the text plan and sequence the
57
+ other after it. Do not add a metadata format for a small overlap.
58
+
59
+ ## Coordinator gates
60
+
61
+ 1. Run `fimo migrate init` and inspect the real target paths before workers
62
+ write.
63
+ 2. Start runtime/routes/content-planner/locales together, or the framework
64
+ worker plus content planner/locales in conversion mode.
65
+ 3. After the content plan, upload every planned asset and patch payloads.
66
+ 4. Start data workers only after the asset gate and, in conversion mode, the
67
+ framework gate.
68
+ 5. Start each code worker only after its own imported records read back as
69
+ non-empty. A build over empty data proves nothing.
70
+ 6. Start the independent validator only after every writer has returned.
71
+
72
+ Each prompt names the worker's source paths, exact target ownership, applicable
73
+ reference above, and dependencies. Each report states status, duration, source
74
+ evidence, files changed, Fimo writes, source items handled, unresolved work,
75
+ and the next action. The coordinator verifies those claims against `git diff`,
76
+ CLI read-back, and rendered routes.
77
+
78
+ A source item is covered only when its target value exists and the application
79
+ consumes it at the original behavior path, or when an explicit unresolved item
80
+ names the impact and owner action. If validation fails, create one bounded
81
+ repair task for that surface and rerun the validator; do not restart every
82
+ worker.
@@ -1,194 +1,142 @@
1
1
  # Migration Workflow
2
2
 
3
- Use this as the phase contract for complete migrations.
4
-
5
- ## Phase 0: Target Safety
6
-
7
- 1. Confirm the target path.
8
- 2. If the target path is missing, create exactly one Fimo project there.
9
- 3. If it has `.fimo/project.json` or the legacy `.fimo.settings.json`, reuse it.
10
- 4. If it is non-empty and not a Fimo project, stop and ask for a target path.
11
- 5. Never overwrite user work outside generated migration folders without reading
12
- the existing files first.
13
-
14
- ## Phase 1: Source Intake
15
-
16
- Classify all available evidence:
17
-
18
- - published URLs and sitemap URLs
19
- - downloaded HTML, source repo, builder export, or static export
20
- - CMS CSV/XML/JSON exports
21
- - media folders and remote media URLs
22
- - forms and third-party form actions
23
- - redirects, locales, SEO metadata, robots/sitemap data
24
- - unsupported app behavior such as auth, commerce, search, members, custom JS
25
-
26
- For source-backed migrations, inspect the source/export directly with shell
27
- tools such as `rg`, `find`, `ls`, and targeted file reads. Treat CMS exports and
28
- media folders as source-of-truth evidence, then copy normalized facts into the
29
- canonical ledger.
30
-
31
- For URL-only migrations, run `fimo migrate <url> [dir]` and inspect
32
- `.fimo/migrations/current/`.
33
-
34
- Read these URL migration artifacts first when they exist:
35
-
36
- - `.fimo/migrations/current/brief.md`
37
- - `.fimo/migrations/current/manifest.json`
38
- - `.fimo/migrations/current/extracted/pages.json`
39
- - `.fimo/migrations/current/extracted/forms.json`
40
- - `.fimo/migrations/current/extracted/design-tokens.json`
41
- - `.fimo/migrations/current/refine/agent-prompt.md`
42
- - `.fimo/migrations/current/refine/pages/*.md`
43
-
44
- When default crawling misses client-rendered or lazy-loaded content, use the
45
- agent or harness browser tools to collect additional HTML, screenshots, and route
46
- notes, then merge that evidence into the migration artifacts. Import reviewed
47
- media, schemas, forms, and entries through the regular Fimo CLI commands.
48
-
49
- ## Phase 2: Canonical Ledger
50
-
51
- Create `.fimo/migration/manifest.json` using `references/manifest.md`.
52
-
53
- If an older ledger exists under `.fimo/migrations/current/` or
54
- `.fimo/source-migration/`, keep it as evidence and copy normalized facts into the
55
- canonical ledger instead of editing unrelated history.
56
-
57
- Use the bundled script when possible:
58
-
59
- ```bash
60
- node <this-skill>/scripts/build-canonical-manifest.mjs <project-root>
61
- ```
62
-
63
- Pass `--fresh` only when intentionally discarding previous canonical manifest
64
- progress such as verified statuses, uploaded asset IDs, or notes.
65
-
66
- Every item needs one of these statuses:
67
-
68
- - `discovered`
69
- - `planned`
70
- - `generated`
71
- - `imported`
72
- - `verified`
73
- - `ignored`
74
- - `unsupported`
75
- - `unresolved`
76
-
77
- ## Phase 3: Content Model First
78
-
79
- Before writing page code:
80
-
81
- 1. Detect dynamic collections from both repeated route groups AND repeated
82
- in-page blocks. A hardcoded array of 3+ structurally-identical items (cards,
83
- list rows, tiles) is a collection, not static markup. Ignore locale prefixes
84
- when naming collections.
85
- 2. Map each CMS export or inferred collection to a Fimo schema or unresolved item.
86
- 3. Preserve stable source IDs, slugs, dates, SEO, authors, categories, tags,
87
- locales, and publish status.
88
- 4. Decide which references are real. Do not invent references from vague text.
89
- 5. Build seed/import entries with source IDs and media references preserved.
90
- 6. Record source count and planned import count for each content type.
91
-
92
- Use `references/content.md`, including "Detecting Dynamic Collections".
93
-
94
- ## Phase 4: Media And Forms
95
-
96
- Before final page wiring:
97
-
98
- 1. Build a media map from local files and remote URLs.
99
- 2. Upload or plan uploads for media referenced by pages, CMS entries, SEO, and
100
- forms.
101
- 3. Replace source media references only after upload mapping is known.
102
- 4. Classify forms as Fimo-native, third-party integration, or unsupported.
103
- 5. Generate `src/forms/*.json` for accepted Fimo-native forms.
104
-
105
- Use `references/media.md` and `references/forms.md`.
106
-
107
- ## Phase 5: Import Payloads
108
-
109
- Before calling the migration complete, prepare the actual import path described
110
- in `references/import-contract.md`.
111
-
112
- Required order:
113
-
114
- 1. media files
115
- 2. schemas
116
- 3. CMS entries with media references resolved
117
- 4. forms
118
-
119
- Record target IDs, import counts, failures, and unresolved items in the
120
- canonical ledger. Generated JSON without import counts is still draft state.
121
-
122
- ## Phase 6: Fimo Implementation
123
-
124
- Implement routes, schemas, forms, entries, media, redirects, translations, and
125
- React pages with Fimo conventions.
126
-
127
- Rules:
128
-
129
- - If no target exists, create one Fimo project. Do not create a nested Fimo app
130
- inside a source repository unless the user explicitly chose that directory.
131
- - If a target Fimo project exists, inspect existing routes, schemas, forms, and
132
- components before writing.
133
- - Store migration analysis artifacts under `.fimo/migration/`.
134
- - Use source CSS/design files as visual evidence, not as a permanent global CSS
135
- dump.
136
- - Schema-driven media renders with Fimo media primitives, not raw source URLs.
137
- - CMS pages must have matching `src/schemas/*.json` before generated clients or
138
- queries are used.
139
- - Repeated dynamic items (games, locations, posts, testimonials, pricing) render
140
- from CMS collections, not hardcoded arrays. A page left with a hardcoded array
141
- of collection-shaped items is an incomplete migration, not a finished one.
142
- - Generated `.ts` schema/form clients are not edited manually.
143
- - Unsupported source behavior is replaced with a Fimo-native equivalent or shown
144
- as unresolved, never hidden behind broken UI.
145
-
146
- ## Phase 7: Import
147
-
148
- Import only reviewed artifacts:
149
-
150
- - media assets and media map updates
151
- - schemas
152
- - forms
153
- - entries
154
- - redirects/locales when supported by the current project tooling
155
-
156
- After import, update the ledger with created IDs, uploaded asset IDs, failures,
157
- and counts.
158
-
159
- ## Phase 8: QA Gate And Report
160
-
161
- Run `references/qa.md`. Write `.fimo/migration/migration-report.md` with:
162
-
163
- - source summary
164
- - route coverage
165
- - CMS source/import counts
166
- - media source/upload/reference counts
167
- - form coverage
168
- - build/runtime checks
169
- - visual checks
170
- - unresolved/unsupported items
171
- - exact next actions
172
-
173
- Use the bundled report script to make the QA state explicit:
174
-
175
- ```bash
176
- node <this-skill>/scripts/write-migration-report.mjs <project-root>
177
- ```
178
-
179
- The script exits non-zero when required coverage checks fail. That is a prompt
180
- to continue the migration or document the gaps, not a reason to hide the report.
181
-
182
- All checks in this phase are **local** (build, local dev, route render, visual
183
- comparison). Do not run `fimo deploy` / `fimo publish` to verify anything.
184
-
185
- ## Phase 9: Propose Deployment
186
-
187
- Deployment is not part of the migration loop and is never run to preview or
188
- verify. Once Phase 8 passes:
189
-
190
- 1. Do not run `fimo deploy` or `fimo publish` yourself.
191
- 2. End by proposing it: tell the owner the migration is ready, that one
192
- `fimo deploy` creates its hosted preview, and that going live requires a
193
- separate explicit publish.
194
- 3. Deploy only if the owner explicitly asks in this turn, and then only once.
3
+ Use this as the phase contract for a complete migration. The coordinator and
4
+ workers communicate in plain text. JSON is used only for Fimo schemas and the
5
+ content payloads that the data-plane commands import.
6
+
7
+ ## Phase 0: Initialize the target
8
+
9
+ 1. Confirm the target path. The target is a separate directory; the source
10
+ checkout remains read-only evidence.
11
+ 2. Initialize or reuse exactly one linked Fimo target before workers start:
12
+ - URL migration: `fimo migrate init <source-url> <target-dir> --framework <framework>`
13
+ - link an existing project: `fimo migrate init <target-dir> --project-id <projectId> --framework <framework>`
14
+ - create a project: `fimo migrate init <target-dir> --org <organizationId> --framework <framework>`
15
+ Use the detected source framework for source-backed migrations. A framework
16
+ conversion requires an explicit user choice; URL-only and rebuild
17
+ migrations ask the user which framework to use. Never choose a framework by
18
+ copying an arbitrary `--template-root`, invent a project ID, or hand-write
19
+ `.fimo/project.json`.
20
+ 3. Inspect the target's real `package.json`, `.fimo/config.json`, framework config, and route
21
+ directories. They are the authority for paths. Do not infer an app root
22
+ from a skill example and do not create a second `app/` or `src/app/` tree.
23
+ 4. If the target is non-empty and not a Fimo project, stop and ask for a target
24
+ path; do not overlay a template on top of it.
25
+ 5. Keep source material in `.fimo/migration/source` or another explicit source
26
+ location. Do not copy source files over the initialized target root.
27
+
28
+ Write a short `.fimo/migration/migration-plan.md` containing the source
29
+ location, selected framework, actual target directories, worker owners, and
30
+ known questions. Do not create `target.json`, `manifest.json`,
31
+ `worker-plan.json`, `decision.json`, or JSON worker receipts for a new run.
32
+
33
+ ## Phase 1: Source intake
34
+
35
+ Read the source directly with `rg`, `find`, `ls`, and targeted file reads.
36
+ Classify the available evidence:
37
+
38
+ - source repository, export, downloaded HTML, or media folder;
39
+ - CMS CSV/XML/JSON exports and public APIs;
40
+ - forms and third-party form actions;
41
+ - integrations and the environment-key names they need, never secret values;
42
+ - redirects, security headers, locales, SEO, robots, sitemap, and OG behavior;
43
+ - unsupported behavior such as auth, commerce, search, members, custom JS, or
44
+ provider-specific workers.
45
+
46
+ For private APIs or CMSs, ask for a user-provided export or a narrowly scoped
47
+ server-side credential. Never recover credentials from browser bundles or copy
48
+ them into migration artifacts. Missing access blocks only that lane and becomes
49
+ an unresolved item; never invent replacement content.
50
+
51
+ For URL-only migrations, run `fimo migrate <url> [dir]` and inspect the
52
+ generated `.fimo/migrations/current/` files as source evidence. Do not copy
53
+ that crawl manifest into another canonical JSON registry.
54
+
55
+ ## Phase 2: Fan out workers
56
+
57
+ The coordinator launches only the workers supported by the source:
58
+
59
+ - **runtime**: preserve the detected framework, router, runtime, dependencies,
60
+ provider configuration, and environment wiring. A framework conversion needs
61
+ an explicit user choice.
62
+ - **routes/SEO**: preserve one target route per source route, redirects, 404,
63
+ metadata, OG/social output, sitemap, robots, and other observable behavior.
64
+ - **content planner**: discover content, labels, data sources, consumers, and
65
+ schemas; push schemas and prepare content payloads. It does not rewrite page
66
+ code or import every entry itself.
67
+ - **locales**: configure locales and migrate translated UI-visible copy when
68
+ the source has it.
69
+ - **assets/forms**: after content planning, upload every referenced media item
70
+ and preserve, replace, or report forms and integrations.
71
+
72
+ When the user explicitly chose a framework conversion, one framework
73
+ conversion worker replaces the runtime and routes lanes and owns all
74
+ structural target code (see `references/workers/framework.md`). The content
75
+ planner may read the source in parallel, but it must not convert the framework
76
+ or rewrite page code. Follow the asset, data, and code gates in
77
+ `references/workers.md`.
78
+
79
+ The coordinator gives each worker a plain-language prompt naming its ownership,
80
+ files, dependencies, and worker-specific reference from `references/workers/`.
81
+ Workers may write the application inside their ownership. They do not need a
82
+ JSON plan or receipt. If two workers need the same file, name one owner and run
83
+ the other after it.
84
+
85
+ ## Phase 3: Content planning
86
+
87
+ The planner follows `references/workers/content-planner.md`, plus
88
+ `references/content.md`, `references/decision.md`, and
89
+ `references/import-contract.md`. Its text plan and payloads must be complete
90
+ before Phase 4; data workers must not rediscover unrelated source files.
91
+
92
+ ## Phase 4: Media, forms, and integrations
93
+
94
+ 1. Account for every planner media obligation, including schema media fields
95
+ and richtext/Tiptap image nodes, plus route, SEO, and form media.
96
+ 2. Upload media through Fimo and replace references only after the upload is
97
+ confirmed. A local `public/` copy or source URL is not an imported asset.
98
+ 3. Preserve third-party integrations unless Fimo reproduces their exact
99
+ user-visible behavior. Record required environment-key names only.
100
+ 4. Use a Fimo-native form only when it matches the source behavior end to end;
101
+ otherwise preserve the integration or report it unresolved.
102
+
103
+ After every media obligation has a target mapping, patch the content payloads
104
+ and run one data worker per schema/locale. Verify each imported batch by
105
+ read-back before starting its content code worker. The code worker replaces
106
+ each planned consumer in place and proves at least one real imported item
107
+ crosses every Server-to-Client or plain-JSON boundary it uses. A build over an
108
+ empty result is not proof. Load the active `fimo-code` framework reference for
109
+ the exact serialization and hydration contract.
110
+
111
+ ## Phase 5: Framework implementation
112
+
113
+ Preserve the detected source framework, router, runtime, and configuration.
114
+ React Router/Vite stays React Router/Vite and Next.js stays Next.js. Convert to
115
+ Next.js only after the user explicitly chooses it. An explicit conversion is a
116
+ faithful first pass owned by the framework conversion worker: it ports the
117
+ source's APIs, loaders, hardcoded content, integrations, and visible behavior
118
+ into the new framework, and it must pass the framework gate in
119
+ `references/workers/framework.md` before content code work continues. A gate
120
+ failure is draft-only or unresolved; never fall back silently to a generic
121
+ shell or another framework. Load the matching `fimo-code` framework and
122
+ hosting references before integration work.
123
+
124
+ Preserve the source route surface and behavior. Do not replace many pages with
125
+ one generic static shell. Apply the matching framework reference before
126
+ disposing of provider-specific rules; redirects, headers, feeds, metadata,
127
+ forms, and freshness behavior are observable contracts.
128
+
129
+ ## Phase 6: Fan in, validate, and report
130
+
131
+ Workers return the plain-text receipt defined in `references/workers.md`.
132
+ The coordinator checks those claims against the diff, source, CLI read-back,
133
+ build, and rendered routes. Then an independent worker follows
134
+ `references/workers/validator.md`; a worker saying "done" is not evidence.
135
+
136
+ Write `.fimo/migration/migration-report.md` with route/content/media/form/SEO
137
+ coverage, import counts, worker timings, unresolved items, and next actions.
138
+ Use `complete` only when required checks pass, `complete-with-unresolved` when
139
+ the app works and every gap is explicit, and `draft-only` when import or
140
+ verification is incomplete.
141
+
142
+ All checks are local. Do not deploy or publish to verify a migration.