kadence 0.3.2 → 0.4.1

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,54 +1,233 @@
1
1
  #!/usr/bin/env node
2
- import{A as re,B as oe,C as I,D as de,E as ce,F as le,G as ue,H as me,I as fe,J as pe,K as B,L as he,M as ge,N as ke,O as be,P as ye,Q as we,R as ve,S as Ae,T as xe,U as De,a as Y,b as V,c as O,d as C,e as J,f as G,g as H,h as x,i as N,j as z,k as Q,l as X,m as Z,n as ee,o as te,p as K,q as k,r as _,s as b,t as y,u as ne,v as w,w as R,x as se,y as ie,z as ae}from"./chunks/chunk-EPFIY2MT.js";function U(e){return e==null?[]:Array.isArray(e)?e:[e]}function ze(e,s,n,t){var i,a=e[s],r=~t.string.indexOf(s)?n==null||n===!0?"":String(n):typeof n=="boolean"?n:~t.boolean.indexOf(s)?n==="false"?!1:n==="true"||(e._.push((i=+n,i*0===0?i:n)),!!n):(i=+n,i*0===0?i:n);e[s]=a==null?r:Array.isArray(a)?a.concat(r):[a,r]}function Qe(e,s){e=e||[],s=s||{};var n,t,i,a,r,o={_:[]},c=0,l=0,u=0,m=e.length;let A=s.alias!==void 0,p=s.unknown!==void 0,h=s.default!==void 0;if(s.alias=s.alias||{},s.string=U(s.string),s.boolean=U(s.boolean),A)for(n in s.alias)for(t=s.alias[n]=U(s.alias[n]),c=0;c<t.length;c++)(s.alias[t[c]]=t.concat(n)).splice(c,1);for(c=s.boolean.length;c-- >0;)for(t=s.alias[s.boolean[c]]||[],l=t.length;l-- >0;)s.boolean.push(t[l]);for(c=s.string.length;c-- >0;)for(t=s.alias[s.string[c]]||[],l=t.length;l-- >0;)s.string.push(t[l]);if(h){for(n in s.default)if(a=typeof s.default[n],t=s.alias[n]=s.alias[n]||[],s[a]!==void 0)for(s[a].push(n),c=0;c<t.length;c++)s[a].push(t[c])}let D=p?Object.keys(s.alias):[];for(c=0;c<m;c++){if(i=e[c],i==="--"){o._=o._.concat(e.slice(++c));break}for(l=0;l<i.length&&i.charCodeAt(l)===45;l++);if(l===0)o._.push(i);else if(i.substring(l,l+3)==="no-"){if(a=i.substring(l+3),p&&!~D.indexOf(a))return s.unknown(i);o[a]=!1}else{for(u=l+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(a=i.substring(l,u),r=i.substring(++u)||c+1===m||(""+e[c+1]).charCodeAt(0)===45||e[++c],t=l===2?[a]:a,u=0;u<t.length;u++){if(a=t[u],p&&!~D.indexOf(a))return s.unknown("-".repeat(l)+a);ze(o,a,u+1<t.length||r,s)}}}if(h)for(n in s.default)o[n]===void 0&&(o[n]=s.default[n]);if(A)for(n in o)for(t=s.alias[n]||[];t.length>0;)o[t.shift()]=o[n];return o}function $e(e){return e.replace(/[<[].+/,"").trim()}function Xe(e){let s=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,t=[],i=o=>{let c=!1,l=o[1];return l.startsWith("...")&&(l=l.slice(3),c=!0),{required:o[0].startsWith("<"),value:l,variadic:c}},a;for(;a=s.exec(e);)t.push(i(a));let r;for(;r=n.exec(e);)t.push(i(r));return t}function Ze(e){let s={alias:{},boolean:[]};for(let[n,t]of e.entries())t.names.length>1&&(s.alias[t.names[0]]=t.names.slice(1)),t.isBoolean&&(t.negated&&e.some((i,a)=>a!==n&&i.names.some(r=>t.names.includes(r))&&typeof i.required=="boolean")||s.boolean.push(t.names[0]));return s}function Ce(e){return e.sort((s,n)=>s.length>n.length?-1:1)[0]}function Se(e,s){return e.length>=s?e:`${e}${" ".repeat(s-e.length)}`}function et(e){return e.replaceAll(/([a-z])-([a-z])/g,(s,n,t)=>n+t.toUpperCase())}function tt(e,s,n){let t=e;for(let i=0;i<s.length;i++){let a=s[i];if(i===s.length-1){t[a]=n;return}if(t[a]==null){let r=+s[i+1]>-1;t[a]=r?[]:{}}t=t[a]}}function nt(e,s){for(let n of Object.keys(s)){let t=s[n];t.shouldTransform&&(e[n]=[e[n]].flat(),typeof t.transformFunction=="function"&&(e[n]=e[n].map(t.transformFunction)))}}function st(e){let s=/([^\\/]+)$/.exec(e);return s?s[1]:""}function je(e){return e.split(".").map((s,n)=>n===0?et(s):s).join(".")}var j=class extends Error{constructor(e){super(e),this.name="CACError",typeof Error.captureStackTrace!="function"&&(this.stack=new Error(e).stack)}},it=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,s,n){this.rawName=e,this.description=s,this.config=Object.assign({},n),e=e.replaceAll(".*",""),this.negated=!1,this.names=$e(e).split(",").map(t=>{let i=t.trim().replace(/^-{1,2}/,"");return i.startsWith("no-")&&(this.negated=!0,i=i.replace(/^no-/,"")),je(i)}).sort((t,i)=>t.length>i.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}},L,E;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",E=`${process.platform}-${process.arch} ${e}-${process.version}`,L=process.argv}else typeof navigator>"u"?E="unknown":E=`${navigator.platform} ${navigator.userAgent}`;var Ee=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,s,n={},t){this.rawName=e,this.description=s,this.config=n,this.cli=t,this.options=[],this.aliasNames=[],this.name=$e(e),this.args=Xe(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,s="-v, --version"){return this.versionNumber=e,this.option(s,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,s,n){let t=new it(e,s,n);return this.options.push(t),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 Te}hasOption(e){return e=e.split(".")[0],this.options.find(s=>s.names.includes(e))}outputHelp(){let{name:e,commands:s}=this.cli,{versionNumber:n,options:t,helpCallback:i}=this.cli.globalCommand,a=[{body:`${e}${n?`/${n}`:""}`}];if(a.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&s.length>0){let o=Ce(s.map(c=>c.rawName));a.push({title:"Commands",body:s.map(c=>` ${Se(c.rawName,o.length)} ${c.description}`).join(`
3
- `)},{title:"For more info, run any command with the `--help` flag",body:s.map(c=>` $ ${e}${c.name===""?"":` ${c.name}`} --help`).join(`
4
- `)})}let r=this.isGlobalCommand?t:[...this.options,...t||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(r=r.filter(o=>o.name!=="version")),r.length>0){let o=Ce(r.map(c=>c.rawName));a.push({title:"Options",body:r.map(c=>` ${Se(c.rawName,o.length)} ${c.description} ${c.config.default===void 0?"":`(default: ${c.config.default})`}`).join(`
5
- `)})}this.examples.length>0&&a.push({title:"Examples",body:this.examples.map(o=>typeof o=="function"?o(e):o).join(`
6
- `)}),i&&(a=i(a)||a),console.info(a.map(o=>o.title?`${o.title}:
7
- ${o.body}`:o.body).join(`
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(`
8
8
 
9
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:s}=this.cli.globalCommand;s&&console.info(`${e}/${s} ${E}`)}checkRequiredArgs(){let e=this.args.filter(s=>s.required).length;if(this.cli.args.length<e)throw new j(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:s}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!s.hasOption(n))throw new j(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:s}=this.cli,n=[...s.options,...this.options];for(let t of n){let i=e[t.name.split(".")[0]];if(t.required){let a=n.some(r=>r.negated&&r.names.includes(t.name));if(i===!0||i===!1&&!a)throw new j(`option \`${t.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(s=>s.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new j(`Unused args: ${this.cli.args.slice(e).map(s=>`\`${s}\``).join(", ")}`)}},Te=class extends Ee{constructor(e){super("@@global@@","",{},e)}},at=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 Te(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,s,n){let t=new Ee(e,s||"",n,this);return t.globalCommand=this.globalCommand,this.commands.push(t),t}option(e,s,n){return this.globalCommand.option(e,s,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,s="-v, --version"){return this.globalCommand.version(e,s),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:s},n,t){return this.args=e,this.options=s,n&&(this.matchedCommand=n),t&&(this.matchedCommandName=t),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:s=!0}={}){if(!e){if(!L)throw new Error("No argv provided and runtime process argv is not available.");e=L}this.rawArgs=e,this.name||(this.name=e[1]?st(e[1]):"cli");let n=!0;for(let i of this.commands){let a=this.mri(e.slice(2),i),r=a.args[0];if(i.isMatched(r)){n=!1;let o={...a,args:a.args.slice(1)};this.setParsedInfo(o,i,r),this.dispatchEvent(new CustomEvent(`command:${r}`,{detail:i}))}}if(n){for(let i of this.commands)if(i.isDefaultCommand){n=!1;let a=this.mri(e.slice(2),i);this.setParsedInfo(a,i),this.dispatchEvent(new CustomEvent("command:!",{detail:i}))}}if(n){let i=this.mri(e.slice(2));this.setParsedInfo(i)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),s=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),s=!1,this.unsetMatchedCommand());let t={args:this.args,options:this.options};return s&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]})),t}mri(e,s){let n=[...this.globalCommand.options,...s?s.options:[]],t=Ze(n),i=[],a=e.indexOf("--");a!==-1&&(i=e.slice(a+1),e=e.slice(0,a));let r=Qe(e,t);r=Object.keys(r).reduce((m,A)=>({...m,[je(A)]:r[A]}),{_:[]});let o=r._,c={"--":i},l=s&&s.config.ignoreOptionDefaultValue?s.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,u=Object.create(null);for(let m of n){if(!l&&m.config.default!==void 0)for(let A of m.names)c[A]=m.config.default;Array.isArray(m.config.type)&&u[m.name]===void 0&&(u[m.name]=Object.create(null),u[m.name].shouldTransform=!0,u[m.name].transformFunction=m.config.type[0])}for(let m of Object.keys(r))m!=="_"&&(tt(c,m.split("."),r[m]),nt(c,u));return{args:o,options:c}}runMatchedCommand(){let{args:e,options:s,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let t=[];return n.args.forEach((i,a)=>{i.variadic?t.push(e.slice(a)):t.push(e[a])}),t.push(s),n.commandAction.apply(this,t)}},Oe=(e="")=>new at(e);import{existsSync as T,mkdirSync as rt,readFileSync as Ke,writeFileSync as P}from"node:fs";import{join as F}from"node:path";var Ne=".kadence/state.json",ot=["AGENTS.md","CLAUDE.md"];function _e(e,s="dev"){let n=Y(e);if(n===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: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.
10
10
  Create one and try again:
11
- git init`};let t=T(O(n));rt(O(n),{recursive:!0}),dt(n);let i=F(V(n),"README.md");T(i)||P(i,J(s),"utf8");for(let a of ot)ct(n,a,s);return{ok:!0,alreadyInitialized:t,root:n,message:t?"kadence is already initialised.":`kadence is ready.
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?`
12
+
13
+ ${Cn(o)}`:"";return{ok:!0,alreadyInitialized:s,root:o,message:s?`kadence is already initialised.${i}`:`kadence is ready.
12
14
 
13
15
  kadence task add "first task"
14
16
  kadence board
15
17
 
16
- Files were created but not committed \u2014 that call is yours.`}}function dt(e){let s=F(e,".gitignore"),n="";if(T(s)&&(n=Ke(s,"utf8")),n.includes(Ne))return;let t=n.length>0&&!n.endsWith(`
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(`
17
21
  `)?`
18
- `:"";P(s,`${n}${t}${Ne}
19
- `,"utf8")}function ct(e,s,n){let t=F(e,s),i=T(t)?Ke(t,"utf8"):null,a=G(i,n);a!==i&&P(t,a,"utf8")}import{existsSync as lt}from"node:fs";import{isAbsolute as ut,join as mt,relative as ft}from"node:path";function Re(e,s){let n=s.toUpperCase();return e.decisions.find(t=>t.id===n||t.label===n)}function Ie(e){return k(1,"decision_not_found",`No decision ${e}.
20
- kadence decision list`,{received:e,hint:"kadence decision list --json"})}function Be(e,s,n,t){let i=b(e,s);if(!y(i))return i;let a=n.trim();if(a.length===0)return k(2,"invalid_argument","A decision needs a title.",{hint:'kadence decision add "Use ULIDs" --why "Clocks disagree between machines"'});let r=t.why?.trim()??"";if(r.length===0)return k(2,"invalid_argument",`A decision needs a reason.
21
- --why "..."`,{received:a,hint:'kadence decision add "Use ULIDs" --why "Clocks disagree between machines"'});let{state:o,warnings:c}=w(i.root,i.actor),l;if(t.task!==void 0){let g=R(o,t.task);if(g===void 0)return _(t.task);l=g.id}let u;if(t.supersedes!==void 0){let g=Re(o,t.supersedes);if(g===void 0)return Ie(t.supersedes);u=g.id,l===void 0&&g.task!==null&&(l=g.task)}let m=(t.docs??[]).map(g=>ut(g)?ft(i.root,g):g.replace(/^\.\//,"")),p=m.filter(g=>!lt(mt(i.root,g))).map(g=>`No file at ${g} \u2014 the link is recorded anyway; it may arrive later.`),h=x();C(i.root,{id:h,type:"decision.recorded",entity:h,actor:i.actor,ts:new Date().toISOString(),source:i.source,data:{title:a,why:r,...t.rejected!==void 0?{rejected:t.rejected.trim()}:{},...l!==void 0?{task:l}:{},...u!==void 0?{supersedes:u}:{},...m.length>0?{docs:m}:{}}});let W=w(i.root,i.actor).state.decisions.find(g=>g.id===h)?.label??h,He=u===void 0?"":`
22
- It replaces ${t.supersedes}, and both links were written by one event \u2014 neither side can go stale.`;return{ok:!0,exitCode:0,warnings:[...c,...p],message:`${W} recorded.${He}`,data:{schema:"kadence/v1",ok:!0,decision:{id:h,label:W,title:a}}}}function Ue(e,s,n){let t=b(e,s);if(!y(t))return t;let{state:i,warnings:a}=w(t.root,t.actor),r=i.decisions;if(n.task!==void 0){let o=R(i,n.task);if(o===void 0)return _(n.task);r=r.filter(c=>c.task===o.id)}return n.all!==!0&&(r=r.filter(o=>o.supersededBy===null)),{ok:!0,exitCode:0,warnings:a,message:pt(r,i),data:{schema:"kadence/v1",ok:!0,decisions:r.map(o=>Pe(o,i))}}}function Le(e,s,n){let t=b(e,s);if(!y(t))return t;let{state:i,warnings:a}=w(t.root,t.actor),r=Re(i,n);return r===void 0?Ie(n):{ok:!0,exitCode:0,warnings:a,message:ht(r,i),data:{schema:"kadence/v1",ok:!0,decision:Pe(r,i)}}}function S(e,s){return s===null?null:e.decisions.find(n=>n.id===s)?.label??e.tasks.find(n=>n.id===s)?.label??s}function Pe(e,s){return{id:e.id,label:e.label,title:e.title,why:e.why,rejected:e.rejected,task:S(s,e.task),docs:e.docs,supersedes:S(s,e.supersedes),supersededBy:S(s,e.supersededBy),superseded:e.supersededBy!==null,at:e.at,by:e.by,source:e.source}}function pt(e,s){return e.length===0?`No decisions recorded yet.
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
+ 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.
32
+ 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(`
40
+ `)}
41
+ `:e==="bash"?`${V} for bash
42
+ _kadence() {
43
+ local cur prev
44
+ cur="\${COMP_WORDS[COMP_CWORD]}"
45
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
46
+
47
+ if [ "$COMP_CWORD" -eq 1 ]; then
48
+ COMPREPLY=( $(compgen -W "${t}" -- "$cur") )
49
+ return
50
+ fi
51
+ case "$prev" in
52
+ task) COMPREPLY=( $(compgen -W "${me.join(" ")}" -- "$cur") ) ;;
53
+ sprint) COMPREPLY=( $(compgen -W "create add edit start close status list burndown" -- "$cur") ) ;;
54
+ milestone) COMPREPLY=( $(compgen -W "create add list close" -- "$cur") ) ;;
55
+ decision) COMPREPLY=( $(compgen -W "add list show" -- "$cur") ) ;;
56
+ completion) COMPREPLY=( $(compgen -W "install" -- "$cur") ) ;;
57
+ *) COMPREPLY=( $(compgen -W "--json" -- "$cur") ) ;;
58
+ esac
59
+ }
60
+ complete -F _kadence kadence
61
+ `:`#compdef kadence
62
+ ${V} for zsh
63
+
64
+ _kadence() {
65
+ local -a commands
66
+ commands=(
67
+ ${ue.map(([n,o])=>` '${n}:${o.replace(/'/g,"")}'`).join(`
68
+ `)}
69
+ )
70
+
71
+ if (( CURRENT == 2 )); then
72
+ _describe 'command' commands
73
+ return
74
+ fi
75
+
76
+ case "\${words[2]}" in
77
+ task) _values 'action' ${me.join(" ")} ;;
78
+ sprint) _values 'action' create add edit start close status list burndown ;;
79
+ milestone) _values 'action' create add list close ;;
80
+ decision) _values 'action' add list show ;;
81
+ completion) _values 'action' install ;;
82
+ *) _arguments '--json[Machine-readable output for agents]' ;;
83
+ esac
84
+ }
85
+
86
+ _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.
88
+ 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.
90
+ 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"?`
92
+ zsh loads completions from fpath, which is yours to set. Add to ~/.zshrc:
93
+ fpath=(${_t(s)} $fpath)
94
+ 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
96
+ 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.
98
+
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.
100
+ Record the first one:
101
+ kadence note "text"
102
+
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}".
106
+ 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.
110
+ Create one:
111
+ kadence milestone create "1.0"`:`Every milestone is closed.
112
+ 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.
23
119
  Record the first one:
