@locusai/sdk 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.
@@ -1 +1 @@
1
- {"version":3,"file":"codebase-indexer-service.d.ts","sourceRoot":"","sources":["../../src/agent/codebase-indexer-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,KAAK,CAAC;CACZ;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,IAAI;IAFxB,OAAO,CAAC,OAAO,CAAkB;gBAEb,IAAI,EAAE,0BAA0B;IAI9C,OAAO,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA2C5C"}
1
+ {"version":3,"file":"codebase-indexer-service.d.ts","sourceRoot":"","sources":["../../src/agent/codebase-indexer-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,KAAK,CAAC;CACZ;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,IAAI;IAFxB,OAAO,CAAC,OAAO,CAAkB;gBAEb,IAAI,EAAE,0BAA0B;IAI9C,OAAO,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA2C5C"}
@@ -17,5 +17,6 @@ export { AgentOrchestrator, type AgentState, type OrchestratorConfig, } from "./
17
17
  export * from "./planning/index.js";
18
18
  export { KnowledgeBase } from "./project/knowledge-base.js";
19
19
  export { c } from "./utils/colors.js";
20
+ export { extractJsonFromLLMOutput } from "./utils/json-extractor.js";
20
21
  export * from "./worktree/index.js";
21
22
  //# sourceMappingURL=index-node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAE9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,cAAc,iBAAiB,CAAC;AAEhC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAE9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,cAAc,iBAAiB,CAAC;AAEhC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,cAAc,qBAAqB,CAAC"}
@@ -2882,6 +2882,7 @@ __export(exports_index_node, {
2882
2882
  getDefaultBranch: () => getDefaultBranch,
2883
2883
  getCurrentBranch: () => getCurrentBranch,
2884
2884
  getAgentArtifactsPath: () => getAgentArtifactsPath,
2885
+ extractJsonFromLLMOutput: () => extractJsonFromLLMOutput,
2885
2886
  detectRemoteProvider: () => detectRemoteProvider,
2886
2887
  createAiRunner: () => createAiRunner,
2887
2888
  c: () => c,
@@ -3148,6 +3149,51 @@ class CodebaseIndexer {
3148
3149
  }
3149
3150
  }
3150
3151
 
3152
+ // src/utils/json-extractor.ts
3153
+ function extractJsonFromLLMOutput(raw) {
3154
+ const trimmed = raw.trim();
3155
+ const codeBlockMatch = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
3156
+ if (codeBlockMatch) {
3157
+ return codeBlockMatch[1]?.trim() || "";
3158
+ }
3159
+ if (trimmed.startsWith("{")) {
3160
+ return trimmed;
3161
+ }
3162
+ const startIdx = trimmed.indexOf("{");
3163
+ if (startIdx === -1) {
3164
+ return trimmed;
3165
+ }
3166
+ let depth = 0;
3167
+ let inString = false;
3168
+ let escaped = false;
3169
+ for (let i = startIdx;i < trimmed.length; i++) {
3170
+ const ch = trimmed[i];
3171
+ if (escaped) {
3172
+ escaped = false;
3173
+ continue;
3174
+ }
3175
+ if (ch === "\\") {
3176
+ escaped = true;
3177
+ continue;
3178
+ }
3179
+ if (ch === '"') {
3180
+ inString = !inString;
3181
+ continue;
3182
+ }
3183
+ if (inString)
3184
+ continue;
3185
+ if (ch === "{")
3186
+ depth++;
3187
+ else if (ch === "}") {
3188
+ depth--;
3189
+ if (depth === 0) {
3190
+ return trimmed.slice(startIdx, i + 1);
3191
+ }
3192
+ }
3193
+ }
3194
+ return trimmed.slice(startIdx);
3195
+ }
3196
+
3151
3197
  // src/agent/codebase-indexer-service.ts
3152
3198
  class CodebaseIndexerService {
3153
3199
  deps;
@@ -3173,11 +3219,12 @@ ${tree}
3173
3219
 
3174
3220
  Return ONLY valid JSON, no markdown formatting.`;
3175
3221
  const response = await this.deps.aiRunner.run(prompt);
3176
- const jsonMatch = response.match(/\{[\s\S]*\}/);
3177
- if (jsonMatch) {
3178
- return JSON.parse(jsonMatch[0]);
3222
+ const jsonStr = extractJsonFromLLMOutput(response);
3223
+ try {
3224
+ return JSON.parse(jsonStr);
3225
+ } catch {
3226
+ return { symbols: {}, responsibilities: {}, lastIndexed: "" };
3179
3227
  }
3180
- return { symbols: {}, responsibilities: {}, lastIndexed: "" };
3181
3228
  }, force);
3182
3229
  if (index === null) {
3183
3230
  this.deps.log("No changes detected, skipping reindex", "info");
@@ -4805,11 +4852,7 @@ function plannedTasksToCreatePayloads(plan, sprintId) {
4805
4852
  }));
4806
4853
  }
4807
4854
  function parseSprintPlanFromAI(raw, directive) {
4808
- let jsonStr = raw.trim();
4809
- const jsonMatch = jsonStr.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
4810
- if (jsonMatch) {
4811
- jsonStr = jsonMatch[1]?.trim() || "";
4812
- }
4855
+ const jsonStr = extractJsonFromLLMOutput(raw);
4813
4856
  let parsed = JSON.parse(jsonStr);
4814
4857
  if (parsed.revisedPlan) {
4815
4858
  parsed = parsed.revisedPlan;
@@ -5032,7 +5075,7 @@ Tasks are executed by INDEPENDENT agents on SEPARATE git branches that get merge
5032
5075
 
5033
5076
  ## Output Format
5034
5077
 
5035
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
5078
+ 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:
5036
5079
 
5037
5080
  {
5038
5081
  "tasks": [
@@ -5122,7 +5165,7 @@ Identify the highest-risk files (files that multiple tasks might touch) and ensu
5122
5165
 
5123
5166
  ## Output Format
5124
5167
 
5125
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
5168
+ 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:
5126
5169
 
5127
5170
  {
5128
5171
  "hasIssues": true | false,
@@ -5217,7 +5260,7 @@ Before finalizing, validate that EVERY task is fully self-contained and conflict
5217
5260
 
5218
5261
  ## Output Format
5219
5262
 
5220
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
5263
+ 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:
5221
5264
 
5222
5265
  {
5223
5266
  "name": "string (2-4 words)",
@@ -5298,7 +5341,7 @@ Tasks will be executed by INDEPENDENT agents on SEPARATE git branches that get m
5298
5341
 
5299
5342
  ## Output Format
5300
5343
 
5301
- Respond with ONLY a JSON object (no markdown code blocks, no explanation):
5344
+ 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:
5302
5345
 
5303
5346
  {
5304
5347
  "tasks": [
@@ -1 +1 @@
1
- {"version":3,"file":"sprint-plan.d.ts","sourceRoot":"","sources":["../../src/planning/sprint-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACrC;A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EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CA+D7D;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,GACf,UAAU,EAAE,CAgBd;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,UAAU,CA0CZ"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Extract a JSON object string from LLM output that may contain
3
+ * surrounding prose, markdown code blocks, or other non-JSON text.
4
+ */
5
+ export declare function extractJsonFromLLMOutput(raw: string): string;
6
+ //# sourceMappingURL=json-extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-extractor.d.ts","sourceRoot":"","sources":["../../src/utils/json-extractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAuD5D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/sdk",
3
- "version": "0.9.17",
3
+ "version": "0.9.18",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -30,7 +30,7 @@
30
30
  "clean": "rm -rf node_modules"
31
31
  },
32
32
  "dependencies": {
33
- "@locusai/shared": "^0.9.17",
33
+ "@locusai/shared": "^0.9.18",
34
34
  "axios": "^1.13.2",
35
35
  "events": "^3.3.0",
36
36
  "globby": "^14.0.2"