@aitne-sh/aitne 0.1.3 → 0.1.4

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 (87) hide show
  1. package/README.md +151 -147
  2. package/agent-assets/agent-profiles/conversational.md +23 -1
  3. package/agent-assets/agent-profiles/observer.md +15 -0
  4. package/agent-assets/agent-profiles/routine-fetch-window.md +128 -0
  5. package/agent-assets/agent-profiles/routine.md +16 -0
  6. package/agent-assets/agent-profiles/task.md +15 -0
  7. package/agent-assets/docs/concepts/auth-health.md +25 -9
  8. package/agent-assets/docs/concepts/backends-and-tiers.md +40 -4
  9. package/agent-assets/docs/concepts/costs-and-quotas.md +87 -25
  10. package/agent-assets/docs/concepts/delegated-mode.md +7 -13
  11. package/agent-assets/docs/concepts/memory-model.md +14 -1
  12. package/agent-assets/docs/concepts/observations.md +19 -1
  13. package/agent-assets/docs/concepts/process-keys.md +5 -0
  14. package/agent-assets/docs/concepts/routines.md +22 -10
  15. package/agent-assets/docs/concepts/safety-model.md +3 -8
  16. package/agent-assets/docs/concepts/skills.md +36 -1
  17. package/agent-assets/docs/features/integrations/calendar.md +74 -3
  18. package/agent-assets/docs/features/integrations/git.md +4 -4
  19. package/agent-assets/docs/features/integrations/github.md +75 -107
  20. package/agent-assets/docs/features/lifestyle/git.md +169 -22
  21. package/agent-assets/docs/features/messaging/overview.md +10 -1
  22. package/agent-assets/docs/features/routines/morning-routine.md +1 -1
  23. package/agent-assets/docs/getting-started/01-what-is-this.md +30 -12
  24. package/agent-assets/docs/getting-started/02-first-steps.md +15 -4
  25. package/agent-assets/docs/getting-started/03-what-can-this-do.md +17 -2
  26. package/agent-assets/docs/guides/install-and-run.md +10 -1
  27. package/agent-assets/docs/guides/setup-wizard.md +43 -6
  28. package/agent-assets/docs/guides/switch-default-backend.md +7 -3
  29. package/agent-assets/docs/reference/skills.md +10 -1
  30. package/agent-assets/docs/troubleshooting/auth-failed.md +27 -8
  31. package/agent-assets/docs/troubleshooting/quota-exhausted.md +35 -12
  32. package/agent-assets/skills/context/SKILL.md +6 -0
  33. package/agent-assets/skills/external-services/SKILL.md +4 -0
  34. package/agent-assets/skills/external-services/SKILL.native.claude.md +320 -0
  35. package/agent-assets/skills/external-services/SKILL.native.codex.md +243 -0
  36. package/agent-assets/skills/external-services/SKILL.native.gemini.md +237 -0
  37. package/agent-assets/skills/mail/SKILL.md +42 -14
  38. package/agent-assets/skills/mail/SKILL.native.claude.md +175 -0
  39. package/agent-assets/skills/mail/SKILL.native.codex.md +165 -0
  40. package/agent-assets/skills/mail/SKILL.native.gemini.md +169 -0
  41. package/agent-assets/skills/management-task-modify/SKILL.md +2 -1
  42. package/agent-assets/skills/management-task-stop/SKILL.md +2 -2
  43. package/agent-assets/skills/notify/SKILL.md +4 -4
  44. package/agent-assets/skills/notion/SKILL.md +6 -0
  45. package/agent-assets/skills/notion/SKILL.native.claude.md +202 -0
  46. package/agent-assets/skills/notion/SKILL.native.codex.md +166 -0
  47. package/agent-assets/skills/notion/SKILL.native.gemini.md +167 -0
  48. package/agent-assets/skills/observations/SKILL.md +7 -0
  49. package/agent-assets/skills/project-doc/SKILL.md +6 -0
  50. package/agent-assets/skills/reading/SKILL.md +2 -0
  51. package/agent-assets/skills/roadmap/SKILL.md +7 -0
  52. package/agent-assets/skills/today/SKILL.md +7 -0
  53. package/agent-assets/skills/user-interview/SKILL.md +1 -1
  54. package/agent-assets/skills/user-profile/SKILL.md +7 -0
  55. package/agent-assets/task-flows/_partials/calendar-acquire.google_calendar.md +119 -0
  56. package/agent-assets/task-flows/_partials/calendar-acquire.outlook_calendar.md +101 -0
  57. package/agent-assets/task-flows/_partials/mail-acquire.gmail.md +113 -0
  58. package/agent-assets/task-flows/_partials/mail-acquire.outlook_mail.md +97 -0
  59. package/agent-assets/task-flows/_partials/notion-acquire.notion.md +104 -0
  60. package/agent-assets/task-flows/git.project.refresh_architecture.md +24 -1
  61. package/agent-assets/task-flows/message.received.dm.md +3 -0
  62. package/agent-assets/task-flows/message.received.dm.native.claude.md +76 -0
  63. package/agent-assets/task-flows/message.received.dm.native.codex.md +57 -0
  64. package/agent-assets/task-flows/message.received.dm.native.gemini.md +70 -0
  65. package/agent-assets/task-flows/message.received.dm_first.md +3 -0
  66. package/agent-assets/task-flows/message.received.dm_first.native.claude.md +56 -0
  67. package/agent-assets/task-flows/message.received.dm_first.native.codex.md +48 -0
  68. package/agent-assets/task-flows/message.received.dm_first.native.gemini.md +54 -0
  69. package/agent-assets/task-flows/routine.evening_review.md +28 -1
  70. package/agent-assets/task-flows/routine.fetch_window.md +93 -0
  71. package/agent-assets/task-flows/routine.hourly_check.md +44 -5
  72. package/agent-assets/task-flows/routine.monthly_review.md +13 -2
  73. package/agent-assets/task-flows/routine.morning_routine.md +55 -42
  74. package/agent-assets/task-flows/routine.morning_routine_initial.md +37 -38
  75. package/agent-assets/task-flows/routine.roadmap_refresh.md +38 -46
  76. package/agent-assets/task-flows/routine.today_refresh.md +53 -96
  77. package/agent-assets/task-flows/routine.weekly_review.md +40 -17
  78. package/agent-assets/task-flows/scheduled.dm.md +13 -11
  79. package/agent-assets/task-flows/scheduled.task.md +2 -2
  80. package/agent-assets/task-flows/setup.initial.md +5 -4
  81. package/agent-assets/task-flows/setup.update.md +1 -1
  82. package/agent-assets/templates/README.md +13 -6
  83. package/package.json +4 -4
  84. package/scripts/regen-skill-fixtures.mjs +39 -0
  85. package/agent-assets/task-flows/routine.hourly_check.delegated.claude.md +0 -405
  86. package/agent-assets/task-flows/routine.hourly_check.delegated.codex.md +0 -400
  87. package/agent-assets/task-flows/routine.hourly_check.delegated.gemini.md +0 -404
