module ContextPackPlanner
Overview
Pack documents into a token budget, highest priority first. Greedy packing is a rule of thumb: it is deterministic and easy to read, but it is not an optimal selection. Token counts are your own estimates.
Defined in:
context_pack_planner.crConstant Summary
-
REQUIRED =
["doc_id", "tokens", "priority"] of ::String -
USAGE =
"usage: context-pack-planner docs.csv --budget 1000\nCSV columns: doc_id, tokens, priority. The budget is set by you and the token counts are your own estimates; greedy packing is a rule of thumb, not an optimal selection. More: https://www.onegtmlab.dev/glossary/context-engineering" -
VERSION =
"1.0.0"
Class Method Summary
-
.cli(args : Array(String), stdout : IO, stderr : IO) : Int32
Command line entry.
-
.parse_csv(text : String) : Array(Array(String))
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark.
-
.plan(docs : Array(Doc), budget : Int64) : Plan
Sort by priority (high first), then tokens (small first), then doc_id.
- .read_docs(text : String) : Array(Doc)
- .render(plan : Plan) : String
- .table(rows : Array(Array(String))) : String
Class Method Detail
Command line entry. Returns the exit code: 0 ok, 1 bad input or file, 2 usage.
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.
Sort by priority (high first), then tokens (small first), then doc_id. Add each document that still fits; skip the rest and keep going.