@neta-art/cohub-cli 2.2.9 → 2.2.10

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.
@@ -252,6 +252,85 @@ async function sendPrompt(command, words, opts) {
252
252
  handleHttp(e);
253
253
  }
254
254
  }
255
+ async function runCompletionCommand(command, words, opts) {
256
+ const spaceId = resolveSpace(command);
257
+ const content = words.join(" ").trim();
258
+ if (!content && process.stdin.isTTY) {
259
+ return error("Message required", "Pass content args or pipe via stdin");
260
+ }
261
+ let text = content;
262
+ if (!text && !process.stdin.isTTY) {
263
+ const chunks = [];
264
+ for await (const chunk of process.stdin)
265
+ chunks.push(chunk);
266
+ text = Buffer.concat(chunks).toString().trim();
267
+ }
268
+ if (!text)
269
+ return error("Message required", "Pass content args or pipe via stdin");
270
+ const temperature = opts.temperature !== undefined ? Number(opts.temperature) : undefined;
271
+ if (temperature !== undefined && !Number.isFinite(temperature)) {
272
+ return error("Invalid temperature", "--temperature must be a number");
273
+ }
274
+ const maxTokens = opts.maxTokens !== undefined ? Number(opts.maxTokens) : undefined;
275
+ if (maxTokens !== undefined && (!Number.isFinite(maxTokens) || maxTokens <= 0)) {
276
+ return error("Invalid max tokens", "--max-tokens must be a positive number");
277
+ }
278
+ const thinkingLevel = opts.thinkingLevel?.trim() || undefined;
279
+ if (thinkingLevel
280
+ && !new Set(["off", "minimal", "low", "medium", "high", "xhigh"]).has(thinkingLevel)) {
281
+ return error("Invalid thinking level", "Use off|minimal|low|medium|high|xhigh");
282
+ }
283
+ const client = createClient();
284
+ const input = {
285
+ provider: opts.provider,
286
+ model: opts.model,
287
+ systemPromptPath: opts.systemPrompt,
288
+ messages: [{ role: "user", content: [{ type: "text", text }] }],
289
+ temperature,
290
+ maxTokens,
291
+ thinkingLevel: thinkingLevel,
292
+ };
293
+ try {
294
+ if (opts.stream) {
295
+ const iterator = client.space(spaceId).streamCompletion(input);
296
+ let step = await iterator.next();
297
+ let finalResult = null;
298
+ while (!step.done) {
299
+ const event = step.value;
300
+ if (event.type === "delta") {
301
+ if (!jsonRequested(opts))
302
+ process.stdout.write(event.text);
303
+ }
304
+ else if (event.type === "thinking_delta" && !jsonRequested(opts)) {
305
+ process.stderr.write(event.text);
306
+ }
307
+ step = await iterator.next();
308
+ }
309
+ finalResult = step.value;
310
+ if (jsonRequested(opts))
311
+ return outJson(finalResult);
312
+ process.stdout.write("\n");
313
+ if (finalResult.usage?.totalTokens != null) {
314
+ process.stderr.write(` tokens: ${finalResult.usage.totalTokens}\n`);
315
+ }
316
+ return;
317
+ }
318
+ const result = await client.space(spaceId).completion(input);
319
+ if (jsonRequested(opts))
320
+ return outJson(result);
321
+ const textOut = result.message.content
322
+ .filter((block) => block.type === "text")
323
+ .map((block) => block.text)
324
+ .join("");
325
+ console.log(textOut);
326
+ if (result.usage?.totalTokens != null) {
327
+ process.stderr.write(`\n tokens: ${result.usage.totalTokens}\n`);
328
+ }
329
+ }
330
+ catch (e) {
331
+ handleHttp(e);
332
+ }
333
+ }
255
334
  export function registerPrompt(program) {
256
335
  program
257
336
  .command("prompt [content...]")
@@ -272,6 +351,18 @@ export function registerPrompt(program) {
272
351
  .option("--image <path>", "Attach an image", collectOption, [])
273
352
  .option("--json", "Output as JSON")
274
353
  .action((words, opts) => sendPrompt(program, words, opts));
354
+ program
355
+ .command("completion [content...]")
356
+ .description("Raw LLM completion with full message control")
357
+ .option("-m, --model <model>", "Model name")
358
+ .option("-p, --provider <provider>", "Provider name")
359
+ .option("--system-prompt <path>", "Space-relative system prompt markdown path")
360
+ .option("--stream", "Stream tokens via SSE")
361
+ .option("--temperature <n>", "Sampling temperature")
362
+ .option("--max-tokens <n>", "Maximum output tokens")
363
+ .option("--thinking-level <level>", "Thinking level: off|minimal|low|medium|high|xhigh")
364
+ .option("--json", "Output as JSON")
365
+ .action((words, opts) => runCompletionCommand(program, words, opts));
275
366
  }
276
367
  export function registerSpaces(program) {
277
368
  const spacesCmd = program.command("spaces").description("Space management");
@@ -476,6 +567,19 @@ export function registerSpaces(program) {
476
567
  .option("--image <path>", "Attach an image", collectOption, [])
477
568
  .option("--json", "Output as JSON")
478
569
  .action((words, opts) => sendPrompt(spacesCmd, words, opts));
570
+ // ── spaces completion ──
571
+ spacesCmd
572
+ .command("completion [content...]")
573
+ .description("Raw LLM completion with full message control")
574
+ .option("-m, --model <model>", "Model name")
575
+ .option("-p, --provider <provider>", "Provider name")
576
+ .option("--system-prompt <path>", "Space-relative system prompt markdown path")
577
+ .option("--stream", "Stream tokens via SSE")
578
+ .option("--temperature <n>", "Sampling temperature")
579
+ .option("--max-tokens <n>", "Maximum output tokens")
580
+ .option("--thinking-level <level>", "Thinking level: off|minimal|low|medium|high|xhigh")
581
+ .option("--json", "Output as JSON")
582
+ .action((words, opts) => runCompletionCommand(spacesCmd, words, opts));
479
583
  // ── spaces files ──
480
584
  registerFiles(spacesCmd);
481
585
  // ── spaces sessions ──
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ Common commands:
41
41
  cohub profile avatar ./avatar.png
42
42
  cohub spaces ls
43
43
  cohub -s <space-id> prompt "Fix the failing tests"
44
+ cohub -s <space-id> completion "Summarize AGENTS.md" --system-prompt AGENTS.md --stream
44
45
  cohub -s <space-id> run -- git status
45
46
  cohub sandbox up ./my-project
46
47
  cohub search "release notes"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -16,7 +16,7 @@
16
16
  "@neta-art/generation": "^0.1.12",
17
17
  "commander": "^14.0.3",
18
18
  "sharp": "^0.34.5",
19
- "@neta-art/cohub": "2.8.0"
19
+ "@neta-art/cohub": "2.9.0"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public"