kadence 0.4.1 → 0.5.0

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/cli.js CHANGED
@@ -1,55 +1,140 @@
1
1
  #!/usr/bin/env node
2
- import{$ as lt,A as Ke,B as We,C as Fe,D as Ue,E as te,F as Ye,G as ze,H as Je,I as qe,J as He,K as Ve,L as Ge,M as Ze,N as Qe,O as Xe,P as et,Q as tt,R as nt,S as ne,T as P,U as st,V as ot,W as rt,X as it,Y as at,Z as dt,_ as ct,a as ve,aa as ut,ba as mt,ca as ft,e as $e,f as Z,g as j,h as xe,i as Se,j as Ce,k as Ae,l as je,m as De,n as S,o as W,p as Re,q as Ne,r as ee,s as y,t as R,u as w,v,w as Ie,x,y as N,z as Be}from"./chunks/chunk-FKPFXIL4.js";import{b as D,c as T,d as Te,e as Ee,g as Oe,h as Q,j as Me,k as _e,o as X,p as F,q as Pe,r as Le}from"./chunks/chunk-CDGGOWGY.js";function se(e){return e==null?[]:Array.isArray(e)?e:[e]}function pn(e,t,n,o){var s,r=e[t],i=~o.string.indexOf(t)?n==null||n===!0?"":String(n):typeof n=="boolean"?n:~o.boolean.indexOf(t)?n==="false"?!1:n==="true"||(e._.push((s=+n,s*0===0?s:n)),!!n):(s=+n,s*0===0?s:n);e[t]=r==null?i:Array.isArray(r)?r.concat(i):[r,i]}function hn(e,t){e=e||[],t=t||{};var n,o,s,r,i,d={_:[]},a=0,c=0,l=0,m=e.length;let f=t.alias!==void 0,h=t.unknown!==void 0,p=t.default!==void 0;if(t.alias=t.alias||{},t.string=se(t.string),t.boolean=se(t.boolean),f)for(n in t.alias)for(o=t.alias[n]=se(t.alias[n]),a=0;a<o.length;a++)(t.alias[o[a]]=o.concat(n)).splice(a,1);for(a=t.boolean.length;a-- >0;)for(o=t.alias[t.boolean[a]]||[],c=o.length;c-- >0;)t.boolean.push(o[c]);for(a=t.string.length;a-- >0;)for(o=t.alias[t.string[a]]||[],c=o.length;c-- >0;)t.string.push(o[c]);if(p){for(n in t.default)if(r=typeof t.default[n],o=t.alias[n]=t.alias[n]||[],t[r]!==void 0)for(t[r].push(n),a=0;a<o.length;a++)t[r].push(o[a])}let k=h?Object.keys(t.alias):[];for(a=0;a<m;a++){if(s=e[a],s==="--"){d._=d._.concat(e.slice(++a));break}for(c=0;c<s.length&&s.charCodeAt(c)===45;c++);if(c===0)d._.push(s);else if(s.substring(c,c+3)==="no-"){if(r=s.substring(c+3),h&&!~k.indexOf(r))return t.unknown(s);d[r]=!1}else{for(l=c+1;l<s.length&&s.charCodeAt(l)!==61;l++);for(r=s.substring(c,l),i=s.substring(++l)||a+1===m||(""+e[a+1]).charCodeAt(0)===45||e[++a],o=c===2?[r]:r,l=0;l<o.length;l++){if(r=o[l],h&&!~k.indexOf(r))return t.unknown("-".repeat(c)+r);pn(d,r,l+1<o.length||i,t)}}}if(p)for(n in t.default)d[n]===void 0&&(d[n]=t.default[n]);if(f)for(n in d)for(o=t.alias[n]||[];o.length>0;)d[o.shift()]=d[n];return d}function gt(e){return e.replace(/[<[].+/,"").trim()}function gn(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,o=[],s=d=>{let a=!1,c=d[1];return c.startsWith("...")&&(c=c.slice(3),a=!0),{required:d[0].startsWith("<"),value:c,variadic:a}},r;for(;r=t.exec(e);)o.push(s(r));let i;for(;i=n.exec(e);)o.push(s(i));return o}function kn(e){let t={alias:{},boolean:[]};for(let[n,o]of e.entries())o.names.length>1&&(t.alias[o.names[0]]=o.names.slice(1)),o.isBoolean&&(o.negated&&e.some((s,r)=>r!==n&&s.names.some(i=>o.names.includes(i))&&typeof s.required=="boolean")||t.boolean.push(o.names[0]));return t}function pt(e){return e.sort((t,n)=>t.length>n.length?-1:1)[0]}function ht(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function bn(e){return e.replaceAll(/([a-z])-([a-z])/g,(t,n,o)=>n+o.toUpperCase())}function yn(e,t,n){let o=e;for(let s=0;s<t.length;s++){let r=t[s];if(s===t.length-1){o[r]=n;return}if(o[r]==null){let i=+t[s+1]>-1;o[r]=i?[]:{}}o=o[r]}}function wn(e,t){for(let n of Object.keys(t)){let o=t[n];o.shouldTransform&&(e[n]=[e[n]].flat(),typeof o.transformFunction=="function"&&(e[n]=e[n].map(o.transformFunction)))}}function vn(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function kt(e){return e.split(".").map((t,n)=>n===0?bn(t):t).join(".")}var U=class extends Error{constructor(e){super(e),this.name="CACError",typeof Error.captureStackTrace!="function"&&(this.stack=new Error(e).stack)}},$n=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,n){this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replaceAll(".*",""),this.negated=!1,this.names=gt(e).split(",").map(o=>{let s=o.trim().replace(/^-{1,2}/,"");return s.startsWith("no-")&&(this.negated=!0,s=s.replace(/^no-/,"")),kt(s)}).sort((o,s)=>o.length>s.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null&&(this.config.default=!0),e.includes("<")?this.required=!0:e.includes("[")?this.required=!1:this.isBoolean=!0}},oe,Y;if(typeof process<"u"){let e;typeof Deno<"u"&&typeof Deno.version?.deno=="string"?e="deno":typeof Bun<"u"&&typeof Bun.version=="string"?e="bun":e="node",Y=`${process.platform}-${process.arch} ${e}-${process.version}`,oe=process.argv}else typeof navigator>"u"?Y="unknown":Y=`${navigator.platform} ${navigator.userAgent}`;var bt=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,t,n={},o){this.rawName=e,this.description=t,this.config=n,this.cli=o,this.options=[],this.aliasNames=[],this.name=gt(e),this.args=gn(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,n){let o=new $n(e,t,n);return this.options.push(o),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof yt}hasOption(e){return e=e.split(".")[0],this.options.find(t=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:o,helpCallback:s}=this.cli.globalCommand,r=[{body:`${e}${n?`/${n}`:""}`}];if(r.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let d=pt(t.map(a=>a.rawName));r.push({title:"Commands",body:t.map(a=>` ${ht(a.rawName,d.length)} ${a.description}`).join(`
3
- `)},{title:"For more info, run any command with the `--help` flag",body:t.map(a=>` $ ${e}${a.name===""?"":` ${a.name}`} --help`).join(`
4
- `)})}let i=this.isGlobalCommand?o:[...this.options,...o||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(i=i.filter(d=>d.name!=="version")),i.length>0){let d=pt(i.map(a=>a.rawName));r.push({title:"Options",body:i.map(a=>` ${ht(a.rawName,d.length)} ${a.description} ${a.config.default===void 0?"":`(default: ${a.config.default})`}`).join(`
5
- `)})}this.examples.length>0&&r.push({title:"Examples",body:this.examples.map(d=>typeof d=="function"?d(e):d).join(`
6
- `)}),s&&(r=s(r)||r),console.info(r.map(d=>d.title?`${d.title}:
7
- ${d.body}`:d.body).join(`
2
+ import{$ as It,A as pt,B as ht,C as ft,D as gt,E as De,F as kt,G as bt,H as yt,I as $t,J as wt,K as vt,L as xt,M as St,N as Ct,O as At,P as jt,Q as Dt,R as Tt,S as Te,T as X,U as Rt,V as Et,W as Nt,X as Ot,Y as Mt,Z as _t,_ as Pt,a as Je,aa as Lt,ba as Wt,ca as Bt,da as Ft,e as Ve,ea as Kt,f as Ae,fa as Ut,g as R,h as Ge,i as Ze,j as Qe,k as Xe,l as et,m as tt,n as T,o as me,p as rt,q as ot,r as je,s as w,t as F,u as S,v as C,w as ut,x as A,y as K,z as mt}from"./chunks/chunk-FCPGSN7D.js";import{b as O,c as M,d as nt,e as st,g as it,h as oe,j as at,k as dt,o as Q,p as pe,q as lt,r as ct}from"./chunks/chunk-CDGGOWGY.js";function Re(e){return e==null?[]:Array.isArray(e)?e:[e]}function os(e,n,t,r){var s,o=e[n],i=~r.string.indexOf(n)?t==null||t===!0?"":String(t):typeof t=="boolean"?t:~r.boolean.indexOf(n)?t==="false"?!1:t==="true"||(e._.push((s=+t,s*0===0?s:t)),!!t):(s=+t,s*0===0?s:t);e[n]=o==null?i:Array.isArray(o)?o.concat(i):[o,i]}function is(e,n){e=e||[],n=n||{};var t,r,s,o,i,a={_:[]},d=0,l=0,c=0,u=e.length;let m=n.alias!==void 0,k=n.unknown!==void 0,f=n.default!==void 0;if(n.alias=n.alias||{},n.string=Re(n.string),n.boolean=Re(n.boolean),m)for(t in n.alias)for(r=n.alias[t]=Re(n.alias[t]),d=0;d<r.length;d++)(n.alias[r[d]]=r.concat(t)).splice(d,1);for(d=n.boolean.length;d-- >0;)for(r=n.alias[n.boolean[d]]||[],l=r.length;l-- >0;)n.boolean.push(r[l]);for(d=n.string.length;d-- >0;)for(r=n.alias[n.string[d]]||[],l=r.length;l-- >0;)n.string.push(r[l]);if(f){for(t in n.default)if(o=typeof n.default[t],r=n.alias[t]=n.alias[t]||[],n[o]!==void 0)for(n[o].push(t),d=0;d<r.length;d++)n[o].push(r[d])}let y=k?Object.keys(n.alias):[];for(d=0;d<u;d++){if(s=e[d],s==="--"){a._=a._.concat(e.slice(++d));break}for(l=0;l<s.length&&s.charCodeAt(l)===45;l++);if(l===0)a._.push(s);else if(s.substring(l,l+3)==="no-"){if(o=s.substring(l+3),k&&!~y.indexOf(o))return n.unknown(s);a[o]=!1}else{for(c=l+1;c<s.length&&s.charCodeAt(c)!==61;c++);for(o=s.substring(l,c),i=s.substring(++c)||d+1===u||(""+e[d+1]).charCodeAt(0)===45||e[++d],r=l===2?[o]:o,c=0;c<r.length;c++){if(o=r[c],k&&!~y.indexOf(o))return n.unknown("-".repeat(l)+o);os(a,o,c+1<r.length||i,n)}}}if(f)for(t in n.default)a[t]===void 0&&(a[t]=n.default[t]);if(m)for(t in a)for(r=n.alias[t]||[];r.length>0;)a[r.shift()]=a[t];return a}function Yt(e){return e.replace(/[<[].+/,"").trim()}function as(e){let n=/<([^>]+)>/g,t=/\[([^\]]+)\]/g,r=[],s=a=>{let d=!1,l=a[1];return l.startsWith("...")&&(l=l.slice(3),d=!0),{required:a[0].startsWith("<"),value:l,variadic:d}},o;for(;o=n.exec(e);)r.push(s(o));let i;for(;i=t.exec(e);)r.push(s(i));return r}function ds(e){let n={alias:{},boolean:[]};for(let[t,r]of e.entries())r.names.length>1&&(n.alias[r.names[0]]=r.names.slice(1)),r.isBoolean&&(r.negated&&e.some((s,o)=>o!==t&&s.names.some(i=>r.names.includes(i))&&typeof s.required=="boolean")||n.boolean.push(r.names[0]));return n}function Ht(e){return e.sort((n,t)=>n.length>t.length?-1:1)[0]}function zt(e,n){return e.length>=n?e:`${e}${" ".repeat(n-e.length)}`}function ls(e){return e.replaceAll(/([a-z])-([a-z])/g,(n,t,r)=>t+r.toUpperCase())}function cs(e,n,t){let r=e;for(let s=0;s<n.length;s++){let o=n[s];if(s===n.length-1){r[o]=t;return}if(r[o]==null){let i=+n[s+1]>-1;r[o]=i?[]:{}}r=r[o]}}function us(e,n){for(let t of Object.keys(n)){let r=n[t];r.shouldTransform&&(e[t]=[e[t]].flat(),typeof r.transformFunction=="function"&&(e[t]=e[t].map(r.transformFunction)))}}function ms(e){let n=/([^\\/]+)$/.exec(e);return n?n[1]:""}function qt(e){return e.split(".").map((n,t)=>t===0?ls(n):n).join(".")}var he=class extends Error{constructor(e){super(e),this.name="CACError",typeof Error.captureStackTrace!="function"&&(this.stack=new Error(e).stack)}},ps=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,n,t){this.rawName=e,this.description=n,this.config=Object.assign({},t),e=e.replaceAll(".*",""),this.negated=!1,this.names=Yt(e).split(",").map(r=>{let s=r.trim().replace(/^-{1,2}/,"");return s.startsWith("no-")&&(this.negated=!0,s=s.replace(/^no-/,"")),qt(s)}).sort((r,s)=>r.length>s.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null&&(this.config.default=!0),e.includes("<")?this.required=!0:e.includes("[")?this.required=!1:this.isBoolean=!0}},Ee,fe;if(typeof process<"u"){let e;typeof Deno<"u"&&typeof Deno.version?.deno=="string"?e="deno":typeof Bun<"u"&&typeof Bun.version=="string"?e="bun":e="node",fe=`${process.platform}-${process.arch} ${e}-${process.version}`,Ee=process.argv}else typeof navigator>"u"?fe="unknown":fe=`${navigator.platform} ${navigator.userAgent}`;var Jt=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,n,t={},r){this.rawName=e,this.description=n,this.config=t,this.cli=r,this.options=[],this.aliasNames=[],this.name=Yt(e),this.args=as(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,n="-v, --version"){return this.versionNumber=e,this.option(n,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,n,t){let r=new ps(e,n,t);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof Vt}hasOption(e){return e=e.split(".")[0],this.options.find(n=>n.names.includes(e))}outputHelp(){let{name:e,commands:n}=this.cli,{versionNumber:t,options:r,helpCallback:s}=this.cli.globalCommand,o=[{body:`${e}${t?`/${t}`:""}`}];if(o.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&n.length>0){let a=Ht(n.map(d=>d.rawName));o.push({title:"Commands",body:n.map(d=>` ${zt(d.rawName,a.length)} ${d.description}`).join(`
3
+ `)},{title:"For more info, run any command with the `--help` flag",body:n.map(d=>` $ ${e}${d.name===""?"":` ${d.name}`} --help`).join(`
4
+ `)})}let i=this.isGlobalCommand?r:[...this.options,...r||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(i=i.filter(a=>a.name!=="version")),i.length>0){let a=Ht(i.map(d=>d.rawName));o.push({title:"Options",body:i.map(d=>` ${zt(d.rawName,a.length)} ${d.description} ${d.config.default===void 0?"":`(default: ${d.config.default})`}`).join(`
5
+ `)})}this.examples.length>0&&o.push({title:"Examples",body:this.examples.map(a=>typeof a=="function"?a(e):a).join(`
6
+ `)}),s&&(o=s(o)||o),console.info(o.map(a=>a.title?`${a.title}:
7
+ ${a.body}`:a.body).join(`
8
8
 
9
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.info(`${e}/${t} ${Y}`)}checkRequiredArgs(){let e=this.args.filter(t=>t.required).length;if(this.cli.args.length<e)throw new U(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!t.hasOption(n))throw new U(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let o of n){let s=e[o.name.split(".")[0]];if(o.required){let r=n.some(i=>i.negated&&i.names.includes(o.name));if(s===!0||s===!1&&!r)throw new U(`option \`${o.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(t=>t.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new U(`Unused args: ${this.cli.args.slice(e).map(t=>`\`${t}\``).join(", ")}`)}},yt=class extends bt{constructor(e){super("@@global@@","",{},e)}},xn=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=""){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new yt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let o=new bt(e,t||"",n,this);return o.globalCommand=this.globalCommand,this.commands.push(o),o}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,o){return this.args=e,this.options=t,n&&(this.matchedCommand=n),o&&(this.matchedCommandName=o),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!oe)throw new Error("No argv provided and runtime process argv is not available.");e=oe}this.rawArgs=e,this.name||(this.name=e[1]?vn(e[1]):"cli");let n=!0;for(let s of this.commands){let r=this.mri(e.slice(2),s),i=r.args[0];if(s.isMatched(i)){n=!1;let d={...r,args:r.args.slice(1)};this.setParsedInfo(d,s,i),this.dispatchEvent(new CustomEvent(`command:${i}`,{detail:s}))}}if(n){for(let s of this.commands)if(s.isDefaultCommand){n=!1;let r=this.mri(e.slice(2),s);this.setParsedInfo(r,s),this.dispatchEvent(new CustomEvent("command:!",{detail:s}))}}if(n){let s=this.mri(e.slice(2));this.setParsedInfo(s)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let o={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]})),o}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],o=kn(n),s=[],r=e.indexOf("--");r!==-1&&(s=e.slice(r+1),e=e.slice(0,r));let i=hn(e,o);i=Object.keys(i).reduce((m,f)=>({...m,[kt(f)]:i[f]}),{_:[]});let d=i._,a={"--":s},c=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,l=Object.create(null);for(let m of n){if(!c&&m.config.default!==void 0)for(let f of m.names)a[f]=m.config.default;Array.isArray(m.config.type)&&l[m.name]===void 0&&(l[m.name]=Object.create(null),l[m.name].shouldTransform=!0,l[m.name].transformFunction=m.config.type[0])}for(let m of Object.keys(i))m!=="_"&&(yn(a,m.split("."),i[m]),wn(a,l));return{args:d,options:a}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let o=[];return n.args.forEach((s,r)=>{s.variadic?o.push(e.slice(r)):o.push(e[r])}),o.push(t),n.commandAction.apply(this,o)}},wt=(e="")=>new xn(e);import{existsSync as I,mkdirSync as xt,readFileSync as ie,writeFileSync as z}from"node:fs";import{join as B}from"node:path";var vt=".kadence/state.json",Sn=["AGENTS.md","CLAUDE.md"];function St(e,t="dev",n={}){let o=ve(e);if(o===null)return{ok:!1,alreadyInitialized:!1,root:null,message:`kadence lives inside a git repository, and there is none here.
9
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:n}=this.cli.globalCommand;n&&console.info(`${e}/${n} ${fe}`)}checkRequiredArgs(){let e=this.args.filter(n=>n.required).length;if(this.cli.args.length<e)throw new he(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:n}=this.cli;if(!this.config.allowUnknownOptions){for(let t of Object.keys(e))if(t!=="--"&&!this.hasOption(t)&&!n.hasOption(t))throw new he(`Unknown option \`${t.length>1?`--${t}`:`-${t}`}\``)}}checkOptionValue(){let{options:e,globalCommand:n}=this.cli,t=[...n.options,...this.options];for(let r of t){let s=e[r.name.split(".")[0]];if(r.required){let o=t.some(i=>i.negated&&i.names.includes(r.name));if(s===!0||s===!1&&!o)throw new he(`option \`${r.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(n=>n.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new he(`Unused args: ${this.cli.args.slice(e).map(n=>`\`${n}\``).join(", ")}`)}},Vt=class extends Jt{constructor(e){super("@@global@@","",{},e)}},hs=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=""){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new Vt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,n,t){let r=new Jt(e,n||"",t,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,n,t){return this.globalCommand.option(e,n,t),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,n="-v, --version"){return this.globalCommand.version(e,n),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:n},t,r){return this.args=e,this.options=n,t&&(this.matchedCommand=t),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:n=!0}={}){if(!e){if(!Ee)throw new Error("No argv provided and runtime process argv is not available.");e=Ee}this.rawArgs=e,this.name||(this.name=e[1]?ms(e[1]):"cli");let t=!0;for(let s of this.commands){let o=this.mri(e.slice(2),s),i=o.args[0];if(s.isMatched(i)){t=!1;let a={...o,args:o.args.slice(1)};this.setParsedInfo(a,s,i),this.dispatchEvent(new CustomEvent(`command:${i}`,{detail:s}))}}if(t){for(let s of this.commands)if(s.isDefaultCommand){t=!1;let o=this.mri(e.slice(2),s);this.setParsedInfo(o,s),this.dispatchEvent(new CustomEvent("command:!",{detail:s}))}}if(t){let s=this.mri(e.slice(2));this.setParsedInfo(s)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),n=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),n=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return n&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]})),r}mri(e,n){let t=[...this.globalCommand.options,...n?n.options:[]],r=ds(t),s=[],o=e.indexOf("--");o!==-1&&(s=e.slice(o+1),e=e.slice(0,o));let i=is(e,r);i=Object.keys(i).reduce((u,m)=>({...u,[qt(m)]:i[m]}),{_:[]});let a=i._,d={"--":s},l=n&&n.config.ignoreOptionDefaultValue?n.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,c=Object.create(null);for(let u of t){if(!l&&u.config.default!==void 0)for(let m of u.names)d[m]=u.config.default;Array.isArray(u.config.type)&&c[u.name]===void 0&&(c[u.name]=Object.create(null),c[u.name].shouldTransform=!0,c[u.name].transformFunction=u.config.type[0])}for(let u of Object.keys(i))u!=="_"&&(cs(d,u.split("."),i[u]),us(d,c));return{args:a,options:d}}runMatchedCommand(){let{args:e,options:n,matchedCommand:t}=this;if(!t||!t.commandAction)return;t.checkUnknownOptions(),t.checkOptionValue(),t.checkRequiredArgs(),t.checkUnusedArgs();let r=[];return t.args.forEach((s,o)=>{s.variadic?r.push(e.slice(o)):r.push(e[o])}),r.push(n),t.commandAction.apply(this,r)}},Gt=(e="")=>new hs(e);import{existsSync as q,mkdirSync as en,readFileSync as ke,writeFileSync as ie}from"node:fs";import{join as J}from"node:path";var Zt=".kadence/state.json",fs=["AGENTS.md","CLAUDE.md"];function tn(e,n="dev",t={}){let r=Je(e);if(r===null)return{ok:!1,alreadyInitialized:!1,root:null,message:`kadence lives inside a git repository, and there is none here.
10
10
  Create one and try again:
11
- git init`};let s=I(Z(o));xt(Z(o),{recursive:!0}),An(o);let r=B($e(o),"README.md");I(r)||z(r,Ae(t),"utf8");for(let d of Sn)jn(o,d,t);let i=n.hooks===!0?`
11
+ git init`};let s=q(Ae(r));en(Ae(r),{recursive:!0}),ks(r);let o=J(Ve(r),"README.md");q(o)||ie(o,Xe(n),"utf8");for(let l of fs)bs(r,l,n);let i=t.hooks===!0?`
12
12
 
13
- ${Cn(o)}`:"";return{ok:!0,alreadyInitialized:s,root:o,message:s?`kadence is already initialised.${i}`:`kadence is ready.
13
+ ${gs(r)}`:"",a=t.hooks!==!0&&q(J(r,".claude"))&&!Xt(r)?`
14
+
15
+ kadence init --hooks adds prime at session start.`:"",d=[".kadence/","AGENTS.md","CLAUDE.md"];return t.hooks===!0&&Xt(r)&&d.push(".claude/settings.json"),{ok:!0,alreadyInitialized:s,root:r,message:s?`kadence is already initialised.${i}${a}`:`kadence is ready.
14
16
 
15
17
  kadence task add "first task"
18
+ kadence decision add "What we chose" --why "Why we chose it"
16
19
  kadence board
17
20
 
18
- Files were created but not committed \u2014 that call is yours.`+i}}var re="kadence prime",$t="startup";function Cn(e){let t=B(e,".claude"),n=B(t,"settings.json"),o={};if(I(n)){let a=ie(n,"utf8");try{let c=JSON.parse(a);if(typeof c!="object"||c===null||Array.isArray(c))throw new Error("not an object");o=c}catch{return`${n} is not valid JSON, so the hook was not added. Fix it and run:
19
- kadence init --hooks`}}let s=o.hooks??{},r=Array.isArray(s.SessionStart)?s.SessionStart:[];if(r.some(a=>(a.hooks??[]).some(c=>c.command===re)))return`The SessionStart hook is already in ${n}.`;let d=r.find(a=>a.matcher===$t);return d===void 0&&(d={matcher:$t,hooks:[]},r.push(d)),Array.isArray(d.hooks)||(d.hooks=[]),d.hooks.push({type:"command",command:re,timeout:60}),s.SessionStart=r,o.hooks=s,xt(t,{recursive:!0}),z(n,`${JSON.stringify(o,null,2)}
20
- `,"utf8"),`Added a SessionStart hook to ${n}: every session now starts with \`${re}\`.`}function An(e){let t=B(e,".gitignore"),n="";if(I(t)&&(n=ie(t,"utf8")),n.includes(vt))return;let o=n.length>0&&!n.endsWith(`
21
+ Commit ${d.join(", ")} so a teammate's agent finds them.
22
+ Files were created but not committed \u2014 that call is yours.`+i+a}}var ge="if command -v kadence >/dev/null 2>&1; then kadence prime; else echo 'kadence is not installed on this machine: ask the human to run npm install -g kadence. The team journal is in .kadence/.'; fi",nn=["kadence prime",ge],Qt="startup";function gs(e){let n=J(e,".claude"),t=J(n,"settings.json"),r={};if(q(t)){let d=ke(t,"utf8");try{let l=JSON.parse(d);if(typeof l!="object"||l===null||Array.isArray(l))throw new Error("not an object");r=l}catch{return`${t} is not valid JSON, so the hook was not added. Fix it and run:
23
+ kadence init --hooks`}}let s=r.hooks??{},o=Array.isArray(s.SessionStart)?s.SessionStart:[],i=o.flatMap(d=>(Array.isArray(d.hooks)?d.hooks:[]).filter(l=>typeof l.command=="string"&&nn.includes(l.command)));if(i.some(d=>d.command===ge))return`The SessionStart hook is already in ${t}.`;if(i.length>0){for(let d of i)d.command=ge;return ie(t,`${JSON.stringify(r,null,2)}
24
+ `,"utf8"),`Updated the SessionStart hook in ${t}: it now prints an install hint where kadence is missing.`}let a=o.find(d=>d.matcher===Qt);return a===void 0&&(a={matcher:Qt,hooks:[]},o.push(a)),Array.isArray(a.hooks)||(a.hooks=[]),a.hooks.push({type:"command",command:ge,timeout:60}),s.SessionStart=o,r.hooks=s,en(n,{recursive:!0}),ie(t,`${JSON.stringify(r,null,2)}
25
+ `,"utf8"),`Added a SessionStart hook to ${t}: every session now starts with \`kadence prime\`.`}function Xt(e){let n=J(e,".claude","settings.json");if(!q(n))return!1;try{let r=JSON.parse(ke(n,"utf8"))?.hooks?.SessionStart;return Array.isArray(r)?r.some(s=>Array.isArray(s?.hooks)&&s.hooks.some(o=>typeof o?.command=="string"&&nn.includes(o.command))):!1}catch{return!1}}function ks(e){let n=J(e,".gitignore"),t="";if(q(n)&&(t=ke(n,"utf8")),t.includes(Zt))return;let r=t.length>0&&!t.endsWith(`
21
26
  `)?`
22
- `:"";z(t,`${n}${o}${vt}
23
- `,"utf8")}function jn(e,t,n){let o=B(e,t),s=I(o)?ie(o,"utf8"):null,r=je(s,n);r!==s&&z(o,r,"utf8")}function Dn(e){return{label:e.label,title:e.title,priority:e.priority,estimate:e.estimate,labels:e.labels,claimedBy:e.claimedBy,contestedBy:e.contestedBy}}function Ct(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i={statuses:s.statuses,started:s.started},d=F(s.tasks,{viewer:o.actor,...i,...n.assignee===void 0?{}:{assignee:n.assignee}}),a=n.limit!==void 0&&n.limit>0?d.slice(0,n.limit):d;if(a.length===0)return{ok:!0,exitCode:0,warnings:r,message:Pe(s.tasks,o.actor,n.assignee,i),data:{schema:"kadence/v1",ok:!0,tasks:[]}};let c=W(t,process.stdout.isTTY===!0),l=a.map(m=>{let f=m.contestedBy.length>0?` [contested: ${m.contestedBy.join(", ")}]`:"";return`${Re(m,c)}${f}`});return{ok:!0,exitCode:0,warnings:r,message:[...l,"",`Take the first one:
24
- kadence task claim ${a[0].label}`].join(`
25
- `),data:{schema:"kadence/v1",ok:!0,tasks:a.map(Dn)}}}var Tn=864e5;function ae(e){return e.history[e.history.length-1]?.ts??e.createdAt}function K(e,t){let n=Math.floor((t.getTime()-Date.parse(e))/Tn);return n>0?n:0}function En(e){for(let t=e.history.length-1;t>=0;t--){let n=e.history[t];if(n.id===e.claimedEventId)return!1;if(n.type==="task.moved")return!0}return!1}function Rn(e,t,n,o,s,r){let i=[],d=e.blockedBy.filter(c=>o.has(c));if(d.length>0&&i.push({kind:"dead_blocker",blockers:d.map(c=>n.get(c)??c)}),!Q(t,e))return i;let a=K(ae(e),s);if(a>=r&&i.push({kind:"stalled",days:a}),e.assignee===null&&e.claimedBy===null){let c=Oe(e,t.started,t.statuses,t.startedChanges),l=c===null?a:K(c,s);l>=r&&i.push({kind:"unowned",days:l})}if(e.claimedBy!==null&&e.claimedAt!==null&&!En(e)){let c=K(e.claimedAt,s);c>=r&&i.push({kind:"stale_claim",days:c,who:e.claimedBy})}return i}function J(e){switch(e.kind){case"stalled":return`stalled ${String(e.days)}d`;case"unowned":return`unowned ${String(e.days)}d`;case"stale_claim":return`claimed ${String(e.days)}d ago by ${e.who??"someone"}, never moved`;case"dead_blocker":return`blocked by ${(e.blockers??[]).join(", ")}, already done`}}function q(e,t=new Date,n=7){let o=e.tasks.filter(a=>!X(a)),s=new Set(e.tasks.filter(X).map(a=>a.id)),r=new Map(e.tasks.map(a=>[a.id,a.label])),i=[];for(let a of o){let c=Rn(a,e,r,s,t,n);c.length!==0&&i.push({label:a.label,title:a.title,status:a.status,priority:a.priority,assignee:a.assignee,idleDays:K(ae(a),t),signals:c})}let d=new Map(e.tasks.map((a,c)=>[a.label,c]));return i.sort((a,c)=>c.idleDays!==a.idleDays?c.idleDays-a.idleDays:(d.get(a.label)??0)-(d.get(c.label)??0)),{threshold:n,started:e.started,asOf:t.toISOString().slice(0,10),rows:i,notes:i.length>0?[]:Nn(e,o,t,n)}}function Nn(e,t,n,o){let s=t.filter(i=>Q(e,i));if(s.length===0)return[`Nothing to report: there is no work in progress past \`${e.started}\`.`];let r=Math.min(...s.map(i=>K(ae(i),n)));return[`Nothing to report: ${String(s.length)} task${s.length===1?"":"s"} in progress, none silent or ownerless for ${String(o)} days (the quietest was touched ${String(r)} day(s) ago).`]}function On(e,t){return t===null?null:e.tasks.find(n=>n.id===t)?.label??null}var Mn=5,_n=5,Pn=5,Ln=3,In=7,At=60,jt=["kadence ready what can be started now","kadence task show KAD-1 one task in full, with its decisions","kadence decision list the reasons behind the work","kadence board the whole board"];function de(e){let t=[...e];return t.length>At?`${t.slice(0,At-1).join("")}\u2026`:e}function Bn(e,t){if(e===null)return null;let n=Date.parse(`${e}T00:00:00.000Z`);if(Number.isNaN(n))return null;let o=Date.parse(`${t.toISOString().slice(0,10)}T00:00:00.000Z`);return Math.round((n-o)/864e5)}function Kn(e,t){return e.tasks.filter(n=>n.claimedBy===t||n.assignee===t&&n.status===e.started)}function Dt(e,t,n,o=new Date){let s=w(e,t);if(!v(s))return s;let{state:r,warnings:i}=x(s.root,s.actor),d=r.sprints.find(g=>g.status==="active"),a=d===void 0?null:Bn(d.endDate,o),c=Kn(r,s.actor),l=[...c].reverse().slice(0,Mn),m=F(r.tasks,{viewer:s.actor,statuses:r.statuses,started:r.started}),f=q(r,o,In).rows,h=f.slice(0,Ln),p=r.decisions.filter(g=>g.supersededBy===null).slice(-_n).reverse().map(g=>({label:g.label,title:g.title})),k=r.notes.slice(-Pn).reverse().map(g=>({text:g.text,by:g.by,task:On(r,g.task)})),$=[];$.push(d===void 0?"No active sprint.":`Sprint: ${d.name}${a===null?"":`, ${a} day(s) left`}`);let O=c.length>l.length?`${l.length} of ${c.length}`:`${l.length}`;$.push("",c.length===0?"Nothing claimed by you.":`Yours (${O}):`);for(let g of l)$.push(` ${g.label} ${g.status} ${de(g.title)}`);if($.push("",`Ready to start: ${m.length} (kadence ready)`),h.length>0){let g=f.length>h.length?`${h.length} of ${f.length}`:`${h.length}`;$.push("",`Nobody is moving (${g}): (kadence report attention)`);for(let we of h)$.push(` ${we.label} ${we.signals.map(J).join(" \xB7 ")}`)}if(p.length>0){$.push("","Decisions in force:");for(let g of p)$.push(` ${g.label} ${de(g.title)}`)}if(k.length>0){$.push("","Recent notes:");for(let g of k)$.push(` ${g.task===null?"":`${g.task} `}${de(g.text)}`)}$.push("","Go deeper:");for(let g of jt)$.push(` ${g}`);return{ok:!0,exitCode:0,warnings:i,message:$.join(`
26
- `),data:{schema:"kadence/v1",ok:!0,sprint:d===void 0?null:{name:d.name,endDate:d.endDate,daysLeft:a},mine:l.map(g=>({label:g.label,title:g.title,status:g.status})),mineTotal:c.length,ready:m.length,attention:h,attentionTotal:f.length,decisions:p,notes:k,commands:jt}}}var Wn=3;function Tt(e,t){let n=new Map;for(let o of e)n.set(t(o),(n.get(t(o))??0)+1);return[...n.entries()].sort((o,s)=>s[1]-o[1]||(o[0]<s[0]?-1:1))}function Fn(e){return e.sprints.filter(t=>t.status==="closed").sort((t,n)=>(t.closedBy??"")<(n.closedBy??"")?1:-1).slice(0,Wn).map(t=>{let n=P(e,t.id);return{name:t.name,velocity:n?.velocity??0}})}function Et(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i=s.tasks.filter(p=>p.status!==D&&p.status!==T),d=new Set(s.tasks.filter(p=>p.status===D||p.status===T).map(p=>p.id)),a=Tt(s.tasks,p=>p.status),c=Tt(i,p=>p.assignee??"unassigned"),l=i.filter(p=>p.blockedBy.some(k=>!d.has(k))),m=s.tasks.filter(p=>p.contestedBy.length>0),f=Fn(s);if(s.tasks.length===0)return{ok:!0,exitCode:0,warnings:r,message:`No tasks yet.
27
+ `:"";ie(n,`${t}${r}${Zt}
28
+ `,"utf8")}function bs(e,n,t){let r=J(e,n),s=q(r)?ke(r,"utf8"):null,o=et(s,t);o!==s&&ie(r,o,"utf8")}function ys(e){return{label:e.label,title:e.title,priority:e.priority,estimate:e.estimate,labels:e.labels,claimedBy:e.claimedBy,contestedBy:e.contestedBy}}function sn(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i={statuses:s.statuses,started:s.started},a=pe(s.tasks,{viewer:r.actor,...i,...t.assignee===void 0?{}:{assignee:t.assignee}}),d=t.limit!==void 0&&t.limit>0?a.slice(0,t.limit):a;if(d.length===0)return{ok:!0,exitCode:0,warnings:o,message:lt(s.tasks,r.actor,t.assignee,i),data:{schema:"kadence/v1",ok:!0,tasks:[]}};let l=me(n,process.stdout.isTTY===!0),c=d.map(u=>{let m=u.contestedBy.length>0?` [contested: ${u.contestedBy.join(", ")}]`:"";return`${rt(u,l)}${m}`});return{ok:!0,exitCode:0,warnings:o,message:[...c,"",`Take the first one:
29
+ kadence task claim ${d[0].label}`].join(`
30
+ `),data:{schema:"kadence/v1",ok:!0,tasks:d.map(ys)}}}var $s=864e5;function Ne(e){return e.history[e.history.length-1]?.ts??e.createdAt}function ae(e,n){let t=Math.floor((n.getTime()-Date.parse(e))/$s);return t>0?t:0}function ws(e){for(let n=e.history.length-1;n>=0;n--){let t=e.history[n];if(t.id===e.claimedEventId)return!1;if(t.type==="task.moved")return!0}return!1}function vs(e,n,t,r,s,o){let i=[],a=e.blockedBy.filter(l=>r.has(l));if(a.length>0&&i.push({kind:"dead_blocker",blockers:a.map(l=>t.get(l)??l)}),!oe(n,e))return i;let d=ae(Ne(e),s);if(d>=o&&i.push({kind:"stalled",days:d}),e.assignee===null&&e.claimedBy===null){let l=it(e,n.started,n.statuses,n.startedChanges),c=l===null?d:ae(l,s);c>=o&&i.push({kind:"unowned",days:c})}if(e.claimedBy!==null&&e.claimedAt!==null&&!ws(e)){let l=ae(e.claimedAt,s);l>=o&&i.push({kind:"stale_claim",days:l,who:e.claimedBy})}return i}function ee(e){switch(e.kind){case"stalled":return`stalled ${String(e.days)}d`;case"unowned":return`unowned ${String(e.days)}d`;case"stale_claim":return`claimed ${String(e.days)}d ago by ${e.who??"someone"}, never moved`;case"dead_blocker":return`blocked by ${(e.blockers??[]).join(", ")}, already done`}}function be(e,n=new Date,t=7){let r=e.tasks.filter(d=>!Q(d)),s=new Set(e.tasks.filter(Q).map(d=>d.id)),o=new Map(e.tasks.map(d=>[d.id,d.label])),i=[];for(let d of r){let l=vs(d,e,o,s,n,t);l.length!==0&&i.push({label:d.label,title:d.title,status:d.status,priority:d.priority,assignee:d.assignee,idleDays:ae(Ne(d),n),signals:l})}let a=new Map(e.tasks.map((d,l)=>[d.label,l]));return i.sort((d,l)=>l.idleDays!==d.idleDays?l.idleDays-d.idleDays:(a.get(d.label)??0)-(a.get(l.label)??0)),{threshold:t,started:e.started,asOf:n.toISOString().slice(0,10),rows:i,notes:i.length>0?[]:xs(e,r,n,t)}}function xs(e,n,t,r){let s=n.filter(i=>oe(e,i));if(s.length===0)return[`Nothing to report: there is no work in progress past \`${e.started}\`.`];let o=Math.min(...s.map(i=>ae(Ne(i),t)));return[`Nothing to report: ${String(s.length)} task${s.length===1?"":"s"} in progress, none silent or ownerless for ${String(r)} days (the quietest was touched ${String(o)} day(s) ago).`]}function Ss(e,n){return n===null?null:e.tasks.find(t=>t.id===n)?.label??null}var Cs=5,As=5,js=5,Ds=3,Ts=7,rn=60,Rs='record why: kadence decision add "\u2026" --why "\u2026"',on=["kadence ready what can be started now","kadence task show KAD-1 one task in full, with its decisions","kadence decision list the reasons behind the work","kadence board the whole board"];function Oe(e){let n=[...e];return n.length>rn?`${n.slice(0,rn-1).join("")}\u2026`:e}function Es(e,n){if(e===null)return null;let t=Date.parse(`${e}T00:00:00.000Z`);if(Number.isNaN(t))return null;let r=Date.parse(`${n.toISOString().slice(0,10)}T00:00:00.000Z`);return Math.round((t-r)/864e5)}function Ns(e,n){return e.tasks.filter(t=>t.claimedBy===n||t.assignee===n&&t.status===e.started)}function an(e,n,t,r=new Date){let s=S(e,n);if(!C(s))return s;let{state:o,warnings:i}=A(s.root,s.actor),a=o.sprints.find(g=>g.status==="active"),d=a===void 0?null:Es(a.endDate,r),l=Ns(o,s.actor),c=[...l].reverse().slice(0,Cs),u=pe(o.tasks,{viewer:s.actor,statuses:o.statuses,started:o.started}),m=be(o,r,Ts).rows,k=m.slice(0,Ds),f=o.decisions.filter(g=>g.supersededBy===null).slice(-As).reverse().map(g=>({label:g.label,title:g.title})),y=o.notes.slice(-js).reverse().map(g=>({text:g.text,by:g.by,task:Ss(o,g.task)})),b=[];a!==void 0&&b.push(`Sprint: ${a.name}${d===null?"":`, ${d} day(s) left`}`,"");let v=l.length>c.length?`${c.length} of ${l.length}`:`${c.length}`;b.push(l.length===0?"Nothing claimed by you.":`Yours (${v}):`);for(let g of c)b.push(` ${g.label} ${g.status} ${Oe(g.title)}`);if(b.push("",`Ready to start: ${u.length} (kadence ready)`),k.length>0){let g=m.length>k.length?`${k.length} of ${m.length}`:`${k.length}`;b.push("",`Nobody is moving (${g}): (kadence report attention)`);for(let W of k)b.push(` ${W.label} ${W.signals.map(ee).join(" \xB7 ")}`)}if(f.length>0){b.push("","Decisions in force:");for(let g of f)b.push(` ${g.label} ${Oe(g.title)}`)}else b.push("",Rs);if(y.length>0){b.push("","Recent notes:");for(let g of y)b.push(` ${g.task===null?"":`${g.task} `}${Oe(g.text)}`)}b.push("","Go deeper:");for(let g of on)b.push(` ${g}`);return{ok:!0,exitCode:0,warnings:i,message:b.join(`
31
+ `),data:{schema:"kadence/v1",ok:!0,sprint:a===void 0?null:{name:a.name,endDate:a.endDate,daysLeft:d},mine:c.map(g=>({label:g.label,title:g.title,status:g.status})),mineTotal:l.length,ready:u.length,attention:k,attentionTotal:m.length,decisions:f,notes:y,commands:on}}}var Os=3;function dn(e,n){let t=new Map;for(let r of e)t.set(n(r),(t.get(n(r))??0)+1);return[...t.entries()].sort((r,s)=>s[1]-r[1]||(r[0]<s[0]?-1:1))}function Ms(e){return e.sprints.filter(n=>n.status==="closed").sort((n,t)=>(n.closedBy??"")<(t.closedBy??"")?1:-1).slice(0,Os).map(n=>{let t=X(e,n.id);return{name:n.name,velocity:t?.velocity??0}})}function ln(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i=s.tasks.filter(f=>f.status!==O&&f.status!==M),a=new Set(s.tasks.filter(f=>f.status===O||f.status===M).map(f=>f.id)),d=dn(s.tasks,f=>f.status),l=dn(i,f=>f.assignee??"unassigned"),c=i.filter(f=>f.blockedBy.some(y=>!a.has(y))),u=s.tasks.filter(f=>f.contestedBy.length>0),m=Ms(s);if(s.tasks.length===0)return{ok:!0,exitCode:0,warnings:o,message:`No tasks yet.
27
32
  Create the first one:
28
- kadence task add "title"`,data:{schema:"kadence/v1",ok:!0,tasks:0,open:0,byStatus:[],byAssignee:[],blocked:[],contested:[],velocity:[]}};let h=[];h.push(`${s.tasks.length} tasks, ${i.length} open`),h.push("","By status:");for(let[p,k]of a)h.push(` ${k} ${p}`);if(c.length>0){h.push("","Open work by assignee:");for(let[p,k]of c)h.push(` ${k} ${p}`)}if(l.length>0&&h.push("",`Blocked (${l.length}): ${l.map(p=>p.label).join(", ")}`),m.length>0&&h.push("",`Contested (${m.length}): ${m.map(p=>p.label).join(", ")}`),f.length>0){h.push("","Velocity of the last closed sprints:");for(let p of f)h.push(` ${p.velocity} points ${p.name}`)}return{ok:!0,exitCode:0,warnings:r,message:h.join(`
29
- `),data:{schema:"kadence/v1",ok:!0,tasks:s.tasks.length,open:i.length,byStatus:a.map(([p,k])=>({status:p,count:k})),byAssignee:c.map(([p,k])=>({assignee:p,count:k})),blocked:l.map(p=>p.label),contested:m.map(p=>p.label),velocity:f}}}var Un=2;function Yn(e,t){let n=e.getUTCFullYear(),o=e.getUTCMonth();return new Date(Date.UTC(n,o-(t-1),1)).toISOString().slice(0,7)}function Rt(e,t,n,o=new Date){let s=w(e,t);if(!v(s))return s;let r=n.keepMonths??Un;if(!Number.isInteger(r)||r<1){let l=n.keepMonthsRaw??String(r);return y(2,"invalid_argument",`--keep-months must be a whole number of at least 1, got "${l}".`,{received:l,hint:"kadence compact --keep-months 3"})}let i=Yn(o,r),d=Se(s.root,i);if(d.months.length===0)return{ok:!0,exitCode:0,message:`Nothing to archive: every event is from ${i} or later, which --keep-months ${r} keeps as separate files.`,data:{schema:"kadence/v1",ok:!0,keepFrom:i,archivedMonths:[],archivedEvents:0,dryRun:n.dryRun===!0}};let a=d.months.map(l=>`${l.month} (${l.events} event${l.events===1?"":"s"})`).join(", ");if(n.dryRun===!0)return{ok:!0,exitCode:0,message:`Would archive ${d.events} event${d.events===1?"":"s"} from ${a}, keeping ${i} onward as separate files.
30
- Nothing was written. Drop --dry-run to do it.`,data:{schema:"kadence/v1",ok:!0,keepFrom:i,archivedMonths:d.months.map(l=>l.month),archivedEvents:d.events,dryRun:!0}};let c=Ce(s.root,i);if(c.skipped.length>0){let l=c.skipped.map(f=>f.replace(`${s.root}/`,"")).join(", "),m=c.archivedMonths.length>0?`Archived ${c.archivedMonths.join(", ")} first; those are done.
31
- `:"";return y(1,"conflicting_state",`${m}Could not read ${l}, so ${c.skipped.length===1?"that month was":"those months were"} left alone. Nothing was deleted. The archive holds every event compacted before it \u2014 restore the file from git, or move it aside if you accept losing what it held, then run this again.`,{received:l,hint:"git checkout -- .kadence/events/archive/"})}return{ok:!0,exitCode:0,message:`Archived ${c.archivedEvents} event${c.archivedEvents===1?"":"s"} from ${a} into .kadence/events/archive/, keeping ${i} onward as separate files.
33
+ kadence task add "title"`,data:{schema:"kadence/v1",ok:!0,tasks:0,open:0,byStatus:[],byAssignee:[],blocked:[],contested:[],velocity:[]}};let k=[];k.push(`${s.tasks.length} tasks, ${i.length} open`),k.push("","By status:");for(let[f,y]of d)k.push(` ${y} ${f}`);if(l.length>0){k.push("","Open work by assignee:");for(let[f,y]of l)k.push(` ${y} ${f}`)}if(c.length>0&&k.push("",`Blocked (${c.length}): ${c.map(f=>f.label).join(", ")}`),u.length>0&&k.push("",`Contested (${u.length}): ${u.map(f=>f.label).join(", ")}`),m.length>0){k.push("","Velocity of the last closed sprints:");for(let f of m)k.push(` ${f.velocity} points ${f.name}`)}return{ok:!0,exitCode:0,warnings:o,message:k.join(`
34
+ `),data:{schema:"kadence/v1",ok:!0,tasks:s.tasks.length,open:i.length,byStatus:d.map(([f,y])=>({status:f,count:y})),byAssignee:l.map(([f,y])=>({assignee:f,count:y})),blocked:c.map(f=>f.label),contested:u.map(f=>f.label),velocity:m}}}var _s=2;function Ps(e,n){let t=e.getUTCFullYear(),r=e.getUTCMonth();return new Date(Date.UTC(t,r-(n-1),1)).toISOString().slice(0,7)}function cn(e,n,t,r=new Date){let s=S(e,n);if(!C(s))return s;let o=t.keepMonths??_s;if(!Number.isInteger(o)||o<1){let c=t.keepMonthsRaw??String(o);return w(2,"invalid_argument",`--keep-months must be a whole number of at least 1, got "${c}".`,{received:c,hint:"kadence compact --keep-months 3"})}let i=Ps(r,o),a=Ze(s.root,i);if(a.months.length===0)return{ok:!0,exitCode:0,message:`Nothing to archive: every event is from ${i} or later, which --keep-months ${o} keeps as separate files.`,data:{schema:"kadence/v1",ok:!0,keepFrom:i,archivedMonths:[],archivedEvents:0,dryRun:t.dryRun===!0}};let d=a.months.map(c=>`${c.month} (${c.events} event${c.events===1?"":"s"})`).join(", ");if(t.dryRun===!0)return{ok:!0,exitCode:0,message:`Would archive ${a.events} event${a.events===1?"":"s"} from ${d}, keeping ${i} onward as separate files.
35
+ Nothing was written. Drop --dry-run to do it.`,data:{schema:"kadence/v1",ok:!0,keepFrom:i,archivedMonths:a.months.map(c=>c.month),archivedEvents:a.events,dryRun:!0}};let l=Qe(s.root,i);if(l.skipped.length>0){let c=l.skipped.map(m=>m.replace(`${s.root}/`,"")).join(", "),u=l.archivedMonths.length>0?`Archived ${l.archivedMonths.join(", ")} first; those are done.
36
+ `:"";return w(1,"conflicting_state",`${u}Could not read ${c}, so ${l.skipped.length===1?"that month was":"those months were"} left alone. Nothing was deleted. The archive holds every event compacted before it \u2014 restore the file from git, or move it aside if you accept losing what it held, then run this again.`,{received:c,hint:"git checkout -- .kadence/events/archive/"})}return{ok:!0,exitCode:0,message:`Archived ${l.archivedEvents} event${l.archivedEvents===1?"":"s"} from ${d} into .kadence/events/archive/, keeping ${i} onward as separate files.
32
37
  An archived month is one file. Compact on one branch and merge it before compacting on another; the events themselves are unchanged, only where they live.
33
- Nothing was committed \u2014 that call is yours.`,data:{schema:"kadence/v1",ok:!0,keepFrom:i,archivedMonths:c.archivedMonths,archivedEvents:c.archivedEvents,dryRun:!1}}}var H=["flow","cfd","attention"],Ot=30,zn=7,Nt=730;function Jn(e,t=Ot){if(e===void 0)return t;let n=/^(\d+)\s*d?$/i.exec(e.trim()),o=n===null?NaN:Number(n[1]);return!Number.isInteger(o)||o<1||o>Nt?y(2,"invalid_argument",`--since takes a number of days from 1 to ${Nt}, like 30d, got "${e}".`,{received:e,hint:"kadence report flow --since 30d"}):o}function ce(e,t){return e===null?"no data":`p50 ${e.p50} \xB7 p85 ${e.p85} \xB7 p95 ${e.p95} ${t} (n=${e.n})`}function qn(e){let t=[];if(t.push(`Flow, ${e.window.from} to ${e.window.to} UTC (${e.window.days} calendar days). Work starts at "${e.started}".`),t.push(""),t.push(` In progress now: ${e.wip}`),t.push(` Finished: ${e.finished}`),t.push(` Cycle time: ${ce(e.cycleTime,"days")}`),t.push(` Lead time: ${ce(e.leadTime,"days")}`),t.push(` Response time: ${ce(e.responseTime,"days")}`),e.blocked.tasks>0&&t.push(` Blocked: ${e.blocked.tasks} task(s), ${e.blocked.days} days in total`),e.sle!==null&&t.push("",` ${e.sle}`),e.perWeek.some(n=>n.finished>0||n.created>0)){t.push(""," Week Created Finished");for(let n of e.perWeek)t.push(` ${n.week} ${String(n.created).padStart(7)} ${String(n.finished).padStart(8)}`)}if(e.aging.length>0){t.push(""," Aging work in progress (oldest first):");for(let n of e.aging.slice(0,10)){let o=n.overP85?" \u2190 older than p85":"";t.push(` ${n.label} ${String(n.ageDays).padStart(5)} d ${n.status} ${n.title}${o}`)}e.aging.length>10&&t.push(` \u2026 and ${e.aging.length-10} more`)}if(e.notes.length>0){t.push("");for(let n of e.notes)t.push(` ${n}`)}return t.join(`
34
- `)}function Hn(e){let t=[];t.push(`Cumulative flow, ${e.window.from} to ${e.window.to} UTC. Tasks per column at the end of each day.`),t.push("");let n=e.statuses,o=Math.max(6,...n.map(r=>r.length));t.push(` ${"date".padEnd(10)} ${n.map(r=>r.padStart(o)).join(" ")}`);let s=e.days.filter((r,i)=>i%7===0||i===e.days.length-1);for(let r of s)t.push(` ${r.date} ${n.map(i=>String(r.counts[i]??0).padStart(o)).join(" ")}`);return s.length<e.days.length&&t.push("",` ${e.days.length} days in the window; one row per week shown. --json carries every day.`),t.join(`
35
- `)}function Vn(e){let t=[];if(t.push(`Attention, as of ${e.asOf} UTC. Work past "${e.started}" that nobody is moving \u2014 silent or ownerless for ${e.threshold} days or more, or blocked by work that is already done.`),e.rows.length>0){t.push("");for(let n of e.rows.slice(0,15))t.push(` ${n.label} ${String(n.idleDays).padStart(4)} d ${n.title}`),t.push(` ${n.signals.map(J).join(" \xB7 ")}`);e.rows.length>15&&t.push(` \u2026 and ${e.rows.length-15} more`)}if(e.notes.length>0){t.push("");for(let n of e.notes)t.push(` ${n}`)}return t.join(`
36
- `)}function Mt(e,t,n,o,s=new Date){if(n===void 0||!H.includes(n))return y(2,"invalid_argument",`Which report?
37
- kadence report flow cycle time, throughput, aging work
38
- kadence report cfd tasks per column, per day
39
- kadence report attention work in flight that nobody is moving`,{...n===void 0?{}:{received:n},allowed:H,hint:"kadence report flow"});let r=Jn(o.since,n==="attention"?zn:Ot);if(typeof r!="number")return r;let i=w(e,t);if(!v(i))return i;let{state:d,warnings:a}=x(i.root,i.actor);if(n==="attention"){let l=q(d,s,r);return{ok:!0,exitCode:0,warnings:a,message:Vn(l),data:{schema:"kadence/v1",ok:!0,report:"attention",...l}}}if(n==="cfd"){let l=_e(d,s,r);return{ok:!0,exitCode:0,warnings:a,message:Hn(l),data:{schema:"kadence/v1",ok:!0,report:"cfd",...l}}}let c=Me(d,s,r);return{ok:!0,exitCode:0,warnings:a,message:qn(c),data:{schema:"kadence/v1",ok:!0,report:"flow",...c}}}import{existsSync as Gn,mkdirSync as Zn,readFileSync as Qn,writeFileSync as Xn}from"node:fs";import{homedir as es}from"node:os";import{dirname as _t,join as le}from"node:path";var V="# kadence completion",L=["zsh","bash","fish"];function ts(e){return L.includes(e)}var ue=[["init","Set up kadence in this repository"],["prime","Everything a session needs before it starts"],["ready","What can be started right now"],["task","Tasks: add, list, show, move, claim, ac"],["board","Kanban board in the terminal"],["sprint","Sprints: create, start, close, status"],["milestone","Milestones: create, add, list, close"],["decision","Decisions: add, list, show"],["note","Record something learned"],["stats","Where the project stands"],["template","Task templates: save, list, delete"],["schema","The machine-readable --json contract"],["completion","Shell completion"],["ui","The interactive board"]],me=["add","list","show","edit","move","assign","comment","log","parent","block","unblock","claim","release","ac","doc","cancel","delete"];function ns(e){let t=ue.map(([n])=>n).join(" ");return e==="fish"?`${[`${V} for fish`,"complete -c kadence -f",...ue.map(([o,s])=>`complete -c kadence -n "not __fish_seen_subcommand_from ${t}" -a ${o} -d '${s.replace(/'/g,"")}'`),`complete -c kadence -n "__fish_seen_subcommand_from task" -a "${me.join(" ")}"`,"complete -c kadence -l json -d 'Machine-readable output for agents'"].join(`
38
+ Nothing was committed \u2014 that call is yours.`,data:{schema:"kadence/v1",ok:!0,keepFrom:i,archivedMonths:l.archivedMonths,archivedEvents:l.archivedEvents,dryRun:!1}}}function un(e,n=new Date){let t=e.tasks.filter(d=>!Q(d)),r=new Set(e.tasks.filter(d=>!Q(d)).map(d=>d.id)),s=new Map;for(let d of t){let l=d.assignee,c=s.get(l);c===void 0?s.set(l,[d]):c.push(d)}let o=[...s.entries()].map(([d,l])=>({assignee:d,open:l.length,openPoints:l.reduce((c,u)=>c+(u.estimate??0),0),inProgress:l.filter(c=>oe(e,c)).length,blocked:l.filter(c=>c.blockedBy.some(u=>r.has(u))).length,unestimated:l.filter(c=>c.estimate===null).length})).sort((d,l)=>l.openPoints-d.openPoints||l.open-d.open),i=[];o.length===0&&i.push("Nothing open.");let a=o.reduce((d,l)=>d+l.unestimated,0);return a>0&&i.push(`${a} open task${a===1?"":"s"} carry no estimate, so the points understate the work by an unknown amount.`),{asOf:n.toISOString().slice(0,10),started:e.started,rows:o,notes:i}}function $(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var P=`
39
+ :root {
40
+ color-scheme: light dark;
41
+ --bg: #ffffff; --fg: #1a1a1a; --muted: #6b6b6b; --line: #e2e2e2;
42
+ --card: #fafafa; --accent: #2d6cdf; --done: #2e7d32; --warn: #b26a00;
43
+ --danger: #c62828;
44
+ --grid: #ececec;
45
+ --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
46
+ --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
47
+ --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
48
+ }
49
+ @media (prefers-color-scheme: dark) {
50
+ :root {
51
+ --bg: #17181a; --fg: #e8e8e8; --muted: #9a9a9a; --line: #2e2f33;
52
+ --card: #1f2023; --accent: #6ea8fe; --done: #7bc47f; --warn: #e0a458;
53
+ --danger: #ef6b6b;
54
+ --grid: #2b2c30;
55
+ --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
56
+ --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
57
+ }
58
+ }
59
+ * { box-sizing: border-box; }
60
+ body {
61
+ margin: 0; padding: 2rem 1.5rem; background: var(--bg); color: var(--fg);
62
+ font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
63
+ }
64
+ main { max-width: 1100px; margin: 0 auto; }
65
+ h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
66
+ h2 { font-size: 1.05rem; margin: 2rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); }
67
+ .stamp { color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }
68
+ .stamp code { background: var(--card); padding: .1rem .3rem; border-radius: 3px; }
69
+ .pill { display: inline-block; font-size: .72rem; padding: .05rem .35rem; border-radius: 3px; border: 1px solid var(--line); margin-right: .25rem; }
70
+ .pill.danger { color: var(--danger); border-color: var(--danger); }
71
+ .pill.warn { color: var(--warn); border-color: var(--warn); }
72
+ .bar { background: var(--line); border-radius: 3px; height: .55rem; overflow: hidden; }
73
+ .bar > span { display: block; height: 100%; background: var(--accent); }
74
+ .bar.done > span { background: var(--done); }
75
+ table { border-collapse: collapse; width: 100%; font-size: .88rem; }
76
+ th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
77
+ th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
78
+ td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
79
+ .empty { color: var(--muted); }
80
+ footer { margin-top: 2.5rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); padding-top: .75rem; }
81
+ `,I=`
82
+ .tiles { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 1.5rem; }
83
+ .tile { flex: 1 1 140px; max-width: 16rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .75rem; }
84
+ .tile .label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
85
+ .tile .value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
86
+ .tile .sub, td .sub { color: var(--muted); font-size: .78rem; }
87
+ .tile.critical .value { color: var(--critical); }
88
+ .callout { background: var(--card); border-left: 3px solid var(--s1); border-radius: 0 5px 5px 0; padding: .6rem .8rem; margin: 0 0 1.5rem; }
89
+ .viz { width: 100%; height: auto; display: block; overflow: visible; }
90
+ .viz .grid { stroke: var(--grid); stroke-width: 1; }
91
+ .viz .tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
92
+ .viz .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
93
+ .viz .seam { fill: none; stroke: var(--bg); stroke-width: 2; }
94
+ .viz .range { stroke: var(--s1); stroke-width: 2; stroke-linecap: round; }
95
+ .viz .dot { fill: var(--s1); stroke: var(--bg); stroke-width: 2; }
96
+ .viz .reference { stroke: var(--critical); stroke-width: 1; }
97
+ .viz .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
98
+ .viz .reference-line { stroke: var(--muted); stroke-width: 2; opacity: .45; }
99
+ .legend { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 .5rem; font-size: .8rem; color: var(--muted); }
100
+ .legend span { display: inline-flex; align-items: center; gap: .35rem; }
101
+ .legend i { width: .7rem; height: .7rem; border-radius: 2px; display: inline-block; }
102
+ /* A five-column table is wider than a phone. It scrolls inside its own box
103
+ rather than making the whole page scroll sideways. */
104
+ .rows { overflow-x: auto; }
105
+ .figure { margin: 0 0 1rem; }
106
+ .figure figcaption { color: var(--muted); font-size: .8rem; margin-top: .4rem; }
107
+ details { margin: .5rem 0 1.5rem; }
108
+ summary { color: var(--muted); font-size: .82rem; cursor: pointer; }
109
+ summary::marker { color: var(--line); }
110
+ tr.critical td:first-child { border-left: 3px solid var(--critical); }
111
+ `;function L(e,n,t){return["<!doctype html>",'<html lang="en">',"<head>",'<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',`<title>${$(e)}</title>`,`<style>${n}</style>`,"</head>","<body>","<main>",...t,"</main>","</body>","</html>",""].join(`
112
+ `)}function j(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function p(e){return Number.isFinite(e)?String(Math.round(e*100)/100):"0"}function de(e){if(!Number.isFinite(e)||e<=0)return 1;let n=Math.floor(Math.log10(e)),t=Math.pow(10,n),r=e/t;return(r<=1?1:r<=2?2:r<=5?5:10)*t}function Is(e,n,t,r){let s=Math.min(4,t/2,r);return r<=0?"":`M${p(e)},${p(n+r)}L${p(e)},${p(n+s)}Q${p(e)},${p(n)} ${p(e+s)},${p(n)}L${p(e+t-s)},${p(n)}Q${p(e+t)},${p(n)} ${p(e+t)},${p(n+s)}L${p(e+t)},${p(n+r)}Z`}function Ls(e,n,t,r){let s=Math.min(4,r/2,t);return t<=0?"":`M${p(e)},${p(n)}L${p(e+t-s)},${p(n)}Q${p(e+t)},${p(n)} ${p(e+t)},${p(n+s)}L${p(e+t)},${p(n+r-s)}Q${p(e+t)},${p(n+r)} ${p(e+t-s)},${p(n+r)}L${p(e)},${p(n+r)}Z`}function le(e,n,t,r){return`<svg class="viz" viewBox="0 0 ${e} ${n}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${j(t)}"><title>${j(t)}</title>${r}</svg>`}function Me(e){let t=e.height??220,r={top:12,right:14,bottom:30,left:38},s=760-r.left-r.right,o=t-r.top-r.bottom,i=Math.max(1,e.labels.length),a=s/i,d=de(Math.max(0,...e.series.flatMap(v=>v.values))),l=v=>r.top+o-v/d*o,c=[];for(let v of[0,d/2,d])c.push(`<line class="grid" x1="${r.left}" y1="${p(l(v))}" x2="${p(760-r.right)}" y2="${p(l(v))}"/>`,`<text class="tick" x="${r.left-6}" y="${p(l(v)+3.5)}" text-anchor="end">${p(v)}</text>`);let u=2,m=(a-8-u*(e.series.length-1))/e.series.length,k=Math.min(24,Math.max(2,m)),f=k*e.series.length+u*(e.series.length-1);e.series.forEach((v,g)=>{e.labels.forEach((W,z)=>{let Z=v.values[z]??0,re=o-(l(Z)-r.top);if(re<=0)return;let Y=r.left+z*a+(a-f)/2+g*(k+u);c.push(`<path d="${Is(Y,l(Z),k,re)}" fill="var(${v.color})"><title>${j(W)} \xB7 ${j(v.name)}: ${Z} ${j(e.unit)}</title></path>`)})});let y=e.labels.length>8;e.labels.forEach((v,g)=>{let W=g===0||g===e.labels.length-1;if(!(y&&!W)){if(y){let z=g===0?r.left:760-r.right;c.push(`<text class="tick" x="${p(z)}" y="${p(t-10)}" text-anchor="${g===0?"start":"end"}">${j(v)}</text>`);return}c.push(`<text class="tick" x="${p(r.left+g*a+a/2)}" y="${p(t-10)}" text-anchor="middle">${j(v)}</text>`)}});let b=`${e.series.map(v=>v.name).join(" and ")} per period, in ${e.unit}.`;return le(760,t,b,c.join(""))}function mn(e){let t=e.height??240,r={top:12,right:104,bottom:30,left:38},s=760-r.left-r.right,o=t-r.top-r.bottom,i=Math.max(1,e.dates.length),a=b=>i===1?r.left+s/2:r.left+b/(i-1)*s,d=e.dates.map((b,v)=>e.bands.reduce((g,W)=>g+(W.values[v]??0),0)),l=de(Math.max(0,...d)),c=b=>r.top+o-b/l*o,u=[];for(let b of[0,l/2,l])u.push(`<line class="grid" x1="${r.left}" y1="${p(c(b))}" x2="${p(760-r.right)}" y2="${p(c(b))}"/>`,`<text class="tick" x="${r.left-6}" y="${p(c(b)+3.5)}" text-anchor="end">${p(b)}</text>`);let m=e.dates.map(()=>0),k=[...e.bands].reverse(),f=[];for(let b of k){let v=[...m];e.dates.forEach((Y,N)=>{m[N]=(m[N]??0)+(b.values[N]??0)});let g=e.dates.map((Y,N)=>`${p(a(N))},${p(c(m[N]??0))}`),W=e.dates.map((Y,N)=>`${p(a(N))},${p(c(v[N]??0))}`).reverse();if(i===1){let Y=Math.min(24,s),N=c(v[0]??0)-c(m[0]??0);N>0&&u.push(`<rect x="${p(a(0)-Y/2)}" y="${p(c(m[0]??0))}" width="${p(Y)}" height="${p(N)}" fill="var(${b.color})"><title>${j(b.name)}: ${b.values[0]??0}</title></rect>`);continue}u.push(`<path d="M${g.join("L")}L${W.join("L")}Z" fill="var(${b.color})" fill-opacity="0.9"><title>${j(b.name)}</title></path>`,`<polyline class="seam" points="${g.join(" ")}"/>`);let z=e.dates.length-1,Z=c(m[z]??0),re=c(v[z]??0);f.push({name:b.name,y:(Z+re)/2,height:re-Z})}let y=Number.NEGATIVE_INFINITY;for(let b of[...f].sort((v,g)=>v.y-g.y))b.height<10||b.y-y<13||(y=b.y,u.push(`<text class="tick" x="${p(760-r.right+10)}" y="${p(b.y+3.5)}">${j(b.name)}</text>`));return e.dates.forEach((b,v)=>{(v===0||v===e.dates.length-1)&&u.push(`<text class="tick" x="${p(a(v))}" y="${p(t-10)}" text-anchor="${v===0?"start":"end"}">${j(b)}</text>`)}),le(760,t,`Tasks per column per day, ${e.bands.map(b=>b.name).join(", ")}.`,u.join(""))}function ye(e){let r={top:8,right:52,bottom:26,left:92},s=r.top+r.bottom+Math.max(1,e.rows.length)*26,o=760-r.left-r.right,i=de(Math.max(e.reference?.value??0,...e.rows.map(l=>l.value))),a=l=>r.left+l/i*o,d=[];return d.push(`<line class="grid" x1="${r.left}" y1="${r.top}" x2="${r.left}" y2="${p(s-r.bottom)}"/>`),e.rows.forEach((l,c)=>{let u=r.top+c*26,m=Math.min(14,16),k=a(l.value)-r.left,f=l.critical===!0?"var(--critical)":"var(--s1)";d.push(`<text class="tick mono" x="${r.left-8}" y="${p(u+m/2+8)}" text-anchor="end">${j(l.name)}</text>`,`<path d="${Ls(r.left,u+5,Math.max(k,1),m)}" fill="${f}"><title>${j(l.name)}: ${l.value} ${j(e.unit)}${l.note===void 0?"":` \xB7 ${j(l.note)}`}</title></path>`,`<text class="tick" x="${p(a(l.value)+6)}" y="${p(u+m/2+8)}">${l.value}</text>`)}),e.reference!==void 0&&e.reference.value>0&&d.push(`<line class="reference" x1="${p(a(e.reference.value))}" y1="${r.top}" x2="${p(a(e.reference.value))}" y2="${p(s-r.bottom+4)}"/>`,`<text class="tick" x="${p(a(e.reference.value))}" y="${p(s-10)}" text-anchor="middle">${j(e.reference.label)}</text>`),le(760,s,`${e.rows.length} rows, in ${e.unit}.`,d.join(""))}function pn(e,n){let s={top:10,right:20,bottom:26,left:92},o=s.top+s.bottom+Math.max(1,e.length)*44,i=760-s.left-s.right,a=de(Math.max(1,...e.map(c=>c.p95))),d=c=>s.left+c/a*i,l=[];for(let c of[0,a/2,a])l.push(`<line class="grid" x1="${p(d(c))}" y1="${s.top}" x2="${p(d(c))}" y2="${p(o-s.bottom+2)}"/>`,`<text class="tick" x="${p(d(c))}" y="${p(o-10)}" text-anchor="middle">${p(c)}</text>`);return e.forEach((c,u)=>{let m=s.top+u*44+22-4;l.push(`<text class="tick" x="${s.left-8}" y="${p(m+4)}" text-anchor="end">${j(c.name)}</text>`,`<line class="range" x1="${p(d(c.p50))}" y1="${p(m)}" x2="${p(d(c.p95))}" y2="${p(m)}"/>`);for(let[k,f,y]of[["p50",c.p50,4.5],["p85",c.p85,6],["p95",c.p95,4.5]])l.push(`<circle class="dot" cx="${p(d(f))}" cy="${p(m)}" r="${y}"><title>${j(c.name)} ${k}: ${f} ${j(n)} (n=${c.n})</title></circle>`);l.push(`<text class="tick" x="${p(d(c.p85))}" y="${p(m-12)}" text-anchor="middle">p85 = ${c.p85}</text>`)}),le(760,o,`p50, p85 and p95 per measure, in ${n}.`,l.join(""))}function hn(e){let t=e.height??230,r={top:12,right:60,bottom:30,left:38},s=760-r.left-r.right,o=t-r.top-r.bottom,i=Math.max(1,e.labels.length),a=u=>i===1?r.left+s/2:r.left+u/(i-1)*s,d=de(Math.max(0,...e.series.flatMap(u=>u.values))),l=u=>r.top+o-u/d*o,c=[];for(let u of[0,d/2,d])c.push(`<line class="grid" x1="${r.left}" y1="${p(l(u))}" x2="${p(760-r.right)}" y2="${p(l(u))}"/>`,`<text class="tick" x="${r.left-6}" y="${p(l(u)+3.5)}" text-anchor="end">${p(u)}</text>`);for(let u of e.series){let m=u.values.map((b,v)=>`${p(a(v))},${p(l(b))}`).join("L"),k=u.reference===!0;c.push(`<path class="line${k?" reference-line":""}" d="M${m}" ${k?"":`stroke="var(${u.color})"`}><title>${j(u.name)}, ${j(e.unit)}</title></path>`);let f=u.values.length-1,y=u.values[f];!k&&y!==void 0&&c.push(`<circle class="dot" cx="${p(a(f))}" cy="${p(l(y))}" r="4.5" fill="var(${u.color})"/>`,`<text class="tick" x="${p(a(f)+9)}" y="${p(l(y)+3.5)}">${y}</text>`)}return e.labels.forEach((u,m)=>{m!==0&&m!==e.labels.length-1||c.push(`<text class="tick" x="${p(a(m))}" y="${p(t-10)}" text-anchor="${m===0?"start":"end"}">${j(u)}</text>`)}),le(760,t,`${e.series.map(u=>u.name).join(" against ")}, in ${e.unit}.`,c.join(""))}var ce=["--s1","--s2","--s3","--s4","--s5","--s6","--s7","--s8"];function te(e,n){return`<p class="stamp">${e.map($).join(" ")} A file, not a page: nothing here is live, and regenerating it is <code>${$(n)}</code>.</p>`}function E(e,n,t,r=!1){return`<div class="tile${r?" critical":""}"><div class="label">${$(e)}</div><div class="value">${$(n)}</div><div class="sub">${$(t)}</div></div>`}function $e(e){return'<div class="legend">'+e.map(n=>`<span><i style="background:var(${n.color})"></i>${$(n.name)}</span>`).join("")+"</div>"}function U(e,n){return`<figure class="figure">${e}<figcaption>${$(n)}</figcaption></figure>`}function H(e,n){return`<div class="rows"><table><tr>${e.map(r=>`<th${r.num===!0?' class="num"':""}>${$(r.head)}</th>`).join("")}</tr>${n.join("")}</table></div>`}function ue(e){return e.length===0?"":e.map(n=>`<p class="empty">${$(n)}</p>`).join("")}function B(e){return`<footer>${$(e)} Folded from the event journal by kadence. No server, no network.</footer>`}function ne(e){return`${e.toISOString().slice(0,16).replace("T"," ")} UTC`}function fn(e,n=new Date){let t=[];t.push("<h1>Flow</h1>"),t.push(te([`${e.window.from} to ${e.window.to} UTC, ${e.window.days} calendar days.`,`Work counts as started at "${e.started}".`,`Generated ${ne(n)}.`],"kadence report flow --html"));let r=e.cycleTime===null?"\u2014":String(e.cycleTime.p85);t.push('<div class="tiles">',E("In progress now",String(e.wip),"tasks past the started boundary"),E("Finished",String(e.finished),`in ${e.window.days} calendar days`),E("Cycle time p85",r,e.cycleTime===null?"nothing finished yet":`calendar days, n=${e.cycleTime.n}`),E("Blocked",String(e.blocked.days),e.blocked.tasks===0?"no blocked time in the window":`days across ${e.blocked.tasks} task(s)`,e.blocked.tasks>0),"</div>"),e.sle!==null&&t.push(`<p class="callout">${$(e.sle)}</p>`);let o=[{name:"Cycle time",p:e.cycleTime},{name:"Lead time",p:e.leadTime},{name:"Response time",p:e.responseTime}].filter(i=>i.p!==null);if(t.push("<h2>How long work takes</h2>"),o.length===0?t.push('<p class="empty">Nothing has finished in this window, so there is nothing to measure.</p>'):(t.push(U(pn(o.map(i=>({name:i.name,p50:i.p.p50,p85:i.p.p85,p95:i.p.p95,n:i.p.n})),"calendar days"),"p50, p85 and p95 in calendar days. Percentiles, never a mean \u2014 the tail is the part worth managing.")),t.push(H([{head:"Measure"},{head:"p50",num:!0},{head:"p85",num:!0},{head:"p95",num:!0},{head:"n",num:!0}],o.map(i=>`<tr><td>${$(i.name)}</td><td class="num">${i.p.p50}</td><td class="num">${i.p.p85}</td><td class="num">${i.p.p95}</td><td class="num">${i.p.n}</td></tr>`)))),t.push("<h2>Created and finished, per week</h2>"),e.perWeek.length===0)t.push('<p class="empty">No weeks in this window carry either.</p>');else{let i=[{name:"Created",color:"--s2",values:e.perWeek.map(a=>a.created)},{name:"Finished",color:"--s1",values:e.perWeek.map(a=>a.finished)}];t.push($e(i.map(a=>({name:a.name,color:a.color})))),t.push(U(Me({labels:e.perWeek.map(a=>a.week),series:i,unit:"tasks"}),"One band per week, labelled by its Monday. More created than finished, week after week, is a queue growing.")),t.push("<details><summary>Every week as rows</summary>",H([{head:"Week of"},{head:"Created",num:!0},{head:"Finished",num:!0}],e.perWeek.map(a=>`<tr><td>${$(a.week)}</td><td class="num">${a.created}</td><td class="num">${a.finished}</td></tr>`)),"</details>")}if(t.push("<h2>Aging work in progress</h2>"),e.aging.length===0)t.push('<p class="empty">Nothing is in progress.</p>');else{let i=e.aging.slice(0,15);t.push(U(ye({rows:i.map(a=>({name:a.label,value:a.ageDays,critical:a.overP85,note:`${a.status} \xB7 ${a.title}`})),unit:"calendar days",...e.cycleTime===null?{}:{reference:{value:e.cycleTime.p85,label:`p85 = ${e.cycleTime.p85} d`}}}),e.cycleTime===null?"Age in calendar days, oldest first.":"Age in calendar days, oldest first. The line is the p85 cycle time: work to its right has already taken longer than 85% of what finished.")),t.push(H([{head:"Task"},{head:"Age",num:!0},{head:"Status"},{head:"Title"}],i.map(a=>`<tr class="${a.overP85?"critical":""}"><td>${$(a.label)}</td><td class="num">${a.ageDays}</td><td>${$(a.status)}</td><td>${$(a.title)}${a.overP85?' <span class="pill danger">older than p85</span>':""}</td></tr>`))),e.aging.length>i.length&&t.push(`<p class="empty">\u2026 and ${e.aging.length-i.length} more. The --json response carries every row.</p>`)}return t.push(ue(e.notes)),t.push(B(`${e.finished} finished, ${e.wip} in progress.`)),L("kadence flow",P+I,t)}function gn(e,n=new Date){let t=[];if(t.push("<h1>Cumulative flow</h1>"),t.push(te([`${e.window.from} to ${e.window.to} UTC, ${e.window.days} calendar days.`,"Tasks per column at the end of each day.",`Generated ${ne(n)}.`],"kadence report cfd --html")),e.statuses.length===0||e.days.length===0)return t.push('<p class="empty">No columns to draw yet.</p>'),t.push(B("Nothing in the window.")),L("kadence cumulative flow",P+I,t);let r=e.statuses.slice(0,ce.length),s=e.statuses.slice(ce.length),o=r.map((a,d)=>({name:a,color:ce[d],values:e.days.map(l=>l.counts[a]??0)}));s.length>0&&o.push({name:`Other (${s.length} columns)`,color:ce[ce.length-1],values:e.days.map(a=>s.reduce((d,l)=>d+(a.counts[l]??0),0))}),t.push($e(o.map(a=>({name:a.name,color:a.color})))),t.push(U(mn({dates:e.days.map(a=>a.date),bands:o}),"Bands stack in board order, finished work at the baseline. A band that widens is a queue; the height between two lines is the work sitting in that column."));let i=[{head:"Date"},...o.map(a=>({head:a.name,num:!0}))];return t.push("<details><summary>Every day as rows</summary>",H(i,e.days.map(a=>{let d=r.map(c=>`<td class="num">${a.counts[c]??0}</td>`).join(""),l=s.length===0?"":`<td class="num">${s.reduce((c,u)=>c+(a.counts[u]??0),0)}</td>`;return`<tr><td>${$(a.date)}</td>${d}${l}</tr>`})),"</details>"),t.push(B(`${e.days.length} days, ${e.statuses.length} columns.`)),L("kadence cumulative flow",P+I,t)}function kn(e,n=new Date){let t=[];if(t.push("<h1>Attention</h1>"),t.push(te([`As of ${e.asOf} UTC.`,`Work past "${e.started}" that nobody is moving \u2014 silent or ownerless for ${e.threshold} days or more, or blocked by work that is already done.`,`Generated ${ne(n)}.`],"kadence report attention --html")),t.push('<div class="tiles">',E("Needs attention",String(e.rows.length),e.rows.length===0?"nothing is stuck":"of the work in flight",e.rows.length>0),E("Threshold",`${e.threshold} d`,"silence before a task counts as stalled"),"</div>"),e.rows.length===0)t.push('<p class="empty">Nothing is stalled, unowned, claimed and forgotten, or waiting on work that is already done.</p>');else{let r=e.rows.slice(0,20);t.push(U(ye({rows:r.map(s=>({name:s.label,value:s.idleDays,critical:s.idleDays>=e.threshold*2,note:`${s.status} \xB7 ${s.title}`})),unit:"days of silence",reference:{value:e.threshold,label:`${e.threshold} d`}}),`Days since the task last moved. The line is the ${e.threshold}-day threshold; everything here is already past it, and a bar turns critical past twice it.`)),t.push(H([{head:"Task"},{head:"Idle",num:!0},{head:"Status"},{head:"Why it is here"}],r.map(s=>`<tr class="${s.idleDays>=e.threshold*2?"critical":""}"><td>${$(s.label)}</td><td class="num">${s.idleDays}</td><td>${$(s.status)}</td><td>${$(s.title)}<div class="sub">${$(s.signals.map(ee).join(" \xB7 "))}</div></td></tr>`))),e.rows.length>r.length&&t.push(`<p class="empty">\u2026 and ${e.rows.length-r.length} more. The --json response carries every row.</p>`)}return t.push(ue(e.notes)),t.push(B(`${e.rows.length} needing attention.`)),L("kadence attention",P+I,t)}function bn(e,n=new Date){let t=[];if(t.push("<h1>Burndown</h1>"),t.push(te([`${$(e.sprintName)}: ${e.committed} points committed.`,e.finalRemaining===null?"The sprint is still open, so the last day is today rather than the end.":`Closed with ${e.finalRemaining} point(s) unfinished.`,`Generated ${ne(n)}.`],"kadence report burndown --html")),e.committed===0||e.days.length===0)return t.push('<p class="empty">Nothing to burn down: no task in this sprint carries an estimate.</p>'),t.push(B(`${e.sprintName}, ${e.days.length} days.`)),L("kadence burndown",P+I,t);let r=e.days[e.days.length-1],s=r.remaining<=r.ideal;return t.push('<div class="tiles">',E("Committed",String(e.committed),"points taken into the sprint"),E("Remaining",String(r.remaining),`of ${e.committed}, on ${r.date}`,!s),E("Against the ideal",`${s?"\u2212":"+"}${Math.abs(Math.round(r.remaining-r.ideal))}`,s?"points ahead of an even burn":"points behind an even burn",!s),"</div>"),t.push($e([{name:"Remaining",color:"--s1"},{name:"An even burn",color:"--muted"}])),t.push(U(hn({labels:e.days.map(o=>o.date),series:[{name:"An even burn",color:"--muted",values:e.days.map(o=>Math.round(o.ideal*10)/10),reference:!0},{name:"Remaining",color:"--s1",values:e.days.map(o=>o.remaining)}],unit:"points"}),"Points still open at the end of each day. The muted line is where a perfectly even burn would have been \u2014 an expectation, not a measurement.")),t.push("<details><summary>Every day as rows</summary>",H([{head:"Date"},{head:"Remaining",num:!0},{head:"Even burn",num:!0},{head:"Finished that day",num:!0}],e.days.map(o=>`<tr><td>${$(o.date)}</td><td class="num">${o.remaining}</td><td class="num">${Math.round(o.ideal*10)/10}</td><td class="num">${o.completed}</td></tr>`)),"</details>"),t.push(B(`${e.sprintName}, ${e.days.length} days, ${e.committed} points.`)),L("kadence burndown",P+I,t)}function yn(e,n=new Date){let t=[];if(t.push("<h1>Velocity</h1>"),t.push(te(["Points taken into a sprint against points finished, oldest first.",`Generated ${ne(n)}.`],"kadence report velocity --html")),e.rows.length===0)return t.push('<p class="empty">No closed sprint yet. Velocity is what a finished sprint leaves behind.</p>'),t.push(ue(e.notes)),t.push(B("No sprints closed.")),L("kadence velocity",P+I,t);t.push('<div class="tiles">',E("Finished",`${e.low}\u2013${e.high}`,`points per sprint, median ${e.median}`),E("Sprints",String(e.rows.length),"closed and counted"),"</div>");let r=[{name:"Committed",color:"--s2",values:e.rows.map(s=>s.committed)},{name:"Finished",color:"--s1",values:e.rows.map(s=>s.velocity)}];return t.push($e(r.map(s=>({name:s.name,color:s.color})))),t.push(U(Me({labels:e.rows.map(s=>s.name),series:r,unit:"points"}),"A committed column taller than its finished one, sprint after sprint, is a team taking in more than it can deliver \u2014 not a team that is slow.")),t.push(H([{head:"Sprint"},{head:"Committed",num:!0},{head:"Finished",num:!0},{head:"Carried over",num:!0}],e.rows.map(s=>`<tr><td>${$(s.name)}</td><td class="num">${s.committed}</td><td class="num">${s.velocity}</td><td class="num">${s.carriedOver}</td></tr>`))),t.push(ue(e.notes)),t.push(B(`${e.rows.length} closed sprint(s).`)),L("kadence velocity",P+I,t)}function $n(e,n=new Date){let t=[];if(t.push("<h1>Workload</h1>"),t.push(te([`Open work by owner, as of ${e.asOf} UTC.`,`Work counts as in progress at "${e.started}".`,`Generated ${ne(n)}.`],"kadence report workload --html")),e.rows.length===0)return t.push('<p class="empty">Nothing open.</p>'),t.push(B("Nothing open.")),L("kadence workload",P+I,t);let r=i=>i===null?"unassigned":i.split("@")[0]??i,s=e.rows.reduce((i,a)=>i+a.openPoints,0),o=e.rows.find(i=>i.assignee===null);return t.push('<div class="tiles">',E("Open points",String(s),`across ${e.rows.length} owner(s)`),E("Unassigned",String(o?.openPoints??0),o===void 0?"everything has an owner":`points over ${o.open} task(s)`,o!==void 0&&o.openPoints>s/2),"</div>"),t.push(U(ye({rows:e.rows.map(i=>({name:r(i.assignee),value:i.openPoints,critical:i.assignee===null,note:`${i.open} open, ${i.inProgress} in progress${i.blocked>0?`, ${i.blocked} blocked`:""}`})),unit:"open points"}),"Open points per owner. The unassigned row is drawn in the critical colour and named in the table: work nobody owns is what this report exists to surface.")),t.push(H([{head:"Owner"},{head:"Open",num:!0},{head:"Points",num:!0},{head:"In progress",num:!0},{head:"Blocked",num:!0}],e.rows.map(i=>`<tr class="${i.assignee===null?"critical":""}"><td>${$(i.assignee??"(unassigned)")}</td><td class="num">${i.open}</td><td class="num">${i.openPoints}</td><td class="num">${i.inProgress}</td><td class="num">${i.blocked}</td></tr>`))),t.push(ue(e.notes)),t.push(B(`${s} open points.`)),L("kadence workload",P+I,t)}import{mkdirSync as Ws,writeFileSync as Bs}from"node:fs";import{dirname as Fs}from"node:path";function we(e,n,t,r,s){let o=$t(e,n??t,s);if("exitCode"in o)return o;Ws(Fs(o.full),{recursive:!0});try{Bs(o.full,r,"utf8")}catch(i){return w(1,"conflicting_state",`Could not write ${o.full}: ${i.code??"unknown error"}.`,{received:o.rel,hint:s})}return{path:o.full,bytes:Buffer.byteLength(r)}}var ve=["flow","cfd","attention","burndown","velocity","workload"],Ie=[{name:"flow",answers:"How long work takes, how much is in flight, and what is aging."},{name:"cfd",answers:"Where work piles up: tasks per column at the end of each day."},{name:"attention",answers:"Work in flight that nobody is moving, and why."},{name:"burndown",answers:"Whether a sprint is on track against an even burn."},{name:"velocity",answers:"Committed against completed, sprint by sprint, as a range."},{name:"workload",answers:"Who is carrying what right now, unassigned work included."}],wn={team:["attention","flow","cfd"],sprint:["burndown","velocity","workload"]};function vn(e){let n=Ie.find(t=>t.name===e);return` ${n.name.padEnd(10)} ${n.answers}`}var _e=["flow","cfd","attention"],Sn=30,Ks=7,xn=730;function Us(e,n=Sn){if(e===void 0)return n;let t=/^(\d+)\s*d?$/i.exec(e.trim()),r=t===null?NaN:Number(t[1]);return!Number.isInteger(r)||r<1||r>xn?w(2,"invalid_argument",`--since takes a number of days from 1 to ${xn}, like 30d, got "${e}".`,{received:e,hint:"kadence report flow --since 30d"}):r}function Pe(e,n){return e===null?"no data":`p50 ${e.p50} \xB7 p85 ${e.p85} \xB7 p95 ${e.p95} ${n} (n=${e.n})`}function Hs(e){let n=[];if(n.push(`Flow, ${e.window.from} to ${e.window.to} UTC (${e.window.days} calendar days). Work starts at "${e.started}".`),n.push(""),n.push(` In progress now: ${e.wip}`),n.push(` Finished: ${e.finished}`),n.push(` Cycle time: ${Pe(e.cycleTime,"days")}`),n.push(` Lead time: ${Pe(e.leadTime,"days")}`),n.push(` Response time: ${Pe(e.responseTime,"days")}`),e.blocked.tasks>0&&n.push(` Blocked: ${e.blocked.tasks} task(s), ${e.blocked.days} days in total`),e.sle!==null&&n.push("",` ${e.sle}`),e.perWeek.some(t=>t.finished>0||t.created>0)){n.push(""," Week Created Finished");for(let t of e.perWeek)n.push(` ${t.week} ${String(t.created).padStart(7)} ${String(t.finished).padStart(8)}`)}if(e.aging.length>0){n.push(""," Aging work in progress (oldest first):");for(let t of e.aging.slice(0,10)){let r=t.overP85?" \u2190 older than p85":"";n.push(` ${t.label} ${String(t.ageDays).padStart(5)} d ${t.status} ${t.title}${r}`)}e.aging.length>10&&n.push(` \u2026 and ${e.aging.length-10} more`)}if(e.notes.length>0){n.push("");for(let t of e.notes)n.push(` ${t}`)}return n.join(`
113
+ `)}function zs(e){let n=[];n.push(`Cumulative flow, ${e.window.from} to ${e.window.to} UTC. Tasks per column at the end of each day.`),n.push("");let t=e.statuses,r=Math.max(6,...t.map(o=>o.length));n.push(` ${"date".padEnd(10)} ${t.map(o=>o.padStart(r)).join(" ")}`);let s=e.days.filter((o,i)=>i%7===0||i===e.days.length-1);for(let o of s)n.push(` ${o.date} ${t.map(i=>String(o.counts[i]??0).padStart(r)).join(" ")}`);return s.length<e.days.length&&n.push("",` ${e.days.length} days in the window; one row per week shown. --json carries every day.`),n.join(`
114
+ `)}function Ys(e){let n=[];if(n.push(`Attention, as of ${e.asOf} UTC. Work past "${e.started}" that nobody is moving \u2014 silent or ownerless for ${e.threshold} days or more, or blocked by work that is already done.`),e.rows.length>0){n.push("");for(let t of e.rows.slice(0,15))n.push(` ${t.label} ${String(t.idleDays).padStart(4)} d ${t.title}`),n.push(` ${t.signals.map(ee).join(" \xB7 ")}`);e.rows.length>15&&n.push(` \u2026 and ${e.rows.length-15} more`)}if(e.notes.length>0){n.push("");for(let t of e.notes)n.push(` ${t}`)}return n.join(`
115
+ `)}function qs(e){let n=[];if(n.push("Velocity, oldest first. Points taken into a sprint against points finished."),e.rows.length===0){n.push(""," No closed sprint yet.");for(let r of e.notes)n.push(` ${r}`);return n.join(`
116
+ `)}n.push("");let t=Math.max(8,...e.rows.map(r=>r.name.length));n.push(` ${"Sprint".padEnd(t)} Committed Finished Carried`);for(let r of e.rows)n.push(` ${r.name.padEnd(t)} ${String(r.committed).padStart(9)} ${String(r.velocity).padStart(8)} ${String(r.carriedOver).padStart(7)}`);n.push("",` Finished: ${e.low} to ${e.high} points, median ${e.median}, over ${e.rows.length} sprint(s).`);for(let r of e.notes)n.push(` ${r}`);return n.join(`
117
+ `)}function Js(e){let n=[];if(n.push(`Open work by owner, as of ${e.asOf} UTC. Work counts as in progress at "${e.started}".`),e.rows.length===0)return n.push(""," Nothing open."),n.join(`
118
+ `);n.push("");let t=s=>s??"(unassigned)",r=Math.max(10,...e.rows.map(s=>t(s.assignee).length));n.push(` ${"Owner".padEnd(r)} Open Points Doing Blocked`);for(let s of e.rows)n.push(` ${t(s.assignee).padEnd(r)} ${String(s.open).padStart(4)} ${String(s.openPoints).padStart(6)} ${String(s.inProgress).padStart(5)} ${String(s.blocked).padStart(7)}`);e.notes.length>0&&n.push("");for(let s of e.notes)n.push(` ${s}`);return n.join(`
119
+ `)}function Cn(e,n,t,r,s=new Date){if(r.list===!0)return{ok:!0,exitCode:0,warnings:[],message:["Reports, each a fold over the journal:","",...wn.team.map(vn),"","Sprint and team:",...wn.sprint.map(vn),"","Each takes --json, and --html to write it as a page with charts."," kadence report flow --html"].join(`
120
+ `),data:{schema:"kadence/v1",ok:!0,reports:Ie}};if(t===void 0||!ve.includes(t))return w(2,"invalid_argument",["Which report?",...Ie.map(c=>` kadence report ${c.name.padEnd(10)} ${c.answers}`)].join(`
121
+ `),{...t===void 0?{}:{received:t},allowed:ve,hint:"kadence report flow"});if(r.since!==void 0&&!_e.includes(t))return w(2,"invalid_argument",`--since is a window, and ${t} does not have one.
122
+ It applies to ${_e.join(", ")}.`,{received:r.since,allowed:_e,hint:`kadence report ${t}`});if(r.sprint!==void 0&&t!=="burndown")return w(2,"invalid_argument",`--sprint applies to burndown, not to ${t}.`,{received:r.sprint,hint:'kadence report burndown --sprint "Sprint 3"'});let o=Us(r.since,t==="attention"?Ks:Sn);if(typeof o!="number")return o;let i=S(e,n);if(!C(i))return i;let{state:a,warnings:d}=A(i.root,i.actor),l;if(t==="attention"){let c=be(a,s,o);l={data:c,message:Ys(c),html:()=>kn(c,s)}}else if(t==="cfd"){let c=dt(a,s,o);l={data:c,message:zs(c),html:()=>gn(c,s)}}else if(t==="burndown"){let c=Bt(i.root,a,r.sprint);if("exitCode"in c)return c;let{sprint:u,chart:m}=c;if(m===null)return{ok:!0,exitCode:0,warnings:d,message:`"${u.name}" has no tasks yet.
123
+ kadence sprint add KAD-1`,data:{schema:"kadence/v1",ok:!0,report:t,burndown:null}};l={data:{burndown:m},message:Nt(m),html:()=>bn(m,s)}}else if(t==="velocity"){let c=Rt(a);l={data:c,message:qs(c),html:()=>yn(c,s)}}else if(t==="workload"){let c=un(a,s);l={data:c,message:Js(c),html:()=>$n(c,s)}}else{let c=at(a,s,o);l={data:c,message:Hs(c),html:()=>fn(c,s)}}if(r.html===!0){let c=we(i.root,r.file,`kadence-${t}.html`,l.html(),`kadence report ${t} --html --file docs/${t}.html`);return"exitCode"in c?c:{ok:!0,exitCode:0,warnings:d,message:`Wrote ${c.path}.
124
+ Open it from disk \u2014 there is no server, and the page makes no requests.`,data:{schema:"kadence/v1",ok:!0,report:t,format:"html",path:c.path,bytes:c.bytes}}}return{ok:!0,exitCode:0,warnings:d,message:l.message,data:{schema:"kadence/v1",ok:!0,report:t,...l.data}}}import{existsSync as Vs,mkdirSync as Gs,readFileSync as Zs,writeFileSync as Qs}from"node:fs";import{homedir as Xs}from"node:os";import{dirname as An,join as Le}from"node:path";var xe="# kadence completion",se=["zsh","bash","fish"];function er(e){return se.includes(e)}var We=[["init","Set up kadence in this repository"],["prime","Everything a session needs before it starts"],["ready","What can be started right now"],["task","Tasks: add, list, show, move, claim, ac"],["board","Kanban board in the terminal"],["sprint","Sprints: create, start, close, status"],["milestone","Milestones: create, add, list, close"],["decision","Decisions: add, list, show"],["note","Record something learned"],["stats","Where the project stands"],["template","Task templates: save, list, delete"],["schema","The machine-readable --json contract"],["completion","Shell completion"],["ui","The interactive board"]],Be=["add","list","show","edit","move","assign","comment","log","parent","block","unblock","claim","release","ac","doc","cancel","delete"];function tr(e){let n=We.map(([t])=>t).join(" ");return e==="fish"?`${[`${xe} for fish`,"complete -c kadence -f",...We.map(([r,s])=>`complete -c kadence -n "not __fish_seen_subcommand_from ${n}" -a ${r} -d '${s.replace(/'/g,"")}'`),`complete -c kadence -n "__fish_seen_subcommand_from task" -a "${Be.join(" ")}"`,"complete -c kadence -l json -d 'Machine-readable output for agents'"].join(`
40
125
  `)}
41
- `:e==="bash"?`${V} for bash
126
+ `:e==="bash"?`${xe} for bash
42
127
  _kadence() {
43
128
  local cur prev
44
129
  cur="\${COMP_WORDS[COMP_CWORD]}"
45
130
  prev="\${COMP_WORDS[COMP_CWORD-1]}"
46
131
 
47
132
  if [ "$COMP_CWORD" -eq 1 ]; then
48
- COMPREPLY=( $(compgen -W "${t}" -- "$cur") )
133
+ COMPREPLY=( $(compgen -W "${n}" -- "$cur") )
49
134
  return
50
135
  fi
51
136
  case "$prev" in
52
- task) COMPREPLY=( $(compgen -W "${me.join(" ")}" -- "$cur") ) ;;
137
+ task) COMPREPLY=( $(compgen -W "${Be.join(" ")}" -- "$cur") ) ;;
53
138
  sprint) COMPREPLY=( $(compgen -W "create add edit start close status list burndown" -- "$cur") ) ;;
54
139
  milestone) COMPREPLY=( $(compgen -W "create add list close" -- "$cur") ) ;;
55
140
  decision) COMPREPLY=( $(compgen -W "add list show" -- "$cur") ) ;;
@@ -59,12 +144,12 @@ _kadence() {
59
144
  }
60
145
  complete -F _kadence kadence
61
146
  `:`#compdef kadence
62
- ${V} for zsh
147
+ ${xe} for zsh
63
148
 
64
149
  _kadence() {
65
150
  local -a commands
66
151
  commands=(
67
- ${ue.map(([n,o])=>` '${n}:${o.replace(/'/g,"")}'`).join(`
152
+ ${We.map(([t,r])=>` '${t}:${r.replace(/'/g,"")}'`).join(`
68
153
  `)}
69
154
  )
70
155
 
@@ -74,7 +159,7 @@ ${ue.map(([n,o])=>` '${n}:${o.replace(/'/g,"")}'`).join(`
74
159
  fi
75
160
 
76
161
  case "\${words[2]}" in
77
- task) _values 'action' ${me.join(" ")} ;;
162
+ task) _values 'action' ${Be.join(" ")} ;;
78
163
  sprint) _values 'action' create add edit start close status list burndown ;;
