Skip to content

feat: add init command to initialize new projects and update README#28

Merged
Bechma merged 2 commits intocyberfabric:mainfrom
Bechma:move-init-and-main
Apr 8, 2026
Merged

feat: add init command to initialize new projects and update README#28
Bechma merged 2 commits intocyberfabric:mainfrom
Bechma:move-init-and-main

Conversation

@Bechma
Copy link
Copy Markdown
Collaborator

@Bechma Bechma commented Apr 8, 2026

Summary by CodeRabbit

  • New Features

    • Exposed an init subcommand at the top-level CLI.
    • Generated servers now read configuration at runtime from CF_CLI_CONFIG.
  • Documentation

    • Renamed examples/docs from mod initinit.
    • Added guidance for build output location (.cyberfabric/) and manual execution using CF_CLI_CONFIG and --manifest-path.
  • Chores

    • Removed liquid dependency from workspace and CLI crate.

Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc140304-bd85-4fa7-8c27-77f8ad6822d1

📥 Commits

Reviewing files that changed from the base of the PR and between 08db470 and dfa0a6d.

📒 Files selected for processing (1)
  • crates/cli/src/common.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/cli/src/common.rs

📝 Walkthrough

Walkthrough

This PR moves server config-path handling from compile-time template substitution to runtime via the CF_CLI_CONFIG environment variable, removes liquid templating, and promotes the CLI init subcommand from the mod namespace to a top-level command.

Changes

Cohort / File(s) Summary
Workspace & crate deps
Cargo.toml, crates/cli/Cargo.toml
Removed liquid dependency declarations from workspace and crate-level Cargo manifests.
Docs & examples
README.md, SKILLS.md
Renamed mod initinit in docs; documented runtime config via CF_CLI_CONFIG, updated build output path to .cyberfabric/<CONFIG_NAME>, and added manual run instructions.
CLI command wiring
crates/cli/src/lib.rs, crates/cli/src/mod/mod.rs
Added top-level Init command in lib.rs; removed mod init wiring from mod/mod.rs (moved subcommand).
Server generation & templating
crates/cli/src/common.rs
Rewrote server main template to read CF_CLI_CONFIG at runtime; removed liquid templating and runtime init code; prepare_cargo_server_main now returns an inlined String; generate_server_structure no longer takes config_path.
Build / run plumbing
crates/cli/src/build/mod.rs, crates/cli/src/run/run_loop.rs
Adjusted calls to generate_server_structure; changed cargo_command signature to accept config_path and set CF_CLI_CONFIG in the spawned cargo process; propagated config_path through watch-mode run loop.

Sequence Diagram

sequenceDiagram
    participant User as User/CLI
    participant CLI as CLI Handler
    participant Common as common.rs
    participant Cargo as Cargo Process
    participant GenServer as Generated Server
    participant Env as Environment

    rect rgba(100, 150, 200, 0.5)
    note over User,Env: Runtime configuration via CF_CLI_CONFIG
    User->>CLI: Run `build` / `run` with config_path
    CLI->>Common: generate_server_structure(project, deps)
    Common->>Common: Write main.rs reading CF_CLI_CONFIG (no config_path substitution)
    CLI->>Common: cargo_command(subcommand, path, config_path, ...)
    Common->>Cargo: Spawn cargo with CF_CLI_CONFIG env set
    Cargo->>GenServer: Build/Run generated server
    GenServer->>Env: Read CF_CLI_CONFIG at runtime
    Env-->>GenServer: Provide config path
    GenServer->>GenServer: Load config and start
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 A hop, a patch, a config in flight,

CF_CLI_CONFIG now guides the night.
Templates trimmed, the liquid's gone,
Init leaps up to the top, full-on.
Cargo runs with env set right. 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: moving the init command from mod/init to a top-level init command and updating documentation to match this refactoring.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
crates/cli/src/common.rs (1)

389-402: Test should verify hyphen-to-underscore conversion.

If the hyphen fix is applied, update the test to verify that dependency names with hyphens are correctly converted to valid Rust identifiers:

🧪 Proposed test enhancement
     #[test]
     fn generated_server_main_reads_config_from_env_and_includes_dependencies() {
         let dependencies = CargoTomlDependencies::from([
             ("module_a".to_owned(), Default::default()),
             ("module_b".to_owned(), Default::default()),
+            ("api-db-handler".to_owned(), Default::default()),
         ]);

         let main_rs = prepare_cargo_server_main(&dependencies);

         assert!(main_rs.contains("std::env::var_os(\"CF_CLI_CONFIG\")"));
         assert!(main_rs.contains("use module_a as _;"));
         assert!(main_rs.contains("use module_b as _;"));
+        assert!(main_rs.contains("use api_db_handler as _;"));
+        assert!(!main_rs.contains("use api-db-handler as _;"));
         assert!(!main_rs.contains("{{dependencies}}"));
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/cli/src/common.rs` around lines 389 - 402, The test
generated_server_main_reads_config_from_env_and_includes_dependencies needs to
also assert that dependency names containing hyphens are converted to valid Rust
identifiers (hyphen -> underscore) when generating the main.rs; update the
test's CargoTomlDependencies input to include entries with hyphens (e.g.,
"module-a" and "module-b") and change the assertions to expect "use module_a as
_;" and "use module_b as _;" (still ensure "{{dependencies}}" is not present),
so prepare_cargo_server_main and the generation logic are validated for
hyphen-to-underscore conversion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/cli/src/common.rs`:
- Around line 389-402: The test
generated_server_main_reads_config_from_env_and_includes_dependencies needs to
also assert that dependency names containing hyphens are converted to valid Rust
identifiers (hyphen -> underscore) when generating the main.rs; update the
test's CargoTomlDependencies input to include entries with hyphens (e.g.,
"module-a" and "module-b") and change the assertions to expect "use module_a as
_;" and "use module_b as _;" (still ensure "{{dependencies}}" is not present),
so prepare_cargo_server_main and the generation logic are validated for
hyphen-to-underscore conversion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: beaec668-f1d3-4aef-9639-f7b6b7c888d2

📥 Commits

Reviewing files that changed from the base of the PR and between be04e67 and 08db470.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • README.md
  • SKILLS.md
  • crates/cli/Cargo.toml
  • crates/cli/src/build/mod.rs
  • crates/cli/src/common.rs
  • crates/cli/src/init/mod.rs
  • crates/cli/src/lib.rs
  • crates/cli/src/mod/mod.rs
  • crates/cli/src/run/run_loop.rs
💤 Files with no reviewable changes (3)
  • Cargo.toml
  • crates/cli/Cargo.toml
  • crates/cli/src/mod/mod.rs

Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
@Bechma Bechma merged commit fbf1e02 into cyberfabric:main Apr 8, 2026
2 checks passed
@Bechma Bechma deleted the move-init-and-main branch April 8, 2026 20:38
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