create crate tools #123

Open
opened 2026-03-26 04:27:45 +00:00 by despiegk · 4 comments
Owner

see /Volumes/T7/code0/hero_lib/crates/tools

make examples

structure to use /Volumes/T7/code0/hero_lib/crates/os (see how we use examples, src, ...)

now implement all we have done in

/Users/despiegk/hero/code/hero_skills/tools/modules
which are tools in nushell

we now need to have them reimplemented in rust

use the os modules from /Volumes/T7/code0/hero_lib/crates/os/src e.g. git... where we can

see /Volumes/T7/code0/hero_lib/crates/tools make examples structure to use /Volumes/T7/code0/hero_lib/crates/os (see how we use examples, src, ...) now implement all we have done in /Users/despiegk/hero/code/hero_skills/tools/modules which are tools in nushell we now need to have them reimplemented in rust use the os modules from /Volumes/T7/code0/hero_lib/crates/os/src e.g. git... where we can
Author
Owner

Implementation Spec for Issue #123: Create Crate Tools

Objective

Create a new herolib_tools Rust crate that reimplements all 9 nushell tool modules from hero_skills/tools/modules in Rust, following herolib_os crate conventions, reusing existing OS modules where possible.

Nushell Modules to Reimplement (9 total)

  1. forge.nu (48KB) — Forgejo API client: find, list, info, pull, push, clone, delete, new, worktree, workspace, workmerge, workdiscard, copy, rename, user
  2. agent.nu — AI agent launcher config (model selection for Claude/OpenRouter/Groq/DeepInfra)
  3. hero_utils.nu — Utilities: external disk detection, shell init parsing, string stats, markdown tables
  4. init.nu — Hero environment initialization (ROOTDIR derivation, secrets loading, sccache config)
  5. installers.nu — Platform-aware tool installation (base tools, Claude Code, Python/uv)
  6. legacy.nu — Legacy shell support (generate init.sh for bash/zsh)
  7. secrets_lib.nu (15KB) — Secrets management (TOML parsing, flatten, merge, sync with Forgejo)
  8. services.nu — Service management (hero_proc, hero_aibroker, hero_browser_mcp)
  9. skills.nu — Skills repo sync and Claude skills installation

Files to Create

  • crates/tools/Cargo.toml + register in workspace
  • crates/tools/src/lib.rs with 9 submodules
  • crates/tools/src/forge/ (6 files: client, env, resolve, repo, sync, worktree)
  • crates/tools/src/agent/mod.rs
  • crates/tools/src/hero_utils/mod.rs
  • crates/tools/src/init/mod.rs
  • crates/tools/src/installers/mod.rs
  • crates/tools/src/legacy/mod.rs
  • crates/tools/src/secrets/ (template, loader, sync)
  • crates/tools/src/services/mod.rs
  • crates/tools/src/skills/mod.rs
  • crates/tools/examples/ (5 examples)
  • crates/tools/tests/ (4 test files)
  • crates/tools/README.md

Implementation Plan (13 steps)

  1. Scaffold crate & register in workspace
  2. hero_utils module (disk detection, shell parsing, string stats, md-table)
  3. secrets module (TOML template, flatten, merge, toml→sh, sync)
  4. forge module — largest (API client, repo CRUD, pull/push/clone, worktrees, name resolution)
  5. init module (derive ROOTDIR, init_main, init_setup)
  6. installers module (detect pkg manager, install tools)
  7. legacy module (write init.sh, patch rc files)
  8. services module (hero_proc, aibroker, browser_mcp)
  9. skills module (sync skills repo, rsync to Claude config)
  10. agent module (model config, env vars, CLI args)
  11. Create 5 examples
  12. Write integration tests
  13. Add README.md

OS Modules to Reuse

herolib_os::git, process, os::fs, os::platform, os::package::PackHero, os::download, rsync, ssh

Acceptance Criteria

  • Crate compiles in workspace
  • All 9 nushell modules have Rust counterparts
  • Forge module: auth, list, clone/pull/push, worktrees
  • Secrets: parse TOML, flatten, merge, generate .sh
  • Init: derive ROOTDIR, set paths
  • Installers: detect pkg manager, install tools
  • 5+ working examples
  • All tests pass
  • README documents module mapping
