diff --git a/.gitignore b/.gitignore index 8e24cb07..bcc08937 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ PROMPT.md PROMPT-*.md PROMPT.MD PROMPT-*.MD + +# Local Code Review +src/.vscode/local-reviews/ diff --git a/src/.cargo/documentation.md b/src/.cargo/documentation.md new file mode 100644 index 00000000..dbbaea17 --- /dev/null +++ b/src/.cargo/documentation.md @@ -0,0 +1,7 @@ +# Documentation Rules + +- Document public items with `///`. +- Add examples in docs where helpful. +- Use `//!` for module-level docs. +- Focus comments on why, not what. +- Use [`TypeName`] rustdoc links instead of backticks. diff --git a/src/.cargo/general.md b/src/.cargo/general.md new file mode 100644 index 00000000..5e231494 --- /dev/null +++ b/src/.cargo/general.md @@ -0,0 +1,4 @@ +# General Rules + +- Keep modules under 500 lines excluding tests. +- Place `use` inside functions only for `#[cfg]` conditional compilation. diff --git a/src/.cargo/performance.md b/src/.cargo/performance.md new file mode 100644 index 00000000..1e230794 --- /dev/null +++ b/src/.cargo/performance.md @@ -0,0 +1,24 @@ +# Performance Rules + +## Memory and allocation + +- Preallocate collections when size is known or estimable: + - `String::with_capacity(estimated_len)` + - `Vec::with_capacity(count)` + - `BufReader::with_capacity(size, reader)` +- Prefer `&str` / `&[T]` returns over owned types when lifetime allows. +- Use `Cow<'_, str>` for conditional ownership such as `String::from_utf8_lossy`. +- Use `&'static str` for compile-time constant strings. +- Reuse buffers with `.clear()` instead of reallocating. + +## Zero-cost abstractions + +- Use const generics for compile-time branching such as ``. +- Use `#[inline]` on small hot-path functions. +- Prefer `core` over `std` where possible. +- Stream data instead of loading entire files when possible. + +## Dependencies + +- Prefer performance-oriented crates such as `parking_lot` and `memchr`. +- Keep dependency footprint minimal. diff --git a/src/AGENTS.md b/src/AGENTS.md index 8a8cbfb2..69ed5595 100644 --- a/src/AGENTS.md +++ b/src/AGENTS.md @@ -1,70 +1,2 @@ -Basic coding oriented tools for LLM agents - -# Feature Flags (llm-coding-tools-core) - -- `tokio` (default): Async mode with tokio runtime. Enables async function signatures. -- `blocking`: Sync/blocking mode. Mutually exclusive with `tokio`/`async`. -- `async`: Base async signatures (internal use). Do not enable directly; use `tokio`. - -The `async` and `blocking` features are mutually exclusive - enabling both causes a compile error. - -# Project Structure - -- `llm-coding-tools-core/` - Framework-agnostic core library - - `src/tools/` - Core tool implementations (read, write, edit, glob, grep, bash, etc.) - - `src/path/` - Path resolution (absolute and allowed) - - `src/error.rs` - Unified error types - - `src/output.rs` - Tool output formatting - - `src/util.rs` - Shared utilities -- `llm-coding-tools-serdesai/` - serdesAI framework Tool implementations - - `src/absolute/` - Unrestricted file system tools - - `src/allowed/` - Sandboxed file system tools - - `src/convert.rs` - Type conversions between core and serdesAI - -# Code & Performance Guidelines - -This is a high-performance library. Optimize aggressively. - -## Memory & Allocation - -- Preallocate collections when size is known or estimable: - - `String::with_capacity(estimated_len)` - - `Vec::with_capacity(count)` - - `BufReader::with_capacity(size, reader)` -- Prefer `&str` / `&[T]` returns over owned types when lifetime allows -- Use `Cow<'_, str>` for conditional ownership (e.g., `String::from_utf8_lossy`) -- Use `&'static str` for compile-time constant strings -- Reuse buffers: `.clear()` and reuse `Vec`/`String` instead of reallocating - -## Zero-Cost Abstractions - -- Use const generics for compile-time branching (e.g., ``) -- Use `#[inline]` on small, hot-path functions -- Prefer `core` over `std` where possible (`core::mem` over `std::mem`) - -## I/O Efficiency - -- Stream data instead of loading entire files when possible -- Use `memchr` for fast byte searching over manual iteration - -## Dependencies - -- Prefer performance-oriented crates: `parking_lot` over `std::sync`, `memchr` for byte search -- Keep dependency footprint minimal - -## General - -- Keep modules under 500 lines (excluding tests); split if larger -- Place `use` inside functions only for `#[cfg]` conditional compilation - -# Documentation Standards - -- Document public items with `///` -- Add examples in docs where helpful -- Use `//!` for module-level docs -- Focus comments on "why" not "what" -- Use [`TypeName`] rustdoc links, not backticks. - -# Post-Change Verification - -After code changes, always run `.cargo/verify` script before returning to the user. Search if not found. +After code changes, run `verify` from `.cargo/` or `src/.cargo/` before returning. +Review-only rules files (`general.md`, `performance.md`, `documentation.md`) live alongside `verify` in that directory.