Skip to content

refactor(console)!: move Console and Command into Utopia\Console - #14261

Merged
ChiragAgg5k merged 3 commits into
mainfrom
refactor/console-namespace
Oct 8, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
refactor/console-namespace

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

Phase 6 of #13828 (step B in rfc/monorepo.md) for console. Console was one of the two packages still declaring the bare Utopia\ prefix, which a standard Utopia\<Ns>\ prefix cannot load. Its two classes move into the package namespace:

Old New
Utopia\Console Utopia\Console\Console
Utopia\Command Utopia\Console\Command

The commits:

  1. refactor(console)!: move Console and Command into Utopia\Console

    • packages/console maps Utopia\Console\ → src/. Command now imports Utopia\Validator explicitly, which it used to resolve from the shared Utopia namespace.

    • Shim: src/compat.php aliases both old names. It's loaded through autoload.files and mirrors the shim client shipped for its 0.5 rename: the aliases are registered up front, because PHP never autoloads a name while checking a declared type, and each is guarded with class_exists(..., false), because a process can load the file through both the root and the package autoloader.

    • bin/monorepo: console leaves BARE.

    • Root composer.json: bin/monorepo autoload adds Utopia\Console\ → packages/console/src and autoload.files → packages/console/src/compat.php, and removes packages/console/src from the bare Utopia\ list.

    • The PHPStan baseline's two entries are renamed to the new class names. There are no new findings.

    • New tests in CompatTest:

      • both old names resolve to the moved classes and still work (\Utopia\Console::log(), new \Utopia\Command(...));
      • in a separate process, a consumer typed against \Utopia\Command accepts a new Utopia\Console\Command.

      With compat.php emptied, all three fail (2 failures, 1 error).

  2. refactor: import Console and Command from Utopia\Console: every call site moves to the new names, so nothing in this repository depends on the aliases. 96 files (imports only), plus packages/cli/README.md:

    • src: 63
    • tests: 13
    • packages/vcs: 10
    • app: 7
    • packages/agents, packages/emails, packages/orchestration: 1 each

    Outside the shim, its tests and RFC prose, nothing references the old names.

  3. docs(rfc): record console's step B

Bare Utopia\ list

After this, the root Utopia\ entry holds only packages/validators/src. The validators step B runs in a parallel PR. Whichever of the two merges second removes the Utopia\ key from the root autoload entirely, and that PR should resolve the conflict that way.

Release plan

