@locusai/cli 0.22.10 → 0.22.12

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.
Files changed (2) hide show
  1. package/bin/locus.js +72 -45
  2. package/package.json +2 -2
package/bin/locus.js CHANGED
@@ -4896,39 +4896,49 @@ class ClaudeRunner {
4896
4896
  stdio: ["pipe", "pipe", "pipe"],
4897
4897
  env
4898
4898
  });
4899
+ let flushLineBuffer = null;
4899
4900
  if (options.verbose) {
4900
4901
  let lineBuffer = "";
4901
4902
  const seenToolIds = new Set;
4903
+ const processLine = (line) => {
4904
+ if (!line.trim())
4905
+ return;
4906
+ try {
4907
+ const event = JSON.parse(line);
4908
+ if (event.type === "assistant" && event.message?.content) {
4909
+ for (const item of event.message.content) {
4910
+ if (item.type === "tool_use" && item.id && !seenToolIds.has(item.id)) {
4911
+ seenToolIds.add(item.id);
4912
+ options.onToolActivity?.(formatToolCall(item.name ?? "", item.input ?? {}));
4913
+ }
4914
+ }
4915
+ } else if (event.type === "result") {
4916
+ const text = event.result ?? "";
4917
+ output = text;
4918
+ options.onOutput?.(text);
4919
+ }
4920
+ } catch {
4921
+ const newLine = `${line}
4922
+ `;
4923
+ output += newLine;
4924
+ options.onOutput?.(newLine);
4925
+ }
4926
+ };
4902
4927
  this.process.stdout?.on("data", (chunk) => {
4903
4928
  lineBuffer += chunk.toString();
4904
4929
  const lines = lineBuffer.split(`
4905
4930
  `);
4906
4931
  lineBuffer = lines.pop() ?? "";
4907
4932
  for (const line of lines) {
4908
- if (!line.trim())
4909
- continue;
4910
- try {
4911
- const event = JSON.parse(line);
4912
- if (event.type === "assistant" && event.message?.content) {
4913
- for (const item of event.message.content) {
4914
- if (item.type === "tool_use" && item.id && !seenToolIds.has(item.id)) {
4915
- seenToolIds.add(item.id);
4916
- options.onToolActivity?.(formatToolCall(item.name ?? "", item.input ?? {}));
4917
- }
4918
- }
4919
- } else if (event.type === "result") {
4920
- const text = event.result ?? "";
4921
- output = text;
4922
- options.onOutput?.(text);
4923
- }
4924
- } catch {
4925
- const newLine = `${line}
4926
- `;
4927
- output += newLine;
4928
- options.onOutput?.(newLine);
4929
- }
4933
+ processLine(line);
4930
4934
  }
4931
4935
  });
4936
+ flushLineBuffer = () => {
4937
+ if (lineBuffer.trim()) {
4938
+ processLine(lineBuffer);
4939
+ lineBuffer = "";
4940
+ }
4941
+ };
4932
4942
  } else {
4933
4943
  this.process.stdout?.on("data", (chunk) => {
4934
4944
  const text = chunk.toString();
@@ -4943,6 +4953,7 @@ class ClaudeRunner {
4943
4953
  });
4944
4954
  this.process.on("close", (code) => {
4945
4955
  this.process = null;
4956
+ flushLineBuffer?.();
4946
4957
  if (this.aborted) {
4947
4958
  resolve2({
4948
4959
  success: false,
@@ -5317,39 +5328,49 @@ class SandboxedClaudeRunner {
5317
5328
  stdio: ["ignore", "pipe", "pipe"],
5318
5329
  env: process.env
5319
5330
  });
5331
+ let flushLineBuffer = null;
5320
5332
  if (options.verbose) {
5321
5333
  let lineBuffer = "";
5322
5334
  const seenToolIds = new Set;
5335
+ const processLine = (line) => {
5336
+ if (!line.trim())
5337
+ return;
5338
+ try {
5339
+ const event = JSON.parse(line);
5340
+ if (event.type === "assistant" && event.message?.content) {
5341
+ for (const item of event.message.content) {
5342
+ if (item.type === "tool_use" && item.id && !seenToolIds.has(item.id)) {
5343
+ seenToolIds.add(item.id);
5344
+ options.onToolActivity?.(formatToolCall2(item.name ?? "", item.input ?? {}));
5345
+ }
5346
+ }
5347
+ } else if (event.type === "result") {
5348
+ const text = event.result ?? "";
5349
+ output = text;
5350
+ options.onOutput?.(text);
5351
+ }
5352
+ } catch {
5353
+ const newLine = `${line}
5354
+ `;
5355
+ output += newLine;
5356
+ options.onOutput?.(newLine);
5357
+ }
5358
+ };
5323
5359
  this.process.stdout?.on("data", (chunk) => {
5324
5360
  lineBuffer += chunk.toString();
5325
5361
  const lines = lineBuffer.split(`
5326
5362
  `);
5327
5363
  lineBuffer = lines.pop() ?? "";
5328
5364
  for (const line of lines) {
5329
- if (!line.trim())
5330
- continue;
5331
- try {
5332
- const event = JSON.parse(line);
5333
- if (event.type === "assistant" && event.message?.content) {
5334
- for (const item of event.message.content) {
5335
- if (item.type === "tool_use" && item.id && !seenToolIds.has(item.id)) {
5336
- seenToolIds.add(item.id);
5337
- options.onToolActivity?.(formatToolCall2(item.name ?? "", item.input ?? {}));
5338
- }
5339
- }
5340
- } else if (event.type === "result") {
5341
- const text = event.result ?? "";
5342
- output = text;
5343
- options.onOutput?.(text);
5344
- }
5345
- } catch {
5346
- const newLine = `${line}
5347
- `;
5348
- output += newLine;
5349
- options.onOutput?.(newLine);
5350
- }
5365
+ processLine(line);
5351
5366
  }
5352
5367
  });
5368
+ flushLineBuffer = () => {
5369
+ if (lineBuffer.trim()) {
5370
+ processLine(lineBuffer);
5371
+ lineBuffer = "";
5372
+ }
5373
+ };
5353
5374
  } else {
5354
5375
  this.process.stdout?.on("data", (chunk) => {
5355
5376
  const text = chunk.toString();
@@ -5364,6 +5385,7 @@ class SandboxedClaudeRunner {
5364
5385
  });
5365
5386
  this.process.on("close", (code) => {
5366
5387
  this.process = null;
5388
+ flushLineBuffer?.();
5367
5389
  if (this.aborted) {
5368
5390
  resolve2({
5369
5391
  success: false,
@@ -10516,7 +10538,12 @@ function resolveExecutionContext(config, modelOverride) {
10516
10538
  const model = modelOverride ?? config.ai.model;
10517
10539
  const provider = inferProviderFromModel(model) ?? config.ai.provider;
10518
10540
  const sandboxName = getModelSandboxName(config.sandbox, model, provider);
10519
- return { provider, model, sandboxName, containerWorkdir: config.sandbox.containerWorkdir };
10541
+ return {
10542
+ provider,
10543
+ model,
10544
+ sandboxName,
10545
+ containerWorkdir: config.sandbox.containerWorkdir
10546
+ };
10520
10547
  }
10521
10548
  function printRunHelp() {
10522
10549
  process.stderr.write(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/cli",
3
- "version": "0.22.10",
3
+ "version": "0.22.12",
4
4
  "description": "GitHub-native AI engineering assistant",
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,7 +36,7 @@
36
36
  "license": "MIT",
37
37
  "dependencies": {},
38
38
  "devDependencies": {
39
- "@locusai/sdk": "^0.22.10",
39
+ "@locusai/sdk": "^0.22.12",
40
40
  "@types/bun": "latest",
41
41
  "typescript": "^5.8.3"
42
42
  },