dskcode 0.1.52 → 0.1.53
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/index.js +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -189,7 +189,7 @@ ${s}
|
|
|
189
189
|
`}var cT=/^\/(\S+)(?:\s+(.*))?$/;async function Oh(e,t){let n=cT.exec(e);if(!n)return{kind:"no-match"};let r=n[1],o=(n[2]??"").trim(),s=t.find(l=>l.name===r);if(!s)return{kind:"no-match"};let i;try{i=await Ws(s.skillFilePath)}catch(l){return{kind:"error",message:l instanceof Error?l.message:String(l)}}let a=Xi(s,i);return{kind:"text",text:o?`${a}
|
|
190
190
|
|
|
191
191
|
${o}`:a}}p();import{Box as tu,Text as lr}from"ink";import uT from"ink-spinner";import{jsx as Ut,jsxs as Nh}from"react/jsx-runtime";function Dh(e){switch(e){case"pending":return"\u2610";case"done":return"\u2611";case"failed":return"\u2717";case"skipped":return"\u2298";case"running":return"\u25B6"}}function dT({status:e}){return e==="running"?Ut(lr,{color:"cyan",children:Ut(uT,{type:"dots"})}):e==="done"?Ut(lr,{color:"green",children:"\u2705"}):e==="failed"?Ut(lr,{color:"red",children:Dh(e)}):Ut(lr,{dimColor:!0,children:Dh(e)})}function nu({items:e}){return e.length===0?null:Nh(tu,{flexDirection:"column",marginTop:1,children:[Ut(tu,{children:Ut(lr,{dimColor:!0,children:"\u{1F527} \u4EFB\u52A1\u8FDB\u5EA6"})}),e.map(t=>Nh(tu,{children:[Ut(lr,{dimColor:!0,children:" "}),Ut(dT,{status:t.status}),Ut(lr,{dimColor:!0,children:` ${t.content}`})]},t.id))]})}p();import{Box as qe,Text as Ae}from"ink";import pT from"ink-spinner";import{useMemo as Bh}from"react";import{Fragment as bT,jsx as Te,jsxs as Pe}from"react/jsx-runtime";function fT(e){if(e.phase==="idle")return 0;if(e.phase==="done"||e.phase==="error")return 100;let t=e.progress;if(!t)return 5;if(t.type==="start")return 10;if(t.type==="summary_delta"){let n=Math.min(t.totalSoFar.length/800,1);return Math.min(10+n*80,90)}return t.type==="fallback"?95:5}function mT(e){if(e.phase==="error")return{icon:"\u2717",text:"\u538B\u7F29\u51FA\u9519",color:"#ff6347"};if(e.phase==="done")return e.strategy==="fallback"?{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210\uFF08\u672C\u5730\u515C\u5E95\uFF09",color:"#ff9800"}:{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210",color:"#00ff41"};let t=e.progress;return t?t.type==="start"?{icon:"\u280B",text:`\u51C6\u5907\u6458\u8981 ${t.droppedTurns} \u4E2A\u65E7\u56DE\u5408...`,color:"#00ffff"}:t.type==="summary_delta"?{icon:"\u280B",text:"\u8C03\u7528 LLM \u751F\u6210\u6458\u8981...",color:"#00ffff"}:t.type==="fallback"?{icon:"\u26A0",text:`LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\uFF1A${t.reason}`,color:"#ff9800"}:{icon:"\u280B",text:"\u538B\u7F29\u4E2D...",color:"#00ffff"}:{icon:"\u280B",text:"\u51C6\u5907\u538B\u7F29...",color:"#00ffff"}}function hT({percent:e,color:t}){let r=Math.round(e/100*24),o=24-r;return Pe(Ae,{children:[Te(Ae,{color:t,children:"\u2588".repeat(r)}),Te(Ae,{color:"#444444",children:"\u2591".repeat(o)}),Pe(Ae,{color:t,children:[" ",e.toFixed(0),"%"]})]})}function gT({state:e}){let t=(()=>{if(e.phase==="idle")return 0;if(e.phase==="error"){let o=e.progress;return o?.type==="summary_delta"||o?.type==="start"?1:2}if(e.phase==="done")return 3;let r=e.progress;return!r||r.type==="start"?0:r.type==="summary_delta"?1:(r.type==="fallback",2)})(),n=["\u542F\u52A8","LLM \u6458\u8981","\u5E94\u7528\u538B\u7F29","\u5B8C\u6210"];return Te(qe,{children:n.map((r,o)=>{let s=o===t,i=o<t;return Pe(qe,{marginRight:1,children:[Pe(Ae,{color:i?"#00ff41":s?"#00ffff":"#444444",children:[i?"\u2713":s?"\u25B8":"\xB7"," ",r]}),o<n.length-1&&Te(Ae,{color:"#444444",children:" \u2192 "})]},r)})})}function yT({text:e,contentWidth:t}){let r=Math.max(t-6,20);if(!e)return Te(Ae,{dimColor:!0,children:" (\u7B49\u5F85 LLM \u8F93\u51FA...)"});let s=xT(e,r).slice(-4);return Te(qe,{flexDirection:"column",children:s.map((i,a)=>Pe(Ae,{dimColor:!0,children:[" ",i]},a))})}function xT(e,t){if(e==="")return[];if(t<=0)return[e];let n=[];for(let r of e.split(`
|
|
192
|
-
`)){if(r.length===0){n.push("");continue}let o="",s=0;for(let i of r){let l=i.codePointAt(0)>11904?2:1;s+l>t&&o.length>0?(n.push(o),o=i,s=l):(o+=i,s+=l)}o.length>0&&n.push(o)}return n}function Fh(e){return e.toLocaleString()}function ru({state:e,contentWidth:t}){let n=Bh(()=>fT(e),[e]),r=Bh(()=>mT(e),[e]),o=e.progress?.type==="summary_delta"?e.progress.totalSoFar:e.progress?.type==="fallback"?e.progress.fallbackSummary:(e.phase==="done"&&e.strategy==="summary",""),s=e.phase==="done"&&e.strategy==="summary"?e.progress?.type==="summary_delta"?e.progress.totalSoFar:"":o,i=e.phase==="error"?"#ff6347":"#00ffff";return Te(qe,{flexDirection:"column",marginTop:1,children:Pe(qe,{flexDirection:"row",children:[Te(qe,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),Pe(qe,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Pe(qe,{children:[Te(Ae,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),Te(qe,{flexGrow:1}),e.phase==="running"&&Pe(Ae,{color:r.color,children:[Te(pT,{type:"dots"})," ",r.text]}),e.phase==="done"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]})]}),Pe(qe,{marginTop:1,children:[Te(Ae,{color:"#808080",children:"\u8FDB\u5EA6: "}),Te(hT,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),Te(qe,{marginTop:1,children:Te(gT,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&Pe(qe,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&Pe(Ae,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&Pe(Ae,{color:"#ff9800",children:["\u{1F4E6} token: ",Fh(e.beforeTokens),e.afterTokens!==void 0&&Pe(bT,{children:[" \u2192 ",Te(Ae,{color:"#00ff41",bold:!0,children:Fh(e.afterTokens)}),Pe(Ae,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&Pe(qe,{marginTop:1,flexDirection:"column",children:[Te(Ae,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),Te(yT,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&Te(qe,{marginTop:1,children:Te(Ae,{color:"#ff9800",children:"\u26A0 LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\u6458\u8981\u3002\u538B\u7F29\u5DF2\u751F\u6548\u4F46\u6458\u8981\u8D28\u91CF\u8F83\u4F4E\u3002"})}),e.phase==="error"&&e.errorMessage&&Te(qe,{marginTop:1,children:Pe(Ae,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var Gh={name:"dskcode",version:"0.1.
|
|
192
|
+
`)){if(r.length===0){n.push("");continue}let o="",s=0;for(let i of r){let l=i.codePointAt(0)>11904?2:1;s+l>t&&o.length>0?(n.push(o),o=i,s=l):(o+=i,s+=l)}o.length>0&&n.push(o)}return n}function Fh(e){return e.toLocaleString()}function ru({state:e,contentWidth:t}){let n=Bh(()=>fT(e),[e]),r=Bh(()=>mT(e),[e]),o=e.progress?.type==="summary_delta"?e.progress.totalSoFar:e.progress?.type==="fallback"?e.progress.fallbackSummary:(e.phase==="done"&&e.strategy==="summary",""),s=e.phase==="done"&&e.strategy==="summary"?e.progress?.type==="summary_delta"?e.progress.totalSoFar:"":o,i=e.phase==="error"?"#ff6347":"#00ffff";return Te(qe,{flexDirection:"column",marginTop:1,children:Pe(qe,{flexDirection:"row",children:[Te(qe,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),Pe(qe,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Pe(qe,{children:[Te(Ae,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),Te(qe,{flexGrow:1}),e.phase==="running"&&Pe(Ae,{color:r.color,children:[Te(pT,{type:"dots"})," ",r.text]}),e.phase==="done"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]})]}),Pe(qe,{marginTop:1,children:[Te(Ae,{color:"#808080",children:"\u8FDB\u5EA6: "}),Te(hT,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),Te(qe,{marginTop:1,children:Te(gT,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&Pe(qe,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&Pe(Ae,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&Pe(Ae,{color:"#ff9800",children:["\u{1F4E6} token: ",Fh(e.beforeTokens),e.afterTokens!==void 0&&Pe(bT,{children:[" \u2192 ",Te(Ae,{color:"#00ff41",bold:!0,children:Fh(e.afterTokens)}),Pe(Ae,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&Pe(qe,{marginTop:1,flexDirection:"column",children:[Te(Ae,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),Te(yT,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&Te(qe,{marginTop:1,children:Te(Ae,{color:"#ff9800",children:"\u26A0 LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\u6458\u8981\u3002\u538B\u7F29\u5DF2\u751F\u6548\u4F46\u6458\u8981\u8D28\u91CF\u8F83\u4F4E\u3002"})}),e.phase==="error"&&e.errorMessage&&Te(qe,{marginTop:1,children:Pe(Ae,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var Gh={name:"dskcode",version:"0.1.53",keywords:["cli","ink","commander","deepseek","asciichart"],description:"A DeepSeek-native AI coding agent for your terminal",type:"module",bin:{dskcode:"dist/index.js"},exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist","README.md","LICENSE","!dist/**/*.map"],scripts:{dev:"tsup --watch",debug:"npm run build && node dist/index.js",build:"tsup",obfuscate:"node scripts/obfuscate.mjs","build:clean":"node scripts/clean-sourcemaps.mjs","type-check":"tsc --noEmit",format:"prettier --write src/ tests/","format:check":"prettier --check src/ tests/",test:"vitest run --exclude 'tests/checkpoint.test.ts' --exclude 'tests/session-rewind.test.ts'","test:checkpoint":"vitest run tests/checkpoint.test.ts tests/session-rewind.test.ts",prepublishOnly:"npm run build && npm run test && npm run build:clean"},dependencies:{asciichart:"^1.5.25",chalk:"^5.6.2",commander:"^13.1.0",handlebars:"^4.7.9",ink:"^7.1.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0",react:"^19.2.7",ws:"^8.21.0",yaml:"^2.6.0",zod:"^3.25.76"},devDependencies:{"@shikijs/cli":"^4.3.1","@types/node":"^22.14.0","@types/react":"^19.2.17","@types/ws":"^8.18.1","javascript-obfuscator":"^4.1.1",prettier:"^3.5.3",tsup:"^8.4.0",typescript:"^5.8.3",vitest:"^3.1.1"},engines:{node:">=22.0.0"},license:"MIT"};var Qo=Gh.version;p();p();var Ji=class{#e=new Map;#t=new Map;register(t,n){this.#e.set(t,n)}get(t,n){if(!al(n.model))throw new ll(n.model);let r=`${t}:${n.baseUrl}:${n.model}`,o=this.#t.get(r);if(o)return o;let s=this.#e.get(t);if(!s){let a=[...this.#e.keys()].join(", ");throw new Error(`\u672A\u6CE8\u518C\u7684 Provider: "${t}"\u3002\u53EF\u7528: ${a}`)}let i=s(n);return this.#t.set(r,i),i}list(){return[...this.#e.keys()]}clear(){this.#t.clear()}},ou=new Ji;ou.register("deepseek",e=>new cl({apiKey:e.apiKey,baseUrl:e.baseUrl,model:e.model}));function su(e){return ou.get(e.name,e)}p();p();import Wh from"handlebars";var jh=`\u4F60\u662F dskcode\uFF0C\u4E00\u4E2A\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u7EC8\u7AEF\u4E2D\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u5F00\u53D1\u8005\u7F16\u5199\u3001\u7406\u89E3\u3001\u8C03\u8BD5\u548C\u91CD\u6784\u4EE3\u7801\u3002\r
|
|
193
193
|
\r
|
|
194
194
|
## \u6838\u5FC3\u539F\u5219\r
|
|
195
195
|
- \u56DE\u7B54\u4F7F\u7528\u4E2D\u6587\uFF0C\u4EE3\u7801\u6807\u8BC6\u7B26\u4FDD\u6301\u82F1\u6587\r
|
|
@@ -493,7 +493,7 @@ ${d}`,issues:a}}let u={name:n,success:c.success,error:c.error,timestamp:r,...a?{
|
|
|
493
493
|
`);return t+`
|
|
494
494
|
|
|
495
495
|
`+o}#o(t){let n=t.recentSameTool;if(n.length<this.#e)return null;let r=n.slice(-this.#e),o=r[0];if(!r.every(i=>!i.success&&i.error===o.error))return null;let s=o.error??"\u672A\u77E5\u9519\u8BEF";return{category:"repeated_failure",toolName:t.name,hint:`\u4F60\u5DF2\u8FDE\u7EED ${this.#e} \u6B21\u8C03\u7528 \`${t.name}\` \u5931\u8D25\uFF08\u9519\u8BEF\uFF1A${s}\uFF09\u3002\u8BF7\u5148 \`read_file\` \u770B\u6E05\u73B0\u573A\u6216\u6362\u5176\u4ED6\u5DE5\u5177\uFF0C\u4E0D\u8981\u7EE7\u7EED\u540C\u6837\u7684\u9519\u8BEF\u8C03\u7528\u3002`}}#n(t){let n=t.result.error==="TOOL_NOT_FOUND",r=t.result.data??"",o=r.includes("ENOENT")||r.includes("No such file")||/\bnot found\b/i.test(r);return!n&&!o?null:{category:"file_not_found",toolName:t.name,hint:`\`${t.name}\` \u5931\u8D25\uFF1A\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\u8BF7\u5148\u7528 \`ls\` / \`glob\` \u770B\u4E00\u4E0B\u76EE\u5F55\u7ED3\u6784\uFF0C\u6216\u786E\u8BA4\u8DEF\u5F84\u62FC\u5199\uFF08\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u89C1 system prompt\uFF09\u3002`}}#a(t){if(!(t.result.error==="TEXT_NOT_FOUND"||t.result.error==="TEXT_MULTIPLE_MATCHES"))return null;let o=t.result.error==="TEXT_MULTIPLE_MATCHES"?`\`${t.name}\`\uFF1Aold_text \u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\u3002\u8BF7\u8865\u5145\u4E0A\u4E0B\u6587\u8BA9 old_text \u552F\u4E00\uFF0C\u6216\u6539\u7528 multi_edit \u7684 replaceAll\u3002`:`\`${t.name}\`\uFF1A\u672A\u627E\u5230 old_text\u3002\u8BF7\u91CD\u65B0 \`read_file\` \u770B\u5F53\u524D\u5185\u5BB9\uFF0C\u9010\u5B57\u590D\u5236\u8981\u66FF\u6362\u7684\u7247\u6BB5\uFF08\u6CE8\u610F\u7F29\u8FDB\u4E0E\u7A7A\u683C\uFF09\uFF1B\u884C\u5C3E\u5DF2\u505A CRLF \u5F52\u4E00\u5316\uFF0C\u65E0\u9700\u624B\u5199 \\r\\n\u3002`;return{category:"text_not_found",toolName:t.name,hint:o}}#c(t){let n=t.result.error==="GATE_DENIED",r=t.result.data??"",o=r.includes("EACCES")||/\bpermission\b/i.test(r)||/\bdenied\b/i.test(r);return!n&&!o?null:{category:"permission_denied",toolName:t.name,hint:`\`${t.name}\` \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\u3002\u8BF7\u68C0\u67E5\uFF1A1) \u8DEF\u5F84\u662F\u5426\u5728\u5141\u8BB8\u6839\u76EE\u5F55\u5185\uFF1B2) \u662F\u5426\u9700\u8981\u5207\u6362\u6388\u6743\u6A21\u5F0F\uFF1B3) \u6539\u7528\u5176\u4ED6\u4E0D\u9700\u8981\u6743\u9650\u7684\u5DE5\u5177\u3002`}}#i(t,n){if(!(t.kind==="edit"||t.kind==="delete"||t.kind==="move")||t.result.error!=="OUTSIDE_WRITE_ROOTS")return null;let o=n[0]??"<\u672A\u914D\u7F6E>";return{category:"out_of_write_root",toolName:t.name,hint:`\`${t.name}\` \u662F\u5199\u64CD\u4F5C\u4F46\u76EE\u6807\u8DEF\u5F84\u4E0D\u5728\u5141\u8BB8\u7684\u6839\u76EE\u5F55\u5185\u3002\u8BF7\u6539\u7528 \`${o}\` \u4E0B\u7684\u8DEF\u5F84\uFF0C\u6216\u8C03\u6574\u9879\u76EE\u7684 \`writeRoots\` \u914D\u7F6E\u3002`}}#p(t){return t.length<=this.#r?t:t.slice(0,this.#r-3)+"..."}#s(t){let n=t.result.issues;if(!n||n.length===0)return null;let r=n.slice(0,3).map(s=>s.message).join("; "),o=n.length>3?`\uFF08\u53E6\u6709 ${n.length-3} \u6761\uFF09`:"";return{category:"invalid_args",toolName:t.name,hint:`\`${t.name}\` \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A${r}${o}\u3002\u8BF7\u68C0\u67E5\u5FC5\u586B\u5B57\u6BB5\u3001\u7C7B\u578B\u4E0E enum \u767D\u540D\u5355\u3002`}}};p();function ng(e,t){return(t==="plan"?e.listReadTools():e.list()).map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:r.parameters}}))}p();var na=class{#e=[];#t=0;add(t,n=[]){for(let o of n)if(!this.#e.find(s=>s.id===o))throw new Error(`todo \u4F9D\u8D56 #${o} \u4E0D\u5B58\u5728\uFF08\u5DF2\u5206\u914D\u7684 id: ${this.#e.map(s=>s.id).join(", ")||"(\u7A7A)"}\uFF09`);let r=this.#t++;return this.#e.push({id:r,content:t,status:"pending",deps:[...n],updatedAt:Date.now()}),r}resetForRetry(t){let n=this.#r(t);return!n||n.status!=="failed"?!1:(n.status="pending",n.evidence=void 0,n.updatedAt=Date.now(),!0)}markRunning(t){let n=this.#r(t);return!n||n.status!=="pending"||!this.#o(n.deps)?!1:(n.status="running",n.updatedAt=Date.now(),!0)}markDone(t,n){let r=this.#r(t);return!r||r.status!=="running"&&r.status!=="pending"?!1:(r.status="done",n!==void 0&&(r.evidence=n),r.updatedAt=Date.now(),!0)}markFailed(t,n){let r=this.#r(t);return!r||r.status==="done"?!1:(r.status="failed",r.evidence=n,r.updatedAt=Date.now(),!0)}markSkipped(t,n){let r=this.#r(t);return!r||r.status==="done"||r.status==="failed"?!1:(r.status="skipped",r.evidence=n,r.updatedAt=Date.now(),!0)}pending(){return this.#e.filter(t=>t.status==="pending"&&this.#o(t.deps))}unfinished(){return this.#e.filter(t=>t.status==="pending"||t.status==="running"||t.status==="failed")}isAllTerminated(){return this.#e.every(t=>t.status==="done"||t.status==="failed"||t.status==="skipped")}get items(){return this.#e.map(t=>({...t}))}toMarkdown(t=20){if(this.#e.length===0)return"";let n=this.#e.filter(l=>l.status==="pending"||l.status==="running"||l.status==="failed"),o=[...this.#e.filter(l=>l.status==="done"||l.status==="skipped")].sort((l,c)=>c.updatedAt-l.updatedAt),s=o.length>t,i=s?o.slice(0,Math.max(0,t-n.length)):o,a=[...n,...i].map(l=>{let c=this.#n(l.status),u=l.deps.length>0?` (\u4F9D\u8D56: #${l.deps.join(", #")})`:"",d=l.evidence?` \u2014 ${l.evidence}`:"";return`- ${c} #${l.id} ${l.content}${u}${d}`});if(s){let l=o.length-i.length;a.push(`- ...\uFF08\u53E6\u6709 ${l} \u6761\u5DF2\u5B8C\u6210\u5DF2\u6298\u53E0\uFF09`)}return["## \u{1F4CB} \u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6",...a,"","\u89C4\u5219\uFF1A\u6309\u987A\u5E8F\u63A8\u8FDB\uFF1B\u672A\u5B8C\u6210\u4F9D\u8D56\u65F6\u4E0D\u8981\u8DF3\u6B65\uFF1B\u5B8C\u6210\u8BF7\u8C03\u7528 todo_mark_done\uFF0C\u5931\u8D25\u8BF7\u8C03\u7528 todo_mark_failed\uFF1B\u91CD\u8BD5\u5931\u8D25\u9879\u5148\u8C03 todo_retry \u518D\u91CD\u8DD1\u3002"].join(`
|
|
496
|
-
`)}#r(t){return this.#e.find(n=>n.id===t)}#o(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#n(t){switch(t){case"pending":return"\u2610";case"running":return"\u25B6";case"done":return"\u2705";case"failed":return"\u274C";case"skipped":return"\u23ED"}}};p();function rg(e){return[UT(e),WT(e),HT(e),VT(e),zT(e)]}function UT(e){return{name:"todo_add",kind:"
|
|
496
|
+
`)}#r(t){return this.#e.find(n=>n.id===t)}#o(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#n(t){switch(t){case"pending":return"\u2610";case"running":return"\u25B6";case"done":return"\u2705";case"failed":return"\u274C";case"skipped":return"\u23ED"}}};p();function rg(e){return[UT(e),WT(e),HT(e),VT(e),zT(e)]}function UT(e){return{name:"todo_add",kind:"read",description:`\u26A0\uFE0F \u3010\u590D\u6742\u4EFB\u52A1\u7B2C\u4E00\u6B65\u3011\u6DFB\u52A0\u4E00\u4E2A\u5F85\u529E\u5230\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3002
|
|
497
497
|
|
|
498
498
|
\u4EC0\u4E48\u60C5\u51B5\u4E0B\u8C03\u6211\uFF1A
|
|
499
499
|
- \u9700\u8981\u591A\u6B65\u624D\u80FD\u5B8C\u6210\uFF08\u6539\u591A\u4E2A\u6587\u4EF6 / \u8DE8\u591A\u8F6E\uFF09
|
|
@@ -505,13 +505,13 @@ ${d}`,issues:a}}let u={name:n,success:c.success,error:c.error,timestamp:r,...a?{
|
|
|
505
505
|
|
|
506
506
|
\u7528\u6CD5\uFF1A\u6BCF\u6B21\u52A0\u4E00\u4E2A step\uFF0C\u591A\u6B65\u5C31\u8C03\u591A\u6B21\u3002\u6709\u4F9D\u8D56\u5173\u7CFB\u4F20 deps=[\u524D\u6B65 id]\u3002\u8FD4\u56DE\u5206\u914D\u7684 id\uFF0C\u540E\u7EED\u7528 todo_mark_done / todo_mark_failed \u5F15\u7528\u3002
|
|
507
507
|
|
|
508
|
-
\u793A\u4F8B\uFF1A\u7528\u6237\u8BF4\u300C\u628A X \u6539\u6210 Y\u300D\u2192 \u8C03 1) todo_add("\u8BFB X") 2) todo_add("\u6539 X", deps=[0]) 3) todo_add("\u68C0\u67E5\u6539\u52A8", deps=[1])`,parameters:{type:"object",properties:{content:{type:"string",description:"\u6B65\u9AA4\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF0C\u5EFA\u8BAE\u7B80\u6D01\uFF09"},deps:{type:"array",description:"\u4F9D\u8D56\u7684 todo id \u6570\u7EC4\uFF08\u8FD9\u4E9B\u90FD done \u540E\u672C\u9879\u624D\u53EF\u6267\u884C\uFF09",items:{type:"number"}}},required:["content"],additionalProperties:!1},async execute(t){if(typeof t?.content!="string"||t.content.length===0)return{success:!1,data:"\u7F3A\u5C11 content \u53C2\u6570",error:"INVALID_ARGS"};let n=Array.isArray(t.deps)?t.deps.filter(r=>typeof r=="number"):[];try{let r=e.add(t.content,n);return{success:!0,data:`\u5DF2\u6DFB\u52A0 todo #${r}\uFF1A${t.content}${n.length>0?`\uFF08\u4F9D\u8D56: ${n.join(", ")})`:""}`,summary:`\u{1F4CB} \u6DFB\u52A0 #${r}`}}catch(r){return{success:!1,data:r instanceof Error?r.message:String(r),error:"TODO_DEPS_INVALID"}}}}}function WT(e){return{name:"todo_mark_running",kind:"
|
|
508
|
+
\u793A\u4F8B\uFF1A\u7528\u6237\u8BF4\u300C\u628A X \u6539\u6210 Y\u300D\u2192 \u8C03 1) todo_add("\u8BFB X") 2) todo_add("\u6539 X", deps=[0]) 3) todo_add("\u68C0\u67E5\u6539\u52A8", deps=[1])`,parameters:{type:"object",properties:{content:{type:"string",description:"\u6B65\u9AA4\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF0C\u5EFA\u8BAE\u7B80\u6D01\uFF09"},deps:{type:"array",description:"\u4F9D\u8D56\u7684 todo id \u6570\u7EC4\uFF08\u8FD9\u4E9B\u90FD done \u540E\u672C\u9879\u624D\u53EF\u6267\u884C\uFF09",items:{type:"number"}}},required:["content"],additionalProperties:!1},async execute(t){if(typeof t?.content!="string"||t.content.length===0)return{success:!1,data:"\u7F3A\u5C11 content \u53C2\u6570",error:"INVALID_ARGS"};let n=Array.isArray(t.deps)?t.deps.filter(r=>typeof r=="number"):[];try{let r=e.add(t.content,n);return{success:!0,data:`\u5DF2\u6DFB\u52A0 todo #${r}\uFF1A${t.content}${n.length>0?`\uFF08\u4F9D\u8D56: ${n.join(", ")})`:""}`,summary:`\u{1F4CB} \u6DFB\u52A0 #${r}`}}catch(r){return{success:!1,data:r instanceof Error?r.message:String(r),error:"TODO_DEPS_INVALID"}}}}}function WT(e){return{name:"todo_mark_running",kind:"read",description:`\u628A todo \u4ECE pending \u63A8\u8FDB\u5230 running\uFF0C\u8868\u793A\u4F60\u300C\u6B63\u5728\u505A\u300D\u8FD9\u4E00\u6B65\u3002
|
|
509
509
|
\u524D\u63D0\uFF1A\u8BE5 todo \u5B58\u5728\u3001\u5F53\u524D\u662F pending\u3001\u4E14\u6240\u6709 deps \u5DF2 done \u6216 skipped\u3002
|
|
510
510
|
\u5DE5\u4F5C\u6D41\uFF1A\u5148\u8C03 todo_mark_running\uFF0C\u518D\u53BB\u8C03\u5B9E\u9645\u7684\u5DE5\u5177\uFF08read_file / edit_file \u7B49\uFF09\uFF0C\u6700\u540E\u7528 todo_mark_done \u6216 todo_mark_failed \u6536\u5C3E\u3002
|
|
511
|
-
**\u4E0D\u8981\u8DF3\u8FC7 mark_running \u76F4\u63A5 mark_done** \u2014 \u4F1A\u7834\u574F\u4F9D\u8D56\u68C0\u67E5\uFF0C\u4E0B\u6E38\u6B65\u9AA4\u53EF\u80FD\u8BEF\u4EE5\u4E3A\u4F9D\u8D56\u5DF2\u6EE1\u8DB3\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="pending"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 pending \u53EF\u4EE5\u63A8\u8FDB\u5230 running`,error:"TODO_INVALID_STATE"}:e.markRunning(t.id)?{success:!0,data:`\u5DF2\u5F00\u59CB todo #${t.id}\uFF1A${n.content}`,summary:`\u25B6 \u5F00\u59CB #${t.id}`}:{success:!1,data:`todo #${t.id} \u4F9D\u8D56\u672A\u5168\u90E8\u5B8C\u6210\uFF08\u4F9D\u8D56: #${n.deps.join(", #")}\uFF09`,error:"TODO_DEPS_NOT_READY"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function HT(e){return{name:"todo_mark_done",kind:"
|
|
512
|
-
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},evidence:{type:"string",description:"\u5B8C\u6210\u8BC1\u636E\uFF08\u4E00\u53E5\u8BDD\uFF0C\u53EF\u9009\uFF09"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_done\uFF1B\u5982\u9700\u91CD\u8BD5\u8BF7\u5148 todo_retry`,error:"TODO_INVALID_STATE"}:e.markDone(t.id,t.evidence)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5B8C\u6210${t.evidence?`\uFF1A${t.evidence}`:""}`,summary:`\u2705 \u5B8C\u6210 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function VT(e){return{name:"todo_mark_failed",kind:"
|
|
511
|
+
**\u4E0D\u8981\u8DF3\u8FC7 mark_running \u76F4\u63A5 mark_done** \u2014 \u4F1A\u7834\u574F\u4F9D\u8D56\u68C0\u67E5\uFF0C\u4E0B\u6E38\u6B65\u9AA4\u53EF\u80FD\u8BEF\u4EE5\u4E3A\u4F9D\u8D56\u5DF2\u6EE1\u8DB3\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="pending"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 pending \u53EF\u4EE5\u63A8\u8FDB\u5230 running`,error:"TODO_INVALID_STATE"}:e.markRunning(t.id)?{success:!0,data:`\u5DF2\u5F00\u59CB todo #${t.id}\uFF1A${n.content}`,summary:`\u25B6 \u5F00\u59CB #${t.id}`}:{success:!1,data:`todo #${t.id} \u4F9D\u8D56\u672A\u5168\u90E8\u5B8C\u6210\uFF08\u4F9D\u8D56: #${n.deps.join(", #")}\uFF09`,error:"TODO_DEPS_NOT_READY"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function HT(e){return{name:"todo_mark_done",kind:"read",description:`\u628A todo \u6807\u8BB0\u4E3A\u5B8C\u6210\u3002evidence \u586B\u300C\u5B8C\u6210\u8BC1\u636E\u300D\uFF08\u5982\u300C\u8BFB\u5230 120 \u884C\u300D\u3001\u300Ctypecheck \u901A\u8FC7\u300D\u3001\u300Cedit \u6210\u529F\u300D\uFF09\uFF0C\u4E0D\u586B\u4E5F\u884C\u3002
|
|
512
|
+
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},evidence:{type:"string",description:"\u5B8C\u6210\u8BC1\u636E\uFF08\u4E00\u53E5\u8BDD\uFF0C\u53EF\u9009\uFF09"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_done\uFF1B\u5982\u9700\u91CD\u8BD5\u8BF7\u5148 todo_retry`,error:"TODO_INVALID_STATE"}:e.markDone(t.id,t.evidence)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5B8C\u6210${t.evidence?`\uFF1A${t.evidence}`:""}`,summary:`\u2705 \u5B8C\u6210 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function VT(e){return{name:"todo_mark_failed",kind:"read",description:`\u628A todo \u6807\u8BB0\u4E3A\u5931\u8D25\uFF0Creason \u586B\u300C\u5931\u8D25\u539F\u56E0\u300D\uFF08\u5982\u300Cold_text \u62FC\u9519\u300D\u3001\u300C\u6587\u4EF6\u4E0D\u5B58\u5728\u300D\uFF09\u3002
|
|
513
513
|
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002
|
|
514
|
-
\u8C03\u7528\u540E\u8BE5 step \u72B6\u6001\u53D8\u4E3A failed\u3002\u60F3\u91CD\u8BD5\uFF1A\u8C03 todo_retry(id) \u91CD\u7F6E\u56DE pending\uFF0C\u518D mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 mark_done\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},reason:{type:"string",description:"\u5931\u8D25\u539F\u56E0\uFF08\u4E00\u53E5\u8BDD\uFF09"}},required:["id","reason"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};if(typeof t?.reason!="string")return{success:!1,data:"\u7F3A\u5C11 reason \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_failed`,error:"TODO_INVALID_STATE"}:e.markFailed(t.id,t.reason)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5931\u8D25\uFF1A${t.reason}`,summary:`\u274C \u5931\u8D25 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function zT(e){return{name:"todo_retry",kind:"
|
|
514
|
+
\u8C03\u7528\u540E\u8BE5 step \u72B6\u6001\u53D8\u4E3A failed\u3002\u60F3\u91CD\u8BD5\uFF1A\u8C03 todo_retry(id) \u91CD\u7F6E\u56DE pending\uFF0C\u518D mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 mark_done\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},reason:{type:"string",description:"\u5931\u8D25\u539F\u56E0\uFF08\u4E00\u53E5\u8BDD\uFF09"}},required:["id","reason"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};if(typeof t?.reason!="string")return{success:!1,data:"\u7F3A\u5C11 reason \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_failed`,error:"TODO_INVALID_STATE"}:e.markFailed(t.id,t.reason)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5931\u8D25\uFF1A${t.reason}`,summary:`\u274C \u5931\u8D25 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function zT(e){return{name:"todo_retry",kind:"read",description:`\u628A\u5931\u8D25\u7684 todo \u91CD\u7F6E\u56DE pending\uFF08\u6E05\u7A7A evidence\uFF09\uFF0C\u7136\u540E\u4F60\u53EF\u4EE5\u91CD\u65B0\u8D70 todo_mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 todo_mark_done \u7684\u6D41\u7A0B\u3002
|
|
515
515
|
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F failed\u3002done / skipped / running \u4E0D\u5141\u8BB8\u91CD\u8BD5\uFF08done \u4E0D\u53EF\u53CD\u6094\u3001running \u5E94\u5148 mark_failed\uFF09\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="failed"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 failed \u53EF\u4EE5\u91CD\u8BD5`,error:"TODO_INVALID_STATE"}:e.resetForRetry(t.id)?{success:!0,data:`\u5DF2\u91CD\u7F6E todo #${t.id} \u4E3A pending\uFF0C\u53EF\u91CD\u65B0\u8DD1`,summary:`\u{1F504} \u91CD\u8BD5 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}p();p();import{execFile as qT}from"child_process";import{promisify as KT}from"util";var oa=KT(qT),sa={windowsHide:!0};async function mu(e){try{return await oa("git",["rev-parse","--is-inside-work-tree"],{cwd:e,...sa}),!0}catch{return!1}}async function og(e){try{return await oa("git",["rev-parse","--verify","HEAD"],{cwd:e,...sa}),!0}catch{return!1}}async function XT(e){return(await oa("git",["status","--porcelain"],{cwd:e,...sa})).stdout.trim().length>0}async function Wt(e,t){try{let{stdout:n}=await oa("git",e,{cwd:t,...sa});return n}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`git ${e.join(" ")} \u5931\u8D25: ${r}`)}}async function ra(e){return(await Wt(["stash","list","--format=%H"],e)).split(`
|
|
516
516
|
`).map(n=>n.trim()).filter(Boolean)}async function hu(e){let t=Date.now();if(!await mu(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!1};if(!await og(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};if(!await XT(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};let r=await ra(e);await Wt(["stash","push","-m",`dskcode-cp-${t}`,"-u"],e);let o=await ra(e);if(o.length===0)throw new Error("git stash push \u672A\u80FD\u521B\u5EFA stash entry");let s=o.find(i=>!r.includes(i))??o[0];return await Wt(["stash","apply",s],e),{stashSha:s,timestamp:t,cwd:e,isGitRepo:!0}}async function gu(e){if(!e.isGitRepo)throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!e.stashSha)throw new Error("\u68C0\u67E5\u70B9\u4E3A\u7A7A\uFF08\u5DE5\u4F5C\u533A\u539F\u672C\u5C31\u5E72\u51C0\uFF09\uFF0C\u65E0\u9700\u6062\u590D");let{cwd:t,stashSha:n}=e,r=await ra(t);if(!r.includes(n))throw new Error("\u68C0\u67E5\u70B9\u5DF2\u5931\u6548\uFF08stash entry \u5DF2\u88AB\u6D88\u8D39\u6216 GC\uFF09\uFF0C\u65E0\u6CD5\u6062\u590D");await Wt(["checkout","--","."],t),await Wt(["clean","-fd"],t),await Wt(["stash","apply",n],t);let o=r.indexOf(n);o>=0&&await Wt(["stash","drop",`stash@{${o}}`],t)}async function yu(e){if(!await mu(e))throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!await og(e))throw new Error("\u4ED3\u5E93\u65E0 commit\uFF0C\u65E0\u6CD5\u6062\u590D");await Wt(["checkout","--","."],e),await Wt(["clean","-fd"],e)}async function ia(e){if(!e.isGitRepo||!e.stashSha)return;let{cwd:t,stashSha:n}=e,r;try{r=await ra(t)}catch{return}let o=r.indexOf(n);if(!(o<0))try{await Wt(["stash","drop",`stash@{${o}}`],t)}catch{}}p();p();import{mkdir as JT,readFile as sg,writeFile as ZT,readdir as YT,unlink as QT,rename as eC}from"fs/promises";import{join as Wr}from"path";import{randomUUID as tC}from"crypto";function ig(){let e=process.env.HOME??process.env.USERPROFILE??"~";return Wr(e,".dskcode","sessions")}var cr=class{#e;constructor(t){this.#e=t??ig()}get dir(){return this.#e}async save(t){await JT(this.#e,{recursive:!0});let n=Wr(this.#e,`${t.id}.json`),r=Wr(this.#e,`.${t.id}.json.tmp`);await ZT(r,JSON.stringify(t,null,2),"utf-8"),await eC(r,n)}async load(t){let n=Wr(this.#e,`${t}.json`);try{let r=await sg(n,"utf-8");return JSON.parse(r)}catch(r){if(xu(r))return null;throw r}}async list(){let t;try{t=await YT(this.#e)}catch(r){if(xu(r))return[];throw r}let n=[];for(let r of t)if(!(!r.endsWith(".json")||r.startsWith(".")))try{let o=await sg(Wr(this.#e,r),"utf-8"),s=JSON.parse(o);n.push({id:s.id,title:s.title||"\uFF08\u65E0\u6807\u9898\uFF09",updatedAt:s.updatedAt,cwd:s.cwd,messageCount:s.messages?.length??0})}catch{}return n.sort((r,o)=>o.updatedAt-r.updatedAt)}async delete(t){let n=Wr(this.#e,`${t}.json`);try{await QT(n)}catch(r){if(!xu(r))throw r}}async exists(t){return await this.load(t)!==null}static newId(){return tC()}};function xu(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}p();p();import{readFile as sC,stat as iC,open as aC}from"fs/promises";import{relative as lC}from"path";p();import{resolve as es,relative as cg,isAbsolute as nC}from"path";import{realpath as ag}from"fs/promises";import{spawn as rC}from"child_process";import ug from"process";var dg=3e4,pg=5e4,hN=10*1024*1024,aa=ug.platform==="win32";function Hr(e){return e.startsWith("@")?e.slice(1):e}function lt(e,t){let n=Hr(e),r=nC(n)?n:es(t,n);return es(r)}async function lg(e){try{return await ag(e)}catch{let t=es(e,"..");try{let n=await ag(t);return es(n,cg(t,e))}catch{return es(e)}}}async function on(e,t){if(e.length===0)return{ok:!0};let n=await lg(t);for(let r of e){let o=await lg(r);if(n===o)return{ok:!0};let s=cg(o,n);if(!s.startsWith("..")&&s!==""&&!s.startsWith("/")&&!s.startsWith("\\"))return{ok:!0}}return{ok:!1,error:`\u8DEF\u5F84 "${t}" \u4E0D\u5728\u5141\u8BB8\u7684\u5199\u5165\u8303\u56F4\u5185 ${e.join(", ")}`}}function Ze(e,t=pg){return e.length<=t?e:`${e.slice(0,t)}
|
|
517
517
|
|