Skip to content

Add @varlock/alchemy-integration - #1228

Open
theoephraim wants to merge 15 commits into
mainfrom
alchemy-integration
Open

theoephraim wants to merge 15 commits into
mainfrom
alchemy-integration

Conversation

@theoephraim

@theoephraim theoephraim commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Adds @varlock/alchemy-integration, a secrets provider for Alchemy stacks (alchemy 2.0.0-beta.84+; the integration tracks the latest alchemy release rather than carrying compatibility notes for older betas).

const env = Varlock.Secrets<CoercedEnvSchema>({ bindingsFilter: "!#deploy" });

export default Alchemy.Stack("app",
  { providers: Cloudflare.providers(), state: Cloudflare.state(), secrets: env },
  Effect.gen(function* () {
    const api = yield* Cloudflare.Worker("api", { main: "./src/worker.ts", env: { ...(yield* env.bindings) } });
    return { url: api.url };
  }),
);
  • Varlock.Secrets() resolves one .env.schema before alchemy builds providers; Secrets({ services }) loads one schema per service for monorepos, with a root schema that feeds alchemy's Config (Cloudflare credentials) but is never bound into a Worker.
  • Values feed alchemy's Effect Config, so alchemy's own reads (including CLOUDFLARE_*) come from varlock. @internal items never reach alchemy.
  • env.bindings / env.bindingsFor(name) give typed Worker bindings: @sensitive items as Redacted (secret_text), the rest plain text or JSON, plus the __VARLOCK_ENV blob so @varlock/cloudflare-integration/init gives the Worker log redaction, leak detection and a typed ENV. bindingsFilter (--filter syntax, e.g. "!#deploy") keeps tagged items out of the Worker.
  • ALCHEMY_STACK, ALCHEMY_STAGE and ALCHEMY_DEV are visible to the schema while it resolves. The package ships a .env.schema fragment that derives ALCHEMY_ENV from them with if() and remap() (alchemy dev is development, production is production, other stages are preview), so @currentEnv=$ALCHEMY_ENV is plain schema logic users copy and adjust.
  • The provider contributes nothing during auth-provider discovery, so alchemy login works before any vault credential exists.

Core changes it rests on:

  • varlock/env-blob: buildEnvBlobBindings() / readEnvBlob(), the __VARLOCK_ENV wire format (optional chunking at a per-variable byte limit, optional encryption). varlock-wrangler, the Cloudflare Vite plugin and the Cloudflare init runtime now use it, so the writer and reader share one implementation.
  • filterSerializedGraphKeys() on the main entry applies a --filter expression to a serialized graph.
  • varlock load --format json-full lists @tag names as tags.

Docs: new integrations/alchemy page; the Cloudflare page's non-wrangler caution becomes a "Deploying with Alchemy" section (the zero-package varlock/auto-load path, which also works on older alchemy).

Verified against published alchemy 2.0.0-beta.84 (the release that split Cloudflare and the Doppler/Infisical providers into their own packages; the secrets provider contract is unchanged) in a Better-T-Stack scaffold (Astro + Hono on Workers, one schema per app): alchemy dev runs, Worker bindings and blob match the schemas, leak detection fires in workerd. A real deploy of that example is tracked in varlock-examples.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

minor Minor releases

  • @varlock/alchemy-integration 0.0.0 → 0.1.0
  • @varlock/cloudflare-integration 1.6.3 → 1.7.0
  • @varlock/native-helper-darwin 1.24.0 → 1.25.0
  • @varlock/native-helper-linux-arm64 1.24.0 → 1.25.0
  • @varlock/native-helper-linux-x64 1.24.0 → 1.25.0
  • @varlock/native-helper-win32-x64 1.24.0 → 1.25.0
  • varlock 1.24.0 → 1.25.0

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size

⚠️ grows the bundle by 29.4 KB (+0.6%)

