blade-code 0.10.29 → 0.10.31
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/dist/blade.js +2 -2
- package/dist/{chunk-5m5nxkfs.js → chunk-07t42c40.js} +1 -1
- package/dist/{chunk-9pww3s5m.js → chunk-0ew7vmkb.js} +1 -1
- package/dist/{chunk-4qyhtrhx.js → chunk-0qjzgs1d.js} +1 -1
- package/dist/{chunk-s0txchah.js → chunk-1905jhyj.js} +2 -2
- package/dist/chunk-1pr72n4c.js +1 -0
- package/dist/{chunk-hdr8bcxt.js → chunk-1v251p73.js} +1 -1
- package/dist/chunk-1y3jpc4s.js +1 -0
- package/dist/{chunk-8gv6hsrf.js → chunk-2nga4tsd.js} +2 -2
- package/dist/chunk-2q06pq10.js +9 -0
- package/dist/{chunk-5jxm20vq.js → chunk-2rmt821w.js} +2 -2
- package/dist/{chunk-1zpqxjj7.js → chunk-321dpgd3.js} +1 -1
- package/dist/{chunk-4p9cwr9s.js → chunk-3fzevvzm.js} +2 -2
- package/dist/chunk-3gbrc75h.js +1 -0
- package/dist/{chunk-qv9xa4h1.js → chunk-44ep1v89.js} +3 -3
- package/dist/chunk-6pwgtmw3.js +1 -0
- package/dist/chunk-7b81rbkw.js +1 -0
- package/dist/{chunk-heydawsf.js → chunk-7gsqx900.js} +2 -2
- package/dist/{chunk-2d35rmyg.js → chunk-7hs1n09m.js} +2 -2
- package/dist/{chunk-4djps7bz.js → chunk-86phvby9.js} +1 -1
- package/dist/{chunk-amm31k3r.js → chunk-93zgz6v6.js} +1 -1
- package/dist/{chunk-0yy41vwq.js → chunk-9afqfajf.js} +2 -2
- package/dist/{chunk-gdp6fg4e.js → chunk-9jkbhaec.js} +1 -1
- package/dist/{chunk-37se34rx.js → chunk-9wy7xryc.js} +1 -1
- package/dist/chunk-a83cdn7b.js +1 -0
- package/dist/{chunk-pamjbphm.js → chunk-aa4xya8p.js} +2 -2
- package/dist/{chunk-48tz6s0s.js → chunk-anm5phza.js} +2 -2
- package/dist/{chunk-fvfwmdp0.js → chunk-at2krx3x.js} +2 -2
- package/dist/{chunk-vz0zsct0.js → chunk-ayx03d6y.js} +1 -1
- package/dist/{chunk-d4327k1v.js → chunk-b63dfss4.js} +1 -1
- package/dist/{chunk-bk649qwy.js → chunk-bqmd7hp7.js} +41 -41
- package/dist/{chunk-xn5zf98b.js → chunk-byqg8qby.js} +1 -1
- package/dist/{chunk-6kc12pma.js → chunk-c2bgj76r.js} +1 -1
- package/dist/{chunk-0mq1yd3k.js → chunk-c913zbnw.js} +2 -2
- package/dist/{chunk-x1p5dmfv.js → chunk-d0sej62r.js} +2 -2
- package/dist/{chunk-xr033fd3.js → chunk-fqrt55g3.js} +1 -1
- package/dist/{chunk-ej1z75jf.js → chunk-fs1r9hyz.js} +1 -1
- package/dist/chunk-hev5sqxy.js +1 -0
- package/dist/chunk-hrfdc0dt.js +6 -0
- package/dist/{chunk-s3zfyy7r.js → chunk-jmyxhygx.js} +1 -1
- package/dist/{chunk-rezjy4mp.js → chunk-khvbwbtv.js} +2 -2
- package/dist/{chunk-1ggxyyar.js → chunk-km155c83.js} +1 -1
- package/dist/{chunk-z9ytq8tq.js → chunk-ktwp84cv.js} +2 -2
- package/dist/chunk-nnby8asg.js +10 -0
- package/dist/{chunk-grt2wftd.js → chunk-pgs555fv.js} +2 -2
- package/dist/{chunk-39gb49pv.js → chunk-pqsg5265.js} +1 -1
- package/dist/{chunk-d9gthet1.js → chunk-q1v03abc.js} +2 -2
- package/dist/{chunk-p6s92zj1.js → chunk-qat3ara1.js} +1 -1
- package/dist/{chunk-z5eaph4a.js → chunk-qfd0tees.js} +1 -1
- package/dist/chunk-rj3cmn4b.js +1 -0
- package/dist/{chunk-4qtb8yf6.js → chunk-s4zvf2tf.js} +2 -2
- package/dist/{chunk-bbfeb6ry.js → chunk-s6exb18e.js} +3 -3
- package/dist/{chunk-0rwz7tm0.js → chunk-s8889acm.js} +1 -1
- package/dist/{chunk-c2sxy022.js → chunk-t857g6s9.js} +1 -1
- package/dist/{chunk-js9g83ty.js → chunk-tb1hr6w9.js} +1 -1
- package/dist/chunk-tps0kwhy.js +1 -0
- package/dist/chunk-tsfv04af.js +1 -0
- package/dist/chunk-v0sfs2b6.js +1 -0
- package/dist/{chunk-0prp87ys.js → chunk-v1jxren4.js} +1 -1
- package/dist/chunk-vd17dtg7.js +1 -0
- package/dist/{chunk-b5btamzc.js → chunk-vw6z3t41.js} +1 -1
- package/dist/chunk-vy59rm9j.js +2 -0
- package/dist/{chunk-rfybbxab.js → chunk-x36dp4pj.js} +1 -1
- package/dist/{chunk-ekv4hpy8.js → chunk-xhxvde2k.js} +2 -2
- package/dist/{chunk-fewpzx8s.js → chunk-xtaq5ck1.js} +1 -1
- package/dist/{chunk-66f2fv34.js → chunk-xv1bz8f4.js} +326 -326
- package/dist/chunk-y7m792w3.js +1 -0
- package/dist/chunk-y9v884rp.js +204 -0
- package/dist/chunk-ykjpwdba.js +1 -0
- package/dist/{chunk-q0c3fww1.js → chunk-zfpbkkdh.js} +12 -12
- package/dist/{chunk-k98n1xwg.js → chunk-zzkzmrjd.js} +2 -2
- package/dist/web/assets/{ChatView-BtSSERlQ.js → ChatView-SgrwGFY6.js} +5 -5
- package/dist/web/assets/{CodeBlockHighlighter-CAuanOO0.js → CodeBlockHighlighter-BgvTBcCD.js} +1 -1
- package/dist/web/assets/{FilePreview-BKQ-EBj3.js → FilePreview-D1ZOOgV-.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-BdYjJ_NM.js → MarkdownRenderer-BdBwdGfs.js} +3 -3
- package/dist/web/assets/{SettingsModal-CB6hM8fT.js → SettingsModal-y7zf5Dbj.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-sSD4B7C_.js → TaskSwitcher-YYFAqV6o.js} +1 -1
- package/dist/web/assets/{TerminalPanel-ZnEoQU6o.js → TerminalPanel-BjA-x8tb.js} +1 -1
- package/dist/web/assets/index-7zaeanZL.css +1 -0
- package/dist/web/assets/{index-DtOztVFd.js → index-B6QL61mx.js} +4 -4
- package/dist/web/assets/{session-events-C2PMff2v.js → session-events-Bgb4zeFL.js} +9 -9
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-1p45ytbg.js +0 -1
- package/dist/chunk-1yyyt228.js +0 -1
- package/dist/chunk-33wkt12h.js +0 -1
- package/dist/chunk-5dt6199b.js +0 -1
- package/dist/chunk-5x26t0c4.js +0 -204
- package/dist/chunk-a5yd0c77.js +0 -1
- package/dist/chunk-h45x1nem.js +0 -1
- package/dist/chunk-m9rg16w4.js +0 -10
- package/dist/chunk-mqezgpcw.js +0 -1
- package/dist/chunk-pdkj959x.js +0 -1
- package/dist/chunk-pwwm04bc.js +0 -1
- package/dist/chunk-qgp7sqh2.js +0 -1
- package/dist/chunk-s6rdv601.js +0 -2
- package/dist/chunk-szmm21q9.js +0 -1
- package/dist/chunk-tf9jmrwk.js +0 -1
- package/dist/chunk-v5q235ny.js +0 -1
- package/dist/chunk-vz7hpwf0.js +0 -1
- package/dist/chunk-wxzsnptj.js +0 -6
- package/dist/chunk-zx8ktpc4.js +0 -9
- package/dist/web/assets/index-BC7ygRH_.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
function v(b){switch(b){case"default":case"ignore":case void 0:return"default";case"acceptEdits":return"autoEdit";case"dontAsk":case"bypassPermissions":return"yolo";case"plan":return"plan";default:return"default"}}
|
|
2
|
-
export{v as
|
|
2
|
+
export{v as se};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H as P}from"./chunk-
|
|
1
|
+
import{H as P}from"./chunk-xv1bz8f4.js";import{Pa as K}from"./chunk-y9v884rp.js";import{Ib as G,Jb as N,Kb as S,Lb as O,Mb as s,pc as B}from"./chunk-at2krx3x.js";import{xc as j}from"./chunk-khvbwbtv.js";import{xd as q}from"./chunk-c2bgj76r.js";import{Pd as v}from"./chunk-zzkzmrjd.js";import{cg as z}from"./chunk-7gsqx900.js";import R from"node:path";import{nanoid as cf}from"nanoid";import{execFile as I}from"node:child_process";import{createHash as p}from"node:crypto";import{lstat as o,readFile as ff,realpath as V}from"node:fs/promises";import A from"node:path";import{promisify as af}from"node:util";var tf=af(I),L=8388608,U=500,Y=200;async function y(n,a){try{return(await tf("git",["-c","core.pager=cat",...a],{cwd:n,encoding:"utf8",timeout:30000,maxBuffer:L+1024,env:{...process.env,GIT_CONFIG_NOSYSTEM:"1",GIT_PAGER:"cat",GIT_OPTIONAL_LOCKS:"0"}})).stdout}catch(f){let t=f instanceof Error&&f.message.includes("maxBuffer")?`Review target exceeds the ${L} byte limit`:f instanceof Error?f.message:String(f);throw Error(`Git review target failed: ${t}`)}}function Q(n,a){let f=n?.trim();if(!f||f.length>Y||f.includes("\x00")||f.includes(`
|
|
2
2
|
`)||f.includes("\r"))throw Error(`${a} must contain 1-${Y} characters`);return f}function W(n){return n.split("\x00").filter(Boolean)}async function _(n,a){return(await y(n,["rev-parse","--verify",`${a}^{commit}`])).trim()}async function nf(n,a,f,t,g){let w=g,c=await V(n);for(let e of a){let $=A.resolve(c,e),l=A.relative(c,$);if(!l||l.startsWith("..")||A.isAbsolute(l))throw Error(`Untracked review path escapes the workspace: ${e}`);let i=await o($);if(!i.isFile()||i.isSymbolicLink())throw Error(`Untracked review target must be a regular file: ${e}`);if(w+=i.size,w>L)throw Error(`Review target exceeds ${L} bytes`);f.update("\x00untracked\x00"),f.update(l.replaceAll(A.sep,"/")),f.update("\x00");let b=await ff($);f.update(b);let m=Math.max(1,b.toString("utf8").split(`
|
|
3
3
|
`).length);t.set(l.replaceAll(A.sep,"/"),[{start:1,end:m}])}}function M(n,a){let f=new Map,t,g,w,c,e=!1,$=(l,i)=>{let b=f.get(l)??[],m=b.at(-1);if(m&&i<=m.end+1)m.end=Math.max(m.end,i);else b.push({start:i,end:i});f.set(l,b)};for(let l of n.split(`
|
|
4
4
|
`)){if(l.startsWith("--- ")){let i=l.slice(4).split("\t")[0]?.trim();t=i&&i!=="/dev/null"?i.replace(/^a\//,"").replaceAll("\\","/"):void 0;continue}if(l.startsWith("+++ ")){let i=l.slice(4).split("\t")[0]?.trim();e=i==="/dev/null",g=e?t:i?i.replace(/^b\//,"").replaceAll("\\","/"):void 0,w=void 0,c=void 0;continue}if(l.startsWith("@@ ")){let i=/-(\d+)(?:,\d+)? \+(\d+)(?:,\d+)?/.exec(l);w=i?Math.max(1,Number(i[1])):void 0,c=i?Math.max(1,Number(i[2])):void 0;continue}if(!g||w===void 0||c===void 0)continue;if(l.startsWith("+")&&!l.startsWith("+++"))$(g,c),c++;else if(l.startsWith("-")&&!l.startsWith("---"))$(g,e?w:c),w++;else if(!l.startsWith("\\"))w++,c++}for(let l of a)if(!f.has(l))f.set(l,[{start:1,end:1}]);return f}function D(n){if(n.length>U)throw Error(`Review target exceeds the ${U} file limit`)}class d{static async resolve(n,a){let f=await V(n);await y(f,["rev-parse","--is-inside-work-tree"]);let t=await _(f,"HEAD"),g=p("sha256");g.update(`kind\x00${a.kind}\x00head\x00${t}\x00`);let w="",c=[],e,$,l,i,b=new Map;switch(a.kind){case"uncommitted":{w=await y(f,["diff","--binary","--no-ext-diff","--relative","HEAD","--","."]);let m=W(await y(f,["diff","--name-only","-z","--relative","HEAD","--","."])),h=W(await y(f,["ls-files","--others","--exclude-standard","-z","--","."]));if(c=[...new Set([...m,...h])].sort(),D(c),c.length===0)throw Error("No uncommitted changes to review");g.update(w),b=M(w,m),await nf(f,h,g,b,Buffer.byteLength(w)),l="uncommitted changes",i=["Review the uncommitted working tree against HEAD.","Use git status --short, git diff --cached, and git diff, then inspect","every relevant untracked file listed by git status."].join(" ");break}case"base":{let m=Q(a.ref,"Base ref");e=await _(f,m);let h=(await y(f,["merge-base",e,t])).trim();if(w=await y(f,["diff","--binary","--no-ext-diff","--relative",`${h}..${t}`,"--","."]),c=W(await y(f,["diff","--name-only","-z","--relative",`${h}..${t}`,"--","."])),D(c),c.length===0)throw Error(`No changes between ${m} and HEAD`);g.update(w),g.update(`\x00merge-base\x00${h}`),b=M(w,c),l=`changes against ${m}`,i=`Review changes introduced by ${h}..${t}.`;break}case"commit":{let m=Q(a.ref,"Commit ref");if($=await _(f,m),w=await y(f,["show","--format=","--binary","--no-ext-diff","--relative",$,"--","."]),c=W(await y(f,["diff-tree","--root","--no-commit-id","--name-only","-r","-z",$,"--","."])),D(c),c.length===0)throw Error(`Commit has no changes in this workspace: ${m}`);g.update(w),g.update(`\x00commit\x00${$}`),b=M(w,c),l=`commit ${m}`,i=`Review only the changes introduced by commit ${$}.`;break}}if(Buffer.byteLength(w)>L)throw Error(`Review diff exceeds ${L} bytes`);return{info:{kind:a.kind,label:l,headSha:t,...e?{baseSha:e}:{},...$?{commitSha:$}:{},digest:g.digest("hex"),fileCount:c.length},instruction:i,changedLines:b}}}var wf=131072,X=50,E=new Set;function Z(n,a){return`${R.resolve(n)}\x00${a}`}function J(n){return`/review ${n.kind}${n.kind==="uncommitted"?"":` ${n.ref?.trim()??""}`}`}function C(n,a,f,t=!1){if(typeof n!=="string")throw Error(`${a} must be a string`);let g=n.trim();if(!t&&!g||g.length>f)throw Error(`${a} exceeds its allowed length`);return g}function lf(n,a,f){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Review finding must be an object");let t=n,g=typeof t.line==="number"&&Number.isInteger(t.line)?t.line:void 0,w=t.code_location??(typeof t.file==="string"&&g!==void 0?{path:t.file,line_start:g,line_end:g}:void 0);if(!w||typeof w!=="object"||Array.isArray(w))throw Error("Review finding has no code_location");let c=w,e=C(c.path,"Finding path",1000),$=R.posix.normalize(e.replaceAll("\\","/"));if(R.posix.isAbsolute($)||$===".."||$.startsWith("../"))throw Error("Review finding path must be workspace-relative");let l=R.resolve(a,$),i=R.relative(R.resolve(a),l);if(i.startsWith("..")||R.isAbsolute(i))throw Error("Review finding path escapes the workspace");let b=typeof t.severity==="string"?t.severity.toLowerCase():"",m=b==="critical"?0:b==="high"?1:b==="medium"?2:b==="low"?3:void 0,h=t.priority??m;if(h!==0&&h!==1&&h!==2&&h!==3)throw Error("Review finding priority must be 0-3");let x=t.confidence_score??t.confidence??0.8;if(typeof x!=="number"||!Number.isFinite(x)||x<0||x>1)throw Error("Review finding confidence_score must be between 0 and 1");let{line_start:r,line_end:u}=c;if(!Number.isInteger(r)||!Number.isInteger(u)||r<1||u<r||u-r>=10)throw Error("Review finding line range is invalid");let F=f.changedLines.get($);if(!F)throw Error("Review finding path is outside the review target");if(!F.some((T)=>r<=T.end&&u>=T.start))throw Error("Review finding line range does not overlap the changed lines");let k=C(t.title??`[P${h}] ${String(t.type??"Review finding").replaceAll("-"," ").replace(/\b\w/g,(T)=>T.toUpperCase())}`,"Finding title",120);if(!k.startsWith(`[P${h}] `))throw Error("Review finding title priority does not match priority");return{title:k,body:C(t.body??t.description,"Finding body",4000),priority:h,confidenceScore:x,codeLocation:{path:$,lineStart:r,lineEnd:u}}}function mf(n,a,f){if(Buffer.byteLength(n)>wf)throw Error("Review output exceeds the 128 KiB limit");let t=n.indexOf("{"),g=n.lastIndexOf("}");if(t<0||g<=t)throw Error("Reviewer did not return a JSON object");let w;try{w=JSON.parse(n.slice(t,g+1))}catch{throw Error("Reviewer returned invalid JSON")}if(!w||typeof w!=="object"||Array.isArray(w))throw Error("Reviewer output must be an object");let c=w;if(!Array.isArray(c.findings))throw Error("Reviewer output must contain findings");if(c.findings.length>X)throw Error(`Reviewer returned more than ${X} findings`);return{overallExplanation:C(c.overall_explanation??c.summary,"Review explanation",1e4,!0),findings:c.findings.map((e)=>lf(e,a,f))}}async function H(n,a){return new j(z(n,a)).readAll()}class gf{static async start(n){let{sessionId:a,projectPath:f,runtime:t,request:g,onEvent:w}=n;if(t.sessionId!==a||R.resolve(t.workspaceRoot)!==R.resolve(f))throw Error("Review runtime does not own the requested Session");if(t.hasTurnOwner())throw Error("Cannot start a review during an active turn");await B.assertSessionWritable(a,f);let c=Z(f,a);if(E.has(c))throw Error("Session already has an active review");let e=await H(f,a);if(N(e))throw Error("Session has an interrupted review that must be recovered");let $=g.instructions?.trim();if($&&$.length>4000)throw Error("Review instructions exceed 4,000 characters");let l=await d.resolve(f,g),i=cf(16),b=q("review"),m=new Date().toISOString(),h={reviewId:i,reviewerSessionId:b,target:l.info,startedAt:m},x=new K(f);await x.saveReviewStart(a,h),await x.saveMessage(a,"user",J(g),null,{codeReview:{reviewId:i,phase:"started",targetKind:l.info.kind,targetDigest:l.info.digest}}),await B.updateSessionMetadata(a,f,{taskStatus:"running",taskStatusReason:`Reviewing ${l.info.label}`,taskPromptSummary:J(g),taskStartedAt:m,taskCompletedAt:null,taskFailure:null}),E.add(c);let r=this.execute({...n,target:l,reviewId:i,reviewerSessionId:b,instructions:$,store:x,onEvent:w}).finally(()=>{E.delete(c)});return{reviewId:i,completion:r}}static async execute(n){let{sessionId:a,projectPath:f,runtime:t,request:g,signal:w,onEvent:c,target:e,reviewId:$,reviewerSessionId:l,instructions:i,store:b}=n,m;try{let x=[e.instruction,"Bash already starts in the review workspace. Never prefix a command with cd.",`Authoritative target digest: ${e.info.digest}`,`Changed file count: ${e.info.fileCount}`,i?`Additional review instructions:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Tf as S}from"./chunk-d0sej62r.js";import{ig as f}from"./chunk-9wy7xryc.js";import*as $ from"fs/promises";import*as K from"path";import j from"semver";import{ProxyAgent as H,fetch as I}from"undici";function R(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy}function N(){let q=R();if(q)try{return new H(q)}catch(z){console.warn(`[proxyFetch] Invalid proxy URL: ${q}`)}return}async function M(q,z={}){let{timeout:W=30000,signal:Q,...B}=z;if(Q?.aborted)throw new DOMException("The operation was aborted.","AbortError");let J=N(),X=new AbortController,Y=!1,F=setTimeout(()=>{Y=!0,X.abort()},W),b=()=>X.abort();Q?.addEventListener("abort",b);try{let Z={method:B.method,headers:B.headers,body:B.body,signal:X.signal,dispatcher:J};return await I(q.toString(),Z)}catch(Z){if(Z instanceof Error&&Z.name==="AbortError"){if(Y)throw Error(`Request timeout after ${W}ms`);throw Z}throw Z}finally{clearTimeout(F),Q?.removeEventListener("abort",b)}}var w="blade-code",y="https://cdn.jsdelivr.net/npm/blade-code@latest/CHANGELOG.md",G=K.join(process.env.HOME||process.env.USERPROFILE||".",".blade"),O=K.join(G,"version-cache.json"),P=3600000,k=`https://registry.npmjs.org/${w}/latest`;async function L(){try{if(process.env.BLADE_VERSION)return process.env.BLADE_VERSION;return S()}catch{return"unknown"}}async function T(){try{let q=await $.readFile(O,"utf-8"),z=JSON.parse(q);if(Date.now()-z.checkedAt<P)return z;return{...z,checkedAt:0}}catch{return null}}async function D(q){try{await $.mkdir(G,{recursive:!0,mode:493}),await $.writeFile(O,JSON.stringify(q,null,2))}catch{}}async function x(){try{let q=await M(k,{timeout:5000,headers:{Accept:"application/json"}});if(!q.ok)return null;return(await q.json()).version||null}catch{return null}}async function _(q=!1){let z=await L(),W=y;if(z==="unknown")return{currentVersion:z,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:W,error:"Unable to determine current version"};let Q=await T(),B=Q?.skipUntilVersion,J=null;if(!q&&Q?.latestVersion&&Q.checkedAt>0)J=Q.latestVersion;else if(J=await x(),J)await D({latestVersion:J,checkedAt:Date.now(),skipUntilVersion:B});else if(Q?.latestVersion)await D({checkedAt:0,skipUntilVersion:B});if(!J||!j.valid(J))return{currentVersion:z,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:W,error:"Unable to check for updates"};if(j.lt(J,z))J=z,await D({latestVersion:J,checkedAt:Date.now(),skipUntilVersion:B});let X=j.gt(J,z),Y=X;if(X&&B)Y=j.gt(J,B);return{currentVersion:z,latestVersion:J,hasUpdate:X,shouldPrompt:Y,releaseNotesUrl:W}}async function u(q){let z=await T();await D({latestVersion:z?.latestVersion??q,checkedAt:z?.checkedAt||Date.now(),skipUntilVersion:q})}function g(){return`npm install -g ${w}@latest --registry https://registry.npmjs.org`}async function C(){let{spawn:q}=await import("child_process");return new Promise((z)=>{let W=g(),Q=q(W,{stdio:"inherit",shell:!0});Q.on("close",(B)=>{if(B===0)z({success:!0,message:"Upgrade successful! Please restart blade."});else z({success:!1,message:`Upgrade failed (exit code: ${B})`})}),Q.on("error",(B)=>{z({success:!1,message:`Upgrade failed: ${B.message}`})})})}async function V(){try{let q=await _();return q.shouldPrompt?q:null}catch{return null}}
|
|
2
2
|
export{_ as a,u as b,g as c,C as d,V as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Yf as a}from"./chunk-7hs1n09m.js";import"./chunk-b63dfss4.js";import"./chunk-7gsqx900.js";import"./chunk-9wy7xryc.js";export{a as WorkspaceTrustService};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-tb1hr6w9.js";import"./chunk-d0sej62r.js";import"./chunk-9wy7xryc.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$a as e,Ta as a,Ua as b,Wa as c,_a as d,ab as f,bb as g,cb as h,db as i,eb as j,fb as k,kb as l,lb as m,mb as n,nb as o,pb as p,qb as q,rb as r}from"./chunk-y9v884rp.js";import"./chunk-fs1r9hyz.js";import"./chunk-at2krx3x.js";import"./chunk-86phvby9.js";import"./chunk-khvbwbtv.js";import"./chunk-c2bgj76r.js";import"./chunk-s4zvf2tf.js";import"./chunk-ayx03d6y.js";import"./chunk-v1jxren4.js";import"./chunk-0ew7vmkb.js";import"./chunk-44ep1v89.js";import"./chunk-jmyxhygx.js";import"./chunk-9jkbhaec.js";import"./chunk-0qjzgs1d.js";import"./chunk-vy59rm9j.js";import"./chunk-km155c83.js";import"./chunk-xhxvde2k.js";import"./chunk-2nga4tsd.js";import"./chunk-07t42c40.js";import"./chunk-d0sej62r.js";import"./chunk-b63dfss4.js";import"./chunk-7gsqx900.js";import"./chunk-9wy7xryc.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var i="verification",E="goal-verification",e="review";function t(n){return n==="verification"||n==="goal-verification"}function o(n){return t(n)||n==="review"}
|
|
2
|
-
export{i as
|
|
2
|
+
export{i as ie,E as je,e as ke,t as le,o as me};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Kd as a,Ld as b,Md as c}from"./chunk-pgs555fv.js";import"./chunk-9afqfajf.js";import"./chunk-9jkbhaec.js";import"./chunk-0qjzgs1d.js";import"./chunk-vy59rm9j.js";import"./chunk-km155c83.js";import"./chunk-xhxvde2k.js";import"./chunk-2nga4tsd.js";import"./chunk-07t42c40.js";import"./chunk-d0sej62r.js";import"./chunk-7hs1n09m.js";import"./chunk-b63dfss4.js";import"./chunk-7gsqx900.js";import"./chunk-9wy7xryc.js";export{c as snapshotWorkspaceModelResources,b as resolveWorkspaceModelResources,a as cloneWorkspaceModelConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-
|
|
1
|
+
import{a as o}from"./chunk-tb1hr6w9.js";import"./chunk-d0sej62r.js";import"./chunk-9wy7xryc.js";import{execSync as r}from"child_process";var l={command:"update",describe:"Check for updates and install if available",handler:async()=>{console.log("Checking for updates...");try{let e=await o(!0);if(console.log(`Current version: ${e.currentVersion}`),e.error){console.log(`Warning: ${e.error}`);return}if(e.latestVersion)console.log(`Latest version: ${e.latestVersion}`);if(e.hasUpdate&&e.latestVersion){console.log(""),console.log(`\x1B[33mUpdate available: ${e.currentVersion} -> ${e.latestVersion}\x1B[0m`),console.log(""),console.log("Updating...");try{r("npm install -g blade-code@latest --registry https://registry.npmjs.org",{stdio:"inherit"}),console.log(""),console.log("Update complete!")}catch(t){console.error("Error: Update failed. Please run manually:"),console.error(" npm install -g blade-code@latest"),process.exit(1)}}else console.log("You are running the latest version of Blade")}catch(e){console.error(`Error: Failed to check for updates: ${e instanceof Error?e.message:"未知错误"}`),process.exit(1)}}};export{l as updateCommands};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as F,aa as L}from"./chunk-
|
|
1
|
+
import{_ as F,aa as L}from"./chunk-xv1bz8f4.js";import{fc as $,hc as B,pc as Q}from"./chunk-at2krx3x.js";import{fe as y}from"./chunk-zzkzmrjd.js";import{Bf as V}from"./chunk-km155c83.js";async function j(){await y(V())}async function I(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(!z.isTTY){let G=[];for await(let K of z)G.push(K);return Buffer.concat(G).toString("utf-8").trim()}if(b.defaultMessage!==void 0)return b.defaultMessage;throw Error("No input provided")}async function M(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(z.isTTY)return;let G=[];for await(let Z of z)G.push(Buffer.isBuffer(Z)?Z:Buffer.from(Z));return Buffer.concat(G).toString("utf-8").trim()||void 0}async function R(b){if(!F(b))return{mode:"agent",content:b};let q=await L(b,{cwd:V(),surface:"headless",workspaceRoot:V()});if(!q.success)return{mode:"output",content:`Error: ${q.error||"未知错误"}`,exitCode:1};let z=q.data;if(z?.action==="invoke_skill"){let{skillName:G,skillArgs:K}=z;return{mode:"agent",content:K?`Please use the "${G}" skill to help me with: ${K}`:`Please use the "${G}" skill.`}}if(z?.action==="invoke_custom_command"||z?.action==="invoke_plugin_command"){let G=z.processedContent;return{mode:"agent",content:`# Custom Command: /${z.commandName}
|
|
2
2
|
|
|
3
3
|
${G}`}}return{mode:"output",content:q.content||q.message||"",exitCode:0}}import{readFile as D,stat as H}from"node:fs/promises";import J from"node:path";function x(b,q){let z;try{z=JSON.parse(b)}catch(G){throw Error(`Invalid JSON output schema from ${q}`,{cause:G})}return B(z).schema}async function _(b){if(b.jsonSchema!==void 0&&b.outputSchema!==void 0)throw Error("--json-schema cannot be combined with --output-schema");if(b.jsonSchema!==void 0)return x(b.jsonSchema,"--json-schema");if(b.outputSchema===void 0)return;let q=J.resolve(b.outputSchema),z=await H(q);if(!z.isFile())throw Error(`Output schema path is not a regular file: ${q}`);if(z.size>$)throw Error(`Output schema exceeds ${$} bytes: ${q}`);return x(await D(q,"utf8"),q)}function N(b){if(!(b instanceof Error))return!1;return b.message.includes("未找到会话")||b.message.includes("ENOENT")||b.message.includes("no such file")}async function W(b){try{return await Q.loadSessionModelContext(b,V())}catch(q){if(N(q))return null;throw q}}async function C(b){if(b.resume===!0||b.resume==="true")throw Error("--resume without a session ID is only supported in interactive UI mode");if(typeof b.resume==="string"&&b.resume.length>0){if(b.forkSession){let G=V(),K=await Q.forkSession(b.resume,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...K,messages:await Q.loadSessionModelContext(K.sessionId,G)}}let[q,z]=await Promise.all([Q.loadSessionModelContext(b.resume),Q.findSessionMetadata(b.resume)]);return{sessionId:b.resume,messages:q,metadata:z}}if(b.continue){let q=b.forkSession?await Q.listSessions({cwd:V()}):await Q.listSessions();if(q.length>0){let z=q[0].sessionId;if(b.forkSession){let G=V(),K=await Q.forkSession(z,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...K,messages:await Q.loadSessionModelContext(K.sessionId,G)}}return{sessionId:z,messages:await Q.loadSessionModelContext(z),metadata:q[0]}}if(b.forkSession)throw Error("Cannot fork: no sessions are available to continue")}if(b.sessionId){let q=await W(b.sessionId);return{sessionId:b.sessionId,messages:q??[],...q?{metadata:await Q.findSessionMetadata(b.sessionId,V())}:{}}}return{sessionId:`${b.fallbackSessionPrefix}-${Date.now()}`,messages:[]}}
|
|
4
4
|
export{j as m,I as n,M as o,R as p,_ as q,C as r};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{gg as j}from"./chunk-7gsqx900.js";import{appendFileSync as E,existsSync as O,mkdirSync as R,readdirSync as U,statSync as B,unlinkSync as k}from"node:fs";import W from"node:path";var X;((H)=>{H[H.DEBUG=0]="DEBUG";H[H.INFO=1]="INFO";H[H.WARN=2]="WARN";H[H.ERROR=3]="ERROR"})(X||={});var T=null,_=null,$=!1;function m(q){if(T!==q)T=q}async function I(){}function w(){if($)return _;$=!0;try{let q=W.join(j(),"logs");if(!O(q))R(q,{recursive:!0,mode:493});if(B(q).uid===0&&process.getuid&&process.getuid()!==0)return console.error(""),console.error("[FAIL] 权限错误:~/.blade/logs 目录属于 root 用户"),console.error(""),console.error("这通常是因为您曾经使用 sudo 运行过 blade。"),console.error(""),console.error("解决方法:"),console.error(" sudo chown -R $USER:$USER ~/.blade/"),console.error(""),console.error("然后重新运行 blade(不要使用 sudo)"),console.error(""),null;return z(q,30),_=q,q}catch(q){return console.error("[Logger] 无法创建日志目录:",q),null}}function z(q,G){try{let J=U(q),K=Date.now(),H=G*24*60*60*1000;for(let Q of J){if(!Q.startsWith("blade-")||!Q.endsWith(".log")&&!Q.endsWith(".jsonl"))continue;let Y=W.join(q,Q);try{let Z=B(Y);if(K-Z.mtimeMs>H)k(Y)}catch(Z){}}}catch(J){}}function F(){let q=w();if(!q)return null;let G=T||"default";return W.join(q,`blade-${G}.jsonl`)}function A(q,G,J){let K=F();if(!K)return;try{let H={timestamp:new Date().toISOString(),level:X[G],category:q,message:J};E(K,JSON.stringify(H)+`
|
|
2
2
|
`)}catch(H){}}class M{static globalDebugConfig=null;enabled;minLevel;category;constructor(q={}){if(q.enabled!==void 0)this.enabled=q.enabled;else if(M.globalDebugConfig!==null)this.enabled=Boolean(M.globalDebugConfig);else this.enabled=!1;this.minLevel=q.minLevel??0,this.category=q.category??"General"}static setGlobalDebug(q){M.globalDebugConfig=q}static clearGlobalDebug(){M.globalDebugConfig=null}setEnabled(q){this.enabled=q}parseDebugFilter(q){if(!q)return{enabled:!1};if(q===!0||q==="true"||q==="1")return{enabled:!0};let G=String(q).trim();if(!G)return{enabled:!0};if(G.startsWith("!"))return{enabled:!0,filter:{mode:"exclude",categories:G.split(",").map((H)=>H.trim().replace(/^!/,"")).filter(Boolean)}};return{enabled:!0,filter:{mode:"include",categories:G.split(",").map((K)=>K.trim()).filter(Boolean)}}}shouldLogCategory(q){if(!q)return!0;let G=this.category.toLowerCase();if(q.mode==="include")return q.categories.some((J)=>G.includes(J.toLowerCase()));return!q.categories.some((J)=>G.includes(J.toLowerCase()))}shouldLogToConsole(q){if(M.globalDebugConfig!==null){let{enabled:G,filter:J}=this.parseDebugFilter(M.globalDebugConfig);if(!G)return!1;if(q<this.minLevel)return!1;return this.shouldLogCategory(J)}return this.enabled&&q>=this.minLevel}log(q,...G){let J=G.map((K)=>typeof K==="object"?JSON.stringify(K):String(K)).join(" ");if(A(this.category,q,J),this.shouldLogToConsole(q)){let K=X[q],H=`[${this.category}] [${K}]`;console.error(H,...G)}}debug(...q){this.log(0,...q)}info(...q){this.log(1,...q)}warn(...q){this.log(2,...q)}error(...q){this.log(3,...q)}}function V(q,G){return new M({...G,category:q})}var h=new M({category:"General"});
|
|
3
|
-
export{m as
|
|
3
|
+
export{m as Cf,I as Df,M as Ef,V as Ff,h as Gf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as o}from"./chunk-
|
|
1
|
+
import{D as o}from"./chunk-xv1bz8f4.js";import{pc as i}from"./chunk-at2krx3x.js";import a from"node:path";function n(e){let s=e.replace(/\s+/g," ").trim();return s.length<=72?s:`${s.slice(0,69)}...`}function c(e){let s=e.replace(/\s+/g," ").trim();return s.length<=500?s:`${s.slice(0,497)}...`}function d(e){return`task/${e.replace(/[^a-zA-Z0-9_-]/g,"-").slice(0,40)}`}class m{static async createSessionTask(e){if(!e.prompt.trim())throw Error("Task prompt must not be blank");if(!a.isAbsolute(e.sourceProjectPath))throw Error("Task source project path must be absolute");let s=a.resolve(e.sourceProjectPath),t;try{return t=e.isolation==="worktree"?await o.enter({sessionId:e.sessionId,workspaceRoot:s,name:d(e.sessionId)}):void 0,{metadata:await i.createSessionMetadata(e.sessionId,t?.workspaceRoot??s,{title:e.title?.trim()||n(e.prompt),taskPromptSummary:c(e.prompt),taskDispatch:e.dispatch,taskModelId:e.dispatch?.modelId,selectedModelId:e.dispatch?.modelId,permissionMode:e.dispatch?.permissionMode,reasoningEffort:e.dispatch?.reasoningEffort,serviceTier:e.dispatch?.serviceTier,responseVerbosity:e.dispatch?.responseVerbosity,communicationStyle:e.dispatch?.communicationStyle,communicationStyleDigest:e.dispatch?.communicationStyleDigest,projectInstructionsDigest:e.dispatch?.projectInstructionsDigest,taskRetriedFrom:e.retriedFrom,taskIsolation:e.isolation,taskSourceProjectPath:s,taskWorktree:t}),taskWorktree:t}}catch(r){if(t)await o.exit({sessionId:e.sessionId,action:"remove",discardChanges:!0}).catch(()=>{return});throw r}}}
|
|
2
2
|
export{m as t};
|