Skip to content

feat(library): package @vivswan/github-settings-as-code - #142

Merged
Vivswan merged 7 commits into
mainfrom
feat/library-package
Sep 12, 2026
Merged

Vivswan merged 7 commits into
mainfrom
feat/library-package

Conversation

@Vivswan

@Vivswan Vivswan commented Sep 11, 2026

Copy link
Copy Markdown
Owner
npm install @vivswan/github-settings-as-code        # stable, from the first release
npm install @vivswan/github-settings-as-code@next   # every green main, until then

exports:
  .                        -> lib/pkg/index.js  (types: lib/pkg/index.d.ts)
  ./settings.schema.json   -> lib/settings.schema.json
  ./package.json           -> package.json
  • package.json is now the npm manifest: scoped name, version mirroring .release-please-manifest.json, exports map, files, publishConfig, engines (Node 22.14+), ESM only. A new test/package-json.test.ts pins the field set and the version equality.
  • bun run build:lib (tsdown, tsdown.config.ts) bundles src/index.ts into lib/pkg/index.js plus one index.d.ts, runtime dependencies external. Built, never committed (gitignored beside lib/index.js). The action bundle is untouched.
  • .github/scripts/package-smoke.ts builds, runs publint --strict and attw --profile esm-only, packs, installs the tarball into a fresh consumer, imports it under Node (entry and schema subpath), and typechecks a consumer with skipLibCheck false. checks.yml runs it as the package-smoke job, so all-green covers it.
  • @actions/artifact and @actions/core move to devDependencies (only the action bundle inlines them); @octokit/types and @octokit/openapi-types move to dependencies because the bundled d.ts imports @octokit/types.
  • release-please rewrites package.json $.version through a json extra-file; the docs marker test now filters string entries and pins that one json entry.
  • New docs/reference/library.md: install lines, the API by group with one example each, versioning, and the one-time trusted-publishing setup. README gains a short Library section. Nothing is published by this PR.
Technical details
  • Base is refactor/flows-library (stacked). build:lib fails on that base today with TS4023: PlannedOpBase, Unverifiable, Tolerance (and Justification) in src/sections/contract/plan.ts are referenced by every exported section module but not exported, so the declaration emitter cannot name them. That fix belongs to the base branch; package-smoke stays red here until it lands. With those four exports applied locally, the full smoke passes end to end (build, publint, attw, pack, install, Node import, tsc).
  • repository is the object form ({type: "git", url: "git+https://..."}): publint --strict rejects the bare git+https string.
  • tsdown's fixedExtension is off so the outputs are index.js and index.d.ts (the package is type: module); deps.neverBundle lists every runtime dependency and its subpaths.
  • npm pack --json prints an array under npm 11 and an object keyed by package name under npm 12; the smoke reads both. --ignore-scripts keeps the prepare hook's output out of the JSON.
  • prepare is lefthook install || true so a github: install (which runs prepare) survives a tree without lefthook.
  • knip: src/index.ts left the explicit entry list because the tsdown plugin already reports it as an entry; lint:package is the package.json home for publint and attw so knip sees the binaries.
  • The github:Vivswan/github-settings-as-code#<sha> install form documented on the library page needs the packaged branch to carry lib/pkg/; the page says so.

Reviewer note (Copilot): report a finding only with a concrete input and the wrong output it produces.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

File size check

0 over a hard cap (fails), 90 warning(s).

