PHPackages                             milpa/command - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. milpa/command

ActiveMilpa-capability[Framework](/categories/framework)

milpa/command
=============

The Command-as-atom core: the surface-agnostic Operation value object plus the CommandProvider and SurfaceProjector contracts. One operation, N surfaces.

v0.9.1(2w ago)03.1k↑86.4%[1 issues](https://github.com/getmilpa/command/issues)9Apache-2.0PHPPHP &gt;=8.3CI passing

Since Jul 10Pushed 1w agoCompare

[ Source](https://github.com/getmilpa/command)[ Packagist](https://packagist.org/packages/milpa/command)[ RSS](/packages/milpa-command/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (16)Versions (14)Used By (9)

 [   ![Milpa](https://raw.githubusercontent.com/getmilpa/core/main/art/lockup/milpa-lockup-v-color-light.svg)  ](https://github.com/getmilpa)

Milpa Command
=============

[](#milpa-command)

> The **Command-as-atom** core of Milpa: one surface-agnostic `Operation` value object — schema of inputs + handler + metadata (`mutating` / `requiresConfirmation` / `scopes` / `outputSchema` / `version` / `path` / `surfaces`) — plus two contracts, `CommandProvider` (the discovery seam a plugin implements to declare operations) and `SurfaceProjector` (the contract each surface projector implements). One operation, N surfaces — CLI, MCP, HTTP, web, TUI.

[![CI](https://github.com/getmilpa/command/actions/workflows/ci.yml/badge.svg)](https://github.com/getmilpa/command/actions/workflows/ci.yml)[![Packagist](https://camo.githubusercontent.com/646cb2e32b5f1502e616e6b57b4bdef26003327c903e385206b3c9a4d2418ed5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696c70612f636f6d6d616e642e737667)](https://packagist.org/packages/milpa/command)[![PHP](https://camo.githubusercontent.com/ca03f11ea27dac4dedc8ad56a7bdfc4a9ff5feb825055f9d2983616115076607/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230382e332d3737376262342e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/798509b4df525f56802b56f8096862487f08023e3d7561c68656f8dab10d0d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302d626c75652e737667)](LICENSE)[![Docs](https://camo.githubusercontent.com/c6dc6a3411e15b0ac7cc4583e8e6a8144181caedb82f5d98753353decda06d77/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d4150492532307265666572656e63652d626c75652e737667)](https://getmilpa.github.io/command/)

`milpa/command` carries the Command-as-atom contracts for Milpa — one operation, written once, that N surfaces materialize from. An `Operation` is a plain `readonly` value object: a name, a description, a handler, and the metadata a projector needs to decide how — and whether — to expose it. **No projector, no kernel, no registry** — just the atom and the two seams everything else binds to. The concrete surface projectors (CLI, MCP, HTTP, …) live host-side, in the skeleton; this package has zero package dependencies, Milpa or otherwise.

Install
-------

[](#install)

```
composer require milpa/command
```

Quick example
-------------

[](#quick-example)

```
use Milpa\Command\CommandProvider;
use Milpa\Command\Operation;
use Milpa\Command\SurfaceProjector;

final class PostsProvider implements CommandProvider
{
    public function operations(): array
    {
        return [
            new Operation(
                name: 'create_post',
                description: 'Create a post',
                handler: [PostsHandler::class, 'create'],
                inputSchema: ['type' => 'object', 'properties' => ['title' => ['type' => 'string']]],
                mutating: true,
                requiresConfirmation: true,
                scopes: ['posts:write'],
                path: '/posts',
            ),
        ];
    }
}

final class CliProjector implements SurfaceProjector
{
    public function surface(): string
    {
        return 'cli';
    }

    public function supports(Operation $op): bool
    {
        return $op->supportsSurface($this->surface());
    }
}
```

One `Operation` — `create_post` — and a `CliProjector` turns it into a `coa` command, an MCP projector registers it as a tool, an HTTP projector synthesizes the `POST /posts` route. Each projector decides, per operation, whether and how to project it (`supports()` / `supportsSurface()`); `milpa/command` never runs any of them — that dispatch is the host's job.

Two contracts, one atom
-----------------------

[](#two-contracts-one-atom)

ContractRole`CommandProvider`The discovery seam a plugin implements to declare the operations it contributes — the kernel checks every booted plugin for it and merges `operations()` into the command table.`SurfaceProjector`The contract every surface projector implements: reports the surface it targets (`cli`, `mcp`, `http`, …) and whether a given `Operation` opts into that surface.The concrete projectors — the CLI command factory, the MCP tool registrar, the HTTP route synthesizer — live host-side, not in this package.

An operation can own its doubt
------------------------------

[](#an-operation-can-own-its-doubt)

Since 0.5, an operation may declare that its target must be **named by the human** who asked:

```
new Operation(
    name: 'plugins.disable',
    // …
    namedTarget: 'name',   // the argument whose value must appear in the request
);
```

Declaring is the whole job of this package — the field is a contract, not a behaviour. Whoever holds the session enforces it (the framework's session gate does: an agent calling `plugins.disable {name: X}` when the request never named X gets a **formal question** back, not an execution). It exists because 160 measured runs showed an ambiguous imperative reads as authorisation at every link of the chain: ask "remove the old plugin" and a sampled candidate dies, with no fact saying why. With the contract declared, an unnamed target becomes a question instead. The doubt belongs to the operation that discovers a concrete operation cannot exist yet.

Requirements
------------

[](#requirements)

- PHP **≥ 8.3**
- Nothing else — `milpa/command` has no package dependencies, Milpa or otherwise

Documentation
-------------

[](#documentation)

**Full API reference: [getmilpa.github.io/command](https://getmilpa.github.io/command/)** — generated straight from the source DocBlocks and dressed with the Milpa design system.

Contributing
------------

[](#contributing)

Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Please report security issues via [SECURITY.md](SECURITY.md), and note that this project follows a [Code of Conduct](CODE_OF_CONDUCT.md).

License
-------

[](#license)

[Apache-2.0](LICENSE) © Rodrigo Vicente - TeamX Agency.

---

Milpa is designed, built, and maintained by **[Rodrigo Vicente - TeamX Agency](https://teamx.agency/?utm_source=github&utm_medium=readme&utm_campaign=milpa&utm_content=command)**.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance98

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

12

Last Release

14d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1993784?v=4)[rodrigomx](/maintainers/rodrigomx)[@rodrigomx](https://github.com/rodrigomx)

---

Top Contributors

[![rodrigoteamx](https://avatars.githubusercontent.com/u/269849276?v=4)](https://github.com/rodrigoteamx "rodrigoteamx (39 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (20 commits)")

---

Tags

command-patterncommandscqrsframeworkmilpaphpprojectionssurface-agnosticvalue-objectphpframeworkValue Objectcqrscommand-patternmilpasurface-agnostic

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/milpa-command/health.svg)

```
[![Health](https://phpackages.com/badges/milpa-command/health.svg)](https://phpackages.com/packages/milpa-command)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.9k](/packages/cakephp-cakephp)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k56](/packages/neuron-core-neuron-ai)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[dragon-code/support

Support package is a collection of helpers and tools for any project.

2310.7M115](/packages/dragon-code-support)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
