@pbuilder/sdk 0.3.1 → 0.5.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 +57 -17
  2. package/dist/commons/index.d.ts +22 -22
  3. package/dist/commons/index.js +25 -22
  4. package/dist/conformance/index.d.ts +2 -2
  5. package/dist/conformance/index.js +38 -19
  6. package/dist/core/authoring-error.d.ts +3 -3
  7. package/dist/core/authoring-error.js +5 -5
  8. package/dist/core/context.d.ts +6 -6
  9. package/dist/core/context.js +18 -18
  10. package/dist/core/define-dialect.d.ts +1 -1
  11. package/dist/core/define-dialect.js +16 -9
  12. package/dist/core/dialect-handle.js +9 -9
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/core/json-value.d.ts +14 -0
  15. package/dist/core/json-value.js +43 -0
  16. package/dist/core/session.d.ts +1 -1
  17. package/dist/core/session.js +2 -2
  18. package/dist/dialects/json/ast.d.ts +24 -0
  19. package/dist/dialects/json/ast.js +21 -0
  20. package/dist/dialects/json/index.d.ts +55 -0
  21. package/dist/dialects/json/index.js +54 -0
  22. package/dist/dialects/json/ops.d.ts +46 -0
  23. package/dist/dialects/json/ops.js +561 -0
  24. package/dist/dialects/react/index.d.ts +1 -1
  25. package/dist/dialects/react/index.js +1 -1
  26. package/dist/dialects/typescript/index.d.ts +2 -2
  27. package/dist/dialects/typescript/index.js +2 -2
  28. package/dist/dialects/typescript/ops.js +1 -1
  29. package/dist/dialects/yaml/ast.d.ts +15 -0
  30. package/dist/dialects/yaml/ast.js +154 -0
  31. package/dist/dialects/yaml/documents.d.ts +8 -0
  32. package/dist/dialects/yaml/documents.js +24 -0
  33. package/dist/dialects/yaml/index.d.ts +69 -0
  34. package/dist/dialects/yaml/index.js +70 -0
  35. package/dist/dialects/yaml/paths.d.ts +55 -0
  36. package/dist/dialects/yaml/paths.js +208 -0
  37. package/dist/dialects/yaml/presentation.d.ts +24 -0
  38. package/dist/dialects/yaml/presentation.js +264 -0
  39. package/dist/dialects/yaml/structural.d.ts +39 -0
  40. package/dist/dialects/yaml/structural.js +307 -0
  41. package/dist/pending-directives/index.d.ts +2 -0
  42. package/dist/pending-directives/index.js +1 -0
  43. package/dist/{dry-run/plan.d.ts → pending-directives/render.d.ts} +8 -33
  44. package/dist/{dry-run/plan.js → pending-directives/render.js} +5 -5
  45. package/dist/runner-manifest.json +6 -6
  46. package/dist/scaffold/expander.js +3 -3
  47. package/dist/scaffold/index.d.ts +1 -1
  48. package/dist/scaffold/index.js +1 -1
  49. package/dist/transport/error-text.d.ts +6 -1
  50. package/dist/transport/error-text.js +94 -31
  51. package/package.json +16 -3
  52. package/schemas/project-builder.schema.json +112 -0
  53. package/dist/dry-run/index.d.ts +0 -2
  54. package/dist/dry-run/index.js +0 -1
@@ -1,31 +1,7 @@
1
1
  import type { Directive } from "../core/wire.ts";
