donebear 0.3.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/AGENTS.md ADDED
@@ -0,0 +1,129 @@
1
+ # donebear
2
+
3
+ Done Bear command-line interface for OAuth auth, workspace management, and task workflows.
4
+
5
+ ## Commands
6
+
7
+ Run from repo root:
8
+
9
+ - `npm run build --workspace=apps/cli` — build with tsdown
10
+ - `npm run dev --workspace=apps/cli` — watch build
11
+ - `npm run lint --workspace=apps/cli` — lint with Oxlint
12
+ - `npm run check-types --workspace=apps/cli` — TypeScript check
13
+ - `npm run test --workspace=apps/cli` — Vitest tests
14
+ - `npm exec -- ultracite fix` — format/autofix before commit
15
+
16
+ Run CLI locally from repo root:
17
+
18
+ - `npm exec --workspace=apps/cli donebear -- --help`
19
+
20
+ ## Agent Quickstart
21
+
22
+ These two commands orient an AI agent before doing any work:
23
+
24
+ ```bash
25
+ # Discover all CLI commands and options (no auth required, ~500 tokens)
26
+ donebear spec
27
+ donebear spec task add # Detailed spec for one command
28
+
29
+ # Get current workspace state (requires auth)
30
+ donebear context --json
31
+ donebear context --markdown # Markdown for system prompt injection
32
+ ```
33
+
34
+ ### Non-interactive / CI use
35
+
36
+ Set `DONEBEAR_TOKEN` instead of running `donebear auth login`:
37
+
38
+ ```bash
39
+ export DONEBEAR_TOKEN=<your-token>
40
+ donebear task list --json
41
+ donebear task add "Fix bug" --when today --json
42
+ ```
43
+
44
+ ### Common agent patterns
45
+
46
+ ```bash
47
+ # Discover → orient → act
48
+ donebear spec task add # read field reference
49
+ donebear context --json # check current workspace + task counts
50
+ donebear task list --json # list open tasks
51
+ donebear task add "Fix X" --when today --json
52
+ donebear task done <id> --json
53
+
54
+ # Task id: full UUID or prefix of >= 4 chars
55
+ donebear task show 8f2c --json
56
+ donebear task edit 8f2c --deadline 2026-03-20 --json
57
+
58
+ # Workspace targeting (no flag needed)
59
+ donebear workspace=myorg task list --json
60
+ ```
61
+
62
+ ## Architecture
63
+
64
+ ```text
65
+ src/
66
+ cli.ts # Commander entrypoint + global flags
67
+ runtime.ts # context parsing, error handling, interactive detection
68
+ command-context.ts # auth/API/context resolution for commands
69
+ command-helpers.ts # workspace normalization, task state parsing
70
+ command-parsers.ts # input validators (positive int, etc.)
71
+ manage-api.ts # legacy API helpers (GraphQL loaders)
72
+ workspace-context.ts # workspace slug validation + default resolution
73
+ task-defaults.ts # task view-to-start field mapping
74
+ output.ts # JSON/CSV/TSV/text/clipboard output formatting
75
+ types.ts # shared TypeScript interfaces for all models
76
+ constants.ts # env var names, defaults, config paths
77
+ errors.ts # CliError class + exit codes
78
+ date-codecs.ts # ISO 8601 date-only/instant parsing + epoch conversion
79
+ env.ts # dotenv loading from workspace .env files
80
+ auth-session.ts # token precedence + refresh behavior
81
+ supabase.ts # Supabase config + auth client helpers
82
+ oauth.ts # OAuth state generation
83
+ oauth-callback.ts # loopback callback server for OAuth PKCE
84
+ context-store.ts # local context cache (workspace + clientId)
85
+ storage.ts # stored auth session persistence
86
+ browser.ts # platform-aware URL opening
87
+ index.ts # library re-exports
88
+ api/
89
+ http.ts # base fetch wrapper, NDJSON streaming, error handling
90
+ sync.ts # sync protocol (mutateModel, batch reads)
91
+ commands/
92
+ auth.ts # auth login/status/logout
93
+ whoami.ts # current user output
94
+ workspace.ts # workspace list/current/use/clear/create/join
95
+ task.ts # task list/show/add/edit/done/reopen/archive/unarchive
96
+ project.ts # project list/show/add/edit/done/archive/unarchive
97
+ label.ts # label list/show
98
+ team.ts # team list/show
99
+ today.ts # today's tasks shortcut
100
+ search.ts # task search across workspace
101
+ history.ts # workspace audit log
102
+ spec.ts # progressive CLI spec (no auth, static data)
103
+ context.ts # workspace state snapshot (auth + workspace required)
104
+ api-key.ts # API key create/list/revoke
105
+ import.ts # Things 3 import (uses import/ modules)
106
+ interactive.ts # TUI mode (no args + TTY stdin)
107
+ import/
108
+ things-runner.ts # orchestrates full Things 3 import pipeline
109
+ things-sqlite.ts # reads Things 3 SQLite database
110
+ things-mapper.ts # maps Things rows to Done Bear sync transactions
111
+ things-values.ts # Things date/field value decoders
112
+ things-labels.ts # label normalization for import dedup
113
+ things-recurrence.ts # Things recurrence to RRule conversion
114
+ things-output.ts # import result summary formatting
115
+ model-id.ts # deterministic UUID generation for imports
116
+ time-zone.ts # calendar date/time zone helpers
117
+ tests/ # Vitest — npm run test --workspace=apps/cli
118
+ ```
119
+
120
+ ## Gotchas
121
+
122
+ - OAuth callback defaults to `http://127.0.0.1:8787/auth/callback`; it must be allow-listed in Supabase redirect URLs.
123
+ - Token precedence is `--token` > `DONEBEAR_TOKEN` > stored auth session.
124
+ - API URL precedence is `--api-url` > `DONEBEAR_API_URL` > `NEXT_PUBLIC_RESERVE_MANAGE_API` > `http://127.0.0.1:3001`.
125
+ - Local auth/context files are unencrypted and stored in the OS config dir (`DONEBEAR_CONFIG_DIR` can override).
126
+ - `task` commands accept ID prefixes; prefix resolution is workspace-scoped and may be ambiguous without `--workspace`.
127
+ - Use `--json` for scripts/automation and keep human-readable output as default.
128
+ - `spec` command returns JSON regardless of `--format` — it is always machine-targeted.
129
+ - `context --markdown` uses `--markdown` (local flag), not the global `--format` option.
package/README.md ADDED
@@ -0,0 +1,251 @@
1
+ # donebear
2
+
3
+ Done Bear CLI for OAuth auth, workspace management, and task workflows against `manage-api`.
4
+
5
+ ## Quick start
6
+
7
+ 1. Install workspace dependencies from repo root:
8
+
9
+ ```bash
10
+ npm install
11
+ ```
12
+
13
+ 2. Build the CLI package:
14
+
15
+ ```bash
16
+ npm run build --workspace=apps/cli
17
+ ```
18
+
19
+ 3. Set required environment variables:
20
+
21
+ ```bash
22
+ export DONEBEAR_SUPABASE_URL="https://<project-ref>.supabase.co"
23
+ export DONEBEAR_SUPABASE_PUBLISHABLE_KEY="<publishable-or-anon-key>"
24
+ export DONEBEAR_API_URL="http://127.0.0.1:3001"
25
+ ```
26
+
27
+ 4. Define a local runner command:
28
+
29
+ ```bash
30
+ CLI="npm exec --workspace=apps/cli donebear --"
31
+ ```
32
+
33
+ 5. Authenticate and run the core task flow:
34
+
35
+ ```bash
36
+ $CLI auth login
37
+ $CLI workspace list
38
+ $CLI workspace use <workspace-id-or-slug>
39
+ $CLI task add "Ship donebear CLI" --when today
40
+ $CLI task list --state open
41
+ ```
42
+
43
+ ## OAuth setup
44
+
45
+ The default callback URL is:
46
+
47
+ ```text
48
+ http://127.0.0.1:8787/auth/callback
49
+ ```
50
+
51
+ Add that URL to Supabase Auth allowed redirect URLs.
52
+
53
+ Login options:
54
+
55
+ ```bash
56
+ $CLI auth login --provider google
57
+ $CLI auth login --provider github --port 8787 --timeout 180
58
+ $CLI auth login --no-open
59
+ ```
60
+
61
+ Check and clear auth:
62
+
63
+ ```bash
64
+ $CLI auth status
65
+ $CLI whoami
66
+ $CLI auth logout
67
+ ```
68
+
69
+ ## Core task flows
70
+
71
+ Capture:
72
+
73
+ ```bash
74
+ $CLI task add "Draft release notes" --when inbox
75
+ $CLI task add "Pay invoice" --when today --deadline 2026-03-05
76
+ $CLI task add "Write tests" --project PROJ --team ENG
77
+ ```
78
+
79
+ Review:
80
+
81
+ ```bash
82
+ $CLI task list --state open --limit 50
83
+ $CLI task list --state all --search invoice
84
+ $CLI task show <task-id-or-prefix>
85
+ $CLI task read <id>
86
+ $CLI today
87
+ $CLI search "invoice"
88
+ ```
89
+
90
+ Triage/edit:
91
+
92
+ ```bash
93
+ $CLI task edit <id> --title "Pay vendor invoice"
94
+ $CLI task edit <id> --notes "Waiting for approval" --when upcoming
95
+ $CLI task edit <id> --clear-deadline
96
+ $CLI task append <id> "Added follow-up note"
97
+ $CLI task prepend <id> "Priority note"
98
+ ```
99
+
100
+ Complete and clean up:
101
+
102
+ ```bash
103
+ $CLI task done <id>
104
+ $CLI task reopen <id>
105
+ $CLI task archive <id>
106
+ $CLI task unarchive <id>
107
+ ```
108
+
109
+ Checklists:
110
+
111
+ ```bash
112
+ $CLI task checklist <id>
113
+ $CLI task checklist <id> add "Subtask title"
114
+ $CLI task checklist <id> done <item-id>
115
+ $CLI task checklist <id> remove <item-id>
116
+ ```
117
+
118
+ Projects:
119
+
120
+ ```bash
121
+ $CLI project list
122
+ $CLI project add "Q1 Launch" --key LAUNCH --target-date 2026-06-30
123
+ $CLI project edit LAUNCH --target-date 2026-03-31
124
+ $CLI project done LAUNCH
125
+ $CLI project archive LAUNCH
126
+ ```
127
+
128
+ Workspace:
129
+
130
+ ```bash
131
+ $CLI workspace create "Personal" --slug personal --no-use
132
+ $CLI workspace join <invite-code>
133
+ $CLI workspace members <workspace-id>
134
+ $CLI workspace invitations <workspace-id>
135
+ $CLI workspace invite <workspace-id> --email user@example.com
136
+ $CLI workspace clear
137
+ ```
138
+
139
+ Notes:
140
+
141
+ - `task show|done|reopen|archive|unarchive|edit` accept a full task ID or unique ID prefix (>= 4 chars).
142
+ - `project show|edit|done|archive|unarchive` accept a full ID, project key, or name.
143
+ - Prefix resolution uses your selected workspace, or `--workspace` if provided.
144
+ - `task list` paginates through GraphQL results, so it is not capped at 100 tasks.
145
+ - `donebear auth`, `donebear workspace`, and `donebear task` run sensible defaults (status, list workspaces, list open tasks).
146
+
147
+ ## Command reference
148
+
149
+ Global options:
150
+
151
+ - `--json` machine-readable output
152
+ - `--format <format>` output format: text | json | csv | tsv
153
+ - `--copy` copy output to clipboard
154
+ - `--total` print count only
155
+ - `--token <token>` explicit bearer token
156
+ - `--api-url <url>` manage-api base URL
157
+ - `--debug` include stack traces in failures
158
+ - `--no-color` disable ANSI color
159
+
160
+ Root commands:
161
+
162
+ - `auth` (default: status) + login/status/logout
163
+ - `workspace` (default: list) + list/current/use/clear/create/join/members/invitations/invite
164
+ - `task` (default: list open) + list/show/add/edit/done/reopen/archive/unarchive/read/append/prepend/random/checklist
165
+ - `project` (default: list) + list/show/add/edit/done/archive/unarchive
166
+ - `label` (default: list) + list/show
167
+ - `team` (default: list) + list/show
168
+ - `today` list today's tasks
169
+ - `search <query>` search tasks by title or notes
170
+ - `history` workspace audit log
171
+ - `context` workspace state snapshot (--markdown for system prompts)
172
+ - `spec` progressive CLI spec for agent discovery (no auth required)
173
+ - `api-key` + create/list/revoke
174
+ - `import things` import from Things 3 (--dry-run supported)
175
+ - `whoami` print current authenticated user (`me` alias)
176
+
177
+ Run `donebear <command> --help` for aliases and short flags.
178
+
179
+ ## JSON and automation
180
+
181
+ Example: pick current workspace id:
182
+
183
+ ```bash
184
+ $CLI workspace current --json | jq -r '.workspace.id'
185
+ ```
186
+
187
+ Example: list open task titles:
188
+
189
+ ```bash
190
+ $CLI task list --state open --json | jq -r '.tasks[].title'
191
+ ```
192
+
193
+ Example: export tasks as CSV:
194
+
195
+ ```bash
196
+ $CLI task list --format csv > tasks.csv
197
+ ```
198
+
199
+ Non-interactive auth with API key or token:
200
+
201
+ ```bash
202
+ $CLI api-key create "CI" # creates a long-lived API key
203
+ export DONEBEAR_TOKEN=<key>
204
+ $CLI task list --json
205
+ ```
206
+
207
+ Auth token precedence:
208
+
209
+ 1. `--token <token>`
210
+ 2. `DONEBEAR_TOKEN`
211
+ 3. stored session (`auth login`)
212
+
213
+ ## Environment variables
214
+
215
+ | Variable | Purpose | Default / fallback |
216
+ | ----------------------------------- | ------------------------------------- | ----------------------------------------------------------------------------- |
217
+ | `DONEBEAR_SUPABASE_URL` | Supabase project URL for OAuth | fallback: `NEXT_PUBLIC_SUPABASE_URL`, `SUPABASE_URL` |
218
+ | `DONEBEAR_SUPABASE_PUBLISHABLE_KEY` | Supabase publishable/anon key | fallback: `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY`, `SUPABASE_ANON_KEY` |
219
+ | `DONEBEAR_API_URL` | manage-api base URL | fallback: `NEXT_PUBLIC_RESERVE_MANAGE_API`, default `http://127.0.0.1:3001` |
220
+ | `DONEBEAR_TOKEN` | non-interactive bearer token | none |
221
+ | `DONEBEAR_CONFIG_DIR` | override local config/cache directory | OS config dir + `/donebear` |
222
+ | `DONEBEAR_DEBUG` | enable debug logging (`1`) | disabled |
223
+
224
+ ## Exit codes
225
+
226
+ | Code | Meaning |
227
+ | ---- | ----------------------- |
228
+ | `0` | Success |
229
+ | `1` | General error |
230
+ | `2` | Cancelled or timeout |
231
+ | `4` | Authentication required |
232
+
233
+ ## Troubleshooting
234
+
235
+ | Symptom | Cause | Fix |
236
+ | --------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------- |
237
+ | `Not authenticated. Run donebear auth login.` | Missing or expired token | Run `$CLI auth login`, or pass `--token` |
238
+ | OAuth times out waiting for callback | Callback URL/port mismatch or blocked browser redirect | Verify Supabase redirect URL and retry with `--port` or `--no-open` |
239
+ | `No default workspace selected.` | Multiple workspaces and none selected | Run `$CLI workspace use <id-or-slug>` |
240
+ | `Task prefix "..." is ambiguous` | Prefix matches multiple tasks | Use full task ID from `task list` |
241
+
242
+ ## Development
243
+
244
+ From repo root:
245
+
246
+ ```bash
247
+ npm run lint --workspace=apps/cli
248
+ npm run check-types --workspace=apps/cli
249
+ npm run test --workspace=apps/cli
250
+ npm run build --workspace=apps/cli
251
+ ```
package/dist/cli.d.mts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { };