Skip to content

Add plugin authoring best-practices section and ref docs#621

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/add-plugin-authoring-section
Open

Add plugin authoring best-practices section and ref docs#621
Copilot wants to merge 2 commits into
mainfrom
copilot/add-plugin-authoring-section

Conversation

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor
  • Review current plugins guide and plugin-lib API surface
  • Understand type signatures: RootDecoratorDef, ItemDecoratorDef, ResolverDef, EnvGraphDataTypeDef, VarlockPlugin metadata, error classes
  • Delete reference/plugin-api/ folder (5 individual pages removed)
  • Create reference/plugin-api.mdx — single page in the style of root-decorators / functions reference pages
  • Update astro.config.ts sidebar to add one "Plugin API" entry under Reference
  • Run parallel_validation

@changeset-bot

changeset-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: caaadfb

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 15, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
varlock-website 7640356 Commit Preview URL

Branch Preview URL
Jun 16 2026, 07:16 AM

@pkg-pr-new

pkg-pr-new Bot commented Apr 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@env-spec/parser@621
npm i https://pkg.pr.new/varlock@621

commit: 5f9dccb

@philmillman philmillman changed the title Add plugin authoring best-practices section to plugins guide Add plugin authoring best-practices section and ref docs Apr 15, 2026

@selfire1 selfire1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the docs! It comes in handy as we're looking to build a custom internal plugin.

I started following the WIP docs. When using strict: true, I got a few errors that I needed to resolve with !.

This might not be the most elegant solution, but I just wanted to put on your radar that the examples require some coercion or checks.

Comment on lines +189 to +194
async execute({ id, tokenResolver }) {
// Await dynamic values (these may reference other schema items)
const token = await tokenResolver?.resolve();
instances[id].token = token ? String(token) : undefined;
},
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
async execute({ id, tokenResolver }) {
// Await dynamic values (these may reference other schema items)
const token = await tokenResolver?.resolve();
instances[id].token = token ? String(token) : undefined;
},
});
async execute({ id, tokenResolver }) {
// Await dynamic values (these may reference other schema items)
const token = await tokenResolver?.resolve();
instances[id]!.token = token ? String(token) : undefined;
}

Comment on lines +240 to +253
process() {
let instanceId = '_default';
let refResolver: Resolver;

if (this.arrArgs!.length === 1) {
refResolver = this.arrArgs![0];
} else {
// first arg is the instance id – must be a literal
if (!this.arrArgs![0].isStatic) {
throw new SchemaError('Instance id must be a static value');
}
instanceId = String(this.arrArgs![0].staticValue);
refResolver = this.arrArgs![1];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
process() {
let instanceId = '_default';
let refResolver: Resolver;
if (this.arrArgs!.length === 1) {
refResolver = this.arrArgs![0];
} else {
// first arg is the instance id – must be a literal
if (!this.arrArgs![0].isStatic) {
throw new SchemaError('Instance id must be a static value');
}
instanceId = String(this.arrArgs![0].staticValue);
refResolver = this.arrArgs![1];
}
process() {
let instanceId = '_default';
let refResolver: Resolver;
if (this.arrArgs!.length === 1) {
refResolver = this.arrArgs![0]!;
} else {
// first arg is the instance id – must be a literal
if (!this.arrArgs![0]!.isStatic) {
throw new SchemaError('Instance id must be a static value');
}
instanceId = String(this.arrArgs![0]!.staticValue);
refResolver = this.arrArgs![1]!;
}
if (!instances[instanceId]) {
throw new SchemaError(
`No MyPlugin instance "${instanceId}" found`,
{ tip: 'Add @initMyPlugin() to your .env.schema file' },
);
}
return { instanceId, refResolver };
}

@philmillman

Copy link
Copy Markdown
Member

Thanks @selfire1, we'll revisit and get something merged this week.

Adds a plugin authoring best-practices section (design conventions,
scaffolding, the four register* primitives, caching, error handling,
packaging, testing) to the plugins guide, plus a Plugin API reference
page documenting varlock/plugin-lib. Also notes the labeler.yaml step
for new monorepo plugins in AGENTS.md.
@theoephraim theoephraim force-pushed the copilot/add-plugin-authoring-section branch from 5f9dccb to 371eedb Compare June 16, 2026 07:05
The consumer plugins guide (guides/plugins) is now install/scope/init/use
only. The authoring how-to lives at plugins/authoring (Plugins sidebar
group, after Overview); the Plugin API reference stays under Reference.
Cross-linked from the overview, consumer guide, and reference page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants