@kungfu-tech/buildchain 3.0.4-alpha.4 → 3.0.4-alpha.6

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 (34) hide show
  1. package/AGENTS.md +14 -5
  2. package/README.md +18 -0
  3. package/bin/buildchain.mjs +10 -1
  4. package/dist/site/buildchain-contract.json +5 -5
  5. package/dist/site/buildchain-site.json +1459 -58
  6. package/dist/site/capability-registry.json +8 -5
  7. package/dist/site/cli-registry.json +1869 -0
  8. package/dist/site/kfd-claims.json +79 -7
  9. package/dist/site/kfd-upstream-aggregate.json +1 -1
  10. package/dist/site/manual-registry.json +47 -4
  11. package/dist/site/node-api-registry.json +17761 -6
  12. package/dist/site/page-registry.json +1435 -58
  13. package/dist/site/public-surface-audit.json +2809 -352
  14. package/dist/site/publication-registry.json +4 -4
  15. package/dist/site/site-manifest.json +32 -8
  16. package/docs/MAP.md +20 -5
  17. package/docs/cli-reference.md +1936 -0
  18. package/docs/cli.md +13 -0
  19. package/docs/getting-started.md +167 -0
  20. package/docs/node-api-reference.md +1949 -0
  21. package/docs/site-bundle-contract.md +10 -4
  22. package/docs/versioning.md +5 -4
  23. package/package.json +8 -5
  24. package/packages/core/buildchain-agent-manuals.js +37 -0
  25. package/packages/core/buildchain-kfd-claims.js +3 -36
  26. package/packages/core/paper-agent-entry.js +8 -4
  27. package/packages/core/paper.js +1 -0
  28. package/packages/core/publication-package.js +7 -0
  29. package/scripts/check-inventory.mjs +2 -2
  30. package/scripts/generate-public-reference.mjs +68 -0
  31. package/scripts/generate-site-bundle.mjs +19 -34
  32. package/scripts/public-reference.mjs +557 -0
  33. package/scripts/site-reference-registry.mjs +174 -0
  34. package/scripts/verify-golden-path.mjs +169 -0
@@ -58,8 +58,13 @@ those surfaces.
58
58
  `manual-registry.json` enumerates the packaged Markdown manuals with source
59
59
  digests so an agent can find complete operating documentation from the npm
60
60
  artifact. `node-api-registry.json` enumerates public Node import surfaces from
61
- `package.json#exports`, so agents do not have to infer supported APIs from
62
- internal paths.
61
+ `package.json#exports` and closes each JavaScript subpath over its exact exported
62
+ symbols. Each symbol includes its source-derived signature and parameters,
63
+ conservative return/error contract, detected side effects, maturity, example
64
+ import, and source location, so agents do not have to infer supported APIs from
65
+ internal paths. `cli-registry.json` similarly retains every governed command
66
+ path, syntax, option, alias, and side-effect-free help command projected from
67
+ the runtime registry and usage authority.
63
68
  `kfd-claims.json` is the Buildchain-owned KFD claim registry. It is generated
64
69
  from `packages/core/buildchain-kfd-claims.js` and enumerates the public release
65
70
  claims plus the KFD-3 collaboration surfaces that Buildchain self-verifies
@@ -130,6 +135,7 @@ import siteManifest from "@kungfu-tech/buildchain/site/site-manifest.json" with
130
135
  ## Generation
131
136
 
132
137
  ```bash
138
+ pnpm run generate:reference
133
139
  pnpm run generate:site
134
140
  pnpm run check:site
135
141
  ```
@@ -148,9 +154,9 @@ The P0 bundle includes:
148
154
  Node API overview, and fixtures;
149
155
  - site manifest;
150
156
  - publication archive registry for downstream papers surfaces;
151
- - CLI command registry;
157
+ - CLI command registry plus full-path generated human reference;
152
158
  - manual registry for packaged agent-facing documentation;
153
- - Node API registry for public package exports;
159
+ - Node API registry plus per-symbol generated human reference for public package exports;
154
160
  - workflow/action registry;
155
161
  - release model facts;
156
162
  - artifact and evidence schema index;
@@ -8,7 +8,7 @@ confidence: high
8
8
  sensitivity: public
9
9
  evidence_grade: A
10
10
  review_state: unreviewed
11
- last_reviewed: 2026-07-31
11
+ last_reviewed: 2026-08-01
12
12
  ai_provenance:
