lunel-cli 0.1.52 → 0.1.53

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.
@@ -101,6 +101,7 @@ export declare class CodexProvider implements AIProvider {
101
101
  private extractDiffLikePayload;
102
102
  private renderFileChangeEntriesBody;
103
103
  private renderUnifiedDiffBody;
104
+ private extractCanonicalPatch;
104
105
  private normalizedFileChangeStatus;
105
106
  private extractToolInput;
106
107
  private describeCompletedItemOutput;
package/dist/ai/codex.js CHANGED
@@ -374,10 +374,12 @@ export class CodexProvider {
374
374
  case "codex/event/read":
375
375
  case "codex/event/search":
376
376
  case "codex/event/list_files":
377
+ this.emitStructuredToolPart(session, method, params, false);
378
+ return;
377
379
  case "turn/diff/updated":
378
380
  case "codex/event/turn_diff_updated":
379
381
  case "codex/event/turn_diff":
380
- this.emitStructuredToolPart(session, method, params, false);
382
+ this.emitStructuredToolPart(session, method, params, true);
381
383
  return;
382
384
  case "item/completed":
383
385
  case "codex/event/item_completed":
@@ -521,6 +523,9 @@ export class CodexProvider {
521
523
  const name = this.describeToolPart(normalizedType, method, item);
522
524
  const input = this.extractToolInput(item, params);
523
525
  const outputValue = output || this.describeCompletedItemOutput(item, params, normalizedType) || undefined;
526
+ const patch = emittedPartType === "file-change"
527
+ ? this.extractCanonicalPatch(params, item)
528
+ : undefined;
524
529
  const part = {
525
530
  id: partId,
526
531
  sessionID: session.id,
@@ -528,7 +533,7 @@ export class CodexProvider {
528
533
  type: emittedPartType,
529
534
  ...(emittedPartType === "reasoning"
530
535
  ? { text: outputValue ?? "Planning..." }
531
- : { name, toolName: name, input, output: outputValue, state }),
536
+ : { name, toolName: name, input, output: outputValue, state, ...(patch ? { patch } : {}) }),
532
537
  };
533
538
  this.upsertLocalMessagePart(session, messageId, part);
534
539
  this.emitMessagePartEvent(session.id, messageId, "assistant", part);
@@ -821,6 +826,9 @@ export class CodexProvider {
821
826
  const emittedPartType = this.isFileChangeStructuredItem(type, itemObject)
822
827
  ? "file-change"
823
828
  : "tool";
829
+ const patch = emittedPartType === "file-change"
830
+ ? this.extractCanonicalPatch({}, itemObject)
831
+ : undefined;
824
832
  messages.push({
825
833
  id: itemId,
826
834
  role: "assistant",
@@ -831,6 +839,7 @@ export class CodexProvider {
831
839
  toolName: type,
832
840
  output,
833
841
  state: "completed",
842
+ ...(patch ? { patch } : {}),
834
843
  sessionID: threadId,
835
844
  messageID: itemId,
836
845
  }],
@@ -1194,6 +1203,28 @@ export class CodexProvider {
1194
1203
  renderUnifiedDiffBody(diff, status) {
1195
1204
  return `Status: ${status}\n\n\`\`\`diff\n${diff.trim()}\n\`\`\``;
1196
1205
  }
1206
+ extractCanonicalPatch(params, item) {
1207
+ const event = this.asRecord(params.event);
1208
+ const nestedItem = this.asRecord(event.item);
1209
+ const sources = [item, params, event, nestedItem];
1210
+ for (const source of sources) {
1211
+ const diff = this.firstString(source, ["diff", "unified_diff", "unifiedDiff", "patch"]);
1212
+ if (diff?.trim()) {
1213
+ return diff.trim();
1214
+ }
1215
+ }
1216
+ const changes = this.readArray(item.changes ?? params.changes ?? event.changes ?? nestedItem.changes);
1217
+ if (changes.length === 0)
1218
+ return undefined;
1219
+ const patch = changes
1220
+ .map((change) => {
1221
+ const obj = this.asRecord(change);
1222
+ return this.firstString(obj, ["diff", "unified_diff", "unifiedDiff", "patch"]) ?? "";
1223
+ })
1224
+ .filter((value) => value.trim().length > 0)
1225
+ .join("\n");
1226
+ return patch.trim() || undefined;
1227
+ }
1197
1228
  normalizedFileChangeStatus(itemObject, isCompleted) {
1198
1229
  const status = this.readString(itemObject.status)
1199
1230
  ?? this.readString(this.asRecord(itemObject.status).type)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunel-cli",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "author": [
5
5
  {
6
6
  "name": "Soham Bharambe",