Skip to content

Commit 5dcdf94

Browse files
committed
docs(module): migrate authoring examples to LibModule
1 parent 515bb0e commit 5dcdf94

23 files changed

Lines changed: 335 additions & 299 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@
9393
`ModuleCommandRunner`, `ModulesCommand` and `NativeModulesCommand` now live
9494
in `LibModule`, making `/easymodule`, `/emodule` and `/modules` a
9595
LibModule-owned surface instead of an EasyLibrary core-owned command.
96+
- Added the OP-68H authoring example migration. The `examples/` tree now
97+
documents the `LibModule` public API directly: modules use `ModuleContext`,
98+
commands extend `BaseModuleCommand`, services/capabilities are provided
99+
through `ModuleRuntime`, and EasyLibrary's legacy `ModuleManager` is no
100+
longer imported by the examples.
96101
- Validated OP-60 live loading against the local PMMP smoke server. LibModule
97102
loaded as `source=package-backed-virtual` from
98103
`plugin_data/EasyLibrary/packages/libmodule/1.0.0-dev` and as
@@ -154,8 +159,10 @@
154159
link to the new repository operations guide.
155160
- Aligned GitHub About, homepage and topics with the official EasyLibrary lib
156161
repository pattern instead of leaving the remote metadata blank.
157-
- Kept the existing example plugins, but documented that they are still backed
158-
by EasyLibrary's internal runtime until extraction work is promoted.
162+
- Reworked the example plugin docs as `LibModule` authoring references instead
163+
of EasyLibrary-backed module examples. The docs now explain that PMMP
164+
discovery/resource registration remains a host-adapter responsibility until
165+
OP-68I/OP-68J finish the migration.
159166
- Updated `LibModuleInfo` and `package.yml` metadata to report
160167
contracts/read-model/provider-contract/provider-probe/dependency-resolver
161168
manifest/source, loader-boundary and registry/service readiness while still

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ The following pieces are already present:
120120
OP-68 finishes removing the old core runtime;
121121
- OP-60 live smoke evidence: `elprobe run libmodule` reports
122122
`functional=yes` for both package-backed virtual and standalone loading;
123-
- examples showing the current EasyLibrary-backed module format;
123+
- examples showing the `LibModule` authoring API with `BaseModule`,
124+
`ModuleContext`, `BaseModuleCommand`, services, capabilities and diagnostics;
124125
- docs describing the extraction boundary and current scaffold status.
125126

126127
PMMP host adapters such as YAML reading through `pocketmine\utils\Config`,
127-
listener/task registration and example plugin migration are still being
128-
extracted from EasyLibrary 3.0-dev after OP-68E.
128+
listener/task registration and copy-into-server example smoke are still being
129+
extracted from EasyLibrary 3.0-dev after OP-68H.
129130

130131
## Installation
131132

@@ -141,30 +142,30 @@ EasyLibrary 3.0-dev. When both standalone and package-backed copies exist, the
141142
standalone plugin wins for that server session and EasyLibrary reports the
142143
internal package as shadowed.
143144

144-
Plugins that use the current EasyLibrary-backed module authoring helpers should
145-
still depend on EasyLibrary:
145+
New module authoring code should import the public `LibModule` API:
146146

