Skip to content

feat(lsp): add cannonfile fragment schema and include field#1857

Merged
dbeal-eth merged 3 commits intousecannon:devfrom
saturn-dbeal:feat/lsp-schema-fragment
Mar 7, 2026
Merged

feat(lsp): add cannonfile fragment schema and include field#1857
dbeal-eth merged 3 commits intousecannon:devfrom
saturn-dbeal:feat/lsp-schema-fragment

Conversation

@saturn-dbeal
Copy link
Contributor

Summary

This PR adds support for cannonfile fragments - TOML files that are meant to be included from a main cannonfile and don't require top-level metadata like name and version.

Changes

1. Add include field to chainDefinitionSchema

include = [
    "tomls/settings.toml",
    "tomls/core.toml",
    "tomls/permissions.toml"
]

This field was already parsed by the CLI but was missing from the schema, causing IDE warnings.

2. Add cannonfileFragmentSchema

A new schema for included fragments that omits:

  • name (required for publishing)
  • version (required for publishing)
  • preset (optional in both)
  • include (only main cannonfile should include)
  • privateSourceCode (only main cannonfile should define)
  • description (only main cannonfile should define)
  • keywords (only main cannonfile should define)
  • deployers (only main cannonfile should define)

Fragments can contain all the same actions: deploy, invoke, clone, pull, var, router, diamond, etc.

3. Generate both schemas

  • schema.json - Full cannonfile schema
  • schema-fragment.json - Fragment schema for included files

Usage

IDEs/LSPs can now provide proper validation for:

  • Full cannonfiles: Must have name and version, can have include
  • Fragment files: Only actions, no metadata required

Example Fragment (tomls/core.toml)

[var.system_config]
core_package = "my-protocol-core:1.0.0"

[deploy.Core]
artifact = "Core"
args = ["<%= settings.owner %>"]

This fragment can be included from a main cannonfile without causing validation errors about missing name/version.


Draft PR - ready for review.

@saturn-dbeal
Copy link
Contributor Author

Updated to also include the include field in the fragment schema, so fragments can include other fragments.

@dbeal-eth dbeal-eth marked this pull request as ready for review March 1, 2026 16:21
@dbeal-eth dbeal-eth enabled auto-merge (squash) March 1, 2026 16:22
@dbeal-eth dbeal-eth disabled auto-merge March 1, 2026 16:22
@saturn-dbeal
Copy link
Contributor Author

Good call — extracted the shared actions into cannonfileActionsSchema and both the full schema and fragment schema now compose from it. ~76 lines removed.

@saturn-dbeal
Copy link
Contributor Author

Addressed review feedback: deduplicated the schemas by extracting a shared cannonfileActionsSchema that both the full schema and fragment schema extend from. No more code duplication.

@saturn-dbeal
Copy link
Contributor Author

Inline review comment addressed in 66411d0 — deduplicated the fragment and full schemas so the full schema extends the fragment.

Ready for re-review @dbeal-eth

@saturn-dbeal saturn-dbeal requested a review from dbeal-eth March 2, 2026 09:31
Add support for cannonfile fragments - TOML files that are meant to be
included from a main cannonfile and don't require top-level metadata.

Changes:
- Add 'include' field to chainDefinitionSchema for importing other TOML files
- Add cannonfileFragmentSchema for included fragments (no name/version required)
- Update generateSchema.js to generate both schema.json and schema-fragment.json
- Fragment schema omits: name, version, preset, include, privateSourceCode,
  description, keywords, deployers

This allows IDEs to provide proper validation for both:
- Full cannonfiles (with name, version, etc.)
- Fragment files (included TOMLs with only actions)
Extract shared action definitions into cannonfileActionsSchema and
reuse it in both chainDefinitionSchema and cannonfileFragmentSchema
to eliminate code duplication.
@saturn-dbeal saturn-dbeal force-pushed the feat/lsp-schema-fragment branch from 656e683 to b774417 Compare March 6, 2026 21:09
@dbeal-eth
Copy link
Contributor

tests will not pass due to PR being contributed from external, so merging with bypassed rues.

@dbeal-eth dbeal-eth merged commit a735b85 into usecannon:dev Mar 7, 2026
4 of 7 checks passed
saturn-dbeal added a commit that referenced this pull request Mar 8, 2026
Release includes:
- feat(website): add pagination feature (#1826)
- feat(lsp): add cannonfile fragment schema and include field (#1857)
- feat(cli): add --ipfs-superfluous flag to clean command (#1854)
- feat(cli): sourcify verification (#1850)
- feat(builder): create2 option support for router step (#1839)
- fix(cli): prevent spinner output corruption (#1858)
- fix(cli): viair does not work properly with cannon verify (#1847)
- fix(cli): cleanup pitfalls and improve overall fetch UX (#1835)
- fix(builder): prevent flaky/inconsistent rpcs from failing the build (#1848)
- fix(builder): early return from computeTemplateAccesses (#1846)
- fix(builder): deploy importExisting was not properly handling create2 contracts (#1853)
- fix: bugs in package caching process (#1859)
- Fix Select Safe dialog overflow (#1852)
@saturn-dbeal saturn-dbeal mentioned this pull request Mar 8, 2026
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