@domain-first/project-structure 8.10.0 → 8.11.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 (50) hide show
  1. package/README.md +17 -7
  2. package/dist/115.js +142 -141
  3. package/dist/201.js +10 -1
  4. package/dist/287.js +983 -434
  5. package/dist/364.js +79 -0
  6. package/dist/38.js +29 -13
  7. package/dist/561.js +167 -93
  8. package/dist/agent-cli.d.ts +13 -2
  9. package/dist/agent-requests.d.ts +76 -2
  10. package/dist/config-file.d.ts +25 -1
  11. package/dist/frontend-cli.d.ts +3 -0
  12. package/dist/frontend-modules.d.ts +9 -0
  13. package/dist/graph.cjs +10 -1
  14. package/dist/index.cjs +3470 -2913
  15. package/dist/init.cjs +325 -83
  16. package/dist/integration.cjs +3470 -2913
  17. package/dist/integrations/openapi.d.ts +9 -2
  18. package/dist/integrations/orval.d.ts +31 -4
  19. package/dist/integrations/rest-endpoint-generator.d.ts +11 -7
  20. package/dist/integrations/storybook.d.ts +19 -1
  21. package/dist/lint.cjs +40 -15
  22. package/dist/lint.js +1 -1
  23. package/dist/page-router.d.ts +18 -0
  24. package/dist/react-module-move.d.ts +27 -12
  25. package/dist/react.cjs +1577 -993
  26. package/dist/react.js +2 -102
  27. package/dist/rest-adapters.d.ts +13 -0
  28. package/dist/svelte-agent-cli.spec.d.ts +1 -0
  29. package/dist/svelte.cjs +7311 -0
  30. package/dist/svelte.d.ts +2 -0
  31. package/dist/svelte.js +3 -0
  32. package/dist/sveltekit-app.d.ts +7 -0
  33. package/dist/upgrade-steps.d.ts +6 -1
  34. package/dist/upgrade.cjs +12 -2
  35. package/dist/use-cases/add-integration.d.ts +1 -1
  36. package/dist/use-cases/delete-react-module.d.ts +4 -4
  37. package/dist/use-cases/index.d.ts +1 -0
  38. package/dist/use-cases/move-react-module.d.ts +2 -2
  39. package/dist/use-cases/rest-endpoint-generator.d.ts +6 -4
  40. package/dist/use-cases/scaffold-svelte-modules.d.ts +22 -0
  41. package/package.json +2 -1
  42. package/skills/df-ps-implement/SKILL.md +3 -3
  43. package/skills/df-ps-plan-feature/SKILL.md +2 -2
  44. package/skills/df-ps-scaffold/SKILL.md +11 -10
  45. package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
  46. package/skills/df-ps-scaffold/references/agent-operations.md +8 -4
  47. package/skills/df-ps-scaffold/references/generators.md +1 -1
  48. package/skills/df-ps-scaffold/references/work-plan.md +1 -1
  49. package/skills/df-ps-svelte/SKILL.md +49 -0
  50. package/skills/df-ps-svelte/references/generators.md +56 -0
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/svelte.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { runFrontendCLI } from "./364.js";
3
+ runFrontendCLI('svelte');
@@ -0,0 +1,7 @@
1
+ /** SvelteKit is used only when the config selects it explicitly. */
2
+ export declare const usesSvelteKit: () => boolean;
3
+ /**
4
+ * The routes folder: `src/routes`, SvelteKit's default, or `routes` when
5
+ * only that one exists.
6
+ */
7
+ export declare const svelteKitRoutesFolder: (root: string) => string;
@@ -81,7 +81,7 @@ export declare const planUpgrade: (config: unknown, acceptOptional?: (step: Plan
81
81
  add?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
82
82
  remove?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
83
83
  }>> | undefined;
84
- lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "clock" | "config", boolean>> | undefined;
84
+ lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "svelte" | "clock" | "config", boolean>> | undefined;
85
85
  } | undefined;
86
86
  } | undefined;
87
87
  frontend?: {
@@ -91,6 +91,11 @@ export declare const planUpgrade: (config: unknown, acceptOptional?: (step: Plan
91
91
  framework?: "react" | "next" | undefined;
92
92
  storybookFramework?: string | undefined;
93
93
  } | undefined;
94
+ svelte?: {
95
+ [x: string]: unknown;
96
+ framework?: "svelte" | "sveltekit" | undefined;
97
+ storybookFramework?: string | undefined;
98
+ } | undefined;
94
99
  } | undefined;
95
100
  } | undefined;
96
101
  }>;
package/dist/upgrade.cjs CHANGED
@@ -257,6 +257,7 @@ const lintChecks = [
257
257
  'layers',
258
258
  'dependencies',
259
259
  'react',
260
+ 'svelte',
260
261
  'clock',
261
262
  'config'
262
263
  ];
@@ -301,8 +302,16 @@ const reactConfigSchema = external_zod_default().object({
301
302
  ]).optional(),
302
303
  storybookFramework: external_zod_default().string().optional()
303
304
  }).passthrough();
305
+ const svelteConfigSchema = external_zod_default().object({
306
+ framework: external_zod_default()["enum"]([
307
+ 'svelte',
308
+ 'sveltekit'
309
+ ]).optional(),
310
+ storybookFramework: external_zod_default().string().optional()
311
+ }).passthrough();
304
312
  const frontendConfigSchema = external_zod_default().object({
305
- react: reactConfigSchema.optional()
313
+ react: reactConfigSchema.optional(),
314
+ svelte: svelteConfigSchema.optional()
306
315
  }).passthrough();
