From 552c22d74e5df915088d9e9ff4a286c96c2a54d6 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Fri, 5 Jun 2026 21:20:34 +0900 Subject: feat(cli): one-shot terminal client (models, chat, --text/--file/--cwd/--conversation) HTTP client of transport-contract; pure-core arg/render/ndjson + injected fetch/fs shell. Docs: GLOSSARY (credential/key/model name/model catalog), tasks.md milestone, ORCHESTRATOR geography. --- packages/cli/src/ndjson.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 packages/cli/src/ndjson.ts (limited to 'packages/cli/src/ndjson.ts') diff --git a/packages/cli/src/ndjson.ts b/packages/cli/src/ndjson.ts new file mode 100644 index 0000000..57093c1 --- /dev/null +++ b/packages/cli/src/ndjson.ts @@ -0,0 +1,18 @@ +/** + * Pure NDJSON line splitter — zero I/O. + * + * Splits a buffer on newlines, keeping an incomplete trailing line in `rest`. + * Does NOT parse JSON — that is the caller's job. + */ + +export interface SplitResult { + readonly lines: readonly string[]; + readonly rest: string; +} + +export function splitNdjsonLines(buffer: string): SplitResult { + const parts = buffer.split("\n"); + const rest = parts[parts.length - 1] ?? ""; + const lines = parts.slice(0, -1).filter((l) => l.length > 0); + return { lines, rest }; +} -- cgit v1.2.3