@@ -0,0 +1,57 @@
1
+ {context}
2
+
3
+ ## DM Reply — Native Mode (Codex connectors)
4
+
5
+ Variant of `message.received.dm` selected when at least one integration
6
+ the agent may need to reach during this DM is in `native` mode and the
7
+ session backend (Codex) matches the integration's `nativeBackend`.
8
+
9
+ > **Connector routing (native).** `<integration_modes>` carries
10
+ > `gmail`, `google_calendar`, and `notion` mode attributes plus
11
+ > `<key>_native_backend="<backend>"` for every native key. For any
12
+ > native integration the user's DM may need:
13
+ >
14
+ > - Call `mcp__codex_apps__<service>._*` MCP tools directly. The Codex
15
+ > namespace terminates with `._` — the bare suffix from each skill's
16
+ > `SKILL.native.codex.md` body is what you append.
17
+ > - Do **NOT** call `POST /api/integrations/<key>/exec` (410 in native).
18
+ > - Do **NOT** call the per-integration daemon routes
19
+ > (`/api/calendar/*`, `/api/notion/query|search|pages|...`, Gmail
20
+ > accounts under `/api/mail/*`) — each returns 410 in native mode.
21
+ > - Write-class MCP calls (per registry `destructiveTools`) require
22
+ > explicit user confirmation; the absolute-block layer continues to
23
+ > fire.
24
+ > - Direct-mode siblings keep using their direct routes — native gate
25
+ > is per-key.
26
+
27
+ ### Per-session integration routing
28
+
29
+ <integration-routing-table>
30
+
31
+ ### Native MCP routing — per integration
32
+
33
+ **Calendar — real-time queries.** When `google_calendar="native"`, use
34
+ the `mcp__codex_apps__google_calendar._*` MCP tools (`_search` /
35
+ `_search_events` / `_read_event` / `_fetch` / `_get_availability` +
36
+ destructive set). `/api/calendar/*` and
37
+ `POST /api/integrations/google_calendar/exec` both return 410.
38
+
39
+ **Mail — DM read / draft / reply.** When `gmail="native"`, use the
40
+ `mcp__codex_apps__gmail._*` MCP tools per the `mail` skill's native
41
+ body (`_search_emails` / `_read_email` / `_read_email_thread` /
42
+ `_create_draft`). Destructive set (`_send_email` / `_send_draft` /
43
+ `_forward_emails` / `_delete_emails` / `_archive_emails` / etc.)
44
+ requires explicit user confirmation. For non-Gmail accounts (IMAP /
45
+ Outlook / iCloud / Yahoo), keep using the direct-mode
46
+ `/api/mail/<acct>/*` routes per the base `mail` skill body.
47
+
48
+ **Notion — DM read / search.** When `notion="native"`, use the
49
+ `mcp__codex_apps__notion._*` MCP tools (`_search` / `_fetch` /
50
+ `_notion_query_data_sources` for structured filters). The
51
+ `/api/notion/databases` config dump remains reachable in every mode.
52
+
53
+ The dispatch decision flow (capture user info, profile-question
54
+ reconcile, compose reply, route durable intent) is shared with the
55
+ direct variant via the `{{> base }}` partial below.
56
+
57
+ {{> base }}
@@ -0,0 +1,70 @@
1
+ {context}
2
+
3
+ ## DM Reply — Native Mode (Gemini connectors)
4
+
5
+ Variant of `message.received.dm` selected when at least one integration
6
+ the agent may need to reach during this DM is in `native` mode and the
7
+ session backend (Gemini) matches the integration's `nativeBackend`.
8
+
9
+ > **Connector routing (native).** `<integration_modes>` carries
10
+ > `gmail`, `google_calendar`, and `notion` mode attributes plus
11
+ > `<key>_native_backend="<backend>"` for every native key. For any
12
+ > native integration the user's DM may need:
13
+ >
14
+ > - Call `mcp_google-workspace_*.*` and `mcp_notion_*` MCP tools
15
+ > directly. Gemini's namespace convention uses single underscores
16
+ > between server and tool names with `.` as the inner separator (see
17
+ > each skill's `SKILL.native.gemini.md` body for exact tool names).
18
+ > - Do **NOT** call `POST /api/integrations/<key>/exec` (410 in native).
19
+ > - Do **NOT** call the per-integration daemon routes
20
+ > (`/api/calendar/*`, `/api/notion/query|search|pages|...`, Gmail
21
+ > accounts under `/api/mail/*`) — each returns 410 in native mode.
22
+ > - Write-class MCP calls (per registry `destructiveTools`) require
23
+ > explicit user confirmation; the absolute-block layer continues to
24
+ > fire.
25
+ > - Direct-mode siblings keep using their direct routes.
26
+ > - **Gemini-specific quirks** (carry over from delegated mode):
27
+ > `maxResults` is silently ignored on Gmail `search` and Calendar
28
+ > `listEvents` — narrow the query window when the result is larger
29
+ > than expected.
30
+
31
+ ### Per-session integration routing
32
+
33
+ <integration-routing-table>
34
+
35
+ ### Native MCP routing — per integration
36
+
37
+ **Calendar — real-time queries.** When `google_calendar="native"`, use
38
+ the `mcp_google-workspace_calendar.*` MCP tools (`listEvents` /
39
+ `getEvent` / `list` (list calendars) / `findFreeTime` + destructive
40
+ set). `/api/calendar/*` and
41
+ `POST /api/integrations/google_calendar/exec` both return 410.
42
+ `maxResults` is silently ignored on `listEvents` — narrow the window
43
+ when needed. The default `attendeeResponseStatus` excludes declined
44
+ events; pass the full list explicitly when declined meetings are
45
+ relevant.
46
+
47
+ **Mail — DM read / draft / reply.** When `gmail="native"`, use the
48
+ `mcp_google-workspace_gmail.*` MCP tools per the `mail` skill's
49
+ native body (`search` / `get` / `createDraft`). Destructive set
50
+ (`send` / `sendDraft` / `modify` / `modifyThread` / `createLabel` /
51
+ `batchModify`) requires explicit user confirmation. The extension
52
+ has no dedicated `delete` or `forward` tool — compose from primitives.
53
+ For non-Gmail accounts (IMAP / Outlook / iCloud / Yahoo), keep using
54
+ the direct-mode `/api/mail/<acct>/*` routes per the base `mail` skill
55
+ body.
56
+
57
+ **Notion — DM read / search.** When `notion="native"`, use the
58
+ `mcp_notion_*` MCP tools per the `notion` skill's native body
59
+ (`mcp_notion_notion-search` / `mcp_notion_notion-fetch` and the
60
+ destructive set). The descriptor assumes the user registered Notion's
61
+ official MCP server under the literal name `notion`
62
+ (`gemini mcp add notion <url>`); the §9.3 probe at flip time verifies
63
+ presence. The `/api/notion/databases` config dump remains reachable in
64
+ every mode.
65
+
66
+ The dispatch decision flow (capture user info, profile-question
67
+ reconcile, compose reply, route durable intent) is shared with the
68
+ direct variant via the `{{> base }}` partial below.
69
+
70
+ {{> base }}
@@ -86,6 +86,9 @@ same-backend delegated → use your session's native Google Calendar MCP tools (
86
86
  <!-- mode:delegated-cross:google_calendar -->
87
87
  cross-backend delegated → call `POST /api/integrations/google_calendar/exec` with a natural-language `task` + `outputSchema`, via the external-services skill. Do NOT call `/api/calendar/events` (returns 410) and do NOT fall back to your own backend's native Calendar MCP tools — they read a different Google account.
88
88
  <!-- /mode:delegated-cross:google_calendar -->
89
+ <!-- mode:native:google_calendar -->
90
+ native → your session backend's native Google Calendar MCP tools (see the `external-services` skill's native body for the exact tool namespace per backend). `/api/calendar/*` returns 410 in native mode and `POST /api/integrations/google_calendar/exec` returns 410 with `X-Integration-Mode: native` — do NOT call either; the daemon does not proxy Calendar in native mode.
91
+ <!-- /mode:native:google_calendar -->
89
92
  <!-- mode:disabled:google_calendar -->
