blade-code 0.10.98 → 0.10.100
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-q74f1pj9.js → chunk-0zhdjaen.js} +1 -1
- package/dist/{chunk-b4ahgdtn.js → chunk-10taec1j.js} +2 -2
- package/dist/{chunk-0bsn86gg.js → chunk-1nwc2wt6.js} +1 -1
- package/dist/{chunk-4004spc1.js → chunk-2hb222re.js} +1 -1
- package/dist/{chunk-hphdt9ph.js → chunk-2s86w4yb.js} +36 -36
- package/dist/{chunk-j9cnp8ms.js → chunk-2va6ex5v.js} +1 -1
- package/dist/{chunk-mf2s05b7.js → chunk-39qzk9nm.js} +1 -1
- package/dist/chunk-3awjdsef.js +5 -0
- package/dist/chunk-3ktsyk2g.js +1 -0
- package/dist/{chunk-krhr8xbg.js → chunk-425p4nwx.js} +2 -2
- package/dist/{chunk-hdhxzmw7.js → chunk-4fmtv329.js} +1 -1
- package/dist/{chunk-wzgdm617.js → chunk-53xtssbf.js} +2 -2
- package/dist/chunk-5dkzqgxa.js +1 -0
- package/dist/{chunk-hmgxkjbx.js → chunk-6hr7mv7f.js} +39 -39
- package/dist/{chunk-wkfhpjkf.js → chunk-6jhndjnq.js} +1 -1
- package/dist/{chunk-gcy8nczq.js → chunk-6p9p71qm.js} +1 -1
- package/dist/chunk-6rd8x9j0.js +1 -0
- package/dist/{chunk-8jtwm19d.js → chunk-70hwyc2w.js} +1 -1
- package/dist/{chunk-szccdrah.js → chunk-73t5j9dn.js} +1 -1
- package/dist/{chunk-rmkw6dpm.js → chunk-8wzn2p00.js} +1 -1
- package/dist/{chunk-e99cqtmv.js → chunk-8zm5r6g8.js} +2 -2
- package/dist/{chunk-8v8frtnd.js → chunk-9hsbjy6a.js} +1 -1
- package/dist/{chunk-j0ndrqv6.js → chunk-9sx3vsyj.js} +1 -1
- package/dist/{chunk-7yn3d4cf.js → chunk-ara0zd89.js} +1 -1
- package/dist/chunk-axycs651.js +1 -0
- package/dist/{chunk-9qqhkwbw.js → chunk-b4d43ap3.js} +1 -1
- package/dist/{chunk-7kbtqzy0.js → chunk-c3yd59qh.js} +3 -3
- package/dist/{chunk-h1wvtdh4.js → chunk-c6tq09mt.js} +1 -1
- package/dist/{chunk-3wjb3bhw.js → chunk-cc74b8qp.js} +10 -2
- package/dist/{chunk-fra0nwzj.js → chunk-cp7xsjj2.js} +2 -2
- package/dist/{chunk-nvypaz88.js → chunk-czcxx8tb.js} +1 -1
- package/dist/{chunk-54syvhtz.js → chunk-d8wzc602.js} +2 -2
- package/dist/chunk-dfxfcsm1.js +1 -0
- package/dist/{chunk-ef5b0ysc.js → chunk-dg0d3303.js} +1 -1
- package/dist/{chunk-4ytvrkks.js → chunk-f9asjkfz.js} +1 -1
- package/dist/{chunk-17ck16tq.js → chunk-fvfc95g3.js} +1 -1
- package/dist/{chunk-4crf8nvz.js → chunk-gcnke6s4.js} +2 -2
- package/dist/{chunk-dp9xbrjy.js → chunk-gkdynynx.js} +2 -2
- package/dist/chunk-gr6e2vsy.js +1 -0
- package/dist/{chunk-wzx5s1dm.js → chunk-h8qjkxee.js} +2 -2
- package/dist/{chunk-drqezf1p.js → chunk-hx3c0qn6.js} +1 -1
- package/dist/{chunk-hy9tkb5x.js → chunk-hx55j0d0.js} +419 -414
- package/dist/{chunk-qb1wev32.js → chunk-hz5rsfxv.js} +1 -1
- package/dist/{chunk-e6wgta3m.js → chunk-j00px1es.js} +1 -1
- package/dist/{chunk-azcca8bk.js → chunk-jac8cc04.js} +1 -1
- package/dist/{chunk-63wahkkf.js → chunk-k7vv9vne.js} +1 -1
- package/dist/chunk-kvdk0pfk.js +1 -0
- package/dist/chunk-maebpz1j.js +2 -0
- package/dist/chunk-n4cw6vt1.js +1 -0
- package/dist/chunk-njctfzqw.js +1 -0
- package/dist/{chunk-rzcm8hw3.js → chunk-p0rvgzpx.js} +1 -1
- package/dist/{chunk-7k38nj7a.js → chunk-p4h3p1at.js} +1 -1
- package/dist/chunk-p7t010gq.js +1 -0
- package/dist/chunk-pzp42zf0.js +1 -0
- package/dist/{chunk-v2p30pe1.js → chunk-q1cc7kwn.js} +1 -1
- package/dist/{chunk-s6n0cgg5.js → chunk-q3vza5gt.js} +2 -2
- package/dist/{chunk-my7nr1sx.js → chunk-qc4fe1j6.js} +2 -2
- package/dist/{chunk-gaj6kkb6.js → chunk-qcy79mva.js} +1 -1
- package/dist/{chunk-ps9vc0m3.js → chunk-rej5bbbs.js} +2 -2
- package/dist/{chunk-qdf2a3vf.js → chunk-rmhgyrgh.js} +1 -1
- package/dist/chunk-s0tq8gyx.js +2 -0
- package/dist/chunk-s15phq98.js +1 -0
- package/dist/{chunk-1j3mmdbt.js → chunk-sgzqcr55.js} +1 -1
- package/dist/chunk-t29x8420.js +1 -0
- package/dist/chunk-tagtjbw9.js +2 -0
- package/dist/chunk-tsthz2ex.js +8 -0
- package/dist/{chunk-7wgtj7w4.js → chunk-ttg3xrsc.js} +2 -2
- package/dist/{chunk-p47hbq3a.js → chunk-v9pcf4w4.js} +2 -2
- package/dist/chunk-vgevdm8b.js +1 -0
- package/dist/{chunk-d2f41jxt.js → chunk-w9xfks7f.js} +1 -1
- package/dist/chunk-x677fstt.js +10 -0
- package/dist/{chunk-ks3f9h9n.js → chunk-y7bsjbsa.js} +2 -2
- package/dist/{chunk-vw2j0avq.js → chunk-ykkqywtq.js} +1 -1
- package/dist/web/assets/{ChatView-DRfyX8iK.js → ChatView-Cwc3fRAC.js} +4 -4
- package/dist/web/assets/{CodeBlockHighlighter-DAFduwex.js → CodeBlockHighlighter-IGDocZUy.js} +1 -1
- package/dist/web/assets/FilePreview-EWE-k9VN.js +65 -0
- package/dist/web/assets/{KanbanBoard-CWMPGJNx.js → KanbanBoard-FiiVQgTQ.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-Dp8ahj7G.js → MarkdownRenderer-DjhWmikM.js} +3 -3
- package/dist/web/assets/{SettingsModal-BR_98FMD.js → SettingsModal-bHPx0fVG.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-D5WijUhR.js → TaskSwitcher-CclOfJEl.js} +1 -1
- package/dist/web/assets/{TerminalPanel-CE33pxwb.js → TerminalPanel-Bnep8jE2.js} +1 -1
- package/dist/web/assets/{arrow-left-Cv-KDeEq.js → arrow-left-CiX0E9Mt.js} +1 -1
- package/dist/web/assets/{calendar-clock-Cv_w0wjo.js → calendar-clock-Bgfr-twh.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-BAdiQ6sx.js → chevrons-up-down-B4T5fHUs.js} +1 -1
- package/dist/web/assets/{clock-3-wrrODhWr.js → clock-3-CGIhJjon.js} +1 -1
- package/dist/web/assets/{external-link-CBEu1rS8.js → external-link-DnQv1VYE.js} +1 -1
- package/dist/web/assets/{folder-aphP4iXp.js → folder-C5f8TpGj.js} +1 -1
- package/dist/web/assets/index-DGf6Z2kM.css +1 -0
- package/dist/web/assets/{index-rQ1P5u3I.js → index-DNoVz0u1.js} +61 -57
- package/dist/web/assets/{pause-Bp8TFDGG.js → pause-Cb0ijwnO.js} +1 -1
- package/dist/web/assets/{play-CuOkQMyB.js → play-Dsw1qmpk.js} +1 -1
- package/dist/web/assets/{session-events-C95VE6d2.js → session-events-B4Cq2TwN.js} +1 -1
- package/dist/web/assets/{teamService-BXTinwSE.js → teamService-C69fFhny.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-4n7zxjk0.js +0 -1
- package/dist/chunk-6b232wd7.js +0 -1
- package/dist/chunk-78bmtbzh.js +0 -1
- package/dist/chunk-8dtggj9c.js +0 -2
- package/dist/chunk-a7hz8scf.js +0 -8
- package/dist/chunk-a9ek5zt1.js +0 -5
- package/dist/chunk-d1je4wzc.js +0 -2
- package/dist/chunk-d3z12cgn.js +0 -1
- package/dist/chunk-d62jkv36.js +0 -1
- package/dist/chunk-dc3k9999.js +0 -1
- package/dist/chunk-hdrap16m.js +0 -1
- package/dist/chunk-hvz0wk1j.js +0 -1
- package/dist/chunk-kv6w817v.js +0 -10
- package/dist/chunk-m4bg4jp9.js +0 -1
- package/dist/chunk-mpm2kdf6.js +0 -1
- package/dist/chunk-rztsp1jj.js +0 -1
- package/dist/chunk-tae9c030.js +0 -2
- package/dist/chunk-wq8zryfj.js +0 -1
- package/dist/chunk-ysckkpw0.js +0 -1
- package/dist/chunk-zppdqh51.js +0 -1
- package/dist/web/assets/FilePreview-DP5FG_5E.js +0 -59
- package/dist/web/assets/index-zY4JU9fd.css +0 -1
package/dist/blade.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{we as W}from"./chunk-ttg3xrsc.js";import{Ae as M,ze as F}from"./chunk-rej5bbbs.js";import"./chunk-v9pcf4w4.js";import"./chunk-v508x7cg.js";import"./chunk-dg0d3303.js";import"./chunk-c3yd59qh.js";import"./chunk-c6tq09mt.js";import"./chunk-gcnke6s4.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import{Mh as N,Nh as B}from"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import{mi as T}from"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import"./chunk-tagtjbw9.js";import"./chunk-cp7xsjj2.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import{Vi as J}from"./chunk-w9xfks7f.js";import p from"node:path";var E=process.argv.slice(2),I=c(E),u=I!==null;if(I!==null)T.setGlobalDebug(I);function c(Q){for(let Y=0;Y<Q.length;Y+=1){let U=Q[Y];if(U==="--debug"||U==="-d"){let X=Q[Y+1];return X&&!X.startsWith("-")?X:!0}if(U.startsWith("--debug="))return U.slice(8)||!0}return null}function m(Q){return Q.length===1&&(Q[0]==="--version"||Q[0]==="-V")}function q(Q,...Y){return Q.some((U)=>Y.some((X)=>U===X||U.startsWith(`${X}=`)))}function t(Q,...Y){let U=[];for(let X=0;X<Q.length;X+=1){let G=Q[X],z=Y.find(($)=>G.startsWith(`${$}=`));if(z){let $=G.slice(z.length+1);if($)U.push($);continue}if(Y.includes(G)){let $=Q[X+1];if($&&!$.startsWith("-"))U.push($),X+=1}}return U}async function l(){if(m(E)){let{getVersion:K}=await import("./chunk-gr6e2vsy.js");console.log(K());return}let Q=process.cwd(),Y=F(Q);M(Y),N(B());let U=t(E,"--plugin-dir","--pluginDir");if(U.length>0){let{configureInvocationPluginDirs:K}=await import("./chunk-s15phq98.js");K(U.map((Z)=>p.resolve(Q,Z)))}if(q(E,"--trust-workspace","--trustWorkspace")){let{WorkspaceTrustService:K}=await import("./chunk-kvdk0pfk.js");await K.getInstance().trust(B())}if(process.getuid&&process.getuid()===0){let K=!!process.env.SUDO_USER,Z=!!process.env.BLADE_ALLOW_ROOT;if(K&&!Z)console.error(""),console.error("Error: 请不要使用 sudo 运行 blade"),console.error(""),console.error("原因:"),console.error(" 使用 sudo 会创建属于 root 的配置文件,"),console.error(" 导致普通用户无法访问。"),console.error(""),console.error("正确用法:"),console.error(" blade # 直接运行,不要加 sudo"),console.error(""),console.error("如果遇到权限错误,请运行:"),console.error(" sudo chown -R $USER:$USER ~/.blade/"),console.error(""),console.error("如果你确实需要以 root 运行(容器/CI),设置环境变量:"),console.error(" BLADE_ALLOW_ROOT=1 blade"),console.error(""),process.exit(1)}if(q(E,"--headless")){let{handleHeadlessMode:K}=await import("./chunk-8wzn2p00.js");if(await K())return}if(W(),q(E,"--print","-p")){let{handlePrintMode:K}=await import("./chunk-hx3c0qn6.js");if(await K())return}if(E.includes("--acp")){let{runAcpIntegration:K}=await import("./chunk-p4h3p1at.js");await K();return}let[{default:X},{hideBin:G},{cliConfig:z,globalOptions:$},{loadConfiguration:_,validateOutput:D,validatePermissions:R},{browserCommands:S},{doctorCommands:k},{installCommands:O},{mcpCommands:y},{projectsCommands:V},{scheduleCommands:b},{serveCommand:P},{updateCommands:x},{webCommand:A}]=await Promise.all([import("yargs"),import("yargs/helpers"),import("./chunk-vgevdm8b.js"),import("./chunk-pzp42zf0.js"),import("./chunk-ykkqywtq.js"),import("./chunk-y7bsjbsa.js"),import("./chunk-9hsbjy6a.js"),import("./chunk-6jhndjnq.js"),import("./chunk-4fmtv329.js"),import("./chunk-b4d43ap3.js"),import("./chunk-axycs651.js"),import("./chunk-q1cc7kwn.js"),import("./chunk-x677fstt.js")]),h=X(G(process.argv)).scriptName(z.scriptName).usage(z.usage).version(z.version).locale(z.locale).showHelpOnFail(z.showHelpOnFail).demandCommand(0,"").recommendCommands().strict(z.strict).parserConfiguration({"populate--":!0}).options($).middleware([_,R,D]).command(S).command(y).command(V).command(b).command(k).command(x).command(O).command(A).command(P).completion("completion",!1).help("help","Show help").alias("help","h").alias("version","V").fail((K,Z,L)=>{if(Z){if(console.error("An error occurred:"),console.error(Z.message),u&&Z.stack)console.error(`
|
|
3
3
|
Stack trace:`),console.error(Z.stack);else console.error(`
|
|
4
4
|
Run with --debug to show the stack trace.`);process.exit(1)}if(K)console.error("Error: Invalid arguments:"),console.error(K),console.error(`
|
|
5
|
-
Hint: Did you mean:`),L.showHelp(),process.exit(1)}).command("$0",!1,()=>{},async(K)=>{let Z=K._.slice(1),L=Z.length>0?Z.join(" "):void 0,f=import("./chunk-
|
|
5
|
+
Hint: Did you mean:`),L.showHelp(),process.exit(1)}).command("$0",!1,()=>{},async(K)=>{let Z=K._.slice(1),L=Z.length>0?Z.join(" "):void 0,f=import("./chunk-t29x8420.js").then(({checkVersionOnStartup:v})=>v()),[{render:w},{createElement:j},{AppWrapper:C}]=await Promise.all([import("ink"),import("react"),import("./chunk-73t5j9dn.js")]),H={...K,initialMessage:L,debug:K.debug,print:Boolean(K.print),versionCheckPromise:f};delete H._,delete H.$0,delete H.message,w(j(C,H),{patchConsole:!0,exitOnCtrlC:!1,alternateBuffer:!1})});try{await h.parse()}catch(K){console.error("Error: Parse error:",K),process.exit(1)}}if(J.main==J.module)l().catch(console.error);export{l as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Vi as K}from"./chunk-w9xfks7f.js";import{spawn as Y}from"node:child_process";import{constants as j}from"node:fs";import{access as x,readFile as B}from"node:fs/promises";import{createRequire as L}from"node:module";import C from"node:path";var P="blade browser install";var D=["PATH","Path","PATHEXT","HOME","USERPROFILE","LOCALAPPDATA","PROGRAMDATA","TMPDIR","TMP","TEMP","LANG","LC_ALL","LC_CTYPE","TZ","SystemRoot","SYSTEMROOT","WINDIR","COMSPEC","XDG_RUNTIME_DIR","CHROME_DEVEL_SANDBOX"],A=[...D,"PLAYWRIGHT_BROWSERS_PATH","PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT","PLAYWRIGHT_DOWNLOAD_HOST","PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","http_proxy","https_proxy","no_proxy","NODE_EXTRA_CA_CERTS","SSL_CERT_FILE","SSL_CERT_DIR"],J=32768,M=4096;function U(f,F){let $={};for(let Z of F){let q=f[Z];if(q!==void 0&&q.length<=J)$[Z]=q}return $}function V(f=process.env){return U(f,D)}function S(f=process.env){return U(f,A)}function W(){return L(import.meta.url).resolve("playwright/package.json")}function y(f=W){return C.join(C.dirname(f()),"cli.js")}async function T(){return await import("playwright")}async function m(f){let F=JSON.parse(await B(f,"utf8"));if(typeof F.version!=="string"||F.version.length===0)throw Error("Playwright package version is invalid");return F.version}function I(f){return(f instanceof Error?f.message:String(f)).replace(/[\r\n]+/g," ").slice(0,M)}async function R(f={}){let $=(f.resolvePackageJson??W)(),Z=await m($),q=await(f.loadPlaywright??T)(),G=q.chromium.executablePath(),H=f.access??x,z;try{await H(G,j.X_OK),z=await q.chromium.launch({executablePath:G,headless:!0,chromiumSandbox:!0,env:V(f.environment)});let Q=z.version();return await z.close(),z=void 0,{playwrightVersion:Z,executablePath:G,installed:!0,browserVersion:Q}}catch(Q){return{playwrightVersion:Z,executablePath:G,installed:!1,error:I(Q)}}finally{await z?.close().catch(()=>{return})}}async function N(f={}){let F=f.resolvePackageJson??W,$=y(F),Z=f.spawn??((q,G,H)=>Y(q,[...G],H));await new Promise((q,G)=>{let H=Z(f.execPath??process.execPath,[$,"install","chromium"],{env:S(f.environment),shell:!1,stdio:"inherit"}),z=!1;H.once("error",(Q)=>{if(z)return;z=!0,G(Q)}),H.once("close",(Q,X)=>{if(z)return;if(z=!0,Q===0){q();return}G(Error(X?`Playwright browser installer stopped by ${X}`:`Playwright browser installer exited with code ${Q??1}`))})})}
|
|
2
2
|
export{P as va,V as wa,R as xa,N as ya};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{Z as
|
|
1
|
+
import{lg as Q}from"./chunk-p0rvgzpx.js";import{Bh as k,Eh as G,zh as F}from"./chunk-czcxx8tb.js";var V=k.String({minLength:1,maxLength:128,pattern:"^[A-Za-z0-9][A-Za-z0-9_-]*$"}),K=k.Array(k.String({minLength:1,maxLength:200,pattern:".*\\S.*"}),{maxItems:128}),W=k.Object({description:k.String({minLength:1,maxLength:4096,pattern:".*\\S.*"}),prompt:k.String({minLength:1,maxLength:1e5,pattern:".*\\S.*"}),tools:k.Optional(K),disallowedTools:k.Optional(K),model:k.Optional(k.String({minLength:1,maxLength:200,pattern:".*\\S.*"})),permissionMode:k.Optional(G(["default","acceptEdits","dontAsk","bypassPermissions","plan","ignore"])),maxTurns:k.Optional(k.Integer({minimum:1})),isolation:k.Optional(G(["none","worktree"]))},{additionalProperties:!1});function Z(R){let w;try{w=JSON.parse(R)}catch{throw Error("Invalid JSON provided to --agents")}if(w===null||Array.isArray(w)||typeof w!=="object")throw Error("--agents must be a JSON object");let H=Object.entries(w);if(H.length>64)throw Error("--agents supports at most 64 definitions");return H.map(([z,U])=>{if(!F(V,z).success)throw Error(`Invalid --agents name "${z}": use letters, numbers, hyphens, or underscores`);let I=F(W,U);if(!I.success)throw Error(`Invalid --agents definition for "${z}"`);let q=I.data;return{name:z,description:q.description.trim(),systemPrompt:q.prompt.trim(),tools:q.tools?[...new Set(q.tools.map((B)=>B.trim()))]:void 0,disallowedTools:q.disallowedTools?[...new Set(q.disallowedTools.map((B)=>B.trim()))]:void 0,model:q.model?.trim(),permissionMode:q.permissionMode===void 0?void 0:Q(q.permissionMode),maxTurns:q.maxTurns,isolation:q.isolation,source:"flag"}})}
|
|
2
|
+
export{Z as te};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as P}from"./chunk-
|
|
1
|
+
import{V as P}from"./chunk-hx55j0d0.js";import{tb as K}from"./chunk-2s86w4yb.js";import{$c as S,Qd as B,Zc as G,_c as N,ad as O,bd as s}from"./chunk-6hr7mv7f.js";import{$d as j}from"./chunk-h8qjkxee.js";import{af as q}from"./chunk-dg0d3303.js";import{yf as v}from"./chunk-cc74b8qp.js";import{Pi as z}from"./chunk-q3vza5gt.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
1
|
import{clampThinkingLevel as t,getSupportedThinkingLevels as i}from"@earendil-works/pi-ai";var f=["auto","off","minimal","low","medium","high","xhigh","max"];function s(e){return typeof e==="string"&&f.includes(e)}function g(e,o){let n=i(e);if(o!=="auto"&&!n.includes(o))throw Error(`Reasoning effort ${o} is not supported by ${e.name}`);return{selection:o,effective:o==="auto"?t(e,"high"):o,supported:n}}
|
|
2
|
-
export{s as
|
|
2
|
+
export{s as qf,g as rf};
|