-
Notifications
You must be signed in to change notification settings - Fork 61
add: cli foundation #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
0x76agabond
wants to merge
3
commits into
Perfect-Abstractions:cli
Choose a base branch
from
0x76agabond:cli
base: cli
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add: cli foundation #349
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| node_modules/ | ||
| dist/ | ||
| my-diamond/ | ||
| spec/ | ||
| skills/ | ||
| *.tsbuildinfo | ||
| .vscode/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Compose CLI Project Template | ||
|
|
||
| This directory is the current Compose CLI implementation template. It is a Node.js/TypeScript CLI that scaffolds a Diamond-based Foundry project from Compose-owned metadata under `bases/`. | ||
|
|
||
| ## Current Behavior | ||
|
|
||
| - `compose` with no command prints help. | ||
| - `compose init` starts the interactive init flow. | ||
| - Interactive init asks for framework, base, Compose library facets, extension facets, and local example facets. | ||
| - Foundry init validates selected facets before writing files. | ||
| - Generated Foundry files are written into the current Foundry project when `foundry.toml` exists, otherwise into `my-diamond/`. | ||
| - `compose validate` and `compose inspect` are routed placeholders only. | ||
|
|
||
| ## Commands | ||
|
|
||
| From this directory: | ||
|
|
||
| ```sh | ||
| npm install | ||
| npm run build | ||
| node dist/index.js | ||
| node dist/index.js init | ||
| ``` | ||
|
|
||
| For development: | ||
|
|
||
| ```sh | ||
| npm run dev -- init | ||
| ``` | ||
|
|
||
| ## Structure | ||
|
|
||
| - `bases/`: Compose-owned metadata for standards, diamond facets, library facets, and local examples. | ||
| - `src/index.ts`: CLI entrypoint. | ||
| - `src/context`: Shared context types and factory. | ||
| - `src/pipelines`: Top-level and command pipelines. | ||
| - `src/modules`: Feature logic for entry UI, config loading, validation, scaffolding, routing, and Foundry project detection. | ||
| - `src/adapters`: External library adapters, currently hashing through `viem`. | ||
| - `src/resolver`: Dependency keys, registry, and resolver. | ||
| - `src/utils`: Generic reusable helpers for files, regex, terminal output, and Solidity text parsing. | ||
| - `src/templates`: Solidity template assets copied into generated projects. | ||
| - `spec/`: M1 design notes and architecture documentation. | ||
| - `skills/`: Local Codex architecture skill used while developing this template. | ||
|
|
||
| ## Metadata | ||
|
|
||
| `bases/` is the source of truth for interactive init options. | ||
|
|
||
| - `diamond.json`: Diamond facets. | ||
| - `libraries.json`: Compose library facets. | ||
| - `examples.json`: Local example facets used for validation testing. | ||
| - Other JSON files define selectable bases such as ERC-20, ERC-721, ERC-1155, ERC-6909, AccessControl, and Owner. | ||
|
|
||
| Each base has: | ||
|
|
||
| - `required`: Facets always included for that base. | ||
| - `optional`: Extension facets shown after the base is selected. | ||
|
|
||
| ## Validation | ||
|
|
||
| Foundry init currently validates: | ||
|
|
||
| - Selector exports: every selected facet must export all intended external/public functions. | ||
| - Selector collisions: selected facets must not introduce duplicate function selectors. | ||
| - Identifier collisions: selected facets must not use incompatible storage layouts for the same storage identifier. | ||
|
|
||
| Validation is fail-fast. `EntryModule.showReport` prints the error report and stops the flow before scaffolding continues. | ||
|
|
||
| ## Generated Output | ||
|
|
||
| Generated files are organized by meaning: | ||
|
|
||
| ```txt | ||
| src/ | ||
| diamond/ | ||
| libraries/ | ||
| facets/ | ||
| ``` | ||
|
|
||
| The CLI also writes a generated `compose.json` into the target project. `compose.lock` is not part of the current M1 implementation. | ||
|
|
||
| ## Local Artifacts | ||
|
|
||
| The local `.gitignore` excludes generated or machine-local files: | ||
|
|
||
| ```gitignore | ||
| node_modules/ | ||
| dist/ | ||
| my-diamond/ | ||
| *.tsbuildinfo | ||
| .vscode/ | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| { | ||
| "access-control": { | ||
| "label": "AccessControl", | ||
| "required": { | ||
| "AccessControlDataFacet": { | ||
| "path": "./src/templates/access/AccessControl/Data/AccessControlDataFacet.sol" | ||
| }, | ||
| "AccessControlGrantFacet": { | ||
| "path": "./src/templates/access/AccessControl/Grant/AccessControlGrantFacet.sol" | ||
| }, | ||
| "AccessControlRevokeFacet": { | ||
| "path": "./src/templates/access/AccessControl/Revoke/AccessControlRevokeFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "AccessControlAdminFacet": { | ||
| "path": "./src/templates/access/AccessControl/Admin/AccessControlAdminFacet.sol" | ||
| }, | ||
| "AccessControlGrantBatchFacet": { | ||
| "path": "./src/templates/access/AccessControl/Batch/Grant/AccessControlGrantBatchFacet.sol" | ||
| }, | ||
| "AccessControlRevokeBatchFacet": { | ||
| "path": "./src/templates/access/AccessControl/Batch/Revoke/AccessControlRevokeBatchFacet.sol" | ||
| }, | ||
| "AccessControlPausableFacet": { | ||
| "path": "./src/templates/access/AccessControl/Pausable/AccessControlPausableFacet.sol" | ||
| }, | ||
| "AccessControlRenounceFacet": { | ||
| "path": "./src/templates/access/AccessControl/Renounce/AccessControlRenounceFacet.sol" | ||
| }, | ||
| "AccessControlTemporalDataFacet": { | ||
| "path": "./src/templates/access/AccessControl/Temporal/Data/AccessControlTemporalDataFacet.sol" | ||
| }, | ||
| "AccessControlTemporalGrantFacet": { | ||
| "path": "./src/templates/access/AccessControl/Temporal/Grant/AccessControlTemporalGrantFacet.sol" | ||
| }, | ||
| "AccessControlTemporalRevokeFacet": { | ||
| "path": "./src/templates/access/AccessControl/Temporal/Revoke/AccessControlTemporalRevokeFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "diamond": { | ||
| "label": "Diamond", | ||
| "required": { | ||
| "DiamondInspectFacet": { | ||
| "path": "./src/templates/diamond/DiamondInspectFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "DiamondUpgradeFacet": { | ||
| "path": "./src/templates/diamond/DiamondUpgradeFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "erc-1155": { | ||
| "label": "ERC-1155", | ||
| "required": { | ||
| "ERC1155DataFacet": { | ||
| "path": "./src/templates/token/ERC1155/Data/ERC1155DataFacet.sol" | ||
| }, | ||
| "ERC1155ApproveFacet": { | ||
| "path": "./src/templates/token/ERC1155/Approve/ERC1155ApproveFacet.sol" | ||
| }, | ||
| "ERC1155TransferFacet": { | ||
| "path": "./src/templates/token/ERC1155/Transfer/ERC1155TransferFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "ERC1155BurnFacet": { | ||
| "path": "./src/templates/token/ERC1155/Burn/ERC1155BurnFacet.sol" | ||
| }, | ||
| "ERC1155MetadataFacet": { | ||
| "path": "./src/templates/token/ERC1155/Metadata/ERC1155MetadataFacet.sol" | ||
| }, | ||
| "RoyaltyFacet": { | ||
| "path": "./src/templates/token/Royalty/RoyaltyFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "erc-20": { | ||
| "label": "ERC-20", | ||
| "required": { | ||
| "ERC20DataFacet": { | ||
| "path": "./src/templates/token/ERC20/Data/ERC20DataFacet.sol" | ||
| }, | ||
| "ERC20ApproveFacet": { | ||
| "path": "./src/templates/token/ERC20/Approve/ERC20ApproveFacet.sol" | ||
| }, | ||
| "ERC20TransferFacet": { | ||
| "path": "./src/templates/token/ERC20/Transfer/ERC20TransferFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "ERC20BurnFacet": { | ||
| "path": "./src/templates/token/ERC20/Burn/ERC20BurnFacet.sol" | ||
| }, | ||
| "ERC20MetadataFacet": { | ||
| "path": "./src/templates/token/ERC20/Metadata/ERC20MetadataFacet.sol" | ||
| }, | ||
| "ERC20PermitFacet": { | ||
| "path": "./src/templates/token/ERC20/Permit/ERC20PermitFacet.sol" | ||
| }, | ||
| "ERC20BridgeableFacet": { | ||
| "path": "./src/templates/token/ERC20/Bridgeable/ERC20BridgeableFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "erc-6909": { | ||
| "label": "ERC-6909", | ||
| "required": { | ||
| "ERC6909DataFacet": { | ||
| "path": "./src/templates/token/ERC6909/Data/ERC6909DataFacet.sol" | ||
| }, | ||
| "ERC6909TransferFacet": { | ||
| "path": "./src/templates/token/ERC6909/Transfer/ERC6909TransferFacet.sol" | ||
| }, | ||
| "ERC6909ApproveFacet": { | ||
| "path": "./src/templates/token/ERC6909/Approve/ERC6909ApproveFacet.sol" | ||
| }, | ||
| "ERC6909OperatorFacet": { | ||
| "path": "./src/templates/token/ERC6909/Operator/ERC6909OperatorFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "ERC6909BurnFacet": { | ||
| "path": "./src/templates/token/ERC6909/Burn/ERC6909BurnFacet.sol" | ||
| }, | ||
| "RoyaltyFacet": { | ||
| "path": "./src/templates/token/Royalty/RoyaltyFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| { | ||
| "erc-721": { | ||
| "label": "ERC-721", | ||
| "required": { | ||
| "ERC721ApproveFacet": { | ||
| "path": "./src/templates/token/ERC721/Approve/ERC721ApproveFacet.sol" | ||
| }, | ||
| "ERC721DataFacet": { | ||
| "path": "./src/templates/token/ERC721/Data/ERC721DataFacet.sol" | ||
| }, | ||
| "ERC721TransferFacet": { | ||
| "path": "./src/templates/token/ERC721/Transfer/ERC721TransferFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "ERC721BurnFacet": { | ||
| "path": "./src/templates/token/ERC721/Burn/ERC721BurnFacet.sol" | ||
| }, | ||
| "ERC721MetadataFacet": { | ||
| "path": "./src/templates/token/ERC721/Metadata/ERC721MetadataFacet.sol" | ||
| }, | ||
| "RoyaltyFacet": { | ||
| "path": "./src/templates/token/Royalty/RoyaltyFacet.sol" | ||
| } | ||
| } | ||
| }, | ||
| "erc-721-enumerable": { | ||
| "label": "ERC-721 Enumerable", | ||
| "required": { | ||
| "ERC721ApproveFacet": { | ||
| "path": "./src/templates/token/ERC721/Approve/ERC721ApproveFacet.sol" | ||
| }, | ||
| "ERC721DataFacet": { | ||
| "path": "./src/templates/token/ERC721/Data/ERC721DataFacet.sol" | ||
| }, | ||
| "ERC721EnumerableDataFacet": { | ||
| "path": "./src/templates/token/ERC721/Enumerable/Data/ERC721EnumerableDataFacet.sol" | ||
| }, | ||
| "ERC721EnumerableTransferFacet": { | ||
| "path": "./src/templates/token/ERC721/Enumerable/Transfer/ERC721EnumerableTransferFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "ERC721EnumerableBurnFacet": { | ||
| "path": "./src/templates/token/ERC721/Enumerable/Burn/ERC721EnumerableBurnFacet.sol" | ||
| }, | ||
| "ERC721MetadataFacet": { | ||
| "path": "./src/templates/token/ERC721/Metadata/ERC721MetadataFacet.sol" | ||
| }, | ||
| "RoyaltyFacet": { | ||
| "path": "./src/templates/token/Royalty/RoyaltyFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "examples": { | ||
| "label": "Local Examples", | ||
| "required": {}, | ||
| "optional": { | ||
| "ERC20MissingExportSelector": { | ||
| "path": "./src/templates/examples/ERC20MissingExportSelector.sol" | ||
| }, | ||
| "ERC20SelectorCollisionError": { | ||
| "path": "./src/templates/examples/ERC20SelectorCollisionError.sol" | ||
| }, | ||
| "ERC20IdentifierCollisionError": { | ||
| "path": "./src/templates/examples/ERC20IdentifierCollisionError.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "libraries": { | ||
| "label": "Libraries", | ||
| "required": {}, | ||
| "optional": { | ||
| "ERC165Facet": { | ||
| "path": "./src/templates/interfaceDetection/ERC165/ERC165Facet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "owner": { | ||
| "label": "Owner", | ||
| "required": { | ||
| "OwnerDataFacet": { | ||
| "path": "./src/templates/access/Owner/Data/OwnerDataFacet.sol" | ||
| }, | ||
| "OwnerTransferFacet": { | ||
| "path": "./src/templates/access/Owner/Transfer/OwnerTransferFacet.sol" | ||
| } | ||
| }, | ||
| "optional": { | ||
| "OwnerRenounceFacet": { | ||
| "path": "./src/templates/access/Owner/Renounce/OwnerRenounceFacet.sol" | ||
| }, | ||
| "OwnerTwoStepDataFacet": { | ||
| "path": "./src/templates/access/Owner/TwoSteps/Data/OwnerTwoStepDataFacet.sol" | ||
| }, | ||
| "OwnerTwoStepTransferFacet": { | ||
| "path": "./src/templates/access/Owner/TwoSteps/Transfer/OwnerTwoStepTransferFacet.sol" | ||
| }, | ||
| "OwnerTwoStepRenounceFacet": { | ||
| "path": "./src/templates/access/Owner/TwoSteps/Renounce/OwnerTwoStepRenounceFacet.sol" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the
composepackage. We will import from there.Only specific facets or modules could be there like a CounterFacet and error examples that won't be supported in the standard library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'm glad it helps.
I will move the spec and skills folders to the PRD repo, and update the code according to your review.