@domain-first/project-structure 8.6.0 → 8.7.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 (54) hide show
  1. package/README.md +1 -1
  2. package/bin/df-skills.mjs +55 -9
  3. package/dist/287.js +54 -2
  4. package/dist/38.js +36 -0
  5. package/dist/561.js +9 -1
  6. package/dist/780.js +2 -1
  7. package/dist/947.js +11 -1
  8. package/dist/agent-cli.d.ts +9 -2
  9. package/dist/agent-principles.cjs +116 -0
  10. package/dist/agent-principles.d.ts +9 -0
  11. package/dist/agent-principles.js +64 -0
  12. package/dist/agent-principles.spec.d.ts +1 -0
  13. package/dist/agent-requests.d.ts +16 -2
  14. package/dist/file-system.d.ts +2 -1
  15. package/dist/graph.cjs +12 -1
  16. package/dist/index.cjs +76 -2
  17. package/dist/index.js +4 -1
  18. package/dist/init.cjs +14 -3
  19. package/dist/integration.cjs +73 -2
  20. package/dist/lint.cjs +48 -1
  21. package/dist/react.cjs +73 -2
  22. package/dist/upgrade.cjs +21 -13
  23. package/dist/upgrade.js +19 -12
  24. package/dist/use-cases/add-integration.d.ts +1 -1
  25. package/dist/use-cases/index.d.ts +1 -0
  26. package/dist/use-cases/scaffold-new-infrastructure-helper.d.ts +7 -0
  27. package/dist/wiring.d.ts +2 -2
  28. package/package.json +3 -2
  29. package/principles/df-principles.md +33 -0
  30. package/skills/df-ps-implement/SKILL.md +26 -1
  31. package/skills/df-ps-plan-feature/SKILL.md +22 -18
  32. package/skills/df-ps-react/SKILL.md +2 -9
  33. package/skills/df-ps-react/references/generators.md +9 -9
  34. package/skills/df-ps-scaffold/SKILL.md +19 -125
  35. package/skills/df-ps-scaffold/references/agent-mode.md +2 -2
  36. package/skills/df-ps-scaffold/references/agent-operations.md +1 -0
  37. package/skills/df-ps-scaffold/references/choosing-components.md +65 -49
  38. package/skills/df-ps-scaffold/references/generators.md +28 -5
  39. package/skills/df-ps-scaffold/references/units/aggregate.md +1 -3
  40. package/skills/df-ps-scaffold/references/units/bounded-context.md +1 -1
  41. package/skills/df-ps-scaffold/references/units/command-query.md +4 -6
  42. package/skills/df-ps-scaffold/references/units/delete.md +0 -2
  43. package/skills/df-ps-scaffold/references/units/endpoint.md +1 -4
  44. package/skills/df-ps-scaffold/references/units/entity-value-object.md +0 -4
  45. package/skills/df-ps-scaffold/references/units/errors.md +0 -4
  46. package/skills/df-ps-scaffold/references/units/helper.md +30 -0
  47. package/skills/df-ps-scaffold/references/units/implementation.md +0 -4
  48. package/skills/df-ps-scaffold/references/units/move-or-rename.md +0 -4
  49. package/skills/df-ps-scaffold/references/units/port.md +2 -5
  50. package/skills/df-ps-scaffold/references/units/services.md +2 -4
  51. package/skills/df-ps-scaffold/references/units/use-case.md +1 -2
  52. package/skills/df-ps-scaffold/references/units/wire-dependency.md +0 -2
  53. package/skills/df-ps-scaffold/references/work-plan.md +73 -0
  54. package/skills/df-ps-scaffold/scripts/drive.mjs +0 -252
package/README.md CHANGED
@@ -347,7 +347,7 @@ The package ships skills that teach coding agents to plan features, scaffold wit
347
347
  npx df-skills --claude
348
348
  ```
349
349
 
350
- Run it again after upgrading the package to get the new versions.
350
+ Run it again after upgrading the package to get the new versions. Add `--principles` to also connect the programming principles to `CLAUDE.md` and `AGENTS.md`.
351
351
 
352
352
  ## License
353
353
 
package/bin/df-skills.mjs CHANGED
@@ -1,17 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { cpSync, existsSync, readdirSync, rmSync } from 'node:fs';
3
+ import { cpSync, existsSync, readdirSync, readFileSync, rmSync } from 'node:fs';
4
4
  import { homedir } from 'node:os';
5
5
  import { dirname, join, relative, resolve } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { parseArgs } from 'node:util';
8
- import { checkbox, select } from '@inquirer/prompts';
8
+ import { checkbox, confirm, select } from '@inquirer/prompts';
9
+ import { applyPrinciples, principlesState } from '../dist/agent-principles.js';
9
10
 
10
- const SKILLS_SOURCE = resolve(dirname(fileURLToPath(import.meta.url)), '..', 'skills');
11
+ const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
12
+ const SKILLS_SOURCE = join(PACKAGE_ROOT, 'skills');
13
+ const PRINCIPLES_SOURCE = join(PACKAGE_ROOT, 'principles', 'df-principles.md');
11
14
 
12
15
  const AGENTS = {
13
- claude: { title: 'Claude Code', folder: join('.claude', 'skills') },
14
- codex: { title: 'Codex', folder: join('.agents', 'skills') },
16
+ claude: { title: 'Claude Code', folder: join('.claude', 'skills'), entry: 'CLAUDE.md' },
17
+ codex: { title: 'Codex', folder: join('.agents', 'skills'), entry: 'AGENTS.md' },
15
18
  };
16
19
 
17
20
  const HELP = `Usage: df-skills [options]