13
13
  model_family: GPT-5
14
14
  product: Codex
@@ -79,9 +79,10 @@ repository changes are patch".
79
79
 
80
80
  | Date | Action | Line | Faces | Class | Rationale | PR |
81
81
  | ---------- | ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
82
- | 2026-07-31 | extend-minor | `v3.0` | auditable-demo-workflow, auditable-demo-media-profile, auditable-demo-media-receipt | additive | Add an opt-in responsive profile that binds source-resolution and exact 1280x720 MP4/WebM/GIF renditions to one Gate and receipt while rejecting upscales, aspect-ratio drift, and profile changes between Gate-only and full-render paths. | |
83
- | 2026-07-31 | extend-minor | `v3.0` | release-candidate-family-evidence, release-passport-evidence-attachment, promotion-action, release-passport-cli | additive | Restore all-ref v2 parity for optional Initiative-family candidate binding and typed product-owned release evidence attachments while retaining Kungfu native Family State authority and the newer v3 post-activation released-evidence stage. | #2089 |
84
- | 2026-07-30 | extend-minor | `v3.0` | reusable-build-workflow, observed-evidence-bundle, release-passport-json-reader, web-surface-release-governance | additive | Add bounded artifact compression and remote-read controls plus transactional derived evidence projections while repairing release-PR runtime handoff so production remains protected-main-only. | |
82
+ | 2026-08-01 | extend-minor | `v3.0` | cli-reference-registry, node-api-symbol-registry, golden-path-manual | additive | Add generated, drift-checked CLI and Node API reference registries to the public site bundle, plus a package-tested first-user Golden Path; existing command execution and import semantics remain unchanged. | |
83
+ | 2026-07-31 | extend-minor | `v3.0` | auditable-demo-workflow, auditable-demo-media-profile, auditable-demo-media-receipt | additive | Add an opt-in responsive profile that binds source-resolution and exact 1280x720 MP4/WebM/GIF renditions to one Gate and receipt while rejecting upscales, aspect-ratio drift, and profile changes between Gate-only and full-render paths. | |
84
+ | 2026-07-31 | extend-minor | `v3.0` | release-candidate-family-evidence, release-passport-evidence-attachment, promotion-action, release-passport-cli | additive | Restore all-ref v2 parity for optional Initiative-family candidate binding and typed product-owned release evidence attachments while retaining Kungfu native Family State authority and the newer v3 post-activation released-evidence stage. | #2089 |
85
+ | 2026-07-30 | extend-minor | `v3.0` | reusable-build-workflow, observed-evidence-bundle, release-passport-json-reader, web-surface-release-governance | additive | Add bounded artifact compression and remote-read controls plus transactional derived evidence projections while repairing release-PR runtime handoff so production remains protected-main-only. | |
85
86
  | 2026-07-29 | extend-minor | `v3.0` | artifact-signing-config, apple-developer-id-authority, artifact-signing-evidence | additive | Extend the consumer-neutral signing declaration to macOS compound archives, including nested wheel Mach-O signing, PEP 427 RECORD repair, safe archive reconstruction, and whole-product notarization under the same protected authority. | |
86
87
  | 2026-07-28 | extend-minor | `v3.0` | auditable-demo-workflow, auditable-demo-media-profile, auditable-demo-media-receipt | additive | Add opt-in archive, web-delivery, and site-hero profiles; independently bind codec, container, audio, layout, byte-budget, role, and fast-start facts into a v2 media receipt while preserving the existing archive default. | |
87
88
  | 2026-07-26 | extend-minor | `v3.0` | auditable-demo-workflow, auditable-demo-evidence | additive | Forward-port the consumer-neutral reusable Gate that binds exact same-run GitHub Artifacts to checked-in adapters and immutable renderer evidence, with optional media rendering only from the exact passing Gate bundle. | #1862 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungfu-tech/buildchain",
3
- "version": "3.0.4-alpha.4",
3
+ "version": "3.0.4-alpha.6",
4
4
  "private": false,
5
5
  "description": "Buildchain Release Passport, release governance, CLI toolkit, and site facts.",
6
6
  "repository": "https://github.com/kungfu-systems/buildchain",
@@ -108,11 +108,14 @@
108
108
  },
109
109
  "packageManager": "pnpm@11.7.0",
