blade-code 0.7.1 → 0.7.3

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 (73) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-xmdpc0y5.js → chunk-06awrjgg.js} +2 -2
  3. package/dist/chunk-1vngdr7p.js +1 -0
  4. package/dist/{chunk-2dvn9y9f.js → chunk-29pqj0tb.js} +1 -1
  5. package/dist/{chunk-56frm8dx.js → chunk-373pmz70.js} +1 -1
  6. package/dist/{chunk-zxddgwsb.js → chunk-38h3yh6z.js} +1 -1
  7. package/dist/{chunk-bmxgshct.js → chunk-5n7h04jg.js} +1 -1
  8. package/dist/chunk-5smacbk0.js +24 -0
  9. package/dist/chunk-63dzf6hr.js +2 -0
  10. package/dist/{chunk-f8mjpmdx.js → chunk-87gff8b7.js} +1 -1
  11. package/dist/chunk-98fvxsvc.js +6 -0
  12. package/dist/chunk-98jpdmgc.js +9 -0
  13. package/dist/chunk-aevyre2t.js +1 -0
  14. package/dist/chunk-avebc3bj.js +2 -0
  15. package/dist/chunk-b4hmtjec.js +1 -0
  16. package/dist/{chunk-zm4jr1k2.js → chunk-bmcc85nj.js} +1 -1
  17. package/dist/chunk-cqrg2pp7.js +1 -0
  18. package/dist/{chunk-zvk6ktj1.js → chunk-cw125vv3.js} +1 -1
  19. package/dist/{chunk-f76d6jxg.js → chunk-cyxb6fxe.js} +1 -1
  20. package/dist/{chunk-a7dw8fwn.js → chunk-d0fata6n.js} +1 -1
  21. package/dist/{chunk-qyfdt8h1.js → chunk-e21htmg4.js} +1 -1
  22. package/dist/chunk-e9kfbbpm.js +1 -0
  23. package/dist/chunk-eady1q1w.js +150 -0
  24. package/dist/{chunk-dzmrdtpc.js → chunk-gb0x14v5.js} +37 -34
  25. package/dist/{chunk-7v7s2aag.js → chunk-gjf2d2yg.js} +1 -1
  26. package/dist/chunk-hs4j2fcr.js +6 -0
  27. package/dist/{chunk-qds0yxfy.js → chunk-jf48kahn.js} +3 -3
  28. package/dist/{chunk-h7qab07x.js → chunk-k4behavv.js} +1 -1
  29. package/dist/chunk-k63hr1eg.js +7 -0
  30. package/dist/{chunk-0afbeec0.js → chunk-kfg3vx5z.js} +1 -1
  31. package/dist/{chunk-v1d0d4b4.js → chunk-pvxp2gzr.js} +1 -1
  32. package/dist/{chunk-7z6ba6t9.js → chunk-qxvp127d.js} +1 -1
  33. package/dist/{chunk-867h27ke.js → chunk-rkhhzc4r.js} +2 -2
  34. package/dist/{chunk-b0q2q0ax.js → chunk-rtn0rb16.js} +2 -2
  35. package/dist/chunk-txjvy8qp.js +1 -0
  36. package/dist/{chunk-1dt2y16n.js → chunk-vw3f4mbt.js} +1 -1
  37. package/dist/chunk-w1zb8zac.js +3 -0
  38. package/dist/chunk-wev2rke6.js +1 -0
  39. package/dist/chunk-wp67n9q7.js +1534 -0
  40. package/dist/{chunk-aam53te2.js → chunk-y50fy1gq.js} +2 -2
  41. package/dist/web/assets/{FilePreview-DLnUh-wQ.js → FilePreview-IDRQBiWa.js} +1 -1
  42. package/dist/web/assets/{MarkdownRenderer-C5KTk9XG.js → MarkdownRenderer-BgDKGD2u.js} +1 -1
  43. package/dist/web/assets/{McpModal-B9qJ4ewt.js → McpModal-CJ2l7j-5.js} +1 -1
  44. package/dist/web/assets/{SettingsModal-DpeZ6cJb.js → SettingsModal-BWpbIioU.js} +1 -1
  45. package/dist/web/assets/{SettingsStore-IzKtyAnM.js → SettingsStore-BZjkLZcL.js} +1 -1
  46. package/dist/web/assets/{SkillsModal-BDfzgJIj.js → SkillsModal-CRuRJrN-.js} +1 -1
  47. package/dist/web/assets/{TerminalPanel-B2iTF_CR.js → TerminalPanel-BnZPkS19.js} +1 -1
  48. package/dist/web/assets/{dialog-sI3ihAze.js → dialog-DYRMhlp_.js} +1 -1
  49. package/dist/web/assets/index-Bu13aXyE.css +1 -0
  50. package/dist/web/assets/index-D4CAglTd.js +10 -0
  51. package/dist/web/index.html +2 -2
  52. package/package.json +1 -1
  53. package/dist/chunk-0k8js58t.js +0 -6
  54. package/dist/chunk-0vd9antx.js +0 -1
  55. package/dist/chunk-6jezjq4h.js +0 -6
  56. package/dist/chunk-6k4vs71p.js +0 -1
  57. package/dist/chunk-70ya127f.js +0 -1
  58. package/dist/chunk-7ycmx7c2.js +0 -2
  59. package/dist/chunk-92qcc3gj.js +0 -2138
  60. package/dist/chunk-a2nshjdc.js +0 -49
  61. package/dist/chunk-a8eedntd.js +0 -6
  62. package/dist/chunk-d3db8wrw.js +0 -1
  63. package/dist/chunk-e06p3dkw.js +0 -157
  64. package/dist/chunk-k9h9bw13.js +0 -76
  65. package/dist/chunk-m51xzgwt.js +0 -1
  66. package/dist/chunk-mt1c5da4.js +0 -3
  67. package/dist/chunk-qdnx9x5g.js +0 -2
  68. package/dist/chunk-r6paqm6d.js +0 -1
  69. package/dist/chunk-v0rjbvky.js +0 -9
  70. package/dist/chunk-vs915jzz.js +0 -1
  71. package/dist/chunk-zbtb3jxm.js +0 -1
  72. package/dist/web/assets/index-D8mo0jzF.js +0 -10
  73. package/dist/web/assets/index-DmXmCQOW.css +0 -1