Metric main This PR Δ
Total dist 5178.5 KB 5207.9 KB +29.4 KB (+0.6%)
JS 1977.1 KB 1984.7 KB +7.6 KB (+0.4%)
Sourcemaps 3064.3 KB 3079.6 KB +15.3 KB (+0.5%)
Type defs 137.1 KB 143.6 KB +6.5 KB (+4.7%)
Other 0.0 KB 0.0 KB —

dist/ only; native binaries are versioned separately and not counted here.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 14, 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 53f2ef9 Commit Preview URL

Branch Preview URL
Nov 03 2026, 07:33 PM

@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

varlock

npm i https://pkg.pr.new/varlock@1228

@varlock/alchemy-integration

npm i https://pkg.pr.new/@varlock/alchemy-integration@1228

@varlock/astro-integration

npm i https://pkg.pr.new/@varlock/astro-integration@1228

@varlock/cloudflare-integration

npm i https://pkg.pr.new/@varlock/cloudflare-integration@1228

@varlock/nuxt-integration

npm i https://pkg.pr.new/@varlock/nuxt-integration@1228

@varlock/vite-integration

npm i https://pkg.pr.new/@varlock/vite-integration@1228

@varlock/native-helper-darwin

npm i https://pkg.pr.new/@varlock/native-helper-darwin@1228

@varlock/native-helper-linux-arm64

npm i https://pkg.pr.new/@varlock/native-helper-linux-arm64@1228

@varlock/native-helper-linux-x64

npm i https://pkg.pr.new/@varlock/native-helper-linux-x64@1228

@varlock/native-helper-win32-x64

npm i https://pkg.pr.new/@varlock/native-helper-win32-x64@1228

@varlock/1password-plugin

npm i https://pkg.pr.new/@varlock/1password-plugin@1228

@varlock/bitwarden-plugin

npm i https://pkg.pr.new/@varlock/bitwarden-plugin@1228

@varlock/keepass-plugin

npm i https://pkg.pr.new/@varlock/keepass-plugin@1228

@varlock/pass-plugin

npm i https://pkg.pr.new/@varlock/pass-plugin@1228

@varlock/proton-pass-plugin

npm i https://pkg.pr.new/@varlock/proton-pass-plugin@1228

commit: 53f2ef9

@pullfrog pullfrog Bot 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.

Important

filter currently drops the intended configuration, and the binding types can make valid Worker code fail at runtime for composite values. Both should be addressed before merging.

Reviewed changes: Reviewed the Alchemy provider, shared blob refactor, serialized filtering, and deployment documentation; integration builds, Alchemy typechecking, 66 focused tests, and the website build passed.

  • Alchemy provider: Adds single-schema and multi-service providers, stage-aware resolution, Config precedence, binding filters, and runtime blob injection.
  • Shared blob transport: Centralizes chunking and encryption for Alchemy, Cloudflare Vite, Wrangler, and Worker initialization.
  • Serialized filtering: Exposes item tags in json-full and adds filtering over resolved graph metadata.
  • Documentation: Adds Alchemy setup and monorepo guidance and documents the auto-load deployment alternative.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes: Reviewed the changes since the prior review, including the provider API consolidation and both behavioral fixes. All 13 Alchemy integration tests, the package typecheck, and the integration build passed.

  • Renamed Provider API to Varlock.Secrets(), with overloads for single-schema and multi-service stacks, and updated examples.
  • Fixed CLI filtering by passing validated selectors without literal quotes, with regression coverage for key globs and negated tags.
  • Corrected Composite binding types to describe their string wire values while retaining numeric and boolean types, and documented the distinction from parsed ENV values.
  • Added Runtime opt-out guidance for validation and binding injection without the Worker runtime, plus clarification about the planned encrypted local state store.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog

pullfrog Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Pullfrog stalled

The agent stopped emitting events for 125s and was killed by the activity-timeout watchdog. The model produced no output at all before the stall — the request was sent but nothing came back. This is usually transient; re-running often succeeds.

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

Important

The new conditional hook example can select development configuration during a production deploy and should be corrected before merging.