24
- kadence decision add "Use ULIDs" --why "Clocks disagree"`:e.map(n=>{let t=n.supersededBy===null?"":` (superseded by ${S(s,n.supersededBy)})`,i=n.source==="agent"?" [agent]":"";return`${n.label} ${n.title}${t}${i}`}).join(`
25
- `)}function ht(e,s){let n=[`${e.label} ${e.title}`];return e.supersededBy!==null&&n.push("",`!! SUPERSEDED by ${S(s,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: ${S(s,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: ${S(s,e.supersedes)}`),n.join(`
26
- `)}import{writeSync as kt}from"node:fs";var M="cancelled";function Fe(e,s,n,t){let i=b(e,s);if(!y(i))return i;let{fields:a,error:r}=ae(t);if(r!==null)return r;let{state:o,warnings:c}=w(i.root,i.actor),l=o.tasks.filter(p=>p.status!==M);if(n.assignee!==void 0){let p=n.assignee.toLowerCase(),h=p==="me"?i.actor.toLowerCase():p;l=l.filter(D=>(D.assignee??"").toLowerCase()===h)}if(n.sprint==="active"){let p=o.sprints.find(h=>h.status==="active"||h.status==="planned");l=p===void 0?[]:l.filter(h=>h.sprint===p.id)}let u={};for(let p of o.statuses)p!==M&&(u[p]=l.filter(h=>h.status===p));let m=o.orphanStatuses.filter(p=>p!==M);for(let p of m)u[p]=l.filter(h=>h.status===p);let A=m.length>0?[`Statuses not in the board configuration: ${m.join(", ")}.
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=`
123
+ :root {
124
+ color-scheme: light dark;
125
+ --bg: #ffffff; --fg: #1a1a1a; --muted: #6b6b6b; --line: #e2e2e2;
126
+ --card: #fafafa; --accent: #2d6cdf; --done: #2e7d32; --warn: #b26a00;
127
+ --danger: #c62828;
128
+ }
129
+ @media (prefers-color-scheme: dark) {
130
+ :root {
131
+ --bg: #17181a; --fg: #e8e8e8; --muted: #9a9a9a; --line: #2e2f33;
132
+ --card: #1f2023; --accent: #6ea8fe; --done: #7bc47f; --warn: #e0a458;
133
+ --danger: #ef6b6b;
134
+ }
135
+ }
136
+ * { box-sizing: border-box; }
137
+ body {
138
+ margin: 0; padding: 2rem 1.5rem; background: var(--bg); color: var(--fg);
139
+ font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
140
+ }
141
+ main { max-width: 1100px; margin: 0 auto; }
142
+ h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
143
+ h2 { font-size: 1.05rem; margin: 2rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); }
144
+ .stamp { color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }
145
+ .stamp code { background: var(--card); padding: .1rem .3rem; border-radius: 3px; }
146
+ .columns { display: flex; gap: .75rem; align-items: flex-start; overflow-x: auto; padding-bottom: .5rem; }
147
+ .column { flex: 1 1 0; min-width: 190px; }
148
+ .column h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .5rem; }
149
+ .card { background: var(--card); border: 1px solid var(--line); border-left-width: 3px; border-radius: 5px; padding: .5rem .6rem; margin-bottom: .5rem; }
150
+ .card .label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: var(--accent); }
151
+ .card .title { display: block; margin: .15rem 0; }
152
+ .card .meta { color: var(--muted); font-size: .78rem; }
153
+ .card.done { border-left-color: var(--done); }
154
+ .card.blocked, .card.contested { border-left-color: var(--danger); }
155
+ .card.in_progress { border-left-color: var(--accent); }
156
+ .pill { display: inline-block; font-size: .72rem; padding: .05rem .35rem; border-radius: 3px; border: 1px solid var(--line); margin-right: .25rem; }
157
+ .pill.danger { color: var(--danger); border-color: var(--danger); }
158
+ .pill.warn { color: var(--warn); border-color: var(--warn); }
159
+ .bar { background: var(--line); border-radius: 3px; height: .55rem; overflow: hidden; }
160
+ .bar > span { display: block; height: 100%; background: var(--accent); }
161
+ .bar.done > span { background: var(--done); }
162
+ table { border-collapse: collapse; width: 100%; font-size: .88rem; }
163
+ th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
164
+ th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
165
+ .chart { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
166
+ .chart div { display: flex; gap: .5rem; align-items: center; }
167
+ .chart .day { color: var(--muted); width: 3.5rem; }
168
+ .chart .track { flex: 1; }
169
+ .decision { border-left: 3px solid var(--line); padding-left: .75rem; margin-bottom: 1rem; }
170
+ .decision .why { color: var(--muted); }
171
+ .criteria { list-style: none; margin: .35rem 0 0; padding: 0; font-size: .8rem; color: var(--muted); }
172
+ .criteria li.checked { color: var(--done); }
173
+ .empty { color: var(--muted); }
174
+ 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(`
177
+ `)}
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(`
181
+ `)?"":`
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(", ")}.
27
185
  Tasks there are still shown. Add the column or move them:
28
- kadence board config --statuses "..."`]:[];return{ok:!0,exitCode:0,warnings:[...c,...A],message:ee(u,Z(s,process.stdout.isTTY===!0)),data:{schema:"kadence/v1",ok:!0,columns:Object.fromEntries(Object.entries(u).map(([p,h])=>[p,h.map(D=>re(D,a))]))}}}function Me(e,s,n){let t=b(e,s);if(!y(t))return t;let{state:i,warnings:a}=w(t.root,t.actor);if(n===void 0)return{ok:!0,exitCode:0,warnings:a,message:`Board columns: ${i.statuses.join(", ")}
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(", ")}
187
+ Started: ${i.started} (cycle time and actual hours count from here)
188
+ ${f}
29
189
 
30
190
  Change them with:
31
- kadence board config --statuses "todo,doing,review,done"`,data:{schema:"kadence/v1",ok:!0,statuses:i.statuses}};let r=n.split(",").map(l=>l.trim().toLowerCase().replace(/\s+/g,"_")).filter(l=>l.length>0);if(r.length===0)return k(2,"invalid_argument","At least one status is required.",{received:n});if(new Set(r).size!==r.length)return k(2,"invalid_argument","The same status is listed twice.",{received:n});if(!r.includes(N))return k(2,"invalid_argument",`The list must include "${N}" \u2014 velocity and burndown are computed from it.`,{received:n});let o=i.tasks.filter(l=>!r.includes(l.status)&&l.status!==z);C(t.root,{id:x(),type:"board.configured",entity:x(),actor:t.actor,ts:new Date().toISOString(),source:t.source,data:{statuses:r}});let c=o.length>0?`
32
- ${o.length} task(s) remain in removed columns: ${[...new Set(o.map(l=>l.status))].join(", ")}. They are still listed.`:"";return{ok:!0,exitCode:0,warnings:a,message:`Board columns: ${r.join(", ")}${c}`,data:{schema:"kadence/v1",ok:!0,statuses:r}}}var gt=["description","type","priority","estimate","labels","assignee"];function qe(e,s,n,t){let i=b(e,s);if(!y(i))return i;let a=n.trim();if(a.length===0)return k(2,"invalid_argument","A template needs a name.",{hint:"kadence template list --json"});let r={};for(let o of gt)t[o]!==void 0&&(r[o]=t[o]);return Object.keys(r).length===0?k(2,"invalid_argument",`A template needs at least one field.
33
- kadence template save bug --type bug --priority high --label triage`,{received:n}):(C(i.root,{id:x(),type:"template.saved",entity:x(),actor:i.actor,ts:new Date().toISOString(),source:i.source,data:{name:a,fields:r}}),{ok:!0,exitCode:0,message:`Template "${a}" saved: ${Object.keys(r).join(", ")}.
34
- kadence task add "title" --template ${a}`,data:{schema:"kadence/v1",ok:!0,template:{name:a,fields:r}}})}function We(e,s){let n=b(e,s);if(!y(n))return n;let{state:t,warnings:i}=w(n.root,n.actor);return t.templates.length===0?{ok:!0,exitCode:0,warnings:i,message:`No templates yet.
35
- kadence template save bug --type bug --priority high`,data:{schema:"kadence/v1",ok:!0,templates:[]}}:{ok:!0,exitCode:0,warnings:i,message:t.templates.map(a=>{let r=Object.entries(a.fields).map(([o,c])=>`${o}=${Array.isArray(c)?c.join("/"):String(c)}`).join(" ");return` ${a.name.padEnd(14)} ${r}`}).join(`
36
- `),data:{schema:"kadence/v1",ok:!0,templates:t.templates}}}function Ye(e,s,n){let t=b(e,s);if(!y(t))return t;let{state:i,warnings:a}=w(t.root,t.actor);return i.templates.some(r=>r.name===n)?(C(t.root,{id:x(),type:"template.deleted",entity:x(),actor:t.actor,ts:new Date().toISOString(),source:t.source,data:{name:n}}),{ok:!0,exitCode:0,warnings:a,message:`Template "${n}" deleted.`}):k(1,"template_not_found",`No template "${n}".
37
- kadence template list`,{received:n,hint:"kadence template list --json"})}function Ve(e,s,n){let t=b(e,s);if(!y(t))return{error:t};let{state:i}=w(t.root,t.actor),a=i.templates.find(r=>r.name===n);if(a===void 0){let r=i.templates.map(o=>o.name);return{error:k(1,"template_not_found",`No template "${n}".`+(r.length>0?`
38
- Available: ${r.join(", ")}`:`
39
- kadence template save ...`),{received:n,...r.length>0?{allowed:r}:{}})}}return{fields:a.fields}}function q(e,s){let n=Buffer.from(s,"utf8"),t=0;for(;t<n.length;)try{t+=kt(e,n,t,n.length-t)}catch(i){if(i.code!=="EAGAIN")throw i}}var v=Oe("kadence");function d(e,s){for(let n of e.warnings??[])q(2,`${n}
40
- `);if(s){let n=e.data??{schema:"kadence/v1",ok:e.ok,...e.ok?{}:{error:e.error??{message:e.message}}};q(1,`${JSON.stringify(n)}
41
- `)}else q(e.ok?1:2,`${e.message}
42
- `);process.exit(e.exitCode)}function Je(e,s,n,t){if(e!==void 0)return e;ge(process.env,process.stdout.isTTY===!0)||d(f(`No terminal available for an editor.
191
+ kadence board config --statuses "todo,doing,review,done"
192
+ 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?
199
+ 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.
201
+ 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?`
212
+ 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.
43
217
  Pass the text directly:
44
- --description "..."`),t);let i=he(process.env,s,n);return i.error!==null&&d({ok:!1,exitCode:1,message:i.error},t),i.text===null&&d({ok:!0,exitCode:0,message:"Aborted \u2014 nothing changed."},t),i.text}var bt=["add","list","show","edit","move","assign","comment","log","parent","block","unblock","cancel","delete"],yt=["create","add","edit","start","close","status","list","burndown"],wt=["save","list","delete"];function f(e,s={}){return k(2,"invalid_argument",e,s)}function vt(e){let s=e.commands,n=e.errors;return`kadence/v1 \u2014 ${s.length} commands, ${n.length} error codes.
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.
45
219
  ${e.stability}
46
220
 
47
221
  The machine-readable form is what agents read:
48
- kadence schema --json`}v.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,s,n)=>{let t=n.json===!0,i=process.cwd(),a=n.doc===void 0?void 0:Array.isArray(n.doc)?n.doc:[n.doc];switch(e){case"add":s===void 0&&d(f(`A title is required:
49
- kadence decision add "Use ULIDs" --why "..."`),t),d(Be(i,process.env,s,{...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}:{},...a!==void 0?{docs:a}:{}}),t);break;case void 0:case"list":d(Ue(i,process.env,{...n.all===!0?{all:!0}:{},...n.task!==void 0?{task:n.task}:{}}),t);break;case"show":s===void 0&&d(f(`Which decision?
50
- kadence decision show DEC-1`),t),d(Le(i,process.env,s),t);break;default:d(f(`Unknown action "${e}".
51
- Available: add, list, show`),t)}});v.command("schema","The machine-readable --json contract, for agents").option("--json","Machine-readable output for agents").example(" kadence schema --json").action(e=>{let s=e.json===!0,n=H("0.3.2");d({ok:!0,exitCode:0,message:vt(n),data:{schema:"kadence/v1",ok:!0,contract:n}},s)});v.command("init","Set up kadence in this repository").example(" kadence init").action(()=>{let e=_e(process.cwd(),"0.3.2");d({ok:e.ok,message:e.message,exitCode:e.ok?0:1},!1)});v.command("task [action] [arg] [value]","Tasks: add | list | show | move | assign | doc").option("--title <text>","New title (for edit)").option("-d, --description <text>","Full description; use quotes for multiple lines").option("--type <type>",`Type: ${Q.join(" | ")}`).option("--priority <level>",`Priority: ${X.join(" | ")}`).option("-a, --assignee <who>","Assignee, e.g. dev@example.com").option("--label <name>","Label; repeat the flag 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: ${K.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: ${te.join(" | ")}`).option("--tree","Show parent/child structure").option("--parent <task>",'Parent task, e.g. KAD-1 (use "none" to detach)').option("--template <name>","Pre-fill fields from a saved template").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 --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 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,s,n,t)=>{let i=t.json===!0,a=process.cwd();switch(e===void 0&&d(f(`Which action?
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:
226
+ 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?
52
231
  kadence task add "Fix login"
53
232
  kadence task list
54
233
  kadence task show KAD-1
@@ -57,45 +236,53 @@ Available: add, list, show`),t)}});v.command("schema","The machine-readable --js
57
236
  kadence task assign KAD-1 dev@example.com
58
237
  kadence task comment KAD-1 "text"
59
238
  kadence task cancel KAD-1
60
- kadence task delete KAD-1`),i),e){case"add":{s===void 0&&d(f(`A title is required:
61
- kadence task add "Fix login"`),i);let r=t.estimate===void 0?void 0:Number(t.estimate);r!==void 0&&(!Number.isFinite(r)||r<0)&&d(f(`Estimate must be a positive number, got "${t.estimate}".
62
- kadence task add "Fix login" --estimate 3`),i);let o={};if(t.template!==void 0){let l=Ve(a,process.env,t.template);"error"in l?d(l.error,i):o=l.fields}let c=t.label===void 0?void 0:Array.isArray(t.label)?t.label:[t.label];d(ne(a,process.env,s,{...o,...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}:{},...c!==void 0?{labels:c}:{},...t.due!==void 0?{due:t.due}:{},...t.parent!==void 0?{parent:t.parent}:{},...r!==void 0?{estimate:r}:{}}),i);break}case"doc":(s===void 0||n===void 0)&&d(f(`A task and a path are required:
63
- kadence task doc KAD-1 docs/design.md`),i),d(ue(a,process.env,s,n),i);break;case"log":(s===void 0||n===void 0)&&d(f(`A task and a duration are required:
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:
242
+ 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:
64
244
  kadence task log KAD-1 2h
65
- kadence task log KAD-1 90m`),i),d(B(a,process.env,s,n),i);break;case"parent":(s===void 0||n===void 0)&&d(f(`A task and a parent are required:
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:
66
246
  kadence task parent KAD-2 KAD-1
67
- kadence task parent KAD-2 none to detach`),i),d(fe(a,process.env,s,n),i);break;case"block":case"unblock":(s===void 0||n===void 0)&&d(f(`A task and a blocker are required:
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:
248
+ kadence task ac add KAD-1 "tests green"
249
+ kadence task ac check KAD-1 1
250
+ 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:
68
255
  kadence task block KAD-2 KAD-1 KAD-2 waits for KAD-1
69
- kadence task unblock KAD-2 KAD-1`),i),d(pe(a,process.env,s,n,e==="unblock"),i);break;case"edit":{s===void 0&&d(f(`Which task?
70
- kadence task edit KAD-1 --priority high`),i);let r=t.estimate===void 0?void 0:Number(t.estimate);r!==void 0&&(!Number.isFinite(r)||r<0)&&d(f(`Estimate must be a positive number, got "${t.estimate}".`),i);let o=t.label===void 0?void 0:Array.isArray(t.label)?t.label:[t.label],c=t.title!==void 0||t.description!==void 0||t.type!==void 0||t.priority!==void 0||t.due!==void 0||r!==void 0||o!==void 0||n!==void 0,l=t.description;if(!c){let u=I(a,process.env,s);u.ok||d(u,i);let m=u.data.task??{description:null};l=Je(void 0,m.description??"",`Editing the description of ${s}.`,i)}d(de(a,process.env,s,{...t.title!==void 0?{title:t.title}:n!==void 0?{title:n}:{},...l!==void 0?{description:l}:{},...t.type!==void 0?{type:t.type}:{},...t.priority!==void 0?{priority:t.priority}:{},...t.due!==void 0?{due:t.due}:{},...r!==void 0?{estimate:r}:{},...o!==void 0?{labels:o}:{}}),i);break}case"comment":{s===void 0&&d(f(`Which task?
71
- kadence task comment KAD-1 "text"`),i);let r=Je(n,"",`Comment on ${s}.`,i);d(me(a,process.env,s,r??""),i);break}case"cancel":s===void 0&&d(f(`Which task?
72
- kadence task cancel KAD-1`),i),d(ce(a,process.env,s),i);break;case"delete":s===void 0&&d(f(`Which task?
73
- kadence task delete KAD-1`),i),d(le(a,process.env,s),i);break;case"list":d(se(a,process.env,{...t.status!==void 0?{status:t.status}:{},...t.search!==void 0?{search:t.search}:{},...t.type!==void 0?{type:t.type}:{},...t.priority!==void 0?{priority:t.priority}:{},...t.assignee!==void 0?{assignee:t.assignee}:{},...t.label!==void 0?{label:Array.isArray(t.label)?t.label.at(-1):t.label}:{},...t.overdue===!0?{overdue:!0}:{},...t.dueBefore!==void 0?{dueBefore:t.dueBefore}:{},...t.sort!==void 0?{sort:t.sort}:{},...t.tree===!0?{tree:!0}:{},...i&&t.fields!==void 0?{fields:t.fields}:{}}),i);break;case"show":s===void 0&&d(f(`Which task?
74
- kadence task show KAD-1`),i),d(I(a,process.env,s),i);break;case"move":(s===void 0||n===void 0)&&d(f(`A task and a target status are required:
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:
75
262
  kadence task move KAD-1 done
76
- Statuses: ${K.join(", ")}`),i),d(ie(a,process.env,s,n),i);break;case"assign":(s===void 0||n===void 0)&&d(f(`A task and an assignee are required:
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:
77
264
  kadence task assign KAD-1 dev@example.com
78
- kadence task assign KAD-1 none to unassign`),i),d(oe(a,process.env,s,n),i);break;default:d(f(`Unknown action "${e}".
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}".
79
266
  Available: add, list, show, edit, move, assign, comment, log,
80
267
  parent, block, unblock, cancel, delete
81
- kadence task --help`,{received:e,allowed:bt}),i)}});v.command("board [action]",'Kanban board in the terminal; "config" edits the columns').option("--fields <list>","JSON only: comma-separated task fields to return").option("--statuses <list>",'Comma-separated columns, e.g. "todo,doing,done"').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 config").example(' kadence board config --statuses "todo,doing,review,done"').action((e,s)=>{e==="config"&&d(Me(process.cwd(),process.env,s.statuses),s.json===!0),e!==void 0&&d(f(`Unknown action "${e}".
82
- Available: config
83
- kadence board --help`,{received:e,allowed:["config"]}),s.json===!0),d(Fe(process.cwd(),process.env,{...s.assignee!==void 0?{assignee:s.assignee}:{},...s.sprint===!0?{sprint:"active"}:{}},s.json===!0?s.fields:void 0),s.json===!0)});v.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,s,n)=>{let t=n.json===!0,i=process.cwd();switch(e===void 0&&d(f(`Which action?
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}".
269
+ 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?
84
271
  kadence sprint create "Sprint 1"
