Skip to content

refactor: prepare for release#79

Merged
andrew-fleming merged 14 commits into
mainfrom
refactor/prepare-for-release
May 15, 2026
Merged

refactor: prepare for release#79
andrew-fleming merged 14 commits into
mainfrom
refactor/prepare-for-release

Conversation

@0xisk
Copy link
Copy Markdown
Member

@0xisk 0xisk commented May 12, 2026

Types of changes

What types of changes does your code introduce to OpenZeppelin Midnight Contracts? Put an `` in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Fixes #???

  • Split into 3 publishable packages: @openzeppelin/compact-builder (library), @openzeppelin/compact-cli (bins, depends on -builder), @openzeppelin/compact-simulator.
  • Refactored builder library into services/, types/options.ts, utils.ts.
  • New flags (CLI + BuilderOptions): --clean-dist, --exclude <glob> (drives both compiler discovery and builder copy), --copy <path>, --hierarchical now also drives .compact copy layout.
  • **Per-package ** (Keep-a-Changelog); follow-up TODO documented for migrating to changesets.
  • Docs: root + per-package READMEs rewritten; RELEASING.md updated with new dependency chain + first-release order.
  • CI: release.yml lists the three new package options; turbo types task now dependsOn: ["^build"].

PR Checklist

  • I have read the Contributing Guide
  • I have added tests that prove my fix is effective or that my feature works
  • I have added documentation of new methods and any new behavior or changes to existing behavior
  • CI Workflows Are Passing

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Summary by CodeRabbit

  • New Features

    • Introduced @openzeppelin/compact-builder package with programmatic compiler and build APIs.
    • Reorganized monorepo: CLI now a lightweight wrapper around builder package.
  • Documentation

    • Updated installation instructions and examples for renamed packages.
    • Added release procedures and monorepo development guidance.
    • Updated toolchain version references to 0.29.0.
  • Chores

    • Renamed packages: compact-tools-clicompact-cli, compact-tools-simulatorcompact-simulator.
    • Updated workflow dispatch inputs for release pipeline.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3f95cf4-1cb8-4546-ab83-45172a56f031

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The PR reorganizes the Compact toolchain from a monolithic package into three separately published packages: extracting the programmatic compiler/builder APIs into @openzeppelin/compact-builder, reducing @openzeppelin/compact-cli to a thin wrapper, and renaming the simulator package. The monorepo root is renamed to compact-tools-monorepo.

Changes

Compact Builder Library and CLI Refactoring

Layer / File(s) Summary
Builder package scaffolding
packages/builder/package.json, packages/builder/tsconfig.json, packages/builder/vitest.config.ts, packages/builder/CHANGELOG.md, packages/builder/README.md
New @openzeppelin/compact-builder package with ESM config, Node 20+ engine, build/test/clean scripts, TypeScript/Vitest tooling, and documentation of the programmatic API.
Shared option types and utilities
packages/builder/src/types/options.ts, packages/builder/src/utils.ts
CompilerOptions, BuilderOptions, and helper types (ExecFunction, BuildStep); utility functions for glob→regex conversion, exclusion matching, shell quoting, and find command generation.
Compilation services foundation
packages/builder/src/services/EnvironmentValidator.ts, packages/builder/src/services/FileDiscovery.ts, packages/builder/src/services/CompilerService.ts, packages/builder/src/services/UIService.ts
Services for environment validation (compact --version checks), recursive .compact file discovery with exclude patterns, per-file compilation via compact compile, and formatted console output with spinners.
CompactCompiler orchestrator
packages/builder/src/Compiler.ts, packages/builder/test/Compiler.test.ts
Top-level compiler entry point wiring environment validation, file discovery, and compilation; CLI argument parser supporting --dir, --exclude, --hierarchical, +<version> toolchain selection; validation and per-file execution with error wrapping.
CompactBuilder orchestrator
packages/builder/src/Builder.ts, packages/builder/test/Builder.test.ts
Build pipeline generator creating ordered steps (clean dist, compile TypeScript, copy artifacts, copy .compact files, copy extra targets) and executor running each with ora spinners, colored output, and process.exit(1) on failure.
Builder package entrypoint
packages/builder/src/index.ts
Re-exports all public APIs (orchestrators, services, types, errors) for stable consumer imports.
CLI package refactoring
packages/cli/src/runBuilder.ts, packages/cli/src/runCompiler.ts, packages/cli/test/runCompiler.test.ts, packages/cli/package.json, packages/cli/CHANGELOG.md, packages/cli/README.md, packages/cli/tsconfig.json
CLI imports CompactCompiler and CompactBuilder from @openzeppelin/compact-builder; removes local Builder.ts and Compiler.ts modules; renames package to @openzeppelin/compact-cli with explicit ./run-builder and ./run-compiler exports; updates documentation to position as bin wrapper only.
Simulator and monorepo package renames
packages/simulator/package.json, packages/simulator/README.md, packages/simulator/CHANGELOG.md, package.json
Simulator renamed to @openzeppelin/compact-simulator; updates import examples in simulator docs; monorepo root renamed to compact-tools-monorepo.
Release workflow and documentation
.github/workflows/release.yml, RELEASING.md, README.md, turbo.json
Workflow dispatch package options updated to compact-builder, compact-cli, compact-simulator; release docs added with per-package changelog guidance and first-release publication order; main README updated with new package names, version 0.29.0, and file: dev dependency wiring for local development; Turbo task dependencies adjusted for types task.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as `@openzeppelin/compact-cli`<br/>(bin wrapper)
    participant Builder as `@openzeppelin/compact-builder`<br/>(programmatic API)
    participant Services as Compiler/File/<br/>Environment Services
    participant Shell as child_process.exec
    participant Compact as Compact Toolchain<br/>(compactc binary)

    User->>CLI: yarn compact-compiler --dir src --exclude mock
    CLI->>Builder: CompactCompiler.fromArgs(args)
    Builder->>Builder: parseArgs() → CompilerOptions
    Builder->>Services: validateEnvironment()
    Services->>Shell: compact --version
    Shell->>Compact: check CLI available
    Compact-->>Shell: "Compactc version: 0.29.0"
    Shell-->>Services: devToolsVersion, toolchainVersion
    Services-->>Builder: environment validated
    Builder->>Services: FileDiscovery.getCompactFiles(dir)
    Services-->>Builder: [file1.compact, file2.compact]
    Builder->>Services: compile each file with spinner
    Services->>Shell: compact compile file.compact --out dist
    Shell->>Compact: compile
    Compact-->>Shell: stdout/stderr
    Shell-->>Services: compilation result
    Services-->>Builder: per-file success/error
    Builder->>Builder: display progress, handle errors
    Builder-->>CLI: compilation complete
    CLI-->>User: exit(0) or exit(1)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

