Expand description
The knowledge_base workspace API-surface technique (#669), with a
pluggable language-pack model.
A language pack is pure DATA (crate::config::LanguagePack): file
extensions, entry-point file globs, and regex symbol-extraction rules with
free-form kind labels. So adding a language is config, not code.
- Built-in packs (first-class): Rust, Python, Bash, C/C++, Go, Java —
see
builtin_packs. They double as the canonical examples. - External packs: drop a
<name>.tomlinto~/.newt/language-packs/(global) or.newt/language-packs/(project-local), or inline under[[context.api_surface.language_packs]]. Packs merge byname, so a community pack (Ruby, Swift, Objective-C, …) adds or overrides without ever touching the binary. Seedocs/language-packs.md+examples/language-packs/.
The rendered surface rides the frozen system prompt — the compressor’s
protected head ([super::agentic::compress] head_len) — so it is a stable
base that is never summarized (#661 group E).
§Extraction engine: regex is the BOOTSTRAP; AST (tree-sitter) is the target
Per-line regex rules are a deliberate bootstrap — fragile for real code
(multi-line declarations, macros, generics, attributes). The right engine
is an AST parser (tree-sitter): a pack becomes a grammar + a tree-sitter
query, and the query — like the regex rules here — is pluggable DATA. The
architecture is chosen so that swap is local: extensions / entry_points /
merge-by-name / drop-in loading are all engine-agnostic; only the per-pack
extraction rules change shape (regex → query). Tracked as a follow-up.
Structs§
- ApiSurface
Provider - Injects the workspace’s public API surface into the system prompt, driven by a resolved set of language packs.
Functions§
- builtin_
packs - The first-class built-in language packs (Rust, Python, Bash, C/C++, Go, Java).
These also serve as the worked examples a contributor copies —
newt language-pack template <lang>emits one to a drop-in file. Best-effort regexes (a surface, not a parser); override any of them by name with your own pack. - load_
packs_ from_ dir - Load language packs from a drop-in directory (
<dir>/*.toml, one pack per file). A malformed pack file is skipped with a warning, never fatal — the same “drop-in, tolerant” contract as the[backends]directory. A missing directory yields[]. - merge_
packs - Merge pack layers by name — later layers win (built-ins < global dir <
project dir < inline config). A custom pack named
rustreplaces the built-inrust; a new name adds a language. Output order is stable (insertion order of first appearance, then last value wins).