90
93
  disabled → tell the user real-time calendar access is unavailable in this configuration; work from the morning snapshot in <today> only.
91
94
  <!-- /mode:disabled:google_calendar -->
@@ -0,0 +1,56 @@
1
+ {context}
2
+
3
+ ## DM — First Message of the Day (Native Mode — Claude connectors)
4
+
5
+ This is the first DM of today. <today> contains today's schedule,
6
+ user tasks, and the agent's day plan. Variant of
7
+ `message.received.dm_first` selected when at least one integration is
8
+ in `native` mode bound to Claude.
9
+
10
+ Behavior is identical to `message.received.dm.native.claude.md` except
11
+ for the first-day delta in Step 3 (you may briefly preview the user's
12
+ most imminent task as a follow-up question — handled by the base
13
+ `message.received.dm_first.md` flow inlined below).
14
+
15
+ > **Connector routing (native).** `<integration_modes>` carries
16
+ > `<key>_native_backend="claude"` for every native key. For any native
17
+ > integration the user's DM may need:
18
+ >
19
+ > - Call `mcp__claude_ai_<Service>__*` MCP tools directly per each
20
+ > skill's `SKILL.native.claude.md` body.
21
+ > - Do **NOT** call `POST /api/integrations/<key>/exec` (410 in native).
22
+ > - Do **NOT** call the per-integration daemon routes — each returns
23
+ > 410 in native mode.
24
+ > - Write-class MCP calls require explicit user confirmation.
25
+ > - Direct-mode siblings keep using their direct routes.
26
+
27
+ ### Per-session integration routing
28
+
29
+ <integration-routing-table>
30
+
31
+ ### Native MCP routing — per integration
32
+
33
+ **Calendar.** When `google_calendar="native"`, use
34
+ `mcp__claude_ai_Google_Calendar__*` MCP tools (`list_events` /
35
+ `get_event` / `list_calendars` / `suggest_time`). `/api/calendar/*` and
36
+ `POST /api/integrations/google_calendar/exec` both return 410.
37
+ Destructive calendar tools require explicit user confirmation.
38
+
39
+ **Mail.** When `gmail="native"`, use `mcp__claude_ai_Gmail__*` MCP
40
+ tools per the `mail` skill's native body. Claude's hosted Gmail
41
+ connector is **draft-only** — there is no send / forward / delete
42
+ surface; if the user asks to send, point them at the Gmail web UI.
43
+ For non-Gmail accounts (IMAP / Outlook / iCloud / Yahoo), keep using
44
+ the direct-mode `/api/mail/<acct>/*` routes per the base `mail`
45
+ skill body.
46
+
47
+ **Notion.** When `notion="native"`, use the
48
+ `mcp__claude_ai_Notion__*` MCP tools. `/api/notion/databases` (label
49
+ → UUID config dump) remains reachable in every mode.
50
+
51
+ The first-DM dispatch decision flow (capture user info, profile-question
52
+ reconcile, compose reply with the optional 1–2 task preview, route
53
+ durable intent) is shared with the direct first-DM variant via the
54
+ `{{> base }}` partial below.
55
+
56
+ {{> base }}
@@ -0,0 +1,48 @@
1
+ {context}
2
+
3
+ ## DM — First Message of the Day (Native Mode — Codex connectors)
4
+
5
+ This is the first DM of today. <today> contains today's schedule,
6
+ user tasks, and the agent's day plan. Variant of
7
+ `message.received.dm_first` selected when at least one integration is
8
+ in `native` mode bound to Codex.
9
+
10
+ Behavior is identical to `message.received.dm.native.codex.md` except
11
+ for the first-day delta in Step 3 (handled by the base
12
+ `message.received.dm_first.md` flow inlined below).
13
+
14
+ > **Connector routing (native).** Use
15
+ > `mcp__codex_apps__<service>._*` MCP tools directly. Do **NOT** call
16
+ > `POST /api/integrations/<key>/exec` (410) or the per-integration
17
+ > daemon routes (410). Write-class MCP calls require explicit user
18
+ > confirmation; direct-mode siblings keep using their direct routes.
19
+
20
+ ### Per-session integration routing
21
+
22
+ <integration-routing-table>
23
+
24
+ ### Native MCP routing — per integration
25
+
26
+ **Calendar.** When `google_calendar="native"`, use
27
+ `mcp__codex_apps__google_calendar._*` MCP tools (`_search` /
28
+ `_search_events` / `_read_event` / `_fetch` / `_get_availability` +
29
+ destructive set). `/api/calendar/*` and
30
+ `POST /api/integrations/google_calendar/exec` both return 410.
31
+
32
+ **Mail.** When `gmail="native"`, use `mcp__codex_apps__gmail._*` MCP
33
+ tools. Destructive set (`_send_email` / `_send_draft` /
34
+ `_forward_emails` / `_delete_emails` / `_archive_emails` / ...)
35
+ requires explicit user confirmation. For non-Gmail accounts keep
36
+ using `/api/mail/<acct>/*`.
37
+
38
+ **Notion.** When `notion="native"`, use `mcp__codex_apps__notion._*`
39
+ MCP tools. `_notion_query_data_sources` is the SQL-style structured
40
+ query for property-shaped intents (Codex-only capability).
41
+ `/api/notion/databases` config dump is reachable in every mode.
42
+
43
+ The first-DM dispatch decision flow (capture user info, profile-question
44
+ reconcile, compose reply with the optional 1–2 task preview, route
45
+ durable intent) is shared with the direct first-DM variant via the
46
+ `{{> base }}` partial below.
47
+
48
+ {{> base }}
@@ -0,0 +1,54 @@
1
+ {context}
2
+
3
+ ## DM — First Message of the Day (Native Mode — Gemini connectors)
4
+
5
+ This is the first DM of today. <today> contains today's schedule,
6
+ user tasks, and the agent's day plan. Variant of
7
+ `message.received.dm_first` selected when at least one integration is
8
+ in `native` mode bound to Gemini.
9
+
10
+ Behavior is identical to `message.received.dm.native.gemini.md`
11
+ except for the first-day delta in Step 3 (handled by the base
12
+ `message.received.dm_first.md` flow inlined below).
13
+
14
+ > **Connector routing (native).** Use `mcp_google-workspace_*.*` and
15
+ > `mcp_notion_*` MCP tools directly. Do **NOT** call
16
+ > `POST /api/integrations/<key>/exec` (410) or the per-integration
17
+ > daemon routes (410). Write-class MCP calls require explicit user
18
+ > confirmation; direct-mode siblings keep using their direct routes.
19
+ > **Gemini quirks**: `maxResults` is silently ignored on Gmail
20
+ > `search` and Calendar `listEvents` — narrow the query window when
21
+ > the result is larger than expected.
22
+
23
+ ### Per-session integration routing
24
+
25
+ <integration-routing-table>
26
+
27
+ ### Native MCP routing — per integration
28
+
29
+ **Calendar.** When `google_calendar="native"`, use
30
+ `mcp_google-workspace_calendar.*` MCP tools (`listEvents` / `getEvent`
31
+ / `list` / `findFreeTime` + destructive set). `maxResults` silently
32
+ ignored on `listEvents`; default `attendeeResponseStatus` excludes
33
+ declined events (pass full list explicitly when needed).
34
+ `/api/calendar/*` and `POST /api/integrations/google_calendar/exec`
35
+ both return 410.
36
+
37
+ **Mail.** When `gmail="native"`, use `mcp_google-workspace_gmail.*`
38
+ MCP tools. The extension has no dedicated `delete` or `forward` tool
39
+ — compose from primitives (delete = `modify` + add TRASH; forward =
40
+ `send` with re-quoted body). Destructive set requires explicit user
41
+ confirmation. For non-Gmail accounts keep using `/api/mail/<acct>/*`.
42
+
43
+ **Notion.** When `notion="native"`, use `mcp_notion_*` MCP tools per
44
+ the `notion` skill's native body. No SQL-style structured query
45
+ exists on this connector — use `mcp_notion_notion-search` for
46
+ property-shaped intents and filter client-side.
47
+ `/api/notion/databases` config dump is reachable in every mode.
48
+
49
+ The first-DM dispatch decision flow (capture user info, profile-question
50
+ reconcile, compose reply with the optional 1–2 task preview, route
51
+ durable intent) is shared with the direct first-DM variant via the
52
+ `{{> base }}` partial below.
53
+
54
+ {{> base }}
@@ -18,6 +18,32 @@ Close out today and prepare tomorrow. Steps 1–3 are internal bookkeeping
18
18
  (Morning Routine depends on them). Step 4 is the ONLY user-visible output,
