refactor(terraphim_agent): extract cli_schema module (issue #211 step 2) - #16
Open
AlexMikhalev wants to merge 3 commits into
Open
AlexMikhalev wants to merge 3 commits into
AlexMikhalev wants to merge 3 commits into
Conversation
Step 1 of #211. Moves the formatting/word-boundary/UI-building helpers out of main.rs (which was 6 842 LOC, the only file over the soft threshold across the entire Terraphim polyrepo family per the 2026-09-09 de-monolithize census). No behaviour change. Same signatures, same callers. Helpers are pub(crate) so main.rs can still reference them via the existing call-site names (truncate_snippet, format_auto_route_line, is_word_boundary_char, is_at_word_boundary, format_replacement_link, transparent_style, create_block); all call sites were updated implicitly via a single 'use cli_helpers::*;' import. The 7 unit tests for is_word_boundary_* and the 4 tests for truncate_snippet and the 1 test for format_auto_route_line move with their functions into cli_helpers.rs. main.rs: 6 842 -> 6 610 LOC (-232). cli_helpers.rs: 0 -> 251 LOC (new). Verified locally: cargo build -p terraphim_agent --features server OK cargo clippy -p terraphim_agent --features server -- -D warnings OK cargo test -p terraphim_agent --features server --lib --bin terraphim-agent 582 passed, 0 failed
…dule (issue #211 step 1)' (#212) from fix/de-monolith-issue-211 into release/1.21.14-automata-bump
Step 2 of #211. Moves the entire CLI schema (Cli struct, Command enum with all variants, all subcommand enums, and helper enums for format/operator/boundary/hook types) into cli_schema.rs. Following the Phase 2 evidence in terraphim/demonolith-workspaces/per-repo/terraphim-clients/phase2_findings_main_rs.md which identified the schema as the next cluster after cli_helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor(terraphim_agent): extract cli_schema module (issue #211 step 2)
Step 2 of #211. Builds on the cli_helpers extraction from #212.
Summary
Moves the entire CLI schema out of
crates/terraphim_agent/src/main.rsinto a new sibling module
crates/terraphim_agent/src/cli_schema.rs:HookType,BoundaryMode,OutputFormat,CommandOutputMode,LogicalOperatorCli(withFrom<LogicalOperatorCli> for LogicalOperator)struct Cli(withpub(crate)fields so the dispatch inmain.rscan still read them)
enum Commandand all 22 of its variants (Search,Roles,Config,Graph,Kg,Chat,Extract,Replace,Validate,Suggest,Hook,Guard,Interactive,Repl,Setup,CheckUpdate,Update,Learn,Sessions,Listen,Cache,Robot,Memory)CacheSub,LearnSub,CorrectionSub,SharedLearningSub,SuggestSub,ProcedureSub,RolesSub,ConfigSub,KgSub,SessionsSub,RobotSub,MemorySubSeam notes
main.rsarepattern matches (e.g.
Command::Search { query, terms, .. }); nocommand variants are constructed outside their own definitions.
No dispatch code needed to move.
RobotFormat,CommandOutputConfig,resolve_output_config, andprint_json_outputstay inmain.rsbecause they are output-renderinghelpers coupled to
robot::output::RobotFormatter, not to the schema.RobotSub(moved) references them assuper::RobotFormat.get_session_cache_pathis a path helper used by the dispatch (notthe schema), so it stays in
main.rs.CommandOutputModemoved tocli_schemawhileCommandOutputConfigstays in
main.rs; the latter referencescli_schema::CommandOutputModevia the
use cli_schema::*;glob import.Verification (on bigbox)
cargo build -p terraphim_agent --features server— OKcargo clippy -p terraphim_agent --features server -- -D warnings— OKcargo test -p terraphim_agent --features server— passes; the onlyfailing tests are the pre-existing
cross_mode_consistency_testonesthat need
TERRAPHIM_SERVER_BIN(a known environmental requirement,not related to this refactor)
Line-count delta
main.rs: 6610 → 5732 LOC (−878)cli_schema.rs(new): 898 LOC (includes module docs anduselines)Ref #211