layrith 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/layrith.js +1 -0
  2. package/package.json +2 -2
package/layrith.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env bun
1
2
  // @bun
2
3
  var f8=Object.create;var{getPrototypeOf:d8,defineProperty:Q9,getOwnPropertyNames:$8}=Object;var p8=Object.prototype.hasOwnProperty;function i8(I){return this[I]}var Q8,n8,wG=(I,Z,b)=>{var G=I!=null&&typeof I==="object";if(G){var B=Z?Q8??=new WeakMap:n8??=new WeakMap,V=B.get(I);if(V)return V}b=I!=null?f8(d8(I)):{};let W=Z||!I||!I.__esModule?Q9(b,"default",{value:I,enumerable:!0}):b;for(let N of $8(I))if(!p8.call(W,N))Q9(W,N,{get:i8.bind(I,N),enumerable:!0});if(G)B.set(I,W);return W};var r=(I,Z)=>()=>(Z||I((Z={exports:{}}).exports,Z),Z.exports);var o8=(I)=>I;function r8(I,Z){this[I]=o8.bind(null,Z)}var aF=(I,Z)=>{for(var b in Z)Q9(I,b,{get:Z[b],enumerable:!0,configurable:!0,set:r8.bind(Z,b)})};var a=(I,Z)=>()=>(I&&(Z=I(I=0)),Z);var Cb=import.meta.require;var _0=r((a8)=>{class n9 extends Error{constructor(I,Z,b){super(b);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=Z,this.exitCode=I,this.nestedError=void 0}}class tF extends n9{constructor(I){super(1,"commander.invalidArgument",I);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}a8.CommanderError=n9;a8.InvalidArgumentError=tF});var UW=r((ZK)=>{var{InvalidArgumentError:e8}=_0();class sF{constructor(I,Z){switch(this.description=Z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,I[0]){case"<":this.required=!0,this._name=I.slice(1,-1);break;case"[":this.required=!1,this._name=I.slice(1,-1);break;default:this.required=!0,this._name=I;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(I,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[I];return Z.push(I),Z}default(I,Z){return this.defaultValue=I,this.defaultValueDescription=Z,this}argParser(I){return this.parseArg=I,this}choices(I){return this.argChoices=I.slice(),this.parseArg=(Z,b)=>{if(!this.argChoices.includes(Z))throw new e8(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,b);return Z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function IK(I){let Z=I.name()+(I.variadic===!0?"...":"");return I.required?"<"+Z+">":"["+Z+"]"}ZK.Argument=sF;ZK.humanReadableArgName=IK});var o9=r((VK)=>{var{humanReadableArgName:BK}=UW();class eF{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(I){this.helpWidth=this.helpWidth??I.helpWidth??80}visibleCommands(I){let Z=I.commands.filter((G)=>!G._hidden),b=I._getHelpCommand();if(b&&!b._hidden)Z.push(b);if(this.sortSubcommands)Z.sort((G,B)=>{return G.name().localeCompare(B.name())});return Z}compareOptions(I,Z){let b=(G)=>{return G.short?G.short.replace(/^-/,""):G.long.replace(/^--/,"")};return b(I).localeCompare(b(Z))}visibleOptions(I){let Z=I.options.filter((G)=>!G.hidden),b=I._getHelpOption();if(b&&!b.hidden){let G=b.short&&I._findOption(b.short),B=b.long&&I._findOption(b.long);if(!G&&!B)Z.push(b);else if(b.long&&!B)Z.push(I.createOption(b.long,b.description));else if(b.short&&!G)Z.push(I.createOption(b.short,b.description))}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleGlobalOptions(I){if(!this.showGlobalOptions)return[];let Z=[];for(let b=I.parent;b;b=b.parent){let G=b.options.filter((B)=>!B.hidden);Z.push(...G)}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleArguments(I){if(I._argsDescription)I.registeredArguments.forEach((Z)=>{Z.description=Z.description||I._argsDescription[Z.name()]||""});if(I.registeredArguments.find((Z)=>Z.description))return I.registeredArguments;return[]}subcommandTerm(I){let Z=I.registeredArguments.map((b)=>BK(b)).join(" ");return I._name+(I._aliases[0]?"|"+I._aliases[0]:"")+(I.options.length?" [options]":"")+(Z?" "+Z:"")}optionTerm(I){return I.flags}argumentTerm(I){return I.name()}longestSubcommandTermLength(I,Z){return Z.visibleCommands(I).reduce((b,G)=>{return Math.max(b,this.displayWidth(Z.styleSubcommandTerm(Z.subcommandTerm(G))))},0)}longestOptionTermLength(I,Z){return Z.visibleOptions(I).reduce((b,G)=>{return Math.max(b,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(G))))},0)}longestGlobalOptionTermLength(I,Z){return Z.visibleGlobalOptions(I).reduce((b,G)=>{return Math.max(b,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(G))))},0)}longestArgumentTermLength(I,Z){return Z.visibleArguments(I).reduce((b,G)=>{return Math.max(b,this.displayWidth(Z.styleArgumentTerm(Z.argumentTerm(G))))},0)}commandUsage(I){let Z=I._name;if(I._aliases[0])Z=Z+"|"+I._aliases[0];let b="";for(let G=I.parent;G;G=G.parent)b=G.name()+" "+b;return b+Z+" "+I.usage()}commandDescription(I){return I.description()}subcommandDescription(I){return I.summary()||I.description()}optionDescription(I){let Z=[];if(I.argChoices)Z.push(`choices: ${I.argChoices.map((b)=>JSON.stringify(b)).join(", ")}`);if(I.defaultValue!==void 0){if(I.required||I.optional||I.isBoolean()&&typeof I.defaultValue==="boolean")Z.push(`default: ${I.defaultValueDescription||JSON.stringify(I.defaultValue)}`)}if(I.presetArg!==void 0&&I.optional)Z.push(`preset: ${JSON.stringify(I.presetArg)}`);if(I.envVar!==void 0)Z.push(`env: ${I.envVar}`);if(Z.length>0){let b=`(${Z.join(", ")})`;if(I.description)return`${I.description} ${b}`;return b}return I.description}argumentDescription(I){let Z=[];if(I.argChoices)Z.push(`choices: ${I.argChoices.map((b)=>JSON.stringify(b)).join(", ")}`);if(I.defaultValue!==void 0)Z.push(`default: ${I.defaultValueDescription||JSON.stringify(I.defaultValue)}`);if(Z.length>0){let b=`(${Z.join(", ")})`;if(I.description)return`${I.description} ${b}`;return b}return I.description}formatItemList(I,Z,b){if(Z.length===0)return[];return[b.styleTitle(I),...Z,""]}groupItems(I,Z,b){let G=new Map;return I.forEach((B)=>{let V=b(B);if(!G.has(V))G.set(V,[])}),Z.forEach((B)=>{let V=b(B);if(!G.has(V))G.set(V,[]);G.get(V).push(B)}),G}formatHelp(I,Z){let b=Z.padWidth(I,Z),G=Z.helpWidth??80;function B(H,F){return Z.formatItem(H,b,F,Z)}let V=[`${Z.styleTitle("Usage:")} ${Z.styleUsage(Z.commandUsage(I))}`,""],W=Z.commandDescription(I);if(W.length>0)V=V.concat([Z.boxWrap(Z.styleCommandDescription(W),G),""]);let N=Z.visibleArguments(I).map((H)=>{return B(Z.styleArgumentTerm(Z.argumentTerm(H)),Z.styleArgumentDescription(Z.argumentDescription(H)))});if(V=V.concat(this.formatItemList("Arguments:",N,Z)),this.groupItems(I.options,Z.visibleOptions(I),(H)=>H.helpGroupHeading??"Options:").forEach((H,F)=>{let C=H.map((S)=>{return B(Z.styleOptionTerm(Z.optionTerm(S)),Z.styleOptionDescription(Z.optionDescription(S)))});V=V.concat(this.formatItemList(F,C,Z))}),Z.showGlobalOptions){let H=Z.visibleGlobalOptions(I).map((F)=>{return B(Z.styleOptionTerm(Z.optionTerm(F)),Z.styleOptionDescription(Z.optionDescription(F)))});V=V.concat(this.formatItemList("Global Options:",H,Z))}return this.groupItems(I.commands,Z.visibleCommands(I),(H)=>H.helpGroup()||"Commands:").forEach((H,F)=>{let C=H.map((S)=>{return B(Z.styleSubcommandTerm(Z.subcommandTerm(S)),Z.styleSubcommandDescription(Z.subcommandDescription(S)))});V=V.concat(this.formatItemList(F,C,Z))}),V.join(`
3
4
  `)}displayWidth(I){return I5(I).length}styleTitle(I){return I}styleUsage(I){return I.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z==="[command]")return this.styleSubcommandText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleCommandText(Z)}).join(" ")}styleCommandDescription(I){return this.styleDescriptionText(I)}styleOptionDescription(I){return this.styleDescriptionText(I)}styleSubcommandDescription(I){return this.styleDescriptionText(I)}styleArgumentDescription(I){return this.styleDescriptionText(I)}styleDescriptionText(I){return I}styleOptionTerm(I){return this.styleOptionText(I)}styleSubcommandTerm(I){return I.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleSubcommandText(Z)}).join(" ")}styleArgumentTerm(I){return this.styleArgumentText(I)}styleOptionText(I){return I}styleArgumentText(I){return I}styleSubcommandText(I){return I}styleCommandText(I){return I}padWidth(I,Z){return Math.max(Z.longestOptionTermLength(I,Z),Z.longestGlobalOptionTermLength(I,Z),Z.longestSubcommandTermLength(I,Z),Z.longestArgumentTermLength(I,Z))}preformatted(I){return/\n[^\S\r\n]/.test(I)}formatItem(I,Z,b,G){let V=" ".repeat(2);if(!b)return V+I;let W=I.padEnd(Z+I.length-G.displayWidth(I)),N=2,R=(this.helpWidth??80)-Z-N-2,H;if(R<this.minWidthToWrap||G.preformatted(b))H=b;else H=G.boxWrap(b,R).replace(/\n/g,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layrith",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "module": "layrith.js",
5
5
  "type": "module",
6
6
  "private": false,
@@ -17,7 +17,7 @@
17
17
  "dev": "bun run index.ts",
18
18
  "chat": "bun run index.ts chat",
19
19
  "embed:prompts": "node ./scripts/embed-system-prompts.mjs",
20
- "build": "bun run embed:prompts && bun build ./index.ts --outfile ./layrith.js --target bun --format esm --minify",
20
+ "build": "bun run embed:prompts && bun build ./index.ts --outfile ./layrith.js --target bun --format esm --minify --banner \"#!/usr/bin/env bun\"",
21
21
  "prepack": "bun run build",
22
22
  "web:dev": "bun --cwd web run dev",
23
23
  "web:build": "bun --cwd web run build"