@dinoxx/dinox-cli 2.18.4 → 2.19.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.
Files changed (35) hide show
  1. package/dist/commands/notes/contentEngine.js +8 -4
  2. package/dist/commands/schema/renderSkills.js +3 -1
  3. package/dist/commands/todo/contentModel.d.ts +5 -3
  4. package/dist/commands/todo/contentModel.js +7 -5
  5. package/dist/commands/todo/dryRun.d.ts +9 -7
  6. package/dist/commands/todo/dryRun.js +99 -86
  7. package/dist/commands/todo/index.js +279 -93
  8. package/dist/commands/todo/repo.d.ts +128 -7
  9. package/dist/commands/todo/repo.js +474 -130
  10. package/dist/commands/todo/taskModel.d.ts +20 -1
  11. package/dist/commands/todo/taskModel.js +153 -20
  12. package/dist/commands/todo/taskPatch.d.ts +119 -0
  13. package/dist/commands/todo/taskPatch.js +502 -0
  14. package/dist/commands/todo/taskText.d.ts +26 -0
  15. package/dist/commands/todo/taskText.js +221 -0
  16. package/dist/daemon/supervisor.d.ts +0 -6
  17. package/dist/daemon/supervisor.js +10 -2
  18. package/dist/dsh-plugin/lib/client.js +713 -289
  19. package/dist/dsh-plugin/lib/index.js +7 -2
  20. package/dist/dsh-plugin/package.json +1 -1
  21. package/dist/dsh-plugin/runtime.json +1 -1
  22. package/dist/editor/compat.d.ts +6 -0
  23. package/dist/editor/compat.js +18 -0
  24. package/dist/editor/daemon.js +27 -0
  25. package/dist/editor/mcp.js +99 -2
  26. package/dist/editor/service.d.ts +57 -1
  27. package/dist/editor/service.js +174 -7
  28. package/dist/editor/todos.d.ts +67 -0
  29. package/dist/editor/todos.js +293 -0
  30. package/dist/editor-ui/mcp-app.html +262 -253
  31. package/dist/integrations/dsh/host.js +10 -2
  32. package/dist/utils/tiptapMarkdown.js +15 -1
  33. package/dist/vendor/electron/shared/task-priority.d.ts +42 -0
  34. package/dist/vendor/electron/shared/task-priority.js +186 -0
  35. package/package.json +1 -1
@@ -8,10 +8,10 @@ import { printDryRunPreview } from '../../utils/dryRun.js';
8
8
  import { DinoxError } from '../../utils/errors.js';
9
9
  import { printSuccess } from '../../utils/output.js';
10
10
  import { commandStale, resolveWriteDurabilityForRuntime, syncBeforeCommand, waitForMutationUpload, withCommandRuntime, } from '../runtime.js';
11
- import { readNoteWriteReceipt } from '../notes/writeReceipt.js';
11
+ import { readNoteRevisionReceipts, readNoteWriteReceipt } from '../notes/writeReceipt.js';
12
12
  import { parseCreatedAtRange } from '../notes/searchTime.js';
13
13
  import { buildTodoAppendDryRunPreview, buildTodoCreateDryRunPreview, buildTodoUpdateDryRunPreview, } from './dryRun.js';
14
- import { appendTodoTasks, createTodoNote, executeTodoSearch, normalizeTaskTexts, toTodoSearchWire, updateTodoTaskStatus, } from './repo.js';
14
+ import { appendTodoTasks, createTodoNote, executeTodoSearch, normalizeTaskTexts, toTodoSearchWire, updateTodoTasks, updateTodoTaskStatus, } from './repo.js';
15
15
  import { routeRead } from '../../daemon/route.js';
16
16
  const DEFAULT_TASK_LIMIT = 50;
17
17
  const DEFAULT_NOTE_SCAN_LIMIT = 200;
@@ -27,6 +27,121 @@ const TODO_WRITE_RECEIPT_FIELDS = [
27
27
  'changed',
28
28
  'stale',
29
29
  ];
