ace-assistant-cli 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.dev.md +53 -0
- package/dist/index.js +53 -50
- package/package.json +1 -1
package/README.dev.md
CHANGED
|
@@ -52,6 +52,19 @@ ace actions list --status active # Filter by status
|
|
|
52
52
|
ace actions add "New task" # Create action
|
|
53
53
|
ace actions complete <id> # Mark complete
|
|
54
54
|
ace actions update <id> --status waiting --waiting "Bob"
|
|
55
|
+
|
|
56
|
+
# Date-based filtering
|
|
57
|
+
ace actions due # Actions due today
|
|
58
|
+
ace actions due --week # Actions due this week
|
|
59
|
+
ace actions overdue # Overdue actions
|
|
60
|
+
ace actions completed # Recently completed (last 7 days)
|
|
61
|
+
ace actions completed --days 14 # Completed in last 14 days
|
|
62
|
+
|
|
63
|
+
# Other filters
|
|
64
|
+
ace actions waiting # Actions waiting on someone
|
|
65
|
+
ace actions count # Count by status
|
|
66
|
+
ace actions list --due today # Filter by due date
|
|
67
|
+
ace actions list --overdue # Include overdue flag
|
|
55
68
|
```
|
|
56
69
|
|
|
57
70
|
### Projects
|
|
@@ -63,7 +76,47 @@ ace projects list --domain Work # Filter by domain
|
|
|
63
76
|
ace projects add "New Project" # Create project
|
|
64
77
|
ace projects activate <id> # Set to active
|
|
65
78
|
ace projects complete <id> # Mark complete
|
|
79
|
+
|
|
80
|
+
# Reviews
|
|
66
81
|
ace projects review # Projects due for review
|
|
82
|
+
ace projects mark-reviewed <id> # Mark as reviewed
|
|
83
|
+
|
|
84
|
+
# Status changes
|
|
85
|
+
ace projects drop <id> # Drop a project
|
|
86
|
+
ace projects completed # Recently completed (last 7 days)
|
|
87
|
+
ace projects completed --days 14 # Completed in last 14 days
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Goals
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
ace goals list # List all goals
|
|
94
|
+
ace goals active # List active goals
|
|
95
|
+
ace goals list --domain Work # Filter by domain
|
|
96
|
+
ace goals get <id> # Get goal details
|
|
97
|
+
ace goals add "New Goal" --domain Work # Create goal
|
|
98
|
+
ace goals update <id> --name "Updated" # Update goal
|
|
99
|
+
ace goals complete <id> # Mark complete
|
|
100
|
+
ace goals pause <id> # Pause goal
|
|
101
|
+
ace goals drop <id> # Drop goal
|
|
102
|
+
ace goals review # Goals due for review
|
|
103
|
+
ace goals mark-reviewed <id> # Mark as reviewed
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Activity Log
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
ace activity list # Recent activity (last 7 days)
|
|
110
|
+
ace activity list --days 14 # Activity from last 14 days
|
|
111
|
+
ace activity list --source manual # Filter by source
|
|
112
|
+
ace activity log "Did the thing" # Log new activity
|
|
113
|
+
ace activity log "Meeting" --category <id> # With category
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Contexts
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
ace contexts list # List all contexts
|
|
67
120
|
```
|
|
68
121
|
|
|
69
122
|
## JSON Output
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createRequire as
|
|
4
|
-
`).replace(/^/gm," ".repeat(2))}let U=[`Usage: ${
|
|
5
|
-
`)}padWidth(y
|
|
3
|
+
import{createRequire as I$}from"node:module";var f$=Object.create;var{getPrototypeOf:P$,defineProperty:kc,getOwnPropertyNames:R$}=Object;var G$=Object.prototype.hasOwnProperty;var U$=(c,y,$)=>{$=c!=null?f$(P$(c)):{};let j=y||!c||!c.__esModule?kc($,"default",{value:c,enumerable:!0}):$;for(let f of R$(c))if(!G$.call(j,f))kc(j,f,{get:()=>c[f],enumerable:!0});return j};var C=(c,y)=>()=>(y||c((y={exports:{}}).exports,y),y.exports);var v=I$(import.meta.url);var b=C((L$)=>{class $c extends Error{constructor(c,y,$){super($);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=y,this.exitCode=c,this.nestedError=void 0}}class tc extends $c{constructor(c){super(1,"commander.invalidArgument",c);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}L$.CommanderError=$c;L$.InvalidArgumentError=tc});var r=C((Y$)=>{var{InvalidArgumentError:w$}=b();class uc{constructor(c,y){switch(this.description=y||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,c[0]){case"<":this.required=!0,this._name=c.slice(1,-1);break;case"[":this.required=!1,this._name=c.slice(1,-1);break;default:this.required=!0,this._name=c;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue(c,y){if(y===this.defaultValue||!Array.isArray(y))return[c];return y.concat(c)}default(c,y){return this.defaultValue=c,this.defaultValueDescription=y,this}argParser(c){return this.parseArg=c,this}choices(c){return this.argChoices=c.slice(),this.parseArg=(y,$)=>{if(!this.argChoices.includes(y))throw new w$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(y,$);return y},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function E$(c){let y=c.name()+(c.variadic===!0?"...":"");return c.required?"<"+y+">":"["+y+"]"}Y$.Argument=uc;Y$.humanReadableArgName=E$});var jc=C((F$)=>{var{humanReadableArgName:Z$}=r();class hc{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(c){let y=c.commands.filter((j)=>!j._hidden),$=c._getHelpCommand();if($&&!$._hidden)y.push($);if(this.sortSubcommands)y.sort((j,f)=>{return j.name().localeCompare(f.name())});return y}compareOptions(c,y){let $=(j)=>{return j.short?j.short.replace(/^-/,""):j.long.replace(/^--/,"")};return $(c).localeCompare($(y))}visibleOptions(c){let y=c.options.filter((j)=>!j.hidden),$=c._getHelpOption();if($&&!$.hidden){let j=$.short&&c._findOption($.short),f=$.long&&c._findOption($.long);if(!j&&!f)y.push($);else if($.long&&!f)y.push(c.createOption($.long,$.description));else if($.short&&!j)y.push(c.createOption($.short,$.description))}if(this.sortOptions)y.sort(this.compareOptions);return y}visibleGlobalOptions(c){if(!this.showGlobalOptions)return[];let y=[];for(let $=c.parent;$;$=$.parent){let j=$.options.filter((f)=>!f.hidden);y.push(...j)}if(this.sortOptions)y.sort(this.compareOptions);return y}visibleArguments(c){if(c._argsDescription)c.registeredArguments.forEach((y)=>{y.description=y.description||c._argsDescription[y.name()]||""});if(c.registeredArguments.find((y)=>y.description))return c.registeredArguments;return[]}subcommandTerm(c){let y=c.registeredArguments.map(($)=>Z$($)).join(" ");return c._name+(c._aliases[0]?"|"+c._aliases[0]:"")+(c.options.length?" [options]":"")+(y?" "+y:"")}optionTerm(c){return c.flags}argumentTerm(c){return c.name()}longestSubcommandTermLength(c,y){return y.visibleCommands(c).reduce(($,j)=>{return Math.max($,y.subcommandTerm(j).length)},0)}longestOptionTermLength(c,y){return y.visibleOptions(c).reduce(($,j)=>{return Math.max($,y.optionTerm(j).length)},0)}longestGlobalOptionTermLength(c,y){return y.visibleGlobalOptions(c).reduce(($,j)=>{return Math.max($,y.optionTerm(j).length)},0)}longestArgumentTermLength(c,y){return y.visibleArguments(c).reduce(($,j)=>{return Math.max($,y.argumentTerm(j).length)},0)}commandUsage(c){let y=c._name;if(c._aliases[0])y=y+"|"+c._aliases[0];let $="";for(let j=c.parent;j;j=j.parent)$=j.name()+" "+$;return $+y+" "+c.usage()}commandDescription(c){return c.description()}subcommandDescription(c){return c.summary()||c.description()}optionDescription(c){let y=[];if(c.argChoices)y.push(`choices: ${c.argChoices.map(($)=>JSON.stringify($)).join(", ")}`);if(c.defaultValue!==void 0){if(c.required||c.optional||c.isBoolean()&&typeof c.defaultValue==="boolean")y.push(`default: ${c.defaultValueDescription||JSON.stringify(c.defaultValue)}`)}if(c.presetArg!==void 0&&c.optional)y.push(`preset: ${JSON.stringify(c.presetArg)}`);if(c.envVar!==void 0)y.push(`env: ${c.envVar}`);if(y.length>0)return`${c.description} (${y.join(", ")})`;return c.description}argumentDescription(c){let y=[];if(c.argChoices)y.push(`choices: ${c.argChoices.map(($)=>JSON.stringify($)).join(", ")}`);if(c.defaultValue!==void 0)y.push(`default: ${c.defaultValueDescription||JSON.stringify(c.defaultValue)}`);if(y.length>0){let $=`(${y.join(", ")})`;if(c.description)return`${c.description} ${$}`;return $}return c.description}formatHelp(c,y){let $=y.padWidth(c,y),j=y.helpWidth||80,f=2,P=2;function R(Q,H){if(H){let yc=`${Q.padEnd($+2)}${H}`;return y.wrap(yc,j-2,$+2)}return Q}function G(Q){return Q.join(`
|
|
4
|
+
`).replace(/^/gm," ".repeat(2))}let U=[`Usage: ${y.commandUsage(c)}`,""],q=y.commandDescription(c);if(q.length>0)U=U.concat([y.wrap(q,j,0),""]);let w=y.visibleArguments(c).map((Q)=>{return R(y.argumentTerm(Q),y.argumentDescription(Q))});if(w.length>0)U=U.concat(["Arguments:",G(w),""]);let Y=y.visibleOptions(c).map((Q)=>{return R(y.optionTerm(Q),y.optionDescription(Q))});if(Y.length>0)U=U.concat(["Options:",G(Y),""]);if(this.showGlobalOptions){let Q=y.visibleGlobalOptions(c).map((H)=>{return R(y.optionTerm(H),y.optionDescription(H))});if(Q.length>0)U=U.concat(["Global Options:",G(Q),""])}let Z=y.visibleCommands(c).map((Q)=>{return R(y.subcommandTerm(Q),y.subcommandDescription(Q))});if(Z.length>0)U=U.concat(["Commands:",G(Z),""]);return U.join(`
|
|
5
|
+
`)}padWidth(c,y){return Math.max(y.longestOptionTermLength(c,y),y.longestGlobalOptionTermLength(c,y),y.longestSubcommandTermLength(c,y),y.longestArgumentTermLength(c,y))}wrap(c,y,$,j=40){let P=new RegExp(`[\\n][${" \\f\\t\\v - \uFEFF"}]+`);if(c.match(P))return c;let R=y-$;if(R<j)return c;let G=c.slice(0,$),U=c.slice($).replace(`\r
|
|
6
6
|
`,`
|
|
7
|
-
`),
|
|
8
|
-
|.{1,${
|
|
9
|
-
`)return"";return(
|
|
10
|
-
`)}}
|
|
11
|
-
(Did you mean one of ${
|
|
12
|
-
(Did you mean ${
|
|
13
|
-
- specify the name in Command constructor or using .name()`);if(
|
|
14
|
-
Expecting one of '${
|
|
15
|
-
- already used by option '${
|
|
16
|
-
- if '${
|
|
7
|
+
`),q=" ".repeat($),Y=`\\s${""}`,Z=new RegExp(`
|
|
8
|
+
|.{1,${R-1}}([${Y}]|$)|[^${Y}]+?([${Y}]|$)`,"g"),Q=U.match(Z)||[];return G+Q.map((H,yc)=>{if(H===`
|
|
9
|
+
`)return"";return(yc>0?q:"")+H.trimEnd()}).join(`
|
|
10
|
+
`)}}F$.Help=hc});var fc=C((_$)=>{var{InvalidArgumentError:X$}=b();class vc{constructor(c,y){this.flags=c,this.description=y||"",this.required=c.includes("<"),this.optional=c.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(c),this.mandatory=!1;let $=W$(c);if(this.short=$.shortFlag,this.long=$.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(c,y){return this.defaultValue=c,this.defaultValueDescription=y,this}preset(c){return this.presetArg=c,this}conflicts(c){return this.conflictsWith=this.conflictsWith.concat(c),this}implies(c){let y=c;if(typeof c==="string")y={[c]:!0};return this.implied=Object.assign(this.implied||{},y),this}env(c){return this.envVar=c,this}argParser(c){return this.parseArg=c,this}makeOptionMandatory(c=!0){return this.mandatory=!!c,this}hideHelp(c=!0){return this.hidden=!!c,this}_concatValue(c,y){if(y===this.defaultValue||!Array.isArray(y))return[c];return y.concat(c)}choices(c){return this.argChoices=c.slice(),this.parseArg=(y,$)=>{if(!this.argChoices.includes(y))throw new X$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(y,$);return y},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return H$(this.name().replace(/^no-/,""))}is(c){return this.short===c||this.long===c}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class bc{constructor(c){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,c.forEach((y)=>{if(y.negate)this.negativeOptions.set(y.attributeName(),y);else this.positiveOptions.set(y.attributeName(),y)}),this.negativeOptions.forEach((y,$)=>{if(this.positiveOptions.has($))this.dualOptions.add($)})}valueFromOption(c,y){let $=y.attributeName();if(!this.dualOptions.has($))return!0;let j=this.negativeOptions.get($).presetArg,f=j!==void 0?j:!1;return y.negate===(f===c)}}function H$(c){return c.split("-").reduce((y,$)=>{return y+$[0].toUpperCase()+$.slice(1)})}function W$(c){let y,$,j=c.split(/[ |,]+/);if(j.length>1&&!/^[[<]/.test(j[1]))y=j.shift();if($=j.shift(),!y&&/^-[^-]$/.test($))y=$,$=void 0;return{shortFlag:y,longFlag:$}}_$.Option=vc;_$.DualOptions=bc});var Oc=C((B$)=>{function T$(c,y){if(Math.abs(c.length-y.length)>3)return Math.max(c.length,y.length);let $=[];for(let j=0;j<=c.length;j++)$[j]=[j];for(let j=0;j<=y.length;j++)$[0][j]=j;for(let j=1;j<=y.length;j++)for(let f=1;f<=c.length;f++){let P=1;if(c[f-1]===y[j-1])P=0;else P=1;if($[f][j]=Math.min($[f-1][j]+1,$[f][j-1]+1,$[f-1][j-1]+P),f>1&&j>1&&c[f-1]===y[j-2]&&c[f-2]===y[j-1])$[f][j]=Math.min($[f][j],$[f-2][j-2]+1)}return $[c.length][y.length]}function C$(c,y){if(!y||y.length===0)return"";y=Array.from(new Set(y));let $=c.startsWith("--");if($)c=c.slice(2),y=y.map((R)=>R.slice(2));let j=[],f=3,P=0.4;if(y.forEach((R)=>{if(R.length<=1)return;let G=T$(c,R),U=Math.max(c.length,R.length);if((U-G)/U>P){if(G<f)f=G,j=[R];else if(G===f)j.push(R)}}),j.sort((R,G)=>R.localeCompare(G)),$)j=j.map((R)=>`--${R}`);if(j.length>1)return`
|
|
11
|
+
(Did you mean one of ${j.join(", ")}?)`;if(j.length===1)return`
|
|
12
|
+
(Did you mean ${j[0]}?)`;return""}B$.suggestSimilar=C$});var rc=C((t$)=>{var N$=v("node:events").EventEmitter,Pc=v("node:child_process"),X=v("node:path"),Rc=v("node:fs"),J=v("node:process"),{Argument:V$,humanReadableArgName:A$}=r(),{CommanderError:Gc}=b(),{Help:D$}=jc(),{Option:sc,DualOptions:k$}=fc(),{suggestSimilar:gc}=Oc();class Uc extends N${constructor(c){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=c||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(y)=>J.stdout.write(y),writeErr:(y)=>J.stderr.write(y),getOutHelpWidth:()=>J.stdout.isTTY?J.stdout.columns:void 0,getErrHelpWidth:()=>J.stderr.isTTY?J.stderr.columns:void 0,outputError:(y,$)=>$(y)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(c){return this._outputConfiguration=c._outputConfiguration,this._helpOption=c._helpOption,this._helpCommand=c._helpCommand,this._helpConfiguration=c._helpConfiguration,this._exitCallback=c._exitCallback,this._storeOptionsAsProperties=c._storeOptionsAsProperties,this._combineFlagAndOptionalValue=c._combineFlagAndOptionalValue,this._allowExcessArguments=c._allowExcessArguments,this._enablePositionalOptions=c._enablePositionalOptions,this._showHelpAfterError=c._showHelpAfterError,this._showSuggestionAfterError=c._showSuggestionAfterError,this}_getCommandAndAncestors(){let c=[];for(let y=this;y;y=y.parent)c.push(y);return c}command(c,y,$){let j=y,f=$;if(typeof j==="object"&&j!==null)f=j,j=null;f=f||{};let[,P,R]=c.match(/([^ ]+) *(.*)/),G=this.createCommand(P);if(j)G.description(j),G._executableHandler=!0;if(f.isDefault)this._defaultCommandName=G._name;if(G._hidden=!!(f.noHelp||f.hidden),G._executableFile=f.executableFile||null,R)G.arguments(R);if(this._registerCommand(G),G.parent=this,G.copyInheritedSettings(this),j)return this;return G}createCommand(c){return new Uc(c)}createHelp(){return Object.assign(new D$,this.configureHelp())}configureHelp(c){if(c===void 0)return this._helpConfiguration;return this._helpConfiguration=c,this}configureOutput(c){if(c===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,c),this}showHelpAfterError(c=!0){if(typeof c!=="string")c=!!c;return this._showHelpAfterError=c,this}showSuggestionAfterError(c=!0){return this._showSuggestionAfterError=!!c,this}addCommand(c,y){if(!c._name)throw Error(`Command passed to .addCommand() must have a name
|
|
13
|
+
- specify the name in Command constructor or using .name()`);if(y=y||{},y.isDefault)this._defaultCommandName=c._name;if(y.noHelp||y.hidden)c._hidden=!0;return this._registerCommand(c),c.parent=this,c._checkForBrokenPassThrough(),this}createArgument(c,y){return new V$(c,y)}argument(c,y,$,j){let f=this.createArgument(c,y);if(typeof $==="function")f.default(j).argParser($);else f.default($);return this.addArgument(f),this}arguments(c){return c.trim().split(/ +/).forEach((y)=>{this.argument(y)}),this}addArgument(c){let y=this.registeredArguments.slice(-1)[0];if(y&&y.variadic)throw Error(`only the last argument can be variadic '${y.name()}'`);if(c.required&&c.defaultValue!==void 0&&c.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${c.name()}'`);return this.registeredArguments.push(c),this}helpCommand(c,y){if(typeof c==="boolean")return this._addImplicitHelpCommand=c,this;c=c??"help [command]";let[,$,j]=c.match(/([^ ]+) *(.*)/),f=y??"display help for command",P=this.createCommand($);if(P.helpOption(!1),j)P.arguments(j);if(f)P.description(f);return this._addImplicitHelpCommand=!0,this._helpCommand=P,this}addHelpCommand(c,y){if(typeof c!=="object")return this.helpCommand(c,y),this;return this._addImplicitHelpCommand=!0,this._helpCommand=c,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(c,y){let $=["preSubcommand","preAction","postAction"];if(!$.includes(c))throw Error(`Unexpected value for event passed to hook : '${c}'.
|
|
14
|
+
Expecting one of '${$.join("', '")}'`);if(this._lifeCycleHooks[c])this._lifeCycleHooks[c].push(y);else this._lifeCycleHooks[c]=[y];return this}exitOverride(c){if(c)this._exitCallback=c;else this._exitCallback=(y)=>{if(y.code!=="commander.executeSubCommandAsync")throw y};return this}_exit(c,y,$){if(this._exitCallback)this._exitCallback(new Gc(c,y,$));J.exit(c)}action(c){let y=($)=>{let j=this.registeredArguments.length,f=$.slice(0,j);if(this._storeOptionsAsProperties)f[j]=this;else f[j]=this.opts();return f.push(this),c.apply(this,f)};return this._actionHandler=y,this}createOption(c,y){return new sc(c,y)}_callParseArg(c,y,$,j){try{return c.parseArg(y,$)}catch(f){if(f.code==="commander.invalidArgument"){let P=`${j} ${f.message}`;this.error(P,{exitCode:f.exitCode,code:f.code})}throw f}}_registerOption(c){let y=c.short&&this._findOption(c.short)||c.long&&this._findOption(c.long);if(y){let $=c.long&&this._findOption(c.long)?c.long:c.short;throw Error(`Cannot add option '${c.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${$}'
|
|
15
|
+
- already used by option '${y.flags}'`)}this.options.push(c)}_registerCommand(c){let y=(j)=>{return[j.name()].concat(j.aliases())},$=y(c).find((j)=>this._findCommand(j));if($){let j=y(this._findCommand($)).join("|"),f=y(c).join("|");throw Error(`cannot add command '${f}' as already have command '${j}'`)}this.commands.push(c)}addOption(c){this._registerOption(c);let y=c.name(),$=c.attributeName();if(c.negate){let f=c.long.replace(/^--no-/,"--");if(!this._findOption(f))this.setOptionValueWithSource($,c.defaultValue===void 0?!0:c.defaultValue,"default")}else if(c.defaultValue!==void 0)this.setOptionValueWithSource($,c.defaultValue,"default");let j=(f,P,R)=>{if(f==null&&c.presetArg!==void 0)f=c.presetArg;let G=this.getOptionValue($);if(f!==null&&c.parseArg)f=this._callParseArg(c,f,G,P);else if(f!==null&&c.variadic)f=c._concatValue(f,G);if(f==null)if(c.negate)f=!1;else if(c.isBoolean()||c.optional)f=!0;else f="";this.setOptionValueWithSource($,f,R)};if(this.on("option:"+y,(f)=>{let P=`error: option '${c.flags}' argument '${f}' is invalid.`;j(f,P,"cli")}),c.envVar)this.on("optionEnv:"+y,(f)=>{let P=`error: option '${c.flags}' value '${f}' from env '${c.envVar}' is invalid.`;j(f,P,"env")});return this}_optionEx(c,y,$,j,f){if(typeof y==="object"&&y instanceof sc)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let P=this.createOption(y,$);if(P.makeOptionMandatory(!!c.mandatory),typeof j==="function")P.default(f).argParser(j);else if(j instanceof RegExp){let R=j;j=(G,U)=>{let q=R.exec(G);return q?q[0]:U},P.default(f).argParser(j)}else P.default(j);return this.addOption(P)}option(c,y,$,j){return this._optionEx({},c,y,$,j)}requiredOption(c,y,$,j){return this._optionEx({mandatory:!0},c,y,$,j)}combineFlagAndOptionalValue(c=!0){return this._combineFlagAndOptionalValue=!!c,this}allowUnknownOption(c=!0){return this._allowUnknownOption=!!c,this}allowExcessArguments(c=!0){return this._allowExcessArguments=!!c,this}enablePositionalOptions(c=!0){return this._enablePositionalOptions=!!c,this}passThroughOptions(c=!0){return this._passThroughOptions=!!c,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(c=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!c,this}getOptionValue(c){if(this._storeOptionsAsProperties)return this[c];return this._optionValues[c]}setOptionValue(c,y){return this.setOptionValueWithSource(c,y,void 0)}setOptionValueWithSource(c,y,$){if(this._storeOptionsAsProperties)this[c]=y;else this._optionValues[c]=y;return this._optionValueSources[c]=$,this}getOptionValueSource(c){return this._optionValueSources[c]}getOptionValueSourceWithGlobals(c){let y;return this._getCommandAndAncestors().forEach(($)=>{if($.getOptionValueSource(c)!==void 0)y=$.getOptionValueSource(c)}),y}_prepareUserArgs(c,y){if(c!==void 0&&!Array.isArray(c))throw Error("first parameter to parse must be array or undefined");if(y=y||{},c===void 0&&y.from===void 0){if(J.versions?.electron)y.from="electron";let j=J.execArgv??[];if(j.includes("-e")||j.includes("--eval")||j.includes("-p")||j.includes("--print"))y.from="eval"}if(c===void 0)c=J.argv;this.rawArgs=c.slice();let $;switch(y.from){case void 0:case"node":this._scriptPath=c[1],$=c.slice(2);break;case"electron":if(J.defaultApp)this._scriptPath=c[1],$=c.slice(2);else $=c.slice(1);break;case"user":$=c.slice(0);break;case"eval":$=c.slice(1);break;default:throw Error(`unexpected parse option { from: '${y.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",$}parse(c,y){let $=this._prepareUserArgs(c,y);return this._parseCommand([],$),this}async parseAsync(c,y){let $=this._prepareUserArgs(c,y);return await this._parseCommand([],$),this}_executeSubCommand(c,y){y=y.slice();let $=!1,j=[".js",".ts",".tsx",".mjs",".cjs"];function f(q,w){let Y=X.resolve(q,w);if(Rc.existsSync(Y))return Y;if(j.includes(X.extname(w)))return;let Z=j.find((Q)=>Rc.existsSync(`${Y}${Q}`));if(Z)return`${Y}${Z}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let P=c._executableFile||`${this._name}-${c._name}`,R=this._executableDir||"";if(this._scriptPath){let q;try{q=Rc.realpathSync(this._scriptPath)}catch(w){q=this._scriptPath}R=X.resolve(X.dirname(q),R)}if(R){let q=f(R,P);if(!q&&!c._executableFile&&this._scriptPath){let w=X.basename(this._scriptPath,X.extname(this._scriptPath));if(w!==this._name)q=f(R,`${w}-${c._name}`)}P=q||P}$=j.includes(X.extname(P));let G;if(J.platform!=="win32")if($)y.unshift(P),y=mc(J.execArgv).concat(y),G=Pc.spawn(J.argv[0],y,{stdio:"inherit"});else G=Pc.spawn(P,y,{stdio:"inherit"});else y.unshift(P),y=mc(J.execArgv).concat(y),G=Pc.spawn(J.execPath,y,{stdio:"inherit"});if(!G.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((w)=>{J.on(w,()=>{if(G.killed===!1&&G.exitCode===null)G.kill(w)})});let U=this._exitCallback;G.on("close",(q)=>{if(q=q??1,!U)J.exit(q);else U(new Gc(q,"commander.executeSubCommandAsync","(close)"))}),G.on("error",(q)=>{if(q.code==="ENOENT"){let w=R?`searched for local subcommand relative to directory '${R}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Y=`'${P}' does not exist
|
|
16
|
+
- if '${c._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
17
17
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
18
|
-
- ${
|
|
18
|
+
- ${w}`;throw Error(Y)}else if(q.code==="EACCES")throw Error(`'${P}' not executable`);if(!U)J.exit(1);else{let w=new Gc(1,"commander.executeSubCommandAsync","(error)");w.nestedError=q,U(w)}}),this.runningCommand=G}_dispatchSubcommand(c,y,$){let j=this._findCommand(c);if(!j)this.help({error:!0});let f;return f=this._chainOrCallSubCommandHook(f,j,"preSubcommand"),f=this._chainOrCall(f,()=>{if(j._executableHandler)this._executeSubCommand(j,y.concat($));else return j._parseCommand(y,$)}),f}_dispatchHelpCommand(c){if(!c)this.help();let y=this._findCommand(c);if(y&&!y._executableHandler)y.help();return this._dispatchSubcommand(c,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((c,y)=>{if(c.required&&this.args[y]==null)this.missingArgument(c.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let c=($,j,f)=>{let P=j;if(j!==null&&$.parseArg){let R=`error: command-argument value '${j}' is invalid for argument '${$.name()}'.`;P=this._callParseArg($,j,f,R)}return P};this._checkNumberOfArguments();let y=[];this.registeredArguments.forEach(($,j)=>{let f=$.defaultValue;if($.variadic){if(j<this.args.length){if(f=this.args.slice(j),$.parseArg)f=f.reduce((P,R)=>{return c($,R,P)},$.defaultValue)}else if(f===void 0)f=[]}else if(j<this.args.length){if(f=this.args[j],$.parseArg)f=c($,f,$.defaultValue)}y[j]=f}),this.processedArgs=y}_chainOrCall(c,y){if(c&&c.then&&typeof c.then==="function")return c.then(()=>y());return y()}_chainOrCallHooks(c,y){let $=c,j=[];if(this._getCommandAndAncestors().reverse().filter((f)=>f._lifeCycleHooks[y]!==void 0).forEach((f)=>{f._lifeCycleHooks[y].forEach((P)=>{j.push({hookedCommand:f,callback:P})})}),y==="postAction")j.reverse();return j.forEach((f)=>{$=this._chainOrCall($,()=>{return f.callback(f.hookedCommand,this)})}),$}_chainOrCallSubCommandHook(c,y,$){let j=c;if(this._lifeCycleHooks[$]!==void 0)this._lifeCycleHooks[$].forEach((f)=>{j=this._chainOrCall(j,()=>{return f(this,y)})});return j}_parseCommand(c,y){let $=this.parseOptions(y);if(this._parseOptionsEnv(),this._parseOptionsImplied(),c=c.concat($.operands),y=$.unknown,this.args=c.concat(y),c&&this._findCommand(c[0]))return this._dispatchSubcommand(c[0],c.slice(1),y);if(this._getHelpCommand()&&c[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(c[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(y),this._dispatchSubcommand(this._defaultCommandName,c,y);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested($.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let j=()=>{if($.unknown.length>0)this.unknownOption($.unknown[0])},f=`command:${this.name()}`;if(this._actionHandler){j(),this._processArguments();let P;if(P=this._chainOrCallHooks(P,"preAction"),P=this._chainOrCall(P,()=>this._actionHandler(this.processedArgs)),this.parent)P=this._chainOrCall(P,()=>{this.parent.emit(f,c,y)});return P=this._chainOrCallHooks(P,"postAction"),P}if(this.parent&&this.parent.listenerCount(f))j(),this._processArguments(),this.parent.emit(f,c,y);else if(c.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",c,y);if(this.listenerCount("command:*"))this.emit("command:*",c,y);else if(this.commands.length)this.unknownCommand();else j(),this._processArguments()}else if(this.commands.length)j(),this.help({error:!0});else j(),this._processArguments()}_findCommand(c){if(!c)return;return this.commands.find((y)=>y._name===c||y._aliases.includes(c))}_findOption(c){return this.options.find((y)=>y.is(c))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((c)=>{c.options.forEach((y)=>{if(y.mandatory&&c.getOptionValue(y.attributeName())===void 0)c.missingMandatoryOptionValue(y)})})}_checkForConflictingLocalOptions(){let c=this.options.filter(($)=>{let j=$.attributeName();if(this.getOptionValue(j)===void 0)return!1;return this.getOptionValueSource(j)!=="default"});c.filter(($)=>$.conflictsWith.length>0).forEach(($)=>{let j=c.find((f)=>$.conflictsWith.includes(f.attributeName()));if(j)this._conflictingOption($,j)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((c)=>{c._checkForConflictingLocalOptions()})}parseOptions(c){let y=[],$=[],j=y,f=c.slice();function P(G){return G.length>1&&G[0]==="-"}let R=null;while(f.length){let G=f.shift();if(G==="--"){if(j===$)j.push(G);j.push(...f);break}if(R&&!P(G)){this.emit(`option:${R.name()}`,G);continue}if(R=null,P(G)){let U=this._findOption(G);if(U){if(U.required){let q=f.shift();if(q===void 0)this.optionMissingArgument(U);this.emit(`option:${U.name()}`,q)}else if(U.optional){let q=null;if(f.length>0&&!P(f[0]))q=f.shift();this.emit(`option:${U.name()}`,q)}else this.emit(`option:${U.name()}`);R=U.variadic?U:null;continue}}if(G.length>2&&G[0]==="-"&&G[1]!=="-"){let U=this._findOption(`-${G[1]}`);if(U){if(U.required||U.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${U.name()}`,G.slice(2));else this.emit(`option:${U.name()}`),f.unshift(`-${G.slice(2)}`);continue}}if(/^--[^=]+=/.test(G)){let U=G.indexOf("="),q=this._findOption(G.slice(0,U));if(q&&(q.required||q.optional)){this.emit(`option:${q.name()}`,G.slice(U+1));continue}}if(P(G))j=$;if((this._enablePositionalOptions||this._passThroughOptions)&&y.length===0&&$.length===0){if(this._findCommand(G)){if(y.push(G),f.length>0)$.push(...f);break}else if(this._getHelpCommand()&&G===this._getHelpCommand().name()){if(y.push(G),f.length>0)y.push(...f);break}else if(this._defaultCommandName){if($.push(G),f.length>0)$.push(...f);break}}if(this._passThroughOptions){if(j.push(G),f.length>0)j.push(...f);break}j.push(G)}return{operands:y,unknown:$}}opts(){if(this._storeOptionsAsProperties){let c={},y=this.options.length;for(let $=0;$<y;$++){let j=this.options[$].attributeName();c[j]=j===this._versionOptionName?this._version:this[j]}return c}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((c,y)=>Object.assign(c,y.opts()),{})}error(c,y){if(this._outputConfiguration.outputError(`${c}
|
|
19
19
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
20
20
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
21
|
-
`),this.outputHelp({error:!0});let
|
|
22
|
-
`),this._exit(0,"commander.version",
|
|
23
|
-
Expecting one of '${
|
|
24
|
-
`)}),this}_outputHelpIfRequested(
|
|
25
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as
|
|
26
|
-
`);let
|
|
27
|
-
${
|
|
28
|
-
`)}`;return
|
|
29
|
-
`)}function
|
|
30
|
-
${
|
|
31
|
-
`)}`;return
|
|
32
|
-
`)}function c
|
|
33
|
-
${
|
|
34
|
-
`)}`),
|
|
21
|
+
`),this.outputHelp({error:!0});let $=y||{},j=$.exitCode||1,f=$.code||"commander.error";this._exit(j,f,c)}_parseOptionsEnv(){this.options.forEach((c)=>{if(c.envVar&&c.envVar in J.env){let y=c.attributeName();if(this.getOptionValue(y)===void 0||["default","config","env"].includes(this.getOptionValueSource(y)))if(c.required||c.optional)this.emit(`optionEnv:${c.name()}`,J.env[c.envVar]);else this.emit(`optionEnv:${c.name()}`)}})}_parseOptionsImplied(){let c=new k$(this.options),y=($)=>{return this.getOptionValue($)!==void 0&&!["default","implied"].includes(this.getOptionValueSource($))};this.options.filter(($)=>$.implied!==void 0&&y($.attributeName())&&c.valueFromOption(this.getOptionValue($.attributeName()),$)).forEach(($)=>{Object.keys($.implied).filter((j)=>!y(j)).forEach((j)=>{this.setOptionValueWithSource(j,$.implied[j],"implied")})})}missingArgument(c){let y=`error: missing required argument '${c}'`;this.error(y,{code:"commander.missingArgument"})}optionMissingArgument(c){let y=`error: option '${c.flags}' argument missing`;this.error(y,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(c){let y=`error: required option '${c.flags}' not specified`;this.error(y,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(c,y){let $=(P)=>{let R=P.attributeName(),G=this.getOptionValue(R),U=this.options.find((w)=>w.negate&&R===w.attributeName()),q=this.options.find((w)=>!w.negate&&R===w.attributeName());if(U&&(U.presetArg===void 0&&G===!1||U.presetArg!==void 0&&G===U.presetArg))return U;return q||P},j=(P)=>{let R=$(P),G=R.attributeName();if(this.getOptionValueSource(G)==="env")return`environment variable '${R.envVar}'`;return`option '${R.flags}'`},f=`error: ${j(c)} cannot be used with ${j(y)}`;this.error(f,{code:"commander.conflictingOption"})}unknownOption(c){if(this._allowUnknownOption)return;let y="";if(c.startsWith("--")&&this._showSuggestionAfterError){let j=[],f=this;do{let P=f.createHelp().visibleOptions(f).filter((R)=>R.long).map((R)=>R.long);j=j.concat(P),f=f.parent}while(f&&!f._enablePositionalOptions);y=gc(c,j)}let $=`error: unknown option '${c}'${y}`;this.error($,{code:"commander.unknownOption"})}_excessArguments(c){if(this._allowExcessArguments)return;let y=this.registeredArguments.length,$=y===1?"":"s",f=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${y} argument${$} but got ${c.length}.`;this.error(f,{code:"commander.excessArguments"})}unknownCommand(){let c=this.args[0],y="";if(this._showSuggestionAfterError){let j=[];this.createHelp().visibleCommands(this).forEach((f)=>{if(j.push(f.name()),f.alias())j.push(f.alias())}),y=gc(c,j)}let $=`error: unknown command '${c}'${y}`;this.error($,{code:"commander.unknownCommand"})}version(c,y,$){if(c===void 0)return this._version;this._version=c,y=y||"-V, --version",$=$||"output the version number";let j=this.createOption(y,$);return this._versionOptionName=j.attributeName(),this._registerOption(j),this.on("option:"+j.name(),()=>{this._outputConfiguration.writeOut(`${c}
|
|
22
|
+
`),this._exit(0,"commander.version",c)}),this}description(c,y){if(c===void 0&&y===void 0)return this._description;if(this._description=c,y)this._argsDescription=y;return this}summary(c){if(c===void 0)return this._summary;return this._summary=c,this}alias(c){if(c===void 0)return this._aliases[0];let y=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)y=this.commands[this.commands.length-1];if(c===y._name)throw Error("Command alias can't be the same as its name");let $=this.parent?._findCommand(c);if($){let j=[$.name()].concat($.aliases()).join("|");throw Error(`cannot add alias '${c}' to command '${this.name()}' as already have command '${j}'`)}return y._aliases.push(c),this}aliases(c){if(c===void 0)return this._aliases;return c.forEach((y)=>this.alias(y)),this}usage(c){if(c===void 0){if(this._usage)return this._usage;let y=this.registeredArguments.map(($)=>{return A$($)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?y:[]).join(" ")}return this._usage=c,this}name(c){if(c===void 0)return this._name;return this._name=c,this}nameFromFilename(c){return this._name=X.basename(c,X.extname(c)),this}executableDir(c){if(c===void 0)return this._executableDir;return this._executableDir=c,this}helpInformation(c){let y=this.createHelp();if(y.helpWidth===void 0)y.helpWidth=c&&c.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return y.formatHelp(this,y)}_getHelpContext(c){c=c||{};let y={error:!!c.error},$;if(y.error)$=(j)=>this._outputConfiguration.writeErr(j);else $=(j)=>this._outputConfiguration.writeOut(j);return y.write=c.write||$,y.command=this,y}outputHelp(c){let y;if(typeof c==="function")y=c,c=void 0;let $=this._getHelpContext(c);this._getCommandAndAncestors().reverse().forEach((f)=>f.emit("beforeAllHelp",$)),this.emit("beforeHelp",$);let j=this.helpInformation($);if(y){if(j=y(j),typeof j!=="string"&&!Buffer.isBuffer(j))throw Error("outputHelp callback must return a string or a Buffer")}if($.write(j),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",$),this._getCommandAndAncestors().forEach((f)=>f.emit("afterAllHelp",$))}helpOption(c,y){if(typeof c==="boolean"){if(c)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return c=c??"-h, --help",y=y??"display help for command",this._helpOption=this.createOption(c,y),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(c){return this._helpOption=c,this}help(c){this.outputHelp(c);let y=J.exitCode||0;if(y===0&&c&&typeof c!=="function"&&c.error)y=1;this._exit(y,"commander.help","(outputHelp)")}addHelpText(c,y){let $=["beforeAll","before","after","afterAll"];if(!$.includes(c))throw Error(`Unexpected value for position to addHelpText.
|
|
23
|
+
Expecting one of '${$.join("', '")}'`);let j=`${c}Help`;return this.on(j,(f)=>{let P;if(typeof y==="function")P=y({error:f.error,command:f.command});else P=y;if(P)f.write(`${P}
|
|
24
|
+
`)}),this}_outputHelpIfRequested(c){let y=this._getHelpOption();if(y&&c.find((j)=>y.is(j)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function mc(c){return c.map((y)=>{if(!y.startsWith("--inspect"))return y;let $,j="127.0.0.1",f="9229",P;if((P=y.match(/^(--inspect(-brk)?)$/))!==null)$=P[1];else if((P=y.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if($=P[1],/^\d+$/.test(P[3]))f=P[3];else j=P[3];else if((P=y.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)$=P[1],j=P[3],f=P[4];if($&&f!=="0")return`${$}=${j}:${parseInt(f)+1}`;return y})}t$.Command=Uc});var ac=C((b$)=>{var{Argument:lc}=r(),{Command:Ic}=rc(),{CommanderError:h$,InvalidArgumentError:dc}=b(),{Help:v$}=jc(),{Option:ec}=fc();b$.program=new Ic;b$.createCommand=(c)=>new Ic(c);b$.createOption=(c,y)=>new ec(c,y);b$.createArgument=(c,y)=>new lc(c,y);b$.Command=Ic;b$.Option=ec;b$.Argument=lc;b$.Help=v$;b$.CommanderError=h$;b$.InvalidArgumentError=dc;b$.InvalidOptionArgumentError=dc});var ic=U$(ac(),1),{program:F,createCommand:$f,createArgument:jf,createOption:ff,CommanderError:Pf,InvalidArgumentError:Rf,InvalidOptionArgumentError:Gf,Command:Uf,Argument:If,Option:Lf,Help:Sf}=ic.default;var nc="0.3.0";import{homedir as p$}from"os";import{join as oc}from"path";import{existsSync as Lc,mkdirSync as cj,readFileSync as yj,writeFileSync as $j,unlinkSync as jj}from"fs";function pc(){let c=process.env.ACE_TEST_HOME??p$();return oc(c,".ace")}function Sc(){return oc(pc(),"credentials.json")}var cy="https://aceisyourassistant.com",fj=process.env.DEBUG==="true"||process.env.ACE_DEBUG==="true";function B(c,...y){if(fj)console.error(`[ace-cli debug] ${c}`,...y)}function Pj(){let c=pc();if(!Lc(c))cj(c,{recursive:!0,mode:448})}function x(){let c=process.env.ACE_TOKEN;if(c)return B("Using ACE_TOKEN environment variable"),{apiUrl:process.env.ACE_API_URL??cy,token:c,expiresAt:null,userId:"env-token",userEmail:"ACE_TOKEN"};try{let y=Sc();if(!Lc(y))return B("Credentials file does not exist:",y),null;let $=yj(y,"utf-8"),j=JSON.parse($);if(j.expiresAt&&new Date(j.expiresAt)<new Date)return B("Token expired at:",j.expiresAt),null;return j}catch(y){return B("Error reading credentials:",y),null}}function qc(c){Pj();let y=Sc();$j(y,JSON.stringify(c,null,2),{mode:384}),B("Credentials saved to:",y)}function wc(){try{let c=Sc();if(Lc(c))return jj(c),B("Credentials cleared"),!0;return!1}catch(c){return B("Error clearing credentials:",c),!1}}function O(){return x()?.apiUrl??process.env.ACE_API_URL??cy}function l(){return!!process.env.ACE_TOKEN}import _c from"node:process";import{Buffer as qy}from"node:buffer";import wy from"node:path";import{fileURLToPath as xj}from"node:url";import{promisify as Nj}from"node:util";import Ey from"node:child_process";import Vj,{constants as Aj}from"node:fs/promises";import fy from"node:process";import Py,{constants as qj}from"node:fs/promises";import jy from"node:process";import Lj from"node:os";import Sj from"node:fs";import Uj from"node:fs";import yy from"node:fs";var Ec;function Rj(){try{return yy.statSync("/.dockerenv"),!0}catch{return!1}}function Gj(){try{return yy.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function Yc(){if(Ec===void 0)Ec=Rj()||Gj();return Ec}var Qc,Ij=()=>{try{return Uj.statSync("/run/.containerenv"),!0}catch{return!1}};function k(){if(Qc===void 0)Qc=Ij()||Yc();return Qc}var $y=()=>{if(jy.platform!=="linux")return!1;if(Lj.release().toLowerCase().includes("microsoft")){if(k())return!1;return!0}try{return Sj.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!k():!1}catch{return!1}},W=jy.env.__IS_WSL_TEST__?$y:$y();var wj=(()=>{let y;return async function(){if(y)return y;let $="/etc/wsl.conf",j=!1;try{await Py.access($,qj.F_OK),j=!0}catch{}if(!j)return"/mnt/";let f=await Py.readFile($,{encoding:"utf8"}),P=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(f);if(!P)return"/mnt/";return y=P.groups.mountPoint.trim(),y=y.endsWith("/")?y:`${y}/`,y}})(),Ej=async()=>{return`${await wj()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},Jc=async()=>{if(W)return Ej();return`${fy.env.SYSTEMROOT||fy.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`};function _(c,y,$){let j=(f)=>Object.defineProperty(c,y,{value:f,enumerable:!0,writable:!0});return Object.defineProperty(c,y,{configurable:!0,enumerable:!0,get(){let f=$();return j(f),f},set(f){j(f)}}),c}import{promisify as Kj}from"node:util";import Hc from"node:process";import{execFile as Tj}from"node:child_process";import{promisify as Yj}from"node:util";import Qj from"node:process";import{execFile as Jj}from"node:child_process";var Zj=Yj(Jj);async function Zc(){if(Qj.platform!=="darwin")throw Error("macOS only");let{stdout:c}=await Zj("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),$=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(c)?.groups.id??"com.apple.Safari";if($==="com.apple.safari")return"com.apple.Safari";return $}import Fj from"node:process";import{promisify as zj}from"node:util";import{execFile as Xj,execFileSync as Of}from"node:child_process";var Hj=zj(Xj);async function Ry(c,{humanReadableOutput:y=!0,signal:$}={}){if(Fj.platform!=="darwin")throw Error("macOS only");let j=y?[]:["-ss"],f={};if($)f.signal=$;let{stdout:P}=await Hj("osascript",["-e",c,j],f);return P.trim()}async function Fc(c){return Ry(`tell application "Finder" to set app_path to application file id "${c}" as string
|
|
25
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as Wj}from"node:util";import{execFile as _j}from"node:child_process";var Mj=Wj(_j),Gy={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},df=new Map(Object.entries(Gy));class zc extends Error{}async function Xc(c=Mj){let{stdout:y}=await c("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),$=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(y);if(!$)throw new zc(`Cannot find Windows browser in stdout: ${JSON.stringify(y)}`);let{id:j}=$.groups,f=Gy[j];if(!f)throw new zc(`Unknown browser ID: ${j}`);return f}var Cj=Kj(Tj),Bj=(c)=>c.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(y)=>y.toUpperCase());async function Wc(){if(Hc.platform==="darwin"){let c=await Zc();return{name:await Fc(c),id:c}}if(Hc.platform==="linux"){let{stdout:c}=await Cj("xdg-mime",["query","default","x-scheme-handler/http"]),y=c.trim();return{name:Bj(y.replace(/.desktop$/,"").replace("-"," ")),id:y}}if(Hc.platform==="win32")return Xc();throw Error("Only macOS, Linux, and Windows are supported")}var Dj=Nj(Ey.execFile),Mc=wy.dirname(xj(import.meta.url)),Uy=wy.join(Mc,"xdg-open"),{platform:t,arch:Iy}=_c;async function kj(){let c=await Jc(),y=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,$=qy.from(y,"utf16le").toString("base64"),{stdout:j}=await Dj(c,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",$],{encoding:"utf8"}),f=j.trim(),P={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return P[f]?{id:P[f]}:{}}var Ly=async(c,y)=>{let $;for(let j of c)try{return await y(j)}catch(f){$=f}throw $},d=async(c)=>{if(c={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...c},Array.isArray(c.app))return Ly(c.app,(G)=>d({...c,app:G}));let{name:y,arguments:$=[]}=c.app??{};if($=[...$],Array.isArray(y))return Ly(y,(G)=>d({...c,app:{name:G,arguments:$}}));if(y==="browser"||y==="browserPrivate"){let G={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},U={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},q=W?await kj():await Wc();if(q.id in G){let w=G[q.id];if(y==="browserPrivate")$.push(U[w]);return d({...c,app:{name:N[w],arguments:$}})}throw Error(`${q.name} is not supported as a default browser`)}let j,f=[],P={};if(t==="darwin"){if(j="open",c.wait)f.push("--wait-apps");if(c.background)f.push("--background");if(c.newInstance)f.push("--new");if(y)f.push("-a",y)}else if(t==="win32"||W&&!k()&&!y){if(j=await Jc(),f.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),!W)P.windowsVerbatimArguments=!0;let G=["Start"];if(c.wait)G.push("-Wait");if(y){if(G.push(`"\`"${y}\`""`),c.target)$.push(c.target)}else if(c.target)G.push(`"${c.target}"`);if($.length>0)$=$.map((U)=>`"\`"${U}\`""`),G.push("-ArgumentList",$.join(","));c.target=qy.from(G.join(" "),"utf16le").toString("base64")}else{if(y)j=y;else{let G=!Mc||Mc==="/",U=!1;try{await Vj.access(Uy,Aj.X_OK),U=!0}catch{}j=_c.versions.electron??(t==="android"||G||!U)?"xdg-open":Uy}if($.length>0)f.push(...$);if(!c.wait)P.stdio="ignore",P.detached=!0}if(t==="darwin"&&$.length>0)f.push("--args",...$);if(c.target)f.push(c.target);let R=Ey.spawn(j,f,P);if(c.wait)return new Promise((G,U)=>{R.once("error",U),R.once("close",(q)=>{if(!c.allowNonzeroExitCode&&q>0){U(Error(`Exited with code ${q}`));return}G(R)})});return R.unref(),R},tj=(c,y)=>{if(typeof c!=="string")throw TypeError("Expected a `target`");return d({...y,target:c})};function Sy(c){if(typeof c==="string"||Array.isArray(c))return c;let{[Iy]:y}=c;if(!y)throw Error(`${Iy} is not supported`);return y}function e({[t]:c},{wsl:y}){if(y&&W)return Sy(y);if(!c)throw Error(`${t} is not supported`);return Sy(c)}var N={};_(N,"chrome",()=>e({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));_(N,"brave",()=>e({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));_(N,"firefox",()=>e({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));_(N,"edge",()=>e({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));_(N,"browser",()=>"browser");_(N,"browserPrivate",()=>"browserPrivate");var Yy=tj;var uj=2000,hj=600;async function Kc(c){let y=c??O();console.log(`Initiating authentication...
|
|
26
|
+
`);let $=await fetch(`${y}/api/cli-auth/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!$.ok){let Y=await $.text();throw Error(`Failed to initiate auth: ${Y}`)}let{deviceCode:j,userCode:f,verificationUrl:P,interval:R,expiresIn:G}=await $.json(),U=(R||uj/1000)*1000,q=Math.ceil((G||hj)/(U/1000));console.log("Opening browser to authenticate..."),console.log(""),console.log(` Your code: ${f}`),console.log(""),console.log(` Or visit: ${P}`),console.log(""),await Yy(P),console.log("Waiting for authorization...");let w=0;while(w<q){await vj(U),w++;try{let Y=await fetch(`${y}/api/cli-auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:j})});if(!Y.ok){if(Y.status===400)continue;throw Error(`Poll failed: ${await Y.text()}`)}let Z=await Y.json();if(Z.status==="authorized"&&Z.token){let Q={apiUrl:y,token:Z.token.token,expiresAt:Z.token.expiresAt,userId:Z.token.userId,userEmail:Z.token.userEmail};qc(Q),console.log(""),console.log(`Authenticated as ${Z.token.userEmail}`),console.log(""),console.log("You can now use ace commands. Try:"),console.log(" ace orient"),console.log(' ace capture "My new task"');return}if(Z.status==="expired")throw Error("Authentication code expired. Please try again.")}catch(Y){if(Y instanceof TypeError)continue;throw Y}}throw Error("Authentication timed out. Please try again.")}function vj(c){return new Promise((y)=>setTimeout(y,c))}function Tc(c,y){let $=y?new Date(y):new Date,j=c.toLowerCase().trim().replace(/\s+/g,""),f,P=0,R=j.match(/^(\d{1,2}):(\d{2})(?::\d{2})?$/);if(R)f=parseInt(R[1],10),P=parseInt(R[2],10);else{let G=j.match(/^(\d{1,2})(?::(\d{2}))?([ap]m?)$/);if(G){f=parseInt(G[1],10),P=G[2]?parseInt(G[2],10):0;let U=G[3].startsWith("p");if(U&&f!==12)f+=12;else if(!U&&f===12)f=0}else{let U=new Date(c);if(!isNaN(U.getTime()))return U.toISOString();throw Error(`Invalid time format: ${c}. Use "HH:MM", "H:MMam/pm", or ISO format.`)}}if(f<0||f>23)throw Error(`Invalid hours: ${f}. Must be between 0 and 23.`);if(P<0||P>59)throw Error(`Invalid minutes: ${P}. Must be between 0 and 59.`);return $.setHours(f,P,0,0),$.toISOString()}function Qy(c,y){let $=new Date(c);return new Date($.getTime()+y*60*1000).toISOString()}function A(c){let $=new Date(new Date);if($.setHours(0,0,0,0),c==="today"){let R=new Date($);return R.setHours(23,59,59,999),{startDate:$.toISOString(),endDate:R.toISOString()}}if(c==="week"){let R=new Date($);return R.setDate(R.getDate()+7),R.setHours(23,59,59,999),{startDate:$.toISOString(),endDate:R.toISOString()}}if(!/^\d{4}-\d{2}-\d{2}$/.test(c))throw Error(`Invalid date format: ${c}. Use YYYY-MM-DD format.`);let f=new Date(c);if(isNaN(f.getTime()))throw Error(`Invalid date: ${c}. Use YYYY-MM-DD format.`);f.setHours(0,0,0,0);let P=new Date(f);return P.setHours(23,59,59,999),{startDate:f.toISOString(),endDate:P.toISOString()}}function s(c){return new Date(c).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function V(c){return new Date(c).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function Jy(c,y,$){if($)return s(c);let j=new Date(c),f=new Date(y);if(j.toDateString()===f.toDateString())return`${V(c)} - ${V(y)}`;return`${s(c)} ${V(c)} - ${s(y)} ${V(y)}`}function g(){return new Date().toISOString().split("T")[0]}function L(){return process.argv.includes("--json")}function S(c,y){if(y?.json||L())console.log(JSON.stringify(c,null,2));else if(typeof c==="string")console.log(c);else console.log(JSON.stringify(c,null,2))}function I(c){if(L())console.log(JSON.stringify({error:c}));else console.error(`Error: ${c}`)}function M(c){let y=[`[${c.id.slice(0,8)}] ${c.name}`];if(c.project_name)y.push(`(${c.project_name})`);if(c.dueDate)y.push(`due: ${c.dueDate}`);if(c.status==="waiting"&&c.waitingFor)y.push(`waiting: ${c.waitingFor}`);return y.join(" ")}function K(c){let y=[`[${c.id.slice(0,8)}] ${c.name}`];if(c.category_name)y.push(`(${c.category_name})`);if(c.status!=="active")y.push(`[${c.status}]`);return y.join(" ")}function z(c,y){if(c.length===0)return y?`${y}: (none)`:"(no actions)";let $=c.map((j)=>` ${M(j)}`);if(y)return`${y} (${c.length}):
|
|
27
|
+
${$.join(`
|
|
28
|
+
`)}`;return $.join(`
|
|
29
|
+
`)}function u(c,y){if(c.length===0)return y?`${y}: (none)`:"(no projects)";let $=c.map((j)=>` ${K(j)}`);if(y)return`${y} (${c.length}):
|
|
30
|
+
${$.join(`
|
|
31
|
+
`)}`;return $.join(`
|
|
32
|
+
`)}function Zy(c){let y=[];y.push(`Inbox: ${c.inboxCount} items`);let $=c.domains.map((j)=>` ${j.name}: ${j.active_count}/${j.activeProjectLimit} active`);if(y.push(`Capacity:
|
|
33
|
+
${$.join(`
|
|
34
|
+
`)}`),c.activeProjects.length>0)y.push(u(c.activeProjects,"Active Projects"));if(c.overdue.length>0)y.push(z(c.overdue,"Overdue"));if(c.dueToday.length>0)y.push(z(c.dueToday,"Due Today"));if(c.waiting.length>0)y.push(z(c.waiting,"Waiting"));return y.join(`
|
|
35
35
|
|
|
36
|
-
`)}function
|
|
37
|
-
${
|
|
38
|
-
`)}`;return
|
|
39
|
-
`)}function
|
|
40
|
-
${
|
|
41
|
-
`)}function
|
|
42
|
-
Notes: ${
|
|
43
|
-
Contexts: ${
|
|
44
|
-
The One Thing: ${
|
|
45
|
-
Notes: ${
|
|
46
|
-
Status: ${
|
|
47
|
-
${
|
|
48
|
-
`)}function
|
|
49
|
-
Status: ${
|
|
50
|
-
Notes: ${
|
|
51
|
-
Review after: ${
|
|
52
|
-
Linked Projects (${
|
|
53
|
-
${
|
|
54
|
-
`)}function
|
|
55
|
-
More events available. Use --page-token ${
|
|
56
|
-
`);
|
|
57
|
-
${
|
|
36
|
+
`)}function bj(c){let y=[`[${c.id.slice(0,8)}] ${c.name}`];if(y.push(`(${c.accountEmail})`),!c.isEnabled)y.push("[disabled]");return y.join(" ")}function Fy(c,y){if(c.length===0)return y?`${y}: (none)`:"(no calendars connected)";let $=c.map((j)=>` ${bj(j)}`);if(y)return`${y} (${c.length}):
|
|
37
|
+
${$.join(`
|
|
38
|
+
`)}`;return $.join(`
|
|
39
|
+
`)}function zy(c){let $=[`${Jy(c.startTime,c.endTime,c.isAllDay)} - ${c.summary}`];if(c.location)$.push(`@ ${c.location}`);return $.join(" ")}function Cc(c,y){if(c.length===0)return y?`${y}: (no events)`:"(no events)";let $=new Map;for(let f of c){let P=s(f.startTime),R=$.get(P)||[];R.push(f),$.set(P,R)}let j=[];if(y)j.push(`${y} (${c.length}):`);for(let[f,P]of $){j.push(`
|
|
40
|
+
${f}:`);for(let R of P){let U=` ${R.isAllDay?"All day":`${V(R.startTime)} - ${V(R.endTime)}`}: ${R.summary}`;if(R.location)U+=` @ ${R.location}`;j.push(U)}}return j.join(`
|
|
41
|
+
`)}function Xy(c){let y=c.command("auth").description("Manage authentication");y.command("login").description("Authenticate with Ace").option("--api-url <url>","Ace API URL (default: https://aceisyourassistant.com)").action(async($)=>{try{await Kc($.apiUrl)}catch(j){I(j instanceof Error?j.message:"Login failed"),process.exit(1)}}),y.command("logout").description("Remove stored credentials").action(()=>{let $=wc();if(L())S({success:$});else if($)console.log("Logged out successfully");else console.log("No credentials to remove")}),y.command("status").description("Show current authentication status").action(()=>{let $=x(),j=l();if(L())S({authenticated:!!$,method:j?"env-token":"stored-credentials",email:$?.userEmail??null,apiUrl:$?.apiUrl??null});else if($&&j)console.log("Authenticated via ACE_TOKEN environment variable"),console.log(`API URL: ${$.apiUrl}`);else if($)console.log(`Authenticated as ${$.userEmail}`),console.log(`API URL: ${$.apiUrl}`);else console.log("Not authenticated. Run: ace auth login")}),y.command("whoami").description("Show current user").action(()=>{let $=x(),j=l();if(L())S({authenticated:!!$,method:j?"env-token":"stored-credentials",email:j?null:$?.userEmail??null,userId:j?null:$?.userId??null});else if($&&j)console.log("Authenticated via ACE_TOKEN (run ace auth login for full user info)");else if($)console.log($.userEmail);else console.log("Not authenticated"),process.exit(1)})}class xc extends Error{status;body;constructor(c,y,$){super(c);this.status=y;this.body=$;this.name="ApiError"}}class Bc extends xc{constructor(c="Not authenticated. Run: ace auth login"){super(c,401);this.name="AuthError"}}async function E(c,y={},$){let j=x();if(!j)throw new Bc;let P=`${$??j.apiUrl??O()}/api${c}`,R=await fetch(P,{...y,headers:{Authorization:`Bearer ${j.token}`,"Content-Type":"application/json",...y.headers}});if(R.status===401)throw new Bc("Session expired. Run: ace auth login");if(!R.ok){let G=await R.json().catch(()=>({}));throw new xc(G.error??`Request failed with status ${R.status}`,R.status,G)}return R.json()}async function Hy(){return E("/dashboard")}async function T(c={}){let y=new URLSearchParams;if(c.status)y.set("status",c.status);if(c.projectId)y.set("project_id",c.projectId);if(c.contextId)y.set("context_id",c.contextId);if(c.search)y.set("search",c.search);if(c.limit)y.set("limit",String(c.limit));if(c.offset)y.set("offset",String(c.offset));if(c.dueBefore)y.set("due_before",c.dueBefore);if(c.dueAfter)y.set("due_after",c.dueAfter);if(c.completedAfter)y.set("completed_after",c.completedAfter);let $=y.toString(),j=$?`/actions?${$}`:"/actions";return(await E(j)).actions}async function Wy(c){return E(`/actions/${c}`)}async function a(c){return E("/actions",{method:"POST",body:JSON.stringify(c)})}async function Nc(c,y){return E(`/actions/${c}`,{method:"PUT",body:JSON.stringify(y)})}async function _y(c){return Nc(c,{status:"completed"})}async function My(c){await E(`/actions/${c}`,{method:"DELETE"})}async function m(c={}){let y=new URLSearchParams;if(c.status)y.set("status",c.status);if(c.domain)y.set("domain",c.domain);if(c.categoryId)y.set("category_id",c.categoryId);if(c.search)y.set("search",c.search);if(c.dueForReview)y.set("dueForReview","true");if(c.completedAfter)y.set("completed_after",c.completedAfter);let $=y.toString(),j=$?`/projects?${$}`:"/projects";return(await E(j)).projects}async function Ky(c){return E(`/projects/${c}`)}async function Ty(c){return E("/projects",{method:"POST",body:JSON.stringify(c)})}async function i(c,y){return E(`/projects/${c}`,{method:"PUT",body:JSON.stringify(y)})}async function Cy(c){return E(`/projects/${c}`,{method:"PUT",body:JSON.stringify({action:"review"})})}async function By(c){await E(`/projects/${c}`,{method:"DELETE"})}async function xy(){return(await E("/contexts")).contexts}async function n(c={}){let y=new URLSearchParams;if(c.status)y.set("status",c.status);if(c.domain)y.set("domain",c.domain);if(c.search)y.set("search",c.search);if(c.dueForReview)y.set("dueForReview","true");let $=y.toString(),j=$?`/goals?${$}`:"/goals";return(await E(j)).goals}async function Ny(c,y=!1){let $=y?`/goals/${c}?include=projects`:`/goals/${c}`;return E($)}async function Vy(c){return E("/goals",{method:"POST",body:JSON.stringify(c)})}async function o(c,y){return E(`/goals/${c}`,{method:"PUT",body:JSON.stringify(y)})}async function Ay(c){return E(`/goals/${c}`,{method:"PUT",body:JSON.stringify({action:"review"})})}async function Dy(c){await E(`/goals/${c}`,{method:"DELETE"})}async function ky(){return(await E("/domains")).domains}async function ty(c={}){let y=new URLSearchParams;if(c.source)y.set("source",c.source);if(c.limit)y.set("limit",String(c.limit));let $=y.toString(),j=$?`/activity-log?${$}`:"/activity-log";return(await E(j)).logs}async function uy(c){return E("/activity-log",{method:"POST",body:JSON.stringify(c)})}async function Vc(){return(await E("/calendar/calendars")).calendars}async function Ac(c={}){let y=new URLSearchParams;if(c.calendarId)y.set("calendarId",c.calendarId);if(c.startDate)y.set("startDate",c.startDate);if(c.endDate)y.set("endDate",c.endDate);if(c.limit)y.set("limit",String(c.limit));if(c.pageToken)y.set("pageToken",c.pageToken);let $=y.toString(),j=$?`/calendar/events?${$}`:"/calendar/events";return E(j)}async function hy(c){return(await E("/calendar/events",{method:"POST",body:JSON.stringify(c)})).event}async function vy(c={}){let y=new URLSearchParams;if(c.limit)y.set("limit",String(c.limit));if(c.offset)y.set("offset",String(c.offset));let $=y.toString(),j=$?`/updates?${$}`:"/updates";return(await E(j)).updates}async function by(c={}){return E("/updates",{method:"POST",body:JSON.stringify(c)})}async function Oy(c){return E(`/updates/${c}`)}async function sy(c={}){let y=new URLSearchParams;if(c.hours)y.set("hours",String(c.hours));if(c.since)y.set("since",c.since);if(c.until)y.set("until",c.until);if(c.statuses)y.set("statuses",c.statuses);let $=y.toString(),j=$?`/linear/issues?${$}`:"/linear/issues";return E(j)}async function gy(){return E("/linear/statuses")}function my(c){c.command("capture").description("Quick capture an item to inbox").argument("<text>","The item to capture").option("-n, --notes <notes>","Additional notes").action(async(y,$)=>{try{let j=await a({name:y,status:"inbox",notes:$.notes});if(L())S(j);else console.log(`Captured: ${M(j)}`)}catch(j){I(j instanceof Error?j.message:"Capture failed"),process.exit(1)}})}function ry(c){c.command("orient").description("Daily orientation - see your current state").alias("dashboard").action(async()=>{try{let y=await Hy();if(L())S(y);else console.log(Zy(y))}catch(y){I(y instanceof Error?y.message:"Failed to load dashboard"),process.exit(1)}})}function Oj(){let c=new Date;return c.setHours(0,0,0,0),c}function p(c){return c.toISOString().split("T")[0]}function h(c){let y=Oj();if(c==="overdue")return{dueBefore:p(y)};if(c==="today"){let $=new Date(y);return $.setDate($.getDate()+1),{dueAfter:p(y),dueBefore:p($)}}if(c==="week"){let $=new Date(y);return $.setDate($.getDate()+7),{dueBefore:p($)}}return{}}function ly(c){if(c==="today")return h("today");if(c==="week")return h("week");return{dueBefore:c}}function cc(c){let y=new Date;return y.setDate(y.getDate()-c),y.toISOString()}function dy(c){let y=c.command("actions").description("Manage actions");y.command("list").description("List actions").option("-s, --status <status>","Filter by status (inbox, active, waiting, someday)").option("-p, --project <id>","Filter by project ID").option("-c, --context <id>","Filter by context ID").option("-q, --search <query>","Search by name").option("-l, --limit <n>","Limit results","50").option("-d, --due <period>","Filter by due date (today, week, or YYYY-MM-DD)").option("--overdue","Show only overdue actions").action(async($)=>{try{let j,f;if($.overdue)j=h("overdue").dueBefore;else if($.due){let R=ly($.due);j=R.dueBefore,f=R.dueAfter}let P=await T({status:$.status,projectId:$.project,contextId:$.context,search:$.search,limit:parseInt($.limit),dueBefore:j,dueAfter:f});if(L())S({actions:P});else{let R=$.status?`${$.status} actions`:"Actions";console.log(z(P,R))}}catch(j){I(j instanceof Error?j.message:"Failed to list actions"),process.exit(1)}}),y.command("inbox").description("List inbox items").action(async()=>{try{let $=await T({status:"inbox"});if(L())S({actions:$,count:$.length});else console.log(z($,"Inbox"))}catch($){I($ instanceof Error?$.message:"Failed to list inbox"),process.exit(1)}}),y.command("due").description("List actions due today").option("-w, --week","Show actions due this week").action(async($)=>{try{let j=h($.week?"week":"today"),f=await T({status:"active",dueBefore:j.dueBefore,dueAfter:j.dueAfter});if(L())S({actions:f,count:f.length});else{let P=$.week?"Due This Week":"Due Today";console.log(z(f,P))}}catch(j){I(j instanceof Error?j.message:"Failed to list due actions"),process.exit(1)}}),y.command("overdue").description("List overdue actions").action(async()=>{try{let $=h("overdue"),j=await T({status:"active",dueBefore:$.dueBefore});if(L())S({actions:j,count:j.length});else console.log(z(j,"Overdue"))}catch($){I($ instanceof Error?$.message:"Failed to list overdue actions"),process.exit(1)}}),y.command("waiting").description("List actions waiting on someone/something").action(async()=>{try{let $=await T({status:"waiting"});if(L())S({actions:$,count:$.length});else console.log(z($,"Waiting"))}catch($){I($ instanceof Error?$.message:"Failed to list waiting actions"),process.exit(1)}}),y.command("get <id>").description("Get action details").action(async($)=>{try{let j=await Wy($);if(L())S(j);else{if(console.log(M(j)),j.notes)console.log(`
|
|
42
|
+
Notes: ${j.notes}`);if(j.contexts.length>0)console.log(`
|
|
43
|
+
Contexts: ${j.contexts.map((f)=>f.name).join(", ")}`)}}catch(j){I(j instanceof Error?j.message:"Failed to get action"),process.exit(1)}}),y.command("add <name>").description("Create a new action").option("-s, --status <status>","Initial status (default: inbox)").option("-p, --project <id>","Assign to project").option("-d, --due <date>","Due date (YYYY-MM-DD)").option("-n, --notes <notes>","Additional notes").action(async($,j)=>{try{let f=await a({name:$,status:j.status??"inbox",projectId:j.project,dueDate:j.due,notes:j.notes});if(L())S(f);else console.log(`Created: ${M(f)}`)}catch(f){I(f instanceof Error?f.message:"Failed to create action"),process.exit(1)}}),y.command("update <id>").description("Update an action").option("-n, --name <name>","New name").option("-s, --status <status>","New status").option("-p, --project <id>",'Assign to project (use "none" to unassign)').option("-d, --due <date>",'Due date (YYYY-MM-DD, or "none" to clear)').option("--notes <notes>","Update notes").option("-w, --waiting <reason>","Set waiting reason").action(async($,j)=>{try{let f={};if(j.name)f.name=j.name;if(j.status)f.status=j.status;if(j.project==="none")f.projectId=null;else if(j.project)f.projectId=j.project;if(j.due==="none")f.dueDate=null;else if(j.due)f.dueDate=j.due;if(j.notes)f.notes=j.notes;if(j.waiting)f.waitingFor=j.waiting,f.status="waiting";let P=await Nc($,f);if(L())S(P);else console.log(`Updated: ${M(P)}`)}catch(f){I(f instanceof Error?f.message:"Failed to update action"),process.exit(1)}}),y.command("complete <id>").description("Mark an action as completed").action(async($)=>{try{let j=await _y($);if(L())S(j);else console.log(`Completed: ${M(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to complete action"),process.exit(1)}}),y.command("delete <id>").description("Delete an action").action(async($)=>{try{if(await My($),L())S({success:!0,id:$});else console.log(`Deleted action ${$}`)}catch(j){I(j instanceof Error?j.message:"Failed to delete action"),process.exit(1)}}),y.command("count").description("Count actions by status").option("-s, --status <status>","Status to count (default: inbox)").action(async($)=>{try{let j=$.status??"inbox",f=await T({status:j});if(L())S({status:j,count:f.length});else console.log(`${j}: ${f.length}`)}catch(j){I(j instanceof Error?j.message:"Failed to count actions"),process.exit(1)}}),y.command("completed").description("List recently completed actions").option("-d, --days <n>","Number of days to look back","7").option("-l, --limit <n>","Max items to return","50").action(async($)=>{try{let j=parseInt($.days),f=await T({status:"completed",completedAfter:cc(j),limit:parseInt($.limit)});if(L())S({actions:f,count:f.length,days:j});else console.log(z(f,`Completed (last ${$.days} days)`))}catch(j){I(j instanceof Error?j.message:"Failed to list completed actions"),process.exit(1)}})}function ey(c){let y=c.command("projects").description("Manage projects");y.command("list").description("List projects").option("-s, --status <status>","Filter by status").option("-d, --domain <domain>","Filter by domain (Work, Personal)").option("-c, --category <id>","Filter by category ID").option("-q, --search <query>","Search by name").option("-r, --review","Show only projects due for review").action(async($)=>{try{let j=await m({status:$.status,domain:$.domain,categoryId:$.category,search:$.search,dueForReview:$.review});if(L())S({projects:j});else{let f=$.status?`${$.status} projects`:"Projects";console.log(u(j,f))}}catch(j){I(j instanceof Error?j.message:"Failed to list projects"),process.exit(1)}}),y.command("active").description("List active projects").option("-d, --domain <domain>","Filter by domain (Work, Personal)").action(async($)=>{try{let j=await m({status:"active",domain:$.domain});if(L())S({projects:j,count:j.length});else console.log(u(j,"Active Projects"))}catch(j){I(j instanceof Error?j.message:"Failed to list active projects"),process.exit(1)}}),y.command("get <id>").description("Get project details").action(async($)=>{try{let j=await Ky($);if(L())S(j);else{if(console.log(K(j)),j.theOneThing)console.log(`
|
|
44
|
+
The One Thing: ${j.theOneThing}`);if(j.notes)console.log(`
|
|
45
|
+
Notes: ${j.notes}`);if(console.log(`
|
|
46
|
+
Status: ${j.status}`),j.reviewAfter)console.log(`Review after: ${j.reviewAfter}`)}}catch(j){I(j instanceof Error?j.message:"Failed to get project"),process.exit(1)}}),y.command("add <name>").description("Create a new project").option("-s, --status <status>","Initial status (default: incubating)").option("-c, --category <id>","Assign to category").option("-t, --the-one-thing <text>","Set the one thing").option("-n, --notes <notes>","Additional notes").action(async($,j)=>{try{let f=await Ty({name:$,status:j.status??"incubating",categoryId:j.category,theOneThing:j.theOneThing,notes:j.notes});if(L())S(f);else console.log(`Created: ${K(f)}`)}catch(f){I(f instanceof Error?f.message:"Failed to create project"),process.exit(1)}}),y.command("update <id>").description("Update a project").option("-n, --name <name>","New name").option("-s, --status <status>","New status").option("-c, --category <id>",'Assign to category (use "none" to unassign)').option("-t, --the-one-thing <text>","Set the one thing").option("--notes <notes>","Update notes").action(async($,j)=>{try{let f={};if(j.name)f.name=j.name;if(j.status)f.status=j.status;if(j.category==="none")f.categoryId=null;else if(j.category)f.categoryId=j.category;if(j.theOneThing)f.theOneThing=j.theOneThing;if(j.notes)f.notes=j.notes;let P=await i($,f);if(L())S(P);else console.log(`Updated: ${K(P)}`)}catch(f){I(f instanceof Error?f.message:"Failed to update project"),process.exit(1)}}),y.command("activate <id>").description("Set project status to active").action(async($)=>{try{let j=await i($,{status:"active"});if(L())S(j);else console.log(`Activated: ${K(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to activate project"),process.exit(1)}}),y.command("complete <id>").description("Mark a project as completed").action(async($)=>{try{let j=await i($,{status:"completed"});if(L())S(j);else console.log(`Completed: ${K(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to complete project"),process.exit(1)}}),y.command("review").description("List projects due for review").action(async()=>{try{let $=await m({dueForReview:!0});if(L())S({projects:$,count:$.length});else console.log(u($,"Projects Due for Review"))}catch($){I($ instanceof Error?$.message:"Failed to list projects for review"),process.exit(1)}}),y.command("mark-reviewed <id>").description("Mark a project as reviewed (resets review timer)").action(async($)=>{try{let j=await Cy($);if(L())S(j);else console.log(`Marked as reviewed: ${K(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to mark project as reviewed"),process.exit(1)}}),y.command("drop <id>").description("Drop a project (soft delete)").action(async($)=>{try{if(await By($),L())S({success:!0,id:$});else console.log(`Dropped project ${$}`)}catch(j){I(j instanceof Error?j.message:"Failed to drop project"),process.exit(1)}}),y.command("completed").description("List recently completed projects").option("-d, --days <n>","Number of days to look back","7").action(async($)=>{try{let j=parseInt($.days),f=await m({status:"completed",completedAfter:cc(j)});if(L())S({projects:f,count:f.length,days:j});else console.log(u(f,`Completed (last ${$.days} days)`))}catch(j){I(j instanceof Error?j.message:"Failed to list completed projects"),process.exit(1)}})}function D(c){let y=c.id.slice(0,8),$=c.domain_name?` (${c.domain_name})`:"";return`[${y}] ${c.name}${$}`}function Dc(c,y){if(c.length===0)return`${y}: (none)`;let $=[`${y} (${c.length}):`],j=c.reduce((f,P)=>{let R=P.domain_name||"Unknown";if(!f[R])f[R]=[];return f[R].push(P),f},{});for(let[f,P]of Object.entries(j)){$.push(`
|
|
47
|
+
${f}:`);for(let R of P){let G=R.status!=="active"?` [${R.status}]`:"";if($.push(` ${D(R)}${G}`),R.theOneThing)$.push(` Focus: ${R.theOneThing}`);if(R.project_count!==void 0)$.push(` Projects: ${R.project_count}`)}}return $.join(`
|
|
48
|
+
`)}function ay(c){let y=c.command("goals").description("Manage goals");y.command("list").description("List goals").option("-s, --status <status>","Filter by status (active, paused, completed, dropped)").option("-d, --domain <domain>","Filter by domain (Work, Personal)").option("-q, --search <query>","Search by name").option("-r, --review","Show only goals due for review").action(async($)=>{try{let j=await n({status:$.status,domain:$.domain,search:$.search,dueForReview:$.review});if(L())S({goals:j});else{let f=$.status?`${$.status} goals`:"Goals";console.log(Dc(j,f))}}catch(j){I(j instanceof Error?j.message:"Failed to list goals"),process.exit(1)}}),y.command("active").description("List active goals").option("-d, --domain <domain>","Filter by domain (Work, Personal)").action(async($)=>{try{let j=await n({status:"active",domain:$.domain});if(L())S({goals:j,count:j.length});else console.log(Dc(j,"Active Goals"))}catch(j){I(j instanceof Error?j.message:"Failed to list active goals"),process.exit(1)}}),y.command("get <id>").description("Get goal details").option("-p, --projects","Include linked projects").action(async($,j)=>{try{let f=await Ny($,j.projects);if(L())S(f);else{if(console.log(D(f)),console.log(`
|
|
49
|
+
Status: ${f.status}`),f.theOneThing)console.log(`Focus: ${f.theOneThing}`);if(f.notes)console.log(`
|
|
50
|
+
Notes: ${f.notes}`);if(f.reviewAfter)console.log(`
|
|
51
|
+
Review after: ${f.reviewAfter}`);if(f.projects&&f.projects.length>0){console.log(`
|
|
52
|
+
Linked Projects (${f.projects.length}):`);for(let P of f.projects)console.log(` - ${P.name} [${P.status}]`)}}}catch(f){I(f instanceof Error?f.message:"Failed to get goal"),process.exit(1)}}),y.command("add <name>").description("Create a new goal").option("-d, --domain <domain>","Domain (Work or Personal)","Personal").option("-s, --status <status>","Initial status (default: active)").option("-f, --focus <text>","Set the focus/one thing").option("-n, --notes <notes>","Additional notes").action(async($,j)=>{try{let f=await ky();if(!f||f.length===0)I("No domains found. Please check your Ace configuration."),process.exit(1);let P=f.find((G)=>G.name.toLowerCase()===j.domain.toLowerCase());if(!P){let G=f.map((U)=>U.name).join(", ");I(`Invalid domain: ${j.domain}. Valid options: ${G}`),process.exit(1)}let R=await Vy({name:$,domainId:P.id,status:j.status??"active",theOneThing:j.focus,notes:j.notes});if(L())S(R);else console.log(`Created: ${D(R)}`)}catch(f){I(f instanceof Error?f.message:"Failed to create goal"),process.exit(1)}}),y.command("update <id>").description("Update a goal").option("-n, --name <name>","New name").option("-s, --status <status>","New status").option("-f, --focus <text>","Update the focus/one thing").option("--notes <notes>","Update notes").action(async($,j)=>{try{let f={};if(j.name)f.name=j.name;if(j.status)f.status=j.status;if(j.focus)f.theOneThing=j.focus;if(j.notes)f.notes=j.notes;let P=await o($,f);if(L())S(P);else console.log(`Updated: ${D(P)}`)}catch(f){I(f instanceof Error?f.message:"Failed to update goal"),process.exit(1)}}),y.command("mark-reviewed <id>").description("Mark a goal as reviewed (resets review timer)").action(async($)=>{try{let j=await Ay($);if(L())S(j);else console.log(`Marked as reviewed: ${D(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to mark goal as reviewed"),process.exit(1)}}),y.command("complete <id>").description("Mark a goal as completed").action(async($)=>{try{let j=await o($,{status:"completed"});if(L())S(j);else console.log(`Completed: ${D(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to complete goal"),process.exit(1)}}),y.command("pause <id>").description("Pause a goal").action(async($)=>{try{let j=await o($,{status:"paused"});if(L())S(j);else console.log(`Paused: ${D(j)}`)}catch(j){I(j instanceof Error?j.message:"Failed to pause goal"),process.exit(1)}}),y.command("drop <id>").description("Drop a goal").action(async($)=>{try{if(await Dy($),L())S({success:!0,id:$});else console.log(`Dropped goal ${$}`)}catch(j){I(j instanceof Error?j.message:"Failed to drop goal"),process.exit(1)}}),y.command("review").description("List goals due for review").action(async()=>{try{let $=await n({dueForReview:!0});if(L())S({goals:$,count:$.length});else console.log(Dc($,"Goals Due for Review"))}catch($){I($ instanceof Error?$.message:"Failed to list goals for review"),process.exit(1)}})}function sj(c,y){if(c.length===0)return`${y}: (none)`;let $=[`${y} (${c.length}):`],j=c.reduce((f,P)=>{let R=new Date(P.timestamp).toLocaleDateString();if(!f[R])f[R]=[];return f[R].push(P),f},{});for(let[f,P]of Object.entries(j)){$.push(`
|
|
53
|
+
${f}:`);for(let R of P){let G=new Date(R.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});$.push(` ${G} [${R.source}] ${R.summary}`)}}return $.join(`
|
|
54
|
+
`)}function iy(c){let y=c.command("activity").description("View and log activity");y.command("list").description("List activity log entries").option("-s, --source <source>","Filter by source (manual, git, calendar, etc.)").option("-l, --limit <n>","Limit results","50").action(async($)=>{try{let j=await ty({source:$.source,limit:parseInt($.limit)});if(L())S({logs:j});else{let f=$.source?`Activity (${$.source})`:"Recent Activity";console.log(sj(j,f))}}catch(j){I(j instanceof Error?j.message:"Failed to list activity"),process.exit(1)}}),y.command("log <summary>").description("Log an activity").option("-s, --source <source>","Activity source","manual").option("-p, --project <id>","Link to project").option("-a, --action <id>","Link to action").action(async($,j)=>{try{let f=await uy({source:j.source,summary:$,project_id:j.project,action_id:j.action});if(L())S(f);else if(console.log(`Logged: ${$}`),j.project)console.log(` Linked to project: ${j.project}`)}catch(f){I(f instanceof Error?f.message:"Failed to log activity"),process.exit(1)}})}function ny(c){c.command("contexts").description("Manage contexts").command("list").description("List all contexts").action(async()=>{try{let $=await xy();if(L())S({contexts:$});else if($.length===0)console.log("No contexts found");else{console.log("Contexts:");for(let j of $){let f=j.type?` (${j.type})`:"";console.log(` [${j.id.slice(0,8)}] ${j.name}${f}`)}}}catch($){I($ instanceof Error?$.message:"Failed to list contexts"),process.exit(1)}})}var gj=30,oy=1,py=250,mj=50;function c$(c){let y=c.command("calendar").description("Manage calendar events");y.command("list").description("List connected calendars").action(async()=>{try{let $=await Vc();if(L())S({calendars:$});else console.log(Fy($,"Connected Calendars"))}catch($){I($ instanceof Error?$.message:"Failed to list calendars"),process.exit(1)}}),y.command("events").description("List calendar events").option("-c, --calendar <id>","Filter by calendar ID").option("-d, --date <date>","Date to show events for (YYYY-MM-DD, default: today)").option("-w, --week","Show events for the next 7 days").option("--from <date>","Start date for range (YYYY-MM-DD)").option("--to <date>","End date for range (YYYY-MM-DD)").option("-l, --limit <n>","Maximum number of events",String(mj)).option("--page-token <token>","Page token for pagination (requires --calendar)").action(async($)=>{try{if($.pageToken&&!$.calendar)I("--page-token requires --calendar to be specified"),process.exit(1);let j,f;if($.from&&$.to){let G=A($.from),U=A($.to);j=G.startDate,f=U.endDate}else if($.week){let G=A("week");j=G.startDate,f=G.endDate}else if($.date){let G=A($.date);j=G.startDate,f=G.endDate}else{let G=A("today");j=G.startDate,f=G.endDate}let P=parseInt($.limit);if(isNaN(P)||P<oy||P>py)I(`Invalid limit. Must be between ${oy} and ${py}.`),process.exit(1);let R=await Ac({calendarId:$.calendar,startDate:j,endDate:f,limit:P,pageToken:$.pageToken});if(L())S({events:R.events,count:R.events.length,nextPageToken:R.nextPageToken});else{let G="Events";if($.week)G="Events (next 7 days)";else if($.date)G=`Events for ${$.date}`;else if($.from&&$.to)G=`Events from ${$.from} to ${$.to}`;else G=`Events for ${g()}`;if(console.log(Cc(R.events,G)),R.nextPageToken)console.log(`
|
|
55
|
+
More events available. Use --page-token ${R.nextPageToken} to see next page.`)}}catch(j){I(j instanceof Error?j.message:"Failed to list events"),process.exit(1)}}),y.command("today").description("List today's calendar events").option("-c, --calendar <id>","Filter by calendar ID").action(async($)=>{try{let j=A("today"),f=await Ac({calendarId:$.calendar,startDate:j.startDate,endDate:j.endDate});if(L())S({events:f.events,count:f.events.length,date:g()});else console.log(Cc(f.events,`Today (${g()})`))}catch(j){I(j instanceof Error?j.message:"Failed to list today's events"),process.exit(1)}}),y.command("add <summary>").description("Create a new calendar event").option("-c, --calendar <id>","Calendar ID to create event on").option("-s, --start <time>","Start time (e.g., 14:00, 2pm)","").option("-e, --end <time>","End time (e.g., 15:00, 3pm)").option("--duration <minutes>","Duration in minutes (alternative to --end)",String(gj)).option("-d, --date <date>","Date for the event (YYYY-MM-DD, default: today)").option("-l, --location <location>","Event location").option("--description <text>","Event description").option("--timezone <tz>","Timezone for the event (e.g., America/New_York, default: calendar's timezone)").action(async($,j)=>{try{if(!j.calendar){let q=(await Vc()).filter((w)=>w.isEnabled);if(q.length===0)I("No calendars connected. Connect a calendar via the web app first."),process.exit(1);if(q.length===1)j.calendar=q[0].id;else{let w=q.map((Y)=>` ${Y.id.slice(0,8)} - ${Y.name} (${Y.accountEmail})`).join(`
|
|
56
|
+
`);I(`Multiple calendars available. Please specify --calendar <id>:
|
|
57
|
+
${w}`),process.exit(1)}}if(!j.start)I("Start time is required. Use --start <time> (e.g., --start 14:00 or --start 2pm)"),process.exit(1);let f=j.date||g(),P;try{P=Tc(j.start,f)}catch(U){I(U instanceof Error?U.message:"Invalid start time"),process.exit(1)}let R;if(j.end)try{R=Tc(j.end,f)}catch(U){I(U instanceof Error?U.message:"Invalid end time"),process.exit(1)}else{let U=parseInt(j.duration);if(isNaN(U)||U<=0)I("Invalid duration. Must be a positive number of minutes."),process.exit(1);R=Qy(P,U)}let G=await hy({calendarId:j.calendar,summary:$,startTime:P,endTime:R,location:j.location,description:j.description,timeZone:j.timezone});if(L())S(G);else console.log(`Created: ${zy(G)}`)}catch(f){I(f instanceof Error?f.message:"Failed to create event"),process.exit(1)}})}function y$(c){let y=c.command("linear").description("Linear integration commands");y.command("issues").description("List Linear issues for a time period or by workflow status").option("-h, --hours <n>","Hours to look back","24").option("-s, --since <date>","Start date (ISO string)").option("-u, --until <date>","End date (ISO string, defaults to now)").option("--status <names>",'Filter by workflow status names (comma-separated, e.g. "In Progress,Todo")').option("-f, --format <format>","Output format: text, markdown, slack, html","text").action(async($)=>{try{let j=!!$.status,f=await sy({hours:j?void 0:$.hours?parseInt($.hours):void 0,since:j?void 0:$.since,until:j?void 0:$.until,statuses:$.status});if(L())S(f);else{let P=$.format.toLowerCase();switch(P){case"html":console.log(f.formatted.html);break;case"markdown":console.log(f.formatted.markdown);break;case"slack":console.log(f.formatted.slack);break;case"text":default:console.log(f.formatted.text);break}if(P==="text")if(console.log(""),j)console.log(`--- Stats: ${f.stats.totalIssues} issues (${f.stats.completedIssues} completed)`);else console.log(`--- Stats: ${f.stats.totalIssues} issues (${f.stats.completedIssues} completed), ${f.stats.comments} comments, ${f.stats.statusChanges} status changes`)}}catch(j){I(j instanceof Error?j.message:"Failed to fetch Linear issues"),process.exit(1)}}),y.command("statuses").description("List available workflow statuses from linked Linear teams").action(async()=>{try{let $=await gy();if(L())S($);else{if($.teams.length===0){console.log("No linked Linear teams found.");return}for(let j of $.teams){console.log(`${j.teamName} (${j.teamKey})`);for(let f of j.states)console.log(` ${f.name} [${f.type}]`);console.log("")}}}catch($){I($ instanceof Error?$.message:"Failed to fetch Linear statuses"),process.exit(1)}})}function rj(c){let y=new Date(c.periodEnd).toLocaleDateString(),$=c.aceActivityCount+c.githubActivityCount+c.linearActivityCount+c.calendarActivityCount,j=[`[${c.id.slice(0,8)}] ${y}`];if(j.push(`(${$} activities)`),c.categoriesIncluded.length>0)j.push(`- ${c.categoriesIncluded.join(", ")}`);return j.join(" ")}function lj(c,y){if(c.length===0)return`${y}: (none)`;let $=c.map((j)=>` ${rj(j)}`);return`${y} (${c.length}):
|
|
58
|
+
${$.join(`
|
|
59
|
+
`)}`}function $$(c){let y=c.stats,$=[];if(y.aceItems>0)$.push(`${y.aceItems} ace`);if(y.commits>0)$.push(`${y.commits} commits`);if(y.pullRequests>0)$.push(`${y.pullRequests} PRs`);if(y.issues>0)$.push(`${y.issues} issues`);if(y.linearIssues>0)$.push(`${y.linearIssues} linear`);if(y.calendarEvents>0)$.push(`${y.calendarEvents} meetings`);if(y.slackMessages>0)$.push(`${y.slackMessages} slack`);return["",`--- Period: ${c.periodStart.slice(0,10)} to ${c.periodEnd.slice(0,10)}`,`--- Stats: ${$.join(", ")||"no activity"}`].join(`
|
|
60
|
+
`)}function j$(c){let y=c.command("updates").description("Daily update commands");y.command("list").description("List recent updates").option("-l, --limit <n>","Number of updates to show","10").option("-o, --offset <n>","Skip first N updates","0").action(async($)=>{try{let j=await vy({limit:parseInt($.limit,10),offset:parseInt($.offset,10)});if(L())S({updates:j,count:j.length});else console.log(lj(j,"Recent Updates"))}catch(j){I(j instanceof Error?j.message:"Failed to list updates"),process.exit(1)}}),y.command("generate").description("Generate a new daily update").option("-d, --date <YYYY-MM-DD>","Target date (defaults to today)").option("--days-off <dates>","Comma-separated ISO dates to skip").option("--timezone <tz>","IANA timezone for working day calculation").option("-f, --format <format>","Output format: markdown, slack","markdown").action(async($)=>{try{let j=$.daysOff?$.daysOff.split(",").map((P)=>P.trim()):void 0,f=await by({targetDate:$.date,daysOff:j,timezone:$.timezone});if(L())S(f);else{if($.format.toLowerCase()==="slack")console.log(f.formatted.slackMrkdwn);else console.log(f.formatted.markdown);console.log($$(f)),console.log(`--- ID: ${f.id}`)}}catch(j){I(j instanceof Error?j.message:"Failed to generate update"),process.exit(1)}}),y.command("show <id>").description("Show a specific update").option("-f, --format <format>","Output format: markdown, slack","markdown").action(async($,j)=>{try{let f=await Oy($);if(L())S(f);else{if(j.format.toLowerCase()==="slack")console.log(f.formatted.slackMrkdwn);else console.log(f.formatted.markdown);console.log($$(f))}}catch(f){I(f instanceof Error?f.message:"Failed to show update"),process.exit(1)}})}F.name("ace").description("CLI for Ace productivity assistant").version(nc);Xy(F);my(F);ry(F);dy(F);ey(F);ay(F);iy(F);ny(F);c$(F);y$(F);j$(F);F.option("--json","Output in JSON format for AI consumption").option("--api-url <url>","Override API URL");F.parse();
|