147-
```yaml
148-
depend:
149-
- EasyLibrary
147+
```php
148+
use imperazim\module\BaseModule;
149+
use imperazim\module\ModuleContext;
150150
```
151151

152-
Do not publish a stable migration promise from this dev baseline alone. The
153-
portable `LibModule` runtime is active/catalog-ready and the public authoring
154-
classes exist here, but EasyLibrary still owns filesystem discovery, runtime
155-
host registration and example migration until the rest of OP-68 is complete.
152+
Do not publish a stable copy-into-server module authoring promise from this dev
153+
baseline alone. The portable `LibModule` runtime is active/catalog-ready and
154+
the public authoring classes/examples exist here, but EasyLibrary still owns
155+
part of the PMMP host adapter until the rest of OP-68 is complete.
156156

157157
## Examples
158158

159-
The `examples/` directory contains PocketMine-MP plugin examples that target
160-
the current EasyLibrary-backed module system:
159+
The `examples/` directory contains module authoring examples that target the
160+
`LibModule` API:
161161

162162
- `01-basic-plugin`: basic module discovery and lifecycle;
163163
- `02-economy-provider-plugin`: service/capability provider example;
164164
- `03-farm-consumer-plugin`: cross-plugin consumer example;
165165
- `04-diagnostics-plugin`: controlled broken modules for diagnostics.
166166

167-
See [docs/examples.md](docs/examples.md) for the current usage notes.
167+
See [docs/examples.md](docs/examples.md) for the current usage notes and host
168+
registration boundary.
168169
See [docs/authoring-api.md](docs/authoring-api.md) for the OP-68B
169170
`BaseModule`, context, helper, event, command, listener and async API slice.
170171
The command diagnostics surface is now owned here too: `/easymodule`,
@@ -251,6 +252,9 @@ runtime is removed.
251252
OP-68F prepared the public GitHub repository presence: badges, issue/PR
252253
templates, release note categories, Dependabot, CODEOWNERS, repository
253254
notification workflow documentation and remote About/topics metadata.
255+
OP-68H moved the authoring examples and usage docs out of EasyLibrary's legacy
256+
core tree and into this repository. The examples now use `ModuleContext` and
257+
the `LibModule` public helpers instead of EasyLibrary's legacy `ModuleManager`.
254258

255259
## License
256260

docs/examples.md

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,102 @@
11
# Examples
22

3-
The runnable example plugins in this repository still target the EasyLibrary
4-
3.0-dev module runtime.
3+
The `examples/` directory now belongs to `LibModule` and targets the
4+
`imperazim\module` authoring API:
55

6-
Each example plugin declares:
6+
- modules extend `imperazim\module\BaseModule`;
7+
- lifecycle hooks receive `imperazim\module\ModuleContext`;
8+
- module-owned native commands extend `imperazim\module\command\BaseModuleCommand`;
9+
- listeners extend `imperazim\module\event\BaseModuleListener`;
10+
- services, capabilities, cleanup callbacks and diagnostics use
11+
`ModuleContext`/`ModuleRuntime`.
712

8-
```yaml
9-
depend:
10-
- EasyLibrary
11-
```
13+
These examples are intentionally no longer written against EasyLibrary's legacy
14+
`ModuleManager` helpers.
15+
16+
## Current Host Status
17+
18+
OP-68H moves the authoring examples and docs into `LibModule`. The examples are
19+
authoring references for the new API, not a stable copy-into-server promise yet.
20+
21+
During the rest of OP-68, EasyLibrary still owns part of the PMMP host adapter:
1222

13-
That dependency is correct for these examples until OP-68H migrates them.
23+
- plugin/module source discovery;
24+
- YAML reading through the PocketMine environment;
25+
- PMMP command, listener and task registration;
26+
- compatibility with old `ModuleManager`-centric modules.
1427

15-
The public authoring API already exists in `LibModule` after OP-68B. The
16-
examples still need a separate pass because they also exercise filesystem
17-
discovery, command/listener/task registration and full server smoke behavior.
28+
That means a host must explicitly wire these examples into a `ModuleRuntime`
29+
session and register any PMMP resources it wants to expose. The files under
30+
`examples/` show the module shape and the runtime contracts that the host will
31+
load once OP-68I removes the remaining EasyLibrary legacy runtime.
1832

1933
## Included Examples
2034

21-
- `01-basic-plugin`: minimal module discovery, command, listener, service and
22-
task usage.
23-
- `02-economy-provider-plugin`: module-owned service and capability provider.
24-
- `03-farm-consumer-plugin`: module consuming a service from another example.
25-
- `04-diagnostics-plugin`: intentionally broken modules for doctor/failure
26-
command testing.
35+
- `01-basic-plugin`: basic service/capability provider, health reporting,
36+
cleanup and optional command/listener/task classes.
37+
- `02-economy-provider-plugin`: module-owned economy service and capability
38+
provider.
39+
- `03-farm-consumer-plugin`: consumer module waiting on the economy service and
40+
capability, plus optional hello-service usage.
41+
- `04-diagnostics-plugin`: intentionally disabled/missing-dependency modules
42+
for doctor/failure output.
43+
44+
## Module Shape
45+
46+
Minimal module:
47+
48+
```php
49+
<?php
50+
51+
declare(strict_types=1);
2752

28-
## Manual Test Flow
53+
namespace vendor\plugin\modules\farm;
2954

30-
1. Install EasyLibrary 3.0-dev on a PocketMine-MP test server.
31-
2. Copy one example plugin directory into `plugins/`.
32-
3. Start the server.
33-
4. Run:
55+
use imperazim\module\BaseModule;
56+
use imperazim\module\ModuleContext;
3457

35-
```text
36-
/easymodule list
37-
/easymodule doctor
38-
/easymodule info <module-id>
58+
final class FarmModule extends BaseModule {
59+
protected function onEnable(ModuleContext $context): void {
60+
$this->provideService('vendor:farm-service', new FarmService());
61+
$this->addCleanup(static function(): void {
62+
// Close runtime resources here.
63+
});
64+
}
65+
}
3966
```
4067