79
164
  milestone) _values 'action' create add list close ;;
80
165
  decision) _values 'action' add list show ;;
@@ -84,42 +169,42 @@ ${ue.map(([n,o])=>` '${n}:${o.replace(/'/g,"")}'`).join(`
84
169
  }
85
170
 
86
171
  _kadence "$@"
87
- `}function ss(e,t){return e==="fish"?le(t,".config","fish","completions","kadence.fish"):e==="bash"?le(t,".local","share","bash-completion","completions","kadence"):le(t,".zsh","completions","_kadence")}function os(e){let t=e.SHELL??"";for(let n of L)if(t.endsWith(`/${n}`)||t===n)return n;return null}function Pt(e,t){let n;if(t.shell!==void 0){if(!ts(t.shell))return y(2,"invalid_argument",`kadence has no completion for "${t.shell}".`,{received:t.shell,allowed:L,hint:"kadence completion install --shell zsh"});n=t.shell}else{let i=os(e);if(i===null)return y(2,"invalid_argument",`Could not tell which shell you use from $SHELL.
172
+ `}function nr(e,n){return e==="fish"?Le(n,".config","fish","completions","kadence.fish"):e==="bash"?Le(n,".local","share","bash-completion","completions","kadence"):Le(n,".zsh","completions","_kadence")}function sr(e){let n=e.SHELL??"";for(let t of se)if(n.endsWith(`/${t}`)||n===t)return t;return null}function jn(e,n){let t;if(n.shell!==void 0){if(!er(n.shell))return w(2,"invalid_argument",`kadence has no completion for "${n.shell}".`,{received:n.shell,allowed:se,hint:"kadence completion install --shell zsh"});t=n.shell}else{let i=sr(e);if(i===null)return w(2,"invalid_argument",`Could not tell which shell you use from $SHELL.
88
173
  Name it:
89
- kadence completion install --shell zsh`,{allowed:L,hint:"kadence completion install --shell zsh"});n=i}let o=ns(n);if(t.install!==!0||t.isTty===!1)return{ok:!0,exitCode:0,message:o,data:{schema:"kadence/v1",ok:!0,shell:n,script:o}};let s=ss(n,t.home??es());if(Gn(s)){let i=Qn(s,"utf8");if(i===o)return{ok:!0,exitCode:0,message:`Completion for ${n} is already installed at ${s}.`,data:{schema:"kadence/v1",ok:!0,shell:n,path:s,written:!1}};if(!i.includes(V)&&t.force!==!0)return y(1,"conflicting_state",`${s} exists and was not written by kadence.
174
+ kadence completion install --shell zsh`,{allowed:se,hint:"kadence completion install --shell zsh"});t=i}let r=tr(t);if(n.install!==!0||n.isTty===!1)return{ok:!0,exitCode:0,message:r,data:{schema:"kadence/v1",ok:!0,shell:t,script:r}};let s=nr(t,n.home??Xs());if(Vs(s)){let i=Zs(s,"utf8");if(i===r)return{ok:!0,exitCode:0,message:`Completion for ${t} is already installed at ${s}.`,data:{schema:"kadence/v1",ok:!0,shell:t,path:s,written:!1}};if(!i.includes(xe)&&n.force!==!0)return w(1,"conflicting_state",`${s} exists and was not written by kadence.
90
175
  Nothing was changed. Look at it, then either move it or run:
91
- kadence completion install --shell ${n} --force`,{received:s,hint:`kadence completion install --shell ${n} --force`})}Zn(_t(s),{recursive:!0}),Xn(s,o,"utf8");let r=n==="zsh"?`
176
+ kadence completion install --shell ${t} --force`,{received:s,hint:`kadence completion install --shell ${t} --force`})}Gs(An(s),{recursive:!0}),Qs(s,r,"utf8");let o=t==="zsh"?`
92
177
  zsh loads completions from fpath, which is yours to set. Add to ~/.zshrc:
93
- fpath=(${_t(s)} $fpath)
178
+ fpath=(${An(s)} $fpath)
94
179
  autoload -Uz compinit && compinit`:`
95
- Open a new shell, or reload it, and it will be picked up.`;return{ok:!0,exitCode:0,message:`Wrote ${n} completion to ${s}.${r}`,data:{schema:"kadence/v1",ok:!0,shell:n,path:s,written:!0}}}var Lt=`A note records something learned. When there was a choice and something was
180
+ Open a new shell, or reload it, and it will be picked up.`;return{ok:!0,exitCode:0,message:`Wrote ${t} completion to ${s}.${o}`,data:{schema:"kadence/v1",ok:!0,shell:t,path:s,written:!0}}}var Dn=`A note records something learned. When there was a choice and something was
96
181
  turned down, record it as a decision instead:
97
- kadence decision add "title" --why "reason"`;function rs(e,t){return{id:e.id,text:e.text,task:t(e.task),at:e.at,by:e.by,source:e.source}}function It(e,t,n,o){let s=w(e,t);if(!v(s))return s;let r=n.trim();if(r.length===0)return y(2,"invalid_argument",`A note needs text.
182
+ kadence decision add "title" --why "reason"`;function rr(e,n){return{id:e.id,text:e.text,task:n(e.task),at:e.at,by:e.by,source:e.source}}function Tn(e,n,t,r){let s=S(e,n);if(!C(s))return s;let o=t.trim();if(o.length===0)return w(2,"invalid_argument",`A note needs text.
98
183
 
99
- ${Lt}`,{hint:'kadence note "Tests need a git identity"'});let{state:i,warnings:d}=x(s.root,s.actor),a=null,c=null;if(o.task!==void 0&&o.task.trim().length>0){let f=N(i,o.task);if(f===void 0)return R(o.task);a=f.id,c=f.label}let l=S();j(s.root,{id:l,type:"note.recorded",entity:l,actor:s.actor,ts:new Date().toISOString(),source:s.source,data:a===null?{text:r}:{text:r,task:a}});let m=c===null?"":` on ${c}`;return{ok:!0,exitCode:0,warnings:d,message:`Note recorded${m}.`,data:{schema:"kadence/v1",ok:!0,note:{id:l,text:r,task:c}}}}function Bt(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i=s.notes;if(n.task!==void 0&&n.task.trim().length>0){let l=N(s,n.task);if(l===void 0)return R(n.task);i=i.filter(m=>m.task===l.id)}let d=[...i].reverse(),a=n.limit!==void 0&&n.limit>0?d.slice(0,n.limit):d;if(a.length===0)return{ok:!0,exitCode:0,warnings:r,message:`No notes yet.
184
+ ${Dn}`,{hint:'kadence note "Tests need a git identity"'});let{state:i,warnings:a}=A(s.root,s.actor),d=null,l=null;if(r.task!==void 0&&r.task.trim().length>0){let m=K(i,r.task);if(m===void 0)return F(r.task);d=m.id,l=m.label}let c=T();R(s.root,{id:c,type:"note.recorded",entity:c,actor:s.actor,ts:new Date().toISOString(),source:s.source,data:d===null?{text:o}:{text:o,task:d}});let u=l===null?"":` on ${l}`;return{ok:!0,exitCode:0,warnings:a,message:`Note recorded${u}.`,data:{schema:"kadence/v1",ok:!0,note:{id:c,text:o,task:l}}}}function Rn(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i=s.notes;if(t.task!==void 0&&t.task.trim().length>0){let c=K(s,t.task);if(c===void 0)return F(t.task);i=i.filter(u=>u.task===c.id)}let a=[...i].reverse(),d=t.limit!==void 0&&t.limit>0?a.slice(0,t.limit):a;if(d.length===0)return{ok:!0,exitCode:0,warnings:o,message:`No notes yet.
100
185
  Record the first one:
101
186
  kadence note "text"
102
187
 
103
- ${Lt}`,data:{schema:"kadence/v1",ok:!0,notes:[]}};let c=is(s);return{ok:!0,exitCode:0,warnings:r,message:a.map(l=>as(l,c)).join(`
104
- `),data:{schema:"kadence/v1",ok:!0,notes:a.map(l=>rs(l,c))}}}function is(e){return t=>t===null?null:e.tasks.find(n=>n.id===t)?.label??null}function as(e,t){let n=t(e.task),o=n===null?"":` ${n}`,s=e.source==="agent"?` ${e.by} [agent]`:` ${e.by}`;return`${e.at.slice(0,10)}${o}${s}
105
- ${e.text}`}var ds=/^\d{4}-\d{2}-\d{2}$/;function fe(e,t){let n=String(t).trim(),o=n.toUpperCase();return e.milestones.find(s=>s.id===o||s.label===o||s.name.toLowerCase()===n.toLowerCase())}function Kt(e,t){let n=e.milestones.map(o=>`${o.label} ${o.name}`);return y(1,"milestone_not_found",n.length===0?`No milestone "${t}".
188
+ ${Dn}`,data:{schema:"kadence/v1",ok:!0,notes:[]}};let l=or(s);return{ok:!0,exitCode:0,warnings:o,message:d.map(c=>ir(c,l)).join(`
189
+ `),data:{schema:"kadence/v1",ok:!0,notes:d.map(c=>rr(c,l))}}}function or(e){return n=>n===null?null:e.tasks.find(t=>t.id===n)?.label??null}function ir(e,n){let t=n(e.task),r=t===null?"":` ${t}`,s=e.source==="agent"?` ${e.by} [agent]`:` ${e.by}`;return`${e.at.slice(0,10)}${r}${s}
190
+ ${e.text}`}var ar=/^\d{4}-\d{2}-\d{2}$/;function Fe(e,n){let t=String(n).trim(),r=t.toUpperCase();return e.milestones.find(s=>s.id===r||s.label===r||s.name.toLowerCase()===t.toLowerCase())}function En(e,n){let t=e.milestones.map(r=>`${r.label} ${r.name}`);return w(1,"milestone_not_found",t.length===0?`No milestone "${n}".
106
191
  Create one:
107
- kadence milestone create "1.0"`:`No milestone "${t}".
108
- Available: ${n.join(", ")}`,{received:t,hint:"kadence milestone list --json"})}function pe(e,t,n,o){j(e.root,{id:S(),type:t,entity:n,actor:e.actor,ts:new Date().toISOString(),source:e.source,data:o})}function Wt(e,t,n,o){let s=w(e,t);if(!v(s))return s;let r=n.trim();if(r.length===0)return y(2,"invalid_argument","A milestone needs a name.",{hint:'kadence milestone create "1.0"'});if(o.due!==void 0&&!ds.test(o.due))return y(2,"invalid_argument",`"${o.due}" is not a date. Use YYYY-MM-DD.`,{received:o.due,hint:'kadence milestone create "1.0" --due 2026-12-01'});let{state:i,warnings:d}=x(s.root,s.actor),a=fe(i,r),c=a===void 0?[]:[`A milestone named ${a.name} already exists as ${a.label}. Both stay in the journal \u2014 reference them by label to be unambiguous.`],l=S();pe(s,"milestone.created",l,{name:r,...o.due===void 0?{}:{due:o.due}});let m=`MS-${i.milestones.filter(f=>f.id<l).length+1}`;return{ok:!0,exitCode:0,warnings:[...d,...c],message:`${m} ${r}${o.due===void 0?"":` \u2014 due ${o.due}`}`,data:{schema:"kadence/v1",ok:!0,milestone:{id:l,label:m,name:r,due:o.due??null}}}}function Ft(e,t,n,o){let s=w(e,t);if(!v(s))return s;let{state:r,warnings:i}=x(s.root,s.actor),d=N(r,n);if(d===void 0)return R(n);let a=fe(r,o);if(a===void 0)return Kt(r,o);if(d.milestone===a.id)return{ok:!0,exitCode:0,warnings:i,message:`${d.label} is already in ${a.label} ${a.name}.`,data:{schema:"kadence/v1",ok:!0,task:{id:d.id,label:d.label}}};let c=d.milestone===null?null:r.milestones.find(l=>l.id===d.milestone);return pe(s,"milestone.task_added",a.id,{task:d.id}),{ok:!0,exitCode:0,warnings:i,message:c==null?`${d.label} \u2192 ${a.label} ${a.name}`:`${d.label}: ${c.label} ${c.name} \u2192 ${a.label} ${a.name}`,data:{schema:"kadence/v1",ok:!0,task:{id:d.id,label:d.label},milestone:{id:a.id,label:a.label,name:a.name},...c==null?{}:{previous:c.label}}}}function Ut(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i=fe(s,n);if(i===void 0)return Kt(s,n);if(i.status==="closed")return{ok:!0,exitCode:0,warnings:r,message:`${i.label} ${i.name} is already closed.`,data:{schema:"kadence/v1",ok:!0,milestone:{id:i.id,label:i.label}}};pe(o,"milestone.closed",i.id,{});let d=i.totalTasks-i.doneTasks;return{ok:!0,exitCode:0,warnings:r,message:`${i.label} ${i.name} closed at ${i.donePoints}/${i.totalPoints} points.`+(d>0?`
109
- ${d} task(s) are still open; closing does not move them.`:""),data:{schema:"kadence/v1",ok:!0,milestone:{id:i.id,label:i.label,name:i.name,donePoints:i.donePoints,totalPoints:i.totalPoints}}}}function Yt(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i=n.all===!0?s.milestones:s.milestones.filter(d=>d.status==="open");return i.length===0?{ok:!0,exitCode:0,warnings:r,message:s.milestones.length===0?`No milestones yet.
192
+ kadence milestone create "1.0"`:`No milestone "${n}".
193
+ Available: ${t.join(", ")}`,{received:n,hint:"kadence milestone list --json"})}function Ke(e,n,t,r){R(e.root,{id:T(),type:n,entity:t,actor:e.actor,ts:new Date().toISOString(),source:e.source,data:r})}function Nn(e,n,t,r){let s=S(e,n);if(!C(s))return s;let o=t.trim();if(o.length===0)return w(2,"invalid_argument","A milestone needs a name.",{hint:'kadence milestone create "1.0"'});if(r.due!==void 0&&!ar.test(r.due))return w(2,"invalid_argument",`"${r.due}" is not a date. Use YYYY-MM-DD.`,{received:r.due,hint:'kadence milestone create "1.0" --due 2026-12-01'});let{state:i,warnings:a}=A(s.root,s.actor),d=Fe(i,o),l=d===void 0?[]:[`A milestone named ${d.name} already exists as ${d.label}. Both stay in the journal \u2014 reference them by label to be unambiguous.`],c=T();Ke(s,"milestone.created",c,{name:o,...r.due===void 0?{}:{due:r.due}});let u=`MS-${i.milestones.filter(m=>m.id<c).length+1}`;return{ok:!0,exitCode:0,warnings:[...a,...l],message:`${u} ${o}${r.due===void 0?"":` \u2014 due ${r.due}`}`,data:{schema:"kadence/v1",ok:!0,milestone:{id:c,label:u,name:o,due:r.due??null}}}}function On(e,n,t,r){let s=S(e,n);if(!C(s))return s;let{state:o,warnings:i}=A(s.root,s.actor),a=K(o,t);if(a===void 0)return F(t);let d=Fe(o,r);if(d===void 0)return En(o,r);if(a.milestone===d.id)return{ok:!0,exitCode:0,warnings:i,message:`${a.label} is already in ${d.label} ${d.name}.`,data:{schema:"kadence/v1",ok:!0,task:{id:a.id,label:a.label}}};let l=a.milestone===null?null:o.milestones.find(c=>c.id===a.milestone);return Ke(s,"milestone.task_added",d.id,{task:a.id}),{ok:!0,exitCode:0,warnings:i,message:l==null?`${a.label} \u2192 ${d.label} ${d.name}`:`${a.label}: ${l.label} ${l.name} \u2192 ${d.label} ${d.name}`,data:{schema:"kadence/v1",ok:!0,task:{id:a.id,label:a.label},milestone:{id:d.id,label:d.label,name:d.name},...l==null?{}:{previous:l.label}}}}function Mn(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i=Fe(s,t);if(i===void 0)return En(s,t);if(i.status==="closed")return{ok:!0,exitCode:0,warnings:o,message:`${i.label} ${i.name} is already closed.`,data:{schema:"kadence/v1",ok:!0,milestone:{id:i.id,label:i.label}}};Ke(r,"milestone.closed",i.id,{});let a=i.totalTasks-i.doneTasks;return{ok:!0,exitCode:0,warnings:o,message:`${i.label} ${i.name} closed at ${i.donePoints}/${i.totalPoints} points.`+(a>0?`
194
+ ${a} task(s) are still open; closing does not move them.`:""),data:{schema:"kadence/v1",ok:!0,milestone:{id:i.id,label:i.label,name:i.name,donePoints:i.donePoints,totalPoints:i.totalPoints}}}}function _n(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i=t.all===!0?s.milestones:s.milestones.filter(a=>a.status==="open");return i.length===0?{ok:!0,exitCode:0,warnings:o,message:s.milestones.length===0?`No milestones yet.
110
195
  Create one:
111
196
  kadence milestone create "1.0"`:`Every milestone is closed.
112
197
  See them all:
113
- kadence milestone list --all`,data:{schema:"kadence/v1",ok:!0,milestones:[]}}:{ok:!0,exitCode:0,warnings:r,message:i.map(ls).join(`
114
- `),data:{schema:"kadence/v1",ok:!0,milestones:i.map(cs)}}}function cs(e){return{id:e.id,label:e.label,name:e.name,due:e.due,status:e.status,doneTasks:e.doneTasks,totalTasks:e.totalTasks,donePoints:e.donePoints,totalPoints:e.totalPoints}}function ls(e){let t=e.totalPoints===0?0:Math.round(e.donePoints/e.totalPoints*100),n=Math.round(t/10),o=`${"#".repeat(n)}${".".repeat(10-n)}`,s=e.due===null?"":` due ${e.due}`,r=e.status==="closed"?" [closed]":"";return`${e.label} ${e.name}${s}${r}
115
- ${o} ${t}% ${e.donePoints}/${e.totalPoints} points, ${e.doneTasks}/${e.totalTasks} tasks`}import{existsSync as us}from"node:fs";import{isAbsolute as ms,join as fs,relative as ps}from"node:path";function zt(e,t){let n=t.toUpperCase();return e.decisions.find(o=>o.id===n||o.label===n)}function Jt(e){return y(1,"decision_not_found",`No decision ${e}.
116
- kadence decision list`,{received:e,hint:"kadence decision list --json"})}function qt(e,t,n,o){let s=w(e,t);if(!v(s))return s;let r=n.trim();if(r.length===0)return y(2,"invalid_argument","A decision needs a title.",{hint:'kadence decision add "Use ULIDs" --why "Clocks disagree between machines"'});let i=o.why?.trim()??"";if(i.length===0)return y(2,"invalid_argument",`A decision needs a reason.
117
- --why "..."`,{received:r,hint:'kadence decision add "Use ULIDs" --why "Clocks disagree between machines"'});let{state:d,warnings:a}=x(s.root,s.actor),c;if(o.task!==void 0){let g=N(d,o.task);if(g===void 0)return R(o.task);c=g.id}let l;if(o.supersedes!==void 0){let g=zt(d,o.supersedes);if(g===void 0)return Jt(o.supersedes);l=g.id,c===void 0&&g.task!==null&&(c=g.task)}let m=(o.docs??[]).map(g=>ms(g)?ps(s.root,g):g.replace(/^\.\//,"")),h=m.filter(g=>!us(fs(s.root,g))).map(g=>`No file at ${g} \u2014 the link is recorded anyway; it may arrive later.`),p=S();j(s.root,{id:p,type:"decision.recorded",entity:p,actor:s.actor,ts:new Date().toISOString(),source:s.source,data:{title:r,why:i,...o.rejected!==void 0?{rejected:o.rejected.trim()}:{},...c!==void 0?{task:c}:{},...l!==void 0?{supersedes:l}:{},...m.length>0?{docs:m}:{}}});let $=x(s.root,s.actor).state.decisions.find(g=>g.id===p)?.label??p,O=l===void 0?"":`
118
- It replaces ${o.supersedes}, and both links were written by one event \u2014 neither side can go stale.`;return{ok:!0,exitCode:0,warnings:[...a,...h],message:`${$} recorded.${O}`,data:{schema:"kadence/v1",ok:!0,decision:{id:p,label:$,title:r}}}}function Ht(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i=s.decisions;if(n.task!==void 0){let d=N(s,n.task);if(d===void 0)return R(n.task);i=i.filter(a=>a.task===d.id)}return n.all!==!0&&(i=i.filter(d=>d.supersededBy===null)),{ok:!0,exitCode:0,warnings:r,message:hs(i,s),data:{schema:"kadence/v1",ok:!0,decisions:i.map(d=>Gt(d,s))}}}function Vt(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor),i=zt(s,n);return i===void 0?Jt(n):{ok:!0,exitCode:0,warnings:r,message:gs(i,s),data:{schema:"kadence/v1",ok:!0,decision:Gt(i,s)}}}function M(e,t){return t===null?null:e.decisions.find(n=>n.id===t)?.label??e.tasks.find(n=>n.id===t)?.label??t}function Gt(e,t){return{id:e.id,label:e.label,title:e.title,why:e.why,rejected:e.rejected,task:M(t,e.task),docs:e.docs,supersedes:M(t,e.supersedes),supersededBy:M(t,e.supersededBy),superseded:e.supersededBy!==null,at:e.at,by:e.by,source:e.source}}function hs(e,t){return e.length===0?`No decisions recorded yet.
198
+ kadence milestone list --all`,data:{schema:"kadence/v1",ok:!0,milestones:[]}}:{ok:!0,exitCode:0,warnings:o,message:i.map(lr).join(`
199
+ `),data:{schema:"kadence/v1",ok:!0,milestones:i.map(dr)}}}function dr(e){return{id:e.id,label:e.label,name:e.name,due:e.due,status:e.status,doneTasks:e.doneTasks,totalTasks:e.totalTasks,donePoints:e.donePoints,totalPoints:e.totalPoints}}function lr(e){let n=e.totalPoints===0?0:Math.round(e.donePoints/e.totalPoints*100),t=Math.round(n/10),r=`${"#".repeat(t)}${".".repeat(10-t)}`,s=e.due===null?"":` due ${e.due}`,o=e.status==="closed"?" [closed]":"";return`${e.label} ${e.name}${s}${o}
200
+ ${r} ${n}% ${e.donePoints}/${e.totalPoints} points, ${e.doneTasks}/${e.totalTasks} tasks`}import{existsSync as cr}from"node:fs";import{isAbsolute as ur,join as mr,relative as pr}from"node:path";function Pn(e,n){let t=n.toUpperCase();return e.decisions.find(r=>r.id===t||r.label===t)}function In(e){return w(1,"decision_not_found",`No decision ${e}.
201
+ kadence decision list`,{received:e,hint:"kadence decision list --json"})}function Ln(e,n,t,r){let s=S(e,n);if(!C(s))return s;let o=t.trim();if(o.length===0)return w(2,"invalid_argument","A decision needs a title.",{hint:'kadence decision add "Use ULIDs" --why "Clocks disagree between machines"'});let i=r.why?.trim()??"";if(i.length===0)return w(2,"invalid_argument",`A decision needs a reason.
202
+ --why "..."`,{received:o,hint:'kadence decision add "Use ULIDs" --why "Clocks disagree between machines"'});let{state:a,warnings:d}=A(s.root,s.actor),l;if(r.task!==void 0){let g=K(a,r.task);if(g===void 0)return F(r.task);l=g.id}let c;if(r.supersedes!==void 0){let g=Pn(a,r.supersedes);if(g===void 0)return In(r.supersedes);c=g.id,l===void 0&&g.task!==null&&(l=g.task)}let u=(r.docs??[]).map(g=>ur(g)?pr(s.root,g):g.replace(/^\.\//,"")),k=u.filter(g=>!cr(mr(s.root,g))).map(g=>`No file at ${g} \u2014 the link is recorded anyway; it may arrive later.`),f=T();R(s.root,{id:f,type:"decision.recorded",entity:f,actor:s.actor,ts:new Date().toISOString(),source:s.source,data:{title:o,why:i,...r.rejected!==void 0?{rejected:r.rejected.trim()}:{},...l!==void 0?{task:l}:{},...c!==void 0?{supersedes:c}:{},...u.length>0?{docs:u}:{}}});let b=A(s.root,s.actor).state.decisions.find(g=>g.id===f)?.label??f,v=c===void 0?"":`
203
+ It replaces ${r.supersedes}, and both links were written by one event \u2014 neither side can go stale.`;return{ok:!0,exitCode:0,warnings:[...d,...k],message:`${b} recorded.${v}`,data:{schema:"kadence/v1",ok:!0,decision:{id:f,label:b,title:o}}}}function Wn(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i=s.decisions;if(t.task!==void 0){let a=K(s,t.task);if(a===void 0)return F(t.task);i=i.filter(d=>d.task===a.id)}return t.all!==!0&&(i=i.filter(a=>a.supersededBy===null)),{ok:!0,exitCode:0,warnings:o,message:hr(i,s),data:{schema:"kadence/v1",ok:!0,decisions:i.map(a=>Fn(a,s))}}}function Bn(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor),i=Pn(s,t);return i===void 0?In(t):{ok:!0,exitCode:0,warnings:o,message:fr(i,s),data:{schema:"kadence/v1",ok:!0,decision:Fn(i,s)}}}function V(e,n){return n===null?null:e.decisions.find(t=>t.id===n)?.label??e.tasks.find(t=>t.id===n)?.label??n}function Fn(e,n){return{id:e.id,label:e.label,title:e.title,why:e.why,rejected:e.rejected,task:V(n,e.task),docs:e.docs,supersedes:V(n,e.supersedes),supersededBy:V(n,e.supersededBy),superseded:e.supersededBy!==null,at:e.at,by:e.by,source:e.source}}function hr(e,n){return e.length===0?`No decisions recorded yet.
119
204
  Record the first one:
120
- kadence decision add "Use ULIDs" --why "Clocks disagree"`:e.map(n=>{let o=n.supersededBy===null?"":` (superseded by ${M(t,n.supersededBy)})`,s=n.source==="agent"?" [agent]":"";return`${n.label} ${n.title}${o}${s}`}).join(`
121
- `)}function gs(e,t){let n=[`${e.label} ${e.title}`];return e.supersededBy!==null&&n.push("",`!! SUPERSEDED by ${M(t,e.supersededBy)} \u2014 this is no longer in force.`),n.push("",`Why: ${e.why}`),e.rejected!==null&&n.push(`Rejected: ${e.rejected}`),e.task!==null&&n.push(`Task: ${M(t,e.task)}`),e.docs.length>0&&n.push(`Docs: ${e.docs.join(", ")}`),n.push(`By: ${e.by}${e.source==="agent"?" (agent)":""}`),e.supersedes!==null&&n.push(`Replaces: ${M(t,e.supersedes)}`),n.join(`
122
- `)}import{writeSync as Es}from"node:fs";import{mkdirSync as ws,existsSync as vs,readFileSync as $s,writeFileSync as nn}from"node:fs";import{dirname as xs,join as Ss}from"node:path";function C(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var ks=`
205
+ kadence decision add "Use ULIDs" --why "Clocks disagree"`:e.map(t=>{let r=t.supersededBy===null?"":` (superseded by ${V(n,t.supersededBy)})`,s=t.source==="agent"?" [agent]":"";return`${t.label} ${t.title}${r}${s}`}).join(`
206
+ `)}function fr(e,n){let t=[`${e.label} ${e.title}`];return e.supersededBy!==null&&t.push("",`!! SUPERSEDED by ${V(n,e.supersededBy)} \u2014 this is no longer in force.`),t.push("",`Why: ${e.why}`),e.rejected!==null&&t.push(`Rejected: ${e.rejected}`),e.task!==null&&t.push(`Task: ${V(n,e.task)}`),e.docs.length>0&&t.push(`Docs: ${e.docs.join(", ")}`),t.push(`By: ${e.by}${e.source==="agent"?" (agent)":""}`),e.supersedes!==null&&t.push(`Replaces: ${V(n,e.supersedes)}`),t.join(`
207
+ `)}import{writeSync as Dr}from"node:fs";import{existsSync as yr,readFileSync as $r,writeFileSync as wr}from"node:fs";import{join as vr}from"node:path";var gr=`
123
208
  :root {
124
209
  color-scheme: light dark;
125
210
  --bg: #ffffff; --fg: #1a1a1a; --muted: #6b6b6b; --line: #e2e2e2;
@@ -172,62 +257,62 @@ th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: u
172
257
  .criteria li.checked { color: var(--done); }
173
258
  .empty { color: var(--muted); }
174
259
  footer { margin-top: 2.5rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); padding-top: .75rem; }
175
- `;function Zt(e,t,n=""){let o=t===0?0:Math.round(e/t*100);return`<div class="bar ${n}"><span style="width:${o}%"></span></div>`}function bs(e,t){let n=[];if(e.contestedBy.length>0?n.push(`<span class="pill danger">contested: ${C(e.contestedBy.join(", "))}</span>`):e.claimedBy!==null&&n.push(`<span class="pill">claimed ${C(e.claimedBy)}</span>`),e.blockedBy.length>0&&n.push(`<span class="pill danger">blocked by ${e.blockedBy.length}</span>`),e.criteria.length>0){let d=e.criteria.filter(c=>c.checked).length,a=d===e.criteria.length?"pill":"pill warn";n.push(`<span class="${a}">${d}/${e.criteria.length} criteria</span>`)}let o=e.milestone===null?null:t.milestones.find(d=>d.id===e.milestone)?.name??null;o!==null&&n.push(`<span class="pill">${C(o)}</span>`);let s=[e.assignee===null?"":C(e.assignee),e.estimate===null?"":`${e.estimate} pts`,e.due===null?"":`due ${C(e.due)}`].filter(d=>d.length>0),r=e.criteria.length===0?"":`<ul class="criteria">${e.criteria.map(d=>`<li class="${d.checked?"checked":""}">${d.checked?"\u2611":"\u2610"} ${C(d.text)}</li>`).join("")}</ul>`;return[`<div class="card ${e.contestedBy.length>0?"contested":e.blockedBy.length>0?"blocked":C(e.status)}">`,`<span class="label">${C(e.label)}</span>`,`<span class="title">${C(e.title)}</span>`,n.length>0?n.join(""):"",r,s.length>0?`<div class="meta">${s.join(" \xB7 ")}</div>`:"","</div>"].join("")}function Qt(e,t=null,n=new Date){let o=n.toISOString().slice(0,16).replace("T"," "),s=[];s.push("<h1>Board</h1>"),s.push(`<p class="stamp">Snapshot of <code>.kadence/</code> at ${C(o)} UTC. A file, not a page: nothing here is live, and regenerating it is <code>kadence board export --html</code>.</p>`);let r=e.tasks.length>0;r||s.push('<p class="empty">No tasks yet. Create the first one with <code>kadence task add "title"</code>.</p>');{let d=e.sprints.find(c=>c.status==="active");if(r&&d!==void 0){let c=P(e,d.id);if(s.push(`<h2>Sprint: ${C(d.name)}</h2>`),c!==null&&(s.push(Zt(c.velocity,c.committed,"done")),s.push(`<p class="stamp">${c.velocity} of ${c.committed} points done, ${c.carriedOver.length} carrying over.</p>`)),t!==null&&t.committed>0&&t.days.length>0){s.push("<h2>Burndown</h2>"),s.push('<div class="chart">');for(let l of t.days){let m=Math.round(l.remaining/t.committed*100),f=Math.round(l.ideal/t.committed*100);s.push(`<div><span class="day">${C(l.date.slice(5))}</span><span class="track"><span class="bar"><span style="width:${m}%"></span></span></span><span class="day">${l.remaining} / ${f}%</span></div>`)}s.push("</div>")}}if(e.milestones.length>0){s.push("<h2>Milestones</h2>"),s.push("<table><tr><th>Milestone</th><th>Due</th><th>Progress</th><th>Points</th><th>Tasks</th></tr>");for(let c of e.milestones)s.push(`<tr><td>${C(c.name)}${c.status==="closed"?' <span class="pill">closed</span>':""}</td><td>${C(c.due??"")}</td><td>${Zt(c.donePoints,c.totalPoints)}</td><td>${c.donePoints}/${c.totalPoints}</td><td>${c.doneTasks}/${c.totalTasks}</td></tr>`);s.push("</table>")}if(r){s.push("<h2>Tasks</h2>"),s.push('<div class="columns">');let c=[...e.statuses,...e.orphanStatuses];for(let l of c){let m=e.tasks.filter(f=>f.status===l);if(!(m.length===0&&l===T)){s.push('<div class="column">'),s.push(`<h3>${C(l)} (${m.length})</h3>`),m.length===0&&s.push('<p class="empty">\u2014</p>');for(let f of m)s.push(bs(f,e));s.push("</div>")}}s.push("</div>")}let a=e.decisions.filter(c=>c.supersededBy===null);if(a.length>0){s.push("<h2>Decisions in force</h2>");for(let c of a)s.push('<div class="decision">'),s.push(`<strong>${C(c.label)} ${C(c.title)}</strong>`),s.push(`<div class="why">Why: ${C(c.why)}</div>`),c.rejected!==null&&s.push(`<div class="why">Rejected: ${C(c.rejected)}</div>`),s.push("</div>")}}let i=e.tasks.filter(d=>d.status!==D&&d.status!==T);return s.push(`<footer>${e.tasks.length} tasks, ${i.length} open. Generated by kadence from the event journal. No server, no network.</footer>`),["<!doctype html>",'<html lang="en">',"<head>",'<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',"<title>kadence board</title>",`<style>${ks}</style>`,"</head>","<body>","<main>",...s,"</main>","</body>","</html>",""].join(`
176
- `)}var Xt="<!-- kadence:board:begin -->",he="<!-- kadence:board:end -->";function E(e){return e.replace(/\|/g,"\\|").replace(/\n+/g," ").replace(/kadence:board:(begin|end)/g,"kadence:board:\u200B$1")}function en(e,t,n=20){if(t===0)return`${"\u2591".repeat(n)} 0%`;let o=Math.round(e/t*100),s=Math.round(o/100*n);return`${"\u2588".repeat(s)}${"\u2591".repeat(n-s)} ${o}%`}function ys(e,t){let n=e.criteria.length===0?"":`${e.criteria.filter(s=>s.checked).length}/${e.criteria.length}`,o=e.milestone===null?"":t.find(s=>s.id===e.milestone)?.name??"";return`| ${E(e.label)} | ${E(e.title)} | ${E(e.status)} | ${E(e.priority)} | ${e.estimate??""} | ${E(e.assignee??"")} | ${n} | ${E(o)} |`}function ge(e,t=new Date){let n=["# Board"],o=t.toISOString().slice(0,16).replace("T"," ");n.push("",`Snapshot of \`.kadence/\` at ${o} UTC. Regenerate with \`kadence board export --md\`.`);let s=e.tasks.length>0,r=e.sprints.find(a=>a.status==="active");if(s&&r!==void 0){let a=P(e,r.id);n.push("",`## Sprint: ${E(r.name)}`),a!==null&&(n.push(""),n.push(`${en(a.velocity,a.committed)} \u2014 ${a.velocity} of ${a.committed} points`))}if(e.milestones.length>0){n.push("","## Milestones","","| Milestone | Due | Progress | Points | Tasks |","|---|---|---|---|---|");for(let a of e.milestones)n.push(`| ${E(a.name)}${a.status==="closed"?" (closed)":""} | ${E(a.due??"")} | ${en(a.donePoints,a.totalPoints,10)} | ${a.donePoints}/${a.totalPoints} | ${a.doneTasks}/${a.totalTasks} |`)}if(s){n.push("","## Tasks","","| Task | Title | Status | Priority | Points | Assignee | Criteria | Milestone |","|---|---|---|---|---|---|---|---|");let a=new Map(e.statuses.map((l,m)=>[l,m])),c=[...e.tasks].sort((l,m)=>(a.get(l.status)??99)-(a.get(m.status)??99)||(l.id<m.id?-1:1));for(let l of c)n.push(ys(l,e.milestones))}else n.push("","No tasks yet.","",' kadence task add "first task"');let i=e.decisions.filter(a=>a.supersededBy===null);if(i.length>0){n.push("","## Decisions in force");for(let a of i)n.push("",`**${a.label} ${E(a.title)}**`,"",`Why: ${E(a.why)}`),a.rejected!==null&&n.push("",`Rejected: ${E(a.rejected)}`)}let d=e.tasks.filter(a=>a.status!==D&&a.status!==T);return n.push("",`${e.tasks.length} tasks, ${d.length} open.`),`${n.join(`
260
+ `;function Kn(e,n,t=""){let r=n===0?0:Math.round(e/n*100);return`<div class="bar ${t}"><span style="width:${r}%"></span></div>`}function kr(e,n){let t=[];if(e.contestedBy.length>0?t.push(`<span class="pill danger">contested: ${$(e.contestedBy.join(", "))}</span>`):e.claimedBy!==null&&t.push(`<span class="pill">claimed ${$(e.claimedBy)}</span>`),e.blockedBy.length>0&&t.push(`<span class="pill danger">blocked by ${e.blockedBy.length}</span>`),e.criteria.length>0){let a=e.criteria.filter(l=>l.checked).length,d=a===e.criteria.length?"pill":"pill warn";t.push(`<span class="${d}">${a}/${e.criteria.length} criteria</span>`)}let r=e.milestone===null?null:n.milestones.find(a=>a.id===e.milestone)?.name??null;r!==null&&t.push(`<span class="pill">${$(r)}</span>`);let s=[e.assignee===null?"":$(e.assignee),e.estimate===null?"":`${e.estimate} pts`,e.due===null?"":`due ${$(e.due)}`].filter(a=>a.length>0),o=e.criteria.length===0?"":`<ul class="criteria">${e.criteria.map(a=>`<li class="${a.checked?"checked":""}">${a.checked?"\u2611":"\u2610"} ${$(a.text)}</li>`).join("")}</ul>`;return[`<div class="card ${e.contestedBy.length>0?"contested":e.blockedBy.length>0?"blocked":$(e.status)}">`,`<span class="label">${$(e.label)}</span>`,`<span class="title">${$(e.title)}</span>`,t.length>0?t.join(""):"",o,s.length>0?`<div class="meta">${s.join(" \xB7 ")}</div>`:"","</div>"].join("")}function Un(e,n=null,t=new Date){let r=t.toISOString().slice(0,16).replace("T"," "),s=[];s.push("<h1>Board</h1>"),s.push(`<p class="stamp">Snapshot of <code>.kadence/</code> at ${$(r)} UTC. A file, not a page: nothing here is live, and regenerating it is <code>kadence board export --html</code>.</p>`);let o=e.tasks.length>0;o||s.push('<p class="empty">No tasks yet. Create the first one with <code>kadence task add "title"</code>.</p>');{let a=e.sprints.find(l=>l.status==="active");if(o&&a!==void 0){let l=X(e,a.id);if(s.push(`<h2>Sprint: ${$(a.name)}</h2>`),l!==null&&(s.push(Kn(l.velocity,l.committed,"done")),s.push(`<p class="stamp">${l.velocity} of ${l.committed} points done, ${l.carriedOver.length} carrying over.</p>`)),n!==null&&n.committed>0&&n.days.length>0){s.push("<h2>Burndown</h2>"),s.push('<div class="chart">');for(let c of n.days){let u=Math.round(c.remaining/n.committed*100),m=Math.round(c.ideal/n.committed*100);s.push(`<div><span class="day">${$(c.date.slice(5))}</span><span class="track"><span class="bar"><span style="width:${u}%"></span></span></span><span class="day">${c.remaining} / ${m}%</span></div>`)}s.push("</div>")}}if(e.milestones.length>0){s.push("<h2>Milestones</h2>"),s.push("<table><tr><th>Milestone</th><th>Due</th><th>Progress</th><th>Points</th><th>Tasks</th></tr>");for(let l of e.milestones)s.push(`<tr><td>${$(l.name)}${l.status==="closed"?' <span class="pill">closed</span>':""}</td><td>${$(l.due??"")}</td><td>${Kn(l.donePoints,l.totalPoints)}</td><td>${l.donePoints}/${l.totalPoints}</td><td>${l.doneTasks}/${l.totalTasks}</td></tr>`);s.push("</table>")}if(o){s.push("<h2>Tasks</h2>"),s.push('<div class="columns">');let l=[...e.statuses,...e.orphanStatuses];for(let c of l){let u=e.tasks.filter(m=>m.status===c);if(!(u.length===0&&c===M)){s.push('<div class="column">'),s.push(`<h3>${$(c)} (${u.length})</h3>`),u.length===0&&s.push('<p class="empty">\u2014</p>');for(let m of u)s.push(kr(m,e));s.push("</div>")}}s.push("</div>")}let d=e.decisions.filter(l=>l.supersededBy===null);if(d.length>0){s.push("<h2>Decisions in force</h2>");for(let l of d)s.push('<div class="decision">'),s.push(`<strong>${$(l.label)} ${$(l.title)}</strong>`),s.push(`<div class="why">Why: ${$(l.why)}</div>`),l.rejected!==null&&s.push(`<div class="why">Rejected: ${$(l.rejected)}</div>`),s.push("</div>")}}let i=e.tasks.filter(a=>a.status!==O&&a.status!==M);return s.push(`<footer>${e.tasks.length} tasks, ${i.length} open. Generated by kadence from the event journal. No server, no network.</footer>`),["<!doctype html>",'<html lang="en">',"<head>",'<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',"<title>kadence board</title>",`<style>${gr}</style>`,"</head>","<body>","<main>",...s,"</main>","</body>","</html>",""].join(`
261
+ `)}var Hn="<!-- kadence:board:begin -->",Ue="<!-- kadence:board:end -->";function _(e){return e.replace(/\|/g,"\\|").replace(/\n+/g," ").replace(/kadence:board:(begin|end)/g,"kadence:board:\u200B$1")}function zn(e,n,t=20){if(n===0)return`${"\u2591".repeat(t)} 0%`;let r=Math.round(e/n*100),s=Math.round(r/100*t);return`${"\u2588".repeat(s)}${"\u2591".repeat(t-s)} ${r}%`}function br(e,n){let t=e.criteria.length===0?"":`${e.criteria.filter(s=>s.checked).length}/${e.criteria.length}`,r=e.milestone===null?"":n.find(s=>s.id===e.milestone)?.name??"";return`| ${_(e.label)} | ${_(e.title)} | ${_(e.status)} | ${_(e.priority)} | ${e.estimate??""} | ${_(e.assignee??"")} | ${t} | ${_(r)} |`}function He(e,n=new Date){let t=["# Board"],r=n.toISOString().slice(0,16).replace("T"," ");t.push("",`Snapshot of \`.kadence/\` at ${r} UTC. Regenerate with \`kadence board export --md\`.`);let s=e.tasks.length>0,o=e.sprints.find(d=>d.status==="active");if(s&&o!==void 0){let d=X(e,o.id);t.push("",`## Sprint: ${_(o.name)}`),d!==null&&(t.push(""),t.push(`${zn(d.velocity,d.committed)} \u2014 ${d.velocity} of ${d.committed} points`))}if(e.milestones.length>0){t.push("","## Milestones","","| Milestone | Due | Progress | Points | Tasks |","|---|---|---|---|---|");for(let d of e.milestones)t.push(`| ${_(d.name)}${d.status==="closed"?" (closed)":""} | ${_(d.due??"")} | ${zn(d.donePoints,d.totalPoints,10)} | ${d.donePoints}/${d.totalPoints} | ${d.doneTasks}/${d.totalTasks} |`)}if(s){t.push("","## Tasks","","| Task | Title | Status | Priority | Points | Assignee | Criteria | Milestone |","|---|---|---|---|---|---|---|---|");let d=new Map(e.statuses.map((c,u)=>[c,u])),l=[...e.tasks].sort((c,u)=>(d.get(c.status)??99)-(d.get(u.status)??99)||(c.id<u.id?-1:1));for(let c of l)t.push(br(c,e.milestones))}else t.push("","No tasks yet.","",' kadence task add "first task"');let i=e.decisions.filter(d=>d.supersededBy===null);if(i.length>0){t.push("","## Decisions in force");for(let d of i)t.push("",`**${d.label} ${_(d.title)}**`,"",`Why: ${_(d.why)}`),d.rejected!==null&&t.push("",`Rejected: ${_(d.rejected)}`)}let a=e.tasks.filter(d=>d.status!==O&&d.status!==M);return t.push("",`${e.tasks.length} tasks, ${a.length} open.`),`${t.join(`
177
262
  `)}
178
- `}function tn(e,t){let n=`${Xt}
179
- ${t.trimEnd()}
180
- ${he}`,o=e.indexOf(Xt),s=o===-1?-1:e.indexOf(he,o);if(o!==-1&&s!==-1&&s>o)return`${e.slice(0,o)}${n}${e.slice(s+he.length)}`;let r=e.endsWith(`
263
+ `}function Yn(e,n){let t=`${Hn}
264
+ ${n.trimEnd()}
265
+ ${Ue}`,r=e.indexOf(Hn),s=r===-1?-1:e.indexOf(Ue,r);if(r!==-1&&s!==-1&&s>r)return`${e.slice(0,r)}${t}${e.slice(s+Ue.length)}`;let o=e.endsWith(`
181
266
  `)?"":`
182
- `;return`${e}${r}
183
- ${n}
184
- `}var ke="cancelled",Cs=["id","label","title","status","type","priority","estimate","assignee","claimedBy","contestedBy","blockedBy","sprint","milestone","due"];function on(e,t,n,o,s=!1){let r=w(e,t);if(!v(r))return r;let{fields:i,error:d}=We(o);if(d!==null)return d;let a=i??(s?[...Cs]:null),{state:c,warnings:l}=x(r.root,r.actor),m=c.tasks.filter(k=>k.status!==ke);if(n.assignee!==void 0){let k=n.assignee.toLowerCase(),$=k==="me"?r.actor.toLowerCase():k;m=m.filter(O=>(O.assignee??"").toLowerCase()===$)}if(n.sprint==="active"){let k=c.sprints.find($=>$.status==="active"||$.status==="planned");m=k===void 0?[]:m.filter($=>$.sprint===k.id)}let f={};for(let k of c.statuses)k!==ke&&(f[k]=m.filter($=>$.status===k));let h=c.orphanStatuses.filter(k=>k!==ke);for(let k of h)f[k]=m.filter($=>$.status===k);let p=h.length>0?[`Statuses not in the board configuration: ${h.join(", ")}.
267
+ `;return`${e}${o}
268
+ ${t}
269
+ `}var ze="cancelled",xr=["id","label","title","status","type","priority","estimate","assignee","claimedBy","contestedBy","blockedBy","sprint","milestone","due"];function Jn(e,n,t,r,s=!1){let o=S(e,n);if(!C(o))return o;let{fields:i,error:a}=ht(r);if(a!==null)return a;let d=i??(s?[...xr]:null),{state:l,warnings:c}=A(o.root,o.actor),u=l.tasks.filter(y=>y.status!==ze);if(t.assignee!==void 0){let y=t.assignee.toLowerCase(),b=y==="me"?o.actor.toLowerCase():y;u=u.filter(v=>(v.assignee??"").toLowerCase()===b)}if(t.sprint==="active"){let y=l.sprints.find(b=>b.status==="active"||b.status==="planned");u=y===void 0?[]:u.filter(b=>b.sprint===y.id)}let m={};for(let y of l.statuses)y!==ze&&(m[y]=u.filter(b=>b.status===y));let k=l.orphanStatuses.filter(y=>y!==ze);for(let y of k)m[y]=u.filter(b=>b.status===y);let f=k.length>0?[`Statuses not in the board configuration: ${k.join(", ")}.
185
270
  Tasks there are still shown. Add the column or move them:
186
- kadence board config --statuses "..."`]:[];return{ok:!0,exitCode:0,warnings:[...l,...p],message:Ne(f,W(t,process.stdout.isTTY===!0)),data:{schema:"kadence/v1",ok:!0,columns:Object.fromEntries(Object.entries(f).map(([k,$])=>[k,$.map(O=>Fe(O,a,c))]))}}}function rn(e,t,n,o,s){let r=w(e,t);if(!v(r))return r;let{state:i,warnings:d}=x(r.root,r.actor);if(n===void 0&&o===void 0&&s===void 0){let f=i.dod.length===0?"Definition of done: not set":`Definition of done: ${i.dod.join(", ")}`;return{ok:!0,exitCode:0,warnings:[...d,...sn(i.statuses,i.started)],message:`Board columns: ${i.statuses.join(", ")}
271
+ kadence board config --statuses "..."`]:[];return{ok:!0,exitCode:0,warnings:[...c,...f],message:ot(m,me(n,process.stdout.isTTY===!0)),data:{schema:"kadence/v1",ok:!0,columns:Object.fromEntries(Object.entries(m).map(([y,b])=>[y,b.map(v=>ft(v,d,l))]))}}}function Vn(e,n,t,r,s){let o=S(e,n);if(!C(o))return o;let{state:i,warnings:a}=A(o.root,o.actor);if(t===void 0&&r===void 0&&s===void 0){let m=i.dod.length===0?"Definition of done: not set":`Definition of done: ${i.dod.join(", ")}`;return{ok:!0,exitCode:0,warnings:[...a,...qn(i.statuses,i.started)],message:`Board columns: ${i.statuses.join(", ")}
187
272
  Started: ${i.started} (cycle time and actual hours count from here)
188
- ${f}
273
+ ${m}
189
274
 
190
275
  Change them with:
191
276
  kadence board config --statuses "todo,doing,review,done"
192
277
  kadence board config --started doing
193
- kadence board config --dod "tests green,docs updated"`,data:{schema:"kadence/v1",ok:!0,statuses:i.statuses,dod:i.dod,started:i.started}}}if(n===void 0&&o===void 0&&s!==void 0){let f=be(s,i.statuses);if(typeof f!="string")return f;let h=f;return h===i.started?{ok:!0,exitCode:0,warnings:d,message:`Work already counts as started at "${h}".`,data:{schema:"kadence/v1",ok:!0,started:h}}:(j(r.root,{id:S(),type:"board.configured",entity:S(),actor:r.actor,ts:new Date().toISOString(),source:r.source,data:{started:h}}),{ok:!0,exitCode:0,warnings:d,message:`Work counts as started at "${h}".
194
- Cycle time, work item age and a sprint's actual hours are measured from this column.`,data:{schema:"kadence/v1",ok:!0,started:h}})}if(n===void 0){let f;if(s!==void 0){let p=be(s,i.statuses);if(typeof p!="string")return p;f=p}let h=o.split(",").map(p=>p.trim()).filter(p=>p.length>0);return h.length===i.dod.length&&h.every((p,k)=>p===i.dod[k])?{ok:!0,exitCode:0,warnings:d,message:h.length===0?"There is already no definition of done.":`Definition of done is already: ${h.join(", ")}`,data:{schema:"kadence/v1",ok:!0,dod:h}}:(j(r.root,{id:S(),type:"board.configured",entity:S(),actor:r.actor,ts:new Date().toISOString(),source:r.source,data:{dod:h,...f===void 0?{}:{started:f}}}),{ok:!0,exitCode:0,warnings:d,message:(h.length===0?"Definition of done cleared. New tasks start with no criteria.":`Definition of done: ${h.join(", ")}
195
- New tasks start with these criteria. Tasks that already exist keep theirs.`)+(f===void 0?"":`
196
- Work counts as started at "${f}".`),data:{schema:"kadence/v1",ok:!0,dod:h,...f===void 0?{}:{started:f}}})}let a=n.split(",").map(f=>f.trim().toLowerCase().replace(/\s+/g,"_")).filter(f=>f.length>0);if(a.length===0)return y(2,"invalid_argument","At least one status is required.",{received:n});if(new Set(a).size!==a.length)return y(2,"invalid_argument","The same status is listed twice.",{received:n});if(!a.includes(D))return y(2,"invalid_argument",`The list must include "${D}" \u2014 velocity and burndown are computed from it.`,{received:n});let c=i.tasks.filter(f=>!a.includes(f.status)&&f.status!==T),l;if(s!==void 0){let f=be(s,a);if(typeof f!="string")return f;l=f}j(r.root,{id:S(),type:"board.configured",entity:S(),actor:r.actor,ts:new Date().toISOString(),source:r.source,data:{statuses:a,...o===void 0?{}:{dod:o.split(",").map(f=>f.trim()).filter(f=>f.length>0)},...l===void 0?{}:{started:l}}});let m=c.length>0?`
197
- ${c.length} task(s) remain in removed columns: ${[...new Set(c.map(f=>f.status))].join(", ")}. They are still listed.`:"";return{ok:!0,exitCode:0,warnings:[...d,...sn(a,l??i.started)],message:`Board columns: ${a.join(", ")}${m}`+(l===void 0?"":`
198
- Work counts as started at "${l}".`),data:{schema:"kadence/v1",ok:!0,statuses:a}}}var As="kadence-board.html",js="kadence-board.md";function an(e,t,n){let o=w(e,t);if(!v(o))return o;if(n.html!==!0&&n.md!==!0)return y(2,"invalid_argument",`Which format?
278
+ kadence board config --dod "tests green,docs updated"`,data:{schema:"kadence/v1",ok:!0,statuses:i.statuses,dod:i.dod,started:i.started}}}if(t===void 0&&r===void 0&&s!==void 0){let m=Ye(s,i.statuses);if(typeof m!="string")return m;let k=m;return k===i.started?{ok:!0,exitCode:0,warnings:a,message:`Work already counts as started at "${k}".`,data:{schema:"kadence/v1",ok:!0,started:k}}:(R(o.root,{id:T(),type:"board.configured",entity:T(),actor:o.actor,ts:new Date().toISOString(),source:o.source,data:{started:k}}),{ok:!0,exitCode:0,warnings:a,message:`Work counts as started at "${k}".
279
+ Cycle time, work item age and a sprint's actual hours are measured from this column.`,data:{schema:"kadence/v1",ok:!0,started:k}})}if(t===void 0){let m;if(s!==void 0){let f=Ye(s,i.statuses);if(typeof f!="string")return f;m=f}let k=r.split(",").map(f=>f.trim()).filter(f=>f.length>0);return k.length===i.dod.length&&k.every((f,y)=>f===i.dod[y])?{ok:!0,exitCode:0,warnings:a,message:k.length===0?"There is already no definition of done.":`Definition of done is already: ${k.join(", ")}`,data:{schema:"kadence/v1",ok:!0,dod:k}}:(R(o.root,{id:T(),type:"board.configured",entity:T(),actor:o.actor,ts:new Date().toISOString(),source:o.source,data:{dod:k,...m===void 0?{}:{started:m}}}),{ok:!0,exitCode:0,warnings:a,message:(k.length===0?"Definition of done cleared. New tasks start with no criteria.":`Definition of done: ${k.join(", ")}
280
+ New tasks start with these criteria. Tasks that already exist keep theirs.`)+(m===void 0?"":`
281
+ Work counts as started at "${m}".`),data:{schema:"kadence/v1",ok:!0,dod:k,...m===void 0?{}:{started:m}}})}let d=t.split(",").map(m=>m.trim().toLowerCase().replace(/\s+/g,"_")).filter(m=>m.length>0);if(d.length===0)return w(2,"invalid_argument","At least one status is required.",{received:t});if(new Set(d).size!==d.length)return w(2,"invalid_argument","The same status is listed twice.",{received:t});if(!d.includes(O))return w(2,"invalid_argument",`The list must include "${O}" \u2014 velocity and burndown are computed from it.`,{received:t});let l=i.tasks.filter(m=>!d.includes(m.status)&&m.status!==M),c;if(s!==void 0){let m=Ye(s,d);if(typeof m!="string")return m;c=m}R(o.root,{id:T(),type:"board.configured",entity:T(),actor:o.actor,ts:new Date().toISOString(),source:o.source,data:{statuses:d,...r===void 0?{}:{dod:r.split(",").map(m=>m.trim()).filter(m=>m.length>0)},...c===void 0?{}:{started:c}}});let u=l.length>0?`
282
+ ${l.length} task(s) remain in removed columns: ${[...new Set(l.map(m=>m.status))].join(", ")}. They are still listed.`:"";return{ok:!0,exitCode:0,warnings:[...a,...qn(d,c??i.started)],message:`Board columns: ${d.join(", ")}${u}`+(c===void 0?"":`
283
+ Work counts as started at "${c}".`),data:{schema:"kadence/v1",ok:!0,statuses:d}}}var Sr="kadence-board.html",Cr="kadence-board.md";function Gn(e,n,t){let r=S(e,n);if(!C(r))return r;if(t.html!==!0&&t.md!==!0)return w(2,"invalid_argument",`Which format?
199
284
  kadence board export --html
200
- kadence board export --md`,{hint:"kadence board export --html"});if(n.html===!0&&n.md===!0)return y(2,"invalid_argument","One format at a time: --html or --md.",{hint:"kadence board export --html"});if(n.readme===!0&&n.html===!0)return y(2,"invalid_argument","--readme writes markdown. Use --md with it.",{hint:"kadence board export --md --readme"});let{state:s,warnings:r}=x(o.root,o.actor);if(n.md===!0&&n.readme===!0){if(n.file!==void 0)return y(2,"invalid_argument","--readme writes into README.md, so --file has nowhere to go.",{received:n.file,hint:"kadence board export --md --file docs/board.md"});let l=Ss(o.root,"README.md");if(!vs(l))return y(1,"conflicting_state",`There is no README.md here to update.
285
+ kadence board export --md`,{hint:"kadence board export --html"});if(t.html===!0&&t.md===!0)return w(2,"invalid_argument","One format at a time: --html or --md.",{hint:"kadence board export --html"});if(t.readme===!0&&t.html===!0)return w(2,"invalid_argument","--readme writes markdown. Use --md with it.",{hint:"kadence board export --md --readme"});let{state:s,warnings:o}=A(r.root,r.actor);if(t.md===!0&&t.readme===!0){if(t.file!==void 0)return w(2,"invalid_argument","--readme writes into README.md, so --file has nowhere to go.",{received:t.file,hint:"kadence board export --md --file docs/board.md"});let l=vr(r.root,"README.md");if(!yr(l))return w(1,"conflicting_state",`There is no README.md here to update.
201
286
  Write the board to a file instead:
202
- kadence board export --md`,{hint:"kadence board export --md"});let m=tn($s(l,"utf8"),ge(s));return nn(l,m,"utf8"),{ok:!0,exitCode:0,warnings:r,message:`Board section updated in ${l}.
203
- It is a snapshot: rerun this after the board changes.`,data:{schema:"kadence/v1",ok:!0,format:"md",path:l,section:!0,bytes:Buffer.byteLength(m)}}}let i=n.file??(n.html===!0?As:js),d=qe(o.root,i,"kadence board export --html --file docs/board.html");if("exitCode"in d)return d;let a=d.full,c=n.html===!0?Qt(s,Ds(o.root,s)):ge(s);ws(xs(a),{recursive:!0});try{nn(a,c,"utf8")}catch(l){return y(1,"conflicting_state",`Could not write ${a}: ${l.code??"unknown error"}.`,{received:d.rel,hint:"kadence board export --html --file docs/board.html"})}return{ok:!0,exitCode:0,warnings:r,message:`Wrote ${a}.
204
- `+(n.html===!0?"Open it from disk \u2014 there is no server, and the page makes no requests.":"A snapshot for a README or a pull request."),data:{schema:"kadence/v1",ok:!0,format:n.html===!0?"html":"md",path:a,section:!1,bytes:Buffer.byteLength(c)}}}function Ds(e,t){let n=t.sprints.find(o=>o.status==="active");return n===void 0?null:rt(t,xe(e).events,n)}function sn(e,t){return e.includes(t)?[]:[`Work is set to start at "${t}", which is not one of the columns any more. Cycle time and actual hours will be empty until it is:
205
- kadence board config --started ${e[1]??e[0]??"doing"}`]}function be(e,t){let n=e.trim().toLowerCase().replace(/\s+/g,"_");return n===D||n===T?y(2,"invalid_argument",`Work cannot start at "${n}" \u2014 that is where it ends. Cycle time would always be zero.`,{received:e,allowed:t.filter(o=>o!==D&&o!==T)}):t.includes(n)?n:y(2,"unknown_status",`"${e}" is not one of this board's columns.
206
- Available: ${t.join(", ")}`,{received:e,allowed:t,hint:"kadence board config --json"})}var Ts=["description","type","priority","estimate","labels","assignee"];function dn(e,t,n,o){let s=w(e,t);if(!v(s))return s;let r=n.trim();if(r.length===0)return y(2,"invalid_argument","A template needs a name.",{hint:"kadence template list --json"});let i={};for(let d of Ts)o[d]!==void 0&&(i[d]=o[d]);return Object.keys(i).length===0?y(2,"invalid_argument",`A template needs at least one field.
207
- kadence template save bug --type bug --priority high --label triage`,{received:n}):(j(s.root,{id:S(),type:"template.saved",entity:S(),actor:s.actor,ts:new Date().toISOString(),source:s.source,data:{name:r,fields:i}}),{ok:!0,exitCode:0,message:`Template "${r}" saved: ${Object.keys(i).join(", ")}.
208
- kadence task add "title" --template ${r}`,data:{schema:"kadence/v1",ok:!0,template:{name:r,fields:i}}})}function cn(e,t){let n=w(e,t);if(!v(n))return n;let{state:o,warnings:s}=x(n.root,n.actor);return o.templates.length===0?{ok:!0,exitCode:0,warnings:s,message:`No templates yet.
209
- kadence template save bug --type bug --priority high`,data:{schema:"kadence/v1",ok:!0,templates:[]}}:{ok:!0,exitCode:0,warnings:s,message:o.templates.map(r=>{let i=Object.entries(r.fields).map(([d,a])=>`${d}=${Array.isArray(a)?a.join("/"):String(a)}`).join(" ");return` ${r.name.padEnd(14)} ${i}`}).join(`
210
- `),data:{schema:"kadence/v1",ok:!0,templates:o.templates}}}function ln(e,t,n){let o=w(e,t);if(!v(o))return o;let{state:s,warnings:r}=x(o.root,o.actor);return s.templates.some(i=>i.name===n)?(j(o.root,{id:S(),type:"template.deleted",entity:S(),actor:o.actor,ts:new Date().toISOString(),source:o.source,data:{name:n}}),{ok:!0,exitCode:0,warnings:r,message:`Template "${n}" deleted.`}):y(1,"template_not_found",`No template "${n}".
211
- kadence template list`,{received:n,hint:"kadence template list --json"})}function un(e,t,n){let o=w(e,t);if(!v(o))return{error:o};let{state:s}=x(o.root,o.actor),r=s.templates.find(i=>i.name===n);if(r===void 0){let i=s.templates.map(d=>d.name);return{error:y(1,"template_not_found",`No template "${n}".`+(i.length>0?`
287
+ kadence board export --md`,{hint:"kadence board export --md"});let c=Yn($r(l,"utf8"),He(s));return wr(l,c,"utf8"),{ok:!0,exitCode:0,warnings:o,message:`Board section updated in ${l}.
288
+ It is a snapshot: rerun this after the board changes.`,data:{schema:"kadence/v1",ok:!0,format:"md",path:l,section:!0,bytes:Buffer.byteLength(c)}}}let i=t.html===!0?Un(s,Ar(r.root,s)):He(s),a=we(r.root,t.file,t.html===!0?Sr:Cr,i,"kadence board export --html --file docs/board.html");if("exitCode"in a)return a;let d=a.path;return{ok:!0,exitCode:0,warnings:o,message:`Wrote ${d}.
289
+ `+(t.html===!0?"Open it from disk \u2014 there is no server, and the page makes no requests.":"A snapshot for a README or a pull request."),data:{schema:"kadence/v1",ok:!0,format:t.html===!0?"html":"md",path:d,section:!1,bytes:a.bytes}}}function Ar(e,n){let t=n.sprints.find(r=>r.status==="active");return t===void 0?null:Et(n,Ge(e).events,t)}function qn(e,n){return e.includes(n)?[]:[`Work is set to start at "${n}", which is not one of the columns any more. Cycle time and actual hours will be empty until it is:
290
+ kadence board config --started ${e[1]??e[0]??"doing"}`]}function Ye(e,n){let t=e.trim().toLowerCase().replace(/\s+/g,"_");return t===O||t===M?w(2,"invalid_argument",`Work cannot start at "${t}" \u2014 that is where it ends. Cycle time would always be zero.`,{received:e,allowed:n.filter(r=>r!==O&&r!==M)}):n.includes(t)?t:w(2,"unknown_status",`"${e}" is not one of this board's columns.
291
+ Available: ${n.join(", ")}`,{received:e,allowed:n,hint:"kadence board config --json"})}var jr=["description","type","priority","estimate","labels","assignee"];function Zn(e,n,t,r){let s=S(e,n);if(!C(s))return s;let o=t.trim();if(o.length===0)return w(2,"invalid_argument","A template needs a name.",{hint:"kadence template list --json"});let i={};for(let a of jr)r[a]!==void 0&&(i[a]=r[a]);return Object.keys(i).length===0?w(2,"invalid_argument",`A template needs at least one field.
292
+ kadence template save bug --type bug --priority high --label triage`,{received:t}):(R(s.root,{id:T(),type:"template.saved",entity:T(),actor:s.actor,ts:new Date().toISOString(),source:s.source,data:{name:o,fields:i}}),{ok:!0,exitCode:0,message:`Template "${o}" saved: ${Object.keys(i).join(", ")}.
293
+ kadence task add "title" --template ${o}`,data:{schema:"kadence/v1",ok:!0,template:{name:o,fields:i}}})}function Qn(e,n){let t=S(e,n);if(!C(t))return t;let{state:r,warnings:s}=A(t.root,t.actor);return r.templates.length===0?{ok:!0,exitCode:0,warnings:s,message:`No templates yet.
294
+ kadence template save bug --type bug --priority high`,data:{schema:"kadence/v1",ok:!0,templates:[]}}:{ok:!0,exitCode:0,warnings:s,message:r.templates.map(o=>{let i=Object.entries(o.fields).map(([a,d])=>`${a}=${Array.isArray(d)?d.join("/"):String(d)}`).join(" ");return` ${o.name.padEnd(14)} ${i}`}).join(`
295
+ `),data:{schema:"kadence/v1",ok:!0,templates:r.templates}}}function Xn(e,n,t){let r=S(e,n);if(!C(r))return r;let{state:s,warnings:o}=A(r.root,r.actor);return s.templates.some(i=>i.name===t)?(R(r.root,{id:T(),type:"template.deleted",entity:T(),actor:r.actor,ts:new Date().toISOString(),source:r.source,data:{name:t}}),{ok:!0,exitCode:0,warnings:o,message:`Template "${t}" deleted.`}):w(1,"template_not_found",`No template "${t}".
296
+ kadence template list`,{received:t,hint:"kadence template list --json"})}function es(e,n,t){let r=S(e,n);if(!C(r))return{error:r};let{state:s}=A(r.root,r.actor),o=s.templates.find(i=>i.name===t);if(o===void 0){let i=s.templates.map(a=>a.name);return{error:w(1,"template_not_found",`No template "${t}".`+(i.length>0?`
212
297
  Available: ${i.join(", ")}`:`
213
- kadence template save ...`),{received:n,...i.length>0?{allowed:i}:{}})}}return{fields:r.fields}}function ye(e,t){let n=Buffer.from(t,"utf8"),o=0;for(;o<n.length;)try{o+=Es(e,n,o,n.length-o)}catch(s){if(s.code!=="EAGAIN")throw s}}var A=wt("kadence");function u(e,t){for(let n of e.warnings??[])ye(2,`${n}
214
- `);if(t){let n=e.data??{schema:"kadence/v1",ok:e.ok,...e.ok?{}:{error:e.error??{message:e.message}}};ye(1,`${JSON.stringify(n)}
215
- `)}else ye(e.ok?1:2,`${e.message}
216
- `);process.exit(e.exitCode)}function mn(e,t,n,o){if(e!==void 0)return e;ot(process.env,process.stdout.isTTY===!0)||u(b(`No terminal available for an editor.
298
+ kadence template save ...`),{received:t,...i.length>0?{allowed:i}:{}})}}return{fields:o.fields}}function Se(e){return Array.isArray(e)?e.at(-1)??"":e}function Tr(e){return Array.isArray(e)?e.join("; "):e}function qe(e,n){let t=Buffer.from(n,"utf8"),r=0;for(;r<t.length;)try{r+=Dr(e,t,r,t.length-r)}catch(s){if(s.code!=="EAGAIN")throw s}}var D=Gt("kadence");function h(e,n){for(let t of e.warnings??[])qe(2,`${t}
299
+ `);if(n){let t=e.data??{schema:"kadence/v1",ok:e.ok,...e.ok?{}:{error:e.error??{message:e.message}}};qe(1,`${JSON.stringify(t)}
300
+ `)}else qe(e.ok?1:2,`${e.message}
301
+ `);process.exit(e.exitCode)}function ts(e,n,t,r){if(e!==void 0)return e;Ut(process.env,process.stdout.isTTY===!0)||h(x(`No terminal available for an editor.
217
302
  Pass the text directly:
218
- --description "..."`),o);let s=st(process.env,t,n);return s.error!==null&&u({ok:!1,exitCode:1,message:s.error},o),s.text===null&&u({ok:!0,exitCode:0,message:"Aborted \u2014 nothing changed."},o),s.text}function G(e,t=process.argv){let n=`--${e}`;for(let o=0;o<t.length;o++){let s=t[o];if(s===n)return t[o+1];if(s.startsWith(`${n}=`))return s.slice(n.length+1)}}var Rs=["add","list","show","edit","move","assign","comment","log","parent","block","unblock","claim","release","ac","cancel","delete"],Ns=["create","add","edit","start","close","status","list","burndown"],Os=["save","list","delete"],Ms=["create","add","list","close"];function b(e,t={}){return y(2,"invalid_argument",e,t)}function _s(e){let t=e.commands,n=e.errors;return`kadence/v1 \u2014 ${t.length} commands, ${n.length} error codes.
303
+ --description "..."`),r);let s=Kt(process.env,n,t);return s.error!==null&&h({ok:!1,exitCode:1,message:s.error},r),s.text===null&&h({ok:!0,exitCode:0,message:"Aborted \u2014 nothing changed."},r),s.text}function Ce(e,n=process.argv){let t=`--${e}`;for(let r=0;r<n.length;r++){let s=n[r];if(s===t)return n[r+1];if(s.startsWith(`${t}=`))return s.slice(t.length+1)}}var Rr=["add","list","show","edit","move","assign","comment","log","parent","block","unblock","claim","release","ac","doc","cancel","delete"],Er=["create","add","edit","start","close","status","list","burndown"],Nr=["save","list","delete"],Or=["create","add","list","close"],Mr=["add","list","show"];function x(e,n={}){return w(2,"invalid_argument",e,n)}function _r(e){let n=e.commands,t=e.errors;return`kadence/v1 \u2014 ${n.length} commands, ${t.length} error codes.
219
304
  ${e.stability}
220
305
 
221
306
  The machine-readable form is what agents read:
222
- kadence schema --json`}A.command("milestone [action] [arg]","Milestones: create | add | list | close \u2014 grouping by outcome").option("--due <date>","Target date, YYYY-MM-DD").option("--milestone <ref>","Which milestone, by MS-N or name").option("--all","Include closed milestones, hidden by default").option("--json","Machine-readable output for agents").example(' kadence milestone create "1.0" --due 2026-12-01').example(" kadence milestone add KAD-1 --milestone 1.0").example(" kadence milestone list --json").example(" kadence milestone close 1.0").action((e,t,n)=>{let o=n.json===!0,s=process.cwd();switch(e){case"create":t===void 0&&u(b(`A milestone needs a name:
223
- kadence milestone create "1.0"`),o),u(Wt(s,process.env,t,n.due===void 0?{}:{due:G("due")??String(n.due)}),o);break;case"add":(t===void 0||n.milestone===void 0)&&u(b(`A task and a milestone are required:
224
- kadence milestone add KAD-1 --milestone 1.0`),o),u(Ft(s,process.env,t,G("milestone")??String(n.milestone)),o);break;case"close":t===void 0&&u(b(`Which milestone?
225
- kadence milestone close 1.0`),o),u(Ut(s,process.env,t),o);break;case"list":case void 0:u(Yt(s,process.env,{...n.all===!0?{all:!0}:{},json:o}),o);break;default:u(b(`Unknown milestone action "${e}".`,{received:e,allowed:Ms}),o)}});A.command("note [text]","Record something learned; `note list` reads them back").option("--task <ref>","The task it came out of").option("--limit <n>","At most this many, newest first").option("--json","Machine-readable output for agents").example(' kadence note "Tests need a git identity"').example(' kadence note "The redirect drops the cookie" --task KAD-1').example(" kadence note list --limit 5").action((e,t)=>{let n=t.json===!0,o=process.cwd(),s=t.limit===void 0?void 0:Number(t.limit);if(s!==void 0&&(!Number.isFinite(s)||s<1)&&u(b(`--limit must be a positive number, got "${t.limit}".`),n),e==="list"){u(Bt(o,process.env,{...t.task===void 0?{}:{task:t.task},...s===void 0?{}:{limit:s},json:n}),n);return}e===void 0&&u(b(`A note needs text:
307
+ kadence schema --json`}D.command("milestone [action] [arg]","Milestones: create | add | list | close \u2014 grouping by outcome").option("--due <date>","Target date, YYYY-MM-DD").option("--milestone <ref>","Which milestone, by MS-N or name").option("--all","Include closed milestones, hidden by default").option("--json","Machine-readable output for agents").example(' kadence milestone create "1.0" --due 2026-12-01').example(" kadence milestone add KAD-1 --milestone 1.0").example(" kadence milestone list --json").example(" kadence milestone close 1.0").action((e,n,t)=>{let r=t.json===!0,s=process.cwd();switch(e){case"create":n===void 0&&h(x(`A milestone needs a name:
308
+ kadence milestone create "1.0"`),r),h(Nn(s,process.env,n,t.due===void 0?{}:{due:Ce("due")??String(t.due)}),r);break;case"add":(n===void 0||t.milestone===void 0)&&h(x(`A task and a milestone are required:
309
+ kadence milestone add KAD-1 --milestone 1.0`),r),h(On(s,process.env,n,Ce("milestone")??String(t.milestone)),r);break;case"close":n===void 0&&h(x(`Which milestone?
310
+ kadence milestone close 1.0`),r),h(Mn(s,process.env,n),r);break;case"list":case void 0:h(_n(s,process.env,{...t.all===!0?{all:!0}:{},json:r}),r);break;default:h(x(`Unknown milestone action "${e}".`,{received:e,allowed:Or}),r)}});D.command("note [text]","Record something learned; `note list` reads them back").option("--task <ref>","The task it came out of").option("--limit <n>","At most this many, newest first").option("--json","Machine-readable output for agents").example(' kadence note "Tests need a git identity"').example(' kadence note "The redirect drops the cookie" --task KAD-1').example(" kadence note list --limit 5").action((e,n)=>{let t=n.json===!0,r=process.cwd(),s=n.limit===void 0?void 0:Number(n.limit);if(s!==void 0&&(!Number.isFinite(s)||s<1)&&h(x(`--limit must be a positive number, got "${n.limit}".`),t),e==="list"){h(Rn(r,process.env,{...n.task===void 0?{}:{task:n.task},...s===void 0?{}:{limit:s},json:t}),t);return}e===void 0&&h(x(`A note needs text:
226
311
  kadence note "Tests need a git identity"
227
- kadence note list`),n),u(It(o,process.env,e,t.task===void 0?{}:{task:t.task}),n)});A.command("decision [action] [arg]","Decisions: add | list | show \u2014 the why behind the work").option("--why <text>","Why this was chosen. Required \u2014 without it this is a changelog line").option("--rejected <text>","The alternative that was turned down").option("--task <ref>","The task this decision came out of").option("--supersedes <ref>","The decision this one replaces").option("--doc <path>","A document that carries the detail; repeat for several").option("--all","Include superseded decisions, hidden by default").option("--json","Machine-readable output for agents").example(' kadence decision add "Use ULIDs" --why "Clocks disagree between machines"').example(' kadence decision add "Use Avro" --why "..." --supersedes DEC-1').example(" kadence decision list --json").action((e,t,n)=>{let o=n.json===!0,s=process.cwd(),r=n.doc===void 0?void 0:Array.isArray(n.doc)?n.doc:[n.doc];switch(e){case"add":t===void 0&&u(b(`A title is required:
228
- kadence decision add "Use ULIDs" --why "..."`),o),u(qt(s,process.env,t,{...n.why!==void 0?{why:n.why}:{},...n.rejected!==void 0?{rejected:n.rejected}:{},...n.task!==void 0?{task:n.task}:{},...n.supersedes!==void 0?{supersedes:n.supersedes}:{},...r!==void 0?{docs:r}:{}}),o);break;case void 0:case"list":u(Ht(s,process.env,{...n.all===!0?{all:!0}:{},...n.task!==void 0?{task:n.task}:{}}),o);break;case"show":t===void 0&&u(b(`Which decision?
229
- kadence decision show DEC-1`),o),u(Vt(s,process.env,t),o);break;default:u(b(`Unknown action "${e}".
230
- Available: add, list, show`),o)}});A.command("schema","The machine-readable --json contract, for agents").option("--json","Machine-readable output for agents").example(" kadence schema --json").action(e=>{let t=e.json===!0,n=De("0.4.1");u({ok:!0,exitCode:0,message:_s(n),data:{schema:"kadence/v1",ok:!0,contract:n}},t)});A.command("prime","Everything a session needs before it starts. Short by design").option("--json","Machine-readable output for agents").example(" kadence prime").example(" kadence prime --json").action(e=>{u(Dt(process.cwd(),process.env,{json:e.json===!0}),e.json===!0)});A.command("ready","What can be started right now: open, unblocked, unclaimed").option("-a, --assignee <who>",'Only this person; "me" for yourself').option("--limit <n>","At most this many tasks").option("--json","Machine-readable output for agents").example(" kadence ready").example(" kadence ready --assignee me --json").action(e=>{let t=e.limit===void 0?void 0:Number(e.limit);t!==void 0&&(!Number.isFinite(t)||t<1)&&u(b(`--limit must be a positive number, got "${e.limit}".`),e.json===!0),u(Ct(process.cwd(),process.env,{...e.assignee===void 0?{}:{assignee:e.assignee},...t===void 0?{}:{limit:t},json:e.json===!0}),e.json===!0)});A.command("stats","Where the project stands: counts, blockers, contested claims, velocity").option("--json","Machine-readable output for agents").example(" kadence stats").action(e=>{u(Et(process.cwd(),process.env,{json:e.json===!0}),e.json===!0)});A.command("report [name]",`Reports folded from the journal: ${H.join(" | ")}`).option("--since <days>","Window ending today, in calendar days (default 30d)").option("--json","Machine-readable output for agents").example(" kadence report flow cycle time, throughput, aging work").example(" kadence report flow --since 90d").example(" kadence report cfd tasks per column, per day").example(" kadence report attention work in flight that nobody is moving").action((e,t)=>{u(Mt(process.cwd(),process.env,e,{...t.since===void 0?{}:{since:G("since")??String(t.since)},json:t.json===!0}),t.json===!0)});A.command("compact","Fold old months into one file each; cold start on a long journal drops from ~200 ms to ~20 ms").option("--keep-months <n>","Months to keep as separate files, counting this one (default 2)").option("--dry-run","Say what would be archived and write nothing").option("--json","Machine-readable output for agents").example(" kadence compact --dry-run").example(" kadence compact --keep-months 3").action(e=>{let t=G("keep-months"),n=e.keepMonths===void 0?void 0:Number(t??e.keepMonths);u(Rt(process.cwd(),process.env,{...n===void 0?{}:{keepMonths:n,keepMonthsRaw:t??String(e.keepMonths)},...e.dryRun===!0?{dryRun:!0}:{},json:e.json===!0}),e.json===!0)});A.command("completion [action]",'Shell completion; "install" writes it where your shell looks').option("--shell <name>",`Shell: ${L.join(" | ")}; detected from $SHELL by default`).option("--force","Overwrite a completion file kadence did not write").option("--json","Machine-readable output for agents").example(" kadence completion print the script").example(" kadence completion install --shell zsh").action((e,t)=>{let n=t.json===!0;e!==void 0&&e!=="install"&&u(b(`Unknown completion action "${e}".`,{received:e,allowed:["install"]}),n),u(Pt(process.env,{...t.shell===void 0?{}:{shell:t.shell},...e==="install"?{install:!0}:{},...t.force===!0?{force:!0}:{},isTty:process.stdout.isTTY===!0}),n)});A.command("init","Set up kadence in this repository").option("--hooks","Also add a SessionStart hook running `kadence prime` to .claude/settings.json").example(" kadence init").example(" kadence init --hooks").action(e=>{let t=St(process.cwd(),"0.4.1",{hooks:e.hooks===!0});u({ok:t.ok,message:t.message,exitCode:t.ok?0:1},!1)});A.command("task [action] [arg] [value] [extra]","Tasks: add | list | show | move | assign | ac | doc").option("--title <text>","New title (for edit)").option("-d, --description <text>","Full description; use quotes for multiple lines").option("--type <type>",`Type: ${Te.join(" | ")}`).option("--priority <level>",`Priority: ${Ee.join(" | ")}`).option("-a, --assignee <who>","Assignee, e.g. dev@example.com").option("--label <name>","Label; repeat the flag for several. On edit, the set becomes exactly this").option("--add-label <name>","Add one label, leaving the rest; repeat for several").option("--remove-label <name>","Remove one label, leaving the rest; repeat for several").option("--estimate <points>","Estimate in points, a positive number").option("--due <date>","Due date, YYYY-MM-DD; empty string clears it").option("--status <status>",`Filter by status: ${ee.join(" | ")}`).option("--search <text>","Search title, description and comments").option("--overdue","Only tasks past their due date").option("--due-before <date>","Only tasks due before YYYY-MM-DD").option("--sort <key>",`Sort by: ${Le.join(" | ")}`).option("--tree","Show parent/child structure").option("--branch","Only the work this branch introduced").option("--base <name>","What --branch compares against; main by default").option("--parent <task>",'Parent task, e.g. KAD-1 (use "none" to detach)').option("--template <name>","Pre-fill fields from a saved template").option("--no-dod","Skip the board's definition of done for this task").option("--fields <list>","JSON only: comma-separated task fields to return").option("--json","Machine-readable output for agents").example(' kadence task add "Fix login" -d "Broken since 2.3" --type bug --priority high --estimate 3').example(" kadence task list --status in_progress --sort priority").example(" kadence task list --search cookie --overdue").example(" kadence task list --assignee me --label auth").example(" kadence task list --tree").example(" kadence task list --branch what this branch is about").example(" kadence task list --branch --base release/1.0").example(" kadence task list --json --fields id,label,status").example(" kadence task move KAD-1,KAD-2,KAD-3 done bulk: all or nothing").example(' kadence task add "Login form" --parent KAD-1 KAD-1 can be an epic').example(" kadence task claim take the top of `kadence ready`").example(" kadence task claim KAD-1").example(" kadence task release KAD-1").example(' kadence task ac add KAD-1 "tests green"').example(" kadence task ac check KAD-1 1").example(" kadence task ac list KAD-1").example(" kadence task doc add KAD-1 docs/design.md create it and link it").example(" kadence task parent KAD-2 KAD-1").example(" kadence task block KAD-2 KAD-1 KAD-2 waits for KAD-1").example(" kadence task unblock KAD-2 KAD-1").example(" kadence task log KAD-1 2h also 90m, or -30m to correct").example(' kadence task add "Crash on save" --template bug').example(" kadence task show KAD-1").example(" kadence task move KAD-1 done").example(" kadence task edit KAD-1 --priority urgent --due 2026-09-30").example(" kadence task edit KAD-1 opens $EDITOR for the description").example(' kadence task comment KAD-1 "Needs review"').example(' kadence task assign KAD-1 dev@example.com (use "none" to unassign)').example(" kadence task cancel KAD-1 keeps it in history").example(" kadence task delete KAD-1 drops it from the board").action((e,t,n,o,s)=>{let r=s.json===!0,i=process.cwd();switch(e===void 0&&u(b(`Which action?
312
+ kadence note list`),t),h(Tn(r,process.env,e,n.task===void 0?{}:{task:n.task}),t)});D.command("decision [action] [arg]","Decisions: add | list | show \u2014 the why behind the work").option("--why <text>","Why this was chosen. Required \u2014 without it this is a changelog line").option("--rejected <text>","The alternative that was turned down").option("--task <ref>","The task this decision came out of").option("--supersedes <ref>","The decision this one replaces").option("--doc <path>","A document that carries the detail; repeat for several").option("--all","Include superseded decisions, hidden by default").option("--json","Machine-readable output for agents").example(' kadence decision add "Use ULIDs" --why "Clocks disagree between machines"').example(' kadence decision add "Use Avro" --why "..." --supersedes DEC-1').example(" kadence decision list --json").action((e,n,t)=>{let r=t.json===!0,s=process.cwd(),o=t.doc===void 0?void 0:Array.isArray(t.doc)?t.doc:[t.doc];switch(e){case"add":n===void 0&&h(x(`A title is required:
313
+ kadence decision add "Use ULIDs" --why "..."`),r),h(Ln(s,process.env,n,{...t.why!==void 0?{why:Se(t.why)}:{},...t.rejected!==void 0?{rejected:Tr(t.rejected)}:{},...t.task!==void 0?{task:Se(t.task)}:{},...t.supersedes!==void 0?{supersedes:Se(t.supersedes)}:{},...o!==void 0?{docs:o}:{}}),r);break;case void 0:case"list":h(Wn(s,process.env,{...t.all===!0?{all:!0}:{},...t.task!==void 0?{task:Se(t.task)}:{}}),r);break;case"show":n===void 0&&h(x(`Which decision?
314
+ kadence decision show DEC-1`),r),h(Bn(s,process.env,n),r);break;default:h(x(`Unknown action "${e}".
315
+ Available: add, list, show`,{...e===void 0?{}:{received:e},allowed:Mr}),r)}});D.command("schema","The machine-readable --json contract, for agents").option("--json","Machine-readable output for agents").example(" kadence schema --json").action(e=>{let n=e.json===!0,t=tt("0.5.0");h({ok:!0,exitCode:0,message:_r(t),data:{schema:"kadence/v1",ok:!0,contract:t}},n)});D.command("prime","Everything a session needs before it starts. Short by design").option("--json","Machine-readable output for agents").example(" kadence prime").example(" kadence prime --json").action(e=>{h(an(process.cwd(),process.env,{json:e.json===!0}),e.json===!0)});D.command("ready","What can be started right now: open, unblocked, unclaimed").option("-a, --assignee <who>",'Only this person; "me" for yourself').option("--limit <n>","At most this many tasks").option("--json","Machine-readable output for agents").example(" kadence ready").example(" kadence ready --assignee me --json").action(e=>{let n=e.limit===void 0?void 0:Number(e.limit);n!==void 0&&(!Number.isFinite(n)||n<1)&&h(x(`--limit must be a positive number, got "${e.limit}".`),e.json===!0),h(sn(process.cwd(),process.env,{...e.assignee===void 0?{}:{assignee:e.assignee},...n===void 0?{}:{limit:n},json:e.json===!0}),e.json===!0)});D.command("stats","Where the project stands: counts, blockers, contested claims, velocity").option("--json","Machine-readable output for agents").example(" kadence stats").action(e=>{h(ln(process.cwd(),process.env,{json:e.json===!0}),e.json===!0)});D.command("report [name]",`Reports folded from the journal: ${ve.join(" | ")}`).option("--list","Name every report and what each one answers").option("--since <days>","flow, cfd, attention: window ending today, in calendar days (default 30d)").option("--sprint <name>","burndown: a sprint by name, rather than the active one").option("--html","Write one self-contained page instead of printing; charts included, no network").option("--file <path>","html: where to write it (default kadence-<report>.html)").option("--json","Machine-readable output for agents").example(" kadence report --list every report, and what it answers").example(" kadence report flow cycle time, throughput, aging work").example(" kadence report flow --since 90d").example(" kadence report cfd tasks per column, per day").example(" kadence report attention work in flight that nobody is moving").example(" kadence report burndown the active sprint against an even burn").example(" kadence report velocity committed against finished, sprint by sprint").example(" kadence report workload who is carrying what right now").example(" kadence report flow --html the same numbers as a page, with charts").example(" kadence report cfd --html --file docs/cfd.html").action((e,n)=>{h(Cn(process.cwd(),process.env,e,{...n.since===void 0?{}:{since:Ce("since")??String(n.since)},...n.list===!0?{list:!0}:{},...n.sprint===void 0?{}:{sprint:String(n.sprint)},...n.html===!0?{html:!0}:{},...n.file===void 0?{}:{file:String(n.file)},json:n.json===!0}),n.json===!0)});D.command("compact","Fold old months into one file each; cold start on a long journal drops from ~200 ms to ~20 ms").option("--keep-months <n>","Months to keep as separate files, counting this one (default 2)").option("--dry-run","Say what would be archived and write nothing").option("--json","Machine-readable output for agents").example(" kadence compact --dry-run").example(" kadence compact --keep-months 3").action(e=>{let n=Ce("keep-months"),t=e.keepMonths===void 0?void 0:Number(n??e.keepMonths);h(cn(process.cwd(),process.env,{...t===void 0?{}:{keepMonths:t,keepMonthsRaw:n??String(e.keepMonths)},...e.dryRun===!0?{dryRun:!0}:{},json:e.json===!0}),e.json===!0)});D.command("completion [action]",'Shell completion; "install" writes it where your shell looks').option("--shell <name>",`Shell: ${se.join(" | ")}; detected from $SHELL by default`).option("--force","Overwrite a completion file kadence did not write").option("--json","Machine-readable output for agents").example(" kadence completion print the script").example(" kadence completion install --shell zsh").action((e,n)=>{let t=n.json===!0;e!==void 0&&e!=="install"&&h(x(`Unknown completion action "${e}".`,{received:e,allowed:["install"]}),t),h(jn(process.env,{...n.shell===void 0?{}:{shell:n.shell},...e==="install"?{install:!0}:{},...n.force===!0?{force:!0}:{},isTty:process.stdout.isTTY===!0}),t)});D.command("init","Set up kadence in this repository").option("--hooks","Also add a SessionStart hook running `kadence prime` to .claude/settings.json").example(" kadence init").example(" kadence init --hooks").action(e=>{let n=tn(process.cwd(),"0.5.0",{hooks:e.hooks===!0});h({ok:n.ok,message:n.message,exitCode:n.ok?0:1},!1)});D.command("task [action] [arg] [value] [extra]","Tasks: add | list | show | move | assign | ac | doc").option("--title <text>","New title (for edit)").option("-d, --description <text>","Full description; use quotes for multiple lines").option("--type <type>",`Type: ${nt.join(" | ")}`).option("--priority <level>",`Priority: ${st.join(" | ")}`).option("-a, --assignee <who>","Assignee, e.g. dev@example.com").option("--label <name>","Label; repeat the flag for several. On edit, the set becomes exactly this").option("--add-label <name>","Add one label, leaving the rest; repeat for several").option("--remove-label <name>","Remove one label, leaving the rest; repeat for several").option("--estimate <points>","Estimate in points, a positive number").option("--due <date>","Due date, YYYY-MM-DD; empty string clears it").option("--status <status>",`Filter by status: ${je.join(" | ")}`).option("--search <text>","Search title, description and comments").option("--overdue","Only tasks past their due date").option("--due-before <date>","Only tasks due before YYYY-MM-DD").option("--sort <key>",`Sort by: ${ct.join(" | ")}`).option("--tree","Show parent/child structure").option("--branch","Only the work this branch introduced").option("--base <name>","What --branch compares against; main by default").option("--parent <task>",'Parent task, e.g. KAD-1 (use "none" to detach)').option("--template <name>","Pre-fill fields from a saved template").option("--no-dod","Skip the board's definition of done for this task").option("--fields <list>","JSON only: comma-separated task fields to return").option("--json","Machine-readable output for agents").example(' kadence task add "Fix login" -d "Broken since 2.3" --type bug --priority high --estimate 3').example(" kadence task list --status in_progress --sort priority").example(" kadence task list --search cookie --overdue").example(" kadence task list --assignee me --label auth").example(" kadence task list --tree").example(" kadence task list --branch what this branch is about").example(" kadence task list --branch --base release/1.0").example(" kadence task list --json --fields id,label,status").example(" kadence task move KAD-1,KAD-2,KAD-3 done bulk: all or nothing").example(' kadence task add "Login form" --parent KAD-1 KAD-1 can be an epic').example(" kadence task claim take the top of `kadence ready`").example(" kadence task claim KAD-1").example(" kadence task release KAD-1").example(' kadence task ac add KAD-1 "tests green"').example(" kadence task ac check KAD-1 1").example(" kadence task ac list KAD-1").example(" kadence task doc add KAD-1 docs/design.md create it and link it").example(" kadence task parent KAD-2 KAD-1").example(" kadence task block KAD-2 KAD-1 KAD-2 waits for KAD-1").example(" kadence task unblock KAD-2 KAD-1").example(" kadence task log KAD-1 2h also 90m, or -30m to correct").example(' kadence task add "Crash on save" --template bug').example(" kadence task show KAD-1").example(" kadence task move KAD-1 done").example(" kadence task edit KAD-1 --priority urgent --due 2026-09-30").example(" kadence task edit KAD-1 opens $EDITOR for the description").example(' kadence task comment KAD-1 "Needs review"').example(' kadence task assign KAD-1 dev@example.com (use "none" to unassign)').example(" kadence task cancel KAD-1 keeps it in history").example(" kadence task delete KAD-1 drops it from the board").action((e,n,t,r,s)=>{let o=s.json===!0,i=process.cwd();switch(e===void 0&&h(x(`Which action?
231
316
  kadence task add "Fix login"
232
317
  kadence task list
233
318
  kadence task show KAD-1
@@ -236,53 +321,53 @@ Available: add, list, show`),o)}});A.command("schema","The machine-readable --js
236
321
  kadence task assign KAD-1 dev@example.com
237
322
  kadence task comment KAD-1 "text"
238
323
  kadence task cancel KAD-1
239
- kadence task delete KAD-1`),r),e){case"add":{t===void 0&&u(b(`A title is required:
240
- kadence task add "Fix login"`),r);let d=s.estimate===void 0?void 0:Number(s.estimate);d!==void 0&&(!Number.isFinite(d)||d<0)&&u(b(`Estimate must be a positive number, got "${s.estimate}".
241
- kadence task add "Fix login" --estimate 3`),r);let a={};if(s.template!==void 0){let l=un(i,process.env,s.template);"error"in l?u(l.error,r):a=l.fields}let c=s.label===void 0?void 0:Array.isArray(s.label)?s.label:[s.label];u(Ie(i,process.env,t,{...a,...s.description!==void 0?{description:s.description}:{},...s.type!==void 0?{type:s.type}:{},...s.priority!==void 0?{priority:s.priority}:{},...s.assignee!==void 0?{assignee:s.assignee}:{},...c!==void 0?{labels:c}:{},...s.due!==void 0?{due:s.due}:{},...s.parent!==void 0?{parent:s.parent}:{},...d!==void 0?{estimate:d}:{},...s.dod===!1?{noDod:!0}:{}}),r);break}case"doc":{let d=t==="add",a=d?n:t,c=d?o:n;(a===void 0||c===void 0)&&u(b(`A task and a path are required:
324
+ kadence task delete KAD-1`),o),e){case"add":{n===void 0&&h(x(`A title is required:
325
+ kadence task add "Fix login"`),o);let a=s.estimate===void 0?void 0:Number(s.estimate);a!==void 0&&(!Number.isFinite(a)||a<0)&&h(x(`Estimate must be a positive number, got "${s.estimate}".
326
+ kadence task add "Fix login" --estimate 3`),o);let d={};if(s.template!==void 0){let c=es(i,process.env,s.template);"error"in c?h(c.error,o):d=c.fields}let l=s.label===void 0?void 0:Array.isArray(s.label)?s.label:[s.label];h(ut(i,process.env,n,{...d,...s.description!==void 0?{description:s.description}:{},...s.type!==void 0?{type:s.type}:{},...s.priority!==void 0?{priority:s.priority}:{},...s.assignee!==void 0?{assignee:s.assignee}:{},...l!==void 0?{labels:l}:{},...s.due!==void 0?{due:s.due}:{},...s.parent!==void 0?{parent:s.parent}:{},...a!==void 0?{estimate:a}:{},...s.dod===!1?{noDod:!0}:{}}),o);break}case"doc":{let a=n==="add",d=a?t:n,l=a?r:t;(d===void 0||l===void 0)&&h(x(`A task and a path are required:
242
327
  kadence task doc KAD-1 docs/design.md link an existing file
243
- kadence task doc add KAD-1 docs/design.md create it and link it`),r),u(He(i,process.env,a,c,d),r);break}case"log":(t===void 0||n===void 0)&&u(b(`A task and a duration are required:
328
+ kadence task doc add KAD-1 docs/design.md create it and link it`),o),h(wt(i,process.env,d,l,a),o);break}case"log":(n===void 0||t===void 0)&&h(x(`A task and a duration are required:
244
329
  kadence task log KAD-1 2h
245
- kadence task log KAD-1 90m`),r),u(ne(i,process.env,t,n),r);break;case"parent":(t===void 0||n===void 0)&&u(b(`A task and a parent are required:
330
+ kadence task log KAD-1 90m`),o),h(Te(i,process.env,n,t),o);break;case"parent":(n===void 0||t===void 0)&&h(x(`A task and a parent are required:
246
331
  kadence task parent KAD-2 KAD-1
247
- kadence task parent KAD-2 none to detach`),r),u(tt(i,process.env,t,n),r);break;case"ac":{if((t===void 0||n===void 0)&&u(b(`An action and a task are required:
332
+ kadence task parent KAD-2 none to detach`),o),h(Dt(i,process.env,n,t),o);break;case"ac":{if((n===void 0||t===void 0)&&h(x(`An action and a task are required:
248
333
  kadence task ac add KAD-1 "tests green"
249
334
  kadence task ac check KAD-1 1
250
335
  kadence task ac uncheck KAD-1 1
251
- kadence task ac list KAD-1`,{...t===void 0?{}:{received:t},allowed:["add","check","uncheck","list"]}),r),t==="list"){u(Xe(i,process.env,n),r);break}if(o===void 0&&u(b(t==="add"?`The criterion text is missing:
252
- kadence task ac add ${n} "tests green"`:`Which criterion?
253
- kadence task ac ${t} ${n} 1`,{received:t}),r),t==="add"){u(Ze(i,process.env,n,o),r);break}if(t==="check"||t==="uncheck"){u(Qe(i,process.env,n,o,t==="uncheck"),r);break}u(b(`Unknown criteria action "${t}".`,{received:t,allowed:["add","check","uncheck","list"]}),r);break}case"claim":u(Ve(i,process.env,t,s.assignee===void 0?{}:{assignee:s.assignee}),r);break;case"release":t===void 0&&u(b(`Which task?
254
- kadence task release KAD-1`),r),u(Ge(i,process.env,t),r);break;case"block":case"unblock":(t===void 0||n===void 0)&&u(b(`A task and a blocker are required:
336
+ kadence task ac list KAD-1`,{...n===void 0?{}:{received:n},allowed:["add","check","uncheck","list"]}),o),n==="list"){h(At(i,process.env,t),o);break}if(r===void 0&&h(x(n==="add"?`The criterion text is missing:
337
+ kadence task ac add ${t} "tests green"`:`Which criterion?
338
+ kadence task ac ${n} ${t} 1`,{received:n}),o),n==="add"){h(St(i,process.env,t,r),o);break}if(n==="check"||n==="uncheck"){h(Ct(i,process.env,t,r,n==="uncheck"),o);break}h(x(`Unknown criteria action "${n}".`,{received:n,allowed:["add","check","uncheck","list"]}),o);break}case"claim":h(vt(i,process.env,n,s.assignee===void 0?{}:{assignee:s.assignee}),o);break;case"release":n===void 0&&h(x(`Which task?
339
+ kadence task release KAD-1`),o),h(xt(i,process.env,n),o);break;case"block":case"unblock":(n===void 0||t===void 0)&&h(x(`A task and a blocker are required:
255
340
  kadence task block KAD-2 KAD-1 KAD-2 waits for KAD-1
256
- kadence task unblock KAD-2 KAD-1`),r),u(nt(i,process.env,t,n,e==="unblock"),r);break;case"edit":{t===void 0&&u(b(`Which task?
257
- kadence task edit KAD-1 --priority high`),r);let d=s.estimate===void 0?void 0:Number(s.estimate);d!==void 0&&(!Number.isFinite(d)||d<0)&&u(b(`Estimate must be a positive number, got "${s.estimate}".`),r);let a=p=>p===void 0?void 0:Array.isArray(p)?p:[p],c=a(s.label),l=a(s.addLabel),m=a(s.removeLabel),f=s.title!==void 0||s.description!==void 0||s.type!==void 0||s.priority!==void 0||s.due!==void 0||d!==void 0||c!==void 0||l!==void 0||m!==void 0||n!==void 0,h=s.description;if(!f){let p=te(i,process.env,t);p.ok||u(p,r);let k=p.data.task??{description:null};h=mn(void 0,k.description??"",`Editing the description of ${t}.`,r)}u(Ye(i,process.env,t,{...s.title!==void 0?{title:s.title}:n!==void 0?{title:n}:{},...h!==void 0?{description:h}:{},...s.type!==void 0?{type:s.type}:{},...s.priority!==void 0?{priority:s.priority}:{},...s.due!==void 0?{due:s.due}:{},...d!==void 0?{estimate:d}:{},...c!==void 0?{labels:c}:{},...l!==void 0?{addLabels:l}:{},...m!==void 0?{removeLabels:m}:{}}),r);break}case"comment":{t===void 0&&u(b(`Which task?
258
- kadence task comment KAD-1 "text"`),r);let d=mn(n,"",`Comment on ${t}.`,r);u(et(i,process.env,t,d??""),r);break}case"cancel":t===void 0&&u(b(`Which task?
259
- kadence task cancel KAD-1`),r),u(ze(i,process.env,t),r);break;case"delete":t===void 0&&u(b(`Which task?
260
- kadence task delete KAD-1`),r),u(Je(i,process.env,t),r);break;case"list":u(Be(i,process.env,{...s.status!==void 0?{status:s.status}:{},...s.search!==void 0?{search:s.search}:{},...s.type!==void 0?{type:s.type}:{},...s.priority!==void 0?{priority:s.priority}:{},...s.assignee!==void 0?{assignee:s.assignee}:{},...s.label!==void 0?{label:Array.isArray(s.label)?s.label.at(-1):s.label}:{},...s.overdue===!0?{overdue:!0}:{},...s.dueBefore!==void 0?{dueBefore:s.dueBefore}:{},...s.sort!==void 0?{sort:s.sort}:{},...s.tree===!0?{tree:!0}:{},...s.branch===!0?{branch:!0}:{},...s.base!==void 0?{base:s.base}:{},...r&&s.fields!==void 0?{fields:s.fields}:{}}),r);break;case"show":t===void 0&&u(b(`Which task?
261
- kadence task show KAD-1`),r),u(te(i,process.env,t),r);break;case"move":(t===void 0||n===void 0)&&u(b(`A task and a target status are required:
341
+ kadence task unblock KAD-2 KAD-1`),o),h(Tt(i,process.env,n,t,e==="unblock"),o);break;case"edit":{n===void 0&&h(x(`Which task?
342
+ kadence task edit KAD-1 --priority high`),o);let a=s.estimate===void 0?void 0:Number(s.estimate);a!==void 0&&(!Number.isFinite(a)||a<0)&&h(x(`Estimate must be a positive number, got "${s.estimate}".`),o);let d=f=>f===void 0?void 0:Array.isArray(f)?f:[f],l=d(s.label),c=d(s.addLabel),u=d(s.removeLabel),m=s.title!==void 0||s.description!==void 0||s.type!==void 0||s.priority!==void 0||s.due!==void 0||a!==void 0||l!==void 0||c!==void 0||u!==void 0||t!==void 0,k=s.description;if(!m){let f=De(i,process.env,n);f.ok||h(f,o);let y=f.data.task??{description:null};k=ts(void 0,y.description??"",`Editing the description of ${n}.`,o)}h(kt(i,process.env,n,{...s.title!==void 0?{title:s.title}:t!==void 0?{title:t}:{},...k!==void 0?{description:k}:{},...s.type!==void 0?{type:s.type}:{},...s.priority!==void 0?{priority:s.priority}:{},...s.due!==void 0?{due:s.due}:{},...a!==void 0?{estimate:a}:{},...l!==void 0?{labels:l}:{},...c!==void 0?{addLabels:c}:{},...u!==void 0?{removeLabels:u}:{}}),o);break}case"comment":{n===void 0&&h(x(`Which task?
343
+ kadence task comment KAD-1 "text"`),o);let a=ts(t,"",`Comment on ${n}.`,o);h(jt(i,process.env,n,a??""),o);break}case"cancel":n===void 0&&h(x(`Which task?
344
+ kadence task cancel KAD-1`),o),h(bt(i,process.env,n),o);break;case"delete":n===void 0&&h(x(`Which task?
345
+ kadence task delete KAD-1`),o),h(yt(i,process.env,n),o);break;case"list":h(mt(i,process.env,{...s.status!==void 0?{status:s.status}:{},...s.search!==void 0?{search:s.search}:{},...s.type!==void 0?{type:s.type}:{},...s.priority!==void 0?{priority:s.priority}:{},...s.assignee!==void 0?{assignee:s.assignee}:{},...s.label!==void 0?{label:Array.isArray(s.label)?s.label.at(-1):s.label}:{},...s.overdue===!0?{overdue:!0}:{},...s.dueBefore!==void 0?{dueBefore:s.dueBefore}:{},...s.sort!==void 0?{sort:s.sort}:{},...s.tree===!0?{tree:!0}:{},...s.branch===!0?{branch:!0}:{},...s.base!==void 0?{base:s.base}:{},...o&&s.fields!==void 0?{fields:s.fields}:{}}),o);break;case"show":n===void 0&&h(x(`Which task?
346
+ kadence task show KAD-1`),o),h(De(i,process.env,n),o);break;case"move":(n===void 0||t===void 0)&&h(x(`A task and a target status are required:
262
347
  kadence task move KAD-1 done
263
- Statuses: ${ee.join(", ")}`),r),u(Ke(i,process.env,t,n),r);break;case"assign":(t===void 0||n===void 0)&&u(b(`A task and an assignee are required:
348
+ Statuses: ${je.join(", ")}`),o),h(pt(i,process.env,n,t),o);break;case"assign":(n===void 0||t===void 0)&&h(x(`A task and an assignee are required:
264
349
  kadence task assign KAD-1 dev@example.com
265
- kadence task assign KAD-1 none to unassign`),r),u(Ue(i,process.env,t,n),r);break;default:u(b(`Unknown action "${e}".
350
+ kadence task assign KAD-1 none to unassign`),o),h(gt(i,process.env,n,t),o);break;default:h(x(`Unknown action "${e}".
266
351
  Available: add, list, show, edit, move, assign, comment, log,
267
352
  parent, block, unblock, cancel, delete
268
- kadence task --help`,{received:e,allowed:Rs}),r)}});A.command("board [action]",'Kanban board in the terminal; "config" edits it, "export" writes a snapshot').option("--fields <list>","JSON only: comma-separated task fields to return").option("--statuses <list>",'Comma-separated columns, e.g. "todo,doing,done"').option("--dod <list>",'Criteria every new task starts with, e.g. "tests green,docs updated"').option("--started <status>","The column where work counts as started; cycle time is measured from it").option("--summary","JSON only: column state without history or comments").option("--html","export: one self-contained HTML file, no server and no network").option("--md","export: markdown for a README or a pull request").option("--readme","export: update the section between markers in README.md").option("--file <path>","export: where to write it").option("-a, --assignee <who>",`Only this person's tasks; "me" means you`).option("--sprint","Only tasks in the active sprint").option("--json","Machine-readable output for agents").example(" kadence board").example(" kadence board --assignee me --sprint").example(" kadence board --json --fields label,status,assignee").example(" kadence board --json --summary the state, without the history").example(" kadence board config").example(' kadence board config --statuses "todo,doing,review,done"').example(' kadence board config --dod "tests green,docs updated"').example(" kadence board config --started doing where cycle time starts counting").example(" kadence board export --html").example(" kadence board export --md --readme").action((e,t)=>{if(e==="export"){u(an(process.cwd(),process.env,{...t.html===!0?{html:!0}:{},...t.md===!0?{md:!0}:{},...t.readme===!0?{readme:!0}:{},...t.file===void 0?{}:{file:t.file}}),t.json===!0);return}e==="config"&&u(rn(process.cwd(),process.env,t.statuses,t.dod,t.started),t.json===!0),e!==void 0&&u(b(`Unknown action "${e}".
353
+ kadence task --help`,{received:e,allowed:Rr}),o)}});D.command("board [action]",'Kanban board in the terminal; "config" edits it, "export" writes a snapshot').option("--fields <list>","JSON only: comma-separated task fields to return").option("--statuses <list>",'Comma-separated columns, e.g. "todo,doing,done"').option("--dod <list>",'Criteria every new task starts with, e.g. "tests green,docs updated"').option("--started <status>","The column where work counts as started; cycle time is measured from it").option("--summary","JSON only: column state without history or comments").option("--html","export: one self-contained HTML file, no server and no network").option("--md","export: markdown for a README or a pull request").option("--readme","export: update the section between markers in README.md").option("--file <path>","export: where to write it").option("-a, --assignee <who>",`Only this person's tasks; "me" means you`).option("--sprint","Only tasks in the active sprint").option("--json","Machine-readable output for agents").example(" kadence board").example(" kadence board --assignee me --sprint").example(" kadence board --json --fields label,status,assignee").example(" kadence board --json --summary the state, without the history").example(" kadence board config").example(' kadence board config --statuses "todo,doing,review,done"').example(' kadence board config --dod "tests green,docs updated"').example(" kadence board config --started doing where cycle time starts counting").example(" kadence board export --html").example(" kadence board export --md --readme").action((e,n)=>{if(e==="export"){h(Gn(process.cwd(),process.env,{...n.html===!0?{html:!0}:{},...n.md===!0?{md:!0}:{},...n.readme===!0?{readme:!0}:{},...n.file===void 0?{}:{file:n.file}}),n.json===!0);return}e==="config"&&h(Vn(process.cwd(),process.env,n.statuses,n.dod,n.started),n.json===!0),e!==void 0&&h(x(`Unknown action "${e}".
269
354
  Available: config, export
270
- kadence board --help`,{received:e,allowed:["config","export"]}),t.json===!0),u(on(process.cwd(),process.env,{...t.assignee!==void 0?{assignee:t.assignee}:{},...t.sprint===!0?{sprint:"active"}:{}},t.json===!0?t.fields:void 0,t.json===!0&&t.summary===!0),t.json===!0)});A.command("sprint [action] [name]","Sprints: create | add | edit | start | close | status | list | burndown").option("--sprint <name>","Which sprint to add to; defaults to the active one").option("--name <name>","New name (for edit)").option("-d, --description <text>","Sprint description (for edit)").option("--start <date>","Start date, YYYY-MM-DD").option("--end <date>","End date, YYYY-MM-DD").option("--json","Machine-readable output for agents").example(' kadence sprint create "Sprint 1" first one starts right away').example(' kadence sprint create "Sprint 2" later ones are planned').example(' kadence sprint add KAD-1 --sprint "Sprint 2"').example(" kadence sprint start starts the next planned sprint").example(" kadence sprint edit --start 2026-09-01 --end 2026-09-14").example(' kadence sprint edit "Sprint 2" --name "Sprint 2: auth"').example(" kadence sprint burndown chart from the journal, any day").example(" kadence sprint close closes the active one, reports velocity").action((e,t,n)=>{let o=n.json===!0,s=process.cwd();switch(e===void 0&&u(b(`Which action?
355
+ kadence board --help`,{received:e,allowed:["config","export"]}),n.json===!0),h(Jn(process.cwd(),process.env,{...n.assignee!==void 0?{assignee:n.assignee}:{},...n.sprint===!0?{sprint:"active"}:{}},n.json===!0?n.fields:void 0,n.json===!0&&n.summary===!0),n.json===!0)});D.command("sprint [action] [name]","Sprints: create | add | edit | start | close | status | list | burndown").option("--sprint <name>","Which sprint to add to; defaults to the active one").option("--name <name>","New name (for edit)").option("-d, --description <text>","Sprint description (for edit)").option("--start <date>","Start date, YYYY-MM-DD").option("--end <date>","End date, YYYY-MM-DD").option("--json","Machine-readable output for agents").example(' kadence sprint create "Sprint 1" first one starts right away').example(' kadence sprint create "Sprint 2" later ones are planned').example(' kadence sprint add KAD-1 --sprint "Sprint 2"').example(" kadence sprint start starts the next planned sprint").example(" kadence sprint edit --start 2026-09-01 --end 2026-09-14").example(' kadence sprint edit "Sprint 2" --name "Sprint 2: auth"').example(" kadence sprint burndown chart from the journal, any day").example(" kadence sprint close closes the active one, reports velocity").action((e,n,t)=>{let r=t.json===!0,s=process.cwd();switch(e===void 0&&h(x(`Which action?
271
356
  kadence sprint create "Sprint 1"
272
357
  kadence sprint add KAD-1
273
358
  kadence sprint edit --start 2026-09-01
274
359
  kadence sprint start
275
360
  kadence sprint close
276
361
  kadence sprint status
277
- kadence sprint list`),o),e){case"create":t===void 0&&u(b(`A sprint name is required:
278
- kadence sprint create "Sprint 1"`),o),u(it(s,process.env,t),o);break;case"add":t===void 0&&u(b(`Which task?
362
+ kadence sprint list`),r),e){case"create":n===void 0&&h(x(`A sprint name is required:
363
+ kadence sprint create "Sprint 1"`),r),h(Ot(s,process.env,n),r);break;case"add":n===void 0&&h(x(`Which task?
279
364
  kadence sprint add KAD-1
280
- kadence sprint add KAD-1 --sprint "Sprint 2"`),o),u(at(s,process.env,t,n.sprint===void 0?{}:{sprint:n.sprint}),o);break;case"edit":u(mt(s,process.env,t,{...n.name!==void 0?{name:n.name}:{},...n.description!==void 0?{description:n.description}:{},...n.start!==void 0?{startDate:n.start}:{},...n.end!==void 0?{endDate:n.end}:{}}),o);break;case"start":u(lt(s,process.env,t),o);break;case"close":u(dt(s,process.env),o);break;case"status":u(ct(s,process.env),o);break;case"list":u(ut(s,process.env),o);break;case"burndown":u(ft(s,process.env,t),o);break;default:u(b(`Unknown action "${e}".
365
+ kadence sprint add KAD-1 --sprint "Sprint 2"`),r),h(Mt(s,process.env,n,t.sprint===void 0?{}:{sprint:t.sprint}),r);break;case"edit":h(Wt(s,process.env,n,{...t.name!==void 0?{name:t.name}:{},...t.description!==void 0?{description:t.description}:{},...t.start!==void 0?{startDate:t.start}:{},...t.end!==void 0?{endDate:t.end}:{}}),r);break;case"start":h(It(s,process.env,n),r);break;case"close":h(_t(s,process.env),r);break;case"status":h(Pt(s,process.env),r);break;case"list":h(Lt(s,process.env),r);break;case"burndown":h(Ft(s,process.env,n),r);break;default:h(x(`Unknown action "${e}".
281
366
  Available: create, add, edit, start, close, status, list, burndown
282
- kadence sprint --help`,{received:e,allowed:Ns}),o)}});A.command("template [action] [name]","Task templates: save | list | delete").option("-d, --description <text>","Default description").option("--type <type>","Default type").option("--priority <level>","Default priority").option("-a, --assignee <who>","Default assignee").option("--label <name>","Default label; repeat for several").option("--estimate <points>","Default estimate").option("--json","Machine-readable output for agents").example(" kadence template save bug --type bug --priority high --label triage").example(" kadence template list").action((e,t,n)=>{let o=n.json===!0,s=process.cwd();switch(e){case"save":{t===void 0&&u(b(`A template name is required:
283
- kadence template save bug --type bug`),o);let r=n.label===void 0?void 0:Array.isArray(n.label)?n.label:[n.label];u(dn(s,process.env,t,{...n.description!==void 0?{description:n.description}:{},...n.type!==void 0?{type:n.type}:{},...n.priority!==void 0?{priority:n.priority}:{},...n.assignee!==void 0?{assignee:n.assignee}:{},...r!==void 0?{labels:r}:{},...n.estimate!==void 0?{estimate:Number(n.estimate)}:{}}),o);break}case"list":case void 0:u(cn(s,process.env),o);break;case"delete":t===void 0&&u(b(`Which template?
284
- kadence template delete bug`),o),u(ln(s,process.env,t),o);break;default:u(b(`Unknown action "${e}".
285
- Available: save, list, delete`,{received:e,allowed:Os}),o)}});A.command("ui","Interactive kanban board").alias("board:ui").example(" kadence ui").action(async()=>{let{runUi:e}=await import("./chunks/ui-BZTPZE22.js"),t=await e(process.cwd(),process.env);t.ok||u(t,!1)});A.help();A.version("0.4.1");var _=process.argv;if(_[2]==="task"&&_[3]==="log"&&_[4]!==void 0&&_[5]!==void 0){let e=ne(process.cwd(),process.env,_[4],_[5]),t=_.includes("--json");u(e,t)}var fn=process.argv.findIndex((e,t)=>e.startsWith("-")&&/^-\d+(\.\d+)?$/.test(e)&&process.argv[t-1]==="--estimate");fn!==-1&&(process.stderr.write(`Estimate must be a positive number, got "${process.argv[fn]}".
367
+ kadence sprint --help`,{received:e,allowed:Er}),r)}});D.command("template [action] [name]","Task templates: save | list | delete").option("-d, --description <text>","Default description").option("--type <type>","Default type").option("--priority <level>","Default priority").option("-a, --assignee <who>","Default assignee").option("--label <name>","Default label; repeat for several").option("--estimate <points>","Default estimate").option("--json","Machine-readable output for agents").example(" kadence template save bug --type bug --priority high --label triage").example(" kadence template list").action((e,n,t)=>{let r=t.json===!0,s=process.cwd();switch(e){case"save":{n===void 0&&h(x(`A template name is required:
368
+ kadence template save bug --type bug`),r);let o=t.label===void 0?void 0:Array.isArray(t.label)?t.label:[t.label];h(Zn(s,process.env,n,{...t.description!==void 0?{description:t.description}:{},...t.type!==void 0?{type:t.type}:{},...t.priority!==void 0?{priority:t.priority}:{},...t.assignee!==void 0?{assignee:t.assignee}:{},...o!==void 0?{labels:o}:{},...t.estimate!==void 0?{estimate:Number(t.estimate)}:{}}),r);break}case"list":case void 0:h(Qn(s,process.env),r);break;case"delete":n===void 0&&h(x(`Which template?
369
+ kadence template delete bug`),r),h(Xn(s,process.env,n),r);break;default:h(x(`Unknown action "${e}".
370
+ Available: save, list, delete`,{received:e,allowed:Nr}),r)}});D.command("ui","Interactive kanban board").alias("board:ui").example(" kadence ui").action(async()=>{let{runUi:e}=await import("./chunks/ui-Q53SLKMA.js"),n=await e(process.cwd(),process.env);n.ok||h(n,!1)});var ns=["init","prime","ready","task","decision","note","board","ui","schema","sprint","milestone","template","report","stats","compact","completion"],ss=e=>{let n=ns.indexOf(e);return n===-1?ns.length:n};D.commands.sort((e,n)=>ss(e.name)-ss(n.name));D.help();D.version("0.5.0");var G=process.argv;if(G[2]==="task"&&G[3]==="log"&&G[4]!==void 0&&G[5]!==void 0){let e=Te(process.cwd(),process.env,G[4],G[5]),n=G.includes("--json");h(e,n)}var rs=process.argv.findIndex((e,n)=>e.startsWith("-")&&/^-\d+(\.\d+)?$/.test(e)&&process.argv[n-1]==="--estimate");rs!==-1&&(process.stderr.write(`Estimate must be a positive number, got "${process.argv[rs]}".
286
371
  kadence task add "Fix login" --estimate 3
287
- `),process.exit(2));try{A.parse()}catch(e){process.stderr.write(`${e.message}
372
+ `),process.exit(2));try{D.parse()}catch(e){process.stderr.write(`${e.message}
288
373
  `),process.exit(2)}