@agent-teams/docs-protocol 0.1.0-rc.1 → 0.1.0-rc.12

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 (91) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +34 -5
  3. package/assets/catalog.json +1 -0
  4. package/assets/docs-protocol.yml +14 -0
  5. package/assets/history/sha256-097df9fe1b90ab45f73389c8b69736f8a54d4199b09536d586222b5a7f0fbb09/caller.yml +13 -0
  6. package/assets/history/sha256-3e53262efc8a530b532380dac21d876456473d3b88aba20889a1d24823bf3a1b/caller.yml +14 -0
  7. package/assets/history/sha256-7b31cd257532247f64c55a014dc926c601e4d742176cfb8513b6b0d8ab48213e/skill.md +28 -0
  8. package/assets/history/sha256-fd633c3c6337e5cfe51a9f36989bb654381634c5ab4add9e4da71fe40ab4e0dd/caller.yml +14 -0
  9. package/assets/transition-catalog.json +1 -0
  10. package/dist/composition/cli.d.ts.map +1 -1
  11. package/dist/composition/cli.js +9 -1
  12. package/dist/composition/cli.js.map +1 -1
  13. package/dist/consumer-integration/adapters/agents-route-adapter-v1.d.ts +15 -0
  14. package/dist/consumer-integration/adapters/agents-route-adapter-v1.d.ts.map +1 -0
  15. package/dist/consumer-integration/adapters/agents-route-adapter-v1.js +96 -0
  16. package/dist/consumer-integration/adapters/agents-route-adapter-v1.js.map +1 -0
  17. package/dist/consumer-integration/adapters/bounded-repository-topology.d.ts +8 -0
  18. package/dist/consumer-integration/adapters/bounded-repository-topology.d.ts.map +1 -0
  19. package/dist/consumer-integration/adapters/bounded-repository-topology.js +80 -0
  20. package/dist/consumer-integration/adapters/bounded-repository-topology.js.map +1 -0
  21. package/dist/consumer-integration/adapters/consumer-integration-schema-validator.d.ts +3 -0
  22. package/dist/consumer-integration/adapters/consumer-integration-schema-validator.d.ts.map +1 -0
  23. package/dist/consumer-integration/adapters/consumer-integration-schema-validator.js +43 -0
  24. package/dist/consumer-integration/adapters/consumer-integration-schema-validator.js.map +1 -0
  25. package/dist/consumer-integration/adapters/node-consumer-integration-repository.d.ts +14 -0
  26. package/dist/consumer-integration/adapters/node-consumer-integration-repository.d.ts.map +1 -0
  27. package/dist/consumer-integration/adapters/node-consumer-integration-repository.js +405 -0
  28. package/dist/consumer-integration/adapters/node-consumer-integration-repository.js.map +1 -0
  29. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.d.ts +3 -0
  30. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.d.ts.map +1 -0
  31. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.js +152 -0
  32. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.js.map +1 -0
  33. package/dist/consumer-integration/adapters/pnpm-lockfile-policy-v1.d.ts +3 -0
  34. package/dist/consumer-integration/adapters/pnpm-lockfile-policy-v1.d.ts.map +1 -0
  35. package/dist/consumer-integration/adapters/pnpm-lockfile-policy-v1.js +37 -0
  36. package/dist/consumer-integration/adapters/pnpm-lockfile-policy-v1.js.map +1 -0
  37. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.d.ts +16 -0
  38. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.d.ts.map +1 -0
  39. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.js +155 -0
  40. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.js.map +1 -0
  41. package/dist/consumer-integration/adapters/pnpm-runtime-closure-v1.d.ts +8 -0
  42. package/dist/consumer-integration/adapters/pnpm-runtime-closure-v1.d.ts.map +1 -0
  43. package/dist/consumer-integration/adapters/pnpm-runtime-closure-v1.js +245 -0
  44. package/dist/consumer-integration/adapters/pnpm-runtime-closure-v1.js.map +1 -0
  45. package/dist/consumer-integration/application/policies/consumer-integration-assets.d.ts +57 -0
  46. package/dist/consumer-integration/application/policies/consumer-integration-assets.d.ts.map +1 -0
  47. package/dist/consumer-integration/application/policies/consumer-integration-assets.js +147 -0
  48. package/dist/consumer-integration/application/policies/consumer-integration-assets.js.map +1 -0
  49. package/dist/consumer-integration/application/policies/consumer-integration-authority-guards.d.ts +4 -0
  50. package/dist/consumer-integration/application/policies/consumer-integration-authority-guards.d.ts.map +1 -0
  51. package/dist/consumer-integration/application/policies/consumer-integration-authority-guards.js +23 -0
  52. package/dist/consumer-integration/application/policies/consumer-integration-authority-guards.js.map +1 -0
  53. package/dist/consumer-integration/application/policies/consumer-integration-desired-state.d.ts +4 -0
  54. package/dist/consumer-integration/application/policies/consumer-integration-desired-state.d.ts.map +1 -0
  55. package/dist/consumer-integration/application/policies/consumer-integration-desired-state.js +153 -0
  56. package/dist/consumer-integration/application/policies/consumer-integration-desired-state.js.map +1 -0
  57. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.d.ts +18 -0
  58. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.d.ts.map +1 -0
  59. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.js +537 -0
  60. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.js.map +1 -0
  61. package/dist/consumer-integration/composition/consumer-integration-cli.d.ts +3 -0
  62. package/dist/consumer-integration/composition/consumer-integration-cli.d.ts.map +1 -0
  63. package/dist/consumer-integration/composition/consumer-integration-cli.js +223 -0
  64. package/dist/consumer-integration/composition/consumer-integration-cli.js.map +1 -0
  65. package/dist/consumer-integration/composition/node-consumer-integration.d.ts +28 -0
  66. package/dist/consumer-integration/composition/node-consumer-integration.d.ts.map +1 -0
  67. package/dist/consumer-integration/composition/node-consumer-integration.js +138 -0
  68. package/dist/consumer-integration/composition/node-consumer-integration.js.map +1 -0
  69. package/dist/consumer-integration/domain/model.d.ts +105 -0
  70. package/dist/consumer-integration/domain/model.d.ts.map +1 -0
  71. package/dist/consumer-integration/domain/model.js +2 -0
  72. package/dist/consumer-integration/domain/model.js.map +1 -0
  73. package/dist/consumer-integration/generated/canonical-assets.d.ts +4 -0
  74. package/dist/consumer-integration/generated/canonical-assets.d.ts.map +1 -0
  75. package/dist/consumer-integration/generated/canonical-assets.js +5 -0
  76. package/dist/consumer-integration/generated/canonical-assets.js.map +1 -0
  77. package/dist/consumer-integration/index.d.ts +11 -0
  78. package/dist/consumer-integration/index.d.ts.map +1 -0
  79. package/dist/consumer-integration/index.js +7 -0
  80. package/dist/consumer-integration/index.js.map +1 -0
  81. package/dist/index.d.ts +1 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +1 -0
  84. package/dist/index.js.map +1 -1
  85. package/package.json +13 -3
  86. package/schemas/docs-consumer-integration-execution/v1.schema.json +29 -0
  87. package/schemas/docs-consumer-integration-plan/v1.schema.json +63 -0
  88. package/schemas/docs-consumer-integration-profile/v1.schema.json +110 -0
  89. package/schemas/docs-consumer-managed-state/v1.schema.json +99 -0
  90. package/schemas/qualified-docs-cohort/v1.schema.json +96 -0
  91. package/skills/docs/SKILL.md +28 -0
