Skip to content

docs: state the self-contained plugin output rule (no autoExternal, no externals) - #573

Merged
ScriptedAlchemy merged 2 commits into
mainfrom
docs/self-contained-plugin-output
Sep 5, 2026
Merged

docs: state the self-contained plugin output rule (no autoExternal, no externals)#573
ScriptedAlchemy merged 2 commits into
mainfrom
docs/self-contained-plugin-output

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Why

The project rule "plugin builds are self-contained — no autoExternal, no externals" is already what the compiler does, but it was stated nowhere as a rule, so refactors and toolchain upgrades kept brushing against it. This PR codifies it, describing the behavior the source has today (every sentence was checked against the code, not the design intent).

What

  • AGENTS.md: new ## Generated plugin output section after "Public examples" (3 bullets).
  • website/docs/{en,zh}/guide/distribution/validation.mdx: one paragraph in "The npm prepack gate" — the page an author reads when deciding what goes in dependencies — en and zh in the same PR.
  • docs/entry-conventions.md: one sentence in the tools section, beside the existing reserved-specifier externals rule.

Sources verified: packages/agent-bundle/src/build/rslib.ts (composeEntryLibConfig profile: autoExternal: false, bundle: true, splitChunks: false, no externals; reservedExternalsViolation / guardReservedExternals reject reserved specifiers in the resolved externals), src/build/mcp-apps.ts (views inline everything into one HTML file; assertSelfContainedViews), Rslib 0.23.2 composeTargetConfig (Node built-ins plus pnpapi externalized for output.target: 'node' independently of autoExternal), src/build/validate-artifact-modules.ts (AB6005) and build.ts (every artifact build validates), package-build.ts (dist not walked by AB6005), pack-dependencies.ts / pack-inventory.ts (AB7014/AB7015), and the packed pool (scripts/run-packed-tests.mjs, packed-stdio-projection.test.ts, removeProjectSource, packed-deleted-source).

Gate: pnpm docs:site:build (typecheck, Rspress build, dead-link/anchor/image, en/zh parity) passes on the final tree.

Changeset

skip-changeset: docs and AGENTS.md only; no publishable package changes.

Self-review

Reviewer: change-risk-reviewer (gpt-5.6-sol-medium), asked only whether every sentence matches the code. Three passes.

Pass 1 — four findings, all fixed:

  1. "Only Node built-ins are external" omitted pnpapi, which Rslib's nodeBuiltInModules list also externalizes (@rslib/core/dist/index.js composeTargetConfig). Now: "Rslib's node target leaves only Node built-ins (and pnpapi) external"; AB6005 accepts only isBuiltin names, which the text states.
  2. "The externals handling only polices the author's tools hatch" — enforceInvariants inspects the resolved config.externals (rslib.ts:598–607), which includes Rslib's built-in list. Now: "rejects reserved specifiers in the resolved externals, which come from the author's tools hatch and Rslib's built-in list, never from the profile."
  3. "A package a consumer must install is the author's tools hatch decision; AB7014/AB7015 judge it" understated AB7014's evidence kinds and AB7015's role. Now names hatch externals, packed declaration references, install scripts and (en) bin execution as evidence, AB7014 as the evidence check, AB7015 as the installability check.
  4. "Every build walks the emitted modules" — the package build's dist is not walked by validateArtifact (package-build.ts). Now: "every artifact build walks the compiled host-pack modules … the package build's dist is judged by the prepack gate instead"; the en/zh paragraph says dist output rather than dist/bin.

Pass 2 — four smaller findings, all fixed:

  1. "Plugin artifacts are self-contained" ignored opaque prebuilt payloads → "Generated plugin output is self-contained".
  2. AB6005 also accepts in-artifact relative/file: imports → "the only bare specifiers AB6005 accepts in a host-pack module are Node built-ins".
  3. Prebuilt modules are not walked → "compiled host-pack modules/bytes".
  4. AB7015 is not purely registry resolvability (packed file: sources and bundleDependencies are exempt) → "a specifier a consumer's npm can install" / "one a consumer's npm cannot install".

Pass 3 — one finding, fixed: "the package build" in the en/zh surface list also covers the bundleless .d.ts graph (package-build.ts:29–32), so the list now says "the package build's JavaScript bundles". No other mismatches; zh confirmed a faithful translation of en.

@ScriptedAlchemy ScriptedAlchemy added the skip-changeset PR changes a publishable package but ships no observable change; changeset not required label Sep 5, 2026
@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9ba6927

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T01:05:20.649125Z 4d346ef PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ScriptedAlchemy
ScriptedAlchemy enabled auto-merge (squash) September 5, 2026 01:02
@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@573
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@573
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/rsc-markdown-stream@573
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@573

commit: 9ba6927

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d346efda7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +197 to +201
entry is therefore only for what the packed files demonstrably need from outside a compiled bundle
— a package a packed module still imports because the author kept it external through the
[`tools` hatch](../../reference/configuration.mdx#tools) (possible in the package build's `dist`
output, which `AB6005` does not walk; a host-pack module with that import fails the build), one a
consumer-side install script runs, one whose `bin` a packed file executes, or one a packed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Account for dependencies imported by prebuilt payloads

When an opaque prebuilt MCP, hook, or payload module imports a package such as express, that dependency is valid even though it was not externalized through the tools hatch: validateGeneratedFiles exempts prebuilt paths from AB6005, while packInventoryDiagnostics scans every packed JavaScript file and lets that import satisfy AB7014. This exhaustive list omits that supported case and may lead authors to move a required runtime package to devDependencies; include dependencies imported by prebuilt payloads here and in the mirrored Chinese paragraph.

AGENTS.md reference: AGENTS.md:L108-L111

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Agreed — prebuilt payload imports are valid AB7014 evidence (prebuiltPaths exempt them from AB6005; pack-dependencies.ts scans every packed JS file). Fixed in the en and zh paragraphs in #574.

@ScriptedAlchemy
ScriptedAlchemy merged commit ba558a8 into main Sep 5, 2026
14 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the docs/self-contained-plugin-output branch September 5, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changeset PR changes a publishable package but ships no observable change; changeset not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant