| Crates.io | scribe-webservice |
| lib.rs | scribe-webservice |
| version | 0.5.1 |
| created_at | 2025-09-17 16:02:31.544246+00 |
| updated_at | 2025-12-01 20:16:41.534914+00 |
| description | Web service interface for Scribe repository analysis |
| homepage | https://github.com/sibyllinesoft/scribe |
| repository | https://github.com/sibyllinesoft/scribe |
| max_upload_size | |
| id | 1843541 |
| size | 227,902 |
Web service interface for Scribe repository analysis and interactive bundle editing.
scribe-webservice provides a RESTful API and interactive web UI for Scribe's repository analysis capabilities. It enables browser-based repository exploration, real-time bundle customization, and integration with web-based development tools. The service is built on Axum, a high-performance async web framework.
HTTP Request → Axum Router → Service Layer → Scribe Core → Response
↓ ↓ ↓ ↓ ↓
JSON Body Path Matching Analysis Scanner JSON/HTML
+ Query + Middleware Orchestration + Graph + Headers
Params + Selection
↓ ↓
CORS Async Tokio
Logging Processing
ScribeServiceMain service orchestrator:
ApiHandlersHTTP request handlers:
POST /api/analyze: Full repository analysisPOST /api/covering-set: Surgical entity selectionGET /api/health: Service health and metricsGET /api/config: Current configurationPOST /api/config: Update configurationBundleRendererGenerates output in multiple formats:
StaticAssetServerServes web UI resources:
use scribe_webservice::{ScribeService, ServiceConfig};
#[tokio::main]
async fn main() -> Result<()> {
let config = ServiceConfig {
host: "127.0.0.1".to_string(),
port: 8080,
token_budget: 100_000,
max_file_size: 1_000_000,
..Default::default()
};
let service = ScribeService::new(config);
service.start().await?;
println!("Scribe service running on http://127.0.0.1:8080");
Ok(())
}
The service is exposed via the Scribe CLI:
# Start service and open browser
scribe --port 8080 --open-browser
# Specify repository
scribe /path/to/repo --port 9000
# Custom configuration
scribe --port 8080 --token-budget 150000 --max-file-size 2000000
# Generate HTML bundle with editor
scribe --style html --editor --output bundle.html
curl -X POST http://localhost:8080/api/analyze \
-H "Content-Type: application/json" \
-d '{
"repo_path": "/path/to/repo",
"token_budget": 100000,
"exclude_tests": true,
"algorithm": "simple_router"
}'
Response:
{
"status": "success",
"files_selected": 156,
"total_tokens": 98534,
"analysis_time_ms": 1234,
"bundle_url": "/api/bundle/abc123"
}
curl -X POST http://localhost:8080/api/covering-set \
-H "Content-Type: application/json" \
-d '{
"repo_path": "/path/to/repo",
"entity_name": "authenticate_user",
"entity_type": "function",
"max_files": 20,
"max_depth": 3
}'
Response:
{
"status": "success",
"files": [
{
"path": "src/auth.rs",
"reason": "Target",
"depth": 0
},
{
"path": "src/db.rs",
"reason": "DirectDependency",
"depth": 1
}
]
}
curl http://localhost:8080/api/health
Response:
{
"status": "healthy",
"version": "0.5.1",
"uptime_seconds": 12345,
"requests_processed": 42,
"cache_hit_rate": 0.75
}
use scribe_webservice::{ApiClient, AnalyzeRequest};
let client = ApiClient::new("http://localhost:8080")?;
let request = AnalyzeRequest {
repo_path: PathBuf::from("."),
token_budget: 100_000,
exclude_tests: true,
algorithm: Algorithm::SimpleRouter,
};
let response = client.analyze(request).await?;
println!("Selected {} files", response.files_selected);
println!("Bundle available at: {}", response.bundle_url);
The generated HTML bundle includes a full-featured editor:
# Generate interactive HTML bundle
scribe --style html --editor --output bundle.html
# Opens in browser automatically
scribe --style html --editor --output bundle.html --open-browser
The HTML bundle is a single file containing:
File size: ~280KB smaller with CDN-linked assets (vs embedded).
Modify templates in templates/ directory:
bundle_editor.hbs: Main HTML structurefile_tree.hbs: Tree component templateassets/styles.cssassets/scribe-tree-bundle.jsRebuild frontend:
cd scribe-rs/frontend
bun run build
cp dist/scribe-tree-bundle.js ../assets/
ServiceConfig| Field | Type | Default | Description |
|---|---|---|---|
host |
String |
"127.0.0.1" |
Bind address |
port |
u16 |
8080 |
HTTP port |
token_budget |
usize |
100_000 |
Default token budget |
max_file_size |
usize |
1_000_000 |
Max file size to process |
max_requests |
usize |
100 |
Rate limit |
request_timeout_secs |
u64 |
300 |
Request timeout (5 min) |
enable_cors |
bool |
true |
CORS support |
log_level |
String |
"info" |
Logging verbosity |
Configure via environment:
SCRIBE_HOST=0.0.0.0
SCRIBE_PORT=9000
SCRIBE_TOKEN_BUDGET=150000
SCRIBE_LOG_LEVEL=debug
RUST_LOG=scribe_webservice=debug
| Method | Path | Description |
|---|---|---|
POST |
/api/analyze |
Full repository analysis |
POST |
/api/covering-set |
Entity-targeted selection |
GET |
/api/bundle/:id |
Retrieve generated bundle |
| Method | Path | Description |
|---|---|---|
GET |
/api/config |
Get current config |
POST |
/api/config |
Update config |
| Method | Path | Description |
|---|---|---|
GET |
/api/health |
Service health check |
GET |
/api/metrics |
Performance metrics |
| Method | Path | Description |
|---|---|---|
GET |
/assets/* |
JavaScript, CSS, fonts |
GET |
/ |
Web UI homepage |
# Run with hot reload
cd scribe-rs
cargo watch -x 'run --bin scribe -- --port 8080'
FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release -p scribe-webservice
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/scribe /usr/local/bin/
EXPOSE 8080
CMD ["scribe", "--port", "8080", "--host", "0.0.0.0"]
Build and run:
docker build -t scribe-webservice .
docker run -p 8080:8080 -v $(pwd):/repo scribe-webservice scribe /repo
For production deployment:
max_requests appropriatelyExample nginx config:
server {
listen 80;
server_name scribe.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
scribe-webservice integrates with:
scribe-scaling: Handles large repository processingscribe-selection: Implements selection algorithms exposed via APItemplates/: Handlebars templates for HTML renderingfrontend/: React-based interactive UI components../../BUNDLE_EDITOR.md: Bundle editor documentation