2
+ import type { AuthoringVerb } from "../core/authoring-error.ts";
2
3
  /**
3
- * Author-facing verb vocabulary for a dry-run plan entry.
4
- *
5
- * Frozen at exactly these seven members — adding a member is a MAJOR event (ADR-0025).
6
- * `schematic-local-files` S-003 (ADR-0025 amendment): grew from six to seven — `copyIn`
7
- * added, 1:1 with the `copyIn` wire op (ADR-0043).
8
- *
9
- * @example
10
- * function label(verb: DryRunVerb): string {
11
- * switch (verb) {
12
- * case "create": return "creates";
13
- * case "modify": return "modifies";
14
- * case "remove": return "removes";
15
- * case "rename": return "renames";
16
- * case "move": return "moves";
17
- * case "copy": return "copies";
18
- * case "copyIn": return "copies in";
19
- * default: {
20
- * const exhaustive: never = verb;
21
- * return exhaustive;
22
- * }
23
- * }
24
- * }
25
- */
26
- export type DryRunVerb = "create" | "modify" | "remove" | "rename" | "move" | "copy" | "copyIn";
27
- /**
28
- * One entry of a rendered dry-run plan: the author verb and the primary path the
4
+ * One pending Directive rendered in author vocabulary: the author verb and the primary path the
29
5
  * operation targets. Carries no content or byte preview.
30
6
  *
31
7
  * `kind` is present ONLY on the package-local-READ verbs whose transport is CLASSIFIED
@@ -42,19 +18,18 @@ export type DryRunVerb = "create" | "modify" | "remove" | "rename" | "move" | "c
42
18
  * about its own behavior).
43
19
  *
44
20
  * @example
45
- * const plan = dryRun(); // from "@pbuilder/sdk/commons"
46
- * for (const entry of plan) {
21
+ * for (const entry of pendingDirectives()) { // from "@pbuilder/sdk/commons"
47
22
  * console.log(entry.verb, entry.path, entry.kind);
48
23
  * }
49
24
  */