30
+ const TASK_PRIORITIES = ['high', 'medium', 'low'];
31
+ function optionalString(value) {
32
+ return typeof value === 'string' ? value : undefined;
33
+ }
34
+ /** `high|medium|low` sets a priority; `none` clears it. */
35
+ function parsePriorityValue(value, optionName) {
36
+ const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
37
+ if (TASK_PRIORITIES.includes(normalized))
38
+ return normalized;
39
+ if (normalized === 'none')
40
+ return null;
41
+ throw new DinoxError(`${optionName} must be one of: high, medium, low, none`, { code: 'INVALID_ARGUMENT' });
42
+ }
43
+ function parsePriorityFilter(value) {
44
+ if (typeof value !== 'string' || !value.trim())
45
+ return [];
46
+ return Array.from(new Set(value.split(/[\s,,]+/).filter(Boolean).map((entry) => {
47
+ const priority = parsePriorityValue(entry, '--priority');
48
+ return priority ?? 'none';
49
+ })));
50
+ }
51
+ /** `--due` / `--time` into a schedule; `--time` alone is rejected (a due time needs a day). */
52
+ function parseScheduleOptions(due, time) {
53
+ const date = typeof due === 'string' ? due.trim() : '';
54
+ const clock = typeof time === 'string' ? time.trim() : '';
55
+ if (!date) {
56
+ if (clock)
57
+ throw new DinoxError('--time needs --due <YYYY-MM-DD>', { code: 'INVALID_ARGUMENT' });
58
+ return undefined;
59
+ }
60
+ return { date, time: clock || null };
61
+ }
62
+ async function parseJsonInput(value, optionName) {
63
+ const raw = await readStringOrFile(value);
64
+ try {
65
+ return JSON.parse(raw);
66
+ }
67
+ catch (error) {
68
+ throw new DinoxError(`${optionName} must be valid JSON`, { code: 'INVALID_ARGUMENT', cause: error });
69
+ }
70
+ }
71
+ function toDraftItems(value, path = '--items') {
72
+ if (!Array.isArray(value)) {
73
+ throw new DinoxError(`${path} must be a JSON array of task items`, { code: 'INVALID_ARGUMENT' });
74
+ }
75
+ return value.map((entry, index) => {
76
+ const where = `${path}[${index}]`;
77
+ if (typeof entry === 'string')
78
+ return { text: entry };
79
+ if (!entry || typeof entry !== 'object') {
80
+ throw new DinoxError(`${where} must be a string or an object with "text"`, { code: 'INVALID_ARGUMENT' });
81
+ }
82
+ const item = entry;
83
+ if (typeof item.text !== 'string') {
84
+ throw new DinoxError(`${where}.text must be a string`, { code: 'INVALID_ARGUMENT' });
85
+ }
86
+ const draft = { text: item.text };
87
+ if (item.checked !== undefined)
88
+ draft.checked = item.checked === true;
89
+ if (item.priority !== undefined && item.priority !== null) {
90
+ draft.priority = parsePriorityValue(item.priority, `${where}.priority`);
91
+ }
92
+ if (item.schedule !== undefined && item.schedule !== null) {
93
+ draft.schedule = toSchedule(item.schedule, `${where}.schedule`);
94
+ }
95
+ if (item.subtasks !== undefined && item.subtasks !== null) {
96
+ draft.subtasks = toDraftItems(item.subtasks, `${where}.subtasks`);
97
+ }
98
+ return draft;
99
+ });
100
+ }
101
+ function toSchedule(value, where) {
102
+ if (!value || typeof value !== 'object') {
103
+ throw new DinoxError(`${where} must be {"date":"YYYY-MM-DD","time":"HH:mm"|null}`, { code: 'INVALID_ARGUMENT' });
104
+ }
105
+ const schedule = value;
106
+ if (typeof schedule.date !== 'string') {
107
+ throw new DinoxError(`${where}.date must be a YYYY-MM-DD string`, { code: 'INVALID_ARGUMENT' });
108
+ }
109
+ if (schedule.time !== undefined && schedule.time !== null && typeof schedule.time !== 'string') {
110
+ throw new DinoxError(`${where}.time must be HH:mm or null`, { code: 'INVALID_ARGUMENT' });
111
+ }
112
+ return { date: schedule.date, time: schedule.time ?? null };
113
+ }
114
+ function toTaskUpdates(value) {
115
+ if (!Array.isArray(value) || value.length === 0) {
116
+ throw new DinoxError('--updates must be a non-empty JSON array', { code: 'INVALID_ARGUMENT' });
117
+ }
118
+ return value.map((entry, index) => {
119
+ const where = `--updates[${index}]`;
120
+ if (!entry || typeof entry !== 'object') {
121
+ throw new DinoxError(`${where} must be an object`, { code: 'INVALID_ARGUMENT' });
122
+ }
123
+ const item = entry;
124
+ const taskId = item.task_id ?? item.taskId;
125
+ if (typeof taskId !== 'string' || !taskId.trim()) {
126
+ throw new DinoxError(`${where}.task_id is required`, { code: 'INVALID_ARGUMENT' });
127
+ }
128
+ const noteId = item.note_id ?? item.noteId;
129
+ const update = { taskId };
130
+ if (typeof noteId === 'string')
131
+ update.noteId = noteId;
132
+ if (item.status !== undefined)
133
+ update.checked = parseTaskCheckedStatus(item.status);
134
+ if (typeof item.checked === 'boolean')
135
+ update.checked = item.checked;
136
+ if (item.priority !== undefined) {
137
+ update.priority = item.priority === null ? null : parsePriorityValue(item.priority, `${where}.priority`);
138
+ }
139
+ if (item.schedule !== undefined) {
140
+ update.schedule = item.schedule === null ? null : toSchedule(item.schedule, `${where}.schedule`);
141
+ }
142
+ return update;
143
+ });
144
+ }
30
145
  function parseTaskStatus(value) {
31
146
  const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
32
147
  if (normalized === 'all' || normalized === 'completed' || normalized === 'uncompleted') {
@@ -116,19 +231,35 @@ async function parseTaskListInput(value) {
116
231
  function collectStringOptionValue(value, previous) {
117
232
  return [...(Array.isArray(previous) ? previous : []), value];
118
233
  }
119
- async function parseTaskInput(args) {
120
- const merged = [];
121
- if (typeof args.positionalTask === 'string') {
122
- merged.push(args.positionalTask);
234
+ /**
235
+ * Collect new tasks from `[task]`, `--task`, `--tasks` (flat texts, which take `--priority`,
236
+ * `--due` and `--time`) and `--items` (structured items with their own fields and subtasks).
237
+ */
238
+ async function parseTaskDrafts(positionalTask, options) {
239
+ const texts = [];
240
+ if (typeof positionalTask === 'string')
241
+ texts.push(positionalTask);
242
+ if (Array.isArray(options.task))
243
+ texts.push(...options.task);
244
+ if (typeof options.tasks === 'string')
245
+ texts.push(...await parseTaskListInput(options.tasks));
246
+ const priority = options.priority === undefined ? undefined : parsePriorityValue(options.priority, '--priority');
247
+ const schedule = parseScheduleOptions(options.due, options.time);
248
+ const items = typeof options.items === 'string' ? toDraftItems(await parseJsonInput(options.items, '--items')) : [];
249
+ if (texts.length === 0 && items.length === 0) {
250
+ throw new DinoxError('At least one non-empty task is required', { code: 'INVALID_ARGUMENT' });
123
251
  }
124
- if (Array.isArray(args.taskOptionList)) {
125
- merged.push(...args.taskOptionList);
252
+ if (texts.length === 0 && (priority !== undefined || schedule)) {
253
+ throw new DinoxError('--priority/--due/--time apply to --task/--tasks; put them inside --items entries instead', { code: 'INVALID_ARGUMENT' });
126
254
  }
127
- if (typeof args.tasksOption === 'string') {
128
- const parsed = await parseTaskListInput(args.tasksOption);
129
- merged.push(...parsed);
130
- }
131
- return normalizeTaskTexts(merged);
255
+ const flat = texts.length > 0
256
+ ? normalizeTaskTexts(texts).map((text) => ({
257
+ text,
258
+ ...(priority ? { priority } : {}),
259
+ ...(schedule ? { schedule } : {}),
260
+ }))
261
+ : [];
262
+ return [...flat, ...items];
132
263
  }
133
264
  async function withTodoDatabase(globals, run) {
134
265
  return withCommandRuntime(globals, run);
@@ -141,6 +272,7 @@ async function runTodoSearch({ args, globals, options }) {
141
272
  const taskTagFilter = typeof searchOptions.tags === 'string'
142
273
  ? await parseTagFilterInput(searchOptions.tags)
143
274
  : [];
275
+ const taskPriorityFilter = parsePriorityFilter(searchOptions.priority);
144
276
  const taskDateRange = parseTaskDateRange({
145
277
  from: searchOptions.from,
146
278
  to: searchOptions.to,
@@ -154,6 +286,7 @@ async function runTodoSearch({ args, globals, options }) {
154
286
  includeDeleted: Boolean(searchOptions.includeDeleted),
155
287
  taskStatus,
156
288
  taskTagFilter,
289
+ ...(taskPriorityFilter.length > 0 ? { taskPriorityFilter } : {}),
157
290
  from: searchOptions.from,
158
291
  to: searchOptions.to,
159
292
  days: searchOptions.days,
@@ -164,6 +297,7 @@ async function runTodoSearch({ args, globals, options }) {
164
297
  includeDeleted: Boolean(searchOptions.includeDeleted),
165
298
  taskStatus,
166
299
  taskTagFilter,
300
+ taskPriorityFilter,
167
301
  taskDateRange,
168
302
  limit,
169
303
  offset,
@@ -188,29 +322,26 @@ async function runTodoAppend({ args, globals, options }) {
188
322
  const { db, config, offline } = runtime;
189
323
  await syncBeforeCommand(runtime);
190
324
  const durability = resolveWriteDurabilityForRuntime(runtime, appendOptions.durability);
191
- const taskTexts = await parseTaskInput({
192
- positionalTask: args.task,
193
- tasksOption: typeof appendOptions.tasks === 'string' ? appendOptions.tasks : undefined,
194
- taskOptionList: Array.isArray(appendOptions.task) ? appendOptions.task : [],
195
- });
325
+ const items = await parseTaskDrafts(args.task, appendOptions);
326
+ const target = {
327
+ noteId: optionalString(appendOptions.noteId),
328
+ parentTaskId: optionalString(appendOptions.parent),
329
+ date: optionalString(appendOptions.date),
330
+ };
196
331
  if (Boolean(appendOptions.dryRun)) {
197
- const preview = await buildTodoAppendDryRunPreview({
198
- db,
199
- config,
200
- offline,
201
- noteId: typeof appendOptions.noteId === 'string' ? appendOptions.noteId : undefined,
202
- taskTexts,
203
- });
332
+ const preview = await buildTodoAppendDryRunPreview({ db, config, offline, ...target, items });
204
333
  printDryRunPreview(preview, runtime);
205
334
  return;
206
335
  }
207
- const result = await appendTodoTasks(db, {
208
- noteId: typeof appendOptions.noteId === 'string' ? appendOptions.noteId : undefined,
209
- taskTexts,
210
- });
336
+ // Only needed when today's daily todo note has to be created.
337
+ const needsUser = !target.noteId && !target.parentTaskId;
338
+ const userId = needsUser ? (await resolveAuthIdentity(config)).userId : undefined;
339
+ const result = await appendTodoTasks(db, { ...target, items, userId });
211
340
  const upload = await waitForMutationUpload(runtime, { durability });
212
341
  const receipt = await readNoteWriteReceipt(db, result.note_id, {
213
- changed: ['content_json', 'image_detail', 'content_md', 'content_text'],
342
+ changed: result.created
343
+ ? ['title', 'type', 'content_json', 'image_detail', 'content_md', 'content_text']
344
+ : ['content_json', 'image_detail', 'content_md', 'content_text'],
214
345
  upload,
215
346
  stale: commandStale(runtime),
216
347
  });
@@ -223,27 +354,15 @@ async function runTodoCreate({ args, globals, options }) {
223
354
  const { db, config, offline } = runtime;
224
355
  await syncBeforeCommand(runtime);
225
356
  const durability = resolveWriteDurabilityForRuntime(runtime, createOptions.durability);
226
- const taskTexts = await parseTaskInput({
227
- positionalTask: args.task,
228
- tasksOption: typeof createOptions.tasks === 'string' ? createOptions.tasks : undefined,
229
- taskOptionList: Array.isArray(createOptions.task) ? createOptions.task : [],
230
- });
357
+ const items = await parseTaskDrafts(args.task, createOptions);
358
+ const title = optionalString(createOptions.title);
231
359
  if (Boolean(createOptions.dryRun)) {
232
- const preview = await buildTodoCreateDryRunPreview({
233
- config,
234
- offline,
235
- title: typeof createOptions.title === 'string' ? createOptions.title : undefined,
236
- taskTexts,
237
- });
360
+ const preview = await buildTodoCreateDryRunPreview({ config, offline, title, items });
238
361
  printDryRunPreview(preview, runtime);
239
362
  return;
240
363
  }
241
364
  const identity = await resolveAuthIdentity(config);
242
- const result = await createTodoNote(db, {
243
- taskTexts,
244
- title: typeof createOptions.title === 'string' ? createOptions.title : undefined,
245
- userId: identity.userId,
246
- });
365
+ const result = await createTodoNote(db, { items, title, userId: identity.userId });
247
366
  const upload = await waitForMutationUpload(runtime, { durability });
248
367
  const receipt = await readNoteWriteReceipt(db, result.note_id, {
249
368
  changed: ['title', 'type', 'content_json', 'image_detail', 'content_md', 'content_text'],
@@ -253,39 +372,80 @@ async function runTodoCreate({ args, globals, options }) {
253
372
  printSuccess({ ok: true, ...receipt, ...result });
254
373
  });
255
374
  }
375
+ const TODO_UPDATE_CHANGED_FIELDS = ['content_json', 'image_detail', 'content_md', 'content_text'];
376
+ function parseSingleUpdate(taskId, options) {
377
+ if (!taskId?.trim()) {
378
+ throw new DinoxError('taskId is required (or pass --updates for a batch)', { code: 'INVALID_ARGUMENT' });
379
+ }
380
+ const update = { taskId };
381
+ const noteId = optionalString(options.noteId);
382
+ if (noteId !== undefined)
383
+ update.noteId = noteId;
384
+ if (options.status !== undefined)
385
+ update.checked = parseTaskCheckedStatus(options.status);
386
+ if (options.priority !== undefined)
387
+ update.priority = parsePriorityValue(options.priority, '--priority');
388
+ const schedule = parseScheduleOptions(options.due, options.time);
389
+ if (options.clearDue) {
390
+ if (schedule)
391
+ throw new DinoxError('--clear-due cannot be combined with --due/--time', { code: 'INVALID_ARGUMENT' });
392
+ update.schedule = null;
393
+ }
394
+ else if (schedule) {
395
+ update.schedule = schedule;
396
+ }
397
+ return update;
398
+ }
256
399
  async function runTodoUpdate({ args, globals, options }) {
257
400
  const updateOptions = options;
258
401
  await withTodoDatabase(globals, async (runtime) => {
259
402
  const { db, config, offline } = runtime;
260
403
  await syncBeforeCommand(runtime);
261
404
  const durability = resolveWriteDurabilityForRuntime(runtime, updateOptions.durability);
262
- const taskId = args.taskId;
263
- if (!taskId) {
264
- throw new DinoxError('taskId is required');
405
+ if (typeof updateOptions.updates === 'string') {
406
+ const hasSingleFields = args.taskId !== undefined
407
+ || [updateOptions.status, updateOptions.priority, updateOptions.due, updateOptions.time, updateOptions.clearDue, updateOptions.noteId]
408
+ .some((value) => value !== undefined);
409
+ if (hasSingleFields) {
410
+ throw new DinoxError('--updates replaces <taskId> and the per-task options; put them inside each entry', { code: 'INVALID_ARGUMENT' });
411
+ }
412
+ const updates = toTaskUpdates(await parseJsonInput(updateOptions.updates, '--updates'));
413
+ if (Boolean(updateOptions.dryRun)) {
414
+ printDryRunPreview(await buildTodoUpdateDryRunPreview({ db, config, offline, updates }), runtime);
415
+ return;
416
+ }
417
+ const result = await updateTodoTasks(db, updates);
418
+ const upload = await waitForMutationUpload(runtime, { durability });
419
+ const changedNotes = new Set(result.tasks.filter((task) => task.updated).map((task) => task.note_id));
420
+ const revisions = await readNoteRevisionReceipts(db, result.note_ids, new Map(result.note_ids.map((id) => [id, changedNotes.has(id) ? TODO_UPDATE_CHANGED_FIELDS : []])));
421
+ printSuccess({
422
+ ok: true,
423
+ ...upload,
424
+ stale: commandStale(runtime),
425
+ ...result,
426
+ notes: result.note_ids.map((id) => ({ note_id: id, ...revisions.get(id) })),
427
+ });
428
+ return;
265
429
  }
266
- const checked = parseTaskCheckedStatus(updateOptions.status);
430
+ const update = parseSingleUpdate(args.taskId, updateOptions);
267
431
  if (Boolean(updateOptions.dryRun)) {
268
432
  const preview = await buildTodoUpdateDryRunPreview({
269
433
  db,
270
434
  config,
271
435
  offline,
272
- taskId,
273
- noteId: typeof updateOptions.noteId === 'string' ? updateOptions.noteId : undefined,
274
- checked,
436
+ taskId: update.taskId,
437
+ noteId: update.noteId,
438
+ checked: update.checked,
439
+ priority: update.priority,
440
+ schedule: update.schedule,
275
441
  });
276
442
  printDryRunPreview(preview, runtime);
277
443
  return;
278
444
  }
279
- const result = await updateTodoTaskStatus(db, {
280
- taskId,
281
- noteId: typeof updateOptions.noteId === 'string' ? updateOptions.noteId : undefined,
282
- checked,
283
- });
445
+ const result = await updateTodoTaskStatus(db, update);
284
446
  const upload = await waitForMutationUpload(runtime, { durability });
285
447
  const receipt = await readNoteWriteReceipt(db, result.note_id, {
286
- changed: result.updated
287
- ? ['content_json', 'image_detail', 'content_md', 'content_text']
288
- : [],
448
+ changed: result.updated ? TODO_UPDATE_CHANGED_FIELDS : [],
289
449
  upload,
290
450
  stale: commandStale(runtime),
291
451
  });
@@ -303,8 +463,9 @@ const todoSearchCommand = {
303
463
  ],
304
464
  options: [
305
465
  { flags: '--status <status>', description: 'Task status: all | completed | uncompleted', defaultValue: 'all' },
306
- { flags: '--tags <string|@file>', description: 'Task tags (JSON array or comma/newline-separated)' },
307
- { flags: '--from <date>', description: 'Task date range start (YYYY-MM-DD or ISO datetime)' },
466
+ { flags: '--tags <string|@file>', description: 'Tags every task must carry, via its own #tag or its note\'s tags (JSON array or comma/newline-separated)' },
467
+ { flags: '--priority <list>', description: 'Priorities to keep, comma-separated: high,medium,low,none' },
468
+ { flags: '--from <date>', description: 'Task date range start (YYYY-MM-DD or ISO datetime); matches tasks whose schedule overlaps the range' },
308
469
  { flags: '--to <date>', description: 'Task date range end (YYYY-MM-DD or ISO datetime)' },
309
470
  { flags: '--days <n>', description: 'Recent N days; mutually exclusive with --from/--to' },
310
471
  { flags: '--limit <n>', description: 'Maximum returned tasks' },
@@ -320,16 +481,36 @@ const todoSearchCommand = {
320
481
  output: {
321
482
  type: 'structured',
322
483
  summary: 'Todo search payload with metadata and task list',
323
- fields: ['tasks.task_id', 'tasks.task_key', 'tasks.note_id', 'tasks.note_title', 'tasks.status', 'tasks.depth', 'tasks.parent_id', 'tasks.tags'],
324
- metaFields: ['stale', 'meta.query', 'meta.returned_count', 'meta.total_count', 'meta.total_count_is_lower_bound', 'meta.matched_note_count', 'meta.limit', 'meta.offset', 'meta.has_more', 'meta.next_cursor', 'meta.scan_limit', 'meta.scanned_note_count', 'meta.scan_truncated', 'meta.truncated', 'meta.applied_filters.status', 'meta.applied_filters.tags', 'meta.applied_filters.include_deleted', 'meta.applied_filters.date_range'],
484
+ fields: ['tasks.task_id', 'tasks.task_key', 'tasks.note_id', 'tasks.note_title', 'tasks.status', 'tasks.priority', 'tasks.depth', 'tasks.parent_id', 'tasks.tags', 'tasks.note_tags', 'tasks.note_box_ids', 'tasks.start_time', 'tasks.due_time'],
485
+ metaFields: ['stale', 'meta.query', 'meta.returned_count', 'meta.total_count', 'meta.total_count_is_lower_bound', 'meta.matched_note_count', 'meta.limit', 'meta.offset', 'meta.has_more', 'meta.next_cursor', 'meta.scan_limit', 'meta.scanned_note_count', 'meta.scan_truncated', 'meta.truncated', 'meta.applied_filters.status', 'meta.applied_filters.tags', 'meta.applied_filters.priority', 'meta.applied_filters.include_deleted', 'meta.applied_filters.date_range'],
325
486
  },
326
- examples: ['dino todo search "报销" --status uncompleted --format json', 'dino todo search --days 7 --format json'],
487
+ examples: [
488
+ 'dino todo search "报销" --status uncompleted --format json',
489
+ 'dino todo search --days 7 --format json',
490
+ 'dino todo search --status uncompleted --priority high,medium --format json',
491
+ ],
327
492
  },
328
493
  action: runTodoSearch,
329
494
  };
495
+ const NEW_TASK_OPTIONS = [
496
+ {
497
+ flags: '--task <text>',
498
+ description: 'Repeatable task text (inline Markdown: #tag, links, [#A] priority cookie)',
499
+ parser: collectStringOptionValue,
500
+ defaultValue: [],
501
+ },
502
+ { flags: '--tasks <string|@file>', description: 'Task list (JSON array or comma/newline-separated)' },
503
+ {
504
+ flags: '--items <json|@file>',
505
+ description: 'Structured tasks: JSON array of {text, checked?, priority?, schedule?: {date, time?}, subtasks?: [...]}',
506
+ },
507
+ { flags: '--priority <priority>', description: 'Priority for --task/--tasks: high|medium|low' },
508
+ { flags: '--due <date>', description: 'Due date for --task/--tasks (local YYYY-MM-DD)' },
509
+ { flags: '--time <HH:mm>', description: 'Due clock time with --due (local HH:mm); omit for an all-day due date' },
510
+ ];
330
511
  const todoAppendCommand = {
331
512
  name: 'append',
332
- description: 'Append one or more tasks to an existing note',
513
+ description: 'Add tasks to today\'s daily todo note, a given note, or under a task as subtasks',
333
514
  arguments: [
334
515
  {
335
516
  syntax: '[task]',
@@ -337,14 +518,10 @@ const todoAppendCommand = {
337
518
  },
338
519
  ],
339
520
  options: [
340
- {
341
- flags: '--task <text>',
342
- description: 'Repeatable task text',
343
- parser: collectStringOptionValue,
344
- defaultValue: [],
345
- },
346
- { flags: '--tasks <string|@file>', description: 'Task list (JSON array or comma/newline-separated)' },
347
- { flags: '--note-id <id>', description: 'Target note id; omitted means latest eligible note' },
521
+ ...NEW_TASK_OPTIONS,
522
+ { flags: '--note-id <id>', description: 'Target note id; omitted means the daily todo note (created if missing)' },
523
+ { flags: '--parent <taskId>', description: 'Add the tasks as subtasks of this task (combine with --note-id to skip the lookup)' },
524
+ { flags: '--date <date>', description: 'Daily target day (local YYYY-MM-DD); also the due date of tasks without one' },
348
525
  WRITE_DURABILITY_OPTION,
349
526
  { flags: '--dry-run', description: 'Preview the write without executing it' },
350
527
  ],
@@ -355,10 +532,14 @@ const todoAppendCommand = {
355
532
  globalOptions: TODO_GLOBAL_OPTIONS,
356
533
  output: {
357
534
  type: 'structured',
358
- summary: 'Append result with target note, appended task count, and write receipt',
359
- fields: ['note_id', 'appended_count', 'source', ...TODO_WRITE_RECEIPT_FIELDS],
535
+ summary: 'Append result with target note, created tasks, and write receipt',
536
+ fields: ['note_id', 'appended_count', 'source', 'created', 'day_key', 'parent_task_id', 'tasks.task_id', 'tasks.text', 'tasks.priority', 'tasks.parent_task_id', 'tasks.due_time', ...TODO_WRITE_RECEIPT_FIELDS],
360
537
  },
361
- examples: ['dino todo append --note-id <id> --task "补交报销单" --durability uploaded --format json'],
538
+ examples: [
539
+ 'dino todo append "补交报销单" --priority high --due 2026-11-10 --format json',
540
+ 'dino todo append --note-id <id> --task "补交报销单" --durability uploaded --format json',
541
+ 'dino todo append --parent <taskId> --task "整理发票" --format json',
542
+ ],
362
543
  },
363
544
  action: runTodoAppend,
364
545
  };
@@ -372,13 +553,7 @@ const todoCreateCommand = {
372
553
  },
373
554
  ],
374
555
  options: [
375
- {
376
- flags: '--task <text>',
377
- description: 'Repeatable task text',
378
- parser: collectStringOptionValue,
379
- defaultValue: [],
380
- },
381
- { flags: '--tasks <string|@file>', description: 'Task list (JSON array or comma/newline-separated)' },
556
+ ...NEW_TASK_OPTIONS,
382
557
  { flags: '--title <string>', description: 'Optional note title' },
383
558
  WRITE_DURABILITY_OPTION,
384
559
  { flags: '--dry-run', description: 'Preview the write without executing it' },
@@ -391,7 +566,7 @@ const todoCreateCommand = {
391
566
  output: {
392
567
  type: 'structured',
393
568
  summary: 'Creation result with new note id, created task count, and write receipt',
394
- fields: ['note_id', 'created_count', 'title', ...TODO_WRITE_RECEIPT_FIELDS],
569
+ fields: ['note_id', 'created_count', 'title', 'tasks.task_id', 'tasks.text', 'tasks.priority', 'tasks.parent_task_id', 'tasks.due_time', ...TODO_WRITE_RECEIPT_FIELDS],
395
570
  },
396
571
  examples: ['dino todo create --task "补交报销单" --task "整理发票" --format json'],
397
572
  },
@@ -399,18 +574,25 @@ const todoCreateCommand = {
399
574
  };
400
575
  const todoUpdateCommand = {
401
576
  name: 'update',
402
- description: 'Update a todo task checked status by task id',
577
+ description: 'Update a task\'s status, priority, or due time by task id (checking cascades to subtasks)',
403
578
  arguments: [
404
579
  {
405
- syntax: '<taskId>',
406
- description: 'Task id',
580
+ syntax: '[taskId]',
581
+ description: 'Task id (omit when using --updates)',
407
582
  },
408
583
  ],
409
584
  options: [
410
585
  {
411
586
  flags: '--status <status>',
412
587
  description: 'Target status: completed|uncompleted|done|undone|true|false|1|0',
413
- required: true,
588
+ },
589
+ { flags: '--priority <priority>', description: 'Set priority: high|medium|low, or none to clear' },
590
+ { flags: '--due <date>', description: 'Set the due date (local YYYY-MM-DD)' },
591
+ { flags: '--time <HH:mm>', description: 'Due clock time with --due (local HH:mm); omit for an all-day due date' },
592
+ { flags: '--clear-due', description: 'Remove the task\'s due time' },
593
+ {
594
+ flags: '--updates <json|@file>',
595
+ description: 'Batch: JSON array of {task_id, note_id?, status?, priority?, schedule?: {date, time?}|null}',
414
596
  },
415
597
  { flags: '--note-id <id>', description: 'Restrict task lookup to one exact note id' },
416
598
  WRITE_DURABILITY_OPTION,
@@ -423,10 +605,14 @@ const todoUpdateCommand = {
423
605
  globalOptions: TODO_GLOBAL_OPTIONS,
424
606
  output: {
425
607
  type: 'structured',
426
- summary: 'Mutation result with updated status, target note id, and write receipt',
427
- fields: ['task_id', 'checked', 'updated', 'note_id', ...TODO_WRITE_RECEIPT_FIELDS],
608
+ summary: 'Mutation result with the task\'s new state, cascaded tasks, and write receipt (batch: per-task results and per-note receipts)',
609
+ fields: ['task_id', 'checked', 'priority', 'due_time', 'cascaded_task_ids', 'updated', 'note_id', 'updated_count', 'note_ids', 'tasks.task_id', 'tasks.updated', 'notes.note_id', ...TODO_WRITE_RECEIPT_FIELDS],
428
610
  },
429
- examples: ['dino todo update <taskId> --note-id <noteId> --status completed --format json'],
611
+ examples: [
612
+ 'dino todo update <taskId> --note-id <noteId> --status completed --format json',
613
+ 'dino todo update <taskId> --priority high --due 2026-11-10 --time 09:30 --format json',
614
+ 'dino todo update --updates \'[{"task_id":"<id>","status":"done"},{"task_id":"<id2>","priority":"none"}]\' --format json',
615
+ ],
430
616
  },
431
617
  action: runTodoUpdate,
432
618
  };