85
272
  kadence sprint add KAD-1
86
273
  kadence sprint edit --start 2026-09-01
87
274
  kadence sprint start
88
275
  kadence sprint close
89
276
  kadence sprint status
90
- kadence sprint list`),t),e){case"create":s===void 0&&d(f(`A sprint name is required:
91
- kadence sprint create "Sprint 1"`),t),d(ke(i,process.env,s),t);break;case"add":s===void 0&&d(f(`Which task?
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?
92
279
  kadence sprint add KAD-1
93
- kadence sprint add KAD-1 --sprint "Sprint 2"`),t),d(be(i,process.env,s,n.sprint===void 0?{}:{sprint:n.sprint}),t);break;case"edit":d(xe(i,process.env,s,{...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}:{}}),t);break;case"start":d(ve(i,process.env,s),t);break;case"close":d(ye(i,process.env),t);break;case"status":d(we(i,process.env),t);break;case"list":d(Ae(i,process.env),t);break;case"burndown":d(De(i,process.env,s),t);break;default:d(f(`Unknown action "${e}".
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}".
94
281
  Available: create, add, edit, start, close, status, list, burndown
95
- kadence sprint --help`,{received:e,allowed:yt}),t)}});v.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,s,n)=>{let t=n.json===!0,i=process.cwd();switch(e){case"save":{s===void 0&&d(f(`A template name is required:
96
- kadence template save bug --type bug`),t);let a=n.label===void 0?void 0:Array.isArray(n.label)?n.label:[n.label];d(qe(i,process.env,s,{...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}:{},...a!==void 0?{labels:a}:{},...n.estimate!==void 0?{estimate:Number(n.estimate)}:{}}),t);break}case"list":case void 0:d(We(i,process.env),t);break;case"delete":s===void 0&&d(f(`Which template?
97
- kadence template delete bug`),t),d(Ye(i,process.env,s),t);break;default:d(f(`Unknown action "${e}".
98
- Available: save, list, delete`,{received:e,allowed:wt}),t)}});v.command("ui","Interactive kanban board").alias("board:ui").example(" kadence ui").action(async()=>{let{runUi:e}=await import("./chunks/ui-HHJ5TWYZ.js"),s=await e(process.cwd(),process.env);s.ok||d(s,!1)});v.help();v.version("0.3.2");var $=process.argv;if($[2]==="task"&&$[3]==="log"&&$[4]!==void 0&&$[5]!==void 0){let e=B(process.cwd(),process.env,$[4],$[5]),s=$.includes("--json");d(e,s)}var Ge=process.argv.findIndex((e,s)=>e.startsWith("-")&&/^-\d+(\.\d+)?$/.test(e)&&process.argv[s-1]==="--estimate");Ge!==-1&&(process.stderr.write(`Estimate must be a positive number, got "${process.argv[Ge]}".
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]}".
99
286
  kadence task add "Fix login" --estimate 3
100
- `),process.exit(2));try{v.parse()}catch(e){process.stderr.write(`${e.message}
287
+ `),process.exit(2));try{A.parse()}catch(e){process.stderr.write(`${e.message}
101
288
  `),process.exit(2)}