rhai bindngs for tools #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
implement /Volumes/T7/code0/hero_lib_rhai/crates/tools_rhai
from /Volumes/T7/code0/hero_lib/crates/tools
see how we did it for the others
use skill /rhai_bindings_reference
make good tests
Implementation Spec for Issue #2 — Rhai Bindings for Tools
Objective
Create a new crate
herolib_tools_rhaiatcrates/tools_rhai/that exposes the public API ofherolib_tools(forge, agent, hero_utils, init, installers, legacy, secrets, services, skills) to the Rhai scripting engine, following the established patterns fromos_rhai,ai_rhai, andcode_rhai.Requirements
*_rhaicratesBox<EvalAltResult>consistentlyForgeClient(notClone) viaArcwrapperregister_tools_module(&mut Engine)convenience functionhero_doFiles to Create
crates/tools_rhai/Cargo.toml— Crate manifestcrates/tools_rhai/src/lib.rs— Top-level module +register_tools_module()crates/tools_rhai/src/forge.rs— ForgeClient, ForgeEnv, repo typescrates/tools_rhai/src/agent.rs— ModelConfig, ModelProvidercrates/tools_rhai/src/hero_utils.rs— detect_external_disks, string_stats, etc.crates/tools_rhai/src/init.rs— HeroEnv, derive_rootdir, detect_editorcrates/tools_rhai/src/installers.rs— package manager detection, install functionscrates/tools_rhai/src/legacy.rs— set_pathscrates/tools_rhai/src/secrets.rs— secrets source, sync, toml_to_shcrates/tools_rhai/src/services.rs— HeroService, service statuscrates/tools_rhai/src/skills.rs— skills_sync, skills_editFiles to Modify
Cargo.toml— Add tools_rhai to workspace members and dependenciescrates/hero_do/Cargo.toml— Add herolib_tools_rhai dependencycrates/hero_do/src/lib.rs— Register tools module in engine setupImplementation Plan (13 Steps)
Acceptance Criteria
cargo build -p herolib_tools_rhaisucceedscargo test -p herolib_tools_rhaipassescargo build -p herolib_dosucceeds with new moduleNotes
Arcfor Rhai Clone requirementTest Results
All tests pass cleanly with no warnings from
herolib_tools_rhai.Tests by module:
tests::test_register_tools_module✅agent::tests::test_claude_flags✅agent::tests::test_claude_model_config✅forge::tests::test_parse_repo_input✅forge::tests::test_forge_env_optional✅hero_utils::tests::test_string_stats✅hero_utils::tests::test_detect_external_disks✅init::tests::test_derive_rootdir✅installers::tests::test_detect_package_manager✅secrets::tests::test_secrets_path✅services::tests::test_service_repo✅skills::tests::test_skills_repo_path✅Build verification:
cargo build -p herolib_tools_rhai✅cargo build -p herolib_do(with tools_rhai integrated) ✅Implementation Summary
New crate:
herolib_tools_rhai(crates/tools_rhai/)Created complete Rhai scripting bindings for all 9 submodules of
herolib_tools:hero_utilsstring_stats,detect_external_disks,load_init_sh,to_markdown_table,ls_bigStringStats,FileEntryagentagent_model_config,agent_claude_flagsModelConfiginithero_init,hero_derive_rootdir,hero_detect_editorHeroEnvinstallersdetect_package_manager,ensure_installed,ensure_installed_pkg,install_base,install_ai,install_pylegacylegacy_set_pathssecretssecrets_source,secrets_path,secrets_toml_to_sh,secrets_sync_builderSecretsSyncResult,SecretsSyncforgeforge_client,forge_env_from_env,forge_env_from_env_optional,is_online,user,list,list_all,find,info,resolve,create_repo,delete_repo,rename_repo,ensure_local,pull,push,clone_repo_to,forge_parse_repo_input,forge_resolve_localForgeClient,ForgeEnv,RepoSummary,RepoDetail,UserInfo,RepoInfoservicesis_service_running,service_repo,ensure_service,start_serviceServiceResultskillsskills_repo_path,skills_edit,skills_syncSkillsSyncResultFiles created (11):
crates/tools_rhai/Cargo.tomlcrates/tools_rhai/src/lib.rscrates/tools_rhai/src/agent.rscrates/tools_rhai/src/forge.rscrates/tools_rhai/src/hero_utils.rscrates/tools_rhai/src/init.rscrates/tools_rhai/src/installers.rscrates/tools_rhai/src/legacy.rscrates/tools_rhai/src/secrets.rscrates/tools_rhai/src/services.rscrates/tools_rhai/src/skills.rsFiles modified (3):
Cargo.toml— Addedtools_rhaito workspace members and dependenciescrates/hero_do/Cargo.toml— Addedherolib_tools_rhaidependencycrates/hero_do/src/lib.rs— Registered tools module in engine setupKey design decisions:
ForgeClientwrapped inArcfor RhaiClonerequirementBox<EvalAltResult>consistentlyPathBuffields converted toStringin Rhai wrapper typesForgeClientuse it as the first (&mut) parameter for Rhai compatibilityImplementation committed:
c3f6375Browse:
c3f6375