110
110
  "scripts": {
111
- "check": "pnpm run check:static && node scripts/check-maintainability.mjs && node scripts/check-internal-architecture.mjs && node scripts/check-inventory.mjs && pnpm run check:site && pnpm run check:workflows && pnpm run test:unit && node scripts/check-action-bundles.mjs",
112
- "check:static": "node scripts/check-javascript-syntax.mjs && prettier --check architecture/*.json bin/internal/command-registry.mjs scripts/authorize-promotion-runtime-override.cjs scripts/check-javascript-syntax.mjs scripts/check-maintainability.mjs scripts/maintainability-metrics.mjs tests/authorize-promotion-runtime-override.test.mjs tests/command-registry.test.mjs tests/maintainability.test.mjs tests/promotion-responsibilities.test.mjs",
111
+ "check": "pnpm run check:static && node scripts/check-maintainability.mjs && node scripts/check-internal-architecture.mjs && node scripts/check-inventory.mjs && pnpm run check:site && pnpm run check:workflows && pnpm run test:unit && pnpm run check:golden-path && node scripts/check-action-bundles.mjs",
112
+ "check:static": "node scripts/check-javascript-syntax.mjs && prettier --check architecture/*.json bin/internal/command-registry.mjs scripts/authorize-promotion-runtime-override.cjs scripts/check-javascript-syntax.mjs scripts/check-maintainability.mjs scripts/maintainability-metrics.mjs scripts/public-reference.mjs scripts/site-reference-registry.mjs scripts/generate-public-reference.mjs scripts/verify-golden-path.mjs tests/authorize-promotion-runtime-override.test.mjs tests/command-registry.test.mjs tests/maintainability.test.mjs tests/promotion-responsibilities.test.mjs tests/public-reference.test.mjs",
113
113
  "check:workflows": "bash scripts/check-workflows.sh",
114
- "generate:site": "node scripts/generate-site-bundle.mjs",
115
- "check:site": "node scripts/generate-site-bundle.mjs --check",
114
+ "generate:reference": "node scripts/generate-public-reference.mjs",
115
+ "check:reference": "node scripts/generate-public-reference.mjs --check",
116
+ "generate:site": "pnpm run generate:reference && node scripts/generate-site-bundle.mjs",
117
+ "check:site": "pnpm run check:reference && node scripts/generate-site-bundle.mjs --check",
118
+ "check:golden-path": "node scripts/verify-golden-path.mjs",
116
119
  "test:unit": "node --test tests/*.test.mjs",
117
120
  "build": "pnpm -r --filter \"./actions/**\" build",
118
121
  "binary:build": "node scripts/build-standalone-binary.mjs",
@@ -0,0 +1,37 @@
1
+ export const BUILDCHAIN_AGENT_MANUALS = Object.freeze([
2
+ { id: "map", title: "Buildchain documentation map", path: "docs/MAP.md", plane: "use" },
3
+ { id: "getting-started", title: "Golden Path", path: "docs/getting-started.md", plane: "use" },
4
+ { id: "auditable-demo", title: "Auditable demo artifact pipeline", path: "docs/auditable-demo.md", plane: "verify" },
5
+ { id: "install", title: "Install and verify Buildchain", path: "docs/install.md", plane: "use" },
6
+ { id: "release-passport", title: "Release Passport protocol", path: "docs/release-passport.md", plane: "verify" },
7
+ { id: "github-artifact-attestation", title: "GitHub-native Linux artifact attestation", path: "docs/github-artifact-attestation.md", plane: "verify" },
8
+ { id: "controller-evidence", title: "Controller evidence contract", path: "docs/controller-evidence.md", plane: "verify" },
9
+ { id: "publication-authority", title: "Sealed publication authority", path: "docs/publication-authority.md", plane: "verify" },
10
+ { id: "github-governance-authority", title: "GitHub governance authority", path: "docs/github-governance-authority.md", plane: "verify" },
11
+ { id: "release-candidate", title: "Release Candidate Passport", path: "docs/release-candidate.md", plane: "verify" },
12
+ { id: "release-propagation", title: "Release propagation", path: "docs/release-propagation.md", plane: "use" },
13
+ { id: "readme-badges", title: "README badge blocks", path: "docs/readme-badges.md", plane: "use" },
14
+ { id: "homebrew", title: "Homebrew distribution indexes", path: "docs/homebrew.md", plane: "use" },
15
+ { id: "binary-distribution", title: "Binary distribution contract", path: "docs/binary-distribution.md", plane: "verify" },
16
+ { id: "consumer-issue-reporting", title: "Consumer issue reporting", path: "docs/consumer-issue-reporting.md", plane: "use" },
17
+ { id: "infra-contract", title: "Infra Contract", path: "docs/infra-contract.md", plane: "use" },
18
+ { id: "toolkit-observability", title: "Toolkit observability", path: "docs/toolkit-observability.md", plane: "use" },
19
+ { id: "site-bundle-contract", title: "Site bundle contract", path: "docs/site-bundle-contract.md", plane: "use" },
20
+ { id: "migration-inventory", title: "Migration inventory", path: "docs/migration-inventory.md", plane: "verify" },
21
+ { id: "ownership", title: "Ownership", path: "docs/ownership.md", plane: "why" },
22
+ { id: "product-mechanism", title: "Product mechanism", path: "docs/product-mechanism.md", plane: "why" },
23
+ { id: "cli", title: "CLI and npm package", path: "docs/cli.md", plane: "use" },
24
+ { id: "cli-reference", title: "Generated CLI reference", path: "docs/cli-reference.md", plane: "use" },
25
+ { id: "node-api-reference", title: "Generated Node API reference", path: "docs/node-api-reference.md", plane: "use" },
26
+ { id: "build-facts", title: "Build Facts", path: "docs/build-facts.md", plane: "use" },
27
+ { id: "kfd-support", title: "KFD support and KFD-3 surface registration", path: "docs/kfd-support.md", plane: "verify" },
28
+ { id: "kfd-agent-hub", title: "KFD Agent Hub Builder flow", path: "docs/kfd-agent-hub.md", plane: "use" },
29
+ { id: "lifecycle-protocol", title: "Lifecycle protocol", path: "docs/lifecycle-protocol.md", plane: "use" },
30
+ { id: "reusable-build-surface", title: "Reusable build surface", path: "docs/reusable-build-surface.md", plane: "use" },
31
+ { id: "publish-transaction", title: "Publish transaction", path: "docs/publish-transaction.md", plane: "verify" },
32
+ { id: "release-governance", title: "Release governance", path: "docs/release-governance.md", plane: "why" },
33
+ { id: "release-flow", title: "Release flow", path: "docs/release-flow.md", plane: "verify" },
34
+ { id: "runtime-train-validation", title: "Runtime train validation", path: "docs/runtime-train-validation.md", plane: "verify" },
35
+ { id: "versioning", title: "Versioning", path: "docs/versioning.md", plane: "why" },
36
+ { id: "web-surface-deployments", title: "Web surface deployments", path: "docs/web-surface-deployments.md", plane: "use" },
37
+ ]);
@@ -7,45 +7,13 @@ import {
7
7
  collectPublicSurfaceReverseAudit,
8
8
  } from "./public-surface-audit.js";
9
9
  import { normalizeKfd3DistributionDeclaration } from "./kfd3-surface-register.js";
10
+ import { BUILDCHAIN_AGENT_MANUALS } from "./buildchain-agent-manuals.js";
11
+
12
+ export { BUILDCHAIN_AGENT_MANUALS } from "./buildchain-agent-manuals.js";
10
13
 
11
14
  export const BUILDCHAIN_KFD_CLAIM_REGISTRY_CONTRACT = "kungfu-buildchain-kfd-claim-registry";
12
15
  export const BUILDCHAIN_KFD_COLLABORATION_INTERFACE_CONTRACT = "kungfu-buildchain-kfd-collaboration-interface";
13
16
 
14
- export const BUILDCHAIN_AGENT_MANUALS = Object.freeze([
15
- { id: "map", title: "Buildchain documentation map", path: "docs/MAP.md", plane: "use" },
16
- { id: "auditable-demo", title: "Auditable demo artifact pipeline", path: "docs/auditable-demo.md", plane: "verify" },
17
- { id: "install", title: "Install and verify Buildchain", path: "docs/install.md", plane: "use" },
18
- { id: "release-passport", title: "Release Passport protocol", path: "docs/release-passport.md", plane: "verify" },
19
- { id: "github-artifact-attestation", title: "GitHub-native Linux artifact attestation", path: "docs/github-artifact-attestation.md", plane: "verify" },
20
- { id: "controller-evidence", title: "Controller evidence contract", path: "docs/controller-evidence.md", plane: "verify" },
21
- { id: "publication-authority", title: "Sealed publication authority", path: "docs/publication-authority.md", plane: "verify" },
22
- { id: "github-governance-authority", title: "GitHub governance authority", path: "docs/github-governance-authority.md", plane: "verify" },
23
- { id: "release-candidate", title: "Release Candidate Passport", path: "docs/release-candidate.md", plane: "verify" },
24
- { id: "release-propagation", title: "Release propagation", path: "docs/release-propagation.md", plane: "use" },
25
- { id: "readme-badges", title: "README badge blocks", path: "docs/readme-badges.md", plane: "use" },
26
- { id: "homebrew", title: "Homebrew distribution indexes", path: "docs/homebrew.md", plane: "use" },
27
- { id: "binary-distribution", title: "Binary distribution contract", path: "docs/binary-distribution.md", plane: "verify" },
28
- { id: "consumer-issue-reporting", title: "Consumer issue reporting", path: "docs/consumer-issue-reporting.md", plane: "use" },
29
- { id: "infra-contract", title: "Infra Contract", path: "docs/infra-contract.md", plane: "use" },
30
- { id: "toolkit-observability", title: "Toolkit observability", path: "docs/toolkit-observability.md", plane: "use" },
31
- { id: "site-bundle-contract", title: "Site bundle contract", path: "docs/site-bundle-contract.md", plane: "use" },
32
- { id: "migration-inventory", title: "Migration inventory", path: "docs/migration-inventory.md", plane: "verify" },
33
- { id: "ownership", title: "Ownership", path: "docs/ownership.md", plane: "why" },
34
- { id: "product-mechanism", title: "Product mechanism", path: "docs/product-mechanism.md", plane: "why" },
35
- { id: "cli", title: "CLI and npm package", path: "docs/cli.md", plane: "use" },
36
- { id: "build-facts", title: "Build Facts", path: "docs/build-facts.md", plane: "use" },
37
- { id: "kfd-support", title: "KFD support and KFD-3 surface registration", path: "docs/kfd-support.md", plane: "verify" },
38
- { id: "kfd-agent-hub", title: "KFD Agent Hub Builder flow", path: "docs/kfd-agent-hub.md", plane: "use" },
39
- { id: "lifecycle-protocol", title: "Lifecycle protocol", path: "docs/lifecycle-protocol.md", plane: "use" },
40
- { id: "reusable-build-surface", title: "Reusable build surface", path: "docs/reusable-build-surface.md", plane: "use" },
41
- { id: "publish-transaction", title: "Publish transaction", path: "docs/publish-transaction.md", plane: "verify" },
42
- { id: "release-governance", title: "Release governance", path: "docs/release-governance.md", plane: "why" },
43
- { id: "release-flow", title: "Release flow", path: "docs/release-flow.md", plane: "verify" },
44
- { id: "runtime-train-validation", title: "Runtime train validation", path: "docs/runtime-train-validation.md", plane: "verify" },
45
- { id: "versioning", title: "Versioning", path: "docs/versioning.md", plane: "why" },
46
- { id: "web-surface-deployments", title: "Web surface deployments", path: "docs/web-surface-deployments.md", plane: "use" },
47
- ]);
48
-
49
17
  const SITE_CONTRACT_FILES = Object.freeze([
50
18
  "dist/site/buildchain-site.json",
51
19
  "dist/site/site-manifest.json",
@@ -203,7 +171,6 @@ function uniqueById(entries) {
203
171
  return true;
204
172
  });
205
173
  }
206
-
207
174
  function uniquePaths(paths) {
208
175
  return [...new Set(paths.filter(Boolean))].sort();
209
176
  }
@@ -199,10 +199,14 @@ function ciContext({ env, developmentRef }) {
199
199
  const pullRequest = ["pull_request", "pull_request_target"].includes(event);
200
200
  const channelBranches = expectedCiBranches(developmentRef);
201
201
  const channelIndex = channelBranches.indexOf(targetBranch);
202
+ const versionStatePrefix = `buildchain/version-state/${targetBranch.replaceAll("/", "-")}/`;
203
+ const generatedVersionState =
204
+ channelBranches.includes(targetBranch) &&
205
+ sourceBranch.startsWith(versionStatePrefix) &&
206
+ /^[0-9a-f]{12}$/i.test(sourceBranch.slice(versionStatePrefix.length));
202
207
  const branchOk = pullRequest
203
- ? (PAPER_WORK_BRANCH_PATTERN.test(sourceBranch) &&
204
- targetBranch === developmentRef) ||
205
- (channelIndex > 0 && sourceBranch === channelBranches[channelIndex - 1])
208
+ ? (PAPER_WORK_BRANCH_PATTERN.test(sourceBranch) && targetBranch === developmentRef) ||
209
+ (channelIndex > 0 && sourceBranch === channelBranches[channelIndex - 1]) || generatedVersionState
206
210
  : channelBranches.includes(refName);
207
211
  return {
208
212
  mode: "ci",
@@ -213,7 +217,7 @@ function ciContext({ env, developmentRef }) {
213
217
  pullRequest,
214
218
  ok: branchOk,
215
219
  message: pullRequest
216
- ? `Pull requests must target ${developmentRef} from an allowed work branch or promote adjacent protected channels.`
220
+ ? `Pull requests must target ${developmentRef} from an allowed work branch, promote adjacent protected channels, or carry an exact target-bound generated version state.`
217
221
  : `Channel checks must run on ${channelBranches.join(", ")}.`,
218
222
  };
219
223
  }
@@ -421,6 +421,7 @@ ${passportInput} secrets:
421
421
  BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID: \${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID }}
422
422
  BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY: \${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY }}