@@ -20,16 +23,19 @@ Copies Domain-First (df-ps) agent skills into your project.
20
23
  Runs interactively when no agent is given.
21
24
 
22
25
  Options:
23
- --claude install for Claude Code (.claude/skills)
24
- --codex install for Codex (.agents/skills)
25
- --global install into the home directory instead of the current project
26
- -h, --help show this help`;
26
+ --claude install for Claude Code (.claude/skills)
27
+ --codex install for Codex (.agents/skills)
28
+ --global install into the home directory instead of the current project
29
+ --principles connect the programming principles to CLAUDE.md and AGENTS.md
30
+ (connected ones are refreshed without this flag; not with --global)
31
+ -h, --help show this help`;
27
32
 
28
33
  const { values } = parseArgs({
29
34
  options: {
30
35
  claude: { type: 'boolean', default: false },
31
36
  codex: { type: 'boolean', default: false },
32
37
  global: { type: 'boolean', default: false },
38
+ principles: { type: 'boolean', default: false },
33
39
  help: { type: 'boolean', short: 'h', default: false },
34
40
  },
35
41
  });
@@ -39,6 +45,20 @@ if (values.help) {
39
45
  process.exit(0);
40
46
  }
41
47
 
48
+ const principles = readFileSync(PRINCIPLES_SOURCE, 'utf8');
49
+
50
+ const refuse = (message) => {
51
+ console.error(message);
52
+ process.exit(1);
53
+ };
54
+
55
+ if (values.principles && values.global) {
56
+ refuse('--principles is not available with --global: they apply to one project.');
57
+ }
58
+ if (values.principles && !principles.trim()) {
59
+ refuse('This version of the package has no programming principles to connect.');
60
+ }
61
+
42
62
  const skills = readdirSync(SKILLS_SOURCE, { withFileTypes: true })
43
63
  .filter((entry) => entry.isDirectory())
44
64
  .map((entry) => entry.name);
@@ -70,6 +90,22 @@ const global =
70
90
 
71
91
  const root = global ? homedir() : process.cwd();
72
92
 
93
+ // The principles of one architecture don't belong in every project of the user.
94
+ const withPrinciples = !global && Boolean(principles.trim());
95
+ const notConnected = withPrinciples
96
+ ? agents.filter((agent) => principlesState(root, agent) === 'absent')
97
+ : [];
98
+ const installPrinciples =
99
+ values.principles ||
100
+ (interactive && notConnected.length > 0
101
+ ? await confirm({
102
+ message: `Add the programming principles to ${notConnected
103
+ .map((agent) => AGENTS[agent].entry)
104
+ .join(' and ')}?`,
105
+ default: true,
106
+ })
107
+ : false);
108
+
73
109
  for (const agent of agents) {
74
110
  const target = join(root, AGENTS[agent].folder);
75
111
  console.log(`\n${AGENTS[agent].title} → ${global ? target : relative(root, target)}`);
@@ -82,4 +118,14 @@ for (const agent of agents) {
82
118
  cpSync(join(SKILLS_SOURCE, skill), destination, { recursive: true });
83
119
  console.log(` ${existed ? 'updated' : 'added '} ${skill}`);
84
120
  }
121
+
122
+ if (!withPrinciples) continue;
123
+ const result = applyPrinciples(root, agent, principles, installPrinciples);
124
+ if (result === 'conflict') {
125
+ console.warn(
126
+ ` skipped principles: fix the df-principles markers in ${AGENTS[agent].entry} (one start, then one end)`
127
+ );
128
+ } else if (result !== 'skipped') {
129
+ console.log(` ${result === 'updated' ? 'updated' : 'added '} principles`);
130
+ }
85
131
  }
