Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[package]
name = "specsync"
version = "3.2.0"
version = "3.3.0"
edition = "2024"
rust-version = "1.85"
description = "Bidirectional spec-to-code validation with schema column checking — 11 languages, single binary"
license = "MIT"
readme = "README.md"
homepage = "https://github.com/CorvidLabs/spec-sync"
repository = "https://github.com/CorvidLabs/spec-sync"
keywords = ["spec", "documentation", "validation", "coverage"]
keywords = ["spec", "documentation", "validation", "coverage", "code-quality"]
categories = ["development-tools", "command-line-utilities"]
exclude = ["tests/", "specs/", ".github/", ".specsync/"]

[[bin]]
name = "specsync"
Expand All @@ -23,6 +25,7 @@ walkdir = "2"
colored = "3"
notify = "7"
notify-debouncer-full = "0.4"
sha2 = "0.10"
ureq = { version = "3", features = ["json"] }

[dev-dependencies]
Expand Down
20 changes: 14 additions & 6 deletions src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ const MAX_FILE_CHARS: usize = 30_000;
const MAX_PROMPT_CHARS: usize = 150_000;
const DEFAULT_AI_TIMEOUT_SECS: u64 = 120;

/// Truncate a string to at most `max_bytes` bytes on a valid UTF-8 char boundary.
fn safe_truncate(s: &str, max_bytes: usize) -> &str {
if s.len() <= max_bytes {
return s;
}
let mut end = max_bytes;
while end > 0 && !s.is_char_boundary(end) {
end -= 1;
}
&s[..end]
}

/// A resolved provider ready to execute — either a CLI command or a direct API call.
#[derive(Debug, Clone)]
pub enum ResolvedProvider {
Expand Down Expand Up @@ -274,7 +286,7 @@ fn build_prompt(
let truncated = if content.len() > MAX_FILE_CHARS {
format!(
"{}\n\n[... truncated at {MAX_FILE_CHARS} chars ...]",
&content[..MAX_FILE_CHARS]
safe_truncate(content, MAX_FILE_CHARS)
)
} else {
content.clone()
Expand Down Expand Up @@ -679,11 +691,7 @@ fn build_regen_prompt(
prompt.push_str(&format!("(Skipping {path} — size budget exceeded)\n\n"));
continue;
}
let truncated = if content.len() > 30_000 {
&content[..30_000]
} else {
content.as_str()
};
let truncated = safe_truncate(content, 30_000);
prompt.push_str(&format!("### `{path}`\n\n```\n{truncated}\n```\n\n"));
total_len += truncated.len();
}
Expand Down
Loading
Loading