Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(tasks): ten pre-built automation templates, one module each
rubenluetke10-beep49e62b2e7921
diff --git a/jarvis/tasks/templates/__init__.py b/jarvis/tasks/templates/__init__.pynew file mode 100644index 0000000000..6329c0eabe--- /dev/null+++ b/jarvis/tasks/templates/__init__.py@@ -0,0 +1,348 @@+"""Automation templates — the pre-built automations catalogue.++An *automation* is a recurring scheduled task (``jarvis/tasks``) whose action+is an agentic brain turn with a plugin allowlist. A *template* is the+ready-made blueprint for one: a name, a category, a default schedule, the+prompt, the plugin grants it needs, and optional user inputs (a watchlist, a+city, a repository path) that are substituted into the prompt when the user+adds it.++Layout — ONE MODULE PER TEMPLATE. Every ``jarvis/tasks/templates/<key>.py``+exports a module-level ``TEMPLATE: AutomationTemplate``; :func:`all_templates`+discovers them with ``pkgutil`` so adding a template never touches a shared+file (ten authors can land ten templates in parallel without a merge+conflict). Modules starting with ``_`` are helpers and are skipped.++Rules for a template:++- ``prompt`` is English. It asks for the reply in the configured output+ language — the one resolver (``jarvis/core/turn_language.py``) decides.+- ``plugin_grants`` name LIVE TOOL NAMES (``gmail``, ``google_calendar``,+ ``search_web``, ``wiki-recall``, ``github`` — the last one is a prefix+ grant that covers every ``github/<tool>``). ``requires`` lists the subset+ the automation cannot work without; the API reports ``ready`` per+ template by checking those against the live tool registry so the card can+ say "needs Gmail" instead of failing at 09:00.+- ``{placeholders}`` in ``prompt`` are template inputs (``inputs``), filled+ from the user's values (or the input's ``default``) when the template is+ instantiated. No other brace syntax — ``build_spec`` escapes the rest.+- ``name``/``description`` carry ``en``/``de``/``es`` — the UI picks the+ active locale and falls back to ``en``.+"""+from __future__ import annotations++import importlib+import pkgutil+import re+from collections.abc import Iterable+from datetime import datetime, timedelta+from typing import Any, Literal++from pydantic import BaseModel, ConfigDict, Field++from jarvis.tasks.schema import (+ AgentAction,+ PluginGrant,+ TaskSpec,+ TriggerEvery,+)++Locale = Literal["en", "de", "es"]+LOCALES: tuple[Locale, ...] = ("en", "de", "es")++TemplateCategory = Literal["news", "productivity", "finance", "research", "developer"]+#: Display order of the catalogue sections (the UI groups cards by this).+CATEGORIES: tuple[TemplateCategory, ...] = (+ "news", "productivity", "finance", "research", "developer",+)++#: Tag that marks a task as "created from template <key>" — the UI uses it to+#: show the template as installed and to pair a task with its card.+TEMPLATE_TAG_PREFIX = "template:"+++class LocalizedText(BaseModel):+ """A short UI string in the three product locales (``en`` is mandatory)."""+ model_config = ConfigDict(frozen=True, extra="forbid")+ en: str = Field(min_length=1, max_length=512)+ de: str = Field(default="", max_length=512)+ es: str = Field(default="", max_length=512)++ def for_locale(self, locale: str) -> str:+ return getattr(self, locale, "") or self.en+++class TemplateInput(BaseModel):+ """A value the user may fill in when adding the template (a watchlist, a+ city, a repo path). ``key`` is the ``{placeholder}`` used in the prompt."""+ model_config = ConfigDict(frozen=True, extra="forbid")+ key: str = Field(min_length=1, max_length=32, pattern=r"^[a-z][a-z0-9_]*$")+ label: LocalizedText+ placeholder: LocalizedText | None = None+ default: str = Field(default="", max_length=2048)+ required: bool = False+++class TemplateSchedule(BaseModel):+ """Default schedule, expressed the way the UI shows it ("Daily at 07:30",+ "Mondays at 09:00"), not as a cron expression. Mapped onto the+ ``every`` trigger by :func:`schedule_to_trigger`.++ ``weekday`` follows ``datetime.weekday()``: 0 = Monday … 6 = Sunday.+ """+ model_config = ConfigDict(frozen=True, extra="forbid")+ kind: Literal["hourly", "daily", "weekly"] = "daily"+ time: str = Field(default="08:00", pattern=r"^([01]\d|2[0-3]):[0-5]\d$")+ weekday: int = Field(default=0, ge=0, le=6)+++class AutomationTemplate(BaseModel):+ model_config = ConfigDict(frozen=True, extra="forbid")++ key: str = Field(min_length=1, max_length=48, pattern=r"^[a-z][a-z0-9_]*$")+ category: TemplateCategory+ #: A lucide icon name the UI resolves (``sun``, ``mail``, ``dollar-sign``).+ icon: str = Field(default="sparkles", max_length=48)+ name: LocalizedText+ description: LocalizedText+ schedule: TemplateSchedule = Field(default_factory=TemplateSchedule)+ prompt: str = Field(min_length=1, max_length=16_384)+ plugin_grants: tuple[PluginGrant, ...] = Field(default_factory=tuple)+ #: Tool names (or ``prefix`` grants like ``github``) the automation cannot+ #: run without. Empty = works on any install (brain only).+ requires: tuple[str, ...] = Field(default_factory=tuple)+ inputs: tuple[TemplateInput, ...] = Field(default_factory=tuple)+ model_tier: Literal["fast", "deep", "auto"] = "auto"+ tags: tuple[str, ...] = Field(default_factory=tuple)++ @property+ def tag(self) -> str:+ return f"{TEMPLATE_TAG_PREFIX}{self.key}"++ def to_api(self, locale: str, *, live_tools: Iterable[str] | None = None) -> dict[str, Any]:+ """Flat dict for ``GET /api/tasks/templates`` — localized, with the+ readiness verdict so the card can say what is missing."""+ missing = missing_requirements(self.requires, live_tools) if live_tools is not None else []+ return {+ "key": self.key,+ "category": self.category,+ "icon": self.icon,+ "name": self.name.for_locale(locale),+ "description": self.description.for_locale(locale),+ "schedule": self.schedule.model_dump(),+ "schedule_label": schedule_label(self.schedule, locale),+ "plugin_grants": [g.model_dump() for g in self.plugin_grants],+ "requires": list(self.requires),+ "missing": missing,+ "ready": not missing,+ "inputs": [+ {+ "key": i.key,+ "label": i.label.for_locale(locale),+ "placeholder": i.placeholder.for_locale(locale) if i.placeholder else "",+ "default": i.default,+ "required": i.required,+ }+ for i in self.inputs+ ],+ "model_tier": self.model_tier,+ "tags": list(self.tags),+ "prompt": self.prompt,+ }+++# ---------------------------------------------------------------------+# Discovery+# ---------------------------------------------------------------------++_cache: dict[str, AutomationTemplate] | None = None+++def all_templates(*, refresh: bool = False) -> dict[str, AutomationTemplate]:+ """Every template module in this package, keyed by ``template.key``,+ ordered by category (catalogue order) and then by key."""+ global _cache+ if _cache is not None and not refresh:+ return _cache+ found: dict[str, AutomationTemplate] = {}+ for info in pkgutil.iter_modules(__path__):+ if info.name.startswith("_"):+ continue+ module = importlib.import_module(f"{__name__}.{info.name}")+ template = getattr(module, "TEMPLATE", None)+ if not isinstance(template, AutomationTemplate):+ continue+ if template.key in found:+ raise RuntimeError(+ f"duplicate automation template key {template.key!r} "+ f"({info.name}.py)"+ )+ found[template.key] = template+ order = {c: i for i, c in enumerate(CATEGORIES)}+ _cache = dict(+ sorted(found.items(), key=lambda kv: (order[kv[1].category], kv[0]))+ )+ return _cache+++def get_template(key: str) -> AutomationTemplate | None:+ return all_templates().get(key)+++# ---------------------------------------------------------------------+# Readiness+# ---------------------------------------------------------------------++def grant_matches(grant: str, tool_name: str) -> bool:+ """A grant names a tool exactly, or is a prefix grant for a bridged+ plugin whose tools are namespaced ``<plugin>/<tool>`` (``github`` covers+ ``github/list_issues``)."""+ return tool_name == grant or tool_name.startswith(grant + "/")+++def missing_requirements(+ requires: Iterable[str], live_tools: Iterable[str] | None,+) -> list[str]:+ live = list(live_tools or ())+ return [+ req for req in requires+ if not any(grant_matches(req, name) for name in live)+ ]+++# ---------------------------------------------------------------------+# Schedule → trigger+# ---------------------------------------------------------------------++def _parse_hhmm(value: str) -> tuple[int, int]:+ hh, mm = value.split(":")+ return int(hh), int(mm)+++def next_occurrence(schedule: TemplateSchedule, now: datetime) -> datetime:+ """The first wall-clock moment strictly after ``now`` that matches the+ schedule (local time, naive — the scheduler treats ISO without a zone as+ the system zone)."""+ if schedule.kind == "hourly":+ return (now + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)+ hh, mm = _parse_hhmm(schedule.time)+ candidate = now.replace(hour=hh, minute=mm, second=0, microsecond=0)+ if schedule.kind == "daily":+ if candidate <= now:+ candidate += timedelta(days=1)+ return candidate+ # weekly+ days_ahead = (schedule.weekday - now.weekday()) % 7+ candidate += timedelta(days=days_ahead)+ if candidate <= now:+ candidate += timedelta(days=7)+ return candidate+++def schedule_to_trigger(schedule: TemplateSchedule, now: datetime | None = None) -> TriggerEvery:+ now = now or datetime.now()+ interval = {"hourly": 3600, "daily": 86_400, "weekly": 7 * 86_400}[schedule.kind]+ first = next_occurrence(schedule, now)+ return TriggerEvery(+ interval_seconds=float(interval),+ start_at=first.isoformat(timespec="seconds"),+ )+++_WEEKDAY_NAMES: dict[str, tuple[str, ...]] = {+ "en": ("Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays", "Sundays"),+ "de": ( # i18n-allow+ "Montags", "Dienstags", "Mittwochs", "Donnerstags", "Freitags", "Samstags", "Sonntags",+ ),+ "es": ("Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábados", "Domingos"),+}+_SCHEDULE_WORDS: dict[str, dict[str, str]] = {+ "en": {"hourly": "Every hour", "daily": "Daily at {time}", "weekly": "{day} at {time}"},+ "de": { # i18n-allow+ "hourly": "Stündlich", "daily": "Täglich um {time}", "weekly": "{day} um {time}",+ },+ "es": {"hourly": "Cada hora", "daily": "Diario a las {time}", "weekly": "{day} a las {time}"},+}+++def schedule_label(schedule: TemplateSchedule, locale: str = "en") -> str:+ """"Daily at 07:30" / "Täglich um 07:30" / "Mondays at 09:00"."""+ loc = locale if locale in _SCHEDULE_WORDS else "en"+ words = _SCHEDULE_WORDS[loc]+ if schedule.kind == "hourly":+ return words["hourly"]+ if schedule.kind == "daily":+ return words["daily"].format(time=schedule.time)+ day = _WEEKDAY_NAMES[loc][schedule.weekday]+ return words["weekly"].format(day=day, time=schedule.time)+++# ---------------------------------------------------------------------+# Instantiate+# ---------------------------------------------------------------------++_PLACEHOLDER = re.compile(r"\{([a-z][a-z0-9_]*)\}")+++def render_prompt(template: AutomationTemplate, inputs: dict[str, str] | None) -> str:+ """Substitute ``{input_key}`` placeholders; unknown braces stay literal."""+ values = {+ i.key: ((inputs or {}).get(i.key) or "").strip() or i.default+ for i in template.inputs+ }++ def _sub(match: re.Match[str]) -> str:+ key = match.group(1)+ return values.get(key, match.group(0))++ return _PLACEHOLDER.sub(_sub, template.prompt)+++def build_spec(+ template: AutomationTemplate,+ *,+ inputs: dict[str, str] | None = None,+ schedule: TemplateSchedule | None = None,+ title: str | None = None,+ locale: str = "en",+ now: datetime | None = None,+) -> TaskSpec:+ """The TaskSpec a template turns into when the user adds it."""+ missing_inputs = [+ i.key for i in template.inputs+ if i.required and not (((inputs or {}).get(i.key) or "").strip() or i.default)+ ]+ if missing_inputs:+ raise ValueError(f"missing required inputs: {', '.join(missing_inputs)}")+ sched = schedule or template.schedule+ return TaskSpec(+ title=(title or "").strip() or template.name.for_locale(locale),+ trigger=schedule_to_trigger(sched, now),+ action=AgentAction(+ prompt=render_prompt(template, inputs),+ plugin_grants=template.plugin_grants,+ model_tier=template.model_tier,+ ),+ created_by="template",+ tags=(template.tag, *template.tags),+ )+++__all__ = [+ "CATEGORIES",+ "LOCALES",+ "TEMPLATE_TAG_PREFIX",+ "AutomationTemplate",+ "LocalizedText",+ "TemplateInput",+ "TemplateSchedule",+ "all_templates",+ "build_spec",+ "get_template",+ "grant_matches",+ "missing_requirements",+ "next_occurrence",+ "render_prompt",+ "schedule_label",+ "schedule_to_trigger",+]diff --git a/jarvis/tasks/templates/ai_news_digest.py b/jarvis/tasks/templates/ai_news_digest.pynew file mode 100644index 0000000000..7bbeff450a--- /dev/null+++ b/jarvis/tasks/templates/ai_news_digest.py@@ -0,0 +1,91 @@+"""AI News Digest — model releases, research, and funding that actually matter.++A daily ``search_web`` sweep over the last 24–48 hours, de-duplicated and+stripped of hype, delivered as at most six one-liners with a "why it+matters" and a source name.+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling today's AI news digest. Focus areas: {focus}.++This is a written, scheduled digest — not a spoken reply. Any "answer in one \+or two spoken sentences / never name a source" note attached to search \+results does not apply here; the format below does.++Step 1 — gather. Call the `search_web` tool at least three times with \+`max_results` 8, each call with 2–3 different query phrasings in `queries`, \+covering separately: (a) new model releases and open-source model launches, \+(b) notable AI research papers or technical breakthroughs, (c) AI funding \+rounds, acquisitions, and major company announcements. Put a recency cue in \+every query ("this week", "today", the current month and year) so results \+come from the last 24–48 hours. Results carry only a title, a snippet, and a \+URL — judge recency from the text itself (an explicit date, "today", "this \+week", a version or event that is plainly new). Discard anything that reads \+as older than 48 hours or whose timing you cannot tell.++Step 2 — filter. Merge duplicates (the same story from several outlets \+counts once). Drop hype, opinion pieces, listicles, product marketing, minor \+version bumps, and anything you cannot ground in a search result. Keep \+only items a practitioner would want to know about. If fewer than six items \+survive, report fewer — never pad.++Step 3 — write. Return at most 6 items. For each item, exactly three lines:+- Line 1: one factual sentence stating what happened (who, what, when).+- Line 2: "Why it matters:" followed by at most 15 words.+- Line 3: "Source:" followed by the outlet or organisation name (no URL).++Separate items with a blank line. Rules: write in the configured output \+language (translate the two labels accordingly); no headline, no preamble, \+no closing remark; no emojis; no bold, asterisks, or markdown formatting; \+never invent names, numbers, or dates; state only what the search results \+support. If the searches return nothing usable, reply with one sentence \+saying that no significant AI news was found for the period.+"""++TEMPLATE = AutomationTemplate(+ key="ai_news_digest",+ category="news",+ icon="bot",+ name=LocalizedText(+ en="AI News Digest",+ de="KI-News-Digest",+ es="Resumen de noticias de IA",+ ),+ description=LocalizedText(+ en="Model releases, research, and funding that actually matter.",+ de="Modell-Releases, Forschung und Finanzierungen, die wirklich zählen.",+ es="Lanzamientos de modelos, investigación y financiación que realmente importan.",+ ),+ schedule=TemplateSchedule(kind="daily", time="08:00"),+ prompt=_PROMPT,+ plugin_grants=(PluginGrant(plugin_id="search_web", scope="read"),),+ requires=("search_web",),+ inputs=(+ TemplateInput(+ key="focus",+ label=LocalizedText(+ en="Focus areas",+ de="Schwerpunkte",+ es="Áreas de enfoque",+ ),+ placeholder=LocalizedText(+ en="e.g. open-source models, agents, robotics",+ de="z. B. Open-Source-Modelle, Agenten, Robotik",+ es="p. ej. modelos de código abierto, agentes, robótica",+ ),+ default="model releases, open-source models, AI research, AI funding",+ required=False,+ ),+ ),+ model_tier="auto",+ tags=("ai", "news", "daily"),+)diff --git a/jarvis/tasks/templates/daily_planner.py b/jarvis/tasks/templates/daily_planner.pynew file mode 100644index 0000000000..24c9732935--- /dev/null+++ b/jarvis/tasks/templates/daily_planner.py@@ -0,0 +1,103 @@+"""Daily Planner — a realistic plan for today: the meetings, the free focus+blocks between them, and three quick wins."""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling the user's Daily Planner for today. The user's work hours \+are {work_hours} (local time).++Procedure:+1. Call `google_calendar` with action `list_events`, `time_min` = today at \+00:00 and `time_max` = today at 23:59 as RFC3339 datetimes in the local time \+zone (e.g. 2026-08-24T00:00:00+02:00), `max_results` 50. Use the current \+date from your context; never guess a different day.+2. From the returned events keep only those on today's date. Sort them by \+start time. All-day events count as context, not as meetings.+3. Compute the free blocks: the gaps between the timed events inside the \+work hours {work_hours}. Merge gaps shorter than 30 minutes into the \+neighbouring meeting; keep at most the 3 longest gaps.+4. Call `gmail` with action `list_messages`, `query` "is:unread \+newer_than:2d", `max_results` 15. Read only subjects and senders. Note \+anything that clearly has to be handled today (a deadline, a direct \+question, a confirmation someone is waiting for). Do not open or reply to \+messages.++Output rules:+- Write in the configured output language. At most 12 lines in total. No \+preamble, no closing remarks, no emojis, no markdown headings or tables.+- Line block 1 — meetings: one line per timed meeting, "HH:MM–HH:MM Title". \+If there are no timed events today, write exactly one line saying the \+calendar is empty today.+- Line block 2 — focus blocks: 1 to 3 lines, "HH:MM–HH:MM Focus: <one \+concrete suggestion>". Base the suggestion on the mail findings or the \+meetings (prepare for X, answer Y, finish Z); when neither gives a hint, \+suggest deep work on the day's most important project. If the calendar is \+empty, the whole work window is one focus block.+- Line block 3 — quick wins: exactly 3 lines, each starting with "Quick win:" \+followed by one small task of 15 minutes or less, taken from the unread \+mail when possible (name the sender or subject), otherwise a sensible \+generic one (confirm tomorrow's meetings, clear the inbox to zero, prepare \+the next agenda).+- Use only facts the tools returned. Never invent events, senders or \+deadlines. If a tool call fails, say so in one line and continue with the \+rest.+"""++TEMPLATE = AutomationTemplate(+ key="daily_planner",+ category="productivity",+ icon="calendar-check",+ name=LocalizedText(+ en="Daily Planner",+ de="Tagesplaner", # i18n-allow+ es="Planificador diario",+ ),+ description=LocalizedText(+ en=(+ "A realistic plan for today: your meetings, the free focus blocks "+ "between them, and three quick wins."+ ),+ de=( # i18n-allow+ "Ein realistischer Plan für heute: deine Termine, die freien "+ "Fokusblöcke dazwischen und drei schnelle Erfolge."+ ),+ es=(+ "Un plan realista para hoy: tus reuniones, los bloques de "+ "concentración libres entre ellas y tres logros rápidos."+ ),+ ),+ schedule=TemplateSchedule(kind="daily", time="08:30"),+ prompt=_PROMPT,+ plugin_grants=(+ PluginGrant(plugin_id="google_calendar", scope="read"),+ PluginGrant(plugin_id="gmail", scope="read"),+ ),+ requires=("google_calendar",),+ inputs=(+ TemplateInput(+ key="work_hours",+ label=LocalizedText(+ en="Work hours",+ de="Arbeitszeit", # i18n-allow+ es="Horario laboral",+ ),+ placeholder=LocalizedText(+ en="09:00-18:00",+ de="09:00-18:00",+ es="09:00-18:00",+ ),+ default="09:00-18:00",+ required=False,+ ),+ ),+ model_tier="auto",+ tags=("productivity", "calendar", "mail", "daily"),+)diff --git a/jarvis/tasks/templates/inbox_brief.py b/jarvis/tasks/templates/inbox_brief.pynew file mode 100644index 0000000000..fcde71df2b--- /dev/null+++ b/jarvis/tasks/templates/inbox_brief.py@@ -0,0 +1,97 @@+"""``inbox_brief`` — unread mail sorted by urgency, once a day.++The automation only READS mail: the ``gmail`` grant stays at ``read`` scope+because ``list_messages`` / ``get_message`` are ``safe``-tier actions+(``jarvis/plugins/tool/gmail_rest.py``), so an unattended run never hits the+approval gate and never sends anything.+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling the user's daily inbox brief. Use the `gmail` tool — you \+never send, modify or delete anything.++Steps:+1. Call `gmail` with action `list_messages`, query \+`is:unread newer_than:{lookback_hours}h in:inbox -category:promotions \+-category:social` and max_results 15. The result contains message ids only — \+no subjects, no senders — so you cannot judge anything from it yet.+2. Call `gmail` with action `get_message` for EVERY id returned (one call per \+id). Only then do you know sender, subject, date and a short body.+3. Skip newsletters, marketing, social notifications, automated receipts and \+system alerts — unless one is clearly urgent (payment failed, account locked, \+security warning, deadline today). Keep mail where a person wants something \+from the user: a question, a request, a deadline, an invoice, a confirmation.+4. Sort what remains into three groups, most urgent first:+ - "Needs reply today": a person is waiting for an answer, or something is due today.+ - "FYI": worth knowing, no action needed.+ - "Can wait": low priority, can be handled later.++Output rules — follow them exactly:+- Write in the configured output language.+- No emojis, no preamble, no closing remark, no markdown headings.+- Three short group labels (translate them), each followed by its items.+- One line per mail: the sender's name (person or company, never the address), \+then a comma, then ONE clause saying what they want or what it is about. \+Mention a deadline or amount only when the mail states it.+- Maximum 8 lines in total including the group labels; drop the least \+important items first, and drop an empty group entirely.+- Only report what the tool actually returned. Never invent senders, subjects \+or deadlines. Do not describe how you worked.+- If there is no unread or recent mail worth mentioning, reply with exactly \+one sentence saying the inbox is clear.+- If the `gmail` tool reports that Gmail is not connected, say so in one \+sentence and stop.+"""++TEMPLATE = AutomationTemplate(+ key="inbox_brief",+ category="productivity",+ icon="mail",+ name=LocalizedText(+ en="Inbox Brief",+ de="Posteingang-Briefing", # i18n-allow+ es="Resumen de bandeja",+ ),+ description=LocalizedText(+ en=(+ "Unread mail sorted by urgency, with who wants what, and which "+ "ones need a reply today."+ ),+ de=( # i18n-allow+ "Ungelesene Mails nach Dringlichkeit sortiert: wer will was, und "+ "welche brauchen heute eine Antwort."+ ),+ es=(+ "Correo sin leer ordenado por urgencia: quién quiere qué y cuáles "+ "necesitan respuesta hoy."+ ),+ ),+ schedule=TemplateSchedule(kind="daily", time="09:00"),+ prompt=_PROMPT,+ plugin_grants=(PluginGrant(plugin_id="gmail", scope="read"),),+ requires=("gmail",),+ inputs=(+ TemplateInput(+ key="lookback_hours",+ label=LocalizedText(+ en="Look back (hours)",+ de="Zeitraum (Stunden)", # i18n-allow+ es="Periodo (horas)",+ ),+ placeholder=LocalizedText(en="24", de="24", es="24"),+ default="24",+ required=False,+ ),+ ),+ model_tier="auto",+ tags=("mail", "daily"),+)diff --git a/jarvis/tasks/templates/memory_recap.py b/jarvis/tasks/templates/memory_recap.pynew file mode 100644index 0000000000..89b04c50f0--- /dev/null+++ b/jarvis/tasks/templates/memory_recap.py@@ -0,0 +1,105 @@+"""Memory Recap — a weekly look at what Jarvis learned about the user and+their projects, drawn from the local wiki/memory only.++This is the one catalogue template that works fully offline: every grant+is a read-only local memory tool, no external key or network is needed.+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling the weekly Memory Recap: what Jarvis learned about the \+user and their projects during the last 7 days, and the open threads worth \+picking up. Everything comes from the user's LOCAL wiki/memory — do not use \+the web, and never fill gaps from general knowledge.++Procedure:+1. Call `wiki-list` once to see every page that actually exists (path, size, \+title). The listing carries no modification dates. A page flagged as a \+system file is the vault's editing contract (`schema.md`) — never treat its \+example layout as content. Exception: a self-description page such as \+`memory.md` ("My Memory") may be flagged too, yet it holds a "Recently \+updated" list and live status — read it FIRST with `wiki-page-read` when it \+exists and use its list as the shortlist of pages that changed recently.+2. Work out today's date and the dates of the last 7 days from the \+timestamp context you have. Run `wiki-recall` with 2-3 of those dates as \+plain ISO strings (for example "2026-08-24") — the vault's activity log \+records dated entries and page frontmatter carries `updated:` dates, so the \+hits reveal which pages and events belong to this week. The log page itself \+can be too large to read; rely on the recall snippets for it.+3. Call `wiki-page-read` on the pages most likely to have changed this week \+(at most 8: the "Recently updated" shortlist, then hits from step 2). On \+each page look at frontmatter `updated:`, facts marked "(as of <date>)", \+"Current Status" and "Open Threads" sections — those are the source for the \+themes and the open items.+4. Then run `wiki-recall` with 2-3 short keyword queries built from the \+names and projects you found, plus one for open items (e.g. "open threads", \+"blocked", "next steps"). Use `ultrawiki-search` for the same queries when \+it is available and returns hits; ignore it when it reports being disabled. \+Follow at most 3 promising hits with `wiki-page-read`.+5. Keep only facts that appear in the tool output. Never invent people, \+projects, dates or decisions. If you cannot tell whether a note is from this \+week, treat it as recent background rather than claiming a date.++Output rules:+- Write in the configured output language.+- Cluster the findings into 3 to 5 themes (projects, people, decisions, \+habits, tools). One theme per block: a heading line with the theme name, \+then one line with what was learned (concrete names and facts from the \+notes), then one line beginning with "Open:" that names ONE open question or \+next step for that theme. Never leave the "Open:" line empty; when the notes \+contain no open item, propose the most natural next step for that theme.+- At most 12 lines in total. Short, specific sentences.+- No preamble, no closing remarks, no emojis, no markdown tables.+- When `wiki-list` reports that the vault is empty or does not exist, or \+when no page carries any usable content, reply with exactly one line saying \+plainly that the memory is empty and there is nothing to recap yet. Do not \+add advice.+- If a memory tool itself fails, say so in one line instead of guessing.+"""++TEMPLATE = AutomationTemplate(+ key="memory_recap",+ category="research",+ icon="brain",+ name=LocalizedText(+ en="Memory Recap",+ de="Gedächtnis-Rückblick", # i18n-allow+ es="Resumen de memoria",+ ),+ description=LocalizedText(+ en=(+ "What Jarvis learned about you and your projects this week, and "+ "the open threads worth picking up. Runs fully offline from your "+ "local memory — no external key needed."+ ),+ de=( # i18n-allow+ "Was Jarvis diese Woche über dich und deine Projekte gelernt hat, "+ "und welche offenen Fäden sich lohnen. Läuft komplett offline aus "+ "deinem lokalen Gedächtnis — kein externer Schlüssel nötig."+ ),+ es=(+ "Lo que Jarvis aprendió esta semana sobre ti y tus proyectos, y los "+ "hilos abiertos que vale la pena retomar. Funciona totalmente sin "+ "conexión desde tu memoria local — no necesita ninguna clave externa."+ ),+ ),+ schedule=TemplateSchedule(kind="weekly", weekday=6, time="18:00"),+ prompt=_PROMPT,+ plugin_grants=(+ PluginGrant(plugin_id="wiki-recall", scope="read"),+ PluginGrant(plugin_id="wiki-list", scope="read"),+ PluginGrant(plugin_id="wiki-page-read", scope="read"),+ PluginGrant(plugin_id="ultrawiki-search", scope="read"),+ ),+ requires=("wiki-recall",),+ inputs=(),+ model_tier="auto",+ tags=("research", "memory", "offline", "weekly"),+)diff --git a/jarvis/tasks/templates/morning_brief.py b/jarvis/tasks/templates/morning_brief.pynew file mode 100644index 0000000000..a76d6f72e6--- /dev/null+++ b/jarvis/tasks/templates/morning_brief.py@@ -0,0 +1,95 @@+"""Morning Brief — headlines, market mood and (optionally) the weather.++Runs once a day, early. The prompt forces several ``search_web`` calls so the+brief is grounded in live results rather than the brain's memory: one call+per interest area, one for the market mood, and one weather lookup when the+user configured a city (``search_web`` routes a query naming a location plus+a weather word to Open-Meteo). Without a city the brief simply has no+weather line — it must never guess where the user lives.+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling a morning brief for {interests}. City for the weather: "{city}".+Today's date is in your context; every fact below MUST come from tool output.++Gather the material with the `search_web` tool — at least three separate calls:+1. One call PER interest area listed above (e.g. "top {interests} headlines today").+ Use the `queries` parameter with 2-3 phrasings in one call to get better coverage.+2. One call for the market mood: "stock market today S&P 500 DAX Nasdaq".+3. If, and only if, the city above is NOT empty: one call whose query is+ "weather <city> today" — the tool answers weather queries directly when the+ query names a location. If the city is empty, skip the weather entirely;+ never pick or guess a city.++Then write the brief. Rules:+- 5 to 7 bullets maximum, most important first. Each bullet is one specific,+ concrete finding (who, what, number, date) and ends with the source name in+ parentheses, e.g. "(Reuters)". The weather, if available, is one of those+ bullets: current conditions and today's high/low.+- After the bullets, ONE sentence starting with "What matters today:" (translated+ into the output language) that connects the most important items.+- Only report what the tool results actually say. If a search returned nothing+ useful for a topic, say so in one short bullet instead of inventing news.+- Do NOT mention that you searched, do NOT describe your process, no preamble,+ no closing remark, no emojis, no markdown headings.+- Write the whole brief in the configured output language.+"""++TEMPLATE = AutomationTemplate(+ key="morning_brief",+ category="news",+ icon="sun",+ name=LocalizedText(+ en="Morning Brief",+ de="Morgen-Briefing", # i18n-allow+ es="Resumen matutino",+ ),+ description=LocalizedText(+ en="Start the day with headlines, market moves, and your weather.",+ de="Starte den Tag mit Schlagzeilen, Börsenlage und deinem Wetter.", # i18n-allow+ es="Empieza el día con titulares, la bolsa y el tiempo en tu ciudad.",+ ),+ schedule=TemplateSchedule(kind="daily", time="07:30"),+ prompt=_PROMPT,+ plugin_grants=(PluginGrant(plugin_id="search_web", scope="read"),),+ requires=("search_web",),+ inputs=(+ TemplateInput(+ key="city",+ label=LocalizedText(+ en="City for the weather",+ de="Stadt für das Wetter", # i18n-allow+ es="Ciudad para el tiempo",+ ),+ placeholder=LocalizedText(+ en="e.g. Berlin (leave empty to skip weather)",+ de="z. B. Berlin (leer = kein Wetter)", # i18n-allow+ es="p. ej. Madrid (vacío = sin tiempo)",+ ),+ default="",+ required=False,+ ),+ TemplateInput(+ key="interests",+ label=LocalizedText(en="Topics", de="Themen", es="Temas"), # i18n-allow+ placeholder=LocalizedText(+ en="world news, technology, business",+ de="Weltnachrichten, Technik, Wirtschaft", # i18n-allow+ es="noticias del mundo, tecnología, negocios",+ ),+ default="world news, technology, business",+ required=False,+ ),+ ),+ model_tier="auto",+ tags=("news", "weather", "markets"),+)diff --git a/jarvis/tasks/templates/repo_pulse.py b/jarvis/tasks/templates/repo_pulse.pynew file mode 100644index 0000000000..2f2442e198--- /dev/null+++ b/jarvis/tasks/templates/repo_pulse.py@@ -0,0 +1,96 @@+"""Repo Pulse — a daily developer briefing for one GitHub repository:+yesterday's commits, the open pull requests waiting on the user, and the+issues opened since the last run."""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling the daily Repo Pulse for the GitHub repository `{repo}` \+(format owner/name; split it at the slash into the `owner` and `repo` tool \+arguments).++Procedure — use ONLY the GitHub tools, never memory or guesses. Compute the \+cutoff as now minus 24 hours in ISO 8601 (UTC) and pass it as `since`:+1. Commits: `github/list_commits` with `since` = cutoff, `perPage` 30, \+`fields` ["sha", "commit", "author"]. Note the count, the authors and the \+first line of each message.+2. Pull requests: `github/list_pull_requests` with `state` "open", `sort` \+"updated", `direction` "desc", `perPage` 20, `fields` ["number", "title", \+"draft", "user", "requested_reviewers", "mergeable_state", "created_at"]. \+Flag a PR when it has requested reviewers, is a draft, or has \+`mergeable_state` "dirty" or "blocked". For at most 3 flagged PRs you may \+call `github/pull_request_read` with `method` "get_check_runs" to name the \+failing checks.+3. Issues: `github/list_issues` with `state` "OPEN", `since` = cutoff, \+`orderBy` "CREATED_AT", `direction` "DESC", `perPage` 20, `fields` \+["number", "title", "user", "labels", "created_at"]. Keep only issues whose \+`created_at` is after the cutoff.++Output rules:+- Write in the configured output language.+- Exactly three short sections in this order: commits, pull requests, \+issues. Each starts with a one-line heading, followed by at most 3 \+one-line bullets naming the concrete item (short SHA or #number, message or \+title, author) — most important first.+- When a section has nothing in the window, write exactly one line saying \+so under its heading — never pad with older activity.+- At most 12 lines in total. No preamble, no closing remarks, no emojis, no \+markdown tables.+- Only state facts that appear in the tool results. If a tool call fails, \+say so in one line for that section instead of guessing.+"""++TEMPLATE = AutomationTemplate(+ key="repo_pulse",+ category="developer",+ icon="git-branch",+ name=LocalizedText(+ en="Repo Pulse",+ de="Repo-Puls", # i18n-allow+ es="Pulso del repositorio",+ ),+ description=LocalizedText(+ en=(+ "Yesterday's commits, open pull requests waiting on you, and new "+ "issues for one repository."+ ),+ de=( # i18n-allow+ "Die Commits von gestern, offene Pull Requests, die auf dich "+ "warten, und neue Issues für ein Repository."+ ),+ es=(+ "Los commits de ayer, los pull requests abiertos que te esperan y "+ "los issues nuevos de un repositorio."+ ),+ ),+ schedule=TemplateSchedule(kind="daily", time="09:00"),+ prompt=_PROMPT,+ # A prefix grant: covers every bridged ``github/<tool>``.+ plugin_grants=(PluginGrant(plugin_id="github", scope="read"),),+ requires=("github",),+ inputs=(+ TemplateInput(+ key="repo",+ label=LocalizedText(+ en="Repository",+ de="Repository", # i18n-allow+ es="Repositorio",+ ),+ placeholder=LocalizedText(+ en="owner/name",+ de="owner/name", # i18n-allow+ es="owner/name",+ ),+ required=True,+ ),+ ),+ model_tier="auto",+ tags=("developer", "github", "daily"),+)diff --git a/jarvis/tasks/templates/stock_tracker.py b/jarvis/tasks/templates/stock_tracker.pynew file mode 100644index 0000000000..88524d49ca--- /dev/null+++ b/jarvis/tasks/templates/stock_tracker.py@@ -0,0 +1,99 @@+"""Daily Stock Tracker — prices, sentiment, and catalysts for a watchlist.++Two ``search_web`` calls per ticker (one for the latest price and day move,+one for news), then one line per ticker with the approximate last price as+the source reported it, the day move, and one catalyst with its source+name. Numbers are never invented: a ticker whose price the searches did not+surface is reported as "price not found".+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling today's stock tracker for this watchlist: {watchlist}.++Step 1 — gather, per ticker. For EACH ticker in the watchlist call the \+`search_web` tool exactly twice, with `max_results` 8. Call A (price): \+`query` "<TICKER> stock price today" plus two variants in `queries` such as \+"<TICKER> share price change today" and "<TICKER> stock quote <current \+date>". Call B (news): `query` "<TICKER> stock news today" plus variants \+such as "<TICKER> earnings analyst news this week" and "why is <TICKER> \+stock up or down today". Put a recency cue in every query ("today", the \+current date). Do not skip a ticker and do not stop after the first ticker; \+two tickers means four calls.++Step 2 — extract. The tool returns RAW web hits (title, snippet, url) — \+read figures only from that text. For each ticker take the most recent price \+figure and the day's percentage or point move exactly as a snippet or title \+states them, and name the outlet from the hit's title or domain. Prefer the \+hit with the newest date cue; ignore hits with no date or older than two \+trading days. If no hit states a concrete price, the price is unknown — \+never estimate it from memory or from an older figure. Pick ONE catalyst: \+the single most relevant news item explaining the move or likely to move \+the stock next (earnings, guidance, product, regulation, analyst action, \+macro event).++Step 3 — write. Return exactly one line per ticker, in watchlist order, in \+this shape:+<TICKER> — approx. <price> <currency>, <day move> (per <source name>) — \+<one catalyst sentence> (<source name>)+If the price could not be established, write "price not found" in place of \+the price and move, and still give the catalyst if one was found. If no \+news was found either, say "no notable news found" in place of the catalyst.++Then end with ONE sentence describing the overall market mood for the day \+based only on what the searches returned.++Rules: write in the configured output language (translate the fixed phrases \+accordingly, but keep ticker symbols as they are); no headline, no preamble, \+no closing remark; no emojis; no bold, asterisks, or markdown formatting; \+never invent or round-trip numbers from memory — every figure must come from \+a search result; this is information only, so give no buy, sell, or hold \+advice and no predictions of your own.+"""++TEMPLATE = AutomationTemplate(+ key="stock_tracker",+ category="finance",+ icon="dollar-sign",+ name=LocalizedText(+ en="Daily Stock Tracker",+ de="Täglicher Aktien-Tracker",+ es="Seguimiento diario de acciones",+ ),+ description=LocalizedText(+ en="Prices, sentiment, and catalysts for your watchlist every day.",+ de="Kurse, Stimmung und Kurstreiber für deine Watchlist, jeden Tag.",+ es="Precios, sentimiento y catalizadores de tu lista de seguimiento cada día.",+ ),+ schedule=TemplateSchedule(kind="daily", time="14:00"),+ prompt=_PROMPT,+ plugin_grants=(PluginGrant(plugin_id="search_web", scope="read"),),+ requires=("search_web",),+ inputs=(+ TemplateInput(+ key="watchlist",+ label=LocalizedText(+ en="Watchlist",+ de="Watchlist",+ es="Lista de seguimiento",+ ),+ placeholder=LocalizedText(+ en="NVDA, AAPL, TSLA",+ de="NVDA, AAPL, TSLA",+ es="NVDA, AAPL, TSLA",+ ),+ default="",+ required=True,+ ),+ ),+ model_tier="auto",+ tags=("stocks", "finance", "daily"),+)diff --git a/jarvis/tasks/templates/task_extractor.py b/jarvis/tasks/templates/task_extractor.pynew file mode 100644index 0000000000..356e7cad00--- /dev/null+++ b/jarvis/tasks/templates/task_extractor.py@@ -0,0 +1,117 @@+"""Task Extractor — the action items hiding in today's mail, remembered.++Runs once a day, late afternoon. The prompt grounds everything in the Gmail+tool: one ``list_messages`` search over the lookback window (newsletters and+notifications excluded by query), then ``get_message`` for each hit, because+``list_messages`` only returns ids. Every action item must be traceable to a+mail the tool actually returned. The list is then persisted through+``wiki-ingest`` (a ``write`` grant, so the unattended run never blocks on an+approval prompt) as one note headed ``Action items <date>``, and the final+answer IS the list — short, in the configured output language, or the single+sentence "no action items today" when the mail contained none.++Why ``wiki-ingest`` and not ``remember``: ``remember`` is registered as an+entry point but is deliberately NOT a router-tier tool (ADR-0011), so the+brain's live tool dict never contains it and a task grant for it is silently+dropped by ``BrainManager._select_task_tools``. ``wiki-ingest`` IS live,+takes free text, and lands in the long-term wiki the brain recalls from.+Storage is a soft requirement — ``requires`` names only ``gmail``; if the+wiki tool is missing the prompt says so instead of pretending.+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are extracting the concrete action items from the user's mail of the last \+{lookback_hours} hours. Today's date is in your context; every item below MUST \+come from a message the `gmail` tool actually returned — never invent a task, \+a sender or a deadline.++Step 1 — find the mail. Call `gmail` with action "list_messages", max_results 25 \+and this query (convert the hours into whole days, rounding up: 24 hours = 1d, \+48 hours = 2d):+ in:inbox newer_than:<N>d -category:promotions -category:social -category:forums \+-unsubscribe -"no-reply"+Step 2 — read it. `list_messages` returns only ids: call `gmail` with action \+"get_message" for each id (at most 15 messages, newest first). Read the sender, \+subject, date and body.+Step 3 — extract. An action item is something a real person asks the user to do, \+decide, send, review, pay, confirm or answer, or an obligation with a date \+(invoice due, appointment to confirm, form to return). Skip newsletters, \+marketing, automated notifications, receipts and "FYI" mail with nothing to do. \+For each item capture: who asked (name, no email address), what exactly, and by \+when (the stated date or "no deadline given"). Merge duplicates from the same \+thread. Keep at most 8 items, most urgent first.+Step 4 — store. If at least one item exists, call `wiki-ingest` ONCE with \+`source` "automation:task_extractor" and `text` being one self-contained \+block of plain prose of the form+ Action items <today's date YYYY-MM-DD>: 1) <who> — <what> — <by when>; 2) ...+so the list survives this turn as a wiki note. Do not call it when there are \+no items. If the `wiki-ingest` tool is not available or returns an error, do \+not pretend the list was stored — say so in one short final sentence.+Step 5 — answer. Reply with the numbered list only, one line per item in the \+form "<who>: <what> (by <when>)". If there are no action items, reply with the \+single sentence "no action items today" (translated into the output language).++Rules: no preamble, no closing remark, no emojis, no markdown headings, do not \+describe your process or the tools. If the mail tool returned an error, say that \+in one sentence instead of inventing a list. Write everything in the configured \+output language.+"""++TEMPLATE = AutomationTemplate(+ key="task_extractor",+ category="productivity",+ icon="list-checks",+ name=LocalizedText(+ en="Task Extractor",+ de="Aufgaben-Extraktor", # i18n-allow+ es="Extractor de tareas",+ ),+ description=LocalizedText(+ en="Pulls the action items out of today's mail and remembers them, so nothing slips.",+ de=( # i18n-allow+ "Zieht die Aufgaben aus den Mails von heute und merkt sie sich, "+ "damit nichts durchrutscht."+ ),+ es=(+ "Saca las tareas pendientes del correo de hoy y las recuerda "+ "para que nada se escape."+ ),+ ),+ schedule=TemplateSchedule(kind="daily", time="17:00"),+ prompt=_PROMPT,+ plugin_grants=(+ PluginGrant(plugin_id="gmail", scope="read"),+ # write: the unattended run must be allowed to store the list+ # without a human answering an approval prompt.+ PluginGrant(plugin_id="wiki-ingest", scope="write"),+ ),+ requires=("gmail",),+ inputs=(+ TemplateInput(+ key="lookback_hours",+ label=LocalizedText(+ en="Lookback window (hours)",+ de="Zeitfenster (Stunden)", # i18n-allow+ es="Ventana de tiempo (horas)",+ ),+ placeholder=LocalizedText(+ en="24",+ de="24",+ es="24",+ ),+ default="24",+ required=False,+ ),+ ),+ model_tier="auto",+ tags=("mail", "tasks", "memory"),+)diff --git a/jarvis/tasks/templates/topic_watch.py b/jarvis/tasks/templates/topic_watch.pynew file mode 100644index 0000000000..d7a9d6bca8--- /dev/null+++ b/jarvis/tasks/templates/topic_watch.py@@ -0,0 +1,92 @@+"""Topic Watch — a weekly digest of what changed around the companies,+products or topics the user follows."""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateInput,+ TemplateSchedule,+)++_PROMPT = """\+You are compiling a weekly Topic Watch digest. The user follows these topics \+(companies, products or themes): {topics}++Procedure:+1. Split the list into individual topics.+2. For EVERY topic run at least one `search_web` query scoped to the past \+week (add phrases like "this week" or "past 7 days" and the topic name; \+launches, pricing, hires, partnerships, controversies, funding). Run a second, \+differently worded query when the first one returns nothing relevant.+3. Keep only findings that happened within the last seven days and that \+actually come from the search results. Never invent, extrapolate or recall \+events from memory.++Output rules:+- Write in the configured output language.+- Group findings per topic. One heading line per topic (the topic name), \+followed by at most 3 bullets. Each bullet is one or two sentences that name \+the concrete change and end with the source name in parentheses, e.g. \+"(Reuters)".+- Lead with the most consequential item per topic.+- When the search returned nothing notable for a topic, write exactly one \+line under its heading saying that nothing notable happened this week — never \+pad with background information, older news or generic descriptions of the \+company.+- No preamble, no closing remarks, no emojis, no markdown tables.+- If `search_web` itself fails, say so in one line for that topic instead of \+guessing.+"""++TEMPLATE = AutomationTemplate(+ key="topic_watch",+ category="news",+ icon="radar",+ name=LocalizedText(+ en="Topic Watch",+ de="Themen-Radar", # i18n-allow+ es="Radar de temas",+ ),+ description=LocalizedText(+ en=(+ "Weekly digest of what changed around the companies, products or "+ "topics you follow (launches, pricing, hires, controversies)."+ ),+ de=( # i18n-allow+ "Wöchentliche Zusammenfassung, was sich bei den Firmen, Produkten "+ "oder Themen getan hat, die du verfolgst (Launches, Preise, "+ "Personalien, Kontroversen)."+ ),+ es=(+ "Resumen semanal de lo que cambió en las empresas, productos o "+ "temas que sigues (lanzamientos, precios, fichajes, polémicas)."+ ),+ ),+ schedule=TemplateSchedule(kind="weekly", weekday=0, time="09:00"),+ prompt=_PROMPT,+ plugin_grants=(PluginGrant(plugin_id="search_web", scope="read"),),+ requires=("search_web",),+ inputs=(+ TemplateInput(+ key="topics",+ label=LocalizedText(+ en="Topics to follow",+ de="Themen, die du verfolgst", # i18n-allow+ es="Temas que sigues",+ ),+ placeholder=LocalizedText(+ en="OpenAI, Anthropic, xAI — the competitors or topics you follow",+ de=( # i18n-allow+ "OpenAI, Anthropic, xAI — die Konkurrenten oder Themen, "+ "die du verfolgst"+ ),+ es="OpenAI, Anthropic, xAI — los competidores o temas que sigues",+ ),+ required=True,+ ),+ ),+ model_tier="auto",+ tags=("news", "web", "weekly"),+)diff --git a/jarvis/tasks/templates/weekly_review.py b/jarvis/tasks/templates/weekly_review.pynew file mode 100644index 0000000000..9517b6f62c--- /dev/null+++ b/jarvis/tasks/templates/weekly_review.py@@ -0,0 +1,95 @@+"""Weekly Review — wrap the week: what got done, what is still open, and the+three priorities for next week.++Runs once a week, Friday afternoon. The review is grounded in three sources+the automation may or may not have on a given install: this week's calendar+events (``google_calendar``), the notable mail threads (``gmail``) and the+memory notes of the past seven days (``wiki-recall``). None of them is a hard+requirement — with no calendar or mailbox connected the review is written+from memory alone, and the prompt tells the brain to use whatever tools are+available and to state which sources it actually used, so a thin review is+never mistaken for a full one.+"""+from __future__ import annotations++from jarvis.tasks.schema import PluginGrant+from jarvis.tasks.templates import (+ AutomationTemplate,+ LocalizedText,+ TemplateSchedule,+)++_PROMPT = """\+You are writing the user's Weekly Review. Today's date is in your context; \+"this week" means the last 7 days up to and including today.++Gather the material from whichever of these tools you have — use every one \+that is available, and if a tool is missing or fails, carry on without it:+1. `google_calendar` — call it with action "list_events", time_min = 7 days \+ago at 00:00 and time_max = today at 23:59 (RFC3339), max_results 50. \+These events are what happened this week.+2. `gmail` — call it with action "list_messages" and query "newer_than:7d", \+max_results 20. Keep only the threads that carry a decision, a request \+addressed to the user, a deadline or an open reply; ignore newsletters, \+notifications and promotions.+3. `wiki-recall` — run two or three short keyword searches for this week's \+projects, decisions and plans (e.g. the names of the projects and people \+that appear in the calendar and mail results, plus generic words like \+"plan", "decision", "todo"). Treat the hits as the user's own memory notes.++Then write the review. Rules:+- Exactly three sections with these headings, translated into the output \+language: "Done", "Open", "Next week (3 priorities)". Each line under a \+heading is one bullet.+- "Done": concrete things that happened or were completed this week (meetings \+held, decisions made, tasks closed) — who, what, when.+- "Open": items still waiting: unanswered mail, unresolved threads, notes that \+name a pending task, events that need follow-up.+- "Next week (3 priorities)": exactly three bullets, the most consequential \+things to do next week, each derived from an Open item or an upcoming event.+- Every fact MUST come from tool output. Never invent events, mails or notes; \+never fill a section with generic advice. If a section has nothing, write \+one bullet saying so.+- The whole review is at most 15 lines including the headings.+- End with ONE final line, translated into the output language, that names \+the sources actually used, e.g. "Sources: calendar, mail, memory" — list \+only the tools that returned data, and name the ones that were unavailable.+- No preamble, no closing remark, no emojis, no markdown tables. Do not \+describe your process.+- Write the whole review in the configured output language.+"""++TEMPLATE = AutomationTemplate(+ key="weekly_review",+ category="productivity",+ icon="clipboard-list",+ name=LocalizedText(+ en="Weekly Review",+ de="Wochenrückblick", # i18n-allow+ es="Revisión semanal",+ ),+ description=LocalizedText(+ en="Wrap the week: what you did, what's still open, and next week's three priorities.",+ de=( # i18n-allow+ "Schließe die Woche ab: was du geschafft hast, was offen ist "+ "und die drei Prioritäten für nächste Woche."+ ),+ es=(+ "Cierra la semana: lo que hiciste, lo que sigue abierto "+ "y las tres prioridades de la próxima."+ ),+ ),+ schedule=TemplateSchedule(kind="weekly", weekday=4, time="16:00"),+ prompt=_PROMPT,+ plugin_grants=(+ PluginGrant(plugin_id="google_calendar", scope="read"),+ PluginGrant(plugin_id="gmail", scope="read"),+ PluginGrant(plugin_id="wiki-recall", scope="read"),+ ),+ # Deliberately empty: the review degrades to memory-only without a+ # calendar or mailbox, so nothing blocks the card on a bare install.+ requires=(),+ inputs=(),+ model_tier="auto",+ tags=("review", "planning", "calendar", "mail", "memory"),+)diff --git a/scripts/ci/german-allowlist.txt b/scripts/ci/german-allowlist.txtindex 9a6febc44f..4d006cd1d1 100644--- a/scripts/ci/german-allowlist.txt+++ b/scripts/ci/german-allowlist.txt@@ -463,3 +463,7 @@ docs/commands-reference.md# German voice fixtures — content under test (reason 4). ---jarvis/brain/artifact_gate.pytests/unit/brain/test_artifact_tool_hide.py++# --- Automation templates (2026-08-24): localized card copy (en/de/es) lives+# next to each template so ten authors never edit one shared i18n file ---+jarvis/tasks/templates/*diff --git a/tests/unit/tasks/templates/__init__.py b/tests/unit/tasks/templates/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/tests/unit/tasks/templates/test_ai_news_digest.py b/tests/unit/tasks/templates/test_ai_news_digest.pynew file mode 100644index 0000000000..46038e2cde--- /dev/null+++ b/tests/unit/tasks/templates/test_ai_news_digest.py@@ -0,0 +1,85 @@+"""The ``ai_news_digest`` automation template — validates, builds a spec,+renders its prompt, and is discoverable through the catalogue."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.schema import TriggerEvery+from jarvis.tasks.templates import (+ LOCALES,+ all_templates,+ build_spec,+ missing_requirements,+ render_prompt,+)+from jarvis.tasks.templates.ai_news_digest import TEMPLATE++_DEFAULT_FOCUS = "model releases, open-source models, AI research, AI funding"+++def test_identity_and_catalogue_placement() -> None:+ assert TEMPLATE.key == "ai_news_digest"+ assert TEMPLATE.category == "news"+ assert TEMPLATE.icon == "bot"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "08:00"+++def test_discovered_by_catalogue() -> None:+ assert all_templates(refresh=True)["ai_news_digest"] is TEMPLATE+++def test_copy_present_in_every_locale() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale).strip()+ assert TEMPLATE.description.for_locale(locale).strip()+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale).strip()+ assert TEMPLATE.name.for_locale("en") == "AI News Digest"+++def test_requires_is_subset_of_grants_and_read_only() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert granted == {"search_web"}+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_readiness_against_live_tools() -> None:+ assert missing_requirements(TEMPLATE.requires, ["search_web", "gmail"]) == []+ assert missing_requirements(TEMPLATE.requires, ["gmail"]) == ["search_web"]+++def test_prompt_renders_default_focus_and_leaves_no_placeholder() -> None:+ text = render_prompt(TEMPLATE, None)+ assert _DEFAULT_FOCUS in text+ assert "{focus}" not in text+ custom = render_prompt(TEMPLATE, {"focus": "robotics"})+ assert "robotics" in custom+ assert _DEFAULT_FOCUS not in custom+++def test_prompt_states_the_contract() -> None:+ text = TEMPLATE.prompt+ assert "search_web" in text+ assert "at most 6" in text+ assert "48" in text+ assert "no emojis" in text+ assert "configured output language" in text+ assert "no preamble" in text+++def test_build_spec_without_inputs() -> None:+ now = datetime(2026, 8, 24, 9, 30)+ spec = build_spec(TEMPLATE, locale="de", now=now)+ assert spec.title == "KI-News-Digest"+ assert spec.created_by == "template"+ assert "template:ai_news_digest" in spec.tags+ assert spec.action.kind == "agent"+ assert spec.action.plugin_grants == TEMPLATE.plugin_grants+ assert _DEFAULT_FOCUS in spec.action.prompt+ assert isinstance(spec.trigger, TriggerEvery)+ assert spec.trigger.interval_seconds == 86_400+ # 09:30 is past 08:00, so the first run is tomorrow at 08:00.+ assert spec.trigger.start_at == "2026-08-25T08:00:00"+ assert spec.model_dump(mode="json")["action"]["prompt"] == spec.action.promptdiff --git a/tests/unit/tasks/templates/test_daily_planner.py b/tests/unit/tasks/templates/test_daily_planner.pynew file mode 100644index 0000000000..b9f14fcc51--- /dev/null+++ b/tests/unit/tasks/templates/test_daily_planner.py@@ -0,0 +1,68 @@+"""The ``daily_planner`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ render_prompt,+)+from jarvis.tasks.templates.daily_planner import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["daily_planner"] is TEMPLATE+ assert TEMPLATE.category == "productivity"+ assert TEMPLATE.icon == "calendar-check"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "08:30"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_grants_and_read_only() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert TEMPLATE.requires == ("google_calendar",)+ assert granted == {"google_calendar", "gmail"}+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_prompt_renders_default_work_hours() -> None:+ rendered = render_prompt(TEMPLATE, None)+ assert "09:00-18:00" in rendered+ assert "{work_hours}" not in rendered+ assert "list_events" in rendered+ assert "list_messages" in rendered+ assert "calendar is empty" in rendered+++def test_prompt_renders_custom_work_hours() -> None:+ rendered = render_prompt(TEMPLATE, {"work_hours": "08:00-16:00"})+ assert "08:00-16:00" in rendered+ assert "09:00-18:00" not in rendered+++def test_build_spec_builds_daily_agent_task_without_inputs() -> None:+ now = datetime(2026, 8, 24, 9, 0)+ spec = build_spec(TEMPLATE, inputs={}, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:daily_planner" in spec.tags+ assert spec.title == "Tagesplaner" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 86_400+ assert spec.trigger.start_at == "2026-08-25T08:30:00"+ assert spec.action.kind == "agent"+ assert "09:00-18:00" in spec.action.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_inbox_brief.py b/tests/unit/tasks/templates/test_inbox_brief.pynew file mode 100644index 0000000000..19102c6796--- /dev/null+++ b/tests/unit/tasks/templates/test_inbox_brief.py@@ -0,0 +1,71 @@+"""The ``inbox_brief`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ render_prompt,+)+from jarvis.tasks.templates.inbox_brief import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["inbox_brief"] is TEMPLATE+ assert TEMPLATE.category == "productivity"+ assert TEMPLATE.icon == "mail"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "09:00"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_read_only_gmail_grant() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert granted == {"gmail"}+ # The brief never sends — a read grant is all it may ever hold.+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_prompt_renders_lookback_and_keeps_output_rules() -> None:+ default = render_prompt(TEMPLATE, None)+ assert "newer_than:24h" in default+ custom = render_prompt(TEMPLATE, {"lookback_hours": "48"})+ assert "newer_than:48h" in custom+ assert "{lookback_hours}" not in custom+ assert "list_messages" in custom+ assert "get_message" in custom+ # list_messages returns ids only (gmail_rest.py), so the prompt must+ # force a get_message per id and pre-filter noise in the query itself.+ assert "EVERY id" in custom+ assert "-category:promotions" in custom+ assert "send" in custom and "never send" in custom+ assert "Maximum 8 lines" in custom+ assert "No emojis" in custom+ assert "inbox is clear" in custom+++def test_build_spec_builds_daily_agent_task_without_inputs() -> None:+ now = datetime(2026, 8, 24, 12, 0)+ spec = build_spec(TEMPLATE, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:inbox_brief" in spec.tags+ assert spec.title == "Posteingang-Briefing" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 86_400+ assert spec.trigger.start_at == "2026-08-25T09:00:00"+ assert spec.action.kind == "agent"+ assert "newer_than:24h" in spec.action.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_memory_recap.py b/tests/unit/tasks/templates/test_memory_recap.pynew file mode 100644index 0000000000..912e53657c--- /dev/null+++ b/tests/unit/tasks/templates/test_memory_recap.py@@ -0,0 +1,86 @@+"""The ``memory_recap`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ missing_requirements,+ render_prompt,+)+from jarvis.tasks.templates.memory_recap import TEMPLATE++_LOCAL_MEMORY_TOOLS = ("wiki-recall", "wiki-list", "wiki-page-read", "ultrawiki-search")+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["memory_recap"] is TEMPLATE+ assert TEMPLATE.category == "research"+ assert TEMPLATE.icon == "brain"+ assert TEMPLATE.schedule.kind == "weekly"+ assert TEMPLATE.schedule.weekday == 6 # Sunday+ assert TEMPLATE.schedule.time == "18:00"+ assert TEMPLATE.inputs == ()+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+++def test_description_says_it_works_offline_without_a_key() -> None:+ en = TEMPLATE.description.en.lower()+ assert "offline" in en+ assert "key" in en+ assert "offline" in TEMPLATE.description.de.lower()+ assert "sin conexión" in TEMPLATE.description.es.lower()+++def test_requires_is_subset_of_grants_and_all_read_only() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert granted == set(_LOCAL_MEMORY_TOOLS)+ assert TEMPLATE.requires == ("wiki-recall",)+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_only_local_tools_no_external_dependency() -> None:+ # Ready on a box that has nothing but the local memory tools.+ assert missing_requirements(TEMPLATE.requires, ["wiki-recall"]) == []+ # Not ready when the memory tool is absent.+ assert missing_requirements(TEMPLATE.requires, ["search_web"]) == ["wiki-recall"]+ for external in ("search_web", "gmail", "google_calendar", "github"):+ assert external not in {g.plugin_id for g in TEMPLATE.plugin_grants}+++def test_prompt_renders_without_placeholders() -> None:+ rendered = render_prompt(TEMPLATE, None)+ assert rendered == TEMPLATE.prompt+ assert "{" not in rendered and "}" not in rendered+ for tool in _LOCAL_MEMORY_TOOLS:+ assert tool in rendered+ assert "7 days" in rendered+ assert "3 to 5 themes" in rendered+ assert "12 lines" in rendered+ assert "configured output language" in rendered+ assert "no emojis" in rendered+ assert "memory is empty" in rendered+++def test_build_spec_builds_weekly_sunday_agent_task() -> None:+ now = datetime(2026, 8, 19, 12, 0) # a Wednesday+ spec = build_spec(TEMPLATE, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:memory_recap" in spec.tags+ assert spec.title == "Gedächtnis-Rückblick" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 7 * 86_400+ assert spec.trigger.start_at == "2026-08-23T18:00:00"+ assert spec.action.kind == "agent"+ assert spec.action.prompt == TEMPLATE.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_morning_brief.py b/tests/unit/tasks/templates/test_morning_brief.pynew file mode 100644index 0000000000..dae1ff4eea--- /dev/null+++ b/tests/unit/tasks/templates/test_morning_brief.py@@ -0,0 +1,77 @@+"""The ``morning_brief`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ render_prompt,+)+from jarvis.tasks.templates.morning_brief import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["morning_brief"] is TEMPLATE+ assert TEMPLATE.category == "news"+ assert TEMPLATE.icon == "sun"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "07:30"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_grants() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert granted == {"search_web"}+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_inputs_are_optional_with_sane_defaults() -> None:+ by_key = {i.key: i for i in TEMPLATE.inputs}+ assert set(by_key) == {"city", "interests"}+ assert not by_key["city"].required and by_key["city"].default == ""+ assert not by_key["interests"].required+ assert by_key["interests"].default == "world news, technology, business"+++def test_prompt_renders_inputs_and_keeps_the_weather_conditional() -> None:+ rendered = render_prompt(TEMPLATE, {"city": "Hamburg", "interests": "AI, football"})+ assert 'City for the weather: "Hamburg"' in rendered+ assert "morning brief for AI, football" in rendered+ assert "{city}" not in rendered and "{interests}" not in rendered+ # The prompt tells the agent how to call the tool and how to stay honest.+ assert "search_web" in rendered+ assert "never pick or guess a city" in rendered+ assert "output language" in rendered+++def test_prompt_without_city_leaves_the_field_empty_not_invented() -> None:+ rendered = render_prompt(TEMPLATE, {})+ assert 'City for the weather: ""' in rendered+ assert "world news, technology, business" in rendered+++def test_build_spec_produces_a_daily_agent_task() -> None:+ now = datetime(2026, 8, 24, 9, 0, 0)+ spec = build_spec(TEMPLATE, inputs={"city": "Berlin"}, locale="de", now=now)+ assert spec.title == "Morgen-Briefing" # i18n-allow+ assert spec.created_by == "template"+ assert "template:morning_brief" in spec.tags+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 86_400+ assert spec.trigger.start_at == "2026-08-25T07:30:00"+ assert spec.action.kind == "agent"+ assert 'City for the weather: "Berlin"' in spec.action.prompt+ assert [g.plugin_id for g in spec.action.plugin_grants] == ["search_web"]diff --git a/tests/unit/tasks/templates/test_repo_pulse.py b/tests/unit/tasks/templates/test_repo_pulse.pynew file mode 100644index 0000000000..80b8fdabbb--- /dev/null+++ b/tests/unit/tasks/templates/test_repo_pulse.py@@ -0,0 +1,83 @@+"""The ``repo_pulse`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++import pytest++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ grant_matches,+ missing_requirements,+ render_prompt,+)+from jarvis.tasks.templates.repo_pulse import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["repo_pulse"] is TEMPLATE+ assert TEMPLATE.category == "developer"+ assert TEMPLATE.icon == "git-branch"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "09:00"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_grants() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert granted == {"github"}+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_prefix_grant_covers_bridged_github_tools() -> None:+ live = ["gmail", "github/list_commits", "github/list_pull_requests", "github/list_issues"]+ assert grant_matches("github", "github/list_commits")+ assert not grant_matches("github", "githubish/list_commits")+ assert missing_requirements(TEMPLATE.requires, live) == []+ assert missing_requirements(TEMPLATE.requires, ["gmail", "search_web"]) == ["github"]+++def test_prompt_renders_repo() -> None:+ rendered = render_prompt(TEMPLATE, {"repo": "octo/hello"})+ assert "`octo/hello`" in rendered+ assert "{repo}" not in rendered+ for tool in ("github/list_commits", "github/list_pull_requests", "github/list_issues"):+ assert tool in rendered+ assert "24 hours" in rendered+ assert "12 lines" in rendered+++def test_build_spec_requires_repo() -> None:+ with pytest.raises(ValueError, match="repo"):+ build_spec(TEMPLATE, inputs={})+ with pytest.raises(ValueError, match="repo"):+ build_spec(TEMPLATE, inputs={"repo": ""})+ with pytest.raises(ValueError, match="repo"):+ build_spec(TEMPLATE)+++def test_build_spec_builds_daily_agent_task() -> None:+ now = datetime(2026, 8, 24, 12, 0)+ spec = build_spec(TEMPLATE, inputs={"repo": "octo/hello"}, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:repo_pulse" in spec.tags+ assert spec.title == "Repo-Puls" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 86_400+ assert spec.trigger.start_at == "2026-08-25T09:00:00"+ assert spec.action.kind == "agent"+ assert "octo/hello" in spec.action.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_stock_tracker.py b/tests/unit/tasks/templates/test_stock_tracker.pynew file mode 100644index 0000000000..edf3601cb0--- /dev/null+++ b/tests/unit/tasks/templates/test_stock_tracker.py@@ -0,0 +1,74 @@+"""The ``stock_tracker`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++import pytest++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ render_prompt,+)+from jarvis.tasks.templates.stock_tracker import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["stock_tracker"] is TEMPLATE+ assert TEMPLATE.category == "finance"+ assert TEMPLATE.icon == "dollar-sign"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "14:00"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_grants() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert granted == {"search_web"}+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_prompt_renders_watchlist_and_guardrails() -> None:+ rendered = render_prompt(TEMPLATE, {"watchlist": "NVDA, AAPL"})+ assert "NVDA, AAPL" in rendered+ assert "{watchlist}" not in rendered+ assert "search_web" in rendered+ assert "price not found" in rendered+ assert "no emojis" in rendered+ assert "configured output language" in rendered+ assert "advice" in rendered+++def test_build_spec_requires_watchlist() -> None:+ with pytest.raises(ValueError, match="watchlist"):+ build_spec(TEMPLATE, inputs={})+ with pytest.raises(ValueError, match="watchlist"):+ build_spec(TEMPLATE, inputs={"watchlist": ""})+ with pytest.raises(ValueError, match="watchlist"):+ build_spec(TEMPLATE)+++def test_build_spec_builds_daily_agent_task() -> None:+ now = datetime(2026, 8, 24, 15, 0) # after 14:00 -> next day+ spec = build_spec(TEMPLATE, inputs={"watchlist": "NVDA, AAPL"}, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:stock_tracker" in spec.tags+ assert spec.title == "Täglicher Aktien-Tracker" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 86_400+ assert spec.trigger.start_at == "2026-08-25T14:00:00"+ assert spec.action.kind == "agent"+ assert "NVDA, AAPL" in spec.action.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_task_extractor.py b/tests/unit/tasks/templates/test_task_extractor.pynew file mode 100644index 0000000000..6a7d2bc0fa--- /dev/null+++ b/tests/unit/tasks/templates/test_task_extractor.py@@ -0,0 +1,71 @@+"""The ``task_extractor`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ render_prompt,+)+from jarvis.tasks.templates.task_extractor import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["task_extractor"] is TEMPLATE+ assert TEMPLATE.category == "productivity"+ assert TEMPLATE.icon == "list-checks"+ assert TEMPLATE.schedule.kind == "daily"+ assert TEMPLATE.schedule.time == "17:00"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_grants_and_storage_may_write() -> None:+ scopes = {g.plugin_id: g.scope for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= set(scopes)+ # Storage is a soft requirement: the card is "ready" with Gmail alone.+ assert TEMPLATE.requires == ("gmail",)+ assert scopes["gmail"] == "read"+ # The unattended run must be able to store the list without approval,+ # through a tool that is actually live for task turns (not `remember`,+ # which ADR-0011 keeps out of the router tool set).+ assert scopes["wiki-ingest"] == "write"+ assert "remember" not in scopes+++def test_prompt_renders_lookback_default_and_override() -> None:+ rendered = render_prompt(TEMPLATE, None)+ assert "last 24 hours" in rendered+ assert "{lookback_hours}" not in rendered+ rendered = render_prompt(TEMPLATE, {"lookback_hours": "48"})+ assert "last 48 hours" in rendered+ for needle in ("list_messages", "get_message", "wiki-ingest",+ "automation:task_extractor", "Action items",+ "no action items today", "no emojis"):+ assert needle in rendered+ assert "`remember`" not in rendered+++def test_build_spec_builds_daily_agent_task() -> None:+ now = datetime(2026, 8, 24, 18, 0) # after 17:00 → tomorrow+ spec = build_spec(TEMPLATE, inputs={}, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:task_extractor" in spec.tags+ assert spec.title == "Aufgaben-Extraktor" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 86_400+ assert spec.trigger.start_at == "2026-08-25T17:00:00"+ assert spec.action.kind == "agent"+ assert "last 24 hours" in spec.action.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_topic_watch.py b/tests/unit/tasks/templates/test_topic_watch.pynew file mode 100644index 0000000000..387f854a66--- /dev/null+++ b/tests/unit/tasks/templates/test_topic_watch.py@@ -0,0 +1,72 @@+"""The ``topic_watch`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++import pytest++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ render_prompt,+)+from jarvis.tasks.templates.topic_watch import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["topic_watch"] is TEMPLATE+ assert TEMPLATE.category == "news"+ assert TEMPLATE.icon == "radar"+ assert TEMPLATE.schedule.kind == "weekly"+ assert TEMPLATE.schedule.weekday == 0+ assert TEMPLATE.schedule.time == "09:00"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ for inp in TEMPLATE.inputs:+ assert inp.label.for_locale(locale)+ assert inp.placeholder is not None and inp.placeholder.for_locale(locale)+++def test_requires_is_subset_of_grants() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert set(TEMPLATE.requires) <= granted+ assert "search_web" in granted+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+++def test_prompt_renders_topics() -> None:+ rendered = render_prompt(TEMPLATE, {"topics": "OpenAI, xAI"})+ assert "OpenAI, xAI" in rendered+ assert "{topics}" not in rendered+ assert "search_web" in rendered+ assert "nothing notable" in rendered+++def test_build_spec_requires_topics() -> None:+ with pytest.raises(ValueError, match="topics"):+ build_spec(TEMPLATE, inputs={})+ with pytest.raises(ValueError, match="topics"):+ build_spec(TEMPLATE, inputs={"topics": ""})+ with pytest.raises(ValueError, match="topics"):+ build_spec(TEMPLATE)+++def test_build_spec_builds_weekly_agent_task() -> None:+ now = datetime(2026, 8, 19, 12, 0) # a Wednesday+ spec = build_spec(TEMPLATE, inputs={"topics": "OpenAI, xAI"}, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:topic_watch" in spec.tags+ assert spec.title == "Themen-Radar" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 7 * 86_400+ assert spec.trigger.start_at == "2026-08-24T09:00:00"+ assert spec.action.kind == "agent"+ assert "OpenAI, xAI" in spec.action.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grantsdiff --git a/tests/unit/tasks/templates/test_weekly_review.py b/tests/unit/tasks/templates/test_weekly_review.pynew file mode 100644index 0000000000..094611970f--- /dev/null+++ b/tests/unit/tasks/templates/test_weekly_review.py@@ -0,0 +1,83 @@+"""The ``weekly_review`` automation template validates, renders and builds a spec."""+from __future__ import annotations++from datetime import datetime++from jarvis.tasks.templates import (+ LOCALES,+ AutomationTemplate,+ all_templates,+ build_spec,+ missing_requirements,+ render_prompt,+ schedule_label,+)+from jarvis.tasks.templates.weekly_review import TEMPLATE+++def test_template_is_discovered_and_well_formed() -> None:+ assert isinstance(TEMPLATE, AutomationTemplate)+ assert all_templates(refresh=True)["weekly_review"] is TEMPLATE+ assert TEMPLATE.category == "productivity"+ assert TEMPLATE.icon == "clipboard-list"+ assert TEMPLATE.schedule.kind == "weekly"+ assert TEMPLATE.schedule.weekday == 4 # Friday+ assert TEMPLATE.schedule.time == "16:00"+ assert schedule_label(TEMPLATE.schedule, "en") == "Fridays at 16:00"+++def test_all_locales_present() -> None:+ for locale in LOCALES:+ assert TEMPLATE.name.for_locale(locale)+ assert TEMPLATE.description.for_locale(locale)+ assert TEMPLATE.inputs == ()+++def test_grants_are_read_only_and_nothing_is_required() -> None:+ granted = {g.plugin_id for g in TEMPLATE.plugin_grants}+ assert granted == {"google_calendar", "gmail", "wiki-recall"}+ assert all(g.scope == "read" for g in TEMPLATE.plugin_grants)+ # Degrades to memory-only: no hard requirement, so the card is ready on+ # an install without a calendar or a mailbox.+ assert TEMPLATE.requires == ()+ assert set(TEMPLATE.requires) <= granted+ assert missing_requirements(TEMPLATE.requires, ["wiki-recall"]) == []+ assert missing_requirements(TEMPLATE.requires, []) == []+++def test_prompt_renders_without_inputs_and_names_every_tool() -> None:+ rendered = render_prompt(TEMPLATE, None)+ assert rendered == TEMPLATE.prompt+ assert "{" not in rendered # no placeholders: the template has no inputs+ for tool in ("google_calendar", "gmail", "wiki-recall"):+ assert f"`{tool}`" in rendered+ for heading in ("Done", "Open", "Next week (3 priorities)"):+ assert f'"{heading}"' in rendered+ assert "15 lines" in rendered+ assert "no emojis" in rendered+ assert "no preamble" in rendered.lower()+ assert "configured output language" in rendered+ # Degradation contract: use what is available, say which sources were used.+ assert "carry on without it" in rendered+ assert "sources actually used" in rendered+++def test_build_spec_builds_weekly_friday_agent_task() -> None:+ now = datetime(2026, 8, 19, 12, 0) # a Wednesday+ spec = build_spec(TEMPLATE, locale="de", now=now)+ assert spec.created_by == "template"+ assert "template:weekly_review" in spec.tags+ assert spec.title == "Wochenrückblick" # i18n-allow+ assert spec.trigger.type == "every"+ assert spec.trigger.interval_seconds == 7 * 86_400+ assert spec.trigger.start_at == "2026-08-21T16:00:00"+ assert spec.action.kind == "agent"+ assert spec.action.prompt == TEMPLATE.prompt+ assert spec.action.plugin_grants == TEMPLATE.plugin_grants+ assert spec.action.model_tier == "auto"+++def test_build_spec_after_friday_cutoff_rolls_to_next_week() -> None:+ now = datetime(2026, 8, 21, 16, 30) # Friday, past 16:00+ spec = build_spec(TEMPLATE, now=now)+ assert spec.trigger.start_at == "2026-08-28T16:00:00"