Skip to content

refactor(devframe)!: add cac adapter (createCac) as an optional peer dependency; deprecate the cli alias#96

Merged
antfu merged 2 commits into
mainfrom
green-hotels-agree
Jul 15, 2026
Merged

refactor(devframe)!: add cac adapter (createCac) as an optional peer dependency; deprecate the cli alias#96
antfu merged 2 commits into
mainfrom
green-hotels-agree

Conversation

@antfubot

@antfubot antfubot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What

Two related changes to how the cac-powered CLI adapter is packaged:

  1. cac is now an optional peer dependency of devframe instead of a hard dependency, so consumers opt into it — or bring their own CLI framework without ever pulling cac. This mirrors the existing treatment of @modelcontextprotocol/sdk: the dependency is only reached through its adapter entry, so tools that assemble their own shell from createDevServer / createBuild / createMcpServer run without it.

  2. The adapter is renamed to cac. The canonical entry is now devframe/adapters/cac exposing createCac (with CacHandle / CreateCacOptions). The historical devframe/adapters/cli entry (createCli / CliHandle / CreateCliOptions) remains as a deprecated alias that re-exports the cac module, to be removed in a future major.

Details

  • devframe: cac moved from dependencies to peerDependencies (^7.0.0) + peerDependenciesMeta.cac.optional; kept as a devDependency for the workspace build.
  • src/adapters/cac.ts is the implementation; src/adapters/cli.ts is a thin deprecated shim.
  • The typed-flag helpers (defineCliFlags / parseCliFlags) stay co-located on the CLI adapter — re-exported from devframe/adapters/cac (and the deprecated devframe/adapters/cli) rather than a separate module.
  • Consumers of the adapter now declare cac themselves: plugins git, a11y, inspect, messages, terminals, code-server; examples files-inspector, next-runtime-snapshot, streaming-chat — all migrated to createCac.
  • alias.ts (the source of truth that regenerates tsconfig.base.json paths) gains the devframe/adapters/cac alias.
  • Docs, skill, and tsnapi API snapshots updated; the adapters/cli docs page becomes adapters/cac.

Why not make createCac async

cac@7 is ESM-only, so a graceful in-function require isn't possible; deferring it via dynamic import would force createCac to become async and break every call site. The chosen approach keeps it synchronous while achieving the opt-in goal, matching the repo's established optional-peer pattern (importing the adapter entry without cac throws the usual Node module-not-found error).

Verification

pnpm build, pnpm typecheck, pnpm lint, and pnpm test (653 passing) all green.

Note

Marked ! (breaking): cac must now be installed explicitly by anyone using the adapter, and new code should import createCac from devframe/adapters/cac.

PR created with the help of an agent.

…adapter

cac is now an optional peer dependency, pulled in only through the
devframe/adapters/cli entry. Tools that assemble their own command-line
shell from the createDevServer / createBuild / createMcpServer factories
run without installing cac.

A new cac-free devframe/adapters/flags entry exposes the typed-flag
helpers (defineCliFlags / parseCliFlags) so bring-your-own-CLI tools get
flag validation without depending on cac. The helpers stay re-exported
from adapters/cli for back-compat.

Plugins and examples that ship a createCli-backed binary now declare cac
directly.

PR created with the help of an agent.
@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit e7aa167
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a5744979c2fef00084266cd
😎 Deploy Preview https://deploy-preview-96--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

…cate createCli

The cac-based CLI adapter is now canonically devframe/adapters/cac with
createCac / CacHandle / CreateCacOptions. The historical
devframe/adapters/cli entry keeps working as a deprecated alias
(createCli / CliHandle / CreateCliOptions re-export the cac module),
to be removed in a future major.

The typed-flag helpers (defineCliFlags / parseCliFlags) stay co-located
on the CLI adapter (re-exported from devframe/adapters/cac and the
deprecated devframe/adapters/cli) rather than a separate entry.

Internal plugins, examples, docs, and the skill migrate to createCac.

PR created with the help of an agent.
@antfubot antfubot changed the title refactor(devframe)!: make cac an optional peer dependency of the cli adapter refactor(devframe)!: add cac adapter (createCac) as an optional peer dependency; deprecate the cli alias Jul 15, 2026
@antfu antfu merged commit df3cefd into main Jul 15, 2026
12 checks passed
@antfu antfu deleted the green-hotels-agree branch July 15, 2026 08:40
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.

2 participants