@dinoxx/dinox-cli 2.20.1 → 3.0.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 +17 -16
- package/dist/chunks/{applePodcast-V4FSJOC5.js → applePodcast-YDYM4JYQ.js} +3 -3
- package/dist/chunks/{bbc-NTMRPYRF.js → bbc-N3BM2EGG.js} +3 -3
- package/dist/chunks/{bilibili-UA3MBSPH.js → bilibili-V4XVW33T.js} +63 -9
- package/dist/chunks/{bohaishibei-B7UVXH4Y.js → bohaishibei-IQO5CZTN.js} +3 -3
- package/dist/chunks/{chunk-BKCNERPB.js → chunk-2DREJFKB.js} +98 -17
- package/dist/chunks/{chunk-X7JXCHLI.js → chunk-ARBWJ3ZA.js} +4176 -2821
- package/dist/chunks/{chunk-XMMTGPZ6.js → chunk-AZ43P73A.js} +56 -2
- package/dist/chunks/{chunk-PGR7R2HI.js → chunk-HG3RZFDX.js} +3 -3
- package/dist/chunks/{chunk-VI7C4BBS.js → chunk-KJBN7TD7.js} +3 -3
- package/dist/chunks/{chunk-FIQYJ6KZ.js → chunk-LLAXR5EG.js} +1 -1
- package/dist/chunks/{chunk-TILRKKRN.js → chunk-MKEL2KNU.js} +893 -468
- package/dist/chunks/{chunk-FGQRYB7F.js → chunk-MZMOE3RX.js} +13 -1
- package/dist/chunks/{chunk-53CT7DJ3.js → chunk-N2VYTZWU.js} +2 -2
- package/dist/chunks/{chunk-XEPDFQYD.js → chunk-N5YDNM3P.js} +26 -26
- package/dist/chunks/{chunk-YDIE7QBM.js → chunk-NVKSI4BD.js} +671 -159
- package/dist/chunks/{chunk-QFUD3I7W.js → chunk-QPVGA46P.js} +0 -1
- package/dist/chunks/{chunk-6AZT4ARG.js → chunk-R2CGNGOT.js} +3 -3
- package/dist/chunks/{chunk-GTDX2LIJ.js → chunk-RSSEVU2F.js} +58 -10
- package/dist/chunks/{chunk-G6JSWE66.js → chunk-WABL3OUP.js} +2 -2
- package/dist/chunks/{cookies-6QQHSM26.js → cookies-ORQ3RLAH.js} +1 -3
- package/dist/chunks/{doubanGroup-HR4K2KMY.js → doubanGroup-MADXDGDI.js} +4 -4
- package/dist/chunks/{doubao-MXUHPLUB.js → doubao-DKZERP6Y.js} +2 -2
- package/dist/chunks/{douyin-UU2FSQPS.js → douyin-PIWFZHK7.js} +91 -5
- package/dist/chunks/{ensure-CHJ5YTBX.js → ensure-MPOQ244L.js} +5 -5
- package/dist/chunks/{execute-RXJ4AO2Z.js → execute-KMNZ5EFR.js} +3 -3
- package/dist/chunks/{facebook-SZFOVE7R.js → facebook-TI2CF5UY.js} +2 -2
- package/dist/chunks/{feishu-ISWRJ7HI.js → feishu-XSSEBWQD.js} +2 -2
- package/dist/chunks/{ima-D7CX5WR4.js → ima-SKE2C64C.js} +2 -2
- package/dist/chunks/{instagram-HNDPO37H.js → instagram-4W4HCWJN.js} +2 -2
- package/dist/chunks/{install-IIMVFNAT.js → install-35YBLHXE.js} +0 -2
- package/dist/chunks/{jike-H7L4LJTN.js → jike-GS64MEEO.js} +4 -4
- package/dist/chunks/{mcp-NMKVOSVN.js → mcp-H667ML2O.js} +9 -9
- package/dist/chunks/{mcpServer-NYJAKMVH.js → mcpServer-G2WEAD2O.js} +13 -11
- package/dist/chunks/{metaso-ZVZW5UBB.js → metaso-RRYEUXIL.js} +2 -2
- package/dist/chunks/{run-ETPFUFB6.js → run-7D6ATULD.js} +7 -7
- package/dist/chunks/{runCli-GJRY73UA.js → runCli-QEWWUIZN.js} +8 -8
- package/dist/chunks/{setup-EEU6GSWX.js → setup-DSTOF3BZ.js} +2 -2
- package/dist/chunks/{threads-ADW6IANQ.js → threads-JKMT3E73.js} +3 -3
- package/dist/chunks/{twitter-NAGCB3NI.js → twitter-WNBOJELM.js} +2 -2
- package/dist/chunks/{web-QFKZCM4F.js → web-LJESVHHV.js} +4 -4
- package/dist/chunks/{wechat-OXNNLT4J.js → wechat-N7O77CB4.js} +40 -1
- package/dist/chunks/{weibo-PMVGDNQU.js → weibo-XPEV5CLQ.js} +4 -4
- package/dist/chunks/{workbuddy-NNAXIIIZ.js → workbuddy-ZXNDX7O7.js} +5 -5
- package/dist/chunks/{xiaoheihe-WFQJRBAD.js → xiaoheihe-WXFAORLQ.js} +3 -3
- package/dist/chunks/{xiaohongshu-5CXBELGW.js → xiaohongshu-3N3ZVSXJ.js} +2 -2
- package/dist/chunks/{xiaoyuzhou-6L6IB46Y.js → xiaoyuzhou-OGIWFABL.js} +3 -3
- package/dist/chunks/{youtube-52NGBTQC.js → youtube-YRSK7CWC.js} +3 -3
- package/dist/chunks/{zcool-HDSWK4KD.js → zcool-K5KJ2KDG.js} +2 -2
- package/dist/chunks/{zhihu-EX2VRJYY.js → zhihu-X6XSPD6B.js} +2 -2
- package/dist/dinox.js +5 -5
- package/dist/dsh-plugin/lib/client.js +309 -567
- package/dist/dsh-plugin/lib/index.js +1 -1
- package/dist/dsh-plugin/package.json +1 -1
- package/dist/dsh-plugin/runtime.json +2 -2
- package/dist/editor-ui/mcp-app.html +356 -592
- package/package.json +22 -12
- /package/dist/chunks/{chunk-QFSMFANX.js → chunk-SM2QOO45.js} +0 -0
package/README.md
CHANGED
|
@@ -500,7 +500,7 @@ Dinox 的待办来自笔记内容中的任务列表。CLI 提供了 4 个最常
|
|
|
500
500
|
```bash
|
|
501
501
|
dino todo search
|
|
502
502
|
dino todo search "付款"
|
|
503
|
-
dino todo search "付款" --status
|
|
503
|
+
dino todo search "付款" --status backlog,todo,in_progress
|
|
504
504
|
dino todo search --from 2026-03-01 --to 2026-03-07 --limit 100
|
|
505
505
|
```
|
|
506
506
|
|
|
@@ -540,22 +540,23 @@ dino todo append --note-id <note-id> --tasks @./todo.txt
|
|
|
540
540
|
#### 更新待办状态
|
|
541
541
|
|
|
542
542
|
```bash
|
|
543
|
-
dino todo update <task-id> --status
|
|
544
|
-
dino todo update <task-id> --note-id <note-id> --status
|
|
545
|
-
dino todo update <task-id> --status
|
|
543
|
+
dino todo update <task-id> --status done
|
|
544
|
+
dino todo update <task-id> --note-id <note-id> --status done
|
|
545
|
+
dino todo update <task-id> --status todo
|
|
546
|
+
dino todo update <task-id> --status cancelled
|
|
546
547
|
```
|
|
547
548
|
|
|
548
|
-
|
|
549
|
+
任务状态只有 5 个值:
|
|
549
550
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
551
|
+
- `backlog`:以后再说(Markdown `[>]`)
|
|
552
|
+
- `todo`:待办(`[ ]`)
|
|
553
|
+
- `in_progress`:进行中(`[/]`)
|
|
554
|
+
- `done`:完成(`[x]`)
|
|
555
|
+
- `cancelled`:取消(`[-]`)
|
|
554
556
|
|
|
555
|
-
|
|
557
|
+
`done`/`cancelled` 是已关闭,其余是未关闭。设为 `done` 或 `cancelled` 时,未关闭的子任务会一并设为同一状态(已关闭的子任务保持原状);设为未关闭状态时,已关闭的父任务会重新打开为 `todo`;`backlog`/`in_progress` 不向下传递。父任务不会自动完成。
|
|
556
558
|
|
|
557
|
-
|
|
558
|
-
- `uncompleted`
|
|
559
|
+
3.0 起旧写法(`completed`/`uncompleted`/`all`、`undone`/`true`/`false`/`1`/`0`、JSON 里的 `checked`)全部移除,不再兼容。
|
|
559
560
|
|
|
560
561
|
对没有持久 task id 的旧笔记,`todo search` 会返回 `legacy-task-*` 合成 id。该 id 绑定搜索时的任务位置和内容;如果笔记结构随后变化,更新会安全失败,必须重新搜索,避免把状态写到另一条任务。建议始终把搜索结果中的 `note_id` 一并传给 `--note-id`。
|
|
561
562
|
|
|
@@ -786,13 +787,13 @@ dino note delete <id>
|
|
|
786
787
|
dino todo search [query]
|
|
787
788
|
dino todo append [task]
|
|
788
789
|
dino todo create [task]
|
|
789
|
-
dino todo update <task-id> --status
|
|
790
|
+
dino todo update <task-id> --status done
|
|
790
791
|
```
|
|
791
792
|
|
|
792
793
|
重点参数:
|
|
793
794
|
|
|
794
795
|
- `todo search`
|
|
795
|
-
- `--status <
|
|
796
|
+
- `--status <list>`:逗号分隔的状态(`backlog,todo,in_progress,done,cancelled`),不传即全部
|
|
796
797
|
- `--tags <list>`
|
|
797
798
|
- `--from <date>` / `--to <date>` / `--days <n>`
|
|
798
799
|
- `--limit <n>`
|
|
@@ -807,7 +808,7 @@ dino todo update <task-id> --status completed
|
|
|
807
808
|
- `--title <string>`
|
|
808
809
|
- `--dry-run`
|
|
809
810
|
- `todo update`
|
|
810
|
-
- `--status <
|
|
811
|
+
- `--status <backlog|todo|in_progress|done|cancelled>`
|
|
811
812
|
- `--note-id <id>`:用搜索结果中的笔记 id 精确限定目标
|
|
812
813
|
- `--dry-run`
|
|
813
814
|
|
|
@@ -987,7 +988,7 @@ dino update
|
|
|
987
988
|
```bash
|
|
988
989
|
dino note search "dinox" --limit 5 --format json
|
|
989
990
|
dino note detail <id> --format json
|
|
990
|
-
dino todo search --status
|
|
991
|
+
dino todo search --status backlog,todo,in_progress --format json
|
|
991
992
|
```
|
|
992
993
|
|
|
993
994
|
`--format json` 会返回稳定的结构化 envelope,适合被脚本、自动化任务和 AI Agent 解析。
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
downloadAudio,
|
|
10
10
|
formatDuration
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RSSEVU2F.js";
|
|
12
12
|
import {
|
|
13
13
|
composeClipMarkdown
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-LLAXR5EG.js";
|
|
15
|
+
import "./chunk-AZ43P73A.js";
|
|
16
16
|
import "./chunk-URYABAYN.js";
|
|
17
17
|
import {
|
|
18
18
|
ytdlpOptionsFor
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-X36EIV25.js";
|
|
7
7
|
import {
|
|
8
8
|
downloadWebImages
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MKEL2KNU.js";
|
|
10
10
|
import "./chunk-2LW76QIL.js";
|
|
11
11
|
import "./chunk-PTFGE4KS.js";
|
|
12
12
|
import {
|
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
import "./chunk-QZQRG3JY.js";
|
|
28
28
|
import {
|
|
29
29
|
composeClipMarkdown
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import "./chunk-
|
|
30
|
+
} from "./chunk-LLAXR5EG.js";
|
|
31
|
+
import "./chunk-AZ43P73A.js";
|
|
32
32
|
import "./chunk-URYABAYN.js";
|
|
33
33
|
import {
|
|
34
34
|
clipEngineConfig
|
|
@@ -13,13 +13,16 @@ import {
|
|
|
13
13
|
createRequestSpacer
|
|
14
14
|
} from "./chunk-FZGEWY5L.js";
|
|
15
15
|
import {
|
|
16
|
+
currentVideoByteBudget,
|
|
16
17
|
loadCookieHeader
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MZMOE3RX.js";
|
|
18
19
|
import {
|
|
20
|
+
VideoExtractError,
|
|
19
21
|
buildVideoMarkdown,
|
|
20
22
|
downloadVideo,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
pickBudgetedFormat,
|
|
24
|
+
resolveVideoInfo
|
|
25
|
+
} from "./chunk-RSSEVU2F.js";
|
|
23
26
|
import {
|
|
24
27
|
summarizeImageFailures
|
|
25
28
|
} from "./chunk-5KU25TMX.js";
|
|
@@ -29,8 +32,8 @@ import {
|
|
|
29
32
|
} from "./chunk-QZQRG3JY.js";
|
|
30
33
|
import {
|
|
31
34
|
composeClipMarkdown
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-LLAXR5EG.js";
|
|
36
|
+
import "./chunk-AZ43P73A.js";
|
|
34
37
|
import "./chunk-URYABAYN.js";
|
|
35
38
|
import {
|
|
36
39
|
clipEngineConfig,
|
|
@@ -63,6 +66,8 @@ var TOO_FREQUENT_CODES = /* @__PURE__ */ new Set([-509, -799]);
|
|
|
63
66
|
var BILIBILI_API_MIN_INTERVAL_MS = 5e3;
|
|
64
67
|
var apiSpacer = createRequestSpacer({ intervalMs: BILIBILI_API_MIN_INTERVAL_MS });
|
|
65
68
|
var NOT_FOUND_CODES = /* @__PURE__ */ new Set([-404, 4101131, 4101152, 4128002]);
|
|
69
|
+
var VIDEO_GONE_CODES = /* @__PURE__ */ new Set([-404, 62002, 62004, 62012]);
|
|
70
|
+
var VIDEO_VIEW_URL = "https://api.bilibili.com/x/web-interface/view";
|
|
66
71
|
async function fetchBilibiliDynamic(id, options = {}) {
|
|
67
72
|
const url = `${DYNAMIC_DETAIL_URL}?id=${encodeURIComponent(id)}&features=itemOpusStyle`;
|
|
68
73
|
const data = await getApiData(url, { id, kind: "dynamic" }, options);
|
|
@@ -117,6 +122,23 @@ async function fetchBilibiliArticle(id, options = {}) {
|
|
|
117
122
|
}
|
|
118
123
|
return data;
|
|
119
124
|
}
|
|
125
|
+
async function fetchBilibiliVideoGone(videoUrl, options = {}) {
|
|
126
|
+
const id = /\/video\/(BV[0-9A-Za-z]+|av\d+)/i.exec(videoUrl)?.[1];
|
|
127
|
+
if (!id) return null;
|
|
128
|
+
const query = /^av/i.test(id) ? `aid=${id.slice(2)}` : `bvid=${id}`;
|
|
129
|
+
try {
|
|
130
|
+
const intervalMs = options.minIntervalMs ?? (options.fetcher ? 0 : BILIBILI_API_MIN_INTERVAL_MS);
|
|
131
|
+
const envelope = await apiSpacer.run(
|
|
132
|
+
() => requestJson(`${VIDEO_VIEW_URL}?${query}`, { id, kind: "video" }, options),
|
|
133
|
+
{ intervalMs }
|
|
134
|
+
);
|
|
135
|
+
const code = typeof envelope.code === "number" ? envelope.code : Number(envelope.code);
|
|
136
|
+
if (!VIDEO_GONE_CODES.has(code)) return null;
|
|
137
|
+
return { code, message: typeof envelope.message === "string" ? envelope.message : "" };
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
120
142
|
async function resolveB23Url(url, options = {}) {
|
|
121
143
|
try {
|
|
122
144
|
const response = await fetchWithTimeout(
|
|
@@ -769,12 +791,12 @@ async function extractBilibiliClip(inputUrl, ctx, options = {}) {
|
|
|
769
791
|
logInfo("bilibili.runner", "post.is-video", { id: target.ref.id, kind: target.ref.kind, url });
|
|
770
792
|
}
|
|
771
793
|
const videoUrl = target.url;
|
|
772
|
-
const metadata = await
|
|
794
|
+
const { info, metadata } = await resolveBilibiliVideo(videoUrl);
|
|
773
795
|
const markdown = buildVideoMarkdown(
|
|
774
796
|
{ ...metadata, description: cleanBilibiliVideoDescription(metadata.description) },
|
|
775
797
|
{ site: "Bilibili" }
|
|
776
798
|
);
|
|
777
|
-
const video = await downloadBilibiliVideo(ctx.workDir, videoUrl);
|
|
799
|
+
const video = await downloadBilibiliVideo(ctx.workDir, videoUrl, info);
|
|
778
800
|
logInfo("bilibili.runner", "extract.ok", { primaryVideo: Boolean(video), title: metadata.title });
|
|
779
801
|
return {
|
|
780
802
|
author: metadata.author,
|
|
@@ -817,9 +839,41 @@ async function extractPost(post, workDir) {
|
|
|
817
839
|
title: post.title
|
|
818
840
|
};
|
|
819
841
|
}
|
|
820
|
-
async function
|
|
842
|
+
async function resolveBilibiliVideo(videoUrl) {
|
|
843
|
+
try {
|
|
844
|
+
return await resolveVideoInfo(videoUrl, ytdlpOptionsFor("bilibili"));
|
|
845
|
+
} catch (error) {
|
|
846
|
+
if (!(error instanceof VideoExtractError) || error.code !== "METADATA_FAILED") throw error;
|
|
847
|
+
const cookieHeader = await loadCookieHeader(platformCookiesFile("bilibili"), BILIBILI_COOKIE_DOMAIN_RE);
|
|
848
|
+
const gone = await fetchBilibiliVideoGone(videoUrl, { cookieHeader });
|
|
849
|
+
if (!gone) throw error;
|
|
850
|
+
logInfo("bilibili.runner", "video.gone", { code: gone.code, url: videoUrl });
|
|
851
|
+
throw new VideoExtractError("CONTENT_NOT_FOUND", `bilibili video is deleted or not visible (${gone.code} ${gone.message})`, {
|
|
852
|
+
code: gone.code,
|
|
853
|
+
url: videoUrl
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async function downloadBilibiliVideo(workDir, url, info) {
|
|
858
|
+
const opts = ytdlpOptionsFor("bilibili");
|
|
859
|
+
const budget = currentVideoByteBudget();
|
|
860
|
+
const pick = budget ? pickBudgetedFormat(info, { budgetBytes: budget.bytes, maxHeight: opts.maxHeight }) : void 0;
|
|
861
|
+
if (budget && pick) {
|
|
862
|
+
logInfo("bilibili.runner", "video.format.budgeted", {
|
|
863
|
+
budgetBytes: budget.bytes,
|
|
864
|
+
estimatedBytes: pick.estimatedBytes,
|
|
865
|
+
fits: pick.fits,
|
|
866
|
+
height: pick.height,
|
|
867
|
+
measured: budget.measured,
|
|
868
|
+
url
|
|
869
|
+
});
|
|
870
|
+
if (!pick.fits && budget.measured) {
|
|
871
|
+
logWarn("bilibili.runner", "video.skipped", { reason: "over-upload-budget", url });
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
821
875
|
try {
|
|
822
|
-
const video = await downloadVideo({ opts
|
|
876
|
+
const video = await downloadVideo({ opts, outDir: workDir, ...pick ? { preferredFormat: pick.selector } : {}, url });
|
|
823
877
|
if (!video) logWarn("bilibili.runner", "video.skipped", { reason: "oversize-or-unavailable", url });
|
|
824
878
|
return video;
|
|
825
879
|
} catch (error) {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-NGIIELO4.js";
|
|
7
7
|
import {
|
|
8
8
|
downloadWebImages
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MKEL2KNU.js";
|
|
10
10
|
import "./chunk-2LW76QIL.js";
|
|
11
11
|
import "./chunk-PTFGE4KS.js";
|
|
12
12
|
import {
|
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
import "./chunk-QZQRG3JY.js";
|
|
25
25
|
import {
|
|
26
26
|
composeClipMarkdown
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-LLAXR5EG.js";
|
|
28
|
+
import "./chunk-AZ43P73A.js";
|
|
29
29
|
import "./chunk-URYABAYN.js";
|
|
30
30
|
import {
|
|
31
31
|
clipEngineConfig
|
|
@@ -4,9 +4,77 @@ import {
|
|
|
4
4
|
DinoxError
|
|
5
5
|
} from "./chunk-3VZNZWDG.js";
|
|
6
6
|
|
|
7
|
+
// ../../packages/note-schema/src/tasks/taskStatus.ts
|
|
8
|
+
var TASK_STATUS_VALUES = [
|
|
9
|
+
"backlog",
|
|
10
|
+
"todo",
|
|
11
|
+
"in_progress",
|
|
12
|
+
"done",
|
|
13
|
+
"cancelled"
|
|
14
|
+
];
|
|
15
|
+
var OPEN_TASK_STATUSES = ["backlog", "todo", "in_progress"];
|
|
16
|
+
var TASK_STATUS_MARKDOWN_MARKER = {
|
|
17
|
+
backlog: ">",
|
|
18
|
+
todo: " ",
|
|
19
|
+
in_progress: "/",
|
|
20
|
+
done: "x",
|
|
21
|
+
cancelled: "-"
|
|
22
|
+
};
|
|
23
|
+
var TASK_STATUS_MARKER_CHARS = "[ xX>/-]";
|
|
24
|
+
function isTaskStatus(value) {
|
|
25
|
+
return typeof value === "string" && TASK_STATUS_VALUES.includes(value);
|
|
26
|
+
}
|
|
27
|
+
function isTaskClosed(status) {
|
|
28
|
+
return status === "done" || status === "cancelled";
|
|
29
|
+
}
|
|
30
|
+
function normalizeStoredTaskStatus(value) {
|
|
31
|
+
return value === "backlog" || value === "in_progress" || value === "cancelled" ? value : null;
|
|
32
|
+
}
|
|
33
|
+
function resolveTaskStatus(attrs) {
|
|
34
|
+
const stored = normalizeStoredTaskStatus(attrs?.status);
|
|
35
|
+
if (attrs?.checked === true) return stored === "cancelled" ? "cancelled" : "done";
|
|
36
|
+
return stored === "backlog" || stored === "in_progress" ? stored : "todo";
|
|
37
|
+
}
|
|
38
|
+
function taskStatusAttrs(status) {
|
|
39
|
+
switch (status) {
|
|
40
|
+
case "backlog":
|
|
41
|
+
case "in_progress":
|
|
42
|
+
return { checked: false, status };
|
|
43
|
+
case "todo":
|
|
44
|
+
return { checked: false, status: null };
|
|
45
|
+
case "done":
|
|
46
|
+
return { checked: true, status: null };
|
|
47
|
+
case "cancelled":
|
|
48
|
+
return { checked: true, status: "cancelled" };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function taskStatusFromMarkdownMarker(marker) {
|
|
52
|
+
switch (marker) {
|
|
53
|
+
case " ":
|
|
54
|
+
return "todo";
|
|
55
|
+
case "x":
|
|
56
|
+
case "X":
|
|
57
|
+
return "done";
|
|
58
|
+
case ">":
|
|
59
|
+
return "backlog";
|
|
60
|
+
case "/":
|
|
61
|
+
return "in_progress";
|
|
62
|
+
case "-":
|
|
63
|
+
return "cancelled";
|
|
64
|
+
default:
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function cascadedChildTaskStatus(parent, child) {
|
|
69
|
+
if (isTaskClosed(parent) && !isTaskClosed(child)) return parent;
|
|
70
|
+
return child;
|
|
71
|
+
}
|
|
72
|
+
function reopenedAncestorTaskStatus(ancestor) {
|
|
73
|
+
return isTaskClosed(ancestor) ? "todo" : ancestor;
|
|
74
|
+
}
|
|
75
|
+
|
|
7
76
|
// src/editor/todos.ts
|
|
8
|
-
var DEFAULT_TODO_FILTER = { status:
|
|
9
|
-
var STATUSES = ["uncompleted", "completed", "all"];
|
|
77
|
+
var DEFAULT_TODO_FILTER = { status: [...OPEN_TASK_STATUSES], query: "", tags: [], priority: [], from: null, to: null };
|
|
10
78
|
var PRIORITIES = ["high", "medium", "low", "none"];
|
|
11
79
|
var DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
12
80
|
var TIME = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
@@ -37,14 +105,18 @@ function parseTodoFilter(raw, base = DEFAULT_TODO_FILTER) {
|
|
|
37
105
|
if (raw === void 0 || raw === null) return { ...base };
|
|
38
106
|
if (typeof raw !== "object" || Array.isArray(raw)) throw invalid("filter must be an object");
|
|
39
107
|
const input = raw;
|
|
40
|
-
const status = input.status === void 0 ? base.status : input.status;
|
|
41
|
-
if (!STATUSES.includes(status)) throw invalid(`status must be one of ${STATUSES.join(", ")}`);
|
|
42
108
|
const list = (value, name) => {
|
|
43
109
|
if (value === void 0 || value === null) return [];
|
|
44
110
|
const items = Array.isArray(value) ? value : [value];
|
|
45
111
|
if (items.length > 20) throw invalid(`${name} has too many values`);
|
|
46
112
|
return items.map((item) => text(item, name, 100)).filter(Boolean);
|
|
47
113
|
};
|
|
114
|
+
let status = base.status;
|
|
115
|
+
if (input.status !== void 0) {
|
|
116
|
+
const wanted = new Set(list(input.status, "status"));
|
|
117
|
+
for (const value of wanted) if (!isTaskStatus(value)) throw invalid(`status must be a list of ${TASK_STATUS_VALUES.join(", ")}`);
|
|
118
|
+
status = TASK_STATUS_VALUES.filter((value) => wanted.has(value));
|
|
119
|
+
}
|
|
48
120
|
const tags = input.tags === void 0 ? base.tags : [...new Set(list(input.tags, "tags").map((tag) => tag.replace(/^#/, "")))];
|
|
49
121
|
const priority = input.priority === void 0 ? base.priority : [...new Set(list(input.priority, "priority"))];
|
|
50
122
|
for (const value of priority) if (!PRIORITIES.includes(value)) throw invalid(`priority must be one of ${PRIORITIES.join(", ")}`);
|
|
@@ -52,7 +124,7 @@ function parseTodoFilter(raw, base = DEFAULT_TODO_FILTER) {
|
|
|
52
124
|
const to = input.to === void 0 ? base.to : localDate(input.to, "to");
|
|
53
125
|
if (from && to && from > to) throw invalid("from must not be after to");
|
|
54
126
|
return {
|
|
55
|
-
status,
|
|
127
|
+
status: [...status],
|
|
56
128
|
query: input.query === void 0 ? base.query : text(input.query, "query", 500),
|
|
57
129
|
tags,
|
|
58
130
|
priority,
|
|
@@ -88,10 +160,7 @@ function parseTodoUpdates(raw) {
|
|
|
88
160
|
const update = { taskId };
|
|
89
161
|
const noteId = text(input.noteId, `updates[${index}].noteId`, 200);
|
|
90
162
|
if (noteId) update.noteId = noteId;
|
|
91
|
-
if (input.
|
|
92
|
-
if (typeof input.checked !== "boolean") throw invalid(`updates[${index}].checked must be true or false`);
|
|
93
|
-
update.checked = input.checked;
|
|
94
|
-
}
|
|
163
|
+
if (input.status !== void 0) update.status = statusValue(input.status, `updates[${index}].status`);
|
|
95
164
|
if (input.priority !== void 0) {
|
|
96
165
|
if (input.priority !== null && input.priority !== "none" && !["high", "medium", "low"].includes(input.priority)) {
|
|
97
166
|
throw invalid(`updates[${index}].priority must be high, medium, low or null`);
|
|
@@ -115,7 +184,7 @@ function parseTodoUpdates(raw) {
|
|
|
115
184
|
if (!words) throw invalid(`updates[${index}].text cannot be empty`);
|
|
116
185
|
update.text = words;
|
|
117
186
|
}
|
|
118
|
-
if (update.
|
|
187
|
+
if (update.status === void 0 && update.priority === void 0 && update.schedule === void 0 && update.text === void 0) {
|
|
119
188
|
throw invalid(`updates[${index}] changes nothing`);
|
|
120
189
|
}
|
|
121
190
|
return update;
|
|
@@ -123,6 +192,10 @@ function parseTodoUpdates(raw) {
|
|
|
123
192
|
}
|
|
124
193
|
var MAX_APPEND = 20;
|
|
125
194
|
var POINT_FORMATS = ["date", "datetime", "datetime-seconds", "time"];
|
|
195
|
+
function statusValue(value, name) {
|
|
196
|
+
if (!isTaskStatus(value)) throw invalid(`${name} must be one of ${TASK_STATUS_VALUES.join(", ")}`);
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
126
199
|
function priorityValue(value, name) {
|
|
127
200
|
if (value === null || value === "none") return null;
|
|
128
201
|
if (!["high", "medium", "low"].includes(value)) throw invalid(`${name} must be high, medium, low or null`);
|
|
@@ -183,10 +256,7 @@ function parseTodoRestore(raw) {
|
|
|
183
256
|
if (!taskId || !noteId) throw invalid(`entries[${index}] needs taskId and noteId`);
|
|
184
257
|
const restore = { taskId, noteId };
|
|
185
258
|
if (input.remove === true) return { ...restore, remove: true };
|
|
186
|
-
if (input.
|
|
187
|
-
if (typeof input.checked !== "boolean") throw invalid(`entries[${index}].checked must be true or false`);
|
|
188
|
-
restore.checked = input.checked;
|
|
189
|
-
}
|
|
259
|
+
if (input.status !== void 0) restore.status = statusValue(input.status, `entries[${index}].status`);
|
|
190
260
|
if (input.priority !== void 0) restore.priority = priorityValue(input.priority, `entries[${index}].priority`);
|
|
191
261
|
if (input.due !== void 0) {
|
|
192
262
|
if (input.due === null) {
|
|
@@ -200,7 +270,7 @@ function parseTodoRestore(raw) {
|
|
|
200
270
|
}
|
|
201
271
|
}
|
|
202
272
|
if (input.paragraph !== void 0) restore.paragraph = restoreParagraph(input.paragraph, `entries[${index}].paragraph`);
|
|
203
|
-
if (restore.
|
|
273
|
+
if (restore.status === void 0 && restore.priority === void 0 && restore.dueAt === void 0 && restore.paragraph === void 0) {
|
|
204
274
|
throw invalid(`entries[${index}] changes nothing`);
|
|
205
275
|
}
|
|
206
276
|
return restore;
|
|
@@ -218,7 +288,7 @@ function dueText(task) {
|
|
|
218
288
|
function formatTodoList(list, max = 40) {
|
|
219
289
|
const { filter } = list;
|
|
220
290
|
const scope = [
|
|
221
|
-
filter.status ===
|
|
291
|
+
filter.status.length === 0 || filter.status.length === TASK_STATUS_VALUES.length ? "all tasks" : `${filter.status.join("/")} tasks`,
|
|
222
292
|
filter.query ? `matching "${filter.query}"` : "",
|
|
223
293
|
filter.tags.length ? `tagged ${filter.tags.map((tag) => `#${tag}`).join(" ")}` : "",
|
|
224
294
|
filter.priority.length ? `priority ${filter.priority.join("/")}` : "",
|
|
@@ -227,13 +297,24 @@ function formatTodoList(list, max = 40) {
|
|
|
227
297
|
const lines = [`${list.total}${list.hasMore ? "+" : ""} ${scope}.`];
|
|
228
298
|
for (const task of list.tasks.slice(0, max)) {
|
|
229
299
|
const extras = [PRIORITY_MARK[task.priority ?? ""], dueText(task) && `due ${dueText(task)}`, `in "${task.note_title || "Untitled"}"`].filter(Boolean).join(" \xB7 ");
|
|
230
|
-
lines.push(`${" ".repeat(Math.min(task.depth, 4))}- [${task.
|
|
300
|
+
lines.push(`${" ".repeat(Math.min(task.depth, 4))}- [${TASK_STATUS_MARKDOWN_MARKER[task.status]}] ${task.text} (${extras}) [${task.task_id}]`);
|
|
231
301
|
}
|
|
232
302
|
if (list.tasks.length > max) lines.push(`\u2026 ${list.tasks.length - max} more in the panel.`);
|
|
233
303
|
return lines.join("\n");
|
|
234
304
|
}
|
|
235
305
|
|
|
236
306
|
export {
|
|
307
|
+
TASK_STATUS_VALUES,
|
|
308
|
+
TASK_STATUS_MARKDOWN_MARKER,
|
|
309
|
+
TASK_STATUS_MARKER_CHARS,
|
|
310
|
+
isTaskStatus,
|
|
311
|
+
isTaskClosed,
|
|
312
|
+
normalizeStoredTaskStatus,
|
|
313
|
+
resolveTaskStatus,
|
|
314
|
+
taskStatusAttrs,
|
|
315
|
+
taskStatusFromMarkdownMarker,
|
|
316
|
+
cascadedChildTaskStatus,
|
|
317
|
+
reopenedAncestorTaskStatus,
|
|
237
318
|
DEFAULT_TODO_FILTER,
|
|
238
319
|
parseTodoFilter,
|
|
239
320
|
todoSearchWire,
|