File Size Tier Cap
.github/scripts/release-pipeline.ts:1 40 comment lines (header) warn 25
.github/scripts/release-pipeline.ts:524 22 comment lines warn 10
.github/scripts/release-pipeline.ts:640 11 comment lines warn 10
.github/scripts/release-pipeline.ts:981 17 comment lines warn 10
.github/scripts/release-pipeline.ts:1065 14 comment lines warn 10
.github/workflows/auto-fix.yml:1 36 comment lines (header) warn 25
.github/workflows/post-green.yml:65 205 chars warn 150
.github/workflows/post-green.yml:66 193 chars warn 150
.github/workflows/post-green.yml:35 13 comment lines warn 10
.github/workflows/update-release.yml:1 32 comment lines (header) warn 25
src/engine/layers.ts:48 11 comment lines warn 10
src/engine/layers.ts:172 11 comment lines warn 10
src/engine/layers.ts:538 13 comment lines warn 10
src/engine/secret-refs.ts:119 11 comment lines warn 10
src/engine/validate.ts:13 13 comment lines warn 10
src/flows/settings-read.ts:16 11 comment lines warn 10
src/report/issue-report.ts:316 13 comment lines warn 10
src/report/issue-report.ts:348 14 comment lines warn 10
src/schema.ts:1 36 comment lines (header) warn 25
src/sections/contract/module.ts:68 12 comment lines warn 10
src/sections/contract/module.ts:95 17 comment lines warn 10
src/sections/contract/module.ts:179 11 comment lines warn 10
src/sections/contract/module.ts:325 11 comment lines warn 10
src/sections/contract/module.ts:370 11 comment lines warn 10
src/sections/contract/module.ts:382 18 comment lines warn 10
src/sections/contract/module.ts:421 11 comment lines warn 10
src/sections/contract/module.ts:515 18 comment lines warn 10
src/sections/contract/module.ts:719 12 comment lines warn 10
src/sections/contract/permissions.ts:113 13 comment lines warn 10
src/sections/environments/nested.ts:63 12 comment lines warn 10
src/sections/environments/nested.ts:173 12 comment lines warn 10
src/sections/environments/nested.ts:228 14 comment lines warn 10
src/sections/environments/schema.ts:144 11 comment lines warn 10
src/sections/shared/repo-secrets.ts:158 13 comment lines warn 10
src/sections/shared/schema-helpers.ts:32 16 comment lines warn 10
test/docs/claims.ts:108 11 comment lines warn 10
test/docs/guides.test.ts:329 13 comment lines warn 10
test/e2e/fuzz.ts:624 18 comment lines warn 10
test/e2e/fuzz.ts:770 14 comment lines warn 10
test/e2e/fuzz.ts:1013 12 comment lines warn 10
test/e2e/fuzz.ts:1450 12 comment lines warn 10
test/e2e/fuzz.ts:1559 12 comment lines warn 10
test/e2e/fuzz.ts:1658 11 comment lines warn 10
test/e2e/fuzz.ts:1685 11 comment lines warn 10
test/e2e/fuzz.ts:1789 11 comment lines warn 10
test/e2e/fuzz.ts:1840 13 comment lines warn 10
test/e2e/gen-support.ts:52 17 comment lines warn 10
test/e2e/gen-support.ts:150 13 comment lines warn 10
test/e2e/generators.ts 2745 lines warn 2560
test/e2e/generators.ts:86 11 comment lines warn 10
test/e2e/generators.ts:225 16 comment lines warn 10
test/e2e/generators.ts:259 19 comment lines warn 10
test/e2e/generators.ts:394 12 comment lines warn 10
test/e2e/generators.ts:809 13 comment lines warn 10
test/e2e/generators.ts:1169 12 comment lines warn 10
test/e2e/generators.ts:1231 11 comment lines warn 10
test/e2e/generators.ts:1252 32 comment lines warn 10
test/e2e/generators.ts:1317 11 comment lines warn 10
test/e2e/generators.ts:1480 13 comment lines warn 10
test/e2e/generators.ts:2295 18 comment lines warn 10
test/e2e/mock/core-paths.ts:75 16 comment lines warn 10
test/e2e/mock/core-paths.ts:173 11 comment lines warn 10
test/e2e/mock/core-paths.ts:242 13 comment lines warn 10
test/e2e/mock/core-paths.ts:373 15 comment lines warn 10
test/e2e/mock/core-paths.ts:418 13 comment lines warn 10
test/e2e/mock/core-paths.ts:588 14 comment lines warn 10
test/e2e/mock/routes.ts:174 17 comment lines warn 10
test/e2e/mock/routes.ts:599 11 comment lines warn 10
test/e2e/mock/state.ts:960 15 comment lines warn 10
test/e2e/mock/state.ts:1122 11 comment lines warn 10
test/e2e/openapi/paths.ts:34 16 comment lines warn 10
test/e2e/openapi/validate.ts:85 23 comment lines warn 10
test/e2e/openapi/validate.ts:416 13 comment lines warn 10
test/e2e/openapi/validate.ts:602 12 comment lines warn 10
test/e2e/oracle.ts:78 13 comment lines warn 10
test/e2e/oracle.ts:121 14 comment lines warn 10
test/e2e/oracle.ts:1032 11 comment lines warn 10
test/e2e/oracle.ts:1117 11 comment lines warn 10
test/e2e/runner.ts:105 11 comment lines warn 10
test/e2e/runner.ts:480 11 comment lines warn 10
test/e2e/runner.ts:540 11 comment lines warn 10
test/e2e/runner.ts:707 15 comment lines warn 10
test/e2e/schema.ts:172 20 comment lines warn 10
test/e2e/schema.ts:296 11 comment lines warn 10
test/e2e/schema.ts:352 22 comment lines warn 10
test/e2e/schema.ts:561 11 comment lines warn 10
test/e2e/schema.ts:670 18 comment lines warn 10
test/scripts/release-pipeline.test.ts 2602 lines warn 2560
test/sections/registry.test.ts:266 13 comment lines warn 10
test/sections/registry.test.ts:467 11 comment lines warn 10

Split the file, wrap the line, shorten or exempt the comment, or list the path in .file-size-allow.local with a # reason.

5 managed file(s) skipped; repo-platform owns them.

