Skip to content

Conversation

@hghalebi
Copy link
Owner

@hghalebi hghalebi commented Dec 30, 2025

TL;DR

Added a comprehensive tutorial and basic usage example for RigScribe.

What changed?

  • Added TUTORIAL.md with detailed instructions on using RigScribe for automated prompt engineering
  • Created a new examples/basic_usage.rs file demonstrating the core functionality
  • Updated .gitignore to exclude logs and debug report files

How to test?

  1. Review the tutorial content in TUTORIAL.md for accuracy and completeness
  2. Run the example with:
    export GEMINI_API_KEY="your_api_key_here"
    cargo run --example basic_usage
  3. Verify that the example correctly generates or loads a cached prompt for the CLI assistant

Why make this change?

To provide clear documentation and practical examples for users getting started with RigScribe. The tutorial explains core concepts like Intent vs. Artifact, ScopeId, caching, and the prompt refinement process, while the example demonstrates the implementation of these concepts in a real-world scenario.


This pull request significantly enhances the user experience by adding comprehensive documentation and a runnable example for the RigScribe library.

Key changes include:

  • Added a detailed TUTORIAL.md: This new guide provides a step-by-step introduction to RigScribe, covering core concepts such as Intent vs. Artifact, ScopeId, and caching. It includes a full code example demonstrating how to generate and optimize system prompts, explains the underlying "Refinery" agent workflow, and outlines advanced usage scenarios.
  • Introduced examples/basic_usage.rs: A new, runnable Rust example is provided, mirroring the code in the tutorial, to demonstrate the basic usage of RigScribe for optimizing system prompts with caching.
  • Updated .gitignore: Added logs and STREAMING_DEBUG_REPORT.md to the ignore list to prevent generated log and debug files from being committed.

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added comprehensive tutorial for RigScribe covering prerequisites, core concepts including Intent vs. Artifact and caching mechanisms, implementation workflows, and advanced usage patterns with detailed code examples
    • Added practical example demonstrating how to optimize system prompts using local caching features
  • Chores

    • Updated gitignore configuration

✏️ Tip: You can customize this high-level summary in your review settings.

@hghalebi hghalebi mentioned this pull request Dec 30, 2025
Copy link
Owner Author

hghalebi commented Dec 30, 2025

.*
.idea
.prompts_perssitense_cache
.prompts_perssitense_cache
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache directory mismatch will cause cache files to be committed to git. The .gitignore specifies .prompts_perssitense_cache but the code uses .prompts_cache (see examples/basic_usage.rs line 14 and TUTORIAL.md line 74). This means the actual cache directory won't be ignored.

Fix by changing to:

.prompts_cache
Suggested change
.prompts_perssitense_cache
.prompts_cache

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@hghalebi hghalebi changed the base branch from doc to graphite-base/15 December 31, 2025 14:47
@hghalebi hghalebi marked this pull request as ready for review December 31, 2025 14:47
@coderabbitai
Copy link

coderabbitai bot commented Dec 31, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

This PR introduces user-facing documentation and a practical example for the RigScribe Rust crate. A new TUTORIAL.md provides an end-to-end guide for prompt engineering automation with caching, while examples/basic_usage.rs demonstrates core API usage patterns. Minor .gitignore updates exclude cache and debug files.

Changes

Cohort / File(s) Summary
Configuration
.gitignore
Adds trailing newline and two new ignore entries: logs and STREAMING_DEBUG_REPORT.md. No functional logic changes.
Documentation
TUTORIAL.md
New file: comprehensive end-to-end guide covering prerequisites, core concepts (Intent vs. Artifact, ScopeId, caching), step-by-step implementation for generating system prompts, and advanced usage patterns including cache bypass and custom cache directories.
Examples
examples/basic_usage.rs
New example demonstrating RigScribe usage: environment validation, caching setup, async prompt optimization workflow with error handling. Illustrates practical API interaction patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A tutorial hops into view,
With examples fresh and cache anew,
Prompts refined by code so keen,
The finest RigScribe scenes we've seen!
With logs ignored and docs so bright,
This PR shines—pure delight!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eac2dbc and 0215785.

📒 Files selected for processing (3)
  • .gitignore
  • TUTORIAL.md
  • examples/basic_usage.rs

Comment @coderabbitai help to get the list of available commands and usage tips.

@kody-ai
Copy link

