synara 0.1.2 → 0.1.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.
- package/dist/index.js +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
|
|
41
41
|
${u.bold("Usage:")}
|
|
42
42
|
synapse Start coding session in current directory
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
synara login Login with username/password
|
|
44
|
+
synara logout Remove stored credentials
|
|
45
45
|
|
|
46
46
|
${u.bold("Session commands:")}
|
|
47
47
|
/compact Compress conversation history
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
n Deny this operation
|
|
54
54
|
t Trust this tool type for the session
|
|
55
55
|
`),process.exit(0));let t=null,e=null,s=null;function r(){let f=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],d=0;process.stdout.write(u.gray(`
|
|
56
|
-
${f[0]} Thinking...`)),s=setInterval(()=>{d=(d+1)%f.length,process.stdout.write(`\r ${u.gray(f[d]+" Thinking...")}`)},80)}function n(){s&&(clearInterval(s),s=null,process.stdout.write("\r"+" ".repeat(30)+"\r"))}function i(){try{return k.readFileSync(di,"utf-8").trim()}catch{return null}}function o(){for(let f of["SYNAPSE.md","synapse.md"]){let d=J.join(process.cwd(),f);if(k.existsSync(d))return k.readFileSync(d,"utf-8")}}async function a(){Ys();let f=i();f||(Se("Not logged in. Run:
|
|
56
|
+
${f[0]} Thinking...`)),s=setInterval(()=>{d=(d+1)%f.length,process.stdout.write(`\r ${u.gray(f[d]+" Thinking...")}`)},80)}function n(){s&&(clearInterval(s),s=null,process.stdout.write("\r"+" ".repeat(30)+"\r"))}function i(){try{return k.readFileSync(di,"utf-8").trim()}catch{return null}}function o(){for(let f of["SYNAPSE.md","synapse.md"]){let d=J.join(process.cwd(),f);if(k.existsSync(d))return k.readFileSync(d,"utf-8")}}async function a(){Ys();let f=i();f||(Se("Not logged in. Run: synara login"),process.exit(1));let d=`${hi}/ws?token=${encodeURIComponent(f)}`,S=new Ts(d);t=S,S.on("open",()=>{_({type:"auth",token:f,project:{path:process.cwd(),synapseMd:o()}})}),S.on("message",async T=>{let y=JSON.parse(T.toString());switch(y.type){case"session_ready":w();break;case"thinking":zs(y.content);break;case"reasoning_token":break;case"reasoning_end":break;case"content_token":n(),process.stdout.write(y.content);break;case"content_end":process.stdout.write(`
|
|
57
57
|
`);break;case"turn_end":n(),m();break;case"assistant_message":n(),Hs(y.content),m();break;case"tool_request":n(),y.tool==="web_search"||y.tool==="web_fetch"?mt(y.tool,y.args):await c(y);break;case"tool_result_from_cloud":Ks(y.tool,y.success,y.output),r();break;case"session_save":n(),h(y),m();break;case"session_load":n(),p(y);break;case"session_list_request":n(),g(),m();break;case"error":n(),Se(y.message),m();break}}),S.on("close",()=>{console.log(u.gray(`
|
|
58
58
|
Connection closed.`)),process.exit(0)}),S.on("error",T=>{Se(`Connection failed: ${T.message}`),process.exit(1)})}async function c(f){let d=f.description||`${f.tool}`;mt(f.tool,f.args,d);let S=await Ds(f.tool,f.args,d);if(S==="y"||S==="t"){let X=Date.now(),G=await _t(f.tool,f.args);gt(f.tool,G.success,G.output,Date.now()-X),_({type:"tool_result",call_id:f.call_id,...G}),r();return}if(f.tool==="write_file"&&f.args.content)Js(f.args.path,f.args.content);else if(f.tool==="edit_file"&&f.args.old_str&&f.args.new_str){let X=js(f.args.path);Xs(f.args.old_str,f.args.new_str,f.args.path,X)}if(e?.close(),e=null,await Ws(f.tool,f.args,d)==="n"){_({type:"tool_result",call_id:f.call_id,success:!1,output:"User denied"}),r();return}let y=Date.now(),B=await _t(f.tool,f.args);gt(f.tool,B.success,B.output,Date.now()-y),_({type:"tool_result",call_id:f.call_id,...B}),r()}let l=J.join(process.cwd(),".synapse","sessions");function h(f){k.mkdirSync(l,{recursive:!0});let d=f.name||new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),S=J.join(l,`${d}.json`);if(k.existsSync(S)&&!f.force){Se(`Session '${d}' already exists. Use /save ${d} --force to overwrite.`);return}let T={name:d,saved_at:new Date().toISOString(),messages:f.messages,meta:f.meta};k.writeFileSync(S,JSON.stringify(T,null,2),"utf-8"),console.log(u.blue(` \u2713 Session saved: ${d}`)+u.gray(` (${f.messages.length} messages, ${(Buffer.byteLength(JSON.stringify(T))/1024).toFixed(1)} KB)`))}function p(f){let d=f.name;if(!d){g(),_({type:"session_data",messages:null,error:"No session name provided. Use /sessions to list, then /load <name>."}),m();return}let S=J.join(l,`${d}.json`);if(!k.existsSync(S)){_({type:"session_data",messages:null,error:`Session '${d}' not found.`}),m();return}try{let T=JSON.parse(k.readFileSync(S,"utf-8"));_({type:"session_data",name:d,messages:T.messages,meta:T.meta||{}}),r()}catch(T){_({type:"session_data",messages:null,error:`Failed to read session: ${T}`}),m()}}function g(){if(!k.existsSync(l)){console.log(u.gray(" No saved sessions."));return}let f=k.readdirSync(l).filter(d=>d.endsWith(".json")).sort();if(f.length===0){console.log(u.gray(" No saved sessions."));return}console.log(u.white(`
|
|
59
59
|
Saved sessions (${f.length}):`));for(let d of f)try{let S=JSON.parse(k.readFileSync(J.join(l,d),"utf-8")),T=d.replace(".json",""),y=S.messages?.length||0,B=S.saved_at?new Date(S.saved_at).toLocaleString():"?";console.log(u.cyan(` ${T}`)+u.gray(` \u2014 ${y} messages, saved ${B}`))}catch{console.log(u.cyan(` ${d.replace(".json","")}`)+u.gray(" \u2014 (unreadable)"))}console.log("")}function w(){m()}function m(){e&&(e.close(),e=null),e=nr.createInterface({input:process.stdin,output:process.stdout,terminal:!0}),e.question(u.cyan(`
|
package/package.json
CHANGED