newt_coder/lib.rs
1//! newt-coder — coder plugin closing failure mode T0b.
2//!
3//! Background: see the authoritative knowledge card
4//! `~/workspaces/knowledge/board/drake/2026-05-29_newt-coder-failure-mode-taxonomy.md`.
5//!
6//! The default `newt worker` (newt-flat) sends the operator's task
7//! prompt verbatim with no file contents, then asks the model to emit
8//! a unified diff. Local Ollama coder models reliably invent
9//! plausible-but-wrong context lines under that contract — apply_patch
10//! rejects the patch on context mismatch and the workspace diff stays
11//! empty (failure mode T0b).
12//!
13//! newt-coder is the opinionated path: it scans the workspace for
14//! files the task mentions, injects them verbatim into the user
15//! message, and asks the model to emit each updated file in full
16//! (no fences, no prose, no diffs). The reply is parsed by
17//! `normalize_emission` and the changes are written to the workspace;
18//! the caller then captures a real diff via `git diff`.
19//!
20//! Activation:
21//! - env: `NEWT_CODER=1`, or
22//! - per-session ACP param: `{ "coder": true }` on `new_session`.
23//!
24//! Both are checked by `newt-acp-worker`. The legacy newt-flat path is
25//! the default and remains unchanged.
26
27pub mod coder;
28pub mod emission;
29pub mod error;
30pub mod prompt;
31pub mod workspace_scan;
32
33#[cfg(feature = "pyo3")]
34pub mod pyo3_module;
35
36pub use coder::{Coder, CoderRun};
37pub use emission::{normalize_emission, Emission};
38pub use error::{CoderError, Result};
39pub use prompt::{build_prompt, CoderPrompt, DEFAULT_CONTEXT_CAP_CHARS, WHOLE_FILE_SYSTEM_PROMPT};
40pub use workspace_scan::scan_workspace_for_files;