kody-ai bot commented Dec 31, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Breaking Changes
Cross File
Kody Rules
Code Style
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization

Access your configuration settings here.

.*
.idea
.prompts_perssitense_cache
.prompts_perssitense_cache
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Cross File medium

// In .gitignore, replace the incorrect entry with:
.prompts_cache

There's a mismatch between the cache directory name used in the code and the entry in .gitignore. The code in TUTORIAL.md (line 74) and examples/basic_usage.rs (line 14) creates a directory named .prompts_cache. However, .gitignore is configured to ignore .prompts_perssitense_cache. This will cause the generated cache files to be tracked by git. Let's update .gitignore to match the directory name used in the code.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

```rust
use rigscribe::RigScribe;

let artifact = RigScribe::optimize_agentic("Explain Quantum Physics like a pirate").await?;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

use rigscribe::{RigScribe, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let artifact = RigScribe::optimize_agentic("Explain Quantum Physics like a pirate").await?;
    println!("\n--- Agentic-Optimized System Prompt ---\n");
    println!("{}", artifact.system_prompt);
    Ok(())
}

The code snippet for optimize_agentic is not a complete, runnable example. It uses .await outside of an async function, which will cause a compilation error, preventing users from testing this feature.

To ensure the example is immediately usable, it should be wrapped in a minimal async main function, similar to the primary example in the tutorial. This provides a complete, copy-paste-runnable demonstration of the feature.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

use rigscribe::{RigScribe, ScopeId, Result};
use std::env;

#[tokio::main]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Cross File medium

// In TUTORIAL.md, update the code block to match the example:
use rigscribe::{RigScribe, ScopeId, Result};
use std::env;

#[tokio::main]
async fn main() -> Result<()> {
    // Ensure API key is set
    if env::var("GEMINI_API_KEY").is_err() {
        eprintln!("Error: GEMINI_API_KEY environment variable is not set.");
        return Ok(());
    }

    let scribe = RigScribe::new("./.prompts_cache");
    let raw_request = "I want an AI assistant that helps users write Clap CLI tools in Rust.";
    let feature_id = ScopeId(101);

    println!("Refining prompt for: '{}'...", raw_request);

    match scribe.optimize_with_cache(raw_request, feature_id).await {
        Ok(artifact) => {
            println!("\n--- Optimized System Prompt ---\n");
            println!("{}", artifact.system_prompt);
        }
        Err(e) => {
            eprintln!("Error optimizing prompt: {}", e);
        }
    }
    
    Ok(())
}

The code example in the tutorial (TUTORIAL.md) is a simplified version of the one in examples/basic_usage.rs. The official example includes an important check for the GEMINI_API_KEY and demonstrates more robust error handling with a match statement. To provide users with a more complete and safer starting point, it's best to align the tutorial's code with the best practices shown in the example file. This helps prevent runtime errors and confusion.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

#[tokio::main]
async fn main() -> Result<()> {
// Ensure API key is set
if env::var("GEMINI_API_KEY").is_err() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

    if env::var("GEMINI_API_KEY").is_err() {
        eprintln!("Error: GEMINI_API_KEY environment variable is not set.");
        std::process::exit(1);
    }

    // ...

    let artifact = scribe.optimize_with_cache(raw_request, feature_id).await?;

    println!("\n--- Optimized System Prompt ---\n");
    println!("{}", artifact.system_prompt);
    
    Ok(())

The application currently exits with a success code (0) even when critical errors occur, such as a missing API key or a failure during prompt optimization. This is misleading for users and masks failures in automated scripts.

In command-line applications, it's crucial to signal failure with a non-zero exit code. Since the main function already returns a Result<()>, you should propagate errors instead of just printing them and returning Ok(()).

By using the ? operator, any error from optimize_with_cache will be automatically returned from main, causing the program to exit correctly. For the API key check, explicitly exiting with a non-zero status code achieves the same result.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@hghalebi hghalebi force-pushed the add-auto-generated-docs branch from 477b396 to 82f76ae Compare December 31, 2025 14:51
@hghalebi hghalebi changed the base branch from graphite-base/15 to main December 31, 2025 14:51
@hghalebi hghalebi force-pushed the add-auto-generated-docs branch from 82f76ae to 0215785 Compare December 31, 2025 14:51
@hghalebi hghalebi merged commit 911553d into main Dec 31, 2025
2 of 3 checks passed
Copy link
Owner Author

Merge activity

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