zencefyl 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli/headless.ts
4
+ async function readStdin() {
5
+ if (process.stdin.isTTY) return "";
6
+ const chunks = [];
7
+ for await (const chunk of process.stdin) chunks.push(chunk);
8
+ return Buffer.concat(chunks).toString("utf8").trim();
9
+ }
10
+ async function runHeadless(engine, prompt) {
11
+ for await (const delta of engine.sendMessage(prompt)) {
12
+ if (delta.type === "text") process.stdout.write(delta.text);
13
+ if (delta.type === "done") break;
14
+ }
15
+ process.stdout.write("\n");
16
+ }
17
+ async function resolveHeadlessPrompt() {
18
+ const args = process.argv.slice(2).filter((a) => a !== "-p" && a !== "--print");
19
+ const promptArg = args.find((a) => !a.startsWith("-"));
20
+ if (promptArg) return promptArg;
21
+ const stdin = await readStdin();
22
+ if (stdin) return stdin;
23
+ return null;
24
+ }
25
+ export {
26
+ resolveHeadlessPrompt,
27
+ runHeadless
28
+ };
29
+ //# sourceMappingURL=headless-B5GW5RGP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/headless.ts"],"sourcesContent":["// Non-interactive output mode — used when zencefyl is invoked with -p / --print.\n// Streams the response directly to stdout and exits. No Ink, no animations.\n// Usage: zencefyl -p \"question\" or echo \"question\" | zencefyl -p\n\nimport type { Engine } from '../core/engine.js'\nimport type { Container } from '../bootstrap/container.js'\n\n// Read all of stdin into a string (for piped input).\nasync function readStdin(): Promise<string> {\n if (process.stdin.isTTY) return '' // interactive — no piped content\n const chunks: Buffer[] = []\n for await (const chunk of process.stdin) chunks.push(chunk as Buffer)\n return Buffer.concat(chunks).toString('utf8').trim()\n}\n\n// Run a single headless prompt: stream response to stdout, then exit.\nexport async function runHeadless(\n engine: Engine,\n prompt: string,\n): Promise<void> {\n for await (const delta of engine.sendMessage(prompt)) {\n if (delta.type === 'text') process.stdout.write(delta.text)\n if (delta.type === 'done') break\n }\n process.stdout.write('\\n')\n}\n\n// Entry point for headless mode — resolves the prompt from args or stdin.\nexport async function resolveHeadlessPrompt(): Promise<string | null> {\n // Find first non-flag argument after the binary name\n const args = process.argv.slice(2).filter(a => a !== '-p' && a !== '--print')\n const promptArg = args.find(a => !a.startsWith('-'))\n if (promptArg) return promptArg\n\n // No arg — try reading from stdin (piped input)\n const stdin = await readStdin()\n if (stdin) return stdin\n\n return null\n}\n"],"mappings":";;;AAQA,eAAe,YAA6B;AAC1C,MAAI,QAAQ,MAAM,MAAO,QAAO;AAChC,QAAM,SAAmB,CAAC;AAC1B,mBAAiB,SAAS,QAAQ,MAAO,QAAO,KAAK,KAAe;AACpE,SAAO,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK;AACrD;AAGA,eAAsB,YACpB,QACA,QACe;AACf,mBAAiB,SAAS,OAAO,YAAY,MAAM,GAAG;AACpD,QAAI,MAAM,SAAS,OAAQ,SAAQ,OAAO,MAAM,MAAM,IAAI;AAC1D,QAAI,MAAM,SAAS,OAAQ;AAAA,EAC7B;AACA,UAAQ,OAAO,MAAM,IAAI;AAC3B;AAGA,eAAsB,wBAAgD;AAEpE,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC,EAAE,OAAO,OAAK,MAAM,QAAQ,MAAM,SAAS;AAC5E,QAAM,YAAY,KAAK,KAAK,OAAK,CAAC,EAAE,WAAW,GAAG,CAAC;AACnD,MAAI,UAAW,QAAO;AAGtB,QAAM,QAAQ,MAAM,UAAU;AAC9B,MAAI,MAAO,QAAO;AAElB,SAAO;AACT;","names":[]}