19
19
  and it must be written for the user — not as a report of what you just did.
20
20
 
21
+ ### Step 0 — Read today's mail outcomes
22
+
23
+ The pre-pass fetcher session (`routine.fetch_window`) ran ahead of you
24
+ and posted observations for the `today_outcomes` window (mail sent /
25
+ replied since the agent-day start) for every active mail integration.
26
+ The `<fetch_report>` block in your prompt tells you the pre-pass
27
+ status — `success` / `partial` means the table is fresh; `skipped`
28
+ means every mail integration is disabled and this step contributes
29
+ nothing to the wrap-up; `failed` means trust no row newer than the
30
+ prior tick and treat the section as best-effort.
31
+
32
+ Drain pending mail observations with the agent-day-start floor — the
33
+ daily synthesis already has the morning inflows from the morning
34
+ routine:
35
+
36
+ ```
37
+ GET /api/observations?pending=true&source_prefix=gmail:,outlook_mail:&observed_at_after=<agent_day_start_iso>&limit=50
38
+ ```
39
+
40
+ Fold meaningful items into the in-memory state you carry into Step 1
41
+ (Finalize today.md — Agent Log entries when an outbound reply closed a
42
+ loop) and Step 4 (Wrap-up — an unanswered inbound that surfaced today
43
+ might satisfy trigger (b)). Do NOT push back into the mail provider —
44
+ this step is read-only; outbound replies belong to the user / morning
45
+ routine / DM-reply paths.
46
+
21
47
  ### Step 1 — Finalize today.md