41-
The command names may change when the LibModule extraction reaches the command
42-
provider phase.
68+
Minimal manifest:
69+
70+
```yaml
71+
id: vendor:farm
72+
name: Farm System
73+
version: 1.0.0
74+
loader: FarmModule
75+
namespace: vendor\plugin\modules\farm
76+
77+
provides:
78+
services:
79+
- vendor:farm-service
80+
capabilities:
81+
- vendor.farm
82+
```
83+
84+
## Host Registration Boundary
85+
86+
`BaseModule` deliberately does not hide PMMP command/listener/task registration.
87+
That work belongs to the active host adapter, because `LibModule` also needs to
88+
support non-EasyLibrary consumers and pure runtime tests.
89+
90+
A host can:
91+
92+
1. scan `module.yml` files with `ModuleManifestPathScanner`;
93+
2. normalize them with `ModuleManifestNormalizer`;
94+
3. load classes with `ModuleClassFileLoader`;
95+
4. validate classes with `ModuleRuntimeClassValidator`;
96+
5. register module instances in `ModuleRuntime`;
97+
6. register optional PMMP resources such as `BaseModuleCommand`,
98+
`BaseModuleListener` or `Task` instances.
99+
100+
The current examples include command/listener/task classes so the host adapter
101+
has realistic resources to register, but the modules themselves only use the
102+
portable API.

docs/scaffold-status.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Scaffold Status
22

3-
`LibModule` is intentionally in early extraction mode.
3+
`LibModule` is intentionally in 3.0-dev extraction mode.
44

55
The repository can now be validated, built and released as a dev artifact, but
6-
it does not yet own the production module runtime. OP-40 moved only the first
7-
portable contracts/read-model slice. The runtime remains inside EasyLibrary
8-
under `imperazim\module` until later extraction steps promote it.
6+
the PMMP host adapter is still being completed. The portable runtime, command
7+
surface, authoring API and examples now live here; EasyLibrary still owns the
8+
transitional host bridge until OP-68I/OP-68J prove parity.
99

1010
## Ready
1111

@@ -17,21 +17,20 @@ under `imperazim\module` until later extraction steps promote it.
1717
- Discord notification workflow.
1818
- Portable module constants and read models.
1919
- Read-only module provider contract.
20-
- Examples preserved for current EasyLibrary-backed modules.
20+
- Authoring examples updated for the `LibModule` public API.
2121

2222
## Not Ready
2323

24-
- Runtime replacement for EasyLibrary modules.
25-
- Module manager/lifecycle/commands.
26-
- Mutable provider operations.
24+
- Full PMMP host adapter ownership.
25+
- Copy-into-server example smoke as the only supported module workflow.
2726
- Official EasyLibrary package catalog entry.
2827
- Stable release.
29-
- Standalone production usage.
28+
- Standalone production usage without EasyLibrary host integration.
3029

3130
## Guardrails
3231

33-
- Do not add `LibModule` to EasyLibrary's package catalog while
34-
`runtime-ready` is `false`.
35-
- Do not remove `imperazim\module` from EasyLibrary until external provider
32+
- Keep `imperazim\module` owned by `LibModule`; EasyLibrary transitional code
33+
must stay under `imperazim\library\module`.
34+
- Do not remove the remaining EasyLibrary host bridge until external provider
3635
tests prove parity.
3736
- Do not publish a stable release from scaffold-only code.

examples/01-basic-plugin/README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
# EasyModuleBasicExample
2-
3-
Plugin minimo para testar um modulo externo da EasyLibrary.
4-
5-
## O que ele testa
6-
7-
- descoberta por `easylibrary-modules`;
8-
- `module.yml` externo;
9-
- `BaseModule`;
10-
- `ModuleContext`;
11-
- logger por modulo;
12-
- config propria do modulo;
13-
- command/listener/task registrados pelo lifecycle;
14-
- cleanup automatico;
15-
- service registry;
16-
- API publica por modulo;
17-
- health check.
18-
19-
## Comandos
20-
21-
```txt
22-
/examplehello
23-
/examplehello api
24-
/examplehello service
25-
/examplehello config
1+
# LibModule Basic Example
2+
3+
Minimal module authoring example for the `LibModule` API.
4+
5+
This example shows:
6+
7+
- a `BaseModule` using `ModuleContext`;
8+
- service/capability provisioning;
9+
- module settings stored in `module.yml`;
10+
- health reporting;
11+
- cleanup registration;
12+
- optional PMMP-facing command, listener and task classes that a host adapter
13+
can register.
14+
15+
## Module
16+
17+
```text
18+
examples:hello
2619
```
2720

28-
## Diagnostico recomendado
21+
## Provided Service
2922

30-
```txt
31-
/easymodule info examples:hello
32-
/easymodule resources examples:hello
33-
/easymodule health examples:hello
34-
/easymodule services
35-
/easymodule capabilities
36-
/easymodule reload examples:hello
23+
```text
24+
examples:hello-service
3725
```
26+
27+
Contract/interface:
28+
29+
```php
30+
easylibraryexamples\basic\modules\hello\api\HelloApi
31+
```
32+
33+
## Notes
34+
35+
The module itself only uses portable `LibModule` APIs. Command/listener/task
36+
registration is intentionally left to the active host adapter during the OP-68
37+
runtime extraction.

0 commit comments

Comments
 (0)