307
316
  const configSchema = external_zod_default().object({
308
317
  project: projectConfigSchema,
@@ -564,13 +573,14 @@ const ignoredFolders = new Set([
564
573
  'node_modules',
565
574
  '.git',
566
575
  '.next',
576
+ '.svelte-kit',
567
577
  'dist',
568
578
  'build',
569
579
  'out',
570
580
  'coverage',
571
581
  'storybook-static'
572
582
  ]);
573
- const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx)$/;
583
+ const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx|svelte)$/;
574
584
  const module_move_walk = (folder)=>{
575
585
  if (!external_node_fs_default().existsSync(folder)) return [];
576
586
  return external_node_fs_default().readdirSync(folder, {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Integrations are shown by group, but selected ones run in this order, each one seeing the changes of
3
- * the previous ones: Storybook configures `frontend.react` for the Swagger UI page
3
+ * the previous ones: Storybook configures `frontend.react` (or follows `frontend.svelte`) for the Swagger UI page
4
4
  * of OpenAPI, integration tests read the Prisma and Drizzle configs and the Vitest
5
5
  * config, Orval reads the OpenAPI document path.
6
6
  */
@@ -1,8 +1,8 @@
1
1
  import { type Folder } from '../file-system';
2
- import { type ReactModuleKind } from '../react-module-move';
2
+ import { type FrontendFramework, type ReactModuleKind } from '../react-module-move';
3
3
  /**
4
4
  * Deletes a page or widget with its files once nothing else imports it.
5
- * With Next.js, a page's own route can go with it: its URL stops working,
6
- * so it is asked.
5
+ * With Next.js or SvelteKit, a page's own route can go with it: its URL
6
+ * stops working, so it is asked.
7
7
  */
8
- export declare const deleteReactModuleUseCase: (presentationReactFolder: Folder, kind: ReactModuleKind) => Promise<void>;
8
+ export declare const deleteReactModuleUseCase: (presentationReactFolder: Folder, kind: ReactModuleKind, framework?: FrontendFramework) => Promise<void>;
@@ -23,4 +23,5 @@ export * from './scaffold-react-page';
23
23
  export * from './scaffold-react-shared-hook';
24
24
  export * from './scaffold-react-ui-kit-component';
25
25
  export * from './scaffold-react-widget';
26
+ export * from './scaffold-svelte-modules';
26
27
  export * from './wire-dependency';
@@ -1,3 +1,3 @@
1
1
  import { type Folder } from '../file-system';
2
- import { type ReactModuleKind } from '../react-module-move';
3
- export declare const moveReactModuleUseCase: (presentationReactFolder: Folder, kind: ReactModuleKind) => Promise<void>;
2
+ import { type FrontendFramework, type ReactModuleKind } from '../react-module-move';
3
+ export declare const moveReactModuleUseCase: (presentationReactFolder: Folder, kind: ReactModuleKind, framework?: FrontendFramework) => Promise<void>;
@@ -1,12 +1,14 @@
1
1
  import { File, type Folder } from '../file-system';
2
+ import { type RestAdapter } from '../rest-adapters';
2
3
  /**
3
4
  * The one endpoint generator of the project: a Shared Kernel presentation
4
5
  * service, scaffolded like any other. Every generating method is a getter
5
- * typed as `EndpointGenerator`. With `withNextAdapter`, the adapter is
6
- * `nextAdapter` of `@domain-first/handlers-next` instead of a placeholder.
6
+ * typed as `EndpointGenerator`. With a framework `adapter`, it is
7
+ * `nextAdapter` of `@domain-first/handlers-next` or `svelteAdapter` of
8
+ * `@domain-first/handlers-svelte` instead of a placeholder.
7
9
  */
8
- export declare const scaffoldRestEndpointGenerator: (sharedFolder: Folder, { withNextAdapter }?: {
9
- withNextAdapter?: boolean;
10
+ export declare const scaffoldRestEndpointGenerator: (sharedFolder: Folder, { adapter: framework }?: {
11
+ adapter?: RestAdapter;
10
12
  }) => File | undefined;
11
13
  /**
12
14
  * The generator's type and factory, or undefined in projects initialized
@@ -0,0 +1,22 @@
1
+ import { type Folder } from '../file-system';
2
+ import { NestedName } from '../nested-name';
3
+ /**
4
+ * A Svelte 5 component: the props type is exported from the module
5
+ * script, so importers can use it as with `export type` in React.
6
+ */
7
+ export declare const svelteComponentContent: (propsType: string) => string;
8
+ /** A thin SvelteKit route that renders the page component. */
9
+ export declare const svelteKitRouteContent: (ClassName: string, pageImport: string) => string;
10
+ /**
11
+ * With SvelteKit, the page also gets its route at the same path, e.g.
12
+ * `admin/users` → `src/routes/admin/users/+page.svelte`. An existing route
13
+ * is kept: it may hold the user's code, and the returned hint says so.
14
+ */
15
+ export declare const scaffoldSvelteKitRoute: (name: NestedName, pagePath: string) => string | undefined;
16
+ export declare const scaffoldSveltePage: (presentationSvelteFolder: Folder) => Promise<void>;
17
+ export declare const scaffoldSvelteWidget: (presentationSvelteFolder: Folder) => Promise<void>;
18
+ export declare const scaffoldSvelteUIKitComponent: (presentationSvelteFolder: Folder) => Promise<void>;
19
+ /**
20
+ * A shared hook is a `.svelte.ts` module, so it may use runes.
21
+ */
22
+ export declare const scaffoldSvelteSharedHook: (presentationSvelteFolder: Folder) => Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@domain-first/project-structure",
3
3
  "description": "Build and manage your Domain-First project structure with CLI",
4
- "version": "8.10.0",
4
+ "version": "8.11.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,6 +19,7 @@
19
19
  "df-init": "./dist/init.js",
20
20
  "df-scaffold": "./dist/index.js",
21
21
  "df-react": "./dist/react.js",
22
+ "df-svelte": "./dist/svelte.js",
22
23
  "df-integration": "./dist/integration.js",
23
24
  "df-skills": "./bin/df-skills.mjs",
24
25
  "df-lint": "./dist/lint.js",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: df-ps-implement
3
- description: Fill in code generated by the `df-scaffold` CLI (@domain-first/project-structure) — aggregates, entities and value objects (@domain-first/types), repositories, handler schemas (@domain-first/handlers), errors (@domain-first/errors), wiring (@domain-first/wire), handlers-rest endpoints, tests — while keeping bounded contexts isolated. React modules: df-ps-react. Use after scaffolding, or when the user asks to implement, connect, or wire Domain-First components in a project with domain-first.project-structure.config.json.
3
+ description: Fill in code generated by the `df-scaffold` CLI (@domain-first/project-structure) — aggregates, entities and value objects (@domain-first/types), repositories, handler schemas (@domain-first/handlers), errors (@domain-first/errors), wiring (@domain-first/wire), handlers-rest endpoints, tests — while keeping bounded contexts isolated. React modules: df-ps-react; Svelte modules: df-ps-svelte. Use after scaffolding, or when the user asks to implement, connect, or wire Domain-First components in a project with domain-first.project-structure.config.json.
4
4
  ---
5
5
 
6
6
  # Implement Domain-First scaffolds
@@ -27,7 +27,7 @@ Context A's domain and application import nothing from B. Direct calls are confi
27
27
  - Refer to B's entities by id only.
28
28
  - `shared-kernel/` may import any context's **`domain/errors`** (e.g. to map them to HTTP statuses), and nothing else from a context. The one exception: the shared in-memory DB, `shared-kernel/infrastructure/services/in-memory-db-infrastructure-service.ts`, may also import any context's **domain models** (aggregate roots, entities, value objects: the `domainType` classes under `domain/aggregates/`, `domain/entities/`, `domain/value-objects/`) to type its sections, never repository contracts or anything outside `domain/`. Don't move a context's domain concepts into `shared-kernel/` to share them between contexts; only universal entities / value objects (`money`, `email`) live there.
29
29
  - `<rootFolder>/presentation/rest/` (the generated `wires.ts`, `index.ts`) may import every context's REST wiring.
30
- - `<rootFolder>/presentation/react/` imports **nothing** from contexts whenever it can avoid it: a generated API client first, `import type` of endpoint contracts only without one (`df-ps-react`, "Talking to the backend").
30
+ - `<rootFolder>/presentation/react/` (and `presentation/svelte/`) imports **nothing** from contexts whenever it can avoid it: a generated API client first, `import type` of endpoint contracts only without one (`df-ps-react`, "Talking to the backend").
31
31
  - Need a forbidden import? A's own port or its cross-context adapter is missing. Plan it and generate it.
32
32
 
33
33
  Check before reporting done; fix every finding:
@@ -94,7 +94,7 @@ export const wirePlaceOrderUseCase = wireClass(PlaceOrderUseCase, [
94
94
 
95
95
  ## React
96
96
 
97
- Pages, widgets, UI-kit components, shared hooks and stories, and how they reach the backend: `df-ps-react`.
97
+ Pages, widgets, UI-kit components, shared hooks and stories, and how they reach the backend: `df-ps-react` (Svelte: `df-ps-svelte`).
98
98
 
99
99
  ## Tests
100
100
 
@@ -5,7 +5,7 @@ description: Turn an abstract feature request into a Domain-First plan for a pro
5
5
 
6
6
  # Plan a feature
7
7
 
8
- Understand → decompose → assign → get approval → hand off. A feature creates files, so nothing is generated or written before approval (`df-ps-scaffold`, rule 1). Only the user's literal request to skip the plan ("skip the plan", "with plan skipped", etc.) removes this step. However direct or urgent any other wording sounds, it is a request to write the plan.
8
+ Understand → decompose → assign → get approval → hand off. A feature creates files, so nothing is generated or written before approval (`df-ps-scaffold`, rule 1). This step is removed only when the user explicitly says that no plan is needed: the message names the plan itself and declines it ("skip the plan", "without a plan", "no plan needed"), in whatever language the user writes. A request that doesn't mention the plan ("let's build the order export", "just do it") is always a request to write the plan, however direct or urgent it sounds.
9
9
 
10
10
  ## 1. Understand what exists
11
11
 
@@ -25,7 +25,7 @@ For each affected context, note what it owns, what it does, its language, and th
25
25
 
26
26
  ## 2. Decompose
27
27
 
28
- Split the request into pieces of logic and choose each piece's component with `df-ps-scaffold/references/choosing-components.md` (pieces of UI: `df-ps-react`, "Choosing the module"). Record the deciding step for the "Why" in the plan: `choosing-components, step N` for a component, `step 3, rule N` (below) for a placement.
28
+ Split the request into pieces of logic and choose each piece's component with `df-ps-scaffold/references/choosing-components.md` (pieces of UI: `df-ps-react`, "Choosing the module"; Svelte projects run them with `df-svelte`). Record the deciding step for the "Why" in the plan: `choosing-components, step N` for a component, `step 3, rule N` (below) for a placement.
29
29
 
30
30
  ## 3. Assign to contexts
31
31
 
@@ -9,13 +9,13 @@ description: Generate Domain-First components with the `df-scaffold` CLI (@domai
9
9
 
10
10
  Follow this order for every request:
11
11
 
12
- 1. Read `domain-first.project-structure.config.json` beside the nearest `package.json`: `project.rootFolder`, `backend` (including `backend.implementations` and `backend.rules`), and `frontend`. `frontend.react.framework` records React (`react`) or Next.js (`next`); both use `df-react`. Initialization and configuration belong to the human: never run `df-init` or manually add/change these settings. If the config is missing, tell the user to run `npx df-init`; if backend work needs an absent `backend`, tell them to run `npx df-init --section backend`. Continue only with work whose required sections are configured. A config of an earlier major version (flat, without `project`) makes every command stop with `run npx df-upgrade` (`CONFIG_OUTDATED` in JSON mode): ask the user to run `npx df-upgrade`; never run it or convert the config yourself. `df-init` scaffolds explicit standard lists and enabled lint checks under `backend.rules`; read the saved values as authoritative. Older or partial configs may omit entries, which retain the defaults. Backend reconfiguration by the user fills missing entries without resetting existing rules.
12
+ 1. Read `domain-first.project-structure.config.json` beside the nearest `package.json`: `project.rootFolder`, `backend` (including `backend.implementations` and `backend.rules`), and `frontend`. `frontend.react.framework` records React (`react`) or Next.js (`next`); both use `df-react`. `frontend.svelte.framework` records Svelte (`svelte`) or SvelteKit (`sveltekit`); both use `df-svelte`. Initialization and configuration belong to the human: never run `df-init` or manually add/change these settings. If the config is missing, tell the user to run `npx df-init`; if backend work needs an absent `backend`, tell them to run `npx df-init --section backend`. Continue only with work whose required sections are configured. A config of an earlier major version (flat, without `project`) makes every command stop with `run npx df-upgrade` (`CONFIG_OUTDATED` in JSON mode): ask the user to run `npx df-upgrade`; never run it or convert the config yourself. `df-init` scaffolds explicit standard lists and enabled lint checks under `backend.rules`; read the saved values as authoritative. Older or partial configs may omit entries, which retain the defaults. Backend reconfiguration by the user fills missing entries without resetting existing rules.
13
13
  2. Feature request without named contexts/components → `df-ps-plan-feature` (it covers steps 3–5).
14
- 3. Choose a component for each piece of logic with `references/choosing-components.md`. Pieces of UI (pages, widgets, UI-kit components, shared hooks): `df-ps-react`.
14
+ 3. Choose a component for each piece of logic with `references/choosing-components.md`. Pieces of UI (pages, widgets, UI-kit components, shared hooks): `df-ps-react` (Svelte: `df-ps-svelte`).
15
15
  4. Read `references/units/<unit>.md` for every unit in the plan ("Units" below) and prepare the run details ("Preparing runs"). Read [agent-mode.md](references/agent-mode.md) for the JSON protocol and use `--describe` to obtain the installed request schema and selectable IDs.
16
16
  5. If the task creates files, show the work plan and **stop until it's approved** (rule 1).
17
17
  6. Run the generators in plan order with `--request` JSON; check exit code, `ok` and all returned file lists.
18
- 7. Implement each unit by the "Implement" and "Test" sections of its unit file and the general rules of `df-ps-implement`, in this order: domain → application → schema tool runs (migrations) → infrastructure → endpoints → other tool runs (OpenAPI, API client) → React (`df-ps-react`).
18
+ 7. Implement each unit by the "Implement" and "Test" sections of its unit file and the general rules of `df-ps-implement`, in this order: domain → application → schema tool runs (migrations) → infrastructure → endpoints → other tool runs (OpenAPI, API client) → React (`df-ps-react`) or Svelte (`df-ps-svelte`).
19
19
  8. Run `npx df-lint` and the project's tsc/lint/tests.
20
20
  9. Report against the plan.
21
21
 
@@ -23,24 +23,24 @@ Follow this order for every request:
23
23
 
24
24
  ### 1. Work plan approval
25
25
 
26
- **A task that creates any new file** (a df-scaffold run, or a hand-created file under rule 2) needs an approved work plan first, even for one component. The plan can be skipped only when the user literally asks to skip it for this task ("skip the plan", "пропусти план"). Anything else, however direct or urgent it sounds ("just do it", "build it now", "no need to ask"), is still a request that starts with a plan. This is about skipping the plan: once a plan is shown, an ordinary "yes" or "go ahead" approves it. Until approval, only read (`--describe` and `dryRun: true` do not write files). Files written by the project's own scripts (rule 2, exception 2) don't count: run those scripts when the work needs them.
26
+ **A task that creates any new file** (a df-scaffold run, or a hand-created file under rule 2) needs an approved work plan first, even for one component. The plan can be skipped only when the user explicitly says, for this task, that no plan is needed: the message names the plan itself and declines it ("skip the plan", "without a plan", "no plan needed"), in whatever language the user writes. A request that doesn't mention the plan always starts with one, however direct or urgent it sounds ("let's build the order export", "just do it", "build it now", "no need to ask"). Never infer that the user wants no plan from the size of the task, its urgency or earlier tasks. This is about skipping the plan: once a plan is shown, an ordinary "yes" or "go ahead" approves it. Until approval, only read (`--describe` and `dryRun: true` do not write files). Files written by the project's own scripts (rule 2, exception 2) don't count: run those scripts when the work needs them.
27
27
 
28
28
  Tasks that only edit existing files (a bug fix, a new field, a changed rule) don't need a plan: do them directly and say what you changed.
29
29
 
30
30
  Read [references/work-plan.md](references/work-plan.md), show the plan in that format and stop.
31
31
 
32
- - Approval must be explicit ("ok", "да", "делай"…). A question or silence isn't approval. Changes to the plan → show the updated plan and ask again.
32
+ - Approval must be explicit ("ok", "yes", "go ahead"…). A question or silence isn't approval. Changes to the plan → show the updated plan and ask again.
33
33
  - After approval, do exactly the plan. An extra module or file, or a different name/option → stop and get the delta approved. Edits to existing files needed along the way don't need approval; list them in the final report.
34
34
 
35
35
  ### 2. New files only through df-scaffold
36
36
 
37
- Every new file is created by `df-scaffold` (React modules: `df-react`). Don't create files with the Write tool, `touch`, redirects, or by copying templates. The only exceptions (`<C>` = `<rootFolder>/bounded-contexts/<context>`):
37
+ Every new file is created by `df-scaffold` (React modules: `df-react`; Svelte modules: `df-svelte`). Don't create files with the Write tool, `touch`, redirects, or by copying templates. The only exceptions (`<C>` = `<rootFolder>/bounded-contexts/<context>`):
38
38
 
39
39
  | # | Files | Location | Condition |
40
40
  | --- | --- | --- | --- |
41
41
  | 1 | Missing spec | `<component>.spec.ts` next to the component | Exactly from "Spec templates" in `references/generators.md`. |
42
42
  | 2 | Output of project tools | where the tool puts it | Migrations, codegen: run the project's script, use its output as-is; never hand-write or edit it. No approval needed for these files. |
43
- | 3 | Widget hooks / UI | `…/presentation/react/widgets/<name>/hooks/**`, `ui/**` | Widget generated by df-react. |
43
+ | 3 | Widget hooks / UI | `…/presentation/react/widgets/<name>/hooks/**`, `ui/**` (Svelte: `…/presentation/svelte/widgets/<name>/…`) | Widget generated by df-react or df-svelte. |
44
44
  | 4 | Widget/page/UI-kit support files | inside the widget folder or `ui-kit/<name>/`: styles, assets, `*.test.tsx`, `*.stories.tsx`; next to a page: `pages/<name>-page.module.css`, for a nested page in its folder (`pages/admin/admin-users-page.module.css`) (layout of its widgets only) | Widget/page/UI-kit component generated by df-react. Details and story templates: `df-ps-react`. |
45
45
  | 5 | App bootstrap and config | outside `<rootFolder>/{bounded-contexts,shared-kernel,presentation}/`: entry point, HTTP server setup registering `restHandlers`, tool configs | Bootstrapping only. Domain/application/infrastructure logic never goes there. |
46
46
 
@@ -48,7 +48,7 @@ Anything else (helpers, types, constants, mappers, wiring, barrels): put it in a
48
48
 
49
49
  If the CLI cannot run, report the failure and give the user the prepared JSON command to run themselves. Never hand-write its output. Missing generated files are only recreated by re-running the generator, as an approved overwrite.
50
50
 
51
- Moving, renaming and deleting a module go through the CLI too, never by hand, and need an approved plan: `references/units/move-or-rename.md`, `references/units/delete.md`; pages and widgets: `df-ps-react`.
51
+ Moving, renaming and deleting a module go through the CLI too, never by hand, and need an approved plan: `references/units/move-or-rename.md`, `references/units/delete.md`; pages and widgets: `df-ps-react` / `df-ps-svelte`.
52
52
 
53
53
  ### 3. New dependencies only through df-scaffold
54
54
 
@@ -83,6 +83,7 @@ One file per unit in `references/units/`: when to choose it, how to generate it
83
83
  | Moving or renaming a module | `move-or-rename.md` | Move or rename |
84
84
  | Deleting a module | `delete.md` | Delete |
85
85
  | React modules | `df-ps-react` skill | `df-react` |
86
+ | Svelte modules | `df-ps-svelte` skill | `df-svelte` |
86
87
 
87
88
  ## Preparing runs
88
89
 
@@ -91,11 +92,11 @@ One file per unit in `references/units/`: when to choose it, how to generate it
91
92
  - **Collisions**: JSON requests require `overwrite: true` to replace changed existing files. Inspect `overwriteRequired` with `dryRun: true` and include those overwrites in the plan. The interactive equivalent asks `Overwrite them?`.
92
93
  - **Integration specs**: with the Testcontainers integration and wire, primary implementations of the types in `backend.implementations.integrationTests`, and infrastructure services when asked, get a spec in `specs/integration/` (`references/generators.md`). For a new type, set `integrationTests: false` when the container can't exercise it (an external API).
93
94
  - **Tests**: with `backend.testingLibrary` set, df-scaffold generates specs for modules without infrastructure (domain model, non-infrastructure services, use cases); repositories, commands/queries, ports, infrastructure services and helpers get none. Add a test implementation (`in-memory`/`mock`) to repositories, commands/queries and ports, so `NODE_ENV=test` specs of the use cases that inject them don't touch real infrastructure. Without `backend.testingLibrary`, tell the user once and suggest adding it with `! npx df-integration` (Vitest); don't edit the config yourself.
94
- - **Run order** in a plan: new contexts → domain (aggregates before their entities and value objects) → application (ports, commands/queries, use cases) → new implementations of existing contracts → endpoints → React (`df-ps-react`).
95
+ - **Run order** in a plan: new contexts → domain (aggregates before their entities and value objects) → application (ports, commands/queries, use cases) → new implementations of existing contracts → endpoints → React (`df-ps-react`) or Svelte (`df-ps-svelte`).
95
96
  - **Requests**: take the unit semantics and output files from its reference, then use `--describe` and `references/agent-mode.md` to build a JSON request.
96
97
 
97
98
  ## Running non-interactively
98
99
 
99
- Use `npx df-scaffold --describe` and execute approved operations with `--request` JSON. React uses `df-react`; integrations use `df-integration`. Protocol, discovery IDs, previews and error handling: [references/agent-mode.md](references/agent-mode.md). Complete backend/React operation map, dependency recipes and conditional integration options: [references/agent-operations.md](references/agent-operations.md).
100
+ Use `npx df-scaffold --describe` and execute approved operations with `--request` JSON. React uses `df-react`, Svelte `df-svelte`; integrations use `df-integration`. Protocol, discovery IDs, previews and error handling: [references/agent-mode.md](references/agent-mode.md). Complete backend/React operation map, dependency recipes and conditional integration options: [references/agent-operations.md](references/agent-operations.md).
100
101
 
101
102
  Initialization remains a human task. No JSON initialization workflow is provided.
@@ -1,6 +1,6 @@
1
1
  # Non-interactive operations for agents
2
2
 
3
- Prefer the JSON interface for `df-scaffold`, `df-react` and `df-integration`. Initialization (`df-init`) remains a human task. The same plan, file creation and dependency rules apply to both interfaces.
3
+ Prefer the JSON interface for `df-scaffold`, `df-react`, `df-svelte` and `df-integration`. Initialization (`df-init`) remains a human task. The same plan, file creation and dependency rules apply to both interfaces.
4
4
 
5
5
  For the complete operation map, conditional integration fields and recipes, read [agent-operations.md](agent-operations.md) for the work at hand.
6
6
 
@@ -129,22 +129,26 @@ The owner configures frontend first. React and Next.js use the same operations.
129
129
 
130
130
  All support `dryRun` and `overwrite`. Use CLI moves even for a rename or folder regrouping; an existing target or a move into itself is rejected.
131
131
 
132
+ ## Svelte operations: df-svelte
133
+
134
+ With `frontend.svelte` configured, `df-svelte` takes the same operations and fields as `df-react` for `<rootFolder>/presentation/svelte/`; `--describe` lists modules as `svelteModules`. Svelte and SvelteKit use the same operations. With SvelteKit, `page` also creates `src/routes/<name>/+page.svelte`, and `moveRoute` / `deleteRoute` apply to that route folder. Stories follow `frontend.svelte.storybookFramework`. Generated files: `df-ps-svelte/references/generators.md`.
135
+
132
136
  ## Integrations: df-integration
133
137
 
134
138
  Use `operation: "add"` and a nonempty `integrations` array. Select only IDs marked available by discovery. They run in the fixed order below, regardless of request order, so later integrations see earlier staged changes.
135
139
 
136
140
  | Integration ID | Relevant fields and conditions |
137
141
  | --- | --- |
138
- | `storybook` | Shared React + Vite setup. `configureReact` is required when React is absent or another Storybook framework is configured; true aligns it with the shared preset, false skips this setup. |
139
- | `rest-endpoint-generator` | Backend must have `@domain-first/handlers-rest`. `nextAdapter` applies only when `frontend.react.framework` is `next`; omitted means no Next adapter in JSON mode. Existing support files are preserved with a manual connection note as needed. |
142
+ | `storybook` | Shared React + Vite setup. `configureReact` is required when React is absent or another Storybook framework is configured; true aligns it with the shared preset, false skips this setup. With `frontend.svelte`, it sets up `@storybook/svelte-vite` (Svelte) or `@storybook/sveltekit` (SvelteKit) in `presentation/svelte/.storybook` instead, without extra fields. |
143
+ | `rest-endpoint-generator` | Backend must have `@domain-first/handlers-rest`. `nextAdapter` applies only when `frontend.react.framework` is `next`, `svelteAdapter` (`@domain-first/handlers-svelte`, route `src/routes/api/[...path]/+server.ts`) only when `frontend.svelte.framework` is `sveltekit`; omitted means no framework adapter in JSON mode. Existing support files are preserved with a manual connection note as needed. |
140
144
  | `in-memory-db` | Backend required. Enables the DB flag and restores missing support files while keeping edited files. No extra fields. |
141
145
  | `prisma` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `prisma` implementation choices. Existing incompatible Prisma setups are rejected rather than upgraded. |
142
146
  | `drizzle` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `drizzle` implementation choices. A `drizzle.config.*` in the project root is rejected as an existing setup. |
143
147
  | `vitest` | Backend required. `replaceTestingLibrary` is required if a different testing library is configured; true changes it to Vitest, false skips this setup. |
144
148
  | `playwright` | No extra integration-specific fields. Adds its config, example and scripts. |
145
149
  | `testcontainers` | Backend required. With wire: optional `integrationTestTypes`, the saved primary types whose implementations get integration specs (omitted: the configured list stays); missing specs of existing primary implementations are added. Reads staged Prisma/Drizzle/Vitest setup when selected together. Database scripts are generated, not executed. |
146
- | `openapi` | Backend with `handlers-rest`. `routePrefix` defaults to `/api`; `openapiPath` is computed from the project unless supplied. `withExtractor` defaults to true. `swaggerPage` applies only with React configured and defaults to true there; otherwise omit it. |
147
- | `orval` | Requires configured `handlers-rest`. `openapiPath` is read from the staged/existing OpenAPI generator when omitted. With React configured, `targets` can be a nonempty list of `hooks`/`client` and defaults to `hooks`. Without React, omit `targets`: the typed client is generated automatically. |
150
+ | `openapi` | Backend with `handlers-rest`. `routePrefix` defaults to `/api`; `openapiPath` is computed from the project unless supplied. `withExtractor` defaults to true. `swaggerPage` applies only with React or Svelte configured and defaults to true there; otherwise omit it. With Svelte it is `swagger-page.svelte` (route `src/routes/swagger/+page.svelte` with SvelteKit), and `openapiPath` defaults to `static/openapi.json` with SvelteKit. |
151
+ | `orval` | Requires configured `handlers-rest`. `openapiPath` is read from the staged/existing OpenAPI generator when omitted. With React or Svelte configured, `targets` can be a nonempty list of `hooks`/`client` and defaults to `hooks` (React Query or Svelte Query hooks; with SvelteKit, a missing `src/routes/+layout.svelte` is created with `QueryProvider`). Without a frontend, omit `targets`: the typed client is generated automatically. |
148
152
 
149
153
  Fields for integrations not selected, or for conditions that do not apply, must be omitted. For example, `targets` on a non-React project and `nextAdapter` on an explicitly React project are unused parameters. If OpenAPI and Orval are selected together, a supplied `openapiPath` applies to both.
150
154
 
@@ -4,7 +4,7 @@ Use the JSON interface described in [agent-mode.md](agent-mode.md), with the com
4
4
 
5
5
  What every generator shares: notation, the `Dependencies:` step, env-branched wiring, spec templates and integration specs. Prompts and output of each generator are in `units/<unit>.md`.
6
6
 
7
- Config paths: `project.rootFolder`, `backend.domainFirstPackages`, `backend.testingLibrary`, `backend.withInMemoryDb`, and `frontend.react.storybookFramework`. Initialization/reconfiguration is performed by the user, not the agent.
7
+ Config paths: `project.rootFolder`, `backend.domainFirstPackages`, `backend.testingLibrary`, `backend.withInMemoryDb`, and `frontend.react.storybookFramework` (`frontend.svelte.storybookFramework` for Svelte). Initialization/reconfiguration is performed by the user, not the agent.
8
8
 
9
9
  Notation: `<C>` = `<rootFolder>/bounded-contexts/<context>` or `<rootFolder>/shared-kernel`. `n` = the entered kebab-case name, `N` = PascalCase, `v` = camelCase. `I` = implementation label (`prisma` → `Prisma`). Specs are generated without a prompt **only if `backend.testingLibrary` is set**. `{pkg}` = output depends on that `@domain-first/*` package.
10
10
 
@@ -60,7 +60,7 @@ Reply "ok" to start.
60
60
  - Write the plan in the user's language (headings and sentences); module names, types, commands and paths stay as in the code. Omit empty sections.
61
61
  - **Scaffolding** has one block per owner, in run order: new contexts first, marked `(new)` (and `(provisional)` with the reason when ownership is a reversible default), then existing contexts, `shared-kernel`, React last.
62
62
  - **Why here**: one short sentence on why this owner, not another: the data or rule the context owns; for `shared-kernel`, why several contexts share it; for React, why the UI changes.
63
- - **What will be scaffolded**: one table per owner, one row per `df-scaffold`/`df-react` run. Layers in order domain → application → infrastructure → presentation, the layer in bold only on its first row. Repositories go with their aggregate in domain; commands, queries and ports in application (their implementations are Details); endpoints and React modules in presentation.
63
+ - **What will be scaffolded**: one table per owner, one row per `df-scaffold`/`df-react`/`df-svelte` run. Layers in order domain → application → infrastructure → presentation, the layer in bold only on its first row. Repositories go with their aggregate in domain; commands, queries and ports in application (their implementations are Details); endpoints and React modules in presentation.
64
64
  - **Type**: the unit: aggregate, entity, value object, error, error namespace, service, port, command, query, use case, implementation, endpoint, wire dependency, move, delete; for React: page, widget, ui-kit component, hook, page move, widget move, ui-kit component move, hook move, page delete, widget delete, ui-kit component delete, hook delete.
65
65
  - **Name**: the entered name; for a move `old → new`; for an implementation the contract; for wire dependency the module.
66
66
  - **Details**: only what changes behavior: implementation types (`(saved)` when saved for future runs), the test implementation, dependencies (`deps: OrderRepository`), environments, widget type, the endpoint's handler, whether a Next.js route moves (`route moves: /a → /b`). No file paths, no CLI menu paths.
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: df-ps-svelte
3
+ description: Build the Svelte part of a Domain-First project with the `df-svelte` CLI (@domain-first/project-structure) — choose between pages, widgets (separated UI, headless, monolithic), UI-kit components and shared hooks (Svelte 5 runes), generate them with Storybook stories and SvelteKit routes, move, rename or delete them, and implement them against the backend without importing bounded contexts. Use when the project has domain-first.project-structure.config.json with frontend.svelte configured and the user asks for screens, UI blocks, components, runes/hooks or stories, or to move, rename or regroup a page or widget.
4
+ ---
5
+
6
+ # Svelte modules with df-svelte
7
+
8
+ Svelte modules live in `<rootFolder>/presentation/svelte/` (`…/svelte/` below) and come only from `df-svelte`. The modules, their kinds and the rules are those of `df-ps-react`; this skill lists only what differs. The mandatory rules of `df-ps-scaffold` apply here too: an approved work plan before any new file (rule 1), new files only through the CLI or its listed exceptions (rule 2).
9
+
10
+ ## Workflow
11
+
12
+ 1. Read `domain-first.project-structure.config.json`: source root is `project.rootFolder`; Svelte is enabled by `frontend.svelte`; `frontend.svelte.framework` is `svelte` or `sveltekit`, and both use `df-svelte`. Stories use `frontend.svelte.storybookFramework` (`@storybook/svelte-vite` or `@storybook/sveltekit`). A config of an earlier major version (`CONFIG_OUTDATED`): ask the user to run `npx df-upgrade`; never run it yourself. Without the config, tell the user to run `npx df-init`; without Svelte configured, tell them to run `npx df-init --section frontend`. Initialization and configuration belong to the human: do not run `df-init` or edit these settings yourself.
13
+ 2. A feature that also needs backend work → plan it with `df-ps-plan-feature`; Svelte runs come last in the plan.
14
+ 3. Choose a module for each piece of UI by "Choosing the module" of `df-ps-react`: page, widget, UI-kit component, shared hook. Widgets never import each other; the widget type defaults to `with separated ui`.
15
+ 4. Show the work plan in the format of `df-ps-scaffold/references/work-plan.md` (the frontend block, `df-svelte` runs) and **stop until it's approved**. Details holds the widget type and, for a page move or delete with SvelteKit, whether the route follows.
16
+ 5. Run the generators with `df-svelte --request` JSON in plan order (shared hooks → UI-kit → widgets → pages); check each output.
17
+ 6. Implement ("Implementing"), after the backend and the regenerated API client.
18
+ 7. Run `npx df-lint` and the project's svelte-check/lint/tests. Report against the plan.
19
+
20
+ ## Running df-svelte
21
+
22
+ Prefer `npx df-svelte --describe` and `npx df-svelte --request` JSON. The operations and fields are those of `df-react` (`page`, `widget`, `ui-kit-component`, `shared-hook`, `move-*`, `delete-*`); `--describe` lists current Svelte modules as `svelteModules`. For example:
23
+
24
+ ```bash
25
+ npx df-svelte --request '{"operation":"widget","name":"cart","widgetType":"separated"}'
26
+ ```
27
+
28
+ Generated files and story templates: `references/generators.md`. Previews, overwrite control and JSON results: `df-ps-scaffold` [agent-mode.md](../df-ps-scaffold/references/agent-mode.md). If the CLI cannot run, report the failure and give the user the prepared JSON command. Never hand-write its output.
29
+
30
+ Moving, renaming and deleting go through df-svelte, never by hand, with an approved plan, exactly as in `df-ps-react` ("Moving and renaming"). With SvelteKit, moving a page can move its route folder (`src/routes/<name>/`: `+page.svelte`, `+page.ts`, `+layout.svelte`…; child routes stay) and so change its URL (`moveRoute`); deleting a page can delete its route (`deleteRoute`). State it in the plan, and ask the user when the request doesn't say.
31
+
32
+ ### Files you may create by hand
33
+
34
+ Only these (`df-ps-scaffold`, rule 2, exceptions 3–4), for modules generated by df-svelte:
35
+
36
+ - Widget hooks and UI parts: `…/svelte/widgets/<name>/hooks/**` (`*.svelte.ts` for runes), `ui/**`.
37
+ - Support files inside the widget folder or `ui-kit/<name>/`: styles, assets, `*.test.ts`, `*.stories.ts`. A missing UI-kit or widget UI story: exactly from "Story templates" in `references/generators.md`.
38
+ - A page stays one `.svelte` file that composes widgets; its `<style>` block lays out its widgets only. Its own state, UI parts or types mean a widget is missing, so generate it.
39
+ - SvelteKit route files next to a generated route (`+page.ts`, `+layout.svelte`, `+error.svelte`) for loading and layout; the route's `+page.svelte` only renders the page component.
40
+
41
+ ## Implementing
42
+
43
+ - Svelte 5 with runes: props through `$props()`, state through `$state`, derived values through `$derived`. Each component exports its props type from `<script lang="ts" module>`.
44
+ - Separated UI widget: state, effects and derived data in `hooks/use-<name>-ui-model.svelte.ts` (props → UI props). Return getters (or `$derived` values behind getters) so `{...uiModel}` stays reactive; `ui/` stays presentational. Headless: the same hook, and the consumer passes `UI` (a `Component<UIProps>`).
45
+ - UI-kit components and shared hooks (`…/svelte/hooks/use-<name>.svelte.ts`): the same limits as in `df-ps-react` — driven only by props or arguments; no API client, no data loading, no imports from widgets, pages or contexts.
46
+ - Stories (`frontend.svelte.storybookFramework`): fill `args` of `Default` with valid props and add one story per meaningful state. Keep `meta`, the file name and the title (`UI-kit/N` or `Widgets/N`).
47
+ - Talking to the backend: as in `df-ps-react` ("Talking to the backend") — a generated API client first (Orval's Svelte Query hooks in `<rootFolder>/presentation/svelte/data-layer/orval`, or its typed client in `<rootFolder>/presentation/data-layer`; queries need `QueryProvider` from `…/svelte/data-layer/query-provider.svelte` above them, which SvelteKit's root `+layout.svelte` provides), `import type` of endpoint contracts only without one. SvelteKit `+page.ts`/`+page.server.ts` loads call the client, not bounded contexts.
48
+
49
+ `npx df-lint` (check `svelte`) reports a widget importing another widget, UI-kit importing widgets, pages or contexts, shared hooks importing UI-kit, widgets, pages or contexts, and Svelte importing contexts beyond the contract types. Fix every finding.
@@ -0,0 +1,56 @@
1
+ # df-svelte generators: operations and output
2
+
3
+ Prefer JSON requests; operations and fields are those of [df-react](../../df-ps-scaffold/references/agent-operations.md#react-operations-df-react), with `SvelteKit` routes in place of Next.js ones. Settings: `project.rootFolder` and `frontend.svelte.storybookFramework`. The frontend section must be configured by the user before these runs.
4
+
5
+ Notation: `…/svelte/` = `<rootFolder>/presentation/svelte/`. `n` = the entered kebab-case name, `N` = PascalCase. Components are Svelte 5 with runes; each one exports its props type from `<script lang="ts" module>`.
6
+
7
+ ## New page
8
+
9
+ `…/svelte/pages/n-page.svelte` (`NPageProps`); with SvelteKit (`frontend.svelte.framework: sveltekit`) also `src/routes/n/+page.svelte` importing `NPage` from the page file and rendering `<NPage />`, unless that route already exists. A nested name nests the route too: `admin/users` → `src/routes/admin/users/+page.svelte`.
10
+
11
+ ## New widget
12
+
13
+ `…/svelte/widgets/n/`:
14
+
15
+ - `with separated ui` (default): `n-widget.svelte`, `types.ts`, `ui/n-widget-ui.svelte`, `hooks/use-n-ui-model.svelte.ts`; with `storybookFramework`: `ui/n-widget-ui.stories.ts` (CSF3: `title: 'Widgets/N'`, `component: NWidgetUI`, story `Default`)
16
+ - `headless`: `n-widget.svelte` (renders `<UI {...uiModel} />`), `types.ts` (props include `UI: Component<NWidgetUIProps>`), `hooks/use-n-ui-model.svelte.ts`
17
+ - `monolithic`: `n-widget.svelte` (`NWidgetProps`)
18
+ - every type: `index.ts` (`export { default as NWidget } from './n-widget.svelte'` and the props type)
19
+
20
+ Nested names work as in df-react: `admin/panel/users` → `…/widgets/admin/panel/users/admin-panel-users-widget.svelte`, story title `Widgets/Admin/Panel/Users`.
21
+
22
+ ## New UI-kit component
23
+
24
+ `…/svelte/ui-kit/n/`: `n.svelte` (`NProps`), `index.ts` (`export { default as N } from './n.svelte'` and `NProps`), with `storybookFramework`: `n.stories.ts` (`title: 'UI-kit/N'`).
25
+
26
+ ## New shared hook
27
+
28
+ `…/svelte/hooks/use-n.svelte.ts` (`const useN = () => …`), so it may use runes. A leading `use-` in the name is dropped.
29
+
30
+ ## Move, rename, delete
31
+
32
+ As in df-react: files, `<Name>Page` / `<Name>Widget…` / `use<Name>UIModel` / `<Name>` / `use<Name>`, story titles and every import (with or without the `.svelte` extension, relative or through `tsconfig` aliases) follow a move; a delete is refused while other files import the module. With SvelteKit, the page's own route folder files move or are deleted too when confirmed.
33
+
34
+ ## Story templates
35
+
36
+ Only for recreating a **missing** story (`df-ps-scaffold`, rule 2, exception 4).
37
+
38
+ UI-kit, at `…/svelte/ui-kit/n/n.stories.ts`; widget UI (`with separated ui` only), at `…/svelte/widgets/n/ui/n-widget-ui.stories.ts` with `NWidgetUI`, `./n-widget-ui.svelte` and `Widgets/N`:
39
+
40
+ ```ts
41
+ import type { Meta, StoryObj } from "<storybookFramework>";
42
+ import N from "./n.svelte";
43
+
44
+ const meta = {
45
+ title: "UI-kit/N",
46
+ component: N,
47
+ } satisfies Meta<typeof N>;
48
+
49
+ export default meta;
50
+
51
+ type Story = StoryObj<typeof meta>;
52
+
53
+ export const Default: Story = {
54
+ args: {},
55
+ };
56
+ ```