@domain-first/project-structure 7.2.0 → 8.1.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 (66) hide show
  1. package/README.md +125 -26
  2. package/dist/201.js +87 -338
  3. package/dist/287.js +1235 -575
  4. package/dist/561.js +519 -0
  5. package/dist/711.js +22 -0
  6. package/dist/870.js +438 -0
  7. package/dist/agent-cli.d.ts +379 -0
  8. package/dist/agent-cli.spec.d.ts +1 -0
  9. package/dist/agent-identifiers.d.ts +4 -0
  10. package/dist/agent-requests.d.ts +490 -0
  11. package/dist/config-file.d.ts +231 -26
  12. package/dist/config-file.spec.d.ts +1 -0
  13. package/dist/context-dependencies.d.ts +16 -0
  14. package/dist/dependency-rules.d.ts +17 -17
  15. package/dist/file-system.d.ts +10 -1
  16. package/dist/implementation-choices.d.ts +8 -0
  17. package/dist/implementation-choices.spec.d.ts +1 -0
  18. package/dist/implementation-options-schema.d.ts +14 -0
  19. package/dist/index.cjs +3645 -584
  20. package/dist/index.js +20 -7
  21. package/dist/init.cjs +717 -122
  22. package/dist/init.js +24 -12
  23. package/dist/integration.cjs +3783 -186
  24. package/dist/integration.js +29 -17
  25. package/dist/integrations/rest-endpoint-generator.d.ts +4 -2
  26. package/dist/integrations/storybook.d.ts +1 -0
  27. package/dist/interaction.d.ts +41 -0
  28. package/dist/lint.cjs +165 -41
  29. package/dist/lint.js +22 -7
  30. package/dist/module-move.d.ts +6 -2
  31. package/dist/next-app.d.ts +7 -0
  32. package/dist/react-module-move.d.ts +17 -2
  33. package/dist/react.cjs +5181 -421
  34. package/dist/react.js +72 -60
  35. package/dist/system-implementations.d.ts +6 -0
  36. package/dist/upgrade-steps.d.ts +81 -0
  37. package/dist/upgrade-steps.spec.d.ts +1 -0
  38. package/dist/upgrade.cjs +593 -0
  39. package/dist/upgrade.d.ts +2 -0
  40. package/dist/upgrade.js +235 -0
  41. package/dist/use-cases/add-integration.d.ts +16 -1
  42. package/dist/use-cases/cross-context-dependencies.spec.d.ts +1 -0
  43. package/dist/use-cases/initialize.d.ts +4 -4
  44. package/dist/use-cases/initialize.spec.d.ts +1 -0
  45. package/dist/use-cases/prompt-implementation-type.d.ts +20 -0
  46. package/dist/use-cases/scaffold-react-page.d.ts +3 -1
  47. package/dist/wire-branches.d.ts +26 -0
  48. package/dist/wiring.d.ts +3 -2
  49. package/package.json +3 -2
  50. package/skills/df-ps-implement/SKILL.md +9 -8
  51. package/skills/df-ps-plan-feature/SKILL.md +8 -7
  52. package/skills/df-ps-react/SKILL.md +14 -8
  53. package/skills/df-ps-react/references/generators.md +6 -2
  54. package/skills/df-ps-scaffold/SKILL.md +28 -17
  55. package/skills/df-ps-scaffold/references/agent-mode.md +72 -0
  56. package/skills/df-ps-scaffold/references/agent-operations.md +155 -0
  57. package/skills/df-ps-scaffold/references/choosing-components.md +13 -13
  58. package/skills/df-ps-scaffold/references/generators.md +20 -3
  59. package/skills/df-ps-scaffold/references/units/aggregate.md +4 -3
  60. package/skills/df-ps-scaffold/references/units/bounded-context.md +1 -1
  61. package/skills/df-ps-scaffold/references/units/command-query.md +12 -12
  62. package/skills/df-ps-scaffold/references/units/implementation.md +2 -2
  63. package/skills/df-ps-scaffold/references/units/move-or-rename.md +1 -1
  64. package/skills/df-ps-scaffold/references/units/port.md +7 -4
  65. package/skills/df-ps-scaffold/references/units/use-case.md +1 -1
  66. package/skills/df-ps-scaffold/scripts/drive.mjs +9 -1
@@ -4,9 +4,9 @@ When: a repository, command, query or port already exists and needs one more imp
4
4
 
5
5
  ## Generate (context and Shared Kernel)
6
6
 
