blade-code 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/blade.js +1 -1
  2. package/package.json +1 -1
package/dist/blade.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as YH}from"node:module";var sU=Object.create;var{getPrototypeOf:tU,defineProperty:V6,getOwnPropertyNames:eU}=Object;var $H=Object.prototype.hasOwnProperty;var d0=($,Z,Y)=>{Y=$!=null?sU(tU($)):{};let Q=Z||!$||!$.__esModule?V6(Y,"default",{value:$,enumerable:!0}):Y;for(let X of eU($))if(!$H.call(Q,X))V6(Q,X,{get:()=>$[X],enumerable:!0});return Q};var ZH=($,Z)=>{for(var Y in Z)V6($,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(Q)=>Z[Y]=()=>Q})};var A=($,Z)=>()=>($&&(Z=$($=0)),Z);var V0=YH(import.meta.url);var j8;var qY=A(()=>{j8={name:"blade-code",version:"0.1.1",private:!1,description:"🗡️ Blade Code - 智能代码助手命令行工具",type:"module",bin:{blade:"dist/blade.js"},files:["dist","vendor/ripgrep/**","README.md","docs/public/changelog.md"],scripts:{dev:"bun --watch src/blade.tsx",build:"rm -rf dist && bun run scripts/build.ts",start:"bun run dist/blade.js",test:"node scripts/test.js","test:all":"vitest run --config vitest.config.ts","test:unit":"node scripts/test.js unit","test:integration":"node scripts/test.js integration","test:cli":"node scripts/test.js cli","test:coverage":"node scripts/test.js all --coverage","test:unit:coverage":"node scripts/test.js unit --coverage","test:integration:coverage":"node scripts/test.js integration --coverage","test:cli:coverage":"node scripts/test.js cli --coverage","test:watch":"vitest --watch --config vitest.config.ts","test:unit:watch":"vitest --watch --config vitest.config.ts --project unit","test:integration:watch":"vitest --watch --config vitest.config.ts --project integration","test:cli:watch":"vitest --watch --config vitest.config.ts --project cli","test:debug":"node scripts/test.js all --debug","test:verbose":"node scripts/test.js all --verbose","test:ci":"vitest run --config vitest.config.ts --coverage --reporter=verbose","test:performance":'vitest --testNamePattern="performance" --verbose',lint:"biome lint src tests","lint:fix":"biome lint --write src tests",format:"biome format --write src tests","format:check":"biome format src tests",check:"biome check src tests","check:fix":"biome check --write src tests","type-check":"tsc --noEmit","check:full":"npm run type-check && npm run lint && npm run format:check && npm run test:ci","security:audit":"pnpm audit","security:test":"bash scripts/run-security-tests.sh","vendor:ripgrep":"node scripts/download-ripgrep.js","vendor:ripgrep:clean":"rm -rf vendor/ripgrep/darwin-* vendor/ripgrep/linux-* vendor/ripgrep/win32-*",release:"node scripts/release.js","release:dry":"node scripts/release.js --dry-run","release:major":"node scripts/release.js --major","release:minor":"node scripts/release.js --minor","release:patch":"node scripts/release.js --patch",clean:"rm -rf dist node_modules/.cache coverage",prepare:'test -n "$CI" || bun run build',preflight:"npm run clean && pnpm install && npm run format && npm run lint && npm run build && npm run type-check && npm run test:ci"},keywords:["cli","blade","ai","assistant","agent","llm","tool","qwen","volcengine","smart-tools","code-review","documentation","git-tools"],author:"echoVic",license:"MIT",repository:{type:"git",url:"git+https://github.com/echoVic/blade-code.git"},homepage:"https://github.com/echoVic/blade-code",bugs:{url:"https://github.com/echoVic/blade-code/issues"},engines:{node:">=20.0.0"},devDependencies:{"@biomejs/biome":"^2.2.4","@types/bun":"^1.3.4","@types/json-schema":"^7.0.15","@types/lodash-es":"^4.17.12","@types/node":"^22.15.24","@types/picomatch":"^4.0.2","@types/react":"^19.1.12","@types/react-dom":"^19.1.9","@types/semver":"^7.7.1","@types/write-file-atomic":"^4.0.3","@types/ws":"^8.5.12","@types/yargs":"^17.0.33","@vitest/coverage-v8":"^3.0.0",jsdom:"^26.0.0",knip:"^5.80.0",typescript:"^5.9.2",vitest:"^3.0.0"},optionalDependencies:{"@vscode/ripgrep":"^1.17.0"},dependencies:{"@agentclientprotocol/sdk":"^0.12.0","@anthropic-ai/sdk":"^0.71.2","@azure/identity":"^4.13.0","@google/genai":"^1.34.0","@inkjs/ui":"^2.0.0","@modelcontextprotocol/sdk":"^1.17.4",ahooks:"^3.9.5","ansi-escapes":"^7.2.0","async-mutex":"^0.5.0",axios:"^1.12.2",chalk:"^5.4.1",diff:"^8.0.2","fast-glob":"^3.3.3","fuse.js":"^7.1.0","gray-matter":"^4.0.3",ink:"npm:@jrichman/ink@6.4.6","ink-big-text":"^2.0.0","ink-gradient":"^3.0.0","ink-select-input":"^6.2.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0","js-tiktoken":"^1.0.21","lodash-es":"^4.17.21",lowlight:"^3.3.0","lru-cache":"^11.2.4",nanoid:"^5.1.6",openai:"^6.2.0",picomatch:"^4.0.3",pino:"^10.1.0","pino-pretty":"^13.1.3",react:"^19.1.1","react-dom":"^19.1.1",semver:"^7.7.3","string-width":"^8.1.0",undici:"^7.16.0","write-file-atomic":"^7.0.0",ws:"^8.18.0",yaml:"^2.8.1",yargs:"^18.0.0",zod:"^3.24.2","zod-to-json-schema":"^3.24.6",zustand:"^5.0.9"}}});function j4(){return j8.version}function WY(){return j8.name}function UY(){return j8.description}function HY(){return`v${j8.version} © 2025 Blade Code`}var I8=A(()=>{qY()});var U0=()=>{};var I4;var D6=A(()=>{U0();I4={currentModelId:"",models:[],temperature:0,maxContextTokens:128000,maxOutputTokens:32768,stream:!0,topP:0.9,topK:50,timeout:180000,theme:"GitHub",language:"zh-CN",fontSize:14,debug:!1,mcpEnabled:!1,mcpServers:{},permissions:{allow:["Bash(pwd)","Bash(which *)","Bash(whoami)","Bash(hostname)","Bash(uname *)","Bash(date)","Bash(echo *)","Bash(ls *)","Bash(tree *)","Bash(git status)","Bash(git log *)","Bash(git diff *)","Bash(git branch *)","Bash(git show *)","Bash(git remote *)","Bash(npm list *)","Bash(npm view *)","Bash(npm outdated *)","Bash(pnpm list *)","Bash(yarn list *)","Bash(pip list *)","Bash(pip show *)"],ask:["Bash(curl *)","Bash(wget *)","Bash(aria2c *)","Bash(axel *)","Bash(rm -rf *)","Bash(rm -r *)","Bash(rm --recursive *)","Bash(nc *)","Bash(netcat *)","Bash(telnet *)","Bash(ncat *)"],deny:["Read(./.env)","Read(./.env.*)","Bash(rm -rf /)","Bash(rm -rf /*)","Bash(sudo *)","Bash(chmod 777 *)","Bash(bash *)","Bash(sh *)","Bash(zsh *)","Bash(fish *)","Bash(dash *)","Bash(eval *)","Bash(source *)","Bash(mkfs *)","Bash(fdisk *)","Bash(dd *)","Bash(format *)","Bash(parted *)","Bash(open http*)","Bash(open https*)","Bash(xdg-open http*)","Bash(xdg-open https*)"]},permissionMode:"default",hooks:{enabled:!1,defaultTimeout:60,timeoutBehavior:"ignore",failureBehavior:"ignore",maxConcurrentHooks:5,PreToolUse:[],PostToolUse:[],PostToolUseFailure:[],PermissionRequest:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[],SubagentStop:[],Notification:[],Compaction:[]},env:{},disableAllHooks:!1,maxTurns:-1}});import{promises as OY}from"fs";import{merge as zY}from"lodash-es";import _Y from"os";import y8 from"path";class u0{static instance=null;constructor(){}static getInstance(){if(!u0.instance)u0.instance=new u0;return u0.instance}static resetInstance(){u0.instance=null}async initialize(){try{let $=await this.loadConfigFiles(),Z=await this.loadSettingsFiles(),Y={...I4,...$,...Z};if(this.resolveEnvInterpolation(Y),Y.debug)console.log("[ConfigManager] Configuration loaded successfully");return Y}catch($){return console.error("[ConfigManager] Failed to initialize:",$),I4}}async loadConfigFiles(){let $=y8.join(_Y.homedir(),".blade","config.json"),Z=y8.join(process.cwd(),".blade","config.json"),Y={},Q=await this.loadJsonFile($);if(Q)Y={...Y,...Q};let X=await this.loadJsonFile(Z);if(X){let J={...Y.mcpServers||{},...X.mcpServers||{}};if(Y={...Y,...X},Object.keys(J).length>0)Y.mcpServers=J}return Y}async loadSettingsFiles(){let $=y8.join(_Y.homedir(),".blade","settings.json"),Z=y8.join(process.cwd(),".blade","settings.json"),Y=y8.join(process.cwd(),".blade","settings.local.json"),Q={},X=await this.loadJsonFile($);if(X)Q=this.mergeSettings(Q,X);let J=await this.loadJsonFile(Z);if(J)Q=this.mergeSettings(Q,J);let G=await this.loadJsonFile(Y);if(G)Q=this.mergeSettings(Q,G);return Q}mergeSettings($,Z){let Y=JSON.parse(JSON.stringify($));if(Z.permissions){if(!Y.permissions)Y.permissions={allow:[],ask:[],deny:[]};if(Z.permissions.allow){let Q=[...Y.permissions.allow||[],...Z.permissions.allow];Y.permissions.allow=Array.from(new Set(Q))}if(Z.permissions.ask){let Q=[...Y.permissions.ask||[],...Z.permissions.ask];Y.permissions.ask=Array.from(new Set(Q))}if(Z.permissions.deny){let Q=[...Y.permissions.deny||[],...Z.permissions.deny];Y.permissions.deny=Array.from(new Set(Q))}}if(Z.hooks)Y.hooks=zY({},Y.hooks,Z.hooks);if(Z.env)Y.env=zY({},Y.env,Z.env);if(Z.mcpServers)Y.mcpServers={...Y.mcpServers||{},...Z.mcpServers};if(Z.disableAllHooks!==void 0)Y.disableAllHooks=Z.disableAllHooks;if(Z.permissionMode!==void 0)Y.permissionMode=Z.permissionMode;if(Z.maxTurns!==void 0)Y.maxTurns=Z.maxTurns;return Y}resolveEnvInterpolation($){let Z=/\$\{?([A-Z_][A-Z0-9_]*)(:-([^}]+))?\}?/g,Y=(Q)=>{if(typeof Q==="string")return Q.replace(Z,(X,J,G,K)=>{return process.env[J]||K||X});return Q};for(let[Q,X]of Object.entries($))if(typeof X==="string")$[Q]=Y(X)}async loadJsonFile($){try{if(await this.fileExists($)){let Z=await OY.readFile($,"utf-8");return JSON.parse(Z)}}catch(Z){console.warn(`[ConfigManager] Failed to load ${$}:`,Z)}return null}async fileExists($){try{return await OY.access($),!0}catch{return!1}}validateConfig($){let Z=[];if(!$.models||$.models.length===0)Z.push("没有可用的模型配置");if($.models&&$.models.length>0){if(!$.currentModelId)Z.push("未设置当前模型 ID");else if(!$.models.find((Q)=>Q.id===$.currentModelId))Z.push("当前模型 ID 无效")}if(Z.length>0)throw Error(`配置验证失败:
2
+ import{createRequire as YH}from"node:module";var sU=Object.create;var{getPrototypeOf:tU,defineProperty:V6,getOwnPropertyNames:eU}=Object;var $H=Object.prototype.hasOwnProperty;var d0=($,Z,Y)=>{Y=$!=null?sU(tU($)):{};let Q=Z||!$||!$.__esModule?V6(Y,"default",{value:$,enumerable:!0}):Y;for(let X of eU($))if(!$H.call(Q,X))V6(Q,X,{get:()=>$[X],enumerable:!0});return Q};var ZH=($,Z)=>{for(var Y in Z)V6($,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(Q)=>Z[Y]=()=>Q})};var A=($,Z)=>()=>($&&(Z=$($=0)),Z);var V0=YH(import.meta.url);var j8;var qY=A(()=>{j8={name:"blade-code",version:"0.1.2",private:!1,description:"🗡️ Blade Code - 智能代码助手命令行工具",type:"module",bin:{blade:"dist/blade.js"},files:["dist","vendor/ripgrep/**","README.md","docs/public/changelog.md"],scripts:{dev:"bun --watch src/blade.tsx",build:"rm -rf dist && bun run scripts/build.ts",start:"bun run dist/blade.js",test:"node scripts/test.js","test:all":"vitest run --config vitest.config.ts","test:unit":"node scripts/test.js unit","test:integration":"node scripts/test.js integration","test:cli":"node scripts/test.js cli","test:coverage":"node scripts/test.js all --coverage","test:unit:coverage":"node scripts/test.js unit --coverage","test:integration:coverage":"node scripts/test.js integration --coverage","test:cli:coverage":"node scripts/test.js cli --coverage","test:watch":"vitest --watch --config vitest.config.ts","test:unit:watch":"vitest --watch --config vitest.config.ts --project unit","test:integration:watch":"vitest --watch --config vitest.config.ts --project integration","test:cli:watch":"vitest --watch --config vitest.config.ts --project cli","test:debug":"node scripts/test.js all --debug","test:verbose":"node scripts/test.js all --verbose","test:ci":"vitest run --config vitest.config.ts --coverage --reporter=verbose","test:performance":'vitest --testNamePattern="performance" --verbose',lint:"biome lint src tests","lint:fix":"biome lint --write src tests",format:"biome format --write src tests","format:check":"biome format src tests",check:"biome check src tests","check:fix":"biome check --write src tests","type-check":"tsc --noEmit","check:full":"npm run type-check && npm run lint && npm run format:check && npm run test:ci","security:audit":"pnpm audit","security:test":"bash scripts/run-security-tests.sh","vendor:ripgrep":"node scripts/download-ripgrep.js","vendor:ripgrep:clean":"rm -rf vendor/ripgrep/darwin-* vendor/ripgrep/linux-* vendor/ripgrep/win32-*",release:"node scripts/release.js","release:dry":"node scripts/release.js --dry-run","release:major":"node scripts/release.js --major","release:minor":"node scripts/release.js --minor","release:patch":"node scripts/release.js --patch",clean:"rm -rf dist node_modules/.cache coverage",prepare:'test -n "$CI" || bun run build',preflight:"npm run clean && pnpm install && npm run format && npm run lint && npm run build && npm run type-check && npm run test:ci"},keywords:["cli","blade","ai","assistant","agent","llm","tool","qwen","volcengine","smart-tools","code-review","documentation","git-tools"],author:"echoVic",license:"MIT",repository:{type:"git",url:"git+https://github.com/echoVic/blade-code.git"},homepage:"https://github.com/echoVic/blade-code",bugs:{url:"https://github.com/echoVic/blade-code/issues"},engines:{node:">=20.0.0"},devDependencies:{"@biomejs/biome":"^2.2.4","@types/bun":"^1.3.4","@types/json-schema":"^7.0.15","@types/lodash-es":"^4.17.12","@types/node":"^22.15.24","@types/picomatch":"^4.0.2","@types/react":"^19.1.12","@types/react-dom":"^19.1.9","@types/semver":"^7.7.1","@types/write-file-atomic":"^4.0.3","@types/ws":"^8.5.12","@types/yargs":"^17.0.33","@vitest/coverage-v8":"^3.0.0",jsdom:"^26.0.0",knip:"^5.80.0",typescript:"^5.9.2",vitest:"^3.0.0"},optionalDependencies:{"@vscode/ripgrep":"^1.17.0"},dependencies:{"@agentclientprotocol/sdk":"^0.12.0","@anthropic-ai/sdk":"^0.71.2","@azure/identity":"^4.13.0","@google/genai":"^1.34.0","@inkjs/ui":"^2.0.0","@modelcontextprotocol/sdk":"^1.17.4",ahooks:"^3.9.5","ansi-escapes":"^7.2.0","async-mutex":"^0.5.0",axios:"^1.12.2",chalk:"^5.4.1",diff:"^8.0.2","fast-glob":"^3.3.3","fuse.js":"^7.1.0","gray-matter":"^4.0.3",ink:"npm:@jrichman/ink@6.4.6","ink-big-text":"^2.0.0","ink-gradient":"^3.0.0","ink-select-input":"^6.2.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0","js-tiktoken":"^1.0.21","lodash-es":"^4.17.21",lowlight:"^3.3.0","lru-cache":"^11.2.4",nanoid:"^5.1.6",openai:"^6.2.0",picomatch:"^4.0.3",pino:"^10.1.0","pino-pretty":"^13.1.3",react:"^19.1.1","react-dom":"^19.1.1",semver:"^7.7.3","string-width":"^8.1.0",undici:"^7.16.0","write-file-atomic":"^7.0.0",ws:"^8.18.0",yaml:"^2.8.1",yargs:"^18.0.0",zod:"^3.24.2","zod-to-json-schema":"^3.24.6",zustand:"^5.0.9"}}});function j4(){return j8.version}function WY(){return j8.name}function UY(){return j8.description}function HY(){return`v${j8.version} © 2025 Blade Code`}var I8=A(()=>{qY()});var U0=()=>{};var I4;var D6=A(()=>{U0();I4={currentModelId:"",models:[],temperature:0,maxContextTokens:128000,maxOutputTokens:32768,stream:!0,topP:0.9,topK:50,timeout:180000,theme:"GitHub",language:"zh-CN",fontSize:14,debug:!1,mcpEnabled:!1,mcpServers:{},permissions:{allow:["Bash(pwd)","Bash(which *)","Bash(whoami)","Bash(hostname)","Bash(uname *)","Bash(date)","Bash(echo *)","Bash(ls *)","Bash(tree *)","Bash(git status)","Bash(git log *)","Bash(git diff *)","Bash(git branch *)","Bash(git show *)","Bash(git remote *)","Bash(npm list *)","Bash(npm view *)","Bash(npm outdated *)","Bash(pnpm list *)","Bash(yarn list *)","Bash(pip list *)","Bash(pip show *)"],ask:["Bash(curl *)","Bash(wget *)","Bash(aria2c *)","Bash(axel *)","Bash(rm -rf *)","Bash(rm -r *)","Bash(rm --recursive *)","Bash(nc *)","Bash(netcat *)","Bash(telnet *)","Bash(ncat *)"],deny:["Read(./.env)","Read(./.env.*)","Bash(rm -rf /)","Bash(rm -rf /*)","Bash(sudo *)","Bash(chmod 777 *)","Bash(bash *)","Bash(sh *)","Bash(zsh *)","Bash(fish *)","Bash(dash *)","Bash(eval *)","Bash(source *)","Bash(mkfs *)","Bash(fdisk *)","Bash(dd *)","Bash(format *)","Bash(parted *)","Bash(open http*)","Bash(open https*)","Bash(xdg-open http*)","Bash(xdg-open https*)"]},permissionMode:"default",hooks:{enabled:!1,defaultTimeout:60,timeoutBehavior:"ignore",failureBehavior:"ignore",maxConcurrentHooks:5,PreToolUse:[],PostToolUse:[],PostToolUseFailure:[],PermissionRequest:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[],SubagentStop:[],Notification:[],Compaction:[]},env:{},disableAllHooks:!1,maxTurns:-1}});import{promises as OY}from"fs";import{merge as zY}from"lodash-es";import _Y from"os";import y8 from"path";class u0{static instance=null;constructor(){}static getInstance(){if(!u0.instance)u0.instance=new u0;return u0.instance}static resetInstance(){u0.instance=null}async initialize(){try{let $=await this.loadConfigFiles(),Z=await this.loadSettingsFiles(),Y={...I4,...$,...Z};if(this.resolveEnvInterpolation(Y),Y.debug)console.log("[ConfigManager] Configuration loaded successfully");return Y}catch($){return console.error("[ConfigManager] Failed to initialize:",$),I4}}async loadConfigFiles(){let $=y8.join(_Y.homedir(),".blade","config.json"),Z=y8.join(process.cwd(),".blade","config.json"),Y={},Q=await this.loadJsonFile($);if(Q)Y={...Y,...Q};let X=await this.loadJsonFile(Z);if(X){let J={...Y.mcpServers||{},...X.mcpServers||{}};if(Y={...Y,...X},Object.keys(J).length>0)Y.mcpServers=J}return Y}async loadSettingsFiles(){let $=y8.join(_Y.homedir(),".blade","settings.json"),Z=y8.join(process.cwd(),".blade","settings.json"),Y=y8.join(process.cwd(),".blade","settings.local.json"),Q={},X=await this.loadJsonFile($);if(X)Q=this.mergeSettings(Q,X);let J=await this.loadJsonFile(Z);if(J)Q=this.mergeSettings(Q,J);let G=await this.loadJsonFile(Y);if(G)Q=this.mergeSettings(Q,G);return Q}mergeSettings($,Z){let Y=JSON.parse(JSON.stringify($));if(Z.permissions){if(!Y.permissions)Y.permissions={allow:[],ask:[],deny:[]};if(Z.permissions.allow){let Q=[...Y.permissions.allow||[],...Z.permissions.allow];Y.permissions.allow=Array.from(new Set(Q))}if(Z.permissions.ask){let Q=[...Y.permissions.ask||[],...Z.permissions.ask];Y.permissions.ask=Array.from(new Set(Q))}if(Z.permissions.deny){let Q=[...Y.permissions.deny||[],...Z.permissions.deny];Y.permissions.deny=Array.from(new Set(Q))}}if(Z.hooks)Y.hooks=zY({},Y.hooks,Z.hooks);if(Z.env)Y.env=zY({},Y.env,Z.env);if(Z.mcpServers)Y.mcpServers={...Y.mcpServers||{},...Z.mcpServers};if(Z.disableAllHooks!==void 0)Y.disableAllHooks=Z.disableAllHooks;if(Z.permissionMode!==void 0)Y.permissionMode=Z.permissionMode;if(Z.maxTurns!==void 0)Y.maxTurns=Z.maxTurns;return Y}resolveEnvInterpolation($){let Z=/\$\{?([A-Z_][A-Z0-9_]*)(:-([^}]+))?\}?/g,Y=(Q)=>{if(typeof Q==="string")return Q.replace(Z,(X,J,G,K)=>{return process.env[J]||K||X});return Q};for(let[Q,X]of Object.entries($))if(typeof X==="string")$[Q]=Y(X)}async loadJsonFile($){try{if(await this.fileExists($)){let Z=await OY.readFile($,"utf-8");return JSON.parse(Z)}}catch(Z){console.warn(`[ConfigManager] Failed to load ${$}:`,Z)}return null}async fileExists($){try{return await OY.access($),!0}catch{return!1}}validateConfig($){let Z=[];if(!$.models||$.models.length===0)Z.push("没有可用的模型配置");if($.models&&$.models.length>0){if(!$.currentModelId)Z.push("未设置当前模型 ID");else if(!$.models.find((Q)=>Q.id===$.currentModelId))Z.push("当前模型 ID 无效")}if(Z.length>0)throw Error(`配置验证失败:
3
3
  ${Z.map((Y)=>` - ${Y}`).join(`
4
4
  `)}
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blade-code",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "🗡️ Blade Code - 智能代码助手命令行工具",
6
6
  "type": "module",