22
48
  - Check incomplete ## User Tasks status and mark accordingly.
23
49
  - Reconcile ## Agent Plan: every row whose HH:MM has already passed should be
@@ -312,7 +338,8 @@ wrap-up contract** in the notify skill. That contract owns:
312
338
  - the 4-line cap and markdown rules,
313
339
  - the no-ceremony / no-filler-timing-commentary rule,
314
340
  - the no-internal-mechanism-names vocabulary rule,
315
- - the language and tone from the Character block (always present when set),
341
+ - output language per `<output_language_policy>` and tone from the
342
+ Character block (always present when set),
316
343
  - the good / bad worked examples (including the exact anti-pattern
317
344
  the user has flagged).
318
345
 
@@ -0,0 +1,93 @@
1
+ {context}
2
+
3
+ ## Routine Data-Fetch Pre-Pass
4
+
5
+ You are the **pre-pass fetcher** dispatched by the daemon immediately
6
+ ahead of a parent routine session. Your sole job is to materialise the
7
+ `<fetch>` rows from the `<acquisition-plan>` block in your prompt into
8
+ fresh `/api/observations` rows. The parent routine reads those rows
9
+ after you terminate; you do not write to context files, do not
10
+ synthesize, and do not notify the owner.
11
+
12
+ Read the `<acquisition-plan>` block carefully — every row carries the
13
+ exact `(integration, mode, window, account?, query)` tuple the daemon
14
+ already resolved for you. Trust that routing: do **not** probe MCP
15
+ registries, do **not** guess tool names, do **not** call the daemon's
16
+ `/api/integrations/<key>/exec` proxy for any `userManagedConnector`
17
+ integration (`outlook_mail`, `outlook_calendar` today). If a row has
18
+ no usable surface, append a `no-surface` error entry and move on.
19
+
20
+ For every `<fetch>` row, follow the matching integration partial
21
+ below. Each partial owns the wire surface for its `(integration, mode)`
22
+ cell — `applyIntegrationModeFilter` has already pruned the inactive
23
+ branches, so the body you see is the one that applies for the current
24
+ deployment state.
25
+
26
+ ### Step 1 — Fetch every row in `<acquisition-plan>`
27
+
28
+ For each `<fetch integration="…" mode="…" window="…" query="…" account="…?">` element:
29
+
30
+ - `integration="gmail"` → follow the gmail mail partial below.
31
+ - `integration="outlook_mail"` → follow the outlook_mail mail partial below.
32
+ - `integration="google_calendar"` → follow the google_calendar partial below.
33
+ - `integration="outlook_calendar"` → follow the outlook_calendar partial below.
34
+ - `integration="notion"` → follow the notion partial below.
35
+
36
+ If `<acquisition-plan>` carries no `<fetch>` rows (an empty plan is
37
+ legal — every routine has at least the wrapper) print the
38
+ `{"fetched":0,"posted":0,"duplicates":0,"errors":[]}` JSON line and
39
+ terminate.
40
+
41
+ {include:_partials/mail-acquire.gmail.md}
42
+
43
+ {include:_partials/mail-acquire.outlook_mail.md}
44
+
45
+ {include:_partials/calendar-acquire.google_calendar.md}
46
+
47
+ {include:_partials/calendar-acquire.outlook_calendar.md}
48
+
49
+ {include:_partials/notion-acquire.notion.md}
50
+
51
+ ### Step 2 — Emit a single JSON line and terminate
52
+
53
+ After every row has been processed (success, duplicate, or recorded
54
+ error), emit exactly one JSON line on stdout with the shape:
55
+
56
+ ```json
57
+ {"fetched":<int>,"posted":<int>,"duplicates":<int>,"errors":[<{type,...}>]}
58
+ ```
59
+
60
+ - `fetched` — total items returned by upstream APIs across every row.
61
+ - `posted` — count of 2xx responses from `/api/observations` (new rows).
62
+ - `duplicates` — count of 409 responses (server-side dedup-hash collision).
63
+ - `errors` — list of `{type, ...}` records. Common types:
64
+ - `no-surface` — the row points at an in-session connector that
65
+ isn't bound on this backend.
66
+ - `unexpected-row` — `mode="disabled"` slipped past the daemon
67
+ filter (defensive).
68
+ - `fetch-failed` — upstream API returned a non-2xx; include
69
+ `{type, integration, account?, status, message}`.
70
+ - `budget-exhausted` — you hit the configured `max_turns` /
71
+ `max_budget_usd` for `routine.fetch_window`. Include
72
+ `{type, remaining: <fetch-row-summary>}` so the audit trail
73
+ surfaces which rows were not attempted.
74
+
75
+ Do NOT print prose around the JSON line — the dispatcher reads the
76
+ last JSON-shaped object on stdout. A malformed line surfaces as a
77
+ `pre-pass-failed` error in the parent routine's `<fetch_report>`
78
+ block and the parent continues with whatever observations the rest of
79
+ the plan produced.
80
+
81
+ ### Hard guardrails
82
+
83
+ - Do NOT call `/api/context/*` (read or write). The parent routine
84
+ owns every context-MD file.
85
+ - Do NOT call `/api/notify`. The pre-pass is invisible to the owner
86
+ by contract.
87
+ - Do NOT spawn sub-agents (Task tool or otherwise). Keep the run flat
88
+ so the dispatcher can clamp turn / budget cleanly.
89
+ - `actor` on every `/api/observations` POST MUST be `"agent"` — the
90
+ server rejects `"user"`.
91
+ - Do NOT compute a `contentHash` yourself; the server derives it from
92
+ `(source, payload)`. A 409 means dedup — count it in `duplicates`
93
+ and continue.
@@ -17,13 +17,51 @@ framework for the observation-review step; additional checks the user
17
17
  has added to the routine file run alongside them using the same
