refactor(cli): remove programmatic AST schema mutation in favor of init presets and doc snippets - #1736
Conversation
…it presets and doc snippets
|
Run failed. View the logs →
|
🦋 Changeset detectedLatest commit: af71c26 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
# Conflicts: # apps/www/content/docs/core-concepts/hosting-presets.mdx # apps/www/content/docs/reference/index.mdx # apps/www/content/docs/reference/init.mdx # apps/www/content/docs/reference/meta.json # apps/www/content/docs/reference/preset.mdx # packages/arkenv/src/bin.ts # packages/arkenv/src/cli/cli.ts # packages/arkenv/src/cli/commands/help.test.ts # packages/arkenv/src/cli/commands/help.ts # packages/arkenv/src/cli/composition.ts
@arkenv/agent-plugin
arkenv
@arkenv/build
@arkenv/bun-plugin
@arkenv/core
@arkenv/fumadocs-ui
@arkenv/nextjs
@arkenv/nuxt
@arkenv/standard
@arkenv/vite-plugin
commit: |
|
@pullfrog review please |
There was a problem hiding this comment.
Important
The CLI removal itself is clean and fully green, but several shipped surfaces still reference the removed arkenv preset command — the AI-agent guide, a Next-steps card on the check reference, and the installed arkenv skill. An agent following the guide will literally run a command that no longer exists. Details in the sections below.
Reviewed changes
- Removed the
arkenv presetcommand end-to-end:bin.ts/cli.ts/composition.ts/help.tsrouting,presetInput,--fileflag, and thefeatures/config-mutationAST +@arkenv-preset-start/endmarker engine (with its ~1,000-line test suite). - Relocated the three framework transformers (
transformViteConfig,transformNextjsConfig,transformNuxtConfig) intoadapters/node-workspace/utils/bootstrappers.tsbyte-for-byte, backed by a new, slimmerbootstrappers.test.ts. - Docs: deleted
reference/preset.mdx, rewrotecore-concepts/hosting-presets.mdxas per-validator copy-paste tabs, updated nav/index/cards, and added permanent redirects for/docs/reference/presetand/docs/reference/add-host. - Added a
majorchangeset forarkenv(command removal).
I verified the CLI package is green: built @repo/utils, @arkenv/core, @arkenv/standard, and the arkenv CLI, then ran the full packages/arkenv vitest suite — 397 tests pass, including the relocated bootstrappers.test.ts, the updated cli.test.ts (39) and help.test.ts, and the check/smoke suites. No behavioral diff between the deleted and relocated transformer implementations.
⚠️ Stale references to the removed preset surface remain
The PR swept preset out of index.mdx, init.mdx, meta.json, and preset.mdx, but four surfaces were missed:
apps/www/content/docs/reference/check.mdx:204— the "Next steps" Cards still render apresetcard titled "Apply, refresh, or remove hosting provider presets." that hrefs/docs/reference/preset(now a 404 → redirect).apps/www/content/docs/guides/ai.mdx:109— "Add the Vercel hosting preset withnpx arkenv preset apply vercel --agent..." — this is the guide AI agents are pointed to, and the command is gone.skills/arkenv/SKILL.md:37-38,41-64,111-133— the skill installed into user projects vianpx skills add yamcodes/arkenv(and detected byNodeProjectScannerAdapter.hasSkill()) still documentspreset apply/preset remove,--file, managed-block markers, and the.env.examplesync rules for a command this PR deletes.apps/www/lib/normalize-package-manager-command.test.ts:126-130— thepresetPromptfixture mirrors theai.mdxtext and will silently go stale with whatever replacement copy is chosen.
Technical details
# Remove stale `arkenv preset` references
## Affected sites
- apps/www/content/docs/reference/check.mdx:204 — `preset` Card href + description in Next steps
- apps/www/content/docs/guides/ai.mdx:109 — `npx arkenv preset apply vercel --agent` in the Hosting preset prompt
- skills/arkenv/SKILL.md:37-64, 111-133 — Managed Preset Blocks section + `preset apply`/`preset remove` command docs, `--file` option
- apps/www/lib/normalize-package-manager-command.test.ts:126-130 — fixture mirroring the ai.mdx prompt
## Required outcome
- No shipped docs/skill copy instructs the removed `preset` command. ai.mdx should route readers to the copy-paste snippets in `core-concepts/hosting-presets.mdx` (or `init --preset` for new projects); check.mdx's card should point there too; the skill should drop the preset-command and marker-management sections; the normalize fixture should track the replacement prompt text.
## Open questions for the human
- Does the installed skill ship verbatim from `skills/arkenv/SKILL.md`, or is there a build/copy step between repo and `npx skills add`?ℹ️ init --preset still scaffolds marker blocks that nothing manages
arkenv init --preset vercel still emits // @arkenv-preset-start vercel / // @arkenv-preset-end vercel via assemble-simple.ts:59-60 and frameworks/layouts/codegen.ts:255-257, but this PR deletes the only tooling that ever acted on those markers and strips the "Why comment markers exist" doc section. Users scaffolding with a preset now get unexplained machine-owned-sounding comments in their env.ts, and anyone copy-pasting from the new hosting-presets snippets gets a schema without them — two shapes of the same feature. The markers are inert comments, so this is mergeable as-is; it's a design call only the author can make.
ℹ️ Nitpicks
MutationInput.envImportPathis now accepted by all three transformers and used by none of them (Vite ignored it before too); it's a publicly exported field on the relocated module that reads as dead API.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Run failed. View the logs →
|
Addressed Code Review Feedback
|
There was a problem hiding this comment.
✅ No new issues found in the incremental delta. All prior feedback is addressed — the stale
presetreferences were swept fromai.mdx, thecheckreference card,SKILL.md, and the normalize fixture; the inert marker comments were removed frominit --presetscaffold output; transformer test coverage was restored; and the deadMutationInput.envImportPathfield was dropped. The delta's one real code change (an AST-leveldefineConfigcallback guard) was verified against magicast's proxy shape and is double-covered by the retained legacy guard.
Reviewed changes
- Removed
@arkenv-preset-start/endmarkers frominit --presetscaffold output inassemble-simple.tsandframeworks/layouts/codegen.ts, and deleted the marker helper functions fromscaffold/presets.ts, so scaffolding and the copy-paste docs produce the same marker-free schema shape. - Rerouted the AI-agent hosting-preset prompt (
guides/ai.mdx) and thecheckreference "Next steps" card to the copy-paste snippets in/docs/core-concepts/hosting-presets, replacing the removednpx arkenv preset apply vercel --agentinstruction. - Rewrote
skills/arkenv/SKILL.md's hosting-preset guidance as code-first, removingpreset apply/preset remove, the--fileoption, managed-block markers, and the.env.examplesync rules for the deleted command. - Replaced the
preset applyfixture innormalize-package-manager-command.test.tswith aninit --preset vercelprompt fixture (a command that still exists). - Restored dropped transformer coverage in
bootstrappers.test.ts(+175 lines): Vite space/tab indentation and trailing-newline preservation, defineConfig callback refusal, invalid-config and missing-default-export refusals, Next.js CommonJS refusal and inline-withArkEnvdedupe, plus Nuxt module-array creation and refusal paths. - Added an AST-level callback guard in
transformViteConfig(checks$ast.arguments[0].typeforArrowFunctionExpression/FunctionExpression) with the existing$args.$typeguard retained as a fallback.
One mergeable leftover worth a follow-up: apps/www/content/docs/guides/migrating-to-v1.mdx:23 still lists the v1 arkenv CLI as "(init, preset)" in the package-mapping table — stale now that this PR removes preset (and #1733 already dropped example); the cell should read something like "(init, check)".
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to v1, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `v1` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `v1`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## arkenv@1.0.0-alpha.20 ### Major Changes - #### Remove programmatic AST schema mutation and preset command _[`#1736`](#1736) [`e117bbd`](e117bbd) [@yamcodes](https://github.com/yamcodes)_ The `arkenv preset apply` and `arkenv preset remove` commands, along with programmatic AST and comment-marker schema mutation, have been removed from the CLI. Hosting presets (Vercel, Netlify, Cloudflare, Railway, Render, Fly.io) remain available during initial project scaffolding via `arkenv init --preset <name>` and are documented as copyable code snippets in the docs. **BREAKING CHANGE**: The `arkenv preset` command and `// @arkenv-preset-start` comment marker management have been removed. Use `arkenv init --preset <provider>` when scaffolding new projects, or copy provider variable definitions directly into `./env.ts` for existing schemas. Co-authored-by: arkenv-bot[bot] <237618717+arkenv-bot[bot]@users.noreply.github.com>

Fixes #1716
Summary
packages/arkenv/src/features/config-mutation/containing programmatic AST / comment-marker mutation logic.transformViteConfig,transformNextjsConfig,transformNuxtConfig) toadapters/node-workspace/utils/bootstrappers.tsand added unit tests inbootstrappers.test.ts.arkenv presetcommand and its subcommand routing frombin.ts,cli.ts, andcomposition.ts.arkenv init.reference/preset.mdx, updatedhosting-presets.mdxwith copy-paste snippets for ArkType, Zod, and Valibot, and added permanent redirects innext.config.ts.arkenv.