summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/ndjson.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-05 21:20:34 +0900
committerAdam Malczewski <[email protected]>2026-06-05 21:20:34 +0900
commit552c22d74e5df915088d9e9ff4a286c96c2a54d6 (patch)
tree7d9db1052bab91ef994446d80efc3bfc38026cad /packages/cli/src/ndjson.ts
parent7fb3269c698ae583ea7997ce206c4ae252fd3218 (diff)
downloaddispatch-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.ts18
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 };
+}