18
18
  routing rules.
19
19
 
20
- Use the observations skill to fetch pending user-originated items:
21
- GET /api/observations?pending=true&actor=user&limit=20. Follow the
20
+ Output language: follow `<output_language_policy>` (Policy B for any
21
+ context-MD write-up; Policy C for the optional `POST /api/notify` DM).
22
+ Agent log appends to `agent/journal.md` stay English (Policy A).
23
+
24
+ Use the observations skill to fetch pending items. The pre-pass
25
+ fetcher session (`routine.fetch_window`) ran ahead of you and posted
26
+ small `unread_last_hour` / `imminent_2h` / `updated_1h` windows for
27
+ every active mail / calendar / notion integration; both `actor=user`
28
+ and `actor=agent` rows reach this session — the user-actor rows are
29
+ vault / git / file activity, the agent-actor rows are the windows
30
+ the pre-pass posted. The downstream steps draw on the merged view:
31
+
32
+ ```
33
+ GET /api/observations?pending=true&limit=30
34
+ ```
35
+
36
+ The legacy `actor=user&limit=20` query stays valid for sessions that
37
+ only want the user-actor surface (e.g. early triage). Follow the
22
38
  context skill for today.md section formats and the day-type filter
23
39
  mapping — this prompt owns the decision workflow only. Most runs should
