Skip to content

Add library support for using codey as a Rust dependency#41

Merged
tcdent merged 4 commits intomainfrom
claude/library-refactor-6QbUF
Jan 19, 2026
Merged

Add library support for using codey as a Rust dependency#41
tcdent merged 4 commits intomainfrom
claude/library-refactor-6QbUF

Conversation

@tcdent
Copy link
Owner

@tcdent tcdent commented Jan 19, 2026

  • Add lib.rs with public exports for Agent, ToolRegistry, and core types
  • Add [lib] and [[bin]] sections to Cargo.toml
  • Add Default impl for AgentRuntimeConfig for easier library usage
  • Move SUB_AGENT_PROMPT from app.rs to spawn_agent.rs (removes cross-module dependency)
  • Move CODEY_DIR/TRANSCRIPTS_DIR constants to transcript.rs
  • Create LIBRARY.md with usage documentation and examples
  • Re-export commonly used types at crate root for convenience

Enables using codey as a library to create custom AI agents with
configurable system prompts and tool selections.

- Add lib.rs with public exports for Agent, ToolRegistry, and core types
- Add [lib] and [[bin]] sections to Cargo.toml
- Add Default impl for AgentRuntimeConfig for easier library usage
- Move SUB_AGENT_PROMPT from app.rs to spawn_agent.rs (removes cross-module dependency)
- Move CODEY_DIR/TRANSCRIPTS_DIR constants to transcript.rs
- Create LIBRARY.md with usage documentation and examples
- Re-export commonly used types at crate root for convenience

Enables using codey as a library to create custom AI agents with
configurable system prompts and tool selections.
- Remove public exposure of built-in tools (too coupled to UI)
- Remove public exposure of IDE module
- Keep only essential exports: Agent, AgentStep, RequestMode, Usage,
  AgentRuntimeConfig, ToolRegistry
- Update LIBRARY.md with simpler documentation
- Add Usage export to llm module

The library now focuses on creating agents with custom system prompts.
Users who need tool capabilities can implement their own tool layer
outside of codey.
- Add SimpleTool struct that implements Tool trait with minimal requirements
- Users define name, description, and JSON schema
- Tool execution is handled by the user via AgentStep::ToolRequest
- Export SimpleTool and ToolCall from lib.rs
- Update LIBRARY.md with comprehensive custom tool documentation

This enables library users to create agents with custom tools while
keeping the implementation simple - they handle tool execution themselves
rather than using the internal effect pipeline.
- Add CODEY_DIR and TRANSCRIPTS_DIR constants to config.rs
- Create prompts.rs with all system prompts (SYSTEM_PROMPT,
  COMPACTION_PROMPT, SUB_AGENT_PROMPT, WELCOME_MESSAGE)
- Update app.rs to import from config and prompts modules
- Update transcript.rs to import paths from config
- Update spawn_agent.rs to import prompt from prompts module
- Add prompts module to lib.rs and main.rs

This removes the cross-module dependencies that required importing
from app.rs, making the codebase cleaner and avoiding issues with
library builds.
@tcdent tcdent merged commit 6aa1700 into main Jan 19, 2026
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.

2 participants