blade-code 0.10.205 → 0.10.206
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-09kqfdpa.js +3 -0
- package/dist/{chunk-efjjkha8.js → chunk-0ef47wgr.js} +2 -2
- package/dist/chunk-1j39te3t.js +23 -0
- package/dist/{chunk-fdr4fcrf.js → chunk-1n4v80hy.js} +1 -1
- package/dist/{chunk-ynd1v33f.js → chunk-28n945me.js} +2 -2
- package/dist/{chunk-ys8gysg8.js → chunk-28tzj187.js} +1 -1
- package/dist/{chunk-qtwgm95z.js → chunk-3crwyd2r.js} +3 -3
- package/dist/{chunk-zfxcef0z.js → chunk-50vwafn5.js} +1 -1
- package/dist/chunk-514va7ce.js +2 -0
- package/dist/{chunk-kkzznz4w.js → chunk-53vh6vpt.js} +1 -1
- package/dist/chunk-5k8k56f2.js +731 -0
- package/dist/{chunk-515yj7mt.js → chunk-65wc1h38.js} +1 -1
- package/dist/{chunk-xbs91jd8.js → chunk-67wy9mm7.js} +2 -2
- package/dist/chunk-6p0hkf4f.js +1 -0
- package/dist/{chunk-qdbbke8f.js → chunk-6xzk4hsg.js} +1 -1
- package/dist/chunk-793wjhvz.js +332 -0
- package/dist/{chunk-rtwd35gd.js → chunk-826xegd8.js} +2 -2
- package/dist/chunk-867bpjzg.js +1 -0
- package/dist/{chunk-zj1g4nbq.js → chunk-870szc6v.js} +1 -1
- package/dist/chunk-983hqzat.js +1 -0
- package/dist/{chunk-0eajnhrj.js → chunk-9kj19a8t.js} +1 -1
- package/dist/{chunk-430b319j.js → chunk-9sf1t8gw.js} +1 -1
- package/dist/chunk-9tpzmy8v.js +4 -0
- package/dist/chunk-af0m5227.js +1 -0
- package/dist/{chunk-f8kjdxz7.js → chunk-asgmmaec.js} +2 -2
- package/dist/{chunk-vz88tqtd.js → chunk-av799ng5.js} +2 -2
- package/dist/{chunk-bwe49m6n.js → chunk-az3rehz9.js} +360 -360
- package/dist/{chunk-p0wyhp5a.js → chunk-dnpkf5mv.js} +2 -2
- package/dist/chunk-dpg006xj.js +1 -0
- package/dist/{chunk-xmymx75h.js → chunk-e0ft3vwg.js} +1 -1
- package/dist/chunk-e45r1a8r.js +25 -0
- package/dist/{chunk-g01mth5d.js → chunk-ebpg1srd.js} +2 -2
- package/dist/{chunk-4wx5sya5.js → chunk-ed2hdrwe.js} +1 -1
- package/dist/{chunk-7ajvrtb3.js → chunk-erhaedch.js} +1 -1
- package/dist/{chunk-kehgewqh.js → chunk-ewwrss2w.js} +1 -1
- package/dist/{chunk-kf9gj2gn.js → chunk-fc1gz532.js} +2 -2
- package/dist/{chunk-9jz1q7bk.js → chunk-fd0a8h55.js} +2 -2
- package/dist/{chunk-qp2qc4p2.js → chunk-fnmqxhv1.js} +2 -2
- package/dist/chunk-g7tphxme.js +6 -0
- package/dist/{chunk-eg3ms291.js → chunk-gmpsfkgg.js} +1 -1
- package/dist/chunk-gpnkxh4c.js +1 -0
- package/dist/{chunk-b8ast0cp.js → chunk-gz84aewr.js} +1 -1
- package/dist/{chunk-xxbxc31z.js → chunk-h4k69z1b.js} +1 -1
- package/dist/{chunk-17d4m89n.js → chunk-h6ahwwpa.js} +2 -2
- package/dist/chunk-hpge30p8.js +8 -0
- package/dist/{chunk-1cy4ab77.js → chunk-hv8nt7wj.js} +1 -1
- package/dist/chunk-mtvbm7xe.js +1 -0
- package/dist/chunk-mys9mmcp.js +1 -0
- package/dist/{chunk-wezr6wfq.js → chunk-n34qsnks.js} +1 -1
- package/dist/chunk-n5jzmwhy.js +25 -0
- package/dist/chunk-new78c3h.js +1 -0
- package/dist/{chunk-8pd1hp4r.js → chunk-nj6kpdte.js} +2 -2
- package/dist/chunk-nng1xbsm.js +10 -0
- package/dist/{chunk-xyypxrad.js → chunk-p2y1zqsb.js} +2 -2
- package/dist/chunk-p8vpvx07.js +12 -0
- package/dist/{chunk-w42j9p3t.js → chunk-pdna2qvv.js} +2 -2
- package/dist/{chunk-gn9er641.js → chunk-pga8gxtf.js} +1 -1
- package/dist/chunk-pt0y4zrg.js +14 -0
- package/dist/{chunk-5zmp7p0n.js → chunk-q6abav45.js} +51 -51
- package/dist/chunk-r4em0ha7.js +1 -0
- package/dist/chunk-rdzbd5vk.js +1 -0
- package/dist/chunk-sbfe9vh3.js +94 -0
- package/dist/chunk-sqk8cnej.js +44 -0
- package/dist/{chunk-5yyp6njq.js → chunk-t0gm0pn1.js} +1 -1
- package/dist/{chunk-egss0m1x.js → chunk-tsm8rhmd.js} +1 -1
- package/dist/chunk-tzvb0nd2.js +2 -0
- package/dist/{chunk-kvp523gt.js → chunk-v4cxk10d.js} +1 -1
- package/dist/{chunk-ak5xvsxr.js → chunk-v5vx6nz9.js} +1 -1
- package/dist/{chunk-qq5y7b2r.js → chunk-vx2g1faw.js} +1 -1
- package/dist/chunk-w6zat4v4.js +1 -0
- package/dist/chunk-wsd3rn0q.js +1 -0
- package/dist/{chunk-c51wwnh2.js → chunk-xcq0cehr.js} +5 -6
- package/dist/chunk-yjjxv7fn.js +352 -0
- package/dist/{chunk-6169xxb4.js → chunk-yzf2jpam.js} +2 -2
- package/dist/web/assets/{ChatView-BF6HUrBw.js → ChatView-lUD-61n0.js} +4 -4
- package/dist/web/assets/{CodeBlockHighlighter-C4CgCiRf.js → CodeBlockHighlighter--TbfcBxW.js} +1 -1
- package/dist/web/assets/FilePreview-R6OKQPf2.js +55 -0
- package/dist/web/assets/{KanbanBoard-DDXB-yq1.js → KanbanBoard-BHOKtiv5.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-DS7RznBE.js → MarkdownRenderer-DqxNq8pa.js} +3 -3
- package/dist/web/assets/{ScrollArea-BM9NzGZM.js → ScrollArea-Dhu0B-zB.js} +1 -1
- package/dist/web/assets/{SessionHistorySurface-DnRySeLE.js → SessionHistorySurface-aZvoj3ma.js} +1 -1
- package/dist/web/assets/{SettingsModal-D5YLUtIo.js → SettingsModal-C7QBnIqa.js} +1 -1
- package/dist/web/assets/{Sidebar-BZC6OkDJ.js → Sidebar-Bznnq91x.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-WewOkw5m.js → TaskSwitcher-DJczhDRp.js} +1 -1
- package/dist/web/assets/{TerminalPanel-C5SGdRNr.js → TerminalPanel-Vk4p0V3p.js} +1 -1
- package/dist/web/assets/{archive-DkczUU08.js → archive-0hLYBKQf.js} +1 -1
- package/dist/web/assets/{arrow-left-9pBiQwu7.js → arrow-left-CXb6Gqf3.js} +1 -1
- package/dist/web/assets/{calendar-clock-BFnUlxrU.js → calendar-clock-DiaFI9Jk.js} +1 -1
- package/dist/web/assets/{chevron-right-yCVkAEcj.js → chevron-right-CcPXH37D.js} +1 -1
- package/dist/web/assets/{clock-3-CcoWoRQs.js → clock-3-D6VR6gJc.js} +1 -1
- package/dist/web/assets/{copy-HJF0oQBS.js → copy-C3eUAQgp.js} +1 -1
- package/dist/web/assets/{download-DSBCIqk3.js → download-DHvS9tI3.js} +1 -1
- package/dist/web/assets/{external-link-zIgEO0KB.js → external-link-BDVaEuqY.js} +1 -1
- package/dist/web/assets/{folder-BdRo64o3.js → folder-B80Ac6rr.js} +1 -1
- package/dist/web/assets/index-VwIiNjc8.css +1 -0
- package/dist/web/assets/{index-BVDkKudh.js → index-YqughEZk.js} +4 -4
- package/dist/web/assets/{message-square-plus-3klTXO0S.js → message-square-plus-D15quyPH.js} +1 -1
- package/dist/web/assets/{pause-B9Q5JWvH.js → pause-BjMlj6Bx.js} +1 -1
- package/dist/web/assets/{pencil-CbYIz1b1.js → pencil-BMoJvcB7.js} +1 -1
- package/dist/web/assets/{play-CZMTj43e.js → play-BHh4py3p.js} +1 -1
- package/dist/web/assets/{plus-Cc7I8fhb.js → plus-DeFz_gQq.js} +1 -1
- package/dist/web/assets/session-events-DCHBz9We.js +25 -0
- package/dist/web/assets/{settings-DSF3exX2.js → settings-CI8xbId2.js} +1 -1
- package/dist/web/assets/{team-qfeJHL9s.js → team-zZ803hH9.js} +1 -1
- package/dist/web/assets/{teamService-Bs9qBKI8.js → teamService-CgLBXgmv.js} +1 -1
- package/dist/web/assets/{terminal-DQLqe-Ed.js → terminal-1WxSJ47E.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-18swytk4.js +0 -25
- package/dist/chunk-3297ghav.js +0 -1
- package/dist/chunk-33ck9ryb.js +0 -1
- package/dist/chunk-4fa11h6f.js +0 -94
- package/dist/chunk-535s1mm8.js +0 -1
- package/dist/chunk-57939tb3.js +0 -8
- package/dist/chunk-6v0cdqkw.js +0 -1
- package/dist/chunk-8kwj6px8.js +0 -1
- package/dist/chunk-a8z11yd2.js +0 -3
- package/dist/chunk-aatfjx15.js +0 -2
- package/dist/chunk-b2ek44t5.js +0 -12
- package/dist/chunk-b9d0ex8n.js +0 -4
- package/dist/chunk-ccgtbzrz.js +0 -14
- package/dist/chunk-jgxfhk9k.js +0 -733
- package/dist/chunk-jhpwwwjt.js +0 -1
- package/dist/chunk-jjj86dej.js +0 -1
- package/dist/chunk-kejvty9z.js +0 -23
- package/dist/chunk-mhe1zppc.js +0 -1
- package/dist/chunk-pb1q26gw.js +0 -181
- package/dist/chunk-pc5f77qh.js +0 -1
- package/dist/chunk-pkx6kfy6.js +0 -1
- package/dist/chunk-qjptyj18.js +0 -1
- package/dist/chunk-shgxzmdw.js +0 -1
- package/dist/chunk-thytjs86.js +0 -44
- package/dist/chunk-tm3789m3.js +0 -2
- package/dist/chunk-tnmcrvk2.js +0 -25
- package/dist/chunk-wejthch2.js +0 -1
- package/dist/chunk-xv6ejk2z.js +0 -353
- package/dist/chunk-yvgef7rp.js +0 -10
- package/dist/chunk-zj48897e.js +0 -6
- package/dist/web/assets/FilePreview-BS4PgFKb.js +0 -55
- package/dist/web/assets/index-CaCifsSK.css +0 -1
- package/dist/web/assets/session-events-NEjosinC.js +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Af as v}from"./chunk-nj6kpdte.js";import{Tf as e}from"./chunk-n5jzmwhy.js";import{Dh as Y,Di as S,Ei as m,Fi as c,Gi as p,Ii as u,Ji as d,Ni as l,Si as i,Ti as t,fi as y,hi as D,ii as h,ki as A,ri as P,si as T,ui as E,wi as _,xi as f,zi as C}from"./chunk-sqk8cnej.js";import{_i as X}from"./chunk-6xzk4hsg.js";import{cj as U,dj as L,jj as M,kj as O,mj as $,nj as I,oj as G,qj as N,rj as j,tj as F,uj as R}from"./chunk-n34qsnks.js";import{Cj as s,Ej as x,Gj as k,Jj as Z}from"./chunk-09kqfdpa.js";import{promises as a}from"node:fs";import g from"node:path";var r=["systemPrompt","appendSystemPrompt","initialMessage","resumeSessionId","forkSession","allowedTools","disallowedTools","mcpConfigPaths","strictMcpConfig","model","addDirs","outputFormat","inputFormat","print","includePartialMessages","replayUserMessages","agentsConfig","settingSources"],kk=new Set([...Object.keys(l),...r,"providerRequestConcurrency","providerGlobalConcurrency","providerOwnerConcurrency"]),W=k.Number({exclusiveMinimum:0}),z=k.String({minLength:1}),b=k.Array(k.String()),qk=k.Object({currentModelId:k.Optional(k.String()),modelProviders:k.Optional(k.Record(z,k.Object({name:z,baseUrl:z,wireApi:Z(["openai-completions","anthropic-messages"]),apiKeyEnv:k.Optional(z)}))),models:k.Optional(k.Array(k.Object({id:z,displayName:k.Optional(z),provider:z,model:z,overrides:k.Optional(k.Object({baseUrl:k.Optional(k.String()),temperature:k.Optional(k.Number()),maxOutputTokens:k.Optional(W),timeout:k.Optional(W),streamIdleTimeout:k.Optional(k.Number({minimum:1000})),apiVersion:k.Optional(k.String()),customHeaders:k.Optional(k.Record(k.String(),k.String())),maxRetries:k.Optional(k.Integer({minimum:0})),enablePromptCaching:k.Optional(k.Boolean())})),fallbackModels:k.Optional(k.Array(k.Object({provider:z,model:z,configId:k.Optional(z)})))}))),temperature:k.Optional(k.Number()),maxOutputTokens:k.Optional(W),stream:k.Optional(k.Boolean()),topP:k.Optional(k.Number()),topK:k.Optional(k.Number()),timeout:k.Optional(W),bashForegroundHandoffMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:P,maximum:T})])),providerForegroundRecoveryMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:U,maximum:L})])),providerCircuitBreakerOpenMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:M,maximum:O})])),providerRequestConcurrency:k.Optional(k.Integer({minimum:$,maximum:I})),providerGlobalConcurrency:k.Optional(k.Integer({minimum:$,maximum:G})),providerOwnerConcurrency:k.Optional(k.Integer({minimum:$,maximum:G})),providerRequestAdmissionMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:N,maximum:j})])),providerRequestPendingBytes:k.Optional(k.Integer({minimum:F,maximum:R})),agentTeamsEnabled:k.Optional(k.Boolean()),codeTheme:k.Optional(k.String()),uiTheme:k.Optional(Z(["light","dark","system"])),language:k.Optional(k.String()),fontSize:k.Optional(W),autoSaveSessions:k.Optional(k.Boolean()),notifyBuild:k.Optional(k.Boolean()),notifyErrors:k.Optional(k.Boolean()),notifySounds:k.Optional(k.Boolean()),privacyTelemetry:k.Optional(k.Boolean()),privacyCrash:k.Optional(k.Boolean()),debug:k.Optional(k.Union([k.Boolean(),k.String()])),mcpEnabled:k.Optional(k.Boolean()),mcpServers:k.Optional(k.Record(k.String(),k.Record(k.String(),k.Unknown()))),lspServers:k.Optional(k.Record(z,k.Object({command:z,args:k.Optional(k.Array(k.String())),extensionToLanguage:k.Record(z,z),env:k.Optional(k.Record(k.String(),k.String())),initializationOptions:k.Optional(k.Unknown()),settings:k.Optional(k.Unknown()),enabled:k.Optional(k.Boolean()),priority:k.Optional(k.Integer()),startupTimeout:k.Optional(k.Integer({minimum:100})),shutdownTimeout:k.Optional(k.Integer({minimum:100})),requestTimeout:k.Optional(k.Integer({minimum:100})),diagnosticWaitTimeout:k.Optional(k.Integer({minimum:0})),maxRestarts:k.Optional(k.Integer({minimum:0,maximum:10}))}))),permissionMode:k.Optional(k.Enum(Y)),maxTurns:k.Optional(k.Integer({minimum:-1})),maxConcurrentTasks:k.Optional(k.Integer({minimum:S,maximum:m})),maxQueuedTasks:k.Optional(k.Integer({minimum:c,maximum:p})),maxQueuedTaskBytes:k.Optional(k.Integer({minimum:u,maximum:d})),maxResidentSessionRuntimes:k.Optional(k.Integer({minimum:E,maximum:_})),sessionRuntimeIdleMs:k.Optional(k.Integer({minimum:f,maximum:C})),maxResidentSessionProjections:k.Optional(k.Integer({minimum:y,maximum:D})),sessionProjectionIdleMs:k.Optional(k.Integer({minimum:h,maximum:A})),systemPrompt:k.Optional(k.String()),appendSystemPrompt:k.Optional(k.String()),initialMessage:k.Optional(k.String()),resumeSessionId:k.Optional(k.String()),forkSession:k.Optional(k.Boolean()),allowedTools:k.Optional(k.Array(z)),disallowedTools:k.Optional(k.Array(z)),mcpConfigPaths:k.Optional(k.Array(z)),strictMcpConfig:k.Optional(k.Boolean()),model:k.Optional(z),addDirs:k.Optional(k.Array(z)),outputFormat:k.Optional(Z(["text","json","stream-json","jsonl"])),inputFormat:k.Optional(Z(["text","stream-json"])),print:k.Optional(k.Boolean()),includePartialMessages:k.Optional(k.Boolean()),replayUserMessages:k.Optional(k.Boolean()),agentsConfig:k.Optional(k.String()),settingSources:k.Optional(k.String()),permissions:k.Optional(k.Object({allow:k.Optional(b),ask:k.Optional(b),deny:k.Optional(b)})),env:k.Optional(k.Record(k.String(),k.String())),hooks:k.Optional(k.Record(k.String(),k.Unknown())),enabledPlugins:k.Optional(k.Record(z,k.Boolean())),pluginSourcePolicy:k.Optional(k.Object({restrictToAllowedSources:k.Optional(k.Boolean()),requireGitCommitSha:k.Optional(k.Boolean()),allowedGitHosts:k.Optional(k.Array(z)),allowedMarketplaces:k.Optional(k.Array(z)),allowedLocalRoots:k.Optional(k.Array(z))})),disableAllHooks:k.Optional(k.Boolean())}),wk=[["systemPrompt","systemPrompt"],["appendSystemPrompt","appendSystemPrompt"],["initialMessage","initialMessage"],["resumeSessionId","sessionId"],["forkSession","forkSession"],["allowedTools","allowedTools"],["disallowedTools","disallowedTools"],["mcpConfigPaths","mcpConfig"],["strictMcpConfig","strictMcpConfig"],["model","model"],["addDirs","addDir"],["outputFormat","outputFormat"],["inputFormat","inputFormat"],["print","print"],["includePartialMessages","includePartialMessages"],["replayUserMessages","replayUserMessages"],["agentsConfig","agents"],["settingSources","settingSources"],["permissionMode","permissionMode"],["maxTurns","maxTurns"],["maxConcurrentTasks","maxConcurrentTasks"],["maxQueuedTasks","maxQueuedTasks"],["maxQueuedTaskBytes","maxQueuedTaskBytes"],["maxResidentSessionRuntimes","maxResidentSessionRuntimes"],["sessionRuntimeIdleMs","sessionRuntimeIdleMs"],["maxResidentSessionProjections","maxResidentSessionProjections"],["sessionProjectionIdleMs","sessionProjectionIdleMs"]];function V(q,B){let w;try{w=JSON.parse(q)}catch(H){let K=H instanceof Error?`: ${H.message}`:"";throw Error(`Invalid JSON provided to --settings (${B})${K}`)}if(!w||typeof w!=="object"||Array.isArray(w))throw Error("--settings must contain a JSON object");for(let H of Object.keys(w))if(!kk.has(H))throw Error(`Unknown --settings field: ${H}`);let J=x(qk,w);if(!J.success){let H=J.error.issues.map((K)=>`${K.path.join(".")||"settings"}: ${K.message}`).join("; ");throw Error(`Invalid --settings value: ${H}`)}return J.data}async function n(q){if(q===void 0)return;let B=q.trim();if(!B)throw Error("--settings requires a JSON object or file path");if(B.startsWith("{"))return V(B,"inline JSON");let w=g.resolve(X(),B),J;try{J=await a.readFile(w,"utf8")}catch(H){let K=H instanceof Error?`: ${H.message}`:"";throw Error(`Unable to read --settings file ${w}${K}`)}return V(J,w)}function o(q,B){if(!B)return;let w=B;for(let[J,H]of wk){if(J==="permissionMode"&&q.yolo===!0)continue;if(q[H]===void 0&&w[J]!==void 0)q[H]=w[J]}}var Q=s("General"),Uk=(q)=>{if(q.yolo){if(q.permissionMode&&q.permissionMode!=="yolo")throw Error("Cannot use both --yolo and --permission-mode with different values");q.permissionMode="yolo"}if(Array.isArray(q.allowedTools))q.allowedTools=q.allowedTools.flatMap((B)=>B.split(",").map((w)=>w.trim()).filter((w)=>w.length>0));if(Array.isArray(q.disallowedTools))q.disallowedTools=q.disallowedTools.flatMap((B)=>B.split(",").map((w)=>w.trim()).filter((w)=>w.length>0));if(Array.isArray(q.allowedTools)&&Array.isArray(q.disallowedTools)){let B=q.allowedTools.filter((w)=>q.disallowedTools.includes(w));if(B.length>0)throw Error(`Tools cannot be both allowed and disallowed: ${B.join(", ")}`)}},Lk=async(q)=>{let B=await n(typeof q.settings==="string"?q.settings:void 0);if(o(q,B),typeof q.agents==="string")v(q.agents);zk(q);try{let J=await i.getInstance().initialize(B),H=t(J,q);if(e().config.actions.setConfig(H),q.debug)Q.info("[CLI] 配置已加载到 Store")}catch(w){Q.error("[CLI] [FAIL] 配置初始化失败",w instanceof Error?w.message:w),console.error(`
|
|
2
2
|
[FAIL] 配置初始化失败
|
|
3
3
|
`),console.error("原因:",w instanceof Error?w.message:"未知错误"),console.error(`
|
|
4
4
|
请检查:`),console.error(" 1. 配置文件格式是否正确 (~/.blade/config.json)"),console.error(" 2. 是否需要运行 blade 进行首次配置"),console.error(` 3. 配置文件权限是否正确
|
|
5
5
|
`),process.exit(1)}};function zk(q){if(q.continue&&q.resume)throw Error("Cannot use both --continue and --resume flags simultaneously");if(q.forkSession&&!q.continue&&!q.resume)throw Error("--fork-session requires --resume or --continue");if(q.sessionId&&(q.continue||q.resume)&&!q.forkSession)throw Error("--session-id can only be combined with --resume or --continue when --fork-session is set")}var Mk=(q)=>{if(q.jsonSchema&&q.outputSchema)throw Error("--json-schema cannot be combined with --output-schema");if((q.jsonSchema||q.outputSchema)&&!q.print&&!q.headless)throw Error("--json-schema and --output-schema can only be used with --print or --headless");if(q.outputFormat&&q.outputFormat!=="text"&&!q.print&&!q.headless)throw Error("--output-format can only be used with --print or --headless");if(q.headless&&q.outputFormat&&!["text","jsonl"].includes(q.outputFormat))throw Error(`--headless only supports --output-format text|jsonl, but got "${q.outputFormat}". Use --print for json|stream-json support.`);if(q.print&&q.outputFormat&&!["text","json","stream-json"].includes(q.outputFormat))throw Error(`--print only supports --output-format text|json|stream-json, but got "${q.outputFormat}". Use --headless for jsonl support.`);if(q.inputFormat==="stream-json"&&q.print)Q.warn("[WARN] Warning: stream-json input format may not work as expected with --print")};
|
|
6
|
-
export{Uk as
|
|
6
|
+
export{Uk as xf,Lk as yf,Mk as zf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{xf as a,yf as b,zf as c}from"./chunk-826xegd8.js";import"./chunk-nj6kpdte.js";import"./chunk-n5jzmwhy.js";import"./chunk-t0gm0pn1.js";import"./chunk-v508x7cg.js";import"./chunk-erhaedch.js";import"./chunk-sqk8cnej.js";import"./chunk-514va7ce.js";import"./chunk-6xzk4hsg.js";import"./chunk-n34qsnks.js";import"./chunk-09kqfdpa.js";import"./chunk-3crwyd2r.js";import"./chunk-9kj19a8t.js";import"./chunk-yzf2jpam.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Hk as $,dk as F}from"./chunk-ed2hdrwe.js";import{promises as J}from"node:fs";import Q from"node:path";import{Mutex as U}from"async-mutex";import w from"write-file-atomic";var X=1;function D(k){if(!k||typeof k!=="object"||Array.isArray(k))return!1;let q=k;return typeof q.path==="string"&&Q.isAbsolute(q.path)&&typeof q.boundAt==="string"}async function Z(k){if(!Q.isAbsolute(k))throw Error("Project path must be absolute");let q=await J.realpath(k);if(!(await J.stat(q)).isDirectory())throw Error("Project path must be a directory");return q}class K{filePath;mutex=new U;constructor(k=Q.join(F(),"bound-projects.json")){this.filePath=k}async list(k){let q=await this.read(),z=await Z(k),H=new Map;for(let C of q.projects)H.set(C.path,C);if(!H.has(z))H.set(z,{path:z,boundAt:new Date(0).toISOString()});return(await Promise.all([...H.values()].map(async(C)=>{let L=!1;try{L=(await J.stat(C.path)).isDirectory()}catch{}return{path:C.path,name:Q.basename(C.path)||C.path,...L?{gitBranch:$(C.path)}:{},available:L,isCurrent:C.path===z,boundAt:C.boundAt}}))).sort((C,L)=>{if(C.isCurrent!==L.isCurrent)return C.isCurrent?-1:1;return C.name.localeCompare(L.name)})}async bind(k,q){return this.mutex.runExclusive(async()=>{let z=await Z(k),H=await this.read(),W=H.projects.find((M)=>M.path===z),C=W??{path:z,boundAt:new Date().toISOString()};if(!W)H.projects.push(C),await this.write(H);let L=await Z(q),A=$(z);return{path:z,name:Q.basename(z)||z,...A?{gitBranch:A}:{},available:!0,isCurrent:z===L,boundAt:C.boundAt}})}async unbind(k){return this.mutex.runExclusive(async()=>{if(!Q.isAbsolute(k))throw Error("Project path must be absolute");let q=await J.realpath(k).catch(()=>Q.resolve(k)),z=await this.read(),H=z.projects.filter((W)=>W.path!==q);if(H.length===z.projects.length)return!1;return z.projects=H,await this.write(z),!0})}async read(){try{let k=await J.readFile(this.filePath,"utf8"),q=JSON.parse(k);if(q.version!==X||!Array.isArray(q.projects))return{version:X,projects:[]};return{version:X,projects:q.projects.filter(D)}}catch(k){if(k.code==="ENOENT"||k instanceof SyntaxError)return{version:X,projects:[]};throw k}}async write(k){let q=Q.dirname(this.filePath);await J.mkdir(q,{recursive:!0,mode:448}),await J.chmod(q,448),await w(this.filePath,`${JSON.stringify(k,null,2)}
|
|
2
2
|
`,{mode:384}),await J.chmod(this.filePath,384)}}var _=new K;
|
|
3
3
|
export{_ as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Vj as a,Wj as b,Xj as c,Yj as d,Zj as e,_j as f}from"./chunk-yzf2jpam.js";import"./chunk-gmpsfkgg.js";export{b as getVersion,c as getPackageName,a as getPackageInfo,e as getFormattedVersion,d as getDescription,f as getCopyright};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var t=["auto","low","medium","high"],s=new Set(["openai-completions","openai-responses","openai-codex-responses","azure-openai-responses"]);function n(e){return/(?:^|[/.:_-])gpt-5(?:$|[/.:_-])/i.test(e.id)}function f(e){return typeof e==="string"&&t.includes(e)}function p(e){if(e.api==="openai-codex-responses"||s.has(e.api)&&n(e))return["low","medium","high"];return[]}function u(e,r){let i=p(e);if(r!=="auto"&&!i.includes(r))throw Error(`Response verbosity ${r} is not supported by ${e.name}`);if(r==="auto")return{selection:r,effective:"provider-default",supported:i};return{selection:r,effective:r,supported:i,providerValue:r}}var a=["auto","standard","fast","flex"],o=new Set(["openai-completions","openai-responses","openai-codex-responses","azure-openai-responses"]);function S(e){return typeof e==="string"&&a.includes(e)}function c(e){if(o.has(e.api))return["standard","fast","flex"];if(e.api==="anthropic-messages"&&/(?:^|-)claude-opus-4-6(?:-|$)/i.test(e.id))return["standard","fast"];return["standard"]}function l(e,r){let i=c(e);if(r!=="auto"&&!i.includes(r))throw Error(`Service tier ${r} is not supported by ${e.name}`);if(r==="auto")return{selection:r,effective:"provider-default",supported:i};if(r==="standard")return{selection:r,effective:"standard",supported:i,...o.has(e.api)?{providerValue:"default"}:{}};if(r==="fast")return{selection:r,effective:"fast",supported:i,providerValue:e.api==="anthropic-messages"?"fast":"priority"};return{selection:r,effective:"flex",supported:i,providerValue:"flex"}}
|
|
2
|
-
export{f as
|
|
2
|
+
export{f as Pj,p as Qj,u as Rj,S as Sj,c as Tj,l as Uj};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ua as H}from"./chunk-e45r1a8r.js";import"./chunk-1n4v80hy.js";import"./chunk-tsm8rhmd.js";import{ag as $,cg as T}from"./chunk-n5jzmwhy.js";import"./chunk-t0gm0pn1.js";import"./chunk-v508x7cg.js";import"./chunk-xcq0cehr.js";import"./chunk-28tzj187.js";import"./chunk-sqk8cnej.js";import"./chunk-514va7ce.js";import{aj as k}from"./chunk-6xzk4hsg.js";import"./chunk-n34qsnks.js";import"./chunk-09kqfdpa.js";import"./chunk-3crwyd2r.js";import"./chunk-9kj19a8t.js";import"./chunk-yzf2jpam.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import U from"os";import J from"path";function X(z){return typeof z==="string"?z:void 0}function N(z){if(!Array.isArray(z))return;let q=[];for(let K of z)if(typeof K==="string")q.push(K);else if(K!=null)q.push(String(K));return q}function b(){console.log(`
|
|
2
2
|
blade mcp
|
|
3
3
|
`),console.log(`管理 MCP 服务器
|
|
4
4
|
`),console.log("Commands:"),console.log(" blade mcp add <name> <commandOrUrl> [args...] 添加 MCP 服务器"),console.log(" blade mcp remove <name> 删除 MCP 服务器 [aliases: rm]"),console.log(" blade mcp list 列出所有 MCP 服务器并检查健康状态 [aliases: ls]"),console.log(" blade mcp get <name> 获取服务器详情"),console.log(" blade mcp login <name> 登录远程 MCP OAuth"),console.log(" blade mcp logout <name> 清除远程 MCP OAuth 凭证"),console.log(` blade mcp add-json <name> <json> 从 JSON 字符串添加服务器
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{Da as I,Fa as K}from"./chunk-az3rehz9.js";import{be as l,de as V,le as q}from"./chunk-sbfe9vh3.js";import{Wg as z}from"./chunk-5k8k56f2.js";import{aj as x}from"./chunk-6xzk4hsg.js";async function J(){await z(x())}async function N(y){let R=y.message||y._?.[0];if(typeof R==="string"&&R.trim())return R;let G=y.stdin??process.stdin;if(!G.isTTY){let b=[];for await(let F of G)b.push(F);return Buffer.concat(b).toString("utf-8").trim()}if(y.defaultMessage!==void 0)return y.defaultMessage;throw Error("No input provided")}async function W(y){let R=y.message||y._?.[0];if(typeof R==="string"&&R.trim())return R;let G=y.stdin??process.stdin;if(G.isTTY)return;let b=[];for await(let O of G)b.push(Buffer.isBuffer(O)?O:Buffer.from(O));return Buffer.concat(b).toString("utf-8").trim()||void 0}async function X(y){if(!I(y))return{mode:"agent",content:y};let R=await K(y,{cwd:x(),surface:"headless",workspaceRoot:x()});if(!R.success)return{mode:"output",content:`Error: ${R.error||"未知错误"}`,exitCode:1};let G=R.data;if(G?.action==="invoke_skill"){let{skillName:b,skillArgs:F}=G;return{mode:"agent",content:F?`Please use the "${b}" skill to help me with: ${F}`:`Please use the "${b}" skill.`}}if(G?.action==="invoke_custom_command"||G?.action==="invoke_plugin_command"){let b=G.processedContent;return{mode:"agent",content:`# Custom Command: /${G.commandName}
|
|
2
|
+
|
|
3
|
+
${b}`}}return{mode:"output",content:R.content||R.message||"",exitCode:0}}async function m(y,R){let G=R&&y.getPendingSteeringCount()>0,b=R&&!G?await y.getGoal():null,F=b?.status==="active"||b?.status==="verifying",O=R&&!G&&!F,v=y.getTurnRecoveryAssessment?.()??{state:"none"},Z=O&&v.state!=="requires_attention"?await y.getRecoveredFinalResponse():void 0;return{pendingInputOnly:G,resumedGoal:b,goalContinuationOnly:F,finalRecovery:O,recoveryAssessment:v,recoveredFinalResponse:Z}}import{readFile as $,stat as L}from"node:fs/promises";import f from"node:path";function Q(y,R){let G;try{G=JSON.parse(y)}catch(b){throw Error(`Invalid JSON output schema from ${R}`,{cause:b})}return V(G).schema}async function _(y){if(y.jsonSchema!==void 0&&y.outputSchema!==void 0)throw Error("--json-schema cannot be combined with --output-schema");if(y.jsonSchema!==void 0)return Q(y.jsonSchema,"--json-schema");if(y.outputSchema===void 0)return;let R=f.resolve(y.outputSchema),G=await L(R);if(!G.isFile())throw Error(`Output schema path is not a regular file: ${R}`);if(G.size>l)throw Error(`Output schema exceeds ${l} bytes: ${R}`);return Q(await $(R,"utf8"),R)}function j(y){if(!(y instanceof Error))return!1;return y.message.includes("未找到会话")||y.message.includes("ENOENT")||y.message.includes("no such file")}async function A(y){try{return await q.loadSessionModelContext(y,x())}catch(R){if(j(R))return null;throw R}}async function C(y){if(y.resume===!0||y.resume==="true")throw Error("--resume without a session ID is only supported in interactive UI mode");if(typeof y.resume==="string"&&y.resume.length>0){if(y.forkSession){let b=x(),F=await q.forkSession(y.resume,{newSessionId:y.sessionId,sourceProjectPath:b,targetProjectPath:b});return{...F,messages:await q.loadSessionModelContext(F.sessionId,b)}}let[R,G]=await Promise.all([q.loadSessionModelContext(y.resume),q.findSessionMetadata(y.resume)]);return{sessionId:y.resume,messages:R,metadata:G}}if(y.continue){let R=y.forkSession?await q.listSessions({cwd:x()}):await q.listSessions();if(R.length>0){let G=R[0].sessionId;if(y.forkSession){let b=x(),F=await q.forkSession(G,{newSessionId:y.sessionId,sourceProjectPath:b,targetProjectPath:b});return{...F,messages:await q.loadSessionModelContext(F.sessionId,b)}}return{sessionId:G,messages:await q.loadSessionModelContext(G),metadata:R[0]}}if(y.forkSession)throw Error("Cannot fork: no sessions are available to continue")}if(y.sessionId){let R=await A(y.sessionId);return{sessionId:y.sessionId,messages:R??[],...R?{metadata:await q.findSessionMetadata(y.sessionId,x())}:{}}}return{sessionId:`${y.fallbackSessionPrefix}-${Date.now()}`,messages:[]}}
|
|
4
|
+
export{J as p,N as q,W as r,X as s,m as t,_ as u,C as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sg as a,tg as b,ug as c}from"./chunk-pdna2qvv.js";import"./chunk-50vwafn5.js";import"./chunk-3crwyd2r.js";import"./chunk-9kj19a8t.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{b as resolveModelConfig,c as getModelDisplayName,a as getModelApiKeyEnvironmentVariable};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{fk as E}from"./chunk-4wx5sya5.js";import{createHash as y}from"node:crypto";import{constants as I,promises as b}from"node:fs";import S from"node:os";import Y from"node:path";import{Mutex as P}from"async-mutex";import{LRUCache as v}from"lru-cache";import f from"write-file-atomic";import{promises as G}from"node:fs";import K from"node:path";import{LRUCache as k}from"lru-cache";var g=512,W=new k({max:g});async function m(q){let Q=q;while(!0){try{return await G.lstat(K.join(Q,".git")),Q}catch($){if($.code!=="ENOENT")return}let Z=K.dirname(Q);if(Z===Q)return;Q=Z}}async function j(q){let Q=K.join(q,".git"),Z=await G.lstat(Q);if(Z.isDirectory())return q;if(!Z.isFile())return;let $=await G.readFile(Q,"utf8"),H=/^gitdir:\s*(.+)\s*$/im.exec($);if(!H)return;let J=await G.realpath(K.isAbsolute(H[1])?H[1]:K.resolve(q,H[1])),F=J;try{let L=(await G.readFile(K.join(J,"commondir"),"utf8")).trim();if(L)F=await G.realpath(K.resolve(J,L))}catch(L){if(L.code!=="ENOENT")throw L}return K.basename(F)===".git"?G.realpath(K.dirname(F)):void 0}async function A(q){if(!K.isAbsolute(q))throw Error("Workspace path must be absolute");let Q=await G.realpath(q),Z=W.get(Q);if(Z)return Z;let $=Q;try{let J=await m(Q);if(J){let F=await j(J),L=K.relative(J,Q);if(F&&(L===""||!L.startsWith(`..${K.sep}`)&&L!==".."&&!K.isAbsolute(L))){let z=K.resolve(F,L);$=await G.realpath(z).catch(()=>z)}}}catch{}let H={projectPath:Q,trustRoot:$};return W.set(Q,H),H}async function _(q){if(!K.isAbsolute(q))throw Error("Workspace path must be absolute");let Q=await G.realpath(q);W.delete(Q)}var N=1,l=65536,R=1048576,V=100,D=64;function Bq(q){return q.state==="trusted"||q.state==="not_required"}function U(q){return q!==null&&typeof q==="object"&&!Array.isArray(q)}function M(q,Q=2048){return q.length<=Q?q:`${q.slice(0,Q-1)}…`}function T(q){if(typeof q!=="string"||!q.trim())return;try{let Q=new URL(q);return M(`${Q.origin}${Q.pathname}`)}catch{return M(q)}}function w(q){return Array.isArray(q)?q.filter((Q)=>typeof Q==="string"):[]}function h(q){if(!U(q))return[];return Object.entries(q).slice(0,V).map(([Q,Z])=>{let $=U(Z)?Z:{},H=typeof $.type==="string"?$.type:"unknown",J=typeof $.command==="string"?$.command:void 0,F=w($.args),L=H==="stdio"?M([J,...F].filter(Boolean).join(" ")):T($.url);return{kind:"mcp",name:`${Q} (${H})`,...L?{target:L}:{}}})}function d(q){if(!U(q))return[];return Object.entries(q).slice(0,V).map(([Q,Z])=>{let $=U(Z)?Z:{},H=typeof $.command==="string"?M($.command):void 0,J=U($.extensionToLanguage)?Object.keys($.extensionToLanguage).slice(0,12).join(", "):"unknown extensions";return{kind:"lsp",name:`${Q} (${J})`,...H?{target:H}:{}}})}function u(q){if(!Array.isArray(q))return[];return q.slice(0,V).flatMap((Q)=>{if(!U(Q))return[];let Z=typeof Q.id==="string"?Q.id:"unnamed",$=typeof Q.provider==="string"?Q.provider:"unknown",H=typeof Q.model==="string"?Q.model:"unknown",J=U(Q.overrides)?Q.overrides:{},F=T(J.baseUrl);return[{kind:"model",name:`${Z}: ${$}/${H}`,...F?{target:F}:{}}]})}function p(q){if(!U(q))return[];return Object.entries(q).slice(0,V).map(([Q,Z])=>{let $=U(Z)?Z:{},H=typeof $.wireApi==="string"?$.wireApi:"unknown",J=T($.baseUrl);return{kind:"model",name:`${Q} (${H})`,...J?{target:J}:{}}})}function n(q){if(!U(q))return[];let Q=[];for(let Z of["allow","ask","deny"])for(let $ of w(q[Z]).slice(0,V))Q.push({kind:"permission",name:`${Z}: ${M($,512)}`});return Q}function c(q){let Q=[...h(q.mcpServers),...d(q.lspServers),...u(q.models),...p(q.modelProviders),...n(q.permissions)];if(U(q.env))for(let Z of Object.keys(q.env).slice(0,V))Q.push({kind:"environment",name:Z});if(typeof q.permissionMode==="string")Q.push({kind:"permission",name:`permissionMode: ${q.permissionMode}`});return Q}function s(q){return q!=="hooks"&&q!=="disableAllHooks"}function o(q){return y("sha256").update(q).digest("hex")}function i(q,Q){let Z=Y.relative(q,Q);return Z===""||!Z.startsWith(`..${Y.sep}`)&&Z!==".."&&!Y.isAbsolute(Z)}class O{storeDir;static instance=null;mutex=new P;statusCache=new v({max:D});constructor(q=Y.join(E(),"workspace-trust")){this.storeDir=q}static getInstance(){if(!O.instance)O.instance=new O;return O.instance}static resetInstance(){O.instance=null}async getStatus(q){let Q=await A(q),Z;try{Z=await this.discoverSensitiveSources(Q.projectPath)}catch(B){let X={...Q,state:"error",sensitiveSources:0,sources:[],decision:"undecided",error:B instanceof Error?B.message:"Workspace trust review failed"};return this.cacheStatus(q,X),X}if(Z.length===0){let B={...Q,state:"not_required",sensitiveSources:0,sources:Z,decision:"undecided"};return this.cacheStatus(q,B),B}let $;try{$=await this.readDecisions()}catch(B){let X={...Q,state:"error",sensitiveSources:Z.length,sources:Z,decision:"undecided",error:B instanceof Error?B.message:"Workspace trust store is unavailable"};return this.cacheStatus(q,X),X}let H=$.filter((B)=>i(B.path,Q.trustRoot)),J=Math.max(-1,...H.map((B)=>B.path.split(Y.sep).length)),F=H.filter((B)=>B.path.split(Y.sep).length===J),L=F.length>0&&F.every((B)=>B.trusted),z=F[0],x=z?.path===Q.trustRoot,C={...Q,state:L?"trusted":"untrusted",sensitiveSources:Z.length,sources:Z,decision:z?x?z.trusted?"trusted":"untrusted":"inherited":"undecided",...z?.decidedAt?{decidedAt:z.decidedAt}:{},...!x&&z?.path?{inheritedFrom:z.path}:{}};return this.cacheStatus(q,C),C}cacheStatus(q,Q){this.statusCache.set(Y.resolve(q),Q),this.statusCache.set(Q.projectPath,Q)}getCachedStatus(q){return this.statusCache.get(Y.resolve(q))}isTrustedCached(q){return this.getCachedStatus(q)?.state==="trusted"}getCacheStats(){return{capacity:D,entries:this.statusCache.size}}async trust(q){return this.recordDecision(q,!0)}async revoke(q){return this.recordDecision(q,!1)}async recordDecision(q,Q){return this.mutex.runExclusive(async()=>{await _(q);let Z=await A(q);await this.assertSafeTrustRoot(Z);let $={version:N,path:Z.trustRoot,trusted:Q,decidedAt:new Date().toISOString()};return await this.writeDecision($),this.statusCache.clear(),this.getStatus(q)})}async assertSafeTrustRoot(q){let Q=Y.parse(q.trustRoot).root,Z=await b.realpath(S.homedir()).catch(()=>Y.resolve(S.homedir()));if(!Y.isAbsolute(q.trustRoot)||q.trustRoot===Q||q.trustRoot===Z)throw Error("Refusing to trust the filesystem root or user home directory")}async discoverSensitiveSources(q){let Q=[],Z=await this.reviewPackageScripts(q);if(Z)Q.push(Z);for(let[$,H]of[[".blade/config.json","config"],[".blade/settings.json","settings"],[".blade/settings.local.json","settings"]]){let J=await this.reviewConfigFile(q,$,H);if(J)Q.push(J)}for(let $ of[".blade/plugins",".claude/plugins"]){let H=await this.reviewResourceDirectory(q,$,"plugins","plugin");if(H)Q.push(H)}for(let $ of[".blade/commands",".claude/commands"]){let H=await this.reviewResourceDirectory(q,$,"commands","command");if(H)Q.push(H)}for(let[$,H,J]of[[".blade/skills","skills","skill"],[".claude/skills","skills","skill"],[".blade/agents","agents","agent"],[".claude/agents","agents","agent"]]){let F=await this.reviewResourceDirectory(q,$,H,J);if(F)Q.push(F)}for(let $ of["CLAUDE.md","AGENTS.md","BLADE.md"]){let H=await this.reviewInstructionFile(q,$);if(H)Q.push(H)}return Q}async reviewPackageScripts(q){let Q=Y.join(q,"package.json"),Z;try{Z=await b.stat(Q)}catch(F){if(F.code==="ENOENT")return;throw F}if(!Z.isFile())return;if(Z.size>R)throw Error("package.json exceeds the 1 MiB workspace review limit");let $;try{$=JSON.parse(await b.readFile(Q,"utf8"))}catch{return{path:"package.json",kind:"package",keys:[],effects:[],warning:"Invalid package.json; project scripts will remain blocked"}}if(!U($)||!U($.scripts))return;let H=$.scripts,J=Object.keys(H).filter((F)=>typeof H[F]==="string").sort().slice(0,V);if(J.length===0)return;return{path:"package.json",kind:"package",keys:J,effects:J.map((F)=>({kind:"command",name:`package script: ${F}`}))}}async reviewInstructionFile(q,Q){try{if(!(await b.stat(Y.join(q,Q))).isFile())return}catch(Z){if(Z.code==="ENOENT")return;throw Z}return{path:Q,kind:"instructions",keys:[Q],effects:[{kind:"instruction",name:Q}]}}async reviewConfigFile(q,Q,Z){let $=Y.join(q,Q),H;try{H=await b.stat($)}catch(x){if(x.code==="ENOENT")return;throw x}if(!H.isFile())return;if(H.size>R)throw Error(`${Q} exceeds the 1 MiB workspace review limit`);let J;try{J=JSON.parse(await b.readFile($,"utf8"))}catch{return{path:Q,kind:Z,keys:[],effects:[],warning:"Invalid JSON; the file will remain blocked"}}if(!U(J))return{path:Q,kind:Z,keys:[],effects:[],warning:"Configuration root is not an object"};let F=Object.keys(J).filter(s).sort();if(F.length===0)return;let L=c(J),z=new Set(["mcpServers","lspServers","models","modelProviders","permissions","env","permissionMode"]);for(let x of F)if(!z.has(x))L.push({kind:"configuration",name:x});return{path:Q,kind:Z,keys:F,effects:L}}async reviewResourceDirectory(q,Q,Z,$){let H=Y.join(q,Q),J;try{J=await b.readdir(H,{withFileTypes:!0})}catch(L){if(L.code==="ENOENT")return;throw L}let F=J.filter((L)=>Z==="plugins"||Z==="skills"?L.isDirectory()||L.isSymbolicLink():L.isFile()||L.isDirectory()||L.isSymbolicLink()).slice(0,V);if(F.length===0)return;return{path:Q,kind:Z,keys:F.map((L)=>L.name),effects:F.map((L)=>({kind:$,name:L.name}))}}async readDecisions(){let q;try{q=await b.lstat(this.storeDir)}catch($){if($.code==="ENOENT")return[];throw $}if(!q.isDirectory()||q.isSymbolicLink())throw Error("Workspace trust store must be a regular directory");if(process.getuid&&q.uid!==process.getuid())throw Error("Workspace trust store must be owned by the current user");if((q.mode&511)!==448)throw Error("Workspace trust store permissions must be 0700");let Q=await b.readdir(this.storeDir,{withFileTypes:!0}),Z=[];for(let $ of Q){if(!$.name.endsWith(".json"))continue;if(!$.isFile())throw Error("Workspace trust store entries must be regular files");Z.push(await this.readDecision(Y.join(this.storeDir,$.name)))}return Z}async readDecision(q){let Q;try{Q=await b.open(q,I.O_RDONLY|I.O_NOFOLLOW)}catch{throw Error("Workspace trust decision must be a regular file")}try{let Z=await Q.stat();if(!Z.isFile()||Z.size>l)throw Error("Workspace trust decision is invalid");if(process.getuid&&Z.uid!==process.getuid())throw Error("Workspace trust decisions must be owned by the current user");if((Z.mode&511)!==384)throw Error("Workspace trust decision permissions must be 0600");let $=JSON.parse(await Q.readFile("utf8"));if(!U($)||$.version!==N||typeof $.path!=="string"||!Y.isAbsolute($.path)||typeof $.trusted!=="boolean"||typeof $.decidedAt!=="string"||!Number.isFinite(Date.parse($.decidedAt))||Object.keys($).some((H)=>H!=="version"&&H!=="path"&&H!=="trusted"&&H!=="decidedAt"))throw Error("Workspace trust decision schema is invalid");return{version:N,path:$.path,trusted:$.trusted,decidedAt:$.decidedAt}}finally{await Q.close()}}async writeDecision(q){await this.ensureStoreDirectoryForWrite();let Q=Y.join(this.storeDir,`${o(q.path)}.json`);try{let Z=await b.lstat(Q);if(!Z.isFile()||Z.isSymbolicLink())throw Error("Workspace trust decision must be a regular file");if(process.getuid&&Z.uid!==process.getuid())throw Error("Workspace trust decisions must be owned by the current user");if((Z.mode&511)!==384)throw Error("Workspace trust decision permissions must be 0600")}catch(Z){if(Z.code!=="ENOENT")throw Z}await f(Q,`${JSON.stringify(q,null,2)}
|
|
1
|
+
import{dk as E}from"./chunk-ed2hdrwe.js";import{createHash as y}from"node:crypto";import{constants as I,promises as b}from"node:fs";import S from"node:os";import Y from"node:path";import{Mutex as P}from"async-mutex";import{LRUCache as v}from"lru-cache";import f from"write-file-atomic";import{promises as G}from"node:fs";import K from"node:path";import{LRUCache as k}from"lru-cache";var g=512,W=new k({max:g});async function m(q){let Q=q;while(!0){try{return await G.lstat(K.join(Q,".git")),Q}catch($){if($.code!=="ENOENT")return}let Z=K.dirname(Q);if(Z===Q)return;Q=Z}}async function j(q){let Q=K.join(q,".git"),Z=await G.lstat(Q);if(Z.isDirectory())return q;if(!Z.isFile())return;let $=await G.readFile(Q,"utf8"),H=/^gitdir:\s*(.+)\s*$/im.exec($);if(!H)return;let J=await G.realpath(K.isAbsolute(H[1])?H[1]:K.resolve(q,H[1])),F=J;try{let L=(await G.readFile(K.join(J,"commondir"),"utf8")).trim();if(L)F=await G.realpath(K.resolve(J,L))}catch(L){if(L.code!=="ENOENT")throw L}return K.basename(F)===".git"?G.realpath(K.dirname(F)):void 0}async function A(q){if(!K.isAbsolute(q))throw Error("Workspace path must be absolute");let Q=await G.realpath(q),Z=W.get(Q);if(Z)return Z;let $=Q;try{let J=await m(Q);if(J){let F=await j(J),L=K.relative(J,Q);if(F&&(L===""||!L.startsWith(`..${K.sep}`)&&L!==".."&&!K.isAbsolute(L))){let z=K.resolve(F,L);$=await G.realpath(z).catch(()=>z)}}}catch{}let H={projectPath:Q,trustRoot:$};return W.set(Q,H),H}async function _(q){if(!K.isAbsolute(q))throw Error("Workspace path must be absolute");let Q=await G.realpath(q);W.delete(Q)}var N=1,l=65536,R=1048576,V=100,D=64;function Bq(q){return q.state==="trusted"||q.state==="not_required"}function U(q){return q!==null&&typeof q==="object"&&!Array.isArray(q)}function M(q,Q=2048){return q.length<=Q?q:`${q.slice(0,Q-1)}…`}function T(q){if(typeof q!=="string"||!q.trim())return;try{let Q=new URL(q);return M(`${Q.origin}${Q.pathname}`)}catch{return M(q)}}function w(q){return Array.isArray(q)?q.filter((Q)=>typeof Q==="string"):[]}function h(q){if(!U(q))return[];return Object.entries(q).slice(0,V).map(([Q,Z])=>{let $=U(Z)?Z:{},H=typeof $.type==="string"?$.type:"unknown",J=typeof $.command==="string"?$.command:void 0,F=w($.args),L=H==="stdio"?M([J,...F].filter(Boolean).join(" ")):T($.url);return{kind:"mcp",name:`${Q} (${H})`,...L?{target:L}:{}}})}function d(q){if(!U(q))return[];return Object.entries(q).slice(0,V).map(([Q,Z])=>{let $=U(Z)?Z:{},H=typeof $.command==="string"?M($.command):void 0,J=U($.extensionToLanguage)?Object.keys($.extensionToLanguage).slice(0,12).join(", "):"unknown extensions";return{kind:"lsp",name:`${Q} (${J})`,...H?{target:H}:{}}})}function u(q){if(!Array.isArray(q))return[];return q.slice(0,V).flatMap((Q)=>{if(!U(Q))return[];let Z=typeof Q.id==="string"?Q.id:"unnamed",$=typeof Q.provider==="string"?Q.provider:"unknown",H=typeof Q.model==="string"?Q.model:"unknown",J=U(Q.overrides)?Q.overrides:{},F=T(J.baseUrl);return[{kind:"model",name:`${Z}: ${$}/${H}`,...F?{target:F}:{}}]})}function p(q){if(!U(q))return[];return Object.entries(q).slice(0,V).map(([Q,Z])=>{let $=U(Z)?Z:{},H=typeof $.wireApi==="string"?$.wireApi:"unknown",J=T($.baseUrl);return{kind:"model",name:`${Q} (${H})`,...J?{target:J}:{}}})}function n(q){if(!U(q))return[];let Q=[];for(let Z of["allow","ask","deny"])for(let $ of w(q[Z]).slice(0,V))Q.push({kind:"permission",name:`${Z}: ${M($,512)}`});return Q}function c(q){let Q=[...h(q.mcpServers),...d(q.lspServers),...u(q.models),...p(q.modelProviders),...n(q.permissions)];if(U(q.env))for(let Z of Object.keys(q.env).slice(0,V))Q.push({kind:"environment",name:Z});if(typeof q.permissionMode==="string")Q.push({kind:"permission",name:`permissionMode: ${q.permissionMode}`});return Q}function s(q){return q!=="hooks"&&q!=="disableAllHooks"}function o(q){return y("sha256").update(q).digest("hex")}function i(q,Q){let Z=Y.relative(q,Q);return Z===""||!Z.startsWith(`..${Y.sep}`)&&Z!==".."&&!Y.isAbsolute(Z)}class O{storeDir;static instance=null;mutex=new P;statusCache=new v({max:D});constructor(q=Y.join(E(),"workspace-trust")){this.storeDir=q}static getInstance(){if(!O.instance)O.instance=new O;return O.instance}static resetInstance(){O.instance=null}async getStatus(q){let Q=await A(q),Z;try{Z=await this.discoverSensitiveSources(Q.projectPath)}catch(B){let X={...Q,state:"error",sensitiveSources:0,sources:[],decision:"undecided",error:B instanceof Error?B.message:"Workspace trust review failed"};return this.cacheStatus(q,X),X}if(Z.length===0){let B={...Q,state:"not_required",sensitiveSources:0,sources:Z,decision:"undecided"};return this.cacheStatus(q,B),B}let $;try{$=await this.readDecisions()}catch(B){let X={...Q,state:"error",sensitiveSources:Z.length,sources:Z,decision:"undecided",error:B instanceof Error?B.message:"Workspace trust store is unavailable"};return this.cacheStatus(q,X),X}let H=$.filter((B)=>i(B.path,Q.trustRoot)),J=Math.max(-1,...H.map((B)=>B.path.split(Y.sep).length)),F=H.filter((B)=>B.path.split(Y.sep).length===J),L=F.length>0&&F.every((B)=>B.trusted),z=F[0],x=z?.path===Q.trustRoot,C={...Q,state:L?"trusted":"untrusted",sensitiveSources:Z.length,sources:Z,decision:z?x?z.trusted?"trusted":"untrusted":"inherited":"undecided",...z?.decidedAt?{decidedAt:z.decidedAt}:{},...!x&&z?.path?{inheritedFrom:z.path}:{}};return this.cacheStatus(q,C),C}cacheStatus(q,Q){this.statusCache.set(Y.resolve(q),Q),this.statusCache.set(Q.projectPath,Q)}getCachedStatus(q){return this.statusCache.get(Y.resolve(q))}isTrustedCached(q){return this.getCachedStatus(q)?.state==="trusted"}getCacheStats(){return{capacity:D,entries:this.statusCache.size}}async trust(q){return this.recordDecision(q,!0)}async revoke(q){return this.recordDecision(q,!1)}async recordDecision(q,Q){return this.mutex.runExclusive(async()=>{await _(q);let Z=await A(q);await this.assertSafeTrustRoot(Z);let $={version:N,path:Z.trustRoot,trusted:Q,decidedAt:new Date().toISOString()};return await this.writeDecision($),this.statusCache.clear(),this.getStatus(q)})}async assertSafeTrustRoot(q){let Q=Y.parse(q.trustRoot).root,Z=await b.realpath(S.homedir()).catch(()=>Y.resolve(S.homedir()));if(!Y.isAbsolute(q.trustRoot)||q.trustRoot===Q||q.trustRoot===Z)throw Error("Refusing to trust the filesystem root or user home directory")}async discoverSensitiveSources(q){let Q=[],Z=await this.reviewPackageScripts(q);if(Z)Q.push(Z);for(let[$,H]of[[".blade/config.json","config"],[".blade/settings.json","settings"],[".blade/settings.local.json","settings"]]){let J=await this.reviewConfigFile(q,$,H);if(J)Q.push(J)}for(let $ of[".blade/plugins",".claude/plugins"]){let H=await this.reviewResourceDirectory(q,$,"plugins","plugin");if(H)Q.push(H)}for(let $ of[".blade/commands",".claude/commands"]){let H=await this.reviewResourceDirectory(q,$,"commands","command");if(H)Q.push(H)}for(let[$,H,J]of[[".blade/skills","skills","skill"],[".claude/skills","skills","skill"],[".blade/agents","agents","agent"],[".claude/agents","agents","agent"]]){let F=await this.reviewResourceDirectory(q,$,H,J);if(F)Q.push(F)}for(let $ of["CLAUDE.md","AGENTS.md","BLADE.md"]){let H=await this.reviewInstructionFile(q,$);if(H)Q.push(H)}return Q}async reviewPackageScripts(q){let Q=Y.join(q,"package.json"),Z;try{Z=await b.stat(Q)}catch(F){if(F.code==="ENOENT")return;throw F}if(!Z.isFile())return;if(Z.size>R)throw Error("package.json exceeds the 1 MiB workspace review limit");let $;try{$=JSON.parse(await b.readFile(Q,"utf8"))}catch{return{path:"package.json",kind:"package",keys:[],effects:[],warning:"Invalid package.json; project scripts will remain blocked"}}if(!U($)||!U($.scripts))return;let H=$.scripts,J=Object.keys(H).filter((F)=>typeof H[F]==="string").sort().slice(0,V);if(J.length===0)return;return{path:"package.json",kind:"package",keys:J,effects:J.map((F)=>({kind:"command",name:`package script: ${F}`}))}}async reviewInstructionFile(q,Q){try{if(!(await b.stat(Y.join(q,Q))).isFile())return}catch(Z){if(Z.code==="ENOENT")return;throw Z}return{path:Q,kind:"instructions",keys:[Q],effects:[{kind:"instruction",name:Q}]}}async reviewConfigFile(q,Q,Z){let $=Y.join(q,Q),H;try{H=await b.stat($)}catch(x){if(x.code==="ENOENT")return;throw x}if(!H.isFile())return;if(H.size>R)throw Error(`${Q} exceeds the 1 MiB workspace review limit`);let J;try{J=JSON.parse(await b.readFile($,"utf8"))}catch{return{path:Q,kind:Z,keys:[],effects:[],warning:"Invalid JSON; the file will remain blocked"}}if(!U(J))return{path:Q,kind:Z,keys:[],effects:[],warning:"Configuration root is not an object"};let F=Object.keys(J).filter(s).sort();if(F.length===0)return;let L=c(J),z=new Set(["mcpServers","lspServers","models","modelProviders","permissions","env","permissionMode"]);for(let x of F)if(!z.has(x))L.push({kind:"configuration",name:x});return{path:Q,kind:Z,keys:F,effects:L}}async reviewResourceDirectory(q,Q,Z,$){let H=Y.join(q,Q),J;try{J=await b.readdir(H,{withFileTypes:!0})}catch(L){if(L.code==="ENOENT")return;throw L}let F=J.filter((L)=>Z==="plugins"||Z==="skills"?L.isDirectory()||L.isSymbolicLink():L.isFile()||L.isDirectory()||L.isSymbolicLink()).slice(0,V);if(F.length===0)return;return{path:Q,kind:Z,keys:F.map((L)=>L.name),effects:F.map((L)=>({kind:$,name:L.name}))}}async readDecisions(){let q;try{q=await b.lstat(this.storeDir)}catch($){if($.code==="ENOENT")return[];throw $}if(!q.isDirectory()||q.isSymbolicLink())throw Error("Workspace trust store must be a regular directory");if(process.getuid&&q.uid!==process.getuid())throw Error("Workspace trust store must be owned by the current user");if((q.mode&511)!==448)throw Error("Workspace trust store permissions must be 0700");let Q=await b.readdir(this.storeDir,{withFileTypes:!0}),Z=[];for(let $ of Q){if(!$.name.endsWith(".json"))continue;if(!$.isFile())throw Error("Workspace trust store entries must be regular files");Z.push(await this.readDecision(Y.join(this.storeDir,$.name)))}return Z}async readDecision(q){let Q;try{Q=await b.open(q,I.O_RDONLY|I.O_NOFOLLOW)}catch{throw Error("Workspace trust decision must be a regular file")}try{let Z=await Q.stat();if(!Z.isFile()||Z.size>l)throw Error("Workspace trust decision is invalid");if(process.getuid&&Z.uid!==process.getuid())throw Error("Workspace trust decisions must be owned by the current user");if((Z.mode&511)!==384)throw Error("Workspace trust decision permissions must be 0600");let $=JSON.parse(await Q.readFile("utf8"));if(!U($)||$.version!==N||typeof $.path!=="string"||!Y.isAbsolute($.path)||typeof $.trusted!=="boolean"||typeof $.decidedAt!=="string"||!Number.isFinite(Date.parse($.decidedAt))||Object.keys($).some((H)=>H!=="version"&&H!=="path"&&H!=="trusted"&&H!=="decidedAt"))throw Error("Workspace trust decision schema is invalid");return{version:N,path:$.path,trusted:$.trusted,decidedAt:$.decidedAt}}finally{await Q.close()}}async writeDecision(q){await this.ensureStoreDirectoryForWrite();let Q=Y.join(this.storeDir,`${o(q.path)}.json`);try{let Z=await b.lstat(Q);if(!Z.isFile()||Z.isSymbolicLink())throw Error("Workspace trust decision must be a regular file");if(process.getuid&&Z.uid!==process.getuid())throw Error("Workspace trust decisions must be owned by the current user");if((Z.mode&511)!==384)throw Error("Workspace trust decision permissions must be 0600")}catch(Z){if(Z.code!=="ENOENT")throw Z}await f(Q,`${JSON.stringify(q,null,2)}
|
|
2
2
|
`,{mode:384}),await b.chmod(Q,384)}async ensureStoreDirectoryForWrite(){try{let q=await b.lstat(this.storeDir);if(!q.isDirectory()||q.isSymbolicLink())throw Error("Workspace trust store must be a regular directory");if(process.getuid&&q.uid!==process.getuid())throw Error("Workspace trust store must be owned by the current user");if((q.mode&511)!==448)throw Error("Workspace trust store permissions must be 0700")}catch(q){if(q.code!=="ENOENT")throw q;await b.mkdir(this.storeDir,{recursive:!0,mode:448}),await b.chmod(this.storeDir,448)}}}
|
|
3
|
-
export{A as
|
|
3
|
+
export{A as $j,D as ak,Bq as bk,O as ck};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./chunk-v508x7cg.js";import{
|
|
2
|
-
`);try{let{rebuildProjectionIndex:z}=await import("./chunk-
|
|
1
|
+
import"./chunk-v508x7cg.js";import{Si as Q}from"./chunk-sqk8cnej.js";import"./chunk-514va7ce.js";import{aj as L}from"./chunk-6xzk4hsg.js";import"./chunk-n34qsnks.js";import"./chunk-09kqfdpa.js";import"./chunk-3crwyd2r.js";import"./chunk-9kj19a8t.js";import"./chunk-yzf2jpam.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import{Jk as F}from"./chunk-gmpsfkgg.js";var K=[22,19,0];function T(G){let A=/^v?(\d+)\.(\d+)\.(\d+)/.exec(G);if(!A)return!1;let H=A.slice(1).map(Number);for(let z=0;z<K.length;z++){let B=H[z]??0,J=K[z];if(B!==J)return B>J}return!0}var X={command:"doctor",describe:"Check the health of your Blade installation",builder:(G)=>G.option("rebuild-index",{type:"boolean",default:!1,describe:"Rebuild the SQLite session index from JSONL transcripts"}),handler:async(G)=>{if(G.rebuildIndex){console.log(`Rebuilding session index from JSONL transcripts...
|
|
2
|
+
`);try{let{rebuildProjectionIndex:z}=await import("./chunk-h4k69z1b.js"),{SessionService:B}=await import("./chunk-w6zat4v4.js"),J=await z(B.projectionDeriverForSearch());if(J===null)console.log("[WARN] Session index unavailable (SQLite driver missing); reads fall back to JSONL scan.");else console.log(`[OK] Session index rebuilt: ${J} session(s) indexed.`)}catch(z){console.log("[FAIL] Session index rebuild failed"),console.log(` Error: ${z instanceof Error?z.message:"未知错误"}`),process.exit(1)}return}console.log(`Running Blade health check...
|
|
3
3
|
`);let A=0;try{await Q.getInstance().initialize(),console.log("[OK] Configuration: OK")}catch(z){console.log("[FAIL] Configuration: FAILED"),console.log(` Error: ${z instanceof Error?z.message:"未知错误"}`),A++}let H=process.version;if(T(H))console.log(`[OK] Node.js version: ${H}`);else console.log(`[WARN] Node.js version: ${H} (required: >=22.19.0)`),A++;try{let z=await import("fs/promises"),B=L();await z.access(B,(await import("fs")).constants.R_OK|(await import("fs")).constants.W_OK),console.log("[OK] File system permissions: OK")}catch(z){console.log("[FAIL] File system permissions: FAILED"),console.log(" Error: Cannot read/write in current directory"),A++}try{await import("ink"),console.log("[OK] Dependencies: OK")}catch(z){console.log("[FAIL] Dependencies: FAILED"),console.log(" Error: Missing required dependencies"),A++}if(console.log(`
|
|
4
4
|
Health Check Summary:`),A===0)console.log("All checks passed! Blade is ready to use.");else console.log(`Warning: Found ${A} issue(s). Please resolve them for optimal performance.`),process.exit(1)}};export{T as isSupportedNodeVersion,X as doctorCommands};
|