24
40
  do bookkeeping silently; only fire POST /api/notify on the urgency gate
25
41
  in Step 8 below.
26
42
 
43
+ ### Step 0 — Read pre-pass `<fetch_report>`
44
+
45
+ The `<fetch_report>` block in your prompt tells you the pre-pass
46
+ status:
47
+
48
+ - `status="success"` or `"partial"` → fresh mail / calendar / notion
49
+ rows are visible in `/api/observations?pending=true`. Trust the
50
+ table.
51
+ - `status="failed"` → the pre-pass crashed or its output was
52
+ unparseable; treat the table as best-effort, fall back to
53
+ user-actor rows for this tick.
54
+ - `status="skipped"` → no integration was active for this tick (or
55
+ every applicable cell resolved to disabled); the table carries
56
+ only user-actor signals.
57
+
58
+ Window sizes are intentionally small by design (typical: 0–2 mail
59
+ items, 0–1 calendar item, 0–3 notion pages) so this step costs
60
+ near-nothing on most ticks. The pre-pass partial bodies own the
61
+ per-(integration, mode) wire surface — do NOT call upstream
62
+ integration APIs from this session; treat the observations table as
63
+ authoritative from Step 1 onward.
64
+
27
65
  ### Execution budget
28
66
  Target: 5–10 turns. If you reach 15 turns, wrap up current work and log.
