zen-code 4.10.1 → 4.10.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.
- package/dist/app.js +157 -2615
- package/dist/chunk-0ddrb30y.js +1 -0
- package/dist/chunk-215an3fz.js +1 -0
- package/dist/chunk-40ht9pe1.js +91 -0
- package/dist/chunk-4wnmk2tj.js +7 -0
- package/dist/chunk-4z0w0ng1.js +2 -0
- package/dist/chunk-57bj89e2.js +1 -0
- package/dist/chunk-5a5mepqj.js +1 -0
- package/dist/chunk-5c3bpcpm.js +1 -0
- package/dist/chunk-7kw7ss8d.js +1 -0
- package/dist/chunk-86m0rmtc.js +1 -0
- package/dist/chunk-8f19qk9r.js +26 -0
- package/dist/chunk-8tbtavry.js +6 -0
- package/dist/chunk-9rayxazs.js +8 -0
- package/dist/chunk-a9gpb2tx.js +2 -0
- package/dist/chunk-a9tw6d68.js +1 -0
- package/dist/chunk-anbtppz1.js +294 -0
- package/dist/chunk-bca8tkkr.js +1 -0
- package/dist/chunk-bdqds8vh.js +1 -0
- package/dist/chunk-bzgznka5.js +3 -0
- package/dist/chunk-c7kd2qrp.js +278 -0
- package/dist/chunk-dvbb3dd1.js +233 -0
- package/dist/chunk-e8kxa5vj.js +140 -0
- package/dist/chunk-ehmmd8qc.js +1 -0
- package/dist/chunk-ejfa95sm.js +1 -0
- package/dist/chunk-f0m4532p.js +54 -0
- package/dist/chunk-f7cps5x1.js +1 -0
- package/dist/chunk-fbemqjck.js +2 -0
- package/dist/chunk-feeqtzv5.js +1 -0
- package/dist/chunk-fzh0v6r0.js +6 -0
- package/dist/chunk-g2zskge5.js +81 -0
- package/dist/chunk-g974hxbz.js +3 -0
- package/dist/chunk-g9911ymn.js +1 -0
- package/dist/chunk-gfhmzpy7.js +176 -0
- package/dist/chunk-gt8c6dne.js +3 -0
- package/dist/chunk-h8fdexm4.js +2 -0
- package/dist/chunk-hnnwbfqk.js +3 -0
- package/dist/chunk-hp2jzn9x.js +166 -0
- package/dist/chunk-hve2a279.js +2 -0
- package/dist/chunk-js4qp900.js +2 -0
- package/dist/chunk-k4q8j7pg.js +2 -0
- package/dist/chunk-m21hvv91.js +2 -0
- package/dist/chunk-mmx0k2yq.js +1 -0
- package/dist/chunk-mnnyjmgw.js +224 -0
- package/dist/chunk-mw7x6xqp.js +1 -0
- package/dist/chunk-n7s6my89.js +112 -0
- package/dist/chunk-n9rpnke9.js +4 -0
- package/dist/chunk-nk62q95g.js +93 -0
- package/dist/chunk-nmzx5nmt.js +1 -0
- package/dist/chunk-nqh1pptf.js +88 -0
- package/dist/chunk-nsw5168d.js +2 -0
- package/dist/chunk-pe8mzxwn.js +16 -0
- package/dist/chunk-pg1ppq4y.js +1 -0
- package/dist/chunk-pzb224c5.js +2 -0
- package/dist/chunk-q1cxrg0x.js +2 -0
- package/dist/chunk-qxebn3jw.js +18 -0
- package/dist/chunk-s1tbdcs8.js +4 -0
- package/dist/chunk-s5cqejr6.js +79 -0
- package/dist/chunk-spa69h7p.js +2 -0
- package/dist/chunk-spx7nn8t.js +6 -0
- package/dist/chunk-swc7se71.js +2 -0
- package/dist/chunk-swyc15ym.js +1 -0
- package/dist/chunk-t2s3s6af.js +1 -0
- package/dist/chunk-t6440ajd.js +5 -0
- package/dist/chunk-tjg2e8v3.js +41 -0
- package/dist/chunk-tjvhqr94.js +1 -0
- package/dist/chunk-vbb3m0vz.js +1 -0
- package/dist/chunk-vdmq9d9x.js +4 -0
- package/dist/chunk-vfxjbdz4.js +2 -0
- package/dist/chunk-vrnj0659.js +213 -0
- package/dist/chunk-wmyc17aa.js +23 -0
- package/dist/chunk-wt3p1w1g.js +1 -0
- package/dist/chunk-y5ry5c7v.js +1 -0
- package/dist/chunk-y8qhrx11.js +2 -0
- package/dist/chunk-yy8p9zph.js +2 -0
- package/dist/chunk-z61m3anh.js +1 -0
- package/dist/chunk-zg54h6gy.js +1 -0
- package/dist/chunk-zr90qp47.js +1 -0
- package/dist/chunk-zsa62xr0.js +2 -0
- package/dist/cli.js +1 -3116
- package/dist/nonInteractive.js +180 -1950
- package/dist/zen-keyboard.js +3 -358
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as d,i as e}from"./chunk-js4qp900.js";import{j as u}from"./chunk-h8fdexm4.js";import{R as o}from"./chunk-m21hvv91.js";import"./chunk-4wnmk2tj.js";import{Ae as J,De as c,Ie as x,Je as f,Ke as s,Le as i,Ne as t,we as l,ze as N}from"./chunk-c7kd2qrp.js";import"./chunk-a9tw6d68.js";import"./chunk-k4q8j7pg.js";import"./chunk-spx7nn8t.js";import"./chunk-vfxjbdz4.js";import"./chunk-qxebn3jw.js";import"./chunk-e8kxa5vj.js";import"./chunk-q1cxrg0x.js";import"./chunk-tjg2e8v3.js";import{Dl as S}from"./chunk-y8qhrx11.js";var zq=S(l(),1);var U=S(l(),1);var H=S(f(),1),a={openai:"\uD83E\uDD16",anthropic:"\uD83E\uDDE0",gemini:"✨",default:"\uD83D\uDD2E"};var Jq=({defaultValue:O,onSubmit:F,onSwitchProvider:X})=>{let[_,W]=U.useState(O),B=U.useCallback((G)=>{if(!G.trim())return;F(G.trim())},[F]),R=U.useCallback((G,K)=>{if(K.tab)return X?.(K.shift?"left":"right"),!1;if(K.leftArrow)return X?.("left"),!1;if(K.rightArrow)return X?.("right"),!1;return!0},[X]);return H.jsxDEV(N,{paddingX:2,paddingY:1,flexDirection:"column",gap:1,children:[H.jsxDEV(J,{color:"gray",children:"请输入模型名称(Enter 确认):"},void 0,!1,void 0,this),H.jsxDEV(s,{value:_,onChange:W,onSubmit:B,onHotKey:R,maxVisibleLines:1,placeholder:"例如:gpt-4o"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Qq=({onClose:O})=>{let{extraParams:F,config:X,updateConfig:_}=u(),[W,B]=U.useState(""),R=U.useRef([]),G=U.useMemo(()=>{if(!X?.providers||X.providers.length===0)return[];return X.providers.map((q)=>{let $=q.type||"default";return{id:q.id,label:q.id,icon:a[$]||a.default,config:q}})},[X?.providers]);U.useMemo(()=>{if(G.length>0&&!W){let q=G.find(($)=>$.id===F.provider_id);B(q?.id||G[0].id)}},[G,F.provider_id,W]);let K=G.find((q)=>q.id===W),{data:V,isLoading:y,error:v}=d({provider:K?.config||null,enabled:!!W}),b=U.useMemo(()=>{let q=(V||[]).map(($)=>({id:$.id,name:$.name}));return R.current=q,q},[V]),D=U.useCallback(async()=>{return R.current},[]),j=U.useCallback((q,$,C)=>{let M=q.id===F.provider_id+"-"+q.id;return H.jsxDEV(i,{isSelected:C,isCurrent:M,children:[H.jsxDEV(J,{bold:!0,children:[$+1,". ",q.id]},void 0,!0,void 0,this),H.jsxDEV(J,{dimColor:!0,children:[" ",q.name!==q.id?`(${q.name})`:""]},void 0,!0,void 0,this)]},`model-${$}-${q.id}`,!0,void 0,this)},[F.provider_id]),P=U.useCallback((q)=>{return q.id===F.provider_id+"-"+q.id},[F.provider_id]),g=U.useCallback(async(q)=>{await _({model_id:q}),O()},[_,O]),E=U.useCallback(async(q)=>{let C=G.find((M)=>M.id===W)?.config.type||"openai";await _({provider_id:W,provider_type:C,model_id:q.id}),O()},[_,W,O,G]),k=U.useCallback(async(q)=>{if(G.length<=1)return;let $=G.findIndex((p)=>p.id===W),C=q==="left"?($-1+G.length)%G.length:($+1)%G.length,M=G[C];B(M.id),await _({provider_id:M.id,provider_type:M.config.type})},[W,G,_]),m=U.useMemo(()=>{let q=K?.label||"加载中...";return{id:`model-${W}`,title:`模型选择 - ${q}`,icon:K?.icon||"\uD83D\uDD2E",dataSource:D,searchable:!0,searchFields:["id","name"],searchPlaceholder:"搜索模型...",itemHeight:1,visibleCount:10,renderItem:j,isSelected:P,onSelect:E,showCount:!0,keyMap:{leftArrow:($)=>{k("left")},rightArrow:($)=>{k("right")}}}},[W,K,D,j,P,E,k]);if(G.length===0)return H.jsxDEV(N,{flexDirection:"column",paddingX:2,paddingY:1,children:[H.jsxDEV(J,{color:"yellow",children:"⚠️ 未配置任何 Provider"},void 0,!1,void 0,this),H.jsxDEV(J,{color:"gray",dimColor:!0,children:"请先配置 Provider 后再查看模型列表"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let T=K?.config.apiKey;return H.jsxDEV(N,{flexDirection:"column",children:[H.jsxDEV(N,{gap:1,paddingX:1,paddingY:1,children:G.map((q,$)=>H.jsxDEV(J,{bold:q.id===W,color:q.id===W?"cyan":"gray",children:[q.icon," ",q.label,q.id===W&&" [当前]",q.id===W&&!T&&" (未配置 API Key)"]},`provider-tab-${$}-${q.id}`,!0,void 0,this))},void 0,!1,void 0,this),y?H.jsxDEV(N,{paddingX:2,paddingY:1,children:H.jsxDEV(J,{color:"gray",children:"加载模型列表中..."},void 0,!1,void 0,this)},void 0,!1,void 0,this):v||b.length===0?H.jsxDEV(Jq,{defaultValue:X?.model_id||"",onSubmit:g,onSwitchProvider:k},void 0,!1,void 0,this):!T?H.jsxDEV(N,{paddingX:2,paddingY:1,children:H.jsxDEV(J,{color:"yellow",children:"请先配置 API Key"},void 0,!1,void 0,this)},void 0,!1,void 0,this):H.jsxDEV(t,{config:m,onClose:O},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},r=Qq;var z=S(l(),1);var Z=S(f(),1),Wq=({onClose:O})=>{let{config:F,updateConfig:X}=u(),[_,W]=z.useState("list"),[B,R]=z.useState(null),[G,K]=z.useState(0),[V,y]=z.useState(null),v=z.useCallback(()=>y(null),[]);o(v,V?3000:null);let b=z.useRef(_),D=z.useRef(G),j=z.useRef([]),P=z.useRef(!0);z.useEffect(()=>{b.current=_},[_]),z.useEffect(()=>{D.current=G},[G]);let g=F?.providers||[];z.useEffect(()=>{j.current=g},[g]);let E=z.useCallback(()=>{P.current=!0,R(null),W("form"),y(null)},[]),k=z.useCallback(()=>{let Q=j.current,Y=D.current,L=Q[Y];if(!L)return;P.current=!1,R(L),W("form"),y(null)},[]),m=z.useCallback(()=>{W("list"),R(null),y(null)},[]),T=z.useCallback(async(Q)=>{let Y=j.current,L=P.current,A=L?[...Y,Q]:Y.map((w)=>w.id===Q.id?Q:w);if(await X({providers:A}),y(L?`已添加 Provider: ${Q.id}`:`已更新 Provider: ${Q.id}`),L){let w=A.findIndex((I)=>I.id===Q.id);K(w>=0?w:0)}W("list"),R(null),y(null)},[X]),q=z.useCallback(async()=>{let Q=j.current,Y=D.current,L=Q[Y];if(!L)return;if(Q.length<=1){y("无法删除最后一个 Provider");return}let A=Q.filter((I)=>I.id!==L.id);await X({providers:A});let w=Math.min(Y,A.length-1);K(w>=0?w:0),y(`已删除 Provider: ${L.id}`)},[X]),$=z.useRef(E),C=z.useRef(k),M=z.useRef(q),p=z.useRef(m),n=z.useRef(O);z.useEffect(()=>{$.current=E},[E]),z.useEffect(()=>{C.current=k},[k]),z.useEffect(()=>{M.current=q},[q]),z.useEffect(()=>{p.current=m},[m]),z.useEffect(()=>{n.current=O},[O]),x((Q,Y)=>{let L=b.current,A=j.current,w=D.current;if(L==="form"){if(Y.escape)p.current();return}if(Y.upArrow)K((I)=>I>0?I-1:A.length-1);else if(Y.downArrow)K((I)=>I<A.length-1?I+1:0);else if(Q==="n"||Q==="N")$.current();else if((Q==="e"||Q==="E"||Y.return)&&A[w])C.current();else if((Q==="d"||Q==="D")&&A[w])M.current();else if(Y.escape)n.current()},{isActive:!0});let Gq=z.useMemo(()=>{if(g.length===0)return Z.jsxDEV(N,{paddingX:2,paddingY:1,children:Z.jsxDEV(J,{color:"yellow",children:"未配置任何 Provider"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Z.jsxDEV(N,{flexDirection:"column",paddingX:2,gap:1,children:[g.map((Q,Y)=>{let L=!!Q.apiKey,A=L?"green":"yellow";return Z.jsxDEV(N,{marginBottom:0,gap:1,children:[Z.jsxDEV(J,{color:Y===G?"cyan":"gray",bold:Y===G,children:Y===G?">":" "},void 0,!1,void 0,this),Z.jsxDEV(J,{bold:Y===G,color:Y===G?"cyan":void 0,children:Q.id},void 0,!1,void 0,this),Z.jsxDEV(c,{},void 0,!1,void 0,this),Z.jsxDEV(J,{color:"gray",dimColor:Y!==G,children:[" ",Q.type]},void 0,!0,void 0,this),Z.jsxDEV(J,{color:A,dimColor:Y!==G,children:[" ","[",L?"已配置":"未配置","]"]},void 0,!0,void 0,this)]},`provider-${Y}-${Q.id}`,!0,void 0,this)}),Z.jsxDEV(N,{marginTop:1,children:Z.jsxDEV(J,{color:"gray",dimColor:!0,children:[Z.jsxDEV(J,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",Z.jsxDEV(J,{color:"cyan",children:"n"},void 0,!1,void 0,this)," 新增 ",Z.jsxDEV(J,{color:"cyan",children:"d"},void 0,!1,void 0,this)," ","删除 ",Z.jsxDEV(J,{color:"cyan",children:"Esc"},void 0,!1,void 0,this)," 关闭"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},[g,G]);return Z.jsxDEV(N,{flexDirection:"column",children:[Z.jsxDEV(N,{paddingX:2,paddingY:1,children:Z.jsxDEV(J,{bold:!0,color:"cyan",children:"Providers"},void 0,!1,void 0,this)},void 0,!1,void 0,this),_==="list"?Gq:Z.jsxDEV(e,{provider:B||void 0,onCancel:m,onSave:T},void 0,!1,void 0,this),V&&Z.jsxDEV(N,{paddingX:2,paddingY:0,children:Z.jsxDEV(J,{color:"green",children:V},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},qq=Wq;var h=S(f(),1),Xq=({onClose:O,initialTab:F="model"})=>{let[X,_]=zq.useState(F);return x((W,B)=>{if(B.leftArrow&&B.alt)_("model");else if(B.rightArrow&&B.alt)_("provider");else if(B.escape)O()},{isActive:!0}),h.jsxDEV(N,{flexDirection:"column",width:"100%",borderStyle:"single",borderDimColor:!0,children:[h.jsxDEV(N,{flexDirection:"column",paddingX:0,paddingY:0,children:[X==="model"&&h.jsxDEV(r,{onClose:O},void 0,!1,void 0,this),X==="provider"&&h.jsxDEV(qq,{onClose:O},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h.jsxDEV(N,{flexDirection:"row",gap:2,paddingX:2,paddingY:1,borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",borderColor:"gray",children:[h.jsxDEV(J,{bold:X==="model",color:X==="model"?"cyan":"gray",children:"\uD83E\uDD16 Model"},void 0,!1,void 0,this),h.jsxDEV(J,{bold:X==="provider",color:X==="provider"?"cyan":"gray",children:"\uD83D\uDD0C Provider"},void 0,!1,void 0,this),h.jsxDEV(c,{},void 0,!1,void 0,this),h.jsxDEV(J,{dimColor:!0,children:"Alt+ < >"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},jq=Xq;export{jq as default};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import{Ek as t}from"./chunk-nk62q95g.js";import{tl as e}from"./chunk-tjg2e8v3.js";var s=e.object({content:e.string().min(1),status:e.enum(["pending","in_progress","completed"]),id:e.string()}),a=e.object({todos:e.array(s).describe("The updated todo list")}),n=t(async()=>{return"todo saved successfully"},{name:"todo_write",description:`Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
2
|
+
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
3
|
+
## When to Use This Tool
|
|
4
|
+
Use this tool proactively in these scenarios:
|
|
5
|
+
|
|
6
|
+
1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
|
|
7
|
+
2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
|
|
8
|
+
3. User explicitly requests todo list - When the user directly asks you to use the todo list
|
|
9
|
+
4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
10
|
+
5. After receiving new instructions - Immediately capture user requirements as todos
|
|
11
|
+
6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
|
|
12
|
+
7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
|
|
13
|
+
|
|
14
|
+
## When NOT to Use This Tool
|
|
15
|
+
|
|
16
|
+
Skip using this tool when:
|
|
17
|
+
1. There is only a single, straightforward task
|
|
18
|
+
2. The task is trivial and tracking it provides no organizational benefit
|
|
19
|
+
3. The task can be completed in less than 3 trivial steps
|
|
20
|
+
4. The task is purely conversational or informational
|
|
21
|
+
|
|
22
|
+
NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
|
|
23
|
+
|
|
24
|
+
## Examples of When to Use the Todo List
|
|
25
|
+
|
|
26
|
+
<example>
|
|
27
|
+
User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
|
|
28
|
+
Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
|
|
29
|
+
*Creates todo list with the following items:*
|
|
30
|
+
1. Create dark mode toggle component in Settings page
|
|
31
|
+
2. Add dark mode state management (context/store)
|
|
32
|
+
3. Implement CSS-in-JS styles for dark theme
|
|
33
|
+
4. Update existing components to support theme switching
|
|
34
|
+
5. Run tests and build process, addressing any failures or errors that occur
|
|
35
|
+
*Begins working on the first task*
|
|
36
|
+
|
|
37
|
+
<reasoning>
|
|
38
|
+
The assistant used the todo list because:
|
|
39
|
+
1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
|
|
40
|
+
2. The user explicitly requested tests and build be run afterward
|
|
41
|
+
3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task
|
|
42
|
+
</reasoning>
|
|
43
|
+
</example>
|
|
44
|
+
|
|
45
|
+
<example>
|
|
46
|
+
User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
|
|
47
|
+
Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
|
|
48
|
+
*Uses grep or search tools to locate all instances of getCwd in the codebase*
|
|
49
|
+
Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
|
|
50
|
+
*Creates todo list with specific items for each file that needs updating*
|
|
51
|
+
|
|
52
|
+
<reasoning>
|
|
53
|
+
The assistant used the todo list because:
|
|
54
|
+
1. First, the assistant searched to understand the scope of the task
|
|
55
|
+
2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
|
|
56
|
+
3. The todo list helps ensure every instance is tracked and updated systematically
|
|
57
|
+
4. This approach prevents missing any occurrences and maintains code consistency
|
|
58
|
+
</reasoning>
|
|
59
|
+
</example>
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
<example>
|
|
63
|
+
User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
|
|
64
|
+
Assistant: I'll help implement these features. First, let's add all the features to the todo list.
|
|
65
|
+
*Creates a todo list breaking down each feature into specific tasks based on the project architecture*
|
|
66
|
+
Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
|
|
67
|
+
|
|
68
|
+
<reasoning>
|
|
69
|
+
The assistant used the todo list because:
|
|
70
|
+
1. The user provided multiple complex features to implement in a comma separated list
|
|
71
|
+
2. The todo list helps organize these large features into manageable tasks
|
|
72
|
+
3. This approach allows for tracking progress across the entire implementation
|
|
73
|
+
</reasoning>
|
|
74
|
+
</example>
|
|
75
|
+
|
|
76
|
+
<example>
|
|
77
|
+
User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
|
|
78
|
+
Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
|
|
79
|
+
*Reviews component structure, render patterns, state management, and data fetching*
|
|
80
|
+
Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
|
|
81
|
+
*Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
|
|
82
|
+
Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
|
|
83
|
+
|
|
84
|
+
<reasoning>
|
|
85
|
+
The assistant used the todo list because:
|
|
86
|
+
1. First, the assistant examined the codebase to identify specific performance issues
|
|
87
|
+
2. Based on this analysis, it identified multiple optimization opportunities
|
|
88
|
+
3. Performance optimization is a non-trivial task requiring multiple steps
|
|
89
|
+
4. The todo list helps methodically track improvements across different components
|
|
90
|
+
5. This systematic approach ensures all performance bottlenecks are addressed
|
|
91
|
+
</reasoning>
|
|
92
|
+
</example>
|
|
93
|
+
|
|
94
|
+
## Examples of When NOT to Use the Todo List
|
|
95
|
+
|
|
96
|
+
<example>
|
|
97
|
+
User: How do I print 'Hello World' in Python?
|
|
98
|
+
Assistant: In Python, you can print "Hello World" with this simple code:
|
|
99
|
+
|
|
100
|
+
python
|
|
101
|
+
print("Hello World")
|
|
102
|
+
|
|
103
|
+
This will output the text "Hello World" to the console when executed.</assistant>
|
|
104
|
+
|
|
105
|
+
<reasoning>
|
|
106
|
+
The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
|
|
107
|
+
</reasoning>
|
|
108
|
+
</example>
|
|
109
|
+
|
|
110
|
+
<example>
|
|
111
|
+
User: What does the git status command do?
|
|
112
|
+
Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
|
|
113
|
+
|
|
114
|
+
<reasoning>
|
|
115
|
+
The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
|
|
116
|
+
</reasoning>
|
|
117
|
+
</example>
|
|
118
|
+
|
|
119
|
+
<example>
|
|
120
|
+
User: Can you add a comment to the calculateTotal function to explain what it does?
|
|
121
|
+
Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
|
|
122
|
+
* Uses the Edit tool to add a comment to the calculateTotal function *
|
|
123
|
+
|
|
124
|
+
<reasoning>
|
|
125
|
+
The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
|
|
126
|
+
</reasoning>
|
|
127
|
+
</example>
|
|
128
|
+
|
|
129
|
+
<example>
|
|
130
|
+
User: Run npm install for me and tell me what happens.
|
|
131
|
+
Assistant: I'll run the npm install command for you.
|
|
132
|
+
|
|
133
|
+
*Executes: npm install*
|
|
134
|
+
|
|
135
|
+
The command completed successfully. Here's the output:
|
|
136
|
+
[Output of npm install command]
|
|
137
|
+
|
|
138
|
+
All dependencies have been installed according to your package.json file.
|
|
139
|
+
|
|
140
|
+
<reasoning>
|
|
141
|
+
The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
|
|
142
|
+
</reasoning>
|
|
143
|
+
</example>
|
|
144
|
+
|
|
145
|
+
## Task States and Management
|
|
146
|
+
|
|
147
|
+
1. **Task States**: Use these states to track progress:
|
|
148
|
+
- pending: Task not yet started
|
|
149
|
+
- in_progress: Currently working on (limit to ONE task at a time)
|
|
150
|
+
- completed: Task finished successfully
|
|
151
|
+
|
|
152
|
+
2. **Task Management**:
|
|
153
|
+
- Update task status in real-time as you work
|
|
154
|
+
- Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
|
|
155
|
+
- Only have ONE task in_progress at any time
|
|
156
|
+
- Complete current tasks before starting new ones
|
|
157
|
+
- Remove tasks that are no longer relevant from the list entirely
|
|
158
|
+
|
|
159
|
+
3. **Task Completion Requirements**:
|
|
160
|
+
- ONLY mark a task as completed when you have FULLY accomplished it
|
|
161
|
+
- If you encounter errors, blockers, or cannot finish, keep the task as in_progress
|
|
162
|
+
- When blocked, create a new task describing what needs to be resolved
|
|
163
|
+
- Never mark a task as completed if:
|
|
164
|
+
- Tests are failing
|
|
165
|
+
- Implementation is partial
|
|
166
|
+
- You encountered unresolved errors
|
|
167
|
+
- You couldn't find necessary files or dependencies
|
|
168
|
+
|
|
169
|
+
4. **Task Breakdown**:
|
|
170
|
+
- Create specific, actionable items
|
|
171
|
+
- Break complex tasks into smaller, manageable steps
|
|
172
|
+
- Use clear, descriptive task names
|
|
173
|
+
|
|
174
|
+
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
|
|
175
|
+
`,schema:a});
|
|
176
|
+
export{a as re,n as se};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{l as v,m as Z}from"./chunk-9rayxazs.js";import{Ae as G,Ie as M,Je as F,Ne as O,we as k,ze as Q}from"./chunk-c7kd2qrp.js";import"./chunk-vrnj0659.js";import"./chunk-fzh0v6r0.js";import"./chunk-nk62q95g.js";import"./chunk-nmzx5nmt.js";import"./chunk-q1cxrg0x.js";import"./chunk-tjg2e8v3.js";import"./chunk-nsw5168d.js";import"./chunk-hve2a279.js";import{Dl as Y}from"./chunk-y8qhrx11.js";var N=Y(k(),1);var y=Y(k(),1);var J=Y(F(),1),h=({pid:z,onClose:A})=>{let[H,R]=y.useState({stdout:"",stderr:""});M((W,X)=>{if(X.escape)A()}),y.useEffect(()=>{let W=()=>{let _=Z.getProcessOutput(z);if(_)R(_)};W();let X=setInterval(W,500);return()=>clearInterval(X)},[z]);let $=I(H.stdout,20),U=I(H.stderr,20);return J.jsxDEV(Q,{flexDirection:"column",padding:1,children:[J.jsxDEV(Q,{justifyContent:"space-between",marginBottom:1,children:[J.jsxDEV(G,{bold:!0,color:"cyan",children:["进程 [",z,"] 输出"]},void 0,!0,void 0,this),J.jsxDEV(G,{dimColor:!0,children:"按 ESC 返回"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.jsxDEV(Q,{flexDirection:"column",marginBottom:1,children:[J.jsxDEV(G,{color:"green",bold:!0,children:"STDOUT:"},void 0,!1,void 0,this),J.jsxDEV(Q,{borderStyle:"single",borderColor:"green",paddingX:1,children:J.jsxDEV(G,{children:$||"(空)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.jsxDEV(Q,{flexDirection:"column",children:[J.jsxDEV(G,{color:"red",bold:!0,children:"STDERR:"},void 0,!1,void 0,this),J.jsxDEV(Q,{borderStyle:"single",borderColor:"red",paddingX:1,children:J.jsxDEV(G,{children:U||"(空)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};function I(z,A){let H=z.split(`
|
|
2
|
+
`);if(H.length<=A)return z;return`...${H.slice(-A).join(`
|
|
3
|
+
`)}`}var g=h;var w=Y(F(),1),T=({onClose:z})=>{let[A,H]=N.useState([]),[R,$]=N.useState(null);N.useEffect(()=>{let q=async()=>{let b=await Z.getProcessList();H(b)};q();let K=setInterval(q,1000);return()=>clearInterval(K)},[]);let U=N.useCallback(async()=>{let q=await Z.getProcessList();H(q)},[]),W=N.useCallback((q,K,b)=>{let C=q.status==="running"?"\uD83D\uDFE2":"\uD83D\uDD34",B=f(q.duration);return w.jsxDEV(Q,{flexDirection:"column",children:[w.jsxDEV(Q,{children:[w.jsxDEV(G,{color:"cyan",children:[C," [",q.pid,"]"]},void 0,!0,void 0,this),w.jsxDEV(G,{children:[" ",P(q.command,40)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV(Q,{paddingLeft:3,children:[w.jsxDEV(G,{dimColor:!0,children:["⏱ ",B]},void 0,!0,void 0,this),w.jsxDEV(G,{dimColor:!0,children:[" | CPU: ",q.cpu.toFixed(1),"%"]},void 0,!0,void 0,this),w.jsxDEV(G,{dimColor:!0,children:[" | MEM: ",(q.memory/1024/1024).toFixed(1),"MB"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},[]),X=N.useCallback((q)=>{Z.killProcess(q.pid)},[]),_=N.useCallback((q)=>{$(q.pid)},[]),L=N.useCallback((q)=>{return w.jsxDEV(G,{dimColor:!0,children:["运行中: ",q.filter((K)=>K.status==="running").length," | 总计: ",q.length," | Enter 查看输出 | Backspace/Delete 关闭进程"]},void 0,!0,void 0,this)},[]),S=N.useMemo(()=>({id:"processes",title:"进程管理器",icon:"⚙️",dataSource:()=>Promise.resolve(A),searchable:!0,searchFields:["command"],renderItem:W,keyExtractor:(q)=>q.pid,onSelect:_,onDelete:X,itemHeight:2,statusInfo:L,keyMap:{r:()=>{U()}}}),[A,W,_,X,L,U]);return w.jsxDEV(w.Fragment,{children:R!==null?w.jsxDEV(v,{name:"ProcessOutputPanel",fallback:null,children:w.jsxDEV(g,{pid:R,onClose:()=>$(null)},void 0,!1,void 0,this)},void 0,!1,void 0,this):w.jsxDEV(O,{config:S,onClose:z},void 0,!1,void 0,this)},void 0,!1,void 0,this)};function f(z){let A=Math.floor(z/1000),H=Math.floor(A/60),R=Math.floor(H/60);if(R>0)return`${R}h ${H%60}m`;if(H>0)return`${H}m ${A%60}s`;return`${A}s`}function P(z,A){return z.length>A?z.slice(0,A-3)+"...":z}var n=T;export{n as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{U,W as Y,X as B,Y as W}from"./chunk-4wnmk2tj.js";import{Ae as O,Je as j,we as q,ze as T}from"./chunk-c7kd2qrp.js";import{if as k}from"./chunk-qxebn3jw.js";import{Dl as b}from"./chunk-y8qhrx11.js";var J=b(q(),1);function K({manager:G,enabled:N=!0}){return Y({queryKey:W.config.detail(),queryFn:async()=>{return await G.initialize(),await G.getConfig()},enabled:N,staleTime:300000,gcTime:600000})}function P({manager:G}){let N=U();return B({mutationFn:async(R)=>{return await G.updateConfig(R),await G.getConfig()},onSuccess:(R)=>{N.setQueryData(W.config.detail(),R),N.invalidateQueries({queryKey:W.providers.all}),N.invalidateQueries({queryKey:W.models.all})}})}var X=b(j(),1),H=null,Z=null;async function S(){if(!H){if(!Z)Z=k().then((G)=>{return H=G,Z=null,G});return Z}return Promise.resolve(H)}var I=J.createContext(void 0),E=({manager:G,get_allowed_models:N,children:R})=>{let{data:z,isLoading:V,error:x}=K({manager:G}),$=P({manager:G}),{data:F=[],isLoading:h,error:p}=Y({queryKey:W.models.available(),queryFn:N,staleTime:1800000,retry:1}),A=J.useMemo(()=>{return{provider_id:z?.provider_id||"openai",provider_type:z?.provider_type||"openai",model_id:z?.model_id||F[0]?.id||"default",mcp_config:z?.mcp_config,enable_thinking:z?.enable_thinking??!0,streaming:z?.streaming??!1,switch_command:z?.switch_command||"",cwd:process.cwd()}},[z?.provider_id,z?.provider_type,z?.model_id,z?.mcp_config,z?.enable_thinking,z?.streaming,z?.switch_command,z?.providers,F]),Q=J.useMemo(()=>{return z?.compact_mode??!1},[z?.compact_mode]),w=async()=>{await $.mutateAsync({compact_mode:!Q})},v=J.useMemo(()=>{return z?.show_detailed_info??!1},[z?.show_detailed_info]),L=async()=>{await $.mutateAsync({show_detailed_info:!v})},D=async(_)=>{await $.mutateAsync(_)};if(V||h)return X.jsxDEV(T,{padding:2,children:X.jsxDEV(O,{children:"Loading configuration..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);return X.jsxDEV(I.Provider,{value:{config:z||null,updateConfig:D,extraParams:A,AVAILABLE_MODELS:F,manager:G,compactMode:Q,toggleCompactMode:w,showDetailedInfo:v,toggleDetailedInfo:L},children:R},void 0,!1,void 0,this)},c=()=>{let G=J.useContext(I);if(G===void 0)throw Error("useSettings must be used within a SettingsProvider");return G},r=({get_allowed_models:G,children:N})=>{let[R,z]=J.useState(null);if(J.useEffect(()=>{S().then(z)},[]),!R)return X.jsxDEV(T,{padding:2,children:X.jsxDEV(O,{children:"Initializing configuration manager..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);return X.jsxDEV(E,{manager:R,get_allowed_models:G,children:N},void 0,!1,void 0,this)};
|
|
2
|
+
export{c as j,r as k};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{ul as We}from"./chunk-nsw5168d.js";import{Bl as Oh,Cl as Mh,vl as ou}from"./chunk-hve2a279.js";import{Dl as Vh,El as Ch,Fl as L,Il as _}from"./chunk-y8qhrx11.js";var wu=L((qu)=>{(function(){var u=function(e,h,r){var f,q;q="";while(e.length>0)if(f=e.match(h),f)q+=e.slice(0,f.index),q+=r(f),e=e.slice(f.index+f[0].length);else q+=e,e="";return q};qu.split=function(e){var h,r;if(e==null)e="";if(r=[],h="",u(e,/\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/,function(f){var q,w,E,M,O,V,F;if(M=f[0],F=f[1],V=f[2],q=f[3],w=f[4],E=f[5],O=f[6],E!=null)throw Error("Unmatched quote");if(h+=F||(V||q||w).replace(/\\(?=.)/,""),O!=null)return r.push(h),h=""}),h)r.push(h);return r},qu.escape=function(e){if(e==null)e="";if(e==null)return"''";return e.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g,"\\$1").replace(/\n/g,`'
|
|
2
|
+
'`)}}).call(qu)});var yu=L((Th,Eu)=>{var _u=_("fs"),k;function nu(){try{return _u.statSync("/.dockerenv"),!0}catch(u){return!1}}function tu(){try{return _u.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch(u){return!1}}Eu.exports=()=>{if(k===void 0)k=nu()||tu();return k}});var Mu=L((zh,b)=>{var su=_("os"),pu=_("fs"),Cu=yu(),Ou=()=>{if(process.platform!=="linux")return!1;if(su.release().toLowerCase().includes("microsoft")){if(Cu())return!1;return!0}try{return pu.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Cu():!1}catch(u){return!1}};if(process.env.__IS_WSL_TEST__)b.exports=Ou;else b.exports=Ou()});var K=L((Me,y)=>{var ue=wu(),g=_("child_process"),a=ou(),ee=Mu(),he=_("path"),fe=_("url"),X=_("os"),l=_("fs"),re=_("net");function ju(u){return JSON.parse(JSON.stringify(u))}Me.clone=ju;var qe=function(u){if(typeof u==="string")return u.replace(/(["$`\\])/g,"\\$1");else return u},we=function(u,e){return u.indexOf(e)!==-1},Lu={u:"urgency",urgency:"urgency",t:"expire-time",time:"expire-time",timeout:"expire-time",e:"expire-time",expire:"expire-time","expire-time":"expire-time",i:"icon",icon:"icon",c:"category",category:"category",subtitle:"category",h:"hint",hint:"hint",a:"app-name","app-name":"app-name"};Me.command=function(u,e,h){if(u=ue.escape(u),process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (command):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return g.exec(u+" "+e.join(" "),function(r,f,q){if(r)return h(r);h(q,f)})};Me.fileCommand=function(u,e,h){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (fileCommand):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return g.execFile(u,e,function(r,f,q){if(r)return h(r,f);h(q,f)})};Me.fileCommandJson=function(u,e,h){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (fileCommandJson):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return g.execFile(u,e,function(r,f,q){if(r)return h(r,f);if(!f)return h(r,{});try{let w=JSON.parse(f);h(!q?null:q,w)}catch(w){h(w,f)}})};Me.immediateFileCommand=function(u,e,h){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (notifier):"),console.info("[notifier path]",u);_e(u,function(r,f){if(!f)return h(Error("Notifier ("+u+") not found on system."));g.execFile(u,e),h()})};function _e(u,e){return l.stat(u,function(h,r){if(!h)return e(h,r.isFile());if(he.extname(u))return e(h,!1);return l.stat(u+".exe",function(f,q){if(f)return e(f,!1);e(f,q.isFile())})})}var m=function(u){if(u.appIcon)u.icon=u.appIcon,delete u.appIcon;return u},N=function(u){if(u.text)u.message=u.text,delete u.text;return u},Yu=function(u){if(u.i)u.icon=u.i,delete u.i;return u};Me.mapToNotifySend=function(u){if(u=m(u),u=N(u),u.timeout===!1)delete u.timeout;if(u.wait===!0)u["expire-time"]=5;for(let e in u){if(e==="message"||e==="title")continue;if(u.hasOwnProperty(e)&&Lu[e]!==e)u[Lu[e]]=u[e],delete u[e]}if(typeof u["expire-time"]>"u")u["expire-time"]=1e4;else if(typeof u["expire-time"]==="number")u["expire-time"]=u["expire-time"]*1000;return u};Me.mapToGrowl=function(u){if(u=m(u),u=Yu(u),u=N(u),u.icon&&!Buffer.isBuffer(u.icon))try{u.icon=l.readFileSync(u.icon)}catch(e){}return u};Me.mapToMac=function(u){if(u=Yu(u),u=N(u),u.icon)u.appIcon=u.icon,delete u.icon;if(u.sound===!0)u.sound="Bottle";if(u.sound===!1)delete u.sound;if(u.sound&&u.sound.indexOf("Notification.")===0)u.sound="Bottle";if(u.wait===!0){if(!u.timeout)u.timeout=5;delete u.wait}if(!u.wait&&!u.timeout)if(u.timeout===!1)delete u.timeout;else u.timeout=10;return u.json=!0,u};function i(u){return Object.prototype.toString.call(u)==="[object Array]"}Me.isArray=i;function Ee(){}Me.actionJackerDecorator=function(u,e,h,r){if(e=ju(e),h=h||Ee,typeof h!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof h);return function(f,q){let w=q,E={};if(w&&typeof w==="object")E=w,w=w.activationType;if(w){if(w=w.toLowerCase().trim(),w.match(/^activate|clicked$/))w="activate";if(w.match(/^timedout$/))w="timeout"}if(h.apply(u,[f,w,E]),!r||!w)return;let M=r(w);if(!M)return;u.emit(M,u,e,E)}};Me.constructArgumentList=function(u,e){let h=[];e=e||{};let r=e.initial||[],f=e.keyExtra||"",q=e.allowedArguments||[],w=e.noEscape!==void 0,E=e.allowedArguments!==void 0,M=!!e.explicitTrue,O=!!e.keepNewlines,V=e.wrapper===void 0?'"':e.wrapper,F=function U($){if(i($))return Ju($.map(U).join(","));if(!w)$=qe($);if(typeof $==="string"&&!O)$=Ju($);return V+$+V};r.forEach(function(U){h.push(F(U))});for(let U in u)if(u.hasOwnProperty(U)&&(!E||we(q,U)))if(M&&u[U]===!0)h.push("-"+f+U);else if(M&&u[U]===!1)continue;else h.push("-"+f+U,F(u[U]));return h};function Ju(u){let e=process.platform==="win32"?"\\r\\n":"\\n";return u.replace(/\r?\n/g,e)}var ye=["t","m","b","tb","p","id","s","silent","appID","pid","pipeName","close","install"],Ce="Notification.",Uu="Notification.Default";Me.mapToWin8=function(u){if(u=m(u),u=N(u),u.icon){if(/^file:\/+/.test(u.icon))u.p=new fe.URL(u.icon).pathname.replace(/^\/(\w:\/)/,"$1").replace(/\//g,"\\");else u.p=u.icon;delete u.icon}if(u.message)u.m=u.message.replace(/\x1b/g,""),delete u.message;if(u.title)u.t=u.title,delete u.title;if(u.appName)u.appID=u.appName,delete u.appName;if(typeof u.remove<"u")u.close=u.remove,delete u.remove;if(u.quiet||u.silent)u.silent=u.quiet||u.silent,delete u.quiet;if(typeof u.sound<"u")u.s=u.sound,delete u.sound;if(u.s===!1)u.silent=!0,delete u.s;if(u.s&&u.silent)delete u.s;if(u.s===!0)u.s=Uu;if(u.s&&u.s.indexOf(Ce)!==0)u.s=Uu;if(u.actions&&i(u.actions))u.b=u.actions.join(";"),delete u.actions;for(let e in u)if(u.hasOwnProperty(e)&&ye.indexOf(e)===-1)delete u[e];return u};Me.mapToNotifu=function(u){if(u=m(u),u=N(u),u.icon)u.i=u.icon,delete u.icon;if(u.message)u.m=u.message,delete u.message;if(u.title)u.p=u.title,delete u.title;if(u.time)u.d=u.time,delete u.time;if(u.q!==!1)u.q=!0;else delete u.q;if(u.quiet===!1)delete u.q,delete u.quiet;if(u.sound)delete u.q,delete u.sound;if(u.t)u.d=u.t,delete u.t;if(u.type)u.t=Oe(u.type),delete u.type;return u};Me.isMac=function(){return X.type()==="Darwin"};Me.isMountainLion=function(){return X.type()==="Darwin"&&a.satisfies(n(X.release()),">=12.0.0")};Me.isWin8=function(){return X.type()==="Windows_NT"&&a.satisfies(n(X.release()),">=6.2.9200")};Me.isWSL=function(){return ee};Me.isLessThanWin8=function(){return X.type()==="Windows_NT"&&a.satisfies(n(X.release()),"<6.2.9200")};function n(u){if(u.split(".").length===2)u+=".0";return u}function Oe(u){if(typeof u==="string"||u instanceof String){if(u.toLowerCase()==="info")return"info";if(u.toLowerCase()==="warn")return"warn";if(u.toLowerCase()==="error")return"error"}return"info"}Me.createNamedPipe=(u)=>{let e=Buffer.alloc(1024);return new Promise((h)=>{u.instance=re.createServer((r)=>{r.on("data",(f)=>{e.write(f.toString())}),r.on("end",()=>{u.instance.close()})}),u.instance.listen(u.namedPipe,()=>{h(e)})})}});var Hu=L((Bh,Zu)=>{var $u=_("os"),Te=We(),Q=K(),Ku=_("events").EventEmitter,ze=_("util"),v;Zu.exports=A;function A(u){if(u=Q.clone(u||{}),!(this instanceof A))return new A(u);this.options=u,Ku.call(this)}ze.inherits(A,Ku);function Be(){}function ce(u,e){if(u=Q.clone(u||{}),e=e||Be,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof e);if(typeof u==="string")u={title:"node-notifier",message:u};if(!u.message)return e(Error("Message is required.")),this;if($u.type()!=="Linux"&&!$u.type().match(/BSD$/))return e(Error("Only supported on Linux and *BSD systems")),this;if(v===!1)return e(Error("notify-send must be installed on the system.")),this;if(v||!!this.options.suppressOsdCheck)return Xu(u,e),this;try{v=!!Te.sync("notify-send"),Xu(u,e)}catch(h){return v=!1,e(h)}return this}Object.defineProperty(A.prototype,"notify",{get:function(){if(!this._notify)this._notify=ce.bind(this);return this._notify}});var De=["urgency","expire-time","icon","category","hint","app-name"];function Xu(u,e){u=Q.mapToNotifySend(u),u.title=u.title||"Node Notification:";let h=[u.title,u.message];delete u.title,delete u.message;let r=Q.constructArgumentList(u,{initial:h,keyExtra:"-",allowedArguments:De});Q.command("notify-send",r,e)}});var t=L((ch,Ru)=>{var ge=_("net");Ru.exports=function(u,e){if(typeof e>"u")e=u,u={};let h=u.port||23053,r=u.host||"localhost",f=ge.connect(h,r);f.setTimeout(100),f.once("connect",function(){f.end(),e(null,!0)}),f.once("error",function(){f.end(),e(null,!1)})}});var Nu=L((Dh,Fu)=>{var me=_("net"),ve=_("crypto"),Vu=_("util").format,xe=_("fs"),J=`\r
|
|
3
|
+
`;function Z(u,e){e=e||{},this.type=u,this.host=e.host||"localhost",this.port=e.port||23053,this.request="GNTP/1.0 "+u+" NONE"+J,this.resources=[],this.attempts=0,this.maxAttempts=5}Z.prototype.parseResp=function(u){var e={},h,r;return u=u.slice(0,u.indexOf(J+J)).split(J),h=u[0],r=u.slice(1),e.state=h.match(/-(OK|ERROR|CALLBACK)/)[0].slice(1),r.forEach(function(f){f=f.split(": "),e[f[0]]=f[1]}),e};Z.prototype.retry=function(){var u=this,e=arguments;setTimeout(function(){u.send.apply(u,e)},750)};Z.prototype.addResource=function(u){var e=ve.createHash("md5").update(u).digest("hex"),h="Identifier: "+e+J+"Length: "+u.length+J+J;return this.resources.push({header:h,file:u}),"x-growl-resource://"+e};Z.prototype.add=function(u,e){if(e===void 0)return;if(/-Icon/.test(u)&&!/^https?:\/\//.test(e)){if(/\.(png|gif|jpe?g)$/.test(e))e=this.addResource(xe.readFileSync(e));else if(e instanceof Buffer)e=this.addResource(e)}this.request+=u+": "+e+J};Z.prototype.newline=function(){this.request+=J};Z.prototype.send=function(u){var e=this,h=me.connect(this.port,this.host),r="";u=u||function(){},this.attempts+=1,h.on("connect",function(){h.write(e.request),e.resources.forEach(function(f){h.write(f.header),h.write(f.file),h.write(J+J)})}),h.on("data",function(f){if(r+=f.toString(),r.slice(r.length-4)!==J+J)return;if(r=e.parseResp(r),r.state==="ERROR"||r.state==="CALLBACK")h.end();else r=""}),h.on("end",function(){if(["200","401","402"].indexOf(r["Error-Code"])>=0)if(e.attempts<=e.maxAttempts)e.retry(u);else{var f='GNTP request to "%s:%d" failed with error code %s (%s)';u(Error(Vu(f,e.host,e.port,r["Error-Code"],r["Error-Description"])))}else u(void 0,r)}),h.on("error",function(){u(Error(Vu('Error while sending GNTP request to "%s:%d"',e.host,e.port))),h.destroy()})};Fu.exports=Z});var Su=L((gh,Au)=>{var Qu=Nu();function S(){this.appname="Growly",this.notifications=void 0,this.labels=void 0,this.count=0,this.registered=!1,this.host=void 0,this.port=void 0}S.prototype.getLabels=function(){return this.notifications.map(function(u){return u.label})};S.prototype.setHost=function(u,e){this.host=u,this.port=e};S.prototype.register=function(u,e,h,r){var f;if(typeof e==="object")h=e,e=void 0;if(h===void 0||!h.length)h=[{label:"default",dispname:"Default Notification",enabled:!0}];if(typeof arguments[arguments.length-1]==="function")r=arguments[arguments.length-1];else r=function(){};this.appname=u,this.notifications=h,this.labels=this.getLabels(),this.registered=!0,f=new Qu("REGISTER",{host:this.host,port:this.port}),f.add("Application-Name",u),f.add("Application-Icon",e),f.add("Notifications-Count",h.length),f.newline(),h.forEach(function(q){if(q.enabled===void 0)q.enabled=!0;f.add("Notification-Name",q.label),f.add("Notification-Display-Name",q.dispname),f.add("Notification-Enabled",q.enabled?"True":"False"),f.add("Notification-Icon",q.icon),f.newline()}),f.send(r)};S.prototype.notify=function(u,e,h){var r=this,f;if(!this.registered){this.register(this.appname,function(q){if(q)console.log(q);r.notify.call(r,u,e,h)});return}if(e=e||{},typeof e==="function")h=e,e={};f=new Qu("NOTIFY",{host:this.host,port:this.port}),f.add("Application-Name",this.appname),f.add("Notification-Name",e.label||this.labels[0]),f.add("Notification-ID",++this.count),f.add("Notification-Title",e.title),f.add("Notification-Text",u),f.add("Notification-Sticky",e.sticky?"True":"False"),f.add("Notification-Priority",e.priority),f.add("Notification-Icon",e.icon),f.add("Notification-Coalescing-ID",e.coalescingId||void 0),f.add("Notification-Callback-Context",h?"context":void 0),f.add("Notification-Callback-Context-Type",h?"string":void 0),f.add("Notification-Callback-Target",void 0),f.newline(),f.send(function(q,w){if(h&&q)h(q);else if(h&&w.state==="CALLBACK")h(void 0,w["Notification-Callback-Result"].toLowerCase())})};Au.exports=new S});var P=L((mh,Wu)=>{var Pe=t(),x=K(),G=Su(),Iu=_("events").EventEmitter,de=_("util");Wu.exports=I;var Gu;function I(u){if(u=x.clone(u||{}),!(this instanceof I))return new I(u);G.appname=u.name||"Node",this.options=u,Iu.call(this)}de.inherits(I,Iu);function ke(u,e){if(G.setHost(this.options.host,this.options.port),u=x.clone(u||{}),typeof u==="string")u={title:"node-notifier",message:u};if(e=x.actionJackerDecorator(this,u,e,function(h){if(h==="click")return"click";if(h==="timedout")return"timeout";return!1}),u=x.mapToGrowl(u),!u.message)return e(Error("Message is required.")),this;if(u.title=u.title||"Node Notification:",Gu||!!u.wait){let h=u.wait?e:be;if(G.notify(u.message,u,h),!u.wait)e();return this}return Pe(G,function(h,r){if(Gu=r,!r)return e(Error("Couldn't connect to growl (might be used as a fallback). Make sure it is running"));G.notify(u.message,u),e()}),this}Object.defineProperty(I.prototype,"notify",{get:function(){if(!this._notify)this._notify=ke.bind(this);return this._notify}});function be(){}});var cu=L((vh,Bu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",H=K(),le=P(),ae=_("path"),ie=ae.join(__dirname,"../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier"),zu=_("events").EventEmitter,ne=_("util"),te="You need Mac OS X 10.8 or above to use NotificationCenter, or use Growl fallback with constructor option {withFallback: true}.";Bu.exports=W;function W(u){if(u=H.clone(u||{}),!(this instanceof W))return new W(u);this.options=u,zu.call(this)}ne.inherits(W,zu);var Tu=null;function se(){}function pe(u,e){let h,r=oe();if(u=H.clone(u||{}),Tu=r,typeof u==="string")u={title:"node-notifier",message:u};if(e=e||se,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let f=H.actionJackerDecorator(this,u,e,function(w){if(Tu!==r)return!1;if(w==="activate")return"click";if(w==="timeout")return"timeout";if(w==="replied")return"replied";return!1});if(u=H.mapToMac(u),!u.message&&!u.group&&!u.list&&!u.remove)return e(Error("Message, group, remove or list property is required.")),this;let q=H.constructArgumentList(u);if(H.isMountainLion())return H.fileCommandJson(this.options.customPath||ie,q,f),this;if(h||!!this.options.withFallback)return h=h||new le(this.options),h.notify(u,e);return e(Error(te)),this}Object.defineProperty(W.prototype,"notify",{get:function(){if(!this._notify)this._notify=pe.bind(this);return this._notify}});function oe(){return{_ref:"val"}}});var s=L((xh,vu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",uh=_("path"),eh=uh.resolve(__dirname,"../vendor/notifu/notifu"),hh=t(),Y=K(),fh=p(),Du=P(),rh=_("os"),mu=_("events").EventEmitter,qh=_("util"),d;vu.exports=T;function T(u){if(u=Y.clone(u||{}),!(this instanceof T))return new T(u);this.options=u,mu.call(this)}qh.inherits(T,mu);function wh(){}function _h(u,e){let h,r=this.options;if(u=Y.clone(u||{}),e=e||wh,typeof u==="string")u={title:"node-notifier",message:u};let f=Y.actionJackerDecorator(this,u,e,function(q){if(q==="activate")return"click";if(q==="timeout")return"timeout";return!1});if(!!this.options.withFallback&&Y.isWin8())return h=h||new fh(r),h.notify(u,e);if(!!this.options.withFallback&&(!Y.isLessThanWin8()||d===!0))return h=h||new Du(r),h.notify(u,e);if(!this.options.withFallback||d===!1)return gu(u,r,f),this;return hh(r,function(q,w){if(d=w,d)return h=h||new Du(r),h.notify(u,e);gu(u,r,f)}),this}Object.defineProperty(T.prototype,"notify",{get:function(){if(!this._notify)this._notify=_h.bind(this);return this._notify}});var Eh=["t","d","p","m","i","e","q","w","xp"];function gu(u,e,h){let r=rh.arch()==="x64";u=u||{},u=Y.mapToNotifu(u),u.p=u.p||"Node Notification:";let f=eh+(r?"64":"")+".exe",q=e.customPath||f;if(!u.m)return h(Error("Message is required.")),this;let w=Y.constructArgumentList(u,{wrapper:"",noEscape:!0,explicitTrue:!0,allowedArguments:Eh});if(u.wait)return Y.fileCommand(q,w,function(E,M){let O=yh(E.code);if(O==="error")return h(E,M);return h(null,O)});Y.immediateFileCommand(q,w,h)}function yh(u){switch(u){case 2:return"timeout";case 3:case 6:case 7:return"activate";case 4:return"close";default:return"error"}}});var p=L((Ph,Pu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",Lh=_("path"),Jh=Lh.resolve(__dirname,"../vendor/snoreToast/snoretoast"),j=K(),Uh=s(),jh=_("os"),{v4:Yh}=(Mh(),Ch(Oh)),xu=_("events").EventEmitter,$h=_("util"),o;Pu.exports=z;function z(u){if(u=j.clone(u||{}),!(this instanceof z))return new z(u);this.options=u,xu.call(this)}$h.inherits(z,xu);function Xh(){}function Kh(u){if(!u)return{};return u.split(";").reduce((e,h)=>{let r=h.split("=");if(r&&r.length===2)e[r[0]]=r[1];return e},{})}function Zh(){return`${j.isWSL()?"/tmp/":"\\\\.\\pipe\\"}notifierPipe-${Yh()}`}function Hh(u,e){u=j.clone(u||{}),e=e||Xh;let h=jh.arch()==="x64",r,f={namedPipe:Zh()};if(typeof u==="string")u={title:"node-notifier",message:u};if(typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let q=(E,M)=>{let O=Kh(r&&r.toString("utf16le"));if(O.action==="buttonClicked"&&O.button)O.activationType=O.button;else if(O.action)O.activationType=O.action;if(E&&E.code===-1)M(E,O);M(null,O),f.instance&&f.instance.close()},w=(E)=>q(E,j.actionJackerDecorator(this,u,e,(M)=>M==="activate"?"click":M||!1));if(u.title=u.title||"Node Notification:",typeof u.message>"u"&&typeof u.close>"u")return e(Error("Message or ID to close is required.")),this;if(!j.isWin8()&&!j.isWSL()&&!!this.options.withFallback)return o=o||new Uh(this.options),o.notify(u,e);return j.createNamedPipe(f).then((E)=>{r=E,u.pipeName=f.namedPipe;let M=u.customPath||this.options.customPath||Jh+"-x"+(h?"64":"86")+".exe";u=j.mapToWin8(u);let O=j.constructArgumentList(u,{explicitTrue:!0,wrapper:"",keepNewlines:!0,noEscape:!0});j.fileCommand(M,O,w)}),this}Object.defineProperty(z.prototype,"notify",{get:function(){if(!this._notify)this._notify=Hh.bind(this);return this._notify}})});var bu=L((dh,C)=>{var du=_("os"),ku=K(),B=Hu(),uu=cu(),c=p(),eu=P(),hu=s(),R={withFallback:!0},Rh=ku.isWSL()?"WSL":du.type();switch(Rh){case"Linux":C.exports=new B(R),C.exports.Notification=B;break;case"Darwin":C.exports=new uu(R),C.exports.Notification=uu;break;case"Windows_NT":if(ku.isLessThanWin8())C.exports=new hu(R),C.exports.Notification=hu;else C.exports=new c(R),C.exports.Notification=c;break;case"WSL":C.exports=new c(R),C.exports.Notification=c;break;default:if(du.type().match(/BSD$/))C.exports=new B(R),C.exports.Notification=B;else C.exports=new eu(R),C.exports.Notification=eu}C.exports.NotifySend=B;C.exports.NotificationCenter=uu;C.exports.WindowsToaster=c;C.exports.WindowsBalloon=hu;C.exports.Growl=eu});import ru from"node:path";import lu from"node:os";import D from"node:fs";function au(u){let e=u.replace(/^~/,lu.homedir()),h=ru.resolve(e),r=ru.dirname(h);if(!D.existsSync(r))D.mkdirSync(r,{recursive:!0});return h}function iu(u,e){if(!D.existsSync(u)){process.env.DATABASE_INIT="true";return}let h=process.env.SQLITE_MAX_SIZE_MB?parseInt(process.env.SQLITE_MAX_SIZE_MB,10)*1024*1024:void 0,r=e??h??314572800,q=D.statSync(u).size,w=q/1048576;if(q>r){let E=r/1048576;console.trace(`⚠️ Database file is large: ${w.toFixed(2)}MB (limit: ${E.toFixed(2)}MB)`),console.trace(` Path: ${u}`),console.trace(" Set SQLITE_MAX_SIZE_MB to adjust limit")}}function Ah(u){let e=au(u);return process.env.SQLITE_DATABASE_URI=e,iu(e),e}var fu=Vh(bu(),1);function kh(u){if(typeof u==="string")fu.default.notify({title:"Notification",message:u});else fu.default.notify({title:u.title||"Notification",message:u.message,icon:u.icon,sound:u.sound??!0})}var lh={path:process.cwd()};export{Ah as te,kh as ue,lh as ve};
|