@pbuilder/sdk 0.13.0 → 0.15.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 (207) hide show
  1. package/README.md +57 -42
  2. package/dist/{transport → acl/irwire}/frame-reader.d.ts +2 -0
  3. package/dist/{transport → acl/irwire}/frame-reader.js +57 -5
  4. package/dist/{transport → acl/irwire}/stdio-engine-client.d.ts +2 -2
  5. package/dist/{transport → acl/irwire}/stdio-engine-client.js +4 -4
  6. package/dist/bin/pbuilder-codegen.js +30 -35
  7. package/dist/bin/pbuilder-runner.js +6 -6
  8. package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.d.ts +106 -0
  9. package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.js +202 -0
  10. package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/render.d.ts +2 -2
  11. package/dist/{core → bounded-contexts/authoring/application/usecases/run-factory}/context.d.ts +12 -9
  12. package/dist/{core → bounded-contexts/authoring/application/usecases/run-factory}/context.js +59 -120
  13. package/dist/bounded-contexts/authoring/application/usecases/run-factory/driving.d.ts +5 -0
  14. package/dist/bounded-contexts/authoring/application/usecases/run-factory/driving.js +15 -0
  15. package/dist/bounded-contexts/authoring/application/usecases/scaffold/classify-transport.d.ts +51 -0
  16. package/dist/bounded-contexts/authoring/application/usecases/scaffold/classify-transport.js +105 -0
  17. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/expander.d.ts +2 -1
  18. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/expander.js +16 -7
  19. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/index.d.ts +1 -1
  20. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/index.js +7 -6
  21. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/path-guards.d.ts +11 -10
  22. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/path-guards.js +21 -48
  23. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/walk.d.ts +2 -3
  24. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/walk.js +37 -56
  25. package/dist/{core → bounded-contexts/authoring/domain/aggregates/session}/session.d.ts +2 -2
  26. package/dist/{core → bounded-contexts/authoring/domain/aggregates/session}/session.js +1 -1
  27. package/dist/{core → bounded-contexts/authoring/domain/entities}/dialect-handle.d.ts +1 -1
  28. package/dist/{core → bounded-contexts/authoring/domain/entities}/dialect-handle.js +10 -10
  29. package/dist/{core → bounded-contexts/authoring/domain/ports}/engine-client.d.ts +1 -1
  30. package/dist/bounded-contexts/authoring/domain/ports/package-files.d.ts +53 -0
  31. package/dist/bounded-contexts/authoring/domain/ports/package-files.js +11 -0
  32. package/dist/{core → bounded-contexts/authoring/domain/services}/define-dialect.d.ts +2 -2
  33. package/dist/{core → bounded-contexts/authoring/domain/services}/define-dialect.js +3 -3
  34. package/dist/{core → bounded-contexts/authoring/domain/services}/directive-factory.d.ts +2 -2
  35. package/dist/{core → bounded-contexts/authoring/domain/services}/directive-factory.js +37 -12
  36. package/dist/{scaffold → bounded-contexts/authoring/domain/services}/filename-pipeline.d.ts +11 -1
  37. package/dist/{scaffold → bounded-contexts/authoring/domain/services}/filename-pipeline.js +94 -3
  38. package/dist/{core/jsx-name-validator.d.ts → bounded-contexts/authoring/domain/services/identifier-names.d.ts} +8 -4
  39. package/dist/{core/jsx-name-validator.js → bounded-contexts/authoring/domain/services/identifier-names.js} +21 -28
  40. package/dist/bounded-contexts/authoring/domain/services/reject-tail.d.ts +9 -0
  41. package/dist/bounded-contexts/authoring/domain/services/reject-tail.js +30 -0
  42. package/dist/bounded-contexts/authoring/domain/services/run-context.d.ts +5 -0
  43. package/dist/bounded-contexts/authoring/domain/services/run-context.js +70 -0
  44. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/input-rejection.d.ts +1 -1
  45. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/input-rejection.js +1 -1
  46. package/dist/bounded-contexts/authoring/domain/services/schema/schema-files.d.ts +2 -0
  47. package/dist/bounded-contexts/authoring/domain/services/schema/schema-files.js +6 -0
  48. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-locate.d.ts +2 -1
  49. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-locate.js +13 -2
  50. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-parse.d.ts +1 -1
  51. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-parse.js +2 -14
  52. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-sufficiency.d.ts +4 -3
  53. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-sufficiency.js +8 -4
  54. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-validate.d.ts +1 -1
  55. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-validate.js +1 -1
  56. package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/authoring-error.js +1 -1
  57. package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/wire.d.ts +0 -3
  58. package/dist/bounded-contexts/authoring/domain/valueobjects/wire.js +28 -0
  59. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.d.ts +27 -0
  60. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.js +306 -0
  61. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.d.ts +7 -0
  62. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.js +68 -0
  63. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.d.ts +19 -0
  64. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.js +131 -0
  65. package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.d.ts +182 -0
  66. package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.js +94 -0
  67. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.d.ts +63 -0
  68. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.js +68 -0
  69. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/angular/ops.js +9 -9
  70. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.d.ts +40 -0
  71. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.js +38 -0
  72. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ops.js +2 -2
  73. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.d.ts +55 -0
  74. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.js +54 -0
  75. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ops.d.ts +1 -1
  76. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ops.js +35 -8
  77. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.d.ts +43 -0
  78. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.js +46 -0
  79. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/nestjs/ops.js +7 -7
  80. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.d.ts +52 -0
  81. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.js +73 -0
  82. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/jsx-names.d.ts +4 -0
  83. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/jsx-names.js +18 -0
  84. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/match-tails.d.ts +4 -0
  85. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/match-tails.js +25 -0
  86. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.js +5 -3
  87. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/array-element.d.ts +7 -2
  88. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/array-element.js +29 -15
  89. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.d.ts +5 -1
  90. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.js +22 -4
  91. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/class-property.js +14 -19
  92. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.d.ts +53 -0
  93. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.js +37 -0
  94. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.d.ts +6 -1
  95. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.js +90 -54
  96. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.d.ts +69 -0
  97. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.js +70 -0
  98. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/paths.d.ts +1 -1
  99. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/paths.js +2 -2
  100. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/presentation.js +1 -1
  101. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/structural.js +2 -2
  102. package/dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.d.ts +8 -0
  103. package/dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.js +133 -0
  104. package/dist/bounded-contexts/authoring/testing/conformance/index.d.ts +157 -0
  105. package/dist/bounded-contexts/authoring/testing/conformance/index.js +261 -0
  106. package/dist/{testing → bounded-contexts/authoring/testing}/contract-fake.d.ts +2 -2
  107. package/dist/{testing → bounded-contexts/authoring/testing}/contract-fake.js +4 -3
  108. package/dist/bounded-contexts/authoring/testing/harness/index.d.ts +89 -0
  109. package/dist/bounded-contexts/authoring/testing/harness/index.js +85 -0
  110. package/dist/{conformance → bounded-contexts/authoring/testing}/run-vehicle.d.ts +1 -1
  111. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/bootstrap-bridge.js +2 -2
  112. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/exit-codes.js +5 -4
  113. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/factory-pointer.js +1 -1
  114. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/runner.d.ts +4 -0
  115. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/runner.js +49 -23
  116. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/single-instance-probe.js +1 -1
  117. package/dist/commons/index.d.ts +1 -278
  118. package/dist/commons/index.js +1 -286
  119. package/dist/conformance/index.d.ts +1 -157
  120. package/dist/conformance/index.js +1 -261
  121. package/dist/dialects/angular/index.d.ts +1 -63
  122. package/dist/dialects/angular/index.js +1 -68
  123. package/dist/dialects/css/index.d.ts +1 -40
  124. package/dist/dialects/css/index.js +1 -38
  125. package/dist/dialects/json/index.d.ts +1 -55
  126. package/dist/dialects/json/index.js +1 -54
  127. package/dist/dialects/nestjs/index.d.ts +1 -43
  128. package/dist/dialects/nestjs/index.js +1 -46
  129. package/dist/dialects/react/index.d.ts +1 -52
  130. package/dist/dialects/react/index.js +1 -73
  131. package/dist/dialects/typescript/index.d.ts +1 -53
  132. package/dist/dialects/typescript/index.js +1 -37
  133. package/dist/dialects/yaml/index.d.ts +1 -69
  134. package/dist/dialects/yaml/index.js +1 -70
  135. package/dist/{core → platform}/deep-equal.js +2 -2
  136. package/dist/{transport → platform}/error-text.js +2 -2
  137. package/dist/runner-manifest.json +66 -46
  138. package/dist/shared-kernel/batch-cap.d.ts +4 -0
  139. package/dist/{core/wire.js → shared-kernel/batch-cap.js} +9 -26
  140. package/dist/{transport → shared-kernel}/framing.js +2 -2
  141. package/dist/{transport → shared-kernel}/wire-protocol.js +1 -1
  142. package/dist/testing/index.d.ts +1 -84
  143. package/dist/testing/index.js +1 -82
  144. package/package.json +9 -3
  145. package/dist/core/index.d.ts +0 -10
  146. package/dist/core/index.js +0 -6
  147. package/dist/core/reject-tail.d.ts +0 -13
  148. package/dist/core/reject-tail.js +0 -52
  149. package/dist/core/schema/schema-discovery.d.ts +0 -13
  150. package/dist/core/schema/schema-discovery.js +0 -51
  151. package/dist/scaffold/classify-transport.d.ts +0 -54
  152. package/dist/scaffold/classify-transport.js +0 -119
  153. /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/index.d.ts +0 -0
  154. /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/index.js +0 -0
  155. /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/render.js +0 -0
  156. /package/dist/{core → bounded-contexts/authoring/domain/entities}/base-handle.d.ts +0 -0
  157. /package/dist/{core → bounded-contexts/authoring/domain/entities}/base-handle.js +0 -0
  158. /package/dist/{core → bounded-contexts/authoring/domain/entities}/handle-state.d.ts +0 -0
  159. /package/dist/{core → bounded-contexts/authoring/domain/entities}/handle-state.js +0 -0
  160. /package/dist/{core → bounded-contexts/authoring/domain/ports}/emit-rejection.d.ts +0 -0
  161. /package/dist/{core → bounded-contexts/authoring/domain/ports}/emit-rejection.js +0 -0
  162. /package/dist/{core → bounded-contexts/authoring/domain/ports}/engine-client.js +0 -0
  163. /package/dist/{commons → bounded-contexts/authoring/domain/services}/classify-content.d.ts +0 -0
  164. /package/dist/{commons → bounded-contexts/authoring/domain/services}/classify-content.js +0 -0
  165. /package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-digest.d.ts +0 -0
  166. /package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-digest.js +0 -0
  167. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/authoring-error.d.ts +0 -0
  168. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/dialect-error.d.ts +0 -0
  169. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/dialect-error.js +0 -0
  170. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/json-value.d.ts +0 -0
  171. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/json-value.js +0 -0
  172. /package/dist/{core/schema → bounded-contexts/authoring/domain/valueobjects}/schema-model.d.ts +0 -0
  173. /package/dist/{core/schema → bounded-contexts/authoring/domain/valueobjects}/schema-model.js +0 -0
  174. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/angular/ops.d.ts +0 -0
  175. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ast.d.ts +0 -0
  176. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ast.js +0 -0
  177. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ops.d.ts +0 -0
  178. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ast.d.ts +0 -0
  179. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ast.js +0 -0
  180. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/nestjs/ops.d.ts +0 -0
  181. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ast.d.ts +0 -0
  182. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ast.js +0 -0
  183. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.d.ts +0 -0
  184. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/class-property.d.ts +0 -0
  185. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/import-order.d.ts +0 -0
  186. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/import-order.js +0 -0
  187. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/pack.d.ts +0 -0
  188. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/pack.js +0 -0
  189. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/ast.d.ts +0 -0
  190. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/ast.js +0 -0
  191. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/documents.d.ts +0 -0
  192. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/documents.js +0 -0
  193. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/presentation.d.ts +0 -0
  194. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/structural.d.ts +0 -0
  195. /package/dist/{testing → bounded-contexts/authoring/testing}/rejection-messages.d.ts +0 -0
  196. /package/dist/{testing → bounded-contexts/authoring/testing}/rejection-messages.js +0 -0
  197. /package/dist/{conformance → bounded-contexts/authoring/testing}/run-vehicle.js +0 -0
  198. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/bootstrap-bridge.d.ts +0 -0
  199. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/exit-codes.d.ts +0 -0
  200. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/factory-pointer.d.ts +0 -0
  201. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/single-instance-probe.d.ts +0 -0
  202. /package/dist/{core → platform}/deep-equal.d.ts +0 -0
  203. /package/dist/{transport → platform}/error-text.d.ts +0 -0
  204. /package/dist/{core → platform}/fs-errors.d.ts +0 -0
  205. /package/dist/{core → platform}/fs-errors.js +0 -0
  206. /package/dist/{transport → shared-kernel}/framing.d.ts +0 -0
  207. /package/dist/{transport → shared-kernel}/wire-protocol.d.ts +0 -0