package/dist/287.js CHANGED
@@ -4,7 +4,7 @@ import { Separator, checkbox as prompts_checkbox, confirm as prompts_confirm, in
4
4
  import { styleText } from "node:util";
5
5
  import node_fs from "node:fs";
6
6
  import { addImport, availableDependencies, findWiredModules, UnknownFormatNaming, readWiredModule, addClassMember, hasNeighboringBoundedContext, addBranchedImplementation, addWireDependencies, boundedContextLocation, addConstructorParameters, relativeImport, wireBranches, wireDependencies, implementationType as wiring_implementationType, crossContextImportAllowed, crossContextImplementation, isSuggestedFor } from "./947.js";
7
- import { implementationLabelSchema, withoutOverwrites, domainFirstPackages as config_file_domainFirstPackages, scaffoldBackendRules, branchNameSchema, discardPendingChanges, ConfigFile, filesToOverwrite, Folder, writePendingChanges, File, ProjectRoot, compilerOption } from "./780.js";
7
+ import { implementationLabelSchema, withoutOverwrites, domainFirstPackages as config_file_domainFirstPackages, scaffoldBackendRules, branchNameSchema, discardPendingChanges, ConfigFile, filesToOverwrite, Folder, writePendingChanges, File, ProjectRoot, implementationKinds, compilerOption } from "./780.js";
8
8
  import { missingDomainFirstPackages, walk, projectImports, escapeRegExp, pathParameterAsName, hasLegacyRootEndpoints, stageModuleMove, toPosix, rootStaticSegments, openapiExtractorPath, restControllers, hasDependency, openapiExtractor, missingPackages, codeExtension, isPathParameterName } from "./526.js";
9
9
  const moduleId = (module)=>`${boundedContextLocation(module.typeFile)?.name ?? 'shared-kernel'}:${module.typeName}`;
10
10
  const unitId = (unit)=>`${unit.kind}:${unit.aggregate ? `${unit.aggregate}/` : ''}${unit.name}`;
@@ -4217,6 +4217,58 @@ const scaffoldNewImplementation = async (ownerFolder)=>{
4217
4217
  for (const implementation of unused)report(`${implementation.className} is no longer used in any environment.`);
4218
4218
  await wireNewImplementationDependencies(ownerFolder, wireFile, className, inMemoryRepositoryWiring(ownerFolder, unit, wireFile));
4219
4219
  };
4220
+ const helperImplementationTypes = ()=>[
4221
+ ...new Set(implementationKinds.flatMap((kind)=>[
4222
+ ...savedImplementations(kind, 'primary'),
4223
+ ...savedImplementations(kind, 'test'),
4224
+ ...systemImplementationChoices(kind).map(({ value })=>value)
4225
+ ]))
4226
+ ].filter((label)=>label !== crossContextImplementation);
4227
+ const validateName = (value)=>{
4228
+ const valid = NestedName.validate(value);
4229
+ if (true !== valid) return valid;
4230
+ const { folders, folderName } = new NestedName(value);
4231
+ return [
4232
+ ...folders,
4233
+ folderName
4234
+ ].every((part)=>kebabName.test(part)) ? true : 'Use lowercase kebab-case split by "/", e.g. mappers/social-network-type';
4235
+ };
4236
+ const scaffoldNewInfrastructureHelper = async (ownerFolder)=>{
4237
+ const types = helperImplementationTypes();
4238
+ if (!types.length) return void report('No implementation types yet: a helper belongs to one, so add an implementation first.');
4239
+ const name = new NestedName(await interaction_input({
4240
+ key: 'name',
4241
+ message: 'Name (folders split by "/"): ',
4242
+ validate: validateName
4243
+ }));
4244
+ const label = await interaction_select({
4245
+ key: 'implementationType',
4246
+ message: 'Implementation:',
4247
+ choices: types.map((value)=>({
4248
+ name: value,
4249
+ value
4250
+ }))
4251
+ });
4252
+ const fileName = name.folderName.startsWith(`${label}-`) ? name.folderName : `${label}-${name.folderName}`;
4253
+ const naming = new UnknownFormatNaming(fileName);
4254
+ const folder = ownerFolder.subitem([
4255
+ 'infrastructure',
4256
+ 'helpers',
4257
+ label,
4258
+ ...name.folders
4259
+ ]);
4260
+ folder.createFile(`${fileName}.ts`, `export const ${naming.variableName} = () => {}`);
4261
+ if (ConfigFile.backend.testingLibrary) folder.createFile(`${fileName}.spec.ts`, `
4262
+ import { describe, test, expect } from '${ConfigFile.backend.testingLibrary}'
4263
+ import { ${naming.variableName} } from './${fileName}'
4264
+
4265
+ describe('${naming.withSpaces}', () => {
4266
+ test('is defined', () => {
4267
+ expect(${naming.variableName}).toBeDefined()
4268
+ })
4269
+ })
4270
+ `.trim());
4271
+ };
4220
4272
  const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
4221
4273
  const name = await interaction_input({
4222
4274
  key: 'name',
@@ -4616,4 +4668,4 @@ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps
4616
4668
  break;
4617
4669
  }
4618
4670
  };
4619
- export { RequestError, addIntegration, assertAnswersConsumed, configurationSections, deleteBackendUnitUseCase, deleteReactModuleUseCase, findBackendUnits, findContracts, findReactModules, findRestEndpointGenerator, initializeUseCase, integrationDescriptions, integrationIds, moduleId, moveBackendUnitUseCase, moveReactModuleUseCase, printNextSteps, reactKindTitles, rootControllerChoice, runWithAnswers, savePendingChanges, savedImplementations, scaffoldNewAggregateUseCase, scaffoldNewApplicationPort, scaffoldNewApplicationService, scaffoldNewBoundedContextUseCase, scaffoldNewCommand, scaffoldNewDomainObject, scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewHandlersRestEndpoint, scaffoldNewImplementation, scaffoldNewInfrastructureService, scaffoldNewPresentationService, scaffoldNewQuery, scaffoldNewUseCase, scaffoldReactPage, scaffoldReactSharedHook, scaffoldReactUIKitComponent, scaffoldReactWidget, systemImplementationChoices, unitId, wireDependency };
4671
+ export { RequestError, addIntegration, assertAnswersConsumed, configurationSections, deleteBackendUnitUseCase, deleteReactModuleUseCase, findBackendUnits, findContracts, findReactModules, findRestEndpointGenerator, helperImplementationTypes, initializeUseCase, integrationDescriptions, integrationIds, moduleId, moveBackendUnitUseCase, moveReactModuleUseCase, printNextSteps, reactKindTitles, rootControllerChoice, runWithAnswers, savePendingChanges, savedImplementations, scaffoldNewAggregateUseCase, scaffoldNewApplicationPort, scaffoldNewApplicationService, scaffoldNewBoundedContextUseCase, scaffoldNewCommand, scaffoldNewDomainObject, scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewHandlersRestEndpoint, scaffoldNewImplementation, scaffoldNewInfrastructureHelper, scaffoldNewInfrastructureService, scaffoldNewPresentationService, scaffoldNewQuery, scaffoldNewUseCase, scaffoldReactPage, scaffoldReactSharedHook, scaffoldReactUIKitComponent, scaffoldReactWidget, systemImplementationChoices, unitId, wireDependency };
package/dist/38.js CHANGED
@@ -68,6 +68,32 @@ const layerImportRules = {
68
68
  };
69
69
  const baseName = (file)=>node_path.basename(file).replace(/\.[^.]+$/, '');
70
70
  const isOwnContract = (file, target)=>baseName(file).endsWith(`-${baseName(target)}`);
71
+ const helperOf = ([layer, kind, ...rest])=>'infrastructure' === layer && 'helpers' === kind && rest.length ? {
72
+ label: rest.length > 1 ? rest[0] : void 0
73
+ } : void 0;
74
+ const implementationLabelOf = ([layer, kind, label, ...rest])=>'infrastructure' === layer && [
75
+ 'repositories',
76
+ 'commands',
77
+ 'queries',
78
+ 'application-adapters'
79
+ ].includes(kind) && rest.length ? label : void 0;
80
+ const helperImportRule = (from, to, typeOnly)=>{
81
+ const fromHelper = helperOf(from);
82
+ const toHelper = helperOf(to);
83
+ if (toHelper && 'wiring' === from[0]) return 'wiring imports an infrastructure helper:';
84
+ if (fromHelper && !toHelper) {
85
+ const toKind = fileModuleKind(to);
86
+ if ('infrastructure' === to[0] || toKind && !(typeOnly && [
87
+ 'queries',
88
+ 'commands',
89
+ 'application-ports'
90
+ ].includes(toKind))) return 'an infrastructure helper imports a module (only domain models, other helpers and `import type` of query, command and port contracts):';
91
+ }
92
+ if (toHelper?.label) {
93
+ const label = fromHelper ? fromHelper.label : implementationLabelOf(from);
94
+ if ((fromHelper || label) && label !== toHelper.label) return 'imports a helper of another implementation:';
95
+ }
96
+ };
71
97
  const importViolations = (projectRoot, rootFolder, rules)=>{
72
98
  const root = node_path.resolve(projectRoot, rootFolder);
73
99
  const contextsFolder = node_path.join(root, 'bounded-contexts');
@@ -115,6 +141,14 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
115
141
  for (const file of files){
116
142
  const source = node_fs.readFileSync(file, 'utf8');
117
143
  const from = locate(file);
144
+ const helper = from && helperOf(from.segments);
145
+ if (helper && !helper.label) violations.push({
146
+ check: 'layers',
147
+ rule: `[${from.owner}] a helper outside the folder of its implementation (code shared by implementations is an infrastructure service):`,
148
+ file,
149
+ line: 1,
150
+ text: node_path.basename(file)
151
+ });
118
152
  const ownContext = inside(contextsFolder, file)?.[0];
119
153
  const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file, node_path.join(contextsFolder, ownContext))?.implementations.some((implementation)=>isCrossContextImplementation(implementation.file));
120
154
  const report = (check, rule, imported)=>violations.push({
@@ -153,6 +187,8 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
153
187
  if (!from || !to) continue;
154
188
  if (crossContextAllowed) continue;
155
189
  if (isSpec(file)) continue;
190
+ const helperRule = helperImportRule(from.segments, to.segments, imported.typeOnly);
191
+ if (helperRule) report('layers', `[${from.owner}] ${helperRule}`, imported);
156
192
  const fromKind = fileModuleKind(from.segments);
157
193
  const toKind = fileModuleKind(to.segments);
158
194
  if (fromKind && toKind) {
package/dist/561.js CHANGED
@@ -3,7 +3,7 @@ import node_path from "node:path";
3
3
  import { parseArgs } from "node:util";
4
4
  import zod from "zod";
5
5
  import { implementationLabelSchema, discardPendingChanges, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges } from "./780.js";
6
- import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, scaffoldNewQuery, runWithAnswers, scaffoldNewCommand, moveBackendUnitUseCase, findReactModules, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewApplicationService, scaffoldNewImplementation, savedImplementations, RequestError, deleteReactModuleUseCase, rootControllerChoice, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
6
+ import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, helperImplementationTypes, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, runWithAnswers, scaffoldNewCommand, scaffoldNewQuery, findReactModules, moveBackendUnitUseCase, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewApplicationService, scaffoldNewImplementation, savedImplementations, RequestError, deleteReactModuleUseCase, rootControllerChoice, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, scaffoldNewInfrastructureHelper, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
7
7
  import { findWiredModules, availableDependencies, hasNeighboringBoundedContext } from "./947.js";
8
8
  import { restControllers } from "./526.js";
9
9
  const agent_requests_name = implementationLabelSchema;
@@ -75,6 +75,12 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
75
75
  ...named,
76
76
  ...wired
77
77
  }),
78
+ agent_requests_operation('helper', {
79
+ ...common,
80
+ ...agent_requests_owner,
81
+ name: nestedName.describe('Kebab-case, folders split by "/": mappers/social-network-type.'),
82
+ implementationType: agent_requests_name.describe('A saved or system implementation type: a helper belongs to one.')
83
+ }),
78
84
  agent_requests_operation('presentation-service', {
79
85
  ...named,
80
86
  ...wired
@@ -399,6 +405,7 @@ const executeScaffold = async (request, owner)=>{
399
405
  ]).content.fileNames.includes(request.namespace)) throw new RequestError('TARGET_NOT_FOUND', `Unknown namespace: ${request.namespace}.`);
400
406
  if ('implementation' === request.operation && !findContracts(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No contracts in this context.');
401
407
  if (('move' === request.operation || 'delete' === request.operation) && !findBackendUnits(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No modules in this context.');
408
+ if ('helper' === request.operation && !helperImplementationTypes().length) throw new RequestError('TARGET_NOT_FOUND', 'No implementation types yet: add an implementation first.');
402
409
  if ('wire-dependency' === request.operation && (!ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire') || !findWiredModules(owner.path).length)) throw new RequestError('TARGET_NOT_FOUND', 'No wired modules in this context.');
403
410
  if ('endpoint' === request.operation) {
404
411
  if (!ConfigFile.backend.domainFirstPackages.includes('@domain-first/handlers-rest') || !findRestEndpointGenerator(new Folder(requireProject()).subitem([
@@ -419,6 +426,7 @@ const executeScaffold = async (request, owner)=>{
419
426
  'domain-service': ()=>scaffoldNewDomainService(owner),
420
427
  'application-service': ()=>scaffoldNewApplicationService(owner),
421
428
  'infrastructure-service': ()=>scaffoldNewInfrastructureService(owner),
429
+ helper: ()=>scaffoldNewInfrastructureHelper(owner),
422
430
  'presentation-service': ()=>scaffoldNewPresentationService(owner),
423
431
  'use-case': ()=>scaffoldNewUseCase(owner),
424
432
  command: ()=>scaffoldNewCommand(owner),
package/dist/780.js CHANGED
@@ -293,7 +293,8 @@ class File extends FileSystemItem {
293
293
  });
294
294
  };
295
295
  addLineIfMissing = (newLine, separator = '\n')=>{
296
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
296
+ const normalized = (line)=>line.trim().replace(/;$/, '');
297
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
297
298
  if (!alreadyAdded) this.addLine(newLine, separator);
298
299
  };
299
300
  }
package/dist/947.js CHANGED
@@ -212,7 +212,17 @@ const findWiredModules = (contextPath)=>{
212
212
  const moduleKindOf = (module)=>wiredModuleKind(module.kind);
213
213
  const layerRule = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && ('infrastructure' !== consumer.implementationsLayer || 'application' !== candidate.layer || 'application-ports' === candidate.kind);
214
214
  const implementationType = (consumer, implementation)=>consumer.branched ? node_path.basename(node_path.dirname(implementation.file)) : void 0;
215
- const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${node_path.basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
215
+ const systemInfrastructureServices = new Map([
216
+ [
217
+ 'prisma',
218
+ 'prisma-infrastructure-service'
219
+ ],
220
+ [
221
+ 'in-memory',
222
+ 'in-memory-db-infrastructure-service'
223
+ ]
224
+ ]);
225
+ const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && node_path.basename(candidate.typeFile, '.ts') === systemInfrastructureServices.get(implementation);
216
226
  const canDependOn = (consumer, candidate, rules = defaultDependencyRules, implementation = consumer.implementations[0])=>{
217
227
  const crossContext = crossContextImportAllowed(consumer.wireFile, candidate.wireFile);
218
228
  if (void 0 !== crossContext) return crossContext && 'infrastructure' === consumer.implementationsLayer && 'application' === candidate.layer && !!implementation && true === crossContextImportAllowed(implementation.file, candidate.typeFile);
@@ -90,6 +90,13 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
90
90
  context: z.ZodString;
91
91
  overwrite: z.ZodOptional<z.ZodBoolean>;
92
92
  dryRun: z.ZodOptional<z.ZodBoolean>;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ operation: z.ZodLiteral<"helper">;
95
+ name: z.ZodString;
96
+ implementationType: z.ZodString;
97
+ context: z.ZodString;
98
+ overwrite: z.ZodOptional<z.ZodBoolean>;
99
+ dryRun: z.ZodOptional<z.ZodBoolean>;
93
100
  }, z.core.$strict>, z.ZodObject<{
94
101
  operation: z.ZodLiteral<"presentation-service">;
95
102
  dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
@@ -272,9 +279,9 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
272
279
  }, z.core.$strict>], "operation"> | z.ZodObject<{
273
280
  operation: z.ZodLiteral<"add">;
274
281
  integrations: z.ZodArray<z.ZodEnum<{
282
+ prisma: "prisma";
275
283
  openapi: "openapi";
276
284
  orval: "orval";
277
- prisma: "prisma";
278
285
  "rest-endpoint-generator": "rest-endpoint-generator";
279
286
  storybook: "storybook";
280
287
  vitest: "vitest";
@@ -379,7 +386,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
379
386
  } | undefined;
380
387
  }[];
381
388
  integrations: {
382
- id: "openapi" | "orval" | "prisma" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
389
+ id: "prisma" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
383
390
  name: string;
384
391
  group: "backend" | "frontend";
385
392
  available: boolean;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ applyPrinciples: ()=>applyPrinciples,
41
+ principlesState: ()=>principlesState
42
+ });
43
+ const external_node_fs_namespaceObject = require("node:fs");
44
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
45
+ const external_node_path_namespaceObject = require("node:path");
46
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
47
+ const copyName = 'df-principles.md';
48
+ const blockStart = '<!-- df-principles:start -->';
49
+ const blockEnd = '<!-- df-principles:end -->';
50
+ const read = (file)=>external_node_fs_default().existsSync(file) ? external_node_fs_default().readFileSync(file, 'utf8') : void 0;
51
+ const write = (file, content)=>{
52
+ external_node_fs_default().mkdirSync(external_node_path_default().dirname(file), {
53
+ recursive: true
54
+ });
55
+ external_node_fs_default().writeFileSync(file, content);
56
+ };
57
+ const withParagraph = (content, paragraph)=>content?.trim() ? `${content.trimEnd()}\n\n${paragraph}\n` : `${paragraph}\n`;
58
+ const claudeEntries = (root)=>[
59
+ {
60
+ file: external_node_path_default().join(root, 'CLAUDE.md'),
61
+ line: `@.claude/${copyName}`
62
+ },
63
+ {
64
+ file: external_node_path_default().join(root, '.claude', 'CLAUDE.md'),
65
+ line: `@${copyName}`
66
+ }
67
+ ];
68
+ const connectedClaudeEntry = (root)=>claudeEntries(root).find(({ file, line })=>read(file)?.split('\n').some((candidate)=>candidate.trim() === line));
69
+ const occurrences = (content, marker)=>content.split(marker).length - 1;
70
+ const blockState = (content = '')=>{
71
+ const starts = occurrences(content, blockStart);
72
+ const ends = occurrences(content, blockEnd);
73
+ if (!starts && !ends) return 'absent';
74
+ return 1 === starts && 1 === ends && content.indexOf(blockStart) < content.indexOf(blockEnd) ? 'connected' : 'broken';
75
+ };
76
+ const applyToClaude = (root, text, install)=>{
77
+ const copy = external_node_path_default().join(root, '.claude', copyName);
78
+ if (connectedClaudeEntry(root)) {
79
+ write(copy, text);
80
+ return 'updated';
81
+ }
82
+ if (!install) return 'skipped';
83
+ const [rootEntry, nestedEntry] = claudeEntries(root);
84
+ const entry = !external_node_fs_default().existsSync(rootEntry.file) && external_node_fs_default().existsSync(nestedEntry.file) ? nestedEntry : rootEntry;
85
+ write(copy, text);
86
+ write(entry.file, withParagraph(read(entry.file), entry.line));
87
+ return 'added';
88
+ };
89
+ const applyToCodex = (root, text, install)=>{
90
+ const file = external_node_path_default().join(root, 'AGENTS.md');
91
+ const content = read(file);
92
+ const state = blockState(content);
93
+ if ('broken' === state) return 'conflict';
94
+ const block = `${blockStart}\n${text.trim()}\n${blockEnd}`;
95
+ if ('connected' === state && void 0 !== content) {
96
+ write(file, content.slice(0, content.indexOf(blockStart)) + block + content.slice(content.indexOf(blockEnd) + blockEnd.length));
97
+ return 'updated';
98
+ }
99
+ if (!install) return 'skipped';
100
+ write(file, withParagraph(content, block));
101
+ return 'added';
102
+ };
103
+ const principlesState = (root, agent)=>{
104
+ if ('codex' === agent) return blockState(read(external_node_path_default().join(root, 'AGENTS.md')));
105
+ return connectedClaudeEntry(root) ? 'connected' : 'absent';
106
+ };
107
+ const applyPrinciples = (root, agent, text, install)=>('codex' === agent ? applyToCodex : applyToClaude)(root, text, install);
108
+ exports.applyPrinciples = __webpack_exports__.applyPrinciples;
109
+ exports.principlesState = __webpack_exports__.principlesState;
110
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
111
+ "applyPrinciples",
112
+ "principlesState"
113
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
114
+ Object.defineProperty(exports, '__esModule', {
115
+ value: true
116
+ });
@@ -0,0 +1,9 @@
1
+ export type PrinciplesAgent = 'claude' | 'codex';
2
+ export type PrinciplesState = 'connected' | 'absent' | 'broken';
3
+ export type PrinciplesResult = 'added' | 'updated' | 'skipped' | 'conflict';
4
+ export declare const principlesState: (root: string, agent: PrinciplesAgent) => PrinciplesState;
5
+ /**
6
+ * Refreshes connected principles. Connects them only with `install`, so
7
+ * a project that removed them stays without them.
8
+ */
9
+ export declare const applyPrinciples: (root: string, agent: PrinciplesAgent, text: string, install: boolean) => PrinciplesResult;
@@ -0,0 +1,64 @@
1
+ import node_fs from "node:fs";
2
+ import node_path from "node:path";
3
+ const copyName = 'df-principles.md';
4
+ const blockStart = '<!-- df-principles:start -->';
5
+ const blockEnd = '<!-- df-principles:end -->';
6
+ const read = (file)=>node_fs.existsSync(file) ? node_fs.readFileSync(file, 'utf8') : void 0;
7
+ const write = (file, content)=>{
8
+ node_fs.mkdirSync(node_path.dirname(file), {
9
+ recursive: true
10
+ });
11
+ node_fs.writeFileSync(file, content);
12
+ };
13
+ const withParagraph = (content, paragraph)=>content?.trim() ? `${content.trimEnd()}\n\n${paragraph}\n` : `${paragraph}\n`;
14
+ const claudeEntries = (root)=>[
15
+ {
16
+ file: node_path.join(root, 'CLAUDE.md'),
17
+ line: `@.claude/${copyName}`
18
+ },
19
+ {
20
+ file: node_path.join(root, '.claude', 'CLAUDE.md'),
21
+ line: `@${copyName}`
22
+ }
23
+ ];
24
+ const connectedClaudeEntry = (root)=>claudeEntries(root).find(({ file, line })=>read(file)?.split('\n').some((candidate)=>candidate.trim() === line));
25
+ const occurrences = (content, marker)=>content.split(marker).length - 1;
26
+ const blockState = (content = '')=>{
27
+ const starts = occurrences(content, blockStart);
28
+ const ends = occurrences(content, blockEnd);
29
+ if (!starts && !ends) return 'absent';
30
+ return 1 === starts && 1 === ends && content.indexOf(blockStart) < content.indexOf(blockEnd) ? 'connected' : 'broken';
31
+ };
32
+ const applyToClaude = (root, text, install)=>{
33
+ const copy = node_path.join(root, '.claude', copyName);
34
+ if (connectedClaudeEntry(root)) {
35
+ write(copy, text);
36
+ return 'updated';
37
+ }
38
+ if (!install) return 'skipped';
39
+ const [rootEntry, nestedEntry] = claudeEntries(root);
40
+ const entry = !node_fs.existsSync(rootEntry.file) && node_fs.existsSync(nestedEntry.file) ? nestedEntry : rootEntry;
41
+ write(copy, text);
42
+ write(entry.file, withParagraph(read(entry.file), entry.line));
43
+ return 'added';
44
+ };
45
+ const applyToCodex = (root, text, install)=>{
46
+ const file = node_path.join(root, 'AGENTS.md');
47
+ const content = read(file);
48
+ const state = blockState(content);
49
+ if ('broken' === state) return 'conflict';
50
+ const block = `${blockStart}\n${text.trim()}\n${blockEnd}`;
51
+ if ('connected' === state && void 0 !== content) {
52
+ write(file, content.slice(0, content.indexOf(blockStart)) + block + content.slice(content.indexOf(blockEnd) + blockEnd.length));
53
+ return 'updated';
54
+ }
55
+ if (!install) return 'skipped';
56
+ write(file, withParagraph(content, block));
57
+ return 'added';
58
+ };
59
+ const principlesState = (root, agent)=>{
60
+ if ('codex' === agent) return blockState(read(node_path.join(root, 'AGENTS.md')));
61
+ return connectedClaudeEntry(root) ? 'connected' : 'absent';
62
+ };
63
+ const applyPrinciples = (root, agent, text, install)=>('codex' === agent ? applyToCodex : applyToClaude)(root, text, install);
64
+ export { applyPrinciples, principlesState };
@@ -0,0 +1 @@
1
+ export {};
@@ -68,6 +68,13 @@ export declare const scaffoldRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject
68
68
  context: z.ZodString;
69
69
  overwrite: z.ZodOptional<z.ZodBoolean>;
70
70
  dryRun: z.ZodOptional<z.ZodBoolean>;
71
+ }, z.core.$strict>, z.ZodObject<{
72
+ operation: z.ZodLiteral<"helper">;
73
+ name: z.ZodString;
74
+ implementationType: z.ZodString;
75
+ context: z.ZodString;
76
+ overwrite: z.ZodOptional<z.ZodBoolean>;
77
+ dryRun: z.ZodOptional<z.ZodBoolean>;
71
78
  }, z.core.$strict>, z.ZodObject<{
72
79
  operation: z.ZodLiteral<"presentation-service">;
73
80
  dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
@@ -252,9 +259,9 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
252
259
  export declare const integrationRequestSchema: z.ZodObject<{
253
260
  operation: z.ZodLiteral<"add">;
254
261
  integrations: z.ZodArray<z.ZodEnum<{
262
+ prisma: "prisma";
255
263
  openapi: "openapi";
256
264
  orval: "orval";
257
- prisma: "prisma";
258
265
  "rest-endpoint-generator": "rest-endpoint-generator";
259
266
  storybook: "storybook";
260
267
  vitest: "vitest";
@@ -353,6 +360,13 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
353
360
  context: z.ZodString;
354
361
  overwrite: z.ZodOptional<z.ZodBoolean>;
355
362
  dryRun: z.ZodOptional<z.ZodBoolean>;
363
+ }, z.core.$strict>, z.ZodObject<{
364
+ operation: z.ZodLiteral<"helper">;
365
+ name: z.ZodString;
366
+ implementationType: z.ZodString;
367
+ context: z.ZodString;
368
+ overwrite: z.ZodOptional<z.ZodBoolean>;
369
+ dryRun: z.ZodOptional<z.ZodBoolean>;
356
370
  }, z.core.$strict>, z.ZodObject<{
357
371
  operation: z.ZodLiteral<"presentation-service">;
358
372
  dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
@@ -535,9 +549,9 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
535
549
  }, z.core.$strict>], "operation"> | z.ZodObject<{
536
550
  operation: z.ZodLiteral<"add">;
537
551
  integrations: z.ZodArray<z.ZodEnum<{
552
+ prisma: "prisma";
538
553
  openapi: "openapi";
539
554
  orval: "orval";
540
- prisma: "prisma";
541
555
  "rest-endpoint-generator": "rest-endpoint-generator";
542
556
  storybook: "storybook";
543
557
  vitest: "vitest";
@@ -54,7 +54,8 @@ export declare class File extends FileSystemItem {
54
54
  update: (content: string) => void;
55
55
  addLine: (newLine: string, separator?: string) => void;
56
56
  /**
57
- * Re-running a generator for the same name must not duplicate the line.
57
+ * Re-running a generator for the same name must not duplicate the line,
58
+ * also after a formatter added the semicolon.
58
59
  */
59
60
  addLineIfMissing: (newLine: string, separator?: string) => void;
60
61
  }
package/dist/graph.cjs CHANGED
@@ -180,7 +180,8 @@ class file_system_File extends FileSystemItem {
180
180
  });
181
181
  };
182
182
  addLineIfMissing = (newLine, separator = '\n')=>{
183
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
183
+ const normalized = (line)=>line.trim().replace(/;$/, '');
184
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
184
185
  if (!alreadyAdded) this.addLine(newLine, separator);
185
186
  };
186
187
  }
@@ -497,6 +498,16 @@ const wiring_findWiredModules = (contextPath)=>{
497
498
  walk(external_node_path_default().join(contextPath, 'wiring'));
498
499
  return result.sort((a, b)=>a.typeName.localeCompare(b.typeName));
499
500
  };
501
+ new Map([
502
+ [
503
+ 'prisma',
504
+ 'prisma-infrastructure-service'
505
+ ],
506
+ [
507
+ 'in-memory',
508
+ 'in-memory-db-infrastructure-service'
509
+ ]
510
+ ]);
500
511
  const codeOnly = (source)=>{
501
512
  let result = '';
502
513
  let index = 0;