jaz-clio 4.48.6 → 4.48.7
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/cli.mjs +1 -1
- package/package.json +6 -2
- package/postinstall.mjs +8 -0
package/cli.mjs
CHANGED
|
@@ -358,7 +358,7 @@ Run `+Re.cyan("{updateCommand}")+" to update",i=t.message||o;t.boxenOptions??={p
|
|
|
358
358
|
${t}`,vW=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),SW=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),EW=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,o=bW.bind(null,n,t.toString());Object.defineProperty(o,"name",SW);let{writable:i,enumerable:s,configurable:a}=vW;Object.defineProperty(e,"toString",{value:o,writable:i,enumerable:s,configurable:a})};function xE(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:n}=e;for(let o of Reflect.ownKeys(t))gW(e,t,o,r);return DW(e,t),EW(e,t,n),e}var Em=new WeakMap,Pk=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0,o=e.displayName||e.name||"<anonymous>",i=function(...s){if(Em.set(i,++n),n===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return xE(i,e),Em.set(i,n),i};Pk.callCount=e=>{if(!Em.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Em.get(e)};var Lk=Pk;var Bs=[];Bs.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bs.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bs.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var _m=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",AE=Symbol.for("signal-exit emitter"),$E=globalThis,_W=Object.defineProperty.bind(Object),OE=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if($E[AE])return $E[AE];_W($E,AE,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let n=this.listeners[t],o=n.indexOf(r);o!==-1&&(o===0&&n.length===1?n.length=0:n.splice(o,1))}emit(t,r,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let o=!1;for(let i of this.listeners[t])o=i(r,n)===!0||o;return t==="exit"&&(o=this.emit("afterExit",r,n)||o),o}},Im=class{},IW=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),TE=class extends Im{onExit(){return()=>{}}load(){}unload(){}},NE=class extends Im{#n=FE.platform==="win32"?"SIGINT":"SIGHUP";#o=new OE;#t;#r;#e;#i={};#s=!1;constructor(t){super(),this.#t=t,this.#i={};for(let r of Bs)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:o}=this.#o,i=t;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(o+=i.__signal_exit_emitter__.count),n.length===o){this.unload();let s=this.#o.emit("exit",null,r),a=r==="SIGHUP"?this.#n:r;s||t.kill(t.pid,a)}};this.#e=t.reallyExit,this.#r=t.emit}onExit(t,r){if(!_m(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#o.on(n,t),()=>{this.#o.removeListener(n,t),this.#o.listeners.exit.length===0&&this.#o.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#o.count+=1;for(let t of Bs)try{let r=this.#i[t];r&&this.#t.on(t,r)}catch{}this.#t.emit=(t,...r)=>this.#d(t,...r),this.#t.reallyExit=t=>this.#a(t)}}unload(){this.#s&&(this.#s=!1,Bs.forEach(t=>{let r=this.#i[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,r)}catch{}}),this.#t.emit=this.#r,this.#t.reallyExit=this.#e,this.#o.count-=1)}#a(t){return _m(this.#t)?(this.#t.exitCode=t||0,this.#o.emit("exit",this.#t.exitCode,null),this.#e.call(this.#t,this.#t.exitCode)):0}#d(t,...r){let n=this.#r;if(t==="exit"&&_m(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let o=n.call(this.#t,t,...r);return this.#o.emit("exit",this.#t.exitCode,null),o}else return n.call(this.#t,t,...r)}},FE=globalThis.process,{onExit:Mk,load:a_e,unload:c_e}=IW(_m(FE)?new NE(FE):new TE);var jk=wm.stderr.isTTY?wm.stderr:wm.stdout.isTTY?wm.stdout:void 0,wW=jk?Lk(()=>{Mk(()=>{jk.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Bk=wW;var Cm=!1,sc={};sc.show=(e=qk.stderr)=>{e.isTTY&&(Cm=!1,e.write("\x1B[?25h"))};sc.hide=(e=qk.stderr)=>{e.isTTY&&(Bk(),Cm=!0,e.write("\x1B[?25l"))};sc.toggle=(e,t)=>{e!==void 0&&(Cm=e),Cm?sc.show(t):sc.hide(t)};var ac=sc;var Dl=vt(kE(),1);Za();import ao from"node:process";function RE(){return ao.platform!=="win32"?ao.env.TERM!=="linux":!!ao.env.CI||!!ao.env.WT_SESSION||!!ao.env.TERMINUS_SUBLIME||ao.env.ConEmuTask==="{cmd::Cmder}"||ao.env.TERM_PROGRAM==="Terminus-Sublime"||ao.env.TERM_PROGRAM==="vscode"||ao.env.TERM==="xterm-256color"||ao.env.TERM==="alacritty"||ao.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var xW={info:Re.blue("\u2139"),success:Re.green("\u2714"),warning:Re.yellow("\u26A0"),error:Re.red("\u2716")},AW={info:Re.blue("i"),success:Re.green("\u221A"),warning:Re.yellow("\u203C"),error:Re.red("\xD7")},$W=RE()?xW:AW,gl=$W;function PE({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}LE();import Lo from"node:process";var OW=3,ME=class{#n=0;start(){this.#n++,this.#n===1&&this.#o()}stop(){if(this.#n<=0)throw new Error("`stop` called more times than `start`");this.#n--,this.#n===0&&this.#t()}#o(){Lo.platform==="win32"||!Lo.stdin.isTTY||(Lo.stdin.setRawMode(!0),Lo.stdin.on("data",this.#r),Lo.stdin.resume())}#t(){Lo.stdin.isTTY&&(Lo.stdin.off("data",this.#r),Lo.stdin.pause(),Lo.stdin.setRawMode(!1))}#r(t){t[0]===OW&&Lo.emit("SIGINT")}},TW=new ME,jE=TW;var NW=vt(kE(),1),BE=class{#n=0;#o=!1;#t=0;#r=-1;#e=0;#i;#s;#a;#d;#g;#p;#l;#c;#m;#f;#u;color;constructor(t){typeof t=="string"&&(t={text:t}),this.#i={color:"cyan",stream:Am.stderr,discardStdin:!0,hideCursor:!0,...t},this.color=this.#i.color,this.spinner=this.#i.spinner,this.#g=this.#i.interval,this.#a=this.#i.stream,this.#p=typeof this.#i.isEnabled=="boolean"?this.#i.isEnabled:PE({stream:this.#a}),this.#l=typeof this.#i.isSilent=="boolean"?this.#i.isSilent:!1,this.text=this.#i.text,this.prefixText=this.#i.prefixText,this.suffixText=this.#i.suffixText,this.indent=this.#i.indent,Am.env.NODE_ENV==="test"&&(this._stream=this.#a,this._isEnabled=this.#p,Object.defineProperty(this,"_linesToClear",{get(){return this.#n},set(r){this.#n=r}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#r}}),Object.defineProperty(this,"_lineCount",{get(){return this.#t}}))}get indent(){return this.#c}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");this.#c=t,this.#D()}get interval(){return this.#g??this.#s.interval??100}get spinner(){return this.#s}set spinner(t){if(this.#r=-1,this.#g=void 0,typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#s=t}else if(!yl())this.#s=Dl.default.line;else if(t===void 0)this.#s=Dl.default.dots;else if(t!=="default"&&Dl.default[t])this.#s=Dl.default[t];else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#m}set text(t=""){this.#m=t,this.#D()}get prefixText(){return this.#f}set prefixText(t=""){this.#f=t,this.#D()}get suffixText(){return this.#u}set suffixText(t=""){this.#u=t,this.#D()}get isSpinning(){return this.#d!==void 0}#h(t=this.#f,r=" "){return typeof t=="string"&&t!==""?t+r:typeof t=="function"?t()+r:""}#y(t=this.#u,r=" "){return typeof t=="string"&&t!==""?r+t:typeof t=="function"?r+t():""}#D(){let t=this.#a.columns??80,r=this.#h(this.#f,"-"),n=this.#y(this.#u,"-"),o=" ".repeat(this.#c)+r+"--"+this.#m+"--"+n;this.#t=0;for(let i of _n(o).split(`
|
|
359
359
|
`))this.#t+=Math.max(1,Math.ceil(Dr(i,{countAnsiEscapeCodes:!0})/t))}get isEnabled(){return this.#p&&!this.#l}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#p=t}get isSilent(){return this.#l}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#l=t}frame(){let t=Date.now();(this.#r===-1||t-this.#e>=this.interval)&&(this.#r=++this.#r%this.#s.frames.length,this.#e=t);let{frames:r}=this.#s,n=r[this.#r];this.color&&(n=Re[this.color](n));let o=typeof this.#f=="string"&&this.#f!==""?this.#f+" ":"",i=typeof this.text=="string"?" "+this.text:"",s=typeof this.#u=="string"&&this.#u!==""?" "+this.#u:"";return o+n+i+s}clear(){if(!this.#p||!this.#a.isTTY)return this;this.#a.cursorTo(0);for(let t=0;t<this.#n;t++)t>0&&this.#a.moveCursor(0,-1),this.#a.clearLine(1);return(this.#c||this.lastIndent!==this.#c)&&this.#a.cursorTo(this.#c),this.lastIndent=this.#c,this.#n=0,this}render(){return this.#l?this:(this.clear(),this.#a.write(this.frame()),this.#n=this.#t,this)}start(t){return t&&(this.text=t),this.#l?this:this.#p?this.isSpinning?this:(this.#i.hideCursor&&ac.hide(this.#a),this.#i.discardStdin&&Am.stdin.isTTY&&(this.#o=!0,jE.start()),this.render(),this.#d=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#a.write(`- ${this.text}
|
|
360
360
|
`),this)}stop(){return this.#p?(clearInterval(this.#d),this.#d=void 0,this.#r=0,this.clear(),this.#i.hideCursor&&ac.show(this.#a),this.#i.discardStdin&&Am.stdin.isTTY&&this.#o&&(jE.stop(),this.#o=!1),this):this}succeed(t){return this.stopAndPersist({symbol:gl.success,text:t})}fail(t){return this.stopAndPersist({symbol:gl.error,text:t})}warn(t){return this.stopAndPersist({symbol:gl.warning,text:t})}info(t){return this.stopAndPersist({symbol:gl.info,text:t})}stopAndPersist(t={}){if(this.#l)return this;let r=t.prefixText??this.#f,n=this.#h(r," "),o=t.symbol??" ",i=t.text??this.text,a=typeof i=="string"?(o?" ":"")+i:"",c=t.suffixText??this.#u,u=this.#y(c," "),l=n+o+a+u+`
|
|
361
|
-
`;return this.stop(),this.#a.write(l),this}};function Ti(e){return new BE(e)}Zs();var Ws=["jaz-api","jaz-cli","jaz-conversion","jaz-recipes","jaz-jobs","all"],pc={"jaz-api":"Jaz REST API reference \u2014 117 rules, endpoint catalog, error catalog, field mapping","jaz-cli":"CLI command reference \u2014 auth, output formats, pagination, entity resolution, workflows","jaz-conversion":"Data conversion pipeline \u2014 Xero, QuickBooks, Sage, Excel migration to Jaz","jaz-recipes":"Complex accounting recipes \u2014 prepaid, deferred revenue, loans, IFRS 16, depreciation","jaz-jobs":"Accounting job blueprints \u2014 month/quarter/year-end close + 9 ad-hoc operational workflows"};import{mkdir as jH,cp as BH,rm as qH,access as zH}from"node:fs/promises";import{join as un,dirname as UH}from"node:path";import{fileURLToPath as YH}from"node:url";var JH=UH(YH(import.meta.url)),GH=un(JH,"..","..","assets"),VH=["jaz-api","jaz-cli","jaz-conversion","jaz-recipes","jaz-jobs"],ZH={"jaz-api":"api","jaz-cli":"cli","jaz-conversion":"conversion","jaz-recipes":"transaction-recipes","jaz-jobs":"jobs"};async function Cn(e){try{return await zH(e),!0}catch{return!1}}async function S_(e){return await Cn(un(e,".claude","skills"))?"claude":await Cn(un(e,".agents","skills"))?"agents":await Cn(un(e,".claude"))?"claude":await Cn(un(e,".codex"))||await Cn(un(e,".antigravity"))||await Cn(un(e,".cursor"))||await Cn(un(e,".copilot"))||await Cn(un(e,".windsurf"))||await Cn(un(e,".goose"))?"agents":await Cn(un(e,"CLAUDE.md"))?"claude":(await Cn(un(e,"AGENTS.md")),"agents")}function WH(e){return e==="claude"?".claude/skills":".agents/skills"}async function HH(e,t,r,n){let o=ZH[t],i=un(GH,"skills",o),s=WH(n),a=un(e,s,o);if(!await Cn(i))throw new Error(`Skill source not found: ${i}`);if(await Cn(a)){if(!r)throw new Error(`${a} already exists. Use --force to overwrite.`);await qH(a,{recursive:!0,force:!0})}return await jH(a,{recursive:!0}),await BH(i,a,{recursive:!0,force:!0}),`${s}/${o}`}async function Zm(e,t,r=!1,n="auto"){let o=n==="claude"?"claude":n==="auto"?await S_(e):"agents",i=t==="all"?VH:[t],s=[];for(let a of i){let c=await HH(e,a,r,o);s.push(c)}return s}oe();var dn={title(e){console.log(),console.log(`${we}${H(e)}`),console.log(`${we}${x(gt.horizontal.repeat(e.length))}`),console.log()},info(e){console.log(`${we}${zn(Wr.info)} ${e}`)},success(e){console.log(`${we}${O(Wr.tick)} ${e}`)},warn(e){console.log(`${we}${K(Wr.warning)} ${e}`)},error(e){console.log(`${we}${F(Wr.cross)} ${e}`)},step(e,t){console.log(`${we}${x(`${e}.`)} ${t}`)},divider(){let e=process.stdout.columns?Math.min(process.stdout.columns-4,60):40;console.log(`${we}${x(gt.horizontal.repeat(e))}`)},blank(){console.log()}};oe();async function TR(e){dn.title("Clio \u2014 Skill Installer");let t=e.skill??"all";if(!e.skill){let s=await Gs({message:"Which skills do you want to install?",options:[{label:"All (Recommended)",hint:"API reference + CLI + data conversion + transaction recipes + accounting jobs",value:"all"},{label:"API only",hint:pc["jaz-api"],value:"jaz-api"},{label:"CLI only",hint:pc["jaz-cli"],value:"jaz-cli"},{label:"Conversion only",hint:pc["jaz-conversion"],value:"jaz-conversion"},{label:"Transaction Recipes only",hint:pc["jaz-recipes"],value:"jaz-recipes"},{label:"Jobs only",hint:pc["jaz-jobs"],value:"jaz-jobs"}],initialValue:"all"});if(sr(s)){dn.warn("Installation cancelled");return}t=s}let r=t==="all"?"jaz-api + jaz-cli + jaz-conversion + jaz-recipes + jaz-jobs":t;dn.info(`Installing: ${H(r)}`);let n=Ti("Installing skill files...").start(),o=process.cwd(),i=e.platform??"auto";try{if(i==="auto"){let a=await S_(o);n.text=`Detected platform: ${a==="claude"?"Claude Code":"Agent Skills (universal)"}`}n.text="Copying skill files...";let s=await Zm(o,t,e.force??!1,i);n.succeed("Skills installed!"),console.log(),dn.info("Installed:"),s.forEach(a=>{console.log(` ${O("+")} ${a}/`)}),console.log(),dn.success("Clio \u2014 Jaz AI skills installed successfully!"),console.log(),console.log(E("Next steps:")),console.log(x(" 1. Restart your AI tool (Claude Code, Antigravity, Codex, Copilot, Cursor, etc.)")),console.log(x(' 2. Try: "Create an invoice with line items and tax"')),(t==="all"||t==="jaz-conversion")&&console.log(x(' 3. Try: "Convert this Xero trial balance to Jaz"')),console.log(),console.log(x(` Docs: ${E_("https://help.jaz.ai")}`)),console.log()}catch(s){n.fail("Installation failed"),s instanceof Error&&dn.error(s.message),process.exit(1)}}oe();var rK="teamjaz",nK="jaz-ai",oK="https://api.github.com",fc=class extends Error{constructor(t){super(t),this.name="GitHubRateLimitError"}},w_=class extends Error{constructor(t){super(t),this.name="GitHubDownloadError"}};function iK(e){let t=e.headers.get("x-ratelimit-remaining");if(e.status===403&&t==="0"){let r=e.headers.get("x-ratelimit-reset"),n=r?new Date(parseInt(r)*1e3).toLocaleTimeString():"unknown";throw new fc(`GitHub API rate limit exceeded. Resets at ${n}`)}if(e.status===429)throw new fc("GitHub API rate limit exceeded (429 Too Many Requests)")}async function NR(){let e=`${oK}/repos/${rK}/${nK}/releases`,t=await fetch(e,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"jaz-clio"}});if(iK(t),!t.ok)throw new w_(`Failed to fetch releases: ${t.status} ${t.statusText}`);return t.json()}async function FR(){dn.title("Clio \u2014 Available Versions");let e=Ti("Fetching versions from GitHub...").start();try{let t=await NR();if(t.length===0){e.warn("No releases found");return}e.succeed(`Found ${t.length} version(s)`),console.log(),t.forEach((r,n)=>{let o=r.tag_name,i=new Date(r.published_at).toLocaleDateString(),s=n===0?O(" (latest)"):"";console.log(` ${H(o)}${s} ${x(i)}`)}),console.log()}catch(t){t instanceof fc?e.fail("GitHub rate limit reached. Try again later."):t instanceof Error&&e.fail(`Failed to fetch versions: ${t.message}`),process.exit(1)}}oe();import{execFileSync as kR}from"node:child_process";async function RR(e){dn.title("Clio \u2014 Update");let t=Ti("Checking for CLI updates...").start();try{let{readFileSync:o}=await import("node:fs"),{join:i,dirname:s}=await import("node:path"),{fileURLToPath:a}=await import("node:url"),c=i(s(a(import.meta.url)),"..","..","package.json"),u=JSON.parse(o(c,"utf-8")).version,l=kR("npm",["view","jaz-clio","version"],{encoding:"utf-8"}).trim();u===l?t.succeed(`CLI is up to date (v${u})`):(t.text=`Updating CLI v${u} \u2192 v${l}...`,kR("npm",["install","-g","jaz-clio@latest"],{stdio:"pipe"}),t.succeed(`CLI updated to v${l}`))}catch{t.warn("CLI self-update skipped (run manually: npm update -g jaz-clio)")}let r=e.skill??"all",n=Ti("Updating skill files...").start();try{let o=await Zm(process.cwd(),r,!0);n.succeed("Skills updated!"),console.log(),dn.info("Updated:"),o.forEach(i=>{console.log(` ${O("+")} ${i}/`)}),console.log(),dn.success("
|
|
361
|
+
`;return this.stop(),this.#a.write(l),this}};function Ti(e){return new BE(e)}Zs();var Ws=["jaz-api","jaz-cli","jaz-conversion","jaz-recipes","jaz-jobs","all"],pc={"jaz-api":"Jaz REST API reference \u2014 117 rules, endpoint catalog, error catalog, field mapping","jaz-cli":"CLI command reference \u2014 auth, output formats, pagination, entity resolution, workflows","jaz-conversion":"Data conversion pipeline \u2014 Xero, QuickBooks, Sage, Excel migration to Jaz","jaz-recipes":"Complex accounting recipes \u2014 prepaid, deferred revenue, loans, IFRS 16, depreciation","jaz-jobs":"Accounting job blueprints \u2014 month/quarter/year-end close + 9 ad-hoc operational workflows"};import{mkdir as jH,cp as BH,rm as qH,access as zH}from"node:fs/promises";import{join as un,dirname as UH}from"node:path";import{fileURLToPath as YH}from"node:url";var JH=UH(YH(import.meta.url)),GH=un(JH,"..","..","assets"),VH=["jaz-api","jaz-cli","jaz-conversion","jaz-recipes","jaz-jobs"],ZH={"jaz-api":"api","jaz-cli":"cli","jaz-conversion":"conversion","jaz-recipes":"transaction-recipes","jaz-jobs":"jobs"};async function Cn(e){try{return await zH(e),!0}catch{return!1}}async function S_(e){return await Cn(un(e,".claude","skills"))?"claude":await Cn(un(e,".agents","skills"))?"agents":await Cn(un(e,".claude"))?"claude":await Cn(un(e,".codex"))||await Cn(un(e,".antigravity"))||await Cn(un(e,".cursor"))||await Cn(un(e,".copilot"))||await Cn(un(e,".windsurf"))||await Cn(un(e,".goose"))?"agents":await Cn(un(e,"CLAUDE.md"))?"claude":(await Cn(un(e,"AGENTS.md")),"agents")}function WH(e){return e==="claude"?".claude/skills":".agents/skills"}async function HH(e,t,r,n){let o=ZH[t],i=un(GH,"skills",o),s=WH(n),a=un(e,s,o);if(!await Cn(i))throw new Error(`Skill source not found: ${i}`);if(await Cn(a)){if(!r)throw new Error(`${a} already exists. Use --force to overwrite.`);await qH(a,{recursive:!0,force:!0})}return await jH(a,{recursive:!0}),await BH(i,a,{recursive:!0,force:!0}),`${s}/${o}`}async function Zm(e,t,r=!1,n="auto"){let o=n==="claude"?"claude":n==="auto"?await S_(e):"agents",i=t==="all"?VH:[t],s=[];for(let a of i){let c=await HH(e,a,r,o);s.push(c)}return s}oe();var dn={title(e){console.log(),console.log(`${we}${H(e)}`),console.log(`${we}${x(gt.horizontal.repeat(e.length))}`),console.log()},info(e){console.log(`${we}${zn(Wr.info)} ${e}`)},success(e){console.log(`${we}${O(Wr.tick)} ${e}`)},warn(e){console.log(`${we}${K(Wr.warning)} ${e}`)},error(e){console.log(`${we}${F(Wr.cross)} ${e}`)},step(e,t){console.log(`${we}${x(`${e}.`)} ${t}`)},divider(){let e=process.stdout.columns?Math.min(process.stdout.columns-4,60):40;console.log(`${we}${x(gt.horizontal.repeat(e))}`)},blank(){console.log()}};oe();async function TR(e){dn.title("Clio \u2014 Skill Installer");let t=e.skill??"all";if(!e.skill){let s=await Gs({message:"Which skills do you want to install?",options:[{label:"All (Recommended)",hint:"API reference + CLI + data conversion + transaction recipes + accounting jobs",value:"all"},{label:"API only",hint:pc["jaz-api"],value:"jaz-api"},{label:"CLI only",hint:pc["jaz-cli"],value:"jaz-cli"},{label:"Conversion only",hint:pc["jaz-conversion"],value:"jaz-conversion"},{label:"Transaction Recipes only",hint:pc["jaz-recipes"],value:"jaz-recipes"},{label:"Jobs only",hint:pc["jaz-jobs"],value:"jaz-jobs"}],initialValue:"all"});if(sr(s)){dn.warn("Installation cancelled");return}t=s}let r=t==="all"?"jaz-api + jaz-cli + jaz-conversion + jaz-recipes + jaz-jobs":t;dn.info(`Installing: ${H(r)}`);let n=Ti("Installing skill files...").start(),o=process.cwd(),i=e.platform??"auto";try{if(i==="auto"){let a=await S_(o);n.text=`Detected platform: ${a==="claude"?"Claude Code":"Agent Skills (universal)"}`}n.text="Copying skill files...";let s=await Zm(o,t,e.force??!1,i);n.succeed("Skills installed!"),console.log(),dn.info("Installed:"),s.forEach(a=>{console.log(` ${O("+")} ${a}/`)}),console.log(),dn.success("Clio \u2014 Jaz AI skills installed successfully!"),console.log(),console.log(E("Next steps:")),console.log(x(" 1. Restart your AI tool (Claude Code, Antigravity, Codex, Copilot, Cursor, etc.)")),console.log(x(' 2. Try: "Create an invoice with line items and tax"')),(t==="all"||t==="jaz-conversion")&&console.log(x(' 3. Try: "Convert this Xero trial balance to Jaz"')),console.log(),console.log(x(` Docs: ${E_("https://help.jaz.ai")}`)),console.log()}catch(s){n.fail("Installation failed"),s instanceof Error&&dn.error(s.message),process.exit(1)}}oe();var rK="teamjaz",nK="jaz-ai",oK="https://api.github.com",fc=class extends Error{constructor(t){super(t),this.name="GitHubRateLimitError"}},w_=class extends Error{constructor(t){super(t),this.name="GitHubDownloadError"}};function iK(e){let t=e.headers.get("x-ratelimit-remaining");if(e.status===403&&t==="0"){let r=e.headers.get("x-ratelimit-reset"),n=r?new Date(parseInt(r)*1e3).toLocaleTimeString():"unknown";throw new fc(`GitHub API rate limit exceeded. Resets at ${n}`)}if(e.status===429)throw new fc("GitHub API rate limit exceeded (429 Too Many Requests)")}async function NR(){let e=`${oK}/repos/${rK}/${nK}/releases`,t=await fetch(e,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"jaz-clio"}});if(iK(t),!t.ok)throw new w_(`Failed to fetch releases: ${t.status} ${t.statusText}`);return t.json()}async function FR(){dn.title("Clio \u2014 Available Versions");let e=Ti("Fetching versions from GitHub...").start();try{let t=await NR();if(t.length===0){e.warn("No releases found");return}e.succeed(`Found ${t.length} version(s)`),console.log(),t.forEach((r,n)=>{let o=r.tag_name,i=new Date(r.published_at).toLocaleDateString(),s=n===0?O(" (latest)"):"";console.log(` ${H(o)}${s} ${x(i)}`)}),console.log()}catch(t){t instanceof fc?e.fail("GitHub rate limit reached. Try again later."):t instanceof Error&&e.fail(`Failed to fetch versions: ${t.message}`),process.exit(1)}}oe();import{execFileSync as kR}from"node:child_process";async function RR(e){dn.title("Clio \u2014 Update");let t=Ti("Checking for CLI updates...").start();try{let{readFileSync:o}=await import("node:fs"),{join:i,dirname:s}=await import("node:path"),{fileURLToPath:a}=await import("node:url"),c=i(s(a(import.meta.url)),"..","..","package.json"),u=JSON.parse(o(c,"utf-8")).version,l=kR("npm",["view","jaz-clio","version"],{encoding:"utf-8"}).trim();u===l?t.succeed(`CLI is up to date (v${u})`):(t.text=`Updating CLI v${u} \u2192 v${l}...`,kR("npm",["install","-g","jaz-clio@latest"],{stdio:"pipe"}),t.succeed(`CLI updated to v${l}`))}catch{t.warn("CLI self-update skipped (run manually: npm update -g jaz-clio)")}let r=e.skill??"all",n=Ti("Updating skill files...").start();try{let o=await Zm(process.cwd(),r,!0);n.succeed("Skills updated!"),console.log(),dn.info("Updated:"),o.forEach(i=>{console.log(` ${O("+")} ${i}/`)}),console.log(),dn.success("All up to date. Run: clio --help"),console.log()}catch(o){n.fail("Skill update failed"),o instanceof Error&&dn.error(o.message),process.exit(1)}}oe();var HR=vt(wl(),1);function $(e){return Math.round(e*100)/100}function cr(e,t){let r=e.split("-");if(r.length!==3)throw new Error(`Invalid date format: ${e}`);let[n,o,i]=r.map(Number);if(!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(i))throw new Error(`Invalid date: ${e}`);let s=o-1+t,a=n+Math.floor(s/12),c=(s%12+12)%12,u=new Date(Date.UTC(a,c+1,0)).getUTCDate(),l=Math.min(i,u);return`${String(a).padStart(4,"0")}-${String(c+1).padStart(2,"0")}-${String(l).padStart(2,"0")}`}var Oe=class extends Error{constructor(t){super(t),this.name="CalcValidationError"}};function ct(e,t){if(!Number.isFinite(e)||e<=0)throw new Oe(`${t} must be a positive number (got ${e})`)}function Bo(e,t){if(!Number.isFinite(e)||e<0)throw new Oe(`${t} must be zero or positive (got ${e})`)}function Zt(e,t){if(!Number.isInteger(e)||e<1)throw new Oe(`${t} must be a positive integer (got ${e})`)}function Hm(e,t){if(e>=t)throw new Oe(`Salvage value (${e}) must be less than cost (${t})`)}function Ut(e){if(!e)return;if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Oe(`Date must be YYYY-MM-DD format (got "${e}")`);let t=new Date(e+"T00:00:00");if(isNaN(t.getTime()))throw new Oe(`Invalid date: "${e}"`)}function ki(e,t="Rate"){Bo(e,t),e>100&&process.stderr.write(`Warning: ${t} is ${e}% \u2014 are you sure this isn't a decimal? (e.g. 6 for 6%, not 0.06)
|
|
362
362
|
`)}function JR(e){if(!e||typeof e!="object")throw new Oe("Input must be a JSON object with bankRecords and transactions arrays");let t=e;if(!Array.isArray(t.bankRecords))throw new Oe("bankRecords must be an array");if(!Array.isArray(t.transactions))throw new Oe("transactions must be an array");if(t.bankRecords.length===0)throw new Oe("bankRecords array is empty \u2014 nothing to match");if(t.transactions.length===0)throw new Oe("transactions array is empty \u2014 nothing to match");for(let o=0;o<t.bankRecords.length;o++){let i=t.bankRecords[o];if(!i.id||typeof i.id!="string")throw new Oe(`bankRecords[${o}]: id is required (string)`);if(typeof i.amount!="number"||!Number.isFinite(i.amount))throw new Oe(`bankRecords[${o}]: amount must be a finite number`);if(i.amount===0)throw new Oe(`bankRecords[${o}]: amount must not be zero`);if(!i.date||typeof i.date!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(i.date))throw new Oe(`bankRecords[${o}]: date must be YYYY-MM-DD format`)}for(let o=0;o<t.transactions.length;o++){let i=t.transactions[o];if(!i.id||typeof i.id!="string")throw new Oe(`transactions[${o}]: id is required (string)`);if(i.direction!=="PAYIN"&&i.direction!=="PAYOUT")throw new Oe(`transactions[${o}]: direction must be 'PAYIN' or 'PAYOUT'`);if(typeof i.amount!="number"||!Number.isFinite(i.amount)||i.amount<=0)throw new Oe(`transactions[${o}]: amount must be a positive number`);if(!i.date||typeof i.date!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(i.date))throw new Oe(`transactions[${o}]: date must be YYYY-MM-DD format`);if(i.crossCurrency&&(!i.currency||typeof i.currency!="string"))throw new Oe(`transactions[${o}]: crossCurrency is true but currency is missing`)}let r=t.options;if(r){if(r.tolerance!==void 0&&(typeof r.tolerance!="number"||r.tolerance<0))throw new Oe("options.tolerance must be a non-negative number");if(r.dateWindowDays!==void 0&&(typeof r.dateWindowDays!="number"||!Number.isInteger(r.dateWindowDays)||r.dateWindowDays<0))throw new Oe("options.dateWindowDays must be a non-negative integer");if(r.maxGroupSize!==void 0&&(typeof r.maxGroupSize!="number"||!Number.isInteger(r.maxGroupSize)||r.maxGroupSize<2||r.maxGroupSize>10))throw new Oe("options.maxGroupSize must be an integer between 2 and 10")}let n=r?.exchangeRates;for(let o=0;o<t.transactions.length;o++){let i=t.transactions[o];if(i.crossCurrency&&i.currency&&(!n||typeof n[i.currency]!="number"))throw new Oe(`transactions[${o}]: crossCurrency is true with currency "${i.currency}" but no exchange rate provided in options.exchangeRates`)}return e}function Ze(e,t,r,n){return{step:e,action:"journal",description:t,date:r,lines:n}}function GR(e,t,r,n){return{step:e,action:"bill",description:t,date:r,lines:n}}function VR(e,t,r,n){return{step:e,action:"invoice",description:t,date:r,lines:n}}function Hs(e,t,r,n){return{step:e,action:"cash-out",description:t,date:r,lines:n}}function Km(e,t,r,n){return{step:e,action:"cash-in",description:t,date:r,lines:n}}function ZR(e,t,r=null){return{step:e,action:"fixed-asset",description:t,date:r,lines:[]}}function WR(e,t,r=null){return{step:e,action:"note",description:t,date:r,lines:[]}}function Mt(e,t){let r=e.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0});return t?`${t} ${r}`:r}function V(e,t){let r=e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});return t?`${t} ${r}`:r}function Xm(e){let{principal:t,annualRate:r,termMonths:n,startDate:o,currency:i}=e;ct(t,"Principal"),ki(r,"Annual rate"),Zt(n,"Term (months)"),Ut(o);let s=r/100/12,a=$(-(0,HR.pmt)(s,n,t)),c=[],u=t,l=0,d=0;for(let p=1;p<=n;p++){let m=$(u),h=p===n,g,D,b;h?(g=$(m*s),D=m,b=$(D+g)):(g=$(m*s),D=$(a-g),b=a),u=$(m-D),l=$(l+g),d=$(d+D);let y=o?cr(o,p):null,v={description:`Loan payment \u2014 Month ${p} of ${n}`,lines:[{account:"Loan Payable",debit:D,credit:0},{account:"Interest Expense",debit:g,credit:0},{account:"Cash / Bank Account",debit:0,credit:b}]};c.push({period:p,date:y,openingBalance:m,payment:b,interest:g,principal:D,closingBalance:u,journal:v})}let f=null;if(o){let p=[Km(1,"Record loan proceeds received from bank",o,[{account:"Cash / Bank Account",debit:t,credit:0},{account:"Loan Payable",debit:0,credit:t}]),...c.map((g,D)=>Ze(D+2,g.journal.description,g.date,g.journal.lines))],m=i??void 0,h=["Loan Amortization Workings",`Principal: ${V(t,m)} | Rate: ${r}% p.a. (${$(s*100)}% monthly)`,`Term: ${n} months | Monthly payment: ${V(a,m)}`,`Total payments: ${V($(l+d),m)} | Total interest: ${V(l,m)}`,"Method: PMT formula, constant payment amortization","Rounding: 2dp per period, final period closes balance to $0.00"].join(`
|
|
363
363
|
`);f={capsuleType:"Loan Repayment",capsuleName:`Bank Loan \u2014 ${Mt(t,i)} \u2014 ${r}% \u2014 ${n} months`,capsuleDescription:h,tags:["Bank Loan"],customFields:{"Loan Reference":null},steps:p}}return{type:"loan",currency:i??null,inputs:{principal:t,annualRate:r,termMonths:n,startDate:o??null},monthlyPayment:a,totalPayments:$(l+d),totalInterest:l,totalPrincipal:d,schedule:c,blueprint:f}}var KR=vt(wl(),1);function Qm(e){let{monthlyPayment:t,termMonths:r,annualRate:n,usefulLifeMonths:o,startDate:i,currency:s}=e;if(ct(t,"Monthly payment"),ki(n,"Annual rate (IBR)"),Zt(r,"Term (months)"),o!==void 0&&(Zt(o,"Useful life (months)"),o<r))throw new Oe(`Useful life (${o} months) must be >= lease term (${r} months) for hire purchase.`);Ut(i);let a=o!==void 0,c=n/100/12,u=$(-(0,KR.pv)(c,r,t)),l=a?o:r,d=$(u/l),f={description:"Initial recognition \u2014 IFRS 16 lease",lines:[{account:"Right-of-Use Asset",debit:u,credit:0},{account:"Lease Liability",debit:0,credit:u}]},p=[],m=u,h=0,g=0;for(let y=1;y<=r;y++){let v=$(m),S=y===r,I,_,T;S?(I=$(v*c),_=v,T=$(_+I)):(I=$(v*c),_=$(t-I),T=t),m=$(v-_),h=$(h+I),g=$(g+_);let N=i?cr(i,y):null,k={description:`Lease payment \u2014 Month ${y} of ${r}`,lines:[{account:"Lease Liability",debit:_,credit:0},{account:"Interest Expense \u2014 Leases",debit:I,credit:0},{account:"Cash / Bank Account",debit:0,credit:T}]};p.push({period:y,date:N,openingBalance:v,payment:T,interest:I,principal:_,closingBalance:m,journal:k})}let D=$(d*(r-1)+(u-d*(r-1))),b=null;if(i){let y=a?`Register Right-of-Use Asset in Fixed Asset register: cost ${u}, salvage 0, life ${l} months (straight-line over useful life, not lease term). Jaz will auto-post monthly depreciation of ${d}.`:`Register Right-of-Use Asset in Fixed Asset register: cost ${u}, salvage 0, life ${r} months (straight-line). Jaz will auto-post monthly depreciation of ${d}.`,v=[Ze(1,f.description,i,f.lines),ZR(2,y,i),...p.map((N,k)=>Ze(k+3,N.journal.description,N.date,N.journal.lines))],S=a?"Hire Purchase":"Lease Accounting",I=a?`Hire Purchase \u2014 ${Mt(t,s)}/month \u2014 ${r} months \u2014 useful life ${l} months`:`IFRS 16 Lease \u2014 ${Mt(t,s)}/month \u2014 ${r} months`,_=s??void 0,T=[`${a?"Hire Purchase":"IFRS 16 Lease"} Workings`,`Monthly payment: ${V(t,_)} | IBR: ${n}% p.a. (${$(c*100)}% monthly)`,`Lease term: ${r} months | PV of payments: ${V(u,_)} (IFRS 16.26)`];a?T.push(`Useful life: ${o} months | ROU depreciation: ${V(d,_)}/month over ${l} months`):T.push(`ROU depreciation: ${V(d,_)}/month (SL over ${r} months)`),T.push(`Total cash payments: ${V($(h+g),_)} | Total interest: ${V(h,_)}`,"Method: Effective interest (IFRS 16.36-37), ROU straight-line (IFRS 16.31-32)","Rounding: 2dp per period, final period closes liability to $0.00"),b={capsuleType:S,capsuleName:I,capsuleDescription:T.join(`
|
|
364
364
|
`),tags:[S],customFields:a?{"HP Agreement #":null}:{"Lease Contract #":null},steps:v}}return{type:"lease",currency:s??null,inputs:{monthlyPayment:t,termMonths:r,annualRate:n,usefulLifeMonths:o??null,startDate:i??null},presentValue:u,monthlyRouDepreciation:d,depreciationMonths:l,isHirePurchase:a,totalCashPayments:$(h+g),totalInterest:h,totalDepreciation:D,initialJournal:f,schedule:p,blueprint:b}}function eh(e){let{cost:t,salvageValue:r,usefulLifeYears:n,method:o="ddb",frequency:i="annual",currency:s}=e;ct(t,"Asset cost"),Bo(r,"Salvage value"),Zt(n,"Useful life (years)"),r>0&&Hm(r,t);let a=$(t-r);if(o==="sl")return EK(t,r,n,a,i,s);let u=(o==="ddb"?2:1.5)/n;if(i==="annual")return XR(t,r,n,u,a,o,s);let l=XR(t,r,n,u,a,o,s),d=[],f=0;for(let p of l.schedule){let m=$(p.depreciation/12),h=p.depreciation;for(let g=1;g<=12;g++){f++;let b=g===12?$(h):m;h=$(h-b);let y=f===1?t:$(d[f-2].closingBookValue),v=$(y-b),S={description:`${p.methodUsed} depreciation \u2014 Month ${f} of ${n*12}`,lines:[{account:"Depreciation Expense",debit:b,credit:0},{account:"Accumulated Depreciation",debit:0,credit:b}]};d.push({period:f,date:null,openingBookValue:y,ddbAmount:$(p.ddbAmount/12),slAmount:$(p.slAmount/12),methodUsed:p.methodUsed,depreciation:b,closingBookValue:v,journal:S})}}return{type:"depreciation",currency:s??null,inputs:{cost:t,salvageValue:r,usefulLifeYears:n,method:o,frequency:i},totalDepreciation:a,schedule:d,blueprint:l.blueprint}}function EK(e,t,r,n,o,i){let s=o==="monthly"?r*12:r,a=$(n/s),c=o==="monthly"?"Month":"Year",u=o==="monthly"?r*12:r,l=[],d=e;for(let h=1;h<=s;h++){let g=$(d),b=h===s?$(g-t):a;d=$(g-b);let y={description:`SL depreciation \u2014 ${c} ${h} of ${u}`,lines:[{account:"Depreciation Expense",debit:b,credit:0},{account:"Accumulated Depreciation",debit:0,credit:b}]};l.push({period:h,date:null,openingBookValue:g,ddbAmount:0,slAmount:b,methodUsed:"SL",depreciation:b,closingBookValue:d,journal:y})}let f=l.map((h,g)=>Ze(g+1,h.journal.description,h.date,h.journal.lines)),p=i??void 0,m=["Straight-Line Depreciation Workings",`Cost: ${V(e,p)} | Salvage: ${V(t,p)} | Depreciable base: ${V(n,p)}`,`Useful life: ${r} years | Frequency: ${o}`,`Per ${o==="monthly"?"month":"year"}: ${V(a,p)}`,`Total depreciation: ${V(n,p)}`,`Method: (Cost \u2212 Salvage) \xF7 Life = ${V(n,p)} \xF7 ${s} = ${V(a,p)}`,"Rounding: 2dp per period, final period closes to salvage value"].join(`
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jaz-clio",
|
|
3
|
-
"version": "4.48.
|
|
4
|
-
"description": "Clio — Command Line Interface
|
|
3
|
+
"version": "4.48.7",
|
|
4
|
+
"description": "Clio — Command Line Interface Operator for Jaz AI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"clio": "./cli.mjs"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node postinstall.mjs"
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
13
|
"cli.mjs",
|
|
14
|
+
"postinstall.mjs",
|
|
11
15
|
"assets",
|
|
12
16
|
"help-center-mirror"
|
|
13
17
|
],
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Branded welcome on install (TTY only)
|
|
2
|
+
if (process.stdout.isTTY) {
|
|
3
|
+
const v = process.env.npm_package_version || "";
|
|
4
|
+
console.log("");
|
|
5
|
+
console.log(" [32m✓[0m [1mClio[0m" + (v ? " v" + v : "") + " installed");
|
|
6
|
+
console.log(" [2mGet started:[0m clio --help");
|
|
7
|
+
console.log("");
|
|
8
|
+
}
|