convert researcher to rust #7
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_researcher#7
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?
use skill /hero_crates_best_practices_check
use ai client from /herolib_ai
convert all to rust
Implementation Spec for Issue #7: Convert researcher to Rust
Objective
Rewrite hero_researcher from TypeScript/Bun to Rust, using herolib_ai for AI calls, following hero crate workspace conventions.
Current Architecture
The existing TypeScript project is an AI-powered research assistant that:
Requirements
Workspace Structure
Implementation Plan (10 Steps)
Step 1: Scaffold Workspace and Build Infrastructure
Create workspace Cargo.toml, all crate Cargo.tomls, Makefile, buildenv.sh, scripts, .gitignore, minimal stubs.
Step 2: Core Types, Error Handling, and Config
Port types.ts, config.ts, validation.ts, logger.ts → error.rs, types.rs, config.rs, logger.rs
Step 3: Search Providers
Port all 6 search providers + aggregator + key rotator + factory
Step 4: Scraper and Platform Scrapers
Port generic scraper + 8 platform scrapers + evidence building
Step 5: Research Prompts and Audit Log
Port prompt templates + audit logging
Step 6: Core Researcher Logic
Port the main Researcher struct with full research pipeline using herolib_ai
Step 7: Report Formatter
Port markdown/JSON/HTML formatters
Step 8: CLI Binary
Port CLI with clap, matching current interface
Step 9: Web Server and Database
Port web server with SSE + SQLite persistence
Step 10: Testing, Documentation, and Cleanup
Tests, docs, README, remove TypeScript files
Acceptance Criteria
cargo check --workspacepassescargo test --workspacepassesNotes
Updated Implementation Spec for Issue #7: Convert researcher to Rust
Updated Plan — Added Phase 0: Expand herolib_ai
Based on gap analysis, herolib_ai at
/Volumes/T7/code0/hero_lib/crates/aineeds the following additions before we can port hero_researcher:Critical Gaps to Fix in herolib_ai:
:onlinesuffix for models that support online searchresponse_formatsupport for JSON modeWhat herolib_ai already supports (no changes needed):
Revised 12-Step Plan
Step 0A: Add missing models to herolib_ai
Add Claude Opus 4.6, Claude Sonnet 4.5, Gemini 3 Flash Preview, Gemini 3 Pro Preview to Model enum with provider mappings. Write tests.
Step 0B: Add custom model ID support to herolib_ai
Allow passing arbitrary model ID strings (e.g.,
"anthropic/claude-opus-4.6") alongside the Model enum. Needed for OpenRouter's full model catalog. Write tests.Step 0C: Add online mode support to herolib_ai
Support
:onlinesuffix for models that enable online search capability. Write tests.Step 0D: Add structured JSON output to herolib_ai
Add
response_formatparameter support for JSON mode output. Write tests.Step 0E: Add rate limiting to herolib_ai
Token bucket rate limiter, configurable RPM (default 60). Write tests.
Steps 1-10: Same as original spec
Key Change
All herolib_ai improvements (Steps 0A-0E) will be done first with independent tests, in the hero_lib repo. Then hero_researcher conversion (Steps 1-10) proceeds using the expanded AI client.
Test Results
Build
cargo check --workspace: PASS (all 3 crates compile)cargo clippy --workspace: PASS (3 minor style warnings, no errors)cargo fmt: PASS (all code formatted)Tests
cargo test --workspace: PASS (0 failures)Crates
herolib_ai Expansion (in hero_lib repo)
chat_with_raw_model)raw_model()andjson_mode()methodscargo test -p herolib_ai: 48 unit tests + 3 doc tests PASSImplementation Summary
What was done
herolib_ai expansion (in hero_lib repo):
chat_with_raw_model()for arbitrary model IDs via OpenRouterResponseFormatsupport for JSON moderaw_model()andjson_mode()to PromptBuilderhero_researcher conversion to Rust:
Changes summary
Build status
cargo check --workspace: PASScargo clippy --workspace: PASS (3 minor warnings)cargo test --workspace: PASScargo fmt: PASSImplementation committed:
44a311bf2caeb8686f3bd31157b6e61509b70045Browse:
44a311bf2c