Skip to content

Expose task scheduled / deadline through the CLI and update list_tasks MCP description#163

Merged
ramonski merged 2 commits into
masterfrom
fix-cli-mcp-task-date-coverage
Jun 9, 2026
Merged

Expose task scheduled / deadline through the CLI and update list_tasks MCP description#163
ramonski merged 2 commits into
masterfrom
fix-cli-mcp-task-date-coverage

Conversation

@ramonski

@ramonski ramonski commented Jun 9, 2026

Copy link
Copy Markdown
Member

Discovered while doing the post-feature audit; expanded with the deadline-before-scheduled validation.

CLI + MCP coverage

Backend, API, MCP add_task/update_task, and the React UI already wrote the new scheduled / deadline fields; the CLI was the only seam that didn't, so neither a shell user nor a script could set or change a snooze or deadline from the terminal.

  • kai task add gains --scheduled / --deadline options (YYYY-MM-DD or omit).
  • kai task update gains the same two options. Empty string clears.
  • _format_task_line appends scheduled:DATE / deadline:DATE segments when present.
  • MCP list_tasks description now mentions both fields so the advisor's prompts know they're part of the returned shape.

Reject deadline-before-scheduled

A snoozed-past-its-deadline task is incoherent — the deadline badge would fire before the snooze even surfaces. Four layers (backend, API, CLI, frontend) all accepted any combination of dates without checking.

  • API: TaskCreate and TaskUpdate gain a model_validator that returns 422 when both fields are present in the same payload AND deadline < scheduled. Lex compare on YYYY-MM-DD agrees with chronological order. The PATCH check catches "user sent both at once"; sending one that breaks the invariant against the stored other is validated client-side (the frontend has the merged shape).
  • Frontend: TaskEditForm computes datesOutOfOrder from the edit-state strings, shows a red inline message, and disables Save / Cmd+Enter when violated. i18n added in all four locales.

Tests

Three new API cases in TestKanban: create rejects invalid pair (422), same-day passes (201), update rejects invalid pair (422). Backend round-trip from #159 still passes. 702 tests pass overall; flake8 clean for new code.

Smoke-tested locally end-to-end:

kai task add Acme "snooze me" --scheduled 2099-06-15 --deadline 2099-06-20 --json
# → org file gets :SCHEDULED:/:DEADLINE: heading properties
kai task list  # → shows  scheduled:2099-06-15  deadline:2099-06-20

ramonski added 2 commits June 9, 2026 23:10
…mmands and surface the dates in task list and the MCP list_tasks description

Backend, API, MCP add_task/update_task, and the React UI
already wrote these fields; the CLI was the missing seam
so neither a shell user nor a script could set or change
a snooze / deadline from the terminal. Three small wiring
changes:

- task add gains --scheduled / --deadline options, both
  accepting YYYY-MM-DD or omission for no value.

- task update gains the same two options. The empty-string
  pattern from the rest of update_task still applies: '' clears.

- _format_task_line appends scheduled:DATE / deadline:DATE
  segments when present so the dates show up in plain
  task list output without forcing --json.

- list_tasks MCP description now mentions both fields so
  the advisor knows they are part of the returned shape
  (the data already crossed the wire; this just lights it
  up in the schema description).
… form so the typo can't sneak in

A snoozed-past-its-deadline task is incoherent: the
deadline badge would fire before the snooze even
surfaces. Almost certainly a typo, but the four layers
(backend, API, CLI, frontend) all accepted any
combination of dates without checking.

API: TaskCreate and TaskUpdate both gain a model_validator
that rejects with 422 when both fields are present in the
same payload AND deadline < scheduled. Lex compare on
YYYY-MM-DD agrees with chronological order, so a plain
string compare is enough. The PATCH check only catches
the 'user sent both at once' case; sending one that
breaks the invariant against the stored other is not
validated server-side (the frontend has the merged
shape and gates that locally).

Frontend: TaskEditForm computes datesOutOfOrder from the
two edit-state strings and shows a red inline message
plus disables the Save button when the invariant is
violated. Cmd+Enter and the Save click both short-circuit
through a handleSave gate so accidental commits are
impossible from the form. i18n key added in all four
locales (en/de/es/ru).

Tests: three new API cases in TestKanban -- create
rejects, same-day passes, update rejects -- and the
existing 699 backend tests still pass.
@ramonski ramonski merged commit e6957a6 into master Jun 9, 2026
2 checks passed
@ramonski ramonski deleted the fix-cli-mcp-task-date-coverage branch June 9, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant