aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xexamples/tools/vikunja.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/tools/vikunja.py b/examples/tools/vikunja.py
index 30e36fb..13b4f8c 100755
--- a/examples/tools/vikunja.py
+++ b/examples/tools/vikunja.py
@@ -177,9 +177,22 @@ def do_list(query, project, due_before, all_, id_):
# ponytail: first 50 matches sorted here; with more open tasks than that,
# the soonest due can be missed. Server-side sort_by if it happens.
items = call("tasks_list", **args)["items"]
+ head = ""
+ if not items and query.strip() and f[0] == "done = false":
+ # The model does not retry with all=1 on its own: a task the user
+ # names after closing it ("delete the bread one") must still be found.
+ args["filter"] = " && ".join(f[1:])
+ items = call("tasks_list", **args)["items"]
+ head = "no open tasks match; done ones that do:\n" if items else ""
+ if not items:
+ # Titles are Italian or English, the question may be the other:
+ # "piante" never matches "Water the plants". Let the model pick.
+ args["filter"] = " && ".join([f[0]] + f[2:])
+ items = call("tasks_list", **args)["items"]
+ head = f"no task title contains {query.strip()!r}; open tasks:\n" if items else ""
far = datetime.max.replace(tzinfo=timezone.utc)
items.sort(key=lambda t: (when(t["due_date"]) or far, t["id"]))
- return "\n".join(line(t, ps) for t in items) or "no tasks"
+ return head + "\n".join(line(t, ps) for t in items) or "no tasks"
def do_add(title, description, due, project):