Skip to content

feat: enhance server generation with project name support#15

Merged
Bechma merged 1 commit intocyberfabric:mainfrom
Bechma:add-multiple-servers
Mar 23, 2026
Merged

feat: enhance server generation with project name support#15
Bechma merged 1 commit intocyberfabric:mainfrom
Bechma:add-multiple-servers

Conversation

@Bechma
Copy link
Copy Markdown
Collaborator

@Bechma Bechma commented Mar 23, 2026

Summary by CodeRabbit

  • New Features

    • Added optional --name flag to customize the generated project/binary name (defaults to config filename)
    • Generated projects are created in per-project directories for isolation
  • Bug Fixes

    • --clean now removes artifacts for the selected generated project only
    • Build/run execute from the per-project directory and use the shared workspace target directory
  • Documentation

    • CLI docs and examples updated to describe the new flag, paths, and behaviors

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

The PR adds per-project generated directories and a CLI --name option to select the generated project name; workspace/config resolution now returns the project name and build/run flows pass that name into server-structure generation and cargo invocations.

Changes

Cohort / File(s) Summary
Project naming & generation
crates/cli/src/common.rs
Added --name flag to build/run args; resolve_workspace_and_config() now returns (workspace_path, config_path, project_name); added resolve_generated_project_name() and public generated_project_dir(); generate_server_structure() updated to accept project_name and write files under .cyberfabric/<name>/; adjusted cargo config to use ../../target; added unit tests.
Build integration
crates/cli/src/build/mod.rs
BuildArgs::run now destructures project name from resolver, passes project_name to generate_server_structure(), and uses generated_project_dir() as the cargo working directory for cargo build.
Run integration & loop
crates/cli/src/run/mod.rs, crates/cli/src/run/run_loop.rs
RunArgs::run and RunLoop::new() updated to accept project_name; RunLoop stores project_name; server-structure generation and watch-mode regenerations pass project_name; cargo run uses generated_project_dir().
Docs & metadata
SKILLS.md, AGENTS.md, Cargo.toml
Documented new --name flag, updated paths and examples to .cyberfabric/<name>/; added doc rule for SKILLS updates; bumped several dependency versions.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Build cmd #3: Modifies CLI server scaffolding flow and generate_server_structure usage; closely related to per-project generation and cargo path changes.
  • add cargo support and fix a couple of bugs #11: Changes crates/cli/src/common.rs and generation behavior, overlapping on project-name determination and file-generation logic.

Poem

🐰 I stitched a name upon each seed and stem,
A tidy burrow for code, a tiny den,
With --name I hop, I carve the path so fine,
Directories bloom beneath the moonlight's shine,
Hooray — each project now gets its own sign! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% 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 'feat: enhance server generation with project name support' directly and clearly describes the main change: adding project name support to server generation across the codebase.

✏️ 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/cli/src/common.rs`:
- Around line 284-286: generated_project_dir currently produces collisions by
using only the config file stem; update it so default project names are
collision-resistant by incorporating more of the config path (e.g., include the
config parent directory or a short hash of the absolute config path) into the
returned PathBuf, and add a check where the generated directory already exists
to detect whether the existing dir was created from a different config and
return/fail with an explicit error instead of silently overwriting; apply the
same change/guard in the related code paths mentioned around the 324-345 range
that derive project names from file_stem().

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dca44ede-f194-49f1-8a8e-fc01b4623822

📥 Commits

Reviewing files that changed from the base of the PR and between f84e793 and 5f61e2a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • crates/cli/src/build/mod.rs
  • crates/cli/src/common.rs
  • crates/cli/src/run/mod.rs
  • crates/cli/src/run/run_loop.rs

Comment on lines +284 to +286
pub fn generated_project_dir(path: &Path, project_name: &str) -> PathBuf {
PathBuf::from(path).join(BASE_PATH).join(project_name)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Default project names can silently alias distinct configs.

Line 333 derives the default from file_stem() only. configs/admin.yml and examples/admin.yaml both resolve to admin, so Line 285 sends both commands to the same .cyberfabric/admin directory and the later build/run rewrites the earlier config's generated Cargo.toml and src/main.rs. That breaks the multi-server workflow this PR is trying to enable. Please make the default collision-resistant, or fail when the target directory is already associated with a different config.

Also applies to: 324-345

🤖 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 284 - 286, generated_project_dir
currently produces collisions by using only the config file stem; update it so
default project names are collision-resistant by incorporating more of the
config path (e.g., include the config parent directory or a short hash of the
absolute config path) into the returned PathBuf, and add a check where the
generated directory already exists to detect whether the existing dir was
created from a different config and return/fail with an explicit error instead
of silently overwriting; apply the same change/guard in the related code paths
mentioned around the 324-345 range that derive project names from file_stem().

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

that's fine. This is why we have the flag to override the default behaviour

Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
@Bechma Bechma force-pushed the add-multiple-servers branch from 5f61e2a to 7cac347 Compare March 23, 2026 15:10
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)

324-345: Consider adding a test for invalid name rejection.

The validation logic correctly handles both explicit overrides and derived names, with helpful error context when the config stem fails validation. However, the test suite only covers happy paths.

🧪 Suggested additional test case
#[test]
fn generated_project_name_rejects_invalid_override() {
    let result = resolve_generated_project_name(Path::new("/tmp/quickstart.yml"), Some("invalid name!"));
    assert!(result.is_err(), "should reject names with invalid characters");
}

#[test]
fn generated_project_name_rejects_invalid_config_stem() {
    let result = resolve_generated_project_name(Path::new("/tmp/invalid name!.yml"), None);
    assert!(result.is_err(), "should reject config stems with invalid characters");
}
🤖 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 324 - 345, Add unit tests to exercise
resolve_generated_project_name's error paths: one where override_name is
provided but invalid, and one where the config file stem derived from
config_path is invalid. Use Path::new(...) to construct test paths and call
resolve_generated_project_name; assert the Result is Err for both cases.
Reference the function resolve_generated_project_name and the validate_name
behavior so the tests fail when invalid names (e.g., containing spaces or
punctuation) are allowed.
🤖 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 324-345: Add unit tests to exercise
resolve_generated_project_name's error paths: one where override_name is
provided but invalid, and one where the config file stem derived from
config_path is invalid. Use Path::new(...) to construct test paths and call
resolve_generated_project_name; assert the Result is Err for both cases.
Reference the function resolve_generated_project_name and the validate_name
behavior so the tests fail when invalid names (e.g., containing spaces or
punctuation) are allowed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ded522b-c2cf-416a-a3a9-62708cea6869

📥 Commits

Reviewing files that changed from the base of the PR and between 5f61e2a and 7cac347.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • AGENTS.md
  • Cargo.toml
  • SKILLS.md
  • crates/cli/src/build/mod.rs
  • crates/cli/src/common.rs
  • crates/cli/src/run/mod.rs
  • crates/cli/src/run/run_loop.rs
✅ Files skipped from review due to trivial changes (2)
  • AGENTS.md
  • Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/cli/src/run/mod.rs
  • crates/cli/src/build/mod.rs

@Bechma Bechma merged commit ae427b9 into cyberfabric:main Mar 23, 2026
2 checks passed
@Bechma Bechma deleted the add-multiple-servers branch March 23, 2026 15:25
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