conductor-remote 1.115.0 → 1.116.0

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.
package/README.md CHANGED
@@ -298,8 +298,10 @@ RELAY_TOKEN=$(openssl rand -hex 16) yarn start
298
298
  targeting, no focus needed. Speaks a private, versioned IPC (see FINDINGS ▸
299
299
  Writes), so it's the more fragile of the two.
300
300
  - ✅ **Attach images and files** — tap the paperclip or paste an image into the
301
- composer. Files up to 25 MB are stored in Conductor's own attachment layout
302
- before the prompt is sent.
301
+ composer. Text pastes over 2,000 characters become a removable `pasted-text.txt`
302
+ attachment in chats and New workspace; shorter or offline pastes stay in the
303
+ editor. Files up to 25 MB are stored in Conductor's own attachment layout before
304
+ the prompt is sent.
303
305
  - ✅ **Deterministic cross-provider Workflow** — configure exact picker-backed
304
306
  planning, exploration, and implementation roles, then turn on **Workflow** in
305
307
  New workspace or an untouched **+ New chat**. The PWA calls the UI-only
@@ -335,8 +337,8 @@ Two transports, same tools.
335
337
  | `dev_server` | inspect, start, forward or stop a workspace's configured Conductor Run task; use this instead of launching a long-lived server from an agent shell |
336
338
  | `send_prompt` · `stop_turn` · `close_chat` | talk to a running agent, cancel its turn, or hide a chat tab |
337
339
  | `split_chat` | move a tangent into a fresh tab, or set `new_workspace` to carry the transcript and current code into a separate worktree |
338
- | `list_roles` | inspect exact-picker Workflow role definitions and validation issues; role editing remains a phone UI action |
339
- | `delegate_task` · `list_delegations` | from an already-authorized Workflow root, request a capability-scoped tracked child or observe active/failed jobs; neither tool can start or recover a Workflow |
340
+ | `list_roles` | inspect configured roles and validation issues for lightweight delegation or future Workflows; role editing remains a phone UI action |
341
+ | `delegate_task` · `list_delegations` | spawn a lightweight tracked child from an ordinary chat, or a capability-scoped child from a Workflow root; observe active/failed jobs |
340
342
  | `list_models` · `set_agent_options` · `set_default_model` | cached model labels (including the starred default), model, effort, plan, fast; starring a default also selects it for the target chat, matching Conductor |
341
343
  | `set_workspace_status` | move a workspace between the sidebar's status groups |