@@ -1,49 +0,0 @@
1
- import{Ca as F,na as $,pa as E,qa as q}from"./chunk-k9h9bw13.js";import{Ob as w}from"./chunk-mt1c5da4.js";import{nanoid as O}from"nanoid";var Z=w("Spec");class X{static instance=null;fileManager=null;constructor(){}static getInstance(){if(!X.instance)X.instance=new X;return X.instance}static resetInstance(){X.instance=null}getStoreState(){return q.getState().spec}updateStoreState(z){q.setState((B)=>({spec:{...B.spec,...z}}))}async initialize(z){if(this.fileManager){Z.debug("SpecManager already initialized, skipping...");return}this.fileManager=new E(z),await this.fileManager.initializeDirectories();let B=await this.fileManager.readSteeringContext();this.updateStoreState({steeringContext:B}),Z.debug("SpecManager initialized successfully")}getFileManager(){if(!this.fileManager)throw Error("SpecManager not initialized. Call initialize() first.");return this.fileManager}getState(){return{...this.getStoreState()}}getCurrentSpec(){return this.getStoreState().currentSpec}isActive(){return this.getStoreState().isActive}getSteeringContext(){return this.getStoreState().steeringContext}async getSteeringContextString(){let z=this.getStoreState().steeringContext;if(!z)return null;let B=[];if(z.constitution)B.push(`## Constitution (Project Governance)
2
-
3
- ${z.constitution}`);if(z.product)B.push(`## Product Vision
4
-
5
- ${z.product}`);if(z.tech)B.push(`## Technology Stack
6
-
7
- ${z.tech}`);if(z.structure)B.push(`## Code Structure
8
-
9
- ${z.structure}`);return B.length>0?B.join(`
10
-
11
- ---
12
-
13
- `):null}async createSpec(z,B){let D=this.getFileManager();if(await D.changeExists(z))return{success:!1,message:`Spec "${z}" already exists`,error:"SPEC_EXISTS"};let K=await D.createChangeDir(z),J=D.createMetadata(z,B);await D.writeMetadata(z,J);let G=this.generateProposalTemplate(z,B);await D.writeSpecFile(z,"proposal",G);let U=this.getStoreState().recentSpecs.filter((Q)=>Q!==z);return U.unshift(z),this.updateStoreState({currentSpec:J,specPath:K,isActive:!0,recentSpecs:U.slice(0,10)}),{success:!0,message:`Spec "${z}" created successfully`,data:{spec:J,path:K}}}async loadSpec(z){let B=this.getFileManager(),D=await B.readMetadata(z);if(!D)return{success:!1,message:`Spec "${z}" not found`,error:"SPEC_NOT_FOUND"};let K=B.getChangePath(z),J=this.getStoreState().recentSpecs.filter((G)=>G!==z);return J.unshift(z),this.updateStoreState({currentSpec:D,specPath:K,isActive:!0,recentSpecs:J.slice(0,10)}),{success:!0,message:`Spec "${z}" loaded successfully`,data:{spec:D,path:K}}}closeSpec(){this.updateStoreState({currentSpec:null,specPath:null,isActive:!1})}exitSpecMode(){this.closeSpec()}async transitionPhase(z){let B=this.getCurrentSpec();if(!B)return{success:!1,message:"No active spec",error:"NO_ACTIVE_SPEC"};if(!$[B.phase].includes(z))return{success:!1,message:`Cannot transition from "${B.phase}" to "${z}"`,error:"INVALID_TRANSITION"};let J=await this.getFileManager().updatePhase(B.name,z);if(!J)return{success:!1,message:"Failed to update phase",error:"UPDATE_FAILED"};if(this.updateStoreState({currentSpec:J}),z==="done")try{await F().setPermissionMode("default"),Z.info("Spec 已完成,已自动退出 Spec 模式")}catch(G){Z.error("自动退出 Spec 模式失败:",G)}return{success:!0,message:`Transitioned to "${z}" phase`,data:{spec:J,phase:z}}}getAllowedTransitions(){let z=this.getCurrentSpec();if(!z)return[];return $[z.phase]}async addTask(z,B,D){let K=this.getCurrentSpec();if(!K)return{success:!1,message:"No active spec",error:"NO_ACTIVE_SPEC"};let J={id:O(8),title:z,description:B,status:"pending",dependencies:D?.dependencies||[],affectedFiles:D?.affectedFiles||[],complexity:D?.complexity||"medium"},G={...K,tasks:[...K.tasks,J],updatedAt:new Date().toISOString()};return await this.getFileManager().writeMetadata(K.name,G),this.updateStoreState({currentSpec:G}),{success:!0,message:`Task "${z}" added`,data:{task:J}}}async updateTaskStatus(z,B){let D=this.getCurrentSpec();if(!D)return{success:!1,message:"No active spec",error:"NO_ACTIVE_SPEC"};let K=D.tasks.find((Q)=>Q.id===z);if(!K)return{success:!1,message:`Task "${z}" not found`,error:"TASK_NOT_FOUND"};let J={...K,status:B,completedAt:B==="completed"?new Date().toISOString():K.completedAt},G=D.tasks.map((Q)=>Q.id===z?J:Q),U={...D,tasks:G,currentTaskId:B==="in_progress"?z:D.currentTaskId===z?void 0:D.currentTaskId,updatedAt:new Date().toISOString()};return await this.getFileManager().writeMetadata(D.name,U),this.updateStoreState({currentSpec:U}),{success:!0,message:`Task status updated to "${B}"`,data:{task:J}}}getNextTask(){let z=this.getCurrentSpec();if(!z)return null;return z.tasks.find((B)=>{if(B.status!=="pending")return!1;return B.dependencies.every((D)=>{return z.tasks.find((J)=>J.id===D)?.status==="completed"})})||null}getTaskProgress(){let z=this.getCurrentSpec();if(!z||z.tasks.length===0)return{total:0,completed:0,percentage:0};let B=z.tasks.length,D=z.tasks.filter((J)=>J.status==="completed").length,K=Math.round(D/B*100);return{total:B,completed:D,percentage:K}}async listSpecs(z){let B=this.getFileManager(),D=[],K=await B.listActiveChanges();for(let J of K){let G=await B.readMetadata(J);if(!G)continue;if(z?.phase&&G.phase!==z.phase)continue;if(z?.tags&&!z.tags.some((Q)=>G.tags?.includes(Q)))continue;if(z?.query&&!G.name.toLowerCase().includes(z.query.toLowerCase())&&!G.description.toLowerCase().includes(z.query.toLowerCase()))continue;let U=this.calculateTaskProgress(G.tasks);D.push({name:G.name,description:G.description,phase:G.phase,updatedAt:G.updatedAt,path:B.getChangePath(J),isArchived:!1,taskProgress:U})}if(z?.includeArchived){let J=await B.listArchivedChanges();for(let G of J)D.push({name:G,description:"(archived)",phase:"done",updatedAt:"",path:`${B.getArchiveDir()}/${G}`,isArchived:!0,taskProgress:{total:0,completed:0}})}return D.sort((J,G)=>{if(J.isArchived!==G.isArchived)return J.isArchived?1:-1;return new Date(G.updatedAt).getTime()-new Date(J.updatedAt).getTime()}),D}async archiveCurrentSpec(){let z=this.getCurrentSpec();if(!z)return{success:!1,message:"No active spec",error:"NO_ACTIVE_SPEC"};let B=this.getFileManager(),D=await B.mergeSpecDeltas(z.name);return await B.updatePhase(z.name,"done"),await B.archiveChange(z.name),this.closeSpec(),{success:!0,message:`Spec "${z.name}" archived successfully`,data:{spec:{...z,phase:"done"}}}}async validateCurrentSpec(){let z=this.getCurrentSpec();if(!z)return{valid:!1,phase:"init",completeness:{proposal:!1,spec:!1,requirements:!1,design:!1,tasks:!1},issues:[{severity:"error",file:"meta",message:"No active spec"}],suggestions:["Create a new spec with /spec proposal <name>"]};let B=this.getFileManager(),D=[],K=[],[J,G,U,Q,V]=await Promise.all([B.readSpecFile(z.name,"proposal"),B.readSpecFile(z.name,"spec"),B.readSpecFile(z.name,"requirements"),B.readSpecFile(z.name,"design"),B.readSpecFile(z.name,"tasks")]),Y={proposal:!!J,spec:!!G,requirements:!!U,design:!!Q,tasks:!!V};if(z.phase==="requirements"&&!Y.requirements)D.push({severity:"warning",file:"requirements",message:"Requirements document is missing"}),K.push("Generate requirements using EARS format");if(z.phase==="design"&&!Y.design)D.push({severity:"warning",file:"design",message:"Design document is missing"}),K.push("Create architecture diagrams and API contracts");if(z.phase==="tasks"&&z.tasks.length===0)D.push({severity:"warning",file:"tasks",message:"No tasks defined"}),K.push("Break down the spec into atomic tasks");if(z.phase==="implementation"){let W=this.getTaskProgress();if(W.completed<W.total)D.push({severity:"info",file:"tasks",message:`${W.total-W.completed} tasks remaining`})}return{valid:D.filter((W)=>W.severity==="error").length===0,phase:z.phase,completeness:Y,issues:D,suggestions:K}}buildProgressContext(){if(!this.isActive())return null;let z=this.getCurrentSpec();if(!z||z.phase!=="implementation")return null;let B=z.tasks;if(B.length===0)return null;let D=B.filter((V)=>V.status==="completed").length,K=B.filter((V)=>V.status==="skipped").length,J=B.length,G=z.currentTaskId?B.find((V)=>V.id===z.currentTaskId):B.find((V)=>V.status==="in_progress"),U=B.find((V)=>{if(V.status!=="pending")return!1;return V.dependencies.every((Y)=>{return B.find((H)=>H.id===Y)?.status==="completed"})}),Q=[`当前正在执行 Spec: ${z.name} (${z.phase} 阶段)`,`进度: ${D}/${J} 任务已完成${K>0?`,${K} 个已跳过`:""}`];if(G)Q.push(`当前任务: #${B.indexOf(G)+1} - ${G.title}${G.description?` (${G.description})`:""}`);if(U&&U!==G)Q.push(`下一个任务: #${B.indexOf(U)+1} - ${U.title}`);if(D+K>=J)Q.push("所有任务已完成,可以进入验证和归档阶段。");return Q.join(`
14
- `)}generateProposalTemplate(z,B){return`# ${z}
15
-
16
- ## Summary
17
-
18
- ${B}
19
-
20
- ## Background
21
-
22
- <!-- Why is this change needed? What problem does it solve? -->
23
-
24
- ## Goals
25
-
26
- <!-- What are the specific objectives of this change? -->
27
-
28
- - [ ] Goal 1
29
- - [ ] Goal 2
30
-
31
- ## Non-Goals
32
-
33
- <!-- What is explicitly out of scope? -->
34
-
35
- ## Risks and Mitigations
36
-
37
- <!-- What could go wrong? How will you address it? -->
38
-
39
- | Risk | Mitigation |
40
- |------|------------|
41
- | | |
42
-
43
- ## Open Questions
44
-
45
- <!-- What needs to be clarified before proceeding? -->
46
-
47
- 1.
48
- `}calculateTaskProgress(z){let B=z.length,D=z.filter((K)=>K.status==="completed").length;return{total:B,completed:D}}}
49
- export{X as Y};
@@ -1,6 +0,0 @@
1
- import{p as A,q as E,r as N,s as f}from"./chunk-f8mjpmdx.js";import{t as D}from"./chunk-1dt2y16n.js";import{v as L,w as _,x}from"./chunk-zvk6ktj1.js";import{y as B}from"./chunk-h7qab07x.js";import{H as $,N as b}from"./chunk-92qcc3gj.js";import"./chunk-a2nshjdc.js";import"./chunk-qyfdt8h1.js";import"./chunk-aam53te2.js";import"./chunk-b0q2q0ax.js";import"./chunk-k9h9bw13.js";import"./chunk-867h27ke.js";import"./chunk-xmdpc0y5.js";import{Za as Z}from"./chunk-dzmrdtpc.js";import"./chunk-f76d6jxg.js";import"./chunk-qds0yxfy.js";import{wb as X,xb as Y}from"./chunk-7ycmx7c2.js";import"./chunk-v0rjbvky.js";import"./chunk-mt1c5da4.js";import"./chunk-0afbeec0.js";import h from"yargs";import{hideBin as R}from"yargs/helpers";var w=new Set(Object.values(X));function W(k){if(k&&w.has(k))return k;return}function M(k){return k.command("* [message]","Print response and exit (useful for pipes)",(F)=>F.positional("message",{describe:"Message to process",type:"string"}).option("p",{alias:"print",describe:"Print response and exit (useful for pipes)",type:"boolean"}).option("output-format",{describe:'Output format: "text", "json", "stream-json"',type:"string",default:"text"}).option("include-partial-messages",{describe:"Include partial message chunks as they arrive",type:"boolean"}).option("input-format",{describe:'Input format: "text", "stream-json"',type:"string",default:"text"}).option("model",{describe:"Model for the current session",type:"string"}).option("append-system-prompt",{describe:"Append a system prompt to the default system prompt",type:"string"}).option("system-prompt",{describe:"Replace 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"}),async(F)=>{if(!F.p)return;let q=await O(F);process.exit(q)})}async function O(k,F=process){let q;try{await A();let J=await E({message:k.message,_:k._,defaultMessage:"Hello"}),G=await N(J);if(G.mode==="output"){if(G.content)F.stdout.write(`${G.content}
2
- `);return G.exitCode??0}let Q=G.content,{sessionId:K,messages:T}=await f({sessionId:k.sessionId,continue:k.continue,resume:k.resume,forkSession:k.forkSession,fallbackSessionPrefix:"print"});q=await $.create({sessionId:K,modelId:k.model,mcpConfig:k.mcpConfig,strictMcpConfig:k.strictMcpConfig,agents:k.agents?B(k.agents):void 0});let U=await b.createWithRuntime(q,{sessionId:K,systemPrompt:k.systemPrompt,appendSystemPrompt:k.appendSystemPrompt,maxTurns:k.maxTurns,modelId:k.model,permissionMode:W(k.permissionMode),toolWhitelist:k.allowedTools,toolBlacklist:k.disallowedTools,mcpConfig:k.mcpConfig,strictMcpConfig:k.strictMcpConfig}),H=(await Z(U.chatStream(Q,{messages:[...T],userId:"cli-user",sessionId:K,workspaceRoot:Y(),permissionMode:W(k.permissionMode)}))).finalMessage||"";if(k.outputFormat==="json")F.stdout.write(`${JSON.stringify({response:H,input:Q,model:k.model,timestamp:new Date().toISOString()},null,2)}
3
- `);else if(k.outputFormat==="stream-json")F.stdout.write(`${JSON.stringify({type:"response",content:H})}
4
- `);else F.stdout.write(`${H}
5
- `);return 0}catch(J){return F.stderr.write(`Error: ${J instanceof Error?J.message:"未知错误"}
6
- `),1}finally{await q?.dispose()}}async function d(){if(process.argv.slice(2).findIndex((q)=>q==="--print"||q==="-p")===-1)return!1;try{let{print:q,"output-format":J,"include-partial-messages":G,"input-format":Q,"system-prompt":K,"append-system-prompt":T,"max-turns":U,...V}=D,H=h(R(process.argv)).scriptName("blade").strict(!1).options(V).middleware([_,L,x]);return M(H),await H.parse(),!0}catch(q){console.error(`Print mode error: ${q instanceof Error?q.message:"未知错误"}`),process.exit(1)}}export{O as runPrint,d as handlePrintMode};
@@ -1 +0,0 @@
1
- import{Y as a}from"./chunk-a2nshjdc.js";import"./chunk-k9h9bw13.js";import"./chunk-867h27ke.js";import"./chunk-7ycmx7c2.js";import"./chunk-mt1c5da4.js";import"./chunk-0afbeec0.js";export{a as SpecManager};