@pithosai/pithosai 1.0.2 → 1.0.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.
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- (()=>{"use strict";let e=require("node:fs/promises"),t=require("node:path"),r=require("marked"),n=require("../shims/chalk-cjs-shim.cjs"),i=function(){if("function"==typeof n.hex)return n;let e=n.default;return e&&"function"==typeof e.hex?e:n}(),l="#FF5A2D",a="#FF7A3D",s="#FFB020",o="string"==typeof process.env.FORCE_COLOR&&process.env.FORCE_COLOR.trim().length>0&&"0"!==process.env.FORCE_COLOR.trim(),h=process.env.NO_COLOR&&!o?new n.Chalk({level:0}):i,u={accent:h.hex(l),accentBright:h.hex(a),accentDim:h.hex("#D14A22"),info:h.hex("#FF8A5B"),success:h.hex("#2FBF71"),warn:h.hex(s),error:h.hex("#E23D2D"),muted:h.hex("#8B7F77"),heading:h.bold.hex(l),strong:h.bold.hex(a),command:h.hex(a),option:h.hex(s)},p=RegExp("\\x1b\\[[0-9;]*m","g"),m=RegExp("\\x1b\\]8;;.*?\\x1b\\\\|\\x1b\\]8;;\\x1b\\\\","g");function c(e){return 0===e||e<32||e>=127&&e<160||8205===e||8204===e||e>=65024&&e<=65039||e>=917760&&e<=917999||e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071?0:e>=127744&&e<=129791||e>=9728&&e<=10175||e>=65280&&e<=65519?2:e<4352?e>=12288&&e<=12351?2:1:e>=4352&&e<=4607||e>=11904&&e<=42191||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65040&&e<=65135||e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}function f(e){let t=e.replace(m,"").replace(p,""),r=0;for(let e=0;e<t.length;){let n=t.codePointAt(e)??0;r+=c(n),e+=n>65535?2:1}return r}function d(e,t){return t<=0?"":e.repeat(t)}let g="\x1b]8;;",x=!1;(async function(){let n=process.argv[2];n||(console.error("Usage: node scripts/render-markdown.js <path-to-file.md>"),process.exit(1));let i=(0,t.resolve)(process.cwd(),n);try{let t=await (0,e.readFile)(i,"utf-8"),n=function(e){if("string"!=typeof e||!e.trim())return e??"";x||(r.marked.use({renderer:{heading({tokens:e,depth:t}){let r=this.parser.parseInline(e),n=u.heading(r);return 1===t?`
3
- ${n}
4
- `:`${n}
5
- `},strong({tokens:e}){return u.strong(this.parser.parseInline(e))},em({tokens:e}){return u.muted(this.parser.parseInline(e))},codespan:({text:e})=>u.muted(e),link({tokens:e,href:t}){var r,n;return r=this.parser.parseInline(e),n=t??"",n?.trim()?h.level>0?`${g}${n}\x1b\\${r}${g}\x1b\\`:`${r} (${n})`:r},blockquote({tokens:e}){let t=this.parser.parse(e).trimEnd().split("\n").map(e=>u.muted("│ ")+e).join("\n");return`
6
- ${t}
7
-
8
- `},hr(){let e=Math.min(process.stdout?.columns??80,80)-2;return"\n"+u.muted("─".repeat(Math.max(0,e)))+"\n"},code({text:e,lang:t}){let r=(t??"").trim().toLowerCase(),n=/^(bash|sh|shell|zsh)$/.test(r),i=/^(javascript|js|typescript|ts|python|py|java|rust|rs|c|cpp|c\+\+)$/.test(r),l=n?u.command:i?u.info:u.muted,a=t?u.muted(`[${t}] `):"",s=e.replace(/\n$/,"").split("\n").map(e=>l(e)).join("\n");return`
9
- ${a}${s}
10
-
11
- `},list({items:e,ordered:t}){let r=e.map((e,r)=>{let n=t?`${r+1}. `:"• ";return this.listitem(e).trimEnd().split("\n").map((e,t)=>0===t?u.accent(n)+e:" "+e).join("\n")}).join("\n");return`
12
- ${r}
13
-
14
- `},listitem({tokens:e,task:t,checked:r}){return(t?u[r?"success":"muted"](r?"[x] ":"[ ] "):"")+this.parser.parse(e)},paragraph({tokens:e}){return this.parser.parseInline(e)+"\n\n"},table(e){let t=e?.header??[],r=e?.rows??[],n=e?.align,i=e=>e?null!=e.tokens?this.parser.parseInline(e.tokens):"string"==typeof e.text?e.text:String(e):"";if(!Array.isArray(t)||!Array.isArray(r)||0===t.length){let e=[t,...r].filter(Array.isArray).map(e=>e.map(i).join(" | ")).join("\n");return e?`
15
- ${u.muted(e)}
16
- `:"\n"}let l=t.length,a=t.map(i),s={left:"left",center:"center",right:"right"},o=a.map((e,t)=>({key:String(t),header:u.heading(e),align:s[n?.[t]]??"left"})),h=function(e){let t=e.rows.map(e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=null==n?"":String(n);return t}),r=e.border??"unicode";if("none"===r){let r=e.columns,n=[r.map(e=>e.header).join(" | "),...t.map(e=>r.map(t=>e[t.key]??"").join(" | "))];return`${n.join("\n")}
17
- `}let n=Math.max(0,e.padding??1),i=e.columns,l=i.map(e=>({headerW:f(e.header),cellW:Math.max(0,...t.map(t=>f(t[e.key]??"")))})),a=i.map((e,t)=>{let r=l[t],i=Math.max(r?.headerW??0,r?.cellW??0)+2*n,a=e.maxWidth?Math.min(i,e.maxWidth):i;return Math.max(e.minWidth??3,a)}),s=function(e){if(null!=e&&Number.isFinite(e)&&!(e<=0))return Math.floor(e)}(e.width),o=i.length+1,h=a.reduce((e,t)=>e+t,0)+o,u=e=>Math.max((l[e]?.headerW??0)+2*n,(l[e]?.cellW??0)+2*n,3),p=i.map((e,t)=>Math.max(e.minWidth??3,u(t))),m=i.map((e,t)=>u(t));if(s&&h>s){let e=h-s,t=i.map((e,t)=>({i:t,w:a[t]??0})).filter(({i:e})=>!!i[e]?.flex).sort((e,t)=>t.w-e.w).map(e=>e.i),r=i.map((e,t)=>({i:t,w:a[t]??0})).filter(({i:e})=>!i[e]?.flex).sort((e,t)=>t.w-e.w).map(e=>e.i),n=(t,r)=>{for(;e>0;){let n=!1;for(let i of t)if(!((a[i]??0)<=(r[i]??0))&&(a[i]=(a[i]??0)-1,n=!0,(e-=1)<=0))break;if(!n)break}};n(t,p),n(t,m),n(r,p),n(r,m)}if(s){let e=i.length+1,t=s-(a.reduce((e,t)=>e+t,0)+e);if(t>0){let e=i.map((e,t)=>({c:e,i:t})).filter(({c:e})=>!!e.flex).map(({i:e})=>e);if(e.length>0){let r=i.map(e=>"number"==typeof e.maxWidth&&e.maxWidth>0?Math.floor(e.maxWidth):1/0);for(;t>0;){let n=!1;for(let i of e)if(!((a[i]??0)>=(r[i]??1/0))&&(a[i]=(a[i]??0)+1,n=!0,(t-=1)<=0))break;if(!n)break}}}}let g="ascii"===r?{tl:"+",tr:"+",bl:"+",br:"+",h:"-",v:"|",t:"+",ml:"+",m:"+",mr:"+",b:"+"}:{tl:"┌",tr:"┐",bl:"└",br:"┘",h:"─",v:"│",t:"┬",ml:"├",m:"┼",mr:"┤",b:"┴"},x=(e,t,r)=>`${e}${a.map(e=>d(g.h,e)).join(t)}${r}`,$=e=>Math.max(1,a[e]-2*n),b=d(" ",n),k=(e,t=!1)=>{let r=i.map(r=>t?r.header:e[r.key]??"").map((e,t)=>(function(e,t){if(t<=0)return[e];let r=[];for(let t=0;t<e.length;){if("\x1b"===e[t]){if("["===e[t+1]){let n=t+2;for(;n<e.length;){let t=e[n];if("m"===t)break;if(t&&t>="0"&&t<="9"||";"===t){n+=1;continue}break}if("m"===e[n]){r.push({kind:"ansi",value:e.slice(t,n+1)}),t=n+1;continue}}if("]"===e[t+1]&&"8;;"===e.slice(t+2,t+5)){let n=e.indexOf("\x1b\\",t+5);if(n>=0){r.push({kind:"ansi",value:e.slice(t,n+2)}),t=n+2;continue}}}let n=e.codePointAt(t)??0,i=String.fromCodePoint(n);r.push({kind:"char",value:i,w:c(n)}),t+=n>65535?2:1}let n=r.findIndex(e=>"char"===e.kind);if(n<0)return[e];let i=-1;for(let e=r.length-1;e>=0;e-=1)if(r[e]?.kind==="char"){i=e;break}let l=r.slice(0,n).filter(e=>"ansi"===e.kind).map(e=>e.value).join(""),a=r.slice(i+1).filter(e=>"ansi"===e.kind).map(e=>e.value).join(""),s=r.slice(n,i+1),o=[],h=e=>" "===e||" "===e||"/"===e||"-"===e||"_"===e||"."===e,u=e=>" "===e||" "===e,p=[],m=0,f=null,d=e=>(e??p).map(e=>e.value).join(""),g=e=>{let t=e.replace(/\s+$/,"");0!==t.trim().length&&o.push(t)},x=e=>{if(0===p.length)return;if(null==e||e<=0){g(d()),p.length=0,m=0,f=null;return}let t=p.slice(0,e),r=p.slice(e);for(g(d(t));r.length>0&&r[0]?.kind==="char"&&u(r[0].value);)r.shift();p.length=0,p.push(...r),m=r.filter(e=>"char"===e.kind).reduce((e,t)=>e+(t.w??1),0),f=null};for(let e of s){if("ansi"===e.kind){p.push(e);continue}let r=e.value,n=e.w??1;if("\n"===r||"\r"===r){x(p.length);continue}m+n>t&&m>0&&x(f),p.push(e),m+=n,h(r)&&(f=p.length)}return(x(p.length),o.length)?l||a?o.map(e=>e?`${l}${e}${a}`:e):o:[""]})(e,$(t))),n=Math.max(...r.map(e=>e.length)),l=[];for(let e=0;e<n;e+=1){let t=r.map((t,r)=>{let n=function(e,t,r){let n=f(e);if(n>=t)return e;let i=t-n;if("right"===r)return`${d(" ",i)}${e}`;if("center"===r){let t=Math.floor(i/2),r=i-t;return`${d(" ",t)}${e}${d(" ",r)}`}return`${e}${d(" ",i)}`}(t[e]??"",$(r),i[r]?.align??"left");return`${b}${n}${b}`});l.push(`${g.v}${t.join(g.v)}${g.v}`)}return l},y=[];for(let e of(y.push(x(g.tl,g.t,g.tr)),y.push(...k({},!0)),y.push(x(g.ml,g.m,g.mr)),t))y.push(...k(e,!1));return y.push(x(g.bl,g.b,g.br)),`${y.join("\n")}
18
- `}({columns:o,rows:r.map(e=>{let t={},r=Array.isArray(e)?e:[];for(let e=0;e<l;e+=1)t[String(e)]=u.muted(i(r[e]));return t}),padding:1,border:"unicode"});return`
19
- ${h}
20
- `},tablerow:({text:e})=>e,tablecell({tokens:e}){return this.parser.parseInline(e)},br:()=>"\n",text(e){return e.tokens&&e.tokens.length>0?this.parser.parseInline(e.tokens):e.text??""},html:()=>"",checkbox:({checked:e})=>u[e?"success":"muted"](e?"[x]":"[ ]")+" "}}),r.marked.setOptions({gfm:!0,breaks:!0}),x=!0);let t="string"!=typeof e?"":e.trim().replace(/\r\n/g,"\n").replace(/\r/g,"\n");try{let e=r.marked.parse(t,{async:!1});return"string"==typeof e?e:String(e)}catch{return e}}(t);process.stdout.write(n),n.endsWith("\n")||process.stdout.write("\n")}catch(e){console.error(`Error: ${e.message}`),process.exit(1)}})(),module.exports={}})();