ace-assistant-cli 0.1.0 → 0.1.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/README.dev.md +85 -0
- package/README.md +5 -36
- package/README.npm.md +85 -0
- package/dist/index.js +27 -27
- package/package.json +5 -3
package/README.dev.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Ace CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for [Ace](https://aceisyourassistant.com), a GTD-inspired productivity assistant. Designed for integration with AI tools like Claude Code.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g ace-assistant-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Authentication
|
|
12
|
+
|
|
13
|
+
First, authenticate with your Ace account:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ace auth login
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This opens a browser window where you can authorize the CLI. Your credentials are stored in `~/.ace/credentials.json`.
|
|
20
|
+
|
|
21
|
+
### Auth Commands
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ace auth login # Authenticate with Ace
|
|
25
|
+
ace auth logout # Remove stored credentials
|
|
26
|
+
ace auth status # Show authentication status
|
|
27
|
+
ace auth whoami # Show current user
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Quick Capture
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
ace capture "Call dentist tomorrow"
|
|
36
|
+
ace capture "Review PR #123" --notes "Check the test coverage"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Daily Orientation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
ace orient # Human-readable dashboard
|
|
43
|
+
ace orient --json # JSON for AI consumption
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Actions
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ace actions list # List all actions
|
|
50
|
+
ace actions inbox # List inbox items
|
|
51
|
+
ace actions list --status active # Filter by status
|
|
52
|
+
ace actions add "New task" # Create action
|
|
53
|
+
ace actions complete <id> # Mark complete
|
|
54
|
+
ace actions update <id> --status waiting --waiting "Bob"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Projects
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
ace projects list # List all projects
|
|
61
|
+
ace projects active # List active projects
|
|
62
|
+
ace projects list --domain Work # Filter by domain
|
|
63
|
+
ace projects add "New Project" # Create project
|
|
64
|
+
ace projects activate <id> # Set to active
|
|
65
|
+
ace projects complete <id> # Mark complete
|
|
66
|
+
ace projects review # Projects due for review
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## JSON Output
|
|
70
|
+
|
|
71
|
+
Add `--json` to any command for machine-readable output (ideal for AI tools):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
ace orient --json
|
|
75
|
+
ace actions list --json
|
|
76
|
+
ace projects active --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Environment Variables
|
|
80
|
+
|
|
81
|
+
- `ACE_API_URL` - Override the API URL (default: https://aceisyourassistant.com)
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- [Ace Web App](https://aceisyourassistant.com)
|
package/README.md
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
# Ace CLI
|
|
2
2
|
|
|
3
|
-
Command-line interface for
|
|
3
|
+
Command-line interface for [Ace](https://aceisyourassistant.com), a GTD-inspired productivity assistant. Designed for integration with AI tools like Claude Code.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
9
|
-
pnpm add -g ace-assistant-cli
|
|
10
|
-
|
|
11
|
-
# Or use pnpm dlx
|
|
12
|
-
pnpm dlx ace-assistant-cli
|
|
13
|
-
|
|
14
|
-
# For development
|
|
15
|
-
cd packages/cli
|
|
16
|
-
bun install
|
|
17
|
-
bun run dev
|
|
8
|
+
npm install -g ace-assistant-cli
|
|
18
9
|
```
|
|
19
10
|
|
|
20
11
|
## Authentication
|
|
@@ -87,30 +78,8 @@ ace projects active --json
|
|
|
87
78
|
|
|
88
79
|
## Environment Variables
|
|
89
80
|
|
|
90
|
-
- `ACE_API_URL` - Override the API URL (default: https://
|
|
91
|
-
|
|
92
|
-
## Development
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
# Install dependencies
|
|
96
|
-
bun install
|
|
97
|
-
|
|
98
|
-
# Run in development
|
|
99
|
-
bun run dev --help
|
|
81
|
+
- `ACE_API_URL` - Override the API URL (default: https://aceisyourassistant.com)
|
|
100
82
|
|
|
101
|
-
|
|
102
|
-
bun run build
|
|
83
|
+
## Links
|
|
103
84
|
|
|
104
|
-
|
|
105
|
-
bun run typecheck
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Publishing
|
|
109
|
-
|
|
110
|
-
The CLI is published to npm as `ace-assistant-cli`:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
cd packages/cli
|
|
114
|
-
bun run build
|
|
115
|
-
npm publish
|
|
116
|
-
```
|
|
85
|
+
- [Ace Web App](https://aceisyourassistant.com)
|
package/README.npm.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Ace CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for [Ace](https://aceisyourassistant.com), a GTD-inspired productivity assistant. Designed for integration with AI tools like Claude Code.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g ace-assistant-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Authentication
|
|
12
|
+
|
|
13
|
+
First, authenticate with your Ace account:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ace auth login
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This opens a browser window where you can authorize the CLI. Your credentials are stored in `~/.ace/credentials.json`.
|
|
20
|
+
|
|
21
|
+
### Auth Commands
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ace auth login # Authenticate with Ace
|
|
25
|
+
ace auth logout # Remove stored credentials
|
|
26
|
+
ace auth status # Show authentication status
|
|
27
|
+
ace auth whoami # Show current user
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Quick Capture
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
ace capture "Call dentist tomorrow"
|
|
36
|
+
ace capture "Review PR #123" --notes "Check the test coverage"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Daily Orientation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
ace orient # Human-readable dashboard
|
|
43
|
+
ace orient --json # JSON for AI consumption
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Actions
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ace actions list # List all actions
|
|
50
|
+
ace actions inbox # List inbox items
|
|
51
|
+
ace actions list --status active # Filter by status
|
|
52
|
+
ace actions add "New task" # Create action
|
|
53
|
+
ace actions complete <id> # Mark complete
|
|
54
|
+
ace actions update <id> --status waiting --waiting "Bob"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Projects
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
ace projects list # List all projects
|
|
61
|
+
ace projects active # List active projects
|
|
62
|
+
ace projects list --domain Work # Filter by domain
|
|
63
|
+
ace projects add "New Project" # Create project
|
|
64
|
+
ace projects activate <id> # Set to active
|
|
65
|
+
ace projects complete <id> # Mark complete
|
|
66
|
+
ace projects review # Projects due for review
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## JSON Output
|
|
70
|
+
|
|
71
|
+
Add `--json` to any command for machine-readable output (ideal for AI tools):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
ace orient --json
|
|
75
|
+
ace actions list --json
|
|
76
|
+
ace projects active --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Environment Variables
|
|
80
|
+
|
|
81
|
+
- `ACE_API_URL` - Override the API URL (default: https://aceisyourassistant.com)
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- [Ace Web App](https://aceisyourassistant.com)
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createRequire as
|
|
4
|
-
`).replace(/^/gm," ".repeat(2))}let
|
|
5
|
-
`)}padWidth(j,$){return Math.max($.longestOptionTermLength(j,$),$.longestGlobalOptionTermLength(j,$),$.longestSubcommandTermLength(j,$),$.longestArgumentTermLength(j,$))}wrap(j,$,S,
|
|
3
|
+
import{createRequire as M$}from"node:module";var T$=Object.create;var{getPrototypeOf:Q$,defineProperty:zj,getOwnPropertyNames:U$}=Object;var Z$=Object.prototype.hasOwnProperty;var G$=(j,$,S)=>{S=j!=null?T$(Q$(j)):{};let y=$||!j||!j.__esModule?zj(S,"default",{value:j,enumerable:!0}):S;for(let q of U$(j))if(!Z$.call(y,q))zj(y,q,{get:()=>j[q],enumerable:!0});return y};var F=(j,$)=>()=>($||j(($={exports:{}}).exports,$),$.exports);var C=M$(import.meta.url);var k=F((X$)=>{class r extends Error{constructor(j,$,S){super(S);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=$,this.exitCode=j,this.nestedError=void 0}}class Wj extends r{constructor(j){super(1,"commander.invalidArgument",j);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}X$.CommanderError=r;X$.InvalidArgumentError=Wj});var O=F((L$)=>{var{InvalidArgumentError:W$}=k();class Hj{constructor(j,$){switch(this.description=$||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,j[0]){case"<":this.required=!0,this._name=j.slice(1,-1);break;case"[":this.required=!1,this._name=j.slice(1,-1);break;default:this.required=!0,this._name=j;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(j,$){if($===this.defaultValue||!Array.isArray($))return[j];return $.concat(j)}default(j,$){return this.defaultValue=j,this.defaultValueDescription=$,this}argParser(j){return this.parseArg=j,this}choices(j){return this.argChoices=j.slice(),this.parseArg=($,S)=>{if(!this.argChoices.includes($))throw new W$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue($,S);return $},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function H$(j){let $=j.name()+(j.variadic===!0?"...":"");return j.required?"<"+$+">":"["+$+"]"}L$.Argument=Hj;L$.humanReadableArgName=H$});var l=F((B$)=>{var{humanReadableArgName:F$}=O();class Lj{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(j){let $=j.commands.filter((y)=>!y._hidden),S=j._getHelpCommand();if(S&&!S._hidden)$.push(S);if(this.sortSubcommands)$.sort((y,q)=>{return y.name().localeCompare(q.name())});return $}compareOptions(j,$){let S=(y)=>{return y.short?y.short.replace(/^-/,""):y.long.replace(/^--/,"")};return S(j).localeCompare(S($))}visibleOptions(j){let $=j.options.filter((y)=>!y.hidden),S=j._getHelpOption();if(S&&!S.hidden){let y=S.short&&j._findOption(S.short),q=S.long&&j._findOption(S.long);if(!y&&!q)$.push(S);else if(S.long&&!q)$.push(j.createOption(S.long,S.description));else if(S.short&&!y)$.push(j.createOption(S.short,S.description))}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleGlobalOptions(j){if(!this.showGlobalOptions)return[];let $=[];for(let S=j.parent;S;S=S.parent){let y=S.options.filter((q)=>!q.hidden);$.push(...y)}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleArguments(j){if(j._argsDescription)j.registeredArguments.forEach(($)=>{$.description=$.description||j._argsDescription[$.name()]||""});if(j.registeredArguments.find(($)=>$.description))return j.registeredArguments;return[]}subcommandTerm(j){let $=j.registeredArguments.map((S)=>F$(S)).join(" ");return j._name+(j._aliases[0]?"|"+j._aliases[0]:"")+(j.options.length?" [options]":"")+($?" "+$:"")}optionTerm(j){return j.flags}argumentTerm(j){return j.name()}longestSubcommandTermLength(j,$){return $.visibleCommands(j).reduce((S,y)=>{return Math.max(S,$.subcommandTerm(y).length)},0)}longestOptionTermLength(j,$){return $.visibleOptions(j).reduce((S,y)=>{return Math.max(S,$.optionTerm(y).length)},0)}longestGlobalOptionTermLength(j,$){return $.visibleGlobalOptions(j).reduce((S,y)=>{return Math.max(S,$.optionTerm(y).length)},0)}longestArgumentTermLength(j,$){return $.visibleArguments(j).reduce((S,y)=>{return Math.max(S,$.argumentTerm(y).length)},0)}commandUsage(j){let $=j._name;if(j._aliases[0])$=$+"|"+j._aliases[0];let S="";for(let y=j.parent;y;y=y.parent)S=y.name()+" "+S;return S+$+" "+j.usage()}commandDescription(j){return j.description()}subcommandDescription(j){return j.summary()||j.description()}optionDescription(j){let $=[];if(j.argChoices)$.push(`choices: ${j.argChoices.map((S)=>JSON.stringify(S)).join(", ")}`);if(j.defaultValue!==void 0){if(j.required||j.optional||j.isBoolean()&&typeof j.defaultValue==="boolean")$.push(`default: ${j.defaultValueDescription||JSON.stringify(j.defaultValue)}`)}if(j.presetArg!==void 0&&j.optional)$.push(`preset: ${JSON.stringify(j.presetArg)}`);if(j.envVar!==void 0)$.push(`env: ${j.envVar}`);if($.length>0)return`${j.description} (${$.join(", ")})`;return j.description}argumentDescription(j){let $=[];if(j.argChoices)$.push(`choices: ${j.argChoices.map((S)=>JSON.stringify(S)).join(", ")}`);if(j.defaultValue!==void 0)$.push(`default: ${j.defaultValueDescription||JSON.stringify(j.defaultValue)}`);if($.length>0){let S=`(${$.join(", ")})`;if(j.description)return`${j.description} ${S}`;return S}return j.description}formatHelp(j,$){let S=$.padWidth(j,$),y=$.helpWidth||80,q=2,R=2;function I(G,H){if(H){let s=`${G.padEnd(S+2)}${H}`;return $.wrap(s,y-2,S+2)}return G}function E(G){return G.join(`
|
|
4
|
+
`).replace(/^/gm," ".repeat(2))}let P=[`Usage: ${$.commandUsage(j)}`,""],J=$.commandDescription(j);if(J.length>0)P=P.concat([$.wrap(J,y,0),""]);let Y=$.visibleArguments(j).map((G)=>{return I($.argumentTerm(G),$.argumentDescription(G))});if(Y.length>0)P=P.concat(["Arguments:",E(Y),""]);let Z=$.visibleOptions(j).map((G)=>{return I($.optionTerm(G),$.optionDescription(G))});if(Z.length>0)P=P.concat(["Options:",E(Z),""]);if(this.showGlobalOptions){let G=$.visibleGlobalOptions(j).map((H)=>{return I($.optionTerm(H),$.optionDescription(H))});if(G.length>0)P=P.concat(["Global Options:",E(G),""])}let X=$.visibleCommands(j).map((G)=>{return I($.subcommandTerm(G),$.subcommandDescription(G))});if(X.length>0)P=P.concat(["Commands:",E(X),""]);return P.join(`
|
|
5
|
+
`)}padWidth(j,$){return Math.max($.longestOptionTermLength(j,$),$.longestGlobalOptionTermLength(j,$),$.longestSubcommandTermLength(j,$),$.longestArgumentTermLength(j,$))}wrap(j,$,S,y=40){let R=new RegExp(`[\\n][${" \\f\\t\\v - \uFEFF"}]+`);if(j.match(R))return j;let I=$-S;if(I<y)return j;let E=j.slice(0,S),P=j.slice(S).replace(`\r
|
|
6
6
|
`,`
|
|
7
|
-
`),
|
|
8
|
-
|.{1,${
|
|
9
|
-
`)return"";return(s>0?
|
|
10
|
-
`)}}B$.Help=Lj});var d=
|
|
11
|
-
(Did you mean one of ${
|
|
12
|
-
(Did you mean ${
|
|
13
|
-
- specify the name in Command constructor or using .name()`);if($=$||{},$.isDefault)this._defaultCommandName=j._name;if($.noHelp||$.hidden)j._hidden=!0;return this._registerCommand(j),j.parent=this,j._checkForBrokenPassThrough(),this}createArgument(j,$){return new h$(j,$)}argument(j,$,S,
|
|
14
|
-
Expecting one of '${S.join("', '")}'`);if(this._lifeCycleHooks[j])this._lifeCycleHooks[j].push($);else this._lifeCycleHooks[j]=[$];return this}exitOverride(j){if(j)this._exitCallback=j;else this._exitCallback=($)=>{if($.code!=="commander.executeSubCommandAsync")throw $};return this}_exit(j,$,S){if(this._exitCallback)this._exitCallback(new o(j,$,S));
|
|
15
|
-
- already used by option '${$.flags}'`)}this.options.push(j)}_registerCommand(j){let $=(
|
|
7
|
+
`),J=" ".repeat(S),Z=`\\s${""}`,X=new RegExp(`
|
|
8
|
+
|.{1,${I-1}}([${Z}]|$)|[^${Z}]+?([${Z}]|$)`,"g"),G=P.match(X)||[];return E+G.map((H,s)=>{if(H===`
|
|
9
|
+
`)return"";return(s>0?J:"")+H.trimEnd()}).join(`
|
|
10
|
+
`)}}B$.Help=Lj});var d=F((w$)=>{var{InvalidArgumentError:V$}=k();class Dj{constructor(j,$){this.flags=j,this.description=$||"",this.required=j.includes("<"),this.optional=j.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(j),this.mandatory=!1;let S=f$(j);if(this.short=S.shortFlag,this.long=S.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(j,$){return this.defaultValue=j,this.defaultValueDescription=$,this}preset(j){return this.presetArg=j,this}conflicts(j){return this.conflictsWith=this.conflictsWith.concat(j),this}implies(j){let $=j;if(typeof j==="string")$={[j]:!0};return this.implied=Object.assign(this.implied||{},$),this}env(j){return this.envVar=j,this}argParser(j){return this.parseArg=j,this}makeOptionMandatory(j=!0){return this.mandatory=!!j,this}hideHelp(j=!0){return this.hidden=!!j,this}_concatValue(j,$){if($===this.defaultValue||!Array.isArray($))return[j];return $.concat(j)}choices(j){return this.argChoices=j.slice(),this.parseArg=($,S)=>{if(!this.argChoices.includes($))throw new V$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue($,S);return $},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return A$(this.name().replace(/^no-/,""))}is(j){return this.short===j||this.long===j}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class Kj{constructor(j){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,j.forEach(($)=>{if($.negate)this.negativeOptions.set($.attributeName(),$);else this.positiveOptions.set($.attributeName(),$)}),this.negativeOptions.forEach(($,S)=>{if(this.positiveOptions.has(S))this.dualOptions.add(S)})}valueFromOption(j,$){let S=$.attributeName();if(!this.dualOptions.has(S))return!0;let y=this.negativeOptions.get(S).presetArg,q=y!==void 0?y:!1;return $.negate===(q===j)}}function A$(j){return j.split("-").reduce(($,S)=>{return $+S[0].toUpperCase()+S.slice(1)})}function f$(j){let $,S,y=j.split(/[ |,]+/);if(y.length>1&&!/^[[<]/.test(y[1]))$=y.shift();if(S=y.shift(),!$&&/^-[^-]$/.test(S))$=S,S=void 0;return{shortFlag:$,longFlag:S}}w$.Option=Dj;w$.DualOptions=Kj});var Fj=F((u$)=>{function k$(j,$){if(Math.abs(j.length-$.length)>3)return Math.max(j.length,$.length);let S=[];for(let y=0;y<=j.length;y++)S[y]=[y];for(let y=0;y<=$.length;y++)S[0][y]=y;for(let y=1;y<=$.length;y++)for(let q=1;q<=j.length;q++){let R=1;if(j[q-1]===$[y-1])R=0;else R=1;if(S[q][y]=Math.min(S[q-1][y]+1,S[q][y-1]+1,S[q-1][y-1]+R),q>1&&y>1&&j[q-1]===$[y-2]&&j[q-2]===$[y-1])S[q][y]=Math.min(S[q][y],S[q-2][y-2]+1)}return S[j.length][$.length]}function b$(j,$){if(!$||$.length===0)return"";$=Array.from(new Set($));let S=j.startsWith("--");if(S)j=j.slice(2),$=$.map((I)=>I.slice(2));let y=[],q=3,R=0.4;if($.forEach((I)=>{if(I.length<=1)return;let E=k$(j,I),P=Math.max(j.length,I.length);if((P-E)/P>R){if(E<q)q=E,y=[I];else if(E===q)y.push(I)}}),y.sort((I,E)=>I.localeCompare(E)),S)y=y.map((I)=>`--${I}`);if(y.length>1)return`
|
|
11
|
+
(Did you mean one of ${y.join(", ")}?)`;if(y.length===1)return`
|
|
12
|
+
(Did you mean ${y[0]}?)`;return""}u$.suggestSimilar=b$});var Aj=F((m$)=>{var c$=C("node:events").EventEmitter,i=C("node:child_process"),z=C("node:path"),p=C("node:fs"),M=C("node:process"),{Argument:h$,humanReadableArgName:v$}=O(),{CommanderError:o}=k(),{Help:t$}=l(),{Option:Bj,DualOptions:g$}=d(),{suggestSimilar:Nj}=Fj();class n extends c${constructor(j){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=j||"",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:($)=>M.stdout.write($),writeErr:($)=>M.stderr.write($),getOutHelpWidth:()=>M.stdout.isTTY?M.stdout.columns:void 0,getErrHelpWidth:()=>M.stderr.isTTY?M.stderr.columns:void 0,outputError:($,S)=>S($)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(j){return this._outputConfiguration=j._outputConfiguration,this._helpOption=j._helpOption,this._helpCommand=j._helpCommand,this._helpConfiguration=j._helpConfiguration,this._exitCallback=j._exitCallback,this._storeOptionsAsProperties=j._storeOptionsAsProperties,this._combineFlagAndOptionalValue=j._combineFlagAndOptionalValue,this._allowExcessArguments=j._allowExcessArguments,this._enablePositionalOptions=j._enablePositionalOptions,this._showHelpAfterError=j._showHelpAfterError,this._showSuggestionAfterError=j._showSuggestionAfterError,this}_getCommandAndAncestors(){let j=[];for(let $=this;$;$=$.parent)j.push($);return j}command(j,$,S){let y=$,q=S;if(typeof y==="object"&&y!==null)q=y,y=null;q=q||{};let[,R,I]=j.match(/([^ ]+) *(.*)/),E=this.createCommand(R);if(y)E.description(y),E._executableHandler=!0;if(q.isDefault)this._defaultCommandName=E._name;if(E._hidden=!!(q.noHelp||q.hidden),E._executableFile=q.executableFile||null,I)E.arguments(I);if(this._registerCommand(E),E.parent=this,E.copyInheritedSettings(this),y)return this;return E}createCommand(j){return new n(j)}createHelp(){return Object.assign(new t$,this.configureHelp())}configureHelp(j){if(j===void 0)return this._helpConfiguration;return this._helpConfiguration=j,this}configureOutput(j){if(j===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,j),this}showHelpAfterError(j=!0){if(typeof j!=="string")j=!!j;return this._showHelpAfterError=j,this}showSuggestionAfterError(j=!0){return this._showSuggestionAfterError=!!j,this}addCommand(j,$){if(!j._name)throw Error(`Command passed to .addCommand() must have a name
|
|
13
|
+
- specify the name in Command constructor or using .name()`);if($=$||{},$.isDefault)this._defaultCommandName=j._name;if($.noHelp||$.hidden)j._hidden=!0;return this._registerCommand(j),j.parent=this,j._checkForBrokenPassThrough(),this}createArgument(j,$){return new h$(j,$)}argument(j,$,S,y){let q=this.createArgument(j,$);if(typeof S==="function")q.default(y).argParser(S);else q.default(S);return this.addArgument(q),this}arguments(j){return j.trim().split(/ +/).forEach(($)=>{this.argument($)}),this}addArgument(j){let $=this.registeredArguments.slice(-1)[0];if($&&$.variadic)throw Error(`only the last argument can be variadic '${$.name()}'`);if(j.required&&j.defaultValue!==void 0&&j.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${j.name()}'`);return this.registeredArguments.push(j),this}helpCommand(j,$){if(typeof j==="boolean")return this._addImplicitHelpCommand=j,this;j=j??"help [command]";let[,S,y]=j.match(/([^ ]+) *(.*)/),q=$??"display help for command",R=this.createCommand(S);if(R.helpOption(!1),y)R.arguments(y);if(q)R.description(q);return this._addImplicitHelpCommand=!0,this._helpCommand=R,this}addHelpCommand(j,$){if(typeof j!=="object")return this.helpCommand(j,$),this;return this._addImplicitHelpCommand=!0,this._helpCommand=j,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(j,$){let S=["preSubcommand","preAction","postAction"];if(!S.includes(j))throw Error(`Unexpected value for event passed to hook : '${j}'.
|
|
14
|
+
Expecting one of '${S.join("', '")}'`);if(this._lifeCycleHooks[j])this._lifeCycleHooks[j].push($);else this._lifeCycleHooks[j]=[$];return this}exitOverride(j){if(j)this._exitCallback=j;else this._exitCallback=($)=>{if($.code!=="commander.executeSubCommandAsync")throw $};return this}_exit(j,$,S){if(this._exitCallback)this._exitCallback(new o(j,$,S));M.exit(j)}action(j){let $=(S)=>{let y=this.registeredArguments.length,q=S.slice(0,y);if(this._storeOptionsAsProperties)q[y]=this;else q[y]=this.opts();return q.push(this),j.apply(this,q)};return this._actionHandler=$,this}createOption(j,$){return new Bj(j,$)}_callParseArg(j,$,S,y){try{return j.parseArg($,S)}catch(q){if(q.code==="commander.invalidArgument"){let R=`${y} ${q.message}`;this.error(R,{exitCode:q.exitCode,code:q.code})}throw q}}_registerOption(j){let $=j.short&&this._findOption(j.short)||j.long&&this._findOption(j.long);if($){let S=j.long&&this._findOption(j.long)?j.long:j.short;throw Error(`Cannot add option '${j.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${S}'
|
|
15
|
+
- already used by option '${$.flags}'`)}this.options.push(j)}_registerCommand(j){let $=(y)=>{return[y.name()].concat(y.aliases())},S=$(j).find((y)=>this._findCommand(y));if(S){let y=$(this._findCommand(S)).join("|"),q=$(j).join("|");throw Error(`cannot add command '${q}' as already have command '${y}'`)}this.commands.push(j)}addOption(j){this._registerOption(j);let $=j.name(),S=j.attributeName();if(j.negate){let q=j.long.replace(/^--no-/,"--");if(!this._findOption(q))this.setOptionValueWithSource(S,j.defaultValue===void 0?!0:j.defaultValue,"default")}else if(j.defaultValue!==void 0)this.setOptionValueWithSource(S,j.defaultValue,"default");let y=(q,R,I)=>{if(q==null&&j.presetArg!==void 0)q=j.presetArg;let E=this.getOptionValue(S);if(q!==null&&j.parseArg)q=this._callParseArg(j,q,E,R);else if(q!==null&&j.variadic)q=j._concatValue(q,E);if(q==null)if(j.negate)q=!1;else if(j.isBoolean()||j.optional)q=!0;else q="";this.setOptionValueWithSource(S,q,I)};if(this.on("option:"+$,(q)=>{let R=`error: option '${j.flags}' argument '${q}' is invalid.`;y(q,R,"cli")}),j.envVar)this.on("optionEnv:"+$,(q)=>{let R=`error: option '${j.flags}' value '${q}' from env '${j.envVar}' is invalid.`;y(q,R,"env")});return this}_optionEx(j,$,S,y,q){if(typeof $==="object"&&$ instanceof Bj)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let R=this.createOption($,S);if(R.makeOptionMandatory(!!j.mandatory),typeof y==="function")R.default(q).argParser(y);else if(y instanceof RegExp){let I=y;y=(E,P)=>{let J=I.exec(E);return J?J[0]:P},R.default(q).argParser(y)}else R.default(y);return this.addOption(R)}option(j,$,S,y){return this._optionEx({},j,$,S,y)}requiredOption(j,$,S,y){return this._optionEx({mandatory:!0},j,$,S,y)}combineFlagAndOptionalValue(j=!0){return this._combineFlagAndOptionalValue=!!j,this}allowUnknownOption(j=!0){return this._allowUnknownOption=!!j,this}allowExcessArguments(j=!0){return this._allowExcessArguments=!!j,this}enablePositionalOptions(j=!0){return this._enablePositionalOptions=!!j,this}passThroughOptions(j=!0){return this._passThroughOptions=!!j,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(j=!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=!!j,this}getOptionValue(j){if(this._storeOptionsAsProperties)return this[j];return this._optionValues[j]}setOptionValue(j,$){return this.setOptionValueWithSource(j,$,void 0)}setOptionValueWithSource(j,$,S){if(this._storeOptionsAsProperties)this[j]=$;else this._optionValues[j]=$;return this._optionValueSources[j]=S,this}getOptionValueSource(j){return this._optionValueSources[j]}getOptionValueSourceWithGlobals(j){let $;return this._getCommandAndAncestors().forEach((S)=>{if(S.getOptionValueSource(j)!==void 0)$=S.getOptionValueSource(j)}),$}_prepareUserArgs(j,$){if(j!==void 0&&!Array.isArray(j))throw Error("first parameter to parse must be array or undefined");if($=$||{},j===void 0&&$.from===void 0){if(M.versions?.electron)$.from="electron";let y=M.execArgv??[];if(y.includes("-e")||y.includes("--eval")||y.includes("-p")||y.includes("--print"))$.from="eval"}if(j===void 0)j=M.argv;this.rawArgs=j.slice();let S;switch($.from){case void 0:case"node":this._scriptPath=j[1],S=j.slice(2);break;case"electron":if(M.defaultApp)this._scriptPath=j[1],S=j.slice(2);else S=j.slice(1);break;case"user":S=j.slice(0);break;case"eval":S=j.slice(1);break;default:throw Error(`unexpected parse option { from: '${$.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",S}parse(j,$){let S=this._prepareUserArgs(j,$);return this._parseCommand([],S),this}async parseAsync(j,$){let S=this._prepareUserArgs(j,$);return await this._parseCommand([],S),this}_executeSubCommand(j,$){$=$.slice();let S=!1,y=[".js",".ts",".tsx",".mjs",".cjs"];function q(J,Y){let Z=z.resolve(J,Y);if(p.existsSync(Z))return Z;if(y.includes(z.extname(Y)))return;let X=y.find((G)=>p.existsSync(`${Z}${G}`));if(X)return`${Z}${X}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let R=j._executableFile||`${this._name}-${j._name}`,I=this._executableDir||"";if(this._scriptPath){let J;try{J=p.realpathSync(this._scriptPath)}catch(Y){J=this._scriptPath}I=z.resolve(z.dirname(J),I)}if(I){let J=q(I,R);if(!J&&!j._executableFile&&this._scriptPath){let Y=z.basename(this._scriptPath,z.extname(this._scriptPath));if(Y!==this._name)J=q(I,`${Y}-${j._name}`)}R=J||R}S=y.includes(z.extname(R));let E;if(M.platform!=="win32")if(S)$.unshift(R),$=Vj(M.execArgv).concat($),E=i.spawn(M.argv[0],$,{stdio:"inherit"});else E=i.spawn(R,$,{stdio:"inherit"});else $.unshift(R),$=Vj(M.execArgv).concat($),E=i.spawn(M.execPath,$,{stdio:"inherit"});if(!E.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Y)=>{M.on(Y,()=>{if(E.killed===!1&&E.exitCode===null)E.kill(Y)})});let P=this._exitCallback;E.on("close",(J)=>{if(J=J??1,!P)M.exit(J);else P(new o(J,"commander.executeSubCommandAsync","(close)"))}),E.on("error",(J)=>{if(J.code==="ENOENT"){let Y=I?`searched for local subcommand relative to directory '${I}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Z=`'${R}' does not exist
|
|
16
16
|
- if '${j._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
|
+
- ${Y}`;throw Error(Z)}else if(J.code==="EACCES")throw Error(`'${R}' not executable`);if(!P)M.exit(1);else{let Y=new o(1,"commander.executeSubCommandAsync","(error)");Y.nestedError=J,P(Y)}}),this.runningCommand=E}_dispatchSubcommand(j,$,S){let y=this._findCommand(j);if(!y)this.help({error:!0});let q;return q=this._chainOrCallSubCommandHook(q,y,"preSubcommand"),q=this._chainOrCall(q,()=>{if(y._executableHandler)this._executeSubCommand(y,$.concat(S));else return y._parseCommand($,S)}),q}_dispatchHelpCommand(j){if(!j)this.help();let $=this._findCommand(j);if($&&!$._executableHandler)$.help();return this._dispatchSubcommand(j,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((j,$)=>{if(j.required&&this.args[$]==null)this.missingArgument(j.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 j=(S,y,q)=>{let R=y;if(y!==null&&S.parseArg){let I=`error: command-argument value '${y}' is invalid for argument '${S.name()}'.`;R=this._callParseArg(S,y,q,I)}return R};this._checkNumberOfArguments();let $=[];this.registeredArguments.forEach((S,y)=>{let q=S.defaultValue;if(S.variadic){if(y<this.args.length){if(q=this.args.slice(y),S.parseArg)q=q.reduce((R,I)=>{return j(S,I,R)},S.defaultValue)}else if(q===void 0)q=[]}else if(y<this.args.length){if(q=this.args[y],S.parseArg)q=j(S,q,S.defaultValue)}$[y]=q}),this.processedArgs=$}_chainOrCall(j,$){if(j&&j.then&&typeof j.then==="function")return j.then(()=>$());return $()}_chainOrCallHooks(j,$){let S=j,y=[];if(this._getCommandAndAncestors().reverse().filter((q)=>q._lifeCycleHooks[$]!==void 0).forEach((q)=>{q._lifeCycleHooks[$].forEach((R)=>{y.push({hookedCommand:q,callback:R})})}),$==="postAction")y.reverse();return y.forEach((q)=>{S=this._chainOrCall(S,()=>{return q.callback(q.hookedCommand,this)})}),S}_chainOrCallSubCommandHook(j,$,S){let y=j;if(this._lifeCycleHooks[S]!==void 0)this._lifeCycleHooks[S].forEach((q)=>{y=this._chainOrCall(y,()=>{return q(this,$)})});return y}_parseCommand(j,$){let S=this.parseOptions($);if(this._parseOptionsEnv(),this._parseOptionsImplied(),j=j.concat(S.operands),$=S.unknown,this.args=j.concat($),j&&this._findCommand(j[0]))return this._dispatchSubcommand(j[0],j.slice(1),$);if(this._getHelpCommand()&&j[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(j[1]);if(this._defaultCommandName)return this._outputHelpIfRequested($),this._dispatchSubcommand(this._defaultCommandName,j,$);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(S.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let y=()=>{if(S.unknown.length>0)this.unknownOption(S.unknown[0])},q=`command:${this.name()}`;if(this._actionHandler){y(),this._processArguments();let R;if(R=this._chainOrCallHooks(R,"preAction"),R=this._chainOrCall(R,()=>this._actionHandler(this.processedArgs)),this.parent)R=this._chainOrCall(R,()=>{this.parent.emit(q,j,$)});return R=this._chainOrCallHooks(R,"postAction"),R}if(this.parent&&this.parent.listenerCount(q))y(),this._processArguments(),this.parent.emit(q,j,$);else if(j.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",j,$);if(this.listenerCount("command:*"))this.emit("command:*",j,$);else if(this.commands.length)this.unknownCommand();else y(),this._processArguments()}else if(this.commands.length)y(),this.help({error:!0});else y(),this._processArguments()}_findCommand(j){if(!j)return;return this.commands.find(($)=>$._name===j||$._aliases.includes(j))}_findOption(j){return this.options.find(($)=>$.is(j))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((j)=>{j.options.forEach(($)=>{if($.mandatory&&j.getOptionValue($.attributeName())===void 0)j.missingMandatoryOptionValue($)})})}_checkForConflictingLocalOptions(){let j=this.options.filter((S)=>{let y=S.attributeName();if(this.getOptionValue(y)===void 0)return!1;return this.getOptionValueSource(y)!=="default"});j.filter((S)=>S.conflictsWith.length>0).forEach((S)=>{let y=j.find((q)=>S.conflictsWith.includes(q.attributeName()));if(y)this._conflictingOption(S,y)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((j)=>{j._checkForConflictingLocalOptions()})}parseOptions(j){let $=[],S=[],y=$,q=j.slice();function R(E){return E.length>1&&E[0]==="-"}let I=null;while(q.length){let E=q.shift();if(E==="--"){if(y===S)y.push(E);y.push(...q);break}if(I&&!R(E)){this.emit(`option:${I.name()}`,E);continue}if(I=null,R(E)){let P=this._findOption(E);if(P){if(P.required){let J=q.shift();if(J===void 0)this.optionMissingArgument(P);this.emit(`option:${P.name()}`,J)}else if(P.optional){let J=null;if(q.length>0&&!R(q[0]))J=q.shift();this.emit(`option:${P.name()}`,J)}else this.emit(`option:${P.name()}`);I=P.variadic?P:null;continue}}if(E.length>2&&E[0]==="-"&&E[1]!=="-"){let P=this._findOption(`-${E[1]}`);if(P){if(P.required||P.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${P.name()}`,E.slice(2));else this.emit(`option:${P.name()}`),q.unshift(`-${E.slice(2)}`);continue}}if(/^--[^=]+=/.test(E)){let P=E.indexOf("="),J=this._findOption(E.slice(0,P));if(J&&(J.required||J.optional)){this.emit(`option:${J.name()}`,E.slice(P+1));continue}}if(R(E))y=S;if((this._enablePositionalOptions||this._passThroughOptions)&&$.length===0&&S.length===0){if(this._findCommand(E)){if($.push(E),q.length>0)S.push(...q);break}else if(this._getHelpCommand()&&E===this._getHelpCommand().name()){if($.push(E),q.length>0)$.push(...q);break}else if(this._defaultCommandName){if(S.push(E),q.length>0)S.push(...q);break}}if(this._passThroughOptions){if(y.push(E),q.length>0)y.push(...q);break}y.push(E)}return{operands:$,unknown:S}}opts(){if(this._storeOptionsAsProperties){let j={},$=this.options.length;for(let S=0;S<$;S++){let y=this.options[S].attributeName();j[y]=y===this._versionOptionName?this._version:this[y]}return j}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((j,$)=>Object.assign(j,$.opts()),{})}error(j,$){if(this._outputConfiguration.outputError(`${j}
|
|
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 S=$||{},
|
|
22
|
-
`),this._exit(0,"commander.version",j)}),this}description(j,$){if(j===void 0&&$===void 0)return this._description;if(this._description=j,$)this._argsDescription=$;return this}summary(j){if(j===void 0)return this._summary;return this._summary=j,this}alias(j){if(j===void 0)return this._aliases[0];let $=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)$=this.commands[this.commands.length-1];if(j===$._name)throw Error("Command alias can't be the same as its name");let S=this.parent?._findCommand(j);if(S){let
|
|
23
|
-
Expecting one of '${S.join("', '")}'`);let
|
|
24
|
-
`)}),this}_outputHelpIfRequested(j){let $=this._getHelpOption();if($&&j.find((
|
|
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 f1}from"node:util";import{execFile as
|
|
26
|
-
`);let S=await fetch(`${$}/api/cli-auth/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!S.ok){let
|
|
21
|
+
`),this.outputHelp({error:!0});let S=$||{},y=S.exitCode||1,q=S.code||"commander.error";this._exit(y,q,j)}_parseOptionsEnv(){this.options.forEach((j)=>{if(j.envVar&&j.envVar in M.env){let $=j.attributeName();if(this.getOptionValue($)===void 0||["default","config","env"].includes(this.getOptionValueSource($)))if(j.required||j.optional)this.emit(`optionEnv:${j.name()}`,M.env[j.envVar]);else this.emit(`optionEnv:${j.name()}`)}})}_parseOptionsImplied(){let j=new g$(this.options),$=(S)=>{return this.getOptionValue(S)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(S))};this.options.filter((S)=>S.implied!==void 0&&$(S.attributeName())&&j.valueFromOption(this.getOptionValue(S.attributeName()),S)).forEach((S)=>{Object.keys(S.implied).filter((y)=>!$(y)).forEach((y)=>{this.setOptionValueWithSource(y,S.implied[y],"implied")})})}missingArgument(j){let $=`error: missing required argument '${j}'`;this.error($,{code:"commander.missingArgument"})}optionMissingArgument(j){let $=`error: option '${j.flags}' argument missing`;this.error($,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(j){let $=`error: required option '${j.flags}' not specified`;this.error($,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(j,$){let S=(R)=>{let I=R.attributeName(),E=this.getOptionValue(I),P=this.options.find((Y)=>Y.negate&&I===Y.attributeName()),J=this.options.find((Y)=>!Y.negate&&I===Y.attributeName());if(P&&(P.presetArg===void 0&&E===!1||P.presetArg!==void 0&&E===P.presetArg))return P;return J||R},y=(R)=>{let I=S(R),E=I.attributeName();if(this.getOptionValueSource(E)==="env")return`environment variable '${I.envVar}'`;return`option '${I.flags}'`},q=`error: ${y(j)} cannot be used with ${y($)}`;this.error(q,{code:"commander.conflictingOption"})}unknownOption(j){if(this._allowUnknownOption)return;let $="";if(j.startsWith("--")&&this._showSuggestionAfterError){let y=[],q=this;do{let R=q.createHelp().visibleOptions(q).filter((I)=>I.long).map((I)=>I.long);y=y.concat(R),q=q.parent}while(q&&!q._enablePositionalOptions);$=Nj(j,y)}let S=`error: unknown option '${j}'${$}`;this.error(S,{code:"commander.unknownOption"})}_excessArguments(j){if(this._allowExcessArguments)return;let $=this.registeredArguments.length,S=$===1?"":"s",q=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${$} argument${S} but got ${j.length}.`;this.error(q,{code:"commander.excessArguments"})}unknownCommand(){let j=this.args[0],$="";if(this._showSuggestionAfterError){let y=[];this.createHelp().visibleCommands(this).forEach((q)=>{if(y.push(q.name()),q.alias())y.push(q.alias())}),$=Nj(j,y)}let S=`error: unknown command '${j}'${$}`;this.error(S,{code:"commander.unknownCommand"})}version(j,$,S){if(j===void 0)return this._version;this._version=j,$=$||"-V, --version",S=S||"output the version number";let y=this.createOption($,S);return this._versionOptionName=y.attributeName(),this._registerOption(y),this.on("option:"+y.name(),()=>{this._outputConfiguration.writeOut(`${j}
|
|
22
|
+
`),this._exit(0,"commander.version",j)}),this}description(j,$){if(j===void 0&&$===void 0)return this._description;if(this._description=j,$)this._argsDescription=$;return this}summary(j){if(j===void 0)return this._summary;return this._summary=j,this}alias(j){if(j===void 0)return this._aliases[0];let $=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)$=this.commands[this.commands.length-1];if(j===$._name)throw Error("Command alias can't be the same as its name");let S=this.parent?._findCommand(j);if(S){let y=[S.name()].concat(S.aliases()).join("|");throw Error(`cannot add alias '${j}' to command '${this.name()}' as already have command '${y}'`)}return $._aliases.push(j),this}aliases(j){if(j===void 0)return this._aliases;return j.forEach(($)=>this.alias($)),this}usage(j){if(j===void 0){if(this._usage)return this._usage;let $=this.registeredArguments.map((S)=>{return v$(S)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?$:[]).join(" ")}return this._usage=j,this}name(j){if(j===void 0)return this._name;return this._name=j,this}nameFromFilename(j){return this._name=z.basename(j,z.extname(j)),this}executableDir(j){if(j===void 0)return this._executableDir;return this._executableDir=j,this}helpInformation(j){let $=this.createHelp();if($.helpWidth===void 0)$.helpWidth=j&&j.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return $.formatHelp(this,$)}_getHelpContext(j){j=j||{};let $={error:!!j.error},S;if($.error)S=(y)=>this._outputConfiguration.writeErr(y);else S=(y)=>this._outputConfiguration.writeOut(y);return $.write=j.write||S,$.command=this,$}outputHelp(j){let $;if(typeof j==="function")$=j,j=void 0;let S=this._getHelpContext(j);this._getCommandAndAncestors().reverse().forEach((q)=>q.emit("beforeAllHelp",S)),this.emit("beforeHelp",S);let y=this.helpInformation(S);if($){if(y=$(y),typeof y!=="string"&&!Buffer.isBuffer(y))throw Error("outputHelp callback must return a string or a Buffer")}if(S.write(y),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",S),this._getCommandAndAncestors().forEach((q)=>q.emit("afterAllHelp",S))}helpOption(j,$){if(typeof j==="boolean"){if(j)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return j=j??"-h, --help",$=$??"display help for command",this._helpOption=this.createOption(j,$),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(j){return this._helpOption=j,this}help(j){this.outputHelp(j);let $=M.exitCode||0;if($===0&&j&&typeof j!=="function"&&j.error)$=1;this._exit($,"commander.help","(outputHelp)")}addHelpText(j,$){let S=["beforeAll","before","after","afterAll"];if(!S.includes(j))throw Error(`Unexpected value for position to addHelpText.
|
|
23
|
+
Expecting one of '${S.join("', '")}'`);let y=`${j}Help`;return this.on(y,(q)=>{let R;if(typeof $==="function")R=$({error:q.error,command:q.command});else R=$;if(R)q.write(`${R}
|
|
24
|
+
`)}),this}_outputHelpIfRequested(j){let $=this._getHelpOption();if($&&j.find((y)=>$.is(y)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Vj(j){return j.map(($)=>{if(!$.startsWith("--inspect"))return $;let S,y="127.0.0.1",q="9229",R;if((R=$.match(/^(--inspect(-brk)?)$/))!==null)S=R[1];else if((R=$.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(S=R[1],/^\d+$/.test(R[3]))q=R[3];else y=R[3];else if((R=$.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)S=R[1],y=R[3],q=R[4];if(S&&q!=="0")return`${S}=${y}:${parseInt(q)+1}`;return $})}m$.Command=n});var Cj=F((d$)=>{var{Argument:fj}=O(),{Command:a}=Aj(),{CommanderError:r$,InvalidArgumentError:wj}=k(),{Help:l$}=l(),{Option:xj}=d();d$.program=new a;d$.createCommand=(j)=>new a(j);d$.createOption=(j,$)=>new xj(j,$);d$.createArgument=(j,$)=>new fj(j,$);d$.Command=a;d$.Option=xj;d$.Argument=fj;d$.Help=l$;d$.CommanderError=r$;d$.InvalidArgumentError=wj;d$.InvalidOptionArgumentError=wj});var kj=G$(Cj(),1),{program:W,createCommand:SS,createArgument:yS,createOption:qS,CommanderError:RS,InvalidArgumentError:ES,InvalidOptionArgumentError:IS,Command:PS,Argument:JS,Option:YS,Help:TS}=kj.default;var bj="0.1.1";import{homedir as E1}from"os";import{join as uj}from"path";import{existsSync as e,mkdirSync as I1,readFileSync as P1,writeFileSync as J1,unlinkSync as Y1}from"fs";function Oj(){let j=process.env.ACE_TEST_HOME??E1();return uj(j,".ace")}function jj(){return uj(Oj(),"credentials.json")}var T1=process.env.DEBUG==="true"||process.env.ACE_DEBUG==="true";function A(j,...$){if(T1)console.error(`[ace-cli debug] ${j}`,...$)}function Q1(){let j=Oj();if(!e(j))I1(j,{recursive:!0,mode:448})}function B(){try{let j=jj();if(!e(j))return A("Credentials file does not exist:",j),null;let $=P1(j,"utf-8"),S=JSON.parse($);if(S.expiresAt&&new Date(S.expiresAt)<new Date)return A("Token expired at:",S.expiresAt),null;return S}catch(j){return A("Error reading credentials:",j),null}}function $j(j){Q1();let $=jj();J1($,JSON.stringify(j,null,2),{mode:384}),A("Credentials saved to:",$)}function Sj(){try{let j=jj();if(e(j))return Y1(j),A("Credentials cleared"),!0;return!1}catch(j){return A("Error clearing credentials:",j),!1}}function b(){return B()?.apiUrl??process.env.ACE_API_URL??"https://aceisyourassistant.com"}import Uj from"node:process";import{Buffer as pj}from"node:buffer";import oj from"node:path";import{fileURLToPath as O1}from"node:url";import{promisify as c1}from"node:util";import nj from"node:child_process";import h1,{constants as v1}from"node:fs/promises";import tj from"node:process";import gj,{constants as z1}from"node:fs/promises";import vj from"node:process";import X1 from"node:os";import _1 from"node:fs";import G1 from"node:fs";import cj from"node:fs";var yj;function U1(){try{return cj.statSync("/.dockerenv"),!0}catch{return!1}}function Z1(){try{return cj.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function qj(){if(yj===void 0)yj=U1()||Z1();return yj}var Rj,M1=()=>{try{return G1.statSync("/run/.containerenv"),!0}catch{return!1}};function f(){if(Rj===void 0)Rj=M1()||qj();return Rj}var hj=()=>{if(vj.platform!=="linux")return!1;if(X1.release().toLowerCase().includes("microsoft")){if(f())return!1;return!0}try{return _1.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!f():!1}catch{return!1}},L=vj.env.__IS_WSL_TEST__?hj:hj();var W1=(()=>{let $;return async function(){if($)return $;let S="/etc/wsl.conf",y=!1;try{await gj.access(S,z1.F_OK),y=!0}catch{}if(!y)return"/mnt/";let q=await gj.readFile(S,{encoding:"utf8"}),R=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(q);if(!R)return"/mnt/";return $=R.groups.mountPoint.trim(),$=$.endsWith("/")?$:`${$}/`,$}})(),H1=async()=>{return`${await W1()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},Ej=async()=>{if(L)return H1();return`${tj.env.SYSTEMROOT||tj.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`};function D(j,$,S){let y=(q)=>Object.defineProperty(j,$,{value:q,enumerable:!0,writable:!0});return Object.defineProperty(j,$,{configurable:!0,enumerable:!0,get(){let q=S();return y(q),q},set(q){y(q)}}),j}import{promisify as C1}from"node:util";import Tj from"node:process";import{execFile as k1}from"node:child_process";import{promisify as L1}from"node:util";import D1 from"node:process";import{execFile as K1}from"node:child_process";var F1=L1(K1);async function Ij(){if(D1.platform!=="darwin")throw Error("macOS only");let{stdout:j}=await F1("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),S=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(j)?.groups.id??"com.apple.Safari";if(S==="com.apple.safari")return"com.apple.Safari";return S}import B1 from"node:process";import{promisify as N1}from"node:util";import{execFile as V1,execFileSync as tS}from"node:child_process";var A1=N1(V1);async function mj(j,{humanReadableOutput:$=!0,signal:S}={}){if(B1.platform!=="darwin")throw Error("macOS only");let y=$?[]:["-ss"],q={};if(S)q.signal=S;let{stdout:R}=await A1("osascript",["-e",j,y],q);return R.trim()}async function Pj(j){return mj(`tell application "Finder" to set app_path to application file id "${j}" 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 f1}from"node:util";import{execFile as w1}from"node:child_process";var x1=f1(w1),sj={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"}},dS=new Map(Object.entries(sj));class Jj extends Error{}async function Yj(j=x1){let{stdout:$}=await j("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),S=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec($);if(!S)throw new Jj(`Cannot find Windows browser in stdout: ${JSON.stringify($)}`);let{id:y}=S.groups,q=sj[y];if(!q)throw new Jj(`Unknown browser ID: ${y}`);return q}var b1=C1(k1),u1=(j)=>j.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,($)=>$.toUpperCase());async function Qj(){if(Tj.platform==="darwin"){let j=await Ij();return{name:await Pj(j),id:j}}if(Tj.platform==="linux"){let{stdout:j}=await b1("xdg-mime",["query","default","x-scheme-handler/http"]),$=j.trim();return{name:u1($.replace(/.desktop$/,"").replace("-"," ")),id:$}}if(Tj.platform==="win32")return Yj();throw Error("Only macOS, Linux, and Windows are supported")}var t1=c1(nj.execFile),Zj=oj.dirname(O1(import.meta.url)),rj=oj.join(Zj,"xdg-open"),{platform:w,arch:lj}=Uj;async function g1(){let j=await Ej(),$=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,S=pj.from($,"utf16le").toString("base64"),{stdout:y}=await t1(j,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",S],{encoding:"utf8"}),q=y.trim(),R={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return R[q]?{id:R[q]}:{}}var dj=async(j,$)=>{let S;for(let y of j)try{return await $(y)}catch(q){S=q}throw S},c=async(j)=>{if(j={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...j},Array.isArray(j.app))return dj(j.app,(E)=>c({...j,app:E}));let{name:$,arguments:S=[]}=j.app??{};if(S=[...S],Array.isArray($))return dj($,(E)=>c({...j,app:{name:E,arguments:S}}));if($==="browser"||$==="browserPrivate"){let E={"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"},P={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},J=L?await g1():await Qj();if(J.id in E){let Y=E[J.id];if($==="browserPrivate")S.push(P[Y]);return c({...j,app:{name:N[Y],arguments:S}})}throw Error(`${J.name} is not supported as a default browser`)}let y,q=[],R={};if(w==="darwin"){if(y="open",j.wait)q.push("--wait-apps");if(j.background)q.push("--background");if(j.newInstance)q.push("--new");if($)q.push("-a",$)}else if(w==="win32"||L&&!f()&&!$){if(y=await Ej(),q.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),!L)R.windowsVerbatimArguments=!0;let E=["Start"];if(j.wait)E.push("-Wait");if($){if(E.push(`"\`"${$}\`""`),j.target)S.push(j.target)}else if(j.target)E.push(`"${j.target}"`);if(S.length>0)S=S.map((P)=>`"\`"${P}\`""`),E.push("-ArgumentList",S.join(","));j.target=pj.from(E.join(" "),"utf16le").toString("base64")}else{if($)y=$;else{let E=!Zj||Zj==="/",P=!1;try{await h1.access(rj,v1.X_OK),P=!0}catch{}y=Uj.versions.electron??(w==="android"||E||!P)?"xdg-open":rj}if(S.length>0)q.push(...S);if(!j.wait)R.stdio="ignore",R.detached=!0}if(w==="darwin"&&S.length>0)q.push("--args",...S);if(j.target)q.push(j.target);let I=nj.spawn(y,q,R);if(j.wait)return new Promise((E,P)=>{I.once("error",P),I.once("close",(J)=>{if(!j.allowNonzeroExitCode&&J>0){P(Error(`Exited with code ${J}`));return}E(I)})});return I.unref(),I},m1=(j,$)=>{if(typeof j!=="string")throw TypeError("Expected a `target`");return c({...$,target:j})};function ij(j){if(typeof j==="string"||Array.isArray(j))return j;let{[lj]:$}=j;if(!$)throw Error(`${lj} is not supported`);return $}function h({[w]:j},{wsl:$}){if($&&L)return ij($);if(!j)throw Error(`${w} is not supported`);return ij(j)}var N={};D(N,"chrome",()=>h({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"]}}));D(N,"brave",()=>h({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"]}}));D(N,"firefox",()=>h({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));D(N,"edge",()=>h({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));D(N,"browser",()=>"browser");D(N,"browserPrivate",()=>"browserPrivate");var aj=m1;var s1=2000,r1=600;async function Gj(j){let $=j??b();console.log(`Initiating authentication...
|
|
26
|
+
`);let S=await fetch(`${$}/api/cli-auth/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!S.ok){let Z=await S.text();throw Error(`Failed to initiate auth: ${Z}`)}let{deviceCode:y,userCode:q,verificationUrl:R,interval:I,expiresIn:E}=await S.json(),P=(I||s1/1000)*1000,J=Math.ceil((E||r1)/(P/1000));console.log("Opening browser to authenticate..."),console.log(""),console.log(` Your code: ${q}`),console.log(""),console.log(` Or visit: ${R}`),console.log(""),await aj(R),console.log("Waiting for authorization...");let Y=0;while(Y<J){await l1(P),Y++;try{let Z=await fetch(`${$}/api/cli-auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:y})});if(!Z.ok){if(Z.status===400)continue;throw Error(`Poll failed: ${await Z.text()}`)}let X=await Z.json();if(X.status==="authorized"&&X.token){let G={apiUrl:$,token:X.token.token,expiresAt:X.token.expiresAt,userId:X.token.userId,userEmail:X.token.userEmail};$j(G),console.log(""),console.log(`Authenticated as ${X.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(X.status==="expired")throw Error("Authentication code expired. Please try again.")}catch(Z){if(Z instanceof TypeError)continue;throw Z}}throw Error("Authentication timed out. Please try again.")}function l1(j){return new Promise(($)=>setTimeout($,j))}function T(){return process.argv.includes("--json")}function Q(j,$){if($?.json||T())console.log(JSON.stringify(j,null,2));else if(typeof j==="string")console.log(j);else console.log(JSON.stringify(j,null,2))}function U(j){if(T())console.log(JSON.stringify({error:j}));else console.error(`Error: ${j}`)}function K(j){let $=[`[${j.id.slice(0,8)}] ${j.name}`];if(j.project_name)$.push(`(${j.project_name})`);if(j.dueDate)$.push(`due: ${j.dueDate}`);if(j.status==="waiting"&&j.waitingFor)$.push(`waiting: ${j.waitingFor}`);return $.join(" ")}function V(j){let $=[`[${j.id.slice(0,8)}] ${j.name}`];if(j.category_name)$.push(`(${j.category_name})`);if(j.status!=="active")$.push(`[${j.status}]`);return $.join(" ")}function x(j,$){if(j.length===0)return $?`${$}: (none)`:"(no actions)";let S=j.map((y)=>` ${K(y)}`);if($)return`${$} (${j.length}):
|
|
27
27
|
${S.join(`
|
|
28
28
|
`)}`;return S.join(`
|
|
29
|
-
`)}function u(j,$){if(j.length===0)return $?`${$}: (none)`:"(no projects)";let S=j.map((
|
|
29
|
+
`)}function u(j,$){if(j.length===0)return $?`${$}: (none)`:"(no projects)";let S=j.map((y)=>` ${V(y)}`);if($)return`${$} (${j.length}):
|
|
30
30
|
${S.join(`
|
|
31
31
|
`)}`;return S.join(`
|
|
32
|
-
`)}function ej(j){let $=[];$.push(`Inbox: ${j.inboxCount} items`);let S=j.domains.map((
|
|
32
|
+
`)}function ej(j){let $=[];$.push(`Inbox: ${j.inboxCount} items`);let S=j.domains.map((y)=>` ${y.name}: ${y.active_count}/${y.activeProjectLimit} active`);if($.push(`Capacity:
|
|
33
33
|
${S.join(`
|
|
34
34
|
`)}`),j.activeProjects.length>0)$.push(u(j.activeProjects,"Active Projects"));if(j.overdue.length>0)$.push(x(j.overdue,"Overdue"));if(j.dueToday.length>0)$.push(x(j.dueToday,"Due Today"));if(j.waiting.length>0)$.push(x(j.waiting,"Waiting"));return $.join(`
|
|
35
35
|
|
|
36
|
-
`)}function j$(j){let $=j.command("auth").description("Manage authentication");$.command("login").description("Authenticate with Ace").option("--api-url <url>","Ace API URL (default: https://
|
|
37
|
-
Notes: ${
|
|
38
|
-
Contexts: ${
|
|
39
|
-
The One Thing: ${
|
|
40
|
-
Notes: ${
|
|
41
|
-
Status: ${
|
|
36
|
+
`)}function j$(j){let $=j.command("auth").description("Manage authentication");$.command("login").description("Authenticate with Ace").option("--api-url <url>","Ace API URL (default: https://aceisyourassistant.com)").action(async(S)=>{try{await Gj(S.apiUrl)}catch(y){U(y instanceof Error?y.message:"Login failed"),process.exit(1)}}),$.command("logout").description("Remove stored credentials").action(()=>{let S=Sj();if(T())Q({success:S});else if(S)console.log("Logged out successfully");else console.log("No credentials to remove")}),$.command("status").description("Show current authentication status").action(()=>{let S=B();if(T())Q({authenticated:!!S,email:S?.userEmail??null,apiUrl:S?.apiUrl??null});else if(S)console.log(`Authenticated as ${S.userEmail}`),console.log(`API URL: ${S.apiUrl}`);else console.log("Not authenticated. Run: ace auth login")}),$.command("whoami").description("Show current user").action(()=>{let S=B();if(T())Q({authenticated:!!S,email:S?.userEmail??null,userId:S?.userId??null});else if(S)console.log(S.userEmail);else console.log("Not authenticated"),process.exit(1)})}class Xj extends Error{status;body;constructor(j,$,S){super(j);this.status=$;this.body=S;this.name="ApiError"}}class Mj extends Xj{constructor(j="Not authenticated. Run: ace auth login"){super(j,401);this.name="AuthError"}}async function _(j,$={},S){let y=B();if(!y)throw new Mj;let R=`${S??y.apiUrl??b()}/api${j}`,I=await fetch(R,{...$,headers:{Authorization:`Bearer ${y.token}`,"Content-Type":"application/json",...$.headers}});if(I.status===401)throw new Mj("Session expired. Run: ace auth login");if(!I.ok){let E=await I.json().catch(()=>({}));throw new Xj(E.error??`Request failed with status ${I.status}`,I.status,E)}return I.json()}async function $$(){return _("/dashboard")}async function v(j={}){let $=new URLSearchParams;if(j.status)$.set("status",j.status);if(j.projectId)$.set("project_id",j.projectId);if(j.contextId)$.set("context_id",j.contextId);if(j.search)$.set("search",j.search);if(j.limit)$.set("limit",String(j.limit));if(j.offset)$.set("offset",String(j.offset));let S=$.toString(),y=S?`/actions?${S}`:"/actions";return(await _(y)).actions}async function S$(j){return _(`/actions/${j}`)}async function t(j){return _("/actions",{method:"POST",body:JSON.stringify(j)})}async function _j(j,$){return _(`/actions/${j}`,{method:"PUT",body:JSON.stringify($)})}async function y$(j){return _j(j,{status:"completed"})}async function q$(j){await _(`/actions/${j}`,{method:"DELETE"})}async function g(j={}){let $=new URLSearchParams;if(j.status)$.set("status",j.status);if(j.domain)$.set("domain",j.domain);if(j.categoryId)$.set("category_id",j.categoryId);if(j.search)$.set("search",j.search);if(j.dueForReview)$.set("due_for_review","true");let S=$.toString(),y=S?`/projects?${S}`:"/projects";return(await _(y)).projects}async function R$(j){return _(`/projects/${j}`)}async function E$(j){return _("/projects",{method:"POST",body:JSON.stringify(j)})}async function m(j,$){return _(`/projects/${j}`,{method:"PUT",body:JSON.stringify($)})}function I$(j){j.command("capture").description("Quick capture an item to inbox").argument("<text>","The item to capture").option("-n, --notes <notes>","Additional notes").action(async($,S)=>{try{let y=await t({name:$,status:"inbox",notes:S.notes});if(T())Q(y);else console.log(`Captured: ${K(y)}`)}catch(y){U(y instanceof Error?y.message:"Capture failed"),process.exit(1)}})}function P$(j){j.command("orient").description("Daily orientation - see your current state").alias("dashboard").action(async()=>{try{let $=await $$();if(T())Q($);else console.log(ej($))}catch($){U($ instanceof Error?$.message:"Failed to load dashboard"),process.exit(1)}})}function J$(j){let $=j.command("actions").description("Manage actions");$.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").action(async(S)=>{try{let y=await v({status:S.status,projectId:S.project,contextId:S.context,search:S.search,limit:parseInt(S.limit)});if(T())Q({actions:y});else{let q=S.status?`${S.status} actions`:"Actions";console.log(x(y,q))}}catch(y){U(y instanceof Error?y.message:"Failed to list actions"),process.exit(1)}}),$.command("inbox").description("List inbox items").action(async()=>{try{let S=await v({status:"inbox"});if(T())Q({actions:S,count:S.length});else console.log(x(S,"Inbox"))}catch(S){U(S instanceof Error?S.message:"Failed to list inbox"),process.exit(1)}}),$.command("get <id>").description("Get action details").action(async(S)=>{try{let y=await S$(S);if(T())Q(y);else{if(console.log(K(y)),y.notes)console.log(`
|
|
37
|
+
Notes: ${y.notes}`);if(y.contexts.length>0)console.log(`
|
|
38
|
+
Contexts: ${y.contexts.map((q)=>q.name).join(", ")}`)}}catch(y){U(y instanceof Error?y.message:"Failed to get action"),process.exit(1)}}),$.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(S,y)=>{try{let q=await t({name:S,status:y.status??"inbox",projectId:y.project,dueDate:y.due,notes:y.notes});if(T())Q(q);else console.log(`Created: ${K(q)}`)}catch(q){U(q instanceof Error?q.message:"Failed to create action"),process.exit(1)}}),$.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(S,y)=>{try{let q={};if(y.name)q.name=y.name;if(y.status)q.status=y.status;if(y.project==="none")q.projectId=null;else if(y.project)q.projectId=y.project;if(y.due==="none")q.dueDate=null;else if(y.due)q.dueDate=y.due;if(y.notes)q.notes=y.notes;if(y.waiting)q.waitingFor=y.waiting,q.status="waiting";let R=await _j(S,q);if(T())Q(R);else console.log(`Updated: ${K(R)}`)}catch(q){U(q instanceof Error?q.message:"Failed to update action"),process.exit(1)}}),$.command("complete <id>").description("Mark an action as completed").action(async(S)=>{try{let y=await y$(S);if(T())Q(y);else console.log(`Completed: ${K(y)}`)}catch(y){U(y instanceof Error?y.message:"Failed to complete action"),process.exit(1)}}),$.command("delete <id>").description("Delete an action").action(async(S)=>{try{if(await q$(S),T())Q({success:!0,id:S});else console.log(`Deleted action ${S}`)}catch(y){U(y instanceof Error?y.message:"Failed to delete action"),process.exit(1)}}),$.command("count").description("Count actions by status").option("-s, --status <status>","Status to count (default: inbox)").action(async(S)=>{try{let y=S.status??"inbox",q=await v({status:y});if(T())Q({status:y,count:q.length});else console.log(`${y}: ${q.length}`)}catch(y){U(y instanceof Error?y.message:"Failed to count actions"),process.exit(1)}})}function Y$(j){let $=j.command("projects").description("Manage projects");$.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(S)=>{try{let y=await g({status:S.status,domain:S.domain,categoryId:S.category,search:S.search,dueForReview:S.review});if(T())Q({projects:y});else{let q=S.status?`${S.status} projects`:"Projects";console.log(u(y,q))}}catch(y){U(y instanceof Error?y.message:"Failed to list projects"),process.exit(1)}}),$.command("active").description("List active projects").option("-d, --domain <domain>","Filter by domain (Work, Personal)").action(async(S)=>{try{let y=await g({status:"active",domain:S.domain});if(T())Q({projects:y,count:y.length});else console.log(u(y,"Active Projects"))}catch(y){U(y instanceof Error?y.message:"Failed to list active projects"),process.exit(1)}}),$.command("get <id>").description("Get project details").action(async(S)=>{try{let y=await R$(S);if(T())Q(y);else{if(console.log(V(y)),y.theOneThing)console.log(`
|
|
39
|
+
The One Thing: ${y.theOneThing}`);if(y.notes)console.log(`
|
|
40
|
+
Notes: ${y.notes}`);if(console.log(`
|
|
41
|
+
Status: ${y.status}`),y.reviewAfter)console.log(`Review after: ${y.reviewAfter}`)}}catch(y){U(y instanceof Error?y.message:"Failed to get project"),process.exit(1)}}),$.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(S,y)=>{try{let q=await E$({name:S,status:y.status??"incubating",categoryId:y.category,theOneThing:y.theOneThing,notes:y.notes});if(T())Q(q);else console.log(`Created: ${V(q)}`)}catch(q){U(q instanceof Error?q.message:"Failed to create project"),process.exit(1)}}),$.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(S,y)=>{try{let q={};if(y.name)q.name=y.name;if(y.status)q.status=y.status;if(y.category==="none")q.categoryId=null;else if(y.category)q.categoryId=y.category;if(y.theOneThing)q.theOneThing=y.theOneThing;if(y.notes)q.notes=y.notes;let R=await m(S,q);if(T())Q(R);else console.log(`Updated: ${V(R)}`)}catch(q){U(q instanceof Error?q.message:"Failed to update project"),process.exit(1)}}),$.command("activate <id>").description("Set project status to active").action(async(S)=>{try{let y=await m(S,{status:"active"});if(T())Q(y);else console.log(`Activated: ${V(y)}`)}catch(y){U(y instanceof Error?y.message:"Failed to activate project"),process.exit(1)}}),$.command("complete <id>").description("Mark a project as completed").action(async(S)=>{try{let y=await m(S,{status:"completed"});if(T())Q(y);else console.log(`Completed: ${V(y)}`)}catch(y){U(y instanceof Error?y.message:"Failed to complete project"),process.exit(1)}}),$.command("review").description("List projects due for review").action(async()=>{try{let S=await g({dueForReview:!0});if(T())Q({projects:S,count:S.length});else console.log(u(S,"Projects Due for Review"))}catch(S){U(S instanceof Error?S.message:"Failed to list projects for review"),process.exit(1)}})}W.name("ace").description("CLI for Ace productivity assistant").version(bj);j$(W);I$(W);P$(W);J$(W);Y$(W);W.option("--json","Output in JSON format for AI consumption").option("--api-url <url>","Override API URL");W.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ace-assistant-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI for Ace productivity assistant - bring your own AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"bin"
|
|
12
|
+
"bin",
|
|
13
|
+
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"dev": "bun run src/index.ts",
|
|
16
17
|
"build": "bun build src/index.ts --outdir dist --target node --minify",
|
|
17
18
|
"test": "bun test",
|
|
18
19
|
"test:watch": "bun test --watch",
|
|
19
|
-
"prepublishOnly": "bun run build",
|
|
20
|
+
"prepublishOnly": "bun run build && cp README.md README.dev.md && cp README.npm.md README.md",
|
|
21
|
+
"postpublish": "test -f README.dev.md && mv README.dev.md README.md || echo 'Warning: README.dev.md not found'",
|
|
20
22
|
"typecheck": "tsc --noEmit"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {
|