The changes span a large structural refactoring involving new package creation, extracted services/APIs, refactored orchestrators, CLI repointing, manifest updates, and documentation revisions across multiple directories. The complexity stems from coordinated changes across interconnected files (service wiring, type definitions, CLI imports, tests), new test coverage for builder/compiler logic, and careful validation that the extracted builder library maintains the same behavior as the original embedded CLI implementation. While individual files are manageable, the reviewer must trace the dependency graph and validate the complete flow across the monorepo.

🐰 A builder takes flight, libraries shine bright,
The CLI now sleek, tools rearranged just right,
Three packages dance where one used to be,
Compact compiler flows, programmatic and free!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactoring effort to prepare the repository for a multi-package release by splitting and organizing the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/prepare-for-release

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread packages/builder/src/services/CompilerService.ts Fixed
Comment thread packages/builder/src/services/CompilerService.ts Fixed
Comment thread packages/builder/src/services/CompilerService.ts Fixed
Comment thread packages/builder/src/services/CompilerService.ts Fixed
Comment thread packages/builder/src/services/EnvironmentValidator.ts Fixed
Comment thread packages/builder/src/services/EnvironmentValidator.ts Fixed
@0xisk 0xisk force-pushed the refactor/prepare-for-release branch from 6980ab0 to 6225d51 Compare May 13, 2026 07:12
@0xisk 0xisk changed the title refactor: update compiler and builder as in the compact-contracts refactor: prepare for release May 13, 2026
@0xisk 0xisk marked this pull request as ready for review May 13, 2026 07:17
@0xisk 0xisk requested review from a team as code owners May 13, 2026 07:17
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/runCompiler.ts (1)

133-141: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Route all argument-validation errors to usage help and document --exclude.

Only one parser error string is recognized today. --src, --out, and --exclude validation failures will be shown as “Unexpected error”, and the help text is missing --exclude.