423
423
  BUILDCHAIN_GENERATED_WRITE_TOKEN: \${{ secrets.BUILDCHAIN_GENERATED_WRITE_TOKEN }}
424
+ BUILDCHAIN_PROMOTION_TOKEN: \${{ secrets.BUILDCHAIN_PROMOTION_TOKEN }}
424
425
  `;
425
426
  }
426
427
 
@@ -4,6 +4,7 @@ import path from "node:path";
4
4
  import { loadBuildchainConfig } from "./buildchain-config.js";
5
5
 
6
6
  export const PUBLICATION_NPM_PACKAGE_CONTRACT = "kungfu-buildchain-publication-npm-package";
7
+ const GIT_SHA_PATTERN = /^[0-9a-f]{40}$/i;
7
8
 
8
9
  function toPosix(value) {
9
10
  return String(value || "").split(path.sep).join("/");
@@ -154,6 +155,11 @@ export function preparePublicationNpmPackage({
154
155
  if (!fs.existsSync(passportFile)) {
155
156
  throw new Error(`publication passport is missing: ${facts.publication.passportPath}`);
156
157
  }
158
+ const manifest = readJson(manifestFile);
159
+ const gitHead = String(manifest.source?.sha || "").trim().toLowerCase();
160
+ if (!GIT_SHA_PATTERN.test(gitHead)) {
161
+ throw new Error("publication npm package requires an exact 40-character source Git SHA");
162
+ }
157
163
  if (!files.some((file) => file.path === facts.publication.primaryArtifact)) {
158
164
  throw new Error(`publication primary artifact is missing from npm package: ${facts.publication.primaryArtifact}`);
159
165
  }
@@ -174,6 +180,7 @@ export function preparePublicationNpmPackage({
174
180
  description: `${facts.publication.title} publication artifact package.`,
175
181
  license: sourcePackage.license || "UNLICENSED",
176
182
  repository,
183
+ gitHead,
177
184
  type: "module",
178
185
  files: [
179
186
  ".buildchain/publication/",
@@ -15,11 +15,10 @@ import {
15
15
  generateChannelPromotionWorkflow,
16
16
  parsePromotionShellRouting,
17
17
  } from "./generate-channel-promotion-workflow.mjs";
18
-
18
+ import { assertPublicReferenceRegistry } from "./site-reference-registry.mjs";
19
19
  const root = process.cwd();
20
20
  const sharedActionTsupConfig = fs.readFileSync(path.join(root, "scripts/tsup-action.config.mjs"), "utf8");
21
21
  const commonJsSourcePattern = /\b(require\s*\(|module\.exports|exports\.|require\.main|createRequire)\b/;
22
-
23
22
  function assertSelfReleaseImpactContract(impact, { expectedVersion = "" } = {}) {
24
23
  if (!impact || typeof impact !== "object" || Array.isArray(impact)) {
25
24
  throw new Error("Buildchain self release impact must be a JSON object");
@@ -700,6 +699,7 @@ for (const exported of nodeApiRegistry.exports || []) {
700
699
  }
701
700
  assertPublicLifecycle(exported, `node-api-registry.json export ${exported.export || exported.specifier}`);
702
701
  }
702
+ assertPublicReferenceRegistry({ cliRegistry, nodeApiRegistry });
703
703
  const workflowRegistry = JSON.parse(fs.readFileSync(path.join(root, "dist/site/workflow-registry.json"), "utf8"));
704
704
  for (const workflow of workflowRegistry.workflows || []) {
705
705
  assertPublicLifecycle(workflow, `workflow-registry.json workflow ${workflow.id || workflow.path}`);
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+
6
+ import { BUILDCHAIN_USAGE } from "./buildchain-cli-help.mjs";
7
+ import {
8
+ createCliReference,
9
+ createNodeApiReference,
10
+ renderCliReference,
11
+ renderNodeApiReference,
12
+ } from "./public-reference.mjs";
13
+
14
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
15
+
16
+ export function publicReferenceOutputs({ repoRoot = root } = {}) {
17
+ const packageJson = JSON.parse(
18
+ fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"),
19
+ );
20
+ return {
21
+ "docs/cli-reference.md": renderCliReference(
22
+ createCliReference(BUILDCHAIN_USAGE),
23
+ ),
24
+ "docs/node-api-reference.md": renderNodeApiReference(
25
+ createNodeApiReference({ root: repoRoot, packageJson }),
26
+ ),
27
+ };
28
+ }
29
+
30
+ export function generatePublicReference({
31
+ check = false,
32
+ repoRoot = root,
33
+ } = {}) {
34
+ const outputs = publicReferenceOutputs({ repoRoot });
35
+ const stale = [];
36
+ for (const [relPath, content] of Object.entries(outputs)) {
37
+ const filePath = path.join(repoRoot, relPath);
38
+ const current = fs.existsSync(filePath)
39
+ ? fs.readFileSync(filePath, "utf8")
40
+ : "";
41
+ if (current !== content) {
42
+ if (check) stale.push(relPath);
43
+ else fs.writeFileSync(filePath, content);
44
+ }
45
+ }
46
+ if (stale.length > 0) {
47
+ throw new Error(`public reference is stale: ${stale.join(", ")}`);
48
+ }
49
+ return {
50
+ contract: "kungfu-buildchain-public-reference-generation/v1",
51
+ check,
52
+ files: Object.keys(outputs),
53
+ };
54
+ }
55
+
56
+ if (
57
+ process.argv[1] &&
58
+ import.meta.url === pathToFileURL(process.argv[1]).href
59
+ ) {
60
+ try {
61
+ process.stdout.write(
62
+ `${JSON.stringify(generatePublicReference({ check: process.argv.includes("--check") }), null, 2)}\n`,
63
+ );
64
+ } catch (error) {
65
+ console.error(`buildchain public reference: ${error.message}`);
66
+ process.exitCode = 1;
67
+ }
68
+ }
@@ -35,6 +35,12 @@ import {
35
35
  import { createSurfaceTimestampPolicy } from "../packages/core/surface-manifest.js";
36
36
  import { cliCommandMeta, nodeApiMeta } from "./site-capability-metadata.mjs";
37
37
  import { projectHomepageIntro } from "./site-bundle-homepage.mjs";
38
+ import { BUILDCHAIN_USAGE } from "./buildchain-cli-help.mjs";
39
+ import {
40
+ cliReferenceById,
41
+ createCliReference,
42
+ } from "./public-reference.mjs";
43
+ import { createSiteNodeApiRegistry } from "./site-reference-registry.mjs";
38
44
  import {
39
45
  BUILDCHAIN_COMMAND_REGISTRY,
40
46
  resolveBuildchainCommand,
@@ -341,9 +347,12 @@ function publicSurfaceLifecycle({ owner, maturity, nonDuplicationRationale }) {
341
347
 
342
348
  const manualMetaById = new Map(Object.entries({
343
349
  map: { capabilityGroup: "getting-started", audience: ["agent", "consumer"], maturity: "stable", order: 10 },
350
+ "getting-started": { capabilityGroup: "getting-started", audience: ["consumer", "agent"], maturity: "stable", order: 15 },
344
351
  install: { capabilityGroup: "getting-started", audience: ["consumer"], maturity: "stable", order: 20 },
345
352
  "product-mechanism": { capabilityGroup: "getting-started", audience: ["agent", "maintainer"], maturity: "stable", order: 30 },
346
353
  cli: { capabilityGroup: "api-cli-reference", audience: ["agent", "developer"], maturity: "stable", order: 40 },
354
+ "cli-reference": { capabilityGroup: "api-cli-reference", audience: ["agent", "developer", "operator"], maturity: "stable", order: 42 },
355
+ "node-api-reference": { capabilityGroup: "api-cli-reference", audience: ["agent", "developer"], maturity: "stable", order: 44 },
347
356
  "release-passport": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "stable", order: 100 },
348
357
  "github-artifact-attestation": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "preview", order: 108 },
349
358
  "publication-authority": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "preview", order: 105 },
@@ -409,6 +418,8 @@ function pageCapabilityMeta(relPath, category) {
409
418
 
410
419
  function createCliRegistry(packageJson) {
411
420
  const commands = enumerateCliCommandsFromBin({ root });
421
+ const reference = createCliReference(BUILDCHAIN_USAGE);
422
+ const referenceById = cliReferenceById(reference);
412
423
  const documentedTopLevelCommands = new Set();
413
424
  for (const entry of commands) {
414
425
  const command = entry.usage.split(/\s+/)[1] || "";
@@ -433,6 +444,13 @@ function createCliRegistry(packageJson) {
433
444
  const meta = cliCommandMeta(entry.id);
434
445
  return {
435
446
  ...entry,
447
+ ...(referenceById.get(entry.id) || {
448
+ paths: [],
449
+ syntaxes: [],
450
+ options: [],
451
+ aliases: [],
452
+ helpCommands: [],
453
+ }),
436
454
  purpose: meta.purpose,
437
455
  capabilityGroup: meta.capabilityGroup,
438
456
  audience: meta.audience,
@@ -738,40 +756,7 @@ function buildSiteBundle() {
738
756
  pages,
739
757
  };
740
758
 
741
- const nodeApiRegistry = {
742
- schemaVersion: 1,
743
- contract: "kungfu-buildchain-node-api-registry",
744
- package: packageJson.name,
745
- moduleSystem: packageJson.type || "module",
746
- exports: Object.entries(packageJson.exports || {})
747
- .filter(([specifier]) => !specifier.startsWith("./site/") && specifier !== "./package.json")
748
- .map(([specifier, target]) => {
749
- const meta = nodeApiMeta(specifier);
750
- return {
751
- specifier: specifier === "." ? packageJson.name : `${packageJson.name}/${specifier.replace(/^\.\//, "")}`,
752
- export: specifier,
753
- target,
754
- digest: typeof target === "string" ? sha256File(target.replace(/^\.\//, "")) : "",
755
- summary: meta.summary,
756
- capabilityGroup: meta.capabilityGroup,
757
- audience: meta.audience,
758
- ...publicSurfaceLifecycle({
759
- owner: "buildchain-core",
760
- maturity: meta.maturity,
761
- nonDuplicationRationale: "Existing package subpath retained as the canonical API boundary for this capability.",
762
- }),
763
- };
764
- }),
765
- docs: [
766
- { id: "cli-and-node-package", path: "docs/cli.md", digest: sha256File("docs/cli.md") },
767
- { id: "build-facts", path: "docs/build-facts.md", digest: sha256File("docs/build-facts.md") },
768
- { id: "kfd-support", path: "docs/kfd-support.md", digest: sha256File("docs/kfd-support.md") },
769
- { id: "readme-badges", path: "docs/readme-badges.md", digest: sha256File("docs/readme-badges.md") },
770
- { id: "homebrew", path: "docs/homebrew.md", digest: sha256File("docs/homebrew.md") },
771
- { id: "site-bundle-contract", path: "docs/site-bundle-contract.md", digest: sha256File("docs/site-bundle-contract.md") },
772
- ],
773
- guidance: "These are the public Node import surfaces shipped by the npm package. Agents should prefer these exports over internal file paths.",
774
- };
759
+ const nodeApiRegistry = createSiteNodeApiRegistry({ root, packageJson, nodeApiMeta, sha256File, publicSurfaceLifecycle });
775
760
 
776
761
  const workflowRegistry = {
777
762
  schemaVersion: 1,