Comment thread tsdown.config.ts Fixed
@Vivswan
Vivswan force-pushed the refactor/flows-library branch 2 times, most recently from 6bc1674 to 649afb3 Compare September 11, 2026 22:46
@Vivswan
Vivswan force-pushed the feat/library-package branch 2 times, most recently from a78f0db to 11757a2 Compare September 11, 2026 23:18
@Vivswan
Vivswan force-pushed the refactor/flows-library branch from 649afb3 to 801c7ec Compare September 12, 2026 01:11
@Vivswan
Vivswan force-pushed the feat/library-package branch from 11757a2 to d45b6fa Compare September 12, 2026 01:20
Base automatically changed from refactor/flows-library to main September 12, 2026 01:24
Copilot AI balanced review requested due to automatic review settings September 12, 2026 01:39
@Vivswan
Vivswan force-pushed the feat/library-package branch from d45b6fa to a3d764a Compare September 12, 2026 01:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documented trusted-publishing setup cannot bootstrap the package's first npm release.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Packages the existing engine as an ESM npm library with validated artifacts, CI smoke testing, release version synchronization, and consumer documentation.

Changes:

  • Adds the tsdown library build and npm manifest exports.
  • Adds package validation, consumer smoke tests, and CI gating.
  • Documents the public API, installation, and release process.
File summaries
File Description
tsdown.config.ts Configures the ESM library build.
package.json Defines npm metadata, exports, scripts, and dependencies.
bun.lock Locks the new packaging tools and dependencies.
.gitignore Excludes generated library artifacts.
knip.json Delegates public-entry discovery to tsdown.
src/index.ts Exports declaration-required plan types.
src/sections/contract/plan.ts Makes referenced plan types public.
.github/scripts/package-smoke.ts Builds and validates an installed package.
.github/workflows/checks.yml Adds the package smoke CI gate.
release-please-config.json Synchronizes the package version during releases.
test/package-json.test.ts Pins the publishable manifest contract.
test/library/package-smoke.test.ts Tests smoke-script helpers.
test/library/public-surface.test.ts Pins the expanded public type surface.
test/docs/readme.test.ts Verifies library documentation links.
test/docs/guides.test.ts Registers and validates the library guide.
docs/reference/library.md Documents installation, APIs, and publishing.
README.md Introduces the npm library.
docs/README.md Adds library documentation navigation.
AGENTS.md Records repository packaging conventions.
Review details
  • Files reviewed: 17/19 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/reference/library.md Resolved
Copilot AI review requested due to automatic review settings September 12, 2026 01:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documented first publish can produce an immutable package whose exported library files are absent.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 17/19 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread docs/reference/library.md Resolved
Copilot AI review requested due to automatic review settings September 12, 2026 01:54
@Vivswan
Vivswan force-pushed the feat/library-package branch 3 times, most recently from a18dc70 to 379c9b1 Compare September 12, 2026 01:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Packaged Git refs omit lib/pkg, causing the documented GitHub package installation to fail.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 17/19 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread package.json Resolved
@Vivswan Vivswan closed this Sep 12, 2026
@Vivswan Vivswan reopened this Sep 12, 2026
@Vivswan
Vivswan marked this pull request as ready for review September 12, 2026 03:06
settings-as-code-release added 4 commits September 11, 2026 23:10
Publish the engine as an ESM-only npm library beside the action:

- package.json becomes the npm manifest (scoped name, version mirroring
  .release-please-manifest.json, exports map, files, publishConfig);
  the action-only @actions packages move to devDependencies.
- tsdown builds src/index.ts to lib/pkg/index.js plus one index.d.ts
  (bun run build:lib; built, not committed).
- .github/scripts/package-smoke.ts builds, runs publint and attw, packs,
  installs into a fresh consumer, imports under Node, and typechecks with
  skipLibCheck off; checks.yml runs it as the package-smoke job.
- release-please rewrites package.json version through a json extra-file.
- docs/reference/library.md documents install lines, the API by group,
  versioning, and the one-time trusted-publishing setup.
The bundled declaration build (tsdown, dts: true) fails with TS4023 when
a type reachable from the public entry is not exported from its module:
every section module carries PlannedOpBase, Tolerance, Unverifiable, and
Justification from src/sections/contract/plan.ts in its type. Export the
four, re-export them as types from src/index.ts, and pin them in the
public-surface test.
The package is not published yet and the build branch carries no lib/pkg/,
so the install and versioning sections now say the library is built here
with bun run build:lib and that npm and packaged-branch installation arrive
with the publishing change. The API-by-group content is unchanged.
settings-as-code-release added 3 commits September 11, 2026 23:10
main now takes { token, io?, baseUrl?, apiVersion? }; the positional form
compiled against the old signature and left the client unauthenticated.
A trusted publisher can only be added to a package that already exists on
npm, so the setup section now starts with the manual first publish.
Every fallible call now returns a neverthrow Result or ResultAsync with a
typed Problem: the library page examples and the package-smoke consumer
snippets read .isOk()/.isErr()/.value/.match and render problems with
describeProblem; readSettingsFile takes the file role and the check example
passes a SectionSelection.
Copilot AI review requested due to automatic review settings September 12, 2026 03:28
@Vivswan
Vivswan force-pushed the feat/library-package branch from 379c9b1 to 6ea8aa1 Compare September 12, 2026 03:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The package build, public declarations, manifest, documentation, and consumer smoke coverage are consistent and complete.

Review details
  • Files reviewed: 17/19 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@Vivswan
Vivswan merged commit cbeb56f into main Sep 12, 2026
38 checks passed
@Vivswan
Vivswan deleted the feat/library-package branch September 12, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants