alchemylab-opencode 2.0.0 → 2.0.1

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.
@@ -11,7 +11,7 @@ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) =
11
11
  import { createRequire as __alchemyCreateRequire } from 'node:module';
12
12
  const require = __alchemyCreateRequire(import.meta.url);
13
13
 
14
- import{D as Ye,s as yt,w as ze}from"./chunk-ZMHNE2MU.js";import{b as ut}from"./chunk-QRABYJKL.js";import{C as Ge,Ea as $e,Sa as Me,Va as te,Wa as Oe,Xa as qe,Ya as Be,oa as Le,ra as Ve,s as Ne,sa as mt,v as ae,va as U}from"./chunk-OMDJ6ZZ2.js";import{Ia as lt,K as at,L as dt,Ma as O,Na as ft,P as le,Qa as ve,U as Se,a as ee,b as rt,d as ot,h as Q,i as nt,qb as Z,r as it,s as st,t as Ee,ub as y,vb as _e,wb as Ae,xb as _,y as ct,zc as pt}from"./chunk-BM2C7NHL.js";import{a as m,d as ce}from"./chunk-RHIWAYN5.js";var et={};ce(et,{CreateFailedError:()=>Fe,CreateInput:()=>ir,Event:()=>Re,Info:()=>nr,ListFailedError:()=>Ue,NameGenerationFailedError:()=>Te,NotGitError:()=>ye,RemoveFailedError:()=>ne,RemoveInput:()=>sr,ResetFailedError:()=>N,ResetInput:()=>cr,Service:()=>ge,StartCommandFailedError:()=>Je,Worktree:()=>et,node:()=>fr});var me={};ce(me,{InstanceStore:()=>me,Service:()=>de,bootstrapNode:()=>vt,node:()=>Qt,use:()=>Xt});import{Context as Bt,Deferred as X,Duration as zt,Effect as d,Exit as Ce,Layer as Yt,Scope as Ht}from"effect";var fe={};ce(fe,{InstanceBootstrap:()=>fe,Service:()=>He});import{Context as Et}from"effect";var He=class extends Et.Service()("@opencode/InstanceBootstrap"){static{m(this,"Service")}};var oe={};ce(oe,{Event:()=>wt,Info:()=>Vt,NotFoundError:()=>Pe,Project:()=>oe,Service:()=>J,UpdateInput:()=>$t,UpdatePayload:()=>Mt,fromRow:()=>re,node:()=>Qe,use:()=>qt});import{and as Ut,eq as T,sql as Wt}from"drizzle-orm";var ue={};ce(ue,{Command:()=>ue,Default:()=>Ie,Event:()=>Ct,Info:()=>Rt,Service:()=>pe,hints:()=>je,node:()=>Ft});import jt from"path";import{Effect as be,Layer as Dt,Context as Pt,Schema as A}from"effect";var Xe=`Create or update \`AGENTS.md\` for this repository.
14
+ import{D as Ye,s as yt,w as ze}from"./chunk-4FEBIOI5.js";import{b as ut}from"./chunk-QRABYJKL.js";import{C as Ge,Ea as $e,Sa as Me,Va as te,Wa as Oe,Xa as qe,Ya as Be,oa as Le,ra as Ve,s as Ne,sa as mt,v as ae,va as U}from"./chunk-OMDJ6ZZ2.js";import{Ia as lt,K as at,L as dt,Ma as O,Na as ft,P as le,Qa as ve,U as Se,a as ee,b as rt,d as ot,h as Q,i as nt,qb as Z,r as it,s as st,t as Ee,ub as y,vb as _e,wb as Ae,xb as _,y as ct,zc as pt}from"./chunk-BM2C7NHL.js";import{a as m,d as ce}from"./chunk-RHIWAYN5.js";var et={};ce(et,{CreateFailedError:()=>Fe,CreateInput:()=>ir,Event:()=>Re,Info:()=>nr,ListFailedError:()=>Ue,NameGenerationFailedError:()=>Te,NotGitError:()=>ye,RemoveFailedError:()=>ne,RemoveInput:()=>sr,ResetFailedError:()=>N,ResetInput:()=>cr,Service:()=>ge,StartCommandFailedError:()=>Je,Worktree:()=>et,node:()=>fr});var me={};ce(me,{InstanceStore:()=>me,Service:()=>de,bootstrapNode:()=>vt,node:()=>Qt,use:()=>Xt});import{Context as Bt,Deferred as X,Duration as zt,Effect as d,Exit as Ce,Layer as Yt,Scope as Ht}from"effect";var fe={};ce(fe,{InstanceBootstrap:()=>fe,Service:()=>He});import{Context as Et}from"effect";var He=class extends Et.Service()("@opencode/InstanceBootstrap"){static{m(this,"Service")}};var oe={};ce(oe,{Event:()=>wt,Info:()=>Vt,NotFoundError:()=>Pe,Project:()=>oe,Service:()=>J,UpdateInput:()=>$t,UpdatePayload:()=>Mt,fromRow:()=>re,node:()=>Qe,use:()=>qt});import{and as Ut,eq as T,sql as Wt}from"drizzle-orm";var ue={};ce(ue,{Command:()=>ue,Default:()=>Ie,Event:()=>Ct,Info:()=>Rt,Service:()=>pe,hints:()=>je,node:()=>Ft});import jt from"path";import{Effect as be,Layer as Dt,Context as Pt,Schema as A}from"effect";var Xe=`Create or update \`AGENTS.md\` for this repository.
15
15
 
16
16
  The goal is a compact instruction file that helps future OpenCode sessions avoid mistakes and ramp up quickly. Every line should answer: "Would an agent likely miss this without help?" If not, leave it out.
17
17
 
@@ -11,7 +11,7 @@ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) =
11
11
  import { createRequire as __alchemyCreateRequire } from 'node:module';
12
12
  const require = __alchemyCreateRequire(import.meta.url);
13
13
 
14
- import{E as bt,G as kt,z as wt}from"./chunk-PLQOF3WF.js";import"./chunk-4K2RXRZL.js";import{N as yt}from"./chunk-Z5TLIUAI.js";import{B as ht,D as gt,u as Ye}from"./chunk-ZMHNE2MU.js";import"./chunk-QRABYJKL.js";import"./chunk-OMDJ6ZZ2.js";import"./chunk-BM2C7NHL.js";import{a as l,d as Xe}from"./chunk-RHIWAYN5.js";import{CallToolResultSchema as Cr}from"@modelcontextprotocol/sdk/types.js";import{Cause as Mn,Effect as M,Schema as Nn}from"effect";var Ie={};Xe(Ie,{Diagnostic:()=>En,DiagnosticKind:()=>An,Failure:()=>Cn,Input:()=>xr,Result:()=>Rr,Success:()=>Tn,execute:()=>Ar,make:()=>Er});import{Schema as S}from"effect";import{parse as cr}from"acorn";import{Cause as se,Effect as d,Exit as Ne,Fiber as kn,Semaphore as ur}from"effect";import{DiagnosticCategory as lr,ModuleKind as dr,ScriptTarget as fr,flattenDiagnosticMessageText as pr,transpileModule as mr}from"typescript";var ue={};Xe(ue,{ToolReference:()=>z,ToolRuntime:()=>ue,ToolRuntimeError:()=>j,assertValidTools:()=>Zn,catalog:()=>Wn,copyIn:()=>ne,copyOut:()=>ce,isBlockedMember:()=>F,make:()=>rr,prepare:()=>er,searchIndex:()=>Qn});import{Cause as $t,Effect as H,Schema as q}from"effect";import{Schema as Le}from"effect";var ae=class extends Le.TaggedErrorClass()("ToolError",{message:Le.String,cause:Le.optionalKey(Le.Defect())}){static{l(this,"ToolError")}},be=l((t,e)=>new ae({message:t,...e===void 0?{}:{cause:e}}),"toolError");import{JsonPointer as et,Schema as Re}from"effect";var Te=l(t=>Re.isSchema(t),"isEffectSchema"),St=l(t=>JSON.stringify(t)??"unknown","renderLiteral"),tt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Un=l(t=>tt.test(t)?t:JSON.stringify(t),"renderKey"),Dn=l(t=>t.type==="string"&&Array.isArray(t.enum)&&t.enum.length===1&&(t.enum[0]==="NaN"||t.enum[0]==="Infinity"||t.enum[0]==="-Infinity"),"effectNumberSentinel"),Qe=l(t=>{let e=t.filter(n=>n!=="unknown");return e.length===0?"unknown":e.length===1?e[0]??"unknown":e.map(n=>n.includes(" | ")?`(${n})`:n).join(" & ")},"intersection"),Ln=8,Ze=l((t,e,n=new Set,r=new Set)=>{if(r.has(t))return!1;let o=new Set([...r,t]);if(t.$ref!==void 0){let s=t.$ref.match(/^#\/(?:\$defs|definitions)\/([^/]+)$/)?.[1],a=s===void 0?void 0:et.unescapeToken(s);if(a===void 0||e[a]===void 0||n.has(a)||Ze(e[a],e,new Set([...n,a]),o))return!0}return[...t.anyOf??[],...t.oneOf??[],...t.allOf??[],...Object.values(t.properties??{}),...t.items===void 0?[]:[t.items],...typeof t.additionalProperties=="object"?[t.additionalProperties]:[]].some(s=>Ze(s,e,n,o))},"hasUnresolvedRef"),qn=l(t=>{let e=[];if(t.deprecated===!0&&e.push("@deprecated"),t.default!==void 0)try{let n=JSON.stringify(t.default);n!==void 0&&e.push(`@default ${n}`)}catch{}return typeof t.format=="string"&&e.push(`@format ${t.format}`),typeof t.minItems=="number"&&e.push(`@minItems ${t.minItems}`),typeof t.maxItems=="number"&&e.push(`@maxItems ${t.maxItems}`),e},"docTags"),Fn=l((t,e,n)=>{let r=[...t===void 0?[]:t.split(`
14
+ import{E as bt,G as kt,z as wt}from"./chunk-MKEMZFJI.js";import"./chunk-4K2RXRZL.js";import{N as yt}from"./chunk-Z5TLIUAI.js";import{B as ht,D as gt,u as Ye}from"./chunk-4FEBIOI5.js";import"./chunk-QRABYJKL.js";import"./chunk-OMDJ6ZZ2.js";import"./chunk-BM2C7NHL.js";import{a as l,d as Xe}from"./chunk-RHIWAYN5.js";import{CallToolResultSchema as Cr}from"@modelcontextprotocol/sdk/types.js";import{Cause as Mn,Effect as M,Schema as Nn}from"effect";var Ie={};Xe(Ie,{Diagnostic:()=>En,DiagnosticKind:()=>An,Failure:()=>Cn,Input:()=>xr,Result:()=>Rr,Success:()=>Tn,execute:()=>Ar,make:()=>Er});import{Schema as S}from"effect";import{parse as cr}from"acorn";import{Cause as se,Effect as d,Exit as Ne,Fiber as kn,Semaphore as ur}from"effect";import{DiagnosticCategory as lr,ModuleKind as dr,ScriptTarget as fr,flattenDiagnosticMessageText as pr,transpileModule as mr}from"typescript";var ue={};Xe(ue,{ToolReference:()=>z,ToolRuntime:()=>ue,ToolRuntimeError:()=>j,assertValidTools:()=>Zn,catalog:()=>Wn,copyIn:()=>ne,copyOut:()=>ce,isBlockedMember:()=>F,make:()=>rr,prepare:()=>er,searchIndex:()=>Qn});import{Cause as $t,Effect as H,Schema as q}from"effect";import{Schema as Le}from"effect";var ae=class extends Le.TaggedErrorClass()("ToolError",{message:Le.String,cause:Le.optionalKey(Le.Defect())}){static{l(this,"ToolError")}},be=l((t,e)=>new ae({message:t,...e===void 0?{}:{cause:e}}),"toolError");import{JsonPointer as et,Schema as Re}from"effect";var Te=l(t=>Re.isSchema(t),"isEffectSchema"),St=l(t=>JSON.stringify(t)??"unknown","renderLiteral"),tt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Un=l(t=>tt.test(t)?t:JSON.stringify(t),"renderKey"),Dn=l(t=>t.type==="string"&&Array.isArray(t.enum)&&t.enum.length===1&&(t.enum[0]==="NaN"||t.enum[0]==="Infinity"||t.enum[0]==="-Infinity"),"effectNumberSentinel"),Qe=l(t=>{let e=t.filter(n=>n!=="unknown");return e.length===0?"unknown":e.length===1?e[0]??"unknown":e.map(n=>n.includes(" | ")?`(${n})`:n).join(" & ")},"intersection"),Ln=8,Ze=l((t,e,n=new Set,r=new Set)=>{if(r.has(t))return!1;let o=new Set([...r,t]);if(t.$ref!==void 0){let s=t.$ref.match(/^#\/(?:\$defs|definitions)\/([^/]+)$/)?.[1],a=s===void 0?void 0:et.unescapeToken(s);if(a===void 0||e[a]===void 0||n.has(a)||Ze(e[a],e,new Set([...n,a]),o))return!0}return[...t.anyOf??[],...t.oneOf??[],...t.allOf??[],...Object.values(t.properties??{}),...t.items===void 0?[]:[t.items],...typeof t.additionalProperties=="object"?[t.additionalProperties]:[]].some(s=>Ze(s,e,n,o))},"hasUnresolvedRef"),qn=l(t=>{let e=[];if(t.deprecated===!0&&e.push("@deprecated"),t.default!==void 0)try{let n=JSON.stringify(t.default);n!==void 0&&e.push(`@default ${n}`)}catch{}return typeof t.format=="string"&&e.push(`@format ${t.format}`),typeof t.minItems=="number"&&e.push(`@minItems ${t.minItems}`),typeof t.maxItems=="number"&&e.push(`@maxItems ${t.maxItems}`),e},"docTags"),Fn=l((t,e,n)=>{let r=[...t===void 0?[]:t.split(`
15
15
  `),...e].map(s=>s.replaceAll("*/","* /").replace(/\s+$/,""));for(;r.length>0&&r[0].trim()==="";)r.shift();for(;r.length>0&&r[r.length-1].trim()==="";)r.pop();if(r.length===0)return"";if(r.length===1)return`${n}/** ${r[0]} */
16
16
  `;let o=r.map(s=>`${n} *${s===""?"":` ${s}`}`).join(`
17
17
  `);return`${n}/**
package/dist/run.js CHANGED
@@ -11,4 +11,4 @@ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) =
11
11
  import { createRequire as __alchemyCreateRequire } from 'node:module';
12
12
  const require = __alchemyCreateRequire(import.meta.url);
13
13
 
14
- import{a as l}from"./chunk-RHIWAYN5.js";import{homedir as w}from"node:os";import{join as h}from"node:path";process.env.OPENCODE_DATA_DIR=process.env.OPENCODE_DATA_DIR||h(w(),".alchemy_lab","opencode");function E(e){let t={message:[]},m=new Set(["attach","session","agent","model","variant","dir","title","command","password"]),u={s:"session",m:"model",c:"continue"};for(let r=0;r<e.length;r++){let n=e[r];if(n==="--"){t.message.push(...e.slice(r+1));break}let i=n.startsWith("--")?n.slice(2):n.startsWith("-")&&n.length===2?u[n[1]]:void 0;if(!i){t.message.push(n);continue}let[a,p]=i.includes("=")?[i.slice(0,i.indexOf("=")),i.slice(i.indexOf("=")+1)]:[i,void 0];if(a==="continue"){t.continue=!0;continue}if(!m.has(a))continue;let o=p??e[++r];t[a]=o}return t.message[0]==="run"&&t.message.shift(),t}l(E,"parseArgs");var s=E(process.argv.slice(2));async function O(){let e=s.attach,t;if(!e){let{Server:o}=await import("./server-TI57TGPO.js"),c=await o.listen({port:0,hostname:"127.0.0.1"});e=c.url.toString().replace(/\/$/,""),t=l(()=>c.stop(!0),"stop")}e=e.replace(/\/$/,"");let m={"content-type":"application/json"},u=s.password??process.env.OPENCODE_SERVER_PASSWORD;if(u){let o=process.env.OPENCODE_SERVER_USERNAME??"opencode";m.authorization=`Basic ${Buffer.from(`${o}:${u}`).toString("base64")}`}let r=s.dir?`?directory=${encodeURIComponent(s.dir)}`:"",n=l(async(o,c,d)=>{let g=await fetch(`${e}${c}${r}`,{method:o,headers:m,body:d===void 0?void 0:JSON.stringify(d)}),f=await g.text();if(!g.ok)throw new Error(`${o} ${c}: HTTP ${g.status} ${f.slice(0,500)}`);return f?JSON.parse(f):void 0},"call"),i=await(async()=>{if(s.session)return s.session;if(s.continue){let d=(await n("GET","/session")).find(g=>!g.parentID);if(d)return d.id}return(await n("POST","/session",s.title?{title:s.title}:{})).id})(),a=s.message.join(" "),p=s.model?{providerID:s.model.split("/")[0],modelID:s.model.split("/").slice(1).join("/")}:void 0;s.command?await n("POST",`/session/${i}/command`,{agent:s.agent,model:s.model,command:s.command,arguments:a,variant:s.variant}):await n("POST",`/session/${i}/message`,{agent:s.agent,model:p,variant:s.variant,parts:[{type:"text",text:a}]}),t&&await t()}l(O,"main");O().then(()=>process.exit(0),e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
14
+ import{a as l}from"./chunk-RHIWAYN5.js";import{homedir as w}from"node:os";import{join as h}from"node:path";process.env.OPENCODE_DATA_DIR=process.env.OPENCODE_DATA_DIR||h(w(),".alchemy_lab","opencode");function E(e){let t={message:[]},m=new Set(["attach","session","agent","model","variant","dir","title","command","password"]),u={s:"session",m:"model",c:"continue"};for(let r=0;r<e.length;r++){let n=e[r];if(n==="--"){t.message.push(...e.slice(r+1));break}let i=n.startsWith("--")?n.slice(2):n.startsWith("-")&&n.length===2?u[n[1]]:void 0;if(!i){t.message.push(n);continue}let[a,p]=i.includes("=")?[i.slice(0,i.indexOf("=")),i.slice(i.indexOf("=")+1)]:[i,void 0];if(a==="continue"){t.continue=!0;continue}if(!m.has(a))continue;let o=p??e[++r];t[a]=o}return t.message[0]==="run"&&t.message.shift(),t}l(E,"parseArgs");var s=E(process.argv.slice(2));async function O(){let e=s.attach,t;if(!e){let{Server:o}=await import("./server-BFUQR7MX.js"),c=await o.listen({port:0,hostname:"127.0.0.1"});e=c.url.toString().replace(/\/$/,""),t=l(()=>c.stop(!0),"stop")}e=e.replace(/\/$/,"");let m={"content-type":"application/json"},u=s.password??process.env.OPENCODE_SERVER_PASSWORD;if(u){let o=process.env.OPENCODE_SERVER_USERNAME??"opencode";m.authorization=`Basic ${Buffer.from(`${o}:${u}`).toString("base64")}`}let r=s.dir?`?directory=${encodeURIComponent(s.dir)}`:"",n=l(async(o,c,d)=>{let g=await fetch(`${e}${c}${r}`,{method:o,headers:m,body:d===void 0?void 0:JSON.stringify(d)}),f=await g.text();if(!g.ok)throw new Error(`${o} ${c}: HTTP ${g.status} ${f.slice(0,500)}`);return f?JSON.parse(f):void 0},"call"),i=await(async()=>{if(s.session)return s.session;if(s.continue){let d=(await n("GET","/session")).find(g=>!g.parentID);if(d)return d.id}return(await n("POST","/session",s.title?{title:s.title}:{})).id})(),a=s.message.join(" "),p=s.model?{providerID:s.model.split("/")[0],modelID:s.model.split("/").slice(1).join("/")}:void 0;s.command?await n("POST",`/session/${i}/command`,{agent:s.agent,model:s.model,command:s.command,arguments:a,variant:s.variant}):await n("POST",`/session/${i}/message`,{agent:s.agent,model:p,variant:s.variant,parts:[{type:"text",text:a}]}),t&&await t()}l(O,"main");O().then(()=>process.exit(0),e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
package/dist/serve.js CHANGED
@@ -11,4 +11,4 @@ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) =
11
11
  import { createRequire as __alchemyCreateRequire } from 'node:module';
12
12
  const require = __alchemyCreateRequire(import.meta.url);
13
13
 
14
- import{a as t}from"./chunk-RHIWAYN5.js";import{Agent as p,setGlobalDispatcher as l}from"undici";import{homedir as d}from"node:os";import{join as n}from"node:path";import{existsSync as a}from"node:fs";l(new p({connect:{keepAlive:!0,keepAliveInitialDelay:5e3},headersTimeout:0,bodyTimeout:0}));function r(e,o){let s=process.argv.indexOf(`--${e}`);return s!==-1&&process.argv[s+1]?process.argv[s+1]:o}t(r,"arg");var m=n(d(),".alchemy_lab","opencode"),c=r("data-dir",m);process.env.OPENCODE_DATA_DIR=c;!process.env.OPENCODE_DB&&a(n(c,"opencode-local.db"))&&!a(n(c,"opencode.db"))&&(process.env.OPENCODE_DB="opencode-local.db");var i=r("log-level","INFO").toUpperCase();process.env.OPENCODE_LOG_LEVEL=["DEBUG","INFO","WARN","ERROR"].includes(i)?i:"INFO";process.env.OPENCODE_PRINT_LOGS??="1";var{Server:O}=await import("./server-TI57TGPO.js"),v=parseInt(r("port","4096"),10),D=r("hostname","127.0.0.1");try{let e=await O.listen({port:v,hostname:D});console.log(`opencode server listening on http://${e.hostname}:${e.port}`);let o=t(async()=>{await e.stop(!0),process.exit(0)},"shutdown");process.on("SIGINT",o),process.on("SIGTERM",o),await new Promise(()=>{})}catch(e){console.error("Failed to start server:",e),process.exit(1)}
14
+ import{a as t}from"./chunk-RHIWAYN5.js";import{Agent as p,setGlobalDispatcher as l}from"undici";import{homedir as d}from"node:os";import{join as n}from"node:path";import{existsSync as a}from"node:fs";l(new p({connect:{keepAlive:!0,keepAliveInitialDelay:5e3},headersTimeout:0,bodyTimeout:0}));function r(e,o){let s=process.argv.indexOf(`--${e}`);return s!==-1&&process.argv[s+1]?process.argv[s+1]:o}t(r,"arg");var m=n(d(),".alchemy_lab","opencode"),c=r("data-dir",m);process.env.OPENCODE_DATA_DIR=c;!process.env.OPENCODE_DB&&a(n(c,"opencode-local.db"))&&!a(n(c,"opencode.db"))&&(process.env.OPENCODE_DB="opencode-local.db");var i=r("log-level","INFO").toUpperCase();process.env.OPENCODE_LOG_LEVEL=["DEBUG","INFO","WARN","ERROR"].includes(i)?i:"INFO";process.env.OPENCODE_PRINT_LOGS??="1";var{Server:O}=await import("./server-BFUQR7MX.js"),v=parseInt(r("port","4096"),10),D=r("hostname","127.0.0.1");try{let e=await O.listen({port:v,hostname:D});console.log(`opencode server listening on http://${e.hostname}:${e.port}`);let o=t(async()=>{await e.stop(!0),process.exit(0)},"shutdown");process.on("SIGINT",o),process.on("SIGTERM",o),await new Promise(()=>{})}catch(e){console.error("Failed to start server:",e),process.exit(1)}