Reviewed changes: Reviewed the new environment inference and related documentation since the previous substantive review. All 14 Alchemy integration tests, the package typecheck, and the integration build passed.

  • Added Environment inference through inferVarlockEnv(), supplying VARLOCK_ENV from Alchemy's stage and local-dev mode to single-schema and multi-service resolution.
  • Expanded Regression coverage for development, preview, production, staging, and explicit hook overrides.
  • Updated Integration guidance with the stage mapping, hook customization example, and Alchemy sidebar entry.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes: Reviewed 4176dcc..4c78207, including the environment opt-out and revised custom-stage examples. All 15 Alchemy integration tests, the package typecheck, the integration build, and the website build passed.

  • Added Environment opt-out with varlockEnv: false for single-schema and multi-service providers, leaving environment selection to ambient configuration or varlock's own detection.
  • Replaced Custom mapping examples with explicit APP_ENV mappings in the schema or environment hook, removing the unsafe undefined fallback.
  • Added Regression coverage for opting out of the Alchemy-derived environment.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes: Reviewed 4c78207..5e436be, focusing on the separation of Alchemy-derived environment selection from varlock's built-in detection. All 14 Alchemy integration tests, the package typecheck, the integration build, and the website build passed.

  • Replaced Environment injection with ALCHEMY_ENV and renamed the inference helper to inferAlchemyEnv(), leaving VARLOCK_ENV unchanged for single-schema and multi-service stacks.
  • Removed The environment opt-out because the provider no longer overrides varlock's own detection.
  • Updated Schemas and guidance to declare ALCHEMY_ENV, use it for @currentEnv, and demonstrate hook overrides, with matching regression coverage.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

Important

The environment example fails the documented plain varlock load workflow because its context variables remain required.

Reviewed changes: Reviewed 5e436be..44afe01, moving environment derivation from the provider into a shipped schema fragment. All 14 integration tests, the package typecheck, the integration build, and the website build passed.

  • Added Schema-based environment derivation with a packaged .env.schema fragment using if() and remap(), including a development fallback when no stage exists.
  • Removed Provider-side inference and direct ALCHEMY_ENV injection, retaining raw Alchemy context and hook overrides.
  • Updated Fixtures and guidance to derive ALCHEMY_ENV in the schema and describe copying and customizing the fragment.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

Important

No new issues found in this commit. The existing documentation finding about required Alchemy context variables remains unresolved, so approval is still pending.

Reviewed changes: Reviewed 44afe01..87788bf, validating the explicit regex conversion against varlock's resolver implementation and the shipped schema.

  • Replaced Stage-matching syntax with regex() in the packaged fragment, server fixture, and documentation, preserving exact production/staging aliases and the preview fallback.
  • Updated Customization examples to use regex("^pr-") and regex("^dev_").

All 14 integration tests, the package typecheck, and the integration build passed. Direct CLI checks also passed for stage aliases, local-dev precedence, unknown stages, and absent context in the shipped fragment.

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

Important

The updated Cloudflare imports require a separate package that the setup instructions do not install.

Reviewed changes: Reviewed 87788bf..e0d0b56, covering the environment example fix and compatibility updates for Alchemy beta.84. All 14 integration tests, the package typecheck, and the integration build passed; the copied schema also resolves development with plain varlock load.

  • Fixed Environment declarations by marking the Alchemy context optional/public while preserving defaults for application items.
  • Updated Dependency compatibility to test against Alchemy beta.84 and Effect 4.0.6.
  • Replaced Cloudflare imports in documentation and JSDoc with @alchemy.run/cloudflare, with an older-version note on the Alchemy page.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

A secrets provider for Alchemy stacks (alchemy 2.0.0-beta.80 or later):
varlock() resolves one .env.schema, varlockServices() one per service.
Resolved values feed the stack's Effect Config (so alchemy's own Cloudflare
credential reads come from varlock) and every schema item, or those passing a
bindingsFilter, is offered as a typed Worker binding: sensitive items as
Redacted (secret_text), the rest plain text or JSON, plus the __VARLOCK_ENV
blob so @varlock/cloudflare-integration/init boots the varlock runtime inside
the Worker. Alchemy's stack, stage and dev mode are exposed to the schema as
ALCHEMY_STACK / ALCHEMY_STAGE / ALCHEMY_DEV so @currentEnv can be derived with
remap(). The provider contributes nothing during auth-provider discovery.