7
- Prompts: `Contract:` (select, grouped: Repositories, Commands, Queries, Ports; each with its implementations: `file-storage (in-memory, s3)`) → `Implementation type:` (kebab-case, one the contract doesn't have) → {wire} `Environments:` (checkbox `test`, `development`, `production`, each shown with its current implementation: `development (now: s3)`; at least one) → {wire} `Dependencies for <Implementation>:` for the new implementation only (`../generators.md`).
7
+ Prompts: `Contract:` → `Implementation type:` → {wire} `Environments:` (at least one) → {wire} dependencies for the new implementation. The type menu merges the category's primary/test history with active system choices and both manual-entry actions (`../generators.md`); it has no ordinary `api`, `mock` or `in-memory` presets. System choices are explicitly marked and conditional: cross-context for ports with a neighbor, shared in-memory DB for repositories/commands/queries with that integration ready. Existing types are disabled. Saving a new ordinary label registers it under `test` and/or `primary` according to selected environments (primary without usable wiring). The run-only action registers nothing.
8
8
 
9
- `… pick:Infrastructure "pick:New Implementation" pick:file-storage text:local toggle:2`
9
+ `… pick:Infrastructure "pick:New Implementation" pick:file-storage "pick:Enter implementation type and save for future use" text:local toggle:2`
10
10
 
11
11
  `toggle:` numbers the environments top to bottom: 1 `test`, 2 `development`, 3 `production`.
12
12
 
@@ -12,7 +12,7 @@ Prompts: `Module:` (select, grouped by kind; entities and value objects of an ag
12
12
 
13
13
  Every file of the module moves (contract, implementations, wire, specs; an aggregate with its whole folder), every import of it follows, and derived names change in the module and its importers: `OrderRepository`, `PrismaOrderRepository`, `wireOrderRepository`, dependents' `orderRepository` parameters, an aggregate's in-memory DB section. An entity leaving its aggregate is no longer re-exported there; its importers import its file.
14
14
 
15
- Before `Apply?` the CLI lists the files to move and to update: check them against the plan. A move that would make a context import another one prints `Nothing was moved: these imports would cross a bounded context boundary.` with the imports: nothing changed. Fix the design instead (`../choosing-components.md`, step 9: the other context gets its own query or command), or move the dependency first.
15
+ Before `Apply?` the CLI lists the files to move and to update: check them against the plan. A move that would introduce a forbidden context import prints `Nothing was moved: these imports would cross a bounded context boundary.` with the imports: nothing changed. Fix the design instead (`../choosing-components.md`, step 9: the consuming context gets a port with a cross-context adapter), or move the dependency first.
16
16
 
17
17
  In the plan, list a move as a run: old → new place and name, the files to move (`→`) and the files whose imports or names change (`~`).
18
18
 
@@ -1,12 +1,13 @@
1
1
  # Port
2
2
 
3
- When: something that leaves this context's code and storage: an external system or time (`../choosing-components.md`, step 10, "Port or service?"). Own storage → repository, command or query; another context → a query or command, never a port. One method is enough: a single read from an external system is still a port. Another context is only a folder in `bounded-contexts/`; any other service (another team's API, a SaaS) is external. Wanting to mock a class or imagining multiple implementations is not enough. The `clock` port is always a port, usually in the Shared Kernel.
3
+ When: a capability across this context's boundary: another bounded context, an external system, or time (`../choosing-components.md`, steps 9–10). Own aggregate persistence → repository; atomic operations on this context's own storage → command/query. One method is enough. Wanting to mock a class or imagining multiple implementations does not by itself establish a boundary. The `clock` port usually belongs in the Shared Kernel.
4
4
 
5
5
  ## Generate (context and Shared Kernel)
6
6
 
7
- Prompts: name → adapter implementation (default `api`) → `With test implementation` → if yes: test implementation (default `mock`) → {wire} `Dependencies for <Implementation>:` per implementation (`../generators.md`).
7
+ Prompts: name → primary adapter select → `With test implementation` → test adapter select if yes → {wire} dependencies per adapter. Both selects show saved port types for their role, active system types and both manual-entry actions (`../generators.md`). The only automatic system choice is `System: cross-context (calls handlers in another bounded context)`, conditional on a neighboring context and unavailable in the Shared Kernel. No `api`, `mock` or `in-memory` presets are inserted for ports. The first saved/system choice is the default; manual input is empty without saved choices. Existing labels are disabled. Saved ordinary port types are isolated from other categories. Save-entry updates `ports` history; run-only entry generates the adapter without updating the catalog.
8
8
 
9
- `… pick:Application "pick:New Port" text:payment-gateway default yes default`
9
+ `… pick:Application "pick:New Port" text:payment-gateway "pick:Enter implementation type and save for future use" text:api yes "pick:Enter implementation type and save for future use" text:mock`
10
+ `… pick:Application "pick:New Port" text:billing-gateway "pick:System: cross-context" yes "pick:Enter implementation type for this run only" text:mock`
10
11
 
11
12
  - `<C>/application/ports/n.ts` (abstract `N`; name it after the capability), spec
12
13
  - `<C>/infrastructure/application-adapters/I/I-n.ts` per implementation (`class IN extends N`)
@@ -15,9 +16,11 @@ Prompts: name → adapter implementation (default `api`) → `With test implemen
15
16
  ## Implement
16
17
 
17
18
  - Abstract members in the port, described in the capability's terms (`charge(amount: Money)`), not the provider's.
19
+ - For another context, define the port in the consuming context with its own models and errors. A `cross-context` adapter can inject queries, commands and use cases from any neighboring context; choices are labelled `(<context>)` and names get context-qualified aliases. Only this adapter imports neighboring handler types, and only its matching wiring imports their factories. Never import foreign models, errors, repositories, ports, services, infrastructure or barrels.
20
+ - Implement the capability's methods by mapping input, invoking injected handlers, and mapping results/errors. The CLI creates the contract, adapters and dependencies; it does not generate methods or delegation. Keep business coordination in the consuming use case.
18
21
  - One implementation per adapter: `api` performs the real interaction (an SDK or HTTP client, through an [infrastructure service](services.md) for the client); `mock`/`fake` is deterministic.
19
22
  - Use the Shared Kernel `clock` port instead of `new Date()` / `Date.now()` in domain and application code.
20
23
 
21
24
  ## Test
22
25
 
23
- `NODE_ENV=test` wires the test implementation, so the logic that uses the port is tested with it.
26
+ Use a deterministic `mock`/`stub` adapter so tests do not run neighboring contexts. `NODE_ENV=test` wires the test implementation, so the logic that uses the port is tested with it.
@@ -1,6 +1,6 @@
1
1
  # Use case
2
2
 
3
- When: one business action a user or system triggers that doesn't fit into a single query or command (`../choosing-components.md`, step 8). **No proxy use cases**: an action that is exactly one query or command gets none, because every query and command is a handler an endpoint can use directly. A use case whose logic lives in an application service is not a proxy.
3
+ When: one business action a user or system triggers that doesn't fit into a single query or command (`../choosing-components.md`, step 8). **No proxy use cases**: an action that is exactly one query or command gets none, because every query and command is a handler an endpoint can use directly. A use case is also the handler for an action that calls a port: the port has capability methods, not `handle`. A use case whose logic lives in an application service is not a proxy.
4
4
 
5
5
  ## Generate (context only)
6
6
 
@@ -6,15 +6,23 @@
6
6
  *
7
7
  * Usage:
8
8
  * node drive.mjs [--bin <name>] [--cwd <dir>] [--delay <ms>] <step> [<step> ...]
9
+ * node drive.mjs "pick:Bounded Context: sales" pick:Application "pick:New Port" text:billing-gateway "pick:System: cross-context" no toggle:1
10
+ * (when the dependency list has the desired neighboring handler at item 1)
9
11
  *
10
12
  * Steps (one per prompt, in the order the CLI asks them):
11
13
  * pick:<label> select prompt: type the choice label (or a unique prefix) and press Enter
12
14
  * text:<value> input prompt: type the value and press Enter
13
- * default input prompt: accept the suggested default (press Enter)
15
+ * default input/select prompt: accept the suggested default (press Enter)
14
16
  * yes | no confirm prompt
15
17
  * toggle:<n,..> checkbox prompt: toggle 1-based items (headers not counted),
16
18
  * moving with the arrow keys, then press Enter
17
19
  * none checkbox prompt: submit as is (pre-checked items stay checked)
20
+ *
21
+ * Implementation menus use the same pick:<label> steps as any select:
22
+ * a saved implementation label or an available System: implementation,
23
+ * or either manual-entry action followed by a separate text:<type> step:
24
+ * "pick:Enter implementation type and save for future use" text:redis
25
+ * "pick:Enter implementation type for this run only" text:redis
18
26
  */
19
27
  import { spawn } from 'node:child_process';
20
28
  import fs from 'node:fs';