Cut console/0.3.0 after merge. In 0.x the minor is the breaking slot (^0.2 won't pick it up), the same as client 0.4 → 0.5. It's the first console release from this repository; the mirror's last one is 0.2.9.

What consumers see:

  • Appwrite: loads packages/console directly, and every call site uses the new names.
  • Vendored utopia-php/database / migration: these still use Utopia\Console in src/ (Database.php, PDO.php, PDOStatement.php). replace hands them packages/console, and the shim keeps the old name working. I checked this by calling \Utopia\Console::warning() through the root autoloader after loading Utopia\Database\Database. Both packages are being absorbed (Absorb database, mongo and migration into packages/ (wave 6) #14255), and their imports can move then.
  • Cloud: takes console through server-ce. Its own call sites keep working through the shim on the next bump and can move to the new names whenever convenient.
  • Edge (console 0.1.1 locked) and open-runtimes/executor (^0.1.1): unaffected until they move to ^0.3. When they do, the old names keep working through the shim.
  • Dropping the shim: in the next breaking release (0.4.0), once database, migration, Cloud, Edge and executor import the new names.

Tests

  • bin/monorepo test console: 46 tests, 180 assertions.
  • bin/monorepo check console: Rector, Pint and PHPStan (level max with the renamed baseline) pass.
  • bin/monorepo check agents emails orchestration vcs: all pass.
  • bin/monorepo test <dependent> --linked (siblings from this checkout, as CI runs dependents):
    • agents: 139 tests pass;
    • emails: 118 pass;
    • orchestration and vcs: their unit tiers pass. Their E2E tiers need Docker-in-Docker and provider services, so CI's package jobs are the check for those.
  • Appwrite unit suite in appwrite/base:2.1.0: 1419 tests pass.
  • packages suite in Docker: 9435 tests. The 5 errors are agents' DiffCheckTest, which can't run git inside the container from a git worktree checkout ("not a git repository"); the same file passes on the host (5 tests). The NATS warning is unrelated.
  • Root pint --test, rector --dry-run, phpstan analyse and bin/monorepo validate all pass.

Part of #13828.

Step B of the monorepo shape (phase 6 of #13828): console was one of two
packages left at the bare Utopia\ root, which a Utopia\<Ns>\ prefix
cannot load. Console and Command now live in Utopia\Console and the
package maps Utopia\Console\ => src/ like every other one.

src/compat.php aliases the old names, registered up front and guarded as
client's shim was, so vendored utopia-php/database and consumers on
Packagist keep working until the next major drops it. console leaves
BARE, and the root autoload maps Utopia\Console\ and loads the shim.
Every call site in Appwrite and the sibling packages moves to the new
names in the same change, so nothing here relies on the compat aliases.
@luxor-code-review

luxor-code-review Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to

🟡 Medium — Sibling packages pin console ^0.2 but use 0.3 names · composer.json:34 · file not in diff

// packages/vcs/composer.json
34	        "utopia-php/console": "^0.2",

The console classes moved to Utopia\Console\Console / Utopia\Console\Command and ship as console/0.3.0 per rfc/monorepo.md, yet packages that depend on console still require constraints excluding 0.3.0: packages/vcs/composer.json:34 and packages/agents/composer.json:42 say ^0.2, and packages/orchestration/composer.json:36 says 0.2.*. The same PR changed those packages' sources to import the new names (e.g. packages/vcs/src/Adapter.php now uses Utopia\Console\Command), which only exist from 0.3.0 onward — the compat.php alias shim also only ships in 0.3.0. A standalone Composer install of any of these mirrors resolves console 0.2.x and fails with a fatal class-not-found; the root monorepo autoload masks the problem, which is why tests pass.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Regenerate stale composer.lock content-hash (composer.json:42) — The PR edits root composer.json (adds the Utopia\Console\ psr-4 mapping and the packages/console/src/compat.php files entry) but composer.lock was not regenerated, so its content-hash no longer matches (composer.json:79).

This PR absorbs utopia-php/console as packages/console, moving the classes to Utopia\Console\Console and Utopia\Console\Command with a guarded class_alias shim autoloaded via composer.json files for backwards compatibility, plus matching test fixtures.

Files Change
packages/console/*, composer.json, bin/monorepo Absorbed console package with namespace move, compat.php BC alias, composer wiring, and monorepo tooling updates
app/*, src/Appwrite/**, packages/{agents,emails,orchestration,vcs}/* Mechanical import renames from Utopia\Console/Utopia\Command to the new namespaced classes across entrypoints, workers, tasks, migrations, and VCS adapters
tests/e2e/**, packages/*/tests Test bases and fixtures updated to the renamed classes, with a new CompatTest covering the alias shim

The rename itself is clean and consistent — no stale old-namespace imports remain. Two packaging-level items worth attention: sibling package version constraints and a stale composer.lock content hash.

Reviewed commit: 1f54b4c

@ghost

ghost commented Oct 8, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The migration and compatibility aliases are wired consistently, with tests covering both legacy resolution and typed consumers.

Moved the console package classes into Utopia\Console and added autoloaded aliases for the legacy class names. Updated Composer mappings, repository call sites, tests, and the monorepo RFC to use and document the new namespace.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 4
File Change
packages/console Moved Console and Command, added guarded compatibility aliases, and updated package docs and tests.
composer.json, bin/monorepo Registered the package namespace and compatibility file in root autoloading and removed console from the bare-prefix list.
app, src, tests, packages/agents, packages/cli, packages/emails, packages/orchestration, packages/vcs Updated imports and examples to reference the moved classes.
rfc/monorepo.md Recorded console's namespace migration and release plan.

Reviewed 1f54b4c · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit 7f65c43 into main Oct 8, 2026
107 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the refactor/console-namespace branch October 8, 2026 11:49
ChiragAgg5k added a commit that referenced this pull request Oct 8, 2026
console took step B in #14261, so validators is the second to land: the
root autoload drops the bare Utopia\ prefix, BARE is empty, both compat
shims load through files, and console's Command imports the new validator
name and requires validators ^2.0.
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