50
- export interface DryRunEntry {
51
- verb: DryRunVerb;
25
+ export interface PendingDirective {
26
+ verb: AuthoringVerb;
52
27
  path: string;
53
28
  kind?: "rendered" | "copied";
54
29
  }
55
- export declare const WIRE_TO_AUTHOR_VERB: Readonly<Record<Directive["op"], DryRunVerb>>;
30
+ export declare const WIRE_TO_AUTHOR_VERB: Readonly<Record<Directive["op"], AuthoringVerb>>;
56
31
  /**
57
- * Renders a directive snapshot as an author-vocabulary plan.
32
+ * Renders pending Directives in author vocabulary.
58
33
  *
59
34
  * Each entry carries the author verb (per the frozen `WIRE_TO_AUTHOR_VERB` table above)
60
35
  * and the primary source path of the operation:
@@ -66,4 +41,4 @@ export declare const WIRE_TO_AUTHOR_VERB: Readonly<Record<Directive["op"], DryRu
66
41
  * copy → copy.from (primary source path)
67
42
  * copyIn → copyIn.from (primary source path, REQ-BRC-07 package-relative)
68
43
  */
69
- export declare function dryRunPlan(snapshot: readonly Directive[]): DryRunEntry[];
44
+ export declare function renderPendingDirectives(directives: readonly Directive[]): PendingDirective[];
@@ -1,8 +1,8 @@
1
1
  // Frozen seven-row wire→author verb map — delete→remove, identity elsewhere (including
2
2
  // copyIn→copyIn). EXPORTED for the D3 consistency test (test-only reach, §4.6b): NOT
3
- // re-exported by src/dry-run/index.ts or ./commons. The Record<Directive["op"], DryRunVerb>
3
+ // re-exported by src/pending-directives/index.ts or ./commons. The Record<Directive["op"], AuthoringVerb>
4
4
  // annotation itself compile-enforces totality over wire ops and value-membership in
5
- // DryRunVerb; Object.freeze makes the "frozen" claim literal at runtime.
5
+ // AuthoringVerb; Object.freeze makes the "frozen" claim literal at runtime.
6
6
  export const WIRE_TO_AUTHOR_VERB = Object.freeze({
7
7
  create: "create",
8
8
  modify: "modify",
@@ -13,7 +13,7 @@ export const WIRE_TO_AUTHOR_VERB = Object.freeze({
13
13
  copyIn: "copyIn",
14
14
  });
15
15
  /**
16
- * Renders a directive snapshot as an author-vocabulary plan.
16
+ * Renders pending Directives in author vocabulary.
17
17
  *
18
18
  * Each entry carries the author verb (per the frozen `WIRE_TO_AUTHOR_VERB` table above)
19
19
  * and the primary source path of the operation:
@@ -25,8 +25,8 @@ export const WIRE_TO_AUTHOR_VERB = Object.freeze({
25
25
  * copy → copy.from (primary source path)
26
26
  * copyIn → copyIn.from (primary source path, REQ-BRC-07 package-relative)
27
27
  */
28
- export function dryRunPlan(snapshot) {
29
- return snapshot.map((d) => {
28
+ export function renderPendingDirectives(directives) {
29
+ return directives.map((d) => {
30
30
  const verb = WIRE_TO_AUTHOR_VERB[d.op];
31
31
  switch (d.op) {
32
32
  // "rendered" — every `create` IS a render request, inline `template` or
@@ -2,7 +2,7 @@
2
2
  "manifestVersion": 1,
3
3
  "algorithm": "sha256",
4
4
  "entry": "dist/bin/pbuilder-runner.js",
5
- "packageVersion": "0.3.1",
5
+ "packageVersion": "0.5.0",
6
6
  "files": [
7
7
  {
8
8
  "path": "dist/bin/pbuilder-runner.js",
@@ -10,11 +10,11 @@
10
10
  },
11
11
  {
12
12
  "path": "dist/core/authoring-error.js",
13
- "sha256": "cae518ed676614d754a58edb8fbb5c857c9dcdc7994e960d688c662a9774df53"
13
+ "sha256": "e7ac92bcd689f78911230841da74dc458ca0281ef69734ca1f8a42ac77a20576"
14
14
  },
15
15
  {
16
16
  "path": "dist/core/context.js",
17
- "sha256": "5a8b416fbf4c715e320dc51892766285d1d1ecb3733cfd5c138596e6bd4f969b"
17
+ "sha256": "e5bc7098b04a42487d0632f847efbbf88e66628d0b8241345ad16f178ae78e30"
18
18
  },
19
19
  {
20
20
  "path": "dist/core/directive-factory.js",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  {
56
56
  "path": "dist/core/session.js",
57
- "sha256": "4661d074fa557ec01981df7d19b5a722d89135693eaea727a849d03bd08fdd51"
57
+ "sha256": "bdb3c5cd7fe86028818d9de766c14b67070fea0fc3866f7e1fb5310f1605056e"
58
58
  },
59
59
  {
60
60
  "path": "dist/core/wire.js",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  {
64
64
  "path": "dist/transport/error-text.js",
65
- "sha256": "1dbb02d8e889c2747cc56209c76238a3686676d7d48561c085b03ffc2041b939"
65
+ "sha256": "e857d5f2e844564f9d21930e833bd2e7b179253235d3c38a3af389f2573ca329"
66
66
  },
67
67
  {
68
68
  "path": "dist/transport/exit-codes.js",
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "path": "package.json",
101
- "sha256": "5e427d8c807d686899a66bb02209b22447a74e9e0607ff6e47c75c0173a7559a"
101
+ "sha256": "be7fadf1443334e3af115de2b5c9fc3a081a19cda6a58f0659adc0e0530ef754"
102
102
  }
103
103
  ]
104
104
  }
@@ -1,6 +1,6 @@
1
1
  // src/scaffold/expander.ts (ADR-0044): the SINGLE owner of the scaffold fan-out — drives
2
2
  // `walk.ts` → `filename-pipeline.ts` → `classify-transport.ts` → emits `factory.create(...)`/
3
- // `factory.copyIn(...)` directives via the run's session (Executor Context §18).
3
+ // `factory.copyIn(...)` directives via the Session (Executor Context §18).
4
4
  // `classify-transport.ts` stays a PURE per-file decision; a by-reference VERDICT is handled
5
5
  // HERE, not there. S-003: the by-reference verdict now emits a real `copyIn` directive
6
6
  // (`from` package-relative, REQ-BRC-07) instead of S-001/S-002's fail-loud placeholder throw.
@@ -118,7 +118,7 @@ export function runScaffold(args) {
118
118
  // function, ABOVE `currentContext()`, so an escaping `to` called OUTSIDE any run reported
119
119
  // `invalid-input` where `copyIn` (whose own version of this same guard already runs
120
120
  // AFTER its `currentContext()`/`requirePackageAnchors` calls, see `index.ts`'s
121
- // `runCopyIn`) reports `outside-run` — the two package-local verbs disagreed on which
121
+ // `runCopyIn`) reports `outside-session` — the two package-local verbs disagreed on which
122
122
  // failure wins when BOTH apply. `runScaffold` now mirrors `runCopyIn`'s exact ordering:
123
123
  // ctx → packageDir → destination guard → (new F7/F1 screens below) → source guard. The
124
124
  // existing post-rename/post-token-translation validation of the FINAL `destPath` inside
@@ -155,7 +155,7 @@ export function runScaffold(args) {
155
155
  // and maintained incrementally. Byte-identical to re-serializing the whole batch per
156
156
  // append: JSON array bytes are additive — each extra element contributes exactly its own
157
157
  // `JSON.stringify` bytes plus one comma when it is not the first.
158
- const seedPending = session.pendingSnapshot();
158
+ const seedPending = session.pendingDirectives();
159
159
  let pendingCount = seedPending.length;
160
160
  let pendingSize = serializedBatchSize(seedPending);
161
161
  for (const result of pipelineResults) {
@@ -3,7 +3,7 @@ export { runScaffold } from "./expander.ts";
3
3
  export type { ScaffoldArgs } from "./expander.ts";
4
4
  export { isSniffableText } from "./classify-transport.ts";
5
5
  /**
6
- * Reads a package-local file (relative to the active run's `packageDir`) and returns its
6
+ * Reads a package-local file (relative to the active Session's `packageDir`) and returns its
7
7
  * content as the string to use for a `create({ templateFile })` render request.
8
8
  *
9
9
  * ADR-0077: the path is screened lexically (`validateSourceLexical`, `ir-path-well-formedness`
@@ -27,7 +27,7 @@ function templateFileOversizedMessage(relPath) {
27
27
  // so this module's surface is unchanged.
28
28
  export { isSniffableText } from "./classify-transport.js";
29
29
  /**
30
- * Reads a package-local file (relative to the active run's `packageDir`) and returns its
30
+ * Reads a package-local file (relative to the active Session's `packageDir`) and returns its
31
31
  * content as the string to use for a `create({ templateFile })` render request.
32
32
  *
33
33
  * ADR-0077: the path is screened lexically (`validateSourceLexical`, `ir-path-well-formedness`
@@ -6,4 +6,9 @@ export declare function boundMessage(message: string): string;
6
6
  export declare function formatRelativeCandidate(candidate: string): string;
7
7
  export declare function toProjectRelativePath(subjectPath: string, projectRoot?: string): string;
8
8
  export declare function composeWithToken(prefix: string, token: string, suffix?: string): string;
9
- export declare function scrubAbsolutePaths(message: string, projectRoot?: string): string;
9
+ export interface ScrubAnchor {
10
+ token: string;
11
+ path: string;
12
+ }
13
+ export declare function hostAnchors(projectRoot?: string): ScrubAnchor[];
14
+ export declare function scrubAbsolutePaths(message: string, projectRoot?: string, anchors?: readonly ScrubAnchor[]): string;
@@ -4,7 +4,9 @@
4
4
  // module source excerpts, no raw peer frame bytes), and every path is expressed
5
5
  // project-relative, NEVER absolute (falling back to the `<outside-project>` placeholder
6
6
  // when no relative form is meaningful, e.g. a different filesystem root).
7
- import { isAbsolute, relative } from "node:path";
7
+ import { realpathSync } from "node:fs";
8
+ import { dirname, isAbsolute, relative } from "node:path";
9
+ import { fileURLToPath } from "node:url";
8
10
  // SDK-chosen placeholders pending engine-side confirmation — same provenance posture as
9
11
  // SEC-05's timeout bound and WPS-06's BATCH_CAP_BYTES.
10
12
  export const MESSAGE_CEILING_CHARS = 2000;
@@ -42,36 +44,97 @@ export function toProjectRelativePath(subjectPath, projectRoot = process.cwd())
42
44
  export function composeWithToken(prefix, token, suffix = "") {
43
45
  return boundMessage(`${prefix}${truncateToken(token)}${suffix}`);
44
46
  }
45
- // REQ-WPS-07.4/.6, ADR-02: Windows-drive-letter or UNC/WSL-interop backslash-prefixed
46
- // shapes — replaced FIRST, unconditionally, since node:path's POSIX-default
47
- // isAbsolute/relative cannot correctly classify either shape on this SDK's POSIX hosts. The
48
- // drive-letter branch's negative lookbehind keeps it from firing on a letter-colon-slash
49
- // that isn't a path boundary (e.g. the "e:/" inside "file:///..." must NOT be read as a
50
- // drive letter — that segment belongs to POSIX_ABS_PATH instead).
47
+ // This module sits at <sdk>/src/transport/ in source and <sdk>/dist/transport/ in the build.
48
+ // dirname rather than a "../.." URL: that form keeps a trailing slash, which never matches
49
+ // as a whole segment.
50
+ const SDK_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
51
+ // REQ-WPS-07.7: the prefixes whose disclosure says something about THIS machine, each also
52
+ // under its realpath (a symlinked checkout reports either). Home and temp directories are not
53
+ // anchored: reading them needs node:os or process.env, neither admitted in the runner closure
54
+ // (scripts/capability-admission.ts).
55
+ export function hostAnchors(projectRoot = process.cwd()) {
56
+ const anchors = [];
57
+ const known = [
58
+ ["<project-root>", projectRoot],
59
+ ["<sdk>", SDK_ROOT],
60
+ ];
61
+ for (const [token, path] of known) {
62
+ anchors.push({ token, path });
63
+ try {
64
+ const real = realpathSync(path);
65
+ if (real !== path)
66
+ anchors.push({ token, path: real });
67
+ }
68
+ catch {
69
+ // A prefix that does not exist on disk has no realpath form to add.
70
+ }
71
+ }
72
+ return anchors;
73
+ }
74
+ // REQ-WPS-07.7: exact substring replacement — no left boundary, so a path glued to the word
75
+ // before it ("loaderror/home/...") is still caught. The right side must end the segment, so
76
+ // "/repo" never claims "/repo-old". Longest prefix first: the SDK root usually sits under the
77
+ // project root. "/" is skipped: it would claim every slash in the message. A plain scan rather
78
+ // than a built RegExp: the runner closure admits regex literals only.
79
+ const CONTINUES_SEGMENT = /[^\s'"<>\\/]/;
80
+ function anchorKnownPrefixes(message, anchors) {
81
+ const ordered = anchors.filter(({ path }) => path.length > 1).sort((a, b) => b.path.length - a.path.length);
82
+ let scrubbed = "";
83
+ let index = 0;
84
+ while (index < message.length) {
85
+ const anchor = ordered.find(({ path }) => message.startsWith(path, index) && !CONTINUES_SEGMENT.test(message.charAt(index + path.length)));
86
+ if (anchor === undefined) {
87
+ scrubbed += message.charAt(index);
88
+ index += 1;
89
+ }
90
+ else {
91
+ scrubbed += anchor.token;
92
+ index += anchor.path.length;
93
+ }
94
+ }
95
+ return scrubbed;
96
+ }
97
+ // One alternation, so every position is claimed by exactly one shape and a URL's path or a
98
+ // token's tail is never re-scanned by the groups after it:
51
99
  //
52
- // A literal space does not end the match: it's consumed via the second alternative ONLY
53
- // when a lookahead proves the path keeps going — more non-terminator characters followed by
54
- // a separator (e.g. "Program Files\x"). A space with no further separator ahead (the path
55
- // ends, or a quote/space terminates the token first) is NOT consumed, so prose is never
56
- // swallowed past the actual path boundary.
57
- const WINDOWS_UNC_ABS_PATH = /(?:(?<![A-Za-z0-9_])[A-Za-z]:[\\/]|\\\\)(?:[^\s'"<>]|[ ](?=[^\s'"<>]*[\\/]))*/g;
58
- // REQ-WPS-07.4: a POSIX absolute path. The leading "/" carries a negative lookbehind — the
59
- // same boundary check the Windows drive-letter branch above already relies on — so a slash
60
- // preceded by a word character (prose like "and/or", "24/7") is never mistaken for a path
61
- // root, while a slash preceded by a real boundary (start of string, space, quote, paren, "=",
62
- // ":") is. That boundary check is what lets a SINGLE segment ("/root", "/etc" — no second
63
- // "/" to require) count as absolute without also matching prose fractions.
100
+ // 1. What the prefix pass left behind: a token plus its tail, already safe.
101
+ // 2. REQ-WPS-07.8: a URL, recognised whole so its "scheme:" never reads as a path boundary
102
+ // before "//authority/...". The two-character scheme minimum leaves "C://x" to group 3.
103
+ // 3. REQ-WPS-07.4/.6, ADR-02: a Windows-drive-letter or UNC/WSL-interop path — replaced
104
+ // unconditionally, since node:path's POSIX-default isAbsolute/relative cannot classify
105
+ // either on this SDK's POSIX hosts. The drive-letter lookbehind keeps a letter-colon-slash
106
+ // after a word character from reading as a drive. A UNC path needs a server name and its
107
+ // closing backslash (REQ-WPS-07.9), so a bare "\\" in prose survives.
108
+ // 4. REQ-WPS-07.4: a POSIX path. The lookbehind on "/" keeps prose ("and/or", "24/7") from
109
+ // reading as a root while a real boundary (start, space, quote, paren, "=", ":") does not,
110
+ // which is what lets a single segment ("/root", "/etc") count as absolute.
64
111
  //
65
- // Same space-survives-via-lookahead mechanism as WINDOWS_UNC_ABS_PATH above, for the same
66
- // reason (a directory name with a space, e.g. "Application Support/x", must not truncate the
67
- // match at the space).
68
- const POSIX_ABS_PATH = /(?<![A-Za-z0-9_])\/(?:[^\s'"<>]|[ ](?=[^\s'"<>]*\/))+/g;
69
- // REQ-WPS-07.4/.6: scrubs absolute-path-shaped substrings embedded anywhere in a plain
70
- // Error's free-text message — Windows/UNC/WSL shapes to the outside-project placeholder
71
- // (ADR-02), POSIX shapes via the existing toProjectRelativePath formatter (ADR-01). Best-
72
- // effort, not a security boundary: non-path-shaped secret content is untouched (REQ-WPS-07.5).
73
- export function scrubAbsolutePaths(message, projectRoot) {
74
- return message
75
- .replace(WINDOWS_UNC_ABS_PATH, OUTSIDE_PROJECT_TOKEN)
76
- .replace(POSIX_ABS_PATH, (match) => toProjectRelativePath(match, projectRoot));
112
+ // In groups 3 and 4 a literal space does not end the match: it's consumed ONLY when a
113
+ // lookahead proves the path keeps going — more non-terminator characters followed by a
114
+ // separator ("Program Files\x", "Application Support/x"). A space with no further separator
115
+ // ahead is NOT consumed, so prose is never swallowed past the actual path boundary.
116
+ const SHAPES = /(<(?:project-root|sdk)>[^\s'"<>]*)|([A-Za-z][A-Za-z0-9+.-]+:\/\/[^\s'"<>]*)|((?:(?<![A-Za-z0-9_])[A-Za-z]:[\\/]|\\\\[A-Za-z0-9._$-]+\\)(?:[^\s'"<>]|[ ](?=[^\s'"<>]*[\\/]))*)|(?<![A-Za-z0-9_])\/(?:[^\s'"<>]|[ ](?=[^\s'"<>]*\/))+/g;
117
+ // A scheme ending in "file" also covers a word glued before it ("loadfile:///..."). A drive
118
+ // letter after the authority slash ("file:///C:/...") is handed to the Windows group.
119
+ const FILE_URL = /^([A-Za-z0-9+.-]*file:\/\/)(?:\/(?=[A-Za-z]:[\\/]))?/i;
120
+ function scrubShapes(text, projectRoot) {
121
+ return text.replace(SHAPES, (match, anchored, url, windows) => {
122
+ if (anchored !== undefined)
123
+ return match;
124
+ if (url !== undefined) {
125
+ const fileUrl = FILE_URL.exec(match);
126
+ return fileUrl === null ? match : `${fileUrl[1]}${scrubShapes(match.slice(fileUrl[0].length), projectRoot)}`;
127
+ }
128
+ if (windows !== undefined)
129
+ return OUTSIDE_PROJECT_TOKEN;
130
+ return toProjectRelativePath(match, projectRoot);
131
+ });
132
+ }
133
+ // REQ-WPS-07.4/.6/.7: scrubs absolute paths embedded anywhere in a plain Error's free-text
134
+ // message. Known host prefixes are replaced first, by exact substring; whatever is left is
135
+ // matched by shape — Windows/UNC/WSL to the outside-project placeholder (ADR-02), POSIX via
136
+ // toProjectRelativePath (ADR-01). Best-effort, not a security boundary: non-path-shaped secret
137
+ // content is untouched (REQ-WPS-07.5).
138
+ export function scrubAbsolutePaths(message, projectRoot, anchors = hostAnchors(projectRoot)) {
139
+ return scrubShapes(anchorKnownPrefixes(message, anchors), projectRoot);
77
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbuilder/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "The public TypeScript/Bun authoring layer for Project Builder schematics. Authors file mutations (create, replaceContent, remove, rename, move, copy, copyIn), lowers them to IR, and talks to the Project Builder engine over framed stdio (see docs/engine-sdk-wire-spec.md).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,7 +30,8 @@
30
30
  "access": "public"
31
31
  },
32
32
  "files": [
33
- "dist"
33
+ "dist",
34
+ "schemas"
34
35
  ],
35
36
  "bin": {
36
37
  "pbuilder-codegen": "dist/bin/pbuilder-codegen.js"
@@ -66,6 +67,16 @@
66
67
  "types": "./dist/dialects/react/index.d.ts",
67
68
  "import": "./dist/dialects/react/index.js",
68
69
  "default": "./dist/dialects/react/index.js"
70
+ },
71
+ "./json": {
72
+ "types": "./dist/dialects/json/index.d.ts",
73
+ "import": "./dist/dialects/json/index.js",
74
+ "default": "./dist/dialects/json/index.js"
75
+ },
76
+ "./yaml": {
77
+ "types": "./dist/dialects/yaml/index.d.ts",
78
+ "import": "./dist/dialects/yaml/index.js",
79
+ "default": "./dist/dialects/yaml/index.js"
69
80
  }
70
81
  },
71
82
  "scripts": {
@@ -90,6 +101,8 @@
90
101
  "verdaccio": "6.10.3"
91
102
  },
92
103
  "dependencies": {
93
- "ts-morph": "28.0.0"
104
+ "jsonc-parser": "3.3.1",
105
+ "ts-morph": "28.0.0",
106
+ "yaml": "2.9.1"
94
107
  }
95
108
  }
@@ -0,0 +1,112 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/Project-Builder-Schematics/project-builder-sdk/schemas/project-builder.schema.json",
4
+ "title": "project-builder.json",
5
+ "description": "Workspace configuration read and written by the project-builder CLI.",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "description": "Path or URL of this schema."
11
+ },
12
+ "version": {
13
+ "type": "string",
14
+ "description": "Config format version.",
15
+ "examples": ["1"]
16
+ },
17
+ "collections": {
18
+ "type": "object",
19
+ "description": "Collections by name. An entry either points at a collection.json or holds schematics by name.",
20
+ "additionalProperties": {
21
+ "oneOf": [
22
+ { "$ref": "#/$defs/collectionPointer" },
23
+ { "$ref": "#/$defs/schematicContainer" }
24
+ ]
25
+ }
26
+ },
27
+ "dependencies": {
28
+ "type": "object",
29
+ "description": "Package names mapped to semver ranges.",
30
+ "additionalProperties": { "type": "string" }
31
+ },
32
+ "settings": {
33
+ "type": "object",
34
+ "properties": {
35
+ "autoInstall": { "type": "boolean", "default": true },
36
+ "conflictPolicy": {
37
+ "type": "string",
38
+ "default": "child-wins",
39
+ "description": "Documented values: child-wins, strict."
40
+ },
41
+ "depValidation": {
42
+ "type": "string",
43
+ "default": "dev",
44
+ "description": "Documented values: dev, strict."
45
+ },
46
+ "schematicCollections": {
47
+ "type": "array",
48
+ "items": { "type": "string" },
49
+ "default": ["default"],
50
+ "description": "Ordered collections searched for a bare schematic name."
51
+ }
52
+ }
53
+ },
54
+ "skill": {
55
+ "type": "object",
56
+ "properties": {
57
+ "enabled": { "type": "boolean" },
58
+ "path": { "type": "string" }
59
+ }
60
+ },
61
+ "sdk": {
62
+ "type": "object",
63
+ "properties": {
64
+ "version": {
65
+ "type": "string",
66
+ "description": "Minimum @pbuilder/sdk version, used when package.json declares none.",
67
+ "examples": ["0.2.4"]
68
+ },
69
+ "root": {
70
+ "type": "string",
71
+ "description": "Absolute or config-relative path to an external @pbuilder/sdk package directory."
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "$defs": {
77
+ "collectionPointer": {
78
+ "type": "object",
79
+ "required": ["path"],
80
+ "properties": {
81
+ "path": {
82
+ "type": "string",
83
+ "description": "Workspace-relative path to a collection.json."
84
+ }
85
+ }
86
+ },
87
+ "schematicContainer": {
88
+ "type": "object",
89
+ "not": { "required": ["path"] },
90
+ "properties": {
91
+ "schematics": {
92
+ "type": "object",
93
+ "description": "Inline schematic registrations.",
94
+ "additionalProperties": {
95
+ "type": "object",
96
+ "properties": { "factory": { "type": "string" } }
97
+ }
98
+ }
99
+ },
100
+ "additionalProperties": {
101
+ "type": "object",
102
+ "required": ["path"],
103
+ "properties": {
104
+ "path": {
105
+ "type": "string",
106
+ "description": "Workspace-relative path to a schematic directory."
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
@@ -1,2 +0,0 @@
1
- export { dryRunPlan } from "./plan.ts";
2
- export type { DryRunEntry, DryRunVerb } from "./plan.ts";
@@ -1 +0,0 @@
1
- export { dryRunPlan } from "./plan.js";