## Implementation Spec for Issue #123: Create Crate Tools ### Objective Create a new `herolib_tools` Rust crate that reimplements all 9 nushell tool modules from `hero_skills/tools/modules` in Rust, following `herolib_os` crate conventions, reusing existing OS modules where possible. ### Nushell Modules to Reimplement (9 total) 1. **forge.nu** (48KB) — Forgejo API client: find, list, info, pull, push, clone, delete, new, worktree, workspace, workmerge, workdiscard, copy, rename, user 2. **agent.nu** — AI agent launcher config (model selection for Claude/OpenRouter/Groq/DeepInfra) 3. **hero_utils.nu** — Utilities: external disk detection, shell init parsing, string stats, markdown tables 4. **init.nu** — Hero environment initialization (ROOTDIR derivation, secrets loading, sccache config) 5. **installers.nu** — Platform-aware tool installation (base tools, Claude Code, Python/uv) 6. **legacy.nu** — Legacy shell support (generate init.sh for bash/zsh) 7. **secrets_lib.nu** (15KB) — Secrets management (TOML parsing, flatten, merge, sync with Forgejo) 8. **services.nu** — Service management (hero_proc, hero_aibroker, hero_browser_mcp) 9. **skills.nu** — Skills repo sync and Claude skills installation ### Files to Create - `crates/tools/Cargo.toml` + register in workspace - `crates/tools/src/lib.rs` with 9 submodules - `crates/tools/src/forge/` (6 files: client, env, resolve, repo, sync, worktree) - `crates/tools/src/agent/mod.rs` - `crates/tools/src/hero_utils/mod.rs` - `crates/tools/src/init/mod.rs` - `crates/tools/src/installers/mod.rs` - `crates/tools/src/legacy/mod.rs` - `crates/tools/src/secrets/` (template, loader, sync) - `crates/tools/src/services/mod.rs` - `crates/tools/src/skills/mod.rs` - `crates/tools/examples/` (5 examples) - `crates/tools/tests/` (4 test files) - `crates/tools/README.md` ### Implementation Plan (13 steps) 1. Scaffold crate & register in workspace 2. `hero_utils` module (disk detection, shell parsing, string stats, md-table) 3. `secrets` module (TOML template, flatten, merge, toml→sh, sync) 4. `forge` module — largest (API client, repo CRUD, pull/push/clone, worktrees, name resolution) 5. `init` module (derive ROOTDIR, init_main, init_setup) 6. `installers` module (detect pkg manager, install tools) 7. `legacy` module (write init.sh, patch rc files) 8. `services` module (hero_proc, aibroker, browser_mcp) 9. `skills` module (sync skills repo, rsync to Claude config) 10. `agent` module (model config, env vars, CLI args) 11. Create 5 examples 12. Write integration tests 13. Add README.md ### OS Modules to Reuse `herolib_os::git`, `process`, `os::fs`, `os::platform`, `os::package::PackHero`, `os::download`, `rsync`, `ssh` ### Acceptance Criteria - [ ] Crate compiles in workspace - [ ] All 9 nushell modules have Rust counterparts - [ ] Forge module: auth, list, clone/pull/push, worktrees - [ ] Secrets: parse TOML, flatten, merge, generate .sh - [ ] Init: derive ROOTDIR, set paths - [ ] Installers: detect pkg manager, install tools - [ ] 5+ working examples - [ ] All tests pass - [ ] README documents module mapping
Author
Owner

Test Results

  • Total: 0 (compilation failed)
  • Passed: 0
  • Failed: 13 compilation errors
Full output
warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/git/mod.rs:40:7
   |
40 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
   = note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/kernel/mod.rs:10:7
   |
10 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/net/mod.rs:37:7
   |
37 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/os/mod.rs:51:7
   |
51 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/process/mod.rs:18:7
   |
18 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
 --> crates/os/src/profiling/cpu/mod.rs:5:7
  |
5 | #[cfg(feature = "rhai")]
  |       ^^^^^^^^^^^^^^^^
  |
  = note: expected values for `feature` are: `default`, `full`, and `repl`
  = help: consider adding `rhai` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
 --> crates/os/src/profiling/disk/mod.rs:8:7
  |
8 | #[cfg(feature = "rhai")]
  |       ^^^^^^^^^^^^^^^^
  |
  = note: expected values for `feature` are: `default`, `full`, and `repl`
  = help: consider adding `rhai` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/profiling/error.rs:54:7
   |
54 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/profiling/error.rs:59:7
   |
59 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/profiling/error.rs:73:7
   |
73 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
 --> crates/os/src/profiling/memory/mod.rs:8:7
  |
8 | #[cfg(feature = "rhai")]
  |       ^^^^^^^^^^^^^^^^
  |
  = note: expected values for `feature` are: `default`, `full`, and `repl`
  = help: consider adding `rhai` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
 --> crates/os/src/profiling/monitor/mod.rs:7:7
  |
7 | #[cfg(feature = "rhai")]
  |       ^^^^^^^^^^^^^^^^
  |
  = note: expected values for `feature` are: `default`, `full`, and `repl`
  = help: consider adding `rhai` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/profiling/network/mod.rs:10:7
   |