342
344
  | `archive_workspace` | put a finished workspace away (Conductor's ⌘⇧A) — deletes the worktree, keeps the chat |
@@ -395,7 +397,7 @@ of the time.
395
397
  | `list_workspaces` | what is running right now, with status and model |
396
398
  | `list_chats` | the chat tabs in a workspace |
397
399
  | `list_roles` | picker-backed cross-provider role definitions and validation issues |
398
- | `delegate_task` | enqueue a tracked child only for the caller's existing Workflow id/current phase capability, then return its job id |
400
+ | `delegate_task` | enqueue a tracked sibling subtab from an ordinary chat with `session_id`, `role`, and `prompt`; active Workflows require their root's id/current phase capability |
399
401
  | `list_delegations` | active and failed delegated jobs |
400
402
  | `workspace_diff` | a workspace's diff against its target branch |
401
403
  | `list_repos` | repos a workspace can be created in |
@@ -414,9 +416,9 @@ Conductor deep link, so creation itself needs no Accessibility and steals no foc
414
416
  requested model, effort, plan, and fast settings are applied later before the first
415
417
  prompt. Neither `create_workspace` nor `send_prompt` can start or join a Workflow.
416
418
  Workflow Start is deliberately PWA-only: the relay first accepts `POST /api/workflows`,
417
- then its durable coordinator performs the workspace/root effects. `delegate_task`
418
- requires the Workflow id, root session, role, and opaque capability delivered for the
419
- current phase; it persists and returns immediately while the coordinator later
419
+ then its durable coordinator performs the workspace/root effects. For an active Workflow,
420
+ `delegate_task` requires the Workflow id, root session, role, and opaque capability delivered
421
+ for the current phase; it persists and returns immediately while the coordinator later
420
422
  opens/configures/sends the child. MCP cannot start, retry, adopt, replay, cancel,
421
423
  complete, edit roles, or dismiss a managed failure. Generic Plan remains independent
422
424
  on the ordinary agent-option routes and is not part of Workflow's frozen tuple.
@@ -425,6 +427,29 @@ from their shell. Its start and stop actions go through Conductor's Run controls
425
427
  preserves the workspace's allocated ports, run-mode policy and process-group cleanup;
426
428
  the MCP tool cannot forbid shell commands, but removes the reason to use one here.
427
429
 
430
+ **Lightweight codebase agents need no Workflow.** In an ordinary chat, call `list_roles`,
431
+ then `delegate_task` with `session_id`, a configured `role`, and a focused `prompt`.
432
+ Choose a role whose instructions fit the task, usually `exploration` for investigation.
433
+ Its model, effort, Fast mode, and preamble come from the role configuration. Repeat the call
434
+ for independent questions: children run concurrently after their serialized UI setup,
435
+ each appears under its parent in **Delegated agents**, and each returns its result.
436
+ The parent keeps its own model and role. A completed child stays under the correct
437
+ parent even after its successful job is removed. No planning or implementation phase
438
+ is scheduled, and a Baton's suggested next role is only advice.
439
+
440
+ Ordinary calls can set `return_mode` (`queue` behind the current turn by default;
441
+ use `steer` to receive the result during the current turn), `through`
442
+ (a `read_chat` cursor), and `include_thinking` (false by default). These options are
443
+ refused on Workflow calls, where the coordinator owns the handoff and return path.
444
+ Both active Workflow roots and their children are refused by ordinary-chat intake;
445
+ only the root can delegate through its current phase capability. Each accepted ad hoc
446
+ job freezes the configured role, which must use a different provider than its parent.
447
+
448
+ Skills such as gstack can use the same routing through a user instruction override.
449
+ See [Conductor agent routing](docs/conductor-agent-routing.md) for a prompt block that
450
+ preserves skill steps and routes helper work through tracked chats without changing
451
+ gstack source.
452
+
428
453
  The HTTP transport is deliberately minimal: the server never initiates a message, so
429
454
  there is no SSE stream and `GET /mcp` answers 405, which the spec allows. It keeps no
430
455
  session either. A request carrying an `Origin` header is refused outright — a real MCP
@@ -450,8 +475,8 @@ surface each of those choices.
450
475
  The workflow icon in either workspace header opens **Roles**. Models there are
451
476
  choices previously read from Conductor's real picker; a missing or ambiguous label
452
477
  stays red and Start is refused before the relay opens a tab. The shipped
453
- `exploration` placeholder is intentionally invalid when several Spark rows exist,
454
- so choose the exact one once. Start freezes all three roles for that run; editing a
478
+ role placeholders stay invalid until an exact model is selected for each role.
479
+ Start freezes all three roles for that run; editing a
455
480
  definition later affects only the next run. The root receives those frozen model labels
456
481
  and responsibilities in its first prompt; it does not need to call `list_roles`, whose
457
482
  output describes mutable defaults for later runs. In the sidebar, a Workflow workspace
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-syntax/cpp-DddhVWhK.js","assets/diff-syntax/c-BIGW1oBm.js","assets/diff-syntax/html-pp8916En.js","assets/diff-syntax/javascript-wDzz0qaB.js","assets/diff-syntax/css-CLj8gQPS.js","assets/diff-syntax/php-Csjmro_R.js","assets/diff-syntax/xml-sdJ4AIDG.js","assets/diff-syntax/java-CylS5w8V.js","assets/diff-syntax/sql-CRqJ_cUM.js","assets/diff-syntax/json-Cp-IABpG.js","assets/diff-syntax/ruby-C-9S-GLb.js","assets/diff-syntax/typescript-BPQ3VLAy.js","assets/diff-syntax/jsx-g9-lgVsj.js","assets/diff-syntax/tsx-COt5Ahok.js","assets/diff-syntax/zsh-Yzrsuije.js","assets/diff-syntax/yml-DbVfSbck.js","assets/diff-syntax/scss-D5BDwBP9.js"])))=>i.map(i=>d[i]);
2
- import{w as er,s as Xs,f as Ba,a as Ga,b as za,c as gr,h as ja,_ as D,r as Q,j,p as Wa,d as Va}from"./index-Dkiq148q.js";const mr={}.hasOwnProperty;function qa(e,t){const n=t||{};function i(r,...s){let o=i.invalid;const l=i.handlers;if(r&&mr.call(r,e)){const a=String(r[e]);o=mr.call(l,a)?l[a]:i.unknown}if(o)return o.call(this,r,...s)}return i.handlers=n.handlers||{},i.invalid=n.invalid,i.unknown=n.unknown,i}const Ys="diffs-container";(()=>{try{return!1}catch{return!1}})();const Ka=/(?=^From [a-f0-9]+ .+$)/m,Qs=/(?=^diff --git)/gm,Xa=new RegExp("(?<=\\n)"),Ya=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Qa=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Za=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Ja=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Zs="header-prefix",Js="header-filename-suffix",eo="header-metadata",tr="header-custom",le={dark:"pierre-dark",light:"pierre-light"},el="data-theme-css",tl="data-unsafe-css",nl="data-diffs-scrollbar-measure",to="--diffs-scrollbar-gutter-measured",il=1e5,rl={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},sl=Object.freeze({fromStart:0,fromEnd:0}),br={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},ol={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},gt=new Set;let mt=null;function no(e){gt.add(e),mt??=requestAnimationFrame(io)}function Ci(e){gt.delete(e)&&gt.size===0&&mt!=null&&(cancelAnimationFrame(mt),mt=null)}function io(e){const t=new Set(gt);gt.clear();for(const n of t)try{n(e)}catch(i){console.error(i)}gt.size>0?mt=requestAnimationFrame(io):mt=null}function Si(e,t,n){if(e===t||e==null||t==null)return e===t;const i=new Set(n),r=Object.keys(e),s=new Set(Object.keys(t));for(const o of r)if(s.delete(o),!i.has(o)&&(!(o in t)||e[o]!==t[o]))return!1;for(const o of Array.from(s))if(!i.has(o))return!1;return!0}function nr(e,t){return e==null||t==null||typeof e=="string"||typeof t=="string"?e===t:e.dark===t.dark&&e.light===t.light}function ro(e,t){const n=e?.theme??le,i=t?.theme??le,r=vr(e),s=vr(t);return nr(n,i)&&Si(e,t,["theme","parseDiffOptions"])&&Si(r,s)}function vr(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function wi(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function Pe(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}const al=new TextEncoder,ll=new TextDecoder("utf-8",{ignoreBOM:!0}),dl=/[\uD800-\uDFFF]/,xi=1024;let ft=new Uint8Array(xi);function so(){ft.length!==xi&&(ft=new Uint8Array(xi))}function W(e){if(e.length===0)return e;if(dl.test(e))return JSON.parse(JSON.stringify(e));const t=e.length*3;ft.length<t&&(ft=new Uint8Array(t));const{written:n}=al.encodeInto(e,ft);return ll.decode(ft.subarray(0,n))}function Se(e,t){return e-(t===0?0:1)}function ie(e,t){return Se(e,t)+t}const cl=4096,ul=.5;function hl(e){for(const t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){const i=t.hunkContent[n];if(i.type!=="change")continue;const r=pl(e,i);r!=null&&(t.hunkContent.splice(n,1,...r),n+=r.length-1)}fl(t,e)}}function fl(e,t){const{hunkContent:n}=e;for(let i=1;i<n.length;i++){const r=n[i],s=n[i-1];if(r.type!=="change"||r.additions>0&&r.deletions>0||s.type!=="context")continue;const o=r.additions>0,l=o?t.additionLines:t.deletionLines,a=o?r.additionLineIndex:r.deletionLineIndex,d=o?r.additions:r.deletions,c=l[a]??"";if(c.trim()!=="")continue;let u=!0;for(let v=1;v<d;v++)if(l[a+v]!==c){u=!1;break}if(!u)continue;let h=0;for(;h<s.lines&&t.additionLines[s.additionLineIndex+s.lines-1-h]===c;)h++;if(h===0||i===1&&h===s.lines)continue;r.additionLineIndex-=h,r.deletionLineIndex-=h;const f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,g=n[i+1];g?.type==="context"?(g.lines+=h,g.additionLineIndex=f,g.deletionLineIndex=p):n.splice(i+1,0,{type:"context",lines:h,additionLineIndex:f,deletionLineIndex:p}),s.lines-=h,s.lines===0&&(n.splice(i-1,1),i--)}}function pl(e,t){const{deletions:n,additions:i,deletionLineIndex:r,additionLineIndex:s}=t,o=Math.min(n,i),l=Math.abs(i-n);if(o===0||l===0||o*(l+1)>cl)return null;const a=[];for(let g=0;g<n;g++)a.push(yr(e.deletionLines[r+g]??""));const d=[];for(let g=0;g<i;g++)d.push(yr(e.additionLines[s+g]??""));const c=i>n;let u=0,h=-1;for(let g=0;g<=l;g++){let v=0;for(let m=0;m<o;m++)v+=ml(a[m+(c?0:g)],d[m+(c?g:0)]);g===0?h=v+o*ul:v>h&&(h=v,u=g)}if(u===0)return null;const f=[],p=(g,v,m,b)=>{(g>0||v>0)&&f.push({type:"change",deletions:g,additions:v,deletionLineIndex:m,additionLineIndex:b})};return c?(p(0,u,r,s),p(o,o,r,s+u),p(0,i-o-u,r+o,s+u+o)):(p(u,0,r,s),p(o,o,r+u,s),p(n-o-u,0,r+u+o,s+o)),f}const gl=/\s+/g;function yr(e){return e.replace(gl,"")}function ml(e,t){if(e===t)return 1;const n=Math.max(e.length,t.length),i=Math.min(e.length,t.length);if(i===0)return 0;let r=0;for(;r<i&&e[r]===t[r];)r++;let s=0;for(;s<i-r&&e[e.length-1-s]===t[t.length-1-s];)s++;return(r+s)/n}function bl(e,t,n){try{return vl(e,t,n)}finally{so()}}function vl(e,t,n=!1){const i=_l(e),r=i?wl(e):xl(e);let s;const o=[];for(const l of r){if(i&&!Qs.test(l)){if(s==null)s=W(l);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}else if(!i&&!kl(l)){if(s==null)s=W(l);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}const a=oo(l,{cacheKey:void 0,isGitDiff:i,throwOnError:n});a!=null&&o.push(a)}return{patchMetadata:s,files:o}}function yl(e,t){try{return oo(e,t)}finally{so()}}function oo(e,{cacheKey:t,isGitDiff:n=Qs.test(e),oldFile:i,newFile:r,throwOnError:s=!1}={}){let o=0;const l=uo(e,"@@ ");let a;const d=i==null||r==null;let c=0,u=0;for(const h of l){const f=ao(h),p=f[0];if(p==null){if(s)throw Error("parsePatchContent: invalid hunk");console.error("parsePatchContent: invalid hunk",h);continue}const g=co(p);let v=0,m=0;if(g==null||a==null){if(a!=null){if(s)throw Error("parsePatchContent: Invalid hunk");console.error("parsePatchContent: Invalid hunk",h);continue}a={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&i!=null&&r!=null?Cr(r.contents):[],deletionLines:!d&&i!=null&&r!=null?Cr(i.contents):[],cacheKey:xr(t)},a.additionLines.length===1&&r?.contents===""&&(a.additionLines.length=0),a.deletionLines.length===1&&i?.contents===""&&(a.deletionLines.length=0);for(const k of f){if(k.startsWith("diff --git")){const F=k.trim().match(Za),L=F?.[1]??F?.[2],A=F?.[3]??F?.[4];if(L==null||A==null){if(s)throw Error("parsePatchContent: invalid git diff header");console.error("parsePatchContent: invalid git diff header",k);continue}a.name=W(A.trim()),L!==A&&(a.prevName=W(L.trim()));continue}const _=k.startsWith("---")||k.startsWith("+++")?k.match(n?Qa:Ya):null;if(_!=null){const[,F,L]=_;if(F==="---"&&L!=="/dev/null"){const A=W(L.trim());a.prevName=A,a.name=A}else F==="+++"&&L!=="/dev/null"&&(a.name=W(L.trim()))}else if(n){if(k.startsWith("new mode ")&&(a.mode=W(k.slice(8).trim())),k.startsWith("old mode ")&&(a.prevMode=W(k.slice(8).trim())),k.startsWith("new file mode")&&(a.type="new",a.mode=W(k.slice(13).trim())),k.startsWith("deleted file mode")&&(a.type="deleted",a.mode=W(k.slice(17).trim())),k.startsWith("similarity index")&&(k.startsWith("similarity index 100%")?a.type="rename-pure":a.type="rename-changed"),k.startsWith("index ")){const[,F,L,A]=k.trim().match(Ja)??[];F!=null&&(a.prevObjectId=W(F)),L!=null&&(a.newObjectId=W(L)),A!=null&&(a.mode=W(A))}k.startsWith("rename from ")&&(a.prevName=W(k.slice(12).trim())),k.startsWith("rename to ")&&(a.name=W(k.slice(10).trim()))}}continue}let b,y;for(;f.length>0&&(f[f.length-1]===`
2
+ import{w as er,s as Xs,f as Ba,a as Ga,b as za,c as gr,h as ja,_ as D,r as Q,j,p as Wa,d as Va}from"./index-QJR7tn2I.js";const mr={}.hasOwnProperty;function qa(e,t){const n=t||{};function i(r,...s){let o=i.invalid;const l=i.handlers;if(r&&mr.call(r,e)){const a=String(r[e]);o=mr.call(l,a)?l[a]:i.unknown}if(o)return o.call(this,r,...s)}return i.handlers=n.handlers||{},i.invalid=n.invalid,i.unknown=n.unknown,i}const Ys="diffs-container";(()=>{try{return!1}catch{return!1}})();const Ka=/(?=^From [a-f0-9]+ .+$)/m,Qs=/(?=^diff --git)/gm,Xa=new RegExp("(?<=\\n)"),Ya=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Qa=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Za=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Ja=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Zs="header-prefix",Js="header-filename-suffix",eo="header-metadata",tr="header-custom",le={dark:"pierre-dark",light:"pierre-light"},el="data-theme-css",tl="data-unsafe-css",nl="data-diffs-scrollbar-measure",to="--diffs-scrollbar-gutter-measured",il=1e5,rl={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},sl=Object.freeze({fromStart:0,fromEnd:0}),br={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},ol={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},gt=new Set;let mt=null;function no(e){gt.add(e),mt??=requestAnimationFrame(io)}function Ci(e){gt.delete(e)&&gt.size===0&&mt!=null&&(cancelAnimationFrame(mt),mt=null)}function io(e){const t=new Set(gt);gt.clear();for(const n of t)try{n(e)}catch(i){console.error(i)}gt.size>0?mt=requestAnimationFrame(io):mt=null}function Si(e,t,n){if(e===t||e==null||t==null)return e===t;const i=new Set(n),r=Object.keys(e),s=new Set(Object.keys(t));for(const o of r)if(s.delete(o),!i.has(o)&&(!(o in t)||e[o]!==t[o]))return!1;for(const o of Array.from(s))if(!i.has(o))return!1;return!0}function nr(e,t){return e==null||t==null||typeof e=="string"||typeof t=="string"?e===t:e.dark===t.dark&&e.light===t.light}function ro(e,t){const n=e?.theme??le,i=t?.theme??le,r=vr(e),s=vr(t);return nr(n,i)&&Si(e,t,["theme","parseDiffOptions"])&&Si(r,s)}function vr(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function wi(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function Pe(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}const al=new TextEncoder,ll=new TextDecoder("utf-8",{ignoreBOM:!0}),dl=/[\uD800-\uDFFF]/,xi=1024;let ft=new Uint8Array(xi);function so(){ft.length!==xi&&(ft=new Uint8Array(xi))}function W(e){if(e.length===0)return e;if(dl.test(e))return JSON.parse(JSON.stringify(e));const t=e.length*3;ft.length<t&&(ft=new Uint8Array(t));const{written:n}=al.encodeInto(e,ft);return ll.decode(ft.subarray(0,n))}function Se(e,t){return e-(t===0?0:1)}function ie(e,t){return Se(e,t)+t}const cl=4096,ul=.5;function hl(e){for(const t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){const i=t.hunkContent[n];if(i.type!=="change")continue;const r=pl(e,i);r!=null&&(t.hunkContent.splice(n,1,...r),n+=r.length-1)}fl(t,e)}}function fl(e,t){const{hunkContent:n}=e;for(let i=1;i<n.length;i++){const r=n[i],s=n[i-1];if(r.type!=="change"||r.additions>0&&r.deletions>0||s.type!=="context")continue;const o=r.additions>0,l=o?t.additionLines:t.deletionLines,a=o?r.additionLineIndex:r.deletionLineIndex,d=o?r.additions:r.deletions,c=l[a]??"";if(c.trim()!=="")continue;let u=!0;for(let v=1;v<d;v++)if(l[a+v]!==c){u=!1;break}if(!u)continue;let h=0;for(;h<s.lines&&t.additionLines[s.additionLineIndex+s.lines-1-h]===c;)h++;if(h===0||i===1&&h===s.lines)continue;r.additionLineIndex-=h,r.deletionLineIndex-=h;const f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,g=n[i+1];g?.type==="context"?(g.lines+=h,g.additionLineIndex=f,g.deletionLineIndex=p):n.splice(i+1,0,{type:"context",lines:h,additionLineIndex:f,deletionLineIndex:p}),s.lines-=h,s.lines===0&&(n.splice(i-1,1),i--)}}function pl(e,t){const{deletions:n,additions:i,deletionLineIndex:r,additionLineIndex:s}=t,o=Math.min(n,i),l=Math.abs(i-n);if(o===0||l===0||o*(l+1)>cl)return null;const a=[];for(let g=0;g<n;g++)a.push(yr(e.deletionLines[r+g]??""));const d=[];for(let g=0;g<i;g++)d.push(yr(e.additionLines[s+g]??""));const c=i>n;let u=0,h=-1;for(let g=0;g<=l;g++){let v=0;for(let m=0;m<o;m++)v+=ml(a[m+(c?0:g)],d[m+(c?g:0)]);g===0?h=v+o*ul:v>h&&(h=v,u=g)}if(u===0)return null;const f=[],p=(g,v,m,b)=>{(g>0||v>0)&&f.push({type:"change",deletions:g,additions:v,deletionLineIndex:m,additionLineIndex:b})};return c?(p(0,u,r,s),p(o,o,r,s+u),p(0,i-o-u,r+o,s+u+o)):(p(u,0,r,s),p(o,o,r+u,s),p(n-o-u,0,r+u+o,s+o)),f}const gl=/\s+/g;function yr(e){return e.replace(gl,"")}function ml(e,t){if(e===t)return 1;const n=Math.max(e.length,t.length),i=Math.min(e.length,t.length);if(i===0)return 0;let r=0;for(;r<i&&e[r]===t[r];)r++;let s=0;for(;s<i-r&&e[e.length-1-s]===t[t.length-1-s];)s++;return(r+s)/n}function bl(e,t,n){try{return vl(e,t,n)}finally{so()}}function vl(e,t,n=!1){const i=_l(e),r=i?wl(e):xl(e);let s;const o=[];for(const l of r){if(i&&!Qs.test(l)){if(s==null)s=W(l);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}else if(!i&&!kl(l)){if(s==null)s=W(l);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}const a=oo(l,{cacheKey:void 0,isGitDiff:i,throwOnError:n});a!=null&&o.push(a)}return{patchMetadata:s,files:o}}function yl(e,t){try{return oo(e,t)}finally{so()}}function oo(e,{cacheKey:t,isGitDiff:n=Qs.test(e),oldFile:i,newFile:r,throwOnError:s=!1}={}){let o=0;const l=uo(e,"@@ ");let a;const d=i==null||r==null;let c=0,u=0;for(const h of l){const f=ao(h),p=f[0];if(p==null){if(s)throw Error("parsePatchContent: invalid hunk");console.error("parsePatchContent: invalid hunk",h);continue}const g=co(p);let v=0,m=0;if(g==null||a==null){if(a!=null){if(s)throw Error("parsePatchContent: Invalid hunk");console.error("parsePatchContent: Invalid hunk",h);continue}a={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&i!=null&&r!=null?Cr(r.contents):[],deletionLines:!d&&i!=null&&r!=null?Cr(i.contents):[],cacheKey:xr(t)},a.additionLines.length===1&&r?.contents===""&&(a.additionLines.length=0),a.deletionLines.length===1&&i?.contents===""&&(a.deletionLines.length=0);for(const k of f){if(k.startsWith("diff --git")){const F=k.trim().match(Za),L=F?.[1]??F?.[2],A=F?.[3]??F?.[4];if(L==null||A==null){if(s)throw Error("parsePatchContent: invalid git diff header");console.error("parsePatchContent: invalid git diff header",k);continue}a.name=W(A.trim()),L!==A&&(a.prevName=W(L.trim()));continue}const _=k.startsWith("---")||k.startsWith("+++")?k.match(n?Qa:Ya):null;if(_!=null){const[,F,L]=_;if(F==="---"&&L!=="/dev/null"){const A=W(L.trim());a.prevName=A,a.name=A}else F==="+++"&&L!=="/dev/null"&&(a.name=W(L.trim()))}else if(n){if(k.startsWith("new mode ")&&(a.mode=W(k.slice(8).trim())),k.startsWith("old mode ")&&(a.prevMode=W(k.slice(8).trim())),k.startsWith("new file mode")&&(a.type="new",a.mode=W(k.slice(13).trim())),k.startsWith("deleted file mode")&&(a.type="deleted",a.mode=W(k.slice(17).trim())),k.startsWith("similarity index")&&(k.startsWith("similarity index 100%")?a.type="rename-pure":a.type="rename-changed"),k.startsWith("index ")){const[,F,L,A]=k.trim().match(Ja)??[];F!=null&&(a.prevObjectId=W(F)),L!=null&&(a.newObjectId=W(L)),A!=null&&(a.mode=W(A))}k.startsWith("rename from ")&&(a.prevName=W(k.slice(12).trim())),k.startsWith("rename to ")&&(a.name=W(k.slice(10).trim()))}}continue}let b,y;for(;f.length>0&&(f[f.length-1]===`
3
3
  `||f[f.length-1]==="\r"||f[f.length-1]===`\r
4
4
  `||f[f.length-1]==="");)f.pop();const{additionStart:S,deletionStart:C}=g;c=d?c:C-1,u=d?u:S-1;const w={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:g.additionCount,additionStart:S,additionLines:v,deletionCount:g.deletionCount,deletionStart:C,deletionLines:m,deletionLineIndex:c,additionLineIndex:u,hunkContent:[],hunkContext:xr(g.hunkContext),hunkSpecs:W(p),noEOFCRAdditions:!1,noEOFCRDeletions:!1};let x=0,E=0;for(let k=1;k<f.length;k++){const _=f[k];if(x>=w.additionCount&&E>=w.deletionCount&&!_.startsWith("\\")){if(s&&Ll(_)&&!El(_))throw Error("parsePatchContent: hunk has more lines than expected");break}const F=_[0];if(F!=="+"&&F!=="-"&&F!==" "&&F!=="\\"){if(s)throw Error("parsePatchContent: invalid hunk line");console.error(`parseLineType: Invalid firstChar: "${F}", full line: "${_}"`),console.error("processFile: invalid rawLine:",_);continue}const L=Rl(F);if(L==="addition"){if(s&&x>=w.additionCount)throw Error("parsePatchContent: hunk has too many addition lines");const A=jn(_);(b==null||b.type!=="change")&&(b=Wn("change",c,u),w.hunkContent.push(b)),u++,x++,d&&a.additionLines.push(A),b.additions++,v++,y="addition"}else if(L==="deletion"){if(s&&E>=w.deletionCount)throw Error("parsePatchContent: hunk has too many deletion lines");const A=jn(_);(b==null||b.type!=="change")&&(b=Wn("change",c,u),w.hunkContent.push(b)),c++,E++,d&&a.deletionLines.push(A),b.deletions++,m++,y="deletion"}else if(L==="context"){if(s&&(E>=w.deletionCount||x>=w.additionCount))throw Error("parsePatchContent: hunk has too many context lines");const A=jn(_);(b==null||b.type!=="context")&&(b=Wn("context",c,u),w.hunkContent.push(b)),u++,c++,x++,E++,d&&(a.deletionLines.push(A),a.additionLines.push(A)),b.lines++,y="context"}else if(L==="metadata"&&b!=null){if(b.type==="context"?(w.noEOFCRAdditions=!0,w.noEOFCRDeletions=!0):y==="deletion"?w.noEOFCRDeletions=!0:y==="addition"&&(w.noEOFCRAdditions=!0),d&&(y==="addition"||y==="context")){const A=a.additionLines.length-1;A>=0&&(a.additionLines[A]=Pe(a.additionLines[A]))}if(d&&(y==="deletion"||y==="context")){const A=a.deletionLines.length-1;A>=0&&(a.deletionLines[A]=Pe(a.deletionLines[A]))}}}if(s&&(x!==w.additionCount||E!==w.deletionCount))throw Error("parsePatchContent: hunk line count mismatch");w.additionLines=v,w.deletionLines=m,w.collapsedBefore=Math.max(Se(w.additionStart,w.additionCount)-o,0),a.hunks.push(w),o=ie(w.additionStart,w.additionCount);for(const k of w.hunkContent)k.type==="context"?(w.splitLineCount+=k.lines,w.unifiedLineCount+=k.lines):(w.splitLineCount+=Math.max(k.additions,k.deletions),w.unifiedLineCount+=k.deletions+k.additions);w.splitLineStart=a.splitLineCount+w.collapsedBefore,w.unifiedLineStart=a.unifiedLineCount+w.collapsedBefore,a.splitLineCount+=w.collapsedBefore+w.splitLineCount,a.unifiedLineCount+=w.collapsedBefore+w.unifiedLineCount}if(a!=null){if(s&&d&&!n&&a.hunks.length===0)throw Error("parsePatchContent: unified file has no hunks");if(a.hunks.length>0&&!d&&a.additionLines.length>0&&a.deletionLines.length>0){const h=a.hunks[a.hunks.length-1],f=ie(h.additionStart,h.additionCount),p=a.additionLines.length,g=Math.max(p-f,0);a.splitLineCount+=g,a.unifiedLineCount+=g}return n||(a.prevName!=null&&a.name!==a.prevName?a.hunks.length>0?a.type="rename-changed":a.type="rename-pure":(i==null||i.contents==="")&&r!=null&&r.contents!==""?a.type="new":i!=null&&i.contents!==""&&(r==null||r.contents==="")&&(a.type="deleted")),a.type!=="rename-pure"&&a.type!=="rename-changed"&&(a.prevName=void 0),hl(a),a}}function Cl(e,t,n=!1){const i=[],r=Sl(e)?e.split(Ka):[e];for(const s of r)try{i.push(bl(s,t!=null?`${t}-${i.length}`:void 0,n))}catch(o){if(n)throw o;console.error(o)}return i}function Sl(e){return e.startsWith("From ")||e.includes(`
5
5
  From `)}function Cr(e){const t=ao(e);for(let n=0;n<t.length;n++)t[n]=W(t[n]);return t}function ao(e){if(e.length===0)return[""];const t=[];let n=0;for(;;){const i=e.indexOf(`