@locusai/cli 0.9.17 → 0.9.18

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 +54 -13
  2. package/package.json +2 -2
package/bin/locus.js CHANGED
@@ -6317,6 +6317,51 @@ var init_indexer = __esm(() => {
6317
6317
  init_globby();
6318
6318
  });
6319
6319
 
6320
+ // ../sdk/src/utils/json-extractor.ts
6321
+ function extractJsonFromLLMOutput(raw) {
6322
+ const trimmed = raw.trim();
6323
+ const codeBlockMatch = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
6324
+ if (codeBlockMatch) {
6325
+ return codeBlockMatch[1]?.trim() || "";
6326
+ }
6327
+ if (trimmed.startsWith("{")) {
6328
+ return trimmed;
6329
+ }
6330
+ const startIdx = trimmed.indexOf("{");
6331
+ if (startIdx === -1) {
6332
+ return trimmed;
6333
+ }
6334
+ let depth = 0;
6335
+ let inString = false;
6336
+ let escaped = false;
6337
+ for (let i = startIdx;i < trimmed.length; i++) {
6338
+ const ch = trimmed[i];
6339
+ if (escaped) {
6340
+ escaped = false;
6341
+ continue;
6342
+ }
6343
+ if (ch === "\\") {
6344
+ escaped = true;
6345
+ continue;
6346
+ }
6347
+ if (ch === '"') {
6348
+ inString = !inString;
6349
+ continue;
6350
+ }
6351
+ if (inString)
6352
+ continue;
6353
+ if (ch === "{")
6354
+ depth++;
6355
+ else if (ch === "}") {
6356
+ depth--;
6357
+ if (depth === 0) {
6358
+ return trimmed.slice(startIdx, i + 1);
6359
+ }
6360
+ }
6361
+ }
6362
+ return trimmed.slice(startIdx);
6363
+ }
6364
+
6320
6365
  // ../sdk/src/agent/codebase-indexer-service.ts
6321
6366
  var init_codebase_indexer_service = __esm(() => {
6322
6367
  init_indexer();
@@ -40584,11 +40629,7 @@ function plannedTasksToCreatePayloads(plan, sprintId) {
40584
40629
  }));
40585
40630
  }
40586
40631
  function parseSprintPlanFromAI(raw, directive) {
40587
- let jsonStr = raw.trim();
40588
- const jsonMatch = jsonStr.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
40589
- if (jsonMatch) {
40590
- jsonStr = jsonMatch[1]?.trim() || "";
40591
- }
40632
+ const jsonStr = extractJsonFromLLMOutput(raw);
40592
40633
  let parsed = JSON.parse(jsonStr);
40593
40634
  if (parsed.revisedPlan) {
40594
40635
  parsed = parsed.revisedPlan;
@@ -40827,7 +40868,7 @@ Tasks are executed by INDEPENDENT agents on SEPARATE git branches that get merge
40827
40868
 
40828
40869
  ## Output Format
40829
40870
 
40830
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
40871
+ Your entire response must be a single JSON object no text before it, no text after it, no markdown code blocks, no explanation. Start your response with the "{" character:
40831
40872
 
40832
40873
  {
40833
40874
  "tasks": [
@@ -40917,7 +40958,7 @@ Identify the highest-risk files (files that multiple tasks might touch) and ensu
40917
40958
 
40918
40959
  ## Output Format
40919
40960
 
40920
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
40961
+ Your entire response must be a single JSON object no text before it, no text after it, no markdown code blocks, no explanation. Start your response with the "{" character:
40921
40962
 
40922
40963
  {
40923
40964
  "hasIssues": true | false,
@@ -41012,7 +41053,7 @@ Before finalizing, validate that EVERY task is fully self-contained and conflict
41012
41053
 
41013
41054
  ## Output Format
41014
41055
 
41015
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
41056
+ Your entire response must be a single JSON object no text before it, no text after it, no markdown code blocks, no explanation. Start your response with the "{" character:
41016
41057
 
41017
41058
  {
41018
41059
  "name": "string (2-4 words)",
@@ -41093,7 +41134,7 @@ Tasks will be executed by INDEPENDENT agents on SEPARATE git branches that get m
41093
41134
 
41094
41135
  ## Output Format
41095
41136
 
41096
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
41137
+ Your entire response must be a single JSON object no text before it, no text after it, no markdown code blocks, no explanation. Start your response with the "{" character:
41097
41138
 
41098
41139
  {
41099
41140
  "tasks": [
@@ -43648,6 +43689,8 @@ init_index_node();
43648
43689
  import { parseArgs as parseArgs4 } from "node:util";
43649
43690
 
43650
43691
  // src/tree-summarizer.ts
43692
+ init_index_node();
43693
+
43651
43694
  class TreeSummarizer {
43652
43695
  aiRunner;
43653
43696
  constructor(aiRunner) {
@@ -43664,10 +43707,8 @@ Return ONLY a JSON object with this structure:
43664
43707
  File Tree:
43665
43708
  ${tree}`;
43666
43709
  const output = await this.aiRunner.run(prompt);
43667
- const jsonMatch = output.match(/\{[\s\S]*\}/);
43668
- if (jsonMatch)
43669
- return JSON.parse(jsonMatch[0]);
43670
- throw new Error("Could not find JSON in AI output");
43710
+ const jsonStr = extractJsonFromLLMOutput(output);
43711
+ return JSON.parse(jsonStr);
43671
43712
  }
43672
43713
  }
43673
43714
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/cli",
3
- "version": "0.9.17",
3
+ "version": "0.9.18",
4
4
  "description": "CLI for Locus - AI-native project management platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "author": "",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@locusai/sdk": "^0.9.17"
35
+ "@locusai/sdk": "^0.9.18"
36
36
  },
37
37
  "devDependencies": {}
38
38
  }