10 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
 --> crates/os/src/profiling/report/mod.rs:7:7
  |
7 | #[cfg(feature = "rhai")]
  |       ^^^^^^^^^^^^^^^^
  |
  = note: expected values for `feature` are: `default`, `full`, and `repl`
  = help: consider adding `rhai` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/rootfs/mod.rs:46:7
   |
46 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/rsync/mod.rs:69:7
   |
69 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `rhai`
  --> crates/os/src/ssh/mod.rs:89:7
   |
89 | #[cfg(feature = "rhai")]
   |       ^^^^^^^^^^^^^^^^
   |
   = note: expected values for `feature` are: `default`, `full`, and `repl`
   = help: consider adding `rhai` as a feature in `Cargo.toml`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: method `command_exists` is never used
  --> crates/os/src/rootfs/distros/alpine.rs:59:8
   |
24 | impl AlpineFactory {
   | ------------------ method in this implementation
...
59 |     fn command_exists(&self, cmd: &str) -> bool {
   |        ^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: `herolib_os` (lib) generated 18 warnings
   Compiling herolib_tools v0.4.2 (/Volumes/T7/code0/hero_lib/crates/tools)
error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:262:9
    |
262 |         std::env::remove_var("OPENROUTER_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:271:9
    |
271 |         std::env::set_var("OPENROUTER_API_KEY", "test-key-123");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:284:9
    |
284 |         std::env::remove_var("OPENROUTER_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:289:9
    |
289 |         std::env::remove_var("GROQ_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:298:9
    |
298 |         std::env::set_var("GROQ_API_KEY", "groq-test-key");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:307:9
    |
307 |         std::env::remove_var("GROQ_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:312:9
    |
312 |         std::env::remove_var("DEEPGRAM_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:321:9
    |
321 |         std::env::set_var("DEEPGRAM_API_KEY", "deepinfra-test-key");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:330:9
    |
330 |         std::env::remove_var("DEEPGRAM_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:335:9
    |
335 |         std::env::set_var("OPENROUTER_API_KEY", "test-key");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:343:9
    |
343 |         std::env::remove_var("OPENROUTER_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:348:9
    |
348 |         std::env::set_var("GROQ_API_KEY", "groq-test-key");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block
   --> crates/tools/src/agent/mod.rs:353:9
    |
353 |         std::env::remove_var("GROQ_API_KEY");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

For more information about this error, try `rustc --explain E0133`.
error: could not compile `herolib_tools` (lib test) due to 13 previous errors

## Test Results - **Total**: 0 (compilation failed) - **Passed**: 0 - **Failed**: 13 compilation errors <details> <summary>Full output</summary> ``` warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/git/mod.rs:40:7 | 40 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/kernel/mod.rs:10:7 | 10 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/net/mod.rs:37:7 | 37 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/os/mod.rs:51:7 | 51 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/process/mod.rs:18:7 | 18 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/cpu/mod.rs:5:7 | 5 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/disk/mod.rs:8:7 | 8 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/error.rs:54:7 | 54 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/error.rs:59:7 | 59 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/error.rs:73:7 | 73 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/memory/mod.rs:8:7 | 8 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/monitor/mod.rs:7:7 | 7 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/network/mod.rs:10:7 | 10 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/profiling/report/mod.rs:7:7 | 7 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/rootfs/mod.rs:46:7 | 46 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/rsync/mod.rs:69:7 | 69 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `rhai` --> crates/os/src/ssh/mod.rs:89:7 | 89 | #[cfg(feature = "rhai")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `default`, `full`, and `repl` = help: consider adding `rhai` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration warning: method `command_exists` is never used --> crates/os/src/rootfs/distros/alpine.rs:59:8 | 24 | impl AlpineFactory { | ------------------ method in this implementation ... 59 | fn command_exists(&self, cmd: &str) -> bool { | ^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default warning: `herolib_os` (lib) generated 18 warnings Compiling herolib_tools v0.4.2 (/Volumes/T7/code0/hero_lib/crates/tools) error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:262:9 | 262 | std::env::remove_var("OPENROUTER_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:271:9 | 271 | std::env::set_var("OPENROUTER_API_KEY", "test-key-123"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:284:9 | 284 | std::env::remove_var("OPENROUTER_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:289:9 | 289 | std::env::remove_var("GROQ_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:298:9 | 298 | std::env::set_var("GROQ_API_KEY", "groq-test-key"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:307:9 | 307 | std::env::remove_var("GROQ_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:312:9 | 312 | std::env::remove_var("DEEPGRAM_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:321:9 | 321 | std::env::set_var("DEEPGRAM_API_KEY", "deepinfra-test-key"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:330:9 | 330 | std::env::remove_var("DEEPGRAM_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:335:9 | 335 | std::env::set_var("OPENROUTER_API_KEY", "test-key"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:343:9 | 343 | std::env::remove_var("OPENROUTER_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:348:9 | 348 | std::env::set_var("GROQ_API_KEY", "groq-test-key"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `remove_var` is unsafe and requires unsafe block --> crates/tools/src/agent/mod.rs:353:9 | 353 | std::env::remove_var("GROQ_API_KEY"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior For more information about this error, try `rustc --explain E0133`. error: could not compile `herolib_tools` (lib test) due to 13 previous errors ``` </details>
Author
Owner

Implementation Complete

Changes Made

New crate: herolib_tools (crates/tools/) — reimplements all 9 nushell tool modules in Rust.

Files Created (25 source files + 5 examples + 1 README)

Crate setup:

  • crates/tools/Cargo.toml — crate manifest with workspace dependencies
  • crates/tools/src/lib.rs — root module exposing all 9 submodules
  • crates/tools/README.md — documentation with module mapping table

Source modules (9 modules, matching all nushell originals):

  • src/forge/ (7 files) — Forgejo API client, repo CRUD, pull/push/clone, worktrees, name resolution
  • src/agent/mod.rs — AI model configuration for Claude, OpenRouter, Groq, DeepInfra
  • src/hero_utils/mod.rs — disk detection, shell file parsing, string stats, markdown tables
  • src/init/mod.rs — Hero environment initialization (ROOTDIR derivation, path setup)
  • src/installers/mod.rs — platform-aware tool installation (brew/apt/dnf/pacman)
  • src/legacy/mod.rs — legacy shell support (init.sh generation, rc file patching)
  • src/secrets/ (4 files) — TOML secrets management, flatten, merge, sync with Forgejo
  • src/services/mod.rs — Hero service management (hero_proc, aibroker, browser_mcp)
  • src/skills/mod.rs — Skills repo sync and rsync installation

Examples (5):

  • examples/forge_list.rs, forge_info.rs, init_env.rs, secrets_source.rs, install_base.rs

Workspace registration:

  • Modified Cargo.toml — added crates/tools to workspace members and dependencies

Test Results

  • 72 unit tests: all passed
  • 34 doc-tests: all passed
  • Total: 106 tests, 0 failures

OS Module Reuse

Leverages herolib_os extensively: git (GitTree, GitRepo, GitCloneBuilder), process (run_command), os::fs, os::platform, os::package, rsync (RsyncBuilder)

## Implementation Complete ### Changes Made **New crate: `herolib_tools`** (`crates/tools/`) — reimplements all 9 nushell tool modules in Rust. #### Files Created (25 source files + 5 examples + 1 README) **Crate setup:** - `crates/tools/Cargo.toml` — crate manifest with workspace dependencies - `crates/tools/src/lib.rs` — root module exposing all 9 submodules - `crates/tools/README.md` — documentation with module mapping table **Source modules (9 modules, matching all nushell originals):** - `src/forge/` (7 files) — Forgejo API client, repo CRUD, pull/push/clone, worktrees, name resolution - `src/agent/mod.rs` — AI model configuration for Claude, OpenRouter, Groq, DeepInfra - `src/hero_utils/mod.rs` — disk detection, shell file parsing, string stats, markdown tables - `src/init/mod.rs` — Hero environment initialization (ROOTDIR derivation, path setup) - `src/installers/mod.rs` — platform-aware tool installation (brew/apt/dnf/pacman) - `src/legacy/mod.rs` — legacy shell support (init.sh generation, rc file patching) - `src/secrets/` (4 files) — TOML secrets management, flatten, merge, sync with Forgejo - `src/services/mod.rs` — Hero service management (hero_proc, aibroker, browser_mcp) - `src/skills/mod.rs` — Skills repo sync and rsync installation **Examples (5):** - `examples/forge_list.rs`, `forge_info.rs`, `init_env.rs`, `secrets_source.rs`, `install_base.rs` **Workspace registration:** - Modified `Cargo.toml` — added `crates/tools` to workspace members and dependencies ### Test Results - **72 unit tests**: all passed - **34 doc-tests**: all passed - **Total: 106 tests, 0 failures** ### OS Module Reuse Leverages `herolib_os` extensively: `git` (GitTree, GitRepo, GitCloneBuilder), `process` (run_command), `os::fs`, `os::platform`, `os::package`, `rsync` (RsyncBuilder)
Author
Owner

Implementation committed: 085bee39

Browse: 085bee39

Implementation committed: `085bee39` Browse: https://forge.ourworld.tf/lhumina_code/hero_lib/commit/085bee39
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_lib#123
No description provided.