bluma-cli 0.0.0-stage → 0.2.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.md +60 -2
- package/dist/bluma.js +109 -0
- package/package.json +28 -4
package/README.md
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bluma
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bluma tasks from the terminal. Capture, list and finish to-dos, bring your lists over from Things or Todoist, and connect an agent over MCP. It talks to https://api.bluma.sh unless you point it elsewhere.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
**npm** (Node 20 or newer, no Bun needed)
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx bluma-cli today
|
|
11
|
+
npm install -g bluma-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Homebrew** (macOS and Linux)
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
brew install arnenoori/bluma/bluma
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**curl** (macOS and Linux; installs to `~/.local/bin`, or `$BLUMA_INSTALL_DIR`; never uses sudo)
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
curl -fsSL https://bluma.sh/install.sh | sh
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**From source** (needs [Bun](https://bun.sh))
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
git clone <the repository> && cd bluma
|
|
30
|
+
bun install
|
|
31
|
+
bun run bluma -- today
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Check it worked with `bluma --version`.
|
|
35
|
+
|
|
36
|
+
## First run
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
bluma signup --email you@example.com # new account; asks for a password
|
|
40
|
+
bluma login --email you@example.com # existing account
|
|
41
|
+
bluma add "Buy milk" -w today
|
|
42
|
+
bluma today
|
|
43
|
+
bluma done <id>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For scripts and agents, use an API token instead: `bluma login --token blm_...`, or set `BLUMA_TOKEN`. Make one while signed in with your email: `bluma token add "claude code"`, with `--read-only` for a token that cannot change anything and `--expires 30d` (or `90d`, or any number of days up to 365) for one that stops working by itself. An API token cannot make another token. `BLUMA_URL` points the CLI at your own server. Run `bluma --help` for every command.
|
|
47
|
+
|
|
48
|
+
## Files on to-dos
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
bluma attach <task> screenshot.png build.log # up to 25 MB each, 20 per to-do
|
|
52
|
+
bluma attachments <task> # the files and their ids
|
|
53
|
+
bluma attachment get <id> # saved here under its own name; -o <path>, --force to overwrite
|
|
54
|
+
bluma attachment rm <id>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
An agent connected over MCP reads these with `read_attachment` and can attach its own output with `attach_file`. `attachment get` never writes outside the current folder unless you pass `-o`, and never overwrites a file without `--force`.
|
|
58
|
+
|
|
59
|
+
## Importing from Things
|
|
60
|
+
|
|
61
|
+
`bluma import things` reads a copy of the Things 3 database on your Mac and never changes Things. It works in the standalone binary (Homebrew, curl), under Bun, and under Node 22.13 or newer. On older Node it says so; use the binary instead.
|
package/dist/bluma.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var x=["inbox","today","upcoming","anytime","someday","logbook","trash"];function N(e){let t="";for(let n of e){let r=n.codePointAt(0)??0,a=r<32&&r!==9&&r!==10||r>=127&&r<=159,s=r>=8234&&r<=8238||r>=8294&&r<=8297;if(!a&&!s)t+=n}return t}var fe={fileBytes:26214400,perTask:20,accountBytes:1073741824,name:255},ht=16;function ye(e){let t=N(e).replace(/[\t\n]/g," ").replace(/[/\\]/g,"").trim(),n=[...t],r=t;if(n.length>fe.name){let a=t.lastIndexOf("."),s=a>0?Array.from(t.slice(a)):[],o=s.length<=ht?s:[];r=[...n.slice(0,fe.name-o.length),...o].join("")}return r===""||r==="."||r===".."?"file":r}class w extends Error{status;code;issues;constructor(e,t,n,r){super(n);this.status=e;this.code=t;this.issues=r;this.name="BlumaError"}}class I extends Error{constructor(e){super(e instanceof Error?e.message:String(e),{cause:e});this.name="NetworkError"}}async function D(e,t,n){try{return await e(t,n)}catch(r){throw new I(r)}}async function we(e){try{return await e}catch(t){throw new I(t)}}async function L(e){let t=await we(e.text());try{return t?JSON.parse(t):void 0}catch{return}}async function B(e){let n=(await L(e))?.error;return new w(e.status,n?.code??"http_error",n?.message??`Request failed with HTTP ${e.status}`,n?.issues)}async function A(e,t,n,r={}){let a=await D(e.fetch??fetch,`${e.baseUrl.replace(/\/+$/,"")}${t}`,{method:"POST",headers:{...r,"content-type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw await B(a);return await L(a)}var ft=(e,t,n)=>A(e,t,n),ke=(e,t)=>A(e,"/v1/password/forgot",{email:t}),Te=(e,t)=>A(e,"/v1/password/reset",t);var be=(e,t)=>ft(e,"/v1/signup",t);var ve=(e,t)=>A(e,"/v1/enter",t);var Ce=(e,t,n)=>A(e,"/v1/bootstrap",n,{authorization:`Bearer ${t}`});function yt(e){let t=/filename\*=UTF-8''([^;\s]+)/i.exec(e??"")?.[1];if(!t)return null;try{return decodeURIComponent(t)}catch{return null}}var wt=1e4;async function kt(e){let t=await e(),n={rev:t.rev,full:t.full,tasks:[],projects:[],areas:[],headings:[]},r=t;for(let a=1;;a++){if(n.tasks.push(...r.tasks),n.projects.push(...r.projects),n.areas.push(...r.areas),n.headings.push(...r.headings),r.next===void 0||a>=wt)return n;r=await e(r.next)}}async function Tt(e,t,n){let r=await D(e.fetch,new URL(`${e.base}/v1/tasks/${encodeURIComponent(t)}/attachments`),{method:"POST",headers:{...e.identity,"content-type":n.contentType??"application/octet-stream","content-length":String(n.bytes.byteLength),"x-bluma-filename":encodeURIComponent(n.name)},body:n.bytes});if(!r.ok)throw await B(r);return await L(r)}async function bt(e,t){let n=await D(e.fetch,new URL(`${e.base}/v1/attachments/${encodeURIComponent(t)}`),{headers:e.identity});if(!n.ok)throw await B(n);return{name:yt(n.headers.get("content-disposition"))??t,contentType:n.headers.get("content-type")??"application/octet-stream",bytes:new Uint8Array(await we(n.arrayBuffer()))}}function F(e){let t=e.baseUrl.replace(/\/+$/,""),n=e.fetch??fetch,r={authorization:`Bearer ${e.token}`,...e.client?{"x-bluma-client":e.client}:{}},a={base:t,fetch:n,identity:r};async function s(o,i,c,l){let u=new URL(t+i);for(let[m,h]of Object.entries(l??{}))if(h!==void 0)u.searchParams.set(m,String(h));let p=await D(n,u,{method:o,headers:{...r,...c===void 0?{}:{"content-type":"application/json"}},body:c===void 0?void 0:JSON.stringify(c)});if(!p.ok)throw await B(p);return await L(p)}return{me:()=>s("GET","/v1/me"),updateMe:(o)=>s("PATCH","/v1/me",o),logout:()=>s("POST","/v1/logout"),setPassword:(o)=>s("POST","/v1/me/password",o),resendVerification:()=>s("POST","/v1/me/verify-email"),export:()=>s("GET","/v1/export"),deleteAccount:()=>s("DELETE","/v1/me"),sync:(o)=>s("GET","/v1/sync",void 0,{since:o}),syncPaged:(o,i)=>kt((c)=>s("GET","/v1/sync",void 0,{since:o,limit:i,after:c})),tasks:{list:(o={})=>s("GET","/v1/tasks",void 0,o).then((i)=>i.tasks),get:(o)=>s("GET",`/v1/tasks/${o}`),create:(o)=>s("POST","/v1/tasks",o),createMany:(o)=>s("POST","/v1/tasks/batch",{tasks:o}),update:(o,i)=>s("PATCH",`/v1/tasks/${o}`,i),complete:(o)=>s("PATCH",`/v1/tasks/${o}`,{status:"completed"}),cancel:(o)=>s("PATCH",`/v1/tasks/${o}`,{status:"canceled"}),reopen:(o)=>s("PATCH",`/v1/tasks/${o}`,{status:"open"}),trash:(o)=>s("DELETE",`/v1/tasks/${o}`),restore:(o)=>s("POST",`/v1/tasks/${o}/restore`)},attachments:{list:(o)=>s("GET",`/v1/tasks/${o}/attachments`).then((i)=>i.attachments),upload:(o,i)=>Tt(a,o,i),download:(o)=>bt(a,o),remove:(o)=>s("DELETE",`/v1/attachments/${o}`)},projects:{list:(o={})=>s("GET","/v1/projects",void 0,o).then((i)=>i.projects),get:(o)=>s("GET",`/v1/projects/${o}`),create:(o)=>s("POST","/v1/projects",o),update:(o,i)=>s("PATCH",`/v1/projects/${o}`,i),trash:(o)=>s("DELETE",`/v1/projects/${o}`),restore:(o)=>s("POST",`/v1/projects/${o}/restore`)},areas:{list:()=>s("GET","/v1/areas").then((o)=>o.areas),create:(o)=>s("POST","/v1/areas",o),update:(o,i)=>s("PATCH",`/v1/areas/${o}`,i),trash:(o)=>s("DELETE",`/v1/areas/${o}`),restore:(o)=>s("POST",`/v1/areas/${o}/restore`)},headings:{list:(o)=>s("GET","/v1/headings",void 0,{projectId:o}).then((i)=>i.headings),create:(o)=>s("POST","/v1/headings",o),update:(o,i)=>s("PATCH",`/v1/headings/${o}`,i),trash:(o)=>s("DELETE",`/v1/headings/${o}`),restore:(o)=>s("POST",`/v1/headings/${o}/restore`)},tokens:{list:()=>s("GET","/v1/tokens").then((o)=>o.tokens),create:(o,i={})=>s("POST","/v1/tokens",{name:o,...i}),revoke:(o)=>s("DELETE",`/v1/tokens/${o}`),revokeOthers:()=>s("POST","/v1/tokens/revoke-others")},calendar:{status:()=>s("GET","/v1/calendar"),select:(o)=>s("PUT","/v1/calendar",{calendarIds:o}),start:()=>s("GET","/v1/calendar/google/start"),finish:(o)=>s("POST","/v1/calendar/google/connect",{handoff:o}),disconnect:()=>s("DELETE","/v1/calendar/google"),events:(o,i)=>s("GET","/v1/calendar/events",void 0,{from:o,to:i}).then((c)=>c.events)},push:{config:()=>s("GET","/v1/push/config"),subscribe:(o)=>s("POST","/v1/push/subscriptions",o),unsubscribe:(o)=>s("DELETE",`/v1/push/subscriptions/${o}`)},sendFeedback:(o)=>s("POST","/v1/feedback",o),emptyTrash:()=>s("POST","/v1/trash/empty"),tags:()=>s("GET","/v1/tags").then((o)=>o.tags)}}function ee(e){return`every ${e.every===1?e.unit:`${e.every} ${e.unit}s`}${e.after==="completion"?" after completion":""}`}var te=()=>Intl.DateTimeFormat().resolvedOptions().timeZone;import{parseArgs as Pn}from"node:util";import{chmodSync as Ie,existsSync as Pt,mkdirSync as Ae,readFileSync as xt,writeFileSync as Re}from"node:fs";import{homedir as It}from"node:os";import{dirname as se,join as ne}from"node:path";var Se={name:"@bluma/cli",version:"0.2.0",private:!0,type:"module",bin:{bluma:"./src/main.ts"},scripts:{build:"bun build src/main.ts --compile --outfile dist/bluma",typecheck:"tsc -p tsconfig.json",test:"bun test"},dependencies:{"@bluma/core":"workspace:*"}};var C=(e)=>String(e).padStart(2,"0"),$e=(e)=>`${e.getFullYear()}-${C(e.getMonth()+1)}-${C(e.getDate())}`;function je(e){let t=/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/i.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]??0),a=t[3]?.toLowerCase();if(!a&&t[2]===void 0)return null;if(a&&(n<1||n>12))return null;if(a==="pm"&&n<12)n+=12;if(a==="am"&&n===12)n=0;if(n>23||r>59)return null;return`${C(n)}:${C(r)}`}function Pe(e,t){let n=e.trim().toLowerCase();if(n==="today")return $e(t);if(n==="tomorrow"){let r=new Date(t);return r.setDate(r.getDate()+1),$e(r)}return/^\d{4}-\d{2}-\d{2}$/.test(n)?n:null}var Ct='a time like "2026-12-01 09:00", "tomorrow 9am", "today 18:30" or "9am", or "none" to clear';function xe(e,t=new Date){let n=e.trim();if(n.toLowerCase()==="none")return null;let r=()=>Error(`Could not read the reminder "${e}". Use ${Ct}.`),[a="",...s]=n.split(/[\sT]+/),o=s.join("").replace(/^at/i,""),i=Pe(a,t);if(i){if(o==="")return`${i}T09:00`;let u=je(o);if(!u)throw r();return`${i}T${u}`}let c=je(n.replace(/^at\s+/i,"").replace(/\s+/g,""));if(!c)throw r();let l=`${C(t.getHours())}:${C(t.getMinutes())}`;return`${Pe(c>l?"today":"tomorrow",t)}T${c}`}var St={day:"day",week:"week",month:"month",year:"year"},$t={daily:"day",weekly:"week",monthly:"month",yearly:"year"},jt='"daily", "weekly", "monthly", "yearly", "every 2 weeks" or "every 3 days after completion", or "none" to clear';function _(e){let t=e.trim().toLowerCase().replace(/\s+/g," ");if(t==="none")return null;let n=/\bafter (completion|done|finishing)$/.test(t)?"completion":"schedule";t=t.replace(/ ?\bafter (completion|done|finishing)$/,"");let r=$t[t];if(r)return{every:1,unit:r,after:n};let a=/^every (?:(\d+|other) )?(day|week|month|year)s?$/.exec(t),s=a?.[2]?St[a[2]]:void 0,o=a?.[1]==="other"?2:Number(a?.[1]??1);if(!s||o<1||o>365)throw Error(`Could not read the repeat "${e}". Use ${jt}.`);return{every:o,unit:s,after:n}}var H=Se.version,R="https://api.bluma.sh",Ee={when:{type:"string",short:"w"},deadline:{type:"string",short:"d"},project:{type:"string",short:"p"},area:{type:"string",short:"a"},tag:{type:"string",short:"t",multiple:!0},notes:{type:"string",short:"n"},check:{type:"string",short:"c",multiple:!0},remind:{type:"string",short:"r"},evening:{type:"boolean"},"no-evening":{type:"boolean"},repeat:{type:"string"},"dry-run":{type:"boolean"},output:{type:"string",short:"o"},force:{type:"boolean"},db:{type:"string"},title:{type:"string"},query:{type:"string",short:"q"},kind:{type:"string"},details:{type:"string"},url:{type:"string"},token:{type:"string"},"read-only":{type:"boolean"},expires:{type:"string"},email:{type:"string"},"admin-secret":{type:"string"},timezone:{type:"string"},json:{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}};class d extends Error{}var re=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Oe(e,t,n){if(!Pt(e))return;let r;try{r=JSON.parse(xt(e,"utf8"))}catch{r=void 0}if(!t(r))throw new d(`Could not read ${e}. Fix or delete it, then ${n}.`);return r}var At=(e)=>re(e)&&["url","token"].every((t)=>e[t]===void 0||typeof e[t]==="string");function oe(e){return e.BLUMA_CONFIG??ne(e.XDG_CONFIG_HOME??ne(It(),".config"),"bluma","config.json")}var q=(e)=>Oe(oe(e),At,'run "bluma login" again')??{};function j(e,t){let n=oe(e);return Ae(se(n),{recursive:!0,mode:448}),Re(n,`${JSON.stringify(t,null,2)}
|
|
3
|
+
`,{mode:384}),Ie(n,384),n}function P(e,t){let n=q(e.env),r=t.url??e.env.BLUMA_URL??n.url??R,a=t.token??e.env.BLUMA_TOKEN??n.token;if(!a)throw new d('Not signed in. Run "bluma login --email you@example.com" (or "bluma signup --email you@example.com" for a new account). For a script, set BLUMA_TOKEN or use "bluma login --token <token>".');return{url:r,token:a}}async function T(e,t,n="BLUMA_PASSWORD"){let r=e.env[n]??await e.askSecret?.(t);if(r===void 0)throw new d(`No terminal to ask on. Set ${n} instead.`);return r}var Rt=(e)=>re(e)&&Object.values(e).every((t)=>re(t)&&Object.values(t).every((n)=>typeof n==="string")),z=(e)=>ne(se(oe(e)),"imports.json"),Me=(e)=>Oe(z(e),Rt,"import again")??{};function Ue(e,t){let n=z(e);Ae(se(n),{recursive:!0,mode:448}),Re(n,`${JSON.stringify(t)}
|
|
4
|
+
`,{mode:384}),Ie(n,384)}var K=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function ae(e){return[K(e.areas,"area"),K(e.projects,"project"),K(e.headings,"heading"),K(e.tasks,"to-do")].join(", ")}var ie=(e)=>Object.entries(e.skipped).map(([t,n])=>` left out ${n}: ${t}`);function S(e,t,n){let r=n.toLowerCase(),a=t.filter((c)=>c.id===n||c.title.toLowerCase()===r),s=a.length>0?a:t.filter((c)=>c.id.startsWith(n)),o=s.length>0?s:t.filter((c)=>c.title.toLowerCase().includes(r));if(o.length===1&&o[0])return o[0];if(o.length===0)throw new d(`No ${e} matches "${n}".`);let i=o.map((c)=>` ${g(c.id)} ${c.title}`).join(`
|
|
5
|
+
`);throw new d(`"${n}" matches more than one ${e}:
|
|
6
|
+
${i}`)}async function b(e,t){try{return await e.tasks.get(t)}catch(l){if(!(l instanceof w&&l.status===404))throw l}let n=(l)=>l.filter((u)=>u.id.startsWith(t)),r=(l)=>e.tasks.list({view:l,idPrefix:t,limit:500}).then(n),[a,s,o]=await Promise.all([r(),r("logbook"),r("trash")]),i=a.length>0?a:[...o,...s.filter((l)=>l.deletedAt===null)];if(i.length===1&&i[0])return i[0];if(i.length===0)throw new d(`No task matches "${t}".`);let c=i.map((l)=>` ${g(l.id)} ${l.title}`).join(`
|
|
7
|
+
`);throw new d(`"${t}" matches more than one task:
|
|
8
|
+
${c}`)}async function E(e,t){let n={};if(t.project!==void 0)n.projectId=t.project==="none"?null:S("project",await e.projects.list({status:"all"}),t.project).id;if(t.area!==void 0)n.areaId=t.area==="none"?null:S("area",await e.areas.list(),t.area).id;return n}function ce(e){let t={};if(e.title!==void 0)t.title=e.title;if(e.when!==void 0)t.when=e.when;if(e.deadline!==void 0)t.deadline=e.deadline==="none"?null:e.deadline;if(e.notes!==void 0)t.notes=e.notes;if(e.tag!==void 0)t.tags=e.tag;if(e.check!==void 0)t.checklist=e.check;try{if(e.remind!==void 0)t.remindAt=xe(e.remind);if(e.repeat!==void 0)t.repeat=_(e.repeat)}catch(n){throw new d(n instanceof Error?n.message:String(n))}if(e.evening&&e["no-evening"])throw new d("Pass --evening or --no-evening, not both.");if(e.evening)t.evening=!0;if(e["no-evening"])t.evening=!1;return t}var g=(e)=>e.slice(0,6),Et={open:"[ ]",completed:"[x]",canceled:"[-]"};function Ne(e,t){let n=[Et[e.status],g(e.id),e.title];if(e.scheduledFor)n.push(`@${e.scheduledFor}`);if(e.deadline)n.push(`due ${e.deadline}`);if(e.evening)n.push("evening");if(e.remindAt)n.push(`remind ${e.remindAt.slice(5).replace("T"," ")}`);if(e.repeat)n.push(ee(e.repeat));let r=e.projectId?t.get(e.projectId):void 0;if(r)n.push(`(${r})`);for(let a of e.tags)n.push(`#${a}`);if(e.checklist.length>0)n.push(`${e.checklist.filter((a)=>a.done).length}/${e.checklist.length}`);return n.join(" ")}function De(e,t,n){let r=[["id",e.id],["status",e.status],["when",e.scheduledFor??e.when],["deadline",e.deadline],["evening",e.evening?"yes":null],["reminder",e.remindAt?.replace("T"," ")],["repeats",e.repeat&&ee(e.repeat)],["project",e.projectId&&(t.get(e.projectId)??e.projectId)],["area",e.areaId&&(n.get(e.areaId)??e.areaId)],["tags",e.tags.join(", ")],["completed",e.completedAt],["trashed",e.deletedAt]],a=[e.title,...r.filter(([,s])=>s).map(([s,o])=>` ${s.padEnd(10)}${o}`)];if(e.notes)a.push("",...e.notes.split(`
|
|
9
|
+
`).map((s)=>` ${s}`));if(e.checklist.length>0)a.push("",...e.checklist.map((s)=>` ${s.done?"[x]":"[ ]"} ${s.title}`));return a.join(`
|
|
10
|
+
`)}var O=(e)=>new Map(e.map((t)=>[t.id,t.title]));function Le(e,t,n){return{io:e,flags:t,rest:n,print:(r,a)=>e.out(t.json?JSON.stringify(r,null,2):a()),connect(){let{url:r,token:a}=P(e,t);return F({baseUrl:r,token:a,fetch:e.fetch,client:`cli/${H}`})},need(r){if(n.length===0)throw new d(`Missing ${r}. Run "bluma --help" for usage.`);return n}}}function v(e,t,n){return(r)=>{let a=r.connect(),[s,...o]=r.rest;if(s===void 0)return n(r,a,o);let i=Object.hasOwn(t,s)?t[s]:void 0;if(!i)throw new d(`Unknown ${e} command "${s}". Try: ${Object.keys(t).join(", ")}.`);return i(r,a,o)}}var W=({io:e,flags:t})=>t.url??e.env.BLUMA_URL??q(e.env).url??R;function Ot(e){if(e===void 0||e==="never")return;let t=/^(\d+)d?$/.exec(e.trim()),n=t?Number(t[1]):0;if(n<1||n>365)throw new d("--expires takes a number of days from 1 to 365, such as 30d.");return n}function Be(e){return`${e.scope==="read"?"read only":"can change"}, ${e.expiresAt?`expires ${e.expiresAt.slice(0,10)}`:"no expiry"}`}var Fe=v("token",{async add({print:e,flags:t},n,r){if(r.length===0)throw new d("Missing a name for the token, such as the agent it is for.");let a=Ot(t.expires),s=await n.tokens.create(r.join(" "),{scope:t["read-only"]?"read":"full",...a?{expiresInDays:a}:{}});return e(s,()=>`${s.token}
|
|
11
|
+
${s.name}: ${Be(s)}.
|
|
12
|
+
Save it now; it is not shown again. Revoke with: bluma token rm ${s.id}`),0},async rm({print:e},t,n){let r=await t.tokens.list(),a=S("token",r.map((s)=>({...s,title:s.name})),n.join(" "));return await t.tokens.revoke(a.id),e({revoked:a.id},()=>`Revoked ${a.name}`),0}},async({print:e},t)=>{let n=await t.tokens.list();return e(n,()=>n.map((r)=>[g(r.id),r.kind==="session"?"device":"api ",r.name+(r.current?" (this one)":""),...r.kind==="api"?[Be(r)]:[],`made ${r.createdAt.slice(0,10)}`,r.lastUsedAt?`used ${r.lastUsedAt.slice(0,10)}`:"never used"].join(" ")).join(`
|
|
13
|
+
`)),0}),Mt=async(e)=>{let t=await e.connect().me();return e.print(t,()=>`${t.email??t.id} ${t.timezone} today is ${t.today}`),0};async function Ut({io:e,flags:t,print:n},r){let{token:a}=P(e,t),s=await F({baseUrl:r,token:a,fetch:e.fetch}).me(),o=j(e.env,{url:r,token:a});return n({...s,config:o},()=>`Signed in as ${s.email??s.id}. Saved to ${o}`),0}var _e="bluma cli";function Ke({io:e,print:t},n,r,a){let s=j(e.env,{url:n,token:r.token.token});return t({user:r.user,config:s},()=>`${a} ${r.user.email}. Saved to ${s}`),0}var Nt=async(e)=>{let{io:t,flags:n}=e,r=W(e);if(!n.email)throw new d("signup needs --email.");let a=await T(t,"Password: "),s={email:n.email,password:a,device:_e,timezone:n.timezone??te()};return Ke(e,r,await be({baseUrl:r,fetch:t.fetch},s),"Welcome to Bluma,")},Dt=async(e)=>{let{io:t,flags:n}=e,r=W(e),{email:a}=n;if(n.token||!a)return Ut(e,r);let s=await T(t,"Password: "),o=await ve({baseUrl:r,fetch:t.fetch},{email:a,password:s,device:_e}).catch((i)=>{if(i instanceof w&&i.code==="no_account")throw new d(`No account for ${a} yet. Create one with: bluma signup --email ${a}`);throw i});return Ke(e,r,o,"Signed in as")},Lt=async(e)=>{let{io:t,print:n}=e;await e.connect().logout().catch(()=>{});let r=j(t.env,{url:q(t.env).url??R});return n({config:r},()=>"Signed out."),0};async function Bt(e){let{io:t,flags:n,print:r}=e,a=W(e);if(!n.email)throw new d("password reset needs --email.");let s={baseUrl:a,fetch:t.fetch};if(!t.env.BLUMA_RESET_CODE)await ke(s,n.email),t.err(`If ${n.email} has an account, a reset email is on its way. It works for 30 minutes.`);let o=await T(t,"Code from the email: ","BLUMA_RESET_CODE"),i=await T(t,"New password: ");return await Te(s,{token:o.trim(),password:i}),j(t.env,{url:a}),r({ok:!0},()=>`Password saved. Every device was signed out. Sign in with: bluma login --email ${n.email}`),0}var Ft=async(e)=>{if(e.rest[0]==="reset")return Bt(e);let{io:t,print:n}=e,r=await T(t,"Current password (empty if you never set one): ","BLUMA_CURRENT_PASSWORD"),a=await T(t,"New password: ");return await e.connect().setPassword({current:r||void 0,password:a}),n({ok:!0},()=>"Password saved."),0},_t=async({io:e,flags:t,print:n})=>{let r=t.url??e.env.BLUMA_URL??R,a=t["admin-secret"]??e.env.BLUMA_ADMIN_SECRET;if(!a||!t.email)throw new d("init needs --email and --admin-secret (or BLUMA_ADMIN_SECRET).");let s=await Ce({baseUrl:r,fetch:e.fetch},a,{email:t.email,timezone:t.timezone??te(),tokenName:"cli"}),o=j(e.env,{url:r,token:s.token.token});return n({url:r,config:o},()=>`Account ready for ${t.email}. Token saved to ${o}`),0},Kt=async({io:e,flags:t,print:n})=>{let{url:r,token:a}=P(e,t),s=`${r.replace(/\/+$/,"")}/mcp`,o={mcpServers:{bluma:{type:"http",url:s,headers:{Authorization:`Bearer ${a}`}}}};return n(o,()=>["Claude Code:",` claude mcp add --transport http bluma ${s} --header "Authorization: Bearer ${a}"`,"","Any other MCP client (Streamable HTTP):",JSON.stringify(o,null,2)].join(`
|
|
14
|
+
`)),0},He={tokens:Fe,token:Fe,whoami:Mt,signup:Nt,login:Dt,logout:Lt,password:Ft,init:_t,mcp:Kt};async function le(e,t){let{flags:n,print:r}=e,a=e.connect(),{projectId:s,areaId:o}=await E(a,n),[i,c]=await Promise.all([a.tasks.list({view:t,tag:n.tag?.[0],q:n.query,projectId:s??void 0,areaId:o??void 0}),a.projects.list({status:"all"})]),l=O(c);return r(i,()=>i.length>0?i.map((u)=>Ne(u,l)).join(`
|
|
15
|
+
`):"Nothing here."),0}var qe=(e)=>{let t=e.rest[0];if(t!==void 0&&!x.includes(t))throw new d(`Unknown view "${t}". Choose one of: ${x.join(", ")}.`);return le(e,t)};function M(e,t){return async(n)=>{let r=n.connect(),a=[];for(let s of n.need("a task id"))a.push(await t(r,await b(r,s)));return n.print(a.length===1?a[0]:a,()=>a.map((s)=>`${e} ${g(s.id)} ${s.title}`).join(`
|
|
16
|
+
`)),0}}var Ht=async(e)=>{let{flags:t,print:n}=e,r=e.connect(),a=e.need("a title").join(" "),s=await r.tasks.create({...ce(t),...await E(r,t),title:a});return n(s,()=>`Added ${g(s.id)} ${s.title}`),0},qt=async(e)=>{let t=e.connect(),[n,r,a]=await Promise.all([b(t,e.need("a task id")[0]??""),t.projects.list({status:"all"}),t.areas.list()]);return e.print(n,()=>De(n,O(r),O(a))),0},zt=async(e)=>{let{flags:t,print:n}=e,r=e.connect(),a=await b(r,e.need("a task id")[0]??""),s={...ce(t),...await E(r,t)};if(Object.keys(s).length===0)throw new d("Nothing to change. Pass at least one option.");let o=await r.tasks.update(a.id,s);return n(o,()=>`Updated ${g(o.id)} ${o.title}`),0},Wt=async(e)=>{let t=await e.connect().emptyTrash();return e.print(t,()=>t.tasks+t.projects===0?"The trash is already empty.":`Permanently deleted ${t.tasks} task(s) and ${t.projects} project(s).`),0},ze=v("project",{async add({flags:e,print:t},n,r){if(r.length===0)throw new d("Missing a project title.");let{areaId:a}=await E(n,e),s=await n.projects.create({title:r.join(" "),notes:e.notes,when:e.when,deadline:e.deadline,areaId:a,tags:e.tag});return t(s,()=>`Added project ${g(s.id)} ${s.title}`),0},async done({print:e},t,n){let r=S("project",await t.projects.list(),n.join(" ")),a=await t.projects.update(r.id,{status:"completed"});return e(a,()=>`Completed project ${g(a.id)} ${a.title}`),0}},async({print:e},t)=>{let[n,r,a]=await Promise.all([t.projects.list(),t.areas.list(),t.tasks.list({})]),s=O(r),o=(i)=>{let c=a.filter((p)=>p.projectId===i.id).length,l=i.areaId?` (${s.get(i.areaId)??"?"})`:"",u=i.deadline?` due ${i.deadline}`:"";return`${g(i.id)} ${i.title} ${c} open${u}${l}`};return e(n,()=>n.length===0?"No projects yet.":n.map(o).join(`
|
|
17
|
+
`)),0}),We=v("area",{async add({print:e},t,n){if(n.length===0)throw new d("Missing an area title.");let r=await t.areas.create({title:n.join(" ")});return e(r,()=>`Added area ${g(r.id)} ${r.title}`),0}},async({print:e},t)=>{let n=await t.areas.list();return e(n,()=>n.length===0?"No areas yet.":n.map((r)=>`${g(r.id)} ${r.title}`).join(`
|
|
18
|
+
`)),0}),de={bug:"bug",missing:"missing_capability",confusing:"confusing",idea:"idea"},Gt=async(e)=>{let{flags:t,rest:n,print:r}=e,a=n.join(" ").trim();if(!a)throw new d('Say what it is about: bluma feedback "Upcoming skips repeating to-dos"');let s=t.kind??"idea",o=Object.hasOwn(de,s)?de[s]:null;if(!o)throw new d(`--kind is one of: ${Object.keys(de).join(", ")}`);let i=await e.connect().sendFeedback({kind:o,summary:a,happened:t.details});return r(i,()=>`Sent. Thank you. (report ${i.id.slice(0,6)})`),0},Yt=async(e)=>(e.io.out(JSON.stringify(await e.connect().export(),null,2)),0),Ge={list:qe,ls:qe,add:Ht,show:qt,edit:zt,done:M("Completed",(e,t)=>e.tasks.complete(t.id)),cancel:M("Canceled",(e,t)=>e.tasks.cancel(t.id)),reopen:M("Reopened",(e,t)=>e.tasks.reopen(t.id)),rm:M("Trashed",(e,t)=>e.tasks.trash(t.id)),restore:M("Restored",(e,t)=>e.tasks.restore(t.id)),"empty-trash":Wt,projects:ze,project:ze,areas:We,area:We,export:Yt,feedback:Gt};import{existsSync as ue,readFileSync as Vt,statSync as Ye,writeFileSync as Jt}from"node:fs";import{basename as Qt,dirname as Xt,extname as Zt,resolve as G}from"node:path";var en={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".log":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".html":"text/html",".svg":"image/svg+xml",".zip":"application/zip"};function pe(e){if(e<1024)return`${e} B`;if(e<1048576)return`${Math.round(e/1024)} KB`;return`${(e/1024/1024).toFixed(1)} MB`}var tn=(e)=>`${e.id} ${e.name} ${pe(e.size)} ${e.contentType}`,nn=async(e)=>{let[t,...n]=e.need("a task id and a file");if(!t||n.length===0)throw new d("Missing a file. Usage: bluma attach <task> <file…>");let r=e.connect(),a=await b(r,t),s=[];for(let o of n){if(!ue(o)||!Ye(o).isFile())throw new d(`No file at ${o}.`);let i=new Uint8Array(Vt(o)),c=en[Zt(o).toLowerCase()]??"application/octet-stream";s.push(await r.attachments.upload(a.id,{name:Qt(o),contentType:c,bytes:i}))}return e.print(s.length===1?s[0]:s,()=>s.map((o)=>`Attached ${o.name} (${pe(o.size)}) to ${g(a.id)} ${a.title}`).join(`
|
|
19
|
+
`)),0},rn=async(e)=>{let t=e.connect(),n=await b(t,e.need("a task id")[0]??""),r=await t.attachments.list(n.id);return e.print(r,()=>r.length===0?"No files on this to-do.":r.map(tn).join(`
|
|
20
|
+
`)),0};function sn(e,t){let n=G(e.io.cwd??process.cwd()),r=ye(t),a=e.flags.output;if(a!==void 0&&!(ue(a)&&Ye(a).isDirectory()))return G(n,a);let s=G(n,a??"."),o=G(s,r);if(Xt(o)!==s)throw new d(`Refusing to save "${r}" outside ${s}. Pass -o <path>.`);return o}var on=v("attachment",{async get(e,t,[n]){if(!n)throw new d("Missing an attachment id. Usage: bluma attachment get <id> [-o path]");let r=await t.attachments.download(n),a=sn(e,r.name);if(ue(a)&&!e.flags.force)throw new d(`${a} already exists. Pass --force to overwrite it.`);return Jt(a,r.bytes,{flag:e.flags.force?"w":"wx"}),e.print({path:a,name:r.name,size:r.bytes.byteLength},()=>`Saved ${a} (${pe(r.bytes.byteLength)})`),0},async rm({print:e},t,n){if(n.length===0)throw new d("Missing an attachment id. Usage: bluma attachment rm <id…>");for(let r of n)await t.attachments.remove(r);return e({removed:n},()=>n.map((r)=>`Removed ${r}`).join(`
|
|
21
|
+
`)),0}},()=>{throw new d("Try: bluma attachment get <id> [-o path], or bluma attachment rm <id>.")}),Ve={attach:nn,attachments:rn,attachment:on};import{existsSync as lt,readFileSync as Sn}from"node:fs";import{copyFileSync as Xe,existsSync as me,mkdtempSync as cn,readdirSync as dn,rmSync as ln}from"node:fs";import{homedir as un,tmpdir as pn}from"node:os";import{basename as mn,join as U}from"node:path";class Y extends Error{}var an="Reading the Things database needs the bluma binary, Bun, or Node 22.13 or newer";function Je(e){let t=Reflect.get(process,"getBuiltinModule");if(typeof t!=="function")return;let{emitWarning:n}=process;process.emitWarning=()=>{};try{return t.call(process,e)}catch{return}finally{process.emitWarning=n}}function Qe(e){if(process.versions.bun){let r=Je("bun:sqlite");if(r){let a=new r.Database(e);return{all:(s)=>a.query(s).all(),close:()=>a.close()}}}let t=Je("node:sqlite");if(!t)throw new Y(`${an}. This is Node ${process.versions.node}.`);let n=new t.DatabaseSync(e);return{all:(r)=>n.prepare(r).all(),close:()=>n.close()}}var tt=()=>({areas:[],projects:[],headings:[],tasks:[],skipped:{}}),V=(e,t,n=1)=>{if(n>0)e.skipped[t]=(e.skipped[t]??0)+n},J=(e)=>String(e).padStart(2,"0");function Q(e){if(!e)return null;return`${e>>16&2047}-${J(e>>12&15)}-${J(e>>7&31)}`}function gn(e){if(e===null)return null;return`${J(e>>26&31)}:${J(e>>20&63)}`}function nt(e=un()){let t=U(e,"Library","Group Containers","JLMPQHK86H.com.culturedcode.ThingsMac");if(!me(t))return null;return[...dn(t).filter((r)=>r.startsWith("ThingsData-")).map((r)=>U(t,r,"Things Database.thingsdatabase","main.sqlite")),U(t,"Things Database.thingsdatabase","main.sqlite")].find((r)=>me(r))??null}function rt(e){let t=cn(U(pn(),"bluma-things-"));try{let n=U(t,"main.sqlite");Xe(e,n);for(let a of["-wal","-shm"])if(me(e+a))Xe(e+a,n+a);let r=Qe(n);try{let a=new Set(r.all("SELECT name FROM pragma_table_info('TMTask')").map((i)=>i.name)),s=a.has("heading")?"heading":"actionGroup",o=a.has("reminderTime")?"reminderTime":"NULL";return{areas:r.all('SELECT uuid, title FROM TMArea ORDER BY "index"'),tasks:r.all(`SELECT uuid, type, status, trashed, title, notes, start, startDate, startBucket, deadline,
|
|
22
|
+
${o} AS reminderTime, area, project, ${s} AS heading,
|
|
23
|
+
rt1_recurrenceRule IS NOT NULL AS repeats
|
|
24
|
+
FROM TMTask ORDER BY "index"`),tags:r.all("SELECT TMTaskTag.tasks AS task, TMTag.title AS title FROM TMTaskTag JOIN TMTag ON TMTag.uuid = TMTaskTag.tags"),checklist:r.all('SELECT task, title, status FROM TMChecklistItem ORDER BY "index"')}}finally{r.close()}}finally{ln(t,{recursive:!0,force:!0})}}var Ze=(e)=>e.status===0&&e.trashed===0;function st(e,t){if(e.start===0)return"inbox";if(e.start===2)return"someday";let n=Q(e.startDate);if(!n)return"anytime";return n<=t?"today":n}function et(e){let t=new Map;for(let{task:n,title:r}of e)t.set(n,[...t.get(n)??[],r]);return t}function hn(e,t){let n=e.heading&&t.everyHeading.has(e.heading)&&!t.headings.has(e.heading),r=e.project&&t.everyProject.has(e.project)&&!t.projects.has(e.project);return Boolean(n||r)}function fn(e,t){if(e.trashed!==0)return"in the trash";if(e.status!==0)return"completed or canceled";if(e.repeats)return"repeating templates (set the repeat again in Bluma)";if(!e.title?.trim())return"without a title";return hn(e,t)?"inside a finished or trashed project":null}function yn(e,t){let n=st(e,t.today);return{key:e.uuid,title:e.title?.trim()||"Untitled project",notes:e.notes??"",areaKey:e.area&&t.areas.has(e.area)?e.area:null,when:n==="inbox"?null:n,deadline:Q(e.deadline),tags:t.tags.get(e.uuid)??[]}}function wn(e,t){let n=e.heading&&t.headings.has(e.heading)?e.heading:null,r=n?t.headings.get(n)??null:e.project,a=Q(e.startDate),s=gn(e.reminderTime);return{key:e.uuid,title:(e.title??"").trim(),notes:e.notes??"",when:st(e,t.today),evening:e.startBucket===1,deadline:Q(e.deadline),remindAt:a&&s?`${a}T${s}`:null,repeat:null,projectKey:r&&t.projects.has(r)?r:null,areaKey:!r&&e.area&&t.areas.has(e.area)?e.area:null,headingKey:n,tags:t.tags.get(e.uuid)??[],checklist:t.steps.get(e.uuid)??[]}}function ot(e,t){let n=tt(),r=(i)=>e.tasks.filter((c)=>c.type===i),a=e.checklist.flatMap((i)=>i.status===0&&i.title?[{task:i.task,title:i.title}]:[]),s={today:t,areas:new Set(e.areas.map((i)=>i.uuid)),projects:new Set,headings:new Map,everyProject:new Set(r(1).map((i)=>i.uuid)),everyHeading:new Set(r(2).map((i)=>i.uuid)),tags:et(e.tags),steps:et(a)};n.areas=e.areas.map((i)=>({key:i.uuid,title:i.title?.trim()||"Untitled area"}));for(let i of r(1).filter(Ze))s.projects.add(i.uuid),n.projects.push(yn(i,s));for(let i of r(2).filter(Ze)){if(!i.project||!s.projects.has(i.project))continue;s.headings.set(i.uuid,i.project),n.headings.push({key:i.uuid,projectKey:i.project,title:i.title?.trim()||"Untitled heading"})}for(let i of r(0)){let c=fn(i,s);if(c)V(n,c);else n.tasks.push(wn(i,s))}let o=new Set([...n.projects.map((i)=>i.areaKey),...n.tasks.map((i)=>i.areaKey)]);return V(n,"empty areas",n.areas.filter((i)=>!o.has(i.key)).length),n.areas=n.areas.filter((i)=>o.has(i.key)),n}function kn(e){let t=[],n=[],r="",a=!1,s=e.replace(/^/,"");for(let o=0;o<s.length;o++){let i=s[o];if(a)if(i==='"'&&s[o+1]==='"')r+='"',o++;else if(i==='"')a=!1;else r+=i;else if(i==='"')a=!0;else if(i===",")n.push(r),r="";else if(i===`
|
|
25
|
+
`||i==="\r"){if(i==="\r"&&s[o+1]===`
|
|
26
|
+
`)o++;n.push(r),t.push(n),n=[],r=""}else r+=i}if(r!==""||n.length>0)t.push([...n,r]);return t}function Tn(e){let t=5381;for(let n of e.join("\x00"))t=(t<<5)+t+n.charCodeAt(0)>>>0;return t.toString(36)}function at(e,t,n){let r=tt(),[a=[],...s]=kn(e),o=(h)=>a.findIndex((f)=>f.trim().toUpperCase()===h),i={type:o("TYPE"),content:o("CONTENT"),notes:o("DESCRIPTION")},c={priority:o("PRIORITY"),date:o("DATE")};if(i.type<0||i.content<0)throw Error("That does not look like a Todoist CSV export: it has no TYPE and CONTENT columns.");let l=(h,f)=>f<0?"":(h[f]??"").trim(),u=`todoist:${t}`;r.projects.push({key:u,title:t,notes:"",areaKey:null,when:null,deadline:null,tags:[]});let p=null,m;for(let h of s){let f=l(h,i.type).toLowerCase(),k=l(h,i.content);if(f==="section"&&k)p=`${u}:section:${k}`,r.headings.push({key:p,projectKey:u,title:k}),m=void 0;else if(f==="note"&&k&&m)m.notes=[m.notes,k].filter(Boolean).join(`
|
|
27
|
+
|
|
28
|
+
`);else if(f==="task"&&k){let y=l(h,c.date),ge=[l(h,i.notes)],Z="anytime",he=null;if(/^\d{4}-\d{2}-\d{2}$/.test(y))Z=y<=n?"today":y;else if(y.toLowerCase()==="today"||y.toLowerCase()==="tomorrow")Z=y.toLowerCase();else if(y)try{he=_(y.replace(/^every day$/i,"daily"))}catch{ge.push(`Date in Todoist: ${y}`),V(r,"dates kept as a note")}let gt=l(h,c.priority);m={key:`${u}:${Tn([p??"",k,y])}`,title:k,notes:ge.filter(Boolean).join(`
|
|
29
|
+
|
|
30
|
+
`),when:Z,evening:!1,deadline:null,remindAt:null,repeat:he,projectKey:u,areaKey:null,headingKey:p,tags:gt==="1"?["p1"]:[],checklist:[]},r.tasks.push(m)}}return r}var it=(e)=>mn(e).replace(/\.csv$/i,""),X=(e)=>({areas:e.areas.length,projects:e.projects.length,headings:e.headings.length,tasks:e.tasks.length});function ct(e,t){let n=(i)=>i.filter((c)=>!(c.key in t)),r=X(e),a={...e,areas:n(e.areas),projects:n(e.projects),headings:n(e.headings),tasks:n(e.tasks),skipped:{...e.skipped}},s=X(a),o=Object.values(r).reduce((i,c)=>i+c,0);return V(a,"already imported",o-Object.values(s).reduce((i,c)=>i+c,0)),a}var bn=100,vn=393216;function Cn(e,t){let n=[],r=[],a=0;for(let s of e){let o=JSON.stringify(t(s)).length;if(r.length>0&&(r.length>=bn||a+o>vn))n.push(r),r=[],a=0;r.push(s),a+=o}if(r.length>0)n.push(r);return n}async function dt(e,t,n,r){let a=(o)=>o?n[o]??null:null,s={areas:0,projects:0,headings:0,tasks:0};try{for(let i of t.areas)n[i.key]=(await e.areas.create({title:i.title})).id,s.areas++;for(let i of t.projects){let c=await e.projects.create({title:i.title,notes:i.notes,areaId:a(i.areaKey),when:i.when??void 0,deadline:i.deadline,tags:i.tags});n[i.key]=c.id,s.projects++}for(let i of t.headings){let c=a(i.projectKey);if(!c)continue;n[i.key]=(await e.headings.create({projectId:c,title:i.title})).id,s.headings++}let o=t.tasks.map((i)=>({key:i.key,input:{title:i.title,notes:i.notes,when:i.when,evening:i.evening,deadline:i.deadline,remindAt:i.remindAt,repeat:i.repeat,headingId:a(i.headingKey),projectId:i.headingKey?void 0:a(i.projectKey),areaId:i.projectKey?void 0:a(i.areaKey),tags:i.tags,checklist:i.checklist}}));for(let i of Cn(o,(c)=>c.input)){let{results:c}=await e.tasks.createMany(i.map((u)=>u.input)),l;for(let[u,p]of c.entries()){let m=i[u]?.key;if(!("task"in p))l??=new w(p.status,p.error.code,p.error.message);else if(m)n[m]=p.task.id,s.tasks++}if(r(),l)throw l}}finally{r()}return s}function $n(e,t){let n=e??nt();if(!n||!lt(n))throw new d("Could not find the Things database on this Mac. Pass its path with --db.");try{return ot(rt(n),t)}catch(r){if(r instanceof Y)throw new d(r.message);throw r}}function jn(e,t){if(e.length===0)throw new d("Which file? Pass one or more Todoist CSV exports.");let n={areas:[],projects:[],headings:[],tasks:[],skipped:{}};for(let r of e){if(!lt(r))throw new d(`No file at ${r}.`);let a;try{a=at(Sn(r,"utf8"),it(r),t)}catch(s){throw new d(`${r}: ${s instanceof Error?s.message:String(s)}`)}n.projects.push(...a.projects),n.headings.push(...a.headings),n.tasks.push(...a.tasks);for(let[s,o]of Object.entries(a.skipped))n.skipped[s]=(n.skipped[s]??0)+o}return n}var ut=async(e)=>{let{io:t,flags:n,print:r}=e,[a,...s]=e.rest;if(a!=="things"&&a!=="todoist")throw new d('Import from where? Use "bluma import things" or "bluma import todoist <file.csv>".');let o=e.connect(),i=await o.me(),c=a==="things"?$n(n.db,i.today):jn(s,i.today),l=Me(t.env),u=`${P(t,n).url}#${i.id}#${a}`,p=n.force?{}:l[u]??{},m=ct(c,p),h=X(m);if(n["dry-run"])return r({dryRun:!0,wouldCreate:h,skipped:m.skipped},()=>[`Would create ${ae(h)}.`,...ie(m),"Nothing was changed."].join(`
|
|
31
|
+
`)),0;l[u]=p;let f=await dt(o,m,p,()=>Ue(t.env,l));return r({created:f,skipped:m.skipped},()=>[`Imported ${ae(f)}.`,...ie(m),`What was imported is noted in ${z(t.env)}, so running this again adds only what is new.`].join(`
|
|
32
|
+
`)),0};var xn=`bluma ${H} — tasks from the terminal
|
|
33
|
+
|
|
34
|
+
Usage: bluma <command> [options]
|
|
35
|
+
|
|
36
|
+
New here? Run "bluma signup --email you@example.com", or "bluma login --email you@example.com" if you
|
|
37
|
+
have an account (it talks to https://api.bluma.sh). Then: bluma add "Buy milk" -w today
|
|
38
|
+
|
|
39
|
+
Capture and review
|
|
40
|
+
add <title…> Add a task (inbox unless --when, --project or --area is given)
|
|
41
|
+
today | inbox | upcoming | anytime | someday | logbook | trash
|
|
42
|
+
list [view] List a view, or all open tasks; filter with -p, -a, -t, -q
|
|
43
|
+
show <task> Show one task with notes and checklist
|
|
44
|
+
|
|
45
|
+
Change
|
|
46
|
+
done <task…> Complete tasks cancel <task…> reopen <task…>
|
|
47
|
+
edit <task> Change fields with the options below
|
|
48
|
+
rm <task…> Move to the trash restore <task…>
|
|
49
|
+
empty-trash Permanently delete everything in the trash
|
|
50
|
+
|
|
51
|
+
Files on to-dos (up to 25 MB each, 20 per to-do; an agent reads them over MCP)
|
|
52
|
+
attach <task> <file…> Attach files to a to-do
|
|
53
|
+
attachments <task> List a to-do's files, with their ids
|
|
54
|
+
attachment get <id> Download a file into this folder under its own name: -o <path or folder>, --force
|
|
55
|
+
to overwrite. A name is never allowed to point outside the folder
|
|
56
|
+
attachment rm <id…> Delete files for good
|
|
57
|
+
|
|
58
|
+
Organise
|
|
59
|
+
projects List projects project add <title…> [-a area] [-w when] [-d date]
|
|
60
|
+
areas List areas area add <title…>
|
|
61
|
+
project done <project> Complete a project and everything open in it
|
|
62
|
+
|
|
63
|
+
Bring your lists over
|
|
64
|
+
import things From Things 3 on this Mac (reads a copy; Things is never changed)
|
|
65
|
+
import todoist <csv…> From Todoist CSV exports, one project per file
|
|
66
|
+
Both take --dry-run to see what would be made, and skip what was imported before
|
|
67
|
+
|
|
68
|
+
Setup
|
|
69
|
+
signup Create an account: --email (asks for a password, or reads BLUMA_PASSWORD)
|
|
70
|
+
login Sign in: --email, or --token for an API token (also BLUMA_URL / BLUMA_TOKEN)
|
|
71
|
+
logout Sign out and forget the saved token
|
|
72
|
+
password Set or change your password (other devices are signed out)
|
|
73
|
+
password reset Forgot it: --email, then paste the code from the email
|
|
74
|
+
export Print everything in your account as JSON
|
|
75
|
+
init Create an account on your own server: --url, --admin-secret, --email
|
|
76
|
+
feedback <summary…> Tell us about a bug, a gap or an idea: --kind bug|missing|confusing|idea, --details "…"
|
|
77
|
+
whoami Show the signed-in account
|
|
78
|
+
mcp Print the config for connecting an agent over MCP
|
|
79
|
+
tokens List devices and API tokens, with what each can do and when it expires
|
|
80
|
+
token add <name…> Make an API token for an agent or script (needs an email sign-in, not a token):
|
|
81
|
+
--read-only so it cannot change anything, --expires 30d|90d|<n>d (default: never)
|
|
82
|
+
token rm <token> Revoke a token
|
|
83
|
+
|
|
84
|
+
Options
|
|
85
|
+
-w, --when <when> today, tomorrow, anytime, someday, inbox, or YYYY-MM-DD
|
|
86
|
+
-d, --deadline <date> YYYY-MM-DD, or "none" to clear
|
|
87
|
+
-p, --project <ref> Project id, id prefix or title ("none" to clear)
|
|
88
|
+
-a, --area <ref> Area id, id prefix or title ("none" to clear)
|
|
89
|
+
-t, --tag <tag> Repeatable. On edit, replaces the task's tags
|
|
90
|
+
-n, --notes <text> Notes
|
|
91
|
+
-c, --check <item> Checklist item, repeatable
|
|
92
|
+
-r, --remind <time> Reminder: "2026-12-01 09:00", "tomorrow 9am", "today 18:30", "9am" ("none" to clear)
|
|
93
|
+
--evening Put it under This Evening in Today (--no-evening to undo)
|
|
94
|
+
--repeat <rule> daily, weekly, monthly, yearly, "every 2 weeks",
|
|
95
|
+
"every 3 days after completion" ("none" to clear)
|
|
96
|
+
--title <text> New title (edit)
|
|
97
|
+
-q, --query <text> Search title and notes (list)
|
|
98
|
+
--dry-run Import: show what would be created and create nothing
|
|
99
|
+
--force Import: bring over again what an earlier import already made. attachment get:
|
|
100
|
+
overwrite an existing file
|
|
101
|
+
-o, --output <path> attachment get: where to save the file
|
|
102
|
+
--db <path> Import things: the Things database, if it is not in the usual place
|
|
103
|
+
--json Print JSON instead of text
|
|
104
|
+
-h, --help -v, --version
|
|
105
|
+
|
|
106
|
+
Tasks, projects and areas can be named by id or any unique id prefix.`,pt={...Object.fromEntries(x.map((e)=>[e,(t)=>le(t,e)])),...Ge,...Ve,...He,import:ut};function In(e){switch(e.code){case"session_required":return"An API token cannot do this. Sign in with `bluma login --email you@example.com`, then run this again.";case"read_only_token":return"This token is read only, so it cannot change anything. Use a token that can change, or sign in with `bluma login --email you@example.com`.";default:return`${e.message} (${e.code})`}}async function mt(e,t){try{return await An(e,t)}catch(n){if(n instanceof d)return t.err(n.message),2;if(n instanceof w)return t.err(In(n)),1;if(n instanceof I)return t.err(`Could not reach the server: ${n.message}`),1;if(n instanceof TypeError&&/option|argument/i.test(n.message))return t.err(`${n.message}
|
|
107
|
+
Run "bluma --help" for usage.`),2;return t.err(n instanceof Error?n.message:String(n)),1}}async function An(e,t){let{values:n,positionals:r}=Pn({args:e,options:Ee,allowPositionals:!0}),[a,...s]=r;if(n.version)return t.out(H),0;if(n.help||!a||a==="help")return t.out(xn),0;let o=Object.hasOwn(pt,a)?pt[a]:void 0;if(!o)throw new d(`Unknown command "${a}". Run "bluma --help" for usage.`);return o(Le(t,n,s))}function Rn(e){let{stdin:t,stderr:n}=process;if(!t.isTTY)return Promise.reject(Error("Not a terminal. Set BLUMA_PASSWORD instead."));return n.write(e),t.setRawMode(!0),t.resume(),new Promise((r,a)=>{let s="",o=(c)=>{t.setRawMode(!1),t.pause(),t.off("data",i),n.write(`
|
|
108
|
+
`),c()},i=(c)=>{for(let l of c.toString("utf8")){if(l==="\r"||l===`
|
|
109
|
+
`)return o(()=>r(s));if(l==="\x03")return o(()=>a(Error("Cancelled.")));if(l==="\x7F"||l==="\b")s=s.slice(0,-1);else s+=l}};t.on("data",i)})}process.exitCode=await mt(process.argv.slice(2),{out:(e)=>console.log(N(e)),err:(e)=>console.error(N(e)),env:process.env,askSecret:process.stdin.isTTY?Rn:void 0});
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bluma-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Bluma from the terminal: capture, list and finish tasks, import from Things or Todoist, connect an agent over MCP.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tasks",
|
|
7
|
+
"todo",
|
|
8
|
+
"cli",
|
|
9
|
+
"gtd",
|
|
10
|
+
"things",
|
|
11
|
+
"mcp",
|
|
12
|
+
"bluma"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://bluma.sh/cli/",
|
|
15
|
+
"license": "UNLICENSED",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"bin": {
|
|
18
|
+
"bluma": "dist/bluma.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/bluma.js",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
30
|
+
}
|