@domain-first/project-structure 8.10.1 → 8.12.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.
- package/README.md +17 -7
- package/dist/287.js +406 -788
- package/dist/364.js +79 -0
- package/dist/38.js +31 -14
- package/dist/561.js +179 -96
- package/dist/783.js +1147 -0
- package/dist/{201.js → 878.js} +465 -2
- package/dist/agent-cli.d.ts +17 -6
- package/dist/agent-requests.d.ts +82 -8
- package/dist/config-file.d.ts +25 -1
- package/dist/frontend-cli.d.ts +3 -0
- package/dist/frontend-modules.d.ts +14 -0
- package/dist/graph.cjs +125 -5
- package/dist/graph.js +1 -1
- package/dist/index.cjs +3545 -2930
- package/dist/index.js +1 -1
- package/dist/init.cjs +368 -83
- package/dist/init.js +1 -1
- package/dist/integration.cjs +3545 -2930
- package/dist/integration.js +1 -1
- package/dist/integrations/openapi.d.ts +19 -2
- package/dist/integrations/orval.d.ts +31 -4
- package/dist/integrations/rest-endpoint-generator.d.ts +11 -7
- package/dist/integrations/storybook.d.ts +19 -1
- package/dist/lint.cjs +159 -22
- package/dist/lint.js +2 -2
- package/dist/page-router.d.ts +18 -0
- package/dist/react-module-move.d.ts +47 -14
- package/dist/react.cjs +1645 -999
- package/dist/react.js +2 -102
- package/dist/rest-adapters.d.ts +13 -0
- package/dist/svelte-agent-cli.spec.d.ts +1 -0
- package/dist/svelte.cjs +7373 -0
- package/dist/svelte.d.ts +2 -0
- package/dist/svelte.js +3 -0
- package/dist/sveltekit-app.d.ts +7 -0
- package/dist/upgrade-steps.d.ts +6 -1
- package/dist/upgrade-svelte.d.ts +15 -0
- package/dist/upgrade-svelte.spec.d.ts +1 -0
- package/dist/upgrade.cjs +307 -42
- package/dist/upgrade.js +132 -13
- package/dist/use-cases/add-integration.d.ts +1 -1
- package/dist/use-cases/delete-react-module.d.ts +4 -4
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/move-react-module.d.ts +2 -2
- package/dist/use-cases/rest-endpoint-generator.d.ts +6 -4
- package/dist/use-cases/scaffold-svelte-modules.d.ts +27 -0
- package/package.json +2 -1
- package/skills/df-ps-implement/SKILL.md +3 -3
- package/skills/df-ps-plan-feature/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +9 -8
- package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +8 -4
- package/skills/df-ps-scaffold/references/generators.md +1 -1
- package/skills/df-ps-scaffold/references/work-plan.md +1 -1
- package/skills/df-ps-svelte/SKILL.md +54 -0
- package/skills/df-ps-svelte/references/generators.md +56 -0
- package/dist/115.js +0 -615
package/dist/upgrade.js
CHANGED
|
@@ -4,8 +4,8 @@ import { parseArgs } from "node:util";
|
|
|
4
4
|
import { confirm as prompts_confirm } from "@inquirer/prompts";
|
|
5
5
|
import zod from "zod";
|
|
6
6
|
import node_fs from "node:fs";
|
|
7
|
-
import {
|
|
8
|
-
import { restFolders, withIdLookup,
|
|
7
|
+
import { domainFirstPackages as config_file_domainFirstPackages, discardPendingChanges, configSchema, module_move_walk, escapeRegExp, writePendingChanges, stageModuleMove, configFileName, toPosix, boundedContextNames, implementationLabelSchema, rulesSchema, ConfigFile, boundedContextPath, isOutdatedConfig, File, ProjectRoot, codeExtension, boundedContextName } from "./878.js";
|
|
8
|
+
import { svelteSwaggerPage, restFolders, withIdLookup, openapiExtractorPath, rootEndpointFileLookup, legacyEndpointFileLookup, hasLegacyRootEndpoints, legacyHasId, legacyWithIdLookup, endpointFileLookup, hasDependency, svelteKitStaticUrl, legacyRootEndpoints, swaggerPagePath } from "./783.js";
|
|
9
9
|
const serviceFile = ({ config })=>{
|
|
10
10
|
const project = config.project;
|
|
11
11
|
const rootFolder = 'object' == typeof project && null !== project ? project.rootFolder : void 0;
|
|
@@ -48,7 +48,7 @@ const rootMoves = (contextFolder)=>{
|
|
|
48
48
|
files: [
|
|
49
49
|
...[
|
|
50
50
|
...endpointFiles,
|
|
51
|
-
...parameterFolders.flatMap(
|
|
51
|
+
...parameterFolders.flatMap(module_move_walk)
|
|
52
52
|
].map((file)=>[
|
|
53
53
|
file,
|
|
54
54
|
intoRoot(presentation, file)
|
|
@@ -201,6 +201,122 @@ const openapiExtractorManualStep = {
|
|
|
201
201
|
]
|
|
202
202
|
};
|
|
203
203
|
const record = (value)=>'object' != typeof value || null === value || Array.isArray(value) ? {} : value;
|
|
204
|
+
const svelteOf = ({ config })=>'svelte' in record(config.frontend) ? record(record(config.frontend).svelte) : void 0;
|
|
205
|
+
const upgrade_svelte_rootFolderOf = ({ config })=>{
|
|
206
|
+
const rootFolder = record(config.project).rootFolder;
|
|
207
|
+
return 'string' == typeof rootFolder ? rootFolder : void 0;
|
|
208
|
+
};
|
|
209
|
+
const upgrade_svelte_relative = (file)=>toPosix(node_path.relative(new ProjectRoot().path, file));
|
|
210
|
+
const svelteFolder = (context)=>{
|
|
211
|
+
const rootFolder = upgrade_svelte_rootFolderOf(context);
|
|
212
|
+
return svelteOf(context) && rootFolder ? node_path.join(new ProjectRoot().path, rootFolder, 'presentation', 'svelte') : void 0;
|
|
213
|
+
};
|
|
214
|
+
const legacySwaggerPage = (context)=>{
|
|
215
|
+
const rootFolder = upgrade_svelte_rootFolderOf(context);
|
|
216
|
+
if (!svelteOf(context) || !rootFolder) return;
|
|
217
|
+
const file = new File(node_path.join(new ProjectRoot().path, swaggerPagePath(rootFolder, 'svelte')));
|
|
218
|
+
return file.exists && /swagger-ui\/dist\/swagger-ui\.css|import\(\s*['"]swagger-ui['"]\s*\)/.test(file.data) ? file : void 0;
|
|
219
|
+
};
|
|
220
|
+
const importedSpecPath = (page)=>{
|
|
221
|
+
const specifier = page.data.match(/import\s+spec\s+from\s+['"]([^'"]+)['"]/)?.[1];
|
|
222
|
+
return specifier?.startsWith('.') ? upgrade_svelte_relative(node_path.resolve(node_path.dirname(page.path), specifier)) : void 0;
|
|
223
|
+
};
|
|
224
|
+
const svelteSwaggerPageStep = {
|
|
225
|
+
id: 'svelte-swagger-ui-dist',
|
|
226
|
+
kind: 'optional',
|
|
227
|
+
title: 'Render the Svelte Swagger UI page with swagger-ui-dist',
|
|
228
|
+
detect: (context)=>{
|
|
229
|
+
const page = legacySwaggerPage(context);
|
|
230
|
+
return !!page && !!importedSpecPath(page);
|
|
231
|
+
},
|
|
232
|
+
plan: (context)=>{
|
|
233
|
+
const page = legacySwaggerPage(context);
|
|
234
|
+
return [
|
|
235
|
+
`${upgrade_svelte_relative(page.path)}: regenerated on swagger-ui-dist/swagger-ui-bundle.js, which bundles its own React`
|
|
236
|
+
];
|
|
237
|
+
},
|
|
238
|
+
apply: (context)=>{
|
|
239
|
+
const page = legacySwaggerPage(context);
|
|
240
|
+
const outputPath = importedSpecPath(page);
|
|
241
|
+
const sveltekit = svelteOf(context)?.framework === 'sveltekit';
|
|
242
|
+
page.update(svelteSwaggerPage(upgrade_svelte_rootFolderOf(context), outputPath, sveltekit ? svelteKitStaticUrl(outputPath) : void 0));
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const svelteSwaggerPackagesStep = {
|
|
246
|
+
id: 'svelte-swagger-ui-dist-packages',
|
|
247
|
+
kind: 'manual',
|
|
248
|
+
title: 'Replace swagger-ui with swagger-ui-dist',
|
|
249
|
+
detect: (context)=>!!svelteOf(context) && hasDependency('swagger-ui'),
|
|
250
|
+
plan: ()=>[
|
|
251
|
+
`npm uninstall swagger-ui${hasDependency('@types/swagger-ui') ? ' @types/swagger-ui' : ''}`,
|
|
252
|
+
...hasDependency('swagger-ui-dist') ? [] : [
|
|
253
|
+
'npm install swagger-ui-dist'
|
|
254
|
+
],
|
|
255
|
+
...hasDependency('@types/swagger-ui-dist') ? [] : [
|
|
256
|
+
'npm install --save-dev @types/swagger-ui-dist'
|
|
257
|
+
]
|
|
258
|
+
]
|
|
259
|
+
};
|
|
260
|
+
const legacyFunctionNames = (file)=>[
|
|
261
|
+
...node_fs.readFileSync(file, 'utf8').matchAll(/export\s+(?:const|function)\s+use(\w+)\b/g)
|
|
262
|
+
].map(([, name])=>[
|
|
263
|
+
`use${name}`,
|
|
264
|
+
`create${name}`
|
|
265
|
+
]);
|
|
266
|
+
const legacyModels = (context)=>{
|
|
267
|
+
const folder = svelteFolder(context);
|
|
268
|
+
if (!folder) return [];
|
|
269
|
+
const isModule = (file)=>/^use-.+\.svelte\.[jt]s$/.test(node_path.basename(file)) && !/\.(spec|test)\./.test(file);
|
|
270
|
+
const renamed = (file)=>node_path.basename(file).replace(/^use-/, 'create-');
|
|
271
|
+
const widgetModels = module_move_walk(node_path.join(folder, 'widgets')).filter((file)=>'hooks' === node_path.basename(node_path.dirname(file)) && /-ui-model\./.test(file) && isModule(file)).map((file)=>({
|
|
272
|
+
from: file,
|
|
273
|
+
to: node_path.join(node_path.dirname(node_path.dirname(file)), 'model', renamed(file))
|
|
274
|
+
}));
|
|
275
|
+
const sharedFolder = node_path.join(folder, 'hooks');
|
|
276
|
+
const sharedHooks = node_fs.existsSync(sharedFolder) ? node_fs.readdirSync(sharedFolder).map((name)=>node_path.join(sharedFolder, name)).filter(isModule).map((file)=>({
|
|
277
|
+
from: file,
|
|
278
|
+
to: node_path.join(folder, 'shared', 'model', renamed(file))
|
|
279
|
+
})) : [];
|
|
280
|
+
return [
|
|
281
|
+
...widgetModels,
|
|
282
|
+
...sharedHooks
|
|
283
|
+
].filter(({ to })=>!node_fs.existsSync(to)).map((move)=>({
|
|
284
|
+
...move,
|
|
285
|
+
names: legacyFunctionNames(move.from)
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
const svelteModelsStep = {
|
|
289
|
+
id: 'svelte-models',
|
|
290
|
+
kind: 'optional',
|
|
291
|
+
title: 'Rename Svelte hooks to models: model/create-*.svelte.ts',
|
|
292
|
+
detect: (context)=>legacyModels(context).length > 0,
|
|
293
|
+
plan: (context)=>legacyModels(context).flatMap(({ from, to, names })=>[
|
|
294
|
+
`${upgrade_svelte_relative(from)} → ${upgrade_svelte_relative(to)}`,
|
|
295
|
+
...names.map(([from, to])=>` ${from} → ${to}`)
|
|
296
|
+
]),
|
|
297
|
+
apply: (context)=>{
|
|
298
|
+
const models = legacyModels(context);
|
|
299
|
+
const moves = new Map(models.map(({ from, to })=>[
|
|
300
|
+
from,
|
|
301
|
+
to
|
|
302
|
+
]));
|
|
303
|
+
const withoutExtension = new Map(models.map(({ from, to })=>[
|
|
304
|
+
from.replace(codeExtension, ''),
|
|
305
|
+
to.replace(codeExtension, '')
|
|
306
|
+
]));
|
|
307
|
+
const names = models.flatMap((model)=>model.names);
|
|
308
|
+
const namePattern = names.length && new RegExp(`(?<![\\w$])(${names.map(([from])=>escapeRegExp(from)).join('|')})(?![\\w$])`, 'g');
|
|
309
|
+
const renames = new Map(names);
|
|
310
|
+
stageModuleMove({
|
|
311
|
+
projectRoot: new ProjectRoot().path,
|
|
312
|
+
stopAt: svelteFolder(context),
|
|
313
|
+
moves,
|
|
314
|
+
movedPath: (candidate)=>moves.get(candidate) ?? withoutExtension.get(candidate),
|
|
315
|
+
rename: (content)=>namePattern ? content.replace(namePattern, (name)=>renames.get(name) ?? name) : content
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
const upgrade_steps_record = (value)=>'object' != typeof value || null === value || Array.isArray(value) ? {} : value;
|
|
204
320
|
const flatConfigSchema = zod.object({
|
|
205
321
|
rootFolder: zod.string().min(1),
|
|
206
322
|
domainFirstPackages: zod.array(zod["enum"](config_file_domainFirstPackages)),
|
|
@@ -254,17 +370,17 @@ const sectionsStep = {
|
|
|
254
370
|
};
|
|
255
371
|
}
|
|
256
372
|
};
|
|
257
|
-
const reactOf = (config)=>
|
|
373
|
+
const reactOf = (config)=>upgrade_steps_record(upgrade_steps_record(config.frontend).react);
|
|
258
374
|
const frameworkStep = {
|
|
259
375
|
id: 'react-framework',
|
|
260
376
|
kind: 'required',
|
|
261
377
|
title: 'Record the frontend framework explicitly',
|
|
262
|
-
detect: ({ config })=>'react' in
|
|
378
|
+
detect: ({ config })=>'react' in upgrade_steps_record(config.frontend) && !reactOf(config).framework,
|
|
263
379
|
plan: ()=>[
|
|
264
380
|
hasDependency('next') ? 'frontend.react.framework: "next" (next is in package.json)' : 'frontend.react.framework: "react" (next is not in package.json)'
|
|
265
381
|
],
|
|
266
382
|
apply: ({ config })=>{
|
|
267
|
-
const frontend =
|
|
383
|
+
const frontend = upgrade_steps_record(config.frontend);
|
|
268
384
|
config.frontend = {
|
|
269
385
|
...frontend,
|
|
270
386
|
react: {
|
|
@@ -283,9 +399,9 @@ const persistenceStep = {
|
|
|
283
399
|
id: 'persistence-default',
|
|
284
400
|
kind: 'required',
|
|
285
401
|
title: 'Move the default persistence implementation to saved implementation types',
|
|
286
|
-
detect: ({ config })=>'defaultPersistenceLayerImplementation' in
|
|
402
|
+
detect: ({ config })=>'defaultPersistenceLayerImplementation' in upgrade_steps_record(config.backend),
|
|
287
403
|
plan: ({ config })=>{
|
|
288
|
-
const label =
|
|
404
|
+
const label = upgrade_steps_record(config.backend).defaultPersistenceLayerImplementation;
|
|
289
405
|
if (void 0 === label) return [];
|
|
290
406
|
return implementationLabelSchema.safeParse(label).success ? [
|
|
291
407
|
`defaultPersistenceLayerImplementation "${label}" → first primary type of backend.implementations.${persistenceKinds.join(', ')}`
|
|
@@ -294,11 +410,11 @@ const persistenceStep = {
|
|
|
294
410
|
];
|
|
295
411
|
},
|
|
296
412
|
apply: ({ config })=>{
|
|
297
|
-
const { defaultPersistenceLayerImplementation: label, ...backend } =
|
|
298
|
-
const implementations =
|
|
413
|
+
const { defaultPersistenceLayerImplementation: label, ...backend } = upgrade_steps_record(config.backend);
|
|
414
|
+
const implementations = upgrade_steps_record(backend.implementations);
|
|
299
415
|
if (implementationLabelSchema.safeParse(label).success) {
|
|
300
416
|
for (const kind of persistenceKinds){
|
|
301
|
-
const group =
|
|
417
|
+
const group = upgrade_steps_record(implementations[kind]);
|
|
302
418
|
const primary = Array.isArray(group.primary) ? group.primary : [];
|
|
303
419
|
implementations[kind] = {
|
|
304
420
|
primary: [
|
|
@@ -321,12 +437,15 @@ const upgradeSteps = [
|
|
|
321
437
|
openapiExtractorRootStep,
|
|
322
438
|
openapiExtractorNestedStep,
|
|
323
439
|
openapiExtractorManualStep,
|
|
324
|
-
inMemoryDbWithIdStep
|
|
440
|
+
inMemoryDbWithIdStep,
|
|
441
|
+
svelteSwaggerPageStep,
|
|
442
|
+
svelteSwaggerPackagesStep,
|
|
443
|
+
svelteModelsStep
|
|
325
444
|
];
|
|
326
445
|
const skillsNote = 'Update the agent skills to this version: npx df-skills';
|
|
327
446
|
const planUpgrade = async (config, acceptOptional = ()=>true, steps = upgradeSteps)=>{
|
|
328
447
|
const context = {
|
|
329
|
-
config: structuredClone(
|
|
448
|
+
config: structuredClone(upgrade_steps_record(config))
|
|
330
449
|
};
|
|
331
450
|
const original = JSON.stringify(context.config);
|
|
332
451
|
const planned = [];
|
|
@@ -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
|
|
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 `
|
|
6
|
-
* `nextAdapter` of `@domain-first/handlers-next`
|
|
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, {
|
|
9
|
-
|
|
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,27 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* The UI model of a widget: props → UI props, reactive through getters.
|
|
10
|
+
*/
|
|
11
|
+
export declare const svelteUIModelContent: (ClassName: string, propsType: string) => string;
|
|
12
|
+
/** A thin SvelteKit route that renders the page component. */
|
|
13
|
+
export declare const svelteKitRouteContent: (ClassName: string, pageImport: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* With SvelteKit, the page also gets its route at the same path, e.g.
|
|
16
|
+
* `admin/users` → `src/routes/admin/users/+page.svelte`. An existing route
|
|
17
|
+
* is kept: it may hold the user's code, and the returned hint says so.
|
|
18
|
+
*/
|
|
19
|
+
export declare const scaffoldSvelteKitRoute: (name: NestedName, pagePath: string) => string | undefined;
|
|
20
|
+
export declare const scaffoldSveltePage: (presentationSvelteFolder: Folder) => Promise<void>;
|
|
21
|
+
export declare const scaffoldSvelteWidget: (presentationSvelteFolder: Folder) => Promise<void>;
|
|
22
|
+
export declare const scaffoldSvelteUIKitComponent: (presentationSvelteFolder: Folder) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* A shared model is a `.svelte.ts` factory, so it may use runes. Svelte
|
|
25
|
+
* has no hooks: in SvelteKit they are `hooks.server.ts`/`hooks.client.ts`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const scaffoldSvelteSharedModel: (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.
|
|
4
|
+
"version": "8.12.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
|
|
|
@@ -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`, with shared models in place of shared hooks).
|
|
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
|
|
|
@@ -34,13 +34,13 @@ Read [references/work-plan.md](references/work-plan.md), show the plan in that f
|
|
|
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>/model/**`, `ui/**`) | 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/`, except that Svelte has shared models, not hooks: `shared-model`, `move-shared-model` and `delete-shared-model` (`shared/model/create-<name>.svelte.ts`, `create<Name>`; a leading `create-` is dropped) replace the `shared-hook` operations, which `df-svelte` rejects with `INVALID_REQUEST`. `--describe` lists modules as `svelteModules`, shared models with kind `model`. 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
|
|
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
|
|
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 hooks, or Svelte Query `createQuery`/`createMutation`; 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
|
|
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,54 @@
|
|
|
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 models (Svelte 5 runes, `create…` factories), 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, reusable reactive logic 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 model (React's shared hook: Svelte has no hooks). 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 models → 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`, `move-*`, `delete-*`), with `shared-model`, `move-shared-model` and `delete-shared-model` in place of the `shared-hook` ones; `--describe` lists current Svelte modules as `svelteModules` (shared models with kind `model`). 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 models and UI parts: `…/svelte/widgets/<name>/model/**` (`*.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 `model/create-<name>-ui-model.svelte.ts` (`create<Name>UIModel`: props → UI props); `ui/` stays presentational. Keep it reactive:
|
|
45
|
+
- take `widgetProps` whole, the `$props()` proxy; destructuring it in the signature (`({ a }) =>`) or copying props in `<script>` (`{ ...props }`, `{ a: props.a }`) reads them once and the UI stops following them;
|
|
46
|
+
- values that depend on props are `$derived` and leave the model through getters only (`get total() { return total }`); getters satisfy the UI props type;
|
|
47
|
+
- local state is `$state`; methods are plain functions of the returned object;
|
|
48
|
+
- keep the generated `// svelte-ignore state_referenced_locally` before `create<Name>UIModel(props)`: the proxy never changes, the warning is a false positive.
|
|
49
|
+
- Headless: the same model, given `widgetProps` from `let { UI, ...widgetProps } = $props()` (the rest stays reactive); the consumer passes `UI` (a `Component<UIProps>`).
|
|
50
|
+
- UI-kit components and shared models (`…/svelte/shared/model/create-<name>.svelte.ts`, `create<Name>`): 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.
|
|
51
|
+
- 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`).
|
|
52
|
+
- Talking to the backend: as in `df-ps-react` ("Talking to the backend") — a generated API client first (Orval's Svelte Query `createQuery`/`createMutation` 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.
|
|
53
|
+
|
|
54
|
+
`npx df-lint` (check `svelte`) reports a widget importing another widget, UI-kit importing widgets, pages or contexts, shared models 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`, `model/create-n-ui-model.svelte.ts` (`createNUIModel`, returning getters); 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>`), `model/create-n-ui-model.svelte.ts`, given the rest of `let { UI, ...widgetProps } = $props()`
|
|
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 model
|
|
27
|
+
|
|
28
|
+
Operation `shared-model`: `…/svelte/shared/model/create-n.svelte.ts` (`const createN = () => …`), so it may use runes. A leading `create-` in the name is dropped. Svelte has no hooks: in SvelteKit they are `hooks.server.ts`/`hooks.client.ts`.
|
|
29
|
+
|
|
30
|
+
## Move, rename, delete
|
|
31
|
+
|
|
32
|
+
As in df-react: files, `<Name>Page` / `<Name>Widget…` / `create<Name>UIModel` / `<Name>` / `create<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
|
+
```
|