1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! # Module: lib (agent_doc)
//!
//! ## Spec
//! - Exposes the public API surface consumed by the CLI binary, FFI layer, and editor plugins.
//! - Re-exports: `component`, `crdt`, `debounce`, `ffi`, `frontmatter`, `merge`, `project_config`, `template`.
//! - `component::strip_comments(content)` is the shared entry point for comment stripping,
//! usable by both the binary (`diff::compute`) and external crates (`eval-runner`).
//! - Provides two boundary-ID utilities used across all write paths:
//! - `new_boundary_id()` — 8-hex-char UUID v4 prefix (length controlled by `BOUNDARY_ID_LEN`).
//! - `new_boundary_id_with_summary(summary)` — same ID optionally suffixed with a 3-word,
//! 20-char-max slug derived from `summary` (format: `a0cfeb34:boundary-fix`).
//! - `format_boundary_marker(id)` — renders the canonical HTML comment form
//! `<!-- agent:boundary:<id> -->` used in document component boundaries.
//! - `BOUNDARY_ID_LEN = 8` is a public constant; callers may read but should not override.
//!
//! ## Agentic Contracts
//! - All public symbols are safe to call from FFI consumers (JNA, napi-rs) via `ffi` module.
//! - `new_boundary_id` is non-deterministic (UUID v4); callers must not rely on ordering.
//! - `new_boundary_id_with_summary(None)` and `new_boundary_id_with_summary(Some(""))` both
//! return a plain 8-char ID with no suffix.
//! - Slug derivation: lowercase, non-alphanumeric chars → `-`, collapse runs, take first 3 words,
//! truncate to 20 chars.
//!
//! ## Evals
//! - new_boundary_id_len: result is exactly `BOUNDARY_ID_LEN` chars of hex
//! - new_boundary_id_with_summary_none: `None` summary → plain 8-char hex
//! - new_boundary_id_with_summary_empty: `Some("")` → plain 8-char hex
//! - new_boundary_id_with_summary_slug: `Some("Boundary Fix")` → `"<id>:boundary-fix"`
//! - new_boundary_id_with_summary_truncate: long summary → slug capped at 20 chars
//! - format_boundary_marker: `"abc123"` → `"<!-- agent:boundary:abc123 -->"`
/// Default number of hex characters for boundary IDs.
pub const BOUNDARY_ID_LEN: usize = 8;
/// Generate a new boundary ID (short hex string from UUID v4).
/// Generate a boundary ID with an optional summary suffix.
///
/// Format: `a0cfeb34` or `a0cfeb34:boundary-fix` (with summary).
/// The summary is slugified (lowercase, non-alphanumeric → `-`, max 20 chars).
/// Format a boundary marker comment.