@@ -1,286 +1 @@
1
- // Author surface: positional + trailing options, frozen public API (KIT-03/SKEL-01/KIT-04).
2
- // No AST imports. All handle write-ops wired (S-003).
3
- import { posix } from "node:path";
4
- import { currentContext } from "../core/context.js";
5
- import { forceEntry } from "../core/directive-factory.js";
6
- import { AuthoringError } from "../core/authoring-error.js";
7
- import { readTemplateFile, runScaffold, runCopyIn } from "../scaffold/index.js";
8
- // ADR-0023: AuthoringError (+ its supporting types) is an author-facing DATA type, not
9
- // kit MACHINERY (the port, the session, the directive factory stay unexported) — it
10
- // legitimately crosses the ADR-0009 boundary via the same two-step pattern
11
- // FoundHandle/WritableHandle already use.
12
- export { AuthoringError };
13
- // 2.3 (CQ-1, droppable): classifyContent + ContentState give authors a named,
14
- // branchable read-result classification (see find()'s JSDoc pointer below). Severable
15
- // from the AuthoringError cluster above — no other component references it.
16
- export { classifyContent } from "./classify-content.js";
17
- // Pure factory for WritableHandle. Returned by every write verb.
18
- function buildWritableHandle(path) {
19
- return {
20
- read() {
21
- const { session } = currentContext();
22
- return session.read(path);
23
- },
24
- replaceContent(content) {
25
- const { session, factory } = currentContext();
26
- session.buffer(factory.modify({ path, content }));
27
- return buildWritableHandle(path);
28
- },
29
- rename(newName, opts) {
30
- const { session, factory } = currentContext();
31
- session.buffer(factory.rename({ path, newName, ...forceEntry(opts?.force) }));
32
- const dir = posix.dirname(path);
33
- return buildWritableHandle(dir === "." ? newName : posix.join(dir, newName));
34
- },
35
- move(toDir, opts) {
36
- const { session, factory } = currentContext();
37
- session.buffer(factory.move({ path, toDir, ...forceEntry(opts?.force) }));
38
- return buildWritableHandle(posix.join(toDir, posix.basename(path)));
39
- },
40
- copy(to, opts) {
41
- const { session, factory } = currentContext();
42
- session.buffer(factory.copy({ from: path, to, ...forceEntry(opts?.force) }));
43
- return buildWritableHandle(to);
44
- },
45
- };
46
- }
47
- // FoundHandle factory. Returned exclusively by find(). Has remove().
48
- function buildFoundHandle(path) {
49
- return {
50
- read() {
51
- const { session } = currentContext();
52
- return session.read(path);
53
- },
54
- replaceContent(content) {
55
- const { session, factory } = currentContext();
56
- session.buffer(factory.modify({ path, content }));
57
- return buildWritableHandle(path);
58
- },
59
- rename(newName, opts) {
60
- const { session, factory } = currentContext();
61
- session.buffer(factory.rename({ path, newName, ...forceEntry(opts?.force) }));
62
- const dir = posix.dirname(path);
63
- return buildWritableHandle(dir === "." ? newName : posix.join(dir, newName));
64
- },
65
- move(toDir, opts) {
66
- const { session, factory } = currentContext();
67
- session.buffer(factory.move({ path, toDir, ...forceEntry(opts?.force) }));
68
- return buildWritableHandle(posix.join(toDir, posix.basename(path)));
69
- },
70
- copy(to, opts) {
71
- const { session, factory } = currentContext();
72
- session.buffer(factory.copy({ from: path, to, ...forceEntry(opts?.force) }));
73
- return buildWritableHandle(to);
74
- },
75
- remove() {
76
- const { session, factory } = currentContext();
77
- session.buffer(factory.remove({ path }));
78
- },
79
- };
80
- }
81
- /**
82
- * Locates an existing file and returns a `FoundHandle` for reading or removing it.
83
- *
84
- * `read()` resolves `string | undefined`: the content, `undefined` when the path does not
85
- * exist, or `""` when the file exists but is empty. Branch on the three outcomes with strict
86
- * `=== undefined` / `=== ""` — NEVER `if (!content)`, which would merge `undefined`, `""`,
87
- * `"0"` and `"false"` and reintroduce the absent-vs-empty bug. Prefer `classifyContent()`
88
- * over manual comparisons — it names the trichotomy and gives exhaustive-switch parity.
89
- *
90
- * @example
91
- * const c = await find("src/config.ts").read();
92
- * if (c === undefined) create("src/config.ts", { template, options });
93
- * else if (c === "") replaceContent("src/config.ts", seedContent);
94
- * else replaceContent("src/config.ts", patch(c));
95
- */
96
- export function find(path) {
97
- return buildFoundHandle(path);
98
- }
99
- export function create(path, opts) {
100
- const { session, factory } = currentContext();
101
- // The wire requires `options`, and an omitted bag (untyped callers) would vanish in JSON and
102
- // fail the batch's round-trip check as unrepresentable content.
103
- const options = opts.options === undefined ? {} : opts.options;
104
- const template = "templateFile" in opts ? readTemplateFile(opts.templateFile, path, options, opts.force) : opts.template;
105
- session.buffer(factory.create({
106
- pathTemplate: path,
107
- template,
108
- options,
109
- ...forceEntry(opts.force),
110
- }));
111
- return buildWritableHandle(path);
112
- }
113
- /**
114
- * Walks a package-local folder (`from`, resolved against the active Session's `packageDir`)
115
- * and mirrors every entry into `to`, applying the rename → filename-token-translation →
116
- * `.template`-strip pipeline (REQ-FSC-05) and include/exclude glob filtering (REQ-FSC-03,
117
- * `exclude` wins on overlap). Each source classifies by-value or by-reference
118
- * (`content-classification`, entirely sniffed — never author-declared); by-value sources
119
- * emit a `create` directive through the existing IR. A `from` folder with zero entries
120
- * no-ops silently; `include`/`exclude` eliminating every entry rejects fail-loud, naming
121
- * the filters (REQ-FSC-04 — two distinct outcomes, never collapsed). `force` (default
122
- * `false`) passes through unchanged to every emitted directive, no per-file override
123
- * (REQ-FSC-06). Two or more sources collapsing to the same destination reject fail-loud,
124
- * naming every offending source (REQ-FSC-08). Only usable inside a
125
- * factory invocation started with packageDir — there is no resolution anchor to walk a
126
- * package-local folder against otherwise (`invalid-input`, never a cwd fallback).
127
- *
128
- * `rename` is a static REMAP TABLE (`Record<originalSourceRelativePath,
129
- * newDestinationRelativePath>`), matched against the ORIGINAL (pre-token-translation)
130
- * source path — distinct from the `rename()` verb, which renames one already-targeted
131
- * file's basename at emit time, not a folder-walk's per-entry destination.
132
- *
133
- * A NESTED symlinked directory is never descended, regardless of where its target
134
- * resolves — skipped silently, no error; enumeration determinism and cycle-safety are the
135
- * rationale (a symlinked directory could point anywhere, including into a cycle — never
136
- * descending is the simplest invariant that is safe under all targets, REQ-FSC-09). The
137
- * walk ROOT (`from` itself) is held to a stricter standard: a symlinked root REJECTS
138
- * (`invalid-input`) rather than being followed or silently skipped (owner ruling 16) — but
139
- * this check inspects only `from`'s FINAL path component; a symlink at a MID-path segment
140
- * (e.g. `from: "link/sub"`) is not detected and the walk proceeds through it, the same
141
- * documented residual SECURITY.md covers for `create`/`copyIn` reads. The walk is capped
142
- * at 10,000 enumerated entries per call, failing loud and naming the bound past that
143
- * (REQ-FSC-09) — a loop-safety/DoS resource guard no real schematic collection should
144
- * approach.
145
- *
146
- * **Packaging caveat**: the empty-folder no-op (above) depends on `from` existing ON
147
- * DISK at run time — npm tarball packaging commonly DROPS empty directories, so an
148
- * empty `from` folder that relies on this no-op may not survive `npm publish` at all
149
- * (REQ-FSC-04). Ship at least a placeholder file if the folder's presence matters.
150
- *
151
- * Returns `void` (REQ-FSC-07) — fire-and-forget, no chainable handle group.
152
- *
153
- * @example
154
- * scaffold({ from: "files", to: "src/generated", options: { name: "Widget" } });
155
- */
156
- export function scaffold(args) {
157
- runScaffold(args);
158
- }
159
- /**
160
- * Emits a by-reference copy of ONE package-local file (`from`, resolved against the active
161
- * run's `packageDir`) to `to` — ALWAYS by-reference, NEVER classified or rendered
162
- * (REQ-FEH-03), regardless of the source's own text-vs-binary shape: a text asset
163
- * containing `{= =}`-like sequences (that `scaffold` would otherwise render as tokens)
164
- * travels verbatim — the documented escape from `scaffold`'s by-value classification
165
- * (`content-classification` REQ-CCL-04). Contrast with tree→tree `copy`: `copyIn`'s source
166
- * is a PACKAGE-LOCAL path read at emission time, not an existing tree entry.
167
- *
168
- * `from`/`to` are mandatory; `force` defaults `false`. A missing `from`/`to` rejects
169
- * fail-loud before any emission (REQ-FEH-04.1/.2). Collision without `force` rejects;
170
- * `force: true` overwrites (`by-reference-copy-wire` REQ-BRC-05). Only usable inside a
171
- * factory invocation started with packageDir — there is no resolution anchor to read a
172
- * package-local file against otherwise (`invalid-input`, never a cwd fallback).
173
- *
174
- * Returns `void` (REQ-FEH-04.3) — NOT a `WritableHandle`, unlike `copy`: a by-reference
175
- * destination's bytes exist only after the ENGINE applies the directive (the fake never
176
- * materializes them, `author-test-harness` REQ-ATH-15) — a handle chaining over tree
177
- * CONTENT would lie about content that was never staged. This asymmetry with `copy`
178
- * (which DOES stage tree→tree content the fake can chain over) is deliberate.
179
- *
180
- * @example
181
- * copyIn("assets/logo.svg", "src/generated/logo.svg");
182
- */
183
- export function copyIn(from, to, opts) {
184
- runCopyIn({ from, to, force: opts?.force });
185
- }
186
- /**
187
- * Schedules an in-place content replacement for an existing file and returns a `WritableHandle`.
188
- * A rejected Session (e.g. the target does not exist) throws `AuthoringError`.
189
- *
190
- * @example
191
- * replaceContent("src/config.json", '{ "version": "2.0.0" }');
192
- */
193
- export function replaceContent(path, content) {
194
- const { session, factory } = currentContext();
195
- session.buffer(factory.modify({ path, content }));
196
- return buildWritableHandle(path);
197
- }
198
- /**
199
- * Schedules a file deletion. Idempotent — deleting an absent file is not an error.
200
- *
201
- * @example
202
- * remove("src/legacy.ts");
203
- */
204
- export function remove(path) {
205
- const { session, factory } = currentContext();
206
- session.buffer(factory.remove({ path }));
207
- }
208
- /**
209
- * Schedules a file rename (basename only) and returns a `WritableHandle` for the new path.
210
- * Renaming onto an existing path is rejected at the engine seam unless
211
- * `{ force: true }` is passed (overwrite-on-collision, ADR-0017 fail-closed) — a
212
- * rejected Session throws `AuthoringError`.
213
- *
214
- * @example
215
- * rename("src/foo.ts", "bar.ts");
216
- */
217
- export function rename(path, newName, opts) {
218
- const { session, factory } = currentContext();
219
- session.buffer(factory.rename({ path, newName, ...forceEntry(opts?.force) }));
220
- const dir = posix.dirname(path);
221
- return buildWritableHandle(dir === "." ? newName : posix.join(dir, newName));
222
- }
223
- /**
224
- * Schedules a file move to a different directory and returns a `WritableHandle`.
225
- * Moving onto an existing destination is rejected at the engine seam unless
226
- * `{ force: true }` is passed (overwrite-on-collision, ADR-0017 fail-closed) — a
227
- * rejected Session throws `AuthoringError`.
228
- * A move whose destination equals its source is a no-op, never a collision
229
- * (ADR-0017 self-move amendment).
230
- *
231
- * @example
232
- * move("src/utils/helper.ts", "src/shared");
233
- */
234
- export function move(path, toDir, opts) {
235
- const { session, factory } = currentContext();
236
- session.buffer(factory.move({ path, toDir, ...forceEntry(opts?.force) }));
237
- return buildWritableHandle(posix.join(toDir, posix.basename(path)));
238
- }
239
- /**
240
- * Schedules a file copy to a new path and returns a `WritableHandle` for the destination.
241
- * Copying onto an existing destination is rejected at the engine seam unless
242
- * `{ force: true }` is passed (overwrite-on-collision, ADR-0017 fail-closed) — a
243
- * rejected Session throws `AuthoringError`.
244
- *
245
- * @example
246
- * copy("src/template.ts", "src/generated/output.ts");
247
- */
248
- export function copy(from, to, opts) {
249
- const { session, factory } = currentContext();
250
- session.buffer(factory.copy({ from, to, ...forceEntry(opts?.force) }));
251
- return buildWritableHandle(to);
252
- }
253
- // --- Stage 3: pending Directives exposure (REQ-DRE-01..04) ---
254
- import { renderPendingDirectives } from "../pending-directives/index.js";
255
- /**
256
- * Returns the Directives still pending in the active Session's buffer, rendered in
257
- * author vocabulary.
258
- *
259
- * Only what is still pending appears — the honest answer to "what will this Session
260
- * still emit", not "what has this Session emitted in total." A `read()` (or any flush)
261
- * drains the pending buffer, so Directives already sent no longer appear.
262
- *
263
- * Entries carry verb and path — no content or byte preview — plus an optional `kind`
264
- * (`"rendered" | "copied"`) present only on the package-local-read verbs whose transport
265
- * is classified: `create` (inline or `templateFile`, `kind: "rendered"`) and `copyIn`
266
- * (`kind: "copied"`). The tree→tree `copy` verb also materializes content but predates
267
- * this axis and is never package-local-read/classified, so it carries no `kind`.
268
- *
269
- * Call it inside an active factory invocation, like every other `./commons` verb.
270
- *
271
- * @example
272
- * const run = () => {
273
- * create("src/index.ts", { template: "export const version = '1.0.0';", options: {} });
274
- * find("src/legacy.ts").remove();
275
- * for (const entry of pendingDirectives()) {
276
- * console.log(entry.verb, entry.path); // "create src/index.ts", then "remove src/legacy.ts"
277
- * }
278
- * };
279
- *
280
- * @throws When called outside an active factory invocation, propagates the standard
281
- * error — authoring verbs "can only be used while a schematic is running" (ADR-0026: the
282
- * message no longer enumerates individual verbs, so it covers `pendingDirectives` too).
283
- */
284
- export function pendingDirectives() {
285
- return renderPendingDirectives(currentContext().session.pendingDirectives());
286
- }
1
+ export * from "../bounded-contexts/authoring/infrastructure/in/commons/index.js";
@@ -1,157 +1 @@
1
- import type { Dialect, Handle, OpPack } from "../core/define-dialect.ts";
2
- /**
3
- * Runtime module contract; native namespace exports also preserve upstream types.
4
- *
5
- * @example
6
- * import type { DialectModule } from "@pbuilder/sdk/conformance";
7
- * import * as typescript from "@pbuilder/sdk/typescript";
8
- *
9
- * const module: DialectModule<typeof typescript.astLibrary> = typescript;
10
- * const project = new module.astLibrary.Project({ useInMemoryFileSystem: true });
11
- * const ast = project.createSourceFile("example.ts", "const answer = 1;\n");
12
- * console.assert(module.astLibrary.Node.isSourceFile(ast));
13
- */
14
- export interface DialectModule<Library extends object = object> {
15
- readonly find: (path: string) => Handle<"found", unknown, {}>;
16
- readonly astLibrary: Library;
17
- }
18
- /**
19
- * Actual entrypoint, independent adapter-library evidence, and a byte-exact editing exercise.
20
- * The library exercise receives two arguments; public handle callbacks still receive only the AST.
21
- *
22
- * @example
23
- * // In this repository's test/conformance/ directory:
24
- * import { testDialect, type DialectFixture } from "@pbuilder/sdk/conformance";
25
- * import * as module from "@pbuilder/sdk/typescript";
26
- * import * as expectedAstLibrary from "ts-morph";
27
- * import { defineDialect } from "../../src/core/define-dialect.ts";
28
- * import { parse, print } from "../../src/dialects/typescript/ast.ts";
29
- *
30
- * const exerciseLibrary: DialectFixture<typeof expectedAstLibrary>["libraryExercise"]["modify"] = (ast, library) => {
31
- * if (!(ast instanceof library.SourceFile) || !library.Node.isSourceFile(ast)) {
32
- * throw new Error("incompatible adapter library");
33
- * }
34
- * ast.getVariableStatements()[0]!.setDeclarationKind(library.VariableDeclarationKind.Const);
35
- * };
36
- * const fixture: DialectFixture<typeof expectedAstLibrary> = {
37
- * dialect: defineDialect({ extensions: [".ts"], ast: { parse, print }, ops: {} }),
38
- * samples: ["const x = 1;\n"],
39
- * module,
40
- * expectedAstLibrary,
41
- * libraryExercise: {
42
- * path: "example.ts", seed: "let answer = 1;\n", expect: "const answer = 1;\n",
43
- * modify: exerciseLibrary,
44
- * },
45
- * };
46
- * await testDialect(fixture);
47
- */
48
- export interface DialectFixture<Library extends object = object> {
49
- /** The dialect instance to exercise. */
50
- dialect: Dialect;
51
- /** Representative source strings the dialect's parse/print round-trip must survive byte-exact. */
52
- samples: string[];
53
- module: DialectModule<Library>;
54
- /** Independent evidence from the adapter's library dependency, not the tested export. */
55
- expectedAstLibrary: Library;
56
- libraryExercise: {
57
- path: string;
58
- seed: string;
59
- expect: string;
60
- modify: (ast: unknown, library: Library) => void;
61
- };
62
- }
63
- /**
64
- * One op-invocation recipe `testOpPack` applies to a seeded target: seed the file, run the
65
- * op `chain` (named pack ops and/or the universal `.modify`), and assert the coalesced
66
- * `modify`'s content is BYTE-EXACT `expect` — a full-output comparison, never a substring,
67
- * so one assertion proves both the op's intended effect AND that every other region is
68
- * byte-stable (REQ-DC-02's unchanged-elsewhere).
69
- *
70
- * @example
71
- * const exercise: OpExercise = {
72
- * seed: "export const x = 1;",
73
- * chain: [{ op: "addImport", args: ["readFileSync", "node:fs"] }],
74
- * expect: 'import { readFileSync } from "node:fs";\nexport const x = 1;',
75
- * };
76
- */
77
- export interface OpExercise {
78
- /** Initial content seeded at `path` (flush-seed-rule, REQ-MC-04) — never a `create()` target. */
79
- seed: string;
80
- /** Optional target path; the kit defaults to a stable name using `baseDialect.extensions[0]`. */
81
- path?: string;
82
- /** Ops applied in order: a named pack op (`op` + `args`), or the universal `.modify`. */
83
- chain: ReadonlyArray<{
84
- readonly op: string;
85
- readonly args: readonly unknown[];
86
- } | {
87
- readonly modify: (ast: unknown) => void;
88
- }>;
89
- /** BYTE-EXACT printed content of the coalesced `modify` directive after the chain runs. */
90
- expect: string;
91
- }
92
- /**
93
- * Fixture passed to `testOpPack` to drive the conformance suite.
94
- * The fixture supplies the op-pack under test, the base dialect it augments, and the
95
- * op-invocation recipes (`exercises`) the kit needs to actually apply each op and assert
96
- * byte-exact effects — REQUIRED at the type level so an exercise-less fixture cannot
97
- * silently skip `testOpPack`'s load-bearing per-op assertions (REQ-DC-02..04).
98
- *
99
- * @example
100
- * const fixture: OpPackFixture = {
101
- * opPack: myInsertImportOps,
102
- * baseDialect: myTypeScriptDialect,
103
- * exercises: [
104
- * {
105
- * seed: "export const x = 1;",
106
- * chain: [{ op: "addImport", args: ["readFileSync", "node:fs"] }],
107
- * expect: 'import { readFileSync } from "node:fs";\nexport const x = 1;',
108
- * },
109
- * ],
110
- * };
111
- */
112
- export interface OpPackFixture {
113
- /** The op-pack to exercise against a real base dialect (not a mock). */
114
- opPack: OpPack;
115
- /** The base dialect that holds the live AST — required by ADR-0012 (op-packs tested against real dialects). */
116
- baseDialect: Dialect;
117
- /** The op-invocation recipes `testOpPack` applies — REQUIRED (rev 5, ADR-0012 amendment). */
118
- exercises: readonly OpExercise[];
119
- }
120
- /**
121
- * Runs the conformance suite for a dialect: asserts parse/print no-op round-trip fidelity
122
- * (REQ-DC-01) — `print(parse(sample)) === sample` BYTE-EXACT, never AST-equal, for every
123
- * sample in `fixture.samples` PLUS the four mandatory adversarial samples the kit injects on
124
- * every run (REQ-DC-06 — additive, not opt-out-able). Before each round-trip check, verifies
125
- * `fixture.dialect.ast.parse` is a REAL parser, not an identity/stub function (REQ-DC-08): a
126
- * `parse` returning `null`/`undefined`, or the input string unchanged, fails BEFORE the
127
- * round-trip assertion could vacuously pass.
128
- *
129
- * Requires runtime library exports matching independent adapter evidence, then exercises
130
- * the actual module's `find().modify()` through a real run with byte-exact emitted output.
131
- */
132
- export declare function testDialect<Library extends object>(fixture: DialectFixture<Library>): Promise<void>;
133
- /**
134
- * Runs the conformance suite for an op-pack against a REAL base dialect (never a mock,
135
- * ADR-0012): for each of `fixture.exercises`, asserts single-op fidelity +
136
- * unchanged-elsewhere (REQ-DC-02) / coalescing-to-one content-verified (REQ-DC-03) via a
137
- * no-read run, seam-serializability (REQ-DC-04) over every emitted directive, and — for
138
- * every multi-op exercise — the read-boundary split (REQ-DC-05.2's live counterpart): a
139
- * mid-chain `read()` must force exactly TWO cumulative modify directives, never one. Finally,
140
- * asserts `fixture.baseDialect` survives the four mandatory adversarial samples' round-trip +
141
- * real-base probe (REQ-DC-06/REQ-DC-08 — additive, not opt-out-able, same mechanism
142
- * `testDialect` runs), unconditionally on every call whose exercises pass.
143
- *
144
- * @example
145
- * await testOpPack({
146
- * opPack: myInsertImportOps,
147
- * baseDialect: myTypeScriptDialect,
148
- * exercises: [
149
- * {
150
- * seed: "export const x = 1;",
151
- * chain: [{ op: "addImport", args: ["readFileSync", "node:fs"] }],
152
- * expect: 'import { readFileSync } from "node:fs";\nexport const x = 1;',
153
- * },
154
- * ],
155
- * });
156
- */
157
- export declare function testOpPack(fixture: OpPackFixture): Promise<void>;
1
+ export * from "../bounded-contexts/authoring/testing/conformance/index.ts";