blade-code 0.6.2 → 0.6.4
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-07xv0cqp.js +1 -0
- package/dist/{chunk-t44946na.js → chunk-0e9dhemy.js} +3 -3
- package/dist/{chunk-k4sbqc14.js → chunk-2zk921d9.js} +1 -1
- package/dist/chunk-3mmm8g84.js +1 -0
- package/dist/{chunk-3j3v297d.js → chunk-59e6eg4b.js} +1 -1
- package/dist/{chunk-9ce1fadm.js → chunk-5bs94pb1.js} +9 -9
- package/dist/{chunk-t7hd45rg.js → chunk-6mfmy7nq.js} +2 -2
- package/dist/chunk-7c9k2c9m.js +1 -0
- package/dist/chunk-7t23swne.js +2125 -0
- package/dist/{chunk-39h8jdm3.js → chunk-7ycmx7c2.js} +1 -1
- package/dist/chunk-9p4fe43p.js +1 -0
- package/dist/{chunk-kevt8v3j.js → chunk-9vsbmtqj.js} +1 -1
- package/dist/{chunk-j1ehsp0x.js → chunk-bpx8x87m.js} +2 -2
- package/dist/{chunk-m7xm1ssb.js → chunk-cfe1fywb.js} +1 -1
- package/dist/{chunk-b5nhr3na.js → chunk-ck43cs45.js} +1 -1
- package/dist/{chunk-1cm8qqth.js → chunk-dmc5gf4f.js} +1 -1
- package/dist/chunk-evc1xkeb.js +28 -0
- package/dist/{chunk-mpafvahb.js → chunk-ey640ttd.js} +1 -1
- package/dist/chunk-f24ahjpc.js +1 -0
- package/dist/{chunk-21zps3hb.js → chunk-h46kk20y.js} +1 -1
- package/dist/{chunk-7rjrzngk.js → chunk-hc91pmdk.js} +1 -1
- package/dist/{chunk-s53zeref.js → chunk-j7nh0j36.js} +1 -1
- package/dist/{chunk-ythh98wk.js → chunk-jm9r362m.js} +1 -1
- package/dist/{chunk-dyaxme6k.js → chunk-k063tt5h.js} +1 -1
- package/dist/{chunk-y57hcnk6.js → chunk-m26jr2tg.js} +1 -1
- package/dist/{chunk-67dzm8te.js → chunk-m41xq6d0.js} +1 -1
- package/dist/{chunk-6gycrrb9.js → chunk-mpn4zfcn.js} +1 -1
- package/dist/{chunk-7v6xxyd3.js → chunk-njq4w631.js} +10 -10
- package/dist/{chunk-gn1acna6.js → chunk-nm2w2ftg.js} +1 -1
- package/dist/{chunk-fkttsa1n.js → chunk-p8pggabj.js} +1 -1
- package/dist/{chunk-7010r8zb.js → chunk-qnvkxpkw.js} +1 -1
- package/dist/{chunk-zfy765hj.js → chunk-sfr69fw8.js} +1 -1
- package/dist/{chunk-63954vzc.js → chunk-sh1pk5j3.js} +1 -1
- package/dist/{chunk-2ahbedmp.js → chunk-tdarh4fh.js} +1 -1
- package/dist/{chunk-8a2z6mgp.js → chunk-tz44akn7.js} +1 -1
- package/dist/chunk-vxgexcsm.js +1 -0
- package/dist/{chunk-6vwc66b4.js → chunk-w96xaeyd.js} +1 -1
- package/dist/{chunk-9zbmef4r.js → chunk-zm78rg9t.js} +1 -1
- package/dist/{chunk-cydswa20.js → chunk-zwwvv85t.js} +1 -1
- package/package.json +2 -1
- package/dist/chunk-1t0cavth.js +0 -28
- package/dist/chunk-3ak4p05x.js +0 -1
- package/dist/chunk-4e20kfa4.js +0 -1
- package/dist/chunk-563zye36.js +0 -1
- package/dist/chunk-9pg8nttx.js +0 -2121
- package/dist/chunk-caw1bxy6.js +0 -1
- package/dist/chunk-g7xh4e99.js +0 -1
- package/dist/chunk-n9mwp62v.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as g,q as v,r as p,s as d}from"./chunk-
|
|
1
|
+
import{p as g,q as v,r as p,s as d}from"./chunk-zwwvv85t.js";import{t as S}from"./chunk-w96xaeyd.js";import{v as h,w as c,x as z}from"./chunk-tz44akn7.js";import{G as F,I as y,J as C,L,M as E}from"./chunk-7t23swne.js";import"./chunk-59e6eg4b.js";import"./chunk-evc1xkeb.js";import"./chunk-p8pggabj.js";import"./chunk-ck43cs45.js";import"./chunk-h46kk20y.js";import"./chunk-m41xq6d0.js";import{Ta as w}from"./chunk-njq4w631.js";import"./chunk-f24ahjpc.js";import"./chunk-0e9dhemy.js";import"./chunk-6mfmy7nq.js";import{wb as T,xb as O}from"./chunk-7ycmx7c2.js";import"./chunk-bpx8x87m.js";import"./chunk-j7nh0j36.js";import Uq from"yargs";import{hideBin as Kq}from"yargs/helpers";import{z as b}from"zod";import{z as Q}from"zod";var N=1,_=Q.object({event_version:Q.literal(N)}),n=_.extend({type:Q.literal("content_delta"),delta:Q.string()}),r=_.extend({type:Q.literal("thinking_delta"),delta:Q.string()}),s=_.extend({type:Q.literal("thinking"),content:Q.string()}),o=_.extend({type:Q.literal("stream_end")}),a=_.extend({type:Q.literal("content"),content:Q.string()}),t=_.extend({type:Q.literal("tool_start"),tool_name:Q.string(),summary:Q.string(),target:Q.string().optional(),tool_kind:Q.enum(["readonly","write","execute"]).optional()}),e=_.extend({type:Q.literal("tool_result"),tool_name:Q.string(),summary:Q.string(),target:Q.string().optional(),tool_kind:Q.enum(["readonly","write","execute"]).optional()}),qq=_.extend({type:Q.literal("phase"),phase:Q.enum(["turn","searching","inspecting","target_hit","executing","completed"]),status:Q.enum(["ongoing","hit","done"]),message:Q.string(),turn:Q.number().optional(),tool_name:Q.string().optional(),target:Q.string().optional()}),Gq=_.extend({type:Q.literal("tool_detail"),tool_name:Q.string(),detail:Q.string()}),Qq=_.extend({type:Q.literal("task_update"),tasks:Q.array(L)}),Xq=_.extend({type:Q.literal("token_usage"),input_tokens:Q.number(),output_tokens:Q.number(),total_tokens:Q.number(),max_context_tokens:Q.number()}),Yq=_.extend({type:Q.literal("compacting"),state:Q.enum(["started","completed"])}),Zq=_.extend({type:Q.literal("turn_limit"),turns_count:Q.number(),action:Q.literal("continue")}),$q=_.extend({type:Q.literal("output"),content:Q.string(),exit_code:Q.number()}),bq=_.extend({type:Q.literal("error"),message:Q.string()}),Nq=Q.discriminatedUnion("type",[n,r,s,o,a,t,e,qq,Gq,Qq,Xq,Yq,Zq,$q,bq]);function W(G,X){return{event_version:N,type:G,...X}}var Aq=b.enum(["text","jsonl"]),Vq=b.object({headless:b.boolean().optional(),message:b.string().optional(),_:b.array(b.union([b.string(),b.number()])).optional(),model:b.string().optional(),systemPrompt:b.string().optional(),appendSystemPrompt:b.string().optional(),maxTurns:b.number().int().refine((G)=>G===-1||G>0,{message:"must be -1 or a positive integer"}).optional(),permissionMode:b.nativeEnum(T).optional(),mcpConfig:b.array(b.string()).optional(),strictMcpConfig:b.boolean().optional(),sessionId:b.string().optional(),allowedTools:b.array(b.string()).optional(),disallowedTools:b.array(b.string()).optional(),continue:b.boolean().optional(),resume:b.union([b.string(),b.boolean()]).optional(),outputFormat:Aq.optional()});class u{openedThinking=!1;wroteAssistantContent=!1;markAssistantContent(){this.wroteAssistantContent=!0}setThinkingOpened(G){this.openedThinking=G}hasOpenThinking(){return this.openedThinking}completeStream(){let G={openedThinking:this.openedThinking,wroteAssistantContent:this.wroteAssistantContent};return this.openedThinking=!1,this.wroteAssistantContent=!1,G}}function _q(G){return G.issues.map((X)=>`${X.path.join(".")||"options"}: ${X.message}`).join("; ")}function Dq(G){let X=Vq.safeParse(G);if(!X.success)throw Error(`Invalid headless options: ${_q(X.error)}`);return X.data}function Mq(G){return G.command("* [message]","Run full agent loop without Ink UI and print events to the terminal",(X)=>X.positional("message",{describe:"Message to process",type:"string"}).option("headless",{type:"boolean",describe:"Run full agent loop without Ink UI and print events to the terminal"}).option("model",{describe:"Model ID for this run",type:"string"}).option("system-prompt",{describe:"Replace the default system prompt",type:"string"}).option("append-system-prompt",{describe:"Append a system prompt to the default system prompt",type:"string"}).option("max-turns",{alias:["maxTurns"],describe:"Maximum conversation turns (-1: unlimited, N>0: limit to N turns)",type:"number"}).option("output-format",{alias:["outputFormat"],choices:["text","jsonl"],describe:"Headless output format",type:"string"}),async(X)=>{if(!X.headless)return;let Y=await Jq(X);process.exit(Y)})}function D(G,X=""){G.write(`${X}
|
|
2
2
|
`)}function Rq(G){return`[task] [${G.status}] ${G.subject}`}function jq(){return{requestConfirmation:async(G)=>({approved:!0,reason:"headless-auto-approved",scope:"session"})}}function fq(G){if(!(G instanceof Error))return"Unknown error";let q=G.lastError??G;if(q.responseBody)try{let A=JSON.parse(q.responseBody)?.error?.message;if(A)return q.statusCode?`${A} (HTTP ${q.statusCode})`:A}catch{}let Z=G.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return G.message}function Bq(G){return G==="jsonl"?"jsonl":"text"}function k(G,X){let Y=(...q)=>{for(let Z of q){let U=X[Z];if(typeof U==="string"&&U.trim()!=="")return U}return};switch(G){case"Read":case"Edit":case"Write":case"UndoEdit":return Y("file_path");case"NotebookEdit":return Y("notebook_path");case"Grep":return Y("path","pattern");case"Glob":return Y("pattern");case"WebFetch":return Y("url");case"WebSearch":return Y("query");case"Bash":return Y("description","command");case"Task":return Y("description");case"LSP":return Y("filePath","operation");case"EnterWorktree":return Y("name");case"ExitWorktree":return Y("action");default:return}}function Iq(G,X,Y,q){let Z=new Set(["Glob","Grep","WebSearch","LS"]),U=new Set(["Read","WebFetch"]);if(new Set(["Edit","Write","NotebookEdit","Bash","LSP","UndoEdit","EnterWorktree","ExitWorktree"]).has(G)&&!q.targetLocked)return{phase:"target_hit",status:"hit",message:`Target locked: ${X}`,shouldLockTarget:!0};if(q.targetLocked)return{phase:"executing",status:"hit",message:Y?`Working within target: ${X}`:`Executing: ${X}`,shouldLockTarget:!1};if(Z.has(G))return{phase:"searching",status:"ongoing",message:`Still searching: ${X}`,shouldLockTarget:!1};if(U.has(G))return{phase:"inspecting",status:"ongoing",message:`Inspecting candidate: ${X}`,shouldLockTarget:!1};return{phase:"executing",status:q.targetLocked?"hit":"ongoing",message:`Executing: ${X}`,shouldLockTarget:!1}}function H(G,X){let Y=(q,Z)=>{G.stdout.write(`${JSON.stringify(W(q,Z))}
|
|
3
3
|
`)};return{contentDelta(q){if(X==="jsonl"){Y("content_delta",{delta:q});return}G.stdout.write(q)},thinkingDelta(q,Z){if(X==="jsonl")return Y("thinking_delta",{delta:q}),Z;if(!Z)G.stderr.write("[thinking] ");return G.stderr.write(q),!0},thinking(q){if(X==="jsonl"){Y("thinking",{content:q});return}D(G.stderr,`[thinking] ${q}`)},streamEnd(q,Z){if(X==="jsonl"){Y("stream_end",{});return}if(Z)G.stderr.write(`
|
|
4
4
|
`);if(q)G.stdout.write(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{N as l,O as c,P as m,S as g,U as d}from"./chunk-
|
|
1
|
+
import{N as l,O as c,P as m,S as g,U as d}from"./chunk-7t23swne.js";import{xb as u}from"./chunk-7ycmx7c2.js";async function C(){if((await l().initialize(u(),[])).plugins.length>0)await c()}async function h(t){let e=t.message||t._?.[0];if(typeof e==="string"&&e.trim())return e;let n=t.stdin??process.stdin;if(!n.isTTY){let a=[];for await(let i of n)a.push(i);return Buffer.concat(a).toString("utf-8").trim()}if(t.defaultMessage!==void 0)return t.defaultMessage;throw Error("No input provided")}async function R(t){if(!g(t))return{mode:"agent",content:t};let e=await d(t,{cwd:u(),workspaceRoot:u()});if(!e.success)return{mode:"output",content:`Error: ${e.error||"未知错误"}`,exitCode:1};let n=e.data;if(n?.action==="invoke_skill"){let{skillName:a,skillArgs:i}=n;return{mode:"agent",content:i?`Please use the "${a}" skill to help me with: ${i}`:`Please use the "${a}" skill.`}}if(n?.action==="invoke_custom_command"||n?.action==="invoke_plugin_command"){let a=n.processedContent;return{mode:"agent",content:`# Custom Command: /${n.commandName}
|
|
2
2
|
|
|
3
3
|
${a}`}}return{mode:"output",content:e.content||e.message||"",exitCode:0}}function r(t){if(!(t instanceof Error))return!1;return t.message.includes("未找到会话")||t.message.includes("ENOENT")||t.message.includes("no such file")}async function s(t){try{return await m.loadSession(t,u())}catch(e){if(r(e))return null;throw e}}async function N(t){if(t.resume===!0||t.resume==="true")throw Error("--resume without a session ID is only supported in interactive UI mode");if(typeof t.resume==="string"&&t.resume.length>0)return{sessionId:t.resume,messages:await m.loadSession(t.resume)};if(t.continue){let e=await m.listSessions();if(e.length>0){let n=e[0].sessionId;return{sessionId:n,messages:await m.loadSession(n)}}}if(t.sessionId)return{sessionId:t.sessionId,messages:await s(t.sessionId)??[]};return{sessionId:`${t.fallbackSessionPrefix}-${Date.now()}`,messages:[]}}
|
|
4
4
|
export{C as p,h as q,R as r,N as s};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blade-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "🗡️ Blade Code - 智能代码助手命令行工具",
|
|
6
6
|
"type": "module",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@ai-sdk/google": "^3.0.4",
|
|
71
71
|
"@ai-sdk/openai": "^3.0.26",
|
|
72
72
|
"@ai-sdk/openai-compatible": "^2.0.4",
|
|
73
|
+
"@anthropic-ai/sandbox-runtime": "0.0.67",
|
|
73
74
|
"@inkjs/ui": "^2.0.0",
|
|
74
75
|
"@modelcontextprotocol/sdk": "^1.17.4",
|
|
75
76
|
"ahooks": "^3.9.6",
|
package/dist/chunk-1t0cavth.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import{tb as I,yb as L}from"./chunk-39h8jdm3.js";import{execSync as T}from"child_process";import{existsSync as Q,readFileSync as F,realpathSync as O}from"fs";import{basename as b,isAbsolute as J,resolve as j}from"path";import*as V from"os";import*as H from"path";function R(){let B=L(),q=G(B);return{workingDirectory:B,projectRoot:q,platform:`${V.platform()} (${V.arch()})`,nodeVersion:process.version,currentDate:new Date().toISOString().split("T")[0],homeDirectory:V.homedir()}}function X(B,q){try{return T(q,{cwd:B,encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return null}}function S(B={}){let{includeGitSnapshot:q=!0,includeDirectoryListing:M=!0}=B,z=R(),Z=Q(H.join(z.projectRoot,".git")),_=b(process.env.SHELL||"unknown"),$=["package.json","tsconfig.json","BLADE.md",".env.example"].filter((K)=>Q(H.join(z.projectRoot,K))).map((K)=>`- \`${H.join(z.projectRoot,K)}\``),N=`# Environment
|
|
2
|
-
You have been invoked in the following environment:
|
|
3
|
-
- Primary working directory: ${z.workingDirectory}
|
|
4
|
-
- Is a git repository: ${Z?"true":"false"}
|
|
5
|
-
- Platform: ${z.platform}
|
|
6
|
-
- Shell: ${_}
|
|
7
|
-
- Node.js: ${z.nodeVersion}`;if(q&&Z){let K=X(z.projectRoot,"git rev-parse --abbrev-ref HEAD"),Y=X(z.projectRoot,"git status --short"),U=X(z.projectRoot,"git log --oneline -n 3");if(K)N+=`
|
|
8
|
-
- Current branch: ${K}`;if(Y)N+=`
|
|
9
|
-
|
|
10
|
-
Working tree status:
|
|
11
|
-
${Y}`;if(U)N+=`
|
|
12
|
-
|
|
13
|
-
Recent commits:
|
|
14
|
-
${U}`}if(N+=`
|
|
15
|
-
|
|
16
|
-
When using file tools (read, write, edit), provide absolute paths based on: \`${z.workingDirectory}/\``,$.length>0)N+=`
|
|
17
|
-
|
|
18
|
-
Key project files at root for quick reference:
|
|
19
|
-
${$.join(`
|
|
20
|
-
`)}`;let A=H.join(z.projectRoot,"package.json");if(Q(A))try{let K=F(A,"utf-8"),U=JSON.parse(K).scripts;if(U){let E=["test","lint","type-check","build","dev","start"].filter((W)=>U[W]).map((W)=>` ${W}: ${U[W].slice(0,60)}`);if(E.length>0)N+=`
|
|
21
|
-
|
|
22
|
-
Available npm scripts:
|
|
23
|
-
${E.join(`
|
|
24
|
-
`)}`}}catch{}if(M){let K=X(z.projectRoot,"ls -1 | head -30");if(K)N+=`
|
|
25
|
-
|
|
26
|
-
Project root directory listing:
|
|
27
|
-
${K}`}return N}function G(B){let q=B,M=null;while(q!==H.dirname(q)){if(Q(H.join(q,".git")))return q;if(Q(H.join(q,".blade")))return q;if(Q(H.join(q,".claude")))return q;if(!M&&Q(H.join(q,"package.json")))M=q;q=H.dirname(q)}return M??B}function g(B,q){let M=J(B)?B:j(q||process.cwd(),B),z;try{z=O(M)}catch{z=M}I(z)}
|
|
28
|
-
export{S as Z,G as _,g as $};
|
package/dist/chunk-3ak4p05x.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function q(x){return x!==void 0&&typeof x.pattern==="string"&&typeof x.search_path==="string"}function v(x){return x!==void 0&&x.kind==="edit"&&typeof x.matches_found==="number"}function w(x){return x==="readonly"}class b{toolName;params;context;aborted=!1;result;_internal={};constructor(x,f,h){this.toolName=x;this.params=f;this.context=h}shouldAbort(){return this.aborted||(this.context.signal?.aborted??!1)}abort(x,f){this.aborted=!0,this.result={success:!1,llmContent:f?.llmContent||`Tool execution aborted: ${x||"Unknown reason"}`,error:{type:f?.errorType||"execution_error",message:x||"Execution aborted"},metadata:{summary:f?.summary||`执行已中止: ${x||"未知原因"}`,...f?.shouldExitLoop?{shouldExitLoop:!0}:{},...f?.abortedBeforeLaunch?{abortedBeforeLaunch:!0}:{}}}}setResult(x){this.result=x}getResult(){if(!this.result)throw Error("Tool execution result not set");return this.result}}export{q as jb,v as kb,w as lb,b as mb};
|
package/dist/chunk-4e20kfa4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as a,u as b}from"./chunk-6vwc66b4.js";import"./chunk-fkttsa1n.js";import"./chunk-s53zeref.js";export{a as globalOptions,b as cliConfig};
|
package/dist/chunk-563zye36.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ga as a}from"./chunk-b5nhr3na.js";import"./chunk-21zps3hb.js";import"./chunk-67dzm8te.js";import"./chunk-39h8jdm3.js";import"./chunk-j1ehsp0x.js";import"./chunk-s53zeref.js";export{a as SpecManager};
|