diff options
| author | Adam Malczewski <[email protected]> | 2026-06-05 21:20:34 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-05 21:20:34 +0900 |
| commit | 552c22d74e5df915088d9e9ff4a286c96c2a54d6 (patch) | |
| tree | 7d9db1052bab91ef994446d80efc3bfc38026cad /packages/cli/src/ndjson.ts | |
| parent | 7fb3269c698ae583ea7997ce206c4ae252fd3218 (diff) | |
| download | dispatch-552c22d74e5df915088d9e9ff4a286c96c2a54d6.tar.gz dispatch-552c22d74e5df915088d9e9ff4a286c96c2a54d6.zip | |
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.
Diffstat (limited to 'packages/cli/src/ndjson.ts')
| -rw-r--r-- | packages/cli/src/ndjson.ts | 18 |
1 files changed, 18 insertions, 0 deletions
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 }; +} |