Suggested patch
-  if (errorMessage.includes('--dir flag requires a directory name')) {
+  const parseErrorMessages = [
+    '--dir flag requires a directory name',
+    '--src flag requires a directory path',
+    '--out flag requires a directory path',
+    '--exclude flag requires a pattern',
+  ];
+  if (parseErrorMessages.some((msg) => errorMessage.includes(msg))) {
     spinner.fail(
-      chalk.red('[COMPILE] Error: --dir flag requires a directory name'),
+      chalk.red(`[COMPILE] Error: ${errorMessage}`),
     );
     showUsageHelp();
     return;
   }
   console.log(
     chalk.yellow(
       '  --hierarchical    Preserve source directory structure in artifacts output',
     ),
   );
+  console.log(
+    chalk.yellow(
+      '  --exclude <glob>   Exclude matching .compact files (repeatable)',
+    ),
+  );

Also applies to: 171-195

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/runCompiler.ts` around lines 133 - 141, The argument parsing
only handles one specific parser error; update the arg-validation handling in
runCompiler.ts to detect all relevant flag errors (at least '--dir', '--src',
'--out', and '--exclude') instead of only checking for the single string; on
errorMessage containing patterns like "flag requires a directory name" or "flag
requires a value" or specific substrings for '--src', '--out', '--exclude', call
spinner.fail with a clear message naming the missing flag (e.g., "[COMPILE]
Error: --exclude flag requires a value"), then call showUsageHelp() and return;
also update the usage/help text emitted by showUsageHelp (or the usage constant
it prints) to include documentation for the --exclude flag; apply the same fix
to the other validation block referenced (the block around the 171-195 region)
so all parser errors are routed to usage help consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/builder/src/Builder.ts`:
- Around line 237-250: The catch block in Builder.executeStep (CompactBuilder)
currently calls process.exit(1), which library code must not do; remove the
process.exit(1) call and instead propagate the error to callers by rethrowing
the caught error (or throwing a new Error with contextual message) after
logging/printing via printOutput/isPromisifiedChildProcessError; ensure
executeStep's signature still returns a rejected Promise on failure so callers
(CLI wrappers) can decide exit behavior.

In `@packages/builder/src/Compiler.ts`:
- Around line 191-194: The current loop in Compiler.ts that conditionally pushes
into the flags array (checking if (!flags.includes(args[i]))
flags.push(args[i])) incorrectly deduplicates forwarded compiler args and can
change CLI semantics; modify the loop in the Compiler class where args and flags
are handled to always push the arg (remove the includes check) so forwarded args
are preserved in original order and repeats are allowed.
- Around line 308-320: The guard using isPromisifiedChildProcessError on the
CompilationError instance is unreachable; instead, inside the CompilationError
branch (the code handling error instanceof CompilationError in Compiler.ts)
unwrap the underlying error via error.cause, check
isPromisifiedChildProcessError(error.cause) and then treat that cause as the
execError (accessing stdout/stderr from the cause), apply the same filtering and
UIService.printOutput calls (use the same filteredOutput logic and
execError.stderr) so you read child-process output from error.cause rather than
from the CompilationError itself.

In `@packages/cli/src/runBuilder.ts`:
- Around line 41-42: Update the example command string in runBuilder.ts to fix
the archive exclude glob by removing the literal backslashes: replace the wrong
pattern '*\/archive\/*' with the correct shell glob '*/archive/*' (so the
exclude becomes --exclude '*/archive/*'); edit the comment/example where the
command is defined to ensure users won't include backslashes that prevent
matching.

In `@README.md`:
- Line 141: Update the README.md sentence that links to packages/cli/README.md
and remove the phrase “programmatic API” (the current text: "See
[packages/cli/README.md](./packages/cli/README.md) for full documentation
including all options, programmatic API, and examples."); edit it to only
reference the CLI docs (e.g., "for full documentation including all options and
examples") or otherwise omit “programmatic API”, and if needed add a brief
separate pointer to `@openzeppelin/compact-builder` for the programmatic API.

In `@RELEASING.md`:
- Around line 47-48: The release runbook uses an ambiguous short name
"`-builder`" in the release-order step; update the text to use the full package
name "`compact-builder`" so it's unambiguous (replace the string "`-builder`"
with "`compact-builder`" in the RELEASING.md step that currently reads
"`compact-cli` (depends on `-builder`; pull `main` first...)`). Ensure the
surrounding sentence still reads naturally after the change.
- Around line 34-39: The fenced code block that starts with "compact-cli (bin
wrapper)" in RELEASING.md is missing a language tag which triggers markdownlint
MD040; update that fenced block to include a language identifier (for example
"text") so it reads ```text ... ``` around the existing lines (the block
containing "compact-cli (bin wrapper)", "└─ depends on compact-builder",
"compact-builder (library)", "compact-simulator (library)").

---

Outside diff comments:
In `@packages/cli/src/runCompiler.ts`:
- Around line 133-141: The argument parsing only handles one specific parser
error; update the arg-validation handling in runCompiler.ts to detect all
relevant flag errors (at least '--dir', '--src', '--out', and '--exclude')
instead of only checking for the single string; on errorMessage containing
patterns like "flag requires a directory name" or "flag requires a value" or
specific substrings for '--src', '--out', '--exclude', call spinner.fail with a
clear message naming the missing flag (e.g., "[COMPILE] Error: --exclude flag
requires a value"), then call showUsageHelp() and return; also update the
usage/help text emitted by showUsageHelp (or the usage constant it prints) to
include documentation for the --exclude flag; apply the same fix to the other
validation block referenced (the block around the 171-195 region) so all parser
errors are routed to usage help consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e5aa748f-94ae-4204-9a21-7b636701a81a

📥 Commits

Reviewing files that changed from the base of the PR and between f921b0c and 6225d51.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (34)
  • .github/workflows/release.yml
  • README.md
  • RELEASING.md
  • package.json
  • packages/builder/CHANGELOG.md
  • packages/builder/README.md
  • packages/builder/package.json
  • packages/builder/src/Builder.ts
  • packages/builder/src/Compiler.ts
  • packages/builder/src/index.ts
  • packages/builder/src/services/CompilerService.ts
  • packages/builder/src/services/EnvironmentValidator.ts
  • packages/builder/src/services/FileDiscovery.ts
  • packages/builder/src/services/UIService.ts
  • packages/builder/src/types/errors.ts
  • packages/builder/src/types/options.ts
  • packages/builder/src/utils.ts
  • packages/builder/test/Builder.test.ts
  • packages/builder/test/Compiler.test.ts
  • packages/builder/tsconfig.json
  • packages/builder/vitest.config.ts
  • packages/cli/CHANGELOG.md
  • packages/cli/README.md
  • packages/cli/package.json
  • packages/cli/src/Builder.ts
  • packages/cli/src/Compiler.ts
  • packages/cli/src/runBuilder.ts
  • packages/cli/src/runCompiler.ts
  • packages/cli/test/runCompiler.test.ts
  • packages/cli/tsconfig.json
  • packages/simulator/CHANGELOG.md
  • packages/simulator/README.md
  • packages/simulator/package.json
  • turbo.json
💤 Files with no reviewable changes (2)
  • packages/cli/src/Builder.ts
  • packages/cli/src/Compiler.ts

Comment thread packages/builder/src/Builder.ts
Comment thread packages/builder/src/Compiler.ts Outdated
Comment thread packages/builder/src/Compiler.ts Outdated
Comment thread packages/cli/src/runBuilder.ts Outdated
Comment thread README.md Outdated
Comment thread RELEASING.md Outdated
Comment thread RELEASING.md Outdated
Comment thread RELEASING.md Outdated
Comment thread packages/builder/CHANGELOG.md Outdated
Comment thread packages/builder/CHANGELOG.md Outdated
Comment thread packages/builder/package.json Outdated
Comment thread packages/cli/src/runBuilder.ts Outdated
Comment thread packages/cli/CHANGELOG.md Outdated
Comment thread packages/cli/README.md Outdated
Comment thread packages/simulator/CHANGELOG.md Outdated
Comment thread README.md Outdated
Comment thread README.md
…s, generalize toolchain version)

- Drop pre-baseline CHANGELOGs for builder/cli/simulator and remove
  them from package.json file lists (no released baseline yet)
- RELEASING.md: drop the changesets-migration TODO section and the
  CHANGELOG preamble
- README.md: remove submodule-consumption section; drop busy
  "## Packages" walkthrough (each package has its own README);
  rename "Getting started" -> "Development"; linkify package list
- packages/cli/README.md: split em-dash sentence per review;
  replace hardcoded +0.29.0 with +<version> placeholder
- runCompiler.ts: generalize +<version> in help text + JSDoc;
  update matching test assertions
- runBuilder.ts: drop confusing JSDoc @example block; point to
  cli README for usage examples
- Set author = "OpenZeppelin Community <maintainers@openzeppelin.org>"
  across builder/cli/simulator package.json
@0xisk 0xisk force-pushed the refactor/prepare-for-release branch from b08798e to 7f70dc9 Compare May 15, 2026 10:49
@0xisk 0xisk requested a review from andrew-fleming May 15, 2026 10:50
@0xisk
Copy link
Copy Markdown
Member Author

0xisk commented May 15, 2026

Thank you @andrew-fleming! agree with all the comments and fixed them all.

Copy link
Copy Markdown
Contributor

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xisk amazing work on the PR + improvements! Separating the compiler service into multiple files is much cleaner and will be easier to maintain 👍 LGTM!

Comment thread README.md
- [`packages/simulator`](./packages/simulator) — TypeScript simulator to run and test Compact contracts locally

## External usage (via git submodule until npm publish)
See each package's README for usage, options, and examples.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@andrew-fleming andrew-fleming merged commit 91d823e into main May 15, 2026
10 checks passed
@andrew-fleming andrew-fleming deleted the refactor/prepare-for-release branch May 15, 2026 19:31
@github-project-automation github-project-automation Bot moved this from Backlog to Complete/Stable Release in OZ Development for Midnight May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete/Stable Release

Development

Successfully merging this pull request may close these issues.

3 participants