@parker-brown-family/triage
v0.1.0
Published
Deterministic regex-based intent classifier. Labels an utterance as directive, constraint, question, preference, or exploration without calling an LLM.
Maintainers
Readme
triage
Deterministic regex-based intent classifier. Labels an utterance as
directive, constraint, question, preference, or exploration
without calling an LLM.
Most tooling that wants to "classify this utterance" reaches for an LLM immediately and pays per call. A well-tuned regex classifier handles the common cases instantly, for free, and with auditable rules.
Install
npm install @parker-brown-family/triage
# or
bun add @parker-brown-family/triageUse — library
import { classify } from "@parker-brown-family/triage";
classify("We must add rate limiting before launch.");
// {
// label: "directive",
// confidence: 0.9,
// hits: { directive: 3, constraint: 0, question: 0, preference: 0, exploration: 0 }
// }
classify("What if we cache it client-side?");
// { label: "exploration", confidence: 0.3, ... }
classify("The signup form cannot block on external services.");
// { label: "constraint", confidence: 0.7, ... }Use — CLI
echo "Maybe we should cache this." | triage
# {"label":"exploration","confidence":0.3,"hits":{...}}
triage "Users must be able to cancel a booking."
# {"label":"directive","confidence":0.9,"hits":{...}}Label set
| Label | Signal |
|---|---|
| directive | must / shall / should / implement / add / ensure |
| constraint | cannot / must not / prohibited / at most / maximum |
| question | ? / how do / what is / can we |
| preference | prefer / would like / nice to have / ideally |
| exploration | maybe / what if / wondering / consider |
Precedence
Exploration markers win when present (they signal non-commitment). Constraints win over directives (negation inverts intent). Question marks win when directive signal is weak. Otherwise highest hit count wins.
Custom patterns
Extend the defaults by merging your own regex list into a single category. Unspecified categories fall back to the built-in set.
import { classify, DEFAULT_PATTERNS } from "@parker-brown-family/triage";
const patterns = {
...DEFAULT_PATTERNS,
directive: [
...DEFAULT_PATTERNS.directive,
/\bship\b/i,
/\broll\s+out\b/i,
],
};
classify("Ship the new pricing page by Friday.", { patterns });
// { label: "directive", ... }Provenance
Pattern set originally ported from
GroundTruth-KB
(AGPL-3.0) — src/groundtruth_kb/intake.py. Reimplemented in TypeScript
under MIT with extended test coverage and a public API.
License
MIT