@@ -0,0 +1,152 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { digestBytes } from "../application/policies/consumer-integration-assets.js";
3
+ import { assertQualifiedDocsCohortBindingV1 } from "../application/policies/consumer-integration-desired-state.js";
4
+ const DIGEST = /^sha256:[0-9a-f]{64}$/u;
5
+ const COHORT_ID = /^[a-z0-9]+(?:[._-][a-z0-9]+)*$/u;
6
+ const INTEGRITY = /^sha512-[A-Za-z0-9+/]{86}==$/u;
7
+ const SEMVER = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?$/u;
8
+ const BUNDLE_PATH = /^assets\/history\/sha256-[0-9a-f]{64}\/(?:caller\.yml|skill\.md)$/u;
9
+ const MAXIMUM_CATALOG_BYTES = 2 * 1024 * 1024;
10
+ const MAXIMUM_BUNDLE_BYTES = 1024 * 1024;
11
+ function record(value, subject) {
12
+ if (typeof value !== "object" || value === null || Array.isArray(value) ||
13
+ Object.getPrototypeOf(value) !== Object.prototype) {
14
+ throw new TypeError(`${subject} must be one plain object.`);
15
+ }
16
+ return value;
17
+ }
18
+ function digest(value, subject) {
19
+ if (typeof value !== "string" || !DIGEST.test(value)) {
20
+ throw new TypeError(`${subject} must be one sha256 digest.`);
21
+ }
22
+ return value;
23
+ }
24
+ function hasExactKeys(value, keys) {
25
+ return Object.keys(value).toSorted().join("\u0000") === [...keys].toSorted().join("\u0000");
26
+ }
27
+ function packagePair(value) {
28
+ const packages = record(value, "currentSourceExecutor.packages");
29
+ const docsProtocol = record(packages["docsProtocol"], "currentSourceExecutor.packages.docsProtocol");
30
+ const engineeringFoundation = record(packages["engineeringFoundation"], "currentSourceExecutor.packages.engineeringFoundation");
31
+ if (!hasExactKeys(packages, ["docsProtocol", "engineeringFoundation"]) ||
32
+ !hasExactKeys(docsProtocol, ["version", "integrity"]) ||
33
+ !hasExactKeys(engineeringFoundation, ["version", "integrity"]) ||
34
+ !SEMVER.test(String(docsProtocol["version"])) ||
35
+ !SEMVER.test(String(engineeringFoundation["version"])) ||
36
+ !INTEGRITY.test(String(docsProtocol["integrity"])) ||
37
+ !INTEGRITY.test(String(engineeringFoundation["integrity"]))) {
38
+ throw new TypeError("Current source executor package pair is invalid.");
39
+ }
40
+ return packages;
41
+ }
42
+ function schemas(value) {
43
+ const candidate = record(value, "currentSourceExecutor.schemas");
44
+ if (!hasExactKeys(candidate, ["consumerIntegration", "managedState", "docsProtocol"]) ||
45
+ Object.values(candidate).some((entry) => entry !== 1)) {
46
+ throw new TypeError("Current source executor schemas are invalid.");
47
+ }
48
+ return candidate;
49
+ }
50
+ function runtime(value) {
51
+ const candidate = record(value, "currentSourceExecutor.runtime");
52
+ if (!hasExactKeys(candidate, ["node", "pnpm", "runtimeClosureDigest"]) ||
53
+ candidate["node"] !== ">=24.18.0 <25" || candidate["pnpm"] !== ">=11.17.0 <12") {
54
+ throw new TypeError("Current source executor runtime is invalid.");
55
+ }
56
+ digest(candidate["runtimeClosureDigest"], "currentSourceExecutor.runtime.runtimeClosureDigest");
57
+ return candidate;
58
+ }
59
+ function cohortIds(value) {
60
+ if (!Array.isArray(value) || value.length === 0 || value.length > 32 ||
61
+ value.some((entry) => typeof entry !== "string" || !COHORT_ID.test(entry)) ||
62
+ new Set(value).size !== value.length) {
63
+ throw new TypeError("Current source executor target Cohort IDs are invalid.");
64
+ }
65
+ return value;
66
+ }
67
+ async function bundleBytes(path, expected) {
68
+ if (typeof path !== "string" || !BUNDLE_PATH.test(path)) {
69
+ throw new TypeError("Direct-target bundle paths must be content-addressed package assets.");
70
+ }
71
+ const bytes = await readFile(new URL(`../../../${path}`, import.meta.url));
72
+ if (bytes.byteLength > MAXIMUM_BUNDLE_BYTES || digestBytes(bytes) !== digest(expected, path)) {
73
+ throw new TypeError(`Direct-target bundle digest mismatch: ${path}.`);
74
+ }
75
+ return bytes;
76
+ }
77
+ function currentSource(value) {
78
+ const source = record(value, "currentSourceExecutor");
79
+ if (!hasExactKeys(source, [
80
+ "packages", "schemas", "runtime", "assetCatalogDigest", "skillDigest", "callerWorkflowDigest",
81
+ "agentsRouteDigest", "docsScriptsDigest", "directTargetCohortIds"
82
+ ])) {
83
+ throw new TypeError("Current source executor fields are invalid.");
84
+ }
85
+ return Object.freeze({
86
+ packages: packagePair(source["packages"]),
87
+ schemas: schemas(source["schemas"]),
88
+ runtime: runtime(source["runtime"]),
89
+ assetCatalogDigest: digest(source["assetCatalogDigest"], "currentSourceExecutor.assetCatalogDigest"),
90
+ skillDigest: digest(source["skillDigest"], "currentSourceExecutor.skillDigest"),
91
+ callerWorkflowDigest: digest(source["callerWorkflowDigest"], "currentSourceExecutor.callerWorkflowDigest"),
92
+ agentsRouteDigest: digest(source["agentsRouteDigest"], "currentSourceExecutor.agentsRouteDigest"),
93
+ docsScriptsDigest: digest(source["docsScriptsDigest"], "currentSourceExecutor.docsScriptsDigest"),
94
+ directTargetCohortIds: cohortIds(source["directTargetCohortIds"])
95
+ });
96
+ }
97
+ async function directTarget(value) {
98
+ const target = record(value, "directTargetBundle");
99
+ const cohort = record(target["cohort"], "directTargetBundle.cohort");
100
+ assertQualifiedDocsCohortBindingV1(cohort);
101
+ const [skill, callerWorkflow] = await Promise.all([
102
+ bundleBytes(target["skillPath"], target["skillDigest"]),
103
+ bundleBytes(target["callerWorkflowPath"], target["callerWorkflowDigest"])
104
+ ]);
105
+ return Object.freeze({
106
+ cohort,
107
+ skill,
108
+ callerWorkflow,
109
+ agentsRouteDigest: digest(target["agentsRouteDigest"], "directTargetBundle.agentsRouteDigest"),
110
+ docsScriptsDigest: digest(target["docsScriptsDigest"], "directTargetBundle.docsScriptsDigest")
111
+ });
112
+ }
113
+ export async function loadPackageConsumerAssetCatalog() {
114
+ const [bytes, transitionBytes, docsManifestBytes, foundationManifestBytes] = await Promise.all([
115
+ readFile(new URL("../../../assets/catalog.json", import.meta.url)),
116
+ readFile(new URL("../../../assets/transition-catalog.json", import.meta.url)),
117
+ readFile(new URL("../../../package.json", import.meta.url)),
118
+ readFile(new URL(import.meta.resolve("@agent-teams/engineering-foundation/package.json")))
119
+ ]);
120
+ if (bytes.byteLength > MAXIMUM_CATALOG_BYTES) {
121
+ throw new TypeError("Consumer asset catalog is too large.");
122
+ }
123
+ if (transitionBytes.byteLength > MAXIMUM_CATALOG_BYTES) {
124
+ throw new TypeError("Consumer transition catalog is too large.");
125
+ }
126
+ const source = record(JSON.parse(transitionBytes.toString("utf8")), "consumer transition catalog");
127
+ if (!hasExactKeys(source, ["schemaVersion", "currentSourceExecutors", "directTargetBundles"]) ||
128
+ source["schemaVersion"] !== 1) {
129
+ throw new TypeError("Consumer transition catalog fields are invalid.");
130
+ }
131
+ const sources = source["currentSourceExecutors"];
132
+ const targets = source["directTargetBundles"];
133
+ if (!Array.isArray(sources) || sources.length > 32 || !Array.isArray(targets) || targets.length > 32) {
134
+ throw new TypeError("Consumer asset catalog executor and target lists must be bounded arrays.");
135
+ }
136
+ const docsVersion = record(JSON.parse(docsManifestBytes.toString("utf8")), "Docs package")["version"];
137
+ const foundationVersion = record(JSON.parse(foundationManifestBytes.toString("utf8")), "Foundation package")["version"];
138
+ const currentSourceExecutors = sources.map(currentSource).filter(({ packages }) => packages.docsProtocol.version === docsVersion &&
139
+ packages.engineeringFoundation.version === foundationVersion);
140
+ const directTargetBundles = await Promise.all(targets.map(directTarget));
141
+ const directTargetIds = new Set(directTargetBundles.map(({ cohort }) => cohort.cohortId));
142
+ if (directTargetIds.size !== directTargetBundles.length || currentSourceExecutors.some(({ directTargetCohortIds }) => directTargetCohortIds.some((id) => !directTargetIds.has(id)))) {
143
+ throw new TypeError("Consumer transition catalog target Cohort identities must be unique.");
144
+ }
145
+ return Object.freeze({
146
+ catalogDigest: digestBytes(bytes),
147
+ transitionCatalogDigest: digestBytes(transitionBytes),
148
+ currentSourceExecutors: Object.freeze(currentSourceExecutors),
149
+ directTargetBundles: Object.freeze(directTargetBundles)
150
+ });
151
+ }
152
+ //# sourceMappingURL=package-consumer-asset-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-consumer-asset-catalog.js","sourceRoot":"","sources":["../../../src/consumer-integration/adapters/package-consumer-asset-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EACL,WAAW,EAIZ,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,kCAAkC,EAAE,MAAM,+DAA+D,CAAC;AAEnH,MAAM,MAAM,GAAG,wBAAwB,CAAC;AACxC,MAAM,SAAS,GAAG,iCAAiC,CAAC;AACpD,MAAM,SAAS,GAAG,+BAA+B,CAAC;AAClD,MAAM,MAAM,GAAG,+CAA+C,CAAC;AAC/D,MAAM,WAAW,GAAG,oEAAoE,CAAC;AACzF,MAAM,qBAAqB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,SAAS,MAAM,CAAC,KAAc,EAAE,OAAe;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrE,MAAM,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AAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;IACzE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1F,IAAI,eAAe,CAAC,IAAI,KAAK,mBAAmB,CAAC,MAAM,IAAI,sBAAsB,CAAC,IAAI,CACpF,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAC5F,EAAE,CAAC;QACF,MAAM,IAAI,SAAS,CAAC,sEAAsE,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC;QACjC,uBAAuB,EAAE,WAAW,CAAC,eAAe,CAAC;QACrD,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC;QAC7D,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;KACxD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function validPnpmPeerContext(value: unknown, exactVersion: string): value is string;
2
+ export declare function targetsManagedPackage(value: unknown): boolean;
3
+ //# sourceMappingURL=pnpm-lockfile-policy-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm-lockfile-policy-v1.d.ts","sourceRoot":"","sources":["../../../src/consumer-integration/adapters/pnpm-lockfile-policy-v1.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAgB1F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM7D"}
@@ -0,0 +1,37 @@
1
+ export function validPnpmPeerContext(value, exactVersion) {
2
+ if (value === exactVersion) {
3
+ return true;
4
+ }
5
+ if (typeof value !== "string" || !value.startsWith(`${exactVersion}(`)) {
6
+ return false;
7
+ }
8
+ const contentByDepth = [];
9
+ for (const character of value.slice(exactVersion.length)) {
10
+ if (character === "(") {
11
+ contentByDepth.push(false);
12
+ }
13
+ else if (character === ")") {
14
+ if (contentByDepth.pop() !== true) {
15
+ return false;
16
+ }
17
+ if (contentByDepth.length > 0) {
18
+ contentByDepth[contentByDepth.length - 1] = true;
19
+ }
20
+ }
21
+ else {
22
+ if (contentByDepth.length === 0 || /\s/u.test(character)) {
23
+ return false;
24
+ }
25
+ contentByDepth[contentByDepth.length - 1] = true;
26
+ }
27
+ }
28
+ return contentByDepth.length === 0;
29
+ }
30
+ export function targetsManagedPackage(value) {
31
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
32
+ return false;
33
+ }
34
+ return Object.keys(value).some((key) => key.includes("@agent-teams/docs-protocol") ||
35
+ key.includes("@agent-teams/engineering-foundation"));
36
+ }
37
+ //# sourceMappingURL=pnpm-lockfile-policy-v1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm-lockfile-policy-v1.js","sourceRoot":"","sources":["../../../src/consumer-integration/adapters/pnpm-lockfile-policy-v1.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,YAAoB;IACvE,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;QAAA,OAAO,IAAI,CAAC;IAAA,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC;QAAA,OAAO,KAAK,CAAC;IAAA,CAAC;IACvF,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,KAAK,MAAM,SAAS,IAAI,KAAK,CA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ocsCohortBindingV1 } from "../domain/model.js";
2
+ /** @public */
3
+ export interface PnpmManifestPlanV1 {
4
+ readonly state: "conflict" | "exact-current" | "known-prior";
5
+ readonly currentDigest: ConsumerIntegrationDigest;
6
+ readonly expectedDigest: ConsumerIntegrationDigest;
7
+ readonly postimage?: Uint8Array;
8
+ readonly issues: readonly ConsumerIntegrationIssue[];
9
+ }
10
+ export declare function planPnpmManifestV1(input: {
11
+ readonly observation: ConsumerIntegrationFileObservation;
12
+ readonly profilePath: string;
13
+ readonly cohort: QualifiedDocsCohortBindingV1;
14
+ readonly knownPriorScriptsDigest?: ConsumerIntegrationDigest;
15
+ }): PnpmManifestPlanV1;
16
+ //# sourceMappingURL=pnpm-manifest-adapter-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm-manifest-adapter-v1.d.ts","sourceRoot":"","sources":["../../../src/consumer-integration/adapters/pnpm-manifest-adapter-v1.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EACzB,kCAAkC,EAClC,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,oBAAoB,CAAC;AAU5B,cAAc;AACd,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,GAAG,aAAa,CAAC;IAC7D,QAAQ,CAAC,aAAa,EAAE,yBAAyB,CAAC;IAClD,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,wBAAwB,EAAE,CAAC;CACtD;AAoGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,QAAQ,CAAC,WAAW,EAAE,kCAAkC,CAAC;IACzD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;IAC9C,QAAQ,CAAC,uBAAuB,CAAC,EAAE,yBAAyB,CAAC;CAC9D,GAAG,kBAAkB,CA8ErB"}
@@ -0,0 +1,155 @@
1
+ import { applyEdits, modify } from "jsonc-parser";
2
+ import { parseJsonRecord, recordField } from "../../adapters/adoption-input.js";
3
+ import { canonicalConsumerIntegrationJson, canonicalDocsScripts, digestBytes } from "../application/policies/consumer-integration-assets.js";
4
+ const DOCS_PACKAGE = "@agent-teams/docs-protocol";
5
+ const FOUNDATION_PACKAGE = "@agent-teams/engineering-foundation";
6
+ function issue(subject, code, message) {
7
+ return { code, severity: "error", subject, message };
8
+ }
9
+ function rejectPrototypeKeys(value, path = "package.json") {
10
+ if (Array.isArray(value)) {
11
+ value.forEach((entry, index) => rejectPrototypeKeys(entry, `${path}[${index}]`));
12
+ return;
13
+ }
14
+ if (typeof value !== "object" || value === null) {
15
+ return;
16
+ }
17
+ for (const [key, entry] of Object.entries(value)) {
18
+ if (["__proto__", "constructor", "prototype"].includes(key)) {
19
+ throw new TypeError(`${path}.${key} is forbidden.`);
20
+ }
21
+ rejectPrototypeKeys(entry, `${path}.${key}`);
22
+ }
23
+ }
24
+ function formatting(source) {
25
+ const eol = source.includes("\r\n") ? "\r\n" : "\n";
26
+ const indent = source.match(/\n([\t ]+)"/u)?.[1] ?? " ";
27
+ return {
28
+ eol,
29
+ insertSpaces: !indent.includes("\t"),
30
+ tabSize: indent.includes("\t") ? 1 : indent.length
31
+ };
32
+ }
33
+ function applyField(source, path, value) {
34
+ return applyEdits(source, modify(source, [...path], value, {
35
+ formattingOptions: formatting(source)
36
+ }));
37
+ }
38
+ function parseManifest(bytes) {
39
+ const source = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
40
+ if (source.startsWith("\uFEFF")) {
41
+ throw new TypeError("package.json must not contain a UTF-8 BOM.");
42
+ }
43
+ const manifest = parseJsonRecord(source);
44
+ rejectPrototypeKeys(manifest);
45
+ return { manifest, source };
46
+ }
47
+ function manifestShapeIssues(manifest) {
48
+ const issues = [];
49
+ for (const field of [
50
+ "scripts", "dependencies", "devDependencies", "optionalDependencies", "peerDependencies"
51
+ ]) {
52
+ const value = manifest[field];
53
+ if (value !== undefined &&
54
+ (typeof value !== "object" || value === null || Array.isArray(value))) {
55
+ issues.push(issue(`package.json#${field}`, "DOCS_CONSUMER_MANIFEST_FIELD_INVALID", `${field} must be one object when present.`));
56
+ }
57
+ }
58
+ return issues;
59
+ }
60
+ function cohortDependencyIssues(dependencies, devDependencies, optionalDependencies, peerDependencies, cohort) {
61
+ const issues = [];
62
+ for (const packageName of [DOCS_PACKAGE, FOUNDATION_PACKAGE]) {
63
+ for (const [field, declarations] of [
64
+ ["dependencies", dependencies],
65
+ ["optionalDependencies", optionalDependencies],
66
+ ["peerDependencies", peerDependencies]
67
+ ]) {
68
+ if (declarations[packageName] !== undefined) {
69
+ issues.push(issue(`package.json#${field}`, "DOCS_CONSUMER_NON_DEV_DEPENDENCY", `${packageName} may be declared only in root devDependencies.`));
70
+ }
71
+ }
72
+ }
73
+ const requiredVersions = {
74
+ [DOCS_PACKAGE]: cohort.packages.docsProtocol.version,
75
+ [FOUNDATION_PACKAGE]: cohort.packages.engineeringFoundation.version
76
+ };
77
+ for (const [packageName, version] of Object.entries(requiredVersions)) {
78
+ if (devDependencies[packageName] !== version) {
79
+ issues.push(issue(`package.json#devDependencies.${packageName}`, "DOCS_CONSUMER_COHORT_PIN_REQUIRED", `Update ${packageName} and pnpm-lock.yaml together to exact version ${version} before consumer apply.`));
80
+ }
81
+ }
82
+ return issues;
83
+ }
84
+ export function planPnpmManifestV1(input) {
85
+ if (input.observation.state === "absent") {
86
+ const empty = digestBytes(new Uint8Array());
87
+ return {
88
+ state: "conflict",
89
+ currentDigest: empty,
90
+ expectedDigest: empty,
91
+ issues: [issue("package.json", "DOCS_CONSUMER_MANIFEST_MISSING", "A root package.json is required and is never created by consumer integration.")]
92
+ };
93
+ }
94
+ const bytes = Buffer.from(input.observation.bytes);
95
+ const currentDigest = digestBytes(bytes);
96
+ let source;
97
+ let manifest;
98
+ try {
99
+ ({ manifest, source } = parseManifest(bytes));
100
+ }
101
+ catch (error) {
102
+ return {
103
+ state: "conflict",
104
+ currentDigest,
105
+ expectedDigest: currentDigest,
106
+ issues: [issue("package.json", "DOCS_CONSUMER_MANIFEST_INVALID", error instanceof Error ? error.message : "package.json is invalid.")]
107
+ };
108
+ }
109
+ const issues = manifestShapeIssues(manifest);
110
+ const scripts = recordField(manifest, "scripts");
111
+ const dependencies = recordField(manifest, "dependencies");
112
+ const devDependencies = recordField(manifest, "devDependencies");
113
+ const optionalDependencies = recordField(manifest, "optionalDependencies");
114
+ const peerDependencies = recordField(manifest, "peerDependencies");
115
+ issues.push(...cohortDependencyIssues(dependencies, devDependencies, optionalDependencies, peerDependencies, input.cohort));
116
+ const desiredScripts = canonicalDocsScripts(input.profilePath);
117
+ const observedScripts = Object.fromEntries(Object.keys(desiredScripts).map((script) => [
118
+ script,
119
+ scripts[script] ?? null
120
+ ]));
121
+ const observedScriptsDigest = digestBytes(Buffer.from(canonicalConsumerIntegrationJson(observedScripts), "utf8"));
122
+ let postimage = source;
123
+ for (const [script, command] of Object.entries(desiredScripts)) {
124
+ const pre = `pre${script}`;
125
+ const post = `post${script}`;
126
+ if (scripts[pre] !== undefined || scripts[post] !== undefined) {
127
+ issues.push(issue(`package.json#scripts.${script}`, "DOCS_CONSUMER_RESERVED_LIFECYCLE_SCRIPT", `${pre} and ${post} are forbidden for managed documentation commands.`));
128
+ }
129
+ const current = scripts[script];
130
+ if (current !== undefined && current !== command &&
131
+ observedScriptsDigest !== input.knownPriorScriptsDigest) {
132
+ issues.push(issue(`package.json#scripts.${script}`, "DOCS_CONSUMER_RESERVED_SCRIPT_CONFLICT", `${script} contains unknown local behavior and was not overwritten.`));
133
+ continue;
134
+ }
135
+ if (current !== command) {
136
+ postimage = applyField(postimage, ["scripts", script], command);
137
+ }
138
+ }
139
+ const expectedBytes = Buffer.from(postimage, "utf8");
140
+ const expectedDigest = digestBytes(expectedBytes);
141
+ if (issues.length > 0) {
142
+ return { state: "conflict", currentDigest, expectedDigest, issues: Object.freeze(issues) };
143
+ }
144
+ if (expectedDigest === currentDigest) {
145
+ return { state: "exact-current", currentDigest, expectedDigest, issues: [] };
146
+ }
147
+ return {
148
+ state: "known-prior",
149
+ currentDigest,
150
+ expectedDigest,
151
+ postimage: expectedBytes,
152
+ issues: []
153
+ };
154
+ }
155
+ //# sourceMappingURL=pnpm-manifest-adapter-v1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm-manifest-adapter-v1.js","sourceRoot":"","sources":["../../../src/consumer-integration/adapters/pnpm-manifest-adapter-v1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAOhF,OAAO,EACL,gCAAgC,EAChC,oBAAoB,EACpB,WAAW,EACZ,MAAM,wDAAwD,CAAC;AAEhE,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAClD,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAWjE,SAAS,KAAK,CAAC,OAAe,EAAE,IAAY,EAAE,OAAe;IAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc,EAAE,IAAI,GAAG,cAAc;IAChE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;QACjF,OAAO;IACT,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,GAA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AC;IACrD,MAAM,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7F,CAAC;IACD,IAAI,cAAc,KAAK,aAAa,EAAE,CAAC;QACrC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO;QACL,KAAK,EAAE,aAAa;QACpB,aAAa;QACb,cAAc;QACd,SAAS,EAAE,aAAa;QACxB,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { QualifiedDocsCohortBindingV1 } from "../domain/model.js";
2
+ type JsonRecord = Record<string, unknown>;
3
+ export declare class PnpmRuntimeClosureError extends Error {
4
+ readonly code = "DOCS_CONSUMER_RUNTIME_CLOSURE_MISMATCH";
5
+ }
6
+ export declare function computePnpmRuntimeClosureDigestV1(lock: JsonRecord, cohort: QualifiedDocsCohortBindingV1): `sha256:${string}`;
7
+ export {};
8
+ //# sourceMappingURL=pnpm-runtime-closure-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm-runtime-closure-v1.d.ts","sourceRoot":"","sources":["../../../src/consumer-integration/adapters/pnpm-runtime-closure-v1.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAYvE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAyB1C,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,IAAI,4CAA4C;CACjE;AAyMD,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,4BAA4B,GACnC,UAAU,MAAM,EAAE,CA8EpB"}