Skip to content

refactor(app): split monolithic lib.rs/main.rs into per-module files#284

Merged
tcp404 merged 1 commit into
mainfrom
boii/feat-subcmd
May 16, 2026
Merged

refactor(app): split monolithic lib.rs/main.rs into per-module files#284
tcp404 merged 1 commit into
mainfrom
boii/feat-subcmd

Conversation

@tcp404

@tcp404 tcp404 commented May 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Reorganize `aionui-app` into a layered layout where `lib.rs` / `main.rs` / every `mod.rs` is a pure façade (module declarations + re-exports only). Every type / function lives in its own focused file.

New layout

```
src/
├── main.rs binary entry (47 lines)
├── cli.rs CLI argument definitions
├── lib.rs pure re-exports
├── config.rs AppConfig + derive_encryption_key
├── services.rs AppServices (lib public capability)
├── bootstrap/ binary-private startup helpers
│ ├── mod.rs façade
│ ├── environment.rs ServerEnvironment + init_environment + init_data_layer
│ ├── tracing_init.rs
│ ├── work_dir.rs
│ └── builtin_skills.rs
├── commands/ subcommand implementations
│ ├── mod.rs façade
│ ├── bridge.rs
│ ├── server.rs
│ ├── team_guide.rs
│ └── team_stdio.rs
└── router/ HTTP router assembly
├── mod.rs façade
├── routes.rs create_router* + middleware stack
├── state.rs ModuleStates + build_*_state (merged former module_states.rs + state_builders.rs)
├── trace.rs access log layer
└── health.rs /health + /api/system/guide-mcp
```

Where things live, and why

  • `AppServices` in lib tree — tests/* consume `aionui_app::AppServices::from_config` directly, so it must be a public lib capability.
  • `bootstrap/` in binary tree — only the binary needs process-level init (`tracing_subscriber::registry().init()`, `std::env::set_var`, builtin-skills materialization). Single consumer (`main`), so it stays binary-private.
  • Dependencies flow outer → inner: `main → bootstrap + commands`; `commands::server → bootstrap + aionui_app lib`; `router::routes → router::state → services + config`.

Test plan

  • `cargo build -p aionui-app`
  • `cargo fmt --all -- --check`
  • `cargo clippy -p aionui-app -- -D warnings`
  • `cargo test -p aionui-app` — all suites pass (config tests + services tests + state tests + tests/*.rs e2e)

Reorganize aionui-app into a layered layout where lib.rs / main.rs / mod.rs
are pure façades (declarations + re-exports only) and every type/function
lives in its own focused file:

- lib.rs: re-exports only — moves AppConfig + derive_encryption_key to
  config.rs, AppServices to services.rs, ModuleStates + build_*_state to
  router/state.rs (merged from former module_states.rs + state_builders.rs).
- router/: routes.rs (create_router*), state.rs (states + builders),
  trace.rs (access log), health.rs (/health + /api/system/guide-mcp).
- main.rs: 47 lines — only CLI parse + runtime init + subcommand dispatch.
- bootstrap/: binary-private startup helpers (tracing_init, environment,
  work_dir, builtin_skills) — each is its own file.
- commands/: only the 4 real subcommands (bridge, server, team_guide,
  team_stdio); previous mixed-in helpers moved out to bootstrap/.

Dependency direction is strictly outer→inner. AppServices stays in the
lib tree because tests/* consume it directly; the side-effect-laden
bootstrap helpers stay in the binary tree (single consumer = main).

No behavioral change. tests pass, clippy clean, fmt clean.
@tcp404 tcp404 force-pushed the boii/feat-subcmd branch from dd776e5 to 604a4f4 Compare May 16, 2026 09:06
@tcp404 tcp404 enabled auto-merge (squash) May 16, 2026 09:10
@tcp404 tcp404 merged commit f3462cb into main May 16, 2026
5 checks passed
@tcp404 tcp404 deleted the boii/feat-subcmd branch May 16, 2026 09:16
This was referenced May 16, 2026
piorpua pushed a commit that referenced this pull request May 16, 2026
🤖 I have created a release *beep* *boop*
---


## [0.1.4](v0.1.3...v0.1.4)
(2026-05-16)


### Features

* **ai-agent:** log every CLI detection + add doctor subcommand
([#285](#285))
([5ef6d0a](5ef6d0a))
* **runtime:** full shell-style command in spawn logs
([#278](#278))
([dd51616](dd51616))


### Bug Fixes

* **ai-agent:** negotiate OpenClaw protocol v3..v4
([#288](#288))
([dfeece0](dfeece0))
* **team:** model routing + schema unification + lazy warm mode
persistence ([#286](#286))
([199a392](199a392))


### Performance Improvements

* **team:** lazy warm — only start agent processes on first message
([#282](#282))
([6281f31](6281f31))


### Code Refactoring

* **app:** extract CLI definitions to cli.rs
([#280](#280))
([5685d52](5685d52))
* **app:** introduce commands/ module with layered bootstrap for
subcommands ([#283](#283))
([1216597](1216597))
* **app:** replace argv sniffing with clap Subcommand for mcp-* helpers
([#277](#277))
([c3d137c](c3d137c))
* **app:** split monolithic lib.rs/main.rs into per-module files
([#284](#284))
([f3462cb](f3462cb))
* rename binary from aionui-backend to aioncli
([#289](#289))
([30eeca3](30eeca3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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