Skip to content

Run the CLI on the embedded API (one orchestration layer)#18

Merged
DanMat merged 1 commit into
mainfrom
refactor/cli-on-embedded
Jul 26, 2026
Merged

Run the CLI on the embedded API (one orchestration layer)#18
DanMat merged 1 commit into
mainfrom
refactor/cli-on-embedded

Conversation

@DanMat

@DanMat DanMat commented Jul 26, 2026

Copy link
Copy Markdown
Owner

The flagship follow-up from the 3.0 approval review: "make the CLI consume the embedded API… everything else becomes adapters."

Before this, the CLI was the one surface not sharing the embedded pipeline — it called the core's generate directly and wrote with its own writer, so its diagnostics, collision handling, and path safety could drift from what host apps, and even the CLI's own MCP sibling, get.

What changed

Generation and resolution are split so the CLI can keep doing its pre-generation work (Node-floor check, remote resolution) on the resolved config:

  • resolveProjectConfig(input) (new, public) — resolves preset + overrides, returns { config, diagnostics } without generating.
  • createProjectFromResolvedConfig(config, { diagnostics }) (new, public) — builds the project from that config after the CLI has set fields like repo, carrying the resolution diagnostics through.
  • The CLI writes through writeGeneratedProject instead of its own writeProject; --merge maps to the skip collision policy.

The side effects the embedded API deliberately never performs — git init, install, creating the remote — stay in the CLI adapter, untouched.

Behavior preserved — verified, not assumed

Path Result
ts-lib -y file set exact parity (31/31, none missing/extra)
--merge into a non-empty dir keeps existing, "Kept 1 existing file", 30 written
non-empty dir, no --merge still aborts with the same message
--git-remote git init + lockfile + push, 2 commits, all fire
install runs; project builds green

And a genuine improvement falls out of the unification: the CLI now surfaces coercion warnings it used to swallow — e.g. ⚠ Storybook was disabled because it only applies to a component library.

Also in here

  • ARCHITECTURE.md — the six layering principles from the review, written down as rules.
  • Removed a dead reactEntry() reference in meta.js (unreachable: libraryEntry only runs for non-framework libraries). A --checkJs pass surfaced it — which is the kind of thing the next follow-up (self-enforcement) will catch automatically.

87 tests pass (2 new covering the two-phase entry points and that a post-resolution repo still bakes in). Web configurator and MCP verified unchanged.

🤖 Generated with Claude Code

The flagship follow-up from the 3.0 approval review. The CLI generated
files by calling the core directly and writing with its own writer, so it
was the one surface not sharing the embedded pipeline's diagnostics,
collision handling, and path safety.

It now resolves and generates through the embedded API:
- resolveProjectConfig (new) resolves preset + overrides and returns the
  config plus normalization diagnostics WITHOUT generating, so the CLI can
  still do its Node-floor check and remote resolution on the resolved
  config before generating.
- createProjectFromResolvedConfig (new) builds the project from that
  config (after the CLI sets things like repo), carrying the diagnostics.
- writeGeneratedProject replaces the CLI's direct writeProject; --merge
  maps to the 'skip' collision policy.

The side effects the embedded API deliberately never performs — git init,
install, creating the remote — stay in the CLI adapter, unchanged.

Behavior verified identical: exact file parity on ts-lib; --merge keeps
existing files and reports them; the non-empty abort still fires; the
--git-remote path still inits git, writes the lockfile, and pushes; and
install still runs and the project builds. The CLI additionally now
surfaces coercion warnings it previously swallowed (e.g. "Storybook was
disabled because it only applies to a component library").

Also: removed a dead reactEntry() reference in meta.js (unreachable —
libraryEntry only runs for non-framework libraries; a --checkJs pass
surfaced it), and wrote ARCHITECTURE.md codifying the six layering
principles from the review.

87 tests pass (2 new for the two-phase entry points); CLI, web, MCP all
verified unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DanMat
DanMat merged commit f2e7d6d into main Jul 26, 2026
36 checks passed
@DanMat
DanMat deleted the refactor/cli-on-embedded branch July 26, 2026 19:04
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.

1 participant