Supporting core changes: varlock/env-blob exports buildEnvBlobBindings() and
readEnvBlob() (the __VARLOCK_ENV wire format, with optional chunking and
encryption), shared by varlock-wrangler, the Cloudflare Vite plugin and this
package; filterSerializedGraphKeys() applies a --filter expression to a
serialized graph; varlock load --format json-full lists @tag names as tags.
The Cloudflare integration's env-bindings export and init runtime are thin
wrappers over the core module.

Docs: new integrations/alchemy page; the Cloudflare page's non-wrangler
caution becomes a Deploying with Alchemy section.
…composite bindings as strings

- Secrets() replaces varlock() and varlockServices(): one name matching alchemy's
  Doppler.Secrets() / Infisical.Secrets() convention, with overloads keyed on the
  presence of `services`.
- The `filter` option was passed to the CLI JSON-quoted, which execFileSync handed
  through literally, so any filter selected nothing. The expression is now validated
  against the filter grammar and passed unquoted.
- Arrays and objects are bound as their process.env string form, and VarlockBindings
  now says so (BindingValue<T>), instead of promising the coerced type that only the
  blob carries.
The provider now sets varlock's built-in VARLOCK_ENV so @currentEnv=$VARLOCK_ENV
works with no mapping in the schema: alchemy dev is development, the
production/prod stage is production, staging and test map to themselves, and
every other stage (dev_<user>, pr-<n>) is preview. The env hook can override it.
The derived environment name now arrives as ALCHEMY_ENV (same vocabulary as
VARLOCK_ENV), so a schema opts in with @currentEnv=$ALCHEMY_ENV and varlock's own
VARLOCK_ENV detection is never touched. Drops the varlockEnv option.
…d of the integration

The integration now only exposes the raw ALCHEMY_STACK, ALCHEMY_STAGE and
ALCHEMY_DEV. The package ships a .env.schema fragment that declares them and
derives ALCHEMY_ENV with if() and remap(), so the stage mapping is ordinary schema
logic users copy (and later @import) and change like any other value.

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes: Reviewed the delta since e0d0b56, focusing on the Cloudflare package-split setup correction.

  • Added Cloudflare installation guidance for Alchemy beta.84+ using the existing package-manager widget.
  • Clarified Version compatibility by documenting matching package versions and the older alchemy/Cloudflare import in both integration guides.
  • Refreshed Generated workspace versions in the lockfile.

Verified the installation widget and published beta.84 package contract. Tests and the website build were not rerun for this small documentation correction.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot 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.

Important

Removing the historical version note also removed a required installation step from the standalone Cloudflare guide.

Reviewed changes: Reviewed the delta since 0ce9923, covering the minimum-version change and associated setup guidance. Verified the dependency contract against published beta.84 manifests; tests and the website build were not rerun for these manifest and prose changes.

  • Raised Alchemy minimum version to 2.0.0-beta.84 in the peer dependency, lockfile, README, and release description.
  • Simplified Compatibility guidance to track current Alchemy releases while retaining the matching Cloudflare package installation in the Alchemy setup.
  • Removed Historical import guidance from the standalone Cloudflare deployment section.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏


```ts title="alchemy.run.ts"
import "varlock/auto-load";
import * as Cloudflare from "@alchemy.run/cloudflare";

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.

[P2] Preserve the current Cloudflare package prerequisite

Deleting the parenthetical above also deletes this standalone guide's only instruction to install @alchemy.run/cloudflare at the same version as alchemy. Alchemy beta.84 does not supply that dependency, so readers who follow this zero-package path without the separate integration setup can hit Cannot find package '@alchemy.run/cloudflare'; retain the current installation prerequisite without restoring the historical-beta notes.

This branch has not been deployed

No deployments
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.

2 participants