alchemylab 3.0.6 → 3.0.8

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/994.js CHANGED
@@ -1,139 +1,360 @@
1
- "use strict"
2
- exports.ids=[994],exports.modules={75994(t,exports,e){function r(t){if(!t.hasCode&&t.branch===t.home)return`${h.default.yellow("alchemy")}${h.default.gray(">")} `
3
- const e=t.status&&t.branch!==t.home?` ${h.default.gray("|")} ${t.status}`:""
4
- return`${h.default.cyan("[")}${h.default.green(t.branch)}${e}${h.default.cyan("]")} ${h.default.yellow("alchemy")}${h.default.gray(">")} `}function s(t){return t?'Type "help" for available commands. Commands run in the current branch directory.':'Type "help" for available commands.'}var a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}}
5
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.InteractiveShell=void 0,exports.shellPrompt=r,exports.briefHelpLine=s
6
- const i=a(e(23785)),o=e(35317),n=e(83807),l=a(e(16928)),c=a(e(79896)),h=a(e(96895)),u=e(14139),d=e(7202),f=e(44192),p=e(41152),g=e(76634),m=e(79414),y=e(52232)
7
- exports.InteractiveShell=class{constructor(t){if(this.home="main",this.currentBranch="main",this.currentStatus=null,this.history=[],this.statusCache={map:new Map,ts:0},this.pathExecutableCache=null,this.projectPath=t.projectPath,this.currentSymlink=l.default.join(t.projectPath,u.ALCHEMY_DIR_NAME,"current"),this.currentDir=t.projectPath,this.logger=t.logger,this.historyFile=l.default.join(t.projectPath,u.ALCHEMY_DIR_NAME,"shell-history.txt"),this.projectId=t.projectId,this.remoteServerUrl=t.remoteServerUrl,this.authToken=t.authToken,this.hasCode=!1!==t.hasCode,t.remoteServerUrl){const e=(0,p.createMetricsCollector)(!1)
8
- this.apiClient=new f.BaseApiClient(t.remoteServerUrl,t.logger,e,t.authToken)}}async publishPr(t,e){if(!t||!/^req\d{6}$/.test(t))return void console.log(h.default.red("Usage: publish req###### [base-branch]"))
1
+ exports.ids=[994],exports.modules={94083(module,e,t){"use strict"
2
+ module=t.nmd(module)
3
+ const r=(e,t)=>(...r)=>`\x1b[${e(...r)+t}m`,n=(e,t)=>(...r)=>{const n=e(...r)
4
+ return`\x1b[${38+t};5;${n}m`},s=(e,t)=>(...r)=>{const n=e(...r)
5
+ return`\x1b[${38+t};2;${n[0]};${n[1]};${n[2]}m`},o=e=>e,a=(e,t,r)=>[e,t,r],l=(e,t,r)=>{Object.defineProperty(e,t,{get:()=>{const n=r()
6
+ return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})}
7
+ let i
8
+ const c=(e,r,n,s)=>{void 0===i&&(i=t(10734))
9
+ const o=s?10:0,a={}
10
+ for(const[t,s]of Object.entries(i)){const l="ansi16"===t?"ansi":t
11
+ t===r?a[l]=e(n,o):"object"==typeof s&&(a[l]=e(s[r],o))}return a}
12
+ Object.defineProperty(module,"exports",{enumerable:!0,get:function(){const e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}}
13
+ t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright
14
+ for(const[r,n]of Object.entries(t)){for(const[r,s]of Object.entries(n))t[r]={open:`\x1b[${s[0]}m`,close:`\x1b[${s[1]}m`},n[r]=t[r],e.set(s[0],s[1])
15
+ Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1b[39m",t.bgColor.close="\x1b[49m",l(t.color,"ansi",()=>c(r,"ansi16",o,!1)),l(t.color,"ansi256",()=>c(n,"ansi256",o,!1)),l(t.color,"ansi16m",()=>c(s,"rgb",a,!1)),l(t.bgColor,"ansi",()=>c(r,"ansi16",o,!0)),l(t.bgColor,"ansi256",()=>c(n,"ansi256",o,!0)),l(t.bgColor,"ansi16m",()=>c(s,"rgb",a,!0)),t}})},55248(module,e,t){"use strict"
16
+ function r(e){return d(e)}const n=t(94083),{stdout:s,stderr:o}=t(27687),{stringReplaceAll:a,stringEncaseCRLFWithFirstIndex:l}=t(4058),{isArray:i}=Array,c=["ansi","ansi","ansi256","ansi16m"],h=Object.create(null)
17
+ class u{constructor(e){return d(e)}}const d=e=>{const t={}
18
+ return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3")
19
+ const r=s?s.level:0
20
+ e.level=void 0===t.level?r:t.level})(t,e),t.template=(...e)=>w(t.template,...e),Object.setPrototypeOf(t,r.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=u,t.template}
21
+ for(const[e,t]of Object.entries(n))h[e]={get(){const r=m(this,p(t.open,t.close,this._styler),this._isEmpty)
22
+ return Object.defineProperty(this,e,{value:r}),r}}
23
+ h.visible={get(){const e=m(this,this._styler,!0)
24
+ return Object.defineProperty(this,"visible",{value:e}),e}}
25
+ const g=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"]
26
+ for(const e of g)h[e]={get(){const{level:t}=this
27
+ return function(...r){const s=p(n.color[c[t]][e](...r),n.color.close,this._styler)
28
+ return m(this,s,this._isEmpty)}}}
29
+ for(const e of g)h["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this
30
+ return function(...r){const s=p(n.bgColor[c[t]][e](...r),n.bgColor.close,this._styler)
31
+ return m(this,s,this._isEmpty)}}}
32
+ const f=Object.defineProperties(()=>{},{...h,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),p=(e,t,r)=>{let n,s
33
+ return void 0===r?(n=e,s=t):(n=r.openAll+e,s=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:s,parent:r}},m=(e,t,r)=>{const n=(...e)=>i(e[0])&&i(e[0].raw)?y(n,w(n,...e)):y(n,1===e.length?""+e[0]:e.join(" "))
34
+ return Object.setPrototypeOf(n,f),n._generator=e,n._styler=t,n._isEmpty=r,n},y=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?"":t
35
+ let r=e._styler
36
+ if(void 0===r)return t
37
+ const{openAll:n,closeAll:s}=r
38
+ if(-1!==t.indexOf("\x1b"))for(;void 0!==r;)t=a(t,r.close,r.open),r=r.parent
39
+ const o=t.indexOf("\n")
40
+ return-1!==o&&(t=l(t,s,n,o)),n+t+s}
41
+ let b
42
+ const w=(e,...r)=>{const[n]=r
43
+ if(!i(n)||!i(n.raw))return r.join(" ")
44
+ const s=r.slice(1),o=[n.raw[0]]
45
+ for(let e=1;e<n.length;e++)o.push(String(s[e-1]).replace(/[{}\\]/g,"\\$&"),String(n.raw[e]))
46
+ return void 0===b&&(b=t(12991)),b(e,o.join(""))}
47
+ Object.defineProperties(r.prototype,h)
48
+ const v=r()
49
+ v.supportsColor=s,v.stderr=r({level:o?o.level:0}),v.stderr.supportsColor=o,module.exports=v},12991(module){"use strict"
50
+ function e(e){const t="u"===e[0],r="{"===e[1]
51
+ return t&&!r&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):t&&r?String.fromCodePoint(parseInt(e.slice(2,-1),16)):i.get(e)||e}function t(t,r){const n=[],s=r.trim().split(/\s*,\s*/g)
52
+ let o
53
+ for(const r of s){const s=Number(r)
54
+ if(Number.isNaN(s)){if(!(o=r.match(a)))throw new Error(`Invalid Chalk template style argument: ${r} (in style '${t}')`)
55
+ n.push(o[2].replace(l,(t,r,n)=>r?e(r):n))}else n.push(s)}return n}function r(e){o.lastIndex=0
56
+ const r=[]
57
+ let n
58
+ for(;null!==(n=o.exec(e));){const e=n[1]
59
+ if(n[2]){const s=t(e,n[2])
60
+ r.push([e].concat(s))}else r.push([e])}return r}function n(e,t){const r={}
61
+ for(const e of t)for(const t of e.styles)r[t[0]]=e.inverse?null:t.slice(1)
62
+ let n=e
63
+ for(const[e,t]of Object.entries(r))if(Array.isArray(t)){if(!(e in n))throw new Error(`Unknown Chalk style: ${e}`)
64
+ n=t.length>0?n[e](...t):n[e]}return n}const s=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,o=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,a=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,l=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,i=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1b"],["a","\x07"]])
65
+ module.exports=(t,o)=>{const a=[],l=[]
66
+ let i=[]
67
+ if(o.replace(s,(s,o,c,h,u,d)=>{if(o)i.push(e(o))
68
+ else if(h){const e=i.join("")
69
+ i=[],l.push(0===a.length?e:n(t,a)(e)),a.push({inverse:c,styles:r(h)})}else if(u){if(0===a.length)throw new Error("Found extraneous } in Chalk template literal")
70
+ l.push(n(t,a)(i.join(""))),i=[],a.pop()}else i.push(d)}),l.push(i.join("")),a.length>0){const e=`Chalk template literal is missing ${a.length} closing bracket${1===a.length?"":"s"} (\`}\`)`
71
+ throw new Error(e)}return l.join("")}},4058(module){"use strict"
72
+ module.exports={stringReplaceAll:(e,t,r)=>{let n=e.indexOf(t)
73
+ if(-1===n)return e
74
+ const s=t.length
75
+ let o=0,a=""
76
+ do{a+=e.substr(o,n-o)+t+r,o=n+s,n=e.indexOf(t,o)}while(-1!==n)
77
+ return a+=e.substr(o),a},stringEncaseCRLFWithFirstIndex:(e,t,r,n)=>{let s=0,o=""
78
+ do{const a="\r"===e[n-1]
79
+ o+=e.substr(s,(a?n-1:n)-s)+t+(a?"\r\n":"\n")+r,s=n+1,n=e.indexOf("\n",s)}while(-1!==n)
80
+ return o+=e.substr(s),o}}},15659(module,e,t){function r(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}const n=t(8156),s={}
81
+ for(const e of Object.keys(n))s[n[e]]=e
82
+ const o={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}}
83
+ module.exports=o
84
+ for(const e of Object.keys(o)){if(!("channels"in o[e]))throw new Error("missing channels property: "+e)
85
+ if(!("labels"in o[e]))throw new Error("missing channel labels property: "+e)
86
+ if(o[e].labels.length!==o[e].channels)throw new Error("channel and label counts mismatch: "+e)
87
+ const{channels:t,labels:r}=o[e]
88
+ delete o[e].channels,delete o[e].labels,Object.defineProperty(o[e],"channels",{value:t}),Object.defineProperty(o[e],"labels",{value:r})}o.rgb.hsl=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,s=Math.min(t,r,n),o=Math.max(t,r,n),a=o-s
89
+ let l,i
90
+ o===s?l=0:t===o?l=(r-n)/a:r===o?l=2+(n-t)/a:n===o&&(l=4+(t-r)/a),l=Math.min(60*l,360),l<0&&(l+=360)
91
+ const c=(s+o)/2
92
+ return i=o===s?0:c<=.5?a/(o+s):a/(2-o-s),[l,100*i,100*c]},o.rgb.hsv=function(e){let t,r,n,s,o
93
+ const a=e[0]/255,l=e[1]/255,i=e[2]/255,c=Math.max(a,l,i),h=c-Math.min(a,l,i),u=function(e){return(c-e)/6/h+.5}
94
+ return 0===h?(s=0,o=0):(o=h/c,t=u(a),r=u(l),n=u(i),a===c?s=n-r:l===c?s=1/3+t-n:i===c&&(s=2/3+r-t),s<0?s+=1:s>1&&(s-=1)),[360*s,100*o,100*c]},o.rgb.hwb=function(e){const t=e[0],r=e[1]
95
+ let n=e[2]
96
+ const s=o.rgb.hsl(e)[0],a=1/255*Math.min(t,Math.min(r,n))
97
+ return n=1-1/255*Math.max(t,Math.max(r,n)),[s,100*a,100*n]},o.rgb.cmyk=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,s=Math.min(1-t,1-r,1-n)
98
+ return[100*((1-t-s)/(1-s)||0),100*((1-r-s)/(1-s)||0),100*((1-n-s)/(1-s)||0),100*s]},o.rgb.keyword=function(e){const t=s[e]
99
+ if(t)return t
100
+ let o,a=1/0
101
+ for(const t of Object.keys(n)){const s=r(e,n[t])
102
+ s<a&&(a=s,o=t)}return o},o.keyword.rgb=function(e){return n[e]},o.rgb.xyz=function(e){let t=e[0]/255,r=e[1]/255,n=e[2]/255
103
+ return t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,[100*(.4124*t+.3576*r+.1805*n),100*(.2126*t+.7152*r+.0722*n),100*(.0193*t+.1192*r+.9505*n)]},o.rgb.lab=function(e){const t=o.rgb.xyz(e)
104
+ let r=t[0],n=t[1],s=t[2]
105
+ return r/=95.047,n/=100,s/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,[116*n-16,500*(r-n),200*(n-s)]},o.hsl.rgb=function(e){const t=e[0]/360,r=e[1]/100,n=e[2]/100
106
+ let s,o,a
107
+ if(0===r)return a=255*n,[a,a,a]
108
+ s=n<.5?n*(1+r):n+r-n*r
109
+ const l=2*n-s,i=[0,0,0]
110
+ for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,a=6*o<1?l+6*(s-l)*o:2*o<1?s:3*o<2?l+(s-l)*(2/3-o)*6:l,i[e]=255*a
111
+ return i},o.hsl.hsv=function(e){const t=e[0]
112
+ let r=e[1]/100,n=e[2]/100,s=r
113
+ const o=Math.max(n,.01)
114
+ return n*=2,r*=n<=1?n:2-n,s*=o<=1?o:2-o,[t,100*(0===n?2*s/(o+s):2*r/(n+r)),(n+r)/2*100]},o.hsv.rgb=function(e){const t=e[0]/60,r=e[1]/100
115
+ let n=e[2]/100
116
+ const s=Math.floor(t)%6,o=t-Math.floor(t),a=255*n*(1-r),l=255*n*(1-r*o),i=255*n*(1-r*(1-o))
117
+ switch(n*=255,s){case 0:return[n,i,a]
118
+ case 1:return[l,n,a]
119
+ case 2:return[a,n,i]
120
+ case 3:return[a,l,n]
121
+ case 4:return[i,a,n]
122
+ case 5:return[n,a,l]}},o.hsv.hsl=function(e){const t=e[0],r=e[1]/100,n=e[2]/100,s=Math.max(n,.01)
123
+ let o,a
124
+ a=(2-r)*n
125
+ const l=(2-r)*s
126
+ return o=r*s,o/=l<=1?l:2-l,o=o||0,a/=2,[t,100*o,100*a]},o.hwb.rgb=function(e){const t=e[0]/360
127
+ let r=e[1]/100,n=e[2]/100
128
+ const s=r+n
129
+ let o
130
+ s>1&&(r/=s,n/=s)
131
+ const a=Math.floor(6*t),l=1-n
132
+ o=6*t-a,1&a&&(o=1-o)
133
+ const i=r+o*(l-r)
134
+ let c,h,u
135
+ switch(a){default:case 6:case 0:c=l,h=i,u=r
136
+ break
137
+ case 1:c=i,h=l,u=r
138
+ break
139
+ case 2:c=r,h=l,u=i
140
+ break
141
+ case 3:c=r,h=i,u=l
142
+ break
143
+ case 4:c=i,h=r,u=l
144
+ break
145
+ case 5:c=l,h=r,u=i}return[255*c,255*h,255*u]},o.cmyk.rgb=function(e){const t=e[0]/100,r=e[1]/100,n=e[2]/100,s=e[3]/100
146
+ return[255*(1-Math.min(1,t*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s))]},o.xyz.rgb=function(e){const t=e[0]/100,r=e[1]/100,n=e[2]/100
147
+ let s,o,a
148
+ return s=3.2406*t+-1.5372*r+-.4986*n,o=-.9689*t+1.8758*r+.0415*n,a=.0557*t+-.204*r+1.057*n,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[255*s,255*o,255*a]},o.xyz.lab=function(e){let t=e[0],r=e[1],n=e[2]
149
+ return t/=95.047,r/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,[116*r-16,500*(t-r),200*(r-n)]},o.lab.xyz=function(e){let t,r,n
150
+ r=(e[0]+16)/116,t=e[1]/500+r,n=r-e[2]/200
151
+ const s=r**3,o=t**3,a=n**3
152
+ return r=s>.008856?s:(r-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,n=a>.008856?a:(n-16/116)/7.787,t*=95.047,r*=100,n*=108.883,[t,r,n]},o.lab.lch=function(e){const t=e[0],r=e[1],n=e[2]
153
+ let s
154
+ return s=360*Math.atan2(n,r)/2/Math.PI,s<0&&(s+=360),[t,Math.sqrt(r*r+n*n),s]},o.lch.lab=function(e){const t=e[0],r=e[1],n=e[2]/360*2*Math.PI
155
+ return[t,r*Math.cos(n),r*Math.sin(n)]},o.rgb.ansi16=function(e,t=null){const[r,n,s]=e
156
+ let a=null===t?o.rgb.hsv(e)[2]:t
157
+ if(a=Math.round(a/50),0===a)return 30
158
+ let l=30+(Math.round(s/255)<<2|Math.round(n/255)<<1|Math.round(r/255))
159
+ return 2===a&&(l+=60),l},o.hsv.ansi16=function(e){return o.rgb.ansi16(o.hsv.rgb(e),e[2])},o.rgb.ansi256=function(e){const t=e[0],r=e[1],n=e[2]
160
+ return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},o.ansi16.rgb=function(e){let t=e%10
161
+ if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t]
162
+ const r=.5*(1+~~(e>50))
163
+ return[(1&t)*r*255,(t>>1&1)*r*255,(t>>2&1)*r*255]},o.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8
164
+ return[t,t,t]}let t
165
+ return e-=16,[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},o.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase()
166
+ return"000000".substring(t.length)+t},o.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i)
167
+ if(!t)return[0,0,0]
168
+ let r=t[0]
169
+ 3===t[0].length&&(r=r.split("").map(e=>e+e).join(""))
170
+ const n=parseInt(r,16)
171
+ return[n>>16&255,n>>8&255,255&n]},o.rgb.hcg=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,s=Math.max(Math.max(t,r),n),o=Math.min(Math.min(t,r),n),a=s-o
172
+ let l,i
173
+ return l=a<1?o/(1-a):0,i=a<=0?0:s===t?(r-n)/a%6:s===r?2+(n-t)/a:4+(t-r)/a,i/=6,i%=1,[360*i,100*a,100*l]},o.hsl.hcg=function(e){const t=e[1]/100,r=e[2]/100,n=r<.5?2*t*r:2*t*(1-r)
174
+ let s=0
175
+ return n<1&&(s=(r-.5*n)/(1-n)),[e[0],100*n,100*s]},o.hsv.hcg=function(e){const t=e[1]/100,r=e[2]/100,n=t*r
176
+ let s=0
177
+ return n<1&&(s=(r-n)/(1-n)),[e[0],100*n,100*s]},o.hcg.rgb=function(e){const t=e[0]/360,r=e[1]/100,n=e[2]/100
178
+ if(0===r)return[255*n,255*n,255*n]
179
+ const s=[0,0,0],o=t%1*6,a=o%1,l=1-a
180
+ let i=0
181
+ switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0
182
+ break
183
+ case 1:s[0]=l,s[1]=1,s[2]=0
184
+ break
185
+ case 2:s[0]=0,s[1]=1,s[2]=a
186
+ break
187
+ case 3:s[0]=0,s[1]=l,s[2]=1
188
+ break
189
+ case 4:s[0]=a,s[1]=0,s[2]=1
190
+ break
191
+ default:s[0]=1,s[1]=0,s[2]=l}return i=(1-r)*n,[255*(r*s[0]+i),255*(r*s[1]+i),255*(r*s[2]+i)]},o.hcg.hsv=function(e){const t=e[1]/100,r=t+e[2]/100*(1-t)
192
+ let n=0
193
+ return r>0&&(n=t/r),[e[0],100*n,100*r]},o.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t
194
+ let n=0
195
+ return r>0&&r<.5?n=t/(2*r):r>=.5&&r<1&&(n=t/(2*(1-r))),[e[0],100*n,100*r]},o.hcg.hwb=function(e){const t=e[1]/100,r=t+e[2]/100*(1-t)
196
+ return[e[0],100*(r-t),100*(1-r)]},o.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,n=r-t
197
+ let s=0
198
+ return n<1&&(s=(r-n)/(1-n)),[e[0],100*n,100*s]},o.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},o.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},o.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},o.gray.hsl=function(e){return[0,0,e[0]]},o.gray.hsv=o.gray.hsl,o.gray.hwb=function(e){return[0,100,e[0]]},o.gray.cmyk=function(e){return[0,0,0,e[0]]},o.gray.lab=function(e){return[e[0],0,0]},o.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),r=((t<<16)+(t<<8)+t).toString(16).toUpperCase()
199
+ return"000000".substring(r.length)+r},o.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},10734(module,e,t){const r=t(15659),n=t(8507),s={}
200
+ Object.keys(r).forEach(e=>{s[e]={},Object.defineProperty(s[e],"channels",{value:r[e].channels}),Object.defineProperty(s[e],"labels",{value:r[e].labels})
201
+ const t=n(e)
202
+ Object.keys(t).forEach(r=>{const n=t[r]
203
+ s[e][r]=function(e){const t=function(...t){const r=t[0]
204
+ if(null==r)return r
205
+ r.length>1&&(t=r)
206
+ const n=e(t)
207
+ if("object"==typeof n)for(let e=n.length,t=0;t<e;t++)n[t]=Math.round(n[t])
208
+ return n}
209
+ return"conversion"in e&&(t.conversion=e.conversion),t}(n),s[e][r].raw=function(e){const t=function(...t){const r=t[0]
210
+ return null==r?r:(r.length>1&&(t=r),e(t))}
211
+ return"conversion"in e&&(t.conversion=e.conversion),t}(n)})}),module.exports=s},8507(module,e,t){function r(e,t){return function(r){return t(e(r))}}function n(e,t){const n=[t[e].parent,e]
212
+ let o=s[t[e].parent][e],a=t[e].parent
213
+ for(;t[a].parent;)n.unshift(t[a].parent),o=r(s[t[a].parent][a],o),a=t[a].parent
214
+ return o.conversion=n,o}const s=t(15659)
215
+ module.exports=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(s)
216
+ for(let r=t.length,n=0;n<r;n++)e[t[n]]={distance:-1,parent:null}
217
+ return e}(),r=[e]
218
+ for(t[e].distance=0;r.length;){const e=r.pop(),n=Object.keys(s[e])
219
+ for(let s=n.length,o=0;o<s;o++){const s=n[o],a=t[s];-1===a.distance&&(a.distance=t[e].distance+1,a.parent=e,r.unshift(s))}}return t}(e),r={},o=Object.keys(t)
220
+ for(let e=o.length,s=0;s<e;s++){const e=o[s]
221
+ null!==t[e].parent&&(r[e]=n(e,t))}return r}},8156(module){"use strict"
222
+ module.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},75994(e,exports,t){"use strict"
223
+ function r(e){if(!e.hasCode&&e.branch===e.home)return`${h.default.yellow("alchemy")}${h.default.gray(">")} `
224
+ const t=e.status&&e.branch!==e.home?` ${h.default.gray("|")} ${e.status}`:""
225
+ return`${h.default.cyan("[")}${h.default.green(e.branch)}${t}${h.default.cyan("]")} ${h.default.yellow("alchemy")}${h.default.gray(">")} `}function n(e){return e?'Type "help" for available commands. Commands run in the current branch directory.':'Type "help" for available commands.'}var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
226
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.InteractiveShell=void 0,exports.shellPrompt=r,exports.briefHelpLine=n
227
+ const o=s(t(23785)),a=t(35317),l=t(94662),i=s(t(16928)),c=s(t(79896)),h=s(t(55248)),u=t(14139),d=t(7202),g=t(44192),f=t(41152),p=t(76634),m=t(79414),y=t(52232)
228
+ exports.InteractiveShell=class{constructor(e){if(this.home="main",this.currentBranch="main",this.currentStatus=null,this.history=[],this.statusCache={map:new Map,ts:0},this.pathExecutableCache=null,this.projectPath=e.projectPath,this.currentSymlink=i.default.join(e.projectPath,u.ALCHEMY_DIR_NAME,"current"),this.currentDir=e.projectPath,this.logger=e.logger,this.historyFile=i.default.join(e.projectPath,u.ALCHEMY_DIR_NAME,"shell-history.txt"),this.projectId=e.projectId,this.remoteServerUrl=e.remoteServerUrl,this.authToken=e.authToken,this.hasCode=!1!==e.hasCode,e.remoteServerUrl){const t=(0,f.createMetricsCollector)(!1)
229
+ this.apiClient=new g.BaseApiClient(e.remoteServerUrl,e.logger,t,e.authToken)}}async publishPr(e,t){if(!e||!/^req\d{6}$/.test(e))return void console.log(h.default.red("Usage: publish req###### [base-branch]"))
9
230
  if(!this.projectId||!this.remoteServerUrl)return void console.log(h.default.red("Project is not registered with the remote yet."))
10
- const r=this.projectId,s={"X-Client-Type":"alchemy-local-service"}
11
- this.authToken&&(s.Authorization=`Bearer ${this.authToken}`)
12
- try{console.log(h.default.gray(`Publishing ${t} as a GitHub PR (uses your local gh auth; no token is stored)...`))
13
- const a=await(0,g.publishRequestPr)({projectPath:this.projectPath,requestLocalId:t,base:e},{run:(0,g.defaultRunner)(),fetchRequest:async t=>{const e=await(this.apiClient?.get(`/api/projects/${r}/requests/${t}`))
14
- return e?.data??e??null},fetchReceiptMarkdown:async t=>{const e=await fetch(`${this.remoteServerUrl}/api/projects/${r}/requests/${t}/receipt?format=md`,{headers:s})
15
- if(!e.ok)throw new Error(`Receipt fetch failed: HTTP ${e.status}`)
16
- return await e.text()}})
17
- console.log(h.default.green(`${a.created?"PR created":"Receipt added to the existing PR"}: ${a.prUrl}`)),a.statusPosted&&console.log(h.default.gray("Commit status alchemylab/gates set on the head commit."))}catch(t){console.log(h.default.red(t instanceof Error?t.message:String(t)))}}async linearImport(t){if(t&&/^[A-Za-z][A-Za-z0-9]{1,9}-\d{1,6}$/.test(t))try{const e=(0,m.getActionServerBaseUrl)(),r=await fetch(`${e}/api/connections/linear/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueKey:t.toUpperCase()})}),s=await r.json()
18
- s.success&&s.data?.requestId?console.log(h.default.green(`Imported ${s.data.issue} as draft request ${s.data.requestId}. Start it in AlchemyLab when it is ready.`)):console.log(h.default.red(s.error||"Import failed."))}catch(t){console.log(h.default.red(t instanceof Error?t.message:String(t)))}else console.log(h.default.red("Usage: linear <issue key> e.g. linear ENG-123"))}async start(t){return this.shutdownCallback=t,this.home=await(0,y.resolveDefaultBranch)(this.projectPath).catch(()=>"main"),this.currentBranch=this.home,this.updateCurrentSymlink(),this.loadHistory(),this.rl=i.default.createInterface({input:process.stdin,output:process.stdout,prompt:this.buildPrompt(),historySize:500,removeHistoryDuplicates:!0,completer:t=>this.completer(t)}),this.history.length>0&&(this.rl.history=[...this.history].reverse()),this.printHelp(!0),this.rl.prompt(),new Promise(t=>{this.rl.on("line",async e=>{const r=e.trim()
19
- if(r){if(this.appendHistory(r),await this.processCommand(r))return this.rl.close(),void t()
231
+ const r=this.projectId,n={"X-Client-Type":"alchemy-local-service"}
232
+ this.authToken&&(n.Authorization=`Bearer ${this.authToken}`)
233
+ try{console.log(h.default.gray(`Publishing ${e} as a GitHub PR (uses your local gh auth; no token is stored)...`))
234
+ const s=await(0,p.publishRequestPr)({projectPath:this.projectPath,requestLocalId:e,base:t},{run:(0,p.defaultRunner)(),fetchRequest:async e=>{const t=await(this.apiClient?.get(`/api/projects/${r}/requests/${e}`))
235
+ return t?.data??t??null},fetchReceiptMarkdown:async e=>{const t=await fetch(`${this.remoteServerUrl}/api/projects/${r}/requests/${e}/receipt?format=md`,{headers:n})
236
+ if(!t.ok)throw new Error(`Receipt fetch failed: HTTP ${t.status}`)
237
+ return await t.text()}})
238
+ console.log(h.default.green(`${s.created?"PR created":"Receipt added to the existing PR"}: ${s.prUrl}`)),s.statusPosted&&console.log(h.default.gray("Commit status alchemylab/gates set on the head commit."))}catch(e){console.log(h.default.red(e instanceof Error?e.message:String(e)))}}async linearImport(e){if(e&&/^[A-Za-z][A-Za-z0-9]{1,9}-\d{1,6}$/.test(e))try{const t=(0,m.getActionServerBaseUrl)(),r=await fetch(`${t}/api/connections/linear/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueKey:e.toUpperCase()})}),n=await r.json()
239
+ n.success&&n.data?.requestId?console.log(h.default.green(`Imported ${n.data.issue} as draft request ${n.data.requestId}. Start it in AlchemyLab when it is ready.`)):console.log(h.default.red(n.error||"Import failed."))}catch(e){console.log(h.default.red(e instanceof Error?e.message:String(e)))}else console.log(h.default.red("Usage: linear <issue key> e.g. linear ENG-123"))}async start(e){return this.shutdownCallback=e,this.home=await(0,y.resolveDefaultBranch)(this.projectPath).catch(()=>"main"),this.currentBranch=this.home,this.updateCurrentSymlink(),this.loadHistory(),this.rl=o.default.createInterface({input:process.stdin,output:process.stdout,prompt:this.buildPrompt(),historySize:500,removeHistoryDuplicates:!0,completer:e=>this.completer(e)}),this.history.length>0&&(this.rl.history=[...this.history].reverse()),this.printHelp(!0),this.rl.prompt(),new Promise(e=>{this.rl.on("line",async t=>{const r=t.trim()
240
+ if(r){if(this.appendHistory(r),await this.processCommand(r))return this.rl.close(),void e()
20
241
  this.rl.prompt()}else this.rl.prompt()})
21
- let e,r=!1
22
- this.rl.on("SIGINT",()=>{r?(e&&clearTimeout(e),this.rl.close()):(r=!0,console.log(""),console.log(h.default.gray("Press Ctrl+C again to exit, or continue typing.")),this.rl.prompt(),e=setTimeout(()=>{r=!1},2e3))}),this.rl.on("close",async()=>{this.shutdownCallback&&await this.shutdownCallback(),t()})})}buildPrompt(){return r({branch:this.currentBranch,home:this.home,status:this.currentStatus?this.colorStatus(this.currentStatus):null,hasCode:this.hasCode})}colorStatus(t){switch(t){case"completed":return h.default.green(t)
23
- case"in_progress":return h.default.yellow(t)
24
- case"open":return h.default.blue(t)
242
+ let t,r=!1
243
+ this.rl.on("SIGINT",()=>{r?(t&&clearTimeout(t),this.rl.close()):(r=!0,console.log(""),console.log(h.default.gray("Press Ctrl+C again to exit, or continue typing.")),this.rl.prompt(),t=setTimeout(()=>{r=!1},2e3))}),this.rl.on("close",async()=>{this.shutdownCallback&&await this.shutdownCallback(),e()})})}buildPrompt(){return r({branch:this.currentBranch,home:this.home,status:this.currentStatus?this.colorStatus(this.currentStatus):null,hasCode:this.hasCode})}colorStatus(e){switch(e){case"completed":return h.default.green(e)
244
+ case"in_progress":return h.default.yellow(e)
245
+ case"open":return h.default.blue(e)
25
246
  case"ready_for_review":return h.default.magenta("review")
26
- case"canceled":default:return h.default.gray(t)
27
- case"reverted":return h.default.red(t)}}async fetchRequestStatus(t){if(!this.apiClient||!this.projectId)return null
28
- try{const e=await this.apiClient.get(`/api/projects/${this.projectId}/requests/${t}`),r=e?.data||e
247
+ case"canceled":default:return h.default.gray(e)
248
+ case"reverted":return h.default.red(e)}}async fetchRequestStatus(e){if(!this.apiClient||!this.projectId)return null
249
+ try{const t=await this.apiClient.get(`/api/projects/${this.projectId}/requests/${e}`),r=t?.data||t
29
250
  return r?.status||null}catch{return null}}async fetchBulkStatuses(){if(Date.now()-this.statusCache.ts<1e4&&this.statusCache.map.size>0)return this.statusCache.map
30
251
  if(!this.apiClient||!this.projectId)return new Map
31
- try{const t=await this.apiClient.get(`/api/projects/${this.projectId}/requests?limit=100&sortBy=updated&sortDirection=desc`),e=t?.data||t||[],r=new Map
32
- for(const t of Array.isArray(e)?e:[])t.localId&&t.status&&r.set(t.localId,t.status)
33
- return this.statusCache={map:r,ts:Date.now()},r}catch{return this.statusCache.map}}formatRequestWithStatus(t,e,r){return`${r?h.default.green(t):t}${e?` ${this.colorStatus(e)}`:""}`}updatePrompt(){this.rl.setPrompt(this.buildPrompt())}getPathExecutables(){if(this.pathExecutableCache)return this.pathExecutableCache
34
- const t=new Set,e=(process.env.PATH||"").split(l.default.delimiter)
35
- for(const r of e)try{if(!c.default.existsSync(r))continue
36
- for(const e of c.default.readdirSync(r))t.add(e)}catch{}return this.pathExecutableCache=Array.from(t).sort(),this.pathExecutableCache}completer(t){const e=["br","branch","logs","pwd","cd ","publish ","linear ","help","exit","quit"],r=t.includes(" "),s=t.indexOf(" "),a=r?t.slice(0,s).toLowerCase():""
37
- if(r&&("br"===a||"branch"===a))return setImmediate(()=>this.rl.write("\n")),[[],""]
38
- if(!r){const r=e.filter(e=>e.startsWith(t)),s=t?this.getPathExecutables().filter(e=>e.startsWith(t)):[],a=[...new Set([...r,...s])]
39
- if(a.length>0)return[a,t]
40
- if(!t)return[e,t]}const i=t.lastIndexOf(" "),o=i>=0?t.slice(i+1):t,n=i>=0?t.slice(0,i+1):""
41
- try{const e=o.includes(l.default.sep)||o.includes("/"),r=e?l.default.resolve(this.currentDir,l.default.dirname(o)):this.currentDir,s=e?l.default.basename(o):o,a=e?l.default.dirname(o)+"/":""
42
- if(!c.default.existsSync(r))return[[],t]
43
- const i=c.default.readdirSync(r,{withFileTypes:!0}).filter(t=>t.name.startsWith(s)&&!t.name.startsWith(".")).map(t=>{const e=t.isDirectory()?t.name+"/":t.name
44
- return n+a+e})
45
- if(i.length>0)return[i,t]}catch{}return[[],t]}async detectCurrentBranch(){try{const t=(0,n.simpleGit)(this.currentDir),e=(await t.branch()).current||this.home
46
- this.currentBranch=this.extractRequestId(e)||e}catch{this.currentBranch=this.home}}async processCommand(t){const e=t.split(/\s+/),r=e[0].toLowerCase(),s=e.slice(1)
252
+ try{const e=await this.apiClient.get(`/api/projects/${this.projectId}/requests?limit=100&sortBy=updated&sortDirection=desc`),t=e?.data||e||[],r=new Map
253
+ for(const e of Array.isArray(t)?t:[])e.localId&&e.status&&r.set(e.localId,e.status)
254
+ return this.statusCache={map:r,ts:Date.now()},r}catch{return this.statusCache.map}}formatRequestWithStatus(e,t,r){return`${r?h.default.green(e):e}${t?` ${this.colorStatus(t)}`:""}`}updatePrompt(){this.rl.setPrompt(this.buildPrompt())}getPathExecutables(){if(this.pathExecutableCache)return this.pathExecutableCache
255
+ const e=new Set,t=(process.env.PATH||"").split(i.default.delimiter)
256
+ for(const r of t)try{if(!c.default.existsSync(r))continue
257
+ for(const t of c.default.readdirSync(r))e.add(t)}catch{}return this.pathExecutableCache=Array.from(e).sort(),this.pathExecutableCache}completer(e){const t=["br","branch","logs","pwd","cd ","publish ","linear ","help","exit","quit"],r=e.includes(" "),n=e.indexOf(" "),s=r?e.slice(0,n).toLowerCase():""
258
+ if(r&&("br"===s||"branch"===s))return setImmediate(()=>this.rl.write("\n")),[[],""]
259
+ if(!r){const r=t.filter(t=>t.startsWith(e)),n=e?this.getPathExecutables().filter(t=>t.startsWith(e)):[],s=[...new Set([...r,...n])]
260
+ if(s.length>0)return[s,e]
261
+ if(!e)return[t,e]}const o=e.lastIndexOf(" "),a=o>=0?e.slice(o+1):e,l=o>=0?e.slice(0,o+1):""
262
+ try{const t=a.includes(i.default.sep)||a.includes("/"),r=t?i.default.resolve(this.currentDir,i.default.dirname(a)):this.currentDir,n=t?i.default.basename(a):a,s=t?i.default.dirname(a)+"/":""
263
+ if(!c.default.existsSync(r))return[[],e]
264
+ const o=c.default.readdirSync(r,{withFileTypes:!0}).filter(e=>e.name.startsWith(n)&&!e.name.startsWith(".")).map(e=>{const t=e.isDirectory()?e.name+"/":e.name
265
+ return l+s+t})
266
+ if(o.length>0)return[o,e]}catch{}return[[],e]}async detectCurrentBranch(){try{const e=(0,l.simpleGit)(this.currentDir),t=(await e.branch()).current||this.home
267
+ this.currentBranch=this.extractRequestId(t)||t}catch{this.currentBranch=this.home}}async processCommand(e){const t=e.split(/\s+/),r=t[0].toLowerCase(),n=t.slice(1)
47
268
  switch(r){case"exit":case"quit":return this.shutdownCallback&&await this.shutdownCallback(),!0
48
269
  case"help":return this.printHelp(!1),!1
49
- case"br":case"branch":return await this.listBranches(s.length>0?s.join(" "):void 0),!1
50
- case"logs":return await this.tailLogs(s),!1
270
+ case"br":case"branch":return await this.listBranches(n.length>0?n.join(" "):void 0),!1
271
+ case"logs":return await this.tailLogs(n),!1
51
272
  case"pwd":return console.log(this.getVirtualCwd()),!1
52
- case"cd":return this.changeDirectory(s[0]||"~"),!1
53
- case"publish":return await this.publishPr(s[0],s[1]),!1
54
- case"linear":return await this.linearImport(s[0]),!1
55
- default:return this.executeCommand(t),!1}}changeDirectory(t){try{let e
56
- if(e="~"===t||""===t?this.currentSymlink:l.default.isAbsolute(t)?t:l.default.resolve(this.currentDir,t),!c.default.existsSync(e)||!c.default.statSync(e).isDirectory())return void console.log(h.default.red(`cd: no such directory: ${t}`))
57
- this.currentDir=e}catch(t){console.log(h.default.red(`cd: ${t.message}`))}}async tailLogs(t){const r=l.default.join(this.projectPath,u.ALCHEMY_DIR_NAME,"server.log")
273
+ case"cd":return this.changeDirectory(n[0]||"~"),!1
274
+ case"publish":return await this.publishPr(n[0],n[1]),!1
275
+ case"linear":return await this.linearImport(n[0]),!1
276
+ default:return this.executeCommand(e),!1}}changeDirectory(e){try{let t
277
+ if(t="~"===e||""===e?this.currentSymlink:i.default.isAbsolute(e)?e:i.default.resolve(this.currentDir,e),!c.default.existsSync(t)||!c.default.statSync(t).isDirectory())return void console.log(h.default.red(`cd: no such directory: ${e}`))
278
+ this.currentDir=t}catch(e){console.log(h.default.red(`cd: ${e.message}`))}}async tailLogs(e){const r=i.default.join(this.projectPath,u.ALCHEMY_DIR_NAME,"server.log")
58
279
  if(!c.default.existsSync(r))return void console.log(h.default.gray("No log file found yet. Logs will appear once the server processes requests."))
59
- const s=t[0]&&/^\d+$/.test(t[0])?parseInt(t[0],10):50
60
- console.log(h.default.gray(`Tailing ${r} (last ${s} lines, Ctrl+C to stop)`))
61
- const{spawn:a}=await Promise.resolve().then(()=>e.t(35317,23)),i=a("tail",["-n",String(s),"-f",r],{stdio:["ignore","inherit","inherit"]})
62
- return new Promise(t=>{const e=process.stdin,r=e.isRaw
63
- this.rl.pause(),e.setRawMode(!0),e.resume()
64
- const s=()=>{e.removeListener("data",a)
65
- try{i.kill("SIGTERM")}catch{}try{e.setRawMode(r??!1)}catch{}this.rl.resume()},a=t=>{3!==t[0]&&"q"!==t.toString()||i.kill("SIGTERM")}
66
- e.on("data",a),i.on("close",()=>{s(),t()})})}updateCurrentSymlink(){try{let t
67
- if(this.currentBranch===this.home)t=this.projectPath
68
- else{const e=(0,d.requestWorktreePath)(this.projectPath,this.currentBranch)
69
- t=c.default.existsSync(e)?e:this.projectPath}try{c.default.unlinkSync(this.currentSymlink)}catch{}c.default.symlinkSync(t,this.currentSymlink),this.currentDir=this.currentSymlink}catch(t){this.logger.warn("Failed to update current symlink",{error:t.message})}}getVirtualCwd(){return this.currentDir}executeCommand(t){try{(0,o.execSync)(t,{cwd:this.currentDir,stdio:"inherit",env:{...process.env,PWD:this.currentDir,GIT_DIR:void 0,GIT_WORK_TREE:void 0}})}catch(t){void 0!==t.status&&null!==t.status||console.log(h.default.red(`Error: ${t.message}`))}}getWorktreeRequestIds(){const t=(0,d.requestWorktreesDir)(this.projectPath),e=new Set
70
- if(c.default.existsSync(t))for(const r of c.default.readdirSync(t,{withFileTypes:!0}))r.isDirectory()&&e.add(r.name)
71
- return e}extractRequestId(t){const e=t.match(/^(?:requests\/)?(req\d+)/)
72
- return e?e[1]:null}async listBranches(t){try{const e=(0,n.simpleGit)(this.projectPath),r=await e.branch(),s=this.getWorktreeRequestIds(),a=await this.fetchBulkStatuses(),i=new Set,o=[],l=[]
73
- for(const t of r.all){if(t.startsWith("remotes/"))continue
74
- if(t===this.home)continue
75
- const e=this.extractRequestId(t)
76
- e&&!i.has(e)&&(i.add(e),o.push(e))}for(const t of s)i.has(t)||(i.add(t),o.push(t))
77
- o.sort((t,e)=>t.localeCompare(e))
78
- for(const t of o){const e=this.currentBranch===t||this.currentBranch===`requests/${t}`
79
- l.push(this.formatRequestWithStatus(t,a.get(t),e))}if(o.push(this.home),l.push(this.currentBranch===this.home?h.default.green(this.home):this.home),0===o.length)return void console.log(h.default.gray("No branches found."))
80
- if(t&&o.includes(t))return void(t!==this.currentBranch&&await this.switchBranch(t))
81
- let c=o.indexOf(this.currentBranch)
82
- c<0&&(c=o.length-1)
83
- const u=await this.selectFromList(o,"Select branch:",l,t?0:c,!0,t)
84
- this.rl.pause(),u&&u!==this.currentBranch?await this.switchBranch(u):u||console.log(h.default.gray("Cancelled.")),this.rl.resume()}catch(t){console.log(h.default.red(`Failed to list branches: ${t.message}`))}}async ensureWorktree(t,e){const r=(0,d.requestWorktreesDir)(this.projectPath),s=l.default.join(r,t)
85
- if(c.default.existsSync(s)&&c.default.statSync(s).isDirectory())return s
86
- console.log(h.default.gray(`Creating worktree for ${t}...`)),c.default.mkdirSync(r,{recursive:!0})
87
- const a=(0,n.simpleGit)(this.projectPath)
88
- return await a.raw(["worktree","add",s,e]),console.log(h.default.gray(`Worktree created at ${s}`)),s}async selectFromList(t,e,r,s,a,i){const o=t,n=r||t
89
- return new Promise(t=>{let r=0
90
- const l=process.stdin,c=l.isRaw
91
- let u=!1,d=i||"",f=o.map((t,e)=>e)
92
- null!=s&&s>=0&&s<o.length&&(r=s)
93
- const p=()=>{if(!d)return void(f=o.map((t,e)=>e))
94
- const t=d.toLowerCase()
95
- let e=o.map((t,e)=>({item:t,i:e})).filter(({item:e})=>e.toLowerCase().startsWith(t))
96
- 0===e.length&&/^\d+$/.test(t)&&(e=o.map((t,e)=>({item:t,i:e})).filter(({item:e})=>e.replace(/\D/g,"").endsWith(t))),0===e.length&&(e=o.map((t,e)=>({item:t,i:e})).filter(({item:e})=>e.toLowerCase().includes(t))),f=e.map(t=>t.i)},g=process.stdout.rows||24,m=Math.max(3,g-4)
97
- let y=0,w=0,$=0
280
+ const n=e[0]&&/^\d+$/.test(e[0])?parseInt(e[0],10):50
281
+ console.log(h.default.gray(`Tailing ${r} (last ${n} lines, Ctrl+C to stop)`))
282
+ const{spawn:s}=await Promise.resolve().then(()=>t.t(35317,23)),o=s("tail",["-n",String(n),"-f",r],{stdio:["ignore","inherit","inherit"]})
283
+ return new Promise(e=>{const t=process.stdin,r=t.isRaw
284
+ this.rl.pause(),t.setRawMode(!0),t.resume()
285
+ const n=()=>{t.removeListener("data",s)
286
+ try{o.kill("SIGTERM")}catch{}try{t.setRawMode(r??!1)}catch{}this.rl.resume()},s=e=>{3!==e[0]&&"q"!==e.toString()||o.kill("SIGTERM")}
287
+ t.on("data",s),o.on("close",()=>{n(),e()})})}updateCurrentSymlink(){try{let e
288
+ if(this.currentBranch===this.home)e=this.projectPath
289
+ else{const t=(0,d.requestWorktreePath)(this.projectPath,this.currentBranch)
290
+ e=c.default.existsSync(t)?t:this.projectPath}try{c.default.unlinkSync(this.currentSymlink)}catch{}c.default.symlinkSync(e,this.currentSymlink),this.currentDir=this.currentSymlink}catch(e){this.logger.warn("Failed to update current symlink",{error:e.message})}}getVirtualCwd(){return this.currentDir}executeCommand(e){try{(0,a.execSync)(e,{cwd:this.currentDir,stdio:"inherit",env:{...process.env,PWD:this.currentDir,GIT_DIR:void 0,GIT_WORK_TREE:void 0}})}catch(e){void 0!==e.status&&null!==e.status||console.log(h.default.red(`Error: ${e.message}`))}}getWorktreeRequestIds(){const e=(0,d.requestWorktreesDir)(this.projectPath),t=new Set
291
+ if(c.default.existsSync(e))for(const r of c.default.readdirSync(e,{withFileTypes:!0}))r.isDirectory()&&t.add(r.name)
292
+ return t}extractRequestId(e){const t=e.match(/^(?:requests\/)?(req\d+)/)
293
+ return t?t[1]:null}async listBranches(e){try{const t=(0,l.simpleGit)(this.projectPath),r=await t.branch(),n=this.getWorktreeRequestIds(),s=await this.fetchBulkStatuses(),o=new Set,a=[],i=[]
294
+ for(const e of r.all){if(e.startsWith("remotes/"))continue
295
+ if(e===this.home)continue
296
+ const t=this.extractRequestId(e)
297
+ t&&!o.has(t)&&(o.add(t),a.push(t))}for(const e of n)o.has(e)||(o.add(e),a.push(e))
298
+ a.sort((e,t)=>e.localeCompare(t))
299
+ for(const e of a){const t=this.currentBranch===e||this.currentBranch===`requests/${e}`
300
+ i.push(this.formatRequestWithStatus(e,s.get(e),t))}if(a.push(this.home),i.push(this.currentBranch===this.home?h.default.green(this.home):this.home),0===a.length)return void console.log(h.default.gray("No branches found."))
301
+ if(e&&a.includes(e))return void(e!==this.currentBranch&&await this.switchBranch(e))
302
+ let c=a.indexOf(this.currentBranch)
303
+ c<0&&(c=a.length-1)
304
+ const u=await this.selectFromList(a,"Select branch:",i,e?0:c,!0,e)
305
+ this.rl.pause(),u&&u!==this.currentBranch?await this.switchBranch(u):u||console.log(h.default.gray("Cancelled.")),this.rl.resume()}catch(e){console.log(h.default.red(`Failed to list branches: ${e.message}`))}}async ensureWorktree(e,t){const r=(0,d.requestWorktreesDir)(this.projectPath),n=i.default.join(r,e)
306
+ if(c.default.existsSync(n)&&c.default.statSync(n).isDirectory())return n
307
+ console.log(h.default.gray(`Creating worktree for ${e}...`)),c.default.mkdirSync(r,{recursive:!0})
308
+ const s=(0,l.simpleGit)(this.projectPath)
309
+ return await s.raw(["worktree","add",n,t]),console.log(h.default.gray(`Worktree created at ${n}`)),n}async selectFromList(e,t,r,n,s,o){const a=e,l=r||e
310
+ return new Promise(e=>{let r=0
311
+ const i=process.stdin,c=i.isRaw
312
+ let u=!1,d=o||"",g=a.map((e,t)=>t)
313
+ null!=n&&n>=0&&n<a.length&&(r=n)
314
+ const f=()=>{if(!d)return void(g=a.map((e,t)=>t))
315
+ const e=d.toLowerCase()
316
+ let t=a.map((e,t)=>({item:e,i:t})).filter(({item:t})=>t.toLowerCase().startsWith(e))
317
+ 0===t.length&&/^\d+$/.test(e)&&(t=a.map((e,t)=>({item:e,i:t})).filter(({item:t})=>t.replace(/\D/g,"").endsWith(e))),0===t.length&&(t=a.map((e,t)=>({item:e,i:t})).filter(({item:t})=>t.toLowerCase().includes(e))),g=t.map(e=>e.i)},p=process.stdout.rows||24,m=Math.max(3,p-4)
318
+ let y=0,b=0,w=0
98
319
  this.rl.pause()
99
- const S=()=>{const t=f.length,s=t>m
100
- s?r<y?y=r:r>=y+m&&(y=r-m+1):y=0
101
- const i=(()=>{const t=f.length
102
- if(0===t)return 1
103
- const e=t>m
104
- let r=e?Math.min(m,t-y):t
105
- return e&&y>0&&r++,e&&y+m<t&&r++,r})(),o=i+1
106
- C&&$>1&&process.stdout.write(`\r\x1b[${$-1}A\r`),o>w&&(w=o),$=w
107
- const l=w-o
108
- for(let t=0;t<l;t++)process.stdout.write("\x1b[2K\n")
109
- if(0===t)process.stdout.write(`\x1b[2K ${h.default.gray("no matches")}\n`)
110
- else{const e=s&&y>0,a=s&&y+m<t,i=s?Math.min(y+m,t):t,o=s?y:0
111
- e&&process.stdout.write(`\x1b[2K ${h.default.gray(`\u25b2 ${y} more`)}\n`)
112
- for(let t=o;t<i;t++){const e=f[t],s=t===r?h.default.cyan("\u276f "):" ",a=t===r?h.default.cyan(n[e]):n[e]
113
- process.stdout.write(`\x1b[2K${s}${a}\n`)}a&&process.stdout.write(`\x1b[2K ${h.default.gray(`\u25bc ${t-i} more`)}\n`)}a&&d?process.stdout.write(`\x1b[2K${h.default.gray(">")} ${h.default.yellow(d)}${h.default.gray("_")}`):a?process.stdout.write(`\x1b[2K${h.default.gray(">")} ${h.default.gray("type to filter...")}`):process.stdout.write(`\x1b[2K${h.default.gray(e)}`),C=!0}
114
- d&&(p(),r=0)
115
- let C=!1
116
- S(),l.setRawMode(!0),l.resume()
117
- const b=()=>{if(!u){u=!0,l.removeListener("data",v)
118
- try{l.setRawMode(c??!1)}catch{}C&&$>1&&process.stdout.write(`\r\x1b[${$-1}A\r`),process.stdout.write("\x1b[J"),this.rl.resume()}},v=e=>{if(!u)try{const s=e.toString()
119
- "\x1b[A"===s?f.length>0&&(r=Math.max(0,r-1),S()):"\x1b[B"===s?f.length>0&&(r=Math.min(f.length-1,r+1),S()):"\r"===s||"\n"===s?f.length>0&&(b(),t(o[f[r]])):"\x1b"===s||"\x03"===s?(b(),t(null)):a&&"\x7f"===s?d.length>0&&(d=d.slice(0,-1),p(),r=0,y=0,S()):a&&1===s.length&&s>=" "&&s<="~"&&(d+=s,p(),r=0,y=0,S())}catch{b(),t(null)}}
120
- l.on("data",v)})}findMatchingBranches(t,e,r){const s=new Set
121
- for(const t of e){const e=this.extractRequestId(t)
122
- e&&s.add(e)}for(const t of r)s.add(t)
123
- const a=Array.from(s)
124
- if(s.has(t))return[t]
125
- const i=a.filter(e=>e.startsWith(t))
126
- if(i.length>0)return i.sort()
127
- if(/^\d+$/.test(t)){const e=a.filter(e=>e.replace(/\D/g,"").endsWith(t))
128
- if(e.length>0)return e.sort()}return[]}async switchBranch(t){try{if(t===this.home||"main"===t)return this.currentBranch=this.home,this.currentStatus=null,this.updateCurrentSymlink(),this.updatePrompt(),console.log(h.default.green(`Switched to ${this.home}`)),void console.log(h.default.gray(` ${this.currentDir}`))
129
- const e=(0,n.simpleGit)(this.projectPath),r=await e.branch(),s=this.getWorktreeRequestIds(),a=this.findMatchingBranches(t,r.all,s)
130
- if(0===a.length)return console.log(h.default.red(`No branch matching: ${t}`)),void console.log(h.default.gray(' Use "branches" to see available branches'))
131
- let i
132
- if(1===a.length)i=a[0]
133
- else{const e=await this.fetchBulkStatuses(),r=a.map(t=>this.formatRequestWithStatus(t,e.get(t),!1)),s=await this.selectFromList(a,`Multiple matches for "${t}" \u2014 select one:`,r,void 0,!0)
134
- if(!s)return void console.log(h.default.gray("Cancelled."))
135
- i=s}const o=r.all.includes(`requests/${i}`)?`requests/${i}`:i
136
- await this.ensureWorktree(i,o),this.currentBranch=i,this.updateCurrentSymlink(),this.currentStatus=await this.fetchRequestStatus(i),this.updatePrompt()
137
- const l=this.currentStatus?` ${h.default.gray("|")} ${this.colorStatus(this.currentStatus)}`:""
138
- console.log(h.default.green(`Switched to ${i}`)+l),console.log(h.default.gray(` ${this.getVirtualCwd()}`))}catch(t){console.log(h.default.red(`Failed to switch: ${t.message}`))}}printHelp(t){t?(console.log(""),console.log(h.default.gray(s(this.hasCode))),console.log("")):(console.log(""),console.log(h.default.bold("Interactive Shell Commands:")),console.log(` ${h.default.yellow("branch")} / ${h.default.yellow("br")} Browse and switch branches`),console.log(` ${h.default.yellow("logs")} ${h.default.gray("[N]")} Tail action server log (Ctrl+C to stop, N = lines of history)`),console.log(` ${h.default.yellow("cd")} ${h.default.gray("<dir>")} Change directory within current branch`),console.log(` ${h.default.yellow("pwd")} Show current working directory`),console.log(` ${h.default.yellow("publish")} ${h.default.gray("<req id>")} Push the request branch and open a GitHub PR with its receipt`),console.log(` ${h.default.yellow("linear")} ${h.default.gray("<ENG-123>")} Import a Linear issue as a draft request`),console.log(` ${h.default.yellow("help")} Show this help`),console.log(` ${h.default.yellow("exit")} / ${h.default.yellow("quit")} Stop the server and exit`),console.log(""),console.log(h.default.gray(" Any other input is executed as a shell command in the current directory.")),console.log(""))}loadHistory(){try{if(c.default.existsSync(this.historyFile)){const t=c.default.readFileSync(this.historyFile,"utf-8")
139
- this.history=t.split("\n").filter(t=>""!==t.trim()),this.history.length>500&&(this.history=this.history.slice(-500))}}catch{}}appendHistory(t){try{this.history.push(t),c.default.appendFileSync(this.historyFile,t+"\n")}catch{}}}}}
320
+ const v=()=>{const e=g.length,n=e>m
321
+ n?r<y?y=r:r>=y+m&&(y=r-m+1):y=0
322
+ const o=(()=>{const e=g.length
323
+ if(0===e)return 1
324
+ const t=e>m
325
+ let r=t?Math.min(m,e-y):e
326
+ return t&&y>0&&r++,t&&y+m<e&&r++,r})(),a=o+1
327
+ k&&w>1&&process.stdout.write(`\r\x1b[${w-1}A\r`),a>b&&(b=a),w=b
328
+ const i=b-a
329
+ for(let e=0;e<i;e++)process.stdout.write("\x1b[2K\n")
330
+ if(0===e)process.stdout.write(`\x1b[2K ${h.default.gray("no matches")}\n`)
331
+ else{const t=n&&y>0,s=n&&y+m<e,o=n?Math.min(y+m,e):e,a=n?y:0
332
+ t&&process.stdout.write(`\x1b[2K ${h.default.gray(`\u25b2 ${y} more`)}\n`)
333
+ for(let e=a;e<o;e++){const t=g[e],n=e===r?h.default.cyan("\u276f "):" ",s=e===r?h.default.cyan(l[t]):l[t]
334
+ process.stdout.write(`\x1b[2K${n}${s}\n`)}s&&process.stdout.write(`\x1b[2K ${h.default.gray(`\u25bc ${e-o} more`)}\n`)}s&&d?process.stdout.write(`\x1b[2K${h.default.gray(">")} ${h.default.yellow(d)}${h.default.gray("_")}`):s?process.stdout.write(`\x1b[2K${h.default.gray(">")} ${h.default.gray("type to filter...")}`):process.stdout.write(`\x1b[2K${h.default.gray(t)}`),k=!0}
335
+ d&&(f(),r=0)
336
+ let k=!1
337
+ v(),i.setRawMode(!0),i.resume()
338
+ const $=()=>{if(!u){u=!0,i.removeListener("data",C)
339
+ try{i.setRawMode(c??!1)}catch{}k&&w>1&&process.stdout.write(`\r\x1b[${w-1}A\r`),process.stdout.write("\x1b[J"),this.rl.resume()}},C=t=>{if(!u)try{const n=t.toString()
340
+ "\x1b[A"===n?g.length>0&&(r=Math.max(0,r-1),v()):"\x1b[B"===n?g.length>0&&(r=Math.min(g.length-1,r+1),v()):"\r"===n||"\n"===n?g.length>0&&($(),e(a[g[r]])):"\x1b"===n||"\x03"===n?($(),e(null)):s&&"\x7f"===n?d.length>0&&(d=d.slice(0,-1),f(),r=0,y=0,v()):s&&1===n.length&&n>=" "&&n<="~"&&(d+=n,f(),r=0,y=0,v())}catch{$(),e(null)}}
341
+ i.on("data",C)})}findMatchingBranches(e,t,r){const n=new Set
342
+ for(const e of t){const t=this.extractRequestId(e)
343
+ t&&n.add(t)}for(const e of r)n.add(e)
344
+ const s=Array.from(n)
345
+ if(n.has(e))return[e]
346
+ const o=s.filter(t=>t.startsWith(e))
347
+ if(o.length>0)return o.sort()
348
+ if(/^\d+$/.test(e)){const t=s.filter(t=>t.replace(/\D/g,"").endsWith(e))
349
+ if(t.length>0)return t.sort()}return[]}async switchBranch(e){try{if(e===this.home||"main"===e)return this.currentBranch=this.home,this.currentStatus=null,this.updateCurrentSymlink(),this.updatePrompt(),console.log(h.default.green(`Switched to ${this.home}`)),void console.log(h.default.gray(` ${this.currentDir}`))
350
+ const t=(0,l.simpleGit)(this.projectPath),r=await t.branch(),n=this.getWorktreeRequestIds(),s=this.findMatchingBranches(e,r.all,n)
351
+ if(0===s.length)return console.log(h.default.red(`No branch matching: ${e}`)),void console.log(h.default.gray(' Use "branches" to see available branches'))
352
+ let o
353
+ if(1===s.length)o=s[0]
354
+ else{const t=await this.fetchBulkStatuses(),r=s.map(e=>this.formatRequestWithStatus(e,t.get(e),!1)),n=await this.selectFromList(s,`Multiple matches for "${e}" \u2014 select one:`,r,void 0,!0)
355
+ if(!n)return void console.log(h.default.gray("Cancelled."))
356
+ o=n}const a=r.all.includes(`requests/${o}`)?`requests/${o}`:o
357
+ await this.ensureWorktree(o,a),this.currentBranch=o,this.updateCurrentSymlink(),this.currentStatus=await this.fetchRequestStatus(o),this.updatePrompt()
358
+ const i=this.currentStatus?` ${h.default.gray("|")} ${this.colorStatus(this.currentStatus)}`:""
359
+ console.log(h.default.green(`Switched to ${o}`)+i),console.log(h.default.gray(` ${this.getVirtualCwd()}`))}catch(e){console.log(h.default.red(`Failed to switch: ${e.message}`))}}printHelp(e){e?(console.log(""),console.log(h.default.gray(n(this.hasCode))),console.log("")):(console.log(""),console.log(h.default.bold("Interactive Shell Commands:")),console.log(` ${h.default.yellow("branch")} / ${h.default.yellow("br")} Browse and switch branches`),console.log(` ${h.default.yellow("logs")} ${h.default.gray("[N]")} Tail action server log (Ctrl+C to stop, N = lines of history)`),console.log(` ${h.default.yellow("cd")} ${h.default.gray("<dir>")} Change directory within current branch`),console.log(` ${h.default.yellow("pwd")} Show current working directory`),console.log(` ${h.default.yellow("publish")} ${h.default.gray("<req id>")} Push the request branch and open a GitHub PR with its receipt`),console.log(` ${h.default.yellow("linear")} ${h.default.gray("<ENG-123>")} Import a Linear issue as a draft request`),console.log(` ${h.default.yellow("help")} Show this help`),console.log(` ${h.default.yellow("exit")} / ${h.default.yellow("quit")} Stop the server and exit`),console.log(""),console.log(h.default.gray(" Any other input is executed as a shell command in the current directory.")),console.log(""))}loadHistory(){try{if(c.default.existsSync(this.historyFile)){const e=c.default.readFileSync(this.historyFile,"utf-8")
360
+ this.history=e.split("\n").filter(e=>""!==e.trim()),this.history.length>500&&(this.history=this.history.slice(-500))}}catch{}}appendHistory(e){try{this.history.push(e),c.default.appendFileSync(this.historyFile,e+"\n")}catch{}}}}}