29
67
  Do NOT read roadmap.md, projects/*.md, or user/*.md unless an
@@ -32,9 +70,10 @@ milestone, or deliverable — not merely a file edit in a watched repo).
32
70
 
33
71
  ### Stage gate decision (cost-reduction-structural §B)
34
72
  When `<gate_decision>` is present, this run was escalated through the
35
- three-stage funnel (Stage 1 deterministic gate or Stage 2 lite-tier
36
- triage). The block tells you *why* you were spawned — pull the
37
- `reason` and `signals_snapshot` into your prioritisation. Examples:
73
+ three-stage funnel (Stage 0 deterministic gate or Stage 2 lite-tier
74
+ triage; Stage 3 is the current session). The block tells you *why*
75
+ you were spawned — pull the `reason` and `signals_snapshot` into
76
+ your prioritisation. Examples:
38
77
 
39
78
  - `reason: vip_mail_unread` → start with the mail observation, do not
40
79
  scan obsidian noise first.
@@ -30,6 +30,17 @@ workflow; the skill owns the file contract.
30
30
  ### Phase 1: Gather the month
31
31
  1. Determine the target file name from <current_time>:
32
32
  `monthly/YYYY-MM.md`.
33
+
34
+ **Pre-pass acquisition (none).** Unlike morning / hourly / today_refresh /
35
+ evening / weekly, monthly_review does NOT trigger an `<acquisition-plan>`
36
+ block — the 30-day calendar window already arrives via the
37
+ `<calendar_events_30d>` ContextBuilder block (multi-provider after the
38
+ §6.6 generalization), and mail / notion signals already flowed through
39
+ daily journals over the course of the month. The monthly review is
40
+ **summative**, not reactive; it synthesises across previously-captured
41
+ state rather than fetching fresh windows. If the dispatcher emitted any
42
+ `<fetch>` rows for this routine (a misconfiguration), ignore them and
43
+ continue.
33
44
  2. Fetch source material for the current month:
34
45
  - Use GET /api/context/list/daily to discover archived daily files and
35
46
  read each `daily/YYYY-MM-DD.md` in the current month.
@@ -211,7 +222,7 @@ weekly section of agent/journal.md: `silent monthly wrap-up — nothing
211
222
  actionable`.
212
223
 
213
224
  #### 4b. When you DO notify — content rules
214
- Answer, in the user's preferred language from the Character block:
225
+ Output language: follow `<output_language_policy>`. Answer:
215
226
  1. **The biggest win of the month** (1 line).
216
227
  2. **The single most important open loop carrying into next month**, with
217
228
  a brief user-meaningful reason. Omit if Outstanding Items is empty.
@@ -232,7 +243,7 @@ days and is visibly slipping.
232
243
  - Priority `normal`. Respects quiet hours via the notify skill contract.
233
244
  - Exactly ONE notification via POST /api/notify. Do not split.
234
245
 
235
- #### 4d. Shape example (illustrative — translate to user's language)
246
+ #### 4d. Shape example (illustrative — render in the language `<output_language_policy>` resolves to)
236
247
  Good (something worth saying):
237
248
  Biggest win of April: Phase 1 of {APP_NAME} shipped on time.
238
249
  Still open: the Phase 2 scope call — you'll want a decision before week 2.