Skip to content

Refactor the core CLI architecture - #355

Merged
0x76agabond merged 11 commits into
Perfect-Abstractions:mainfrom
maxnorm:refactor/cli
Jul 16, 2026
Merged

Refactor the core CLI architecture#355
0x76agabond merged 11 commits into
Perfect-Abstractions:mainfrom
maxnorm:refactor/cli

Conversation

@maxnorm

@maxnorm maxnorm commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Rewrite the Compose CLI from JavaScript to TypeScript with a modular pipeline/context architecture.

Special thank you to our new maintainer @0x76agabond for his major contribution of helping design and build the new CLI version.

Changes Made

  • Rewrote CLI entrypoint and argument parsing: replaced minimist with commander, added positional [project-name] argument, per-command flags (--framework, --base, --ownership, --toolbox, --yes, etc.) (cli/src/comander.ts, cli/src/index.ts)

  • Introduced pipeline/context architecture: ComposeContext carries params, config, state, and status through typed pipelines (EntryPipeline, InitPipeline, InfoPipeline, CatalogPipeline). Each step returns the updated context (cli/src/context/types.ts, cli/src/pipelines/)

  • Added bases catalog: declarative JSON configs per standard (cli/bases/*.json: erc20, erc721, erc1155, erc6909, counter, owner, accesscontrol, diamond, libraries). Each base defines required and optional facets with paths, constructor calls, and ERC-165 registrations

  • Added catalog command: lists all available bases from the catalog

  • Added info command: scans compose.json, reads facet source files, and displays a tree-view of diamonds, facets, selectors, and storage slots (cli/src/modules/info/)

  • Added validation module: detects missing/extra selector exports, 4-byte selector collisions across facets, and incompatible storage layout identifier collisions (cli/src/modules/validation/)

  • Added Solidity source parsing: extracts contract bodies, functions, exported selector signatures, and diamond storage layouts from .sol files (cli/src/utils/solidityText.ts, cli/src/utils/soliditySources.ts)

  • Added framework adapters: IFrameworkAdapter interface with Foundry and Hardhat implementations for project init, config writing, and path resolution (cli/src/adapters/)

  • Added scaffolding module: copies facets with import closure resolution, writes compose.json, validates local facet files (cli/src/modules/scaffolding/)

  • Added diamond/deploy/test generation: auto-generates Diamond.sol, framework-specific deploy scripts, and test boilerplate (cli/src/modules/diamondGeneration/, deployGeneration/, testGeneration/)

  • Added dependency resolver: resolves hashing and framework adapters at runtime (cli/src/resolver/)

  • Converted to TypeScript: added tsconfig.json, builds to dist/, entry point is now bin/compose.js â�� dist/index.js. Removed old JS tests and build:templates script

  • Updated CI: cli.yml now runs TypeScript build, removed integration tests and Node 20 smoke test (unsupported by Hardhat 3), smoke tests now use --base counter instead of --template default

Checklist

Before submitting this PR, please ensure:

  • Code follows the Solidity feature ban - No inheritance, constructors, modifiers, public/private variables, external library functions, using for directives, or selfdestruct

  • Code follows Design Principles - Readable, uses diamond storage, favors composition over inheritance

  • Code matches the codebase style - Consistent formatting, documentation, and patterns (e.g. ERC20Facet.sol)

  • Code is formatted with forge fmt

  • Existing tests pass - Run tests to be sure existing tests pass.

  • New tests are optional - If you don't provide tests for new functionality or changes then please create a new issue so this can be assigned to someone.

  • All tests pass - Run forge test and ensure everything works

  • Documentation updated - If applicable, update relevant documentation

  • Changesets — If this PR changes publishable packages (src/, cli/), changeset-bot will comment if a release note might be needed. You can add one when convenient or defer to maintainers.

Make sure to follow the contributing guidelines.

Additional Notes

  • The old JS test suite (cli/test/) was removed as part of the rewrite. The new CLI has no unit tests yet â�� this should be tracked as follow-up work.
  • The cli/.gitmodules file was removed; the CLI no longer requires the forge-std submodule at build time.
  • cli/index.js is deleted; the new entry point is cli/bin/compose.js which loads dist/index.js.

@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c902b8b

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

@netlify

netlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

👷 Deploy request for compose-diamonds pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c902b8b

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Coverage

Metric Coverage Details
Lines 79% 1560/1983 lines
Functions 92% 445/484 functions
Branches 74% 161/217 branches

Last updated: Thu, 16 Jul 2026 13:28:40 GMT for commit c902b8b

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Gas Report

No gas usage changes detected between main and refactor/cli.

All functions maintain the same gas costs. ✅

Last updated: Thu, 16 Jul 2026 13:29:03 GMT for commit c902b8b

@maxnorm
maxnorm requested a review from 0x76agabond July 15, 2026 17:12
Comment thread cli/src/modules/config/module.ts Outdated
Comment thread cli/src/utils/codegen.ts Outdated
Comment thread cli/bases/diamond.json
@0x76agabond

Copy link
Copy Markdown
Collaborator

Overall, I think it looks great. Thank you for the refactor, it’s clean and makes sense.

@0x76agabond
0x76agabond merged commit b30a84c into Perfect-Abstractions:main Jul 16, 2026
9 checks passed
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